Files
ARTEX/agent/tools_overview_test.go
BaaRai e233c02314 Translate all Chinese text to English
Comments, doc comments, UI labels, log and error messages, LLM prompt
strings, markdown docs, test data and assertions. Identifiers, enum
keys, routes, placeholders and code structure are unchanged.

Notes:
- docs/漏洞流量证据.md renamed to docs/vulnerability-traffic-evidence.md
- tests that exercised CJK specific handling (GBK zip names, Chinese
  full text search) now use ASCII equivalents; go build passes and the
  test suite matches the pre translation baseline (remaining failures
  need a PostgreSQL DSN and fail identically on the original)
- frontend mention syntax now uses English kinds (finding, asset, ...)
  matching the backend, chat mentions tests pass
2026-10-08 23:14:34 +02:00

32 lines
1005 B
Go
Raw Permalink Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
package agent
import (
"strings"
"testing"
"unicode/utf8"
"github.com/Autumn-27/artex/db"
)
func TestOverviewTextBudgetIsFairAndUTF8Safe(t *testing.T) {
if got := relatedOverviewBudgetForSources(1); got != relatedOverviewMaxTextPerSource {
t.Fatalf("single source budget=%d want=%d", got, relatedOverviewMaxTextPerSource)
}
perSource := relatedOverviewBudgetForSources(db.MaxTaskSourceCount)
if perSource*db.MaxTaskSourceCount > relatedOverviewTotalTextRunes {
t.Fatalf("aggregate budget exceeded: per_source=%d", perSource)
}
budget := overviewTextBudget{remaining: 5}
got := budget.take(strings.Repeat("α", 10), 20)
if !utf8.ValidString(got) {
t.Fatalf("budget truncation produced invalid UTF-8: %q", got)
}
if utf8.RuneCountInString(got) != 5 || !budget.truncated || budget.remaining != 0 {
t.Fatalf("unexpected truncation: got=%q budget=%+v", got, budget)
}
if tail := budget.take("more", 20); tail != "" {
t.Fatalf("exhausted budget returned more text: %q", tail)
}
}