Remove padding from table and add test

This commit is contained in:
Foorack 2025-02-08 17:06:33 +01:00
parent 34d22a8b50
commit 4b4f4932f7
2 changed files with 21 additions and 0 deletions
src/uu/lsmem/src
tests/by-util

@ -499,6 +499,17 @@ fn print_table(lsmem: &Lsmem, opts: &Options) {
.with(Style::blank())
.with(Modify::new(object::Columns::new(1..)).with(Alignment::right()));
// Remove padding in beginning and end of table
table.get_config_mut().set_padding(
tabled::grid::config::Entity::Global,
tabled::grid::config::Sides::new(
tabled::grid::config::Indent::default(),
tabled::grid::config::Indent::default(),
tabled::grid::config::Indent::default(),
tabled::grid::config::Indent::default(),
),
);
// the default version
table.with(Remove::column(ByColumnName::new("NODE")));
table.with(Remove::column(ByColumnName::new("ZONES")));

@ -9,3 +9,13 @@ use crate::common::util::TestScenario;
fn test_invalid_arg() {
new_ucmd!().arg("--definitely-invalid").fails().code_is(1);
}
#[test]
fn test_table_not_padded() {
let result = new_ucmd!().succeeds();
let stdout = result.code_is(0).stdout_str();
assert!(
!stdout.starts_with(' '),
"Table output should not start with a space"
);
}