some more tests which our implementation passes and r5 does not :)
git-svn-id: file:///srv/svn/repos/haiku/trunk/current@2015 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
parent
89feafabe5
commit
9f83f86cbe
@ -37,13 +37,45 @@ StringAccessTest::PerformTest(void)
|
||||
BString string3(s);
|
||||
CPPUNIT_ASSERT(string3.CountChars() == 2);
|
||||
CPPUNIT_ASSERT(string3.Length() == strlen(string3.String()));
|
||||
|
||||
|
||||
//An empty string
|
||||
NextSubTest();
|
||||
BString empty;
|
||||
CPPUNIT_ASSERT(strcmp(empty.String(), "") == 0);
|
||||
CPPUNIT_ASSERT(empty.Length() == 0);
|
||||
CPPUNIT_ASSERT(empty.CountChars() == 0);
|
||||
|
||||
//Truncate the string at end so we are left with an invalid
|
||||
//UTF8 character
|
||||
NextSubTest();
|
||||
BString invalid("some text with utf8 characters"B_UTF8_ELLIPSIS);
|
||||
invalid.Truncate(invalid.Length() -1);
|
||||
CPPUNIT_ASSERT(invalid.CountChars() == 31);
|
||||
|
||||
//LockBuffer(int32) and UnlockBuffer(int32)
|
||||
NextSubTest();
|
||||
BString locked("a string");
|
||||
char *ptrstr = locked.LockBuffer(20);
|
||||
CPPUNIT_ASSERT(strcmp(ptrstr, "a string") == 0);
|
||||
strcat(ptrstr, " to be locked");
|
||||
locked.UnlockBuffer();
|
||||
CPPUNIT_ASSERT(strcmp(ptrstr, "a string to be locked") == 0);
|
||||
|
||||
NextSubTest();
|
||||
BString locked2("some text");
|
||||
char *ptr = locked2.LockBuffer(3);
|
||||
CPPUNIT_ASSERT(strcmp(ptr, "some text") == 0);
|
||||
locked2.UnlockBuffer(4);
|
||||
CPPUNIT_ASSERT(strcmp(locked2.String(), "some") == 0);
|
||||
CPPUNIT_ASSERT(locked2.Length() == 4);
|
||||
|
||||
NextSubTest();
|
||||
BString emptylocked;
|
||||
ptr = emptylocked.LockBuffer(10);
|
||||
CPPUNIT_ASSERT(strcmp(ptr, "") == 0);
|
||||
strcat(ptr, "pippo");
|
||||
emptylocked.UnlockBuffer();
|
||||
CPPUNIT_ASSERT(strcmp(emptylocked.String(), "pippo") == 0);
|
||||
}
|
||||
|
||||
|
||||
|
@ -46,14 +46,16 @@ StringEscapeTest::PerformTest(void)
|
||||
string1->CharacterEscape("newstring", "esi", '0');
|
||||
CPPUNIT_ASSERT(strcmp(string1->String(), "n0ew0str0ing") == 0);
|
||||
delete string1;
|
||||
|
||||
|
||||
#ifndef TEST_R5
|
||||
//assigned string is NULL
|
||||
//commented out as it crashes r5 implementation
|
||||
//NextSubTest();
|
||||
//string1 = new BString("something");
|
||||
//string1->CharacterEscape((char*)NULL, "ei", '-');
|
||||
//CPPUNIT_ASSERT(strcmp(string1->String(), "") == 0);
|
||||
//delete string1;
|
||||
//it crashes r5 implementation, but not ours :)
|
||||
NextSubTest();
|
||||
string1 = new BString("something");
|
||||
string1->CharacterEscape((char*)NULL, "ei", '-');
|
||||
CPPUNIT_ASSERT(strcmp(string1->String(), "") == 0);
|
||||
delete string1;
|
||||
#endif
|
||||
|
||||
//String was empty
|
||||
NextSubTest();
|
||||
@ -96,15 +98,17 @@ StringEscapeTest::PerformTest(void)
|
||||
string1->CharacterDeescape("new/str/ing", '/');
|
||||
CPPUNIT_ASSERT(strcmp(string1->String(), "newstring") == 0);
|
||||
delete string1;
|
||||
|
||||
|
||||
#ifndef TEST_R5
|
||||
//assigned string is empty
|
||||
//commented out as it crashes r5 implementation
|
||||
//NextSubTest();
|
||||
//string1 = new BString("pippo");
|
||||
//string1->CharacterDeescape((char*)NULL, '/');
|
||||
//CPPUNIT_ASSERT(strcmp(string1->String(), "") == 0);
|
||||
//delete string1;
|
||||
|
||||
//it crashes r5 implementation, but not ours :)
|
||||
NextSubTest();
|
||||
string1 = new BString("pippo");
|
||||
string1->CharacterDeescape((char*)NULL, '/');
|
||||
CPPUNIT_ASSERT(strcmp(string1->String(), "") == 0);
|
||||
delete string1;
|
||||
#endif
|
||||
|
||||
//String doesn't contain character to escape
|
||||
NextSubTest();
|
||||
string1 = new BString("Old");
|
||||
|
@ -36,15 +36,18 @@ StringRemoveTest::PerformTest(void)
|
||||
CPPUNIT_ASSERT(strcmp(string1->String(), "This is a long") == 0);
|
||||
CPPUNIT_ASSERT(string1->Length() == 14);
|
||||
delete string1;
|
||||
|
||||
|
||||
#ifndef TEST_R5
|
||||
//new length is < 0
|
||||
//commented out as it crashes r5 implementation
|
||||
//NextSubTest();
|
||||
//string1 = new BString("This is a long string");
|
||||
//string1->Truncate(-3);
|
||||
//CPPUNIT_ASSERT(strcmp(string1->String(), "This is a long string") == 0);
|
||||
//CPPUNIT_ASSERT(string1->Length() == 21);
|
||||
//delete string1;
|
||||
//it crashes r5 implementation, but ours works fine here,
|
||||
//in this case, we ignore the truncation
|
||||
NextSubTest();
|
||||
string1 = new BString("This is a long string");
|
||||
string1->Truncate(-3);
|
||||
CPPUNIT_ASSERT(strcmp(string1->String(), "This is a long string") == 0);
|
||||
CPPUNIT_ASSERT(string1->Length() == 21);
|
||||
delete string1;
|
||||
#endif
|
||||
|
||||
//new length is > old length
|
||||
NextSubTest();
|
||||
|
Loading…
Reference in New Issue
Block a user