Debian Codegraph @

debian/rust-vendor/futures-timer/tests/timeout.rs

raw
1 use std::error::Error;
2 use std::time::{Duration, Instant};
3
4 use futures_timer::Delay;
5
6 #[async_std::test]
7 async fn smoke() -> Result<(), Box<dyn Error + Send + Sync + 'static>> {
8 let dur = Duration::from_millis(10);
9 let start = Instant::now();
10 Delay::new(dur).await;
11 assert!(start.elapsed() >= (dur / 2));
12 Ok(())
13 }
14
15 #[async_std::test]
16 async fn two() -> Result<(), Box<dyn Error + Send + Sync + 'static>> {
17 let dur = Duration::from_millis(10);
18 Delay::new(dur).await;
19 Delay::new(dur).await;
20 Ok(())
21 }