diff --git a/test/parallel/test-buffer-negative-length.js b/test/parallel/test-buffer-negative-length.js deleted file mode 100644 index bf903b933d2689..00000000000000 --- a/test/parallel/test-buffer-negative-length.js +++ /dev/null @@ -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); diff --git a/test/parallel/test-buffer-no-negative-allocation.js b/test/parallel/test-buffer-no-negative-allocation.js index b34477aa8c4b45..6d44e432f3c780 100644 --- a/test/parallel/test-buffer-no-negative-allocation.js +++ b/test/parallel/test-buffer-no-negative-allocation.js @@ -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"$/ -}, 12); +}, 15); // Test that negative Buffer length inputs throw errors. @@ -26,3 +27,7 @@ assert.throws(() => Buffer.allocUnsafe(-1), msg); assert.throws(() => Buffer.allocUnsafeSlow(-Buffer.poolSize), msg); assert.throws(() => Buffer.allocUnsafeSlow(-100), msg); assert.throws(() => Buffer.allocUnsafeSlow(-1), msg); + +assert.throws(() => SlowBuffer(-Buffer.poolSize), msg); +assert.throws(() => SlowBuffer(-100), msg); +assert.throws(() => SlowBuffer(-1), msg);