[Pkg-javascript-commits] [node-sha.js] 07/237: test incremental update

Bastien Roucariès rouca at moszumanska.debian.org
Fri May 5 09:02:50 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 d11e6f69f4be8d2d1c89f8492d4de2cf2b42027b
Author: Dominic Tarr <dominic.tarr at gmail.com>
Date:   Wed Dec 25 23:17:14 2013 +0700

    test incremental update
---
 test/test.js | 45 ++++++++++++++++++++++++++++++++++++++++++++-
 1 file changed, 44 insertions(+), 1 deletion(-)

diff --git a/test/test.js b/test/test.js
index 2f509a7..7e80b93 100644
--- a/test/test.js
+++ b/test/test.js
@@ -21,7 +21,8 @@ var inputs = [
  ['123456789abcdef123456789abcdef123456789abcdef123456789abc', 'ascii'],
  ['123456789abcdef123456789abcdef123456789abcdef123456789ab', 'ascii'],
  ['0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcde', 'ascii'],
- ['0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef', 'ascii']
+ ['0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef', 'ascii'],
+ ['foobarbaz', 'ascii']
 ]
 
 tape("hash is the same as node's crypto", function (t) {
@@ -37,3 +38,45 @@ tape("hash is the same as node's crypto", function (t) {
   t.end()
 
 })
+
+tape('call update multiple times', function (t) {
+  var n = 1
+  inputs.forEach(function (v) {
+    console.log('HASH', v, v[0].length)
+    var hash = new Sha1()
+    var _hash = crypto.createHash('sha1')
+    for(var i = 0; i < v[0].length; i=(i+1)*2) {
+      var s = v[0].substring(i, (i+1)*2)
+      console.log('UPDATE', s)
+      hash.update(s, v[1])
+      _hash.update(s, v[1])
+    }
+    var a = hash.digest('hex')
+    var e = _hash.digest('hex')
+    console.log(a, e)
+    t.equal(a, e)
+  })
+  t.end()
+})
+
+
+tape('call update twice', function (t) {
+
+  var _hash = crypto.createHash('sha1')
+  var hash  = new Sha1()
+
+  _hash.update('foo')
+  hash.update('foo')
+
+  _hash.update('bar')
+  hash.update('bar')
+
+  _hash.update('baz')
+  hash.update('baz')
+
+  var a = hash.digest('hex')
+  var e = _hash.digest('hex')
+
+  t.equal(a, e)
+  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