-
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.
Fixed serialization order of sfixed64, fixes #536
- Loading branch information
Showing
7 changed files
with
45 additions
and
7 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
Binary file not shown.
Large diffs are not rendered by default.
Oops, something went wrong.
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,38 @@ | ||
var tape = require("tape"); | ||
|
||
var protobuf = require(".."); | ||
|
||
tape.test("sfixed64 for grpc", function(test) { | ||
|
||
var root = protobuf.Root.fromJSON({ | ||
nested: { | ||
test: { | ||
nested: { | ||
Test: { | ||
fields: { | ||
int_64: { | ||
type: 'sfixed64', | ||
id: 1 | ||
} | ||
} | ||
} | ||
} | ||
} | ||
} | ||
}); | ||
|
||
var Test = root.lookup("test.Test"); | ||
|
||
var buffer = Test.encode({ | ||
int_64: '-9095674951825889465' | ||
}).finish(); | ||
|
||
test.equal(buffer.length, 9, "should encode a total of 9 bytes"); | ||
test.equal(buffer[0], 9, "should encode id 1, wireType 1"); | ||
|
||
var decoded = Test.decode(buffer); | ||
test.ok(decoded.int_64 == '-9095674951825889465', "should decode back the original value"); | ||
|
||
test.end(); | ||
|
||
}); |