Permalink
Browse files

readme note and a failing test about not enough data for parse mode

  • Loading branch information...
1 parent 266f0f9 commit 49590ecf3c802e618c51f6f1d82e07044fa4fff4 @substack committed Feb 7, 2011
Showing with 17 additions and 0 deletions.
  1. +4 −0 README.markdown
  2. +13 −0 test/binary.js
View
@@ -57,6 +57,10 @@ Parse a static buffer in one pass. Returns a chainable interface with the
methods below plus a `vars` field to get at the variable stash as the last item
in a chain.
+In parse mode, methods will set their keys to `null` if the buffer isn't big
+enough except `buffer()` and `scan()` which read up up to the end of the buffer
+and stop.
+
Binary.stream(emitter, eventName='data')
----------------------------------------
View
@@ -596,3 +596,16 @@ exports.notEnoughParse = function () {
assert.ok(vars.c === null);
assert.ok(vars.d === null);
};
+
+exports.notEnoughBuf = function () {
+ var vars = Binary(new Buffer([1,2,3,4]))
+ .word8('a')
+ .buffer('b', 10)
+ .word8('c')
+ .vars
+ ;
+
+ assert.eql(vars.a, 1);
+ assert.eql(vars.b, new Buffer([2,3,4]));
+ assert.ok(vars.c === null);
+};

0 comments on commit 49590ec

Please sign in to comment.