From 03189c9ca91cca33a15516da776a989880df8ba2 Mon Sep 17 00:00:00 2001 From: Dominic Tarr Date: Fri, 9 May 2014 00:35:28 +0200 Subject: [PATCH] test for encoding length --- test.js | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/test.js b/test.js index 2aeb653..868adb1 100644 --- a/test.js +++ b/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)