Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

support Catch2 v3 #206

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions tests/catch/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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}/../.. )

Expand Down
8 changes: 8 additions & 0 deletions tests/catch/archive.cpp
Original file line number Diff line number Diff line change
@@ -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>
Expand Down Expand Up @@ -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")
{
Expand Down
4 changes: 4 additions & 0 deletions tests/catch/array.cpp
Original file line number Diff line number Diff line change
@@ -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;
Expand Down
4 changes: 4 additions & 0 deletions tests/catch/main.cpp
Original file line number Diff line number Diff line change
@@ -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
4 changes: 4 additions & 0 deletions tests/catch/ranges.cpp
Original file line number Diff line number Diff line change
@@ -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>
Expand Down
4 changes: 4 additions & 0 deletions tests/catch/symboltable.cpp
Original file line number Diff line number Diff line change
@@ -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;
Expand Down
4 changes: 4 additions & 0 deletions tests/catch/utils.cpp
Original file line number Diff line number Diff line change
@@ -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;
Expand Down
4 changes: 4 additions & 0 deletions tests/catch/version.cpp
Original file line number Diff line number Diff line change
@@ -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;
Expand Down