diff options
| author | 2025-11-22 08:00:00 +0800 | |
|---|---|---|
| committer | 2025-11-22 08:00:00 +0800 | |
| commit | 10987664c3a92e6d7744f7dcfa1214b8e1063234 (patch) | |
| tree | 9c3bd029d09730e6f24f816e7b8f090d52da3d43 /internal/zlibx/decompress_test.go | |
| parent | flatex: Reformat code (diff) | |
| signature | No signature | |
bufpool: Improve perf by using buckets of different size classes
Diffstat (limited to 'internal/zlibx/decompress_test.go')
| -rw-r--r-- | internal/zlibx/decompress_test.go | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/internal/zlibx/decompress_test.go b/internal/zlibx/decompress_test.go index a4e9c608..3dfc07a5 100644 --- a/internal/zlibx/decompress_test.go +++ b/internal/zlibx/decompress_test.go @@ -82,3 +82,22 @@ func TestDecompressChecksumError(t *testing.T) { t.Fatalf("expected ErrChecksum, got %v", err) } } + +func TestDecompressSizedUsesHint(t *testing.T) { + payload := []byte("tiny payload") + compressed := compressZlib(t, payload, nil) + + const hint = 1 << 20 + out, err := DecompressSized(compressed, hint) + if err != nil { + t.Fatalf("DecompressSized: %v", err) + } + defer out.Release() + + if !bytes.Equal(out.Bytes(), payload) { + t.Fatalf("unexpected payload %q", out.Bytes()) + } + if cap(out.Bytes()) < hint { + t.Fatalf("expected capacity >= %d, got %d", hint, cap(out.Bytes())) + } +} |
