sinf 0.1.0

Library for obtaining in-depth system information at both the hardware and software levels
Documentation
use crate::platform::MIN_USERS;
use crate::*;

#[test]
fn check_list() {
    let mut users = check_unsupported!(Users::new());
    assert!(users.is_empty());
    users.refresh();
    assert!(users.len() >= MIN_USERS);
}

// Ensures that `Uid`, `Gid` and `Pid` implement the conversion traits supported by their platform.
#[allow(clippy::unnecessary_fallible_conversions)]
#[test]
fn check_uid_gid_from_impls() {
    use std::str::FromStr;

    #[cfg(not(windows))]
    {
        use std::convert::TryFrom;

        assert!(crate::Uid::try_from(0usize).is_ok());
        assert!(crate::Uid::from_str("0").is_ok());
    }
    #[cfg(windows)]
    {
        assert!(crate::Uid::from_str("S-1-5-18").is_ok()); // SECURITY_LOCAL_SYSTEM_RID
        assert!(crate::Uid::from_str("0").is_err());
    }

    #[cfg(not(windows))]
    {
        assert!(crate::Gid::try_from(0usize).is_ok());
        assert!(crate::Gid::from_str("0").is_ok());
    }
    #[cfg(windows)]
    {
        assert!(crate::Gid::from_str("S-1-5-32-544").is_ok());
    }
}

#[test]
fn check_groups() {
    let groups = check_unsupported!(Groups::new_with_refreshed_list());
    assert!(!groups.is_empty());
}

#[test]
fn check_user_order_matches_equality() {
    let users = check_unsupported!(Users::new_with_refreshed_list());
    if users.is_empty() {
        return;
    }
    for a in users.iter() {
        for b in users.iter() {
            assert_eq!(
                a == b,
                a.cmp(b) == std::cmp::Ordering::Equal,
                "inconsistent `Eq`/`Ord` for users"
            );
        }
    }
}