// 用户积分流水分页测试，验证无效参数修正和每页数量上限。
package service

import "testing"

// TestNormalizeConsumptionPagination 验证积分流水分页参数始终落在允许范围内。
func TestNormalizeConsumptionPagination(t *testing.T) {
	tests := []struct {
		name         string
		page         int
		pageSize     int
		wantPage     int
		wantPageSize int
	}{
		{name: "defaults", page: 0, pageSize: 0, wantPage: 1, wantPageSize: 10},
		{name: "keeps valid values", page: 3, pageSize: 20, wantPage: 3, wantPageSize: 20},
		{name: "caps page size", page: 2, pageSize: 500, wantPage: 2, wantPageSize: 100},
	}
	for _, test := range tests {
		t.Run(test.name, func(t *testing.T) {
			page, pageSize := normalizeConsumptionPagination(test.page, test.pageSize)
			if page != test.wantPage || pageSize != test.wantPageSize {
				t.Fatalf("pagination = (%d, %d), want (%d, %d)", page, pageSize, test.wantPage, test.wantPageSize)
			}
		})
	}
}
