Add initial basic tests

This commit is contained in:
GCHQDeveloper581 2026-03-02 17:06:33 +00:00
parent 5ddba1ac6c
commit e1e48b51a9
No known key found for this signature in database
GPG Key ID: 6222E059A3DF595C
2 changed files with 29 additions and 0 deletions

View File

@ -23,6 +23,7 @@ import "./tests/Dish.mjs";
import "./tests/NodeDish.mjs"; import "./tests/NodeDish.mjs";
import "./tests/Utils.mjs"; import "./tests/Utils.mjs";
import "./tests/Categories.mjs"; import "./tests/Categories.mjs";
import "./tests/lib/BigIntUtils.mjs";
const testStatus = { const testStatus = {
allTestsPassing: true, allTestsPassing: true,

View File

@ -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...)"
});
}),
]);