-
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.
feat: proto3 optional support (#1584)
Co-authored-by: Benjamin E. Coe <bencoe@google.com>
- Loading branch information
1 parent
94e9ef0
commit 6c4d307
Showing
4 changed files
with
71 additions
and
5 deletions.
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
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,26 @@ | ||
var tape = require("tape"); | ||
|
||
var protobuf = require(".."); | ||
|
||
var proto = "syntax = \"proto3\";\ | ||
\ | ||
message Message {\ | ||
int32 regular_int32 = 1;\ | ||
optional int32 optional_int32 = 2;\ | ||
oneof _oneof_int32 {\ | ||
int32 oneof_int32 = 3;\ | ||
}\ | ||
}\ | ||
"; | ||
|
||
tape.test("proto3 optional", function(test) { | ||
var root = protobuf.parse(proto).root; | ||
|
||
var Message = root.lookup("Message"); | ||
test.equal(Message.fields.optionalInt32.optional, true); | ||
test.equal(Message.fields.optionalInt32.options.proto3_optional, true); | ||
test.equal(Message.oneofs._optionalInt32.name, '_optionalInt32'); | ||
test.deepEqual(Message.oneofs._optionalInt32.oneof, ['optionalInt32']); | ||
|
||
test.end(); | ||
}); |