From c21f86fc91ab3f78f6ecc6b8d52a297dd5317f69 Mon Sep 17 00:00:00 2001 From: "reed@google.com" Date: Mon, 29 Apr 2013 14:18:23 +0000 Subject: [PATCH] add unittest for SkCLZ git-svn-id: http://skia.googlecode.com/svn/trunk@8896 2bbb7eff-a529-9590-31e7-b0007b416f81 --- tests/MathTest.cpp | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/tests/MathTest.cpp b/tests/MathTest.cpp index 372b41c793..4ad83d1829 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 @@ static void TestMath(skiatest::Reporter* reporter) { if (false) test_blend31(); // avoid bit rot, suppress warning test_muldivround(reporter); + test_clz(reporter); } #include "TestClassDef.h" -- 2.34.1