aboutsummaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorJaromir Wysoglad2019-04-02 14:33:31 +0200
committerFilippos Karapetis2019-04-06 15:02:58 +0300
commit56397ae4575dc6819e69c66fbd901972353b482c (patch)
treed6305a34659bd4744e1b7128d8da871a5cafe57d /test
parentbf5999044b8c87c014098f588517c2c946103623 (diff)
downloadscummvm-rg350-56397ae4575dc6819e69c66fbd901972353b482c.tar.gz
scummvm-rg350-56397ae4575dc6819e69c66fbd901972353b482c.tar.bz2
scummvm-rg350-56397ae4575dc6819e69c66fbd901972353b482c.zip
COMMON: add tests for Common::String
I added tests for firstChar, setChar, insertChar
Diffstat (limited to 'test')
-rw-r--r--test/common/str.h25
1 files changed, 25 insertions, 0 deletions
diff --git a/test/common/str.h b/test/common/str.h
index 3c69d1792c..c6a6e7bed6 100644
--- a/test/common/str.h
+++ b/test/common/str.h
@@ -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");
+ }
};