MCPcopy
hub / github.com/protocolbuffers/protobuf-go / TestDecodeRequiredFieldChecks

Function TestDecodeRequiredFieldChecks

proto/decode_test.go:57–73  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

55}
56
57func TestDecodeRequiredFieldChecks(t *testing.T) {
58 for _, test := range testValidMessages {
59 if !test.partial {
60 continue
61 }
62 for _, m := range test.decodeTo {
63 t.Run(fmt.Sprintf("%s (%T)", test.desc, m), func(t *testing.T) {
64 opts := test.unmarshalOptions
65 opts.AllowPartial = false
66 got := reflect.New(reflect.TypeOf(m).Elem()).Interface().(proto.Message)
67 if err := proto.Unmarshal(test.wire, got); err == nil {
68 t.Fatalf("Unmarshal succeeded (want error)\nMessage:\n%v", prototext.Format(got))
69 }
70 })
71 }
72 }
73}
74
75func TestDecodeInvalidMessages(t *testing.T) {
76 for _, test := range testInvalidMessages {

Callers

nothing calls this directly

Calls 6

UnmarshalFunction · 0.92
FormatFunction · 0.92
RunMethod · 0.80
ElemMethod · 0.80
InterfaceMethod · 0.65
NewMethod · 0.65

Tested by

no test coverage detected