OLD | NEW |
| (Empty) |
1 /* | |
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 "CurveIntersection.h" | |
8 #include "Intersection_Tests.h" | |
9 #include "IntersectionUtilities.h" | |
10 | |
11 static void assert_that(int x, int y, const char* s) { | |
12 if (x == y) { | |
13 return; | |
14 } | |
15 SkDebugf("result=%d expected=%d %s\n", x, y, s); | |
16 } | |
17 | |
18 static 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 | |
24 static 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 | |
30 static 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 } | |
44 SkDebugf("[%d,%d] other_two failed mask=%d [%d,%d]\n", | |
45 x, y, mask, x ^ mask, y ^ mask); | |
46 } | |
47 } | |
48 } | |
49 | |
50 void Inline_Tests() { | |
51 side_test(); | |
52 sideBit_test(); | |
53 other_two_test(); | |
54 } | |
OLD | NEW |