diff options
author | Max Horn | 2009-04-20 19:27:11 +0000 |
---|---|---|
committer | Max Horn | 2009-04-20 19:27:11 +0000 |
commit | 78cf5a4ccfe4e36f33230bb196aad34eb3cf89f7 (patch) | |
tree | 15f038e525bc9a7d0900f339e558ea43e53e1856 /test | |
parent | faa911794953679a1fff24999878f79612dfc7f3 (diff) | |
download | scummvm-rg350-78cf5a4ccfe4e36f33230bb196aad34eb3cf89f7.tar.gz scummvm-rg350-78cf5a4ccfe4e36f33230bb196aad34eb3cf89f7.tar.bz2 scummvm-rg350-78cf5a4ccfe4e36f33230bb196aad34eb3cf89f7.zip |
COMMON & TESTS: Added new constructor to Array<T>, namely Array(const T* data, int n), which makes it possible to clone a regular array into a Common::Array; added a unit test for that and slightly extended existing Common::Array unit tests
svn-id: r40027
Diffstat (limited to 'test')
-rw-r--r-- | test/common/array.h | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/test/common/array.h b/test/common/array.h index 2a41cd5b6a..ad92acaf3a 100644 --- a/test/common/array.h +++ b/test/common/array.h @@ -73,6 +73,8 @@ class ArrayTestSuite : public CxxTest::TestSuite TS_ASSERT_EQUALS( array[2], 33 ); TS_ASSERT_EQUALS( array[3], 25 ); TS_ASSERT_EQUALS( array[4], -11 ); + + TS_ASSERT_EQUALS( array.size(), 5 ); } void test_remove_at() { @@ -92,6 +94,8 @@ class ArrayTestSuite : public CxxTest::TestSuite TS_ASSERT_EQUALS( array[1], 33 ); TS_ASSERT_EQUALS( array[2], 25 ); TS_ASSERT_EQUALS( array[3], -11 ); + + TS_ASSERT_EQUALS( array.size(), 4 ); } void test_push_back() { @@ -114,6 +118,9 @@ class ArrayTestSuite : public CxxTest::TestSuite TS_ASSERT_EQUALS( array1[3], 3 ); TS_ASSERT_EQUALS( array1[4], -2 ); TS_ASSERT_EQUALS( array1[5], -131 ); + + TS_ASSERT_EQUALS( array1.size(), 6 ); + TS_ASSERT_EQUALS( array2.size(), 3 ); } void test_copy_constructor() { @@ -129,5 +136,19 @@ class ArrayTestSuite : public CxxTest::TestSuite TS_ASSERT_EQUALS( array2[0], -3 ); TS_ASSERT_EQUALS( array2[1], 5 ); TS_ASSERT_EQUALS( array2[2], 9 ); + + TS_ASSERT_EQUALS( array2.size(), 3 ); + } + + void test_array_constructor() { + const int array1[] = { -3, 5, 9 }; + + Common::Array<int> array2(array1, 3); + + TS_ASSERT_EQUALS( array2[0], -3 ); + TS_ASSERT_EQUALS( array2[1], 5 ); + TS_ASSERT_EQUALS( array2[2], 9 ); + + TS_ASSERT_EQUALS( array2.size(), 3 ); } }; |