| 31 | } |
| 32 | |
| 33 | func Test_isInColdCache(t *testing.T) { |
| 34 | tests := []struct { |
| 35 | name string |
| 36 | loc location |
| 37 | want bool |
| 38 | }{ |
| 39 | {"all zeroes", 0b00000000000000000000000000000000, true}, |
| 40 | {"leading one", 0b10000000000000000000000000000000, false}, |
| 41 | {"all ones", 0b11111111111111111111111111111111, false}, |
| 42 | {"all ones but first", 0b01111111111111111111111111111111, true}, |
| 43 | {"all zeros with less specified bits", 0b0, true}, |
| 44 | {"trailing one", 0b1, true}, |
| 45 | } |
| 46 | for _, tt := range tests { |
| 47 | t.Run(tt.name, func(t *testing.T) { |
| 48 | if tt.loc.isCold() != tt.want { |
| 49 | t.Errorf("got loc.isCold() = %t, want %t", tt.loc.isCold(), tt.want) |
| 50 | } |
| 51 | }) |
| 52 | } |
| 53 | } |
| 54 | |
| 55 | func TestBufferCache_PutAndFlushCompressed(t *testing.T) { |
| 56 | flushed := false |