diff --git a/conanfile.py b/conanfile.py index 208b50ba..b1c78b3f 100644 --- a/conanfile.py +++ b/conanfile.py @@ -115,7 +115,7 @@ class MPUnitsConan(ConanFile): def build_requirements(self): if self._build_all: - self.test_requires("catch2/2.13.9") + self.test_requires("catch2/3.1.0") self.test_requires("wg21-linear_algebra/0.7.2") if not self._skip_docs: self.tool_requires("doxygen/1.9.4") diff --git a/test/unit_test/runtime/CMakeLists.txt b/test/unit_test/runtime/CMakeLists.txt index 9e2c70b2..61a67670 100644 --- a/test/unit_test/runtime/CMakeLists.txt +++ b/test/unit_test/runtime/CMakeLists.txt @@ -22,13 +22,12 @@ cmake_minimum_required(VERSION 3.2) -find_package(Catch2 CONFIG REQUIRED) +find_package(Catch2 3 CONFIG REQUIRED) add_executable( - unit_tests_runtime catch_main.cpp math_test.cpp magnitude_test.cpp fmt_test.cpp fmt_units_test.cpp - distribution_test.cpp + unit_tests_runtime math_test.cpp magnitude_test.cpp fmt_test.cpp fmt_units_test.cpp distribution_test.cpp ) -target_link_libraries(unit_tests_runtime PRIVATE mp-units::mp-units Catch2::Catch2) +target_link_libraries(unit_tests_runtime PRIVATE mp-units::mp-units Catch2::Catch2WithMain) if(CMAKE_CXX_COMPILER_ID STREQUAL "MSVC") target_compile_options( diff --git a/test/unit_test/runtime/catch_main.cpp b/test/unit_test/runtime/catch_main.cpp deleted file mode 100644 index 4ed06df1..00000000 --- a/test/unit_test/runtime/catch_main.cpp +++ /dev/null @@ -1,2 +0,0 @@ -#define CATCH_CONFIG_MAIN -#include diff --git a/test/unit_test/runtime/distribution_test.cpp b/test/unit_test/runtime/distribution_test.cpp index e5dda8e6..65120cf0 100644 --- a/test/unit_test/runtime/distribution_test.cpp +++ b/test/unit_test/runtime/distribution_test.cpp @@ -20,8 +20,9 @@ // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE // SOFTWARE. -#include +#include #include +#include #include #include #include diff --git a/test/unit_test/runtime/fmt_test.cpp b/test/unit_test/runtime/fmt_test.cpp index bd317b91..bc6854ae 100644 --- a/test/unit_test/runtime/fmt_test.cpp +++ b/test/unit_test/runtime/fmt_test.cpp @@ -20,7 +20,7 @@ // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE // SOFTWARE. -#include +#include #include #include #include @@ -35,7 +35,6 @@ using namespace units; using namespace units::isq; using namespace units::isq::si; -using namespace Catch::Matchers; TEST_CASE("operator<< on a quantity", "[text][ostream][fmt]") { @@ -696,13 +695,13 @@ TEST_CASE("precision specification for integral representation should throw", "[ SECTION("full format {:%Q %q} on a quantity") { REQUIRE_THROWS_MATCHES(STD_FMT::vformat("{:%.1Q %q}", STD_FMT::make_format_args(1_q_m)), STD_FMT::format_error, - Message("precision not allowed for integral quantity representation")); + Catch::Matchers::Message("precision not allowed for integral quantity representation")); } SECTION("value only format {:%Q} on a quantity") { REQUIRE_THROWS_MATCHES(STD_FMT::vformat("{:%.1Q}", STD_FMT::make_format_args(1_q_m)), STD_FMT::format_error, - Message("precision not allowed for integral quantity representation")); + Catch::Matchers::Message("precision not allowed for integral quantity representation")); } } diff --git a/test/unit_test/runtime/fmt_units_test.cpp b/test/unit_test/runtime/fmt_units_test.cpp index 002e58fd..03067f3a 100644 --- a/test/unit_test/runtime/fmt_units_test.cpp +++ b/test/unit_test/runtime/fmt_units_test.cpp @@ -20,7 +20,7 @@ // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE // SOFTWARE. -#include +#include #include // IWYU pragma: keep #include #include diff --git a/test/unit_test/runtime/magnitude_test.cpp b/test/unit_test/runtime/magnitude_test.cpp index 87f0c473..dddd2785 100644 --- a/test/unit_test/runtime/magnitude_test.cpp +++ b/test/unit_test/runtime/magnitude_test.cpp @@ -20,7 +20,7 @@ // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE // SOFTWARE. -#include +#include #include #include #include diff --git a/test/unit_test/runtime/math_test.cpp b/test/unit_test/runtime/math_test.cpp index 783480db..dc73da88 100644 --- a/test/unit_test/runtime/math_test.cpp +++ b/test/unit_test/runtime/math_test.cpp @@ -20,13 +20,14 @@ // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE // SOFTWARE. -#include +#include #include #include #include #include #include #include +#include #include using namespace units; @@ -296,7 +297,7 @@ TEMPLATE_TEST_CASE_SIG("pow() implementation exponentiates values to power N" (std::intmax_t N, N), 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 15, 20, 25) { auto v = GENERATE(range(0.5, 20.0, 0.5)); - REQUIRE(detail::pow_impl(v) == Approx(std::pow(v, N)).epsilon(1e-15).margin(0)); + REQUIRE(detail::pow_impl(v) == Catch::Approx(std::pow(v, N)).epsilon(1e-15).margin(0)); } template