time for a snapshot
This commit is contained in:
@@ -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);
|
||||
});
|
||||
Reference in New Issue
Block a user