func TestFooProtoText(t *testing2.T) { popr := math_rand2.New(math_rand2.NewSource(time2.Now().UnixNano())) p := NewPopulatedFoo(popr, true) data := dropbox_gogoprotobuf_proto1.MarshalTextString(p) msg := &Foo{} if err := dropbox_gogoprotobuf_proto1.UnmarshalText(data, msg); err != nil { panic(err) } if !p.Equal(msg) { t.Fatalf("%#v !Proto %#v", msg, p) } }
func TestGroups2_GProtoText(t *testing2.T) { popr := math_rand2.New(math_rand2.NewSource(time2.Now().UnixNano())) p := NewPopulatedGroups2_G(popr, true) data := dropbox_gogoprotobuf_proto1.MarshalTextString(p) msg := &Groups2_G{} if err := dropbox_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) } }