2016-12-13 04:51:01 +00:00
|
|
|
'use strict';
|
2019-12-25 17:02:16 +00:00
|
|
|
require('../common');
|
2020-06-18 06:40:30 +00:00
|
|
|
|
2016-12-13 04:51:01 +00:00
|
|
|
const assert = require('assert');
|
|
|
|
|
|
|
|
const buffer = require('buffer');
|
|
|
|
const SlowBuffer = buffer.SlowBuffer;
|
|
|
|
|
|
|
|
const kMaxLength = buffer.kMaxLength;
|
2019-12-25 17:02:16 +00:00
|
|
|
const bufferMaxSizeMsg = {
|
2023-01-18 10:36:27 +00:00
|
|
|
code: 'ERR_OUT_OF_RANGE',
|
2019-12-25 17:02:16 +00:00
|
|
|
name: 'RangeError',
|
|
|
|
};
|
2016-12-13 04:51:01 +00:00
|
|
|
|
|
|
|
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);
|