fix test for is_hostname_port_str

This commit is contained in:
qiushiyang 2023-01-18 03:35:13 +00:00
parent f10f969c2c
commit 12d446b217

View File

@ -347,19 +347,20 @@ mod test_lib {
assert_eq!(is_ipv6_str("[1:2::0]:"), false);
assert_eq!(is_ipv6_str("1:2::0]:1"), false);
}
#[test]
fn test_hostname_port() {
assert_eq!(is_ipv6_str("a:12"), true);
assert_eq!(is_ipv6_str("a.b.c:12"), true);
assert_eq!(is_ipv6_str("test.com:12"), true);
assert_eq!(is_ipv6_str("1.2.3:12"), true);
assert_eq!(is_ipv6_str("a.b.c:123456"), false);
assert_eq!(is_hostname_port_str("a:12"), true);
assert_eq!(is_hostname_port_str("a.b.c:12"), true);
assert_eq!(is_hostname_port_str("test.com:12"), true);
assert_eq!(is_hostname_port_str("1.2.3:12"), true);
assert_eq!(is_hostname_port_str("a.b.c:123456"), false);
// todo: should we also check for these edge case?
// out-of-range port
assert_eq!(is_ipv6_str("test.com:0"), true);
assert_eq!(is_ipv6_str("test.com:98989"), true);
assert_eq!(is_hostname_port_str("test.com:0"), true);
assert_eq!(is_hostname_port_str("test.com:98989"), true);
// invalid hostname
assert_eq!(is_ipv6_str("---:12"), true);
assert_eq!(is_ipv6_str(".:12"), true);
assert_eq!(is_hostname_port_str("---:12"), true);
assert_eq!(is_hostname_port_str(".:12"), true);
}
}