Index: tests/PathOpsCubicLineIntersectionTest.cpp |
diff --git a/tests/PathOpsCubicLineIntersectionTest.cpp b/tests/PathOpsCubicLineIntersectionTest.cpp |
index 8ded198e7431a2e454a40ec4d3298da56e54230e..17a025b143deea58bb4b039a8bc5d248d9f8d479 100644 |
--- a/tests/PathOpsCubicLineIntersectionTest.cpp |
+++ b/tests/PathOpsCubicLineIntersectionTest.cpp |
@@ -11,10 +11,45 @@ |
#include "SkReduceOrder.h" |
#include "Test.h" |
-static struct lineCubic { |
+struct lineCubic { |
SkDCubic cubic; |
SkDLine line; |
-} lineCubicTests[] = { |
+}; |
+ |
+static lineCubic failLineCubicTests[] = { |
+ {{{{37.5273438,-1.44140625}, {37.8736992,-1.69921875}, {38.1640625,-2.140625}, |
+ {38.3984375,-2.765625}}}, |
+ {{{40.625,-5.7890625}, {37.7109375,1.3515625}}}}, |
+}; |
+ |
+static const size_t failLineCubicTests_count = SK_ARRAY_COUNT(failLineCubicTests); |
+ |
+static void testFail(skiatest::Reporter* reporter, int iIndex) { |
+ const SkDCubic& cubic = failLineCubicTests[iIndex].cubic; |
+ SkASSERT(ValidCubic(cubic)); |
+ const SkDLine& line = failLineCubicTests[iIndex].line; |
+ SkASSERT(ValidLine(line)); |
+ SkReduceOrder reduce1; |
+ SkReduceOrder reduce2; |
+ int order1 = reduce1.reduce(cubic, SkReduceOrder::kNo_Quadratics); |
+ int order2 = reduce2.reduce(line); |
+ if (order1 < 4) { |
+ SkDebugf("[%d] cubic order=%d\n", iIndex, order1); |
+ REPORTER_ASSERT(reporter, 0); |
+ } |
+ if (order2 < 2) { |
+ SkDebugf("[%d] line order=%d\n", iIndex, order2); |
+ REPORTER_ASSERT(reporter, 0); |
+ } |
+ if (order1 == 4 && order2 == 2) { |
+ SkIntersections i; |
+ int roots = i.intersect(cubic, line); |
+ REPORTER_ASSERT(reporter, roots == 0); |
+ } |
+} |
+ |
+static lineCubic lineCubicTests[] = { |
+ |
{{{{421, 378}, {421, 380.209137f}, {418.761414f, 382}, {416, 382}}}, |
{{{320, 378}, {421, 378.000031f}}}}, |
@@ -97,6 +132,14 @@ static void testOne(skiatest::Reporter* reporter, int iIndex) { |
} |
} |
+DEF_TEST(PathOpsFailCubicLineIntersection, reporter) { |
+ for (size_t index = 0; index < failLineCubicTests_count; ++index) { |
+ int iIndex = static_cast<int>(index); |
+ testFail(reporter, iIndex); |
+ reporter->bumpTestCount(); |
+ } |
+} |
+ |
DEF_TEST(PathOpsCubicLineIntersection, reporter) { |
for (size_t index = 0; index < lineCubicTests_count; ++index) { |
int iIndex = static_cast<int>(index); |