MCPcopy Create free account
hub / github.com/codehamr/codehamr / TestTruncateSnapsToRuneBoundary

Function TestTruncateSnapsToRuneBoundary

internal/ctx/ctx_test.go:82–91  ·  view source on GitHub ↗

TestTruncateSnapsToRuneBoundary: Truncate's byte-offset cut must not slice multi-byte runes mid-sequence: output stays valid UTF-8.

(t *testing.T)

Source from the content-addressed store, hash-verified

80// TestTruncateSnapsToRuneBoundary: Truncate's byte-offset cut must not slice
81// multi-byte runes mid-sequence: output stays valid UTF-8.
82func TestTruncateSnapsToRuneBoundary(t *testing.T) {
83 in := strings.Repeat("ä", 20000) // 2 bytes each, 40000 bytes total = 10000 tokens
84 out := Truncate(in)
85 if !strings.Contains(out, "truncated") {
86 t.Fatalf("expected truncation marker, got %q", out[:80])
87 }
88 if !utf8.ValidString(out) {
89 t.Fatal("Truncate produced invalid UTF-8 - slice landed mid-rune")
90 }
91}
92
93func TestPackNewestFirstWhole(t *testing.T) {
94 big := strings.Repeat("a", 4*1000) // 1000 tokens

Callers

nothing calls this directly

Calls 1

TruncateFunction · 0.85

Tested by

no test coverage detected