From ae64b7e35452fe13e9ac7c7833c21a5f6f444694 Mon Sep 17 00:00:00 2001 From: Stefano Ceccherini Date: Tue, 5 Nov 2002 13:17:52 +0000 Subject: [PATCH] Some more tests for Replace Functions (which our BString doesn't pass (will fix it later)) git-svn-id: file:///srv/svn/repos/haiku/trunk/current@1850 a95241bf-73f2-0310-859d-f6bbb57e9c96 --- .../support/bstring/StringReplaceTest.cpp | 58 +++++++++++++++++++ 1 file changed, 58 insertions(+) diff --git a/src/tests/kits/support/bstring/StringReplaceTest.cpp b/src/tests/kits/support/bstring/StringReplaceTest.cpp index 69ec726463..87b297f116 100644 --- a/src/tests/kits/support/bstring/StringReplaceTest.cpp +++ b/src/tests/kits/support/bstring/StringReplaceTest.cpp @@ -70,6 +70,64 @@ StringReplaceTest::PerformTest(void) str1->Replace('s' 't', 4, 2); CPPUNIT_ASSERT(strcmp(str1->String(), "she tellt tea thells on the sea shore") == 0); delete str1; + + NextSubTest(); + str1 = new BString(); + str1->Replace('s', 'x', 12, 32); + CPPUNIT_ASSERT(strcmp(str1->String(), "") == 0); + delete str1; + + //&ReplaceFirst(const char*, const char*) + NextSubTest(); + str1 = new BString("she sells sea shells on the seashore"); + str1->ReplaceFirst("sea", "the"); + CPPUNIT_ASSERT(strcmp(str1->String(), + "she sells the shells on the seashore") == 0); + delete str1; + + NextSubTest(); + str1 = new BString("she sells sea shells on the seashore"); + str1->ReplaceFirst("tex", "the"); + CPPUNIT_ASSERT(strcmp(str1->String(), + "she sells sea shells on the seashore") == 0); + delete str1; + + //&ReplaceLast(const char*, const char*) + NextSubTest(); + str1 = new BString("she sells sea shells on the seashore"); + str1->ReplaceLast("sea", "the"); + CPPUNIT_ASSERT(strcmp(str1->String(), + "she sells sea shells on the theshore") == 0); + delete str1; + + NextSubTest(); + str1 = new BString("she sells sea shells on the seashore"); + str1->ReplaceLast("tex", "the"); + CPPUNIT_ASSERT(strcmp(str1->String(), + "she sells sea shells on the seashore") == 0); + delete str1; + + //&ReplaceAll(const char*, const char*, int32) + NextSubTest(); + str1 = new BString("abc abc abc"); + str1->ReplaceAll("ab", "abc"); + CPPUNIT_ASSERT(strcmp(str1->String(), + "abcc abcc abcc") == 0); + delete str1; + + NextSubTest(); + str1 = new BString("she sells sea shells on the seashore"); + str1->ReplaceAll("tex", "the"); + CPPUNIT_ASSERT(strcmp(str1->String(), + "she sells sea shells on the seashore") == 0); + delete str1; + + NextSubTest(); + str1 = new BString("she sells sea shells on the seashore"); + str1->ReplaceAll("sea", "the", 11); + CPPUNIT_ASSERT(strcmp(str1->String(), + "she sells sea shells on the theshore") == 0); + delete str1; }