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

uucore: error on negative interval in parse_time

Return an error when a negative interval is provided as the argument
to `uucore::parse_time::from_str()`, since a `Duration` should only be
non-negative.
This commit is contained in:
Jeffrey Finkelstein 2022-03-20 15:35:32 -04:00
parent 5eeac5881a
commit f4af226820
3 changed files with 25 additions and 0 deletions

View file

@ -149,3 +149,11 @@ fn test_sum_overflow() {
.no_stderr()
.no_stdout();
}
#[test]
fn test_negative_interval() {
new_ucmd!()
.args(&["--", "-1"])
.fails()
.usage_error("invalid time interval '-1'");
}