blob: d6994943bddc16080a64b4aa1076528f3d219862 [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 "SkPathOpsCubic.h"
9#include "Test.h"
10
11static const SkDCubic tests[] = {
12 {{{2, 0}, {3, 1}, {2, 2}, {1, 1}}},
13 {{{3, 1}, {2, 2}, {1, 1}, {2, 0}}},
14 {{{3, 0}, {2, 1}, {3, 2}, {1, 1}}},
15};
16
caryclark@google.comad65a3e2013-04-15 19:13:59 +000017static const size_t tests_count = SK_ARRAY_COUNT(tests);
caryclark@google.com07393ca2013-04-08 11:47:37 +000018
tfarina@chromium.org78e7b4e2014-01-02 21:45:03 +000019DEF_TEST(PathOpsDCubic, reporter) {
caryclark@google.com07393ca2013-04-08 11:47:37 +000020 for (size_t index = 0; index < tests_count; ++index) {
21 const SkDCubic& cubic = tests[index];
caryclark@google.com8d0a5242013-07-16 16:11:16 +000022 SkASSERT(ValidCubic(cubic));
caryclark@google.com07393ca2013-04-08 11:47:37 +000023 bool result = cubic.clockwise();
24 if (!result) {
25 SkDebugf("%s [%d] expected clockwise\n", __FUNCTION__, index);
26 REPORTER_ASSERT(reporter, 0);
27 }
28 }
29}
caryclark1049f122015-04-20 08:31:59 -070030
31static const SkDCubic hullTests[] = {
32{{{2.6250000819563866, 2.3750000223517418}, {2.833333432674408, 2.3333333432674408}, {3.1111112236976624, 2.3333333134651184}, {3.4074075222015381, 2.3333332538604736}}},
33};
34
35static const size_t hullTests_count = SK_ARRAY_COUNT(hullTests);
36
37DEF_TEST(PathOpsCubicHull, reporter) {
38 for (size_t index = 0; index < hullTests_count; ++index) {
39 const SkDCubic& cubic = hullTests[index];
40 char order[4];
41 cubic.convexHull(order);
42 }
43}