@@ -736,6 +736,15 @@ mod tests {
736
736
assert_eq ! ( err. 0 , ErrorKind :: InvalidAuthority ) ;
737
737
}
738
738
739
+ #[ test]
740
+ fn allows_from_simplest_ipv4 ( ) {
741
+ let localhost0 = SocketAddr :: new ( IpAddr :: V4 ( Ipv4Addr :: new ( 127 , 0 , 0 , 1 ) ) , 0 ) ;
742
+
743
+ let auth1: Authority = Authority :: from_sockaddr ( localhost0) . unwrap ( ) ;
744
+ assert_eq ! ( auth1. port( ) , None ) ;
745
+ assert_eq ! ( auth1. host( ) , "127.0.0.1" ) ;
746
+ }
747
+
739
748
#[ test]
740
749
fn allows_from_simple_ipv4 ( ) {
741
750
let localhost8080 = SocketAddr :: new ( IpAddr :: V4 ( Ipv4Addr :: new ( 127 , 0 , 0 , 1 ) ) , 8080 ) ;
@@ -755,6 +764,19 @@ mod tests {
755
764
assert_eq ! ( auth1. host( ) , "[2001:db8::1]" ) ;
756
765
}
757
766
767
+ #[ test]
768
+ fn allows_from_scoped_ipv6 ( ) {
769
+ let example0scope2 = SocketAddrV6 :: new ( Ipv6Addr :: new ( 0x2001 , 0x0db8 , 0 , 0 ,
770
+ 0 , 0 , 0 , 1 ) ,
771
+ 0 , /* port number */
772
+ 0 , /* flowid */
773
+ 2 /* scopeid */ ) ;
774
+ let auth1: Authority = Authority :: from_sockaddr ( std:: net:: SocketAddr :: V6 ( example0scope2) ) . unwrap ( ) ;
775
+ assert_eq ! ( auth1. port( ) , None ) ;
776
+ assert_eq ! ( auth1. host( ) , "[2001:db8::1%2]" ) ;
777
+
778
+ }
779
+
758
780
#[ test]
759
781
fn allows_from_complex_ipv6 ( ) {
760
782
let example8080scope1 = SocketAddrV6 :: new ( Ipv6Addr :: new ( 0x2001 , 0x0db8 , 0 , 0 ,
0 commit comments