diff --git a/.github/workflows/cmake-multi-platform.yml b/.github/workflows/cmake-multi-platform.yml index 2d9c25a..c7f3856 100644 --- a/.github/workflows/cmake-multi-platform.yml +++ b/.github/workflows/cmake-multi-platform.yml @@ -57,6 +57,7 @@ jobs: git checkout "v3.6.0" mkdir build && cd build cmake .. -DBUILD_TESTING=OFF + cmake --build . --target install sudo cmake --build . --target install - name: Set reusable strings diff --git a/tests/unit/CMakeLists.txt b/tests/unit/CMakeLists.txt index 9f97967..738857d 100644 --- a/tests/unit/CMakeLists.txt +++ b/tests/unit/CMakeLists.txt @@ -68,6 +68,16 @@ add_executable(unit_tests test_timer.cpp ) +target_include_directories(unit_tests PRIVATE + ${CMAKE_CURRENT_SOURCE_DIR} +) + +if (Catch2_VERSION VERSION_LESS "3.0") + target_compile_definitions(unit_tests PUBLIC CATCH2_V2) + message(STATUS "catch2 version is less than in upstream") +endif() + + # --- Link for executables --- target_link_libraries(unit_tests diff --git a/tests/unit/catch2_version.h b/tests/unit/catch2_version.h new file mode 100644 index 0000000..a9ccd47 --- /dev/null +++ b/tests/unit/catch2_version.h @@ -0,0 +1,46 @@ +// catch2_version.h +// +// Header to figure out which Catch2 version we're using, and the proper +// header for that version. +// + +/**************************************************************************** + * BSD 3-Clause License + * + * Copyright (c) 2024, Frank Pagliughi + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are + * met: + * + * Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * + * Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * Neither the name of the copyright holder nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS + * IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, + * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR + * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF + * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + ***************************************************************************/ + +#ifdef CATCH2_V2 + #include "catch2/catch.hpp" +#else + #include "catch2/catch_all.hpp" +#endif diff --git a/tests/unit/test_func_wrapper.cpp b/tests/unit/test_func_wrapper.cpp index 36ca036..d647fda 100644 --- a/tests/unit/test_func_wrapper.cpp +++ b/tests/unit/test_func_wrapper.cpp @@ -2,7 +2,7 @@ // #include "cooper/func_wrapper.h" -#include +#include "catch2_version.h" using namespace cooper; diff --git a/tests/unit/test_task_queue.cpp b/tests/unit/test_task_queue.cpp index ea34e8e..1144fba 100644 --- a/tests/unit/test_task_queue.cpp +++ b/tests/unit/test_task_queue.cpp @@ -8,7 +8,7 @@ /**************************************************************************** * BSD 3-Clause License * - * Copyright (c) 2019, Frank Pagliughi + * Copyright (c) 2019-2024, Frank Pagliughi * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -41,7 +41,7 @@ ***************************************************************************/ #include "cooper/task_queue.h" -#include +#include "catch2_version.h" using namespace std::chrono; using namespace cooper; diff --git a/tests/unit/test_timer.cpp b/tests/unit/test_timer.cpp index edf7aec..7d6821f 100644 --- a/tests/unit/test_timer.cpp +++ b/tests/unit/test_timer.cpp @@ -40,7 +40,7 @@ ***************************************************************************/ #include "cooper/task_queue.h" -#include +#include "catch2_version.h" #if 0 #include diff --git a/tests/unit/test_work.cpp b/tests/unit/test_work.cpp index 54f5356..a2c470f 100644 --- a/tests/unit/test_work.cpp +++ b/tests/unit/test_work.cpp @@ -8,7 +8,7 @@ /**************************************************************************** * BSD 3-Clause License * - * Copyright (c) 2019, Frank Pagliughi + * Copyright (c) 2019-2024, Frank Pagliughi * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -41,7 +41,7 @@ ***************************************************************************/ #include "cooper/work_thread.h" -#include +#include "catch2_version.h" #if 0 #include diff --git a/tests/unit/unit_tests.cpp b/tests/unit/unit_tests.cpp index 9cf73cc..556e2fe 100644 --- a/tests/unit/unit_tests.cpp +++ b/tests/unit/unit_tests.cpp @@ -1,10 +1,10 @@ // unit_tests.cpp // -// Main for the Catch2 unit tests for the Paho MQTT C++ library. +// Main for the Catch2 unit tests for the cooper C++ actor library. // /******************************************************************************* - * Copyright (c) 2019 Frank Pagliughi + * Copyright (c) 2019-2024 Frank Pagliughi * * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 @@ -21,5 +21,5 @@ // This tells Catch to provide a main() - only do this in one cpp file #define CATCH_CONFIG_MAIN -#include "catch2/catch.hpp" +#include "catch2_version.h"