-
Notifications
You must be signed in to change notification settings - Fork 28
/
paginator_test.go
79 lines (72 loc) · 1.35 KB
/
paginator_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
package util
import (
"reflect"
"testing"
)
func TestPaginator0(t *testing.T) {
srcArr := [][]int{
{1, 0},
{2, 0},
{3, 0},
{4, 0},
{5, 0},
{6, 0},
{7, 0},
{7, 1},
{7, 2},
{7, 3},
{7, 4},
{7, 5},
{7, 6},
{8, 0},
{8, 2},
{8, 3},
{8, 5},
{8, 7},
{11, 0},
{11, 2},
{11, 4},
{11, 5},
{11, 6},
{11, 8},
{11, 10},
}
dstArr := [][]int{
{0},
{0, 1},
{0, 1, 2},
{0, 1, 2, 3},
{0, 1, 2, 3, 4},
{0, 1, 2, 3, 4, 5},
{0, 1, 2, 3, 4, 5, 6},
{0, 1, 2, 3, 4, 5, 6},
{0, 1, 2, 3, 4, 5, 6},
{0, 1, 2, 3, 4, 5, 6},
{0, 1, 2, 3, 4, 5, 6},
{0, 1, 2, 3, 4, 5, 6},
{0, 1, 2, 3, 4, 5, 6},
{0, 1, 2, 3, 4, -1, 6, 7},
{0, 1, 2, 3, 4, -1, 6, 7},
{0, 1, 2, 3, 4, 5, 6, 7},
{0, 1, -1, 3, 4, 5, 6, 7},
{0, 1, -1, 3, 4, 5, 6, 7},
{0, 1, 2, 3, 4, -1, 9, 10},
{0, 1, 2, 3, 4, -1, 9, 10},
{0, 1, 2, 3, 4, 5, 6, -1, 9, 10},
{0, 1, -1, 3, 4, 5, 6, 7, -1, 9, 10},
{0, 1, -1, 4, 5, 6, 7, 8, 9, 10},
{0, 1, -1, 6, 7, 8, 9, 10},
{0, 1, -1, 6, 7, 8, 9, 10},
}
for i, src := range srcArr {
dst, err := Paginator0(src[0], src[1])
if err != nil {
t.Errorf("Paginator0(%d, %d):\nError: %q\n", src[0], src[1], err.Error())
continue
}
if dstWant := dstArr[i]; !reflect.DeepEqual(dst, dstWant) {
t.Errorf("Paginator0(%d, %d):\nhave %v\nwant %v\n", src[0], src[1], dst, dstWant)
continue
}
}
}