2014-03-31 05:47:47 +02:00
|
|
|
var assert = require('assert')
|
2014-05-13 09:55:53 +02:00
|
|
|
var convert = require('../src/convert')
|
2013-02-17 06:39:15 +01:00
|
|
|
|
2014-06-04 07:16:19 +02:00
|
|
|
var fixtures = require('./fixtures/convert')
|
2014-03-31 05:47:47 +02:00
|
|
|
|
2014-06-04 07:16:19 +02:00
|
|
|
describe('convert', function() {
|
|
|
|
describe('bufferToWordArray', function() {
|
|
|
|
fixtures.valid.forEach(function(f) {
|
|
|
|
it('converts ' + f.hex + ' correctly', function() {
|
|
|
|
var buffer = new Buffer(f.hex, 'hex')
|
|
|
|
var result = convert.bufferToWordArray(buffer)
|
2014-03-25 19:03:27 +01:00
|
|
|
|
2014-06-04 07:16:19 +02:00
|
|
|
assert.deepEqual(result, f.wordArray)
|
2014-03-25 19:03:27 +01:00
|
|
|
})
|
|
|
|
})
|
2014-06-04 07:16:19 +02:00
|
|
|
})
|
|
|
|
|
|
|
|
describe('wordArrayToBuffer', function() {
|
|
|
|
fixtures.valid.forEach(function(f) {
|
|
|
|
it('converts to ' + f.hex + ' correctly', function() {
|
|
|
|
var resultHex = convert.wordArrayToBuffer(f.wordArray).toString('hex')
|
2014-03-22 07:37:09 +01:00
|
|
|
|
2014-06-04 07:16:19 +02:00
|
|
|
assert.deepEqual(resultHex, f.hex)
|
2014-03-26 08:30:17 +01:00
|
|
|
})
|
|
|
|
})
|
2014-03-31 05:47:47 +02:00
|
|
|
})
|
2014-01-11 07:57:43 +01:00
|
|
|
})
|