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

Function TestEncoder_SmallDictFresh

zstd/dict_test.go:288–432  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

286}
287
288func TestEncoder_SmallDictFresh(t *testing.T) {
289 // All files have CRC
290 zr := testCreateZipReader("testdata/dict-tests-small.zip", t)
291 var dicts [][]byte
292 var encs []func() *Encoder
293 var noDictEncs []*Encoder
294 var encNames []string
295
296 for _, tt := range zr.File {
297 if !strings.HasSuffix(tt.Name, ".dict") {
298 continue
299 }
300 func() {
301 r, err := tt.Open()
302 if err != nil {
303 t.Fatal(err)
304 }
305 defer r.Close()
306 in, err := io.ReadAll(r)
307 if err != nil {
308 t.Fatal(err)
309 }
310 dicts = append(dicts, in)
311 for level := SpeedFastest; level < speedLast; level++ {
312 if isRaceTest && level >= SpeedBestCompression {
313 break
314 }
315 level := level
316 encs = append(encs, func() *Encoder {
317 enc, err := NewWriter(nil, WithEncoderConcurrency(1), WithEncoderDict(in), WithEncoderLevel(level), WithWindowSize(1<<17))
318 if err != nil {
319 t.Fatal(err)
320 }
321 return enc
322 })
323 encNames = append(encNames, fmt.Sprint("level-", level.String(), "-dict-", len(dicts)))
324
325 enc, err := NewWriter(nil, WithEncoderConcurrency(1), WithEncoderLevel(level), WithWindowSize(1<<17))
326 if err != nil {
327 t.Fatal(err)
328 }
329 noDictEncs = append(noDictEncs, enc)
330 }
331 }()
332 }
333 dec, err := NewReader(nil, WithDecoderConcurrency(1), WithDecoderDicts(dicts...))
334 if err != nil {
335 t.Fatal(err)
336 return
337 }
338 defer dec.Close()
339 for i, tt := range zr.File {
340 if testing.Short() && i > 100 {
341 break
342 }
343 if !strings.HasSuffix(tt.Name, ".zst") {
344 continue
345 }

Callers

nothing calls this directly

Calls 15

CloseMethod · 0.95
CloseMethod · 0.95
WriteMethod · 0.95
testCreateZipReaderFunction · 0.85
WithEncoderConcurrencyFunction · 0.85
WithEncoderDictFunction · 0.85
WithEncoderLevelFunction · 0.85
WithWindowSizeFunction · 0.85
WithDecoderConcurrencyFunction · 0.85
WithDecoderDictsFunction · 0.85
FatalMethod · 0.80
DecodeAllMethod · 0.80

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…