2022-02-06 20:34:13 +00:00
|
|
|
import { numberToUint16BE, numberToUint32BE } from '../../src/utilities/number'
|
|
|
|
|
|
|
|
test('Test number conversion to Uint16 big endian buffer.', () => {
|
|
|
|
// When
|
|
|
|
const result = numberToUint16BE(1234)
|
|
|
|
|
|
|
|
// Then
|
2022-02-22 22:35:55 +00:00
|
|
|
const expectedResult = new Uint8Array([0x04, 0xd2])
|
2022-02-06 20:34:13 +00:00
|
|
|
expect(result).toMatchObject(expectedResult)
|
|
|
|
})
|
|
|
|
|
|
|
|
test('Test number conversion to Uint32 big endian buffer.', () => {
|
|
|
|
// When
|
|
|
|
const result = numberToUint32BE(123456)
|
|
|
|
|
|
|
|
// Then
|
2022-02-22 22:35:55 +00:00
|
|
|
const expectedResult = new Uint8Array([0x00, 0x01, 0xE2, 0x40])
|
2022-02-06 20:34:13 +00:00
|
|
|
expect(result).toMatchObject(expectedResult)
|
|
|
|
})
|