mirror of
https://github.com/RGBCube/uutils-coreutils
synced 2025-07-27 11:07:44 +00:00
Merge pull request #2000 from paulotten/issue1999
Consistency with GNU version of `du` when doing `du -h` on an empty file
This commit is contained in:
commit
8d2e4e4b71
3 changed files with 13 additions and 0 deletions
|
@ -305,6 +305,9 @@ fn convert_size_human(size: u64, multiplier: u64, _block_size: u64) -> String {
|
|||
return format!("{:.1}{}", (size as f64) / (limit as f64), unit);
|
||||
}
|
||||
}
|
||||
if size == 0 {
|
||||
return format!("0");
|
||||
}
|
||||
format!("{}B", size)
|
||||
}
|
||||
|
||||
|
|
|
@ -162,3 +162,13 @@ fn _du_d_flag(s: String) {
|
|||
assert_eq!(s, "8\t./subdir\n8\t./\n");
|
||||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_du_h_flag_empty_file() {
|
||||
let ts = TestScenario::new("du");
|
||||
|
||||
let result = ts.ucmd().arg("-h").arg("empty.txt").run();
|
||||
assert!(result.success);
|
||||
assert_eq!(result.stderr, "");
|
||||
assert_eq!(result.stdout, "0\tempty.txt\n");
|
||||
}
|
||||
|
|
0
tests/fixtures/du/empty.txt
vendored
Normal file
0
tests/fixtures/du/empty.txt
vendored
Normal file
Loading…
Add table
Add a link
Reference in a new issue