MCPcopy Index your code
hub / github.com/google/gvisor / TestRead

Function TestRead

pkg/buffer/buffer_test.go:653–676  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

651}
652
653func TestRead(t *testing.T) {
654 readStrings := []string{"abcdef", "123456", "ghijkl"}
655 totalSize := len(readStrings) * len(readStrings[0])
656 for readSz := 0; readSz < totalSize+1; readSz++ {
657 b := Buffer{}
658 for _, s := range readStrings {
659 v := NewViewWithData([]byte(s))
660 b.appendOwned(v)
661 }
662 orig := b.Clone()
663 orig.Truncate(int64(readSz))
664 p := make([]byte, readSz)
665 _, err := b.read(p)
666 if err != nil {
667 t.Fatalf("Read([]byte(%d)) failed: %v", readSz, err)
668 }
669 if !bytes.Equal(p, orig.Flatten()) {
670 t.Errorf("Read([]byte(%d)) failed, want p=%v, got %v", readSz, orig.Flatten(), p)
671 }
672 if int(b.Size()) != totalSize-readSz {
673 t.Errorf("Read([]byte(%d)) failed, want b.Size()=%v, got %v", readSz, totalSize-readSz, b.Size())
674 }
675 }
676}
677
678func TestReadByte(t *testing.T) {
679 readString := "abcdef123456ghijkl"

Callers

nothing calls this directly

Calls 10

appendOwnedMethod · 0.95
CloneMethod · 0.95
readMethod · 0.95
SizeMethod · 0.95
NewViewWithDataFunction · 0.85
FlattenMethod · 0.80
TruncateMethod · 0.65
FatalfMethod · 0.65
ErrorfMethod · 0.65
EqualMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…