Read-only mirrors. Development, issues and pull requests are on GitHub.

summaryrefslogtreecommitdiffhomepage
path: root/tests/SelfTest/IntrospectiveTests/StringManip.tests.cpp
diff options
context:
space:
mode:
authorMartin Jeřábek2024-02-25 18:01:28 +0100
committerMartin Hořeňovský2024-03-01 21:24:45 +0100
commit4d8affc989cc13f60796f66781b8729d175c18e9 (patch)
treec5ead1e093ba86da285f9fbe77c11236545a32b8 /tests/SelfTest/IntrospectiveTests/StringManip.tests.cpp
parentcde35096641d55b4aa0f743bb03e04703fbb5e9c (diff)
downloadcatch3-4d8affc989cc13f60796f66781b8729d175c18e9.tar.gz
less copies and allocations in replaceInPlace
Diffstat (limited to 'tests/SelfTest/IntrospectiveTests/StringManip.tests.cpp')
-rw-r--r--tests/SelfTest/IntrospectiveTests/StringManip.tests.cpp11
1 files changed, 11 insertions, 0 deletions
diff --git a/tests/SelfTest/IntrospectiveTests/StringManip.tests.cpp b/tests/SelfTest/IntrospectiveTests/StringManip.tests.cpp
index 36554ddc..f30573cc 100644
--- a/tests/SelfTest/IntrospectiveTests/StringManip.tests.cpp
+++ b/tests/SelfTest/IntrospectiveTests/StringManip.tests.cpp
@@ -57,6 +57,17 @@ TEST_CASE("replaceInPlace", "[string-manip]") {
CHECK_FALSE(Catch::replaceInPlace(letters, "x", "z"));
CHECK(letters == letters);
}
+ SECTION("no replace in already-replaced string") {
+ SECTION("lengthening") {
+ CHECK(Catch::replaceInPlace(letters, "c", "cc"));
+ CHECK(letters == "abccdefccg");
+ }
+ SECTION("shortening") {
+ std::string s = "----";
+ CHECK(Catch::replaceInPlace(s, "--", "-"));
+ CHECK(s == "--");
+ }
+ }
SECTION("escape '") {
std::string s = "didn't";
CHECK(Catch::replaceInPlace(s, "'", "|'"));