-
-
Notifications
You must be signed in to change notification settings - Fork 0
/
mod.test.ts
23 lines (20 loc) · 752 Bytes
/
mod.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
import { assertEquals } from "https://deno.land/[email protected]/testing/asserts.ts";
import { base85decode, base85encode } from "./mod.ts";
Deno.test("Success Encode Function", (): void => {
const str: Uint8Array = new TextEncoder().encode("Dream Theater");
const encode: string = base85encode(str);
assertEquals(encode, "<~6uljID'2ekART[lEW?(>~>");
});
Deno.test("Success Decode Function", (): void => {
const str = '<~87cURD]i,"Ebo8=~>';
const decode: string = new TextDecoder().decode(base85decode(str));
assertEquals(decode, "Hello World.");
});
Deno.test("Faile Decode Function", (): void => {
try {
const str = '87cURD]i,"Ebo8=';
base85decode(str);
} catch (e) {
assertEquals(e, Error("base86: invalid input"));
}
});