aboutsummaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorMax Horn2004-05-21 17:43:16 +0000
committerMax Horn2004-05-21 17:43:16 +0000
commit7a772513c54387141dbbff1a8f0c125d1a2b74e9 (patch)
tree7b2edb966e20d19f6967177d678e131759eeea15 /test
parent6801dd2eef7e7a008f763294d0204014f8511fbe (diff)
downloadscummvm-rg350-7a772513c54387141dbbff1a8f0c125d1a2b74e9.tar.gz
scummvm-rg350-7a772513c54387141dbbff1a8f0c125d1a2b74e9.tar.bz2
scummvm-rg350-7a772513c54387141dbbff1a8f0c125d1a2b74e9.zip
Updated unit tests
svn-id: r13847
Diffstat (limited to 'test')
-rw-r--r--test/common/array.h43
-rw-r--r--test/common/list.h72
2 files changed, 115 insertions, 0 deletions
diff --git a/test/common/array.h b/test/common/array.h
index 94239a9783..cfef3553e5 100644
--- a/test/common/array.h
+++ b/test/common/array.h
@@ -16,4 +16,47 @@ class ArrayTestSuite : public CxxTest::TestSuite
array.clear();
TS_ASSERT( array.isEmpty() );
}
+
+ void test_iterator( void )
+ {
+ Common::Array<int> array;
+ Common::Array<int>::iterator iter;
+
+ // Fill the array with some random data
+ array.push_back(17);
+ array.push_back(33);
+ array.push_back(-11);
+
+ // Iterate over the array and verify that we encounter the elements in
+ // the order we expect them to be.
+
+ iter = array.begin();
+
+ TS_ASSERT( *iter == 17 );
+ ++iter;
+ TS_ASSERT( iter != array.end() );
+
+ TS_ASSERT( *iter == 33 );
+ ++iter;
+ TS_ASSERT( iter != array.end() );
+
+ // Also test the postinc
+ TS_ASSERT( *iter == -11 );
+ iter++;
+ TS_ASSERT( iter == array.end() );
+ }
+
+ void test_direct_access( void )
+ {
+ Common::Array<int> array;
+
+ // Fill the array with some random data
+ array.push_back(17);
+ array.push_back(33);
+ array.push_back(-11);
+
+ TS_ASSERT( array[0] == 17 );
+ TS_ASSERT( array[1] == 33 );
+ TS_ASSERT( array[2] == -11 );
+ }
};
diff --git a/test/common/list.h b/test/common/list.h
index b52a9c0f21..f5a02af159 100644
--- a/test/common/list.h
+++ b/test/common/list.h
@@ -16,4 +16,76 @@ class ListTestSuite : public CxxTest::TestSuite
list.clear();
TS_ASSERT( list.isEmpty() );
}
+
+ void test_iterator( void )
+ {
+ Common::List<int> list;
+ Common::List<int>::iterator iter;
+
+ // Fill the list with some random data
+ list.push_back(17);
+ list.push_back(33);
+ list.push_back(-11);
+
+ // Iterate over the list and verify that we encounter the elements in
+ // the order we expect them to be.
+
+ iter = list.begin();
+
+ TS_ASSERT( *iter == 17 );
+ ++iter;
+ TS_ASSERT( iter != list.end() );
+
+ TS_ASSERT( *iter == 33 );
+ ++iter;
+ TS_ASSERT( iter != list.end() );
+
+ // Also test the postinc
+ TS_ASSERT( *iter == -11 );
+ iter++;
+ TS_ASSERT( iter == list.end() );
+ }
+
+
+ void test_insert( void )
+ {
+ Common::List<int> list;
+ Common::List<int>::iterator iter;
+
+ // Fill the list with some random data
+ list.push_back(17);
+ list.push_back(33);
+ list.push_back(-11);
+
+ // Iterate to after the second element
+ iter = list.begin();
+ ++iter;
+ ++iter;
+
+ // Now insert some values here
+ list.insert(iter, 42);
+ list.insert(iter, 43);
+
+ iter = list.begin();
+
+ TS_ASSERT( *iter == 17 );
+ ++iter;
+ TS_ASSERT( iter != list.end() );
+
+ TS_ASSERT( *iter == 33 );
+ ++iter;
+ TS_ASSERT( iter != list.end() );
+
+ TS_ASSERT( *iter == 42 );
+ ++iter;
+ TS_ASSERT( iter != list.end() );
+
+ TS_ASSERT( *iter == 43 );
+ ++iter;
+ TS_ASSERT( iter != list.end() );
+
+ TS_ASSERT( *iter == -11 );
+ ++iter;
+ TS_ASSERT( iter == list.end() );
+ }
};