mirror of
https://github.com/uutils/procps.git
synced 2026-06-10 16:14:00 -07:00
+1
-1
@@ -53,7 +53,7 @@ feat_common_core = [
|
||||
[workspace.dependencies]
|
||||
bytesize = "2.0.0"
|
||||
chrono = { version = "0.4.38", default-features = false, features = ["clock"] }
|
||||
clap = { version = "4.5.4", features = ["wrap_help", "cargo"] }
|
||||
clap = { version = "4.5.4", features = ["wrap_help", "cargo", "env"] }
|
||||
clap_complete = "4.5.2"
|
||||
clap_mangen = "0.2.20"
|
||||
crossterm = "0.29.0"
|
||||
|
||||
@@ -19,7 +19,12 @@ fn parse_interval(input: &str) -> Result<Duration, ParseIntError> {
|
||||
// Find index where to split string into seconds and nanos
|
||||
let Some(index) = input.find([',', '.']) else {
|
||||
let seconds: u64 = input.parse()?;
|
||||
return Ok(Duration::new(seconds, 0));
|
||||
|
||||
return if seconds == 0 {
|
||||
Ok(Duration::from_millis(100))
|
||||
} else {
|
||||
Ok(Duration::new(seconds, 0))
|
||||
};
|
||||
};
|
||||
|
||||
// If the seconds string is empty, set seconds to 0
|
||||
@@ -250,4 +255,16 @@ mod parse_interval_tests {
|
||||
let interval = parse_interval("1.00000000000a");
|
||||
assert!(interval.is_err())
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_minimum_seconds() {
|
||||
let interval = parse_interval("0");
|
||||
assert_eq!(Ok(Duration::from_millis(100)), interval);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_minimum_nanos() {
|
||||
let interval = parse_interval("0.0");
|
||||
assert_eq!(Ok(Duration::from_millis(100)), interval);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user