init commit of template_files

This commit is contained in:
jakeg00dwin 2024-02-29 22:49:19 -08:00
parent f6330c7eec
commit afd2bca9b3
6 changed files with 68 additions and 0 deletions

View File

@ -0,0 +1,7 @@
add_library(module_name STATIC
module_name.c
)
target_include_directories(modlue_name PUBLIC
${CMAKE_CURRENT_LIST_DIR}
)

View File

@ -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}")

View File

@ -0,0 +1,16 @@
/*
* Author: username
* Date: todays_year
* 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;
}

View File

@ -0,0 +1,14 @@
/*
* Author: username
* Date: todays_year
* filename: module_name.h
* description: module_purpose
*/
#ifndef module_name
#define module_name
int add_two(int a);
#endif //module_name

View File

View File

@ -0,0 +1,18 @@
#include <stdarg.h>
#include <stddef.h>
#include <stdint.h>
#include <setjmp.h>
#include <cmocka.h>
/* 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);
}