diff --git a/tests/uds.rs b/tests/uds.rs index 9dbda87..e160ad7 100644 --- a/tests/uds.rs +++ b/tests/uds.rs @@ -22,3 +22,21 @@ fn send_recv() -> io::Result<()> { Ok(()) }) } + +#[test] +fn into_raw_fd() -> io::Result<()> { + use async_std::os::unix::io::{FromRawFd, IntoRawFd}; + task::block_on(async { + let (socket1, socket2) = UnixDatagram::pair().unwrap(); + socket1.send(JULIUS_CAESAR).await?; + + let mut buf = vec![0; 1024]; + + let socket2 = unsafe { UnixDatagram::from_raw_fd(socket2.into_raw_fd()) }; + let n = socket2.recv(&mut buf).await?; + assert_eq!(&buf[..n], JULIUS_CAESAR); + + Ok(()) + }) + +}