SET(CMAKE_BUILD_TYPE "Debug" CACHE STRING "build type")
+
IF(${CMAKE_BUILD_TYPE} STREQUAL "Debug")
SET(CMAKE_C_FLAGS "-Wall -g -fsanitize=address")
ENDIF()
MESSAGE(STATUS "CMAKE_C_FLAGS: ${CMAKE_C_FLAGS}")
-PROJECT(feierabend VERSION 0.0.1)
+PROJECT(feierabend-c)
-ADD_EXECUTABLE(${PROJECT_NAME} main.c)
\ No newline at end of file
+ADD_SUBDIRECTORY(src)
+ADD_SUBDIRECTORY(tests)
\ No newline at end of file
+++ /dev/null
-#include <stdio.h>
-
-int main()
-{
- printf("Hello World!\n");
- return 0;
-}
\ No newline at end of file
--- /dev/null
+CMAKE_MINIMUM_REQUIRED(VERSION 3.25.1)
+
+PROJECT(feierabend VERSION 0.0.1)
+
+ADD_EXECUTABLE(${PROJECT_NAME} main.c)
\ No newline at end of file
--- /dev/null
+#include <stdio.h>
+
+int main()
+{
+ printf("Hello World!\n");
+ return 0;
+}
\ No newline at end of file
--- /dev/null
+CMAKE_MINIMUM_REQUIRED(VERSION 3.25.1)
+
+FIND_LIBRARY(CMOCKA cmocka REQUIRED)
+
+ADD_EXECUTABLE(feierabend-test main.c)
+TARGET_LINK_LIBRARIES(feierabend-test
+ ${CMOCKA})
+
+INCLUDE(CTest)
+ADD_TEST(NAME feierabendtest
+ COMMAND feierabend-test)
+
+ADD_CUSTOM_TARGET(run-tests
+ ALL "ctest" "--verbose"
+ DEPENDS feierabend-test)
\ No newline at end of file
--- /dev/null
+#define UNIT_TESTING
+#include <stdarg.h>
+#include <stddef.h>
+#include <stdint.h>
+#include <setjmp.h>
+#include <cmocka.h>
+
+void sanity_check()
+{
+ assert_false(0);
+}
+
+int main()
+{
+ const struct CMUnitTest tests[] = {
+ cmocka_unit_test(sanity_check)
+ };
+
+ return cmocka_run_group_tests(tests, NULL, NULL);
+}
\ No newline at end of file