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 }
81 if Tokens(out) > ToolTruncHead+ToolTruncTail+200 {
82 t.Fatalf("truncated output too large: %d tokens", Tokens(out))
83 }
84 if !strings.HasPrefix(out, in[:100]) {
85 t.Fatal("expected head preserved")
86 }
87 if !strings.HasSuffix(out, in[len(in)-100:]) {
88 t.Fatal("expected tail preserved")
89 }
90 // Tail bias: errors sit at the end of long output, so the kept tail must be
91 // larger than the kept head (the spill file covers the dropped middle).
92 if ToolTruncTail <= ToolTruncHead {
93 t.Fatalf("truncation must keep more tail than head, got head=%d tail=%d", ToolTruncHead, ToolTruncTail)
94 }

Callers

nothing calls this directly

Calls 1

TruncateFunction · 0.85

Tested by

no test coverage detected