summaryrefslogtreecommitdiffstats
path: root/third_party/rust/mio/test/test_smoke.rs
blob: 96f7d3c9e40fff36a4cd9a4c8726e939418d81e6 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
extern crate mio;

use mio::{Events, Poll, Token, Ready, PollOpt};
use mio::net::TcpListener;
use std::time::Duration;

#[test]
fn run_once_with_nothing() {
    let mut events = Events::with_capacity(1024);
    let poll = Poll::new().unwrap();
    poll.poll(&mut events, Some(Duration::from_millis(100))).unwrap();
}

#[test]
fn add_then_drop() {
    let mut events = Events::with_capacity(1024);
    let l = TcpListener::bind(&"127.0.0.1:0".parse().unwrap()).unwrap();
    let poll = Poll::new().unwrap();
    poll.register(&l, Token(1), Ready::readable() | Ready::writable(), PollOpt::edge()).unwrap();
    drop(l);
    poll.poll(&mut events, Some(Duration::from_millis(100))).unwrap();

}