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:
Lőrinc
2026-08-20 12:37:17 -07:00
parent dc0395c585
commit 4efaa6763a

View File

@@ -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)