Skip to content

Commit 0b9b1d8

Browse files
committed
Test case for #556
1 parent da07d8b commit 0b9b1d8

File tree

2 files changed

+36
-1
lines changed

2 files changed

+36
-1
lines changed

package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "protobufjs",
3-
"version": "6.1.1",
3+
"version": "6.1.2",
44
"description": "Protocol Buffers for JavaScript (& TypeScript).",
55
"author": "Daniel Wirtz <[email protected]>",
66
"license": "Apache-2.0",

tests/tag.js

+35
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
var tape = require("tape");
2+
3+
var protobuf = require("..");
4+
5+
var root = protobuf.Root.fromJSON({
6+
nested: {
7+
Message: {
8+
fields: {
9+
val: {
10+
type: "uint32",
11+
id: 0x1FFFFFFF
12+
}
13+
}
14+
}
15+
}
16+
});
17+
18+
tape.test("long tags", function(test) {
19+
20+
var Message = root.lookup("Message");
21+
var message = { val: 1 };
22+
var buf = Message.encode(message).finish();
23+
24+
test.equal(buf[0], 0xF8, "should write F8 (78)");
25+
test.equal(buf[1], 0xff, "should write FF (7F)");
26+
test.equal(buf[2], 0xff, "should write FF (7F)");
27+
test.equal(buf[3], 0xff, "should write FF (7F)");
28+
test.equal(buf[4], 0b1111, "should write 1111b");
29+
test.equal(buf[5], 1, "should write value 1");
30+
31+
var comp = Message.decode(buf);
32+
test.deepEqual(comp, message, "should decode back the original data");
33+
34+
test.end();
35+
});

0 commit comments

Comments
 (0)