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