From 9d3e1818b7bdc2ec7720c31f6219a2b7376baeab Mon Sep 17 00:00:00 2001
From: Russel Arbore <russel.jma@gmail.com>
Date: Sun, 17 Nov 2024 15:05:20 -0600
Subject: [PATCH] Make hercules samples into tests

---
 hercules_samples/dot/src/main.rs    | 8 +++++++-
 hercules_samples/fac/src/main.rs    | 6 ++++++
 hercules_samples/matmul/src/main.rs | 9 +++++++++
 3 files changed, 22 insertions(+), 1 deletion(-)

diff --git a/hercules_samples/dot/src/main.rs b/hercules_samples/dot/src/main.rs
index 3d282ae2..6d4cf380 100644
--- a/hercules_samples/dot/src/main.rs
+++ b/hercules_samples/dot/src/main.rs
@@ -9,6 +9,12 @@ fn main() {
         let mut a = vec![0.0, 1.0, 0.0, 2.0, 0.0, 3.0, 0.0, 4.0];
         let mut b = vec![0.0, 5.0, 0.0, 6.0, 0.0, 7.0, 0.0, 8.0];
         let c = unsafe { dot(a.as_mut_ptr(), b.as_mut_ptr(), 8).await };
-        println!("{}", c,);
+        println!("{}", c);
+        assert_eq!(c, 70.0);
     });
 }
+
+#[test]
+fn dot_test() {
+    main();
+}
diff --git a/hercules_samples/fac/src/main.rs b/hercules_samples/fac/src/main.rs
index e29860ee..e3a307fc 100644
--- a/hercules_samples/fac/src/main.rs
+++ b/hercules_samples/fac/src/main.rs
@@ -8,5 +8,11 @@ fn main() {
     async_std::task::block_on(async {
         let f = unsafe { fac(8).await };
         println!("{}", f);
+        assert_eq!(f, 40320);
     });
 }
+
+#[test]
+fn fac_test() {
+    main();
+}
diff --git a/hercules_samples/matmul/src/main.rs b/hercules_samples/matmul/src/main.rs
index 26168d4b..f3ceba93 100644
--- a/hercules_samples/matmul/src/main.rs
+++ b/hercules_samples/matmul/src/main.rs
@@ -15,5 +15,14 @@ fn main() {
             matmul(a.as_mut_ptr(), b.as_mut_ptr(), c.as_mut_ptr(), 2, 2, 2).await;
         }
         println!("[[{}, {}], [{}, {}]]", c[0], c[1], c[2], c[3]);
+        assert_eq!(c[0], 19.0);
+        assert_eq!(c[1], 22.0);
+        assert_eq!(c[2], 43.0);
+        assert_eq!(c[3], 50.0);
     });
 }
+
+#[test]
+fn matmul_test() {
+    main();
+}
-- 
GitLab