(t *testing.T)
| 129 | } |
| 130 | |
| 131 | func TestOverwrite(t *testing.T) { |
| 132 | cache := NewCache(1024) |
| 133 | key := []byte("abcd") |
| 134 | var val []byte |
| 135 | cache.Set(key, val, 0) |
| 136 | val = []byte("efgh") |
| 137 | cache.Set(key, val, 0) |
| 138 | val = append(val, 'i') |
| 139 | cache.Set(key, val, 0) |
| 140 | if count := cache.OverwriteCount(); count != 0 { |
| 141 | t.Error("overwrite count is", count, "expected ", 0) |
| 142 | } |
| 143 | res, _ := cache.Get(key) |
| 144 | if string(res) != string(val) { |
| 145 | t.Error(string(res)) |
| 146 | } |
| 147 | val = append(val, 'j') |
| 148 | cache.Set(key, val, 0) |
| 149 | res, _ = cache.Get(key) |
| 150 | if string(res) != string(val) { |
| 151 | t.Error(string(res), "aaa") |
| 152 | } |
| 153 | val = append(val, 'k') |
| 154 | cache.Set(key, val, 0) |
| 155 | res, _ = cache.Get(key) |
| 156 | if string(res) != "efghijk" { |
| 157 | t.Error(string(res)) |
| 158 | } |
| 159 | val = append(val, 'l') |
| 160 | cache.Set(key, val, 0) |
| 161 | res, _ = cache.Get(key) |
| 162 | if string(res) != "efghijkl" { |
| 163 | t.Error(string(res)) |
| 164 | } |
| 165 | val = append(val, 'm') |
| 166 | cache.Set(key, val, 0) |
| 167 | if count := cache.OverwriteCount(); count != 3 { |
| 168 | t.Error("overwrite count is", count, "expected ", 3) |
| 169 | } |
| 170 | } |
| 171 | |
| 172 | func TestGetOrSet(t *testing.T) { |
| 173 | cache := NewCache(1024) |
nothing calls this directly
no test coverage detected
searching dependent graphs…