Browse Source

Add RFC test vectors for convert.bytesToBase64

hk-custom-address
Andreas Brekken 11 years ago
parent
commit
81b44ef269
  1. 19
      test/convert.js

19
test/convert.js

@ -25,4 +25,23 @@ describe('convert', function() {
assert.equal(hex.length, 512);
assert.deepEqual(convert.hexToBytes(hex), bytes);
})
describe('bytesToBase64', function() {
it('passes RFC4648 test vectors', function() {
// Test vectors from:
// http://tools.ietf.org/html/rfc4648#page-12
var b64 = function(s) {
return convert.bytesToBase64(convert.stringToBytes(s))
}
assert.equal(b64(''), '')
assert.equal(b64('f'), 'Zg==')
assert.equal(b64('fo'), 'Zm8=')
assert.equal(b64('foo'), 'Zm9v')
assert.equal(b64('foob'), 'Zm9vYg==')
assert.equal(b64('fooba'), 'Zm9vYmE=')
assert.equal(b64('foobar'), 'Zm9vYmFy')
})
})
})

Loading…
Cancel
Save