| 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 | |
| 9 #include "Test.h" | 8 #include "Test.h" |
| 9 #include "TestClassDef.h" |
| 10 | 10 |
| 11 // This is a GR test | 11 // This is a GR test |
| 12 #if SK_SUPPORT_GPU | 12 #if SK_SUPPORT_GPU |
| 13 #include "GrTHashTable.h" | 13 #include "GrTHashTable.h" |
| 14 | 14 |
| 15 struct HashElement { | 15 struct HashElement { |
| 16 int fKey; | 16 int fKey; |
| 17 int fValue; | 17 int fValue; |
| 18 }; | 18 }; |
| 19 | 19 |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 52 } | 52 } |
| 53 static bool Equals(const HashElement& a, const HashElement& b) { | 53 static bool Equals(const HashElement& a, const HashElement& b) { |
| 54 return a.fKey == b.fKey; | 54 return a.fKey == b.fKey; |
| 55 } | 55 } |
| 56 #endif | 56 #endif |
| 57 | 57 |
| 58 protected: | 58 protected: |
| 59 int fKey; | 59 int fKey; |
| 60 }; | 60 }; |
| 61 | 61 |
| 62 //////////////////////////////////////////////////////////////////////////////// | 62 DEF_TEST(HashCache, reporter) { |
| 63 static void TestHashCache(skiatest::Reporter* reporter) { | |
| 64 | |
| 65 GrTHashTable<HashElement, HashKey, 4> cache; | 63 GrTHashTable<HashElement, HashKey, 4> cache; |
| 66 | 64 |
| 67 HashElement negHashElements[10] = { | 65 HashElement negHashElements[10] = { |
| 68 { 0, 0 }, | 66 { 0, 0 }, |
| 69 { 1, -1 }, | 67 { 1, -1 }, |
| 70 { 2, -2 }, | 68 { 2, -2 }, |
| 71 { 3, -3 }, | 69 { 3, -3 }, |
| 72 { 4, -4 }, | 70 { 4, -4 }, |
| 73 { 5, -5 }, | 71 { 5, -5 }, |
| 74 { 6, -6 }, | 72 { 6, -6 }, |
| (...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 147 { | 145 { |
| 148 cache.remove(0, &negHashElements[0]); | 146 cache.remove(0, &negHashElements[0]); |
| 149 cache.remove(0, &posHashElements[0]); | 147 cache.remove(0, &posHashElements[0]); |
| 150 REPORTER_ASSERT(reporter, 18 == cache.count()); | 148 REPORTER_ASSERT(reporter, 18 == cache.count()); |
| 151 | 149 |
| 152 HashElement* found = cache.find(0); | 150 HashElement* found = cache.find(0); |
| 153 REPORTER_ASSERT(reporter, NULL == found); | 151 REPORTER_ASSERT(reporter, NULL == found); |
| 154 } | 152 } |
| 155 } | 153 } |
| 156 | 154 |
| 157 //////////////////////////////////////////////////////////////////////////////// | |
| 158 #include "TestClassDef.h" | |
| 159 DEFINE_TESTCLASS("HashCache", HashCacheTestClass, TestHashCache) | |
| 160 | |
| 161 #endif | 155 #endif |
| OLD | NEW |