-
Notifications
You must be signed in to change notification settings - Fork 1
/
joiner_test.go
90 lines (74 loc) · 1.42 KB
/
joiner_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
83
84
85
86
87
88
89
90
package ranges
import (
"testing"
)
func TestJoiner(t *testing.T) {
t.Parallel()
result := string(Slice(
Joiner(
Cache(
Map(
Only("Mary", "has", "a", "little", "lamb"),
func(x string) InputRange[rune] { return Runes(x) },
),
),
Runes("..."),
),
))
assertEqual(t, result, "Mary...has...a...little...lamb")
}
func TestJoinerF(t *testing.T) {
t.Parallel()
result := string(SliceF(
JoinerF(
CacheF(
MapF(
Only("Mary", "has", "a", "little", "lamb"),
func(x string) ForwardRange[byte] { return Bytes(x) },
),
),
Bytes("..."),
),
))
assertEqual(t, result, "Mary...has...a...little...lamb")
}
func TestJoinerS(t *testing.T) {
t.Parallel()
result := string(SliceF(
JoinerS(
[]ForwardRange[rune]{
Runes("Mary"),
Runes("has"),
Runes("a"),
Runes("little"),
Runes("lamb"),
},
Runes("..."),
),
))
assertEqual(t, result, "Mary...has...a...little...lamb")
}
func TestJoinerSS(t *testing.T) {
t.Parallel()
result := string(SliceF(
JoinerSS(
[][]rune{
[]rune("Mary"),
[]rune("has"),
[]rune("a"),
[]rune("little"),
[]rune("lamb"),
},
[]rune("..."),
),
))
assertEqual(t, result, "Mary...has...a...little...lamb")
}
func TestJoinStrings(t *testing.T) {
t.Parallel()
result := JoinStrings(
Only("Mary", "has", "a", "little", "lamb"),
"...",
)
assertEqual(t, result, "Mary...has...a...little...lamb")
}