1
0
mirror of https://github.com/duke-git/lancet.git synced 2026-03-01 00:35:28 +08:00

feat: add func Tee

This commit is contained in:
dudaodong
2022-04-21 11:18:45 +08:00
parent 046e90486d
commit 922999037f
2 changed files with 42 additions and 0 deletions

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)
}
}