Skip to content

Commit

Permalink
Improve UNIT_TEST_RUN macro to correctly manage function name passing…
Browse files Browse the repository at this point in the history
… to unity.
  • Loading branch information
nicolas-rabault committed May 5, 2023
1 parent bcfc661 commit 3af5b9b
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 19 deletions.
2 changes: 1 addition & 1 deletion platformio.ini
Original file line number Diff line number Diff line change
Expand Up @@ -32,4 +32,4 @@ build_type = debug
test_build_src = true

; To debug a test, replace "test_template" by the directory test name you want to debug (example : "test_msg_alloc")
debug_test = tests_io/test_filter
debug_test = tests_io/test_msg_alloc
17 changes: 1 addition & 16 deletions test/_resources/Unity/unit_test.c
Original file line number Diff line number Diff line change
Expand Up @@ -27,21 +27,6 @@ bool try_state = false;
* Function
******************************************************************************/

/******************************************************************************
* @brief Launch a unit test
* @param None
* @return None
******************************************************************************/
void RUN(const char *name, void (*function)(void))
{
printf("\n\n===============================================================================================================\n");
printf("Unit test function : %s\n", name);
printf("===============================================================================================================\n");

test_case_number = 0;
RUN_TEST(function);
}

/******************************************************************************
* @brief Start a new test case
* @param title (test description title)
Expand Down Expand Up @@ -150,4 +135,4 @@ void setUp(void)

void tearDown(void)
{
}
}
8 changes: 7 additions & 1 deletion test/_resources/Unity/unit_test.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,15 @@

extern jmp_buf err_ctx;
extern bool try_state;
extern uint16_t test_case_number;

#ifndef UNIT_TEST_RUN
#define UNIT_TEST_RUN(f) RUN(#f, f)
#define UNIT_TEST_RUN(f) \
printf("\n\n===============================================================================================================\n"); \
printf("Unit test function : %s\n", #f); \
printf("===============================================================================================================\n"); \
test_case_number = 0; \
RUN_TEST(f)
#endif

#define TRY \
Expand Down
2 changes: 1 addition & 1 deletion test/tests_core/test_topic/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -129,4 +129,4 @@ int main(int argc, char **argv)
UNIT_TEST_RUN(unittest_Luos_Unsubscribe);

UNITY_END();
}
}

0 comments on commit 3af5b9b

Please sign in to comment.