[Pkg-javascript-commits] [node-ripemd160] 35/71: test/ripemd160: uses test fixtures now

Bastien Roucariès rouca at moszumanska.debian.org
Thu May 4 10:25:39 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 09f08d1f9518ad074aface0d2e6ad72e939c9bbc
Author: JP Richardson <jprichardson at gmail.com>
Date:   Wed Jan 14 06:28:37 2015 -0600

    test/ripemd160: uses test fixtures now
---
 test/ripemd160.test.js | 31 +++++++++++++++++++------------
 1 file changed, 19 insertions(+), 12 deletions(-)

diff --git a/test/ripemd160.test.js b/test/ripemd160.test.js
index 806ff75..73353c4 100644
--- a/test/ripemd160.test.js
+++ b/test/ripemd160.test.js
@@ -1,18 +1,25 @@
 var assert = require('assert')
-var ripemd160 = require('../lib/ripemd160')
+var ripemd160 = require('../')
 
-describe('+ ripemd160(input)', function() {
-  describe('> when input is a string', function() {
-    it('should compute the ripemd160 hash', function() {
-      var input = "hello";
-      assert.equal(ripemd160(input).toString('hex'), "108f07b8382412612c048d07d13f814118445acd")
-    })
-  })
+// from http://homes.esat.kuleuven.be/~bosselae/ripemd160.html
+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)
+          assert.equal(result.toString('hex'), (new Buffer(f.result, 'hex')).toString('hex'))
+        })
+      })
+    }
 
-  describe('> when input is a buffer', function() {
-    it('should compute the ripemd160 hash', function() {
-      var input = new Buffer("hello");
-      assert.equal(ripemd160(input).toString('hex'), "108f07b8382412612c048d07d13f814118445acd")
+    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'))
+      })
     })
   })
 })

-- 
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