aboutsummaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorWillem Jan Palenstijn2009-06-09 15:26:09 +0000
committerWillem Jan Palenstijn2009-06-09 15:26:09 +0000
commitfcc0b69c073399d4af0443108eaa22cb630b276f (patch)
treeab9b758023a7a82264ef719342ad2d7cdedd1529 /test
parentac46c98fb82f124bad5f2ece496b885a344e2cde (diff)
downloadscummvm-rg350-fcc0b69c073399d4af0443108eaa22cb630b276f.tar.gz
scummvm-rg350-fcc0b69c073399d4af0443108eaa22cb630b276f.tar.bz2
scummvm-rg350-fcc0b69c073399d4af0443108eaa22cb630b276f.zip
Add (failing) hashmap test case for collision handling
svn-id: r41400
Diffstat (limited to 'test')
-rw-r--r--test/common/hashmap.h43
1 files changed, 43 insertions, 0 deletions
diff --git a/test/common/hashmap.h b/test/common/hashmap.h
index c62f909f95..13f630430c 100644
--- a/test/common/hashmap.h
+++ b/test/common/hashmap.h
@@ -108,5 +108,48 @@ class HashMapTestSuite : public CxxTest::TestSuite
TS_ASSERT_EQUALS(container2[323], 32);
}
+ void test_collision() {
+ // NB: The usefulness of this example depends strongly on the
+ // specific hashmap implementation.
+ // It is constructed to insert multiple colliding elements.
+ Common::HashMap<int, int> h;
+ h[5] = 1;
+ h[32+5] = 1;
+ h[64+5] = 1;
+ h[128+5] = 1;
+ TS_ASSERT(h.contains(5));
+ TS_ASSERT(h.contains(32+5));
+ TS_ASSERT(h.contains(64+5));
+ TS_ASSERT(h.contains(128+5));
+ h.erase(32+5);
+ TS_ASSERT(h.contains(5));
+ TS_ASSERT(h.contains(64+5));
+ TS_ASSERT(h.contains(128+5));
+ h.erase(5);
+ TS_ASSERT(h.contains(64+5));
+ TS_ASSERT(h.contains(128+5));
+ h[32+5] = 1;
+ TS_ASSERT(h.contains(32+5));
+ TS_ASSERT(h.contains(64+5));
+ TS_ASSERT(h.contains(128+5));
+ h[5] = 1;
+ TS_ASSERT(h.contains(5));
+ TS_ASSERT(h.contains(32+5));
+ TS_ASSERT(h.contains(64+5));
+ TS_ASSERT(h.contains(128+5));
+ h.erase(5);
+ TS_ASSERT(h.contains(32+5));
+ TS_ASSERT(h.contains(64+5));
+ TS_ASSERT(h.contains(128+5));
+ h.erase(64+5);
+ TS_ASSERT(h.contains(32+5));
+ TS_ASSERT(h.contains(128+5));
+ h.erase(128+5);
+ TS_ASSERT(h.contains(32+5));
+ h.erase(32+5);
+ TS_ASSERT(h.empty());
+ }
+
+
// TODO: Add test cases for iterators, find, ...
};