feat: TU demo .c
fix: TU demo fix: TU demo
This commit is contained in:
@@ -54,10 +54,12 @@ add_compile_definitions(TEST DEBUG=0 SKIP_FOR_CMOCKA)
|
||||
include_directories(../../src/)
|
||||
include_directories(../../src_common)
|
||||
|
||||
add_executable(test_utils tests/utils.c)
|
||||
# add cmocka tests
|
||||
add_executable(test_demo tests/demo.c)
|
||||
|
||||
add_library(utils SHARED ../../src/utils2.c)
|
||||
# add src
|
||||
add_library(demo SHARED ./demo_tu.c)
|
||||
|
||||
target_link_libraries(test_utils PUBLIC cmocka gcov utils)
|
||||
target_link_libraries(test_demo PUBLIC cmocka gcov demo)
|
||||
|
||||
add_test(test_utils test_utils)
|
||||
add_test(test_demo test_demo)
|
||||
12
tests/unit/demo_tu.c
Normal file
12
tests/unit/demo_tu.c
Normal file
@@ -0,0 +1,12 @@
|
||||
#include <string.h>
|
||||
|
||||
int local_strchr_demo(char *string, char ch) {
|
||||
unsigned int length = strlen(string);
|
||||
unsigned int i;
|
||||
for (i = 0; i < length; i++) {
|
||||
if (string[i] == ch) {
|
||||
return i;
|
||||
}
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
@@ -3,11 +3,11 @@
|
||||
#include <setjmp.h>
|
||||
#include <cmocka.h>
|
||||
|
||||
int local_strchr(char *string, char ch);
|
||||
int local_strchr_demo(char *string, char ch);
|
||||
|
||||
static void null_test_success(void **state) {
|
||||
assert_int_equal(local_strchr("salut", 'c'), -1);
|
||||
assert_int_equal(local_strchr("av", 'a'), 0);
|
||||
assert_int_equal(local_strchr_demo("salut", 'c'), -1);
|
||||
assert_int_equal(local_strchr_demo("av", 'a'), 0);
|
||||
}
|
||||
|
||||
int main(void) {
|
||||
Reference in New Issue
Block a user