aboutsummaryrefslogtreecommitdiffhomepage
path: root/tests/PathOpsCubicIntersectionTest.cpp
diff options
context:
space:
mode:
authorGravatar caryclark@google.com <caryclark@google.com@2bbb7eff-a529-9590-31e7-b0007b416f81>2013-10-02 14:49:34 +0000
committerGravatar caryclark@google.com <caryclark@google.com@2bbb7eff-a529-9590-31e7-b0007b416f81>2013-10-02 14:49:34 +0000
commit7eaa53d8f7e48fd17d02b5e3bd91f90e9c1899ef (patch)
tree057de94d997d99e897c68157f7444fbca687ebf9 /tests/PathOpsCubicIntersectionTest.cpp
parent77af6805e5faea1e2a5c0220098aec9082f3a6e5 (diff)
path ops work in progress
make more skps work remove edit files BUG= Review URL: https://codereview.chromium.org/23542056 git-svn-id: http://skia.googlecode.com/svn/trunk@11570 2bbb7eff-a529-9590-31e7-b0007b416f81
Diffstat (limited to 'tests/PathOpsCubicIntersectionTest.cpp')
-rw-r--r--tests/PathOpsCubicIntersectionTest.cpp55
1 files changed, 51 insertions, 4 deletions
diff --git a/tests/PathOpsCubicIntersectionTest.cpp b/tests/PathOpsCubicIntersectionTest.cpp
index d04f2dbf94..109c42ed3f 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)