mirror of
https://github.com/catchorg/Catch2.git
synced 2025-08-01 21:05:39 +02:00
less copies and allocations in replaceInPlace
This commit is contained in:

committed by
Martin Hořeňovský

parent
cde3509664
commit
4d8affc989
@@ -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, "'", "|'"));
|
||||
|
Reference in New Issue
Block a user