MCPcopy
hub / github.com/gofiber/fiber / Test_PageInfoStart

Function Test_PageInfoStart

middleware/paginate/paginate_test.go:115–139  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

113}
114
115func Test_PageInfoStart(t *testing.T) {
116 t.Parallel()
117
118 tests := []struct {
119 name string
120 pageInfo PageInfo
121 expected int
122 }{
123 {"Page 1, limit 10", PageInfo{Page: 1, Limit: 10}, 0},
124 {"Page 1, limit 1", PageInfo{Page: 1, Limit: 1}, 0},
125 {"Page 2, limit 10", PageInfo{Page: 2, Limit: 10}, 10},
126 {"Page 2, limit 1", PageInfo{Page: 2, Limit: 1}, 1},
127 {"Page 3, limit 20", PageInfo{Page: 3, Limit: 20}, 40},
128 {"With offset", PageInfo{Page: 2, Limit: 10, Offset: 25}, 25},
129 {"Zero page", PageInfo{Page: 0, Limit: 10}, 0},
130 {"Overflow clamps to MaxInt", PageInfo{Page: int(^uint(0) >> 1), Limit: 100}, int(^uint(0) >> 1)},
131 }
132
133 for _, tt := range tests {
134 t.Run(tt.name, func(t *testing.T) {
135 t.Parallel()
136 require.Equal(t, tt.expected, tt.pageInfo.Start())
137 })
138 }
139}
140
141func Test_PageInfoSortBy(t *testing.T) {
142 t.Parallel()

Callers

nothing calls this directly

Calls 1

StartMethod · 0.65

Tested by

no test coverage detected