diff options
| author | Christiaan Dirkx <christiaan@dirkx.email> | 2020-09-01 21:58:35 +0200 |
|---|---|---|
| committer | Christiaan Dirkx <christiaan@dirkx.email> | 2020-09-01 21:58:35 +0200 |
| commit | fb64e6dcf0a7ea0518c8f2d499327a2b6974f859 (patch) | |
| tree | 3d73e0eb83db460938237e4b26c15cd0dc38d854 | |
| parent | ee9e48bafcc9667f08027e50ed84578e9861a456 (diff) | |
| download | rust-fb64e6dcf0a7ea0518c8f2d499327a2b6974f859.tar.gz rust-fb64e6dcf0a7ea0518c8f2d499327a2b6974f859.zip | |
Add test for `Ipv4Addr` methods in a const context
| -rw-r--r-- | src/test/ui/consts/std/net/ipv4.rs | 41 |
1 files changed, 41 insertions, 0 deletions
diff --git a/src/test/ui/consts/std/net/ipv4.rs b/src/test/ui/consts/std/net/ipv4.rs new file mode 100644 index 00000000000..eca42f297e5 --- /dev/null +++ b/src/test/ui/consts/std/net/ipv4.rs @@ -0,0 +1,41 @@ +// run-pass + +#![feature(ip)] +#![feature(const_ipv4)] + +use std::net::Ipv4Addr; + +fn main() { + const IP_ADDRESS: Ipv4Addr = Ipv4Addr::new(127, 0, 0, 1); + assert_eq!(IP_ADDRESS, Ipv4Addr::LOCALHOST); + + const OCTETS: [u8; 4] = IP_ADDRESS.octets(); + assert_eq!(OCTETS, [127, 0, 0, 1]); + + const IS_UNSPECIFIED : bool = IP_ADDRESS.is_unspecified(); + assert!(!IS_UNSPECIFIED); + + const IS_LOOPBACK : bool = IP_ADDRESS.is_loopback(); + assert!(IS_LOOPBACK); + + const IS_PRIVATE : bool = IP_ADDRESS.is_private(); + assert!(!IS_PRIVATE); + + const IS_LINK_LOCAL : bool = IP_ADDRESS.is_link_local(); + assert!(!IS_LINK_LOCAL); + + const IS_SHARED : bool = IP_ADDRESS.is_shared(); + assert!(!IS_SHARED); + + const IS_IETF_PROTOCOL_ASSIGNMENT : bool = IP_ADDRESS.is_ietf_protocol_assignment(); + assert!(!IS_IETF_PROTOCOL_ASSIGNMENT); + + const IS_BENCHMARKING : bool = IP_ADDRESS.is_benchmarking(); + assert!(!IS_BENCHMARKING); + + const IS_MULTICAST : bool = IP_ADDRESS.is_multicast(); + assert!(!IS_MULTICAST); + + const IS_DOCUMENTATION : bool = IP_ADDRESS.is_documentation(); + assert!(!IS_DOCUMENTATION); +} |
