(t *testing.T)
| 1318 | } |
| 1319 | |
| 1320 | func TestMapParsing(t *testing.T) { |
| 1321 | m := new(pb2.MessageWithMap) |
| 1322 | const in = `name_mapping:<key:1234 value:"Feist"> name_mapping:<key:1 value:"Beatles">` + |
| 1323 | `msg_mapping:<key:-4, value:<f: 2.0>,>` + // separating commas are okay |
| 1324 | `msg_mapping<key:-2 value<f: 4.0>>` + // no colon after "value" |
| 1325 | `msg_mapping:<value:<f: 5.0>>` + // omitted key |
| 1326 | `byte_mapping:<key:true value:"so be it">` + |
| 1327 | `byte_mapping:<>` // omitted key and value |
| 1328 | want := &pb2.MessageWithMap{ |
| 1329 | NameMapping: map[int32]string{ |
| 1330 | 1: "Beatles", |
| 1331 | 1234: "Feist", |
| 1332 | }, |
| 1333 | MsgMapping: map[int64]*pb2.FloatingPoint{ |
| 1334 | -4: {F: proto.Float64(2.0)}, |
| 1335 | -2: {F: proto.Float64(4.0)}, |
| 1336 | 0: {F: proto.Float64(5.0)}, |
| 1337 | }, |
| 1338 | ByteMapping: map[bool][]byte{ |
| 1339 | false: nil, |
| 1340 | true: []byte("so be it"), |
| 1341 | }, |
| 1342 | } |
| 1343 | if err := proto.UnmarshalText(in, m); err != nil { |
| 1344 | t.Fatal(err) |
| 1345 | } |
| 1346 | if !proto.Equal(m, want) { |
| 1347 | t.Errorf("proto.Equal mismatch:\ngot: %v\nwant %v", m, want) |
| 1348 | } |
| 1349 | } |
| 1350 | |
| 1351 | func TestOneofParsing(t *testing.T) { |
| 1352 | const in = `name:"Shrek"` |
nothing calls this directly
no test coverage detected