Skip to content

Commit

Permalink
std/net/udp: Improve set_nonblocking test
Browse files Browse the repository at this point in the history
  • Loading branch information
Tyler Julian committed Jan 11, 2017
1 parent 0500fbf commit 3038013
Showing 1 changed file with 16 additions and 4 deletions.
20 changes: 16 additions & 4 deletions src/libstd/net/udp.rs
Original file line number Diff line number Diff line change
Expand Up @@ -883,11 +883,23 @@ mod tests {

#[test]
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!(socket.connect(addr));

t!(stream.set_nonblocking(true));
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),
}
})
}
}

0 comments on commit 3038013

Please sign in to comment.