MCPcopy
hub / github.com/klauspost/compress / testFile

Function testFile

s2/s2_test.go:2037–2087  ·  view source on GitHub ↗
(t *testing.T, i, repeat int)

Source from the content-addressed store, hash-verified

2035}
2036
2037func testFile(t *testing.T, i, repeat int) {
2038 if err := downloadBenchmarkFiles(t, testFiles[i].filename); err != nil {
2039 t.Skipf("failed to download testdata: %s", err)
2040 }
2041
2042 if testing.Short() {
2043 repeat = 0
2044 }
2045 t.Run(fmt.Sprint(i, "-", testFiles[i].label), func(t *testing.T) {
2046 bDir := filepath.FromSlash(*benchdataDir)
2047 data := readFile(t, filepath.Join(bDir, testFiles[i].filename))
2048 if testing.Short() && len(data) > 10000 {
2049 t.SkipNow()
2050 }
2051 oSize := len(data)
2052 for i := 0; i < repeat; i++ {
2053 data = append(data, data[:oSize]...)
2054 }
2055 t.Run("s2", func(t *testing.T) {
2056 testWriterRoundtrip(t, data)
2057 })
2058 t.Run("s2-better", func(t *testing.T) {
2059 testWriterRoundtrip(t, data, WriterBetterCompression())
2060 })
2061 t.Run("s2-best", func(t *testing.T) {
2062 testWriterRoundtrip(t, data, WriterBestCompression())
2063 })
2064 t.Run("s2-uncompressed", func(t *testing.T) {
2065 testWriterRoundtrip(t, data, WriterUncompressed())
2066 })
2067 t.Run("block", func(t *testing.T) {
2068 d := data
2069 testBlockRoundtrip(t, d)
2070 })
2071 t.Run("block-better", func(t *testing.T) {
2072 d := data
2073 testBetterBlockRoundtrip(t, d)
2074 })
2075 t.Run("block-best", func(t *testing.T) {
2076 d := data
2077 testBestBlockRoundtrip(t, d)
2078 })
2079 t.Run("s2-snappy", func(t *testing.T) {
2080 d := data
2081 testSnappyBlockRoundtrip(t, d)
2082 })
2083 t.Run("snappy", func(t *testing.T) {
2084 testSnappyDecode(t, data)
2085 })
2086 })
2087}
2088
2089func TestDataRoundtrips(t *testing.T) {
2090 test := func(t *testing.T, data []byte) {

Callers 1

TestRoundtripsFunction · 0.70

Calls 11

testWriterRoundtripFunction · 0.85
WriterBetterCompressionFunction · 0.85
WriterBestCompressionFunction · 0.85
WriterUncompressedFunction · 0.85
testBlockRoundtripFunction · 0.85
testBetterBlockRoundtripFunction · 0.85
testBestBlockRoundtripFunction · 0.85
testSnappyBlockRoundtripFunction · 0.85
testSnappyDecodeFunction · 0.85
downloadBenchmarkFilesFunction · 0.70
readFileFunction · 0.70

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…