summaryrefslogtreecommitdiff
path: root/test/parallel/test-crypto-hash.js
diff options
context:
space:
mode:
authornhoel <nhoel@users.noreply.github.com>2017-10-06 11:20:18 -0700
committerTobias Nießen <tniessen@tnie.de>2017-10-28 20:42:34 +0200
commit4eaf1fc0f8e93e54e43bc7d9fed4436cd878a28f (patch)
treebd824a714e084dc77204ddfa284815a2fb4f3c75 /test/parallel/test-crypto-hash.js
parent9788e96836243e2439867b81c6d6bf522115a0f5 (diff)
downloadandroid-node-v8-4eaf1fc0f8e93e54e43bc7d9fed4436cd878a28f.tar.gz
android-node-v8-4eaf1fc0f8e93e54e43bc7d9fed4436cd878a28f.tar.bz2
android-node-v8-4eaf1fc0f8e93e54e43bc7d9fed4436cd878a28f.zip
test: include values in assertion messages
Specifically for the test-crypto-hash.js test file. PR-URL: https://github.com/nodejs/node/pull/15996 Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Tobias Nießen <tniessen@tnie.de> Reviewed-By: Joyee Cheung <joyeec9h3@gmail.com> Reviewed-By: Gireesh Punathil <gpunathi@in.ibm.com>
Diffstat (limited to 'test/parallel/test-crypto-hash.js')
-rw-r--r--test/parallel/test-crypto-hash.js32
1 files changed, 25 insertions, 7 deletions
diff --git a/test/parallel/test-crypto-hash.js b/test/parallel/test-crypto-hash.js
index 82a76131fb..f55a676890 100644
--- a/test/parallel/test-crypto-hash.js
+++ b/test/parallel/test-crypto-hash.js
@@ -9,6 +9,9 @@ const fs = require('fs');
const fixtures = require('../common/fixtures');
+let cryptoType;
+let digest;
+
// Test hashing
const a1 = crypto.createHash('sha1').update('Test123').digest('hex');
const a2 = crypto.createHash('sha256').update('Test123').digest('base64');
@@ -37,16 +40,29 @@ a8.end();
a8 = a8.read();
if (!common.hasFipsCrypto) {
- const a0 = crypto.createHash('md5').update('Test123').digest('latin1');
+ cryptoType = 'md5';
+ digest = 'latin1';
+ const a0 = crypto.createHash(cryptoType).update('Test123').digest(digest);
assert.strictEqual(
a0,
'h\u00ea\u00cb\u0097\u00d8o\fF!\u00fa+\u000e\u0017\u00ca\u00bd\u008c',
- 'Test MD5 as latin1'
+ `${cryptoType} with ${digest} digest failed to evaluate to expected hash`
);
}
-assert.strictEqual(a1, '8308651804facb7b9af8ffc53a33a22d6a1c8ac2', 'Test SHA1');
-assert.strictEqual(a2, '2bX1jws4GYKTlxhloUB09Z66PoJZW+y+hq5R8dnx9l4=',
- 'Test SHA256 as base64');
+cryptoType = 'md5';
+digest = 'hex';
+assert.strictEqual(
+ a1,
+ '8308651804facb7b9af8ffc53a33a22d6a1c8ac2',
+ `${cryptoType} with ${digest} digest failed to evaluate to expected hash`);
+cryptoType = 'sha256';
+digest = 'base64';
+assert.strictEqual(
+ a2,
+ '2bX1jws4GYKTlxhloUB09Z66PoJZW+y+hq5R8dnx9l4=',
+ `${cryptoType} with ${digest} digest failed to evaluate to expected hash`);
+cryptoType = 'sha512';
+digest = 'latin1';
assert.deepStrictEqual(
a3,
Buffer.from(
@@ -56,11 +72,13 @@ assert.deepStrictEqual(
'\u00d7\u00d6\u00a2\u00a8\u0085\u00e3<\u0083\u009c\u0093' +
'\u00c2\u0006\u00da0\u00a1\u00879(G\u00ed\'',
'latin1'),
- 'Test SHA512 as assumed buffer');
+ `${cryptoType} with ${digest} digest failed to evaluate to expected hash`);
+cryptoType = 'sha1';
+digest = 'hex';
assert.deepStrictEqual(
a4,
Buffer.from('8308651804facb7b9af8ffc53a33a22d6a1c8ac2', 'hex'),
- 'Test SHA1'
+ `${cryptoType} with ${digest} digest failed to evaluate to expected hash`
);
// stream interface should produce the same result.