From 0541bb67f5469d87ad91e0ca03700df599a20db4 Mon Sep 17 00:00:00 2001 From: Karsten Schmidt Date: Sat, 12 Aug 2023 12:22:03 +0200 Subject: [PATCH] test(base-n): add tests --- packages/base-n/test/index.ts | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/packages/base-n/test/index.ts b/packages/base-n/test/index.ts index eadbffd32b..189d3e3e78 100644 --- a/packages/base-n/test/index.ts +++ b/packages/base-n/test/index.ts @@ -1,12 +1,15 @@ 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, @@ -14,7 +17,7 @@ import { group("base-n", { roundtrip: () => { - const X = BigInt(2) ** BigInt(128) - BigInt(1); + const X = (BigInt(1) << BigInt(128)) - BigInt(1); const check = ( base: IBase, @@ -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");