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

Function TestReadByte

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

Source from the content-addressed store, hash-verified

676}
677
678func TestReadByte(t *testing.T) {
679 readString := "abcdef123456ghijkl"
680 b := Buffer{}
681 nViews := 3
682 for i := 0; i < nViews; i++ {
683 vLen := len(readString) / nViews
684 v := NewViewWithData([]byte(readString[i*vLen : (i+1)*vLen]))
685 b.appendOwned(v)
686 }
687 for i := 0; i < len(readString); i++ {
688 orig := readString[i]
689 bt, err := b.readByte()
690 if err != nil {
691 t.Fatalf("readByte() failed: %v", err)
692 }
693 if bt != orig {
694 t.Errorf("readByte() failed, want %v, got %v", orig, bt)
695 }
696 if int(b.Size()) != len(readString[i+1:]) {
697 t.Errorf("readByte() failed, want b.Size()=%v, got %v", len(readString[i+1:]), b.Size())
698 }
699 }
700}
701
702func TestPullUpModifiedViews(t *testing.T) {
703 var b Buffer

Callers

nothing calls this directly

Calls 6

appendOwnedMethod · 0.95
readByteMethod · 0.95
SizeMethod · 0.95
NewViewWithDataFunction · 0.85
FatalfMethod · 0.65
ErrorfMethod · 0.65

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…