test: fix test for buffer regression #649
pass a regexp to assert.throws() PR-URL: https://github.com/nodejs/node/pull/9924 Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: James M Snell <jasnell@gmail.com>
This commit is contained in:
parent
1be73e828d
commit
a3a3937d76
@ -6,8 +6,13 @@ const SlowBuffer = require('buffer').SlowBuffer;
|
||||
|
||||
// Regression test for https://github.com/nodejs/node/issues/649.
|
||||
const len = 1422561062959;
|
||||
assert.throws(() => Buffer(len).toString('utf8'));
|
||||
assert.throws(() => SlowBuffer(len).toString('utf8'));
|
||||
assert.throws(() => Buffer.alloc(len).toString('utf8'));
|
||||
assert.throws(() => Buffer.allocUnsafe(len).toString('utf8'));
|
||||
assert.throws(() => Buffer.allocUnsafeSlow(len).toString('utf8'));
|
||||
const lenLimitMsg = new RegExp('^RangeError: (Invalid typed array length' +
|
||||
'|Array buffer allocation failed' +
|
||||
'|Invalid array buffer length)$');
|
||||
|
||||
assert.throws(() => Buffer(len).toString('utf8'), lenLimitMsg);
|
||||
assert.throws(() => SlowBuffer(len).toString('utf8'), lenLimitMsg);
|
||||
assert.throws(() => Buffer.alloc(len).toString('utf8'), lenLimitMsg);
|
||||
assert.throws(() => Buffer.allocUnsafe(len).toString('utf8'), lenLimitMsg);
|
||||
assert.throws(() => Buffer.allocUnsafeSlow(len).toString('utf8'),
|
||||
lenLimitMsg);
|
||||
|
Loading…
x
Reference in New Issue
Block a user