Macro lifeline::assert_completes [−][src]
Asserts that the expression completes within a given number of milliseconds.
This will invoke the panic!
macro if the provided future
expression fails to complete within the given number of
milliseconds. This macro expands to an await
and must be
invoked inside an async context.
A default timeout of 50ms is used if no duration is passed.
Examples
use lifeline::assert_completes; use tokio::time::sleep; async { // Succeeds because default time is longer than delay. assert_completes!(sleep(Duration::from_millis(5))); }
ⓘ
use lifeline::assert_completes; use tokio::time::sleep; async { // Fails because timeout is shorter than delay. assert_completes!(sleep(Duration::from_millis(250)), 10); }