about summary refs log tree commit diff
path: root/src/libstd
diff options
context:
space:
mode:
authorCorentin Henry <corentinhenry@gmail.com>2019-04-22 16:00:58 +0200
committerCorentin Henry <corentinhenry@gmail.com>2019-04-22 17:41:43 +0200
commita2bead8761306a46079edc8cc7cff84b85d8f891 (patch)
treeb7737c8d6130c8945a6bf12b6ff25d4243496d82 /src/libstd
parent9dcfd9f58ca808d586c186f983f5572667e56471 (diff)
downloadrust-a2bead8761306a46079edc8cc7cff84b85d8f891.tar.gz
rust-a2bead8761306a46079edc8cc7cff84b85d8f891.zip
std::net: tests for Ipv4addr::is_ietf_protocol_assignment()
Also add tests to IpAddr to make sure these addresses are not global.
Diffstat (limited to 'src/libstd')
-rw-r--r--src/libstd/net/ip.rs16
1 files changed, 16 insertions, 0 deletions
diff --git a/src/libstd/net/ip.rs b/src/libstd/net/ip.rs
index 5e93a6c1e86..4ff47257c3f 100644
--- a/src/libstd/net/ip.rs
+++ b/src/libstd/net/ip.rs
@@ -2023,9 +2023,14 @@ mod tests {
         check!("224.0.0.0", global|multicast);
         check!("239.255.255.255", global|multicast);
         check!("255.255.255.255");
+        // make sure benchmarking addresses are not global
         check!("198.18.0.0");
         check!("198.18.54.2");
         check!("198.19.255.255");
+        // make sure addresses reserved for protocol assignment are not global
+        check!("192.0.0.0");
+        check!("192.0.0.255");
+        check!("192.0.0.100");
 
         check!("::", unspec);
         check!("::1", loopback);
@@ -2070,6 +2075,7 @@ mod tests {
                 let broadcast: u16 = 1 << 6;
                 let documentation: u16 = 1 << 7;
                 let benchmarking: u16 = 1 << 8;
+                let ietf_protocol_assignment: u16 = 1 << 9;
 
                 if ($mask & unspec) == unspec {
                     assert!(ip!($s).is_unspecified());
@@ -2124,6 +2130,12 @@ mod tests {
                 } else {
                     assert!(!ip!($s).is_benchmarking());
                 }
+
+                if ($mask & ietf_protocol_assignment) == ietf_protocol_assignment {
+                    assert!(ip!($s).is_ietf_protocol_assignment());
+                } else {
+                    assert!(!ip!($s).is_ietf_protocol_assignment());
+                }
             }}
         }
 
@@ -2136,6 +2148,7 @@ mod tests {
         let broadcast: u16 = 1 << 6;
         let documentation: u16 = 1 << 7;
         let benchmarking: u16 = 1 << 8;
+        let ietf_protocol_assignment: u16 = 1 << 9;
 
         check!("0.0.0.0", unspec);
         check!("0.0.0.1");
@@ -2156,6 +2169,9 @@ mod tests {
         check!("198.18.0.0", benchmarking);
         check!("198.18.54.2", benchmarking);
         check!("198.19.255.255", benchmarking);
+        check!("192.0.0.0", ietf_protocol_assignment);
+        check!("192.0.0.255", ietf_protocol_assignment);
+        check!("192.0.0.100", ietf_protocol_assignment);
     }
 
     #[test]