skia2/experimental/Intersection/Inline_Tests.cpp
caryclark@google.com 9e49fb63d3 shape ops work in progress
add copyrights everywhere
start working on quadratic line segments (for quad intersection)

git-svn-id: http://skia.googlecode.com/svn/trunk@5286 2bbb7eff-a529-9590-31e7-b0007b416f81
2012-08-27 14:11:33 +00:00

55 lines
1.3 KiB
C++

/*
* Copyright 2012 Google Inc.
*
* Use of this source code is governed by a BSD-style license that can be
* found in the LICENSE file.
*/
#include "CurveIntersection.h"
#include "Intersection_Tests.h"
#include "IntersectionUtilities.h"
static void assert_that(int x, int y, const char* s) {
if (x == y) {
return;
}
printf("result=%d expected=%d %s\n", x, y, s);
}
static void side_test() {
assert_that(side(-1), 0, "side(-1) != 0");
assert_that(side(0), 1, "side(0) != 1");
assert_that(side(1), 2, "side(1) != 2");
}
static void sideBit_test() {
assert_that(sideBit(-1), 1, "sideBit(-1) != 1");
assert_that(sideBit(0), 2, "sideBit(0) != 2");
assert_that(sideBit(1), 4, "sideBit(1) != 4");
}
static void other_two_test() {
for (int x = 0; x < 4; ++x) {
for (int y = 0; y < 4; ++y) {
if (x == y) {
continue;
}
int mask = other_two(x, y);
int all = 1 << x;
all |= 1 << y;
all |= 1 << (x ^ mask);
all |= 1 << (y ^ mask);
if (all == 0x0F) {
continue;
}
printf("[%d,%d] other_two failed mask=%d [%d,%d]\n",
x, y, mask, x ^ mask, y ^ mask);
}
}
}
void Inline_Tests() {
side_test();
sideBit_test();
other_two_test();
}