std/net/udp: Improve set_nonblocking test

This commit is contained in:
Tyler Julian
2017-01-10 22:06:17 -08:00
parent 0500fbf6ba
commit 30380137f8

View File

@@ -883,11 +883,23 @@ mod tests {
#[test] #[test]
fn set_nonblocking() { fn set_nonblocking() {
let addr = next_test_ip4(); each_ip(&mut |addr, _| {
let socket = t!(UdpSocket::bind(&addr));
let stream = t!(UdpSocket::bind(&addr)); t!(socket.set_nonblocking(true));
t!(socket.set_nonblocking(false));
t!(stream.set_nonblocking(true)); t!(socket.connect(addr));
t!(stream.set_nonblocking(false));
t!(socket.set_nonblocking(false));
t!(socket.set_nonblocking(true));
let mut buf = [0];
match socket.recv(&mut buf) {
Ok(_) => panic!("expected error"),
Err(ref e) if e.kind() == ErrorKind::WouldBlock => {}
Err(e) => panic!("unexpected error {}", e),
}
})
} }
} }