goprotobuf: Fix text formatting of typed nil.
R=adg
CC=golang-dev
https://codereview.appspot.com/7223057
diff --git a/proto/text_test.go b/proto/text_test.go
index 69ae0cc..4904295 100644
--- a/proto/text_test.go
+++ b/proto/text_test.go
@@ -152,6 +152,20 @@
}
}
+func TestMarshalTextNil(t *testing.T) {
+ want := "<nil>"
+ tests := []proto.Message{nil, (*pb.MyMessage)(nil)}
+ for i, test := range tests {
+ buf := new(bytes.Buffer)
+ if err := proto.MarshalText(buf, test); err != nil {
+ t.Fatal(err)
+ }
+ if got := buf.String(); got != want {
+ t.Errorf("%d: got %q want %q", i, got, want)
+ }
+ }
+}
+
func BenchmarkMarshalTextBuffered(b *testing.B) {
buf := new(bytes.Buffer)
m := newTestMessage()