Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(140)

Side by Side Diff: tests/DynamicHashTest.cpp

Issue 222343002: SkTDynamicHash: remove need for Equals(const T&, const Key&) param. (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Created 6 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « src/gpu/GrTMultiMap.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 "SkTDynamicHash.h" 8 #include "SkTDynamicHash.h"
9 #include "Test.h" 9 #include "Test.h"
10 10
11 namespace { 11 namespace {
12 12
13 struct Entry { 13 struct Entry {
14 int key; 14 int key;
15 double value; 15 double value;
16 }; 16 };
17 17
18 const int& GetKey(const Entry& entry) { return entry.key; } 18 const int& GetKey(const Entry& entry) { return entry.key; }
19 uint32_t GetHash(const int& key) { return key; } 19 uint32_t GetHash(const int& key) { return key; }
20 bool AreEqual(const Entry& entry, const int& key) { return entry.key == key; }
21 20
22 class Hash : public SkTDynamicHash<Entry, int, GetKey, GetHash, AreEqual> { 21 class Hash : public SkTDynamicHash<Entry, int, GetKey, GetHash> {
23 public: 22 public:
24 Hash() : INHERITED() {} 23 Hash() : INHERITED() {}
25 24
26 // Promote protected methods to public for this test. 25 // Promote protected methods to public for this test.
27 int capacity() const { return this->INHERITED::capacity(); } 26 int capacity() const { return this->INHERITED::capacity(); }
28 int countCollisions(const int& key) const { return this->INHERITED::countCol lisions(key); } 27 int countCollisions(const int& key) const { return this->INHERITED::countCol lisions(key); }
29 28
30 private: 29 private:
31 typedef SkTDynamicHash<Entry, int, GetKey, GetHash, AreEqual> INHERITED; 30 typedef SkTDynamicHash<Entry, int, GetKey, GetHash> INHERITED;
32 }; 31 };
33 32
34 } // namespace 33 } // namespace
35 34
36 #define ASSERT(x) REPORTER_ASSERT(reporter, x) 35 #define ASSERT(x) REPORTER_ASSERT(reporter, x)
37 36
38 DEF_TEST(DynamicHash_growth, reporter) { 37 DEF_TEST(DynamicHash_growth, reporter) {
39 Entry a = { 1, 2.0 }; 38 Entry a = { 1, 2.0 };
40 Entry b = { 2, 3.0 }; 39 Entry b = { 2, 3.0 };
41 Entry c = { 3, 4.0 }; 40 Entry c = { 3, 4.0 };
(...skipping 134 matching lines...) Expand 10 before | Expand all | Expand 10 after
176 for (Hash::Iter iter(&hash); !iter.done(); ++iter) { 175 for (Hash::Iter iter(&hash); !iter.done(); ++iter) {
177 int key = (*iter).key; 176 int key = (*iter).key;
178 keys[count] = key; 177 keys[count] = key;
179 ASSERT(key != 1); 178 ASSERT(key != 1);
180 ASSERT(hash.find(key) != NULL); 179 ASSERT(hash.find(key) != NULL);
181 ++count; 180 ++count;
182 } 181 }
183 ASSERT(2 == count); 182 ASSERT(2 == count);
184 ASSERT(keys[0] != keys[1]); 183 ASSERT(keys[0] != keys[1]);
185 } 184 }
OLDNEW
« no previous file with comments | « src/gpu/GrTMultiMap.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698