summaryrefslogtreecommitdiff
path: root/stacks/terminal/test_apply_event.c
diff options
context:
space:
mode:
authorinfo@mode42.com <info@mode42.com>2026-08-07 18:23:28 +0000
committerinfo@mode42.com <info@mode42.com>2026-08-07 18:23:28 +0000
commitfa05a5f8238e9e1417235711656e5062ccc843a7 (patch)
tree46fbbd18de54492b59307c16efcc7f3152723238 /stacks/terminal/test_apply_event.c
Initial push
Diffstat (limited to 'stacks/terminal/test_apply_event.c')
-rw-r--r--stacks/terminal/test_apply_event.c30
1 files changed, 30 insertions, 0 deletions
diff --git a/stacks/terminal/test_apply_event.c b/stacks/terminal/test_apply_event.c
new file mode 100644
index 0000000..36e10f0
--- /dev/null
+++ b/stacks/terminal/test_apply_event.c
@@ -0,0 +1,30 @@
+/* Offline unit test: EVENT connected/disconnected → status.connected */
+#include "max25_proto.h"
+
+#include <stdio.h>
+#include <string.h>
+
+int main(void)
+{
+ max25_status_t st;
+
+ memset(&st, 0, sizeof(st));
+ if (max25_client_apply_event("EVENT connected", &st) != 1 || !st.connected) {
+ fprintf(stderr, "FAIL: EVENT connected\n");
+ return 1;
+ }
+ if (max25_client_apply_event("EVENT disconnected", &st) != 1 || st.connected) {
+ fprintf(stderr, "FAIL: EVENT disconnected\n");
+ return 1;
+ }
+ if (max25_client_apply_event("EVENT device=max25e0 serial=ready", &st) != 0) {
+ fprintf(stderr, "FAIL: unrelated EVENT should be ignored\n");
+ return 1;
+ }
+ if (max25_client_apply_event("OK", &st) != 0) {
+ fprintf(stderr, "FAIL: non-EVENT\n");
+ return 1;
+ }
+ puts("OK: apply_event");
+ return 0;
+}
git clone -b <branch> https://cgit.mode42.com/<repo>.git
git clone -b <branch> git://cgit.mode42.com/<repo>.git

info@mode42.com