-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathunittest.c
More file actions
55 lines (44 loc) · 769 Bytes
/
unittest.c
File metadata and controls
55 lines (44 loc) · 769 Bytes
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
52
53
54
#include <linux/kernel.h>
#include <linux/crc16.h>
#include "unity.h"
#include "unity_fixture.h"
TEST_GROUP(crc);
TEST_SETUP(crc)
{
UnityPrint("test setup");
UNITY_OUTPUT_CHAR('\n');
}
TEST_TEAR_DOWN(crc)
{
UnityPrint("test teardown");
UNITY_OUTPUT_CHAR('\n');
}
TEST(crc, crc16)
{
u8 *buffer = "1234";
size_t len = 4;
u16 result = crc16(1, buffer, len);
TEST_ASSERT_EQUAL(1, result);
}
IGNORE_TEST(crc, crc16_ignore)
{
u8 *buffer = "4";
size_t len = 1;
u16 result = crc16(1, buffer, len);
TEST_ASSERT_EQUAL(1, result);
}
TEST_GROUP_RUNNER(crc)
{
RUN_TEST_CASE(crc, crc16);
RUN_TEST_CASE(crc, crc16_ignore);
}
static void RUN_crc(void)
{
RUN_TEST_GROUP(crc);
}
int unittest_init(void)
{
int ret;
ret = UnityMain(0, 0, RUN_crc);
return 0;
}