Skip to content

Commit 5c13c69

Browse files
committed
Add tests for SocketAddrV6 ordering with scope_id and flowinfo
1 parent 963131e commit 5c13c69

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

library/core/tests/net/socket_addr.rs

+11
Original file line numberDiff line numberDiff line change
@@ -199,6 +199,9 @@ fn compare() {
199199
let v6_1 = "[2001:db8:f00::1002]:23456".parse::<SocketAddrV6>().unwrap();
200200
let v6_2 = "[2001:db8:f00::2001]:12345".parse::<SocketAddrV6>().unwrap();
201201
let v6_3 = "[2001:db8:f00::2001]:23456".parse::<SocketAddrV6>().unwrap();
202+
let v6_4 = "[2001:db8:f00::2001%42]:23456".parse::<SocketAddrV6>().unwrap();
203+
let mut v6_5 = "[2001:db8:f00::2001]:23456".parse::<SocketAddrV6>().unwrap();
204+
v6_5.set_flowinfo(17);
202205

203206
// equality
204207
assert_eq!(v4_1, v4_1);
@@ -207,6 +210,8 @@ fn compare() {
207210
assert_eq!(SocketAddr::V6(v6_1), SocketAddr::V6(v6_1));
208211
assert!(v4_1 != v4_2);
209212
assert!(v6_1 != v6_2);
213+
assert!(v6_3 != v6_4);
214+
assert!(v6_3 != v6_5);
210215

211216
// compare different addresses
212217
assert!(v4_1 < v4_2);
@@ -226,6 +231,12 @@ fn compare() {
226231
assert!(v4_3 > v4_1);
227232
assert!(v6_3 > v6_1);
228233

234+
// compare the same address with different scope_id
235+
assert!(v6_3 < v6_4);
236+
237+
// compare the same address with different flowinfo
238+
assert!(v6_3 < v6_5);
239+
229240
// compare with an inferred right-hand side
230241
assert_eq!(v4_1, "224.120.45.1:23456".parse().unwrap());
231242
assert_eq!(v6_1, "[2001:db8:f00::1002]:23456".parse().unwrap());

0 commit comments

Comments
 (0)