MCPcopy Index your code
hub / github.com/klauspost/compress / TestEncoder_EncodeAllSilesia

Function TestEncoder_EncodeAllSilesia

zstd/encoder_test.go:764–798  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

762}
763
764func TestEncoder_EncodeAllSilesia(t *testing.T) {
765 if testing.Short() {
766 t.SkipNow()
767 }
768 in, err := os.ReadFile("testdata/silesia.tar")
769 if err != nil {
770 if os.IsNotExist(err) {
771 t.Skip("Missing testdata/silesia.tar")
772 return
773 }
774 t.Fatal(err)
775 }
776
777 var e Encoder
778 start := time.Now()
779 dst := e.EncodeAll(in, nil)
780 t.Log("Fast Encoder len", len(in), "-> zstd len", len(dst))
781 mbpersec := (float64(len(in)) / (1024 * 1024)) / (float64(time.Since(start)) / (float64(time.Second)))
782 t.Logf("Encoded %d bytes with %.2f MB/s", len(in), mbpersec)
783
784 dec, err := NewReader(nil, WithDecoderMaxMemory(220<<20))
785 if err != nil {
786 t.Fatal(err)
787 }
788 defer dec.Close()
789 decoded, err := dec.DecodeAll(dst, nil)
790 if err != nil {
791 t.Error(err, len(decoded))
792 }
793 if !bytes.Equal(decoded, in) {
794 os.WriteFile("testdata/"+t.Name()+"-silesia.tar.got", decoded, os.ModePerm)
795 t.Fatal("Decoded does not match")
796 }
797 t.Log("Encoded content matched")
798}
799
800func TestEncoderReadFrom(t *testing.T) {
801 buffer := bytes.NewBuffer(nil)

Callers

nothing calls this directly

Calls 9

EncodeAllMethod · 0.95
CloseMethod · 0.95
WithDecoderMaxMemoryFunction · 0.85
SkipMethod · 0.80
FatalMethod · 0.80
DecodeAllMethod · 0.80
NewReaderFunction · 0.70
ErrorMethod · 0.45
NameMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…