Change filenames for easy diff
This commit is contained in:
parent
e2dea8289a
commit
11e4a12caf
25 changed files with 0 additions and 0 deletions
49
test/bufferutils.spec.ts
Normal file
49
test/bufferutils.spec.ts
Normal file
|
@ -0,0 +1,49 @@
|
|||
const { describe, it } = require('mocha')
|
||||
const assert = require('assert')
|
||||
const bufferutils = require('../src/bufferutils')
|
||||
|
||||
const fixtures = require('./fixtures/bufferutils.json')
|
||||
|
||||
describe('bufferutils', () => {
|
||||
describe('readUInt64LE', () => {
|
||||
fixtures.valid.forEach(f => {
|
||||
it('decodes ' + f.hex, () => {
|
||||
const buffer = Buffer.from(f.hex, 'hex')
|
||||
const number = bufferutils.readUInt64LE(buffer, 0)
|
||||
|
||||
assert.strictEqual(number, f.dec)
|
||||
})
|
||||
})
|
||||
|
||||
fixtures.invalid.readUInt64LE.forEach(f => {
|
||||
it('throws on ' + f.description, () => {
|
||||
const buffer = Buffer.from(f.hex, 'hex')
|
||||
|
||||
assert.throws(() => {
|
||||
bufferutils.readUInt64LE(buffer, 0)
|
||||
}, new RegExp(f.exception))
|
||||
})
|
||||
})
|
||||
})
|
||||
|
||||
describe('writeUInt64LE', () => {
|
||||
fixtures.valid.forEach(f => {
|
||||
it('encodes ' + f.dec, () => {
|
||||
const buffer = Buffer.alloc(8, 0)
|
||||
|
||||
bufferutils.writeUInt64LE(buffer, f.dec, 0)
|
||||
assert.strictEqual(buffer.toString('hex'), f.hex)
|
||||
})
|
||||
})
|
||||
|
||||
fixtures.invalid.readUInt64LE.forEach(f => {
|
||||
it('throws on ' + f.description, () => {
|
||||
const buffer = Buffer.alloc(8, 0)
|
||||
|
||||
assert.throws(() => {
|
||||
bufferutils.writeUInt64LE(buffer, f.dec, 0)
|
||||
}, new RegExp(f.exception))
|
||||
})
|
||||
})
|
||||
})
|
||||
})
|
Loading…
Add table
Add a link
Reference in a new issue