(t *testing.T)
| 6 | ) |
| 7 | |
| 8 | func TestLRUCache_1(t *testing.T) { |
| 9 | cache := Constructor(2) |
| 10 | cache.Put(1, 1) |
| 11 | cache.Put(2, 2) |
| 12 | assert.Equal(t, 1, cache.Get(1)) // returns 1 |
| 13 | |
| 14 | cache.Put(3, 3) // evicts key 2 |
| 15 | assert.Equal(t, -1, cache.Get(2)) // returns -1 (not found) |
| 16 | |
| 17 | cache.Put(4, 4) // evicts key 1 |
| 18 | assert.Equal(t, -1, cache.Get(1)) // returns -1 (not found) |
| 19 | assert.Equal(t, 3, cache.Get(3)) // returns 3 |
| 20 | assert.Equal(t, 4, cache.Get(4)) // returns 4 |
| 21 | } |
| 22 | |
| 23 | func TestLRUCache_2(t *testing.T) { |
| 24 | cache := Constructor(1) |
nothing calls this directly
no test coverage detected