From 867c0d9645a6475e000cd7f49d72450517aea9aa Mon Sep 17 00:00:00 2001 From: Johannes Schickel Date: Sun, 30 Jan 2011 17:28:35 +0000 Subject: COMMON: Add an erase method which takes an iterator to HashMap. Currently there is no iterator returned from this method, to have some similarity to associative containers of the STL. I also "added" one unit test for this method, which is basically just a copy of the HashMap::erase(const Key &) test with the required adaptions. svn-id: r55661 --- test/common/hashmap.h | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) (limited to 'test') diff --git a/test/common/hashmap.h b/test/common/hashmap.h index b90d91467c..f54c65b801 100644 --- a/test/common/hashmap.h +++ b/test/common/hashmap.h @@ -71,6 +71,35 @@ class HashMapTestSuite : public CxxTest::TestSuite TS_ASSERT(container.empty()); } + void test_add_remove_iterator() { + Common::HashMap container; + container[0] = 17; + container[1] = 33; + container[2] = 45; + container[3] = 12; + container[4] = 96; + TS_ASSERT(container.contains(1)); + container.erase(container.find(1)); + TS_ASSERT(!container.contains(1)); + container[1] = 42; + TS_ASSERT(container.contains(1)); + container.erase(container.find(0)); + TS_ASSERT(!container.empty()); + container.erase(container.find(1)); + TS_ASSERT(!container.empty()); + container.erase(container.find(2)); + TS_ASSERT(!container.empty()); + container.erase(container.find(3)); + TS_ASSERT(!container.empty()); + container.erase(container.find(4)); + TS_ASSERT(container.empty()); + container[1] = 33; + TS_ASSERT(container.contains(1)); + TS_ASSERT(!container.empty()); + container.erase(container.find(1)); + TS_ASSERT(container.empty()); + } + void test_lookup() { Common::HashMap container; container[0] = 17; -- cgit v1.2.3