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

Function TestCompress4X

huff0/compress_test.go:361–397  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

359}
360
361func TestCompress4X(t *testing.T) {
362 for _, test := range testfiles {
363 t.Run(test.name, func(t *testing.T) {
364 var s Scratch
365 buf0, err := test.fn()
366 if err != nil {
367 t.Fatal(err)
368 }
369 if len(buf0) > BlockSizeMax {
370 buf0 = buf0[:BlockSizeMax]
371 }
372 b, re, err := Compress4X(buf0, &s)
373 if err != test.err4X {
374 t.Errorf("want error %v (%T), got %v (%T)", test.err1X, test.err4X, err, err)
375 }
376 if err != nil {
377 t.Log(test.name, err.Error())
378 return
379 }
380 if b == nil {
381 t.Error("got no output")
382 return
383 }
384 if len(s.OutTable) == 0 {
385 t.Error("got no table definition")
386 }
387 if re {
388 t.Error("claimed to have re-used.")
389 }
390 if len(s.OutData) == 0 {
391 t.Error("got no data output")
392 }
393
394 t.Logf("%s: %d -> %d bytes (%.2f:1) %t (table: %d bytes)", test.name, len(buf0), len(b), float64(len(buf0))/float64(len(b)), re, len(s.OutTable))
395 })
396 }
397}
398
399func TestCompress4XReuse(t *testing.T) {
400 rng := rand.NewSource(0x1337)

Callers

nothing calls this directly

Calls 3

Compress4XFunction · 0.85
FatalMethod · 0.80
ErrorMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…