1
Fork 0
mirror of https://github.com/RGBCube/uutils-coreutils synced 2025-08-01 21:47:46 +00:00

Merge pull request #2439 from tertsdiepraam/numfmt/round-and-c-locale

`numfmt`: add `--round` and other minor improvements
This commit is contained in:
Sylvestre Ledru 2021-06-24 21:18:59 +02:00 committed by GitHub
commit ab5d581fa4
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
6 changed files with 139 additions and 59 deletions

View file

@ -481,3 +481,27 @@ fn test_delimiter_with_padding_and_fields() {
.succeeds()
.stdout_only(" 1.0K| 2.0K\n");
}
#[test]
fn test_round() {
for (method, exp) in &[
("from-zero", ["9.1K", "-9.1K", "9.1K", "-9.1K"]),
("towards-zero", ["9.0K", "-9.0K", "9.0K", "-9.0K"]),
("up", ["9.1K", "-9.0K", "9.1K", "-9.0K"]),
("down", ["9.0K", "-9.1K", "9.0K", "-9.1K"]),
("nearest", ["9.0K", "-9.0K", "9.1K", "-9.1K"]),
] {
new_ucmd!()
.args(&[
"--to=si",
&format!("--round={}", method),
"--",
"9001",
"-9001",
"9099",
"-9099",
])
.succeeds()
.stdout_only(exp.join("\n") + "\n");
}
}