[Pkg-javascript-commits] [node-ripemd160] 38/71: test/ripemd160: verified array input would work

Bastien Roucariès rouca at moszumanska.debian.org
Thu May 4 10:25:40 UTC 2017


This is an automated email from the git hooks/post-receive script.

rouca pushed a commit to branch master
in repository node-ripemd160.

commit dbea352b68748dde15afa4289bb887dd66ae6742
Author: JP Richardson <jprichardson at gmail.com>
Date:   Wed Jan 14 06:47:00 2015 -0600

    test/ripemd160: verified array input would work
---
 test/fixtures.json     |  9 +++++++++
 test/ripemd160.test.js | 29 ++++++++++++++++++++---------
 2 files changed, 29 insertions(+), 9 deletions(-)

diff --git a/test/fixtures.json b/test/fixtures.json
index 2bf7558..baefe01 100644
--- a/test/fixtures.json
+++ b/test/fixtures.json
@@ -6,6 +6,15 @@
       "result": "108f07b8382412612c048d07d13f814118445acd"
     },
     {
+      "data": "68656c6c6f",
+      "encoding": "hex",
+      "result": "108f07b8382412612c048d07d13f814118445acd"
+    },
+    {
+      "data": [104, 101, 108, 108, 111],
+      "result": "108f07b8382412612c048d07d13f814118445acd"
+    },
+    {
       "data": "",
       "encoding": "utf8",
       "result": "9c1185a5c5e9fc54612808977ee8f548b2258d31"
diff --git a/test/ripemd160.test.js b/test/ripemd160.test.js
index 73353c4..e13fdce 100644
--- a/test/ripemd160.test.js
+++ b/test/ripemd160.test.js
@@ -6,21 +6,32 @@ var fixtures = require('./fixtures')
 
 describe('ripemd160(input)', function() {
   fixtures.valid.forEach(function(f) {
-    if (f.encoding === 'utf8') {
-      describe('> when input (' + f.data + ') encoding is utf8', function() {
-        it('should accept a native string and produce a result', function() {
-          var result = ripemd160(f.data)
+    if (typeof f.data == 'string') {
+      if (f.encoding === 'utf8') {
+        describe('> when input (' + f.data + ') encoding is utf8', function() {
+          it('should accept a native string and produce a result', function() {
+            var result = ripemd160(f.data)
+            assert.equal(result.toString('hex'), (new Buffer(f.result, 'hex')).toString('hex'))
+          })
+        })
+      }
+
+      describe('> when input ('+ (new Buffer(f.data, f.encoding)).toString('hex') + ')is any encoding', function() {
+        it('should accept a buffer and produce a result', function() {
+          var result = ripemd160(new Buffer(f.data, f.encoding))
           assert.equal(result.toString('hex'), (new Buffer(f.result, 'hex')).toString('hex'))
         })
       })
     }
 
-    describe('> when input ('+ (new Buffer(f.data, f.encoding)).toString('hex') + ' )is any encoding', function() {
-      it('should accept a buffer and produce a result', function() {
-        var result = ripemd160(new Buffer(f.data, f.encoding))
-        assert.equal(result.toString('hex'), (new Buffer(f.result, 'hex')).toString('hex'))
+    if (Array.isArray(f.data)) {
+      describe('> when input ('+ (new Buffer(f.data)).toString('hex') + ') is an array', function() {
+        it('should accept a buffer and produce a result', function() {
+          var result = ripemd160(f.data)
+          assert.equal(result.toString('hex'), (new Buffer(f.result, 'hex')).toString('hex'))
+        })
       })
-    })
+    }
   })
 })
 

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-javascript/node-ripemd160.git



More information about the Pkg-javascript-commits mailing list