package util

import (
	"reflect"
	"testing"
)

func TestPaginator0(t *testing.T) {
	srcArr := [][]int{
		{1, 0},
		{2, 0},
		{3, 0},
		{4, 0},
		{5, 0},
		{6, 0},
		{7, 0},
		{7, 1},
		{7, 2},
		{7, 3},
		{7, 4},
		{7, 5},
		{7, 6},

		{8, 0},
		{8, 2},
		{8, 3},
		{8, 5},
		{8, 7},

		{11, 0},
		{11, 2},
		{11, 4},
		{11, 5},
		{11, 6},
		{11, 8},
		{11, 10},
	}
	dstArr := [][]int{
		{0},
		{0, 1},
		{0, 1, 2},
		{0, 1, 2, 3},
		{0, 1, 2, 3, 4},
		{0, 1, 2, 3, 4, 5},
		{0, 1, 2, 3, 4, 5, 6},
		{0, 1, 2, 3, 4, 5, 6},
		{0, 1, 2, 3, 4, 5, 6},
		{0, 1, 2, 3, 4, 5, 6},
		{0, 1, 2, 3, 4, 5, 6},
		{0, 1, 2, 3, 4, 5, 6},
		{0, 1, 2, 3, 4, 5, 6},

		{0, 1, 2, 3, 4, -1, 6, 7},
		{0, 1, 2, 3, 4, -1, 6, 7},
		{0, 1, 2, 3, 4, 5, 6, 7},
		{0, 1, -1, 3, 4, 5, 6, 7},
		{0, 1, -1, 3, 4, 5, 6, 7},

		{0, 1, 2, 3, 4, -1, 9, 10},
		{0, 1, 2, 3, 4, -1, 9, 10},
		{0, 1, 2, 3, 4, 5, 6, -1, 9, 10},
		{0, 1, -1, 3, 4, 5, 6, 7, -1, 9, 10},
		{0, 1, -1, 4, 5, 6, 7, 8, 9, 10},
		{0, 1, -1, 6, 7, 8, 9, 10},
		{0, 1, -1, 6, 7, 8, 9, 10},
	}

	for i, src := range srcArr {
		dst, err := Paginator0(src[0], src[1])
		if err != nil {
			t.Errorf("Paginator0(%d, %d):\nError: %q\n", src[0], src[1], err.Error())
			continue
		}
		if dstWant := dstArr[i]; !reflect.DeepEqual(dst, dstWant) {
			t.Errorf("Paginator0(%d, %d):\nhave %v\nwant %v\n", src[0], src[1], dst, dstWant)
			continue
		}
	}
}
