Skip to content

Commit

Permalink
test: fix test for buffer regression nodejs#649
Browse files Browse the repository at this point in the history
- pass a regexp to assert.throws()
  • Loading branch information
joyeecheung committed Dec 4, 2016
1 parent 8264a22 commit d6a4e3d
Showing 1 changed file with 11 additions and 5 deletions.
16 changes: 11 additions & 5 deletions test/parallel/test-buffer-regression-649.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,14 @@ 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 = /^RangeError: Invalid typed array 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);

0 comments on commit d6a4e3d

Please sign in to comment.