First Commit
ci / go (push) Waiting to run
ci / go-db (agent) (push) Waiting to run
ci / go-db (config) (push) Waiting to run
ci / go-db (db) (push) Waiting to run
ci / go-db (evidence) (push) Waiting to run
ci / go-db (llmrec) (push) Waiting to run
ci / go-db (server) (push) Waiting to run
web / web (push) Waiting to run
docs / links (push) Canceled after 0s
detections / detections (push) Canceled after 0s

This commit is contained in:
dela
2026-10-09 08:38:16 +08:00
commit 0335d572de
756 changed files with 201663 additions and 0 deletions
+27
View File
@@ -0,0 +1,27 @@
package db
import (
"strings"
"testing"
"unicode/utf8"
)
func TestTruncateUTF8PreservesValidEncoding(t *testing.T) {
t.Parallel()
input := strings.Repeat("额度不足", 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)
}
}