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

Function TestSkipRecursion

msgp/read_test.go:169–205  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

167}
168
169func TestSkipRecursion(t *testing.T) {
170 var buf bytes.Buffer
171 dec := NewReader(&buf)
172 enc := NewWriter(&buf)
173 // Test array recursion...
174 for range recursionLimit * 2 {
175 enc.WriteArrayHeader(1)
176 }
177 enc.Flush()
178 b := buf.Bytes()
179 err := dec.Skip()
180 if !errors.Is(err, ErrRecursion) {
181 t.Errorf("unexpected Reader error: %v", err)
182 }
183 _, err = Skip(b)
184 if !errors.Is(err, ErrRecursion) {
185 t.Errorf("unexpected Bytes error: %v", err)
186 }
187 buf.Reset()
188
189 // Test map recursion...
190 for range recursionLimit * 2 {
191 enc.WriteMapHeader(1)
192 // Write a key...
193 enc.WriteString("a")
194 }
195 enc.Flush()
196 b = buf.Bytes()
197 err = dec.Skip()
198 if !errors.Is(err, ErrRecursion) {
199 t.Errorf("unexpected Reader error: %v", err)
200 }
201 _, err = Skip(b)
202 if !errors.Is(err, ErrRecursion) {
203 t.Errorf("unexpected Bytes error: %v", err)
204 }
205}
206
207func TestReadMapHeader(t *testing.T) {
208 tests := []struct {

Callers

nothing calls this directly

Calls 9

WriteArrayHeaderMethod · 0.95
FlushMethod · 0.95
SkipMethod · 0.95
WriteMapHeaderMethod · 0.95
WriteStringMethod · 0.95
NewReaderFunction · 0.85
NewWriterFunction · 0.85
SkipFunction · 0.85
ResetMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…