Tests for TargetPorts::display()

This commit is contained in:
Nick Mathewson 2022-02-04 16:41:32 -05:00
parent c43f494b44
commit f08c0268bc
1 changed files with 12 additions and 1 deletions

View File

@ -68,7 +68,7 @@ impl Display for TargetPort {
}
}
/// Set of requestedd target ports, mostly for use in error reporting
/// Set of requested target ports, mostly for use in error reporting
///
/// Displays nicely.
#[derive(Debug, Clone, Default)]
@ -831,4 +831,15 @@ mod test {
assert!(!some_isolation.may_share_circuit(&some_isolation2));
assert!(some_isolation.may_share_circuit(&some_isolation));
}
#[test]
fn display_target_ports() {
let ports = [];
assert_eq!(TargetPorts::from(&ports[..]).to_string(), "[]");
let ports = [TargetPort::ipv4(80)];
assert_eq!(TargetPorts::from(&ports[..]).to_string(), "80v4");
let ports = [TargetPort::ipv4(80), TargetPort::ipv6(443)];
assert_eq!(TargetPorts::from(&ports[..]).to_string(), "[80v4,443v6]");
}
}