blob: 96b851f8b0079460a5e7f71a954bdffc12389e42 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
|
/*
* Copyright 2010 Google Inc.
*
* Use of this source code is governed by a BSD-style license that can be
* found in the LICENSE file.
*/
// This is a GPU-backend specific test
#if SK_SUPPORT_GPU
#include "GrBinHashKey.h"
#include "Test.h"
DEF_TEST(GrBinHashKeyTest, reporter) {
const char* testStringA_ = "abcdABCD";
const char* testStringB_ = "abcdBBCD";
const uint32_t* testStringA = reinterpret_cast<const uint32_t*>(testStringA_);
const uint32_t* testStringB = reinterpret_cast<const uint32_t*>(testStringB_);
enum {
kDataLenUsedForKey = 8
};
GrBinHashKey<kDataLenUsedForKey> keyA;
keyA.setKeyData(testStringA);
// test copy constructor and comparison
GrBinHashKey<kDataLenUsedForKey> keyA2(keyA);
REPORTER_ASSERT(reporter, keyA == keyA2);
REPORTER_ASSERT(reporter, keyA.getHash() == keyA2.getHash());
// test re-init
keyA2.setKeyData(testStringA);
REPORTER_ASSERT(reporter, keyA == keyA2);
REPORTER_ASSERT(reporter, keyA.getHash() == keyA2.getHash());
// test sorting
GrBinHashKey<kDataLenUsedForKey> keyB;
keyB.setKeyData(testStringB);
REPORTER_ASSERT(reporter, keyA < keyB);
REPORTER_ASSERT(reporter, keyA.getHash() != keyB.getHash());
}
#endif
|