diff options
author | Hennadii Stepanov <32963518+hebasto@users.noreply.github.com> | 2022-08-08 11:20:48 +0100 |
---|---|---|
committer | Hennadii Stepanov <32963518+hebasto@users.noreply.github.com> | 2022-08-08 11:53:17 +0100 |
commit | 857526e8cbb0847a865e9c2509425960d458f535 (patch) | |
tree | c5c0670df3a37ea717de767e7e64a06faba2a477 /src/test/util_tests.cpp | |
parent | b1a2021f78099c17360dc2179cbcb948059b5969 (diff) |
test: Add test case for `ReplaceAll()` function
Diffstat (limited to 'src/test/util_tests.cpp')
-rw-r--r-- | src/test/util_tests.cpp | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/src/test/util_tests.cpp b/src/test/util_tests.cpp index fda56ccff7..70e2f89e0b 100644 --- a/src/test/util_tests.cpp +++ b/src/test/util_tests.cpp @@ -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"); |