You've already forked agentic-coding-workflow
48 lines
1.2 KiB
Go
48 lines
1.2 KiB
Go
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)
|
|
}
|
|
|
|
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))
|
|
}
|