@@ -735,6 +735,15 @@ mod tests {
735735 assert_eq ! ( err. 0 , ErrorKind :: InvalidAuthority ) ;
736736 }
737737
738+ #[ test]
739+ fn allows_from_simplest_ipv4 ( ) {
740+ let localhost0 = SocketAddr :: new ( IpAddr :: V4 ( Ipv4Addr :: new ( 127 , 0 , 0 , 1 ) ) , 0 ) ;
741+
742+ let auth1: Authority = Authority :: from_sockaddr ( localhost0) . unwrap ( ) ;
743+ assert_eq ! ( auth1. port( ) , None ) ;
744+ assert_eq ! ( auth1. host( ) , "127.0.0.1" ) ;
745+ }
746+
738747 #[ test]
739748 fn allows_from_simple_ipv4 ( ) {
740749 let localhost8080 = SocketAddr :: new ( IpAddr :: V4 ( Ipv4Addr :: new ( 127 , 0 , 0 , 1 ) ) , 8080 ) ;
@@ -754,6 +763,19 @@ mod tests {
754763 assert_eq ! ( auth1. host( ) , "[2001:db8::1]" ) ;
755764 }
756765
766+ #[ test]
767+ fn allows_from_scoped_ipv6 ( ) {
768+ let example0scope2 = SocketAddrV6 :: new ( Ipv6Addr :: new ( 0x2001 , 0x0db8 , 0 , 0 ,
769+ 0 , 0 , 0 , 1 ) ,
770+ 0 , /* port number */
771+ 0 , /* flowid */
772+ 2 /* scopeid */ ) ;
773+ let auth1: Authority = Authority :: from_sockaddr ( std:: net:: SocketAddr :: V6 ( example0scope2) ) . unwrap ( ) ;
774+ assert_eq ! ( auth1. port( ) , None ) ;
775+ assert_eq ! ( auth1. host( ) , "[2001:db8::1%2]" ) ;
776+
777+ }
778+
757779 #[ test]
758780 fn allows_from_complex_ipv6 ( ) {
759781 let example8080scope1 = SocketAddrV6 :: new ( Ipv6Addr :: new ( 0x2001 , 0x0db8 , 0 , 0 ,
0 commit comments