time for a snapshot

This commit is contained in:
Schluffe
2026-07-11 17:48:28 +02:00
parent 135b7c3042
commit 7262752e16
47 changed files with 1712 additions and 61 deletions
+28
View File
@@ -0,0 +1,28 @@
import { expect, test } from "bun:test";
import { type AABB, aabbOverlap, pointInAABB } from "./aabb.ts";
const box: AABB = { x: 10, y: 10, w: 20, h: 20 }; // spans 10..30 in both axes
test("point inside the box", () => {
expect(pointInAABB({ x: 15, y: 15 }, box)).toBe(true);
});
test("point outside the box", () => {
expect(pointInAABB({ x: 5, y: 15 }, box)).toBe(false);
expect(pointInAABB({ x: 15, y: 35 }, box)).toBe(false);
});
test("overlapping boxes", () => {
const other: AABB = { x: 20, y: 20, w: 20, h: 20 };
expect(aabbOverlap(box, other)).toBe(true);
});
test("separated on the x axis only -> no overlap", () => {
const other: AABB = { x: 40, y: 10, w: 5, h: 20 };
expect(aabbOverlap(box, other)).toBe(false);
});
test("separated on the y axis only -> no overlap", () => {
const other: AABB = { x: 10, y: 40, w: 20, h: 5 };
expect(aabbOverlap(box, other)).toBe(false);
});