mirror of
https://github.com/RGBCube/uutils-coreutils
synced 2025-07-28 03:27:44 +00:00
printf: trim leading whitespace when parsing numeric values
Trim leading whitespace from numeric input to printf.
This commit is contained in:
parent
af7411a933
commit
1a0bc30f17
2 changed files with 66 additions and 3 deletions
|
@ -1053,3 +1053,29 @@ fn float_switch_switch_decimal_scientific() {
|
|||
.succeeds()
|
||||
.stdout_only("1e-05");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn float_arg_with_whitespace() {
|
||||
new_ucmd!()
|
||||
.args(&["%f", " \u{0020}\u{000d}\t\n0.000001"])
|
||||
.succeeds()
|
||||
.stdout_only("0.000001");
|
||||
|
||||
new_ucmd!()
|
||||
.args(&["%f", "0.1 "])
|
||||
.fails()
|
||||
.stderr_contains("value not completely converted");
|
||||
|
||||
// Unicode whitespace should not be allowed in a number
|
||||
new_ucmd!()
|
||||
.args(&["%f", "\u{2029}0.1"])
|
||||
.fails()
|
||||
.stderr_contains("expected a numeric value");
|
||||
|
||||
// A input string with a whitespace special character that has
|
||||
// not already been expanded should fail.
|
||||
new_ucmd!()
|
||||
.args(&["%f", "\\t0.1"])
|
||||
.fails()
|
||||
.stderr_contains("expected a numeric value");
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue