Add initial basic tests
This commit is contained in:
parent
5ddba1ac6c
commit
e1e48b51a9
@ -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,
|
||||||
|
|||||||
28
tests/node/tests/lib/BigIntUtils.mjs
Normal file
28
tests/node/tests/lib/BigIntUtils.mjs
Normal 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...)"
|
||||||
|
});
|
||||||
|
}),
|
||||||
|
]);
|
||||||
Loading…
x
Reference in New Issue
Block a user