proto: allow text proto map keys to be omitted or order swapped
diff --git a/proto/text_parser_test.go b/proto/text_parser_test.go
index 32c4117..f25d5b0 100644
--- a/proto/text_parser_test.go
+++ b/proto/text_parser_test.go
@@ -508,7 +508,10 @@
const in = `name_mapping:<key:1234 value:"Feist"> name_mapping:<key:1 value:"Beatles">` +
`msg_mapping:<key:-4, value:<f: 2.0>,>` + // separating commas are okay
`msg_mapping<key:-2 value<f: 4.0>>` + // no colon after "value"
- `byte_mapping:<key:true value:"so be it">`
+ `msg_mapping:<value:<f: 5.0>>` + // omitted key
+ `msg_mapping:<key:1>` + // omitted value
+ `byte_mapping:<key:true value:"so be it">` +
+ `byte_mapping:<>` // omitted key and value
want := &MessageWithMap{
NameMapping: map[int32]string{
1: "Beatles",
@@ -517,9 +520,12 @@
MsgMapping: map[int64]*FloatingPoint{
-4: {F: Float64(2.0)},
-2: {F: Float64(4.0)},
+ 0: {F: Float64(5.0)},
+ 1: nil,
},
ByteMapping: map[bool][]byte{
- true: []byte("so be it"),
+ false: nil,
+ true: []byte("so be it"),
},
}
if err := UnmarshalText(in, m); err != nil {