(t *testing.T)
| 1349 | } |
| 1350 | |
| 1351 | func TestOneofParsing(t *testing.T) { |
| 1352 | const in = `name:"Shrek"` |
| 1353 | m := new(pb2.Communique) |
| 1354 | want := &pb2.Communique{Union: &pb2.Communique_Name{"Shrek"}} |
| 1355 | if err := proto.UnmarshalText(in, m); err != nil { |
| 1356 | t.Fatal(err) |
| 1357 | } |
| 1358 | if !proto.Equal(m, want) { |
| 1359 | t.Errorf("\n got %v\nwant %v", m, want) |
| 1360 | } |
| 1361 | |
| 1362 | const inOverwrite = `name:"Shrek" number:42` |
| 1363 | m = new(pb2.Communique) |
| 1364 | testErr := "line 1.13: field 'number' would overwrite already parsed oneof 'union'" |
| 1365 | if err := proto.UnmarshalText(inOverwrite, m); err == nil { |
| 1366 | t.Errorf("proto.UnmarshalText: got nil error, want %v", testErr) |
| 1367 | } else if err.Error() != testErr { |
| 1368 | t.Errorf("error mismatch:\ngot: %v\nwant: %v", err.Error(), testErr) |
| 1369 | } |
| 1370 | } |
nothing calls this directly
no test coverage detected