Lines Matching refs:proto
51 if err := proto.SetExtension(msg, pb.E_Ext_More, ext1); err != nil {
54 exts, err := proto.GetExtensions(msg, []*proto.ExtensionDesc{
73 proto.SetRawExtension(msg, pb.E_Ext_More.Field, []byte{})
74 _, err := proto.GetExtension(msg, pb.E_Ext_More)
81 msg := &pb.MyMessage{Count: proto.Int32(0)}
82 extdesc1 := &proto.ExtensionDesc{
89 ext1 := proto.Bool(true)
90 if err := proto.SetExtension(msg, extdesc1, ext1); err != nil {
93 extdesc2 := &proto.ExtensionDesc{
101 if err := proto.SetExtension(msg, extdesc2, ext2); err != nil {
104 extdesc3 := &proto.ExtensionDesc{
111 ext3 := &pb.Ext{Data: proto.String("foo")}
112 if err := proto.SetExtension(msg, extdesc3, ext3); err != nil {
116 b, err := proto.Marshal(msg)
120 if err := proto.Unmarshal(b, msg); err != nil {
124 var expected proto.Buffer
125 if err := expected.EncodeVarint(uint64((extdesc1.Field << 3) | proto.WireVarint)); err != nil {
132 if b, err := proto.GetExtension(msg, &proto.ExtensionDesc{Field: extdesc1.Field}); err != nil {
138 expected = proto.Buffer{} // reset
139 if err := expected.EncodeVarint(uint64((extdesc2.Field << 3) | proto.WireBytes)); err != nil {
146 if b, err := proto.GetExtension(msg, &proto.ExtensionDesc{Field: extdesc2.Field}); err != nil {
152 expected = proto.Buffer{} // reset
153 if err := expected.EncodeVarint(uint64((extdesc3.Field << 3) | proto.WireBytes)); err != nil {
156 if b, err := proto.Marshal(ext3); err != nil {
162 if b, err := proto.GetExtension(msg, &proto.ExtensionDesc{Field: extdesc3.Field}); err != nil {
170 msg := &pb.MyMessage{Count: proto.Int32(0)}
172 if descs, err := proto.ExtensionDescs(msg); len(descs) != 0 || err != nil {
177 if err := proto.SetExtension(msg, extdesc1, ext1); err != nil {
180 extdesc2 := &proto.ExtensionDesc{
187 ext2 := proto.Bool(false)
188 if err := proto.SetExtension(msg, extdesc2, ext2); err != nil {
192 b, err := proto.Marshal(msg)
196 if err := proto.Unmarshal(b, msg); err != nil {
200 descs, err := proto.ExtensionDescs(msg)
205 wantDescs := []*proto.ExtensionDesc{extdesc1, {Field: extdesc2.Field}}
211 type ExtensionDescSlice []*proto.ExtensionDesc
217 func sortExtDescs(s []*proto.ExtensionDesc) {
223 ext1, err := proto.GetExtension(m, pb.E_Ext_More)
227 ext2, err := proto.GetExtension(m, pb.E_Ext_More)
233 msg := &pb.MyMessage{Count: proto.Int32(4)}
235 if err := proto.SetExtension(msg, pb.E_Ext_More, ext0); err != nil {
241 bb, err := proto.Marshal(msg)
246 err = proto.Unmarshal(bb, msg1)
269 ext *proto.ExtensionDesc // Extension we are testing.
311 val, err := proto.GetExtension(msg, test.ext)
316 if want := proto.ErrMissingExtension; err != want {
374 if err := proto.SetExtension(msg, test.ext, setTo(test)); err != nil {
385 proto.ClearExtension(msg, test.ext)
394 if got, err := proto.GetExtension(nil, pb.E_Ext_More); err == nil {
410 if proto.HasExtension(nilMsg, desc) {
414 if _, err := proto.GetExtensions(nilMsg, []*proto.ExtensionDesc{desc}); !isNotExtendable(err) {
418 if _, err := proto.ExtensionDescs(nilMsg); !isNotExtendable(err) {
422 if err := proto.SetExtension(nilMsg, desc, nil); !isNotExtendable(err) {
426 proto.ClearExtension(nilMsg, desc) // no-op
427 proto.ClearAllExtensions(nilMsg) // no-op
433 Data: proto.String("hi"),
436 Data: proto.String("there"),
438 exists := proto.HasExtension(msg, pb.E_Ext_More)
442 if err := proto.SetExtension(msg, pb.E_Ext_More, ext1); err != nil {
445 if err := proto.SetExtension(msg, pb.E_Ext_More, ext2); err != nil {
448 e, err := proto.GetExtension(msg, pb.E_Ext_More)
458 proto.ClearExtension(msg, pb.E_Ext_More)
459 if _, err = proto.GetExtension(msg, pb.E_Ext_More); err != proto.ErrMissingExtension {
462 if _, err := proto.GetExtension(msg, pb.E_X215); err == nil {
465 if err := proto.SetExtension(msg, pb.E_X215, 12); err == nil {
468 if err := proto.SetExtension(msg, pb.E_Ext_More, 12); err == nil {
475 Count: proto.Int32(1),
477 if err := proto.SetExtension(msg, pb.E_Ext_Text, proto.String("hello")); err != nil {
480 if err := proto.SetExtension(msg, pb.E_Ext_More, (*pb.Ext)(nil)); err == nil {
498 {First: proto.Int32(7)},
499 {Second: proto.Int32(11)},
513 {First: proto.Int32(9)},
514 {Second: proto.Int32(21)},
522 err := proto.SetExtension(msg1, pb.E_RComplex, test.ext)
526 b, err := proto.Marshal(msg1)
533 err = proto.Unmarshal(b, msg2)
537 e, err := proto.GetExtension(msg2, pb.E_RComplex)
549 if !proto.Equal(ext[i], test.ext[i]) {
567 {First: proto.Int32(7)},
568 {Second: proto.Int32(11)},
582 {First: proto.Int32(9)},
583 {Second: proto.Int32(21)},
596 proto.Merge(&want, e)
600 err := proto.SetExtension(msg, pb.E_Complex, e)
604 b, err := proto.Marshal(msg)
613 err := proto.Unmarshal(buf.Bytes(), msg2)
617 e, err := proto.GetExtension(msg2, pb.E_Complex)
625 if !proto.Equal(ext, &want) {
633 desc := &proto.ExtensionDesc{
641 if proto.HasExtension(m, desc) {
642 t.Errorf("proto.HasExtension(%s): got true, want false", proto.MarshalTextString(m))
644 if err := proto.SetExtension(m, desc, proto.Bool(true)); err != nil {
647 if !proto.HasExtension(m, desc) {
648 t.Errorf("proto.HasExtension(%s): got false, want true", proto.MarshalTextString(m))
650 proto.ClearAllExtensions(m)
651 if proto.HasExtension(m, desc) {
652 t.Errorf("proto.HasExtension(%s): got true, want false", proto.MarshalTextString(m))
658 m := &pb.MyMessage{Count: proto.Int32(4)}
659 if err := proto.SetExtension(m, pb.E_Ext_More, ext); err != nil {
663 b, err := proto.Marshal(m)
667 if err := proto.Unmarshal(b, m); err != nil {
680 _, err := proto.Marshal(m)