24 lines
372 B
Go
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)
|
|
}
|
|
}
|
|
}
|