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

Function TestUnmarshaling

jsonpb/json_test.go:834–852  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

832}
833
834func TestUnmarshaling(t *testing.T) {
835 for _, tt := range unmarshalingTests {
836 // Make a new instance of the type of our wanted object.
837 p := reflect.New(reflect.TypeOf(tt.pb).Elem()).Interface().(proto.Message)
838
839 err := tt.unmarshaler.Unmarshal(strings.NewReader(tt.json), p)
840 if err != nil {
841 t.Errorf("unmarshaling %s: %v", tt.desc, err)
842 continue
843 }
844
845 // For easier diffs, compare text strings of the protos.
846 exp := proto.MarshalTextString(tt.pb)
847 act := proto.MarshalTextString(p)
848 if string(exp) != string(act) {
849 t.Errorf("%s: got [%s] want [%s]", tt.desc, act, exp)
850 }
851 }
852}
853
854func TestUnmarshalNullArray(t *testing.T) {
855 var repeats pb2.Repeats

Callers

nothing calls this directly

Calls 4

MarshalTextStringFunction · 0.92
InterfaceMethod · 0.80
UnmarshalMethod · 0.65
NewMethod · 0.45

Tested by

no test coverage detected