blob: 59caf3046f12fb95fdfdc9b8e2b5de256cbdb22b [file] [log] [blame]
caryclark@google.com639df892012-01-10 21:46:10 +00001#include "CubicIntersection.h"
2#include "CubicIntersection_Tests.h"
3#include "IntersectionUtilities.h"
4
5static void assert_that(int x, int y, const char* s) {
6 if (x == y) {
7 return;
8 }
9 printf("result=%d expected=%d %s\n", x, y, s);
10}
11
12static void side_test() {
13 assert_that(side(-1), 0, "side(-1) != 0");
14 assert_that(side(0), 1, "side(0) != 1");
15 assert_that(side(1), 2, "side(1) != 2");
16}
17
18static void sideBit_test() {
19 assert_that(sideBit(-1), 1, "sideBit(-1) != 1");
20 assert_that(sideBit(0), 2, "sideBit(0) != 2");
21 assert_that(sideBit(1), 4, "sideBit(1) != 4");
22}
23
24static void other_two_test() {
25 for (int x = 0; x < 4; ++x) {
26 for (int y = 0; y < 4; ++y) {
27 if (x == y) {
28 continue;
29 }
30 int mask = other_two(x, y);
31 int all = 1 << x;
32 all |= 1 << y;
33 all |= 1 << (x ^ mask);
34 all |= 1 << (y ^ mask);
35 if (all == 0x0F) {
36 continue;
37 }
38 printf("[%d,%d] other_two failed mask=%d [%d,%d]\n",
39 x, y, mask, x ^ mask, y ^ mask);
40 }
41 }
42}
43
44void Inline_Tests() {
45 side_test();
46 sideBit_test();
47 other_two_test();
48}