From 7d6afb3dbf3919ef893a7512fca736352fe42d97 Mon Sep 17 00:00:00 2001 From: ZYSzys <17367077526@163.com> Date: Sun, 17 Feb 2019 19:28:06 +0800 Subject: [PATCH] test: remove duplicated buffer negative allocation test MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit PR-URL: https://github.com/nodejs/node/pull/26160 Reviewed-By: Anna Henningsen Reviewed-By: Rich Trott Reviewed-By: Colin Ihrig Reviewed-By: Luigi Pinca Reviewed-By: Ruben Bridgewater Reviewed-By: James M Snell Reviewed-By: Сковорода Никита Андреевич --- test/parallel/test-buffer-negative-length.js | 17 ----------------- .../test-buffer-no-negative-allocation.js | 7 ++++++- 2 files changed, 6 insertions(+), 18 deletions(-) delete mode 100644 test/parallel/test-buffer-negative-length.js 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);