MCPcopy
hub / github.com/tinylib/msgp / TestReadBytesBytes

Function TestReadBytesBytes

msgp/read_bytes_test.go:481–503  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

479}
480
481func TestReadBytesBytes(t *testing.T) {
482 var buf bytes.Buffer
483 en := NewWriter(&buf)
484
485 tests := [][]byte{{}, []byte("some bytes"), []byte("some more bytes")}
486 var scratch []byte
487
488 for i, v := range tests {
489 buf.Reset()
490 en.WriteBytes(v)
491 en.Flush()
492 out, left, err := ReadBytesBytes(buf.Bytes(), scratch)
493 if err != nil {
494 t.Errorf("test case %d: %s", i, err)
495 }
496 if len(left) != 0 {
497 t.Errorf("expected 0 bytes left; found %d", len(left))
498 }
499 if !bytes.Equal(out, v) {
500 t.Errorf("%q in; %q out", v, out)
501 }
502 }
503}
504
505func TestReadZCBytes(t *testing.T) {
506 var buf bytes.Buffer

Callers

nothing calls this directly

Calls 6

WriteBytesMethod · 0.95
FlushMethod · 0.95
NewWriterFunction · 0.85
ReadBytesBytesFunction · 0.85
ResetMethod · 0.45
EqualMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…