-
Notifications
You must be signed in to change notification settings - Fork 0
/
map_test.go
53 lines (39 loc) · 1.23 KB
/
map_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
48
49
50
51
52
53
package pipe
import (
"testing"
"github.com/msacore/pipe/test"
)
func TestMap(t *testing.T) {
t.Run("Parallel", func(t *testing.T) {
test.Suit(t, func(epipe chan error) ([]<-chan float32, chan error) {
pipe := test.Generator(0, 64, 16)
pipe2 := Map(func(val int) float32 {
return float32(val)
}, pipe)
pipe2, epipe = test.AssertCount("count", pipe2, epipe, 64)
return []<-chan float32{pipe2}, epipe
})
})
t.Run("Sync", func(t *testing.T) {
test.Suit(t, func(epipe chan error) ([]<-chan float32, chan error) {
pipe := test.Generator(0, 64, 16)
pipe2 := MapSync(func(val int) float32 {
return float32(val)
}, pipe)
pipe2, epipe = test.AssertOrderAsc("ordering", pipe2, epipe)
pipe2, epipe = test.AssertCount("count", pipe2, epipe, 64)
return []<-chan float32{pipe2}, epipe
})
})
t.Run("Sequential", func(t *testing.T) {
test.Suit(t, func(epipe chan error) ([]<-chan float32, chan error) {
pipe := test.Generator(0, 64, 16)
pipe2 := MapSequential(func(val int) float32 {
return float32(val)
}, pipe)
pipe2, epipe = test.AssertOrderAsc("ordering", pipe2, epipe)
pipe2, epipe = test.AssertCount("count", pipe2, epipe, 64)
return []<-chan float32{pipe2}, epipe
})
})
}