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

Function TestReadZCBytes

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

Source from the content-addressed store, hash-verified

503}
504
505func TestReadZCBytes(t *testing.T) {
506 var buf bytes.Buffer
507 en := NewWriter(&buf)
508
509 tests := [][]byte{{}, []byte("some bytes"), []byte("some more bytes")}
510
511 for i, v := range tests {
512 buf.Reset()
513 en.WriteBytes(v)
514 en.Flush()
515 out, left, err := ReadBytesZC(buf.Bytes())
516 if err != nil {
517 t.Errorf("test case %d: %s", i, err)
518 }
519 if len(left) != 0 {
520 t.Errorf("expected 0 bytes left; found %d", len(left))
521 }
522 if !bytes.Equal(out, v) {
523 t.Errorf("%q in; %q out", v, out)
524 }
525 }
526}
527
528func TestReadZCString(t *testing.T) {
529 var buf bytes.Buffer

Callers

nothing calls this directly

Calls 6

WriteBytesMethod · 0.95
FlushMethod · 0.95
NewWriterFunction · 0.85
ReadBytesZCFunction · 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…