#[test]
fn detect_is_safe_and_repeatable() {
let first = gpu_probe::detect();
let second = gpu_probe::detect();
assert_eq!(
first.len(),
second.len(),
"the set of detected GPUs should be stable",
);
for (a, b) in first.iter().zip(&second) {
assert_eq!(a.name, b.name, "GPU name should be stable");
assert_eq!(a.vendor, b.vendor, "GPU vendor should be stable");
assert_eq!(
a.total_bytes, b.total_bytes,
"total memory should be stable",
);
}
}
#[test]
fn detected_gpus_satisfy_invariants() {
for gpu in gpu_probe::detect() {
assert!(!gpu.name.is_empty(), "every GPU must have a name");
assert!(
gpu.total_bytes > 0,
"a detected GPU must report some memory"
);
if let Some(free) = gpu.free_bytes {
assert!(free <= gpu.total_bytes, "free cannot exceed total");
}
if let Some(used) = gpu.used_bytes {
assert!(used <= gpu.total_bytes, "used cannot exceed total");
}
assert!(!gpu.to_string().is_empty());
}
}
#[test]
fn vendor_is_publicly_usable() {
let v = gpu_probe::Vendor::Apple;
let copied = v;
assert_eq!(copied.to_string(), "Apple");
}