MCPcopy
hub / github.com/TarsCloud/TarsGo / TestBuffer_bytes

Function TestBuffer_bytes

tars/protocol/codec/codec_test.go:381–404  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

379}
380
381func TestBuffer_bytes(t *testing.T) {
382 var wants = [][]byte{
383 {1, 3, 4, 5, 6, 100, 250},
384 []byte("hello world"),
385 }
386 var got []byte
387 for _, want := range wants {
388 buf := NewBuffer()
389 err := buf.WriteBytes(want)
390 if err != nil {
391 t.Errorf("Test Write_bytes failed. err:%s\n", err)
392 }
393
394 reader := r(buf)
395 err = reader.ReadBytes(&got, int32(len(want)), true)
396 if err != nil {
397 t.Errorf("Test Read_bytes failed. err:%s\n", err)
398 }
399
400 if !reflect.DeepEqual(want, got) {
401 t.Errorf("Test Write_bytes failed. want:%v, got:%v\n", want, got)
402 }
403 }
404}
405
406func TestBuffer_bool(t *testing.T) {
407 var got bool

Callers

nothing calls this directly

Calls 5

WriteBytesMethod · 0.95
NewBufferFunction · 0.85
rFunction · 0.85
ReadBytesMethod · 0.80
ErrorfMethod · 0.45

Tested by

no test coverage detected