blob: a95ac0b7e87b2a003f224d7beb3e56b2cb6fc33e [file] [log] [blame]
Damien Neil5ec58b92019-04-30 11:36:39 -07001// Copyright 2019 The Go Authors. All rights reserved.
2// Use of this source code is governed by a BSD-style
3// license that can be found in the LICENSE file.
4
5package prototest_test
6
7import (
8 "fmt"
9 "testing"
10
Joe Tsai3d8e3692019-04-08 13:52:14 -070011 "google.golang.org/protobuf/internal/flags"
Damien Neile89e6242019-05-13 23:55:40 -070012 "google.golang.org/protobuf/proto"
13 "google.golang.org/protobuf/testing/prototest"
Joe Tsai3d8e3692019-04-08 13:52:14 -070014
15 irregularpb "google.golang.org/protobuf/internal/testprotos/irregular"
16 testpb "google.golang.org/protobuf/internal/testprotos/test"
17 _ "google.golang.org/protobuf/internal/testprotos/test/weak1"
18 _ "google.golang.org/protobuf/internal/testprotos/test/weak2"
19 test3pb "google.golang.org/protobuf/internal/testprotos/test3"
Damien Neil5ec58b92019-04-30 11:36:39 -070020)
21
22func Test(t *testing.T) {
Joe Tsai3d8e3692019-04-08 13:52:14 -070023 ms := []proto.Message{
Damien Neil5ec58b92019-04-30 11:36:39 -070024 (*testpb.TestAllTypes)(nil),
25 (*test3pb.TestAllTypes)(nil),
26 (*testpb.TestRequired)(nil),
Damien Neil5b6d0472019-06-14 11:54:07 -070027 (*irregularpb.Message)(nil),
Damien Neild91246e2019-06-21 08:36:26 -070028 (*testpb.TestAllExtensions)(nil),
Joe Tsai3d8e3692019-04-08 13:52:14 -070029 }
30 if flags.Proto1Legacy {
31 ms = append(ms, (*testpb.TestWeak)(nil))
32 }
33
34 for _, m := range ms {
Damien Neil5ec58b92019-04-30 11:36:39 -070035 t.Run(fmt.Sprintf("%T", m), func(t *testing.T) {
Damien Neild91246e2019-06-21 08:36:26 -070036 prototest.TestMessage(t, m, prototest.MessageOptions{})
Damien Neil5ec58b92019-04-30 11:36:39 -070037 })
38 }
39}