blob: 36e10f071f4ca8de4e0e8a30e67e2769af0fe75b (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
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;
}
|