From 33857437dbb974951a3f39f968670261fa9aa57d Mon Sep 17 00:00:00 2001 From: Wei Lu Date: Fri, 7 Mar 2014 21:54:25 +0800 Subject: [PATCH] add tests for bytes and words conversion --- test/util.js | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) create mode 100644 test/util.js diff --git a/test/util.js b/test/util.js new file mode 100644 index 0000000..f76b5a5 --- /dev/null +++ b/test/util.js @@ -0,0 +1,33 @@ +var util = require('../src/util.js') +var assert = require('assert') + +describe('util', function() { + + describe('byte array and word array conversions', function(){ + var bytes, wordArray; + + beforeEach(function(){ + bytes = [ + 98, 233, 7, 177, 92, 191, 39, 213, 66, 83, + 153, 235, 246, 240, 251, 80, 235, 184, 143, 24 + ] + wordArray = { + words: [1659439025, 1556031445, 1112775147, -151979184, -340226280], + sigBytes: 20 + } + }) + + describe('bytesToWords', function() { + it('works', function() { + assert.deepEqual(util.bytesToWordArray(bytes), wordArray) + }) + }) + + describe('bytesToWords', function() { + it('works', function() { + assert.deepEqual(util.wordArrayToBytes(wordArray), bytes) + }) + }) + }) + +})