mirror of
https://github.com/bitcoin/bitcoin.git
synced 2026-09-11 21:20:39 +02:00
test: simplify ReplaceAll coverage
Let each case provide its input so strings outside the original fixture can use the same table without separate temporary variables.
This commit is contained in:
@@ -300,17 +300,16 @@ BOOST_AUTO_TEST_CASE(util_Join)
|
||||
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;
|
||||
auto test_replaceall{[](std::string test, const std::string& search, const std::string& substitute, const std::string& expected) {
|
||||
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.");
|
||||
test_replaceall(original, "", "foo", original);
|
||||
test_replaceall(original, original, "foo", "foo");
|
||||
test_replaceall(original, "%s", "foo", "A test \"foo\" string 'foo'.");
|
||||
test_replaceall(original, "\"", "foo", "A test foo%sfoo string '%s'.");
|
||||
test_replaceall(original, "'", "foo", "A test \"%s\" string foo%sfoo.");
|
||||
}
|
||||
|
||||
BOOST_AUTO_TEST_CASE(util_TrimString)
|
||||
|
||||
Reference in New Issue
Block a user