test: remove duplicated buffer negative allocation test
PR-URL: https://github.com/nodejs/node/pull/26160 Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: Rich Trott <rtrott@gmail.com> Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Luigi Pinca <luigipinca@gmail.com> Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Сковорода Никита Андреевич <chalkerx@gmail.com>
This commit is contained in:
parent
df67cd0fef
commit
6f6f6d4087
@ -1,17 +0,0 @@
|
||||
'use strict';
|
||||
|
||||
const common = require('../common');
|
||||
const assert = require('assert');
|
||||
const SlowBuffer = require('buffer').SlowBuffer;
|
||||
|
||||
const bufferNegativeMsg = common.expectsError({
|
||||
code: 'ERR_INVALID_OPT_VALUE',
|
||||
type: RangeError,
|
||||
message: /^The value "[^"]*" is invalid for option "size"$/
|
||||
}, 5);
|
||||
assert.throws(() => Buffer(-1).toString('utf8'), bufferNegativeMsg);
|
||||
assert.throws(() => SlowBuffer(-1).toString('utf8'), bufferNegativeMsg);
|
||||
assert.throws(() => Buffer.alloc(-1).toString('utf8'), bufferNegativeMsg);
|
||||
assert.throws(() => Buffer.allocUnsafe(-1).toString('utf8'), bufferNegativeMsg);
|
||||
assert.throws(() => Buffer.allocUnsafeSlow(-1).toString('utf8'),
|
||||
bufferNegativeMsg);
|
@ -2,12 +2,13 @@
|
||||
|
||||
const common = require('../common');
|
||||
const assert = require('assert');
|
||||
const { SlowBuffer } = require('buffer');
|
||||
|
||||
const msg = common.expectsError({
|
||||
code: 'ERR_INVALID_OPT_VALUE',
|
||||
type: RangeError,
|
||||
message: /^The value "[^"]*" is invalid for option "size"$/
|
||||
}, 16);
|
||||
}, 20);
|
||||
|
||||
// Test that negative Buffer length inputs throw errors.
|
||||
|
||||
@ -30,3 +31,8 @@ assert.throws(() => Buffer.allocUnsafeSlow(-Buffer.poolSize), msg);
|
||||
assert.throws(() => Buffer.allocUnsafeSlow(-100), msg);
|
||||
assert.throws(() => Buffer.allocUnsafeSlow(-1), msg);
|
||||
assert.throws(() => Buffer.allocUnsafeSlow(NaN), msg);
|
||||
|
||||
assert.throws(() => SlowBuffer(-Buffer.poolSize), msg);
|
||||
assert.throws(() => SlowBuffer(-100), msg);
|
||||
assert.throws(() => SlowBuffer(-1), msg);
|
||||
assert.throws(() => SlowBuffer(NaN), msg);
|
||||
|
Loading…
x
Reference in New Issue
Block a user