xref: /aosp_15_r20/external/golang-protobuf/testing/protocmp/xform_test.go (revision 1c12ee1efe575feb122dbf939ff15148a3b3e8f2)
1*1c12ee1eSDan Willemsen// Copyright 2019 The Go Authors. All rights reserved.
2*1c12ee1eSDan Willemsen// Use of this source code is governed by a BSD-style
3*1c12ee1eSDan Willemsen// license that can be found in the LICENSE file.
4*1c12ee1eSDan Willemsen
5*1c12ee1eSDan Willemsenpackage protocmp
6*1c12ee1eSDan Willemsen
7*1c12ee1eSDan Willemsenimport (
8*1c12ee1eSDan Willemsen	"testing"
9*1c12ee1eSDan Willemsen
10*1c12ee1eSDan Willemsen	"github.com/google/go-cmp/cmp"
11*1c12ee1eSDan Willemsen
12*1c12ee1eSDan Willemsen	"google.golang.org/protobuf/internal/detrand"
13*1c12ee1eSDan Willemsen	"google.golang.org/protobuf/proto"
14*1c12ee1eSDan Willemsen	"google.golang.org/protobuf/reflect/protoreflect"
15*1c12ee1eSDan Willemsen	"google.golang.org/protobuf/testing/protopack"
16*1c12ee1eSDan Willemsen
17*1c12ee1eSDan Willemsen	testpb "google.golang.org/protobuf/internal/testprotos/test"
18*1c12ee1eSDan Willemsen)
19*1c12ee1eSDan Willemsen
20*1c12ee1eSDan Willemsenfunc init() {
21*1c12ee1eSDan Willemsen	detrand.Disable()
22*1c12ee1eSDan Willemsen}
23*1c12ee1eSDan Willemsen
24*1c12ee1eSDan Willemsenfunc TestTransform(t *testing.T) {
25*1c12ee1eSDan Willemsen	tests := []struct {
26*1c12ee1eSDan Willemsen		in   proto.Message
27*1c12ee1eSDan Willemsen		want Message
28*1c12ee1eSDan Willemsen	}{{
29*1c12ee1eSDan Willemsen		in: &testpb.TestAllTypes{
30*1c12ee1eSDan Willemsen			OptionalBool:          proto.Bool(false),
31*1c12ee1eSDan Willemsen			OptionalInt32:         proto.Int32(-32),
32*1c12ee1eSDan Willemsen			OptionalInt64:         proto.Int64(-64),
33*1c12ee1eSDan Willemsen			OptionalUint32:        proto.Uint32(32),
34*1c12ee1eSDan Willemsen			OptionalUint64:        proto.Uint64(64),
35*1c12ee1eSDan Willemsen			OptionalFloat:         proto.Float32(32.32),
36*1c12ee1eSDan Willemsen			OptionalDouble:        proto.Float64(64.64),
37*1c12ee1eSDan Willemsen			OptionalString:        proto.String("string"),
38*1c12ee1eSDan Willemsen			OptionalBytes:         []byte("bytes"),
39*1c12ee1eSDan Willemsen			OptionalNestedEnum:    testpb.TestAllTypes_NEG.Enum(),
40*1c12ee1eSDan Willemsen			OptionalNestedMessage: &testpb.TestAllTypes_NestedMessage{A: proto.Int32(5)},
41*1c12ee1eSDan Willemsen		},
42*1c12ee1eSDan Willemsen		want: Message{
43*1c12ee1eSDan Willemsen			messageTypeKey:            messageMetaOf(&testpb.TestAllTypes{}),
44*1c12ee1eSDan Willemsen			"optional_bool":           bool(false),
45*1c12ee1eSDan Willemsen			"optional_int32":          int32(-32),
46*1c12ee1eSDan Willemsen			"optional_int64":          int64(-64),
47*1c12ee1eSDan Willemsen			"optional_uint32":         uint32(32),
48*1c12ee1eSDan Willemsen			"optional_uint64":         uint64(64),
49*1c12ee1eSDan Willemsen			"optional_float":          float32(32.32),
50*1c12ee1eSDan Willemsen			"optional_double":         float64(64.64),
51*1c12ee1eSDan Willemsen			"optional_string":         string("string"),
52*1c12ee1eSDan Willemsen			"optional_bytes":          []byte("bytes"),
53*1c12ee1eSDan Willemsen			"optional_nested_enum":    enumOf(testpb.TestAllTypes_NEG),
54*1c12ee1eSDan Willemsen			"optional_nested_message": Message{messageTypeKey: messageMetaOf(&testpb.TestAllTypes_NestedMessage{}), "a": int32(5)},
55*1c12ee1eSDan Willemsen		},
56*1c12ee1eSDan Willemsen	}, {
57*1c12ee1eSDan Willemsen		in: &testpb.TestAllTypes{
58*1c12ee1eSDan Willemsen			RepeatedBool:   []bool{false, true},
59*1c12ee1eSDan Willemsen			RepeatedInt32:  []int32{32, -32},
60*1c12ee1eSDan Willemsen			RepeatedInt64:  []int64{64, -64},
61*1c12ee1eSDan Willemsen			RepeatedUint32: []uint32{0, 32},
62*1c12ee1eSDan Willemsen			RepeatedUint64: []uint64{0, 64},
63*1c12ee1eSDan Willemsen			RepeatedFloat:  []float32{0, 32.32},
64*1c12ee1eSDan Willemsen			RepeatedDouble: []float64{0, 64.64},
65*1c12ee1eSDan Willemsen			RepeatedString: []string{"s1", "s2"},
66*1c12ee1eSDan Willemsen			RepeatedBytes:  [][]byte{{1}, {2}},
67*1c12ee1eSDan Willemsen			RepeatedNestedEnum: []testpb.TestAllTypes_NestedEnum{
68*1c12ee1eSDan Willemsen				testpb.TestAllTypes_FOO,
69*1c12ee1eSDan Willemsen				testpb.TestAllTypes_BAR,
70*1c12ee1eSDan Willemsen			},
71*1c12ee1eSDan Willemsen			RepeatedNestedMessage: []*testpb.TestAllTypes_NestedMessage{
72*1c12ee1eSDan Willemsen				{A: proto.Int32(5)},
73*1c12ee1eSDan Willemsen				{A: proto.Int32(-5)},
74*1c12ee1eSDan Willemsen			},
75*1c12ee1eSDan Willemsen		},
76*1c12ee1eSDan Willemsen		want: Message{
77*1c12ee1eSDan Willemsen			messageTypeKey:    messageMetaOf(&testpb.TestAllTypes{}),
78*1c12ee1eSDan Willemsen			"repeated_bool":   []bool{false, true},
79*1c12ee1eSDan Willemsen			"repeated_int32":  []int32{32, -32},
80*1c12ee1eSDan Willemsen			"repeated_int64":  []int64{64, -64},
81*1c12ee1eSDan Willemsen			"repeated_uint32": []uint32{0, 32},
82*1c12ee1eSDan Willemsen			"repeated_uint64": []uint64{0, 64},
83*1c12ee1eSDan Willemsen			"repeated_float":  []float32{0, 32.32},
84*1c12ee1eSDan Willemsen			"repeated_double": []float64{0, 64.64},
85*1c12ee1eSDan Willemsen			"repeated_string": []string{"s1", "s2"},
86*1c12ee1eSDan Willemsen			"repeated_bytes":  [][]byte{{1}, {2}},
87*1c12ee1eSDan Willemsen			"repeated_nested_enum": []Enum{
88*1c12ee1eSDan Willemsen				enumOf(testpb.TestAllTypes_FOO),
89*1c12ee1eSDan Willemsen				enumOf(testpb.TestAllTypes_BAR),
90*1c12ee1eSDan Willemsen			},
91*1c12ee1eSDan Willemsen			"repeated_nested_message": []Message{
92*1c12ee1eSDan Willemsen				{messageTypeKey: messageMetaOf(&testpb.TestAllTypes_NestedMessage{}), "a": int32(5)},
93*1c12ee1eSDan Willemsen				{messageTypeKey: messageMetaOf(&testpb.TestAllTypes_NestedMessage{}), "a": int32(-5)},
94*1c12ee1eSDan Willemsen			},
95*1c12ee1eSDan Willemsen		},
96*1c12ee1eSDan Willemsen	}, {
97*1c12ee1eSDan Willemsen		in: &testpb.TestAllTypes{
98*1c12ee1eSDan Willemsen			MapBoolBool:     map[bool]bool{true: false},
99*1c12ee1eSDan Willemsen			MapInt32Int32:   map[int32]int32{-32: 32},
100*1c12ee1eSDan Willemsen			MapInt64Int64:   map[int64]int64{-64: 64},
101*1c12ee1eSDan Willemsen			MapUint32Uint32: map[uint32]uint32{0: 32},
102*1c12ee1eSDan Willemsen			MapUint64Uint64: map[uint64]uint64{0: 64},
103*1c12ee1eSDan Willemsen			MapInt32Float:   map[int32]float32{32: 32.32},
104*1c12ee1eSDan Willemsen			MapInt32Double:  map[int32]float64{64: 64.64},
105*1c12ee1eSDan Willemsen			MapStringString: map[string]string{"k": "v", "empty": ""},
106*1c12ee1eSDan Willemsen			MapStringBytes:  map[string][]byte{"k": []byte("v"), "empty": nil},
107*1c12ee1eSDan Willemsen			MapStringNestedEnum: map[string]testpb.TestAllTypes_NestedEnum{
108*1c12ee1eSDan Willemsen				"k": testpb.TestAllTypes_FOO,
109*1c12ee1eSDan Willemsen			},
110*1c12ee1eSDan Willemsen			MapStringNestedMessage: map[string]*testpb.TestAllTypes_NestedMessage{
111*1c12ee1eSDan Willemsen				"k": {A: proto.Int32(5)},
112*1c12ee1eSDan Willemsen			},
113*1c12ee1eSDan Willemsen		},
114*1c12ee1eSDan Willemsen		want: Message{
115*1c12ee1eSDan Willemsen			messageTypeKey:      messageMetaOf(&testpb.TestAllTypes{}),
116*1c12ee1eSDan Willemsen			"map_bool_bool":     map[bool]bool{true: false},
117*1c12ee1eSDan Willemsen			"map_int32_int32":   map[int32]int32{-32: 32},
118*1c12ee1eSDan Willemsen			"map_int64_int64":   map[int64]int64{-64: 64},
119*1c12ee1eSDan Willemsen			"map_uint32_uint32": map[uint32]uint32{0: 32},
120*1c12ee1eSDan Willemsen			"map_uint64_uint64": map[uint64]uint64{0: 64},
121*1c12ee1eSDan Willemsen			"map_int32_float":   map[int32]float32{32: 32.32},
122*1c12ee1eSDan Willemsen			"map_int32_double":  map[int32]float64{64: 64.64},
123*1c12ee1eSDan Willemsen			"map_string_string": map[string]string{"k": "v", "empty": ""},
124*1c12ee1eSDan Willemsen			"map_string_bytes":  map[string][]byte{"k": []byte("v"), "empty": []byte{}},
125*1c12ee1eSDan Willemsen			"map_string_nested_enum": map[string]Enum{
126*1c12ee1eSDan Willemsen				"k": enumOf(testpb.TestAllTypes_FOO),
127*1c12ee1eSDan Willemsen			},
128*1c12ee1eSDan Willemsen			"map_string_nested_message": map[string]Message{
129*1c12ee1eSDan Willemsen				"k": {messageTypeKey: messageMetaOf(&testpb.TestAllTypes_NestedMessage{}), "a": int32(5)},
130*1c12ee1eSDan Willemsen			},
131*1c12ee1eSDan Willemsen		},
132*1c12ee1eSDan Willemsen	}, {
133*1c12ee1eSDan Willemsen		in: func() proto.Message {
134*1c12ee1eSDan Willemsen			m := &testpb.TestAllExtensions{}
135*1c12ee1eSDan Willemsen			proto.SetExtension(m, testpb.E_OptionalBool, bool(false))
136*1c12ee1eSDan Willemsen			proto.SetExtension(m, testpb.E_OptionalInt32, int32(-32))
137*1c12ee1eSDan Willemsen			proto.SetExtension(m, testpb.E_OptionalInt64, int64(-64))
138*1c12ee1eSDan Willemsen			proto.SetExtension(m, testpb.E_OptionalUint32, uint32(32))
139*1c12ee1eSDan Willemsen			proto.SetExtension(m, testpb.E_OptionalUint64, uint64(64))
140*1c12ee1eSDan Willemsen			proto.SetExtension(m, testpb.E_OptionalFloat, float32(32.32))
141*1c12ee1eSDan Willemsen			proto.SetExtension(m, testpb.E_OptionalDouble, float64(64.64))
142*1c12ee1eSDan Willemsen			proto.SetExtension(m, testpb.E_OptionalString, string("string"))
143*1c12ee1eSDan Willemsen			proto.SetExtension(m, testpb.E_OptionalBytes, []byte("bytes"))
144*1c12ee1eSDan Willemsen			proto.SetExtension(m, testpb.E_OptionalNestedEnum, testpb.TestAllTypes_NEG)
145*1c12ee1eSDan Willemsen			proto.SetExtension(m, testpb.E_OptionalNestedMessage, &testpb.TestAllExtensions_NestedMessage{A: proto.Int32(5)})
146*1c12ee1eSDan Willemsen			return m
147*1c12ee1eSDan Willemsen		}(),
148*1c12ee1eSDan Willemsen		want: Message{
149*1c12ee1eSDan Willemsen			messageTypeKey:                                 messageMetaOf(&testpb.TestAllExtensions{}),
150*1c12ee1eSDan Willemsen			"[goproto.proto.test.optional_bool]":           bool(false),
151*1c12ee1eSDan Willemsen			"[goproto.proto.test.optional_int32]":          int32(-32),
152*1c12ee1eSDan Willemsen			"[goproto.proto.test.optional_int64]":          int64(-64),
153*1c12ee1eSDan Willemsen			"[goproto.proto.test.optional_uint32]":         uint32(32),
154*1c12ee1eSDan Willemsen			"[goproto.proto.test.optional_uint64]":         uint64(64),
155*1c12ee1eSDan Willemsen			"[goproto.proto.test.optional_float]":          float32(32.32),
156*1c12ee1eSDan Willemsen			"[goproto.proto.test.optional_double]":         float64(64.64),
157*1c12ee1eSDan Willemsen			"[goproto.proto.test.optional_string]":         string("string"),
158*1c12ee1eSDan Willemsen			"[goproto.proto.test.optional_bytes]":          []byte("bytes"),
159*1c12ee1eSDan Willemsen			"[goproto.proto.test.optional_nested_enum]":    enumOf(testpb.TestAllTypes_NEG),
160*1c12ee1eSDan Willemsen			"[goproto.proto.test.optional_nested_message]": Message{messageTypeKey: messageMetaOf(&testpb.TestAllExtensions_NestedMessage{}), "a": int32(5)},
161*1c12ee1eSDan Willemsen		},
162*1c12ee1eSDan Willemsen	}, {
163*1c12ee1eSDan Willemsen		in: func() proto.Message {
164*1c12ee1eSDan Willemsen			m := &testpb.TestAllExtensions{}
165*1c12ee1eSDan Willemsen			proto.SetExtension(m, testpb.E_RepeatedBool, []bool{false, true})
166*1c12ee1eSDan Willemsen			proto.SetExtension(m, testpb.E_RepeatedInt32, []int32{32, -32})
167*1c12ee1eSDan Willemsen			proto.SetExtension(m, testpb.E_RepeatedInt64, []int64{64, -64})
168*1c12ee1eSDan Willemsen			proto.SetExtension(m, testpb.E_RepeatedUint32, []uint32{0, 32})
169*1c12ee1eSDan Willemsen			proto.SetExtension(m, testpb.E_RepeatedUint64, []uint64{0, 64})
170*1c12ee1eSDan Willemsen			proto.SetExtension(m, testpb.E_RepeatedFloat, []float32{0, 32.32})
171*1c12ee1eSDan Willemsen			proto.SetExtension(m, testpb.E_RepeatedDouble, []float64{0, 64.64})
172*1c12ee1eSDan Willemsen			proto.SetExtension(m, testpb.E_RepeatedString, []string{"s1", "s2"})
173*1c12ee1eSDan Willemsen			proto.SetExtension(m, testpb.E_RepeatedBytes, [][]byte{{1}, {2}})
174*1c12ee1eSDan Willemsen			proto.SetExtension(m, testpb.E_RepeatedNestedEnum, []testpb.TestAllTypes_NestedEnum{
175*1c12ee1eSDan Willemsen				testpb.TestAllTypes_FOO,
176*1c12ee1eSDan Willemsen				testpb.TestAllTypes_BAR,
177*1c12ee1eSDan Willemsen			})
178*1c12ee1eSDan Willemsen			proto.SetExtension(m, testpb.E_RepeatedNestedMessage, []*testpb.TestAllExtensions_NestedMessage{
179*1c12ee1eSDan Willemsen				{A: proto.Int32(5)},
180*1c12ee1eSDan Willemsen				{A: proto.Int32(-5)},
181*1c12ee1eSDan Willemsen			})
182*1c12ee1eSDan Willemsen			return m
183*1c12ee1eSDan Willemsen		}(),
184*1c12ee1eSDan Willemsen		want: Message{
185*1c12ee1eSDan Willemsen			messageTypeKey:                         messageMetaOf(&testpb.TestAllExtensions{}),
186*1c12ee1eSDan Willemsen			"[goproto.proto.test.repeated_bool]":   []bool{false, true},
187*1c12ee1eSDan Willemsen			"[goproto.proto.test.repeated_int32]":  []int32{32, -32},
188*1c12ee1eSDan Willemsen			"[goproto.proto.test.repeated_int64]":  []int64{64, -64},
189*1c12ee1eSDan Willemsen			"[goproto.proto.test.repeated_uint32]": []uint32{0, 32},
190*1c12ee1eSDan Willemsen			"[goproto.proto.test.repeated_uint64]": []uint64{0, 64},
191*1c12ee1eSDan Willemsen			"[goproto.proto.test.repeated_float]":  []float32{0, 32.32},
192*1c12ee1eSDan Willemsen			"[goproto.proto.test.repeated_double]": []float64{0, 64.64},
193*1c12ee1eSDan Willemsen			"[goproto.proto.test.repeated_string]": []string{"s1", "s2"},
194*1c12ee1eSDan Willemsen			"[goproto.proto.test.repeated_bytes]":  [][]byte{{1}, {2}},
195*1c12ee1eSDan Willemsen			"[goproto.proto.test.repeated_nested_enum]": []Enum{
196*1c12ee1eSDan Willemsen				enumOf(testpb.TestAllTypes_FOO),
197*1c12ee1eSDan Willemsen				enumOf(testpb.TestAllTypes_BAR),
198*1c12ee1eSDan Willemsen			},
199*1c12ee1eSDan Willemsen			"[goproto.proto.test.repeated_nested_message]": []Message{
200*1c12ee1eSDan Willemsen				{messageTypeKey: messageMetaOf(&testpb.TestAllExtensions_NestedMessage{}), "a": int32(5)},
201*1c12ee1eSDan Willemsen				{messageTypeKey: messageMetaOf(&testpb.TestAllExtensions_NestedMessage{}), "a": int32(-5)},
202*1c12ee1eSDan Willemsen			},
203*1c12ee1eSDan Willemsen		},
204*1c12ee1eSDan Willemsen	}, {
205*1c12ee1eSDan Willemsen		in: func() proto.Message {
206*1c12ee1eSDan Willemsen			m := &testpb.TestAllTypes{}
207*1c12ee1eSDan Willemsen			m.ProtoReflect().SetUnknown(protopack.Message{
208*1c12ee1eSDan Willemsen				protopack.Tag{Number: 50000, Type: protopack.VarintType}, protopack.Uvarint(100),
209*1c12ee1eSDan Willemsen				protopack.Tag{Number: 50001, Type: protopack.Fixed32Type}, protopack.Uint32(200),
210*1c12ee1eSDan Willemsen				protopack.Tag{Number: 50002, Type: protopack.Fixed64Type}, protopack.Uint64(300),
211*1c12ee1eSDan Willemsen				protopack.Tag{Number: 50003, Type: protopack.BytesType}, protopack.String("hello"),
212*1c12ee1eSDan Willemsen				protopack.Message{
213*1c12ee1eSDan Willemsen					protopack.Tag{Number: 50004, Type: protopack.StartGroupType},
214*1c12ee1eSDan Willemsen					protopack.Tag{Number: 1, Type: protopack.VarintType}, protopack.Uvarint(100),
215*1c12ee1eSDan Willemsen					protopack.Tag{Number: 1, Type: protopack.Fixed32Type}, protopack.Uint32(200),
216*1c12ee1eSDan Willemsen					protopack.Tag{Number: 1, Type: protopack.Fixed64Type}, protopack.Uint64(300),
217*1c12ee1eSDan Willemsen					protopack.Tag{Number: 1, Type: protopack.BytesType}, protopack.String("hello"),
218*1c12ee1eSDan Willemsen					protopack.Message{
219*1c12ee1eSDan Willemsen						protopack.Tag{Number: 1, Type: protopack.StartGroupType},
220*1c12ee1eSDan Willemsen						protopack.Tag{Number: 1, Type: protopack.VarintType}, protopack.Uvarint(100),
221*1c12ee1eSDan Willemsen						protopack.Tag{Number: 1, Type: protopack.Fixed32Type}, protopack.Uint32(200),
222*1c12ee1eSDan Willemsen						protopack.Tag{Number: 1, Type: protopack.Fixed64Type}, protopack.Uint64(300),
223*1c12ee1eSDan Willemsen						protopack.Tag{Number: 1, Type: protopack.BytesType}, protopack.String("hello"),
224*1c12ee1eSDan Willemsen						protopack.Tag{Number: 1, Type: protopack.EndGroupType},
225*1c12ee1eSDan Willemsen					},
226*1c12ee1eSDan Willemsen					protopack.Tag{Number: 50004, Type: protopack.EndGroupType},
227*1c12ee1eSDan Willemsen				},
228*1c12ee1eSDan Willemsen			}.Marshal())
229*1c12ee1eSDan Willemsen			return m
230*1c12ee1eSDan Willemsen		}(),
231*1c12ee1eSDan Willemsen		want: Message{
232*1c12ee1eSDan Willemsen			messageTypeKey: messageMetaOf(&testpb.TestAllTypes{}),
233*1c12ee1eSDan Willemsen			"50000":        protoreflect.RawFields(protopack.Message{protopack.Tag{Number: 50000, Type: protopack.VarintType}, protopack.Uvarint(100)}.Marshal()),
234*1c12ee1eSDan Willemsen			"50001":        protoreflect.RawFields(protopack.Message{protopack.Tag{Number: 50001, Type: protopack.Fixed32Type}, protopack.Uint32(200)}.Marshal()),
235*1c12ee1eSDan Willemsen			"50002":        protoreflect.RawFields(protopack.Message{protopack.Tag{Number: 50002, Type: protopack.Fixed64Type}, protopack.Uint64(300)}.Marshal()),
236*1c12ee1eSDan Willemsen			"50003":        protoreflect.RawFields(protopack.Message{protopack.Tag{Number: 50003, Type: protopack.BytesType}, protopack.String("hello")}.Marshal()),
237*1c12ee1eSDan Willemsen			"50004": protoreflect.RawFields(protopack.Message{
238*1c12ee1eSDan Willemsen				protopack.Tag{Number: 50004, Type: protopack.StartGroupType},
239*1c12ee1eSDan Willemsen				protopack.Tag{Number: 1, Type: protopack.VarintType}, protopack.Uvarint(100),
240*1c12ee1eSDan Willemsen				protopack.Tag{Number: 1, Type: protopack.Fixed32Type}, protopack.Uint32(200),
241*1c12ee1eSDan Willemsen				protopack.Tag{Number: 1, Type: protopack.Fixed64Type}, protopack.Uint64(300),
242*1c12ee1eSDan Willemsen				protopack.Tag{Number: 1, Type: protopack.BytesType}, protopack.String("hello"),
243*1c12ee1eSDan Willemsen				protopack.Message{
244*1c12ee1eSDan Willemsen					protopack.Tag{Number: 1, Type: protopack.StartGroupType},
245*1c12ee1eSDan Willemsen					protopack.Tag{Number: 1, Type: protopack.VarintType}, protopack.Uvarint(100),
246*1c12ee1eSDan Willemsen					protopack.Tag{Number: 1, Type: protopack.Fixed32Type}, protopack.Uint32(200),
247*1c12ee1eSDan Willemsen					protopack.Tag{Number: 1, Type: protopack.Fixed64Type}, protopack.Uint64(300),
248*1c12ee1eSDan Willemsen					protopack.Tag{Number: 1, Type: protopack.BytesType}, protopack.String("hello"),
249*1c12ee1eSDan Willemsen					protopack.Tag{Number: 1, Type: protopack.EndGroupType},
250*1c12ee1eSDan Willemsen				},
251*1c12ee1eSDan Willemsen				protopack.Tag{Number: 50004, Type: protopack.EndGroupType},
252*1c12ee1eSDan Willemsen			}.Marshal()),
253*1c12ee1eSDan Willemsen		},
254*1c12ee1eSDan Willemsen	}}
255*1c12ee1eSDan Willemsen	for _, tt := range tests {
256*1c12ee1eSDan Willemsen		t.Run("", func(t *testing.T) {
257*1c12ee1eSDan Willemsen			got := transformMessage(tt.in.ProtoReflect())
258*1c12ee1eSDan Willemsen			if diff := cmp.Diff(tt.want, got); diff != "" {
259*1c12ee1eSDan Willemsen				t.Errorf("Transform() mismatch (-want +got):\n%v", diff)
260*1c12ee1eSDan Willemsen			}
261*1c12ee1eSDan Willemsen			if got.Unwrap() != tt.in {
262*1c12ee1eSDan Willemsen				t.Errorf("got.Unwrap() = %p, want %p", got.Unwrap(), tt.in)
263*1c12ee1eSDan Willemsen			}
264*1c12ee1eSDan Willemsen		})
265*1c12ee1eSDan Willemsen	}
266*1c12ee1eSDan Willemsen}
267*1c12ee1eSDan Willemsen
268*1c12ee1eSDan Willemsenfunc enumOf(e protoreflect.Enum) Enum {
269*1c12ee1eSDan Willemsen	return Enum{e.Number(), e.Descriptor()}
270*1c12ee1eSDan Willemsen}
271*1c12ee1eSDan Willemsen
272*1c12ee1eSDan Willemsenfunc messageMetaOf(m protoreflect.ProtoMessage) messageMeta {
273*1c12ee1eSDan Willemsen	return messageMeta{m: m, md: m.ProtoReflect().Descriptor()}
274*1c12ee1eSDan Willemsen}
275