// 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())
}
#[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]