Adds panic test to hashset delay

This commit is contained in:
Age Manning
2020-04-28 14:31:00 +10:00
parent d432378a3c
commit 281502396f
2 changed files with 30 additions and 0 deletions

View File

@@ -7,3 +7,6 @@ edition = "2018"
[dependencies]
futures = "0.3.4"
tokio = { version = "0.2.19", features = ["time"] }
[dev-dependencies]
tokio = { version = "0.2.19", features = ["time", "rt-threaded", "macros"] }

View File

@@ -163,3 +163,30 @@ where
}
}
}
#[cfg(test)]
mod tests {
use super::*;
#[tokio::test]
async fn should_not_panic() {
let key = 2u8;
let mut map = HashSetDelay::default();
map.insert(key);
map.update_timeout(&key, Duration::from_secs(100));
let fut = |cx: &mut Context| {
let _ = map.poll_next_unpin(cx);
let _ = map.poll_next_unpin(cx);
Poll::Ready(())
};
future::poll_fn(fut).await;
map.insert(key);
map.update_timeout(&key, Duration::from_secs(100));
}
}