Commit c58eae6c authored by kling@webkit.org's avatar kling@webkit.org
Browse files

Future-proof the WTF.DoubleHashCollisions test.

<http://webkit.org/b/98853>

Reviewed by Anders Carlsson.

Add a check that the two keys that are supposed to clobber each other actually end up
in the same bucket with the DefaultHash<double> hash function.

* TestWebKitAPI/Tests/WTF/HashMap.cpp:
(TestWebKitAPI::bucketForKey):
(TestWebKitAPI):
(TestWebKitAPI::TEST):


git-svn-id: http://svn.webkit.org/repository/webkit/trunk@130905 268f45cc-cd09-0410-ab3c-d52691b4dbfc
parent 48d757be
2012-10-10 Andreas Kling <kling@webkit.org>
Future-proof the WTF.DoubleHashCollisions test.
<http://webkit.org/b/98853>
Reviewed by Anders Carlsson.
Add a check that the two keys that are supposed to clobber each other actually end up
in the same bucket with the DefaultHash<double> hash function.
* TestWebKitAPI/Tests/WTF/HashMap.cpp:
(TestWebKitAPI::bucketForKey):
(TestWebKitAPI):
(TestWebKitAPI::TEST):
2012-10-10 Balazs Kelemen <kbalazs@webkit.org>
[Qt] Test drivers should handle repaint rects
......
......@@ -55,6 +55,11 @@ struct TestDoubleHashTraits : HashTraits<double> {
typedef HashMap<double, int64_t, DefaultHash<double>::Hash, TestDoubleHashTraits> DoubleHashMap;
static int bucketForKey(double key)
{
return DefaultHash<double>::Hash::hash(key) & (TestDoubleHashTraits::minimumTableSize - 1);
}
TEST(WTF, DoubleHashCollisions)
{
// The "clobber" key here is one that ends up stealing the bucket that the -0 key
......@@ -70,6 +75,7 @@ TEST(WTF, DoubleHashCollisions)
map.add(zeroKey, 2);
map.add(negativeZeroKey, 3);
ASSERT_EQ(bucketForKey(clobberKey), bucketForKey(negativeZeroKey));
ASSERT_EQ(map.get(clobberKey), 1);
ASSERT_EQ(map.get(zeroKey), 2);
ASSERT_EQ(map.get(negativeZeroKey), 3);
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment