(t *testing.T)
| 424 | } |
| 425 | |
| 426 | func TestNilExtension(t *testing.T) { |
| 427 | msg := &pb2.MyMessage{ |
| 428 | Count: proto.Int32(1), |
| 429 | } |
| 430 | if err := proto.SetExtension(msg, pb2.E_Ext_Text, proto.String("hello")); err != nil { |
| 431 | t.Fatal(err) |
| 432 | } |
| 433 | if err := proto.SetExtension(msg, pb2.E_Ext_More, (*pb2.Ext)(nil)); err == nil { |
| 434 | t.Error("expected SetExtension to fail due to a nil extension") |
| 435 | } else if want := fmt.Sprintf("proto: SetExtension called with nil value of type %T", new(pb2.Ext)); err.Error() != want { |
| 436 | t.Errorf("expected error %v, got %v", want, err) |
| 437 | } |
| 438 | // Note: if the behavior of Marshal is ever changed to ignore nil extensions, update |
| 439 | // this test to verify that E_Ext_Text is properly propagated through marshal->unmarshal. |
| 440 | } |
| 441 | |
| 442 | func TestMarshalUnmarshalRepeatedExtension(t *testing.T) { |
| 443 | // Add a repeated extension to the result. |
nothing calls this directly
no test coverage detected