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

Function TestBuffer

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

Source from the content-addressed store, hash-verified

98}
99
100func TestBuffer(t *testing.T) {
101 testCases := []struct {
102 name string
103 input string
104 output string
105 op func(*testing.T, *Buffer)
106 }{
107 // Preconditions.
108 {
109 name: "truncate-check",
110 input: "hello",
111 output: "hello", // Not touched.
112 op: func(t *testing.T, b *Buffer) {
113 defer func() {
114 if r := recover(); r == nil {
115 t.Errorf("Truncate(-1) did not panic")
116 }
117 }()
118 b.Truncate(-1)
119 },
120 },
121 {
122 name: "growto-check",
123 input: "hello",
124 output: "hello", // Not touched.
125 op: func(t *testing.T, b *Buffer) {
126 defer func() {
127 if r := recover(); r == nil {
128 t.Errorf("GrowTo(-1) did not panic")
129 }
130 }()
131 b.GrowTo(-1, false)
132 },
133 },
134 {
135 name: "advance-check",
136 input: "hello",
137 output: "", // Consumed.
138 op: func(t *testing.T, b *Buffer) {
139 defer func() {
140 if r := recover(); r == nil {
141 t.Errorf("advanceRead(Size()+1) did not panic")
142 }
143 }()
144 b.advanceRead(b.Size() + 1)
145 },
146 },
147
148 // Prepend.
149 {
150 name: "prepend",
151 input: "world",
152 output: "hello world",
153 op: func(t *testing.T, b *Buffer) {
154 b.Prepend(NewViewWithData([]byte("hello ")))
155 },
156 },
157 {

Callers

nothing calls this directly

Calls 15

TruncateMethod · 0.95
GrowToMethod · 0.95
advanceReadMethod · 0.95
SizeMethod · 0.95
PrependMethod · 0.95
TrimFrontMethod · 0.95
AppendMethod · 0.95
CloneMethod · 0.95
FlattenMethod · 0.95
MergeMethod · 0.95
ApplyMethod · 0.95
ReadToWriterMethod · 0.95

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…