Skip to content

Commit

Permalink
add List tests
Browse files Browse the repository at this point in the history
  • Loading branch information
hsldymq committed Apr 1, 2024
1 parent 588bcac commit ef23209
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions list_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -516,6 +516,21 @@ func TestList_All(t *testing.T) {
}
}

func TestList_Filter(t *testing.T) {
list := NewList[int](1, 2, 3, 4, 5)
e := list.Filter(func(v int) bool {
return v%2 == 0
})
actual := []int{}
for v := range e.Iter() {
actual = append(actual, v)
}
expect := []int{2, 4}
if !slices.Equal(expect, actual) {
t.Fatalf("test List.Filter expect: %v, actual: %v", expect, actual)
}
}

func TestList_Take(t *testing.T) {
list := NewList(1, 2, 3, 4, 5, 6, 7, 8)

Expand Down

0 comments on commit ef23209

Please sign in to comment.