-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathmain.c
More file actions
100 lines (82 loc) · 2.53 KB
/
Copy pathmain.c
File metadata and controls
100 lines (82 loc) · 2.53 KB
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
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
/*----------------------------------------------------------------------------
* Name: main.c
*----------------------------------------------------------------------------*/
// new comment
#include "RTE_Components.h"
#include CMSIS_device_header
#include "unity.h"
#include <stdio.h>
#include "main.h"
#ifdef MIMXRT1052_SERIES
#include "clock_config.h"
#include "board.h"
#include "pin_mux.h"
#include "fsl_iomuxc.h"
// Callbacks for LPUART1 Driver
uint32_t LPUART1_GetFreq (void) { return BOARD_BOOTCLOCKRUN_UART_CLK_ROOT; }
void LPUART1_InitPins (void) { /* Done in BOARD_InitDEBUG_UART function */ }
void LPUART1_DeinitPins(void) { /* Not implemented */ }
// Callbacks for LPUART3 Driver
uint32_t LPUART3_GetFreq (void) { return BOARD_BOOTCLOCKRUN_UART_CLK_ROOT; }
void LPUART3_InitPins (void) { /* Done in BOARD_InitARDUINO_UART function */ }
void LPUART3_DeinitPins(void) { /* Not implemented */ }
#endif
extern void stdio_init (void);
/* Application function to test */
static int my_sum(int a, int b) {
return a + b;
}
/*============= UNIT TESTS ============== */
/* Called in RUN_TEST before executing test function */
void setUp(void) {
// set stuff up here
}
/* Called in RUN_TEST after executing test function */
void tearDown(void) {
// clean stuff up here
}
/* Testing summation of positive integers */
static void test_my_sum_pos(void) {
const int sum = my_sum(1, 1);
TEST_ASSERT_EQUAL_INT(2, sum);
}
/* Testing summation of negative integers */
static void test_my_sum_neg(void) {
const int sum = my_sum(-1, -1);
TEST_ASSERT_EQUAL_INT(-2, sum);
}
/* Testing summation of zeros */
static void test_my_sum_zero(void) {
const int sum = my_sum(0, 0);
TEST_ASSERT_EQUAL_INT(0, sum);
}
/* Failing test with incorrect summation value */
static void test_my_sum_fail(void) {
const int sum = my_sum(1, -1);
TEST_ASSERT_EQUAL_INT(2, sum);
}
/* Main: Run tests */
int main(void) {
#ifdef MIMXRT1052_SERIES
BOARD_InitBootPins();
BOARD_InitBootClocks();
BOARD_InitDebugConsole();
// Enable ENET_REF_CLK output mode
IOMUXC_EnableMode(IOMUXC_GPR, kIOMUXC_GPR_ENET1TxClkOutputDir, true);
NVIC_SetPriority(ENET_IRQn, 8U);
NVIC_SetPriority(USDHC1_IRQn, 8U);
NVIC_SetPriority(LPUART3_IRQn, 8U);
SystemCoreClockUpdate();
#else
stdio_init();
#endif
printf("---[ UNITY BEGIN ]---\n");
UNITY_BEGIN();
RUN_TEST(test_my_sum_pos);
RUN_TEST(test_my_sum_neg);
RUN_TEST(test_my_sum_fail);
RUN_TEST(test_my_sum_zero);
const int result = UNITY_END();
printf("---[ UNITY END ]---\n");
return result;
}