-
Notifications
You must be signed in to change notification settings - Fork 1
/
tee_test.go
47 lines (32 loc) · 849 Bytes
/
tee_test.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
package ranges
import "testing"
func TestTee(t *testing.T) {
t.Parallel()
output := make([]int, 0)
tee := Tee[int](Only(1, 2), SliceSink(&output))
assertNotEmpty(t, tee)
assertEqual(t, tee.Front(), 1)
assertEqual(t, output, []int{})
tee.PopFront()
assertEqual(t, output, []int{1})
assertNotEmpty(t, tee)
assertEqual(t, tee.Front(), 2)
assertEqual(t, output, []int{1})
tee.PopFront()
assertEqual(t, output, []int{1, 2})
}
func TestTeeS(t *testing.T) {
t.Parallel()
output := make([]int, 0)
tee := TeeS([]int{1, 2}, SliceSink(&output))
assertNotEmpty(t, tee)
assertEqual(t, tee.Front(), 1)
assertEqual(t, output, []int{})
tee.PopFront()
assertEqual(t, output, []int{1})
assertNotEmpty(t, tee)
assertEqual(t, tee.Front(), 2)
assertEqual(t, output, []int{1})
tee.PopFront()
assertEqual(t, output, []int{1, 2})
}