initial Paginate() tests

This commit is contained in:
Azareal 2020-03-09 11:37:31 +10:00
parent 5007ddcb1e
commit 42a95d8597
2 changed files with 26 additions and 3 deletions

View File

@ -1,6 +1,7 @@
package main
import (
"fmt"
"strconv"
"strings"
"testing"
@ -370,3 +371,25 @@ func TestParser(t *testing.T) {
t.Error("Expected:", "'"+expect+"'")
}
}
func TestPaginate(t *testing.T) {
var plist []int
f := func(i, want int) {
expect(t, plist[i] == want, fmt.Sprintf("plist[%d] should be %d not %d", i, want, plist[i]))
}
plist = c.Paginate(1, 1, 5)
expect(t, len(plist) == 1, fmt.Sprintf("len of plist should be 1 not %d", len(plist)))
f(0, 1)
plist = c.Paginate(1, 5, 5)
expect(t, len(plist) == 5, fmt.Sprintf("len of plist should be 5 not %d", len(plist)))
f(0, 1)
f(1, 2)
f(2, 3)
f(3, 4)
f(4, 5)
// TODO: More Paginate() tests
// TODO: Tests for other paginator functions
}