From 22f0def4b1e55d973f4da316db34ed82ebc91fa5 Mon Sep 17 00:00:00 2001 From: Eric Wasylishen Date: Sun, 26 Jun 2022 13:21:29 -0600 Subject: [PATCH] update Catch2 to v3.0.1 --- 3rdparty/Catch2 | 2 +- CMakeLists.txt | 7 +------ common/CMakeLists.txt | 4 ++-- common/test.cc | 15 +++++++-------- light/CMakeLists.txt | 3 +-- light/test.cc | 2 -- light/test_common.cc | 2 +- light/test_entities.cc | 2 +- light/test_light.cc | 32 ++++++++++++++++---------------- light/test_ltface.cc | 2 +- qbsp/CMakeLists.txt | 3 +-- qbsp/test.cc | 2 -- qbsp/test_qbsp.cc | 34 +++++++++++++++++----------------- vis/CMakeLists.txt | 3 +-- vis/test.cc | 2 -- vis/test_vis.cc | 2 +- 16 files changed, 51 insertions(+), 66 deletions(-) delete mode 100644 light/test.cc delete mode 100644 qbsp/test.cc delete mode 100644 vis/test.cc diff --git a/3rdparty/Catch2 b/3rdparty/Catch2 index 62fd6605..605a3476 160000 --- a/3rdparty/Catch2 +++ b/3rdparty/Catch2 @@ -1 +1 @@ -Subproject commit 62fd660583d3ae7a7886930b413c3c570e89786c +Subproject commit 605a34765aa5d5ecbf476b4598a862ada971b0cc diff --git a/CMakeLists.txt b/CMakeLists.txt index 3963058b..0e73c8ee 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -4,7 +4,7 @@ cmake_policy(SET CMP0028 NEW) project (ericw-tools) list(APPEND CMAKE_MODULE_PATH "${PROJECT_SOURCE_DIR}/cmake") -list(APPEND CMAKE_MODULE_PATH "${PROJECT_SOURCE_DIR}/3rdparty/Catch2/contrib") +list(APPEND CMAKE_MODULE_PATH "${PROJECT_SOURCE_DIR}/3rdparty/Catch2/extras") # Grab the git describe output and store it in GIT_DESCRIBE # Thanks to http://xit0.org/2013/04/cmake-use-git-branch-and-commit-details-in-project/ @@ -75,11 +75,6 @@ if (ERICWTOOLS_ASAN) message(STATUS "Enabling ASan on all targets") add_compile_options(-fsanitize=address) add_link_options(-fsanitize=address) - - # https://github.com/catchorg/Catch2/issues/898#issuecomment-841733322 - if (WIN32) - add_compile_definitions(CATCH_CONFIG_NO_WINDOWS_SEH) - endif() endif() if (CMAKE_CXX_COMPILER_ID STREQUAL "Clang" AND CMAKE_CXX_SIMULATE_ID STREQUAL "MSVC") diff --git a/common/CMakeLists.txt b/common/CMakeLists.txt index d1059613..fadf76a9 100644 --- a/common/CMakeLists.txt +++ b/common/CMakeLists.txt @@ -37,7 +37,7 @@ add_library(common STATIC target_link_libraries(common ${CMAKE_THREAD_LIBS_INIT} TBB::tbb fmt::fmt nlohmann_json::nlohmann_json) -# test (see: https://google.github.io/googletest/quickstart-cmake.html) +# test target enable_testing() @@ -47,7 +47,7 @@ add_executable(testcommon ${COMMON_TEST_SOURCE}) # HACK: copy .dll dependencies add_custom_command(TARGET testcommon POST_BUILD COMMAND ${CMAKE_COMMAND} -E copy_if_different "$" "$") -target_link_libraries (testcommon common ${CMAKE_THREAD_LIBS_INIT} TBB::tbb Catch2::Catch2 fmt::fmt) +target_link_libraries (testcommon common ${CMAKE_THREAD_LIBS_INIT} TBB::tbb Catch2::Catch2WithMain fmt::fmt) include(Catch) catch_discover_tests(testcommon) \ No newline at end of file diff --git a/common/test.cc b/common/test.cc index 2c3524ac..1e145c3d 100644 --- a/common/test.cc +++ b/common/test.cc @@ -1,5 +1,4 @@ -#define CATCH_CONFIG_MAIN // request a main() -#include +#include #include "common/settings.hh" @@ -258,16 +257,16 @@ TEST_CASE("copyMangle", "[settings]") parser_t p(std::string_view("0.0 -90.0 0.0")); CHECK(sunvec.parse("", p)); - CHECK(Approx(0).margin(1e-6) == sunvec.value()[0]); - CHECK(Approx(0).margin(1e-6) == sunvec.value()[1]); - CHECK(Approx(-1).margin(1e-6) == sunvec.value()[2]); + CHECK(Catch::Approx(0).margin(1e-6) == sunvec.value()[0]); + CHECK(Catch::Approx(0).margin(1e-6) == sunvec.value()[1]); + CHECK(Catch::Approx(-1).margin(1e-6) == sunvec.value()[2]); settings::setting_mangle sunvec2{&settings, {"sunlight_mangle2"}, 0.0, 0.0, 0.0}; sunvec2.copyFrom(sunvec); - CHECK(Approx(0).margin(1e-6) == sunvec2.value()[0]); - CHECK(Approx(0).margin(1e-6) == sunvec2.value()[1]); - CHECK(Approx(-1).margin(1e-6) == sunvec2.value()[2]); + CHECK(Catch::Approx(0).margin(1e-6) == sunvec2.value()[0]); + CHECK(Catch::Approx(0).margin(1e-6) == sunvec2.value()[1]); + CHECK(Catch::Approx(-1).margin(1e-6) == sunvec2.value()[2]); } TEST_CASE("copyContainer", "[settings]") diff --git a/light/CMakeLists.txt b/light/CMakeLists.txt index e0b51cd0..4bc43779 100644 --- a/light/CMakeLists.txt +++ b/light/CMakeLists.txt @@ -121,13 +121,12 @@ install(FILES ${CMAKE_SOURCE_DIR}/gpl_v3.txt DESTINATION bin) enable_testing() set(LIGHT_TEST_SOURCE - test.cc test_entities.cc test_ltface.cc test_light.cc test_common.cc) add_executable(testlight ${LIGHT_TEST_SOURCE}) -target_link_libraries (testlight PRIVATE liblight common ${CMAKE_THREAD_LIBS_INIT} Catch2::Catch2 fmt::fmt) +target_link_libraries (testlight PRIVATE liblight common ${CMAKE_THREAD_LIBS_INIT} Catch2::Catch2WithMain fmt::fmt) if (embree_FOUND) target_link_libraries (testlight PRIVATE embree) diff --git a/light/test.cc b/light/test.cc deleted file mode 100644 index 04ac319b..00000000 --- a/light/test.cc +++ /dev/null @@ -1,2 +0,0 @@ -#define CATCH_CONFIG_MAIN // request a main() -#include \ No newline at end of file diff --git a/light/test_common.cc b/light/test_common.cc index 802298e0..68e28e7c 100644 --- a/light/test_common.cc +++ b/light/test_common.cc @@ -1,4 +1,4 @@ -#include +#include #include #include diff --git a/light/test_entities.cc b/light/test_entities.cc index a01dd7f7..56fee8d5 100644 --- a/light/test_entities.cc +++ b/light/test_entities.cc @@ -1,4 +1,4 @@ -#include +#include #include #include diff --git a/light/test_light.cc b/light/test_light.cc index a8d4903e..9991d848 100644 --- a/light/test_light.cc +++ b/light/test_light.cc @@ -1,4 +1,4 @@ -#include +#include #include #include @@ -20,9 +20,9 @@ TEST_CASE("MakeCDF", "[mathlib]") std::vector cdf = MakeCDF(pdfUnnormzlied); REQUIRE(3u == cdf.size()); - REQUIRE(Approx(0.25) == cdf.at(0)); - REQUIRE(Approx(0.75) == cdf.at(1)); - REQUIRE(Approx(1.0) == cdf.at(2)); + REQUIRE(Catch::Approx(0.25) == cdf.at(0)); + REQUIRE(Catch::Approx(0.75) == cdf.at(1)); + REQUIRE(Catch::Approx(1.0) == cdf.at(2)); // TODO: return pdf REQUIRE(0 == SampleCDF(cdf, 0)); @@ -251,12 +251,12 @@ TEST_CASE("BarycentricRandom", "[mathlib]") REQUIRE(r1 <= 1); const auto bary = qv::Barycentric_Random(r0, r1); - CHECK(Approx(1.0f) == bary[0] + bary[1] + bary[2]); + CHECK(Catch::Approx(1.0f) == bary[0] + bary[1] + bary[2]); const qvec3f point = qv::Barycentric_ToPoint(bary, tri[0], tri[1], tri[2]); CHECK(GLM_EdgePlanes_PointInside(edges, point)); - CHECK(Approx(0.0f) == GLM_DistAbovePlane(plane, point)); + CHECK(Catch::Approx(0.0f) == GLM_DistAbovePlane(plane, point)); } } @@ -284,7 +284,7 @@ TEST_CASE("DistAbovePlane", "[mathlib]") { qvec4f plane(0, 0, 1, 10); qvec3f point(100, 100, 100); - CHECK(Approx(90) == GLM_DistAbovePlane(plane, point)); + CHECK(Catch::Approx(90) == GLM_DistAbovePlane(plane, point)); } TEST_CASE("InterpolateNormalsDegenerate", "[mathlib]") @@ -386,9 +386,9 @@ TEST_CASE("SignedDegreesBetweenUnitVectors", "[mathlib]") const qvec3f fwd{0, 1, 0}; const qvec3f right{1, 0, 0}; - CHECK(Approx(-90) == SignedDegreesBetweenUnitVectors(right, fwd, up)); - CHECK(Approx(90) == SignedDegreesBetweenUnitVectors(fwd, right, up)); - CHECK(Approx(0) == SignedDegreesBetweenUnitVectors(right, right, up)); + CHECK(Catch::Approx(-90) == SignedDegreesBetweenUnitVectors(right, fwd, up)); + CHECK(Catch::Approx(90) == SignedDegreesBetweenUnitVectors(fwd, right, up)); + CHECK(Catch::Approx(0) == SignedDegreesBetweenUnitVectors(right, right, up)); } TEST_CASE("ConcavityTest_concave", "[mathlib]") @@ -570,13 +570,13 @@ TEST_CASE("RandomPointInPoly", "[mathlib]") { TEST_CASE("FractionOfLine", "[mathlib]") { - REQUIRE(Approx(0) == FractionOfLine(qvec3f(0, 0, 0), qvec3f(1, 1, 1), qvec3f(0, 0, 0))); - REQUIRE(Approx(0.5) == FractionOfLine(qvec3f(0, 0, 0), qvec3f(1, 1, 1), qvec3f(0.5, 0.5, 0.5))); - REQUIRE(Approx(1) == FractionOfLine(qvec3f(0, 0, 0), qvec3f(1, 1, 1), qvec3f(1, 1, 1))); - REQUIRE(Approx(2) == FractionOfLine(qvec3f(0, 0, 0), qvec3f(1, 1, 1), qvec3f(2, 2, 2))); - REQUIRE(Approx(-1) == FractionOfLine(qvec3f(0, 0, 0), qvec3f(1, 1, 1), qvec3f(-1, -1, -1))); + REQUIRE(Catch::Approx(0) == FractionOfLine(qvec3f(0, 0, 0), qvec3f(1, 1, 1), qvec3f(0, 0, 0))); + REQUIRE(Catch::Approx(0.5) == FractionOfLine(qvec3f(0, 0, 0), qvec3f(1, 1, 1), qvec3f(0.5, 0.5, 0.5))); + REQUIRE(Catch::Approx(1) == FractionOfLine(qvec3f(0, 0, 0), qvec3f(1, 1, 1), qvec3f(1, 1, 1))); + REQUIRE(Catch::Approx(2) == FractionOfLine(qvec3f(0, 0, 0), qvec3f(1, 1, 1), qvec3f(2, 2, 2))); + REQUIRE(Catch::Approx(-1) == FractionOfLine(qvec3f(0, 0, 0), qvec3f(1, 1, 1), qvec3f(-1, -1, -1))); - REQUIRE(Approx(0) == FractionOfLine(qvec3f(0, 0, 0), qvec3f(0, 0, 0), qvec3f(0, 0, 0))); + REQUIRE(Catch::Approx(0) == FractionOfLine(qvec3f(0, 0, 0), qvec3f(0, 0, 0), qvec3f(0, 0, 0))); } TEST_CASE("DistToLine", "[mathlib]") diff --git a/light/test_ltface.cc b/light/test_ltface.cc index a5fc9d9c..028d6944 100644 --- a/light/test_ltface.cc +++ b/light/test_ltface.cc @@ -1,3 +1,3 @@ -#include +#include #include diff --git a/qbsp/CMakeLists.txt b/qbsp/CMakeLists.txt index 59e31932..3d2ea1b7 100644 --- a/qbsp/CMakeLists.txt +++ b/qbsp/CMakeLists.txt @@ -47,11 +47,10 @@ add_custom_command(TARGET qbsp POST_BUILD enable_testing() set(QBSP_TEST_SOURCE - test.cc test_qbsp.cc ${CMAKE_BINARY_DIR}/testmaps.hh) add_executable(testqbsp ${QBSP_TEST_SOURCE}) -target_link_libraries (testqbsp libqbsp common ${CMAKE_THREAD_LIBS_INIT} TBB::tbb Catch2::Catch2 fmt::fmt nanobench::nanobench) +target_link_libraries (testqbsp libqbsp common ${CMAKE_THREAD_LIBS_INIT} TBB::tbb Catch2::Catch2WithMain fmt::fmt nanobench::nanobench) # HACK: copy .dll dependencies add_custom_command(TARGET testqbsp POST_BUILD diff --git a/qbsp/test.cc b/qbsp/test.cc deleted file mode 100644 index 60da99d7..00000000 --- a/qbsp/test.cc +++ /dev/null @@ -1,2 +0,0 @@ -#define CATCH_CONFIG_MAIN // request a main() -#include diff --git a/qbsp/test_qbsp.cc b/qbsp/test_qbsp.cc index 30d5943a..cee750f8 100644 --- a/qbsp/test_qbsp.cc +++ b/qbsp/test_qbsp.cc @@ -1,4 +1,4 @@ -#include +#include #include #include @@ -322,7 +322,7 @@ TEST_CASE("testTextureIssue", "[qbsp]") #if 0 for (int i=0; i<2; i++) { for (int j=0; j<4; j++) { - CHECK(Approx(texvecsExpected[i][j]) == texvecsActual[i][j]); + CHECK(Catch::Approx(texvecsExpected[i][j]) == texvecsActual[i][j]); } } #endif @@ -517,7 +517,7 @@ TEST_CASE("simple_sealed", "[testmaps_q1]") CHECK(bsp.dleafs[1].nummarksurfaces == 6); CHECK(bsp.dleafs[1].firstmarksurface == 0); - CHECK_THAT(bsp.dleaffaces, Catch::UnorderedEquals(std::vector{0,1,2,3,4,5})); + CHECK_THAT(bsp.dleaffaces, Catch::Matchers::UnorderedEquals(std::vector{0,1,2,3,4,5})); } TEST_CASE("simple_sealed2", "[testmaps_q1]") @@ -553,7 +553,7 @@ TEST_CASE("simple_sealed2", "[testmaps_q1]") auto *other_plus_y = BSP_FindFaceAtPoint(&bsp, &bsp.dmodels[0], qvec3d(-64, -368, 128), qvec3d(0, 1, 0)); // back wall +Y normal - CHECK_THAT(other_markfaces, Catch::UnorderedEquals(std::vector{ + CHECK_THAT(other_markfaces, Catch::Matchers::UnorderedEquals(std::vector{ other_floor, other_ceil, other_minus_x, other_plus_x, other_plus_y })); } @@ -924,8 +924,8 @@ TEST_CASE("origin", "[testmaps_q1]") [](const entdict_t &dict) -> bool { return dict.get("classname") == "rotate_object"; }); REQUIRE(it != ents.end()); - CHECK_THAT(it->get("origin"), Catch::Equals("216 -216 340") - || Catch::Equals("216.00 -216.00 340.00")); + CHECK_THAT(it->get("origin"), Catch::Matchers::Equals("216 -216 340") + || Catch::Matchers::Equals("216.00 -216.00 340.00")); } TEST_CASE("simple", "[testmaps_q1]") @@ -1184,8 +1184,8 @@ TEST_CASE("areaportal", "[testmaps_q2]") // areaportal 0 is a placeholder // // the conceptual area portal has portalnum 1, and consists of two dareaportals entries with connections to area 1 and 2 - CHECK_THAT(bsp.dareaportals, Catch::UnorderedEquals(std::vector{{0, 0}, {1, 1}, {1, 2}})); - CHECK_THAT(bsp.dareas, Catch::UnorderedEquals(std::vector{{0, 0}, {1, 1}, {1, 2}})); + CHECK_THAT(bsp.dareaportals, Catch::Matchers::UnorderedEquals(std::vector{{0, 0}, {1, 1}, {1, 2}})); + CHECK_THAT(bsp.dareas, Catch::Matchers::UnorderedEquals(std::vector{{0, 0}, {1, 1}, {1, 2}})); // look up the leafs const qvec3d player_start{-88, -112, 120}; @@ -1216,7 +1216,7 @@ TEST_CASE("areaportal", "[testmaps_q2]") CHECK(Q2_CONTENTS_SOLID == Leaf_Brushes(&bsp, void_leaf).at(0)->contents); // check leaf areas - CHECK_THAT((std::vector{1, 2}), Catch::UnorderedEquals(std::vector{player_start_leaf->area, other_room_leaf->area})); + CHECK_THAT((std::vector{1, 2}), Catch::Matchers::UnorderedEquals(std::vector{player_start_leaf->area, other_room_leaf->area})); // the areaportal leaf itself actually gets assigned to one of the two sides' areas CHECK((areaportal_leaf->area == 1 || areaportal_leaf->area == 2)); CHECK(0 == void_leaf->area); // a solid leaf gets the invalid area @@ -1243,8 +1243,8 @@ TEST_CASE("areaportal_with_detail", "[testmaps_q2]") // areaportal 0 is a placeholder // // the conceptual area portal has portalnum 1, and consists of two dareaportals entries with connections to area 1 and 2 - CHECK_THAT(bsp.dareaportals, Catch::UnorderedEquals(std::vector{{0, 0}, {1, 1}, {1, 2}})); - CHECK_THAT(bsp.dareas, Catch::UnorderedEquals(std::vector{{0, 0}, {1, 1}, {1, 2}})); + CHECK_THAT(bsp.dareaportals, Catch::Matchers::UnorderedEquals(std::vector{{0, 0}, {1, 1}, {1, 2}})); + CHECK_THAT(bsp.dareas, Catch::Matchers::UnorderedEquals(std::vector{{0, 0}, {1, 1}, {1, 2}})); } TEST_CASE("nodraw_light", "[testmaps_q2]") { @@ -1403,11 +1403,11 @@ TEST_CASE("q2_liquids", "[testmaps_q2]") const qvec3d floor_wateropaque = wateropaque_trans33 - qvec3d(0, 0, 48); CHECK_THAT(TexNames(bsp, BSP_FindFacesAtPoint(&bsp, &bsp.dmodels[0], watertrans66_air)), - Catch::UnorderedEquals({"e1u1/bluwter", "e1u1/bluwter"})); + Catch::Matchers::UnorderedEquals({"e1u1/bluwter", "e1u1/bluwter"})); CHECK(0 == BSP_FindFacesAtPoint(&bsp, &bsp.dmodels[0], watertrans33_trans66).size()); CHECK(0 == BSP_FindFacesAtPoint(&bsp, &bsp.dmodels[0], wateropaque_trans33).size()); CHECK_THAT(TexNames(bsp, BSP_FindFacesAtPoint(&bsp, &bsp.dmodels[0], floor_wateropaque)), - Catch::UnorderedEquals({"e1u1/c_met11_2"})); + Catch::Matchers::UnorderedEquals({"e1u1/c_met11_2"})); } const qvec3d watertrans66_slimetrans66{-116, -144, 116}; @@ -1416,11 +1416,11 @@ TEST_CASE("q2_liquids", "[testmaps_q2]") { CHECK_THAT( TexNames(bsp, BSP_FindFacesAtPoint(&bsp, &bsp.dmodels[0], watertrans66_slimetrans66, qvec3d(0, -1, 0))), - Catch::UnorderedEquals({"e1u1/sewer1"})); + Catch::Matchers::UnorderedEquals({"e1u1/sewer1"})); CHECK_THAT( TexNames(bsp, BSP_FindFacesAtPoint(&bsp, &bsp.dmodels[0], watertrans66_slimetrans66, qvec3d(0, 1, 0))), - Catch::UnorderedEquals({"e1u1/sewer1"})); + Catch::Matchers::UnorderedEquals({"e1u1/sewer1"})); } // slime trans66 / lava trans66 @@ -1428,11 +1428,11 @@ TEST_CASE("q2_liquids", "[testmaps_q2]") { CHECK_THAT( TexNames(bsp, BSP_FindFacesAtPoint(&bsp, &bsp.dmodels[0], slimetrans66_lavatrans66, qvec3d(0, -1, 0))), - Catch::UnorderedEquals({"e1u1/brlava"})); + Catch::Matchers::UnorderedEquals({"e1u1/brlava"})); CHECK_THAT( TexNames(bsp, BSP_FindFacesAtPoint(&bsp, &bsp.dmodels[0], slimetrans66_lavatrans66, qvec3d(0, 1, 0))), - Catch::UnorderedEquals({"e1u1/brlava"})); + Catch::Matchers::UnorderedEquals({"e1u1/brlava"})); } } diff --git a/vis/CMakeLists.txt b/vis/CMakeLists.txt index d3dc8434..8957cab4 100644 --- a/vis/CMakeLists.txt +++ b/vis/CMakeLists.txt @@ -32,9 +32,8 @@ install(TARGETS vis RUNTIME DESTINATION bin) enable_testing() add_executable(testvis - test.cc test_vis.cc) -target_link_libraries(testvis PRIVATE libvis common Catch2::Catch2 fmt::fmt) +target_link_libraries(testvis PRIVATE libvis common Catch2::Catch2WithMain fmt::fmt) # HACK: copy .dll dependencies add_custom_command(TARGET testvis POST_BUILD diff --git a/vis/test.cc b/vis/test.cc deleted file mode 100644 index 60da99d7..00000000 --- a/vis/test.cc +++ /dev/null @@ -1,2 +0,0 @@ -#define CATCH_CONFIG_MAIN // request a main() -#include diff --git a/vis/test_vis.cc b/vis/test_vis.cc index a829525f..85249180 100644 --- a/vis/test_vis.cc +++ b/vis/test_vis.cc @@ -1,2 +1,2 @@ -#include +#include