Files
hjsq_server/models/v/vidmod/recommend_test.go
2026-10-08 16:50:13 +08:00

25 lines
673 B
Go

package vidmod
import "testing"
func TestCalculateRecommendScore(t *testing.T) {
if got, want := CalculateRecommendScore(1, 2, 3, 4), int64(34); got != want {
t.Fatalf("score=%d want=%d", got, want)
}
if got := CalculateRecommendScore(0, 0, 0, 0); got != 0 {
t.Fatalf("zero score=%d", got)
}
}
func TestNonNegativeHistoryValue(t *testing.T) {
if got := nonNegativeInt(-1); got != 0 {
t.Fatalf("negative history=%d want=0", got)
}
if got := maxInt64(8, nonNegativeInt(3)); got != 8 {
t.Fatalf("existing monotonic count overwritten: %d", got)
}
if got := maxInt64(2, nonNegativeInt(3)); got != 3 {
t.Fatalf("history initialization=%d want=3", got)
}
}