Progmasoft Git

catch3

Progmasoft Catch3: an independently maintained C++17 test framework with a parallel runner, property checks, snapshots and structured results.

Clonegit clone https://git.progmasoft.com/catch3

less copies and allocations in replaceInPlace

Commit
4d8affc989cc13f60796f66781b8729d175c18e9
Author
Martin Jeřábek ·
Committer
Martin Hořeňovský
Parents
cde35096641d

Files · Download .tar.gz

Changes

 src/catch2/internal/catch_string_manip.cpp         | 27 ++++++--
 tests/SelfTest/Baselines/compact.sw.approved.txt   | 20 +++---
 .../Baselines/compact.sw.multi.approved.txt        | 20 +++---
 tests/SelfTest/Baselines/console.std.approved.txt  |  2 +-
 tests/SelfTest/Baselines/console.sw.approved.txt   | 66 ++++++++++++++-----
 .../Baselines/console.sw.multi.approved.txt        | 66 ++++++++++++++-----
 tests/SelfTest/Baselines/junit.sw.approved.txt     |  4 +-
 .../SelfTest/Baselines/junit.sw.multi.approved.txt |  4 +-
 tests/SelfTest/Baselines/sonarqube.sw.approved.txt |  2 +
 .../Baselines/sonarqube.sw.multi.approved.txt      |  2 +
 tests/SelfTest/Baselines/tap.sw.approved.txt       | 24 ++++---
 tests/SelfTest/Baselines/tap.sw.multi.approved.txt | 24 ++++---
 tests/SelfTest/Baselines/xml.sw.approved.txt       | 74 +++++++++++++++++-----
 tests/SelfTest/Baselines/xml.sw.multi.approved.txt | 74 +++++++++++++++++-----
 .../IntrospectiveTests/StringManip.tests.cpp       | 11 ++++
 15 files changed, 318 insertions(+), 102 deletions(-)

diff --git a/src/catch2/internal/catch_string_manip.cpp b/src/catch2/internal/catch_string_manip.cpp
index 0c889ca1..ce1abaa0 100644
--- a/src/catch2/internal/catch_string_manip.cpp
+++ b/src/catch2/internal/catch_string_manip.cpp
@@ -5,6 +5,7 @@
 //        https://www.boost.org/LICENSE_1_0.txt)
 
 // SPDX-License-Identifier: BSL-1.0
+#include <catch2/internal/catch_move_and_forward.hpp>
 #include <catch2/internal/catch_string_manip.hpp>
 #include <catch2/internal/catch_stringref.hpp>
 
@@ -65,17 +66,29 @@ namespace Catch {
     }
 
     bool replaceInPlace( std::string& str, std::string const& replaceThis, std::string const& withThis ) {
-        bool replaced = false;
         std::size_t i = str.find( replaceThis );
-        while( i != std::string::npos ) {
-            replaced = true;
-            str = str.substr( 0, i ) + withThis + str.substr( i+replaceThis.size() );
-            if( i < str.size()-withThis.size() )
-                i = str.find( replaceThis, i+withThis.size() );
+        if (i == std::string::npos) {
+            return false;
+        }
+        std::size_t copyBegin = 0;
+        std::string origStr = CATCH_MOVE(str);
+        str.clear();
+        // There is at least one replacement, so reserve with the best guess
+        // we can make without actually counting the number of occurences.
+        str.reserve(origStr.size() - replaceThis.size() + withThis.size());
+        do {
+            str.append(origStr, copyBegin, i-copyBegin );
+            str += withThis;
+            copyBegin = i + replaceThis.size();
+            if( copyBegin < origStr.size() )
+                i = origStr.find( replaceThis, copyBegin );
             else
                 i = std::string::npos;
+        } while( i != std::string::npos );
+        if ( copyBegin < origStr.size() ) {
+            str.append(origStr, copyBegin, origStr.size() );
         }
-        return replaced;
+        return true;
     }
 
     std::vector<StringRef> splitStringRef( StringRef str, char delimiter ) {
diff --git a/tests/SelfTest/Baselines/compact.sw.approved.txt b/tests/SelfTest/Baselines/compact.sw.approved.txt
index a6dd08de..037d7e9f 100644
--- a/tests/SelfTest/Baselines/compact.sw.approved.txt
+++ b/tests/SelfTest/Baselines/compact.sw.approved.txt
@@ -1733,13 +1733,13 @@ Tag.tests.cpp:<line number>: passed: testCase.tags, VectorContains( Tag( "tag wi
 Class.tests.cpp:<line number>: passed: Template_Fixture<TestType>::m_a == 1 for: 1 == 1
 Class.tests.cpp:<line number>: passed: Template_Fixture<TestType>::m_a == 1 for: 1 == 1
 Class.tests.cpp:<line number>: passed: Template_Fixture<TestType>::m_a == 1 for: 1.0 == 1
-Misc.tests.cpp:<line number>: passed: sizeof(TestType) > 0 for: 1 > 0
-Misc.tests.cpp:<line number>: passed: sizeof(TestType) > 0 for: 4 > 0
-Misc.tests.cpp:<line number>: passed: sizeof(TestType) > 0 for: 1 > 0
-Misc.tests.cpp:<line number>: passed: sizeof(TestType) > 0 for: 4 > 0
-Misc.tests.cpp:<line number>: passed: sizeof(TestType) > 0 for: 4 > 0
-Misc.tests.cpp:<line number>: passed: sizeof(TestType) > 0 for: 1 > 0
-Misc.tests.cpp:<line number>: passed: sizeof(TestType) > 0 for: 4 > 0
+Misc.tests.cpp:<line number>: passed: std::is_default_constructible<TestType>::value for: true
+Misc.tests.cpp:<line number>: passed: std::is_default_constructible<TestType>::value for: true
+Misc.tests.cpp:<line number>: passed: std::is_trivially_copyable<TestType>::value for: true
+Misc.tests.cpp:<line number>: passed: std::is_trivially_copyable<TestType>::value for: true
+Misc.tests.cpp:<line number>: passed: std::is_arithmetic<TestType>::value for: true
+Misc.tests.cpp:<line number>: passed: std::is_arithmetic<TestType>::value for: true
+Misc.tests.cpp:<line number>: passed: std::is_arithmetic<TestType>::value for: true
 Misc.tests.cpp:<line number>: passed: v.size() == 5 for: 5 == 5
 Misc.tests.cpp:<line number>: passed: v.capacity() >= 5 for: 5 >= 5
 Misc.tests.cpp:<line number>: passed: v.size() == 10 for: 10 == 10
@@ -2479,6 +2479,10 @@ StringManip.tests.cpp:<line number>: passed: Catch::replaceInPlace(letters, lett
 StringManip.tests.cpp:<line number>: passed: letters == "replaced" for: "replaced" == "replaced"
 StringManip.tests.cpp:<line number>: passed: !(Catch::replaceInPlace(letters, "x", "z")) for: !false
 StringManip.tests.cpp:<line number>: passed: letters == letters for: "abcdefcg" == "abcdefcg"
+StringManip.tests.cpp:<line number>: passed: Catch::replaceInPlace(letters, "c", "cc") for: true
+StringManip.tests.cpp:<line number>: passed: letters == "abccdefccg" for: "abccdefccg" == "abccdefccg"
+StringManip.tests.cpp:<line number>: passed: Catch::replaceInPlace(s, "--", "-") for: true
+StringManip.tests.cpp:<line number>: passed: s == "--" for: "--" == "--"
 StringManip.tests.cpp:<line number>: passed: Catch::replaceInPlace(s, "'", "|'") for: true
 StringManip.tests.cpp:<line number>: passed: s == "didn|'t" for: "didn|'t" == "didn|'t"
 Stream.tests.cpp:<line number>: passed: Catch::makeStream( "%somestream" )
@@ -2686,6 +2690,6 @@ InternalBenchmark.tests.cpp:<line number>: passed: q3 == 23. for: 23.0 == 23.0
 Misc.tests.cpp:<line number>: passed:
 Misc.tests.cpp:<line number>: passed:
 test cases:  417 |  312 passed |  85 failed | 6 skipped | 14 failed as expected
-assertions: 2256 | 2075 passed | 146 failed | 35 failed as expected
+assertions: 2260 | 2079 passed | 146 failed | 35 failed as expected
 
 
diff --git a/tests/SelfTest/Baselines/compact.sw.multi.approved.txt b/tests/SelfTest/Baselines/compact.sw.multi.approved.txt
index 9d4acc5a..b26546c1 100644
--- a/tests/SelfTest/Baselines/compact.sw.multi.approved.txt
+++ b/tests/SelfTest/Baselines/compact.sw.multi.approved.txt
@@ -1726,13 +1726,13 @@ Tag.tests.cpp:<line number>: passed: testCase.tags, VectorContains( Tag( "tag wi
 Class.tests.cpp:<line number>: passed: Template_Fixture<TestType>::m_a == 1 for: 1 == 1
 Class.tests.cpp:<line number>: passed: Template_Fixture<TestType>::m_a == 1 for: 1 == 1
 Class.tests.cpp:<line number>: passed: Template_Fixture<TestType>::m_a == 1 for: 1.0 == 1
-Misc.tests.cpp:<line number>: passed: sizeof(TestType) > 0 for: 1 > 0
-Misc.tests.cpp:<line number>: passed: sizeof(TestType) > 0 for: 4 > 0
-Misc.tests.cpp:<line number>: passed: sizeof(TestType) > 0 for: 1 > 0
-Misc.tests.cpp:<line number>: passed: sizeof(TestType) > 0 for: 4 > 0
-Misc.tests.cpp:<line number>: passed: sizeof(TestType) > 0 for: 4 > 0
-Misc.tests.cpp:<line number>: passed: sizeof(TestType) > 0 for: 1 > 0
-Misc.tests.cpp:<line number>: passed: sizeof(TestType) > 0 for: 4 > 0
+Misc.tests.cpp:<line number>: passed: std::is_default_constructible<TestType>::value for: true
+Misc.tests.cpp:<line number>: passed: std::is_default_constructible<TestType>::value for: true
+Misc.tests.cpp:<line number>: passed: std::is_trivially_copyable<TestType>::value for: true
+Misc.tests.cpp:<line number>: passed: std::is_trivially_copyable<TestType>::value for: true
+Misc.tests.cpp:<line number>: passed: std::is_arithmetic<TestType>::value for: true
+Misc.tests.cpp:<line number>: passed: std::is_arithmetic<TestType>::value for: true
+Misc.tests.cpp:<line number>: passed: std::is_arithmetic<TestType>::value for: true
 Misc.tests.cpp:<line number>: passed: v.size() == 5 for: 5 == 5
 Misc.tests.cpp:<line number>: passed: v.capacity() >= 5 for: 5 >= 5
 Misc.tests.cpp:<line number>: passed: v.size() == 10 for: 10 == 10
@@ -2468,6 +2468,10 @@ StringManip.tests.cpp:<line number>: passed: Catch::replaceInPlace(letters, lett
 StringManip.tests.cpp:<line number>: passed: letters == "replaced" for: "replaced" == "replaced"
 StringManip.tests.cpp:<line number>: passed: !(Catch::replaceInPlace(letters, "x", "z")) for: !false
 StringManip.tests.cpp:<line number>: passed: letters == letters for: "abcdefcg" == "abcdefcg"
+StringManip.tests.cpp:<line number>: passed: Catch::replaceInPlace(letters, "c", "cc") for: true
+StringManip.tests.cpp:<line number>: passed: letters == "abccdefccg" for: "abccdefccg" == "abccdefccg"
+StringManip.tests.cpp:<line number>: passed: Catch::replaceInPlace(s, "--", "-") for: true
+StringManip.tests.cpp:<line number>: passed: s == "--" for: "--" == "--"
 StringManip.tests.cpp:<line number>: passed: Catch::replaceInPlace(s, "'", "|'") for: true
 StringManip.tests.cpp:<line number>: passed: s == "didn|'t" for: "didn|'t" == "didn|'t"
 Stream.tests.cpp:<line number>: passed: Catch::makeStream( "%somestream" )
@@ -2675,6 +2679,6 @@ InternalBenchmark.tests.cpp:<line number>: passed: q3 == 23. for: 23.0 == 23.0
 Misc.tests.cpp:<line number>: passed:
 Misc.tests.cpp:<line number>: passed:
 test cases:  417 |  312 passed |  85 failed | 6 skipped | 14 failed as expected
-assertions: 2256 | 2075 passed | 146 failed | 35 failed as expected
+assertions: 2260 | 2079 passed | 146 failed | 35 failed as expected
 
 
diff --git a/tests/SelfTest/Baselines/console.std.approved.txt b/tests/SelfTest/Baselines/console.std.approved.txt
index e5ea2600..25426256 100644
--- a/tests/SelfTest/Baselines/console.std.approved.txt
+++ b/tests/SelfTest/Baselines/console.std.approved.txt
@@ -1589,5 +1589,5 @@ due to unexpected exception with message:
 
 ===============================================================================
 test cases:  417 |  326 passed |  70 failed | 7 skipped | 14 failed as expected
-assertions: 2239 | 2075 passed | 129 failed | 35 failed as expected
+assertions: 2243 | 2079 passed | 129 failed | 35 failed as expected
 
diff --git a/tests/SelfTest/Baselines/console.sw.approved.txt b/tests/SelfTest/Baselines/console.sw.approved.txt
index 6f7800b6..a14ead16 100644
--- a/tests/SelfTest/Baselines/console.sw.approved.txt
+++ b/tests/SelfTest/Baselines/console.sw.approved.txt
@@ -11655,9 +11655,9 @@ Misc.tests.cpp:<line number>
 ...............................................................................
 
 Misc.tests.cpp:<line number>: PASSED:
-  REQUIRE( sizeof(TestType) > 0 )
+  REQUIRE( std::is_default_constructible<TestType>::value )
 with expansion:
-  1 > 0
+  true
 
 -------------------------------------------------------------------------------
 Template test case with test types specified inside non-copyable and non-
@@ -11667,9 +11667,9 @@ Misc.tests.cpp:<line number>
 ...............................................................................
 
 Misc.tests.cpp:<line number>: PASSED:
-  REQUIRE( sizeof(TestType) > 0 )
+  REQUIRE( std::is_default_constructible<TestType>::value )
 with expansion:
-  4 > 0
+  true
 
 -------------------------------------------------------------------------------
 Template test case with test types specified inside non-default-constructible
@@ -11679,9 +11679,9 @@ Misc.tests.cpp:<line number>
 ...............................................................................
 
 Misc.tests.cpp:<line number>: PASSED:
-  REQUIRE( sizeof(TestType) > 0 )
+  REQUIRE( std::is_trivially_copyable<TestType>::value )
 with expansion:
-  1 > 0
+  true
 
 -------------------------------------------------------------------------------
 Template test case with test types specified inside non-default-constructible
@@ -11691,9 +11691,9 @@ Misc.tests.cpp:<line number>
 ...............................................................................
 
 Misc.tests.cpp:<line number>: PASSED:
-  REQUIRE( sizeof(TestType) > 0 )
+  REQUIRE( std::is_trivially_copyable<TestType>::value )
 with expansion:
-  4 > 0
+  true
 
 -------------------------------------------------------------------------------
 Template test case with test types specified inside std::tuple - MyTypes - 0
@@ -11702,9 +11702,9 @@ Misc.tests.cpp:<line number>
 ...............................................................................
 
 Misc.tests.cpp:<line number>: PASSED:
-  REQUIRE( sizeof(TestType) > 0 )
+  REQUIRE( std::is_arithmetic<TestType>::value )
 with expansion:
-  4 > 0
+  true
 
 -------------------------------------------------------------------------------
 Template test case with test types specified inside std::tuple - MyTypes - 1
@@ -11713,9 +11713,9 @@ Misc.tests.cpp:<line number>
 ...............................................................................
 
 Misc.tests.cpp:<line number>: PASSED:
-  REQUIRE( sizeof(TestType) > 0 )
+  REQUIRE( std::is_arithmetic<TestType>::value )
 with expansion:
-  1 > 0
+  true
 
 -------------------------------------------------------------------------------
 Template test case with test types specified inside std::tuple - MyTypes - 2
@@ -11724,9 +11724,9 @@ Misc.tests.cpp:<line number>
 ...............................................................................
 
 Misc.tests.cpp:<line number>: PASSED:
-  REQUIRE( sizeof(TestType) > 0 )
+  REQUIRE( std::is_arithmetic<TestType>::value )
 with expansion:
-  4 > 0
+  true
 
 -------------------------------------------------------------------------------
 TemplateTest: vectors can be sized and resized - float
@@ -17289,6 +17289,42 @@ StringManip.tests.cpp:<line number>: PASSED:
 with expansion:
   "abcdefcg" == "abcdefcg"
 
+-------------------------------------------------------------------------------
+replaceInPlace
+  no replace in already-replaced string
+  lengthening
+-------------------------------------------------------------------------------
+StringManip.tests.cpp:<line number>
+...............................................................................
+
+StringManip.tests.cpp:<line number>: PASSED:
+  CHECK( Catch::replaceInPlace(letters, "c", "cc") )
+with expansion:
+  true
+
+StringManip.tests.cpp:<line number>: PASSED:
+  CHECK( letters == "abccdefccg" )
+with expansion:
+  "abccdefccg" == "abccdefccg"
+
+-------------------------------------------------------------------------------
+replaceInPlace
+  no replace in already-replaced string
+  shortening
+-------------------------------------------------------------------------------
+StringManip.tests.cpp:<line number>
+...............................................................................
+
+StringManip.tests.cpp:<line number>: PASSED:
+  CHECK( Catch::replaceInPlace(s, "--", "-") )
+with expansion:
+  true
+
+StringManip.tests.cpp:<line number>: PASSED:
+  CHECK( s == "--" )
+with expansion:
+  "--" == "--"
+
 -------------------------------------------------------------------------------
 replaceInPlace
   escape '
@@ -18732,5 +18768,5 @@ Misc.tests.cpp:<line number>: PASSED:
 
 ===============================================================================
 test cases:  417 |  312 passed |  85 failed | 6 skipped | 14 failed as expected
-assertions: 2256 | 2075 passed | 146 failed | 35 failed as expected
+assertions: 2260 | 2079 passed | 146 failed | 35 failed as expected
 
diff --git a/tests/SelfTest/Baselines/console.sw.multi.approved.txt b/tests/SelfTest/Baselines/console.sw.multi.approved.txt
index 78804405..b706c566 100644
--- a/tests/SelfTest/Baselines/console.sw.multi.approved.txt
+++ b/tests/SelfTest/Baselines/console.sw.multi.approved.txt
@@ -11648,9 +11648,9 @@ Misc.tests.cpp:<line number>
 ...............................................................................
 
 Misc.tests.cpp:<line number>: PASSED:
-  REQUIRE( sizeof(TestType) > 0 )
+  REQUIRE( std::is_default_constructible<TestType>::value )
 with expansion:
-  1 > 0
+  true
 
 -------------------------------------------------------------------------------
 Template test case with test types specified inside non-copyable and non-
@@ -11660,9 +11660,9 @@ Misc.tests.cpp:<line number>
 ...............................................................................
 
 Misc.tests.cpp:<line number>: PASSED:
-  REQUIRE( sizeof(TestType) > 0 )
+  REQUIRE( std::is_default_constructible<TestType>::value )
 with expansion:
-  4 > 0
+  true
 
 -------------------------------------------------------------------------------
 Template test case with test types specified inside non-default-constructible
@@ -11672,9 +11672,9 @@ Misc.tests.cpp:<line number>
 ...............................................................................
 
 Misc.tests.cpp:<line number>: PASSED:
-  REQUIRE( sizeof(TestType) > 0 )
+  REQUIRE( std::is_trivially_copyable<TestType>::value )
 with expansion:
-  1 > 0
+  true
 
 -------------------------------------------------------------------------------
 Template test case with test types specified inside non-default-constructible
@@ -11684,9 +11684,9 @@ Misc.tests.cpp:<line number>
 ...............................................................................
 
 Misc.tests.cpp:<line number>: PASSED:
-  REQUIRE( sizeof(TestType) > 0 )
+  REQUIRE( std::is_trivially_copyable<TestType>::value )
 with expansion:
-  4 > 0
+  true
 
 -------------------------------------------------------------------------------
 Template test case with test types specified inside std::tuple - MyTypes - 0
@@ -11695,9 +11695,9 @@ Misc.tests.cpp:<line number>
 ...............................................................................
 
 Misc.tests.cpp:<line number>: PASSED:
-  REQUIRE( sizeof(TestType) > 0 )
+  REQUIRE( std::is_arithmetic<TestType>::value )
 with expansion:
-  4 > 0
+  true
 
 -------------------------------------------------------------------------------
 Template test case with test types specified inside std::tuple - MyTypes - 1
@@ -11706,9 +11706,9 @@ Misc.tests.cpp:<line number>
 ...............................................................................
 
 Misc.tests.cpp:<line number>: PASSED:
-  REQUIRE( sizeof(TestType) > 0 )
+  REQUIRE( std::is_arithmetic<TestType>::value )
 with expansion:
-  1 > 0
+  true
 
 -------------------------------------------------------------------------------
 Template test case with test types specified inside std::tuple - MyTypes - 2
@@ -11717,9 +11717,9 @@ Misc.tests.cpp:<line number>
 ...............................................................................
 
 Misc.tests.cpp:<line number>: PASSED:
-  REQUIRE( sizeof(TestType) > 0 )
+  REQUIRE( std::is_arithmetic<TestType>::value )
 with expansion:
-  4 > 0
+  true
 
 -------------------------------------------------------------------------------
 TemplateTest: vectors can be sized and resized - float
@@ -17278,6 +17278,42 @@ StringManip.tests.cpp:<line number>: PASSED:
 with expansion:
   "abcdefcg" == "abcdefcg"
 
+-------------------------------------------------------------------------------
+replaceInPlace
+  no replace in already-replaced string
+  lengthening
+-------------------------------------------------------------------------------
+StringManip.tests.cpp:<line number>
+...............................................................................
+
+StringManip.tests.cpp:<line number>: PASSED:
+  CHECK( Catch::replaceInPlace(letters, "c", "cc") )
+with expansion:
+  true
+
+StringManip.tests.cpp:<line number>: PASSED:
+  CHECK( letters == "abccdefccg" )
+with expansion:
+  "abccdefccg" == "abccdefccg"
+
+-------------------------------------------------------------------------------
+replaceInPlace
+  no replace in already-replaced string
+  shortening
+-------------------------------------------------------------------------------
+StringManip.tests.cpp:<line number>
+...............................................................................
+
+StringManip.tests.cpp:<line number>: PASSED:
+  CHECK( Catch::replaceInPlace(s, "--", "-") )
+with expansion:
+  true
+
+StringManip.tests.cpp:<line number>: PASSED:
+  CHECK( s == "--" )
+with expansion:
+  "--" == "--"
+
 -------------------------------------------------------------------------------
 replaceInPlace
   escape '
@@ -18721,5 +18757,5 @@ Misc.tests.cpp:<line number>: PASSED:
 
 ===============================================================================
 test cases:  417 |  312 passed |  85 failed | 6 skipped | 14 failed as expected
-assertions: 2256 | 2075 passed | 146 failed | 35 failed as expected
+assertions: 2260 | 2079 passed | 146 failed | 35 failed as expected
 
diff --git a/tests/SelfTest/Baselines/junit.sw.approved.txt b/tests/SelfTest/Baselines/junit.sw.approved.txt
index 39d1149a..bd08461a 100644
--- a/tests/SelfTest/Baselines/junit.sw.approved.txt
+++ b/tests/SelfTest/Baselines/junit.sw.approved.txt
@@ -1,7 +1,7 @@
 <?xml version="1.0" encoding="UTF-8"?>
 <testsuitesloose text artifact
 >
-  <testsuite name="<exe-name>" errors="17" failures="129" skipped="12" tests="2268" hostname="tbd" time="{duration}" timestamp="{iso8601-timestamp}">
+  <testsuite name="<exe-name>" errors="17" failures="129" skipped="12" tests="2272" hostname="tbd" time="{duration}" timestamp="{iso8601-timestamp}">
     <properties>
       <property name="random-seed" value="1"/>
       <property name="filters" value="&quot;*&quot; ~[!nonportable] ~[!benchmark] ~[approvals]"/>
@@ -1966,6 +1966,8 @@ at Message.tests.cpp:<line number>
     <testcase classname="<exe-name>.global" name="replaceInPlace/replace last char" time="{duration}" status="run"/>
     <testcase classname="<exe-name>.global" name="replaceInPlace/replace all chars" time="{duration}" status="run"/>
     <testcase classname="<exe-name>.global" name="replaceInPlace/replace no chars" time="{duration}" status="run"/>
+    <testcase classname="<exe-name>.global" name="replaceInPlace/no replace in already-replaced string/lengthening" time="{duration}" status="run"/>
+    <testcase classname="<exe-name>.global" name="replaceInPlace/no replace in already-replaced string/shortening" time="{duration}" status="run"/>
     <testcase classname="<exe-name>.global" name="replaceInPlace/escape '" time="{duration}" status="run"/>
     <testcase classname="<exe-name>.global" name="request an unknown %-starting stream fails" time="{duration}" status="run"/>
     <testcase classname="<exe-name>.global" name="resolution" time="{duration}" status="run"/>
diff --git a/tests/SelfTest/Baselines/junit.sw.multi.approved.txt b/tests/SelfTest/Baselines/junit.sw.multi.approved.txt
index 8a7e0382..052ffd9e 100644
--- a/tests/SelfTest/Baselines/junit.sw.multi.approved.txt
+++ b/tests/SelfTest/Baselines/junit.sw.multi.approved.txt
@@ -1,6 +1,6 @@
 <?xml version="1.0" encoding="UTF-8"?>
 <testsuites>
-  <testsuite name="<exe-name>" errors="17" failures="129" skipped="12" tests="2268" hostname="tbd" time="{duration}" timestamp="{iso8601-timestamp}">
+  <testsuite name="<exe-name>" errors="17" failures="129" skipped="12" tests="2272" hostname="tbd" time="{duration}" timestamp="{iso8601-timestamp}">
     <properties>
       <property name="random-seed" value="1"/>
       <property name="filters" value="&quot;*&quot; ~[!nonportable] ~[!benchmark] ~[approvals]"/>
@@ -1965,6 +1965,8 @@ at Message.tests.cpp:<line number>
     <testcase classname="<exe-name>.global" name="replaceInPlace/replace last char" time="{duration}" status="run"/>
     <testcase classname="<exe-name>.global" name="replaceInPlace/replace all chars" time="{duration}" status="run"/>
     <testcase classname="<exe-name>.global" name="replaceInPlace/replace no chars" time="{duration}" status="run"/>
+    <testcase classname="<exe-name>.global" name="replaceInPlace/no replace in already-replaced string/lengthening" time="{duration}" status="run"/>
+    <testcase classname="<exe-name>.global" name="replaceInPlace/no replace in already-replaced string/shortening" time="{duration}" status="run"/>
     <testcase classname="<exe-name>.global" name="replaceInPlace/escape '" time="{duration}" status="run"/>
     <testcase classname="<exe-name>.global" name="request an unknown %-starting stream fails" time="{duration}" status="run"/>
     <testcase classname="<exe-name>.global" name="resolution" time="{duration}" status="run"/>
diff --git a/tests/SelfTest/Baselines/sonarqube.sw.approved.txt b/tests/SelfTest/Baselines/sonarqube.sw.approved.txt
index 36b05e54..3db09ec0 100644
--- a/tests/SelfTest/Baselines/sonarqube.sw.approved.txt
+++ b/tests/SelfTest/Baselines/sonarqube.sw.approved.txt
@@ -262,6 +262,8 @@ at AssertionHandler.tests.cpp:<line number>
     <testCase name="replaceInPlace/replace last char" duration="{duration}"/>
     <testCase name="replaceInPlace/replace all chars" duration="{duration}"/>
     <testCase name="replaceInPlace/replace no chars" duration="{duration}"/>
+    <testCase name="replaceInPlace/no replace in already-replaced string/lengthening" duration="{duration}"/>
+    <testCase name="replaceInPlace/no replace in already-replaced string/shortening" duration="{duration}"/>
     <testCase name="replaceInPlace/escape '" duration="{duration}"/>
     <testCase name="splitString" duration="{duration}"/>
     <testCase name="startsWith" duration="{duration}"/>
diff --git a/tests/SelfTest/Baselines/sonarqube.sw.multi.approved.txt b/tests/SelfTest/Baselines/sonarqube.sw.multi.approved.txt
index c9d3d205..f5305eb3 100644
--- a/tests/SelfTest/Baselines/sonarqube.sw.multi.approved.txt
+++ b/tests/SelfTest/Baselines/sonarqube.sw.multi.approved.txt
@@ -261,6 +261,8 @@ at AssertionHandler.tests.cpp:<line number>
     <testCase name="replaceInPlace/replace last char" duration="{duration}"/>
     <testCase name="replaceInPlace/replace all chars" duration="{duration}"/>
     <testCase name="replaceInPlace/replace no chars" duration="{duration}"/>
+    <testCase name="replaceInPlace/no replace in already-replaced string/lengthening" duration="{duration}"/>
+    <testCase name="replaceInPlace/no replace in already-replaced string/shortening" duration="{duration}"/>
     <testCase name="replaceInPlace/escape '" duration="{duration}"/>
     <testCase name="splitString" duration="{duration}"/>
     <testCase name="startsWith" duration="{duration}"/>
diff --git a/tests/SelfTest/Baselines/tap.sw.approved.txt b/tests/SelfTest/Baselines/tap.sw.approved.txt
index 9b759596..7ece3f86 100644
--- a/tests/SelfTest/Baselines/tap.sw.approved.txt
+++ b/tests/SelfTest/Baselines/tap.sw.approved.txt
@@ -2804,19 +2804,19 @@ ok {test-number} - Template_Fixture<TestType>::m_a == 1 for: 1 == 1
 # Template test case method with test types specified inside std::tuple - MyTypes - 2
 ok {test-number} - Template_Fixture<TestType>::m_a == 1 for: 1.0 == 1
 # Template test case with test types specified inside non-copyable and non-movable std::tuple - NonCopyableAndNonMovableTypes - 0
-ok {test-number} - sizeof(TestType) > 0 for: 1 > 0
+ok {test-number} - std::is_default_constructible<TestType>::value for: true
 # Template test case with test types specified inside non-copyable and non-movable std::tuple - NonCopyableAndNonMovableTypes - 1
-ok {test-number} - sizeof(TestType) > 0 for: 4 > 0
+ok {test-number} - std::is_default_constructible<TestType>::value for: true
 # Template test case with test types specified inside non-default-constructible std::tuple - MyNonDefaultConstructibleTypes - 0
-ok {test-number} - sizeof(TestType) > 0 for: 1 > 0
+ok {test-number} - std::is_trivially_copyable<TestType>::value for: true
 # Template test case with test types specified inside non-default-constructible std::tuple - MyNonDefaultConstructibleTypes - 1
-ok {test-number} - sizeof(TestType) > 0 for: 4 > 0
+ok {test-number} - std::is_trivially_copyable<TestType>::value for: true
 # Template test case with test types specified inside std::tuple - MyTypes - 0
-ok {test-number} - sizeof(TestType) > 0 for: 4 > 0
+ok {test-number} - std::is_arithmetic<TestType>::value for: true
 # Template test case with test types specified inside std::tuple - MyTypes - 1
-ok {test-number} - sizeof(TestType) > 0 for: 1 > 0
+ok {test-number} - std::is_arithmetic<TestType>::value for: true
 # Template test case with test types specified inside std::tuple - MyTypes - 2
-ok {test-number} - sizeof(TestType) > 0 for: 4 > 0
+ok {test-number} - std::is_arithmetic<TestType>::value for: true
 # TemplateTest: vectors can be sized and resized - float
 ok {test-number} - v.size() == 5 for: 5 == 5
 # TemplateTest: vectors can be sized and resized - float
@@ -4198,6 +4198,14 @@ ok {test-number} - !(Catch::replaceInPlace(letters, "x", "z")) for: !false
 # replaceInPlace
 ok {test-number} - letters == letters for: "abcdefcg" == "abcdefcg"
 # replaceInPlace
+ok {test-number} - Catch::replaceInPlace(letters, "c", "cc") for: true
+# replaceInPlace
+ok {test-number} - letters == "abccdefccg" for: "abccdefccg" == "abccdefccg"
+# replaceInPlace
+ok {test-number} - Catch::replaceInPlace(s, "--", "-") for: true
+# replaceInPlace
+ok {test-number} - s == "--" for: "--" == "--"
+# replaceInPlace
 ok {test-number} - Catch::replaceInPlace(s, "'", "|'") for: true
 # replaceInPlace
 ok {test-number} - s == "didn|'t" for: "didn|'t" == "didn|'t"
@@ -4541,5 +4549,5 @@ ok {test-number} - q3 == 23. for: 23.0 == 23.0
 ok {test-number} -
 # xmlentitycheck
 ok {test-number} -
-1..2268
+1..2272
 
diff --git a/tests/SelfTest/Baselines/tap.sw.multi.approved.txt b/tests/SelfTest/Baselines/tap.sw.multi.approved.txt
index 49a87c11..2dfcb652 100644
--- a/tests/SelfTest/Baselines/tap.sw.multi.approved.txt
+++ b/tests/SelfTest/Baselines/tap.sw.multi.approved.txt
@@ -2797,19 +2797,19 @@ ok {test-number} - Template_Fixture<TestType>::m_a == 1 for: 1 == 1
 # Template test case method with test types specified inside std::tuple - MyTypes - 2
 ok {test-number} - Template_Fixture<TestType>::m_a == 1 for: 1.0 == 1
 # Template test case with test types specified inside non-copyable and non-movable std::tuple - NonCopyableAndNonMovableTypes - 0
-ok {test-number} - sizeof(TestType) > 0 for: 1 > 0
+ok {test-number} - std::is_default_constructible<TestType>::value for: true
 # Template test case with test types specified inside non-copyable and non-movable std::tuple - NonCopyableAndNonMovableTypes - 1
-ok {test-number} - sizeof(TestType) > 0 for: 4 > 0
+ok {test-number} - std::is_default_constructible<TestType>::value for: true
 # Template test case with test types specified inside non-default-constructible std::tuple - MyNonDefaultConstructibleTypes - 0
-ok {test-number} - sizeof(TestType) > 0 for: 1 > 0
+ok {test-number} - std::is_trivially_copyable<TestType>::value for: true
 # Template test case with test types specified inside non-default-constructible std::tuple - MyNonDefaultConstructibleTypes - 1
-ok {test-number} - sizeof(TestType) > 0 for: 4 > 0
+ok {test-number} - std::is_trivially_copyable<TestType>::value for: true
 # Template test case with test types specified inside std::tuple - MyTypes - 0
-ok {test-number} - sizeof(TestType) > 0 for: 4 > 0
+ok {test-number} - std::is_arithmetic<TestType>::value for: true
 # Template test case with test types specified inside std::tuple - MyTypes - 1
-ok {test-number} - sizeof(TestType) > 0 for: 1 > 0
+ok {test-number} - std::is_arithmetic<TestType>::value for: true
 # Template test case with test types specified inside std::tuple - MyTypes - 2
-ok {test-number} - sizeof(TestType) > 0 for: 4 > 0
+ok {test-number} - std::is_arithmetic<TestType>::value for: true
 # TemplateTest: vectors can be sized and resized - float
 ok {test-number} - v.size() == 5 for: 5 == 5
 # TemplateTest: vectors can be sized and resized - float
@@ -4187,6 +4187,14 @@ ok {test-number} - !(Catch::replaceInPlace(letters, "x", "z")) for: !false
 # replaceInPlace
 ok {test-number} - letters == letters for: "abcdefcg" == "abcdefcg"
 # replaceInPlace
+ok {test-number} - Catch::replaceInPlace(letters, "c", "cc") for: true
+# replaceInPlace
+ok {test-number} - letters == "abccdefccg" for: "abccdefccg" == "abccdefccg"
+# replaceInPlace
+ok {test-number} - Catch::replaceInPlace(s, "--", "-") for: true
+# replaceInPlace
+ok {test-number} - s == "--" for: "--" == "--"
+# replaceInPlace
 ok {test-number} - Catch::replaceInPlace(s, "'", "|'") for: true
 # replaceInPlace
 ok {test-number} - s == "didn|'t" for: "didn|'t" == "didn|'t"
@@ -4530,5 +4538,5 @@ ok {test-number} - q3 == 23. for: 23.0 == 23.0
 ok {test-number} -
 # xmlentitycheck
 ok {test-number} -
-1..2268
+1..2272
 
diff --git a/tests/SelfTest/Baselines/xml.sw.approved.txt b/tests/SelfTest/Baselines/xml.sw.approved.txt
index a083c7f5..01af9edd 100644
--- a/tests/SelfTest/Baselines/xml.sw.approved.txt
+++ b/tests/SelfTest/Baselines/xml.sw.approved.txt
@@ -13560,10 +13560,10 @@ Message from section two
   <TestCase name="Template test case with test types specified inside non-copyable and non-movable std::tuple - NonCopyableAndNonMovableTypes - 0" tags="[list][template]" filename="tests/<exe-name>/UsageTests/Misc.tests.cpp" >
     <Expression success="true" type="REQUIRE" filename="tests/<exe-name>/UsageTests/Misc.tests.cpp" >
       <Original>
-        sizeof(TestType) > 0
+        std::is_default_constructible&lt;TestType>::value
       </Original>
       <Expanded>
-        1 > 0
+        true
       </Expanded>
     </Expression>
     <OverallResult success="true" skips="0"/>
@@ -13571,10 +13571,10 @@ Message from section two
   <TestCase name="Template test case with test types specified inside non-copyable and non-movable std::tuple - NonCopyableAndNonMovableTypes - 1" tags="[list][template]" filename="tests/<exe-name>/UsageTests/Misc.tests.cpp" >
     <Expression success="true" type="REQUIRE" filename="tests/<exe-name>/UsageTests/Misc.tests.cpp" >
       <Original>
-        sizeof(TestType) > 0
+        std::is_default_constructible&lt;TestType>::value
       </Original>
       <Expanded>
-        4 > 0
+        true
       </Expanded>
     </Expression>
     <OverallResult success="true" skips="0"/>
@@ -13582,10 +13582,10 @@ Message from section two
   <TestCase name="Template test case with test types specified inside non-default-constructible std::tuple - MyNonDefaultConstructibleTypes - 0" tags="[list][template]" filename="tests/<exe-name>/UsageTests/Misc.tests.cpp" >
     <Expression success="true" type="REQUIRE" filename="tests/<exe-name>/UsageTests/Misc.tests.cpp" >
       <Original>
-        sizeof(TestType) > 0
+        std::is_trivially_copyable&lt;TestType>::value
       </Original>
       <Expanded>
-        1 > 0
+        true
       </Expanded>
     </Expression>
     <OverallResult success="true" skips="0"/>
@@ -13593,10 +13593,10 @@ Message from section two
   <TestCase name="Template test case with test types specified inside non-default-constructible std::tuple - MyNonDefaultConstructibleTypes - 1" tags="[list][template]" filename="tests/<exe-name>/UsageTests/Misc.tests.cpp" >
     <Expression success="true" type="REQUIRE" filename="tests/<exe-name>/UsageTests/Misc.tests.cpp" >
       <Original>
-        sizeof(TestType) > 0
+        std::is_trivially_copyable&lt;TestType>::value
       </Original>
       <Expanded>
-        4 > 0
+        true
       </Expanded>
     </Expression>
     <OverallResult success="true" skips="0"/>
@@ -13604,10 +13604,10 @@ Message from section two
   <TestCase name="Template test case with test types specified inside std::tuple - MyTypes - 0" tags="[list][template]" filename="tests/<exe-name>/UsageTests/Misc.tests.cpp" >
     <Expression success="true" type="REQUIRE" filename="tests/<exe-name>/UsageTests/Misc.tests.cpp" >
       <Original>
-        sizeof(TestType) > 0
+        std::is_arithmetic&lt;TestType>::value
       </Original>
       <Expanded>
-        4 > 0
+        true
       </Expanded>
     </Expression>
     <OverallResult success="true" skips="0"/>
@@ -13615,10 +13615,10 @@ Message from section two
   <TestCase name="Template test case with test types specified inside std::tuple - MyTypes - 1" tags="[list][template]" filename="tests/<exe-name>/UsageTests/Misc.tests.cpp" >
     <Expression success="true" type="REQUIRE" filename="tests/<exe-name>/UsageTests/Misc.tests.cpp" >
       <Original>
-        sizeof(TestType) > 0
+        std::is_arithmetic&lt;TestType>::value
       </Original>
       <Expanded>
-        1 > 0
+        true
       </Expanded>
     </Expression>
     <OverallResult success="true" skips="0"/>
@@ -13626,10 +13626,10 @@ Message from section two
   <TestCase name="Template test case with test types specified inside std::tuple - MyTypes - 2" tags="[list][template]" filename="tests/<exe-name>/UsageTests/Misc.tests.cpp" >
     <Expression success="true" type="REQUIRE" filename="tests/<exe-name>/UsageTests/Misc.tests.cpp" >
       <Original>
-        sizeof(TestType) > 0
+        std::is_arithmetic&lt;TestType>::value
       </Original>
       <Expanded>
-        4 > 0
+        true
       </Expanded>
     </Expression>
     <OverallResult success="true" skips="0"/>
@@ -20034,6 +20034,50 @@ b1!
       </Expression>
       <OverallResults successes="2" failures="0" expectedFailures="0" skipped="false"/>
     </Section>
+    <Section name="no replace in already-replaced string" filename="tests/<exe-name>/IntrospectiveTests/StringManip.tests.cpp" >
+      <Section name="lengthening" filename="tests/<exe-name>/IntrospectiveTests/StringManip.tests.cpp" >
+        <Expression success="true" type="CHECK" filename="tests/<exe-name>/IntrospectiveTests/StringManip.tests.cpp" >
+          <Original>
+            Catch::replaceInPlace(letters, "c", "cc")
+          </Original>
+          <Expanded>
+            true
+          </Expanded>
+        </Expression>
+        <Expression success="true" type="CHECK" filename="tests/<exe-name>/IntrospectiveTests/StringManip.tests.cpp" >
+          <Original>
+            letters == "abccdefccg"
+          </Original>
+          <Expanded>
+            "abccdefccg" == "abccdefccg"
+          </Expanded>
+        </Expression>
+        <OverallResults successes="2" failures="0" expectedFailures="0" skipped="false"/>
+      </Section>
+      <OverallResults successes="2" failures="0" expectedFailures="0" skipped="false"/>
+    </Section>
+    <Section name="no replace in already-replaced string" filename="tests/<exe-name>/IntrospectiveTests/StringManip.tests.cpp" >
+      <Section name="shortening" filename="tests/<exe-name>/IntrospectiveTests/StringManip.tests.cpp" >
+        <Expression success="true" type="CHECK" filename="tests/<exe-name>/IntrospectiveTests/StringManip.tests.cpp" >
+          <Original>
+            Catch::replaceInPlace(s, "--", "-")
+          </Original>
+          <Expanded>
+            true
+          </Expanded>
+        </Expression>
+        <Expression success="true" type="CHECK" filename="tests/<exe-name>/IntrospectiveTests/StringManip.tests.cpp" >
+          <Original>
+            s == "--"
+          </Original>
+          <Expanded>
+            "--" == "--"
+          </Expanded>
+        </Expression>
+        <OverallResults successes="2" failures="0" expectedFailures="0" skipped="false"/>
+      </Section>
+      <OverallResults successes="2" failures="0" expectedFailures="0" skipped="false"/>
+    </Section>
     <Section name="escape '" filename="tests/<exe-name>/IntrospectiveTests/StringManip.tests.cpp" >
       <Expression success="true" type="CHECK" filename="tests/<exe-name>/IntrospectiveTests/StringManip.tests.cpp" >
         <Original>
@@ -21675,6 +21719,6 @@ b1!
     </Section>
     <OverallResult success="true" skips="0"/>
   </TestCase>
-  <OverallResults successes="2075" failures="146" expectedFailures="35" skips="12"/>
+  <OverallResults successes="2079" failures="146" expectedFailures="35" skips="12"/>
   <OverallResultsCases successes="312" failures="85" expectedFailures="14" skips="6"/>
 </Catch2TestRun>
diff --git a/tests/SelfTest/Baselines/xml.sw.multi.approved.txt b/tests/SelfTest/Baselines/xml.sw.multi.approved.txt
index f11997c5..6c50a996 100644
--- a/tests/SelfTest/Baselines/xml.sw.multi.approved.txt
+++ b/tests/SelfTest/Baselines/xml.sw.multi.approved.txt
@@ -13560,10 +13560,10 @@ Message from section two
   <TestCase name="Template test case with test types specified inside non-copyable and non-movable std::tuple - NonCopyableAndNonMovableTypes - 0" tags="[list][template]" filename="tests/<exe-name>/UsageTests/Misc.tests.cpp" >
     <Expression success="true" type="REQUIRE" filename="tests/<exe-name>/UsageTests/Misc.tests.cpp" >
       <Original>
-        sizeof(TestType) > 0
+        std::is_default_constructible&lt;TestType>::value
       </Original>
       <Expanded>
-        1 > 0
+        true
       </Expanded>
     </Expression>
     <OverallResult success="true" skips="0"/>
@@ -13571,10 +13571,10 @@ Message from section two
   <TestCase name="Template test case with test types specified inside non-copyable and non-movable std::tuple - NonCopyableAndNonMovableTypes - 1" tags="[list][template]" filename="tests/<exe-name>/UsageTests/Misc.tests.cpp" >
     <Expression success="true" type="REQUIRE" filename="tests/<exe-name>/UsageTests/Misc.tests.cpp" >
       <Original>
-        sizeof(TestType) > 0
+        std::is_default_constructible&lt;TestType>::value
       </Original>
       <Expanded>
-        4 > 0
+        true
       </Expanded>
     </Expression>
     <OverallResult success="true" skips="0"/>
@@ -13582,10 +13582,10 @@ Message from section two
   <TestCase name="Template test case with test types specified inside non-default-constructible std::tuple - MyNonDefaultConstructibleTypes - 0" tags="[list][template]" filename="tests/<exe-name>/UsageTests/Misc.tests.cpp" >
     <Expression success="true" type="REQUIRE" filename="tests/<exe-name>/UsageTests/Misc.tests.cpp" >
       <Original>
-        sizeof(TestType) > 0
+        std::is_trivially_copyable&lt;TestType>::value
       </Original>
       <Expanded>
-        1 > 0
+        true
       </Expanded>
     </Expression>
     <OverallResult success="true" skips="0"/>
@@ -13593,10 +13593,10 @@ Message from section two
   <TestCase name="Template test case with test types specified inside non-default-constructible std::tuple - MyNonDefaultConstructibleTypes - 1" tags="[list][template]" filename="tests/<exe-name>/UsageTests/Misc.tests.cpp" >
     <Expression success="true" type="REQUIRE" filename="tests/<exe-name>/UsageTests/Misc.tests.cpp" >
       <Original>
-        sizeof(TestType) > 0
+        std::is_trivially_copyable&lt;TestType>::value
       </Original>
       <Expanded>
-        4 > 0
+        true
       </Expanded>
     </Expression>
     <OverallResult success="true" skips="0"/>
@@ -13604,10 +13604,10 @@ Message from section two
   <TestCase name="Template test case with test types specified inside std::tuple - MyTypes - 0" tags="[list][template]" filename="tests/<exe-name>/UsageTests/Misc.tests.cpp" >
     <Expression success="true" type="REQUIRE" filename="tests/<exe-name>/UsageTests/Misc.tests.cpp" >
       <Original>
-        sizeof(TestType) > 0
+        std::is_arithmetic&lt;TestType>::value
       </Original>
       <Expanded>
-        4 > 0
+        true
       </Expanded>
     </Expression>
     <OverallResult success="true" skips="0"/>
@@ -13615,10 +13615,10 @@ Message from section two
   <TestCase name="Template test case with test types specified inside std::tuple - MyTypes - 1" tags="[list][template]" filename="tests/<exe-name>/UsageTests/Misc.tests.cpp" >
     <Expression success="true" type="REQUIRE" filename="tests/<exe-name>/UsageTests/Misc.tests.cpp" >
       <Original>
-        sizeof(TestType) > 0
+        std::is_arithmetic&lt;TestType>::value
       </Original>
       <Expanded>
-        1 > 0
+        true
       </Expanded>
     </Expression>
     <OverallResult success="true" skips="0"/>
@@ -13626,10 +13626,10 @@ Message from section two
   <TestCase name="Template test case with test types specified inside std::tuple - MyTypes - 2" tags="[list][template]" filename="tests/<exe-name>/UsageTests/Misc.tests.cpp" >
     <Expression success="true" type="REQUIRE" filename="tests/<exe-name>/UsageTests/Misc.tests.cpp" >
       <Original>
-        sizeof(TestType) > 0
+        std::is_arithmetic&lt;TestType>::value
       </Original>
       <Expanded>
-        4 > 0
+        true
       </Expanded>
     </Expression>
     <OverallResult success="true" skips="0"/>
@@ -20033,6 +20033,50 @@ b1!
       </Expression>
       <OverallResults successes="2" failures="0" expectedFailures="0" skipped="false"/>
     </Section>
+    <Section name="no replace in already-replaced string" filename="tests/<exe-name>/IntrospectiveTests/StringManip.tests.cpp" >
+      <Section name="lengthening" filename="tests/<exe-name>/IntrospectiveTests/StringManip.tests.cpp" >
+        <Expression success="true" type="CHECK" filename="tests/<exe-name>/IntrospectiveTests/StringManip.tests.cpp" >
+          <Original>
+            Catch::replaceInPlace(letters, "c", "cc")
+          </Original>
+          <Expanded>
+            true
+          </Expanded>
+        </Expression>
+        <Expression success="true" type="CHECK" filename="tests/<exe-name>/IntrospectiveTests/StringManip.tests.cpp" >
+          <Original>
+            letters == "abccdefccg"
+          </Original>
+          <Expanded>
+            "abccdefccg" == "abccdefccg"
+          </Expanded>
+        </Expression>
+        <OverallResults successes="2" failures="0" expectedFailures="0" skipped="false"/>
+      </Section>
+      <OverallResults successes="2" failures="0" expectedFailures="0" skipped="false"/>
+    </Section>
+    <Section name="no replace in already-replaced string" filename="tests/<exe-name>/IntrospectiveTests/StringManip.tests.cpp" >
+      <Section name="shortening" filename="tests/<exe-name>/IntrospectiveTests/StringManip.tests.cpp" >
+        <Expression success="true" type="CHECK" filename="tests/<exe-name>/IntrospectiveTests/StringManip.tests.cpp" >
+          <Original>
+            Catch::replaceInPlace(s, "--", "-")
+          </Original>
+          <Expanded>
+            true
+          </Expanded>
+        </Expression>
+        <Expression success="true" type="CHECK" filename="tests/<exe-name>/IntrospectiveTests/StringManip.tests.cpp" >
+          <Original>
+            s == "--"
+          </Original>
+          <Expanded>
+            "--" == "--"
+          </Expanded>
+        </Expression>
+        <OverallResults successes="2" failures="0" expectedFailures="0" skipped="false"/>
+      </Section>
+      <OverallResults successes="2" failures="0" expectedFailures="0" skipped="false"/>
+    </Section>
     <Section name="escape '" filename="tests/<exe-name>/IntrospectiveTests/StringManip.tests.cpp" >
       <Expression success="true" type="CHECK" filename="tests/<exe-name>/IntrospectiveTests/StringManip.tests.cpp" >
         <Original>
@@ -21674,6 +21718,6 @@ b1!
     </Section>
     <OverallResult success="true" skips="0"/>
   </TestCase>
-  <OverallResults successes="2075" failures="146" expectedFailures="35" skips="12"/>
+  <OverallResults successes="2079" failures="146" expectedFailures="35" skips="12"/>
   <OverallResultsCases successes="312" failures="85" expectedFailures="14" skips="6"/>
 </Catch2TestRun>
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, "'", "|'"));