From 8e6d8a6fa8663fc98d73ebe62636e429ba1b674f Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Mon, 28 Feb 2022 16:05:32 +0100 Subject: [PATCH] use catch2 main --- unittest/rebootLogic/CMakeLists.txt | 17 +++++++++++++++++ unittest/rebootLogic/main.cpp | 3 ++- 2 files changed, 19 insertions(+), 1 deletion(-) diff --git a/unittest/rebootLogic/CMakeLists.txt b/unittest/rebootLogic/CMakeLists.txt index 4af51d08..9377d45e 100644 --- a/unittest/rebootLogic/CMakeLists.txt +++ b/unittest/rebootLogic/CMakeLists.txt @@ -2,6 +2,21 @@ cmake_minimum_required(VERSION 3.0.0) project(reboot-logic VERSION 0.1.0) include(CTest) +find_package(Catch2 3) +if(NOT Catch2_FOUND) + include(FetchContent) + + FetchContent_Declare( + Catch2 + GIT_REPOSITORY https://github.com/catchorg/Catch2.git + GIT_TAG v3.0.0-preview4 + ) + + FetchContent_MakeAvailable(Catch2) + #fixes regression -preview4, to be confirmed in later releases + set_target_properties(Catch2 PROPERTIES DEBUG_POSTFIX "") +endif() + enable_testing() add_executable(reboot-logic main.cpp) @@ -14,6 +29,8 @@ target_sources(reboot-logic PRIVATE libxiphos.cpp ) +target_link_libraries(reboot-logic PRIVATE Catch2::Catch2WithMain) + target_include_directories(reboot-logic PRIVATE ${CMAKE_CURRENT_SOURCE_DIR} ) diff --git a/unittest/rebootLogic/main.cpp b/unittest/rebootLogic/main.cpp index f3e8680e..cd6117ab 100644 --- a/unittest/rebootLogic/main.cpp +++ b/unittest/rebootLogic/main.cpp @@ -1,7 +1,8 @@ #include "CoreController.h" +#include #include -int main(int, char**) { +TEST_CASE( "Core Controller Reboot File Handling", "[reboot-file]" ) { CoreController ctrl; std::cout << "Hello, world!\n"; }