add unittest for SkCLZ



git-svn-id: http://skia.googlecode.com/svn/trunk@8896 2bbb7eff-a529-9590-31e7-b0007b416f81
diff --git a/tests/MathTest.cpp b/tests/MathTest.cpp
index 372b41c..4ad83d1 100644
--- a/tests/MathTest.cpp
+++ b/tests/MathTest.cpp
@@ -13,6 +13,23 @@
 #include "SkRandom.h"
 #include "SkColorPriv.h"
 
+static void test_clz(skiatest::Reporter* reporter) {
+    REPORTER_ASSERT(reporter, 32 == SkCLZ(0));
+    REPORTER_ASSERT(reporter, 31 == SkCLZ(1));
+    REPORTER_ASSERT(reporter, 1 == SkCLZ(1 << 30));
+    REPORTER_ASSERT(reporter, 0 == SkCLZ(~0UL));
+    
+    SkRandom rand;
+    for (int i = 0; i < 1000; ++i) {
+        uint32_t mask = rand.nextU();
+        int intri = SkCLZ(mask);
+        int porta = SkCLZ_portable(mask);
+        REPORTER_ASSERT(reporter, intri == porta);
+    }
+}
+
+///////////////////////////////////////////////////////////////////////////////
+
 static float sk_fsel(float pred, float result_ge, float result_lt) {
     return pred >= 0 ? result_ge : result_lt;
 }
@@ -623,6 +640,7 @@
     if (false) test_blend31();  // avoid bit rot, suppress warning
 
     test_muldivround(reporter);
+    test_clz(reporter);
 }
 
 #include "TestClassDef.h"