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

Method TestEncode

rpc_util_test.go:257–277  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

255}
256
257func (s) TestEncode(t *testing.T) {
258 for _, test := range []struct {
259 // input
260 msg proto.Message
261 // outputs
262 hdr []byte
263 data []byte
264 err error
265 }{
266 {nil, []byte{0, 0, 0, 0, 0}, []byte{}, nil},
267 } {
268 data, err := encode(getCodec(protoenc.Name), test.msg)
269 if err != test.err || !bytes.Equal(data.Materialize(), test.data) {
270 t.Errorf("encode(_, %v) = %v, %v; want %v, %v", test.msg, data, err, test.data, test.err)
271 continue
272 }
273 if hdr, _ := msgHeader(data, nil, compressionNone); !bytes.Equal(hdr, test.hdr) {
274 t.Errorf("msgHeader(%v, false) = %v; want %v", data, hdr, test.hdr)
275 }
276 }
277}
278
279func (s) TestCompress(t *testing.T) {
280 bestCompressor, err := NewGZIPCompressorWithLevel(gzip.BestCompression)

Callers

nothing calls this directly

Calls 6

encodeFunction · 0.85
getCodecFunction · 0.85
msgHeaderFunction · 0.85
MaterializeMethod · 0.80
EqualMethod · 0.65
ErrorfMethod · 0.65

Tested by

no test coverage detected