bigint-mod-arith/test/bitLength.ts

32 lines
638 B
TypeScript
Raw Normal View History

2022-10-03 15:35:35 +00:00
import * as bma from '#pkg'
describe('bitLength', function () {
const inputs = [
{
value: BigInt(1),
bitLength: 1
},
2021-03-24 14:11:07 +00:00
{
value: 15,
bitLength: 4
},
{
value: BigInt(-2),
bitLength: 2
},
{
value: BigInt('11592217955149597331'),
abs: BigInt('11592217955149597331'),
bitLength: 64
}
]
for (const input of inputs) {
describe(`bitLength(${input.value})`, function () {
it(`should return ${input.bitLength}`, function () {
2022-10-03 15:35:35 +00:00
const ret = bma.bitLength(input.value)
chai.expect(ret).to.equal(input.bitLength)
})
})
}
})