diff options
| author | Martin Jeřábek | 2024-02-25 18:01:28 +0100 |
|---|---|---|
| committer | Martin Hořeňovský | 2024-03-01 21:24:45 +0100 |
| commit | 4d8affc989cc13f60796f66781b8729d175c18e9 (patch) | |
| tree | c5ead1e093ba86da285f9fbe77c11236545a32b8 /tests/SelfTest/IntrospectiveTests/StringManip.tests.cpp | |
| parent | cde35096641d55b4aa0f743bb03e04703fbb5e9c (diff) | |
| download | catch3-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.cpp | 11 |
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, "'", "|'")); |