(t *testing.T)
| 1253 | } |
| 1254 | |
| 1255 | func TestUnmarshalText(t *testing.T) { |
| 1256 | for _, test := range unmarshalTextTests { |
| 1257 | t.Run("", func(t *testing.T) { |
| 1258 | pb := new(pb2.MyMessage) |
| 1259 | err := proto.UnmarshalText(test.in, pb) |
| 1260 | if test.err == "" { |
| 1261 | // We don't expect failure. |
| 1262 | if err != nil { |
| 1263 | t.Errorf("proto.UnmarshalText error: %v", err) |
| 1264 | } else if !proto.Equal(pb, test.out) { |
| 1265 | t.Errorf("proto.Equal mismatch:\ngot: %v\nwant: %v", pb, test.out) |
| 1266 | } |
| 1267 | } else { |
| 1268 | // We do expect failure. |
| 1269 | if err == nil { |
| 1270 | t.Errorf("proto.UnmarshalText: got nil error, want %v", test.err) |
| 1271 | } else if !strings.Contains(err.Error(), test.err) { |
| 1272 | t.Errorf("proto.UnmarshalText error mismatch:\ngot: %v\nwant: %v", err.Error(), test.err) |
| 1273 | } else if _, ok := err.(*proto.RequiredNotSetError); ok && test.out != nil && !proto.Equal(pb, test.out) { |
| 1274 | t.Errorf("proto.Equal mismatch:\ngot %v\nwant: %v", pb, test.out) |
| 1275 | } |
| 1276 | } |
| 1277 | }) |
| 1278 | } |
| 1279 | } |
| 1280 | |
| 1281 | func TestUnmarshalTextCustomMessage(t *testing.T) { |
| 1282 | msg := &textMessage{} |
nothing calls this directly
no test coverage detected