diff options
author | Kim-Anh Tran <kimanh@chromium.org> | 2020-06-18 09:40:30 +0300 |
---|---|---|
committer | Michaƫl Zasso <targos@protonmail.com> | 2020-10-18 21:17:40 +0300 |
commit | 94dd7b9f94fd151195820e961de997a0ad7ca40a (patch) | |
tree | 18b9122b58254e47b192f20d1854176004479ab9 | |
parent | faeb9607c615e5c18605d8d3399658014a563d7b (diff) |
test: update tests after increasing typed array size to 4GB
PR-URL: https://github.com/nodejs/node/pull/35415
Reviewed-By: Rich Trott <rtrott@gmail.com>
Reviewed-By: Jiawen Geng <technicalcute@gmail.com>
Reviewed-By: Daniel Bevenius <daniel.bevenius@gmail.com>
Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
Reviewed-By: Myles Borins <myles.borins@gmail.com>
-rw-r--r-- | test/parallel/test-buffer-alloc.js | 5 | ||||
-rw-r--r-- | test/parallel/test-buffer-over-max-length.js | 13 |
2 files changed, 10 insertions, 8 deletions
diff --git a/test/parallel/test-buffer-alloc.js b/test/parallel/test-buffer-alloc.js index 070a3803802..c72e286f3f0 100644 --- a/test/parallel/test-buffer-alloc.js +++ b/test/parallel/test-buffer-alloc.js @@ -1,5 +1,6 @@ 'use strict'; const common = require('../common'); + const assert = require('assert'); const vm = require('vm'); @@ -8,8 +9,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 ** 32), - { message: 'Invalid typed array length: 4294967296' } + () => new Uint8Array(2 ** 32 + 1), + { message: 'Invalid typed array length: 4294967297' } ); 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 f02c4d1ddd3..c263633d941 100644 --- a/test/parallel/test-buffer-over-max-length.js +++ b/test/parallel/test-buffer-over-max-length.js @@ -1,5 +1,6 @@ 'use strict'; require('../common'); + const assert = require('assert'); const buffer = require('buffer'); @@ -12,11 +13,11 @@ const bufferMaxSizeMsg = { message: /^The argument 'size' is invalid\. Received [^"]*$/ }; -assert.throws(() => Buffer((-1 >>> 0) + 1), bufferMaxSizeMsg); -assert.throws(() => SlowBuffer((-1 >>> 0) + 1), bufferMaxSizeMsg); -assert.throws(() => Buffer.alloc((-1 >>> 0) + 1), bufferMaxSizeMsg); -assert.throws(() => Buffer.allocUnsafe((-1 >>> 0) + 1), bufferMaxSizeMsg); -assert.throws(() => Buffer.allocUnsafeSlow((-1 >>> 0) + 1), bufferMaxSizeMsg); +assert.throws(() => Buffer((-1 >>> 0) + 2), bufferMaxSizeMsg); +assert.throws(() => SlowBuffer((-1 >>> 0) + 2), bufferMaxSizeMsg); +assert.throws(() => Buffer.alloc((-1 >>> 0) + 2), bufferMaxSizeMsg); +assert.throws(() => Buffer.allocUnsafe((-1 >>> 0) + 2), bufferMaxSizeMsg); +assert.throws(() => Buffer.allocUnsafeSlow((-1 >>> 0) + 2), bufferMaxSizeMsg); assert.throws(() => Buffer(kMaxLength + 1), bufferMaxSizeMsg); assert.throws(() => SlowBuffer(kMaxLength + 1), bufferMaxSizeMsg); @@ -25,5 +26,5 @@ assert.throws(() => Buffer.allocUnsafe(kMaxLength + 1), bufferMaxSizeMsg); assert.throws(() => Buffer.allocUnsafeSlow(kMaxLength + 1), bufferMaxSizeMsg); // issue GH-4331 -assert.throws(() => Buffer.allocUnsafe(0x100000000), bufferMaxSizeMsg); +assert.throws(() => Buffer.allocUnsafe(0x100000001), bufferMaxSizeMsg); assert.throws(() => Buffer.allocUnsafe(0xFFFFFFFFF), bufferMaxSizeMsg); |