Repository: diesel-rs/diesel
File: diesel_tests/tests/types.rs (Rust)

Code before:
fn pg_macaddress_to_sql_macaddress() {
    let expected_value = "'08:00:2b:01:02:03'::macaddr";
    let value = [0x08, 0x00, 0x2b, 0x01, 0x02, 0x03];
    assert!(query_to_sql_equality::<MacAddr, [u8; 6]>(
        expected_value,
        value
    ));
}

#[test]
#[cfg(feature = "postgres")]
fn pg_macaddress8_from_sql() {
    let query = "'08:00:2b:01:02:03:04:05'::macaddr8";
    let expected_value = [0x08, 0x00, 0x2b, 0x01, 0x02, 0x03, 0x04, 0x05];
    assert_eq!(
        expected_value,
        query_single_value::<MacAddr, [u8; 8]>(query)
    );
}

#[test]
#[cfg(feature = "postgres")]
fn pg_macaddress8_to_sql_macaddress() {
    let expected_value = "'08:00:2b:01:02:03:04:05'::macaddr8";
    let value = [0x08, 0x00, 0x2b, 0x01, 0x02, 0x03, 0x04, 0x05];
    assert!(query_to_sql_equality::<MacAddr, [u8; 8]>(
        expected_value,
        value
    ));
}

#[test]
#[cfg(feature = "postgres")]
fn pg_v4address_from_sql() {
    extern crate ipnetwork;
    use std::str::FromStr;

    let query = "'192.168.1.0/24'::cidr";
    let expected_value =
        ipnetwork::IpNetwork::V4(ipnetwork::Ipv4Network::from_str("192.168.1.0/24").unwrap());
    assert_eq!(
        expected_value,
        query_single_value::<Cidr, ipnetwork::IpNetwork>(query)
    );
    let query = "'192.168.1.0/24'::inet";
    let expected_value =
        ipnetwork::IpNetwork::V4(ipnetwork::Ipv4Network::from_str("192.168.1.0/24").unwrap());
    assert_eq!(
        expected_value,
        query_single_value::<Inet, ipnetwork::IpNetwork>(query)
    );

Review comment (suggestion):
```suggestion
    assert!(query_to_sql_equality::<MacAddr8, [u8; 8]>(
```

Code after:
fn pg_macaddress_to_sql_macaddress() {
    let expected_value = "'08:00:2b:01:02:03'::macaddr";
    let value = [0x08, 0x00, 0x2b, 0x01, 0x02, 0x03];
    assert!(query_to_sql_equality::<MacAddr, [u8; 6]>(
        expected_value,
        value
    ));
}

#[test]
#[cfg(feature = "postgres")]
fn pg_macaddress8_from_sql() {
    let query = "'08:00:2b:01:02:03:04:05'::macaddr8";
    let expected_value = [0x08, 0x00, 0x2b, 0x01, 0x02, 0x03, 0x04, 0x05];
    assert_eq!(
        expected_value,
        query_single_value::<MacAddr8, [u8; 8]>(query)
    );
}

#[test]
#[cfg(feature = "postgres")]
fn pg_macaddress8_to_sql_macaddress() {
    let expected_value = "'08:00:2b:01:02:03:04:05'::macaddr8";
    let value = [0x08, 0x00, 0x2b, 0x01, 0x02, 0x03, 0x04, 0x05];
    assert!(query_to_sql_equality::<MacAddr8, [u8; 8]>(
        expected_value,
        value
    ));
}

#[test]
#[cfg(feature = "postgres")]
fn pg_v4address_from_sql() {
    extern crate ipnetwork;
    use std::str::FromStr;

    let query = "'192.168.1.0/24'::cidr";
    let expected_value =
        ipnetwork::IpNetwork::V4(ipnetwork::Ipv4Network::from_str("192.168.1.0/24").unwrap());
    assert_eq!(
        expected_value,
        query_single_value::<Cidr, ipnetwork::IpNetwork>(query)
    );
    let query = "'192.168.1.0/24'::inet";
    let expected_value =
        ipnetwork::IpNetwork::V4(ipnetwork::Ipv4Network::from_str("192.168.1.0/24").unwrap());
    assert_eq!(
        expected_value,
        query_single_value::<Inet, ipnetwork::IpNetwork>(query)
    );