feat: add func Tee

This commit is contained in:
dudaodong committed 2022-04-21 11:18:45 +08:00
1 parent 046e90486d
commit 922999037f
2 files changed
+42

No files matched your search

+16
View File
@@ -149,3 +149,19 @@ func TestOrDone(t *testing.T) {
assert.Equal(1, res)
}
func TestTee(t *testing.T) {
assert := internal.NewAssert(t, "TestTee")
ctx, cancel := context.WithCancel(context.Background())
defer cancel()
c := NewChannel()
inStream := c.Take(ctx, c.Repeat(ctx, 1, 2), 4)
out1, out2 := c.Tee(ctx, inStream)
for val := range out1 {
assert.Equal(1, val)
assert.Equal(1, <-out2)
}
}