forked from digisan/go-generics
-
Notifications
You must be signed in to change notification settings - Fork 0
/
iter_test.go
67 lines (54 loc) · 1.02 KB
/
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
59
60
61
62
63
64
65
66
67
package gogenerics
import (
"fmt"
"testing"
)
var (
fPln = fmt.Println
)
func TestIter(t *testing.T) {
for i := range Iter(-10) {
fPln(i)
}
fPln(" ------------ ")
for i := range Iter(1, 5) {
fPln(i)
}
fPln(" ------------ ")
for i := range Iter(2, 3, 10) {
fPln(i)
}
fPln(" ------------ ")
func(slc ...int) {
for _, a := range slc {
fPln(a)
}
}(IterToSlc(11, -3, 2)...)
// ----------------------- //
fPln(" ************************************* ")
for i := range Iter(10, -2, -1) {
fPln(i)
}
fPln(" ------------ ")
for i := range Iter(10, 14) {
fPln(i)
}
}
func TestRangePair(t *testing.T) {
var data []int = []int{1, 2, 3, 4, 5}
for pair := range IterPair(data) {
fmt.Printf("%+v\n", pair)
}
}
func TestRangeTriple(t *testing.T) {
var data = []int{1, 2, 3, 4, 5}
for triple := range IterTriple(data) {
fmt.Printf("%+v\n", triple)
}
}
func TestRangeCache(t *testing.T) {
var data = []int{1, 2, 3, 4, 5}
for cache := range IterCache(data, 3, 3, 999) {
fmt.Printf("%+v\n", cache)
}
}