diff --git a/misc_test.go b/misc_test.go index 897f14c4..9518832d 100644 --- a/misc_test.go +++ b/misc_test.go @@ -1320,13 +1320,13 @@ func TestSearch(t *testing.T) { expect(t, topic.ID == tid, fmt.Sprintf("topic.ID should be %d not %d", tid, topic.ID)) expect(t, topic.Title == title, fmt.Sprintf("topic.Title should be %s not %s", title, topic.Title)) - tids, err = c.RepliesSearch.Query(q, []int{1,2}) + tids, err = c.RepliesSearch.Query(q, []int{1, 2}) fmt.Printf("tids: %+v\n", tids) expectNilErr(t, err) expect(t, len(tids) == 1, fmt.Sprintf("len(tids) should be 1 not %d", len(tids))) q = "bab" - tids, err = c.RepliesSearch.Query(q, []int{1,2}) + tids, err = c.RepliesSearch.Query(q, []int{1, 2}) fmt.Printf("tids: %+v\n", tids) expectNilErr(t, err) expect(t, len(tids) == 1, fmt.Sprintf("len(tids) should be 1 not %d", len(tids))) diff --git a/parser_test.go b/parser_test.go index c4061016..483c0d3d 100644 --- a/parser_test.go +++ b/parser_test.go @@ -1,6 +1,7 @@ package main import ( + "fmt" "strconv" "strings" "testing" @@ -363,10 +364,32 @@ func TestParser(t *testing.T) { } c.WriteURL(sb, c.BuildTopicURL("", tid), "#longidnameneedtooverflowhack-"+strconv.Itoa(tid)) }) - res = c.ParseMessage("#longidnameneedtooverflowhack-1", 1, "forums", nil,nil) + res = c.ParseMessage("#longidnameneedtooverflowhack-1", 1, "forums", nil, nil) expect = "#longidnameneedtooverflowhack-1" if res != expect { t.Error("Bad output:", "'"+res+"'") 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 +}