From 8e68bed7006a05091e1a6fa8e815abd62e1ae206 Mon Sep 17 00:00:00 2001 From: Martin Zink Date: Tue, 18 Jul 2023 15:48:01 +0200 Subject: [PATCH] Update Catch2 from 2.13.10 to 3.4.0 --- cmake/BuildTests.cmake | 19 +- cmake/Catch2.cmake | 26 + controller/MiNiFiController.cpp | 2 +- controller/tests/CMakeLists.txt | 3 +- encrypt-config/tests/CMakeLists.txt | 3 +- extensions/aws/tests/CMakeLists.txt | 2 +- extensions/civetweb/tests/CMakeLists.txt | 2 +- .../coap/tests/CoapC2VerifyHeartbeat.cpp | 1 - extensions/elasticsearch/tests/CMakeLists.txt | 2 +- .../expression-language/tests/CMakeLists.txt | 4 +- .../tests/ExpressionLanguageTests.cpp | 28 +- .../UpdateAttributeIntegrationTest.cpp | 1 - .../http-curl/tests/AbsoluteTimeoutTest.cpp | 1 - extensions/http-curl/tests/C2CompressTest.cpp | 1 - .../http-curl/tests/C2DebugBundleTest.cpp | 1 - .../C2DescribeCoreComponentStateTest.cpp | 1 - .../tests/C2DescribeManifestTest.cpp | 1 - extensions/http-curl/tests/C2JstackTest.cpp | 1 - .../http-curl/tests/C2LogHeartbeatTest.cpp | 1 - .../tests/C2MultipleCommandsTest.cpp | 1 - .../http-curl/tests/C2NullConfiguration.cpp | 1 - .../http-curl/tests/C2PauseResumeTest.cpp | 1 - .../tests/C2VerifyHeartbeatAndStop.cpp | 1 - .../C2VerifyLightweightHeartbeatAndStop.cpp | 1 - ...C2VerifyResourceConsumptionInHeartbeat.cpp | 1 - .../http-curl/tests/C2VerifyServeResults.cpp | 1 - extensions/http-curl/tests/CMakeLists.txt | 3 +- .../http-curl/tests/HTTPIntegrationBase.h | 1 - .../http-curl/tests/HTTPSiteToSiteTests.cpp | 1 - .../tests/HttpPostIntegrationTest.cpp | 1 - .../http-curl/tests/SiteToSiteRestTest.cpp | 1 - .../tests/TimeoutHTTPSiteToSiteTests.cpp | 1 - extensions/http-curl/tests/VerifyInvokeHTTP.h | 1 - .../http-curl/tests/{ => unit}/AlertTests.cpp | 8 +- extensions/kubernetes/tests/CMakeLists.txt | 2 +- extensions/librdkafka/tests/CMakeLists.txt | 2 +- extensions/lua/tests/CMakeLists.txt | 2 +- extensions/mqtt/tests/CMakeLists.txt | 2 +- extensions/mqtt/tests/ConsumeMQTTTests.cpp | 11 +- extensions/mqtt/tests/PublishMQTTTests.cpp | 7 +- extensions/opencv/tests/CMakeLists.txt | 2 +- extensions/pdh/tests/CMakeLists.txt | 2 +- extensions/procfs/tests/CMakeLists.txt | 2 +- extensions/procfs/tests/CPUStatTests.cpp | 3 +- extensions/prometheus/tests/CMakeLists.txt | 2 +- extensions/python/tests/CMakeLists.txt | 4 +- extensions/script/tests/CMakeLists.txt | 2 +- extensions/sftp/tests/CMakeLists.txt | 2 +- extensions/splunk/tests/CMakeLists.txt | 2 +- .../standard-processors/tests/CMakeLists.txt | 2 +- .../tests/integration/ProcessGroupTest.cpp | 1 - .../integration/SecureSocketGetTCPTest.cpp | 1 - .../tests/unit/ExecuteProcessTests.cpp | 5 +- .../tests/unit/ListenSyslogTests.cpp | 58 +- .../tests/unit/ListenTcpTests.cpp | 56 +- .../tests/unit/ListenUDPTests.cpp | 16 +- .../tests/unit/ProcessorTests.cpp | 8 +- extensions/systemd/tests/CMakeLists.txt | 2 +- .../windows-event-log/tests/CMakeLists.txt | 2 +- libminifi/test/Catch.h | 18 +- libminifi/test/CatchMain.cpp | 20 - libminifi/test/Utils.h | 2 +- libminifi/test/archive-tests/CMakeLists.txt | 2 +- libminifi/test/azure-tests/CMakeLists.txt | 2 +- libminifi/test/bustache-tests/CMakeLists.txt | 2 +- libminifi/test/flow-tests/CMakeLists.txt | 2 +- libminifi/test/gps-tests/CMakeLists.txt | 2 +- .../OnScheduleErrorHandlingTests.cpp | 1 - .../StateTransactionalityTests.cpp | 1 - libminifi/test/jni-tests/CMakeLists.txt | 2 +- libminifi/test/keyvalue-tests/CMakeLists.txt | 2 +- .../PersistentStateStorageTest.cpp | 3 +- .../VolatileMapStateStorageTest.cpp | 3 +- .../test/persistence-tests/CMakeLists.txt | 2 +- .../persistence-tests/PersistenceTests.cpp | 3 +- libminifi/test/rocksdb-tests/CMakeLists.txt | 2 +- libminifi/test/schema-tests/CMakeLists.txt | 2 +- libminifi/test/sql-tests/CMakeLists.txt | 3 +- .../test/tensorflow-tests/CMakeLists.txt | 2 +- .../unit/ContentRepositoryDependentTests.h | 2 +- libminifi/test/unit/FileUtilsTests.cpp | 17 +- libminifi/test/unit/NetUtilsTest.cpp | 24 +- libminifi/test/unit/OsUtilTests.cpp | 4 + libminifi/test/unit/ProcessContextTest.cpp | 20 +- libminifi/test/unit/RegexUtilsTests.cpp | 4 +- .../unit/WindowsCertStoreLocationTests.cpp | 6 + libminifi/test/unit/tls/TLSStreamTests.cpp | 1 - minifi_main/tests/CMakeLists.txt | 2 +- thirdparty/catch/catch.hpp | 17976 ---------------- 89 files changed, 234 insertions(+), 18220 deletions(-) create mode 100644 cmake/Catch2.cmake rename extensions/http-curl/tests/{ => unit}/AlertTests.cpp (97%) delete mode 100644 libminifi/test/CatchMain.cpp delete mode 100644 thirdparty/catch/catch.hpp diff --git a/cmake/BuildTests.cmake b/cmake/BuildTests.cmake index 238b1f87b2..3d9c394e6b 100644 --- a/cmake/BuildTests.cmake +++ b/cmake/BuildTests.cmake @@ -15,6 +15,7 @@ # specific language governing permissions and limitations # under the License. +include(Catch2) ### test functions MACRO(GETSOURCEFILES result curdir) @@ -31,7 +32,6 @@ ENDMACRO() set(NANOFI_TEST_DIR "${CMAKE_SOURCE_DIR}/nanofi/tests/") function(appendIncludes testName) - target_include_directories(${testName} SYSTEM BEFORE PRIVATE "${CMAKE_SOURCE_DIR}/thirdparty/catch") target_include_directories(${testName} BEFORE PRIVATE "${CMAKE_SOURCE_DIR}/include") target_include_directories(${testName} BEFORE PRIVATE "${CMAKE_SOURCE_DIR}/libminifi/include/") target_include_directories(${testName} BEFORE PRIVATE "${CMAKE_SOURCE_DIR}/libminifi/include/c2/protocols") @@ -59,16 +59,9 @@ function(createTests testName) message(DEBUG "-- Adding test: ${testName}") appendIncludes("${testName}") - if (Boost_FOUND) - target_include_directories(${testName} BEFORE PRIVATE "${Boost_INCLUDE_DIRS}") - endif() target_link_libraries(${testName} ${CMAKE_DL_LIBS}) target_wholearchive_library(${testName} ${TEST_BASE_LIB}) target_link_libraries(${testName} core-minifi yaml-cpp spdlog Threads::Threads) - if (Boost_FOUND) - target_link_libraries(${testName} ${Boost_SYSTEM_LIBRARY}) - target_link_libraries(${testName} ${Boost_FILESYSTEM_LIBRARY}) - endif() target_compile_definitions(${testName} PRIVATE LOAD_EXTENSIONS) set_target_properties(${testName} PROPERTIES RUNTIME_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/bin") endfunction() @@ -80,7 +73,6 @@ set(TEST_BASE_SOURCES "TestBase.cpp" "RandomServerSocket.cpp" "StatefulProcessor list(TRANSFORM TEST_BASE_SOURCES PREPEND "${TEST_DIR}/") add_library(${TEST_BASE_LIB} STATIC "${TEST_BASE_SOURCES}") target_link_libraries(${TEST_BASE_LIB} core-minifi) -target_include_directories(${TEST_BASE_LIB} SYSTEM BEFORE PRIVATE "${CMAKE_SOURCE_DIR}/thirdparty/catch") target_include_directories(${TEST_BASE_LIB} BEFORE PRIVATE "${CMAKE_SOURCE_DIR}/libminifi/include/") if(WIN32) target_include_directories(${TEST_BASE_LIB} BEFORE PRIVATE "${CMAKE_SOURCE_DIR}/libminifi/opsys/win") @@ -88,11 +80,6 @@ else() target_include_directories(${TEST_BASE_LIB} BEFORE PRIVATE "${CMAKE_SOURCE_DIR}/libminifi/opsys/posix") endif() -SET(CATCH_MAIN_LIB catch_main) -add_library(${CATCH_MAIN_LIB} STATIC "${TEST_DIR}/CatchMain.cpp") -target_include_directories(${CATCH_MAIN_LIB} SYSTEM BEFORE PRIVATE "${CMAKE_SOURCE_DIR}/thirdparty/catch") -target_link_libraries(${CATCH_MAIN_LIB} spdlog) # for fmt - SET(TEST_RESOURCES ${TEST_DIR}/resources) GETSOURCEFILES(UNIT_TESTS "${TEST_DIR}/unit/") @@ -106,7 +93,7 @@ FOREACH(testfile ${UNIT_TESTS}) add_executable("${testfilename}" "${TEST_DIR}/unit/${testfile}") target_compile_definitions("${testfilename}" PRIVATE TZ_DATA_DIR="${CMAKE_BINARY_DIR}/tzdata") createTests("${testfilename}") - target_link_libraries(${testfilename} ${CATCH_MAIN_LIB}) + target_link_libraries(${testfilename} Catch2WithMain) MATH(EXPR UNIT_TEST_COUNT "${UNIT_TEST_COUNT}+1") add_test(NAME "${testfilename}" COMMAND "${testfilename}" WORKING_DIRECTORY ${TEST_DIR}) ENDFOREACH() @@ -134,7 +121,7 @@ if(NOT WIN32 AND ENABLE_NANOFI) target_include_directories(${testfilename} BEFORE PRIVATE "${CMAKE_SOURCE_DIR}/extensions/standard-processors/processors/") target_include_directories(${testfilename} BEFORE PRIVATE "${CMAKE_SOURCE_DIR}/libminifi/test") appendIncludes("${testfilename}") - target_link_libraries(${testfilename} ${CATCH_MAIN_LIB} Threads::Threads) + target_link_libraries(${testfilename} Catch2WithMain Threads::Threads) target_wholearchive_library(${testfilename} nanofi) diff --git a/cmake/Catch2.cmake b/cmake/Catch2.cmake new file mode 100644 index 0000000000..d4c257af2d --- /dev/null +++ b/cmake/Catch2.cmake @@ -0,0 +1,26 @@ +# +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. +# +include(FetchContent) + +FetchContent_Declare( + Catch2 + URL https://github.com/catchorg/Catch2/archive/refs/tags/v3.4.0.tar.gz + URL_HASH SHA256=122928b814b75717316c71af69bd2b43387643ba076a6ec16e7882bfb2dfacbb +) +FetchContent_MakeAvailable(Catch2) diff --git a/controller/MiNiFiController.cpp b/controller/MiNiFiController.cpp index eb826103a3..e66afbdf9b 100644 --- a/controller/MiNiFiController.cpp +++ b/controller/MiNiFiController.cpp @@ -89,7 +89,7 @@ std::shared_ptr getSSLContextService(con int main(int argc, char **argv) { const auto logger = minifi::core::logging::LoggerConfiguration::getConfiguration().getLogger("controller"); - const std::string minifi_home = determineMinifiHome(logger); + const auto minifi_home = determineMinifiHome(logger); if (minifi_home.empty()) { // determineMinifiHome already logged everything we need return -1; diff --git a/controller/tests/CMakeLists.txt b/controller/tests/CMakeLists.txt index 01eaa09af4..e51c2eb82f 100644 --- a/controller/tests/CMakeLists.txt +++ b/controller/tests/CMakeLists.txt @@ -31,14 +31,13 @@ foreach(testfile ${CONTROLLER_TESTS}) get_filename_component(testfilename "${testfile}" NAME_WE) add_executable(${testfilename} "${testfile}" ${CONTROLLER_SOURCES}) - target_include_directories(${testfilename} SYSTEM BEFORE PRIVATE "${CMAKE_SOURCE_DIR}/thirdparty/catch") target_include_directories(${testfilename} BEFORE PRIVATE "${CMAKE_SOURCE_DIR}/controller") target_include_directories(${testfilename} BEFORE PRIVATE "${CMAKE_SOURCE_DIR}/libminifi/include") target_include_directories(${testfilename} BEFORE PRIVATE "${CMAKE_SOURCE_DIR}/libminifi/test") createTests(${testfilename}) - target_link_libraries(${testfilename} ${CATCH_MAIN_LIB} ${LIBMINIFI} ${TEST_BASE_LIB}) + target_link_libraries(${testfilename} Catch2WithMain ${LIBMINIFI} ${TEST_BASE_LIB}) add_test(NAME ${testfilename} COMMAND ${testfilename} WORKING_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}") math(EXPR CONTROLLER_TEST_COUNT "${CONTROLLER_TEST_COUNT}+1") diff --git a/encrypt-config/tests/CMakeLists.txt b/encrypt-config/tests/CMakeLists.txt index 4fda1f7270..5545d00209 100644 --- a/encrypt-config/tests/CMakeLists.txt +++ b/encrypt-config/tests/CMakeLists.txt @@ -26,14 +26,13 @@ foreach(testfile ${ENCRYPT_CONFIG_TESTS}) get_filename_component(testfilename "${testfile}" NAME_WE) add_executable(${testfilename} "${testfile}" ${ENCRYPT_CONFIG_SOURCES}) - target_include_directories(${testfilename} SYSTEM BEFORE PRIVATE "${CMAKE_SOURCE_DIR}/thirdparty/catch") target_include_directories(${testfilename} BEFORE PRIVATE "${CMAKE_SOURCE_DIR}/encrypt-config") target_include_directories(${testfilename} BEFORE PRIVATE "${CMAKE_SOURCE_DIR}/libminifi/include") target_include_directories(${testfilename} BEFORE PRIVATE "${CMAKE_SOURCE_DIR}/libminifi/test") createTests(${testfilename}) - target_link_libraries(${testfilename} ${CATCH_MAIN_LIB} ${LIBMINIFI} ${TEST_BASE_LIB}) + target_link_libraries(${testfilename} Catch2WithMain ${LIBMINIFI} ${TEST_BASE_LIB}) add_test(NAME ${testfilename} COMMAND ${testfilename} WORKING_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}") math(EXPR ENCRYPT_CONFIG_TEST_COUNT "${ENCRYPT_CONFIG_TEST_COUNT}+1") diff --git a/extensions/aws/tests/CMakeLists.txt b/extensions/aws/tests/CMakeLists.txt index 261b7a6941..3cb0680553 100644 --- a/extensions/aws/tests/CMakeLists.txt +++ b/extensions/aws/tests/CMakeLists.txt @@ -30,7 +30,7 @@ FOREACH(testfile ${AWS_INTEGRATION_TESTS}) target_include_directories(${testfilename} PRIVATE BEFORE "${CMAKE_SOURCE_DIR}/extensions/expression-language") target_include_directories(${testfilename} BEFORE PRIVATE "${CMAKE_SOURCE_DIR}/libminifi/test") createTests("${testfilename}") - target_link_libraries(${testfilename} ${CATCH_MAIN_LIB}) + target_link_libraries(${testfilename} Catch2WithMain) target_link_libraries(${testfilename} minifi-aws) target_link_libraries(${testfilename} minifi-standard-processors) target_link_libraries(${testfilename} minifi-expression-language-extensions) diff --git a/extensions/civetweb/tests/CMakeLists.txt b/extensions/civetweb/tests/CMakeLists.txt index 2766bcf6fd..da835ae916 100644 --- a/extensions/civetweb/tests/CMakeLists.txt +++ b/extensions/civetweb/tests/CMakeLists.txt @@ -34,7 +34,7 @@ if(NOT DISABLE_CURL) target_link_libraries(${testfilename} minifi-standard-processors) createTests("${testfilename}") - target_link_libraries(${testfilename} ${CATCH_MAIN_LIB}) + target_link_libraries(${testfilename} Catch2WithMain) MATH(EXPR CIVETWEB-EXTENSIONS_TEST_COUNT "${CIVETWEB-EXTENSIONS_TEST_COUNT}+1") add_test(NAME "${testfilename}" COMMAND "${testfilename}" WORKING_DIRECTORY ${TEST_DIR}) # Copy test resources diff --git a/extensions/coap/tests/CoapC2VerifyHeartbeat.cpp b/extensions/coap/tests/CoapC2VerifyHeartbeat.cpp index 15d7434465..fcfd2cd808 100644 --- a/extensions/coap/tests/CoapC2VerifyHeartbeat.cpp +++ b/extensions/coap/tests/CoapC2VerifyHeartbeat.cpp @@ -32,7 +32,6 @@ #include "BaseHTTPClient.h" #include "processors/InvokeHTTP.h" #include "TestBase.h" -#include "Catch.h" #include "utils/StringUtils.h" #include "core/Core.h" #include "core/logging/Logger.h" diff --git a/extensions/elasticsearch/tests/CMakeLists.txt b/extensions/elasticsearch/tests/CMakeLists.txt index e53b6d4d9c..32269c1877 100644 --- a/extensions/elasticsearch/tests/CMakeLists.txt +++ b/extensions/elasticsearch/tests/CMakeLists.txt @@ -30,7 +30,7 @@ FOREACH(testfile ${ELASTICSEARCH_TESTS}) target_include_directories(${testfilename} BEFORE PRIVATE "${CMAKE_SOURCE_DIR}/extensions/http-curl/") createTests("${testfilename}") - target_link_libraries(${testfilename} ${CATCH_MAIN_LIB}) + target_link_libraries(${testfilename} Catch2WithMain) target_link_libraries(${testfilename} minifi-elasticsearch) target_link_libraries(${testfilename} minifi-civet-extensions) target_link_libraries(${testfilename} minifi-http-curl) diff --git a/extensions/expression-language/tests/CMakeLists.txt b/extensions/expression-language/tests/CMakeLists.txt index 86e078ea25..f8a85a446f 100644 --- a/extensions/expression-language/tests/CMakeLists.txt +++ b/extensions/expression-language/tests/CMakeLists.txt @@ -24,14 +24,13 @@ SET(EXTENSIONS_TEST_COUNT 0) FOREACH(testfile ${EXPRESSION_LANGUAGE_TESTS}) get_filename_component(testfilename "${testfile}" NAME_WE) add_executable(${testfilename} "${testfile}") - target_include_directories(${testfilename} SYSTEM BEFORE PRIVATE "${CMAKE_SOURCE_DIR}/thirdparty/catch") target_include_directories(${testfilename} BEFORE PRIVATE "${CMAKE_SOURCE_DIR}/libminifi/test") target_include_directories(${testfilename} BEFORE PRIVATE "${CMAKE_SOURCE_DIR}/libminifi/include") target_include_directories(${testfilename} BEFORE PRIVATE "${CMAKE_SOURCE_DIR}/extensions/standard-processors") target_include_directories(${testfilename} BEFORE PRIVATE "${CMAKE_SOURCE_DIR}/extensions/standard-processors/processors") target_include_directories(${testfilename} BEFORE PRIVATE "${CMAKE_SOURCE_DIR}/extensions/expression-language") createTests(${testfilename}) - target_link_libraries(${testfilename} ${CATCH_MAIN_LIB}) + target_link_libraries(${testfilename} Catch2WithMain) if(NOT DISABLE_CURL) target_link_libraries(${testfilename} CURL::libcurl) endif() @@ -53,7 +52,6 @@ SET(INT_EXTENSIONS_TEST_COUNT 0) FOREACH(testfile ${INT_EXPRESSION_LANGUAGE_TESTS}) get_filename_component(testfilename "${testfile}" NAME_WE) add_executable(${testfilename} "${testfile}") - target_include_directories(${testfilename} SYSTEM BEFORE PRIVATE "${CMAKE_SOURCE_DIR}/thirdparty/catch") target_include_directories(${testfilename} BEFORE PRIVATE "${CMAKE_SOURCE_DIR}/libminifi/test") target_include_directories(${testfilename} BEFORE PRIVATE "${CMAKE_SOURCE_DIR}/extensions/standard-processors") target_include_directories(${testfilename} BEFORE PRIVATE "${CMAKE_SOURCE_DIR}/extensions/standard-processors/processors") diff --git a/extensions/expression-language/tests/ExpressionLanguageTests.cpp b/extensions/expression-language/tests/ExpressionLanguageTests.cpp index b8f42db791..0fa47935b3 100644 --- a/extensions/expression-language/tests/ExpressionLanguageTests.cpp +++ b/extensions/expression-language/tests/ExpressionLanguageTests.cpp @@ -39,6 +39,7 @@ #include "utils/gsl.h" #include "TestBase.h" #include "Catch.h" +#include "catch2/catch_approx.hpp" #include "unit/ProvenanceTestHelper.h" #include "date/tz.h" #include "Utils.h" @@ -626,7 +627,7 @@ TEST_CASE("Plus Exponent 2", "[expressionLanguagePlusExponent2]") { auto flow_file_a = std::make_shared(); flow_file_a->addAttribute("attr", "11.345678901234"); - REQUIRE(10000011.345678901234 == Approx(expr(expression::Parameters{ flow_file_a }).asLongDouble())); + REQUIRE(10000011.345678901234 == Catch::Approx(expr(expression::Parameters{ flow_file_a }).asLongDouble())); } TEST_CASE("Minus Integer", "[expressionLanguageMinusInteger]") { @@ -658,7 +659,7 @@ TEST_CASE("Multiply Decimal", "[expressionLanguageMultiplyDecimal]") { auto flow_file_a = std::make_shared(); flow_file_a->addAttribute("attr", "11.1"); - REQUIRE(-148.136937 == Approx(expr(expression::Parameters{ flow_file_a }).asLongDouble())); + REQUIRE(-148.136937 == Catch::Approx(expr(expression::Parameters{ flow_file_a }).asLongDouble())); } TEST_CASE("Divide Integer", "[expressionLanguageDivideInteger]") { @@ -910,8 +911,8 @@ TEST_CASE("GT3", "[expressionGT3]") { // using :gt() to test string to integer parsing code TEST_CASE("GT4 Value parsing errors", "[expressionGT4][outofrange]") { - const char* test_str; - const char* expected_substr; + const char* test_str = nullptr; + const char* expected_substr = nullptr; SECTION("integer out of range") { // 2 ^ 64, the smallest positive integer that's not representable even in uint64_t test_str = "18446744073709551616"; @@ -1405,30 +1406,31 @@ TEST_CASE("Reverse DNS lookup with valid ip", "[ExpressionLanguage][reverseDnsLo auto flow_file_a = std::make_shared(); std::string expected_hostname; - SECTION("dns.google IPv4") { - flow_file_a->addAttribute("ip_addr", "8.8.8.8"); - expected_hostname = "dns.google"; - } SECTION("dns.google IPv6") { if (minifi::test::utils::isIPv6Disabled()) - return; + SKIP("IPv6 is disabled"); flow_file_a->addAttribute("ip_addr", "2001:4860:4860::8888"); expected_hostname = "dns.google"; } - SECTION("Unresolvable address IPv4") { - flow_file_a->addAttribute("ip_addr", "192.0.2.0"); - expected_hostname = "192.0.2.0"; + SECTION("dns.google IPv4") { + flow_file_a->addAttribute("ip_addr", "8.8.8.8"); + expected_hostname = "dns.google"; } SECTION("Unresolvable address IPv6") { if (minifi::test::utils::isIPv6Disabled()) - return; + SKIP("IPv6 is disabled"); flow_file_a->addAttribute("ip_addr", "2001:db8::"); expected_hostname = "2001:db8::"; } + SECTION("Unresolvable address IPv4") { + flow_file_a->addAttribute("ip_addr", "192.0.2.0"); + expected_hostname = "192.0.2.0"; + } + REQUIRE(expr(expression::Parameters{ flow_file_a }).asString() == expected_hostname); } diff --git a/extensions/expression-language/tests/integration/UpdateAttributeIntegrationTest.cpp b/extensions/expression-language/tests/integration/UpdateAttributeIntegrationTest.cpp index 28c3dc140a..774edb3a5e 100644 --- a/extensions/expression-language/tests/integration/UpdateAttributeIntegrationTest.cpp +++ b/extensions/expression-language/tests/integration/UpdateAttributeIntegrationTest.cpp @@ -26,7 +26,6 @@ #include "integration/IntegrationBase.h" #include "ProcessContextExpr.h" #include "TestBase.h" -#include "Catch.h" #include "utils/IntegrationTestUtils.h" class TestHarness : public IntegrationBase { diff --git a/extensions/http-curl/tests/AbsoluteTimeoutTest.cpp b/extensions/http-curl/tests/AbsoluteTimeoutTest.cpp index 27b94b2b3b..4eac7b1ebf 100644 --- a/extensions/http-curl/tests/AbsoluteTimeoutTest.cpp +++ b/extensions/http-curl/tests/AbsoluteTimeoutTest.cpp @@ -19,7 +19,6 @@ #include #include "TestBase.h" -#include "Catch.h" #include "tests/TestServer.h" #include "HTTPHandlers.h" diff --git a/extensions/http-curl/tests/C2CompressTest.cpp b/extensions/http-curl/tests/C2CompressTest.cpp index e0ea8974da..feccdf9aac 100644 --- a/extensions/http-curl/tests/C2CompressTest.cpp +++ b/extensions/http-curl/tests/C2CompressTest.cpp @@ -19,7 +19,6 @@ #undef NDEBUG #include "TestBase.h" -#include "Catch.h" #include "c2/C2Agent.h" #include "c2/HeartbeatLogger.h" diff --git a/extensions/http-curl/tests/C2DebugBundleTest.cpp b/extensions/http-curl/tests/C2DebugBundleTest.cpp index b4d5312552..b68bd7b7c0 100644 --- a/extensions/http-curl/tests/C2DebugBundleTest.cpp +++ b/extensions/http-curl/tests/C2DebugBundleTest.cpp @@ -19,7 +19,6 @@ #undef NDEBUG #include "TestBase.h" -#include "Catch.h" #include "c2/C2Agent.h" #include "protocols/RESTProtocol.h" diff --git a/extensions/http-curl/tests/C2DescribeCoreComponentStateTest.cpp b/extensions/http-curl/tests/C2DescribeCoreComponentStateTest.cpp index ea88afed0a..e3cc2556c3 100644 --- a/extensions/http-curl/tests/C2DescribeCoreComponentStateTest.cpp +++ b/extensions/http-curl/tests/C2DescribeCoreComponentStateTest.cpp @@ -19,7 +19,6 @@ #undef NDEBUG #include #include "TestBase.h" -#include "Catch.h" #include "HTTPIntegrationBase.h" #include "HTTPHandlers.h" #include "processors/TailFile.h" diff --git a/extensions/http-curl/tests/C2DescribeManifestTest.cpp b/extensions/http-curl/tests/C2DescribeManifestTest.cpp index 9475b40860..afa2617a07 100644 --- a/extensions/http-curl/tests/C2DescribeManifestTest.cpp +++ b/extensions/http-curl/tests/C2DescribeManifestTest.cpp @@ -18,7 +18,6 @@ #undef NDEBUG #include -#include "Catch.h" #include "HTTPIntegrationBase.h" #include "HTTPHandlers.h" #include "properties/Configuration.h" diff --git a/extensions/http-curl/tests/C2JstackTest.cpp b/extensions/http-curl/tests/C2JstackTest.cpp index f1b9b45211..6ccfd987b9 100644 --- a/extensions/http-curl/tests/C2JstackTest.cpp +++ b/extensions/http-curl/tests/C2JstackTest.cpp @@ -20,7 +20,6 @@ #include #include #include "TestBase.h" -#include "Catch.h" #include "HTTPIntegrationBase.h" #include "HTTPHandlers.h" #include "utils/IntegrationTestUtils.h" diff --git a/extensions/http-curl/tests/C2LogHeartbeatTest.cpp b/extensions/http-curl/tests/C2LogHeartbeatTest.cpp index 1e50c7e542..671b09f097 100644 --- a/extensions/http-curl/tests/C2LogHeartbeatTest.cpp +++ b/extensions/http-curl/tests/C2LogHeartbeatTest.cpp @@ -19,7 +19,6 @@ #undef NDEBUG #include "TestBase.h" -#include "Catch.h" #include "c2/C2Agent.h" #include "c2/HeartbeatLogger.h" diff --git a/extensions/http-curl/tests/C2MultipleCommandsTest.cpp b/extensions/http-curl/tests/C2MultipleCommandsTest.cpp index a8d58ab532..bb82b72708 100644 --- a/extensions/http-curl/tests/C2MultipleCommandsTest.cpp +++ b/extensions/http-curl/tests/C2MultipleCommandsTest.cpp @@ -22,7 +22,6 @@ #include #include "TestBase.h" -#include "Catch.h" #include "HTTPIntegrationBase.h" #include "HTTPHandlers.h" diff --git a/extensions/http-curl/tests/C2NullConfiguration.cpp b/extensions/http-curl/tests/C2NullConfiguration.cpp index 504401d51a..4f04e2a7f6 100644 --- a/extensions/http-curl/tests/C2NullConfiguration.cpp +++ b/extensions/http-curl/tests/C2NullConfiguration.cpp @@ -23,7 +23,6 @@ #include #include "InvokeHTTP.h" #include "TestBase.h" -#include "Catch.h" #include "core/logging/Logger.h" #include "core/ProcessGroup.h" #include "TestServer.h" diff --git a/extensions/http-curl/tests/C2PauseResumeTest.cpp b/extensions/http-curl/tests/C2PauseResumeTest.cpp index eaf80479f2..8644847fa5 100644 --- a/extensions/http-curl/tests/C2PauseResumeTest.cpp +++ b/extensions/http-curl/tests/C2PauseResumeTest.cpp @@ -21,7 +21,6 @@ #include #include "TestBase.h" -#include "Catch.h" #include "HTTPIntegrationBase.h" #include "HTTPHandlers.h" #include "InvokeHTTP.h" diff --git a/extensions/http-curl/tests/C2VerifyHeartbeatAndStop.cpp b/extensions/http-curl/tests/C2VerifyHeartbeatAndStop.cpp index b39f8dee2e..a4791793fa 100644 --- a/extensions/http-curl/tests/C2VerifyHeartbeatAndStop.cpp +++ b/extensions/http-curl/tests/C2VerifyHeartbeatAndStop.cpp @@ -18,7 +18,6 @@ #undef NDEBUG #include "TestBase.h" -#include "Catch.h" #include "c2/C2Agent.h" #include "protocols/RESTProtocol.h" #include "protocols/RESTSender.h" diff --git a/extensions/http-curl/tests/C2VerifyLightweightHeartbeatAndStop.cpp b/extensions/http-curl/tests/C2VerifyLightweightHeartbeatAndStop.cpp index f371685b7b..5b2d26fe4d 100644 --- a/extensions/http-curl/tests/C2VerifyLightweightHeartbeatAndStop.cpp +++ b/extensions/http-curl/tests/C2VerifyLightweightHeartbeatAndStop.cpp @@ -20,7 +20,6 @@ #include #include "TestBase.h" -#include "Catch.h" #include "c2/C2Agent.h" #include "protocols/RESTProtocol.h" #include "protocols/RESTSender.h" diff --git a/extensions/http-curl/tests/C2VerifyResourceConsumptionInHeartbeat.cpp b/extensions/http-curl/tests/C2VerifyResourceConsumptionInHeartbeat.cpp index d9c5cbe82c..35eaaad0ce 100644 --- a/extensions/http-curl/tests/C2VerifyResourceConsumptionInHeartbeat.cpp +++ b/extensions/http-curl/tests/C2VerifyResourceConsumptionInHeartbeat.cpp @@ -21,7 +21,6 @@ #include #include "TestBase.h" -#include "Catch.h" #include "c2/C2Agent.h" #include "protocols/RESTProtocol.h" #include "protocols/RESTSender.h" diff --git a/extensions/http-curl/tests/C2VerifyServeResults.cpp b/extensions/http-curl/tests/C2VerifyServeResults.cpp index 840252a05d..8242dcb79f 100644 --- a/extensions/http-curl/tests/C2VerifyServeResults.cpp +++ b/extensions/http-curl/tests/C2VerifyServeResults.cpp @@ -23,7 +23,6 @@ #include #include "processors/InvokeHTTP.h" #include "TestBase.h" -#include "Catch.h" #include "core/ProcessGroup.h" #include "properties/Configure.h" #include "TestServer.h" diff --git a/extensions/http-curl/tests/CMakeLists.txt b/extensions/http-curl/tests/CMakeLists.txt index 108d1e85ef..5194fe89ca 100644 --- a/extensions/http-curl/tests/CMakeLists.txt +++ b/extensions/http-curl/tests/CMakeLists.txt @@ -35,7 +35,7 @@ FOREACH(testfile ${CURL_UNIT_TESTS}) target_include_directories(${testfilename} BEFORE PRIVATE "${CMAKE_SOURCE_DIR}/extensions/civetweb/") target_include_directories(${testfilename} BEFORE PRIVATE ./include) createTests("${testfilename}") - target_link_libraries(${testfilename} ${CATCH_MAIN_LIB}) + target_link_libraries(${testfilename} Catch2WithMain) target_link_libraries(${testfilename} minifi-http-curl) target_link_libraries(${testfilename} minifi-civet-extensions) target_link_libraries(${testfilename} minifi-standard-processors) @@ -110,4 +110,3 @@ add_test(NAME C2MetricsTest COMMAND C2MetricsTest "${TEST_RESOURCES}/TestC2Metri add_test(NAME C2EmptyMetricTest COMMAND C2EmptyMetricTest "${TEST_RESOURCES}/TestEmpty.yml") add_test(NAME C2SameProcessorMetrics COMMAND C2SameProcessorMetrics "${TEST_RESOURCES}/TestSameProcessorMetrics.yml") add_test(NAME C2DescribeMetricsTest COMMAND C2DescribeMetricsTest "${TEST_RESOURCES}/TestSameProcessorMetrics.yml") -add_test(NAME AlertTests COMMAND AlertTests) diff --git a/extensions/http-curl/tests/HTTPIntegrationBase.h b/extensions/http-curl/tests/HTTPIntegrationBase.h index f7c7733a9f..a4b54d55a4 100644 --- a/extensions/http-curl/tests/HTTPIntegrationBase.h +++ b/extensions/http-curl/tests/HTTPIntegrationBase.h @@ -27,7 +27,6 @@ #include "protocols/RESTSender.h" #include "ServerAwareHandler.h" #include "TestBase.h" -#include "Catch.h" #include "utils/IntegrationTestUtils.h" #include "TestServer.h" #include "properties/Configuration.h" diff --git a/extensions/http-curl/tests/HTTPSiteToSiteTests.cpp b/extensions/http-curl/tests/HTTPSiteToSiteTests.cpp index 311c7b5010..6d02b3d73b 100644 --- a/extensions/http-curl/tests/HTTPSiteToSiteTests.cpp +++ b/extensions/http-curl/tests/HTTPSiteToSiteTests.cpp @@ -26,7 +26,6 @@ #include "sitetosite/HTTPProtocol.h" #include "InvokeHTTP.h" #include "TestBase.h" -#include "Catch.h" #include "FlowController.h" #include "io/StreamFactory.h" #include "RemoteProcessorGroupPort.h" diff --git a/extensions/http-curl/tests/HttpPostIntegrationTest.cpp b/extensions/http-curl/tests/HttpPostIntegrationTest.cpp index dfd6d3d183..d6d03e8858 100644 --- a/extensions/http-curl/tests/HttpPostIntegrationTest.cpp +++ b/extensions/http-curl/tests/HttpPostIntegrationTest.cpp @@ -25,7 +25,6 @@ #include "processors/ListenHTTP.h" #include "processors/LogAttribute.h" #include "TestBase.h" -#include "Catch.h" #include "core/logging/Logger.h" #include "core/ProcessGroup.h" #include "FlowController.h" diff --git a/extensions/http-curl/tests/SiteToSiteRestTest.cpp b/extensions/http-curl/tests/SiteToSiteRestTest.cpp index 51c2ca7d44..697c337248 100644 --- a/extensions/http-curl/tests/SiteToSiteRestTest.cpp +++ b/extensions/http-curl/tests/SiteToSiteRestTest.cpp @@ -24,7 +24,6 @@ #include #include "InvokeHTTP.h" #include "TestBase.h" -#include "Catch.h" #include "core/logging/Logger.h" #include "FlowController.h" #include "CivetServer.h" diff --git a/extensions/http-curl/tests/TimeoutHTTPSiteToSiteTests.cpp b/extensions/http-curl/tests/TimeoutHTTPSiteToSiteTests.cpp index 40bbb48939..c56b434fbe 100644 --- a/extensions/http-curl/tests/TimeoutHTTPSiteToSiteTests.cpp +++ b/extensions/http-curl/tests/TimeoutHTTPSiteToSiteTests.cpp @@ -28,7 +28,6 @@ #include "sitetosite/HTTPProtocol.h" #include "InvokeHTTP.h" #include "TestBase.h" -#include "Catch.h" #include "FlowController.h" #include "io/StreamFactory.h" #include "RemoteProcessorGroupPort.h" diff --git a/extensions/http-curl/tests/VerifyInvokeHTTP.h b/extensions/http-curl/tests/VerifyInvokeHTTP.h index 1d768f2765..03cd8779a5 100644 --- a/extensions/http-curl/tests/VerifyInvokeHTTP.h +++ b/extensions/http-curl/tests/VerifyInvokeHTTP.h @@ -25,7 +25,6 @@ #include #include "TestBase.h" -#include "Catch.h" #include "HTTPClient.h" #include "InvokeHTTP.h" #include "processors/LogAttribute.h" diff --git a/extensions/http-curl/tests/AlertTests.cpp b/extensions/http-curl/tests/unit/AlertTests.cpp similarity index 97% rename from extensions/http-curl/tests/AlertTests.cpp rename to extensions/http-curl/tests/unit/AlertTests.cpp index 2e6df680a8..72fcbeca28 100644 --- a/extensions/http-curl/tests/AlertTests.cpp +++ b/extensions/http-curl/tests/unit/AlertTests.cpp @@ -17,13 +17,11 @@ */ #undef NDEBUG -#define CATCH_CONFIG_MAIN #include "TestBase.h" -#include "Catch.h" -#include "ServerAwareHandler.h" +#include "tests/ServerAwareHandler.h" #include "CivetServer.h" -#include "TestServer.h" -#include "HTTPIntegrationBase.h" +#include "tests/TestServer.h" +#include "tests/HTTPIntegrationBase.h" #include "rapidjson/document.h" #include "EmptyFlow.h" #include "Utils.h" diff --git a/extensions/kubernetes/tests/CMakeLists.txt b/extensions/kubernetes/tests/CMakeLists.txt index 7052a514e5..a3efee665e 100644 --- a/extensions/kubernetes/tests/CMakeLists.txt +++ b/extensions/kubernetes/tests/CMakeLists.txt @@ -26,7 +26,7 @@ FOREACH(TEST_FILE ${KUBERNETES_UNIT_TESTS}) target_include_directories(${TEST_TARGET} PRIVATE BEFORE "${CMAKE_SOURCE_DIR}/libminifi/test") target_include_directories(${TEST_TARGET} PRIVATE BEFORE "${CMAKE_SOURCE_DIR}/extensions/kubernetes") target_link_libraries(${TEST_TARGET} minifi-kubernetes-extensions) - target_link_libraries(${TEST_TARGET} ${CATCH_MAIN_LIB}) + target_link_libraries(${TEST_TARGET} Catch2WithMain) createTests("${TEST_TARGET}") add_test(NAME ${TEST_TARGET} COMMAND "${TEST_TARGET}" WORKING_DIRECTORY "${TEST_DIR}") MATH(EXPR KUBERNETES_UNIT_TEST_COUNT "${KUBERNETES_UNIT_TEST_COUNT}+1") diff --git a/extensions/librdkafka/tests/CMakeLists.txt b/extensions/librdkafka/tests/CMakeLists.txt index 904bb50c0a..7e101ee5dd 100644 --- a/extensions/librdkafka/tests/CMakeLists.txt +++ b/extensions/librdkafka/tests/CMakeLists.txt @@ -26,7 +26,7 @@ FOREACH(testfile ${KAFKA_INTEGRATION_TESTS}) target_include_directories(${testfilename} BEFORE PRIVATE "${CMAKE_SOURCE_DIR}/extensions/librdkafka") target_include_directories(${testfilename} BEFORE PRIVATE "${CMAKE_SOURCE_DIR}/libminifi/test") createTests("${testfilename}") - target_link_libraries(${testfilename} ${CATCH_MAIN_LIB}) + target_link_libraries(${testfilename} Catch2WithMain) target_link_libraries(${testfilename} minifi-rdkafka-extensions) target_link_libraries(${testfilename} minifi-standard-processors) MATH(EXPR EXTENSIONS_TEST_COUNT "${EXTENSIONS_TEST_COUNT}+1") diff --git a/extensions/lua/tests/CMakeLists.txt b/extensions/lua/tests/CMakeLists.txt index daa1c951be..ce0576b6a1 100644 --- a/extensions/lua/tests/CMakeLists.txt +++ b/extensions/lua/tests/CMakeLists.txt @@ -28,7 +28,7 @@ FOREACH(testfile ${EXECUTESCRIPT_LUA_TESTS}) target_include_directories(${testfilename} PRIVATE BEFORE "${CMAKE_SOURCE_DIR}/libminifi/test/") target_include_directories(${testfilename} SYSTEM PRIVATE BEFORE "${SOL2_INCLUDE_DIR}") target_link_libraries(${testfilename} minifi-lua-script-extension minifi-script-extension) - target_link_libraries(${testfilename} ${CATCH_MAIN_LIB}) + target_link_libraries(${testfilename} Catch2WithMain) createTests("${testfilename}") MATH(EXPR EXTENSIONS_TEST_COUNT "${EXTENSIONS_TEST_COUNT}+1") add_test(NAME "${testfilename}" COMMAND "${testfilename}" WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}) diff --git a/extensions/mqtt/tests/CMakeLists.txt b/extensions/mqtt/tests/CMakeLists.txt index 081867aeae..ac94e7026c 100644 --- a/extensions/mqtt/tests/CMakeLists.txt +++ b/extensions/mqtt/tests/CMakeLists.txt @@ -25,7 +25,7 @@ FOREACH(testfile ${MQTT_TESTS}) target_include_directories(${testfilename} PRIVATE BEFORE "${CMAKE_CURRENT_SOURCE_DIR}/../../extensions/standard-processors") target_include_directories(${testfilename} PRIVATE BEFORE "${CMAKE_CURRENT_SOURCE_DIR}/../../../libminifi/test/") createTests("${testfilename}") - target_link_libraries(${testfilename} ${CATCH_MAIN_LIB}) + target_link_libraries(${testfilename} Catch2WithMain) target_link_libraries(${testfilename} minifi-mqtt-extensions) target_link_libraries(${testfilename} minifi-standard-processors) add_test(NAME "${testfilename}" COMMAND "${testfilename}" WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}) diff --git a/extensions/mqtt/tests/ConsumeMQTTTests.cpp b/extensions/mqtt/tests/ConsumeMQTTTests.cpp index 70977026e8..a8f67fffb0 100644 --- a/extensions/mqtt/tests/ConsumeMQTTTests.cpp +++ b/extensions/mqtt/tests/ConsumeMQTTTests.cpp @@ -17,6 +17,7 @@ */ #include "Catch.h" +#include "catch2/matchers/catch_matchers_string.hpp" #include "TestBase.h" #include "../processors/ConsumeMQTT.h" @@ -42,12 +43,12 @@ using namespace std::literals::chrono_literals; TEST_CASE_METHOD(Fixture, "ConsumeMQTTTest_EmptyTopic", "[consumeMQTTTest]") { consumeMqttProcessor_->setProperty(minifi::processors::AbstractMQTTProcessor::BrokerURI, "127.0.0.1:1883"); - REQUIRE_THROWS_WITH(plan_->scheduleProcessor(consumeMqttProcessor_), Catch::EndsWith("Required property is empty: Topic")); + REQUIRE_THROWS_WITH(plan_->scheduleProcessor(consumeMqttProcessor_), Catch::Matchers::EndsWith("Required property is empty: Topic")); } TEST_CASE_METHOD(Fixture, "ConsumeMQTTTest_EmptyBrokerURI", "[consumeMQTTTest]") { consumeMqttProcessor_->setProperty(minifi::processors::ConsumeMQTT::Topic, "mytopic"); - REQUIRE_THROWS_WITH(plan_->scheduleProcessor(consumeMqttProcessor_), Catch::EndsWith("Required property is empty: Broker URI")); + REQUIRE_THROWS_WITH(plan_->scheduleProcessor(consumeMqttProcessor_), Catch::Matchers::EndsWith("Required property is empty: Broker URI")); } TEST_CASE_METHOD(Fixture, "ConsumeMQTTTest_DurableSessionWithoutID", "[consumeMQTTTest]") { @@ -57,7 +58,7 @@ TEST_CASE_METHOD(Fixture, "ConsumeMQTTTest_DurableSessionWithoutID", "[consumeMQ consumeMqttProcessor_->setProperty(minifi::processors::ConsumeMQTT::CleanSession, "false"); REQUIRE_THROWS_WITH(plan_->scheduleProcessor(consumeMqttProcessor_), - Catch::EndsWith("Processor must have a Client ID for durable (non-clean) sessions")); + Catch::Matchers::EndsWith("Processor must have a Client ID for durable (non-clean) sessions")); } TEST_CASE_METHOD(Fixture, "ConsumeMQTTTest_DurableSessionWithoutID_V_5", "[consumeMQTTTest]") { @@ -68,7 +69,7 @@ TEST_CASE_METHOD(Fixture, "ConsumeMQTTTest_DurableSessionWithoutID_V_5", "[consu consumeMqttProcessor_->setProperty(minifi::processors::ConsumeMQTT::SessionExpiryInterval, "1 h"); REQUIRE_THROWS_WITH(plan_->scheduleProcessor(consumeMqttProcessor_), - Catch::EndsWith("Processor must have a Client ID for durable (Session Expiry Interval > 0) sessions")); + Catch::Matchers::EndsWith("Processor must have a Client ID for durable (Session Expiry Interval > 0) sessions")); } TEST_CASE_METHOD(Fixture, "ConsumeMQTTTest_DurableSessionWithID", "[consumeMQTTTest]") { @@ -127,7 +128,7 @@ TEST_CASE_METHOD(Fixture, "ConsumeMQTTTest_EmptyClientID_V_3_1_0", "[consumeMQTT consumeMqttProcessor_->setProperty(minifi::processors::ConsumeMQTT::Topic, "mytopic"); consumeMqttProcessor_->setProperty(minifi::processors::AbstractMQTTProcessor::BrokerURI, "127.0.0.1:1883"); consumeMqttProcessor_->setProperty(minifi::processors::AbstractMQTTProcessor::MqttVersion, toString(minifi::processors::mqtt::MqttVersions::V_3_1_0)); - REQUIRE_THROWS_WITH(plan_->scheduleProcessor(consumeMqttProcessor_), Catch::EndsWith("MQTT 3.1.0 specification does not support empty client IDs")); + REQUIRE_THROWS_WITH(plan_->scheduleProcessor(consumeMqttProcessor_), Catch::Matchers::EndsWith("MQTT 3.1.0 specification does not support empty client IDs")); } TEST_CASE_METHOD(Fixture, "ConsumeMQTTTest_CleanStart_V_3", "[consumeMQTTTest]") { diff --git a/extensions/mqtt/tests/PublishMQTTTests.cpp b/extensions/mqtt/tests/PublishMQTTTests.cpp index 3bf78d5b23..57be7beac6 100644 --- a/extensions/mqtt/tests/PublishMQTTTests.cpp +++ b/extensions/mqtt/tests/PublishMQTTTests.cpp @@ -19,6 +19,7 @@ #include "range/v3/algorithm/find_if.hpp" #include "Catch.h" +#include "catch2/matchers/catch_matchers_string.hpp" #include "TestBase.h" #include "../processors/PublishMQTT.h" @@ -44,19 +45,19 @@ struct Fixture { TEST_CASE_METHOD(Fixture, "PublishMQTTTest_EmptyTopic", "[publishMQTTTest]") { publishMqttProcessor_->setProperty(minifi::processors::AbstractMQTTProcessor::BrokerURI, "127.0.0.1:1883"); - REQUIRE_THROWS_WITH(plan_->scheduleProcessor(publishMqttProcessor_), Catch::EndsWith("Required property is empty: Topic")); + REQUIRE_THROWS_WITH(plan_->scheduleProcessor(publishMqttProcessor_), Catch::Matchers::EndsWith("Required property is empty: Topic")); } TEST_CASE_METHOD(Fixture, "PublishMQTTTest_EmptyBrokerURI", "[publishMQTTTest]") { publishMqttProcessor_->setProperty(minifi::processors::PublishMQTT::Topic, "mytopic"); - REQUIRE_THROWS_WITH(plan_->scheduleProcessor(publishMqttProcessor_), Catch::EndsWith("Required property is empty: Broker URI")); + REQUIRE_THROWS_WITH(plan_->scheduleProcessor(publishMqttProcessor_), Catch::Matchers::EndsWith("Required property is empty: Broker URI")); } TEST_CASE_METHOD(Fixture, "PublishMQTTTest_EmptyClientID_V_3_1_0", "[publishMQTTTest]") { publishMqttProcessor_->setProperty(minifi::processors::PublishMQTT::Topic, "mytopic"); publishMqttProcessor_->setProperty(minifi::processors::AbstractMQTTProcessor::BrokerURI, "127.0.0.1:1883"); publishMqttProcessor_->setProperty(minifi::processors::AbstractMQTTProcessor::MqttVersion, toString(minifi::processors::mqtt::MqttVersions::V_3_1_0)); - REQUIRE_THROWS_WITH(plan_->scheduleProcessor(publishMqttProcessor_), Catch::EndsWith("MQTT 3.1.0 specification does not support empty client IDs")); + REQUIRE_THROWS_WITH(plan_->scheduleProcessor(publishMqttProcessor_), Catch::Matchers::EndsWith("MQTT 3.1.0 specification does not support empty client IDs")); } TEST_CASE_METHOD(Fixture, "PublishMQTTTest_EmptyClientID_V_3", "[publishMQTTTest]") { diff --git a/extensions/opencv/tests/CMakeLists.txt b/extensions/opencv/tests/CMakeLists.txt index 68622cf7b0..8aa55b39c4 100644 --- a/extensions/opencv/tests/CMakeLists.txt +++ b/extensions/opencv/tests/CMakeLists.txt @@ -31,6 +31,6 @@ FOREACH(testfile ${OPENCV_TESTS}) createTests("${testfilename}") MATH(EXPR OPENCV_TEST_COUNT "${OPENCV_TEST_COUNT}+1") add_test(NAME "${testfilename}" COMMAND "${testfilename}" WORKING_DIRECTORY ${TEST_DIR}) - target_link_libraries(${testfilename} ${CATCH_MAIN_LIB}) + target_link_libraries(${testfilename} Catch2WithMain) ENDFOREACH() message("-- Finished building ${OPENCV_TEST_COUNT} OpenCV related test file(s)...") diff --git a/extensions/pdh/tests/CMakeLists.txt b/extensions/pdh/tests/CMakeLists.txt index 3ffd79ca4f..0df960d743 100644 --- a/extensions/pdh/tests/CMakeLists.txt +++ b/extensions/pdh/tests/CMakeLists.txt @@ -27,7 +27,7 @@ FOREACH(testfile ${PDH_TESTS}) target_include_directories(${testfilename} PRIVATE BEFORE "${CMAKE_SOURCE_DIR}/extensions/pdh") target_include_directories(${testfilename} PRIVATE BEFORE "${CMAKE_SOURCE_DIR}/libminifi/test/") createTests("${testfilename}") - target_link_libraries(${testfilename} ${CATCH_MAIN_LIB}) + target_link_libraries(${testfilename} Catch2WithMain) target_link_libraries(${testfilename} minifi-pdh) target_link_libraries(${testfilename} minifi-standard-processors) MATH(EXPR PDH_TEST_COUNT "${PDH_TEST_COUNT}+1") diff --git a/extensions/procfs/tests/CMakeLists.txt b/extensions/procfs/tests/CMakeLists.txt index 3c5ccccbe8..868fe62bbb 100644 --- a/extensions/procfs/tests/CMakeLists.txt +++ b/extensions/procfs/tests/CMakeLists.txt @@ -28,7 +28,7 @@ FOREACH(testfile ${PROCFS_TESTS}) target_include_directories(${testfilename} PRIVATE BEFORE "${CMAKE_SOURCE_DIR}/libminifi/test/") target_include_directories(${testfilename} PRIVATE BEFORE "${CMAKE_SOURCE_DIR}/extensions/standard-processors") createTests("${testfilename}") - target_link_libraries(${testfilename} ${CATCH_MAIN_LIB}) + target_link_libraries(${testfilename} Catch2WithMain) target_link_libraries(${testfilename} minifi-procfs) target_link_libraries(${testfilename} minifi-standard-processors) MATH(EXPR PROCFS_TEST_COUNT "${PROCFS_TEST_COUNT}+1") diff --git a/extensions/procfs/tests/CPUStatTests.cpp b/extensions/procfs/tests/CPUStatTests.cpp index 11d8666052..27507b25b9 100644 --- a/extensions/procfs/tests/CPUStatTests.cpp +++ b/extensions/procfs/tests/CPUStatTests.cpp @@ -16,6 +16,7 @@ */ #include "Catch.h" +#include "catch2/catch_approx.hpp" #include "ProcFs.h" #include "MockProcFs.h" @@ -35,7 +36,7 @@ void cpu_stat_period_total_should_be_one(const CpuStatData& cpu_stat) { percentage += cpu_stat.getSteal() / cpu_stat.getTotal(); percentage += cpu_stat.getGuest() / cpu_stat.getTotal(); percentage += cpu_stat.getGuestNice() / cpu_stat.getTotal(); - REQUIRE(percentage == Approx(1.0)); + REQUIRE(percentage == Catch::Approx(1.0)); } TEST_CASE("ProcFSTest stat test with mock", "[procfsstatmockabsolutetest]") { diff --git a/extensions/prometheus/tests/CMakeLists.txt b/extensions/prometheus/tests/CMakeLists.txt index c84dc55a8a..3d5c2f53c0 100644 --- a/extensions/prometheus/tests/CMakeLists.txt +++ b/extensions/prometheus/tests/CMakeLists.txt @@ -26,7 +26,7 @@ FOREACH(testfile ${PROMETHEUS_TESTS}) target_include_directories(${testfilename} PRIVATE BEFORE "${CMAKE_SOURCE_DIR}/extensions/prometheus") target_include_directories(${testfilename} PRIVATE BEFORE "${CMAKE_SOURCE_DIR}/libminifi/test/") createTests("${testfilename}") - target_link_libraries(${testfilename} ${CATCH_MAIN_LIB}) + target_link_libraries(${testfilename} Catch2WithMain) target_link_libraries(${testfilename} minifi-prometheus) MATH(EXPR PROMETHEUS_TEST_COUNT "${PROMETHEUS_TEST_COUNT}+1") add_test(NAME "${testfilename}" COMMAND "${testfilename}") diff --git a/extensions/python/tests/CMakeLists.txt b/extensions/python/tests/CMakeLists.txt index afa6115d1a..3b6699b698 100644 --- a/extensions/python/tests/CMakeLists.txt +++ b/extensions/python/tests/CMakeLists.txt @@ -29,7 +29,7 @@ FOREACH(testfile ${EXECUTESCRIPT_PYTHON_TESTS}) add_executable("${testfilename}" "${testfile}") target_include_directories(${testfilename} PRIVATE BEFORE "${CMAKE_SOURCE_DIR}/extensions/python") target_include_directories(${testfilename} PRIVATE BEFORE "${CMAKE_SOURCE_DIR}/libminifi/test/") - target_link_libraries(${testfilename} minifi-python-script-extension minifi-script-extension ${CATCH_MAIN_LIB} Python::Python) + target_link_libraries(${testfilename} minifi-python-script-extension minifi-script-extension Catch2WithMain Python::Python) createTests("${testfilename}") MATH(EXPR EXTENSIONS_TEST_COUNT "${EXTENSIONS_TEST_COUNT}+1") add_test(NAME "${testfilename}" COMMAND "${testfilename}" WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}) @@ -57,7 +57,7 @@ FOREACH(testfile ${EXECUTEPYTHONPROCESSOR_UNIT_TESTS}) target_link_libraries(${testfilename} minifi-python-script-extension) target_link_libraries(${testfilename} minifi-standard-processors) - target_link_libraries(${testfilename} ${CATCH_MAIN_LIB}) + target_link_libraries(${testfilename} Catch2WithMain) createTests("${testfilename}") MATH(EXPR EXTENSIONS_TEST_COUNT "${EXTENSIONS_TEST_COUNT}+1") diff --git a/extensions/script/tests/CMakeLists.txt b/extensions/script/tests/CMakeLists.txt index 7a935ed45e..52ac8c6cca 100644 --- a/extensions/script/tests/CMakeLists.txt +++ b/extensions/script/tests/CMakeLists.txt @@ -27,7 +27,7 @@ FOREACH(testfile ${EXECUTE_SCRIPT_TESTS}) target_include_directories(${testfilename} PRIVATE BEFORE "${CMAKE_SOURCE_DIR}/libminifi/test/") createTests("${testfilename}") - target_link_libraries(${testfilename} ${CATCH_MAIN_LIB}) + target_link_libraries(${testfilename} Catch2WithMain) target_link_libraries(${testfilename} minifi-script-extension) MATH(EXPR EXECUTE_SCRIPT_TEST_COUNT "${EXECUTE_SCRIPT_TEST_COUNT}+1") add_test(NAME "${testfilename}" COMMAND "${testfilename}" WORKING_DIRECTORY ${TEST_DIR}) diff --git a/extensions/sftp/tests/CMakeLists.txt b/extensions/sftp/tests/CMakeLists.txt index f0f3f435c4..5b1367cb18 100644 --- a/extensions/sftp/tests/CMakeLists.txt +++ b/extensions/sftp/tests/CMakeLists.txt @@ -42,7 +42,7 @@ if (NOT SKIP_TESTS AND Java_FOUND AND Maven_FOUND AND NOT DISABLE_EXPRESSION_LAN target_include_directories(${testfilename} BEFORE PRIVATE ./tools) createTests("${testfilename}") - target_link_libraries(${testfilename} ${CATCH_MAIN_LIB} core-minifi sftp-test-tools) + target_link_libraries(${testfilename} Catch2WithMain core-minifi sftp-test-tools) target_link_libraries(${testfilename} minifi-sftp) target_link_libraries(${testfilename} minifi-expression-language-extensions) target_link_libraries(${testfilename} minifi-standard-processors) diff --git a/extensions/splunk/tests/CMakeLists.txt b/extensions/splunk/tests/CMakeLists.txt index 1ca2257b37..1a0604ee1d 100644 --- a/extensions/splunk/tests/CMakeLists.txt +++ b/extensions/splunk/tests/CMakeLists.txt @@ -30,7 +30,7 @@ FOREACH(testfile ${SPLUNK_TESTS}) target_include_directories(${testfilename} BEFORE PRIVATE "${CMAKE_SOURCE_DIR}/extensions/http-curl/") createTests("${testfilename}") - target_link_libraries(${testfilename} ${CATCH_MAIN_LIB}) + target_link_libraries(${testfilename} Catch2WithMain) target_link_libraries(${testfilename} minifi-splunk) target_link_libraries(${testfilename} minifi-civet-extensions) target_link_libraries(${testfilename} minifi-http-curl) diff --git a/extensions/standard-processors/tests/CMakeLists.txt b/extensions/standard-processors/tests/CMakeLists.txt index 353b7bbca0..3b1271be39 100644 --- a/extensions/standard-processors/tests/CMakeLists.txt +++ b/extensions/standard-processors/tests/CMakeLists.txt @@ -40,7 +40,7 @@ FOREACH(testfile ${PROCESSOR_UNIT_TESTS}) target_include_directories(${testfilename} BEFORE PRIVATE "../processors") target_include_directories(${testfilename} BEFORE PRIVATE ./include) createTests("${testfilename}") - target_link_libraries(${testfilename} ${CATCH_MAIN_LIB}) + target_link_libraries(${testfilename} Catch2WithMain) target_link_libraries(${testfilename} minifi-expression-language-extensions) target_link_libraries(${testfilename} minifi-standard-processors) target_link_libraries(${testfilename} minifi-civet-extensions) diff --git a/extensions/standard-processors/tests/integration/ProcessGroupTest.cpp b/extensions/standard-processors/tests/integration/ProcessGroupTest.cpp index 5e83586860..e6e71dc149 100644 --- a/extensions/standard-processors/tests/integration/ProcessGroupTest.cpp +++ b/extensions/standard-processors/tests/integration/ProcessGroupTest.cpp @@ -23,7 +23,6 @@ #include "core/logging/Logger.h" #include "FlowController.h" #include "TestBase.h" -#include "Catch.h" #include "processors/GenerateFlowFile.h" #include "processors/LogAttribute.h" #include "processors/UpdateAttribute.h" diff --git a/extensions/standard-processors/tests/integration/SecureSocketGetTCPTest.cpp b/extensions/standard-processors/tests/integration/SecureSocketGetTCPTest.cpp index db443c7f1e..f14c5481d4 100644 --- a/extensions/standard-processors/tests/integration/SecureSocketGetTCPTest.cpp +++ b/extensions/standard-processors/tests/integration/SecureSocketGetTCPTest.cpp @@ -32,7 +32,6 @@ #include "BaseHTTPClient.h" #include "processors/GetTCP.h" #include "TestBase.h" -#include "Catch.h" #include "utils/StringUtils.h" #include "core/Core.h" #include "core/logging/Logger.h" diff --git a/extensions/standard-processors/tests/unit/ExecuteProcessTests.cpp b/extensions/standard-processors/tests/unit/ExecuteProcessTests.cpp index e3c7e310f6..6f25c46f3d 100644 --- a/extensions/standard-processors/tests/unit/ExecuteProcessTests.cpp +++ b/extensions/standard-processors/tests/unit/ExecuteProcessTests.cpp @@ -170,6 +170,9 @@ TEST_CASE_METHOD(ExecuteProcessTestsFixture, "ExecuteProcess buffer long outputs CHECK(success_flow_files[0]->getAttribute("command") == command); CHECK(success_flow_files[0]->getAttribute("command.arguments") == arguments); } - +#else +TEST_CASE("ExecuteProcessTests") { + SUCCEED("To avoid empty test executable"); +} #endif } // namespace org::apache::nifi::minifi::test diff --git a/extensions/standard-processors/tests/unit/ListenSyslogTests.cpp b/extensions/standard-processors/tests/unit/ListenSyslogTests.cpp index 73ed6dd3a0..5a6396dca1 100644 --- a/extensions/standard-processors/tests/unit/ListenSyslogTests.cpp +++ b/extensions/standard-processors/tests/unit/ListenSyslogTests.cpp @@ -265,14 +265,14 @@ TEST_CASE("ListenSyslog without parsing test", "[ListenSyslog]") { port = utils::scheduleProcessorOnRandomPort(controller.plan, listen_syslog); asio::ip::udp::endpoint endpoint; - SECTION("sending through IPv4", "[IPv4]") { - endpoint = asio::ip::udp::endpoint(asio::ip::address_v4::loopback(), port); - } SECTION("sending through IPv6", "[IPv6]") { if (utils::isIPv6Disabled()) - return; + SKIP("IPv6 is disabled"); endpoint = asio::ip::udp::endpoint(asio::ip::address_v6::loopback(), port); } + SECTION("sending through IPv4", "[IPv4]") { + endpoint = asio::ip::udp::endpoint(asio::ip::address_v4::loopback(), port); + } protocol = "UDP"; CHECK_THAT(utils::sendUdpDatagram(rfc5424_logger_example_1, endpoint), MatchesSuccess()); CHECK_THAT(utils::sendUdpDatagram(invalid_syslog, endpoint), MatchesSuccess()); @@ -285,14 +285,14 @@ TEST_CASE("ListenSyslog without parsing test", "[ListenSyslog]") { port = utils::scheduleProcessorOnRandomPort(controller.plan, listen_syslog); asio::ip::tcp::endpoint endpoint; - SECTION("sending through IPv4", "[IPv4]") { - endpoint = asio::ip::tcp::endpoint(asio::ip::address_v4::loopback(), port); - } SECTION("sending through IPv6", "[IPv6]") { if (utils::isIPv6Disabled()) - return; + SKIP("IPv6 is disabled"); endpoint = asio::ip::tcp::endpoint(asio::ip::address_v6::loopback(), port); } + SECTION("sending through IPv4", "[IPv4]") { + endpoint = asio::ip::tcp::endpoint(asio::ip::address_v4::loopback(), port); + } CHECK_THAT(utils::sendMessagesViaTCP({rfc5424_logger_example_1}, endpoint), MatchesSuccess()); CHECK_THAT(utils::sendMessagesViaTCP({invalid_syslog}, endpoint), MatchesSuccess()); } @@ -322,14 +322,14 @@ TEST_CASE("ListenSyslog with parsing test", "[ListenSyslog][NetworkListenerProce port = utils::scheduleProcessorOnRandomPort(controller.plan, listen_syslog); asio::ip::udp::endpoint endpoint; - SECTION("sending through IPv4", "[IPv4]") { - endpoint = asio::ip::udp::endpoint(asio::ip::address_v4::loopback(), port); - } SECTION("sending through IPv6", "[IPv6]") { if (utils::isIPv6Disabled()) - return; + SKIP("IPv6 is disabled"); endpoint = asio::ip::udp::endpoint(asio::ip::address_v6::loopback(), port); } + SECTION("sending through IPv4", "[IPv4]") { + endpoint = asio::ip::udp::endpoint(asio::ip::address_v4::loopback(), port); + } CHECK_THAT(utils::sendUdpDatagram(rfc5424_doc_example_1.unparsed_, endpoint), MatchesSuccess()); CHECK_THAT(utils::sendUdpDatagram(rfc5424_doc_example_2.unparsed_, endpoint), MatchesSuccess()); @@ -352,14 +352,14 @@ TEST_CASE("ListenSyslog with parsing test", "[ListenSyslog][NetworkListenerProce port = utils::scheduleProcessorOnRandomPort(controller.plan, listen_syslog); asio::ip::tcp::endpoint endpoint; - SECTION("sending through IPv4", "[IPv4]") { - endpoint = asio::ip::tcp::endpoint(asio::ip::address_v4::loopback(), port); - } SECTION("sending through IPv6", "[IPv6]") { if (utils::isIPv6Disabled()) - return; + SKIP("IPv6 is disabled"); endpoint = asio::ip::tcp::endpoint(asio::ip::address_v6::loopback(), port); } + SECTION("sending through IPv4", "[IPv4]") { + endpoint = asio::ip::tcp::endpoint(asio::ip::address_v4::loopback(), port); + } CHECK_THAT(utils::sendMessagesViaTCP({rfc5424_doc_example_1.unparsed_, rfc5424_doc_example_2.unparsed_, @@ -450,14 +450,14 @@ TEST_CASE("ListenSyslog max queue and max batch size test", "[ListenSyslog][Netw port = utils::scheduleProcessorOnRandomPort(controller.plan, listen_syslog); asio::ip::udp::endpoint endpoint; - SECTION("sending through IPv4", "[IPv4]") { - endpoint = asio::ip::udp::endpoint(asio::ip::address_v4::loopback(), port); - } SECTION("sending through IPv6", "[IPv6]") { if (utils::isIPv6Disabled()) - return; + SKIP("IPv6 is disabled"); endpoint = asio::ip::udp::endpoint(asio::ip::address_v6::loopback(), port); } + SECTION("sending through IPv4", "[IPv4]") { + endpoint = asio::ip::udp::endpoint(asio::ip::address_v4::loopback(), port); + } for (auto i = 0; i < 100; ++i) { CHECK_THAT(utils::sendUdpDatagram(rfc5424_doc_example_1.unparsed_, endpoint), MatchesSuccess()); } @@ -469,14 +469,16 @@ TEST_CASE("ListenSyslog max queue and max batch size test", "[ListenSyslog][Netw port = utils::scheduleProcessorOnRandomPort(controller.plan, listen_syslog); asio::ip::tcp::endpoint endpoint; - SECTION("sending through IPv4", "[IPv4]") { - endpoint = asio::ip::tcp::endpoint(asio::ip::address_v4::loopback(), port); - } SECTION("sending through IPv6", "[IPv6]") { if (utils::isIPv6Disabled()) - return; + SKIP("IPv6 is disabled"); endpoint = asio::ip::tcp::endpoint(asio::ip::address_v6::loopback(), port); } + + SECTION("sending through IPv4", "[IPv4]") { + endpoint = asio::ip::tcp::endpoint(asio::ip::address_v4::loopback(), port); + } + for (auto i = 0; i < 100; ++i) { CHECK_THAT(utils::sendMessagesViaTCP({rfc5424_doc_example_1.unparsed_}, endpoint), MatchesSuccess()); } @@ -510,14 +512,14 @@ TEST_CASE("Test ListenSyslog via TCP with SSL connection", "[ListenSyslog][Netwo auto port = utils::scheduleProcessorOnRandomPort(controller.plan, listen_syslog); asio::ip::tcp::endpoint endpoint; - SECTION("sending through IPv4", "[IPv4]") { - endpoint = asio::ip::tcp::endpoint(asio::ip::address_v4::loopback(), port); - } SECTION("sending through IPv6", "[IPv6]") { if (utils::isIPv6Disabled()) - return; + SKIP("IPv6 is disabled"); endpoint = asio::ip::tcp::endpoint(asio::ip::address_v6::loopback(), port); } + SECTION("sending through IPv4", "[IPv4]") { + endpoint = asio::ip::tcp::endpoint(asio::ip::address_v4::loopback(), port); + } CHECK_THAT(utils::sendMessagesViaSSL({rfc5424_logger_example_1}, endpoint, executable_dir / "resources" / "ca_A.crt"), MatchesSuccess()); CHECK_THAT(utils::sendMessagesViaSSL({invalid_syslog}, endpoint, executable_dir / "resources" / "ca_A.crt"), MatchesSuccess()); diff --git a/extensions/standard-processors/tests/unit/ListenTcpTests.cpp b/extensions/standard-processors/tests/unit/ListenTcpTests.cpp index 11eb1123c6..c75ef84cb4 100644 --- a/extensions/standard-processors/tests/unit/ListenTcpTests.cpp +++ b/extensions/standard-processors/tests/unit/ListenTcpTests.cpp @@ -43,14 +43,14 @@ TEST_CASE("ListenTCP test multiple messages", "[ListenTCP][NetworkListenerProces auto port = utils::scheduleProcessorOnRandomPort(controller.plan, listen_tcp); asio::ip::tcp::endpoint endpoint; - SECTION("sending through IPv4", "[IPv4]") { - endpoint = asio::ip::tcp::endpoint(asio::ip::address_v4::loopback(), port); - } SECTION("sending through IPv6", "[IPv6]") { if (utils::isIPv6Disabled()) - return; + SKIP("IPv6 is disabled"); endpoint = asio::ip::tcp::endpoint(asio::ip::address_v6::loopback(), port); } + SECTION("sending through IPv4", "[IPv4]") { + endpoint = asio::ip::tcp::endpoint(asio::ip::address_v4::loopback(), port); + } CHECK_THAT(utils::sendMessagesViaTCP({"test_message_1"}, endpoint), MatchesSuccess()); CHECK_THAT(utils::sendMessagesViaTCP({"another_message"}, endpoint), MatchesSuccess()); @@ -84,14 +84,14 @@ TEST_CASE("ListenTCP max queue and max batch size test", "[ListenTCP][NetworkLis auto port = utils::scheduleProcessorOnRandomPort(controller.plan, listen_tcp); asio::ip::tcp::endpoint endpoint; - SECTION("sending through IPv4", "[IPv4]") { - endpoint = asio::ip::tcp::endpoint(asio::ip::address_v4::loopback(), port); - } SECTION("sending through IPv6", "[IPv6]") { if (utils::isIPv6Disabled()) - return; + SKIP("IPv6 is disabled"); endpoint = asio::ip::tcp::endpoint(asio::ip::address_v6::loopback(), port); } + SECTION("sending through IPv4", "[IPv4]") { + endpoint = asio::ip::tcp::endpoint(asio::ip::address_v4::loopback(), port); + } LogTestController::getInstance().setWarn(); @@ -129,27 +129,27 @@ TEST_CASE("Test ListenTCP with SSL connection", "[ListenTCP][NetworkListenerProc SECTION("Client certificate not required, Client Auth set to NONE by default") { ssl_context_service->enable(); port = utils::scheduleProcessorOnRandomPort(controller.plan, listen_tcp); - SECTION("sending through IPv4", "[IPv4]") { - endpoint = asio::ip::tcp::endpoint(asio::ip::address_v4::loopback(), port); - } SECTION("sending through IPv6", "[IPv6]") { if (utils::isIPv6Disabled()) - return; + SKIP("IPv6 is disabled"); endpoint = asio::ip::tcp::endpoint(asio::ip::address_v6::loopback(), port); } + SECTION("sending through IPv4", "[IPv4]") { + endpoint = asio::ip::tcp::endpoint(asio::ip::address_v4::loopback(), port); + } } SECTION("Client certificate not required, but validated if provided") { REQUIRE(controller.plan->setProperty(listen_tcp, ListenTCP::ClientAuth, "WANT")); ssl_context_service->enable(); port = utils::scheduleProcessorOnRandomPort(controller.plan, listen_tcp); - SECTION("sending through IPv4", "[IPv4]") { - endpoint = asio::ip::tcp::endpoint(asio::ip::address_v4::loopback(), port); - } SECTION("sending through IPv6", "[IPv6]") { if (utils::isIPv6Disabled()) - return; + SKIP("IPv6 is disabled"); endpoint = asio::ip::tcp::endpoint(asio::ip::address_v6::loopback(), port); } + SECTION("sending through IPv4", "[IPv4]") { + endpoint = asio::ip::tcp::endpoint(asio::ip::address_v4::loopback(), port); + } } expected_successful_messages = {"test_message_1", "another_message"}; @@ -163,27 +163,27 @@ TEST_CASE("Test ListenTCP with SSL connection", "[ListenTCP][NetworkListenerProc REQUIRE(controller.plan->setProperty(listen_tcp, ListenTCP::ClientAuth, "REQUIRED")); ssl_context_service->enable(); port = utils::scheduleProcessorOnRandomPort(controller.plan, listen_tcp); - SECTION("sending through IPv4", "[IPv4]") { - endpoint = asio::ip::tcp::endpoint(asio::ip::address_v4::loopback(), port); - } SECTION("sending through IPv6", "[IPv6]") { if (utils::isIPv6Disabled()) - return; + SKIP("IPv6 is disabled"); endpoint = asio::ip::tcp::endpoint(asio::ip::address_v6::loopback(), port); } + SECTION("sending through IPv4", "[IPv4]") { + endpoint = asio::ip::tcp::endpoint(asio::ip::address_v4::loopback(), port); + } } SECTION("Client certificate not required but validated") { REQUIRE(controller.plan->setProperty(listen_tcp, ListenTCP::ClientAuth, "WANT")); ssl_context_service->enable(); port = utils::scheduleProcessorOnRandomPort(controller.plan, listen_tcp); - SECTION("sending through IPv4", "[IPv4]") { - endpoint = asio::ip::tcp::endpoint(asio::ip::address_v4::loopback(), port); - } SECTION("sending through IPv6", "[IPv6]") { if (utils::isIPv6Disabled()) - return; + SKIP("IPv6 is disabled"); endpoint = asio::ip::tcp::endpoint(asio::ip::address_v6::loopback(), port); } + SECTION("sending through IPv4", "[IPv4]") { + endpoint = asio::ip::tcp::endpoint(asio::ip::address_v4::loopback(), port); + } } minifi::utils::net::SslData ssl_data; @@ -202,14 +202,14 @@ TEST_CASE("Test ListenTCP with SSL connection", "[ListenTCP][NetworkListenerProc ssl_context_service->enable(); REQUIRE(controller.plan->setProperty(listen_tcp, ListenTCP::ClientAuth, "REQUIRED")); port = utils::scheduleProcessorOnRandomPort(controller.plan, listen_tcp); - SECTION("sending through IPv4", "[IPv4]") { - endpoint = asio::ip::tcp::endpoint(asio::ip::address_v4::loopback(), port); - } SECTION("sending through IPv6", "[IPv6]") { if (utils::isIPv6Disabled()) - return; + SKIP("IPv6 is disabled"); endpoint = asio::ip::tcp::endpoint(asio::ip::address_v6::loopback(), port); } + SECTION("sending through IPv4", "[IPv4]") { + endpoint = asio::ip::tcp::endpoint(asio::ip::address_v4::loopback(), port); + } CHECK_THAT(utils::sendMessagesViaSSL({"test_message_1"}, endpoint, executable_dir / "resources" / "ca_A.crt"), MatchesError()); } diff --git a/extensions/standard-processors/tests/unit/ListenUDPTests.cpp b/extensions/standard-processors/tests/unit/ListenUDPTests.cpp index ca1c0ec250..2005d26ff3 100644 --- a/extensions/standard-processors/tests/unit/ListenUDPTests.cpp +++ b/extensions/standard-processors/tests/unit/ListenUDPTests.cpp @@ -45,14 +45,14 @@ TEST_CASE("ListenUDP test multiple messages", "[ListenUDP][NetworkListenerProces auto port = utils::scheduleProcessorOnRandomPort(controller.plan, listen_udp); asio::ip::udp::endpoint endpoint; - SECTION("sending through IPv4", "[IPv4]") { - endpoint = asio::ip::udp::endpoint(asio::ip::address_v4::loopback(), port); - } SECTION("sending through IPv6", "[IPv6]") { if (utils::isIPv6Disabled()) - return; + SKIP("IPv6 is disabled"); endpoint = asio::ip::udp::endpoint(asio::ip::address_v6::loopback(), port); } + SECTION("sending through IPv4", "[IPv4]") { + endpoint = asio::ip::udp::endpoint(asio::ip::address_v4::loopback(), port); + } controller.plan->scheduleProcessor(listen_udp); CHECK_THAT(utils::sendUdpDatagram({"test_message_1"}, endpoint), MatchesSuccess()); @@ -88,14 +88,14 @@ TEST_CASE("ListenUDP max queue and max batch size test", "[ListenUDP][NetworkLis auto port = utils::scheduleProcessorOnRandomPort(controller.plan, listen_udp); asio::ip::udp::endpoint endpoint; - SECTION("sending through IPv4", "[IPv4]") { - endpoint = asio::ip::udp::endpoint(asio::ip::address_v4::loopback(), port); - } SECTION("sending through IPv6", "[IPv6]") { if (utils::isIPv6Disabled()) - return; + SKIP("IPv6 is disabled"); endpoint = asio::ip::udp::endpoint(asio::ip::address_v6::loopback(), port); } + SECTION("sending through IPv4", "[IPv4]") { + endpoint = asio::ip::udp::endpoint(asio::ip::address_v4::loopback(), port); + } LogTestController::getInstance().setWarn(); diff --git a/extensions/standard-processors/tests/unit/ProcessorTests.cpp b/extensions/standard-processors/tests/unit/ProcessorTests.cpp index b519df65be..9377a95681 100644 --- a/extensions/standard-processors/tests/unit/ProcessorTests.cpp +++ b/extensions/standard-processors/tests/unit/ProcessorTests.cpp @@ -32,6 +32,7 @@ #include "TestBase.h" #include "Catch.h" +#include "catch2/matchers/catch_matchers_string.hpp" #include "LogAttribute.h" #include "GetFile.h" #include "unit/ProvenanceTestHelper.h" @@ -182,8 +183,6 @@ TEST_CASE("Test GetFile Ignore", "[getfileCreate3]") { processor->onSchedule(context, factory); - int prev = 0; - auto session = std::make_shared(context); REQUIRE(processor->getName() == "getfileCreate2"); @@ -228,7 +227,6 @@ TEST_CASE("Test GetFile Ignore", "[getfileCreate3]") { std::shared_ptr ffr = session->get(); REQUIRE(repo->getRepoMap().empty()); - prev++; } TEST_CASE("TestConnectionFull", "[ConnectionFull]") { @@ -750,7 +748,7 @@ TEST_CASE("InputRequirementTestForbidden", "[InputRequirement]") { plan->addProcessor("GenerateFlowFile", "generateFlowFile"); plan->addProcessor("GenerateFlowFile", "generateFlowFile2", core::Relationship("success", "description"), true); - REQUIRE_THROWS_WITH(plan->validateAnnotations(), Catch::EndsWith("INPUT_FORBIDDEN was specified for the processor, but there are incoming connections")); + REQUIRE_THROWS_WITH(plan->validateAnnotations(), Catch::Matchers::EndsWith("INPUT_FORBIDDEN was specified for the processor, but there are incoming connections")); testController.runSession(plan); } @@ -762,7 +760,7 @@ TEST_CASE("InputRequirementTestRequired", "[InputRequirement]") { plan->addProcessor("LogAttribute", "logAttribute"); plan->addProcessor("LogAttribute", "logAttribute2", core::Relationship("success", "description"), true); - REQUIRE_THROWS_WITH(plan->validateAnnotations(), Catch::EndsWith("INPUT_REQUIRED was specified for the processor, but no incoming connections were found")); + REQUIRE_THROWS_WITH(plan->validateAnnotations(), Catch::Matchers::EndsWith("INPUT_REQUIRED was specified for the processor, but no incoming connections were found")); testController.runSession(plan); } diff --git a/extensions/systemd/tests/CMakeLists.txt b/extensions/systemd/tests/CMakeLists.txt index 5ccc870d3e..3e893c8dbf 100644 --- a/extensions/systemd/tests/CMakeLists.txt +++ b/extensions/systemd/tests/CMakeLists.txt @@ -27,7 +27,7 @@ function(add_systemd_test testfile) target_link_libraries(${TEST_TARGET} minifi-standard-processors) createTests("${TEST_TARGET}") add_test(NAME ${TEST_TARGET} COMMAND "${TEST_TARGET}" WORKING_DIRECTORY "${TEST_DIR}") - target_link_libraries(${TEST_TARGET} ${CATCH_MAIN_LIB}) + target_link_libraries(${TEST_TARGET} Catch2WithMain) endfunction() add_systemd_test("ConsumeJournaldTest.cpp") diff --git a/extensions/windows-event-log/tests/CMakeLists.txt b/extensions/windows-event-log/tests/CMakeLists.txt index a88a3c2126..eeacb89e15 100644 --- a/extensions/windows-event-log/tests/CMakeLists.txt +++ b/extensions/windows-event-log/tests/CMakeLists.txt @@ -37,7 +37,7 @@ FOREACH(testfile ${WEL_TESTS}) createTests("${testfilename}") target_link_libraries(${testfilename} minifi-wel) target_link_libraries(${testfilename} minifi-standard-processors) - target_link_libraries (${testfilename} ${LIBMINIFI} ${CATCH_MAIN_LIB}) + target_link_libraries (${testfilename} ${LIBMINIFI} Catch2WithMain) MATH(EXPR WEL_TEST_COUNT "${WEL_TEST_COUNT}+1") add_test(NAME "${testfilename}" COMMAND "${testfilename}" WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}) diff --git a/libminifi/test/Catch.h b/libminifi/test/Catch.h index 755496feb6..71794c3a3d 100644 --- a/libminifi/test/Catch.h +++ b/libminifi/test/Catch.h @@ -17,11 +17,12 @@ #pragma once -#define CATCH_CONFIG_FAST_COMPILE #include #include +#include #include "spdlog/spdlog.h" -#include "catch.hpp" +#include "catch2/catch_test_macros.hpp" +#include "catch2/matchers/catch_matchers.hpp" namespace Catch { template @@ -47,10 +48,17 @@ struct StringMaker { return fmt::format("std::error_code(category:{}, value:{}, message:{})", error_code.category().name(), error_code.value(), error_code.message()); } }; + +template <> +struct StringMaker { + static std::string convert(const std::chrono::file_clock::duration& duration) { + return fmt::format("{} {} s", duration.count(), Catch::ratio_string::symbol()); + } +}; } // namespace Catch namespace org::apache::nifi::minifi::test { -struct MatchesSuccess : Catch::MatcherBase { +struct MatchesSuccess : Catch::Matchers::MatcherBase { MatchesSuccess() = default; bool match(const std::error_code& err) const override { @@ -62,9 +70,9 @@ struct MatchesSuccess : Catch::MatcherBase { } }; -struct MatchesError : Catch::MatcherBase { +struct MatchesError : Catch::Matchers::MatcherBase { explicit MatchesError(std::optional expected_error = std::nullopt) - : Catch::MatcherBase(), + : Catch::Matchers::MatcherBase(), expected_error_(expected_error) { } diff --git a/libminifi/test/CatchMain.cpp b/libminifi/test/CatchMain.cpp deleted file mode 100644 index 18e5243e73..0000000000 --- a/libminifi/test/CatchMain.cpp +++ /dev/null @@ -1,20 +0,0 @@ -/** - * - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#define CATCH_CONFIG_MAIN -#include "Catch.h" diff --git a/libminifi/test/Utils.h b/libminifi/test/Utils.h index bde82555de..1777cc9af6 100644 --- a/libminifi/test/Utils.h +++ b/libminifi/test/Utils.h @@ -81,7 +81,7 @@ void verifyJSON(const std::string& actual_str, const std::string& expected_str, } template -class ExceptionSubStringMatcher : public Catch::MatcherBase { +class ExceptionSubStringMatcher : public Catch::Matchers::MatcherBase { public: explicit ExceptionSubStringMatcher(std::vector exception_substr) : possible_exception_substrs_(std::move(exception_substr)) {} diff --git a/libminifi/test/archive-tests/CMakeLists.txt b/libminifi/test/archive-tests/CMakeLists.txt index 88039891da..6c35ccc606 100644 --- a/libminifi/test/archive-tests/CMakeLists.txt +++ b/libminifi/test/archive-tests/CMakeLists.txt @@ -28,7 +28,7 @@ FOREACH(testfile ${ARCHIVE_INTEGRATION_TESTS}) target_link_libraries(${testfilename} minifi-archive-extensions) target_link_libraries(${testfilename} minifi-standard-processors) createTests("${testfilename}") - target_link_libraries(${testfilename} ${CATCH_MAIN_LIB}) + target_link_libraries(${testfilename} Catch2WithMain) MATH(EXPR EXTENSIONS_TEST_COUNT "${EXTENSIONS_TEST_COUNT}+1") add_test(NAME "${testfilename}" COMMAND "${testfilename}" WORKING_DIRECTORY ${TEST_DIR}) ENDFOREACH() diff --git a/libminifi/test/azure-tests/CMakeLists.txt b/libminifi/test/azure-tests/CMakeLists.txt index 2f8ad6ba4b..189c756626 100644 --- a/libminifi/test/azure-tests/CMakeLists.txt +++ b/libminifi/test/azure-tests/CMakeLists.txt @@ -29,7 +29,7 @@ FOREACH(testfile ${AZURE_INTEGRATION_TESTS}) target_include_directories(${testfilename} PRIVATE BEFORE "${CMAKE_SOURCE_DIR}/extensions/expression-language") target_compile_features(${testfilename} PRIVATE cxx_std_14) createTests("${testfilename}") - target_link_libraries(${testfilename} ${CATCH_MAIN_LIB}) + target_link_libraries(${testfilename} Catch2WithMain) target_link_libraries(${testfilename} minifi-azure) target_link_libraries(${testfilename} minifi-standard-processors) target_link_libraries(${testfilename} minifi-expression-language-extensions) diff --git a/libminifi/test/bustache-tests/CMakeLists.txt b/libminifi/test/bustache-tests/CMakeLists.txt index c89e2b887f..782ad7fa9b 100644 --- a/libminifi/test/bustache-tests/CMakeLists.txt +++ b/libminifi/test/bustache-tests/CMakeLists.txt @@ -30,7 +30,7 @@ FOREACH(testfile ${BUSTACHE_INTEGRATION_TESTS}) target_link_libraries(${testfilename} minifi-standard-processors) createTests("${testfilename}") - target_link_libraries(${testfilename} ${CATCH_MAIN_LIB}) + target_link_libraries(${testfilename} Catch2WithMain) MATH(EXPR BUSTACHE-EXTENSIONS_TEST_COUNT "${BUSTACHE-EXTENSIONS_TEST_COUNT}+1") add_test(NAME "${testfilename}" COMMAND "${testfilename}" WORKING_DIRECTORY ${TEST_DIR}) ENDFOREACH() diff --git a/libminifi/test/flow-tests/CMakeLists.txt b/libminifi/test/flow-tests/CMakeLists.txt index 153c3694dc..5d1960686e 100644 --- a/libminifi/test/flow-tests/CMakeLists.txt +++ b/libminifi/test/flow-tests/CMakeLists.txt @@ -32,7 +32,7 @@ FOREACH(testfile ${FLOW_TESTS}) target_link_libraries(${testfilename} minifi-rocksdb-repos) endif() - target_link_libraries(${testfilename} ${CATCH_MAIN_LIB}) + target_link_libraries(${testfilename} Catch2WithMain) MATH(EXPR FLOW_TEST_COUNT "${FLOW_TEST_COUNT}+1") add_test(NAME "${testfilename}" COMMAND "${testfilename}") ENDFOREACH() diff --git a/libminifi/test/gps-tests/CMakeLists.txt b/libminifi/test/gps-tests/CMakeLists.txt index 076cce3924..3744842df6 100644 --- a/libminifi/test/gps-tests/CMakeLists.txt +++ b/libminifi/test/gps-tests/CMakeLists.txt @@ -27,7 +27,7 @@ FOREACH(testfile ${GPS_INTEGRATION_TESTS}) createTests("${testfilename}") target_link_libraries(${testfilename} minifi-gps) target_link_libraries(${testfilename} minifi-standard-processors) - target_link_libraries(${testfilename} ${CATCH_MAIN_LIB}) + target_link_libraries(${testfilename} Catch2WithMain) MATH(EXPR GPS_TEST_COUNT "${GPS_TEST_COUNT}+1") add_test(NAME "${testfilename}" COMMAND "${testfilename}" WORKING_DIRECTORY ${TEST_DIR}) ENDFOREACH() diff --git a/libminifi/test/integration/OnScheduleErrorHandlingTests.cpp b/libminifi/test/integration/OnScheduleErrorHandlingTests.cpp index e8a1c27e87..14f74f6b4e 100644 --- a/libminifi/test/integration/OnScheduleErrorHandlingTests.cpp +++ b/libminifi/test/integration/OnScheduleErrorHandlingTests.cpp @@ -23,7 +23,6 @@ #include "core/Scheduling.h" #include "core/state/ProcessorController.h" #include "../TestBase.h" -#include "../Catch.h" #include "../../../extensions/test-processors/KamikazeProcessor.h" #include "utils/StringUtils.h" #include "utils/IntegrationTestUtils.h" diff --git a/libminifi/test/integration/StateTransactionalityTests.cpp b/libminifi/test/integration/StateTransactionalityTests.cpp index b95683b8c8..c1f3b28178 100644 --- a/libminifi/test/integration/StateTransactionalityTests.cpp +++ b/libminifi/test/integration/StateTransactionalityTests.cpp @@ -21,7 +21,6 @@ #include "IntegrationBase.h" #include "../StatefulProcessor.h" #include "../TestBase.h" -#include "../Catch.h" #include "utils/IntegrationTestUtils.h" #include "core/state/ProcessorController.h" diff --git a/libminifi/test/jni-tests/CMakeLists.txt b/libminifi/test/jni-tests/CMakeLists.txt index 653fcfadb7..6f8d26579a 100644 --- a/libminifi/test/jni-tests/CMakeLists.txt +++ b/libminifi/test/jni-tests/CMakeLists.txt @@ -27,7 +27,7 @@ FOREACH(testfile ${KAFKA_INTEGRATION_TESTS}) target_include_directories(${testfilename} SYSTEM BEFORE PRIVATE "${CMAKE_SOURCE_DIR}/thirdparty/librdkafka-0.11.1/src") target_include_directories(${testfilename} SYSTEM BEFORE PRIVATE "${CMAKE_SOURCE_DIR}/thirdparty/librdkafka-0.11.1/src-cpp") createTests("${testfilename}") - target_link_libraries(${testfilename} ${CATCH_MAIN_LIB}) + target_link_libraries(${testfilename} Catch2WithMain) target_link_libraries(${testfilename} minifi-jni) target_link_libraries(${testfilename} minifi-standard-processors) MATH(EXPR EXTENSIONS_TEST_COUNT "${EXTENSIONS_TEST_COUNT}+1") diff --git a/libminifi/test/keyvalue-tests/CMakeLists.txt b/libminifi/test/keyvalue-tests/CMakeLists.txt index b8c42bb7a3..ee70932e32 100644 --- a/libminifi/test/keyvalue-tests/CMakeLists.txt +++ b/libminifi/test/keyvalue-tests/CMakeLists.txt @@ -26,7 +26,7 @@ FOREACH(testfile ${KEYVALUE_TESTS}) add_executable("${testfilename}" "${testfile}" ) target_include_directories(${testfilename} PRIVATE BEFORE "${CMAKE_SOURCE_DIR}/libminifi/test/") createTests("${testfilename}") - target_link_libraries(${testfilename} minifi-standard-processors) + target_link_libraries(${testfilename} minifi-standard-processors Catch2) if (NOT DISABLE_ROCKSDB) target_link_libraries(${testfilename} minifi-rocksdb-repos) endif() diff --git a/libminifi/test/keyvalue-tests/PersistentStateStorageTest.cpp b/libminifi/test/keyvalue-tests/PersistentStateStorageTest.cpp index 1d494708db..6c55bfba10 100644 --- a/libminifi/test/keyvalue-tests/PersistentStateStorageTest.cpp +++ b/libminifi/test/keyvalue-tests/PersistentStateStorageTest.cpp @@ -25,6 +25,7 @@ #include "../TestBase.h" #include "../Catch.h" +#include "catch2/catch_session.hpp" #include "core/controller/ControllerService.h" #include "core/ProcessGroup.h" #include "core/yaml/YamlConfiguration.h" @@ -40,7 +41,7 @@ int main(int argc, char* argv[]) { Catch::Session session; auto cli = session.cli() - | Catch::clara::Opt{config_yaml, "config-yaml"} + | Catch::Clara::Opt{config_yaml, "config-yaml"} ["--config-yaml"] ("path to the config.yaml containing the StateStorage controller service configuration"); session.cli(cli); diff --git a/libminifi/test/keyvalue-tests/VolatileMapStateStorageTest.cpp b/libminifi/test/keyvalue-tests/VolatileMapStateStorageTest.cpp index 7681bab921..5e4fdac347 100644 --- a/libminifi/test/keyvalue-tests/VolatileMapStateStorageTest.cpp +++ b/libminifi/test/keyvalue-tests/VolatileMapStateStorageTest.cpp @@ -21,6 +21,7 @@ #include #include "../TestBase.h" #include "../Catch.h" +#include "catch2/catch_session.hpp" #include "controllers/keyvalue/AutoPersistor.h" #include "controllers/keyvalue/KeyValueStateStorage.h" #include "core/ProcessGroup.h" @@ -37,7 +38,7 @@ int main(int argc, char* argv[]) { Catch::Session session; auto cli = session.cli() - | Catch::clara::Opt{config_yaml, "config-yaml"} + | Catch::Clara::Opt{config_yaml, "config-yaml"} ["--config-yaml"] ("path to the config.yaml containing the VolatileMapStateStorageTest controller service configuration"); session.cli(cli); diff --git a/libminifi/test/persistence-tests/CMakeLists.txt b/libminifi/test/persistence-tests/CMakeLists.txt index de2b734394..edd8c56c02 100644 --- a/libminifi/test/persistence-tests/CMakeLists.txt +++ b/libminifi/test/persistence-tests/CMakeLists.txt @@ -32,7 +32,7 @@ FOREACH(testfile ${PERSISTENCE_TESTS}) target_link_libraries(${testfilename} minifi-standard-processors) target_link_libraries(${testfilename} minifi-rocksdb-repos) createTests("${testfilename}") - target_link_libraries(${testfilename} ${CATCH_MAIN_LIB}) + target_link_libraries(${testfilename} Catch2WithMain) MATH(EXPR PERSISTENCE_TEST_COUNT "${PERSISTENCE_TEST_COUNT}+1") add_test(NAME "${testfilename}" COMMAND "${testfilename}" WORKING_DIRECTORY ${TEST_DIR}) ENDFOREACH() diff --git a/libminifi/test/persistence-tests/PersistenceTests.cpp b/libminifi/test/persistence-tests/PersistenceTests.cpp index 0c841e57b3..30579f1c38 100644 --- a/libminifi/test/persistence-tests/PersistenceTests.cpp +++ b/libminifi/test/persistence-tests/PersistenceTests.cpp @@ -30,6 +30,7 @@ #include "../unit/ProvenanceTestHelper.h" #include "../TestBase.h" #include "../Catch.h" +#include "catch2/matchers/catch_matchers_string.hpp" #include "../../extensions/libarchive/MergeContent.h" #include "core/repository/VolatileFlowFileRepository.h" #include "../../extensions/rocksdb-repos/DatabaseContentRepository.h" @@ -235,7 +236,7 @@ TEST_CASE("Processors Can Store FlowFiles", "[TestP1]") { auto content = flow.read(file); // See important note about matchers at: https://github.com/catchorg/Catch2/blob/e8cdfdca87ebacd993befdd08ea6aa7e8068ef3d/docs/matchers.md#using-matchers - REQUIRE_THAT(content, Catch::Equals("_Header_one_Demarcator_two_Demarcator_three_Footer_") || Catch::Equals("_Header_two_Demarcator_one_Demarcator_three_Footer_")); + REQUIRE_THAT(content, Catch::Matchers::Equals("_Header_one_Demarcator_two_Demarcator_three_Footer_") || Catch::Matchers::Equals("_Header_two_Demarcator_one_Demarcator_three_Footer_")); } } diff --git a/libminifi/test/rocksdb-tests/CMakeLists.txt b/libminifi/test/rocksdb-tests/CMakeLists.txt index 0ab38c284e..bad12b51ce 100644 --- a/libminifi/test/rocksdb-tests/CMakeLists.txt +++ b/libminifi/test/rocksdb-tests/CMakeLists.txt @@ -25,7 +25,7 @@ FOREACH(testfile ${ROCKSDB_UNIT_TESTS}) target_include_directories(${testfilename} BEFORE PRIVATE "${CMAKE_SOURCE_DIR}/extensions/rocksdb-repos/") target_include_directories(${testfilename} SYSTEM BEFORE PRIVATE "${ROCKSDB_THIRDPARTY_ROOT}/include") createTests("${testfilename}") - target_link_libraries(${testfilename} ${CATCH_MAIN_LIB}) + target_link_libraries(${testfilename} Catch2WithMain) target_link_libraries(${testfilename} minifi-rocksdb-repos) target_link_libraries(${testfilename} minifi-standard-processors) MATH(EXPR ROCKSDB_TEST_COUNT "${ROCKSDB_TEST_COUNT}+1") diff --git a/libminifi/test/schema-tests/CMakeLists.txt b/libminifi/test/schema-tests/CMakeLists.txt index 3b8dbe0c2f..61b658c25d 100644 --- a/libminifi/test/schema-tests/CMakeLists.txt +++ b/libminifi/test/schema-tests/CMakeLists.txt @@ -25,7 +25,7 @@ FOREACH(testfile ${SCHEMA_TESTS}) get_filename_component(testfilename "${testfile}" NAME_WE) add_executable("${testfilename}" "${testfile}") createTests("${testfilename}") - target_link_libraries(${testfilename} ${CATCH_MAIN_LIB}) + target_link_libraries(${testfilename} Catch2WithMain) target_link_libraries(${testfilename} minifi-standard-processors) target_link_libraries(${testfilename} nlohmann_json_schema_validator) MATH(EXPR SCHEMA_TEST_COUNT "${SCHEMA_TEST_COUNT}+1") diff --git a/libminifi/test/sql-tests/CMakeLists.txt b/libminifi/test/sql-tests/CMakeLists.txt index bf2dccd286..30f0b7faf3 100644 --- a/libminifi/test/sql-tests/CMakeLists.txt +++ b/libminifi/test/sql-tests/CMakeLists.txt @@ -29,14 +29,13 @@ foreach(testfile ${SQL_TESTS}) get_filename_component(testfilename "${testfile}" NAME_WE) add_executable(${testfilename} "${testfile}") - target_include_directories(${testfilename} BEFORE PRIVATE "${CMAKE_SOURCE_DIR}/thirdparty/catch") target_include_directories(${testfilename} BEFORE PRIVATE "${CMAKE_SOURCE_DIR}/extensions/sql") target_include_directories(${testfilename} PRIVATE BEFORE "${CMAKE_SOURCE_DIR}/extensions/standard-processors") target_include_directories(${testfilename} BEFORE PRIVATE "${CMAKE_SOURCE_DIR}/libminifi/include") target_include_directories(${testfilename} BEFORE PRIVATE "${CMAKE_SOURCE_DIR}/libminifi/test") createTests("${testfilename}") - target_link_libraries(${testfilename} ${CATCH_MAIN_LIB}) + target_link_libraries(${testfilename} Catch2WithMain) target_link_libraries(${testfilename} minifi-sql-mocks) target_link_libraries(${testfilename} minifi-sql) target_link_libraries(${testfilename} minifi-standard-processors) diff --git a/libminifi/test/tensorflow-tests/CMakeLists.txt b/libminifi/test/tensorflow-tests/CMakeLists.txt index 7056acbd03..080c884c06 100644 --- a/libminifi/test/tensorflow-tests/CMakeLists.txt +++ b/libminifi/test/tensorflow-tests/CMakeLists.txt @@ -31,7 +31,7 @@ FOREACH(testfile ${TENSORFLOW_INTEGRATION_TESTS}) createTests("${testfilename}") target_link_libraries(${testfilename} minifi-tensorflow-extensions) target_link_libraries(${testfilename} minifi-standard-processors) - target_link_libraries(${testfilename} ${CATCH_MAIN_LIB}) + target_link_libraries(${testfilename} Catch2WithMain) MATH(EXPR EXTENSIONS_TEST_COUNT "${EXTENSIONS_TEST_COUNT}+1") add_test(NAME "${testfilename}" COMMAND "${testfilename}" WORKING_DIRECTORY ${TEST_DIR}) ENDFOREACH() diff --git a/libminifi/test/unit/ContentRepositoryDependentTests.h b/libminifi/test/unit/ContentRepositoryDependentTests.h index f19533ba35..c6b1621a09 100644 --- a/libminifi/test/unit/ContentRepositoryDependentTests.h +++ b/libminifi/test/unit/ContentRepositoryDependentTests.h @@ -21,7 +21,7 @@ #include #include -#include +#include "catch2/catch_test_macros.hpp" #include "core/Processor.h" #include "core/ProcessSession.h" #include "core/Resource.h" diff --git a/libminifi/test/unit/FileUtilsTests.cpp b/libminifi/test/unit/FileUtilsTests.cpp index 28268f925b..cbf7aa9a4a 100644 --- a/libminifi/test/unit/FileUtilsTests.cpp +++ b/libminifi/test/unit/FileUtilsTests.cpp @@ -16,9 +16,9 @@ * limitations under the License. */ +#include #include #include -#include #include #include #include @@ -27,9 +27,7 @@ #include "../Catch.h" #include "core/Core.h" #include "utils/file/FileUtils.h" -#include "utils/file/PathUtils.h" #include "utils/gsl.h" -#include "utils/Environment.h" #include "utils/TimeUtil.h" namespace FileUtils = org::apache::nifi::minifi::utils::file; @@ -186,9 +184,8 @@ TEST_CASE("TestFileUtils::addFilesMatchingExtension", "[TestAddFilesMatchingExte TEST_CASE("FileUtils::last_write_time and last_write_time_point work", "[last_write_time][last_write_time_point]") { using namespace std::chrono; - namespace fs = std::filesystem; - fs::file_time_type time_before_write = file_clock::now(); + file_clock::time_point time_before_write = file_clock::now(); time_point time_point_before_write = time_point_cast(file_clock::now()); TestController testController; @@ -204,10 +201,10 @@ TEST_CASE("FileUtils::last_write_time and last_write_time_point work", "[last_wr test_file_stream << "foo\n"; test_file_stream.flush(); - fs::file_time_type time_after_first_write = file_clock::now(); + file_clock::time_point time_after_first_write = file_clock::now(); time_point time_point_after_first_write = time_point_cast(file_clock::now()); - fs::file_time_type first_mtime = FileUtils::last_write_time(test_file).value(); + file_clock::time_point first_mtime = FileUtils::last_write_time(test_file).value(); REQUIRE(first_mtime >= time_before_write); REQUIRE(first_mtime <= time_after_first_write); @@ -219,10 +216,10 @@ TEST_CASE("FileUtils::last_write_time and last_write_time_point work", "[last_wr test_file_stream << "bar\n"; test_file_stream.flush(); - fs::file_time_type time_after_second_write = file_clock::now(); + file_clock::time_point time_after_second_write = file_clock::now(); time_point time_point_after_second_write = time_point_cast(file_clock::now()); - fs::file_time_type second_mtime = FileUtils::last_write_time(test_file).value(); + file_clock::time_point second_mtime = FileUtils::last_write_time(test_file).value(); REQUIRE(second_mtime >= first_mtime); REQUIRE(second_mtime >= time_after_first_write); REQUIRE(second_mtime <= time_after_second_write); @@ -236,7 +233,7 @@ TEST_CASE("FileUtils::last_write_time and last_write_time_point work", "[last_wr // On Windows it would rarely occur that the last_write_time is off by 1 from the previous check #ifndef WIN32 - fs::file_time_type third_mtime = FileUtils::last_write_time(test_file).value(); + file_clock::time_point third_mtime = FileUtils::last_write_time(test_file).value(); REQUIRE(third_mtime == second_mtime); time_point third_mtime_time_point = FileUtils::last_write_time_point(test_file); diff --git a/libminifi/test/unit/NetUtilsTest.cpp b/libminifi/test/unit/NetUtilsTest.cpp index add55e050f..b29dc8adfc 100644 --- a/libminifi/test/unit/NetUtilsTest.cpp +++ b/libminifi/test/unit/NetUtilsTest.cpp @@ -36,31 +36,31 @@ TEST_CASE("net::resolveHost", "[net][dns][utils][resolveHost]") { } TEST_CASE("net::reverseDnsLookup", "[net][dns][reverseDnsLookup]") { - SECTION("dns.google IPv4") { - auto dns_google_hostname = net::reverseDnsLookup(asio::ip::address::from_string("8.8.8.8")); - REQUIRE(dns_google_hostname.has_value()); - CHECK(dns_google_hostname == "dns.google"); - } - SECTION("dns.google IPv6") { if (minifi::test::utils::isIPv6Disabled()) - return; + SKIP("IPv6 is disabled"); auto dns_google_hostname = net::reverseDnsLookup(asio::ip::address::from_string("2001:4860:4860::8888")); REQUIRE(dns_google_hostname.has_value()); CHECK(dns_google_hostname == "dns.google"); } - SECTION("Unresolvable address IPv4") { - auto unresolvable_hostname = net::reverseDnsLookup(asio::ip::address::from_string("192.0.2.0")); - REQUIRE(unresolvable_hostname.has_value()); - CHECK(unresolvable_hostname == "192.0.2.0"); + SECTION("dns.google IPv4") { + auto dns_google_hostname = net::reverseDnsLookup(asio::ip::address::from_string("8.8.8.8")); + REQUIRE(dns_google_hostname.has_value()); + CHECK(dns_google_hostname == "dns.google"); } SECTION("Unresolvable address IPv6") { if (minifi::test::utils::isIPv6Disabled()) - return; + SKIP("IPv6 is disabled"); auto unresolvable_hostname = net::reverseDnsLookup(asio::ip::address::from_string("2001:db8::")); REQUIRE(unresolvable_hostname.has_value()); CHECK(unresolvable_hostname == "2001:db8::"); } + + SECTION("Unresolvable address IPv4") { + auto unresolvable_hostname = net::reverseDnsLookup(asio::ip::address::from_string("192.0.2.0")); + REQUIRE(unresolvable_hostname.has_value()); + CHECK(unresolvable_hostname == "192.0.2.0"); + } } diff --git a/libminifi/test/unit/OsUtilTests.cpp b/libminifi/test/unit/OsUtilTests.cpp index db38fde090..b1eb4a14d9 100644 --- a/libminifi/test/unit/OsUtilTests.cpp +++ b/libminifi/test/unit/OsUtilTests.cpp @@ -39,6 +39,10 @@ TEST_CASE("Test userIdToUsername for well-known SIDs", "[OsUtils]") { CHECK_FALSE(minifi::utils::OsUtils::userIdToUsername("S-1-3-4").empty()); CHECK_FALSE(minifi::utils::OsUtils::userIdToUsername("S-1-5-80-0").empty()); } +#else +TEST_CASE("OsUtilTests") { + SUCCEED("To avoid empty test executable"); +} #endif } // namespace org::apache::nifi::minifi::test diff --git a/libminifi/test/unit/ProcessContextTest.cpp b/libminifi/test/unit/ProcessContextTest.cpp index a9947d7bae..9cc04c1832 100644 --- a/libminifi/test/unit/ProcessContextTest.cpp +++ b/libminifi/test/unit/ProcessContextTest.cpp @@ -15,6 +15,7 @@ * limitations under the License. */ #include +#include "../Catch.h" #include "ProcessContext.h" #include "core/FlowFile.h" #include "utils/meta/detected.h" @@ -24,13 +25,16 @@ namespace org::apache::nifi::minifi { template using getProperty_compiles = decltype(std::declval().getProperty(std::declval()...)); -static_assert(!utils::meta::is_detected_v); -static_assert(!utils::meta::is_detected_v&>); -static_assert(!utils::meta::is_detected_v); -static_assert(!utils::meta::is_detected_v>); -static_assert(!utils::meta::is_detected_v); -static_assert(!utils::meta::is_detected_v&>); -static_assert(!utils::meta::is_detected_v); -static_assert(!utils::meta::is_detected_v>); +TEST_CASE("ProcessContextTest") { + STATIC_REQUIRE_FALSE(utils::meta::is_detected_v); + STATIC_REQUIRE_FALSE(utils::meta::is_detected_v&>); + STATIC_REQUIRE_FALSE(utils::meta::is_detected_v); + STATIC_REQUIRE_FALSE(utils::meta::is_detected_v>); + STATIC_REQUIRE_FALSE(utils::meta::is_detected_v); + STATIC_REQUIRE_FALSE(utils::meta::is_detected_v&>); + STATIC_REQUIRE_FALSE(utils::meta::is_detected_v); + STATIC_REQUIRE_FALSE(utils::meta::is_detected_v>); +} + } // namespace org::apache::nifi::minifi diff --git a/libminifi/test/unit/RegexUtilsTests.cpp b/libminifi/test/unit/RegexUtilsTests.cpp index 3486a7c770..d54a10ebe5 100644 --- a/libminifi/test/unit/RegexUtilsTests.cpp +++ b/libminifi/test/unit/RegexUtilsTests.cpp @@ -22,6 +22,8 @@ #include "utils/RegexUtils.h" #include "../TestBase.h" #include "../Catch.h" +#include "catch2/catch_all.hpp" +#include "catch2/matchers/catch_matchers_string.hpp" using org::apache::nifi::minifi::utils::Regex; namespace minifi = org::apache::nifi::minifi; @@ -40,7 +42,7 @@ TEST_CASE("TestRegexUtils::invalid_construction", "[regex2]") { std::string rgx2 = "[Invalid)A(F)"; std::vector mode = {Regex::Mode::ICASE}; Regex r1(rgx1, mode); - REQUIRE_THROWS_WITH(Regex(rgx2, mode), Catch::Contains("Regex Operation")); + REQUIRE_THROWS_WITH(Regex(rgx2, mode), Catch::Matchers::StartsWith("Regex Operation")); } TEST_CASE("TestRegexUtils::empty_input", "[regex3]") { diff --git a/libminifi/test/unit/WindowsCertStoreLocationTests.cpp b/libminifi/test/unit/WindowsCertStoreLocationTests.cpp index 7c6bc8b9f0..0ed985dd3a 100644 --- a/libminifi/test/unit/WindowsCertStoreLocationTests.cpp +++ b/libminifi/test/unit/WindowsCertStoreLocationTests.cpp @@ -51,4 +51,10 @@ TEST_CASE("CurrentUser and LocalMachine are among the allowed values of WindowsC CHECK_FALSE(ranges::contains(allowed_locations, "SomebodyElsesComputer")); } +#else +#include "../Catch.h" +TEST_CASE("WindowsCertStoreLocation") { + SUCCEED("To avoid empty test executable"); +} + #endif // WIN32 diff --git a/libminifi/test/unit/tls/TLSStreamTests.cpp b/libminifi/test/unit/tls/TLSStreamTests.cpp index 8b30b88c49..95c473e5d1 100644 --- a/libminifi/test/unit/tls/TLSStreamTests.cpp +++ b/libminifi/test/unit/tls/TLSStreamTests.cpp @@ -25,7 +25,6 @@ #include "io/tls/TLSServerSocket.h" #include "io/tls/TLSSocket.h" #include "../../TestBase.h" -#include "../../Catch.h" #include "../../SimpleSSLTestServer.h" #include "../utils/IntegrationTestUtils.h" diff --git a/minifi_main/tests/CMakeLists.txt b/minifi_main/tests/CMakeLists.txt index 9b54bf315c..54df3efa3c 100644 --- a/minifi_main/tests/CMakeLists.txt +++ b/minifi_main/tests/CMakeLists.txt @@ -25,7 +25,7 @@ FOREACH(TEST_FILE ${MINIFI_MAIN_UNIT_TESTS}) target_include_directories(${TEST_TARGET} PRIVATE BEFORE "${CMAKE_SOURCE_DIR}/libminifi/test" "${CMAKE_SOURCE_DIR}/minifi_main") - target_link_libraries(${TEST_TARGET} core-minifi ${CATCH_MAIN_LIB}) + target_link_libraries(${TEST_TARGET} core-minifi Catch2WithMain) createTests("${TEST_TARGET}") add_test(NAME ${TEST_TARGET} COMMAND "${TEST_TARGET}" WORKING_DIRECTORY "${TEST_DIR}") MATH(EXPR MINIFI_MAIN_UNIT_TEST_COUNT "${MINIFI_MAIN_UNIT_TEST_COUNT}+1") diff --git a/thirdparty/catch/catch.hpp b/thirdparty/catch/catch.hpp deleted file mode 100644 index 9b309bddc6..0000000000 --- a/thirdparty/catch/catch.hpp +++ /dev/null @@ -1,17976 +0,0 @@ -/* - * Catch v2.13.10 - * Generated: 2022-10-16 11:01:23.452308 - * ---------------------------------------------------------- - * This file has been merged from multiple headers. Please don't edit it directly - * Copyright (c) 2022 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 10 - -#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) - -// 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 - -# if !defined(__clang__) // Handle Clang masquerading for msvc - -// 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(_MSVC_TRADITIONAL) || (defined(_MSVC_TRADITIONAL) && _MSVC_TRADITIONAL) -# define CATCH_INTERNAL_CONFIG_TRADITIONAL_MSVC_PREPROCESSOR -# endif // MSVC_TRADITIONAL - -// Only do this if we're not using clang on Windows, which uses `diagnostic push` & `diagnostic pop` -# define CATCH_INTERNAL_START_WARNINGS_SUPPRESSION __pragma( warning(push) ) -# define CATCH_INTERNAL_STOP_WARNINGS_SUPPRESSION __pragma( warning(pop) ) -# 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