mirror of
https://github.com/RGBCube/uutils-coreutils
synced 2025-07-28 11:37:44 +00:00
uucore: format: Pad non-finite numbers with spaces, not zeros
`printf "%05.2f" inf` should print ` inf`, not `00inf`. Add a test to cover that case, too.
This commit is contained in:
parent
ec450d602a
commit
25c492ee19
2 changed files with 27 additions and 2 deletions
|
@ -990,6 +990,23 @@ fn float_flag_position_space_padding() {
|
|||
.stdout_only(" +1.0");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn float_non_finite_space_padding() {
|
||||
new_ucmd!()
|
||||
.args(&["% 5.2f|% 5.2f|% 5.2f|% 5.2f", "inf", "-inf", "nan", "-nan"])
|
||||
.succeeds()
|
||||
.stdout_only(" inf| -inf| nan| -nan");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn float_non_finite_zero_padding() {
|
||||
// Zero-padding pads non-finite numbers with spaces.
|
||||
new_ucmd!()
|
||||
.args(&["%05.2f|%05.2f|%05.2f|%05.2f", "inf", "-inf", "nan", "-nan"])
|
||||
.succeeds()
|
||||
.stdout_only(" inf| -inf| nan| -nan");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn float_abs_value_less_than_one() {
|
||||
new_ucmd!()
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue