Skip to content

Commit 8e43568

Browse files
jakobkummerowMylesBorins
authored andcommittedMar 9, 2020
test: update tests for larger Buffers
V8 is about to increase the max TypedArray length to 2**32-1, which Node inherits as Buffer.kMaxLength. Some tests relied on values greater than the previous max length (2**31-1) to throw errors; this updates those tests for the new max length. PR-URL: #32114 Reviewed-By: Michaël Zasso <targos@protonmail.com> Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Сковорода Никита Андреевич <chalkerx@gmail.com>
1 parent 1ffa9f3 commit 8e43568

File tree

2 files changed

+3
-3
lines changed

2 files changed

+3
-3
lines changed
 

‎test/parallel/test-buffer-alloc.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,8 @@ const SlowBuffer = require('buffer').SlowBuffer;
88
// Verify the maximum Uint8Array size. There is no concrete limit by spec. The
99
// internal limits should be updated if this fails.
1010
assert.throws(
11-
() => new Uint8Array(2 ** 31),
12-
{ message: 'Invalid typed array length: 2147483648' }
11+
() => new Uint8Array(2 ** 32),
12+
{ message: 'Invalid typed array length: 4294967296' }
1313
);
1414

1515
const b = Buffer.allocUnsafe(1024);

‎test/parallel/test-buffer-over-max-length.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -25,5 +25,5 @@ assert.throws(() => Buffer.allocUnsafe(kMaxLength + 1), bufferMaxSizeMsg);
2525
assert.throws(() => Buffer.allocUnsafeSlow(kMaxLength + 1), bufferMaxSizeMsg);
2626

2727
// issue GH-4331
28-
assert.throws(() => Buffer.allocUnsafe(0xFFFFFFFF), bufferMaxSizeMsg);
28+
assert.throws(() => Buffer.allocUnsafe(0x100000000), bufferMaxSizeMsg);
2929
assert.throws(() => Buffer.allocUnsafe(0xFFFFFFFFF), bufferMaxSizeMsg);

0 commit comments

Comments
 (0)
Please sign in to comment.