OLD | NEW |
| 1 /* |
| 2 * Copyright 2013 Google Inc. |
| 3 * |
| 4 * Use of this source code is governed by a BSD-style license that can be |
| 5 * found in the LICENSE file. |
| 6 */ |
| 7 |
1 #include "Test.h" | 8 #include "Test.h" |
2 #include "SkTDynamicHash.h" | 9 #include "SkTDynamicHash.h" |
3 | 10 |
4 namespace { | 11 namespace { |
5 | 12 |
6 struct Entry { | 13 struct Entry { |
7 int key; | 14 int key; |
8 double value; | 15 double value; |
9 }; | 16 }; |
| 17 |
10 const int& GetKey(const Entry& entry) { return entry.key; } | 18 const int& GetKey(const Entry& entry) { return entry.key; } |
11 uint32_t GetHash(const int& key) { return key; } | 19 uint32_t GetHash(const int& key) { return key; } |
12 bool AreEqual(const Entry& entry, const int& key) { return entry.key == key; } | 20 bool AreEqual(const Entry& entry, const int& key) { return entry.key == key; } |
13 | 21 |
14 | |
15 class Hash : public SkTDynamicHash<Entry, int, GetKey, GetHash, AreEqual> { | 22 class Hash : public SkTDynamicHash<Entry, int, GetKey, GetHash, AreEqual> { |
16 public: | 23 public: |
17 Hash() : INHERITED() {} | 24 Hash() : INHERITED() {} |
18 Hash(int capacity) : INHERITED(capacity) {} | 25 Hash(int capacity) : INHERITED(capacity) {} |
19 | 26 |
20 // Promote protected methods to public for this test. | 27 // Promote protected methods to public for this test. |
21 int capacity() const { return this->INHERITED::capacity(); } | 28 int capacity() const { return this->INHERITED::capacity(); } |
22 int countCollisions(const int& key) const { return this->INHERITED::countCol
lisions(key); } | 29 int countCollisions(const int& key) const { return this->INHERITED::countCol
lisions(key); } |
23 | 30 |
24 private: | 31 private: |
(...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
134 | 141 |
135 static void test_dynamic_hash(skiatest::Reporter* reporter) { | 142 static void test_dynamic_hash(skiatest::Reporter* reporter) { |
136 test_growth(reporter); | 143 test_growth(reporter); |
137 test_add(reporter); | 144 test_add(reporter); |
138 test_lookup(reporter); | 145 test_lookup(reporter); |
139 test_remove(reporter); | 146 test_remove(reporter); |
140 } | 147 } |
141 | 148 |
142 #include "TestClassDef.h" | 149 #include "TestClassDef.h" |
143 DEFINE_TESTCLASS("DynamicHash", DynamicHashTestClass, test_dynamic_hash); | 150 DEFINE_TESTCLASS("DynamicHash", DynamicHashTestClass, test_dynamic_hash); |
OLD | NEW |