1
Fork 0
mirror of https://github.com/RGBCube/uutils-coreutils synced 2025-07-28 03:27:44 +00:00

fix(seq): handle 0e... scientific notation without padding (#6934)

* fix(seq): handle 0e... scientific notation without padding

- Updated the parse_exponent_no_decimal function to treat 0e... as zero.
- Added test cases to verify correct behavior for 0e15 and -w 0e15.

Fix: #6926

* fix(seq): improved parse for accurate BigDecimal handling

* apply missing cargo fmt formatting adjustments
This commit is contained in:
aimerlief 2024-12-08 00:42:34 +09:00 committed by GitHub
parent f7c38a3079
commit 367cc19d45
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 48 additions and 2 deletions

View file

@ -842,3 +842,31 @@ fn test_invalid_format() {
.no_stdout()
.stderr_contains("format '%g%g' has too many % directives");
}
#[test]
fn test_parse_scientific_zero() {
new_ucmd!()
.args(&["0e15", "1"])
.succeeds()
.stdout_only("0\n1\n");
new_ucmd!()
.args(&["0.0e15", "1"])
.succeeds()
.stdout_only("0\n1\n");
new_ucmd!()
.args(&["0", "1"])
.succeeds()
.stdout_only("0\n1\n");
new_ucmd!()
.args(&["-w", "0e15", "1"])
.succeeds()
.stdout_only("0000000000000000\n0000000000000001\n");
new_ucmd!()
.args(&["-w", "0.0e15", "1"])
.succeeds()
.stdout_only("0000000000000000\n0000000000000001\n");
new_ucmd!()
.args(&["-w", "0", "1"])
.succeeds()
.stdout_only("0\n1\n");
}