Add test
This commit is contained in:
parent
e32d61749d
commit
0bbe734fbc
2 changed files with 32 additions and 0 deletions
24
2021/1.test.ts
Normal file
24
2021/1.test.ts
Normal file
|
@ -0,0 +1,24 @@
|
|||
import { assertEquals } from "https://deno.land/std@0.116.0/testing/asserts.ts";
|
||||
import { asyncIterator } from "./common.ts";
|
||||
import { part1, part2 } from "./1.ts";
|
||||
|
||||
const testInput = [
|
||||
199,
|
||||
200,
|
||||
208,
|
||||
210,
|
||||
200,
|
||||
207,
|
||||
240,
|
||||
269,
|
||||
260,
|
||||
263,
|
||||
];
|
||||
|
||||
Deno.test("day 1 part 1", async () => {
|
||||
assertEquals(await part1(asyncIterator(testInput)), 7);
|
||||
});
|
||||
|
||||
Deno.test("day 1 part 2", async () => {
|
||||
assertEquals(await part2(asyncIterator(testInput)), 5);
|
||||
});
|
|
@ -76,3 +76,11 @@ export async function inputNumbers(
|
|||
): Promise<AsyncIterableIterator<number>> {
|
||||
return readStringsAsNumbers(await inputLines(day));
|
||||
}
|
||||
|
||||
export async function* asyncIterator<T>(
|
||||
array: T[],
|
||||
): AsyncIterableIterator<T> {
|
||||
for (const v of array) {
|
||||
yield v;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue