MCPcopy
hub / github.com/grpc/grpc-go / TestUnmarshalJSON_MarshalUnmarshal

Method TestUnmarshalJSON_MarshalUnmarshal

codes/codes_test.go:76–94  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

74}
75
76func (s) TestUnmarshalJSON_MarshalUnmarshal(t *testing.T) {
77 for i := 0; i < _maxCode; i++ {
78 var cUnMarshaled Code
79 c := Code(i)
80
81 cJSON, err := json.Marshal(c)
82 if err != nil {
83 t.Errorf("marshalling %q failed: %v", c, err)
84 }
85
86 if err := json.Unmarshal(cJSON, &cUnMarshaled); err != nil {
87 t.Errorf("unmarshalling code failed: %s", err)
88 }
89
90 if c != cUnMarshaled {
91 t.Errorf("code is %q after marshalling/unmarshalling, expected %q", cUnMarshaled, c)
92 }
93 }
94}
95
96func (s) TestUnmarshalJSON_InvalidIntegerCode(t *testing.T) {
97 const wantErr = "invalid code: 200" // for integer invalid code, expect integer value in error message

Callers

nothing calls this directly

Calls 4

CodeTypeAlias · 0.70
MarshalMethod · 0.65
ErrorfMethod · 0.65
UnmarshalMethod · 0.65

Tested by

no test coverage detected