mirror of
https://github.com/nodejs/node.git
synced 2024-12-01 16:10:02 +01:00
dbfe8c4ea2
PR-URL: https://github.com/nodejs/node/pull/13976 Reviewed-By: Refael Ackermann <refack@gmail.com> Reviewed-By: Matteo Collina <matteo.collina@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com>
18 lines
703 B
JavaScript
18 lines
703 B
JavaScript
'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);
|