mirror of
https://github.com/NGSolve/netgen.git
synced 2025-01-27 13:20:34 +05:00
support Catch2 v3
- uses Cmake config files for Catch2
- supports both v2 and v3 of Catch2
- Catch2 v3 includes <catch2/catch_all.hpp> instead of <catch2/catch.hpp>
- v3 moves Catch::Contains to Catch::Matchers::ContainsSubstring
see https://github.com/catchorg/Catch2/blob/devel/docs/migrate-v2-to-v3.md
Patch adapted from debian patch catch2_v3.patch
d7ca1c564d/debian/patches/catch2_v3.patch
This commit is contained in:
parent
63cb566b8d
commit
cb1e8d1269
@ -3,12 +3,18 @@ if(ENABLE_UNIT_TESTS)
|
||||
add_custom_target(unit_tests)
|
||||
|
||||
# Build catch_main test object
|
||||
find_package(Catch2 REQUIRED)
|
||||
include_directories(${CATCH_INCLUDE_DIR} ${CMAKE_CURRENT_SOURCE_DIR}/../../libsrc/include ${SPDLOG_INCLUDE_DIR})
|
||||
add_library(catch_main STATIC main.cpp)
|
||||
set_target_properties(catch_main PROPERTIES CXX_STANDARD 17)
|
||||
add_dependencies(unit_tests catch_main)
|
||||
add_dependencies(catch_main project_catch)
|
||||
|
||||
if (Catch2_VERSION VERSION_GREATER_EQUAL 3)
|
||||
target_compile_options(catch_main PUBLIC -DCATCH2_v3)
|
||||
target_link_libraries(catch_main Catch2::Catch2WithMain)
|
||||
endif()
|
||||
|
||||
# ensure the test targets are built before testing
|
||||
add_test(NAME unit_tests_built COMMAND ${CMAKE_COMMAND} --build . --target unit_tests --config ${CMAKE_BUILD_TYPE} WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/../.. )
|
||||
|
||||
|
@ -1,5 +1,9 @@
|
||||
|
||||
#ifdef CATCH2_v3
|
||||
#include "catch2/catch_all.hpp"
|
||||
#else
|
||||
#include <catch2/catch.hpp>
|
||||
#endif
|
||||
#include <../core/ngcore.hpp>
|
||||
#include <core/register_archive.hpp>
|
||||
#include <core/logging.hpp>
|
||||
@ -354,7 +358,11 @@ void testArchive(Archive& in, Archive& out)
|
||||
SECTION("Not registered")
|
||||
{
|
||||
SharedPtrAndPtrHolder* p = new NotRegisteredForArchive;
|
||||
#ifdef CATCH2_v3
|
||||
REQUIRE_THROWS(out & p, Catch::Matchers::ContainsSubstring("not registered for archive"));
|
||||
#else
|
||||
REQUIRE_THROWS(out & p, Catch::Contains("not registered for archive"));
|
||||
#endif
|
||||
}
|
||||
SECTION("Non-default constructor")
|
||||
{
|
||||
|
@ -1,5 +1,9 @@
|
||||
|
||||
#ifdef CATCH2_v3
|
||||
#include "catch2/catch_all.hpp"
|
||||
#else
|
||||
#include <catch2/catch.hpp>
|
||||
#endif
|
||||
#include <core/array.hpp>
|
||||
using namespace ngcore;
|
||||
using namespace std;
|
||||
|
@ -1,3 +1,7 @@
|
||||
#define CATCH_CONFIG_MAIN
|
||||
#define DO_NOT_USE_WMAIN
|
||||
#ifdef CATCH2_v3
|
||||
#include "catch2/catch_all.hpp"
|
||||
#else
|
||||
#include <catch2/catch.hpp>
|
||||
#endif
|
@ -1,5 +1,9 @@
|
||||
|
||||
#ifdef CATCH2_v3
|
||||
#include "catch2/catch_all.hpp"
|
||||
#else
|
||||
#include <catch2/catch.hpp>
|
||||
#endif
|
||||
|
||||
#include <core/array.hpp>
|
||||
#include <core/ranges.hpp>
|
||||
|
@ -1,5 +1,9 @@
|
||||
|
||||
#ifdef CATCH2_v3
|
||||
#include "catch2/catch_all.hpp"
|
||||
#else
|
||||
#include <catch2/catch.hpp>
|
||||
#endif
|
||||
#include <../core/ngcore.hpp>
|
||||
using namespace ngcore;
|
||||
using namespace std;
|
||||
|
@ -1,5 +1,9 @@
|
||||
|
||||
#ifdef CATCH2_v3
|
||||
#include "catch2/catch_all.hpp"
|
||||
#else
|
||||
#include <catch2/catch.hpp>
|
||||
#endif
|
||||
#include <core/ngcore.hpp>
|
||||
using namespace ngcore;
|
||||
using namespace std;
|
||||
|
@ -1,5 +1,9 @@
|
||||
|
||||
#ifdef CATCH2_v3
|
||||
#include "catch2/catch_all.hpp"
|
||||
#else
|
||||
#include <catch2/catch.hpp>
|
||||
#endif
|
||||
#include <../core/ngcore.hpp>
|
||||
using namespace ngcore;
|
||||
using namespace std;
|
||||
|
Loading…
Reference in New Issue
Block a user