diff options
Diffstat (limited to 'tests/MathTest.cpp')
-rw-r--r-- | tests/MathTest.cpp | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/tests/MathTest.cpp b/tests/MathTest.cpp index fcbd63ddca..0d0bdce67d 100644 --- a/tests/MathTest.cpp +++ b/tests/MathTest.cpp @@ -693,3 +693,27 @@ DEF_TEST(FloatSaturate, reporter) { REPORTER_ASSERT(reporter, r.fExpectedInt == i); } } + +DEF_TEST(DoubleSaturate, reporter) { + const struct { + double fDouble; + int fExpectedInt; + } recs[] = { + { 0, 0 }, + { 100.5, 100 }, + { SK_MaxS32, SK_MaxS32 }, + { SK_MinS32, SK_MinS32 }, + { SK_MaxS32 - 1, SK_MaxS32 - 1 }, + { SK_MinS32 + 1, SK_MinS32 + 1 }, + { SK_MaxS32 * 100.0, SK_MaxS32 }, + { SK_MinS32 * 100.0, SK_MinS32 }, + { SK_ScalarInfinity, SK_MaxS32 }, + { SK_ScalarNegativeInfinity, SK_MinS32 }, + { SK_ScalarNaN, SK_MaxS32 }, + }; + + for (auto r : recs) { + int i = sk_double_saturate2int(r.fDouble); + REPORTER_ASSERT(reporter, r.fExpectedInt == i); + } +} |