proto: move explicit test as a seed into the fuzz test

fuzztest seeds are executed as part of `go test` so there is no need for
an explicit test and having this as a seed in the fuzztest is sufficient
to get test coverage for this case.

Change-Id: Ia4a2d721e544e1a1ad0ad3ef9aa9d0af6bfe2db8
Reviewed-on: https://go-review.googlesource.com/c/protobuf/+/567755
Auto-Submit: Lasse Folger <lassefolger@google.com>
Reviewed-by: Michael Stapelberg <stapelberg@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
This commit is contained in:
Lasse Folger 2024-02-28 16:05:57 +01:00 committed by Gopher Robot
parent 02e13d2dc7
commit 6bec1ef16e

View File

@ -19,22 +19,6 @@ import (
testfuzzpb "google.golang.org/protobuf/internal/testprotos/editionsfuzztest"
)
func TestUnmarshalInvalidGroupField(t *testing.T) {
in := []byte("\x82\x01\x010")
// Test proto2 proto
proto2Proto := &testfuzzpb.TestAllTypesProto2{}
if err := proto.Unmarshal(in, proto2Proto); err != nil {
t.Error(err)
}
// Test equivalent editions proto
editionsProto := &testfuzzpb.TestAllTypesProto2Editions{}
if err := proto.Unmarshal(in, editionsProto); err != nil {
t.Error(err)
}
}
// compareEquivalentProtos compares equivalent messages m0 and m1, where one is
// typically a Protobuf Editions message and the other isn't. It unmarshals the
// wireBytes into a message of type m0 and one of type m1 and compares the
@ -87,6 +71,7 @@ func compareEquivalentProtos(t *testing.T, wireBytes []byte, m0, m1 proto.Messag
func FuzzProto2EditionConversion(f *testing.F) {
f.Add([]byte("Hello World!"))
f.Add([]byte("\x82\x01\x010"))
f.Fuzz(func(t *testing.T, in []byte) {
compareEquivalentProtos(t, in, (*testfuzzpb.TestAllTypesProto2)(nil), (*testfuzzpb.TestAllTypesProto2Editions)(nil))
})
@ -94,6 +79,7 @@ func FuzzProto2EditionConversion(f *testing.F) {
func FuzzProto3EditionConversion(f *testing.F) {
f.Add([]byte("Hello World!"))
f.Add([]byte("\x82\x01\x010"))
f.Fuzz(func(t *testing.T, in []byte) {
compareEquivalentProtos(t, in, (*testfuzzpb.TestAllTypesProto3)(nil), (*testfuzzpb.TestAllTypesProto3Editions)(nil))
})