2011-07-28 14:26:00 +00:00
|
|
|
/*
|
|
|
|
* Copyright 2010 Google Inc.
|
|
|
|
*
|
|
|
|
* Use of this source code is governed by a BSD-style license that can be
|
|
|
|
* found in the LICENSE file.
|
2010-12-22 21:39:39 +00:00
|
|
|
*/
|
|
|
|
|
2013-11-28 08:24:29 +00:00
|
|
|
// This is a GPU-backend specific test
|
|
|
|
#if SK_SUPPORT_GPU
|
2010-12-22 21:39:39 +00:00
|
|
|
|
2014-01-31 21:48:52 +00:00
|
|
|
#include "GrBinHashKey.h"
|
2013-11-28 08:24:29 +00:00
|
|
|
|
2014-01-31 21:48:52 +00:00
|
|
|
#include "Test.h"
|
2010-12-22 21:39:39 +00:00
|
|
|
|
2014-06-24 13:50:39 +00:00
|
|
|
DEF_TEST(GrBinHashKey, reporter) {
|
2011-08-18 18:15:16 +00:00
|
|
|
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_);
|
2011-03-31 21:26:24 +00:00
|
|
|
enum {
|
2011-06-01 20:43:05 +00:00
|
|
|
kDataLenUsedForKey = 8
|
2011-03-31 21:26:24 +00:00
|
|
|
};
|
|
|
|
|
2013-11-28 08:24:29 +00:00
|
|
|
GrBinHashKey<kDataLenUsedForKey> keyA;
|
2011-08-18 18:15:16 +00:00
|
|
|
keyA.setKeyData(testStringA);
|
|
|
|
// test copy constructor and comparison
|
2013-11-28 08:24:29 +00:00
|
|
|
GrBinHashKey<kDataLenUsedForKey> keyA2(keyA);
|
|
|
|
REPORTER_ASSERT(reporter, keyA == keyA2);
|
|
|
|
REPORTER_ASSERT(reporter, keyA.getHash() == keyA2.getHash());
|
2011-08-18 18:15:16 +00:00
|
|
|
// test re-init
|
|
|
|
keyA2.setKeyData(testStringA);
|
2013-11-28 08:24:29 +00:00
|
|
|
REPORTER_ASSERT(reporter, keyA == keyA2);
|
|
|
|
REPORTER_ASSERT(reporter, keyA.getHash() == keyA2.getHash());
|
2011-08-18 18:15:16 +00:00
|
|
|
// test sorting
|
2013-11-28 08:24:29 +00:00
|
|
|
GrBinHashKey<kDataLenUsedForKey> keyB;
|
2011-08-18 18:15:16 +00:00
|
|
|
keyB.setKeyData(testStringB);
|
2013-11-28 08:24:29 +00:00
|
|
|
REPORTER_ASSERT(reporter, keyA < keyB);
|
|
|
|
REPORTER_ASSERT(reporter, keyA.getHash() != keyB.getHash());
|
2011-03-31 21:26:24 +00:00
|
|
|
}
|
|
|
|
|
2013-11-28 08:24:29 +00:00
|
|
|
#endif
|