Replace some unwrap by Result
[temp2RGB.git] / src / tests.rs
index 09c75e4..0cf81ad 100644 (file)
@@ -12,13 +12,14 @@ pub fn tests() {
 
     winring0::init();
 
-    test_asus_aura_usb(asus_aura_usb::Motherboard::AsusCrosshairVIIIHero);
+    // test_asus_aura_usb(asus_aura_usb::Motherboard::AsusCrosshairVIIIHero);
     // test_corsair_lighting_pro();
     // list_usb_devices();
     // test_roccat();
     // test_wmi();
     // test_corsair();
     // test_a770();
+    test_3080ti();
     // test_read_temperature_cpu();
     // test_read_temperature_a770()
     // test_read_temperature_3080();
@@ -85,11 +86,11 @@ fn list_usb_devices() {
 fn test_asus_aura_usb(motherboard: asus_aura_usb::Motherboard) {
     let api = hidapi::HidApi::new().unwrap();
 
-    let device = asus_aura_usb::Device::new(&api, motherboard);
+    let device = asus_aura_usb::Device::new(&api, motherboard).unwrap();
 
-    println!("Firmware: {}", device.get_firmware_string());
+    println!("Firmware: {}", device.get_firmware_string().unwrap());
 
-    let configuration = device.get_configuration_table();
+    let configuration = device.get_configuration_table().unwrap();
     println!("Configuration:");
     for i in 0..60 {
         print!("{:02X} ", configuration[i]);
@@ -101,13 +102,15 @@ fn test_asus_aura_usb(motherboard: asus_aura_usb::Motherboard) {
     println!("Number of leds: {}", configuration[0x1B]);
     println!("Number of RGB headers: {}", configuration[0x1D]);
 
-    device.set_color(&RGB {
-        red: 0,
-        green: 0,
-        blue: 255,
-    });
+    device
+        .set_color(&RGB {
+            red: 0,
+            green: 0,
+            blue: 255,
+        })
+        .unwrap();
 
-    device.save_current_color();
+    device.save_current_color().unwrap();
 }
 
 fn test_corsair_lighting_pro() {
@@ -150,8 +153,18 @@ fn test_corsair() {
 
 fn test_a770() {
     // a770::set_rgb(255, 0, 0);
-    let mut a770 = a770::A770::new();
-    a770.set_color(255, 0, 0);
+    let mut a770 = a770::A770::new().unwrap();
+    a770.set_color(255, 0, 0).unwrap();
+}
+
+fn test_3080ti() {
+    let machine: &mut dyn machine::Machine = &mut machine::MachineLyssMetal::new().unwrap();
+
+    machine.set_color(&RGB {
+        red: 255,
+        green: 0,
+        blue: 0,
+    });
 }
 
 const F17H_M01H_THM_TCON_CUR_TMP: u32 = 0x00059800;
@@ -163,7 +176,7 @@ fn test_read_temperature_cpu() {
 }
 
 fn test_read_temperature_a770() {
-    let jiji: &dyn machine::Machine = &machine::MachineJiji::new();
+    let jiji: &dyn machine::Machine = &machine::MachineJiji::new().unwrap();
     println!("temp gpu: {}", jiji.get_gpu_tmp());
 }