OLD | NEW |
1 /* | 1 /* |
2 * Copyright 2013 Google Inc. | 2 * Copyright 2013 Google Inc. |
3 * | 3 * |
4 * Use of this source code is governed by a BSD-style license that can be | 4 * Use of this source code is governed by a BSD-style license that can be |
5 * found in the LICENSE file. | 5 * found in the LICENSE file. |
6 */ | 6 */ |
7 | 7 |
8 #include "Test.h" | 8 #include "Test.h" |
| 9 #include "TestClassDef.h" |
9 #include "SkTDynamicHash.h" | 10 #include "SkTDynamicHash.h" |
10 | 11 |
11 namespace { | 12 namespace { |
12 | 13 |
13 struct Entry { | 14 struct Entry { |
14 int key; | 15 int key; |
15 double value; | 16 double value; |
16 }; | 17 }; |
17 | 18 |
18 const int& GetKey(const Entry& entry) { return entry.key; } | 19 const int& GetKey(const Entry& entry) { return entry.key; } |
(...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
132 | 133 |
133 // This will go in the same slot as 'a' did before. | 134 // This will go in the same slot as 'a' did before. |
134 ASSERT(hash.countCollisions(9) == 0); | 135 ASSERT(hash.countCollisions(9) == 0); |
135 hash.add(&c); | 136 hash.add(&c); |
136 ASSERT(hash.find(9) != NULL); | 137 ASSERT(hash.find(9) != NULL); |
137 ASSERT(hash.find(9)->value == 4.0); | 138 ASSERT(hash.find(9)->value == 4.0); |
138 ASSERT(hash.find(5) != NULL); | 139 ASSERT(hash.find(5) != NULL); |
139 ASSERT(hash.find(5)->value == 3.0); | 140 ASSERT(hash.find(5)->value == 3.0); |
140 } | 141 } |
141 | 142 |
142 static void test_dynamic_hash(skiatest::Reporter* reporter) { | 143 DEF_TEST(DynamicHash, reporter) { |
143 test_growth(reporter); | 144 test_growth(reporter); |
144 test_add(reporter); | 145 test_add(reporter); |
145 test_lookup(reporter); | 146 test_lookup(reporter); |
146 test_remove(reporter); | 147 test_remove(reporter); |
147 } | 148 } |
148 | |
149 #include "TestClassDef.h" | |
150 DEFINE_TESTCLASS("DynamicHash", DynamicHashTestClass, test_dynamic_hash); | |
OLD | NEW |