learning category repo
This commit is contained in:
23
internal/common/xslices/lru_test.go
Normal file
23
internal/common/xslices/lru_test.go
Normal file
@ -0,0 +1,23 @@
|
||||
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)
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user