* add tests for BString that expose a problem in the looping Replace() implementations
on single chars * automatic whitespace cleanup git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@42681 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
@@ -60,6 +60,12 @@ StringReplaceTest::PerformTest(void)
|
|||||||
CPPUNIT_ASSERT(strcmp(str1->String(), "test string") == 0);
|
CPPUNIT_ASSERT(strcmp(str1->String(), "test string") == 0);
|
||||||
delete str1;
|
delete str1;
|
||||||
|
|
||||||
|
NextSubTest();
|
||||||
|
str1 = new BString("test string");
|
||||||
|
str1->ReplaceAll('t', 't');
|
||||||
|
CPPUNIT_ASSERT(strcmp(str1->String(), "test string") == 0);
|
||||||
|
delete str1;
|
||||||
|
|
||||||
NextSubTest();
|
NextSubTest();
|
||||||
str1 = new BString("test string");
|
str1 = new BString("test string");
|
||||||
str1->ReplaceAll('t', 'i', 2);
|
str1->ReplaceAll('t', 'i', 2);
|
||||||
@@ -73,6 +79,12 @@ StringReplaceTest::PerformTest(void)
|
|||||||
CPPUNIT_ASSERT(strcmp(str1->String(), "she tellt tea thells on the sea shore") == 0);
|
CPPUNIT_ASSERT(strcmp(str1->String(), "she tellt tea thells on the sea shore") == 0);
|
||||||
delete str1;
|
delete str1;
|
||||||
|
|
||||||
|
NextSubTest();
|
||||||
|
str1 = new BString("she sells sea shells on the sea shore");
|
||||||
|
str1->Replace('s', 's', 4, 2);
|
||||||
|
CPPUNIT_ASSERT(strcmp(str1->String(), "she sells sea shells on the sea shore") == 0);
|
||||||
|
delete str1;
|
||||||
|
|
||||||
NextSubTest();
|
NextSubTest();
|
||||||
str1 = new BString();
|
str1 = new BString();
|
||||||
str1->Replace('s', 'x', 12, 32);
|
str1->Replace('s', 'x', 12, 32);
|
||||||
@@ -113,8 +125,13 @@ StringReplaceTest::PerformTest(void)
|
|||||||
NextSubTest();
|
NextSubTest();
|
||||||
str1 = new BString("abc abc abc");
|
str1 = new BString("abc abc abc");
|
||||||
str1->ReplaceAll("ab", "abc");
|
str1->ReplaceAll("ab", "abc");
|
||||||
CPPUNIT_ASSERT(strcmp(str1->String(),
|
CPPUNIT_ASSERT(strcmp(str1->String(), "abcc abcc abcc") == 0);
|
||||||
"abcc abcc abcc") == 0);
|
delete str1;
|
||||||
|
|
||||||
|
NextSubTest();
|
||||||
|
str1 = new BString("abc abc abc");
|
||||||
|
str1->ReplaceAll("abc", "abc");
|
||||||
|
CPPUNIT_ASSERT(strcmp(str1->String(), "abc abc abc") == 0);
|
||||||
delete str1;
|
delete str1;
|
||||||
|
|
||||||
NextSubTest();
|
NextSubTest();
|
||||||
@@ -131,6 +148,13 @@ StringReplaceTest::PerformTest(void)
|
|||||||
"she sells sea shells on the theshore") == 0);
|
"she sells sea shells on the theshore") == 0);
|
||||||
delete str1;
|
delete str1;
|
||||||
|
|
||||||
|
NextSubTest();
|
||||||
|
str1 = new BString("she sells sea shells on the seashore");
|
||||||
|
str1->IReplaceAll("sea", "sea", 11);
|
||||||
|
CPPUNIT_ASSERT(strcmp(str1->String(),
|
||||||
|
"she sells sea shells on the seashore") == 0);
|
||||||
|
delete str1;
|
||||||
|
|
||||||
//&IReplaceFirst(char, char);
|
//&IReplaceFirst(char, char);
|
||||||
NextSubTest();
|
NextSubTest();
|
||||||
str1 = new BString("test string");
|
str1 = new BString("test string");
|
||||||
@@ -164,6 +188,12 @@ StringReplaceTest::PerformTest(void)
|
|||||||
CPPUNIT_ASSERT(strcmp(str1->String(), "iESi siring") == 0);
|
CPPUNIT_ASSERT(strcmp(str1->String(), "iESi siring") == 0);
|
||||||
delete str1;
|
delete str1;
|
||||||
|
|
||||||
|
NextSubTest();
|
||||||
|
str1 = new BString("TEST string");
|
||||||
|
str1->IReplaceAll('t', 'T');
|
||||||
|
CPPUNIT_ASSERT(strcmp(str1->String(), "TEST sTring") == 0);
|
||||||
|
delete str1;
|
||||||
|
|
||||||
NextSubTest();
|
NextSubTest();
|
||||||
str1 = new BString("test string");
|
str1 = new BString("test string");
|
||||||
str1->IReplaceAll('x', 'b');
|
str1->IReplaceAll('x', 'b');
|
||||||
@@ -183,6 +213,12 @@ StringReplaceTest::PerformTest(void)
|
|||||||
CPPUNIT_ASSERT(strcmp(str1->String(), "She tellt tea thells on the sea shore") == 0);
|
CPPUNIT_ASSERT(strcmp(str1->String(), "She tellt tea thells on the sea shore") == 0);
|
||||||
delete str1;
|
delete str1;
|
||||||
|
|
||||||
|
NextSubTest();
|
||||||
|
str1 = new BString("She sells Sea shells on the sea shore");
|
||||||
|
str1->IReplace('s', 's', 4, 2);
|
||||||
|
CPPUNIT_ASSERT(strcmp(str1->String(), "She sells sea shells on the sea shore") == 0);
|
||||||
|
delete str1;
|
||||||
|
|
||||||
NextSubTest();
|
NextSubTest();
|
||||||
str1 = new BString();
|
str1 = new BString();
|
||||||
str1->IReplace('s', 'x', 12, 32);
|
str1->IReplace('s', 'x', 12, 32);
|
||||||
@@ -255,6 +291,12 @@ StringReplaceTest::PerformTest(void)
|
|||||||
CPPUNIT_ASSERT(strcmp(str1->String(), "ccccccccccccccc") == 0);
|
CPPUNIT_ASSERT(strcmp(str1->String(), "ccccccccccccccc") == 0);
|
||||||
delete str1;
|
delete str1;
|
||||||
|
|
||||||
|
NextSubTest();
|
||||||
|
str1 = new BString("abcabcabcbababc");
|
||||||
|
str1->ReplaceSet("c", 'c');
|
||||||
|
CPPUNIT_ASSERT(strcmp(str1->String(), "abcabcabcbababc") == 0);
|
||||||
|
delete str1;
|
||||||
|
|
||||||
#ifndef TEST_R5
|
#ifndef TEST_R5
|
||||||
//ReplaceSet(const char*, const char*)
|
//ReplaceSet(const char*, const char*)
|
||||||
NextSubTest();
|
NextSubTest();
|
||||||
|
|||||||
Reference in New Issue
Block a user