| 10 | ) |
| 11 | |
| 12 | func TestColdCacheGet(t *testing.T) { |
| 13 | l0 := []byte("hello") |
| 14 | l1 := []byte("world!!") |
| 15 | bucket := newBucket(32, 64) |
| 16 | i0, ok := bucket.put(l0, false) |
| 17 | if !ok { |
| 18 | t.Errorf("got full bucket but it shouldn't be") |
| 19 | } |
| 20 | i1, ok := bucket.put(l1, false) |
| 21 | if !ok { |
| 22 | t.Errorf("got full bucket but it shouldn't be") |
| 23 | } |
| 24 | buf, compressed := bucket.get(i0) |
| 25 | if !bytes.Equal(buf, l0) { |
| 26 | t.Errorf("got bucket.get(%d) = %s, want %s", i0, buf, l0) |
| 27 | } |
| 28 | if compressed { |
| 29 | t.Errorf("got bucket.get(%d) compressed", i0) |
| 30 | } |
| 31 | |
| 32 | buf, compressed = bucket.get(i1) |
| 33 | if !bytes.Equal(buf, l1) { |
| 34 | t.Errorf("got bucket.get(%d) = %s, want %s", i1, buf, l0) |
| 35 | } |
| 36 | if compressed { |
| 37 | t.Errorf("got bucket.get(%d) compressed", i1) |
| 38 | } |
| 39 | } |
| 40 | |
| 41 | func TestColdCacheGet_BadCell(t *testing.T) { |
| 42 | bucket := newBucket(32, 64) |