From 38a133eb8a349ed5785f088ecaa2efc9c1f17cb8 Mon Sep 17 00:00:00 2001 From: Augustin Cavalier Date: Sun, 16 Sep 2018 13:53:05 -0400 Subject: [PATCH] StringReplaceTest: Add (failing) invocations of Replace*() with NULL "to". BeOS R5 treats NULL passed as the "replace with" argument as if it were an empty string. Our BString currently does nothing. Change-Id: I54b661e4ea8335ce531e6b6e3de2095a41112cd7 Reviewed-on: https://review.haiku-os.org/571 Reviewed-by: waddlesplash --- .../support/bstring/StringReplaceTest.cpp | 40 +++++++++++++++++++ 1 file changed, 40 insertions(+) diff --git a/src/tests/kits/support/bstring/StringReplaceTest.cpp b/src/tests/kits/support/bstring/StringReplaceTest.cpp index 8e91bf3f0d..f7e80e31aa 100644 --- a/src/tests/kits/support/bstring/StringReplaceTest.cpp +++ b/src/tests/kits/support/bstring/StringReplaceTest.cpp @@ -108,6 +108,12 @@ StringReplaceTest::PerformTest(void) "she sells sea shells on the seashore") == 0); delete str1; + NextSubTest(); + str1 = new BString("Error moving \"%name\""); + str1->ReplaceFirst("%name", NULL); + CPPUNIT_ASSERT(strcmp(str1->String(), "Error moving \"\"") == 0); + delete str1; + // &ReplaceLast(const char*, const char*) NextSubTest(); str1 = new BString("she sells sea shells on the seashore"); @@ -123,6 +129,13 @@ StringReplaceTest::PerformTest(void) "she sells sea shells on the seashore") == 0); delete str1; + NextSubTest(); + str1 = new BString("she sells sea shells on the seashore"); + str1->ReplaceLast("sea", NULL); + CPPUNIT_ASSERT(strcmp(str1->String(), + "she sells sea shells on the shore") == 0); + delete str1; + // &ReplaceAll(const char*, const char*, int32) NextSubTest(); str1 = new BString("abc abc abc"); @@ -136,6 +149,12 @@ StringReplaceTest::PerformTest(void) CPPUNIT_ASSERT(strcmp(str1->String(), "abc abc abc") == 0); delete str1; + NextSubTest(); + str1 = new BString("abc abc abc"); + str1->ReplaceAll("abc", NULL); + CPPUNIT_ASSERT(strcmp(str1->String(), " ") == 0); + delete str1; + NextSubTest(); str1 = new BString("she sells sea shells on the seashore"); str1->ReplaceAll("tex", "the"); @@ -244,6 +263,13 @@ StringReplaceTest::PerformTest(void) "she sells sea shells on the seashore") == 0); delete str1; + NextSubTest(); + str1 = new BString("she sells SeA shells on the seashore"); + str1->IReplaceFirst("sea ", NULL); + CPPUNIT_ASSERT(strcmp(str1->String(), + "she sells shells on the seashore") == 0); + delete str1; + // &IReplaceLast(const char*, const char*) #ifndef TEST_R5 NextSubTest(); @@ -260,6 +286,13 @@ StringReplaceTest::PerformTest(void) "she sells sea shells on the seashore") == 0); delete str1; + NextSubTest(); + str1 = new BString("she sells sea shells on the SEashore"); + str1->IReplaceLast("sea", NULL); + CPPUNIT_ASSERT(strcmp(str1->String(), + "she sells sea shells on the shore") == 0); + delete str1; + // &IReplaceAll(const char*, const char*, int32) NextSubTest(); str1 = new BString("abc ABc aBc"); @@ -282,6 +315,13 @@ StringReplaceTest::PerformTest(void) "she sells SeA shells on the theshore") == 0); delete str1; + NextSubTest(); + str1 = new BString("abc ABc aBc"); + str1->IReplaceAll("ab", NULL); + CPPUNIT_ASSERT(strcmp(str1->String(), + "c c c") == 0); + delete str1; + // ReplaceSet(const char*, char) NextSubTest(); str1 = new BString("abc abc abc");