summaryrefslogtreecommitdiffstats
path: root/crates/common/tedge_config/src/models
diff options
context:
space:
mode:
authorMatthias Beyer <matthias.beyer@ifm.com>2022-03-07 07:52:49 +0100
committerMatthias Beyer <matthias.beyer@ifm.com>2022-03-07 08:02:01 +0100
commit398bf563022c90657760518edfe746d7a431f8c7 (patch)
treece0288952778b656a31d76365144b2d1e88e7b8f /crates/common/tedge_config/src/models
parent82b4f44dbd75c8f99e9112cdf4c8007250f4930c (diff)
Move tests into module
Signed-off-by: Matthias Beyer <matthias.beyer@ifm.com>
Diffstat (limited to 'crates/common/tedge_config/src/models')
-rw-r--r--crates/common/tedge_config/src/models/ipaddress.rs50
1 files changed, 28 insertions, 22 deletions
diff --git a/crates/common/tedge_config/src/models/ipaddress.rs b/crates/common/tedge_config/src/models/ipaddress.rs
index 2c03eba0..9bcaa36f 100644
--- a/crates/common/tedge_config/src/models/ipaddress.rs
+++ b/crates/common/tedge_config/src/models/ipaddress.rs
@@ -51,30 +51,36 @@ impl From<IpAddress> for IpAddr {
}
#[cfg(test)]
-use assert_matches::*;
-use std::net::Ipv6Addr;
+mod tests {
+ use super::InvalidIpAddress;
+ use super::IpAddress;
+ use assert_matches::*;
+ use std::net::IpAddr;
+ use std::net::Ipv4Addr;
+ use std::net::Ipv6Addr;
-#[test]
-fn conversion_from_valid_ipv4_succeeds() {
- let _loh: IpAddress = IpAddress::try_from("127.0.0.1".to_string()).unwrap();
- assert_matches!(Ipv4Addr::LOCALHOST, _loh);
-}
+ #[test]
+ fn conversion_from_valid_ipv4_succeeds() {
+ let _loh: IpAddress = IpAddress::try_from("127.0.0.1".to_string()).unwrap();
+ assert_matches!(Ipv4Addr::LOCALHOST, _loh);
+ }
-#[test]
-fn conversion_from_valid_ipv6_succeeds() {
- let _loh: IpAddress = IpAddress::try_from("::1".to_string()).unwrap();
- assert_matches!(Ipv6Addr::LOCALHOST, _loh);
-}
+ #[test]
+ fn conversion_from_valid_ipv6_succeeds() {
+ let _loh: IpAddress = IpAddress::try_from("::1".to_string()).unwrap();
+ assert_matches!(Ipv6Addr::LOCALHOST, _loh);
+ }
-#[test]
-fn conversion_from_longer_integer_fails() {
- assert_matches!(
- IpAddress::try_from("66000".to_string()),
- Err(InvalidIpAddress { .. })
- );
-}
+ #[test]
+ fn conversion_from_longer_integer_fails() {
+ assert_matches!(
+ IpAddress::try_from("66000".to_string()),
+ Err(InvalidIpAddress { .. })
+ );
+ }
-#[test]
-fn conversion_from_ip_to_string() {
- assert_matches!(TryInto::<String>::try_into(IpAddress(IpAddr::V6(Ipv6Addr::new(0, 0, 0, 0, 0, 0, 0, 1)))), Ok(ip_str) if ip_str == "::1");
+ #[test]
+ fn conversion_from_ip_to_string() {
+ assert_matches!(TryInto::<String>::try_into(IpAddress(IpAddr::V6(Ipv6Addr::new(0, 0, 0, 0, 0, 0, 0, 1)))), Ok(ip_str) if ip_str == "::1");
+ }
}