testtools 0.1.3

Helpers for eliminating boilerplate code in tests
Documentation
use std::{future::Future, time::Instant};

/// Time execution of a closure, and panic if the measured time is lower than
/// the expected runtime.
///
/// `edur` is the expected duration.
pub async fn expect_runtime<F>(edur: std::time::Duration, fut: F)
where
  F: Future<Output = ()> + Send + 'static
{
  let start = Instant::now();

  fut.await;

  let dur = Instant::now() - start;

  assert!(dur > edur);
}

// vim: set ft=rust et sw=2 ts=2 sts=2 cinoptions=2 tw=79 :