Chromium Code Reviews| Index: tests/ScalarTest.cpp |
| diff --git a/tests/ScalarTest.cpp b/tests/ScalarTest.cpp |
| index 82f61ec5c54917c8b1cb9002f4dc72a1b25f6674..2d278834d8dd49edb12d8dc2352627b402255c9a 100644 |
| --- a/tests/ScalarTest.cpp |
| +++ b/tests/ScalarTest.cpp |
| @@ -12,6 +12,19 @@ |
| #include "SkRect.h" |
| #include "Test.h" |
| +static void test_roundtoint(skiatest::Reporter* reporter) { |
| + SkScalar x = 0.49999997; |
| + int ix = SkScalarRoundToInt(x); |
| + // We "should" get 0, since x < 0.5, but we don't due to float addtion rounding up the low |
|
bungeman-skia
2014/05/05 15:39:31
s/addtion/addition
reed1
2014/05/05 15:56:37
Done.
|
| + // bit after adding 0.5. |
| + REPORTER_ASSERT(reporter, 1 == ix); |
| + |
| + // This version explicitly performs the +0.5 step using double, which should avoid losing the |
| + // low bits. |
| + ix = SkDScalarRoundToInt(x); |
| + REPORTER_ASSERT(reporter, 0 == ix); |
| +} |
| + |
| struct PointSet { |
| const SkPoint* fPts; |
| size_t fCount; |
| @@ -187,4 +200,5 @@ static void test_isfinite(skiatest::Reporter* reporter) { |
| DEF_TEST(Scalar, reporter) { |
| test_isfinite(reporter); |
| + test_roundtoint(reporter); |
| } |