Skip to content
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
test: add regex to text-crypto-random
  • Loading branch information
NFoxley authored and Trott committed Dec 14, 2016
commit c834c7f84f1c8ba5881ec0d252482d13355ba1fc
5 changes: 3 additions & 2 deletions test/parallel/test-crypto-random.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,11 @@ crypto.DEFAULT_ENCODING = 'buffer';
// bump, we register a lot of exit listeners
process.setMaxListeners(256);

const expectedErrorRegexp = /^TypeError: size must be a number >= 0$/;
[crypto.randomBytes, crypto.pseudoRandomBytes].forEach(function(f) {
[-1, undefined, null, false, true, {}, []].forEach(function(value) {
assert.throws(function() { f(value); }, TypeError);
assert.throws(function() { f(value, function() {}); }, TypeError);
assert.throws(function() { f(value); }, expectedErrorRegexp);
assert.throws(function() { f(value, function() {}); }, expectedErrorRegexp);
});

[0, 1, 2, 4, 16, 256, 1024].forEach(function(len) {
Expand Down