mirror of
https://github.com/BaaRai/ARTEX.git
synced 2026-11-13 11:40:53 +08:00
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
28 lines
636 B
Go
28 lines
636 B
Go
package db
|
|
|
|
import (
|
|
"strings"
|
|
"testing"
|
|
"unicode/utf8"
|
|
)
|
|
|
|
func TestTruncateUTF8PreservesValidEncoding(t *testing.T) {
|
|
t.Parallel()
|
|
input := strings.Repeat("ü: insufficient quota; ", 400)
|
|
got := truncateUTF8(input, 1000)
|
|
if len(got) > 1000 {
|
|
t.Fatalf("truncated value has %d bytes, want at most 1000", len(got))
|
|
}
|
|
if !utf8.ValidString(got) {
|
|
t.Fatalf("truncated value is not valid UTF-8: %q", got[len(got)-8:])
|
|
}
|
|
}
|
|
|
|
func TestTruncateUTF8RepairsInvalidInput(t *testing.T) {
|
|
t.Parallel()
|
|
got := truncateUTF8("bad\xffvalue", 1000)
|
|
if !utf8.ValidString(got) {
|
|
t.Fatalf("repaired value is not valid UTF-8: %q", got)
|
|
}
|
|
}
|