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 6d77f7b commit 1096e40
Showing 1 changed file with 34 additions and 0 deletions.
34 changes: 34 additions & 0 deletions list_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -482,6 +482,40 @@ func TestList_IterBackward(t *testing.T) {
}
}

func TestList_Any(t *testing.T) {
list := NewList[int](1, 2, 3, 4, 5)
result := list.Any(func(v int) bool {
return v%2 == 0
})
if !result {
t.Fatalf("test List.Any, should return true")
}

result = list.Any(func(v int) bool {
return v == 6
})
if result {
t.Fatalf("test List.Any, should return false")
}
}

func TestList_All(t *testing.T) {
list := NewList[int](1, 2, 3, 4, 5)
result := list.All(func(v int) bool {
return v%2 == 0
})
if result {
t.Fatalf("test List.All, should return false")
}

result = list.All(func(v int) bool {
return v < 6
})
if !result {
t.Fatalf("test List.All, should return true")
}
}

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

Expand Down

0 comments on commit 1096e40

Please sign in to comment.