started idea for testing

main
Jef Roosens 2022-12-04 09:01:32 +01:00
parent 3b4a56bd89
commit c3fc6e6701
Signed by: Jef Roosens
GPG Key ID: B75D4F293C7052DB
5 changed files with 38 additions and 2 deletions

3
.gitmodules vendored 100644
View File

@ -0,0 +1,3 @@
[submodule "vendor/unity"]
path = vendor/unity
url = https://github.com/ThrowTheSwitch/Unity

View File

@ -5,7 +5,8 @@ set(CMAKE_C_STANDARD 17)
find_package(LibArchive REQUIRED)
include_directories(include)
add_subdirectory(vendor/unity)
include_directories(include vendor/unity/src)
file(GLOB CIETER_SRCS src/cieter/**.c)
@ -14,6 +15,12 @@ if(CMAKE_BUILD_TYPE STREQUAL Release)
endif()
add_library(cieter SHARED ${CIETER_SRCS})
target_link_libraries(cieter LibArchive::LibArchive)
if(CMAKE_BUILD_TYPE MATCHES "^Test")
enable_testing()
add_subdirectory(test)
endif()
option(BUILD_CIETERD "Build cieterd binary" ON)
@ -21,5 +28,5 @@ if (BUILD_CIETERD)
file(GLOB CIETERD_SRCS src/cieterd/**.c)
add_executable(cieterd ${CIETERD_SRCS})
target_link_libraries(cieterd cieter LibArchive::LibArchive)
target_link_libraries(cieterd cieter)
endif()

View File

@ -0,0 +1,8 @@
file(GLOB TEST_SRCS **.c)
foreach(TEST_SRC ${TEST_SRCS})
get_filename_component(EXEC_NAME ${TEST_SRC} NAME_WLE)
add_executable(${EXEC_NAME} ${TEST_SRC})
add_test(NAME ${EXEC_NAME} COMMAND ${EXEC_NAME})
target_link_libraries(${EXEC_NAME} cieter unity)
endforeach()

View File

@ -0,0 +1,17 @@
#include "unity.h"
#include "cieter_dynarray.h"
void setUp(void) {}
void tearDown(void) {}
void test_init() {
CieterDynArray *arr = cieter_dynarray_init(2);
TEST_ASSERT_NOT_NULL(arr);
}
int main(void) {
UNITY_BEGIN();
RUN_TEST(test_init);
return UNITY_END();
}

1
vendor/unity vendored 160000

@ -0,0 +1 @@
Subproject commit 0b92f9b960e4af9afc2b2d0918ce602111682e54