1
0
mirror of https://github.com/duke-git/lancet.git synced 2026-02-11 08:12:26 +08:00

feat: add take iterator

This commit is contained in:
dudaodong
2022-12-26 17:20:14 +08:00
parent b06fb6736d
commit 65315dafb1
2 changed files with 36 additions and 0 deletions

View File

@@ -60,3 +60,14 @@ func TestReduce(t *testing.T) {
sum := Reduce(iter, 0, func(a, b int) int { return a + b })
assert.Equal(10, sum)
}
func TestTakeIterator(t *testing.T) {
assert := internal.NewAssert(t, "TestTakeIterator")
iter := FromSlice([]int{1, 2, 3, 4, 5})
iter = Take(iter, 3)
result := ToSlice(iter)
assert.Equal([]int{1, 2, 3}, result)
}