diff --git a/.clang-format b/.clang-format index 41a2d0fb3c..e5417c4504 100644 --- a/.clang-format +++ b/.clang-format @@ -10,14 +10,20 @@ Cpp11BracedListStyle: true DerivePointerAlignment: false IncludeBlocks: Regroup IncludeCategories: - - Regex: 'prelude\.(hpp|hh)' # preludes - Priority: 4 + - Regex: '".*"' # relative headers + Priority: 10 + - Regex: '(bsoncxx|mongocxx)/config(/private)?/prelude\.(hpp|hh)' # v_noabi preludes + Priority: 50 + - Regex: '(bsoncxx|mongocxx)/test/.*' # test headers + Priority: 60 - Regex: '<[[:alnum:]_.]+>' # system headers - Priority: 1 - - Regex: '.*(-|\/)fwd\.(hpp|hh)' # forwarding headers - Priority: 2 - - Regex: '.*' # driver headers - Priority: 3 + Priority: 20 + - Regex: '(bsoncxx|mongocxx)/.*(-|\/)fwd\.(hpp|hh)' # all driver forwarding headers + Priority: 30 + - Regex: '(bsoncxx|mongocxx)/.*' # all remaining (normal) driver headers + Priority: 40 + - Regex: '.*' # all other headers (third party) + Priority: 90 IndentWidth: 4 MaxEmptyLinesToKeep: 1 NamespaceIndentation: None diff --git a/.evergreen/build_snapshot_rpm.sh b/.evergreen/build_snapshot_rpm.sh index 748cc16f8c..1a9d39e21f 100755 --- a/.evergreen/build_snapshot_rpm.sh +++ b/.evergreen/build_snapshot_rpm.sh @@ -105,7 +105,7 @@ sudo mock -r ${config} --use-bootstrap-image --isolation=simple --copyout "/tmp/ sudo mock -r ${config} --use-bootstrap-image --isolation=simple --cwd "/tmp/${build_dir}" --chroot -- /bin/sh -c "( [ -d build ] || mkdir build ; cd build ; - /usr/bin/cmake -DCMAKE_BUILD_TYPE=Release -DBSONCXX_POLY_USE_BOOST=1 -DENABLE_UNINSTALL=OFF .. ; + /usr/bin/cmake -DCMAKE_BUILD_TYPE=Release -DBSONCXX_POLY_USE_BOOST=1 -DENABLE_UNINSTALL=OFF -DENABLE_TESTS=OFF .. ; make -j 8 dist )" diff --git a/.evergreen/test.sh b/.evergreen/test.sh index 8b7ef77ffe..ec99f0d385 100755 --- a/.evergreen/test.sh +++ b/.evergreen/test.sh @@ -60,6 +60,7 @@ PATH="${working_dir:?}/build/src/mongocxx/test/${build_type:?}:${PATH:-}" PATH="${working_dir:?}/build/src/bsoncxx/test/${build_type:?}:${PATH:-}" PATH="${working_dir:?}/build/src/mongocxx/${build_type:?}:${PATH:-}" PATH="${working_dir:?}/build/src/bsoncxx/${build_type:?}:${PATH:-}" +PATH="${working_dir:?}/build/_deps/ep_catch2-build/src/${build_type:?}:${PATH:-}" PATH="${mongoc_dir:?}/bin:${PATH:-}" PATH="${working_dir:?}/build/install/bin:${PATH:-}" diff --git a/.mci.yml b/.mci.yml index 370d049d8d..4f94da4431 100644 --- a/.mci.yml +++ b/.mci.yml @@ -1001,6 +1001,8 @@ tasks: - func: "setup" - func: "fetch_c_driver_source" - func: "compile" + vars: + ENABLE_TESTS: OFF - command: shell.exec type: test params: @@ -1015,6 +1017,8 @@ tasks: - func: "setup" - func: "fetch_c_driver_source" - func: "compile" + vars: + ENABLE_TESTS: OFF - command: shell.exec type: test params: @@ -2156,10 +2160,7 @@ buildvariants: run_on: - windows-64-vs2015-compile tasks: - - name: compile_and_test_with_shared_libs - - name: compile_and_test_with_shared_libs_extra_alignment - - name: compile_and_test_with_static_libs - - name: compile_and_test_with_static_libs_extra_alignment + - name: compile_without_tests - name: uninstall_check_windows - name: windows-2k8-debug @@ -2172,9 +2173,8 @@ buildvariants: run_on: - windows-64-vs2015-compile tasks: - # The debug shared lib is tested in the "integration tests" matrix - - name: compile_and_test_with_static_libs - - name: compile_and_test_with_static_libs_extra_alignment + - name: compile_without_tests + - name: uninstall_check_windows - name: windows-msvc2015-debug display_name: "Windows (VS 2015) Debug (MongoDB 4.2)" @@ -2186,8 +2186,8 @@ buildvariants: run_on: - windows-64-vs2015-compile tasks: - - name: compile_with_shared_libs - - name: compile_and_test_auth_with_shared_libs + - name: compile_without_tests + - name: uninstall_check_windows - name: packaging display_name: Linux Distro Packaging diff --git a/CHANGELOG.md b/CHANGELOG.md index 39611d7618..2e42fa9cc1 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -11,8 +11,10 @@ Changes prior to 3.9.0 are documented as [release notes on GitHub](https://githu ### Changed -- `FetchContent_MakeAvailable()` is used to populate dependencies instead of `FetchContent_Populate()` for the Mongo C Driver (when not provided by `CMAKE_PREFIX_PATH`) and mnmlstc/core (when automatically selected or `BSONCXX_POLY_USE_MNMLSTC=ON`). +- `FetchContent_MakeAvailable()` is used to populate dependencies instead of `FetchContent_Populate()` for the Mongo C Driver (when not provided by `CMAKE_PREFIX_PATH`) and mnmlstc/core (when automatically selected or when `BSONCXX_POLY_USE_MNMLSTC=ON`). - Note: `FetchContent_Populate()` is still used for mnmlstc/core for CMake versions prior to 3.18 to avoid `add_subdirectory()` behavior. +- Test suite now uses Catch2 v3 via FetchContent instead of the bundled Catch2 v2 standalone header. + - C++14 or newer is now required to build tests when enabled with `ENABLE_TESTS=ON`. ### Deprecated diff --git a/THIRD-PARTY-NOTICES b/THIRD-PARTY-NOTICES index 02f71f6afb..9deea968b6 100644 --- a/THIRD-PARTY-NOTICES +++ b/THIRD-PARTY-NOTICES @@ -15,7 +15,7 @@ https://github.com/mongodb/mongo-cxx-driver. --------------------------------------- [Note: Catch is used only for testing.] -Copyright (c) 2012 Two Blue Cubes Ltd. All rights reserved. +Copyright Catch2 Authors Distributed under the Boost Software License, Version 1.0. See http://www.boost.org/LICENSE_1_0.txt diff --git a/cmake/CMakeLists.txt b/cmake/CMakeLists.txt index b7ff0fc481..5078db9a77 100644 --- a/cmake/CMakeLists.txt +++ b/cmake/CMakeLists.txt @@ -16,6 +16,7 @@ add_subdirectory(make_dist) set(cmake_MODULES BsoncxxUtil.cmake + FetchCatch2.cmake FetchMnmlstcCore.cmake FetchMongoC.cmake MacroGuardTest.cmake diff --git a/cmake/FetchCatch2.cmake b/cmake/FetchCatch2.cmake new file mode 100644 index 0000000000..3ce6c40d2a --- /dev/null +++ b/cmake/FetchCatch2.cmake @@ -0,0 +1,46 @@ +# Use FetchContent to obtain Catch2. + +include(FetchContent) + +message(STATUS "Downloading Catch2...") + +function(fetch_catch2) + set(fetch_args "") + if (CMAKE_VERSION VERSION_GREATER_EQUAL "3.25.0") + set(fetch_args "SYSTEM") + endif() + + FetchContent_Declare( + EP_Catch2 + + GIT_REPOSITORY https://github.com/catchorg/Catch2 + GIT_TAG v3.7.0 + GIT_SHALLOW TRUE + LOG_DOWNLOAD ON + + ${fetch_args} + + FETCHCONTENT_UPDATES_DISCONNECTED ON + ) + + FetchContent_GetProperties(EP_Catch2) + + if(NOT ep_catch2_POPULATED) + # Avoid Catch2 compile warnings from being treated as errors. + string(REPLACE " -Werror" "" CMAKE_C_FLAGS "${CMAKE_C_FLAGS}") + string(REPLACE " -Werror" "" CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}") + + FetchContent_MakeAvailable(EP_Catch2) + + # Avoid building unnecessary targets. Use FetchContent_Declare(EXCLUDE_FROM_ALL) in CMake 3.28 and newer. + set_property(DIRECTORY "${ep_catch2_SOURCE_DIR}" PROPERTY EXCLUDE_FROM_ALL ON) + + # Catch2 config vars. + set_property(CACHE CATCH_INSTALL_DOCS PROPERTY VALUE OFF) + set_property(CACHE CATCH_INSTALL_EXTRAS PROPERTY VALUE OFF) + endif() +endfunction() + +fetch_catch2() + +message (STATUS "Downloading Catch2... done.") diff --git a/cmake/FetchMnmlstcCore.cmake b/cmake/FetchMnmlstcCore.cmake index e22903bbde..338399f6f4 100644 --- a/cmake/FetchMnmlstcCore.cmake +++ b/cmake/FetchMnmlstcCore.cmake @@ -7,6 +7,11 @@ set(core-subbuild "${CMAKE_CURRENT_BINARY_DIR}/_deps/core-subbuild") set(core-build "${CMAKE_CURRENT_BINARY_DIR}/_deps/core-build") set(core-install "${CMAKE_CURRENT_BINARY_DIR}/_deps/core-install") +set(fetch_args "") +if (CMAKE_VERSION VERSION_GREATER_EQUAL "3.25.0") + set(fetch_args "SYSTEM") +endif() + # Also update etc/purls.txt. FetchContent_Declare( EP_mnmlstc_core @@ -22,6 +27,8 @@ FetchContent_Declare( GIT_SHALLOW TRUE LOG_DOWNLOAD ON + ${fetch_args} + FETCHCONTENT_UPDATES_DISCONNECTED ON ) FetchContent_GetProperties(EP_mnmlstc_core) @@ -33,7 +40,7 @@ if(core_FOUND AND "$CACHE{INTERNAL_MONGOC_MNMLSTC_CORE_FOUND}") else() if(NOT ep_mnmlstc_core_POPULATED) message(STATUS "Downloading mnmlstc/core...") - if("${CMAKE_VERSION}" VERSION_LESS "3.18.0") + if(CMAKE_VERSION VERSION_LESS "3.18.0") # SOURCE_SUBDIR is not yet supported. FetchContent_Populate(EP_mnmlstc_core) else() diff --git a/cmake/FetchMongoC.cmake b/cmake/FetchMongoC.cmake index c0a1ea6919..cebbae8e30 100644 --- a/cmake/FetchMongoC.cmake +++ b/cmake/FetchMongoC.cmake @@ -4,11 +4,18 @@ include(FetchContent) message(STATUS "Download and configure C driver version ${LIBMONGOC_DOWNLOAD_VERSION} ... begin") +set(fetch_args "") +if (CMAKE_VERSION VERSION_GREATER_EQUAL "3.25.0") + set(fetch_args "SYSTEM") +endif() + # Declare mongo-c-driver as a dependency FetchContent_Declare( mongo-c-driver GIT_REPOSITORY https://github.com/mongodb/mongo-c-driver.git GIT_TAG ${LIBMONGOC_DOWNLOAD_VERSION} + + ${fetch_args} ) FetchContent_GetProperties(mongo-c-driver) diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 7f158f3d1b..c42504620a 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -12,15 +12,11 @@ # See the License for the specific language governing permissions and # limitations under the License. -add_definitions(-DMONGO_CXX_DRIVER_COMPILING) add_subdirectory(bsoncxx) add_subdirectory(mongocxx) set_local_dist(src_DIST_local CMakeLists.txt - third_party/catch/main.cpp - third_party/catch/include/catch.hpp - third_party/catch/include/helpers.hpp ) set(src_DIST diff --git a/src/bsoncxx/include/bsoncxx/v_noabi/bsoncxx/builder/list.hpp b/src/bsoncxx/include/bsoncxx/v_noabi/bsoncxx/builder/list.hpp index c2c9e6c676..832a642129 100644 --- a/src/bsoncxx/include/bsoncxx/v_noabi/bsoncxx/builder/list.hpp +++ b/src/bsoncxx/include/bsoncxx/v_noabi/bsoncxx/builder/list.hpp @@ -160,7 +160,7 @@ class document : public list { /// /// Creates an empty document. /// - document() : list({}, false, false){}; + document() : list({}, false, false) {} /// /// Creates a BSON document. @@ -184,7 +184,7 @@ class array : public list { /// /// Creates an empty array. /// - array() : list({}, false, true){}; + array() : list({}, false, true) {} /// /// Creates a BSON array. diff --git a/src/bsoncxx/test/CMakeLists.txt b/src/bsoncxx/test/CMakeLists.txt index 2b7a6482b8..603c25e665 100644 --- a/src/bsoncxx/test/CMakeLists.txt +++ b/src/bsoncxx/test/CMakeLists.txt @@ -12,6 +12,8 @@ # See the License for the specific language governing permissions and # limitations under the License. +include(FetchCatch2) + if(NOT BUILD_TESTING) set_property(DIRECTORY PROPERTY EXCLUDE_FROM_ALL TRUE) endif() @@ -46,25 +48,28 @@ add_executable(test_bson # Common target properties for test executables. add_library(bsoncxx_test_properties INTERFACE) + +target_link_libraries(bsoncxx_test_properties INTERFACE Catch2::Catch2) +target_compile_features(bsoncxx_test_properties INTERFACE cxx_std_14) + target_link_libraries(bsoncxx_test_properties INTERFACE bsoncxx_testing ${libbson_target}) target_include_directories(bsoncxx_test_properties INTERFACE # Allow `#include ` ${libbson_include_directories} - # Allow `#include ` and `#include `. + # Allow `#include `. ${CMAKE_CURRENT_SOURCE_DIR}/../.. ) target_compile_definitions(bsoncxx_test_properties INTERFACE ${libbson_definitions}) add_library(bsoncxx::test_properties ALIAS bsoncxx_test_properties) # Avoid redundant recompilation of catch/main.cpp. -add_library(bsoncxx_test_properties_with_main STATIC EXCLUDE_FROM_ALL ${THIRD_PARTY_SOURCE_DIR}/catch/main.cpp) -target_link_libraries(bsoncxx_test_properties_with_main PUBLIC bsoncxx::test_properties) +add_library(bsoncxx_test_properties_with_main INTERFACE) +target_link_libraries(bsoncxx_test_properties_with_main INTERFACE bsoncxx::test_properties Catch2::Catch2WithMain) add_library(bsoncxx::test_properties_with_main ALIAS bsoncxx_test_properties_with_main) -set_property(TARGET test_bson APPEND PROPERTY LINK_LIBRARIES bsoncxx::test_properties_with_main) - +target_link_libraries (test_bson PRIVATE bsoncxx::test_properties_with_main) add_test(NAME bson COMMAND test_bson) # Generate test to ensure macro guards behave properly. diff --git a/src/bsoncxx/test/array.cpp b/src/bsoncxx/test/array.cpp index b8743710b4..bfad640fbb 100644 --- a/src/bsoncxx/test/array.cpp +++ b/src/bsoncxx/test/array.cpp @@ -14,10 +14,11 @@ #include #include -#include #include #include +#include + namespace { using namespace bsoncxx; diff --git a/src/bsoncxx/test/bson_b_date.cpp b/src/bsoncxx/test/bson_b_date.cpp index 694010faa9..abe4274b7f 100644 --- a/src/bsoncxx/test/bson_b_date.cpp +++ b/src/bsoncxx/test/bson_b_date.cpp @@ -14,9 +14,10 @@ #include -#include #include +#include + namespace { TEST_CASE("time_point is converted to b_date and back", "[bsoncxx::types::b_date]") { using bsoncxx::types::b_date; diff --git a/src/bsoncxx/test/bson_builder.cpp b/src/bsoncxx/test/bson_builder.cpp index 134af723af..f43b7c806a 100644 --- a/src/bsoncxx/test/bson_builder.cpp +++ b/src/bsoncxx/test/bson_builder.cpp @@ -24,10 +24,14 @@ #include #include #include -#include #include #include +#include + +#include +#include + namespace { using namespace bsoncxx; @@ -1711,12 +1715,12 @@ TEST_CASE("list builder with explicit type deduction", "[bsoncxx::builder::list] SECTION("document") { builder::list b; - auto kvp_regex = - Catch::Matches("(.*)must be list of key-value pairs(.*)", Catch::CaseSensitive::No); + auto kvp_regex = Catch::Matchers::Matches("(.*)must be list of key-value pairs(.*)", + Catch::CaseSensitive::No); REQUIRE_THROWS_WITH((b = builder::document{"foo", 1, 2}), kvp_regex); - auto type_regex = - Catch::Matches("(.*)must be string type(.*)int32(.*)", Catch::CaseSensitive::No); + auto type_regex = Catch::Matchers::Matches("(.*)must be string type(.*)int32(.*)", + Catch::CaseSensitive::No); REQUIRE_THROWS_WITH((b = builder::document{"foo", 1, 2, 4}), type_regex); } } diff --git a/src/bsoncxx/test/bson_get_values.cpp b/src/bsoncxx/test/bson_get_values.cpp index 9377894015..7cbe813bca 100644 --- a/src/bsoncxx/test/bson_get_values.cpp +++ b/src/bsoncxx/test/bson_get_values.cpp @@ -17,6 +17,7 @@ #include #include #include + #include namespace { diff --git a/src/bsoncxx/test/bson_serialization.cpp b/src/bsoncxx/test/bson_serialization.cpp index c95f5b9db4..e7261cd5ba 100644 --- a/src/bsoncxx/test/bson_serialization.cpp +++ b/src/bsoncxx/test/bson_serialization.cpp @@ -17,9 +17,10 @@ #include #include #include -#include #include +#include + namespace { using namespace bsoncxx; diff --git a/src/bsoncxx/test/bson_types.cpp b/src/bsoncxx/test/bson_types.cpp index 4545587d96..f791409d6b 100644 --- a/src/bsoncxx/test/bson_types.cpp +++ b/src/bsoncxx/test/bson_types.cpp @@ -18,10 +18,13 @@ #include #include #include -#include #include #include +#include + +#include + namespace { using namespace bsoncxx; @@ -153,7 +156,7 @@ TEST_CASE("b_int32", "[bsoncxx::type::b_int32]") { REQUIRE(!(a == c)); } -TEST_CASE("b_timestamp", "[bsoncxx::type::b_timestamp") { +TEST_CASE("b_timestamp", "[bsoncxx::type::b_timestamp]") { b_timestamp a{100, 1000}; b_timestamp b{100, 1000}; b_timestamp c{200, 1000}; @@ -373,22 +376,25 @@ TEST_CASE("document uninitialized element throws exceptions", "") { bsoncxx::document::value doc = make_document(kvp("foo", "bar")); REQUIRE_THROWS_WITH(doc["doesnotexist"].get_string().value, - Catch::Contains("cannot get string from an uninitialized element with key " - "\"doesnotexist\": unset document::element")); + + Catch::Matchers::ContainsSubstring( + "cannot get string from an uninitialized element with key " + "\"doesnotexist\": unset document::element")); REQUIRE_THROWS_WITH(doc["alsodoesnotexist"].get_value(), - Catch::Contains("cannot return the type of uninitialized element with key " - "\"alsodoesnotexist\": unset document::element")); + Catch::Matchers::ContainsSubstring( + "cannot return the type of uninitialized element with key " + "\"alsodoesnotexist\": unset document::element")); // Ensure a non-existing element evaluates to false. REQUIRE(!doc["doesnotexist"]); // Ensure finding a non-existing element results in an end iterator. REQUIRE(doc.find("doesnotexist") == doc.cend()); // Ensure getting a key from a non-existing element results in an exception. - REQUIRE_THROWS_WITH( - doc["doesnotexist"].key(), - Catch::Contains("cannot return the key from an uninitialized element with key " - "\"doesnotexist\": unset document::element")); + REQUIRE_THROWS_WITH(doc["doesnotexist"].key(), + Catch::Matchers::ContainsSubstring( + "cannot return the key from an uninitialized element with key " + "\"doesnotexist\": unset document::element")); } TEST_CASE("array uninitialized element throws exceptions", "") { @@ -397,16 +403,17 @@ TEST_CASE("array uninitialized element throws exceptions", "") { bsoncxx::array::value arr = make_array("a", "b", "c"); REQUIRE_THROWS_WITH(arr.view()[3].get_string().value, - Catch::Contains("cannot get string from an uninitialized element with key " - "\"3\": unset document::element")); + Catch::Matchers::ContainsSubstring( + "cannot get string from an uninitialized element with key " + "\"3\": unset document::element")); // Ensure a non-existing element evaluates to false. REQUIRE(!arr.view()[3]); // Ensure finding a non-existing element results in an end iterator. REQUIRE(arr.view().find(3) == arr.view().cend()); // Ensure getting a key from a non-existing element results in an exception. - REQUIRE_THROWS_WITH( - arr.view()[3].key(), - Catch::Contains("cannot return the key from an uninitialized element with key " - "\"3\": unset document::element")); + REQUIRE_THROWS_WITH(arr.view()[3].key(), + Catch::Matchers::ContainsSubstring( + "cannot return the key from an uninitialized element with key " + "\"3\": unset document::element")); } } // namespace diff --git a/src/bsoncxx/test/bson_util_itoa.cpp b/src/bsoncxx/test/bson_util_itoa.cpp index 4f617dbd4a..463e576838 100644 --- a/src/bsoncxx/test/bson_util_itoa.cpp +++ b/src/bsoncxx/test/bson_util_itoa.cpp @@ -13,6 +13,7 @@ // limitations under the License. #include + #include namespace { diff --git a/src/bsoncxx/test/bson_validate.cpp b/src/bsoncxx/test/bson_validate.cpp index 7c43eb43a9..8970c38fe9 100644 --- a/src/bsoncxx/test/bson_validate.cpp +++ b/src/bsoncxx/test/bson_validate.cpp @@ -18,9 +18,10 @@ #include #include #include -#include #include +#include + namespace { using namespace bsoncxx; diff --git a/src/bsoncxx/test/bson_value.cpp b/src/bsoncxx/test/bson_value.cpp index 30bbbd4f20..e5d80164ec 100644 --- a/src/bsoncxx/test/bson_value.cpp +++ b/src/bsoncxx/test/bson_value.cpp @@ -19,11 +19,12 @@ #include #include #include -#include #include #include #include +#include + namespace { using namespace bsoncxx; diff --git a/src/bsoncxx/test/catch.hh b/src/bsoncxx/test/catch.hh index 859c9b96e3..cba3f7f20c 100644 --- a/src/bsoncxx/test/catch.hh +++ b/src/bsoncxx/test/catch.hh @@ -19,13 +19,15 @@ #include #include #include -#include -#include #include +#include + +#include // TEST_CASE, SECTION, CHECK, etc. +#include // Catch::StringMaker + namespace Catch { -using namespace bsoncxx; // Catch2 must be able to stringify documents, optionals, etc. if they're used in Catch2 macros. @@ -39,7 +41,7 @@ struct StringMaker { template <> struct StringMaker { static std::string convert(const bsoncxx::document::view& value) { - return bsoncxx::to_json(value, ExtendedJsonMode::k_relaxed); + return bsoncxx::to_json(value, bsoncxx::ExtendedJsonMode::k_relaxed); } }; @@ -60,6 +62,7 @@ struct StringMaker { template <> struct StringMaker { static std::string convert(const bsoncxx::types::bson_value::view& value) { + using bsoncxx::to_string; return '{' + to_string(value.type()) + ": " + to_string(value) + '}'; } }; @@ -79,7 +82,7 @@ struct StringMaker { }; template -struct StringMaker> { +struct StringMaker> { static std::string convert(const bsoncxx::stdx::optional& value) { if (value) { return StringMaker::convert(value.value()); @@ -90,7 +93,7 @@ struct StringMaker> { }; template <> -struct StringMaker> { +struct StringMaker> { static std::string convert(const bsoncxx::stdx::optional&) { return "{nullopt}"; } diff --git a/src/bsoncxx/test/exception_guard.cpp b/src/bsoncxx/test/exception_guard.cpp index 8fe299fa2d..a1138d97ae 100644 --- a/src/bsoncxx/test/exception_guard.cpp +++ b/src/bsoncxx/test/exception_guard.cpp @@ -25,6 +25,8 @@ #include +#include + namespace { TEST_CASE("bsoncxx::test::exception_guard", "[test]") { @@ -126,7 +128,7 @@ TEST_CASE("bsoncxx::test::exception_guard", "[test]") { CAPTURE(expected.line); CAPTURE(expected.func); - CHECK_THAT(log, Catch::Contains("two")); + CHECK_THAT(log, Catch::Matchers::ContainsSubstring("two")); CHECK(log_view.find(expected.file) != npos); CHECK(log_view.find(std::to_string(expected.line)) != npos); CHECK(log_view.find(expected.func) == npos); // Func is not logged. @@ -148,7 +150,7 @@ TEST_CASE("bsoncxx::test::exception_guard", "[test]") { CAPTURE(expected.line); CAPTURE(expected.func); - CHECK_THAT(log, Catch::Contains("Catch::TestFailureException")); + CHECK_THAT(log, Catch::Matchers::ContainsSubstring("Catch::TestFailureException")); CHECK(log_view.find(expected.file) != npos); CHECK(log_view.find(std::to_string(expected.line)) != npos); CHECK(log_view.find(expected.func) == npos); // Func is not logged. @@ -156,7 +158,7 @@ TEST_CASE("bsoncxx::test::exception_guard", "[test]") { // The original exception. const auto check_expr = [&] { BSONCXX_TEST_EXCEPTION_GUARD_CHECK(eguard); }; - REQUIRE_THROWS_WITH(check_expr(), Catch::Contains("one")); + REQUIRE_THROWS_WITH(check_expr(), Catch::Matchers::ContainsSubstring("one")); } } diff --git a/src/bsoncxx/test/exception_guard.hh b/src/bsoncxx/test/exception_guard.hh index 61282b46b3..d6a29b45d0 100644 --- a/src/bsoncxx/test/exception_guard.hh +++ b/src/bsoncxx/test/exception_guard.hh @@ -22,10 +22,11 @@ #include #include -#include #include +#include + namespace bsoncxx { namespace test { diff --git a/src/bsoncxx/test/json.cpp b/src/bsoncxx/test/json.cpp index 7fe7963142..5e0b380e05 100644 --- a/src/bsoncxx/test/json.cpp +++ b/src/bsoncxx/test/json.cpp @@ -19,6 +19,7 @@ #include #include #include + #include namespace { diff --git a/src/bsoncxx/test/make_unique.test.cpp b/src/bsoncxx/test/make_unique.test.cpp index 73ef238521..a71792448e 100644 --- a/src/bsoncxx/test/make_unique.test.cpp +++ b/src/bsoncxx/test/make_unique.test.cpp @@ -3,6 +3,7 @@ #include #include + #include namespace { diff --git a/src/bsoncxx/test/oid.cpp b/src/bsoncxx/test/oid.cpp index 0603db3975..50a43de820 100644 --- a/src/bsoncxx/test/oid.cpp +++ b/src/bsoncxx/test/oid.cpp @@ -21,6 +21,7 @@ #include #include + #include using namespace bsoncxx; diff --git a/src/bsoncxx/test/optional.test.cpp b/src/bsoncxx/test/optional.test.cpp index d3de72e132..904eaebc72 100644 --- a/src/bsoncxx/test/optional.test.cpp +++ b/src/bsoncxx/test/optional.test.cpp @@ -10,10 +10,11 @@ #include #include #include -#include #include +#include + // Each polyfill library has some set of features that are not conformant with the standard // specification (inconsistent, missing, etc.). Limit testing to bsoncxx implementation and stdlib. #if defined(BSONCXX_POLY_USE_IMPLS) || defined(BSONCXX_POLY_USE_STD) diff --git a/src/bsoncxx/test/string_view.test.cpp b/src/bsoncxx/test/string_view.test.cpp index b9ca5874bf..76bcf2c1e5 100644 --- a/src/bsoncxx/test/string_view.test.cpp +++ b/src/bsoncxx/test/string_view.test.cpp @@ -17,10 +17,11 @@ #include #include #include -#include #include +#include + namespace stdx = bsoncxx::stdx; using stdx::string_view; diff --git a/src/bsoncxx/test/type_traits.test.cpp b/src/bsoncxx/test/type_traits.test.cpp index dc14cbbefa..62354afe79 100644 --- a/src/bsoncxx/test/type_traits.test.cpp +++ b/src/bsoncxx/test/type_traits.test.cpp @@ -2,10 +2,11 @@ #include #include -#include #include +#include + // We declare variables that are only used for compilation checking BSONCXX_DISABLE_WARNING(GNU("-Wunused")); diff --git a/src/bsoncxx/test/view_or_value.cpp b/src/bsoncxx/test/view_or_value.cpp index 7808f5e2ed..1e01f96656 100644 --- a/src/bsoncxx/test/view_or_value.cpp +++ b/src/bsoncxx/test/view_or_value.cpp @@ -19,6 +19,7 @@ #include #include #include + #include namespace { diff --git a/src/mongocxx/test/CMakeLists.txt b/src/mongocxx/test/CMakeLists.txt index 4bf8e8eb12..2550b65b9b 100644 --- a/src/mongocxx/test/CMakeLists.txt +++ b/src/mongocxx/test/CMakeLists.txt @@ -12,6 +12,8 @@ # See the License for the specific language governing permissions and # limitations under the License. +include(FetchCatch2) + if(NOT BUILD_TESTING) set_property(DIRECTORY PROPERTY EXCLUDE_FROM_ALL TRUE) endif() @@ -174,20 +176,23 @@ add_executable(test_versioned_api # Common target properties for test executables. add_library(mongocxx_test_properties INTERFACE) + +target_link_libraries(mongocxx_test_properties INTERFACE Catch2::Catch2) +target_compile_features(mongocxx_test_properties INTERFACE cxx_std_14) + target_link_libraries(mongocxx_test_properties INTERFACE mongocxx_mocked ${libmongoc_target}) target_include_directories(mongocxx_test_properties INTERFACE # Allow `#include ` ${libmongoc_include_directories} - # Allow `#include ` and `#include `. + # Allow `#include `. ${CMAKE_CURRENT_SOURCE_DIR}/../.. ) add_library(mongocxx::test_properties ALIAS mongocxx_test_properties) -# Avoid redundant recompilation of catch/main.cpp. -add_library(mongocxx_test_properties_with_main STATIC EXCLUDE_FROM_ALL ${THIRD_PARTY_SOURCE_DIR}/catch/main.cpp) -target_link_libraries(mongocxx_test_properties_with_main PUBLIC mongocxx::test_properties) +add_library(mongocxx_test_properties_with_main INTERFACE) +target_link_libraries(mongocxx_test_properties_with_main INTERFACE mongocxx::test_properties Catch2::Catch2WithMain) add_library(mongocxx::test_properties_with_main ALIAS mongocxx_test_properties_with_main) set_property( @@ -341,6 +346,7 @@ endif() set_dist_list(src_mongocxx_test_DIST CMakeLists.txt bulk_write.cpp + catch_helpers.hh change_streams.cpp client_helpers.cpp client_helpers.hh diff --git a/src/mongocxx/test/bulk_write.cpp b/src/mongocxx/test/bulk_write.cpp index 66eb45a669..5266b9c34f 100644 --- a/src/mongocxx/test/bulk_write.cpp +++ b/src/mongocxx/test/bulk_write.cpp @@ -13,15 +13,16 @@ // limitations under the License. #include -#include #include #include #include #include #include -#include #include +#include +#include + namespace { using namespace mongocxx; diff --git a/src/third_party/catch/include/helpers.hpp b/src/mongocxx/test/catch_helpers.hh similarity index 79% rename from src/third_party/catch/include/helpers.hpp rename to src/mongocxx/test/catch_helpers.hh index 56ab27df33..f16c6a04fc 100644 --- a/src/third_party/catch/include/helpers.hpp +++ b/src/mongocxx/test/catch_helpers.hh @@ -14,34 +14,41 @@ #pragma once -#include #include #include #include +#include + +#include +#include +#include + namespace mongocxx { namespace test_util { // Check that an error message includes a substring, case-insensitively. Use like: // REQUIRE_THROWS_MATCHES(function(), mongocxx::exception, mongocxx_exception_matcher("substring") -class mongocxx_exception_matcher : public Catch::MatcherBase { +class mongocxx_exception_matcher : public Catch::Matchers::MatcherBase { std::string expected_msg; -public: + public: mongocxx_exception_matcher(std::string msg) : expected_msg(msg) {} bool match(const mongocxx::exception& exc) const override { - return Catch::Contains(expected_msg, Catch::CaseSensitive::No).match(exc.what()); + return Catch::Matchers::ContainsSubstring(expected_msg, Catch::CaseSensitive::No) + .match(exc.what()); } std::string describe() const override { - return std::string("mongocxx::exception was expected to contain the message: \"") + expected_msg + "\""; + return std::string("mongocxx::exception was expected to contain the message: \"") + + expected_msg + "\""; } }; -} // namespace test_util -} // namespace mongocxx +} // namespace test_util +} // namespace mongocxx #define CHECK_OPTIONAL_ARGUMENT(OBJECT, NAME, VALUE) \ SECTION("has NAME disengaged") { \ @@ -51,7 +58,8 @@ class mongocxx_exception_matcher : public Catch::MatcherBaseinterpose([](::mongoc_client_pool_t*, const ::mongoc_ssl_opt_t*) {}); + client_pool_set_ssl_opts->interpose( \ + [](::mongoc_client_pool_t*, const ::mongoc_ssl_opt_t*) {}); \ + ((void)0) #else #define MOCK_POOL MOCK_POOL_NOSSL #endif @@ -82,17 +93,20 @@ class mongocxx_exception_matcher : public Catch::MatcherBaseinterpose([](mongoc_client_t*, const mongoc_write_concern_t*) {}) \ .forever(); \ auto client_reset = libmongoc::client_reset.create_instance(); \ - client_reset->interpose([](const mongoc_client_t*){}).forever(); \ + client_reset->interpose([](const mongoc_client_t*) {}).forever(); \ auto client_get_concern = libmongoc::client_get_write_concern.create_instance(); \ client_get_concern->interpose([](const mongoc_client_t*) { return nullptr; }).forever(); \ auto client_start_session = libmongoc::client_start_session.create_instance(); \ - auto client_find_databases_with_opts = mongocxx::libmongoc::client_find_databases_with_opts.create_instance(); + auto client_find_databases_with_opts = \ + mongocxx::libmongoc::client_find_databases_with_opts.create_instance(); \ + ((void)0) #if defined(MONGOCXX_ENABLE_SSL) && defined(MONGOC_ENABLE_SSL) -#define MOCK_CLIENT \ - MOCK_CLIENT_NOSSL \ - auto client_set_ssl_opts = libmongoc::client_set_ssl_opts.create_instance(); \ - client_set_ssl_opts->interpose([](::mongoc_client_t*, const ::mongoc_ssl_opt_t*) {}); +#define MOCK_CLIENT \ + MOCK_CLIENT_NOSSL; \ + auto client_set_ssl_opts = libmongoc::client_set_ssl_opts.create_instance(); \ + client_set_ssl_opts->interpose([](::mongoc_client_t*, const ::mongoc_ssl_opt_t*) {}); \ + ((void)0) #else #define MOCK_CLIENT MOCK_CLIENT_NOSSL #endif @@ -128,7 +142,8 @@ class mongocxx_exception_matcher : public Catch::MatcherBaseinterpose([](mongoc_collection_t*) { return "dummy_collection"; }); \ auto collection_rename = libmongoc::collection_rename.create_instance(); \ auto collection_find_and_modify_with_opts = \ - libmongoc::collection_find_and_modify_with_opts.create_instance(); + libmongoc::collection_find_and_modify_with_opts.create_instance(); \ + ((void)0) -#define MOCK_CHANGE_STREAM \ - auto collection_watch = libmongoc::collection_watch.create_instance(); \ - auto database_watch = libmongoc::database_watch.create_instance(); \ - auto client_watch = libmongoc::client_watch.create_instance(); \ - auto change_stream_destroy = libmongoc::change_stream_destroy.create_instance(); \ - auto change_stream_next = libmongoc::change_stream_next.create_instance(); \ - auto change_stream_error_document = libmongoc::change_stream_error_document.create_instance(); +#define MOCK_CHANGE_STREAM \ + auto collection_watch = libmongoc::collection_watch.create_instance(); \ + auto database_watch = libmongoc::database_watch.create_instance(); \ + auto client_watch = libmongoc::client_watch.create_instance(); \ + auto change_stream_destroy = libmongoc::change_stream_destroy.create_instance(); \ + auto change_stream_next = libmongoc::change_stream_next.create_instance(); \ + auto change_stream_error_document = libmongoc::change_stream_error_document.create_instance(); \ + ((void)0) #define MOCK_FAM \ auto find_and_modify_opts_destroy = libmongoc::find_and_modify_opts_destroy.create_instance(); \ @@ -181,42 +198,48 @@ class mongocxx_exception_matcher : public Catch::MatcherBaseinterpose([&expected_find_and_modify_opts_fields]( \ - mongoc_find_and_modify_opts_t*, const ::bson_t* fields) { \ - auto fields_view = bsoncxx::helpers::view_from_bson_t(fields); \ - REQUIRE(fields_view == expected_find_and_modify_opts_fields); \ - return true; \ - }); \ + find_and_modify_opts_set_fields->interpose( \ + [&expected_find_and_modify_opts_fields](mongoc_find_and_modify_opts_t*, \ + const ::bson_t* fields) { \ + auto fields_view = bsoncxx::helpers::view_from_bson_t(fields); \ + REQUIRE(fields_view == expected_find_and_modify_opts_fields); \ + return true; \ + }); \ ::mongoc_find_and_modify_flags_t expected_find_and_modify_opts_flags; \ auto find_and_modify_opts_set_flags = \ libmongoc::find_and_modify_opts_set_flags.create_instance(); \ - find_and_modify_opts_set_flags->interpose([&expected_find_and_modify_opts_flags]( \ - mongoc_find_and_modify_opts_t*, const ::mongoc_find_and_modify_flags_t flags) { \ - REQUIRE(flags == expected_find_and_modify_opts_flags); \ - return true; \ - }); \ + find_and_modify_opts_set_flags->interpose( \ + [&expected_find_and_modify_opts_flags](mongoc_find_and_modify_opts_t*, \ + const ::mongoc_find_and_modify_flags_t flags) { \ + REQUIRE(flags == expected_find_and_modify_opts_flags); \ + return true; \ + }); \ bsoncxx::document::view expected_find_and_modify_opts_sort; \ auto find_and_modify_opts_set_sort = \ libmongoc::find_and_modify_opts_set_sort.create_instance(); \ - find_and_modify_opts_set_sort->interpose([&expected_find_and_modify_opts_sort]( \ - mongoc_find_and_modify_opts_t*, const ::bson_t* sort) { \ - auto sort_view = bsoncxx::helpers::view_from_bson_t(sort); \ - REQUIRE(sort_view == expected_find_and_modify_opts_sort); \ - return true; \ - }); \ + find_and_modify_opts_set_sort->interpose( \ + [&expected_find_and_modify_opts_sort](mongoc_find_and_modify_opts_t*, \ + const ::bson_t* sort) { \ + auto sort_view = bsoncxx::helpers::view_from_bson_t(sort); \ + REQUIRE(sort_view == expected_find_and_modify_opts_sort); \ + return true; \ + }); \ bsoncxx::document::view expected_find_and_modify_opts_update; \ auto find_and_modify_opts_set_update = \ libmongoc::find_and_modify_opts_set_update.create_instance(); \ - find_and_modify_opts_set_update->interpose([&expected_find_and_modify_opts_update]( \ - mongoc_find_and_modify_opts_t*, const ::bson_t* update) { \ - auto update_view = bsoncxx::helpers::view_from_bson_t(update); \ - REQUIRE(update_view == expected_find_and_modify_opts_update); \ - return true; \ - }); + find_and_modify_opts_set_update->interpose( \ + [&expected_find_and_modify_opts_update](mongoc_find_and_modify_opts_t*, \ + const ::bson_t* update) { \ + auto update_view = bsoncxx::helpers::view_from_bson_t(update); \ + REQUIRE(update_view == expected_find_and_modify_opts_update); \ + return true; \ + }); \ + ((void)0) #define MOCK_CURSOR \ auto cursor_destroy = libmongoc::cursor_destroy.create_instance(); \ - cursor_destroy->interpose([&](mongoc_cursor_t*) {}); + cursor_destroy->interpose([&](mongoc_cursor_t*) {}); \ + ((void)0) #define MOCK_BULK \ auto bulk_operation_insert_with_opts = \ @@ -241,7 +264,8 @@ class mongocxx_exception_matcher : public Catch::MatcherBase diff --git a/src/mongocxx/test/change_streams.cpp b/src/mongocxx/test/change_streams.cpp index 4137f63abf..76724dac64 100644 --- a/src/mongocxx/test/change_streams.cpp +++ b/src/mongocxx/test/change_streams.cpp @@ -18,7 +18,6 @@ #include #include #include -#include #include #include #include @@ -27,9 +26,11 @@ #include #include #include -#include #include -#include + +#include +#include +#include namespace { @@ -192,7 +193,7 @@ TEST_CASE("Spec Prose Tests") { } TEST_CASE("Mock streams and error-handling") { - MOCK_CHANGE_STREAM + MOCK_CHANGE_STREAM; instance::current(); client mongodb_client{uri{}, test_util::add_test_server_api()}; diff --git a/src/mongocxx/test/client.cpp b/src/mongocxx/test/client.cpp index 0ceacda416..4caeaa49dd 100644 --- a/src/mongocxx/test/client.cpp +++ b/src/mongocxx/test/client.cpp @@ -13,24 +13,25 @@ // limitations under the License. #include -#include #include #include #include #include #include #include -#include #include -#include #include +#include +#include +#include + namespace { using namespace mongocxx; TEST_CASE("A default constructed client is false-ish", "[client]") { - MOCK_CLIENT + MOCK_CLIENT; instance::current(); @@ -49,7 +50,7 @@ TEST_CASE("A client lists its databases with a filter applied", "[client]") { using bsoncxx::builder::basic::kvp; using bsoncxx::builder::basic::make_document; - MOCK_CLIENT + MOCK_CLIENT; instance::current(); auto client_list_databases_called = false; @@ -76,7 +77,7 @@ TEST_CASE("list databases passes authorizedDatabases option", "[client]") { using bsoncxx::builder::basic::kvp; using bsoncxx::builder::basic::make_document; - MOCK_CLIENT + MOCK_CLIENT; bool called = false; stdx::optional opts_passed; @@ -113,7 +114,7 @@ TEST_CASE("list databases passes authorizedDatabases option", "[client]") { } TEST_CASE("A client constructed with a URI is truthy", "[client]") { - MOCK_CLIENT + MOCK_CLIENT; instance::current(); @@ -122,7 +123,7 @@ TEST_CASE("A client constructed with a URI is truthy", "[client]") { } TEST_CASE("A client connects to a provided mongodb uri", "[client]") { - MOCK_CLIENT + MOCK_CLIENT; instance::current(); @@ -140,7 +141,7 @@ TEST_CASE("A client connects to a provided mongodb uri", "[client]") { } TEST_CASE("A client throws if its underlying mongoc client is NULL", "[client]") { - MOCK_CLIENT + MOCK_CLIENT; instance::current(); @@ -150,7 +151,7 @@ TEST_CASE("A client throws if its underlying mongoc client is NULL", "[client]") } TEST_CASE("A client cleans up its underlying mongoc client on destruction", "[client]") { - MOCK_CLIENT + MOCK_CLIENT; instance::current(); @@ -166,7 +167,7 @@ TEST_CASE("A client cleans up its underlying mongoc client on destruction", "[cl } TEST_CASE("A client supports move operations", "[client]") { - MOCK_CLIENT + MOCK_CLIENT; instance::current(); @@ -183,7 +184,7 @@ TEST_CASE("A client supports move operations", "[client]") { } TEST_CASE("A client has a settable Read Concern", "[client]") { - MOCK_CLIENT + MOCK_CLIENT; instance::current(); @@ -207,7 +208,7 @@ TEST_CASE("A client has a settable Read Concern", "[client]") { } TEST_CASE("A client's read preferences may be set and obtained", "[client]") { - MOCK_CLIENT + MOCK_CLIENT; instance::current(); @@ -290,7 +291,7 @@ TEST_CASE("A client can delete apm options and the callbacks will still work pro } TEST_CASE("A client's write concern may be set and obtained", "[client]") { - MOCK_CLIENT + MOCK_CLIENT; instance::current(); @@ -331,7 +332,7 @@ TEST_CASE("A client's write concern may be set and obtained", "[client]") { } TEST_CASE("A client can be reset", "[client]") { - MOCK_CLIENT + MOCK_CLIENT; instance::current(); @@ -345,7 +346,7 @@ TEST_CASE("A client can be reset", "[client]") { } TEST_CASE("A client can create a named database object", "[client]") { - MOCK_CLIENT + MOCK_CLIENT; instance::current(); @@ -427,7 +428,7 @@ TEST_CASE("integration tests for client metadata handshake feature") { #if defined(MONGOCXX_ENABLE_SSL) && defined(MONGOC_ENABLE_SSL) TEST_CASE("A client can be constructed with SSL options", "[client]") { - MOCK_CLIENT + MOCK_CLIENT; instance::current(); diff --git a/src/mongocxx/test/client_helpers.cpp b/src/mongocxx/test/client_helpers.cpp index 42369ac3ba..64e0137eaf 100644 --- a/src/mongocxx/test/client_helpers.cpp +++ b/src/mongocxx/test/client_helpers.cpp @@ -28,7 +28,6 @@ #include #include #include -#include #include #include #include @@ -36,10 +35,12 @@ #include #include #include -#include #include +#include +#include + namespace mongocxx { namespace test_util { diff --git a/src/mongocxx/test/client_helpers.hh b/src/mongocxx/test/client_helpers.hh index 275a98cfef..e89a73b270 100644 --- a/src/mongocxx/test/client_helpers.hh +++ b/src/mongocxx/test/client_helpers.hh @@ -25,7 +25,6 @@ #include #include #include -#include #include #include #include @@ -35,6 +34,8 @@ #include +#include + namespace mongocxx { namespace test_util { diff --git a/src/mongocxx/test/client_session.cpp b/src/mongocxx/test/client_session.cpp index cd5edc4218..6d0e8fdadf 100644 --- a/src/mongocxx/test/client_session.cpp +++ b/src/mongocxx/test/client_session.cpp @@ -16,15 +16,18 @@ #include #include -#include #include #include #include #include #include #include + +#include +#include #include -#include + +#include namespace { using bsoncxx::from_json; @@ -155,7 +158,7 @@ TEST_CASE("session options", "[session]") { TEST_CASE("start_session failure", "[session]") { using namespace mongocxx::test_util; - MOCK_CLIENT + MOCK_CLIENT; instance::current(); @@ -232,8 +235,6 @@ TEST_CASE("session", "[session]") { } SECTION("wrong client") { - using Catch::Matchers::Contains; - // "Session argument is for the right client" test from Driver Sessions Spec. // Passing a session from client "c" should fail with client "c2" and related objects. client c2{uri{}, test_util::add_test_server_api()}; diff --git a/src/mongocxx/test/client_side_encryption.cpp b/src/mongocxx/test/client_side_encryption.cpp index d7ffbc0dc6..8f7afe350d 100644 --- a/src/mongocxx/test/client_side_encryption.cpp +++ b/src/mongocxx/test/client_side_encryption.cpp @@ -23,7 +23,6 @@ #include #include #include -#include #include #include #include @@ -37,14 +36,18 @@ #include #include #include -#include -#include #include #include -#include #include +#include +#include +#include +#include + +#include + namespace { const auto kLocalMasterKey = "\x32\x78\x34\x34\x2b\x78\x64\x75\x54\x61\x42\x42\x6b\x59\x31\x36\x45\x72" @@ -1717,13 +1720,14 @@ TEST_CASE("Bypass spawning mongocryptd", "[client_side_encryption]") { REQUIRE_THROWS(ping_client["admin"].run_command(make_document(kvp("ping", 1)))); } -class kms_tls_expired_cert_matcher : public Catch::MatcherBase { +class kms_tls_expired_cert_matcher : public Catch::Matchers::MatcherBase { public: bool match(const mongocxx::exception& exc) const override { - return (Catch::Contains("certificate has expired") || // OpenSSL - Catch::Contains("CSSMERR_TP_CERT_EXPIRED") || // Secure Transport - Catch::Contains("certificate has expired") || // Secure Channel - Catch::Contains("certificate has expired")) // LibreSSL + return (Catch::Matchers::ContainsSubstring("certificate has expired") || // OpenSSL + Catch::Matchers::ContainsSubstring( + "CSSMERR_TP_CERT_EXPIRED") || // Secure Transport + Catch::Matchers::ContainsSubstring("certificate has expired") || // Secure Channel + Catch::Matchers::ContainsSubstring("certificate has expired")) // LibreSSL .match(exc.what()); } @@ -1779,13 +1783,15 @@ TEST_CASE("KMS TLS expired certificate", "[client_side_encryption]") { kms_tls_expired_cert_matcher()); } -class kms_tls_wrong_host_cert_matcher : public Catch::MatcherBase { +class kms_tls_wrong_host_cert_matcher : public Catch::Matchers::MatcherBase { public: bool match(const mongocxx::exception& exc) const override { - return (Catch::Contains("IP address mismatch") || // OpenSSL - Catch::Contains("Host name mismatch") || // Secure Transport - Catch::Contains("hostname doesn't match certificate") || // Secure Channel - Catch::Contains("not present in server certificate")) // LibreSSL + return (Catch::Matchers::ContainsSubstring("IP address mismatch") || // OpenSSL + Catch::Matchers::ContainsSubstring("Host name mismatch") || // Secure Transport + Catch::Matchers::ContainsSubstring( + "hostname doesn't match certificate") || // Secure Channel + Catch::Matchers::ContainsSubstring( + "not present in server certificate")) // LibreSSL .match(exc.what()); } @@ -1949,8 +1955,9 @@ TEST_CASE("KMS TLS Options Tests", "[client_side_encryption][!mayfail]") { auto client_encryption_invalid_hostname = make_prose_test_11_ce( &setup_client, "127.0.0.1:9001", "127.0.0.1:9001", "127.0.0.1:9001", with_certs::ca_only); - const auto expired_cert_matcher = Catch::Contains("expired", Catch::CaseSensitive::No); - const auto invalid_hostname_matcher = Catch::Matches( + const auto expired_cert_matcher = + Catch::Matchers::ContainsSubstring("expired", Catch::CaseSensitive::No); + const auto invalid_hostname_matcher = Catch::Matchers::Matches( // Content of error message may vary depending on the SSL library being used. ".*(mismatch|doesn't match|not present).*", Catch::CaseSensitive::No); @@ -1985,7 +1992,7 @@ TEST_CASE("KMS TLS Options Tests", "[client_side_encryption][!mayfail]") { << "arn:aws:kms:us-east-1:579766882180:key/89fcc2c4-08b0-4bd9-9f25-e30687b580d0" << "endpoint" << "127.0.0.1:9002" << finalize)), - Catch::Contains("parse error", Catch::CaseSensitive::No)); + Catch::Matchers::ContainsSubstring("parse error", Catch::CaseSensitive::No)); // Expect an error indicating TLS handshake failed due to an expired certificate. CHECK_THROWS_WITH( @@ -2032,8 +2039,9 @@ TEST_CASE("KMS TLS Options Tests", "[client_side_encryption][!mayfail]") { // Expect an error from libmongocrypt with a message containing the string: "HTTP // status=404". This implies TLS handshake succeeded. - CHECK_THROWS_WITH(client_encryption_with_tls.create_data_key("azure", opts), - Catch::Contains("HTTP status=404", Catch::CaseSensitive::No)); + CHECK_THROWS_WITH( + client_encryption_with_tls.create_data_key("azure", opts), + Catch::Matchers::ContainsSubstring("HTTP status=404", Catch::CaseSensitive::No)); // Expect an error indicating TLS handshake failed due to an expired certificate. CHECK_THROWS_WITH(client_encryption_expired.create_data_key("azure", opts), @@ -2064,8 +2072,9 @@ TEST_CASE("KMS TLS Options Tests", "[client_side_encryption][!mayfail]") { // Expect an error from libmongocrypt with a message containing the string: "HTTP // status=404". This implies TLS handshake succeeded. - CHECK_THROWS_WITH(client_encryption_with_tls.create_data_key("gcp", opts), - Catch::Contains("HTTP status=404", Catch::CaseSensitive::No)); + CHECK_THROWS_WITH( + client_encryption_with_tls.create_data_key("gcp", opts), + Catch::Matchers::ContainsSubstring("HTTP status=404", Catch::CaseSensitive::No)); // Expect an error indicating TLS handshake failed due to an expired certificate. CHECK_THROWS_WITH(client_encryption_expired.create_data_key("gcp", opts), @@ -2914,7 +2923,7 @@ std::string to_type_str(RangeFieldType field_type) { return "Int"; case RangeFieldType::Long: return "Long"; - }; + } FAIL("unexpected field type " << static_cast(field_type)); MONGOCXX_UNREACHABLE; @@ -3451,7 +3460,7 @@ TEST_CASE("Range Explicit Encryption", "[client_side_encryption]") { .algorithm( options::encrypt::encryption_algorithm::k_range_preview) .contention_factor(0)), - Catch::Contains( + Catch::Matchers::ContainsSubstring( "Value must be greater than or equal to the minimum value and " "less than or equal to the maximum value")); } @@ -3489,9 +3498,9 @@ TEST_CASE("Range Explicit Encryption", "[client_side_encryption]") { : to_field_value(6, RangeFieldType::Int); // Assert an error was raised. - REQUIRE_THROWS_WITH( - client_encryption.encrypt(value.view(), encrypt_opts), - Catch::Contains("expected matching 'min' and value type")); + REQUIRE_THROWS_WITH(client_encryption.encrypt(value.view(), encrypt_opts), + Catch::Matchers::ContainsSubstring( + "expected matching 'min' and value type")); } break; } @@ -3536,7 +3545,7 @@ TEST_CASE("Range Explicit Encryption", "[client_side_encryption]") { .algorithm( options::encrypt::encryption_algorithm::k_range_preview) .contention_factor(0)), - Catch::Contains( + Catch::Matchers::ContainsSubstring( "expected 'precision' to be set with double or decimal128 index")); } } break; @@ -3563,7 +3572,8 @@ TEST_CASE("16. Rewrap. Case 2: RewrapManyDataKeyOpts.provider is not optional", REQUIRE_THROWS_WITH( clientEncryption.rewrap_many_datakey( make_document(), mongocxx::options::rewrap_many_datakey().master_key(make_document())), - Catch::Contains("expected 'provider' to be set to identify type of 'master_key'")); + Catch::Matchers::ContainsSubstring( + "expected 'provider' to be set to identify type of 'master_key'")); } } // namespace diff --git a/src/mongocxx/test/collection.cpp b/src/mongocxx/test/collection.cpp index 7a6c549150..c27b0b67a8 100644 --- a/src/mongocxx/test/collection.cpp +++ b/src/mongocxx/test/collection.cpp @@ -23,8 +23,6 @@ #include #include #include -#include -#include #include #include #include @@ -38,9 +36,12 @@ #include #include #include -#include #include +#include +#include +#include + namespace { using bsoncxx::builder::basic::document; diff --git a/src/mongocxx/test/collection_mocked.cpp b/src/mongocxx/test/collection_mocked.cpp index 8d567ef434..c7bc54611c 100644 --- a/src/mongocxx/test/collection_mocked.cpp +++ b/src/mongocxx/test/collection_mocked.cpp @@ -21,7 +21,6 @@ #include #include #include -#include #include #include #include @@ -34,7 +33,9 @@ #include #include #include -#include + +#include +#include namespace { using namespace mongocxx; @@ -57,12 +58,12 @@ TEST_CASE("Collection", "[collection]") { const std::string collection_name("dummy_collection"); const std::string database_name("mocked_collection"); - MOCK_CLIENT - MOCK_DATABASE - MOCK_COLLECTION - MOCK_FAM - MOCK_BULK - MOCK_CURSOR + MOCK_CLIENT; + MOCK_DATABASE; + MOCK_COLLECTION; + MOCK_FAM; + MOCK_BULK; + MOCK_CURSOR; client mongo_client{uri{}}; write_concern concern; diff --git a/src/mongocxx/test/conversions.cpp b/src/mongocxx/test/conversions.cpp index b39226cad5..6198e8ad5f 100644 --- a/src/mongocxx/test/conversions.cpp +++ b/src/mongocxx/test/conversions.cpp @@ -12,10 +12,11 @@ // See the License for the specific language governing permissions and // limitations under the License. -#include #include #include +#include + namespace { using namespace mongocxx; diff --git a/src/mongocxx/test/database.cpp b/src/mongocxx/test/database.cpp index 5ddb53b538..3aafc5caec 100644 --- a/src/mongocxx/test/database.cpp +++ b/src/mongocxx/test/database.cpp @@ -16,7 +16,6 @@ #include #include -#include #include #include #include @@ -27,8 +26,12 @@ #include #include #include + +#include +#include #include -#include + +#include namespace { using namespace mongocxx; @@ -128,8 +131,8 @@ TEST_CASE("mongocxx::database copy assignment operator", "[database]") { TEST_CASE("A database", "[database]") { stdx::string_view database_name{"database"}; - MOCK_CLIENT - MOCK_DATABASE + MOCK_CLIENT; + MOCK_DATABASE; instance::current(); @@ -286,7 +289,7 @@ TEST_CASE("A database", "[database]") { } SECTION("may create a collection") { - MOCK_COLLECTION + MOCK_COLLECTION; stdx::string_view collection_name{"dummy_collection"}; database database = mongo_client[database_name]; collection obtained_collection = database[collection_name]; @@ -515,7 +518,7 @@ struct check_service_id { check_service_id(const bool expect_service_id) : expect_service_id(expect_service_id) {} void operator()(const EventT& event) { - INFO("checking for service_id()") + INFO("checking for service_id()"); CAPTURE(event.command_name(), expect_service_id); auto service_id = event.service_id(); diff --git a/src/mongocxx/test/gridfs/bucket.cpp b/src/mongocxx/test/gridfs/bucket.cpp index f888bc444b..6db8a48276 100644 --- a/src/mongocxx/test/gridfs/bucket.cpp +++ b/src/mongocxx/test/gridfs/bucket.cpp @@ -26,7 +26,6 @@ #include #include #include -#include #include #include #include @@ -38,9 +37,11 @@ #include #include #include -#include #include +#include +#include + namespace { using namespace mongocxx; diff --git a/src/mongocxx/test/gridfs/downloader.cpp b/src/mongocxx/test/gridfs/downloader.cpp index 7e7a4dcd83..376b13b029 100644 --- a/src/mongocxx/test/gridfs/downloader.cpp +++ b/src/mongocxx/test/gridfs/downloader.cpp @@ -12,11 +12,12 @@ // See the License for the specific language governing permissions and // limitations under the License. -#include #include #include #include +#include + namespace { using namespace mongocxx; diff --git a/src/mongocxx/test/gridfs/uploader.cpp b/src/mongocxx/test/gridfs/uploader.cpp index 4df52710cb..ee0781186c 100644 --- a/src/mongocxx/test/gridfs/uploader.cpp +++ b/src/mongocxx/test/gridfs/uploader.cpp @@ -14,10 +14,11 @@ #include -#include #include #include +#include + namespace { using namespace mongocxx; diff --git a/src/mongocxx/test/hint.cpp b/src/mongocxx/test/hint.cpp index 1fcb8777cf..d782647524 100644 --- a/src/mongocxx/test/hint.cpp +++ b/src/mongocxx/test/hint.cpp @@ -16,10 +16,11 @@ #include #include #include -#include #include #include +#include + namespace { using namespace mongocxx; using namespace bsoncxx; diff --git a/src/mongocxx/test/index_view.cpp b/src/mongocxx/test/index_view.cpp index bdbe58309a..338f30cb44 100644 --- a/src/mongocxx/test/index_view.cpp +++ b/src/mongocxx/test/index_view.cpp @@ -17,7 +17,6 @@ #include #include -#include #include #include #include @@ -25,8 +24,13 @@ #include #include #include + +#include #include +#include +#include + namespace { using bsoncxx::builder::basic::kvp; using bsoncxx::builder::basic::make_document; @@ -189,7 +193,7 @@ TEST_CASE("create_one", "[index_view]") { options::index_view options; auto commit_quorum_regex = - Catch::Matches("(.*)commit( )?quorum(.*)", Catch::CaseSensitive::No); + Catch::Matchers::Matches("(.*)commit( )?quorum(.*)", Catch::CaseSensitive::No); bool is_supported = test_util::get_max_wire_version(mongodb_client) >= 9; CAPTURE(is_supported); diff --git a/src/mongocxx/test/instance.cpp b/src/mongocxx/test/instance.cpp index 3c15029470..047bf52a61 100644 --- a/src/mongocxx/test/instance.cpp +++ b/src/mongocxx/test/instance.cpp @@ -12,10 +12,11 @@ // See the License for the specific language governing permissions and // limitations under the License. -#include #include #include +#include + namespace { using namespace mongocxx; diff --git a/src/mongocxx/test/logging.cpp b/src/mongocxx/test/logging.cpp index 90a4ff1600..6dc924320a 100644 --- a/src/mongocxx/test/logging.cpp +++ b/src/mongocxx/test/logging.cpp @@ -15,11 +15,12 @@ #include #include -#include #include #include #include +#include + namespace { using namespace mongocxx; diff --git a/src/mongocxx/test/model/delete_many.cpp b/src/mongocxx/test/model/delete_many.cpp index c2d4bbf40e..85ee2e4918 100644 --- a/src/mongocxx/test/model/delete_many.cpp +++ b/src/mongocxx/test/model/delete_many.cpp @@ -13,10 +13,11 @@ // limitations under the License. #include -#include #include #include -#include + +#include +#include namespace { using namespace bsoncxx::builder::basic; diff --git a/src/mongocxx/test/model/delete_one.cpp b/src/mongocxx/test/model/delete_one.cpp index 81717c3586..5d5b0902ae 100644 --- a/src/mongocxx/test/model/delete_one.cpp +++ b/src/mongocxx/test/model/delete_one.cpp @@ -13,10 +13,11 @@ // limitations under the License. #include -#include #include #include -#include + +#include +#include namespace { using namespace bsoncxx::builder::basic; diff --git a/src/mongocxx/test/model/insert_one.cpp b/src/mongocxx/test/model/insert_one.cpp index 46ee974890..e7b9cddf94 100644 --- a/src/mongocxx/test/model/insert_one.cpp +++ b/src/mongocxx/test/model/insert_one.cpp @@ -13,10 +13,11 @@ // limitations under the License. #include -#include #include #include +#include + namespace { using namespace bsoncxx::builder::basic; diff --git a/src/mongocxx/test/model/replace_one.cpp b/src/mongocxx/test/model/replace_one.cpp index 1066e81d35..c68784e989 100644 --- a/src/mongocxx/test/model/replace_one.cpp +++ b/src/mongocxx/test/model/replace_one.cpp @@ -13,10 +13,11 @@ // limitations under the License. #include -#include #include #include -#include + +#include +#include namespace { using namespace bsoncxx::builder::basic; diff --git a/src/mongocxx/test/model/update_many.cpp b/src/mongocxx/test/model/update_many.cpp index 012d0568fc..f1d57af6d2 100644 --- a/src/mongocxx/test/model/update_many.cpp +++ b/src/mongocxx/test/model/update_many.cpp @@ -14,10 +14,11 @@ #include #include -#include #include #include -#include + +#include +#include namespace { using namespace bsoncxx::builder::basic; diff --git a/src/mongocxx/test/model/update_one.cpp b/src/mongocxx/test/model/update_one.cpp index ad80dac84a..4ebb7ab311 100644 --- a/src/mongocxx/test/model/update_one.cpp +++ b/src/mongocxx/test/model/update_one.cpp @@ -14,10 +14,11 @@ #include #include -#include #include #include -#include + +#include +#include namespace { using namespace bsoncxx::builder::basic; diff --git a/src/mongocxx/test/options/aggregate.cpp b/src/mongocxx/test/options/aggregate.cpp index 97397be48d..f70d3ad2f2 100644 --- a/src/mongocxx/test/options/aggregate.cpp +++ b/src/mongocxx/test/options/aggregate.cpp @@ -16,10 +16,11 @@ #include #include -#include #include #include -#include + +#include +#include namespace { using namespace bsoncxx::builder::basic; diff --git a/src/mongocxx/test/options/bulk_write.cpp b/src/mongocxx/test/options/bulk_write.cpp index 0c81fd5021..f5bc34cf1c 100644 --- a/src/mongocxx/test/options/bulk_write.cpp +++ b/src/mongocxx/test/options/bulk_write.cpp @@ -12,10 +12,11 @@ // See the License for the specific language governing permissions and // limitations under the License. -#include #include #include -#include + +#include +#include namespace { using namespace mongocxx; diff --git a/src/mongocxx/test/options/client_session.cpp b/src/mongocxx/test/options/client_session.cpp index 5628b2d983..2a0c132675 100644 --- a/src/mongocxx/test/options/client_session.cpp +++ b/src/mongocxx/test/options/client_session.cpp @@ -12,10 +12,11 @@ // See the License for the specific language governing permissions and // limitations under the License. -#include #include #include +#include + namespace { using namespace mongocxx; diff --git a/src/mongocxx/test/options/count.cpp b/src/mongocxx/test/options/count.cpp index ef8f01b453..8ec1c47026 100644 --- a/src/mongocxx/test/options/count.cpp +++ b/src/mongocxx/test/options/count.cpp @@ -15,10 +15,11 @@ #include #include -#include #include #include -#include + +#include +#include namespace { using namespace bsoncxx::builder::basic; diff --git a/src/mongocxx/test/options/create_collection.cpp b/src/mongocxx/test/options/create_collection.cpp index 9fdd51fbe1..a14af999cc 100644 --- a/src/mongocxx/test/options/create_collection.cpp +++ b/src/mongocxx/test/options/create_collection.cpp @@ -16,12 +16,13 @@ #include #include #include -#include #include #include #include #include -#include + +#include +#include namespace { using namespace bsoncxx; diff --git a/src/mongocxx/test/options/delete.cpp b/src/mongocxx/test/options/delete.cpp index 4d70db089a..03c1850e7f 100644 --- a/src/mongocxx/test/options/delete.cpp +++ b/src/mongocxx/test/options/delete.cpp @@ -15,10 +15,11 @@ #include #include -#include #include #include -#include + +#include +#include namespace { using namespace bsoncxx::builder::basic; diff --git a/src/mongocxx/test/options/distinct.cpp b/src/mongocxx/test/options/distinct.cpp index b5962deb50..b51b7e1d70 100644 --- a/src/mongocxx/test/options/distinct.cpp +++ b/src/mongocxx/test/options/distinct.cpp @@ -15,10 +15,11 @@ #include #include -#include #include #include -#include + +#include +#include namespace { using namespace bsoncxx::builder::basic; diff --git a/src/mongocxx/test/options/find.cpp b/src/mongocxx/test/options/find.cpp index 8214ed5c66..3d2ddec8d3 100644 --- a/src/mongocxx/test/options/find.cpp +++ b/src/mongocxx/test/options/find.cpp @@ -15,10 +15,11 @@ #include #include -#include #include #include -#include + +#include +#include namespace { using namespace bsoncxx::builder::basic; diff --git a/src/mongocxx/test/options/find_one_and_delete.cpp b/src/mongocxx/test/options/find_one_and_delete.cpp index 196b76768d..caa9e0c018 100644 --- a/src/mongocxx/test/options/find_one_and_delete.cpp +++ b/src/mongocxx/test/options/find_one_and_delete.cpp @@ -15,10 +15,11 @@ #include #include -#include #include #include -#include + +#include +#include namespace { using namespace bsoncxx::builder::basic; diff --git a/src/mongocxx/test/options/find_one_and_replace.cpp b/src/mongocxx/test/options/find_one_and_replace.cpp index 5e5f704fa0..34a2fe6bbb 100644 --- a/src/mongocxx/test/options/find_one_and_replace.cpp +++ b/src/mongocxx/test/options/find_one_and_replace.cpp @@ -15,10 +15,11 @@ #include #include -#include #include #include -#include + +#include +#include namespace { using namespace bsoncxx::builder::basic; diff --git a/src/mongocxx/test/options/find_one_and_update.cpp b/src/mongocxx/test/options/find_one_and_update.cpp index 6f31620875..678bc91236 100644 --- a/src/mongocxx/test/options/find_one_and_update.cpp +++ b/src/mongocxx/test/options/find_one_and_update.cpp @@ -16,10 +16,11 @@ #include #include -#include #include #include -#include + +#include +#include namespace { using namespace bsoncxx::builder::basic; diff --git a/src/mongocxx/test/options/gridfs/bucket.cpp b/src/mongocxx/test/options/gridfs/bucket.cpp index 1f57c84cd8..40161a68c7 100644 --- a/src/mongocxx/test/options/gridfs/bucket.cpp +++ b/src/mongocxx/test/options/gridfs/bucket.cpp @@ -12,13 +12,14 @@ // See the License for the specific language governing permissions and // limitations under the License. -#include #include #include #include #include #include -#include + +#include +#include namespace { using namespace mongocxx; diff --git a/src/mongocxx/test/options/gridfs/upload.cpp b/src/mongocxx/test/options/gridfs/upload.cpp index cbc2a9c606..aec022fc3f 100644 --- a/src/mongocxx/test/options/gridfs/upload.cpp +++ b/src/mongocxx/test/options/gridfs/upload.cpp @@ -14,10 +14,11 @@ #include #include -#include #include #include -#include + +#include +#include namespace { using namespace bsoncxx; diff --git a/src/mongocxx/test/options/index.cpp b/src/mongocxx/test/options/index.cpp index 2f177108e7..8d446f83eb 100644 --- a/src/mongocxx/test/options/index.cpp +++ b/src/mongocxx/test/options/index.cpp @@ -14,11 +14,12 @@ #include #include -#include #include #include #include -#include + +#include +#include namespace { using namespace bsoncxx::builder::basic; diff --git a/src/mongocxx/test/options/insert.cpp b/src/mongocxx/test/options/insert.cpp index e851d4267d..958ac19fd8 100644 --- a/src/mongocxx/test/options/insert.cpp +++ b/src/mongocxx/test/options/insert.cpp @@ -12,10 +12,11 @@ // See the License for the specific language governing permissions and // limitations under the License. -#include #include #include -#include + +#include +#include namespace { using namespace mongocxx; diff --git a/src/mongocxx/test/options/pool.cpp b/src/mongocxx/test/options/pool.cpp index 31b28e5401..61e2b7f92c 100644 --- a/src/mongocxx/test/options/pool.cpp +++ b/src/mongocxx/test/options/pool.cpp @@ -12,10 +12,11 @@ // See the License for the specific language governing permissions and // limitations under the License. -#include #include #include +#include + namespace { using namespace mongocxx; diff --git a/src/mongocxx/test/options/replace.cpp b/src/mongocxx/test/options/replace.cpp index 6840aac6e6..c5140ced70 100644 --- a/src/mongocxx/test/options/replace.cpp +++ b/src/mongocxx/test/options/replace.cpp @@ -13,10 +13,11 @@ // limitations under the License. #include -#include #include #include -#include + +#include +#include namespace { using namespace bsoncxx::builder::basic; diff --git a/src/mongocxx/test/options/update.cpp b/src/mongocxx/test/options/update.cpp index 2e6482e4d0..1e41b068a9 100644 --- a/src/mongocxx/test/options/update.cpp +++ b/src/mongocxx/test/options/update.cpp @@ -13,10 +13,11 @@ // limitations under the License. #include -#include #include #include -#include + +#include +#include namespace { using namespace bsoncxx::builder::basic; diff --git a/src/mongocxx/test/pool.cpp b/src/mongocxx/test/pool.cpp index 9a87c76467..a2f713264c 100644 --- a/src/mongocxx/test/pool.cpp +++ b/src/mongocxx/test/pool.cpp @@ -15,22 +15,23 @@ #include #include -#include #include #include #include #include #include #include -#include #include +#include +#include + namespace { using namespace mongocxx; TEST_CASE("a pool is created with the correct MongoDB URI", "[pool]") { - MOCK_POOL + MOCK_POOL; instance::current(); @@ -67,7 +68,7 @@ TEST_CASE( "If we pass an engaged SSL options struct to the pool class, we will use it to configure the " "underlying mongoc pool", "[pool]") { - MOCK_POOL + MOCK_POOL; instance::current(); @@ -108,7 +109,7 @@ TEST_CASE( #endif TEST_CASE("calling acquire on a pool returns an entry that manages its client", "[pool]") { - MOCK_POOL + MOCK_POOL; instance::current(); @@ -163,7 +164,7 @@ TEST_CASE( "try_acquire returns a disengaged stdx::optional if mongoc_client_pool_try_pop " "returns a null pointer", "[pool]") { - MOCK_POOL + MOCK_POOL; instance::current(); diff --git a/src/mongocxx/test/private/numeric_casting.cpp b/src/mongocxx/test/private/numeric_casting.cpp index c0af6b6198..f803f767be 100644 --- a/src/mongocxx/test/private/numeric_casting.cpp +++ b/src/mongocxx/test/private/numeric_casting.cpp @@ -13,10 +13,11 @@ // limitations under the License. #include -#include #include #include +#include + namespace { TEST_CASE("can do basic numeric_casting", "[numeric_casting]") { diff --git a/src/mongocxx/test/private/scoped_bson_t.cpp b/src/mongocxx/test/private/scoped_bson_t.cpp index 9118915f86..605770636f 100644 --- a/src/mongocxx/test/private/scoped_bson_t.cpp +++ b/src/mongocxx/test/private/scoped_bson_t.cpp @@ -15,9 +15,10 @@ #include #include #include -#include #include +#include + namespace { using namespace bsoncxx; using namespace mongocxx; diff --git a/src/mongocxx/test/private/write_concern.cpp b/src/mongocxx/test/private/write_concern.cpp index 24fd484c65..1114a3d69c 100644 --- a/src/mongocxx/test/private/write_concern.cpp +++ b/src/mongocxx/test/private/write_concern.cpp @@ -12,12 +12,13 @@ // See the License for the specific language governing permissions and // limitations under the License. -#include #include #include #include #include +#include + namespace { using namespace mongocxx; diff --git a/src/mongocxx/test/read_concern.cpp b/src/mongocxx/test/read_concern.cpp index 207053a80c..2e8292bbcd 100644 --- a/src/mongocxx/test/read_concern.cpp +++ b/src/mongocxx/test/read_concern.cpp @@ -13,10 +13,11 @@ // limitations under the License. #include -#include #include #include +#include + namespace { using namespace mongocxx; diff --git a/src/mongocxx/test/read_preference.cpp b/src/mongocxx/test/read_preference.cpp index bbaed6b4fe..446f5ea949 100644 --- a/src/mongocxx/test/read_preference.cpp +++ b/src/mongocxx/test/read_preference.cpp @@ -15,12 +15,13 @@ #include #include #include -#include #include #include #include #include -#include + +#include +#include namespace { using namespace bsoncxx; @@ -145,7 +146,7 @@ TEST_CASE("Read preference inequality operator works", "[read_preference]") { TEST_CASE("Read preference methods call underlying mongoc methods", "[read_preference]") { instance::current(); - MOCK_READ_PREFERENCE + MOCK_READ_PREFERENCE; read_preference rp; bool called = false; diff --git a/src/mongocxx/test/result/bulk_write.cpp b/src/mongocxx/test/result/bulk_write.cpp index ced15d8747..39f9ecd287 100644 --- a/src/mongocxx/test/result/bulk_write.cpp +++ b/src/mongocxx/test/result/bulk_write.cpp @@ -14,11 +14,12 @@ #include #include -#include #include #include #include +#include + namespace { using namespace bsoncxx; diff --git a/src/mongocxx/test/result/delete.cpp b/src/mongocxx/test/result/delete.cpp index 9a3cb67393..ef7e8db204 100644 --- a/src/mongocxx/test/result/delete.cpp +++ b/src/mongocxx/test/result/delete.cpp @@ -14,10 +14,11 @@ #include #include -#include #include #include +#include + namespace { using bsoncxx::builder::basic::kvp; diff --git a/src/mongocxx/test/result/gridfs/upload.cpp b/src/mongocxx/test/result/gridfs/upload.cpp index 96192f597d..fd7cb2169d 100644 --- a/src/mongocxx/test/result/gridfs/upload.cpp +++ b/src/mongocxx/test/result/gridfs/upload.cpp @@ -16,12 +16,13 @@ #include #include #include -#include #include #include #include #include +#include + namespace { using namespace bsoncxx; using namespace mongocxx; diff --git a/src/mongocxx/test/result/insert_one.cpp b/src/mongocxx/test/result/insert_one.cpp index 9e95356614..5d19b927c6 100644 --- a/src/mongocxx/test/result/insert_one.cpp +++ b/src/mongocxx/test/result/insert_one.cpp @@ -13,11 +13,12 @@ // limitations under the License. #include -#include #include #include #include +#include + namespace { using namespace bsoncxx; diff --git a/src/mongocxx/test/result/replace_one.cpp b/src/mongocxx/test/result/replace_one.cpp index 849bf49bfb..4547495ff0 100644 --- a/src/mongocxx/test/result/replace_one.cpp +++ b/src/mongocxx/test/result/replace_one.cpp @@ -13,10 +13,11 @@ // limitations under the License. #include -#include #include #include +#include + namespace { using bsoncxx::builder::basic::kvp; using bsoncxx::builder::basic::make_document; diff --git a/src/mongocxx/test/result/update.cpp b/src/mongocxx/test/result/update.cpp index c68bf9ff7a..a58167b9df 100644 --- a/src/mongocxx/test/result/update.cpp +++ b/src/mongocxx/test/result/update.cpp @@ -13,10 +13,11 @@ // limitations under the License. #include -#include #include #include +#include + namespace { using bsoncxx::builder::basic::kvp; using bsoncxx::builder::basic::make_document; diff --git a/src/mongocxx/test/sdam-monitoring.cpp b/src/mongocxx/test/sdam-monitoring.cpp index 50fc4ef500..5a09f6b03c 100644 --- a/src/mongocxx/test/sdam-monitoring.cpp +++ b/src/mongocxx/test/sdam-monitoring.cpp @@ -16,11 +16,12 @@ #include #include -#include -#include #include #include #include + +#include +#include #include #include diff --git a/src/mongocxx/test/search_index_view.cpp b/src/mongocxx/test/search_index_view.cpp index 15c81c4377..ffb1b40d93 100644 --- a/src/mongocxx/test/search_index_view.cpp +++ b/src/mongocxx/test/search_index_view.cpp @@ -4,13 +4,17 @@ #include #include #include -#include #include #include #include #include + +#include #include +#include +#include + namespace { using bsoncxx::builder::basic::kvp; using bsoncxx::builder::basic::make_array; @@ -388,7 +392,7 @@ TEST_CASE("atlas search indexes prose tests", "[atlas][search_indexes]") { const auto model = search_index_model(name, definition.view()); REQUIRE_THROWS_WITH(siv.create_one(model), - Catch::Matchers::Contains("Attribute mappings missing")); + Catch::Matchers::ContainsSubstring("Attribute mappings missing")); SUCCEED("Prose Test Case 8: Driver requires explicit type to create a vector search index"); } diff --git a/src/mongocxx/test/spec/client_side_encryption.cpp b/src/mongocxx/test/spec/client_side_encryption.cpp index 4ec72477ca..cabcae0660 100644 --- a/src/mongocxx/test/spec/client_side_encryption.cpp +++ b/src/mongocxx/test/spec/client_side_encryption.cpp @@ -16,10 +16,11 @@ #include #include -#include #include #include #include + +#include #include #include #include diff --git a/src/mongocxx/test/spec/command_monitoring.cpp b/src/mongocxx/test/spec/command_monitoring.cpp index d82f13388d..ec076b562a 100644 --- a/src/mongocxx/test/spec/command_monitoring.cpp +++ b/src/mongocxx/test/spec/command_monitoring.cpp @@ -16,11 +16,12 @@ #include #include -#include -#include #include #include #include + +#include +#include #include #include #include diff --git a/src/mongocxx/test/spec/crud.cpp b/src/mongocxx/test/spec/crud.cpp index f0ef54f83d..c7c6f56dce 100644 --- a/src/mongocxx/test/spec/crud.cpp +++ b/src/mongocxx/test/spec/crud.cpp @@ -14,8 +14,9 @@ #include -#include #include + +#include #include namespace { diff --git a/src/mongocxx/test/spec/gridfs.cpp b/src/mongocxx/test/spec/gridfs.cpp index 4ae2f60aa2..5e15b715a4 100644 --- a/src/mongocxx/test/spec/gridfs.cpp +++ b/src/mongocxx/test/spec/gridfs.cpp @@ -29,7 +29,6 @@ #include #include #include -#include #include #include #include @@ -40,6 +39,8 @@ #include #include #include + +#include #include #include diff --git a/src/mongocxx/test/spec/initial_dns_seedlist_discovery.cpp b/src/mongocxx/test/spec/initial_dns_seedlist_discovery.cpp index a2862e2415..a79c234349 100644 --- a/src/mongocxx/test/spec/initial_dns_seedlist_discovery.cpp +++ b/src/mongocxx/test/spec/initial_dns_seedlist_discovery.cpp @@ -17,11 +17,12 @@ #include #include -#include #include #include #include #include + +#include #include namespace { diff --git a/src/mongocxx/test/spec/mongohouse.cpp b/src/mongocxx/test/spec/mongohouse.cpp index c8b13fec1a..a7a37ae6e4 100644 --- a/src/mongocxx/test/spec/mongohouse.cpp +++ b/src/mongocxx/test/spec/mongohouse.cpp @@ -15,11 +15,12 @@ #include #include #include -#include #include #include #include #include + +#include #include #include #include diff --git a/src/mongocxx/test/spec/monitoring.cpp b/src/mongocxx/test/spec/monitoring.cpp index e2d0370a28..f5ceaab3de 100644 --- a/src/mongocxx/test/spec/monitoring.cpp +++ b/src/mongocxx/test/spec/monitoring.cpp @@ -17,15 +17,16 @@ #include #include +#include + +#include + #include #include -#include #include #include #include -#include - namespace mongocxx { namespace spec { diff --git a/src/mongocxx/test/spec/monitoring.hh b/src/mongocxx/test/spec/monitoring.hh index 1d3e0687d2..b560216a10 100644 --- a/src/mongocxx/test/spec/monitoring.hh +++ b/src/mongocxx/test/spec/monitoring.hh @@ -15,11 +15,12 @@ #pragma once #include -#include -#include #include +#include +#include + namespace mongocxx { namespace spec { diff --git a/src/mongocxx/test/spec/operation.cpp b/src/mongocxx/test/spec/operation.cpp index e10d0a1f47..20e56b94f4 100644 --- a/src/mongocxx/test/spec/operation.cpp +++ b/src/mongocxx/test/spec/operation.cpp @@ -18,7 +18,6 @@ #include #include #include -#include #include #include #include @@ -40,10 +39,12 @@ #include #include #include -#include #include +#include +#include + namespace mongocxx { namespace spec { diff --git a/src/mongocxx/test/spec/read_write_concern.cpp b/src/mongocxx/test/spec/read_write_concern.cpp index 65be27b3db..a7b2753db9 100644 --- a/src/mongocxx/test/spec/read_write_concern.cpp +++ b/src/mongocxx/test/spec/read_write_concern.cpp @@ -12,8 +12,9 @@ // See the License for the specific language governing permissions and // limitations under the License. -#include #include + +#include #include namespace { diff --git a/src/mongocxx/test/spec/retryable-reads.cpp b/src/mongocxx/test/spec/retryable-reads.cpp index 2bef0a6c40..40578dfb7f 100644 --- a/src/mongocxx/test/spec/retryable-reads.cpp +++ b/src/mongocxx/test/spec/retryable-reads.cpp @@ -16,9 +16,10 @@ #include #include -#include #include #include + +#include #include #include #include diff --git a/src/mongocxx/test/spec/transactions.cpp b/src/mongocxx/test/spec/transactions.cpp index 17af2698d3..3909a2fb80 100644 --- a/src/mongocxx/test/spec/transactions.cpp +++ b/src/mongocxx/test/spec/transactions.cpp @@ -12,8 +12,9 @@ // See the License for the specific language governing permissions and // limitations under the License. -#include #include + +#include #include namespace { diff --git a/src/mongocxx/test/spec/unified_tests/assert.cpp b/src/mongocxx/test/spec/unified_tests/assert.cpp index 62223ab4b3..6ce84b58f1 100644 --- a/src/mongocxx/test/spec/unified_tests/assert.cpp +++ b/src/mongocxx/test/spec/unified_tests/assert.cpp @@ -21,10 +21,11 @@ #include #include -#include -#include #include #include + +#include +#include #include using namespace bsoncxx; diff --git a/src/mongocxx/test/spec/unified_tests/assert.hh b/src/mongocxx/test/spec/unified_tests/assert.hh index 0df047926d..de501928cd 100644 --- a/src/mongocxx/test/spec/unified_tests/assert.hh +++ b/src/mongocxx/test/spec/unified_tests/assert.hh @@ -15,6 +15,7 @@ #pragma once #include "entity.hh" + #include #include diff --git a/src/mongocxx/test/spec/unified_tests/operations.cpp b/src/mongocxx/test/spec/unified_tests/operations.cpp index cd5df41881..89309d7935 100644 --- a/src/mongocxx/test/spec/unified_tests/operations.cpp +++ b/src/mongocxx/test/spec/unified_tests/operations.cpp @@ -20,14 +20,15 @@ #include #include #include -#include #include #include #include -#include #include +#include +#include + namespace mongocxx { using namespace bsoncxx; diff --git a/src/mongocxx/test/spec/unified_tests/operations.hh b/src/mongocxx/test/spec/unified_tests/operations.hh index 4f5dc01663..46df6b5f16 100644 --- a/src/mongocxx/test/spec/unified_tests/operations.hh +++ b/src/mongocxx/test/spec/unified_tests/operations.hh @@ -14,16 +14,18 @@ #pragma once +#include "entity.hh" + #include -#include "entity.hh" #include #include #include -#include #include +#include + namespace mongocxx { namespace operations { diff --git a/src/mongocxx/test/spec/unified_tests/runner.cpp b/src/mongocxx/test/spec/unified_tests/runner.cpp index 38a4767496..aa32df8432 100644 --- a/src/mongocxx/test/spec/unified_tests/runner.cpp +++ b/src/mongocxx/test/spec/unified_tests/runner.cpp @@ -12,27 +12,29 @@ // See the License for the specific language governing permissions and // limitations under the License. +#include "assert.hh" +#include "entity.hh" +#include "operations.hh" + #include #include #include #include #include -#include "assert.hh" -#include "entity.hh" -#include "operations.hh" #include #include #include #include #include -#include #include #include #include #include #include #include + +#include #include #include #include diff --git a/src/mongocxx/test/spec/uri_options.cpp b/src/mongocxx/test/spec/uri_options.cpp index 8adea2430a..c3f1e7e9b4 100644 --- a/src/mongocxx/test/spec/uri_options.cpp +++ b/src/mongocxx/test/spec/uri_options.cpp @@ -15,11 +15,12 @@ #include #include -#include #include #include #include +#include + namespace { struct URIOptionsTest { diff --git a/src/mongocxx/test/spec/util.cpp b/src/mongocxx/test/spec/util.cpp index 1cbeda2d36..bda0bb0009 100644 --- a/src/mongocxx/test/spec/util.cpp +++ b/src/mongocxx/test/spec/util.cpp @@ -25,7 +25,6 @@ #include #include #include -#include #include #include #include @@ -38,11 +37,15 @@ #include #include #include + +#include + +#include #include #include #include -#include +#include namespace mongocxx { namespace spec { @@ -776,7 +779,9 @@ void run_transaction_operations( auto error_contains = test_util::tolowercase(op["result"]["errorContains"].get_string().value); - REQUIRE_THAT(error_msg, Catch::Contains(error_contains, Catch::CaseSensitive::No)); + REQUIRE_THAT( + error_msg, + Catch::Matchers::ContainsSubstring(error_contains, Catch::CaseSensitive::No)); } // "If the result document has an 'errorCodeName' field, verify that the method threw a diff --git a/src/mongocxx/test/spec/util.hh b/src/mongocxx/test/spec/util.hh index c23840d64b..5fbfaf236b 100644 --- a/src/mongocxx/test/spec/util.hh +++ b/src/mongocxx/test/spec/util.hh @@ -19,11 +19,12 @@ #include #include -#include #include #include +#include + namespace mongocxx { namespace spec { diff --git a/src/mongocxx/test/transactions.cpp b/src/mongocxx/test/transactions.cpp index a890270263..0adb4caa72 100644 --- a/src/mongocxx/test/transactions.cpp +++ b/src/mongocxx/test/transactions.cpp @@ -15,11 +15,12 @@ #include #include -#include #include #include #include #include + +#include #include namespace { @@ -455,11 +456,11 @@ TEST_CASE("Transactions Mongos Pinning Prose Tests", "[transactions]") { { mongocxx::client client{mongocxx::uri{"mongodb://localhost:27017"}}; REQUIRE(client["config"].has_collection("shards")); - }; + } { mongocxx::client client{mongocxx::uri{"mongodb://localhost:27018"}}; REQUIRE(client["config"].has_collection("shards")); - }; + } const auto uri = mongocxx::uri("mongodb://localhost:27017,localhost:27018/?localThresholdMS=1000"); diff --git a/src/mongocxx/test/uri.cpp b/src/mongocxx/test/uri.cpp index 5367cb3ff9..d8fd5da99f 100644 --- a/src/mongocxx/test/uri.cpp +++ b/src/mongocxx/test/uri.cpp @@ -18,11 +18,12 @@ #include #include #include -#include #include #include #include +#include + namespace { TEST_CASE("URI", "[uri]") { SECTION("Default URI") { diff --git a/src/mongocxx/test/validation_criteria.cpp b/src/mongocxx/test/validation_criteria.cpp index 4ab3bc3e9c..6de4db7b81 100644 --- a/src/mongocxx/test/validation_criteria.cpp +++ b/src/mongocxx/test/validation_criteria.cpp @@ -15,10 +15,11 @@ #include #include #include -#include #include #include -#include + +#include +#include namespace { using namespace mongocxx; diff --git a/src/mongocxx/test/versioned_api.cpp b/src/mongocxx/test/versioned_api.cpp index 7ad60f2fc2..d6e69d8ee1 100644 --- a/src/mongocxx/test/versioned_api.cpp +++ b/src/mongocxx/test/versioned_api.cpp @@ -13,15 +13,18 @@ // limitations under the License. #include -#include #include #include #include #include #include -#include #include +#include +#include + +#include + using namespace mongocxx; static bool has_api_version_1( @@ -204,7 +207,7 @@ TEST_CASE("Versioned API, with insert-many for 'count' migration") { INFO(error.what()); CHECK(error.code().value() == 323); CHECK_THAT(error.what(), - Catch::StartsWith( + Catch::Matchers::StartsWith( "Provided apiStrict:true, but the command count is not in API Version 1.")); } diff --git a/src/mongocxx/test/write_concern.cpp b/src/mongocxx/test/write_concern.cpp index e5478d1705..0820ba1cf7 100644 --- a/src/mongocxx/test/write_concern.cpp +++ b/src/mongocxx/test/write_concern.cpp @@ -14,12 +14,13 @@ #include #include -#include #include #include #include #include +#include + namespace { using namespace mongocxx; diff --git a/src/third_party/catch/include/catch.hpp b/src/third_party/catch/include/catch.hpp deleted file mode 100644 index a4e70bf1e0..0000000000 --- a/src/third_party/catch/include/catch.hpp +++ /dev/null @@ -1,17959 +0,0 @@ -/* - * Catch v2.13.7 - * Generated: 2021-07-28 20:29:27.753164 - * ---------------------------------------------------------- - * This file has been merged from multiple headers. Please don't edit it directly - * Copyright (c) 2021 Two Blue Cubes Ltd. All rights reserved. - * - * Distributed under the Boost Software License, Version 1.0. (See accompanying - * file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) - */ -#ifndef TWOBLUECUBES_SINGLE_INCLUDE_CATCH_HPP_INCLUDED -#define TWOBLUECUBES_SINGLE_INCLUDE_CATCH_HPP_INCLUDED -// start catch.hpp - - -#define CATCH_VERSION_MAJOR 2 -#define CATCH_VERSION_MINOR 13 -#define CATCH_VERSION_PATCH 7 - -#ifdef __clang__ -# pragma clang system_header -#elif defined __GNUC__ -# pragma GCC system_header -#endif - -// start catch_suppress_warnings.h - -#ifdef __clang__ -# ifdef __ICC // icpc defines the __clang__ macro -# pragma warning(push) -# pragma warning(disable: 161 1682) -# else // __ICC -# pragma clang diagnostic push -# pragma clang diagnostic ignored "-Wpadded" -# pragma clang diagnostic ignored "-Wswitch-enum" -# pragma clang diagnostic ignored "-Wcovered-switch-default" -# endif -#elif defined __GNUC__ - // Because REQUIREs trigger GCC's -Wparentheses, and because still - // supported version of g++ have only buggy support for _Pragmas, - // Wparentheses have to be suppressed globally. -# pragma GCC diagnostic ignored "-Wparentheses" // See #674 for details - -# pragma GCC diagnostic push -# pragma GCC diagnostic ignored "-Wunused-variable" -# pragma GCC diagnostic ignored "-Wpadded" -#endif -// end catch_suppress_warnings.h -#if defined(CATCH_CONFIG_MAIN) || defined(CATCH_CONFIG_RUNNER) -# define CATCH_IMPL -# define CATCH_CONFIG_ALL_PARTS -#endif - -// In the impl file, we want to have access to all parts of the headers -// Can also be used to sanely support PCHs -#if defined(CATCH_CONFIG_ALL_PARTS) -# define CATCH_CONFIG_EXTERNAL_INTERFACES -# if defined(CATCH_CONFIG_DISABLE_MATCHERS) -# undef CATCH_CONFIG_DISABLE_MATCHERS -# endif -# if !defined(CATCH_CONFIG_ENABLE_CHRONO_STRINGMAKER) -# define CATCH_CONFIG_ENABLE_CHRONO_STRINGMAKER -# endif -#endif - -#if !defined(CATCH_CONFIG_IMPL_ONLY) -// start catch_platform.h - -// See e.g.: -// https://opensource.apple.com/source/CarbonHeaders/CarbonHeaders-18.1/TargetConditionals.h.auto.html -#ifdef __APPLE__ -# include -# if (defined(TARGET_OS_OSX) && TARGET_OS_OSX == 1) || \ - (defined(TARGET_OS_MAC) && TARGET_OS_MAC == 1) -# define CATCH_PLATFORM_MAC -# elif (defined(TARGET_OS_IPHONE) && TARGET_OS_IPHONE == 1) -# define CATCH_PLATFORM_IPHONE -# endif - -#elif defined(linux) || defined(__linux) || defined(__linux__) -# define CATCH_PLATFORM_LINUX - -#elif defined(WIN32) || defined(__WIN32__) || defined(_WIN32) || defined(_MSC_VER) || defined(__MINGW32__) -# define CATCH_PLATFORM_WINDOWS -#endif - -// end catch_platform.h - -#ifdef CATCH_IMPL -# ifndef CLARA_CONFIG_MAIN -# define CLARA_CONFIG_MAIN_NOT_DEFINED -# define CLARA_CONFIG_MAIN -# endif -#endif - -// start catch_user_interfaces.h - -namespace Catch { - unsigned int rngSeed(); -} - -// end catch_user_interfaces.h -// start catch_tag_alias_autoregistrar.h - -// start catch_common.h - -// start catch_compiler_capabilities.h - -// Detect a number of compiler features - by compiler -// The following features are defined: -// -// CATCH_CONFIG_COUNTER : is the __COUNTER__ macro supported? -// CATCH_CONFIG_WINDOWS_SEH : is Windows SEH supported? -// CATCH_CONFIG_POSIX_SIGNALS : are POSIX signals supported? -// CATCH_CONFIG_DISABLE_EXCEPTIONS : Are exceptions enabled? -// **************** -// Note to maintainers: if new toggles are added please document them -// in configuration.md, too -// **************** - -// In general each macro has a _NO_ form -// (e.g. CATCH_CONFIG_NO_POSIX_SIGNALS) which disables the feature. -// Many features, at point of detection, define an _INTERNAL_ macro, so they -// can be combined, en-mass, with the _NO_ forms later. - -#ifdef __cplusplus - -# if (__cplusplus >= 201402L) || (defined(_MSVC_LANG) && _MSVC_LANG >= 201402L) -# define CATCH_CPP14_OR_GREATER -# endif - -# if (__cplusplus >= 201703L) || (defined(_MSVC_LANG) && _MSVC_LANG >= 201703L) -# define CATCH_CPP17_OR_GREATER -# endif - -#endif - -// Only GCC compiler should be used in this block, so other compilers trying to -// mask themselves as GCC should be ignored. -#if defined(__GNUC__) && !defined(__clang__) && !defined(__ICC) && !defined(__CUDACC__) && !defined(__LCC__) -# define CATCH_INTERNAL_START_WARNINGS_SUPPRESSION _Pragma( "GCC diagnostic push" ) -# define CATCH_INTERNAL_STOP_WARNINGS_SUPPRESSION _Pragma( "GCC diagnostic pop" ) - -# define CATCH_INTERNAL_IGNORE_BUT_WARN(...) (void)__builtin_constant_p(__VA_ARGS__) - -#endif - -#if defined(__clang__) - -# define CATCH_INTERNAL_START_WARNINGS_SUPPRESSION _Pragma( "clang diagnostic push" ) -# define CATCH_INTERNAL_STOP_WARNINGS_SUPPRESSION _Pragma( "clang diagnostic pop" ) - -// As of this writing, IBM XL's implementation of __builtin_constant_p has a bug -// which results in calls to destructors being emitted for each temporary, -// without a matching initialization. In practice, this can result in something -// like `std::string::~string` being called on an uninitialized value. -// -// For example, this code will likely segfault under IBM XL: -// ``` -// REQUIRE(std::string("12") + "34" == "1234") -// ``` -// -// Therefore, `CATCH_INTERNAL_IGNORE_BUT_WARN` is not implemented. -# if !defined(__ibmxl__) && !defined(__CUDACC__) -# define CATCH_INTERNAL_IGNORE_BUT_WARN(...) (void)__builtin_constant_p(__VA_ARGS__) /* NOLINT(cppcoreguidelines-pro-type-vararg, hicpp-vararg) */ -# endif - -# define CATCH_INTERNAL_SUPPRESS_GLOBALS_WARNINGS \ - _Pragma( "clang diagnostic ignored \"-Wexit-time-destructors\"" ) \ - _Pragma( "clang diagnostic ignored \"-Wglobal-constructors\"") - -# define CATCH_INTERNAL_SUPPRESS_PARENTHESES_WARNINGS \ - _Pragma( "clang diagnostic ignored \"-Wparentheses\"" ) - -# define CATCH_INTERNAL_SUPPRESS_UNUSED_WARNINGS \ - _Pragma( "clang diagnostic ignored \"-Wunused-variable\"" ) - -# define CATCH_INTERNAL_SUPPRESS_ZERO_VARIADIC_WARNINGS \ - _Pragma( "clang diagnostic ignored \"-Wgnu-zero-variadic-macro-arguments\"" ) - -# define CATCH_INTERNAL_SUPPRESS_UNUSED_TEMPLATE_WARNINGS \ - _Pragma( "clang diagnostic ignored \"-Wunused-template\"" ) - -#endif // __clang__ - -//////////////////////////////////////////////////////////////////////////////// -// Assume that non-Windows platforms support posix signals by default -#if !defined(CATCH_PLATFORM_WINDOWS) - #define CATCH_INTERNAL_CONFIG_POSIX_SIGNALS -#endif - -//////////////////////////////////////////////////////////////////////////////// -// We know some environments not to support full POSIX signals -#if defined(__CYGWIN__) || defined(__QNX__) || defined(__EMSCRIPTEN__) || defined(__DJGPP__) - #define CATCH_INTERNAL_CONFIG_NO_POSIX_SIGNALS -#endif - -#ifdef __OS400__ -# define CATCH_INTERNAL_CONFIG_NO_POSIX_SIGNALS -# define CATCH_CONFIG_COLOUR_NONE -#endif - -//////////////////////////////////////////////////////////////////////////////// -// Android somehow still does not support std::to_string -#if defined(__ANDROID__) -# define CATCH_INTERNAL_CONFIG_NO_CPP11_TO_STRING -# define CATCH_INTERNAL_CONFIG_ANDROID_LOGWRITE -#endif - -//////////////////////////////////////////////////////////////////////////////// -// Not all Windows environments support SEH properly -#if defined(__MINGW32__) -# define CATCH_INTERNAL_CONFIG_NO_WINDOWS_SEH -#endif - -//////////////////////////////////////////////////////////////////////////////// -// PS4 -#if defined(__ORBIS__) -# define CATCH_INTERNAL_CONFIG_NO_NEW_CAPTURE -#endif - -//////////////////////////////////////////////////////////////////////////////// -// Cygwin -#ifdef __CYGWIN__ - -// Required for some versions of Cygwin to declare gettimeofday -// see: http://stackoverflow.com/questions/36901803/gettimeofday-not-declared-in-this-scope-cygwin -# define _BSD_SOURCE -// some versions of cygwin (most) do not support std::to_string. Use the libstd check. -// https://gcc.gnu.org/onlinedocs/gcc-4.8.2/libstdc++/api/a01053_source.html line 2812-2813 -# if !((__cplusplus >= 201103L) && defined(_GLIBCXX_USE_C99) \ - && !defined(_GLIBCXX_HAVE_BROKEN_VSWPRINTF)) - -# define CATCH_INTERNAL_CONFIG_NO_CPP11_TO_STRING - -# endif -#endif // __CYGWIN__ - -//////////////////////////////////////////////////////////////////////////////// -// Visual C++ -#if defined(_MSC_VER) - -# define CATCH_INTERNAL_START_WARNINGS_SUPPRESSION __pragma( warning(push) ) -# define CATCH_INTERNAL_STOP_WARNINGS_SUPPRESSION __pragma( warning(pop) ) - -// Universal Windows platform does not support SEH -// Or console colours (or console at all...) -# if defined(WINAPI_FAMILY) && (WINAPI_FAMILY == WINAPI_FAMILY_APP) -# define CATCH_CONFIG_COLOUR_NONE -# else -# define CATCH_INTERNAL_CONFIG_WINDOWS_SEH -# endif - -// MSVC traditional preprocessor needs some workaround for __VA_ARGS__ -// _MSVC_TRADITIONAL == 0 means new conformant preprocessor -// _MSVC_TRADITIONAL == 1 means old traditional non-conformant preprocessor -# if !defined(__clang__) // Handle Clang masquerading for msvc -# if !defined(_MSVC_TRADITIONAL) || (defined(_MSVC_TRADITIONAL) && _MSVC_TRADITIONAL) -# define CATCH_INTERNAL_CONFIG_TRADITIONAL_MSVC_PREPROCESSOR -# endif // MSVC_TRADITIONAL -# endif // __clang__ - -#endif // _MSC_VER - -#if defined(_REENTRANT) || defined(_MSC_VER) -// Enable async processing, as -pthread is specified or no additional linking is required -# define CATCH_INTERNAL_CONFIG_USE_ASYNC -#endif // _MSC_VER - -//////////////////////////////////////////////////////////////////////////////// -// Check if we are compiled with -fno-exceptions or equivalent -#if defined(__EXCEPTIONS) || defined(__cpp_exceptions) || defined(_CPPUNWIND) -# define CATCH_INTERNAL_CONFIG_EXCEPTIONS_ENABLED -#endif - -//////////////////////////////////////////////////////////////////////////////// -// DJGPP -#ifdef __DJGPP__ -# define CATCH_INTERNAL_CONFIG_NO_WCHAR -#endif // __DJGPP__ - -//////////////////////////////////////////////////////////////////////////////// -// Embarcadero C++Build -#if defined(__BORLANDC__) - #define CATCH_INTERNAL_CONFIG_POLYFILL_ISNAN -#endif - -//////////////////////////////////////////////////////////////////////////////// - -// Use of __COUNTER__ is suppressed during code analysis in -// CLion/AppCode 2017.2.x and former, because __COUNTER__ is not properly -// handled by it. -// Otherwise all supported compilers support COUNTER macro, -// but user still might want to turn it off -#if ( !defined(__JETBRAINS_IDE__) || __JETBRAINS_IDE__ >= 20170300L ) - #define CATCH_INTERNAL_CONFIG_COUNTER -#endif - -//////////////////////////////////////////////////////////////////////////////// - -// RTX is a special version of Windows that is real time. -// This means that it is detected as Windows, but does not provide -// the same set of capabilities as real Windows does. -#if defined(UNDER_RTSS) || defined(RTX64_BUILD) - #define CATCH_INTERNAL_CONFIG_NO_WINDOWS_SEH - #define CATCH_INTERNAL_CONFIG_NO_ASYNC - #define CATCH_CONFIG_COLOUR_NONE -#endif - -#if !defined(_GLIBCXX_USE_C99_MATH_TR1) -#define CATCH_INTERNAL_CONFIG_GLOBAL_NEXTAFTER -#endif - -// Various stdlib support checks that require __has_include -#if defined(__has_include) - // Check if string_view is available and usable - #if __has_include() && defined(CATCH_CPP17_OR_GREATER) - # define CATCH_INTERNAL_CONFIG_CPP17_STRING_VIEW - #endif - - // Check if optional is available and usable - # if __has_include() && defined(CATCH_CPP17_OR_GREATER) - # define CATCH_INTERNAL_CONFIG_CPP17_OPTIONAL - # endif // __has_include() && defined(CATCH_CPP17_OR_GREATER) - - // Check if byte is available and usable - # if __has_include() && defined(CATCH_CPP17_OR_GREATER) - # include - # if defined(__cpp_lib_byte) && (__cpp_lib_byte > 0) - # define CATCH_INTERNAL_CONFIG_CPP17_BYTE - # endif - # endif // __has_include() && defined(CATCH_CPP17_OR_GREATER) - - // Check if variant is available and usable - # if __has_include() && defined(CATCH_CPP17_OR_GREATER) - # if defined(__clang__) && (__clang_major__ < 8) - // work around clang bug with libstdc++ https://bugs.llvm.org/show_bug.cgi?id=31852 - // fix should be in clang 8, workaround in libstdc++ 8.2 - # include - # if defined(__GLIBCXX__) && defined(_GLIBCXX_RELEASE) && (_GLIBCXX_RELEASE < 9) - # define CATCH_CONFIG_NO_CPP17_VARIANT - # else - # define CATCH_INTERNAL_CONFIG_CPP17_VARIANT - # endif // defined(__GLIBCXX__) && defined(_GLIBCXX_RELEASE) && (_GLIBCXX_RELEASE < 9) - # else - # define CATCH_INTERNAL_CONFIG_CPP17_VARIANT - # endif // defined(__clang__) && (__clang_major__ < 8) - # endif // __has_include() && defined(CATCH_CPP17_OR_GREATER) -#endif // defined(__has_include) - -#if defined(CATCH_INTERNAL_CONFIG_COUNTER) && !defined(CATCH_CONFIG_NO_COUNTER) && !defined(CATCH_CONFIG_COUNTER) -# define CATCH_CONFIG_COUNTER -#endif -#if defined(CATCH_INTERNAL_CONFIG_WINDOWS_SEH) && !defined(CATCH_CONFIG_NO_WINDOWS_SEH) && !defined(CATCH_CONFIG_WINDOWS_SEH) && !defined(CATCH_INTERNAL_CONFIG_NO_WINDOWS_SEH) -# define CATCH_CONFIG_WINDOWS_SEH -#endif -// This is set by default, because we assume that unix compilers are posix-signal-compatible by default. -#if defined(CATCH_INTERNAL_CONFIG_POSIX_SIGNALS) && !defined(CATCH_INTERNAL_CONFIG_NO_POSIX_SIGNALS) && !defined(CATCH_CONFIG_NO_POSIX_SIGNALS) && !defined(CATCH_CONFIG_POSIX_SIGNALS) -# define CATCH_CONFIG_POSIX_SIGNALS -#endif -// This is set by default, because we assume that compilers with no wchar_t support are just rare exceptions. -#if !defined(CATCH_INTERNAL_CONFIG_NO_WCHAR) && !defined(CATCH_CONFIG_NO_WCHAR) && !defined(CATCH_CONFIG_WCHAR) -# define CATCH_CONFIG_WCHAR -#endif - -#if !defined(CATCH_INTERNAL_CONFIG_NO_CPP11_TO_STRING) && !defined(CATCH_CONFIG_NO_CPP11_TO_STRING) && !defined(CATCH_CONFIG_CPP11_TO_STRING) -# define CATCH_CONFIG_CPP11_TO_STRING -#endif - -#if defined(CATCH_INTERNAL_CONFIG_CPP17_OPTIONAL) && !defined(CATCH_CONFIG_NO_CPP17_OPTIONAL) && !defined(CATCH_CONFIG_CPP17_OPTIONAL) -# define CATCH_CONFIG_CPP17_OPTIONAL -#endif - -#if defined(CATCH_INTERNAL_CONFIG_CPP17_STRING_VIEW) && !defined(CATCH_CONFIG_NO_CPP17_STRING_VIEW) && !defined(CATCH_CONFIG_CPP17_STRING_VIEW) -# define CATCH_CONFIG_CPP17_STRING_VIEW -#endif - -#if defined(CATCH_INTERNAL_CONFIG_CPP17_VARIANT) && !defined(CATCH_CONFIG_NO_CPP17_VARIANT) && !defined(CATCH_CONFIG_CPP17_VARIANT) -# define CATCH_CONFIG_CPP17_VARIANT -#endif - -#if defined(CATCH_INTERNAL_CONFIG_CPP17_BYTE) && !defined(CATCH_CONFIG_NO_CPP17_BYTE) && !defined(CATCH_CONFIG_CPP17_BYTE) -# define CATCH_CONFIG_CPP17_BYTE -#endif - -#if defined(CATCH_CONFIG_EXPERIMENTAL_REDIRECT) -# define CATCH_INTERNAL_CONFIG_NEW_CAPTURE -#endif - -#if defined(CATCH_INTERNAL_CONFIG_NEW_CAPTURE) && !defined(CATCH_INTERNAL_CONFIG_NO_NEW_CAPTURE) && !defined(CATCH_CONFIG_NO_NEW_CAPTURE) && !defined(CATCH_CONFIG_NEW_CAPTURE) -# define CATCH_CONFIG_NEW_CAPTURE -#endif - -#if !defined(CATCH_INTERNAL_CONFIG_EXCEPTIONS_ENABLED) && !defined(CATCH_CONFIG_DISABLE_EXCEPTIONS) -# define CATCH_CONFIG_DISABLE_EXCEPTIONS -#endif - -#if defined(CATCH_INTERNAL_CONFIG_POLYFILL_ISNAN) && !defined(CATCH_CONFIG_NO_POLYFILL_ISNAN) && !defined(CATCH_CONFIG_POLYFILL_ISNAN) -# define CATCH_CONFIG_POLYFILL_ISNAN -#endif - -#if defined(CATCH_INTERNAL_CONFIG_USE_ASYNC) && !defined(CATCH_INTERNAL_CONFIG_NO_ASYNC) && !defined(CATCH_CONFIG_NO_USE_ASYNC) && !defined(CATCH_CONFIG_USE_ASYNC) -# define CATCH_CONFIG_USE_ASYNC -#endif - -#if defined(CATCH_INTERNAL_CONFIG_ANDROID_LOGWRITE) && !defined(CATCH_CONFIG_NO_ANDROID_LOGWRITE) && !defined(CATCH_CONFIG_ANDROID_LOGWRITE) -# define CATCH_CONFIG_ANDROID_LOGWRITE -#endif - -#if defined(CATCH_INTERNAL_CONFIG_GLOBAL_NEXTAFTER) && !defined(CATCH_CONFIG_NO_GLOBAL_NEXTAFTER) && !defined(CATCH_CONFIG_GLOBAL_NEXTAFTER) -# define CATCH_CONFIG_GLOBAL_NEXTAFTER -#endif - -// Even if we do not think the compiler has that warning, we still have -// to provide a macro that can be used by the code. -#if !defined(CATCH_INTERNAL_START_WARNINGS_SUPPRESSION) -# define CATCH_INTERNAL_START_WARNINGS_SUPPRESSION -#endif -#if !defined(CATCH_INTERNAL_STOP_WARNINGS_SUPPRESSION) -# define CATCH_INTERNAL_STOP_WARNINGS_SUPPRESSION -#endif -#if !defined(CATCH_INTERNAL_SUPPRESS_PARENTHESES_WARNINGS) -# define CATCH_INTERNAL_SUPPRESS_PARENTHESES_WARNINGS -#endif -#if !defined(CATCH_INTERNAL_SUPPRESS_GLOBALS_WARNINGS) -# define CATCH_INTERNAL_SUPPRESS_GLOBALS_WARNINGS -#endif -#if !defined(CATCH_INTERNAL_SUPPRESS_UNUSED_WARNINGS) -# define CATCH_INTERNAL_SUPPRESS_UNUSED_WARNINGS -#endif -#if !defined(CATCH_INTERNAL_SUPPRESS_ZERO_VARIADIC_WARNINGS) -# define CATCH_INTERNAL_SUPPRESS_ZERO_VARIADIC_WARNINGS -#endif - -// The goal of this macro is to avoid evaluation of the arguments, but -// still have the compiler warn on problems inside... -#if !defined(CATCH_INTERNAL_IGNORE_BUT_WARN) -# define CATCH_INTERNAL_IGNORE_BUT_WARN(...) -#endif - -#if defined(__APPLE__) && defined(__apple_build_version__) && (__clang_major__ < 10) -# undef CATCH_INTERNAL_SUPPRESS_UNUSED_TEMPLATE_WARNINGS -#elif defined(__clang__) && (__clang_major__ < 5) -# undef CATCH_INTERNAL_SUPPRESS_UNUSED_TEMPLATE_WARNINGS -#endif - -#if !defined(CATCH_INTERNAL_SUPPRESS_UNUSED_TEMPLATE_WARNINGS) -# define CATCH_INTERNAL_SUPPRESS_UNUSED_TEMPLATE_WARNINGS -#endif - -#if defined(CATCH_CONFIG_DISABLE_EXCEPTIONS) -#define CATCH_TRY if ((true)) -#define CATCH_CATCH_ALL if ((false)) -#define CATCH_CATCH_ANON(type) if ((false)) -#else -#define CATCH_TRY try -#define CATCH_CATCH_ALL catch (...) -#define CATCH_CATCH_ANON(type) catch (type) -#endif - -#if defined(CATCH_INTERNAL_CONFIG_TRADITIONAL_MSVC_PREPROCESSOR) && !defined(CATCH_CONFIG_NO_TRADITIONAL_MSVC_PREPROCESSOR) && !defined(CATCH_CONFIG_TRADITIONAL_MSVC_PREPROCESSOR) -#define CATCH_CONFIG_TRADITIONAL_MSVC_PREPROCESSOR -#endif - -// end catch_compiler_capabilities.h -#define INTERNAL_CATCH_UNIQUE_NAME_LINE2( name, line ) name##line -#define INTERNAL_CATCH_UNIQUE_NAME_LINE( name, line ) INTERNAL_CATCH_UNIQUE_NAME_LINE2( name, line ) -#ifdef CATCH_CONFIG_COUNTER -# define INTERNAL_CATCH_UNIQUE_NAME( name ) INTERNAL_CATCH_UNIQUE_NAME_LINE( name, __COUNTER__ ) -#else -# define INTERNAL_CATCH_UNIQUE_NAME( name ) INTERNAL_CATCH_UNIQUE_NAME_LINE( name, __LINE__ ) -#endif - -#include -#include -#include - -// We need a dummy global operator<< so we can bring it into Catch namespace later -struct Catch_global_namespace_dummy {}; -std::ostream& operator<<(std::ostream&, Catch_global_namespace_dummy); - -namespace Catch { - - struct CaseSensitive { enum Choice { - Yes, - No - }; }; - - class NonCopyable { - NonCopyable( NonCopyable const& ) = delete; - NonCopyable( NonCopyable && ) = delete; - NonCopyable& operator = ( NonCopyable const& ) = delete; - NonCopyable& operator = ( NonCopyable && ) = delete; - - protected: - NonCopyable(); - virtual ~NonCopyable(); - }; - - struct SourceLineInfo { - - SourceLineInfo() = delete; - SourceLineInfo( char const* _file, std::size_t _line ) noexcept - : file( _file ), - line( _line ) - {} - - SourceLineInfo( SourceLineInfo const& other ) = default; - SourceLineInfo& operator = ( SourceLineInfo const& ) = default; - SourceLineInfo( SourceLineInfo&& ) noexcept = default; - SourceLineInfo& operator = ( SourceLineInfo&& ) noexcept = default; - - bool empty() const noexcept { return file[0] == '\0'; } - bool operator == ( SourceLineInfo const& other ) const noexcept; - bool operator < ( SourceLineInfo const& other ) const noexcept; - - char const* file; - std::size_t line; - }; - - std::ostream& operator << ( std::ostream& os, SourceLineInfo const& info ); - - // Bring in operator<< from global namespace into Catch namespace - // This is necessary because the overload of operator<< above makes - // lookup stop at namespace Catch - using ::operator<<; - - // Use this in variadic streaming macros to allow - // >> +StreamEndStop - // as well as - // >> stuff +StreamEndStop - struct StreamEndStop { - std::string operator+() const; - }; - template - T const& operator + ( T const& value, StreamEndStop ) { - return value; - } -} - -#define CATCH_INTERNAL_LINEINFO \ - ::Catch::SourceLineInfo( __FILE__, static_cast( __LINE__ ) ) - -// end catch_common.h -namespace Catch { - - struct RegistrarForTagAliases { - RegistrarForTagAliases( char const* alias, char const* tag, SourceLineInfo const& lineInfo ); - }; - -} // end namespace Catch - -#define CATCH_REGISTER_TAG_ALIAS( alias, spec ) \ - CATCH_INTERNAL_START_WARNINGS_SUPPRESSION \ - CATCH_INTERNAL_SUPPRESS_GLOBALS_WARNINGS \ - namespace{ Catch::RegistrarForTagAliases INTERNAL_CATCH_UNIQUE_NAME( AutoRegisterTagAlias )( alias, spec, CATCH_INTERNAL_LINEINFO ); } \ - CATCH_INTERNAL_STOP_WARNINGS_SUPPRESSION - -// end catch_tag_alias_autoregistrar.h -// start catch_test_registry.h - -// start catch_interfaces_testcase.h - -#include - -namespace Catch { - - class TestSpec; - - struct ITestInvoker { - virtual void invoke () const = 0; - virtual ~ITestInvoker(); - }; - - class TestCase; - struct IConfig; - - struct ITestCaseRegistry { - virtual ~ITestCaseRegistry(); - virtual std::vector const& getAllTests() const = 0; - virtual std::vector const& getAllTestsSorted( IConfig const& config ) const = 0; - }; - - bool isThrowSafe( TestCase const& testCase, IConfig const& config ); - bool matchTest( TestCase const& testCase, TestSpec const& testSpec, IConfig const& config ); - std::vector filterTests( std::vector const& testCases, TestSpec const& testSpec, IConfig const& config ); - std::vector const& getAllTestCasesSorted( IConfig const& config ); - -} - -// end catch_interfaces_testcase.h -// start catch_stringref.h - -#include -#include -#include -#include - -namespace Catch { - - /// A non-owning string class (similar to the forthcoming std::string_view) - /// Note that, because a StringRef may be a substring of another string, - /// it may not be null terminated. - class StringRef { - public: - using size_type = std::size_t; - using const_iterator = const char*; - - private: - static constexpr char const* const s_empty = ""; - - char const* m_start = s_empty; - size_type m_size = 0; - - public: // construction - constexpr StringRef() noexcept = default; - - StringRef( char const* rawChars ) noexcept; - - constexpr StringRef( char const* rawChars, size_type size ) noexcept - : m_start( rawChars ), - m_size( size ) - {} - - StringRef( std::string const& stdString ) noexcept - : m_start( stdString.c_str() ), - m_size( stdString.size() ) - {} - - explicit operator std::string() const { - return std::string(m_start, m_size); - } - - public: // operators - auto operator == ( StringRef const& other ) const noexcept -> bool; - auto operator != (StringRef const& other) const noexcept -> bool { - return !(*this == other); - } - - auto operator[] ( size_type index ) const noexcept -> char { - assert(index < m_size); - return m_start[index]; - } - - public: // named queries - constexpr auto empty() const noexcept -> bool { - return m_size == 0; - } - constexpr auto size() const noexcept -> size_type { - return m_size; - } - - // Returns the current start pointer. If the StringRef is not - // null-terminated, throws std::domain_exception - auto c_str() const -> char const*; - - public: // substrings and searches - // Returns a substring of [start, start + length). - // If start + length > size(), then the substring is [start, size()). - // If start > size(), then the substring is empty. - auto substr( size_type start, size_type length ) const noexcept -> StringRef; - - // Returns the current start pointer. May not be null-terminated. - auto data() const noexcept -> char const*; - - constexpr auto isNullTerminated() const noexcept -> bool { - return m_start[m_size] == '\0'; - } - - public: // iterators - constexpr const_iterator begin() const { return m_start; } - constexpr const_iterator end() const { return m_start + m_size; } - }; - - auto operator += ( std::string& lhs, StringRef const& sr ) -> std::string&; - auto operator << ( std::ostream& os, StringRef const& sr ) -> std::ostream&; - - constexpr auto operator "" _sr( char const* rawChars, std::size_t size ) noexcept -> StringRef { - return StringRef( rawChars, size ); - } -} // namespace Catch - -constexpr auto operator "" _catch_sr( char const* rawChars, std::size_t size ) noexcept -> Catch::StringRef { - return Catch::StringRef( rawChars, size ); -} - -// end catch_stringref.h -// start catch_preprocessor.hpp - - -#define CATCH_RECURSION_LEVEL0(...) __VA_ARGS__ -#define CATCH_RECURSION_LEVEL1(...) CATCH_RECURSION_LEVEL0(CATCH_RECURSION_LEVEL0(CATCH_RECURSION_LEVEL0(__VA_ARGS__))) -#define CATCH_RECURSION_LEVEL2(...) CATCH_RECURSION_LEVEL1(CATCH_RECURSION_LEVEL1(CATCH_RECURSION_LEVEL1(__VA_ARGS__))) -#define CATCH_RECURSION_LEVEL3(...) CATCH_RECURSION_LEVEL2(CATCH_RECURSION_LEVEL2(CATCH_RECURSION_LEVEL2(__VA_ARGS__))) -#define CATCH_RECURSION_LEVEL4(...) CATCH_RECURSION_LEVEL3(CATCH_RECURSION_LEVEL3(CATCH_RECURSION_LEVEL3(__VA_ARGS__))) -#define CATCH_RECURSION_LEVEL5(...) CATCH_RECURSION_LEVEL4(CATCH_RECURSION_LEVEL4(CATCH_RECURSION_LEVEL4(__VA_ARGS__))) - -#ifdef CATCH_CONFIG_TRADITIONAL_MSVC_PREPROCESSOR -#define INTERNAL_CATCH_EXPAND_VARGS(...) __VA_ARGS__ -// MSVC needs more evaluations -#define CATCH_RECURSION_LEVEL6(...) CATCH_RECURSION_LEVEL5(CATCH_RECURSION_LEVEL5(CATCH_RECURSION_LEVEL5(__VA_ARGS__))) -#define CATCH_RECURSE(...) CATCH_RECURSION_LEVEL6(CATCH_RECURSION_LEVEL6(__VA_ARGS__)) -#else -#define CATCH_RECURSE(...) CATCH_RECURSION_LEVEL5(__VA_ARGS__) -#endif - -#define CATCH_REC_END(...) -#define CATCH_REC_OUT - -#define CATCH_EMPTY() -#define CATCH_DEFER(id) id CATCH_EMPTY() - -#define CATCH_REC_GET_END2() 0, CATCH_REC_END -#define CATCH_REC_GET_END1(...) CATCH_REC_GET_END2 -#define CATCH_REC_GET_END(...) CATCH_REC_GET_END1 -#define CATCH_REC_NEXT0(test, next, ...) next CATCH_REC_OUT -#define CATCH_REC_NEXT1(test, next) CATCH_DEFER ( CATCH_REC_NEXT0 ) ( test, next, 0) -#define CATCH_REC_NEXT(test, next) CATCH_REC_NEXT1(CATCH_REC_GET_END test, next) - -#define CATCH_REC_LIST0(f, x, peek, ...) , f(x) CATCH_DEFER ( CATCH_REC_NEXT(peek, CATCH_REC_LIST1) ) ( f, peek, __VA_ARGS__ ) -#define CATCH_REC_LIST1(f, x, peek, ...) , f(x) CATCH_DEFER ( CATCH_REC_NEXT(peek, CATCH_REC_LIST0) ) ( f, peek, __VA_ARGS__ ) -#define CATCH_REC_LIST2(f, x, peek, ...) f(x) CATCH_DEFER ( CATCH_REC_NEXT(peek, CATCH_REC_LIST1) ) ( f, peek, __VA_ARGS__ ) - -#define CATCH_REC_LIST0_UD(f, userdata, x, peek, ...) , f(userdata, x) CATCH_DEFER ( CATCH_REC_NEXT(peek, CATCH_REC_LIST1_UD) ) ( f, userdata, peek, __VA_ARGS__ ) -#define CATCH_REC_LIST1_UD(f, userdata, x, peek, ...) , f(userdata, x) CATCH_DEFER ( CATCH_REC_NEXT(peek, CATCH_REC_LIST0_UD) ) ( f, userdata, peek, __VA_ARGS__ ) -#define CATCH_REC_LIST2_UD(f, userdata, x, peek, ...) f(userdata, x) CATCH_DEFER ( CATCH_REC_NEXT(peek, CATCH_REC_LIST1_UD) ) ( f, userdata, peek, __VA_ARGS__ ) - -// Applies the function macro `f` to each of the remaining parameters, inserts commas between the results, -// and passes userdata as the first parameter to each invocation, -// e.g. CATCH_REC_LIST_UD(f, x, a, b, c) evaluates to f(x, a), f(x, b), f(x, c) -#define CATCH_REC_LIST_UD(f, userdata, ...) CATCH_RECURSE(CATCH_REC_LIST2_UD(f, userdata, __VA_ARGS__, ()()(), ()()(), ()()(), 0)) - -#define CATCH_REC_LIST(f, ...) CATCH_RECURSE(CATCH_REC_LIST2(f, __VA_ARGS__, ()()(), ()()(), ()()(), 0)) - -#define INTERNAL_CATCH_EXPAND1(param) INTERNAL_CATCH_EXPAND2(param) -#define INTERNAL_CATCH_EXPAND2(...) INTERNAL_CATCH_NO## __VA_ARGS__ -#define INTERNAL_CATCH_DEF(...) INTERNAL_CATCH_DEF __VA_ARGS__ -#define INTERNAL_CATCH_NOINTERNAL_CATCH_DEF -#define INTERNAL_CATCH_STRINGIZE(...) INTERNAL_CATCH_STRINGIZE2(__VA_ARGS__) -#ifndef CATCH_CONFIG_TRADITIONAL_MSVC_PREPROCESSOR -#define INTERNAL_CATCH_STRINGIZE2(...) #__VA_ARGS__ -#define INTERNAL_CATCH_STRINGIZE_WITHOUT_PARENS(param) INTERNAL_CATCH_STRINGIZE(INTERNAL_CATCH_REMOVE_PARENS(param)) -#else -// MSVC is adding extra space and needs another indirection to expand INTERNAL_CATCH_NOINTERNAL_CATCH_DEF -#define INTERNAL_CATCH_STRINGIZE2(...) INTERNAL_CATCH_STRINGIZE3(__VA_ARGS__) -#define INTERNAL_CATCH_STRINGIZE3(...) #__VA_ARGS__ -#define INTERNAL_CATCH_STRINGIZE_WITHOUT_PARENS(param) (INTERNAL_CATCH_STRINGIZE(INTERNAL_CATCH_REMOVE_PARENS(param)) + 1) -#endif - -#define INTERNAL_CATCH_MAKE_NAMESPACE2(...) ns_##__VA_ARGS__ -#define INTERNAL_CATCH_MAKE_NAMESPACE(name) INTERNAL_CATCH_MAKE_NAMESPACE2(name) - -#define INTERNAL_CATCH_REMOVE_PARENS(...) INTERNAL_CATCH_EXPAND1(INTERNAL_CATCH_DEF __VA_ARGS__) - -#ifndef CATCH_CONFIG_TRADITIONAL_MSVC_PREPROCESSOR -#define INTERNAL_CATCH_MAKE_TYPE_LIST2(...) decltype(get_wrapper()) -#define INTERNAL_CATCH_MAKE_TYPE_LIST(...) INTERNAL_CATCH_MAKE_TYPE_LIST2(INTERNAL_CATCH_REMOVE_PARENS(__VA_ARGS__)) -#else -#define INTERNAL_CATCH_MAKE_TYPE_LIST2(...) INTERNAL_CATCH_EXPAND_VARGS(decltype(get_wrapper())) -#define INTERNAL_CATCH_MAKE_TYPE_LIST(...) INTERNAL_CATCH_EXPAND_VARGS(INTERNAL_CATCH_MAKE_TYPE_LIST2(INTERNAL_CATCH_REMOVE_PARENS(__VA_ARGS__))) -#endif - -#define INTERNAL_CATCH_MAKE_TYPE_LISTS_FROM_TYPES(...)\ - CATCH_REC_LIST(INTERNAL_CATCH_MAKE_TYPE_LIST,__VA_ARGS__) - -#define INTERNAL_CATCH_REMOVE_PARENS_1_ARG(_0) INTERNAL_CATCH_REMOVE_PARENS(_0) -#define INTERNAL_CATCH_REMOVE_PARENS_2_ARG(_0, _1) INTERNAL_CATCH_REMOVE_PARENS(_0), INTERNAL_CATCH_REMOVE_PARENS_1_ARG(_1) -#define INTERNAL_CATCH_REMOVE_PARENS_3_ARG(_0, _1, _2) INTERNAL_CATCH_REMOVE_PARENS(_0), INTERNAL_CATCH_REMOVE_PARENS_2_ARG(_1, _2) -#define INTERNAL_CATCH_REMOVE_PARENS_4_ARG(_0, _1, _2, _3) INTERNAL_CATCH_REMOVE_PARENS(_0), INTERNAL_CATCH_REMOVE_PARENS_3_ARG(_1, _2, _3) -#define INTERNAL_CATCH_REMOVE_PARENS_5_ARG(_0, _1, _2, _3, _4) INTERNAL_CATCH_REMOVE_PARENS(_0), INTERNAL_CATCH_REMOVE_PARENS_4_ARG(_1, _2, _3, _4) -#define INTERNAL_CATCH_REMOVE_PARENS_6_ARG(_0, _1, _2, _3, _4, _5) INTERNAL_CATCH_REMOVE_PARENS(_0), INTERNAL_CATCH_REMOVE_PARENS_5_ARG(_1, _2, _3, _4, _5) -#define INTERNAL_CATCH_REMOVE_PARENS_7_ARG(_0, _1, _2, _3, _4, _5, _6) INTERNAL_CATCH_REMOVE_PARENS(_0), INTERNAL_CATCH_REMOVE_PARENS_6_ARG(_1, _2, _3, _4, _5, _6) -#define INTERNAL_CATCH_REMOVE_PARENS_8_ARG(_0, _1, _2, _3, _4, _5, _6, _7) INTERNAL_CATCH_REMOVE_PARENS(_0), INTERNAL_CATCH_REMOVE_PARENS_7_ARG(_1, _2, _3, _4, _5, _6, _7) -#define INTERNAL_CATCH_REMOVE_PARENS_9_ARG(_0, _1, _2, _3, _4, _5, _6, _7, _8) INTERNAL_CATCH_REMOVE_PARENS(_0), INTERNAL_CATCH_REMOVE_PARENS_8_ARG(_1, _2, _3, _4, _5, _6, _7, _8) -#define INTERNAL_CATCH_REMOVE_PARENS_10_ARG(_0, _1, _2, _3, _4, _5, _6, _7, _8, _9) INTERNAL_CATCH_REMOVE_PARENS(_0), INTERNAL_CATCH_REMOVE_PARENS_9_ARG(_1, _2, _3, _4, _5, _6, _7, _8, _9) -#define INTERNAL_CATCH_REMOVE_PARENS_11_ARG(_0, _1, _2, _3, _4, _5, _6, _7, _8, _9, _10) INTERNAL_CATCH_REMOVE_PARENS(_0), INTERNAL_CATCH_REMOVE_PARENS_10_ARG(_1, _2, _3, _4, _5, _6, _7, _8, _9, _10) - -#define INTERNAL_CATCH_VA_NARGS_IMPL(_0, _1, _2, _3, _4, _5, _6, _7, _8, _9, _10, N, ...) N - -#define INTERNAL_CATCH_TYPE_GEN\ - template struct TypeList {};\ - template\ - constexpr auto get_wrapper() noexcept -> TypeList { return {}; }\ - template class...> struct TemplateTypeList{};\ - template class...Cs>\ - constexpr auto get_wrapper() noexcept -> TemplateTypeList { return {}; }\ - template\ - struct append;\ - template\ - struct rewrap;\ - template class, typename...>\ - struct create;\ - template class, typename>\ - struct convert;\ - \ - template \ - struct append { using type = T; };\ - template< template class L1, typename...E1, template class L2, typename...E2, typename...Rest>\ - struct append, L2, Rest...> { using type = typename append, Rest...>::type; };\ - template< template class L1, typename...E1, typename...Rest>\ - struct append, TypeList, Rest...> { using type = L1; };\ - \ - template< template class Container, template class List, typename...elems>\ - struct rewrap, List> { using type = TypeList>; };\ - template< template class Container, template class List, class...Elems, typename...Elements>\ - struct rewrap, List, Elements...> { using type = typename append>, typename rewrap, Elements...>::type>::type; };\ - \ - template