carlos / platform Public

Clone
git clone https://amadan.net/carlos/platform

Plain git — no account needed to clone.

Download

Download this file

1package assetcache
2
3import "testing"
4
5func TestDefaultBudget(t *testing.T) {
6 const gib = int64(1) << 30
7 cases := []struct {
8 name string
9 total uint64
10 want int64
11 }{
12 {"20 GiB gives 2 GiB", uint64(20 * gib), 2 * gib},
13 {"60 GiB gives 4 GiB", uint64(60 * gib), 4 * gib},
14 {"40 GiB is exactly the cap", uint64(40 * gib), 4 * gib},
15 {"zero gives zero", 0, 0},
16 }
17 for _, c := range cases {
18 if got := DefaultBudget(c.total); got != c.want {
19 t.Errorf("%s: DefaultBudget(%d) = %d, want %d", c.name, c.total, got, c.want)
20 }
21 }
22}
23