blob: 90f5e7ab024051c04b31bd576e41c3dc9c0d4ecc [file] [log] [blame]
caryclark@google.com9e49fb62012-08-27 14:11:33 +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.comc6825902012-02-03 22:07:47 +00007#include "CurveIntersection.h"
caryclark@google.com27accef2012-01-25 18:57:23 +00008#include "Intersection_Tests.h"
caryclark@google.com639df892012-01-10 21:46:10 +00009#include "IntersectionUtilities.h"
10
11static void assert_that(int x, int y, const char* s) {
12 if (x == y) {
13 return;
14 }
caryclark@google.comaa358312013-01-29 20:28:49 +000015 SkDebugf("result=%d expected=%d %s\n", x, y, s);
caryclark@google.com639df892012-01-10 21:46:10 +000016}
17
18static void side_test() {
19 assert_that(side(-1), 0, "side(-1) != 0");
20 assert_that(side(0), 1, "side(0) != 1");
21 assert_that(side(1), 2, "side(1) != 2");
22}
23
24static void sideBit_test() {
25 assert_that(sideBit(-1), 1, "sideBit(-1) != 1");
26 assert_that(sideBit(0), 2, "sideBit(0) != 2");
27 assert_that(sideBit(1), 4, "sideBit(1) != 4");
28}
29
30static void other_two_test() {
31 for (int x = 0; x < 4; ++x) {
32 for (int y = 0; y < 4; ++y) {
33 if (x == y) {
34 continue;
35 }
36 int mask = other_two(x, y);
37 int all = 1 << x;
38 all |= 1 << y;
39 all |= 1 << (x ^ mask);
40 all |= 1 << (y ^ mask);
41 if (all == 0x0F) {
42 continue;
43 }
caryclark@google.comaa358312013-01-29 20:28:49 +000044 SkDebugf("[%d,%d] other_two failed mask=%d [%d,%d]\n",
caryclark@google.com639df892012-01-10 21:46:10 +000045 x, y, mask, x ^ mask, y ^ mask);
46 }
47 }
48}
49
50void Inline_Tests() {
51 side_test();
52 sideBit_test();
53 other_two_test();
54}