Skip to content

Commit

Permalink
test(base-n): add tests
Browse files Browse the repository at this point in the history
  • Loading branch information
postspectacular committed Aug 12, 2023
1 parent da6765d commit 0541bb6
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion packages/base-n/test/index.ts
Original file line number Diff line number Diff line change
@@ -1,20 +1,23 @@
import { group } from "@thi.ng/testament";
import * as assert from "assert";
import {
BASE16_LC,
BASE16_UC,
BASE32_HEX,
BASE32_RFC4648,
BASE36,
BASE58,
BASE62,
BASE64,
BASE8,
BASE85,
defBase,
type IBase,
} from "../src/index.js";

group("base-n", {
roundtrip: () => {
const X = BigInt(2) ** BigInt(128) - BigInt(1);
const X = (BigInt(1) << BigInt(128)) - BigInt(1);

const check = (
base: IBase,
Expand All @@ -25,6 +28,9 @@ group("base-n", {
assert.strictEqual(base.decodeBigInt(expected), X, `decode: ${id}`);
};

check(BASE8, "3777777777777777777777777777777777777777777");
check(BASE16_LC, "ffffffffffffffffffffffffffffffff");
check(BASE16_UC, "FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF");
check(BASE32_RFC4648, "H7777777777777777777777777", "32rfc");
check(BASE32_HEX, "7VVVVVVVVVVVVVVVVVVVVVVVVV", "32hex");
check(BASE36, "F5LXX1ZZ5PNORYNQGLHZMSP33");
Expand Down

0 comments on commit 0541bb6

Please sign in to comment.