use sysinfo::System;

pub fn get(sys: &System) -> (u64, u64, u64) {
    (sys.used_memory(), sys.free_memory(), sys.total_memory())
}

#[cfg(test)]
mod tests {
    use super::*;
    use sysinfo::System;

    #[test]
    fn test_memory_coherent() {
        let mut sys = System::new();
        sys.refresh_memory();
        let (used, free, total) = get(&sys);
        assert!(total > 0, "Total mémoire nul");
        assert!(used + free <= total + 1024 * 1024, "used + free > total");
    }
}
