MCPcopy
hub / github.com/valyala/fasthttp / testZstdCompressSingleCase

Function testZstdCompressSingleCase

zstd_test.go:81–102  ·  view source on GitHub ↗
(s string)

Source from the content-addressed store, hash-verified

79}
80
81func testZstdCompressSingleCase(s string) error {
82 var buf bytes.Buffer
83 zw := acquireStacklessZstdWriter(&buf, CompressZstdDefault)
84 if _, err := zw.Write([]byte(s)); err != nil {
85 return fmt.Errorf("unexpected error: %w. s=%q", err, s)
86 }
87 releaseStacklessZstdWriter(zw, CompressZstdDefault)
88
89 zr, err := acquireZstdReader(&buf)
90 if err != nil {
91 return fmt.Errorf("unexpected error: %w. s=%q", err, s)
92 }
93 body, err := io.ReadAll(zr)
94 if err != nil {
95 return fmt.Errorf("unexpected error: %w. s=%q", err, s)
96 }
97 if string(body) != s {
98 return fmt.Errorf("unexpected string after decompression: %q. Expecting %q", body, s)
99 }
100 releaseZstdReader(zr)
101 return nil
102}

Callers 1

testZstdCompressFunction · 0.85

Calls 5

acquireZstdReaderFunction · 0.85
releaseZstdReaderFunction · 0.85
WriteMethod · 0.65

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…