MCPcopy
hub / github.com/golang/protobuf / TestUnmarshalGolden

Function TestUnmarshalGolden

proto/text_test.go:201–222  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

199}
200
201func TestUnmarshalGolden(t *testing.T) {
202 for _, tt := range goldenMessages {
203 t.Run("", func(t *testing.T) {
204 want := tt.m
205 got := proto.Clone(tt.m)
206 got.Reset()
207 if err := proto.UnmarshalText(tt.t, got); err != nil {
208 t.Errorf("failed to unmarshal\n%s\nerror: %v", tt.t, err)
209 }
210 if !anyEqual(got, want) {
211 t.Errorf("message:\n%s\ngot:\n%s\nwant:\n%s", tt.t, got, want)
212 }
213 got.Reset()
214 if err := proto.UnmarshalText(tt.c, got); err != nil {
215 t.Errorf("failed to unmarshal\n%s\nerror: %v", tt.c, err)
216 }
217 if !anyEqual(got, want) {
218 t.Errorf("message:\n%s\ngot:\n%s\nwant:\n%s", tt.c, got, want)
219 }
220 })
221 }
222}
223
224func TestMarshalUnknownAny(t *testing.T) {
225 m := &pb3.Message{

Callers

nothing calls this directly

Calls 4

CloneFunction · 0.92
UnmarshalTextFunction · 0.92
anyEqualFunction · 0.85
ResetMethod · 0.45

Tested by

no test coverage detected