diff --git a/test/parallel/test-buffer-alloc.js b/test/parallel/test-buffer-alloc.js index aad9c6bcab69e9..9aab1fddfecc5d 100644 --- a/test/parallel/test-buffer-alloc.js +++ b/test/parallel/test-buffer-alloc.js @@ -9,6 +9,7 @@ const { kMaxLength, } = require('buffer'); +<<<<<<< HEAD // Verify the maximum Uint8Array size. There is no concrete limit by spec. The // internal limits should be updated if this fails. assert.throws( @@ -16,6 +17,8 @@ assert.throws( { message: `Invalid typed array length: ${kMaxLength + 1}` }, ); +======= +>>>>>>> b3e1523f34 (Adapt tests for increased TypedArray sizes (#161)) const b = Buffer.allocUnsafe(1024); assert.strictEqual(b.length, 1024); diff --git a/test/parallel/test-buffer-tostring-rangeerror.js b/test/parallel/test-buffer-tostring-rangeerror.js index 0ebea759b5c42b..b8c4d75e7eadeb 100644 --- a/test/parallel/test-buffer-tostring-rangeerror.js +++ b/test/parallel/test-buffer-tostring-rangeerror.js @@ -13,13 +13,23 @@ const { }, } = require('buffer'); -const len = MAX_STRING_LENGTH + 1; +// Find the maximum supported buffer length. +let limit = 1 << 31; // 2GB +while (true) { + try { + Buffer(limit); + limit *= 2; + } catch (e) { + break; + } +} + const message = { code: 'ERR_STRING_TOO_LONG', name: 'Error', }; -assert.throws(() => Buffer(len).toString('utf8'), message); -assert.throws(() => SlowBuffer(len).toString('utf8'), message); -assert.throws(() => Buffer.alloc(len).toString('utf8'), message); -assert.throws(() => Buffer.allocUnsafe(len).toString('utf8'), message); -assert.throws(() => Buffer.allocUnsafeSlow(len).toString('utf8'), message); +assert.throws(() => Buffer(limit).toString('utf8'), message); +assert.throws(() => SlowBuffer(limit).toString('utf8'), message); +assert.throws(() => Buffer.alloc(limit).toString('utf8'), message); +assert.throws(() => Buffer.allocUnsafe(limit).toString('utf8'), message); +assert.throws(() => Buffer.allocUnsafeSlow(limit).toString('utf8'), message);