-
Notifications
You must be signed in to change notification settings - Fork 0
/
join_test.go
82 lines (71 loc) · 1.94 KB
/
join_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
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
package iterator
import (
"testing"
)
func TestJoin(t *testing.T) {
cases := []struct {
iter Iterator[int]
expected []int
}{
{Join[int](), []int{}},
{Join(Empty[int](), Empty[int]()), []int{}},
{Join(Empty[int](), Range(4, 6, 1)), []int{4, 5, 6}},
{Join(Range(4, 6, 1), Empty[int]()), []int{4, 5, 6}},
{Join(Range(1, 3, 1), Range(4, 6, 1)), []int{1, 2, 3, 4, 5, 6}},
}
for i := range cases {
checkIteratorEqual(t, cases[i].iter, cases[i].expected)
}
}
func TestJoinLeading(t *testing.T) {
cases := []struct {
iter Iterator[int]
expected []int
}{
{JoinLeading(Empty[int]())(Range(4, 6, 1)), []int{4, 5, 6}},
{JoinLeading(Range(4, 6, 1))(Empty[int]()), []int{4, 5, 6}},
{JoinLeading(Range(1, 3, 1))(Range(4, 6, 1)), []int{1, 2, 3, 4, 5, 6}},
}
for i := range cases {
checkIteratorEqual(t, cases[i].iter, cases[i].expected)
}
}
func TestJoinTrailing(t *testing.T) {
cases := []struct {
iter Iterator[int]
expected []int
}{
{JoinTrailing(Empty[int]())(Range(4, 6, 1)), []int{4, 5, 6}},
{JoinTrailing(Range(4, 6, 1))(Empty[int]()), []int{4, 5, 6}},
{JoinTrailing(Range(4, 6, 1))(Range(1, 3, 1)), []int{1, 2, 3, 4, 5, 6}},
}
for i := range cases {
checkIteratorEqual(t, cases[i].iter, cases[i].expected)
}
}
func TestAppend(t *testing.T) {
cases := []struct {
iter Iterator[int]
expected []int
}{
{Append[int]()(Range(4, 6, 1)), []int{4, 5, 6}},
{Append(4, 5, 6)(Empty[int]()), []int{4, 5, 6}},
{Append(4, 5, 6)(Range(1, 3, 1)), []int{1, 2, 3, 4, 5, 6}},
}
for i := range cases {
checkIteratorEqual(t, cases[i].iter, cases[i].expected)
}
}
func TestPrepend(t *testing.T) {
cases := []struct {
iter Iterator[int]
expected []int
}{
{Prepend[int]()(Range(4, 6, 1)), []int{4, 5, 6}},
{Prepend(4, 5, 6)(Empty[int]()), []int{4, 5, 6}},
{Prepend(1, 2, 3)(Range(4, 6, 1)), []int{1, 2, 3, 4, 5, 6}},
}
for i := range cases {
checkIteratorEqual(t, cases[i].iter, cases[i].expected)
}
}