More tests. All methods are tested and are working, but LockBuffer and UnlockBuffer()

git-svn-id: file:///srv/svn/repos/haiku/trunk/current@1888 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
Stefano Ceccherini 2002-11-09 11:50:33 +00:00
parent b71ba910ba
commit ee37218ef1

View File

@ -124,10 +124,134 @@ StringReplaceTest::PerformTest(void)
NextSubTest();
str1 = new BString("she sells sea shells on the seashore");
str1->ReplaceAll("sea", "the", 11);
str1->IReplaceAll("sea", "the", 11);
CPPUNIT_ASSERT(strcmp(str1->String(),
"she sells sea shells on the theshore") == 0);
delete str1;
//&IReplaceFirst(char, char);
NextSubTest();
str1 = new BString("test string");
str1->IReplaceFirst('t', 'b');
CPPUNIT_ASSERT(strcmp(str1->String(), "best string") == 0);
delete str1;
NextSubTest();
str1 = new BString("test string");
str1->IReplaceFirst('x', 'b');
CPPUNIT_ASSERT(strcmp(str1->String(), "test string") == 0);
delete str1;
//&IReplaceLast(char, char);
NextSubTest();
str1 = new BString("test string");
str1->IReplaceLast('t', 'w');
CPPUNIT_ASSERT(strcmp(str1->String(), "test swring") == 0);
delete str1;
NextSubTest();
str1 = new BString("test string");
str1->IReplaceLast('x', 'b');
CPPUNIT_ASSERT(strcmp(str1->String(), "test string") == 0);
delete str1;
//&IReplaceAll(char, char, int32);
NextSubTest();
str1 = new BString("TEST string");
str1->IReplaceAll('t', 'i');
CPPUNIT_ASSERT(strcmp(str1->String(), "iESi siring") == 0);
delete str1;
NextSubTest();
str1 = new BString("test string");
str1->IReplaceAll('x', 'b');
CPPUNIT_ASSERT(strcmp(str1->String(), "test string") == 0);
delete str1;
NextSubTest();
str1 = new BString("TEST string");
str1->IReplaceAll('t', 'i', 2);
CPPUNIT_ASSERT(strcmp(str1->String(), "TESi siring") == 0);
delete str1;
//&IReplace(char, char, int32, int32)
NextSubTest();
str1 = new BString("She sells Sea shells on the sea shore");
str1->IReplace('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->IReplace('s', 'x', 12, 32);
CPPUNIT_ASSERT(strcmp(str1->String(), "") == 0);
delete str1;
//&IReplaceFirst(const char*, const char*)
NextSubTest();
str1 = new BString("she sells SeA shells on the seashore");
str1->IReplaceFirst("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->IReplaceFirst("tex", "the");
CPPUNIT_ASSERT(strcmp(str1->String(),
"she sells sea shells on the seashore") == 0);
delete str1;
//&IReplaceLast(const char*, const char*)
NextSubTest();
str1 = new BString("she sells sea shells on the SEashore");
str1->IReplaceLast("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->IReplaceLast("tex", "the");
CPPUNIT_ASSERT(strcmp(str1->String(),
"she sells sea shells on the seashore") == 0);
delete str1;
//&IReplaceAll(const char*, const char*, int32)
NextSubTest();
str1 = new BString("abc ABc aBc");
str1->IReplaceAll("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->IReplaceAll("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->IReplaceAll("sea", "the", 11);
CPPUNIT_ASSERT(strcmp(str1->String(),
"she sells SeA shells on the theshore") == 0);
delete str1;
//ReplaceSet(const char*, char)
NextSubTest();
str1 = new BString("abc abc abc");
str1->ReplaceSet("ab", 'x');
CPPUNIT_ASSERT(strcmp(str1->String(), "xxc xxc xxc") == 0);
delete str1;
//ReplaceSet(const char*, const char*)
NextSubTest();
str1 = new BString("abcd abcd abcd");
str1->ReplaceSet("ad", "da");
CPPUNIT_ASSERT(strcmp(str1->String(), "dabcda dabcda dabcda") == 0);
delete str1;
}