Skip to content

Commit

Permalink
test: fix errors in test-buffer-alloc.js
Browse files Browse the repository at this point in the history
This fixes test code that was mistaken landed by me this morning. (Code
& Learn rush gone bad.) Sorry. Please fast track.

PR-URL: #23645
Reviewed-By: Anna Henningsen <[email protected]>
Reviewed-By: Franziska Hinkelmann <[email protected]>
  • Loading branch information
Trott authored and jasnell committed Oct 17, 2018
1 parent 5e68333 commit 2d2388d
Showing 1 changed file with 12 additions and 7 deletions.
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

0 comments on commit 2d2388d

Please sign in to comment.