Skip to content

Commit

Permalink
Test case for #556
Browse files Browse the repository at this point in the history
  • Loading branch information
dcodeIO committed Dec 14, 2016
1 parent da07d8b commit 0b9b1d8
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 1 deletion.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "protobufjs",
"version": "6.1.1",
"version": "6.1.2",
"description": "Protocol Buffers for JavaScript (& TypeScript).",
"author": "Daniel Wirtz <[email protected]>",
"license": "Apache-2.0",
Expand Down
35 changes: 35 additions & 0 deletions tests/tag.js
Original file line number Diff line number Diff line change
@@ -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.