Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(325)

Unified Diff: tests/PathOpsCubicLineIntersectionTest.cpp

Issue 252243003: fix cubic/line intersection; add skp tests (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: bracket new test correctly Created 6 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « src/pathops/SkDCubicLineIntersection.cpp ('k') | tests/PathOpsExtendedTest.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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);
« no previous file with comments | « src/pathops/SkDCubicLineIntersection.cpp ('k') | tests/PathOpsExtendedTest.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698