use std::{thread::sleep as thread_sleep, time::Duration};
use tokio::time::sleep as task_sleep;
use testtools::{task, thread};
#[test]
fn test1ms() {
thread::expect_runtime(Duration::from_millis(1), || {
thread_sleep(Duration::from_millis(1));
});
}
#[test]
fn test200ms() {
thread::expect_runtime(Duration::from_millis(200), || {
thread_sleep(Duration::from_millis(200));
});
}
#[test]
fn test500ms() {
thread::expect_runtime(Duration::from_millis(500), || {
thread_sleep(Duration::from_millis(500));
});
}
#[tokio::test]
async fn async_test1ms() {
task::expect_runtime(Duration::from_millis(1), async {
task_sleep(Duration::from_millis(1)).await;
})
.await;
}
#[tokio::test]
async fn async_test200ms() {
task::expect_runtime(Duration::from_millis(200), async {
task_sleep(Duration::from_millis(200)).await;
})
.await;
}
#[tokio::test]
async fn async_test500ms() {
task::expect_runtime(Duration::from_millis(500), async {
task_sleep(Duration::from_millis(500)).await;
})
.await;
}