2019-04-30 18:36:39 +00:00
|
|
|
// Copyright 2019 The Go Authors. All rights reserved.
|
|
|
|
// Use of this source code is governed by a BSD-style
|
|
|
|
// license that can be found in the LICENSE file.
|
|
|
|
|
|
|
|
package prototest_test
|
|
|
|
|
|
|
|
import (
|
|
|
|
"fmt"
|
|
|
|
"testing"
|
|
|
|
|
2019-04-08 20:52:14 +00:00
|
|
|
"google.golang.org/protobuf/internal/flags"
|
|
|
|
"google.golang.org/protobuf/proto"
|
2019-08-02 23:58:08 +00:00
|
|
|
"google.golang.org/protobuf/runtime/protoimpl"
|
2019-04-08 20:52:14 +00:00
|
|
|
"google.golang.org/protobuf/testing/prototest"
|
|
|
|
|
2019-06-14 18:54:07 +00:00
|
|
|
irregularpb "google.golang.org/protobuf/internal/testprotos/irregular"
|
2019-08-02 23:58:08 +00:00
|
|
|
legacypb "google.golang.org/protobuf/internal/testprotos/legacy"
|
2020-01-11 08:25:01 +00:00
|
|
|
legacy1pb "google.golang.org/protobuf/internal/testprotos/legacy/proto2_20160225_2fc053c5"
|
2019-05-14 06:55:40 +00:00
|
|
|
testpb "google.golang.org/protobuf/internal/testprotos/test"
|
2019-04-08 20:52:14 +00:00
|
|
|
_ "google.golang.org/protobuf/internal/testprotos/test/weak1"
|
|
|
|
_ "google.golang.org/protobuf/internal/testprotos/test/weak2"
|
2019-05-14 06:55:40 +00:00
|
|
|
test3pb "google.golang.org/protobuf/internal/testprotos/test3"
|
2024-02-16 13:36:44 +00:00
|
|
|
testeditionspb "google.golang.org/protobuf/internal/testprotos/testeditions"
|
2019-04-30 18:36:39 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
func Test(t *testing.T) {
|
2019-04-08 20:52:14 +00:00
|
|
|
ms := []proto.Message{
|
2019-04-30 18:36:39 +00:00
|
|
|
(*testpb.TestAllTypes)(nil),
|
|
|
|
(*test3pb.TestAllTypes)(nil),
|
2024-02-16 13:36:44 +00:00
|
|
|
(*testeditionspb.TestAllTypes)(nil),
|
2019-04-30 18:36:39 +00:00
|
|
|
(*testpb.TestRequired)(nil),
|
2024-02-22 14:11:57 +00:00
|
|
|
(*testeditionspb.TestRequired)(nil),
|
2019-06-14 18:54:07 +00:00
|
|
|
(*irregularpb.Message)(nil),
|
2019-06-21 15:36:26 +00:00
|
|
|
(*testpb.TestAllExtensions)(nil),
|
2024-02-22 09:30:08 +00:00
|
|
|
(*testeditionspb.TestAllExtensions)(nil),
|
2019-08-02 23:58:08 +00:00
|
|
|
(*legacypb.Legacy)(nil),
|
|
|
|
protoimpl.X.MessageOf((*legacy1pb.Message)(nil)).Interface(),
|
2019-04-08 20:52:14 +00:00
|
|
|
}
|
2019-08-08 20:31:59 +00:00
|
|
|
if flags.ProtoLegacy {
|
2019-04-08 20:52:14 +00:00
|
|
|
ms = append(ms, (*testpb.TestWeak)(nil))
|
|
|
|
}
|
|
|
|
|
|
|
|
for _, m := range ms {
|
2019-04-30 18:36:39 +00:00
|
|
|
t.Run(fmt.Sprintf("%T", m), func(t *testing.T) {
|
2020-02-12 00:43:13 +00:00
|
|
|
prototest.Message{}.Test(t, m.ProtoReflect().Type())
|
2019-04-30 18:36:39 +00:00
|
|
|
})
|
|
|
|
}
|
|
|
|
}
|