| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright 2010 Google Inc. | 2 * Copyright 2010 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 // This is a GPU-backend specific test | 8 // This is a GPU-backend specific test |
| 9 #if SK_SUPPORT_GPU | 9 #if SK_SUPPORT_GPU |
| 10 | 10 |
| 11 #include "GrBinHashKey.h" | 11 #include "GrBinHashKey.h" |
| 12 | 12 |
| 13 #include "Test.h" | 13 #include "Test.h" |
| 14 | 14 |
| 15 DEF_TEST(GrBinHashKeyTest, reporter) { | 15 DEF_TEST(GrBinHashKey, reporter) { |
| 16 const char* testStringA_ = "abcdABCD"; | 16 const char* testStringA_ = "abcdABCD"; |
| 17 const char* testStringB_ = "abcdBBCD"; | 17 const char* testStringB_ = "abcdBBCD"; |
| 18 const uint32_t* testStringA = reinterpret_cast<const uint32_t*>(testStringA_
); | 18 const uint32_t* testStringA = reinterpret_cast<const uint32_t*>(testStringA_
); |
| 19 const uint32_t* testStringB = reinterpret_cast<const uint32_t*>(testStringB_
); | 19 const uint32_t* testStringB = reinterpret_cast<const uint32_t*>(testStringB_
); |
| 20 enum { | 20 enum { |
| 21 kDataLenUsedForKey = 8 | 21 kDataLenUsedForKey = 8 |
| 22 }; | 22 }; |
| 23 | 23 |
| 24 GrBinHashKey<kDataLenUsedForKey> keyA; | 24 GrBinHashKey<kDataLenUsedForKey> keyA; |
| 25 keyA.setKeyData(testStringA); | 25 keyA.setKeyData(testStringA); |
| 26 // test copy constructor and comparison | 26 // test copy constructor and comparison |
| 27 GrBinHashKey<kDataLenUsedForKey> keyA2(keyA); | 27 GrBinHashKey<kDataLenUsedForKey> keyA2(keyA); |
| 28 REPORTER_ASSERT(reporter, keyA == keyA2); | 28 REPORTER_ASSERT(reporter, keyA == keyA2); |
| 29 REPORTER_ASSERT(reporter, keyA.getHash() == keyA2.getHash()); | 29 REPORTER_ASSERT(reporter, keyA.getHash() == keyA2.getHash()); |
| 30 // test re-init | 30 // test re-init |
| 31 keyA2.setKeyData(testStringA); | 31 keyA2.setKeyData(testStringA); |
| 32 REPORTER_ASSERT(reporter, keyA == keyA2); | 32 REPORTER_ASSERT(reporter, keyA == keyA2); |
| 33 REPORTER_ASSERT(reporter, keyA.getHash() == keyA2.getHash()); | 33 REPORTER_ASSERT(reporter, keyA.getHash() == keyA2.getHash()); |
| 34 // test sorting | 34 // test sorting |
| 35 GrBinHashKey<kDataLenUsedForKey> keyB; | 35 GrBinHashKey<kDataLenUsedForKey> keyB; |
| 36 keyB.setKeyData(testStringB); | 36 keyB.setKeyData(testStringB); |
| 37 REPORTER_ASSERT(reporter, keyA < keyB); | 37 REPORTER_ASSERT(reporter, keyA < keyB); |
| 38 REPORTER_ASSERT(reporter, keyA.getHash() != keyB.getHash()); | 38 REPORTER_ASSERT(reporter, keyA.getHash() != keyB.getHash()); |
| 39 } | 39 } |
| 40 | 40 |
| 41 #endif | 41 #endif |
| OLD | NEW |