aboutsummaryrefslogtreecommitdiff
path: root/cmd/krino/sort_test.go
diff options
context:
space:
mode:
authorLukasz Kasprzak <lukas@labunix.xyz>2026-09-12 01:22:12 +0200
committerLukasz Kasprzak <lukas@labunix.xyz>2026-09-12 01:22:12 +0200
commit3b36a48b7ce5a53a9366f3b31f94311f178e2553 (patch)
treeecbb277ff916b719f2ee45fba017792b85d5faf9 /cmd/krino/sort_test.go
parent42b02c47be9b285099203e44a2570636d4ca6f03 (diff)
downloadkrino-3b36a48b7ce5a53a9366f3b31f94311f178e2553.tar.gz
krino-3b36a48b7ce5a53a9366f3b31f94311f178e2553.zip
krino: matching — scan, ignore, conditions, extraction, duplicates, explain, dry run
Diffstat (limited to 'cmd/krino/sort_test.go')
-rw-r--r--cmd/krino/sort_test.go23
1 files changed, 23 insertions, 0 deletions
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)
+ }
+}