[Scummvm-cvs-logs] CVS: scummvm/test/common array.h,1.1,1.2 list.h,1.1,1.2
Max Horn
fingolfin at users.sourceforge.net
Fri May 21 10:44:38 CEST 2004
Update of /cvsroot/scummvm/scummvm/test/common
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv8192/common
Modified Files:
array.h list.h
Log Message:
Updated unit tests
Index: array.h
===================================================================
RCS file: /cvsroot/scummvm/scummvm/test/common/array.h,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -d -r1.1 -r1.2
--- array.h 12 Apr 2004 01:19:39 -0000 1.1
+++ array.h 21 May 2004 17:43:16 -0000 1.2
@@ -16,4 +16,47 @@
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 );
+ }
};
Index: list.h
===================================================================
RCS file: /cvsroot/scummvm/scummvm/test/common/list.h,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -d -r1.1 -r1.2
--- list.h 24 Dec 2003 16:16:00 -0000 1.1
+++ list.h 21 May 2004 17:43:16 -0000 1.2
@@ -16,4 +16,76 @@
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() );
+ }
};
More information about the Scummvm-git-logs
mailing list