diff options
author | Mike Reed <reed@google.com> | 2017-08-09 11:06:53 -0400 |
---|---|---|
committer | Skia Commit-Bot <skia-commit-bot@chromium.org> | 2017-08-09 16:07:24 +0000 |
commit | 828f1d51958c17d716ac95182051a866be785e01 (patch) | |
tree | 325bab378605660b8905381aa5d6c907a2c1c215 /tests/MathTest.cpp | |
parent | 74c627f0bde675f13587b12069d6556868edf45e (diff) |
handle overflows in float->int
rects are already auto-vectorized, so no need to explicitly write a 4f version of SkRect::round()
Bug: skia:
Change-Id: I098945767bfcaa7093d770c376bd17ff3bdc9983
Reviewed-on: https://skia-review.googlesource.com/32060
Commit-Queue: Mike Reed <reed@google.com>
Reviewed-by: Florin Malita <fmalita@chromium.org>
Diffstat (limited to 'tests/MathTest.cpp')
-rw-r--r-- | tests/MathTest.cpp | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/tests/MathTest.cpp b/tests/MathTest.cpp index 3d30f0db2a..bbd551e1e9 100644 --- a/tests/MathTest.cpp +++ b/tests/MathTest.cpp @@ -671,3 +671,25 @@ DEF_TEST(GrNextSizePow2, reporter) { test_nextsizepow2(reporter, SIZE_MAX, SIZE_MAX); } + +DEF_TEST(FloatSaturate, reporter) { + const struct { + float fFloat; + int fExpectedInt; + } recs[] = { + { 0, 0 }, + { 100.5f, 100 }, + { (float)SK_MaxS32, SK_MaxS32FitsInFloat }, + { (float)SK_MinS32, SK_MinS32FitsInFloat }, + { SK_MaxS32 * 100.0f, SK_MaxS32FitsInFloat }, + { SK_MinS32 * 100.0f, SK_MinS32FitsInFloat }, + { SK_ScalarInfinity, SK_MaxS32FitsInFloat }, + { SK_ScalarNegativeInfinity, SK_MinS32FitsInFloat }, + { SK_ScalarNaN, SK_MaxS32FitsInFloat }, + }; + + for (auto r : recs) { + int i = sk_float_saturate2int(r.fFloat); + REPORTER_ASSERT(reporter, r.fExpectedInt == i); + } +} |