...
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 )
24
25 func Test(t *testing.T) {
26 ms := []proto.Message{
27 (*testpb.TestAllTypes)(nil),
28 (*test3pb.TestAllTypes)(nil),
29 (*testpb.TestRequired)(nil),
30 (*irregularpb.Message)(nil),
31 (*testpb.TestAllExtensions)(nil),
32 (*legacypb.Legacy)(nil),
33 protoimpl.X.MessageOf((*legacy1pb.Message)(nil)).Interface(),
34 }
35 if flags.ProtoLegacy {
36 ms = append(ms, (*testpb.TestWeak)(nil))
37 }
38
39 for _, m := range ms {
40 t.Run(fmt.Sprintf("%T", m), func(t *testing.T) {
41 prototest.Message{}.Test(t, m.ProtoReflect().Type())
42 })
43 }
44 }
45
View as plain text