From 4efaa6763a7eb3614b78fa09e676fe0630c34678 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?L=C5=91rinc?= Date: Thu, 20 Aug 2026 12:37:17 -0700 Subject: [PATCH] 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. --- src/test/util_tests.cpp | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/src/test/util_tests.cpp b/src/test/util_tests.cpp index 90510e3dec0..a2125c4ae1c 100644 --- a/src/test/util_tests.cpp +++ b/src/test/util_tests.cpp @@ -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)