package chat import ( "testing" "github.com/stretchr/testify/require" ) func TestComputeCost_BasicMath(t *testing.T) { m := LLMModel{ PromptPricePerMillionUSD: 3.0, CompletionPricePerMillionUSD: 15.0, ThinkingPricePerMillionUSD: 3.0, } // 1000 prompt tokens × $3/M = $0.003 got := computeCost(m, 1000, 0, 0) require.InDelta(t, 0.003, got, 1e-9) // 1000 completion tokens × $15/M = $0.015 got = computeCost(m, 0, 1000, 0) require.InDelta(t, 0.015, got, 1e-9) // 1000 thinking tokens × $3/M = $0.003 got = computeCost(m, 0, 0, 1000) require.InDelta(t, 0.003, got, 1e-9) // combined: 1000+1000+1000 = $0.021 got = computeCost(m, 1000, 1000, 1000) require.InDelta(t, 0.021, got, 1e-9) } // TestExportedComputeCost_EqualsUnexported guards that the exported ComputeCost // (reused by internal/acp) returns identical results to the unexported alias. func TestExportedComputeCost_EqualsUnexported(t *testing.T) { m := LLMModel{ PromptPricePerMillionUSD: 3.0, CompletionPricePerMillionUSD: 15.0, ThinkingPricePerMillionUSD: 3.0, } for _, c := range [][3]int{{1000, 0, 0}, {0, 1000, 0}, {0, 0, 1000}, {1234, 5678, 90}} { require.Equal(t, computeCost(m, c[0], c[1], c[2]), ComputeCost(m, c[0], c[1], c[2])) } } func TestComputeCost_ZeroTokens(t *testing.T) { m := LLMModel{ PromptPricePerMillionUSD: 3.0, CompletionPricePerMillionUSD: 15.0, ThinkingPricePerMillionUSD: 3.0, } require.Equal(t, 0.0, computeCost(m, 0, 0, 0)) } func TestInt64ToString(t *testing.T) { require.Equal(t, "0", int64ToString(0)) require.Equal(t, "42", int64ToString(42)) require.Equal(t, "-1", int64ToString(-1)) require.Equal(t, "9223372036854775807", int64ToString(9223372036854775807)) }