Browse Source

test for encoding length

master
Dominic Tarr 9 years ago
parent
commit
03189c9ca9
  1. 10
      test.js

10
test.js

@ -2,6 +2,7 @@ var varint = require('./index')
, test = require('tape')
, decode = varint.decode
, encode = varint.encode
, encodingLength = varint.encodingLength
test('fuzz test', function(assert) {
var expect
@ -106,6 +107,15 @@ test('fuzz test - big', function(assert) {
assert.end()
})
test('encodingLength', function (assert) {
for(var i = 0; i <= 53; i++) {
var n = Math.pow(2, i)
assert.equal(encode(n).length, encodingLength(n))
}
assert.end()
})
function randint(range) {
return Math.floor(Math.random() * range)

Loading…
Cancel
Save