-
Notifications
You must be signed in to change notification settings - Fork 130
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Share test durations between all tests
- Loading branch information
Showing
6 changed files
with
57 additions
and
50 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
use cfg_if::cfg_if; | ||
|
||
cfg_if! { | ||
if #[cfg(test)] { | ||
pub(crate) mod timeout; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
use std::time::Duration; | ||
|
||
/// A sequence of strongly monotonic inrceasing durations. Introduced for testing conversions from | ||
/// `Duration` to platform-specific types. | ||
pub(crate) const MONOTONIC_DURATIONS: [Duration; 17] = [ | ||
Duration::ZERO, | ||
Duration::from_nanos(1), | ||
Duration::from_millis(1), | ||
Duration::from_secs(1), | ||
Duration::from_secs(i16::MAX as u64 - 1), | ||
Duration::from_secs(i16::MAX as u64), | ||
Duration::from_secs(i16::MAX as u64 + 1), | ||
Duration::from_secs(i32::MAX as u64 - 1), | ||
Duration::from_secs(i32::MAX as u64), | ||
Duration::from_secs(i32::MAX as u64 + 1), | ||
Duration::from_secs(i64::MAX as u64 - 1), | ||
Duration::from_secs(i64::MAX as u64), | ||
Duration::from_secs(i64::MAX as u64 + 1), | ||
Duration::from_secs(u64::MAX - 1), | ||
Duration::from_secs(u64::MAX), | ||
Duration::new(u64::MAX, 1_000_000), | ||
Duration::MAX, | ||
]; | ||
|
||
#[cfg(test)] | ||
mod tests { | ||
use super::*; | ||
|
||
#[test] | ||
fn basic_durations_properties() { | ||
assert_eq!(Duration::ZERO, *MONOTONIC_DURATIONS.first().unwrap()); | ||
assert_eq!(Duration::MAX, *MONOTONIC_DURATIONS.last().unwrap()); | ||
|
||
// Check that this array is monotonic. | ||
let mut last = MONOTONIC_DURATIONS[0]; | ||
for next in MONOTONIC_DURATIONS { | ||
assert!(last <= next); | ||
last = next; | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters