Skip to content

Commit

Permalink
add TestEvict
Browse files Browse the repository at this point in the history
  • Loading branch information
knbr13 committed Apr 6, 2024
1 parent 68b924e commit f089271
Showing 1 changed file with 25 additions and 0 deletions.
25 changes: 25 additions & 0 deletions mcache_test.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package incache

import (
"fmt"
"testing"
"time"
)
Expand Down Expand Up @@ -254,3 +255,27 @@ func TestCount(t *testing.T) {
t.Errorf("Count: expected: %d, got: %d", 2, count)
}
}

func TestEvict(t *testing.T) {
c := newManual(&CacheBuilder[string, string]{
et: Manual,
size: 3,
})

c.Set("1", "one")
c.Set("2", "two")
c.Set("3", "three")
c.Set("4", "four")

fmt.Println(c.Keys())

if count := c.Count(); count != 3 {
t.Errorf("Count: expected: %d, got: %d", 3, count)
}

c.evict(2)

if count := c.Count(); count != 1 {
t.Errorf("Count: expected: %d, got: %d", 1, count)
}
}

0 comments on commit f089271

Please sign in to comment.