-
Notifications
You must be signed in to change notification settings - Fork 0
/
pagination_test.go
67 lines (64 loc) · 1.07 KB
/
pagination_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 httpkit
import (
"reflect"
"testing"
)
func TestPagination(t *testing.T) {
cases := []struct {
Actual Pagination
Excepted Pagination
}{
{
Actual: Pagination{
First: 1,
Last: 1,
Current: 1,
Size: 10,
Items: 0,
},
Excepted: NewPagination(1, 10, 0),
},
{
Actual: Pagination{
First: 1,
Last: 1,
Current: 1,
Size: 10,
Items: 9,
},
Excepted: NewPagination(1, 10, 9),
},
{
Actual: Pagination{
First: 1,
Last: 2,
Current: 1,
Next: 2,
Size: 10,
Items: 11,
},
Excepted: NewPagination(1, 10, 11),
},
{
Actual: Pagination{
First: 1,
Last: 3,
Previous: 1,
Current: 2,
Next: 3,
Size: 10,
Items: 21,
},
Excepted: NewPagination(2, 10, 21),
},
{
Actual: NewPagination(3, 10, 21),
Excepted: NewPagination(4, 10, 21),
},
}
for _, c := range cases {
if !reflect.DeepEqual(c.Actual, c.Excepted) {
t.Fatalf("Pagination, Actual=%+v, Excepted=%+v\n", c.Actual, c.Excepted)
}
}
}