mirror of
https://github.com/duke-git/lancet.git
synced 2026-02-14 01:32:27 +08:00
feat: add Generate chan function in concurrency package
This commit is contained in:
24
concurrency/channel_test.go
Normal file
24
concurrency/channel_test.go
Normal file
@@ -0,0 +1,24 @@
|
||||
package concurrency
|
||||
|
||||
import (
|
||||
"testing"
|
||||
|
||||
"github.com/duke-git/lancet/v2/internal"
|
||||
)
|
||||
|
||||
func TestGenerate(t *testing.T) {
|
||||
assert := internal.NewAssert(t, "TestToChar")
|
||||
|
||||
done := make(chan any)
|
||||
defer close(done)
|
||||
|
||||
c := NewChannel()
|
||||
intStream := c.Generate(done, 1, 2, 3)
|
||||
|
||||
// for v := range intStream {
|
||||
// t.Log(v)
|
||||
// }
|
||||
assert.Equal(1, <-intStream)
|
||||
assert.Equal(2, <-intStream)
|
||||
assert.Equal(3, <-intStream)
|
||||
}
|
||||
Reference in New Issue
Block a user