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

Function dodgifyMsgpString

_generated/errorwrap_test.go:100–112  ·  view source on GitHub ↗

dodgifyMsgpString will wreck the nth string in the msgpack blob so that it raises an error when decoded or unmarshaled.

(bts []byte, idx int)

Source from the content-addressed store, hash-verified

98// dodgifyMsgpString will wreck the nth string in the msgpack blob
99// so that it raises an error when decoded or unmarshaled.
100func dodgifyMsgpString(bts []byte, idx int) []byte {
101 r := msgp.NewReader(bytes.NewReader(bts))
102 out := &dodgifierBuf{Buffer: &bytes.Buffer{}, dodgifyString: idx}
103 for {
104 _, err := r.CopyNext(out)
105 if err == io.EOF {
106 break
107 } else if err != nil {
108 panic(err)
109 }
110 }
111 return out.Bytes()
112}
113
114func TestErrorCtxAsMapUnmarshal(t *testing.T) {
115 bts := marshalErrorCtx(fillErrorCtxAsMap())

Callers 4

TestErrorCtxAsMapDecodeFunction · 0.85

Calls 2

CopyNextMethod · 0.95
NewReaderFunction · 0.92

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…