TestTruncateSnapsToRuneBoundary: Truncate's byte-offset cut must not slice multi-byte runes mid-sequence: output stays valid UTF-8.
(t *testing.T)
| 80 | // TestTruncateSnapsToRuneBoundary: Truncate's byte-offset cut must not slice |
| 81 | // multi-byte runes mid-sequence: output stays valid UTF-8. |
| 82 | func 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 | |
| 93 | func TestPackNewestFirstWhole(t *testing.T) { |
| 94 | big := strings.Repeat("a", 4*1000) // 1000 tokens |
nothing calls this directly
no test coverage detected