From 6f6f6d4087ed2a60b6a443151dc75c76812a8d80 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 | 8 +++++++- 2 files changed, 7 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 bf903b933d2..00000000000 --- 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 3a4958c8f62..d48d02cb9b2 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"$/ -}, 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);