MCPcopy
hub / github.com/golang/protobuf / TestGetExtensionsWithMissingExtensions

Function TestGetExtensionsWithMissingExtensions

proto/extensions_test.go:21–40  ·  proto/extensions_test.go::TestGetExtensionsWithMissingExtensions
(t *testing.T)

Source from the content-addressed store, hash-verified

19)
20
21func TestGetExtensionsWithMissingExtensions(t *testing.T) {
22 msg := &pb2.MyMessage{}
23 ext1 := &pb2.Ext{}
24 if err := proto.SetExtension(msg, pb2.E_Ext_More, ext1); err != nil {
25 t.Fatalf("Could not set ext1: %s", err)
26 }
27 exts, err := proto.GetExtensions(msg, []*proto.ExtensionDesc{
28 pb2.E_Ext_More,
29 pb2.E_Ext_Text,
30 })
31 if err != nil {
32 t.Fatalf("GetExtensions() failed: %s", err)
33 }
34 if exts[0] != ext1 {
35 t.Errorf("ext1 not in returned extensions: %T %v", exts[0], exts[0])
36 }
37 if exts[1] != nil {
38 t.Errorf("ext2 in returned extensions: %T %v", exts[1], exts[1])
39 }
40}
41
42func TestGetExtensionForIncompleteDesc(t *testing.T) {
43 msg := &pb2.MyMessage{Count: proto.Int32(0)}

Callers

nothing calls this directly

Calls 2

SetExtensionFunction · 0.92
GetExtensionsFunction · 0.92

Tested by

no test coverage detected