From 13b7856444f9ec0b3f58acca4084a7c2a16049a3 Mon Sep 17 00:00:00 2001 From: Eric Christie Date: Wed, 8 Feb 2017 23:20:05 -0500 Subject: [PATCH] test: improve coverage in test-crypto.dh MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit PR-URL: https://github.com/nodejs/node/pull/11253 Reviewed-By: Rich Trott Reviewed-By: Michaƫl Zasso Reviewed-By: Colin Ihrig Reviewed-By: James M Snell --- test/pummel/test-crypto-dh.js | 35 ++++++++++++++++++++++++++--------- 1 file changed, 26 insertions(+), 9 deletions(-) diff --git a/test/pummel/test-crypto-dh.js b/test/pummel/test-crypto-dh.js index 7656d0ffa92e84..a19e583c516398 100644 --- a/test/pummel/test-crypto-dh.js +++ b/test/pummel/test-crypto-dh.js @@ -8,15 +8,32 @@ if (!common.hasCrypto) { return; } -assert.throws(function() { - crypto.getDiffieHellman('unknown-group'); -}); -assert.throws(function() { - crypto.getDiffieHellman('modp1').setPrivateKey(''); -}); -assert.throws(function() { - crypto.getDiffieHellman('modp1').setPublicKey(''); -}); +assert.throws( + function() { + crypto.getDiffieHellman('unknown-group'); + }, + /^Error: Unknown group$/, + 'crypto.getDiffieHellman(\'unknown-group\') ' + + 'failed to throw the expected error.' +); +assert.throws( + function() { + crypto.getDiffieHellman('modp1').setPrivateKey(''); + }, + new RegExp('^TypeError: crypto\\.getDiffieHellman\\(\\.\\.\\.\\)\\.' + + 'setPrivateKey is not a function$'), + 'crypto.getDiffieHellman(\'modp1\').setPrivateKey(\'\') ' + + 'failed to throw the expected error.' +); +assert.throws( + function() { + crypto.getDiffieHellman('modp1').setPublicKey(''); + }, + new RegExp('^TypeError: crypto\\.getDiffieHellman\\(\\.\\.\\.\\)\\.' + + 'setPublicKey is not a function$'), + 'crypto.getDiffieHellman(\'modp1\').setPublicKey(\'\') ' + + 'failed to throw the expected error.' +); var hashes = { modp1: '630e9acd2cc63f7e80d8507624ba60ac0757201a',