diff --git a/src/apple/macos/system.rs b/src/apple/macos/system.rs index 1fbe13fc0..bf1fb233d 100644 --- a/src/apple/macos/system.rs +++ b/src/apple/macos/system.rs @@ -137,3 +137,29 @@ impl SystemTimeInfo { } } } + +#[cfg(test)] +mod test { + + use super::*; + + /// Regression test for . + #[test] + fn test_getting_time_interval() { + if !crate::System::IS_SUPPORTED || cfg!(feature = "apple-sandbox") { + return; + } + + let port = unsafe { libc::mach_host_self() }; + let mut info = SystemTimeInfo::new(port).unwrap(); + info.get_time_interval(port); + + std::thread::sleep(crate::System::MINIMUM_CPU_UPDATE_INTERVAL.saturating_mul(2)); + + let val = info.get_time_interval(port); + assert!( + val > crate::System::MINIMUM_CPU_UPDATE_INTERVAL.as_secs_f64() * 1_000_000_000.0 + / info.timebase_to_ns + ); + } +}