-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathiter_test.go
58 lines (51 loc) · 833 Bytes
/
iter_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
package iter
import (
"testing"
)
func TestN(t *testing.T) {
t.Run("Should do nothing", func(t *testing.T) {
match := 0
for n := range N() {
if match != n {
t.Fail()
}
match++
}
})
t.Run("Should generate sequence 1-9", func(t *testing.T) {
match := 1
for n := range N(1, 10) {
if match != n {
t.Fail()
}
match++
}
})
t.Run("Should generate sequence 0-9", func(t *testing.T) {
match := 0
for n := range N(10) {
if match != n {
t.Fail()
}
match++
}
})
t.Run("Should generate sequence 1-9 by step+=2", func(t *testing.T) {
match := 1
for n := range N(1, 10, 2) {
if match != n {
t.Fail()
}
match += 2
}
})
}
func TestL(t *testing.T) {
output := ""
for c := range L('a', 'e') {
output += string(c)
}
if output != "abcde" {
t.Fail()
}
}