...
1
2
3
4
5 package prototest
6
7 import (
8 "testing"
9
10 "google.golang.org/protobuf/reflect/protoreflect"
11 )
12
13
14 type Enum struct{}
15
16 func (test Enum) Test(t testing.TB, et protoreflect.EnumType) {
17 ed := et.Descriptor()
18 values := ed.Values()
19 for i := 0; i < values.Len(); i++ {
20 evd := values.Get(i)
21 num := evd.Number()
22 e := et.New(num)
23 if e.Descriptor() != ed {
24 t.Errorf("enumType.New(%v).Descriptor() != enumType.Descriptor(), should match", num)
25 }
26 if e.Type() != et {
27 t.Errorf("enumType.New(%v).Type() != enumType, should match", num)
28 }
29 if got, want := e.Number(), num; got != want {
30 t.Errorf("enumType.New(%v).Number() = %v, want %v", num, got, want)
31 }
32 }
33 }
34
View as plain text