in quic/s2n-quic-core/src/inet/ipv4.rs [759:805]
fn scope_test() {
let g = produce::<[u8; 4]>().map_gen(IpV4Address::from);
check!().with_generator(g).cloned().for_each(|subject| {
use ip::UnicastScope::*;
let expected = std::net::Ipv4Addr::from(subject);
// Several IP methods are blocked behind `feature(ip)`: https://github.com/rust-lang/rust/issues/27709
//
// Use the `ip_network` crate to fill any gaps
let network = ip_network::Ipv4Network::from(expected);
match subject.unicast_scope() {
Some(Global) => {
// ip_network has a bug in the `is_global` logic. Remove this once its fixed
// and published
// https://github.com/JakubOnderka/ip_network/pull/7
if subject.octets == [192, 0, 0, 9] || subject.octets == [192, 0, 0, 10] {
return;
}
assert!(network.is_global());
}
Some(Private) => {
assert!(expected.is_private() || network.is_shared_address_space());
}
Some(Loopback) => {
assert!(expected.is_loopback());
}
Some(LinkLocal) => {
assert!(expected.is_link_local());
}
None => {
assert!(
expected.is_broadcast()
|| expected.is_multicast()
|| expected.is_documentation()
|| network.is_benchmarking()
|| network.is_ietf_protocol_assignments()
|| network.is_reserved()
|| network.is_local_identification()
|| network.is_unspecified()
);
}
}
})
}