mirror of
https://github.com/RGBCube/uutils-coreutils
synced 2025-07-28 11:37:44 +00:00
seq: compute width of numbers after parsing
Fix a bug in `seq` where the number of characters needed to print the number was computed incorrectly in some cases. This commit changes the computation of the width to be after parsing the number instead of before, in order to accommodate inputs like `1e3`, which requires four digits when printing the number, not three.
This commit is contained in:
parent
64a65370b0
commit
5cd55391ec
2 changed files with 78 additions and 6 deletions
|
@ -158,3 +158,21 @@ fn test_drop_negative_zero_end() {
|
|||
.stdout_is("1\n0\n")
|
||||
.no_stderr();
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_width_scientific_notation() {
|
||||
new_ucmd!()
|
||||
.args(&["-w", "999", "1e3"])
|
||||
.succeeds()
|
||||
.stdout_is("0999\n1000\n")
|
||||
.no_stderr();
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_width_negative_zero() {
|
||||
new_ucmd!()
|
||||
.args(&["-w", "-0", "1"])
|
||||
.succeeds()
|
||||
.stdout_is("-0\n01\n")
|
||||
.no_stderr();
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue