mirror of
https://github.com/RGBCube/uutils-coreutils
synced 2025-07-28 11:37:44 +00:00
Merge pull request #3732 from cakebaker/numfmt_auto_suf_si_i
numfmt: show "invalid suffix" error for "i" suffix
This commit is contained in:
commit
ba24565b60
2 changed files with 11 additions and 6 deletions
|
@ -79,7 +79,7 @@ fn parse_suffix(s: &str) -> Result<(f64, Option<Suffix>)> {
|
||||||
Some('E') => Some((RawSuffix::E, with_i)),
|
Some('E') => Some((RawSuffix::E, with_i)),
|
||||||
Some('Z') => Some((RawSuffix::Z, with_i)),
|
Some('Z') => Some((RawSuffix::Z, with_i)),
|
||||||
Some('Y') => Some((RawSuffix::Y, with_i)),
|
Some('Y') => Some((RawSuffix::Y, with_i)),
|
||||||
Some('0'..='9') => None,
|
Some('0'..='9') if !with_i => None,
|
||||||
_ => return Err(format!("invalid suffix in input: {}", s.quote())),
|
_ => return Err(format!("invalid suffix in input: {}", s.quote())),
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -208,11 +208,16 @@ fn test_should_report_invalid_empty_number_on_blank_stdin() {
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn test_should_report_invalid_suffix_on_stdin() {
|
fn test_should_report_invalid_suffix_on_stdin() {
|
||||||
new_ucmd!()
|
for c in b'a'..=b'z' {
|
||||||
.args(&["--from=auto"])
|
new_ucmd!()
|
||||||
.pipe_in("1k")
|
.args(&["--from=auto"])
|
||||||
.run()
|
.pipe_in(format!("1{}", c as char))
|
||||||
.stderr_is("numfmt: invalid suffix in input: '1k'\n");
|
.run()
|
||||||
|
.stderr_is(format!(
|
||||||
|
"numfmt: invalid suffix in input: '1{}'\n",
|
||||||
|
c as char
|
||||||
|
));
|
||||||
|
}
|
||||||
|
|
||||||
// GNU numfmt reports this one as “invalid number”
|
// GNU numfmt reports this one as “invalid number”
|
||||||
new_ucmd!()
|
new_ucmd!()
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue