60 lines
3.0 KiB
JavaScript
60 lines
3.0 KiB
JavaScript
'use strict';
|
|
|
|
// For the browser test builder to work you MUST import them module in a variable that
|
|
// is the camelised version of the package name.
|
|
const bigintUtils = require('../dist/bigint-utils-latest.node');
|
|
const chai = require('chai');
|
|
|
|
const numbers = [
|
|
{
|
|
value: BigInt(1),
|
|
prime: false
|
|
},
|
|
{
|
|
value: BigInt(2),
|
|
prime: true
|
|
},
|
|
{
|
|
value: BigInt(3),
|
|
prime: true
|
|
},
|
|
{
|
|
value: BigInt(15),
|
|
prime: false
|
|
},
|
|
{
|
|
value: BigInt(29),
|
|
prime: true
|
|
},
|
|
{
|
|
value: BigInt('669483106578092405936560831017556154622901950048903016651289'),
|
|
prime: true
|
|
},
|
|
{
|
|
value: BigInt('2074722246773485207821695222107608587480996474721117292752992589912196684750549658310084416732550077'),
|
|
prime: true
|
|
},
|
|
{
|
|
value: BigInt('2074722246773485207821695222107608587480996474721117292752992589912196684750549658310084416732550079'),
|
|
prime: false
|
|
},
|
|
{
|
|
value: BigInt('115922179551495973383410176342643722334557255682879605864838806293659619625004303206250384392546855063844106965156287951749387634112551089284595541103692716528774876311641700929986988023197242224581099872580798960693521778607396791006450968430359009613295725905514216842343121690916290236558767890728449777'),
|
|
prime: true
|
|
},
|
|
{
|
|
value: BigInt('918145944120889203205646923554374144932845997937845799234617798611046542304088105084854788397071323714642587188481158334265864050544813693415594035822877094557870151480865568334936301231664228940480803192289508235412296324312748621874408067955753620604885023289655277704554716080844406284392300643321715285709865081125252390440327650852470312931679380011885102491340191287595160450544053114365852338670819405357496612993587404998677760882578064637552397840566752638770525765833183986360029736508910848408875329873614164495552615086579144675027852136994842529623698055210822311666048300438808691619782893307972452223713060928388502843564836966586109748062827799521852219158489504529458627699284110902303538160168376473182639384638674469114371472053977558648090155686345760457454061117853710619580819749222459422610617170567016772342291486643520567969321969827786373531753524990712622940069883277763528926899970596407140603912036918433859986491820017690762751824769335720368488097262208835708414085501930989486498185503469986946236128468697606998536541209764920494156326791142098506801288127033229779646920082892258428128572765585196779698362187479280520327053508580551167899837393726371144977951402741307021389967382422805567365901203'),
|
|
prime: true
|
|
}
|
|
];
|
|
|
|
describe('Testing validation of prime numbers', function () {
|
|
for (const num of numbers) {
|
|
describe(`isProbablyPrime(${num.value})`, function () {
|
|
it(`should return ${num.prime}`, async function () {
|
|
const ret = await bigintUtils.isProbablyPrime(num.value);
|
|
chai.expect(ret).to.equal(num.prime);
|
|
});
|
|
});
|
|
}
|
|
}); |