-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathasync_compacted_sequence_test.go
More file actions
64 lines (52 loc) · 1.92 KB
/
Copy pathasync_compacted_sequence_test.go
File metadata and controls
64 lines (52 loc) · 1.92 KB
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
54
55
56
57
58
59
60
61
62
63
64
package co_test
import (
"testing"
"github.com/smartystreets/goconvey/convey"
"go.tempura.ink/co"
)
type vData struct{ v int }
func TestAsyncCompactedSequence(t *testing.T) {
convey.Convey("given a sequential int", t, func() {
dataList := []*vData{{1}, nil, {4}, {3245}, {6}, nil, nil, {7}, nil, nil, nil, {32}, {4}}
aList := co.OfListWith(dataList...)
pList := co.NewAsyncCompactedSequence[*vData](aList)
convey.Convey("expect resolved list to be identical with given values", func() {
expected := []*vData{{1}, {4}, {3245}, {6}, {7}, {32}, {4}}
actual := []*vData{}
for data := range pList.Iter() {
actual = append(actual, data)
}
convey.So(actual, convey.ShouldResemble, expected)
})
})
}
func TestAsyncCompactedSequenceStruct(t *testing.T) {
convey.Convey("given a sequential int", t, func() {
dataList := []vData{{1}, {}, {4}, {3245}, {6}, {}, {}, {7}, {}, {}, {}, {32}, {4}}
aList := co.OfListWith(dataList...)
pList := co.NewAsyncCompactedSequence[vData](aList)
convey.Convey("expect resolved list to be identical with given values", func() {
expected := []vData{{1}, {4}, {3245}, {6}, {7}, {32}, {4}}
actual := []vData{}
for data := range pList.Iter() {
actual = append(actual, data)
}
convey.So(actual, convey.ShouldResemble, expected)
})
})
}
func TestAsyncCompactedSequencePrimitiveTypes(t *testing.T) {
convey.Convey("given a sequential int", t, func() {
dataList := []int{1, 23, 0, 5, 8, 0, 1, 3, 40, 0, 73, 12, 32345, 0, 123, 0, 123, 0, 0, 0, 0, 324, 1, 5, 6}
aList := co.OfListWith(dataList...)
pList := co.NewAsyncCompactedSequence[int](aList)
convey.Convey("expect resolved list to be identical with given values", func() {
expected := []int{1, 23, 5, 8, 1, 3, 40, 73, 12, 32345, 123, 123, 324, 1, 5, 6}
actual := []int{}
for data := range pList.Iter() {
actual = append(actual, data)
}
convey.So(actual, convey.ShouldResemble, expected)
})
})
}