fix mac build of gr unit test

Review URL: http://codereview.appspot.com/4351042/



git-svn-id: http://skia.googlecode.com/svn/trunk@1034 2bbb7eff-a529-9590-31e7-b0007b416f81
This commit is contained in:
bsalomon@google.com 2011-04-01 14:51:07 +00:00
parent f1ec465f87
commit beccee78bb

View File

@ -75,6 +75,9 @@ static void test_bsearch() {
} }
} }
// bogus empty class for GrBinHashKey
class BogusEntry {};
static void test_binHashKey() static void test_binHashKey()
{ {
const char* testStringA = "abcdA"; const char* testStringA = "abcdA";
@ -83,11 +86,7 @@ static void test_binHashKey()
kDataLenUsedForKey = 5 kDataLenUsedForKey = 5
}; };
class Entry { typedef GrBinHashKey<BogusEntry, kDataLenUsedForKey> KeyType;
// bogus empty class
};
typedef GrBinHashKey<Entry, kDataLenUsedForKey> KeyType;
KeyType keyA; KeyType keyA;
int passCnt = 0; int passCnt = 0;
@ -96,7 +95,7 @@ static void test_binHashKey()
keyA.keyData(reinterpret_cast<const uint8_t*>(testStringA), kDataLenUsedForKey); keyA.keyData(reinterpret_cast<const uint8_t*>(testStringA), kDataLenUsedForKey);
} }
GrAssert(passCnt == 1); //We expect the static allocation to suffice GrAssert(passCnt == 1); //We expect the static allocation to suffice
GrBinHashKey<Entry, kDataLenUsedForKey-1> keyBust; GrBinHashKey<BogusEntry, kDataLenUsedForKey-1> keyBust;
passCnt = 0; passCnt = 0;
while (keyBust.doPass()) { while (keyBust.doPass()) {
++passCnt; ++passCnt;
@ -135,13 +134,13 @@ static void test_binHashKey()
GrAssert(keyA.compare(keyA2) == 0); GrAssert(keyA.compare(keyA2) == 0);
//Test ownership tranfer and copying with key on heap //Test ownership tranfer and copying with key on heap
GrBinHashKey<Entry, kDataLenUsedForKey-1> keyBust2; GrBinHashKey<BogusEntry, kDataLenUsedForKey-1> keyBust2;
keyBust2.deepCopyFrom(keyBust); keyBust2.deepCopyFrom(keyBust);
GrAssert(keyBust.fIsValid); GrAssert(keyBust.fIsValid);
GrAssert(keyBust2.fIsValid); GrAssert(keyBust2.fIsValid);
GrAssert(keyBust.getHash() == keyBust2.getHash()); GrAssert(keyBust.getHash() == keyBust2.getHash());
GrAssert(keyBust.compare(keyBust2) == 0); GrAssert(keyBust.compare(keyBust2) == 0);
GrBinHashKey<Entry, kDataLenUsedForKey-1> keyBust3; GrBinHashKey<BogusEntry, kDataLenUsedForKey-1> keyBust3;
keyBust3.deepCopyFrom(keyBust); keyBust3.deepCopyFrom(keyBust);
GrAssert(keyBust.fIsValid == false); GrAssert(keyBust.fIsValid == false);
GrAssert(keyBust3.fIsValid); GrAssert(keyBust3.fIsValid);