diff --git a/.template_files/modules/CMakeLists.txt b/.template_files/modules/CMakeLists.txt new file mode 100644 index 0000000..5e1257e --- /dev/null +++ b/.template_files/modules/CMakeLists.txt @@ -0,0 +1,7 @@ +add_library(module_name STATIC + module_name.c +) + +target_include_directories(modlue_name PUBLIC + ${CMAKE_CURRENT_LIST_DIR} +) diff --git a/.template_files/modules/TestCMakeLists.txt b/.template_files/modules/TestCMakeLists.txt new file mode 100644 index 0000000..fe0aea3 --- /dev/null +++ b/.template_files/modules/TestCMakeLists.txt @@ -0,0 +1,13 @@ +# The module_name module tests +list(APPEND TEST_LIBS "${CMOCKA_LIBRARIES}") +list(APPEND TEST_LIBS module_name) + +list(APPEND TEST_DIRS "${CMOCKA_INCLUDE_DIRS}") +list(APPEND TEST_DIRS "${PROJECT_SOURCE_DIR}/src") + +add_cmocka_test(test_module_name + SOURCES test_module_name.c + COMPILE_OPTIONS ${DEFAULT_C_COMPILE_FLAGS} + LINK_LIBRARIES "${TEST_LIBS}") +add_cmocka_test_environment(test_module_name) +target_include_directories(test_module_name PUBLIC "${TEST_DIRS}") diff --git a/.template_files/modules/module_name.c b/.template_files/modules/module_name.c new file mode 100644 index 0000000..119b0bc --- /dev/null +++ b/.template_files/modules/module_name.c @@ -0,0 +1,16 @@ +/* + * Author: username + * Date: todays_date + * filename: module_name.c + * description: module_purpose + */ + +#include "module_name.h" + +// dumb test function +int add_two(int a) +{ + int b = a; + b += 2; + return b; +} diff --git a/.template_files/modules/module_name.h b/.template_files/modules/module_name.h new file mode 100644 index 0000000..e3907fd --- /dev/null +++ b/.template_files/modules/module_name.h @@ -0,0 +1,14 @@ +/* + * Author: username + * Date: todays_date + * filename: module_name.h + * description: module_purpose + */ + +#ifndef module_name +#define module_name + + +int add_two(int a); + +#endif //module_name diff --git a/.template_files/modules/moudle.h b/.template_files/modules/moudle.h new file mode 100644 index 0000000..e69de29 diff --git a/.template_files/modules/test_module_name.c b/.template_files/modules/test_module_name.c new file mode 100644 index 0000000..7d47c40 --- /dev/null +++ b/.template_files/modules/test_module_name.c @@ -0,0 +1,18 @@ +#include +#include +#include +#include +#include + +/* A test case that does nothing and succeeds. */ +static void null_test_success(void **state) { + (void) state; /* unused */ +} + +int main(void) +{ + const struct CMUnitTest tests[] = { + cmocka_unit_test(null_test_success), + }; + return cmocka_run_group_tests(tests, NULL, NULL); +}