Skip to content

Commit

Permalink
Add unit test
Browse files Browse the repository at this point in the history
  • Loading branch information
JimChenWYU committed Aug 26, 2024
1 parent 73b2680 commit f198a45
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions simplelru/lru_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -178,6 +178,9 @@ func TestCache_PeekOldest(t *testing.T) {
k, v int
ok bool
)
_, _, ok = l.PeekOldest()
assert.False(t, ok)

l.Put(1, 1)
l.Put(2, 2)
l.Put(3, 3)
Expand All @@ -203,6 +206,18 @@ func TestCache_Keys_Values(t *testing.T) {
assert.EqualValues(t, []int{10, 20, 30}, l.Values())
}

func TestCache_Resize(t *testing.T) {
l, _ := New[int, int](1)
assert.EqualValues(t, 0, l.Resize(3))

l.Put(1, 10)
l.Put(2, 20)
l.Put(3, 30)
assert.EqualValues(t, 3, l.Len())
assert.EqualValues(t, 2, l.Resize(1))
assert.EqualValues(t, 1, l.Len())
}

func TestCache_Contains(t *testing.T) {
tests := []struct {
name string
Expand Down

0 comments on commit f198a45

Please # to comment.