diff options
author | Johannes Schickel | 2010-10-13 03:57:44 +0000 |
---|---|---|
committer | Johannes Schickel | 2010-10-13 03:57:44 +0000 |
commit | 75e8452b6e6a2bf4fb2f588aa00b428a60d873b5 (patch) | |
tree | f29541d55309487a94bd1d38e8b53bb3dde9aec6 /test | |
parent | 48ee83b88957dab86bc763e9ef21a70179fa8679 (diff) | |
parent | e9f50882ea5b6beeefa994040be9d3bab6a1f107 (diff) | |
download | scummvm-rg350-75e8452b6e6a2bf4fb2f588aa00b428a60d873b5.tar.gz scummvm-rg350-75e8452b6e6a2bf4fb2f588aa00b428a60d873b5.tar.bz2 scummvm-rg350-75e8452b6e6a2bf4fb2f588aa00b428a60d873b5.zip |
OPENGL: Merged from trunk, from rev 52105 to 53396.
This includes an rather hacky attempt to merge all the recent gp2x backend
changes into the branch. I suppose the gp2x backend and probably all new
backends, i.e. gph, dingux etc., might not compile anymore.
Since I have no way of testing those it would be nice if porters could look
into getting those up to speed in this branch.
svn-id: r53399
Diffstat (limited to 'test')
-rw-r--r-- | test/common/array.h | 30 | ||||
-rw-r--r-- | test/common/bufferedreadstream.h | 25 | ||||
-rw-r--r-- | test/common/rational.h | 20 | ||||
-rw-r--r-- | test/common/str.h | 17 |
4 files changed, 86 insertions, 6 deletions
diff --git a/test/common/array.h b/test/common/array.h index c85e056b19..f17edd3984 100644 --- a/test/common/array.h +++ b/test/common/array.h @@ -78,6 +78,36 @@ class ArrayTestSuite : public CxxTest::TestSuite TS_ASSERT_EQUALS(array.size(), (unsigned int)5); } + void test_insert_at_array() { + Common::Array<int> array; + Common::Array<int> array2; + + // First of all some data + array.push_back(-12); + array.push_back(17); + array.push_back(25); + array.push_back(-11); + + array2.push_back(42); + array2.push_back(105); + array2.push_back(-1); + + // Insert some data + array.insert_at(2, array2); + + TS_ASSERT_EQUALS(array.size(), (unsigned int)7); + + TS_ASSERT_EQUALS(array[0], -12); + TS_ASSERT_EQUALS(array[1], 17); + TS_ASSERT_EQUALS(array[2], 42); + TS_ASSERT_EQUALS(array[3], 105); + TS_ASSERT_EQUALS(array[4], -1); + TS_ASSERT_EQUALS(array[5], 25); + TS_ASSERT_EQUALS(array[6], -11); + + } + + void test_remove_at() { Common::Array<int> array; diff --git a/test/common/bufferedreadstream.h b/test/common/bufferedreadstream.h index c171836466..0b2cda696c 100644 --- a/test/common/bufferedreadstream.h +++ b/test/common/bufferedreadstream.h @@ -27,4 +27,29 @@ class BufferedReadStreamTestSuite : public CxxTest::TestSuite { TS_ASSERT(srs.eos()); } + + void test_traverse2() { + byte contents[9] = { 0, 1, 2, 3, 4, 5, 6, 7, 8 }; + Common::MemoryReadStream ms(contents, 9); + + Common::BufferedReadStream brs(&ms, 4); + + // Traverse the stream with reads of 2 bytes. The size is not + // a multiple of 2, so we can test the final partial read. + + byte i, b[2]; + for (i = 0; i < 4; ++i) { + TS_ASSERT(!brs.eos()); + + int n = brs.read(b, 2); + TS_ASSERT_EQUALS(n, 2); + } + + TS_ASSERT(!brs.eos()); + + int n = brs.read(b, 2); + TS_ASSERT_EQUALS(n, 1); + + TS_ASSERT(brs.eos()); + } }; diff --git a/test/common/rational.h b/test/common/rational.h index 4248283ade..21b84a8a41 100644 --- a/test/common/rational.h +++ b/test/common/rational.h @@ -17,9 +17,18 @@ public: Common::Rational r6 = r5 - 1; TS_ASSERT(r4 == r5); + TS_ASSERT(!(r4 != r5)); + + TS_ASSERT(r4 != r6); + TS_ASSERT(!(r4 == r6)); TS_ASSERT(-r4 == -r5); + TS_ASSERT(r0 == 2); + TS_ASSERT(!(r0 != 2)); + TS_ASSERT(!(r3 == 2)); + TS_ASSERT(r3 != 2); + TS_ASSERT( r4 > r6); TS_ASSERT( r4 >= r6); TS_ASSERT(!(r4 < r6)); @@ -70,6 +79,11 @@ public: TS_ASSERT_EQUALS(r1 + r0, Common::Rational(5, 2)); TS_ASSERT_EQUALS(r0 - r1, Common::Rational(3, 2)); TS_ASSERT_EQUALS(r1 - r0, Common::Rational(-3, 2)); + + TS_ASSERT_EQUALS(1 + r1, Common::Rational(3, 2)); + TS_ASSERT_EQUALS(r1 + 1, Common::Rational(3, 2)); + TS_ASSERT_EQUALS(1 - r1, Common::Rational(1, 2)); + TS_ASSERT_EQUALS(r1 - 1, Common::Rational(-1, 2)); } void test_mul() { @@ -86,6 +100,9 @@ public: TS_ASSERT_EQUALS((-r2) * r3, -r4); TS_ASSERT_EQUALS(r2 * (-r3), -r4); TS_ASSERT_EQUALS((-r2) * (-r3), r4); + + TS_ASSERT_EQUALS(r1 * 2, 1); + TS_ASSERT_EQUALS(2 * r1, 1); } void test_div() { @@ -93,5 +110,8 @@ public: Common::Rational r1(1, 2); TS_ASSERT_EQUALS(r0 / r1, 4); + + TS_ASSERT_EQUALS(r1 / 2, Common::Rational(1, 4)); + TS_ASSERT_EQUALS(2 / r1, Common::Rational(4, 1)); } }; diff --git a/test/common/str.h b/test/common/str.h index 6581c37cdb..0908b21c1e 100644 --- a/test/common/str.h +++ b/test/common/str.h @@ -266,6 +266,8 @@ class StringTestSuite : public CxxTest::TestSuite TS_ASSERT_EQUALS(Common::lastPathComponent("foo/./bar", '/'), "bar"); TS_ASSERT_EQUALS(Common::lastPathComponent("foo//./bar//", '/'), "bar"); TS_ASSERT_EQUALS(Common::lastPathComponent("foo//.bar//", '/'), ".bar"); + + TS_ASSERT_EQUALS(Common::lastPathComponent("foo", '/'), "foo"); } void test_normalizePath() { @@ -308,17 +310,20 @@ class StringTestSuite : public CxxTest::TestSuite TS_ASSERT(Common::matchString("monkey.s01", "monkey.s*1")); TS_ASSERT(!Common::matchString("monkey.s99", "monkey.s*1")); TS_ASSERT(Common::matchString("monkey.s101", "monkey.s*1")); + + TS_ASSERT(!Common::String("").matchString("*_")); + TS_ASSERT(Common::String("a").matchString("a***")); } void test_string_printf() { - TS_ASSERT( Common::String::printf("") == "" ); - TS_ASSERT( Common::String::printf("%s", "test") == "test" ); - TS_ASSERT( Common::String::printf("%s.s%.02d", "monkey", 1) == "monkey.s01" ); - TS_ASSERT( Common::String::printf("Some %s to make this string longer than the default built-in %s %d", "text", "capacity", 123456) == "Some text to make this string longer than the default built-in capacity 123456" ); + TS_ASSERT_EQUALS( Common::String::printf(""), "" ); + TS_ASSERT_EQUALS( Common::String::printf("%s", "test"), "test" ); + TS_ASSERT_EQUALS( Common::String::printf("%s.s%.02d", "monkey", 1), "monkey.s01" ); + TS_ASSERT_EQUALS( Common::String::printf("Some %s to make this string longer than the default built-in %s %d", "text", "capacity", 123456), "Some text to make this string longer than the default built-in capacity 123456" ); Common::String s = Common::String::printf("%s%X", "test", 1234); - TS_ASSERT(s == "test4D2"); - TS_ASSERT(s.size() == 7); + TS_ASSERT_EQUALS(s, "test4D2"); + TS_ASSERT_EQUALS(s.size(), 7U); } void test_strlcpy() { |