wjmaclean@chromium.org | ff1ec2f | 2011-02-07 17:48:40 +0000 | [diff] [blame^] | 1 | #include "Test.h" |
| 2 | #include "SkRect.h" |
| 3 | |
| 4 | // Tests that hasValidCoordinates() will reject any rect with +/-inf values |
| 5 | // as one of its coordinates. |
| 6 | static void TestInfRect(skiatest::Reporter* reporter) { |
| 7 | |
| 8 | SkRect rect = SkRect::MakeXYWH(10.0f, 10.0f, 100.0f, 100.0f); |
| 9 | REPORTER_ASSERT(reporter, rect.hasValidCoordinates()); |
| 10 | |
| 11 | rect = SkRect::MakeXYWH(10.0f, 10.0f, 100.0f, 1.0f/0.0f); // Make 'inf' value without numeric_limits. |
| 12 | REPORTER_ASSERT(reporter, !rect.hasValidCoordinates()); |
| 13 | |
| 14 | rect = SkRect::MakeXYWH(10.0f, 10.0f, 1.0f/0.0f, 100.0f); |
| 15 | REPORTER_ASSERT(reporter, !rect.hasValidCoordinates()); |
| 16 | |
| 17 | rect = SkRect::MakeXYWH(1.0f/0.0f, 10.0f, 100.0f, 100.0f); |
| 18 | REPORTER_ASSERT(reporter, !rect.hasValidCoordinates()); |
| 19 | |
| 20 | rect = SkRect::MakeXYWH(10.0f, 1.0f/0.0f, 100.0f, 100.0f); |
| 21 | REPORTER_ASSERT(reporter, !rect.hasValidCoordinates()); |
| 22 | |
| 23 | rect = SkRect::MakeXYWH(10.0f, 10.0f, 100.0f, -1.0f/0.0f); |
| 24 | REPORTER_ASSERT(reporter, !rect.hasValidCoordinates()); |
| 25 | |
| 26 | rect = SkRect::MakeXYWH(10.0f, 10.0f, -1.0f/0.0f, 100.0f); |
| 27 | REPORTER_ASSERT(reporter, !rect.hasValidCoordinates()); |
| 28 | |
| 29 | rect = SkRect::MakeXYWH(-1.0f/0.0f, 10.0f, 100.0f, 100.0f); |
| 30 | REPORTER_ASSERT(reporter, !rect.hasValidCoordinates()); |
| 31 | |
| 32 | rect = SkRect::MakeXYWH(10.0f, -1.0f/0.0f, 100.0f, 100.0f); |
| 33 | REPORTER_ASSERT(reporter, !rect.hasValidCoordinates()); |
| 34 | } |
| 35 | |
| 36 | // need tests for SkStrSearch |
| 37 | |
| 38 | #include "TestClassDef.h" |
| 39 | DEFINE_TESTCLASS("InfRect", InfRectTestClass, TestInfRect) |