()
| 54 | var messageWithInt32Extension2 = &pb.MyMessage{Count: Int32(8)} |
| 55 | |
| 56 | func init() { |
| 57 | ext1 := &pb.Ext{Data: String("Kirk")} |
| 58 | ext2 := &pb.Ext{Data: String("Picard")} |
| 59 | |
| 60 | // messageWithExtension1a has ext1, but never marshals it. |
| 61 | if err := SetExtension(messageWithExtension1a, pb.E_Ext_More, ext1); err != nil { |
| 62 | panic("SetExtension on 1a failed: " + err.Error()) |
| 63 | } |
| 64 | |
| 65 | // messageWithExtension1b is the unmarshaled form of messageWithExtension1a. |
| 66 | if err := SetExtension(messageWithExtension1b, pb.E_Ext_More, ext1); err != nil { |
| 67 | panic("SetExtension on 1b failed: " + err.Error()) |
| 68 | } |
| 69 | buf, err := Marshal(messageWithExtension1b) |
| 70 | if err != nil { |
| 71 | panic("Marshal of 1b failed: " + err.Error()) |
| 72 | } |
| 73 | messageWithExtension1b.Reset() |
| 74 | if err := Unmarshal(buf, messageWithExtension1b); err != nil { |
| 75 | panic("Unmarshal of 1b failed: " + err.Error()) |
| 76 | } |
| 77 | |
| 78 | // messageWithExtension2 has ext2. |
| 79 | if err := SetExtension(messageWithExtension2, pb.E_Ext_More, ext2); err != nil { |
| 80 | panic("SetExtension on 2 failed: " + err.Error()) |
| 81 | } |
| 82 | |
| 83 | if err := SetExtension(messageWithInt32Extension1, pb.E_Ext_Number, Int32(23)); err != nil { |
| 84 | panic("SetExtension on Int32-1 failed: " + err.Error()) |
| 85 | } |
| 86 | if err := SetExtension(messageWithInt32Extension1, pb.E_Ext_Number, Int32(24)); err != nil { |
| 87 | panic("SetExtension on Int32-2 failed: " + err.Error()) |
| 88 | } |
| 89 | |
| 90 | // messageWithExtension3{a,b,c} has unregistered extension. |
| 91 | if RegisteredExtensions(messageWithExtension3a)[200] != nil { |
| 92 | panic("expect extension 200 unregistered") |
| 93 | } |
| 94 | bytes := []byte{ |
| 95 | 0xc0, 0x0c, 0x01, // id=200, wiretype=0 (varint), data=1 |
| 96 | } |
| 97 | bytes2 := []byte{ |
| 98 | 0xc0, 0x0c, 0x02, // id=200, wiretype=0 (varint), data=2 |
| 99 | } |
| 100 | SetRawExtension(messageWithExtension3a, 200, bytes) |
| 101 | SetRawExtension(messageWithExtension3b, 200, bytes) |
| 102 | SetRawExtension(messageWithExtension3c, 200, bytes2) |
| 103 | } |
| 104 | |
| 105 | var EqualTests = []struct { |
| 106 | desc string |
nothing calls this directly
no test coverage detected
searching dependent graphs…