2019-05-04 16:08:30 +00:00
|
|
|
'use strict';
|
|
|
|
|
2020-02-27 20:51:48 +00:00
|
|
|
// For the browser test builder to work you MUST import the module in a variable that
|
2019-05-04 16:08:30 +00:00
|
|
|
// is the camelised version of the package name.
|
|
|
|
const bigintCryptoUtils = require('../dist/bigint-crypto-utils-latest.node');
|
|
|
|
const chai = require('chai');
|
|
|
|
|
|
|
|
const inputs = [
|
|
|
|
{
|
|
|
|
value: BigInt(1),
|
|
|
|
bitLength: 1
|
|
|
|
},
|
|
|
|
{
|
|
|
|
value: BigInt(-2),
|
|
|
|
bitLength: 2
|
|
|
|
},
|
|
|
|
{
|
|
|
|
value: BigInt(11592217955149597331),
|
|
|
|
abs: BigInt(11592217955149597331),
|
|
|
|
bitLength: 64
|
|
|
|
}
|
|
|
|
];
|
|
|
|
|
|
|
|
describe('bitLength', function () {
|
|
|
|
for (const input of inputs) {
|
|
|
|
describe(`bitLength(${input.value})`, function () {
|
|
|
|
it(`should return ${input.bitLength}`, function () {
|
2019-05-29 15:44:18 +00:00
|
|
|
const ret = bigintCryptoUtils.bitLength(input.value);
|
2019-05-04 16:08:30 +00:00
|
|
|
chai.expect(ret).to.equal(input.bitLength);
|
|
|
|
});
|
|
|
|
});
|
|
|
|
}
|
|
|
|
});
|