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:
ZYSzys 2019-02-17 19:28:06 +08:00 committed by Ruben Bridgewater
parent df67cd0fef
commit 6f6f6d4087
No known key found for this signature in database
GPG Key ID: F07496B3EB3C1762
2 changed files with 7 additions and 18 deletions

View File

@ -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);

View File

@ -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);