aboutsummaryrefslogtreecommitdiffstats
path: root/fw/tests
diff options
context:
space:
mode:
authorSam Anthony <sam@samanthony.xyz>2025-11-01 17:36:26 -0400
committerSam Anthony <sam@samanthony.xyz>2025-11-01 17:36:26 -0400
commit0dbbdd9b594269fdb66c834146011df48678a901 (patch)
tree91e3969691926868ad8a41d7d907720e4d4ab276 /fw/tests
parentd0ceeb4e2ad98c2f5698d78513143a39c6f36b95 (diff)
downloadcan-gauge-interface-0dbbdd9b594269fdb66c834146011df48678a901.zip
extract big-endian signals from frames
Diffstat (limited to 'fw/tests')
-rw-r--r--fw/tests/unit/signal_utests.c51
-rw-r--r--fw/tests/unit/types_utests.c63
-rw-r--r--fw/tests/unit/types_utests.h5
3 files changed, 51 insertions, 68 deletions
diff --git a/fw/tests/unit/signal_utests.c b/fw/tests/unit/signal_utests.c
new file mode 100644
index 0000000..ebce8f6
--- /dev/null
+++ b/fw/tests/unit/signal_utests.c
@@ -0,0 +1,51 @@
+#include <stdbool.h>
+#include <stdint.h>
+
+#include <unity.h>
+
+#include <types.h>
+#include <can.h>
+#include <signal.h>
+#include <signal_utestable.h>
+
+void setUp(void) {}
+void tearDown(void) {}
+
+static void
+testPluckLE(void) {
+ setUp();
+
+ // TODO
+ TEST_ASSERT(0);
+
+ tearDown();
+}
+
+static void
+testPluckBE(void) {
+ setUp();
+
+ // 1111 1111 (1110 11)10 (1111 0010) 1111 1(101)
+ // 7 0 15 8 23 16 31 24
+ CanFrame frame = {.data = {0xFF, 0xEE, 0xF2, 0xFD}};
+ SigFmt sig = {
+ .start = 10u,
+ .size = 17u,
+ };
+ U32 want = 0x1DF95;
+ U32 got;
+ pluckBE(&sig, &frame, &got);
+ TEST_ASSERT_EQUAL_UINT32(want, got);
+
+ tearDown();
+}
+
+int
+main(void) {
+ UnityBegin(__FILE__);
+
+ RUN_TEST(testPluckLE);
+ RUN_TEST(testPluckBE);
+
+ return UnityEnd();
+}
diff --git a/fw/tests/unit/types_utests.c b/fw/tests/unit/types_utests.c
deleted file mode 100644
index 578a100..0000000
--- a/fw/tests/unit/types_utests.c
+++ /dev/null
@@ -1,63 +0,0 @@
-#include <stdbool.h>
-#include <stdint.h>
-
-#include <unity.h>
-
-#include <types.h>
-
-void setUp(void) {}
-void tearDown(void) {}
-
-void
-testAddU16(void) {
- setUp();
- // TODO
- TEST_ASSERT(false);
- tearDown();
-}
-
-void
-testAddU16U8(void) {
- setUp();
- // TODO
- TEST_ASSERT(false);
- tearDown();
-}
-
-void
-testLshiftU16(void) {
- setUp();
- // TODO
- TEST_ASSERT(false);
- tearDown();
-}
-
-void
-testRshiftU16(void) {
- setUp();
- // TODO
- TEST_ASSERT(false);
- tearDown();
-}
-
-void
-testCmpU16(void) {
- setUp();
- // TODO
- TEST_ASSERT(false);
- tearDown();
-}
-
-int
-main(void) {
- UnityBegin(__FILE__);
-
- // Types
- RUN_TEST(testAddU16);
- RUN_TEST(testAddU16U8);
- RUN_TEST(testLshiftU16);
- RUN_TEST(testRshiftU16);
- RUN_TEST(testCmpU16);
-
- return UnityEnd();
-}
diff --git a/fw/tests/unit/types_utests.h b/fw/tests/unit/types_utests.h
deleted file mode 100644
index 1923727..0000000
--- a/fw/tests/unit/types_utests.h
+++ /dev/null
@@ -1,5 +0,0 @@
-testAddU16(void);
-testAddU16U8(void);
-testLshiftU16(void);
-testRshiftU16(void);
-testCmpU16(void);