aboutsummaryrefslogtreecommitdiffhomepage
path: root/tests/DynamicHashTest.cpp
diff options
context:
space:
mode:
authorGravatar mtklein@google.com <mtklein@google.com@2bbb7eff-a529-9590-31e7-b0007b416f81>2013-08-12 14:51:25 +0000
committerGravatar mtklein@google.com <mtklein@google.com@2bbb7eff-a529-9590-31e7-b0007b416f81>2013-08-12 14:51:25 +0000
commitc9ab2b7dd8411f8a78654b237c69a5886567dfec (patch)
tree3260584eecd429828cf923cec2e9393f0c9b7857 /tests/DynamicHashTest.cpp
parentfb4a68de439b59fd71cea47ca1fd4e9f58844d2a (diff)
SkTDynamicHash
- add validate() - make add() and remove() strict - fill in maybeShrink() - make grow and shrink thresholds configurable. - fix issue where we were getting filled with deleted items - we need to count them as occupied when determining if we should grow BUG= R=reed@google.com Review URL: https://codereview.chromium.org/22571010 git-svn-id: http://skia.googlecode.com/svn/trunk@10677 2bbb7eff-a529-9590-31e7-b0007b416f81
Diffstat (limited to 'tests/DynamicHashTest.cpp')
-rw-r--r--tests/DynamicHashTest.cpp18
1 files changed, 5 insertions, 13 deletions
diff --git a/tests/DynamicHashTest.cpp b/tests/DynamicHashTest.cpp
index 4a8c3a01a2..2425ea24ca 100644
--- a/tests/DynamicHashTest.cpp
+++ b/tests/DynamicHashTest.cpp
@@ -36,23 +36,23 @@ static void test_growth(skiatest::Reporter* reporter) {
Entry d = { 4, 5.0 };
Entry e = { 5, 6.0 };
- Hash hash(0);
- ASSERT(hash.capacity() == 1);
+ Hash hash(4);
+ ASSERT(hash.capacity() == 4);
hash.add(&a);
- ASSERT(hash.capacity() == 2);
+ ASSERT(hash.capacity() == 4);
hash.add(&b);
ASSERT(hash.capacity() == 4);
hash.add(&c);
- ASSERT(hash.capacity() == 8);
+ ASSERT(hash.capacity() == 4);
hash.add(&d);
ASSERT(hash.capacity() == 8);
hash.add(&e);
- ASSERT(hash.capacity() == 16);
+ ASSERT(hash.capacity() == 8);
ASSERT(hash.count() == 5);
}
@@ -61,20 +61,12 @@ static void test_add(skiatest::Reporter* reporter) {
Hash hash;
Entry a = { 1, 2.0 };
Entry b = { 2, 3.0 };
- Entry c = { 1, 1.0 };
ASSERT(hash.count() == 0);
hash.add(&a);
ASSERT(hash.count() == 1);
hash.add(&b);
ASSERT(hash.count() == 2);
- hash.add(&c); // Overwrites a.
- ASSERT(hash.count() == 2);
-
- // Make sure the hash didn't modify the entries we inserted when overwriting.
- ASSERT(a.value == 2.0);
- ASSERT(b.value == 3.0);
- ASSERT(c.value == 1.0);
}
static void test_lookup(skiatest::Reporter* reporter) {