Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

std::net: Ipv4Addr and Ipv6Addr improvements #60145

Merged
merged 20 commits into from
Jun 1, 2019
Merged
Changes from 1 commit
Commits
Show all changes
20 commits
Select commit Hold shift + click to select a range
02d815f
std::net: site-local ipv6 prefixes are global
little-dude Nov 19, 2018
5aea184
std::net: improve Ipv6Addr::is_unicast_site_local() doc
little-dude Nov 19, 2018
1f0aa40
std::net: add Ipv6Addr::is_unicast_link_local_strict()
little-dude Nov 19, 2018
aea687c
std::net: fix doc markdown in Ipv6Addr::is_unique_local()
little-dude Nov 19, 2018
8f67997
std::net: add Ipv4Addr::is_reserved()
little-dude Nov 19, 2018
de3cf0d
std::net: add Ipv4Addr::is_benchmarking()
little-dude Nov 19, 2018
f87b967
std::net: add Ipv4Addr::is_ietf_protocol_assignment()
little-dude Nov 19, 2018
67291cc
std::net: add Ipv4Addr::is_shared()
little-dude Nov 19, 2018
9f6a747
std::net: fix Ipv4Addr::is_global()
little-dude Nov 19, 2018
8106320
std::net: fix documentation markdown
little-dude Nov 20, 2018
c34bcc6
std::net: use macros to test ip properties
little-dude Nov 20, 2018
c302d2c
std::net: fix Ipv4addr::is_global() tests
little-dude Apr 20, 2019
99d9bb6
std::net: fix tests for site-local ipv6 addresses
little-dude Apr 21, 2019
40d0127
std::net: tests for Ipv6addr::is_unicast_link_local{_strict}()
little-dude Apr 22, 2019
9dcfd9f
std::net: tests for Ipv4addr::is_benchmarking()
little-dude Apr 22, 2019
a2bead8
std::net: tests for Ipv4addr::is_ietf_protocol_assignment()
little-dude Apr 22, 2019
6662777
std::net: tests for Ipv4addr::is_reserved()
little-dude Apr 22, 2019
634dcd0
std::net: add warning in Ipv6Addr::is_unicast_site_local() doc
little-dude Apr 23, 2019
fe718ef
std::net: add warning in Ipv4addr::is_reserved() documentation
little-dude Apr 23, 2019
cddb838
std::net: tests for Ipv4addr::is_shared()
little-dude Apr 23, 2019
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
std::net: tests for Ipv4addr::is_benchmarking()
also add test to Ipaddr, making sure that these addresses are not
global.
  • Loading branch information
little-dude committed Apr 22, 2019
commit 9dcfd9f58ca808d586c186f983f5572667e56471
46 changes: 30 additions & 16 deletions src/libstd/net/ip.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2023,6 +2023,9 @@ mod tests {
check!("224.0.0.0", global|multicast);
check!("239.255.255.255", global|multicast);
check!("255.255.255.255");
check!("198.18.0.0");
check!("198.18.54.2");
check!("198.19.255.255");

check!("::", unspec);
check!("::1", loopback);
Expand Down Expand Up @@ -2058,14 +2061,15 @@ mod tests {
};

($s:expr, $mask:expr) => {{
let unspec: u8 = 1 << 0;
let loopback: u8 = 1 << 1;
let private: u8 = 1 << 2;
let link_local: u8 = 1 << 3;
let global: u8 = 1 << 4;
let multicast: u8 = 1 << 5;
let broadcast: u8 = 1 << 6;
let documentation: u8 = 1 << 7;
let unspec: u16 = 1 << 0;
let loopback: u16 = 1 << 1;
let private: u16 = 1 << 2;
let link_local: u16 = 1 << 3;
let global: u16 = 1 << 4;
let multicast: u16 = 1 << 5;
let broadcast: u16 = 1 << 6;
let documentation: u16 = 1 << 7;
let benchmarking: u16 = 1 << 8;

if ($mask & unspec) == unspec {
assert!(ip!($s).is_unspecified());
Expand Down Expand Up @@ -2114,17 +2118,24 @@ mod tests {
} else {
assert!(!ip!($s).is_documentation());
}

if ($mask & benchmarking) == benchmarking {
assert!(ip!($s).is_benchmarking());
} else {
assert!(!ip!($s).is_benchmarking());
}
}}
}

let unspec: u8 = 1 << 0;
let loopback: u8 = 1 << 1;
let private: u8 = 1 << 2;
let link_local: u8 = 1 << 3;
let global: u8 = 1 << 4;
let multicast: u8 = 1 << 5;
let broadcast: u8 = 1 << 6;
let documentation: u8 = 1 << 7;
let unspec: u16 = 1 << 0;
let loopback: u16 = 1 << 1;
let private: u16 = 1 << 2;
let link_local: u16 = 1 << 3;
let global: u16 = 1 << 4;
let multicast: u16 = 1 << 5;
let broadcast: u16 = 1 << 6;
let documentation: u16 = 1 << 7;
let benchmarking: u16 = 1 << 8;

check!("0.0.0.0", unspec);
check!("0.0.0.1");
Expand All @@ -2142,6 +2153,9 @@ mod tests {
check!("224.0.0.0", global|multicast);
check!("239.255.255.255", global|multicast);
check!("255.255.255.255", broadcast);
check!("198.18.0.0", benchmarking);
check!("198.18.54.2", benchmarking);
check!("198.19.255.255", benchmarking);
}

#[test]
Expand Down