Skip to content

Commit 4180f5b

Browse files
committed
ls: add regression test for uutils_term_grid off-by-one in column layout
1 parent 995c9e0 commit 4180f5b

1 file changed

Lines changed: 38 additions & 0 deletions

File tree

tests/by-util/test_ls.rs

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -950,6 +950,44 @@ fn test_ls_across() {
950950
}
951951
}
952952

953+
#[test]
954+
fn test_ls_across_single_row() {
955+
// Regression test: uutils_term_grid had an off-by-one bug where the column-search
956+
// loop used `..cells.len()` (exclusive) instead of `..=cells.len()` (inclusive),
957+
// preventing it from ever trying to fit all items on one row.
958+
// See: https://github.com/uutils/uutils-term-grid/pull/57
959+
// https://github.com/eza-community/eza/issues/1738
960+
let scene = TestScenario::new(util_name!());
961+
let at = &scene.fixtures;
962+
for name in &[
963+
"code",
964+
"Desktop",
965+
"Documents",
966+
"Downloads",
967+
"Music",
968+
"Pictures",
969+
"Public",
970+
"Templates",
971+
"Videos",
972+
] {
973+
at.touch(name);
974+
}
975+
976+
// With width=96 and LC_ALL=C sort order all 9 entries (79 chars total) fit on one line.
977+
// GNU ls produces: "Desktop Documents Downloads Music Pictures Public Templates Videos code"
978+
for option in ACROSS_ARGS {
979+
scene
980+
.ucmd()
981+
.env("LC_ALL", "C")
982+
.arg(option)
983+
.arg("--width=96")
984+
.succeeds()
985+
.stdout_only(
986+
"Desktop Documents Downloads Music Pictures Public Templates Videos code\n",
987+
);
988+
}
989+
}
990+
953991
#[test]
954992
fn test_ls_commas() {
955993
let scene = TestScenario::new(util_name!());

0 commit comments

Comments
 (0)