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

Side by Side Diff: tests/DynamicHashTest.cpp

Issue 22318002: old compiler is dumb (Closed) Base URL: https://skia.googlecode.com/svn/trunk
Patch Set: ok cryptic warning, what do you mean Created 7 years, 4 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 | Annotate | Revision Log
« no previous file with comments | « no previous file | 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 #include "Test.h" 1 #include "Test.h"
2 #include "SkTDynamicHash.h" 2 #include "SkTDynamicHash.h"
3 3
4 namespace { 4 namespace {
5 5
6 struct Entry { 6 struct Entry {
7 int key; 7 int key;
8 float value; 8 double value;
9 };
10 const int& GetKey(const Entry& entry) { return entry.key; }
11 uint32_t GetHash(const int& key) { return key; }
12 bool AreEqual(const Entry& entry, const int& key) { return entry.key == key; }
9 13
10 static const int& Key(const Entry& entry) { return entry.key; }
11 static uint32_t Hash(const int& key) { return key; }
12 static bool Equal(const Entry& entry, const int& key) { return entry.key == key; }
13 };
14 14
15 class Hash : public SkTDynamicHash<Entry, int, Entry::Key, Entry::Hash, Entry::E qual> { 15 class Hash : public SkTDynamicHash<Entry, int, GetKey, GetHash, AreEqual> {
16 public: 16 public:
17 Hash() : INHERITED() {} 17 Hash() : INHERITED() {}
18 Hash(int capacity) : INHERITED(capacity) {} 18 Hash(int capacity) : INHERITED(capacity) {}
19 19
20 // Promote protected methods to public for this test. 20 // Promote protected methods to public for this test.
21 int capacity() const { return this->INHERITED::capacity(); } 21 int capacity() const { return this->INHERITED::capacity(); }
22 int countCollisions(const int& key) const { return this->INHERITED::countCol lisions(key); } 22 int countCollisions(const int& key) const { return this->INHERITED::countCol lisions(key); }
23 23
24 private: 24 private:
25 typedef SkTDynamicHash<Entry, int, Entry::Key, Entry::Hash, Entry::Equal> IN HERITED; 25 typedef SkTDynamicHash<Entry, int, GetKey, GetHash, AreEqual> INHERITED;
26 }; 26 };
27 27
28 } // namespace 28 } // namespace
29 29
30 #define ASSERT(x) REPORTER_ASSERT(reporter, x) 30 #define ASSERT(x) REPORTER_ASSERT(reporter, x)
31 31
32 static void test_growth(skiatest::Reporter* reporter) { 32 static void test_growth(skiatest::Reporter* reporter) {
33 Entry a = { 1, 2.0 }; 33 Entry a = { 1, 2.0 };
34 Entry b = { 2, 3.0 }; 34 Entry b = { 2, 3.0 };
35 Entry c = { 3, 4.0 }; 35 Entry c = { 3, 4.0 };
(...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after
142 142
143 static void test_dynamic_hash(skiatest::Reporter* reporter) { 143 static void test_dynamic_hash(skiatest::Reporter* reporter) {
144 test_growth(reporter); 144 test_growth(reporter);
145 test_add(reporter); 145 test_add(reporter);
146 test_lookup(reporter); 146 test_lookup(reporter);
147 test_remove(reporter); 147 test_remove(reporter);
148 } 148 }
149 149
150 #include "TestClassDef.h" 150 #include "TestClassDef.h"
151 DEFINE_TESTCLASS("DynamicHash", DynamicHashTestClass, test_dynamic_hash); 151 DEFINE_TESTCLASS("DynamicHash", DynamicHashTestClass, test_dynamic_hash);
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698