Skip to content

Commit

Permalink
Add tests for SocketAddrV6 ordering with scope_id and flowinfo
Browse files Browse the repository at this point in the history
  • Loading branch information
WaffleLapkin committed Oct 15, 2023
1 parent 963131e commit 5c13c69
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions library/core/tests/net/socket_addr.rs
Original file line number Diff line number Diff line change
Expand Up @@ -199,6 +199,9 @@ fn compare() {
let v6_1 = "[2001:db8:f00::1002]:23456".parse::<SocketAddrV6>().unwrap();
let v6_2 = "[2001:db8:f00::2001]:12345".parse::<SocketAddrV6>().unwrap();
let v6_3 = "[2001:db8:f00::2001]:23456".parse::<SocketAddrV6>().unwrap();
let v6_4 = "[2001:db8:f00::2001%42]:23456".parse::<SocketAddrV6>().unwrap();
let mut v6_5 = "[2001:db8:f00::2001]:23456".parse::<SocketAddrV6>().unwrap();
v6_5.set_flowinfo(17);

// equality
assert_eq!(v4_1, v4_1);
Expand All @@ -207,6 +210,8 @@ fn compare() {
assert_eq!(SocketAddr::V6(v6_1), SocketAddr::V6(v6_1));
assert!(v4_1 != v4_2);
assert!(v6_1 != v6_2);
assert!(v6_3 != v6_4);
assert!(v6_3 != v6_5);

// compare different addresses
assert!(v4_1 < v4_2);
Expand All @@ -226,6 +231,12 @@ fn compare() {
assert!(v4_3 > v4_1);
assert!(v6_3 > v6_1);

// compare the same address with different scope_id
assert!(v6_3 < v6_4);

// compare the same address with different flowinfo
assert!(v6_3 < v6_5);

// compare with an inferred right-hand side
assert_eq!(v4_1, "224.120.45.1:23456".parse().unwrap());
assert_eq!(v6_1, "[2001:db8:f00::1002]:23456".parse().unwrap());
Expand Down

0 comments on commit 5c13c69

Please sign in to comment.