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

dont use is_numeric to check for digits

Signed-off-by: Hanif Bin Ariffin <hanif.ariffin.43262@gmail.com>
This commit is contained in:
Hanif Bin Ariffin 2022-02-03 20:17:53 +08:00 committed by Hanif Ariffin
parent ee721ebf4e
commit 3586465917
3 changed files with 11 additions and 1 deletions

View file

@ -19,7 +19,7 @@ pub fn parse_obsolete(src: &str) -> Option<Result<impl Iterator<Item = OsString>
let mut has_num = false;
let mut last_char = 0 as char;
for (n, c) in &mut chars {
if c.is_numeric() {
if c.is_digit(10) {
has_num = true;
num_end = n;
} else {

View file

@ -36,6 +36,12 @@ fn test_group_num() {
assert_eq!("", group_num(""));
}
#[test]
#[should_panic]
fn test_group_num_panic_if_invalid_numeric_characters() {
group_num("³³³³³");
}
#[cfg(test)]
mod test_generate_tokens {
use super::*;

View file

@ -491,6 +491,10 @@ fn test_tail_invalid_num() {
));
}
}
new_ucmd!()
.args(&["-c", ""])
.fails()
.stderr_is("tail: invalid number of bytes: '³'");
}
#[test]