aboutsummaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorMax Horn2008-07-23 16:33:53 +0000
committerMax Horn2008-07-23 16:33:53 +0000
commit15c610a069c4f86f921791584fa0248a9e26b9c2 (patch)
treea51ebd1abb1ad467dfea14bde9553319dbdc6acf /test
parent6e2e844f310d4e57ead0c887760d79c39d406e8d (diff)
downloadscummvm-rg350-15c610a069c4f86f921791584fa0248a9e26b9c2.tar.gz
scummvm-rg350-15c610a069c4f86f921791584fa0248a9e26b9c2.tar.bz2
scummvm-rg350-15c610a069c4f86f921791584fa0248a9e26b9c2.zip
Added convenience method String::makeUnique(); simplified String::operator=(char c); extended String unit tests
svn-id: r33246
Diffstat (limited to 'test')
-rw-r--r--test/common/str.h34
1 files changed, 26 insertions, 8 deletions
diff --git a/test/common/str.h b/test/common/str.h
index 7fddd0e21d..72d4df6f61 100644
--- a/test/common/str.h
+++ b/test/common/str.h
@@ -61,43 +61,61 @@ class StringTestSuite : public CxxTest::TestSuite
}
void test_refCount(void) {
+ // using internal storage
Common::String foo1("foo");
- Common::String foo2("foo");
+ Common::String foo2(foo1);
Common::String foo3(foo2);
foo3 += 'X';
- TS_ASSERT_EQUALS(foo2, foo1);
+ TS_ASSERT_EQUALS(foo1, "foo");
TS_ASSERT_EQUALS(foo2, "foo");
TS_ASSERT_EQUALS(foo3, "foo""X");
+ foo2 = 'x';
+ TS_ASSERT_EQUALS(foo1, "foo");
+ TS_ASSERT_EQUALS(foo2, "x");
+ TS_ASSERT_EQUALS(foo3, "foo""X");
}
void test_refCount2(void) {
+ // using external storage
Common::String foo1("fooasdkadklasdjklasdjlkasjdlkasjdklasjdlkjasdasd");
- Common::String foo2("fooasdkadklasdjklasdjlkasjdlkasjdklasjdlkjasdasd");
+ Common::String foo2(foo1);
Common::String foo3(foo2);
foo3 += 'X';
- TS_ASSERT_EQUALS(foo2, foo1);
+ TS_ASSERT_EQUALS(foo1, "fooasdkadklasdjklasdjlkasjdlkasjdklasjdlkjasdasd");
TS_ASSERT_EQUALS(foo2, "fooasdkadklasdjklasdjlkasjdlkasjdklasjdlkjasdasd");
TS_ASSERT_EQUALS(foo3, "fooasdkadklasdjklasdjlkasjdlkasjdklasjdlkjasdasd""X");
+ foo2 = 'x';
+ TS_ASSERT_EQUALS(foo1, "fooasdkadklasdjklasdjlkasjdlkasjdklasjdlkjasdasd");
+ TS_ASSERT_EQUALS(foo2, "x");
+ TS_ASSERT_EQUALS(foo3, "fooasdkadklasdjklasdjlkasjdlkasjdklasjdlkjasdasd""X");
}
void test_refCount3(void) {
Common::String foo1("0123456789abcdefghijk");
- Common::String foo2("0123456789abcdefghijk");
+ Common::String foo2(foo1);
Common::String foo3(foo2);
foo3 += "0123456789abcdefghijk";
- TS_ASSERT_EQUALS(foo2, foo1);
+ TS_ASSERT_EQUALS(foo1, foo2);
TS_ASSERT_EQUALS(foo2, "0123456789abcdefghijk");
TS_ASSERT_EQUALS(foo3, "0123456789abcdefghijk""0123456789abcdefghijk");
+ foo2 = 'x';
+ TS_ASSERT_EQUALS(foo1, "0123456789abcdefghijk");
+ TS_ASSERT_EQUALS(foo2, "x");
+ TS_ASSERT_EQUALS(foo3, "0123456789abcdefghijk""0123456789abcdefghijk");
}
void test_refCount4(void) {
Common::String foo1("fooasdkadklasdjklasdjlkasjdlkasjdklasjdlkjasdasd");
- Common::String foo2("fooasdkadklasdjklasdjlkasjdlkasjdklasjdlkjasdasd");
+ Common::String foo2(foo1);
Common::String foo3(foo2);
foo3 += "fooasdkadklasdjklasdjlkasjdlkasjdklasjdlkjasdasd";
- TS_ASSERT_EQUALS(foo2, foo1);
+ TS_ASSERT_EQUALS(foo1, foo2);
TS_ASSERT_EQUALS(foo2, "fooasdkadklasdjklasdjlkasjdlkasjdklasjdlkjasdasd");
TS_ASSERT_EQUALS(foo3, "fooasdkadklasdjklasdjlkasjdlkasjdklasjdlkjasdasd""fooasdkadklasdjklasdjlkasjdlkasjdklasjdlkjasdasd");
+ foo2 = 'x';
+ TS_ASSERT_EQUALS(foo1, "fooasdkadklasdjklasdjlkasjdlkasjdklasjdlkjasdasd");
+ TS_ASSERT_EQUALS(foo2, "x");
+ TS_ASSERT_EQUALS(foo3, "fooasdkadklasdjklasdjlkasjdlkasjdklasjdlkjasdasd""fooasdkadklasdjklasdjlkasjdlkasjdklasjdlkjasdasd");
}
void test_hasPrefix(void) {