blob: 5921b695782398911abef0ad0eb142e034c5162f [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 */
caryclark@google.com8d0a5242013-07-16 16:11:16 +00007#include "PathOpsTestCommon.h"
caryclark@google.com07393ca2013-04-08 11:47:37 +00008#include "SkPathOpsQuad.h"
9#include "Test.h"
10
11static const SkDQuad tests[] = {
12 {{{1, 1}, {2, 1}, {0, 2}}},
13 {{{0, 0}, {1, 1}, {3, 1}}},
14 {{{2, 0}, {1, 1}, {2, 2}}},
15 {{{4, 0}, {0, 1}, {4, 2}}},
16 {{{0, 0}, {0, 1}, {1, 1}}},
17};
18
19static const SkDPoint inPoint[]= {
20 {1, 1.2},
21 {1, 0.8},
22 {1.8, 1},
23 {1.5, 1},
24 {0.5, 0.5},
25};
26
27static const SkDPoint outPoint[]= {
28 {1, 1.6},
29 {1, 1.5},
30 {2.2, 1},
31 {1.5, 1.5},
32 {1.1, 0.5},
33};
34
caryclark@google.comad65a3e2013-04-15 19:13:59 +000035static const size_t tests_count = SK_ARRAY_COUNT(tests);
caryclark@google.com07393ca2013-04-08 11:47:37 +000036
caryclark@google.comad65a3e2013-04-15 19:13:59 +000037static void PathOpsDQuadTest(skiatest::Reporter* reporter) {
caryclark@google.com07393ca2013-04-08 11:47:37 +000038 for (size_t index = 0; index < tests_count; ++index) {
39 const SkDQuad& quad = tests[index];
caryclark@google.com8d0a5242013-07-16 16:11:16 +000040 SkASSERT(ValidQuad(quad));
caryclark@google.com07393ca2013-04-08 11:47:37 +000041 bool result = quad.pointInHull(inPoint[index]);
42 if (!result) {
43 SkDebugf("%s [%d] expected in hull\n", __FUNCTION__, index);
44 REPORTER_ASSERT(reporter, 0);
45 }
46 result = quad.pointInHull(outPoint[index]);
47 if (result) {
48 SkDebugf("%s [%d] expected outside hull\n", __FUNCTION__, index);
49 REPORTER_ASSERT(reporter, 0);
50 }
51 }
52}
53
54#include "TestClassDef.h"
caryclark@google.comad65a3e2013-04-15 19:13:59 +000055DEFINE_TESTCLASS_SHORT(PathOpsDQuadTest)