COMMON: add tests for Common::String

I added tests for firstChar, setChar, insertChar
This commit is contained in:
Jaromir Wysoglad 2019-04-02 14:33:31 +02:00 committed by Filippos Karapetis
parent bf5999044b
commit 56397ae457

View File

@ -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");
}
};