33 lines
632 B
Rust
33 lines
632 B
Rust
use std::io;
|
|
use std::time::{Duration, Instant};
|
|
|
|
use polling::Poller;
|
|
|
|
#[test]
|
|
fn twice() -> io::Result<()> {
|
|
let poller = Poller::new()?;
|
|
let mut events = Vec::new();
|
|
|
|
for _ in 0..2 {
|
|
let start = Instant::now();
|
|
poller.wait(&mut events, Some(Duration::from_secs(1)))?;
|
|
let elapsed = start.elapsed();
|
|
|
|
assert!(elapsed >= Duration::from_secs(1));
|
|
}
|
|
|
|
Ok(())
|
|
}
|
|
|
|
#[test]
|
|
fn non_blocking() -> io::Result<()> {
|
|
let poller = Poller::new()?;
|
|
let mut events = Vec::new();
|
|
|
|
for _ in 0..100 {
|
|
poller.wait(&mut events, Some(Duration::from_secs(0)))?;
|
|
}
|
|
|
|
Ok(())
|
|
}
|