-
Notifications
You must be signed in to change notification settings - Fork 1.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
2 changed files
with
36 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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(); | ||
}); |