From 226dfdbc021e9500e70f667bc3ec6131e3b9694e Mon Sep 17 00:00:00 2001 From: Eugen Wissner Date: Tue, 18 Mar 2025 16:14:12 +0100 Subject: [PATCH] Katja: Add test facilities --- CMakeLists.txt | 17 ++++++++++++++--- tests/tester.cpp | 9 +++++++++ 2 files changed, 23 insertions(+), 3 deletions(-) create mode 100644 tests/tester.cpp diff --git a/CMakeLists.txt b/CMakeLists.txt index 6b3667c..b2b97d0 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,11 +1,13 @@ cmake_minimum_required(VERSION 3.21) project(Katja) +include(CTest) + set(CMAKE_EXPORT_COMPILE_COMMANDS 1) set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin) set(CMAKE_CXX_STANDARD 17) -find_package(Boost CONFIG COMPONENTS process program_options REQUIRED) +find_package(Boost CONFIG COMPONENTS unit_test_framework REQUIRED) add_library(backend katja/database.cpp include/katja/database.hpp @@ -15,6 +17,15 @@ add_library(backend target_include_directories(backend PRIVATE include ${Boost_INCLUDE_DIR}) add_executable(katja cli/main.cpp) -target_link_libraries(katja PRIVATE backend) target_include_directories(katja PRIVATE include ${Boost_INCLUDE_DIR}) -target_link_libraries(katja LINK_PUBLIC ${Boost_LIBRARIES}) +target_link_libraries(katja LINK_PUBLIC backend) + +if(BUILD_TESTING) + add_executable(tester tests/tester.cpp) + + target_include_directories(tester PRIVATE include ${Boost_INCLUDE_DIR}) + target_compile_definitions(tester PRIVATE "BOOST_TEST_DYN_LINK=1") + target_link_libraries(tester LINK_PRIVATE backend Boost::unit_test_framework) + + add_test(NAME tester COMMAND tester) +endif() diff --git a/tests/tester.cpp b/tests/tester.cpp new file mode 100644 index 0000000..a464447 --- /dev/null +++ b/tests/tester.cpp @@ -0,0 +1,9 @@ +#define BOOST_TEST_MODULE unit tests + +#include +#include "katja/repository.hpp" + +BOOST_AUTO_TEST_CASE(construct_valid_database_package) +{ + BOOST_TEST(true); +}