From 024c0d7ddefc5458911242d61a89f44b5a3b5a38 Mon Sep 17 00:00:00 2001 From: Kyle Huey Date: Wed, 27 Apr 2022 18:27:03 -0700 Subject: Restore conversions from ip v4/6 Sockaddr types to std::net equivalents. Fixes #1710 --- test/sys/test_socket.rs | 13 +++++++++++++ 1 file changed, 13 insertions(+) (limited to 'test/sys/test_socket.rs') 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::*; -- cgit v1.2.3