// SPDX-License-Identifier: GPL-3.0-or-later package main import "testing" // TestRelWidthAndPadCellCountRunes: C4. relWidth and padCell must measure // column width in runes, not bytes, or a name carrying diacritics // misaligns its column - "próba.txt" is 9 runes but 10 bytes (ó is a // two-byte UTF-8 sequence), one column narrower than its byte length // would suggest. func TestRelWidthAndPadCellCountRunes(t *testing.T) { rels := []string{"a.txt", "próba.txt"} if w := relWidth(rels); w != 9 { t.Fatalf("relWidth(%q) = %d, want 9 (rune count of próba.txt, not its %d bytes)", rels, w, len("próba.txt")) } if got, want := padCell("a.txt", 9), "a.txt "; got != want { t.Fatalf("padCell(%q, 9) = %q, want %q", "a.txt", got, want) } if got, want := padCell("próba.txt", 9), "próba.txt"; got != want { t.Fatalf("padCell(%q, 9) = %q, want %q (already at width: no padding)", "próba.txt", got, want) } }