mirror of
https://github.com/bitcoin/bitcoin.git
synced 2025-01-11 20:32:35 -03:00
test: Add test case for ReplaceAll()
function
This commit is contained in:
parent
b1a2021f78
commit
857526e8cb
1 changed files with 16 additions and 0 deletions
|
@ -249,6 +249,22 @@ BOOST_AUTO_TEST_CASE(util_Join)
|
|||
BOOST_CHECK_EQUAL(Join<std::string>({"foo", "bar"}, ", ", op_upper), "FOO, BAR");
|
||||
}
|
||||
|
||||
BOOST_AUTO_TEST_CASE(util_ReplaceAll)
|
||||
{
|
||||
const std::string original("A test \"%s\" string '%s'.");
|
||||
auto test_replaceall = [&original](const std::string& search, const std::string& substitute, const std::string& expected) {
|
||||
auto test = original;
|
||||
ReplaceAll(test, search, substitute);
|
||||
BOOST_CHECK_EQUAL(test, expected);
|
||||
};
|
||||
|
||||
test_replaceall("", "foo", original);
|
||||
test_replaceall(original, "foo", "foo");
|
||||
test_replaceall("%s", "foo", "A test \"foo\" string 'foo'.");
|
||||
test_replaceall("\"", "foo", "A test foo%sfoo string '%s'.");
|
||||
test_replaceall("'", "foo", "A test \"%s\" string foo%sfoo.");
|
||||
}
|
||||
|
||||
BOOST_AUTO_TEST_CASE(util_TrimString)
|
||||
{
|
||||
BOOST_CHECK_EQUAL(TrimString(" foo bar "), "foo bar");
|
||||
|
|
Loading…
Reference in a new issue