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

Function TestEnumDescriptor

descriptor/descriptor_test.go:16–50  ·  descriptor/descriptor_test.go::TestEnumDescriptor
(t *testing.T)

Source from the content-addressed store, hash-verified

14)
15
16func TestEnumDescriptor(t *testing.T) {
17 tests := []struct {
18 enum protoreflect.Enum
19 idxs []int
20 name string
21 }{{
22 enum: descpb.FieldDescriptorProto_Type(0),
23 idxs: []int{
24 new(descpb.FieldDescriptorProto).ProtoReflect().Descriptor().Index(),
25 new(descpb.FieldDescriptorProto_Type).Descriptor().Index(),
26 },
27 name: "Type",
28 }, {
29 enum: descpb.FieldOptions_CType(0),
30 idxs: []int{
31 new(descpb.FieldOptions).ProtoReflect().Descriptor().Index(),
32 new(descpb.FieldOptions_CType).Descriptor().Index(),
33 },
34 name: "CType",
35 }}
36
37 for _, tt := range tests {
38 e := struct{ protoreflect.Enum }{tt.enum} // v2-only enum
39
40 _, idxs := EnumRawDescriptor(e)
41 if diff := cmp.Diff(tt.idxs, idxs); diff != "" {
42 t.Errorf("path index mismatch (-want +got):\n%v", diff)
43 }
44
45 _, ed := EnumDescriptorProto(e)
46 if ed.GetName() != tt.name {
47 t.Errorf("mismatching enum name: got %v, want %v", ed.GetName(), tt.name)
48 }
49 }
50}
51
52func TestMessageDescriptor(t *testing.T) {
53 tests := []struct {

Callers

nothing calls this directly

Calls 5

EnumRawDescriptorFunction · 0.85
EnumDescriptorProtoFunction · 0.85
ProtoReflectMethod · 0.80
DescriptorMethod · 0.65
GetNameMethod · 0.45

Tested by

no test coverage detected