COMMON: add tests for Common::String
I added tests for firstChar, setChar, insertChar
This commit is contained in:
parent
bf5999044b
commit
56397ae457
1 changed files with 25 additions and 0 deletions
|
@ -40,6 +40,15 @@ class StringTestSuite : public CxxTest::TestSuite
|
|||
TS_ASSERT_EQUALS(str2.lastChar(), 'r');
|
||||
}
|
||||
|
||||
void test_firstChar() {
|
||||
Common::String str;
|
||||
TS_ASSERT_EQUALS(str.firstChar(), '\0');
|
||||
str = "first_test";
|
||||
TS_ASSERT_EQUALS(str.firstChar(), 'f');
|
||||
Common::String str2("bar");
|
||||
TS_ASSERT_EQUALS(str2.firstChar(), 'b');
|
||||
}
|
||||
|
||||
void test_concat1() {
|
||||
Common::String str("foo");
|
||||
Common::String str2("bar");
|
||||
|
@ -542,4 +551,20 @@ class StringTestSuite : public CxxTest::TestSuite
|
|||
TS_ASSERT_EQUALS(s3, "TestTestTest");
|
||||
TS_ASSERT_EQUALS(s4, "TestTestTestTestTestTestTestTestTestTestTest");
|
||||
}
|
||||
|
||||
void test_setChar() {
|
||||
Common::String testString("123456");
|
||||
testString.setChar('2', 0);
|
||||
TS_ASSERT(testString == "223456");
|
||||
testString.setChar('0', 5);
|
||||
TS_ASSERT(testString == "223450");
|
||||
}
|
||||
|
||||
void test_insertChar() {
|
||||
Common::String testString("123456");
|
||||
testString.insertChar('2', 0);
|
||||
TS_ASSERT(testString == "2123456");
|
||||
testString.insertChar('0', 5);
|
||||
TS_ASSERT(testString == "21234056");
|
||||
}
|
||||
};
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue