aboutsummaryrefslogtreecommitdiffstats
path: root/fw/tests/unit/signal_utests.c
blob: ebce8f6fdb526e59932e90d6a0e5068a8a66c143 (plain) (blame)
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
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
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();
}