aoc-2023/day_19/range.test.ts

37 lines
849 B
TypeScript
Raw Permalink Normal View History

2024-12-09 22:41:02 +09:00
import { partition, MaterialRange } from "./range.ts";
import { assertEquals } from "https://deno.land/std@0.212.0/assert/mod.ts";
Deno.test("partition", () => {
const mRange = {
x: [0, 10],
m: [0, 10],
a: [0, 10],
s: [0, 10],
} satisfies MaterialRange;
assertEquals(partition({
quality: "x",
cond: "<",
value: 5,
}, mRange),
[
{
x: [5, 10], m: [0, 10], a: [0, 10], s: [0, 10]
},
{
x: [0, 4], m: [0, 10], a: [0, 10], s: [0, 10]
},
]);
assertEquals(partition({
quality: "x",
cond: "<",
value: 11,
}, mRange),
mRange);
assertEquals(partition({
quality: "x",
cond: "<",
value: 0,
}, mRange),
null);
});