This repository was archived by the owner on May 31, 2025. It is now read-only.
File tree Expand file tree Collapse file tree 1 file changed +29
-17
lines changed
Expand file tree Collapse file tree 1 file changed +29
-17
lines changed Original file line number Diff line number Diff line change @@ -4,25 +4,25 @@ import (
44 "testing"
55)
66
7- func TestPaginate (t * testing.T ) {
8- type Data struct {
9- Id int
10- Name string
11- }
7+ type Data struct {
8+ Id int
9+ Name string
10+ }
1211
13- datas : = []Data {
14- {Id : 1 , Name : "a" },
15- {Id : 2 , Name : "b" },
16- {Id : 3 , Name : "c" },
17- {Id : 4 , Name : "d" },
18- {Id : 5 , Name : "e" },
19- {Id : 6 , Name : "f" },
20- {Id : 7 , Name : "g" },
21- {Id : 8 , Name : "h" },
22- {Id : 9 , Name : "i" },
23- {Id : 10 , Name : "j" },
24- }
12+ var datas = []Data {
13+ {Id : 1 , Name : "a" },
14+ {Id : 2 , Name : "b" },
15+ {Id : 3 , Name : "c" },
16+ {Id : 4 , Name : "d" },
17+ {Id : 5 , Name : "e" },
18+ {Id : 6 , Name : "f" },
19+ {Id : 7 , Name : "g" },
20+ {Id : 8 , Name : "h" },
21+ {Id : 9 , Name : "i" },
22+ {Id : 10 , Name : "j" },
23+ }
2524
25+ func TestPaginate (t * testing.T ) {
2626 paginate := Paginate [Data ](datas , 1 , 3 )
2727 if len (paginate ) != 3 {
2828 t .Errorf ("Paginate error" )
@@ -37,3 +37,15 @@ func TestPaginate(t *testing.T) {
3737 t .Errorf ("Paginate error" )
3838 }
3939}
40+
41+ func TestToMap (t * testing.T ) {
42+ toMap := ToMap (datas , func (row Data ) int {
43+ return row .Id
44+ })
45+ if len (toMap ) != 10 {
46+ t .Errorf ("ToMap error" )
47+ }
48+ if toMap [1 ].Id != 1 {
49+ t .Errorf ("ToMap error" )
50+ }
51+ }
You can’t perform that action at this time.
0 commit comments