Fix to bug, partial fix to unit tests following on from
authortomhudson@google.com <tomhudson@google.com@2bbb7eff-a529-9590-31e7-b0007b416f81>
Wed, 1 Jun 2011 20:43:05 +0000 (20:43 +0000)
committertomhudson@google.com <tomhudson@google.com@2bbb7eff-a529-9590-31e7-b0007b416f81>
Wed, 1 Jun 2011 20:43:05 +0000 (20:43 +0000)
http://codereview.appspot.com/4536100/

git-svn-id: http://skia.googlecode.com/svn/trunk@1475 2bbb7eff-a529-9590-31e7-b0007b416f81

gpu/src/GrBinHashKey.h
gpu/src/gr_unittests.cpp

index 8ae98f8..565b460 100644 (file)
@@ -140,7 +140,7 @@ public:
     void keyData(const uint32_t *dataToAdd, size_t len) {
         GrAssert(fIsValid);
         GrAssert(fPass);
-        GrAssert(SkAlign4(len) == len);
+        GrAssert(GrIsALIGN4(len));
         if (fUseHeap) {
             GrAssert(fHeapData);
             GrAssert(fLength + len <= fPhysicalSize);
index df11878..338f2cc 100644 (file)
@@ -80,10 +80,10 @@ class BogusEntry {};
 
 static void test_binHashKey()
 {
-    const char* testStringA = "abcdA";
-    const char* testStringB = "abcdB";
+    const char* testStringA = "abcdABCD";
+    const char* testStringB = "abcdBBCD";
     enum {
-        kDataLenUsedForKey = 5
+        kDataLenUsedForKey = 8
     };
 
     typedef GrBinHashKey<BogusEntry, kDataLenUsedForKey> KeyType;
@@ -92,7 +92,7 @@ static void test_binHashKey()
     int passCnt = 0;
     while (keyA.doPass()) {
         ++passCnt;
-        keyA.keyData(reinterpret_cast<const uint8_t*>(testStringA), kDataLenUsedForKey);
+        keyA.keyData(reinterpret_cast<const uint32_t*>(testStringA), kDataLenUsedForKey);
     }
     GrAssert(passCnt == 1); //We expect the static allocation to suffice
     GrBinHashKey<BogusEntry, kDataLenUsedForKey-1> keyBust;
@@ -100,7 +100,7 @@ static void test_binHashKey()
     while (keyBust.doPass()) {
         ++passCnt;
         // Exceed static storage by 1
-        keyBust.keyData(reinterpret_cast<const uint8_t*>(testStringA), kDataLenUsedForKey);
+        keyBust.keyData(reinterpret_cast<const uint32_t*>(testStringA), kDataLenUsedForKey);
     }
     GrAssert(passCnt == 2); //We expect dynamic allocation to be necessary
     GrAssert(keyA.getHash() == keyBust.getHash());
@@ -109,14 +109,14 @@ static void test_binHashKey()
     // the same hash as with one chunk
     KeyType keyA2;
     while (keyA2.doPass()) {
-        keyA2.keyData(reinterpret_cast<const uint8_t*>(testStringA), 2);
-        keyA2.keyData(&reinterpret_cast<const uint8_t*>(testStringA)[2], kDataLenUsedForKey-2);
+        keyA2.keyData(reinterpret_cast<const uint32_t*>(testStringA), 4);
+        keyA2.keyData(&reinterpret_cast<const uint32_t*>(testStringA)[4], kDataLenUsedForKey-4);
     }
     GrAssert(keyA.getHash() == keyA2.getHash());
 
     KeyType keyB;
     while (keyB.doPass()){
-        keyB.keyData(reinterpret_cast<const uint8_t*>(testStringB), kDataLenUsedForKey);
+        keyB.keyData(reinterpret_cast<const uint32_t*>(testStringB), kDataLenUsedForKey);
     }
     GrAssert(keyA.compare(keyB) < 0);
     GrAssert(keyA.compare(keyA2) == 0);
@@ -275,5 +275,3 @@ void gr_run_unittests() {
     GrRedBlackTree<int>::UnitTest();
     GrDrawTarget::VertexLayoutUnitTest();
 }
-
-