Skip to content

Commit

Permalink
[Test] cover mode by tests #2
Browse files Browse the repository at this point in the history
[Test] cover mode by tests
  • Loading branch information
JanGalek authored Dec 17, 2024
2 parents f259a5c + 978dea8 commit b8fb781
Show file tree
Hide file tree
Showing 2 changed files with 294 additions and 112 deletions.
20 changes: 14 additions & 6 deletions paginator.go
Original file line number Diff line number Diff line change
Expand Up @@ -51,16 +51,23 @@ func (p *Paginator) GetLastPage() *int {
}

func (p *Paginator) GetFirstItemOnPage() int {
if *p.GetItemCount() != 0 {
i := p.offset + 1
return i
if p.GetItemCount() == nil || *p.GetItemCount() == 0 {
return 0
}

return 0
offset := p.GetOffset()
return offset + 1
}

func (p *Paginator) GetLastItemOnPage() int {
return p.offset + p.length
if p.GetItemCount() == nil || *p.GetItemCount() == 0 {
return 0
}

offset := p.GetOffset()
length := p.GetLength()

return offset + length
}

func (p *Paginator) SetBase(base int) *Paginator {
Expand Down Expand Up @@ -134,7 +141,8 @@ func (p *Paginator) GetCountdownOffset() *int {
if p.GetItemCount() == nil {
return nil
}
val := max(0, *p.GetItemCount()-(p.GetPageIndex()-1)*p.GetItemsPerPage())

val := max(0, *p.GetItemCount()-p.GetPageIndex()*p.GetItemsPerPage())
return &val
}
func (p *Paginator) GetLength() int {
Expand Down
Loading

0 comments on commit b8fb781

Please sign in to comment.