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

Side by Side Diff: tests/GrBinHashKeyTest.cpp

Issue 402693003: Replace GrTHash with SkTDynamicHash (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Fix compiler complaints Created 6 years, 5 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
« src/gpu/GrBinHashKey.h ('K') | « tests/DynamicHashTest.cpp ('k') | 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 /* 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(GrBinHashKey, reporter) { 15 template<typename KeyType> static void TestHash(skiatest::Reporter* 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 {
21 kDataLenUsedForKey = 8
22 };
23 20
24 GrBinHashKey<kDataLenUsedForKey> keyA; 21 KeyType keyA;
25 keyA.setKeyData(testStringA); 22 keyA.setKeyData(testStringA);
26 // test copy constructor and comparison 23 // test copy constructor and comparison
27 GrBinHashKey<kDataLenUsedForKey> keyA2(keyA); 24 KeyType keyA2(keyA);
28 REPORTER_ASSERT(reporter, keyA == keyA2); 25 REPORTER_ASSERT(reporter, keyA == keyA2);
29 REPORTER_ASSERT(reporter, keyA.getHash() == keyA2.getHash()); 26 REPORTER_ASSERT(reporter, keyA.getHash() == keyA2.getHash());
30 // test re-init 27 // test re-init
31 keyA2.setKeyData(testStringA); 28 keyA2.setKeyData(testStringA);
32 REPORTER_ASSERT(reporter, keyA == keyA2); 29 REPORTER_ASSERT(reporter, keyA == keyA2);
33 REPORTER_ASSERT(reporter, keyA.getHash() == keyA2.getHash()); 30 REPORTER_ASSERT(reporter, keyA.getHash() == keyA2.getHash());
34 // test sorting 31 // test sorting
35 GrBinHashKey<kDataLenUsedForKey> keyB; 32 KeyType keyB;
36 keyB.setKeyData(testStringB); 33 keyB.setKeyData(testStringB);
37 REPORTER_ASSERT(reporter, keyA < keyB);
38 REPORTER_ASSERT(reporter, keyA.getHash() != keyB.getHash()); 34 REPORTER_ASSERT(reporter, keyA.getHash() != keyB.getHash());
39 } 35 }
40 36
37
38 DEF_TEST(GrBinHashKey, reporter) {
39 enum {
40 kDataLenUsedForKey = 8
41 };
42
43 TestHash<GrBinHashKey<kDataLenUsedForKey> >(reporter);
44 TestHash<GrMurmur3HashKey<kDataLenUsedForKey> >(reporter);
45 }
46
41 #endif 47 #endif
OLDNEW
« src/gpu/GrBinHashKey.h ('K') | « tests/DynamicHashTest.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698