...
1
2
3
4
5 package prototest_test
6
7 import (
8 "fmt"
9 "testing"
10
11 "google.golang.org/protobuf/internal/flags"
12 "google.golang.org/protobuf/proto"
13 "google.golang.org/protobuf/runtime/protoimpl"
14 "google.golang.org/protobuf/testing/prototest"
15
16 irregularpb "google.golang.org/protobuf/internal/testprotos/irregular"
17 legacypb "google.golang.org/protobuf/internal/testprotos/legacy"
18 legacy1pb "google.golang.org/protobuf/internal/testprotos/legacy/proto2_20160225_2fc053c5"
19 testpb "google.golang.org/protobuf/internal/testprotos/test"
20 _ "google.golang.org/protobuf/internal/testprotos/test/weak1"
21 _ "google.golang.org/protobuf/internal/testprotos/test/weak2"
22 test3pb "google.golang.org/protobuf/internal/testprotos/test3"
23 testeditionspb "google.golang.org/protobuf/internal/testprotos/testeditions"
24 )
25
26 func Test(t *testing.T) {
27 ms := []proto.Message{
28 (*testpb.TestAllTypes)(nil),
29 (*test3pb.TestAllTypes)(nil),
30 (*testeditionspb.TestAllTypes)(nil),
31 (*testpb.TestRequired)(nil),
32 (*testeditionspb.TestRequired)(nil),
33 (*irregularpb.Message)(nil),
34 (*testpb.TestAllExtensions)(nil),
35 (*testeditionspb.TestAllExtensions)(nil),
36 (*legacypb.Legacy)(nil),
37 protoimpl.X.MessageOf((*legacy1pb.Message)(nil)).Interface(),
38 }
39 if flags.ProtoLegacy {
40 ms = append(ms, (*testpb.TestWeak)(nil))
41 }
42
43 for _, m := range ms {
44 t.Run(fmt.Sprintf("%T", m), func(t *testing.T) {
45 prototest.Message{}.Test(t, m.ProtoReflect().Type())
46 })
47 }
48 }
49
View as plain text