@@ -39,6 +39,7 @@ class TestUtils : public TestFixture {
3939 TEST_CASE (id_string);
4040 TEST_CASE (startsWith);
4141 TEST_CASE (trim);
42+ TEST_CASE (findAndReplace);
4243 }
4344
4445 void isValidGlobPattern () const {
@@ -393,6 +394,39 @@ class TestUtils : public TestFixture {
393394 ASSERT_EQUALS (" test" , ::trim (" test\n " , " \n " ));
394395 ASSERT_EQUALS (" test" , ::trim (" \n test\n " , " \n " ));
395396 }
397+
398+ void findAndReplace () const {
399+ {
400+ std::string s{" test" };
401+ ::findAndReplace (s, " test" , " tset" );
402+ ASSERT_EQUALS (" tset" , s);
403+ }
404+ {
405+ std::string s{" testtest" };
406+ ::findAndReplace (s, " test" , " tset" );
407+ ASSERT_EQUALS (" tsettset" , s);
408+ }
409+ {
410+ std::string s{" 1test1test1" };
411+ ::findAndReplace (s, " test" , " tset" );
412+ ASSERT_EQUALS (" 1tset1tset1" , s);
413+ }
414+ {
415+ std::string s{" 1test1test1" };
416+ ::findAndReplace (s, " test" , " " );
417+ ASSERT_EQUALS (" 111" , s);
418+ }
419+ {
420+ std::string s{" 111" };
421+ ::findAndReplace (s, " test" , " tset" );
422+ ASSERT_EQUALS (" 111" , s);
423+ }
424+ {
425+ std::string s;
426+ ::findAndReplace (s, " test" , " tset" );
427+ ASSERT_EQUALS (" " , s);
428+ }
429+ }
396430};
397431
398432REGISTER_TEST (TestUtils)
0 commit comments