Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

test: fix errors in test-buffer-alloc.js #23645

Closed
wants to merge 1 commit into from
Closed
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
19 changes: 12 additions & 7 deletions test/parallel/test-buffer-alloc.js
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,11 @@ const outOfBoundsError = {
type: RangeError
};

const outOfRangeError = {
code: 'ERR_OUT_OF_RANGE',
type: RangeError
};

// try to write a 0-length string beyond the end of b
common.expectsError(() => b.write('', 2048), outOfBoundsError);

Expand Down Expand Up @@ -787,31 +792,31 @@ Buffer.from(Buffer.allocUnsafe(0), 0, 0);
// issue GH-5587
common.expectsError(
() => Buffer.alloc(8).writeFloatLE(0, 5),
outOfBoundsError
outOfRangeError
);
common.expectsError(
() => Buffer.alloc(16).writeDoubleLE(0, 9),
outOfBoundsError
outOfRangeError
);

// attempt to overflow buffers, similar to previous bug in array buffers
common.expectsError(
() => Buffer.allocUnsafe(8).writeFloatLE(0.0, 0xffffffff),
outOfBoundsError
outOfRangeError
);
common.expectsError(
() => Buffer.allocUnsafe(8).writeFloatLE(0.0, 0xffffffff),
outOfBoundsError
outOfRangeError
);

// ensure negative values can't get past offset
common.expectsError(
() => Buffer.allocUnsafe(8).writeFloatLE(0.0, -1),
outOfBoundsError
outOfRangeError
);
common.expectsError(
() => Buffer.allocUnsafe(8).writeFloatLE(0.0, -1),
outOfBoundsError
outOfRangeError
);

// test for common write(U)IntLE/BE
Expand Down Expand Up @@ -1005,7 +1010,7 @@ common.expectsError(() => {
const a = Buffer.alloc(1);
const b = Buffer.alloc(1);
a.copy(b, 0, 0x100000000, 0x100000001);
}, outOfBoundsError);
}, outOfRangeError);

// Unpooled buffer (replaces SlowBuffer)
{
Expand Down