Index: tests/PathOpsCubicIntersectionTest.cpp |
diff --git a/tests/PathOpsCubicIntersectionTest.cpp b/tests/PathOpsCubicIntersectionTest.cpp |
index d04f2dbf94b7aacb78c96f497cd23f0551e0a966..109c42ed3f9b4fff75483e649f8a00878cc1d8e6 100644 |
--- a/tests/PathOpsCubicIntersectionTest.cpp |
+++ b/tests/PathOpsCubicIntersectionTest.cpp |
@@ -61,6 +61,7 @@ static void standardTestCases(skiatest::Reporter* reporter) { |
} |
REPORTER_ASSERT(reporter, xy1.approximatelyEqual(xy2)); |
} |
+ reporter->bumpTestCount(); |
} |
} |
@@ -163,7 +164,17 @@ static const SkDCubic testSet[] = { |
const size_t testSetCount = SK_ARRAY_COUNT(testSet); |
static const SkDCubic newTestSet[] = { |
-{{{134, 11414}, {131.990234375, 11414}, {130.32666015625, 11415.482421875}, {130.04275512695312, 11417.4130859375}}}, |
+#if 0 // FIXME: asserts coincidence, not working yet |
+{{{195, 785}, {124.30755615234375, 785}, {67, 841.85986328125}, {67, 912}}}, |
+{{{67, 913}, {67, 842.30755615234375}, {123.85984039306641, 785}, {194, 785}}}, |
+#endif |
+ |
+{{{399,657}, {399,661.970581}, {403.029449,666}, {408,666}}}, |
+{{{406,666}, {402.686279,666}, {400,663.313721}, {400,660}}}, |
+ |
+{{{0,5}, {3,5}, {3,0}, {3,2}}}, |
+{{{0,3}, {2,3}, {5,0}, {5,3}}}, |
+ |
{{{132, 11419}, {130.89543151855469, 11419}, {130, 11418.1044921875}, {130, 11417}}}, |
{{{3, 4}, {1, 5}, {4, 3}, {6, 4}}}, |
@@ -283,7 +294,8 @@ static const SkDCubic newTestSet[] = { |
const size_t newTestSetCount = SK_ARRAY_COUNT(newTestSet); |
-static void oneOff(skiatest::Reporter* reporter, const SkDCubic& cubic1, const SkDCubic& cubic2) { |
+static void oneOff(skiatest::Reporter* reporter, const SkDCubic& cubic1, const SkDCubic& cubic2, |
+ bool coin) { |
SkASSERT(ValidCubic(cubic1)); |
SkASSERT(ValidCubic(cubic2)); |
#if ONE_OFF_DEBUG |
@@ -317,6 +329,7 @@ static void oneOff(skiatest::Reporter* reporter, const SkDCubic& cubic1, const S |
#endif |
SkIntersections intersections; |
intersections.intersect(cubic1, cubic2); |
+ REPORTER_ASSERT(reporter, !coin || intersections.used() == 2); |
double tt1, tt2; |
SkDPoint xy1, xy2; |
for (int pt3 = 0; pt3 < intersections.used(); ++pt3) { |
@@ -334,18 +347,19 @@ static void oneOff(skiatest::Reporter* reporter, const SkDCubic& cubic1, const S |
REPORTER_ASSERT(reporter, xy2.approximatelyEqual(iPt)); |
REPORTER_ASSERT(reporter, xy1.approximatelyEqual(xy2)); |
} |
+ reporter->bumpTestCount(); |
} |
static void oneOff(skiatest::Reporter* reporter, int outer, int inner) { |
const SkDCubic& cubic1 = testSet[outer]; |
const SkDCubic& cubic2 = testSet[inner]; |
- oneOff(reporter, cubic1, cubic2); |
+ oneOff(reporter, cubic1, cubic2, false); |
} |
static void newOneOff(skiatest::Reporter* reporter, int outer, int inner) { |
const SkDCubic& cubic1 = newTestSet[outer]; |
const SkDCubic& cubic2 = newTestSet[inner]; |
- oneOff(reporter, cubic1, cubic2); |
+ oneOff(reporter, cubic1, cubic2, false); |
} |
static void oneOffTests(skiatest::Reporter* reporter) { |
@@ -412,6 +426,7 @@ static void CubicIntersection_RandTest(skiatest::Reporter* reporter) { |
SkDPoint xy2 = cubic2.ptAtT(tt2); |
REPORTER_ASSERT(reporter, xy1.approximatelyEqual(xy2)); |
} |
+ reporter->bumpTestCount(); |
} |
} |
@@ -559,6 +574,7 @@ static void selfOneOff(skiatest::Reporter* reporter, int index) { |
SkDPoint pt1 = cubic.ptAtT(i[0][0]); |
SkDPoint pt2 = cubic.ptAtT(i[1][0]); |
REPORTER_ASSERT(reporter, pt1.approximatelyEqual(pt2)); |
+ reporter->bumpTestCount(); |
} |
static void cubicIntersectionSelfTest(skiatest::Reporter* reporter) { |
@@ -568,6 +584,34 @@ static void cubicIntersectionSelfTest(skiatest::Reporter* reporter) { |
} |
} |
+static const SkDCubic coinSet[] = { |
+ {{{317, 711}, {322.52285766601562, 711}, {327, 715.4771728515625}, {327, 721}}}, |
+ {{{324.07107543945312, 713.928955078125}, {324.4051513671875, 714.26300048828125}, |
+ {324.71566772460937, 714.62060546875}, {325, 714.9990234375}}}, |
+ |
+ {{{2, 3}, {0, 4}, {3, 2}, {5, 3}}}, |
+ {{{2, 3}, {0, 4}, {3, 2}, {5, 3}}}, |
+}; |
+ |
+size_t coinSetCount = SK_ARRAY_COUNT(coinSet); |
+ |
+static void coinOneOff(skiatest::Reporter* reporter, int index) { |
+ const SkDCubic& cubic1 = coinSet[index]; |
+ const SkDCubic& cubic2 = coinSet[index + 1]; |
+ oneOff(reporter, cubic1, cubic2, true); |
+} |
+ |
+static void cubicIntersectionCoinTest(skiatest::Reporter* reporter) { |
+ size_t firstFail = 0; |
+ for (size_t index = firstFail; index < coinSetCount; index += 2) { |
+ coinOneOff(reporter, index); |
+ } |
+} |
+ |
+static void PathOpsCubicCoinOneOffTest(skiatest::Reporter* reporter) { |
+ coinOneOff(reporter, 0); |
+} |
+ |
static void PathOpsCubicIntersectionOneOffTest(skiatest::Reporter* reporter) { |
newOneOff(reporter, 0, 1); |
} |
@@ -579,6 +623,7 @@ static void PathOpsCubicSelfOneOffTest(skiatest::Reporter* reporter) { |
static void PathOpsCubicIntersectionTest(skiatest::Reporter* reporter) { |
oneOffTests(reporter); |
cubicIntersectionSelfTest(reporter); |
+ cubicIntersectionCoinTest(reporter); |
standardTestCases(reporter); |
if (false) CubicIntersection_IntersectionFinder(); |
if (false) CubicIntersection_RandTest(reporter); |
@@ -590,3 +635,5 @@ DEFINE_TESTCLASS_SHORT(PathOpsCubicIntersectionTest) |
DEFINE_TESTCLASS_SHORT(PathOpsCubicIntersectionOneOffTest) |
DEFINE_TESTCLASS_SHORT(PathOpsCubicSelfOneOffTest) |
+ |
+DEFINE_TESTCLASS_SHORT(PathOpsCubicCoinOneOffTest) |