| OLD | NEW |
| (Empty) |
| 1 /* | |
| 2 * Copyright 2010 Google Inc. | |
| 3 * | |
| 4 * Use of this source code is governed by a BSD-style license that can be | |
| 5 * found in the LICENSE file. | |
| 6 */ | |
| 7 | |
| 8 // This is a GPU-backend specific test | |
| 9 #if SK_SUPPORT_GPU | |
| 10 | |
| 11 #include "GrMurmur3HashKey.h" | |
| 12 #include "GrBinHashKey.h" | |
| 13 | |
| 14 #include "Test.h" | |
| 15 | |
| 16 struct AlignedKey { | |
| 17 uint32_t align; | |
| 18 char key[8]; | |
| 19 }; | |
| 20 | |
| 21 template<typename KeyType> static void TestHash(skiatest::Reporter* reporter) { | |
| 22 AlignedKey a, b; | |
| 23 memcpy(&a.key, "abcdABCD", 8); | |
| 24 memcpy(&b.key, "abcdBBCD", 8); | |
| 25 const uint32_t* testStringA = reinterpret_cast<const uint32_t*>(&a.key); | |
| 26 const uint32_t* testStringB = reinterpret_cast<const uint32_t*>(&b.key); | |
| 27 | |
| 28 KeyType keyA; | |
| 29 keyA.setKeyData(testStringA); | |
| 30 // test copy constructor and comparison | |
| 31 KeyType keyA2(keyA); | |
| 32 REPORTER_ASSERT(reporter, keyA == keyA2); | |
| 33 REPORTER_ASSERT(reporter, keyA.getHash() == keyA2.getHash()); | |
| 34 // test re-init | |
| 35 keyA2.setKeyData(testStringA); | |
| 36 REPORTER_ASSERT(reporter, keyA == keyA2); | |
| 37 REPORTER_ASSERT(reporter, keyA.getHash() == keyA2.getHash()); | |
| 38 // test sorting | |
| 39 KeyType keyB; | |
| 40 keyB.setKeyData(testStringB); | |
| 41 REPORTER_ASSERT(reporter, keyA.getHash() != keyB.getHash()); | |
| 42 } | |
| 43 | |
| 44 | |
| 45 DEF_TEST(GrBinHashKey, reporter) { | |
| 46 enum { | |
| 47 kDataLenUsedForKey = 8 | |
| 48 }; | |
| 49 | |
| 50 TestHash<GrBinHashKey<kDataLenUsedForKey> >(reporter); | |
| 51 TestHash<GrMurmur3HashKey<kDataLenUsedForKey> >(reporter); | |
| 52 } | |
| 53 | |
| 54 #endif | |
| OLD | NEW |