diff options
Diffstat (limited to 'library/std/src/net/ip/tests.rs')
| -rw-r--r-- | library/std/src/net/ip/tests.rs | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/library/std/src/net/ip/tests.rs b/library/std/src/net/ip/tests.rs index 76a0ae8b945..d9fbdd1b5e7 100644 --- a/library/std/src/net/ip/tests.rs +++ b/library/std/src/net/ip/tests.rs @@ -918,3 +918,22 @@ fn ipv6_const() { const IP_V4: Option<Ipv4Addr> = IP_ADDRESS.to_ipv4(); assert_eq!(IP_V4.unwrap(), Ipv4Addr::new(0, 0, 0, 1)); } + +#[test] +fn ip_const() { + // test that the methods of `IpAddr` are usable in a const context + + const IP_ADDRESS: IpAddr = IpAddr::V4(Ipv4Addr::LOCALHOST); + + const IS_UNSPECIFIED: bool = IP_ADDRESS.is_unspecified(); + assert!(!IS_UNSPECIFIED); + + const IS_LOOPBACK: bool = IP_ADDRESS.is_loopback(); + assert!(IS_LOOPBACK); + + const IS_GLOBAL: bool = IP_ADDRESS.is_global(); + assert!(!IS_GLOBAL); + + const IS_MULTICAST: bool = IP_ADDRESS.is_multicast(); + assert!(!IS_MULTICAST); +} |
