aboutsummaryrefslogtreecommitdiffhomepage
path: root/tests/Float16Test.cpp
diff options
context:
space:
mode:
authorGravatar mtklein <mtklein@chromium.org>2016-02-11 12:48:23 -0800
committerGravatar Commit bot <commit-bot@chromium.org>2016-02-11 12:48:23 -0800
commitddb64c81fbe05ef7188135564bbd695edea9fdf0 (patch)
tree1f9e95e6ebcea964c85d09183a185ce036f10b26 /tests/Float16Test.cpp
parentbc81111f246ce2d5fbb61d7a347c9d890f6c8359 (diff)
new version of SkHalfToFloat_01
This is a little faster than the previous version, and much better explained. BUG=skia: GOLD_TRYBOT_URL= https://gold.skia.org/search2?unt=true&query=source_type%3Dgm&master=false&issue=1688233002 Review URL: https://codereview.chromium.org/1688233002
Diffstat (limited to 'tests/Float16Test.cpp')
-rw-r--r--tests/Float16Test.cpp13
1 files changed, 13 insertions, 0 deletions
diff --git a/tests/Float16Test.cpp b/tests/Float16Test.cpp
index f96d904567..3b13533853 100644
--- a/tests/Float16Test.cpp
+++ b/tests/Float16Test.cpp
@@ -66,10 +66,23 @@ DEF_TEST(float_to_half, reporter) {
REPORTER_ASSERT(reporter, 0 == memcmp(fscratch, fs, sizeof(fs)));
}
+static uint32_t u(float f) {
+ uint32_t x;
+ memcpy(&x, &f, 4);
+ return x;
+}
+
DEF_TEST(HalfToFloat_01, r) {
for (uint16_t h = 0; h < 0x8000; h++) {
float f = SkHalfToFloat(h);
if (f >= 0 && f <= 1) {
+ float got = SkHalfToFloat_01(h)[0];
+ if (got != f) {
+ SkDebugf("0x%04x -> 0x%08x (%g), want 0x%08x (%g)\n",
+ h,
+ u(got), got,
+ u(f), f);
+ }
REPORTER_ASSERT(r, SkHalfToFloat_01(h)[0] == f);
REPORTER_ASSERT(r, SkFloatToHalf_01(SkHalfToFloat_01(h)) == h);
}