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

Function TestCompress4XReuseActually

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

Source from the content-addressed store, hash-verified

431}
432
433func TestCompress4XReuseActually(t *testing.T) {
434 rng := rand.NewSource(0x1337)
435 var s Scratch
436 s.Reuse = ReusePolicyAllow
437 for i := range 255 {
438 if testing.Short() && i > 10 {
439 break
440 }
441 t.Run(fmt.Sprint("test-", i), func(t *testing.T) {
442 buf0 := make([]byte, BlockSizeMax)
443 for j := range buf0 {
444 buf0[j] = byte(rng.Int63() & 7)
445 }
446
447 tbSz, dSz, reSz, _ := EstimateSizes(buf0, &s)
448 b, re, err := Compress4X(buf0, &s)
449 if err != nil {
450 t.Fatal(err)
451 }
452 if b == nil {
453 t.Error("got no output")
454 return
455 }
456 if len(s.OutData) == 0 {
457 t.Error("got no data output")
458 }
459 if re && i == 0 {
460 t.Error("Claimed to have re-used on first loop.")
461 }
462 if !re && i > 0 {
463 t.Error("Expected table to be reused")
464 }
465 t.Logf("Estimate: table %d, got %d, data %d, got %d, reuse: %d", tbSz, len(s.OutTable), dSz, len(s.OutData), reSz)
466 t.Logf("%s: %d -> %d bytes (%.2f:1) %t (table: %d bytes)", t.Name(), len(buf0), len(b), float64(len(buf0))/float64(len(b)), re, len(s.OutTable))
467 })
468 }
469}
470func TestCompress1XReuse(t *testing.T) {
471 for _, test := range testfiles {
472 t.Run(test.name, func(t *testing.T) {

Callers

nothing calls this directly

Calls 5

EstimateSizesFunction · 0.85
Compress4XFunction · 0.85
FatalMethod · 0.80
ErrorMethod · 0.45
NameMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…