diff options
author | reed@google.com <reed@google.com@2bbb7eff-a529-9590-31e7-b0007b416f81> | 2013-05-03 16:30:44 +0000 |
---|---|---|
committer | reed@google.com <reed@google.com@2bbb7eff-a529-9590-31e7-b0007b416f81> | 2013-05-03 16:30:44 +0000 |
commit | 25720b4d7e6f86043997c040315f2874aa2c8c9a (patch) | |
tree | 144a2cf6cee5839a42f575c2dc36f8a922432f28 /tests/PointTest.cpp | |
parent | 292ce737285a9ee3f1d5395e7ff7f56082e3f214 (diff) |
trick the compiler into not knowning that I will generate an overflow
(which is the point of the test). This avoids a warning, which breaks
our bots.
git-svn-id: http://skia.googlecode.com/svn/trunk@8991 2bbb7eff-a529-9590-31e7-b0007b416f81
Diffstat (limited to 'tests/PointTest.cpp')
-rw-r--r-- | tests/PointTest.cpp | 14 |
1 files changed, 13 insertions, 1 deletions
diff --git a/tests/PointTest.cpp b/tests/PointTest.cpp index 9d4bdfd843..b909762f07 100644 --- a/tests/PointTest.cpp +++ b/tests/PointTest.cpp @@ -50,10 +50,22 @@ static void test_length(skiatest::Reporter* reporter, SkScalar x, SkScalar y, test_Normalize(reporter, x, y); } +// Ugh. Windows compiler can dive into other .cpp files, and sometimes +// notices that I will generate an overflow... which is exactly the point +// of this test! +// +// To avoid this warning, I need to convince the compiler that I might not +// use that big value, hence this hacky helper function: reporter is +// ALWAYS non-null. (shhhhhh, don't tell the compiler that). +template <typename T> T get_value(skiatest::Reporter* reporter, T value) { + return reporter ? value : 0; +} + // test that we handle very large values correctly. i.e. that we can // successfully normalize something whose mag overflows a float. static void test_overflow(skiatest::Reporter* reporter) { - SkPoint pt = { SkFloatToScalar(3.4e38f), SkFloatToScalar(3.4e38f) }; + SkScalar bigFloat = get_value(reporter, SkFloatToScalar(3.4e38f)); + SkPoint pt = { bigFloat, bigFloat }; SkScalar length = pt.length(); REPORTER_ASSERT(reporter, !SkScalarIsFinite(length)); |