update Catch2 to v3.0.1

This commit is contained in:
Eric Wasylishen 2022-06-26 13:21:29 -06:00
parent 2264de71a2
commit 22f0def4b1
16 changed files with 51 additions and 66 deletions

2
3rdparty/Catch2 vendored

@ -1 +1 @@
Subproject commit 62fd660583d3ae7a7886930b413c3c570e89786c
Subproject commit 605a34765aa5d5ecbf476b4598a862ada971b0cc

View File

@ -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")

View File

@ -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_FILE:TBB::tbb>" "$<TARGET_FILE_DIR:testcommon>")
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)

View File

@ -1,5 +1,4 @@
#define CATCH_CONFIG_MAIN // request a main()
#include <catch2/catch.hpp>
#include <catch2/catch_all.hpp>
#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]")

View File

@ -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)

View File

@ -1,2 +0,0 @@
#define CATCH_CONFIG_MAIN // request a main()
#include <catch2/catch.hpp>

View File

@ -1,4 +1,4 @@
#include <catch2/catch.hpp>
#include <catch2/catch_all.hpp>
#include <filesystem>
#include <string>

View File

@ -1,4 +1,4 @@
#include <catch2/catch.hpp>
#include <catch2/catch_all.hpp>
#include <light/entities.hh>
#include <vector>

View File

@ -1,4 +1,4 @@
#include <catch2/catch.hpp>
#include <catch2/catch_all.hpp>
#include <light/light.hh>
#include <light/entities.hh>
@ -20,9 +20,9 @@ TEST_CASE("MakeCDF", "[mathlib]")
std::vector<float> 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]")

View File

@ -1,3 +1,3 @@
#include <catch2/catch.hpp>
#include <catch2/catch_all.hpp>
#include <light/ltface.hh>

View File

@ -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

View File

@ -1,2 +0,0 @@
#define CATCH_CONFIG_MAIN // request a main()
#include <catch2/catch.hpp>

View File

@ -1,4 +1,4 @@
#include <catch2/catch.hpp>
#include <catch2/catch_all.hpp>
#include <qbsp/brush.hh>
#include <qbsp/qbsp.hh>
@ -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<uint32_t>{0,1,2,3,4,5}));
CHECK_THAT(bsp.dleaffaces, Catch::Matchers::UnorderedEquals(std::vector<uint32_t>{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<const mface_t*>{
CHECK_THAT(other_markfaces, Catch::Matchers::UnorderedEquals(std::vector<const mface_t*>{
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<dareaportal_t>{{0, 0}, {1, 1}, {1, 2}}));
CHECK_THAT(bsp.dareas, Catch::UnorderedEquals(std::vector<darea_t>{{0, 0}, {1, 1}, {1, 2}}));
CHECK_THAT(bsp.dareaportals, Catch::Matchers::UnorderedEquals(std::vector<dareaportal_t>{{0, 0}, {1, 1}, {1, 2}}));
CHECK_THAT(bsp.dareas, Catch::Matchers::UnorderedEquals(std::vector<darea_t>{{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<int32_t>{1, 2}), Catch::UnorderedEquals(std::vector<int32_t>{player_start_leaf->area, other_room_leaf->area}));
CHECK_THAT((std::vector<int32_t>{1, 2}), Catch::Matchers::UnorderedEquals(std::vector<int32_t>{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<dareaportal_t>{{0, 0}, {1, 1}, {1, 2}}));
CHECK_THAT(bsp.dareas, Catch::UnorderedEquals(std::vector<darea_t>{{0, 0}, {1, 1}, {1, 2}}));
CHECK_THAT(bsp.dareaportals, Catch::Matchers::UnorderedEquals(std::vector<dareaportal_t>{{0, 0}, {1, 1}, {1, 2}}));
CHECK_THAT(bsp.dareas, Catch::Matchers::UnorderedEquals(std::vector<darea_t>{{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<std::string>({"e1u1/bluwter", "e1u1/bluwter"}));
Catch::Matchers::UnorderedEquals<std::string>({"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<std::string>({"e1u1/c_met11_2"}));
Catch::Matchers::UnorderedEquals<std::string>({"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<std::string>({"e1u1/sewer1"}));
Catch::Matchers::UnorderedEquals<std::string>({"e1u1/sewer1"}));
CHECK_THAT(
TexNames(bsp, BSP_FindFacesAtPoint(&bsp, &bsp.dmodels[0], watertrans66_slimetrans66, qvec3d(0, 1, 0))),
Catch::UnorderedEquals<std::string>({"e1u1/sewer1"}));
Catch::Matchers::UnorderedEquals<std::string>({"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<std::string>({"e1u1/brlava"}));
Catch::Matchers::UnorderedEquals<std::string>({"e1u1/brlava"}));
CHECK_THAT(
TexNames(bsp, BSP_FindFacesAtPoint(&bsp, &bsp.dmodels[0], slimetrans66_lavatrans66, qvec3d(0, 1, 0))),
Catch::UnorderedEquals<std::string>({"e1u1/brlava"}));
Catch::Matchers::UnorderedEquals<std::string>({"e1u1/brlava"}));
}
}

View File

@ -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

View File

@ -1,2 +0,0 @@
#define CATCH_CONFIG_MAIN // request a main()
#include <catch2/catch.hpp>

View File

@ -1,2 +1,2 @@
#include <catch2/catch.hpp>
#include <catch2/catch_all.hpp>