Files
any2anexoj/internal/writing/internal/tabledef/table_test.go
T
natercio 5c146ad60f
Generate check / check-changes (pull_request) Successful in 2s
Generate check / verify-generate (pull_request) Skipped
Quality / check-changes (pull_request) Successful in 2s
Quality / static-checks (pull_request) Failing after 13s
Quality / run-tests (pull_request) Failing after 54s
better domain isolation
2026-10-05 15:08:26 +01:00

25 lines
941 B
Go

package tabledef
import "testing"
func TestTruncateHeader(t *testing.T) {
tests := []struct {
name string
val string
width int
want string
}{
{name: "fits unchanged", val: "TAX PAID ABROAD", width: 15, want: "TAX PAID ABROAD"},
{name: "cut mid-word keeps the most runes", val: "EXPENSES AND CHARGES", width: 15, want: "EXPENSES AND C…"},
{name: "single overlong word is hard cut", val: "ESTRANGEIRO", width: 8, want: "ESTRANG…"},
{name: "cut ignores word boundaries", val: "IMPOSTO PAGO NO ESTRANGEIRO", width: 15, want: "IMPOSTO PAGO N…"},
{name: "multibyte runes count as one", val: "PAÍS DA CONTRAPARTE", width: 12, want: "PAÍS DA CON…"},
{name: "narrow width", val: "ABCD", width: 2, want: "A…"},
}
for _, tt := range tests {
if got := truncateHeader(tt.val, tt.width); got != tt.want {
t.Errorf("%s: truncateHeader(%q, %d) = %q, want %q", tt.name, tt.val, tt.width, got, tt.want)
}
}
}