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
@ -38,12 +38,44 @@ StringAccessTest::PerformTest(void)
|
|||||||
CPPUNIT_ASSERT(string3.CountChars() == 2);
|
CPPUNIT_ASSERT(string3.CountChars() == 2);
|
||||||
CPPUNIT_ASSERT(string3.Length() == strlen(string3.String()));
|
CPPUNIT_ASSERT(string3.Length() == strlen(string3.String()));
|
||||||
|
|
||||||
|
//An empty string
|
||||||
NextSubTest();
|
NextSubTest();
|
||||||
BString empty;
|
BString empty;
|
||||||
CPPUNIT_ASSERT(strcmp(empty.String(), "") == 0);
|
CPPUNIT_ASSERT(strcmp(empty.String(), "") == 0);
|
||||||
CPPUNIT_ASSERT(empty.Length() == 0);
|
CPPUNIT_ASSERT(empty.Length() == 0);
|
||||||
CPPUNIT_ASSERT(empty.CountChars() == 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);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -47,13 +47,15 @@ StringEscapeTest::PerformTest(void)
|
|||||||
CPPUNIT_ASSERT(strcmp(string1->String(), "n0ew0str0ing") == 0);
|
CPPUNIT_ASSERT(strcmp(string1->String(), "n0ew0str0ing") == 0);
|
||||||
delete string1;
|
delete string1;
|
||||||
|
|
||||||
|
#ifndef TEST_R5
|
||||||
//assigned string is NULL
|
//assigned string is NULL
|
||||||
//commented out as it crashes r5 implementation
|
//it crashes r5 implementation, but not ours :)
|
||||||
//NextSubTest();
|
NextSubTest();
|
||||||
//string1 = new BString("something");
|
string1 = new BString("something");
|
||||||
//string1->CharacterEscape((char*)NULL, "ei", '-');
|
string1->CharacterEscape((char*)NULL, "ei", '-');
|
||||||
//CPPUNIT_ASSERT(strcmp(string1->String(), "") == 0);
|
CPPUNIT_ASSERT(strcmp(string1->String(), "") == 0);
|
||||||
//delete string1;
|
delete string1;
|
||||||
|
#endif
|
||||||
|
|
||||||
//String was empty
|
//String was empty
|
||||||
NextSubTest();
|
NextSubTest();
|
||||||
@ -97,13 +99,15 @@ StringEscapeTest::PerformTest(void)
|
|||||||
CPPUNIT_ASSERT(strcmp(string1->String(), "newstring") == 0);
|
CPPUNIT_ASSERT(strcmp(string1->String(), "newstring") == 0);
|
||||||
delete string1;
|
delete string1;
|
||||||
|
|
||||||
|
#ifndef TEST_R5
|
||||||
//assigned string is empty
|
//assigned string is empty
|
||||||
//commented out as it crashes r5 implementation
|
//it crashes r5 implementation, but not ours :)
|
||||||
//NextSubTest();
|
NextSubTest();
|
||||||
//string1 = new BString("pippo");
|
string1 = new BString("pippo");
|
||||||
//string1->CharacterDeescape((char*)NULL, '/');
|
string1->CharacterDeescape((char*)NULL, '/');
|
||||||
//CPPUNIT_ASSERT(strcmp(string1->String(), "") == 0);
|
CPPUNIT_ASSERT(strcmp(string1->String(), "") == 0);
|
||||||
//delete string1;
|
delete string1;
|
||||||
|
#endif
|
||||||
|
|
||||||
//String doesn't contain character to escape
|
//String doesn't contain character to escape
|
||||||
NextSubTest();
|
NextSubTest();
|
||||||
|
@ -37,14 +37,17 @@ StringRemoveTest::PerformTest(void)
|
|||||||
CPPUNIT_ASSERT(string1->Length() == 14);
|
CPPUNIT_ASSERT(string1->Length() == 14);
|
||||||
delete string1;
|
delete string1;
|
||||||
|
|
||||||
|
#ifndef TEST_R5
|
||||||
//new length is < 0
|
//new length is < 0
|
||||||
//commented out as it crashes r5 implementation
|
//it crashes r5 implementation, but ours works fine here,
|
||||||
//NextSubTest();
|
//in this case, we ignore the truncation
|
||||||
//string1 = new BString("This is a long string");
|
NextSubTest();
|
||||||
//string1->Truncate(-3);
|
string1 = new BString("This is a long string");
|
||||||
//CPPUNIT_ASSERT(strcmp(string1->String(), "This is a long string") == 0);
|
string1->Truncate(-3);
|
||||||
//CPPUNIT_ASSERT(string1->Length() == 21);
|
CPPUNIT_ASSERT(strcmp(string1->String(), "This is a long string") == 0);
|
||||||
//delete string1;
|
CPPUNIT_ASSERT(string1->Length() == 21);
|
||||||
|
delete string1;
|
||||||
|
#endif
|
||||||
|
|
||||||
//new length is > old length
|
//new length is > old length
|
||||||
NextSubTest();
|
NextSubTest();
|
||||||
|
Loading…
Reference in New Issue
Block a user