mirror of
https://github.com/RGBCube/uutils-coreutils
synced 2025-07-28 03:27:44 +00:00
uucore: format: num_parser: Add value to Overflow error
When parsing integers, we should still return the min/max value of the type (depending on the type), and wrap that in the error. We need to refactor the map function to handle this case better, and add an extract function to get the value out of an error (if any). This fixes the integer part of #7508.
This commit is contained in:
parent
9872263a96
commit
1e104b7ef9
3 changed files with 107 additions and 42 deletions
|
@ -675,6 +675,19 @@ fn test_overflow() {
|
|||
new_ucmd!()
|
||||
.args(&["%d", "36893488147419103232"])
|
||||
.fails_with_code(1)
|
||||
.stdout_is("9223372036854775807")
|
||||
.stderr_is("printf: '36893488147419103232': Numerical result out of range\n");
|
||||
|
||||
new_ucmd!()
|
||||
.args(&["%d", "-36893488147419103232"])
|
||||
.fails_with_code(1)
|
||||
.stdout_is("-9223372036854775808")
|
||||
.stderr_is("printf: '-36893488147419103232': Numerical result out of range\n");
|
||||
|
||||
new_ucmd!()
|
||||
.args(&["%u", "36893488147419103232"])
|
||||
.fails_with_code(1)
|
||||
.stdout_is("18446744073709551615")
|
||||
.stderr_is("printf: '36893488147419103232': Numerical result out of range\n");
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue