34 lines
1.0 KiB
Go
34 lines
1.0 KiB
Go
|
|
package app
|
||
|
|
|
||
|
|
import "testing"
|
||
|
|
|
||
|
|
func TestCalculateAIPointCost(t *testing.T) {
|
||
|
|
t.Parallel()
|
||
|
|
|
||
|
|
tests := []struct {
|
||
|
|
name string
|
||
|
|
chars int
|
||
|
|
baseChars int
|
||
|
|
want int
|
||
|
|
}{
|
||
|
|
{name: "empty still charges base usage", chars: 0, baseChars: 1000, want: 1},
|
||
|
|
{name: "single char", chars: 1, baseChars: 1000, want: 1},
|
||
|
|
{name: "first base boundary", chars: 1000, baseChars: 1000, want: 2},
|
||
|
|
{name: "over first base", chars: 1001, baseChars: 1000, want: 2},
|
||
|
|
{name: "second base boundary", chars: 2000, baseChars: 1000, want: 3},
|
||
|
|
{name: "over second base", chars: 2001, baseChars: 1000, want: 3},
|
||
|
|
{name: "default base chars", chars: 1000, baseChars: 0, want: 2},
|
||
|
|
{name: "custom base chars", chars: 1500, baseChars: 500, want: 4},
|
||
|
|
}
|
||
|
|
|
||
|
|
for _, tt := range tests {
|
||
|
|
tt := tt
|
||
|
|
t.Run(tt.name, func(t *testing.T) {
|
||
|
|
t.Parallel()
|
||
|
|
if got := calculateAIPointCost(tt.chars, tt.baseChars); got != tt.want {
|
||
|
|
t.Fatalf("calculateAIPointCost(%d, %d) = %d, want %d", tt.chars, tt.baseChars, got, tt.want)
|
||
|
|
}
|
||
|
|
})
|
||
|
|
}
|
||
|
|
}
|