From 3b36a48b7ce5a53a9366f3b31f94311f178e2553 Mon Sep 17 00:00:00 2001 From: Lukasz Kasprzak Date: Sat, 12 Sep 2026 01:22:12 +0200 Subject: krino: matching — scan, ignore, conditions, extraction, duplicates, explain, dry run MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- cmd/krino/sort_test.go | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) create mode 100644 cmd/krino/sort_test.go (limited to 'cmd/krino/sort_test.go') diff --git a/cmd/krino/sort_test.go b/cmd/krino/sort_test.go new file mode 100644 index 0000000..a646503 --- /dev/null +++ b/cmd/krino/sort_test.go @@ -0,0 +1,23 @@ +// 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) + } +} -- cgit v1.3