func TestPBNodeProtoText(t *testing2.T) { popr := math_rand2.New(math_rand2.NewSource(time2.Now().UnixNano())) p := NewPopulatedPBNode(popr, true) data := code_google_com_p_gogoprotobuf_proto1.MarshalTextString(p) msg := &PBNode{} if err := code_google_com_p_gogoprotobuf_proto1.UnmarshalText(data, msg); err != nil { panic(err) } if err := p.VerboseEqual(msg); err != nil { t.Fatalf("%#v !VerboseProto %#v, since %v", msg, p, err) } if !p.Equal(msg) { t.Fatalf("%#v !Proto %#v", msg, p) } }
func TestRepeatedNilText(t *testing.T) { m := &pb.MessageList{ Message: []*pb.MessageList_Message{ nil, { Name: proto.String("Horse"), }, nil, }, } want := `Message <nil> Message { name: "Horse" } Message <nil> ` if s := proto.MarshalTextString(m); s != want { t.Errorf(" got: %s\nwant: %s", s, want) } }