Skip to content

Commit 3038013

Browse files
author
Tyler Julian
committed
std/net/udp: Improve set_nonblocking test
1 parent 0500fbf commit 3038013

File tree

1 file changed

+16
-4
lines changed

1 file changed

+16
-4
lines changed

src/libstd/net/udp.rs

+16-4
Original file line numberDiff line numberDiff line change
@@ -883,11 +883,23 @@ mod tests {
883883

884884
#[test]
885885
fn set_nonblocking() {
886-
let addr = next_test_ip4();
886+
each_ip(&mut |addr, _| {
887+
let socket = t!(UdpSocket::bind(&addr));
887888

888-
let stream = t!(UdpSocket::bind(&addr));
889+
t!(socket.set_nonblocking(true));
890+
t!(socket.set_nonblocking(false));
891+
892+
t!(socket.connect(addr));
889893

890-
t!(stream.set_nonblocking(true));
891-
t!(stream.set_nonblocking(false));
894+
t!(socket.set_nonblocking(false));
895+
t!(socket.set_nonblocking(true));
896+
897+
let mut buf = [0];
898+
match socket.recv(&mut buf) {
899+
Ok(_) => panic!("expected error"),
900+
Err(ref e) if e.kind() == ErrorKind::WouldBlock => {}
901+
Err(e) => panic!("unexpected error {}", e),
902+
}
903+
})
892904
}
893905
}

0 commit comments

Comments
 (0)