From 7a772513c54387141dbbff1a8f0c125d1a2b74e9 Mon Sep 17 00:00:00 2001 From: Max Horn Date: Fri, 21 May 2004 17:43:16 +0000 Subject: Updated unit tests svn-id: r13847 --- test/common/array.h | 43 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 43 insertions(+) (limited to 'test/common/array.h') 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 array; + Common::Array::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 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 ); + } }; -- cgit v1.2.3