Files
kurious/internal/common/xslices/lru_test.go
Aleksandr Trushkin 88a3cae4fa learning category repo
2024-03-16 17:44:43 +03:00

24 lines
372 B
Go

package xslices
import "testing"
func TestLRU(t *testing.T) {
lru := NewLRU[int, string](3)
for i := 0; i < 4; i++ {
lru.Push(i, "v")
}
for i := 0; i < 4; i++ {
_, found := lru.Get(i)
if i == 0 {
if found {
t.Error("expected value to be flushed out of cache")
}
continue
}
if !found {
t.Errorf("expected value %d to be found", i)
}
}
}