MCPcopy Index your code
hub / github.com/codehamr/codehamr / TestTruncateLargeCollapses

Function TestTruncateLargeCollapses

internal/ctx/ctx_test.go:63–78  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

61}
62
63func TestTruncateLargeCollapses(t *testing.T) {
64 in := strings.Repeat("abcd", 8000) // 32000 chars ~= 8000 tokens
65 out := Truncate(in)
66 if !strings.Contains(out, "truncated") {
67 t.Fatalf("expected truncation marker, got %q", out)
68 }
69 if Tokens(out) > 2*ToolHeadTail+200 {
70 t.Fatalf("truncated output too large: %d tokens", Tokens(out))
71 }
72 if !strings.HasPrefix(out, in[:100]) {
73 t.Fatal("expected head preserved")
74 }
75 if !strings.HasSuffix(out, in[len(in)-100:]) {
76 t.Fatal("expected tail preserved")
77 }
78}
79
80// TestTruncateSnapsToRuneBoundary: Truncate's byte-offset cut must not slice
81// multi-byte runes mid-sequence: output stays valid UTF-8.

Callers

nothing calls this directly

Calls 2

TruncateFunction · 0.85
TokensFunction · 0.85

Tested by

no test coverage detected