-
-
Notifications
You must be signed in to change notification settings - Fork 2
/
compress_test.ts
25 lines (22 loc) · 1.02 KB
/
compress_test.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
import { test } from "@cross/test";
import { assertEquals } from "@std/assert";
import { assertType, type IsExact } from "@std/testing/types";
import { compress } from "./compress.ts";
await test("compress the iterable and the selectors are same length", () => {
const result = compress([1, 2, 3, 4, 5], [true, false, true, false, true]);
const expected = [1, 3, 5];
assertEquals(Array.from(result), expected);
assertType<IsExact<typeof result, Iterable<number>>>(true);
});
await test("compress the iterable is larger than the selectors", () => {
const result = compress([1, 2, 3, 4, 5], [true, false, true]);
const expected = [1, 3];
assertEquals(Array.from(result), expected);
assertType<IsExact<typeof result, Iterable<number>>>(true);
});
await test("compress the iterable is smaller than the selector", () => {
const result = compress([1, 2, 3], [true, false, true, false, true]);
const expected = [1, 3];
assertEquals(Array.from(result), expected);
assertType<IsExact<typeof result, Iterable<number>>>(true);
});