[Pkg-javascript-commits] [node-sha.js] 34/237: basic tests for encoding
Bastien Roucariès
rouca at moszumanska.debian.org
Fri May 5 09:02:53 UTC 2017
This is an automated email from the git hooks/post-receive script.
rouca pushed a commit to branch master
in repository node-sha.js.
commit dece220424b1d2776a88b35f28d46001e13b10d7
Author: Dominic Tarr <dominic.tarr at gmail.com>
Date: Fri Dec 27 14:29:37 2013 +0700
basic tests for encoding
---
test/enc.js | 36 ++++++++++++++++++++++++++++++++++++
1 file changed, 36 insertions(+)
diff --git a/test/enc.js b/test/enc.js
new file mode 100644
index 0000000..ab4e261
--- /dev/null
+++ b/test/enc.js
@@ -0,0 +1,36 @@
+var Sha1 = require('../')
+var tape = require('tape')
+var toString = require('../util').toString
+var toBuffer = require('bops/typedarray/from')
+
+var EMPTY = new Uint8Array([
+ 218, 57, 163, 238, 94, 107, 75, 13,
+ 50, 85, 191, 239, 149, 96, 24, 144,
+ 175, 216, 7, 9
+ ])
+
+tape('all the output encodings work', function (t) {
+ var hex = new Sha1().update('', 'ascii').digest('hex')
+ var buffer = new Sha1().update('', 'ascii').digest()
+ var base64 = new Sha1().update('', 'ascii').digest('base64')
+ t.equal(base64, '2jmj7l5rSw0yVb/vlWAYkK/YBwk=')
+ t.equal(hex, 'da39a3ee5e6b4b0d3255bfef95601890afd80709')
+ t.deepEqual(buffer, EMPTY)
+ t.end()
+})
+
+tape('base64', function (t) {
+ t.deepEqual(toBuffer(toString(EMPTY, 'base64'), 'base64'), EMPTY)
+ t.end()
+})
+
+tape('all input encodings work', function (t) {
+ var hex = new Sha1().update(toString(EMPTY, 'hex'), 'hex').digest('hex')
+ var base64 = new Sha1().update(toString(EMPTY, 'base64'), 'base64').digest('hex')
+ var buffer = new Sha1().update(EMPTY).digest('hex')
+ console.log(hex, base64, buffer)
+ t.equal(hex, base64)
+ t.equal(hex, buffer)
+ t.end()
+})
+
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-javascript/node-sha.js.git
More information about the Pkg-javascript-commits
mailing list