mirror of
https://github.com/RGBCube/uutils-coreutils
synced 2025-07-28 03:27:44 +00:00
seq: correct width for certain negative decimals
Fix a bug in which a negative decimal input would not be displayed with the correct width in the output. Before this commit, the output was incorrectly $ seq -w -.1 .1 .11 -0.1 0.0 0.1 After this commit, the output is correctly $ seq -w -.1 .1 .11 -0.1 00.0 00.1 The code was failing to take into account that the input decimal "-.1" needs to be displayed with a leading zero, like "-0.1".
This commit is contained in:
parent
5c0adb26a5
commit
294bde8e08
2 changed files with 90 additions and 4 deletions
|
@ -473,6 +473,15 @@ fn test_width_decimal_scientific_notation_trailing_zeros_increment() {
|
|||
.no_stderr();
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_width_negative_decimal_notation() {
|
||||
new_ucmd!()
|
||||
.args(&["-w", "-.1", ".1", ".11"])
|
||||
.succeeds()
|
||||
.stdout_is("-0.1\n00.0\n00.1\n")
|
||||
.no_stderr();
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_width_negative_scientific_notation() {
|
||||
new_ucmd!()
|
||||
|
@ -480,6 +489,54 @@ fn test_width_negative_scientific_notation() {
|
|||
.succeeds()
|
||||
.stdout_is("-0.001\n00.999\n")
|
||||
.no_stderr();
|
||||
new_ucmd!()
|
||||
.args(&["-w", "-1.e-3", "1"])
|
||||
.succeeds()
|
||||
.stdout_is("-0.001\n00.999\n")
|
||||
.no_stderr();
|
||||
new_ucmd!()
|
||||
.args(&["-w", "-1.0e-4", "1"])
|
||||
.succeeds()
|
||||
.stdout_is("-0.00010\n00.99990\n")
|
||||
.no_stderr();
|
||||
new_ucmd!()
|
||||
.args(&["-w", "-.1e2", "10", "100"])
|
||||
.succeeds()
|
||||
.stdout_is(
|
||||
"-010
|
||||
0000
|
||||
0010
|
||||
0020
|
||||
0030
|
||||
0040
|
||||
0050
|
||||
0060
|
||||
0070
|
||||
0080
|
||||
0090
|
||||
0100
|
||||
",
|
||||
)
|
||||
.no_stderr();
|
||||
new_ucmd!()
|
||||
.args(&["-w", "-0.1e2", "10", "100"])
|
||||
.succeeds()
|
||||
.stdout_is(
|
||||
"-010
|
||||
0000
|
||||
0010
|
||||
0020
|
||||
0030
|
||||
0040
|
||||
0050
|
||||
0060
|
||||
0070
|
||||
0080
|
||||
0090
|
||||
0100
|
||||
",
|
||||
)
|
||||
.no_stderr();
|
||||
}
|
||||
|
||||
/// Test that trailing zeros in the end argument do not contribute to width.
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue