(t *testing.T)
| 166 | } |
| 167 | |
| 168 | func TestExtensionDescsWithUnregisteredExtensions(t *testing.T) { |
| 169 | msg := &pb.MyMessage{Count: proto.Int32(0)} |
| 170 | extdesc1 := pb.E_Ext_More |
| 171 | if descs, err := proto.ExtensionDescs(msg); len(descs) != 0 || err != nil { |
| 172 | t.Errorf("proto.ExtensionDescs: got %d descs, error %v; want 0, nil", len(descs), err) |
| 173 | } |
| 174 | |
| 175 | ext1 := &pb.Ext{} |
| 176 | if err := proto.SetExtension(msg, extdesc1, ext1); err != nil { |
| 177 | t.Fatalf("Could not set ext1: %s", err) |
| 178 | } |
| 179 | extdesc2 := &proto.ExtensionDesc{ |
| 180 | ExtendedType: (*pb.MyMessage)(nil), |
| 181 | ExtensionType: (*bool)(nil), |
| 182 | Field: 123456789, |
| 183 | Name: "a.b", |
| 184 | Tag: "varint,123456789,opt", |
| 185 | } |
| 186 | ext2 := proto.Bool(false) |
| 187 | if err := proto.SetExtension(msg, extdesc2, ext2); err != nil { |
| 188 | t.Fatalf("Could not set ext2: %s", err) |
| 189 | } |
| 190 | |
| 191 | b, err := proto.Marshal(msg) |
| 192 | if err != nil { |
| 193 | t.Fatalf("Could not marshal msg: %v", err) |
| 194 | } |
| 195 | if err = proto.Unmarshal(b, msg); err != nil { |
| 196 | t.Fatalf("Could not unmarshal into msg: %v", err) |
| 197 | } |
| 198 | |
| 199 | descs, err := proto.ExtensionDescs(msg) |
| 200 | if err != nil { |
| 201 | t.Fatalf("proto.ExtensionDescs: got error %v", err) |
| 202 | } |
| 203 | sortExtDescs(descs) |
| 204 | wantDescs := []*proto.ExtensionDesc{extdesc1, {Field: extdesc2.Field}} |
| 205 | if !reflect.DeepEqual(descs, wantDescs) { |
| 206 | t.Errorf("proto.ExtensionDescs(msg) sorted extension ids: got %+v, want %+v", descs, wantDescs) |
| 207 | } |
| 208 | } |
| 209 | |
| 210 | type ExtensionDescSlice []*proto.ExtensionDesc |
| 211 |
nothing calls this directly
no test coverage detected
searching dependent graphs…