package sieve import ( "slices" "testing" ) func TestSieveCache(t *testing.T) { cache := NewCache(3) cache.Put("a", "A") cache.Put("b", "B") cache.Put("c", "C") cache.Put("d", "D") cache.Put("b", "B") cache.Put("e", "E") cache.Put("a", "A") expectedKeys := []string{"a", "b", "e"} count := 0 cache.Range(func(k, _ string) bool { count++ if !slices.Contains(expectedKeys, k) { t.Fail() t.Errorf("unexpected key in result: %s", k) } return true }) }