-
Notifications
You must be signed in to change notification settings - Fork 56
/
iterators_test.go
60 lines (52 loc) · 1.34 KB
/
iterators_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
package plush_test
import (
"testing"
"github.com/gobuffalo/plush/v5"
"github.com/stretchr/testify/require"
)
func Test_groupByHelper(t *testing.T) {
r := require.New(t)
g, err := plush.GroupByHelper(2, []string{"a", "b", "c", "d", "e"})
r.NoError(err)
g1 := g.Next()
r.Equal([]string{"a", "b", "c"}, g1)
g2 := g.Next()
r.Equal([]string{"d", "e"}, g2)
r.Nil(g.Next())
}
func Test_groupByHelper_Exact(t *testing.T) {
r := require.New(t)
g, err := plush.GroupByHelper(2, []string{"a", "b"})
r.NoError(err)
g1 := g.Next()
r.Equal([]string{"a", "b"}, g1)
r.Nil(g.Next())
}
func Test_groupByHelper_Pointer(t *testing.T) {
r := require.New(t)
g, err := plush.GroupByHelper(2, &[]string{"a", "b", "c", "d", "e"})
r.NoError(err)
g1 := g.Next()
r.Equal([]string{"a", "b", "c"}, g1)
g2 := g.Next()
r.Equal([]string{"d", "e"}, g2)
r.Nil(g.Next())
}
func Test_groupByHelper_SmallGroup(t *testing.T) {
r := require.New(t)
g, err := plush.GroupByHelper(1, []string{"a", "b", "c", "d", "e"})
r.NoError(err)
g1 := g.Next()
r.Equal([]string{"a", "b", "c", "d", "e"}, g1)
r.Nil(g.Next())
}
func Test_groupByHelper_NonGroupable(t *testing.T) {
r := require.New(t)
_, err := plush.GroupByHelper(1, 1)
r.Error(err)
}
func Test_groupByHelper_ZeroSize(t *testing.T) {
r := require.New(t)
_, err := plush.GroupByHelper(0, []string{"a"})
r.Error(err)
}