From d3e08aedbb838a36d4ecfc11f87314cf2f1db04f Mon Sep 17 00:00:00 2001 From: Max Horn Date: Tue, 28 Mar 2006 15:16:04 +0000 Subject: Adapted unit tests to current situation svn-id: r21481 --- test/common/hashmap.h | 43 +++++++++++++++++++++++++++++++++++++++++++ test/common/map.h | 6 ++++-- 2 files changed, 47 insertions(+), 2 deletions(-) create mode 100644 test/common/hashmap.h (limited to 'test/common') diff --git a/test/common/hashmap.h b/test/common/hashmap.h new file mode 100644 index 0000000000..85da1487f4 --- /dev/null +++ b/test/common/hashmap.h @@ -0,0 +1,43 @@ +#include + +#include "common/stdafx.h" +#include "common/hashmap.h" + +class HashMapTestSuite : public CxxTest::TestSuite +{ + public: + void test_empty_clear( void ) + { + Common::HashMap map; + TS_ASSERT( map.empty() ); + map[0] = 17; + map[1] = 33; + TS_ASSERT( !map.empty() ); + map.clear(); + TS_ASSERT( map.empty() ); + } + void test_contains( void ) + { + Common::HashMap map; + map[0] = 17; + map[1] = 33; + TS_ASSERT( map.contains(0) ); + TS_ASSERT( map.contains(1) ); + TS_ASSERT( !map.contains(17) ); + TS_ASSERT( !map.contains(-1) ); + } + + void test_add_remove( void ) + { + Common::HashMap map; + map[0] = 17; + map[1] = 33; + TS_ASSERT( map.contains(1) ); + map.erase(1); + TS_ASSERT( !map.contains(1) ); + map[1] = 42; + TS_ASSERT( map.contains(1) ); + } + + // TODO: Add test cases for iterators, find, ... +}; diff --git a/test/common/map.h b/test/common/map.h index 00e5f6c9f6..c113ffe987 100644 --- a/test/common/map.h +++ b/test/common/map.h @@ -33,9 +33,9 @@ class MapTestSuite : public CxxTest::TestSuite map[0] = 17; map[1] = 33; TS_ASSERT( map.contains(1) ); - map.remove(1); + map.erase(1); TS_ASSERT( !map.contains(1) ); - map.addKey(1); + map[1] = 42; TS_ASSERT( map.contains(1) ); } @@ -61,4 +61,6 @@ class MapTestSuite : public CxxTest::TestSuite TS_ASSERT_EQUALS( mapA[3], 12 ); TS_ASSERT_EQUALS( mapA[4], 96 ); } + + // TODO: Add test cases for iterators, find, ... }; -- cgit v1.2.3