blob: 89da6592668ad804e171a919b0ec4a1c527f01cd [file] [log] [blame]
caryclark@google.com07393ca2013-04-08 11:47:37 +00001/*
2 * Copyright 2012 Google Inc.
3 *
4 * Use of this source code is governed by a BSD-style license that can be
5 * found in the LICENSE file.
6 */
7#include "SkPathOpsQuad.h"
8#include "Test.h"
9
10static const SkDQuad tests[] = {
11 {{{1, 1}, {2, 1}, {0, 2}}},
12 {{{0, 0}, {1, 1}, {3, 1}}},
13 {{{2, 0}, {1, 1}, {2, 2}}},
14 {{{4, 0}, {0, 1}, {4, 2}}},
15 {{{0, 0}, {0, 1}, {1, 1}}},
16};
17
18static const SkDPoint inPoint[]= {
19 {1, 1.2},
20 {1, 0.8},
21 {1.8, 1},
22 {1.5, 1},
23 {0.5, 0.5},
24};
25
26static const SkDPoint outPoint[]= {
27 {1, 1.6},
28 {1, 1.5},
29 {2.2, 1},
30 {1.5, 1.5},
31 {1.1, 0.5},
32};
33
caryclark@google.comad65a3e2013-04-15 19:13:59 +000034static const size_t tests_count = SK_ARRAY_COUNT(tests);
caryclark@google.com07393ca2013-04-08 11:47:37 +000035
caryclark@google.comad65a3e2013-04-15 19:13:59 +000036static void PathOpsDQuadTest(skiatest::Reporter* reporter) {
caryclark@google.com07393ca2013-04-08 11:47:37 +000037 for (size_t index = 0; index < tests_count; ++index) {
38 const SkDQuad& quad = tests[index];
39 bool result = quad.pointInHull(inPoint[index]);
40 if (!result) {
41 SkDebugf("%s [%d] expected in hull\n", __FUNCTION__, index);
42 REPORTER_ASSERT(reporter, 0);
43 }
44 result = quad.pointInHull(outPoint[index]);
45 if (result) {
46 SkDebugf("%s [%d] expected outside hull\n", __FUNCTION__, index);
47 REPORTER_ASSERT(reporter, 0);
48 }
49 }
50}
51
52#include "TestClassDef.h"
caryclark@google.comad65a3e2013-04-15 19:13:59 +000053DEFINE_TESTCLASS_SHORT(PathOpsDQuadTest)