From 18f2f4efcd9229f65ff436a247b1aaf321e357bc Mon Sep 17 00:00:00 2001 From: Marco Date: Fri, 3 Mar 2023 18:17:14 +0100 Subject: [PATCH] Forgot some files. --- .vscode/settings.json | 5 ++++ test/test_timer_utils.c | 57 +++++++++++++++++++++++++++++++++++++++++ 2 files changed, 62 insertions(+) create mode 100644 .vscode/settings.json create mode 100644 test/test_timer_utils.c diff --git a/.vscode/settings.json b/.vscode/settings.json new file mode 100644 index 0000000..2be4559 --- /dev/null +++ b/.vscode/settings.json @@ -0,0 +1,5 @@ +{ + "files.associations": { + "time.h": "c" + } +} \ No newline at end of file diff --git a/test/test_timer_utils.c b/test/test_timer_utils.c new file mode 100644 index 0000000..a403e09 --- /dev/null +++ b/test/test_timer_utils.c @@ -0,0 +1,57 @@ +#include +#include + +#include "CUnit/Basic.h" +#include "timer_utils.h" + +int init_suite1(void) +{ + printf("init_suit1()"); + return 0; +} + +int clean_suite1(void) +{ + printf("clean_suit1()"); + return 0; +} + +void test_tmr_add_ns_to_current_time(void) +{ + struct itimerspec test_time = { + .it_value = { + .tv_nsec = 0, + .tv_sec = 0 + } + }; + + tmr_add_ns_to_current_time(&test_time, 1); + + CU_ASSERT(test_time.it_value.tv_nsec == 2); +} + +int main() +{ + CU_pSuite pSuite = NULL; + + if (CUE_SUCCESS != CU_initialize_registry()) + return CU_get_error(); + + pSuite = CU_add_suite("Suite_1", init_suite1, clean_suite1); + if (NULL == pSuite) + { + CU_cleanup_registry(); + return CU_get_error(); + } + + if ((NULL == CU_add_test(pSuite, "test of fprintf()", test_tmr_add_ns_to_current_time))) + { + CU_cleanup_registry(); + return CU_get_error(); + } + + CU_basic_set_mode(CU_BRM_VERBOSE); + CU_basic_run_tests(); + CU_cleanup_registry(); + return CU_get_error(); +} \ No newline at end of file