Permalink
Browse files

Test case for #556

  • Loading branch information...
dcodeIO committed Dec 14, 2016
1 parent da07d8b commit 0b9b1d8505743995c5328daab1f1e124debc63bd
Showing with 36 additions and 1 deletion.
  1. +1 −1 package.json
  2. +35 −0 tests/tag.js
@@ -1,6 +1,6 @@
{
"name": "protobufjs",
"version": "6.1.1",
"version": "6.1.2",
"description": "Protocol Buffers for JavaScript (& TypeScript).",
"author": "Daniel Wirtz <dcode+protobufjs@dcode.io>",
"license": "Apache-2.0",
@@ -0,0 +1,35 @@
var tape = require("tape");
var protobuf = require("..");
var root = protobuf.Root.fromJSON({
nested: {
Message: {
fields: {
val: {
type: "uint32",
id: 0x1FFFFFFF
}
}
}
}
});
tape.test("long tags", function(test) {
var Message = root.lookup("Message");
var message = { val: 1 };
var buf = Message.encode(message).finish();
test.equal(buf[0], 0xF8, "should write F8 (78)");
test.equal(buf[1], 0xff, "should write FF (7F)");
test.equal(buf[2], 0xff, "should write FF (7F)");
test.equal(buf[3], 0xff, "should write FF (7F)");
test.equal(buf[4], 0b1111, "should write 1111b");
test.equal(buf[5], 1, "should write value 1");
var comp = Message.decode(buf);
test.deepEqual(comp, message, "should decode back the original data");
test.end();
});

0 comments on commit 0b9b1d8

Please sign in to comment.