]> git.lizzy.rs Git - rust.git/blobdiff - library/std/src/net/addr/tests.rs
Remove redundant 'static from library crates
[rust.git] / library / std / src / net / addr / tests.rs
index cee9087e13b32a24b536f950c0b8a1969dddf203..40f5a84bcd520a3f19e1eaf90a34c39daae45802 100644 (file)
@@ -68,7 +68,7 @@ fn bind_udp_socket_bad() {
     // returns its own address, it is still an error to bind a UDP socket to
     // a non-local address, and so we still get an error here in that case.
 
-    const INPUT_23076: &'static str = "1200::AB00:1234::2552:7777:1313:34300";
+    const INPUT_23076: &str = "1200::AB00:1234::2552:7777:1313:34300";
 
     assert!(crate::net::UdpSocket::bind(INPUT_23076).is_err())
 }
@@ -178,13 +178,21 @@ fn socket_v4_to_str() {
 
 #[test]
 fn socket_v6_to_str() {
-    let socket: SocketAddrV6 = "[2a02:6b8:0:1::1]:53".parse().unwrap();
+    let mut socket = SocketAddrV6::new(Ipv6Addr::new(0x2a02, 0x6b8, 0, 1, 0, 0, 0, 1), 53, 0, 0);
 
     assert_eq!(format!("{}", socket), "[2a02:6b8:0:1::1]:53");
     assert_eq!(format!("{:<24}", socket), "[2a02:6b8:0:1::1]:53    ");
     assert_eq!(format!("{:>24}", socket), "    [2a02:6b8:0:1::1]:53");
     assert_eq!(format!("{:^24}", socket), "  [2a02:6b8:0:1::1]:53  ");
     assert_eq!(format!("{:.15}", socket), "[2a02:6b8:0:1::");
+
+    socket.set_scope_id(5);
+
+    assert_eq!(format!("{}", socket), "[2a02:6b8:0:1::1%5]:53");
+    assert_eq!(format!("{:<24}", socket), "[2a02:6b8:0:1::1%5]:53  ");
+    assert_eq!(format!("{:>24}", socket), "  [2a02:6b8:0:1::1%5]:53");
+    assert_eq!(format!("{:^24}", socket), " [2a02:6b8:0:1::1%5]:53 ");
+    assert_eq!(format!("{:.18}", socket), "[2a02:6b8:0:1::1%5");
 }
 
 #[test]