diff options
author | fanquake <fanquake@gmail.com> | 2022-08-16 09:15:17 +0100 |
---|---|---|
committer | fanquake <fanquake@gmail.com> | 2022-08-16 09:19:28 +0100 |
commit | cf39913e574857b8066795d33cb88ac5e45d05db (patch) | |
tree | 02df76ab292cdac9fa6a857e4bd58bf3b54c0cb8 /src/test | |
parent | b63c24a509adc1672176c0e3700f25eb1f369f20 (diff) | |
parent | fea75ad3caa29972db32d3ce7e0fe125ec77a0eb (diff) | |
download | bitcoin-cf39913e574857b8066795d33cb88ac5e45d05db.tar.xz |
Merge bitcoin/bitcoin#25803: refactor: Drop `boost/algorithm/string/replace.hpp` dependency
fea75ad3caa29972db32d3ce7e0fe125ec77a0eb refactor: Drop `boost/algorithm/string/replace.hpp` dependency (Hennadii Stepanov)
857526e8cbb0847a865e9c2509425960d458f535 test: Add test case for `ReplaceAll()` function (Hennadii Stepanov)
Pull request description:
A new implementation of the `ReplaceAll()` seems enough for all of our purposes.
ACKs for top commit:
adam2k:
ACK Tested fea75ad3caa29972db32d3ce7e0fe125ec77a0eb
theStack:
Code-review ACK fea75ad3caa29972db32d3ce7e0fe125ec77a0eb
Tree-SHA512: dacfffc9d2bd1fb9f034baf8c045b1e8657b766db2f0a7f8ef7e25ee6cd888f315b0124c54aba7a29ae59186b176ef9868a8b709dc995ea215c6b4ce58e174d9
Diffstat (limited to 'src/test')
-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"); |