1
Fork 0
mirror of https://github.com/RGBCube/uutils-coreutils synced 2025-09-16 03:36:18 +00:00

Merge pull request #3764 from cakebaker/numfmt_preserve_trailing_zeros

numfmt: preserve trailing zeros
This commit is contained in:
Sylvestre Ledru 2022-08-01 13:32:55 +02:00 committed by GitHub
commit 9b81e09f7a
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 63 additions and 8 deletions

View file

@ -10,6 +10,14 @@ fn test_should_not_round_floats() {
.stdout_is("0.99\n1.01\n1.1\n1.22\n0.1\n-0.1\n");
}
#[test]
fn test_should_preserve_trailing_zeros() {
new_ucmd!()
.args(&["0.1000", "10.00"])
.succeeds()
.stdout_is("0.1000\n10.00\n");
}
#[test]
fn test_from_si() {
new_ucmd!()
@ -823,6 +831,18 @@ fn test_format_with_precision_and_to_arg() {
}
}
#[test]
fn test_format_preserve_trailing_zeros_if_no_precision_is_specified() {
let values = vec!["10.0", "0.0100"];
for value in values {
new_ucmd!()
.args(&["--format=%f", value])
.succeeds()
.stdout_is(format!("{}\n", value));
}
}
#[test]
fn test_format_without_percentage_directive() {
let invalid_formats = vec!["", "hello"];