(t *testing.T)
| 370 | } |
| 371 | |
| 372 | func TestParseDiff_Truncation(t *testing.T) { |
| 373 | t.Parallel() |
| 374 | // Build a diff that exceeds maxDiffLines |
| 375 | var b strings.Builder |
| 376 | b.WriteString("@@ -1,20000 +1,20000 @@\n") |
| 377 | for range maxDiffLines + 10 { |
| 378 | b.WriteString("+line\n") |
| 379 | } |
| 380 | parsed := ParseDiff(b.String()) |
| 381 | // Should be capped at maxDiffLines+1 (the truncation marker) |
| 382 | if len(parsed.Lines) > maxDiffLines+2 { |
| 383 | t.Errorf("expected truncation, got %d lines", len(parsed.Lines)) |
| 384 | } |
| 385 | // Last line should be the truncation marker |
| 386 | last := parsed.Lines[len(parsed.Lines)-1] |
| 387 | if last.Type != LineHunkHeader || !strings.Contains(last.Content, "truncated") { |
| 388 | t.Errorf("expected truncation marker, got %+v", last) |
| 389 | } |
| 390 | } |
| 391 | |
| 392 | // --- Render functions --- |
| 393 |
nothing calls this directly
no test coverage detected