diff --git a/tests/node/index.mjs b/tests/node/index.mjs index f6abba40..f872f8f4 100644 --- a/tests/node/index.mjs +++ b/tests/node/index.mjs @@ -23,6 +23,7 @@ import "./tests/Dish.mjs"; import "./tests/NodeDish.mjs"; import "./tests/Utils.mjs"; import "./tests/Categories.mjs"; +import "./tests/lib/BigIntUtils.mjs"; const testStatus = { allTestsPassing: true, diff --git a/tests/node/tests/lib/BigIntUtils.mjs b/tests/node/tests/lib/BigIntUtils.mjs new file mode 100644 index 00000000..1a6b7c0f --- /dev/null +++ b/tests/node/tests/lib/BigIntUtils.mjs @@ -0,0 +1,28 @@ +import TestRegister from "../../../lib/TestRegister.mjs"; +import { parseBigInt, egcd } from "../../../../src/core/lib/BigIntUtils.mjs"; +import it from "../../assertionHandler.mjs"; +import assert from "assert"; + +TestRegister.addApiTests([ + it("BigIntUtils: egcd - basic", () => { + const a = BigInt("36"); + const b = BigInt("48"); + const gcd = BigInt("12"); + const bezout1 = BigInt("-1"); + const bezout2 = BigInt("1"); + assert.deepStrictEqual(egcd(a, b), [gcd, bezout1, bezout2]); + }), + + it("BigIntUtils: parseBigInt - basic", () => { + const value = parseBigInt("1", "test value"); + + assert.deepStrictEqual(value, BigInt("1")); + }), + + it("BigIntUtils: parseBigInt - not an int", () => { + assert.throws(() => parseBigInt("test", "test value"), { + name: "Error", + message: "test value must be decimal or hex (0x...)" + }); + }), +]);