MCPcopy
hub / github.com/containerd/containerd / testCompressDecompress

Function testCompressDecompress

pkg/archive/compression/compression_test.go:85–101  ·  view source on GitHub ↗
(t testing.TB, size int, compression Compression)

Source from the content-addressed store, hash-verified

83}
84
85func testCompressDecompress(t testing.TB, size int, compression Compression) DecompressReadCloser {
86 orig := generateData(t, size)
87 compressed := testCompress(t, orig, compression)
88 t.Logf("compressed %d bytes to %d bytes (%.2f%%)",
89 len(orig), len(compressed), 100.0*float32(len(compressed))/float32(len(orig)))
90 if compared := bytes.Compare(orig, compressed); (compression == Uncompressed && compared != 0) ||
91 (compression != Uncompressed && compared == 0) {
92 t.Fatal("strange compressed data")
93 }
94
95 decompressed, decompressor := testDecompress(t, compressed)
96 if !bytes.Equal(orig, decompressed) {
97 t.Fatal("strange decompressed data")
98 }
99
100 return decompressor
101}
102
103func TestCompressDecompressGzip(t *testing.T) {
104 oldUnpigzPath := gzipPath

Calls 5

generateDataFunction · 0.85
testCompressFunction · 0.85
testDecompressFunction · 0.85
FatalMethod · 0.80
CompareMethod · 0.65

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…