caryclark@google.com | 07393ca | 2013-04-08 11:47:37 +0000 | [diff] [blame] | 1 | /* |
| 2 | * Copyright 2012 Google Inc. |
| 3 | * |
| 4 | * Use of this source code is governed by a BSD-style license that can be |
| 5 | * found in the LICENSE file. |
| 6 | */ |
caryclark@google.com | 8d0a524 | 2013-07-16 16:11:16 +0000 | [diff] [blame] | 7 | #include "PathOpsTestCommon.h" |
caryclark@google.com | 07393ca | 2013-04-08 11:47:37 +0000 | [diff] [blame] | 8 | #include "SkPathOpsTriangle.h" |
| 9 | #include "Test.h" |
| 10 | |
| 11 | static const SkDTriangle tests[] = { |
| 12 | {{{2, 0}, {3, 1}, {2, 2}}}, |
| 13 | {{{3, 1}, {2, 2}, {1, 1}}}, |
| 14 | {{{3, 0}, {2, 1}, {3, 2}}}, |
| 15 | }; |
| 16 | |
| 17 | static const SkDPoint inPoint[] = { |
| 18 | {2.5, 1}, |
| 19 | {2, 1.5}, |
| 20 | {2.5, 1}, |
| 21 | }; |
| 22 | |
| 23 | static const SkDPoint outPoint[] = { |
| 24 | {3, 0}, |
| 25 | {2.5, 2}, |
| 26 | {2.5, 2}, |
| 27 | }; |
| 28 | |
caryclark@google.com | ad65a3e | 2013-04-15 19:13:59 +0000 | [diff] [blame] | 29 | static const size_t tests_count = SK_ARRAY_COUNT(tests); |
caryclark@google.com | 07393ca | 2013-04-08 11:47:37 +0000 | [diff] [blame] | 30 | |
caryclark@google.com | ad65a3e | 2013-04-15 19:13:59 +0000 | [diff] [blame] | 31 | static void PathOpsTriangleUtilitiesTest(skiatest::Reporter* reporter) { |
caryclark@google.com | 07393ca | 2013-04-08 11:47:37 +0000 | [diff] [blame] | 32 | for (size_t index = 0; index < tests_count; ++index) { |
| 33 | const SkDTriangle& triangle = tests[index]; |
caryclark@google.com | 8d0a524 | 2013-07-16 16:11:16 +0000 | [diff] [blame] | 34 | SkASSERT(ValidTriangle(triangle)); |
caryclark@google.com | 07393ca | 2013-04-08 11:47:37 +0000 | [diff] [blame] | 35 | bool result = triangle.contains(inPoint[index]); |
| 36 | if (!result) { |
| 37 | SkDebugf("%s [%d] expected point in triangle\n", __FUNCTION__, index); |
| 38 | REPORTER_ASSERT(reporter, 0); |
| 39 | } |
| 40 | result = triangle.contains(outPoint[index]); |
| 41 | if (result) { |
| 42 | SkDebugf("%s [%d] expected point outside triangle\n", __FUNCTION__, index); |
| 43 | REPORTER_ASSERT(reporter, 0); |
| 44 | } |
| 45 | } |
| 46 | } |
| 47 | |
| 48 | #include "TestClassDef.h" |
caryclark@google.com | ad65a3e | 2013-04-15 19:13:59 +0000 | [diff] [blame] | 49 | DEFINE_TESTCLASS_SHORT(PathOpsTriangleUtilitiesTest) |