diff options
author | Johannes Schickel | 2011-01-30 17:28:35 +0000 |
---|---|---|
committer | Johannes Schickel | 2011-01-30 17:28:35 +0000 |
commit | 867c0d9645a6475e000cd7f49d72450517aea9aa (patch) | |
tree | bc7671373f28ee98f7d3c8d40dc28e8c0633f45d /test/common/hashmap.h | |
parent | ec885e5665b662f5c531d790e80fd064b3c4c428 (diff) | |
download | scummvm-rg350-867c0d9645a6475e000cd7f49d72450517aea9aa.tar.gz scummvm-rg350-867c0d9645a6475e000cd7f49d72450517aea9aa.tar.bz2 scummvm-rg350-867c0d9645a6475e000cd7f49d72450517aea9aa.zip |
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
Diffstat (limited to 'test/common/hashmap.h')
-rw-r--r-- | test/common/hashmap.h | 29 |
1 files changed, 29 insertions, 0 deletions
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<int, int> 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<int, int> container; container[0] = 17; |