MCPcopy Create free account
hub / github.com/bcicen/jstream / TestDecoderReaderFailure

Function TestDecoderReaderFailure

decoder_test.go:210–237  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

208}
209
210func TestDecoderReaderFailure(t *testing.T) {
211 var (
212 failAfter = 900
213 mockData = byte('[')
214 )
215
216 r := newMockReader(failAfter, mockData)
217 decoder := NewDecoder(r, -1)
218
219 for mv := range decoder.Stream() {
220 t.Logf("depth=%d offset=%d len=%d (%v)", mv.Depth, mv.Offset, mv.Length, mv.Value)
221 }
222
223 err := decoder.Err()
224 t.Logf("got error: %s", err)
225 if err == nil {
226 t.Fatalf("missing expected decoder error")
227 }
228
229 derr, ok := err.(DecoderError)
230 if !ok {
231 t.Fatalf("expected error of type DecoderError, got %T", err)
232 }
233
234 if derr.ReaderErr() == nil {
235 t.Fatalf("missing expected underlying reader error")
236 }
237}

Callers

nothing calls this directly

Calls 5

StreamMethod · 0.95
ErrMethod · 0.95
newMockReaderFunction · 0.85
NewDecoderFunction · 0.85
ReaderErrMethod · 0.80

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…