mirror of
https://github.com/protocolbuffers/protobuf-go.git
synced 2025-03-08 19:14:05 +00:00
proto: add tests for groups in oneofs
Fixes golang/protobuf#1000. Change-Id: I9904f6496240c544b0190a8a1bc3e6d067f98f82 Reviewed-on: https://go-review.googlesource.com/c/protobuf/+/218581 Reviewed-by: Joe Tsai <joetsai@google.com>
This commit is contained in:
parent
01b51b4f96
commit
ee206b9211
File diff suppressed because it is too large
Load Diff
@ -126,6 +126,10 @@ message TestAllTypes {
|
||||
float oneof_float = 117;
|
||||
double oneof_double = 118;
|
||||
NestedEnum oneof_enum = 119;
|
||||
group OneofGroup = 121 {
|
||||
optional int32 a = 1;
|
||||
optional int32 b = 2;
|
||||
}
|
||||
}
|
||||
|
||||
// A oneof with exactly one field.
|
||||
|
@ -820,6 +820,46 @@ var testValidMessages = []testProto{
|
||||
}),
|
||||
}.Marshal(),
|
||||
},
|
||||
{
|
||||
desc: "oneof (group)",
|
||||
decodeTo: makeMessages(protobuild.Message{
|
||||
"oneofgroup": protobuild.Message{
|
||||
"a": 1,
|
||||
},
|
||||
}, &testpb.TestAllTypes{}),
|
||||
wire: pack.Message{
|
||||
pack.Tag{121, pack.StartGroupType},
|
||||
pack.Tag{1, pack.VarintType}, pack.Varint(1),
|
||||
pack.Tag{121, pack.EndGroupType},
|
||||
}.Marshal(),
|
||||
},
|
||||
{
|
||||
desc: "oneof (empty group)",
|
||||
decodeTo: makeMessages(protobuild.Message{
|
||||
"oneofgroup": protobuild.Message{},
|
||||
}, &testpb.TestAllTypes{}),
|
||||
wire: pack.Message{
|
||||
pack.Tag{121, pack.StartGroupType},
|
||||
pack.Tag{121, pack.EndGroupType},
|
||||
}.Marshal(),
|
||||
},
|
||||
{
|
||||
desc: "oneof (merged group)",
|
||||
decodeTo: makeMessages(protobuild.Message{
|
||||
"oneofgroup": protobuild.Message{
|
||||
"a": 1,
|
||||
"b": 2,
|
||||
},
|
||||
}, &testpb.TestAllTypes{}),
|
||||
wire: pack.Message{
|
||||
pack.Tag{121, pack.StartGroupType},
|
||||
pack.Tag{1, pack.VarintType}, pack.Varint(1),
|
||||
pack.Tag{121, pack.EndGroupType},
|
||||
pack.Tag{121, pack.StartGroupType},
|
||||
pack.Tag{2, pack.VarintType}, pack.Varint(2),
|
||||
pack.Tag{121, pack.EndGroupType},
|
||||
}.Marshal(),
|
||||
},
|
||||
{
|
||||
desc: "oneof (string)",
|
||||
decodeTo: makeMessages(protobuild.Message{
|
||||
|
Loading…
x
Reference in New Issue
Block a user