Add tests ensuring zero-Duration timeouts result in errors.
Part of https://github.com/rust-lang/rust/issues/48311
This commit is contained in:
@@ -1024,6 +1024,23 @@ mod tests {
|
||||
assert!(start.elapsed() > Duration::from_millis(400));
|
||||
}
|
||||
|
||||
// Ensure the `set_read_timeout` and `set_write_timeout` calls return errors
|
||||
// when passed zero Durations
|
||||
#[test]
|
||||
fn test_timeout_zero_duration() {
|
||||
let addr = next_test_ip4();
|
||||
|
||||
let socket = t!(UdpSocket::bind(&addr));
|
||||
|
||||
let result = socket.set_write_timeout(Some(Duration::new(0, 0)));
|
||||
let err = result.unwrap_err();
|
||||
assert_eq!(err.kind(), ErrorKind::InvalidInput);
|
||||
|
||||
let result = socket.set_read_timeout(Some(Duration::new(0, 0)));
|
||||
let err = result.unwrap_err();
|
||||
assert_eq!(err.kind(), ErrorKind::InvalidInput);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn connect_send_recv() {
|
||||
let addr = next_test_ip4();
|
||||
|
||||
Reference in New Issue
Block a user