Skip to content

Commit d6a4e3d

Browse files
committed
test: fix test for buffer regression #649
- pass a regexp to assert.throws()
1 parent 8264a22 commit d6a4e3d

File tree

1 file changed

+11
-5
lines changed

1 file changed

+11
-5
lines changed

test/parallel/test-buffer-regression-649.js

+11-5
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,14 @@ const SlowBuffer = require('buffer').SlowBuffer;
66

77
// Regression test for https://github.com/nodejs/node/issues/649.
88
const len = 1422561062959;
9-
assert.throws(() => Buffer(len).toString('utf8'));
10-
assert.throws(() => SlowBuffer(len).toString('utf8'));
11-
assert.throws(() => Buffer.alloc(len).toString('utf8'));
12-
assert.throws(() => Buffer.allocUnsafe(len).toString('utf8'));
13-
assert.throws(() => Buffer.allocUnsafeSlow(len).toString('utf8'));
9+
const lenLimitMsg = /^RangeError: Invalid typed array length$/;
10+
assert.throws(() => Buffer(len).toString('utf8'),
11+
lenLimitMsg);
12+
assert.throws(() => SlowBuffer(len).toString('utf8'),
13+
lenLimitMsg);
14+
assert.throws(() => Buffer.alloc(len).toString('utf8'),
15+
lenLimitMsg);
16+
assert.throws(() => Buffer.allocUnsafe(len).toString('utf8'),
17+
lenLimitMsg);
18+
assert.throws(() => Buffer.allocUnsafeSlow(len).toString('utf8'),
19+
lenLimitMsg);

0 commit comments

Comments
 (0)