From 981ac156aca01b1d27870483cd5bfb3b9817b79c Mon Sep 17 00:00:00 2001 From: codedread Date: Fri, 19 Jan 2018 08:35:51 -0800 Subject: [PATCH] Add some tests for BitStreams --- io/bytebuffer.js | 2 +- tests/io-test.html | 103 +++++++++++++++++++++++++++++++++++---------- 2 files changed, 82 insertions(+), 23 deletions(-) diff --git a/io/bytebuffer.js b/io/bytebuffer.js index 444c9e2..71f7401 100644 --- a/io/bytebuffer.js +++ b/io/bytebuffer.js @@ -53,7 +53,7 @@ bitjs.io.ByteBuffer = class { * @param {number} numBytes The number of bytes to write the number into. */ writeNumber(num, numBytes) { - if (numBytes < 1) { + if (numBytes < 1 || !numBytes) { throw 'Trying to write into too few bytes: ' + numBytes; } if (num < 0) { diff --git a/tests/io-test.html b/tests/io-test.html index cfbbba3..a19e824 100644 --- a/tests/io-test.html +++ b/tests/io-test.html @@ -1,7 +1,7 @@ - Unit tests for bitjs.io.ByteStream and bitjs.io.ByteBuffer + Unit tests for bitjs.io.ByteBuffer, bitjs.io.ByteStream, and bitjs.io.BitStream @@ -9,64 +9,123 @@