mirror of
https://github.com/RGBCube/uutils-coreutils
synced 2025-07-28 11:37:44 +00:00
cut: fail when the input == usize::MAX
This commit is contained in:
parent
4038907de6
commit
99120d32c1
2 changed files with 10 additions and 0 deletions
|
@ -38,6 +38,8 @@ impl FromStr for Range {
|
|||
fn parse(s: &str) -> Result<usize, &'static str> {
|
||||
match s.parse::<usize>() {
|
||||
Ok(0) => Err("fields and positions are numbered from 1"),
|
||||
// GNU fails when we are at the limit. Match their behavior
|
||||
Ok(n) if n == usize::MAX => Err("byte/character offset is too large"),
|
||||
Ok(n) => Ok(n),
|
||||
Err(_) => Err("failed to parse range"),
|
||||
}
|
||||
|
|
|
@ -117,6 +117,14 @@ fn test_whitespace_with_char() {
|
|||
.code_is(1);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_too_large() {
|
||||
new_ucmd!()
|
||||
.args(&["-b1-18446744073709551615", "/dev/null"])
|
||||
.fails()
|
||||
.code_is(1);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_specify_delimiter() {
|
||||
for param in ["-d", "--delimiter", "--del"] {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue