Add an access time update check after Cache.Get

This commit is contained in:
Nikita Stroganov 2023-02-26 09:46:23 +00:00 committed by Arseny Balobanov
parent bc379d8da9
commit 9e1a139928

View file

@ -29,6 +29,29 @@ func TestCache_update(t *testing.T) {
require.Equal(t, 2, v)
}
func TestCache_Get(t *testing.T) {
c := New(5)
for i := 0; i < 5; i++ {
c.Set(i, i)
}
c.Get(0)
c.Get(1)
c.Set(5, 5)
c.Set(6, 6)
var keys, values []int
c.Range(func(key, value int) bool {
keys = append(keys, key)
values = append(values, value)
return true
})
require.Equal(t, []int{4, 0, 1, 5, 6}, keys)
require.Equal(t, []int{4, 0, 1, 5, 6}, values)
}
func TestCache_Clear(t *testing.T) {
c := New(5)