forked from hegeldev/hegel-rust
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest_time.rs
More file actions
38 lines (33 loc) · 996 Bytes
/
test_time.rs
File metadata and controls
38 lines (33 loc) · 996 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
mod common;
use common::utils::assert_all_examples;
use hegel::generators;
use std::time::{Duration, Instant};
#[test]
fn test_durations_default() {
assert_all_examples(generators::durations(), |d| *d >= Duration::ZERO);
}
#[test]
fn test_durations_bounded() {
let min = Duration::from_secs(5);
let max = Duration::from_secs(60);
assert_all_examples(
generators::durations().min_value(min).max_value(max),
move |d| *d >= min && *d <= max,
);
}
#[test]
fn test_instants_default() {
let before = Instant::now();
let max_offset = Duration::from_secs(3600);
assert_all_examples(generators::instants(), move |i| {
*i >= before && *i <= Instant::now() + max_offset
});
}
#[test]
fn test_instants_bounded() {
let max_offset = Duration::from_secs(10);
let before = Instant::now();
assert_all_examples(generators::instants().max_offset(max_offset), move |i| {
*i >= before && *i <= Instant::now() + max_offset
});
}