Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

test: fix test for buffer regression #649 #9924

Closed
wants to merge 3 commits into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 10 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,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);