2021-03-24 13:04:30 +00:00
|
|
|
describe('bitLength', function () {
|
|
|
|
const inputs = [
|
|
|
|
{
|
|
|
|
value: BigInt(1),
|
|
|
|
bitLength: 1
|
|
|
|
},
|
2021-03-24 14:11:07 +00:00
|
|
|
{
|
|
|
|
value: 15,
|
|
|
|
bitLength: 4
|
|
|
|
},
|
2021-03-24 13:04:30 +00:00
|
|
|
{
|
|
|
|
value: BigInt(-2),
|
|
|
|
bitLength: 2
|
|
|
|
},
|
|
|
|
{
|
2022-01-17 10:04:55 +00:00
|
|
|
value: BigInt('11592217955149597331'),
|
|
|
|
abs: BigInt('11592217955149597331'),
|
2021-03-24 13:04:30 +00:00
|
|
|
bitLength: 64
|
|
|
|
}
|
|
|
|
]
|
|
|
|
for (const input of inputs) {
|
|
|
|
describe(`bitLength(${input.value})`, function () {
|
|
|
|
it(`should return ${input.bitLength}`, function () {
|
|
|
|
const ret = _pkg.bitLength(input.value)
|
|
|
|
chai.expect(ret).to.equal(input.bitLength)
|
|
|
|
})
|
|
|
|
})
|
|
|
|
}
|
|
|
|
})
|