Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion test/parallel/test-buffer-readint.js
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,7 @@ const assert = require('assert');
});

// Test 1 to 6 bytes.
for (let i = 1; i < 6; i++) {
for (let i = 1; i <= 6; i++) {
['readIntBE', 'readIntLE'].forEach((fn) => {
['', '0', null, {}, [], () => {}, true, false, undefined].forEach((o) => {
assert.throws(
Expand Down
2 changes: 1 addition & 1 deletion test/parallel/test-buffer-readuint.js
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ const assert = require('assert');
});

// Test 1 to 6 bytes.
for (let i = 1; i < 6; i++) {
for (let i = 1; i <= 6; i++) {
['readUIntBE', 'readUIntLE'].forEach((fn) => {
['', '0', null, {}, [], () => {}, true, false, undefined].forEach((o) => {
assert.throws(
Expand Down
15 changes: 15 additions & 0 deletions test/parallel/test-buffer-writeint.js
Original file line number Diff line number Diff line change
Expand Up @@ -162,6 +162,21 @@ const errorOutOfBounds = common.expectsError({
});
}

// Test 48 bit
{
const value = 0x1234567890ab;
const buffer = Buffer.allocUnsafe(6);
buffer.writeIntBE(value, 0, 6);
assert.ok(buffer.equals(new Uint8Array([
0x12, 0x34, 0x56, 0x78, 0x90, 0xab
])));

buffer.writeIntLE(value, 0, 6);
assert.ok(buffer.equals(new Uint8Array([
0xab, 0x90, 0x78, 0x56, 0x34, 0x12
])));
}

// Test Int
{
const data = Buffer.alloc(8);
Expand Down
11 changes: 11 additions & 0 deletions test/parallel/test-buffer-writeuint.js
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,17 @@ const assert = require('assert');
assert.ok(data.equals(new Uint8Array([0x6d, 0x6d, 0x6d, 0x0a, 0xf9, 0xe7])));
}

// Test 48 bit
{
const value = 0x1234567890ab;
const data = Buffer.allocUnsafe(6);
data.writeUIntBE(value, 0, 6);
assert.ok(data.equals(new Uint8Array([0x12, 0x34, 0x56, 0x78, 0x90, 0xab])));

data.writeUIntLE(value, 0, 6);
assert.ok(data.equals(new Uint8Array([0xab, 0x90, 0x78, 0x56, 0x34, 0x12])));
}

// Test UInt
{
const data = Buffer.alloc(8);
Expand Down