package paginate

import "testing"

func TestSlice(t *testing.T) {
	items := []int{1, 2, 3, 4, 5}

	page, total := Slice(items, 0, 2)
	if total != 5 || len(page) != 2 || page[0] != 1 || page[1] != 2 {
		t.Fatalf("first page = %#v total=%d", page, total)
	}

	page, total = Slice(items, 4, 10)
	if total != 5 || len(page) != 1 || page[0] != 5 {
		t.Fatalf("last page = %#v total=%d", page, total)
	}

	page, total = Slice(items, 10, 5)
	if total != 5 || len(page) != 0 {
		t.Fatalf("past end = %#v total=%d", page, total)
	}
}
