diff options
author | Kyle Huey <khuey@kylehuey.com> | 2022-04-27 18:27:03 -0700 |
---|---|---|
committer | Kyle Huey <khuey@kylehuey.com> | 2022-05-02 08:53:08 -0700 |
commit | 024c0d7ddefc5458911242d61a89f44b5a3b5a38 (patch) | |
tree | 0612d9c58f530664ad93be6a07aeeb748358ac6a /test/sys/test_socket.rs | |
parent | 4d79e93904b5f679ea14c382e778404fab306dd0 (diff) | |
download | nix-024c0d7ddefc5458911242d61a89f44b5a3b5a38.zip |
Restore conversions from ip v4/6 Sockaddr types to std::net equivalents.
Fixes #1710
Diffstat (limited to 'test/sys/test_socket.rs')
-rw-r--r-- | test/sys/test_socket.rs | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/test/sys/test_socket.rs b/test/sys/test_socket.rs index 2aac7958..c742960a 100644 --- a/test/sys/test_socket.rs +++ b/test/sys/test_socket.rs @@ -257,6 +257,19 @@ pub fn test_socketpair() { assert_eq!(&buf[..], b"hello"); } +#[test] +pub fn test_std_conversions() { + use nix::sys::socket::*; + + let std_sa = SocketAddrV4::from_str("127.0.0.1:6789").unwrap(); + let sock_addr = SockaddrIn::from(std_sa); + assert_eq!(std_sa, sock_addr.into()); + + let std_sa = SocketAddrV6::from_str("[::1]:6000").unwrap(); + let sock_addr: SockaddrIn6 = SockaddrIn6::from(std_sa); + assert_eq!(std_sa, sock_addr.into()); +} + mod recvfrom { use nix::Result; use nix::sys::socket::*; |