-
-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathtest.ts
More file actions
32 lines (29 loc) · 800 Bytes
/
test.ts
File metadata and controls
32 lines (29 loc) · 800 Bytes
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
26
27
28
29
30
31
32
import { assertEquals } from "https://deno.land/std@0.159.0/testing/asserts.ts";
import { compress, decompress } from "./mod.ts";
function encode(input: string): Uint8Array {
return new TextEncoder().encode(input);
}
Deno.test({
name: "compress",
fn: () => {
// empty
assertEquals(compress(encode("")), new Uint8Array([59]));
// 'X' x64 times
assertEquals(
compress(encode("X".repeat(64))),
new Uint8Array([27, 63, 0, 0, 36, 176, 226, 153, 64, 18]),
);
},
});
Deno.test({
name: "decompress",
fn: () => {
// empty
assertEquals(decompress(Uint8Array.from([59])), new Uint8Array([]));
// 'X' x64 times
assertEquals(
decompress(Uint8Array.from([27, 63, 0, 0, 36, 176, 226, 153, 64, 18])),
encode("X".repeat(64)),
);
},
});