MCPcopy Create free account
hub / github.com/klauspost/compress / TestDecoderRegression

Function TestDecoderRegression

zstd/decoder_test.go:682–817  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

680}
681
682func TestDecoderRegression(t *testing.T) {
683 defer timeout(160 * time.Second)()
684
685 zr := testCreateZipReader("testdata/regression.zip", t)
686 dec, err := NewReader(nil, WithDecoderConcurrency(1), WithDecoderLowmem(true), WithDecoderMaxMemory(1<<20))
687 if err != nil {
688 t.Error(err)
689 return
690 }
691 defer dec.Close()
692 for i, tt := range zr.File {
693 if testing.Short() && i > 10 {
694 continue
695 }
696 t.Run("Reader-"+tt.Name, func(t *testing.T) {
697 r, err := tt.Open()
698 if err != nil {
699 t.Error(err)
700 return
701 }
702 err = dec.Reset(r)
703 if err != nil {
704 t.Error(err)
705 return
706 }
707 got, gotErr := io.ReadAll(dec)
708 t.Log("Received:", len(got), gotErr)
709
710 // Check a fresh instance
711 r, err = tt.Open()
712 if err != nil {
713 t.Error(err)
714 return
715 }
716 decL, err := NewReader(r, WithDecoderConcurrency(1), WithDecoderLowmem(true), WithDecoderMaxMemory(1<<20))
717 if err != nil {
718 t.Error(err)
719 return
720 }
721 defer decL.Close()
722 got2, gotErr2 := io.ReadAll(decL)
723 t.Log("Fresh Reader received:", len(got2), gotErr2)
724 if gotErr != gotErr2 {
725 if gotErr != nil && gotErr2 != nil && gotErr.Error() != gotErr2.Error() {
726 t.Error(gotErr, "!=", gotErr2)
727 }
728 if (gotErr == nil) != (gotErr2 == nil) {
729 t.Error(gotErr, "!=", gotErr2)
730 }
731 }
732 if !bytes.Equal(got2, got) {
733 if gotErr != nil {
734 t.Log("Buffer mismatch without Reset")
735 } else {
736 t.Error("Buffer mismatch without Reset")
737 }
738 }
739 })

Callers

nothing calls this directly

Calls 11

CloseMethod · 0.95
ResetMethod · 0.95
timeoutFunction · 0.85
testCreateZipReaderFunction · 0.85
WithDecoderConcurrencyFunction · 0.85
WithDecoderLowmemFunction · 0.85
WithDecoderMaxMemoryFunction · 0.85
DecodeAllMethod · 0.80
NewReaderFunction · 0.70
ErrorMethod · 0.45
OpenMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…