mirror of
https://github.com/nodejs/node.git
synced 2024-11-21 21:19:50 +01:00
a4fdb1abe0
V8 will soon support typed arrays as large as the maximum array buffer
length. This patch replaces hardcoded values related to
Buffer.kMaxLength with the actual constant.
It also fixes a test that was passing by accident.
Refs: 44b2995900
PR-URL: https://github.com/nodejs/node/pull/49876
Reviewed-By: Richard Lau <rlau@redhat.com>
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
Reviewed-By: Yagiz Nizipli <yagiz@nizipli.com>
20 lines
617 B
JavaScript
20 lines
617 B
JavaScript
'use strict';
|
|
require('../common');
|
|
|
|
const assert = require('assert');
|
|
|
|
const buffer = require('buffer');
|
|
const SlowBuffer = buffer.SlowBuffer;
|
|
|
|
const kMaxLength = buffer.kMaxLength;
|
|
const bufferMaxSizeMsg = {
|
|
code: 'ERR_OUT_OF_RANGE',
|
|
name: 'RangeError',
|
|
};
|
|
|
|
assert.throws(() => Buffer(kMaxLength + 1), bufferMaxSizeMsg);
|
|
assert.throws(() => SlowBuffer(kMaxLength + 1), bufferMaxSizeMsg);
|
|
assert.throws(() => Buffer.alloc(kMaxLength + 1), bufferMaxSizeMsg);
|
|
assert.throws(() => Buffer.allocUnsafe(kMaxLength + 1), bufferMaxSizeMsg);
|
|
assert.throws(() => Buffer.allocUnsafeSlow(kMaxLength + 1), bufferMaxSizeMsg);
|