aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJohannes Schickel2010-05-30 13:10:23 +0000
committerJohannes Schickel2010-05-30 13:10:23 +0000
commit0e9156c7c4d481a0f43b232207dd6065779e9765 (patch)
tree5195f7e399554a22c6e0e6ac17c95fd80a645981
parentd0c79d21e969b0881fb9dfc1d7b204fa74ff2721 (diff)
downloadscummvm-rg350-0e9156c7c4d481a0f43b232207dd6065779e9765.tar.gz
scummvm-rg350-0e9156c7c4d481a0f43b232207dd6065779e9765.tar.bz2
scummvm-rg350-0e9156c7c4d481a0f43b232207dd6065779e9765.zip
Add a (currently) failing test for reference logic in Common::String. (Taken from an example by fuzzie)
svn-id: r49322
-rw-r--r--test/common/str.h22
1 files changed, 22 insertions, 0 deletions
diff --git a/test/common/str.h b/test/common/str.h
index 16fb0859db..2e1651ab59 100644
--- a/test/common/str.h
+++ b/test/common/str.h
@@ -118,6 +118,28 @@ class StringTestSuite : public CxxTest::TestSuite
TS_ASSERT_EQUALS(foo3, "fooasdkadklasdjklasdjlkasjdlkasjdklasjdlkjasdasd""fooasdkadklasdjklasdjlkasjdlkasjdklasjdlkjasdasd");
}
+ void test_refCount5() {
+ // Test for allocated storage
+ Common::String foo1("HelloHelloHelloHelloAndHi");
+ Common::String foo2(foo1);
+
+ for (Common::String::iterator i = foo2.begin(); i != foo2.end(); ++i)
+ *i = 'h';
+
+ TS_ASSERT_EQUALS(foo1, "HelloHelloHelloHelloAndHi");
+ TS_ASSERT_EQUALS(foo2, "hhhhhhhhhhhhhhhhhhhhhhhhh");
+
+ // Test for builtin storage
+ Common::String foo3("Hello");
+ Common::String foo4(foo3);
+
+ for (Common::String::iterator i = foo4.begin(); i != foo4.end(); ++i)
+ *i = 'h';
+
+ TS_ASSERT_EQUALS(foo3, "Hello");
+ TS_ASSERT_EQUALS(foo4, "hhhhh");
+ }
+
void test_self_asignment() {
Common::String foo1("12345678901234567890123456789012");
foo1 = foo1.c_str() + 2;