blob: 96b851f8b0079460a5e7f71a954bdffc12389e42 [file] [log] [blame]
tfarina@chromium.orgbbff2082014-01-31 21:48:52 +00001/*
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 "GrBinHashKey.h"
12
13#include "Test.h"
14
15DEF_TEST(GrBinHashKeyTest, reporter) {
16 const char* testStringA_ = "abcdABCD";
17 const char* testStringB_ = "abcdBBCD";
18 const uint32_t* testStringA = reinterpret_cast<const uint32_t*>(testStringA_);
19 const uint32_t* testStringB = reinterpret_cast<const uint32_t*>(testStringB_);
20 enum {
21 kDataLenUsedForKey = 8
22 };
23
24 GrBinHashKey<kDataLenUsedForKey> keyA;
25 keyA.setKeyData(testStringA);
26 // test copy constructor and comparison
27 GrBinHashKey<kDataLenUsedForKey> keyA2(keyA);
28 REPORTER_ASSERT(reporter, keyA == keyA2);
29 REPORTER_ASSERT(reporter, keyA.getHash() == keyA2.getHash());
30 // test re-init
31 keyA2.setKeyData(testStringA);
32 REPORTER_ASSERT(reporter, keyA == keyA2);
33 REPORTER_ASSERT(reporter, keyA.getHash() == keyA2.getHash());
34 // test sorting
35 GrBinHashKey<kDataLenUsedForKey> keyB;
36 keyB.setKeyData(testStringB);
37 REPORTER_ASSERT(reporter, keyA < keyB);
38 REPORTER_ASSERT(reporter, keyA.getHash() != keyB.getHash());
39}
40
41#endif