change tests
All checks were successful
Linux arm64 / Build (push) Successful in 4m29s

This commit is contained in:
2024-03-22 16:41:52 +01:00
parent 441131a2f5
commit 6e998fc368

View File

@@ -12,25 +12,47 @@ using namespace maths;
#define let auto // sexy boiiii
static void test_basic() {
static void test_left() {
let box = AABB { {-1.0f, -1.0f, -1.0f}, {1.0f, 1.0f, 1.0f} };
let ray = Ray { {-3.0f, 0.0f, 0.0f}, {1.0f, 0.0f, 0.0f} };
let ray = Ray { {-2.0f, 0.0f, 0.0f}, {1.0f, 0.0f, 0.0f} };
blitz_test_assert(Distance(ray, box));
blitz_test_assert(Intersects(ray, box));
}
static void test_right() {
let box = AABB { {-1.0f, -1.0f, -1.0f}, {1.0f, 1.0f, 1.0f} };
let ray = Ray { {2.0f, 0.0f, 0.0f}, {-1.0f, 0.0f, 0.0f} };
blitz_test_assert(Intersects(ray, box));
}
static void test_forward() {
let box = AABB { {-1.0f, -1.0f, -1.0f}, {1.0f, 1.0f, 1.0f} };
let ray = Ray { {0.0f, 2.0f, 0.0f}, {0.0f, -1.0f, 0.0f} };
blitz_test_assert(Intersects(ray, box));
}
static void test_backward() {
let box = AABB { {-1.0f, -1.0f, -1.0f}, {1.0f, 1.0f, 1.0f} };
let ray = Ray { {0.0f, -2.0f, 0.0f}, {0.0f, 1.0f, 0.0f} };
blitz_test_assert(Intersects(ray, box));
}
static void test_shifted() {
let box = AABB { {-1.0f, -1.0f, -1.0f}, {1.0f, 1.0f, 1.0f} };
let ray = Ray { {-3.0f, 0.0f, 100.0f}, {1.0f, 0.0f, 0.0f} };
blitz_test_assert(!Distance(ray, box));
blitz_test_assert(!Intersects(ray, box));
}
int main(int argc, const char* args[]) {
test_basic();
test_left();
test_right();
test_forward();
test_backward();
test_shifted();
return BLITZ_TEST_SUCCESSFUL;
}