Files
kopia/internal/bufcache/bufcache_test.go
Jarek Kowalski e80f5536c3 performance: plumbed through output buffer to encryption and hashing,… (#333)
* performance: plumbed through output buffer to encryption and hashing, so that the caller can pre-allocate/reuse it

* testing: fixed how we do comparison of byte slices to account for possible nils, which can be returned from encryption
2020-03-12 08:27:44 -07:00

32 lines
637 B
Go

package bufcache_test
import (
"testing"
"github.com/kopia/kopia/internal/bufcache"
)
func TestBufCache(t *testing.T) {
cases := []struct {
requestCap int
wantResultCap int
}{
{0, 256},
{1, 256},
{256, 256},
{257, 1024},
{1024, 1024},
{1025, 4096},
{1 << 24, 1 << 24}, // 16 MB
{1 << 25, 1 << 25}, // 32 MB
{1<<25 + 3, 1<<25 + 3}, // 32 MB + 3, not pooled anymore
}
for _, tc := range cases {
result := bufcache.EmptyBytesWithCapacity(tc.requestCap)
if got, want := cap(result), tc.wantResultCap; got != want {
t.Errorf("got invalid capacity of buffer: %v, want %v", got, want)
}
}
}