From 256bc4412c13f21066ae71a55e9cda1dfd5a779f Mon Sep 17 00:00:00 2001 From: Jakob Kummerow Date: Mon, 20 Jan 2020 16:51:02 +0100 Subject: [PATCH] test: update tests for larger Buffers MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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: https://github.com/nodejs/node/pull/32114 Reviewed-By: Michaël Zasso Reviewed-By: Colin Ihrig Reviewed-By: Сковорода Никита Андреевич --- test/parallel/test-buffer-alloc.js | 4 ++-- test/parallel/test-buffer-over-max-length.js | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/test/parallel/test-buffer-alloc.js b/test/parallel/test-buffer-alloc.js index 75bcb03d1913c4..9b7a64607edfc2 100644 --- a/test/parallel/test-buffer-alloc.js +++ b/test/parallel/test-buffer-alloc.js @@ -8,8 +8,8 @@ const SlowBuffer = require('buffer').SlowBuffer; // Verify the maximum Uint8Array size. There is no concrete limit by spec. The // internal limits should be updated if this fails. assert.throws( - () => new Uint8Array(2 ** 31), - { message: 'Invalid typed array length: 2147483648' } + () => new Uint8Array(2 ** 32), + { message: 'Invalid typed array length: 4294967296' } ); const b = Buffer.allocUnsafe(1024); diff --git a/test/parallel/test-buffer-over-max-length.js b/test/parallel/test-buffer-over-max-length.js index b1267b19ff439e..09513e29b406bd 100644 --- a/test/parallel/test-buffer-over-max-length.js +++ b/test/parallel/test-buffer-over-max-length.js @@ -25,5 +25,5 @@ assert.throws(() => Buffer.allocUnsafe(kMaxLength + 1), bufferMaxSizeMsg); assert.throws(() => Buffer.allocUnsafeSlow(kMaxLength + 1), bufferMaxSizeMsg); // issue GH-4331 -assert.throws(() => Buffer.allocUnsafe(0xFFFFFFFF), bufferMaxSizeMsg); +assert.throws(() => Buffer.allocUnsafe(0x100000000), bufferMaxSizeMsg); assert.throws(() => Buffer.allocUnsafe(0xFFFFFFFFF), bufferMaxSizeMsg);