[Pkg-javascript-commits] [node-sha.js] 15/237: tests for Hash
Bastien Roucariès
rouca at moszumanska.debian.org
Fri May 5 09:02:51 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 417c29858090b53b74d91f91b8f8e830dc0384a8
Author: Dominic Tarr <dominic.tarr at gmail.com>
Date: Thu Dec 26 19:22:24 2013 +0700
tests for Hash
---
test/hash.js | 55 +++++++++++++++++++++++++++++++++++++++++++++++++++++++
1 file changed, 55 insertions(+)
diff --git a/test/hash.js b/test/hash.js
new file mode 100644
index 0000000..00d7d69
--- /dev/null
+++ b/test/hash.js
@@ -0,0 +1,55 @@
+
+var Hash = require('../hash')
+
+var tape = require('tape')
+
+tape('Hash#update 2 in 1 messages', function (t) {
+
+ var h = new Hash(16)
+ var n = 3
+ t.plan(3)
+ h._update = function (block) {
+ console.log(block)
+ t.ok(--n)
+ if(n < 0)
+ throw new Error('expecting only 2 calls to _update')
+ }
+
+ h._final = function (block) {
+ t.equal(--n, 0)
+ console.log('final', block)
+ return new Uint8Array(20)
+ }
+
+ h.update('0123456789abcdef0123456789abcdef')
+ var hash = h.digest()
+ console.log(hash)
+
+ t.end()
+})
+
+tape('Hash#update 2 in 3 messages', function (t) {
+
+ var h = new Hash(16)
+ var n = 3
+ t.plan(3)
+ h._update = function (block) {
+ console.log(block)
+ t.ok(--n)
+ if(n < 0)
+ throw new Error('expecting only 2 calls to _update')
+ }
+
+ h._final = function (block) {
+ t.equal(--n, 0)
+ console.log('final', block)
+ return new Uint8Array(20)
+ }
+
+ h.update('0123').update('456789abc').update('def0123456789abcdef')
+ var hash = h.digest()
+ console.log(hash)
+
+ 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