| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright 2012 Google Inc. | 2 * Copyright 2012 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 | 8 |
| 9 #include "Test.h" | 9 #include "Test.h" |
| 10 | 10 |
| (...skipping 21 matching lines...) Expand all Loading... |
| 32 return elem->fValue < 0; | 32 return elem->fValue < 0; |
| 33 } | 33 } |
| 34 }; | 34 }; |
| 35 | 35 |
| 36 class HashKey { | 36 class HashKey { |
| 37 public: | 37 public: |
| 38 HashKey(int key) : fKey(key) {} | 38 HashKey(int key) : fKey(key) {} |
| 39 | 39 |
| 40 uint32_t getHash() const { return fKey; } | 40 uint32_t getHash() const { return fKey; } |
| 41 | 41 |
| 42 static bool LT(const HashElement& entry, const HashKey& key) { | 42 static bool LessThan(const HashElement& entry, const HashKey& key) { |
| 43 return entry.fKey < key.fKey; | 43 return entry.fKey < key.fKey; |
| 44 } | 44 } |
| 45 static bool EQ(const HashElement& entry, const HashKey& key) { | 45 static bool Equals(const HashElement& entry, const HashKey& key) { |
| 46 return entry.fKey == key.fKey; | 46 return entry.fKey == key.fKey; |
| 47 } | 47 } |
| 48 | 48 |
| 49 #ifdef SK_DEBUG | 49 #ifdef SK_DEBUG |
| 50 static uint32_t GetHash(const HashElement& entry) { | 50 static bool LessThan(const HashElement& a, const HashElement& b) { |
| 51 return entry.fKey; | |
| 52 } | |
| 53 static bool LT(const HashElement& a, const HashElement& b) { | |
| 54 return a.fKey < b.fKey; | 51 return a.fKey < b.fKey; |
| 55 } | 52 } |
| 56 static bool EQ(const HashElement& a, const HashElement& b) { | 53 static bool Equals(const HashElement& a, const HashElement& b) { |
| 57 return a.fKey == b.fKey; | 54 return a.fKey == b.fKey; |
| 58 } | 55 } |
| 59 #endif | 56 #endif |
| 60 | 57 |
| 61 protected: | 58 protected: |
| 62 int fKey; | 59 int fKey; |
| 63 }; | 60 }; |
| 64 | 61 |
| 65 //////////////////////////////////////////////////////////////////////////////// | 62 //////////////////////////////////////////////////////////////////////////////// |
| 66 static void TestHashCache(skiatest::Reporter* reporter) { | 63 static void TestHashCache(skiatest::Reporter* reporter) { |
| (...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 155 HashElement* found = cache.find(0); | 152 HashElement* found = cache.find(0); |
| 156 REPORTER_ASSERT(reporter, NULL == found); | 153 REPORTER_ASSERT(reporter, NULL == found); |
| 157 } | 154 } |
| 158 } | 155 } |
| 159 | 156 |
| 160 //////////////////////////////////////////////////////////////////////////////// | 157 //////////////////////////////////////////////////////////////////////////////// |
| 161 #include "TestClassDef.h" | 158 #include "TestClassDef.h" |
| 162 DEFINE_TESTCLASS("HashCache", HashCacheTestClass, TestHashCache) | 159 DEFINE_TESTCLASS("HashCache", HashCacheTestClass, TestHashCache) |
| 163 | 160 |
| 164 #endif | 161 #endif |
| OLD | NEW |