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

Function TestBufferSubApply

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

Source from the content-addressed store, hash-verified

736}
737
738func TestBufferSubApply(t *testing.T) {
739 var b Buffer
740 defer b.Release()
741 b.appendOwned(NewViewWithData([]byte("0123")))
742 b.appendOwned(NewViewWithData([]byte("45678")))
743 b.appendOwned(NewViewWithData([]byte("9abcd")))
744 data := []byte("0123456789abcd")
745
746 for i := 0; i <= len(data); i++ {
747 for j := i; j <= len(data); j++ {
748 t.Run(fmt.Sprintf("SubApply(%d,%d)", i, j), func(t *testing.T) {
749 var got []byte
750 b.SubApply(i, j-i, func(v *View) {
751 got = append(got, v.AsSlice()...)
752 })
753 if want := data[i:j]; !bytes.Equal(got, want) {
754 t.Errorf("got = %q; want %q", got, want)
755 }
756 })
757 }
758 }
759}
760
761func doSaveAndLoad(t *testing.T, toSave, toLoad *Buffer) {
762 t.Helper()

Callers

nothing calls this directly

Calls 8

ReleaseMethod · 0.95
appendOwnedMethod · 0.95
SubApplyMethod · 0.95
NewViewWithDataFunction · 0.85
RunMethod · 0.65
ErrorfMethod · 0.65
AsSliceMethod · 0.45
EqualMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…