Separate readUInt64LE fixtures from writeUInt64LE; add two more tests: "n < 0" & "0 < n < 1"

This commit is contained in:
Vlad Stan 2020-08-31 15:57:09 +03:00
parent 68fb3cdb11
commit 62bb17b045
2 changed files with 27 additions and 1 deletions

View file

@ -42,7 +42,7 @@ describe('bufferutils', () => {
}); });
}); });
fixtures.invalid.readUInt64LE.forEach(f => { fixtures.invalid.writeUInt64LE.forEach(f => {
it('throws on ' + f.description, () => { it('throws on ' + f.description, () => {
const buffer = Buffer.alloc(8, 0); const buffer = Buffer.alloc(8, 0);

View file

@ -71,6 +71,32 @@
"hex": "0100000000002000", "hex": "0100000000002000",
"dec": 9007199254740993 "dec": 9007199254740993
} }
],
"writeUInt64LE": [
{
"description": "n === 2^53",
"exception": "RangeError: value out of range",
"hex": "0000000000002000",
"dec": 9007199254740992
},
{
"description": "n > 2^53",
"exception": "RangeError: value out of range",
"hex": "0100000000002000",
"dec": 9007199254740993
},
{
"description": "n < 0",
"exception": "specified a negative value for writing an unsigned value",
"hex": "",
"dec": -1
},
{
"description": "0 < n < 1",
"exception": "value has a fractional component",
"hex": "",
"dec": 0.1
}
] ]
} }
} }