1
0
mirror of https://github.com/duke-git/lancet.git synced 2026-02-10 07:42:27 +08:00

feat: add FromChannel for create stream

This commit is contained in:
dudaodong
2023-01-17 16:47:20 +08:00
parent 585d33cafa
commit 82cbb54787
2 changed files with 30 additions and 3 deletions

View File

@@ -39,6 +39,22 @@ func TestFromSlice(t *testing.T) {
assert.Equal([]int{1, 2, 3}, stream.ToSlice())
}
func TestFromChannel(t *testing.T) {
assert := internal.NewAssert(t, "TestFromChannel")
ch := make(chan int)
go func() {
for i := 1; i < 4; i++ {
ch <- i
}
close(ch)
}()
stream := FromChannel(ch)
assert.Equal([]int{1, 2, 3}, stream.ToSlice())
}
func TestFromRange(t *testing.T) {
assert := internal.NewAssert(t, "TestFromRange")