aboutsummaryrefslogtreecommitdiffhomepage
path: root/tests/PathOpsCubicLineIntersectionTest.cpp
diff options
context:
space:
mode:
authorGravatar commit-bot@chromium.org <commit-bot@chromium.org@2bbb7eff-a529-9590-31e7-b0007b416f81>2014-04-30 13:37:48 +0000
committerGravatar commit-bot@chromium.org <commit-bot@chromium.org@2bbb7eff-a529-9590-31e7-b0007b416f81>2014-04-30 13:37:48 +0000
commit91fc81c972c5ac4090f106d3b3fd9b26a3235ce1 (patch)
tree977d8c67df4ec1096a30bc08ddc09763342d4cc5 /tests/PathOpsCubicLineIntersectionTest.cpp
parenta90c6803865766d28e92091f56f718f5e41fe80f (diff)
fix cubic/line intersection; add skp tests
BUG=skia:2488 TBR=reed Author: caryclark@google.com Review URL: https://codereview.chromium.org/252243003 git-svn-id: http://skia.googlecode.com/svn/trunk@14458 2bbb7eff-a529-9590-31e7-b0007b416f81
Diffstat (limited to 'tests/PathOpsCubicLineIntersectionTest.cpp')
-rw-r--r--tests/PathOpsCubicLineIntersectionTest.cpp47
1 files changed, 45 insertions, 2 deletions
diff --git a/tests/PathOpsCubicLineIntersectionTest.cpp b/tests/PathOpsCubicLineIntersectionTest.cpp
index 8ded198e74..1a2e188589 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);