From 89ce68b88ad27c35f80f98cf11078564e20c74c1 Mon Sep 17 00:00:00 2001 From: Richard Samuels <1666322+richardsamuels@users.noreply.github.com> Date: Wed, 9 Feb 2022 14:31:31 -0500 Subject: [PATCH] TIG-3662 Create HTTP actor (#604) --- cmake/Findcppcodec.cmake | 14 + src/CMakeLists.txt | 2 +- src/cast_core/CMakeLists.txt | 4 + .../cast_core/actors/SampleHttpClient.hpp | 54 + src/cast_core/src/SampleHttpClient.cpp | 117 + src/third_party/CMakeLists.txt | 5 +- src/third_party/cppcodec/.gitignore | 3 + src/third_party/cppcodec/.gitmodules | 3 + src/third_party/cppcodec/.travis.yml | 143 + src/third_party/cppcodec/CMakeLists.txt | 81 + src/third_party/cppcodec/LICENSE | 21 + src/third_party/cppcodec/README.md | 248 + src/third_party/cppcodec/TODO.md | 63 + src/third_party/cppcodec/appveyor.yml | 66 + src/third_party/cppcodec/cppcodec.pc.in | 7 + .../cppcodec/cppcodec/base32_crockford.hpp | 91 + .../cppcodec/base32_default_crockford.hpp | 31 + .../cppcodec/cppcodec/base32_default_hex.hpp | 31 + .../cppcodec/base32_default_rfc4648.hpp | 31 + .../cppcodec/cppcodec/base32_hex.hpp | 76 + .../cppcodec/cppcodec/base32_rfc4648.hpp | 76 + .../cppcodec/base64_default_rfc4648.hpp | 31 + .../cppcodec/cppcodec/base64_default_url.hpp | 31 + .../cppcodec/base64_default_url_unpadded.hpp | 31 + .../cppcodec/cppcodec/base64_rfc4648.hpp | 73 + .../cppcodec/cppcodec/base64_url.hpp | 75 + .../cppcodec/cppcodec/base64_url_unpadded.hpp | 48 + .../cppcodec/cppcodec/data/access.hpp | 328 + .../cppcodec/data/raw_result_buffer.hpp | 70 + .../cppcodec/cppcodec/detail/base32.hpp | 166 + .../cppcodec/cppcodec/detail/base64.hpp | 132 + .../cppcodec/cppcodec/detail/codec.hpp | 327 + .../cppcodec/cppcodec/detail/config.hpp | 40 + .../cppcodec/cppcodec/detail/hex.hpp | 114 + .../cppcodec/cppcodec/detail/stream_codec.hpp | 439 + .../cppcodec/cppcodec/hex_default_lower.hpp | 31 + .../cppcodec/cppcodec/hex_default_upper.hpp | 31 + .../cppcodec/cppcodec/hex_lower.hpp | 75 + .../cppcodec/cppcodec/hex_upper.hpp | 75 + .../cppcodec/cppcodec/parse_error.hpp | 109 + .../cppcodec/example/CMakeLists.txt | 6 + .../cppcodec/example/helloworld.cpp | 39 + .../cppcodec/example/type_support_wrapper.cpp | 149 + src/third_party/cppcodec/test/CMakeLists.txt | 22 + .../cppcodec/test/benchmark_cppcodec.cpp | 164 + .../cppcodec/test/catch/.gitattributes | 22 + .../test/catch/.github/issue_template.md | 29 + .../catch/.github/pull_request_template.md | 28 + .../cppcodec/test/catch/.gitignore | 29 + .../cppcodec/test/catch/.travis.yml | 285 + .../test/catch/CMake/Catch2Config.cmake.in | 10 + .../cppcodec/test/catch/CMake/FindGcov.cmake | 157 + .../cppcodec/test/catch/CMake/FindLcov.cmake | 354 + .../test/catch/CMake/Findcodecov.cmake | 258 + .../test/catch/CMake/MiscFunctions.cmake | 26 + .../cppcodec/test/catch/CMake/catch2.pc.in | 7 + .../test/catch/CMake/llvm-cov-wrapper | 56 + .../cppcodec/test/catch/CMakeLists.txt | 184 + .../cppcodec/test/catch/CODE_OF_CONDUCT.md | 46 + .../cppcodec/test/catch/LICENSE.txt | 23 + src/third_party/cppcodec/test/catch/README.md | 38 + .../cppcodec/test/catch/appveyor.yml | 98 + .../test/catch/artwork/catch2-c-logo.png | Bin 0 -> 18222 bytes .../test/catch/artwork/catch2-hand-logo.png | Bin 0 -> 57969 bytes .../test/catch/artwork/catch2-logo-small.png | Bin 0 -> 29025 bytes .../cppcodec/test/catch/codecov.yml | 24 + .../cppcodec/test/catch/conanfile.py | 31 + .../cppcodec/test/catch/contrib/Catch.cmake | 175 + .../test/catch/contrib/CatchAddTests.cmake | 76 + .../catch/contrib/ParseAndAddCatchTests.cmake | 188 + .../cppcodec/test/catch/contrib/gdbinit | 16 + .../cppcodec/test/catch/contrib/lldbinit | 16 + .../cppcodec/test/catch/docs/Readme.md | 36 + .../cppcodec/test/catch/docs/assertions.md | 201 + .../cppcodec/test/catch/docs/ci-and-misc.md | 102 + .../test/catch/docs/cmake-integration.md | 189 + .../cppcodec/test/catch/docs/command-line.md | 349 + .../test/catch/docs/commercial-users.md | 17 + .../cppcodec/test/catch/docs/configuration.md | 205 + .../cppcodec/test/catch/docs/contributing.md | 61 + .../test/catch/docs/event-listeners.md | 75 + .../cppcodec/test/catch/docs/limitations.md | 139 + .../test/catch/docs/list-of-examples.md | 37 + .../cppcodec/test/catch/docs/logging.md | 77 + .../cppcodec/test/catch/docs/matchers.md | 136 + .../test/catch/docs/opensource-users.md | 105 + .../cppcodec/test/catch/docs/own-main.md | 125 + .../cppcodec/test/catch/docs/release-notes.md | 624 + .../test/catch/docs/release-process.md | 53 + .../cppcodec/test/catch/docs/reporters.md | 46 + .../cppcodec/test/catch/docs/slow-compiles.md | 71 + .../catch/docs/test-cases-and-sections.md | 91 + .../cppcodec/test/catch/docs/test-fixtures.md | 35 + .../cppcodec/test/catch/docs/tostring.md | 65 + .../cppcodec/test/catch/docs/tutorial.md | 267 + .../cppcodec/test/catch/docs/why-catch.md | 46 + .../test/catch/examples/000-CatchMain.cpp | 15 + .../test/catch/examples/010-TestCase.cpp | 36 + .../test/catch/examples/020-TestCase-1.cpp | 35 + .../test/catch/examples/020-TestCase-2.cpp | 33 + .../catch/examples/030-Asn-Require-Check.cpp | 74 + .../test/catch/examples/100-Fix-Section.cpp | 69 + .../catch/examples/110-Fix-ClassFixture.cpp | 63 + .../120-Bdd-ScenarioGivenWhenThen.cpp | 73 + .../catch/examples/210-Evt-EventListeners.cpp | 422 + .../catch/examples/231-Cfg-OutputStreams.cpp | 49 + .../test/catch/examples/CMakeLists.txt | 101 + .../cppcodec/test/catch/include/catch.hpp | 357 + .../test/catch/include/catch_with_main.hpp | 14 + .../test/catch/include/external/clara.hpp | 1256 ++ .../catch/include/internal/catch_approx.cpp | 72 + .../catch/include/internal/catch_approx.h | 140 + .../internal/catch_assertionhandler.cpp | 116 + .../include/internal/catch_assertionhandler.h | 88 + .../include/internal/catch_assertioninfo.h | 31 + .../internal/catch_assertionresult.cpp | 98 + .../include/internal/catch_assertionresult.h | 59 + .../include/internal/catch_benchmark.cpp | 36 + .../catch/include/internal/catch_benchmark.h | 57 + .../catch/include/internal/catch_capture.hpp | 147 + .../internal/catch_capture_matchers.cpp | 24 + .../include/internal/catch_capture_matchers.h | 86 + .../test/catch/include/internal/catch_clara.h | 38 + .../include/internal/catch_commandline.cpp | 194 + .../include/internal/catch_commandline.h | 20 + .../catch/include/internal/catch_common.cpp | 44 + .../catch/include/internal/catch_common.h | 83 + .../internal/catch_compiler_capabilities.h | 197 + .../catch/include/internal/catch_config.cpp | 71 + .../catch/include/internal/catch_config.hpp | 122 + .../include/internal/catch_console_colour.cpp | 236 + .../include/internal/catch_console_colour.h | 69 + .../catch/include/internal/catch_context.cpp | 62 + .../catch/include/internal/catch_context.h | 60 + .../include/internal/catch_debug_console.cpp | 31 + .../include/internal/catch_debug_console.h | 17 + .../catch/include/internal/catch_debugger.cpp | 113 + .../catch/include/internal/catch_debugger.h | 49 + .../include/internal/catch_decomposer.cpp | 24 + .../catch/include/internal/catch_decomposer.h | 175 + .../include/internal/catch_default_main.hpp | 46 + .../catch/include/internal/catch_enforce.h | 24 + .../include/internal/catch_errno_guard.cpp | 15 + .../include/internal/catch_errno_guard.h | 22 + .../catch_exception_translator_registry.cpp | 73 + .../catch_exception_translator_registry.h | 30 + .../internal/catch_external_interfaces.h | 20 + .../internal/catch_fatal_condition.cpp | 176 + .../include/internal/catch_fatal_condition.h | 69 + .../catch/include/internal/catch_impl.hpp | 33 + .../internal/catch_interfaces_capture.cpp | 5 + .../internal/catch_interfaces_capture.h | 84 + .../internal/catch_interfaces_config.cpp | 5 + .../internal/catch_interfaces_config.h | 83 + .../internal/catch_interfaces_exception.cpp | 6 + .../internal/catch_interfaces_exception.h | 83 + .../catch_interfaces_registry_hub.cpp | 6 + .../internal/catch_interfaces_registry_hub.h | 59 + .../internal/catch_interfaces_reporter.cpp | 114 + .../internal/catch_interfaces_reporter.h | 232 + .../internal/catch_interfaces_runner.cpp | 5 + .../internal/catch_interfaces_runner.h | 19 + .../catch_interfaces_tag_alias_registry.h | 28 + .../internal/catch_interfaces_testcase.cpp | 6 + .../internal/catch_interfaces_testcase.h | 40 + .../include/internal/catch_leak_detector.cpp | 32 + .../include/internal/catch_leak_detector.h | 17 + .../catch/include/internal/catch_list.cpp | 162 + .../test/catch/include/internal/catch_list.h | 38 + .../catch/include/internal/catch_matchers.cpp | 28 + .../catch/include/internal/catch_matchers.h | 158 + .../internal/catch_matchers_floating.cpp | 140 + .../internal/catch_matchers_floating.h | 53 + .../internal/catch_matchers_generic.cpp | 9 + .../internal/catch_matchers_generic.hpp | 58 + .../internal/catch_matchers_string.cpp | 118 + .../include/internal/catch_matchers_string.h | 80 + .../include/internal/catch_matchers_vector.h | 183 + .../catch/include/internal/catch_message.cpp | 58 + .../catch/include/internal/catch_message.h | 70 + .../catch/include/internal/catch_objc.hpp | 215 + .../catch/include/internal/catch_objc_arc.hpp | 51 + .../catch/include/internal/catch_option.hpp | 73 + .../internal/catch_output_redirect.cpp | 139 + .../include/internal/catch_output_redirect.h | 101 + .../catch/include/internal/catch_platform.h | 27 + .../catch_random_number_generator.cpp | 29 + .../internal/catch_random_number_generator.h | 23 + .../internal/catch_reenable_warnings.h | 21 + .../include/internal/catch_registry_hub.cpp | 97 + .../internal/catch_reporter_registrars.hpp | 76 + .../internal/catch_reporter_registry.cpp | 34 + .../internal/catch_reporter_registry.h | 37 + .../include/internal/catch_result_type.cpp | 27 + .../include/internal/catch_result_type.h | 55 + .../include/internal/catch_run_context.cpp | 430 + .../include/internal/catch_run_context.h | 146 + .../catch/include/internal/catch_section.cpp | 38 + .../catch/include/internal/catch_section.h | 49 + .../include/internal/catch_section_info.cpp | 19 + .../include/internal/catch_section_info.h | 42 + .../catch/include/internal/catch_session.cpp | 282 + .../catch/include/internal/catch_session.h | 53 + .../catch_startup_exception_registry.cpp | 26 + .../catch_startup_exception_registry.h | 27 + .../catch/include/internal/catch_stream.cpp | 213 + .../catch/include/internal/catch_stream.h | 51 + .../include/internal/catch_string_manip.cpp | 80 + .../include/internal/catch_string_manip.h | 36 + .../include/internal/catch_stringref.cpp | 127 + .../catch/include/internal/catch_stringref.h | 130 + .../internal/catch_suppress_warnings.h | 26 + .../include/internal/catch_tag_alias.cpp | 5 + .../catch/include/internal/catch_tag_alias.h | 26 + .../catch_tag_alias_autoregistrar.cpp | 15 + .../internal/catch_tag_alias_autoregistrar.h | 25 + .../internal/catch_tag_alias_registry.cpp | 58 + .../internal/catch_tag_alias_registry.h | 31 + .../include/internal/catch_test_case_info.cpp | 180 + .../include/internal/catch_test_case_info.h | 90 + .../catch_test_case_registry_impl.cpp | 112 + .../internal/catch_test_case_registry_impl.h | 69 + .../internal/catch_test_case_tracker.cpp | 287 + .../internal/catch_test_case_tracker.h | 183 + .../include/internal/catch_test_registry.cpp | 36 + .../include/internal/catch_test_registry.h | 105 + .../include/internal/catch_test_spec.cpp | 59 + .../catch/include/internal/catch_test_spec.h | 80 + .../internal/catch_test_spec_parser.cpp | 87 + .../include/internal/catch_test_spec_parser.h | 75 + .../test/catch/include/internal/catch_text.h | 17 + .../catch/include/internal/catch_timer.cpp | 74 + .../test/catch/include/internal/catch_timer.h | 30 + .../include/internal/catch_to_string.hpp | 28 + .../catch/include/internal/catch_tostring.cpp | 244 + .../catch/include/internal/catch_tostring.h | 590 + .../catch/include/internal/catch_totals.cpp | 61 + .../catch/include/internal/catch_totals.h | 41 + .../internal/catch_uncaught_exceptions.cpp | 21 + .../internal/catch_uncaught_exceptions.h | 15 + .../include/internal/catch_user_interfaces.h | 18 + .../catch/include/internal/catch_version.cpp | 44 + .../catch/include/internal/catch_version.h | 39 + .../internal/catch_wildcard_pattern.cpp | 49 + .../include/internal/catch_wildcard_pattern.h | 38 + .../include/internal/catch_windows_h_proxy.h | 39 + .../include/internal/catch_xmlwriter.cpp | 284 + .../catch/include/internal/catch_xmlwriter.h | 105 + .../reporters/catch_reporter_automake.hpp | 62 + .../reporters/catch_reporter_bases.cpp | 55 + .../reporters/catch_reporter_bases.hpp | 274 + .../reporters/catch_reporter_compact.cpp | 292 + .../reporters/catch_reporter_compact.h | 41 + .../reporters/catch_reporter_console.cpp | 633 + .../reporters/catch_reporter_console.h | 83 + .../reporters/catch_reporter_junit.cpp | 248 + .../include/reporters/catch_reporter_junit.h | 61 + .../reporters/catch_reporter_listening.cpp | 142 + .../reporters/catch_reporter_listening.h | 57 + .../include/reporters/catch_reporter_tap.hpp | 253 + .../reporters/catch_reporter_teamcity.hpp | 220 + .../include/reporters/catch_reporter_xml.cpp | 223 + .../include/reporters/catch_reporter_xml.h | 61 + .../cppcodec/test/catch/misc/CMakeLists.txt | 11 + .../misc/appveyorBuildConfigurationScript.bat | 27 + .../catch/misc/appveyorMergeCoverageScript.py | 9 + .../test/catch/misc/appveyorTestRunScript.bat | 13 + .../test/catch/misc/coverage-helper.cpp | 105 + .../catch/misc/installOpenCppCoverage.ps1 | 19 + .../test/catch/projects/CMakeLists.txt | 329 + .../Baselines/automake.std.approved.txt | 168 + .../Baselines/compact.sw.approved.txt | 1164 ++ .../Baselines/console.std.approved.txt | 1101 ++ .../Baselines/console.sw.approved.txt | 9157 +++++++++++ .../Baselines/console.swa4.approved.txt | 346 + .../SelfTest/Baselines/junit.sw.approved.txt | 901 ++ .../SelfTest/Baselines/xml.sw.approved.txt | 10097 ++++++++++++ .../CompileTimePerfTests/10.tests.cpp | 13 + .../CompileTimePerfTests/100.tests.cpp | 13 + .../CompileTimePerfTests/All.tests.cpp | 15 + .../IntrospectiveTests/CmdLine.tests.cpp | 459 + .../IntrospectiveTests/PartTracker.tests.cpp | 326 + .../IntrospectiveTests/String.tests.cpp | 204 + .../IntrospectiveTests/TagAlias.tests.cpp | 42 + .../SelfTest/IntrospectiveTests/Xml.tests.cpp | 112 + .../SurrogateCpps/catch_console_colour.cpp | 3 + .../SelfTest/SurrogateCpps/catch_debugger.cpp | 2 + .../catch_interfaces_reporter.cpp | 2 + .../SelfTest/SurrogateCpps/catch_option.cpp | 3 + .../SelfTest/SurrogateCpps/catch_stream.cpp | 3 + .../SurrogateCpps/catch_test_case_tracker.cpp | 2 + .../SurrogateCpps/catch_test_spec.cpp | 3 + .../SurrogateCpps/catch_xmlwriter.cpp | 4 + .../test/catch/projects/SelfTest/TestMain.cpp | 33 + .../SelfTest/UsageTests/Approx.tests.cpp | 214 + .../SelfTest/UsageTests/BDD.tests.cpp | 107 + .../SelfTest/UsageTests/Benchmark.tests.cpp | 43 + .../SelfTest/UsageTests/Class.tests.cpp | 63 + .../SelfTest/UsageTests/Compilation.tests.cpp | 157 + .../SelfTest/UsageTests/Condition.tests.cpp | 334 + .../UsageTests/Decomposition.tests.cpp | 39 + .../UsageTests/EnumToString.tests.cpp | 66 + .../SelfTest/UsageTests/Exception.tests.cpp | 209 + .../SelfTest/UsageTests/Matchers.tests.cpp | 432 + .../SelfTest/UsageTests/Message.tests.cpp | 137 + .../SelfTest/UsageTests/Misc.tests.cpp | 356 + .../UsageTests/ToStringChrono.tests.cpp | 44 + .../UsageTests/ToStringGeneral.tests.cpp | 164 + .../UsageTests/ToStringPair.tests.cpp | 30 + .../UsageTests/ToStringTuple.tests.cpp | 47 + .../UsageTests/ToStringVector.tests.cpp | 86 + .../UsageTests/ToStringWhich.tests.cpp | 193 + .../SelfTest/UsageTests/Tricky.tests.cpp | 428 + .../UsageTests/VariadicMacros.tests.cpp | 29 + .../projects/Where did the projects go.txt | 13 + .../OCTest/OCTest.xcodeproj/project.pbxproj | 294 + .../contents.xcworkspacedata | 7 + .../XCode/OCTest/OCTest/CatchOCTestCase.h | 25 + .../XCode/OCTest/OCTest/CatchOCTestCase.mm | 87 + .../projects/XCode/OCTest/OCTest/Main.mm | 2 + .../projects/XCode/OCTest/OCTest/OCTest.1 | 79 + .../projects/XCode/OCTest/OCTest/OCTest.mm | 28 + .../projects/XCode/OCTest/OCTest/TestObj.h | 28 + .../projects/XCode/OCTest/OCTest/TestObj.m | 25 + .../projects/XCode/OCTest/catch_objc_impl.mm | 69 + .../test/catch/scripts/approvalTests.py | 199 + .../cppcodec/test/catch/scripts/approve.py | 33 + .../test/catch/scripts/benchmarkCompile.py | 148 + .../test/catch/scripts/benchmarkRunner.py | 56 + .../test/catch/scripts/developBuild.py | 10 + .../cppcodec/test/catch/scripts/embed.py | 63 + .../cppcodec/test/catch/scripts/embedClara.py | 27 + .../test/catch/scripts/fixWhitespace.py | 52 + .../catch/scripts/generateSingleHeader.py | 129 + .../test/catch/scripts/majorRelease.py | 10 + .../test/catch/scripts/minorRelease.py | 10 + .../test/catch/scripts/patchRelease.py | 10 + .../test/catch/scripts/releaseCommon.py | 178 + .../test/catch/scripts/releaseNotes.py | 65 + .../test/catch/scripts/scriptCommon.py | 26 + .../test/catch/scripts/updateDocumentToC.py | 447 + .../test/catch/scripts/updateWandbox.py | 47 + .../catch/single_include/catch2/catch.hpp | 13359 ++++++++++++++++ .../catch2/catch_reporter_automake.hpp | 62 + .../catch2/catch_reporter_tap.hpp | 253 + .../catch2/catch_reporter_teamcity.hpp | 220 + .../test/catch/test_package/CMakeLists.txt | 7 + .../test/catch/test_package/MainTest.cpp | 21 + .../test/catch/test_package/conanfile.py | 21 + .../cppcodec/test/catch/third_party/clara.hpp | 1255 ++ .../cppcodec/test/minimal_decode.cpp | 34 + .../cppcodec/test/test_cppcodec.cpp | 991 ++ src/third_party/cppcodec/tool/CMakeLists.txt | 11 + src/third_party/cppcodec/tool/base32dec.cpp | 49 + src/third_party/cppcodec/tool/base32enc.cpp | 40 + src/third_party/cppcodec/tool/base64dec.cpp | 49 + src/third_party/cppcodec/tool/base64enc.cpp | 40 + src/third_party/cppcodec/tool/hexdec.cpp | 49 + src/third_party/cppcodec/tool/hexenc.cpp | 41 + .../simple-beast-client/CMakeLists.txt | 29 + src/third_party/simple-beast-client/LICENSE | 21 + src/third_party/simple-beast-client/README.md | 1 + .../cmake/Findcppcodec.cmake | 14 + .../cmake/modules/Findcppcodec.cmake | 13 + .../cmake/public_modules/Findcppcodec.cmake | 11 + .../cmake/simple-beast-client-config.cmake | 10 + .../example/CMakeLists.txt | 22 + .../simple-beast-client/example/main.cpp | 160 + .../simple-beast-client/client_private.hpp | 367 + .../client_private_http.hpp | 87 + .../client_private_ssl.hpp | 177 + .../digestauthenticator.hpp | 244 + .../simple-beast-client/httpclient.hpp | 147 + .../include/simple-beast-client/url.hpp | 294 + 374 files changed, 73617 insertions(+), 2 deletions(-) create mode 100644 cmake/Findcppcodec.cmake create mode 100644 src/cast_core/include/cast_core/actors/SampleHttpClient.hpp create mode 100644 src/cast_core/src/SampleHttpClient.cpp create mode 100644 src/third_party/cppcodec/.gitignore create mode 100644 src/third_party/cppcodec/.gitmodules create mode 100644 src/third_party/cppcodec/.travis.yml create mode 100644 src/third_party/cppcodec/CMakeLists.txt create mode 100644 src/third_party/cppcodec/LICENSE create mode 100644 src/third_party/cppcodec/README.md create mode 100644 src/third_party/cppcodec/TODO.md create mode 100644 src/third_party/cppcodec/appveyor.yml create mode 100644 src/third_party/cppcodec/cppcodec.pc.in create mode 100644 src/third_party/cppcodec/cppcodec/base32_crockford.hpp create mode 100644 src/third_party/cppcodec/cppcodec/base32_default_crockford.hpp create mode 100644 src/third_party/cppcodec/cppcodec/base32_default_hex.hpp create mode 100644 src/third_party/cppcodec/cppcodec/base32_default_rfc4648.hpp create mode 100644 src/third_party/cppcodec/cppcodec/base32_hex.hpp create mode 100644 src/third_party/cppcodec/cppcodec/base32_rfc4648.hpp create mode 100644 src/third_party/cppcodec/cppcodec/base64_default_rfc4648.hpp create mode 100644 src/third_party/cppcodec/cppcodec/base64_default_url.hpp create mode 100644 src/third_party/cppcodec/cppcodec/base64_default_url_unpadded.hpp create mode 100644 src/third_party/cppcodec/cppcodec/base64_rfc4648.hpp create mode 100644 src/third_party/cppcodec/cppcodec/base64_url.hpp create mode 100644 src/third_party/cppcodec/cppcodec/base64_url_unpadded.hpp create mode 100644 src/third_party/cppcodec/cppcodec/data/access.hpp create mode 100644 src/third_party/cppcodec/cppcodec/data/raw_result_buffer.hpp create mode 100644 src/third_party/cppcodec/cppcodec/detail/base32.hpp create mode 100644 src/third_party/cppcodec/cppcodec/detail/base64.hpp create mode 100644 src/third_party/cppcodec/cppcodec/detail/codec.hpp create mode 100644 src/third_party/cppcodec/cppcodec/detail/config.hpp create mode 100644 src/third_party/cppcodec/cppcodec/detail/hex.hpp create mode 100644 src/third_party/cppcodec/cppcodec/detail/stream_codec.hpp create mode 100644 src/third_party/cppcodec/cppcodec/hex_default_lower.hpp create mode 100644 src/third_party/cppcodec/cppcodec/hex_default_upper.hpp create mode 100644 src/third_party/cppcodec/cppcodec/hex_lower.hpp create mode 100644 src/third_party/cppcodec/cppcodec/hex_upper.hpp create mode 100644 src/third_party/cppcodec/cppcodec/parse_error.hpp create mode 100644 src/third_party/cppcodec/example/CMakeLists.txt create mode 100644 src/third_party/cppcodec/example/helloworld.cpp create mode 100644 src/third_party/cppcodec/example/type_support_wrapper.cpp create mode 100644 src/third_party/cppcodec/test/CMakeLists.txt create mode 100644 src/third_party/cppcodec/test/benchmark_cppcodec.cpp create mode 100644 src/third_party/cppcodec/test/catch/.gitattributes create mode 100644 src/third_party/cppcodec/test/catch/.github/issue_template.md create mode 100644 src/third_party/cppcodec/test/catch/.github/pull_request_template.md create mode 100644 src/third_party/cppcodec/test/catch/.gitignore create mode 100644 src/third_party/cppcodec/test/catch/.travis.yml create mode 100644 src/third_party/cppcodec/test/catch/CMake/Catch2Config.cmake.in create mode 100644 src/third_party/cppcodec/test/catch/CMake/FindGcov.cmake create mode 100644 src/third_party/cppcodec/test/catch/CMake/FindLcov.cmake create mode 100644 src/third_party/cppcodec/test/catch/CMake/Findcodecov.cmake create mode 100644 src/third_party/cppcodec/test/catch/CMake/MiscFunctions.cmake create mode 100644 src/third_party/cppcodec/test/catch/CMake/catch2.pc.in create mode 100755 src/third_party/cppcodec/test/catch/CMake/llvm-cov-wrapper create mode 100644 src/third_party/cppcodec/test/catch/CMakeLists.txt create mode 100644 src/third_party/cppcodec/test/catch/CODE_OF_CONDUCT.md create mode 100644 src/third_party/cppcodec/test/catch/LICENSE.txt create mode 100644 src/third_party/cppcodec/test/catch/README.md create mode 100644 src/third_party/cppcodec/test/catch/appveyor.yml create mode 100644 src/third_party/cppcodec/test/catch/artwork/catch2-c-logo.png create mode 100644 src/third_party/cppcodec/test/catch/artwork/catch2-hand-logo.png create mode 100644 src/third_party/cppcodec/test/catch/artwork/catch2-logo-small.png create mode 100644 src/third_party/cppcodec/test/catch/codecov.yml create mode 100644 src/third_party/cppcodec/test/catch/conanfile.py create mode 100644 src/third_party/cppcodec/test/catch/contrib/Catch.cmake create mode 100644 src/third_party/cppcodec/test/catch/contrib/CatchAddTests.cmake create mode 100644 src/third_party/cppcodec/test/catch/contrib/ParseAndAddCatchTests.cmake create mode 100644 src/third_party/cppcodec/test/catch/contrib/gdbinit create mode 100644 src/third_party/cppcodec/test/catch/contrib/lldbinit create mode 100644 src/third_party/cppcodec/test/catch/docs/Readme.md create mode 100644 src/third_party/cppcodec/test/catch/docs/assertions.md create mode 100644 src/third_party/cppcodec/test/catch/docs/ci-and-misc.md create mode 100644 src/third_party/cppcodec/test/catch/docs/cmake-integration.md create mode 100644 src/third_party/cppcodec/test/catch/docs/command-line.md create mode 100644 src/third_party/cppcodec/test/catch/docs/commercial-users.md create mode 100644 src/third_party/cppcodec/test/catch/docs/configuration.md create mode 100644 src/third_party/cppcodec/test/catch/docs/contributing.md create mode 100644 src/third_party/cppcodec/test/catch/docs/event-listeners.md create mode 100644 src/third_party/cppcodec/test/catch/docs/limitations.md create mode 100644 src/third_party/cppcodec/test/catch/docs/list-of-examples.md create mode 100644 src/third_party/cppcodec/test/catch/docs/logging.md create mode 100644 src/third_party/cppcodec/test/catch/docs/matchers.md create mode 100644 src/third_party/cppcodec/test/catch/docs/opensource-users.md create mode 100644 src/third_party/cppcodec/test/catch/docs/own-main.md create mode 100644 src/third_party/cppcodec/test/catch/docs/release-notes.md create mode 100644 src/third_party/cppcodec/test/catch/docs/release-process.md create mode 100644 src/third_party/cppcodec/test/catch/docs/reporters.md create mode 100644 src/third_party/cppcodec/test/catch/docs/slow-compiles.md create mode 100644 src/third_party/cppcodec/test/catch/docs/test-cases-and-sections.md create mode 100644 src/third_party/cppcodec/test/catch/docs/test-fixtures.md create mode 100644 src/third_party/cppcodec/test/catch/docs/tostring.md create mode 100644 src/third_party/cppcodec/test/catch/docs/tutorial.md create mode 100644 src/third_party/cppcodec/test/catch/docs/why-catch.md create mode 100644 src/third_party/cppcodec/test/catch/examples/000-CatchMain.cpp create mode 100644 src/third_party/cppcodec/test/catch/examples/010-TestCase.cpp create mode 100644 src/third_party/cppcodec/test/catch/examples/020-TestCase-1.cpp create mode 100644 src/third_party/cppcodec/test/catch/examples/020-TestCase-2.cpp create mode 100644 src/third_party/cppcodec/test/catch/examples/030-Asn-Require-Check.cpp create mode 100644 src/third_party/cppcodec/test/catch/examples/100-Fix-Section.cpp create mode 100644 src/third_party/cppcodec/test/catch/examples/110-Fix-ClassFixture.cpp create mode 100644 src/third_party/cppcodec/test/catch/examples/120-Bdd-ScenarioGivenWhenThen.cpp create mode 100644 src/third_party/cppcodec/test/catch/examples/210-Evt-EventListeners.cpp create mode 100644 src/third_party/cppcodec/test/catch/examples/231-Cfg-OutputStreams.cpp create mode 100644 src/third_party/cppcodec/test/catch/examples/CMakeLists.txt create mode 100644 src/third_party/cppcodec/test/catch/include/catch.hpp create mode 100644 src/third_party/cppcodec/test/catch/include/catch_with_main.hpp create mode 100644 src/third_party/cppcodec/test/catch/include/external/clara.hpp create mode 100644 src/third_party/cppcodec/test/catch/include/internal/catch_approx.cpp create mode 100644 src/third_party/cppcodec/test/catch/include/internal/catch_approx.h create mode 100644 src/third_party/cppcodec/test/catch/include/internal/catch_assertionhandler.cpp create mode 100644 src/third_party/cppcodec/test/catch/include/internal/catch_assertionhandler.h create mode 100644 src/third_party/cppcodec/test/catch/include/internal/catch_assertioninfo.h create mode 100644 src/third_party/cppcodec/test/catch/include/internal/catch_assertionresult.cpp create mode 100644 src/third_party/cppcodec/test/catch/include/internal/catch_assertionresult.h create mode 100644 src/third_party/cppcodec/test/catch/include/internal/catch_benchmark.cpp create mode 100644 src/third_party/cppcodec/test/catch/include/internal/catch_benchmark.h create mode 100644 src/third_party/cppcodec/test/catch/include/internal/catch_capture.hpp create mode 100644 src/third_party/cppcodec/test/catch/include/internal/catch_capture_matchers.cpp create mode 100644 src/third_party/cppcodec/test/catch/include/internal/catch_capture_matchers.h create mode 100644 src/third_party/cppcodec/test/catch/include/internal/catch_clara.h create mode 100644 src/third_party/cppcodec/test/catch/include/internal/catch_commandline.cpp create mode 100644 src/third_party/cppcodec/test/catch/include/internal/catch_commandline.h create mode 100644 src/third_party/cppcodec/test/catch/include/internal/catch_common.cpp create mode 100644 src/third_party/cppcodec/test/catch/include/internal/catch_common.h create mode 100644 src/third_party/cppcodec/test/catch/include/internal/catch_compiler_capabilities.h create mode 100644 src/third_party/cppcodec/test/catch/include/internal/catch_config.cpp create mode 100644 src/third_party/cppcodec/test/catch/include/internal/catch_config.hpp create mode 100644 src/third_party/cppcodec/test/catch/include/internal/catch_console_colour.cpp create mode 100644 src/third_party/cppcodec/test/catch/include/internal/catch_console_colour.h create mode 100644 src/third_party/cppcodec/test/catch/include/internal/catch_context.cpp create mode 100644 src/third_party/cppcodec/test/catch/include/internal/catch_context.h create mode 100644 src/third_party/cppcodec/test/catch/include/internal/catch_debug_console.cpp create mode 100644 src/third_party/cppcodec/test/catch/include/internal/catch_debug_console.h create mode 100644 src/third_party/cppcodec/test/catch/include/internal/catch_debugger.cpp create mode 100644 src/third_party/cppcodec/test/catch/include/internal/catch_debugger.h create mode 100644 src/third_party/cppcodec/test/catch/include/internal/catch_decomposer.cpp create mode 100644 src/third_party/cppcodec/test/catch/include/internal/catch_decomposer.h create mode 100644 src/third_party/cppcodec/test/catch/include/internal/catch_default_main.hpp create mode 100644 src/third_party/cppcodec/test/catch/include/internal/catch_enforce.h create mode 100644 src/third_party/cppcodec/test/catch/include/internal/catch_errno_guard.cpp create mode 100644 src/third_party/cppcodec/test/catch/include/internal/catch_errno_guard.h create mode 100644 src/third_party/cppcodec/test/catch/include/internal/catch_exception_translator_registry.cpp create mode 100644 src/third_party/cppcodec/test/catch/include/internal/catch_exception_translator_registry.h create mode 100644 src/third_party/cppcodec/test/catch/include/internal/catch_external_interfaces.h create mode 100644 src/third_party/cppcodec/test/catch/include/internal/catch_fatal_condition.cpp create mode 100644 src/third_party/cppcodec/test/catch/include/internal/catch_fatal_condition.h create mode 100644 src/third_party/cppcodec/test/catch/include/internal/catch_impl.hpp create mode 100644 src/third_party/cppcodec/test/catch/include/internal/catch_interfaces_capture.cpp create mode 100644 src/third_party/cppcodec/test/catch/include/internal/catch_interfaces_capture.h create mode 100644 src/third_party/cppcodec/test/catch/include/internal/catch_interfaces_config.cpp create mode 100644 src/third_party/cppcodec/test/catch/include/internal/catch_interfaces_config.h create mode 100644 src/third_party/cppcodec/test/catch/include/internal/catch_interfaces_exception.cpp create mode 100644 src/third_party/cppcodec/test/catch/include/internal/catch_interfaces_exception.h create mode 100644 src/third_party/cppcodec/test/catch/include/internal/catch_interfaces_registry_hub.cpp create mode 100644 src/third_party/cppcodec/test/catch/include/internal/catch_interfaces_registry_hub.h create mode 100644 src/third_party/cppcodec/test/catch/include/internal/catch_interfaces_reporter.cpp create mode 100644 src/third_party/cppcodec/test/catch/include/internal/catch_interfaces_reporter.h create mode 100644 src/third_party/cppcodec/test/catch/include/internal/catch_interfaces_runner.cpp create mode 100644 src/third_party/cppcodec/test/catch/include/internal/catch_interfaces_runner.h create mode 100644 src/third_party/cppcodec/test/catch/include/internal/catch_interfaces_tag_alias_registry.h create mode 100644 src/third_party/cppcodec/test/catch/include/internal/catch_interfaces_testcase.cpp create mode 100644 src/third_party/cppcodec/test/catch/include/internal/catch_interfaces_testcase.h create mode 100644 src/third_party/cppcodec/test/catch/include/internal/catch_leak_detector.cpp create mode 100644 src/third_party/cppcodec/test/catch/include/internal/catch_leak_detector.h create mode 100644 src/third_party/cppcodec/test/catch/include/internal/catch_list.cpp create mode 100644 src/third_party/cppcodec/test/catch/include/internal/catch_list.h create mode 100644 src/third_party/cppcodec/test/catch/include/internal/catch_matchers.cpp create mode 100644 src/third_party/cppcodec/test/catch/include/internal/catch_matchers.h create mode 100644 src/third_party/cppcodec/test/catch/include/internal/catch_matchers_floating.cpp create mode 100644 src/third_party/cppcodec/test/catch/include/internal/catch_matchers_floating.h create mode 100644 src/third_party/cppcodec/test/catch/include/internal/catch_matchers_generic.cpp create mode 100644 src/third_party/cppcodec/test/catch/include/internal/catch_matchers_generic.hpp create mode 100644 src/third_party/cppcodec/test/catch/include/internal/catch_matchers_string.cpp create mode 100644 src/third_party/cppcodec/test/catch/include/internal/catch_matchers_string.h create mode 100644 src/third_party/cppcodec/test/catch/include/internal/catch_matchers_vector.h create mode 100644 src/third_party/cppcodec/test/catch/include/internal/catch_message.cpp create mode 100644 src/third_party/cppcodec/test/catch/include/internal/catch_message.h create mode 100644 src/third_party/cppcodec/test/catch/include/internal/catch_objc.hpp create mode 100644 src/third_party/cppcodec/test/catch/include/internal/catch_objc_arc.hpp create mode 100644 src/third_party/cppcodec/test/catch/include/internal/catch_option.hpp create mode 100644 src/third_party/cppcodec/test/catch/include/internal/catch_output_redirect.cpp create mode 100644 src/third_party/cppcodec/test/catch/include/internal/catch_output_redirect.h create mode 100644 src/third_party/cppcodec/test/catch/include/internal/catch_platform.h create mode 100644 src/third_party/cppcodec/test/catch/include/internal/catch_random_number_generator.cpp create mode 100644 src/third_party/cppcodec/test/catch/include/internal/catch_random_number_generator.h create mode 100644 src/third_party/cppcodec/test/catch/include/internal/catch_reenable_warnings.h create mode 100644 src/third_party/cppcodec/test/catch/include/internal/catch_registry_hub.cpp create mode 100644 src/third_party/cppcodec/test/catch/include/internal/catch_reporter_registrars.hpp create mode 100644 src/third_party/cppcodec/test/catch/include/internal/catch_reporter_registry.cpp create mode 100644 src/third_party/cppcodec/test/catch/include/internal/catch_reporter_registry.h create mode 100644 src/third_party/cppcodec/test/catch/include/internal/catch_result_type.cpp create mode 100644 src/third_party/cppcodec/test/catch/include/internal/catch_result_type.h create mode 100644 src/third_party/cppcodec/test/catch/include/internal/catch_run_context.cpp create mode 100644 src/third_party/cppcodec/test/catch/include/internal/catch_run_context.h create mode 100644 src/third_party/cppcodec/test/catch/include/internal/catch_section.cpp create mode 100644 src/third_party/cppcodec/test/catch/include/internal/catch_section.h create mode 100644 src/third_party/cppcodec/test/catch/include/internal/catch_section_info.cpp create mode 100644 src/third_party/cppcodec/test/catch/include/internal/catch_section_info.h create mode 100644 src/third_party/cppcodec/test/catch/include/internal/catch_session.cpp create mode 100644 src/third_party/cppcodec/test/catch/include/internal/catch_session.h create mode 100644 src/third_party/cppcodec/test/catch/include/internal/catch_startup_exception_registry.cpp create mode 100644 src/third_party/cppcodec/test/catch/include/internal/catch_startup_exception_registry.h create mode 100644 src/third_party/cppcodec/test/catch/include/internal/catch_stream.cpp create mode 100644 src/third_party/cppcodec/test/catch/include/internal/catch_stream.h create mode 100644 src/third_party/cppcodec/test/catch/include/internal/catch_string_manip.cpp create mode 100644 src/third_party/cppcodec/test/catch/include/internal/catch_string_manip.h create mode 100644 src/third_party/cppcodec/test/catch/include/internal/catch_stringref.cpp create mode 100644 src/third_party/cppcodec/test/catch/include/internal/catch_stringref.h create mode 100644 src/third_party/cppcodec/test/catch/include/internal/catch_suppress_warnings.h create mode 100644 src/third_party/cppcodec/test/catch/include/internal/catch_tag_alias.cpp create mode 100644 src/third_party/cppcodec/test/catch/include/internal/catch_tag_alias.h create mode 100644 src/third_party/cppcodec/test/catch/include/internal/catch_tag_alias_autoregistrar.cpp create mode 100644 src/third_party/cppcodec/test/catch/include/internal/catch_tag_alias_autoregistrar.h create mode 100644 src/third_party/cppcodec/test/catch/include/internal/catch_tag_alias_registry.cpp create mode 100644 src/third_party/cppcodec/test/catch/include/internal/catch_tag_alias_registry.h create mode 100644 src/third_party/cppcodec/test/catch/include/internal/catch_test_case_info.cpp create mode 100644 src/third_party/cppcodec/test/catch/include/internal/catch_test_case_info.h create mode 100644 src/third_party/cppcodec/test/catch/include/internal/catch_test_case_registry_impl.cpp create mode 100644 src/third_party/cppcodec/test/catch/include/internal/catch_test_case_registry_impl.h create mode 100644 src/third_party/cppcodec/test/catch/include/internal/catch_test_case_tracker.cpp create mode 100644 src/third_party/cppcodec/test/catch/include/internal/catch_test_case_tracker.h create mode 100644 src/third_party/cppcodec/test/catch/include/internal/catch_test_registry.cpp create mode 100644 src/third_party/cppcodec/test/catch/include/internal/catch_test_registry.h create mode 100644 src/third_party/cppcodec/test/catch/include/internal/catch_test_spec.cpp create mode 100644 src/third_party/cppcodec/test/catch/include/internal/catch_test_spec.h create mode 100644 src/third_party/cppcodec/test/catch/include/internal/catch_test_spec_parser.cpp create mode 100644 src/third_party/cppcodec/test/catch/include/internal/catch_test_spec_parser.h create mode 100644 src/third_party/cppcodec/test/catch/include/internal/catch_text.h create mode 100644 src/third_party/cppcodec/test/catch/include/internal/catch_timer.cpp create mode 100644 src/third_party/cppcodec/test/catch/include/internal/catch_timer.h create mode 100644 src/third_party/cppcodec/test/catch/include/internal/catch_to_string.hpp create mode 100644 src/third_party/cppcodec/test/catch/include/internal/catch_tostring.cpp create mode 100644 src/third_party/cppcodec/test/catch/include/internal/catch_tostring.h create mode 100644 src/third_party/cppcodec/test/catch/include/internal/catch_totals.cpp create mode 100644 src/third_party/cppcodec/test/catch/include/internal/catch_totals.h create mode 100644 src/third_party/cppcodec/test/catch/include/internal/catch_uncaught_exceptions.cpp create mode 100644 src/third_party/cppcodec/test/catch/include/internal/catch_uncaught_exceptions.h create mode 100644 src/third_party/cppcodec/test/catch/include/internal/catch_user_interfaces.h create mode 100644 src/third_party/cppcodec/test/catch/include/internal/catch_version.cpp create mode 100644 src/third_party/cppcodec/test/catch/include/internal/catch_version.h create mode 100644 src/third_party/cppcodec/test/catch/include/internal/catch_wildcard_pattern.cpp create mode 100644 src/third_party/cppcodec/test/catch/include/internal/catch_wildcard_pattern.h create mode 100644 src/third_party/cppcodec/test/catch/include/internal/catch_windows_h_proxy.h create mode 100644 src/third_party/cppcodec/test/catch/include/internal/catch_xmlwriter.cpp create mode 100644 src/third_party/cppcodec/test/catch/include/internal/catch_xmlwriter.h create mode 100644 src/third_party/cppcodec/test/catch/include/reporters/catch_reporter_automake.hpp create mode 100644 src/third_party/cppcodec/test/catch/include/reporters/catch_reporter_bases.cpp create mode 100644 src/third_party/cppcodec/test/catch/include/reporters/catch_reporter_bases.hpp create mode 100644 src/third_party/cppcodec/test/catch/include/reporters/catch_reporter_compact.cpp create mode 100644 src/third_party/cppcodec/test/catch/include/reporters/catch_reporter_compact.h create mode 100644 src/third_party/cppcodec/test/catch/include/reporters/catch_reporter_console.cpp create mode 100644 src/third_party/cppcodec/test/catch/include/reporters/catch_reporter_console.h create mode 100644 src/third_party/cppcodec/test/catch/include/reporters/catch_reporter_junit.cpp create mode 100644 src/third_party/cppcodec/test/catch/include/reporters/catch_reporter_junit.h create mode 100644 src/third_party/cppcodec/test/catch/include/reporters/catch_reporter_listening.cpp create mode 100644 src/third_party/cppcodec/test/catch/include/reporters/catch_reporter_listening.h create mode 100644 src/third_party/cppcodec/test/catch/include/reporters/catch_reporter_tap.hpp create mode 100644 src/third_party/cppcodec/test/catch/include/reporters/catch_reporter_teamcity.hpp create mode 100644 src/third_party/cppcodec/test/catch/include/reporters/catch_reporter_xml.cpp create mode 100644 src/third_party/cppcodec/test/catch/include/reporters/catch_reporter_xml.h create mode 100644 src/third_party/cppcodec/test/catch/misc/CMakeLists.txt create mode 100644 src/third_party/cppcodec/test/catch/misc/appveyorBuildConfigurationScript.bat create mode 100644 src/third_party/cppcodec/test/catch/misc/appveyorMergeCoverageScript.py create mode 100644 src/third_party/cppcodec/test/catch/misc/appveyorTestRunScript.bat create mode 100644 src/third_party/cppcodec/test/catch/misc/coverage-helper.cpp create mode 100644 src/third_party/cppcodec/test/catch/misc/installOpenCppCoverage.ps1 create mode 100644 src/third_party/cppcodec/test/catch/projects/CMakeLists.txt create mode 100644 src/third_party/cppcodec/test/catch/projects/SelfTest/Baselines/automake.std.approved.txt create mode 100644 src/third_party/cppcodec/test/catch/projects/SelfTest/Baselines/compact.sw.approved.txt create mode 100644 src/third_party/cppcodec/test/catch/projects/SelfTest/Baselines/console.std.approved.txt create mode 100644 src/third_party/cppcodec/test/catch/projects/SelfTest/Baselines/console.sw.approved.txt create mode 100644 src/third_party/cppcodec/test/catch/projects/SelfTest/Baselines/console.swa4.approved.txt create mode 100644 src/third_party/cppcodec/test/catch/projects/SelfTest/Baselines/junit.sw.approved.txt create mode 100644 src/third_party/cppcodec/test/catch/projects/SelfTest/Baselines/xml.sw.approved.txt create mode 100644 src/third_party/cppcodec/test/catch/projects/SelfTest/CompileTimePerfTests/10.tests.cpp create mode 100644 src/third_party/cppcodec/test/catch/projects/SelfTest/CompileTimePerfTests/100.tests.cpp create mode 100644 src/third_party/cppcodec/test/catch/projects/SelfTest/CompileTimePerfTests/All.tests.cpp create mode 100644 src/third_party/cppcodec/test/catch/projects/SelfTest/IntrospectiveTests/CmdLine.tests.cpp create mode 100644 src/third_party/cppcodec/test/catch/projects/SelfTest/IntrospectiveTests/PartTracker.tests.cpp create mode 100644 src/third_party/cppcodec/test/catch/projects/SelfTest/IntrospectiveTests/String.tests.cpp create mode 100644 src/third_party/cppcodec/test/catch/projects/SelfTest/IntrospectiveTests/TagAlias.tests.cpp create mode 100644 src/third_party/cppcodec/test/catch/projects/SelfTest/IntrospectiveTests/Xml.tests.cpp create mode 100644 src/third_party/cppcodec/test/catch/projects/SelfTest/SurrogateCpps/catch_console_colour.cpp create mode 100644 src/third_party/cppcodec/test/catch/projects/SelfTest/SurrogateCpps/catch_debugger.cpp create mode 100644 src/third_party/cppcodec/test/catch/projects/SelfTest/SurrogateCpps/catch_interfaces_reporter.cpp create mode 100644 src/third_party/cppcodec/test/catch/projects/SelfTest/SurrogateCpps/catch_option.cpp create mode 100644 src/third_party/cppcodec/test/catch/projects/SelfTest/SurrogateCpps/catch_stream.cpp create mode 100644 src/third_party/cppcodec/test/catch/projects/SelfTest/SurrogateCpps/catch_test_case_tracker.cpp create mode 100644 src/third_party/cppcodec/test/catch/projects/SelfTest/SurrogateCpps/catch_test_spec.cpp create mode 100644 src/third_party/cppcodec/test/catch/projects/SelfTest/SurrogateCpps/catch_xmlwriter.cpp create mode 100644 src/third_party/cppcodec/test/catch/projects/SelfTest/TestMain.cpp create mode 100644 src/third_party/cppcodec/test/catch/projects/SelfTest/UsageTests/Approx.tests.cpp create mode 100644 src/third_party/cppcodec/test/catch/projects/SelfTest/UsageTests/BDD.tests.cpp create mode 100644 src/third_party/cppcodec/test/catch/projects/SelfTest/UsageTests/Benchmark.tests.cpp create mode 100644 src/third_party/cppcodec/test/catch/projects/SelfTest/UsageTests/Class.tests.cpp create mode 100644 src/third_party/cppcodec/test/catch/projects/SelfTest/UsageTests/Compilation.tests.cpp create mode 100644 src/third_party/cppcodec/test/catch/projects/SelfTest/UsageTests/Condition.tests.cpp create mode 100644 src/third_party/cppcodec/test/catch/projects/SelfTest/UsageTests/Decomposition.tests.cpp create mode 100644 src/third_party/cppcodec/test/catch/projects/SelfTest/UsageTests/EnumToString.tests.cpp create mode 100644 src/third_party/cppcodec/test/catch/projects/SelfTest/UsageTests/Exception.tests.cpp create mode 100644 src/third_party/cppcodec/test/catch/projects/SelfTest/UsageTests/Matchers.tests.cpp create mode 100644 src/third_party/cppcodec/test/catch/projects/SelfTest/UsageTests/Message.tests.cpp create mode 100644 src/third_party/cppcodec/test/catch/projects/SelfTest/UsageTests/Misc.tests.cpp create mode 100644 src/third_party/cppcodec/test/catch/projects/SelfTest/UsageTests/ToStringChrono.tests.cpp create mode 100644 src/third_party/cppcodec/test/catch/projects/SelfTest/UsageTests/ToStringGeneral.tests.cpp create mode 100644 src/third_party/cppcodec/test/catch/projects/SelfTest/UsageTests/ToStringPair.tests.cpp create mode 100644 src/third_party/cppcodec/test/catch/projects/SelfTest/UsageTests/ToStringTuple.tests.cpp create mode 100644 src/third_party/cppcodec/test/catch/projects/SelfTest/UsageTests/ToStringVector.tests.cpp create mode 100644 src/third_party/cppcodec/test/catch/projects/SelfTest/UsageTests/ToStringWhich.tests.cpp create mode 100644 src/third_party/cppcodec/test/catch/projects/SelfTest/UsageTests/Tricky.tests.cpp create mode 100644 src/third_party/cppcodec/test/catch/projects/SelfTest/UsageTests/VariadicMacros.tests.cpp create mode 100644 src/third_party/cppcodec/test/catch/projects/Where did the projects go.txt create mode 100644 src/third_party/cppcodec/test/catch/projects/XCode/OCTest/OCTest.xcodeproj/project.pbxproj create mode 100644 src/third_party/cppcodec/test/catch/projects/XCode/OCTest/OCTest.xcodeproj/project.xcworkspace/contents.xcworkspacedata create mode 100644 src/third_party/cppcodec/test/catch/projects/XCode/OCTest/OCTest/CatchOCTestCase.h create mode 100644 src/third_party/cppcodec/test/catch/projects/XCode/OCTest/OCTest/CatchOCTestCase.mm create mode 100644 src/third_party/cppcodec/test/catch/projects/XCode/OCTest/OCTest/Main.mm create mode 100644 src/third_party/cppcodec/test/catch/projects/XCode/OCTest/OCTest/OCTest.1 create mode 100644 src/third_party/cppcodec/test/catch/projects/XCode/OCTest/OCTest/OCTest.mm create mode 100644 src/third_party/cppcodec/test/catch/projects/XCode/OCTest/OCTest/TestObj.h create mode 100644 src/third_party/cppcodec/test/catch/projects/XCode/OCTest/OCTest/TestObj.m create mode 100644 src/third_party/cppcodec/test/catch/projects/XCode/OCTest/catch_objc_impl.mm create mode 100755 src/third_party/cppcodec/test/catch/scripts/approvalTests.py create mode 100755 src/third_party/cppcodec/test/catch/scripts/approve.py create mode 100755 src/third_party/cppcodec/test/catch/scripts/benchmarkCompile.py create mode 100755 src/third_party/cppcodec/test/catch/scripts/benchmarkRunner.py create mode 100755 src/third_party/cppcodec/test/catch/scripts/developBuild.py create mode 100644 src/third_party/cppcodec/test/catch/scripts/embed.py create mode 100755 src/third_party/cppcodec/test/catch/scripts/embedClara.py create mode 100755 src/third_party/cppcodec/test/catch/scripts/fixWhitespace.py create mode 100755 src/third_party/cppcodec/test/catch/scripts/generateSingleHeader.py create mode 100755 src/third_party/cppcodec/test/catch/scripts/majorRelease.py create mode 100755 src/third_party/cppcodec/test/catch/scripts/minorRelease.py create mode 100755 src/third_party/cppcodec/test/catch/scripts/patchRelease.py create mode 100644 src/third_party/cppcodec/test/catch/scripts/releaseCommon.py create mode 100755 src/third_party/cppcodec/test/catch/scripts/releaseNotes.py create mode 100644 src/third_party/cppcodec/test/catch/scripts/scriptCommon.py create mode 100644 src/third_party/cppcodec/test/catch/scripts/updateDocumentToC.py create mode 100644 src/third_party/cppcodec/test/catch/scripts/updateWandbox.py create mode 100644 src/third_party/cppcodec/test/catch/single_include/catch2/catch.hpp create mode 100644 src/third_party/cppcodec/test/catch/single_include/catch2/catch_reporter_automake.hpp create mode 100644 src/third_party/cppcodec/test/catch/single_include/catch2/catch_reporter_tap.hpp create mode 100644 src/third_party/cppcodec/test/catch/single_include/catch2/catch_reporter_teamcity.hpp create mode 100644 src/third_party/cppcodec/test/catch/test_package/CMakeLists.txt create mode 100644 src/third_party/cppcodec/test/catch/test_package/MainTest.cpp create mode 100644 src/third_party/cppcodec/test/catch/test_package/conanfile.py create mode 100644 src/third_party/cppcodec/test/catch/third_party/clara.hpp create mode 100644 src/third_party/cppcodec/test/minimal_decode.cpp create mode 100644 src/third_party/cppcodec/test/test_cppcodec.cpp create mode 100644 src/third_party/cppcodec/tool/CMakeLists.txt create mode 100644 src/third_party/cppcodec/tool/base32dec.cpp create mode 100644 src/third_party/cppcodec/tool/base32enc.cpp create mode 100644 src/third_party/cppcodec/tool/base64dec.cpp create mode 100644 src/third_party/cppcodec/tool/base64enc.cpp create mode 100644 src/third_party/cppcodec/tool/hexdec.cpp create mode 100644 src/third_party/cppcodec/tool/hexenc.cpp create mode 100644 src/third_party/simple-beast-client/CMakeLists.txt create mode 100644 src/third_party/simple-beast-client/LICENSE create mode 100644 src/third_party/simple-beast-client/README.md create mode 100644 src/third_party/simple-beast-client/cmake/Findcppcodec.cmake create mode 100644 src/third_party/simple-beast-client/cmake/modules/Findcppcodec.cmake create mode 100644 src/third_party/simple-beast-client/cmake/public_modules/Findcppcodec.cmake create mode 100644 src/third_party/simple-beast-client/cmake/simple-beast-client-config.cmake create mode 100644 src/third_party/simple-beast-client/example/CMakeLists.txt create mode 100644 src/third_party/simple-beast-client/example/main.cpp create mode 100644 src/third_party/simple-beast-client/include/simple-beast-client/client_private.hpp create mode 100644 src/third_party/simple-beast-client/include/simple-beast-client/client_private_http.hpp create mode 100644 src/third_party/simple-beast-client/include/simple-beast-client/client_private_ssl.hpp create mode 100644 src/third_party/simple-beast-client/include/simple-beast-client/digestauthenticator.hpp create mode 100644 src/third_party/simple-beast-client/include/simple-beast-client/httpclient.hpp create mode 100644 src/third_party/simple-beast-client/include/simple-beast-client/url.hpp diff --git a/cmake/Findcppcodec.cmake b/cmake/Findcppcodec.cmake new file mode 100644 index 0000000000..86a6993bb8 --- /dev/null +++ b/cmake/Findcppcodec.cmake @@ -0,0 +1,14 @@ +message(${CMAKE_CURRENT_LIST_DIR}) +find_path(cppcodec_INCLUDE_DIRS "cppcodec/base32_crockford.hpp" + PATHS "${CMAKE_CURRENT_LIST_DIR}/../src/third_party/cppcodec" # We allow taking the embedded cppcodec +) +mark_as_advanced(cppcodec_INCLUDE_DIRS) + +find_package_handle_standard_args(cppcodec + REQUIRED_VARS cppcodec_INCLUDE_DIRS +) + +if(cppcodec_FOUND) + add_library(cppcodec::cppcodec IMPORTED INTERFACE) + target_include_directories(cppcodec::cppcodec INTERFACE "${cppcodec_INCLUDE_DIRS}") +endif() diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 6399f6c8c5..b8e3f44436 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -26,7 +26,7 @@ add_subdirectory(value_generators) add_subdirectory(workloads) # This makes the project importable from the build directory -export(TARGETS value_generators metrics gennylib loki cast_core poplarlib +export(TARGETS simple-beast-client value_generators metrics gennylib loki cast_core poplarlib FILE GennyLibraryConfig.cmake) # Below generates a cmake module so if you make install from this diff --git a/src/cast_core/CMakeLists.txt b/src/cast_core/CMakeLists.txt index 1a18e5d18d..b31ba3534b 100644 --- a/src/cast_core/CMakeLists.txt +++ b/src/cast_core/CMakeLists.txt @@ -14,10 +14,14 @@ project(cast_core VERSION 0.0.1 LANGUAGES CXX) +find_package(cppcodec) + CreateGennyTargets( NAME cast_core TYPE SHARED DEPENDS gennylib + cppcodec::cppcodec + simple-beast-client TEST_DEPENDS testlib ) diff --git a/src/cast_core/include/cast_core/actors/SampleHttpClient.hpp b/src/cast_core/include/cast_core/actors/SampleHttpClient.hpp new file mode 100644 index 0000000000..758e91600d --- /dev/null +++ b/src/cast_core/include/cast_core/actors/SampleHttpClient.hpp @@ -0,0 +1,54 @@ +// Copyright 2022-present MongoDB Inc. +// +// Licensed 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. + +#ifndef HEADER_F39B7C7C_1002_4060_AAEE_F379AEE7AB3C_INCLUDED +#define HEADER_F39B7C7C_1002_4060_AAEE_F379AEE7AB3C_INCLUDED + +#include + +#include + +#include +#include +#include + +#include + +namespace genny::actor { + +class SampleHttpClient : public Actor { + +public: + explicit SampleHttpClient(ActorContext& context); + ~SampleHttpClient() = default; + + void run() override; + + static std::string_view defaultName() { + return "SampleHttpClient"; + } + +private: + mongocxx::pool::entry _client; + + genny::metrics::Operation _totalRequests; + + /** @private */ + struct PhaseConfig; + PhaseLoop _loop; +}; + +} // namespace genny::actor + +#endif // HEADER_F39B7C7C_1002_4060_AAEE_F379AEE7AB3C_INCLUDED diff --git a/src/cast_core/src/SampleHttpClient.cpp b/src/cast_core/src/SampleHttpClient.cpp new file mode 100644 index 0000000000..47110fb9ba --- /dev/null +++ b/src/cast_core/src/SampleHttpClient.cpp @@ -0,0 +1,117 @@ +// Copyright 2022-present MongoDB Inc. +// +// Licensed 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 + +#include + +#include + +#include + +#include +#include +#include + +#include +#include + +#include +#include +#include + +#include +#include + + +namespace genny::actor { + +struct SampleHttpClient::PhaseConfig { + mongocxx::database database; + + mongocxx::collection collection; + + DocumentGenerator documentExpr; + + PhaseConfig(PhaseContext& phaseContext, mongocxx::database&& db, ActorId id) + : database{db}, + collection{database[phaseContext["Collection"].to()]}, + documentExpr{phaseContext["Document"].to(phaseContext, id)} {} +}; + + +void SampleHttpClient::run() { + for (auto&& config : _loop) { + for (const auto&& _ : config) { + auto document = config->documentExpr(); + + auto requests = _totalRequests.start(); + + BOOST_LOG_TRIVIAL(debug) + << " SampleHttpClient Inserting " << bsoncxx::to_json(document.view()); + + try { + boost::asio::io_context ioContext; + auto client = std::make_shared( + ioContext, + [](simple_http::empty_body_request& /*req*/, + simple_http::string_body_response& resp) { + // noop for successful HTTP + }); + + client->setFailHandler( + [&requests](const simple_http::empty_body_request& /*req*/, + const simple_http::string_body_response& /*resp*/, + simple_http::fail_reason fr, + boost::string_view message) { + // TODO TIG-3843: this will always be triggered on macOS + // with Failure code 2, Message: Error resolving + // target: Host not found (authoritative) + BOOST_LOG_TRIVIAL(warning) << "Failure code: " << fr << std::endl; + BOOST_LOG_TRIVIAL(warning) << "Message: " << message << std::endl; + requests.failure(); + }); + + // Run the GET request to httpbin.org + client->get(simple_http::url{ + "https://user:passwd@httpbin.org/digest-auth/auth/user/passwd/MD5/never"}); + + ioContext.run(); // blocks until requests are complete. + + requests.success(); + } catch (mongocxx::operation_exception& e) { + requests.failure(); + // + // MongoException lets you include a "causing" bson document in the + // exception message for help debugging. + // + BOOST_THROW_EXCEPTION(MongoException(e, document.view())); + } catch (...) { + requests.failure(); + throw std::current_exception(); + } + } + } +} + +SampleHttpClient::SampleHttpClient(genny::ActorContext& context) + : Actor{context}, + _totalRequests{context.operation("Insert", SampleHttpClient::id())}, + _client{context.client()}, + _loop{context, (*_client)[context["Database"].to()], SampleHttpClient::id()} {} + +namespace { +auto registerSampleHttpClient = Cast::registerDefault(); +} // namespace +} // namespace genny::actor diff --git a/src/third_party/CMakeLists.txt b/src/third_party/CMakeLists.txt index f1f4d75fea..41a43441fa 100644 --- a/src/third_party/CMakeLists.txt +++ b/src/third_party/CMakeLists.txt @@ -15,4 +15,7 @@ add_subdirectory(poplar) # add_subdirectory(catch2) -# \ No newline at end of file +# + +add_subdirectory(cppcodec) +add_subdirectory(simple-beast-client) diff --git a/src/third_party/cppcodec/.gitignore b/src/third_party/cppcodec/.gitignore new file mode 100644 index 0000000000..c2afd08aa4 --- /dev/null +++ b/src/third_party/cppcodec/.gitignore @@ -0,0 +1,3 @@ +CMakeLists.txt.user +.*.swp +.DS_Store diff --git a/src/third_party/cppcodec/.gitmodules b/src/third_party/cppcodec/.gitmodules new file mode 100644 index 0000000000..6f945a7eba --- /dev/null +++ b/src/third_party/cppcodec/.gitmodules @@ -0,0 +1,3 @@ +[submodule "test/catch"] + path = test/catch + url = https://github.com/catchorg/Catch2.git diff --git a/src/third_party/cppcodec/.travis.yml b/src/third_party/cppcodec/.travis.yml new file mode 100644 index 0000000000..af2adeb639 --- /dev/null +++ b/src/third_party/cppcodec/.travis.yml @@ -0,0 +1,143 @@ +dist: trusty +language: cpp + +# sources list: https://github.com/travis-ci/apt-source-whitelist/blob/master/ubuntu.json, +# packages list: https://github.com/travis-ci/apt-package-whitelist/blob/master/ubuntu-trusty + +matrix: + include: + # Newest/oldest GCC + - os: linux + compiler: gcc + addons: + apt: + sources: [ 'ubuntu-toolchain-r-test' ] + packages: [ 'g++-7' ] + env: BUILD_TYPE=MinSizeRel GXX=7 CXX_STD=17 + + - os: linux + compiler: gcc + addons: + apt: + sources: [ 'ubuntu-toolchain-r-test' ] + packages: [ 'g++-7' ] + env: BUILD_TYPE=Release GXX=7 CXX_STD=17 + + - os: linux + compiler: gcc + addons: + apt: + sources: [ 'ubuntu-toolchain-r-test' ] + packages: [ 'g++-4.8' ] + env: BUILD_TYPE=Release GXX=4.8 + + # Newest/oldest clang + - os: linux + compiler: clang + addons: + apt: + sources: [ 'ubuntu-toolchain-r-test', 'llvm-toolchain-trusty-6.0' ] + packages: [ 'clang-6.0', 'libstdc++-7-dev', 'libstdc++6' ] # C++17 support in libstd++ + env: BUILD_TYPE=MinSizeRel CLANGXX=6.0 CXX_STD=17 + + - os: linux + compiler: clang + addons: + apt: + sources: [ 'ubuntu-toolchain-r-test', 'llvm-toolchain-trusty-6.0' ] + packages: [ 'clang-6.0', 'libstdc++-7-dev', 'libstdc++6' ] # C++17 support in libstd++ + env: BUILD_TYPE=Release CLANGXX=6.0 CXX_STD=17 + + - os: linux + compiler: clang + addons: + apt: + sources: [ 'ubuntu-toolchain-r-test', 'llvm-toolchain-precise-3.6' ] + packages: [ 'clang-3.6' ] + env: BUILD_TYPE=Release CLANGXX=3.6 + + # Other compiler versions + - os: linux + compiler: gcc + addons: + apt: + sources: [ 'ubuntu-toolchain-r-test' ] + packages: [ 'g++-7' ] + env: BUILD_TYPE=Debug GXX=7 + + - os: linux + compiler: gcc + addons: + apt: + sources: [ 'ubuntu-toolchain-r-test' ] + packages: [ 'g++-6' ] + env: BUILD_TYPE=MinSizeRel GXX=6 CXX_STD=14 + + - os: linux + compiler: gcc + addons: + apt: + sources: [ 'ubuntu-toolchain-r-test' ] + packages: [ 'g++-5' ] + env: BUILD_TYPE=Release GXX=5 + + - os: linux + compiler: gcc + addons: + apt: + sources: [ 'ubuntu-toolchain-r-test' ] + packages: [ 'g++-4.9' ] + env: BUILD_TYPE=MinSizeRel GXX=4.9 + + - os: linux + compiler: gcc + addons: + apt: + sources: [ 'ubuntu-toolchain-r-test' ] + packages: [ 'g++-4.8' ] + env: BUILD_TYPE=Debug GXX=4.8 + + - os: linux + compiler: clang + addons: + apt: + sources: [ 'ubuntu-toolchain-r-test', 'llvm-toolchain-trusty-5.0' ] + packages: [ 'clang-5.0' ] + env: BUILD_TYPE=Release CLANGXX=5.0 + + - os: linux + compiler: clang + addons: + apt: + sources: [ 'ubuntu-toolchain-r-test', 'llvm-toolchain-trusty-4.0' ] + packages: [ 'clang-4.0' ] + env: BUILD_TYPE=MinSizeRel CLANGXX=4.0 + + - os: linux + compiler: clang + addons: + apt: + sources: [ 'ubuntu-toolchain-r-test', 'llvm-toolchain-precise-3.6' ] + packages: [ 'clang-3.6' ] + env: BUILD_TYPE=Debug CLANGXX=3.6 CXX_STD=14 + +# container-based builds +sudo: false + +before_install: + - env + - export SRC_DIR="`pwd`" + - if [ "$CXX" = "g++" ]; then export CXX="g++-$GXX" CC="gcc-$GXX"; fi + - if [ "$CXX" = "clang++" ]; then export CXX="clang++-$CLANGXX" CC="clang-$CLANGXX"; fi + +script: + - $CXX --version + - cmake --version + - mkdir "$TRAVIS_BUILD_DIR/build" + - cd "$TRAVIS_BUILD_DIR/build" + - pwd + - CXX_STD_ARG=""; if [ ! -z "${CXX_STD}" ]; then CXX_STD_ARG="-DCMAKE_CXX_STANDARD=${CXX_STD}"; fi + - cmake -DCMAKE_BUILD_TYPE=${BUILD_TYPE} ${CXX_STD_ARG} "$SRC_DIR" + - make -j2 # cores according to https://docs.travis-ci.com/user/reference/overview/ + - CTEST_OUTPUT_ON_FAILURE=1 make test + - test/benchmark_cppcodec diff --git a/src/third_party/cppcodec/CMakeLists.txt b/src/third_party/cppcodec/CMakeLists.txt new file mode 100644 index 0000000000..01430f2d50 --- /dev/null +++ b/src/third_party/cppcodec/CMakeLists.txt @@ -0,0 +1,81 @@ +cmake_minimum_required(VERSION 2.8.5) +project(cppcodec CXX) +set(PROJECT_VERSION 0.1) + +include(GNUInstallDirs) +include(CTest) + +# These flags are for binaries built by this particular CMake project (test_cppcodec, base64enc, etc.). +# In your own project that uses cppcodec, you might want to specify a different standard or error level. + +# Request C++11, or let the user specify the standard on via -D command line option. +if (NOT CMAKE_CXX_STANDARD) + set(CMAKE_CXX_STANDARD 11) +endif() +set(CMAKE_CXX_STANDARD_REQUIRED ON) +set(CMAKE_CXX_EXTENSIONS OFF) + +if (MSVC) + # MSVC will respect CMAKE_CXX_STANDARD for CMake >= 3.10 and MSVC >= 19.0.24215 + # (VS 2017 15.3). Older versions will use the compiler default, which should be + # fine for anything except ancient MSVC versions. + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /W4") +else() + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -Wextra -pedantic") + + # CMake versions before 3.1 do not understand CMAKE_CXX_STANDARD. + # Remove this block once CMake >=3.1 has fixated in the ecosystem. + if(${CMAKE_VERSION} VERSION_LESS 3.1) + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++${CMAKE_CXX_STANDARD}") + endif() +endif() + +set(PUBLIC_HEADERS + # base32 + cppcodec/base32_crockford.hpp + cppcodec/base32_default_crockford.hpp + cppcodec/base32_default_hex.hpp + cppcodec/base32_default_rfc4648.hpp + cppcodec/base32_hex.hpp + cppcodec/base32_rfc4648.hpp + # base64 + cppcodec/base64_default_rfc4648.hpp + cppcodec/base64_default_url.hpp + cppcodec/base64_default_url_unpadded.hpp + cppcodec/base64_rfc4648.hpp + cppcodec/base64_url.hpp + cppcodec/base64_url_unpadded.hpp + # hex + cppcodec/hex_default_lower.hpp + cppcodec/hex_default_upper.hpp + cppcodec/hex_lower.hpp + cppcodec/hex_upper.hpp + # other stuff + cppcodec/parse_error.hpp + cppcodec/data/access.hpp + cppcodec/data/raw_result_buffer.hpp + cppcodec/detail/base32.hpp + cppcodec/detail/base64.hpp + cppcodec/detail/codec.hpp + cppcodec/detail/config.hpp + cppcodec/detail/hex.hpp + cppcodec/detail/stream_codec.hpp) + +add_library(cppcodec OBJECT ${PUBLIC_HEADERS}) # unnecessary for building, but makes headers show up in IDEs +set_target_properties(cppcodec PROPERTIES LINKER_LANGUAGE CXX) +add_subdirectory(tool) +add_subdirectory(example) + +if (BUILD_TESTING) + add_subdirectory(test) +endif() + +foreach(h ${PUBLIC_HEADERS}) + get_filename_component(FINAL_PATH ${h} PATH) # use DIRECTORY instead of PATH once requiring CMake 3.0 + install(FILES ${CMAKE_CURRENT_SOURCE_DIR}/${h} DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/${FINAL_PATH} COMPONENT "headers") +endforeach() + +if (NOT WIN32) + configure_file(${CMAKE_CURRENT_SOURCE_DIR}/cppcodec.pc.in ${CMAKE_CURRENT_BINARY_DIR}/cppcodec-1.pc @ONLY) + install(FILES ${CMAKE_CURRENT_BINARY_DIR}/cppcodec-1.pc DESTINATION ${CMAKE_INSTALL_DATAROOTDIR}/pkgconfig) +endif() diff --git a/src/third_party/cppcodec/LICENSE b/src/third_party/cppcodec/LICENSE new file mode 100644 index 0000000000..b8ff4bd195 --- /dev/null +++ b/src/third_party/cppcodec/LICENSE @@ -0,0 +1,21 @@ +Copyright (c) 2015 Topology Inc. +Copyright (c) 2018 Jakob Petsovits +Copyright (c) various other contributors, see individual files + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. diff --git a/src/third_party/cppcodec/README.md b/src/third_party/cppcodec/README.md new file mode 100644 index 0000000000..9e471ecefe --- /dev/null +++ b/src/third_party/cppcodec/README.md @@ -0,0 +1,248 @@ +# cppcodec + +[![Build Status](https://travis-ci.org/tplgy/cppcodec.png)](https://travis-ci.org/tplgy/cppcodec) [![Build status](https://ci.appveyor.com/api/projects/status/github/tplgy/cppcodec?branch=master&svg=true)](https://ci.appveyor.com/project/efidler/cppcodec) + +Header-only C++11 library to encode/decode base64, base64url, base32, base32hex +and hex (a.k.a. base16) as specified in RFC 4648, plus Crockford's base32. + +MIT licensed with consistent, flexible API. Supports raw pointers, +`std::string` and (templated) character vectors without unnecessary allocations. +Cross-platform with measured decent performance and without compiler warnings. + + + +# Usage + +1. Import cppcodec into your project (copy, git submodule, etc.) +2. Add the cppcodec root directory to your build system's list of include directories +3. Include headers and start using the API. + +Since cppcodec is a header-only library, no extra build step is needed. +Alternatively, you can install the headers and build extra tools/tests with CMake. + + + +# Variants + +A number of codec variants exist for base64 and base32, defining different alphabets +or specifying the use of padding and line breaks in different ways. cppcodec is designed +to let you make a conscious choice about which one you're using, see below for a list of variants. + +cppcodec's approach is to implement encoding/decoding algorithms in different classes for namespacing (e.g. `cppcodec::base64_rfc4648`), with classes and their associated header files named verbatim after the codec variants. + +Here is an expected standard use of cppcodec: + +```C++ +#include +#include +#include + +int main() { + using base32 = cppcodec::base32_crockford; + using base64 = cppcodec::base64_rfc4648; + + std::vector decoded = base64::decode("YW55IGNhcm5hbCBwbGVhc3VyZQ=="); + std::cout << "decoded size (\"any carnal pleasure\"): " << decoded.size() << '\n'; + std::cout << base32::encode(decoded) << std::endl; // "C5Q7J833C5S6WRBC41R6RSB1EDTQ4S8" + return 0; +} +``` + +(The prior example included "baseXX_default_*.h" includes, these are not recommended anymore and may eventually get deprecated.) + +Currently supported codec variants are: + +### base64 + +* `base64_rfc4648` uses the PEM/MIME/UTF-7 alphabet, that is (in order) + A-Z, a-z, 0-9 plus characters '+' and '/'. This is what's usually considered + the "standard base64" that you see everywhere and requires padding ('=') but + no line breaks. Whitespace and other out-of-alphabet symbols are regarded as + a parse error. +* `base64_url` is the same as `base64_rfc4648` (and defined in the same RFC) + but uses '-' (minus) and '_' (underscore) as special characters instead of + '+' and '/'. This is safe to use for URLs and file names. Padding with '=' is + required, it will be generated when encoding to a string and regarded as a + parse error if it's not present when decoding. +* `base64_url_unpadded` variant is the same as `base64_url`, but '=' padding + characters are optional. When encoding, no padding will be appended to the + resulting string. Decoding accepts either padded or unpadded strings. + +### base32 + +All base32 variants encode 5 bits as one (8-bit) character, which results in +an encoded length of roughly 160% (= 8/5). Their selling point is mainly +case-insensitive decoding, no special characters and alphabets that can be +communicated via phone. + +* `base32_rfc4648` implements the popular, standardized variant defined in + RFC 4648. It uses the full upper-case alphabet A-Z for the first 26 values + and the digit characters 2-7 for the last ten. Padding with '=' is required + and makes the encoded string a multiple of 8 characters. The codec accepts + no invalid symbols, so if you want to let the user enter base32 data then + consider replacing numbers '0', '1' and '8' with 'O', 'I' and 'B' on input. +* `base32_crockford` implements [Crockford base32](http://www.crockford.com/wrmg/base32.html). + It's less widely used than the RFC 4648 alphabet, but offers a more carefully + picked alphabet and also defines decoding similar characters 'I', 'i', 'L' + 'l' as '1' plus 'O' and 'o' as '0' so no care is required for user input. + Crockford base32 does not use '=' padding. Checksums are not implemented. + Note that the specification is ambiguous about whether to pad bit quintets to + the left or to the right, i.e. whether the codec is a place-based single number + encoding system or a concatenative iterative stream encoder. This codec variant + picks the streaming interpretation and thus zero-pads on the right. (See + http://merrigrove.blogspot.ca/2014/04/what-heck-is-base64-encoding-really.html + for a detailed discussion of the issue.) +* `base32_hex` is the logical extension of the hexadecimal alphabet, and also + specified in RFC 4648. It uses the digit characters 0-9 for the first 10 values + and the upper-case letters A-V for the remaining ones. The alphabet is + conceptually simple, but contains all of the ambiguous number/letter pairs that + the other variants try to avoid. It is also less suitable for verbal + transmission. Padding with '=' is required and makes the encoded string a + multiple of 8 characters. + +### hex + +* `hex_upper` outputs upper-case letters and accepts lower-case as well. + This is an octet-streaming codec variant and for decoding, requires an even + number of input symbols. In other words, don't try to decode (0x)"F", + (0x)"10F" etc. with this variant, use a place-based single number codec + instead if you want to do this. Also, you are expected to prepend and remove + a "0x" prefix externally as it won't be generated when encoding / will be + rejected when decoding. +* `hex_lower` outputs lower-case letters and accepts upper-case as well. + Similar to `hex_upper`, it's stream-based (no odd symbol lengths) and does + not deal with "0x" prefixes. + + + +# Philosophy and trade-offs + +cppcodec aims to support a range of codecs using a shared template-based implementation. +The focus is on a high-quality API that encourages correct use, includes error handling, +and is easy to adopt into other codebases. As a header-only library, cppcodec can +ship implementations of several codecs and variants while only compiling the ones +that you actually use. + +Good performance is a goal, but not the topmost priority. In theory, templates allows +to write generic code that is optimized for each specialization individually; however, +in practice compilers still struggle to produce code that's as simple as a +hand-written specialized function. On release builds, depending on the C++ compiler, +cppcodec runs in between (approx.) 100% and 300% of time compared to "regular" optimized +base64 implementations. Both are beat by highly optimized implementations that use +vector instructions (such as [this](https://github.com/aklomp/base64)) or buy better +performance with larger pre-computed tables (such as Chrome's base64 implementation). +Debug builds of cppcodec are slower by an order of magnitude due to the use of templates +and abstractions; make sure you use release or minimum-size builds in production. + + + +# API + +All codecs expose the same API. In the below documentation, replace `` with a +default alias such as `base64`, `base32` or `hex`, or with the full namespace such as +`cppcodec::base64_rfc4648` or `cppcodec::base32_crockford`. + +For templated parameters `T` and `Result`, you can use e.g. `std::vector`, +`std::string` or anything that supports: +* `.data()` and `.size()` for `T` (read-only) template parameters, +* for `Result` template parameters, also `.reserve(size_t)`, `.resize(size_t)` + and `.push_back([uint8_t|char])`. + +It's possible to support types lacking these functions, consult the code directly if you need this. + + +### Encoding + +```C++ +// Convenient version, returns an std::string. +std::string ::encode(const [uint8_t|char]* binary, size_t binary_size); +std::string ::encode(const T& binary); + +// Convenient version with templated result type. +Result ::encode(const [uint8_t|char]* binary, size_t binary_size); +Result ::encode(const T& binary); + +// Reused result container version. Resizes encoded_result before writing to it. +void ::encode(Result& encoded_result, const [uint8_t|char]* binary, size_t binary_size); +void ::encode(Result& encoded_result, const T& binary); +``` + +Encode binary data into an encoded (base64/base32/hex) string. +Won't throw by itself, but the result type might throw on `.resize()`. + +```C++ +size_t ::encode(char* encoded_result, size_t encoded_buffer_size, const [uint8_t|char]* binary, size_t binary_size) noexcept; +size_t ::encode(char* encoded_result, size_t encoded_buffer_size, const T& binary) noexcept; +``` + +Encode binary data into pre-allocated memory with a buffer size of +`::encoded_size(binary_size)` or larger. + +Returns the byte size of the encoded string excluding null termination, +which is equal to `::encoded_size(binary_size)`. + +If `encoded_buffer_size` is larger than required, a single null termination character (`'\0'`) +is written after the last encoded character. The `encoded_size()` function ensures that the required +buffer size is large enough to hold the padding required for the respective codec variant. +Provide a buffer of size `encoded_size() + 1` to make it a null-terminated C string. + +Calls abort() if `encoded_buffer_size` is insufficient. (That way, the function can remain `noexcept` +rather than throwing on an entirely avoidable error condition.) + +```C++ +size_t ::encoded_size(size_t binary_size) noexcept; +``` + +Calculate the (exact) length of the encoded string based on binary size, +excluding null termination but including padding (if specified by the codec variant). + + +### Decoding + +```C++ +// Convenient version, returns an std::vector. +std::vector ::decode(const char* encoded, size_t encoded_size); +std::vector ::decode(const T& encoded); + +// Convenient version with templated result type. +Result ::decode(const char* encoded, size_t encoded_size); +Result ::decode(const T& encoded); + +// Reused result container version. Resizes binary_result before writing to it. +void ::decode(Result& binary_result, const char* encoded, size_t encoded_size); +void ::decode(Result& binary_result, const T& encoded); +``` + +Decode an encoded (base64/base32/hex) string into a binary buffer. + +Throws a cppcodec::parse_error exception (inheriting from std::domain_error) +if the input data does not conform to the codec variant specification. +Also, the result type might throw on `.resize()`. + +```C++ +size_t ::decode([uint8_t|char]* binary_result, size_t binary_buffer_size, const char* encoded, size_t encoded_size); +size_t ::decode([uint8_t|char]* binary_result, size_t binary_buffer_size, const T& encoded); +``` + +Decode an encoded string into pre-allocated memory with a buffer size of +`::decoded_max_size(encoded_size)` or larger. + +Returns the byte size of the decoded binary data, which is less or equal to +`::decoded_max_size(encoded_size)`. + +Calls abort() if `binary_buffer_size` is insufficient, for consistency with encode(). +Throws a cppcodec::parse_error exception (inheriting from std::domain_error) +if the input data does not conform to the codec variant specification. + +```C++ +size_t ::decoded_max_size(size_t encoded_size) noexcept; +``` + +Calculate the maximum size of the decoded binary buffer based on the encoded string length. + +If the codec variant does not allow padding or whitespace / line breaks, +the maximum decoded size will be the exact decoded size. + +If the codec variant allows padding or whitespace / line breaks, the actual decoded size +might be smaller. If you're using the pre-allocated memory result call, make sure to take +its return value (the actual decoded size) into account. diff --git a/src/third_party/cppcodec/TODO.md b/src/third_party/cppcodec/TODO.md new file mode 100644 index 0000000000..88e6518816 --- /dev/null +++ b/src/third_party/cppcodec/TODO.md @@ -0,0 +1,63 @@ +# TODO + +cppcodec is in pretty good shape already. +Here are a number of things I'd like to do still: + +* Stuff in the GitHub issues list. + +* Implement place-based single number codecs (as opposed to stream codecs) that + view the entire input string as a single number and therefore zero-extend + *to the left* to the next bit multiple (e.g. n*5 for base32, n*4 for hex). + We want this to implement odd hex decoding (e.g. 0xF rather than 0x0F) and + the other interpretation of Crockford base32. No use case seems to exist for + base64 because it's thankfully specified well enough to always encode + octet streams, not numbers. + * API idea: Specialize the encode(Result&, const T&) overload to for T = number + and use that to accept numbers without changing the interface. Not sure if + it's a good idea to switch to a place-based single number codec based on T. + * API idea: Instead of trying to fit both into the same interface, make a + separate interface just for numbers. No binary arrays, templates only on + the encoded side. + * Naming: Current plan is to name place-based single number variants as the + original variant name plus `_num` appended. Examples: `base32_crockford_num`, + `hex_upper_num`, `hex_lower_num`. + * Since we don't know the total number of symbols (could be ignored characters?) + we might have to **(a)** assume there is no whitespace (fail) or + **(b)** walk the source data twice, the first time for counting symbols and + the second time for putting them into their right spot in the byte. + +* Investigate binary size considerations. See how well inline deduplication + works in popular linkers. I've had good experiences with boost::asio but + I don't know if those can translate to a codec library. + +* See if binary size would be saved if std::vector<[unsigned] char> could + return a temporary raw_result_buffer instead of being passed down as itself, + for use cases where both std::vector and raw pointer calls are in use. + +* More codec variants: + * binary - useful for debugging + * octal + * z-base32 might be interesting (and has some funky marginal-space-savings + options if your input length isn't octets), but doesn't appear any more + popular than Crockford base32. Pretty far down on the list. + * base64 variants from PEM (RFC 1421), MIME (RFC 2045) and UTF-7 (RFC 2152) + since they're popular and less strict than RFC 4648. Requires more + sophisticated generation of whitespace and ideally also checks whether + the whitespace is correctly located in the input string. + * Proquints? I'm not quite sure about how useful those are in real life. + +* Checksums: Crockford base32 and RFC 6920 unpadded base64url define optional + checksums, OpenPGP base64 has a mandatory one. Supporting these would mean + a change to the API, potentially together with other options (but not + necessarily so). + +* User options: I'm not too big on accepting invalid/non-conformant input, + but maybe somebody has a valid use case where they need to be more lenient + than one of the standards where the solution shouldn't be a new codec variant + but instead options for an existing variant? I'm not convinced that's a good + idea right now, but if you think it is then please make a point. + * We'll probably want some kind of unspecified whitespace acceptance for hex, + maybe there should just be a template version of cppcodec::hex for that + with ignored characters as the template. + * Crockford base32 allows hyphens as visual delimiter (ignored when decoding) + but doesn't specify diff --git a/src/third_party/cppcodec/appveyor.yml b/src/third_party/cppcodec/appveyor.yml new file mode 100644 index 0000000000..2c6de7b51f --- /dev/null +++ b/src/third_party/cppcodec/appveyor.yml @@ -0,0 +1,66 @@ +version: '{build}' + +branches: + only: + - master + +clone_depth: 1 + +# Build configurations, for MSBuild as well as ctest. +configuration: + - Release + - MinSizeRel + - Debug + +os: + - Visual Studio 2015 + - Visual Studio 2017 + +# Win32 and x64 are CMake-compatible solution platform names. +# This allows us to pass %PLATFORM% to cmake -A. +platform: + - x64 + - Win32 + +matrix: + exclude: + - os: Visual Studio 2015 + platform: x64 + configuration: MinSizeRel + - os: Visual Studio 2015 + platform: Win32 + configuration: Debug + - os: Visual Studio 2017 + platform: Win32 + configuration: Release + - os: Visual Studio 2017 + platform: Win32 + configuration: MinSizeRel + - os: Visual Studio 2017 + platform: x64 + configuration: Debug + +install: + - set SRC_DIR=%CD% + - cmake --version + - git submodule sync --recursive + - git submodule update --init --recursive + - md build + - cd build + - set BUILD_DIR=%CD% + +before_build: + - cd %BUILD_DIR% + - cmake -A%PLATFORM% %SRC_DIR% + +# build with MSBuild +build: + project: build/cppcodec.sln + parallel: true + verbosity: normal + +test_script: + - cd %BUILD_DIR% + - set CTEST_OUTPUT_ON_FAILURE=1 + - ctest -C %CONFIGURATION% -VV + - test\%CONFIGURATION%\benchmark_cppcodec.exe diff --git a/src/third_party/cppcodec/cppcodec.pc.in b/src/third_party/cppcodec/cppcodec.pc.in new file mode 100644 index 0000000000..69fac6900a --- /dev/null +++ b/src/third_party/cppcodec/cppcodec.pc.in @@ -0,0 +1,7 @@ +includedir=@CMAKE_INSTALL_FULL_INCLUDEDIR@ + +Name: @CMAKE_PROJECT_NAME@ +Description: C++ header-only library to encode/decode base64, base64url, base32, base32hex and hex +URL: https://github.com/tplgy/cppcodec +Version: @PROJECT_VERSION@ +Cflags: -I${includedir} diff --git a/src/third_party/cppcodec/cppcodec/base32_crockford.hpp b/src/third_party/cppcodec/cppcodec/base32_crockford.hpp new file mode 100644 index 0000000000..6c2ae36255 --- /dev/null +++ b/src/third_party/cppcodec/cppcodec/base32_crockford.hpp @@ -0,0 +1,91 @@ +/** + * Copyright (C) 2015 Topology LP + * All rights reserved. + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to + * deal in the Software without restriction, including without limitation the + * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or + * sell copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS + * IN THE SOFTWARE. + */ + +#ifndef CPPCODEC_BASE32_CROCKFORD +#define CPPCODEC_BASE32_CROCKFORD + +#include "detail/codec.hpp" +#include "detail/base32.hpp" + +namespace cppcodec { + +namespace detail { + +static constexpr const char base32_crockford_alphabet[] = { + '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', // at index 10 + 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', // 18 - no I + 'J', 'K', // 20 - no L + 'M', 'N', // 22 - no O + 'P', 'Q', 'R', 'S', 'T', // 27 - no U + 'V', 'W', 'X', 'Y', 'Z' // 32 +}; + +class base32_crockford_base +{ +public: + static CPPCODEC_ALWAYS_INLINE constexpr size_t alphabet_size() { + static_assert(sizeof(base32_crockford_alphabet) == 32, "base32 alphabet must have 32 values"); + return sizeof(base32_crockford_alphabet); + } + static CPPCODEC_ALWAYS_INLINE constexpr char symbol(alphabet_index_t idx) + { + return base32_crockford_alphabet[idx]; + } + static CPPCODEC_ALWAYS_INLINE constexpr char normalized_symbol(char c) + { + // Hex decoding is always case-insensitive (even in RFC 4648), the question + // is only for encoding whether to use upper-case or lower-case letters. + return (c == 'O' || c == 'o') ? '0' + : (c == 'I' || c == 'i' || c == 'L' || c == 'l') ? '1' + : (c >= 'a' && c <= 'z') ? (c - 'a' + 'A') + : c; + } + + static CPPCODEC_ALWAYS_INLINE constexpr bool generates_padding() { return false; } + static CPPCODEC_ALWAYS_INLINE constexpr bool requires_padding() { return false; } + static CPPCODEC_ALWAYS_INLINE constexpr bool is_padding_symbol(char) { return false; } + static CPPCODEC_ALWAYS_INLINE constexpr bool is_eof_symbol(char c) { return c == '\0'; } + + static CPPCODEC_ALWAYS_INLINE constexpr bool should_ignore(char c) { + return c == '-'; // "Hyphens (-) can be inserted into strings [for readability]." + } +}; + +// base32_crockford is a concatenative iterative (i.e. streaming) interpretation of Crockford base32. +// It interprets the statement "zero-extend the number to make its bit-length a multiple of 5" +// to mean zero-extending it on the right. +// (The other possible interpretation is base32_crockford_num, a place-based single number encoding system. +// See http://merrigrove.blogspot.ca/2014/04/what-heck-is-base64-encoding-really.html for more info.) +class base32_crockford : public base32_crockford_base +{ +public: + template using codec_impl = stream_codec; +}; + +} // namespace detail + +using base32_crockford = detail::codec>; + +} // namespace cppcodec + +#endif // CPPCODEC_BASE32_CROCKFORD diff --git a/src/third_party/cppcodec/cppcodec/base32_default_crockford.hpp b/src/third_party/cppcodec/cppcodec/base32_default_crockford.hpp new file mode 100644 index 0000000000..73e94eb039 --- /dev/null +++ b/src/third_party/cppcodec/cppcodec/base32_default_crockford.hpp @@ -0,0 +1,31 @@ +/** + * Copyright (C) 2015 Topology LP + * All rights reserved. + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to + * deal in the Software without restriction, including without limitation the + * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or + * sell copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS + * IN THE SOFTWARE. + */ + +#ifndef CPPCODEC_BASE32_DEFAULT_CROCKFORD +#define CPPCODEC_BASE32_DEFAULT_CROCKFORD + +#include "base32_crockford.hpp" + +using base32 = cppcodec::base32_crockford; + +#endif // CPPCODEC_BASE32_DEFAULT_CROCKFORD diff --git a/src/third_party/cppcodec/cppcodec/base32_default_hex.hpp b/src/third_party/cppcodec/cppcodec/base32_default_hex.hpp new file mode 100644 index 0000000000..4cd83360d7 --- /dev/null +++ b/src/third_party/cppcodec/cppcodec/base32_default_hex.hpp @@ -0,0 +1,31 @@ +/** + * Copyright (C) 2015, 2016 Topology LP + * All rights reserved. + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to + * deal in the Software without restriction, including without limitation the + * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or + * sell copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS + * IN THE SOFTWARE. + */ + +#ifndef CPPCODEC_BASE32_DEFAULT_HEX +#define CPPCODEC_BASE32_DEFAULT_HEX + +#include "base32_hex.hpp" + +using base32 = cppcodec::base32_hex; + +#endif // CPPCODEC_BASE32_DEFAULT_HEX diff --git a/src/third_party/cppcodec/cppcodec/base32_default_rfc4648.hpp b/src/third_party/cppcodec/cppcodec/base32_default_rfc4648.hpp new file mode 100644 index 0000000000..75561bca46 --- /dev/null +++ b/src/third_party/cppcodec/cppcodec/base32_default_rfc4648.hpp @@ -0,0 +1,31 @@ +/** + * Copyright (C) 2015 Topology LP + * All rights reserved. + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to + * deal in the Software without restriction, including without limitation the + * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or + * sell copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS + * IN THE SOFTWARE. + */ + +#ifndef CPPCODEC_BASE32_DEFAULT_RFC4648 +#define CPPCODEC_BASE32_DEFAULT_RFC4648 + +#include "base32_rfc4648.hpp" + +using base32 = cppcodec::base32_rfc4648; + +#endif // CPPCODEC_BASE32_DEFAULT_RFC4648 diff --git a/src/third_party/cppcodec/cppcodec/base32_hex.hpp b/src/third_party/cppcodec/cppcodec/base32_hex.hpp new file mode 100644 index 0000000000..ce1d84d9e6 --- /dev/null +++ b/src/third_party/cppcodec/cppcodec/base32_hex.hpp @@ -0,0 +1,76 @@ +/** + * Copyright (C) 2015, 2016 Topology LP + * All rights reserved. + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to + * deal in the Software without restriction, including without limitation the + * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or + * sell copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS + * IN THE SOFTWARE. + */ + +#ifndef CPPCODEC_BASE32_HEX +#define CPPCODEC_BASE32_HEX + +#include "detail/codec.hpp" +#include "detail/base32.hpp" + +namespace cppcodec { + +namespace detail { + +// RFC 4648 also specifies a hex encoding system which uses 0-9, then A-V. +static constexpr const char base32_hex_alphabet[] = { + '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', + 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', + 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V' +}; + +class base32_hex +{ +public: + template using codec_impl = stream_codec; + + static CPPCODEC_ALWAYS_INLINE constexpr size_t alphabet_size() { + static_assert(sizeof(base32_hex_alphabet) == 32, "base32 alphabet must have 32 values"); + return sizeof(base32_hex_alphabet); + } + static CPPCODEC_ALWAYS_INLINE constexpr char symbol(alphabet_index_t idx) + { + return base32_hex_alphabet[idx]; + } + static CPPCODEC_ALWAYS_INLINE constexpr char normalized_symbol(char c) + { + // Lower-case letters are accepted, though not generally expected. + return (c >= 'a' && c <= 'v') ? (c - 'a' + 'A') : c; + } + + static CPPCODEC_ALWAYS_INLINE constexpr bool generates_padding() { return true; } + static CPPCODEC_ALWAYS_INLINE constexpr bool requires_padding() { return true; } + static CPPCODEC_ALWAYS_INLINE constexpr char padding_symbol() { return '='; } + static CPPCODEC_ALWAYS_INLINE constexpr bool is_padding_symbol(char c) { return c == '='; } + static CPPCODEC_ALWAYS_INLINE constexpr bool is_eof_symbol(char c) { return c == '\0'; } + + // RFC4648 does not specify any whitespace being allowed in base32 encodings. + static CPPCODEC_ALWAYS_INLINE constexpr bool should_ignore(char) { return false; } +}; + +} // namespace detail + +using base32_hex = detail::codec>; + +} // namespace cppcodec + +#endif // CPPCODEC_BASE32_HEX diff --git a/src/third_party/cppcodec/cppcodec/base32_rfc4648.hpp b/src/third_party/cppcodec/cppcodec/base32_rfc4648.hpp new file mode 100644 index 0000000000..c0397029d2 --- /dev/null +++ b/src/third_party/cppcodec/cppcodec/base32_rfc4648.hpp @@ -0,0 +1,76 @@ +/** + * Copyright (C) 2015 Topology LP + * All rights reserved. + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to + * deal in the Software without restriction, including without limitation the + * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or + * sell copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS + * IN THE SOFTWARE. + */ + +#ifndef CPPCODEC_BASE32_RFC4648 +#define CPPCODEC_BASE32_RFC4648 + +#include "detail/codec.hpp" +#include "detail/base32.hpp" + +namespace cppcodec { + +namespace detail { + +// RFC 4648 uses a simple alphabet: A-Z starting at index 0, then 2-7 starting at index 26. +static constexpr const char base32_rfc4648_alphabet[] = { + 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', + 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z', // at index 26 + '2', '3', '4', '5', '6', '7' +}; + +class base32_rfc4648 +{ +public: + template using codec_impl = stream_codec; + + static CPPCODEC_ALWAYS_INLINE constexpr size_t alphabet_size() { + static_assert(sizeof(base32_rfc4648_alphabet) == 32, "base32 alphabet must have 32 values"); + return sizeof(base32_rfc4648_alphabet); + } + static CPPCODEC_ALWAYS_INLINE constexpr char symbol(alphabet_index_t idx) + { + return base32_rfc4648_alphabet[idx]; + } + static CPPCODEC_ALWAYS_INLINE constexpr char normalized_symbol(char c) + { + // Lower-case letters are accepted, though not generally expected. + return (c >= 'a' && c <= 'z') ? (c - 'a' + 'A') : c; + } + + static CPPCODEC_ALWAYS_INLINE constexpr bool generates_padding() { return true; } + static CPPCODEC_ALWAYS_INLINE constexpr bool requires_padding() { return true; } + static CPPCODEC_ALWAYS_INLINE constexpr char padding_symbol() { return '='; } + static CPPCODEC_ALWAYS_INLINE constexpr bool is_padding_symbol(char c) { return c == '='; } + static CPPCODEC_ALWAYS_INLINE constexpr bool is_eof_symbol(char c) { return c == '\0'; } + + // RFC4648 does not specify any whitespace being allowed in base32 encodings. + static CPPCODEC_ALWAYS_INLINE constexpr bool should_ignore(char) { return false; } +}; + +} // namespace detail + +using base32_rfc4648 = detail::codec>; + +} // namespace cppcodec + +#endif // CPPCODEC_BASE32_RFC4648 diff --git a/src/third_party/cppcodec/cppcodec/base64_default_rfc4648.hpp b/src/third_party/cppcodec/cppcodec/base64_default_rfc4648.hpp new file mode 100644 index 0000000000..3b39a00c28 --- /dev/null +++ b/src/third_party/cppcodec/cppcodec/base64_default_rfc4648.hpp @@ -0,0 +1,31 @@ +/** + * Copyright (C) 2015 Topology LP + * All rights reserved. + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to + * deal in the Software without restriction, including without limitation the + * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or + * sell copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS + * IN THE SOFTWARE. + */ + +#ifndef CPPCODEC_BASE64_DEFAULT_RFC4648 +#define CPPCODEC_BASE64_DEFAULT_RFC4648 + +#include "base64_rfc4648.hpp" + +using base64 = cppcodec::base64_rfc4648; + +#endif // CPPCODEC_BASE64_DEFAULT_RFC4648 diff --git a/src/third_party/cppcodec/cppcodec/base64_default_url.hpp b/src/third_party/cppcodec/cppcodec/base64_default_url.hpp new file mode 100644 index 0000000000..7db2a39542 --- /dev/null +++ b/src/third_party/cppcodec/cppcodec/base64_default_url.hpp @@ -0,0 +1,31 @@ +/** + * Copyright (C) 2015 Topology LP + * All rights reserved. + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to + * deal in the Software without restriction, including without limitation the + * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or + * sell copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS + * IN THE SOFTWARE. + */ + +#ifndef CPPCODEC_BASE64_DEFAULT_URL +#define CPPCODEC_BASE64_DEFAULT_URL + +#include "base64_url.hpp" + +using base64 = cppcodec::base64_url; + +#endif // CPPCODEC_BASE64_DEFAULT_URL diff --git a/src/third_party/cppcodec/cppcodec/base64_default_url_unpadded.hpp b/src/third_party/cppcodec/cppcodec/base64_default_url_unpadded.hpp new file mode 100644 index 0000000000..317396605f --- /dev/null +++ b/src/third_party/cppcodec/cppcodec/base64_default_url_unpadded.hpp @@ -0,0 +1,31 @@ +/** + * Copyright (C) 2016 Topology LP + * All rights reserved. + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to + * deal in the Software without restriction, including without limitation the + * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or + * sell copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS + * IN THE SOFTWARE. + */ + +#ifndef CPPCODEC_BASE64_DEFAULT_URL_UNPADDED +#define CPPCODEC_BASE64_DEFAULT_URL_UNPADDED + +#include "base64_url_unpadded.hpp" + +using base64 = cppcodec::base64_url_unpadded; + +#endif // CPPCODEC_BASE64_DEFAULT_URL_UNPADDED diff --git a/src/third_party/cppcodec/cppcodec/base64_rfc4648.hpp b/src/third_party/cppcodec/cppcodec/base64_rfc4648.hpp new file mode 100644 index 0000000000..717dceca3f --- /dev/null +++ b/src/third_party/cppcodec/cppcodec/base64_rfc4648.hpp @@ -0,0 +1,73 @@ +/** + * Copyright (C) 2015 Topology LP + * All rights reserved. + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to + * deal in the Software without restriction, including without limitation the + * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or + * sell copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS + * IN THE SOFTWARE. + */ + +#ifndef CPPCODEC_BASE64_RFC4648 +#define CPPCODEC_BASE64_RFC4648 + +#include "detail/codec.hpp" +#include "detail/base64.hpp" + +namespace cppcodec { + +namespace detail { + +static constexpr const char base64_rfc4648_alphabet[] = { + 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', + 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z', + 'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', + 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z', + '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', '+', '/' +}; + +class base64_rfc4648 +{ +public: + template using codec_impl = stream_codec; + + static CPPCODEC_ALWAYS_INLINE constexpr size_t alphabet_size() { + static_assert(sizeof(base64_rfc4648_alphabet) == 64, "base64 alphabet must have 64 values"); + return sizeof(base64_rfc4648_alphabet); + } + static CPPCODEC_ALWAYS_INLINE constexpr char symbol(alphabet_index_t idx) + { + return base64_rfc4648_alphabet[idx]; + } + static CPPCODEC_ALWAYS_INLINE constexpr char normalized_symbol(char c) { return c; } + + static CPPCODEC_ALWAYS_INLINE constexpr bool generates_padding() { return true; } + static CPPCODEC_ALWAYS_INLINE constexpr bool requires_padding() { return true; } + static CPPCODEC_ALWAYS_INLINE constexpr char padding_symbol() { return '='; } + static CPPCODEC_ALWAYS_INLINE constexpr bool is_padding_symbol(char c) { return c == '='; } + static CPPCODEC_ALWAYS_INLINE constexpr bool is_eof_symbol(char c) { return c == '\0'; } + + // RFC4648 does not specify any whitespace being allowed in base64 encodings. + static CPPCODEC_ALWAYS_INLINE constexpr bool should_ignore(char) { return false; } +}; + +} // namespace detail + +using base64_rfc4648 = detail::codec>; + +} // namespace cppcodec + +#endif // CPPCODEC_BASE64_RFC4648 diff --git a/src/third_party/cppcodec/cppcodec/base64_url.hpp b/src/third_party/cppcodec/cppcodec/base64_url.hpp new file mode 100644 index 0000000000..04c2f8bbda --- /dev/null +++ b/src/third_party/cppcodec/cppcodec/base64_url.hpp @@ -0,0 +1,75 @@ +/** + * Copyright (C) 2015 Topology LP + * All rights reserved. + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to + * deal in the Software without restriction, including without limitation the + * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or + * sell copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS + * IN THE SOFTWARE. + */ + +#ifndef CPPCODEC_BASE64_URL +#define CPPCODEC_BASE64_URL + +#include "detail/codec.hpp" +#include "detail/base64.hpp" + +namespace cppcodec { + +namespace detail { + +// The URL and filename safe alphabet is also specified by RFC4648, named "base64url". +// We keep the underscore ("base64_url") for consistency with the other codec variants. +static constexpr const char base64_url_alphabet[] = { + 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', + 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z', + 'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', + 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z', + '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', '-', '_' +}; + +class base64_url +{ +public: + template using codec_impl = stream_codec; + + static CPPCODEC_ALWAYS_INLINE constexpr size_t alphabet_size() { + static_assert(sizeof(base64_url_alphabet) == 64, "base64 alphabet must have 64 values"); + return sizeof(base64_url_alphabet); + } + static CPPCODEC_ALWAYS_INLINE constexpr char symbol(alphabet_index_t idx) + { + return base64_url_alphabet[idx]; + } + static CPPCODEC_ALWAYS_INLINE constexpr char normalized_symbol(char c) { return c; } + + static CPPCODEC_ALWAYS_INLINE constexpr bool generates_padding() { return true; } + static CPPCODEC_ALWAYS_INLINE constexpr bool requires_padding() { return true; } + static CPPCODEC_ALWAYS_INLINE constexpr char padding_symbol() { return '='; } + static CPPCODEC_ALWAYS_INLINE constexpr bool is_padding_symbol(char c) { return c == '='; } + static CPPCODEC_ALWAYS_INLINE constexpr bool is_eof_symbol(char c) { return c == '\0'; } + + // RFC4648 does not specify any whitespace being allowed in base64 encodings. + static CPPCODEC_ALWAYS_INLINE constexpr bool should_ignore(char) { return false; } +}; + +} // namespace detail + +using base64_url = detail::codec>; + +} // namespace cppcodec + +#endif // CPPCODEC_BASE64_URL diff --git a/src/third_party/cppcodec/cppcodec/base64_url_unpadded.hpp b/src/third_party/cppcodec/cppcodec/base64_url_unpadded.hpp new file mode 100644 index 0000000000..e9a5d3fc90 --- /dev/null +++ b/src/third_party/cppcodec/cppcodec/base64_url_unpadded.hpp @@ -0,0 +1,48 @@ +/** + * Copyright (C) 2016 Topology LP + * All rights reserved. + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to + * deal in the Software without restriction, including without limitation the + * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or + * sell copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS + * IN THE SOFTWARE. + */ + +#ifndef CPPCODEC_BASE64_URL_UNPADDED +#define CPPCODEC_BASE64_URL_UNPADDED + +#include "base64_url.hpp" + +namespace cppcodec { + +namespace detail { + +class base64_url_unpadded : public base64_url +{ +public: + template using codec_impl = stream_codec; + + static CPPCODEC_ALWAYS_INLINE constexpr bool generates_padding() { return false; } + static CPPCODEC_ALWAYS_INLINE constexpr bool requires_padding() { return false; } +}; + +} // namespace detail + +using base64_url_unpadded = detail::codec>; + +} // namespace cppcodec + +#endif // CPPCODEC_BASE64_URL_UNPADDED diff --git a/src/third_party/cppcodec/cppcodec/data/access.hpp b/src/third_party/cppcodec/cppcodec/data/access.hpp new file mode 100644 index 0000000000..432a3c77ba --- /dev/null +++ b/src/third_party/cppcodec/cppcodec/data/access.hpp @@ -0,0 +1,328 @@ +/** + * Copyright (C) 2015 Topology LP + * Copyright (C) 2018 Jakob Petsovits + * All rights reserved. + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to + * deal in the Software without restriction, including without limitation the + * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or + * sell copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS + * IN THE SOFTWARE. + */ + +#ifndef CPPCODEC_DETAIL_DATA_ACCESS +#define CPPCODEC_DETAIL_DATA_ACCESS + +#include // for size_t +#include // for static_assert() checking that string will be optimized +#include // for std::enable_if, std::remove_reference, and such +#include // for std::declval +#include // for static_assert() checking that vector will be optimized + +#include "../detail/config.hpp" // for CPPCODEC_ALWAYS_INLINE + +namespace cppcodec { +namespace data { + +// This file contains a number of templated data accessors that can be +// implemented in the cppcodec::data namespace for types that don't fulfill +// the default type requirements: +// For result types: init(Result&, ResultState&, size_t capacity), +// put(Result&, ResultState&, char), finish(Result&, State&) +// For const (read-only) types: char_data(const T&) +// For both const and result types: size(const T&) + +template +CPPCODEC_ALWAYS_INLINE size_t size(const T& t) { return t.size(); } + +template +CPPCODEC_ALWAYS_INLINE constexpr size_t size(const T (&t)[N]) noexcept { + return (void)t, N * sizeof(t[0]); +} + +class general_t {}; +class specific_t : public general_t {}; + +class empty_result_state { + template + CPPCODEC_ALWAYS_INLINE void size(const Result& result) { return size(result); } +}; + +// SFINAE: Generic fallback in case no specific state function applies. +template +CPPCODEC_ALWAYS_INLINE empty_result_state create_state(Result&, general_t) +{ + return empty_result_state(); +} + +// +// Generic templates for containers: Use these init()/put()/finish() +// implementations if no specialization was found. +// + +template +CPPCODEC_ALWAYS_INLINE void init(Result& result, empty_result_state&, size_t capacity) +{ + result.resize(0); + result.reserve(capacity); +} + +template +CPPCODEC_ALWAYS_INLINE void finish(Result&, empty_result_state&) +{ + // Default is to push_back(), which already increases the size. +} + +// For the put() default implementation, we try calling push_back() with either uint8_t or char, +// whichever compiles. Scary-fancy template magic from http://stackoverflow.com/a/1386390. +namespace fallback { + struct flag { char c[2]; }; // sizeof > 1 + flag put_uint8(...); + + int operator,(flag, flag); + template void operator,(flag, T&); // map everything else to void + char operator,(int, flag); // sizeof 1 +} + +template inline void put_uint8(Result& result, uint8_t c) { result.push_back(c); } + +template struct put_impl; +template <> struct put_impl { // put_uint8() available + template + static CPPCODEC_ALWAYS_INLINE void put(Result& result, uint8_t c) + { + put_uint8(result, c); + } +}; +template <> struct put_impl { // put_uint8() not available + template + static CPPCODEC_ALWAYS_INLINE void put(Result& result, uint8_t c) + { + result.push_back(static_cast(c)); + } +}; + +template +CPPCODEC_ALWAYS_INLINE void put(Result& result, empty_result_state&, uint8_t c) +{ + using namespace fallback; + put_impl::put(result, c); +} + +// +// Specialization for container types with direct mutable data access, +// e.g. std::vector. +// +// The expected way to specialize is to draft a new xyz_result_state type and +// return an instance of it from a create_state() template specialization. +// You can then create overloads for init(), put() and finish() +// for the new result state type. +// +// If desired, a non-templated overload for both specific types +// (result & state) can be added to tailor it to that particular result type. +// + +template +constexpr auto data_is_mutable(T* t) -> decltype(t->data()[size_t(0)] = 'x', bool()) +{ + return (void)t, true; +} +constexpr bool data_is_mutable(...) { return false; } + +template +class direct_data_access_result_state +{ +public: + CPPCODEC_ALWAYS_INLINE void init(Result& result, size_t capacity) + { + // reserve() may not actually allocate the storage right away, + // and it isn't guaranteed that it will be untouched upon the + //.next resize(). In that light, resize from the start and + // slightly reduce the size at the end if necessary. + result.resize(capacity); + + // result.data() may perform a calculation to retrieve the address. + // E.g. std::string (since C++11) will use small string optimization, + // so it needs to check if it's using allocated data or (ab)using + // its own member variables interpreted as char array. + // (This result_state is used for std::string starting with C++17.) + // Conditional code paths are slow so we only do it once, at the start. + m_buffer = result.data(); + } + CPPCODEC_ALWAYS_INLINE void put(Result&, char c) + { + m_buffer[m_offset++] = c; + } + CPPCODEC_ALWAYS_INLINE void finish(Result& result) + { + result.resize(m_offset); + } + CPPCODEC_ALWAYS_INLINE size_t size(const Result&) + { + return m_offset; + } +private: + // Make sure to get the mutable buffer decltype by using assignment. + typename std::remove_reference< + decltype(std::declval().data()[size_t(0)] = 'x')>::type* m_buffer; + size_t m_offset = 0; +}; + +// SFINAE: Select a specific state based on the result type and possible result state type. +// Implement this if direct data access (`result.data()[0] = 'x') isn't already possible +// and you want to specialize it for your own result type. +// Note: The enable_if should ideally be part of the class declaration, +// but Visual Studio C++ will not compile it that way. +// Have it here in the factory function instead. +template (nullptr))>::type> +CPPCODEC_ALWAYS_INLINE direct_data_access_result_state create_state(Result&, specific_t) +{ + return direct_data_access_result_state(); +} + +static_assert(std::is_same< + decltype(create_state(*static_cast*>(nullptr), specific_t())), + direct_data_access_result_state>>::value, + "std::vector must be handled by direct_data_access_result_state"); + +// Specialized init(), put() and finish() functions for direct_data_access_result_state. +template +CPPCODEC_ALWAYS_INLINE void init(Result& result, direct_data_access_result_state& state, size_t capacity) +{ + state.init(result, capacity); +} + +template +CPPCODEC_ALWAYS_INLINE void put(Result& result, direct_data_access_result_state& state, char c) +{ + state.put(result, c); +} + +template +CPPCODEC_ALWAYS_INLINE void finish(Result& result, direct_data_access_result_state& state) +{ + state.finish(result); +} + +// +// Specialization for container types with direct mutable array access, +// e.g. std::string. This is generally faster because bound checks are +// minimal and operator[] is more likely noexcept. In addition, +// std::string::push_back() needs to write a null character on every +// expansion, which should be more efficient when done in bulk by resize(). +// +// Compared to the above, tracking an extra offset variable is cheap. +// + +template +constexpr auto array_access_is_mutable(T* t) -> decltype((*t)[size_t(0)] = 'x', bool()) +{ + return (void)t, true; +} +constexpr bool array_access_is_mutable(...) { return false; } + +template +class array_access_result_state +{ +public: + CPPCODEC_ALWAYS_INLINE void init(Result& result, size_t capacity) + { + // reserve() may not actually allocate the storage right away, + // and it isn't guaranteed that it will be untouched upon the + //.next resize(). In that light, resize from the start and + // slightly reduce the size at the end if necessary. + result.resize(capacity); + } + CPPCODEC_ALWAYS_INLINE void put(Result& result, char c) + { + result[m_offset++] = c; + } + CPPCODEC_ALWAYS_INLINE void finish(Result& result) + { + result.resize(m_offset); + } + CPPCODEC_ALWAYS_INLINE size_t size(const Result&) + { + return m_offset; + } +private: + size_t m_offset = 0; +}; + +// SFINAE: Select a specific state based on the result type and possible result state type. +// Note: The enable_if should ideally be part of the class declaration, +// but Visual Studio C++ will not compile it that way. +// Have it here in the factory function instead. +template (nullptr)) // no more than one template option + && array_access_is_mutable(static_cast(nullptr))>::type> +CPPCODEC_ALWAYS_INLINE array_access_result_state create_state(Result&, specific_t) +{ + return array_access_result_state(); +} + +#if __cplusplus >= 201703L || (defined(_MSVC_LANG) && _MSVC_LANG > 201703L) +static_assert(std::is_same< + decltype(create_state(*static_cast(nullptr), specific_t())), + direct_data_access_result_state>::value, + "std::string (C++17 and later) must be handled by direct_data_access_result_state"); +#elif __cplusplus < 201703 && !defined(_MSVC_LANG) // we can't trust MSVC to set this right +static_assert(std::is_same< + decltype(create_state(*static_cast(nullptr), specific_t())), + array_access_result_state>::value, + "std::string (pre-C++17) must be handled by array_access_result_state"); +#endif + +// Specialized init(), put() and finish() functions for array_access_result_state. +template +CPPCODEC_ALWAYS_INLINE void init(Result& result, array_access_result_state& state, size_t capacity) +{ + state.init(result, capacity); +} + +template +CPPCODEC_ALWAYS_INLINE void put(Result& result, array_access_result_state& state, char c) +{ + state.put(result, c); +} + +template +CPPCODEC_ALWAYS_INLINE void finish(Result& result, array_access_result_state& state) +{ + state.finish(result); +} + +// char_data() is only used to read, not for result buffers. +template inline const char* char_data(const T& t) +{ + return reinterpret_cast(t.data()); +} +template inline const char* char_data(const T (&t)[N]) noexcept +{ + return reinterpret_cast(&(t[0])); +} + +template inline const uint8_t* uchar_data(const T& t) +{ + return reinterpret_cast(char_data(t)); +} + +} // namespace data +} // namespace cppcodec + +#endif diff --git a/src/third_party/cppcodec/cppcodec/data/raw_result_buffer.hpp b/src/third_party/cppcodec/cppcodec/data/raw_result_buffer.hpp new file mode 100644 index 0000000000..65b0de558f --- /dev/null +++ b/src/third_party/cppcodec/cppcodec/data/raw_result_buffer.hpp @@ -0,0 +1,70 @@ +/** + * Copyright (C) 2015 Topology LP + * All rights reserved. + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to + * deal in the Software without restriction, including without limitation the + * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or + * sell copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS + * IN THE SOFTWARE. + */ + +#ifndef CPPCODEC_DETAIL_RAW_RESULT_BUFFER +#define CPPCODEC_DETAIL_RAW_RESULT_BUFFER + +#include // for size_t +#include // for abort() + +#include "access.hpp" + +namespace cppcodec { +namespace data { + +class raw_result_buffer +{ +public: + raw_result_buffer(char* data, size_t capacity) + : m_ptr(data + capacity) + , m_begin(data) + { + } + + CPPCODEC_ALWAYS_INLINE void push_back(char c) { *m_ptr = c; ++m_ptr; } + CPPCODEC_ALWAYS_INLINE size_t size() const { return m_ptr - m_begin; } + CPPCODEC_ALWAYS_INLINE void resize(size_t size) { m_ptr = m_begin + size; } + +private: + char* m_ptr; + char* m_begin; +}; + + +template <> inline void init( + raw_result_buffer& result, empty_result_state&, size_t capacity) +{ + // This version of init() doesn't do a reserve(), and instead checks whether the + // initial size (capacity) is enough before resetting m_ptr to m_begin. + // The codec is expected not to exceed this capacity. + if (capacity > result.size()) { + abort(); + } + result.resize(0); +} +template <> inline void finish(raw_result_buffer&, empty_result_state&) { } + +} // namespace data +} // namespace cppcodec + +#endif diff --git a/src/third_party/cppcodec/cppcodec/detail/base32.hpp b/src/third_party/cppcodec/cppcodec/detail/base32.hpp new file mode 100644 index 0000000000..7113b7a2fe --- /dev/null +++ b/src/third_party/cppcodec/cppcodec/detail/base32.hpp @@ -0,0 +1,166 @@ +/** + * Copyright (C) 2015 Trustifier Inc. + * Copyright (C) 2015 Ahmed Masud + * Copyright (C) 2015 Topology LP + * Copyright (C) 2018 Jakob Petsovits + * All rights reserved. + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to + * deal in the Software without restriction, including without limitation the + * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or + * sell copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS + * IN THE SOFTWARE. + * + * Adapted from https://github.com/ahmed-masud/libbase32, + * commit 79761b2b79b0545697945efe0987a8d3004512f9. + * Quite different now. + */ + +#ifndef CPPCODEC_DETAIL_BASE32 +#define CPPCODEC_DETAIL_BASE32 + +#include +#include // for abort() + +#include "../data/access.hpp" +#include "../parse_error.hpp" +#include "config.hpp" +#include "stream_codec.hpp" + +namespace cppcodec { +namespace detail { + +template +class base32 : public CodecVariant::template codec_impl> +{ +public: + static inline constexpr uint8_t binary_block_size() { return 5; } + static inline constexpr uint8_t encoded_block_size() { return 8; } + + static CPPCODEC_ALWAYS_INLINE constexpr uint8_t num_encoded_tail_symbols(uint8_t num_bytes) + { + return (num_bytes == 1) ? 2 // 2 symbols, 6 padding characters + : (num_bytes == 2) ? 4 // 4 symbols, 4 padding characters + : (num_bytes == 3) ? 5 // 5 symbols, 3 padding characters + : (num_bytes == 4) ? 7 // 7 symbols, 1 padding characters + : throw std::domain_error("invalid number of bytes in a tail block"); + } + + template + static CPPCODEC_ALWAYS_INLINE constexpr uint8_t index( + const uint8_t* b /*binary block*/) noexcept + { + static_assert(I >= 0 && I < encoded_block_size(), + "invalid encoding symbol index in a block"); + + return (I == 0) ? ((b[0] >> 3) & 0x1F) // first 5 bits + : (I == 1) ? (((b[0] << 2) & 0x1C) | ((b[1] >> 6) & 0x3)) + : (I == 2) ? ((b[1] >> 1) & 0x1F) + : (I == 3) ? (((b[1] << 4) & 0x10) | ((b[2] >> 4) & 0xF)) + : (I == 4) ? (((b[2] << 1) & 0x1E) | ((b[3] >> 7) & 0x1)) + : (I == 5) ? ((b[3] >> 2) & 0x1F) + : (I == 6) ? (((b[3] << 3) & 0x18) | ((b[4] >> 5) & 0x7)) + : /*I == 7*/ (b[4] & 0x1F); // last 5 bits; + } + + template + using uint8_if = typename std::enable_if::type; + + template + static CPPCODEC_ALWAYS_INLINE constexpr + uint8_if index_last( + const uint8_t* b /*binary block*/) noexcept + { + return (I == 1) ? ((b[0] << 2) & 0x1C) // abbreviated 2nd symbol + : (I == 3) ? ((b[1] << 4) & 0x10) // abbreviated 4th symbol + : (I == 4) ? ((b[2] << 1) & 0x1E) // abbreviated 5th symbol + : /*I == 6*/ ((b[3] << 3) & 0x18); // abbreviated 7th symbol + } + + template + static CPPCODEC_ALWAYS_INLINE + uint8_if index_last( + const uint8_t* /*binary block*/) + { + throw std::domain_error("invalid last encoding symbol index in a tail"); + } + + template + static CPPCODEC_ALWAYS_INLINE void decode_block( + Result& decoded, ResultState&, const alphabet_index_t* idx); + + template + static CPPCODEC_ALWAYS_INLINE void decode_tail( + Result& decoded, ResultState&, const alphabet_index_t* idx, size_t idx_len); +}; + +// +// 11111111 10101010 10110011 10111100 10010100 +// => 11111 11110 10101 01011 00111 01111 00100 10100 +// + +template +template +CPPCODEC_ALWAYS_INLINE void base32::decode_block( + Result& decoded, ResultState& state, const alphabet_index_t* idx) +{ + put(decoded, state, static_cast(((idx[0] << 3) & 0xF8) | ((idx[1] >> 2) & 0x7))); + put(decoded, state, static_cast(((idx[1] << 6) & 0xC0) | ((idx[2] << 1) & 0x3E) | ((idx[3] >> 4) & 0x1))); + put(decoded, state, static_cast(((idx[3] << 4) & 0xF0) | ((idx[4] >> 1) & 0xF))); + put(decoded, state, static_cast(((idx[4] << 7) & 0x80) | ((idx[5] << 2) & 0x7C) | ((idx[6] >> 3) & 0x3))); + put(decoded, state, static_cast(((idx[6] << 5) & 0xE0) | (idx[7] & 0x1F))); +} + +template +template +CPPCODEC_ALWAYS_INLINE void base32::decode_tail( + Result& decoded, ResultState& state, const alphabet_index_t* idx, size_t idx_len) +{ + if (idx_len == 1) { + throw invalid_input_length( + "invalid number of symbols in last base32 block: found 1, expected 2, 4, 5 or 7"); + } + if (idx_len == 3) { + throw invalid_input_length( + "invalid number of symbols in last base32 block: found 3, expected 2, 4, 5 or 7"); + } + if (idx_len == 6) { + throw invalid_input_length( + "invalid number of symbols in last base32 block: found 6, expected 2, 4, 5 or 7"); + } + + // idx_len == 2: decoded size 1 + put(decoded, state, static_cast(((idx[0] << 3) & 0xF8) | ((idx[1] >> 2) & 0x7))); + if (idx_len == 2) { + return; + } + // idx_len == 4: decoded size 2 + put(decoded, state, static_cast(((idx[1] << 6) & 0xC0) | ((idx[2] << 1) & 0x3E) | ((idx[3] >> 4) & 0x1))); + if (idx_len == 4) { + return; + } + // idx_len == 5: decoded size 3 + put(decoded, state, static_cast(((idx[3] << 4) & 0xF0) | ((idx[4] >> 1) & 0xF))); + if (idx_len == 5) { + return; + } + // idx_len == 7: decoded size 4 + put(decoded, state, static_cast(((idx[4] << 7) & 0x80) | ((idx[5] << 2) & 0x7C) | ((idx[6] >> 3) & 0x3))); +} + +} // namespace detail +} // namespace cppcodec + +#endif // CPPCODEC_DETAIL_BASE32 diff --git a/src/third_party/cppcodec/cppcodec/detail/base64.hpp b/src/third_party/cppcodec/cppcodec/detail/base64.hpp new file mode 100644 index 0000000000..b6db6d7694 --- /dev/null +++ b/src/third_party/cppcodec/cppcodec/detail/base64.hpp @@ -0,0 +1,132 @@ +/** + * Copyright (C) 2015 Topology LP + * Copyright (C) 2013 Adam Rudd (bit calculations) + * Copyright (C) 2018 Jakob Petsovits + * All rights reserved. + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to + * deal in the Software without restriction, including without limitation the + * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or + * sell copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS + * IN THE SOFTWARE. + * + * Bit calculations adapted from https://github.com/adamvr/arduino-base64, + * commit 999595783185a0afcba156d7276dfeaa9cb5382f. + */ + +#ifndef CPPCODEC_DETAIL_BASE64 +#define CPPCODEC_DETAIL_BASE64 + +#include +#include + +#include "../data/access.hpp" +#include "../parse_error.hpp" +#include "config.hpp" +#include "stream_codec.hpp" + +namespace cppcodec { +namespace detail { + +template +class base64 : public CodecVariant::template codec_impl> +{ +public: + static inline constexpr uint8_t binary_block_size() { return 3; } + static inline constexpr uint8_t encoded_block_size() { return 4; } + + static CPPCODEC_ALWAYS_INLINE constexpr uint8_t num_encoded_tail_symbols(uint8_t num_bytes) + { + return (num_bytes == 1) ? 2 // 2 symbols, 2 padding characters + : (num_bytes == 2) ? 3 // 3 symbols, 1 padding character + : throw std::domain_error("invalid number of bytes in a tail block"); + } + + template + static CPPCODEC_ALWAYS_INLINE constexpr uint8_t index( + const uint8_t* b /*binary block*/) noexcept + { + static_assert(I >= 0 && I < encoded_block_size(), + "invalid encoding symbol index in a block"); + + return (I == 0) ? (b[0] >> 2) // first 6 bits + : (I == 1) ? (((b[0] & 0x3) << 4) | (b[1] >> 4)) + : (I == 2) ? (((b[1] & 0xF) << 2) | (b[2] >> 6)) + : /*I == 3*/ (b[2] & 0x3F); // last 6 bits + } + + template + using uint8_if = typename std::enable_if::type; + + template + static CPPCODEC_ALWAYS_INLINE constexpr uint8_if index_last( + const uint8_t* b /*binary block*/) noexcept + { + return (I == 1) ? ((b[0] & 0x3) << 4) // abbreviated 2nd symbol + : /*I == 2*/ ((b[1] & 0xF) << 2); // abbreviated 3rd symbol + } + + template + static CPPCODEC_ALWAYS_INLINE uint8_if index_last( + const uint8_t* /*binary block*/) + { + throw std::domain_error("invalid last encoding symbol index in a tail"); + } + + template + static CPPCODEC_ALWAYS_INLINE void decode_block( + Result& decoded, ResultState&, const alphabet_index_t* idx); + + template + static CPPCODEC_ALWAYS_INLINE void decode_tail( + Result& decoded, ResultState&, const alphabet_index_t* idx, size_t idx_len); +}; + + +template +template +CPPCODEC_ALWAYS_INLINE void base64::decode_block( + Result& decoded, ResultState& state, const alphabet_index_t* idx) +{ + uint_fast32_t dec = (idx[0] << 18) | (idx[1] << 12) | (idx[2] << 6) | idx[3]; + data::put(decoded, state, static_cast(dec >> 16)); + data::put(decoded, state, static_cast((dec >> 8) & 0xFF)); + data::put(decoded, state, static_cast(dec & 0xFF)); +} + +template +template +CPPCODEC_ALWAYS_INLINE void base64::decode_tail( + Result& decoded, ResultState& state, const alphabet_index_t* idx, size_t idx_len) +{ + if (idx_len == 1) { + throw invalid_input_length( + "invalid number of symbols in last base64 block: found 1, expected 2 or 3"); + } + + // idx_len == 2: decoded size 1 + data::put(decoded, state, static_cast((idx[0] << 2) + ((idx[1] & 0x30) >> 4))); + if (idx_len == 2) { + return; + } + + // idx_len == 3: decoded size 2 + data::put(decoded, state, static_cast(((idx[1] & 0xF) << 4) + ((idx[2] & 0x3C) >> 2))); +} + +} // namespace detail +} // namespace cppcodec + +#endif // CPPCODEC_DETAIL_BASE64 diff --git a/src/third_party/cppcodec/cppcodec/detail/codec.hpp b/src/third_party/cppcodec/cppcodec/detail/codec.hpp new file mode 100644 index 0000000000..47d98020b0 --- /dev/null +++ b/src/third_party/cppcodec/cppcodec/detail/codec.hpp @@ -0,0 +1,327 @@ +/** + * Copyright (C) 2015 Topology LP + * All rights reserved. + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to + * deal in the Software without restriction, including without limitation the + * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or + * sell copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS + * IN THE SOFTWARE. + */ + +#ifndef CPPCODEC_DETAIL_CODEC +#define CPPCODEC_DETAIL_CODEC + +#include +#include +#include +#include + +#include "../data/access.hpp" +#include "../data/raw_result_buffer.hpp" + +namespace cppcodec { +namespace detail { + +// SFINAE: Templates sometimes beat sensible overloads - make sure we don't call the wrong one. +template +struct non_numeric : std::enable_if::value> { }; + + +/** + * Public interface for all the codecs. For API documentation, see README.md. + */ +template +class codec +{ +public: + // + // Encoding + + // Convenient version, returns an std::string. + static std::string encode(const uint8_t* binary, size_t binary_size); + static std::string encode(const char* binary, size_t binary_size); + // static std::string encode(const T& binary); -> provided by template below + + // Convenient version with templated result type. + template static Result encode(const uint8_t* binary, size_t binary_size); + template static Result encode(const char* binary, size_t binary_size); + template > + static Result encode(const T& binary); + + // Reused result container version. Resizes encoded_result before writing to it. + template + static void encode(Result& encoded_result, const uint8_t* binary, size_t binary_size); + template + static void encode(Result& encoded_result, const char* binary, size_t binary_size); + template ::type* = nullptr> + static void encode(Result& encoded_result, const T& binary); + + // Raw pointer output, assumes pre-allocated memory with size > encoded_size(binary_size). + static size_t encode( + char* encoded_result, size_t encoded_buffer_size, + const uint8_t* binary, size_t binary_size) noexcept; + static size_t encode( + char* encoded_result, size_t encoded_buffer_size, + const char* binary, size_t binary_size) noexcept; + template + static size_t encode( + char* encoded_result, size_t encoded_buffer_size, + const T& binary) noexcept; + + // Calculate the exact length of the encoded string based on binary size. + static constexpr size_t encoded_size(size_t binary_size) noexcept; + + // + // Decoding + + // Convenient version, returns an std::vector. + static std::vector decode(const char* encoded, size_t encoded_size); + // static std::vector decode(const T& encoded); -> provided by template below + + // Convenient version with templated result type. + template static Result decode(const char* encoded, size_t encoded_size); + template , typename T = std::string> + static Result decode(const T& encoded); + + // Reused result container version. Resizes binary_result before writing to it. + template + static void decode(Result& binary_result, const char* encoded, size_t encoded_size); + template ::type* = nullptr> + static void decode(Result& binary_result, const T& encoded); + + // Raw pointer output, assumes pre-allocated memory with size > decoded_max_size(encoded_size). + static size_t decode( + uint8_t* binary_result, size_t binary_buffer_size, + const char* encoded, size_t encoded_size); + static size_t decode( + char* binary_result, size_t binary_buffer_size, + const char* encoded, size_t encoded_size); + template static size_t decode( + uint8_t* binary_result, size_t binary_buffer_size, const T& encoded); + template static size_t decode( + char* binary_result, size_t binary_buffer_size, const T& encoded); + + // Calculate the maximum size of the decoded binary buffer based on the encoded string length. + static constexpr size_t decoded_max_size(size_t encoded_size) noexcept; +}; + + +// +// Inline definitions of the above functions, using CRTP to call into CodecImpl +// + +// +// Encoding + +template +inline std::string codec::encode(const uint8_t* binary, size_t binary_size) +{ + return encode(binary, binary_size); +} + +template +inline std::string codec::encode(const char* binary, size_t binary_size) +{ + return encode(reinterpret_cast(binary), binary_size); +} + +template +template +inline Result codec::encode(const uint8_t* binary, size_t binary_size) +{ + Result encoded_result; + encode(encoded_result, binary, binary_size); + return encoded_result; +} + +template +template +inline Result codec::encode(const char* binary, size_t binary_size) +{ + return encode(reinterpret_cast(binary), binary_size); +} + +template +template +inline Result codec::encode(const T& binary) +{ + return encode(data::uchar_data(binary), data::size(binary)); +} + +template +template +inline void codec::encode( + Result& encoded_result, const uint8_t* binary, size_t binary_size) +{ + // This overload is where we reserve buffer capacity and call into CodecImpl. + size_t encoded_buffer_size = encoded_size(binary_size); + auto state = data::create_state(encoded_result, data::specific_t()); + data::init(encoded_result, state, encoded_buffer_size); + + CodecImpl::encode(encoded_result, state, binary, binary_size); + data::finish(encoded_result, state); + assert(data::size(encoded_result) == encoded_buffer_size); +} + +template +template +inline void codec::encode( + Result& encoded_result, const char* binary, size_t binary_size) +{ + encode(encoded_result, reinterpret_cast(binary), binary_size); +} + +template +template ::type*> +inline void codec::encode(Result& encoded_result, const T& binary) +{ + encode(encoded_result, data::uchar_data(binary), data::size(binary)); +} + +template +inline size_t codec::encode( + char* encoded_result, size_t encoded_buffer_size, + const uint8_t* binary, size_t binary_size) noexcept +{ + // This overload is where we wrap the result pointer & size. + data::raw_result_buffer encoded(encoded_result, encoded_buffer_size); + encode(encoded, binary, binary_size); + + size_t encoded_size = data::size(encoded); + if (encoded_size < encoded_buffer_size) { + encoded_result[encoded_size] = '\0'; + } + return encoded_size; +} + +template +inline size_t codec::encode( + char* encoded_result, size_t encoded_buffer_size, + const char* binary, size_t binary_size) noexcept +{ + // This overload is where we wrap the result pointer & size. + return encode(encoded_result, encoded_buffer_size, + reinterpret_cast(binary), binary_size); +} + +template +template +inline size_t codec::encode( + char* encoded_result, size_t encoded_buffer_size, + const T& binary) noexcept +{ + return encode(encoded_result, encoded_buffer_size, data::uchar_data(binary), data::size(binary)); +} + +template +inline constexpr size_t codec::encoded_size(size_t binary_size) noexcept +{ + return CodecImpl::encoded_size(binary_size); +} + + +// +// Decoding + +template +inline std::vector codec::decode(const char* encoded, size_t encoded_size) +{ + return decode>(encoded, encoded_size); +} + +template +template +inline Result codec::decode(const char* encoded, size_t encoded_size) +{ + Result result; + decode(result, encoded, encoded_size); + return result; +} + +template +template +inline Result codec::decode(const T& encoded) +{ + return decode(data::char_data(encoded), data::size(encoded)); +} + +template +template +inline void codec::decode(Result& binary_result, const char* encoded, size_t encoded_size) +{ + // This overload is where we reserve buffer capacity and call into CodecImpl. + size_t binary_buffer_size = decoded_max_size(encoded_size); + auto state = data::create_state(binary_result, data::specific_t()); + data::init(binary_result, state, binary_buffer_size); + + CodecImpl::decode(binary_result, state, encoded, encoded_size); + data::finish(binary_result, state); + assert(data::size(binary_result) <= binary_buffer_size); +} + + +template +template ::type*> +inline void codec::decode(Result& binary_result, const T& encoded) +{ + decode(binary_result, data::char_data(encoded), data::size(encoded)); +} + +template +inline size_t codec::decode( + uint8_t* binary_result, size_t binary_buffer_size, + const char* encoded, size_t encoded_size) +{ + return decode(reinterpret_cast(binary_result), binary_buffer_size, encoded, encoded_size); +} + +template +inline size_t codec::decode( + char* binary_result, size_t binary_buffer_size, + const char* encoded, size_t encoded_size) +{ + // This overload is where we wrap the result pointer & size. + data::raw_result_buffer binary(binary_result, binary_buffer_size); + decode(binary, encoded, encoded_size); + return data::size(binary); +} + +template +template +inline size_t codec::decode( + uint8_t* binary_result, size_t binary_buffer_size, const T& encoded) +{ + return decode(reinterpret_cast(binary_result), binary_buffer_size, encoded); +} + +template +template +inline size_t codec::decode(char* binary_result, size_t binary_buffer_size, const T& encoded) +{ + return decode(binary_result, binary_buffer_size, data::char_data(encoded), data::size(encoded)); +} + +template +inline constexpr size_t codec::decoded_max_size(size_t encoded_size) noexcept +{ + return CodecImpl::decoded_max_size(encoded_size); +} + + +} // namespace detail +} // namespace cppcodec + +#endif diff --git a/src/third_party/cppcodec/cppcodec/detail/config.hpp b/src/third_party/cppcodec/cppcodec/detail/config.hpp new file mode 100644 index 0000000000..dc66f8f45d --- /dev/null +++ b/src/third_party/cppcodec/cppcodec/detail/config.hpp @@ -0,0 +1,40 @@ +/** + * Copyright (C) 2015 Topology LP + * All rights reserved. + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to + * deal in the Software without restriction, including without limitation the + * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or + * sell copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS + * IN THE SOFTWARE. + */ + +#ifndef CPPCODEC_DETAIL_CONFIG_HPP +#define CPPCODEC_DETAIL_CONFIG_HPP + +#ifndef __has_attribute + #define __has_attribute(x) 0 +#endif + +#if __GNUC__ || __has_attribute(always_inline) +#define CPPCODEC_ALWAYS_INLINE inline __attribute__((always_inline)) +#elif defined(_MSC_VER) && !defined(__INTEL_COMPILER) +#define CPPCODEC_ALWAYS_INLINE inline __forceinline +#else +#define CPPCODEC_ALWAYS_INLINE inline +#endif + +#endif // CPPCODEC_DETAIL_CONFIG_HPP + diff --git a/src/third_party/cppcodec/cppcodec/detail/hex.hpp b/src/third_party/cppcodec/cppcodec/detail/hex.hpp new file mode 100644 index 0000000000..f86be93fdf --- /dev/null +++ b/src/third_party/cppcodec/cppcodec/detail/hex.hpp @@ -0,0 +1,114 @@ +/** + * Copyright (C) 2015 Topology LP + * Copyright (C) 2018 Jakob Petsovits + * All rights reserved. + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to + * deal in the Software without restriction, including without limitation the + * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or + * sell copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS + * IN THE SOFTWARE. + */ + +#ifndef CPPCODEC_DETAIL_HEX +#define CPPCODEC_DETAIL_HEX + +#include +#include // for abort() + +#include "../data/access.hpp" +#include "../parse_error.hpp" +#include "stream_codec.hpp" + +namespace cppcodec { +namespace detail { + +template +class hex : public CodecVariant::template codec_impl> +{ +public: + static inline constexpr uint8_t binary_block_size() { return 1; } + static inline constexpr uint8_t encoded_block_size() { return 2; } + + static CPPCODEC_ALWAYS_INLINE constexpr uint8_t num_encoded_tail_symbols(uint8_t /*num_bytes*/) noexcept + { + // Hex encoding only works on full bytes so there are no tails, + // no padding characters, and this function should (must) never be called. + return 0; + } + + template + static CPPCODEC_ALWAYS_INLINE constexpr uint8_t index( + const uint8_t* b /*binary block*/) noexcept + { + static_assert(I >= 0 && I < encoded_block_size(), + "invalid encoding symbol index in a block"); + + return (I == 0) ? (b[0] >> 4) // first 4 bits + : /*I == 1*/ (b[0] & 0xF); // last 4 bits + } + + // With only 2 bytes, enc<1> will always result in a full index() call and + // enc<0> will be protected by a not-reached assertion, so we don't actually + // care about index_last() except optimizing it out as good as possible. + template + using uint8_if = typename std::enable_if::type; + + template + static CPPCODEC_ALWAYS_INLINE constexpr uint8_if index_last( + const uint8_t* /*binary block*/) noexcept + { + return 0; + } + + template + static CPPCODEC_ALWAYS_INLINE uint8_if index_last( + const uint8_t* /*binary block*/) + { + throw std::domain_error("invalid last encoding symbol index in a tail"); + } + + template + static CPPCODEC_ALWAYS_INLINE void decode_block( + Result& decoded, ResultState&, const alphabet_index_t* idx); + + template + static CPPCODEC_ALWAYS_INLINE void decode_tail( + Result& decoded, ResultState&, const alphabet_index_t* idx, size_t idx_len); +}; + + +template +template +CPPCODEC_ALWAYS_INLINE void hex::decode_block( + Result& decoded, ResultState& state, const alphabet_index_t* idx) +{ + data::put(decoded, state, static_cast((idx[0] << 4) | idx[1])); +} + +template +template +CPPCODEC_ALWAYS_INLINE void hex::decode_tail( + Result&, ResultState&, const alphabet_index_t*, size_t) +{ + throw invalid_input_length( + "odd-length hex input is not supported by the streaming octet decoder, " + "use a place-based number decoder instead"); +} + +} // namespace detail +} // namespace cppcodec + +#endif // CPPCODEC_DETAIL_HEX diff --git a/src/third_party/cppcodec/cppcodec/detail/stream_codec.hpp b/src/third_party/cppcodec/cppcodec/detail/stream_codec.hpp new file mode 100644 index 0000000000..ddc52e37d7 --- /dev/null +++ b/src/third_party/cppcodec/cppcodec/detail/stream_codec.hpp @@ -0,0 +1,439 @@ +/** + * Copyright (C) 2015 Topology LP + * Copyright (C) 2018 Jakob Petsovits + * All rights reserved. + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to + * deal in the Software without restriction, including without limitation the + * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or + * sell copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS + * IN THE SOFTWARE. + */ + +#ifndef CPPCODEC_DETAIL_STREAM_CODEC +#define CPPCODEC_DETAIL_STREAM_CODEC + +#include +#include // for abort() +#include + +#include "../parse_error.hpp" +#include "config.hpp" + +namespace cppcodec { +namespace detail { + +using alphabet_index_t = uint_fast16_t; + +template +class stream_codec +{ +public: + template static void encode( + Result& encoded_result, ResultState&, const uint8_t* binary, size_t binary_size); + + template static void decode( + Result& binary_result, ResultState&, const char* encoded, size_t encoded_size); + + static constexpr size_t encoded_size(size_t binary_size) noexcept; + static constexpr size_t decoded_max_size(size_t encoded_size) noexcept; +}; + +template // default for CodecVariant::generates_padding() == false +struct padder { + template + static CPPCODEC_ALWAYS_INLINE void pad(Result&, ResultState&, SizeT) { } +}; + +template<> // specialization for CodecVariant::generates_padding() == true +struct padder { + template + static CPPCODEC_ALWAYS_INLINE void pad( + Result& encoded, ResultState& state, SizeT num_padding_characters) + { + for (SizeT i = 0; i < num_padding_characters; ++i) { + data::put(encoded, state, CodecVariant::padding_symbol()); + } + } +}; + +template +struct enc { + // Block encoding: Go from 0 to (block size - 1), append a symbol for each iteration unconditionally. + template + static CPPCODEC_ALWAYS_INLINE void block(Result& encoded, ResultState& state, const uint8_t* src) + { + using EncodedBlockSizeT = decltype(Codec::encoded_block_size()); + constexpr static const EncodedBlockSizeT SymbolIndex = static_cast(I - 1); + + enc().template block(encoded, state, src); + data::put(encoded, state, CodecVariant::symbol(Codec::template index(src))); + } + + // Tail encoding: Go from 0 until (runtime) num_symbols, append a symbol for each iteration. + template + static CPPCODEC_ALWAYS_INLINE void tail( + Result& encoded, ResultState& state, const uint8_t* src, EncodedBlockSizeT num_symbols) + { + constexpr static const EncodedBlockSizeT SymbolIndex = Codec::encoded_block_size() - I; + constexpr static const EncodedBlockSizeT NumSymbols = SymbolIndex + static_cast(1); + + if (num_symbols == NumSymbols) { + data::put(encoded, state, CodecVariant::symbol(Codec::template index_last(src))); + return; + } + data::put(encoded, state, CodecVariant::symbol(Codec::template index(src))); + enc().template tail(encoded, state, src, num_symbols); + } +}; + +template<> // terminating specialization +struct enc<0> { + template + static CPPCODEC_ALWAYS_INLINE void block(Result&, ResultState&, const uint8_t*) { } + + template + static CPPCODEC_ALWAYS_INLINE void tail(Result&, ResultState&, const uint8_t*, EncodedBlockSizeT) + { + abort(); // Not reached: block() should be called if num_symbols == block size, not tail(). + } +}; + +template +template +inline void stream_codec::encode( + Result& encoded_result, ResultState& state, + const uint8_t* src, size_t src_size) +{ + using encoder = enc; + + const uint8_t* src_end = src + src_size; + + if (src_size >= Codec::binary_block_size()) { + src_end -= Codec::binary_block_size(); + + for (; src <= src_end; src += Codec::binary_block_size()) { + encoder::template block(encoded_result, state, src); + } + src_end += Codec::binary_block_size(); + } + + if (src_end > src) { + auto remaining_src_len = src_end - src; + if (!remaining_src_len || remaining_src_len >= Codec::binary_block_size()) { + abort(); + return; + } + + auto num_symbols = Codec::num_encoded_tail_symbols( + static_cast(remaining_src_len)); + + encoder::template tail(encoded_result, state, src, num_symbols); + + padder::template pad( + encoded_result, state, Codec::encoded_block_size() - num_symbols); + } +} + +// Range & lookup table generation, see +// http://stackoverflow.com/questions/13313980/populate-an-array-using-constexpr-at-compile-time +// and http://cplusadd.blogspot.ca/2013/02/c11-compile-time-lookup-tablearray-with.html + +template struct seq {}; + +template +struct gen_seq : gen_seq { + // Clang up to 3.6 has a limit of 256 for template recursion, + // so pass a few more symbols at once to make it work. + static_assert(N % 4 == 0, "I must be divisible by 4 to eventually end at 0"); +}; +template +struct gen_seq<0, Is...> : seq {}; + +template +struct lookup_table_t { + alphabet_index_t lookup[N]; + static constexpr size_t size = N; +}; + +template +constexpr lookup_table_t make_lookup_table(seq, LambdaType value_for_index) { + return { { value_for_index(Is)... } }; +} + +template +constexpr lookup_table_t make_lookup_table(LambdaType evalFunc) { + return make_lookup_table(gen_seq(), evalFunc); +} + +// CodecVariant::symbol() provides a symbol for an index. +// Use recursive templates to get the inverse lookup table for fast decoding. + +template +static CPPCODEC_ALWAYS_INLINE constexpr size_t num_possible_values() +{ + return static_cast( + static_cast((std::numeric_limits::max)()) + - static_cast((std::numeric_limits::min)()) + 1); +} + +template +struct index_if_in_alphabet { + static CPPCODEC_ALWAYS_INLINE constexpr alphabet_index_t for_symbol(char symbol) + { + return (CodecVariant::symbol( + static_cast(CodecVariant::alphabet_size() - I)) == symbol) + ? static_cast(CodecVariant::alphabet_size() - I) + : index_if_in_alphabet::for_symbol(symbol); + } +}; +template +struct index_if_in_alphabet { // terminating specialization + static CPPCODEC_ALWAYS_INLINE constexpr alphabet_index_t for_symbol(char) + { + return InvalidIdx; + } +}; + +template +struct padding_searcher { + static CPPCODEC_ALWAYS_INLINE constexpr bool exists_padding_symbol() + { + // Clang up to 3.6 has a limit of 256 for template recursion, + // so pass a few more symbols at once to make it work. + static_assert(I % 4 == 0, "I must be divisible by 4 to eventually end at 0"); + + return CodecVariant::is_padding_symbol( + static_cast(num_possible_values() - I - 4)) + || CodecVariant::is_padding_symbol( + static_cast(num_possible_values() - I - 3)) + || CodecVariant::is_padding_symbol( + static_cast(num_possible_values() - I - 2)) + || CodecVariant::is_padding_symbol( + static_cast(num_possible_values() - I - 1)) + || padding_searcher::exists_padding_symbol(); + } +}; +template +struct padding_searcher { // terminating specialization + static CPPCODEC_ALWAYS_INLINE constexpr bool exists_padding_symbol() { return false; } +}; + +template +struct alphabet_index_info +{ + static constexpr const size_t num_possible_symbols = num_possible_values(); + + static constexpr const alphabet_index_t padding_idx = 1 << 8; + static constexpr const alphabet_index_t invalid_idx = 1 << 9; + static constexpr const alphabet_index_t eof_idx = 1 << 10; + static constexpr const alphabet_index_t stop_character_mask = static_cast(~0xFFu); + + static constexpr const bool padding_allowed = padding_searcher< + CodecVariant, num_possible_symbols>::exists_padding_symbol(); + + static CPPCODEC_ALWAYS_INLINE constexpr bool allows_padding() + { + return padding_allowed; + } + static CPPCODEC_ALWAYS_INLINE constexpr bool is_padding(alphabet_index_t idx) + { + return allows_padding() ? (idx == padding_idx) : false; + } + static CPPCODEC_ALWAYS_INLINE constexpr bool is_invalid(alphabet_index_t idx) { return idx == invalid_idx; } + static CPPCODEC_ALWAYS_INLINE constexpr bool is_eof(alphabet_index_t idx) { return idx == eof_idx; } + static CPPCODEC_ALWAYS_INLINE constexpr bool is_stop_character(alphabet_index_t idx) + { + return (idx & stop_character_mask) != 0; + } + +private: + static CPPCODEC_ALWAYS_INLINE constexpr + alphabet_index_t valid_index_or(alphabet_index_t a, alphabet_index_t b) + { + return a == invalid_idx ? b : a; + } + + using idx_if_in_alphabet = index_if_in_alphabet< + CodecVariant, invalid_idx, CodecVariant::alphabet_size()>; + + static CPPCODEC_ALWAYS_INLINE constexpr alphabet_index_t index_of(char symbol) + { + return valid_index_or(idx_if_in_alphabet::for_symbol(symbol), + CodecVariant::is_eof_symbol(symbol) ? eof_idx + : CodecVariant::is_padding_symbol(symbol) ? padding_idx + : invalid_idx); + } + + // GCC <= 4.9 has a bug with retaining constexpr when passing a function pointer. + // To get around this, we'll create a callable with operator() and pass that one. + // Unfortunately, MSVC prior to VS 2017 (for MinSizeRel or Release builds) + // chokes on this by compiling the project in 20 minutes instead of seconds. + // So let's define two separate variants and remove the old GCC one whenever we + // decide not to support GCC < 5.0 anymore. +#if defined(__GNUC__) && !defined(__clang__) && __GNUC__ < 5 + struct index_at { + CPPCODEC_ALWAYS_INLINE constexpr alphabet_index_t operator()(size_t symbol) const { + return index_of(CodecVariant::normalized_symbol(static_cast(symbol))); + } + }; +#else + static CPPCODEC_ALWAYS_INLINE constexpr alphabet_index_t index_at(size_t symbol) + { + return index_of(CodecVariant::normalized_symbol(static_cast(symbol))); + } +#endif + +public: + struct lookup { + static CPPCODEC_ALWAYS_INLINE alphabet_index_t for_symbol(char symbol) + { +#if defined(__GNUC__) && !defined(__clang__) && __GNUC__ < 5 + static constexpr const auto t = make_lookup_table(index_at()); +#else + static constexpr const auto t = make_lookup_table(&index_at); +#endif + static_assert(t.size == num_possible_symbols, + "lookup table must cover each possible (character) symbol"); + return t.lookup[static_cast(symbol)]; + } + }; +}; + +// +// At long last! The actual decode/encode functions. + +template +template +inline void stream_codec::decode( + Result& binary_result, ResultState& state, + const char* src_encoded, size_t src_size) +{ + using alphabet_index_lookup = typename alphabet_index_info::lookup; + const char* src = src_encoded; + const char* src_end = src + src_size; + + alphabet_index_t alphabet_indexes[Codec::encoded_block_size()] = {}; + alphabet_indexes[0] = alphabet_index_info::eof_idx; + + alphabet_index_t* const alphabet_index_start = &alphabet_indexes[0]; + alphabet_index_t* const alphabet_index_end = &alphabet_indexes[Codec::encoded_block_size()]; + alphabet_index_t* alphabet_index_ptr = &alphabet_indexes[0]; + + while (src < src_end) { + if (CodecVariant::should_ignore(*src)) { + ++src; + continue; + } + *alphabet_index_ptr = alphabet_index_lookup::for_symbol(*src); + if (alphabet_index_info::is_stop_character(*alphabet_index_ptr)) { + break; + } + ++src; + ++alphabet_index_ptr; + + if (alphabet_index_ptr == alphabet_index_end) { + Codec::decode_block(binary_result, state, alphabet_indexes); + alphabet_index_ptr = alphabet_index_start; + } + } + + if (alphabet_index_info::is_invalid(*alphabet_index_ptr)) { + throw symbol_error(*src); + } + ++src; + + alphabet_index_t* last_index_ptr = alphabet_index_ptr; + if (alphabet_index_info::is_padding(*last_index_ptr)) { + if (last_index_ptr == alphabet_index_start) { + // Don't accept padding at the start of a block. + // The encoder should have omitted that padding altogether. + throw padding_error(); + } + // We're in here because we just read a (first) padding character. Try to read more. + // Count with last_index_ptr, but store in alphabet_index_ptr so we don't + // overflow the array in case the input data is too long. + ++last_index_ptr; + while (src < src_end) { + *alphabet_index_ptr = alphabet_index_lookup::for_symbol(*(src++)); + + if (alphabet_index_info::is_eof(*alphabet_index_ptr)) { + *alphabet_index_ptr = alphabet_index_info::padding_idx; + break; + } + if (!alphabet_index_info::is_padding(*alphabet_index_ptr)) { + throw padding_error(); + } + + ++last_index_ptr; + if (last_index_ptr > alphabet_index_end) { + throw padding_error(); + } + } + } + + if (last_index_ptr != alphabet_index_start) { + if ((CodecVariant::requires_padding() + || alphabet_index_info::is_padding(*alphabet_index_ptr) + ) && last_index_ptr != alphabet_index_end) + { + // If the input is not a multiple of the block size then the input is incorrect. + throw padding_error(); + } + if (alphabet_index_ptr >= alphabet_index_end) { + abort(); + return; + } + Codec::decode_tail(binary_result, state, alphabet_indexes, + static_cast(alphabet_index_ptr - alphabet_index_start)); + } +} + +template +inline constexpr size_t stream_codec::encoded_size(size_t binary_size) noexcept +{ + using C = Codec; + + // constexpr rules make this a lot harder to read than it actually is. + return CodecVariant::generates_padding() + // With padding, the encoded size is a multiple of the encoded block size. + // To calculate that, round the binary size up to multiple of the binary block size, + // then convert to encoded by multiplying with { base32: 8/5, base64: 4/3 }. + ? (binary_size + (C::binary_block_size() - 1) + - ((binary_size + (C::binary_block_size() - 1)) % C::binary_block_size())) + * C::encoded_block_size() / C::binary_block_size() + // No padding: only pad to the next multiple of 5 bits, i.e. at most a single extra byte. + : (binary_size * C::encoded_block_size() / C::binary_block_size()) + + (((binary_size * C::encoded_block_size()) % C::binary_block_size()) ? 1 : 0); +} + +template +inline constexpr size_t stream_codec::decoded_max_size(size_t encoded_size) noexcept +{ + using C = Codec; + + return CodecVariant::requires_padding() + ? (encoded_size / C::encoded_block_size() * C::binary_block_size()) + : (encoded_size / C::encoded_block_size() * C::binary_block_size()) + + ((encoded_size % C::encoded_block_size()) + * C::binary_block_size() / C::encoded_block_size()); +} + +} // namespace detail +} // namespace cppcodec + +#endif // CPPCODEC_DETAIL_STREAM_CODEC diff --git a/src/third_party/cppcodec/cppcodec/hex_default_lower.hpp b/src/third_party/cppcodec/cppcodec/hex_default_lower.hpp new file mode 100644 index 0000000000..3b10675a78 --- /dev/null +++ b/src/third_party/cppcodec/cppcodec/hex_default_lower.hpp @@ -0,0 +1,31 @@ +/** + * Copyright (C) 2015 Topology LP + * All rights reserved. + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to + * deal in the Software without restriction, including without limitation the + * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or + * sell copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS + * IN THE SOFTWARE. + */ + +#ifndef CPPCODEC_HEX_DEFAULT_LOWER +#define CPPCODEC_HEX_DEFAULT_LOWER + +#include "hex_lower.hpp" + +using hex = cppcodec::hex_lower; + +#endif // CPPCODEC_HEX_DEFAULT_LOWER diff --git a/src/third_party/cppcodec/cppcodec/hex_default_upper.hpp b/src/third_party/cppcodec/cppcodec/hex_default_upper.hpp new file mode 100644 index 0000000000..a960f0230f --- /dev/null +++ b/src/third_party/cppcodec/cppcodec/hex_default_upper.hpp @@ -0,0 +1,31 @@ +/** + * Copyright (C) 2015 Topology LP + * All rights reserved. + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to + * deal in the Software without restriction, including without limitation the + * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or + * sell copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS + * IN THE SOFTWARE. + */ + +#ifndef CPPCODEC_HEX_DEFAULT_UPPER +#define CPPCODEC_HEX_DEFAULT_UPPER + +#include "hex_upper.hpp" + +using hex = cppcodec::hex_upper; + +#endif // CPPCODEC_HEX_DEFAULT_UPPER diff --git a/src/third_party/cppcodec/cppcodec/hex_lower.hpp b/src/third_party/cppcodec/cppcodec/hex_lower.hpp new file mode 100644 index 0000000000..36ad58334b --- /dev/null +++ b/src/third_party/cppcodec/cppcodec/hex_lower.hpp @@ -0,0 +1,75 @@ +/** + * Copyright (C) 2015 Topology LP + * All rights reserved. + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to + * deal in the Software without restriction, including without limitation the + * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or + * sell copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS + * IN THE SOFTWARE. + */ + +#ifndef CPPCODEC_HEX_LOWER +#define CPPCODEC_HEX_LOWER + +#include "detail/codec.hpp" +#include "detail/hex.hpp" + +namespace cppcodec { + +namespace detail { + +static constexpr const char hex_lower_alphabet[] = { + '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', // at index 10 + 'a', 'b', 'c', 'd', 'e', 'f' +}; + +class hex_lower +{ +public: + template using codec_impl = stream_codec; + + static CPPCODEC_ALWAYS_INLINE constexpr size_t alphabet_size() { + static_assert(sizeof(hex_lower_alphabet) == 16, "hex alphabet must have 16 values"); + return sizeof(hex_lower_alphabet); + } + static CPPCODEC_ALWAYS_INLINE constexpr char symbol(alphabet_index_t index) + { + return hex_lower_alphabet[index]; + } + static CPPCODEC_ALWAYS_INLINE constexpr char normalized_symbol(char c) + { + // Hex decoding is always case-insensitive (even in RFC 4648), the question + // is only for encoding whether to use upper-case or lower-case letters. + return (c >= 'A' && c <= 'F') ? (c - 'A' + 'a') : c; + } + + static CPPCODEC_ALWAYS_INLINE constexpr bool generates_padding() { return false; } + // FIXME: doesn't require padding, but requires a multiple of the encoded block size (2) + static CPPCODEC_ALWAYS_INLINE constexpr bool requires_padding() { return false; } + static CPPCODEC_ALWAYS_INLINE constexpr bool is_padding_symbol(char) { return false; } + static CPPCODEC_ALWAYS_INLINE constexpr bool is_eof_symbol(char c) { return c == '\0'; } + + // Sometimes hex strings include whitespace, but this variant forbids it. + static CPPCODEC_ALWAYS_INLINE constexpr bool should_ignore(char) { return false; } +}; + +} // namespace detail + +using hex_lower = detail::codec>; + +} // namespace cppcodec + +#endif // CPPCODEC_HEX_LOWER diff --git a/src/third_party/cppcodec/cppcodec/hex_upper.hpp b/src/third_party/cppcodec/cppcodec/hex_upper.hpp new file mode 100644 index 0000000000..9b811c690a --- /dev/null +++ b/src/third_party/cppcodec/cppcodec/hex_upper.hpp @@ -0,0 +1,75 @@ +/** + * Copyright (C) 2015 Topology LP + * All rights reserved. + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to + * deal in the Software without restriction, including without limitation the + * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or + * sell copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS + * IN THE SOFTWARE. + */ + +#ifndef CPPCODEC_HEX_UPPER +#define CPPCODEC_HEX_UPPER + +#include "detail/codec.hpp" +#include "detail/hex.hpp" + +namespace cppcodec { + +namespace detail { + +static constexpr const char hex_upper_alphabet[] = { + '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', + 'A', 'B', 'C', 'D', 'E', 'F' +}; + +class hex_upper +{ +public: + template using codec_impl = stream_codec; + + static CPPCODEC_ALWAYS_INLINE constexpr size_t alphabet_size() { + static_assert(sizeof(hex_upper_alphabet) == 16, "hex alphabet must have 16 values"); + return sizeof(hex_upper_alphabet); + } + static CPPCODEC_ALWAYS_INLINE constexpr char symbol(alphabet_index_t index) + { + return hex_upper_alphabet[index]; + } + static CPPCODEC_ALWAYS_INLINE constexpr char normalized_symbol(char c) + { + // Hex decoding is always case-insensitive (even in RFC 4648), the question + // is only for encoding whether to use upper-case or lower-case letters. + return (c >= 'a' && c <= 'f') ? (c - 'a' + 'A') : c; + } + + static CPPCODEC_ALWAYS_INLINE constexpr bool generates_padding() { return false; } + // FIXME: doesn't require padding, but requires a multiple of the encoded block size (2) + static CPPCODEC_ALWAYS_INLINE constexpr bool requires_padding() { return false; } + static CPPCODEC_ALWAYS_INLINE constexpr bool is_padding_symbol(char) { return false; } + static CPPCODEC_ALWAYS_INLINE constexpr bool is_eof_symbol(char c) { return c == '\0'; } + + // Sometimes hex strings include whitespace, but this variant forbids it. + static CPPCODEC_ALWAYS_INLINE constexpr bool should_ignore(char) { return false; } +}; + +} // namespace detail + +using hex_upper = detail::codec>; + +} // namespace cppcodec + +#endif // CPPCODEC_HEX_UPPER diff --git a/src/third_party/cppcodec/cppcodec/parse_error.hpp b/src/third_party/cppcodec/cppcodec/parse_error.hpp new file mode 100644 index 0000000000..97438ade45 --- /dev/null +++ b/src/third_party/cppcodec/cppcodec/parse_error.hpp @@ -0,0 +1,109 @@ +/** + * Copyright (C) 2015 Topology LP + * All rights reserved. + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to + * deal in the Software without restriction, including without limitation the + * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or + * sell copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS + * IN THE SOFTWARE. + */ + +#ifndef CPPCODEC_PARSE_ERROR +#define CPPCODEC_PARSE_ERROR + +#include +#include + +namespace cppcodec { + +namespace detail { +// <*stream> headers include a lot of code and noticeably increase compile times. +// The only thing we want from them really is a char-to-string conversion. +// That's easy to implement with many less lines of code, so let's do it ourselves. +template +static void uctoa(unsigned char n, char (&s)[N]) +{ + static_assert(N >= 4, "need at least 4 bytes to convert an unsigned char to string safely"); + int i = sizeof(s) - 1; + int num_chars = 1; + s[i--] = '\0'; + do { // generate digits in reverse order + s[i--] = n % 10 + '0'; // get next digit + ++num_chars; + } while ((n /= 10) > 0); // delete it + + if (num_chars == sizeof(s)) { + return; + } + for (i = 0; i < num_chars; ++i) { // move chars to front of string + s[i] = s[i + (sizeof(s) - num_chars)]; + } +} +} // end namespace detail + + +class parse_error : public std::domain_error +{ +public: + using std::domain_error::domain_error; +}; + +// Avoids memory allocation, so it can be used in constexpr functions. +class symbol_error : public parse_error +{ +public: + symbol_error(char c) + : parse_error(symbol_error::make_error_message(c)) + , m_symbol(c) + { + } + + symbol_error(const symbol_error&) = default; + + char symbol() const noexcept { return m_symbol; } + +private: + static std::string make_error_message(char c) + { + char s[4]; + detail::uctoa(*reinterpret_cast(&c), s); + return std::string("parse error: character [") + &(s[0]) + " '" + c + "'] out of bounds"; + } + +private: + char m_symbol; +}; + +class invalid_input_length : public parse_error +{ +public: + using parse_error::parse_error; +}; + +class padding_error : public invalid_input_length +{ +public: + padding_error() + : invalid_input_length("parse error: codec expects padded input string but padding was invalid") + { + } + + padding_error(const padding_error&) = default; +}; + +} // namespace cppcodec + +#endif // CPPCODEC_PARSE_ERROR diff --git a/src/third_party/cppcodec/example/CMakeLists.txt b/src/third_party/cppcodec/example/CMakeLists.txt new file mode 100644 index 0000000000..671d422d09 --- /dev/null +++ b/src/third_party/cppcodec/example/CMakeLists.txt @@ -0,0 +1,6 @@ +# For cppcodec itself, don't prefer system headers over development ones. +include_directories(BEFORE ${PROJECT_SOURCE_DIR}) + +add_executable(helloworld helloworld.cpp) + +add_executable(type_support_wrapper type_support_wrapper.cpp) diff --git a/src/third_party/cppcodec/example/helloworld.cpp b/src/third_party/cppcodec/example/helloworld.cpp new file mode 100644 index 0000000000..98cc314a51 --- /dev/null +++ b/src/third_party/cppcodec/example/helloworld.cpp @@ -0,0 +1,39 @@ +/** + * This is free and unencumbered software released into the public domain. + * Anyone is free to copy, modify, publish, use, compile, sell, or + * distribute this software, either in source code form or as a compiled + * binary, for any purpose, commercial or non-commercial, and by any + * means. + * + * In jurisdictions that recognize copyright laws, the author or authors + * of this software dedicate any and all copyright interest in the + * software to the public domain. We make this dedication for the benefit + * of the public at large and to the detriment of our heirs and + * successors. We intend this dedication to be an overt act of + * relinquishment in perpetuity of all present and future rights to this + * software under copyright law. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. + * IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR + * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, + * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR + * OTHER DEALINGS IN THE SOFTWARE. + * + * For more information, please refer to + */ + +#include +#include +#include + +int main() { + using base32 = cppcodec::base32_crockford; + using base64 = cppcodec::base64_rfc4648; + + std::vector decoded = base64::decode("YW55IGNhcm5hbCBwbGVhc3VyZQ=="); + std::cout << "decoded size (\"any carnal pleasure\"): " << decoded.size() << '\n'; + std::cout << base32::encode(decoded) << std::endl; // "C5Q7J833C5S6WRBC41R6RSB1EDTQ4S8" + return 0; +} diff --git a/src/third_party/cppcodec/example/type_support_wrapper.cpp b/src/third_party/cppcodec/example/type_support_wrapper.cpp new file mode 100644 index 0000000000..be2fa9ca9c --- /dev/null +++ b/src/third_party/cppcodec/example/type_support_wrapper.cpp @@ -0,0 +1,149 @@ +/** + * This is free and unencumbered software released into the public domain. + * Anyone is free to copy, modify, publish, use, compile, sell, or + * distribute this software, either in source code form or as a compiled + * binary, for any purpose, commercial or non-commercial, and by any + * means. + * + * In jurisdictions that recognize copyright laws, the author or authors + * of this software dedicate any and all copyright interest in the + * software to the public domain. We make this dedication for the benefit + * of the public at large and to the detriment of our heirs and + * successors. We intend this dedication to be an overt act of + * relinquishment in perpetuity of all present and future rights to this + * software under copyright law. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. + * IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR + * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, + * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR + * OTHER DEALINGS IN THE SOFTWARE. + * + * For more information, please refer to + */ + +#include +#include + + +// This example shows how to wrap a type (here: std::string) in another +// result type in order to modify the standard behavior for that type. +// Use this when you're in a position to wrap the result variable. +// +// This is the more straightforward of two ways for modifying cppcodec's +// behavior for a given type, the other one being able to modify the +// default behavior but also being more complex/intricate. +// +// The overall approach is straightforward: Define a result type with +// push_back(char) and size() methods, implement template specializations +// for init() and finish() for the result type, and call encode()/decode() +// with an object of this type as result parameter. + +class string_append_wrapper +{ +public: + string_append_wrapper(std::string& backing) + : m_backing(backing) + , m_offset(0) + , m_orig_size(0) + { + } + + void init(size_t capacity) + { + m_orig_size = m_backing.size(); + m_offset = m_orig_size; + m_backing.resize(m_orig_size + capacity); + } + void finish() + { + m_backing.resize(m_offset); + } + + // Methods required for satisfying default result type requirements: + CPPCODEC_ALWAYS_INLINE void push_back(char c) { m_backing[m_offset++] = c; } + CPPCODEC_ALWAYS_INLINE size_t size() const { return m_offset - m_orig_size; } + + // Note that the above implementation of push_back() is not the fastest, + // because operator[] for std::string (for C++11 and above) still includes + // a check for whether the size of the string fits into its allocation-less + // character array union. + // + // With C++17 and above, it's legitimate to get the character array as a + // mutable (non-const) char pointer, so this check can be skipped. + // This is implemented via template specialization in cppcodec's + // default behavior for std::string, but omitted here for simplicity. + // If you need that last bit of extra performance, see + // direct_data_access_result_state in cppcodec/data/access.hpp + // for an example of optimal C++17 string access. + +private: + std::string& m_backing; + size_t m_offset; + size_t m_orig_size; +}; + + +// init() and finish() must be declared in the cppcodec::data namespace. +namespace cppcodec { +namespace data { + +template <> inline void init( + string_append_wrapper& result, empty_result_state&, size_t capacity) +{ + // init() is called to prepare the output buffer. cppcodec will call it + // with the maximum output size, null termination not included. + // + // Any thrown exception will not be caught by cppcodec itself, + // the caller of the encode/decode function is responsible for handling it. + // + // empty_result_state can be ignored in this case because the wrapper type + // can carry all required state internally. + // + // In order to maximize performance, init() should generally try to + // allocate or guarantee the entire output buffer at once, so that + // subsequent calls to push_back() don't result in extra checks (slower) + // or even re-allocations. + + result.init(capacity); +} + +// Between init() and finish(), cppcodec will call result.push_back(char) +// repeatedly, once for each output character with no rewinding. +// While init() can ask for greater capacity than the final output length, +// cppcodec guarantees that push_back() will never be called too often. +// +// (If you know exactly how long your output is, you could theoretically +// overcommit on capacity while allocating only the exact expected length +// of the output buffer. This is of course dangerous, because you can +// hardly ever know for sure and everyone's often wrong, so don't try it +// unless you have a business-critical reason to reduce/avoid the allocation.) + +template <> inline void finish( + string_append_wrapper& result, empty_result_state&) +{ + // finish() is called after encoding/decoding is done. + // Its main purpose is to reduce the size of the result type + // from capacity to the actual (often slightly smaller) output length. + // + // After finish(), cppcodec will assert that result.size() does indeed + // equal the number of times that push_back() has been called. + + result.finish(); +} + +} // namespace data +} // namespace cppcodec + + +int main() { + using base64 = cppcodec::base64_rfc4648; + + std::string result = "Result: "; + string_append_wrapper appender(result); + base64::encode(appender, std::string("any carnal pleasure")); + std::cout << result << std::endl; // "Result: YW55IGNhcm5hbCBwbGVhc3VyZQ==" + return 0; +} diff --git a/src/third_party/cppcodec/test/CMakeLists.txt b/src/third_party/cppcodec/test/CMakeLists.txt new file mode 100644 index 0000000000..fe4f4b5bf1 --- /dev/null +++ b/src/third_party/cppcodec/test/CMakeLists.txt @@ -0,0 +1,22 @@ +# For cppcodec itself, don't prefer system headers over development ones. +include_directories(BEFORE ${PROJECT_SOURCE_DIR}) + +find_package(PkgConfig) +if (PKG_CONFIG_FOUND) + pkg_check_modules(CATCH2 catch2) +endif() + +if (CATCH2_FOUND) + message(STATUS "Found system Catch2, not using bundled version") + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${CATCH2_CFLAGS}") +else() + message(STATUS "Did NOT find system Catch2, instead using bundled version") + include_directories(${CMAKE_CURRENT_SOURCE_DIR}/catch/single_include) +endif() + +add_executable(test_cppcodec test_cppcodec.cpp) +add_test(cppcodec test_cppcodec) + +add_executable(benchmark_cppcodec benchmark_cppcodec.cpp) + +add_executable(minimal_decode minimal_decode.cpp) diff --git a/src/third_party/cppcodec/test/benchmark_cppcodec.cpp b/src/third_party/cppcodec/test/benchmark_cppcodec.cpp new file mode 100644 index 0000000000..7bf37bd058 --- /dev/null +++ b/src/third_party/cppcodec/test/benchmark_cppcodec.cpp @@ -0,0 +1,164 @@ +/** + * Copyright (C) 2018 Jakob Petsovits + * All rights reserved. + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to + * deal in the Software without restriction, including without limitation the + * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or + * sell copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS + * IN THE SOFTWARE. + */ + +#include +#include +#include + +#include +#include +#include +#include +#include +#include +#include + +#define BENCHMARK_ENCODING_STR true +#define BENCHMARK_DECODING_STR true +#define BENCHMARK_DECODING_VEC_U8 true + +const size_t max_iterations = 1000000; // 1m iterations ought to be enough for anybody +const size_t iteration_max_ms = 500; // half a second + +uint8_t random_uint8() +{ + static std::random_device rd; + static std::mt19937 pseudo_random(rd()); + static std::uniform_int_distribution dist(0, 255); + return static_cast(dist(pseudo_random)); +} + +template +void benchmark(std::ostream& stream, const std::vector& decoded_sizes) +{ + using clock = std::chrono::high_resolution_clock; + + // Measure decoding into both uint8_t and string. + std::vector time_encoding_str(decoded_sizes.size()); + std::vector time_decoding_vec_u8(decoded_sizes.size()); + std::vector time_decoding_str(decoded_sizes.size()); + std::vector> decoded_vec_u8(decoded_sizes.size()); + std::vector decoded_str(decoded_sizes.size()); + std::vector encoded_str(decoded_sizes.size()); + + for (size_t i = 0; i < decoded_sizes.size(); ++i) { + decoded_vec_u8[i].resize(decoded_sizes[i]); + for (size_t j = 0; j < decoded_sizes[i]; ++j) { + decoded_vec_u8[i][j] = random_uint8(); + } + } + + auto flags = stream.flags(); + auto precision = stream.precision(); + stream << std::fixed << std::setprecision(4); + +#if BENCHMARK_ENCODING_STR + stream << "Encoding:\n"; + + for (size_t i = 0; i < decoded_sizes.size(); ++i) { + encoded_str[i] = Codec::encode(decoded_vec_u8[i]); + + clock::time_point start = clock::now(); + clock::time_point end = start + std::chrono::milliseconds(iteration_max_ms); + size_t j = 0; + for (; j < max_iterations; ++j) { + if (clock::now() > end) { + break; + } + encoded_str[i] = Codec::encode(decoded_vec_u8[i]); + } + time_encoding_str[i] = std::chrono::duration_cast( + clock::now() - start).count() / static_cast(j); + + stream << (i == 0 ? "" : "\t") << decoded_sizes[i] << ": " + << time_encoding_str[i] << std::flush; + } + stream << "\n"; +#else + // Even if we're not benchmarking encoding, we still need the encoded strings. + for (size_t i = 0; i < decoded_sizes.size(); ++i) { + encoded_str[i] = Codec::encode(decoded_vec_u8[i]); + } +#endif // BENCHMARK_ENCODING_STR + +#if BENCHMARK_DECODING_STR + stream << "Decoding to string:\n"; + + for (size_t i = 0; i < decoded_sizes.size(); ++i) { + decoded_str[i] = std::string(); + clock::time_point start = clock::now(); + clock::time_point end = start + std::chrono::milliseconds(iteration_max_ms); + size_t j = 0; + for (; j < max_iterations; ++j) { + if (clock::now() > end) { + break; + } + decoded_str[i] = Codec::template decode(encoded_str[i]); + } + time_decoding_str[i] = std::chrono::duration_cast( + clock::now() - start).count() / static_cast(j); + + stream << (i == 0 ? "" : "\t") << decoded_sizes[i] << ": " + << time_decoding_str[i] << std::flush; + } + + stream << "\n"; +#endif // BENCHMARK_DECODING_STR + +#if BENCHMARK_DECODING_VEC_U8 + stream << "Decoding to vector:\n"; + + for (size_t i = 0; i < decoded_sizes.size(); ++i) { + decoded_vec_u8[i] = std::vector(); + clock::time_point start = clock::now(); + clock::time_point end = start + std::chrono::milliseconds(iteration_max_ms); + size_t j = 0; + for (; j < max_iterations; ++j) { + if (clock::now() > end) { + break; + } + decoded_vec_u8[i] = Codec::decode(encoded_str[i]); + } + time_decoding_vec_u8[i] = std::chrono::duration_cast( + clock::now() - start).count() / static_cast(j); + + stream << (i == 0 ? "" : "\t") << decoded_sizes[i] << ": " + << time_decoding_vec_u8[i] << std::flush; + } + + stream << "\n"; +#endif // BENCHMARK_DECODING_VEC_U8 + + stream << std::setprecision(precision) << "\n"; + stream.flags(flags); +} + +int main() +{ + std::vector decoded_sizes = { + 1, 4, 8, 16, 32, 64, 128, 256, 2048, 4096, 32768 + }; + std::cout << "base64_rfc4648: [decoded size: microseconds]\n"; + benchmark(std::cout, decoded_sizes); + return 0; +} diff --git a/src/third_party/cppcodec/test/catch/.gitattributes b/src/third_party/cppcodec/test/catch/.gitattributes new file mode 100644 index 0000000000..b5a2cdccdf --- /dev/null +++ b/src/third_party/cppcodec/test/catch/.gitattributes @@ -0,0 +1,22 @@ +# This sets the default behaviour, overriding core.autocrlf +* text=auto + +# All source files should have unix line-endings in the repository, +# but convert to native line-endings on checkout +*.cpp text +*.h text +*.hpp text + +# Windows specific files should retain windows line-endings +*.sln text eol=crlf + +# Keep executable scripts with LFs so they can be run after being +# checked out on Windows +*.py text eol=lf + + +# Keep the single include header with LFs to make sure it is uploaded, +# hashed etc with LF +single_include/*.hpp eol=lf +# Also keep the LICENCE file with LFs for the same reason +LICENCE.txt eol=lf diff --git a/src/third_party/cppcodec/test/catch/.github/issue_template.md b/src/third_party/cppcodec/test/catch/.github/issue_template.md new file mode 100644 index 0000000000..051b5e5f83 --- /dev/null +++ b/src/third_party/cppcodec/test/catch/.github/issue_template.md @@ -0,0 +1,29 @@ +## Description + + + +### Steps to reproduce + + + +### Extra information + +* Catch version: **v42.42.42** +* Operating System: **Joe's discount operating system** +* Compiler+version: **Hidden Dragon v1.2.3** diff --git a/src/third_party/cppcodec/test/catch/.github/pull_request_template.md b/src/third_party/cppcodec/test/catch/.github/pull_request_template.md new file mode 100644 index 0000000000..368f41fb1e --- /dev/null +++ b/src/third_party/cppcodec/test/catch/.github/pull_request_template.md @@ -0,0 +1,28 @@ + + + +## Description + + +## GitHub Issues + diff --git a/src/third_party/cppcodec/test/catch/.gitignore b/src/third_party/cppcodec/test/catch/.gitignore new file mode 100644 index 0000000000..ffce8e91c7 --- /dev/null +++ b/src/third_party/cppcodec/test/catch/.gitignore @@ -0,0 +1,29 @@ +*.build +*.pbxuser +*.mode1v3 +*.ncb +*.suo +Debug +Release +*.user +*.xcuserstate +.DS_Store +xcuserdata +CatchSelfTest.xcscheme +Breakpoints.xcbkptlist +projects/VS2010/TestCatch/_UpgradeReport_Files/ +projects/VS2010/TestCatch/TestCatch/TestCatch.vcxproj.filters +projects/VisualStudio/TestCatch/UpgradeLog.XML +projects/CMake/.idea +projects/CMake/cmake-build-debug +UpgradeLog.XML +Resources/DWARF +projects/Generated +*.pyc +DerivedData +*.xccheckout +Build +.idea +.vs +cmake-build-* +benchmark-dir diff --git a/src/third_party/cppcodec/test/catch/.travis.yml b/src/third_party/cppcodec/test/catch/.travis.yml new file mode 100644 index 0000000000..14595f7888 --- /dev/null +++ b/src/third_party/cppcodec/test/catch/.travis.yml @@ -0,0 +1,285 @@ +language: cpp +sudo: false + +branches: + except: + - /dev-appveyor.*/ + +common_sources: &all_sources + - ubuntu-toolchain-r-test + - llvm-toolchain-trusty + - llvm-toolchain-trusty-3.9 + - llvm-toolchain-trusty-4.0 + - llvm-toolchain-trusty-5.0 + - llvm-toolchain-trusty-6.0 + +matrix: + include: + + # 1/ Linux Clang Builds + - os: linux + compiler: clang + addons: + apt: + sources: *all_sources + packages: ['clang-3.5'] + env: COMPILER='clang++-3.5' + + - os: linux + compiler: clang + addons: + apt: + sources: *all_sources + packages: ['clang-3.6'] + env: COMPILER='clang++-3.6' + + # Clang 3.7 is intentionally skipped as we cannot get it easily on + # TravisCI container + + - os: linux + compiler: clang + addons: + apt: + sources: *all_sources + packages: ['lcov', 'clang-3.8'] + env: COMPILER='clang++-3.8' + + - os: linux + compiler: clang + addons: + apt: + sources: *all_sources + packages: ['clang-3.9'] + env: COMPILER='clang++-3.9' + + - os: linux + compiler: clang + addons: + apt: + sources: *all_sources + packages: ['clang-4.0'] + env: COMPILER='clang++-4.0' + + - os: linux + compiler: clang + addons: + apt: + sources: *all_sources + packages: ['clang-5.0'] + env: COMPILER='clang++-5.0' + + - os: linux + compiler: clang + addons: + apt: + sources: *all_sources + packages: ['clang-6.0'] + env: COMPILER='clang++-6.0' + + # 2/ Linux GCC Builds + - os: linux + compiler: gcc + addons: + apt: + sources: *all_sources + packages: ['g++-4.8'] + env: COMPILER='g++-4.8' + + - os: linux + compiler: gcc + addons: + apt: + sources: *all_sources + packages: ['g++-4.9'] + env: COMPILER='g++-4.9' + + - os: linux + compiler: gcc + addons: + apt: + sources: *all_sources + packages: ['g++-5'] + env: COMPILER='g++-5' + + - os: linux + compiler: gcc + addons: &gcc6 + apt: + sources: *all_sources + packages: ['g++-6'] + env: COMPILER='g++-6' + + - os: linux + compiler: gcc + addons: &gcc7 + apt: + sources: *all_sources + packages: ['g++-7'] + env: COMPILER='g++-7' + + - os: linux + compiler: gcc + addons: &gcc8 + apt: + sources: *all_sources + packages: ['g++-8'] + env: COMPILER='g++-8' + + # 3b/ Linux C++14 Clang builds + # Note that we need newer libstdc++ for C++14 support + - os: linux + compiler: clang + addons: + apt: + packages: ['clang-3.8', 'libstdc++-6-dev'] + sources: + - ubuntu-toolchain-r-test + - llvm-toolchain-trusty + env: COMPILER='clang++-3.8' CPP14=1 + + - os: linux + compiler: clang + addons: + apt: + sources: *all_sources + packages: ['clang-3.9', 'libstdc++-6-dev'] + env: COMPILER='clang++-3.9' CPP14=1 + + - os: linux + compiler: clang + addons: + apt: + sources: *all_sources + packages: ['clang-4.0', 'libstdc++-6-dev'] + env: COMPILER='clang++-4.0' CPP14=1 + + - os: linux + compiler: clang + addons: + apt: + sources: *all_sources + packages: ['clang-5.0', 'libstdc++-6-dev'] + env: COMPILER='clang++-5.0' CPP14=1 + + - os: linux + compiler: clang + addons: + apt: + sources: *all_sources + packages: ['clang-6.0', 'libstdc++-6-dev'] + env: COMPILER='clang++-6.0' CPP14=1 + + + # 4a/ Linux C++14 GCC builds + - os: linux + compiler: gcc + addons: *gcc6 + env: COMPILER='g++-6' CPP14=1 + + - os: linux + compiler: gcc + addons: *gcc7 + env: COMPILER='g++-7' CPP14=1 + + - os: linux + compiler: gcc + addons: *gcc8 + env: COMPILER='g++-8' CPP14=1 + + # 5/ OSX Clang Builds + - os: osx + osx_image: xcode7.3 + compiler: clang + env: COMPILER='clang++' + + - os: osx + osx_image: xcode8 + compiler: clang + env: COMPILER='clang++' + + - os: osx + osx_image: xcode9 + compiler: clang + env: COMPILER='clang++' + + - os: osx + osx_image: xcode9.1 + compiler: clang + env: COMPILER='clang++' + + - os: osx + osx_image: xcode9.1 + compiler: clang + env: COMPILER='clang++' CPP14=1 + + # 6/ Special builds -- examples, coverage, valgrind, etc. + - os: linux + compiler: gcc + addons: + apt: + sources: *all_sources + packages: ['lcov', 'g++-7'] + env: COMPILER='g++-7' CPP14=1 EXAMPLES=1 COVERAGE=1 + + - os: linux + compiler: clang + addons: + apt: + packages: ['clang-3.8', 'lcov'] + sources: + - ubuntu-toolchain-r-test + - llvm-toolchain-trusty + env: COMPILER='clang++-3.8' EXAMPLES=1 COVERAGE=1 + + - os: linux + compiler: gcc + addons: + apt: + sources: *all_sources + packages: ['valgrind', 'lcov', 'g++-7'] + env: COMPILER='g++-7' CPP14=1 VALGRIND=1 + + - os: osx + osx_image: xcode9.1 + compiler: clang + env: COMPILER='clang++' CPP14=1 EXAMPLES=1 COVERAGE=1 + +install: + - DEPS_DIR="${TRAVIS_BUILD_DIR}/deps" + - mkdir -p ${DEPS_DIR} && cd ${DEPS_DIR} + - | + if [[ "${TRAVIS_OS_NAME}" == "linux" ]]; then + CMAKE_URL="http://www.cmake.org/files/v3.5/cmake-3.5.2-Linux-x86_64.tar.gz" + mkdir cmake && travis_retry wget --no-check-certificate --quiet -O - ${CMAKE_URL} | tar --strip-components=1 -xz -C cmake + export PATH=${DEPS_DIR}/cmake/bin:${PATH} + elif [[ "${TRAVIS_OS_NAME}" == "osx" ]]; then + which cmake || brew install cmake; + fi + +before_script: + - export CXX=${COMPILER} + - cd ${TRAVIS_BUILD_DIR} + # Regenerate single header file, so it is tested in the examples... + - python scripts/generateSingleHeader.py + + # Use Debug builds for running Valgrind and building examples + - cmake -H. -BBuild-Debug -DCMAKE_BUILD_TYPE=Debug -Wdev -DUSE_CPP14=${CPP14} -DCATCH_USE_VALGRIND=${VALGRIND} -DCATCH_BUILD_EXAMPLES=${EXAMPLES} -DCATCH_ENABLE_COVERAGE=${COVERAGE} + # Don't bother with release build for coverage build + - cmake -H. -BBuild-Release -DCMAKE_BUILD_TYPE=Release -Wdev -DUSE_CPP14=${CPP14} + + +script: + - cd Build-Debug + - make -j 2 + - CTEST_OUTPUT_ON_FAILURE=1 ctest -j 2 + # Coverage collection does not work for OS X atm + - | + if [[ "${TRAVIS_OS_NAME}" == "linux" ]] && [[ "${COVERAGE}" == "1" ]]; then + make gcov + make lcov + bash <(curl -s https://codecov.io/bash) -X gcov || echo "Codecov did not collect coverage reports" + fi + - # Go to release build + - cd ../Build-Release + - make -j 2 + - CTEST_OUTPUT_ON_FAILURE=1 ctest -j 2 diff --git a/src/third_party/cppcodec/test/catch/CMake/Catch2Config.cmake.in b/src/third_party/cppcodec/test/catch/CMake/Catch2Config.cmake.in new file mode 100644 index 0000000000..c485219cdb --- /dev/null +++ b/src/third_party/cppcodec/test/catch/CMake/Catch2Config.cmake.in @@ -0,0 +1,10 @@ +@PACKAGE_INIT@ + + +# Avoid repeatedly including the targets +if(NOT TARGET Catch2::Catch2) + # Provide path for scripts + list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_LIST_DIR}") + + include(${CMAKE_CURRENT_LIST_DIR}/Catch2Targets.cmake) +endif() diff --git a/src/third_party/cppcodec/test/catch/CMake/FindGcov.cmake b/src/third_party/cppcodec/test/catch/CMake/FindGcov.cmake new file mode 100644 index 0000000000..6ffd6eacb1 --- /dev/null +++ b/src/third_party/cppcodec/test/catch/CMake/FindGcov.cmake @@ -0,0 +1,157 @@ +# This file is part of CMake-codecov. +# +# Copyright (c) +# 2015-2017 RWTH Aachen University, Federal Republic of Germany +# +# See the LICENSE file in the package base directory for details +# +# Written by Alexander Haase, alexander.haase@rwth-aachen.de +# + + +# include required Modules +include(FindPackageHandleStandardArgs) + + +# Search for gcov binary. +set(CMAKE_REQUIRED_QUIET_SAVE ${CMAKE_REQUIRED_QUIET}) +set(CMAKE_REQUIRED_QUIET ${codecov_FIND_QUIETLY}) + +get_property(ENABLED_LANGUAGES GLOBAL PROPERTY ENABLED_LANGUAGES) +foreach (LANG ${ENABLED_LANGUAGES}) + # Gcov evaluation is dependend on the used compiler. Check gcov support for + # each compiler that is used. If gcov binary was already found for this + # compiler, do not try to find it again. + if (NOT GCOV_${CMAKE_${LANG}_COMPILER_ID}_BIN) + get_filename_component(COMPILER_PATH "${CMAKE_${LANG}_COMPILER}" PATH) + + if ("${CMAKE_${LANG}_COMPILER_ID}" STREQUAL "GNU") + # Some distributions like OSX (homebrew) ship gcov with the compiler + # version appended as gcov-x. To find this binary we'll build the + # suggested binary name with the compiler version. + string(REGEX MATCH "^[0-9]+" GCC_VERSION + "${CMAKE_${LANG}_COMPILER_VERSION}") + + find_program(GCOV_BIN NAMES gcov-${GCC_VERSION} gcov + HINTS ${COMPILER_PATH}) + + elseif ("${CMAKE_${LANG}_COMPILER_ID}" STREQUAL "Clang") + # Some distributions like Debian ship llvm-cov with the compiler + # version appended as llvm-cov-x.y. To find this binary we'll build + # the suggested binary name with the compiler version. + string(REGEX MATCH "^[0-9]+.[0-9]+" LLVM_VERSION + "${CMAKE_${LANG}_COMPILER_VERSION}") + + # llvm-cov prior version 3.5 seems to be not working with coverage + # evaluation tools, but these versions are compatible with the gcc + # gcov tool. + if(LLVM_VERSION VERSION_GREATER 3.4) + find_program(LLVM_COV_BIN NAMES "llvm-cov-${LLVM_VERSION}" + "llvm-cov" HINTS ${COMPILER_PATH}) + mark_as_advanced(LLVM_COV_BIN) + + if (LLVM_COV_BIN) + find_program(LLVM_COV_WRAPPER "llvm-cov-wrapper" PATHS + ${CMAKE_MODULE_PATH}) + if (LLVM_COV_WRAPPER) + set(GCOV_BIN "${LLVM_COV_WRAPPER}" CACHE FILEPATH "") + + # set additional parameters + set(GCOV_${CMAKE_${LANG}_COMPILER_ID}_ENV + "LLVM_COV_BIN=${LLVM_COV_BIN}" CACHE STRING + "Environment variables for llvm-cov-wrapper.") + mark_as_advanced(GCOV_${CMAKE_${LANG}_COMPILER_ID}_ENV) + endif () + endif () + endif () + + if (NOT GCOV_BIN) + # Fall back to gcov binary if llvm-cov was not found or is + # incompatible. This is the default on OSX, but may crash on + # recent Linux versions. + find_program(GCOV_BIN gcov HINTS ${COMPILER_PATH}) + endif () + endif () + + + if (GCOV_BIN) + set(GCOV_${CMAKE_${LANG}_COMPILER_ID}_BIN "${GCOV_BIN}" CACHE STRING + "${LANG} gcov binary.") + + if (NOT CMAKE_REQUIRED_QUIET) + message("-- Found gcov evaluation for " + "${CMAKE_${LANG}_COMPILER_ID}: ${GCOV_BIN}") + endif() + + unset(GCOV_BIN CACHE) + endif () + endif () +endforeach () + + + + +# Add a new global target for all gcov targets. This target could be used to +# generate the gcov files for the whole project instead of calling -gcov +# for each target. +if (NOT TARGET gcov) + add_custom_target(gcov) +endif (NOT TARGET gcov) + + + +# This function will add gcov evaluation for target . Only sources of +# this target will be evaluated and no dependencies will be added. It will call +# Gcov on any source file of once and store the gcov file in the same +# directory. +function (add_gcov_target TNAME) + set(TDIR ${CMAKE_CURRENT_BINARY_DIR}/CMakeFiles/${TNAME}.dir) + + # We don't have to check, if the target has support for coverage, thus this + # will be checked by add_coverage_target in Findcoverage.cmake. Instead we + # have to determine which gcov binary to use. + get_target_property(TSOURCES ${TNAME} SOURCES) + set(SOURCES "") + set(TCOMPILER "") + foreach (FILE ${TSOURCES}) + codecov_path_of_source(${FILE} FILE) + if (NOT "${FILE}" STREQUAL "") + codecov_lang_of_source(${FILE} LANG) + if (NOT "${LANG}" STREQUAL "") + list(APPEND SOURCES "${FILE}") + set(TCOMPILER ${CMAKE_${LANG}_COMPILER_ID}) + endif () + endif () + endforeach () + + # If no gcov binary was found, coverage data can't be evaluated. + if (NOT GCOV_${TCOMPILER}_BIN) + message(WARNING "No coverage evaluation binary found for ${TCOMPILER}.") + return() + endif () + + set(GCOV_BIN "${GCOV_${TCOMPILER}_BIN}") + set(GCOV_ENV "${GCOV_${TCOMPILER}_ENV}") + + + set(BUFFER "") + foreach(FILE ${SOURCES}) + get_filename_component(FILE_PATH "${TDIR}/${FILE}" PATH) + + # call gcov + add_custom_command(OUTPUT ${TDIR}/${FILE}.gcov + COMMAND ${GCOV_ENV} ${GCOV_BIN} ${TDIR}/${FILE}.gcno > /dev/null + DEPENDS ${TNAME} ${TDIR}/${FILE}.gcno + WORKING_DIRECTORY ${FILE_PATH} + ) + + list(APPEND BUFFER ${TDIR}/${FILE}.gcov) + endforeach() + + + # add target for gcov evaluation of + add_custom_target(${TNAME}-gcov DEPENDS ${BUFFER}) + + # add evaluation target to the global gcov target. + add_dependencies(gcov ${TNAME}-gcov) +endfunction (add_gcov_target) diff --git a/src/third_party/cppcodec/test/catch/CMake/FindLcov.cmake b/src/third_party/cppcodec/test/catch/CMake/FindLcov.cmake new file mode 100644 index 0000000000..beb925ae06 --- /dev/null +++ b/src/third_party/cppcodec/test/catch/CMake/FindLcov.cmake @@ -0,0 +1,354 @@ +# This file is part of CMake-codecov. +# +# Copyright (c) +# 2015-2017 RWTH Aachen University, Federal Republic of Germany +# +# See the LICENSE file in the package base directory for details +# +# Written by Alexander Haase, alexander.haase@rwth-aachen.de +# + + +# configuration +set(LCOV_DATA_PATH "${CMAKE_BINARY_DIR}/lcov/data") +set(LCOV_DATA_PATH_INIT "${LCOV_DATA_PATH}/init") +set(LCOV_DATA_PATH_CAPTURE "${LCOV_DATA_PATH}/capture") +set(LCOV_HTML_PATH "${CMAKE_BINARY_DIR}/lcov/html") + + + + +# Search for Gcov which is used by Lcov. +find_package(Gcov) + + + + +# This function will add lcov evaluation for target . Only sources of +# this target will be evaluated and no dependencies will be added. It will call +# geninfo on any source file of once and store the info file in the same +# directory. +# +# Note: This function is only a wrapper to define this function always, even if +# coverage is not supported by the compiler or disabled. This function must +# be defined here, because the module will be exited, if there is no coverage +# support by the compiler or it is disabled by the user. +function (add_lcov_target TNAME) + if (LCOV_FOUND) + # capture initial coverage data + lcov_capture_initial_tgt(${TNAME}) + + # capture coverage data after execution + lcov_capture_tgt(${TNAME}) + endif () +endfunction (add_lcov_target) + + + + +# include required Modules +include(FindPackageHandleStandardArgs) + +# Search for required lcov binaries. +find_program(LCOV_BIN lcov) +find_program(GENINFO_BIN geninfo) +find_program(GENHTML_BIN genhtml) +find_package_handle_standard_args(lcov + REQUIRED_VARS LCOV_BIN GENINFO_BIN GENHTML_BIN +) + +# enable genhtml C++ demangeling, if c++filt is found. +set(GENHTML_CPPFILT_FLAG "") +find_program(CPPFILT_BIN c++filt) +if (NOT CPPFILT_BIN STREQUAL "") + set(GENHTML_CPPFILT_FLAG "--demangle-cpp") +endif (NOT CPPFILT_BIN STREQUAL "") + +# enable no-external flag for lcov, if available. +if (GENINFO_BIN AND NOT DEFINED GENINFO_EXTERN_FLAG) + set(FLAG "") + execute_process(COMMAND ${GENINFO_BIN} --help OUTPUT_VARIABLE GENINFO_HELP) + string(REGEX MATCH "external" GENINFO_RES "${GENINFO_HELP}") + if (GENINFO_RES) + set(FLAG "--no-external") + endif () + + set(GENINFO_EXTERN_FLAG "${FLAG}" + CACHE STRING "Geninfo flag to exclude system sources.") +endif () + +# If Lcov was not found, exit module now. +if (NOT LCOV_FOUND) + return() +endif (NOT LCOV_FOUND) + + + + +# Create directories to be used. +file(MAKE_DIRECTORY ${LCOV_DATA_PATH_INIT}) +file(MAKE_DIRECTORY ${LCOV_DATA_PATH_CAPTURE}) + +set(LCOV_REMOVE_PATTERNS "") + +# This function will merge lcov files to a single target file. Additional lcov +# flags may be set with setting LCOV_EXTRA_FLAGS before calling this function. +function (lcov_merge_files OUTFILE ...) + # Remove ${OUTFILE} from ${ARGV} and generate lcov parameters with files. + list(REMOVE_AT ARGV 0) + + # Generate merged file. + string(REPLACE "${CMAKE_BINARY_DIR}/" "" FILE_REL "${OUTFILE}") + add_custom_command(OUTPUT "${OUTFILE}.raw" + COMMAND cat ${ARGV} > ${OUTFILE}.raw + DEPENDS ${ARGV} + COMMENT "Generating ${FILE_REL}" + ) + + add_custom_command(OUTPUT "${OUTFILE}" + COMMAND ${LCOV_BIN} --quiet -a ${OUTFILE}.raw --output-file ${OUTFILE} + --base-directory ${PROJECT_SOURCE_DIR} ${LCOV_EXTRA_FLAGS} + COMMAND ${LCOV_BIN} --quiet -r ${OUTFILE} ${LCOV_REMOVE_PATTERNS} + --output-file ${OUTFILE} ${LCOV_EXTRA_FLAGS} + DEPENDS ${OUTFILE}.raw + COMMENT "Post-processing ${FILE_REL}" + ) +endfunction () + + + + +# Add a new global target to generate initial coverage reports for all targets. +# This target will be used to generate the global initial info file, which is +# used to gather even empty report data. +if (NOT TARGET lcov-capture-init) + add_custom_target(lcov-capture-init) + set(LCOV_CAPTURE_INIT_FILES "" CACHE INTERNAL "") +endif (NOT TARGET lcov-capture-init) + + +# This function will add initial capture of coverage data for target , +# which is needed to get also data for objects, which were not loaded at +# execution time. It will call geninfo for every source file of once and +# store the info file in the same directory. +function (lcov_capture_initial_tgt TNAME) + # We don't have to check, if the target has support for coverage, thus this + # will be checked by add_coverage_target in Findcoverage.cmake. Instead we + # have to determine which gcov binary to use. + get_target_property(TSOURCES ${TNAME} SOURCES) + set(SOURCES "") + set(TCOMPILER "") + foreach (FILE ${TSOURCES}) + codecov_path_of_source(${FILE} FILE) + if (NOT "${FILE}" STREQUAL "") + codecov_lang_of_source(${FILE} LANG) + if (NOT "${LANG}" STREQUAL "") + list(APPEND SOURCES "${FILE}") + set(TCOMPILER ${CMAKE_${LANG}_COMPILER_ID}) + endif () + endif () + endforeach () + + # If no gcov binary was found, coverage data can't be evaluated. + if (NOT GCOV_${TCOMPILER}_BIN) + message(WARNING "No coverage evaluation binary found for ${TCOMPILER}.") + return() + endif () + + set(GCOV_BIN "${GCOV_${TCOMPILER}_BIN}") + set(GCOV_ENV "${GCOV_${TCOMPILER}_ENV}") + + + set(TDIR ${CMAKE_CURRENT_BINARY_DIR}/CMakeFiles/${TNAME}.dir) + set(GENINFO_FILES "") + foreach(FILE ${SOURCES}) + # generate empty coverage files + set(OUTFILE "${TDIR}/${FILE}.info.init") + list(APPEND GENINFO_FILES ${OUTFILE}) + + add_custom_command(OUTPUT ${OUTFILE} COMMAND ${GCOV_ENV} ${GENINFO_BIN} + --quiet --base-directory ${PROJECT_SOURCE_DIR} --initial + --gcov-tool ${GCOV_BIN} --output-filename ${OUTFILE} + ${GENINFO_EXTERN_FLAG} ${TDIR}/${FILE}.gcno + DEPENDS ${TNAME} + COMMENT "Capturing initial coverage data for ${FILE}" + ) + endforeach() + + # Concatenate all files generated by geninfo to a single file per target. + set(OUTFILE "${LCOV_DATA_PATH_INIT}/${TNAME}.info") + set(LCOV_EXTRA_FLAGS "--initial") + lcov_merge_files("${OUTFILE}" ${GENINFO_FILES}) + add_custom_target(${TNAME}-capture-init ALL DEPENDS ${OUTFILE}) + + # add geninfo file generation to global lcov-geninfo target + add_dependencies(lcov-capture-init ${TNAME}-capture-init) + set(LCOV_CAPTURE_INIT_FILES "${LCOV_CAPTURE_INIT_FILES}" + "${OUTFILE}" CACHE INTERNAL "" + ) +endfunction (lcov_capture_initial_tgt) + + +# This function will generate the global info file for all targets. It has to be +# called after all other CMake functions in the root CMakeLists.txt file, to get +# a full list of all targets that generate coverage data. +function (lcov_capture_initial) + # Skip this function (and do not create the following targets), if there are + # no input files. + if ("${LCOV_CAPTURE_INIT_FILES}" STREQUAL "") + return() + endif () + + # Add a new target to merge the files of all targets. + set(OUTFILE "${LCOV_DATA_PATH_INIT}/all_targets.info") + lcov_merge_files("${OUTFILE}" ${LCOV_CAPTURE_INIT_FILES}) + add_custom_target(lcov-geninfo-init ALL DEPENDS ${OUTFILE} + lcov-capture-init + ) +endfunction (lcov_capture_initial) + + + + +# Add a new global target to generate coverage reports for all targets. This +# target will be used to generate the global info file. +if (NOT TARGET lcov-capture) + add_custom_target(lcov-capture) + set(LCOV_CAPTURE_FILES "" CACHE INTERNAL "") +endif (NOT TARGET lcov-capture) + + +# This function will add capture of coverage data for target , which is +# needed to get also data for objects, which were not loaded at execution time. +# It will call geninfo for every source file of once and store the info +# file in the same directory. +function (lcov_capture_tgt TNAME) + # We don't have to check, if the target has support for coverage, thus this + # will be checked by add_coverage_target in Findcoverage.cmake. Instead we + # have to determine which gcov binary to use. + get_target_property(TSOURCES ${TNAME} SOURCES) + set(SOURCES "") + set(TCOMPILER "") + foreach (FILE ${TSOURCES}) + codecov_path_of_source(${FILE} FILE) + if (NOT "${FILE}" STREQUAL "") + codecov_lang_of_source(${FILE} LANG) + if (NOT "${LANG}" STREQUAL "") + list(APPEND SOURCES "${FILE}") + set(TCOMPILER ${CMAKE_${LANG}_COMPILER_ID}) + endif () + endif () + endforeach () + + # If no gcov binary was found, coverage data can't be evaluated. + if (NOT GCOV_${TCOMPILER}_BIN) + message(WARNING "No coverage evaluation binary found for ${TCOMPILER}.") + return() + endif () + + set(GCOV_BIN "${GCOV_${TCOMPILER}_BIN}") + set(GCOV_ENV "${GCOV_${TCOMPILER}_ENV}") + + + set(TDIR ${CMAKE_CURRENT_BINARY_DIR}/CMakeFiles/${TNAME}.dir) + set(GENINFO_FILES "") + foreach(FILE ${SOURCES}) + # Generate coverage files. If no .gcda file was generated during + # execution, the empty coverage file will be used instead. + set(OUTFILE "${TDIR}/${FILE}.info") + list(APPEND GENINFO_FILES ${OUTFILE}) + + add_custom_command(OUTPUT ${OUTFILE} + COMMAND test -f "${TDIR}/${FILE}.gcda" + && ${GCOV_ENV} ${GENINFO_BIN} --quiet --base-directory + ${PROJECT_SOURCE_DIR} --gcov-tool ${GCOV_BIN} + --output-filename ${OUTFILE} ${GENINFO_EXTERN_FLAG} + ${TDIR}/${FILE}.gcda + || cp ${OUTFILE}.init ${OUTFILE} + DEPENDS ${TNAME} ${TNAME}-capture-init + COMMENT "Capturing coverage data for ${FILE}" + ) + endforeach() + + # Concatenate all files generated by geninfo to a single file per target. + set(OUTFILE "${LCOV_DATA_PATH_CAPTURE}/${TNAME}.info") + lcov_merge_files("${OUTFILE}" ${GENINFO_FILES}) + add_custom_target(${TNAME}-geninfo DEPENDS ${OUTFILE}) + + # add geninfo file generation to global lcov-capture target + add_dependencies(lcov-capture ${TNAME}-geninfo) + set(LCOV_CAPTURE_FILES "${LCOV_CAPTURE_FILES}" "${OUTFILE}" CACHE INTERNAL + "" + ) + + # Add target for generating html output for this target only. + file(MAKE_DIRECTORY ${LCOV_HTML_PATH}/${TNAME}) + add_custom_target(${TNAME}-genhtml + COMMAND ${GENHTML_BIN} --quiet --sort --prefix ${PROJECT_SOURCE_DIR} + --baseline-file ${LCOV_DATA_PATH_INIT}/${TNAME}.info + --output-directory ${LCOV_HTML_PATH}/${TNAME} + --title "${CMAKE_PROJECT_NAME} - target ${TNAME}" + ${GENHTML_CPPFILT_FLAG} ${OUTFILE} + DEPENDS ${TNAME}-geninfo ${TNAME}-capture-init + ) +endfunction (lcov_capture_tgt) + + +# This function will generate the global info file for all targets. It has to be +# called after all other CMake functions in the root CMakeLists.txt file, to get +# a full list of all targets that generate coverage data. +function (lcov_capture) + # Skip this function (and do not create the following targets), if there are + # no input files. + if ("${LCOV_CAPTURE_FILES}" STREQUAL "") + return() + endif () + + # Add a new target to merge the files of all targets. + set(OUTFILE "${LCOV_DATA_PATH_CAPTURE}/all_targets.info") + lcov_merge_files("${OUTFILE}" ${LCOV_CAPTURE_FILES}) + add_custom_target(lcov-geninfo DEPENDS ${OUTFILE} lcov-capture) + + # Add a new global target for all lcov targets. This target could be used to + # generate the lcov html output for the whole project instead of calling + # -geninfo and -genhtml for each target. It will also be + # used to generate a html site for all project data together instead of one + # for each target. + if (NOT TARGET lcov) + file(MAKE_DIRECTORY ${LCOV_HTML_PATH}/all_targets) + add_custom_target(lcov + COMMAND ${GENHTML_BIN} --quiet --sort + --baseline-file ${LCOV_DATA_PATH_INIT}/all_targets.info + --output-directory ${LCOV_HTML_PATH}/all_targets + --title "${CMAKE_PROJECT_NAME}" --prefix "${PROJECT_SOURCE_DIR}" + ${GENHTML_CPPFILT_FLAG} ${OUTFILE} + DEPENDS lcov-geninfo-init lcov-geninfo + ) + endif () +endfunction (lcov_capture) + + + + +# Add a new global target to generate the lcov html report for the whole project +# instead of calling -genhtml for each target (to create an own report +# for each target). Instead of the lcov target it does not require geninfo for +# all targets, so you have to call -geninfo to generate the info files +# the targets you'd like to have in your report or lcov-geninfo for generating +# info files for all targets before calling lcov-genhtml. +file(MAKE_DIRECTORY ${LCOV_HTML_PATH}/selected_targets) +if (NOT TARGET lcov-genhtml) + add_custom_target(lcov-genhtml + COMMAND ${GENHTML_BIN} + --quiet + --output-directory ${LCOV_HTML_PATH}/selected_targets + --title \"${CMAKE_PROJECT_NAME} - targets `find + ${LCOV_DATA_PATH_CAPTURE} -name \"*.info\" ! -name + \"all_targets.info\" -exec basename {} .info \\\;`\" + --prefix ${PROJECT_SOURCE_DIR} + --sort + ${GENHTML_CPPFILT_FLAG} + `find ${LCOV_DATA_PATH_CAPTURE} -name \"*.info\" ! -name + \"all_targets.info\"` + ) +endif (NOT TARGET lcov-genhtml) diff --git a/src/third_party/cppcodec/test/catch/CMake/Findcodecov.cmake b/src/third_party/cppcodec/test/catch/CMake/Findcodecov.cmake new file mode 100644 index 0000000000..fa135fa8fd --- /dev/null +++ b/src/third_party/cppcodec/test/catch/CMake/Findcodecov.cmake @@ -0,0 +1,258 @@ +# This file is part of CMake-codecov. +# +# Copyright (c) +# 2015-2017 RWTH Aachen University, Federal Republic of Germany +# +# See the LICENSE file in the package base directory for details +# +# Written by Alexander Haase, alexander.haase@rwth-aachen.de +# + + +# Add an option to choose, if coverage should be enabled or not. If enabled +# marked targets will be build with coverage support and appropriate targets +# will be added. If disabled coverage will be ignored for *ALL* targets. +option(ENABLE_COVERAGE "Enable coverage build." OFF) + +set(COVERAGE_FLAG_CANDIDATES + # gcc and clang + "-O0 -g -fprofile-arcs -ftest-coverage" + + # gcc and clang fallback + "-O0 -g --coverage" +) + + +# Add coverage support for target ${TNAME} and register target for coverage +# evaluation. If coverage is disabled or not supported, this function will +# simply do nothing. +# +# Note: This function is only a wrapper to define this function always, even if +# coverage is not supported by the compiler or disabled. This function must +# be defined here, because the module will be exited, if there is no coverage +# support by the compiler or it is disabled by the user. +function (add_coverage TNAME) + # only add coverage for target, if coverage is support and enabled. + if (ENABLE_COVERAGE) + foreach (TNAME ${ARGV}) + add_coverage_target(${TNAME}) + endforeach () + endif () +endfunction (add_coverage) + + +# Add global target to gather coverage information after all targets have been +# added. Other evaluation functions could be added here, after checks for the +# specific module have been passed. +# +# Note: This function is only a wrapper to define this function always, even if +# coverage is not supported by the compiler or disabled. This function must +# be defined here, because the module will be exited, if there is no coverage +# support by the compiler or it is disabled by the user. +function (coverage_evaluate) + # add lcov evaluation + if (LCOV_FOUND) + lcov_capture_initial() + lcov_capture() + endif (LCOV_FOUND) +endfunction () + + +# Exit this module, if coverage is disabled. add_coverage is defined before this +# return, so this module can be exited now safely without breaking any build- +# scripts. +if (NOT ENABLE_COVERAGE) + return() +endif () + + + + +# Find the reuired flags foreach language. +set(CMAKE_REQUIRED_QUIET_SAVE ${CMAKE_REQUIRED_QUIET}) +set(CMAKE_REQUIRED_QUIET ${codecov_FIND_QUIETLY}) + +get_property(ENABLED_LANGUAGES GLOBAL PROPERTY ENABLED_LANGUAGES) +foreach (LANG ${ENABLED_LANGUAGES}) + # Coverage flags are not dependend on language, but the used compiler. So + # instead of searching flags foreach language, search flags foreach compiler + # used. + set(COMPILER ${CMAKE_${LANG}_COMPILER_ID}) + if (NOT COVERAGE_${COMPILER}_FLAGS) + foreach (FLAG ${COVERAGE_FLAG_CANDIDATES}) + if(NOT CMAKE_REQUIRED_QUIET) + message(STATUS "Try ${COMPILER} code coverage flag = [${FLAG}]") + endif() + + set(CMAKE_REQUIRED_FLAGS "${FLAG}") + unset(COVERAGE_FLAG_DETECTED CACHE) + + if (${LANG} STREQUAL "C") + include(CheckCCompilerFlag) + check_c_compiler_flag("${FLAG}" COVERAGE_FLAG_DETECTED) + + elseif (${LANG} STREQUAL "CXX") + include(CheckCXXCompilerFlag) + check_cxx_compiler_flag("${FLAG}" COVERAGE_FLAG_DETECTED) + + elseif (${LANG} STREQUAL "Fortran") + # CheckFortranCompilerFlag was introduced in CMake 3.x. To be + # compatible with older Cmake versions, we will check if this + # module is present before we use it. Otherwise we will define + # Fortran coverage support as not available. + include(CheckFortranCompilerFlag OPTIONAL + RESULT_VARIABLE INCLUDED) + if (INCLUDED) + check_fortran_compiler_flag("${FLAG}" + COVERAGE_FLAG_DETECTED) + elseif (NOT CMAKE_REQUIRED_QUIET) + message("-- Performing Test COVERAGE_FLAG_DETECTED") + message("-- Performing Test COVERAGE_FLAG_DETECTED - Failed" + " (Check not supported)") + endif () + endif() + + if (COVERAGE_FLAG_DETECTED) + set(COVERAGE_${COMPILER}_FLAGS "${FLAG}" + CACHE STRING "${COMPILER} flags for code coverage.") + mark_as_advanced(COVERAGE_${COMPILER}_FLAGS) + break() + else () + message(WARNING "Code coverage is not available for ${COMPILER}" + " compiler. Targets using this compiler will be " + "compiled without it.") + endif () + endforeach () + endif () +endforeach () + +set(CMAKE_REQUIRED_QUIET ${CMAKE_REQUIRED_QUIET_SAVE}) + + + + +# Helper function to get the language of a source file. +function (codecov_lang_of_source FILE RETURN_VAR) + get_filename_component(FILE_EXT "${FILE}" EXT) + string(TOLOWER "${FILE_EXT}" FILE_EXT) + string(SUBSTRING "${FILE_EXT}" 1 -1 FILE_EXT) + + get_property(ENABLED_LANGUAGES GLOBAL PROPERTY ENABLED_LANGUAGES) + foreach (LANG ${ENABLED_LANGUAGES}) + list(FIND CMAKE_${LANG}_SOURCE_FILE_EXTENSIONS "${FILE_EXT}" TEMP) + if (NOT ${TEMP} EQUAL -1) + set(${RETURN_VAR} "${LANG}" PARENT_SCOPE) + return() + endif () + endforeach() + + set(${RETURN_VAR} "" PARENT_SCOPE) +endfunction () + + +# Helper function to get the relative path of the source file destination path. +# This path is needed by FindGcov and FindLcov cmake files to locate the +# captured data. +function (codecov_path_of_source FILE RETURN_VAR) + string(REGEX MATCH "TARGET_OBJECTS:([^ >]+)" _source ${FILE}) + + # If expression was found, SOURCEFILE is a generator-expression for an + # object library. Currently we found no way to call this function automatic + # for the referenced target, so it must be called in the directoryso of the + # object library definition. + if (NOT "${_source}" STREQUAL "") + set(${RETURN_VAR} "" PARENT_SCOPE) + return() + endif () + + + string(REPLACE "${CMAKE_CURRENT_BINARY_DIR}/" "" FILE "${FILE}") + if(IS_ABSOLUTE ${FILE}) + file(RELATIVE_PATH FILE ${CMAKE_CURRENT_SOURCE_DIR} ${FILE}) + endif() + + # get the right path for file + string(REPLACE ".." "__" PATH "${FILE}") + + set(${RETURN_VAR} "${PATH}" PARENT_SCOPE) +endfunction() + + + + +# Add coverage support for target ${TNAME} and register target for coverage +# evaluation. +function(add_coverage_target TNAME) + # Check if all sources for target use the same compiler. If a target uses + # e.g. C and Fortran mixed and uses different compilers (e.g. clang and + # gfortran) this can trigger huge problems, because different compilers may + # use different implementations for code coverage. + get_target_property(TSOURCES ${TNAME} SOURCES) + set(TARGET_COMPILER "") + set(ADDITIONAL_FILES "") + foreach (FILE ${TSOURCES}) + # If expression was found, FILE is a generator-expression for an object + # library. Object libraries will be ignored. + string(REGEX MATCH "TARGET_OBJECTS:([^ >]+)" _file ${FILE}) + if ("${_file}" STREQUAL "") + codecov_lang_of_source(${FILE} LANG) + if (LANG) + list(APPEND TARGET_COMPILER ${CMAKE_${LANG}_COMPILER_ID}) + + list(APPEND ADDITIONAL_FILES "${FILE}.gcno") + list(APPEND ADDITIONAL_FILES "${FILE}.gcda") + endif () + endif () + endforeach () + + list(REMOVE_DUPLICATES TARGET_COMPILER) + list(LENGTH TARGET_COMPILER NUM_COMPILERS) + + if (NUM_COMPILERS GREATER 1) + message(WARNING "Can't use code coverage for target ${TNAME}, because " + "it will be compiled by incompatible compilers. Target will be " + "compiled without code coverage.") + return() + + elseif (NUM_COMPILERS EQUAL 0) + message(WARNING "Can't use code coverage for target ${TNAME}, because " + "it uses an unknown compiler. Target will be compiled without " + "code coverage.") + return() + + elseif (NOT DEFINED "COVERAGE_${TARGET_COMPILER}_FLAGS") + # A warning has been printed before, so just return if flags for this + # compiler aren't available. + return() + endif() + + + # enable coverage for target + set_property(TARGET ${TNAME} APPEND_STRING + PROPERTY COMPILE_FLAGS " ${COVERAGE_${TARGET_COMPILER}_FLAGS}") + set_property(TARGET ${TNAME} APPEND_STRING + PROPERTY LINK_FLAGS " ${COVERAGE_${TARGET_COMPILER}_FLAGS}") + + + # Add gcov files generated by compiler to clean target. + set(CLEAN_FILES "") + foreach (FILE ${ADDITIONAL_FILES}) + codecov_path_of_source(${FILE} FILE) + list(APPEND CLEAN_FILES "CMakeFiles/${TNAME}.dir/${FILE}") + endforeach() + + set_directory_properties(PROPERTIES ADDITIONAL_MAKE_CLEAN_FILES + "${CLEAN_FILES}") + + + add_gcov_target(${TNAME}) + add_lcov_target(${TNAME}) +endfunction(add_coverage_target) + + + + +# Include modules for parsing the collected data and output it in a readable +# format (like gcov and lcov). +find_package(Gcov) +find_package(Lcov) diff --git a/src/third_party/cppcodec/test/catch/CMake/MiscFunctions.cmake b/src/third_party/cppcodec/test/catch/CMake/MiscFunctions.cmake new file mode 100644 index 0000000000..262f7cd829 --- /dev/null +++ b/src/third_party/cppcodec/test/catch/CMake/MiscFunctions.cmake @@ -0,0 +1,26 @@ +#checks that the given hard-coded list contains all headers + sources in the given folder +function(CheckFileList LIST_VAR FOLDER) + set(MESSAGE " should be added to the variable ${LIST_VAR}") + set(MESSAGE "${MESSAGE} in ${CMAKE_CURRENT_LIST_FILE}\n") + file(GLOB GLOBBED_LIST "${FOLDER}/*.cpp" + "${FOLDER}/*.hpp" + "${FOLDER}/*.h") + list(REMOVE_ITEM GLOBBED_LIST ${${LIST_VAR}}) + foreach(EXTRA_ITEM ${GLOBBED_LIST}) + string(REPLACE "${CATCH_DIR}/" "" RELATIVE_FILE_NAME "${EXTRA_ITEM}") + message(AUTHOR_WARNING "The file \"${RELATIVE_FILE_NAME}\"${MESSAGE}") + endforeach() +endfunction() + +function(CheckFileListRec LIST_VAR FOLDER) + set(MESSAGE " should be added to the variable ${LIST_VAR}") + set(MESSAGE "${MESSAGE} in ${CMAKE_CURRENT_LIST_FILE}\n") + file(GLOB_RECURSE GLOBBED_LIST "${FOLDER}/*.cpp" + "${FOLDER}/*.hpp" + "${FOLDER}/*.h") + list(REMOVE_ITEM GLOBBED_LIST ${${LIST_VAR}}) + foreach(EXTRA_ITEM ${GLOBBED_LIST}) + string(REPLACE "${CATCH_DIR}/" "" RELATIVE_FILE_NAME "${EXTRA_ITEM}") + message(AUTHOR_WARNING "The file \"${RELATIVE_FILE_NAME}\"${MESSAGE}") + endforeach() +endfunction() diff --git a/src/third_party/cppcodec/test/catch/CMake/catch2.pc.in b/src/third_party/cppcodec/test/catch/CMake/catch2.pc.in new file mode 100644 index 0000000000..3ac9fbd1a6 --- /dev/null +++ b/src/third_party/cppcodec/test/catch/CMake/catch2.pc.in @@ -0,0 +1,7 @@ +includedir=@CMAKE_INSTALL_FULL_INCLUDEDIR@ + +Name: Catch2 +Description: A modern, C++-native, header-only, test framework for C++11 +URL: https://github.com/catchorg/Catch2 +Version: @Catch2_VERSION@ +Cflags: -I${includedir} diff --git a/src/third_party/cppcodec/test/catch/CMake/llvm-cov-wrapper b/src/third_party/cppcodec/test/catch/CMake/llvm-cov-wrapper new file mode 100755 index 0000000000..2ac3310248 --- /dev/null +++ b/src/third_party/cppcodec/test/catch/CMake/llvm-cov-wrapper @@ -0,0 +1,56 @@ +#!/bin/sh + +# This file is part of CMake-codecov. +# +# Copyright (c) +# 2015-2017 RWTH Aachen University, Federal Republic of Germany +# +# See the LICENSE file in the package base directory for details +# +# Written by Alexander Haase, alexander.haase@rwth-aachen.de +# + +if [ -z "$LLVM_COV_BIN" ] +then + echo "LLVM_COV_BIN not set!" >& 2 + exit 1 +fi + + +# Get LLVM version to find out. +LLVM_VERSION=$($LLVM_COV_BIN -version | grep -i "LLVM version" \ + | sed "s/^\([A-Za-z ]*\)\([0-9]\).\([0-9]\).*$/\2.\3/g") + +if [ "$1" = "-v" ] +then + echo "llvm-cov-wrapper $LLVM_VERSION" + exit 0 +fi + + +if [ -n "$LLVM_VERSION" ] +then + MAJOR=$(echo $LLVM_VERSION | cut -d'.' -f1) + MINOR=$(echo $LLVM_VERSION | cut -d'.' -f2) + + if [ $MAJOR -eq 3 ] && [ $MINOR -le 4 ] + then + if [ -f "$1" ] + then + filename=$(basename "$1") + extension="${filename##*.}" + + case "$extension" in + "gcno") exec $LLVM_COV_BIN --gcno="$1" ;; + "gcda") exec $LLVM_COV_BIN --gcda="$1" ;; + esac + fi + fi + + if [ $MAJOR -eq 3 ] && [ $MINOR -le 5 ] + then + exec $LLVM_COV_BIN $@ + fi +fi + +exec $LLVM_COV_BIN gcov $@ diff --git a/src/third_party/cppcodec/test/catch/CMakeLists.txt b/src/third_party/cppcodec/test/catch/CMakeLists.txt new file mode 100644 index 0000000000..94f90d9f12 --- /dev/null +++ b/src/third_party/cppcodec/test/catch/CMakeLists.txt @@ -0,0 +1,184 @@ +cmake_minimum_required(VERSION 3.5) + +# detect if Catch is being bundled, +# disable testsuite in that case +if(NOT DEFINED PROJECT_NAME) + set(NOT_SUBPROJECT ON) +endif() + +project(Catch2 LANGUAGES CXX VERSION 2.3.0) + +# Provide path for scripts +list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_LIST_DIR}/CMake") + +include(GNUInstallDirs) +include(CMakePackageConfigHelpers) +include(CTest) + +option(CATCH_USE_VALGRIND "Perform SelfTests with Valgrind" OFF) +option(CATCH_BUILD_TESTING "Build SelfTest project" ON) +option(CATCH_BUILD_EXAMPLES "Build documentation examples" OFF) +option(CATCH_ENABLE_COVERAGE "Generate coverage for codecov.io" OFF) +option(CATCH_ENABLE_WERROR "Enable all warnings as errors" ON) +option(CATCH_INSTALL_DOCS "Install documentation alongside library" ON) +option(CATCH_INSTALL_HELPERS "Install contrib alongside library" ON) + + +set_property(GLOBAL PROPERTY USE_FOLDERS ON) + +# define some folders +set(CATCH_DIR ${CMAKE_CURRENT_SOURCE_DIR}) +set(SELF_TEST_DIR ${CATCH_DIR}/projects/SelfTest) +set(BENCHMARK_DIR ${CATCH_DIR}/projects/Benchmark) +set(HEADER_DIR ${CATCH_DIR}/include) + +if(USE_WMAIN) + set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} /ENTRY:wmainCRTStartup") +endif() + +if (BUILD_TESTING AND CATCH_BUILD_TESTING AND NOT_SUBPROJECT) + add_subdirectory(projects) +endif() + +if(CATCH_BUILD_EXAMPLES) + add_subdirectory(examples) +endif() + + +# add catch as a 'linkable' target +add_library(Catch2 INTERFACE) + + + +# depend on some obvious c++11 features so the dependency is transitively added dependents +target_compile_features(Catch2 + INTERFACE + cxx_alignas + cxx_alignof + cxx_attributes + cxx_auto_type + cxx_constexpr + cxx_defaulted_functions + cxx_deleted_functions + cxx_final + cxx_lambdas + cxx_noexcept + cxx_override + cxx_range_for + cxx_rvalue_references + cxx_static_assert + cxx_strong_enums + cxx_trailing_return_types + cxx_unicode_literals + cxx_user_literals + cxx_variadic_macros +) + +target_include_directories(Catch2 + INTERFACE + $ + $ +) + +# provide a namespaced alias for clients to 'link' against if catch is included as a sub-project +add_library(Catch2::Catch2 ALIAS Catch2) + +set(CATCH_CMAKE_CONFIG_DESTINATION "${CMAKE_INSTALL_LIBDIR}/cmake/Catch2") + +include(CMakePackageConfigHelpers) +configure_package_config_file( + ${CMAKE_CURRENT_LIST_DIR}/CMake/Catch2Config.cmake.in + ${CMAKE_CURRENT_BINARY_DIR}/Catch2Config.cmake + INSTALL_DESTINATION + ${CATCH_CMAKE_CONFIG_DESTINATION} +) + + +# create and install an export set for catch target as Catch2::Catch +install( + TARGETS + Catch2 + EXPORT + Catch2Targets + DESTINATION + ${CMAKE_INSTALL_LIBDIR} +) + + +install( + EXPORT + Catch2Targets + NAMESPACE + Catch2:: + DESTINATION + ${CATCH_CMAKE_CONFIG_DESTINATION} +) + +write_basic_package_version_file( + "${CMAKE_CURRENT_BINARY_DIR}/Catch2ConfigVersion.cmake" + COMPATIBILITY + SameMajorVersion +) + +install( + DIRECTORY + "single_include/" + DESTINATION + "${CMAKE_INSTALL_INCLUDEDIR}" +) + +install( + FILES + "${CMAKE_CURRENT_BINARY_DIR}/Catch2Config.cmake" + "${CMAKE_CURRENT_BINARY_DIR}/Catch2ConfigVersion.cmake" + DESTINATION + ${CATCH_CMAKE_CONFIG_DESTINATION} +) + +# Install documentation +if(CATCH_INSTALL_DOCS) + install( + DIRECTORY + docs/ + DESTINATION + "${CMAKE_INSTALL_DOCDIR}" + ) +endif() + +if(CATCH_INSTALL_HELPERS) +# Install CMake scripts +install( + FILES + "contrib/ParseAndAddCatchTests.cmake" + "contrib/Catch.cmake" + "contrib/CatchAddTests.cmake" + DESTINATION + ${CATCH_CMAKE_CONFIG_DESTINATION} +) + +# Install debugger helpers +install( + FILES + "contrib/gdbinit" + "contrib/lldbinit" + DESTINATION + ${CMAKE_INSTALL_DATAROOTDIR}/Catch2 +) +endif() + +## Provide some pkg-config integration +set(PKGCONFIG_INSTALL_DIR + "${CMAKE_INSTALL_DATAROOTDIR}/pkgconfig" + CACHE PATH "Path where catch2.pc is installed" +) +configure_file( + ${CMAKE_CURRENT_SOURCE_DIR}/CMake/catch2.pc.in + ${CMAKE_CURRENT_BINARY_DIR}/catch2.pc + @ONLY +) +install( + FILES + "${CMAKE_CURRENT_BINARY_DIR}/catch2.pc" + DESTINATION + ${PKGCONFIG_INSTALL_DIR} +) diff --git a/src/third_party/cppcodec/test/catch/CODE_OF_CONDUCT.md b/src/third_party/cppcodec/test/catch/CODE_OF_CONDUCT.md new file mode 100644 index 0000000000..be1a688e01 --- /dev/null +++ b/src/third_party/cppcodec/test/catch/CODE_OF_CONDUCT.md @@ -0,0 +1,46 @@ +# Contributor Covenant Code of Conduct + +## Our Pledge + +In the interest of fostering an open and welcoming environment, we as contributors and maintainers pledge to making participation in our project and our community a harassment-free experience for everyone, regardless of age, body size, disability, ethnicity, gender identity and expression, level of experience, nationality, personal appearance, race, religion, or sexual identity and orientation. + +## Our Standards + +Examples of behavior that contributes to creating a positive environment include: + +* Using welcoming and inclusive language +* Being respectful of differing viewpoints and experiences +* Gracefully accepting constructive criticism +* Focusing on what is best for the community +* Showing empathy towards other community members + +Examples of unacceptable behavior by participants include: + +* The use of sexualized language or imagery and unwelcome sexual attention or advances +* Trolling, insulting/derogatory comments, and personal or political attacks +* Public or private harassment +* Publishing others' private information, such as a physical or electronic address, without explicit permission +* Other conduct which could reasonably be considered inappropriate in a professional setting + +## Our Responsibilities + +Project maintainers are responsible for clarifying the standards of acceptable behavior and are expected to take appropriate and fair corrective action in response to any instances of unacceptable behavior. + +Project maintainers have the right and responsibility to remove, edit, or reject comments, commits, code, wiki edits, issues, and other contributions that are not aligned to this Code of Conduct, or to ban temporarily or permanently any contributor for other behaviors that they deem inappropriate, threatening, offensive, or harmful. + +## Scope + +This Code of Conduct applies both within project spaces and in public spaces when an individual is representing the project or its community. Examples of representing a project or community include using an official project e-mail address, posting via an official social media account, or acting as an appointed representative at an online or offline event. Representation of a project may be further defined and clarified by project maintainers. + +## Enforcement + +Instances of abusive, harassing, or otherwise unacceptable behavior may be reported by contacting the project team at github@philnash.me. The project team will review and investigate all complaints, and will respond in a way that it deems appropriate to the circumstances. The project team is obligated to maintain confidentiality with regard to the reporter of an incident. Further details of specific enforcement policies may be posted separately. + +Project maintainers who do not follow or enforce the Code of Conduct in good faith may face temporary or permanent repercussions as determined by other members of the project's leadership. + +## Attribution + +This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4, available at [http://contributor-covenant.org/version/1/4][version] + +[homepage]: http://contributor-covenant.org +[version]: http://contributor-covenant.org/version/1/4/ diff --git a/src/third_party/cppcodec/test/catch/LICENSE.txt b/src/third_party/cppcodec/test/catch/LICENSE.txt new file mode 100644 index 0000000000..36b7cd93cd --- /dev/null +++ b/src/third_party/cppcodec/test/catch/LICENSE.txt @@ -0,0 +1,23 @@ +Boost Software License - Version 1.0 - August 17th, 2003 + +Permission is hereby granted, free of charge, to any person or organization +obtaining a copy of the software and accompanying documentation covered by +this license (the "Software") to use, reproduce, display, distribute, +execute, and transmit the Software, and to prepare derivative works of the +Software, and to permit third-parties to whom the Software is furnished to +do so, all subject to the following: + +The copyright notices in the Software and this entire statement, including +the above license grant, this restriction and the following disclaimer, +must be included in all copies of the Software, in whole or in part, and +all derivative works of the Software, unless such copies or derivative +works are solely in the form of machine-executable object code generated by +a source language processor. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT +SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE +FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE, +ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER +DEALINGS IN THE SOFTWARE. diff --git a/src/third_party/cppcodec/test/catch/README.md b/src/third_party/cppcodec/test/catch/README.md new file mode 100644 index 0000000000..386f8534cd --- /dev/null +++ b/src/third_party/cppcodec/test/catch/README.md @@ -0,0 +1,38 @@ + +![catch logo](artwork/catch2-logo-small.png) + +[![Github Releases](https://img.shields.io/github/release/catchorg/catch2.svg)](https://github.com/catchorg/catch2/releases) +[![Build Status](https://travis-ci.org/catchorg/Catch2.svg?branch=master)](https://travis-ci.org/catchorg/Catch2) +[![Build status](https://ci.appveyor.com/api/projects/status/github/catchorg/Catch2?svg=true)](https://ci.appveyor.com/project/catchorg/catch2) +[![codecov](https://codecov.io/gh/catchorg/Catch2/branch/master/graph/badge.svg)](https://codecov.io/gh/catchorg/Catch2) +[![Try online](https://img.shields.io/badge/try-online-blue.svg)](https://wandbox.org/permlink/Gcuv2Xx3wmWIPNzy) +[![Join the chat in Discord: https://discord.gg/4CWS9zD](https://img.shields.io/badge/Discord-Chat!-brightgreen.svg)](https://discord.gg/4CWS9zD) + + +The latest version of the single header can be downloaded directly using this link + +## Catch2 is released! + +If you've been using an earlier version of Catch, please see the +Breaking Changes section of [the release notes](https://github.com/catchorg/Catch2/releases/tag/v2.0.1) +before moving to Catch2. You might also like to read [this blog post](http://www.levelofindirection.com/journal/2017/11/3/catch2-released.html) for more details. + +## What's the Catch? + +Catch2 stands for C++ Automated Test Cases in a Header and is a +multi-paradigm test framework for C++. which also supports Objective-C +(and maybe C). +It is primarily distributed as a single header file, although certain +extensions may require additional headers. + +## How to use it +This documentation comprises these three parts: + +* [Why do we need yet another C++ Test Framework?](docs/why-catch.md#top) +* [Tutorial](docs/tutorial.md#top) - getting started +* [Reference section](docs/Readme.md#top) - all the details + +## More +* Issues and bugs can be raised on the [Issue tracker on GitHub](https://github.com/catchorg/Catch2/issues) +* For discussion or questions please use [the dedicated Google Groups forum](https://groups.google.com/forum/?fromgroups#!forum/catch-forum) or our [Discord](https://discord.gg/4CWS9zD) +* See [who else is using Catch2](docs/opensource-users.md#top) diff --git a/src/third_party/cppcodec/test/catch/appveyor.yml b/src/third_party/cppcodec/test/catch/appveyor.yml new file mode 100644 index 0000000000..0e97589b57 --- /dev/null +++ b/src/third_party/cppcodec/test/catch/appveyor.yml @@ -0,0 +1,98 @@ +# version string format -- This will be overwritten later anyway +version: "{build}" + +branches: + except: + - /dev-travis.+/ + +os: + - Visual Studio 2017 + - Visual Studio 2015 + +environment: + matrix: + - additional_flags: "/permissive- /std:c++latest" + wmain: 0 + + - additional_flags: "" + wmain: 0 + + - additional_flags: "/D_UNICODE /DUNICODE" + wmain: 1 + coverage: 0 + + # Have a coverage dimension + - additional_flags: "" + wmain: 0 + coverage: 1 + + # Have an examples dimension + - additional_flags: "" + wmain: 0 + examples: 1 + + +matrix: + allow_failures: + - os: Visual Studio 2017 + exclude: + - os: Visual Studio 2015 + additional_flags: "/permissive- /std:c++latest" + + - os: Visual Studio 2015 + additional_flags: "/D_UNICODE /DUNICODE" + + # Exclude unwanted coverage configurations + - coverage: 1 + platform: Win32 + + - coverage: 1 + os: Visual Studio 2015 + + - coverage: 1 + configuration: Release + + # Exclude unwanted examples configurations + - examples: 1 + platform: Win32 + + - examples: 1 + os: Visual Studio 2015 + + - examples: 1 + configuration: Release + + +install: + - ps: if (($env:CONFIGURATION) -eq "Debug" -And ($env:coverage) -eq "1" ) { python -m pip --disable-pip-version-check install codecov } + - ps: if (($env:CONFIGURATION) -eq "Debug" -And ($env:coverage) -eq "1" ) { .\misc\installOpenCppCoverage.ps1 } + +# Win32 and x64 are CMake-compatible solution platform names. +# This allows us to pass %PLATFORM% to CMake -A. +platform: + - Win32 + - x64 + +# build Configurations, i.e. Debug, Release, etc. +configuration: + - Debug + - Release + +#Cmake will autodetect the compiler, but we set the arch +before_build: + - set CXXFLAGS=%additional_flags% + # Indirection because appveyor doesn't handle multiline batch scripts properly + # https://stackoverflow.com/questions/37627248/how-to-split-a-command-over-multiple-lines-in-appveyor-yml/37647169#37647169 + # https://help.appveyor.com/discussions/questions/3888-multi-line-cmd-or-powershell-warning-ignore + - cmd: .\misc\appveyorBuildConfigurationScript.bat + + +# build with MSBuild +build: + project: Build\Catch2.sln # path to Visual Studio solution or project + parallel: true # enable MSBuild parallel builds + verbosity: normal # MSBuild verbosity level {quiet|minimal|normal|detailed} + +test_script: + - set CTEST_OUTPUT_ON_FAILURE=1 + - cmd: .\misc\appveyorTestRunScript.bat diff --git a/src/third_party/cppcodec/test/catch/artwork/catch2-c-logo.png b/src/third_party/cppcodec/test/catch/artwork/catch2-c-logo.png new file mode 100644 index 0000000000000000000000000000000000000000..bab400f91a822bbd14b8712d5815111d4d1b6bea GIT binary patch literal 18222 zcmX6_byU<%7v5bKSh@x2P6b4yyBh>01O%j|LppZp5G18jO1fJ@K%|%MZs~6JTi)*v z4(H78&YhWiC+WXIEo4~ng9S0iv0TpK|_{MGUN;*|A8$fRV4v{ zs&82LCa3^_1VB+n@|_3pAOpS8P`2r@JtLl46GDeiC`Bl>6GX52K||u_v+{SSSP`uC z9BXw37#~M%ZoCh|!bmla>7NxtL1+-F1T_T~R0UQHjJ&KG#F2L#)urI~t9 zBhNOM%a7hegI5n0Q-dFB3KCT4LG-jBdJPC@vu~=4y7uKhNt#uO9hXf_S?OfGHGjF; zz{y_Z)I4<^-KDzl#K#w^f1ax<{0y(eWdE-s91MJSEqcH=|NQ-3ijB^Euh;Y9OM$UZ z?(=}VRMAgY-<7nZi4wMpfnmxj+mTR6m;@2HpJhfO&5~sfvjy<}GMPE|A6e};L#z2Y zccq4vS-RXJU>HQHF#JjO2YBx29P#O>A@OoihU4J_+C>$@5@E3|ze}x&qJfni{ht&F z+<#OVdl~RR_;B6Jgm2i&iZ+Ll?>`r1h^mPKC!u;^e(EX?KI@SwdWEh9|K+#&!exmM zhG@Gc-{yJeOP20{Zvcj4zJlktUs(ThekaQnl>kP8o=L=3)K*P553!T_V!x_(GA zcGGK!&D9$WwLRR_ckK0Nz1y1CyDww`XvTy=Az)SGAx<~Nin`127+PZ){H;($840iq ztp;d++emEjBL!J5BApaJcllHgjQlY5=~P=?WeM|pw*p0pJD_u`jgl1Rh@sLGHz=v| zICx84uZ<(oI1Lpcg&AXfO|_xHoVtlvSGIF_10W&0bn~G>UL^mxK}Pl z_*20N{Bp#4vtMXl@dz*$P~ssg0mf7|77Ou?X73m9*S<}gwS2paD4VkX=)y9Seh{}H zSQ^J+Wp)nMfaM^NhU~<*;xJ+KS^AyP;#M!2o;VPt|M~qRuTxFu<;gph18bWJK%SI# zYy=cSoFdWGuoxHbt6ar!jN#T?mylU~ro?Y7d~I(wH08F;jCJEq#5^{FvVV~ot2Uwd z*YLmYRa&aSh+FUv+&F^<6r4EE7^hkD#$fyZx`&HE(cQwM$cQ zzoCDib>g=gIx06OYwk?k&JVWi?Ipk+30Whg-KFTb?e*_Iu>0=)+SfVoz4xd}0}mu} z;CK(Pyzo6x|N0h3;boBirA@n*ILnA3c!# zf20#XMd}&tYw3xf7AiJI0?VA@p7zWeLpO}~U-B94<|1dZJoZxR1$I5`^eNsqk3Z91 zdyk?)_uuTH*HF#2%|D&DVIfS?O<{NR;x&}RX%8b?N(zCT#WJ*(AQ$G@ z-~)1Rgleo}|o-YbFpej4TQL;V3tQQ$;wuIba4m{%}T?k#_r zG1JHCyGmkr#GC2(aUzL7DWw}vOEdd5Oy{yvJ^$SeMSZFP0@UJ?dtJ@~CD(9Ocv_*= z^pzIk-ue|xmyYbaPP3ubZo0o3FTfh#zDEDI!}Wt3!Ln>+{aN+umFvyUk~k7NuIFh; zhd}aVSFHAGTEj0wo8LrYO?;`@u55-j=NA#l7&8DravhYg+Kc4k(ZeCYuh)96iFLRR zjJDm}bs@fPxO1B-+run-Ef5d6Y}CiEfziRyv)S`&h)SGh)JMFKOW0+|Wk5A>CDmkt zKbuQRu8q& zQJRHaNv%HI1-S5xh-YhMyGzVUC`hqDH<_NPRn~V;Usr7Pqb^r+=w0M^WlaJm7=Emm z6YZd*H%8ya!UMCtr9DZrLXUs00(a`*;!@kvOgRJ+n}{*6w_ORN8_iyTVM2M9k|T1D zBD_690lICs;@#Ts&}l4Pkg7K7?AyU3bNHo+=7pa*DMlz6OE;(&yFZ>&d6PTp?G=$t z0A!f*&yeLTWNw5BB#2DeH`URGBkR{!*-4T*(}MD$hAc7fH^t#iidDd<#u4E|OQ|@4BME^ZeE$GVOl0f`RGo`!L`Xhi~dTsZ9NY;Z8jj(XJUC3G$ zTvCuTBForelAIOj9JYA?C(04iesshVZQNVNI$rFsqK;`)%=QVuF-Uy7=^#9xEyuQt zk^R;gGl>rttFUqgSC^pRT(PD|`E)-(aMdpDpYe%2LI@Sav1G#FJ=B1jqEcO4)u&9E zGy&+&$#=X z-TgyG_>Q+WID|fjM(V~n$&j-69+-n=lEmZbRAj}xIAA!Fn^g>XF*jR2Tz%Sb()ZE` zIRlHoPV}lk9Ni9^;1!ZJWOPa4TF+U2UxD@s*CIbDegs$6cG(Eew(~jEgr}t7yA(LM zyZr?2M9284$9234+wX;+D9Vvr86bj|kB=1m4hLS}7Q5qVjA__JEs|KMk3t}m zfIL~g1rPL&i^%LO*guTdEzZZ>abD;NEeVQ*j2-4w-$iT&cn*#VA0GC{lXos6!G^Pp z>~8>Rw4*R)$T8xVF7WpVwtYX0=?hFg9u_|0XT=)?2h6L>(U-Nw)?Z57xeKjk<1TLtueo#OnMY6 z%4B`r+pZWu8Q=CS^}%qDxj?`RU~|po*J*+CVfv9bv5e^X;*C!F7^*&UpLfEj+;>db zI+F74#VI}0V$zV?r-44QO}-QP+A7lbr}TrB%k9=Gh5Vg}z5ibx>o)+su}hYhhkw5a zp6mJ>oDRqHua5d@;C3d;(8gSNiBYMLf0F-BZNGe!+qGKTUIbJ~tMosi!A?qr#Q_so6ofMN)syK3oE@k(*d)!{0$J|Ik(-mCi22$Hc z2G{h!`hkrLu=Wa#yv-0kK7I#l*0i6)H?!slOUq;7S?E~QAD_PW6M&6~_T%s@G%T*b zEgsg~W7h?qW4dH-`~->tFo(fkJF0ry!GrR4GnWHF3LW<6@}D<3z0hO4pAnA%zGLAY zwPF_cx5wxa&$C8D)_(hRDy0y$oR;3}?-z`@Qs^i2XQ4`}13EwAexaiIYE&NLtOyJ@ z0()GIgsd3(HBHv>Z<^YjF^wP84Njl_X1 zjBmU-B1aomo^8;3sk5>zFj(_R>KB3>_1!lWkKS2vA7NKlk8Kh-6!!_jW1Iiu$-x;)dK}f+~w!%Aj(4Bt2(~rA3-|f$9HEQjr=6V z{mVx_(R)-zkTbUI>j3k#>HSYh*+2W+Pq&8+(5+`emd=TG=?1r6 zGrd$gV7YP)UTx*;peDgPA=}~1d2+GD!5x!t>z=y@2>h z&+h=B8c2i(=0O;h%gyDvJ4q{?cW!m3<(ezD^*p5+dYYHzHy0lR=CXbNxLe~U8qBcL zVIu3C>ua@LQ~%?53CLU2Qi9`qKn5Ebui1Mc5h zZ|JfUE}ii#FRSO0dnGXGB2eoRK&8{%`MoezEjqRY_?N&hLXjr8u_E*{+cq(sH~AX} z%EQ0?{N=NzBlCrJiN2T|8{hia7dgjQcQW6)al7q(nA!BCzAr-S2vphM_&s|4NNSa( z)_d_DoQt0v5sw@0{HbR9MbGVhV5DQALp^aD_N%rPDwCs^g1qq!vm$U|s0GF|j(aEW zZ6V~w{%JE(d5RL-bUCxWlj|9B8!!}S_ouLm9GKzZu|q@>wr2t&;)sUkJ8=v=wwGIO ziio9Gz}JVYb>>oyR`X%jmjx(alRiX>!nRgScC@ZVh;X_=U(viKFY6QCV0F!vEBZR= zlK@xQ-i&1dpKk-gJHyKvA{^EE>7w0W>8f%MfJ*%{*dGT4l*pq0!7%NUp3~Yj}|CUEmFQ z|9a%5+~ZVpdwo&q3AeT)vshDH^P;fjO0t)ej*Tw@{>AW->Z@+Q)ZT#xt!eSnYtU5^ z(#S~>RiuBMosORQWPLYyuJpkKvF$is<@Rp(8Mfb$?m3}==?VsO1J~MGMmswKoWoum z1-_QK8I4*dyg%-6bWK!PqKAJDUGp@4f3tEad$S~z*~uabGy@0*GtP()C<>>prhyD( zn_>Z1)r-K?Yx1ia_ev&H!E?>AScyLrf01!KgCA*IRA8*ZjA~*#R?}vE)C-$*vhR)9 z3;mbsBAPVx2A}YfzSY01ahAoA(9Vljw4{*fs`Hg&B+B?i0JF#N$(w&oE?_e7lh4;l zT(}*U{fM3to*2qQ_yuSV7J`}8OHjH?*Jb*HxJhKqKnvU<{FLc0(;A-w5$d*KHC2&M z(+rgVoiy#U%9BK*z`O|ls=s#(1!>6Bf=IeJjGl1COY`S@xW1@O;jgIyKa$b!j%ou| z2?^xTHBvS;<@RUAV&iMui51T>GYd@hkrzT2qeb3v$5)4^uzK$~w-PK?yWc~-{(`vz zH8)nofe>C5=<7gvX|0T31Hb%|Ohb-4LWa&?&{~isW!8v}pDU>YtjFxc4iR$1#rJ93 zy5XzlJ|2X(vv$!zMfP%TB#V`}WP!oPQA3TYt4y7e15wFv%)?7Ekwd^3cWz8^q@CP?@Y)``v-jn)gML6&Y^*bwa?yH ze*>qm8WbN6zNln=u|ap?QvC4F(^6o^URIkmJFBnqk*@qW>$yz@wmU# zQJKF|Zo6Y3l^cgsR|b3&2Vg8{?w*zuU`}?MZ9*1;_Q}D+lkB|PfFk6CkFq4l`B;iQ z7mb#rw2I*%5Pu=;E_;Tq3xgY{{82dJ;a(5xY};$6rCO~Kx=V$dRzM6dpHTUH^f@)4 zJWpr83keZ!dzs%nuDaT=W)8=4 z=ZySm!^dWp4op0)su#RO2-!?3-F;l4t{TMS9EBO$ybS=I1l!eYIT~$8Md#!IpZKmA`j{xty{&DjitwzULx_aw#|rm zn{pUCjnGyXkI%!4^N8qBtdl6u%TOuZxNije2uqYko~(_?l+VbR)MJvTg{6um!0&Q* zjOa45_SgHKc)r!!lcUJ2!+_6?mhy5}D|?~YBkm#wMGm&L>g)-!v*cYY05J>&Ap+JT z7|T@R<(XROy6=#qRxb7Vm6Tdf>#{$~pV8tEN9Nh{XT zyXxc%ECj1Pit_&yeEfql_A%pKrJ-00tJ9$pwIs`}jfE#Dq+T3#-s zZ)uD~S^tx!gBaj&crr*5el4_=h`V`STjXIhXTxyiZz6>Mv-soX4PpBN^Bfi1N*BI#Q`@#FRnjNoYK z^=nO~v>$xAJja`@Mg`rPqY+Sk@JvtV8#AA#owSp{_!itNW=mnA(@wzIb$K-8T=hQ; zq+(s-bz%XRiQu41*07_Y@aV%1%g)HchBb_*ep%_+d zVH>Y2#B(>$=+jte>aBTRy{ruuaW6jC~R3H*O7GPMP*`-C>+4>lEz zx?~i_YJN(Kyw=78CR0zv)4=S^#B zS;%E?M&=TTT^=*TpR$wwHTboUdPsGnn0wr?=Ca0p7P&{Mk+`Zo9j8iWwR1<0sgO?tlrH zyqriPZH&6kd1J!&l8FUPlesY|PzD^p$W8oF9M3Lq?3@Yv$hGNJL>>ch>AB09tI=sw zCXI`5bD2Xqfd;9@y5MCyM5y^>WjJ(WahXkH*e}tQu@c+p=)mLefP(>w;u<&7c2VX_ z+XOE*{QNmj94XJE{v4wcum_Rm{R;T2D98qS55DZ##-~2o6TPf}BJSRwzr7GB*EZfRdvP=t8MKA2`EJ+}{FAV7ke z`vAO~#yw?o>gjJO#~A~L3Tp&pq2ue-ZoBuMCyqP&xdd=3!z;nxIra#2D)__CkC~mQ z!va-`T=#31T+5_Ro6ifktupu=DsV;_vV4oS=r>h zJsZcW3>5TANrgDZHFa zUdEfmBAY6T3h%mF(zz?7jrJq{c#2w(=Ls_4*v;Ac!Dfd28GxDcax_X4rIM}WMBw~~ zDjvGa2FvmJNT)|y)Q`3{^p#YN|Bou!Q}iT}OO$`lLm=7VTj%&$;0d3w{Lu*KPZh1T zd;D;ShqN(|h~lYiv9gm>?tJvphFKNmb4-`HY|g|`)_QyW7lYMuU~-mYJ}{1_JJ;o% z@)!d*&RhAP?+gV)OMZVJ>&j2Aq0Q#ZzDT%RqiOM*K_$*LKq>Sm%3XhcdoK}UZ5}&; z&G`F|(tp!w@Ac9AbwhmD&CJ(bEd1+q3wn(i1@K{n>vv%m(aq?e)$hRnhy<|3Z)U_P z@;P9BG#_cA{1jt4$ht|G)C~l;YcQ(czN3%9g25EN;7%k)a#{;FwY4(}gKA>mjd>>P z_}p2Bs^k6160(R_mXkuKn+S>2jUrwK|b#BxZOum9DGdd+?VIwh#_; z_SyKAcQ!*<839^5f*F3xuB<| zROeZ*`&r|J+{c?NnPvlkT34?xSAOPgZ+Vs{oRJeux(@MlNy{bP&7k7)*LjATw~r5N z1p5U8IJFlPX9h{#n_VLHKaB}yd4m~a3q8A?RD=|WOCWj5D^y`(->?cG*3PExFVDZ* z-$W4IO;f&%qC3Eu#?)> z;HclvWe0E+Zi8ZnhP`(Ci)wdiO9{+|pVe^VY)A4%`zbbm`a&nhdFJDoJbRchZSbux z`1D+{un4(717PivhK-G5l_!LW087Y%=CQL7*5!p;NC7qp5MKZ%Rj%isR61pes7!vx zb5Ojob?m@o-*8Mq4m|*5;N(P5`8?d`w<+Ph2RhW3HMPq0pkaIu;TJex{Ef=b1&348<8m@E7N97y&A_JC8rUr- zNS3+d6+&Gi(v`s6dSE&-U9h@LA7sGf`i6IaM~ka0$)vZ^{^b+~y#_7F2>S8@v-YSr zEAWW?=iBVxGudpU&+@RdCbAzenL$nXWUzNhlD-u?dpGVfoD+#wW8j%Eah$TG5j{#I zWL!v`1<6xgVP}l#>3Q4D>zBo6(38amEH|vfOqJJ5i*iM`{8vUu1Y^cfk-8S){7#?O zS4b`Ppm0y`$hXkf>{B&rvX0y`Eg{D}4olw#^^A%pcYQ~nM&yKH5CWL=%(&df`}0O) zJ5pi^tP3pgH6ecUXu0BD(fV3qw@?o1Ent8?lzVR&lS&$)3)ZCPraWoG9a;mieIh?n z2`|Zgi3=>>O1=CbDb60*!&5%_EgRU?Vx#KKm5w9g=Z)S7@SIIIcWpOtf#oiQ*)A@C<;O-n=d7z7TV2YaB8 zH^qdWKBzU+s7+Z)K$R73Q5UKEF#h8_Qe`1YR&|%?@3=<|<21lXaE(o6pDo7l_$Sl~k*XUqRCt%P? z@FfT-NbC5bwpj{$_w4N0uuJUA^Cu2iF&n+rkC0q5A1V1$a;rK0iSP#EUvvLo5(O!F z4Ul}InyGDzK0dKeW^zz2y+~H0khjv2R=Q|>4`A!TK3Xa!x~Gl>Gju4bE0%d5&Jm$x zdDU9!tVZNv6C#gw;uDOO5(%n*adpcfM+Wse|K&Aw60E4{?4!6J42xoT3$7`~w*_#V zI_n}sL#Y*=>lhjHf1fC6eoDao|1(4sV48dTV?L+$($L&J@jd4!cLOVPjYlLSydksF zpwKWIF)?|}ve9kOhb#({I0Q3yfb6~2KBF#uUDR?Z~E90s1q36 znf^0p6X6W-XQZxONC z^j7EhlgBgwpd9=2;nnhW%nl>w|NP1cmSdQF1D9*jFu--U=Il-^deTT71km~A+C=Cu zaXESH-4d_?8~l%c9K^5Vvcx|fbvIZie-BE-W;=$&obS-K%Ep3u_RCH2$c=LKVF+##yu(+uCI+I{m#W^!hu zhrOVHx_1@m)6Z>=Tkqe|pcwAQYn`IDkVZAQ*Cp(yHHKZfB%+fCSbH@2Y(`AF^+0bf z14{h<9{z!t-Gq^UM({T@z1v*Yy?J5Ax^U87CbD$6qgSnOSbmQ|dU+HizI?dcyVY4p zF%?x~%53A_EcLyG_p8*SCA~L&qQ7~ZW)3|ng_ITwA(U)u5U1aoo1N;3gsItJjMAKXws>1<}Pui4TY@h>gC zu51^L!rFQ_!r>31ikzNarWhM|RvX=rRYqPGj8(&CK3f>qV~CyPn~Zl5|I53n;P0!M zg@4X&<=U(#1&~&u2{fEpko$v$B_B!b0Bj&xU8CA&y0qr#JjGPKaX-TLNP#wz1zHnp zW|b(;hM+F)&tjxZOf&$ zsF`MAEf#1sxA||9+2FeSPPxnbUf_`|0*?>8-uZR;UQ}VUPpwgP>L}OjqpNo3WTVo? zToQG(clN^B{Vn#gkT{y+Z%Ms|U%yB#5YmbMi-UW??%-vkmO$TbNKD_yjg()UleRb`7yON%w=hxhUNg)Hb?)yjmCqZtz}1%_#c5lU=|AZtEA z4(>xM$#YlNxRkucYB~*So6zirJHCaRs{v-&D=kT*Z4NR{A-|pd%ev47cUEq^v3-yb z3-@;t_erh~bgOX08&kVaO+EISn>1YGj_886XVlOBaUXe9VtTkCfi#p=j>1F-ZHcUL z-rZL+Z91tKtcM#IjzuhTcOnt}{ywKw==i3yTPCok10m1;%~u|xjy!pJ+2AoR&^7)& zPT8sDv%SOiY}8*IH5xZY1^w+DQj7Q6)uSbU=Atu(g{YRdrP@JM*onk35+86nSg>|% z=9rzT=igYfm}FGN-x#f0DORMnngY!=a%jw%O9y zl4CIRehdeeM-H%9vtG>GTptlX8)d8T{amH)agdcZeA08=gOj{OWYTzghzcL#585^e zl+JdSyva2hLq%4DGQ|FwGR#|FS6|pMETI)js5z52iEYrl(;P|B{e{bs|I&J|NKcKp zPxv7@=3CbdP1y6TE&;@jkcrp2z&7>y&$AZXKnYD8K$0IsRp8u3)k>{p|0t}@?Zy5` z>9_0ZU<+x>FB3+k!_me|yZkG=vXHK&prX@Gdo{}NWtJ~4YH)FuQGnw|CO*&_* zq-NInkkL&7ik}ugpk9sm1)TT%NVR;oD&S2%(}18n_pwSi%t&&~%)%E5P&7m~=oz&xGhN0HRpaz8x z+tmYSFguu0(GC=^z1@w)gpcf%zg@=C4c`%jp=@`I^k!R1URnR%9--Z*Pz|~gv#K$a zFp%Tl&Kw>*+u2SjECQ#oXdv?uMY;z+2~e;(>00R|iaY!shB}|qp_`QkX`A7Swc>fb z--JF+GsE|ZBnr4DKexo}j`GLO9lch48_pyJ7!V6>l<}nB$0Y8fpK(S#pN2nw?^e}$ zP4D_5!N%o;3W&C<)XV@^LE*-XrI|1UWj;KjU;lV7zBn*JSR7b27v25qYhX_qTtBDu z+##SmaEj3FqS9NNFi_$((uuyDJqiP%T6z$sXae0=OLDn+&V7JzVX#L7LThJJBdQT4 zh&L|@!(KCdKT8!Bac~eM`@7 zok)*=l|B2v4jC)fXV^>e-iey!kF!y=;da0Lut`58{D2#hk1(G=D(wOMfT`XJ8Q{5=#H#PX2IgbK5e_EYSGQi zAI{hn`6HGy`z3U@vP0wNUGFBggYp&zZP%BD&tt>F52kyfc@Pc5-3Rf~=(}h~) z0k3!J5*w8O!9KEt_1nJaneMlW++Ux|Pv|hc`Z2jn0&=1NECo@%#i0C)SVmndY_P9S zjC$Re_8lfDa)n!5Ep&8VqSCjl)?GttbA&&fn<)@~roRhpvtSL1P47})wvf#``*pKf@8PRnpr*RtJ|~6gyjJ7- zyRjw)beyk`k#R?eZMe;TXW5i%NE9cUgG*o+pLD|;TK@d#hyUwucNRE0=WsJS_E$r* z24@A4LvLlF50C8?h#EhqUX)3aw3Pi7smL-{&;t#9_zvqVi)*qt|VEl zTUaSvA1v3ofCw56dBo{QWhHt(7U{uAt5K3xMNL-!HwR+0_#jAZDSb?IWNw*z=bMG^ za{-rc6BKj~be4N`$VpGX!A{`8_Tq81WW7RJIUQ|~WLm@zn*%sn$4fVd4-{rO1icRb zC2)@MwWKXU`Lc){VCn4e>cyreew_uVrW)}Z?H3I~Z`A*p5b=lDk#!UbV7czX#u`;3 z>%%=w9oCLUBaPE>Drt7(Nn|$zXtR28Jyy7_#TiIR34CBYkL64k#cx*)(bjoP9G^8G zDx+sId}=*t>Y=LzJzO3sjq^&qlv^N9!|4zx^xb1b?e+{?GrU_Dmt<|Y9 zdV1&8fJE7pP@qlU>TM)^bOB7%gc4Dm?!qY;4(4YGt>X?I?%MyB59t@!@Bh>_;f9_L zi}iCKuzsP;#nj5}5X82+ekKOiLt$~i>>S1S-5*Uo=x&3(DNhx99xx*OfM)Q(@LPoH z)q+a;)i=nt82)Oyv3fWUW>}dWt1~*~q=%EbOABvrL48yMYJQxPkLN$q@q z)7v5Y=`+)i8?oW-;}P;m``TVtlt=B5hG$+Pa)Efr*$A}Srl@8i6oqEjM`Kx-aHkwd7Cr91OV&N_Pp@(4J4 z3TyOP>#7j&_Op`;=0MybIW*=Ee2GwdDs<28DCJL--^9wcKKL2kjUv40hu>-4)c8cp zXF%g4p5;m~?b%8m<|l~Yug>1dvV*-o$C(O7Z_s$`MvjJ|%WTb2%qJb34nKh!ozR+x zhuju_|Fil6OJB?RuV2jXB!_6eaI1n0Ecfg*_&{;#7_O6mpoxdG>GU(nzHNz>O%gIe z%_)16@NBLxcZBY*#%{P1)-UVEIBAI`n?D0^Uj)FO&ve)WaHZqHa>i+-wx|YT(p^$% zBiGLJ%+j3v^Y|P(c`NwpoQsYz`@gtb?h0vn9Pc*dE?&*CVOsH^$DA8b=o+5IniTgX; z3#wDfgXMmez1YIEv$`bu&%pmgfkDn!>VNzPK(%A6ys*>i_qrC1rEl4yHZ=8T{gxC2 zg8Q;0c5nbJxmK(n9yht&vCz0Gr?pG#7^-yPr3+C`e*p^*;+JJ92g7hdi8w zTa6DuNHC)S6%H+9n_sm8TiA*e;UNb+Up&Pp{By+C+j*Sk3o`JiBL|cli!G3#r`EbC z#jlbqNP~PWX9qV+_5mW~O9wgLLoM(4?EjobXV%oE%bjtbMdfItRLZw8n|~J~&Guri znMjDy0$;1G%szKx6oOQ^_8+@O8HVkC%*qfPck4Qyy&G3msB5ewdKrZzTV|H)ga}9{miITa`kK-IW(NDP%mMp zkhlkb_N^^Q)N(eFW1wERwDs4_cV-)^!{~zg`nhn@;aVzvi`j~ICoBUEkgCa4$fW=_ zRt`lNN5+^=I7Eg?;{*Sa*c37%?+$)V|CzRMm}6c^C9K85F72W8>V@|N+q}80EhvKm zAV%Qmn;=$Y>dXP~r36n-LG3s7=}LV~DE7p2vwU+5s?VxAMFwK;s{IHTDqhhYDzzaT zm+3t5gC(}njJ?5Y6n@LWdk9BS=Wt}Af$^-u{3i)tnThS7F0CVnxM=V_q}Qg@3HYMKx`4)bjgQi`nnRP8lJ7 zz&?fejHLKl@*t^!em6$8i)^+YD1OMx$2|RDPP6*g$*{5dSH?LU_sw->bBd^lW)~gX z^Ns#Xo;6RjTjIlWnm?68=y!v4+xS3SMVV|Hq${ALj?GzJ^Gj=v6k?~*$hSUCL>-#7 zzj~vp>~1e>36dT8K&qWF&usiP$!4^xKYA$6N6O_^xG@!rfYW9R%2%MyS+opLOHenEXn zMS<6uU8m|uAdUxF+A-U13-)=Y=9qR+6L^Z`geAah_(i+`x`hWWQ1W}Hl^ug84aX@G z`9QM6ns^EyZ!rMPX6_T9Cc~VKM$5yV!TN+d`VnZLtmydlQ#^@>sUTncn7tEv`=sxl zUc(wte?Cx_x-?kk`40U*7*7L~h-Rz+cpSm%kZ<}=K`chl1i+E32+4jUQ9@%BSPVJf z5cLI;Uq&jNk;oncU|**H-8**3*cR&-{jU{SWa0HAt^|c;FZ(kg6=9Fc68rMhs9Sklh50LJGtbHE_0V^MjaF7CRQ@BT))uB}Yq^_v}vIQW& zYoKVrL98|D%-qkWXn>+*&HS$DtjlcL1B5=F;9H%Yqiio4bcigW1*QAIsU8-ZsiIef-3WUldvn1B1TKlU>GCyUIb-tuZu0~XSR&_9oBm0YVvqVO?I_%slC_UG^d zUYrvWKr%Y|03C;!E;+K~kD{FCU;73S8qH8-&h7i(3HAgKTPy}Y4ABC}pNUGkD3gLW zaiclIU@1=!T%%@Ku;Pdge+AO6E}aE?R(EPChP^_gcnQ7+SJK~^y;gS`7}Re zbSt?>>-Q9sC0zp%)g=sz?!&E_5DL{S9V~!1 zfLRxv2>KW_*xRsk{~Y-|0?!Di&*3}7t8OG;HmN#_%hgU-kcki0tVQV0*+~B(DUo&& zj4x%Uh0+GLYH_zW-@mYt;r0f#Nx zvAu{UlKQiRFBUn5oE7Fyw^EV)gCZ(Bdvzu`82(_Oac_~x z0+kJ};}+~{WIXrllPye^q5T5Vrw!)FZjkaVxyLy2zmbolL2g0#Ql$87q$W4>_s;rk zEizCJcV`?LBlp2noaM)VnjzO#Hu*r0KKbp>*REDkrb3J$S^AFIR(>f2o=~eo2$Su= zH+&=g-%jk!Xc+rJjzel&j&%2!*L@G_O!OMOAcL-LO4hq>!^ZEaRVT97MSJ-85%dqn z3a_94)13Jc2{LpG>p%kuuOSvSlFENr*gkx9Zu0c(HIyrHGHtj|jNT(bGB`<~KwN3|{35;Pen7ij zWKOsebj#FUt-eHzq~B*;UrtObi546EyJa(8-M1x_XRJkgr`v?}_GlRY+z?DiTlsvg z5zA-NXS>e~-5m{~HYIe~2}4`>PNbH2@Jai_t79Q80IN~R8Mm16EjLOgkK zsvRr8zI|KBvEgW8c1~%^byIyiWdJeY@^JjCuo3ftyYuI&p!ll3YmLL4?gx_r_ zYaB=CVV@SJZ|p*zSi<4N2}Lka4f3Z@W=UWLq+`C!>A7kVk& z_!*Nag@3$YlG1gGWd_2-{8;0awKE?y3#0x_Kf)RG_ML#w(ZH-+ zP8c-?&Iu}ouNc5fEFm#^E16d(Gp><()^HX%ZYA2`pn|*3Fw#n7zEQfKC(*g~&H-Fj zV>zhAuDX>HQ`D@>(yj>u9~Hl?wD`f(S*wH!DAwj82l^FnlHv9Bj0J^C0f~A+5S1L(8)`Vf+(|`I+IBShk<=75o zFiNFu->IGEXtVnr-q4<80kWvo15T|q=|NPGTG#8T2hyeY)dVx`cUoWMBq5c#M;He< zn;Bvh&_*2b00l}$M>m>jyXjP-z%fCG~O(-T;oV?bkTfGaHk zT$+R@1=7fOZdowruu7y&|N9#L?oToe0f%e`GL;|(3>>}@Ao3zeNaI7MbYSH6Q`7Y7l z%vPw18fMW9Wp@&b#B&H#E24Z#27q;AEJTxi3wdNXNhUF=1g9Q=ilOVRP|NHOhYeCP z2wB?ap#KF=1+e;Dpzdr3${AW;HIJOR)kjzHkX=tuI4L_+`=RU(l8Ar^G){mU27M9Aas3hzNR2>}4FHYgdw_pI)fGe<5)p_` z;Cci(2l`_Cpb8-Z@dz|K3aE2x91_Yq7l{anKs*93;Piikaz?Kz|9I?lc7p_xdIwOQ z{3H0XFI1y~s;TI+2-GIPr5k<$MIaplNp}HNtmK{n>u|eh=2%mB(MTsIkb}lCRF)%WTS5x5=f&9 zsAB$neBfTS$5syLzX*tc-3$i2CT@Xh=K_UW$A&}NP zfNBT1VB8d__7Se8qR*iacoU9t#m*l>wQ6T5x$cOcSu_AdF${VibO(Nsh(I6&u7;oI zLl*|(uiSKuKvoR^v1|`zBft?t5)ts30EcsOla{GIJ1O7XCy>@Cpju?Odl>sb`A94g z0Urr)iRMp0_kpVN_c4d%Q_}>vU|eN4F})nt3vwUI09Wk%26RBvSBD}HfdB}+3qEo) z86Pfw`4DbCa-Pe@(5;{n5fFhG1h~0{8i8;tPuCmHzo7i?7^A%FR1pw?P6Up@cXbD; z5pbz7xEp2m;7;XOUqwI!8YFNC!YzTiR0+t|@bZfz*p6thj4PN3h(H$vcExX8Izknz z7!<7xaIGHh$|Vs25lE51D8&5~v}hH8>w8eH!J^7s47w@< z?B=-w%9S}KA|L`D5!fBR@UE__3P8Vw$!8kM#h0MkcLES3BH$|l4i`NOx)`d;K5Pcu zW8!kC*60BQi3o&5U?80RFX$UkH3VTXco=zpHgphFA_5{1FoCV%JJ)8{`vJcjf!WC8 zZ$o#3N<=^eM4$tK@%Y9u-h2tDCjvhhaI3|iKo5XQL_h>Ypj!eXa0W*VErY5daF4+& z$hXU&M?hPk5)lvq5r|D-2tu3(oeot)P;3UXkVij+9tKsV4+s(w5P@U}aMaK{p?`p` zfvPdcp8*&AdkFe9sQUB)K_UWK5@4kmqHq)M)1aq7_X`m~jy}JDv~S;_f5(6J?@L5L z1acq{Y6DP>dMv)23}s_5vHAynPJ{r5=iUWnWzUNLX{ba5M4$i!)BtqM1U3f8K#ztV z4($(>#3R5veD0rHQSPk8p}7(f5P^abPy!1=55CI1X zr~zm$)3!lyzBi!m3FSzZ?V)^na8cM*GY85cvoosnS$tjym56`{ctk)AK=PSMrX!)8 zk<7+`|F?r~4dvuC>R@Qr!XcN7psdK*Phb6?pE(A9F0>UY5djehfPfl+d@{Kol4XN1 z49bPf*dXwK3 literal 0 HcmV?d00001 diff --git a/src/third_party/cppcodec/test/catch/artwork/catch2-hand-logo.png b/src/third_party/cppcodec/test/catch/artwork/catch2-hand-logo.png new file mode 100644 index 0000000000000000000000000000000000000000..5a5e142d2b8537f0cc7d8c4d66ea28c3310be37d GIT binary patch literal 57969 zcmZ5|by$?^^EWIjAzf0^9Rf;sOLs~vr2`OG{UrlBT}{gC`25)u-&qJpdz5)z6m;s=I~iuez)V8a697tl&d zRSF5IG8*&B`~eb@B$A@6l#U1TuXMC#O1blp_1GXu8p#5<45sR*fMB}!{sI04@0IZJ zD*gSM3bFunIRW7h-xIOY(G>Xm6CtC>#)EPdcNH+RnSz2Y{pJ~xR+#G2s+z2<*3Q9g z0_$sOvnjjYufP0In=JE}LIU9VBLNTSE0U!_Ag_oTe_pLm>g06&jBd*1O63ZKxwney zO3_N%j9B*%63`AMC_D~AMn;!JtlWrzU0pb%Y}&!ScxnQ~*AomYd!{zQn|hmGHfgSb zM`#OA&jJ=mcCWAYCR!{7yFIMFE?*^5|H3auoT2}T`Q1JKeGc&_8$EZlv$N&O z%T1xeA60LV%puxeTt<2-HQeZB8|>b zu7mTDDzV6Zr6zV>_S`dh?>)epAB@Ppy{-N*RowC#cpO1bc!?m?Eu|En!mrp5tl@G!_{_mx1 zfR85HLY27`-QK|BS0m=u~63dqPBe?sk z(HH@!$WQ56lc=&Yo@ymMCWaU%}D51*EcFq(aqrpIP)C3OzMs*#0EF_g{G_yoVixuX3>FJy*>4 z6=TRgU?%!6XJ0Cs1?7kv9Ei9J&%)k6x$XW|qWu4J6@rdo%axhJJPML=oJH@WOrk|F zT2>K8X#DigMw0lzM18vT{vl^MhGZx5ZL7y3_dFkG5Ny#izK0qXZh zlD>z%zSw85sR>F@H_JGvra}AXCSLCg(C#_TjfXr)e39T9%xle0%g?_*g_9fT#EXyw2=VB zgnO7$E%E%=*#kVJAg9SV$~)$AU~q@B^jR=l-`&WU;H;*#MeaaDsN@hR>W3M4XSAHC$3Z{~43%JzWJ4kWW$5X(P*m z1q6p>7Wl5e!l%V}&w>!UY0x2u{767g%Dr1On(R;g-dDNNko<}HF`c7d%gon%S#A=T zeK&4=rTp@aybJn@An;jB%_~2OJ>PDOnIR`!$9sM-0j=>~X$=KoAg*PG3Q;}Yq;*!7 z&K(DGme;xqqW#BoA>YwG-p|xA&OI4DU#&qig3s*I97vP=F&7<4gg774#67qp6^GEk z;5?Jfx1s|a<7){V7=O*h`-Ro$|7Ro$zDFq7M}fRVKVW|Q>jrkhnBo8N6g7%w4!?I7 z^?BbdnL9eCz8cv1ub{qXz#Q=frE+MANCK^NUpw@)o&f%1_ecOcJOi~$5Z5qic=Xrq zDHiv4!T<50k|)3~cn~WFa+&?7g3m6eFp=(g{*RBUkyCev96)?*-{BD!0=C z|9AcOB$z_*ja3*ZTae7Sw2I=R!!e`t|F?shncHu#Bw0%qHPl;;$^Hqi{c7fWRliq5 zL{wqi(+s}JxqrZ_@Yh;T-35Wre;+WUAA-)}e7pjv-`&x%fs(D^@jv$d4;@(;fDA6z z3|Se(8H76TM0hplY#;tdV94k{Xez42cjK+GzV(=;_1d44z3M^x?-?{hK*;Ia>2=1t zBa#c8FY|c+k4J|vVfe^QAA+;b$ffO@L7b5`Rn3!+?``T|H;RW`F8S`0Y`KOHR)$7{ zuk`O9G}BM|&bY3F-WAP6&Bu*Lu`8#kF9wy= z`-kE#e0)Nv#`5)5I%#6CkjZ6xh!`OVZe!s6G~%GeiY})?C`d!{B0CINj>%A8=XcKIfh)Hh)&e`zLlw zMgivvv&2S=)=?pYUe$X+2e@knnqdvx0MHOjETS!bCq{5BpJ&f=k0f?o_HXv^QrgVw zn~>&G2n!A>b79G&-duZv*Ofp$J!jL8H=Hd@PCsyeEI2=%Qu-@ug?N9Gs&h!Es^()X zQ6Zmc*=;)W1Q}TOSqK~-?#CE)JWl$7xapYTPojiy5kcrbiVX%5>!rd2zdm3q{zh2j z7o;shZzyUjtK;mj;;2JdTla)vOm5_ zQiCb4w&@G29eBG7e(AGx3_Igw`Adqdl9}rHbxbF=_BGi|fwQ4%JIxR^#C-#e3u!@) zUofxO(y__ITUYJx#Sl(TaT0?-K<)VTUP$jocdThpn3UN&Kr6n4WUrmgug3H`Dm}6f zDJ_m?e*zgo!;Tp%@{LnD#(w7k{JfIFlCEZ}TF1}_g=Nix4rX-^wj8w?qf))N_b@>= zM1P4X;6W~b=Jvi5Tj!e0IM4auiW3VU2As>2h)Mv(3x;g>EIduOU3<1hTSy-c`&Xjh2FOsmvN#EXH|J*Hvfe@9KC)=4?s-;{`Ri0GNI0#knuIrmjpR zsKAX^8D6@S&6{|T+IX%Osbi7n6k-mbq616C9UMy0mzaM%M{+t$=^`MBd;GR*OFCgB zr<#Q7b}-!EAxnZSGJ(8h|8>(v)kStM{(VqGEXnEs&Xrzeeyq1C;zCgmKV>t|m=9i6 zGA}|XB@=}nOg3v12l&ZclkoAeo!?lC4)B2L7G*4M^-3*2MYz7ICPRpHHb)AZE2Vz?XlTX@RQaTjwx}**XSPgTlVnZ1l?3v7sV)G zA^v|;YDoxiF1scp@uKPMz}ITB-geH&%rj00v7lfp2^z{6B|wU$hjs;`1GRGeB^e!H z#EM^T%=_~}^1MjLhG9Z~l^hYT&1kH@!yDYhj5xtAvmq5qGtC4;D!AZ-d$p*e$_Bno(2b8ZRfs||QTJ*2ELANOg44t{Q=V50FCVfX?s66g5i5sV|pY z=bba6vPyu<1RxD7bIiHZj9cPZMP(?b6PJ6iCSig-#rqsGh7dwb^lJ=GF7$v>u|&Ra z@KjM1f`JlO(4-qzW2|X&duzI+_0GVZ62>Kmwc~#8#>^xIyTsyog z%!z?l;Os$VX8n(3o&q12NcQY zpV{KDw~U?k>?8pq8xzwETS8b{T4-NLE4mKo{|Jyq8$iKk-d#%M_t( z-~;^fu}?s0^cCr7A&%&0;hv5BvjJugta~9c67G#imkaCUNAR}>?I|Z<2yim$-w?!} z?ssl|NK@bP!VxJ65>}7>M~Vd)J_>V}zWi=29_t$u#ca_gpUZSTh1sqx{CJ*5FUu1vpPa%`9FoWfm0ZFo&lWE_QhhZ}LNO>798Qf6-JH#K1@o0;o zG5be#r~vj@>1^LToYecR)Zc*e^Ucmmh#{q`{ghg7+@d@VSVksv-Tk;KU$*^S@&aRs zM<+8i+eL>P%QU6--T3lu?MfFT0X7+~l6LB#-Q){z&t*ORD`prHV$nr9(MYhkoGF(!8Hc!}(7yIDaITzVH&Ls^ zp)>wf0NW^<&;;jdh4hT>YoVtW1uslHi zCmrBbhDFkX8mA^x#nqibMUw%RmvD3+X;ulgZ;tdIqR$gY*o!_RFfE#MF@wJr@dVG& z@_X?sC+#sZREPK1*#rVS0U9VqM&k8Oz57UkjpNAWwj0nn3C4b|zvR>?E=)|dm66?tku zEsJ$7aPK5l7m_FtKDP|}h7bIg0r7GRNQ^(QwT`i<2v1e}*mU4_$uM-gO%k08$|sM} zxC>+`J*3_C6*f)&%2Toj*qV2=?T8YSit9&wDyPJ06ib~33$5wt(6T>{_Sn{6qslv{ zu;B@#vXp}T1)+OTf#8NQxyxw}wdQ6R)UV<`Mh?7Bc?rT}X z!TLAuD*?P&dARmxdQu@X2dzfU6Qxx#J#TRU9Y_6jjBVwNbr?~UA8!$|IL=;HrafsK9!%`8`(q0#MF zP^tudL0v_-S^E#-teWfQ8gi75^c%RbB-_dIe~qpH9}>BWdB{}M!0KaC(h@JkF6Xv` zWMKFrlU>(|P=(6V1*~}d%hd)g?D_v(fiQuAx|(WCy%T%pSFxpLDN1%JCUG~`0WO7% zYAN4PsTXdr$Sj^*TxH&Xzk(f2fxU4a*sWvP?(%oFsuEL6dm)(ZA|JSYF*fQJbsW0| z>r*;a*`$Xz|Bo6VFfl1QT8Y=N_toA9QtttzaWVj?@yt7ReqYukRO;j1F%n9k4iF{~Cj=f?2#z zt18nx(tyl9PzNl;O>grpoua{_pA7Rw%Z?q8{6QM?q zLIia5Mca078Op1|{)MArFd)9fR`ddxwj+Yf5+)}PUpKqw@}S|jNJmcSMs4Gj>GNHO z)Yw`Tu{R(}D>?iPHa1!~1PNG0R}q&ZCUbB_TS5u|yN_hVX7XB&5jsZC6vC6Ys+qdq zqt7s!swWM^??ileFjkF&i9YPZb-tSXoLwEf6-ok{tdJ)>uABD^?w9sQ9p>OZBLv`C zzlS}V+L8`yc!Ir1?n;kacMf&+U%@2SdxAVK>ZAV5PjA0C(U+q^j6;4F=|F~t%Q-+Q zivs}i=@5%b3^nECeDZX8#P8C?4|5=$=usqn9em`AK+CrJW+z&Gb2}K<-s%pvl?k=7bPs%-L2ooZP>Lo68q!u&yfd^6 z(aT&N!Or~IFDBngQm=J@0+)wwM51aQ$tfV=6$HVwdcUbFCY3YP)$lZ!EczNA1lg8& z0m}NA6^(Q=`Gm$}U@y;ID_uXWkmP%1JV1p!$M^xo)=wP&IG(=hVso7y;mJAs3J#4; zO7oMt*ER-un1gPcob##Bn{4YOWiDr zBx0kl=|w1)%AXM_dLaIuPiB8E3Ii9z(T7fg6gR11;6~5N}0{^NZzy zTyt|G*87>DzK%CTK zng0Qz{Y^V&vuV)~I2Po;{S6ID51nQpmrR$Cn1MR~G$QA`cT;cV%+NfSUu8F>*k*iv zv9xARVz7?>E3d>fzM##MyWZ&4Z%?Va#?)&@Zk=1tx+C9BwjRuBM^FKCpu8?W7;ihn z_pW%7?8Z1-S`^TB8Mcms=yP7mb}Mr^pgm{v!Hvt=$s2@qPY=UI5KgC>z(Do(JjXR- zWi?ZXy7SutRl?+#d&it*3Dnaa7*sNr{AB4^nEYh2Qj6Y_a4)iQK3Hm2H3_m#dB$|w z0iQuUOlTlI^+H(DnG0pzpO-YPw95DoII5!rBS}DG;AD#A*{hJo{bmOLLgV^fl=jq! zK*pTBysnaR*}cH0jrRO;u$0+*JX?lqjYdT;nebAzWe3YwC-uGKpY`qmx&%DZY~y7A zxt|z~>(VFj$t~rvaN4*V^m_d$_m_P74&GZ1vl7e&w$TZs1QVve2e-WiLL?Z|StFCS zKz{q>_0K-#9^Ay-D;`UNzqi1^M?r|dz{2x=!@N-~+WoKS9?$|ShAlf`tgGDH-Pllx zetPqBf<3oQ6F6?}Hlr5=E;L{yWYv}@Tv7OEmq^%Pf-^gFf${12XO9MX>}@RMa`JCY z!EoW%)EX&ZQ^PVI-EiZ#h+GmlrF#+BX*^yNwNJN0a+B}%wc^EHb^=+#@CfUpQ_~U3 zU1W}*XKzJUsKfy5Bv3G~YRqdz4|kZUCGjVDJpD}b@{J`?-Fm3Wll>yJ0lUETQ_g`S zL0Ve`4j>DdX8FwuH)Ey&<9?kzrs@iGi-MuW^U16%Nq`*mg}`za#{~nF%IQBQWfuA4 zXZpO8I*%Wq_K!mb3+C?g{fD#_Wm=w!Z%$<6mrn*GMqU%#gQ(DC?O-)^El~rrjUVz&m?1edkA0OM#PPXk#k3(btGx=r(#c15 z@9aZiT2tprVU6U>ffPFLGLs&~R5YV=lsTTpUdbz9BJg0Ug7*l=3JzL3b{)8qNdt<|dNkK=EfP-7%*fj+HQRjvu0K3Qi`v&m(v zak|~l@2f^g9)`!p@O*BvnpgV4v9Oaxl+1{3NercE_kvj%MNxf}?kQ@6Jgnn$g%A1% zy#mvu8^)(4d}Wqjv?nHV4#bq)aPFMS5HE73Xt*#wG;QG3(n8yCO#D(cfEimI_K-LY%p0R z2>@fzyG)~&e|8g$5=%Q$hD$$4lu#T?g>54(0&FETtG3a3a+UeO0p#(s#^(4a}rCm z3%;gwmK~s&?Ex2sNjKq(bRS{e52D=i;MVA<*BR7;>&ojP9>nfYoR5dAXxt_<}roCF| z*-uiKR(ebk5L55DGuH|i3=76z6QvTAA5HCH3Zu>pLbSwcq+l{_Wif&u5ioe2#poES z)jPXL*k$ds3&C+U2n(c>a%Jc|_$-khS^fFEjB|&3cxNSgpux6(l2`X#{(hvmAm~f6 z-BZfeW`lM7!cFNK9yz$Hqzx_VP4Pjs@~!J#j({s*C@1-cKJrz$h*-&f{+NPWAseUS z>I=@DVkO7H^pABPGB-T4bPW8Mku9{XmNL&#(Ag4hnzE`i6?y3P`N+qHJ-(4=3MFO!qlE`Sq_4#_3Mr)7ct(ywJtPuiiL5C%;+Dq@-pMfK9aYjyc99`214W9?fm*Y17TcZ7-!NRnM9Xi zr7E}AIK+wLWnXTnvVIxV7FBmcGc&+hQx?p14>7QGLDPy>%0Do-epTwN9Y@q$av9-X zKk4-0Mo3h$8PSuumA8R<$gs>Fx+HXz#fB1EtP(nMbt=NuR;}c4eDOR?=FgE~gSkeR zXX)ij%oQ2ZKTW1y7;@Y=zDEK)A@umNDrPnP5p~#B@{9{eN5626Wb}N^C1D4Y`$L>l zweZ=c_lpn*Vdp^POr(q$LB*5)1)RzkxfmI?Q^Lr&P2z?*oO<00YWp|w zoiXlG3g1PkM==>Zz89`ToK(L03v)YC?$x$(F9#WtDiH)oG6F-`lUx`iq&n9a_Oep*W)5 zwCIVP&e_J={K^|Dyr)Mgg5YZmEu@@v?XjA3X{Vr+?f5{2nk(JPDci`t7W-|Ll zrhn*3g-3guTgCU~0||>?A$W;6$eC?oqaPcjR;fhfs6umfcdMqD(nnA}B3e9=1O{pp z;`B}d8F3H?Zc%(P_9TCARxq6=8lvMAeYV5V&uG3+xaS?%$}#)IX$IymtYJ)9Pj@qd zf{$3;PmnAxGDG9^?04$doqoWp%RGz^LsWi=1%a#F9tyUzhh22?0Wtoi<)muy2r&IM z;`%IKa6Dwcv)$z^FP|?keCxxgbwCBHqv>%X4|?v2q!$E!<2lQ$-?^)~od`*pPG_6k zOFJt8C|i=AZf3jn>ck$1NrM_`GwR=+VTh$|ZyvB*^2(V}+V!vOwr-n>bgxD%UHICx z<|ze6ZY!8M39ZTzcyJl-cPol?lV0Y%pz0poXYf}?Xk`PCU*{l>QSFz@GeKqJWGhYk z>uJ57HrZ?TqqD>PtG7J@!v-_J@wiK7#W;q6VeTxPcvG~2p~@~dQv}epA`9z?_gMOQ zig7}1v79twv5N0FxS|sl;qw&hDkFsln!vyT0?4df$U}=6qOcL#TvUw0ypepkABxZ( zGWAWB<)o;mVXN{*Y@!FO!LTBwV}r1< zrEno8!8%xFitt`cRLkjI{|TXZv&1eu%pZ)u_(~a%_g0AO5FY?~H=J3ME_7a}4Mr?a zFzQ7S1}WGPp8IC3WJkRkCx(Y`xtR?JFDy=FyxrWs7oUQe-M6cvPK+u66m?lY(~#rr zqL?JT=XFY>O(&#h55CGPMkpXqa#0C$`LI{j(;_&6(XjG#;XQZCKu`q`5xk!FhE zv{z)>lzZ=!2^qYC?%@yVvk;n2SAyc+3GIT%Q2etXEpVjQ#DUW~W&_3cp@M-iP%o~j zTd`T<{kEF!#Iu8x7Zaiq-`O3&&n=?vK^K@SAftJ^0WFQ&n}?L0Nkxeyh~Nj|O$x_c zQ!Ag#)wSYPB3HJtLX|Oqg5}(WVGF$N)|RpyWVbk@jdq2!=>R9mt-F&45(EVFu~=9w zb^-D3JWA4RQP|JSLBBG}4TkG^`{X?R zosr_9()}jl7#?z;D+!o4=CCpz#St@>7y!x~sESp6-)4N3b-FB*jfT?5T9_QTh-{h? zxKSZ=%6S{sCp^HJgcEx;WG#MQqz&OgGOgLw;4NflU5B&S!Ok9QS0IK293&CfPd;7Pf4$};yYe#sG_c&?Zr^6BdZ zr)v>D)mTbYdTuQWV_MDmPnLVh$>-_329JR=-gR}ZhL%HU%iZ z$B-qGo3(}IrsSP>2f6P_(qKWB_=ae2<<25X-Y;g~2n;|y*ZMhSd;<%Q_6^&9TF}(S zqSwx0omUkp%f-a`iE#NAA4m94?3JX`ABy!n?g~bcDdgeZTSJ9$Oj0m z?`2%5oAkC2;g5s)UL2;w&r(eH^;3aA4jtg_c6o7qJC?*7R*ZvUU$>ND*x9~N2L-B! z;Ru&;P3WN|G0QN^;`y^iVwR>Il~yv)8c*^H3&M|4l6CFtY*^6msx{>s5a5}#Vs2va z6ezm#RUOIq@IAH)?08V7OfCMZ=5aAIGP(3I2T5}gE^;*L-nE=M%J)cWf%g@U(79Ez z9$5bZKoDKRxgl!A>n%d~*<1!rK=GnnCgss;2-ydc&n6KaYD$cF zjxyE~n`B`ZSb@gdFrBg6rd$aHDyFTuTh04=mPQGXArQZf(b85Q9bUz-y$lK2x+%6Tt27+5%Hf#c3|`0+$|9 z^l%ZJc!NbtsP4*)7zSi6df#-S>7GUvzuD_S(W0fIOZ@`VKq}J=cEpU3lUv#M_~zsh z=3MXGXM-ZS*z;;*5E7lb@_13(8*R7|l=cr*6o626xLSJ9cJi*vQl&FL)D)a`sojPu z+6p4d6zk(cb+-Np`!cors4!}s%_qm$un=V@tX1Wra3$o1EtcZ?-q39^noU2p(bhU^ zsXAp&d|PUn91mGSk%({PTc~tPIQzg!CBphh(u@b{6dAwd8I^p%s$ahKuJVZ9M&9PZ zy-6TJUZ8Vix1|uxT(;K_a`>E8ivg&-zDDZLV}S@$9TZ(^Lz7#SX(}M_t0vjmU@2P! zq?;L$E0ar^`|6(o9#ooz9VaewylIR!6+b^7BrfoqD1ZHR_UaM~waa&vFY1KSY)z0M zPkTFdyTTjn7rn(-*P(N>hsz+3a=fOr`?}m;G7fmPgT}Z4`3sk%H;Z0Ob~zYs0Uz)N~kz)(xaEj{O>evtDhU2r#sdFHYRrMy5qDh^Eh zo1=08@~1Zz&Q#$~&}_Q3Et|IN&K2>^P)=rmTkI6e^SgPJn{`Dp7hcl0XC;Jg*ptc_ zyH6TE3L8xBi+t!UK>>4nes(RXNviqMsWlOBKVi+13M1>y`a$TUV&jcIBHxReA$7qU zav`3_RQRhcP3pXxXz88v2@Y%CAyI3dHi#;6;q9J26dUUK54Oz4v}d#0{mqRjFpzyM z)8d^y*7+vWF=9xjsWT{;a7%kxOyx{zi?!P(*v%~9pi$=_+yR`FuwL{BJs&a$fTVgl zI_jO$2NoVz?)8g~3nL$1mdd7Y^)CRQ?q3lhW;pd?F#X~SK6A5Fvp;V$gs6`6=)E{z`ra z2>anS2XfoSxJ+PXyx{uRtoOp)x^A2NJuQpg3dKrCH-EZzG)#ch-WQoe5%t`i86iT= z5_#>#h2`>^nO>CY-4SSUpG8bx_?9(=HBJ`WcYz0Xf^Mk{!6~j4HPDrW7k}D4?~@Vz z=xh8!LXrgGwe$Y>eN~)g)Kb1)haLx!BV}%^$seu_q$+O}iV`V=2!-QU-ICO!$MIpB}eciocOW(WpT4Xd|AUa>WK>fFF9{=fyXm$%? z^1d*$>3w<2vlH%33TUP>b?l>$_b3D2_aIn!_y{}5=_&TtVq{MRY=l5@8M8Tq_dW^! z8WDbe!r>2VN(gaqER5#fD8^|nYutC(WQOw-9Qyrf_QcRbXdhmX7nVoJ+0UQP;$;v; z)T%AGO!3uujp#Q=M+7=_RU*(~Qy1Rh%4@{Y&J*RsuHHJs0H$Cz5^}!{(e){=n%Lvorco1bHB zc?RRZ8kIm+7e9GcBXrtznfKOV(-i{&+r;+nINBuLpNh9PB%j&lO)jawwM+75frL|X zK@~7N9s1ELyGMSES3*NIdD!7*XotGvc&GSPhq(!fYHInE#+xHNzM!zkXY`IWORw79 z(Fr@vQ8rtD^tKf^&KC!9#)gn2m<4T$vShl)T)p!u5e9hGleaQZvUn=mAuy&>wjX`a z40A*!g3qtnC2MA=J|whAZ=Un$7fTiXC`r)bqLq1fg{eMD$EG#j@q?IMXQn;y13#w$ zq}QE0`4Q8KB<(qj05EH|gOYPAS&P>GE{hnu`569B;}_S4hMyZbdJ1KLUF@a;{+tOn zoMIg2cm<4*o&FB^Vwhve8nT^HLm+*}iHSh)AzE(|>ae8i*%JZ4XQGNwQkBe_B%`C2 zWif?YvHDZ}t8ytov5g29RfTonbbkG0<-=YvqVjxFV^zz8EhmY%ccq1X^<(15TtRzW zh55*?pKrjQuU{%616J`jz}`R4#z;EOKSd19q-Eupd}5y=-@(~F7HE5qsyPf(h*ktn>@$9GDmw#VBU{!pqF~9eP9)}_JFXJgEG!?k1~96Vt-HpZ2EzE%ghG9UU~6| z*S~AaVa+8^x3%Z_NQ=}@3wY4pspr+>K#9-%a%VEjy!a~Il~w#nf|%@b zzqrdR{8rsb>RqFHvqgMNrNEf=se3VjyN%0N^#Je?QK#<2T#^jLn4WTXk8Ia>bX<;N zxVpa`+fr?3;}Rz>Gszl}Stbt@%if-wJN4mxPma>9w@I+~)G@5)RU<9`L5?PhJLTs@4pTK-fhQ&FuWJ5v9^TOH@66d`oif<)k2lxpwmfoD5zYx!aY9S0DiCc^fp3<1Oa%We)Uc zJ6$hr#_!zoj1 zEXcYx?7Q0*S}aN7p6A12YRLL(EOkgdKChm|Q+z2H9Ff0EbIlTVMXS)Kt>x@_hkcq3 zETzR0Lp}|E{K%K+_XEewcc!LZ*)1=troDCLd?ITcUw@=7_Glsh9BN>(isw-tD+V$w zOj}W`#RkOHld|W9jx9L3zSDT-vH^1+N2M2$x6(7Lb|QQiwqKh+&cN zy`LyH9k*dq6NEJ_ja1`;kUHxTKgG`!^Ne9nPW6czBqUj?X-IUILX{Ci!c<9$jpsGp zHc8ryxDm^Xnuk|E=?MVKUvTLK8rhpk!8*B|i(4}uk z)>tXB%WL>Ru;2HMF845SA8R;FU{m~cg)_Qs`Aa|gC%S3}xl;hhW$oau)du9zi4_UD zth`xDXuJKekV#DkVf(amDv>d-G&~{{=DxBuz3fy+q%Nj;xuT_|CZJhKP2tdzH@bQq&){@eALH>)$GUQ&p_ zgt%)E(+~A<7aOdWGJ`fI$}u1{zg-#(Fm<#J2Sx6-CoXO@Y zSML3w84`1^XHiKziE1cHQ9-9a9&);LG@p<%Y`;1ATAg{7=-3~RK}$5}k;2tH#OHBh ziwv>GDB&D*NOT4%d{u|GQQ2X<>)MY@_`M3BN$+We8)xd+8!2KNhqE2C2me^p$CF49 z=W;47ZIyMK=Cz|rqmXvj&lD4qrojOW+T(pO$o&9Hx@kYHsF!O$F}ZzsyXg=IZrjB% zS?&%Jcz)a@6(RA9AjC1&{v&16ScX3d)_ML>*_5|oM&PX$JXMJbCz$WK8Kd1=!-ELk zFP@`D4HJ&an_mk)7vvv`?}+NS2YWRp)#y*K3JU~?3VbgoyX%ue&}}J0)SJ0fK3Qei zgNjyx}t z-;!P|*HL$$h7W0q7R0oETD6?h zkDm$~PHE>nWkAgB_0m-Q;xw;Jno{+spJUdMw%kaG>_~2>kdbNEwZ{@#DSNm4+7BIZ z3gf}6V)AosD7!j4k2({$pjU-{u+K%jELMvew3&L+j{vCxH2gh>v2iP}tdVU#%H9HZ zCe%S$OAMO{Hv-Ef2-*|?v(#9h^JWOUaP6LIa%BuHm7(mMEWBCl9oFvfMx7~`q_*1Z z$q6lZ;bCj44`}MCG^UUNH!hx0$5wP9hSpNk*`af!7tt2ERt1&9!{7D9yJwh&N#6wN zy`47Z3EU<1rD8;UjHLIL%3=hVkc6y;PffwB9HM#C zSTmU&0(=yw-d2!ps@t%V8lqg>%K`BTVGn6jP-e#Klcb#~rJg0VXg`;XC%^13-#CN1 zR_dG;M0Ob~c(F^2Hb_ochxqtB;>S0#x$6`X0%ur0xvz3ZcP*-0d(`1CE}K~Pd2%<6 zUoVb^TwA-!l==&72jD_o-|}r?PD^Fc0Q@wBMM&cHY>ZARhg%hv9~Xag~4gIXun#O0L5v#T|gFI?B8xr4KT}5z0a8V}#Jbk6gbE{&E)6TdY<97C$KLp!^jS`# z-GR?4UPy3XyCb&PJf|_wTXp4ObD}Q?vn5e(!J&;in_|t;sKX`xXCnN7!=6Qv+*M1L zW*Wa)o-c2uY*u4FghqRQkDI56D-tV&@qZMhrF@$XWBI+6(Mf5j9w2r}vzOB<@?2O8 zZvFTkwYUXRf!_*RH%zoct{sM#xG;lM8||@{U(co@4&l8!1PtG0z7d)NK4>Y@@ey$T z#H+7oFrnBwtU4yDZ>_yKpo3DvQWlvI9s2!=ktSH^;|y4j1tbv*8;h>5%3_#Tec z++Ih^t4B1awFFcVY&H6w@pZ)ieis1f*Q^ktaj?zh#(5dF?&B|-^>ozW>4(wR>x!%b zAs`K(-6U%)4C#oq?ZwmFN`gpQDHhnw*?B9kp|HXqGo#@~hXl48V5HGjeZX!u+ zpX2aAs(>vj{t{onAZu8rG6;F3W91%{z$WyN-hFIXwc(DVI_MkV6?)+#C|qN{`x6gv zOuMJr5c}4$z^KwsGY4^VUs2gq=nUznk~49Hdw)|RepH*V-K`jFS|5%;{W|!gW1WTsB-2+&rGi|O6W+gEjo?$eTC&J zcWKQ73C}9{&-)fq<(j_fc-}Z|4h}ybdeI%qewnFcx>Z7oT}}09zz10&Cd6!A?66YKa1joS>1joOe&#GsytC!^j^{R5 z*v7aQmu_g+3$)Id$92f_xJs~Hd|^Fd6$_^%DW^(gAPqMSq_kr%X_S;)XyLitm7wTj zQ4P!QtRpg`sHX2q<6-T+zwK=*m0U{IU!V3Q@G%aOeMMz*%mbfjRO$2!WMAf!8;3ca zBQHcl%afAjw-npTkY@2tJ5su}aTCuFA^ah_wOm8~4PG86$U@KeNwt{wyCb}QwV>OH z1ep4YL0KeiQkXXok+^okPIRx+oGmvzzR6o!F9;7!l=p4)NhndA9MjKZE5RZfJl-!N z$5Id6qw!PBSzSZRi~=F;1YTB_5}2$%$PsVeSHl-}8xik9MVTAm z)wXJrJ&M|Hl`OIYKgY^AMo4SgoBzm3skX2#wY8!=mAh6i|qb?u-+T8{ay z&_#%XjBR4srbu1Oduf>m44BtIZ{QCx_R6?YwfxR-At3NcERA`rD~7@ggzk^{HUVC1 zswi-y?BJU~*z3t(=GWI^JuPp*G=YdnkH->)cv&_QLtDAc3{eRRJku#-M%b#C!rlvc z0Eqnboz0xEus%c`T)D_bz}|C17j4MQYt z+{XO7arHt35hr)P<=FJ5`u2d)cX2V8H{><*$nC8d^KSuoFC72Q+1%xN0T_>oLcI7I z;CGSxK|g=UV^%TQ2T1}w#LpL&l{SC0YejHnGp|&6hk_ypk9$Q=`t%***UCA%x1M=v zzOZAP)iO!cTwg(B205NYL{=OFIEvlVx}`*BzQU5uu;8zh`^YFS3RWL`I|+%`H7 zoOpR0to7WJWq8@KZ^|%{+fujJ-JJ4dz#ephk=ZwkgP$`8Vzq3sRP~Ih6Yu;Z%9nsI zLh^?B5WC5j!pH*tGk6wXgKFM(;svi~uZur_J~&i$aTFdgP6rQwJKEUy96p_;`NS(j z_2oME2oZ-|-IZ@sviC1KX}DP+JHI==E4l}h6kB5jj~z>&peFv@>9Zl1_0?Q#QX@Qr zJZ5RpuN{%XiD}b!7k=eGf6f|Y`cOJt0M<%&9=~F4`f~v&n!D#}v-nlu6(+ui9zxGb zSF)WAgn=^!o=r!bHg+~oY_NN9qd!%0+Wn%^?>nuqmpp!jyVd8XUri%d73@7+yK{+uMVP0EIgTC!@hKzeT3t{OiwQRd&qJ=2cupb^yGXc zqu3-5=KKG+`pT#{nrPcVAinbF9nc&lkUTh9J+9zx@<9DneuzIe35oa;<2|5YFdRJw@u>frZlj zSos29nx8Qi{S*omLa+E&I^9;gHp$nU+hezbCYqxIFDjoPRz;N36=J(Qr}dJV-Y1m` zNw|@Aj<@;l)~@J*i!9kftUTy1U~1@`xC_6$UhW-16Bx?`gvqIH;8%W@k^M5a zbuK{S$qZZS2b?1;P|3sc{`eTxd~cu|)k-y*6+_u;a)EyS^JB&zesWv1j7MjW4khDRjs1vNfMZqwwHUMdZ~MJaL=98 z`Y-B_i{duzT#^@34H`C=6NxxWhOyn{>5op8J#5zNQ#UK!j8eBKt)DyQ;yNF<=W&3; zC`N3MD#C`-$uWcYmpS<_$2uZ_Z)N>twE@IGs+>PfWHlR)y3T!+SQ{I$#9~~QNY^P1 zUlW|t37%zoU*p|KC|b{G!cN4g>(ZeF*g%QbNdXW!!+>^vsmnj4fW+l8{C*z7JfCp< zVRuf6V(^7aq`8vtMI&#c34Y4)^-f>G0FB);_a->N=P0m%O{G`%#;$xadR#{xErG>BwhO4E|bO%e!jX;=5 z#T8L8E5CNR1A9dbEt?L-kInO7HyvA;6!Z)_DAE))!@jC=`AciW9EFYzTZ3`?AWsd2 zG`wS0A>#fY1{) znoD4`zwM~KD4&^?GNajdD{Jx;a(%vUFUiFogmqI(^tuJ{jIM3$=-dPnq2*reCEDsO zA4fyZFTUZ4$fpx!1JSPA&(1GHGkWQW?q9Bwx9{VgG^M=qC|+g;k)sM;TjG{Ht?YYy zR3=}nmxvw?G%Y<|Q@%eBBZm3<4gS`g;!H2D4AbRPybN$A62E0=pu9Ff4SzO2tGGAN zgSTj(xX;NCvZaOCw^y3a({F57Uv6j8h0`6d3$IHo0TK3}&xC-#^(}O5x9_q@*(xGS z1RFCVYt3}^s)O`l%RD9{eH!;LYwGa|>3N%7hGRQ0853tmNb#f`V|z*HDW~xGvPk zcG?r#(KLyHKvB;XBr_ERsR&U7vWe%LN=FZ7T|Ld85frLUOEE}1 zja}IiGLb|}t{k^ozRH_X$F_wQdS*|%o^uc#iXg=-2rl%6Fno-1)A&QVhqnKY`9-3m zjF$O0k0W;$0>;nt^!6i!yq+f9;!BT95Q=e)bw~`RlkM=k)H60W91OSR;y*k@pIJ#6 z;(J15EO)fMa1vEG23N~+_con)nC(#!L^AmKR$4UOarHdEV?&T2Jz~EKgJCk%(9grT zZzW|^cJI!k=IY}fgzhKBR(pL!xO2XPA3HTWSkQq{~iuiL;EIV z*>8`=3G;SxiKSVCV6t}EWnVngC(?i{&L-lph*-b0z6(^zAHiF|gP$nsn-De{F2)xT zmqAqu#Qt5{g=g$g!piFWDTVgM@B5hH&3VHV4vq|UTI|Yur=??mvlqYdio3L0=UoCb zWH2)E?FT{{xn#)4mvT0!+o$H>X^s=kCYV#@%M?kZ4BEsR^Cq{pMlW0*Co2zyMJ>qR zm%>V+dDpbh6sc3A5*ar4)#@+|u^eY5@e;ET|i; z6D6cyTX>X`iERJ&3azx7Z?sgQ;f7BC)kL;XGcqG08pO=NSvs7}=QU-#6hx!TfZjkB~T@NPe18Okaf@x9S<={kQ5T zye$5g`N6)4A)^a<_MqQD0Q8dMfkoowN{k5N7 z2^@PY?gMKL)#w&uj5l-@+6ygQi*zXwj)LvET%$LrgJBZw(5C5Gf6=eFhT&^mi+VJ^ zpLnCu48BoXq*$GHQpM5JxmEvVMl>^WwtS)>(Y>F7(F;kG;$uX$PRCt9_w@STkk-b& zlc{W$j1NMi-OXg}i%mUuTz>qNMH*I(Khrs^pU zUO}#>!fRcO@yy3nqcZC8pk;3Mq83`-+9KJ2a< zu7EaU;^t-kGNbm%cM}WA#>}JiN?|=b5e7c5kj>(5X0Ic)dbiNY3usV!acyf?I=CZ1 zj_>-hs znS<`bQhkG6%zux$5AB_z1}Tk$G5g$Io-SLBI?9*3HqwkI4B7$qFo~eEaFTNd@~+F~ zX>fzEiG^9jrEWEu`3uKGN2}t8h^&KNPGRCbzyu4Q|3a%^z2kplArmz|i_d5PWIoh0 zyc%p1kb3FCBVn@L2$1IpYAtm`#uw?6KvjAlA0nsyWxaVvE$<12(%f6`UsN>F(C03? zsuq1+hWmUnSd*V;Bg)q*t{h0uBwyXVW#2t9?H{fPiDGq(%Yma&qCGST6#k`=YIvS= z15jIg9P!q3utWdPRio>7DeBFF+&Div-euK_>9 zX*eIL*Ze8m%axyP)bo}w>JuHWKw>b^A&aw=_AQ|+X+wH{uW_Il`j{<=U>lT@F|!9) z!X|F}79gKw83ESdUc$x0D4z=OZ#rDTbqc);h5O*24L?!=!zXGpn2i}p*EYX>HWZWb z$z2>=U4dju`|wghY6w{E-d z7+qkTuk=pmMtl`W8dx&BMtH8;LQ9yVaWd%^A-v5I`nZp0hlZ8HCfg}u{*)fEVw?Sr zAb}@9YZI*DXU{wQYVvaB?6lUs*KS7n5kF>m|(=$uney!AMdzf>Z-3XoMW(;qsMJfPVM+9qE%U zLHk-XMxjBzzS^l9bs+wp0d*wfJgVak(MbUTNaSygXA|T-`8bbJh%PUikx-LYbFCaN z!YnhIhDrA8fcv`e+H4NweYGgk_}upQct4S&4=wO%w!0Gx?|6n~3`a~&M0 zf2R+wk$GEO>C@i98=_!b0FUTs-#bv3K@ShF!Ai5{=*h!?ck~Yz&R2C9D30<~+Mj_A zaU>JC$@-W#GZF|9q~qxKNpZbmZeEk47iVZ7=bv%jCKjo<9$)x@cr|2zx1*=xXC^b2 zQdZr1an$IwggKBl7__!XcOt|SxeDZKIi2*$3c(jCH@`-!bEvJ7$$)X2Y)GF;YH6c; zM=LqLiz0l%NWDt!DYcw58ct>NMUU7S&Gv!6;pUbpXC=7%MHp#?WTeTc^gO3VVPGpZ zZ)4Ikvbzi|DK~8{Ax77={PDzSi<&X0B)DEUe*m;Qh4{Na0NKPI4nmR@{I>C*pe1SW z5YNd&!=F4__X768%bzGGY5`v)a{Dzm6<;L%5yC+Y)J$Z;{3r(z`zC-j6>|LU{;-cX zA}a);OirUsF-XGdtEoLhvSM)G1hi3X`D>7?iX~E0_5_Lap~HbDQ@fOAy-CwNr3skz zp786!HF=1;?=2lCsDOker0ZH^>H_P8@-Y3hO?qU!M_UHzC-%fv$~}|Q-DnN;SR*^ zS%SSIBVR9wZd%TUb||RT+$Q1Wau*rwW^}5}!@kY~XkR`EknIW_I4cZ_7*%<|dCYWu zo(kS{{H!2Davn0JtLIf0P%9%>t>YZf<=uUWXMfpyu8q7a>PdaVY_we7@j>8DZps3U zT&pzx!%o3oMiFbjm)UM?kAhw~+zg&t(b3`zQvE zh7T&YhmOMm5iR9#Q5=mDwJDP%VfFh~8;z9o57gWuj0GLxU&CVU2HE;WN*HLlqG)1n z6~mp22MU8c@5poXX+Rfv59)z3<5aOxGOvYSST3pJI=@Mex^nF4j|%%!{7Le@>z9n0 z<4S4m9%F2?pkWN zgSx0(?eB5)5Z!#=pS>Xut^=Tyq0hT@@|Ld&8BtH@NS_xpp{o8#yQs%lxvrnRv=r-V zjnt$e8Ii^GjdvBKh^wvR0Lvqes`O8gMcNL(*UL!!0tJi4IXHisOOqH(45tdyp+`&H z)^l@&ey3d<9=Y6qJpfqduWjJLanM)Bn#f+U^)jb<5njFm>|dS7FwKxaViyllnX+Se zx65?nsfMexZ>$1di_#Z-Fpal?FSek-b|ag+O8nP6OVM(>{*yEYvU1M zMyY;r0+F%u7LBVfmK&+0XpfmNym8*cLJh?pzce^dWyVVqOVm?sJr_L-^%8?9QII*L zQRS>TM@w*KqmagrUMmWRY1o1T8*xpEs!~iKdIKL@`ze9%WUX6x0#4Pg4~#sW10`}>W)+(i_~iBi zVY^xMaEdo(NOOVBBcg#Q~<9&!7b3g+2;r+xiQ zwsa)0|;L^d7*Ftkc*Yi7VM2FCuq+3YSe{ zU#Vf|cb!3JJZlqPC_c*ONKuJz>JGRYQlyNXoX3KH^G`f~^8=nO{g)3Cvi;~M9d_$} z7vv@^olUIFRk>Sd}F!_hA zJ_boMZ5OriQ0Be{{|v6t)ZTGr(Y0RAfH1l-^E>u!Yc)MW*HTYJVP6kIpk$-Z@TKO( z2t;Vh&+^hDW1YOIb}wIou4UlEV>{=ZmP-UtqNYKur%e8iLtw;#nLZ*-a^8-giOqdp zn7G*N`^^k16OY4}FNw>&mAo;Yxjva)xy-C>rERS)fcs*gdXpMSw&dqWHSTPU1X5xq zX54Xm@l$7RG53FSzpR#r&YS^BqCXiTudHeE+i1QQSaUJj#@I-+e+d>a!|>qO1-H3s z+U(-&yojMHHTkGWgMR;P62VJWR;2Iyru2B=KbA5Lqa#akxT=e47e5!m8J4o$!YF#m zHqhH%Ea>cGo^W)CG9`lXiPGP8yWTr!Hxdx1935($?@=-030|R$u)XQ7=X{#`UKP`T z!etd-Tx~a8EH$Q z#Y<@;AKfMC+lVDNJu(8p8s~6@oxVL~uzE$Tip9IPIHYOkSb98EwJtM9qzo zs^}q-?R&A$Ul@~88QS)pRmEk@m->KADkUllB_{dlE-!vhn1Pb1^bZgfrB2P!r-+ai$WFn-18MeIJBb0M#I`+8xvv(_-W6rC%IzVKgD?0Fnxev@-+%S$zsTH2V zV(<0^zf*m}?LR$@fPS1tjrpaGjrF7-3A;x?Tz2|vh#tr+1x)>jaj1b=!9=_2xi{M) zw0JCfxTy4JA6Rc_!`@o{66qY{^D5s1)V{qUBeG&)Eu0UE%mk}!PvAa}E?6Gy{Pc||ulf9&ZgEQ)q#lJm9AP>iXmKjm-8r~LOA{`-vyOkV-$4|SfX_FXlWckK@`I3}_%RG@K^8=&w! z;h&k&f(ml`)Vtn^6m-rM?ZP`6oj@->!Xd~(&#K@9{`w3O0 zd&sM*#{v{NIrUAZX9r1tB;Ry)yEjw33tD&R1N|bB>``2w9X7$?dAQXAqV% z>YCui=*w~jBoO}x(TC7ph4t@&mEKQAXhJ^zn)PfM_rxv;CO<;gWBPVd`U^u2(F!Rrig(?ZL-P&2S*+hGL=*;@16^ z{W}o9FCegm0cpHpUt6SQlEey5g&p5>VU)5u)a_hw6}Q>=d^BdIO92bypT>B(&rkO{ z9>E*bz5*6C(5KsBs-49VO5BRaNci9%MfJOed@XRn!}B4lQ*4TB>VC?j2-`X8H7f>R zVnG)A)b+-7oX4JG_P6A}{@v-Iq&-|Ei+X~(Khswbkdqr+%Q9q$70<^~6{u=N;#+*_czzn22MQUU zv#80tKv6H!!zb8@PyXT8wXQ#r$K9mm)Hm4t&)&)zO7AH9h(z_C&h&L?TjY@>8g|D2 zOU+3!hRl2-a$^Yok->Qn51%|{*y6+_5q-#g>0|}%x>2GuVK*j~7?FXr=aBj$S;SauX=OqBU>s7?fdtb+o&KEfGeGv)wbY?8WQW348FhOWFRem*d6xYp}FhBN7-I`n@)_d~V^vs`eH$!nz)CHeWPS*6ld8yqI%5Wz2aPbKb?s2HjMIH zk!2{|&i3?JkKh?Af}&%0MJPHcXlS&MKb;*r&NP(OUp5zby1vm3ncn`!{#Q9|>G8#v zMuZ3y>je6;^G&fWDHqp0uJRhrM}ZVs^@i(p*Yql}L@Bz0&LDlfwY9ud$#We60O_Fn zqf%$2GK$yqzchMmbNeo|8S4*PyHPN|ygr7J!Co;X4CmnvXMWBAy}wDvLimllOLEQ( zx(b?+1q~Q2`F`Y2@T|w=uE?6p|*MkVBD%@#u{rs)rMIM36_q9%X zV4fwm4WkIL{a(90JtXCF2zf?8rieH=il&b({~d|o+v zIlo*wbv?hprkfzNZ8|wASP_bX7N%A(7#Pme{5-qei zFw|+z2%YrKvvJG8%u8NQON{1p#q#saX(A?cxIT7ComNXzGE(zZr)nqDSdQndBdRv| zu*z)R+}pRkstA8L0Tcok{BcRep+k02II2FRALmk+J}-21Gw){OpE_tjU4U@gT$=`7jk zv%y~rEsRev)s*Mh=mQYpS%a0ckw*2@SVhn|Z{b4U;UiRUW5AH%jme0!6hE1fCFWgu zS4!Kl^HWFgaXa5e_Km}K!8cm#4puzi+$jdxI=S5|<&H(dUXuKoK23fgIBl1DfZuNV|!4x z<$K3i_pB)lA+2{@qwesS<&bHq(`Q>`!GI=mTzB3V+*=^<_0~q33&|Y`bGn)u8CtCn zdBc;4!uiNJZaX+yQS|9yP%o=@EzndwRGQPGao0vAa=AyTv$(P)*b>eYVI=VT$6_1P zL8|El_{^z-jht%cchgvCANkBacD|Cn^XG&gp=>xHJOo|%D#`}+X{82wfMS%Xk0`PZ zU7pu4=Pz(=Fu4xMJxk0~)qEfO6yfd`*!|lu%ey0pX!*}d!R&*am`NITJTKx}z3rGd^*P+9!-)`3f4kuKS?VCqrst0@Ns^Jz^Y2M2PrY7hIW zuEL{2oEhV5>dV<3hi$CMaZ5&w5+Uceo31WD088``>m21cc3{k=SvnpT+~2WhrT@u| zNu2q)-3|t}Da5Ch188h6+CWtCL*oKJK*-YbJXLC%u?()DeK}c{_zXf=HdRHHk7}=l z0{}#D)Cy~M5MdvOU5GJpFPNsK`NUlh#`J((r$RpD{@8V0ws#I&h-=;08%DQpPpT%- z&+Zl6#`k;h_~c5Pp?miwLAD4T?v0T_|IdnkHv2;Fy&AI?-Soo*=8e>Y36p%))5}46 zrq$D5Aj@IhljiO+(|C!!k5^#}XY>l~ng3^o7)z9HKFsZjAW_%|{XGnDuFMq{JSIib z3yKKbL#GiEpR<~sS&0EFdPwJ)koId?~LjR}d<*t~>B zr^{B{LeR{#Hc-+|<7_{Q*^3SHTLeZfDULXDCa-nqvir=j2Ur7e@Y}xVM@PAw>|IWD z!#ntK4hFxC@5e-lHRuuLQx3c|N6D4x=u#llSCYn>yRD#IA@qr~;N4AcgK@_XZg^rEg|Iu1QIn8-s_$y9t9p*vm5|_)b z-KVXAMHKaP--Vxf3Z2d(M1MY%pi;lKJ3sX5Y6cJ~CphVOG%+cEg@J-o6<@y^qTaz& zp{-gar9is)s|Abt8z^H28}IzhnmMe95*?|F-a1Uxp6vVk4gO9nE@CEBwc+0KuLGtm z4`ip|fKW1cFba#E9G_T?t3YI7r42CzJ@KN;h@2B3m#S8>h+gEA3OlCEZ3-q~o;+a~P$nZa=Ed6KHY&(%U zy%^`ea`5xa4#lOHz0d<)!^D!+tWc?!;tsn@t5#Cfq%i1UzEG~iXVwsPKJh(E?G+9T z*U{aAHlm6md8z!`QhipBW1XldB1az{YBx;^byuzQxLydNJ@kl5PtVj*=4_Pt=r+m#ICB5%8WE;J^z7Ic2%}uU#99JB7*I2Q_}unpHCi0~juNv#e#;9}RDZVXV6M8Z zh9S_{nPa1P22r+`9L(_&bwLSs264TiC8h)FI;Jv@EBP+yS)Uyhr)P<*vfM4Ii3n-? zaq%R}$Q}UO(?D}j=lG-S68Q0y(A-7usoWZU8xK8;Vf+3Bx{teb+zGl|V%v_C>BYPY zkCAO+K*dT)RJr;2PV*7w>Ce8HCCOUVi<`@%ha?o>U#0xe@C$={RmlgR(c$}iId~Ln zZ)(b^(f^AOkx0)U06lyoXT!b1^%JP%6wL)R zHcrei6(jNjMkRlo=j=G8fy^cCtKJ@LaLAYXzJ~ zGe;Mw_glB*v!f_~L{8?$o6lbVHVgG{kt%A5pJ$QpF}wbRIe-fm37M;v=DHi(Fz&;A=}zEIN3B$s}1d9 zp90N^6A~+2EA3VbS`&+?ix9a7^1@8|J#BPVZW`4H{2}o(N6Koh#dh~T&75($Gavn1 zFiUiNjTlR8Z#tS}v^|ER2$p;11=_7a<^FfFBn26D|1%iCi+P zrE>h5GMxX!`>%ptZm;0r$}F9#+@=A>gLWaVaHNTQ~eU^XUiX1 zcO>C;4Ds`DHX($w$6E=vZblpxEQ@8i$*R*7?ITz8=HH9ppy6CFDvxM&@sLO2aq6nl z;_k@hpm>}dqK(tPjNbT)9WBdkcr^)Q%d*(d&q0bW@z=e`6gz@of-Ec_y`62r!zKKC zthxPNbqKOZ76x1CL3Q=~S7d);f2=YwS8$+b)YtgRzcAbPiJLvtbTNFh{SHnl-to&l z-w0fSBuk4Yr6Tpb+z-wZhAq(M>kmS{S?RXt}8=};+Sz2RM3KZ>T+8l8nje( zBiga9A2B$ty7Wr#n4k$^!SfER#9LapgO%FP`g#%e55ZuFsMsRm(QfjneK|2GGu;*O z7~_tAWflAfl&M!?$MvaHqtk9t z6YP1aH6_iKapl%L4@Jl5uAnBuqVuZM66w7r#=Rzbd@oOWV*EgE4SFV3=OsgE&r=Ns z+oQPRyd-8hsK+U~6P42Ng$j8Y%s^MtAA;P_ziRP#W(z}bU=theV`P)3NX_Vx5j1%g z1d&MN{b)WX-oA<-nvq2+b$trCSLNdQxk})6#htbaD%K;bP+*{I37zgzMe&z}wW(#q z(I?R@`9+wPN%AMY6RT{Y4#Xev&|1`bybndL>z@{0p?o2c42*Pg&H>qLT z>R?#*O+|LYqaLL;>8W(-#{CNi`{^#3H_QswU3IbAHU97LFB6m#9W6TV zEs3WJ=^Ow~1v|Dg5jRp^@Ug}k$EDBi=cwE6)yn{59XJxjw9e_|vSf~*NxM~uU5O=; zQB7!tGM)UYqZ$F%?xs1a58Rz%dJ(uA!WpPG8D%?XeH@q4l9n9cRfiZH0+?#02{2;UM-Hw0Hhcf{NV-5w{^Q|saR2TPhL7i08 zwd3#=uY6WxDB&x4foQkPEG3AIk4LN>+1n?Gl3@DF)y-ua;Oeflr;*7Ek)Zky*P-LQ zey}QwUBwUcM%k(A$7+Z`t~>Ay)4q*B+s(*nou`jXr*|iFh)ch+B(8bfQv!rw_CHc3 z&d`^)uBU9f;~nR6Zd-M7PyVd?Psp{1pSCiDT_b<`zcNqcR}oi4GBzh_=HhNS+9 zye~Sb<;_vrRK&i>0Ga0$Jj7Rvug$)e>b9)QYK){tOF;`Vlfc01C;R8&Yv7N5=)% z-bQFQun9qqbm-7^B;NT4!phGEXul?zB)vWbX5A6`6TloJA`o}@3ow4fXICoi{I}$T zRPnsyRO{V~M4OONHcwJnwo5-BSuV?y8Kj$p4F%(bR_UB|61WCvh{mB&fp}^9FM$-n z%+w$D1(i#R4L-|S<>cLe%_N4w>W!CpY3_U|NCnh6gWIGMxAPLJ75Nt0{-WsTqU(~g zEN2{_i0j=`C{HBVy0J91E$_c6Pqh>ug&DEG*K$RxobL7UI2p^1Y$bMCK}8MS7)I9`iXIWZH}2I6nUFgN?6(i^h*`4*8oIRdeuIp7k9_2;`V zs$3}yC{$Pm^)x*{7Mg6|j`K?TBBwj(a-VKXzgU-`E-+a7vwrzUu~w9p%28SwxF;lG zLlIME8Ks_fHl<~~uW({9f+S2(k8|Vk&Q{?bj>Wa3_f8v|i=A#aKc=e2yz)RCQ3r0L zf71BHLPZR9^8WVw?rgFj7bdkSD0g9SY9DO3b!btJaGPMkpgAb6%g$1t;lKhj`RkXh zSUlQ3)j7+vat}BrqP8~zhNoV1AQH|w7YubF&uZ#@jN?nf3j&tK?Hv$m`F9e)n};whg1;0v`{CGznq#94m69xT4c9;Z3HfArBEUOcFEiy$S}_x~90#rLQHH=K%RUn7xmZvnqDyWTFKKfIi% z@-}0-h9@uy^!1Xis?D+Ey(Q+GR1IVWEg&jwzhuUouV7eREJF zBnZ(9RXXKCI_g!)#;(0n2rbq;u>O(IH%6zfVx?!Wk8VBdj@Qt`QtL2*Aj|Itbo5W| z7ghOM{ezLk&fRLHifHFzhOlZgW43yCQOV%g@0133(OzGE0Q8#hsrit;2VVzw@%&PD z0;op}OX^;#z}3q6$Q~8I^o#gAtLY%RanWhFeO<0%%qJPhpO`&a?G@g|C&b+K2z|dniLy`y7NC4ISbzCkkP2-y-*4 zg#?sTjBCvwsqKt0Eyv#=<&y!u^@m@{^r`kWxo~`bMJi2``UnMsRw$O4Xyz-vv32B* z=gMFBiEdZy9q{;E!!Wm)=%{Ifug&Om$G%3{8R%`Mk$-nxP`W;)2087OvrEx{wgo$-pn{gl zS3W=a$I^@Ep#hTlz{t;-`5boUYR#8ik($v0QoMs^fFsC}&b_C=7-}{fG=;~(3*mly z3=4-e&0atw>?v14j_Uo~pfX4ey#9j)+D(X(oCnH|Q+sW$ozSP@Nk#Tel%F_v?cWH9 zd=hprpCTwalwYXx-!uU(fTFSuqj*QBCTVw-wYHCf_)S1*s22DG%CIE;E19Mxr7E#v z7h`tdISB_;B$}zjbJ?-_2_%_V&>L)a%m&DTwR#(S1o-{kqvik`q9 z-uV~9;###_He>{AlnwlTn-opxVOqkLpnR8}ulX75*+d*h$ku)o_-|j;@pp#U$lANi z?mndJdWamm&2LD-puuUbL+_}c9GO~N5u!V^#NYvH@uO21+Kr~?W7x#n$kf2zabW2k zu&ttnh#AIVq?Jf+)y*`x@|Lu6i3ud|rSSqf0|ie|c78HS6ZKF(U}}1U_9l$7zf8P4 zQAHhtoyoZ5a%%0HYFWS@r!e7w|AduK(@&nFe~o+xU4>Xm^TRVN+aNf6;pKf52mk$> z4pqT3&A9DwJnBCflzn{W*K-^4k>>sGkvdAxTjLy6t)y5Dkq zrvF0^4MzvCtqU0Qal4T5K)uN#s0)o$r`N=C_p8wjw)$DHioPn(;;^%91OgH|Eo4GQs+11-X5j~r_P8Uuoi-a+(UG@KG?Gm$rxkl>#by;l z{^`&0K1v&u%lX7Tn=L>CZLP=sXk#SUQ;oPR86mDKqQ19{q;H~eaE)R0GwS^wxCV-y zlq(y&94#9RNyz^maL6OeL9Qz*@UaAEmBUi{p>~H!A-x<@g#Gh+b zk;}D9IVr?kuet4ff6nDvRPGn!u&|Y$vzLyUHJ!dyA%4z|R7h;8S>Be<+v4?FDWyz- zIFG8ucpmabOg9rx=Sr{!Y;?~@DWoq6NFD2IV8JM(?^g@tSI>E8>#-}GYJ_=86@18<18`(@1mNTUj&!WPK|7T z^KI8k#N>R~+#$OM5SJ^f{M`yGb{y!+%Q1B-b==8{ftbFASHuyJLV z$NtK=4E;t>tO&Bu#tX6<12rx3ZP9Qx7b+#mk5j ze{s!mn(0D>I+>2+hAp3Q`Z(8QGZ4OrY;}^Y4YCvgd_b6Nj1Wkve@02XADWtsM4Zjh z&|n|8--#w+1eao3=1X}&dF15LA<1)@hK!TvbkDZq{E-a7mCn=uasfQApk<1v8t~8+ z_3Eq8aSGJ8y9PARG)W)lD#nsAzS)+aoeaso)`5G%={EByWw{=d+h0vaY)|*Uo9lI7 zselw$dgh;InZ1;LvHebC=4tvqVLgc7zAMyLgX6I4V184S-yB$BW$O~u9CKJlS!Fcv zW@`m)psVx+Oe*eOf}od{T}3T&<|YUA+EQYceNK_IVhdkNjyf`sj}v9p z%eQ!7X1sEhD}LNyOGiM@g{Ed|7WM5ICp|NeTjFRazgf&Am^qE=*9hv3dR<$pZKbez zvJt+GCswY+DZPPTSF}MgMl?t1 z33}PzZm3b0R7c5#m&y|I|I-0w@h5+CljGno9}PeL8KylgWCy!h>>cczxfM5rH?^9N zy9uY*f(>2bGgMcT{Y`h4IhDrE`=FFPcM>61*2CCrk9KwR7^5pVG%DO8ldK$}Uw#OtbWT2e)-fMYZirStK>8a{V7eL&${}1 z=EStA^?P4$fbB?y4`?PN3_uwy?(y5d%N3Z(RRM!B+i=XE>{@ha9%VHqARbRY__qBb z!bC=4ZH`D@-SD3@<;3VEdy{Jvv1~sftB3cUrhR?Q`A2a>+e~C5Kn(Rkt#IvLf3#T+ zQX|2#hXoA0`XX#S;EW2AeDc=}UTT*^ZndV1AW%*(Ba3Bj*4}k<4f+rer;*UKzcO*l z%6q%Nff;M5Wf$y3v8C|cI(_;#^DDT}Gm zgI;B$gQG4%R@NqjY??lk`ckFchx0)@_bV2Pwml7(UMY zfMq9;vcOpwlYNCseOBEgE2W>cm2{9-nxtbqqx3|(&|ZU-?VJAh6u93 zl+?b3nxaA%x<62q#*r<4Q6rss)>G{@k_?qf;X%O|<8V?4ziYWaRzu%CaUHsnAP1|O z4~UE8vXV@++)t;Vx$AZ>KbQt|1!eeYIR^YZx(r;m&Jvk%9tO4TX=SH&e^9xTi2EDM z3JupoSD6=MKq>sgfOgLlXw7zrMMGYFe>U!EWf?}d*u(mpMb_cS;du+Pfp7GtQ11ZB zwC8^GJHqT!{9zPk`{if4Nq*~jl+h@5Zww%Zpb0yqr-0Vn>q0&-+Q4VM^D;Wf=sIGY zX+C??)SOas`KolhAU4}IbcvtEBLNwrvAVG8uRLn zeNgt`Tl#d%bm5s3%g5GJzbXJ+2->Modw+(l16!|O21q`njFhjqwu>y+p7*~lD7L1| zUt2sIw|LC0eMM7z%8bd6EoVGhRh+b@zqF5Igb!~#SHtf3F#WbQmxuLncf3#O!*u+H8a3i8*g>2{ZgcaPlt` z=|=i_uy|4pn3{u9;yz9APhErmCtm{zGdKE2*RW}<@Opat_n-)+CmEyn=8DP~>mq&{ zk}Opy=y@fbY01~p|IgqoC@uE7$sOo9!IbacEOqb>7%2)lkC!L`hM z$qUNeKbhaRna?}Z*!mW1{h~)pH?1*!vL^9N!#lo>2fL5v3R}a`j@=?}76#LZ3flts zi#=55@o=&A|D1P4lNuVRqxLh7%ZK*dA_fChV!q!6j5)p>Ki!3``4aw3FETy0aIV`K z<{N1&O$XNpdwMiW1BOU1t9{KCL*?svc~{?D!T(6#7VPvmw~DU$nEi?xITL85N}Z{& z^iiG5nx+O)vXcX%(K&97$!-8Qv8z4ThwX9~hH+`k^0MQKu+77lsrEi3TnEs&oy_wm(hXzG4}`$QwAUUZJ$laBO;|Ym(kV zCEH14pDbl2Vo}l-a}l1>k4i`hbuuhu*CG<+2ZNUUc9cFs$tNED_$TtV?PL~As|yEk zGWO&Oj~&EC4{|sAT15YGM*7+Si3{#kvAr*?$Z#`@L0^xx5{{q?S3q|U@9C)jO`0+{!V7J1|UwuM$;TQK^kA-!$))Uwhr@Btsk zB3opJ)7Z|MQ(LFnsIlb;X)zHan8wCM27mo~ezvOq~B zehK2k#17ZgPLnswj^VG%sO;W(jXC?z?u*ogY^Fx6{NJ2AhVy!$G*WjWv+qb4Q-v~f zi$#X*M&F=kGEw?`V9Lw#?GU!r*zlomKjKh zgmfd)AxcX6-5Z{B-rx7%@$fwNbKO_>-Z(3#$y^VYTE5DJ@quir&y7(Ho~zg9QB*D& z&UZiwak4N2!jc+Y=nX%Ky&H-~a{-m;VtEK)=4}#lQnu0v{UiG$@kE-sS|E@VU z(wnwPMZ=kcKtM@*75*D6OD74JK2L)^VOl)8TJ2`CWZmL~hXk6y%tMtFXXsS?Hw7UoOFJcdQee4IgI!z6^^CvJ7W+RH(zgrSprh4g zJ{x7PdgpGa-u%*?qws=8HAAWFNY~ZnxPT5m`J@4rqkvY4t*YlsFD!b;3=uI!KKi07 zWZ2_TV%dWywsHZyu7=r;N_UsC65IK8#wyi@+B$&aMkGeO^D8qke_-QG@lsR&;3teD z+`>-wOm^A3&y!yTKcberPtUd1U!8B|=lZh(kDS##qUKWC+Of_ydu`7MJa<0U3WG5X{!@)W?yJui|eaHhD|ND5C^eS|xz`=XUyjkzu zV!;JWDP*5PkU6xT#>+ovaV__W)_0-W)~BIH+FkTcL5rMzp-Z|rt6k=X#~YDW=4PUJ zK4u^~i1Y~Z-NRLPT5|Yo=ZosM zwjb~3z5llT8rs}{v*YKN>53cTct5@nhf0j@fG+E6uFX<4bSF>v1kaQqtxKJS9-h6G zaO2=sy7JVj%AX$?veRkq-kTng&pp$hUK1M{wq(@Sh})qRQOlf%+{_5+q~ir ze3hM)*~cO-U^{B%Q}aB&y2Z7)<<}p&H64e~B;|=S43hVL`w(S6jc&I zcd}xuFBge*yuz)IECgQHWt?JdaIv9eB-vO!3Gk!X2>D$jWyQFz9ZS+{j6TE|BK=V$-`R|szGf+ z5-5#REDUI(s7M(h*)0zwdq84Gm8{LTux`~vRHN~gmN@t>hqJbpx@kzkym1aa)OeYK zC;q|S#Jj+iStU<*T9COz{)WgQTB_bFZdROMJAH)(N#x~MZT-QK6P1_Qrn0rO(l#M< zPi)1kPTS*$V+#r`Ndo-a2SS6&$fHh0D?Pxi=vLA(_sROLXF>e#H;(xyu^hx6 znmmdm6|03e0{tVTJML9lc*SKkDrf`&TKv9YH1+9|$`6%{@lw{FK|2o?_cT-I4G&dS zW9DTu19Af)87>S55Xn!CYkUJy)_U{TzSw`T71Y%F@kss_*%$pM)U2AE6rU+GJ`_S< z+PoExS+{;Y_qZM(fJ>omg^w@(eyR{h+JJVs(wj@O8kCZqIx<40#WtX|&Bosx8fKIG z^`;*ESAS;eH*M?Nq#uDzGPuvWfjymA!MC3}G43+FTX8moQu}>lnHrc3b0g>&BbB{bByqn`Hgg z<*`S~r$1L%z#%->824r2HV#YFjJNFl=S6pUEW2V||)goIv#9Gww`Wl8N>iGJD;<`ja z(TzPLY6-cTxx1d;j(+r`w^yPMp$3DjH5xw!=djIP0V^-B)B+>%(E)&J(Tdr55QWpYrX(PRg5FCQBv2u5C!-BSwuX4m*lSGWGW zgGjAyvB2FJvizoknaFC(!=FkF{p7tARV@be)l&58Z|{bOV#)A|&w)s|m?hBogRRds ziHzA{^)$=p8@J>|s#bU(=Sv!CsBUaM*whVLJl}%BtRr&R5%i?~9zJhA^s~}}(heM0~w^6@0SCuDNdL+bt)*&H~rPHwmC+alG4%iBc| zCD$ljov107-TU1Ej1CV z>=X);vhTPh$2r$xxei4$4v;UUNWm>IwGRtDqyj1L%eUDR_;UG26jCxAQsrmGHPM46 zgNLyuf4nb6nb(W9M^iu_tWb>Tw+@k)rC;r|d>h+b^v(r)7k`c)?yIbEJH^F(rXbJ4 z_#kbjON(NRSN`-CnefsHHQp-kFO;j{zfyWdY|1m^Oh(#6W(u94;7o}**9l?%y-<+A zAyf}!jV7eaQwr{ zH6;*6m*B*hNpXEu6AbZP{jdpuVhSw=3ORuLqlJCOoqY_%+Ol8U>!;Y`+(5b<5thk= z#l>JHIXTCz-wy40Ip^Bl3vaxfu!*^tfRv`oSQ|j0!s%qq(M$W=`(07L$?#b=4WlOM zJI#WT_hl-?(UX@V%XoF8TtM4S(v8Fnds6y%F|m)EN)kCnrC^M#L5zGQV!L)`U;5{q8Rz2#jX$KUK4srNYYk9 z3Z)|Vp1z)yNxT9(51b%d`qaZ`?`uu!KEOn}@`vwlU~DC=s%(q=WD(DttmPaxIWI*uT)vk63l-)-#(2H} zn|d{@OKGTSsDw6yw|^i208CK|@}e`go_7?*)7GJN*pMhQ-~R zTTZX31bR0)bfPZs_j!#@PB`gAHtfq!d+Um1@<=H{7_TvUD9PCMs%B7%`b0Y(tNOb~ z-NBb9WTw4E%G9&jPAAyWyt+j#&7Jk_C2mRP>q-zOn>D{63+-ZJ<~F~|#Hf%JZ+$+$ zwm4nf{;h5c`N;u~H=6egnZ?5`<5#8jnhOjDANGsxY$$K#wZj#?T>6fY&{rE@Z zTVgeaYY=!Fa0(5Dpgdd_cMBWz?~MxXP!Ypu+_+`-OBz+mAOD$bCz&{f@~?mN!C5w( zPUh;@uhCn*X=lBPB8BuVbL#K%>O`7&SeKe$augH5GH;t99{3w#c<=+kB9IWI#f`{x*myXW*C9`X$!SYp>i%d(e1L>y%I$bHgc8W%B-yX8_jwZZj;ZZ+-yD;LiOR!M=q>2;H43_9QArBxM!sM!X$Vjg(uPKRTbfJb zSNS`5@W3L|G>EPXKfL;0bfkIkA#?ncoeIjG*gcX74^lYbv1R3_R|se09~;ZpU(Lyk z?gCknq4pHEU$l6be2G^>Dlbn8-hJ@#2PlM+^fOLB4GQj^>k!;BonzxA=u88gU7J-( zMnp&o%Wa-n;&!~oYLms)kSmLcuO`6*TUSzw>kUEaGhYZC8Ig@VFBLRNJzc~_sVxZp z2StIeJza+W07Z!Z=w-55m#Em3LEHux27Jw*3v1HWUNyI4MSPC{b;L{XEYqVn&Su)% z^?L3!g!(lrGAQ^6uXT}W8NP~i8H^pq;h2Pv2Orh4y{#LUqV9o@^kf1G(7%i)0*?i2 z;&RD*C#`abehH|zbe4YQ9ZzUvx}bbWtl~ zi(xu73epwYkLT{k(C14OH@O4oK&{VdPT=Em^HGsd6~3P8ciSod7#*&wP*PT?=OM+Gs)4h3+j5kd!+yX z7mUn7M4f}*X7wko$lY4ZzAHrKycu~7G$SA=_9>YfjzG5w9%%|h*M%M)3?+cjw+d0$ z9GJ{dhi~X$hYfqJKHzo^eqg8XC~*qi3DsMt2#vtScft?Ha1#X^Nyq9*SMi1LI?}B^ zYJHzlYpS`XN1C_|{HHr1CCxI!OO7Q&Wx+>5eRCKk^CVE2&BP(EbLu}$x%WVg`EmvR zWjb)I4Tz3f2X%hB<#_82x!gIyMF+`w1nnKUue& z)=^v(e4&AP0@pmNKJ8q$ad0K~UmgUp2CZjze)Ro5O2F^9XCj--E!HsFrXht;xy<41 zbwPwjZrPnd${HNAtXQalhxAH3(JVDGa(4Nj1u9l&xs}f*U0m9Oo4k}EEb+rO~Q(D6aQ$u9z>qoeqfUWU7M5~=PWXKmmKS~MnWkS)FF8P zUo7`Tffq9Z?5Rhh&UG_W6yTItP;X|=N%p2N@>Vy08CWH1u_YP;`KH=0>e6eg;iDiU zi>E3{KR1O$P@5>R3TS`BiAszvIZUb5@{J#NlnK7Nu-D++FD1%~wt;`0~q4>!+e=GN`krC-%h)!n>^7 zS(qLBv!Ggy8vO~n%2ydeHOBY0pmS*Y>${-NsBM?iC47-OBao(~>Qpbw+A2vpHB zD1IaSxTGFNFtalmK~QRKC6pdI-z3bX2OgV^`cTzC_3l0R*qdH*(EeP$K4-<`FPQ({ z>j`>Jt)>})dR7}YSFmGH_wuom94?0Wp`l|)%gfR6Y@NoHhw^#EfMV07zWNe;pQn~J z)t!V*!_sRCGmKdkq2$U*T&o|sIwk95$(1(3f^;WocDAB`ev$ow@m<}*i0(2}Pi z>8`=A%$!e)a$$T!AP0FW-R!HmrKWxyqF;tOTGi||g&y)GXhy9RC%zO*v&xFcH;XN5 zGXxH)HpE?rqA7@})i1_zuC_(cF>ch2uRF~>E%03Ti>i9 z%PE2oTm{_?{ioSm(9y3RX2P^jOqe0M)ZNn&;?~7((x?Ar?sz* z7K-)=W>|qCki7TmOvUSYGxOHAM9Q{@M&`xakQP`%QB!S<&H{H}pG(Lk1&7a)^o-@3 z4{8*6;*>O6zGz8U%4`7H(L(m94#1O^p|PPb|(?;6V-y>?f|S95&?0wT@C) zXc_Sre-jNT^---FJop{hq9y(VBAIfhb;(gbXu|a}7x}KEBhU)H-7lOoykJez&Up;ITIf_z`Jy zjfj|u;&-7V*X};;Ol1m_g`$eHDromyS;tWPDe>r7IwP3mucOYa^pV{OkK@mW@=^1y zDV-<2c{K6r*s@kfdf5%xH(eyd{5?~ejcM4if{z-j)$FY;v3z@jw{A;^j3VxeY?nXv z^iJBB(Y{FV7+~m9i#J-6x~r92ErqwAP!oTp7}nr)H=z7HrCE2sIrhwrm0&5O=C(gZ z9Y>T+j8RNs{Vf$kui3#>BW}==q>o!a%j;9f=%sAaGGZzIb5%0WM`B>UCExMNx&>p& zG3@wRedDua8e@qld}|n3@Du80n#-zrz}ULGXP{c*MQ44w;8GyYDBB_D{UiIWqxG!b z{js>wYoTyRwg-{tlVhdc#V(rBjk5ES+DC8RC*xfN0f@j2JBxM3iMh=Io6FkPSrC-d zzz0z1TC{5pnX7Ym9M%yRPh&;v^SN^Q+!&a@C&{`4A#^5Dv>8l4vdtJBTA-M(AZHLf z?DB5LJR#LZv`fJm5B0NRKD6`jJ?FYN@4nVS^HjW;QIS@^>-aW4@;n6@A-x}U#F{+% z9x*U~IoIl;>GMmM^I?YhZc1fk_A%Yqx0;p{=H|8D8gzNSE{&5aSp%FGOht6hj80|| z8r=}sI1YHnfmD@yV_`ClLm5wAR3Ahx57n&EsiD?T+Hz;=(w!@LX$(pgzFt4W=PqQA z-e2?6RER5d*EA;3$_`DbQ$9Mh7%_ifJ7LUqImwqS{^!$x2~D=FW^|=vS-0J11cIcW z55-^M&&YI(!M{!43-fv4eR zp}65+_L+&TsEY5la4Oe+My`bWJU9c7H7Ih@|UFQFuz<5it>?~IvXgux*B zFs%#1>nS7KYe%f=Pc#C-y9`RDI2N6r?cG<6%Yq8jnJWP%b??Cp%pe`r5a(}5eOdED z!kuwdad8G0v~K06MuSeTk*@gu7;Q%It}jvqf-rGJ>-hXb)bR6) z+v4UZy968i-6~xY^4KahHsPB;m?akvj1Bfivd^z@AV^G@j0C+uTbl#NbHSA9i!44K zBVLC84x-+g6S>jtG07d5y)0>3rv^P^X&c0ToZaShJ@|=kcZah(0HTw)bVo@%KZ6X4RsSG&MGCj+wCXyVq%le+F6Gyw;WzU)E7bOBr1%W-X;LF|2+{ zBl#Bscr8+Wb55is+hdg702SIxggJ)EHu#2;n@ipBE{)H6mOo)!5VDqvDrSJ9^`Kon zgU0(3g{(spjWevrC~X?ceUas&0GIj@q&GsLcYu!G44OWO4!V(|({`v`6JC&2Oc`T5X4<8HJWH zOiu@r#pK}gAcn^_-1cg=8&SjHnsmz)rWD5iQR_+j zJ505)5K+#R9U89k%I?7O#Um}YHgCnv%}5QYb|mhtzo^cW7v4$~c`^)N#D02K&e>Xz zdJOZ9UC(MN>pCwiUyknw_oKY4nvi_)vA{9Q9eMTYOsUeE7OJD?Qcp6gbl8@?0#e9L z*Gs8)j;*B9I^e<{PgC@0SKoPaXJB_tghQLCb`HM6gg>+hJwV+Eo=L@VsgDHm{E6~W z&;3+Fk~P3sPI-S-vT!8k!q$G%=h&O4_oVFM(-0|z=hW~~e(m)VhM!V8!Fu1h5>=(_OOdTFZTPd-QA zm5tJgJiPQ84V4ZHb^|x+nc_5$di$CBG~QW*F*p58KB0%Hai?gQP?KaOEB^#|Za1FA zE(;B1?yIO1KcKNt_SgN{Nq4jw!BJ8pOw^gilibr-&4x-o+lx^Oh6&0wAI}lzh1ty+*B@wF|i3KK2JN@J6T#}Xd-a5b{30i*6A{7~ThQvBk!(CORp z56mxk<3;7c#oyVH?)S6&+n{JaV$pt7bHT6-PhFZ2R-0JpT>lv3sHF8$pQZevqX;oU z6TE{BlQCXUezvTKm49q}k7PW}wkW?A5oB9-j<|q2uSTL$YCt#m=_eW4&Gx%0EOL0O zrh|@)+1t(d^5!Fe8~14XDAL%zC26}fkcG1CQQ8}F@Dn2Cx&i~gP{p9d!?sV^0q-cW zqQxxi8WdqbTX;}g^l|}BoQ|cWWhc4IuA~@bL27zuyxj&3NWmuHjEDqu6D;DNOk0-LnN@z!A~3NFSgwXaCKm7S8bbF0+zc zkOk#{$17fb*GwjW;zzB9wvAyE8?#oLe__Z~a7`z%`~?YGF$IzkT{ zg0mE_ajBbHW|B^*3?z5rJuC)_dK@u}g%oC$3h*2wtT8()OvNV8$a#W7_wG!x)e?on zkqxdADUz>oxgUyDUcD%GnZPGZ?)$QN19f{d8o zozt~oP?DD4Q$q&W-RA9D0g8 zpt-1e*=H&ws8hu@v~u;CZBMf*Q3O9o8&#bLDq-`-Pk(Q(e}O?x^AgbpIA4e6c6&W~ zfBFLP4^6r?xo5)Ln=BWW<=~XklAuA@>y==C&1E@)C4G3q==Az(*6-UH$ua|qXrIDS zVUB8z+eUt=w$jDC)Yy>4jl1_(`UD2Q3?~oZqXZIvW^AlVSq1F5M`~t?L*-EB=q+0+ zP?b?8Rde!h3#81hByG$HQmpyY!Hn07M8x%QH-&Dy5^O3Ju^z?mQjW4*<4Y~J+-hJV zPALn?PseodBE6CnB$OMV;e;0oF1hJf*yh*P)sG~Qq8}5l21n>$uSCz}Jg&ycQj#bc zq~M8*0b*CBu3oe0Jkm17~!9erpOB+8yc~v8}=; z95@B9rY#=g6f{Sre@QcQKG7!bAn6>eB&9-KPd`odM;ZSi1tQ_1Ke2xHfum%r!B+^5 zz$tVkv4^!}F6TVETXRd=YcC_rPWpBBSS9d00}BzYd)8~Q&YsvRd%eIclh0Ns-&sUp z6TGkFlB_jFJukQKJ6kn%Ef3qp4-Qr@gX1aU@zan zVCt^XdFsit2L0X+k;XDm@TEJ{S~@G{(mh?bK7Ka0=~^Z@uoMU|2i9n)+L)>JTY{&# z)pXoPWhUStT|8tfoyiK+cZ5ajO3<(vYM{4X% z$uzWP!Z#@qUMo>xT+NB%BFp!vU%_{?dqMz_nO%T{g3#GdT<}y zS#-8q`wRG44uN0k?}-L}kmI6#t?e@aB)GBuv>k}Ej{)3uXh290A{kx<;)%|Wkmzn?m4D+-)|KIgnj;iX)sPow1>nziXmT`fo$D+b?A zCq1v`hx+)Gvn3YR@MrQOMhips;wbvP!cDH05Rdzcc%X4m57##PUGi}E_#3-^cx?lS za09{{y&z(%EbD$nM62}X;E*CMyKVIQFz!9A)y{BDs#~0&T!Lw~h7|%pMjx34p$n&I z;(lSu?1G4^CabX>Qu_-&(g^MAWryvC32+pk^|nfqQTN!=N#ku{qBz~ z1T}d(g%Nf3g!`>%;`1d}`}s)m#GP(LmR4VN{9fH9Z|WL*l7l$mV_)Pn0IByXdO_RT zBfP)<)FweK|NWz{5B`r<$Lb<|SH)tNMz!&^)DuJkY~E!wdcmQU+s19oMTVVz*a9o^ z*B+L)S_`xxBpC5rNFcNpPDmnzWAS{I;Krthw0Yjdi<4046Veg%(vi za>=+xvE_btdGSH@zpJa0a^>99RN+d$oPpJCXe@Qp{*~i56O7E4*veY22x4~OD8K3) zjOjNY`{x~iNde={dQ3O_pk`6AmK@Jx<$SH&#j7pum>SM6AGe-EQD5g*_Y;Pn9y}iz zAq+SZ_|;bmB9~tx%&DNEm*b}JM9O>l=)CQVq?8NRl2;2PMq3^?%O|}zu8H+t-pxH)fABzKR{_+beRYY*0ZvTCp ziyI;g;}d^9v@on$d9!4R=E3W^+qU;h&$v1WYf`=Ju0GM+c(TH1v?Td|zsShr&1JP5 z`^<@eo*Q1INk!E=iv%+%Wbjq~JpaOjaC1W8E;p zuhiCUs}pfAi7;(X;26XsBN5vjp#XikA72;7h1F8cpxLL08Z0`qQy5F@hoAJmg}PPz z)$)L5=tHQ+0PCNEXT{9@zbe)f_A0O~kvOmev5d#q?YSYlyZ3(xA?Cyu-8rbpc%5Fp zxo=~WQbqT|_FU_wgRtc|O^Jr`l!|NimkRJbt0zcNYQ{0?^oy>4QL5e8t4Q>Ctn5Xj zs^kdl*_hKezj7;7Waa#bi1|~2|6Yk`LSDC>8N=*SS$f%ZdWxW|u4kV@OI3bpq;1Gs z`=VU(g7mgo)PJ}cIrm(-uxrDtz}*`)!6wW)s3$Y+>cQ0gh}%(DPfX47mJz;ff z^Vc2&@2Y5iOM_3M`3mKt{*&~}XVkIR){>xq%@sh3?-*o<>Ig^Btl&$cT}D7SScMh0P6;}+-yW?( zTlGOv$3}p+1DULON^<8V6J(E|85(P=RB?FT&&_%D+_%@37=^ zl->CUnp0>G=ou?<+IwAZv0XDxhKQ9z#U>orP%W+CQUko!@b1inSYwh=gUgBAGs)>2jLT4H^mnJ+ ztg(Rw#MOOzH({x+HwqgjoGdB{^Ij+5M*!&=oh_wug1_}C>8v>RoSjm$DNDv#60O!Y zbH!cm`%mHCfn(D%!qpm!+bWnT-&fmpSDI?M%R{P}4NHHzw0h{fTvt*3)cNXP!R*Py z<>!0FsVN{pXY^Sm;D$$#I$F5M1GJ-FNH$e=nXi?dn28<=Jl{~qU(78w0V~2&%mq(<@DAeNTQKONQ!4jqs7ic9otwNjO=@MTr2a+=KC=+2V z@pF1cGIP7|fFqu!LTPLBYT8dFCI7)hk_GlZ>D^QR^^&Q$+pZ|LaL!;!fYy3b92fY* zK+&P-y^wS%!fNk(eEQxkm0=gT|MRI;A;try1AfVyslD+vs9UsE2`Xv6YpW$xpqRgp zad~lgf9BLFCSsX~;%acz$JW4SdNNP?ir;i2=rxBGoPyp9N&cVXK3TXlE7?T2x2`QkK^?TOJn}=kTz(vB$5sr{KAxY&h(jfHwA7? zt&iZF`%dgRau)1a`9lidq;d|#@L+XYi$Fc%!9I^|W9S7lKv;R&2tq7-Vzu$mLSkMfe<8VR#$wW<4)m=k* z2%!I!Q(vSQ<#W|vff-xqGO!^-1s9$xYB)&?08%P`K_*C2bRTAb_uLh%~MP`uj!s%}oX5?koe?-8#?lLr2?`1mHq zKz0T7+gg6Ybd16eoEwbq{g2dw&)lKFUKj(R_Yx*Rv3F*7=CP=X=QYr}_1{f>k!K() zRw+;6PE^j%$M4ii+1^pXr&#{w1vC}Z!&2W+=}=Xitxe=~LwiB!;!xKAJwg@|Vj;qY zU_~sF)LA}@8x72S@IUfO!VnRQGt=pn#3%xKkMqUnRNvEir_2aeIQ@qT3pFE$;%T>* zKA4cW9qo9QfHCpC|NFqhv}Wo_Lx)U1@r&a>h_%_a^;_QkkB|ep^t0dA`n;A~``}5g zz5`#|h11rzgfahPuYo^x6*|~|IHfXP6rZ1VX*T>_p;hSwJUSR!tHec^Lp*^fPunOs zb{JV!X3X3&h@pgG3?VlQez;?#6_| z1Lb!MY>aMtZ&W6lOWZoYU(55rKn}%ogWC)KUKb}!wDP+s9pU1!%0_p6J+Z6+Hn#Li zOg*_UUUT4LCshDw=tLwY;Fnu~!-EadQi(P2o^|e8u8a5G8D@Wy4!VwCS^*QpaehFk z!C>;;-~Z_9`!p6BM^fxX-}}loD=^+Q3kZjEjoHr4g|&A|D%-26!P6&0K?D}4y@4&_ zs3^&Jy3nfNQ*rP|X@(jreu-P@Q0do`aVnFkC;-VD|C5C`02U1O_p4jjGC2={ncL==e9y4fv}UHoOoSLq#Vnvg1~n5$ETJbcF~!-&w*K za$e>WCy8DL8FlrAk9vQ_E~3OYWza0QzIckUX!GgrUOIzPA&y^Xnz$uehsMMkJY06+ zFWVvqA#xU{>4Zgh-1wm{u9@7te!Snx+47xA0CNrOsRfS?w0wH-_gtk%I8n`_qG4oj z+3Cv13GNC0paZ9(@~1W?mD5bHoGBJ0`X~?n5$b+sqoJ)~W%`xF=ou%E#$W(-EJV_-$ z2CSlsNC?7&W*}az2M60^4cD&alA(G)AfHBpP8ePM!_lQNobL##AMiAZXbv{c6U&a{ zBs#c;#embxQc837Wp5j0 zMlThtC{iu3&wHrZ7c7^ZqGJlD4KFx}n0r`_hK`2i6@*dVgFWj47q8)Wx#_64HzU0B z+**TRs;$oe(gXTpP4GjV3>4vDV8w-0GXJ#6X@=V~y7$+v>*QSEO#coK4~o6K_nQ$J z)E17)h$TS%3pNav2U86aaRf{pM*I1$LrU3+gqfTJ-iHAcA|3)1GOpTCouCi{5oklx z?Ui+P$J&MmEwVw;O2lReO48hz|Q;b!JXn_I6l1_R*kGQ$e zjc@B=d$$;P^tkE@|4FJ{3irsTf;J^qNNmT+!KXk`p3*|g$ZzncS4$OH=}S21&IE$< z%19gR!ve{VXoy#I)x?3hZ~!RgsZO5(W$TZux7E+3rr$N>VXK~PAG!rj_pYL;BE*T$ zAIlKwY(HwS>b3k_Dhd_W0-f)YJ$_Ok+S-RZY;r2hWxFP1|VM0IOI@ zI-VBvC)2IO>tZ;FX?)3Fi`h!b6SU6;rPiaQGV&gB+cIa-BvVcjH@0VSR?iD&rX~lH z!H=_x1M-|bPfrkshwMf#=xqwI;=jMQ_?PT8PBUKI0er!?Xp5+ zww4UM##dwe>1%f216+#%cb+(NK=k|8w+lk>L|2OOB@42Z@&-a!_SSFrJ}@D9;?o*m z4w^9sR$77Dls^@G1<$T0zJd{0Ta5zyjsj&#Dokgm6|ff%obVW^*-}0yRkO-{Rd<0m z;tbaSX}(pmB;X~i?A);D@F&cz$`+3@qKI4gKJthWA7#Cw_<}SBicmmvi^Rl-0C7Op z&v1~^l647*dm>gx@ma}!wx4;_2TAW0LOrYBs$;1j$6$ZJMl)GE!GP%F6ap%`!d?7| zc>4|U3BG;sYsJQKoZRY-T2mZaFf2Hfju-E5;EfqtkJ!dy)fRBas4mX~0wB=I!3;qJ@M7YO-{1ov5%BmjQE)DSKS02? z;jRm^tQkuj^Z-Rdk5da!YoXuN^Fd}egKf*nU8nl-uFiE4vvMDQ1c<|Lx zP@Ovu1GQ0b`0~ZY%xu8YE5sxG;vt~9gaNd^o7_an>1vrTM(t~SP{Eg6|Hq`I38T$K z>WXKO0s1r_`Ne_Dq7;PFyZLnJRE&^#_dpprH9(~h!2AIE6BB`L+gb1Y#=I{f)wy_q zaF>kO`lg#er%1UJ2Y}A9G)BNJWWUO8Eo zE-P(P2nin(0G(1KmM|(oqou|^s?4xLVhi`KHwi`-KsGC@rKnsvjz@NebMX6$@h6k> zpHauVX4fbe3q6K!kDz3ek1D4?xnC*8SO4Itpk$RoPZLbx#Ul+)gkD)q zBWBwl(g9=DCHt=-K@!+Da15UC0}F%PBxs_pl{0) zK1fuaT8gIuMFhaO@6{+ZJbTd-YYc8mA;?v^ram;@4@DM12EWxQ{wl4GzsyPO&P)*k zp4HMx1WOGWG>C-vD@ws{3faONe~_a6kY~|xTf;(PfYq?f4?w^ZEbS}!DfnuV8hDrk z{kmhv0{ki#OGZbs31uGFZ9_$oY&WEXkM3;}KL((1xsXAK`9U^U;H}B0X`dUpJ<^Im zX>6&05}~$HY-G&=pgHow63+*t)<&raVNmf|q=*rJLa5#*;7A5`3o)5gdbG3J-<2oS zppyfmMSV}{($2ya5%c(4`XVI(f#8;I_-UnQ2Gg4b-vp^VIX#38bvc4T{CUedCL74N z@2Ur0889f}*)Xv-{t9>+p=Xq4^%LGwLuE~EK+E9^hAnt2^ING<#EVn-#RG)l+CTsf z|Hsz%_%GRk?U3URFxs1TZg#q+5@0>`ZSAD$E=6{m+y3q?>OnWbRCOLuiVtkHH^6ki z5^=Q>)0Faa<#(12>6IMrTwF#&dxugW;VMg)CP@9}bXg?Cb9c z5`Tud|3`!-|i* zbxB@=)qtRjNa&$m&4ns3%5xi9t*SGnxq8ja!vvn^OE>5KNO}3xNH+~tFJqVyPX`qvu*+MAqRi50pb;BzC=ZHY(3h>>8*g5gul_-2M_fNRmA+qd! zuIld#M1sKW==OmRF0luY0W}7m$iTa9rWN?*TPBDe!xd54C%K<)CVfL`@k0hkI)@&2 zbJD9u3yGoVdhVY@bVxwZVKTf7ITN3;;%`OR^w(zhX|q_1rM>8vIT*rONfXomz_>G6!_}tV(Nc|G7jRZ;g{pscN95 zKusoa3D01=kQZB9HB^I?IzObU(uA z1q;}wlZ%Kga?m!DO1p|qNNhhNvN*hVC3mWBN|E1#u(qNf0T#1eeHTv$t`A=BeBVGXRx)w1)4C;9|jY^}=BD@QzCJ?{m+ z4K4%*Jah#gPnB?UywL$*K!L-+LGtDcldmrg#4|6}95J|=QLXlsAN@7hKD(>?Qo(d< ziF)Kd!Hxq3hVi<<-~)t@4O`55{J6}$jx8Y&c?B)VU;N$De(;>}$C^7zkMR{7Jz$V# zbwZTD>R5z|5t;3wO#t1M4E(t1X%S_iWz}V3`FuWJFtP-m9S1w#W>E)9!a$8m8L`{W zJGTtMzW~N#L0|DOVty-9fN=5t6!&J94X~oG?;pIoYAl|NQm zcPP;A9pAMj^EaQ0UHNr0;u8ygT0bok;6(P$W3c%q0_wqDSBkK~`OiI2h#s$p$ETSW z_o*(QI+6-sqel|bLFiy0(vtndSzz8U6=qZVr(3-!TuKchfJ3`Hr?)(?48O94#0w{q z0R?!aY@KK}9C;stx{z+jfeL4vv*1n1>|8q*9o%yV0Sg@&Vbu^Y9{A1(nv1M}PmCZh zV!Fer*bw_?VriGSDBRS=ioUDDXo=BDDcsm^0KMR5^Z<(OQy=?)>{a336&&5em^OC# zb+}St!@4eEf~fx3kv5#AIEi2XCwQB##d#D=xnp?3hN70Yxqg;KV*S4x_9%y6-vigL-s?JmM#aI>Gpph zu~5P(lVV@eivod| z_`BdQ^!4KZE9*+bn!1{>!~`LL1`v!O7-g45$_@e9gp?&Lin|~ML_{cy1`yc-WwBN8 zQ*mKUqJ)S*0yZcGF;rTKwQM2+BBT{CB8Zh$)}D|+Zu;d1PafvZoSAp#+;i@n$y_d7 zp+|OuI6jiDW`ZC4qKv?$@$Wu-gY7Wk#6Ow8Zc*5#5d8<|Jd<68td!yP=@tM2eD^bA zw8-TBu3=rSbZuZ{U2mY4sIf+J-TOW!y4d5IWzu>=e|nb_0h-5k+;Yx5ERt>NQ-E7{gK-(ir{>lZa)Glub?=4*Cpi&v8P{-H$5uir z6IE38r!cp&?_-R;tQ=82;pq@(F{h-={{|qh_MxVn2 zWJ3Em2+O4Yf2OJN5N1r9W@J`Ui#MRZV0q+VkF?`>&mBVLHo+U{Rz_Ek2ZGeuw|*6z zNsCP}ab;OT`%)yk|FlcK&!Kq*itlDe;zVym*0N|){1U*9mINXLd!UgUC6a*V{KN_< z%5yOUK6lk$a{0T}ag9J-?F9jdNpj`7|~AjF7-=bV|dJOLz($Y?g7DK)cA5;_NLCQ4yi zW&P)VC^H8c+?IXai?^Zc1%^|_+FFJ!1iY$OUt6g@G(WJC^jeiKX`<5toLAPua(;_F z*hrETMel)K#DS!8U_C)R`R1$YJ?0h!C_CtdkvRG8D58*DBtvaJU5p4@;I++PQ?Eg4 z@(|1%EFy%6ww-ruwKGIdicl#jm$PCrf%qBm-OoeZ*Nx$kLT0ez&@}wkcKjevFU;Tk zE>m`9PV}$_m6bxs_;i3r|4d6jyB-r+2OZ=<1K?WuAeAOhumd*9?BouL0PkYtB{8FI zVdT@#^4PKMw`>vOU*NSK(XpVwhhRGEWpF}@&Svwoxq{enC(-{_1a?=7o3qoE%aQ!e ztH9-1uo(Rp1Q2tDGX2-sjXTUNEZ1rQfPF0RbN)s2eUfo!4=41tUR6rgGSuG~AL7Jy zbRjt=?crdRC+#xcPXrUt=}om`YpD4nch#qF&d043<*v?EGICo*6IWW_FwRl&LPl@f z;7WJpF(KqQuze-(bE>zvaA7 zb|>QdREgBkp6#elzV98j3^}JuxX9XPInWgCzoVHfI)vUGKcYPz5Oi)has2W7g4XoR z+WNEOHmwtu#)hqZGd4HZiNWwv3AaY#!!s&Nrfu-8m48d1Fm@^6|8NP^qf(aJ*Oq9? zvkdM;=i;Ev$%HgMfp-OwiYRg=*cebEjS1Vs;)4}%0xm#gmBC7*_eR8Kc$5yS+<$H% zr104MJP9_Yjzc}JIJuKzlFBPX@yAq=x~@@kA^v_}Mdy6Nvx$mxJS_z31jF~RlRRTH z`}6O;H4x>gb9B4tr$jNnM+p2srj4hb+zh6bYd$$45} zqkr!!o=yCrO2$QS$zfVbMhLmypr6S4v@vu++cfE|eW9!RD##c+ju^sVaQ4Q4QLMq# z*JteYOI{WQe4J@G)^@9@7rE}GI-ftAyv%buXdaz=Nd9EI#42he7cm*{YcI=aVu+(l zD)GkIwwppuYYSjwabWt(-ZSjrtIGLlsd;f=??Ki zH;k@9%u}X}UtO-LlD!OZkX<1xM|14sMWuX7KKnv!;b^s{0LtYJt{9~1#7E7!fcn~ET;B#2kP>rMv_iBrAS_C#xE-boH*baR_xTjivlg)63&W6@b9P9_Y;PVp z9bYRYF9>BoiNyH_#(1bxJ2vNH4@L~Qv>bv6l+Zg$vd-t`H+AFNi`itoif}byw4|^| zus24%Uz-l&+jF+g*V^lvp&`=&9t^JuS`G`~Qfc)k=_WyDP`Q_OF)Z&S-#}Az=CJST zv7tB9}KFCOUpQtbj6OyC=%jTS;p*_ET5|@TCoYP0w{v Tet#vb10NSBkG+)+{;B^0@b8#_ literal 0 HcmV?d00001 diff --git a/src/third_party/cppcodec/test/catch/artwork/catch2-logo-small.png b/src/third_party/cppcodec/test/catch/artwork/catch2-logo-small.png new file mode 100644 index 0000000000000000000000000000000000000000..f2118bee09cf296a9f0598980f5a7c94b8e9f077 GIT binary patch literal 29025 zcmY&=WmsEXvo;V2E-fCsK#`)wgG)KIT8cKwCAUrfQG(r_+g*Rwu=;x2`$2h>pX9wXX z{o@a&rL4Lv8d_C6{;dfX8k!86ih}H0PxL(~b}QYhv%muY3(3c=;=DwJPX&7M8@so~ zoW}B}4zeWZEvB-sv}Dooadfr7IH5~ExU31GPoK)+w*9^dSYEYj^=h*C?BU?W>vQY3 z7g-5%fG{8)AsOfg zwjhF^__V6RRok-s#E7&$qRg1qvusneeWb2`#lewC0_Y&eM)t-k3n7yo^gsWq)dJiV z&C^|FI7+pmfw#2m+4h4fX-^5z8s94acMKVbT@XP)=o_f|J(##V><}*$e3G$k#B%Tu zv`+s2%_gV~K>d<5TBg;An5Fa9EX=rVPpO`cFrA5eipL?S_1}d@5P`gXgb@|pEQc12 zJ^Yq;z8Tf-n3@>>H%97L5Z1L-hqr#i!Yf{kw9b`E^3w>3-YnSWS#O-AW*LPA`J+&e z6OIUKiJngrN19b~?Ex}Fo*-~GcQp(*r5OHCO~1E*Ff)h!&TBT?lFk(454yA<*88S; z8m(J(pIkwMWc~k&by5rTl|`93zPR+*)XU7C8493tyA(ML`$zx(m0ir**#GzO)?Eo7 z`Ht9{1WH;-GBa2)14ql3>3^*7&sgK7@xalh{w@b3)<8F8hI7?$=P>h|B=NOdXO_#wXuA4zt|P;m6|MeltyFTS_6NkR=KmE&cx z&dkr7;N>B{5}HrvCwCzY&HPA?y#M-vwN;kmo=|d9H}~0YK-fN-C`PzEbMHgq{NkZa zBb94n*;9`tu(KY$FJ=|66fYMR@UUcgzodyl_aIA8*Yx0vdi?`~xQouXqafrWTI5Fi zzoI_+jRE0SX?SNmQg2|@v+X0bl-kVp9foUGRPLIMPOrBl^w8_R0NJ4#Aa$8&{9WWh z(#ey`AMJ(wk!31-_WydeRR&PP-Ut^Snv#_&4_|HWpF&w(V8_>`ac8J{CbyH7;(rPs z>J&Lz)Y}~EKYr<}WMZb(|9^HPCbUY%AN&AlN2?e1#jnT6WD}8db*FFJ-SQ{6kP*nt zzj?i2cFJlZKTB8-jGv|PGew#Kmp?QTN1J&iYyBGsemVeX|Iz(e=r~@hSRML&-il${ z9+J#;dz_H&!?z4nTAO`^(RNQm2o2NFn9CJW-MB~mQX$O4gilb%bxw-rLgDWTAG$A~ z_>uUg zvDZo5fN&)w<|Sn-<_JlAJ7o~L3FRzZA1oMw=k-OEIG84DwywbxGa8Kl2nGZ10MM30 zh6nG`Qx~`qaTI4`2xaUAN7<~C!Jzsl`Fk^F?fq@$C_fWh%}d~yU`4Fg6*}i`hklJ% zOTmgUarzM`ntg^aLlbtv>qaQ2b+iK_00;*%sQfpsjEaNcP|rNErqgb#h^3l__~eb< zEp|5w2g-}LuWt`}2aZ(^2_5N-n0uJ*9$fb&4!xRNrW6m}kVc^Joq*ip-N%TctgxKi zo=#Kh!``;8Dy8CbWrKf0u|x<_C!T3=J=fy!Ep8tiGLkD>;(k|B5K$lV6`reB#@Nay|cm9h@E=H=3hgj<@+C0Oa_A0=y>C}7dQAF{zZW@VDj$79O|rj1my$_#h+j?-}2 zAX&cjeKI*x0aGITukYUpIr;G z!g1ZXkz>Z-^~lr=(%60NNd#iLZ)@Yd_QNC!y=x~>RvKRfzKr#3{C{&rKcq$)puZt6$Fyv+8b zpBNmvFZHO(J#c*qS4y+vsjInH3~%3+W(Nu<6C<374BKx@a%EWD&$G`k>#t)A~2J6VZTEdxa>LU{YAkz2zDSQV82Imnhu z&@*Z}`07uMrl2Md;~8`p$?&piSi>~eeid>z-{sfh=136-U3{`4h4}d|&`xu<&L;|x z+bycx6_h>~>)^e~eaGP_xJR5JOc3mjx8=Hl8g|=ATJdhA^>vxt+@|mS-<2xR?~i`4 zdT?{!Z}f~0-A4#-kYwb~IPcs--#lP3{92jhw#_adS)uKvklvUM)VO0q*4Wd%&hVV{ zC)~q}ky$!M$2)a`v#q#$;vd@ve6RM!MZM!osIu$8cxZ+9)Aiy*{{x}d<-lA0bC36& zhI}{6ffwQ}S05$)o!7_pY9>D1T&&*FT*+BmcUq1uV?#A5*ro+4G)81r8Y*9UzRoBV z6{83nL2`NGde>)@ckDO7hF>FoW@0h`HA#-A(O*&gXWQDdg9caCn0LT#!6A7KLd>Bo zV-lC!C!5U38sy1YYtLp+5^~0o$8$2hkW1MFHGToi%=f`u{!Lfezn4MgIed?~fGH)? zf%Q4?0{?$A1#6Hon{>$LG3Y$?WkD@1??RK4^}MvxuRr&|c{a=N&L#dOts_=3os{{Aqb>u~fg~NPq z=)YcU#XvZ$TkQJ5un?Yh8l}^)9;I!QX;fR!im!7QFXAM3o=>7+K>@%%qlNv#OtFjGs4@NoZgI`{2B|5`@rBA|LIG|Hp|3R!9_8M|Px zy?VK}GU@jDo_c;AIb_lh6!%QiDW#pr7q=cOvrI(ISK~ncZqUW$#`04IcKo8-_mQU_ zD{u>FUEG2aM~Df_mz{gs-<#Eyn3tMcAQIM-<*H-;r~_sREaJdI&Wqrn-$Tf|uEGCq zL@V&~mlum|3qI%?(135{3&ryZB#{5MOO(*gkZ=DN&R$6n0r2)gft$hq$@u-}!h!pi&mTnJuKeE8CV7cd)=@rc%mbfvZzAufggrZpcc(D%Q> zZz&HY8aEb;ZQ>sY7%&+|g@)|4-?d&g?BDAjyFHY0tGF!eDMcN9J6oY8I>vJ(Y9t-` zi{`o$-x-9&{H?!H*co&v-`YCH40hE`wlLVFR{~Y4GLRn>qARlktL7+tU8E=S9JvY>6b2^{NfrUtXE$M-Z zz>gy@82Ei-uA-9;l0Qh|J;F@?srs7lvd?X)nh~oU7!asOGFLw9I*7XU-??P9#Rt!R zjudy<1!1nPP&I;R(-eXHRbbU|X_*$`@c&c+2suK}oK20krH$bZ=d0&jSaz(?-IRLV zrTpDf5fs?MzC@~4&CEA#f%#-RfofMU6MWWU%y#(4W64z9BhaQZ>SsZ0-SL*7AB7NU zc`$R9UWUy1|`^3*6N6w1kbVZvdZN< zDnc(5ky|>w{x-rPv?EAENURNMBj4j+9H1#29zt{{Un#|fyL3SKmm^xq#J_!-24qlM zg^*#G?Bu&%%k5&txY;O1t~d%vJo!<`Kj@hu<@W}1opXTM#&Y3Lb6Zod-*PX8YPL(A zp>4Ta#G_px-?1+A#(-YSI})tzPc9BN$K26U`Cdx$RxN^0*;bqn?=UoJj|o)S?Rl=y zK1hsJ@`8_`CiqkY=M4=iPpPi-{!Lp)W&+a!<6+8?e@<;>uHB4*p2yR!N9=ctD)~OS z=?5?Kg~0YZ-Vo8EHf;;+Z?o-Dw72h8c9Hrc5RVAZN&kv&Bi^xVG*~9Ss{`16hbosO zR-wHn!#jCZ+YuZzIFDf0?m)pM%ik~0hqRo$lVMvtH(_cp6pDmh0x|5nY{Qq+Ha+v1i5XPypcBWHV$e~WzONG z)BpHuHK$xDPy5d}JL|7tVHI1~3#?fRQ|8uVp5e8A;!eW~2a^p}DVHT8Uz-WswEjlV zH7P>dU2483peA_{-8T*0uy$X}>0k*AvSR1#i#dp|o*uG8j8d6jF?g6X&iO@F8nF8P*{H69q@W=-lVd zS+ACIzE~n(57=yKYQKAR$AhKc6~%|UF!+3bdq4AFoKjOVBdi9dLmu+uf6lX5pzH5| z2oa`OzotxI`K;{mL21U5KGl4ioF(sz(Le7|V7-yadI|UNpCANsSOX237U!oM-YmFR z2%|=pOY$Ds!9!La7g2-V_mg2Or_AZ#GT;GQc3V=Flz*sAldlD)X~Y0MXBA^J_P}c zA<8dMJbns}{OOn;^0^tgY(#z%ZoU}8*bL046xtsWMV+K2{eI%bcLElv7$u1dxc{xB z&nG%{Qw|1onL169QRrL9FmEis!UODET2^Np7Rg-{Og1Np`|4Cb6Cis!og&t0G`i-Y` zaXxBnJr;Osi!g7e&* z$-!xb%F~tzyUWu`DPn0Ns>NzCN)!EoMcwr;YB)1QaVy#sAHqy%HIv>U6*3hlz5(=V zqH_7okyi(z(m2!eO*t1hG5E1PkE(gox}RaYweezP50Bt_#pZkG=eBaubC*Cd!V~lcm@>&z)e_p`TExB@kmR*=c7t4rh)o1ox}kR4&YPoOzfyIz-}SU z^DWY!{!VnZB`g)AYm(5-aJAb|TnUJuUo7#IrOAcae=iL{d!Rbot~s&kC2OT{7<*B3 z8Pe)=WUNV=ld9?*L*^u=Xe!PDf$ge$(Y(If9uD7;Z~2^bP`O7*ob&}aIU(`vMnGsfu5 zn2ccNw&);L26P1d?@U0v*;#;}v|8L9kNWn08S3F$-p4%N(0o5aRxYfS zvFrWwPm{h*HG9!#n0o6r(TNNdF$9{_(v{g2n-Bpw(>>fp<_57cD!N*ujQsTeVtSGt zySmc1#0Q0#IPhWE=WPv4ZPV}(5~SN>K(Ck&pRWCpj(%ZIKOQJsyZbui;DUr&Hs^>B z*C<5JJ01v}cq{T8(n}at@oW9>Y?7ku!l!H1O{ZI>zIz=|Se-t4-_w_If2T&AbQ?^3 z88qe+EO%ADev@9_n)`C*)o*{=hUJR^d_S$QSOQMhSy|3X8ssEeN|7mSGB-Ct(fd}d zCfg@^urkLK|5)%Ku^mM@Qk4RYY(lq&7r&Kg#umoidNb;%+jOT?epD9=%>t0CYpP($?HWF+pdg zA8Efhm=aM$IbTQNOC*H}p(jizD`*`u3}MlvdEOOjk6M{vZ<_t~SR^^m1fuWYL@xGH zds4VOWj%d4R@EQp=0%yg5&<(%>ubMpnDiS4W5E-6EIU*nbu*c~cP#;yGX@*Z^TsQ1p@G`|rheLq#{8WU=qGK_oW0LjyAByNiG8DCMekMGJvnpH}O z^86#pcVPOaWfu*JK!Bv|9If|F6szHnLUXjXHgXBNFVqLewf%_=`y%xB{pR5Q6veG! zFH$Mq4w;#G{cuEUfXrU725>g_N3Mz904FG-taCA7FHX16pQ4liR4mbR?rE^D@%+HB znHMHWjDmMy*}xPc*f#9VgL**+2=v)BsY-!D#nZ%FMc zLAcpvkBCe`vDZJQO~r!730D|zQ#+>0#VUxyB*J9#G8fw^i(Y+6ocs?7PECBMy z(0lIZ<>R)63ib7Gm*m3u$6#!Pjqd({s`}0j;XgROPf8M&@`E%d7G`D27s?G~@7KLQ zq}=%1__^PDc|QG({o=HR*I=tiQSSW_^~egzJVpF2Z%`dme6Fnroql(ImH^Szt2$R8 z9laa1gdKL6yb^9$Z9Y&!vKie}v(Wz8D6)P}d#uPCB$|QQUaLRiKh@&@%nN(6B(HJV zfbcTsd(6votUB|`OvVGEL-c`XKq~QW0Lh7{48WDp7U%odR|I$x{CvSs9Ee-u)^jfo zRAzGBi#4YlS$^1G)R5G_Wey1;6|H8NIZ=fFeY!+BRL(mSsF6RYC(IX-5Rl=CnKT6x zw6Wf@lEP}2EC)oAdpx!{)~;M^?^)X7`h|U|--l``<*nACR*@Q&l8|108jK7hTAU%7 zk5z{E91Dhr*o`E<24l)jw*=+aZZ(XVJi<5mPUm-kqtnh;>90PR^XA1{%k;PFnlGmx zh=jQOv!CeueKJ3!Eo$mm@4q4DIZiHq*@7nADX}M^^?9+i49^d)_yE18>QQrCIHd65D3jzR#fuY{AZ1fh{b^45SGk_SH3NlEn~D7#W{ zR>bY>>FaQP6ATH=QQ3dV6hjbS*7@3y7&-H3!lnN}HPCG5#rQ@cdWh(9mFn(nor7i| z%#g`0E6Ai41~uQyOxn)t@xAv-hcm})dAb&XBJ%dUGr^o}6Ya=id5W>917Jg-wq;v$ z$>IkFjpHN}bsR!1We_(A83rQ_UtAINB$J!3kbhvd#R7C5KPCxC14lZly?1Gw-^w4- zPJx?Yr&5Fjg@f^d!gb@1KJ1QuML>WD0T6DvwiEHgYd6uBU;D@JSBqlh_81yJJLT$_ zcA%S}G*(f5Q9qv)J=(>hEM6rPj0)!kKy9aGLY`Si2PF{Qp*3O{g?()P<>v6x>w%cy zSOUgjzBJvb==#7>BxK3CD8T1%+M3y*RN&P1DL$uAHs6V`>74HPy367p)z2W^b_vrz z+f@% z&o6+AC!C9@t(EtDrH~JZw;A_z!^BCw184mtcj;nA7_t>SF5RX1E z(hX)Ae9l~pI(7xMx2!Nyp~aHj6lYw7>dVk2H?WQ#pjsuosBprDeL#mtaT?bhBmx!w zn%7+MJp)F{_(I6y{K71Lvy8m9@4jJeRx3!>cf9?SP&3=N83cKmQffxj)sfmuXGnNM z>z?(px(Bl@4!ug@lT397EK-ke zO;6u0ZPYG16u`OA$^PJPhk-8X?cx@ju58^65%px_H-gBGwKvKxPpz~X81m`{&AC~K z2`>%2F!G#iqmmj!Z&w-1tk8%82NRO@4oma7z)(Fi$k-I-&8ZpIvC zrhR{3&I=$Gc@1Q)dij-LqSJpwV4O3=Kph5-g2HgP%M3IXDXWR3Vm)c^RUF47w)$~h zSZ~oYf^?nu_lcFdDhGxYD|kbKhH($61m^-vGKpbTS=!1qvjg8_8ix=~KEIEYd05Xg z#qJ(F`l{i*tz5U7{hs}uoY0WMIzAeG66K{v)5i8d{NV4om8A7#xlBijj>VpSO zw+0`*qTEx=V>hBdVV~gS&>IMHaN)I8?*g?#8~i}fndWD77EkPk^Y7g5OI9jwu-AB& zfHalscZdSpdZ<5++-|1A9G%Q6=tcbr4&pF;Iwfzy_~!vlR)|fwsG?8cSSz~1`1kkz zJEgWsc4?G7UIjt)SU}zW&gB&;PYPG#b+c6oeq<{e0b_)mkQuzJ{*jyM2)c{;=>Tk5 z?Ub=HBHN64WG&^~;NT{zyPxN7mqK5FcIGv`_0rf?`}e$F=a?bOav$@8?211`JQ4R? z-{xg~P^F&hknnmy&rVu){S=YU^xk#nQ*dEcD>2h@Y~BGjTWd?r=g64VT!e;(#`LFz5ie%I{+aYoKtj#$IE#k62AnLjh+l7efFzY@7EFT z5zDokCA!DT7B2hF!)<9{<~L#e4%;Yzeq z)<+T%2kgd3)%aPDdC=2PL2Os9hEVWb!S~UG6D;Lxl4A&o@nQNoRZ3~itIe$TbhC2o znG7n&Z>wJ$3h~QapHE8@v=dG+2~+*bpAUGm#BTNZL8Cxw->1y|UGt{59>sH*Zg|Yf4KmJ< zZQjZ$&K6@CBjg7c{@nSsVhwCC4ar{>jxc_`x@DluyyIl%NO@zBiZRC*4>zNpr6&p` zl%ZQ^qF>o%=>VXDg`)Slzz90VY1v%@d+Zr&At$(4A!+&n*zu@k2AVrv=C||d9Ma;N zQ}8b0An;_aUw*V(z?jAe2(=OD5i>=&3)&LGb0sW1@O(h&;sVE9jjDP(0VJXnRn7ov z+ITOGarPGutlTO=H-V$~Q=oR8+cW5mc~txi(0LZ(Mb!@eCHc+b4FHRGyrzB z6*uZr;B>dMW~Wr<^(!QRJR|U-vzQMTL>D>Vw}_;o0@Te7>`xwZID-^2vC4N9qitYS zk#&+lmxiGB?1bl!)PA8(0Kpf}31>+!HyMb9%gZG|_F0G8N6L6b#$Zw!0nbpg5=HEt9vr9e)&>#Mz#4! zxFy#uRe|j5hl#u?Q3rxpXEZXXo@-tQFr;%<%1AMzZH4qu%#rX8?;c~Rh0e86fN6-f zVuoi1VQiJhCA*>&9AwvazUK5`vNN_J?A;cd7pEj6PBnpw%45KqtCCACMbBLc2-bc# zob|2HFRk?xFn32Vr&|)sDEQdf#&0IdmxLmaWX$*gohSSUt~J^bi!b{3;LpFE-@1c( zw(<+%f_)!4+*y>N3C7w{j?QRR(dkXccb}cjBwTc3J>*pB((vKv!74JDX z0;qIFABY`)@c#SBzTb#iz*7qhWtTURB z2x$xmWtmVB33Q1}%cLr2;*QViwR|tG1bPPkK-QQMLpv7u1-68OU}aLLFD1+d!KKZH zN+d$-XOE={O~;cCfjq%7P@9`K!Q7%UwZNoKwOcTq*Uc~rkp{J6FodBaZ22ptFqeWk z4(S`qdu+0IRoiG-_VDS)c98O$;wqa@-Ey7wUgY>!V}ie(BCl_G_5fu+F4VLS{Iin0 z=|N239$o1(JTFvuYeZHlI8(u#@N{i*hx$YDZcG2H0HDt z9Y1FD5(%mWn!h_lWeu9nroedBwF@Uf0^21&+9_=-Ga@Z<~Frx*1j!MDe7E%oux^ zwkut?;^lMaX6A?Pd>eSK23~#7PF@Zq%Kp~ubWwaV?k*_j|0=se?lr>!qu=mn?s)eW zjrYM0T>xWa+VRgbUxNOaB6ckpB^%L}f)n5$RCE9OV}Aekp6K~1SbHIM|gsY zK)UOu%wAX8YkH`DD&31eF9)O7rpH=wzg>SiNcFqpAPB0>S$ZzB)y3{G0bO%xm_=3d z5#Ew4U>wMJG0d&E?7zvx4pxe+Q^-BlR2Fxb%O8!kju0Op4lX3|8hA=}>=Nnbxqjy& zVso#zc-eC6KYWopIFHl6wz0)PB3|LImf`L4ouw&K{K#TOi%(ReCZjNEbYj=YPj21V z?`bt^dZa_>RN^o4O{H&4@~GSv%lW0bhhxJ#HHn;;LpdyZ6SBNVY=vN3j% z5SPU1-U}ZpBE6o02NvZCB2CBXkvCqX$2*f3q1cT3#mYG@u~iz~UfayXGohIRFvb@) zSJNkglLBDW9^o4T-=uo-%!A!7v@>5_`ePEny%{X2N)YT0g$I_v7#EU4E4tT_scHh@ zGl>p-Yuqt9NOcm@wfTF^kloTTQ#zVXu|r@Ubv#S_xiL55{!G;=_<^Q+Z(2x~t($M) z*(c@`fdux3=|a+t3OsMCUYT#inHJX>lcnpgu)j7jI`0qQ;P^BlZn%@KmSS zpHgQ&tk*#a%|jCssu^clhP|uJ0OS*8Gnu4zYX#S(nNDI8;#rdSVRb9r#*Tux<9m#W z-iewXGIi5)zZW{_5>IQkmRM0+QrNsQrEzsX?FH{~#X~e|3>Lnm zTZDD@a`HD5d>9B0cVtp6Lupy0jT5~ zwey|o@osC$prgG3HaI@v_}UtDb3o-4{SpAj+BBorSgflPm%yspokYSJN0ENGMbFio zS22`pwyk@3ymaRN`o{m{og2%3?5VYF`^JY*G8NdJjkha!UFWs#vA+^hdOIM!qFyvJ z`0+x>HkYx4OBKB%$Qxk3wqNzGZS{HV@;ee6Wg*N6nNjvsHNq6~q7~oD_&Qgk{S5pA z(kz~nL<{zAF^D{UmZ1i$-lK*v5H zEp^(P6UKd7&WaMl_L2$@m{?I;wL?X4p9h5mu{~e>F$r`Kh z>^ZKoOrS46plC%iPA$)m$0A;^CRvHhO@pkz!&LELHZX7g)g9Nx5@G}#`umfl(F89S=nVxGt(V0ZFBR#D+?`PcN z;ugv{w`L&Lyd7ZR=`|ovcIumfE1&@#>KrCz&YwyI3y z(3speA?B-$B9HAMKeVhQ_KLQUCIG2#su#Ux%I<44RLC{&^c1v8_5sEk{Nez8COpP< ze6l5B`pVDtFplJ71}5MG$i)JK)nYGS(lDx$3BOou>0FkPVKXJ4VqCAA}E zIe_xa?$FwCne)hXgMAj$^we6~A-LP*Sy2RuSByejKFqiyfnX6*n>Lp$VSyRed&$0k z2GDXSPh?Tun-LX#G8uE9t^M*#@JvKM(^+eb_Q&Zs+gIo|-Cfjp&YkJ5Je?92Ps8YN zH@nWWo(Lbe|DuVNk^Ga6IW(y@x!N9cP+^?)H`u!1OJ4P8XJqm>jpxf1Fx*+3rZhRB za(Mv$j3YHco|AvjI|bGWsz#akpm$843tt`cL^#uBE{E$g#Z)!N-^R_TCiJnZvt<&M zf2X>71|j zs;D4d`7b(}zkYO5hGgV3x)P)?+NCzVs*lcbaNh5~EGo|PXss*pirRIj6>Vq;{DF*K z8_Q`g+gwhVt5TXtec7F}CQc{V%+p@$Ib2N?sv(>xtgeys+(Ve(uO;b}Mz(Z}P3<{< z<294jrRiK+p3uvCPAg&24E-)VZ5p?@#)a`SN=oBeJ0ZnNf8mhI^WCoH z=&pU@aji-mOt+C%ZeMFuIRDB|`iwAQa-55~@d@_=n(HB?7kwHbjmufGxMl&$tHL7> z30#JSAiM0oi|RFm#ml6=LW&yTZFZj^*vD`eao}m|yKn#cHqsZ!WQ>7(^Am&Cu7S3| zyJu>AsvjDb!y}j~no!MSQ9QW(e^p=;Szn32;<7a33x}4O2vHHl1fKUDyRMZ}j{Ov$ zhO-9nVl!ZCQkr6TZm!28T`M!&48zBR%uH~4wq*V2u|;IRNItu=)lO-Eos)nAlCtdF znW#HNiPKBwO0=AE^8j%9$t%7~4qJ4u3`H#ib!wQQ(_&qSWG=N!4Bi#1XL{LJ)tDzM z-x1|cE|nnqrjfg6V}lnoy6CCg8q@f)@`e@AZzxUHaB-wI}w1TWfb^ z-9^*=q)n9K(u4-@gQ%2bj_b)ZCp9ntSqP_>Q1A_rD0WS>?9X^(x!sP4S|GDml#4wu zbh<))5%;)S&Hnj4M)@E@cuW-@IqgIZSP<8)T=V^_&s$0Q{fe%FDBb0&;+F8sSz zF2sn^ecs8D#cy38x_uFG#whrd*CEqRnoi=`iBImj6z3)Jmr#peZ#R4!N$dmPA52be z`&WweWP}%usv&(2aYQ#y$e=wf9C+!989x);7ys}&u~BnE(odjd_gqw%=bwLO_O+aTukEGS1Gak*vliX(m}{6sV2CJQerK1QZ%aOCezxLLCH6C3f4MErMn-2#! zEaMKCUUt(4nw#?ZZXb%d*^;J{ezdOnke%Ya{Z%qv_d?l*B=MaDw-}yLue3i1Z?$%P2 z##bVHB%1J)+Xt_)7_#v^dS@p_Jf62p2cd(@-$A#aDO(aNqK@;ODNlm-9v4(B-6@q| zsi5Wr`>VT$p2Vnlq4JS!pTUHsR+S*q9}D$)uRkBjq45HP@E276`^F3;;kngI(JP!a z3o?#hIeYLaB}VFr1Wm$38&6!T@1+{AJYid zpvrYh?-o?KX}+G|7R|)5snh_iERRWMx`YmiCQIgT;1dAGAyDGg$*JvO*q}xje&UoGGW>Pvr7C&23<$g%W3P9j4+WtStrV`1g@TN zUmfrtoD|7Kc7Pq23 zYZbh(A$rvr)ARJ>pxE2p6hA3k-_f4BuMMI~4+Oxhsh+^|_(SVDOpbEmXYqv!*+Dm? zd3AIUH>Ao=RV5J@TJ|Fzl1of^lWmiT+}JmXFpZpe!OX{2 z1Bt*N6(i-JkKu4?VD^dBbR>9=UYAA_3DLZLIXEW zvl+=(24UCU)0ww$XHzq+GeXCi%w)=A$hAZFUoFjAsAcCa$s6}X#Wr57v2k{@HXd$0 zY*XfgW1`un7c!eh98Wnl^?fT!(E&M<#;nSuS4}!6KekOgiSe#7f!8Nze6wh#?p<)3 zcT&LA4t=Qyin5|<-6MYue02Vy~fiyAq<3g()dh7spf{J0h+;?f!;-I za~gg>o4k2cMS8oPSu+fh#FT>Ic!^Y2K=D9550&;xNS?aJvuD+H zuil8f_ko3zOjy$Oep-31yowm0V2w|@)|zFgN1HFp9WUP9JD~_^(dtJP955;8MvSeA z1Jhlyb6oBLq2RMTgPE2VUqDmbnkiIsCWI!kKH(cAj8r46MOPZ>8zAzIXy^}NhD;~C+|T*(B-zFus!PQ zzQp&_7+HtpCxX`+e4R1WY5gi4M2&rE+;>HMliLN5G<3KHNpt}HH4r>iZb&u|Z&zMzFnoN`~#wfsJ_GQ)~|C#d&12HNp>X(=pkqLaN^jAAHn zXo)=CP|YZJxB#!lAN}6#(*M>$_Pzm)>Fb%tNNOcUt9)*SPJ`k4qh7 za16gA`1kJ0YfoS*D~iZhP?)h=&SOWjJMHULHOr^3!~7a^Bi(HYpBujCL%r6{%ukFD z-*WfK(qP`A(_`H%+m1B}z4@N!2w2vFzGm7daP$j{-gTFrC6r^hDcVg#QdPF=@&`H& zPhDNwL}WeeVURuBLq4;AbZB>Fx5*!0v5&%v+{FAyhxaRB(MFpFgxt2pi!p9T+N zOT-_!+@t;dY&XIrGqWK?yd`~%b5b0$K`OBO1@vZUArtT7L}4!juCdhdqnFmJ{1m)Y zLahiFwgt3wzae1;pL~Kb8}}@6IrZnZEkPk54`?f}1+khj0(e zqfyI|WGd+R?!(Y1><6Ex>|LysEjnRRkO+^*l}eJiz&Y+M#ohcPVvMICrZ>)(^U0+= z97uYn+(K(Ln!Dj?wIt6B zjd#?%Ha;VV@S#qd|I={n0?ovxAu+;9n=emPk1ekZl7_*rV->!5emuv^6Efv@`#BB0 zw!#te-Wbz@hkmXb1D}xWqhNfP>0{Y{2YU`Wlakx5X_OERVT^AHTqo6vxYWCHO|WpL z+LZqG!we63^1k&CP}yYGimg-d71^`t8s!KqKlwhYi;P+80KNUpbOds&w#Q%XWG>Wo zYPc8i5M{cCXpm+t2}q3|JQ;cv1!KFcbtbno<4&2`7bxtZFZK?Uc~Z$aA*iI zLmV!GrM#ui6KzNU523Svpw~AVi|<1tHH^T`al6DO*AL&Buhrvx9y}+)Xh2_+YRg4C zq=^8#1?d7Xf!kYdsxlFMpiXw7mDIBsa=I2-qZ)HA@?P3l@G;n3Q{Fp?%61l;} zu%$@j?$876t?KR4HT+&-_22-4T4{)z!b*K*JAcndWEyO;d6J3zJOJ9)QAoBLs1M^O zp*u=a>R%cb7I$wiek5KJ4^1K^=Lonvw6_&?4tXk-&9Ouh?^Uffe*9wqXS!=g9B74( za*0a-@y_5&7SX3bIV%~VueHk|t-&12`d;+ufNVJUn^`>no7((eMYY_pO-j9LhQPnlDt z`vYT&d^2pc@^3-XHou=Q2sy?sUU^?T(Nh(R=-cjUWSKnPqLHa@($g@P-2vgp$Q3;z z^(D@qvas)ewp`&&@i1c?H=g=Iv?Esp$EgLi%;uzeky$`wEtAXS)fr@#>X!c5T<1Zs zoB1LY%URRn4{E&(-tF)m=3=(rjU({4D??Do+n=AO;{eH6L0MgiD{f* zl6873WiYVj==#&o0K*;0`kdF(dq8hJhtA)E@JM6bJYs!MP+F=qj#UBf!o(nX*wHwE3HtVmVi^Qmi;a z_L0iwU0~iV$rft~_E1Z!)@SH)g_e|6AioDh>6bR=I3`&-7P-B4 zu##2@;zBz!$A4NhqxG2E0*fhwPMXN!N@j=rR0NP7X89R2Kf*!|Ka@nqFD`tSk+7yD zc)K(4@>1$uiHGlz;7Gf7H3esBczM6rh+ax|nf2@DuVgKb#$(`qrR)r|i?tnPNA6Hj zrI5okq>n+_syoefq zyh)(qOpuPb8w5WWImDTK0b9K8f2`;um3jg&q|>;;u~1lh-(KL*e6d*o*8gkjtpl3= zzW;GxFlwU_7z{)ZBt*I!DM3I%LYg6+(w!30Al=ePN_UJD7%h`7K^p1iH}&=Y{J#I+ zdrv*?Ip=QYoG0)5k=VqN=WFDwh;i&3fgc}zYtQqDT6D7&veug=^lxz-itT7QghwI+;(Rl1|_5zaa#0Cr@rZZVnRK3C@V`Q_QE@K zDLE*UgE14RNA^X!Y^91{&vFJv#Owkua02zOLuq2%s*tSgnRg-S?C{cD5guDc#Uz|; z$HE(y8*CHMdSU(&j-FnwNtFXfW1h{2HL4eFUP0E}<${E1b=0o43p718AhY=PtXIs6 zx`S4=X0|vkocxOk*-o9mi>qEY&NeXiRZA$&WMXd@rwLYy19GMEobI$7NPi_j=&u?* zsXrchf)UABP%nq{NQg^K9o}bGxK|s2r78&!Sl=cgG=oel*eVh3ZJ>K*gp;nm-gb#Wg}@zi%^xa z*C`ge9@}2x2mwF*?trv&@g=8JlutI4~%OqTkq`5n*s z{hKWRpAGisBsW+?jUh0%tQLkT_r~Jg8vLfDvXPf=JGtZS?>yMuIV_w_D4ywXha=!Z zhp)6b)D;h~AJ;{i^{s9Wv}1GtrHZ8lYWfdHtg=tvk*j)(jHn-) zEL6ijBeMK~r$IIo7%+t(Ds>7frjt&cUeUVic4hS5T+qMe6wmW^(O9MRaYoB1(}@Zz z^uVADpomuiK>8AmJGD=%mVS4bkmi()%n%$}?xh_4F5A{IgzoSSrc`wIrx21P*Xo% zYK0|}48Lx3Hn4oSAm!I~-O{q{lAG2p=U~snNrXc_bdO!EBpp-uk(v0qOEZ?KkzKe|9imZYl1H!6U@E^@{2;Q_c7hE4j96WR!NmNyTp?+%5OIZvM?ahhj6DFF)Bj zD!6V4d9N<=S`qCRK2L?o*Mdo)f+hCB8`(+2OQ$Nm%7y1gim;7~GSc@P;_|Dd5*da9 z@RGxajYu)OnhyX?)7b34@oB-)SH?whR$9| zwTc@Vy}(6~*u^+y_M`8utF^0#CA1}O+Fje#RdK6bnPKkbGC^*vGi1!j9YiM_H)Q?l zAS=aUAe}AZ{qE`enP^io^7Chv-Yy7#;oQS)4UWxFz4*$W0!Tpuvs{I2< z=!+03<~*2Tp@{xKXv7|gJ5AsN1603}Wk~!!jsrnX>hLOVXkSsh9XG{do`1n*8-`%0 zj4ZSRjVpw!c2_Rn$u}lIt>_)KUW^u;`YuJDQBGccEL>zM%Y^9XTS^Ri>#m1qZVvbt zZB!;=v-&ey#rLPgy`1itfx8jozL4>-GIXvu*8n{8bPF%{MNI>C#TpiH7BN%qbFL9+h$I0rhBja9E3hm50u;_S@{?wdU4BF zbsfCrPDt1C&mJL*ag)H;l}!6xIi(40IiOt^U`n*|xKHc*hQ_)vRoMWASIXaG5T-0@ z;obWQhyvSwYM8jf)qNfJql3qm<aTXq26KhDxW92pw2ZtE(Nd{9m87% zdw>LX6C-wxd0w5$Yw>Mdui;vdcjM>0a>f83xM)QWpl2ts|YtwNOSy` z#l8!^O)p|Rml?`hb5S;u|LU;yDf<5CS=UHEK>eeAtu(q^`UB1QJ$YfHRa zZoC*5m55k#9~?dc#yzX!L~rq(7^ZL_%Gwy9p(Yh@VRQ{uAEN0CLZ%nGyEZmi9J*oe zD(n{h3YdD5#j$`1)H?nMD#`;qG|eksNW=K))OlJZQ3j@Oc{?PC&*UFqQ}fe?r@3U9bM9YVd!C!8EoYRykqu&qGDwE3tq>g#z%vmE%gA#el`=!9RAeTf zgQI?u2#4>PC08fD;{a<{)PTC$K4t&mwIq(u=)h!M!pdWd52Eq~KlcbNgIovIaRrDD zriX}lR@jvoxM@vdSO>X71qEjU;*{vO_?As5@wlR&l-S}Knn~_rDjjW}HEjd*MS42i zDu$`A?w{KBmn{T@*8^*8Sy-!Mj@`7*Xw~25-HFUTvJiIAyaYvJ;-CYy%`Yw#Ys)B{dR+^ZtbRf5~(L&{n!+8?3$x87h9pM61hvh6JH z9ux}qLWrC+6pxyE26t+{dTcdXay(vlkXmaLJyCjqWJZWAIhIF|WDv1Og$uA^dQUuBL$ zJj0qzx;QKAk?kc*UJODUBSKP)%c2c*hg&(LG~ao>-wcDcoLP!BVr(N~Qenf)78 zHX|fEOBziAL8C)>gN5ke*61gFf^YM>67ko;eq<8`0mL`=k~n;vW=A^uJhbMGDTE<1 zU72=ajSMMhS<$_bHMcWVy+~lZd_+v_gXrNmc2f*B^^BK9R#B;{;%4p`B>mIzaso}S z>H2@EOA9a$(u{5Fp`l6v)@WQjf%CZK1Q|5uw}!iU{?h|IpzUo|v)>SMTQoUso%ILY z5(MR%c1frXe*>u3aP&jV1`%aISwjMTulbDK!e%bl>VE0?vyrWvGk*q2bIM1wLMp-8 zfwqxc5BK+Bt{04|k0B@8{o+xgZM|D1aLUjEl08F6kp1E!Yo3MsFv}0;3F=w`e|WRR zWii`%!YZMfTZ3*x{w}Uf(AkV{Pgu+vtB)pC!^+`n#Nm_AvAYn?feHVf zj|c_8gl?p%&HY4v3?JurWB=KKbF%sHT@3kd9Gt{Wg<|y%DwBTXWj;Kr8q64z^mFjl zjAUYB>7GLoDQW(vclK9WF2%>;<7<=o*)xHAjweEWA#Dnto1Oh#<_LP~bO8moN20jE zw($jqlhr#O`!IX}&^S#cpS(3+ zuMp!mQ9e4aQ=RGJ4ErI~u6Sh`E84$dUGaHx4m~=6oc_ddXeVC`ivzv?M?y6vtdJmo z-;vI8;$t6jK|T^Tvm#`!yM@eTuGiWAp)yk#qbA)Sm9KyQz}@DdS^FaUnuT|mlgibv zn={6BBOD=Pr~Q@(>tG9tRArfojJNjB+gH?_d_sh=Vn)7yAd-zQE1mCz<`s75YP@+h z1qM5a0n|$*!KQ|DR2DSzE2X3za}odrsJ&Q!A+Z602~CvBqORqns9no7xM&FFnw%Mc3zk3b+5O=%6% zV^wd8`5wx;-QfK>zVI_>Wm|app;_F{U|HPWQ&IsX!}LTg{lf90wZ-DzsmS&nwEoTj zREK=Wor89{%0$Szo?w~KDQ&e4Ijc8jL_(IkYc#AbWEL- zoXL&a+k-&Hv8H}a1A~3)n@033whnFY(K7TXcL-qBj>UABM}Tt^BO^$7C37WWxuP{m z=DS++mr4OQK8@onIg+FRcbb76ZW{eof5_s%O$hGNIKq(U=+*wy6uELU3jl$~2_UYCAg$YWC#$VDrTm|L}8 zn#?@k6pyr%>2m0vVql0iAnVi5tFLs~TV|K*a?3?N*Hkx9gVOj-kBWZbGxC8o7PsK5`WuIqDPixeO|ll374){$iDKBrwHSI6EoS(>0Y5OtD$whYhAjI9?_Y*tzZ7c*TYzN61?wR)$~ES?%+hh|XWTr*N3 z+oDx|)$g+IXxGvyolh4Y0)NGc#d}qK`@X0mZkjVBOl9X$*mSPvOmXO0RDKtC+9z82 zzO#FSqvDR%p5G2&O2(})Sl_DML`;y?)$c2hoN_zaHv@X)r8Xq~HzW zDk(_pRvxz)bha>CioV2S;o*&9RyPcCU8)-E`SBIHR48RZ$5zl1cvDeg44xa^hnA-`0m z!~iejEvOWt+2~ytOBTU#xOC;v&Iz!N?qWeOjE;=zKrvH0?G+*(_r7y5|oH*`yYpo``s z`q!eE)1N5cFDTlYnqg`y+(E{wZm^t9>DR`2M(hU#NZvj@oxB-q;r59EDs)ev7c99u1z!wpck(3rC5}A8@v1XyBw3{wNe0n7dQb zG4FhhD)loGBlNjRe{Ti6Q%YEV#OcYdWi;#to>0v-lbwIYm<~L9bPXfo;s0rQz<9vF z{K!6u@=bH&42D|*p=45%nV<7EsSzm-7YAedQ%DnCAVIAjYF;8AXI54#I^rIABQ|M$ z;S4ea&X~UCa%cv4Cea<~2Gy|iY=2_s`}t&FB{Y`*MEUsPrL)|Anl+ZgA`coRrdQ|V zSl8rV+Vj92$#UT)G2I87bEi3LJ3m4_I}R9PiV7w7V;2X#QGHs!QP@{6s=n)% zcPo~gN)WWYA*Azxb_t|IGYDQ^Lf1R=fDnH~O^n5O3KA}U+L?3kN&$A_iI9bEkyjB1 zLnz`A^mLmujK6eTzxYxY|LQyg^goXHMRSL4nK|pR&WEG)MfWS>F>SipctebJG&Xea zh!gDrz~!e~WjVfKAa0KMWORYbtpSq8#N`lnWPv|9b<23!PQcKG_Bd+oz1TCHZ8ISx zSu_C9R@QZ5{mGH449sOa7j?ozAEn~C;iz&?SGzqGSL#IEzo|Etbh-;0K9Gp@V@XlU zz|r}W1TMv3l8Oi_TQw1=ax$;ura|)qP`D&XGN!_O zXYGfaD|#s@;z#M>moDV%#1@|#o{gN(SoUKgQKRG{V~Wby`%Vnkmq?s5fR;MF{wMqc z!i1vZjhMbzXTJq6pnCWo!#taCu`2Q&VVAGYTf3Ixlfyxbqc7L*@odn7Iy>JHJJ|iI zwN1WQSV%huZ8)#PI&*Hd9ehUv%Y+;BpLHD=V>+WyU4}$?9ZQM5Q1n~QU-+NFEudP`ppqR-=%o*!>kzvrF@ zoqk7C+=!oRd{0q)UhA}!@FW#CD_IW zt>}QK?N=7bBtyIB5&hm5Z#(zdz=HGYoKd!%{~52QsBDP^w!nIy*n+^z*buG31_4wz zGp_+a?&pkjl0v0-#?t4q>lJ}R79<8QNszI}*zd;|b32PmWM>}^;E!`^rieZzXZE{+ z_f0SGkkPHCV7zAHqY0R@;dE2q)sB(mr-tI92&skM+ArpBU5>T1p&Oy>M^xM*@}A$v z2|AW?^tHN$bKt{|yy85Bc|RKhwGdD)PMhaY#nf4snSR6=;Y1jL{#>jJ?d%d=V1Tk= z0$^)wZ5hebOnB*x@C85k(6o-P=Yc1USDLgzaMbb;&oUYqxf=~&*s_Af|7;dnD{)}f z15WQuweI^&_Nw$DUEAcKK&}?)BvQPuqmQ9_j&5g|J@st1o~NhW#Y21aL;H!l zd_NWTH+~v{t~85vbZ^svK{HZ$o65UL!I;qx};}aQ=FaAP8u3{z^n~j{_Nv?Jh02`KGk?bp!uP!MfPLylcD$1d^t5EHMfc1-j9o8^at*|tH2tp z6YcGP)FAmFFYN@rrV5B-Z_$AU``Bwprq%MDsE7W>xB(@FiuS|UzIoAC77h3|uc zIse;S39<=MuwafMHnY^_^7)4Y1WUF$ErybGo-DRIm3!?p&TW&^Bv-SA05)LTEUasc zuoI2Nx`US+TjslZLL$qWl|>IjdWyI(lW@kU)OYb$&t)%}v|L_r?ODBf3+>}M#2?sM z5B%J`SmGWyT6_Cde<`Hb*nlXgM1SQx2Rzm8warA>^`lB;s+Jx*)`&a*P4ne`&}pv8 zdgrM$qzFC6_zpely@Jk$Y+5VCD|0Nhio+W%?Q#0+@i#_lafN${N54dOM`f$9Yr6%h zYUk0!^6p>kmAj0rZO6#G4C=lm5{i9JD3b)1EwBIHY@V5g&?8vOjcbvNSyv5B&e2SN z>oLlA{zy<>0`vBvDwULR*6RW)>&@K{oMaoazsW42NId=kVzu-22~1|G?~3N8Tr_x= zQNa3wS&@fdR_qEK9mjVBMa6`1(yEn;(wchErX{yLE}rF&hp!z%8m})YcJal{Z4#Z; zeiO&Oo5|;>2%PRZ`uedY{-BFj0d_bU8R0R1TY|kq3-UPmU}E+0Gy{9YeTp;>mBQBF zn+bv-eDY$0Z5WFoDQ7~@Xwha&_08qdq?`FTBS%qbk&Hu?C{+>V@RM!F5M0IkihrIq_*vZe!6I)WNnfaw=+4TZXaA`A0 z?wdKwjZX1Y){B{`I43)|fosfwN7wbc%IBg4U-FS-*1`!dbH+)7Sn*17(V6d288O6` zQD#%F&3Qk|tkX~mw!=}O-*efDeuHBdP$ZRCCgq&GR-`h2CIKW}rdW2o#*6)l#q(9* zxn|K+1pP*JRKWGxp`|v)QPN`;RHp!@v*785@~+Qj%4lPyzfVqLK$6JnLAQolWwp;> zyn%cPM@G#IJlRN)cgRizu_>)!RC4>i4T`pBN@}5U9Raw44qTap%6T|nySZgqtUNk7 zvKS+pnR{o(MWS=e1l+)wy?kZS>ttREPWq|PBxGSRzv2zxjl5fY&==TzzMjAEP6kr! z#8-jUj+oEvH zzV-8t_mXW3V}tCHK4=b46Hj^ZBM+?36z4dJX=*;?#43O(rEaNdE{?*9ju*Nvxod|$ z=dv8PHd2ZM&SjFSqf)WyEnOZ}!krx!n;fXC0r^PjZ3`osb3gQ$0Ffuq5`w9s3>Ht|NN*?>O#=2?LFPfpaCnZoZN0l*JH!TUwurcjj2+`vQZbMS+H9KzI(I#O zk}dpg@nOZth>@2zU5K>b;j3uGOD|iaM5JvyVlj+rz8HHvw*@iP`@E5yra!cEXOC%U zJg3h1u{MyVe{Pw{qW^57>@3MN&^yk|mpsJOV*l|v-_-;f*@Q2|!3NxV78sXfY}2=| zB(r82Ac7sWOYT5Ck8LmgXWUcfjdW~A>BSF~&pb0fn4|TnH)tl&DIae4EL5Mlay3E# zU!47#eO){w0$}+yZh&`7F2Vb*=G~-+g38->cO=<9QgqIFv6SG(u+d;sDaL+5u56Vm zn6b{2{5HOvTtR}!RX)tZaBEV8Dsju-d5Rf?#7&Q`85YgfHL`+#lbwN%_E$r~|8)vw>%GE;fX%@CsY zN2YG(n;8opX50s@OXt2z^tdtSX-`N*=y3c^@1!5*9vcUI^Okq#C@91M~IzpiW!)Q(+w#{7wJ=8*60%jkDmi(`@kAho!f>i#)+xiMpGW4{;Fet1s_Acpyu+dhc<8`>Y| z7;moK?L*WTTy>+HMS1RyJ&oqp`gXoJsN_wrMQ zZd;~7tWN+TxJ+MwH|H;mA;n{8GCO+tAA;LC#`1OEz~+(b_pcE{Dq#}%yzbnrMt?Z{ zbD&xrdh@(0?unH*w+(Kl!Y@X*(vy|L51h}GzstlMQvY3pI#T(a|GsOIRQ&KLhzQ1EfNi+qy2b{`YZRn0v>B=d zPsiAq5IKFj2Jg;2+;i{}q`Bz)%LkusI0A2Ki;gX&oD^aZ8gHIS8OP%7q zpJ5GN|ES_CBb>v?JpIEQI+(`1v&T0h7I>?zvBu~~a%v4oyqJ)L&8>FQ2w4w#ow{_2 z3d8paLt8N5`@8h^e=X993G_S#`vm&Uq%(6#J}PR8`k1j%|0CcDs@u>UfRtUEd}=6db_jR z;A#A7!DyiR2bgaE@V4MGj)lbM`k>01p54GIZao?VfyVCb19lxR`mvwByquwTI}V0O zin1|=zo;Gih)(Lo_FdRdId0g}CY?@U^-H&G0P3NV!aUk>DbaN!xUe^zS#!Iy=-`K> zxudj*=lP4{oRhcXzH~1IA-=q4PHZLdQJtA!!M$H$veVr5W_69ia=xx)-)c z(tnsh2Wwb#_88<2KTz#`&&%(ZOVYup2SvhsG#~yrS0W3~Fm{d?lG*hm@WWwz&w&A_ z5tcdprwQi)lwdL@MS`|mQ@&RF{b@(j0o&eEIg@RupQl_|j~>O{Gb|BeZw&cSD6C@# zzVZ0uCj5ch+(ssqLnnUs1k*w?drt6DhnGghnIGF`f`s0e+L8##?8pPih2T3HKZg?t zu}OrcTmFGipA)rD{tEY!r;=a@WAG+3V7pZ-eYvhjHap|XvX#gaJa-@bYKi2Xu&qq-);mIZ;T#xi3t1`Ree!6v2x=FY~c1p zQreJ$gTRIPdRM24{oS3%Pv7OWxnO3~Z!dt% zb&WK0$eGjI{}ysK0#lUCp;!6=KaEko*JiSre#~3m?f;Djjr*68lBdJHFSRKQ-n}*- z$i&MGZWo@a7Ul5k`>PssFenTCd%@)Iy8=mO&qUlzvleE6%>Dsb^VdJvpjHXL^UpmW z>Q=?jt<+4MN=+_Wu~W~T_bh9e;`MR zq(WsRej9ms=^&`_ra&UushV_t#Mm*XW$`~QEOLT?23bzeKn=k~(&UPnBk!~$RABSu z0V_WLBN0GAoujyaa|k~i9kYA=EM%c!LvJVW`2Xi~o3qo-E;-Z?D=Diked>qN#<+vJ z5vKqDa{>gEk<#Jl;?7yyBA&@45^{KetMy-w@P`kz1oVxTO58Wj?KL#fcIT=eX8vc~ zoB#+ocB&FT29qOncKc9d#8JNcs)`-C_Yc5-!m0{@@pK0;!(-1^;zVOT(R4JM=I{cQ z8T}Vff1n*NYHZ8oPUj;utI8bj-)ocEL`VGZe6@xEt#v}~qIQwm_^Ak1pW|O1t=dY@ z|GEg2_UtH)j#Js-2QqBBJ+BMsKzblE_`jU| z$;$rHUf}Hn@(P4%)`$NL>TKw4>S7fm0sTo;X}+UMUg$1Z$@~!xks|A4}~#V?8|xEQ4>F^TS{K7(|JX692R1NkIS; z(^;G-sa~~hb64xtg0YOdNi(*G#6O}ar^n^sc{kkG`DUgt&78Spi2_MmA5QoFsOo=g z-BUO66RxaC%FI6>%%nemYAow8dj5X`wORS2zMw~nd~tRGwz{}XJzR5m#aSZ%C#gnB zHNx3RVEYop>XOtd21VeN*-AXHh!-K+$1wzXVd(b%i^n+ua+DW@XHSokD38)-QQu5N OQ_TESTS`` variable. + + The options are: + + ``target`` + Specifies the Catch executable, which must be a known CMake executable + target. CMake will substitute the location of the built executable when + running the test. + + ``TEST_SPEC arg1...`` + Specifies test cases, wildcarded test cases, tags and tag expressions to + pass to the Catch executable with the ``--list-test-names-only`` argument. + + ``EXTRA_ARGS arg1...`` + Any extra arguments to pass on the command line to each test case. + + ``WORKING_DIRECTORY dir`` + Specifies the directory in which to run the discovered test cases. If this + option is not provided, the current binary directory is used. + + ``TEST_PREFIX prefix`` + Specifies a ``prefix`` to be prepended to the name of each discovered test + case. This can be useful when the same test executable is being used in + multiple calls to ``catch_discover_tests()`` but with different + ``TEST_SPEC`` or ``EXTRA_ARGS``. + + ``TEST_SUFFIX suffix`` + Similar to ``TEST_PREFIX`` except the ``suffix`` is appended to the name of + every discovered test case. Both ``TEST_PREFIX`` and ``TEST_SUFFIX`` may + be specified. + + ``PROPERTIES name1 value1...`` + Specifies additional properties to be set on all tests discovered by this + invocation of ``catch_discover_tests``. + + ``TEST_LIST var`` + Make the list of tests available in the variable ``var``, rather than the + default ``_TESTS``. This can be useful when the same test + executable is being used in multiple calls to ``catch_discover_tests()``. + Note that this variable is only available in CTest. + +#]=======================================================================] + +#------------------------------------------------------------------------------ +function(catch_discover_tests TARGET) + cmake_parse_arguments( + "" + "" + "TEST_PREFIX;TEST_SUFFIX;WORKING_DIRECTORY;TEST_LIST" + "TEST_SPEC;EXTRA_ARGS;PROPERTIES" + ${ARGN} + ) + + if(NOT _WORKING_DIRECTORY) + set(_WORKING_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}") + endif() + if(NOT _TEST_LIST) + set(_TEST_LIST ${TARGET}_TESTS) + endif() + + ## Generate a unique name based on the extra arguments + string(SHA1 args_hash "${_TEST_SPEC} ${_EXTRA_ARGS}") + string(SUBSTRING ${args_hash} 0 7 args_hash) + + # Define rule to generate test list for aforementioned test executable + set(ctest_include_file "${CMAKE_CURRENT_BINARY_DIR}/${TARGET}_include-${args_hash}.cmake") + set(ctest_tests_file "${CMAKE_CURRENT_BINARY_DIR}/${TARGET}_tests-${args_hash}.cmake") + get_property(crosscompiling_emulator + TARGET ${TARGET} + PROPERTY CROSSCOMPILING_EMULATOR + ) + add_custom_command( + TARGET ${TARGET} POST_BUILD + BYPRODUCTS "${ctest_tests_file}" + COMMAND "${CMAKE_COMMAND}" + -D "TEST_TARGET=${TARGET}" + -D "TEST_EXECUTABLE=$" + -D "TEST_EXECUTOR=${crosscompiling_emulator}" + -D "TEST_WORKING_DIR=${_WORKING_DIRECTORY}" + -D "TEST_SPEC=${_TEST_SPEC}" + -D "TEST_EXTRA_ARGS=${_EXTRA_ARGS}" + -D "TEST_PROPERTIES=${_PROPERTIES}" + -D "TEST_PREFIX=${_TEST_PREFIX}" + -D "TEST_SUFFIX=${_TEST_SUFFIX}" + -D "TEST_LIST=${_TEST_LIST}" + -D "CTEST_FILE=${ctest_tests_file}" + -P "${_CATCH_DISCOVER_TESTS_SCRIPT}" + VERBATIM + ) + + file(WRITE "${ctest_include_file}" + "if(EXISTS \"${ctest_tests_file}\")\n" + " include(\"${ctest_tests_file}\")\n" + "else()\n" + " add_test(${TARGET}_NOT_BUILT-${args_hash} ${TARGET}_NOT_BUILT-${args_hash})\n" + "endif()\n" + ) + + if(NOT ${CMAKE_VERSION} VERSION_LESS "3.10.0") + # Add discovered tests to directory TEST_INCLUDE_FILES + set_property(DIRECTORY + APPEND PROPERTY TEST_INCLUDE_FILES "${ctest_include_file}" + ) + else() + # Add discovered tests as directory TEST_INCLUDE_FILE if possible + get_property(test_include_file_set DIRECTORY PROPERTY TEST_INCLUDE_FILE SET) + if (NOT ${test_include_file_set}) + set_property(DIRECTORY + PROPERTY TEST_INCLUDE_FILE "${ctest_include_file}" + ) + else() + message(FATAL_ERROR + "Cannot set more than one TEST_INCLUDE_FILE" + ) + endif() + endif() + +endfunction() + +############################################################################### + +set(_CATCH_DISCOVER_TESTS_SCRIPT + ${CMAKE_CURRENT_LIST_DIR}/CatchAddTests.cmake +) diff --git a/src/third_party/cppcodec/test/catch/contrib/CatchAddTests.cmake b/src/third_party/cppcodec/test/catch/contrib/CatchAddTests.cmake new file mode 100644 index 0000000000..0785613066 --- /dev/null +++ b/src/third_party/cppcodec/test/catch/contrib/CatchAddTests.cmake @@ -0,0 +1,76 @@ +# Distributed under the OSI-approved BSD 3-Clause License. See accompanying +# file Copyright.txt or https://cmake.org/licensing for details. + +set(prefix "${TEST_PREFIX}") +set(suffix "${TEST_SUFFIX}") +set(spec ${TEST_SPEC}) +set(extra_args ${TEST_EXTRA_ARGS}) +set(properties ${TEST_PROPERTIES}) +set(script) +set(suite) +set(tests) + +function(add_command NAME) + set(_args "") + foreach(_arg ${ARGN}) + if(_arg MATCHES "[^-./:a-zA-Z0-9_]") + set(_args "${_args} [==[${_arg}]==]") # form a bracket_argument + else() + set(_args "${_args} ${_arg}") + endif() + endforeach() + set(script "${script}${NAME}(${_args})\n" PARENT_SCOPE) +endfunction() + +# Run test executable to get list of available tests +if(NOT EXISTS "${TEST_EXECUTABLE}") + message(FATAL_ERROR + "Specified test executable '${TEST_EXECUTABLE}' does not exist" + ) +endif() +execute_process( + COMMAND ${TEST_EXECUTOR} "${TEST_EXECUTABLE}" ${spec} --list-test-names-only + OUTPUT_VARIABLE output + RESULT_VARIABLE result +) +# Catch --list-test-names-only reports the number of tests, so 0 is... surprising +if(${result} EQUAL 0) + message(WARNING + "Test executable '${TEST_EXECUTABLE}' contains no tests!\n" + ) +elseif(${result} LESS 0) + message(FATAL_ERROR + "Error running test executable '${TEST_EXECUTABLE}':\n" + " Result: ${result}\n" + " Output: ${output}\n" + ) +endif() + +string(REPLACE "\n" ";" output "${output}") + +# Parse output +foreach(line ${output}) + set(test ${line}) + # ...and add to script + add_command(add_test + "${prefix}${test}${suffix}" + ${TEST_EXECUTOR} + "${TEST_EXECUTABLE}" + "${test}" + ${extra_args} + ) + add_command(set_tests_properties + "${prefix}${test}${suffix}" + PROPERTIES + WORKING_DIRECTORY "${TEST_WORKING_DIR}" + ${properties} + ) + list(APPEND tests "${prefix}${test}${suffix}") +endforeach() + +# Create a list of all discovered tests, which users may use to e.g. set +# properties on the tests +add_command(set ${TEST_LIST} ${tests}) + +# Write CTest script +file(WRITE "${CTEST_FILE}" "${script}") diff --git a/src/third_party/cppcodec/test/catch/contrib/ParseAndAddCatchTests.cmake b/src/third_party/cppcodec/test/catch/contrib/ParseAndAddCatchTests.cmake new file mode 100644 index 0000000000..85c06a0dd9 --- /dev/null +++ b/src/third_party/cppcodec/test/catch/contrib/ParseAndAddCatchTests.cmake @@ -0,0 +1,188 @@ +#==================================================================================================# +# supported macros # +# - TEST_CASE, # +# - SCENARIO, # +# - TEST_CASE_METHOD, # +# - CATCH_TEST_CASE, # +# - CATCH_SCENARIO, # +# - CATCH_TEST_CASE_METHOD. # +# # +# Usage # +# 1. make sure this module is in the path or add this otherwise: # +# set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_SOURCE_DIR}/cmake.modules/") # +# 2. make sure that you've enabled testing option for the project by the call: # +# enable_testing() # +# 3. add the lines to the script for testing target (sample CMakeLists.txt): # +# project(testing_target) # +# set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_SOURCE_DIR}/cmake.modules/") # +# enable_testing() # +# # +# find_path(CATCH_INCLUDE_DIR "catch.hpp") # +# include_directories(${INCLUDE_DIRECTORIES} ${CATCH_INCLUDE_DIR}) # +# # +# file(GLOB SOURCE_FILES "*.cpp") # +# add_executable(${PROJECT_NAME} ${SOURCE_FILES}) # +# # +# include(ParseAndAddCatchTests) # +# ParseAndAddCatchTests(${PROJECT_NAME}) # +# # +# The following variables affect the behavior of the script: # +# # +# PARSE_CATCH_TESTS_VERBOSE (Default OFF) # +# -- enables debug messages # +# PARSE_CATCH_TESTS_NO_HIDDEN_TESTS (Default OFF) # +# -- excludes tests marked with [!hide], [.] or [.foo] tags # +# PARSE_CATCH_TESTS_ADD_FIXTURE_IN_TEST_NAME (Default ON) # +# -- adds fixture class name to the test name # +# PARSE_CATCH_TESTS_ADD_TARGET_IN_TEST_NAME (Default ON) # +# -- adds cmake target name to the test name # +# PARSE_CATCH_TESTS_ADD_TO_CONFIGURE_DEPENDS (Default OFF) # +# -- causes CMake to rerun when file with tests changes so that new tests will be discovered # +# # +#==================================================================================================# + +cmake_minimum_required(VERSION 2.8.8) + +option(PARSE_CATCH_TESTS_VERBOSE "Print Catch to CTest parser debug messages" OFF) +option(PARSE_CATCH_TESTS_NO_HIDDEN_TESTS "Exclude tests with [!hide], [.] or [.foo] tags" OFF) +option(PARSE_CATCH_TESTS_ADD_FIXTURE_IN_TEST_NAME "Add fixture class name to the test name" ON) +option(PARSE_CATCH_TESTS_ADD_TARGET_IN_TEST_NAME "Add target name to the test name" ON) +option(PARSE_CATCH_TESTS_ADD_TO_CONFIGURE_DEPENDS "Add test file to CMAKE_CONFIGURE_DEPENDS property" OFF) + +function(PrintDebugMessage) + if(PARSE_CATCH_TESTS_VERBOSE) + message(STATUS "ParseAndAddCatchTests: ${ARGV}") + endif() +endfunction() + +# This removes the contents between +# - block comments (i.e. /* ... */) +# - full line comments (i.e. // ... ) +# contents have been read into '${CppCode}'. +# !keep partial line comments +function(RemoveComments CppCode) + string(ASCII 2 CMakeBeginBlockComment) + string(ASCII 3 CMakeEndBlockComment) + string(REGEX REPLACE "/\\*" "${CMakeBeginBlockComment}" ${CppCode} "${${CppCode}}") + string(REGEX REPLACE "\\*/" "${CMakeEndBlockComment}" ${CppCode} "${${CppCode}}") + string(REGEX REPLACE "${CMakeBeginBlockComment}[^${CMakeEndBlockComment}]*${CMakeEndBlockComment}" "" ${CppCode} "${${CppCode}}") + string(REGEX REPLACE "\n[ \t]*//+[^\n]+" "\n" ${CppCode} "${${CppCode}}") + + set(${CppCode} "${${CppCode}}" PARENT_SCOPE) +endfunction() + +# Worker function +function(ParseFile SourceFile TestTarget) + # According to CMake docs EXISTS behavior is well-defined only for full paths. + get_filename_component(SourceFile ${SourceFile} ABSOLUTE) + if(NOT EXISTS ${SourceFile}) + message(WARNING "Cannot find source file: ${SourceFile}") + return() + endif() + PrintDebugMessage("parsing ${SourceFile}") + file(STRINGS ${SourceFile} Contents NEWLINE_CONSUME) + + # Remove block and fullline comments + RemoveComments(Contents) + + # Find definition of test names + string(REGEX MATCHALL "[ \t]*(CATCH_)?(TEST_CASE_METHOD|SCENARIO|TEST_CASE)[ \t]*\\([^\)]+\\)+[ \t\n]*{+[ \t]*(//[^\n]*[Tt][Ii][Mm][Ee][Oo][Uu][Tt][ \t]*[0-9]+)*" Tests "${Contents}") + + if(PARSE_CATCH_TESTS_ADD_TO_CONFIGURE_DEPENDS AND Tests) + PrintDebugMessage("Adding ${SourceFile} to CMAKE_CONFIGURE_DEPENDS property") + set_property( + DIRECTORY + APPEND + PROPERTY CMAKE_CONFIGURE_DEPENDS ${SourceFile} + ) + endif() + + foreach(TestName ${Tests}) + # Strip newlines + string(REGEX REPLACE "\\\\\n|\n" "" TestName "${TestName}") + + # Get test type and fixture if applicable + string(REGEX MATCH "(CATCH_)?(TEST_CASE_METHOD|SCENARIO|TEST_CASE)[ \t]*\\([^,^\"]*" TestTypeAndFixture "${TestName}") + string(REGEX MATCH "(CATCH_)?(TEST_CASE_METHOD|SCENARIO|TEST_CASE)" TestType "${TestTypeAndFixture}") + string(REPLACE "${TestType}(" "" TestFixture "${TestTypeAndFixture}") + + # Get string parts of test definition + string(REGEX MATCHALL "\"+([^\\^\"]|\\\\\")+\"+" TestStrings "${TestName}") + + # Strip wrapping quotation marks + string(REGEX REPLACE "^\"(.*)\"$" "\\1" TestStrings "${TestStrings}") + string(REPLACE "\";\"" ";" TestStrings "${TestStrings}") + + # Validate that a test name and tags have been provided + list(LENGTH TestStrings TestStringsLength) + if(TestStringsLength GREATER 2 OR TestStringsLength LESS 1) + message(FATAL_ERROR "You must provide a valid test name and tags for all tests in ${SourceFile}") + endif() + + # Assign name and tags + list(GET TestStrings 0 Name) + if("${TestType}" STREQUAL "SCENARIO") + set(Name "Scenario: ${Name}") + endif() + if(PARSE_CATCH_TESTS_ADD_FIXTURE_IN_TEST_NAME AND TestFixture) + set(CTestName "${TestFixture}:${Name}") + else() + set(CTestName "${Name}") + endif() + if(PARSE_CATCH_TESTS_ADD_TARGET_IN_TEST_NAME) + set(CTestName "${TestTarget}:${CTestName}") + endif() + # add target to labels to enable running all tests added from this target + set(Labels ${TestTarget}) + if(TestStringsLength EQUAL 2) + list(GET TestStrings 1 Tags) + string(TOLOWER "${Tags}" Tags) + # remove target from labels if the test is hidden + if("${Tags}" MATCHES ".*\\[!?(hide|\\.)\\].*") + list(REMOVE_ITEM Labels ${TestTarget}) + endif() + string(REPLACE "]" ";" Tags "${Tags}") + string(REPLACE "[" "" Tags "${Tags}") + else() + # unset tags variable from previous loop + unset(Tags) + endif() + + list(APPEND Labels ${Tags}) + + list(FIND Labels "!hide" IndexOfHideLabel) + set(HiddenTagFound OFF) + foreach(label ${Labels}) + string(REGEX MATCH "^!hide|^\\." result ${label}) + if(result) + set(HiddenTagFound ON) + break() + endif(result) + endforeach(label) + if(PARSE_CATCH_TESTS_NO_HIDDEN_TESTS AND ${HiddenTagFound}) + PrintDebugMessage("Skipping test \"${CTestName}\" as it has [!hide], [.] or [.foo] label") + else() + PrintDebugMessage("Adding test \"${CTestName}\"") + if(Labels) + PrintDebugMessage("Setting labels to ${Labels}") + endif() + + # Add the test and set its properties + add_test(NAME "\"${CTestName}\"" COMMAND ${TestTarget} ${Name} ${AdditionalCatchParameters}) + set_tests_properties("\"${CTestName}\"" PROPERTIES FAIL_REGULAR_EXPRESSION "No tests ran" + LABELS "${Labels}") + endif() + + endforeach() +endfunction() + +# entry point +function(ParseAndAddCatchTests TestTarget) + PrintDebugMessage("Started parsing ${TestTarget}") + get_target_property(SourceFiles ${TestTarget} SOURCES) + PrintDebugMessage("Found the following sources: ${SourceFiles}") + foreach(SourceFile ${SourceFiles}) + ParseFile(${SourceFile} ${TestTarget}) + endforeach() + PrintDebugMessage("Finished parsing ${TestTarget}") +endfunction() diff --git a/src/third_party/cppcodec/test/catch/contrib/gdbinit b/src/third_party/cppcodec/test/catch/contrib/gdbinit new file mode 100644 index 0000000000..fb3608aeba --- /dev/null +++ b/src/third_party/cppcodec/test/catch/contrib/gdbinit @@ -0,0 +1,16 @@ +# +# This file provides a way to skip stepping into Catch code when debugging with gdb. +# +# With the gdb "skip" command you can tell gdb to skip files or functions during debugging. +# see https://xaizek.github.io/2016-05-26/skipping-standard-library-in-gdb/ for an example +# +# Basically the following line tells gdb to skip all functions containing the +# regexp "Catch", which matches the complete Catch namespace. +# If you want to skip just some parts of the Catch code you can modify the +# regexp accordingly. +# +# If you want to permanently skip stepping into Catch code copy the following +# line into your ~/.gdbinit file +# + +skip -rfu Catch diff --git a/src/third_party/cppcodec/test/catch/contrib/lldbinit b/src/third_party/cppcodec/test/catch/contrib/lldbinit new file mode 100644 index 0000000000..4f13634d0b --- /dev/null +++ b/src/third_party/cppcodec/test/catch/contrib/lldbinit @@ -0,0 +1,16 @@ +# +# This file provides a way to skip stepping into Catch code when debugging with lldb. +# +# With the setting "target.process.thread.step-avoid-regexp" you can tell lldb +# to skip functions matching the regexp +# +# Basically the following line tells lldb to skip all functions containing the +# regexp "Catch", which matches the complete Catch namespace. +# If you want to skip just some parts of the Catch code you can modify the +# regexp accordingly. +# +# If you want to permanently skip stepping into Catch code copy the following +# line into your ~/.lldbinit file +# + +settings set target.process.thread.step-avoid-regexp Catch \ No newline at end of file diff --git a/src/third_party/cppcodec/test/catch/docs/Readme.md b/src/third_party/cppcodec/test/catch/docs/Readme.md new file mode 100644 index 0000000000..079684036a --- /dev/null +++ b/src/third_party/cppcodec/test/catch/docs/Readme.md @@ -0,0 +1,36 @@ + +# Reference + +To get the most out of Catch2, start with the [tutorial](tutorial.md#top). +Once you're up and running consider the following reference material. + +Writing tests: +* [Assertion macros](assertions.md#top) +* [Matchers](matchers.md#top) +* [Logging macros](logging.md#top) +* [Test cases and sections](test-cases-and-sections.md#top) +* [Test fixtures](test-fixtures.md#top) +* [Reporters](reporters.md#top) +* [Event Listeners](event-listeners.md#top) + +Fine tuning: +* [Supplying your own main()](own-main.md#top) +* [Compile-time configuration](configuration.md#top) +* [String Conversions](tostring.md#top) + +Running: +* [Command line](command-line.md#top) + +Odds and ends: +* [CMake integration](cmake-integration.md#top) +* [CI and other miscellaneous pieces](ci-and-misc.md#top) + +FAQ: +* [Why are my tests slow to compile?](slow-compiles.md#top) +* [Known limitations](limitations.md#top) + +Other: +* [Why Catch?](why-catch.md#top) +* [Open Source Projects using Catch](opensource-users.md#top) +* [Contributing](contributing.md#top) +* [Release Notes](release-notes.md#top) diff --git a/src/third_party/cppcodec/test/catch/docs/assertions.md b/src/third_party/cppcodec/test/catch/docs/assertions.md new file mode 100644 index 0000000000..865fdd6cc3 --- /dev/null +++ b/src/third_party/cppcodec/test/catch/docs/assertions.md @@ -0,0 +1,201 @@ + +# Assertion Macros + +**Contents**
+[Natural Expressions](#natural-expressions)
+[Exceptions](#exceptions)
+[Matcher expressions](#matcher-expressions)
+[Thread Safety](#thread-safety)
+[Expressions with commas](#expressions-with-commas)
+ +Most test frameworks have a large collection of assertion macros to capture all possible conditional forms (```_EQUALS```, ```_NOTEQUALS```, ```_GREATER_THAN``` etc). + +Catch is different. Because it decomposes natural C-style conditional expressions most of these forms are reduced to one or two that you will use all the time. That said there are a rich set of auxiliary macros as well. We'll describe all of these here. + +Most of these macros come in two forms: + +## Natural Expressions + +The ```REQUIRE``` family of macros tests an expression and aborts the test case if it fails. +The ```CHECK``` family are equivalent but execution continues in the same test case even if the assertion fails. This is useful if you have a series of essentially orthogonal assertions and it is useful to see all the results rather than stopping at the first failure. + +* **REQUIRE(** _expression_ **)** and +* **CHECK(** _expression_ **)** + +Evaluates the expression and records the result. If an exception is thrown, it is caught, reported, and counted as a failure. These are the macros you will use most of the time. + +Examples: +``` +CHECK( str == "string value" ); +CHECK( thisReturnsTrue() ); +REQUIRE( i == 42 ); +``` + +* **REQUIRE_FALSE(** _expression_ **)** and +* **CHECK_FALSE(** _expression_ **)** + +Evaluates the expression and records the _logical NOT_ of the result. If an exception is thrown it is caught, reported, and counted as a failure. +(these forms exist as a workaround for the fact that ! prefixed expressions cannot be decomposed). + +Example: +``` +REQUIRE_FALSE( thisReturnsFalse() ); +``` + +Do note that "overly complex" expressions cannot be decomposed and thus will not compile. This is done partly for practical reasons (to keep the underlying expression template machinery to minimum) and partly for philosophical reasons (assertions should be simple and deterministic). + +Examples: +* `CHECK(a == 1 && b == 2);` +This expression is too complex because of the `&&` operator. If you want to check that 2 or more properties hold, you can either put the expression into parenthesis, which stops decomposition from working, or you need to decompose the expression into two assertions: `CHECK( a == 1 ); CHECK( b == 2);` +* `CHECK( a == 2 || b == 1 );` +This expression is too complex because of the `||` operator. If you want to check that one of several properties hold, you can put the expression into parenthesis (unlike with `&&`, expression decomposition into several `CHECK`s is not possible). + + +### Floating point comparisons + +When comparing floating point numbers - especially if at least one of them has been computed - great care must be taken to allow for rounding errors and inexact representations. + +Catch provides a way to perform tolerant comparisons of floating point values through use of a wrapper class called `Approx`. `Approx` can be used on either side of a comparison expression. It overloads the comparisons operators to take a tolerance into account. Here's a simple example: + +```cpp +REQUIRE( performComputation() == Approx( 2.1 ) ); +``` + +Catch also provides a UDL for `Approx`; `_a`. It resides in +the `Catch::literals` namespace and can be used like so: +```cpp +using namespace Catch::literals; +REQUIRE( performComputation() == 2.1_a ); +``` + +`Approx` is constructed with defaults that should cover most simple cases. +For the more complex cases, `Approx` provides 3 customization points: + +* __epsilon__ - epsilon serves to set the percentage by which a result +can differ from `Approx`'s value before it is rejected. +_By default set to `std::numeric_limits::epsilon()*100`._ +* __margin__ - margin serves to set the the absolute value by which +a result can differ from `Approx`'s value before it is rejected. +_By default set to `0.0`._ +* __scale__ - scale is used to change the magnitude of `Approx` for relative check. +_By default set to `0.0`._ + +#### epsilon example +```cpp +Approx target = Approx(100).epsilon(0.01); +100.0 == target; // Obviously true +200.0 == target; // Obviously still false +100.5 == target; // True, because we set target to allow up to 1% difference +``` + +#### margin example +```cpp +Approx target = Approx(100).margin(5); +100.0 == target; // Obviously true +200.0 == target; // Obviously still false +104.0 == target; // True, because we set target to allow absolute difference of at most 5 +``` + +#### scale +Scale can be useful if the computation leading to the result worked +on different scale than is used by the results. Since allowed difference +between Approx's value and compared value is based primarily on Approx's value +(the allowed difference is computed as +`(Approx::scale + Approx::value) * epsilon`), the resulting comparison could +need rescaling to be correct. + + +## Exceptions + +* **REQUIRE_NOTHROW(** _expression_ **)** and +* **CHECK_NOTHROW(** _expression_ **)** + +Expects that no exception is thrown during evaluation of the expression. + +* **REQUIRE_THROWS(** _expression_ **)** and +* **CHECK_THROWS(** _expression_ **)** + +Expects that an exception (of any type) is be thrown during evaluation of the expression. + +* **REQUIRE_THROWS_AS(** _expression_, _exception type_ **)** and +* **CHECK_THROWS_AS(** _expression_, _exception type_ **)** + +Expects that an exception of the _specified type_ is thrown during evaluation of the expression. Note that the _exception type_ is extended with `const&` and you should not include it yourself. + +* **REQUIRE_THROWS_WITH(** _expression_, _string or string matcher_ **)** and +* **CHECK_THROWS_WITH(** _expression_, _string or string matcher_ **)** + +Expects that an exception is thrown that, when converted to a string, matches the _string_ or _string matcher_ provided (see next section for Matchers). + +e.g. +```cpp +REQUIRE_THROWS_WITH( openThePodBayDoors(), Contains( "afraid" ) && Contains( "can't do that" ) ); +REQUIRE_THROWS_WITH( dismantleHal(), "My mind is going" ); +``` + +* **REQUIRE_THROWS_MATCHES(** _expression_, _exception type_, _matcher for given exception type_ **)** and +* **CHECK_THROWS_MATCHES(** _expression_, _exception type_, _matcher for given exception type_ **)** + +Expects that exception of _exception type_ is thrown and it matches provided matcher (see next section for Matchers). + + +_Please note that the `THROW` family of assertions expects to be passed a single expression, not a statement or series of statements. If you want to check a more complicated sequence of operations, you can use a C++11 lambda function._ + +```cpp +REQUIRE_NOTHROW([&](){ + int i = 1; + int j = 2; + auto k = i + j; + if (k == 3) { + throw 1; + } +}()); +``` + + + +## Matcher expressions + +To support Matchers a slightly different form is used. Matchers have [their own documentation](matchers.md#top). + +* **REQUIRE_THAT(** _lhs_, _matcher expression_ **)** and +* **CHECK_THAT(** _lhs_, _matcher expression_ **)** + +Matchers can be composed using `&&`, `||` and `!` operators. + +## Thread Safety + +Currently assertions in Catch are not thread safe. +For more details, along with workarounds, see the section on [the limitations page](limitations.md#thread-safe-assertions). + +## Expressions with commas + +Because the preprocessor parses code using different rules than the +compiler, multiple-argument assertions (e.g. `REQUIRE_THROWS_AS`) have +problems with commas inside the provided expressions. As an example +`REQUIRE_THROWS_AS(std::pair(1, 2), std::invalid_argument);` +will fail to compile, because the preprocessor sees 3 arguments provided, +but the macro accepts only 2. There are two possible workarounds. + +1) Use typedef: +```cpp +using int_pair = std::pair; +REQUIRE_THROWS_AS(int_pair(1, 2), std::invalid_argument); +``` + +This solution is always applicable, but makes the meaning of the code +less clear. + +2) Parenthesize the expression: +```cpp +TEST_CASE_METHOD((Fixture), "foo", "[bar]") { + SUCCEED(); +} +``` + +This solution is not always applicable, because it might require extra +changes on the Catch's side to work. + +--- + +[Home](Readme.md#top) diff --git a/src/third_party/cppcodec/test/catch/docs/ci-and-misc.md b/src/third_party/cppcodec/test/catch/docs/ci-and-misc.md new file mode 100644 index 0000000000..97d5c8399c --- /dev/null +++ b/src/third_party/cppcodec/test/catch/docs/ci-and-misc.md @@ -0,0 +1,102 @@ + +# CI and other odd pieces + +This page talks about how Catch integrates with Continuous Integration +Build Systems may refer to low-level tools, like CMake, or larger systems that run on servers, like Jenkins or TeamCity. This page will talk about both. + +## Continuous Integration systems + +Probably the most important aspect to using Catch with a build server is the use of different reporters. Catch comes bundled with three reporters that should cover the majority of build servers out there - although adding more for better integration with some is always a possibility (currently we also offer TeamCity, TAP and Automake reporters). + +Two of these reporters are built in (XML and JUnit) and the third (TeamCity) is included as a separate header. It's possible that the other two may be split out in the future too - as that would make the core of Catch smaller for those that don't need them. + +### XML Reporter +```-r xml``` + +The XML Reporter writes in an XML format that is specific to Catch. + +The advantage of this format is that it corresponds well to the way Catch works (especially the more unusual features, such as nested sections) and is a fully streaming format - that is it writes output as it goes, without having to store up all its results before it can start writing. + +The disadvantage is that, being specific to Catch, no existing build servers understand the format natively. It can be used as input to an XSLT transformation that could convert it to, say, HTML - although this loses the streaming advantage, of course. + +### JUnit Reporter +```-r junit``` + +The JUnit Reporter writes in an XML format that mimics the JUnit ANT schema. + +The advantage of this format is that the JUnit Ant schema is widely understood by most build servers and so can usually be consumed with no additional work. + +The disadvantage is that this schema was designed to correspond to how JUnit works - and there is a significant mismatch with how Catch works. Additionally the format is not streamable (because opening elements hold counts of failed and passing tests as attributes) - so the whole test run must complete before it can be written. + +## Other reporters +Other reporters are not part of the single-header distribution and need +to be downloaded and included separately. All reporters are stored in +`single_include` directory in the git repository, and are named +`catch_reporter_*.hpp`. For example, to use the TeamCity reporter you +need to download `single_include/catch_reporter_teamcity.hpp` and include +it after Catch itself. + +```cpp +#define CATCH_CONFIG_MAIN +#include "catch.hpp" +#include "catch_reporter_teamcity.hpp" +``` + +### TeamCity Reporter +```-r teamcity``` + +The TeamCity Reporter writes TeamCity service messages to stdout. In order to be able to use this reporter an additional header must also be included. + +Being specific to TeamCity this is the best reporter to use with it - but it is completely unsuitable for any other purpose. It is a streaming format (it writes as it goes) - although test results don't appear in the TeamCity interface until the completion of a suite (usually the whole test run). + +### Automake Reporter +```-r automake``` + +The Automake Reporter writes out the [meta tags](https://www.gnu.org/software/automake/manual/html_node/Log-files-generation-and-test-results-recording.html#Log-files-generation-and-test-results-recording) expected by automake via `make check`. + +### TAP (Test Anything Protocol) Reporter +```-r tap``` + +Because of the incremental nature of Catch's test suites and ability to run specific tests, our implementation of TAP reporter writes out the number of tests in a suite last. + +## Low-level tools + +### Precompiled headers (PCHs) + +Catch offers prototypal support for being included in precompiled headers, but because of its single-header nature it does need some actions by the user: +* The precompiled header needs to define `CATCH_CONFIG_ALL_PARTS` +* The implementation file needs to + * undefine `TWOBLUECUBES_SINGLE_INCLUDE_CATCH_HPP_INCLUDED` + * define `CATCH_CONFIG_IMPL_ONLY` + * define `CATCH_CONFIG_MAIN` or `CATCH_CONFIG_RUNNER` + * include "catch.hpp" again + + +### CodeCoverage module (GCOV, LCOV...) + +If you are using GCOV tool to get testing coverage of your code, and are not sure how to integrate it with CMake and Catch, there should be an external example over at https://github.com/fkromer/catch_cmake_coverage + + +### pkg-config + +Catch2 provides a rudimentary pkg-config integration, by registering itself +under the name `catch2`. This means that after Catch2 is installed, you +can use `pkg-config` to get its include path: `pkg-config --cflags catch2`. + +### gdb and lldb scripts + +Catch2's `contrib` folder also contains two simple debugger scripts, +`gdbinit` for `gdb` and `lldbinit` for `lldb`. If loaded into their +respective debugger, these will tell it to step over Catch2's internals +when stepping through code. + + +## CMake + +[As it has been getting kinda long, the documentation of Catch2's +integration with CMake has been moved to its own page.](cmake-integration.md#top) + + +--- + +[Home](Readme.md#top) diff --git a/src/third_party/cppcodec/test/catch/docs/cmake-integration.md b/src/third_party/cppcodec/test/catch/docs/cmake-integration.md new file mode 100644 index 0000000000..5f57c276a6 --- /dev/null +++ b/src/third_party/cppcodec/test/catch/docs/cmake-integration.md @@ -0,0 +1,189 @@ + +# CMake integration + +Because we use CMake to build Catch2, we also provide a couple of +integration points for our users. + +1) Catch2 exports a (namespaced) CMake target +2) Catch2's repository contains CMake scripts for automatic registration +of `TEST_CASE`s in CTest + +## CMake target + +Catch2's CMake build exports an interface target `Catch2::Catch2`. Linking +against it will add the proper include path and all necessary capabilities +to the resulting binary. + +This means that if Catch2 has been installed on the system, it should be +enough to do: +```cmake +find_package(Catch2 REQUIRED) +target_link_libraries(tests Catch2::Catch2) +``` + + +This target is also provided when Catch2 is used as a subdirectory. +Assuming that Catch2 has been cloned to `lib/Catch2`: +```cmake +add_subdirectory(lib/Catch2) +target_link_libraries(tests Catch2::Catch2) +``` + +## Automatic test registration + +Catch2's repository also contains two CMake scripts that help users +with automatically registering their `TEST_CASE`s with CTest. They +can be found in the `contrib` folder, and are + +1) `Catch.cmake` (and its dependency `CatchAddTests.cmake`) +2) `ParseAndAddCatchTests.cmake` + +If Catch2 has been installed in system, both of these can be used after +doing `find_package(Catch2 REQUIRED)`. Otherwise you need to add them +to your CMake module path. + +### `Catch.cmake` and `AddCatchTests.cmake` + +`Catch.cmake` provides function `catch_discover_tests` to get tests from +a target. This function works by running the resulting executable with +`--list-test-names-only` flag, and then parsing the output to find all +existing tests. + +#### Usage +```cmake +cmake_minimum_required(VERSION 3.5) + +project(baz LANGUAGES CXX VERSION 0.0.1) + +find_package(Catch2 REQUIRED) +add_executable(foo test.cpp) +target_link_libraries(foo Catch2::Catch2) + +include(CTest) +include(Catch) +catch_discover_tests(foo) +``` + + +#### Customization +`catch_discover_tests` can be given several extra argumets: +```cmake +catch_discover_tests(target + [TEST_SPEC arg1...] + [EXTRA_ARGS arg1...] + [WORKING_DIRECTORY dir] + [TEST_PREFIX prefix] + [TEST_SUFFIX suffix] + [PROPERTIES name1 value1...] + [TEST_LIST var] +) +``` + +* `TEST_SPEC arg1...` + +Specifies test cases, wildcarded test cases, tags and tag expressions to +pass to the Catch executable alongside the `--list-test-names-only` flag. + + +* `EXTRA_ARGS arg1...` + +Any extra arguments to pass on the command line to each test case. + + +* `WORKING_DIRECTORY dir` + +Specifies the directory in which to run the discovered test cases. If this +option is not provided, the current binary directory is used. + + +* `TEST_PREFIX prefix` + +Specifies a _prefix_ to be added to the name of each discovered test case. +This can be useful when the same test executable is being used in multiple +calls to `catch_discover_tests()`, with different `TEST_SPEC` or `EXTRA_ARGS`. + + +* `TEST_SUFFIX suffix` + +Same as `TEST_PREFIX`, except it specific the _suffix_ for the test names. +Both `TEST_PREFIX` and `TEST_SUFFIX` can be specified at the same time. + + +* `PROPERTIES name1 value1...` + +Specifies additional properties to be set on all tests discovered by this +invocation of `catch_discover_tests`. + + +* `TEST_LIST var` + +Make the list of tests available in the variable `var`, rather than the +default `_TESTS`. This can be useful when the same test +executable is being used in multiple calls to `catch_discover_tests()`. +Note that this variable is only available in CTest. + + +### `ParseAndAddCatchTests.cmake` + +`ParseAndAddCatchTests` works by parsing all implementation files +associated with the provided target, and registering them via CTest's +`add_test`. This approach has some limitations, such as the fact that +commented-out tests will be registered anyway. + + +#### Usage + +```cmake +cmake_minimum_required(VERSION 3.5) + +project(baz LANGUAGES CXX VERSION 0.0.1) + +find_package(Catch2 REQUIRED) +add_executable(foo test.cpp) +target_link_libraries(foo Catch2::Catch2) + +include(CTest) +include(ParseAndAddCatchTests) +ParseAndAddCatchTests(foo) +``` + + +#### Customization + +`ParseAndAddCatchTests` provides some customization points: +* `PARSE_CATCH_TESTS_VERBOSE` -- When `ON`, the script prints debug +messages. Defaults to `OFF`. +* `PARSE_CATCH_TESTS_NO_HIDDEN_TESTS` -- When `ON`, hidden tests (tests +tagged with any of `[!hide]`, `[.]` or `[.foo]`) will not be registered. +Defaults to `OFF`. +* `PARSE_CATCH_TESTS_ADD_FIXTURE_IN_TEST_NAME` -- When `ON`, adds fixture +class name to the test name in CTest. Defaults to `ON`. +* `PARSE_CATCH_TESTS_ADD_TARGET_IN_TEST_NAME` -- When `ON`, adds target +name to the test name in CTest. Defaults to `ON`. +* `PARSE_CATCH_TESTS_ADD_TO_CONFIGURE_DEPENDS` -- When `ON`, adds test +file to `CMAKE_CONFIGURE_DEPENDS`. This means that the CMake configuration +step will be re-ran when the test files change, letting new tests be +automatically discovered. Defaults to `OFF`. + + +## CMake project options + +Catch2's CMake project also provides some options for other projects +that consume it. These are + +* `CATCH_BUILD_TESTING` -- When `ON`, Catch2's SelfTest project will be +built. Defaults to `ON`. Note that Catch2 also obeys `BUILD_TESTING` CMake +variable, so _both_ of them need to be `ON` for the SelfTest to be built, +and either of them can be set to `OFF` to disable building SelfTest. +* `CATCH_BUILD_EXAMPLES` -- When `ON`, Catch2's usage examples will be +built. Defaults to `OFF`. +* `CATCH_INSTALL_DOCS` -- When `ON`, Catch2's documentation will be +included in the installation. Defaults to `ON`. +* `CATCH_INSTALL_HELPERS` -- When `ON`, Catch2's contrib folder will be +included in the installation. Defaults to `ON`. +* `BUILD_TESTING` -- When `ON` and the project is not used as a subproject, +Catch2's test binary will be built. Defaults to `ON`. + +--- + +[Home](Readme.md#top) diff --git a/src/third_party/cppcodec/test/catch/docs/command-line.md b/src/third_party/cppcodec/test/catch/docs/command-line.md new file mode 100644 index 0000000000..94705ef3c7 --- /dev/null +++ b/src/third_party/cppcodec/test/catch/docs/command-line.md @@ -0,0 +1,349 @@ + +# Command line + +**Contents**
+[Specifying which tests to run](#specifying-which-tests-to-run)
+[Choosing a reporter to use](#choosing-a-reporter-to-use)
+[Breaking into the debugger](#breaking-into-the-debugger)
+[Showing results for successful tests](#showing-results-for-successful-tests)
+[Aborting after a certain number of failures](#aborting-after-a-certain-number-of-failures)
+[Listing available tests, tags or reporters](#listing-available-tests-tags-or-reporters)
+[Sending output to a file](#sending-output-to-a-file)
+[Naming a test run](#naming-a-test-run)
+[Eliding assertions expected to throw](#eliding-assertions-expected-to-throw)
+[Make whitespace visible](#make-whitespace-visible)
+[Warnings](#warnings)
+[Reporting timings](#reporting-timings)
+[Load test names to run from a file](#load-test-names-to-run-from-a-file)
+[Just test names](#just-test-names)
+[Specify the order test cases are run](#specify-the-order-test-cases-are-run)
+[Specify a seed for the Random Number Generator](#specify-a-seed-for-the-random-number-generator)
+[Identify framework and version according to the libIdentify standard](#identify-framework-and-version-according-to-the-libidentify-standard)
+[Wait for key before continuing](#wait-for-key-before-continuing)
+[Specify multiples of clock resolution to run benchmarks for](#specify-multiples-of-clock-resolution-to-run-benchmarks-for)
+[Usage](#usage)
+[Specify the section to run](#specify-the-section-to-run)
+[Filenames as tags](#filenames-as-tags)
+[Override output colouring](#use-colour)
+ +Catch works quite nicely without any command line options at all - but for those times when you want greater control the following options are available. +Click one of the followings links to take you straight to that option - or scroll on to browse the available options. + + ` ...`
+ ` -h, -?, --help`
+ ` -l, --list-tests`
+ ` -t, --list-tags`
+ ` -s, --success`
+ ` -b, --break`
+ ` -e, --nothrow`
+ ` -i, --invisibles`
+ ` -o, --out`
+ ` -r, --reporter`
+ ` -n, --name`
+ ` -a, --abort`
+ ` -x, --abortx`
+ ` -w, --warn`
+ ` -d, --durations`
+ ` -f, --input-file`
+ ` -c, --section`
+ ` -#, --filenames-as-tags`
+ + +
+ + ` --list-test-names-only`
+ ` --list-reporters`
+ ` --order`
+ ` --rng-seed`
+ ` --libidentify`
+ ` --wait-for-keypress`
+ ` --benchmark-resolution-multiple`
+ ` --use-colour`
+ +
+ + + + +## Specifying which tests to run + +
<test-spec> ...
+ +Test cases, wildcarded test cases, tags and tag expressions are all passed directly as arguments. Tags are distinguished by being enclosed in square brackets. + +If no test specs are supplied then all test cases, except "hidden" tests, are run. +A test is hidden by giving it any tag starting with (or just) a period (```.```) - or, in the deprecated case, tagged ```[hide]``` or given name starting with `'./'`. To specify hidden tests from the command line ```[.]``` or ```[hide]``` can be used *regardless of how they were declared*. + +Specs must be enclosed in quotes if they contain spaces. If they do not contain spaces the quotes are optional. + +Wildcards consist of the `*` character at the beginning and/or end of test case names and can substitute for any number of any characters (including none). + +Test specs are case insensitive. + +If a spec is prefixed with `exclude:` or the `~` character then the pattern matches an exclusion. This means that tests matching the pattern are excluded from the set - even if a prior inclusion spec included them. Subsequent inclusion specs will take precedence, however. +Inclusions and exclusions are evaluated in left-to-right order. + +Test case examples: + +
thisTestOnly            Matches the test case called, 'thisTestOnly'
+"this test only"        Matches the test case called, 'this test only'
+these*                  Matches all cases starting with 'these'
+exclude:notThis         Matches all tests except, 'notThis'
+~notThis                Matches all tests except, 'notThis'
+~*private*              Matches all tests except those that contain 'private'
+a* ~ab* abc             Matches all tests that start with 'a', except those that
+                        start with 'ab', except 'abc', which is included
+
+ +Names within square brackets are interpreted as tags. +A series of tags form an AND expression whereas a comma-separated sequence forms an OR expression. e.g.: + +
[one][two],[three]
+This matches all tests tagged `[one]` and `[two]`, as well as all tests tagged `[three]` + +Test names containing special characters, such as `,` or `[` can specify them on the command line using `\`. +`\` also escapes itself. + + +## Choosing a reporter to use + +
-r, --reporter <reporter>
+ +A reporter is an object that formats and structures the output of running tests, and potentially summarises the results. By default a console reporter is used that writes, IDE friendly, textual output. Catch comes bundled with some alternative reporters, but more can be added in client code.
+The bundled reporters are: + +
-r console
+-r compact
+-r xml
+-r junit
+
+ +The JUnit reporter is an xml format that follows the structure of the JUnit XML Report ANT task, as consumed by a number of third-party tools, including Continuous Integration servers such as Hudson. If not otherwise needed, the standard XML reporter is preferred as this is a streaming reporter, whereas the Junit reporter needs to hold all its results until the end so it can write the overall results into attributes of the root node. + + +## Breaking into the debugger +
-b, --break
+ +Under most debuggers Catch2 is capable of automatically breaking on a test +failure. This allows the user to see the current state of the test during +failure. + + +## Showing results for successful tests +
-s, --success
+ +Usually you only want to see reporting for failed tests. Sometimes it's useful to see *all* the output (especially when you don't trust that that test you just added worked first time!). +To see successful, as well as failing, test results just pass this option. Note that each reporter may treat this option differently. The Junit reporter, for example, logs all results regardless. + + +## Aborting after a certain number of failures +
-a, --abort
+-x, --abortx [<failure threshold>]
+
+ +If a ```REQUIRE``` assertion fails the test case aborts, but subsequent test cases are still run. +If a ```CHECK``` assertion fails even the current test case is not aborted. + +Sometimes this results in a flood of failure messages and you'd rather just see the first few. Specifying ```-a``` or ```--abort``` on its own will abort the whole test run on the first failed assertion of any kind. Use ```-x``` or ```--abortx``` followed by a number to abort after that number of assertion failures. + + +## Listing available tests, tags or reporters +
-l, --list-tests
+-t, --list-tags
+--list-reporters
+
+ +```-l``` or ```--list-tests``` will list all registered tests, along with any tags. +If one or more test-specs have been supplied too then only the matching tests will be listed. + +```-t``` or ```--list-tags``` lists all available tags, along with the number of test cases they match. Again, supplying test specs limits the tags that match. + +```--list-reporters``` lists the available reporters. + + +## Sending output to a file +
-o, --out <filename>
+
+ +Use this option to send all output to a file. By default output is sent to stdout (note that uses of stdout and stderr *from within test cases* are redirected and included in the report - so even stderr will effectively end up on stdout). + + +## Naming a test run +
-n, --name <name for test run>
+ +If a name is supplied it will be used by the reporter to provide an overall name for the test run. This can be useful if you are sending to a file, for example, and need to distinguish different test runs - either from different Catch executables or runs of the same executable with different options. If not supplied the name is defaulted to the name of the executable. + + +## Eliding assertions expected to throw +
-e, --nothrow
+ +Skips all assertions that test that an exception is thrown, e.g. ```REQUIRE_THROWS```. + +These can be a nuisance in certain debugging environments that may break when exceptions are thrown (while this is usually optional for handled exceptions, it can be useful to have enabled if you are trying to track down something unexpected). + +Sometimes exceptions are expected outside of one of the assertions that tests for them (perhaps thrown and caught within the code-under-test). The whole test case can be skipped when using ```-e``` by marking it with the ```[!throws]``` tag. + +When running with this option any throw checking assertions are skipped so as not to contribute additional noise. Be careful if this affects the behaviour of subsequent tests. + + +## Make whitespace visible +
-i, --invisibles
+ +If a string comparison fails due to differences in whitespace - especially leading or trailing whitespace - it can be hard to see what's going on. +This option transforms tabs and newline characters into ```\t``` and ```\n``` respectively when printing. + + +## Warnings +
-w, --warn <warning name>
+ +Enables reporting of suspicious test states. There are currently two +available warnings + +``` + NoAssertions // Fail test case / leaf section if no assertions + // (e.g. `REQUIRE`) is encountered. + NoTests // Return non-zero exit code when no test cases were run + // Also calls reporter's noMatchingTestCases method +``` + + + +## Reporting timings +
-d, --durations <yes/no>
+ +When set to ```yes``` Catch will report the duration of each test case, in milliseconds. Note that it does this regardless of whether a test case passes or fails. Note, also, the certain reporters (e.g. Junit) always report test case durations regardless of this option being set or not. + + +## Load test names to run from a file +
-f, --input-file <filename>
+ +Provide the name of a file that contains a list of test case names - one per line. Blank lines are skipped and anything after the comment character, ```#```, is ignored. + +A useful way to generate an initial instance of this file is to use the list-test-names-only option. This can then be manually curated to specify a specific subset of tests - or in a specific order. + + +## Just test names +
--list-test-names-only
+ +This option lists all available tests in a non-indented form, one on each line. This makes it ideal for saving to a file and feeding back into the ```-f``` or ```--input-file``` option. + + + +## Specify the order test cases are run +
--order <decl|lex|rand>
+ +Test cases are ordered one of three ways: + + +### decl +Declaration order. The order the tests were originally declared in. Note that ordering between files is not guaranteed and is implementation dependent. + +### lex +Lexicographically sorted. Tests are sorted, alpha-numerically, by name. + +### rand +Randomly sorted. Test names are sorted using ```std::random_shuffle()```. By default the random number generator is seeded with 0 - and so the order is repeatable. To control the random seed see rng-seed. + + +## Specify a seed for the Random Number Generator +
--rng-seed <'time'|number>
+ +Sets a seed for the random number generator using ```std::srand()```. +If a number is provided this is used directly as the seed so the random pattern is repeatable. +Alternatively if the keyword ```time``` is provided then the result of calling ```std::time(0)``` is used and so the pattern becomes unpredictable. + +In either case the actual value for the seed is printed as part of Catch's output so if an issue is discovered that is sensitive to test ordering the ordering can be reproduced - even if it was originally seeded from ```std::time(0)```. + + +## Identify framework and version according to the libIdentify standard +
--libidentify
+ +See [The LibIdentify repo for more information and examples](https://github.com/janwilmans/LibIdentify). + + +## Wait for key before continuing +
--wait-for-keypress <start|exit|both>
+ +Will cause the executable to print a message and wait until the return/ enter key is pressed before continuing - +either before running any tests, after running all tests - or both, depending on the argument. + + +## Specify multiples of clock resolution to run benchmarks for +
--benchmark-resolution-multiple <multiplier>
+ +When running benchmarks the clock resolution is estimated. Benchmarks are then run for exponentially increasing +numbers of iterations until some multiple of the estimated resolution is exceed. By default that multiple is 100, but +it can be overridden here. + + +## Usage +
-h, -?, --help
+ +Prints the command line arguments to stdout + + + +## Specify the section to run +
-c, --section <section name>
+ +To limit execution to a specific section within a test case, use this option one or more times. +To narrow to sub-sections use multiple instances, where each subsequent instance specifies a deeper nesting level. + +E.g. if you have: + +
+TEST_CASE( "Test" ) {
+  SECTION( "sa" ) {
+    SECTION( "sb" ) {
+      /*...*/
+    }
+    SECTION( "sc" ) {
+      /*...*/
+    }
+  }
+  SECTION( "sd" ) {
+    /*...*/
+  }
+}
+
+ +Then you can run `sb` with: +
./MyExe Test -c sa -c sb
+ +Or run just `sd` with: +
./MyExe Test -c sd
+ +To run all of `sa`, including `sb` and `sc` use: +
./MyExe Test -c sa
+ +There are some limitations of this feature to be aware of: +- Code outside of sections being skipped will still be executed - e.g. any set-up code in the TEST_CASE before the +start of the first section.
+- At time of writing, wildcards are not supported in section names. +- If you specify a section without narrowing to a test case first then all test cases will be executed +(but only matching sections within them). + + + +## Filenames as tags +
-#, --filenames-as-tags
+ +When this option is used then every test is given an additional tag which is formed of the unqualified +filename it is found in, with any extension stripped, prefixed with the `#` character. + +So, for example, tests within the file `~\Dev\MyProject\Ferrets.cpp` would be tagged `[#Ferrets]`. + + +## Override output colouring +
--use-colour <yes|no|auto>
+ +Catch colours output for terminals, but omits colouring when it detects that +output is being sent to a pipe. This is done to avoid interfering with automated +processing of output. + +`--use-colour yes` forces coloured output, `--use-colour no` disables coloured +output. The default behaviour is `--use-colour auto`. + +--- + +[Home](Readme.md#top) diff --git a/src/third_party/cppcodec/test/catch/docs/commercial-users.md b/src/third_party/cppcodec/test/catch/docs/commercial-users.md new file mode 100644 index 0000000000..e4d789f10b --- /dev/null +++ b/src/third_party/cppcodec/test/catch/docs/commercial-users.md @@ -0,0 +1,17 @@ + +# Commercial users of Catch + +As well as [Open Source](opensource-users.md#top) users Catch is widely used within proprietary code bases too. +Many organisations like to keep this information internal, and that's fine, +but if you're more open it would be great if we could list the names of as +many organisations as possible that use Catch somewhere in their codebase. +Enterprise environments often tend to be far more conservative in their tool adoption - +and being aware that other companies are using Catch can ease the path in. + +So if you are aware of Catch usage in your organisation, and are fairly confident there is no issue with sharing this +fact then please let us know - either directly, via a PR or +[issue](https://github.com/philsquared/Catch/issues), or on the [forums](https://groups.google.com/forum/?fromgroups#!forum/catch-forum). + + - Bloomberg + - NASA + - [Inscopix Inc.](https://www.inscopix.com/) diff --git a/src/third_party/cppcodec/test/catch/docs/configuration.md b/src/third_party/cppcodec/test/catch/docs/configuration.md new file mode 100644 index 0000000000..fc7241a21a --- /dev/null +++ b/src/third_party/cppcodec/test/catch/docs/configuration.md @@ -0,0 +1,205 @@ + +# Compile-time configuration + +**Contents**
+[main()/ implementation](#main-implementation)
+[Prefixing Catch macros](#prefixing-catch-macros)
+[Terminal colour](#terminal-colour)
+[Console width](#console-width)
+[stdout](#stdout)
+[Fallback stringifier](#fallback-stringifier)
+[Default reporter](#default-reporter)
+[Other toggles](#other-toggles)
+[Windows header clutter](#windows-header-clutter)
+[Enabling stringification](#enabling-stringification)
+ +Catch is designed to "just work" as much as possible. For most people the only configuration needed is telling Catch which source file should host all the implementation code (```CATCH_CONFIG_MAIN```). + +Nonetheless there are still some occasions where finer control is needed. For these occasions Catch exposes a set of macros for configuring how it is built. + +## main()/ implementation + + CATCH_CONFIG_MAIN // Designates this as implementation file and defines main() + CATCH_CONFIG_RUNNER // Designates this as implementation file + +Although Catch is header only it still, internally, maintains a distinction between interface headers and headers that contain implementation. Only one source file in your test project should compile the implementation headers and this is controlled through the use of one of these macros - one of these identifiers should be defined before including Catch in *exactly one implementation file in your project*. + +# Reporter / Listener interfaces + + CATCH_CONFIG_EXTERNAL_INTERFACES // Brings in necessary headers for Reporter/Listener implementation + +Brings in various parts of Catch that are required for user defined Reporters and Listeners. This means that new Reporters and Listeners can be defined in this file as well as in the main file. + +Implied by both `CATCH_CONFIG_MAIN` and `CATCH_CONFIG_RUNNER`. + +## Prefixing Catch macros + + CATCH_CONFIG_PREFIX_ALL + +To keep test code clean and uncluttered Catch uses short macro names (e.g. ```TEST_CASE``` and ```REQUIRE```). Occasionally these may conflict with identifiers from platform headers or the system under test. In this case the above identifier can be defined. This will cause all the Catch user macros to be prefixed with ```CATCH_``` (e.g. ```CATCH_TEST_CASE``` and ```CATCH_REQUIRE```). + + +## Terminal colour + + CATCH_CONFIG_COLOUR_NONE // completely disables all text colouring + CATCH_CONFIG_COLOUR_WINDOWS // forces the Win32 console API to be used + CATCH_CONFIG_COLOUR_ANSI // forces ANSI colour codes to be used + +Yes, I am English, so I will continue to spell "colour" with a 'u'. + +When sending output to the terminal, if it detects that it can, Catch will use colourised text. On Windows the Win32 API, ```SetConsoleTextAttribute```, is used. On POSIX systems ANSI colour escape codes are inserted into the stream. + +For finer control you can define one of the above identifiers (these are mutually exclusive - but that is not checked so may behave unexpectedly if you mix them): + +Note that when ANSI colour codes are used "unistd.h" must be includable - along with a definition of ```isatty()``` + +Typically you should place the ```#define``` before #including "catch.hpp" in your main source file - but if you prefer you can define it for your whole project by whatever your IDE or build system provides for you to do so. + +## Console width + + CATCH_CONFIG_CONSOLE_WIDTH = x // where x is a number + +Catch formats output intended for the console to fit within a fixed number of characters. This is especially important as indentation is used extensively and uncontrolled line wraps break this. +By default a console width of 80 is assumed but this can be controlled by defining the above identifier to be a different value. + +## stdout + + CATCH_CONFIG_NOSTDOUT + +To support platforms that do not provide `std::cout`, `std::cerr` and +`std::clog`, Catch does not usem the directly, but rather calls +`Catch::cout`, `Catch::cerr` and `Catch::clog`. You can replace their +implementation by defining `CATCH_CONFIG_NOSTDOUT` and implementing +them yourself, their signatures are: + + std::ostream& cout(); + std::ostream& cerr(); + std::ostream& clog(); + +[You can see an example of replacing these functions here.]( +../examples/231-Cfg-OutputStreams.cpp) + + +## Fallback stringifier + +By default, when Catch's stringification machinery has to stringify +a type that does not specialize `StringMaker`, does not overload `operator<<`, +is not an enumeration and is not a range, it uses `"{?}"`. This can be +overriden by defining `CATCH_CONFIG_FALLBACK_STRINGIFIER` to name of a +function that should perform the stringification instead. + +All types that do not provide `StringMaker` specialization or `operator<<` +overload will be sent to this function (this includes enums and ranges). +The provided function must return `std::string` and must accept any type, +e.g. via overloading. + +_Note that if the provided function does not handle a type and this type +requires to be stringified, the compilation will fail._ + + +## Default reporter + +Catch's default reporter can be changed by defining macro +`CATCH_CONFIG_DEFAULT_REPORTER` to string literal naming the desired +default reporter. + +This means that defining `CATCH_CONFIG_DEFAULT_REPORTER` to `"console"` +is equivalent with the out-of-the-box experience. + + +## C++11 toggles + + CATCH_CONFIG_CPP11_TO_STRING // Use `std::to_string` + +Because we support platforms whose standard library does not contain +`std::to_string`, it is possible to force Catch to use a workaround +based on `std::stringstream`. On platforms other than Android, +the default is to use `std::to_string`. On Android, the default is to +use the `stringstream` workaround. As always, it is possible to override +Catch's selection, by defining either `CATCH_CONFIG_CPP11_TO_STRING` or +`CATCH_CONFIG_NO_CPP11_TO_STRING`. + + +## C++17 toggles + + CATCH_CONFIG_CPP17_UNCAUGHT_EXCEPTIONS // Use std::uncaught_exceptions instead of std::uncaught_exception + +Catch contains basic compiler/standard detection and attempts to use +some C++17 features whenever appropriate. This automatic detection +can be manually overridden in both directions, that is, a feature +can be enabled by defining the macro in the table above, and disabled +by using `_NO_` in the macro, e.g. `CATCH_CONFIG_NO_CPP17_UNCAUGHT_EXCEPTIONS`. + + +## Other toggles + + CATCH_CONFIG_COUNTER // Use __COUNTER__ to generate unique names for test cases + CATCH_CONFIG_WINDOWS_SEH // Enable SEH handling on Windows + CATCH_CONFIG_FAST_COMPILE // Sacrifices some (rather minor) features for compilation speed + CATCH_CONFIG_DISABLE_MATCHERS // Do not compile Matchers in this compilation unit + CATCH_CONFIG_POSIX_SIGNALS // Enable handling POSIX signals + CATCH_CONFIG_WINDOWS_CRTDBG // Enable leak checking using Windows's CRT Debug Heap + CATCH_CONFIG_DISABLE_STRINGIFICATION // Disable stringifying the original expression + CATCH_CONFIG_DISABLE // Disables assertions and test case registration + CATCH_CONFIG_WCHAR // Enables use of wchart_t + CATCH_CONFIG_EXPERIMENTAL_REDIRECT // Enables the new (experimental) way of capturing stdout/stderr + +Currently Catch enables `CATCH_CONFIG_WINDOWS_SEH` only when compiled with MSVC, because some versions of MinGW do not have the necessary Win32 API support. + +`CATCH_CONFIG_POSIX_SIGNALS` is on by default, except when Catch is compiled under `Cygwin`, where it is disabled by default (but can be force-enabled by defining `CATCH_CONFIG_POSIX_SIGNALS`). + +`CATCH_CONFIG_WINDOWS_CRTDBG` is off by default. If enabled, Windows's CRT is used to check for memory leaks, and displays them after the tests finish running. + +`CATCH_CONFIG_WCHAR` is on by default, but can be disabled. Currently +it is only used in support for DJGPP cross-compiler. + +With the exception of `CATCH_CONFIG_EXPERIMENTAL_REDIRECT`, +these toggles can be disabled by using `_NO_` form of the toggle, +e.g. `CATCH_CONFIG_NO_WINDOWS_SEH`. + +### `CATCH_CONFIG_FAST_COMPILE` +This compile-time flag speeds up compilation of assertion macros by ~20%, +by disabling the generation of assertion-local try-catch blocks for +non-exception family of assertion macros ({`REQUIRE`,`CHECK`}{``,`_FALSE`, `_THAT`}). +This disables translation of exceptions thrown under these assertions, but +should not lead to false negatives. + +`CATCH_CONFIG_FAST_COMPILE` has to be either defined, or not defined, +in all translation units that are linked into single test binary. + +### `CATCH_CONFIG_DISABLE_MATCHERS` +When `CATCH_CONFIG_DISABLE_MATCHERS` is defined, all mentions of Catch's Matchers are ifdef-ed away from the translation unit. Doing so will speed up compilation of that TU. + +_Note: If you define `CATCH_CONFIG_DISABLE_MATCHERS` in the same file as Catch's main is implemented, your test executable will fail to link if you use Matchers anywhere._ + +### `CATCH_CONFIG_DISABLE_STRINGIFICATION` +This toggle enables a workaround for VS 2017 bug. For details see [known limitations](limitations.md#visual-studio-2017----raw-string-literal-in-assert-fails-to-compile). + +### `CATCH_CONFIG_DISABLE` +This toggle removes most of Catch from given file. This means that `TEST_CASE`s are not registered and assertions are turned into no-ops. Useful for keeping tests within implementation files (ie for functions with internal linkage), instead of in external files. + +This feature is considered experimental and might change at any point. + +_Inspired by Doctest's `DOCTEST_CONFIG_DISABLE`_ + +## Windows header clutter + +On Windows Catch includes `windows.h`. To minimize global namespace clutter in the implementation file, it defines `NOMINMAX` and `WIN32_LEAN_AND_MEAN` before including it. You can control this behaviour via two macros: + + CATCH_CONFIG_NO_NOMINMAX // Stops Catch from using NOMINMAX macro + CATCH_CONFIG_NO_WIN32_LEAN_AND_MEAN // Stops Catch from using WIN32_LEAN_AND_MEAN macro + + +## Enabling stringification + +By default, Catch does not stringify some types from the standard library. This is done to avoid dragging in various standard library headers by default. However, Catch does contain these and can be configured to provide them, using these macros: + + CATCH_CONFIG_ENABLE_PAIR_STRINGMAKER // Provide StringMaker specialization for std::pair + CATCH_CONFIG_ENABLE_TUPLE_STRINGMAKER // Provide StringMaker specialization for std::tuple + CATCH_CONFIG_ENABLE_CHRONO_STRINGMAKER // Provide StringMaker specialization for std::chrono::duration, std::chrono::timepoint + CATCH_CONFIG_ENABLE_ALL_STRINGMAKERS // Defines all of the above + + +--- + +[Home](Readme.md#top) diff --git a/src/third_party/cppcodec/test/catch/docs/contributing.md b/src/third_party/cppcodec/test/catch/docs/contributing.md new file mode 100644 index 0000000000..b6150375c3 --- /dev/null +++ b/src/third_party/cppcodec/test/catch/docs/contributing.md @@ -0,0 +1,61 @@ + +# Contributing to Catch + +So you want to contribute something to Catch? That's great! Whether it's a bug fix, a new feature, support for +additional compilers - or just a fix to the documentation - all contributions are very welcome and very much appreciated. +Of course so are bug reports and other comments and questions. + +If you are contributing to the code base there are a few simple guidelines to keep in mind. This also includes notes to +help you find your way around. As this is liable to drift out of date please raise an issue or, better still, a pull +request for this file, if you notice that. + +## Branches + +Ongoing development is currently on _master_. At some point an integration branch will be set-up and PRs should target + that - but for now it's all against master. You may see feature branches come and go from time to time, too. + +## Directory structure + +_Users_ of Catch primarily use the single header version. _Maintainers_ should work with the full source (which is still, +primarily, in headers). This can be found in the `include` folder. There are a set of test files, currently under +`projects/SelfTest`. The test app can be built via CMake from the `CMakeLists.txt` file in the root, or you can generate +project files for Visual Studio, XCode, and others (instructions in the `projects` folder). If you have access to CLion, +it can work with the CMake file directly. + +As well as the runtime test files you'll also see a `SurrogateCpps` directory under `projects/SelfTest`. +This contains a set of .cpp files that each `#include` a single header. +While these files are not essential to compilation they help to keep the implementation headers self-contained. +At time of writing this set is not complete but has reasonable coverage. +If you add additional headers please try to remember to add a surrogate cpp for it. + +The other directories are `scripts` which contains a set of python scripts to help in testing Catch as well as +generating the single include, and `docs`, which contains the documentation as a set of markdown files. + +__When submitting a pull request please do not include changes to the single include, or to the version number file +as these are managed by the scripts!__ + + +## Testing your changes + +Obviously all changes to Catch's code should be tested. If you added new functionality, you should add tests covering and +showcasing it. Even if you have only made changes to Catch internals (ie you implemented some performance improvements), +you should still test your changes. + +This means 3 things + +* Compiling Catch's SelfTest project -- code that does not compile is evidently incorrect. Obviously, you are not expected to +have access to all compilers and platforms Catch supports, Catch's CI pipeline will compile your code using supported compilers +once you open a PR. +* Running the SelfTest binary. There should be no unexpected failures on simple run. +* Running Catch's approval tests. Approval tests compare current output of the SelfTest binary in various configurations against +known good output. Catch's repository provides utility scripts `approvalTests.py` to help you with this. It needs to be passed +the SelfTest binary compiled with your changes, like so: `$ ./scripts/approvalTests.py clang-build/SelfTest`. The output should +be fairly self-explanatory. + + + + *this document is still in-progress...* + +--- + +[Home](Readme.md#top) diff --git a/src/third_party/cppcodec/test/catch/docs/event-listeners.md b/src/third_party/cppcodec/test/catch/docs/event-listeners.md new file mode 100644 index 0000000000..c6625a2e0b --- /dev/null +++ b/src/third_party/cppcodec/test/catch/docs/event-listeners.md @@ -0,0 +1,75 @@ + +# Event Listeners + +A `Listener` is a class you can register with Catch that will then be passed events, +such as a test case starting or ending, as they happen during a test run. +`Listeners` are actually types of `Reporters`, with a few small differences: + +1. Once registered in code they are automatically used - you don't need to specify them on the command line +2. They are called in addition to (just before) any reporters, and you can register multiple listeners. +3. They derive from `Catch::TestEventListenerBase`, which has default stubs for all the events, +so you are not forced to implement events you're not interested in. +4. You register a listener with `CATCH_REGISTER_LISTENER` + + +## Implementing a Listener +Simply derive a class from `Catch::TestEventListenerBase` and implement the methods you are interested in, either in +the main source file (i.e. the one that defines `CATCH_CONFIG_MAIN` or `CATCH_CONFIG_RUNNER`), or in a +file that defines `CATCH_CONFIG_EXTERNAL_INTERFACES`. + +Then register it using `CATCH_REGISTER_LISTENER`. + +For example ([complete source code](../examples/210-Evt-EventListeners.cpp)): + +```c++ +#define CATCH_CONFIG_MAIN +#include "catch.hpp" + +struct MyListener : Catch::TestEventListenerBase { + + using TestEventListenerBase::TestEventListenerBase; // inherit constructor + + virtual void testCaseStarting( Catch::TestCaseInfo const& testInfo ) override { + // Perform some setup before a test case is run + } + + virtual void testCaseEnded( Catch::TestCaseStats const& testCaseStats ) override { + // Tear-down after a test case is run + } +}; +CATCH_REGISTER_LISTENER( MyListener ) +``` + +_Note that you should not use any assertion macros within a Listener!_ + +## Events that can be hooked + +The following are the methods that can be overridden in the Listener: + +```c++ +// The whole test run, starting and ending +virtual void testRunStarting( TestRunInfo const& testRunInfo ); +virtual void testRunEnded( TestRunStats const& testRunStats ); + +// Test cases starting and ending +virtual void testCaseStarting( TestCaseInfo const& testInfo ); +virtual void testCaseEnded( TestCaseStats const& testCaseStats ); + +// Sections starting and ending +virtual void sectionStarting( SectionInfo const& sectionInfo ); +virtual void sectionEnded( SectionStats const& sectionStats ); + +// Assertions before/ after +virtual void assertionStarting( AssertionInfo const& assertionInfo ); +virtual bool assertionEnded( AssertionStats const& assertionStats ); + +// A test is being skipped (because it is "hidden") +virtual void skipTest( TestCaseInfo const& testInfo ); +``` + +More information about the events (e.g. name of the test case) is contained in the structs passed as arguments - +just look in the source code to see what fields are available. + +--- + +[Home](Readme.md#top) diff --git a/src/third_party/cppcodec/test/catch/docs/limitations.md b/src/third_party/cppcodec/test/catch/docs/limitations.md new file mode 100644 index 0000000000..48c2bf0843 --- /dev/null +++ b/src/third_party/cppcodec/test/catch/docs/limitations.md @@ -0,0 +1,139 @@ + +# Known limitations + +Catch has some known limitations, that we are not planning to change. Some of these are caused by our desire to support C++98 compilers, some of these are caused by our desire to keep Catch crossplatform, some exist because their priority is seen as low compared to the development effort they would need and some other yet are compiler/runtime bugs. + +## Implementation limits +### Sections nested in loops + +If you are using `SECTION`s inside loops, you have to create them with different name per loop's iteration. The recommended way to do so is to incorporate the loop's counter into section's name, like so +```cpp +TEST_CASE( "Looped section" ) { + for (char i = '0'; i < '5'; ++i) { + SECTION(std::string("Looped section ") + i) { + SUCCEED( "Everything is OK" ); + } + } +} +``` + +## Features +This section outlines some missing features, what is their status and their possible workarounds. + +### Thread safe assertions +Catch2's assertion macros are not thread safe. This does not mean that +you cannot use threads inside Catch's test, but that only single thread +can interact with Catch's assertions and other macros. + +This means that this is ok +```cpp + std::vector threads; + std::atomic cnt{ 0 }; + for (int i = 0; i < 4; ++i) { + threads.emplace_back([&]() { + ++cnt; ++cnt; ++cnt; ++cnt; + }); + } + for (auto& t : threads) { t.join(); } + REQUIRE(cnt == 16); +``` +because only one thread passes the `REQUIRE` macro and this is not +```cpp + std::vector threads; + std::atomic cnt{ 0 }; + for (int i = 0; i < 4; ++i) { + threads.emplace_back([&]() { + ++cnt; ++cnt; ++cnt; ++cnt; + CHECK(cnt == 16); + }); + } + for (auto& t : threads) { t.join(); } + REQUIRE(cnt == 16); +``` + +Because C++11 provides the necessary tools to do this, we are planning +to remove this limitation in the future. + +### Process isolation in a test +Catch does not support running tests in isolated (forked) processes. While this might in the future, the fact that Windows does not support forking and only allows full-on process creation and the desire to keep code as similar as possible across platforms, mean that this is likely to take significant development time, that is not currently available. + +### Running multiple tests in parallel +Catch's test execution is strictly serial. If you find yourself with a test suite that takes too long to run and you want to make it parallel, there are 2 feasible solutions + * You can split your tests into multiple binaries and then run these binaries in parallel. + * You can have Catch list contained test cases and then run the same test binary multiple times in parallel, passing each instance list of test cases it should run. + +Both of these solutions have their problems, but should let you wring parallelism out of your test suite. + +## 3rd party bugs +This section outlines known bugs in 3rd party components (this means compilers, standard libraries, standard runtimes). + +### Visual Studio 2017 -- raw string literal in assert fails to compile +There is a known bug in Visual Studio 2017 (VC 15), that causes compilation error when preprocessor attempts to stringize a raw string literal (`#` preprocessor is applied to it). This snippet is sufficient to trigger the compilation error: +```cpp +#define CATCH_CONFIG_MAIN +#include "catch.hpp" + +TEST_CASE("test") { + CHECK(std::string(R"("\)") == "\"\\"); +} +``` + +Catch provides a workaround, it is possible to disable stringification of original expressions by defining `CATCH_CONFIG_DISABLE_STRINGIFICATION`: +```cpp +#define CATCH_CONFIG_FAST_COMPILE +#define CATCH_CONFIG_DISABLE_STRINGIFICATION +#include "catch.hpp" + +TEST_CASE("test") { + CHECK(std::string(R"("\)") == "\"\\"); +} +``` + +_Do note that this changes the output somewhat_ +``` +catchwork\test1.cpp(6): +PASSED: + CHECK( Disabled by CATCH_CONFIG_DISABLE_STRINGIFICATION ) +with expansion: + ""\" == ""\" +``` + +### Visual Studio 2015 -- Alignment compilation error (C2718) + +VS 2015 has a known bug, where `declval` can cause compilation error +if `T` has alignment requirements that it cannot meet. + + +A workaround is to explicitly specialize `Catch::is_range` for given +type (this avoids code path that uses `declval` in a SFINAE context). + + +### Visual Studio 2015 -- Wrong line number reported in debug mode +VS 2015 has a known bug where `__LINE__` macro can be improperly expanded under certain circumstances, while compiling multi-file project in Debug mode. + +A workaround is to compile the binary in Release mode. + +### Clang/G++ -- skipping leaf sections after an exception +Some versions of `libc++` and `libstdc++` (or their runtimes) have a bug with `std::uncaught_exception()` getting stuck returning `true` after rethrow, even if there are no active exceptions. One such case is this snippet, which skipped the sections "a" and "b", when compiled against `libcxxrt` from master +```cpp +#define CATCH_CONFIG_MAIN +#include + +TEST_CASE("a") { + CHECK_THROWS(throw 3); +} + +TEST_CASE("b") { + int i = 0; + SECTION("a") { i = 1; } + SECTION("b") { i = 2; } + CHECK(i > 0); +} +``` + +If you are seeing a problem like this, i.e. a weird test paths that trigger only under Clang with `libc++`, or only under very specific version of `libstdc++`, it is very likely you are seeing this. The only known workaround is to use a fixed version of your standard library. + +### Clang/G++ -- `Matches` string matcher always returns false +This is a bug in `libstdc++-4.8`, where all matching methods from `` return false. Since `Matches` uses `` internally, if the underlying implementation does not work, it doesn't work either. + +Workaround: Use newer version of `libstdc++`. diff --git a/src/third_party/cppcodec/test/catch/docs/list-of-examples.md b/src/third_party/cppcodec/test/catch/docs/list-of-examples.md new file mode 100644 index 0000000000..1284b2d6b0 --- /dev/null +++ b/src/third_party/cppcodec/test/catch/docs/list-of-examples.md @@ -0,0 +1,37 @@ + +# List of examples + +## Already available + +- Test Case: [Single-file](../examples/010-TestCase.cpp) +- Test Case: [Multiple-file 1](../examples/020-TestCase-1.cpp), [2](../examples/020-TestCase-2.cpp) +- Assertion: [REQUIRE, CHECK](../examples/030-Asn-Require-Check.cpp) +- Fixture: [Sections](../examples/100-Fix-Section.cpp) +- Fixture: [Class-based fixtures](../examples/110-Fix-ClassFixture.cpp) +- BDD: [SCENARIO, GIVEN, WHEN, THEN](../examples/120-Bdd-ScenarioGivenWhenThen.cpp) +- Listener: [Listeners](../examples/210-Evt-EventListeners.cpp) +- Configuration: [Provide your own output streams](../examples/231-Cfg-OutputStreams.cpp) + +## Planned + +- Assertion: [REQUIRE_THAT and Matchers](../examples/040-Asn-RequireThat.cpp) +- Assertion: [REQUIRE_NO_THROW](../examples/050-Asn-RequireNoThrow.cpp) +- Assertion: [REQUIRE_THROWS](../examples/050-Asn-RequireThrows.cpp) +- Assertion: [REQUIRE_THROWS_AS](../examples/070-Asn-RequireThrowsAs.cpp) +- Assertion: [REQUIRE_THROWS_WITH](../examples/080-Asn-RequireThrowsWith.cpp) +- Assertion: [REQUIRE_THROWS_MATCHES](../examples/090-Asn-RequireThrowsMatches.cpp) +- Floating point: [Approx - Comparisons](../examples/130-Fpt-Approx.cpp) +- Logging: [CAPTURE - Capture expression](../examples/140-Log-Capture.cpp) +- Logging: [INFO - Provide information with failure](../examples/150-Log-Info.cpp) +- Logging: [WARN - Issue warning](../examples/160-Log-Warn.cpp) +- Logging: [FAIL, FAIL_CHECK - Issue message and force failure/continue](../examples/170-Log-Fail.cpp) +- Logging: [SUCCEED - Issue message and continue](../examples/180-Log-Succeed.cpp) +- Report: [User-defined type](../examples/190-Rpt-ReportUserDefinedType.cpp) +- Report: [Reporter](../examples/200-Rpt-UserDefinedReporter.cpp) +- Configuration: [Provide your own main()](../examples/220-Cfg-OwnMain.cpp) +- Configuration: [Compile-time configuration](../examples/230-Cfg-CompileTimeConfiguration.cpp) +- Configuration: [Run-time configuration](../examples/240-Cfg-RunTimeConfiguration.cpp) + +--- + +[Home](Readme.md#top) diff --git a/src/third_party/cppcodec/test/catch/docs/logging.md b/src/third_party/cppcodec/test/catch/docs/logging.md new file mode 100644 index 0000000000..39ae5c7ac3 --- /dev/null +++ b/src/third_party/cppcodec/test/catch/docs/logging.md @@ -0,0 +1,77 @@ + +# Logging macros + +Additional messages can be logged during a test case. Note that the messages are scoped and thus will not be reported if failure occurs in scope preceding the message declaration. An example: + +```cpp +TEST_CASE("Foo") { + INFO("Test case start"); + for (int i = 0; i < 2; ++i) { + INFO("The number is " << i); + CHECK(i == 0); + } +} + +TEST_CASE("Bar") { + INFO("Test case start"); + for (int i = 0; i < 2; ++i) { + INFO("The number is " << i); + CHECK(i == i); + } + CHECK(false); +} +``` +When the `CHECK` fails in the "Foo" test case, then two messages will be printed. +``` +Test case start +The number is 1 +``` +When the last `CHECK` fails in the "Bar" test case, then only one message will be printed: `Test case start`. + + +## Streaming macros + +All these macros allow heterogenous sequences of values to be streaming using the insertion operator (```<<```) in the same way that std::ostream, std::cout, etc support it. + +E.g.: +```c++ +INFO( "The number is " << i ); +``` + +(Note that there is no initial ```<<``` - instead the insertion sequence is placed in parentheses.) +These macros come in three forms: + +**INFO(** _message expression_ **)** + +The message is logged to a buffer, but only reported with the next assertion that is logged. This allows you to log contextual information in case of failures which is not shown during a successful test run (for the console reporter, without -s). Messages are removed from the buffer at the end of their scope, so may be used, for example, in loops. + +**WARN(** _message expression_ **)** + +The message is always reported but does not fail the test. + +**FAIL(** _message expression_ **)** + +The message is reported and the test case fails. + +**FAIL_CHECK(** _message expression_ **)** + +AS `FAIL`, but does not abort the test + +## Quickly capture a variable value + +**CAPTURE(** _expression_ **)** + +Sometimes you just want to log the name and value of a variable. While you can easily do this with the INFO macro, above, as a convenience the CAPTURE macro handles the stringising of the variable name for you (actually it works with any expression, not just variables). + +E.g. +```c++ +CAPTURE( theAnswer ); +``` + +This would log something like: + +
"theAnswer := 42"
+ +--- + +[Home](Readme.md#top) diff --git a/src/third_party/cppcodec/test/catch/docs/matchers.md b/src/third_party/cppcodec/test/catch/docs/matchers.md new file mode 100644 index 0000000000..adbd4ce7bf --- /dev/null +++ b/src/third_party/cppcodec/test/catch/docs/matchers.md @@ -0,0 +1,136 @@ + +# Matchers + +Matchers are an alternative way to do assertions which are easily extensible and composable. +This makes them well suited to use with more complex types (such as collections) or your own custom types. +Matchers were first popularised by the [Hamcrest](https://en.wikipedia.org/wiki/Hamcrest) family of frameworks. + +## In use + +Matchers are introduced with the `REQUIRE_THAT` or `CHECK_THAT` macros, which take two arguments. +The first argument is the thing (object or value) under test. The second part is a match _expression_, +which consists of either a single matcher or one or more matchers combined using `&&`, `||` or `!` operators. + +For example, to assert that a string ends with a certain substring: + + ```c++ +using Catch::Matchers::EndsWith; // or Catch::EndsWith +std::string str = getStringFromSomewhere(); +REQUIRE_THAT( str, EndsWith( "as a service" ) ); + ``` + +The matcher objects can take multiple arguments, allowing more fine tuning. +The built-in string matchers, for example, take a second argument specifying whether the comparison is +case sensitive or not: + +```c++ +REQUIRE_THAT( str, EndsWith( "as a service", Catch::CaseSensitive::No ) ); + ``` + +And matchers can be combined: + +```c++ +REQUIRE_THAT( str, + EndsWith( "as a service" ) || + (StartsWith( "Big data" ) && !Contains( "web scale" ) ) ); +``` + +## Built in matchers +Catch currently provides some matchers, they are in the `Catch::Matchers` and `Catch` namespaces. + +### String matchers +The string matchers are `StartsWith`, `EndsWith`, `Contains`, `Equals` and `Matches`. The first four match a literal (sub)string against a result, while `Matches` takes and matches an ECMAScript regex. Do note that `Matches` matches the string as a whole, meaning that "abc" will not match against "abcd", but "abc.*" will. + +Each of the provided `std::string` matchers also takes an optional second argument, that decides case sensitivity (by-default, they are case sensitive). + + +### Vector matchers +The vector matchers are `Contains`, `VectorContains` and `Equals`. `VectorContains` looks for a single element in the matched vector, `Contains` looks for a set (vector) of elements inside the matched vector. + +### Floating point matchers +The floating point matchers are `WithinULP` and `WithinAbs`. `WithinAbs` accepts floating point numbers that are within a certain margin of target. `WithinULP` performs an [ULP](https://en.wikipedia.org/wiki/Unit_in_the_last_place)-based comparison of two floating point numbers and accepts them if they are less than certain number of ULPs apart. + +Do note that ULP-based checks only make sense when both compared numbers are of the same type and `WithinULP` will use type of its argument as the target type. This means that `WithinULP(1.f, 1)` will expect to compare `float`s, but `WithinULP(1., 1)` will expect to compare `double`s. + + +### Generic matchers +Catch also aims to provide a set of generic matchers. Currently this set +contains only a matcher that takes arbitrary callable predicate and applies +it onto the provided object. + +Because of type inference limitations, the argument type of the predicate +has to be provided explicitly. Example: +```cpp +REQUIRE_THAT("Hello olleH", + Predicate( + [] (std::string const& str) -> bool { return str.front() == str.back(); }, + "First and last character should be equal") +); +``` + +The second argument is an optional description of the predicate, and is +used only during reporting of the result. + + +## Custom matchers +It's easy to provide your own matchers to extend Catch or just to work with your own types. + +You need to provide two things: +1. A matcher class, derived from `Catch::MatcherBase` - where `T` is the type being tested. +The constructor takes and stores any arguments needed (e.g. something to compare against) and you must +override two methods: `match()` and `describe()`. +2. A simple builder function. This is what is actually called from the test code and allows overloading. + +Here's an example for asserting that an integer falls within a given range +(note that it is all inline for the sake of keeping the example short): + +```c++ +// The matcher class +class IntRange : public Catch::MatcherBase { + int m_begin, m_end; +public: + IntRange( int begin, int end ) : m_begin( begin ), m_end( end ) {} + + // Performs the test for this matcher + virtual bool match( int const& i ) const override { + return i >= m_begin && i <= m_end; + } + + // Produces a string describing what this matcher does. It should + // include any provided data (the begin/ end in this case) and + // be written as if it were stating a fact (in the output it will be + // preceded by the value under test). + virtual std::string describe() const { + std::ostringstream ss; + ss << "is between " << m_begin << " and " << m_end; + return ss.str(); + } +}; + +// The builder function +inline IntRange IsBetween( int begin, int end ) { + return IntRange( begin, end ); +} + +// ... + +// Usage +TEST_CASE("Integers are within a range") +{ + CHECK_THAT( 3, IsBetween( 1, 10 ) ); + CHECK_THAT( 100, IsBetween( 1, 10 ) ); +} +``` + +Running this test gives the following in the console: + +``` +/**/TestFile.cpp:123: FAILED: + CHECK_THAT( 100, IsBetween( 1, 10 ) ) +with expansion: + 100 is between 1 and 10 +``` + +--- + +[Home](Readme.md#top) diff --git a/src/third_party/cppcodec/test/catch/docs/opensource-users.md b/src/third_party/cppcodec/test/catch/docs/opensource-users.md new file mode 100644 index 0000000000..86ab82fe4c --- /dev/null +++ b/src/third_party/cppcodec/test/catch/docs/opensource-users.md @@ -0,0 +1,105 @@ + +# Open Source projects using Catch + +Catch is great for open source. With its [liberal license](../LICENSE.txt) and single-header, dependency-free, distribution +it's easy to just drop the header into your project and start writing tests - what's not to like? + +As a result Catch is now being used in many Open Source projects, including some quite well known ones. +This page is an attempt to track those projects. Obviously it can never be complete. +This effort largely relies on the maintainers of the projects themselves updating this page and submitting a PR +(or, if you prefer contact one of the maintainers of Catch directly, use the +[forums](https://groups.google.com/forum/?fromgroups#!forum/catch-forum)), or raise an [issue](https://github.com/philsquared/Catch/issues) to let us know). +Of course users of those projects might want to update this page too. That's fine - as long you're confident the project maintainers won't mind. +If you're an Open Source project maintainer and see your project listed here but would rather it wasn't - +just let us know via any of the previously mentioned means - although I'm sure there won't be many who feel that way. + +Listing a project here does not imply endorsement and the plan is to keep these ordered alphabetically to avoid an implication of relative importance. + +## Libraries & Frameworks + +### [Azmq](https://github.com/zeromq/azmq) +Boost Asio style bindings for ZeroMQ + +### [ChakraCore](https://github.com/Microsoft/ChakraCore) +The core part of the Chakra JavaScript engine that powers Microsoft Edge + +### [ChaiScript](https://github.com/ChaiScript/ChaiScript) +A, header-only, embedded scripting language designed from the ground up to directly target C++ and take advantage of modern C++ development techniques + +### [Clara](https://github.com/philsquared/Clara) +A, single-header-only, type-safe, command line parser - which also prints formatted usage strings. + +### [Couchbase-lite-core](https://github.com/couchbase/couchbase-lite-core) +The next-generation core storage and query engine for Couchbase Lite + +### [DtCraft](https://github.com/twhuang-uiuc/DtCraft) +A High-performance Cluster Computing Engine + +### [forest](https://github.com/xorz57/forest) +Forest is an open-source, template library of tree data structures written in C++11. + +### [Fuxedo](https://github.com/fuxedo/fuxedo) +Open source Oracle Tuxedo-like XATMI middleware for C and C++. + +### [Inja](https://github.com/pantor/inja) +A header-only template engine for modern C++. + +### [JSON for Modern C++](https://github.com/nlohmann/json) +A, single-header, JSON parsing library that takes advantage of what C++ has to offer. + +### [libcluon](https://github.com/chrberger/libcluon) +A single-header-only library written in C++14 to glue distributed software components (UDP, TCP, shared memory) supporting natively Protobuf, LCM/ZCM, MsgPack, and JSON for dynamic message transformations in-between. + +### [MNMLSTC Core](https://github.com/mnmlstc/core) +A small and easy to use C++11 library that adds a functionality set that will be available in C++14 and later, as well as some useful additions. + +### [nanodbc](https://github.com/lexicalunit/nanodbc/) +A small C++ library wrapper for the native C ODBC API. + +### [Nonius](https://github.com/libnonius/nonius) +A header-only framework for benchmarking small snippets of C++ code. + +### [SOCI](https://github.com/SOCI/soci) +The C++ Database Access Library + +### [polymorphic_value](https://github.com/jbcoe/polymorphic_value) +A polymorphic value-type for C++ + +### [Ppconsul](https://github.com/oliora/ppconsul) +A C++ client library for Consul. Consul is a distributed tool for discovering and configuring services in your infrastructure + +### [Reactive-Extensions/ RxCpp](https://github.com/Reactive-Extensions/RxCpp) +A library of algorithms for values-distributed-in-time + +### [TextFlowCpp](https://github.com/philsquared/textflowcpp) +A small, single-header-only, library for wrapping and composing columns of text + +### [Trompeloeil](https://github.com/rollbear/trompeloeil) +A thread safe header only mocking framework for C++14 + +### [args](https://github.com/Taywee/args) +A simple header-only C++ argument parser library. + +## Applications & Tools + +### [ArangoDB](https://github.com/arangodb/arangodb) +ArangoDB is a native multi-model database with flexible data models for documents, graphs, and key-values. + +### [Giada - Your Hardcore Loop Machine](https://github.com/monocasual/giada) +Minimal, open-source and cross-platform audio tool for live music production. + +### [MAME](https://github.com/mamedev/mame) +MAME originally stood for Multiple Arcade Machine Emulator + +### [Newsbeuter](https://github.com/akrennmair/newsbeuter) +Newsbeuter is an open-source RSS/Atom feed reader for text terminals. + +### [SpECTRE](https://github.com/sxs-collaboration/spectre) +SpECTRE is a code for multi-scale, multi-physics problems in astrophysics and gravitational physics. + +### [Standardese](https://github.com/foonathan/standardese) +Standardese aims to be a nextgen Doxygen + +--- + +[Home](Readme.md#top) diff --git a/src/third_party/cppcodec/test/catch/docs/own-main.md b/src/third_party/cppcodec/test/catch/docs/own-main.md new file mode 100644 index 0000000000..c74f9f14e9 --- /dev/null +++ b/src/third_party/cppcodec/test/catch/docs/own-main.md @@ -0,0 +1,125 @@ + +# Supplying main() yourself + +The easiest way to use Catch is to let it supply ```main()``` for you and handle configuring itself from the command line. + +This is achieved by writing ```#define CATCH_CONFIG_MAIN``` before the ```#include "catch.hpp"``` in *exactly one* source file. + +Sometimes, though, you need to write your own version of main(). You can do this by writing ```#define CATCH_CONFIG_RUNNER``` instead. Now you are free to write ```main()``` as normal and call into Catch yourself manually. + +You now have a lot of flexibility - but here are three recipes to get your started: + +## Let Catch take full control of args and config + +If you just need to have code that executes before and/ or after Catch this is the simplest option. + +```c++ +#define CATCH_CONFIG_RUNNER +#include "catch.hpp" + +int main( int argc, char* argv[] ) { + // global setup... + + int result = Catch::Session().run( argc, argv ); + + // global clean-up... + + return result; +} +``` + +## Amending the config + +If you still want Catch to process the command line, but you want to programmatically tweak the config, you can do so in one of two ways: + +```c++ +#define CATCH_CONFIG_RUNNER +#include "catch.hpp" + +int main( int argc, char* argv[] ) +{ + Catch::Session session; // There must be exactly one instance + + // writing to session.configData() here sets defaults + // this is the preferred way to set them + + int returnCode = session.applyCommandLine( argc, argv ); + if( returnCode != 0 ) // Indicates a command line error + return returnCode; + + // writing to session.configData() or session.Config() here + // overrides command line args + // only do this if you know you need to + + int numFailed = session.run(); + + // numFailed is clamped to 255 as some unices only use the lower 8 bits. + // This clamping has already been applied, so just return it here + // You can also do any post run clean-up here + return numFailed; +} +``` + +Take a look at the definitions of Config and ConfigData to see what you can do with them. + +To take full control of the config simply omit the call to ```applyCommandLine()```. + +## Adding your own command line options + +Catch embeds a powerful command line parser called [Clara](https://github.com/philsquared/Clara). +As of Catch2 (and Clara 1.0) Clara allows you to write _composable_ option and argument parsers, +so extending Catch's own command line options is now easy. + +```c++ +#define CATCH_CONFIG_RUNNER +#include "catch.hpp" + +int main( int argc, char* argv[] ) +{ + Catch::Session session; // There must be exactly one instance + + int height = 0; // Some user variable you want to be able to set + + // Build a new parser on top of Catch's + using namespace Catch::clara; + auto cli + = session.cli() // Get Catch's composite command line parser + | Opt( height, "height" ) // bind variable to a new option, with a hint string + ["-g"]["--height"] // the option names it will respond to + ("how high?"); // description string for the help output + + // Now pass the new composite back to Catch so it uses that + session.cli( cli ); + + // Let Catch (using Clara) parse the command line + int returnCode = session.applyCommandLine( argc, argv ); + if( returnCode != 0 ) // Indicates a command line error + return returnCode; + + // if set on the command line then 'height' is now set at this point + if( height > 0 ) + std::cout << "height: " << height << std::endl; + + return session.run(); +} +``` + +See the [Clara documentation](https://github.com/philsquared/Clara/blob/master/README.md) for more details. + + +## Version detection + +Catch provides a triplet of macros providing the header's version, + +* `CATCH_VERSION_MAJOR` +* `CATCH_VERSION_MINOR` +* `CATCH_VERSION_PATCH` + +these macros expand into a single number, that corresponds to the appropriate +part of the version. As an example, given single header version v2.3.4, +the macros would expand into `2`, `3`, and `4` respectively. + + +--- + +[Home](Readme.md#top) diff --git a/src/third_party/cppcodec/test/catch/docs/release-notes.md b/src/third_party/cppcodec/test/catch/docs/release-notes.md new file mode 100644 index 0000000000..e40be99c09 --- /dev/null +++ b/src/third_party/cppcodec/test/catch/docs/release-notes.md @@ -0,0 +1,624 @@ + + +# 2.3.0 + +**This release changes the include paths provided by our CMake and +pkg-config integration. The proper include path for the single-header +when using one of the above is now ``. This change +also necessitated changes to paths inside the repository, so that the +single-header version is now at `single_include/catch2/catch.hpp`, rather +than `single_include/catch.hpp`.** + + + +## Fixes +* Fixed Objective-C++ build +* `-Wunused-variable` suppression no longer leaks from Catch's header under Clang +* Implementation of the experimental new output capture can now be disabled (#1335) + * This allows building Catch2 on platforms that do not provide things like `dup` or `tmpfile`. +* The JUnit and XML reporters will no longer skip over successful tests when running without `-s` (#1264, #1267, #1310) + * See improvements for more details + +## Improvements +* pkg-config and CMake integration has been rewritten + * If you use them, the new include path is `#include ` + * CMake installation now also installs scripts from `contrib/` + * For details see the [new documentation](cmake-integration.md#top) +* Reporters now have a new customization point, `ReporterPreferences::shouldReportAllAssertions` + * When this is set to `false` and the tests are run without `-s`, passing assertions are not sent to the reporter. + * Defaults to `false`. +* Added `DYNAMIC_SECTION`, a section variant that constructs its name using stream + * This means that you can do `DYNAMIC_SECTION("For X := " << x)`. + + +# 2.2.3 + +**To fix some of the bugs, some behavior had to change in potentially breaking manner.** +**This means that even though this is a patch release, it might not be a drop-in replacement.** + +## Fixes +* Listeners are now called before reporter + * This was always documented to be the case, now it actually works that way +* Catch's commandline will no longer accept multiple reporters + * This was done because multiple reporters never worked properly and broke things in non-obvious ways + * **This has potential to be a breaking change** +* MinGW is now detected as Windows platform w/o SEH support (#1257) + * This means that Catch2 no longer tries to use POSIX signal handling when compiled with MinGW +* Fixed potential UB in parsing tags using non-ASCII characters (#1266) + * Note that Catch2 still supports only ASCII test names/tags/etc +* `TEST_CASE_METHOD` can now be used on classnames containing commas (#1245) + * You have to enclose the classname in extra set of parentheses +* Fixed insufficient alt stack size for POSIX signal handling (#1225) +* Fixed compilation error on Android due to missing `std::to_string` in C++11 mode (#1280) +* Fixed the order of user-provided `FALLBACK_STRINGIFIER` in stringification machinery (#1024) + * It was intended to be replacement for built-in fallbacks, but it was used _after_ them. + * **This has potential to be a breaking change** +* Fixed compilation error when a type has an `operator<<` with templated lhs (#1285, #1306) + +## Improvements +* Added a new, experimental, output capture (#1243) + * This capture can also redirect output written via C apis, e.g. `printf` + * To opt-in, define `CATCH_CONFIG_EXPERIMENTAL_REDIRECT` in the implementation file +* Added a new fallback stringifier for classes derived from `std::exception` + * Both `StringMaker` specialization and `operator<<` overload are given priority + +## Miscellaneous +* `contrib/` now contains dbg scripts that skip over Catch's internals (#904, #1283) + * `gdbinit` for gdb `lldbinit` for lldb +* `CatchAddTests.cmake` no longer strips whitespace from tests (#1265, #1281) +* Online documentation now describes `--use-colour` option (#1263) + + +# 2.2.2 + +## Fixes +* Fixed bug in `WithinAbs::match()` failing spuriously (#1228) +* Fixed clang-tidy diagnostic about virtual call in destructor (#1226) +* Reduced the number of GCC warnings suppression leaking out of the header (#1090, #1091) + * Only `-Wparentheses` should be leaking now +* Added upper bound on the time benchmark timer calibration is allowed to take (#1237) + * On platforms where `std::chrono::high_resolution_clock`'s resolution is low, the calibration would appear stuck +* Fixed compilation error when stringifying static arrays of `unsigned char`s (#1238) + +## Improvements +* XML encoder now hex-encodes invalid UTF-8 sequences (#1207) + * This affects xml and junit reporters + * Some invalid UTF-8 parts are left as is, e.g. surrogate pairs. This is because certain extensions of UTF-8 allow them, such as WTF-8. +* CLR objects (`T^`) can now be stringified (#1216) + * This affects code compiled as C++/CLI +* Added `PredicateMatcher`, a matcher that takes an arbitrary predicate function (#1236) + * See [documentation for details](https://github.com/catchorg/Catch2/blob/master/docs/matchers.md) + +## Others +* Modified CMake-installed pkg-config to allow `#include `(#1239) + * The plans to standardize on `#include ` are still in effect + + +# 2.2.1 + +## Fixes +* Fixed compilation error when compiling Catch2 with `std=c++17` against libc++ (#1214) + * Clara (Catch2's CLI parsing library) used `std::optional` without including it explicitly +* Fixed Catch2 return code always being 0 (#1215) + * In the words of STL, "We feel superbad about letting this in" + + +# 2.2.0 + +## Fixes +* Hidden tests are not listed by default when listing tests (#1175) + * This makes `catch_discover_tests` CMake script work better +* Fixed regression that meant `` could potentially not be included properly (#1197) +* Fixed installing `Catch2ConfigVersion.cmake` when Catch2 is a subproject. + +## Improvements +* Added an option to warn (+ exit with error) when no tests were ran (#1158) + * Use as `-w NoTests` +* Added provisional support for Emscripten (#1114) +* [Added a way to override the fallback stringifier](https://github.com/catchorg/Catch2/blob/master/docs/configuration.md#fallback-stringifier) (#1024) + * This allows project's own stringification machinery to be easily reused for Catch +* `Catch::Session::run()` now accepts `char const * const *`, allowing it to accept array of string literals (#1031, #1178) + * The embedded version of Clara was bumped to v1.1.3 +* Various minor performance improvements +* Added support for DJGPP DOS crosscompiler (#1206) + + +# 2.1.2 + +## Fixes +* Fixed compilation error with `-fno-rtti` (#1165) +* Fixed NoAssertion warnings +* `operator<<` is used before range-based stringification (#1172) +* Fixed `-Wpedantic` warnings (extra semicolons and binary literals) (#1173) + + +## Improvements +* Added `CATCH_VERSION_{MAJOR,MINOR,PATCH}` macros (#1131) +* Added `BrightYellow` colour for use in reporters (#979) + * It is also used by ConsoleReporter for reconstructed expressions + +## Other changes +* Catch is now exported as a CMake package and linkable target (#1170) + +# 2.1.1 + +## Improvements +* Static arrays are now properly stringified like ranges across MSVC/GCC/Clang +* Embedded newer version of Clara -- v1.1.1 + * This should fix some warnings dragged in from Clara +* MSVC's CLR exceptions are supported + + +## Fixes +* Fixed compilation when comparison operators do not return bool (#1147) +* Fixed CLR exceptions blowing up the executable during translation (#1138) + + +## Other changes +* Many CMake changes + * `NO_SELFTEST` option is deprecated, use `BUILD_TESTING` instead. + * Catch specific CMake options were prefixed with `CATCH_` for namespacing purposes + * Other changes to simplify Catch2's packaging + + + +# 2.1.0 + +## Improvements +* Various performance improvements + * On top of the performance regression fixes +* Experimental support for PCH was added (#1061) +* `CATCH_CONFIG_EXTERNAL_INTERFACES` now brings in declarations of Console, Compact, XML and JUnit reporters +* `MatcherBase` no longer has a pointless second template argument +* Reduced the number of warning suppressions that leak into user's code + * Bugs in g++ 4.x and 5.x mean that some of them have to be left in + + +## Fixes +* Fixed performance regression from Catch classic + * One of the performance improvement patches for Catch classic was not applied to Catch2 +* Fixed platform detection for iOS (#1084) +* Fixed compilation when `g++` is used together with `libc++` (#1110) +* Fixed TeamCity reporter compilation with the single header version + * To fix the underlying issue we will be versioning reporters in single_include folder per release +* The XML reporter will now report `WARN` messages even when not used with `-s` +* Fixed compilation when `VectorContains` matcher was combined using `&&` (#1092) +* Fixed test duration overflowing after 10 seconds (#1125, #1129) +* Fixed `std::uncaught_exception` deprecation warning (#1124) + + +## New features +* New Matchers + * Regex matcher for strings, `Matches`. + * Set-equal matcher for vectors, `UnorderedEquals` + * Floating point matchers, `WithinAbs` and `WithinULP`. +* Stringification now attempts to decompose all containers (#606) + * Containers are objects that respond to ADL `begin(T)` and `end(T)`. + + +## Other changes +* Reporters will now be versioned in the `single_include` folder to ensure their compatibility with the last released version + + + + +# 2.0.1 + +## Breaking changes +* Removed C++98 support +* Removed legacy reporter support +* Removed legacy generator support + * Generator support will come back later, reworked +* Removed `Catch::toString` support + * The new stringification machinery uses `Catch::StringMaker` specializations first and `operator<<` overloads second. +* Removed legacy `SCOPED_MSG` and `SCOPED_INFO` macros +* Removed `INTERNAL_CATCH_REGISTER_REPORTER` + * `CATCH_REGISTER_REPORTER` should be used to register reporters +* Removed legacy `[hide]` tag + * `[.]`, `[.foo]` and `[!hide]` are still supported +* Output into debugger is now colourized +* `*_THROWS_AS(expr, exception_type)` now unconditionally appends `const&` to the exception type. +* `CATCH_CONFIG_FAST_COMPILE` now affects the `CHECK_` family of assertions as well as `REQUIRE_` family of assertions + * This is most noticeable in `CHECK(throws())`, which would previously report failure, properly stringify the exception and continue. Now it will report failure and stop executing current section. +* Removed deprecated matcher utility functions `Not`, `AllOf` and `AnyOf`. + * They are superseded by operators `!`, `&&` and `||`, which are natural and do not have limited arity +* Removed support for non-const comparison operators + * Non-const comparison operators are an abomination that should not exist + * They were breaking support for comparing function to function pointer +* `std::pair` and `std::tuple` are no longer stringified by default + * This is done to avoid dragging in `` and `` headers in common path + * Their stringification can be enabled per-file via new configuration macros +* `Approx` is subtly different and hopefully behaves more as users would expect + * `Approx::scale` defaults to `0.0` + * `Approx::epsilon` no longer applies to the larger of the two compared values, but only to the `Approx`'s value + * `INFINITY == Approx(INFINITY)` returns true + + +## Improvements +* Reporters and Listeners can be defined in files different from the main file + * The file has to define `CATCH_CONFIG_EXTERNAL_INTERFACES` before including catch.hpp. +* Errors that happen during set up before main are now caught and properly reported once main is entered + * If you are providing your own main, you can access and use these as well. +* New assertion macros, *_THROWS_MATCHES(expr, exception_type, matcher) are provided + * As the arguments suggest, these allow you to assert that an expression throws desired type of exception and pass the exception to a matcher. +* JUnit reporter no longer has significantly different output for test cases with and without sections +* Most assertions now support expressions containing commas (ie `REQUIRE(foo() == std::vector{1, 2, 3});`) +* Catch now contains experimental micro benchmarking support + * See `projects/SelfTest/Benchmark.tests.cpp` for examples + * The support being experiment means that it can be changed without prior notice +* Catch uses new CLI parsing library (Clara) + * Users can now easily add new command line options to the final executable + * This also leads to some changes in `Catch::Session` interface +* All parts of matchers can be removed from a TU by defining `CATCH_CONFIG_DISABLE_MATCHERS` + * This can be used to somewhat speed up compilation times +* An experimental implementation of `CATCH_CONFIG_DISABLE` has been added + * Inspired by Doctest's `DOCTEST_CONFIG_DISABLE` + * Useful for implementing tests in source files + * ie for functions in anonymous namespaces + * Removes all assertions + * Prevents `TEST_CASE` registrations + * Exception translators are not registered + * Reporters are not registered + * Listeners are not registered +* Reporters/Listeners are now notified of fatal errors + * This means specific signals or structured exceptions + * The Reporter/Listener interface provides default, empty, implementation to preserve backward compatibility +* Stringification of `std::chrono::duration` and `std::chrono::time_point` is now supported + * Needs to be enabled by a per-file compile time configuration option +* Add `pkg-config` support to CMake install command + + +## Fixes +* Don't use console colour if running in XCode +* Explicit constructor in reporter base class +* Swept out `-Wweak-vtables`, `-Wexit-time-destructors`, `-Wglobal-constructors` warnings +* Compilation for Universal Windows Platform (UWP) is supported + * SEH handling and colorized output are disabled when compiling for UWP +* Implemented a workaround for `std::uncaught_exception` issues in libcxxrt + * These issues caused incorrect section traversals + * The workaround is only partial, user's test can still trigger the issue by using `throw;` to rethrow an exception +* Suppressed C4061 warning under MSVC + + +## Internal changes +* The development version now uses .cpp files instead of header files containing implementation. + * This makes partial rebuilds much faster during development +* The expression decomposition layer has been rewritten +* The evaluation layer has been rewritten +* New library (TextFlow) is used for formatting text to output + + +# Older versions + +## 1.11.x + +### 1.11.0 + +#### Fixes +* The original expression in `REQUIRE_FALSE( expr )` is now reporter properly as `!( expr )` (#1051) + * Previously the parentheses were missing and `x != y` would be expanded as `!x != x` +* `Approx::Margin` is now inclusive (#952) + * Previously it was meant and documented as inclusive, but the check itself wasn't + * This means that `REQUIRE( 0.25f == Approx( 0.0f ).margin( 0.25f ) )` passes, instead of fails +* `RandomNumberGenerator::result_type` is now unsigned (#1050) + +#### Improvements +* `__JETBRAINS_IDE__` macro handling is now CLion version specific (#1017) + * When CLion 2017.3 or newer is detected, `__COUNTER__` is used instead of +* TeamCity reporter now explicitly flushes output stream after each report (#1057) + * On some platforms, output from redirected streams would show up only after the tests finished running +* `ParseAndAddCatchTests` now can add test files as dependency to CMake configuration + * This means you do not have to manually rerun CMake configuration step to detect new tests + +## 1.10.x + +### 1.10.0 + +#### Fixes +* Evaluation layer has been rewritten (backported from Catch 2) + * The new layer is much simpler and fixes some issues (#981) +* Implemented workaround for VS 2017 raw string literal stringification bug (#995) +* Fixed interaction between `[!shouldfail]` and `[!mayfail]` tags and sections + * Previously sections with failing assertions would be marked as failed, not failed-but-ok + +#### Improvements +* Added [libidentify](https://github.com/janwilmans/LibIdentify) support +* Added "wait-for-keypress" option + +## 1.9.x + +### 1.9.6 + +#### Improvements +* Catch's runtime overhead has been significantly decreased (#937, #939) +* Added `--list-extra-info` cli option (#934). + * It lists all tests together with extra information, ie filename, line number and description. + + + +### 1.9.5 + +#### Fixes +* Truthy expressions are now reconstructed properly, not as booleans (#914) +* Various warnings are no longer erroneously suppressed in test files (files that include `catch.hpp`, but do not define `CATCH_CONFIG_MAIN` or `CATCH_CONFIG_RUNNER`) (#871) +* Catch no longer fails to link when main is compiled as C++, but linked against Objective-C (#855) +* Fixed incorrect gcc version detection when deciding to use `__COUNTER__` (#928) + * Previously any GCC with minor version less than 3 would be incorrectly classified as not supporting `__COUNTER__`. +* Suppressed C4996 warning caused by upcoming updated to MSVC 2017, marking `std::uncaught_exception` as deprecated. (#927) + +#### Improvements +* CMake integration script now incorporates debug messages and registers tests in an improved way (#911) +* Various documentation improvements + + + +### 1.9.4 + +#### Fixes +* `CATCH_FAIL` macro no longer causes compilation error without variadic macro support +* `INFO` messages are no longer cleared after being reported once + +#### Improvements and minor changes +* Catch now uses `wmain` when compiled under Windows and `UNICODE` is defined. + * Note that Catch still officially supports only ASCII + +### 1.9.3 + +#### Fixes +* Completed the fix for (lack of) uint64_t in earlier Visual Studios + +### 1.9.2 + +#### Improvements and minor changes +* All of `Approx`'s member functions now accept strong typedefs in C++11 mode (#888) + * Previously `Approx::scale`, `Approx::epsilon`, `Approx::margin` and `Approx::operator()` didn't. + + +#### Fixes +* POSIX signals are now disabled by default under QNX (#889) + * QNX does not support current enough (2001) POSIX specification +* JUnit no longer counts exceptions as failures if given test case is marked as ok to fail. +* `Catch::Option` should now have its storage properly aligned. +* Catch no longer attempts to define `uint64_t` on windows (#862) + * This was causing trouble when compiled under Cygwin + +#### Other +* Catch is now compiled under MSVC 2017 using `std:c++latest` (C++17 mode) in CI +* We now provide cmake script that autoregisters Catch tests into ctest. + * See `contrib` folder. + + +### 1.9.1 + +#### Fixes +* Unexpected exceptions are no longer ignored by default (#885, #887) + + +### 1.9.0 + + +#### Improvements and minor changes +* Catch no longer attempts to ensure the exception type passed by user in `REQUIRE_THROWS_AS` is a constant reference. + * It was causing trouble when `REQUIRE_THROWS_AS` was used inside templated functions + * This actually reverts changes made in v1.7.2 +* Catch's `Version` struct should no longer be double freed when multiple instances of Catch tests are loaded into single program (#858) + * It is now a static variable in an inline function instead of being an `extern`ed struct. +* Attempt to register invalid tag or tag alias now throws instead of calling `exit()`. + * Because this happen before entering main, it still aborts execution + * Further improvements to this are coming +* `CATCH_CONFIG_FAST_COMPILE` now speeds-up compilation of `REQUIRE*` assertions by further ~15%. + * The trade-off is disabling translation of unexpected exceptions into text. +* When Catch is compiled using C++11, `Approx` is now constructible with anything that can be explicitly converted to `double`. +* Captured messages are now printed on unexpected exceptions + +#### Fixes: +* Clang's `-Wexit-time-destructors` should be suppressed for Catch's internals +* GCC's `-Wparentheses` is now suppressed for all TU's that include `catch.hpp`. + * This is functionally a revert of changes made in 1.8.0, where we tried using `_Pragma` based suppression. This should have kept the suppression local to Catch's assertions, but bugs in GCC's handling of `_Pragma`s in C++ mode meant that it did not always work. +* You can now tell Catch to use C++11-based check when checking whether a type can be streamed to output. + * This fixes cases when an unstreamable type has streamable private base (#877) + * [Details can be found in documentation](configuration.md#catch_config_cpp11_stream_insertable_check) + + +#### Other notes: +* We have added VS 2017 to our CI +* Work on Catch 2 should start soon + + + +## 1.8.x + +### 1.8.2 + + +#### Improvements and minor changes +* TAP reporter now behaves as if `-s` was always set + * This should be more consistent with the protocol desired behaviour. +* Compact reporter now obeys `-d yes` argument (#780) + * The format is "XXX.123 s: " (3 decimal places are always present). + * Before it did not report the durations at all. +* XML reporter now behaves the same way as Console reporter in regards to `INFO` + * This means it reports `INFO` messages on success, if output on success (`-s`) is enabled. + * Previously it only reported `INFO` messages on failure. +* `CAPTURE(expr)` now stringifies `expr` in the same way assertion macros do (#639) +* Listeners are now finally [documented](event-listeners.md#top). + * Listeners provide a way to hook into events generated by running your tests, including start and end of run, every test case, every section and every assertion. + + +#### Fixes: +* Catch no longer attempts to reconstruct expression that led to a fatal error (#810) + * This fixes possible signal/SEH loop when processing expressions, where the signal was triggered by expression decomposition. +* Fixed (C4265) missing virtual destructor warning in Matchers (#844) +* `std::string`s are now taken by `const&` everywhere (#842). + * Previously some places were taking them by-value. +* Catch should no longer change errno (#835). + * This was caused by libstdc++ bug that we now work around. +* Catch now provides `FAIL_CHECK( ... )` macro (#765). + * Same as `FAIL( ... )`, but does not abort the test. +* Functions like `fabs`, `tolower`, `memset`, `isalnum` are now used with `std::` qualification (#543). +* Clara no longer assumes first argument (binary name) is always present (#729) + * If it is missing, empty string is used as default. +* Clara no longer reads 1 character past argument string (#830) +* Regression in Objective-C bindings (Matchers) fixed (#854) + + +#### Other notes: +* We have added VS 2013 and 2015 to our CI +* Catch Classic (1.x.x) now contains its own, forked, version of Clara (the argument parser). + + + +### 1.8.1 + +#### Fixes + +Cygwin issue with `gettimeofday` - `#define` was not early enough + +### 1.8.0 + +#### New features/ minor changes + +* Matchers have new, simpler (and documented) interface. + * Catch provides string and vector matchers. + * For details see [Matchers documentation](matchers.md#top). +* Changed console reporter test duration reporting format (#322) + * Old format: `Some simple comparisons between doubles completed in 0.000123s` + * New format: `xxx.123s: Some simple comparisons between doubles` _(There will always be exactly 3 decimal places)_ +* Added opt-in leak detection under MSVC + Windows (#439) + * Enable it by compiling Catch's main with `CATCH_CONFIG_WINDOWS_CRTDBG` +* Introduced new compile-time flag, `CATCH_CONFIG_FAST_COMPILE`, trading features for compilation speed. + * Moves debug breaks out of tests and into implementation, speeding up test compilation time (~10% on linux). + * _More changes are coming_ +* Added [TAP (Test Anything Protocol)](https://testanything.org/) and [Automake](https://www.gnu.org/software/automake/manual/html_node/Log-files-generation-and-test-results-recording.html#Log-files-generation-and-test-results-recording) reporters. + * These are not present in the default single-include header and need to be downloaded from GitHub separately. + * For details see [documentation about integrating with build systems](build-systems.md#top). +* XML reporter now reports filename as part of the `Section` and `TestCase` tags. +* `Approx` now supports an optional margin of absolute error + * It has also received [new documentation](assertions.md#top). + +#### Fixes +* Silenced C4312 ("conversion from int to 'ClassName *") warnings in the evaluate layer. +* Fixed C4512 ("assignment operator could not be generated") warnings under VS2013. +* Cygwin compatibility fixes + * Signal handling is no longer compiled by default. + * Usage of `gettimeofday` inside Catch should no longer cause compilation errors. +* Improved `-Wparentheses` suppression for gcc (#674) + * When compiled with gcc 4.8 or newer, the suppression is localized to assertions only + * Otherwise it is supressed for the whole TU +* Fixed test spec parser issue (with escapes in multiple names) + +#### Other +* Various documentation fixes and improvements + + +## 1.7.x + +### 1.7.2 + +#### Fixes and minor improvements +Xml: + +(technically the first two are breaking changes but are also fixes and arguably break few if any people) +* C-escape control characters instead of XML encoding them (which requires XML 1.1) +* Revert XML output to XML 1.0 +* Can provide stylesheet references by extending the XML reporter +* Added description and tags attributes to XML Reporter +* Tags are closed and the stream flushed more eagerly to avoid stdout interpolation + + +Other: +* `REQUIRE_THROWS_AS` now catches exception by `const&` and reports expected type +* In `SECTION`s the file/ line is now of the `SECTION`. not the `TEST_CASE` +* Added std:: qualification to some functions from C stdlib +* Removed use of RTTI (`dynamic_cast`) that had crept back in +* Silenced a few more warnings in different circumstances +* Travis improvements + +### 1.7.1 + +#### Fixes: +* Fixed inconsistency in defining `NOMINMAX` and `WIN32_LEAN_AND_MEAN` inside `catch.hpp`. +* Fixed SEH-related compilation error under older MinGW compilers, by making Windows SEH handling opt-in for compilers other than MSVC. + * For specifics, look into the [documentation](configuration.md#top). +* Fixed compilation error under MinGW caused by improper compiler detection. +* Fixed XML reporter sometimes leaving an empty output file when a test ends with signal/structured exception. +* Fixed XML reporter not reporting captured stdout/stderr. +* Fixed possible infinite recursion in Windows SEH. +* Fixed possible compilation error caused by Catch's operator overloads being ambiguous in regards to user-defined templated operators. + +### 1.7.0 + +#### Features/ Changes: +* Catch now runs significantly faster for passing tests + * Microbenchmark focused on Catch's overhead went from ~3.4s to ~0.7s. + * Real world test using [JSON for Modern C++](https://github.com/nlohmann/json)'s test suite went from ~6m 25s to ~4m 14s. +* Catch can now run specific sections within test cases. + * For now the support is only basic (no wildcards or tags), for details see the [documentation](command-line.md#top). +* Catch now supports SEH on Windows as well as signals on Linux. + * After receiving a signal, Catch reports failing assertion and then passes the signal onto the previous handler. +* Approx can be used to compare values against strong typedefs (available in C++11 mode only). + * Strong typedefs mean types that are explicitly convertible to double. +* CHECK macro no longer stops executing section if an exception happens. +* Certain characters (space, tab, etc) are now pretty printed. + * This means that a `char c = ' '; REQUIRE(c == '\t');` would be printed as `' ' == '\t'`, instead of ` == 9`. + +#### Fixes: +* Text formatting no longer attempts to access out-of-bounds characters under certain conditions. +* THROW family of assertions no longer trigger `-Wunused-value` on expressions containing explicit cast. +* Breaking into debugger under OS X works again and no longer required `DEBUG` to be defined. +* Compilation no longer breaks under certain compiler if a lambda is used inside assertion macro. + +#### Other: +* Catch's CMakeLists now defines install command. +* Catch's CMakeLists now generates projects with warnings enabled. + + +## 1.6.x + +### 1.6.1 + +#### Features/ Changes: +* Catch now supports breaking into debugger on Linux + +#### Fixes: +* Generators no longer leak memory (generators are still unsupported in general) +* JUnit reporter now reports UTC timestamps, instead of "tbd" +* `CHECK_THAT` macro is now properly defined as `CATCH_CHECK_THAT` when using `CATCH_` prefixed macros + +#### Other: +* Types with overloaded `&&` operator are no longer evaluated twice when used in an assertion macro. +* The use of `__COUNTER__` is supressed when Catch is parsed by CLion + * This change is not active when compiling a binary +* Approval tests can now be run on Windows +* CMake will now warn if a file is present in the `include` folder but not is not enumerated as part of the project +* Catch now defines `NOMINMAX` and `WIN32_LEAN_AND_MEAN` before including `windows.h` + * This can be disabled if needed, see [documentation](configuration.md#top) for details. + + +### 1.6.0 + +#### Cmake/ projects: +* Moved CMakeLists.txt to root, made it friendlier for CLion and generating XCode and VS projects, and removed the manually maintained XCode and VS projects. + +#### Features/ Changes: +* Approx now supports `>=` and `<=` +* Can now use `\` to escape chars in test names on command line +* Standardize C++11 feature toggles + +#### Fixes: +* Blue shell colour +* Missing argument to `CATCH_CHECK_THROWS` +* Don't encode extended ASCII in XML +* use `std::shuffle` on more compilers (fixes deprecation warning/error) +* Use `__COUNTER__` more consistently (where available) + +#### Other: +* Tweaks and changes to scripts - particularly for Approval test - to make them more portable + + +# Even Older versions +Release notes were not maintained prior to v1.6.0, but you should be able to work them out from the Git history + +--- + +[Home](Readme.md#top) diff --git a/src/third_party/cppcodec/test/catch/docs/release-process.md b/src/third_party/cppcodec/test/catch/docs/release-process.md new file mode 100644 index 0000000000..b556c3990c --- /dev/null +++ b/src/third_party/cppcodec/test/catch/docs/release-process.md @@ -0,0 +1,53 @@ + +# How to release + +When enough changes have accumulated, it is time to release new version of Catch. This document describes the process in doing so, that no steps are forgotten. Note that all referenced scripts can be found in the `scripts/` directory. + +## Necessary steps + +These steps are necessary and have to be performed before each new release. They serve to make sure that the new release is correct and linked-to from the standard places. + + +### Approval testing + +Catch's releases are primarily validated against output from previous release, stored in `projects/SelfTest/Baselines`. To validate current sources, build the SelfTest binary and pass it to the `approvalTests.py` script: `approvalTests.py `. + +There should be no differences, as Approval tests should be updated when changes to Catch are made, but if there are, then they need to be manually reviewed and either approved (using `approve.py`) or Catch requires other fixes. + + +### Incrementing version number + +Catch uses a variant of [semantic versioning](http://semver.org/), with breaking API changes (and thus major version increments) being very rare. Thus, the release will usually increment the patch version, when it only contains couple of bugfixes, or minor version, when it contains new functionality, or larger changes in implementation of current functionality. + +After deciding which part of version number should be incremented, you can use one of the `*Release.py` scripts to perform the required changes to Catch. + +This will take care of generating the single include header, updating +version numbers everywhere and pushing the new version to Wandbox. + + +### Release notes + +Once a release is ready, release notes need to be written. They should summarize changes done since last release. For rough idea of expected notes see previous releases. Once written, release notes should be placed in `docs/release-notes.md`. + + +### Commit and push update to GitHub + +After version number is incremented, single-include header is regenerated and release notes are updated, changes should be commited and pushed to GitHub. + + +### Release on GitHub + +After pushing changes to GitHub, GitHub release *needs* to be created. +Tag version and release title should be same as the new version, +description should contain the release notes for the current release. +Single header version of `catch.hpp` *needs* to be attached as a binary, +as that is where the official download link links to. Preferably +it should use linux line endings. All non-bundled reporters (Automake, +TAP, TeamCity) should also be attached as binaries, as they are dependent +on a specific version of the single-include header. + + +## Optional steps + +Because Catch's [vcpkg](https://github.com/Microsoft/vcpkg) port updates +itself automagically, there are no optional steps at this time. diff --git a/src/third_party/cppcodec/test/catch/docs/reporters.md b/src/third_party/cppcodec/test/catch/docs/reporters.md new file mode 100644 index 0000000000..78e78ee925 --- /dev/null +++ b/src/third_party/cppcodec/test/catch/docs/reporters.md @@ -0,0 +1,46 @@ + +# Reporters + +Catch has a modular reporting system and comes bundled with a handful of useful reporters built in. +You can also write your own reporters. + +## Using different reporters + +The reporter to use can easily be controlled from the command line. +To specify a reporter use [`-r` or `--reporter`](command-line.md#choosing-a-reporter-to-use), followed by the name of the reporter, e.g.: + +``` +-r xml +``` + +If you don't specify a reporter then the console reporter is used by default. +There are four reporters built in to the single include: + +* `console` writes as lines of text, formatted to a typical terminal width, with colours if a capable terminal is detected. +* `compact` similar to `console` but optimised for minimal output - each entry on one line +* `junit` writes xml that corresponds to Ant's [junitreport](http://help.catchsoftware.com/display/ET/JUnit+Format) target. Useful for build systems that understand Junit. +Because of the way the junit format is structured the run must complete before anything is written. +* `xml` writes an xml format tailored to Catch. Unlike `junit` this is a streaming format so results are delivered progressively. + +There are a few additional reporters, for specific build systems, in the Catch repository (in `include\reporters`) which you can `#include` in your project if you would like to make use of them. +Do this in one source file - the same one you have `CATCH_CONFIG_MAIN` or `CATCH_CONFIG_RUNNER`. + +* `teamcity` writes the native, streaming, format that [TeamCity](https://www.jetbrains.com/teamcity/) understands. +Use this when building as part of a TeamCity build to see results as they happen. +* `tap` writes in the TAP ([Test Anything Protocol](https://en.wikipedia.org/wiki/Test_Anything_Protocol)) format. +* `automake` writes in a format that correspond to [automake .trs](https://www.gnu.org/software/automake/manual/html_node/Log-files-generation-and-test-results-recording.html) files + +You see what reporters are available from the command line by running with `--list-reporters`. + +By default all these reports are written to stdout, but can be redirected to a file with [`-o` or `--out`](command-line.md#sending-output-to-a-file) + +## Writing your own reporter + +You can write your own custom reporter and register it with Catch. +At time of writing the interface is subject to some changes so is not, yet, documented here. +If you are determined you shouldn't have too much trouble working it out from the existing implementations - +but do keep in mind upcoming changes (these will be minor, simplifying, changes such as not needing to forward calls to the base class). + +--- + +[Home](Readme.md#top) diff --git a/src/third_party/cppcodec/test/catch/docs/slow-compiles.md b/src/third_party/cppcodec/test/catch/docs/slow-compiles.md new file mode 100644 index 0000000000..0853b66198 --- /dev/null +++ b/src/third_party/cppcodec/test/catch/docs/slow-compiles.md @@ -0,0 +1,71 @@ + +# Why do my tests take so long to compile? + +**Contents**
+[Short answer](#short-answer)
+[Long answer](#long-answer)
+[Practical example](#practical-example)
+[Other possible solutions](#other-possible-solutions)
+ +Several people have reported that test code written with Catch takes much longer to compile than they would expect. Why is that? + +Catch is implemented entirely in headers. There is a little overhead due to this - but not as much as you might think - and you can minimise it simply by organising your test code as follows: + +## Short answer +Exactly one source file must ```#define``` either ```CATCH_CONFIG_MAIN``` or ```CATCH_CONFIG_RUNNER``` before ```#include```-ing Catch. In this file *do not write any test cases*! In most cases that means this file will just contain two lines (the ```#define``` and the ```#include```). + +## Long answer + +Usually C++ code is split between a header file, containing declarations and prototypes, and an implementation file (.cpp) containing the definition, or implementation, code. Each implementation file, along with all the headers that it includes (and which those headers include, etc), is expanded into a single entity called a translation unit - which is then passed to the compiler and compiled down to an object file. + +But functions and methods can also be written inline in header files. The downside to this is that these definitions will then be compiled in *every* translation unit that includes the header. + +Because Catch is implemented *entirely* in headers you might think that the whole of Catch must be compiled into every translation unit that uses it! Actually it's not quite as bad as that. Catch mitigates this situation by effectively maintaining the traditional separation between the implementation code and declarations. Internally the implementation code is protected by ```#ifdef```s and is conditionally compiled into only one translation unit. This translation unit is that one that ```#define```s ```CATCH_CONFIG_MAIN``` or ```CATCH_CONFIG_RUNNER```. Let's call this the main source file. + +As a result the main source file *does* compile the whole of Catch every time! So it makes sense to dedicate this file to *only* ```#define```-ing the identifier and ```#include```-ing Catch (and implementing the runner code, if you're doing that). Keep all your test cases in other files. This way you won't pay the recompilation cost for the whole of Catch + +## Practical example +Assume you have the `Factorial` function from the [tutorial](tutorial.md#top) in `factorial.cpp` (with forward declaration in `factorial.h`) and want to test it and keep the compile times down when adding new tests. Then you should have 2 files, `tests-main.cpp` and `tests-factorial.cpp`: + +```cpp +// tests-main.cpp +#define CATCH_CONFIG_MAIN +#include "catch.hpp" +``` + +```cpp +// tests-factorial.cpp +#include "catch.hpp" + +#include "factorial.h" + +TEST_CASE( "Factorials are computed", "[factorial]" ) { + REQUIRE( Factorial(1) == 1 ); + REQUIRE( Factorial(2) == 2 ); + REQUIRE( Factorial(3) == 6 ); + REQUIRE( Factorial(10) == 3628800 ); +} +``` + +After compiling `tests-main.cpp` once, it is enough to link it with separately compiled `tests-factorial.cpp`. This means that adding more tests to `tests-factorial.cpp`, will not result in recompiling Catch's main and the resulting compilation times will decrease substantially. + +``` +$ g++ tests-main.cpp -c +$ g++ tests-main.o tests-factorial.cpp -o tests && ./tests -r compact +Passed 1 test case with 4 assertions. +``` + +Now, the next time we change the file `tests-factorial.cpp` (say we add `REQUIRE( Factorial(0) == 1)`), it is enough to recompile the tests instead of recompiling main as well: + +``` +$ g++ tests-main.o tests-factorial.cpp -o tests && ./tests -r compact +tests-factorial.cpp:11: failed: Factorial(0) == 1 for: 0 == 1 +Failed 1 test case, failed 1 assertion. +``` + +## Other possible solutions +You can also opt to sacrifice some features in order to speed-up Catch's compilation times. For details see the [documentation on Catch's compile-time configuration](configuration.md#other-toggles). + +--- + +[Home](Readme.md#top) diff --git a/src/third_party/cppcodec/test/catch/docs/test-cases-and-sections.md b/src/third_party/cppcodec/test/catch/docs/test-cases-and-sections.md new file mode 100644 index 0000000000..68944f51cf --- /dev/null +++ b/src/third_party/cppcodec/test/catch/docs/test-cases-and-sections.md @@ -0,0 +1,91 @@ + +# Test cases and sections + +While Catch fully supports the traditional, xUnit, style of class-based fixtures containing test case methods this is not the preferred style. + +Instead Catch provides a powerful mechanism for nesting test case sections within a test case. For a more detailed discussion see the [tutorial](tutorial.md#test-cases-and-sections). + +Test cases and sections are very easy to use in practice: + +* **TEST_CASE(** _test name_ \[, _tags_ \] **)** +* **SECTION(** _section name_ **)** + +_test name_ and _section name_ are free form, quoted, strings. The optional _tags_ argument is a quoted string containing one or more tags enclosed in square brackets. Tags are discussed below. Test names must be unique within the Catch executable. + +For examples see the [Tutorial](tutorial.md#top) + +## Tags + +Tags allow an arbitrary number of additional strings to be associated with a test case. Test cases can be selected (for running, or just for listing) by tag - or even by an expression that combines several tags. At their most basic level they provide a simple way to group several related tests together. + +As an example - given the following test cases: + + TEST_CASE( "A", "[widget]" ) { /* ... */ } + TEST_CASE( "B", "[widget]" ) { /* ... */ } + TEST_CASE( "C", "[gadget]" ) { /* ... */ } + TEST_CASE( "D", "[widget][gadget]" ) { /* ... */ } + +The tag expression, ```"[widget]"``` selects A, B & D. ```"[gadget]"``` selects C & D. ```"[widget][gadget]"``` selects just D and ```"[widget],[gadget]"``` selects all four test cases. + +For more detail on command line selection see [the command line docs](command-line.md#specifying-which-tests-to-run) + +Tag names are not case sensitive and can contain any ASCII characters. This means that tags `[tag with spaces]` and `[I said "good day"]` are both allowed tags and can be filtered on. Escapes are not supported however and `[\]]` is not a valid tag. + +### Special Tags + +All tag names beginning with non-alphanumeric characters are reserved by Catch. Catch defines a number of "special" tags, which have meaning to the test runner itself. These special tags all begin with a symbol character. Following is a list of currently defined special tags and their meanings. + +* `[!hide]` or `[.]` - causes test cases to be skipped from the default list (i.e. when no test cases have been explicitly selected through tag expressions or name wildcards). The hide tag is often combined with another, user, tag (for example `[.][integration]` - so all integration tests are excluded from the default run but can be run by passing `[integration]` on the command line). As a short-cut you can combine these by simply prefixing your user tag with a `.` - e.g. `[.integration]`. Because the hide tag has evolved to have several forms, all forms are added as tags if you use one of them. + +* `[!throws]` - lets Catch know that this test is likely to throw an exception even if successful. This causes the test to be excluded when running with `-e` or `--nothrow`. + +* `[!mayfail]` - doesn't fail the test if any given assertion fails (but still reports it). This can be useful to flag a work-in-progress, or a known issue that you don't want to immediately fix but still want to track in your tests. + +* `[!shouldfail]` - like `[!mayfail]` but *fails* the test if it *passes*. This can be useful if you want to be notified of accidental, or third-party, fixes. + +* `[!nonportable]` - Indicates that behaviour may vary between platforms or compilers. + +* `[#]` - running with `-#` or `--filenames-as-tags` causes Catch to add the filename, prefixed with `#` (and with any extension stripped), as a tag to all contained tests, e.g. tests in testfile.cpp would all be tagged `[#testfile]`. + +* `[@]` - tag aliases all begin with `@` (see below). + +* `[!benchmark]` - this test case is actually a benchmark. This is an experimental feature, and currently has no documentation. If you want to try it out, look at `projects/SelfTest/Benchmark.tests.cpp` for details. + +## Tag aliases + +Between tag expressions and wildcarded test names (as well as combinations of the two) quite complex patterns can be constructed to direct which test cases are run. If a complex pattern is used often it is convenient to be able to create an alias for the expression. This can be done, in code, using the following form: + + CATCH_REGISTER_TAG_ALIAS( , ) + +Aliases must begin with the `@` character. An example of a tag alias is: + + CATCH_REGISTER_TAG_ALIAS( "[@nhf]", "[failing]~[.]" ) + +Now when `[@nhf]` is used on the command line this matches all tests that are tagged `[failing]`, but which are not also hidden. + +## BDD-style test cases + +In addition to Catch's take on the classic style of test cases, Catch supports an alternative syntax that allow tests to be written as "executable specifications" (one of the early goals of [Behaviour Driven Development](http://dannorth.net/introducing-bdd/)). This set of macros map on to ```TEST_CASE```s and ```SECTION```s, with a little internal support to make them smoother to work with. + +* **SCENARIO(** _scenario name_ \[, _tags_ \] **)** + +This macro maps onto ```TEST_CASE``` and works in the same way, except that the test case name will be prefixed by "Scenario: " + +* **GIVEN(** _something_ **)** +* **WHEN(** _something_ **)** +* **THEN(** _something_ **)** + +These macros map onto ```SECTION```s except that the section names are the _something_s prefixed by "given: ", "when: " or "then: " respectively. + +* **AND_WHEN(** _something_ **)** +* **AND_THEN(** _something_ **)** + +Similar to ```WHEN``` and ```THEN``` except that the prefixes start with "and ". These are used to chain ```WHEN```s and ```THEN```s together. + +When any of these macros are used the console reporter recognises them and formats the test case header such that the Givens, Whens and Thens are aligned to aid readability. + +Other than the additional prefixes and the formatting in the console reporter these macros behave exactly as ```TEST_CASE```s and ```SECTION```s. As such there is nothing enforcing the correct sequencing of these macros - that's up to the programmer! + +--- + +[Home](Readme.md#top) diff --git a/src/third_party/cppcodec/test/catch/docs/test-fixtures.md b/src/third_party/cppcodec/test/catch/docs/test-fixtures.md new file mode 100644 index 0000000000..1dc7babae0 --- /dev/null +++ b/src/third_party/cppcodec/test/catch/docs/test-fixtures.md @@ -0,0 +1,35 @@ + +# Test fixtures + +Although Catch allows you to group tests together as sections within a test case, it can still be convenient, sometimes, to group them using a more traditional test fixture. Catch fully supports this too. You define the test fixture as a simple structure: + +```c++ +class UniqueTestsFixture { + private: + static int uniqueID; + protected: + DBConnection conn; + public: + UniqueTestsFixture() : conn(DBConnection::createConnection("myDB")) { + } + protected: + int getID() { + return ++uniqueID; + } + }; + + int UniqueTestsFixture::uniqueID = 0; + + TEST_CASE_METHOD(UniqueTestsFixture, "Create Employee/No Name", "[create]") { + REQUIRE_THROWS(conn.executeSQL("INSERT INTO employee (id, name) VALUES (?, ?)", getID(), "")); + } + TEST_CASE_METHOD(UniqueTestsFixture, "Create Employee/Normal", "[create]") { + REQUIRE(conn.executeSQL("INSERT INTO employee (id, name) VALUES (?, ?)", getID(), "Joe Bloggs")); + } +``` + +The two test cases here will create uniquely-named derived classes of UniqueTestsFixture and thus can access the `getID()` protected method and `conn` member variables. This ensures that both the test cases are able to create a DBConnection using the same method (DRY principle) and that any ID's created are unique such that the order that tests are executed does not matter. + +--- + +[Home](Readme.md#top) diff --git a/src/third_party/cppcodec/test/catch/docs/tostring.md b/src/third_party/cppcodec/test/catch/docs/tostring.md new file mode 100644 index 0000000000..568c1c2758 --- /dev/null +++ b/src/third_party/cppcodec/test/catch/docs/tostring.md @@ -0,0 +1,65 @@ + +# String conversions + +Catch needs to be able to convert types you use in assertions and logging expressions into strings (for logging and reporting purposes). +Most built-in or std types are supported out of the box but there are two ways that you can tell Catch how to convert your own types (or other, third-party types) into strings. + +## operator << overload for std::ostream + +This is the standard way of providing string conversions in C++ - and the chances are you may already provide this for your own purposes. If you're not familiar with this idiom it involves writing a free function of the form: + +``` +std::ostream& operator << ( std::ostream& os, T const& value ) { + os << convertMyTypeToString( value ); + return os; +} +``` + +(where ```T``` is your type and ```convertMyTypeToString``` is where you'll write whatever code is necessary to make your type printable - it doesn't have to be in another function). + +You should put this function in the same namespace as your type and have it declared before including Catch's header. + +## Catch::StringMaker specialisation +If you don't want to provide an ```operator <<``` overload, or you want to convert your type differently for testing purposes, you can provide a specialization for `Catch::StringMaker`: + +``` +namespace Catch { + template<> + struct StringMaker { + static std::string convert( T const& value ) { + return convertMyTypeToString( value ); + } + }; +} +``` + +## Catch::is_range specialisation +As a fallback, Catch attempts to detect if the type can be iterated +(`begin(T)` and `end(T)` are valid) and if it can be, it is stringified +as a range. For certain types this can lead to infinite recursion, so +it can be disabled by specializing `Catch::is_range` like so: + +```cpp +namespace Catch { + template<> + struct is_range { + static const bool value = false; + }; +} + +``` + + +## Exceptions + +By default all exceptions deriving from `std::exception` will be translated to strings by calling the `what()` method. For exception types that do not derive from `std::exception` - or if `what()` does not return a suitable string - use `CATCH_TRANSLATE_EXCEPTION`. This defines a function that takes your exception type, by reference, and returns a string. It can appear anywhere in the code - it doesn't have to be in the same translation unit. For example: + +``` +CATCH_TRANSLATE_EXCEPTION( MyType& ex ) { + return ex.message(); +} +``` + +--- + +[Home](Readme.md#top) diff --git a/src/third_party/cppcodec/test/catch/docs/tutorial.md b/src/third_party/cppcodec/test/catch/docs/tutorial.md new file mode 100644 index 0000000000..b0c2bc881d --- /dev/null +++ b/src/third_party/cppcodec/test/catch/docs/tutorial.md @@ -0,0 +1,267 @@ + +# Tutorial + +**Contents**
+[Getting Catch2](#getting-catch2)
+[Where to put it?](#where-to-put-it)
+[Writing tests](#writing-tests)
+[Test cases and sections](#test-cases-and-sections)
+[BDD-Style](#bdd-style)
+[Scaling up](#scaling-up)
+[Next steps](#next-steps)
+ +## Getting Catch2 + +The simplest way to get Catch2 is to download the latest [single header version](https://raw.githubusercontent.com/catchorg/Catch2/master/single_include/catch2/catch.hpp). The single header is generated by merging a set of individual headers but it is still just normal source code in a header file. + +Alternative ways of getting Catch2 include using your system package +manager, or installing it using its CMake package. + +The full source for Catch2, including test projects, documentation, and other things, is hosted on GitHub. [http://catch-lib.net](http://catch-lib.net) will redirect you there. + + +## Where to put it? + +Catch2 is header only. All you need to do is drop the file somewhere reachable from your project - either in some central location you can set your header search path to find, or directly into your project tree itself! This is a particularly good option for other Open-Source projects that want to use Catch for their test suite. See [this blog entry for more on that](http://www.levelofindirection.com/journal/2011/5/27/unit-testing-in-c-and-objective-c-just-got-ridiculously-easi.html). + +The rest of this tutorial will assume that the Catch2 single-include header (or the include folder) is available unqualified - but you may need to prefix it with a folder name if necessary. + +_If you have installed Catch2 from system package manager, or CMake +package, you need to include the header as `#include `_ + +## Writing tests + +Let's start with a really simple example ([code](../examples/010-TestCase.cpp)). Say you have written a function to calculate factorials and now you want to test it (let's leave aside TDD for now). + +```c++ +unsigned int Factorial( unsigned int number ) { + return number <= 1 ? number : Factorial(number-1)*number; +} +``` + +To keep things simple we'll put everything in a single file (see later for more on how to structure your test files). + +```c++ +#define CATCH_CONFIG_MAIN // This tells Catch to provide a main() - only do this in one cpp file +#include "catch.hpp" + +unsigned int Factorial( unsigned int number ) { + return number <= 1 ? number : Factorial(number-1)*number; +} + +TEST_CASE( "Factorials are computed", "[factorial]" ) { + REQUIRE( Factorial(1) == 1 ); + REQUIRE( Factorial(2) == 2 ); + REQUIRE( Factorial(3) == 6 ); + REQUIRE( Factorial(10) == 3628800 ); +} +``` + +This will compile to a complete executable which responds to [command line arguments](command-line.md#top). If you just run it with no arguments it will execute all test cases (in this case there is just one), report any failures, report a summary of how many tests passed and failed and return the number of failed tests (useful for if you just want a yes/ no answer to: "did it work"). + +If you run this as written it will pass. Everything is good. Right? +Well, there is still a bug here. In fact the first version of this tutorial I posted here genuinely had the bug in! So it's not completely contrived (thanks to Daryle Walker (```@CTMacUser```) for pointing this out). + +What is the bug? Well what is the factorial of zero? +[The factorial of zero is one](http://mathforum.org/library/drmath/view/57128.html) - which is just one of those things you have to know (and remember!). + +Let's add that to the test case: + +```c++ +TEST_CASE( "Factorials are computed", "[factorial]" ) { + REQUIRE( Factorial(0) == 1 ); + REQUIRE( Factorial(1) == 1 ); + REQUIRE( Factorial(2) == 2 ); + REQUIRE( Factorial(3) == 6 ); + REQUIRE( Factorial(10) == 3628800 ); +} +``` + +Now we get a failure - something like: + +``` +Example.cpp:9: FAILED: + REQUIRE( Factorial(0) == 1 ) +with expansion: + 0 == 1 +``` + +Note that we get the actual return value of Factorial(0) printed for us (0) - even though we used a natural expression with the == operator. That lets us immediately see what the problem is. + +Let's change the factorial function to: + +```c++ +unsigned int Factorial( unsigned int number ) { + return number > 1 ? Factorial(number-1)*number : 1; +} +``` + +Now all the tests pass. + +Of course there are still more issues to deal with. For example we'll hit problems when the return value starts to exceed the range of an unsigned int. With factorials that can happen quite quickly. You might want to add tests for such cases and decide how to handle them. We'll stop short of doing that here. + +### What did we do here? + +Although this was a simple test it's been enough to demonstrate a few things about how Catch is used. Let's take moment to consider those before we move on. + +1. All we did was ```#define``` one identifier and ```#include``` one header and we got everything - even an implementation of ```main()``` that will [respond to command line arguments](command-line.md#top). You can only use that ```#define``` in one implementation file, for (hopefully) obvious reasons. Once you have more than one file with unit tests in you'll just ```#include "catch.hpp"``` and go. Usually it's a good idea to have a dedicated implementation file that just has ```#define CATCH_CONFIG_MAIN``` and ```#include "catch.hpp"```. You can also provide your own implementation of main and drive Catch yourself (see [Supplying-your-own-main()](own-main.md#top)). +2. We introduce test cases with the ```TEST_CASE``` macro. This macro takes one or two arguments - a free form test name and, optionally, one or more tags (for more see Test cases and Sections, ). The test name must be unique. You can run sets of tests by specifying a wildcarded test name or a tag expression. See the [command line docs](command-line.md#top) for more information on running tests. +3. The name and tags arguments are just strings. We haven't had to declare a function or method - or explicitly register the test case anywhere. Behind the scenes a function with a generated name is defined for you, and automatically registered using static registry classes. By abstracting the function name away we can name our tests without the constraints of identifier names. +4. We write our individual test assertions using the ```REQUIRE``` macro. Rather than a separate macro for each type of condition we express the condition naturally using C/C++ syntax. Behind the scenes a simple set of expression templates captures the left-hand-side and right-hand-side of the expression so we can display the values in our test report. As we'll see later there _are_ other assertion macros - but because of this technique the number of them is drastically reduced. + + +## Test cases and sections + +Most test frameworks have a class-based fixture mechanism. That is, test cases map to methods on a class and common setup and teardown can be performed in ```setup()``` and ```teardown()``` methods (or constructor/ destructor in languages, like C++, that support deterministic destruction). + +While Catch fully supports this way of working there are a few problems with the approach. In particular the way your code must be split up, and the blunt granularity of it, may cause problems. You can only have one setup/ teardown pair across a set of methods, but sometimes you want slightly different setup in each method, or you may even want several levels of setup (a concept which we will clarify later on in this tutorial). It was problems like these that led James Newkirk, who led the team that built NUnit, to start again from scratch and build xUnit). + +Catch takes a different approach (to both NUnit and xUnit) that is a more natural fit for C++ and the C family of languages. This is best explained through an example ([code](../examples/100-Fix-Section.cpp)): + +```c++ +TEST_CASE( "vectors can be sized and resized", "[vector]" ) { + + std::vector v( 5 ); + + REQUIRE( v.size() == 5 ); + REQUIRE( v.capacity() >= 5 ); + + SECTION( "resizing bigger changes size and capacity" ) { + v.resize( 10 ); + + REQUIRE( v.size() == 10 ); + REQUIRE( v.capacity() >= 10 ); + } + SECTION( "resizing smaller changes size but not capacity" ) { + v.resize( 0 ); + + REQUIRE( v.size() == 0 ); + REQUIRE( v.capacity() >= 5 ); + } + SECTION( "reserving bigger changes capacity but not size" ) { + v.reserve( 10 ); + + REQUIRE( v.size() == 5 ); + REQUIRE( v.capacity() >= 10 ); + } + SECTION( "reserving smaller does not change size or capacity" ) { + v.reserve( 0 ); + + REQUIRE( v.size() == 5 ); + REQUIRE( v.capacity() >= 5 ); + } +} +``` + +For each ```SECTION``` the ```TEST_CASE``` is executed from the start - so as we enter each section we know that size is 5 and capacity is at least 5. We enforced those requirements with the ```REQUIRE```s at the top level so we can be confident in them. +This works because the ```SECTION``` macro contains an if statement that calls back into Catch to see if the section should be executed. One leaf section is executed on each run through a ```TEST_CASE```. The other sections are skipped. Next time through the next section is executed, and so on until no new sections are encountered. + +So far so good - this is already an improvement on the setup/teardown approach because now we see our setup code inline and use the stack. + +The power of sections really shows, however, when we need to execute a sequence of, checked, operations. Continuing the vector example, we might want to verify that attempting to reserve a capacity smaller than the current capacity of the vector changes nothing. We can do that, naturally, like so: + +```c++ + SECTION( "reserving bigger changes capacity but not size" ) { + v.reserve( 10 ); + + REQUIRE( v.size() == 5 ); + REQUIRE( v.capacity() >= 10 ); + + SECTION( "reserving smaller again does not change capacity" ) { + v.reserve( 7 ); + + REQUIRE( v.capacity() >= 10 ); + } + } +``` + +Sections can be nested to an arbitrary depth (limited only by your stack size). Each leaf section (i.e. a section that contains no nested sections) will be executed exactly once, on a separate path of execution from any other leaf section (so no leaf section can interfere with another). A failure in a parent section will prevent nested sections from running - but then that's the idea. + +## BDD-Style + +If you name your test cases and sections appropriately you can achieve a BDD-style specification structure. This became such a useful way of working that first class support has been added to Catch. Scenarios can be specified using ```SCENARIO```, ```GIVEN```, ```WHEN``` and ```THEN``` macros, which map on to ```TEST_CASE```s and ```SECTION```s, respectively. For more details see [Test cases and sections](test-cases-and-sections.md#top). + +The vector example can be adjusted to use these macros like so ([example code](../examples/120-Bdd-ScenarioGivenWhenThen.cpp)): + +```c++ +SCENARIO( "vectors can be sized and resized", "[vector]" ) { + + GIVEN( "A vector with some items" ) { + std::vector v( 5 ); + + REQUIRE( v.size() == 5 ); + REQUIRE( v.capacity() >= 5 ); + + WHEN( "the size is increased" ) { + v.resize( 10 ); + + THEN( "the size and capacity change" ) { + REQUIRE( v.size() == 10 ); + REQUIRE( v.capacity() >= 10 ); + } + } + WHEN( "the size is reduced" ) { + v.resize( 0 ); + + THEN( "the size changes but not capacity" ) { + REQUIRE( v.size() == 0 ); + REQUIRE( v.capacity() >= 5 ); + } + } + WHEN( "more capacity is reserved" ) { + v.reserve( 10 ); + + THEN( "the capacity changes but not the size" ) { + REQUIRE( v.size() == 5 ); + REQUIRE( v.capacity() >= 10 ); + } + } + WHEN( "less capacity is reserved" ) { + v.reserve( 0 ); + + THEN( "neither size nor capacity are changed" ) { + REQUIRE( v.size() == 5 ); + REQUIRE( v.capacity() >= 5 ); + } + } + } +} +``` + +Conveniently, these tests will be reported as follows when run: + +``` +Scenario: vectors can be sized and resized + Given: A vector with some items + When: more capacity is reserved + Then: the capacity changes but not the size +``` + + +## Scaling up + +To keep the tutorial simple we put all our code in a single file. This is fine to get started - and makes jumping into Catch even quicker and easier. As you write more real-world tests, though, this is not really the best approach. + +The requirement is that the following block of code ([or equivalent](own-main.md#top)): + +```c++ +#define CATCH_CONFIG_MAIN +#include "catch.hpp" +``` + +appears in _exactly one_ source file. Use as many additional cpp files (or whatever you call your implementation files) as you need for your tests, partitioned however makes most sense for your way of working. Each additional file need only ```#include "catch.hpp"``` - do not repeat the ```#define```! + +In fact it is usually a good idea to put the block with the ```#define``` [in its own source file](slow-compiles.md#top) (code example [main](../examples/020-TestCase-1.cpp), [tests](../examples/020-TestCase-2.cpp)). + +Do not write your tests in header files! + + +## Next steps + +This has been a brief introduction to get you up and running with Catch, and to point out some of the key differences between Catch and other frameworks you may already be familiar with. This will get you going quite far already and you are now in a position to dive in and write some tests. + +Of course there is more to learn - most of which you should be able to page-fault in as you go. Please see the ever-growing [Reference section](Readme.md#top) for what's available. + +--- + +[Home](Readme.md#top) diff --git a/src/third_party/cppcodec/test/catch/docs/why-catch.md b/src/third_party/cppcodec/test/catch/docs/why-catch.md new file mode 100644 index 0000000000..45f58a6ab7 --- /dev/null +++ b/src/third_party/cppcodec/test/catch/docs/why-catch.md @@ -0,0 +1,46 @@ + +# Why do we need yet another C++ test framework? + +Good question. For C++ there are quite a number of established frameworks, +including (but not limited to), +[Google Test](http://code.google.com/p/googletest/), +[Boost.Test](http://www.boost.org/doc/libs/1_49_0/libs/test/doc/html/index.html), +[CppUnit](http://sourceforge.net/apps/mediawiki/cppunit/index.php?title=Main_Page), +[Cute](http://r2.ifs.hsr.ch/cute), +[many, many more](http://en.wikipedia.org/wiki/List_of_unit_testing_frameworks#C.2B.2B). + +So what does Catch bring to the party that differentiates it from these? Apart from a Catchy name, of course. + +## Key Features + +* Quick and Really easy to get started. Just download catch.hpp, `#include` it and you're away. +* No external dependencies. As long as you can compile C++11 and have a C++ standard library available. +* Write test cases as, self-registering, functions (or methods, if you prefer). +* Divide test cases into sections, each of which is run in isolation (eliminates the need for fixtures). +* Use BDD-style Given-When-Then sections as well as traditional unit test cases. +* Only one core assertion macro for comparisons. Standard C/C++ operators are used for the comparison - yet the full expression is decomposed and lhs and rhs values are logged. +* Tests are named using free-form strings - no more couching names in legal identifiers. + +## Other core features + +* Tests can be tagged for easily running ad-hoc groups of tests. +* Failures can (optionally) break into the debugger on Windows and Mac. +* Output is through modular reporter objects. Basic textual and XML reporters are included. Custom reporters can easily be added. +* JUnit xml output is supported for integration with third-party tools, such as CI servers. +* A default main() function is provided, but you can supply your own for complete control (e.g. integration into your own test runner GUI). +* A command line parser is provided and can still be used if you choose to provided your own main() function. +* Catch can test itself. +* Alternative assertion macro(s) report failures but don't abort the test case +* Floating point tolerance comparisons are built in using an expressive Approx() syntax. +* Internal and friendly macros are isolated so name clashes can be managed +* Matchers + +## Who else is using Catch? + +See the list of [open source projects using Catch](opensource-users.md#top). + +See the [tutorial](tutorial.md#top) to get more of a taste of using Catch in practice + +--- + +[Home](Readme.md#top) diff --git a/src/third_party/cppcodec/test/catch/examples/000-CatchMain.cpp b/src/third_party/cppcodec/test/catch/examples/000-CatchMain.cpp new file mode 100644 index 0000000000..2894d425ad --- /dev/null +++ b/src/third_party/cppcodec/test/catch/examples/000-CatchMain.cpp @@ -0,0 +1,15 @@ +// 000-CatchMain.cpp + +// In a Catch project with multiple files, dedicate one file to compile the +// source code of Catch itself and reuse the resulting object file for linking. + +// Let Catch provide main(): +#define CATCH_CONFIG_MAIN + +#include + +// That's it + +// Compile implementation of Catch for use with files that do contain tests: +// - g++ -std=c++11 -Wall -I$(CATCH_SINGLE_INCLUDE) -c 000-CatchMain.cpp +// - cl -EHsc -I%CATCH_SINGLE_INCLUDE% -c 000-CatchMain.cpp diff --git a/src/third_party/cppcodec/test/catch/examples/010-TestCase.cpp b/src/third_party/cppcodec/test/catch/examples/010-TestCase.cpp new file mode 100644 index 0000000000..c00b8a8f39 --- /dev/null +++ b/src/third_party/cppcodec/test/catch/examples/010-TestCase.cpp @@ -0,0 +1,36 @@ +// 010-TestCase.cpp + +// Let Catch provide main(): +#define CATCH_CONFIG_MAIN + +#include + +int Factorial( int number ) { + return number <= 1 ? number : Factorial( number - 1 ) * number; // fail +// return number <= 1 ? 1 : Factorial( number - 1 ) * number; // pass +} + +TEST_CASE( "Factorial of 0 is 1 (fail)", "[single-file]" ) { + REQUIRE( Factorial(0) == 1 ); +} + +TEST_CASE( "Factorials of 1 and higher are computed (pass)", "[single-file]" ) { + REQUIRE( Factorial(1) == 1 ); + REQUIRE( Factorial(2) == 2 ); + REQUIRE( Factorial(3) == 6 ); + REQUIRE( Factorial(10) == 3628800 ); +} + +// Compile & run: +// - g++ -std=c++11 -Wall -I$(CATCH_SINGLE_INCLUDE) -o 010-TestCase 010-TestCase.cpp && 010-TestCase --success +// - cl -EHsc -I%CATCH_SINGLE_INCLUDE% 010-TestCase.cpp && 010-TestCase --success + +// Expected compact output (all assertions): +// +// prompt> 010-TestCase --reporter compact --success +// 010-TestCase.cpp:14: failed: Factorial(0) == 1 for: 0 == 1 +// 010-TestCase.cpp:18: passed: Factorial(1) == 1 for: 1 == 1 +// 010-TestCase.cpp:19: passed: Factorial(2) == 2 for: 2 == 2 +// 010-TestCase.cpp:20: passed: Factorial(3) == 6 for: 6 == 6 +// 010-TestCase.cpp:21: passed: Factorial(10) == 3628800 for: 3628800 (0x375f00) == 3628800 (0x375f00) +// Failed 1 test case, failed 1 assertion. diff --git a/src/third_party/cppcodec/test/catch/examples/020-TestCase-1.cpp b/src/third_party/cppcodec/test/catch/examples/020-TestCase-1.cpp new file mode 100644 index 0000000000..ab0249e4dd --- /dev/null +++ b/src/third_party/cppcodec/test/catch/examples/020-TestCase-1.cpp @@ -0,0 +1,35 @@ +// 020-TestCase-1.cpp + +// In a Catch project with multiple files, dedicate one file to compile the +// source code of Catch itself and reuse the resulting object file for linking. + +// Let Catch provide main(): +#define CATCH_CONFIG_MAIN + +#include + +TEST_CASE( "1: All test cases reside in other .cpp files (empty)", "[multi-file:1]" ) { +} + +// ^^^ +// Normally no TEST_CASEs in this file. +// Here just to show there are two source files via option --list-tests. + +// Compile & run: +// - g++ -std=c++11 -Wall -I$(CATCH_SINGLE_INCLUDE) -c 020-TestCase-1.cpp +// - g++ -std=c++11 -Wall -I$(CATCH_SINGLE_INCLUDE) -o 020-TestCase TestCase-1.o 020-TestCase-2.cpp && 020-TestCase --success +// +// - cl -EHsc -I%CATCH_SINGLE_INCLUDE% -c 020-TestCase-1.cpp +// - cl -EHsc -I%CATCH_SINGLE_INCLUDE% -Fe020-TestCase.exe 020-TestCase-1.obj 020-TestCase-2.cpp && 020-TestCase --success + +// Expected test case listing: +// +// prompt> 020-TestCase --list-tests * +// Matching test cases: +// 1: All test cases reside in other .cpp files (empty) +// [multi-file:1] +// 2: Factorial of 0 is computed (fail) +// [multi-file:2] +// 2: Factorials of 1 and higher are computed (pass) +// [multi-file:2] +// 3 matching test cases diff --git a/src/third_party/cppcodec/test/catch/examples/020-TestCase-2.cpp b/src/third_party/cppcodec/test/catch/examples/020-TestCase-2.cpp new file mode 100644 index 0000000000..08b313e0cf --- /dev/null +++ b/src/third_party/cppcodec/test/catch/examples/020-TestCase-2.cpp @@ -0,0 +1,33 @@ +// 020-TestCase-2.cpp + +// main() provided by Catch in file 020-TestCase-1.cpp. + +#include + +int Factorial( int number ) { + return number <= 1 ? number : Factorial( number - 1 ) * number; // fail +// return number <= 1 ? 1 : Factorial( number - 1 ) * number; // pass +} + +TEST_CASE( "2: Factorial of 0 is 1 (fail)", "[multi-file:2]" ) { + REQUIRE( Factorial(0) == 1 ); +} + +TEST_CASE( "2: Factorials of 1 and higher are computed (pass)", "[multi-file:2]" ) { + REQUIRE( Factorial(1) == 1 ); + REQUIRE( Factorial(2) == 2 ); + REQUIRE( Factorial(3) == 6 ); + REQUIRE( Factorial(10) == 3628800 ); +} + +// Compile: see 020-TestCase-1.cpp + +// Expected compact output (all assertions): +// +// prompt> 020-TestCase --reporter compact --success +// 020-TestCase-2.cpp:13: failed: Factorial(0) == 1 for: 0 == 1 +// 020-TestCase-2.cpp:17: passed: Factorial(1) == 1 for: 1 == 1 +// 020-TestCase-2.cpp:18: passed: Factorial(2) == 2 for: 2 == 2 +// 020-TestCase-2.cpp:19: passed: Factorial(3) == 6 for: 6 == 6 +// 020-TestCase-2.cpp:20: passed: Factorial(10) == 3628800 for: 3628800 (0x375f00) == 3628800 (0x375f00) +// Failed 1 test case, failed 1 assertion. diff --git a/src/third_party/cppcodec/test/catch/examples/030-Asn-Require-Check.cpp b/src/third_party/cppcodec/test/catch/examples/030-Asn-Require-Check.cpp new file mode 100644 index 0000000000..f814a1b3ca --- /dev/null +++ b/src/third_party/cppcodec/test/catch/examples/030-Asn-Require-Check.cpp @@ -0,0 +1,74 @@ +// 030-Asn-Require-Check.cpp + +// Catch has two natural expression assertion macro's: +// - REQUIRE() stops at first failure. +// - CHECK() continues after failure. + +// There are two variants to support decomposing negated expressions: +// - REQUIRE_FALSE() stops at first failure. +// - CHECK_FALSE() continues after failure. + +// main() provided in 000-CatchMain.cpp + +#include + +std::string one() { + return "1"; +} + +TEST_CASE( "Assert that something is true (pass)", "[require]" ) { + REQUIRE( one() == "1" ); +} + +TEST_CASE( "Assert that something is true (fail)", "[require]" ) { + REQUIRE( one() == "x" ); +} + +TEST_CASE( "Assert that something is true (stop at first failure)", "[require]" ) { + WARN( "REQUIRE stops at first failure:" ); + + REQUIRE( one() == "x" ); + REQUIRE( one() == "1" ); +} + +TEST_CASE( "Assert that something is true (continue after failure)", "[check]" ) { + WARN( "CHECK continues after failure:" ); + + CHECK( one() == "x" ); + REQUIRE( one() == "1" ); +} + +TEST_CASE( "Assert that something is false (stops at first failure)", "[require-false]" ) { + WARN( "REQUIRE_FALSE stops at first failure:" ); + + REQUIRE_FALSE( one() == "1" ); + REQUIRE_FALSE( one() != "1" ); +} + +TEST_CASE( "Assert that something is false (continue after failure)", "[check-false]" ) { + WARN( "CHECK_FALSE continues after failure:" ); + + CHECK_FALSE( one() == "1" ); + REQUIRE_FALSE( one() != "1" ); +} + +// Compile & run: +// - g++ -std=c++11 -Wall -I$(CATCH_SINGLE_INCLUDE) -o 030-Asn-Require-Check 030-Asn-Require-Check.cpp 000-CatchMain.o && 030-Asn-Require-Check --success +// - cl -EHsc -I%CATCH_SINGLE_INCLUDE% 030-Asn-Require-Check.cpp 000-CatchMain.obj && 030-Asn-Require-Check --success + +// Expected compact output (all assertions): +// +// prompt> 030-Asn-Require-Check.exe --reporter compact --success +// 030-Asn-Require-Check.cpp:20: passed: one() == "1" for: "1" == "1" +// 030-Asn-Require-Check.cpp:24: failed: one() == "x" for: "1" == "x" +// 030-Asn-Require-Check.cpp:28: warning: 'REQUIRE stops at first failure:' +// 030-Asn-Require-Check.cpp:30: failed: one() == "x" for: "1" == "x" +// 030-Asn-Require-Check.cpp:35: warning: 'CHECK continues after failure:' +// 030-Asn-Require-Check.cpp:37: failed: one() == "x" for: "1" == "x" +// 030-Asn-Require-Check.cpp:38: passed: one() == "1" for: "1" == "1" +// 030-Asn-Require-Check.cpp:42: warning: 'REQUIRE_FALSE stops at first failure:' +// 030-Asn-Require-Check.cpp:44: failed: !(one() == "1") for: !("1" == "1") +// 030-Asn-Require-Check.cpp:49: warning: 'CHECK_FALSE continues after failure:' +// 030-Asn-Require-Check.cpp:51: failed: !(one() == "1") for: !("1" == "1") +// 030-Asn-Require-Check.cpp:52: passed: !(one() != "1") for: !("1" != "1") +// Failed 5 test cases, failed 5 assertions. diff --git a/src/third_party/cppcodec/test/catch/examples/100-Fix-Section.cpp b/src/third_party/cppcodec/test/catch/examples/100-Fix-Section.cpp new file mode 100644 index 0000000000..d0b9f2da5b --- /dev/null +++ b/src/third_party/cppcodec/test/catch/examples/100-Fix-Section.cpp @@ -0,0 +1,69 @@ +// 100-Fix-Section.cpp + +// Catch has two ways to express fixtures: +// - Sections (this file) +// - Traditional class-based fixtures + +// main() provided in 000-CatchMain.cpp + +#include + +TEST_CASE( "vectors can be sized and resized", "[vector]" ) { + + // For each section, vector v is anew: + + std::vector v( 5 ); + + REQUIRE( v.size() == 5 ); + REQUIRE( v.capacity() >= 5 ); + + SECTION( "resizing bigger changes size and capacity" ) { + v.resize( 10 ); + + REQUIRE( v.size() == 10 ); + REQUIRE( v.capacity() >= 10 ); + } + SECTION( "resizing smaller changes size but not capacity" ) { + v.resize( 0 ); + + REQUIRE( v.size() == 0 ); + REQUIRE( v.capacity() >= 5 ); + } + SECTION( "reserving bigger changes capacity but not size" ) { + v.reserve( 10 ); + + REQUIRE( v.size() == 5 ); + REQUIRE( v.capacity() >= 10 ); + } + SECTION( "reserving smaller does not change size or capacity" ) { + v.reserve( 0 ); + + REQUIRE( v.size() == 5 ); + REQUIRE( v.capacity() >= 5 ); + } +} + +// Compile & run: +// - g++ -std=c++11 -Wall -I$(CATCH_SINGLE_INCLUDE) -o 100-Fix-Section 100-Fix-Section.cpp 000-CatchMain.o && 100-Fix-Section --success +// - cl -EHsc -I%CATCH_SINGLE_INCLUDE% 100-Fix-Section.cpp 000-CatchMain.obj && 100-Fix-Section --success + +// Expected compact output (all assertions): +// +// prompt> 100-Fix-Section.exe --reporter compact --success +// 100-Fix-Section.cpp:17: passed: v.size() == 5 for: 5 == 5 +// 100-Fix-Section.cpp:18: passed: v.capacity() >= 5 for: 5 >= 5 +// 100-Fix-Section.cpp:23: passed: v.size() == 10 for: 10 == 10 +// 100-Fix-Section.cpp:24: passed: v.capacity() >= 10 for: 10 >= 10 +// 100-Fix-Section.cpp:17: passed: v.size() == 5 for: 5 == 5 +// 100-Fix-Section.cpp:18: passed: v.capacity() >= 5 for: 5 >= 5 +// 100-Fix-Section.cpp:29: passed: v.size() == 0 for: 0 == 0 +// 100-Fix-Section.cpp:30: passed: v.capacity() >= 5 for: 5 >= 5 +// 100-Fix-Section.cpp:17: passed: v.size() == 5 for: 5 == 5 +// 100-Fix-Section.cpp:18: passed: v.capacity() >= 5 for: 5 >= 5 +// 100-Fix-Section.cpp:35: passed: v.size() == 5 for: 5 == 5 +// 100-Fix-Section.cpp:36: passed: v.capacity() >= 10 for: 10 >= 10 +// 100-Fix-Section.cpp:17: passed: v.size() == 5 for: 5 == 5 +// 100-Fix-Section.cpp:18: passed: v.capacity() >= 5 for: 5 >= 5 +// 100-Fix-Section.cpp:41: passed: v.size() == 5 for: 5 == 5 +// 100-Fix-Section.cpp:42: passed: v.capacity() >= 5 for: 5 >= 5 +// Passed 1 test case with 16 assertions. diff --git a/src/third_party/cppcodec/test/catch/examples/110-Fix-ClassFixture.cpp b/src/third_party/cppcodec/test/catch/examples/110-Fix-ClassFixture.cpp new file mode 100644 index 0000000000..e42fd17585 --- /dev/null +++ b/src/third_party/cppcodec/test/catch/examples/110-Fix-ClassFixture.cpp @@ -0,0 +1,63 @@ +// 110-Fix-ClassFixture.cpp + +// Catch has two ways to express fixtures: +// - Sections +// - Traditional class-based fixtures (this file) + +// main() provided in 000-CatchMain.cpp + +#include + +class DBConnection +{ +public: + static DBConnection createConnection( std::string const & /*dbName*/ ) { + return DBConnection(); + } + + bool executeSQL( std::string const & /*query*/, int const /*id*/, std::string const & arg ) { + if ( arg.length() == 0 ) { + throw std::logic_error("empty SQL query argument"); + } + return true; // ok + } +}; + +class UniqueTestsFixture +{ +protected: + UniqueTestsFixture() + : conn( DBConnection::createConnection( "myDB" ) ) + {} + + int getID() { + return ++uniqueID; + } + +protected: + DBConnection conn; + +private: + static int uniqueID; +}; + +int UniqueTestsFixture::uniqueID = 0; + +TEST_CASE_METHOD( UniqueTestsFixture, "Create Employee/No Name", "[create]" ) { + REQUIRE_THROWS( conn.executeSQL( "INSERT INTO employee (id, name) VALUES (?, ?)", getID(), "") ); +} + +TEST_CASE_METHOD( UniqueTestsFixture, "Create Employee/Normal", "[create]" ) { + REQUIRE( conn.executeSQL( "INSERT INTO employee (id, name) VALUES (?, ?)", getID(), "Joe Bloggs" ) ); +} + +// Compile & run: +// - g++ -std=c++11 -Wall -I$(CATCH_SINGLE_INCLUDE) -o 110-Fix-ClassFixture 110-Fix-ClassFixture.cpp 000-CatchMain.o && 110-Fix-ClassFixture --success +// - cl -EHsc -I%CATCH_SINGLE_INCLUDE% 110-Fix-ClassFixture.cpp 000-CatchMain.obj && 110-Fix-ClassFixture --success + +// Expected compact output (all assertions): +// +// prompt> 110-Fix-ClassFixture.exe --reporter compact --success +// 110-Fix-ClassFixture.cpp:47: passed: conn.executeSQL( "INSERT INTO employee (id, name) VALUES (?, ?)", getID(), "") +// 110-Fix-ClassFixture.cpp:51: passed: conn.executeSQL( "INSERT INTO employee (id, name) VALUES (?, ?)", getID(), "Joe Bloggs" ) for: true +// Passed both 2 test cases with 2 assertions. diff --git a/src/third_party/cppcodec/test/catch/examples/120-Bdd-ScenarioGivenWhenThen.cpp b/src/third_party/cppcodec/test/catch/examples/120-Bdd-ScenarioGivenWhenThen.cpp new file mode 100644 index 0000000000..d1b9ce558a --- /dev/null +++ b/src/third_party/cppcodec/test/catch/examples/120-Bdd-ScenarioGivenWhenThen.cpp @@ -0,0 +1,73 @@ +// 120-Bdd-ScenarioGivenWhenThen.cpp + +// main() provided in 000-CatchMain.cpp + +#include + +SCENARIO( "vectors can be sized and resized", "[vector]" ) { + + GIVEN( "A vector with some items" ) { + std::vector v( 5 ); + + REQUIRE( v.size() == 5 ); + REQUIRE( v.capacity() >= 5 ); + + WHEN( "the size is increased" ) { + v.resize( 10 ); + + THEN( "the size and capacity change" ) { + REQUIRE( v.size() == 10 ); + REQUIRE( v.capacity() >= 10 ); + } + } + WHEN( "the size is reduced" ) { + v.resize( 0 ); + + THEN( "the size changes but not capacity" ) { + REQUIRE( v.size() == 0 ); + REQUIRE( v.capacity() >= 5 ); + } + } + WHEN( "more capacity is reserved" ) { + v.reserve( 10 ); + + THEN( "the capacity changes but not the size" ) { + REQUIRE( v.size() == 5 ); + REQUIRE( v.capacity() >= 10 ); + } + } + WHEN( "less capacity is reserved" ) { + v.reserve( 0 ); + + THEN( "neither size nor capacity are changed" ) { + REQUIRE( v.size() == 5 ); + REQUIRE( v.capacity() >= 5 ); + } + } + } +} + +// Compile & run: +// - g++ -std=c++11 -Wall -I$(CATCH_SINGLE_INCLUDE) -o 120-Bdd-ScenarioGivenWhenThen 120-Bdd-ScenarioGivenWhenThen.cpp 000-CatchMain.o && 120-Bdd-ScenarioGivenWhenThen --success +// - cl -EHsc -I%CATCH_SINGLE_INCLUDE% 120-Bdd-ScenarioGivenWhenThen.cpp 000-CatchMain.obj && 120-Bdd-ScenarioGivenWhenThen --success + +// Expected compact output (all assertions): +// +// prompt> 120-Bdd-ScenarioGivenWhenThen.exe --reporter compact --success +// 120-Bdd-ScenarioGivenWhenThen.cpp:12: passed: v.size() == 5 for: 5 == 5 +// 120-Bdd-ScenarioGivenWhenThen.cpp:13: passed: v.capacity() >= 5 for: 5 >= 5 +// 120-Bdd-ScenarioGivenWhenThen.cpp:19: passed: v.size() == 10 for: 10 == 10 +// 120-Bdd-ScenarioGivenWhenThen.cpp:20: passed: v.capacity() >= 10 for: 10 >= 10 +// 120-Bdd-ScenarioGivenWhenThen.cpp:12: passed: v.size() == 5 for: 5 == 5 +// 120-Bdd-ScenarioGivenWhenThen.cpp:13: passed: v.capacity() >= 5 for: 5 >= 5 +// 120-Bdd-ScenarioGivenWhenThen.cpp:27: passed: v.size() == 0 for: 0 == 0 +// 120-Bdd-ScenarioGivenWhenThen.cpp:28: passed: v.capacity() >= 5 for: 5 >= 5 +// 120-Bdd-ScenarioGivenWhenThen.cpp:12: passed: v.size() == 5 for: 5 == 5 +// 120-Bdd-ScenarioGivenWhenThen.cpp:13: passed: v.capacity() >= 5 for: 5 >= 5 +// 120-Bdd-ScenarioGivenWhenThen.cpp:35: passed: v.size() == 5 for: 5 == 5 +// 120-Bdd-ScenarioGivenWhenThen.cpp:36: passed: v.capacity() >= 10 for: 10 >= 10 +// 120-Bdd-ScenarioGivenWhenThen.cpp:12: passed: v.size() == 5 for: 5 == 5 +// 120-Bdd-ScenarioGivenWhenThen.cpp:13: passed: v.capacity() >= 5 for: 5 >= 5 +// 120-Bdd-ScenarioGivenWhenThen.cpp:43: passed: v.size() == 5 for: 5 == 5 +// 120-Bdd-ScenarioGivenWhenThen.cpp:44: passed: v.capacity() >= 5 for: 5 >= 5 +// Passed 1 test case with 16 assertions. diff --git a/src/third_party/cppcodec/test/catch/examples/210-Evt-EventListeners.cpp b/src/third_party/cppcodec/test/catch/examples/210-Evt-EventListeners.cpp new file mode 100644 index 0000000000..7df93d715b --- /dev/null +++ b/src/third_party/cppcodec/test/catch/examples/210-Evt-EventListeners.cpp @@ -0,0 +1,422 @@ +// 210-Evt-EventListeners.cpp + +// Contents: +// 1. Printing of listener data +// 2. My listener and registration +// 3. Test cases + +// main() provided in 000-CatchMain.cpp + +// Let Catch provide the required interfaces: +#define CATCH_CONFIG_EXTERNAL_INTERFACES + +#include +#include + +// ----------------------------------------------------------------------- +// 1. Printing of listener data: +// + +std::string ws(int const level) { + return std::string( 2 * level, ' ' ); +} + +template< typename T > +std::ostream& operator<<( std::ostream& os, std::vector const& v ) { + os << "{ "; + for ( auto x : v ) + os << x << ", "; + return os << "}"; +} + +// struct SourceLineInfo { +// char const* file; +// std::size_t line; +// }; + +void print( std::ostream& os, int const level, std::string const& title, Catch::SourceLineInfo const& info ) { + os << ws(level ) << title << ":\n" + << ws(level+1) << "- file: " << info.file << "\n" + << ws(level+1) << "- line: " << info.line << "\n"; +} + +//struct MessageInfo { +// std::string macroName; +// std::string message; +// SourceLineInfo lineInfo; +// ResultWas::OfType type; +// unsigned int sequence; +//}; + +void print( std::ostream& os, int const level, Catch::MessageInfo const& info ) { + os << ws(level+1) << "- macroName: '" << info.macroName << "'\n" + << ws(level+1) << "- message '" << info.message << "'\n"; + print( os,level+1 , "- lineInfo", info.lineInfo ); + os << ws(level+1) << "- sequence " << info.sequence << "\n"; +} + +void print( std::ostream& os, int const level, std::string const& title, std::vector const& v ) { + os << ws(level ) << title << ":\n"; + for ( auto x : v ) + { + os << ws(level+1) << "{\n"; + print( os, level+2, x ); + os << ws(level+1) << "}\n"; + } +// os << ws(level+1) << "\n"; +} + +// struct TestRunInfo { +// std::string name; +// }; + +void print( std::ostream& os, int const level, std::string const& title, Catch::TestRunInfo const& info ) { + os << ws(level ) << title << ":\n" + << ws(level+1) << "- name: " << info.name << "\n"; +} + +// struct Counts { +// std::size_t total() const; +// bool allPassed() const; +// bool allOk() const; +// +// std::size_t passed = 0; +// std::size_t failed = 0; +// std::size_t failedButOk = 0; +// }; + +void print( std::ostream& os, int const level, std::string const& title, Catch::Counts const& info ) { + os << ws(level ) << title << ":\n" + << ws(level+1) << "- total(): " << info.total() << "\n" + << ws(level+1) << "- allPassed(): " << info.allPassed() << "\n" + << ws(level+1) << "- allOk(): " << info.allOk() << "\n" + << ws(level+1) << "- passed: " << info.passed << "\n" + << ws(level+1) << "- failed: " << info.failed << "\n" + << ws(level+1) << "- failedButOk: " << info.failedButOk << "\n"; +} + +// struct Totals { +// Counts assertions; +// Counts testCases; +// }; + +void print( std::ostream& os, int const level, std::string const& title, Catch::Totals const& info ) { + os << ws(level) << title << ":\n"; + print( os, level+1, "- assertions", info.assertions ); + print( os, level+1, "- testCases" , info.testCases ); +} + +// struct TestRunStats { +// TestRunInfo runInfo; +// Totals totals; +// bool aborting; +// }; + +void print( std::ostream& os, int const level, std::string const& title, Catch::TestRunStats const& info ) { + os << ws(level) << title << ":\n"; + print( os, level+1 , "- runInfo", info.runInfo ); + print( os, level+1 , "- totals" , info.totals ); + os << ws(level+1) << "- aborting: " << info.aborting << "\n"; +} + +// struct TestCaseInfo { +// enum SpecialProperties{ +// None = 0, +// IsHidden = 1 << 1, +// ShouldFail = 1 << 2, +// MayFail = 1 << 3, +// Throws = 1 << 4, +// NonPortable = 1 << 5, +// Benchmark = 1 << 6 +// }; +// +// bool isHidden() const; +// bool throws() const; +// bool okToFail() const; +// bool expectedToFail() const; +// +// std::string tagsAsString() const; +// +// std::string name; +// std::string className; +// std::string description; +// std::vector tags; +// std::vector lcaseTags; +// SourceLineInfo lineInfo; +// SpecialProperties properties; +// }; + +void print( std::ostream& os, int const level, std::string const& title, Catch::TestCaseInfo const& info ) { + os << ws(level ) << title << ":\n" + << ws(level+1) << "- isHidden(): " << info.isHidden() << "\n" + << ws(level+1) << "- throws(): " << info.throws() << "\n" + << ws(level+1) << "- okToFail(): " << info.okToFail() << "\n" + << ws(level+1) << "- expectedToFail(): " << info.expectedToFail() << "\n" + << ws(level+1) << "- tagsAsString(): '" << info.tagsAsString() << "'\n" + << ws(level+1) << "- name: '" << info.name << "'\n" + << ws(level+1) << "- className: '" << info.className << "'\n" + << ws(level+1) << "- description: '" << info.description << "'\n" + << ws(level+1) << "- tags: " << info.tags << "\n" + << ws(level+1) << "- lcaseTags: " << info.lcaseTags << "\n"; + print( os, level+1 , "- lineInfo", info.lineInfo ); + os << ws(level+1) << "- properties (flags): 0x" << std::hex << info.properties << std::dec << "\n"; +} + +// struct TestCaseStats { +// TestCaseInfo testInfo; +// Totals totals; +// std::string stdOut; +// std::string stdErr; +// bool aborting; +// }; + +void print( std::ostream& os, int const level, std::string const& title, Catch::TestCaseStats const& info ) { + os << ws(level ) << title << ":\n"; + print( os, level+1 , "- testInfo", info.testInfo ); + print( os, level+1 , "- totals" , info.totals ); + os << ws(level+1) << "- stdOut: " << info.stdOut << "\n" + << ws(level+1) << "- stdErr: " << info.stdErr << "\n" + << ws(level+1) << "- aborting: " << info.aborting << "\n"; +} + +// struct SectionInfo { +// std::string name; +// std::string description; +// SourceLineInfo lineInfo; +// }; + +void print( std::ostream& os, int const level, std::string const& title, Catch::SectionInfo const& info ) { + os << ws(level ) << title << ":\n" + << ws(level+1) << "- name: " << info.name << "\n"; + print( os, level+1 , "- lineInfo", info.lineInfo ); +} + +// struct SectionStats { +// SectionInfo sectionInfo; +// Counts assertions; +// double durationInSeconds; +// bool missingAssertions; +// }; + +void print( std::ostream& os, int const level, std::string const& title, Catch::SectionStats const& info ) { + os << ws(level ) << title << ":\n"; + print( os, level+1 , "- sectionInfo", info.sectionInfo ); + print( os, level+1 , "- assertions" , info.assertions ); + os << ws(level+1) << "- durationInSeconds: " << info.durationInSeconds << "\n" + << ws(level+1) << "- missingAssertions: " << info.missingAssertions << "\n"; +} + +// struct AssertionInfo +// { +// StringRef macroName; +// SourceLineInfo lineInfo; +// StringRef capturedExpression; +// ResultDisposition::Flags resultDisposition; +// }; + +void print( std::ostream& os, int const level, std::string const& title, Catch::AssertionInfo const& info ) { + os << ws(level ) << title << ":\n" + << ws(level+1) << "- macroName: '" << info.macroName << "'\n"; + print( os, level+1 , "- lineInfo" , info.lineInfo ); + os << ws(level+1) << "- capturedExpression: '" << info.capturedExpression << "'\n" + << ws(level+1) << "- resultDisposition (flags): 0x" << std::hex << info.resultDisposition << std::dec << "\n"; +} + +//struct AssertionResultData +//{ +// std::string reconstructExpression() const; +// +// std::string message; +// mutable std::string reconstructedExpression; +// LazyExpression lazyExpression; +// ResultWas::OfType resultType; +//}; + +void print( std::ostream& os, int const level, std::string const& title, Catch::AssertionResultData const& info ) { + os << ws(level ) << title << ":\n" + << ws(level+1) << "- reconstructExpression(): '" << info.reconstructExpression() << "'\n" + << ws(level+1) << "- message: '" << info.message << "'\n" + << ws(level+1) << "- lazyExpression: '" << "(info.lazyExpression)" << "'\n" + << ws(level+1) << "- resultType: '" << info.resultType << "'\n"; +} + +//class AssertionResult { +// bool isOk() const; +// bool succeeded() const; +// ResultWas::OfType getResultType() const; +// bool hasExpression() const; +// bool hasMessage() const; +// std::string getExpression() const; +// std::string getExpressionInMacro() const; +// bool hasExpandedExpression() const; +// std::string getExpandedExpression() const; +// std::string getMessage() const; +// SourceLineInfo getSourceInfo() const; +// std::string getTestMacroName() const; +// +// AssertionInfo m_info; +// AssertionResultData m_resultData; +//}; + +void print( std::ostream& os, int const level, std::string const& title, Catch::AssertionResult const& info ) { + os << ws(level ) << title << ":\n" + << ws(level+1) << "- isOk(): " << info.isOk() << "\n" + << ws(level+1) << "- succeeded(): " << info.succeeded() << "\n" + << ws(level+1) << "- getResultType(): " << info.getResultType() << "\n" + << ws(level+1) << "- hasExpression(): " << info.hasExpression() << "\n" + << ws(level+1) << "- hasMessage(): " << info.hasMessage() << "\n" + << ws(level+1) << "- getExpression(): '" << info.getExpression() << "'\n" + << ws(level+1) << "- getExpressionInMacro(): '" << info.getExpressionInMacro() << "'\n" + << ws(level+1) << "- hasExpandedExpression(): " << info.hasExpandedExpression() << "\n" + << ws(level+1) << "- getExpandedExpression(): " << info.getExpandedExpression() << "'\n" + << ws(level+1) << "- getMessage(): '" << info.getMessage() << "'\n"; + print( os, level+1 , "- getSourceInfo(): ", info.getSourceInfo() ); + os << ws(level+1) << "- getTestMacroName(): '" << info.getTestMacroName() << "'\n"; + +// print( os, level+1 , "- *** m_info (AssertionInfo)", info.m_info ); +// print( os, level+1 , "- *** m_resultData (AssertionResultData)", info.m_resultData ); +} + +// struct AssertionStats { +// AssertionResult assertionResult; +// std::vector infoMessages; +// Totals totals; +// }; + +void print( std::ostream& os, int const level, std::string const& title, Catch::AssertionStats const& info ) { + os << ws(level ) << title << ":\n"; + print( os, level+1 , "- assertionResult", info.assertionResult ); + print( os, level+1 , "- infoMessages", info.infoMessages ); + print( os, level+1 , "- totals", info.totals ); +} + +// ----------------------------------------------------------------------- +// 2. My listener and registration: +// + +char const * dashed_line = + "--------------------------------------------------------------------------"; + +struct MyListener : Catch::TestEventListenerBase { + + using TestEventListenerBase::TestEventListenerBase; // inherit constructor + + // Get rid of Wweak-tables + ~MyListener(); + + // The whole test run starting + virtual void testRunStarting( Catch::TestRunInfo const& testRunInfo ) override { + std::cout + << std::boolalpha + << "\nEvent: testRunStarting:\n"; + print( std::cout, 1, "- testRunInfo", testRunInfo ); + } + + // The whole test run ending + virtual void testRunEnded( Catch::TestRunStats const& testRunStats ) override { + std::cout + << dashed_line + << "\nEvent: testRunEnded:\n"; + print( std::cout, 1, "- testRunStats", testRunStats ); + } + + // A test is being skipped (because it is "hidden") + virtual void skipTest( Catch::TestCaseInfo const& testInfo ) override { + std::cout + << dashed_line + << "\nEvent: skipTest:\n"; + print( std::cout, 1, "- testInfo", testInfo ); + } + + // Test cases starting + virtual void testCaseStarting( Catch::TestCaseInfo const& testInfo ) override { + std::cout + << dashed_line + << "\nEvent: testCaseStarting:\n"; + print( std::cout, 1, "- testInfo", testInfo ); + } + + // Test cases ending + virtual void testCaseEnded( Catch::TestCaseStats const& testCaseStats ) override { + std::cout << "\nEvent: testCaseEnded:\n"; + print( std::cout, 1, "testCaseStats", testCaseStats ); + } + + // Sections starting + virtual void sectionStarting( Catch::SectionInfo const& sectionInfo ) override { + std::cout << "\nEvent: sectionStarting:\n"; + print( std::cout, 1, "- sectionInfo", sectionInfo ); + } + + // Sections ending + virtual void sectionEnded( Catch::SectionStats const& sectionStats ) override { + std::cout << "\nEvent: sectionEnded:\n"; + print( std::cout, 1, "- sectionStats", sectionStats ); + } + + // Assertions before/ after + virtual void assertionStarting( Catch::AssertionInfo const& assertionInfo ) override { + std::cout << "\nEvent: assertionStarting:\n"; + print( std::cout, 1, "- assertionInfo", assertionInfo ); + } + + virtual bool assertionEnded( Catch::AssertionStats const& assertionStats ) override { + std::cout << "\nEvent: assertionEnded:\n"; + print( std::cout, 1, "- assertionStats", assertionStats ); + return true; + } +}; + +CATCH_REGISTER_LISTENER( MyListener ) + +// Get rid of Wweak-tables +MyListener::~MyListener() {} + + +// ----------------------------------------------------------------------- +// 3. Test cases: +// + +TEST_CASE( "1: Hidden testcase", "[.hidden]" ) { +} + +TEST_CASE( "2: Testcase with sections", "[tag-A][tag-B]" ) { + + int i = 42; + + REQUIRE( i == 42 ); + + SECTION("Section 1") { + INFO("Section 1") + i = 7; + SECTION("Section 1.1") { + INFO("Section 1.1") + REQUIRE( i == 42 ); + } + } + + SECTION("Section 2") { + INFO("Section 2") + REQUIRE( i == 42 ); + } + WARN("At end of test case"); +} + +struct Fixture { + int fortytwo() const { + return 42; + } +}; + +TEST_CASE_METHOD( Fixture, "3: Testcase with class-based fixture", "[tag-C][tag-D]" ) { + REQUIRE( fortytwo() == 42 ); +} + +// Compile & run: +// - g++ -std=c++11 -Wall -I$(CATCH_SINGLE_INCLUDE) -o 210-Evt-EventListeners 210-Evt-EventListeners.cpp 000-CatchMain.o && 210-Evt-EventListeners --success +// - cl -EHsc -I%CATCH_SINGLE_INCLUDE% 210-Evt-EventListeners.cpp 000-CatchMain.obj && 210-Evt-EventListeners --success + +// Expected compact output (all assertions): +// +// prompt> 210-Evt-EventListeners --reporter compact --success +// result omitted for brevity. diff --git a/src/third_party/cppcodec/test/catch/examples/231-Cfg-OutputStreams.cpp b/src/third_party/cppcodec/test/catch/examples/231-Cfg-OutputStreams.cpp new file mode 100644 index 0000000000..efa9997193 --- /dev/null +++ b/src/third_party/cppcodec/test/catch/examples/231-Cfg-OutputStreams.cpp @@ -0,0 +1,49 @@ +// 231-Cfg-OutputStreams.cpp +// Show how to replace the streams with a simple custom made streambuf. + +// Note that this reimplementation _does not_ follow `std::cerr` +// semantic, because it buffers the output. For most uses however, +// there is no important difference between having `std::cerr` buffered +// or unbuffered. + +#define CATCH_CONFIG_NOSTDOUT +#define CATCH_CONFIG_MAIN +#include + +class out_buff : public std::stringbuf { + std::FILE* m_stream; +public: + out_buff(std::FILE* stream) :m_stream(stream) {} + ~out_buff() { pubsync(); } + int sync() { + int ret = 0; + for (unsigned char c : str()) { + if (putc(c, m_stream) == EOF) { + ret = -1; + break; + } + } + // Reset the buffer to avoid printing it multiple times + str(""); + return ret; + } +}; + +namespace Catch { + std::ostream& cout() { + static std::ostream ret(new out_buff(stdout)); + return ret; + } + std::ostream& clog() { + static std::ostream ret(new out_buff(stderr)); + return ret; + } + std::ostream& cerr() { + return clog(); + } +} + + +TEST_CASE("This binary uses putc to write out output", "[compilation-only]") { + SUCCEED("Nothing to test."); +} diff --git a/src/third_party/cppcodec/test/catch/examples/CMakeLists.txt b/src/third_party/cppcodec/test/catch/examples/CMakeLists.txt new file mode 100644 index 0000000000..5c471b4fdd --- /dev/null +++ b/src/third_party/cppcodec/test/catch/examples/CMakeLists.txt @@ -0,0 +1,101 @@ +# +# Build examples. +# +# Requires CATCH_BUILD_EXAMPLES to be defined 'true', see ../CMakeLists.txt. +# + +cmake_minimum_required( VERSION 3.0 ) + +project( CatchExamples CXX ) + +# define folders used: + +set( EXAMPLES_DIR ${CATCH_DIR}/examples ) +set( HEADER_DIR ${CATCH_DIR}/single_include ) + +# single-file sources: + +set( SOURCES_SINGLE_FILE + 010-TestCase.cpp + 231-Cfg-OutputStreams.cpp +) + +# multiple-file modules: + +set( SOURCES_020 + 020-TestCase-1.cpp + 020-TestCase-2.cpp +) + +# main for idiomatic test sources: + +set( SOURCES_IDIOMATIC_MAIN + 000-CatchMain.cpp +) + +# sources to combine with 000-CatchMain.cpp: + +set( SOURCES_IDIOMATIC_TESTS + 030-Asn-Require-Check.cpp + 100-Fix-Section.cpp + 110-Fix-ClassFixture.cpp + 120-Bdd-ScenarioGivenWhenThen.cpp + 210-Evt-EventListeners.cpp +) + +# check if all sources are listed, warn if not: + +set( SOURCES_ALL + ${SOURCES_020} + ${SOURCES_SINGLE_FILE} + ${SOURCES_IDIOMATIC_MAIN} + ${SOURCES_IDIOMATIC_TESTS} +) + +foreach( name ${SOURCES_ALL} ) + list( APPEND SOURCES_ALL_PATH ${EXAMPLES_DIR}/${name} ) +endforeach() + +CheckFileList( SOURCES_ALL_PATH ${EXAMPLES_DIR} ) + +# create target names: + +string( REPLACE ".cpp" "" BASENAMES_SINGLE_FILE "${SOURCES_SINGLE_FILE}" ) +string( REPLACE ".cpp" "" BASENAMES_IDIOMATIC_TESTS "${SOURCES_IDIOMATIC_TESTS}" ) + +set( TARGETS_SINGLE_FILE ${BASENAMES_SINGLE_FILE} ) +set( TARGETS_IDIOMATIC_TESTS ${BASENAMES_IDIOMATIC_TESTS} ) +set( TARGETS_ALL ${TARGETS_SINGLE_FILE} ${TARGETS_IDIOMATIC_TESTS} 020-TestCase CatchMain ) + +# define program targets: + +add_library( CatchMain OBJECT ${EXAMPLES_DIR}/${SOURCES_IDIOMATIC_MAIN} ${HEADER_DIR}/catch2/catch.hpp ) + +add_executable( 020-TestCase ${EXAMPLES_DIR}/020-TestCase-1.cpp ${EXAMPLES_DIR}/020-TestCase-2.cpp ${HEADER_DIR}/catch2/catch.hpp ) + +foreach( name ${TARGETS_SINGLE_FILE} ) + add_executable( ${name} ${EXAMPLES_DIR}/${name}.cpp ${HEADER_DIR}/catch2/catch.hpp ) +endforeach() + +foreach( name ${TARGETS_IDIOMATIC_TESTS} ) + add_executable( ${name} ${EXAMPLES_DIR}/${name}.cpp $ ${HEADER_DIR}/catch2/catch.hpp ) +endforeach() + +foreach( name ${TARGETS_ALL} ) + target_include_directories( ${name} PRIVATE ${HEADER_DIR} ) + + set_property(TARGET ${name} PROPERTY CXX_STANDARD 11) + + # Add desired warnings + if ( CMAKE_CXX_COMPILER_ID MATCHES "Clang|AppleClang|GNU" ) + target_compile_options( ${name} PRIVATE -Wall -Wextra -Wunreachable-code ) + endif() + # Clang specific warning go here + if ( CMAKE_CXX_COMPILER_ID MATCHES "Clang" ) + # Actually keep these + target_compile_options( ${name} PRIVATE -Wweak-vtables -Wexit-time-destructors -Wglobal-constructors -Wmissing-noreturn ) + endif() + if ( CMAKE_CXX_COMPILER_ID MATCHES "MSVC" ) + target_compile_options( ${name} PRIVATE /W4 /w44265 /WX ) + endif() +endforeach() diff --git a/src/third_party/cppcodec/test/catch/include/catch.hpp b/src/third_party/cppcodec/test/catch/include/catch.hpp new file mode 100644 index 0000000000..0a49cb3162 --- /dev/null +++ b/src/third_party/cppcodec/test/catch/include/catch.hpp @@ -0,0 +1,357 @@ +/* + * Created by Phil on 22/10/2010. + * Copyright 2010 Two Blue Cubes Ltd + * + * 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_CATCH_HPP_INCLUDED +#define TWOBLUECUBES_CATCH_HPP_INCLUDED + +#define CATCH_VERSION_MAJOR 2 +#define CATCH_VERSION_MINOR 3 +#define CATCH_VERSION_PATCH 0 + +#ifdef __clang__ +# pragma clang system_header +#elif defined __GNUC__ +# pragma GCC system_header +#endif + +#include "internal/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) +#include "internal/catch_platform.h" + +#ifdef CATCH_IMPL +# ifndef CLARA_CONFIG_MAIN +# define CLARA_CONFIG_MAIN_NOT_DEFINED +# define CLARA_CONFIG_MAIN +# endif +#endif + +#include "internal/catch_user_interfaces.h" +#include "internal/catch_tag_alias_autoregistrar.h" +#include "internal/catch_test_registry.h" +#include "internal/catch_capture.hpp" +#include "internal/catch_section.h" +#include "internal/catch_benchmark.h" +#include "internal/catch_interfaces_exception.h" +#include "internal/catch_approx.h" +#include "internal/catch_compiler_capabilities.h" +#include "internal/catch_string_manip.h" + +#ifndef CATCH_CONFIG_DISABLE_MATCHERS +#include "internal/catch_capture_matchers.h" +#endif + +// These files are included here so the single_include script doesn't put them +// in the conditionally compiled sections +#include "internal/catch_test_case_info.h" +#include "internal/catch_interfaces_runner.h" + +#ifdef __OBJC__ +#include "internal/catch_objc.hpp" +#endif + +#ifdef CATCH_CONFIG_EXTERNAL_INTERFACES +#include "internal/catch_external_interfaces.h" +#endif + +#endif // ! CATCH_CONFIG_IMPL_ONLY + +#ifdef CATCH_IMPL +#include "internal/catch_impl.hpp" +#endif + +#ifdef CATCH_CONFIG_MAIN +#include "internal/catch_default_main.hpp" +#endif + +#if !defined(CATCH_CONFIG_IMPL_ONLY) + +#ifdef CLARA_CONFIG_MAIN_NOT_DEFINED +# undef CLARA_CONFIG_MAIN +#endif + +#if !defined(CATCH_CONFIG_DISABLE) +////// +// If this config identifier is defined then all CATCH macros are prefixed with CATCH_ +#ifdef CATCH_CONFIG_PREFIX_ALL + +#define CATCH_REQUIRE( ... ) INTERNAL_CATCH_TEST( "CATCH_REQUIRE", Catch::ResultDisposition::Normal, __VA_ARGS__ ) +#define CATCH_REQUIRE_FALSE( ... ) INTERNAL_CATCH_TEST( "CATCH_REQUIRE_FALSE", Catch::ResultDisposition::Normal | Catch::ResultDisposition::FalseTest, __VA_ARGS__ ) + +#define CATCH_REQUIRE_THROWS( ... ) INTERNAL_CATCH_THROWS( "CATCH_REQUIRE_THROWS", Catch::ResultDisposition::Normal, "", __VA_ARGS__ ) +#define CATCH_REQUIRE_THROWS_AS( expr, exceptionType ) INTERNAL_CATCH_THROWS_AS( "CATCH_REQUIRE_THROWS_AS", exceptionType, Catch::ResultDisposition::Normal, expr ) +#define CATCH_REQUIRE_THROWS_WITH( expr, matcher ) INTERNAL_CATCH_THROWS_STR_MATCHES( "CATCH_REQUIRE_THROWS_WITH", Catch::ResultDisposition::Normal, matcher, expr ) +#if !defined(CATCH_CONFIG_DISABLE_MATCHERS) +#define CATCH_REQUIRE_THROWS_MATCHES( expr, exceptionType, matcher ) INTERNAL_CATCH_THROWS_MATCHES( "CATCH_REQUIRE_THROWS_MATCHES", exceptionType, Catch::ResultDisposition::Normal, matcher, expr ) +#endif// CATCH_CONFIG_DISABLE_MATCHERS +#define CATCH_REQUIRE_NOTHROW( ... ) INTERNAL_CATCH_NO_THROW( "CATCH_REQUIRE_NOTHROW", Catch::ResultDisposition::Normal, __VA_ARGS__ ) + +#define CATCH_CHECK( ... ) INTERNAL_CATCH_TEST( "CATCH_CHECK", Catch::ResultDisposition::ContinueOnFailure, __VA_ARGS__ ) +#define CATCH_CHECK_FALSE( ... ) INTERNAL_CATCH_TEST( "CATCH_CHECK_FALSE", Catch::ResultDisposition::ContinueOnFailure | Catch::ResultDisposition::FalseTest, __VA_ARGS__ ) +#define CATCH_CHECKED_IF( ... ) INTERNAL_CATCH_IF( "CATCH_CHECKED_IF", Catch::ResultDisposition::ContinueOnFailure, __VA_ARGS__ ) +#define CATCH_CHECKED_ELSE( ... ) INTERNAL_CATCH_ELSE( "CATCH_CHECKED_ELSE", Catch::ResultDisposition::ContinueOnFailure, __VA_ARGS__ ) +#define CATCH_CHECK_NOFAIL( ... ) INTERNAL_CATCH_TEST( "CATCH_CHECK_NOFAIL", Catch::ResultDisposition::ContinueOnFailure | Catch::ResultDisposition::SuppressFail, __VA_ARGS__ ) + +#define CATCH_CHECK_THROWS( ... ) INTERNAL_CATCH_THROWS( "CATCH_CHECK_THROWS", Catch::ResultDisposition::ContinueOnFailure, "", __VA_ARGS__ ) +#define CATCH_CHECK_THROWS_AS( expr, exceptionType ) INTERNAL_CATCH_THROWS_AS( "CATCH_CHECK_THROWS_AS", exceptionType, Catch::ResultDisposition::ContinueOnFailure, expr ) +#define CATCH_CHECK_THROWS_WITH( expr, matcher ) INTERNAL_CATCH_THROWS_STR_MATCHES( "CATCH_CHECK_THROWS_WITH", Catch::ResultDisposition::ContinueOnFailure, matcher, expr ) +#if !defined(CATCH_CONFIG_DISABLE_MATCHERS) +#define CATCH_CHECK_THROWS_MATCHES( expr, exceptionType, matcher ) INTERNAL_CATCH_THROWS_MATCHES( "CATCH_CHECK_THROWS_MATCHES", exceptionType, Catch::ResultDisposition::ContinueOnFailure, matcher, expr ) +#endif // CATCH_CONFIG_DISABLE_MATCHERS +#define CATCH_CHECK_NOTHROW( ... ) INTERNAL_CATCH_NO_THROW( "CATCH_CHECK_NOTHROW", Catch::ResultDisposition::ContinueOnFailure, __VA_ARGS__ ) + +#if !defined(CATCH_CONFIG_DISABLE_MATCHERS) +#define CATCH_CHECK_THAT( arg, matcher ) INTERNAL_CHECK_THAT( "CATCH_CHECK_THAT", matcher, Catch::ResultDisposition::ContinueOnFailure, arg ) + +#define CATCH_REQUIRE_THAT( arg, matcher ) INTERNAL_CHECK_THAT( "CATCH_REQUIRE_THAT", matcher, Catch::ResultDisposition::Normal, arg ) +#endif // CATCH_CONFIG_DISABLE_MATCHERS + +#define CATCH_INFO( msg ) INTERNAL_CATCH_INFO( "CATCH_INFO", msg ) +#define CATCH_WARN( msg ) INTERNAL_CATCH_MSG( "CATCH_WARN", Catch::ResultWas::Warning, Catch::ResultDisposition::ContinueOnFailure, msg ) +#define CATCH_CAPTURE( msg ) INTERNAL_CATCH_INFO( "CATCH_CAPTURE", #msg " := " << ::Catch::Detail::stringify(msg) ) + +#define CATCH_TEST_CASE( ... ) INTERNAL_CATCH_TESTCASE( __VA_ARGS__ ) +#define CATCH_TEST_CASE_METHOD( className, ... ) INTERNAL_CATCH_TEST_CASE_METHOD( className, __VA_ARGS__ ) +#define CATCH_METHOD_AS_TEST_CASE( method, ... ) INTERNAL_CATCH_METHOD_AS_TEST_CASE( method, __VA_ARGS__ ) +#define CATCH_REGISTER_TEST_CASE( Function, ... ) INTERNAL_CATCH_REGISTER_TESTCASE( Function, __VA_ARGS__ ) +#define CATCH_SECTION( ... ) INTERNAL_CATCH_SECTION( __VA_ARGS__ ) +#define CATCH_DYNAMIC_SECTION( ... ) INTERNAL_CATCH_DYNAMIC_SECTION( __VA_ARGS__ ) +#define CATCH_FAIL( ... ) INTERNAL_CATCH_MSG( "CATCH_FAIL", Catch::ResultWas::ExplicitFailure, Catch::ResultDisposition::Normal, __VA_ARGS__ ) +#define CATCH_FAIL_CHECK( ... ) INTERNAL_CATCH_MSG( "CATCH_FAIL_CHECK", Catch::ResultWas::ExplicitFailure, Catch::ResultDisposition::ContinueOnFailure, __VA_ARGS__ ) +#define CATCH_SUCCEED( ... ) INTERNAL_CATCH_MSG( "CATCH_SUCCEED", Catch::ResultWas::Ok, Catch::ResultDisposition::ContinueOnFailure, __VA_ARGS__ ) + +#define CATCH_ANON_TEST_CASE() INTERNAL_CATCH_TESTCASE() + +// "BDD-style" convenience wrappers +#define CATCH_SCENARIO( ... ) CATCH_TEST_CASE( "Scenario: " __VA_ARGS__ ) +#define CATCH_SCENARIO_METHOD( className, ... ) INTERNAL_CATCH_TEST_CASE_METHOD( className, "Scenario: " __VA_ARGS__ ) +#define CATCH_GIVEN( desc ) INTERNAL_CATCH_DYNAMIC_SECTION( " Given: " << desc ) +#define CATCH_WHEN( desc ) INTERNAL_CATCH_DYNAMIC_SECTION( " When: " << desc ) +#define CATCH_AND_WHEN( desc ) INTERNAL_CATCH_DYNAMIC_SECTION( "And when: " << desc ) +#define CATCH_THEN( desc ) INTERNAL_CATCH_DYNAMIC_SECTION( " Then: " << desc ) +#define CATCH_AND_THEN( desc ) INTERNAL_CATCH_DYNAMIC_SECTION( " And: " << desc ) + +// If CATCH_CONFIG_PREFIX_ALL is not defined then the CATCH_ prefix is not required +#else + +#define REQUIRE( ... ) INTERNAL_CATCH_TEST( "REQUIRE", Catch::ResultDisposition::Normal, __VA_ARGS__ ) +#define REQUIRE_FALSE( ... ) INTERNAL_CATCH_TEST( "REQUIRE_FALSE", Catch::ResultDisposition::Normal | Catch::ResultDisposition::FalseTest, __VA_ARGS__ ) + +#define REQUIRE_THROWS( ... ) INTERNAL_CATCH_THROWS( "REQUIRE_THROWS", Catch::ResultDisposition::Normal, __VA_ARGS__ ) +#define REQUIRE_THROWS_AS( expr, exceptionType ) INTERNAL_CATCH_THROWS_AS( "REQUIRE_THROWS_AS", exceptionType, Catch::ResultDisposition::Normal, expr ) +#define REQUIRE_THROWS_WITH( expr, matcher ) INTERNAL_CATCH_THROWS_STR_MATCHES( "REQUIRE_THROWS_WITH", Catch::ResultDisposition::Normal, matcher, expr ) +#if !defined(CATCH_CONFIG_DISABLE_MATCHERS) +#define REQUIRE_THROWS_MATCHES( expr, exceptionType, matcher ) INTERNAL_CATCH_THROWS_MATCHES( "REQUIRE_THROWS_MATCHES", exceptionType, Catch::ResultDisposition::Normal, matcher, expr ) +#endif // CATCH_CONFIG_DISABLE_MATCHERS +#define REQUIRE_NOTHROW( ... ) INTERNAL_CATCH_NO_THROW( "REQUIRE_NOTHROW", Catch::ResultDisposition::Normal, __VA_ARGS__ ) + +#define CHECK( ... ) INTERNAL_CATCH_TEST( "CHECK", Catch::ResultDisposition::ContinueOnFailure, __VA_ARGS__ ) +#define CHECK_FALSE( ... ) INTERNAL_CATCH_TEST( "CHECK_FALSE", Catch::ResultDisposition::ContinueOnFailure | Catch::ResultDisposition::FalseTest, __VA_ARGS__ ) +#define CHECKED_IF( ... ) INTERNAL_CATCH_IF( "CHECKED_IF", Catch::ResultDisposition::ContinueOnFailure, __VA_ARGS__ ) +#define CHECKED_ELSE( ... ) INTERNAL_CATCH_ELSE( "CHECKED_ELSE", Catch::ResultDisposition::ContinueOnFailure, __VA_ARGS__ ) +#define CHECK_NOFAIL( ... ) INTERNAL_CATCH_TEST( "CHECK_NOFAIL", Catch::ResultDisposition::ContinueOnFailure | Catch::ResultDisposition::SuppressFail, __VA_ARGS__ ) + +#define CHECK_THROWS( ... ) INTERNAL_CATCH_THROWS( "CHECK_THROWS", Catch::ResultDisposition::ContinueOnFailure, __VA_ARGS__ ) +#define CHECK_THROWS_AS( expr, exceptionType ) INTERNAL_CATCH_THROWS_AS( "CHECK_THROWS_AS", exceptionType, Catch::ResultDisposition::ContinueOnFailure, expr ) +#define CHECK_THROWS_WITH( expr, matcher ) INTERNAL_CATCH_THROWS_STR_MATCHES( "CHECK_THROWS_WITH", Catch::ResultDisposition::ContinueOnFailure, matcher, expr ) +#if !defined(CATCH_CONFIG_DISABLE_MATCHERS) +#define CHECK_THROWS_MATCHES( expr, exceptionType, matcher ) INTERNAL_CATCH_THROWS_MATCHES( "CHECK_THROWS_MATCHES", exceptionType, Catch::ResultDisposition::ContinueOnFailure, matcher, expr ) +#endif // CATCH_CONFIG_DISABLE_MATCHERS +#define CHECK_NOTHROW( ... ) INTERNAL_CATCH_NO_THROW( "CHECK_NOTHROW", Catch::ResultDisposition::ContinueOnFailure, __VA_ARGS__ ) + + +#if !defined(CATCH_CONFIG_DISABLE_MATCHERS) +#define CHECK_THAT( arg, matcher ) INTERNAL_CHECK_THAT( "CHECK_THAT", matcher, Catch::ResultDisposition::ContinueOnFailure, arg ) + +#define REQUIRE_THAT( arg, matcher ) INTERNAL_CHECK_THAT( "REQUIRE_THAT", matcher, Catch::ResultDisposition::Normal, arg ) +#endif // CATCH_CONFIG_DISABLE_MATCHERS + +#define INFO( msg ) INTERNAL_CATCH_INFO( "INFO", msg ) +#define WARN( msg ) INTERNAL_CATCH_MSG( "WARN", Catch::ResultWas::Warning, Catch::ResultDisposition::ContinueOnFailure, msg ) +#define CAPTURE( msg ) INTERNAL_CATCH_INFO( "CAPTURE", #msg " := " << ::Catch::Detail::stringify(msg) ) + +#define TEST_CASE( ... ) INTERNAL_CATCH_TESTCASE( __VA_ARGS__ ) +#define TEST_CASE_METHOD( className, ... ) INTERNAL_CATCH_TEST_CASE_METHOD( className, __VA_ARGS__ ) +#define METHOD_AS_TEST_CASE( method, ... ) INTERNAL_CATCH_METHOD_AS_TEST_CASE( method, __VA_ARGS__ ) +#define REGISTER_TEST_CASE( Function, ... ) INTERNAL_CATCH_REGISTER_TESTCASE( Function, __VA_ARGS__ ) +#define SECTION( ... ) INTERNAL_CATCH_SECTION( __VA_ARGS__ ) +#define DYNAMIC_SECTION( ... ) INTERNAL_CATCH_DYNAMIC_SECTION( __VA_ARGS__ ) +#define FAIL( ... ) INTERNAL_CATCH_MSG( "FAIL", Catch::ResultWas::ExplicitFailure, Catch::ResultDisposition::Normal, __VA_ARGS__ ) +#define FAIL_CHECK( ... ) INTERNAL_CATCH_MSG( "FAIL_CHECK", Catch::ResultWas::ExplicitFailure, Catch::ResultDisposition::ContinueOnFailure, __VA_ARGS__ ) +#define SUCCEED( ... ) INTERNAL_CATCH_MSG( "SUCCEED", Catch::ResultWas::Ok, Catch::ResultDisposition::ContinueOnFailure, __VA_ARGS__ ) +#define ANON_TEST_CASE() INTERNAL_CATCH_TESTCASE() + +#endif + +#define CATCH_TRANSLATE_EXCEPTION( signature ) INTERNAL_CATCH_TRANSLATE_EXCEPTION( signature ) + +// "BDD-style" convenience wrappers +#define SCENARIO( ... ) TEST_CASE( "Scenario: " __VA_ARGS__ ) +#define SCENARIO_METHOD( className, ... ) INTERNAL_CATCH_TEST_CASE_METHOD( className, "Scenario: " __VA_ARGS__ ) + +#define GIVEN( desc ) INTERNAL_CATCH_DYNAMIC_SECTION( " Given: " << desc ) +#define WHEN( desc ) INTERNAL_CATCH_DYNAMIC_SECTION( " When: " << desc ) +#define AND_WHEN( desc ) INTERNAL_CATCH_DYNAMIC_SECTION( "And when: " << desc ) +#define THEN( desc ) INTERNAL_CATCH_DYNAMIC_SECTION( " Then: " << desc ) +#define AND_THEN( desc ) INTERNAL_CATCH_DYNAMIC_SECTION( " And: " << desc ) + +using Catch::Detail::Approx; + +#else // CATCH_CONFIG_DISABLE + +////// +// If this config identifier is defined then all CATCH macros are prefixed with CATCH_ +#ifdef CATCH_CONFIG_PREFIX_ALL + +#define CATCH_REQUIRE( ... ) (void)(0) +#define CATCH_REQUIRE_FALSE( ... ) (void)(0) + +#define CATCH_REQUIRE_THROWS( ... ) (void)(0) +#define CATCH_REQUIRE_THROWS_AS( expr, exceptionType ) (void)(0) +#define CATCH_REQUIRE_THROWS_WITH( expr, matcher ) (void)(0) +#if !defined(CATCH_CONFIG_DISABLE_MATCHERS) +#define CATCH_REQUIRE_THROWS_MATCHES( expr, exceptionType, matcher ) (void)(0) +#endif// CATCH_CONFIG_DISABLE_MATCHERS +#define CATCH_REQUIRE_NOTHROW( ... ) (void)(0) + +#define CATCH_CHECK( ... ) (void)(0) +#define CATCH_CHECK_FALSE( ... ) (void)(0) +#define CATCH_CHECKED_IF( ... ) if (__VA_ARGS__) +#define CATCH_CHECKED_ELSE( ... ) if (!(__VA_ARGS__)) +#define CATCH_CHECK_NOFAIL( ... ) (void)(0) + +#define CATCH_CHECK_THROWS( ... ) (void)(0) +#define CATCH_CHECK_THROWS_AS( expr, exceptionType ) (void)(0) +#define CATCH_CHECK_THROWS_WITH( expr, matcher ) (void)(0) +#if !defined(CATCH_CONFIG_DISABLE_MATCHERS) +#define CATCH_CHECK_THROWS_MATCHES( expr, exceptionType, matcher ) (void)(0) +#endif // CATCH_CONFIG_DISABLE_MATCHERS +#define CATCH_CHECK_NOTHROW( ... ) (void)(0) + +#if !defined(CATCH_CONFIG_DISABLE_MATCHERS) +#define CATCH_CHECK_THAT( arg, matcher ) (void)(0) + +#define CATCH_REQUIRE_THAT( arg, matcher ) (void)(0) +#endif // CATCH_CONFIG_DISABLE_MATCHERS + +#define CATCH_INFO( msg ) (void)(0) +#define CATCH_WARN( msg ) (void)(0) +#define CATCH_CAPTURE( msg ) (void)(0) + +#define CATCH_TEST_CASE( ... ) INTERNAL_CATCH_TESTCASE_NO_REGISTRATION(INTERNAL_CATCH_UNIQUE_NAME( ____C_A_T_C_H____T_E_S_T____ )) +#define CATCH_TEST_CASE_METHOD( className, ... ) INTERNAL_CATCH_TESTCASE_NO_REGISTRATION(INTERNAL_CATCH_UNIQUE_NAME( ____C_A_T_C_H____T_E_S_T____ )) +#define CATCH_METHOD_AS_TEST_CASE( method, ... ) +#define CATCH_REGISTER_TEST_CASE( Function, ... ) (void)(0) +#define CATCH_SECTION( ... ) +#define CATCH_DYNAMIC_SECTION( ... ) +#define CATCH_FAIL( ... ) (void)(0) +#define CATCH_FAIL_CHECK( ... ) (void)(0) +#define CATCH_SUCCEED( ... ) (void)(0) + +#define CATCH_ANON_TEST_CASE() INTERNAL_CATCH_TESTCASE_NO_REGISTRATION(INTERNAL_CATCH_UNIQUE_NAME( ____C_A_T_C_H____T_E_S_T____ )) + +// "BDD-style" convenience wrappers +#define CATCH_SCENARIO( ... ) INTERNAL_CATCH_TESTCASE_NO_REGISTRATION(INTERNAL_CATCH_UNIQUE_NAME( ____C_A_T_C_H____T_E_S_T____ )) +#define CATCH_SCENARIO_METHOD( className, ... ) INTERNAL_CATCH_TESTCASE_METHOD_NO_REGISTRATION(INTERNAL_CATCH_UNIQUE_NAME( ____C_A_T_C_H____T_E_S_T____ ), className ) +#define CATCH_GIVEN( desc ) +#define CATCH_WHEN( desc ) +#define CATCH_AND_WHEN( desc ) +#define CATCH_THEN( desc ) +#define CATCH_AND_THEN( desc ) + +// If CATCH_CONFIG_PREFIX_ALL is not defined then the CATCH_ prefix is not required +#else + +#define REQUIRE( ... ) (void)(0) +#define REQUIRE_FALSE( ... ) (void)(0) + +#define REQUIRE_THROWS( ... ) (void)(0) +#define REQUIRE_THROWS_AS( expr, exceptionType ) (void)(0) +#define REQUIRE_THROWS_WITH( expr, matcher ) (void)(0) +#if !defined(CATCH_CONFIG_DISABLE_MATCHERS) +#define REQUIRE_THROWS_MATCHES( expr, exceptionType, matcher ) (void)(0) +#endif // CATCH_CONFIG_DISABLE_MATCHERS +#define REQUIRE_NOTHROW( ... ) (void)(0) + +#define CHECK( ... ) (void)(0) +#define CHECK_FALSE( ... ) (void)(0) +#define CHECKED_IF( ... ) if (__VA_ARGS__) +#define CHECKED_ELSE( ... ) if (!(__VA_ARGS__)) +#define CHECK_NOFAIL( ... ) (void)(0) + +#define CHECK_THROWS( ... ) (void)(0) +#define CHECK_THROWS_AS( expr, exceptionType ) (void)(0) +#define CHECK_THROWS_WITH( expr, matcher ) (void)(0) +#if !defined(CATCH_CONFIG_DISABLE_MATCHERS) +#define CHECK_THROWS_MATCHES( expr, exceptionType, matcher ) (void)(0) +#endif // CATCH_CONFIG_DISABLE_MATCHERS +#define CHECK_NOTHROW( ... ) (void)(0) + + +#if !defined(CATCH_CONFIG_DISABLE_MATCHERS) +#define CHECK_THAT( arg, matcher ) (void)(0) + +#define REQUIRE_THAT( arg, matcher ) (void)(0) +#endif // CATCH_CONFIG_DISABLE_MATCHERS + +#define INFO( msg ) (void)(0) +#define WARN( msg ) (void)(0) +#define CAPTURE( msg ) (void)(0) + +#define TEST_CASE( ... ) INTERNAL_CATCH_TESTCASE_NO_REGISTRATION(INTERNAL_CATCH_UNIQUE_NAME( ____C_A_T_C_H____T_E_S_T____ )) +#define TEST_CASE_METHOD( className, ... ) INTERNAL_CATCH_TESTCASE_NO_REGISTRATION(INTERNAL_CATCH_UNIQUE_NAME( ____C_A_T_C_H____T_E_S_T____ )) +#define METHOD_AS_TEST_CASE( method, ... ) +#define REGISTER_TEST_CASE( Function, ... ) (void)(0) +#define SECTION( ... ) +#define DYNAMIC_SECTION( ... ) +#define FAIL( ... ) (void)(0) +#define FAIL_CHECK( ... ) (void)(0) +#define SUCCEED( ... ) (void)(0) +#define ANON_TEST_CASE() INTERNAL_CATCH_TESTCASE_NO_REGISTRATION(INTERNAL_CATCH_UNIQUE_NAME( ____C_A_T_C_H____T_E_S_T____ )) + +#endif + +#define CATCH_TRANSLATE_EXCEPTION( signature ) INTERNAL_CATCH_TRANSLATE_EXCEPTION_NO_REG( INTERNAL_CATCH_UNIQUE_NAME( catch_internal_ExceptionTranslator ), signature ) + +// "BDD-style" convenience wrappers +#define SCENARIO( ... ) INTERNAL_CATCH_TESTCASE_NO_REGISTRATION(INTERNAL_CATCH_UNIQUE_NAME( ____C_A_T_C_H____T_E_S_T____ ) ) +#define SCENARIO_METHOD( className, ... ) INTERNAL_CATCH_TESTCASE_METHOD_NO_REGISTRATION(INTERNAL_CATCH_UNIQUE_NAME( ____C_A_T_C_H____T_E_S_T____ ), className ) + +#define GIVEN( desc ) +#define WHEN( desc ) +#define AND_WHEN( desc ) +#define THEN( desc ) +#define AND_THEN( desc ) + +using Catch::Detail::Approx; + + +#endif + +#endif // ! CATCH_CONFIG_IMPL_ONLY + +#include "internal/catch_reenable_warnings.h" + +#endif // TWOBLUECUBES_CATCH_HPP_INCLUDED diff --git a/src/third_party/cppcodec/test/catch/include/catch_with_main.hpp b/src/third_party/cppcodec/test/catch/include/catch_with_main.hpp new file mode 100644 index 0000000000..54aa651f66 --- /dev/null +++ b/src/third_party/cppcodec/test/catch/include/catch_with_main.hpp @@ -0,0 +1,14 @@ + /* + * Created by Phil on 01/11/2010. + * Copyright 2010 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_CATCH_WITH_MAIN_HPP_INCLUDED +#define TWOBLUECUBES_CATCH_WITH_MAIN_HPP_INCLUDED + +#define CATCH_CONFIG_MAIN +#include "catch.hpp" + +#endif // TWOBLUECUBES_CATCH_WITH_MAIN_HPP_INCLUDED diff --git a/src/third_party/cppcodec/test/catch/include/external/clara.hpp b/src/third_party/cppcodec/test/catch/include/external/clara.hpp new file mode 100644 index 0000000000..3a7f883637 --- /dev/null +++ b/src/third_party/cppcodec/test/catch/include/external/clara.hpp @@ -0,0 +1,1256 @@ +// Copyright 2017 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) +// +// See https://github.com/philsquared/Clara for more details + +// Clara v1.1.4 + +#ifndef CATCH_CLARA_HPP_INCLUDED +#define CATCH_CLARA_HPP_INCLUDED + +#ifndef CATCH_CLARA_CONFIG_CONSOLE_WIDTH +#define CATCH_CLARA_CONFIG_CONSOLE_WIDTH 80 +#endif + +#ifndef CATCH_CLARA_TEXTFLOW_CONFIG_CONSOLE_WIDTH +#define CATCH_CLARA_TEXTFLOW_CONFIG_CONSOLE_WIDTH CATCH_CLARA_CONFIG_CONSOLE_WIDTH +#endif + +#ifndef CLARA_CONFIG_OPTIONAL_TYPE +#ifdef __has_include +#if __has_include() && __cplusplus >= 201703L +#include +#define CLARA_CONFIG_OPTIONAL_TYPE std::optional +#endif +#endif +#endif + + +// ----------- #included from clara_textflow.hpp ----------- + +// TextFlowCpp +// +// A single-header library for wrapping and laying out basic text, by Phil Nash +// +// This work is licensed under the BSD 2-Clause license. +// See the accompanying LICENSE file, or the one at https://opensource.org/licenses/BSD-2-Clause +// +// This project is hosted at https://github.com/philsquared/textflowcpp + +#ifndef CATCH_CLARA_TEXTFLOW_HPP_INCLUDED +#define CATCH_CLARA_TEXTFLOW_HPP_INCLUDED + +#include +#include +#include +#include + +#ifndef CATCH_CLARA_TEXTFLOW_CONFIG_CONSOLE_WIDTH +#define CATCH_CLARA_TEXTFLOW_CONFIG_CONSOLE_WIDTH 80 +#endif + + +namespace Catch { namespace clara { namespace TextFlow { + + inline auto isWhitespace( char c ) -> bool { + static std::string chars = " \t\n\r"; + return chars.find( c ) != std::string::npos; + } + inline auto isBreakableBefore( char c ) -> bool { + static std::string chars = "[({<|"; + return chars.find( c ) != std::string::npos; + } + inline auto isBreakableAfter( char c ) -> bool { + static std::string chars = "])}>.,:;*+-=&/\\"; + return chars.find( c ) != std::string::npos; + } + + class Columns; + + class Column { + std::vector m_strings; + size_t m_width = CATCH_CLARA_TEXTFLOW_CONFIG_CONSOLE_WIDTH; + size_t m_indent = 0; + size_t m_initialIndent = std::string::npos; + + public: + class iterator { + friend Column; + + Column const& m_column; + size_t m_stringIndex = 0; + size_t m_pos = 0; + + size_t m_len = 0; + size_t m_end = 0; + bool m_suffix = false; + + iterator( Column const& column, size_t stringIndex ) + : m_column( column ), + m_stringIndex( stringIndex ) + {} + + auto line() const -> std::string const& { return m_column.m_strings[m_stringIndex]; } + + auto isBoundary( size_t at ) const -> bool { + assert( at > 0 ); + assert( at <= line().size() ); + + return at == line().size() || + ( isWhitespace( line()[at] ) && !isWhitespace( line()[at-1] ) ) || + isBreakableBefore( line()[at] ) || + isBreakableAfter( line()[at-1] ); + } + + void calcLength() { + assert( m_stringIndex < m_column.m_strings.size() ); + + m_suffix = false; + auto width = m_column.m_width-indent(); + m_end = m_pos; + while( m_end < line().size() && line()[m_end] != '\n' ) + ++m_end; + + if( m_end < m_pos + width ) { + m_len = m_end - m_pos; + } + else { + size_t len = width; + while (len > 0 && !isBoundary(m_pos + len)) + --len; + while (len > 0 && isWhitespace( line()[m_pos + len - 1] )) + --len; + + if (len > 0) { + m_len = len; + } else { + m_suffix = true; + m_len = width - 1; + } + } + } + + auto indent() const -> size_t { + auto initial = m_pos == 0 && m_stringIndex == 0 ? m_column.m_initialIndent : std::string::npos; + return initial == std::string::npos ? m_column.m_indent : initial; + } + + auto addIndentAndSuffix(std::string const &plain) const -> std::string { + return std::string( indent(), ' ' ) + (m_suffix ? plain + "-" : plain); + } + + public: + explicit iterator( Column const& column ) : m_column( column ) { + assert( m_column.m_width > m_column.m_indent ); + assert( m_column.m_initialIndent == std::string::npos || m_column.m_width > m_column.m_initialIndent ); + calcLength(); + if( m_len == 0 ) + m_stringIndex++; // Empty string + } + + auto operator *() const -> std::string { + assert( m_stringIndex < m_column.m_strings.size() ); + assert( m_pos <= m_end ); + if( m_pos + m_column.m_width < m_end ) + return addIndentAndSuffix(line().substr(m_pos, m_len)); + else + return addIndentAndSuffix(line().substr(m_pos, m_end - m_pos)); + } + + auto operator ++() -> iterator& { + m_pos += m_len; + if( m_pos < line().size() && line()[m_pos] == '\n' ) + m_pos += 1; + else + while( m_pos < line().size() && isWhitespace( line()[m_pos] ) ) + ++m_pos; + + if( m_pos == line().size() ) { + m_pos = 0; + ++m_stringIndex; + } + if( m_stringIndex < m_column.m_strings.size() ) + calcLength(); + return *this; + } + auto operator ++(int) -> iterator { + iterator prev( *this ); + operator++(); + return prev; + } + + auto operator ==( iterator const& other ) const -> bool { + return + m_pos == other.m_pos && + m_stringIndex == other.m_stringIndex && + &m_column == &other.m_column; + } + auto operator !=( iterator const& other ) const -> bool { + return !operator==( other ); + } + }; + using const_iterator = iterator; + + explicit Column( std::string const& text ) { m_strings.push_back( text ); } + + auto width( size_t newWidth ) -> Column& { + assert( newWidth > 0 ); + m_width = newWidth; + return *this; + } + auto indent( size_t newIndent ) -> Column& { + m_indent = newIndent; + return *this; + } + auto initialIndent( size_t newIndent ) -> Column& { + m_initialIndent = newIndent; + return *this; + } + + auto width() const -> size_t { return m_width; } + auto begin() const -> iterator { return iterator( *this ); } + auto end() const -> iterator { return { *this, m_strings.size() }; } + + inline friend std::ostream& operator << ( std::ostream& os, Column const& col ) { + bool first = true; + for( auto line : col ) { + if( first ) + first = false; + else + os << "\n"; + os << line; + } + return os; + } + + auto operator + ( Column const& other ) -> Columns; + + auto toString() const -> std::string { + std::ostringstream oss; + oss << *this; + return oss.str(); + } + }; + + class Spacer : public Column { + + public: + explicit Spacer( size_t spaceWidth ) : Column( "" ) { + width( spaceWidth ); + } + }; + + class Columns { + std::vector m_columns; + + public: + + class iterator { + friend Columns; + struct EndTag {}; + + std::vector const& m_columns; + std::vector m_iterators; + size_t m_activeIterators; + + iterator( Columns const& columns, EndTag ) + : m_columns( columns.m_columns ), + m_activeIterators( 0 ) + { + m_iterators.reserve( m_columns.size() ); + + for( auto const& col : m_columns ) + m_iterators.push_back( col.end() ); + } + + public: + explicit iterator( Columns const& columns ) + : m_columns( columns.m_columns ), + m_activeIterators( m_columns.size() ) + { + m_iterators.reserve( m_columns.size() ); + + for( auto const& col : m_columns ) + m_iterators.push_back( col.begin() ); + } + + auto operator ==( iterator const& other ) const -> bool { + return m_iterators == other.m_iterators; + } + auto operator !=( iterator const& other ) const -> bool { + return m_iterators != other.m_iterators; + } + auto operator *() const -> std::string { + std::string row, padding; + + for( size_t i = 0; i < m_columns.size(); ++i ) { + auto width = m_columns[i].width(); + if( m_iterators[i] != m_columns[i].end() ) { + std::string col = *m_iterators[i]; + row += padding + col; + if( col.size() < width ) + padding = std::string( width - col.size(), ' ' ); + else + padding = ""; + } + else { + padding += std::string( width, ' ' ); + } + } + return row; + } + auto operator ++() -> iterator& { + for( size_t i = 0; i < m_columns.size(); ++i ) { + if (m_iterators[i] != m_columns[i].end()) + ++m_iterators[i]; + } + return *this; + } + auto operator ++(int) -> iterator { + iterator prev( *this ); + operator++(); + return prev; + } + }; + using const_iterator = iterator; + + auto begin() const -> iterator { return iterator( *this ); } + auto end() const -> iterator { return { *this, iterator::EndTag() }; } + + auto operator += ( Column const& col ) -> Columns& { + m_columns.push_back( col ); + return *this; + } + auto operator + ( Column const& col ) -> Columns { + Columns combined = *this; + combined += col; + return combined; + } + + inline friend std::ostream& operator << ( std::ostream& os, Columns const& cols ) { + + bool first = true; + for( auto line : cols ) { + if( first ) + first = false; + else + os << "\n"; + os << line; + } + return os; + } + + auto toString() const -> std::string { + std::ostringstream oss; + oss << *this; + return oss.str(); + } + }; + + inline auto Column::operator + ( Column const& other ) -> Columns { + Columns cols; + cols += *this; + cols += other; + return cols; + } +}}} // namespace Catch::clara::TextFlow + +#endif // CATCH_CLARA_TEXTFLOW_HPP_INCLUDED + +// ----------- end of #include from clara_textflow.hpp ----------- +// ........... back in clara.hpp + + +#include +#include +#include + +#if !defined(CATCH_PLATFORM_WINDOWS) && ( defined(WIN32) || defined(__WIN32__) || defined(_WIN32) || defined(_MSC_VER) ) +#define CATCH_PLATFORM_WINDOWS +#endif + +namespace Catch { namespace clara { +namespace detail { + + // Traits for extracting arg and return type of lambdas (for single argument lambdas) + template + struct UnaryLambdaTraits : UnaryLambdaTraits {}; + + template + struct UnaryLambdaTraits { + static const bool isValid = false; + }; + + template + struct UnaryLambdaTraits { + static const bool isValid = true; + using ArgType = typename std::remove_const::type>::type; + using ReturnType = ReturnT; + }; + + class TokenStream; + + // Transport for raw args (copied from main args, or supplied via init list for testing) + class Args { + friend TokenStream; + std::string m_exeName; + std::vector m_args; + + public: + Args( int argc, char const* const* argv ) + : m_exeName(argv[0]), + m_args(argv + 1, argv + argc) {} + + Args( std::initializer_list args ) + : m_exeName( *args.begin() ), + m_args( args.begin()+1, args.end() ) + {} + + auto exeName() const -> std::string { + return m_exeName; + } + }; + + // Wraps a token coming from a token stream. These may not directly correspond to strings as a single string + // may encode an option + its argument if the : or = form is used + enum class TokenType { + Option, Argument + }; + struct Token { + TokenType type; + std::string token; + }; + + inline auto isOptPrefix( char c ) -> bool { + return c == '-' +#ifdef CATCH_PLATFORM_WINDOWS + || c == '/' +#endif + ; + } + + // Abstracts iterators into args as a stream of tokens, with option arguments uniformly handled + class TokenStream { + using Iterator = std::vector::const_iterator; + Iterator it; + Iterator itEnd; + std::vector m_tokenBuffer; + + void loadBuffer() { + m_tokenBuffer.resize( 0 ); + + // Skip any empty strings + while( it != itEnd && it->empty() ) + ++it; + + if( it != itEnd ) { + auto const &next = *it; + if( isOptPrefix( next[0] ) ) { + auto delimiterPos = next.find_first_of( " :=" ); + if( delimiterPos != std::string::npos ) { + m_tokenBuffer.push_back( { TokenType::Option, next.substr( 0, delimiterPos ) } ); + m_tokenBuffer.push_back( { TokenType::Argument, next.substr( delimiterPos + 1 ) } ); + } else { + if( next[1] != '-' && next.size() > 2 ) { + std::string opt = "- "; + for( size_t i = 1; i < next.size(); ++i ) { + opt[1] = next[i]; + m_tokenBuffer.push_back( { TokenType::Option, opt } ); + } + } else { + m_tokenBuffer.push_back( { TokenType::Option, next } ); + } + } + } else { + m_tokenBuffer.push_back( { TokenType::Argument, next } ); + } + } + } + + public: + explicit TokenStream( Args const &args ) : TokenStream( args.m_args.begin(), args.m_args.end() ) {} + + TokenStream( Iterator it, Iterator itEnd ) : it( it ), itEnd( itEnd ) { + loadBuffer(); + } + + explicit operator bool() const { + return !m_tokenBuffer.empty() || it != itEnd; + } + + auto count() const -> size_t { return m_tokenBuffer.size() + (itEnd - it); } + + auto operator*() const -> Token { + assert( !m_tokenBuffer.empty() ); + return m_tokenBuffer.front(); + } + + auto operator->() const -> Token const * { + assert( !m_tokenBuffer.empty() ); + return &m_tokenBuffer.front(); + } + + auto operator++() -> TokenStream & { + if( m_tokenBuffer.size() >= 2 ) { + m_tokenBuffer.erase( m_tokenBuffer.begin() ); + } else { + if( it != itEnd ) + ++it; + loadBuffer(); + } + return *this; + } + }; + + + class ResultBase { + public: + enum Type { + Ok, LogicError, RuntimeError + }; + + protected: + ResultBase( Type type ) : m_type( type ) {} + virtual ~ResultBase() = default; + + virtual void enforceOk() const = 0; + + Type m_type; + }; + + template + class ResultValueBase : public ResultBase { + public: + auto value() const -> T const & { + enforceOk(); + return m_value; + } + + protected: + ResultValueBase( Type type ) : ResultBase( type ) {} + + ResultValueBase( ResultValueBase const &other ) : ResultBase( other ) { + if( m_type == ResultBase::Ok ) + new( &m_value ) T( other.m_value ); + } + + ResultValueBase( Type, T const &value ) : ResultBase( Ok ) { + new( &m_value ) T( value ); + } + + auto operator=( ResultValueBase const &other ) -> ResultValueBase & { + if( m_type == ResultBase::Ok ) + m_value.~T(); + ResultBase::operator=(other); + if( m_type == ResultBase::Ok ) + new( &m_value ) T( other.m_value ); + return *this; + } + + ~ResultValueBase() override { + if( m_type == Ok ) + m_value.~T(); + } + + union { + T m_value; + }; + }; + + template<> + class ResultValueBase : public ResultBase { + protected: + using ResultBase::ResultBase; + }; + + template + class BasicResult : public ResultValueBase { + public: + template + explicit BasicResult( BasicResult const &other ) + : ResultValueBase( other.type() ), + m_errorMessage( other.errorMessage() ) + { + assert( type() != ResultBase::Ok ); + } + + template + static auto ok( U const &value ) -> BasicResult { return { ResultBase::Ok, value }; } + static auto ok() -> BasicResult { return { ResultBase::Ok }; } + static auto logicError( std::string const &message ) -> BasicResult { return { ResultBase::LogicError, message }; } + static auto runtimeError( std::string const &message ) -> BasicResult { return { ResultBase::RuntimeError, message }; } + + explicit operator bool() const { return m_type == ResultBase::Ok; } + auto type() const -> ResultBase::Type { return m_type; } + auto errorMessage() const -> std::string { return m_errorMessage; } + + protected: + void enforceOk() const override { + + // Errors shouldn't reach this point, but if they do + // the actual error message will be in m_errorMessage + assert( m_type != ResultBase::LogicError ); + assert( m_type != ResultBase::RuntimeError ); + if( m_type != ResultBase::Ok ) + std::abort(); + } + + std::string m_errorMessage; // Only populated if resultType is an error + + BasicResult( ResultBase::Type type, std::string const &message ) + : ResultValueBase(type), + m_errorMessage(message) + { + assert( m_type != ResultBase::Ok ); + } + + using ResultValueBase::ResultValueBase; + using ResultBase::m_type; + }; + + enum class ParseResultType { + Matched, NoMatch, ShortCircuitAll, ShortCircuitSame + }; + + class ParseState { + public: + + ParseState( ParseResultType type, TokenStream const &remainingTokens ) + : m_type(type), + m_remainingTokens( remainingTokens ) + {} + + auto type() const -> ParseResultType { return m_type; } + auto remainingTokens() const -> TokenStream { return m_remainingTokens; } + + private: + ParseResultType m_type; + TokenStream m_remainingTokens; + }; + + using Result = BasicResult; + using ParserResult = BasicResult; + using InternalParseResult = BasicResult; + + struct HelpColumns { + std::string left; + std::string right; + }; + + template + inline auto convertInto( std::string const &source, T& target ) -> ParserResult { + std::stringstream ss; + ss << source; + ss >> target; + if( ss.fail() ) + return ParserResult::runtimeError( "Unable to convert '" + source + "' to destination type" ); + else + return ParserResult::ok( ParseResultType::Matched ); + } + inline auto convertInto( std::string const &source, std::string& target ) -> ParserResult { + target = source; + return ParserResult::ok( ParseResultType::Matched ); + } + inline auto convertInto( std::string const &source, bool &target ) -> ParserResult { + std::string srcLC = source; + std::transform( srcLC.begin(), srcLC.end(), srcLC.begin(), []( char c ) { return static_cast( ::tolower(c) ); } ); + if (srcLC == "y" || srcLC == "1" || srcLC == "true" || srcLC == "yes" || srcLC == "on") + target = true; + else if (srcLC == "n" || srcLC == "0" || srcLC == "false" || srcLC == "no" || srcLC == "off") + target = false; + else + return ParserResult::runtimeError( "Expected a boolean value but did not recognise: '" + source + "'" ); + return ParserResult::ok( ParseResultType::Matched ); + } +#ifdef CLARA_CONFIG_OPTIONAL_TYPE + template + inline auto convertInto( std::string const &source, CLARA_CONFIG_OPTIONAL_TYPE& target ) -> ParserResult { + T temp; + auto result = convertInto( source, temp ); + if( result ) + target = std::move(temp); + return result; + } +#endif // CLARA_CONFIG_OPTIONAL_TYPE + + struct NonCopyable { + NonCopyable() = default; + NonCopyable( NonCopyable const & ) = delete; + NonCopyable( NonCopyable && ) = delete; + NonCopyable &operator=( NonCopyable const & ) = delete; + NonCopyable &operator=( NonCopyable && ) = delete; + }; + + struct BoundRef : NonCopyable { + virtual ~BoundRef() = default; + virtual auto isContainer() const -> bool { return false; } + virtual auto isFlag() const -> bool { return false; } + }; + struct BoundValueRefBase : BoundRef { + virtual auto setValue( std::string const &arg ) -> ParserResult = 0; + }; + struct BoundFlagRefBase : BoundRef { + virtual auto setFlag( bool flag ) -> ParserResult = 0; + virtual auto isFlag() const -> bool { return true; } + }; + + template + struct BoundValueRef : BoundValueRefBase { + T &m_ref; + + explicit BoundValueRef( T &ref ) : m_ref( ref ) {} + + auto setValue( std::string const &arg ) -> ParserResult override { + return convertInto( arg, m_ref ); + } + }; + + template + struct BoundValueRef> : BoundValueRefBase { + std::vector &m_ref; + + explicit BoundValueRef( std::vector &ref ) : m_ref( ref ) {} + + auto isContainer() const -> bool override { return true; } + + auto setValue( std::string const &arg ) -> ParserResult override { + T temp; + auto result = convertInto( arg, temp ); + if( result ) + m_ref.push_back( temp ); + return result; + } + }; + + struct BoundFlagRef : BoundFlagRefBase { + bool &m_ref; + + explicit BoundFlagRef( bool &ref ) : m_ref( ref ) {} + + auto setFlag( bool flag ) -> ParserResult override { + m_ref = flag; + return ParserResult::ok( ParseResultType::Matched ); + } + }; + + template + struct LambdaInvoker { + static_assert( std::is_same::value, "Lambda must return void or clara::ParserResult" ); + + template + static auto invoke( L const &lambda, ArgType const &arg ) -> ParserResult { + return lambda( arg ); + } + }; + + template<> + struct LambdaInvoker { + template + static auto invoke( L const &lambda, ArgType const &arg ) -> ParserResult { + lambda( arg ); + return ParserResult::ok( ParseResultType::Matched ); + } + }; + + template + inline auto invokeLambda( L const &lambda, std::string const &arg ) -> ParserResult { + ArgType temp{}; + auto result = convertInto( arg, temp ); + return !result + ? result + : LambdaInvoker::ReturnType>::invoke( lambda, temp ); + } + + + template + struct BoundLambda : BoundValueRefBase { + L m_lambda; + + static_assert( UnaryLambdaTraits::isValid, "Supplied lambda must take exactly one argument" ); + explicit BoundLambda( L const &lambda ) : m_lambda( lambda ) {} + + auto setValue( std::string const &arg ) -> ParserResult override { + return invokeLambda::ArgType>( m_lambda, arg ); + } + }; + + template + struct BoundFlagLambda : BoundFlagRefBase { + L m_lambda; + + static_assert( UnaryLambdaTraits::isValid, "Supplied lambda must take exactly one argument" ); + static_assert( std::is_same::ArgType, bool>::value, "flags must be boolean" ); + + explicit BoundFlagLambda( L const &lambda ) : m_lambda( lambda ) {} + + auto setFlag( bool flag ) -> ParserResult override { + return LambdaInvoker::ReturnType>::invoke( m_lambda, flag ); + } + }; + + enum class Optionality { Optional, Required }; + + struct Parser; + + class ParserBase { + public: + virtual ~ParserBase() = default; + virtual auto validate() const -> Result { return Result::ok(); } + virtual auto parse( std::string const& exeName, TokenStream const &tokens) const -> InternalParseResult = 0; + virtual auto cardinality() const -> size_t { return 1; } + + auto parse( Args const &args ) const -> InternalParseResult { + return parse( args.exeName(), TokenStream( args ) ); + } + }; + + template + class ComposableParserImpl : public ParserBase { + public: + template + auto operator|( T const &other ) const -> Parser; + + template + auto operator+( T const &other ) const -> Parser; + }; + + // Common code and state for Args and Opts + template + class ParserRefImpl : public ComposableParserImpl { + protected: + Optionality m_optionality = Optionality::Optional; + std::shared_ptr m_ref; + std::string m_hint; + std::string m_description; + + explicit ParserRefImpl( std::shared_ptr const &ref ) : m_ref( ref ) {} + + public: + template + ParserRefImpl( T &ref, std::string const &hint ) + : m_ref( std::make_shared>( ref ) ), + m_hint( hint ) + {} + + template + ParserRefImpl( LambdaT const &ref, std::string const &hint ) + : m_ref( std::make_shared>( ref ) ), + m_hint(hint) + {} + + auto operator()( std::string const &description ) -> DerivedT & { + m_description = description; + return static_cast( *this ); + } + + auto optional() -> DerivedT & { + m_optionality = Optionality::Optional; + return static_cast( *this ); + }; + + auto required() -> DerivedT & { + m_optionality = Optionality::Required; + return static_cast( *this ); + }; + + auto isOptional() const -> bool { + return m_optionality == Optionality::Optional; + } + + auto cardinality() const -> size_t override { + if( m_ref->isContainer() ) + return 0; + else + return 1; + } + + auto hint() const -> std::string { return m_hint; } + }; + + class ExeName : public ComposableParserImpl { + std::shared_ptr m_name; + std::shared_ptr m_ref; + + template + static auto makeRef(LambdaT const &lambda) -> std::shared_ptr { + return std::make_shared>( lambda) ; + } + + public: + ExeName() : m_name( std::make_shared( "" ) ) {} + + explicit ExeName( std::string &ref ) : ExeName() { + m_ref = std::make_shared>( ref ); + } + + template + explicit ExeName( LambdaT const& lambda ) : ExeName() { + m_ref = std::make_shared>( lambda ); + } + + // The exe name is not parsed out of the normal tokens, but is handled specially + auto parse( std::string const&, TokenStream const &tokens ) const -> InternalParseResult override { + return InternalParseResult::ok( ParseState( ParseResultType::NoMatch, tokens ) ); + } + + auto name() const -> std::string { return *m_name; } + auto set( std::string const& newName ) -> ParserResult { + + auto lastSlash = newName.find_last_of( "\\/" ); + auto filename = ( lastSlash == std::string::npos ) + ? newName + : newName.substr( lastSlash+1 ); + + *m_name = filename; + if( m_ref ) + return m_ref->setValue( filename ); + else + return ParserResult::ok( ParseResultType::Matched ); + } + }; + + class Arg : public ParserRefImpl { + public: + using ParserRefImpl::ParserRefImpl; + + auto parse( std::string const &, TokenStream const &tokens ) const -> InternalParseResult override { + auto validationResult = validate(); + if( !validationResult ) + return InternalParseResult( validationResult ); + + auto remainingTokens = tokens; + auto const &token = *remainingTokens; + if( token.type != TokenType::Argument ) + return InternalParseResult::ok( ParseState( ParseResultType::NoMatch, remainingTokens ) ); + + assert( !m_ref->isFlag() ); + auto valueRef = static_cast( m_ref.get() ); + + auto result = valueRef->setValue( remainingTokens->token ); + if( !result ) + return InternalParseResult( result ); + else + return InternalParseResult::ok( ParseState( ParseResultType::Matched, ++remainingTokens ) ); + } + }; + + inline auto normaliseOpt( std::string const &optName ) -> std::string { +#ifdef CATCH_PLATFORM_WINDOWS + if( optName[0] == '/' ) + return "-" + optName.substr( 1 ); + else +#endif + return optName; + } + + class Opt : public ParserRefImpl { + protected: + std::vector m_optNames; + + public: + template + explicit Opt( LambdaT const &ref ) : ParserRefImpl( std::make_shared>( ref ) ) {} + + explicit Opt( bool &ref ) : ParserRefImpl( std::make_shared( ref ) ) {} + + template + Opt( LambdaT const &ref, std::string const &hint ) : ParserRefImpl( ref, hint ) {} + + template + Opt( T &ref, std::string const &hint ) : ParserRefImpl( ref, hint ) {} + + auto operator[]( std::string const &optName ) -> Opt & { + m_optNames.push_back( optName ); + return *this; + } + + auto getHelpColumns() const -> std::vector { + std::ostringstream oss; + bool first = true; + for( auto const &opt : m_optNames ) { + if (first) + first = false; + else + oss << ", "; + oss << opt; + } + if( !m_hint.empty() ) + oss << " <" << m_hint << ">"; + return { { oss.str(), m_description } }; + } + + auto isMatch( std::string const &optToken ) const -> bool { + auto normalisedToken = normaliseOpt( optToken ); + for( auto const &name : m_optNames ) { + if( normaliseOpt( name ) == normalisedToken ) + return true; + } + return false; + } + + using ParserBase::parse; + + auto parse( std::string const&, TokenStream const &tokens ) const -> InternalParseResult override { + auto validationResult = validate(); + if( !validationResult ) + return InternalParseResult( validationResult ); + + auto remainingTokens = tokens; + if( remainingTokens && remainingTokens->type == TokenType::Option ) { + auto const &token = *remainingTokens; + if( isMatch(token.token ) ) { + if( m_ref->isFlag() ) { + auto flagRef = static_cast( m_ref.get() ); + auto result = flagRef->setFlag( true ); + if( !result ) + return InternalParseResult( result ); + if( result.value() == ParseResultType::ShortCircuitAll ) + return InternalParseResult::ok( ParseState( result.value(), remainingTokens ) ); + } else { + auto valueRef = static_cast( m_ref.get() ); + ++remainingTokens; + if( !remainingTokens ) + return InternalParseResult::runtimeError( "Expected argument following " + token.token ); + auto const &argToken = *remainingTokens; + if( argToken.type != TokenType::Argument ) + return InternalParseResult::runtimeError( "Expected argument following " + token.token ); + auto result = valueRef->setValue( argToken.token ); + if( !result ) + return InternalParseResult( result ); + if( result.value() == ParseResultType::ShortCircuitAll ) + return InternalParseResult::ok( ParseState( result.value(), remainingTokens ) ); + } + return InternalParseResult::ok( ParseState( ParseResultType::Matched, ++remainingTokens ) ); + } + } + return InternalParseResult::ok( ParseState( ParseResultType::NoMatch, remainingTokens ) ); + } + + auto validate() const -> Result override { + if( m_optNames.empty() ) + return Result::logicError( "No options supplied to Opt" ); + for( auto const &name : m_optNames ) { + if( name.empty() ) + return Result::logicError( "Option name cannot be empty" ); +#ifdef CATCH_PLATFORM_WINDOWS + if( name[0] != '-' && name[0] != '/' ) + return Result::logicError( "Option name must begin with '-' or '/'" ); +#else + if( name[0] != '-' ) + return Result::logicError( "Option name must begin with '-'" ); +#endif + } + return ParserRefImpl::validate(); + } + }; + + struct Help : Opt { + Help( bool &showHelpFlag ) + : Opt([&]( bool flag ) { + showHelpFlag = flag; + return ParserResult::ok( ParseResultType::ShortCircuitAll ); + }) + { + static_cast( *this ) + ("display usage information") + ["-?"]["-h"]["--help"] + .optional(); + } + }; + + + struct Parser : ParserBase { + + mutable ExeName m_exeName; + std::vector m_options; + std::vector m_args; + + auto operator|=( ExeName const &exeName ) -> Parser & { + m_exeName = exeName; + return *this; + } + + auto operator|=( Arg const &arg ) -> Parser & { + m_args.push_back(arg); + return *this; + } + + auto operator|=( Opt const &opt ) -> Parser & { + m_options.push_back(opt); + return *this; + } + + auto operator|=( Parser const &other ) -> Parser & { + m_options.insert(m_options.end(), other.m_options.begin(), other.m_options.end()); + m_args.insert(m_args.end(), other.m_args.begin(), other.m_args.end()); + return *this; + } + + template + auto operator|( T const &other ) const -> Parser { + return Parser( *this ) |= other; + } + + // Forward deprecated interface with '+' instead of '|' + template + auto operator+=( T const &other ) -> Parser & { return operator|=( other ); } + template + auto operator+( T const &other ) const -> Parser { return operator|( other ); } + + auto getHelpColumns() const -> std::vector { + std::vector cols; + for (auto const &o : m_options) { + auto childCols = o.getHelpColumns(); + cols.insert( cols.end(), childCols.begin(), childCols.end() ); + } + return cols; + } + + void writeToStream( std::ostream &os ) const { + if (!m_exeName.name().empty()) { + os << "usage:\n" << " " << m_exeName.name() << " "; + bool required = true, first = true; + for( auto const &arg : m_args ) { + if (first) + first = false; + else + os << " "; + if( arg.isOptional() && required ) { + os << "["; + required = false; + } + os << "<" << arg.hint() << ">"; + if( arg.cardinality() == 0 ) + os << " ... "; + } + if( !required ) + os << "]"; + if( !m_options.empty() ) + os << " options"; + os << "\n\nwhere options are:" << std::endl; + } + + auto rows = getHelpColumns(); + size_t consoleWidth = CATCH_CLARA_CONFIG_CONSOLE_WIDTH; + size_t optWidth = 0; + for( auto const &cols : rows ) + optWidth = (std::max)(optWidth, cols.left.size() + 2); + + optWidth = (std::min)(optWidth, consoleWidth/2); + + for( auto const &cols : rows ) { + auto row = + TextFlow::Column( cols.left ).width( optWidth ).indent( 2 ) + + TextFlow::Spacer(4) + + TextFlow::Column( cols.right ).width( consoleWidth - 7 - optWidth ); + os << row << std::endl; + } + } + + friend auto operator<<( std::ostream &os, Parser const &parser ) -> std::ostream& { + parser.writeToStream( os ); + return os; + } + + auto validate() const -> Result override { + for( auto const &opt : m_options ) { + auto result = opt.validate(); + if( !result ) + return result; + } + for( auto const &arg : m_args ) { + auto result = arg.validate(); + if( !result ) + return result; + } + return Result::ok(); + } + + using ParserBase::parse; + + auto parse( std::string const& exeName, TokenStream const &tokens ) const -> InternalParseResult override { + + struct ParserInfo { + ParserBase const* parser = nullptr; + size_t count = 0; + }; + const size_t totalParsers = m_options.size() + m_args.size(); + assert( totalParsers < 512 ); + // ParserInfo parseInfos[totalParsers]; // <-- this is what we really want to do + ParserInfo parseInfos[512]; + + { + size_t i = 0; + for (auto const &opt : m_options) parseInfos[i++].parser = &opt; + for (auto const &arg : m_args) parseInfos[i++].parser = &arg; + } + + m_exeName.set( exeName ); + + auto result = InternalParseResult::ok( ParseState( ParseResultType::NoMatch, tokens ) ); + while( result.value().remainingTokens() ) { + bool tokenParsed = false; + + for( size_t i = 0; i < totalParsers; ++i ) { + auto& parseInfo = parseInfos[i]; + if( parseInfo.parser->cardinality() == 0 || parseInfo.count < parseInfo.parser->cardinality() ) { + result = parseInfo.parser->parse(exeName, result.value().remainingTokens()); + if (!result) + return result; + if (result.value().type() != ParseResultType::NoMatch) { + tokenParsed = true; + ++parseInfo.count; + break; + } + } + } + + if( result.value().type() == ParseResultType::ShortCircuitAll ) + return result; + if( !tokenParsed ) + return InternalParseResult::runtimeError( "Unrecognised token: " + result.value().remainingTokens()->token ); + } + // !TBD Check missing required options + return result; + } + }; + + template + template + auto ComposableParserImpl::operator|( T const &other ) const -> Parser { + return Parser() | static_cast( *this ) | other; + } +} // namespace detail + + +// A Combined parser +using detail::Parser; + +// A parser for options +using detail::Opt; + +// A parser for arguments +using detail::Arg; + +// Wrapper for argc, argv from main() +using detail::Args; + +// Specifies the name of the executable +using detail::ExeName; + +// Convenience wrapper for option parser that specifies the help option +using detail::Help; + +// enum of result types from a parse +using detail::ParseResultType; + +// Result type for parser operation +using detail::ParserResult; + + +}} // namespace Catch::clara + + +#endif // CATCH_CLARA_HPP_INCLUDED diff --git a/src/third_party/cppcodec/test/catch/include/internal/catch_approx.cpp b/src/third_party/cppcodec/test/catch/include/internal/catch_approx.cpp new file mode 100644 index 0000000000..efe245cbd8 --- /dev/null +++ b/src/third_party/cppcodec/test/catch/include/internal/catch_approx.cpp @@ -0,0 +1,72 @@ +/* + * Created by Martin on 19/07/2017. + * Copyright 2017 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) + */ + +#include "catch_approx.h" + +#include +#include + +namespace { + +// Performs equivalent check of std::fabs(lhs - rhs) <= margin +// But without the subtraction to allow for INFINITY in comparison +bool marginComparison(double lhs, double rhs, double margin) { + return (lhs + margin >= rhs) && (rhs + margin >= lhs); +} + +} + +namespace Catch { +namespace Detail { + + Approx::Approx ( double value ) + : m_epsilon( std::numeric_limits::epsilon()*100 ), + m_margin( 0.0 ), + m_scale( 0.0 ), + m_value( value ) + {} + + Approx Approx::custom() { + return Approx( 0 ); + } + + Approx Approx::operator-() const { + auto temp(*this); + temp.m_value = -temp.m_value; + return temp; + } + + + std::string Approx::toString() const { + ReusableStringStream rss; + rss << "Approx( " << ::Catch::Detail::stringify( m_value ) << " )"; + return rss.str(); + } + + bool Approx::equalityComparisonImpl(const double other) const { + // First try with fixed margin, then compute margin based on epsilon, scale and Approx's value + // Thanks to Richard Harris for his help refining the scaled margin value + return marginComparison(m_value, other, m_margin) || marginComparison(m_value, other, m_epsilon * (m_scale + std::fabs(m_value))); + } + +} // end namespace Detail + +namespace literals { + Detail::Approx operator "" _a(long double val) { + return Detail::Approx(val); + } + Detail::Approx operator "" _a(unsigned long long val) { + return Detail::Approx(val); + } +} // end namespace literals + +std::string StringMaker::convert(Catch::Detail::Approx const& value) { + return value.toString(); +} + +} // end namespace Catch diff --git a/src/third_party/cppcodec/test/catch/include/internal/catch_approx.h b/src/third_party/cppcodec/test/catch/include/internal/catch_approx.h new file mode 100644 index 0000000000..287e83078b --- /dev/null +++ b/src/third_party/cppcodec/test/catch/include/internal/catch_approx.h @@ -0,0 +1,140 @@ +/* + * Created by Phil on 28/04/2011. + * Copyright 2010 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_CATCH_APPROX_HPP_INCLUDED +#define TWOBLUECUBES_CATCH_APPROX_HPP_INCLUDED + +#include "catch_tostring.h" + +#include +#include + +namespace Catch { +namespace Detail { + + class Approx { + private: + bool equalityComparisonImpl(double other) const; + + public: + explicit Approx ( double value ); + + static Approx custom(); + + Approx operator-() const; + + template ::value>::type> + Approx operator()( T const& value ) { + Approx approx( static_cast(value) ); + approx.epsilon( m_epsilon ); + approx.margin( m_margin ); + approx.scale( m_scale ); + return approx; + } + + template ::value>::type> + explicit Approx( T const& value ): Approx(static_cast(value)) + {} + + + template ::value>::type> + friend bool operator == ( const T& lhs, Approx const& rhs ) { + auto lhs_v = static_cast(lhs); + return rhs.equalityComparisonImpl(lhs_v); + } + + template ::value>::type> + friend bool operator == ( Approx const& lhs, const T& rhs ) { + return operator==( rhs, lhs ); + } + + template ::value>::type> + friend bool operator != ( T const& lhs, Approx const& rhs ) { + return !operator==( lhs, rhs ); + } + + template ::value>::type> + friend bool operator != ( Approx const& lhs, T const& rhs ) { + return !operator==( rhs, lhs ); + } + + template ::value>::type> + friend bool operator <= ( T const& lhs, Approx const& rhs ) { + return static_cast(lhs) < rhs.m_value || lhs == rhs; + } + + template ::value>::type> + friend bool operator <= ( Approx const& lhs, T const& rhs ) { + return lhs.m_value < static_cast(rhs) || lhs == rhs; + } + + template ::value>::type> + friend bool operator >= ( T const& lhs, Approx const& rhs ) { + return static_cast(lhs) > rhs.m_value || lhs == rhs; + } + + template ::value>::type> + friend bool operator >= ( Approx const& lhs, T const& rhs ) { + return lhs.m_value > static_cast(rhs) || lhs == rhs; + } + + template ::value>::type> + Approx& epsilon( T const& newEpsilon ) { + double epsilonAsDouble = static_cast(newEpsilon); + if( epsilonAsDouble < 0 || epsilonAsDouble > 1.0 ) { + throw std::domain_error + ( "Invalid Approx::epsilon: " + + Catch::Detail::stringify( epsilonAsDouble ) + + ", Approx::epsilon has to be between 0 and 1" ); + } + m_epsilon = epsilonAsDouble; + return *this; + } + + template ::value>::type> + Approx& margin( T const& newMargin ) { + double marginAsDouble = static_cast(newMargin); + if( marginAsDouble < 0 ) { + throw std::domain_error + ( "Invalid Approx::margin: " + + Catch::Detail::stringify( marginAsDouble ) + + ", Approx::Margin has to be non-negative." ); + + } + m_margin = marginAsDouble; + return *this; + } + + template ::value>::type> + Approx& scale( T const& newScale ) { + m_scale = static_cast(newScale); + return *this; + } + + std::string toString() const; + + private: + double m_epsilon; + double m_margin; + double m_scale; + double m_value; + }; +} // end namespace Detail + +namespace literals { + Detail::Approx operator "" _a(long double val); + Detail::Approx operator "" _a(unsigned long long val); +} // end namespace literals + +template<> +struct StringMaker { + static std::string convert(Catch::Detail::Approx const& value); +}; + +} // end namespace Catch + +#endif // TWOBLUECUBES_CATCH_APPROX_HPP_INCLUDED diff --git a/src/third_party/cppcodec/test/catch/include/internal/catch_assertionhandler.cpp b/src/third_party/cppcodec/test/catch/include/internal/catch_assertionhandler.cpp new file mode 100644 index 0000000000..28768077ab --- /dev/null +++ b/src/third_party/cppcodec/test/catch/include/internal/catch_assertionhandler.cpp @@ -0,0 +1,116 @@ +/* + * Created by Phil on 8/8/2017. + * Copyright 2017 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) + */ + +#include "catch_assertionhandler.h" +#include "catch_assertionresult.h" +#include "catch_interfaces_runner.h" +#include "catch_interfaces_config.h" +#include "catch_context.h" +#include "catch_debugger.h" +#include "catch_interfaces_registry_hub.h" +#include "catch_capture_matchers.h" +#include "catch_run_context.h" + +namespace Catch { + + namespace { + auto operator <<( std::ostream& os, ITransientExpression const& expr ) -> std::ostream& { + expr.streamReconstructedExpression( os ); + return os; + } + } + + LazyExpression::LazyExpression( bool isNegated ) + : m_isNegated( isNegated ) + {} + + LazyExpression::LazyExpression( LazyExpression const& other ) : m_isNegated( other.m_isNegated ) {} + + LazyExpression::operator bool() const { + return m_transientExpression != nullptr; + } + + auto operator << ( std::ostream& os, LazyExpression const& lazyExpr ) -> std::ostream& { + if( lazyExpr.m_isNegated ) + os << "!"; + + if( lazyExpr ) { + if( lazyExpr.m_isNegated && lazyExpr.m_transientExpression->isBinaryExpression() ) + os << "(" << *lazyExpr.m_transientExpression << ")"; + else + os << *lazyExpr.m_transientExpression; + } + else { + os << "{** error - unchecked empty expression requested **}"; + } + return os; + } + + AssertionHandler::AssertionHandler + ( StringRef macroName, + SourceLineInfo const& lineInfo, + StringRef capturedExpression, + ResultDisposition::Flags resultDisposition ) + : m_assertionInfo{ macroName, lineInfo, capturedExpression, resultDisposition }, + m_resultCapture( getResultCapture() ) + {} + + void AssertionHandler::handleExpr( ITransientExpression const& expr ) { + m_resultCapture.handleExpr( m_assertionInfo, expr, m_reaction ); + } + void AssertionHandler::handleMessage(ResultWas::OfType resultType, StringRef const& message) { + m_resultCapture.handleMessage( m_assertionInfo, resultType, message, m_reaction ); + } + + auto AssertionHandler::allowThrows() const -> bool { + return getCurrentContext().getConfig()->allowThrows(); + } + + void AssertionHandler::complete() { + setCompleted(); + if( m_reaction.shouldDebugBreak ) { + + // If you find your debugger stopping you here then go one level up on the + // call-stack for the code that caused it (typically a failed assertion) + + // (To go back to the test and change execution, jump over the throw, next) + CATCH_BREAK_INTO_DEBUGGER(); + } + if( m_reaction.shouldThrow ) + throw Catch::TestFailureException(); + } + void AssertionHandler::setCompleted() { + m_completed = true; + } + + void AssertionHandler::handleUnexpectedInflightException() { + m_resultCapture.handleUnexpectedInflightException( m_assertionInfo, Catch::translateActiveException(), m_reaction ); + } + + void AssertionHandler::handleExceptionThrownAsExpected() { + m_resultCapture.handleNonExpr(m_assertionInfo, ResultWas::Ok, m_reaction); + } + void AssertionHandler::handleExceptionNotThrownAsExpected() { + m_resultCapture.handleNonExpr(m_assertionInfo, ResultWas::Ok, m_reaction); + } + + void AssertionHandler::handleUnexpectedExceptionNotThrown() { + m_resultCapture.handleUnexpectedExceptionNotThrown( m_assertionInfo, m_reaction ); + } + + void AssertionHandler::handleThrowingCallSkipped() { + m_resultCapture.handleNonExpr(m_assertionInfo, ResultWas::Ok, m_reaction); + } + + // This is the overload that takes a string and infers the Equals matcher from it + // The more general overload, that takes any string matcher, is in catch_capture_matchers.cpp + void handleExceptionMatchExpr( AssertionHandler& handler, std::string const& str, StringRef matcherString ) { + handleExceptionMatchExpr( handler, Matchers::Equals( str ), matcherString ); + } + +} // namespace Catch diff --git a/src/third_party/cppcodec/test/catch/include/internal/catch_assertionhandler.h b/src/third_party/cppcodec/test/catch/include/internal/catch_assertionhandler.h new file mode 100644 index 0000000000..cadc78f34d --- /dev/null +++ b/src/third_party/cppcodec/test/catch/include/internal/catch_assertionhandler.h @@ -0,0 +1,88 @@ +/* + * Created by Phil on 8/8/2017. + * Copyright 2017 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_CATCH_ASSERTIONHANDLER_H_INCLUDED +#define TWOBLUECUBES_CATCH_ASSERTIONHANDLER_H_INCLUDED + +#include "catch_assertioninfo.h" +#include "catch_decomposer.h" +#include "catch_interfaces_capture.h" + +namespace Catch { + + struct TestFailureException{}; + struct AssertionResultData; + struct IResultCapture; + class RunContext; + + class LazyExpression { + friend class AssertionHandler; + friend struct AssertionStats; + friend class RunContext; + + ITransientExpression const* m_transientExpression = nullptr; + bool m_isNegated; + public: + LazyExpression( bool isNegated ); + LazyExpression( LazyExpression const& other ); + LazyExpression& operator = ( LazyExpression const& ) = delete; + + explicit operator bool() const; + + friend auto operator << ( std::ostream& os, LazyExpression const& lazyExpr ) -> std::ostream&; + }; + + struct AssertionReaction { + bool shouldDebugBreak = false; + bool shouldThrow = false; + }; + + class AssertionHandler { + AssertionInfo m_assertionInfo; + AssertionReaction m_reaction; + bool m_completed = false; + IResultCapture& m_resultCapture; + + public: + AssertionHandler + ( StringRef macroName, + SourceLineInfo const& lineInfo, + StringRef capturedExpression, + ResultDisposition::Flags resultDisposition ); + ~AssertionHandler() { + if ( !m_completed ) { + m_resultCapture.handleIncomplete( m_assertionInfo ); + } + } + + + template + void handleExpr( ExprLhs const& expr ) { + handleExpr( expr.makeUnaryExpr() ); + } + void handleExpr( ITransientExpression const& expr ); + + void handleMessage(ResultWas::OfType resultType, StringRef const& message); + + void handleExceptionThrownAsExpected(); + void handleUnexpectedExceptionNotThrown(); + void handleExceptionNotThrownAsExpected(); + void handleThrowingCallSkipped(); + void handleUnexpectedInflightException(); + + void complete(); + void setCompleted(); + + // query + auto allowThrows() const -> bool; + }; + + void handleExceptionMatchExpr( AssertionHandler& handler, std::string const& str, StringRef matcherString ); + +} // namespace Catch + +#endif // TWOBLUECUBES_CATCH_ASSERTIONHANDLER_H_INCLUDED diff --git a/src/third_party/cppcodec/test/catch/include/internal/catch_assertioninfo.h b/src/third_party/cppcodec/test/catch/include/internal/catch_assertioninfo.h new file mode 100644 index 0000000000..5f136bf738 --- /dev/null +++ b/src/third_party/cppcodec/test/catch/include/internal/catch_assertioninfo.h @@ -0,0 +1,31 @@ +/* + * Created by Phil on 8/8/2017. + * Copyright 2017 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_CATCH_ASSERTIONINFO_H_INCLUDED +#define TWOBLUECUBES_CATCH_ASSERTIONINFO_H_INCLUDED + +#include "catch_result_type.h" +#include "catch_common.h" +#include "catch_stringref.h" + +namespace Catch { + + struct AssertionInfo + { + StringRef macroName; + SourceLineInfo lineInfo; + StringRef capturedExpression; + ResultDisposition::Flags resultDisposition; + + // We want to delete this constructor but a compiler bug in 4.8 means + // the struct is then treated as non-aggregate + //AssertionInfo() = delete; + }; + +} // end namespace Catch + +#endif // TWOBLUECUBES_CATCH_ASSERTIONINFO_H_INCLUDED diff --git a/src/third_party/cppcodec/test/catch/include/internal/catch_assertionresult.cpp b/src/third_party/cppcodec/test/catch/include/internal/catch_assertionresult.cpp new file mode 100644 index 0000000000..4ce071876b --- /dev/null +++ b/src/third_party/cppcodec/test/catch/include/internal/catch_assertionresult.cpp @@ -0,0 +1,98 @@ +/* + * Created by Phil on 8/8/12 + * Copyright 2012 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) + */ + +#include "catch_assertionresult.h" + +namespace Catch { + AssertionResultData::AssertionResultData(ResultWas::OfType _resultType, LazyExpression const & _lazyExpression): + lazyExpression(_lazyExpression), + resultType(_resultType) {} + + std::string AssertionResultData::reconstructExpression() const { + + if( reconstructedExpression.empty() ) { + if( lazyExpression ) { + ReusableStringStream rss; + rss << lazyExpression; + reconstructedExpression = rss.str(); + } + } + return reconstructedExpression; + } + + AssertionResult::AssertionResult( AssertionInfo const& info, AssertionResultData const& data ) + : m_info( info ), + m_resultData( data ) + {} + + // Result was a success + bool AssertionResult::succeeded() const { + return Catch::isOk( m_resultData.resultType ); + } + + // Result was a success, or failure is suppressed + bool AssertionResult::isOk() const { + return Catch::isOk( m_resultData.resultType ) || shouldSuppressFailure( m_info.resultDisposition ); + } + + ResultWas::OfType AssertionResult::getResultType() const { + return m_resultData.resultType; + } + + bool AssertionResult::hasExpression() const { + return m_info.capturedExpression[0] != 0; + } + + bool AssertionResult::hasMessage() const { + return !m_resultData.message.empty(); + } + + std::string AssertionResult::getExpression() const { + if( isFalseTest( m_info.resultDisposition ) ) + return "!(" + m_info.capturedExpression + ")"; + else + return m_info.capturedExpression; + } + + std::string AssertionResult::getExpressionInMacro() const { + std::string expr; + if( m_info.macroName[0] == 0 ) + expr = m_info.capturedExpression; + else { + expr.reserve( m_info.macroName.size() + m_info.capturedExpression.size() + 4 ); + expr += m_info.macroName; + expr += "( "; + expr += m_info.capturedExpression; + expr += " )"; + } + return expr; + } + + bool AssertionResult::hasExpandedExpression() const { + return hasExpression() && getExpandedExpression() != getExpression(); + } + + std::string AssertionResult::getExpandedExpression() const { + std::string expr = m_resultData.reconstructExpression(); + return expr.empty() + ? getExpression() + : expr; + } + + std::string AssertionResult::getMessage() const { + return m_resultData.message; + } + SourceLineInfo AssertionResult::getSourceInfo() const { + return m_info.lineInfo; + } + + StringRef AssertionResult::getTestMacroName() const { + return m_info.macroName; + } + +} // end namespace Catch diff --git a/src/third_party/cppcodec/test/catch/include/internal/catch_assertionresult.h b/src/third_party/cppcodec/test/catch/include/internal/catch_assertionresult.h new file mode 100644 index 0000000000..3c91ea58da --- /dev/null +++ b/src/third_party/cppcodec/test/catch/include/internal/catch_assertionresult.h @@ -0,0 +1,59 @@ +/* + * Created by Phil on 28/10/2010. + * Copyright 2010 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_CATCH_ASSERTIONRESULT_H_INCLUDED +#define TWOBLUECUBES_CATCH_ASSERTIONRESULT_H_INCLUDED + +#include +#include "catch_assertioninfo.h" +#include "catch_result_type.h" +#include "catch_common.h" +#include "catch_stringref.h" +#include "catch_assertionhandler.h" + +namespace Catch { + + struct AssertionResultData + { + AssertionResultData() = delete; + + AssertionResultData( ResultWas::OfType _resultType, LazyExpression const& _lazyExpression ); + + std::string message; + mutable std::string reconstructedExpression; + LazyExpression lazyExpression; + ResultWas::OfType resultType; + + std::string reconstructExpression() const; + }; + + class AssertionResult { + public: + AssertionResult() = delete; + AssertionResult( AssertionInfo const& info, AssertionResultData const& data ); + + bool isOk() const; + bool succeeded() const; + ResultWas::OfType getResultType() const; + bool hasExpression() const; + bool hasMessage() const; + std::string getExpression() const; + std::string getExpressionInMacro() const; + bool hasExpandedExpression() const; + std::string getExpandedExpression() const; + std::string getMessage() const; + SourceLineInfo getSourceInfo() const; + StringRef getTestMacroName() const; + + //protected: + AssertionInfo m_info; + AssertionResultData m_resultData; + }; + +} // end namespace Catch + +#endif // TWOBLUECUBES_CATCH_ASSERTIONRESULT_H_INCLUDED diff --git a/src/third_party/cppcodec/test/catch/include/internal/catch_benchmark.cpp b/src/third_party/cppcodec/test/catch/include/internal/catch_benchmark.cpp new file mode 100644 index 0000000000..742418f7fb --- /dev/null +++ b/src/third_party/cppcodec/test/catch/include/internal/catch_benchmark.cpp @@ -0,0 +1,36 @@ +/* + * Created by Phil on 04/07/2017. + * Copyright 2017 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) + */ + +#include "catch_benchmark.h" +#include "catch_capture.hpp" +#include "catch_interfaces_reporter.h" +#include "catch_context.h" + +namespace Catch { + + auto BenchmarkLooper::getResolution() -> uint64_t { + return getEstimatedClockResolution() * getCurrentContext().getConfig()->benchmarkResolutionMultiple(); + } + + void BenchmarkLooper::reportStart() { + getResultCapture().benchmarkStarting( { m_name } ); + } + auto BenchmarkLooper::needsMoreIterations() -> bool { + auto elapsed = m_timer.getElapsedNanoseconds(); + + // Exponentially increasing iterations until we're confident in our timer resolution + if( elapsed < m_resolution ) { + m_iterationsToRun *= 10; + return true; + } + + getResultCapture().benchmarkEnded( { { m_name }, m_count, elapsed } ); + return false; + } + +} // end namespace Catch diff --git a/src/third_party/cppcodec/test/catch/include/internal/catch_benchmark.h b/src/third_party/cppcodec/test/catch/include/internal/catch_benchmark.h new file mode 100644 index 0000000000..e546713cf9 --- /dev/null +++ b/src/third_party/cppcodec/test/catch/include/internal/catch_benchmark.h @@ -0,0 +1,57 @@ +/* + * Created by Phil on 04/07/2017. + * Copyright 2017 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_CATCH_BENCHMARK_H_INCLUDED +#define TWOBLUECUBES_CATCH_BENCHMARK_H_INCLUDED + +#include "catch_stringref.h" +#include "catch_timer.h" + +#include +#include + +namespace Catch { + + class BenchmarkLooper { + + std::string m_name; + std::size_t m_count = 0; + std::size_t m_iterationsToRun = 1; + uint64_t m_resolution; + Timer m_timer; + + static auto getResolution() -> uint64_t; + public: + // Keep most of this inline as it's on the code path that is being timed + BenchmarkLooper( StringRef name ) + : m_name( name ), + m_resolution( getResolution() ) + { + reportStart(); + m_timer.start(); + } + + explicit operator bool() { + if( m_count < m_iterationsToRun ) + return true; + return needsMoreIterations(); + } + + void increment() { + ++m_count; + } + + void reportStart(); + auto needsMoreIterations() -> bool; + }; + +} // end namespace Catch + +#define BENCHMARK( name ) \ + for( Catch::BenchmarkLooper looper( name ); looper; looper.increment() ) + +#endif // TWOBLUECUBES_CATCH_BENCHMARK_H_INCLUDED diff --git a/src/third_party/cppcodec/test/catch/include/internal/catch_capture.hpp b/src/third_party/cppcodec/test/catch/include/internal/catch_capture.hpp new file mode 100644 index 0000000000..6b25f9cd30 --- /dev/null +++ b/src/third_party/cppcodec/test/catch/include/internal/catch_capture.hpp @@ -0,0 +1,147 @@ +/* + * Created by Phil on 18/10/2010. + * Copyright 2010 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_CATCH_CAPTURE_HPP_INCLUDED +#define TWOBLUECUBES_CATCH_CAPTURE_HPP_INCLUDED + +#include "catch_assertionhandler.h" +#include "catch_message.h" +#include "catch_interfaces_capture.h" + +#if !defined(CATCH_CONFIG_DISABLE) + +#if !defined(CATCH_CONFIG_DISABLE_STRINGIFICATION) + #define CATCH_INTERNAL_STRINGIFY(...) #__VA_ARGS__ +#else + #define CATCH_INTERNAL_STRINGIFY(...) "Disabled by CATCH_CONFIG_DISABLE_STRINGIFICATION" +#endif + +#if defined(CATCH_CONFIG_FAST_COMPILE) + +/////////////////////////////////////////////////////////////////////////////// +// Another way to speed-up compilation is to omit local try-catch for REQUIRE* +// macros. +#define INTERNAL_CATCH_TRY +#define INTERNAL_CATCH_CATCH( capturer ) + +#else // CATCH_CONFIG_FAST_COMPILE + +#define INTERNAL_CATCH_TRY try +#define INTERNAL_CATCH_CATCH( handler ) catch(...) { handler.handleUnexpectedInflightException(); } + +#endif + +#define INTERNAL_CATCH_REACT( handler ) handler.complete(); + +/////////////////////////////////////////////////////////////////////////////// +#define INTERNAL_CATCH_TEST( macroName, resultDisposition, ... ) \ + do { \ + Catch::AssertionHandler catchAssertionHandler( macroName, CATCH_INTERNAL_LINEINFO, CATCH_INTERNAL_STRINGIFY(__VA_ARGS__), resultDisposition ); \ + INTERNAL_CATCH_TRY { \ + CATCH_INTERNAL_SUPPRESS_PARENTHESES_WARNINGS \ + catchAssertionHandler.handleExpr( Catch::Decomposer() <= __VA_ARGS__ ); \ + CATCH_INTERNAL_UNSUPPRESS_PARENTHESES_WARNINGS \ + } INTERNAL_CATCH_CATCH( catchAssertionHandler ) \ + INTERNAL_CATCH_REACT( catchAssertionHandler ) \ + } while( (void)0, false && static_cast( !!(__VA_ARGS__) ) ) // the expression here is never evaluated at runtime but it forces the compiler to give it a look + // The double negation silences MSVC's C4800 warning, the static_cast forces short-circuit evaluation if the type has overloaded &&. + +/////////////////////////////////////////////////////////////////////////////// +#define INTERNAL_CATCH_IF( macroName, resultDisposition, ... ) \ + INTERNAL_CATCH_TEST( macroName, resultDisposition, __VA_ARGS__ ); \ + if( Catch::getResultCapture().lastAssertionPassed() ) + +/////////////////////////////////////////////////////////////////////////////// +#define INTERNAL_CATCH_ELSE( macroName, resultDisposition, ... ) \ + INTERNAL_CATCH_TEST( macroName, resultDisposition, __VA_ARGS__ ); \ + if( !Catch::getResultCapture().lastAssertionPassed() ) + +/////////////////////////////////////////////////////////////////////////////// +#define INTERNAL_CATCH_NO_THROW( macroName, resultDisposition, ... ) \ + do { \ + Catch::AssertionHandler catchAssertionHandler( macroName, CATCH_INTERNAL_LINEINFO, CATCH_INTERNAL_STRINGIFY(__VA_ARGS__), resultDisposition ); \ + try { \ + static_cast(__VA_ARGS__); \ + catchAssertionHandler.handleExceptionNotThrownAsExpected(); \ + } \ + catch( ... ) { \ + catchAssertionHandler.handleUnexpectedInflightException(); \ + } \ + INTERNAL_CATCH_REACT( catchAssertionHandler ) \ + } while( false ) + +/////////////////////////////////////////////////////////////////////////////// +#define INTERNAL_CATCH_THROWS( macroName, resultDisposition, ... ) \ + do { \ + Catch::AssertionHandler catchAssertionHandler( macroName, CATCH_INTERNAL_LINEINFO, CATCH_INTERNAL_STRINGIFY(__VA_ARGS__), resultDisposition); \ + if( catchAssertionHandler.allowThrows() ) \ + try { \ + static_cast(__VA_ARGS__); \ + catchAssertionHandler.handleUnexpectedExceptionNotThrown(); \ + } \ + catch( ... ) { \ + catchAssertionHandler.handleExceptionThrownAsExpected(); \ + } \ + else \ + catchAssertionHandler.handleThrowingCallSkipped(); \ + INTERNAL_CATCH_REACT( catchAssertionHandler ) \ + } while( false ) + +/////////////////////////////////////////////////////////////////////////////// +#define INTERNAL_CATCH_THROWS_AS( macroName, exceptionType, resultDisposition, expr ) \ + do { \ + Catch::AssertionHandler catchAssertionHandler( macroName, CATCH_INTERNAL_LINEINFO, CATCH_INTERNAL_STRINGIFY(expr) ", " CATCH_INTERNAL_STRINGIFY(exceptionType), resultDisposition ); \ + if( catchAssertionHandler.allowThrows() ) \ + try { \ + static_cast(expr); \ + catchAssertionHandler.handleUnexpectedExceptionNotThrown(); \ + } \ + catch( exceptionType const& ) { \ + catchAssertionHandler.handleExceptionThrownAsExpected(); \ + } \ + catch( ... ) { \ + catchAssertionHandler.handleUnexpectedInflightException(); \ + } \ + else \ + catchAssertionHandler.handleThrowingCallSkipped(); \ + INTERNAL_CATCH_REACT( catchAssertionHandler ) \ + } while( false ) + + +/////////////////////////////////////////////////////////////////////////////// +#define INTERNAL_CATCH_MSG( macroName, messageType, resultDisposition, ... ) \ + do { \ + Catch::AssertionHandler catchAssertionHandler( macroName, CATCH_INTERNAL_LINEINFO, Catch::StringRef(), resultDisposition ); \ + catchAssertionHandler.handleMessage( messageType, ( Catch::MessageStream() << __VA_ARGS__ + ::Catch::StreamEndStop() ).m_stream.str() ); \ + INTERNAL_CATCH_REACT( catchAssertionHandler ) \ + } while( false ) + +/////////////////////////////////////////////////////////////////////////////// +#define INTERNAL_CATCH_INFO( macroName, log ) \ + Catch::ScopedMessage INTERNAL_CATCH_UNIQUE_NAME( scopedMessage )( Catch::MessageBuilder( macroName, CATCH_INTERNAL_LINEINFO, Catch::ResultWas::Info ) << log ); + +/////////////////////////////////////////////////////////////////////////////// +// Although this is matcher-based, it can be used with just a string +#define INTERNAL_CATCH_THROWS_STR_MATCHES( macroName, resultDisposition, matcher, ... ) \ + do { \ + Catch::AssertionHandler catchAssertionHandler( macroName, CATCH_INTERNAL_LINEINFO, CATCH_INTERNAL_STRINGIFY(__VA_ARGS__) ", " CATCH_INTERNAL_STRINGIFY(matcher), resultDisposition ); \ + if( catchAssertionHandler.allowThrows() ) \ + try { \ + static_cast(__VA_ARGS__); \ + catchAssertionHandler.handleUnexpectedExceptionNotThrown(); \ + } \ + catch( ... ) { \ + Catch::handleExceptionMatchExpr( catchAssertionHandler, matcher, #matcher ); \ + } \ + else \ + catchAssertionHandler.handleThrowingCallSkipped(); \ + INTERNAL_CATCH_REACT( catchAssertionHandler ) \ + } while( false ) + +#endif // CATCH_CONFIG_DISABLE + +#endif // TWOBLUECUBES_CATCH_CAPTURE_HPP_INCLUDED diff --git a/src/third_party/cppcodec/test/catch/include/internal/catch_capture_matchers.cpp b/src/third_party/cppcodec/test/catch/include/internal/catch_capture_matchers.cpp new file mode 100644 index 0000000000..a67cc797a7 --- /dev/null +++ b/src/third_party/cppcodec/test/catch/include/internal/catch_capture_matchers.cpp @@ -0,0 +1,24 @@ +/* + * Created by Phil on 9/8/2017. + * Copyright 2017 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) + */ +#include "catch_capture_matchers.h" +#include "catch_interfaces_registry_hub.h" + +namespace Catch { + + using StringMatcher = Matchers::Impl::MatcherBase; + + // This is the general overload that takes a any string matcher + // There is another overload, in catch_assertionhandler.h/.cpp, that only takes a string and infers + // the Equals matcher (so the header does not mention matchers) + void handleExceptionMatchExpr( AssertionHandler& handler, StringMatcher const& matcher, StringRef matcherString ) { + std::string exceptionMessage = Catch::translateActiveException(); + MatchExpr expr( exceptionMessage, matcher, matcherString ); + handler.handleExpr( expr ); + } + +} // namespace Catch diff --git a/src/third_party/cppcodec/test/catch/include/internal/catch_capture_matchers.h b/src/third_party/cppcodec/test/catch/include/internal/catch_capture_matchers.h new file mode 100644 index 0000000000..9026aebf67 --- /dev/null +++ b/src/third_party/cppcodec/test/catch/include/internal/catch_capture_matchers.h @@ -0,0 +1,86 @@ +/* + * Created by Phil on 9/8/2017 + * Copyright 2017 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_CATCH_CAPTURE_MATCHERS_HPP_INCLUDED +#define TWOBLUECUBES_CATCH_CAPTURE_MATCHERS_HPP_INCLUDED + +#include "catch_capture.hpp" +#include "catch_matchers.h" +#include "catch_matchers_floating.h" +#include "catch_matchers_generic.hpp" +#include "catch_matchers_string.h" +#include "catch_matchers_vector.h" + +namespace Catch { + + template + class MatchExpr : public ITransientExpression { + ArgT const& m_arg; + MatcherT m_matcher; + StringRef m_matcherString; + public: + MatchExpr( ArgT const& arg, MatcherT const& matcher, StringRef matcherString ) + : ITransientExpression{ true, matcher.match( arg ) }, + m_arg( arg ), + m_matcher( matcher ), + m_matcherString( matcherString ) + {} + + void streamReconstructedExpression( std::ostream &os ) const override { + auto matcherAsString = m_matcher.toString(); + os << Catch::Detail::stringify( m_arg ) << ' '; + if( matcherAsString == Detail::unprintableString ) + os << m_matcherString; + else + os << matcherAsString; + } + }; + + using StringMatcher = Matchers::Impl::MatcherBase; + + void handleExceptionMatchExpr( AssertionHandler& handler, StringMatcher const& matcher, StringRef matcherString ); + + template + auto makeMatchExpr( ArgT const& arg, MatcherT const& matcher, StringRef matcherString ) -> MatchExpr { + return MatchExpr( arg, matcher, matcherString ); + } + +} // namespace Catch + + +/////////////////////////////////////////////////////////////////////////////// +#define INTERNAL_CHECK_THAT( macroName, matcher, resultDisposition, arg ) \ + do { \ + Catch::AssertionHandler catchAssertionHandler( macroName, CATCH_INTERNAL_LINEINFO, CATCH_INTERNAL_STRINGIFY(arg) ", " CATCH_INTERNAL_STRINGIFY(matcher), resultDisposition ); \ + INTERNAL_CATCH_TRY { \ + catchAssertionHandler.handleExpr( Catch::makeMatchExpr( arg, matcher, #matcher ) ); \ + } INTERNAL_CATCH_CATCH( catchAssertionHandler ) \ + INTERNAL_CATCH_REACT( catchAssertionHandler ) \ + } while( false ) + + +/////////////////////////////////////////////////////////////////////////////// +#define INTERNAL_CATCH_THROWS_MATCHES( macroName, exceptionType, resultDisposition, matcher, ... ) \ + do { \ + Catch::AssertionHandler catchAssertionHandler( macroName, CATCH_INTERNAL_LINEINFO, CATCH_INTERNAL_STRINGIFY(__VA_ARGS__) ", " CATCH_INTERNAL_STRINGIFY(exceptionType) ", " CATCH_INTERNAL_STRINGIFY(matcher), resultDisposition ); \ + if( catchAssertionHandler.allowThrows() ) \ + try { \ + static_cast(__VA_ARGS__ ); \ + catchAssertionHandler.handleUnexpectedExceptionNotThrown(); \ + } \ + catch( exceptionType const& ex ) { \ + catchAssertionHandler.handleExpr( Catch::makeMatchExpr( ex, matcher, #matcher ) ); \ + } \ + catch( ... ) { \ + catchAssertionHandler.handleUnexpectedInflightException(); \ + } \ + else \ + catchAssertionHandler.handleThrowingCallSkipped(); \ + INTERNAL_CATCH_REACT( catchAssertionHandler ) \ + } while( false ) + +#endif // TWOBLUECUBES_CATCH_CAPTURE_MATCHERS_HPP_INCLUDED diff --git a/src/third_party/cppcodec/test/catch/include/internal/catch_clara.h b/src/third_party/cppcodec/test/catch/include/internal/catch_clara.h new file mode 100644 index 0000000000..bdf70250b9 --- /dev/null +++ b/src/third_party/cppcodec/test/catch/include/internal/catch_clara.h @@ -0,0 +1,38 @@ +/* + * Created by Phil on 10/2/2014. + * Copyright 2014 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_CATCH_CLARA_H_INCLUDED +#define TWOBLUECUBES_CATCH_CLARA_H_INCLUDED + +// Use Catch's value for console width (store Clara's off to the side, if present) +#ifdef CLARA_CONFIG_CONSOLE_WIDTH +#define CATCH_TEMP_CLARA_CONFIG_CONSOLE_WIDTH CATCH_CLARA_TEXTFLOW_CONFIG_CONSOLE_WIDTH +#undef CATCH_CLARA_TEXTFLOW_CONFIG_CONSOLE_WIDTH +#endif +#define CATCH_CLARA_TEXTFLOW_CONFIG_CONSOLE_WIDTH CATCH_CONFIG_CONSOLE_WIDTH-1 + +#ifdef __clang__ +#pragma clang diagnostic push +#pragma clang diagnostic ignored "-Wweak-vtables" +#pragma clang diagnostic ignored "-Wexit-time-destructors" +#pragma clang diagnostic ignored "-Wshadow" +#endif + +#include "../external/clara.hpp" + +#ifdef __clang__ +#pragma clang diagnostic pop +#endif + +// Restore Clara's value for console width, if present +#ifdef CATCH_TEMP_CLARA_CONFIG_CONSOLE_WIDTH +#define CATCH_CLARA_TEXTFLOW_CONFIG_CONSOLE_WIDTH CATCH_TEMP_CLARA_CONFIG_CONSOLE_WIDTH +#undef CATCH_TEMP_CLARA_CONFIG_CONSOLE_WIDTH +#endif + +#endif // TWOBLUECUBES_CATCH_CLARA_H_INCLUDED diff --git a/src/third_party/cppcodec/test/catch/include/internal/catch_commandline.cpp b/src/third_party/cppcodec/test/catch/include/internal/catch_commandline.cpp new file mode 100644 index 0000000000..c57b7ed74d --- /dev/null +++ b/src/third_party/cppcodec/test/catch/include/internal/catch_commandline.cpp @@ -0,0 +1,194 @@ +/* + * Created by Phil on 02/11/2010. + * Copyright 2010 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) + */ + +#include "catch_commandline.h" + +#include "catch_string_manip.h" + +#include +#include + +namespace Catch { + + clara::Parser makeCommandLineParser( ConfigData& config ) { + + using namespace clara; + + auto const setWarning = [&]( std::string const& warning ) { + auto warningSet = [&]() { + if( warning == "NoAssertions" ) + return WarnAbout::NoAssertions; + + if ( warning == "NoTests" ) + return WarnAbout::NoTests; + + return WarnAbout::Nothing; + }(); + + if (warningSet == WarnAbout::Nothing) + return ParserResult::runtimeError( "Unrecognised warning: '" + warning + "'" ); + config.warnings = static_cast( config.warnings | warningSet ); + return ParserResult::ok( ParseResultType::Matched ); + }; + auto const loadTestNamesFromFile = [&]( std::string const& filename ) { + std::ifstream f( filename.c_str() ); + if( !f.is_open() ) + return ParserResult::runtimeError( "Unable to load input file: '" + filename + "'" ); + + std::string line; + while( std::getline( f, line ) ) { + line = trim(line); + if( !line.empty() && !startsWith( line, '#' ) ) { + if( !startsWith( line, '"' ) ) + line = '"' + line + '"'; + config.testsOrTags.push_back( line + ',' ); + } + } + return ParserResult::ok( ParseResultType::Matched ); + }; + auto const setTestOrder = [&]( std::string const& order ) { + if( startsWith( "declared", order ) ) + config.runOrder = RunTests::InDeclarationOrder; + else if( startsWith( "lexical", order ) ) + config.runOrder = RunTests::InLexicographicalOrder; + else if( startsWith( "random", order ) ) + config.runOrder = RunTests::InRandomOrder; + else + return clara::ParserResult::runtimeError( "Unrecognised ordering: '" + order + "'" ); + return ParserResult::ok( ParseResultType::Matched ); + }; + auto const setRngSeed = [&]( std::string const& seed ) { + if( seed != "time" ) + return clara::detail::convertInto( seed, config.rngSeed ); + config.rngSeed = static_cast( std::time(nullptr) ); + return ParserResult::ok( ParseResultType::Matched ); + }; + auto const setColourUsage = [&]( std::string const& useColour ) { + auto mode = toLower( useColour ); + + if( mode == "yes" ) + config.useColour = UseColour::Yes; + else if( mode == "no" ) + config.useColour = UseColour::No; + else if( mode == "auto" ) + config.useColour = UseColour::Auto; + else + return ParserResult::runtimeError( "colour mode must be one of: auto, yes or no. '" + useColour + "' not recognised" ); + return ParserResult::ok( ParseResultType::Matched ); + }; + auto const setWaitForKeypress = [&]( std::string const& keypress ) { + auto keypressLc = toLower( keypress ); + if( keypressLc == "start" ) + config.waitForKeypress = WaitForKeypress::BeforeStart; + else if( keypressLc == "exit" ) + config.waitForKeypress = WaitForKeypress::BeforeExit; + else if( keypressLc == "both" ) + config.waitForKeypress = WaitForKeypress::BeforeStartAndExit; + else + return ParserResult::runtimeError( "keypress argument must be one of: start, exit or both. '" + keypress + "' not recognised" ); + return ParserResult::ok( ParseResultType::Matched ); + }; + auto const setVerbosity = [&]( std::string const& verbosity ) { + auto lcVerbosity = toLower( verbosity ); + if( lcVerbosity == "quiet" ) + config.verbosity = Verbosity::Quiet; + else if( lcVerbosity == "normal" ) + config.verbosity = Verbosity::Normal; + else if( lcVerbosity == "high" ) + config.verbosity = Verbosity::High; + else + return ParserResult::runtimeError( "Unrecognised verbosity, '" + verbosity + "'" ); + return ParserResult::ok( ParseResultType::Matched ); + }; + + auto cli + = ExeName( config.processName ) + | Help( config.showHelp ) + | Opt( config.listTests ) + ["-l"]["--list-tests"] + ( "list all/matching test cases" ) + | Opt( config.listTags ) + ["-t"]["--list-tags"] + ( "list all/matching tags" ) + | Opt( config.showSuccessfulTests ) + ["-s"]["--success"] + ( "include successful tests in output" ) + | Opt( config.shouldDebugBreak ) + ["-b"]["--break"] + ( "break into debugger on failure" ) + | Opt( config.noThrow ) + ["-e"]["--nothrow"] + ( "skip exception tests" ) + | Opt( config.showInvisibles ) + ["-i"]["--invisibles"] + ( "show invisibles (tabs, newlines)" ) + | Opt( config.outputFilename, "filename" ) + ["-o"]["--out"] + ( "output filename" ) + | Opt( config.reporterName, "name" ) + ["-r"]["--reporter"] + ( "reporter to use (defaults to console)" ) + | Opt( config.name, "name" ) + ["-n"]["--name"] + ( "suite name" ) + | Opt( [&]( bool ){ config.abortAfter = 1; } ) + ["-a"]["--abort"] + ( "abort at first failure" ) + | Opt( [&]( int x ){ config.abortAfter = x; }, "no. failures" ) + ["-x"]["--abortx"] + ( "abort after x failures" ) + | Opt( setWarning, "warning name" ) + ["-w"]["--warn"] + ( "enable warnings" ) + | Opt( [&]( bool flag ) { config.showDurations = flag ? ShowDurations::Always : ShowDurations::Never; }, "yes|no" ) + ["-d"]["--durations"] + ( "show test durations" ) + | Opt( loadTestNamesFromFile, "filename" ) + ["-f"]["--input-file"] + ( "load test names to run from a file" ) + | Opt( config.filenamesAsTags ) + ["-#"]["--filenames-as-tags"] + ( "adds a tag for the filename" ) + | Opt( config.sectionsToRun, "section name" ) + ["-c"]["--section"] + ( "specify section to run" ) + | Opt( setVerbosity, "quiet|normal|high" ) + ["-v"]["--verbosity"] + ( "set output verbosity" ) + | Opt( config.listTestNamesOnly ) + ["--list-test-names-only"] + ( "list all/matching test cases names only" ) + | Opt( config.listReporters ) + ["--list-reporters"] + ( "list all reporters" ) + | Opt( setTestOrder, "decl|lex|rand" ) + ["--order"] + ( "test case order (defaults to decl)" ) + | Opt( setRngSeed, "'time'|number" ) + ["--rng-seed"] + ( "set a specific seed for random numbers" ) + | Opt( setColourUsage, "yes|no" ) + ["--use-colour"] + ( "should output be colourised" ) + | Opt( config.libIdentify ) + ["--libidentify"] + ( "report name and version according to libidentify standard" ) + | Opt( setWaitForKeypress, "start|exit|both" ) + ["--wait-for-keypress"] + ( "waits for a keypress before exiting" ) + | Opt( config.benchmarkResolutionMultiple, "multiplier" ) + ["--benchmark-resolution-multiple"] + ( "multiple of clock resolution to run benchmarks" ) + + | Arg( config.testsOrTags, "test name|pattern|tags" ) + ( "which test or tests to use" ); + + return cli; + } + +} // end namespace Catch diff --git a/src/third_party/cppcodec/test/catch/include/internal/catch_commandline.h b/src/third_party/cppcodec/test/catch/include/internal/catch_commandline.h new file mode 100644 index 0000000000..b73cfa2ddb --- /dev/null +++ b/src/third_party/cppcodec/test/catch/include/internal/catch_commandline.h @@ -0,0 +1,20 @@ +/* + * Created by Phil on 02/11/2010. + * Copyright 2010 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_CATCH_COMMANDLINE_HPP_INCLUDED +#define TWOBLUECUBES_CATCH_COMMANDLINE_HPP_INCLUDED + +#include "catch_config.hpp" +#include "catch_clara.h" + +namespace Catch { + + clara::Parser makeCommandLineParser( ConfigData& config ); + +} // end namespace Catch + +#endif // TWOBLUECUBES_CATCH_COMMANDLINE_HPP_INCLUDED diff --git a/src/third_party/cppcodec/test/catch/include/internal/catch_common.cpp b/src/third_party/cppcodec/test/catch/include/internal/catch_common.cpp new file mode 100644 index 0000000000..c271146d7e --- /dev/null +++ b/src/third_party/cppcodec/test/catch/include/internal/catch_common.cpp @@ -0,0 +1,44 @@ +/* + * Created by Phil on 27/11/2013. + * Copyright 2013 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) + */ + +#include "catch_common.h" +#include "catch_context.h" +#include "catch_interfaces_config.h" + +#include +#include + +namespace Catch { + + bool SourceLineInfo::empty() const noexcept { + return file[0] == '\0'; + } + bool SourceLineInfo::operator == ( SourceLineInfo const& other ) const noexcept { + return line == other.line && (file == other.file || std::strcmp(file, other.file) == 0); + } + bool SourceLineInfo::operator < ( SourceLineInfo const& other ) const noexcept { + return line < other.line || ( line == other.line && (std::strcmp(file, other.file) < 0)); + } + + std::ostream& operator << ( std::ostream& os, SourceLineInfo const& info ) { +#ifndef __GNUG__ + os << info.file << '(' << info.line << ')'; +#else + os << info.file << ':' << info.line; +#endif + return os; + } + + std::string StreamEndStop::operator+() const { + return std::string(); + } + + NonCopyable::NonCopyable() = default; + NonCopyable::~NonCopyable() = default; + +} diff --git a/src/third_party/cppcodec/test/catch/include/internal/catch_common.h b/src/third_party/cppcodec/test/catch/include/internal/catch_common.h new file mode 100644 index 0000000000..4aaf80c590 --- /dev/null +++ b/src/third_party/cppcodec/test/catch/include/internal/catch_common.h @@ -0,0 +1,83 @@ +/* + * Created by Phil on 29/10/2010. + * Copyright 2010 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_CATCH_COMMON_H_INCLUDED +#define TWOBLUECUBES_CATCH_COMMON_H_INCLUDED + +#include "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 + +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( SourceLineInfo && ) = default; + SourceLineInfo& operator = ( SourceLineInfo const& ) = default; + SourceLineInfo& operator = ( SourceLineInfo && ) = default; + + bool empty() const noexcept; + 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 ); + + // 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__ ) ) + +#endif // TWOBLUECUBES_CATCH_COMMON_H_INCLUDED + diff --git a/src/third_party/cppcodec/test/catch/include/internal/catch_compiler_capabilities.h b/src/third_party/cppcodec/test/catch/include/internal/catch_compiler_capabilities.h new file mode 100644 index 0000000000..2276dd369f --- /dev/null +++ b/src/third_party/cppcodec/test/catch/include/internal/catch_compiler_capabilities.h @@ -0,0 +1,197 @@ +/* + * Created by Phil on 15/04/2013. + * Copyright 2013 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_CATCH_COMPILER_CAPABILITIES_HPP_INCLUDED +#define TWOBLUECUBES_CATCH_COMPILER_CAPABILITIES_HPP_INCLUDED + +// 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? +// **************** +// 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. + +#include "catch_platform.h" + +#ifdef __cplusplus + +# if __cplusplus >= 201402L +# define CATCH_CPP14_OR_GREATER +# endif + +# if __cplusplus >= 201703L +# define CATCH_CPP17_OR_GREATER +# endif + +#endif + +#if defined(CATCH_CPP17_OR_GREATER) +# define CATCH_INTERNAL_CONFIG_CPP17_UNCAUGHT_EXCEPTIONS +#endif + +#ifdef __clang__ + +# define CATCH_INTERNAL_SUPPRESS_GLOBALS_WARNINGS \ + _Pragma( "clang diagnostic push" ) \ + _Pragma( "clang diagnostic ignored \"-Wexit-time-destructors\"" ) \ + _Pragma( "clang diagnostic ignored \"-Wglobal-constructors\"") +# define CATCH_INTERNAL_UNSUPPRESS_GLOBALS_WARNINGS \ + _Pragma( "clang diagnostic pop" ) + +# define CATCH_INTERNAL_SUPPRESS_PARENTHESES_WARNINGS \ + _Pragma( "clang diagnostic push" ) \ + _Pragma( "clang diagnostic ignored \"-Wparentheses\"" ) +# define CATCH_INTERNAL_UNSUPPRESS_PARENTHESES_WARNINGS \ + _Pragma( "clang diagnostic pop" ) + +# define CATCH_INTERNAL_SUPPRESS_UNUSED_WARNINGS \ + _Pragma( "clang diagnostic push" ) \ + _Pragma( "clang diagnostic ignored \"-Wunused-variable\"" ) +# define CATCH_INTERNAL_UNSUPPRESS_UNUSED_WARNINGS \ + _Pragma( "clang diagnostic pop" ) + +#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 +#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 + +#endif // __CYGWIN__ + +//////////////////////////////////////////////////////////////////////////////// +// Visual C++ +#ifdef _MSC_VER + + +# if _MSC_VER >= 1900 // Visual Studio 2015 or newer +# define CATCH_INTERNAL_CONFIG_CPP17_UNCAUGHT_EXCEPTIONS +# endif + +// 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 + +#endif // _MSC_VER + +//////////////////////////////////////////////////////////////////////////////// + +// DJGPP +#ifdef __DJGPP__ +# define CATCH_INTERNAL_CONFIG_NO_WCHAR +#endif // __DJGPP__ + +//////////////////////////////////////////////////////////////////////////////// + +// 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 + +#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_UNCAUGHT_EXCEPTIONS) && !defined(CATCH_CONFIG_NO_CPP17_UNCAUGHT_EXCEPTIONS) && !defined(CATCH_CONFIG_CPP17_UNCAUGHT_EXCEPTIONS) +# define CATCH_CONFIG_CPP17_UNCAUGHT_EXCEPTIONS +#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_SUPPRESS_PARENTHESES_WARNINGS) +# define CATCH_INTERNAL_SUPPRESS_PARENTHESES_WARNINGS +# define CATCH_INTERNAL_UNSUPPRESS_PARENTHESES_WARNINGS +#endif +#if !defined(CATCH_INTERNAL_SUPPRESS_GLOBALS_WARNINGS) +# define CATCH_INTERNAL_SUPPRESS_GLOBALS_WARNINGS +# define CATCH_INTERNAL_UNSUPPRESS_GLOBALS_WARNINGS +#endif +#if !defined(CATCH_INTERNAL_SUPPRESS_UNUSED_WARNINGS) +# define CATCH_INTERNAL_SUPPRESS_UNUSED_WARNINGS +# define CATCH_INTERNAL_UNSUPPRESS_UNUSED_WARNINGS +#endif + + +#endif // TWOBLUECUBES_CATCH_COMPILER_CAPABILITIES_HPP_INCLUDED + diff --git a/src/third_party/cppcodec/test/catch/include/internal/catch_config.cpp b/src/third_party/cppcodec/test/catch/include/internal/catch_config.cpp new file mode 100644 index 0000000000..e8ad2a81f2 --- /dev/null +++ b/src/third_party/cppcodec/test/catch/include/internal/catch_config.cpp @@ -0,0 +1,71 @@ +/* + * Created by Martin on 19/07/2017. + * + * 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) + */ + +#include "catch_config.hpp" +#include "catch_enforce.h" +#include "catch_stringref.h" + +namespace Catch { + + Config::Config( ConfigData const& data ) + : m_data( data ), + m_stream( openStream() ) + { + TestSpecParser parser(ITagAliasRegistry::get()); + if (data.testsOrTags.empty()) { + parser.parse("~[.]"); // All not hidden tests + } + else { + m_hasTestFilters = true; + for( auto const& testOrTags : data.testsOrTags ) + parser.parse( testOrTags ); + } + m_testSpec = parser.testSpec(); + } + + std::string const& Config::getFilename() const { + return m_data.outputFilename ; + } + + bool Config::listTests() const { return m_data.listTests; } + bool Config::listTestNamesOnly() const { return m_data.listTestNamesOnly; } + bool Config::listTags() const { return m_data.listTags; } + bool Config::listReporters() const { return m_data.listReporters; } + + std::string Config::getProcessName() const { return m_data.processName; } + std::string const& Config::getReporterName() const { return m_data.reporterName; } + + std::vector const& Config::getTestsOrTags() const { return m_data.testsOrTags; } + std::vector const& Config::getSectionsToRun() const { return m_data.sectionsToRun; } + + TestSpec const& Config::testSpec() const { return m_testSpec; } + bool Config::hasTestFilters() const { return m_hasTestFilters; } + + bool Config::showHelp() const { return m_data.showHelp; } + + // IConfig interface + bool Config::allowThrows() const { return !m_data.noThrow; } + std::ostream& Config::stream() const { return m_stream->stream(); } + std::string Config::name() const { return m_data.name.empty() ? m_data.processName : m_data.name; } + bool Config::includeSuccessfulResults() const { return m_data.showSuccessfulTests; } + bool Config::warnAboutMissingAssertions() const { return !!(m_data.warnings & WarnAbout::NoAssertions); } + bool Config::warnAboutNoTests() const { return !!(m_data.warnings & WarnAbout::NoTests); } + ShowDurations::OrNot Config::showDurations() const { return m_data.showDurations; } + RunTests::InWhatOrder Config::runOrder() const { return m_data.runOrder; } + unsigned int Config::rngSeed() const { return m_data.rngSeed; } + int Config::benchmarkResolutionMultiple() const { return m_data.benchmarkResolutionMultiple; } + UseColour::YesOrNo Config::useColour() const { return m_data.useColour; } + bool Config::shouldDebugBreak() const { return m_data.shouldDebugBreak; } + int Config::abortAfter() const { return m_data.abortAfter; } + bool Config::showInvisibles() const { return m_data.showInvisibles; } + Verbosity Config::verbosity() const { return m_data.verbosity; } + + IStream const* Config::openStream() { + return Catch::makeStream(m_data.outputFilename); + } + +} // end namespace Catch diff --git a/src/third_party/cppcodec/test/catch/include/internal/catch_config.hpp b/src/third_party/cppcodec/test/catch/include/internal/catch_config.hpp new file mode 100644 index 0000000000..7bafc9c361 --- /dev/null +++ b/src/third_party/cppcodec/test/catch/include/internal/catch_config.hpp @@ -0,0 +1,122 @@ +/* + * Created by Phil on 08/11/2010. + * Copyright 2010 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_CATCH_CONFIG_HPP_INCLUDED +#define TWOBLUECUBES_CATCH_CONFIG_HPP_INCLUDED + +#include "catch_test_spec_parser.h" +#include "catch_interfaces_config.h" + +// Libstdc++ doesn't like incomplete classes for unique_ptr +#include "catch_stream.h" + +#include +#include +#include + +#ifndef CATCH_CONFIG_CONSOLE_WIDTH +#define CATCH_CONFIG_CONSOLE_WIDTH 80 +#endif + +namespace Catch { + + struct IStream; + + struct ConfigData { + bool listTests = false; + bool listTags = false; + bool listReporters = false; + bool listTestNamesOnly = false; + + bool showSuccessfulTests = false; + bool shouldDebugBreak = false; + bool noThrow = false; + bool showHelp = false; + bool showInvisibles = false; + bool filenamesAsTags = false; + bool libIdentify = false; + + int abortAfter = -1; + unsigned int rngSeed = 0; + int benchmarkResolutionMultiple = 100; + + Verbosity verbosity = Verbosity::Normal; + WarnAbout::What warnings = WarnAbout::Nothing; + ShowDurations::OrNot showDurations = ShowDurations::DefaultForReporter; + RunTests::InWhatOrder runOrder = RunTests::InDeclarationOrder; + UseColour::YesOrNo useColour = UseColour::Auto; + WaitForKeypress::When waitForKeypress = WaitForKeypress::Never; + + std::string outputFilename; + std::string name; + std::string processName; +#ifndef CATCH_CONFIG_DEFAULT_REPORTER +#define CATCH_CONFIG_DEFAULT_REPORTER "console" +#endif + std::string reporterName = CATCH_CONFIG_DEFAULT_REPORTER; +#undef CATCH_CONFIG_DEFAULT_REPORTER + + std::vector testsOrTags; + std::vector sectionsToRun; + }; + + + class Config : public IConfig { + public: + + Config() = default; + Config( ConfigData const& data ); + virtual ~Config() = default; + + std::string const& getFilename() const; + + bool listTests() const; + bool listTestNamesOnly() const; + bool listTags() const; + bool listReporters() const; + + std::string getProcessName() const; + std::string const& getReporterName() const; + + std::vector const& getTestsOrTags() const; + std::vector const& getSectionsToRun() const override; + + virtual TestSpec const& testSpec() const override; + bool hasTestFilters() const override; + + bool showHelp() const; + + // IConfig interface + bool allowThrows() const override; + std::ostream& stream() const override; + std::string name() const override; + bool includeSuccessfulResults() const override; + bool warnAboutMissingAssertions() const override; + bool warnAboutNoTests() const override; + ShowDurations::OrNot showDurations() const override; + RunTests::InWhatOrder runOrder() const override; + unsigned int rngSeed() const override; + int benchmarkResolutionMultiple() const override; + UseColour::YesOrNo useColour() const override; + bool shouldDebugBreak() const override; + int abortAfter() const override; + bool showInvisibles() const override; + Verbosity verbosity() const override; + + private: + + IStream const* openStream(); + ConfigData m_data; + + std::unique_ptr m_stream; + TestSpec m_testSpec; + bool m_hasTestFilters = false; + }; + +} // end namespace Catch + +#endif // TWOBLUECUBES_CATCH_CONFIG_HPP_INCLUDED diff --git a/src/third_party/cppcodec/test/catch/include/internal/catch_console_colour.cpp b/src/third_party/cppcodec/test/catch/include/internal/catch_console_colour.cpp new file mode 100644 index 0000000000..5fb1d07f1b --- /dev/null +++ b/src/third_party/cppcodec/test/catch/include/internal/catch_console_colour.cpp @@ -0,0 +1,236 @@ +/* + * Created by Phil on 25/2/2012. + * Copyright 2012 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) + */ + + +#if defined(__clang__) +# pragma clang diagnostic push +# pragma clang diagnostic ignored "-Wexit-time-destructors" +#endif + + +#include "catch_console_colour.h" +#include "catch_enforce.h" +#include "catch_errno_guard.h" +#include "catch_interfaces_config.h" +#include "catch_stream.h" +#include "catch_context.h" +#include "catch_platform.h" +#include "catch_debugger.h" +#include "catch_windows_h_proxy.h" + +#include + +namespace Catch { + namespace { + + struct IColourImpl { + virtual ~IColourImpl() = default; + virtual void use( Colour::Code _colourCode ) = 0; + }; + + struct NoColourImpl : IColourImpl { + void use( Colour::Code ) {} + + static IColourImpl* instance() { + static NoColourImpl s_instance; + return &s_instance; + } + }; + + } // anon namespace +} // namespace Catch + +#if !defined( CATCH_CONFIG_COLOUR_NONE ) && !defined( CATCH_CONFIG_COLOUR_WINDOWS ) && !defined( CATCH_CONFIG_COLOUR_ANSI ) +# ifdef CATCH_PLATFORM_WINDOWS +# define CATCH_CONFIG_COLOUR_WINDOWS +# else +# define CATCH_CONFIG_COLOUR_ANSI +# endif +#endif + + +#if defined ( CATCH_CONFIG_COLOUR_WINDOWS ) ///////////////////////////////////////// + +namespace Catch { +namespace { + + class Win32ColourImpl : public IColourImpl { + public: + Win32ColourImpl() : stdoutHandle( GetStdHandle(STD_OUTPUT_HANDLE) ) + { + CONSOLE_SCREEN_BUFFER_INFO csbiInfo; + GetConsoleScreenBufferInfo( stdoutHandle, &csbiInfo ); + originalForegroundAttributes = csbiInfo.wAttributes & ~( BACKGROUND_GREEN | BACKGROUND_RED | BACKGROUND_BLUE | BACKGROUND_INTENSITY ); + originalBackgroundAttributes = csbiInfo.wAttributes & ~( FOREGROUND_GREEN | FOREGROUND_RED | FOREGROUND_BLUE | FOREGROUND_INTENSITY ); + } + + virtual void use( Colour::Code _colourCode ) override { + switch( _colourCode ) { + case Colour::None: return setTextAttribute( originalForegroundAttributes ); + case Colour::White: return setTextAttribute( FOREGROUND_GREEN | FOREGROUND_RED | FOREGROUND_BLUE ); + case Colour::Red: return setTextAttribute( FOREGROUND_RED ); + case Colour::Green: return setTextAttribute( FOREGROUND_GREEN ); + case Colour::Blue: return setTextAttribute( FOREGROUND_BLUE ); + case Colour::Cyan: return setTextAttribute( FOREGROUND_BLUE | FOREGROUND_GREEN ); + case Colour::Yellow: return setTextAttribute( FOREGROUND_RED | FOREGROUND_GREEN ); + case Colour::Grey: return setTextAttribute( 0 ); + + case Colour::LightGrey: return setTextAttribute( FOREGROUND_INTENSITY ); + case Colour::BrightRed: return setTextAttribute( FOREGROUND_INTENSITY | FOREGROUND_RED ); + case Colour::BrightGreen: return setTextAttribute( FOREGROUND_INTENSITY | FOREGROUND_GREEN ); + case Colour::BrightWhite: return setTextAttribute( FOREGROUND_INTENSITY | FOREGROUND_GREEN | FOREGROUND_RED | FOREGROUND_BLUE ); + case Colour::BrightYellow: return setTextAttribute( FOREGROUND_INTENSITY | FOREGROUND_RED | FOREGROUND_GREEN ); + + case Colour::Bright: CATCH_INTERNAL_ERROR( "not a colour" ); + + default: + CATCH_ERROR( "Unknown colour requested" ); + } + } + + private: + void setTextAttribute( WORD _textAttribute ) { + SetConsoleTextAttribute( stdoutHandle, _textAttribute | originalBackgroundAttributes ); + } + HANDLE stdoutHandle; + WORD originalForegroundAttributes; + WORD originalBackgroundAttributes; + }; + + IColourImpl* platformColourInstance() { + static Win32ColourImpl s_instance; + + IConfigPtr config = getCurrentContext().getConfig(); + UseColour::YesOrNo colourMode = config + ? config->useColour() + : UseColour::Auto; + if( colourMode == UseColour::Auto ) + colourMode = UseColour::Yes; + return colourMode == UseColour::Yes + ? &s_instance + : NoColourImpl::instance(); + } + +} // end anon namespace +} // end namespace Catch + +#elif defined( CATCH_CONFIG_COLOUR_ANSI ) ////////////////////////////////////// + +#include + +namespace Catch { +namespace { + + // use POSIX/ ANSI console terminal codes + // Thanks to Adam Strzelecki for original contribution + // (http://github.com/nanoant) + // https://github.com/philsquared/Catch/pull/131 + class PosixColourImpl : public IColourImpl { + public: + virtual void use( Colour::Code _colourCode ) override { + switch( _colourCode ) { + case Colour::None: + case Colour::White: return setColour( "[0m" ); + case Colour::Red: return setColour( "[0;31m" ); + case Colour::Green: return setColour( "[0;32m" ); + case Colour::Blue: return setColour( "[0;34m" ); + case Colour::Cyan: return setColour( "[0;36m" ); + case Colour::Yellow: return setColour( "[0;33m" ); + case Colour::Grey: return setColour( "[1;30m" ); + + case Colour::LightGrey: return setColour( "[0;37m" ); + case Colour::BrightRed: return setColour( "[1;31m" ); + case Colour::BrightGreen: return setColour( "[1;32m" ); + case Colour::BrightWhite: return setColour( "[1;37m" ); + case Colour::BrightYellow: return setColour( "[1;33m" ); + + case Colour::Bright: CATCH_INTERNAL_ERROR( "not a colour" ); + default: CATCH_INTERNAL_ERROR( "Unknown colour requested" ); + } + } + static IColourImpl* instance() { + static PosixColourImpl s_instance; + return &s_instance; + } + + private: + void setColour( const char* _escapeCode ) { + Catch::cout() << '\033' << _escapeCode; + } + }; + + bool useColourOnPlatform() { + return +#ifdef CATCH_PLATFORM_MAC + !isDebuggerActive() && +#endif +#if !(defined(__DJGPP__) && defined(__STRICT_ANSI__)) + isatty(STDOUT_FILENO) +#else + false +#endif + ; + } + IColourImpl* platformColourInstance() { + ErrnoGuard guard; + IConfigPtr config = getCurrentContext().getConfig(); + UseColour::YesOrNo colourMode = config + ? config->useColour() + : UseColour::Auto; + if( colourMode == UseColour::Auto ) + colourMode = useColourOnPlatform() + ? UseColour::Yes + : UseColour::No; + return colourMode == UseColour::Yes + ? PosixColourImpl::instance() + : NoColourImpl::instance(); + } + +} // end anon namespace +} // end namespace Catch + +#else // not Windows or ANSI /////////////////////////////////////////////// + +namespace Catch { + + static IColourImpl* platformColourInstance() { return NoColourImpl::instance(); } + +} // end namespace Catch + +#endif // Windows/ ANSI/ None + +namespace Catch { + + Colour::Colour( Code _colourCode ) { use( _colourCode ); } + Colour::Colour( Colour&& rhs ) noexcept { + m_moved = rhs.m_moved; + rhs.m_moved = true; + } + Colour& Colour::operator=( Colour&& rhs ) noexcept { + m_moved = rhs.m_moved; + rhs.m_moved = true; + return *this; + } + + Colour::~Colour(){ if( !m_moved ) use( None ); } + + void Colour::use( Code _colourCode ) { + static IColourImpl* impl = platformColourInstance(); + impl->use( _colourCode ); + } + + std::ostream& operator << ( std::ostream& os, Colour const& ) { + return os; + } + +} // end namespace Catch + +#if defined(__clang__) +# pragma clang diagnostic pop +#endif + diff --git a/src/third_party/cppcodec/test/catch/include/internal/catch_console_colour.h b/src/third_party/cppcodec/test/catch/include/internal/catch_console_colour.h new file mode 100644 index 0000000000..ec653424e4 --- /dev/null +++ b/src/third_party/cppcodec/test/catch/include/internal/catch_console_colour.h @@ -0,0 +1,69 @@ +/* + * Created by Phil on 25/2/2012. + * Copyright 2012 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_CATCH_CONSOLE_COLOUR_HPP_INCLUDED +#define TWOBLUECUBES_CATCH_CONSOLE_COLOUR_HPP_INCLUDED + +#include "catch_common.h" + +namespace Catch { + + struct Colour { + enum Code { + None = 0, + + White, + Red, + Green, + Blue, + Cyan, + Yellow, + Grey, + + Bright = 0x10, + + BrightRed = Bright | Red, + BrightGreen = Bright | Green, + LightGrey = Bright | Grey, + BrightWhite = Bright | White, + BrightYellow = Bright | Yellow, + + // By intention + FileName = LightGrey, + Warning = BrightYellow, + ResultError = BrightRed, + ResultSuccess = BrightGreen, + ResultExpectedFailure = Warning, + + Error = BrightRed, + Success = Green, + + OriginalExpression = Cyan, + ReconstructedExpression = BrightYellow, + + SecondaryText = LightGrey, + Headers = White + }; + + // Use constructed object for RAII guard + Colour( Code _colourCode ); + Colour( Colour&& other ) noexcept; + Colour& operator=( Colour&& other ) noexcept; + ~Colour(); + + // Use static method for one-shot changes + static void use( Code _colourCode ); + + private: + bool m_moved = false; + }; + + std::ostream& operator << ( std::ostream& os, Colour const& ); + +} // end namespace Catch + +#endif // TWOBLUECUBES_CATCH_CONSOLE_COLOUR_HPP_INCLUDED diff --git a/src/third_party/cppcodec/test/catch/include/internal/catch_context.cpp b/src/third_party/cppcodec/test/catch/include/internal/catch_context.cpp new file mode 100644 index 0000000000..e116f28f57 --- /dev/null +++ b/src/third_party/cppcodec/test/catch/include/internal/catch_context.cpp @@ -0,0 +1,62 @@ +/* + * Created by Phil on 31/12/2010. + * Copyright 2010 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) + */ +#include "catch_context.h" +#include "catch_common.h" + +namespace Catch { + + class Context : public IMutableContext, NonCopyable { + + public: // IContext + virtual IResultCapture* getResultCapture() override { + return m_resultCapture; + } + virtual IRunner* getRunner() override { + return m_runner; + } + + virtual IConfigPtr const& getConfig() const override { + return m_config; + } + + virtual ~Context() override; + + public: // IMutableContext + virtual void setResultCapture( IResultCapture* resultCapture ) override { + m_resultCapture = resultCapture; + } + virtual void setRunner( IRunner* runner ) override { + m_runner = runner; + } + virtual void setConfig( IConfigPtr const& config ) override { + m_config = config; + } + + friend IMutableContext& getCurrentMutableContext(); + + private: + IConfigPtr m_config; + IRunner* m_runner = nullptr; + IResultCapture* m_resultCapture = nullptr; + }; + + IMutableContext *IMutableContext::currentContext = nullptr; + + void IMutableContext::createContext() + { + currentContext = new Context(); + } + + void cleanUpContext() { + delete IMutableContext::currentContext; + IMutableContext::currentContext = nullptr; + } + IContext::~IContext() = default; + IMutableContext::~IMutableContext() = default; + Context::~Context() = default; +} diff --git a/src/third_party/cppcodec/test/catch/include/internal/catch_context.h b/src/third_party/cppcodec/test/catch/include/internal/catch_context.h new file mode 100644 index 0000000000..3d3c6bad46 --- /dev/null +++ b/src/third_party/cppcodec/test/catch/include/internal/catch_context.h @@ -0,0 +1,60 @@ +/* + * Created by Phil on 31/12/2010. + * Copyright 2010 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_CATCH_CONTEXT_H_INCLUDED +#define TWOBLUECUBES_CATCH_CONTEXT_H_INCLUDED + +#include + +namespace Catch { + + struct IResultCapture; + struct IRunner; + struct IConfig; + struct IMutableContext; + + using IConfigPtr = std::shared_ptr; + + struct IContext + { + virtual ~IContext(); + + virtual IResultCapture* getResultCapture() = 0; + virtual IRunner* getRunner() = 0; + virtual IConfigPtr const& getConfig() const = 0; + }; + + struct IMutableContext : IContext + { + virtual ~IMutableContext(); + virtual void setResultCapture( IResultCapture* resultCapture ) = 0; + virtual void setRunner( IRunner* runner ) = 0; + virtual void setConfig( IConfigPtr const& config ) = 0; + + private: + static IMutableContext *currentContext; + friend IMutableContext& getCurrentMutableContext(); + friend void cleanUpContext(); + static void createContext(); + }; + + inline IMutableContext& getCurrentMutableContext() + { + if( !IMutableContext::currentContext ) + IMutableContext::createContext(); + return *IMutableContext::currentContext; + } + + inline IContext& getCurrentContext() + { + return getCurrentMutableContext(); + } + + void cleanUpContext(); +} + +#endif // TWOBLUECUBES_CATCH_CONTEXT_H_INCLUDED diff --git a/src/third_party/cppcodec/test/catch/include/internal/catch_debug_console.cpp b/src/third_party/cppcodec/test/catch/include/internal/catch_debug_console.cpp new file mode 100644 index 0000000000..5d25f651c0 --- /dev/null +++ b/src/third_party/cppcodec/test/catch/include/internal/catch_debug_console.cpp @@ -0,0 +1,31 @@ +/* + * Created by Martin on 29/08/2017. + * + * 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) + * + */ + +#include "catch_debug_console.h" +#include "catch_stream.h" +#include "catch_platform.h" +#include "catch_windows_h_proxy.h" + +#ifdef CATCH_PLATFORM_WINDOWS + + namespace Catch { + void writeToDebugConsole( std::string const& text ) { + ::OutputDebugStringA( text.c_str() ); + } + } + +#else + + namespace Catch { + void writeToDebugConsole( std::string const& text ) { + // !TBD: Need a version for Mac/ XCode and other IDEs + Catch::cout() << text; + } + } + +#endif // Platform diff --git a/src/third_party/cppcodec/test/catch/include/internal/catch_debug_console.h b/src/third_party/cppcodec/test/catch/include/internal/catch_debug_console.h new file mode 100644 index 0000000000..2c229a8348 --- /dev/null +++ b/src/third_party/cppcodec/test/catch/include/internal/catch_debug_console.h @@ -0,0 +1,17 @@ +/* + * Created by Martin on 29/08/2017. + * + * 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_CATCH_DEBUG_CONSOLE_H_INCLUDED +#define TWOBLUECUBES_CATCH_DEBUG_CONSOLE_H_INCLUDED + +#include + +namespace Catch { + void writeToDebugConsole( std::string const& text ); +} + +#endif // TWOBLUECUBES_CATCH_DEBUG_CONSOLE_H_INCLUDED diff --git a/src/third_party/cppcodec/test/catch/include/internal/catch_debugger.cpp b/src/third_party/cppcodec/test/catch/include/internal/catch_debugger.cpp new file mode 100644 index 0000000000..71dc65066c --- /dev/null +++ b/src/third_party/cppcodec/test/catch/include/internal/catch_debugger.cpp @@ -0,0 +1,113 @@ +/* + * Created by Phil on 27/12/2010. + * Copyright 2010 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) + * + */ + +#include "catch_debugger.h" +#include "catch_errno_guard.h" +#include "catch_stream.h" +#include "catch_platform.h" + +#ifdef CATCH_PLATFORM_MAC + +# include +# include +# include +# include +# include +# include +# include + +namespace Catch { + + // The following function is taken directly from the following technical note: + // http://developer.apple.com/library/mac/#qa/qa2004/qa1361.html + + // Returns true if the current process is being debugged (either + // running under the debugger or has a debugger attached post facto). + bool isDebuggerActive(){ + + int mib[4]; + struct kinfo_proc info; + std::size_t size; + + // Initialize the flags so that, if sysctl fails for some bizarre + // reason, we get a predictable result. + + info.kp_proc.p_flag = 0; + + // Initialize mib, which tells sysctl the info we want, in this case + // we're looking for information about a specific process ID. + + mib[0] = CTL_KERN; + mib[1] = KERN_PROC; + mib[2] = KERN_PROC_PID; + mib[3] = getpid(); + + // Call sysctl. + + size = sizeof(info); + if( sysctl(mib, sizeof(mib) / sizeof(*mib), &info, &size, nullptr, 0) != 0 ) { + Catch::cerr() << "\n** Call to sysctl failed - unable to determine if debugger is active **\n" << std::endl; + return false; + } + + // We're being debugged if the P_TRACED flag is set. + + return ( (info.kp_proc.p_flag & P_TRACED) != 0 ); + } + } // namespace Catch + +#elif defined(CATCH_PLATFORM_LINUX) + #include + #include + + namespace Catch{ + // The standard POSIX way of detecting a debugger is to attempt to + // ptrace() the process, but this needs to be done from a child and not + // this process itself to still allow attaching to this process later + // if wanted, so is rather heavy. Under Linux we have the PID of the + // "debugger" (which doesn't need to be gdb, of course, it could also + // be strace, for example) in /proc/$PID/status, so just get it from + // there instead. + bool isDebuggerActive(){ + // Libstdc++ has a bug, where std::ifstream sets errno to 0 + // This way our users can properly assert over errno values + ErrnoGuard guard; + std::ifstream in("/proc/self/status"); + for( std::string line; std::getline(in, line); ) { + static const int PREFIX_LEN = 11; + if( line.compare(0, PREFIX_LEN, "TracerPid:\t") == 0 ) { + // We're traced if the PID is not 0 and no other PID starts + // with 0 digit, so it's enough to check for just a single + // character. + return line.length() > PREFIX_LEN && line[PREFIX_LEN] != '0'; + } + } + + return false; + } + } // namespace Catch +#elif defined(_MSC_VER) + extern "C" __declspec(dllimport) int __stdcall IsDebuggerPresent(); + namespace Catch { + bool isDebuggerActive() { + return IsDebuggerPresent() != 0; + } + } +#elif defined(__MINGW32__) + extern "C" __declspec(dllimport) int __stdcall IsDebuggerPresent(); + namespace Catch { + bool isDebuggerActive() { + return IsDebuggerPresent() != 0; + } + } +#else + namespace Catch { + bool isDebuggerActive() { return false; } + } +#endif // Platform diff --git a/src/third_party/cppcodec/test/catch/include/internal/catch_debugger.h b/src/third_party/cppcodec/test/catch/include/internal/catch_debugger.h new file mode 100644 index 0000000000..75419842b2 --- /dev/null +++ b/src/third_party/cppcodec/test/catch/include/internal/catch_debugger.h @@ -0,0 +1,49 @@ +/* + * Created by Phil on 3/12/2013. + * Copyright 2013 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_CATCH_DEBUGGER_H_INCLUDED +#define TWOBLUECUBES_CATCH_DEBUGGER_H_INCLUDED + +#include "catch_platform.h" + +namespace Catch { + bool isDebuggerActive(); +} + +#ifdef CATCH_PLATFORM_MAC + + #define CATCH_TRAP() __asm__("int $3\n" : : ) /* NOLINT */ + +#elif defined(CATCH_PLATFORM_LINUX) + // If we can use inline assembler, do it because this allows us to break + // directly at the location of the failing check instead of breaking inside + // raise() called from it, i.e. one stack frame below. + #if defined(__GNUC__) && (defined(__i386) || defined(__x86_64)) + #define CATCH_TRAP() asm volatile ("int $3") /* NOLINT */ + #else // Fall back to the generic way. + #include + + #define CATCH_TRAP() raise(SIGTRAP) + #endif +#elif defined(_MSC_VER) + #define CATCH_TRAP() __debugbreak() +#elif defined(__MINGW32__) + extern "C" __declspec(dllimport) void __stdcall DebugBreak(); + #define CATCH_TRAP() DebugBreak() +#endif + +#ifdef CATCH_TRAP + #define CATCH_BREAK_INTO_DEBUGGER() if( Catch::isDebuggerActive() ) { CATCH_TRAP(); } +#else + namespace Catch { + inline void doNothing() {} + } + #define CATCH_BREAK_INTO_DEBUGGER() Catch::doNothing() +#endif + +#endif // TWOBLUECUBES_CATCH_DEBUGGER_H_INCLUDED diff --git a/src/third_party/cppcodec/test/catch/include/internal/catch_decomposer.cpp b/src/third_party/cppcodec/test/catch/include/internal/catch_decomposer.cpp new file mode 100644 index 0000000000..8c19629bba --- /dev/null +++ b/src/third_party/cppcodec/test/catch/include/internal/catch_decomposer.cpp @@ -0,0 +1,24 @@ +/* + * Created by Phil Nash on 8/8/2017. + * Copyright 2017 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) + */ + +#include "catch_decomposer.h" +#include "catch_config.hpp" + +namespace Catch { + + ITransientExpression::~ITransientExpression() = default; + + void formatReconstructedExpression( std::ostream &os, std::string const& lhs, StringRef op, std::string const& rhs ) { + if( lhs.size() + rhs.size() < 40 && + lhs.find('\n') == std::string::npos && + rhs.find('\n') == std::string::npos ) + os << lhs << " " << op << " " << rhs; + else + os << lhs << "\n" << op << "\n" << rhs; + } +} diff --git a/src/third_party/cppcodec/test/catch/include/internal/catch_decomposer.h b/src/third_party/cppcodec/test/catch/include/internal/catch_decomposer.h new file mode 100644 index 0000000000..618a250908 --- /dev/null +++ b/src/third_party/cppcodec/test/catch/include/internal/catch_decomposer.h @@ -0,0 +1,175 @@ +/* + * Created by Phil Nash on 8/8/2017. + * Copyright 2017 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_CATCH_DECOMPOSER_H_INCLUDED +#define TWOBLUECUBES_CATCH_DECOMPOSER_H_INCLUDED + +#include "catch_tostring.h" +#include "catch_stringref.h" + +#include + +#ifdef _MSC_VER +#pragma warning(push) +#pragma warning(disable:4389) // '==' : signed/unsigned mismatch +#pragma warning(disable:4018) // more "signed/unsigned mismatch" +#pragma warning(disable:4312) // Converting int to T* using reinterpret_cast (issue on x64 platform) +#pragma warning(disable:4180) // qualifier applied to function type has no meaning +#endif + +namespace Catch { + + struct ITransientExpression { + auto isBinaryExpression() const -> bool { return m_isBinaryExpression; } + auto getResult() const -> bool { return m_result; } + virtual void streamReconstructedExpression( std::ostream &os ) const = 0; + + ITransientExpression( bool isBinaryExpression, bool result ) + : m_isBinaryExpression( isBinaryExpression ), + m_result( result ) + {} + + // We don't actually need a virtual destructor, but many static analysers + // complain if it's not here :-( + virtual ~ITransientExpression(); + + bool m_isBinaryExpression; + bool m_result; + + }; + + void formatReconstructedExpression( std::ostream &os, std::string const& lhs, StringRef op, std::string const& rhs ); + + template + class BinaryExpr : public ITransientExpression { + LhsT m_lhs; + StringRef m_op; + RhsT m_rhs; + + void streamReconstructedExpression( std::ostream &os ) const override { + formatReconstructedExpression + ( os, Catch::Detail::stringify( m_lhs ), m_op, Catch::Detail::stringify( m_rhs ) ); + } + + public: + BinaryExpr( bool comparisonResult, LhsT lhs, StringRef op, RhsT rhs ) + : ITransientExpression{ true, comparisonResult }, + m_lhs( lhs ), + m_op( op ), + m_rhs( rhs ) + {} + }; + + template + class UnaryExpr : public ITransientExpression { + LhsT m_lhs; + + void streamReconstructedExpression( std::ostream &os ) const override { + os << Catch::Detail::stringify( m_lhs ); + } + + public: + explicit UnaryExpr( LhsT lhs ) + : ITransientExpression{ false, lhs ? true : false }, + m_lhs( lhs ) + {} + }; + + + // Specialised comparison functions to handle equality comparisons between ints and pointers (NULL deduces as an int) + template + auto compareEqual( LhsT const& lhs, RhsT const& rhs ) -> bool { return static_cast(lhs == rhs); } + template + auto compareEqual( T* const& lhs, int rhs ) -> bool { return lhs == reinterpret_cast( rhs ); } + template + auto compareEqual( T* const& lhs, long rhs ) -> bool { return lhs == reinterpret_cast( rhs ); } + template + auto compareEqual( int lhs, T* const& rhs ) -> bool { return reinterpret_cast( lhs ) == rhs; } + template + auto compareEqual( long lhs, T* const& rhs ) -> bool { return reinterpret_cast( lhs ) == rhs; } + + template + auto compareNotEqual( LhsT const& lhs, RhsT&& rhs ) -> bool { return static_cast(lhs != rhs); } + template + auto compareNotEqual( T* const& lhs, int rhs ) -> bool { return lhs != reinterpret_cast( rhs ); } + template + auto compareNotEqual( T* const& lhs, long rhs ) -> bool { return lhs != reinterpret_cast( rhs ); } + template + auto compareNotEqual( int lhs, T* const& rhs ) -> bool { return reinterpret_cast( lhs ) != rhs; } + template + auto compareNotEqual( long lhs, T* const& rhs ) -> bool { return reinterpret_cast( lhs ) != rhs; } + + + template + class ExprLhs { + LhsT m_lhs; + public: + explicit ExprLhs( LhsT lhs ) : m_lhs( lhs ) {} + + template + auto operator == ( RhsT const& rhs ) -> BinaryExpr const { + return { compareEqual( m_lhs, rhs ), m_lhs, "==", rhs }; + } + auto operator == ( bool rhs ) -> BinaryExpr const { + return { m_lhs == rhs, m_lhs, "==", rhs }; + } + + template + auto operator != ( RhsT const& rhs ) -> BinaryExpr const { + return { compareNotEqual( m_lhs, rhs ), m_lhs, "!=", rhs }; + } + auto operator != ( bool rhs ) -> BinaryExpr const { + return { m_lhs != rhs, m_lhs, "!=", rhs }; + } + + template + auto operator > ( RhsT const& rhs ) -> BinaryExpr const { + return { static_cast(m_lhs > rhs), m_lhs, ">", rhs }; + } + template + auto operator < ( RhsT const& rhs ) -> BinaryExpr const { + return { static_cast(m_lhs < rhs), m_lhs, "<", rhs }; + } + template + auto operator >= ( RhsT const& rhs ) -> BinaryExpr const { + return { static_cast(m_lhs >= rhs), m_lhs, ">=", rhs }; + } + template + auto operator <= ( RhsT const& rhs ) -> BinaryExpr const { + return { static_cast(m_lhs <= rhs), m_lhs, "<=", rhs }; + } + + auto makeUnaryExpr() const -> UnaryExpr { + return UnaryExpr{ m_lhs }; + } + }; + + void handleExpression( ITransientExpression const& expr ); + + template + void handleExpression( ExprLhs const& expr ) { + handleExpression( expr.makeUnaryExpr() ); + } + + struct Decomposer { + template + auto operator <= ( T const& lhs ) -> ExprLhs { + return ExprLhs{ lhs }; + } + + auto operator <=( bool value ) -> ExprLhs { + return ExprLhs{ value }; + } + }; + +} // end namespace Catch + +#ifdef _MSC_VER +#pragma warning(pop) +#endif + +#endif // TWOBLUECUBES_CATCH_DECOMPOSER_H_INCLUDED diff --git a/src/third_party/cppcodec/test/catch/include/internal/catch_default_main.hpp b/src/third_party/cppcodec/test/catch/include/internal/catch_default_main.hpp new file mode 100644 index 0000000000..17ad090a8c --- /dev/null +++ b/src/third_party/cppcodec/test/catch/include/internal/catch_default_main.hpp @@ -0,0 +1,46 @@ +/* + * Created by Phil on 20/05/2011. + * Copyright 2011 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_CATCH_DEFAULT_MAIN_HPP_INCLUDED +#define TWOBLUECUBES_CATCH_DEFAULT_MAIN_HPP_INCLUDED + +#include "catch_session.h" + +#ifndef __OBJC__ + +#if defined(CATCH_CONFIG_WCHAR) && defined(WIN32) && defined(_UNICODE) && !defined(DO_NOT_USE_WMAIN) +// Standard C/C++ Win32 Unicode wmain entry point +extern "C" int wmain (int argc, wchar_t * argv[], wchar_t * []) { +#else +// Standard C/C++ main entry point +int main (int argc, char * argv[]) { +#endif + + return Catch::Session().run( argc, argv ); +} + +#else // __OBJC__ + +// Objective-C entry point +int main (int argc, char * const argv[]) { +#if !CATCH_ARC_ENABLED + NSAutoreleasePool * pool = [[NSAutoreleasePool alloc] init]; +#endif + + Catch::registerTestMethods(); + int result = Catch::Session().run( argc, (char**)argv ); + +#if !CATCH_ARC_ENABLED + [pool drain]; +#endif + + return result; +} + +#endif // __OBJC__ + +#endif // TWOBLUECUBES_CATCH_DEFAULT_MAIN_HPP_INCLUDED diff --git a/src/third_party/cppcodec/test/catch/include/internal/catch_enforce.h b/src/third_party/cppcodec/test/catch/include/internal/catch_enforce.h new file mode 100644 index 0000000000..513dcf1c63 --- /dev/null +++ b/src/third_party/cppcodec/test/catch/include/internal/catch_enforce.h @@ -0,0 +1,24 @@ +/* + * Created by Martin on 01/08/2017. + * + * 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_CATCH_ENFORCE_H_INCLUDED +#define TWOBLUECUBES_CATCH_ENFORCE_H_INCLUDED + +#include "catch_common.h" +#include "catch_stream.h" + +#include + +#define CATCH_PREPARE_EXCEPTION( type, msg ) \ + type( ( Catch::ReusableStringStream() << msg ).str() ) +#define CATCH_INTERNAL_ERROR( msg ) \ + throw CATCH_PREPARE_EXCEPTION( std::logic_error, CATCH_INTERNAL_LINEINFO << ": Internal Catch error: " << msg); +#define CATCH_ERROR( msg ) \ + throw CATCH_PREPARE_EXCEPTION( std::domain_error, msg ) +#define CATCH_ENFORCE( condition, msg ) \ + do{ if( !(condition) ) CATCH_ERROR( msg ); } while(false) + +#endif // TWOBLUECUBES_CATCH_ENFORCE_H_INCLUDED diff --git a/src/third_party/cppcodec/test/catch/include/internal/catch_errno_guard.cpp b/src/third_party/cppcodec/test/catch/include/internal/catch_errno_guard.cpp new file mode 100644 index 0000000000..070583bc7d --- /dev/null +++ b/src/third_party/cppcodec/test/catch/include/internal/catch_errno_guard.cpp @@ -0,0 +1,15 @@ +/* + * Created by Martin on 06/03/2017. + * + * 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) + */ + +#include "catch_errno_guard.h" + +#include + +namespace Catch { + ErrnoGuard::ErrnoGuard():m_oldErrno(errno){} + ErrnoGuard::~ErrnoGuard() { errno = m_oldErrno; } +} diff --git a/src/third_party/cppcodec/test/catch/include/internal/catch_errno_guard.h b/src/third_party/cppcodec/test/catch/include/internal/catch_errno_guard.h new file mode 100644 index 0000000000..b1d1fc1c75 --- /dev/null +++ b/src/third_party/cppcodec/test/catch/include/internal/catch_errno_guard.h @@ -0,0 +1,22 @@ +/* + * Created by Martin on 06/03/2017. + * + * 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_CATCH_ERRNO_GUARD_H_INCLUDED +#define TWOBLUECUBES_CATCH_ERRNO_GUARD_H_INCLUDED + +namespace Catch { + + class ErrnoGuard { + public: + ErrnoGuard(); + ~ErrnoGuard(); + private: + int m_oldErrno; + }; + +} + +#endif // TWOBLUECUBES_CATCH_ERRNO_GUARD_H_INCLUDED diff --git a/src/third_party/cppcodec/test/catch/include/internal/catch_exception_translator_registry.cpp b/src/third_party/cppcodec/test/catch/include/internal/catch_exception_translator_registry.cpp new file mode 100644 index 0000000000..78b9c57334 --- /dev/null +++ b/src/third_party/cppcodec/test/catch/include/internal/catch_exception_translator_registry.cpp @@ -0,0 +1,73 @@ +/* + * Created by Phil on 20/04/2011. + * Copyright 2011 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) + */ + +#include "catch_assertionhandler.h" +#include "catch_exception_translator_registry.h" + +#ifdef __OBJC__ +#import "Foundation/Foundation.h" +#endif + +namespace Catch { + + ExceptionTranslatorRegistry::~ExceptionTranslatorRegistry() { + } + + void ExceptionTranslatorRegistry::registerTranslator( const IExceptionTranslator* translator ) { + m_translators.push_back( std::unique_ptr( translator ) ); + } + + std::string ExceptionTranslatorRegistry::translateActiveException() const { + try { +#ifdef __OBJC__ + // In Objective-C try objective-c exceptions first + @try { + return tryTranslators(); + } + @catch (NSException *exception) { + return Catch::Detail::stringify( [exception description] ); + } +#else + // Compiling a mixed mode project with MSVC means that CLR + // exceptions will be caught in (...) as well. However, these + // do not fill-in std::current_exception and thus lead to crash + // when attempting rethrow. + // /EHa switch also causes structured exceptions to be caught + // here, but they fill-in current_exception properly, so + // at worst the output should be a little weird, instead of + // causing a crash. + if (std::current_exception() == nullptr) { + return "Non C++ exception. Possibly a CLR exception."; + } + return tryTranslators(); +#endif + } + catch( TestFailureException& ) { + std::rethrow_exception(std::current_exception()); + } + catch( std::exception& ex ) { + return ex.what(); + } + catch( std::string& msg ) { + return msg; + } + catch( const char* msg ) { + return msg; + } + catch(...) { + return "Unknown exception"; + } + } + + std::string ExceptionTranslatorRegistry::tryTranslators() const { + if( m_translators.empty() ) + std::rethrow_exception(std::current_exception()); + else + return m_translators[0]->translate( m_translators.begin()+1, m_translators.end() ); + } +} diff --git a/src/third_party/cppcodec/test/catch/include/internal/catch_exception_translator_registry.h b/src/third_party/cppcodec/test/catch/include/internal/catch_exception_translator_registry.h new file mode 100644 index 0000000000..da2f4f12fb --- /dev/null +++ b/src/third_party/cppcodec/test/catch/include/internal/catch_exception_translator_registry.h @@ -0,0 +1,30 @@ +/* + * Created by Phil on 20/04/2011. + * Copyright 2011 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_CATCH_EXCEPTION_TRANSLATOR_REGISTRY_HPP_INCLUDED +#define TWOBLUECUBES_CATCH_EXCEPTION_TRANSLATOR_REGISTRY_HPP_INCLUDED + +#include "catch_interfaces_exception.h" +#include +#include +#include + +namespace Catch { + + class ExceptionTranslatorRegistry : public IExceptionTranslatorRegistry { + public: + ~ExceptionTranslatorRegistry(); + virtual void registerTranslator( const IExceptionTranslator* translator ); + virtual std::string translateActiveException() const override; + std::string tryTranslators() const; + + private: + std::vector> m_translators; + }; +} + +#endif // TWOBLUECUBES_CATCH_EXCEPTION_TRANSLATOR_REGISTRY_HPP_INCLUDED diff --git a/src/third_party/cppcodec/test/catch/include/internal/catch_external_interfaces.h b/src/third_party/cppcodec/test/catch/include/internal/catch_external_interfaces.h new file mode 100644 index 0000000000..d025494549 --- /dev/null +++ b/src/third_party/cppcodec/test/catch/include/internal/catch_external_interfaces.h @@ -0,0 +1,20 @@ +/* + * Created by Martin on 17/08/2017. + * + * 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_CATCH_EXTERNAL_INTERFACES_H_INCLUDED +#define TWOBLUECUBES_CATCH_EXTERNAL_INTERFACES_H_INCLUDED + +#include "../reporters/catch_reporter_bases.hpp" +#include "catch_console_colour.h" +#include "catch_reporter_registrars.hpp" + +// Allow users to base their work off existing reporters +#include "../reporters/catch_reporter_compact.h" +#include "../reporters/catch_reporter_console.h" +#include "../reporters/catch_reporter_junit.h" +#include "../reporters/catch_reporter_xml.h" + +#endif // TWOBLUECUBES_CATCH_EXTERNAL_INTERFACES_H_INCLUDED diff --git a/src/third_party/cppcodec/test/catch/include/internal/catch_fatal_condition.cpp b/src/third_party/cppcodec/test/catch/include/internal/catch_fatal_condition.cpp new file mode 100644 index 0000000000..24e16d3c61 --- /dev/null +++ b/src/third_party/cppcodec/test/catch/include/internal/catch_fatal_condition.cpp @@ -0,0 +1,176 @@ +/* + * Created by Phil on 21/08/2014 + * Copyright 2014 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) + * + */ + +#include "catch_fatal_condition.h" + +#include "catch_context.h" +#include "catch_interfaces_capture.h" + +#if defined(__GNUC__) +# pragma GCC diagnostic push +# pragma GCC diagnostic ignored "-Wmissing-field-initializers" +#endif + +#if defined( CATCH_CONFIG_WINDOWS_SEH ) || defined( CATCH_CONFIG_POSIX_SIGNALS ) + +namespace { + // Report the error condition + void reportFatal( char const * const message ) { + Catch::getCurrentContext().getResultCapture()->handleFatalErrorCondition( message ); + } +} + +#endif // signals/SEH handling + +#if defined( CATCH_CONFIG_WINDOWS_SEH ) + +namespace Catch { + struct SignalDefs { DWORD id; const char* name; }; + + // There is no 1-1 mapping between signals and windows exceptions. + // Windows can easily distinguish between SO and SigSegV, + // but SigInt, SigTerm, etc are handled differently. + static SignalDefs signalDefs[] = { + { EXCEPTION_ILLEGAL_INSTRUCTION, "SIGILL - Illegal instruction signal" }, + { EXCEPTION_STACK_OVERFLOW, "SIGSEGV - Stack overflow" }, + { EXCEPTION_ACCESS_VIOLATION, "SIGSEGV - Segmentation violation signal" }, + { EXCEPTION_INT_DIVIDE_BY_ZERO, "Divide by zero error" }, + }; + + LONG CALLBACK FatalConditionHandler::handleVectoredException(PEXCEPTION_POINTERS ExceptionInfo) { + for (auto const& def : signalDefs) { + if (ExceptionInfo->ExceptionRecord->ExceptionCode == def.id) { + reportFatal(def.name); + } + } + // If its not an exception we care about, pass it along. + // This stops us from eating debugger breaks etc. + return EXCEPTION_CONTINUE_SEARCH; + } + + FatalConditionHandler::FatalConditionHandler() { + isSet = true; + // 32k seems enough for Catch to handle stack overflow, + // but the value was found experimentally, so there is no strong guarantee + guaranteeSize = 32 * 1024; + exceptionHandlerHandle = nullptr; + // Register as first handler in current chain + exceptionHandlerHandle = AddVectoredExceptionHandler(1, handleVectoredException); + // Pass in guarantee size to be filled + SetThreadStackGuarantee(&guaranteeSize); + } + + void FatalConditionHandler::reset() { + if (isSet) { + RemoveVectoredExceptionHandler(exceptionHandlerHandle); + SetThreadStackGuarantee(&guaranteeSize); + exceptionHandlerHandle = nullptr; + isSet = false; + } + } + + FatalConditionHandler::~FatalConditionHandler() { + reset(); + } + +bool FatalConditionHandler::isSet = false; +ULONG FatalConditionHandler::guaranteeSize = 0; +PVOID FatalConditionHandler::exceptionHandlerHandle = nullptr; + + +} // namespace Catch + +#elif defined( CATCH_CONFIG_POSIX_SIGNALS ) + +namespace Catch { + + struct SignalDefs { + int id; + const char* name; + }; + + // 32kb for the alternate stack seems to be sufficient. However, this value + // is experimentally determined, so that's not guaranteed. + constexpr static std::size_t sigStackSize = 32768 >= MINSIGSTKSZ ? 32768 : MINSIGSTKSZ; + + static SignalDefs signalDefs[] = { + { SIGINT, "SIGINT - Terminal interrupt signal" }, + { SIGILL, "SIGILL - Illegal instruction signal" }, + { SIGFPE, "SIGFPE - Floating point error signal" }, + { SIGSEGV, "SIGSEGV - Segmentation violation signal" }, + { SIGTERM, "SIGTERM - Termination request signal" }, + { SIGABRT, "SIGABRT - Abort (abnormal termination) signal" } + }; + + + void FatalConditionHandler::handleSignal( int sig ) { + char const * name = ""; + for (auto const& def : signalDefs) { + if (sig == def.id) { + name = def.name; + break; + } + } + reset(); + reportFatal(name); + raise( sig ); + } + + FatalConditionHandler::FatalConditionHandler() { + isSet = true; + stack_t sigStack; + sigStack.ss_sp = altStackMem; + sigStack.ss_size = sigStackSize; + sigStack.ss_flags = 0; + sigaltstack(&sigStack, &oldSigStack); + struct sigaction sa = { }; + + sa.sa_handler = handleSignal; + sa.sa_flags = SA_ONSTACK; + for (std::size_t i = 0; i < sizeof(signalDefs)/sizeof(SignalDefs); ++i) { + sigaction(signalDefs[i].id, &sa, &oldSigActions[i]); + } + } + + + FatalConditionHandler::~FatalConditionHandler() { + reset(); + } + + void FatalConditionHandler::reset() { + if( isSet ) { + // Set signals back to previous values -- hopefully nobody overwrote them in the meantime + for( std::size_t i = 0; i < sizeof(signalDefs)/sizeof(SignalDefs); ++i ) { + sigaction(signalDefs[i].id, &oldSigActions[i], nullptr); + } + // Return the old stack + sigaltstack(&oldSigStack, nullptr); + isSet = false; + } + } + + bool FatalConditionHandler::isSet = false; + struct sigaction FatalConditionHandler::oldSigActions[sizeof(signalDefs)/sizeof(SignalDefs)] = {}; + stack_t FatalConditionHandler::oldSigStack = {}; + char FatalConditionHandler::altStackMem[sigStackSize] = {}; + + +} // namespace Catch + +#else + +namespace Catch { + void FatalConditionHandler::reset() {} +} + +#endif // signals/SEH handling + +#if defined(__GNUC__) +# pragma GCC diagnostic pop +#endif diff --git a/src/third_party/cppcodec/test/catch/include/internal/catch_fatal_condition.h b/src/third_party/cppcodec/test/catch/include/internal/catch_fatal_condition.h new file mode 100644 index 0000000000..a64fa628f7 --- /dev/null +++ b/src/third_party/cppcodec/test/catch/include/internal/catch_fatal_condition.h @@ -0,0 +1,69 @@ +/* + * Created by Phil on 21/08/2014 + * Copyright 2014 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_CATCH_FATAL_CONDITION_H_INCLUDED +#define TWOBLUECUBES_CATCH_FATAL_CONDITION_H_INCLUDED + +#include "catch_platform.h" +#include "catch_compiler_capabilities.h" +#include "catch_windows_h_proxy.h" + + +#if defined( CATCH_CONFIG_WINDOWS_SEH ) + +namespace Catch { + + struct FatalConditionHandler { + + static LONG CALLBACK handleVectoredException(PEXCEPTION_POINTERS ExceptionInfo); + FatalConditionHandler(); + static void reset(); + ~FatalConditionHandler(); + + private: + static bool isSet; + static ULONG guaranteeSize; + static PVOID exceptionHandlerHandle; + }; + +} // namespace Catch + +#elif defined ( CATCH_CONFIG_POSIX_SIGNALS ) + +#include + +namespace Catch { + + struct FatalConditionHandler { + + static bool isSet; + static struct sigaction oldSigActions[]; + static stack_t oldSigStack; + static char altStackMem[]; + + static void handleSignal( int sig ); + + FatalConditionHandler(); + ~FatalConditionHandler(); + static void reset(); + }; + +} // namespace Catch + + +#else + +namespace Catch { + struct FatalConditionHandler { + void reset(); + }; +} + +#endif + +#endif // TWOBLUECUBES_CATCH_FATAL_CONDITION_H_INCLUDED diff --git a/src/third_party/cppcodec/test/catch/include/internal/catch_impl.hpp b/src/third_party/cppcodec/test/catch/include/internal/catch_impl.hpp new file mode 100644 index 0000000000..0b29a39f07 --- /dev/null +++ b/src/third_party/cppcodec/test/catch/include/internal/catch_impl.hpp @@ -0,0 +1,33 @@ +/* + * Created by Phil on 5/8/2012. + * Copyright 2012 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_CATCH_IMPL_HPP_INCLUDED +#define TWOBLUECUBES_CATCH_IMPL_HPP_INCLUDED + +#ifdef __clang__ +#pragma clang diagnostic push +#pragma clang diagnostic ignored "-Wweak-vtables" +#endif + +// Keep these here for external reporters +#include "catch_test_spec.h" +#include "catch_test_case_tracker.h" + +#include "catch_leak_detector.h" + +// Cpp files will be included in the single-header file here +// ~*~* CATCH_CPP_STITCH_PLACE *~*~ + +namespace Catch { + LeakDetector leakDetector; +} + +#ifdef __clang__ +#pragma clang diagnostic pop +#endif + +#endif // TWOBLUECUBES_CATCH_IMPL_HPP_INCLUDED diff --git a/src/third_party/cppcodec/test/catch/include/internal/catch_interfaces_capture.cpp b/src/third_party/cppcodec/test/catch/include/internal/catch_interfaces_capture.cpp new file mode 100644 index 0000000000..3c090bfe99 --- /dev/null +++ b/src/third_party/cppcodec/test/catch/include/internal/catch_interfaces_capture.cpp @@ -0,0 +1,5 @@ +#include "catch_interfaces_capture.h" + +namespace Catch { + IResultCapture::~IResultCapture() = default; +} diff --git a/src/third_party/cppcodec/test/catch/include/internal/catch_interfaces_capture.h b/src/third_party/cppcodec/test/catch/include/internal/catch_interfaces_capture.h new file mode 100644 index 0000000000..4d091f892e --- /dev/null +++ b/src/third_party/cppcodec/test/catch/include/internal/catch_interfaces_capture.h @@ -0,0 +1,84 @@ +/* + * Created by Phil on 07/01/2011. + * Copyright 2011 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_CATCH_INTERFACES_CAPTURE_H_INCLUDED +#define TWOBLUECUBES_CATCH_INTERFACES_CAPTURE_H_INCLUDED + +#include + +#include "catch_stringref.h" +#include "catch_result_type.h" + +namespace Catch { + + class AssertionResult; + struct AssertionInfo; + struct SectionInfo; + struct SectionEndInfo; + struct MessageInfo; + struct Counts; + struct BenchmarkInfo; + struct BenchmarkStats; + struct AssertionReaction; + + struct ITransientExpression; + + struct IResultCapture { + + virtual ~IResultCapture(); + + virtual bool sectionStarted( SectionInfo const& sectionInfo, + Counts& assertions ) = 0; + virtual void sectionEnded( SectionEndInfo const& endInfo ) = 0; + virtual void sectionEndedEarly( SectionEndInfo const& endInfo ) = 0; + + virtual void benchmarkStarting( BenchmarkInfo const& info ) = 0; + virtual void benchmarkEnded( BenchmarkStats const& stats ) = 0; + + virtual void pushScopedMessage( MessageInfo const& message ) = 0; + virtual void popScopedMessage( MessageInfo const& message ) = 0; + + virtual void handleFatalErrorCondition( StringRef message ) = 0; + + virtual void handleExpr + ( AssertionInfo const& info, + ITransientExpression const& expr, + AssertionReaction& reaction ) = 0; + virtual void handleMessage + ( AssertionInfo const& info, + ResultWas::OfType resultType, + StringRef const& message, + AssertionReaction& reaction ) = 0; + virtual void handleUnexpectedExceptionNotThrown + ( AssertionInfo const& info, + AssertionReaction& reaction ) = 0; + virtual void handleUnexpectedInflightException + ( AssertionInfo const& info, + std::string const& message, + AssertionReaction& reaction ) = 0; + virtual void handleIncomplete + ( AssertionInfo const& info ) = 0; + virtual void handleNonExpr + ( AssertionInfo const &info, + ResultWas::OfType resultType, + AssertionReaction &reaction ) = 0; + + + + virtual bool lastAssertionPassed() = 0; + virtual void assertionPassed() = 0; + + // Deprecated, do not use: + virtual std::string getCurrentTestName() const = 0; + virtual const AssertionResult* getLastResult() const = 0; + virtual void exceptionEarlyReported() = 0; + }; + + IResultCapture& getResultCapture(); +} + +#endif // TWOBLUECUBES_CATCH_INTERFACES_CAPTURE_H_INCLUDED diff --git a/src/third_party/cppcodec/test/catch/include/internal/catch_interfaces_config.cpp b/src/third_party/cppcodec/test/catch/include/internal/catch_interfaces_config.cpp new file mode 100644 index 0000000000..b6f5daa2de --- /dev/null +++ b/src/third_party/cppcodec/test/catch/include/internal/catch_interfaces_config.cpp @@ -0,0 +1,5 @@ +#include "internal/catch_interfaces_config.h" + +namespace Catch { + IConfig::~IConfig() = default; +} diff --git a/src/third_party/cppcodec/test/catch/include/internal/catch_interfaces_config.h b/src/third_party/cppcodec/test/catch/include/internal/catch_interfaces_config.h new file mode 100644 index 0000000000..f509c7ed8f --- /dev/null +++ b/src/third_party/cppcodec/test/catch/include/internal/catch_interfaces_config.h @@ -0,0 +1,83 @@ +/* + * Created by Phil on 05/06/2012. + * Copyright 2012 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_CATCH_INTERFACES_CONFIG_H_INCLUDED +#define TWOBLUECUBES_CATCH_INTERFACES_CONFIG_H_INCLUDED + +#include "catch_common.h" + +#include +#include +#include +#include + +namespace Catch { + + enum class Verbosity { + Quiet = 0, + Normal, + High + }; + + struct WarnAbout { enum What { + Nothing = 0x00, + NoAssertions = 0x01, + NoTests = 0x02 + }; }; + + struct ShowDurations { enum OrNot { + DefaultForReporter, + Always, + Never + }; }; + struct RunTests { enum InWhatOrder { + InDeclarationOrder, + InLexicographicalOrder, + InRandomOrder + }; }; + struct UseColour { enum YesOrNo { + Auto, + Yes, + No + }; }; + struct WaitForKeypress { enum When { + Never, + BeforeStart = 1, + BeforeExit = 2, + BeforeStartAndExit = BeforeStart | BeforeExit + }; }; + + class TestSpec; + + struct IConfig : NonCopyable { + + virtual ~IConfig(); + + virtual bool allowThrows() const = 0; + virtual std::ostream& stream() const = 0; + virtual std::string name() const = 0; + virtual bool includeSuccessfulResults() const = 0; + virtual bool shouldDebugBreak() const = 0; + virtual bool warnAboutMissingAssertions() const = 0; + virtual bool warnAboutNoTests() const = 0; + virtual int abortAfter() const = 0; + virtual bool showInvisibles() const = 0; + virtual ShowDurations::OrNot showDurations() const = 0; + virtual TestSpec const& testSpec() const = 0; + virtual bool hasTestFilters() const = 0; + virtual RunTests::InWhatOrder runOrder() const = 0; + virtual unsigned int rngSeed() const = 0; + virtual int benchmarkResolutionMultiple() const = 0; + virtual UseColour::YesOrNo useColour() const = 0; + virtual std::vector const& getSectionsToRun() const = 0; + virtual Verbosity verbosity() const = 0; + }; + + using IConfigPtr = std::shared_ptr; +} + +#endif // TWOBLUECUBES_CATCH_INTERFACES_CONFIG_H_INCLUDED diff --git a/src/third_party/cppcodec/test/catch/include/internal/catch_interfaces_exception.cpp b/src/third_party/cppcodec/test/catch/include/internal/catch_interfaces_exception.cpp new file mode 100644 index 0000000000..8494a2ccda --- /dev/null +++ b/src/third_party/cppcodec/test/catch/include/internal/catch_interfaces_exception.cpp @@ -0,0 +1,6 @@ +#include "internal/catch_interfaces_exception.h" + +namespace Catch { + IExceptionTranslator::~IExceptionTranslator() = default; + IExceptionTranslatorRegistry::~IExceptionTranslatorRegistry() = default; +} diff --git a/src/third_party/cppcodec/test/catch/include/internal/catch_interfaces_exception.h b/src/third_party/cppcodec/test/catch/include/internal/catch_interfaces_exception.h new file mode 100644 index 0000000000..430701cb80 --- /dev/null +++ b/src/third_party/cppcodec/test/catch/include/internal/catch_interfaces_exception.h @@ -0,0 +1,83 @@ +/* + * Created by Phil on 20/04/2011. + * Copyright 2011 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_CATCH_INTERFACES_EXCEPTION_H_INCLUDED +#define TWOBLUECUBES_CATCH_INTERFACES_EXCEPTION_H_INCLUDED + +#include "catch_interfaces_registry_hub.h" + +#if defined(CATCH_CONFIG_DISABLE) + #define INTERNAL_CATCH_TRANSLATE_EXCEPTION_NO_REG( translatorName, signature) \ + static std::string translatorName( signature ) +#endif + +#include +#include +#include + +namespace Catch { + using exceptionTranslateFunction = std::string(*)(); + + struct IExceptionTranslator; + using ExceptionTranslators = std::vector>; + + struct IExceptionTranslator { + virtual ~IExceptionTranslator(); + virtual std::string translate( ExceptionTranslators::const_iterator it, ExceptionTranslators::const_iterator itEnd ) const = 0; + }; + + struct IExceptionTranslatorRegistry { + virtual ~IExceptionTranslatorRegistry(); + + virtual std::string translateActiveException() const = 0; + }; + + class ExceptionTranslatorRegistrar { + template + class ExceptionTranslator : public IExceptionTranslator { + public: + + ExceptionTranslator( std::string(*translateFunction)( T& ) ) + : m_translateFunction( translateFunction ) + {} + + std::string translate( ExceptionTranslators::const_iterator it, ExceptionTranslators::const_iterator itEnd ) const override { + try { + if( it == itEnd ) + std::rethrow_exception(std::current_exception()); + else + return (*it)->translate( it+1, itEnd ); + } + catch( T& ex ) { + return m_translateFunction( ex ); + } + } + + protected: + std::string(*m_translateFunction)( T& ); + }; + + public: + template + ExceptionTranslatorRegistrar( std::string(*translateFunction)( T& ) ) { + getMutableRegistryHub().registerTranslator + ( new ExceptionTranslator( translateFunction ) ); + } + }; +} + +/////////////////////////////////////////////////////////////////////////////// +#define INTERNAL_CATCH_TRANSLATE_EXCEPTION2( translatorName, signature ) \ + static std::string translatorName( signature ); \ + CATCH_INTERNAL_SUPPRESS_GLOBALS_WARNINGS \ + namespace{ Catch::ExceptionTranslatorRegistrar INTERNAL_CATCH_UNIQUE_NAME( catch_internal_ExceptionRegistrar )( &translatorName ); } \ + CATCH_INTERNAL_UNSUPPRESS_GLOBALS_WARNINGS \ + static std::string translatorName( signature ) + +#define INTERNAL_CATCH_TRANSLATE_EXCEPTION( signature ) INTERNAL_CATCH_TRANSLATE_EXCEPTION2( INTERNAL_CATCH_UNIQUE_NAME( catch_internal_ExceptionTranslator ), signature ) + +#endif // TWOBLUECUBES_CATCH_INTERFACES_EXCEPTION_H_INCLUDED diff --git a/src/third_party/cppcodec/test/catch/include/internal/catch_interfaces_registry_hub.cpp b/src/third_party/cppcodec/test/catch/include/internal/catch_interfaces_registry_hub.cpp new file mode 100644 index 0000000000..bd5b8082c2 --- /dev/null +++ b/src/third_party/cppcodec/test/catch/include/internal/catch_interfaces_registry_hub.cpp @@ -0,0 +1,6 @@ +#include "internal/catch_interfaces_registry_hub.h" + +namespace Catch { + IRegistryHub::~IRegistryHub() = default; + IMutableRegistryHub::~IMutableRegistryHub() = default; +} diff --git a/src/third_party/cppcodec/test/catch/include/internal/catch_interfaces_registry_hub.h b/src/third_party/cppcodec/test/catch/include/internal/catch_interfaces_registry_hub.h new file mode 100644 index 0000000000..1afbbec78d --- /dev/null +++ b/src/third_party/cppcodec/test/catch/include/internal/catch_interfaces_registry_hub.h @@ -0,0 +1,59 @@ +/* + * Created by Phil on 5/8/2012. + * Copyright 2012 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_CATCH_INTERFACES_REGISTRY_HUB_H_INCLUDED +#define TWOBLUECUBES_CATCH_INTERFACES_REGISTRY_HUB_H_INCLUDED + +#include "catch_common.h" + +#include +#include + +namespace Catch { + + class TestCase; + struct ITestCaseRegistry; + struct IExceptionTranslatorRegistry; + struct IExceptionTranslator; + struct IReporterRegistry; + struct IReporterFactory; + struct ITagAliasRegistry; + class StartupExceptionRegistry; + + using IReporterFactoryPtr = std::shared_ptr; + + struct IRegistryHub { + virtual ~IRegistryHub(); + + virtual IReporterRegistry const& getReporterRegistry() const = 0; + virtual ITestCaseRegistry const& getTestCaseRegistry() const = 0; + virtual ITagAliasRegistry const& getTagAliasRegistry() const = 0; + + virtual IExceptionTranslatorRegistry& getExceptionTranslatorRegistry() = 0; + + + virtual StartupExceptionRegistry const& getStartupExceptionRegistry() const = 0; + }; + + struct IMutableRegistryHub { + virtual ~IMutableRegistryHub(); + virtual void registerReporter( std::string const& name, IReporterFactoryPtr const& factory ) = 0; + virtual void registerListener( IReporterFactoryPtr const& factory ) = 0; + virtual void registerTest( TestCase const& testInfo ) = 0; + virtual void registerTranslator( const IExceptionTranslator* translator ) = 0; + virtual void registerTagAlias( std::string const& alias, std::string const& tag, SourceLineInfo const& lineInfo ) = 0; + virtual void registerStartupException() noexcept = 0; + }; + + IRegistryHub& getRegistryHub(); + IMutableRegistryHub& getMutableRegistryHub(); + void cleanUp(); + std::string translateActiveException(); + +} + +#endif // TWOBLUECUBES_CATCH_INTERFACES_REGISTRY_HUB_H_INCLUDED diff --git a/src/third_party/cppcodec/test/catch/include/internal/catch_interfaces_reporter.cpp b/src/third_party/cppcodec/test/catch/include/internal/catch_interfaces_reporter.cpp new file mode 100644 index 0000000000..0c367c5bce --- /dev/null +++ b/src/third_party/cppcodec/test/catch/include/internal/catch_interfaces_reporter.cpp @@ -0,0 +1,114 @@ +/* + * Created by Martin on 19/07/2017. + * + * 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) + */ + +#include "catch_interfaces_reporter.h" +#include "../reporters/catch_reporter_listening.h" + +namespace Catch { + + ReporterConfig::ReporterConfig( IConfigPtr const& _fullConfig ) + : m_stream( &_fullConfig->stream() ), m_fullConfig( _fullConfig ) {} + + ReporterConfig::ReporterConfig( IConfigPtr const& _fullConfig, std::ostream& _stream ) + : m_stream( &_stream ), m_fullConfig( _fullConfig ) {} + + std::ostream& ReporterConfig::stream() const { return *m_stream; } + IConfigPtr ReporterConfig::fullConfig() const { return m_fullConfig; } + + + TestRunInfo::TestRunInfo( std::string const& _name ) : name( _name ) {} + + GroupInfo::GroupInfo( std::string const& _name, + std::size_t _groupIndex, + std::size_t _groupsCount ) + : name( _name ), + groupIndex( _groupIndex ), + groupsCounts( _groupsCount ) + {} + + AssertionStats::AssertionStats( AssertionResult const& _assertionResult, + std::vector const& _infoMessages, + Totals const& _totals ) + : assertionResult( _assertionResult ), + infoMessages( _infoMessages ), + totals( _totals ) + { + assertionResult.m_resultData.lazyExpression.m_transientExpression = _assertionResult.m_resultData.lazyExpression.m_transientExpression; + + if( assertionResult.hasMessage() ) { + // Copy message into messages list. + // !TBD This should have been done earlier, somewhere + MessageBuilder builder( assertionResult.getTestMacroName(), assertionResult.getSourceInfo(), assertionResult.getResultType() ); + builder << assertionResult.getMessage(); + builder.m_info.message = builder.m_stream.str(); + + infoMessages.push_back( builder.m_info ); + } + } + + AssertionStats::~AssertionStats() = default; + + SectionStats::SectionStats( SectionInfo const& _sectionInfo, + Counts const& _assertions, + double _durationInSeconds, + bool _missingAssertions ) + : sectionInfo( _sectionInfo ), + assertions( _assertions ), + durationInSeconds( _durationInSeconds ), + missingAssertions( _missingAssertions ) + {} + + SectionStats::~SectionStats() = default; + + + TestCaseStats::TestCaseStats( TestCaseInfo const& _testInfo, + Totals const& _totals, + std::string const& _stdOut, + std::string const& _stdErr, + bool _aborting ) + : testInfo( _testInfo ), + totals( _totals ), + stdOut( _stdOut ), + stdErr( _stdErr ), + aborting( _aborting ) + {} + + TestCaseStats::~TestCaseStats() = default; + + + TestGroupStats::TestGroupStats( GroupInfo const& _groupInfo, + Totals const& _totals, + bool _aborting ) + : groupInfo( _groupInfo ), + totals( _totals ), + aborting( _aborting ) + {} + + TestGroupStats::TestGroupStats( GroupInfo const& _groupInfo ) + : groupInfo( _groupInfo ), + aborting( false ) + {} + + TestGroupStats::~TestGroupStats() = default; + + TestRunStats::TestRunStats( TestRunInfo const& _runInfo, + Totals const& _totals, + bool _aborting ) + : runInfo( _runInfo ), + totals( _totals ), + aborting( _aborting ) + {} + + TestRunStats::~TestRunStats() = default; + + void IStreamingReporter::fatalErrorEncountered( StringRef ) {} + bool IStreamingReporter::isMulti() const { return false; } + + IReporterFactory::~IReporterFactory() = default; + IReporterRegistry::~IReporterRegistry() = default; + +} // end namespace Catch diff --git a/src/third_party/cppcodec/test/catch/include/internal/catch_interfaces_reporter.h b/src/third_party/cppcodec/test/catch/include/internal/catch_interfaces_reporter.h new file mode 100644 index 0000000000..9d99c9814a --- /dev/null +++ b/src/third_party/cppcodec/test/catch/include/internal/catch_interfaces_reporter.h @@ -0,0 +1,232 @@ +/* + * Created by Phil on 31/12/2010. + * Copyright 2010 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_CATCH_INTERFACES_REPORTER_H_INCLUDED +#define TWOBLUECUBES_CATCH_INTERFACES_REPORTER_H_INCLUDED + +#include "catch_section_info.h" +#include "catch_common.h" +#include "catch_config.hpp" +#include "catch_totals.h" +#include "catch_test_case_info.h" +#include "catch_assertionresult.h" +#include "catch_message.h" +#include "catch_option.hpp" +#include "catch_stringref.h" + + +#include +#include +#include +#include +#include + +namespace Catch { + + struct ReporterConfig { + explicit ReporterConfig( IConfigPtr const& _fullConfig ); + + ReporterConfig( IConfigPtr const& _fullConfig, std::ostream& _stream ); + + std::ostream& stream() const; + IConfigPtr fullConfig() const; + + private: + std::ostream* m_stream; + IConfigPtr m_fullConfig; + }; + + struct ReporterPreferences { + bool shouldRedirectStdOut = false; + bool shouldReportAllAssertions = false; + }; + + template + struct LazyStat : Option { + LazyStat& operator=( T const& _value ) { + Option::operator=( _value ); + used = false; + return *this; + } + void reset() { + Option::reset(); + used = false; + } + bool used = false; + }; + + struct TestRunInfo { + TestRunInfo( std::string const& _name ); + std::string name; + }; + struct GroupInfo { + GroupInfo( std::string const& _name, + std::size_t _groupIndex, + std::size_t _groupsCount ); + + std::string name; + std::size_t groupIndex; + std::size_t groupsCounts; + }; + + struct AssertionStats { + AssertionStats( AssertionResult const& _assertionResult, + std::vector const& _infoMessages, + Totals const& _totals ); + + AssertionStats( AssertionStats const& ) = default; + AssertionStats( AssertionStats && ) = default; + AssertionStats& operator = ( AssertionStats const& ) = default; + AssertionStats& operator = ( AssertionStats && ) = default; + virtual ~AssertionStats(); + + AssertionResult assertionResult; + std::vector infoMessages; + Totals totals; + }; + + struct SectionStats { + SectionStats( SectionInfo const& _sectionInfo, + Counts const& _assertions, + double _durationInSeconds, + bool _missingAssertions ); + SectionStats( SectionStats const& ) = default; + SectionStats( SectionStats && ) = default; + SectionStats& operator = ( SectionStats const& ) = default; + SectionStats& operator = ( SectionStats && ) = default; + virtual ~SectionStats(); + + SectionInfo sectionInfo; + Counts assertions; + double durationInSeconds; + bool missingAssertions; + }; + + struct TestCaseStats { + TestCaseStats( TestCaseInfo const& _testInfo, + Totals const& _totals, + std::string const& _stdOut, + std::string const& _stdErr, + bool _aborting ); + + TestCaseStats( TestCaseStats const& ) = default; + TestCaseStats( TestCaseStats && ) = default; + TestCaseStats& operator = ( TestCaseStats const& ) = default; + TestCaseStats& operator = ( TestCaseStats && ) = default; + virtual ~TestCaseStats(); + + TestCaseInfo testInfo; + Totals totals; + std::string stdOut; + std::string stdErr; + bool aborting; + }; + + struct TestGroupStats { + TestGroupStats( GroupInfo const& _groupInfo, + Totals const& _totals, + bool _aborting ); + TestGroupStats( GroupInfo const& _groupInfo ); + + TestGroupStats( TestGroupStats const& ) = default; + TestGroupStats( TestGroupStats && ) = default; + TestGroupStats& operator = ( TestGroupStats const& ) = default; + TestGroupStats& operator = ( TestGroupStats && ) = default; + virtual ~TestGroupStats(); + + GroupInfo groupInfo; + Totals totals; + bool aborting; + }; + + struct TestRunStats { + TestRunStats( TestRunInfo const& _runInfo, + Totals const& _totals, + bool _aborting ); + + TestRunStats( TestRunStats const& ) = default; + TestRunStats( TestRunStats && ) = default; + TestRunStats& operator = ( TestRunStats const& ) = default; + TestRunStats& operator = ( TestRunStats && ) = default; + virtual ~TestRunStats(); + + TestRunInfo runInfo; + Totals totals; + bool aborting; + }; + + struct BenchmarkInfo { + std::string name; + }; + struct BenchmarkStats { + BenchmarkInfo info; + std::size_t iterations; + uint64_t elapsedTimeInNanoseconds; + }; + + struct IStreamingReporter { + virtual ~IStreamingReporter() = default; + + // Implementing class must also provide the following static methods: + // static std::string getDescription(); + // static std::set getSupportedVerbosities() + + virtual ReporterPreferences getPreferences() const = 0; + + virtual void noMatchingTestCases( std::string const& spec ) = 0; + + virtual void testRunStarting( TestRunInfo const& testRunInfo ) = 0; + virtual void testGroupStarting( GroupInfo const& groupInfo ) = 0; + + virtual void testCaseStarting( TestCaseInfo const& testInfo ) = 0; + virtual void sectionStarting( SectionInfo const& sectionInfo ) = 0; + + // *** experimental *** + virtual void benchmarkStarting( BenchmarkInfo const& ) {} + + virtual void assertionStarting( AssertionInfo const& assertionInfo ) = 0; + + // The return value indicates if the messages buffer should be cleared: + virtual bool assertionEnded( AssertionStats const& assertionStats ) = 0; + + // *** experimental *** + virtual void benchmarkEnded( BenchmarkStats const& ) {} + + virtual void sectionEnded( SectionStats const& sectionStats ) = 0; + virtual void testCaseEnded( TestCaseStats const& testCaseStats ) = 0; + virtual void testGroupEnded( TestGroupStats const& testGroupStats ) = 0; + virtual void testRunEnded( TestRunStats const& testRunStats ) = 0; + + virtual void skipTest( TestCaseInfo const& testInfo ) = 0; + + // Default empty implementation provided + virtual void fatalErrorEncountered( StringRef name ); + + virtual bool isMulti() const; + }; + using IStreamingReporterPtr = std::unique_ptr; + + struct IReporterFactory { + virtual ~IReporterFactory(); + virtual IStreamingReporterPtr create( ReporterConfig const& config ) const = 0; + virtual std::string getDescription() const = 0; + }; + using IReporterFactoryPtr = std::shared_ptr; + + struct IReporterRegistry { + using FactoryMap = std::map; + using Listeners = std::vector; + + virtual ~IReporterRegistry(); + virtual IStreamingReporterPtr create( std::string const& name, IConfigPtr const& config ) const = 0; + virtual FactoryMap const& getFactories() const = 0; + virtual Listeners const& getListeners() const = 0; + }; + +} // end namespace Catch + +#endif // TWOBLUECUBES_CATCH_INTERFACES_REPORTER_H_INCLUDED diff --git a/src/third_party/cppcodec/test/catch/include/internal/catch_interfaces_runner.cpp b/src/third_party/cppcodec/test/catch/include/internal/catch_interfaces_runner.cpp new file mode 100644 index 0000000000..2b052eb80f --- /dev/null +++ b/src/third_party/cppcodec/test/catch/include/internal/catch_interfaces_runner.cpp @@ -0,0 +1,5 @@ +#include "internal/catch_interfaces_runner.h" + +namespace Catch { + IRunner::~IRunner() = default; +} diff --git a/src/third_party/cppcodec/test/catch/include/internal/catch_interfaces_runner.h b/src/third_party/cppcodec/test/catch/include/internal/catch_interfaces_runner.h new file mode 100644 index 0000000000..a0deaf7e66 --- /dev/null +++ b/src/third_party/cppcodec/test/catch/include/internal/catch_interfaces_runner.h @@ -0,0 +1,19 @@ +/* + * Created by Phil on 07/01/2011. + * Copyright 2011 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_CATCH_INTERFACES_RUNNER_H_INCLUDED +#define TWOBLUECUBES_CATCH_INTERFACES_RUNNER_H_INCLUDED + +namespace Catch { + + struct IRunner { + virtual ~IRunner(); + virtual bool aborting() const = 0; + }; +} + +#endif // TWOBLUECUBES_CATCH_INTERFACES_RUNNER_H_INCLUDED diff --git a/src/third_party/cppcodec/test/catch/include/internal/catch_interfaces_tag_alias_registry.h b/src/third_party/cppcodec/test/catch/include/internal/catch_interfaces_tag_alias_registry.h new file mode 100644 index 0000000000..24bc535ce8 --- /dev/null +++ b/src/third_party/cppcodec/test/catch/include/internal/catch_interfaces_tag_alias_registry.h @@ -0,0 +1,28 @@ +/* + * Created by Phil on 27/6/2014. + * Copyright 2014 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_CATCH_INTERFACES_TAG_ALIAS_REGISTRY_H_INCLUDED +#define TWOBLUECUBES_CATCH_INTERFACES_TAG_ALIAS_REGISTRY_H_INCLUDED + +#include + +namespace Catch { + + struct TagAlias; + + struct ITagAliasRegistry { + virtual ~ITagAliasRegistry(); + // Nullptr if not present + virtual TagAlias const* find( std::string const& alias ) const = 0; + virtual std::string expandAliases( std::string const& unexpandedTestSpec ) const = 0; + + static ITagAliasRegistry const& get(); + }; + +} // end namespace Catch + +#endif // TWOBLUECUBES_CATCH_INTERFACES_TAG_ALIAS_REGISTRY_H_INCLUDED diff --git a/src/third_party/cppcodec/test/catch/include/internal/catch_interfaces_testcase.cpp b/src/third_party/cppcodec/test/catch/include/internal/catch_interfaces_testcase.cpp new file mode 100644 index 0000000000..35c3db0820 --- /dev/null +++ b/src/third_party/cppcodec/test/catch/include/internal/catch_interfaces_testcase.cpp @@ -0,0 +1,6 @@ +#include "internal/catch_interfaces_testcase.h" + +namespace Catch { + ITestInvoker::~ITestInvoker() = default; + ITestCaseRegistry::~ITestCaseRegistry() = default; +} diff --git a/src/third_party/cppcodec/test/catch/include/internal/catch_interfaces_testcase.h b/src/third_party/cppcodec/test/catch/include/internal/catch_interfaces_testcase.h new file mode 100644 index 0000000000..9e02b14fbe --- /dev/null +++ b/src/third_party/cppcodec/test/catch/include/internal/catch_interfaces_testcase.h @@ -0,0 +1,40 @@ +/* + * Created by Phil on 07/01/2011. + * Copyright 2011 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_CATCH_INTERFACES_TESTCASE_H_INCLUDED +#define TWOBLUECUBES_CATCH_INTERFACES_TESTCASE_H_INCLUDED + +#include +#include + +namespace Catch { + + class TestSpec; + + struct ITestInvoker { + virtual void invoke () const = 0; + virtual ~ITestInvoker(); + }; + + using ITestCasePtr = std::shared_ptr; + + 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 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 ); + +} + +#endif // TWOBLUECUBES_CATCH_INTERFACES_TESTCASE_H_INCLUDED diff --git a/src/third_party/cppcodec/test/catch/include/internal/catch_leak_detector.cpp b/src/third_party/cppcodec/test/catch/include/internal/catch_leak_detector.cpp new file mode 100644 index 0000000000..36aba6abc8 --- /dev/null +++ b/src/third_party/cppcodec/test/catch/include/internal/catch_leak_detector.cpp @@ -0,0 +1,32 @@ +/* + * Created by Martin on 12/07/2017. + * + * 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) + */ + + #include "catch_leak_detector.h" + + +#ifdef CATCH_CONFIG_WINDOWS_CRTDBG +#include + +namespace Catch { + + LeakDetector::LeakDetector() { + int flag = _CrtSetDbgFlag(_CRTDBG_REPORT_FLAG); + flag |= _CRTDBG_LEAK_CHECK_DF; + flag |= _CRTDBG_ALLOC_MEM_DF; + _CrtSetDbgFlag(flag); + _CrtSetReportMode(_CRT_WARN, _CRTDBG_MODE_FILE | _CRTDBG_MODE_DEBUG); + _CrtSetReportFile(_CRT_WARN, _CRTDBG_FILE_STDERR); + // Change this to leaking allocation's number to break there + _CrtSetBreakAlloc(-1); + } +} + +#else + + Catch::LeakDetector::LeakDetector() {} + +#endif diff --git a/src/third_party/cppcodec/test/catch/include/internal/catch_leak_detector.h b/src/third_party/cppcodec/test/catch/include/internal/catch_leak_detector.h new file mode 100644 index 0000000000..bfb0b4298d --- /dev/null +++ b/src/third_party/cppcodec/test/catch/include/internal/catch_leak_detector.h @@ -0,0 +1,17 @@ +/* + * Created by Martin on 12/07/2017. + * + * 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_CATCH_LEAK_DETECTOR_H_INCLUDED +#define TWOBLUECUBES_CATCH_LEAK_DETECTOR_H_INCLUDED + +namespace Catch { + + struct LeakDetector { + LeakDetector(); + }; + +} +#endif // TWOBLUECUBES_CATCH_LEAK_DETECTOR_H_INCLUDED diff --git a/src/third_party/cppcodec/test/catch/include/internal/catch_list.cpp b/src/third_party/cppcodec/test/catch/include/internal/catch_list.cpp new file mode 100644 index 0000000000..3b0e33f112 --- /dev/null +++ b/src/third_party/cppcodec/test/catch/include/internal/catch_list.cpp @@ -0,0 +1,162 @@ +/* + * Created by Phil on 5/11/2010. + * Copyright 2010 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) + */ + +#include "catch_list.h" + +#include "catch_interfaces_registry_hub.h" +#include "catch_interfaces_reporter.h" +#include "catch_interfaces_testcase.h" + +#include "catch_stream.h" +#include "catch_text.h" + +#include "catch_console_colour.h" +#include "catch_test_spec_parser.h" +#include "catch_tostring.h" +#include "catch_string_manip.h" + +#include +#include +#include + +namespace Catch { + + std::size_t listTests( Config const& config ) { + TestSpec testSpec = config.testSpec(); + if( config.hasTestFilters() ) + Catch::cout() << "Matching test cases:\n"; + else { + Catch::cout() << "All available test cases:\n"; + } + + auto matchedTestCases = filterTests( getAllTestCasesSorted( config ), testSpec, config ); + for( auto const& testCaseInfo : matchedTestCases ) { + Colour::Code colour = testCaseInfo.isHidden() + ? Colour::SecondaryText + : Colour::None; + Colour colourGuard( colour ); + + Catch::cout() << Column( testCaseInfo.name ).initialIndent( 2 ).indent( 4 ) << "\n"; + if( config.verbosity() >= Verbosity::High ) { + Catch::cout() << Column( Catch::Detail::stringify( testCaseInfo.lineInfo ) ).indent(4) << std::endl; + std::string description = testCaseInfo.description; + if( description.empty() ) + description = "(NO DESCRIPTION)"; + Catch::cout() << Column( description ).indent(4) << std::endl; + } + if( !testCaseInfo.tags.empty() ) + Catch::cout() << Column( testCaseInfo.tagsAsString() ).indent( 6 ) << "\n"; + } + + if( !config.hasTestFilters() ) + Catch::cout() << pluralise( matchedTestCases.size(), "test case" ) << '\n' << std::endl; + else + Catch::cout() << pluralise( matchedTestCases.size(), "matching test case" ) << '\n' << std::endl; + return matchedTestCases.size(); + } + + std::size_t listTestsNamesOnly( Config const& config ) { + TestSpec testSpec = config.testSpec(); + std::size_t matchedTests = 0; + std::vector matchedTestCases = filterTests( getAllTestCasesSorted( config ), testSpec, config ); + for( auto const& testCaseInfo : matchedTestCases ) { + matchedTests++; + if( startsWith( testCaseInfo.name, '#' ) ) + Catch::cout() << '"' << testCaseInfo.name << '"'; + else + Catch::cout() << testCaseInfo.name; + if ( config.verbosity() >= Verbosity::High ) + Catch::cout() << "\t@" << testCaseInfo.lineInfo; + Catch::cout() << std::endl; + } + return matchedTests; + } + + void TagInfo::add( std::string const& spelling ) { + ++count; + spellings.insert( spelling ); + } + + std::string TagInfo::all() const { + std::string out; + for( auto const& spelling : spellings ) + out += "[" + spelling + "]"; + return out; + } + + std::size_t listTags( Config const& config ) { + TestSpec testSpec = config.testSpec(); + if( config.hasTestFilters() ) + Catch::cout() << "Tags for matching test cases:\n"; + else { + Catch::cout() << "All available tags:\n"; + } + + std::map tagCounts; + + std::vector matchedTestCases = filterTests( getAllTestCasesSorted( config ), testSpec, config ); + for( auto const& testCase : matchedTestCases ) { + for( auto const& tagName : testCase.getTestCaseInfo().tags ) { + std::string lcaseTagName = toLower( tagName ); + auto countIt = tagCounts.find( lcaseTagName ); + if( countIt == tagCounts.end() ) + countIt = tagCounts.insert( std::make_pair( lcaseTagName, TagInfo() ) ).first; + countIt->second.add( tagName ); + } + } + + for( auto const& tagCount : tagCounts ) { + ReusableStringStream rss; + rss << " " << std::setw(2) << tagCount.second.count << " "; + auto str = rss.str(); + auto wrapper = Column( tagCount.second.all() ) + .initialIndent( 0 ) + .indent( str.size() ) + .width( CATCH_CONFIG_CONSOLE_WIDTH-10 ); + Catch::cout() << str << wrapper << '\n'; + } + Catch::cout() << pluralise( tagCounts.size(), "tag" ) << '\n' << std::endl; + return tagCounts.size(); + } + + std::size_t listReporters( Config const& /*config*/ ) { + Catch::cout() << "Available reporters:\n"; + IReporterRegistry::FactoryMap const& factories = getRegistryHub().getReporterRegistry().getFactories(); + std::size_t maxNameLen = 0; + for( auto const& factoryKvp : factories ) + maxNameLen = (std::max)( maxNameLen, factoryKvp.first.size() ); + + for( auto const& factoryKvp : factories ) { + Catch::cout() + << Column( factoryKvp.first + ":" ) + .indent(2) + .width( 5+maxNameLen ) + + Column( factoryKvp.second->getDescription() ) + .initialIndent(0) + .indent(2) + .width( CATCH_CONFIG_CONSOLE_WIDTH - maxNameLen-8 ) + << "\n"; + } + Catch::cout() << std::endl; + return factories.size(); + } + + Option list( Config const& config ) { + Option listedCount; + if( config.listTests() ) + listedCount = listedCount.valueOr(0) + listTests( config ); + if( config.listTestNamesOnly() ) + listedCount = listedCount.valueOr(0) + listTestsNamesOnly( config ); + if( config.listTags() ) + listedCount = listedCount.valueOr(0) + listTags( config ); + if( config.listReporters() ) + listedCount = listedCount.valueOr(0) + listReporters( config ); + return listedCount; + } + +} // end namespace Catch diff --git a/src/third_party/cppcodec/test/catch/include/internal/catch_list.h b/src/third_party/cppcodec/test/catch/include/internal/catch_list.h new file mode 100644 index 0000000000..4bc96ec517 --- /dev/null +++ b/src/third_party/cppcodec/test/catch/include/internal/catch_list.h @@ -0,0 +1,38 @@ +/* + * Created by Phil on 5/11/2010. + * Copyright 2010 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_CATCH_LIST_H_INCLUDED +#define TWOBLUECUBES_CATCH_LIST_H_INCLUDED + +#include "catch_option.hpp" +#include "catch_config.hpp" + +#include + +namespace Catch { + + std::size_t listTests( Config const& config ); + + std::size_t listTestsNamesOnly( Config const& config ); + + struct TagInfo { + void add( std::string const& spelling ); + std::string all() const; + + std::set spellings; + std::size_t count = 0; + }; + + std::size_t listTags( Config const& config ); + + std::size_t listReporters( Config const& /*config*/ ); + + Option list( Config const& config ); + +} // end namespace Catch + +#endif // TWOBLUECUBES_CATCH_LIST_H_INCLUDED diff --git a/src/third_party/cppcodec/test/catch/include/internal/catch_matchers.cpp b/src/third_party/cppcodec/test/catch/include/internal/catch_matchers.cpp new file mode 100644 index 0000000000..32104a1123 --- /dev/null +++ b/src/third_party/cppcodec/test/catch/include/internal/catch_matchers.cpp @@ -0,0 +1,28 @@ +/* + * Created by Phil Nash on 19/07/2017. + * + * 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) + */ + +#include "catch_matchers.h" + +namespace Catch { +namespace Matchers { + namespace Impl { + + std::string MatcherUntypedBase::toString() const { + if( m_cachedToString.empty() ) + m_cachedToString = describe(); + return m_cachedToString; + } + + MatcherUntypedBase::~MatcherUntypedBase() = default; + + } // namespace Impl +} // namespace Matchers + +using namespace Matchers; +using Matchers::Impl::MatcherBase; + +} // namespace Catch diff --git a/src/third_party/cppcodec/test/catch/include/internal/catch_matchers.h b/src/third_party/cppcodec/test/catch/include/internal/catch_matchers.h new file mode 100644 index 0000000000..f2e3aee9ff --- /dev/null +++ b/src/third_party/cppcodec/test/catch/include/internal/catch_matchers.h @@ -0,0 +1,158 @@ +/* + * Created by Phil Nash on 04/03/2012. + * Copyright (c) 2012 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_CATCH_MATCHERS_HPP_INCLUDED +#define TWOBLUECUBES_CATCH_MATCHERS_HPP_INCLUDED + +#include "catch_common.h" + +#include +#include + +namespace Catch { +namespace Matchers { + namespace Impl { + + template struct MatchAllOf; + template struct MatchAnyOf; + template struct MatchNotOf; + + class MatcherUntypedBase { + public: + MatcherUntypedBase() = default; + MatcherUntypedBase ( MatcherUntypedBase const& ) = default; + MatcherUntypedBase& operator = ( MatcherUntypedBase const& ) = delete; + std::string toString() const; + + protected: + virtual ~MatcherUntypedBase(); + virtual std::string describe() const = 0; + mutable std::string m_cachedToString; + }; + + template + struct MatcherMethod { + virtual bool match( ObjectT const& arg ) const = 0; + }; + template + struct MatcherMethod { + virtual bool match( PtrT* arg ) const = 0; + }; + + template + struct MatcherBase : MatcherUntypedBase, MatcherMethod { + + + MatchAllOf operator && ( MatcherBase const& other ) const; + MatchAnyOf operator || ( MatcherBase const& other ) const; + MatchNotOf operator ! () const; + }; + + template + struct MatchAllOf : MatcherBase { + bool match( ArgT const& arg ) const override { + for( auto matcher : m_matchers ) { + if (!matcher->match(arg)) + return false; + } + return true; + } + std::string describe() const override { + std::string description; + description.reserve( 4 + m_matchers.size()*32 ); + description += "( "; + bool first = true; + for( auto matcher : m_matchers ) { + if( first ) + first = false; + else + description += " and "; + description += matcher->toString(); + } + description += " )"; + return description; + } + + MatchAllOf& operator && ( MatcherBase const& other ) { + m_matchers.push_back( &other ); + return *this; + } + + std::vector const*> m_matchers; + }; + template + struct MatchAnyOf : MatcherBase { + + bool match( ArgT const& arg ) const override { + for( auto matcher : m_matchers ) { + if (matcher->match(arg)) + return true; + } + return false; + } + std::string describe() const override { + std::string description; + description.reserve( 4 + m_matchers.size()*32 ); + description += "( "; + bool first = true; + for( auto matcher : m_matchers ) { + if( first ) + first = false; + else + description += " or "; + description += matcher->toString(); + } + description += " )"; + return description; + } + + MatchAnyOf& operator || ( MatcherBase const& other ) { + m_matchers.push_back( &other ); + return *this; + } + + std::vector const*> m_matchers; + }; + + template + struct MatchNotOf : MatcherBase { + + MatchNotOf( MatcherBase const& underlyingMatcher ) : m_underlyingMatcher( underlyingMatcher ) {} + + bool match( ArgT const& arg ) const override { + return !m_underlyingMatcher.match( arg ); + } + + std::string describe() const override { + return "not " + m_underlyingMatcher.toString(); + } + MatcherBase const& m_underlyingMatcher; + }; + + template + MatchAllOf MatcherBase::operator && ( MatcherBase const& other ) const { + return MatchAllOf() && *this && other; + } + template + MatchAnyOf MatcherBase::operator || ( MatcherBase const& other ) const { + return MatchAnyOf() || *this || other; + } + template + MatchNotOf MatcherBase::operator ! () const { + return MatchNotOf( *this ); + } + + } // namespace Impl + +} // namespace Matchers + +using namespace Matchers; +using Matchers::Impl::MatcherBase; + +} // namespace Catch + +#endif // TWOBLUECUBES_CATCH_MATCHERS_HPP_INCLUDED diff --git a/src/third_party/cppcodec/test/catch/include/internal/catch_matchers_floating.cpp b/src/third_party/cppcodec/test/catch/include/internal/catch_matchers_floating.cpp new file mode 100644 index 0000000000..72728a83d2 --- /dev/null +++ b/src/third_party/cppcodec/test/catch/include/internal/catch_matchers_floating.cpp @@ -0,0 +1,140 @@ +/* + * Created by Martin on 07/11/2017. + * + * 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) + */ + +#include "catch_matchers_floating.h" +#include "catch_to_string.hpp" +#include "catch_tostring.h" + +#include +#include +#include +#include + +namespace Catch { +namespace Matchers { +namespace Floating { +enum class FloatingPointKind : uint8_t { + Float, + Double +}; +} +} +} + +namespace { + +template +struct Converter; + +template <> +struct Converter { + static_assert(sizeof(float) == sizeof(int32_t), "Important ULP matcher assumption violated"); + Converter(float f) { + std::memcpy(&i, &f, sizeof(f)); + } + int32_t i; +}; + +template <> +struct Converter { + static_assert(sizeof(double) == sizeof(int64_t), "Important ULP matcher assumption violated"); + Converter(double d) { + std::memcpy(&i, &d, sizeof(d)); + } + int64_t i; +}; + +template +auto convert(T t) -> Converter { + return Converter(t); +} + +template +bool almostEqualUlps(FP lhs, FP rhs, int maxUlpDiff) { + // Comparison with NaN should always be false. + // This way we can rule it out before getting into the ugly details + if (std::isnan(lhs) || std::isnan(rhs)) { + return false; + } + + auto lc = convert(lhs); + auto rc = convert(rhs); + + if ((lc.i < 0) != (rc.i < 0)) { + // Potentially we can have +0 and -0 + return lhs == rhs; + } + + auto ulpDiff = std::abs(lc.i - rc.i); + return ulpDiff <= maxUlpDiff; +} + +} + + +namespace Catch { +namespace Matchers { +namespace Floating { + WithinAbsMatcher::WithinAbsMatcher(double target, double margin) + :m_target{ target }, m_margin{ margin } { + if (m_margin < 0) { + throw std::domain_error("Allowed margin difference has to be >= 0"); + } + } + + // Performs equivalent check of std::fabs(lhs - rhs) <= margin + // But without the subtraction to allow for INFINITY in comparison + bool WithinAbsMatcher::match(double const& matchee) const { + return (matchee + m_margin >= m_target) && (m_target + m_margin >= matchee); + } + + std::string WithinAbsMatcher::describe() const { + return "is within " + ::Catch::Detail::stringify(m_margin) + " of " + ::Catch::Detail::stringify(m_target); + } + + + WithinUlpsMatcher::WithinUlpsMatcher(double target, int ulps, FloatingPointKind baseType) + :m_target{ target }, m_ulps{ ulps }, m_type{ baseType } { + if (m_ulps < 0) { + throw std::domain_error("Allowed ulp difference has to be >= 0"); + } + } + + bool WithinUlpsMatcher::match(double const& matchee) const { + switch (m_type) { + case FloatingPointKind::Float: + return almostEqualUlps(static_cast(matchee), static_cast(m_target), m_ulps); + case FloatingPointKind::Double: + return almostEqualUlps(matchee, m_target, m_ulps); + default: + throw std::domain_error("Unknown FloatingPointKind value"); + } + } + + std::string WithinUlpsMatcher::describe() const { + return "is within " + Catch::to_string(m_ulps) + " ULPs of " + ::Catch::Detail::stringify(m_target) + ((m_type == FloatingPointKind::Float)? "f" : ""); + } + +}// namespace Floating + + + +Floating::WithinUlpsMatcher WithinULP(double target, int maxUlpDiff) { + return Floating::WithinUlpsMatcher(target, maxUlpDiff, Floating::FloatingPointKind::Double); +} + +Floating::WithinUlpsMatcher WithinULP(float target, int maxUlpDiff) { + return Floating::WithinUlpsMatcher(target, maxUlpDiff, Floating::FloatingPointKind::Float); +} + +Floating::WithinAbsMatcher WithinAbs(double target, double margin) { + return Floating::WithinAbsMatcher(target, margin); +} + +} // namespace Matchers +} // namespace Catch + diff --git a/src/third_party/cppcodec/test/catch/include/internal/catch_matchers_floating.h b/src/third_party/cppcodec/test/catch/include/internal/catch_matchers_floating.h new file mode 100644 index 0000000000..ee077526b6 --- /dev/null +++ b/src/third_party/cppcodec/test/catch/include/internal/catch_matchers_floating.h @@ -0,0 +1,53 @@ +/* + * Created by Martin on 07/11/2017. + * + * 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_CATCH_MATCHERS_FLOATING_H_INCLUDED +#define TWOBLUECUBES_CATCH_MATCHERS_FLOATING_H_INCLUDED + +#include "catch_matchers.h" + +#include +#include + +namespace Catch { +namespace Matchers { + + namespace Floating { + + enum class FloatingPointKind : uint8_t; + + struct WithinAbsMatcher : MatcherBase { + WithinAbsMatcher(double target, double margin); + bool match(double const& matchee) const override; + std::string describe() const override; + private: + double m_target; + double m_margin; + }; + + struct WithinUlpsMatcher : MatcherBase { + WithinUlpsMatcher(double target, int ulps, FloatingPointKind baseType); + bool match(double const& matchee) const override; + std::string describe() const override; + private: + double m_target; + int m_ulps; + FloatingPointKind m_type; + }; + + + } // namespace Floating + + // The following functions create the actual matcher objects. + // This allows the types to be inferred + Floating::WithinUlpsMatcher WithinULP(double target, int maxUlpDiff); + Floating::WithinUlpsMatcher WithinULP(float target, int maxUlpDiff); + Floating::WithinAbsMatcher WithinAbs(double target, double margin); + +} // namespace Matchers +} // namespace Catch + +#endif // TWOBLUECUBES_CATCH_MATCHERS_FLOATING_H_INCLUDED diff --git a/src/third_party/cppcodec/test/catch/include/internal/catch_matchers_generic.cpp b/src/third_party/cppcodec/test/catch/include/internal/catch_matchers_generic.cpp new file mode 100644 index 0000000000..300102e0bd --- /dev/null +++ b/src/third_party/cppcodec/test/catch/include/internal/catch_matchers_generic.cpp @@ -0,0 +1,9 @@ +#include "catch_matchers_generic.hpp" + +std::string Catch::Matchers::Generic::Detail::finalizeDescription(const std::string& desc) { + if (desc.empty()) { + return "matches undescribed predicate"; + } else { + return "matches predicate: \"" + desc + '"'; + } +} diff --git a/src/third_party/cppcodec/test/catch/include/internal/catch_matchers_generic.hpp b/src/third_party/cppcodec/test/catch/include/internal/catch_matchers_generic.hpp new file mode 100644 index 0000000000..7c4f9f1dd2 --- /dev/null +++ b/src/third_party/cppcodec/test/catch/include/internal/catch_matchers_generic.hpp @@ -0,0 +1,58 @@ +/* + * Created by Martin HoÅ™eňovský on 03/04/2017. + * + * 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_CATCH_MATCHERS_GENERIC_HPP_INCLUDED +#define TWOBLUECUBES_CATCH_MATCHERS_GENERIC_HPP_INCLUDED + +#include "catch_common.h" +#include "catch_matchers.h" + +#include +#include + +namespace Catch { +namespace Matchers { +namespace Generic { + +namespace Detail { + std::string finalizeDescription(const std::string& desc); +} + +template +class PredicateMatcher : public MatcherBase { + std::function m_predicate; + std::string m_description; +public: + + PredicateMatcher(std::function const& elem, std::string const& descr) + :m_predicate(std::move(elem)), + m_description(Detail::finalizeDescription(descr)) + {} + + bool match( T const& item ) const override { + return m_predicate(item); + } + + std::string describe() const override { + return m_description; + } +}; + +} // namespace Generic + + // The following functions create the actual matcher objects. + // The user has to explicitly specify type to the function, because + // infering std::function is hard (but possible) and + // requires a lot of TMP. + template + Generic::PredicateMatcher Predicate(std::function const& predicate, std::string const& description = "") { + return Generic::PredicateMatcher(predicate, description); + } + +} // namespace Matchers +} // namespace Catch + +#endif // TWOBLUECUBES_CATCH_MATCHERS_GENERIC_HPP_INCLUDED diff --git a/src/third_party/cppcodec/test/catch/include/internal/catch_matchers_string.cpp b/src/third_party/cppcodec/test/catch/include/internal/catch_matchers_string.cpp new file mode 100644 index 0000000000..1e3e72fdfe --- /dev/null +++ b/src/third_party/cppcodec/test/catch/include/internal/catch_matchers_string.cpp @@ -0,0 +1,118 @@ +/* + * Created by Phil Nash on 08/02/2017. + * Copyright (c) 2017 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) + */ + +#include "catch_matchers_string.h" +#include "catch_string_manip.h" +#include "catch_tostring.h" + +#include + +namespace Catch { +namespace Matchers { + + namespace StdString { + + CasedString::CasedString( std::string const& str, CaseSensitive::Choice caseSensitivity ) + : m_caseSensitivity( caseSensitivity ), + m_str( adjustString( str ) ) + {} + std::string CasedString::adjustString( std::string const& str ) const { + return m_caseSensitivity == CaseSensitive::No + ? toLower( str ) + : str; + } + std::string CasedString::caseSensitivitySuffix() const { + return m_caseSensitivity == CaseSensitive::No + ? " (case insensitive)" + : std::string(); + } + + + StringMatcherBase::StringMatcherBase( std::string const& operation, CasedString const& comparator ) + : m_comparator( comparator ), + m_operation( operation ) { + } + + std::string StringMatcherBase::describe() const { + std::string description; + description.reserve(5 + m_operation.size() + m_comparator.m_str.size() + + m_comparator.caseSensitivitySuffix().size()); + description += m_operation; + description += ": \""; + description += m_comparator.m_str; + description += "\""; + description += m_comparator.caseSensitivitySuffix(); + return description; + } + + EqualsMatcher::EqualsMatcher( CasedString const& comparator ) : StringMatcherBase( "equals", comparator ) {} + + bool EqualsMatcher::match( std::string const& source ) const { + return m_comparator.adjustString( source ) == m_comparator.m_str; + } + + + ContainsMatcher::ContainsMatcher( CasedString const& comparator ) : StringMatcherBase( "contains", comparator ) {} + + bool ContainsMatcher::match( std::string const& source ) const { + return contains( m_comparator.adjustString( source ), m_comparator.m_str ); + } + + + StartsWithMatcher::StartsWithMatcher( CasedString const& comparator ) : StringMatcherBase( "starts with", comparator ) {} + + bool StartsWithMatcher::match( std::string const& source ) const { + return startsWith( m_comparator.adjustString( source ), m_comparator.m_str ); + } + + + EndsWithMatcher::EndsWithMatcher( CasedString const& comparator ) : StringMatcherBase( "ends with", comparator ) {} + + bool EndsWithMatcher::match( std::string const& source ) const { + return endsWith( m_comparator.adjustString( source ), m_comparator.m_str ); + } + + + + RegexMatcher::RegexMatcher(std::string regex, CaseSensitive::Choice caseSensitivity): m_regex(std::move(regex)), m_caseSensitivity(caseSensitivity) {} + + bool RegexMatcher::match(std::string const& matchee) const { + auto flags = std::regex::ECMAScript; // ECMAScript is the default syntax option anyway + if (m_caseSensitivity == CaseSensitive::Choice::No) { + flags |= std::regex::icase; + } + auto reg = std::regex(m_regex, flags); + return std::regex_match(matchee, reg); + } + + std::string RegexMatcher::describe() const { + return "matches " + ::Catch::Detail::stringify(m_regex) + ((m_caseSensitivity == CaseSensitive::Choice::Yes)? " case sensitively" : " case insensitively"); + } + + } // namespace StdString + + + StdString::EqualsMatcher Equals( std::string const& str, CaseSensitive::Choice caseSensitivity ) { + return StdString::EqualsMatcher( StdString::CasedString( str, caseSensitivity) ); + } + StdString::ContainsMatcher Contains( std::string const& str, CaseSensitive::Choice caseSensitivity ) { + return StdString::ContainsMatcher( StdString::CasedString( str, caseSensitivity) ); + } + StdString::EndsWithMatcher EndsWith( std::string const& str, CaseSensitive::Choice caseSensitivity ) { + return StdString::EndsWithMatcher( StdString::CasedString( str, caseSensitivity) ); + } + StdString::StartsWithMatcher StartsWith( std::string const& str, CaseSensitive::Choice caseSensitivity ) { + return StdString::StartsWithMatcher( StdString::CasedString( str, caseSensitivity) ); + } + + StdString::RegexMatcher Matches(std::string const& regex, CaseSensitive::Choice caseSensitivity) { + return StdString::RegexMatcher(regex, caseSensitivity); + } + +} // namespace Matchers +} // namespace Catch diff --git a/src/third_party/cppcodec/test/catch/include/internal/catch_matchers_string.h b/src/third_party/cppcodec/test/catch/include/internal/catch_matchers_string.h new file mode 100644 index 0000000000..fdbc03ce75 --- /dev/null +++ b/src/third_party/cppcodec/test/catch/include/internal/catch_matchers_string.h @@ -0,0 +1,80 @@ +/* + * Created by Phil Nash on 08/02/2017. + * Copyright (c) 2017 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_CATCH_MATCHERS_STRING_H_INCLUDED +#define TWOBLUECUBES_CATCH_MATCHERS_STRING_H_INCLUDED + +#include "catch_matchers.h" + +#include + +namespace Catch { +namespace Matchers { + + namespace StdString { + + struct CasedString + { + CasedString( std::string const& str, CaseSensitive::Choice caseSensitivity ); + std::string adjustString( std::string const& str ) const; + std::string caseSensitivitySuffix() const; + + CaseSensitive::Choice m_caseSensitivity; + std::string m_str; + }; + + struct StringMatcherBase : MatcherBase { + StringMatcherBase( std::string const& operation, CasedString const& comparator ); + std::string describe() const override; + + CasedString m_comparator; + std::string m_operation; + }; + + struct EqualsMatcher : StringMatcherBase { + EqualsMatcher( CasedString const& comparator ); + bool match( std::string const& source ) const override; + }; + struct ContainsMatcher : StringMatcherBase { + ContainsMatcher( CasedString const& comparator ); + bool match( std::string const& source ) const override; + }; + struct StartsWithMatcher : StringMatcherBase { + StartsWithMatcher( CasedString const& comparator ); + bool match( std::string const& source ) const override; + }; + struct EndsWithMatcher : StringMatcherBase { + EndsWithMatcher( CasedString const& comparator ); + bool match( std::string const& source ) const override; + }; + + struct RegexMatcher : MatcherBase { + RegexMatcher( std::string regex, CaseSensitive::Choice caseSensitivity ); + bool match( std::string const& matchee ) const override; + std::string describe() const override; + + private: + std::string m_regex; + CaseSensitive::Choice m_caseSensitivity; + }; + + } // namespace StdString + + + // The following functions create the actual matcher objects. + // This allows the types to be inferred + + StdString::EqualsMatcher Equals( std::string const& str, CaseSensitive::Choice caseSensitivity = CaseSensitive::Yes ); + StdString::ContainsMatcher Contains( std::string const& str, CaseSensitive::Choice caseSensitivity = CaseSensitive::Yes ); + StdString::EndsWithMatcher EndsWith( std::string const& str, CaseSensitive::Choice caseSensitivity = CaseSensitive::Yes ); + StdString::StartsWithMatcher StartsWith( std::string const& str, CaseSensitive::Choice caseSensitivity = CaseSensitive::Yes ); + StdString::RegexMatcher Matches( std::string const& regex, CaseSensitive::Choice caseSensitivity = CaseSensitive::Yes ); + +} // namespace Matchers +} // namespace Catch + +#endif // TWOBLUECUBES_CATCH_MATCHERS_STRING_H_INCLUDED diff --git a/src/third_party/cppcodec/test/catch/include/internal/catch_matchers_vector.h b/src/third_party/cppcodec/test/catch/include/internal/catch_matchers_vector.h new file mode 100644 index 0000000000..833d7dc2c4 --- /dev/null +++ b/src/third_party/cppcodec/test/catch/include/internal/catch_matchers_vector.h @@ -0,0 +1,183 @@ +/* + * Created by Phil Nash on 21/02/2017. + * Copyright (c) 2017 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_CATCH_MATCHERS_VECTOR_H_INCLUDED +#define TWOBLUECUBES_CATCH_MATCHERS_VECTOR_H_INCLUDED + +#include "catch_matchers.h" + +#include + +namespace Catch { +namespace Matchers { + + namespace Vector { + namespace Detail { + template + size_t count(InputIterator first, InputIterator last, T const& item) { + size_t cnt = 0; + for (; first != last; ++first) { + if (*first == item) { + ++cnt; + } + } + return cnt; + } + template + bool contains(InputIterator first, InputIterator last, T const& item) { + for (; first != last; ++first) { + if (*first == item) { + return true; + } + } + return false; + } + } + + template + struct ContainsElementMatcher : MatcherBase> { + + ContainsElementMatcher(T const &comparator) : m_comparator( comparator) {} + + bool match(std::vector const &v) const override { + for (auto const& el : v) { + if (el == m_comparator) { + return true; + } + } + return false; + } + + std::string describe() const override { + return "Contains: " + ::Catch::Detail::stringify( m_comparator ); + } + + T const& m_comparator; + }; + + template + struct ContainsMatcher : MatcherBase> { + + ContainsMatcher(std::vector const &comparator) : m_comparator( comparator ) {} + + bool match(std::vector const &v) const override { + // !TBD: see note in EqualsMatcher + if (m_comparator.size() > v.size()) + return false; + for (auto const& comparator : m_comparator) { + auto present = false; + for (const auto& el : v) { + if (el == comparator) { + present = true; + break; + } + } + if (!present) { + return false; + } + } + return true; + } + std::string describe() const override { + return "Contains: " + ::Catch::Detail::stringify( m_comparator ); + } + + std::vector const& m_comparator; + }; + + template + struct EqualsMatcher : MatcherBase> { + + EqualsMatcher(std::vector const &comparator) : m_comparator( comparator ) {} + + bool match(std::vector const &v) const override { + // !TBD: This currently works if all elements can be compared using != + // - a more general approach would be via a compare template that defaults + // to using !=. but could be specialised for, e.g. std::vector etc + // - then just call that directly + if (m_comparator.size() != v.size()) + return false; + for (std::size_t i = 0; i < v.size(); ++i) + if (m_comparator[i] != v[i]) + return false; + return true; + } + std::string describe() const override { + return "Equals: " + ::Catch::Detail::stringify( m_comparator ); + } + std::vector const& m_comparator; + }; + + template + struct UnorderedEqualsMatcher : MatcherBase> { + UnorderedEqualsMatcher(std::vector const& target) : m_target(target) {} + bool match(std::vector const& vec) const override { + // Note: This is a reimplementation of std::is_permutation, + // because I don't want to include inside the common path + if (m_target.size() != vec.size()) { + return false; + } + auto lfirst = m_target.begin(), llast = m_target.end(); + auto rfirst = vec.begin(), rlast = vec.end(); + // Cut common prefix to optimize checking of permuted parts + while (lfirst != llast && *lfirst != *rfirst) { + ++lfirst; ++rfirst; + } + if (lfirst == llast) { + return true; + } + + for (auto mid = lfirst; mid != llast; ++mid) { + // Skip already counted items + if (Detail::contains(lfirst, mid, *mid)) { + continue; + } + size_t num_vec = Detail::count(rfirst, rlast, *mid); + if (num_vec == 0 || Detail::count(lfirst, llast, *mid) != num_vec) { + return false; + } + } + + return true; + } + + std::string describe() const override { + return "UnorderedEquals: " + ::Catch::Detail::stringify(m_target); + } + private: + std::vector const& m_target; + }; + + } // namespace Vector + + // The following functions create the actual matcher objects. + // This allows the types to be inferred + + template + Vector::ContainsMatcher Contains( std::vector const& comparator ) { + return Vector::ContainsMatcher( comparator ); + } + + template + Vector::ContainsElementMatcher VectorContains( T const& comparator ) { + return Vector::ContainsElementMatcher( comparator ); + } + + template + Vector::EqualsMatcher Equals( std::vector const& comparator ) { + return Vector::EqualsMatcher( comparator ); + } + + template + Vector::UnorderedEqualsMatcher UnorderedEquals(std::vector const& target) { + return Vector::UnorderedEqualsMatcher(target); + } + +} // namespace Matchers +} // namespace Catch + +#endif // TWOBLUECUBES_CATCH_MATCHERS_VECTOR_H_INCLUDED diff --git a/src/third_party/cppcodec/test/catch/include/internal/catch_message.cpp b/src/third_party/cppcodec/test/catch/include/internal/catch_message.cpp new file mode 100644 index 0000000000..8684970a97 --- /dev/null +++ b/src/third_party/cppcodec/test/catch/include/internal/catch_message.cpp @@ -0,0 +1,58 @@ +/* + * Created by Phil Nash on 1/2/2013. + * Copyright 2013 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) + */ + +#include "catch_message.h" +#include "catch_interfaces_capture.h" +#include "catch_uncaught_exceptions.h" + +namespace Catch { + + MessageInfo::MessageInfo( std::string const& _macroName, + SourceLineInfo const& _lineInfo, + ResultWas::OfType _type ) + : macroName( _macroName ), + lineInfo( _lineInfo ), + type( _type ), + sequence( ++globalCount ) + {} + + bool MessageInfo::operator==( MessageInfo const& other ) const { + return sequence == other.sequence; + } + + bool MessageInfo::operator<( MessageInfo const& other ) const { + return sequence < other.sequence; + } + + // This may need protecting if threading support is added + unsigned int MessageInfo::globalCount = 0; + + + //////////////////////////////////////////////////////////////////////////// + + Catch::MessageBuilder::MessageBuilder( std::string const& macroName, + SourceLineInfo const& lineInfo, + ResultWas::OfType type ) + :m_info(macroName, lineInfo, type) {} + + //////////////////////////////////////////////////////////////////////////// + + + ScopedMessage::ScopedMessage( MessageBuilder const& builder ) + : m_info( builder.m_info ) + { + m_info.message = builder.m_stream.str(); + getResultCapture().pushScopedMessage( m_info ); + } + + ScopedMessage::~ScopedMessage() { + if ( !uncaught_exceptions() ){ + getResultCapture().popScopedMessage(m_info); + } + } +} // end namespace Catch diff --git a/src/third_party/cppcodec/test/catch/include/internal/catch_message.h b/src/third_party/cppcodec/test/catch/include/internal/catch_message.h new file mode 100644 index 0000000000..0a512ed578 --- /dev/null +++ b/src/third_party/cppcodec/test/catch/include/internal/catch_message.h @@ -0,0 +1,70 @@ +/* + * Created by Phil Nash on 1/2/2013. + * Copyright 2013 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_CATCH_MESSAGE_H_INCLUDED +#define TWOBLUECUBES_CATCH_MESSAGE_H_INCLUDED + +#include +#include "catch_result_type.h" +#include "catch_common.h" +#include "catch_stream.h" + +namespace Catch { + + struct MessageInfo { + MessageInfo( std::string const& _macroName, + SourceLineInfo const& _lineInfo, + ResultWas::OfType _type ); + + std::string macroName; + std::string message; + SourceLineInfo lineInfo; + ResultWas::OfType type; + unsigned int sequence; + + bool operator == ( MessageInfo const& other ) const; + bool operator < ( MessageInfo const& other ) const; + private: + static unsigned int globalCount; + }; + + struct MessageStream { + + template + MessageStream& operator << ( T const& value ) { + m_stream << value; + return *this; + } + + ReusableStringStream m_stream; + }; + + struct MessageBuilder : MessageStream { + MessageBuilder( std::string const& macroName, + SourceLineInfo const& lineInfo, + ResultWas::OfType type ); + + template + MessageBuilder& operator << ( T const& value ) { + m_stream << value; + return *this; + } + + MessageInfo m_info; + }; + + class ScopedMessage { + public: + explicit ScopedMessage( MessageBuilder const& builder ); + ~ScopedMessage(); + + MessageInfo m_info; + }; + +} // end namespace Catch + +#endif // TWOBLUECUBES_CATCH_MESSAGE_H_INCLUDED diff --git a/src/third_party/cppcodec/test/catch/include/internal/catch_objc.hpp b/src/third_party/cppcodec/test/catch/include/internal/catch_objc.hpp new file mode 100644 index 0000000000..39cbb1fa89 --- /dev/null +++ b/src/third_party/cppcodec/test/catch/include/internal/catch_objc.hpp @@ -0,0 +1,215 @@ +/* + * Created by Phil on 14/11/2010. + * Copyright 2010 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_CATCH_OBJC_HPP_INCLUDED +#define TWOBLUECUBES_CATCH_OBJC_HPP_INCLUDED + +#include "catch_objc_arc.hpp" + +#import + +#include + +// NB. Any general catch headers included here must be included +// in catch.hpp first to make sure they are included by the single +// header for non obj-usage +#include "catch_test_case_info.h" +#include "catch_string_manip.h" +#include "catch_tostring.h" + +/////////////////////////////////////////////////////////////////////////////// +// This protocol is really only here for (self) documenting purposes, since +// all its methods are optional. +@protocol OcFixture + +@optional + +-(void) setUp; +-(void) tearDown; + +@end + +namespace Catch { + + class OcMethod : public ITestInvoker { + + public: + OcMethod( Class cls, SEL sel ) : m_cls( cls ), m_sel( sel ) {} + + virtual void invoke() const { + id obj = [[m_cls alloc] init]; + + performOptionalSelector( obj, @selector(setUp) ); + performOptionalSelector( obj, m_sel ); + performOptionalSelector( obj, @selector(tearDown) ); + + arcSafeRelease( obj ); + } + private: + virtual ~OcMethod() {} + + Class m_cls; + SEL m_sel; + }; + + namespace Detail{ + + + inline std::string getAnnotation( Class cls, + std::string const& annotationName, + std::string const& testCaseName ) { + NSString* selStr = [[NSString alloc] initWithFormat:@"Catch_%s_%s", annotationName.c_str(), testCaseName.c_str()]; + SEL sel = NSSelectorFromString( selStr ); + arcSafeRelease( selStr ); + id value = performOptionalSelector( cls, sel ); + if( value ) + return [(NSString*)value UTF8String]; + return ""; + } + } + + inline std::size_t registerTestMethods() { + std::size_t noTestMethods = 0; + int noClasses = objc_getClassList( nullptr, 0 ); + + Class* classes = (CATCH_UNSAFE_UNRETAINED Class *)malloc( sizeof(Class) * noClasses); + objc_getClassList( classes, noClasses ); + + for( int c = 0; c < noClasses; c++ ) { + Class cls = classes[c]; + { + u_int count; + Method* methods = class_copyMethodList( cls, &count ); + for( u_int m = 0; m < count ; m++ ) { + SEL selector = method_getName(methods[m]); + std::string methodName = sel_getName(selector); + if( startsWith( methodName, "Catch_TestCase_" ) ) { + std::string testCaseName = methodName.substr( 15 ); + std::string name = Detail::getAnnotation( cls, "Name", testCaseName ); + std::string desc = Detail::getAnnotation( cls, "Description", testCaseName ); + const char* className = class_getName( cls ); + + getMutableRegistryHub().registerTest( makeTestCase( new OcMethod( cls, selector ), className, NameAndTags( name.c_str(), desc.c_str() ), SourceLineInfo("",0) ) ); + noTestMethods++; + } + } + free(methods); + } + } + return noTestMethods; + } + +#if !defined(CATCH_CONFIG_DISABLE_MATCHERS) + + namespace Matchers { + namespace Impl { + namespace NSStringMatchers { + + struct StringHolder : MatcherBase{ + StringHolder( NSString* substr ) : m_substr( [substr copy] ){} + StringHolder( StringHolder const& other ) : m_substr( [other.m_substr copy] ){} + StringHolder() { + arcSafeRelease( m_substr ); + } + + bool match( NSString* arg ) const override { + return false; + } + + NSString* CATCH_ARC_STRONG m_substr; + }; + + struct Equals : StringHolder { + Equals( NSString* substr ) : StringHolder( substr ){} + + bool match( NSString* str ) const override { + return (str != nil || m_substr == nil ) && + [str isEqualToString:m_substr]; + } + + std::string describe() const override { + return "equals string: " + Catch::Detail::stringify( m_substr ); + } + }; + + struct Contains : StringHolder { + Contains( NSString* substr ) : StringHolder( substr ){} + + bool match( NSString* str ) const { + return (str != nil || m_substr == nil ) && + [str rangeOfString:m_substr].location != NSNotFound; + } + + std::string describe() const override { + return "contains string: " + Catch::Detail::stringify( m_substr ); + } + }; + + struct StartsWith : StringHolder { + StartsWith( NSString* substr ) : StringHolder( substr ){} + + bool match( NSString* str ) const override { + return (str != nil || m_substr == nil ) && + [str rangeOfString:m_substr].location == 0; + } + + std::string describe() const override { + return "starts with: " + Catch::Detail::stringify( m_substr ); + } + }; + struct EndsWith : StringHolder { + EndsWith( NSString* substr ) : StringHolder( substr ){} + + bool match( NSString* str ) const override { + return (str != nil || m_substr == nil ) && + [str rangeOfString:m_substr].location == [str length] - [m_substr length]; + } + + std::string describe() const override { + return "ends with: " + Catch::Detail::stringify( m_substr ); + } + }; + + } // namespace NSStringMatchers + } // namespace Impl + + inline Impl::NSStringMatchers::Equals + Equals( NSString* substr ){ return Impl::NSStringMatchers::Equals( substr ); } + + inline Impl::NSStringMatchers::Contains + Contains( NSString* substr ){ return Impl::NSStringMatchers::Contains( substr ); } + + inline Impl::NSStringMatchers::StartsWith + StartsWith( NSString* substr ){ return Impl::NSStringMatchers::StartsWith( substr ); } + + inline Impl::NSStringMatchers::EndsWith + EndsWith( NSString* substr ){ return Impl::NSStringMatchers::EndsWith( substr ); } + + } // namespace Matchers + + using namespace Matchers; + +#endif // CATCH_CONFIG_DISABLE_MATCHERS + +} // namespace Catch + +/////////////////////////////////////////////////////////////////////////////// +#define OC_MAKE_UNIQUE_NAME( root, uniqueSuffix ) root##uniqueSuffix +#define OC_TEST_CASE2( name, desc, uniqueSuffix ) \ ++(NSString*) OC_MAKE_UNIQUE_NAME( Catch_Name_test_, uniqueSuffix ) \ +{ \ +return @ name; \ +} \ ++(NSString*) OC_MAKE_UNIQUE_NAME( Catch_Description_test_, uniqueSuffix ) \ +{ \ +return @ desc; \ +} \ +-(void) OC_MAKE_UNIQUE_NAME( Catch_TestCase_test_, uniqueSuffix ) + +#define OC_TEST_CASE( name, desc ) OC_TEST_CASE2( name, desc, __LINE__ ) + +#endif // TWOBLUECUBES_CATCH_OBJC_HPP_INCLUDED diff --git a/src/third_party/cppcodec/test/catch/include/internal/catch_objc_arc.hpp b/src/third_party/cppcodec/test/catch/include/internal/catch_objc_arc.hpp new file mode 100644 index 0000000000..6bcd6b82bc --- /dev/null +++ b/src/third_party/cppcodec/test/catch/include/internal/catch_objc_arc.hpp @@ -0,0 +1,51 @@ +/* + * Created by Phil on 1/08/2012. + * Copyright 2012 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_CATCH_OBJC_ARC_HPP_INCLUDED +#define TWOBLUECUBES_CATCH_OBJC_ARC_HPP_INCLUDED + +#import + +#ifdef __has_feature +#define CATCH_ARC_ENABLED __has_feature(objc_arc) +#else +#define CATCH_ARC_ENABLED 0 +#endif + +void arcSafeRelease( NSObject* obj ); +id performOptionalSelector( id obj, SEL sel ); + +#if !CATCH_ARC_ENABLED +inline void arcSafeRelease( NSObject* obj ) { + [obj release]; +} +inline id performOptionalSelector( id obj, SEL sel ) { + if( [obj respondsToSelector: sel] ) + return [obj performSelector: sel]; + return nil; +} +#define CATCH_UNSAFE_UNRETAINED +#define CATCH_ARC_STRONG +#else +inline void arcSafeRelease( NSObject* ){} +inline id performOptionalSelector( id obj, SEL sel ) { +#ifdef __clang__ +#pragma clang diagnostic push +#pragma clang diagnostic ignored "-Warc-performSelector-leaks" +#endif + if( [obj respondsToSelector: sel] ) + return [obj performSelector: sel]; +#ifdef __clang__ +#pragma clang diagnostic pop +#endif + return nil; +} +#define CATCH_UNSAFE_UNRETAINED __unsafe_unretained +#define CATCH_ARC_STRONG __strong +#endif + +#endif // TWOBLUECUBES_CATCH_OBJC_ARC_HPP_INCLUDED diff --git a/src/third_party/cppcodec/test/catch/include/internal/catch_option.hpp b/src/third_party/cppcodec/test/catch/include/internal/catch_option.hpp new file mode 100644 index 0000000000..d790b24587 --- /dev/null +++ b/src/third_party/cppcodec/test/catch/include/internal/catch_option.hpp @@ -0,0 +1,73 @@ +/* + * Created by Phil on 02/12/2012. + * Copyright 2012 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_CATCH_OPTION_HPP_INCLUDED +#define TWOBLUECUBES_CATCH_OPTION_HPP_INCLUDED + +namespace Catch { + + // An optional type + template + class Option { + public: + Option() : nullableValue( nullptr ) {} + Option( T const& _value ) + : nullableValue( new( storage ) T( _value ) ) + {} + Option( Option const& _other ) + : nullableValue( _other ? new( storage ) T( *_other ) : nullptr ) + {} + + ~Option() { + reset(); + } + + Option& operator= ( Option const& _other ) { + if( &_other != this ) { + reset(); + if( _other ) + nullableValue = new( storage ) T( *_other ); + } + return *this; + } + Option& operator = ( T const& _value ) { + reset(); + nullableValue = new( storage ) T( _value ); + return *this; + } + + void reset() { + if( nullableValue ) + nullableValue->~T(); + nullableValue = nullptr; + } + + T& operator*() { return *nullableValue; } + T const& operator*() const { return *nullableValue; } + T* operator->() { return nullableValue; } + const T* operator->() const { return nullableValue; } + + T valueOr( T const& defaultValue ) const { + return nullableValue ? *nullableValue : defaultValue; + } + + bool some() const { return nullableValue != nullptr; } + bool none() const { return nullableValue == nullptr; } + + bool operator !() const { return nullableValue == nullptr; } + explicit operator bool() const { + return some(); + } + + private: + T *nullableValue; + alignas(alignof(T)) char storage[sizeof(T)]; + }; + +} // end namespace Catch + +#endif // TWOBLUECUBES_CATCH_OPTION_HPP_INCLUDED diff --git a/src/third_party/cppcodec/test/catch/include/internal/catch_output_redirect.cpp b/src/third_party/cppcodec/test/catch/include/internal/catch_output_redirect.cpp new file mode 100644 index 0000000000..5965b7fcac --- /dev/null +++ b/src/third_party/cppcodec/test/catch/include/internal/catch_output_redirect.cpp @@ -0,0 +1,139 @@ +/* + * Created by Martin on 28/04/2018. + * + * 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) + */ + +#include "catch_output_redirect.h" + + + +#include +#include +#include +#include +#include + +#if defined(CATCH_CONFIG_NEW_CAPTURE) + #if defined(_MSC_VER) + #include //_dup and _dup2 + #define dup _dup + #define dup2 _dup2 + #define fileno _fileno + #else + #include // dup and dup2 + #endif +#endif + + +namespace Catch { + + RedirectedStream::RedirectedStream( std::ostream& originalStream, std::ostream& redirectionStream ) + : m_originalStream( originalStream ), + m_redirectionStream( redirectionStream ), + m_prevBuf( m_originalStream.rdbuf() ) + { + m_originalStream.rdbuf( m_redirectionStream.rdbuf() ); + } + + RedirectedStream::~RedirectedStream() { + m_originalStream.rdbuf( m_prevBuf ); + } + + RedirectedStdOut::RedirectedStdOut() : m_cout( Catch::cout(), m_rss.get() ) {} + auto RedirectedStdOut::str() const -> std::string { return m_rss.str(); } + + RedirectedStdErr::RedirectedStdErr() + : m_cerr( Catch::cerr(), m_rss.get() ), + m_clog( Catch::clog(), m_rss.get() ) + {} + auto RedirectedStdErr::str() const -> std::string { return m_rss.str(); } + + +#if defined(CATCH_CONFIG_NEW_CAPTURE) + +#if defined(_MSC_VER) + TempFile::TempFile() { + if (tmpnam_s(m_buffer)) { + throw std::runtime_error("Could not get a temp filename"); + } + if (fopen_s(&m_file, m_buffer, "w")) { + char buffer[100]; + if (strerror_s(buffer, errno)) { + throw std::runtime_error("Could not translate errno to string"); + } + throw std::runtime_error("Could not open the temp file: " + std::string(m_buffer) + buffer); + } + } +#else + TempFile::TempFile() { + m_file = std::tmpfile(); + if (!m_file) { + throw std::runtime_error("Could not create a temp file."); + } + } + +#endif + + TempFile::~TempFile() { + // TBD: What to do about errors here? + std::fclose(m_file); + // We manually create the file on Windows only, on Linux + // it will be autodeleted +#if defined(_MSC_VER) + std::remove(m_buffer); +#endif + } + + + FILE* TempFile::getFile() { + return m_file; + } + + std::string TempFile::getContents() { + std::stringstream sstr; + char buffer[100] = {}; + std::rewind(m_file); + while (std::fgets(buffer, sizeof(buffer), m_file)) { + sstr << buffer; + } + return sstr.str(); + } + + OutputRedirect::OutputRedirect(std::string& stdout_dest, std::string& stderr_dest) : + m_originalStdout(dup(1)), + m_originalStderr(dup(2)), + m_stdoutDest(stdout_dest), + m_stderrDest(stderr_dest) { + dup2(fileno(m_stdoutFile.getFile()), 1); + dup2(fileno(m_stderrFile.getFile()), 2); + } + + OutputRedirect::~OutputRedirect() { + Catch::cout() << std::flush; + fflush(stdout); + // Since we support overriding these streams, we flush cerr + // even though std::cerr is unbuffered + Catch::cerr() << std::flush; + Catch::clog() << std::flush; + fflush(stderr); + + dup2(m_originalStdout, 1); + dup2(m_originalStderr, 2); + + m_stdoutDest += m_stdoutFile.getContents(); + m_stderrDest += m_stderrFile.getContents(); + } + +#endif // CATCH_CONFIG_NEW_CAPTURE + +} // namespace Catch + +#if defined(CATCH_CONFIG_NEW_CAPTURE) + #if defined(_MSC_VER) + #undef dup + #undef dup2 + #undef fileno + #endif +#endif diff --git a/src/third_party/cppcodec/test/catch/include/internal/catch_output_redirect.h b/src/third_party/cppcodec/test/catch/include/internal/catch_output_redirect.h new file mode 100644 index 0000000000..ac04040550 --- /dev/null +++ b/src/third_party/cppcodec/test/catch/include/internal/catch_output_redirect.h @@ -0,0 +1,101 @@ +/* + * Created by Martin on 28/04/2018. + * + * 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_CATCH_OUTPUT_REDIRECT_H +#define TWOBLUECUBES_CATCH_OUTPUT_REDIRECT_H + +#include "catch_platform.h" +#include "catch_stream.h" + +#include +#include +#include + +namespace Catch { + + class RedirectedStream { + std::ostream& m_originalStream; + std::ostream& m_redirectionStream; + std::streambuf* m_prevBuf; + + public: + RedirectedStream( std::ostream& originalStream, std::ostream& redirectionStream ); + ~RedirectedStream(); + }; + + class RedirectedStdOut { + ReusableStringStream m_rss; + RedirectedStream m_cout; + public: + RedirectedStdOut(); + auto str() const -> std::string; + }; + + // StdErr has two constituent streams in C++, std::cerr and std::clog + // This means that we need to redirect 2 streams into 1 to keep proper + // order of writes + class RedirectedStdErr { + ReusableStringStream m_rss; + RedirectedStream m_cerr; + RedirectedStream m_clog; + public: + RedirectedStdErr(); + auto str() const -> std::string; + }; + + +#if defined(CATCH_CONFIG_NEW_CAPTURE) + + // Windows's implementation of std::tmpfile is terrible (it tries + // to create a file inside system folder, thus requiring elevated + // privileges for the binary), so we have to use tmpnam(_s) and + // create the file ourselves there. + class TempFile { + public: + TempFile(TempFile const&) = delete; + TempFile& operator=(TempFile const&) = delete; + TempFile(TempFile&&) = delete; + TempFile& operator=(TempFile&&) = delete; + + TempFile(); + ~TempFile(); + + std::FILE* getFile(); + std::string getContents(); + + private: + std::FILE* m_file = nullptr; + #if defined(_MSC_VER) + char m_buffer[L_tmpnam] = { 0 }; + #endif + }; + + + class OutputRedirect { + public: + OutputRedirect(OutputRedirect const&) = delete; + OutputRedirect& operator=(OutputRedirect const&) = delete; + OutputRedirect(OutputRedirect&&) = delete; + OutputRedirect& operator=(OutputRedirect&&) = delete; + + + OutputRedirect(std::string& stdout_dest, std::string& stderr_dest); + ~OutputRedirect(); + + private: + int m_originalStdout = -1; + int m_originalStderr = -1; + TempFile m_stdoutFile; + TempFile m_stderrFile; + std::string& m_stdoutDest; + std::string& m_stderrDest; + }; + +#endif + +} // end namespace Catch + +#endif // TWOBLUECUBES_CATCH_OUTPUT_REDIRECT_H diff --git a/src/third_party/cppcodec/test/catch/include/internal/catch_platform.h b/src/third_party/cppcodec/test/catch/include/internal/catch_platform.h new file mode 100644 index 0000000000..e14cd332df --- /dev/null +++ b/src/third_party/cppcodec/test/catch/include/internal/catch_platform.h @@ -0,0 +1,27 @@ +/* + * Created by Phil on 16/8/2013. + * Copyright 2013 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_CATCH_PLATFORM_H_INCLUDED +#define TWOBLUECUBES_CATCH_PLATFORM_H_INCLUDED + +#ifdef __APPLE__ +# include +# if TARGET_OS_OSX == 1 +# define CATCH_PLATFORM_MAC +# elif 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 + +#endif // TWOBLUECUBES_CATCH_PLATFORM_H_INCLUDED diff --git a/src/third_party/cppcodec/test/catch/include/internal/catch_random_number_generator.cpp b/src/third_party/cppcodec/test/catch/include/internal/catch_random_number_generator.cpp new file mode 100644 index 0000000000..ec8a5eb96f --- /dev/null +++ b/src/third_party/cppcodec/test/catch/include/internal/catch_random_number_generator.cpp @@ -0,0 +1,29 @@ +/* + * Created by Martin on 30/08/2017. + * + * 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) + */ + +#include "catch_random_number_generator.h" +#include "catch_context.h" +#include "catch_interfaces_config.h" + +namespace Catch { + + std::mt19937& rng() { + static std::mt19937 s_rng; + return s_rng; + } + + void seedRng( IConfig const& config ) { + if( config.rngSeed() != 0 ) { + std::srand( config.rngSeed() ); + rng().seed( config.rngSeed() ); + } + } + + unsigned int rngSeed() { + return getCurrentContext().getConfig()->rngSeed(); + } +} diff --git a/src/third_party/cppcodec/test/catch/include/internal/catch_random_number_generator.h b/src/third_party/cppcodec/test/catch/include/internal/catch_random_number_generator.h new file mode 100644 index 0000000000..817b7841ae --- /dev/null +++ b/src/third_party/cppcodec/test/catch/include/internal/catch_random_number_generator.h @@ -0,0 +1,23 @@ +/* + * Created by Martin on 30/08/2017. + * + * 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_CATCH_RANDOM_NUMBER_GENERATOR_H_INCLUDED +#define TWOBLUECUBES_CATCH_RANDOM_NUMBER_GENERATOR_H_INCLUDED + +#include +#include + +namespace Catch { + + struct IConfig; + + std::mt19937& rng(); + void seedRng( IConfig const& config ); + unsigned int rngSeed(); + +} + +#endif // TWOBLUECUBES_CATCH_RANDOM_NUMBER_GENERATOR_H_INCLUDED diff --git a/src/third_party/cppcodec/test/catch/include/internal/catch_reenable_warnings.h b/src/third_party/cppcodec/test/catch/include/internal/catch_reenable_warnings.h new file mode 100644 index 0000000000..33574e0536 --- /dev/null +++ b/src/third_party/cppcodec/test/catch/include/internal/catch_reenable_warnings.h @@ -0,0 +1,21 @@ +/* + * Copyright 2014 Two Blue Cubes Ltd + * + * 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_CATCH_REENABLE_WARNINGS_H_INCLUDED +#define TWOBLUECUBES_CATCH_REENABLE_WARNINGS_H_INCLUDED + +#ifdef __clang__ +# ifdef __ICC // icpc defines the __clang__ macro +# pragma warning(pop) +# else +# pragma clang diagnostic pop +# endif +#elif defined __GNUC__ +# pragma GCC diagnostic pop +#endif + +#endif // TWOBLUECUBES_CATCH_REENABLE_WARNINGS_H_INCLUDED diff --git a/src/third_party/cppcodec/test/catch/include/internal/catch_registry_hub.cpp b/src/third_party/cppcodec/test/catch/include/internal/catch_registry_hub.cpp new file mode 100644 index 0000000000..d98708c584 --- /dev/null +++ b/src/third_party/cppcodec/test/catch/include/internal/catch_registry_hub.cpp @@ -0,0 +1,97 @@ +/* + * Created by Phil on 5/8/2012. + * Copyright 2012 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) + */ + +#include "catch_interfaces_registry_hub.h" + +#include "catch_context.h" +#include "catch_test_case_registry_impl.h" +#include "catch_reporter_registry.h" +#include "catch_exception_translator_registry.h" +#include "catch_tag_alias_registry.h" +#include "catch_startup_exception_registry.h" + +namespace Catch { + + namespace { + + class RegistryHub : public IRegistryHub, public IMutableRegistryHub, + private NonCopyable { + + public: // IRegistryHub + RegistryHub() = default; + IReporterRegistry const& getReporterRegistry() const override { + return m_reporterRegistry; + } + ITestCaseRegistry const& getTestCaseRegistry() const override { + return m_testCaseRegistry; + } + IExceptionTranslatorRegistry& getExceptionTranslatorRegistry() override { + return m_exceptionTranslatorRegistry; + } + ITagAliasRegistry const& getTagAliasRegistry() const override { + return m_tagAliasRegistry; + } + StartupExceptionRegistry const& getStartupExceptionRegistry() const override { + return m_exceptionRegistry; + } + + public: // IMutableRegistryHub + void registerReporter( std::string const& name, IReporterFactoryPtr const& factory ) override { + m_reporterRegistry.registerReporter( name, factory ); + } + void registerListener( IReporterFactoryPtr const& factory ) override { + m_reporterRegistry.registerListener( factory ); + } + void registerTest( TestCase const& testInfo ) override { + m_testCaseRegistry.registerTest( testInfo ); + } + void registerTranslator( const IExceptionTranslator* translator ) override { + m_exceptionTranslatorRegistry.registerTranslator( translator ); + } + void registerTagAlias( std::string const& alias, std::string const& tag, SourceLineInfo const& lineInfo ) override { + m_tagAliasRegistry.add( alias, tag, lineInfo ); + } + void registerStartupException() noexcept override { + m_exceptionRegistry.add(std::current_exception()); + } + + private: + TestRegistry m_testCaseRegistry; + ReporterRegistry m_reporterRegistry; + ExceptionTranslatorRegistry m_exceptionTranslatorRegistry; + TagAliasRegistry m_tagAliasRegistry; + StartupExceptionRegistry m_exceptionRegistry; + }; + + // Single, global, instance + RegistryHub*& getTheRegistryHub() { + static RegistryHub* theRegistryHub = nullptr; + if( !theRegistryHub ) + theRegistryHub = new RegistryHub(); + return theRegistryHub; + } + } + + IRegistryHub& getRegistryHub() { + return *getTheRegistryHub(); + } + IMutableRegistryHub& getMutableRegistryHub() { + return *getTheRegistryHub(); + } + void cleanUp() { + delete getTheRegistryHub(); + getTheRegistryHub() = nullptr; + cleanUpContext(); + ReusableStringStream::cleanup(); + } + std::string translateActiveException() { + return getRegistryHub().getExceptionTranslatorRegistry().translateActiveException(); + } + + +} // end namespace Catch diff --git a/src/third_party/cppcodec/test/catch/include/internal/catch_reporter_registrars.hpp b/src/third_party/cppcodec/test/catch/include/internal/catch_reporter_registrars.hpp new file mode 100644 index 0000000000..943fba6514 --- /dev/null +++ b/src/third_party/cppcodec/test/catch/include/internal/catch_reporter_registrars.hpp @@ -0,0 +1,76 @@ + +/* + * Created by Phil on 31/12/2010. + * Copyright 2010 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_CATCH_REPORTER_REGISTRARS_HPP_INCLUDED +#define TWOBLUECUBES_CATCH_REPORTER_REGISTRARS_HPP_INCLUDED + +#include "catch_interfaces_registry_hub.h" + +namespace Catch { + + template + class ReporterRegistrar { + + class ReporterFactory : public IReporterFactory { + + virtual IStreamingReporterPtr create( ReporterConfig const& config ) const override { + return std::unique_ptr( new T( config ) ); + } + + virtual std::string getDescription() const override { + return T::getDescription(); + } + }; + + public: + + explicit ReporterRegistrar( std::string const& name ) { + getMutableRegistryHub().registerReporter( name, std::make_shared() ); + } + }; + + template + class ListenerRegistrar { + + class ListenerFactory : public IReporterFactory { + + virtual IStreamingReporterPtr create( ReporterConfig const& config ) const override { + return std::unique_ptr( new T( config ) ); + } + virtual std::string getDescription() const override { + return std::string(); + } + }; + + public: + + ListenerRegistrar() { + getMutableRegistryHub().registerListener( std::make_shared() ); + } + }; +} + +#if !defined(CATCH_CONFIG_DISABLE) + +#define CATCH_REGISTER_REPORTER( name, reporterType ) \ + CATCH_INTERNAL_SUPPRESS_GLOBALS_WARNINGS \ + namespace{ Catch::ReporterRegistrar catch_internal_RegistrarFor##reporterType( name ); } \ + CATCH_INTERNAL_UNSUPPRESS_GLOBALS_WARNINGS + +#define CATCH_REGISTER_LISTENER( listenerType ) \ + CATCH_INTERNAL_SUPPRESS_GLOBALS_WARNINGS \ + namespace{ Catch::ListenerRegistrar catch_internal_RegistrarFor##listenerType; } \ + CATCH_INTERNAL_SUPPRESS_GLOBALS_WARNINGS +#else // CATCH_CONFIG_DISABLE + +#define CATCH_REGISTER_REPORTER(name, reporterType) +#define CATCH_REGISTER_LISTENER(listenerType) + +#endif // CATCH_CONFIG_DISABLE + +#endif // TWOBLUECUBES_CATCH_REPORTER_REGISTRARS_HPP_INCLUDED diff --git a/src/third_party/cppcodec/test/catch/include/internal/catch_reporter_registry.cpp b/src/third_party/cppcodec/test/catch/include/internal/catch_reporter_registry.cpp new file mode 100644 index 0000000000..f017e0590e --- /dev/null +++ b/src/third_party/cppcodec/test/catch/include/internal/catch_reporter_registry.cpp @@ -0,0 +1,34 @@ +/* + * Created by Martin on 31/08/2017. + * + * 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) + */ +#include "catch_reporter_registry.h" + +namespace Catch { + + ReporterRegistry::~ReporterRegistry() = default; + + IStreamingReporterPtr ReporterRegistry::create( std::string const& name, IConfigPtr const& config ) const { + auto it = m_factories.find( name ); + if( it == m_factories.end() ) + return nullptr; + return it->second->create( ReporterConfig( config ) ); + } + + void ReporterRegistry::registerReporter( std::string const& name, IReporterFactoryPtr const& factory ) { + m_factories.emplace(name, factory); + } + void ReporterRegistry::registerListener( IReporterFactoryPtr const& factory ) { + m_listeners.push_back( factory ); + } + + IReporterRegistry::FactoryMap const& ReporterRegistry::getFactories() const { + return m_factories; + } + IReporterRegistry::Listeners const& ReporterRegistry::getListeners() const { + return m_listeners; + } + +} diff --git a/src/third_party/cppcodec/test/catch/include/internal/catch_reporter_registry.h b/src/third_party/cppcodec/test/catch/include/internal/catch_reporter_registry.h new file mode 100644 index 0000000000..916e9247be --- /dev/null +++ b/src/third_party/cppcodec/test/catch/include/internal/catch_reporter_registry.h @@ -0,0 +1,37 @@ +/* + * Created by Phil on 29/10/2010. + * Copyright 2010 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_CATCH_REPORTER_REGISTRY_H_INCLUDED +#define TWOBLUECUBES_CATCH_REPORTER_REGISTRY_H_INCLUDED + +#include "catch_interfaces_reporter.h" + +#include + +namespace Catch { + + class ReporterRegistry : public IReporterRegistry { + + public: + + ~ReporterRegistry() override; + + IStreamingReporterPtr create( std::string const& name, IConfigPtr const& config ) const override; + + void registerReporter( std::string const& name, IReporterFactoryPtr const& factory ); + void registerListener( IReporterFactoryPtr const& factory ); + + FactoryMap const& getFactories() const override; + Listeners const& getListeners() const override; + + private: + FactoryMap m_factories; + Listeners m_listeners; + }; +} + +#endif // TWOBLUECUBES_CATCH_REPORTER_REGISTRY_H_INCLUDED diff --git a/src/third_party/cppcodec/test/catch/include/internal/catch_result_type.cpp b/src/third_party/cppcodec/test/catch/include/internal/catch_result_type.cpp new file mode 100644 index 0000000000..0f62f1b883 --- /dev/null +++ b/src/third_party/cppcodec/test/catch/include/internal/catch_result_type.cpp @@ -0,0 +1,27 @@ +/* + * Created by Phil on 07/01/2011. + * Copyright 2011 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) + */ + +#include "catch_result_type.h" + +namespace Catch { + + bool isOk( ResultWas::OfType resultType ) { + return ( resultType & ResultWas::FailureBit ) == 0; + } + bool isJustInfo( int flags ) { + return flags == ResultWas::Info; + } + + ResultDisposition::Flags operator | ( ResultDisposition::Flags lhs, ResultDisposition::Flags rhs ) { + return static_cast( static_cast( lhs ) | static_cast( rhs ) ); + } + + bool shouldContinueOnFailure( int flags ) { return ( flags & ResultDisposition::ContinueOnFailure ) != 0; } + bool shouldSuppressFailure( int flags ) { return ( flags & ResultDisposition::SuppressFail ) != 0; } + +} // end namespace Catch diff --git a/src/third_party/cppcodec/test/catch/include/internal/catch_result_type.h b/src/third_party/cppcodec/test/catch/include/internal/catch_result_type.h new file mode 100644 index 0000000000..000b4f3d8d --- /dev/null +++ b/src/third_party/cppcodec/test/catch/include/internal/catch_result_type.h @@ -0,0 +1,55 @@ +/* + * Created by Phil on 07/01/2011. + * Copyright 2011 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_CATCH_RESULT_TYPE_H_INCLUDED +#define TWOBLUECUBES_CATCH_RESULT_TYPE_H_INCLUDED + +namespace Catch { + + // ResultWas::OfType enum + struct ResultWas { enum OfType { + Unknown = -1, + Ok = 0, + Info = 1, + Warning = 2, + + FailureBit = 0x10, + + ExpressionFailed = FailureBit | 1, + ExplicitFailure = FailureBit | 2, + + Exception = 0x100 | FailureBit, + + ThrewException = Exception | 1, + DidntThrowException = Exception | 2, + + FatalErrorCondition = 0x200 | FailureBit + + }; }; + + bool isOk( ResultWas::OfType resultType ); + bool isJustInfo( int flags ); + + + // ResultDisposition::Flags enum + struct ResultDisposition { enum Flags { + Normal = 0x01, + + ContinueOnFailure = 0x02, // Failures fail test, but execution continues + FalseTest = 0x04, // Prefix expression with ! + SuppressFail = 0x08 // Failures are reported but do not fail the test + }; }; + + ResultDisposition::Flags operator | ( ResultDisposition::Flags lhs, ResultDisposition::Flags rhs ); + + bool shouldContinueOnFailure( int flags ); + inline bool isFalseTest( int flags ) { return ( flags & ResultDisposition::FalseTest ) != 0; } + bool shouldSuppressFailure( int flags ); + +} // end namespace Catch + +#endif // TWOBLUECUBES_CATCH_RESULT_TYPE_H_INCLUDED diff --git a/src/third_party/cppcodec/test/catch/include/internal/catch_run_context.cpp b/src/third_party/cppcodec/test/catch/include/internal/catch_run_context.cpp new file mode 100644 index 0000000000..ecaa34dba3 --- /dev/null +++ b/src/third_party/cppcodec/test/catch/include/internal/catch_run_context.cpp @@ -0,0 +1,430 @@ +#include "catch_run_context.h" +#include "catch_context.h" +#include "catch_enforce.h" +#include "catch_random_number_generator.h" +#include "catch_stream.h" +#include "catch_output_redirect.h" + +#include +#include +#include + +namespace Catch { + + RunContext::RunContext(IConfigPtr const& _config, IStreamingReporterPtr&& reporter) + : m_runInfo(_config->name()), + m_context(getCurrentMutableContext()), + m_config(_config), + m_reporter(std::move(reporter)), + m_lastAssertionInfo{ StringRef(), SourceLineInfo("",0), StringRef(), ResultDisposition::Normal }, + m_includeSuccessfulResults( m_config->includeSuccessfulResults() || m_reporter->getPreferences().shouldReportAllAssertions ) + { + m_context.setRunner(this); + m_context.setConfig(m_config); + m_context.setResultCapture(this); + m_reporter->testRunStarting(m_runInfo); + } + + RunContext::~RunContext() { + m_reporter->testRunEnded(TestRunStats(m_runInfo, m_totals, aborting())); + } + + void RunContext::testGroupStarting(std::string const& testSpec, std::size_t groupIndex, std::size_t groupsCount) { + m_reporter->testGroupStarting(GroupInfo(testSpec, groupIndex, groupsCount)); + } + + void RunContext::testGroupEnded(std::string const& testSpec, Totals const& totals, std::size_t groupIndex, std::size_t groupsCount) { + m_reporter->testGroupEnded(TestGroupStats(GroupInfo(testSpec, groupIndex, groupsCount), totals, aborting())); + } + + Totals RunContext::runTest(TestCase const& testCase) { + Totals prevTotals = m_totals; + + std::string redirectedCout; + std::string redirectedCerr; + + auto const& testInfo = testCase.getTestCaseInfo(); + + m_reporter->testCaseStarting(testInfo); + + m_activeTestCase = &testCase; + + + ITracker& rootTracker = m_trackerContext.startRun(); + assert(rootTracker.isSectionTracker()); + static_cast(rootTracker).addInitialFilters(m_config->getSectionsToRun()); + do { + m_trackerContext.startCycle(); + m_testCaseTracker = &SectionTracker::acquire(m_trackerContext, TestCaseTracking::NameAndLocation(testInfo.name, testInfo.lineInfo)); + runCurrentTest(redirectedCout, redirectedCerr); + } while (!m_testCaseTracker->isSuccessfullyCompleted() && !aborting()); + + Totals deltaTotals = m_totals.delta(prevTotals); + if (testInfo.expectedToFail() && deltaTotals.testCases.passed > 0) { + deltaTotals.assertions.failed++; + deltaTotals.testCases.passed--; + deltaTotals.testCases.failed++; + } + m_totals.testCases += deltaTotals.testCases; + m_reporter->testCaseEnded(TestCaseStats(testInfo, + deltaTotals, + redirectedCout, + redirectedCerr, + aborting())); + + m_activeTestCase = nullptr; + m_testCaseTracker = nullptr; + + return deltaTotals; + } + + IConfigPtr RunContext::config() const { + return m_config; + } + + IStreamingReporter& RunContext::reporter() const { + return *m_reporter; + } + + void RunContext::assertionEnded(AssertionResult const & result) { + if (result.getResultType() == ResultWas::Ok) { + m_totals.assertions.passed++; + m_lastAssertionPassed = true; + } else if (!result.isOk()) { + m_lastAssertionPassed = false; + if( m_activeTestCase->getTestCaseInfo().okToFail() ) + m_totals.assertions.failedButOk++; + else + m_totals.assertions.failed++; + } + else { + m_lastAssertionPassed = true; + } + + // We have no use for the return value (whether messages should be cleared), because messages were made scoped + // and should be let to clear themselves out. + static_cast(m_reporter->assertionEnded(AssertionStats(result, m_messages, m_totals))); + + // Reset working state + resetAssertionInfo(); + m_lastResult = result; + } + void RunContext::resetAssertionInfo() { + m_lastAssertionInfo.macroName = StringRef(); + m_lastAssertionInfo.capturedExpression = "{Unknown expression after the reported line}"_sr; + } + + bool RunContext::sectionStarted(SectionInfo const & sectionInfo, Counts & assertions) { + ITracker& sectionTracker = SectionTracker::acquire(m_trackerContext, TestCaseTracking::NameAndLocation(sectionInfo.name, sectionInfo.lineInfo)); + if (!sectionTracker.isOpen()) + return false; + m_activeSections.push_back(§ionTracker); + + m_lastAssertionInfo.lineInfo = sectionInfo.lineInfo; + + m_reporter->sectionStarting(sectionInfo); + + assertions = m_totals.assertions; + + return true; + } + + bool RunContext::testForMissingAssertions(Counts& assertions) { + if (assertions.total() != 0) + return false; + if (!m_config->warnAboutMissingAssertions()) + return false; + if (m_trackerContext.currentTracker().hasChildren()) + return false; + m_totals.assertions.failed++; + assertions.failed++; + return true; + } + + void RunContext::sectionEnded(SectionEndInfo const & endInfo) { + Counts assertions = m_totals.assertions - endInfo.prevAssertions; + bool missingAssertions = testForMissingAssertions(assertions); + + if (!m_activeSections.empty()) { + m_activeSections.back()->close(); + m_activeSections.pop_back(); + } + + m_reporter->sectionEnded(SectionStats(endInfo.sectionInfo, assertions, endInfo.durationInSeconds, missingAssertions)); + m_messages.clear(); + } + + void RunContext::sectionEndedEarly(SectionEndInfo const & endInfo) { + if (m_unfinishedSections.empty()) + m_activeSections.back()->fail(); + else + m_activeSections.back()->close(); + m_activeSections.pop_back(); + + m_unfinishedSections.push_back(endInfo); + } + void RunContext::benchmarkStarting( BenchmarkInfo const& info ) { + m_reporter->benchmarkStarting( info ); + } + void RunContext::benchmarkEnded( BenchmarkStats const& stats ) { + m_reporter->benchmarkEnded( stats ); + } + + void RunContext::pushScopedMessage(MessageInfo const & message) { + m_messages.push_back(message); + } + + void RunContext::popScopedMessage(MessageInfo const & message) { + m_messages.erase(std::remove(m_messages.begin(), m_messages.end(), message), m_messages.end()); + } + + std::string RunContext::getCurrentTestName() const { + return m_activeTestCase + ? m_activeTestCase->getTestCaseInfo().name + : std::string(); + } + + const AssertionResult * RunContext::getLastResult() const { + return &(*m_lastResult); + } + + void RunContext::exceptionEarlyReported() { + m_shouldReportUnexpected = false; + } + + void RunContext::handleFatalErrorCondition( StringRef message ) { + // First notify reporter that bad things happened + m_reporter->fatalErrorEncountered(message); + + // Don't rebuild the result -- the stringification itself can cause more fatal errors + // Instead, fake a result data. + AssertionResultData tempResult( ResultWas::FatalErrorCondition, { false } ); + tempResult.message = message; + AssertionResult result(m_lastAssertionInfo, tempResult); + + assertionEnded(result); + + handleUnfinishedSections(); + + // Recreate section for test case (as we will lose the one that was in scope) + auto const& testCaseInfo = m_activeTestCase->getTestCaseInfo(); + SectionInfo testCaseSection(testCaseInfo.lineInfo, testCaseInfo.name); + + Counts assertions; + assertions.failed = 1; + SectionStats testCaseSectionStats(testCaseSection, assertions, 0, false); + m_reporter->sectionEnded(testCaseSectionStats); + + auto const& testInfo = m_activeTestCase->getTestCaseInfo(); + + Totals deltaTotals; + deltaTotals.testCases.failed = 1; + deltaTotals.assertions.failed = 1; + m_reporter->testCaseEnded(TestCaseStats(testInfo, + deltaTotals, + std::string(), + std::string(), + false)); + m_totals.testCases.failed++; + testGroupEnded(std::string(), m_totals, 1, 1); + m_reporter->testRunEnded(TestRunStats(m_runInfo, m_totals, false)); + } + + bool RunContext::lastAssertionPassed() { + return m_lastAssertionPassed; + } + + void RunContext::assertionPassed() { + m_lastAssertionPassed = true; + ++m_totals.assertions.passed; + resetAssertionInfo(); + } + + bool RunContext::aborting() const { + return m_totals.assertions.failed == static_cast(m_config->abortAfter()); + } + + void RunContext::runCurrentTest(std::string & redirectedCout, std::string & redirectedCerr) { + auto const& testCaseInfo = m_activeTestCase->getTestCaseInfo(); + SectionInfo testCaseSection(testCaseInfo.lineInfo, testCaseInfo.name); + m_reporter->sectionStarting(testCaseSection); + Counts prevAssertions = m_totals.assertions; + double duration = 0; + m_shouldReportUnexpected = true; + m_lastAssertionInfo = { "TEST_CASE"_sr, testCaseInfo.lineInfo, StringRef(), ResultDisposition::Normal }; + + seedRng(*m_config); + + Timer timer; + try { + if (m_reporter->getPreferences().shouldRedirectStdOut) { +#if !defined(CATCH_CONFIG_EXPERIMENTAL_REDIRECT) + RedirectedStdOut redirectedStdOut; + RedirectedStdErr redirectedStdErr; + + timer.start(); + invokeActiveTestCase(); + redirectedCout += redirectedStdOut.str(); + redirectedCerr += redirectedStdErr.str(); +#else + OutputRedirect r(redirectedCout, redirectedCerr); + timer.start(); + invokeActiveTestCase(); +#endif + } else { + timer.start(); + invokeActiveTestCase(); + } + duration = timer.getElapsedSeconds(); + } catch (TestFailureException&) { + // This just means the test was aborted due to failure + } catch (...) { + // Under CATCH_CONFIG_FAST_COMPILE, unexpected exceptions under REQUIRE assertions + // are reported without translation at the point of origin. + if( m_shouldReportUnexpected ) { + AssertionReaction dummyReaction; + handleUnexpectedInflightException( m_lastAssertionInfo, translateActiveException(), dummyReaction ); + } + } + Counts assertions = m_totals.assertions - prevAssertions; + bool missingAssertions = testForMissingAssertions(assertions); + + m_testCaseTracker->close(); + handleUnfinishedSections(); + m_messages.clear(); + + SectionStats testCaseSectionStats(testCaseSection, assertions, duration, missingAssertions); + m_reporter->sectionEnded(testCaseSectionStats); + } + + void RunContext::invokeActiveTestCase() { + FatalConditionHandler fatalConditionHandler; // Handle signals + m_activeTestCase->invoke(); + fatalConditionHandler.reset(); + } + + void RunContext::handleUnfinishedSections() { + // If sections ended prematurely due to an exception we stored their + // infos here so we can tear them down outside the unwind process. + for (auto it = m_unfinishedSections.rbegin(), + itEnd = m_unfinishedSections.rend(); + it != itEnd; + ++it) + sectionEnded(*it); + m_unfinishedSections.clear(); + } + + void RunContext::handleExpr( + AssertionInfo const& info, + ITransientExpression const& expr, + AssertionReaction& reaction + ) { + m_reporter->assertionStarting( info ); + + bool negated = isFalseTest( info.resultDisposition ); + bool result = expr.getResult() != negated; + + if( result ) { + if (!m_includeSuccessfulResults) { + assertionPassed(); + } + else { + reportExpr(info, ResultWas::Ok, &expr, negated); + } + } + else { + reportExpr(info, ResultWas::ExpressionFailed, &expr, negated ); + populateReaction( reaction ); + } + } + void RunContext::reportExpr( + AssertionInfo const &info, + ResultWas::OfType resultType, + ITransientExpression const *expr, + bool negated ) { + + m_lastAssertionInfo = info; + AssertionResultData data( resultType, LazyExpression( negated ) ); + + AssertionResult assertionResult{ info, data }; + assertionResult.m_resultData.lazyExpression.m_transientExpression = expr; + + assertionEnded( assertionResult ); + } + + void RunContext::handleMessage( + AssertionInfo const& info, + ResultWas::OfType resultType, + StringRef const& message, + AssertionReaction& reaction + ) { + m_reporter->assertionStarting( info ); + + m_lastAssertionInfo = info; + + AssertionResultData data( resultType, LazyExpression( false ) ); + data.message = message; + AssertionResult assertionResult{ m_lastAssertionInfo, data }; + assertionEnded( assertionResult ); + if( !assertionResult.isOk() ) + populateReaction( reaction ); + } + void RunContext::handleUnexpectedExceptionNotThrown( + AssertionInfo const& info, + AssertionReaction& reaction + ) { + handleNonExpr(info, Catch::ResultWas::DidntThrowException, reaction); + } + + void RunContext::handleUnexpectedInflightException( + AssertionInfo const& info, + std::string const& message, + AssertionReaction& reaction + ) { + m_lastAssertionInfo = info; + + AssertionResultData data( ResultWas::ThrewException, LazyExpression( false ) ); + data.message = message; + AssertionResult assertionResult{ info, data }; + assertionEnded( assertionResult ); + populateReaction( reaction ); + } + + void RunContext::populateReaction( AssertionReaction& reaction ) { + reaction.shouldDebugBreak = m_config->shouldDebugBreak(); + reaction.shouldThrow = aborting() || (m_lastAssertionInfo.resultDisposition & ResultDisposition::Normal); + } + + void RunContext::handleIncomplete( + AssertionInfo const& info + ) { + m_lastAssertionInfo = info; + + AssertionResultData data( ResultWas::ThrewException, LazyExpression( false ) ); + data.message = "Exception translation was disabled by CATCH_CONFIG_FAST_COMPILE"; + AssertionResult assertionResult{ info, data }; + assertionEnded( assertionResult ); + } + void RunContext::handleNonExpr( + AssertionInfo const &info, + ResultWas::OfType resultType, + AssertionReaction &reaction + ) { + m_lastAssertionInfo = info; + + AssertionResultData data( resultType, LazyExpression( false ) ); + AssertionResult assertionResult{ info, data }; + assertionEnded( assertionResult ); + + if( !assertionResult.isOk() ) + populateReaction( reaction ); + } + + + IResultCapture& getResultCapture() { + if (auto* capture = getCurrentContext().getResultCapture()) + return *capture; + else + CATCH_INTERNAL_ERROR("No result capture instance"); + } +} diff --git a/src/third_party/cppcodec/test/catch/include/internal/catch_run_context.h b/src/third_party/cppcodec/test/catch/include/internal/catch_run_context.h new file mode 100644 index 0000000000..6b8941739f --- /dev/null +++ b/src/third_party/cppcodec/test/catch/include/internal/catch_run_context.h @@ -0,0 +1,146 @@ + /* + * Created by Phil on 22/10/2010. + * Copyright 2010 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_CATCH_RUNNER_IMPL_HPP_INCLUDED +#define TWOBLUECUBES_CATCH_RUNNER_IMPL_HPP_INCLUDED + +#include "catch_interfaces_runner.h" +#include "catch_interfaces_reporter.h" +#include "catch_interfaces_exception.h" +#include "catch_config.hpp" +#include "catch_test_registry.h" +#include "catch_test_case_info.h" +#include "catch_capture.hpp" +#include "catch_totals.h" +#include "catch_test_spec.h" +#include "catch_test_case_tracker.h" +#include "catch_timer.h" +#include "catch_assertionhandler.h" +#include "catch_fatal_condition.h" + +#include + +namespace Catch { + + struct IMutableContext; + + /////////////////////////////////////////////////////////////////////////// + + class RunContext : public IResultCapture, public IRunner { + + public: + RunContext( RunContext const& ) = delete; + RunContext& operator =( RunContext const& ) = delete; + + explicit RunContext( IConfigPtr const& _config, IStreamingReporterPtr&& reporter ); + + ~RunContext() override; + + void testGroupStarting( std::string const& testSpec, std::size_t groupIndex, std::size_t groupsCount ); + void testGroupEnded( std::string const& testSpec, Totals const& totals, std::size_t groupIndex, std::size_t groupsCount ); + + Totals runTest(TestCase const& testCase); + + IConfigPtr config() const; + IStreamingReporter& reporter() const; + + public: // IResultCapture + + // Assertion handlers + void handleExpr + ( AssertionInfo const& info, + ITransientExpression const& expr, + AssertionReaction& reaction ) override; + void handleMessage + ( AssertionInfo const& info, + ResultWas::OfType resultType, + StringRef const& message, + AssertionReaction& reaction ) override; + void handleUnexpectedExceptionNotThrown + ( AssertionInfo const& info, + AssertionReaction& reaction ) override; + void handleUnexpectedInflightException + ( AssertionInfo const& info, + std::string const& message, + AssertionReaction& reaction ) override; + void handleIncomplete + ( AssertionInfo const& info ) override; + void handleNonExpr + ( AssertionInfo const &info, + ResultWas::OfType resultType, + AssertionReaction &reaction ) override; + + bool sectionStarted( SectionInfo const& sectionInfo, Counts& assertions ) override; + + void sectionEnded( SectionEndInfo const& endInfo ) override; + void sectionEndedEarly( SectionEndInfo const& endInfo ) override; + + void benchmarkStarting( BenchmarkInfo const& info ) override; + void benchmarkEnded( BenchmarkStats const& stats ) override; + + void pushScopedMessage( MessageInfo const& message ) override; + void popScopedMessage( MessageInfo const& message ) override; + + std::string getCurrentTestName() const override; + + const AssertionResult* getLastResult() const override; + + void exceptionEarlyReported() override; + + void handleFatalErrorCondition( StringRef message ) override; + + bool lastAssertionPassed() override; + + void assertionPassed() override; + + public: + // !TBD We need to do this another way! + bool aborting() const final; + + private: + + void runCurrentTest( std::string& redirectedCout, std::string& redirectedCerr ); + void invokeActiveTestCase(); + + void resetAssertionInfo(); + bool testForMissingAssertions( Counts& assertions ); + + void assertionEnded( AssertionResult const& result ); + void reportExpr + ( AssertionInfo const &info, + ResultWas::OfType resultType, + ITransientExpression const *expr, + bool negated ); + + void populateReaction( AssertionReaction& reaction ); + + private: + + void handleUnfinishedSections(); + + TestRunInfo m_runInfo; + IMutableContext& m_context; + TestCase const* m_activeTestCase = nullptr; + ITracker* m_testCaseTracker; + Option m_lastResult; + + IConfigPtr m_config; + Totals m_totals; + IStreamingReporterPtr m_reporter; + std::vector m_messages; + AssertionInfo m_lastAssertionInfo; + std::vector m_unfinishedSections; + std::vector m_activeSections; + TrackerContext m_trackerContext; + bool m_lastAssertionPassed = false; + bool m_shouldReportUnexpected = true; + bool m_includeSuccessfulResults; + }; + +} // end namespace Catch + +#endif // TWOBLUECUBES_CATCH_RUNNER_IMPL_HPP_INCLUDED diff --git a/src/third_party/cppcodec/test/catch/include/internal/catch_section.cpp b/src/third_party/cppcodec/test/catch/include/internal/catch_section.cpp new file mode 100644 index 0000000000..0646d36fe0 --- /dev/null +++ b/src/third_party/cppcodec/test/catch/include/internal/catch_section.cpp @@ -0,0 +1,38 @@ +/* + * Created by Phil on 03/11/2010. + * Copyright 2010 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) + */ + +#include "catch_section.h" +#include "catch_capture.hpp" +#include "catch_uncaught_exceptions.h" + +namespace Catch { + + Section::Section( SectionInfo const& info ) + : m_info( info ), + m_sectionIncluded( getResultCapture().sectionStarted( m_info, m_assertions ) ) + { + m_timer.start(); + } + + Section::~Section() { + if( m_sectionIncluded ) { + SectionEndInfo endInfo{ m_info, m_assertions, m_timer.getElapsedSeconds() }; + if( uncaught_exceptions() ) + getResultCapture().sectionEndedEarly( endInfo ); + else + getResultCapture().sectionEnded( endInfo ); + } + } + + // This indicates whether the section should be executed or not + Section::operator bool() const { + return m_sectionIncluded; + } + + +} // end namespace Catch diff --git a/src/third_party/cppcodec/test/catch/include/internal/catch_section.h b/src/third_party/cppcodec/test/catch/include/internal/catch_section.h new file mode 100644 index 0000000000..00c254b671 --- /dev/null +++ b/src/third_party/cppcodec/test/catch/include/internal/catch_section.h @@ -0,0 +1,49 @@ +/* + * Created by Phil on 03/12/2013. + * Copyright 2013 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_CATCH_SECTION_H_INCLUDED +#define TWOBLUECUBES_CATCH_SECTION_H_INCLUDED + +#include "catch_compiler_capabilities.h" +#include "catch_section_info.h" +#include "catch_totals.h" +#include "catch_timer.h" + +#include + +namespace Catch { + + class Section : NonCopyable { + public: + Section( SectionInfo const& info ); + ~Section(); + + // This indicates whether the section should be executed or not + explicit operator bool() const; + + private: + SectionInfo m_info; + + std::string m_name; + Counts m_assertions; + bool m_sectionIncluded; + Timer m_timer; + }; + +} // end namespace Catch + +#define INTERNAL_CATCH_SECTION( ... ) \ + CATCH_INTERNAL_SUPPRESS_UNUSED_WARNINGS \ + if( Catch::Section const& INTERNAL_CATCH_UNIQUE_NAME( catch_internal_Section ) = Catch::SectionInfo( CATCH_INTERNAL_LINEINFO, __VA_ARGS__ ) ) \ + CATCH_INTERNAL_UNSUPPRESS_UNUSED_WARNINGS + +#define INTERNAL_CATCH_DYNAMIC_SECTION( ... ) \ + CATCH_INTERNAL_SUPPRESS_UNUSED_WARNINGS \ + if( Catch::Section const& INTERNAL_CATCH_UNIQUE_NAME( catch_internal_Section ) = Catch::SectionInfo( CATCH_INTERNAL_LINEINFO, (Catch::ReusableStringStream() << __VA_ARGS__).str() ) ) \ + CATCH_INTERNAL_UNSUPPRESS_UNUSED_WARNINGS + +#endif // TWOBLUECUBES_CATCH_SECTION_H_INCLUDED diff --git a/src/third_party/cppcodec/test/catch/include/internal/catch_section_info.cpp b/src/third_party/cppcodec/test/catch/include/internal/catch_section_info.cpp new file mode 100644 index 0000000000..89714e35e8 --- /dev/null +++ b/src/third_party/cppcodec/test/catch/include/internal/catch_section_info.cpp @@ -0,0 +1,19 @@ +/* + * Created by Martin on 01/08/2017. + * + * 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) + */ + +#include "catch_section_info.h" + +namespace Catch { + + SectionInfo::SectionInfo + ( SourceLineInfo const& _lineInfo, + std::string const& _name ) + : name( _name ), + lineInfo( _lineInfo ) + {} + +} // end namespace Catch diff --git a/src/third_party/cppcodec/test/catch/include/internal/catch_section_info.h b/src/third_party/cppcodec/test/catch/include/internal/catch_section_info.h new file mode 100644 index 0000000000..9cf792e8c8 --- /dev/null +++ b/src/third_party/cppcodec/test/catch/include/internal/catch_section_info.h @@ -0,0 +1,42 @@ +/* + * Created by Phil on 03/11/2010. + * Copyright 2010 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_CATCH_SECTION_INFO_H_INCLUDED +#define TWOBLUECUBES_CATCH_SECTION_INFO_H_INCLUDED + +#include "catch_common.h" +#include "catch_totals.h" + +#include + +namespace Catch { + + struct SectionInfo { + SectionInfo + ( SourceLineInfo const& _lineInfo, + std::string const& _name ); + + // Deprecated + SectionInfo + ( SourceLineInfo const& _lineInfo, + std::string const& _name, + std::string const& ) : SectionInfo( _lineInfo, _name ) {} + + std::string name; + std::string description; // !Deprecated: this will always be empty + SourceLineInfo lineInfo; + }; + + struct SectionEndInfo { + SectionInfo sectionInfo; + Counts prevAssertions; + double durationInSeconds; + }; + +} // end namespace Catch + +#endif // TWOBLUECUBES_CATCH_SECTION_INFO_H_INCLUDED diff --git a/src/third_party/cppcodec/test/catch/include/internal/catch_session.cpp b/src/third_party/cppcodec/test/catch/include/internal/catch_session.cpp new file mode 100644 index 0000000000..2c5fe08e40 --- /dev/null +++ b/src/third_party/cppcodec/test/catch/include/internal/catch_session.cpp @@ -0,0 +1,282 @@ +/* + * Created by Martin on 31/08/2017. + * + * 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) + */ + +#include "catch_session.h" +#include "catch_commandline.h" +#include "catch_console_colour.h" +#include "catch_enforce.h" +#include "catch_list.h" +#include "catch_run_context.h" +#include "catch_stream.h" +#include "catch_test_spec.h" +#include "catch_version.h" +#include "catch_interfaces_reporter.h" +#include "catch_random_number_generator.h" +#include "catch_startup_exception_registry.h" +#include "catch_text.h" +#include "catch_stream.h" +#include "catch_windows_h_proxy.h" +#include "../reporters/catch_reporter_listening.h" + +#include +#include + +namespace Catch { + + namespace { + const int MaxExitCode = 255; + + IStreamingReporterPtr createReporter(std::string const& reporterName, IConfigPtr const& config) { + auto reporter = Catch::getRegistryHub().getReporterRegistry().create(reporterName, config); + CATCH_ENFORCE(reporter, "No reporter registered with name: '" << reporterName << "'"); + + return reporter; + } + + IStreamingReporterPtr makeReporter(std::shared_ptr const& config) { + if (Catch::getRegistryHub().getReporterRegistry().getListeners().empty()) { + return createReporter(config->getReporterName(), config); + } + + auto multi = std::unique_ptr(new ListeningReporter); + + auto const& listeners = Catch::getRegistryHub().getReporterRegistry().getListeners(); + for (auto const& listener : listeners) { + multi->addListener(listener->create(Catch::ReporterConfig(config))); + } + multi->addReporter(createReporter(config->getReporterName(), config)); + return std::move(multi); + } + + + Catch::Totals runTests(std::shared_ptr const& config) { + // FixMe: Add listeners in order first, then add reporters. + + auto reporter = makeReporter(config); + + RunContext context(config, std::move(reporter)); + + Totals totals; + + context.testGroupStarting(config->name(), 1, 1); + + TestSpec testSpec = config->testSpec(); + + auto const& allTestCases = getAllTestCasesSorted(*config); + for (auto const& testCase : allTestCases) { + if (!context.aborting() && matchTest(testCase, testSpec, *config)) + totals += context.runTest(testCase); + else + context.reporter().skipTest(testCase); + } + + if (config->warnAboutNoTests() && totals.testCases.total() == 0) { + ReusableStringStream testConfig; + + bool first = true; + for (const auto& input : config->getTestsOrTags()) { + if (!first) { testConfig << ' '; } + first = false; + testConfig << input; + } + + context.reporter().noMatchingTestCases(testConfig.str()); + totals.error = -1; + } + + context.testGroupEnded(config->name(), totals, 1, 1); + return totals; + } + + void applyFilenamesAsTags(Catch::IConfig const& config) { + auto& tests = const_cast&>(getAllTestCasesSorted(config)); + for (auto& testCase : tests) { + auto tags = testCase.tags; + + std::string filename = testCase.lineInfo.file; + auto lastSlash = filename.find_last_of("\\/"); + if (lastSlash != std::string::npos) { + filename.erase(0, lastSlash); + filename[0] = '#'; + } + + auto lastDot = filename.find_last_of('.'); + if (lastDot != std::string::npos) { + filename.erase(lastDot); + } + + tags.push_back(std::move(filename)); + setTags(testCase, tags); + } + } + + } // anon namespace + + Session::Session() { + static bool alreadyInstantiated = false; + if( alreadyInstantiated ) { + try { CATCH_INTERNAL_ERROR( "Only one instance of Catch::Session can ever be used" ); } + catch(...) { getMutableRegistryHub().registerStartupException(); } + } + + const auto& exceptions = getRegistryHub().getStartupExceptionRegistry().getExceptions(); + if ( !exceptions.empty() ) { + m_startupExceptions = true; + Colour colourGuard( Colour::Red ); + Catch::cerr() << "Errors occurred during startup!" << '\n'; + // iterate over all exceptions and notify user + for ( const auto& ex_ptr : exceptions ) { + try { + std::rethrow_exception(ex_ptr); + } catch ( std::exception const& ex ) { + Catch::cerr() << Column( ex.what() ).indent(2) << '\n'; + } + } + } + + alreadyInstantiated = true; + m_cli = makeCommandLineParser( m_configData ); + } + Session::~Session() { + Catch::cleanUp(); + } + + void Session::showHelp() const { + Catch::cout() + << "\nCatch v" << libraryVersion() << "\n" + << m_cli << std::endl + << "For more detailed usage please see the project docs\n" << std::endl; + } + void Session::libIdentify() { + Catch::cout() + << std::left << std::setw(16) << "description: " << "A Catch test executable\n" + << std::left << std::setw(16) << "category: " << "testframework\n" + << std::left << std::setw(16) << "framework: " << "Catch Test\n" + << std::left << std::setw(16) << "version: " << libraryVersion() << std::endl; + } + + int Session::applyCommandLine( int argc, char const * const * argv ) { + if( m_startupExceptions ) + return 1; + + auto result = m_cli.parse( clara::Args( argc, argv ) ); + if( !result ) { + Catch::cerr() + << Colour( Colour::Red ) + << "\nError(s) in input:\n" + << Column( result.errorMessage() ).indent( 2 ) + << "\n\n"; + Catch::cerr() << "Run with -? for usage\n" << std::endl; + return MaxExitCode; + } + + if( m_configData.showHelp ) + showHelp(); + if( m_configData.libIdentify ) + libIdentify(); + m_config.reset(); + return 0; + } + + void Session::useConfigData( ConfigData const& configData ) { + m_configData = configData; + m_config.reset(); + } + + int Session::run( int argc, char* argv[] ) { + if( m_startupExceptions ) + return 1; + int returnCode = applyCommandLine( argc, argv ); + if( returnCode == 0 ) + returnCode = run(); + return returnCode; + } + +#if defined(CATCH_CONFIG_WCHAR) && defined(WIN32) && defined(UNICODE) + int Session::run( int argc, wchar_t* const argv[] ) { + + char **utf8Argv = new char *[ argc ]; + + for ( int i = 0; i < argc; ++i ) { + int bufSize = WideCharToMultiByte( CP_UTF8, 0, argv[i], -1, NULL, 0, NULL, NULL ); + + utf8Argv[ i ] = new char[ bufSize ]; + + WideCharToMultiByte( CP_UTF8, 0, argv[i], -1, utf8Argv[i], bufSize, NULL, NULL ); + } + + int returnCode = run( argc, utf8Argv ); + + for ( int i = 0; i < argc; ++i ) + delete [] utf8Argv[ i ]; + + delete [] utf8Argv; + + return returnCode; + } +#endif + int Session::run() { + if( ( m_configData.waitForKeypress & WaitForKeypress::BeforeStart ) != 0 ) { + Catch::cout() << "...waiting for enter/ return before starting" << std::endl; + static_cast(std::getchar()); + } + int exitCode = runInternal(); + if( ( m_configData.waitForKeypress & WaitForKeypress::BeforeExit ) != 0 ) { + Catch::cout() << "...waiting for enter/ return before exiting, with code: " << exitCode << std::endl; + static_cast(std::getchar()); + } + return exitCode; + } + + clara::Parser const& Session::cli() const { + return m_cli; + } + void Session::cli( clara::Parser const& newParser ) { + m_cli = newParser; + } + ConfigData& Session::configData() { + return m_configData; + } + Config& Session::config() { + if( !m_config ) + m_config = std::make_shared( m_configData ); + return *m_config; + } + + int Session::runInternal() { + if( m_startupExceptions ) + return 1; + + if( m_configData.showHelp || m_configData.libIdentify ) + return 0; + + try + { + config(); // Force config to be constructed + + seedRng( *m_config ); + + if( m_configData.filenamesAsTags ) + applyFilenamesAsTags( *m_config ); + + // Handle list request + if( Option listed = list( config() ) ) + return static_cast( *listed ); + + auto totals = runTests( m_config ); + // Note that on unices only the lower 8 bits are usually used, clamping + // the return value to 255 prevents false negative when some multiple + // of 256 tests has failed + return (std::min) (MaxExitCode, (std::max) (totals.error, static_cast(totals.assertions.failed))); + } + catch( std::exception& ex ) { + Catch::cerr() << ex.what() << std::endl; + return MaxExitCode; + } + } + +} // end namespace Catch diff --git a/src/third_party/cppcodec/test/catch/include/internal/catch_session.h b/src/third_party/cppcodec/test/catch/include/internal/catch_session.h new file mode 100644 index 0000000000..eb8013cd2f --- /dev/null +++ b/src/third_party/cppcodec/test/catch/include/internal/catch_session.h @@ -0,0 +1,53 @@ +/* + * Created by Phil on 31/10/2010. + * Copyright 2010 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_CATCH_RUNNER_HPP_INCLUDED +#define TWOBLUECUBES_CATCH_RUNNER_HPP_INCLUDED + +#include "catch_commandline.h" +#include "catch_config.hpp" +#include "catch_text.h" + +#include + +namespace Catch { + + class Session : NonCopyable { + public: + + Session(); + ~Session() override; + + void showHelp() const; + void libIdentify(); + + int applyCommandLine( int argc, char const * const * argv ); + + void useConfigData( ConfigData const& configData ); + + int run( int argc, char* argv[] ); + #if defined(CATCH_CONFIG_WCHAR) && defined(WIN32) && defined(UNICODE) + int run( int argc, wchar_t* const argv[] ); + #endif + int run(); + + clara::Parser const& cli() const; + void cli( clara::Parser const& newParser ); + ConfigData& configData(); + Config& config(); + private: + int runInternal(); + + clara::Parser m_cli; + ConfigData m_configData; + std::shared_ptr m_config; + bool m_startupExceptions = false; + }; + +} // end namespace Catch + +#endif // TWOBLUECUBES_CATCH_RUNNER_HPP_INCLUDED diff --git a/src/third_party/cppcodec/test/catch/include/internal/catch_startup_exception_registry.cpp b/src/third_party/cppcodec/test/catch/include/internal/catch_startup_exception_registry.cpp new file mode 100644 index 0000000000..d58d18a5ba --- /dev/null +++ b/src/third_party/cppcodec/test/catch/include/internal/catch_startup_exception_registry.cpp @@ -0,0 +1,26 @@ +/* + * Created by Martin on 04/06/2017. + * Copyright 2017 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) + */ + +#include "catch_startup_exception_registry.h" + +namespace Catch { + void StartupExceptionRegistry::add( std::exception_ptr const& exception ) noexcept { + try { + m_exceptions.push_back(exception); + } + catch(...) { + // If we run out of memory during start-up there's really not a lot more we can do about it + std::terminate(); + } + } + + std::vector const& StartupExceptionRegistry::getExceptions() const noexcept { + return m_exceptions; + } + +} // end namespace Catch diff --git a/src/third_party/cppcodec/test/catch/include/internal/catch_startup_exception_registry.h b/src/third_party/cppcodec/test/catch/include/internal/catch_startup_exception_registry.h new file mode 100644 index 0000000000..feb566019e --- /dev/null +++ b/src/third_party/cppcodec/test/catch/include/internal/catch_startup_exception_registry.h @@ -0,0 +1,27 @@ +/* + * Created by Martin on 04/06/2017. + * Copyright 2017 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_CATCH_STARTUP_EXCEPTION_REGISTRY_H_INCLUDED +#define TWOBLUECUBES_CATCH_STARTUP_EXCEPTION_REGISTRY_H_INCLUDED + + +#include +#include + +namespace Catch { + + class StartupExceptionRegistry { + public: + void add(std::exception_ptr const& exception) noexcept; + std::vector const& getExceptions() const noexcept; + private: + std::vector m_exceptions; + }; + +} // end namespace Catch + +#endif // TWOBLUECUBES_CATCH_STARTUP_EXCEPTION_REGISTRY_H_INCLUDED diff --git a/src/third_party/cppcodec/test/catch/include/internal/catch_stream.cpp b/src/third_party/cppcodec/test/catch/include/internal/catch_stream.cpp new file mode 100644 index 0000000000..125fd471e6 --- /dev/null +++ b/src/third_party/cppcodec/test/catch/include/internal/catch_stream.cpp @@ -0,0 +1,213 @@ +/* + * Created by Phil on 17/01/2011. + * Copyright 2011 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) + * + */ + +#include "catch_common.h" +#include "catch_enforce.h" +#include "catch_stream.h" +#include "catch_debug_console.h" +#include "catch_stringref.h" + +#include +#include +#include +#include +#include +#include + +#if defined(__clang__) +# pragma clang diagnostic push +# pragma clang diagnostic ignored "-Wexit-time-destructors" +#endif + +namespace Catch { + + Catch::IStream::~IStream() = default; + + namespace detail { namespace { + template + class StreamBufImpl : public std::streambuf { + char data[bufferSize]; + WriterF m_writer; + + public: + StreamBufImpl() { + setp( data, data + sizeof(data) ); + } + + ~StreamBufImpl() noexcept { + StreamBufImpl::sync(); + } + + private: + int overflow( int c ) override { + sync(); + + if( c != EOF ) { + if( pbase() == epptr() ) + m_writer( std::string( 1, static_cast( c ) ) ); + else + sputc( static_cast( c ) ); + } + return 0; + } + + int sync() override { + if( pbase() != pptr() ) { + m_writer( std::string( pbase(), static_cast( pptr() - pbase() ) ) ); + setp( pbase(), epptr() ); + } + return 0; + } + }; + + /////////////////////////////////////////////////////////////////////////// + + struct OutputDebugWriter { + + void operator()( std::string const&str ) { + writeToDebugConsole( str ); + } + }; + + /////////////////////////////////////////////////////////////////////////// + + class FileStream : public IStream { + mutable std::ofstream m_ofs; + public: + FileStream( StringRef filename ) { + m_ofs.open( filename.c_str() ); + CATCH_ENFORCE( !m_ofs.fail(), "Unable to open file: '" << filename << "'" ); + } + ~FileStream() override = default; + public: // IStream + std::ostream& stream() const override { + return m_ofs; + } + }; + + /////////////////////////////////////////////////////////////////////////// + + class CoutStream : public IStream { + mutable std::ostream m_os; + public: + // Store the streambuf from cout up-front because + // cout may get redirected when running tests + CoutStream() : m_os( Catch::cout().rdbuf() ) {} + ~CoutStream() override = default; + + public: // IStream + std::ostream& stream() const override { return m_os; } + }; + + /////////////////////////////////////////////////////////////////////////// + + class DebugOutStream : public IStream { + std::unique_ptr> m_streamBuf; + mutable std::ostream m_os; + public: + DebugOutStream() + : m_streamBuf( new StreamBufImpl() ), + m_os( m_streamBuf.get() ) + {} + + ~DebugOutStream() override = default; + + public: // IStream + std::ostream& stream() const override { return m_os; } + }; + + }} // namespace anon::detail + + /////////////////////////////////////////////////////////////////////////// + + auto makeStream( StringRef const &filename ) -> IStream const* { + if( filename.empty() ) + return new detail::CoutStream(); + else if( filename[0] == '%' ) { + if( filename == "%debug" ) + return new detail::DebugOutStream(); + else + CATCH_ERROR( "Unrecognised stream: '" << filename << "'" ); + } + else + return new detail::FileStream( filename ); + } + + + // This class encapsulates the idea of a pool of ostringstreams that can be reused. + struct StringStreams { + std::vector> m_streams; + std::vector m_unused; + std::ostringstream m_referenceStream; // Used for copy state/ flags from + static StringStreams* s_instance; + + auto add() -> std::size_t { + if( m_unused.empty() ) { + m_streams.push_back( std::unique_ptr( new std::ostringstream ) ); + return m_streams.size()-1; + } + else { + auto index = m_unused.back(); + m_unused.pop_back(); + return index; + } + } + + void release( std::size_t index ) { + m_streams[index]->copyfmt( m_referenceStream ); // Restore initial flags and other state + m_unused.push_back(index); + } + + // !TBD: put in TLS + static auto instance() -> StringStreams& { + if( !s_instance ) + s_instance = new StringStreams(); + return *s_instance; + } + static void cleanup() { + delete s_instance; + s_instance = nullptr; + } + }; + + StringStreams* StringStreams::s_instance = nullptr; + + void ReusableStringStream::cleanup() { + StringStreams::cleanup(); + } + + ReusableStringStream::ReusableStringStream() + : m_index( StringStreams::instance().add() ), + m_oss( StringStreams::instance().m_streams[m_index].get() ) + {} + + ReusableStringStream::~ReusableStringStream() { + static_cast( m_oss )->str(""); + m_oss->clear(); + StringStreams::instance().release( m_index ); + } + + auto ReusableStringStream::str() const -> std::string { + return static_cast( m_oss )->str(); + } + + + /////////////////////////////////////////////////////////////////////////// + + +#ifndef CATCH_CONFIG_NOSTDOUT // If you #define this you must implement these functions + std::ostream& cout() { return std::cout; } + std::ostream& cerr() { return std::cerr; } + std::ostream& clog() { return std::clog; } +#endif +} + +#if defined(__clang__) +# pragma clang diagnostic pop +#endif diff --git a/src/third_party/cppcodec/test/catch/include/internal/catch_stream.h b/src/third_party/cppcodec/test/catch/include/internal/catch_stream.h new file mode 100644 index 0000000000..c5e78b226f --- /dev/null +++ b/src/third_party/cppcodec/test/catch/include/internal/catch_stream.h @@ -0,0 +1,51 @@ +/* + * Created by Phil on 2/12/2013. + * Copyright 2013 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_CATCH_STREAM_H_INCLUDED +#define TWOBLUECUBES_CATCH_STREAM_H_INCLUDED + +#include +#include +#include + +namespace Catch { + + std::ostream& cout(); + std::ostream& cerr(); + std::ostream& clog(); + + class StringRef; + + struct IStream { + virtual ~IStream(); + virtual std::ostream& stream() const = 0; + }; + + auto makeStream( StringRef const &filename ) -> IStream const*; + + class ReusableStringStream { + std::size_t m_index; + std::ostream* m_oss; + public: + ReusableStringStream(); + ~ReusableStringStream(); + + auto str() const -> std::string; + + template + auto operator << ( T const& value ) -> ReusableStringStream& { + *m_oss << value; + return *this; + } + auto get() -> std::ostream& { return *m_oss; } + + static void cleanup(); + }; +} + +#endif // TWOBLUECUBES_CATCH_STREAM_H_INCLUDED diff --git a/src/third_party/cppcodec/test/catch/include/internal/catch_string_manip.cpp b/src/third_party/cppcodec/test/catch/include/internal/catch_string_manip.cpp new file mode 100644 index 0000000000..904d10138f --- /dev/null +++ b/src/third_party/cppcodec/test/catch/include/internal/catch_string_manip.cpp @@ -0,0 +1,80 @@ +/* + * Created by Martin on 25/07/2017. + * + * 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) + */ + +#include "catch_string_manip.h" + +#include +#include +#include +#include + +namespace Catch { + + namespace { + char toLowerCh(char c) { + return static_cast( std::tolower( c ) ); + } + } + + bool startsWith( std::string const& s, std::string const& prefix ) { + return s.size() >= prefix.size() && std::equal(prefix.begin(), prefix.end(), s.begin()); + } + bool startsWith( std::string const& s, char prefix ) { + return !s.empty() && s[0] == prefix; + } + bool endsWith( std::string const& s, std::string const& suffix ) { + return s.size() >= suffix.size() && std::equal(suffix.rbegin(), suffix.rend(), s.rbegin()); + } + bool endsWith( std::string const& s, char suffix ) { + return !s.empty() && s[s.size()-1] == suffix; + } + bool contains( std::string const& s, std::string const& infix ) { + return s.find( infix ) != std::string::npos; + } + void toLowerInPlace( std::string& s ) { + std::transform( s.begin(), s.end(), s.begin(), toLowerCh ); + } + std::string toLower( std::string const& s ) { + std::string lc = s; + toLowerInPlace( lc ); + return lc; + } + std::string trim( std::string const& str ) { + static char const* whitespaceChars = "\n\r\t "; + std::string::size_type start = str.find_first_not_of( whitespaceChars ); + std::string::size_type end = str.find_last_not_of( whitespaceChars ); + + return start != std::string::npos ? str.substr( start, 1+end-start ) : std::string(); + } + + bool replaceInPlace( std::string& str, std::string const& replaceThis, std::string const& withThis ) { + bool replaced = false; + std::size_t i = str.find( replaceThis ); + while( i != std::string::npos ) { + replaced = true; + str = str.substr( 0, i ) + withThis + str.substr( i+replaceThis.size() ); + if( i < str.size()-withThis.size() ) + i = str.find( replaceThis, i+withThis.size() ); + else + i = std::string::npos; + } + return replaced; + } + + pluralise::pluralise( std::size_t count, std::string const& label ) + : m_count( count ), + m_label( label ) + {} + + std::ostream& operator << ( std::ostream& os, pluralise const& pluraliser ) { + os << pluraliser.m_count << ' ' << pluraliser.m_label; + if( pluraliser.m_count != 1 ) + os << 's'; + return os; + } + +} diff --git a/src/third_party/cppcodec/test/catch/include/internal/catch_string_manip.h b/src/third_party/cppcodec/test/catch/include/internal/catch_string_manip.h new file mode 100644 index 0000000000..6292cd576e --- /dev/null +++ b/src/third_party/cppcodec/test/catch/include/internal/catch_string_manip.h @@ -0,0 +1,36 @@ +/* + * Created by Martin on 25/07/2017. + * + * 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_CATCH_STRING_MANIP_H_INCLUDED +#define TWOBLUECUBES_CATCH_STRING_MANIP_H_INCLUDED + +#include +#include + +namespace Catch { + + bool startsWith( std::string const& s, std::string const& prefix ); + bool startsWith( std::string const& s, char prefix ); + bool endsWith( std::string const& s, std::string const& suffix ); + bool endsWith( std::string const& s, char suffix ); + bool contains( std::string const& s, std::string const& infix ); + void toLowerInPlace( std::string& s ); + std::string toLower( std::string const& s ); + std::string trim( std::string const& str ); + bool replaceInPlace( std::string& str, std::string const& replaceThis, std::string const& withThis ); + + struct pluralise { + pluralise( std::size_t count, std::string const& label ); + + friend std::ostream& operator << ( std::ostream& os, pluralise const& pluraliser ); + + std::size_t m_count; + std::string m_label; + }; +} + +#endif // TWOBLUECUBES_CATCH_STRING_MANIP_H_INCLUDED + diff --git a/src/third_party/cppcodec/test/catch/include/internal/catch_stringref.cpp b/src/third_party/cppcodec/test/catch/include/internal/catch_stringref.cpp new file mode 100644 index 0000000000..9e9095e4ba --- /dev/null +++ b/src/third_party/cppcodec/test/catch/include/internal/catch_stringref.cpp @@ -0,0 +1,127 @@ +/* + * Copyright 2016 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) + */ + + +#if defined(__clang__) +# pragma clang diagnostic push +# pragma clang diagnostic ignored "-Wexit-time-destructors" +#endif + +#include "catch_stringref.h" + +#include +#include +#include + +namespace { + const uint32_t byte_2_lead = 0xC0; + const uint32_t byte_3_lead = 0xE0; + const uint32_t byte_4_lead = 0xF0; +} + +namespace Catch { + StringRef::StringRef( char const* rawChars ) noexcept + : StringRef( rawChars, static_cast(std::strlen(rawChars) ) ) + {} + + StringRef::operator std::string() const { + return std::string( m_start, m_size ); + } + + void StringRef::swap( StringRef& other ) noexcept { + std::swap( m_start, other.m_start ); + std::swap( m_size, other.m_size ); + std::swap( m_data, other.m_data ); + } + + auto StringRef::c_str() const -> char const* { + if( isSubstring() ) + const_cast( this )->takeOwnership(); + return m_start; + } + auto StringRef::currentData() const noexcept -> char const* { + return m_start; + } + + auto StringRef::isOwned() const noexcept -> bool { + return m_data != nullptr; + } + auto StringRef::isSubstring() const noexcept -> bool { + return m_start[m_size] != '\0'; + } + + void StringRef::takeOwnership() { + if( !isOwned() ) { + m_data = new char[m_size+1]; + memcpy( m_data, m_start, m_size ); + m_data[m_size] = '\0'; + m_start = m_data; + } + } + auto StringRef::substr( size_type start, size_type size ) const noexcept -> StringRef { + if( start < m_size ) + return StringRef( m_start+start, size ); + else + return StringRef(); + } + auto StringRef::operator == ( StringRef const& other ) const noexcept -> bool { + return + size() == other.size() && + (std::strncmp( m_start, other.m_start, size() ) == 0); + } + auto StringRef::operator != ( StringRef const& other ) const noexcept -> bool { + return !operator==( other ); + } + + auto StringRef::operator[](size_type index) const noexcept -> char { + return m_start[index]; + } + + auto StringRef::numberOfCharacters() const noexcept -> size_type { + size_type noChars = m_size; + // Make adjustments for uft encodings + for( size_type i=0; i < m_size; ++i ) { + char c = m_start[i]; + if( ( c & byte_2_lead ) == byte_2_lead ) { + noChars--; + if (( c & byte_3_lead ) == byte_3_lead ) + noChars--; + if( ( c & byte_4_lead ) == byte_4_lead ) + noChars--; + } + } + return noChars; + } + + auto operator + ( StringRef const& lhs, StringRef const& rhs ) -> std::string { + std::string str; + str.reserve( lhs.size() + rhs.size() ); + str += lhs; + str += rhs; + return str; + } + auto operator + ( StringRef const& lhs, const char* rhs ) -> std::string { + return std::string( lhs ) + std::string( rhs ); + } + auto operator + ( char const* lhs, StringRef const& rhs ) -> std::string { + return std::string( lhs ) + std::string( rhs ); + } + + auto operator << ( std::ostream& os, StringRef const& str ) -> std::ostream& { + return os.write(str.currentData(), str.size()); + } + + auto operator+=( std::string& lhs, StringRef const& rhs ) -> std::string& { + lhs.append(rhs.currentData(), rhs.size()); + return lhs; + } + +} // namespace Catch + +#if defined(__clang__) +# pragma clang diagnostic pop +#endif diff --git a/src/third_party/cppcodec/test/catch/include/internal/catch_stringref.h b/src/third_party/cppcodec/test/catch/include/internal/catch_stringref.h new file mode 100644 index 0000000000..757d70cc1a --- /dev/null +++ b/src/third_party/cppcodec/test/catch/include/internal/catch_stringref.h @@ -0,0 +1,130 @@ +/* + * Copyright 2016 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 CATCH_STRINGREF_H_INCLUDED +#define CATCH_STRINGREF_H_INCLUDED + +#include +#include +#include + +namespace Catch { + + class StringData; + + /// 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. c_str() must return a null terminated + /// string, however, and so the StringRef will internally take ownership + /// (taking a copy), if necessary. In theory this ownership is not externally + /// visible - but it does mean (substring) StringRefs should not be shared between + /// threads. + class StringRef { + public: + using size_type = std::size_t; + + private: + friend struct StringRefTestAccess; + + char const* m_start; + size_type m_size; + + char* m_data = nullptr; + + void takeOwnership(); + + static constexpr char const* const s_empty = ""; + + public: // construction/ assignment + StringRef() noexcept + : StringRef( s_empty, 0 ) + {} + + StringRef( StringRef const& other ) noexcept + : m_start( other.m_start ), + m_size( other.m_size ) + {} + + StringRef( StringRef&& other ) noexcept + : m_start( other.m_start ), + m_size( other.m_size ), + m_data( other.m_data ) + { + other.m_data = nullptr; + } + + StringRef( char const* rawChars ) noexcept; + + 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() ) + {} + + ~StringRef() noexcept { + delete[] m_data; + } + + auto operator = ( StringRef const &other ) noexcept -> StringRef& { + delete[] m_data; + m_data = nullptr; + m_start = other.m_start; + m_size = other.m_size; + return *this; + } + + operator std::string() const; + + void swap( StringRef& other ) noexcept; + + public: // operators + auto operator == ( StringRef const& other ) const noexcept -> bool; + auto operator != ( StringRef const& other ) const noexcept -> bool; + + auto operator[] ( size_type index ) const noexcept -> char; + + public: // named queries + auto empty() const noexcept -> bool { + return m_size == 0; + } + auto size() const noexcept -> size_type { + return m_size; + } + + auto numberOfCharacters() const noexcept -> size_type; + auto c_str() const -> char const*; + + public: // substrings and searches + auto substr( size_type start, size_type size ) const noexcept -> StringRef; + + // Returns the current start pointer. + // Note that the pointer can change when if the StringRef is a substring + auto currentData() const noexcept -> char const*; + + private: // ownership queries - may not be consistent between calls + auto isOwned() const noexcept -> bool; + auto isSubstring() const noexcept -> bool; + }; + + auto operator + ( StringRef const& lhs, StringRef const& rhs ) -> std::string; + auto operator + ( StringRef const& lhs, char const* rhs ) -> std::string; + auto operator + ( char const* lhs, StringRef const& rhs ) -> std::string; + + auto operator += ( std::string& lhs, StringRef const& sr ) -> std::string&; + auto operator << ( std::ostream& os, StringRef const& sr ) -> std::ostream&; + + + inline auto operator "" _sr( char const* rawChars, std::size_t size ) noexcept -> StringRef { + return StringRef( rawChars, size ); + } + +} // namespace Catch + +#endif // CATCH_STRINGREF_H_INCLUDED diff --git a/src/third_party/cppcodec/test/catch/include/internal/catch_suppress_warnings.h b/src/third_party/cppcodec/test/catch/include/internal/catch_suppress_warnings.h new file mode 100644 index 0000000000..25d90125b5 --- /dev/null +++ b/src/third_party/cppcodec/test/catch/include/internal/catch_suppress_warnings.h @@ -0,0 +1,26 @@ +/* + * Copyright 2014 Two Blue Cubes Ltd + * + * 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) + */ + +#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__ + // GCC likes to warn on REQUIREs, and we cannot suppress them + // locally because g++'s support for _Pragma is lacking in older, + // still supported, versions +# pragma GCC diagnostic ignored "-Wparentheses" +# pragma GCC diagnostic push +# pragma GCC diagnostic ignored "-Wunused-variable" +# pragma GCC diagnostic ignored "-Wpadded" +#endif diff --git a/src/third_party/cppcodec/test/catch/include/internal/catch_tag_alias.cpp b/src/third_party/cppcodec/test/catch/include/internal/catch_tag_alias.cpp new file mode 100644 index 0000000000..2ea4540e16 --- /dev/null +++ b/src/third_party/cppcodec/test/catch/include/internal/catch_tag_alias.cpp @@ -0,0 +1,5 @@ +#include "catch_tag_alias.h" + +namespace Catch { + TagAlias::TagAlias(std::string const & _tag, SourceLineInfo _lineInfo): tag(_tag), lineInfo(_lineInfo) {} +} diff --git a/src/third_party/cppcodec/test/catch/include/internal/catch_tag_alias.h b/src/third_party/cppcodec/test/catch/include/internal/catch_tag_alias.h new file mode 100644 index 0000000000..a9e6eb372a --- /dev/null +++ b/src/third_party/cppcodec/test/catch/include/internal/catch_tag_alias.h @@ -0,0 +1,26 @@ +/* + * Created by Phil on 27/6/2014. + * Copyright 2014 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_CATCH_TAG_ALIAS_H_INCLUDED +#define TWOBLUECUBES_CATCH_TAG_ALIAS_H_INCLUDED + +#include "catch_common.h" + +#include + +namespace Catch { + + struct TagAlias { + TagAlias(std::string const& _tag, SourceLineInfo _lineInfo); + + std::string tag; + SourceLineInfo lineInfo; + }; + +} // end namespace Catch + +#endif // TWOBLUECUBES_CATCH_TAG_ALIAS_H_INCLUDED diff --git a/src/third_party/cppcodec/test/catch/include/internal/catch_tag_alias_autoregistrar.cpp b/src/third_party/cppcodec/test/catch/include/internal/catch_tag_alias_autoregistrar.cpp new file mode 100644 index 0000000000..35ed059fd5 --- /dev/null +++ b/src/third_party/cppcodec/test/catch/include/internal/catch_tag_alias_autoregistrar.cpp @@ -0,0 +1,15 @@ +#include "catch_tag_alias_autoregistrar.h" +#include "catch_interfaces_registry_hub.h" + +namespace Catch { + + RegistrarForTagAliases::RegistrarForTagAliases(char const* alias, char const* tag, SourceLineInfo const& lineInfo) { + try { + getMutableRegistryHub().registerTagAlias(alias, tag, lineInfo); + } catch (...) { + // Do not throw when constructing global objects, instead register the exception to be processed later + getMutableRegistryHub().registerStartupException(); + } + } + +} diff --git a/src/third_party/cppcodec/test/catch/include/internal/catch_tag_alias_autoregistrar.h b/src/third_party/cppcodec/test/catch/include/internal/catch_tag_alias_autoregistrar.h new file mode 100644 index 0000000000..32a5734eff --- /dev/null +++ b/src/third_party/cppcodec/test/catch/include/internal/catch_tag_alias_autoregistrar.h @@ -0,0 +1,25 @@ +/* + * Created by Martin on 27/07/2017. + * + * 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_CATCH_TAG_ALIAS_AUTOREGISTRAR_H_INCLUDED +#define TWOBLUECUBES_CATCH_TAG_ALIAS_AUTOREGISTRAR_H_INCLUDED + +#include "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_SUPPRESS_GLOBALS_WARNINGS \ + namespace{ Catch::RegistrarForTagAliases INTERNAL_CATCH_UNIQUE_NAME( AutoRegisterTagAlias )( alias, spec, CATCH_INTERNAL_LINEINFO ); } \ + CATCH_INTERNAL_UNSUPPRESS_GLOBALS_WARNINGS + +#endif // TWOBLUECUBES_CATCH_TAG_ALIAS_AUTOREGISTRAR_H_INCLUDED diff --git a/src/third_party/cppcodec/test/catch/include/internal/catch_tag_alias_registry.cpp b/src/third_party/cppcodec/test/catch/include/internal/catch_tag_alias_registry.cpp new file mode 100644 index 0000000000..98aea26acd --- /dev/null +++ b/src/third_party/cppcodec/test/catch/include/internal/catch_tag_alias_registry.cpp @@ -0,0 +1,58 @@ +/* + * Created by Phil on 27/6/2014. + * Copyright 2014 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) + */ + +#include "catch_tag_alias_registry.h" +#include "catch_console_colour.h" +#include "catch_enforce.h" +#include "catch_interfaces_registry_hub.h" +#include "catch_string_manip.h" + +#include + +namespace Catch { + + TagAliasRegistry::~TagAliasRegistry() {} + + TagAlias const* TagAliasRegistry::find( std::string const& alias ) const { + auto it = m_registry.find( alias ); + if( it != m_registry.end() ) + return &(it->second); + else + return nullptr; + } + + std::string TagAliasRegistry::expandAliases( std::string const& unexpandedTestSpec ) const { + std::string expandedTestSpec = unexpandedTestSpec; + for( auto const& registryKvp : m_registry ) { + std::size_t pos = expandedTestSpec.find( registryKvp.first ); + if( pos != std::string::npos ) { + expandedTestSpec = expandedTestSpec.substr( 0, pos ) + + registryKvp.second.tag + + expandedTestSpec.substr( pos + registryKvp.first.size() ); + } + } + return expandedTestSpec; + } + + void TagAliasRegistry::add( std::string const& alias, std::string const& tag, SourceLineInfo const& lineInfo ) { + CATCH_ENFORCE( startsWith(alias, "[@") && endsWith(alias, ']'), + "error: tag alias, '" << alias << "' is not of the form [@alias name].\n" << lineInfo ); + + CATCH_ENFORCE( m_registry.insert(std::make_pair(alias, TagAlias(tag, lineInfo))).second, + "error: tag alias, '" << alias << "' already registered.\n" + << "\tFirst seen at: " << find(alias)->lineInfo << "\n" + << "\tRedefined at: " << lineInfo ); + } + + ITagAliasRegistry::~ITagAliasRegistry() {} + + ITagAliasRegistry const& ITagAliasRegistry::get() { + return getRegistryHub().getTagAliasRegistry(); + } + +} // end namespace Catch diff --git a/src/third_party/cppcodec/test/catch/include/internal/catch_tag_alias_registry.h b/src/third_party/cppcodec/test/catch/include/internal/catch_tag_alias_registry.h new file mode 100644 index 0000000000..d3bb8ffb43 --- /dev/null +++ b/src/third_party/cppcodec/test/catch/include/internal/catch_tag_alias_registry.h @@ -0,0 +1,31 @@ +/* + * Created by Phil on 27/6/2014. + * Copyright 2014 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_CATCH_TAG_ALIAS_REGISTRY_H_INCLUDED +#define TWOBLUECUBES_CATCH_TAG_ALIAS_REGISTRY_H_INCLUDED + +#include "catch_interfaces_tag_alias_registry.h" +#include "catch_tag_alias.h" + +#include + +namespace Catch { + + class TagAliasRegistry : public ITagAliasRegistry { + public: + ~TagAliasRegistry() override; + TagAlias const* find( std::string const& alias ) const override; + std::string expandAliases( std::string const& unexpandedTestSpec ) const override; + void add( std::string const& alias, std::string const& tag, SourceLineInfo const& lineInfo ); + + private: + std::map m_registry; + }; + +} // end namespace Catch + +#endif // TWOBLUECUBES_CATCH_TAG_ALIAS_REGISTRY_H_INCLUDED diff --git a/src/third_party/cppcodec/test/catch/include/internal/catch_test_case_info.cpp b/src/third_party/cppcodec/test/catch/include/internal/catch_test_case_info.cpp new file mode 100644 index 0000000000..536462d114 --- /dev/null +++ b/src/third_party/cppcodec/test/catch/include/internal/catch_test_case_info.cpp @@ -0,0 +1,180 @@ +/* + * Created by Phil on 14/08/2012. + * Copyright 2012 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) + */ + +#include "catch_test_case_info.h" +#include "catch_enforce.h" +#include "catch_test_spec.h" +#include "catch_interfaces_testcase.h" +#include "catch_string_manip.h" + +#include +#include +#include +#include + +namespace Catch { + + namespace { + TestCaseInfo::SpecialProperties parseSpecialTag( std::string const& tag ) { + if( startsWith( tag, '.' ) || + tag == "!hide" ) + return TestCaseInfo::IsHidden; + else if( tag == "!throws" ) + return TestCaseInfo::Throws; + else if( tag == "!shouldfail" ) + return TestCaseInfo::ShouldFail; + else if( tag == "!mayfail" ) + return TestCaseInfo::MayFail; + else if( tag == "!nonportable" ) + return TestCaseInfo::NonPortable; + else if( tag == "!benchmark" ) + return static_cast( TestCaseInfo::Benchmark | TestCaseInfo::IsHidden ); + else + return TestCaseInfo::None; + } + bool isReservedTag( std::string const& tag ) { + return parseSpecialTag( tag ) == TestCaseInfo::None && tag.size() > 0 && !std::isalnum( static_cast(tag[0]) ); + } + void enforceNotReservedTag( std::string const& tag, SourceLineInfo const& _lineInfo ) { + CATCH_ENFORCE( !isReservedTag(tag), + "Tag name: [" << tag << "] is not allowed.\n" + << "Tag names starting with non alpha-numeric characters are reserved\n" + << _lineInfo ); + } + } + + TestCase makeTestCase( ITestInvoker* _testCase, + std::string const& _className, + NameAndTags const& nameAndTags, + SourceLineInfo const& _lineInfo ) + { + bool isHidden = false; + + // Parse out tags + std::vector tags; + std::string desc, tag; + bool inTag = false; + std::string _descOrTags = nameAndTags.tags; + for (char c : _descOrTags) { + if( !inTag ) { + if( c == '[' ) + inTag = true; + else + desc += c; + } + else { + if( c == ']' ) { + TestCaseInfo::SpecialProperties prop = parseSpecialTag( tag ); + if( ( prop & TestCaseInfo::IsHidden ) != 0 ) + isHidden = true; + else if( prop == TestCaseInfo::None ) + enforceNotReservedTag( tag, _lineInfo ); + + tags.push_back( tag ); + tag.clear(); + inTag = false; + } + else + tag += c; + } + } + if( isHidden ) { + tags.push_back( "." ); + } + + TestCaseInfo info( nameAndTags.name, _className, desc, tags, _lineInfo ); + return TestCase( _testCase, std::move(info) ); + } + + void setTags( TestCaseInfo& testCaseInfo, std::vector tags ) { + std::sort(begin(tags), end(tags)); + tags.erase(std::unique(begin(tags), end(tags)), end(tags)); + testCaseInfo.lcaseTags.clear(); + + for( auto const& tag : tags ) { + std::string lcaseTag = toLower( tag ); + testCaseInfo.properties = static_cast( testCaseInfo.properties | parseSpecialTag( lcaseTag ) ); + testCaseInfo.lcaseTags.push_back( lcaseTag ); + } + testCaseInfo.tags = std::move(tags); + } + + TestCaseInfo::TestCaseInfo( std::string const& _name, + std::string const& _className, + std::string const& _description, + std::vector const& _tags, + SourceLineInfo const& _lineInfo ) + : name( _name ), + className( _className ), + description( _description ), + lineInfo( _lineInfo ), + properties( None ) + { + setTags( *this, _tags ); + } + + bool TestCaseInfo::isHidden() const { + return ( properties & IsHidden ) != 0; + } + bool TestCaseInfo::throws() const { + return ( properties & Throws ) != 0; + } + bool TestCaseInfo::okToFail() const { + return ( properties & (ShouldFail | MayFail ) ) != 0; + } + bool TestCaseInfo::expectedToFail() const { + return ( properties & (ShouldFail ) ) != 0; + } + + std::string TestCaseInfo::tagsAsString() const { + std::string ret; + // '[' and ']' per tag + std::size_t full_size = 2 * tags.size(); + for (const auto& tag : tags) { + full_size += tag.size(); + } + ret.reserve(full_size); + for (const auto& tag : tags) { + ret.push_back('['); + ret.append(tag); + ret.push_back(']'); + } + + return ret; + } + + + TestCase::TestCase( ITestInvoker* testCase, TestCaseInfo&& info ) : TestCaseInfo( std::move(info) ), test( testCase ) {} + + + TestCase TestCase::withName( std::string const& _newName ) const { + TestCase other( *this ); + other.name = _newName; + return other; + } + + void TestCase::invoke() const { + test->invoke(); + } + + bool TestCase::operator == ( TestCase const& other ) const { + return test.get() == other.test.get() && + name == other.name && + className == other.className; + } + + bool TestCase::operator < ( TestCase const& other ) const { + return name < other.name; + } + + TestCaseInfo const& TestCase::getTestCaseInfo() const + { + return *this; + } + +} // end namespace Catch diff --git a/src/third_party/cppcodec/test/catch/include/internal/catch_test_case_info.h b/src/third_party/cppcodec/test/catch/include/internal/catch_test_case_info.h new file mode 100644 index 0000000000..809c974f9f --- /dev/null +++ b/src/third_party/cppcodec/test/catch/include/internal/catch_test_case_info.h @@ -0,0 +1,90 @@ +/* + * Created by Phil on 29/10/2010. + * Copyright 2010 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_CATCH_TEST_CASE_INFO_H_INCLUDED +#define TWOBLUECUBES_CATCH_TEST_CASE_INFO_H_INCLUDED + +#include "catch_common.h" +#include "catch_test_registry.h" + +#include +#include +#include + +#ifdef __clang__ +#pragma clang diagnostic push +#pragma clang diagnostic ignored "-Wpadded" +#endif + +namespace Catch { + + struct ITestInvoker; + + struct TestCaseInfo { + enum SpecialProperties{ + None = 0, + IsHidden = 1 << 1, + ShouldFail = 1 << 2, + MayFail = 1 << 3, + Throws = 1 << 4, + NonPortable = 1 << 5, + Benchmark = 1 << 6 + }; + + TestCaseInfo( std::string const& _name, + std::string const& _className, + std::string const& _description, + std::vector const& _tags, + SourceLineInfo const& _lineInfo ); + + friend void setTags( TestCaseInfo& testCaseInfo, std::vector tags ); + + bool isHidden() const; + bool throws() const; + bool okToFail() const; + bool expectedToFail() const; + + std::string tagsAsString() const; + + std::string name; + std::string className; + std::string description; + std::vector tags; + std::vector lcaseTags; + SourceLineInfo lineInfo; + SpecialProperties properties; + }; + + class TestCase : public TestCaseInfo { + public: + + TestCase( ITestInvoker* testCase, TestCaseInfo&& info ); + + TestCase withName( std::string const& _newName ) const; + + void invoke() const; + + TestCaseInfo const& getTestCaseInfo() const; + + bool operator == ( TestCase const& other ) const; + bool operator < ( TestCase const& other ) const; + + private: + std::shared_ptr test; + }; + + TestCase makeTestCase( ITestInvoker* testCase, + std::string const& className, + NameAndTags const& nameAndTags, + SourceLineInfo const& lineInfo ); +} + +#ifdef __clang__ +#pragma clang diagnostic pop +#endif + +#endif // TWOBLUECUBES_CATCH_TEST_CASE_INFO_H_INCLUDED diff --git a/src/third_party/cppcodec/test/catch/include/internal/catch_test_case_registry_impl.cpp b/src/third_party/cppcodec/test/catch/include/internal/catch_test_case_registry_impl.cpp new file mode 100644 index 0000000000..a6b7f57039 --- /dev/null +++ b/src/third_party/cppcodec/test/catch/include/internal/catch_test_case_registry_impl.cpp @@ -0,0 +1,112 @@ +/* + * Created by Martin on 25/07/2017 + * + * 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) + */ + +#include "catch_test_case_registry_impl.h" + +#include "catch_context.h" +#include "catch_enforce.h" +#include "catch_interfaces_registry_hub.h" +#include "catch_random_number_generator.h" +#include "catch_string_manip.h" +#include "catch_test_case_info.h" + +#include + +namespace Catch { + + std::vector sortTests( IConfig const& config, std::vector const& unsortedTestCases ) { + + std::vector sorted = unsortedTestCases; + + switch( config.runOrder() ) { + case RunTests::InLexicographicalOrder: + std::sort( sorted.begin(), sorted.end() ); + break; + case RunTests::InRandomOrder: + seedRng( config ); + std::shuffle( sorted.begin(), sorted.end(), rng() ); + break; + case RunTests::InDeclarationOrder: + // already in declaration order + break; + } + return sorted; + } + bool matchTest( TestCase const& testCase, TestSpec const& testSpec, IConfig const& config ) { + return testSpec.matches( testCase ) && ( config.allowThrows() || !testCase.throws() ); + } + + void enforceNoDuplicateTestCases( std::vector const& functions ) { + std::set seenFunctions; + for( auto const& function : functions ) { + auto prev = seenFunctions.insert( function ); + CATCH_ENFORCE( prev.second, + "error: TEST_CASE( \"" << function.name << "\" ) already defined.\n" + << "\tFirst seen at " << prev.first->getTestCaseInfo().lineInfo << "\n" + << "\tRedefined at " << function.getTestCaseInfo().lineInfo ); + } + } + + std::vector filterTests( std::vector const& testCases, TestSpec const& testSpec, IConfig const& config ) { + std::vector filtered; + filtered.reserve( testCases.size() ); + for( auto const& testCase : testCases ) + if( matchTest( testCase, testSpec, config ) ) + filtered.push_back( testCase ); + return filtered; + } + std::vector const& getAllTestCasesSorted( IConfig const& config ) { + return getRegistryHub().getTestCaseRegistry().getAllTestsSorted( config ); + } + + void TestRegistry::registerTest( TestCase const& testCase ) { + std::string name = testCase.getTestCaseInfo().name; + if( name.empty() ) { + ReusableStringStream rss; + rss << "Anonymous test case " << ++m_unnamedCount; + return registerTest( testCase.withName( rss.str() ) ); + } + m_functions.push_back( testCase ); + } + + std::vector const& TestRegistry::getAllTests() const { + return m_functions; + } + std::vector const& TestRegistry::getAllTestsSorted( IConfig const& config ) const { + if( m_sortedFunctions.empty() ) + enforceNoDuplicateTestCases( m_functions ); + + if( m_currentSortOrder != config.runOrder() || m_sortedFunctions.empty() ) { + m_sortedFunctions = sortTests( config, m_functions ); + m_currentSortOrder = config.runOrder(); + } + return m_sortedFunctions; + } + + + + /////////////////////////////////////////////////////////////////////////// + TestInvokerAsFunction::TestInvokerAsFunction( void(*testAsFunction)() ) noexcept : m_testAsFunction( testAsFunction ) {} + + void TestInvokerAsFunction::invoke() const { + m_testAsFunction(); + } + + std::string extractClassName( StringRef const& classOrQualifiedMethodName ) { + std::string className = classOrQualifiedMethodName; + if( startsWith( className, '&' ) ) + { + std::size_t lastColons = className.rfind( "::" ); + std::size_t penultimateColons = className.rfind( "::", lastColons-1 ); + if( penultimateColons == std::string::npos ) + penultimateColons = 1; + className = className.substr( penultimateColons, lastColons-penultimateColons ); + } + return className; + } + +} // end namespace Catch diff --git a/src/third_party/cppcodec/test/catch/include/internal/catch_test_case_registry_impl.h b/src/third_party/cppcodec/test/catch/include/internal/catch_test_case_registry_impl.h new file mode 100644 index 0000000000..8dc5b0fe3b --- /dev/null +++ b/src/third_party/cppcodec/test/catch/include/internal/catch_test_case_registry_impl.h @@ -0,0 +1,69 @@ +/* + * Created by Phil on 7/1/2011 + * Copyright 2010 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_CATCH_TEST_CASE_REGISTRY_IMPL_HPP_INCLUDED +#define TWOBLUECUBES_CATCH_TEST_CASE_REGISTRY_IMPL_HPP_INCLUDED + +#include "catch_test_registry.h" +#include "catch_test_spec.h" +#include "catch_interfaces_config.h" + +#include +#include +#include +#include + +namespace Catch { + + class TestCase; + struct IConfig; + + std::vector sortTests( IConfig const& config, std::vector const& unsortedTestCases ); + bool matchTest( TestCase const& testCase, TestSpec const& testSpec, IConfig const& config ); + + void enforceNoDuplicateTestCases( std::vector const& functions ); + + std::vector filterTests( std::vector const& testCases, TestSpec const& testSpec, IConfig const& config ); + std::vector const& getAllTestCasesSorted( IConfig const& config ); + + class TestRegistry : public ITestCaseRegistry { + public: + virtual ~TestRegistry() = default; + + virtual void registerTest( TestCase const& testCase ); + + std::vector const& getAllTests() const override; + std::vector const& getAllTestsSorted( IConfig const& config ) const override; + + private: + std::vector m_functions; + mutable RunTests::InWhatOrder m_currentSortOrder = RunTests::InDeclarationOrder; + mutable std::vector m_sortedFunctions; + std::size_t m_unnamedCount = 0; + std::ios_base::Init m_ostreamInit; // Forces cout/ cerr to be initialised + }; + + /////////////////////////////////////////////////////////////////////////// + + class TestInvokerAsFunction : public ITestInvoker { + void(*m_testAsFunction)(); + public: + TestInvokerAsFunction( void(*testAsFunction)() ) noexcept; + + void invoke() const override; + }; + + + std::string extractClassName( StringRef const& classOrQualifiedMethodName ); + + /////////////////////////////////////////////////////////////////////////// + + +} // end namespace Catch + + +#endif // TWOBLUECUBES_CATCH_TEST_CASE_REGISTRY_IMPL_HPP_INCLUDED diff --git a/src/third_party/cppcodec/test/catch/include/internal/catch_test_case_tracker.cpp b/src/third_party/cppcodec/test/catch/include/internal/catch_test_case_tracker.cpp new file mode 100644 index 0000000000..c675943819 --- /dev/null +++ b/src/third_party/cppcodec/test/catch/include/internal/catch_test_case_tracker.cpp @@ -0,0 +1,287 @@ +/* + * Created by Martin on 19/07/2017 + * + * 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) + */ + +#include "catch_test_case_tracker.h" + +#include "catch_enforce.h" + +#include +#include +#include +#include +#include + +#if defined(__clang__) +# pragma clang diagnostic push +# pragma clang diagnostic ignored "-Wexit-time-destructors" +#endif + +namespace Catch { +namespace TestCaseTracking { + + NameAndLocation::NameAndLocation( std::string const& _name, SourceLineInfo const& _location ) + : name( _name ), + location( _location ) + {} + + + ITracker::~ITracker() = default; + + + TrackerContext& TrackerContext::instance() { + static TrackerContext s_instance; + return s_instance; + } + + ITracker& TrackerContext::startRun() { + m_rootTracker = std::make_shared( NameAndLocation( "{root}", CATCH_INTERNAL_LINEINFO ), *this, nullptr ); + m_currentTracker = nullptr; + m_runState = Executing; + return *m_rootTracker; + } + + void TrackerContext::endRun() { + m_rootTracker.reset(); + m_currentTracker = nullptr; + m_runState = NotStarted; + } + + void TrackerContext::startCycle() { + m_currentTracker = m_rootTracker.get(); + m_runState = Executing; + } + void TrackerContext::completeCycle() { + m_runState = CompletedCycle; + } + + bool TrackerContext::completedCycle() const { + return m_runState == CompletedCycle; + } + ITracker& TrackerContext::currentTracker() { + return *m_currentTracker; + } + void TrackerContext::setCurrentTracker( ITracker* tracker ) { + m_currentTracker = tracker; + } + + + + TrackerBase::TrackerHasName::TrackerHasName( NameAndLocation const& nameAndLocation ) : m_nameAndLocation( nameAndLocation ) {} + bool TrackerBase::TrackerHasName::operator ()( ITrackerPtr const& tracker ) const { + return + tracker->nameAndLocation().location == m_nameAndLocation.location && + tracker->nameAndLocation().name == m_nameAndLocation.name; + } + + TrackerBase::TrackerBase( NameAndLocation const& nameAndLocation, TrackerContext& ctx, ITracker* parent ) + : m_nameAndLocation( nameAndLocation ), + m_ctx( ctx ), + m_parent( parent ) + {} + + NameAndLocation const& TrackerBase::nameAndLocation() const { + return m_nameAndLocation; + } + bool TrackerBase::isComplete() const { + return m_runState == CompletedSuccessfully || m_runState == Failed; + } + bool TrackerBase::isSuccessfullyCompleted() const { + return m_runState == CompletedSuccessfully; + } + bool TrackerBase::isOpen() const { + return m_runState != NotStarted && !isComplete(); + } + bool TrackerBase::hasChildren() const { + return !m_children.empty(); + } + + + void TrackerBase::addChild( ITrackerPtr const& child ) { + m_children.push_back( child ); + } + + ITrackerPtr TrackerBase::findChild( NameAndLocation const& nameAndLocation ) { + auto it = std::find_if( m_children.begin(), m_children.end(), TrackerHasName( nameAndLocation ) ); + return( it != m_children.end() ) + ? *it + : nullptr; + } + ITracker& TrackerBase::parent() { + assert( m_parent ); // Should always be non-null except for root + return *m_parent; + } + + void TrackerBase::openChild() { + if( m_runState != ExecutingChildren ) { + m_runState = ExecutingChildren; + if( m_parent ) + m_parent->openChild(); + } + } + + bool TrackerBase::isSectionTracker() const { return false; } + bool TrackerBase::isIndexTracker() const { return false; } + + void TrackerBase::open() { + m_runState = Executing; + moveToThis(); + if( m_parent ) + m_parent->openChild(); + } + + void TrackerBase::close() { + + // Close any still open children (e.g. generators) + while( &m_ctx.currentTracker() != this ) + m_ctx.currentTracker().close(); + + switch( m_runState ) { + case NeedsAnotherRun: + break; + + case Executing: + m_runState = CompletedSuccessfully; + break; + case ExecutingChildren: + if( m_children.empty() || m_children.back()->isComplete() ) + m_runState = CompletedSuccessfully; + break; + + case NotStarted: + case CompletedSuccessfully: + case Failed: + CATCH_INTERNAL_ERROR( "Illogical state: " << m_runState ); + + default: + CATCH_INTERNAL_ERROR( "Unknown state: " << m_runState ); + } + moveToParent(); + m_ctx.completeCycle(); + } + void TrackerBase::fail() { + m_runState = Failed; + if( m_parent ) + m_parent->markAsNeedingAnotherRun(); + moveToParent(); + m_ctx.completeCycle(); + } + void TrackerBase::markAsNeedingAnotherRun() { + m_runState = NeedsAnotherRun; + } + + void TrackerBase::moveToParent() { + assert( m_parent ); + m_ctx.setCurrentTracker( m_parent ); + } + void TrackerBase::moveToThis() { + m_ctx.setCurrentTracker( this ); + } + + SectionTracker::SectionTracker( NameAndLocation const& nameAndLocation, TrackerContext& ctx, ITracker* parent ) + : TrackerBase( nameAndLocation, ctx, parent ) + { + if( parent ) { + while( !parent->isSectionTracker() ) + parent = &parent->parent(); + + SectionTracker& parentSection = static_cast( *parent ); + addNextFilters( parentSection.m_filters ); + } + } + + bool SectionTracker::isSectionTracker() const { return true; } + + SectionTracker& SectionTracker::acquire( TrackerContext& ctx, NameAndLocation const& nameAndLocation ) { + std::shared_ptr section; + + ITracker& currentTracker = ctx.currentTracker(); + if( ITrackerPtr childTracker = currentTracker.findChild( nameAndLocation ) ) { + assert( childTracker ); + assert( childTracker->isSectionTracker() ); + section = std::static_pointer_cast( childTracker ); + } + else { + section = std::make_shared( nameAndLocation, ctx, ¤tTracker ); + currentTracker.addChild( section ); + } + if( !ctx.completedCycle() ) + section->tryOpen(); + return *section; + } + + void SectionTracker::tryOpen() { + if( !isComplete() && (m_filters.empty() || m_filters[0].empty() || m_filters[0] == m_nameAndLocation.name ) ) + open(); + } + + void SectionTracker::addInitialFilters( std::vector const& filters ) { + if( !filters.empty() ) { + m_filters.push_back(""); // Root - should never be consulted + m_filters.push_back(""); // Test Case - not a section filter + m_filters.insert( m_filters.end(), filters.begin(), filters.end() ); + } + } + void SectionTracker::addNextFilters( std::vector const& filters ) { + if( filters.size() > 1 ) + m_filters.insert( m_filters.end(), ++filters.begin(), filters.end() ); + } + + IndexTracker::IndexTracker( NameAndLocation const& nameAndLocation, TrackerContext& ctx, ITracker* parent, int size ) + : TrackerBase( nameAndLocation, ctx, parent ), + m_size( size ) + {} + + bool IndexTracker::isIndexTracker() const { return true; } + + IndexTracker& IndexTracker::acquire( TrackerContext& ctx, NameAndLocation const& nameAndLocation, int size ) { + std::shared_ptr tracker; + + ITracker& currentTracker = ctx.currentTracker(); + if( ITrackerPtr childTracker = currentTracker.findChild( nameAndLocation ) ) { + assert( childTracker ); + assert( childTracker->isIndexTracker() ); + tracker = std::static_pointer_cast( childTracker ); + } + else { + tracker = std::make_shared( nameAndLocation, ctx, ¤tTracker, size ); + currentTracker.addChild( tracker ); + } + + if( !ctx.completedCycle() && !tracker->isComplete() ) { + if( tracker->m_runState != ExecutingChildren && tracker->m_runState != NeedsAnotherRun ) + tracker->moveNext(); + tracker->open(); + } + + return *tracker; + } + + int IndexTracker::index() const { return m_index; } + + void IndexTracker::moveNext() { + m_index++; + m_children.clear(); + } + + void IndexTracker::close() { + TrackerBase::close(); + if( m_runState == CompletedSuccessfully && m_index < m_size-1 ) + m_runState = Executing; + } + +} // namespace TestCaseTracking + +using TestCaseTracking::ITracker; +using TestCaseTracking::TrackerContext; +using TestCaseTracking::SectionTracker; +using TestCaseTracking::IndexTracker; + +} // namespace Catch + +#if defined(__clang__) +# pragma clang diagnostic pop +#endif diff --git a/src/third_party/cppcodec/test/catch/include/internal/catch_test_case_tracker.h b/src/third_party/cppcodec/test/catch/include/internal/catch_test_case_tracker.h new file mode 100644 index 0000000000..a4b0440a3f --- /dev/null +++ b/src/third_party/cppcodec/test/catch/include/internal/catch_test_case_tracker.h @@ -0,0 +1,183 @@ +/* + * Created by Phil Nash on 23/7/2013 + * Copyright 2013 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_CATCH_TEST_CASE_TRACKER_HPP_INCLUDED +#define TWOBLUECUBES_CATCH_TEST_CASE_TRACKER_HPP_INCLUDED + +#include "catch_compiler_capabilities.h" +#include "catch_common.h" + +#include +#include +#include + +namespace Catch { +namespace TestCaseTracking { + + struct NameAndLocation { + std::string name; + SourceLineInfo location; + + NameAndLocation( std::string const& _name, SourceLineInfo const& _location ); + }; + + struct ITracker; + + using ITrackerPtr = std::shared_ptr; + + struct ITracker { + virtual ~ITracker(); + + // static queries + virtual NameAndLocation const& nameAndLocation() const = 0; + + // dynamic queries + virtual bool isComplete() const = 0; // Successfully completed or failed + virtual bool isSuccessfullyCompleted() const = 0; + virtual bool isOpen() const = 0; // Started but not complete + virtual bool hasChildren() const = 0; + + virtual ITracker& parent() = 0; + + // actions + virtual void close() = 0; // Successfully complete + virtual void fail() = 0; + virtual void markAsNeedingAnotherRun() = 0; + + virtual void addChild( ITrackerPtr const& child ) = 0; + virtual ITrackerPtr findChild( NameAndLocation const& nameAndLocation ) = 0; + virtual void openChild() = 0; + + // Debug/ checking + virtual bool isSectionTracker() const = 0; + virtual bool isIndexTracker() const = 0; + }; + + class TrackerContext { + + enum RunState { + NotStarted, + Executing, + CompletedCycle + }; + + ITrackerPtr m_rootTracker; + ITracker* m_currentTracker = nullptr; + RunState m_runState = NotStarted; + + public: + + static TrackerContext& instance(); + + ITracker& startRun(); + void endRun(); + + void startCycle(); + void completeCycle(); + + bool completedCycle() const; + ITracker& currentTracker(); + void setCurrentTracker( ITracker* tracker ); + }; + + class TrackerBase : public ITracker { + protected: + enum CycleState { + NotStarted, + Executing, + ExecutingChildren, + NeedsAnotherRun, + CompletedSuccessfully, + Failed + }; + + class TrackerHasName { + NameAndLocation m_nameAndLocation; + public: + TrackerHasName( NameAndLocation const& nameAndLocation ); + bool operator ()( ITrackerPtr const& tracker ) const; + }; + + using Children = std::vector; + NameAndLocation m_nameAndLocation; + TrackerContext& m_ctx; + ITracker* m_parent; + Children m_children; + CycleState m_runState = NotStarted; + + public: + TrackerBase( NameAndLocation const& nameAndLocation, TrackerContext& ctx, ITracker* parent ); + + NameAndLocation const& nameAndLocation() const override; + bool isComplete() const override; + bool isSuccessfullyCompleted() const override; + bool isOpen() const override; + bool hasChildren() const override; + + + void addChild( ITrackerPtr const& child ) override; + + ITrackerPtr findChild( NameAndLocation const& nameAndLocation ) override; + ITracker& parent() override; + + void openChild() override; + + bool isSectionTracker() const override; + bool isIndexTracker() const override; + + void open(); + + void close() override; + void fail() override; + void markAsNeedingAnotherRun() override; + + private: + void moveToParent(); + void moveToThis(); + }; + + class SectionTracker : public TrackerBase { + std::vector m_filters; + public: + SectionTracker( NameAndLocation const& nameAndLocation, TrackerContext& ctx, ITracker* parent ); + + bool isSectionTracker() const override; + + static SectionTracker& acquire( TrackerContext& ctx, NameAndLocation const& nameAndLocation ); + + void tryOpen(); + + void addInitialFilters( std::vector const& filters ); + void addNextFilters( std::vector const& filters ); + }; + + class IndexTracker : public TrackerBase { + int m_size; + int m_index = -1; + public: + IndexTracker( NameAndLocation const& nameAndLocation, TrackerContext& ctx, ITracker* parent, int size ); + + bool isIndexTracker() const override; + void close() override; + + static IndexTracker& acquire( TrackerContext& ctx, NameAndLocation const& nameAndLocation, int size ); + + int index() const; + + void moveNext(); + }; + +} // namespace TestCaseTracking + +using TestCaseTracking::ITracker; +using TestCaseTracking::TrackerContext; +using TestCaseTracking::SectionTracker; +using TestCaseTracking::IndexTracker; + +} // namespace Catch + +#endif // TWOBLUECUBES_CATCH_TEST_CASE_TRACKER_HPP_INCLUDED diff --git a/src/third_party/cppcodec/test/catch/include/internal/catch_test_registry.cpp b/src/third_party/cppcodec/test/catch/include/internal/catch_test_registry.cpp new file mode 100644 index 0000000000..ac83f33327 --- /dev/null +++ b/src/third_party/cppcodec/test/catch/include/internal/catch_test_registry.cpp @@ -0,0 +1,36 @@ +/* + * Created by Martin on 25/07/2017. + * + * 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) + */ + +#include "catch_test_registry.h" +#include "catch_test_case_registry_impl.h" +#include "catch_interfaces_registry_hub.h" + +namespace Catch { + + auto makeTestInvoker( void(*testAsFunction)() ) noexcept -> ITestInvoker* { + return new(std::nothrow) TestInvokerAsFunction( testAsFunction ); + } + + NameAndTags::NameAndTags( StringRef const& name_ , StringRef const& tags_ ) noexcept : name( name_ ), tags( tags_ ) {} + + AutoReg::AutoReg( ITestInvoker* invoker, SourceLineInfo const& lineInfo, StringRef const& classOrMethod, NameAndTags const& nameAndTags ) noexcept { + try { + getMutableRegistryHub() + .registerTest( + makeTestCase( + invoker, + extractClassName( classOrMethod ), + nameAndTags, + lineInfo)); + } catch (...) { + // Do not throw when constructing global objects, instead register the exception to be processed later + getMutableRegistryHub().registerStartupException(); + } + } + + AutoReg::~AutoReg() = default; +} diff --git a/src/third_party/cppcodec/test/catch/include/internal/catch_test_registry.h b/src/third_party/cppcodec/test/catch/include/internal/catch_test_registry.h new file mode 100644 index 0000000000..7130448348 --- /dev/null +++ b/src/third_party/cppcodec/test/catch/include/internal/catch_test_registry.h @@ -0,0 +1,105 @@ +/* + * Created by Phil on 18/10/2010. + * Copyright 2010 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_CATCH_TEST_REGISTRY_HPP_INCLUDED +#define TWOBLUECUBES_CATCH_TEST_REGISTRY_HPP_INCLUDED + +#include "catch_common.h" +#include "catch_interfaces_testcase.h" +#include "catch_compiler_capabilities.h" +#include "catch_stringref.h" + +namespace Catch { + +template +class TestInvokerAsMethod : public ITestInvoker { + void (C::*m_testAsMethod)(); +public: + TestInvokerAsMethod( void (C::*testAsMethod)() ) noexcept : m_testAsMethod( testAsMethod ) {} + + void invoke() const override { + C obj; + (obj.*m_testAsMethod)(); + } +}; + +auto makeTestInvoker( void(*testAsFunction)() ) noexcept -> ITestInvoker*; + +template +auto makeTestInvoker( void (C::*testAsMethod)() ) noexcept -> ITestInvoker* { + return new(std::nothrow) TestInvokerAsMethod( testAsMethod ); +} + +struct NameAndTags { + NameAndTags( StringRef const& name_ = StringRef(), StringRef const& tags_ = StringRef() ) noexcept; + StringRef name; + StringRef tags; +}; + +struct AutoReg : NonCopyable { + AutoReg( ITestInvoker* invoker, SourceLineInfo const& lineInfo, StringRef const& classOrMethod, NameAndTags const& nameAndTags ) noexcept; + ~AutoReg(); +}; + +} // end namespace Catch + +#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 + +#if defined(CATCH_CONFIG_DISABLE) + #define INTERNAL_CATCH_TESTCASE_NO_REGISTRATION( TestName, ... ) \ + static void TestName() + #define INTERNAL_CATCH_TESTCASE_METHOD_NO_REGISTRATION( TestName, ClassName, ... ) \ + namespace{ \ + struct TestName : INTERNAL_CATCH_EXPAND1(INTERNAL_CATCH_DEF ClassName) { \ + void test(); \ + }; \ + } \ + void TestName::test() + +#endif + + /////////////////////////////////////////////////////////////////////////////// + #define INTERNAL_CATCH_TESTCASE2( TestName, ... ) \ + static void TestName(); \ + CATCH_INTERNAL_SUPPRESS_GLOBALS_WARNINGS \ + namespace{ Catch::AutoReg INTERNAL_CATCH_UNIQUE_NAME( autoRegistrar )( Catch::makeTestInvoker( &TestName ), CATCH_INTERNAL_LINEINFO, Catch::StringRef(), Catch::NameAndTags{ __VA_ARGS__ } ); } /* NOLINT */ \ + CATCH_INTERNAL_UNSUPPRESS_GLOBALS_WARNINGS \ + static void TestName() + #define INTERNAL_CATCH_TESTCASE( ... ) \ + INTERNAL_CATCH_TESTCASE2( INTERNAL_CATCH_UNIQUE_NAME( ____C_A_T_C_H____T_E_S_T____ ), __VA_ARGS__ ) + + /////////////////////////////////////////////////////////////////////////////// + #define INTERNAL_CATCH_METHOD_AS_TEST_CASE( QualifiedMethod, ... ) \ + CATCH_INTERNAL_SUPPRESS_GLOBALS_WARNINGS \ + namespace{ Catch::AutoReg INTERNAL_CATCH_UNIQUE_NAME( autoRegistrar )( Catch::makeTestInvoker( &QualifiedMethod ), CATCH_INTERNAL_LINEINFO, "&" #QualifiedMethod, Catch::NameAndTags{ __VA_ARGS__ } ); } /* NOLINT */ \ + CATCH_INTERNAL_UNSUPPRESS_GLOBALS_WARNINGS + + /////////////////////////////////////////////////////////////////////////////// + #define INTERNAL_CATCH_TEST_CASE_METHOD2( TestName, ClassName, ... )\ + CATCH_INTERNAL_SUPPRESS_GLOBALS_WARNINGS \ + namespace{ \ + struct TestName : INTERNAL_CATCH_EXPAND1(INTERNAL_CATCH_DEF ClassName) { \ + void test(); \ + }; \ + Catch::AutoReg INTERNAL_CATCH_UNIQUE_NAME( autoRegistrar ) ( Catch::makeTestInvoker( &TestName::test ), CATCH_INTERNAL_LINEINFO, #ClassName, Catch::NameAndTags{ __VA_ARGS__ } ); /* NOLINT */ \ + } \ + CATCH_INTERNAL_UNSUPPRESS_GLOBALS_WARNINGS \ + void TestName::test() + #define INTERNAL_CATCH_TEST_CASE_METHOD( ClassName, ... ) \ + INTERNAL_CATCH_TEST_CASE_METHOD2( INTERNAL_CATCH_UNIQUE_NAME( ____C_A_T_C_H____T_E_S_T____ ), ClassName, __VA_ARGS__ ) + + /////////////////////////////////////////////////////////////////////////////// + #define INTERNAL_CATCH_REGISTER_TESTCASE( Function, ... ) \ + CATCH_INTERNAL_SUPPRESS_GLOBALS_WARNINGS \ + Catch::AutoReg INTERNAL_CATCH_UNIQUE_NAME( autoRegistrar )( Catch::makeTestInvoker( Function ), CATCH_INTERNAL_LINEINFO, Catch::StringRef(), Catch::NameAndTags{ __VA_ARGS__ } ); /* NOLINT */ \ + CATCH_INTERNAL_UNSUPPRESS_GLOBALS_WARNINGS + + +#endif // TWOBLUECUBES_CATCH_TEST_REGISTRY_HPP_INCLUDED diff --git a/src/third_party/cppcodec/test/catch/include/internal/catch_test_spec.cpp b/src/third_party/cppcodec/test/catch/include/internal/catch_test_spec.cpp new file mode 100644 index 0000000000..d9c149d501 --- /dev/null +++ b/src/third_party/cppcodec/test/catch/include/internal/catch_test_spec.cpp @@ -0,0 +1,59 @@ +/* + * Created by Martin on 19/07/2017. + * + * 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) + */ + +#include "catch_test_spec.h" +#include "catch_string_manip.h" + +#include +#include +#include +#include + +namespace Catch { + + TestSpec::Pattern::~Pattern() = default; + TestSpec::NamePattern::~NamePattern() = default; + TestSpec::TagPattern::~TagPattern() = default; + TestSpec::ExcludedPattern::~ExcludedPattern() = default; + + TestSpec::NamePattern::NamePattern( std::string const& name ) + : m_wildcardPattern( toLower( name ), CaseSensitive::No ) + {} + bool TestSpec::NamePattern::matches( TestCaseInfo const& testCase ) const { + return m_wildcardPattern.matches( toLower( testCase.name ) ); + } + + TestSpec::TagPattern::TagPattern( std::string const& tag ) : m_tag( toLower( tag ) ) {} + bool TestSpec::TagPattern::matches( TestCaseInfo const& testCase ) const { + return std::find(begin(testCase.lcaseTags), + end(testCase.lcaseTags), + m_tag) != end(testCase.lcaseTags); + } + + TestSpec::ExcludedPattern::ExcludedPattern( PatternPtr const& underlyingPattern ) : m_underlyingPattern( underlyingPattern ) {} + bool TestSpec::ExcludedPattern::matches( TestCaseInfo const& testCase ) const { return !m_underlyingPattern->matches( testCase ); } + + bool TestSpec::Filter::matches( TestCaseInfo const& testCase ) const { + // All patterns in a filter must match for the filter to be a match + for( auto const& pattern : m_patterns ) { + if( !pattern->matches( testCase ) ) + return false; + } + return true; + } + + bool TestSpec::hasFilters() const { + return !m_filters.empty(); + } + bool TestSpec::matches( TestCaseInfo const& testCase ) const { + // A TestSpec matches if any filter matches + for( auto const& filter : m_filters ) + if( filter.matches( testCase ) ) + return true; + return false; + } +} diff --git a/src/third_party/cppcodec/test/catch/include/internal/catch_test_spec.h b/src/third_party/cppcodec/test/catch/include/internal/catch_test_spec.h new file mode 100644 index 0000000000..baf8b0193b --- /dev/null +++ b/src/third_party/cppcodec/test/catch/include/internal/catch_test_spec.h @@ -0,0 +1,80 @@ +/* + * Created by Phil on 14/8/2012. + * Copyright 2010 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_CATCH_TEST_SPEC_HPP_INCLUDED +#define TWOBLUECUBES_CATCH_TEST_SPEC_HPP_INCLUDED + +#ifdef __clang__ +#pragma clang diagnostic push +#pragma clang diagnostic ignored "-Wpadded" +#endif + +#include "catch_wildcard_pattern.h" +#include "catch_test_case_info.h" + +#include +#include +#include + +namespace Catch { + + class TestSpec { + struct Pattern { + virtual ~Pattern(); + virtual bool matches( TestCaseInfo const& testCase ) const = 0; + }; + using PatternPtr = std::shared_ptr; + + class NamePattern : public Pattern { + public: + NamePattern( std::string const& name ); + virtual ~NamePattern(); + virtual bool matches( TestCaseInfo const& testCase ) const override; + private: + WildcardPattern m_wildcardPattern; + }; + + class TagPattern : public Pattern { + public: + TagPattern( std::string const& tag ); + virtual ~TagPattern(); + virtual bool matches( TestCaseInfo const& testCase ) const override; + private: + std::string m_tag; + }; + + class ExcludedPattern : public Pattern { + public: + ExcludedPattern( PatternPtr const& underlyingPattern ); + virtual ~ExcludedPattern(); + virtual bool matches( TestCaseInfo const& testCase ) const override; + private: + PatternPtr m_underlyingPattern; + }; + + struct Filter { + std::vector m_patterns; + + bool matches( TestCaseInfo const& testCase ) const; + }; + + public: + bool hasFilters() const; + bool matches( TestCaseInfo const& testCase ) const; + + private: + std::vector m_filters; + + friend class TestSpecParser; + }; +} + +#ifdef __clang__ +#pragma clang diagnostic pop +#endif + +#endif // TWOBLUECUBES_CATCH_TEST_SPEC_HPP_INCLUDED diff --git a/src/third_party/cppcodec/test/catch/include/internal/catch_test_spec_parser.cpp b/src/third_party/cppcodec/test/catch/include/internal/catch_test_spec_parser.cpp new file mode 100644 index 0000000000..61c9e4df02 --- /dev/null +++ b/src/third_party/cppcodec/test/catch/include/internal/catch_test_spec_parser.cpp @@ -0,0 +1,87 @@ +/* + * Created by Martin on 19/07/2017. + * + * 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) + */ + +#include "catch_test_spec_parser.h" + +namespace Catch { + + TestSpecParser::TestSpecParser( ITagAliasRegistry const& tagAliases ) : m_tagAliases( &tagAliases ) {} + + TestSpecParser& TestSpecParser::parse( std::string const& arg ) { + m_mode = None; + m_exclusion = false; + m_start = std::string::npos; + m_arg = m_tagAliases->expandAliases( arg ); + m_escapeChars.clear(); + for( m_pos = 0; m_pos < m_arg.size(); ++m_pos ) + visitChar( m_arg[m_pos] ); + if( m_mode == Name ) + addPattern(); + return *this; + } + TestSpec TestSpecParser::testSpec() { + addFilter(); + return m_testSpec; + } + + void TestSpecParser::visitChar( char c ) { + if( m_mode == None ) { + switch( c ) { + case ' ': return; + case '~': m_exclusion = true; return; + case '[': return startNewMode( Tag, ++m_pos ); + case '"': return startNewMode( QuotedName, ++m_pos ); + case '\\': return escape(); + default: startNewMode( Name, m_pos ); break; + } + } + if( m_mode == Name ) { + if( c == ',' ) { + addPattern(); + addFilter(); + } + else if( c == '[' ) { + if( subString() == "exclude:" ) + m_exclusion = true; + else + addPattern(); + startNewMode( Tag, ++m_pos ); + } + else if( c == '\\' ) + escape(); + } + else if( m_mode == EscapedName ) + m_mode = Name; + else if( m_mode == QuotedName && c == '"' ) + addPattern(); + else if( m_mode == Tag && c == ']' ) + addPattern(); + } + void TestSpecParser::startNewMode( Mode mode, std::size_t start ) { + m_mode = mode; + m_start = start; + } + void TestSpecParser::escape() { + if( m_mode == None ) + m_start = m_pos; + m_mode = EscapedName; + m_escapeChars.push_back( m_pos ); + } + std::string TestSpecParser::subString() const { return m_arg.substr( m_start, m_pos - m_start ); } + + void TestSpecParser::addFilter() { + if( !m_currentFilter.m_patterns.empty() ) { + m_testSpec.m_filters.push_back( m_currentFilter ); + m_currentFilter = TestSpec::Filter(); + } + } + + TestSpec parseTestSpec( std::string const& arg ) { + return TestSpecParser( ITagAliasRegistry::get() ).parse( arg ).testSpec(); + } + +} // namespace Catch diff --git a/src/third_party/cppcodec/test/catch/include/internal/catch_test_spec_parser.h b/src/third_party/cppcodec/test/catch/include/internal/catch_test_spec_parser.h new file mode 100644 index 0000000000..79ce889885 --- /dev/null +++ b/src/third_party/cppcodec/test/catch/include/internal/catch_test_spec_parser.h @@ -0,0 +1,75 @@ +/* + * Created by Phil on 15/5/2013. + * Copyright 2014 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_CATCH_TEST_SPEC_PARSER_HPP_INCLUDED +#define TWOBLUECUBES_CATCH_TEST_SPEC_PARSER_HPP_INCLUDED + +#ifdef __clang__ +#pragma clang diagnostic push +#pragma clang diagnostic ignored "-Wpadded" +#endif + +#include "catch_test_spec.h" +#include "catch_string_manip.h" +#include "catch_interfaces_tag_alias_registry.h" + +namespace Catch { + + class TestSpecParser { + enum Mode{ None, Name, QuotedName, Tag, EscapedName }; + Mode m_mode = None; + bool m_exclusion = false; + std::size_t m_start = std::string::npos, m_pos = 0; + std::string m_arg; + std::vector m_escapeChars; + TestSpec::Filter m_currentFilter; + TestSpec m_testSpec; + ITagAliasRegistry const* m_tagAliases = nullptr; + + public: + TestSpecParser( ITagAliasRegistry const& tagAliases ); + + TestSpecParser& parse( std::string const& arg ); + TestSpec testSpec(); + + private: + void visitChar( char c ); + void startNewMode( Mode mode, std::size_t start ); + void escape(); + std::string subString() const; + + template + void addPattern() { + std::string token = subString(); + for( std::size_t i = 0; i < m_escapeChars.size(); ++i ) + token = token.substr( 0, m_escapeChars[i]-m_start-i ) + token.substr( m_escapeChars[i]-m_start-i+1 ); + m_escapeChars.clear(); + if( startsWith( token, "exclude:" ) ) { + m_exclusion = true; + token = token.substr( 8 ); + } + if( !token.empty() ) { + TestSpec::PatternPtr pattern = std::make_shared( token ); + if( m_exclusion ) + pattern = std::make_shared( pattern ); + m_currentFilter.m_patterns.push_back( pattern ); + } + m_exclusion = false; + m_mode = None; + } + + void addFilter(); + }; + TestSpec parseTestSpec( std::string const& arg ); + +} // namespace Catch + +#ifdef __clang__ +#pragma clang diagnostic pop +#endif + +#endif // TWOBLUECUBES_CATCH_TEST_SPEC_PARSER_HPP_INCLUDED diff --git a/src/third_party/cppcodec/test/catch/include/internal/catch_text.h b/src/third_party/cppcodec/test/catch/include/internal/catch_text.h new file mode 100644 index 0000000000..eeafe8e2d1 --- /dev/null +++ b/src/third_party/cppcodec/test/catch/include/internal/catch_text.h @@ -0,0 +1,17 @@ +/* + * Created by Phil on 10/2/2014. + * Copyright 2014 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_CATCH_TEXT_H_INCLUDED +#define TWOBLUECUBES_CATCH_TEXT_H_INCLUDED + +#include "catch_clara.h" + +namespace Catch { + using namespace clara::TextFlow; +} + +#endif // TWOBLUECUBES_CATCH_TEXT_H_INCLUDED diff --git a/src/third_party/cppcodec/test/catch/include/internal/catch_timer.cpp b/src/third_party/cppcodec/test/catch/include/internal/catch_timer.cpp new file mode 100644 index 0000000000..d52c0085c0 --- /dev/null +++ b/src/third_party/cppcodec/test/catch/include/internal/catch_timer.cpp @@ -0,0 +1,74 @@ +/* + * Created by Phil on 05/08/2013. + * Copyright 2013 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) + */ + +#include "catch_timer.h" + +#include + +static const uint64_t nanosecondsInSecond = 1000000000; + +namespace Catch { + + auto getCurrentNanosecondsSinceEpoch() -> uint64_t { + return std::chrono::duration_cast( std::chrono::high_resolution_clock::now().time_since_epoch() ).count(); + } + + namespace { + auto estimateClockResolution() -> uint64_t { + uint64_t sum = 0; + static const uint64_t iterations = 1000000; + + auto startTime = getCurrentNanosecondsSinceEpoch(); + + for( std::size_t i = 0; i < iterations; ++i ) { + + uint64_t ticks; + uint64_t baseTicks = getCurrentNanosecondsSinceEpoch(); + do { + ticks = getCurrentNanosecondsSinceEpoch(); + } while( ticks == baseTicks ); + + auto delta = ticks - baseTicks; + sum += delta; + + // If we have been calibrating for over 3 seconds -- the clock + // is terrible and we should move on. + // TBD: How to signal that the measured resolution is probably wrong? + if (ticks > startTime + 3 * nanosecondsInSecond) { + return sum / i; + } + } + + // We're just taking the mean, here. To do better we could take the std. dev and exclude outliers + // - and potentially do more iterations if there's a high variance. + return sum/iterations; + } + } + auto getEstimatedClockResolution() -> uint64_t { + static auto s_resolution = estimateClockResolution(); + return s_resolution; + } + + void Timer::start() { + m_nanoseconds = getCurrentNanosecondsSinceEpoch(); + } + auto Timer::getElapsedNanoseconds() const -> uint64_t { + return getCurrentNanosecondsSinceEpoch() - m_nanoseconds; + } + auto Timer::getElapsedMicroseconds() const -> uint64_t { + return getElapsedNanoseconds()/1000; + } + auto Timer::getElapsedMilliseconds() const -> unsigned int { + return static_cast(getElapsedMicroseconds()/1000); + } + auto Timer::getElapsedSeconds() const -> double { + return getElapsedMicroseconds()/1000000.0; + } + + +} // namespace Catch diff --git a/src/third_party/cppcodec/test/catch/include/internal/catch_timer.h b/src/third_party/cppcodec/test/catch/include/internal/catch_timer.h new file mode 100644 index 0000000000..74ab428e46 --- /dev/null +++ b/src/third_party/cppcodec/test/catch/include/internal/catch_timer.h @@ -0,0 +1,30 @@ +/* + * Created by Phil on 05/08/2013. + * Copyright 2013 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_CATCH_TIMER_H_INCLUDED +#define TWOBLUECUBES_CATCH_TIMER_H_INCLUDED + +#include + +namespace Catch { + + auto getCurrentNanosecondsSinceEpoch() -> uint64_t; + auto getEstimatedClockResolution() -> uint64_t; + + class Timer { + uint64_t m_nanoseconds = 0; + public: + void start(); + auto getElapsedNanoseconds() const -> uint64_t; + auto getElapsedMicroseconds() const -> uint64_t; + auto getElapsedMilliseconds() const -> unsigned int; + auto getElapsedSeconds() const -> double; + }; + +} // namespace Catch + +#endif // TWOBLUECUBES_CATCH_TIMER_H_INCLUDED diff --git a/src/third_party/cppcodec/test/catch/include/internal/catch_to_string.hpp b/src/third_party/cppcodec/test/catch/include/internal/catch_to_string.hpp new file mode 100644 index 0000000000..3e2b587906 --- /dev/null +++ b/src/third_party/cppcodec/test/catch/include/internal/catch_to_string.hpp @@ -0,0 +1,28 @@ +/* + * Created by Martin on 9/5/2018. + * + * 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_CATCH_TO_STRING_H_INCLUDED +#define TWOBLUECUBES_CATCH_TO_STRING_H_INCLUDED + +#include + +#include "catch_compiler_capabilities.h" +#include "catch_stream.h" + +namespace Catch { + template + std::string to_string(T const& t) { +#if defined(CATCH_CONFIG_CPP11_TO_STRING) + return std::to_string(t); +#else + ReusableStringStream rss; + rss << t; + return rss.str(); +#endif + } +} // end namespace Catch + +#endif // TWOBLUECUBES_CATCH_TO_STRING_H_INCLUDED diff --git a/src/third_party/cppcodec/test/catch/include/internal/catch_tostring.cpp b/src/third_party/cppcodec/test/catch/include/internal/catch_tostring.cpp new file mode 100644 index 0000000000..61b29771c6 --- /dev/null +++ b/src/third_party/cppcodec/test/catch/include/internal/catch_tostring.cpp @@ -0,0 +1,244 @@ +/* + * Created by Phil on 23/4/2014. + * Copyright 2014 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) + */ + +#if defined(__clang__) +# pragma clang diagnostic push +# pragma clang diagnostic ignored "-Wexit-time-destructors" +# pragma clang diagnostic ignored "-Wglobal-constructors" +#endif + +// Enable specific decls locally +#if !defined(CATCH_CONFIG_ENABLE_CHRONO_STRINGMAKER) +#define CATCH_CONFIG_ENABLE_CHRONO_STRINGMAKER +#endif + +#include "catch_tostring.h" +#include "catch_interfaces_config.h" +#include "catch_context.h" + +#include +#include + +namespace Catch { + +namespace Detail { + + const std::string unprintableString = "{?}"; + + namespace { + const int hexThreshold = 255; + + struct Endianness { + enum Arch { Big, Little }; + + static Arch which() { + union _{ + int asInt; + char asChar[sizeof (int)]; + } u; + + u.asInt = 1; + return ( u.asChar[sizeof(int)-1] == 1 ) ? Big : Little; + } + }; + } + + std::string rawMemoryToString( const void *object, std::size_t size ) { + // Reverse order for little endian architectures + int i = 0, end = static_cast( size ), inc = 1; + if( Endianness::which() == Endianness::Little ) { + i = end-1; + end = inc = -1; + } + + unsigned char const *bytes = static_cast(object); + ReusableStringStream rss; + rss << "0x" << std::setfill('0') << std::hex; + for( ; i != end; i += inc ) + rss << std::setw(2) << static_cast(bytes[i]); + return rss.str(); + } +} + + +template +std::string fpToString( T value, int precision ) { + if (std::isnan(value)) { + return "nan"; + } + + ReusableStringStream rss; + rss << std::setprecision( precision ) + << std::fixed + << value; + std::string d = rss.str(); + std::size_t i = d.find_last_not_of( '0' ); + if( i != std::string::npos && i != d.size()-1 ) { + if( d[i] == '.' ) + i++; + d = d.substr( 0, i+1 ); + } + return d; +} + + +//// ======================================================= //// +// +// Out-of-line defs for full specialization of StringMaker +// +//// ======================================================= //// + +std::string StringMaker::convert(const std::string& str) { + if (!getCurrentContext().getConfig()->showInvisibles()) { + return '"' + str + '"'; + } + + std::string s("\""); + for (char c : str) { + switch (c) { + case '\n': + s.append("\\n"); + break; + case '\t': + s.append("\\t"); + break; + default: + s.push_back(c); + break; + } + } + s.append("\""); + return s; +} + +#ifdef CATCH_CONFIG_WCHAR +std::string StringMaker::convert(const std::wstring& wstr) { + std::string s; + s.reserve(wstr.size()); + for (auto c : wstr) { + s += (c <= 0xff) ? static_cast(c) : '?'; + } + return ::Catch::Detail::stringify(s); +} +#endif + +std::string StringMaker::convert(char const* str) { + if (str) { + return ::Catch::Detail::stringify(std::string{ str }); + } else { + return{ "{null string}" }; + } +} +std::string StringMaker::convert(char* str) { + if (str) { + return ::Catch::Detail::stringify(std::string{ str }); + } else { + return{ "{null string}" }; + } +} +#ifdef CATCH_CONFIG_WCHAR +std::string StringMaker::convert(wchar_t const * str) { + if (str) { + return ::Catch::Detail::stringify(std::wstring{ str }); + } else { + return{ "{null string}" }; + } +} +std::string StringMaker::convert(wchar_t * str) { + if (str) { + return ::Catch::Detail::stringify(std::wstring{ str }); + } else { + return{ "{null string}" }; + } +} +#endif + + +std::string StringMaker::convert(int value) { + return ::Catch::Detail::stringify(static_cast(value)); +} +std::string StringMaker::convert(long value) { + return ::Catch::Detail::stringify(static_cast(value)); +} +std::string StringMaker::convert(long long value) { + ReusableStringStream rss; + rss << value; + if (value > Detail::hexThreshold) { + rss << " (0x" << std::hex << value << ')'; + } + return rss.str(); +} + +std::string StringMaker::convert(unsigned int value) { + return ::Catch::Detail::stringify(static_cast(value)); +} +std::string StringMaker::convert(unsigned long value) { + return ::Catch::Detail::stringify(static_cast(value)); +} +std::string StringMaker::convert(unsigned long long value) { + ReusableStringStream rss; + rss << value; + if (value > Detail::hexThreshold) { + rss << " (0x" << std::hex << value << ')'; + } + return rss.str(); +} + + +std::string StringMaker::convert(bool b) { + return b ? "true" : "false"; +} + +std::string StringMaker::convert(char value) { + if (value == '\r') { + return "'\\r'"; + } else if (value == '\f') { + return "'\\f'"; + } else if (value == '\n') { + return "'\\n'"; + } else if (value == '\t') { + return "'\\t'"; + } else if ('\0' <= value && value < ' ') { + return ::Catch::Detail::stringify(static_cast(value)); + } else { + char chstr[] = "' '"; + chstr[1] = value; + return chstr; + } +} +std::string StringMaker::convert(signed char c) { + return ::Catch::Detail::stringify(static_cast(c)); +} +std::string StringMaker::convert(unsigned char c) { + return ::Catch::Detail::stringify(static_cast(c)); +} + +std::string StringMaker::convert(std::nullptr_t) { + return "nullptr"; +} + +std::string StringMaker::convert(float value) { + return fpToString(value, 5) + 'f'; +} +std::string StringMaker::convert(double value) { + return fpToString(value, 10); +} + +std::string ratio_string::symbol() { return "a"; } +std::string ratio_string::symbol() { return "f"; } +std::string ratio_string::symbol() { return "p"; } +std::string ratio_string::symbol() { return "n"; } +std::string ratio_string::symbol() { return "u"; } +std::string ratio_string::symbol() { return "m"; } + +} // end namespace Catch + +#if defined(__clang__) +# pragma clang diagnostic pop +#endif + diff --git a/src/third_party/cppcodec/test/catch/include/internal/catch_tostring.h b/src/third_party/cppcodec/test/catch/include/internal/catch_tostring.h new file mode 100644 index 0000000000..2aa06f4427 --- /dev/null +++ b/src/third_party/cppcodec/test/catch/include/internal/catch_tostring.h @@ -0,0 +1,590 @@ +/* + * Created by Phil on 8/5/2012. + * Copyright 2012 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_CATCH_TOSTRING_H_INCLUDED +#define TWOBLUECUBES_CATCH_TOSTRING_H_INCLUDED + + +#include +#include +#include +#include +#include "catch_compiler_capabilities.h" +#include "catch_stream.h" + +#ifdef __OBJC__ +#include "catch_objc_arc.hpp" +#endif + +#ifdef _MSC_VER +#pragma warning(push) +#pragma warning(disable:4180) // We attempt to stream a function (address) by const&, which MSVC complains about but is harmless +#endif + + +// 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 { + // Bring in operator<< from global namespace into Catch namespace + using ::operator<<; + + namespace Detail { + + extern const std::string unprintableString; + + std::string rawMemoryToString( const void *object, std::size_t size ); + + template + std::string rawMemoryToString( const T& object ) { + return rawMemoryToString( &object, sizeof(object) ); + } + + template + class IsStreamInsertable { + template + static auto test(int) + -> decltype(std::declval() << std::declval(), std::true_type()); + + template + static auto test(...)->std::false_type; + + public: + static const bool value = decltype(test(0))::value; + }; + + template + std::string convertUnknownEnumToString( E e ); + + template + typename std::enable_if< + !std::is_enum::value && !std::is_base_of::value, + std::string>::type convertUnstreamable( T const& ) { + return Detail::unprintableString; + } + template + typename std::enable_if< + !std::is_enum::value && std::is_base_of::value, + std::string>::type convertUnstreamable(T const& ex) { + return ex.what(); + } + + + template + typename std::enable_if< + std::is_enum::value + , std::string>::type convertUnstreamable( T const& value ) { + return convertUnknownEnumToString( value ); + } + +#if defined(_MANAGED) + //! Convert a CLR string to a utf8 std::string + template + std::string clrReferenceToString( T^ ref ) { + if (ref == nullptr) + return std::string("null"); + auto bytes = System::Text::Encoding::UTF8->GetBytes(ref->ToString()); + cli::pin_ptr p = &bytes[0]; + return std::string(reinterpret_cast(p), bytes->Length); + } +#endif + + } // namespace Detail + + + // If we decide for C++14, change these to enable_if_ts + template + struct StringMaker { + template + static + typename std::enable_if<::Catch::Detail::IsStreamInsertable::value, std::string>::type + convert(const Fake& value) { + ReusableStringStream rss; + // NB: call using the function-like syntax to avoid ambiguity with + // user-defined templated operator<< under clang. + rss.operator<<(value); + return rss.str(); + } + + template + static + typename std::enable_if::value, std::string>::type + convert( const Fake& value ) { +#if !defined(CATCH_CONFIG_FALLBACK_STRINGIFIER) + return Detail::convertUnstreamable(value); +#else + return CATCH_CONFIG_FALLBACK_STRINGIFIER(value); +#endif + } + }; + + namespace Detail { + + // This function dispatches all stringification requests inside of Catch. + // Should be preferably called fully qualified, like ::Catch::Detail::stringify + template + std::string stringify(const T& e) { + return ::Catch::StringMaker::type>::type>::convert(e); + } + + template + std::string convertUnknownEnumToString( E e ) { + return ::Catch::Detail::stringify(static_cast::type>(e)); + } + +#if defined(_MANAGED) + template + std::string stringify( T^ e ) { + return ::Catch::StringMaker::convert(e); + } +#endif + + } // namespace Detail + + // Some predefined specializations + + template<> + struct StringMaker { + static std::string convert(const std::string& str); + }; +#ifdef CATCH_CONFIG_WCHAR + template<> + struct StringMaker { + static std::string convert(const std::wstring& wstr); + }; +#endif + + template<> + struct StringMaker { + static std::string convert(char const * str); + }; + template<> + struct StringMaker { + static std::string convert(char * str); + }; + +#ifdef CATCH_CONFIG_WCHAR + template<> + struct StringMaker { + static std::string convert(wchar_t const * str); + }; + template<> + struct StringMaker { + static std::string convert(wchar_t * str); + }; +#endif + + // TBD: Should we use `strnlen` to ensure that we don't go out of the buffer, + // while keeping string semantics? + template + struct StringMaker { + static std::string convert(char const* str) { + return ::Catch::Detail::stringify(std::string{ str }); + } + }; + template + struct StringMaker { + static std::string convert(signed char const* str) { + return ::Catch::Detail::stringify(std::string{ reinterpret_cast(str) }); + } + }; + template + struct StringMaker { + static std::string convert(unsigned char const* str) { + return ::Catch::Detail::stringify(std::string{ reinterpret_cast(str) }); + } + }; + + template<> + struct StringMaker { + static std::string convert(int value); + }; + template<> + struct StringMaker { + static std::string convert(long value); + }; + template<> + struct StringMaker { + static std::string convert(long long value); + }; + template<> + struct StringMaker { + static std::string convert(unsigned int value); + }; + template<> + struct StringMaker { + static std::string convert(unsigned long value); + }; + template<> + struct StringMaker { + static std::string convert(unsigned long long value); + }; + + template<> + struct StringMaker { + static std::string convert(bool b); + }; + + template<> + struct StringMaker { + static std::string convert(char c); + }; + template<> + struct StringMaker { + static std::string convert(signed char c); + }; + template<> + struct StringMaker { + static std::string convert(unsigned char c); + }; + + template<> + struct StringMaker { + static std::string convert(std::nullptr_t); + }; + + template<> + struct StringMaker { + static std::string convert(float value); + }; + template<> + struct StringMaker { + static std::string convert(double value); + }; + + template + struct StringMaker { + template + static std::string convert(U* p) { + if (p) { + return ::Catch::Detail::rawMemoryToString(p); + } else { + return "nullptr"; + } + } + }; + + template + struct StringMaker { + static std::string convert(R C::* p) { + if (p) { + return ::Catch::Detail::rawMemoryToString(p); + } else { + return "nullptr"; + } + } + }; + +#if defined(_MANAGED) + template + struct StringMaker { + static std::string convert( T^ ref ) { + return ::Catch::Detail::clrReferenceToString(ref); + } + }; +#endif + + namespace Detail { + template + std::string rangeToString(InputIterator first, InputIterator last) { + ReusableStringStream rss; + rss << "{ "; + if (first != last) { + rss << ::Catch::Detail::stringify(*first); + for (++first; first != last; ++first) + rss << ", " << ::Catch::Detail::stringify(*first); + } + rss << " }"; + return rss.str(); + } + } + +#ifdef __OBJC__ + template<> + struct StringMaker { + static std::string convert(NSString * nsstring) { + if (!nsstring) + return "nil"; + return std::string("@") + [nsstring UTF8String]; + } + }; + template<> + struct StringMaker { + static std::string convert(NSObject* nsObject) { + return ::Catch::Detail::stringify([nsObject description]); + } + + }; + namespace Detail { + inline std::string stringify( NSString* nsstring ) { + return StringMaker::convert( nsstring ); + } + + } // namespace Detail +#endif // __OBJC__ + +} // namespace Catch + +////////////////////////////////////////////////////// +// Separate std-lib types stringification, so it can be selectively enabled +// This means that we do not bring in + +#if defined(CATCH_CONFIG_ENABLE_ALL_STRINGMAKERS) +# define CATCH_CONFIG_ENABLE_PAIR_STRINGMAKER +# define CATCH_CONFIG_ENABLE_TUPLE_STRINGMAKER +# define CATCH_CONFIG_ENABLE_CHRONO_STRINGMAKER +#endif + +// Separate std::pair specialization +#if defined(CATCH_CONFIG_ENABLE_PAIR_STRINGMAKER) +#include +namespace Catch { + template + struct StringMaker > { + static std::string convert(const std::pair& pair) { + ReusableStringStream rss; + rss << "{ " + << ::Catch::Detail::stringify(pair.first) + << ", " + << ::Catch::Detail::stringify(pair.second) + << " }"; + return rss.str(); + } + }; +} +#endif // CATCH_CONFIG_ENABLE_PAIR_STRINGMAKER + +// Separate std::tuple specialization +#if defined(CATCH_CONFIG_ENABLE_TUPLE_STRINGMAKER) +#include +namespace Catch { + namespace Detail { + template< + typename Tuple, + std::size_t N = 0, + bool = (N < std::tuple_size::value) + > + struct TupleElementPrinter { + static void print(const Tuple& tuple, std::ostream& os) { + os << (N ? ", " : " ") + << ::Catch::Detail::stringify(std::get(tuple)); + TupleElementPrinter::print(tuple, os); + } + }; + + template< + typename Tuple, + std::size_t N + > + struct TupleElementPrinter { + static void print(const Tuple&, std::ostream&) {} + }; + + } + + + template + struct StringMaker> { + static std::string convert(const std::tuple& tuple) { + ReusableStringStream rss; + rss << '{'; + Detail::TupleElementPrinter>::print(tuple, rss.get()); + rss << " }"; + return rss.str(); + } + }; +} +#endif // CATCH_CONFIG_ENABLE_TUPLE_STRINGMAKER + +namespace Catch { + struct not_this_one {}; // Tag type for detecting which begin/ end are being selected + + // Import begin/ end from std here so they are considered alongside the fallback (...) overloads in this namespace + using std::begin; + using std::end; + + not_this_one begin( ... ); + not_this_one end( ... ); + + template + struct is_range { + static const bool value = + !std::is_same())), not_this_one>::value && + !std::is_same())), not_this_one>::value; + }; + +#if defined(_MANAGED) // Managed types are never ranges + template + struct is_range { + static const bool value = false; + }; +#endif + + template + std::string rangeToString( Range const& range ) { + return ::Catch::Detail::rangeToString( begin( range ), end( range ) ); + } + + // Handle vector specially + template + std::string rangeToString( std::vector const& v ) { + ReusableStringStream rss; + rss << "{ "; + bool first = true; + for( bool b : v ) { + if( first ) + first = false; + else + rss << ", "; + rss << ::Catch::Detail::stringify( b ); + } + rss << " }"; + return rss.str(); + } + + template + struct StringMaker::value && !::Catch::Detail::IsStreamInsertable::value>::type> { + static std::string convert( R const& range ) { + return rangeToString( range ); + } + }; + + template + struct StringMaker { + static std::string convert(T const(&arr)[SZ]) { + return rangeToString(arr); + } + }; + + +} // namespace Catch + +// Separate std::chrono::duration specialization +#if defined(CATCH_CONFIG_ENABLE_CHRONO_STRINGMAKER) +#include +#include +#include + + +namespace Catch { + +template +struct ratio_string { + static std::string symbol(); +}; + +template +std::string ratio_string::symbol() { + Catch::ReusableStringStream rss; + rss << '[' << Ratio::num << '/' + << Ratio::den << ']'; + return rss.str(); +} +template <> +struct ratio_string { + static std::string symbol(); +}; +template <> +struct ratio_string { + static std::string symbol(); +}; +template <> +struct ratio_string { + static std::string symbol(); +}; +template <> +struct ratio_string { + static std::string symbol(); +}; +template <> +struct ratio_string { + static std::string symbol(); +}; +template <> +struct ratio_string { + static std::string symbol(); +}; + + //////////// + // std::chrono::duration specializations + template + struct StringMaker> { + static std::string convert(std::chrono::duration const& duration) { + ReusableStringStream rss; + rss << duration.count() << ' ' << ratio_string::symbol() << 's'; + return rss.str(); + } + }; + template + struct StringMaker>> { + static std::string convert(std::chrono::duration> const& duration) { + ReusableStringStream rss; + rss << duration.count() << " s"; + return rss.str(); + } + }; + template + struct StringMaker>> { + static std::string convert(std::chrono::duration> const& duration) { + ReusableStringStream rss; + rss << duration.count() << " m"; + return rss.str(); + } + }; + template + struct StringMaker>> { + static std::string convert(std::chrono::duration> const& duration) { + ReusableStringStream rss; + rss << duration.count() << " h"; + return rss.str(); + } + }; + + //////////// + // std::chrono::time_point specialization + // Generic time_point cannot be specialized, only std::chrono::time_point + template + struct StringMaker> { + static std::string convert(std::chrono::time_point const& time_point) { + return ::Catch::Detail::stringify(time_point.time_since_epoch()) + " since epoch"; + } + }; + // std::chrono::time_point specialization + template + struct StringMaker> { + static std::string convert(std::chrono::time_point const& time_point) { + auto converted = std::chrono::system_clock::to_time_t(time_point); + +#ifdef _MSC_VER + std::tm timeInfo = {}; + gmtime_s(&timeInfo, &converted); +#else + std::tm* timeInfo = std::gmtime(&converted); +#endif + + auto const timeStampSize = sizeof("2017-01-16T17:06:45Z"); + char timeStamp[timeStampSize]; + const char * const fmt = "%Y-%m-%dT%H:%M:%SZ"; + +#ifdef _MSC_VER + std::strftime(timeStamp, timeStampSize, fmt, &timeInfo); +#else + std::strftime(timeStamp, timeStampSize, fmt, timeInfo); +#endif + return std::string(timeStamp); + } + }; +} +#endif // CATCH_CONFIG_ENABLE_CHRONO_STRINGMAKER + + +#ifdef _MSC_VER +#pragma warning(pop) +#endif + +#endif // TWOBLUECUBES_CATCH_TOSTRING_H_INCLUDED diff --git a/src/third_party/cppcodec/test/catch/include/internal/catch_totals.cpp b/src/third_party/cppcodec/test/catch/include/internal/catch_totals.cpp new file mode 100644 index 0000000000..0391fe825b --- /dev/null +++ b/src/third_party/cppcodec/test/catch/include/internal/catch_totals.cpp @@ -0,0 +1,61 @@ +/* + * Created by Martin on 19/07/2017. + * + * 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) + */ + +#include "catch_totals.h" + +namespace Catch { + + Counts Counts::operator - ( Counts const& other ) const { + Counts diff; + diff.passed = passed - other.passed; + diff.failed = failed - other.failed; + diff.failedButOk = failedButOk - other.failedButOk; + return diff; + } + + Counts& Counts::operator += ( Counts const& other ) { + passed += other.passed; + failed += other.failed; + failedButOk += other.failedButOk; + return *this; + } + + std::size_t Counts::total() const { + return passed + failed + failedButOk; + } + bool Counts::allPassed() const { + return failed == 0 && failedButOk == 0; + } + bool Counts::allOk() const { + return failed == 0; + } + + Totals Totals::operator - ( Totals const& other ) const { + Totals diff; + diff.assertions = assertions - other.assertions; + diff.testCases = testCases - other.testCases; + return diff; + } + + Totals& Totals::operator += ( Totals const& other ) { + assertions += other.assertions; + testCases += other.testCases; + return *this; + } + + Totals Totals::delta( Totals const& prevTotals ) const { + Totals diff = *this - prevTotals; + if( diff.assertions.failed > 0 ) + ++diff.testCases.failed; + else if( diff.assertions.failedButOk > 0 ) + ++diff.testCases.failedButOk; + else + ++diff.testCases.passed; + return diff; + } + +} diff --git a/src/third_party/cppcodec/test/catch/include/internal/catch_totals.h b/src/third_party/cppcodec/test/catch/include/internal/catch_totals.h new file mode 100644 index 0000000000..5692728327 --- /dev/null +++ b/src/third_party/cppcodec/test/catch/include/internal/catch_totals.h @@ -0,0 +1,41 @@ +/* + * Created by Phil Nash on 23/02/2012. + * Copyright (c) 2012 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_CATCH_TOTALS_HPP_INCLUDED +#define TWOBLUECUBES_CATCH_TOTALS_HPP_INCLUDED + +#include + +namespace Catch { + + struct Counts { + Counts operator - ( Counts const& other ) const; + Counts& operator += ( Counts const& other ); + + std::size_t total() const; + bool allPassed() const; + bool allOk() const; + + std::size_t passed = 0; + std::size_t failed = 0; + std::size_t failedButOk = 0; + }; + + struct Totals { + + Totals operator - ( Totals const& other ) const; + Totals& operator += ( Totals const& other ); + + Totals delta( Totals const& prevTotals ) const; + + int error = 0; + Counts assertions; + Counts testCases; + }; +} + +#endif // TWOBLUECUBES_CATCH_TOTALS_HPP_INCLUDED diff --git a/src/third_party/cppcodec/test/catch/include/internal/catch_uncaught_exceptions.cpp b/src/third_party/cppcodec/test/catch/include/internal/catch_uncaught_exceptions.cpp new file mode 100644 index 0000000000..b990ccd8f3 --- /dev/null +++ b/src/third_party/cppcodec/test/catch/include/internal/catch_uncaught_exceptions.cpp @@ -0,0 +1,21 @@ +/* + * Created by Josh on 1/2/2018. + * Copyright 2018 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) + */ + +#include "catch_compiler_capabilities.h" +#include "catch_uncaught_exceptions.h" +#include + +namespace Catch { + bool uncaught_exceptions() { +#if defined(CATCH_CONFIG_CPP17_UNCAUGHT_EXCEPTIONS) + return std::uncaught_exceptions() > 0; +#else + return std::uncaught_exception(); +#endif + } +} // end namespace Catch diff --git a/src/third_party/cppcodec/test/catch/include/internal/catch_uncaught_exceptions.h b/src/third_party/cppcodec/test/catch/include/internal/catch_uncaught_exceptions.h new file mode 100644 index 0000000000..c68d680cc1 --- /dev/null +++ b/src/third_party/cppcodec/test/catch/include/internal/catch_uncaught_exceptions.h @@ -0,0 +1,15 @@ +/* + * Created by Josh on 1/2/2018. + * Copyright 2018 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_CATCH_UNCAUGHT_EXCEPTIONS_H_INCLUDED +#define TWOBLUECUBES_CATCH_UNCAUGHT_EXCEPTIONS_H_INCLUDED + +namespace Catch { + bool uncaught_exceptions(); +} // end namespace Catch + +#endif // TWOBLUECUBES_CATCH_UNCAUGHT_EXCEPTIONS_H_INCLUDED diff --git a/src/third_party/cppcodec/test/catch/include/internal/catch_user_interfaces.h b/src/third_party/cppcodec/test/catch/include/internal/catch_user_interfaces.h new file mode 100644 index 0000000000..35acb77b11 --- /dev/null +++ b/src/third_party/cppcodec/test/catch/include/internal/catch_user_interfaces.h @@ -0,0 +1,18 @@ +/* + * Created by Martin on 21/11/2017. + * + * This file collects declaration that we want to expose to test files. + * These declarations are expected to be duplicated elsewhere, + * together with their implementation. + * + * 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_CATCH_USER_INTERFACES_H_INCLUDED +#define TWOBLUECUBES_CATCH_USER_INTERFACES_H_INCLUDED + +namespace Catch { + unsigned int rngSeed(); +} + +#endif // TWOBLUECUBES_CATCH_USER_INTERFACES_H_INCLUDED diff --git a/src/third_party/cppcodec/test/catch/include/internal/catch_version.cpp b/src/third_party/cppcodec/test/catch/include/internal/catch_version.cpp new file mode 100644 index 0000000000..1585ff7a7c --- /dev/null +++ b/src/third_party/cppcodec/test/catch/include/internal/catch_version.cpp @@ -0,0 +1,44 @@ +/* + * Created by Phil on 14/11/2012. + * Copyright 2012 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) + */ + +#include "catch_version.h" +#include + +namespace Catch { + + Version::Version + ( unsigned int _majorVersion, + unsigned int _minorVersion, + unsigned int _patchNumber, + char const * const _branchName, + unsigned int _buildNumber ) + : majorVersion( _majorVersion ), + minorVersion( _minorVersion ), + patchNumber( _patchNumber ), + branchName( _branchName ), + buildNumber( _buildNumber ) + {} + + std::ostream& operator << ( std::ostream& os, Version const& version ) { + os << version.majorVersion << '.' + << version.minorVersion << '.' + << version.patchNumber; + // branchName is never null -> 0th char is \0 if it is empty + if (version.branchName[0]) { + os << '-' << version.branchName + << '.' << version.buildNumber; + } + return os; + } + + Version const& libraryVersion() { + static Version version( 2, 3, 0, "", 0 ); + return version; + } + +} diff --git a/src/third_party/cppcodec/test/catch/include/internal/catch_version.h b/src/third_party/cppcodec/test/catch/include/internal/catch_version.h new file mode 100644 index 0000000000..018397f402 --- /dev/null +++ b/src/third_party/cppcodec/test/catch/include/internal/catch_version.h @@ -0,0 +1,39 @@ +/* + * Created by Phil on 13/11/2012. + * Copyright 2012 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_CATCH_VERSION_H_INCLUDED +#define TWOBLUECUBES_CATCH_VERSION_H_INCLUDED + +#include + +namespace Catch { + + // Versioning information + struct Version { + Version( Version const& ) = delete; + Version& operator=( Version const& ) = delete; + Version( unsigned int _majorVersion, + unsigned int _minorVersion, + unsigned int _patchNumber, + char const * const _branchName, + unsigned int _buildNumber ); + + unsigned int const majorVersion; + unsigned int const minorVersion; + unsigned int const patchNumber; + + // buildNumber is only used if branchName is not null + char const * const branchName; + unsigned int const buildNumber; + + friend std::ostream& operator << ( std::ostream& os, Version const& version ); + }; + + Version const& libraryVersion(); +} + +#endif // TWOBLUECUBES_CATCH_VERSION_H_INCLUDED diff --git a/src/third_party/cppcodec/test/catch/include/internal/catch_wildcard_pattern.cpp b/src/third_party/cppcodec/test/catch/include/internal/catch_wildcard_pattern.cpp new file mode 100644 index 0000000000..9bf20f0440 --- /dev/null +++ b/src/third_party/cppcodec/test/catch/include/internal/catch_wildcard_pattern.cpp @@ -0,0 +1,49 @@ +/* + * Created by Martin on 19/07/2017. + * + * 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) + */ + +#include "catch_wildcard_pattern.h" +#include "catch_enforce.h" +#include "catch_string_manip.h" + +#include + +namespace Catch { + + WildcardPattern::WildcardPattern( std::string const& pattern, + CaseSensitive::Choice caseSensitivity ) + : m_caseSensitivity( caseSensitivity ), + m_pattern( adjustCase( pattern ) ) + { + if( startsWith( m_pattern, '*' ) ) { + m_pattern = m_pattern.substr( 1 ); + m_wildcard = WildcardAtStart; + } + if( endsWith( m_pattern, '*' ) ) { + m_pattern = m_pattern.substr( 0, m_pattern.size()-1 ); + m_wildcard = static_cast( m_wildcard | WildcardAtEnd ); + } + } + + bool WildcardPattern::matches( std::string const& str ) const { + switch( m_wildcard ) { + case NoWildcard: + return m_pattern == adjustCase( str ); + case WildcardAtStart: + return endsWith( adjustCase( str ), m_pattern ); + case WildcardAtEnd: + return startsWith( adjustCase( str ), m_pattern ); + case WildcardAtBothEnds: + return contains( adjustCase( str ), m_pattern ); + default: + CATCH_INTERNAL_ERROR( "Unknown enum" ); + } + } + + std::string WildcardPattern::adjustCase( std::string const& str ) const { + return m_caseSensitivity == CaseSensitive::No ? toLower( str ) : str; + } +} diff --git a/src/third_party/cppcodec/test/catch/include/internal/catch_wildcard_pattern.h b/src/third_party/cppcodec/test/catch/include/internal/catch_wildcard_pattern.h new file mode 100644 index 0000000000..4dae717140 --- /dev/null +++ b/src/third_party/cppcodec/test/catch/include/internal/catch_wildcard_pattern.h @@ -0,0 +1,38 @@ +/* + * Created by Phil on 13/7/2015. + * Copyright 2015 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_CATCH_WILDCARD_PATTERN_HPP_INCLUDED +#define TWOBLUECUBES_CATCH_WILDCARD_PATTERN_HPP_INCLUDED + +#include "catch_common.h" + + +namespace Catch +{ + class WildcardPattern { + enum WildcardPosition { + NoWildcard = 0, + WildcardAtStart = 1, + WildcardAtEnd = 2, + WildcardAtBothEnds = WildcardAtStart | WildcardAtEnd + }; + + public: + + WildcardPattern( std::string const& pattern, CaseSensitive::Choice caseSensitivity ); + virtual ~WildcardPattern() = default; + virtual bool matches( std::string const& str ) const; + + private: + std::string adjustCase( std::string const& str ) const; + CaseSensitive::Choice m_caseSensitivity; + WildcardPosition m_wildcard = NoWildcard; + std::string m_pattern; + }; +} + +#endif // TWOBLUECUBES_CATCH_WILDCARD_PATTERN_HPP_INCLUDED diff --git a/src/third_party/cppcodec/test/catch/include/internal/catch_windows_h_proxy.h b/src/third_party/cppcodec/test/catch/include/internal/catch_windows_h_proxy.h new file mode 100644 index 0000000000..a7a19c8ec4 --- /dev/null +++ b/src/third_party/cppcodec/test/catch/include/internal/catch_windows_h_proxy.h @@ -0,0 +1,39 @@ +/* + * Created by Martin on 16/01/2017. + * + * 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_CATCH_WINDOWS_H_PROXY_H_INCLUDED +#define TWOBLUECUBES_CATCH_WINDOWS_H_PROXY_H_INCLUDED + +#include "catch_platform.h" + +#if defined(CATCH_PLATFORM_WINDOWS) + +#if !defined(NOMINMAX) && !defined(CATCH_CONFIG_NO_NOMINMAX) +# define CATCH_DEFINED_NOMINMAX +# define NOMINMAX +#endif +#if !defined(WIN32_LEAN_AND_MEAN) && !defined(CATCH_CONFIG_NO_WIN32_LEAN_AND_MEAN) +# define CATCH_DEFINED_WIN32_LEAN_AND_MEAN +# define WIN32_LEAN_AND_MEAN +#endif + +#ifdef __AFXDLL +#include +#else +#include +#endif + +#ifdef CATCH_DEFINED_NOMINMAX +# undef NOMINMAX +#endif +#ifdef CATCH_DEFINED_WIN32_LEAN_AND_MEAN +# undef WIN32_LEAN_AND_MEAN +#endif + +#endif // defined(CATCH_PLATFORM_WINDOWS) + +#endif // TWOBLUECUBES_CATCH_WINDOWS_H_PROXY_H_INCLUDED diff --git a/src/third_party/cppcodec/test/catch/include/internal/catch_xmlwriter.cpp b/src/third_party/cppcodec/test/catch/include/internal/catch_xmlwriter.cpp new file mode 100644 index 0000000000..221f1c63cf --- /dev/null +++ b/src/third_party/cppcodec/test/catch/include/internal/catch_xmlwriter.cpp @@ -0,0 +1,284 @@ +/* + * Created by Phil on 19/07/2017. + * + * 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) + */ + +#include "catch_xmlwriter.h" + +#include "catch_enforce.h" + +#include + +using uchar = unsigned char; + +namespace Catch { + +namespace { + + size_t trailingBytes(unsigned char c) { + if ((c & 0xE0) == 0xC0) { + return 2; + } + if ((c & 0xF0) == 0xE0) { + return 3; + } + if ((c & 0xF8) == 0xF0) { + return 4; + } + CATCH_INTERNAL_ERROR("Invalid multibyte utf-8 start byte encountered"); + } + + uint32_t headerValue(unsigned char c) { + if ((c & 0xE0) == 0xC0) { + return c & 0x1F; + } + if ((c & 0xF0) == 0xE0) { + return c & 0x0F; + } + if ((c & 0xF8) == 0xF0) { + return c & 0x07; + } + CATCH_INTERNAL_ERROR("Invalid multibyte utf-8 start byte encountered"); + } + + void hexEscapeChar(std::ostream& os, unsigned char c) { + os << "\\x" + << std::uppercase << std::hex << std::setfill('0') << std::setw(2) + << static_cast(c); + } + +} // anonymous namespace + + XmlEncode::XmlEncode( std::string const& str, ForWhat forWhat ) + : m_str( str ), + m_forWhat( forWhat ) + {} + + void XmlEncode::encodeTo( std::ostream& os ) const { + // Apostrophe escaping not necessary if we always use " to write attributes + // (see: http://www.w3.org/TR/xml/#syntax) + + for( std::size_t idx = 0; idx < m_str.size(); ++ idx ) { + uchar c = m_str[idx]; + switch (c) { + case '<': os << "<"; break; + case '&': os << "&"; break; + + case '>': + // See: http://www.w3.org/TR/xml/#syntax + if (idx > 2 && m_str[idx - 1] == ']' && m_str[idx - 2] == ']') + os << ">"; + else + os << c; + break; + + case '\"': + if (m_forWhat == ForAttributes) + os << """; + else + os << c; + break; + + default: + // Check for control characters and invalid utf-8 + + // Escape control characters in standard ascii + // see http://stackoverflow.com/questions/404107/why-are-control-characters-illegal-in-xml-1-0 + if (c < 0x09 || (c > 0x0D && c < 0x20) || c == 0x7F) { + hexEscapeChar(os, c); + break; + } + + // Plain ASCII: Write it to stream + if (c < 0x7F) { + os << c; + break; + } + + // UTF-8 territory + // Check if the encoding is valid and if it is not, hex escape bytes. + // Important: We do not check the exact decoded values for validity, only the encoding format + // First check that this bytes is a valid lead byte: + // This means that it is not encoded as 1111 1XXX + // Or as 10XX XXXX + if (c < 0xC0 || + c >= 0xF8) { + hexEscapeChar(os, c); + break; + } + + auto encBytes = trailingBytes(c); + // Are there enough bytes left to avoid accessing out-of-bounds memory? + if (idx + encBytes - 1 >= m_str.size()) { + hexEscapeChar(os, c); + break; + } + // The header is valid, check data + // The next encBytes bytes must together be a valid utf-8 + // This means: bitpattern 10XX XXXX and the extracted value is sane (ish) + bool valid = true; + uint32_t value = headerValue(c); + for (std::size_t n = 1; n < encBytes; ++n) { + uchar nc = m_str[idx + n]; + valid &= ((nc & 0xC0) == 0x80); + value = (value << 6) | (nc & 0x3F); + } + + if ( + // Wrong bit pattern of following bytes + (!valid) || + // Overlong encodings + (value < 0x80) || + (0x80 <= value && value < 0x800 && encBytes > 2) || + (0x800 < value && value < 0x10000 && encBytes > 3) || + // Encoded value out of range + (value >= 0x110000) + ) { + hexEscapeChar(os, c); + break; + } + + // If we got here, this is in fact a valid(ish) utf-8 sequence + for (std::size_t n = 0; n < encBytes; ++n) { + os << m_str[idx + n]; + } + idx += encBytes - 1; + break; + } + } + } + + std::ostream& operator << ( std::ostream& os, XmlEncode const& xmlEncode ) { + xmlEncode.encodeTo( os ); + return os; + } + + XmlWriter::ScopedElement::ScopedElement( XmlWriter* writer ) + : m_writer( writer ) + {} + + XmlWriter::ScopedElement::ScopedElement( ScopedElement&& other ) noexcept + : m_writer( other.m_writer ){ + other.m_writer = nullptr; + } + XmlWriter::ScopedElement& XmlWriter::ScopedElement::operator=( ScopedElement&& other ) noexcept { + if ( m_writer ) { + m_writer->endElement(); + } + m_writer = other.m_writer; + other.m_writer = nullptr; + return *this; + } + + + XmlWriter::ScopedElement::~ScopedElement() { + if( m_writer ) + m_writer->endElement(); + } + + XmlWriter::ScopedElement& XmlWriter::ScopedElement::writeText( std::string const& text, bool indent ) { + m_writer->writeText( text, indent ); + return *this; + } + + XmlWriter::XmlWriter( std::ostream& os ) : m_os( os ) + { + writeDeclaration(); + } + + XmlWriter::~XmlWriter() { + while( !m_tags.empty() ) + endElement(); + } + + XmlWriter& XmlWriter::startElement( std::string const& name ) { + ensureTagClosed(); + newlineIfNecessary(); + m_os << m_indent << '<' << name; + m_tags.push_back( name ); + m_indent += " "; + m_tagIsOpen = true; + return *this; + } + + XmlWriter::ScopedElement XmlWriter::scopedElement( std::string const& name ) { + ScopedElement scoped( this ); + startElement( name ); + return scoped; + } + + XmlWriter& XmlWriter::endElement() { + newlineIfNecessary(); + m_indent = m_indent.substr( 0, m_indent.size()-2 ); + if( m_tagIsOpen ) { + m_os << "/>"; + m_tagIsOpen = false; + } + else { + m_os << m_indent << ""; + } + m_os << std::endl; + m_tags.pop_back(); + return *this; + } + + XmlWriter& XmlWriter::writeAttribute( std::string const& name, std::string const& attribute ) { + if( !name.empty() && !attribute.empty() ) + m_os << ' ' << name << "=\"" << XmlEncode( attribute, XmlEncode::ForAttributes ) << '"'; + return *this; + } + + XmlWriter& XmlWriter::writeAttribute( std::string const& name, bool attribute ) { + m_os << ' ' << name << "=\"" << ( attribute ? "true" : "false" ) << '"'; + return *this; + } + + XmlWriter& XmlWriter::writeText( std::string const& text, bool indent ) { + if( !text.empty() ){ + bool tagWasOpen = m_tagIsOpen; + ensureTagClosed(); + if( tagWasOpen && indent ) + m_os << m_indent; + m_os << XmlEncode( text ); + m_needsNewline = true; + } + return *this; + } + + XmlWriter& XmlWriter::writeComment( std::string const& text ) { + ensureTagClosed(); + m_os << m_indent << ""; + m_needsNewline = true; + return *this; + } + + void XmlWriter::writeStylesheetRef( std::string const& url ) { + m_os << "\n"; + } + + XmlWriter& XmlWriter::writeBlankLine() { + ensureTagClosed(); + m_os << '\n'; + return *this; + } + + void XmlWriter::ensureTagClosed() { + if( m_tagIsOpen ) { + m_os << ">" << std::endl; + m_tagIsOpen = false; + } + } + + void XmlWriter::writeDeclaration() { + m_os << "\n"; + } + + void XmlWriter::newlineIfNecessary() { + if( m_needsNewline ) { + m_os << std::endl; + m_needsNewline = false; + } + } +} diff --git a/src/third_party/cppcodec/test/catch/include/internal/catch_xmlwriter.h b/src/third_party/cppcodec/test/catch/include/internal/catch_xmlwriter.h new file mode 100644 index 0000000000..c4b1c035ab --- /dev/null +++ b/src/third_party/cppcodec/test/catch/include/internal/catch_xmlwriter.h @@ -0,0 +1,105 @@ +/* + * Created by Phil on 09/12/2010. + * Copyright 2010 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_CATCH_XMLWRITER_HPP_INCLUDED +#define TWOBLUECUBES_CATCH_XMLWRITER_HPP_INCLUDED + +#include "catch_stream.h" +#include "catch_compiler_capabilities.h" + +#include + +namespace Catch { + + class XmlEncode { + public: + enum ForWhat { ForTextNodes, ForAttributes }; + + XmlEncode( std::string const& str, ForWhat forWhat = ForTextNodes ); + + void encodeTo( std::ostream& os ) const; + + friend std::ostream& operator << ( std::ostream& os, XmlEncode const& xmlEncode ); + + private: + std::string m_str; + ForWhat m_forWhat; + }; + + class XmlWriter { + public: + + class ScopedElement { + public: + ScopedElement( XmlWriter* writer ); + + ScopedElement( ScopedElement&& other ) noexcept; + ScopedElement& operator=( ScopedElement&& other ) noexcept; + + ~ScopedElement(); + + ScopedElement& writeText( std::string const& text, bool indent = true ); + + template + ScopedElement& writeAttribute( std::string const& name, T const& attribute ) { + m_writer->writeAttribute( name, attribute ); + return *this; + } + + private: + mutable XmlWriter* m_writer = nullptr; + }; + + XmlWriter( std::ostream& os = Catch::cout() ); + ~XmlWriter(); + + XmlWriter( XmlWriter const& ) = delete; + XmlWriter& operator=( XmlWriter const& ) = delete; + + XmlWriter& startElement( std::string const& name ); + + ScopedElement scopedElement( std::string const& name ); + + XmlWriter& endElement(); + + XmlWriter& writeAttribute( std::string const& name, std::string const& attribute ); + + XmlWriter& writeAttribute( std::string const& name, bool attribute ); + + template + XmlWriter& writeAttribute( std::string const& name, T const& attribute ) { + ReusableStringStream rss; + rss << attribute; + return writeAttribute( name, rss.str() ); + } + + XmlWriter& writeText( std::string const& text, bool indent = true ); + + XmlWriter& writeComment( std::string const& text ); + + void writeStylesheetRef( std::string const& url ); + + XmlWriter& writeBlankLine(); + + void ensureTagClosed(); + + private: + + void writeDeclaration(); + + void newlineIfNecessary(); + + bool m_tagIsOpen = false; + bool m_needsNewline = false; + std::vector m_tags; + std::string m_indent; + std::ostream& m_os; + }; + +} + +#endif // TWOBLUECUBES_CATCH_XMLWRITER_HPP_INCLUDED diff --git a/src/third_party/cppcodec/test/catch/include/reporters/catch_reporter_automake.hpp b/src/third_party/cppcodec/test/catch/include/reporters/catch_reporter_automake.hpp new file mode 100644 index 0000000000..dbebe97516 --- /dev/null +++ b/src/third_party/cppcodec/test/catch/include/reporters/catch_reporter_automake.hpp @@ -0,0 +1,62 @@ +/* + * Created by Justin R. Wilson on 2/19/2017. + * Copyright 2017 Justin R. Wilson. 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_CATCH_REPORTER_AUTOMAKE_HPP_INCLUDED +#define TWOBLUECUBES_CATCH_REPORTER_AUTOMAKE_HPP_INCLUDED + +// Don't #include any Catch headers here - we can assume they are already +// included before this header. +// This is not good practice in general but is necessary in this case so this +// file can be distributed as a single header that works with the main +// Catch single header. + +namespace Catch { + + struct AutomakeReporter : StreamingReporterBase { + AutomakeReporter( ReporterConfig const& _config ) + : StreamingReporterBase( _config ) + {} + + ~AutomakeReporter() override; + + static std::string getDescription() { + return "Reports test results in the format of Automake .trs files"; + } + + void assertionStarting( AssertionInfo const& ) override {} + + bool assertionEnded( AssertionStats const& /*_assertionStats*/ ) override { return true; } + + void testCaseEnded( TestCaseStats const& _testCaseStats ) override { + // Possible values to emit are PASS, XFAIL, SKIP, FAIL, XPASS and ERROR. + stream << ":test-result: "; + if (_testCaseStats.totals.assertions.allPassed()) { + stream << "PASS"; + } else if (_testCaseStats.totals.assertions.allOk()) { + stream << "XFAIL"; + } else { + stream << "FAIL"; + } + stream << ' ' << _testCaseStats.testInfo.name << '\n'; + StreamingReporterBase::testCaseEnded( _testCaseStats ); + } + + void skipTest( TestCaseInfo const& testInfo ) override { + stream << ":test-result: SKIP " << testInfo.name << '\n'; + } + + }; + +#ifdef CATCH_IMPL + AutomakeReporter::~AutomakeReporter() {} +#endif + + CATCH_REGISTER_REPORTER( "automake", AutomakeReporter) + +} // end namespace Catch + +#endif // TWOBLUECUBES_CATCH_REPORTER_AUTOMAKE_HPP_INCLUDED diff --git a/src/third_party/cppcodec/test/catch/include/reporters/catch_reporter_bases.cpp b/src/third_party/cppcodec/test/catch/include/reporters/catch_reporter_bases.cpp new file mode 100644 index 0000000000..4dd4f95dca --- /dev/null +++ b/src/third_party/cppcodec/test/catch/include/reporters/catch_reporter_bases.cpp @@ -0,0 +1,55 @@ +/* + * Created by Phil on 27/11/2013. + * Copyright 2013 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) + */ + +#include "../internal/catch_interfaces_reporter.h" +#include "../internal/catch_errno_guard.h" +#include "catch_reporter_bases.hpp" + +#include +#include +#include +#include +#include + +namespace Catch { + void prepareExpandedExpression(AssertionResult& result) { + result.getExpandedExpression(); + } + + // Because formatting using c++ streams is stateful, drop down to C is required + // Alternatively we could use stringstream, but its performance is... not good. + std::string getFormattedDuration( double duration ) { + // Max exponent + 1 is required to represent the whole part + // + 1 for decimal point + // + 3 for the 3 decimal places + // + 1 for null terminator + const std::size_t maxDoubleSize = DBL_MAX_10_EXP + 1 + 1 + 3 + 1; + char buffer[maxDoubleSize]; + + // Save previous errno, to prevent sprintf from overwriting it + ErrnoGuard guard; +#ifdef _MSC_VER + sprintf_s(buffer, "%.3f", duration); +#else + sprintf(buffer, "%.3f", duration); +#endif + return std::string(buffer); + } + + + TestEventListenerBase::TestEventListenerBase(ReporterConfig const & _config) + :StreamingReporterBase(_config) {} + + void TestEventListenerBase::assertionStarting(AssertionInfo const &) {} + + bool TestEventListenerBase::assertionEnded(AssertionStats const &) { + return false; + } + + +} // end namespace Catch diff --git a/src/third_party/cppcodec/test/catch/include/reporters/catch_reporter_bases.hpp b/src/third_party/cppcodec/test/catch/include/reporters/catch_reporter_bases.hpp new file mode 100644 index 0000000000..f198d21428 --- /dev/null +++ b/src/third_party/cppcodec/test/catch/include/reporters/catch_reporter_bases.hpp @@ -0,0 +1,274 @@ +/* + * Created by Phil on 27/11/2013. + * Copyright 2013 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_CATCH_REPORTER_BASES_HPP_INCLUDED +#define TWOBLUECUBES_CATCH_REPORTER_BASES_HPP_INCLUDED + +#include "../internal/catch_interfaces_reporter.h" + +#include +#include +#include +#include +#include +#include +#include + +namespace Catch { + void prepareExpandedExpression(AssertionResult& result); + + // Returns double formatted as %.3f (format expected on output) + std::string getFormattedDuration( double duration ); + + template + struct StreamingReporterBase : IStreamingReporter { + + StreamingReporterBase( ReporterConfig const& _config ) + : m_config( _config.fullConfig() ), + stream( _config.stream() ) + { + m_reporterPrefs.shouldRedirectStdOut = false; + if( !DerivedT::getSupportedVerbosities().count( m_config->verbosity() ) ) + throw std::domain_error( "Verbosity level not supported by this reporter" ); + } + + ReporterPreferences getPreferences() const override { + return m_reporterPrefs; + } + + static std::set getSupportedVerbosities() { + return { Verbosity::Normal }; + } + + ~StreamingReporterBase() override = default; + + void noMatchingTestCases(std::string const&) override {} + + void testRunStarting(TestRunInfo const& _testRunInfo) override { + currentTestRunInfo = _testRunInfo; + } + void testGroupStarting(GroupInfo const& _groupInfo) override { + currentGroupInfo = _groupInfo; + } + + void testCaseStarting(TestCaseInfo const& _testInfo) override { + currentTestCaseInfo = _testInfo; + } + void sectionStarting(SectionInfo const& _sectionInfo) override { + m_sectionStack.push_back(_sectionInfo); + } + + void sectionEnded(SectionStats const& /* _sectionStats */) override { + m_sectionStack.pop_back(); + } + void testCaseEnded(TestCaseStats const& /* _testCaseStats */) override { + currentTestCaseInfo.reset(); + } + void testGroupEnded(TestGroupStats const& /* _testGroupStats */) override { + currentGroupInfo.reset(); + } + void testRunEnded(TestRunStats const& /* _testRunStats */) override { + currentTestCaseInfo.reset(); + currentGroupInfo.reset(); + currentTestRunInfo.reset(); + } + + void skipTest(TestCaseInfo const&) override { + // Don't do anything with this by default. + // It can optionally be overridden in the derived class. + } + + IConfigPtr m_config; + std::ostream& stream; + + LazyStat currentTestRunInfo; + LazyStat currentGroupInfo; + LazyStat currentTestCaseInfo; + + std::vector m_sectionStack; + ReporterPreferences m_reporterPrefs; + }; + + template + struct CumulativeReporterBase : IStreamingReporter { + template + struct Node { + explicit Node( T const& _value ) : value( _value ) {} + virtual ~Node() {} + + using ChildNodes = std::vector>; + T value; + ChildNodes children; + }; + struct SectionNode { + explicit SectionNode(SectionStats const& _stats) : stats(_stats) {} + virtual ~SectionNode() = default; + + bool operator == (SectionNode const& other) const { + return stats.sectionInfo.lineInfo == other.stats.sectionInfo.lineInfo; + } + bool operator == (std::shared_ptr const& other) const { + return operator==(*other); + } + + SectionStats stats; + using ChildSections = std::vector>; + using Assertions = std::vector; + ChildSections childSections; + Assertions assertions; + std::string stdOut; + std::string stdErr; + }; + + struct BySectionInfo { + BySectionInfo( SectionInfo const& other ) : m_other( other ) {} + BySectionInfo( BySectionInfo const& other ) : m_other( other.m_other ) {} + bool operator() (std::shared_ptr const& node) const { + return ((node->stats.sectionInfo.name == m_other.name) && + (node->stats.sectionInfo.lineInfo == m_other.lineInfo)); + } + void operator=(BySectionInfo const&) = delete; + + private: + SectionInfo const& m_other; + }; + + + using TestCaseNode = Node; + using TestGroupNode = Node; + using TestRunNode = Node; + + CumulativeReporterBase( ReporterConfig const& _config ) + : m_config( _config.fullConfig() ), + stream( _config.stream() ) + { + m_reporterPrefs.shouldRedirectStdOut = false; + if( !DerivedT::getSupportedVerbosities().count( m_config->verbosity() ) ) + throw std::domain_error( "Verbosity level not supported by this reporter" ); + } + ~CumulativeReporterBase() override = default; + + ReporterPreferences getPreferences() const override { + return m_reporterPrefs; + } + + static std::set getSupportedVerbosities() { + return { Verbosity::Normal }; + } + + void testRunStarting( TestRunInfo const& ) override {} + void testGroupStarting( GroupInfo const& ) override {} + + void testCaseStarting( TestCaseInfo const& ) override {} + + void sectionStarting( SectionInfo const& sectionInfo ) override { + SectionStats incompleteStats( sectionInfo, Counts(), 0, false ); + std::shared_ptr node; + if( m_sectionStack.empty() ) { + if( !m_rootSection ) + m_rootSection = std::make_shared( incompleteStats ); + node = m_rootSection; + } + else { + SectionNode& parentNode = *m_sectionStack.back(); + auto it = + std::find_if( parentNode.childSections.begin(), + parentNode.childSections.end(), + BySectionInfo( sectionInfo ) ); + if( it == parentNode.childSections.end() ) { + node = std::make_shared( incompleteStats ); + parentNode.childSections.push_back( node ); + } + else + node = *it; + } + m_sectionStack.push_back( node ); + m_deepestSection = std::move(node); + } + + void assertionStarting(AssertionInfo const&) override {} + + bool assertionEnded(AssertionStats const& assertionStats) override { + assert(!m_sectionStack.empty()); + // AssertionResult holds a pointer to a temporary DecomposedExpression, + // which getExpandedExpression() calls to build the expression string. + // Our section stack copy of the assertionResult will likely outlive the + // temporary, so it must be expanded or discarded now to avoid calling + // a destroyed object later. + prepareExpandedExpression(const_cast( assertionStats.assertionResult ) ); + SectionNode& sectionNode = *m_sectionStack.back(); + sectionNode.assertions.push_back(assertionStats); + return true; + } + void sectionEnded(SectionStats const& sectionStats) override { + assert(!m_sectionStack.empty()); + SectionNode& node = *m_sectionStack.back(); + node.stats = sectionStats; + m_sectionStack.pop_back(); + } + void testCaseEnded(TestCaseStats const& testCaseStats) override { + auto node = std::make_shared(testCaseStats); + assert(m_sectionStack.size() == 0); + node->children.push_back(m_rootSection); + m_testCases.push_back(node); + m_rootSection.reset(); + + assert(m_deepestSection); + m_deepestSection->stdOut = testCaseStats.stdOut; + m_deepestSection->stdErr = testCaseStats.stdErr; + } + void testGroupEnded(TestGroupStats const& testGroupStats) override { + auto node = std::make_shared(testGroupStats); + node->children.swap(m_testCases); + m_testGroups.push_back(node); + } + void testRunEnded(TestRunStats const& testRunStats) override { + auto node = std::make_shared(testRunStats); + node->children.swap(m_testGroups); + m_testRuns.push_back(node); + testRunEndedCumulative(); + } + virtual void testRunEndedCumulative() = 0; + + void skipTest(TestCaseInfo const&) override {} + + IConfigPtr m_config; + std::ostream& stream; + std::vector m_assertions; + std::vector>> m_sections; + std::vector> m_testCases; + std::vector> m_testGroups; + + std::vector> m_testRuns; + + std::shared_ptr m_rootSection; + std::shared_ptr m_deepestSection; + std::vector> m_sectionStack; + ReporterPreferences m_reporterPrefs; + }; + + template + char const* getLineOfChars() { + static char line[CATCH_CONFIG_CONSOLE_WIDTH] = {0}; + if( !*line ) { + std::memset( line, C, CATCH_CONFIG_CONSOLE_WIDTH-1 ); + line[CATCH_CONFIG_CONSOLE_WIDTH-1] = 0; + } + return line; + } + + + struct TestEventListenerBase : StreamingReporterBase { + TestEventListenerBase( ReporterConfig const& _config ); + + void assertionStarting(AssertionInfo const&) override; + bool assertionEnded(AssertionStats const&) override; + }; + +} // end namespace Catch + +#endif // TWOBLUECUBES_CATCH_REPORTER_BASES_HPP_INCLUDED diff --git a/src/third_party/cppcodec/test/catch/include/reporters/catch_reporter_compact.cpp b/src/third_party/cppcodec/test/catch/include/reporters/catch_reporter_compact.cpp new file mode 100644 index 0000000000..65f70266dd --- /dev/null +++ b/src/third_party/cppcodec/test/catch/include/reporters/catch_reporter_compact.cpp @@ -0,0 +1,292 @@ +/* + * Created by Martin on 2017-11-14. + * + * 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) + */ + +#include "catch_reporter_compact.h" + +#include "../internal/catch_reporter_registrars.hpp" +#include "internal/catch_console_colour.h" + +namespace { + +#ifdef CATCH_PLATFORM_MAC + const char* failedString() { return "FAILED"; } + const char* passedString() { return "PASSED"; } +#else + const char* failedString() { return "failed"; } + const char* passedString() { return "passed"; } +#endif + + // Colour::LightGrey + Catch::Colour::Code dimColour() { return Catch::Colour::FileName; } + + std::string bothOrAll( std::size_t count ) { + return count == 1 ? std::string() : + count == 2 ? "both " : "all " ; + } + +} // anon namespace + + +namespace Catch { +namespace { +// Colour, message variants: +// - white: No tests ran. +// - red: Failed [both/all] N test cases, failed [both/all] M assertions. +// - white: Passed [both/all] N test cases (no assertions). +// - red: Failed N tests cases, failed M assertions. +// - green: Passed [both/all] N tests cases with M assertions. +void printTotals(std::ostream& out, const Totals& totals) { + if (totals.testCases.total() == 0) { + out << "No tests ran."; + } else if (totals.testCases.failed == totals.testCases.total()) { + Colour colour(Colour::ResultError); + const std::string qualify_assertions_failed = + totals.assertions.failed == totals.assertions.total() ? + bothOrAll(totals.assertions.failed) : std::string(); + out << + "Failed " << bothOrAll(totals.testCases.failed) + << pluralise(totals.testCases.failed, "test case") << ", " + "failed " << qualify_assertions_failed << + pluralise(totals.assertions.failed, "assertion") << '.'; + } else if (totals.assertions.total() == 0) { + out << + "Passed " << bothOrAll(totals.testCases.total()) + << pluralise(totals.testCases.total(), "test case") + << " (no assertions)."; + } else if (totals.assertions.failed) { + Colour colour(Colour::ResultError); + out << + "Failed " << pluralise(totals.testCases.failed, "test case") << ", " + "failed " << pluralise(totals.assertions.failed, "assertion") << '.'; + } else { + Colour colour(Colour::ResultSuccess); + out << + "Passed " << bothOrAll(totals.testCases.passed) + << pluralise(totals.testCases.passed, "test case") << + " with " << pluralise(totals.assertions.passed, "assertion") << '.'; + } +} + +// Implementation of CompactReporter formatting +class AssertionPrinter { +public: + AssertionPrinter& operator= (AssertionPrinter const&) = delete; + AssertionPrinter(AssertionPrinter const&) = delete; + AssertionPrinter(std::ostream& _stream, AssertionStats const& _stats, bool _printInfoMessages) + : stream(_stream) + , result(_stats.assertionResult) + , messages(_stats.infoMessages) + , itMessage(_stats.infoMessages.begin()) + , printInfoMessages(_printInfoMessages) {} + + void print() { + printSourceInfo(); + + itMessage = messages.begin(); + + switch (result.getResultType()) { + case ResultWas::Ok: + printResultType(Colour::ResultSuccess, passedString()); + printOriginalExpression(); + printReconstructedExpression(); + if (!result.hasExpression()) + printRemainingMessages(Colour::None); + else + printRemainingMessages(); + break; + case ResultWas::ExpressionFailed: + if (result.isOk()) + printResultType(Colour::ResultSuccess, failedString() + std::string(" - but was ok")); + else + printResultType(Colour::Error, failedString()); + printOriginalExpression(); + printReconstructedExpression(); + printRemainingMessages(); + break; + case ResultWas::ThrewException: + printResultType(Colour::Error, failedString()); + printIssue("unexpected exception with message:"); + printMessage(); + printExpressionWas(); + printRemainingMessages(); + break; + case ResultWas::FatalErrorCondition: + printResultType(Colour::Error, failedString()); + printIssue("fatal error condition with message:"); + printMessage(); + printExpressionWas(); + printRemainingMessages(); + break; + case ResultWas::DidntThrowException: + printResultType(Colour::Error, failedString()); + printIssue("expected exception, got none"); + printExpressionWas(); + printRemainingMessages(); + break; + case ResultWas::Info: + printResultType(Colour::None, "info"); + printMessage(); + printRemainingMessages(); + break; + case ResultWas::Warning: + printResultType(Colour::None, "warning"); + printMessage(); + printRemainingMessages(); + break; + case ResultWas::ExplicitFailure: + printResultType(Colour::Error, failedString()); + printIssue("explicitly"); + printRemainingMessages(Colour::None); + break; + // These cases are here to prevent compiler warnings + case ResultWas::Unknown: + case ResultWas::FailureBit: + case ResultWas::Exception: + printResultType(Colour::Error, "** internal error **"); + break; + } + } + +private: + void printSourceInfo() const { + Colour colourGuard(Colour::FileName); + stream << result.getSourceInfo() << ':'; + } + + void printResultType(Colour::Code colour, std::string const& passOrFail) const { + if (!passOrFail.empty()) { + { + Colour colourGuard(colour); + stream << ' ' << passOrFail; + } + stream << ':'; + } + } + + void printIssue(std::string const& issue) const { + stream << ' ' << issue; + } + + void printExpressionWas() { + if (result.hasExpression()) { + stream << ';'; + { + Colour colour(dimColour()); + stream << " expression was:"; + } + printOriginalExpression(); + } + } + + void printOriginalExpression() const { + if (result.hasExpression()) { + stream << ' ' << result.getExpression(); + } + } + + void printReconstructedExpression() const { + if (result.hasExpandedExpression()) { + { + Colour colour(dimColour()); + stream << " for: "; + } + stream << result.getExpandedExpression(); + } + } + + void printMessage() { + if (itMessage != messages.end()) { + stream << " '" << itMessage->message << '\''; + ++itMessage; + } + } + + void printRemainingMessages(Colour::Code colour = dimColour()) { + if (itMessage == messages.end()) + return; + + // using messages.end() directly yields (or auto) compilation error: + std::vector::const_iterator itEnd = messages.end(); + const std::size_t N = static_cast(std::distance(itMessage, itEnd)); + + { + Colour colourGuard(colour); + stream << " with " << pluralise(N, "message") << ':'; + } + + for (; itMessage != itEnd; ) { + // If this assertion is a warning ignore any INFO messages + if (printInfoMessages || itMessage->type != ResultWas::Info) { + stream << " '" << itMessage->message << '\''; + if (++itMessage != itEnd) { + Colour colourGuard(dimColour()); + stream << " and"; + } + } + } + } + +private: + std::ostream& stream; + AssertionResult const& result; + std::vector messages; + std::vector::const_iterator itMessage; + bool printInfoMessages; +}; + +} // anon namespace + + std::string CompactReporter::getDescription() { + return "Reports test results on a single line, suitable for IDEs"; + } + + ReporterPreferences CompactReporter::getPreferences() const { + return m_reporterPrefs; + } + + void CompactReporter::noMatchingTestCases( std::string const& spec ) { + stream << "No test cases matched '" << spec << '\'' << std::endl; + } + + void CompactReporter::assertionStarting( AssertionInfo const& ) {} + + bool CompactReporter::assertionEnded( AssertionStats const& _assertionStats ) { + AssertionResult const& result = _assertionStats.assertionResult; + + bool printInfoMessages = true; + + // Drop out if result was successful and we're not printing those + if( !m_config->includeSuccessfulResults() && result.isOk() ) { + if( result.getResultType() != ResultWas::Warning ) + return false; + printInfoMessages = false; + } + + AssertionPrinter printer( stream, _assertionStats, printInfoMessages ); + printer.print(); + + stream << std::endl; + return true; + } + + void CompactReporter::sectionEnded(SectionStats const& _sectionStats) { + if (m_config->showDurations() == ShowDurations::Always) { + stream << getFormattedDuration(_sectionStats.durationInSeconds) << " s: " << _sectionStats.sectionInfo.name << std::endl; + } + } + + void CompactReporter::testRunEnded( TestRunStats const& _testRunStats ) { + printTotals( stream, _testRunStats.totals ); + stream << '\n' << std::endl; + StreamingReporterBase::testRunEnded( _testRunStats ); + } + + CompactReporter::~CompactReporter() {} + + CATCH_REGISTER_REPORTER( "compact", CompactReporter ) + +} // end namespace Catch diff --git a/src/third_party/cppcodec/test/catch/include/reporters/catch_reporter_compact.h b/src/third_party/cppcodec/test/catch/include/reporters/catch_reporter_compact.h new file mode 100644 index 0000000000..5002df7b1f --- /dev/null +++ b/src/third_party/cppcodec/test/catch/include/reporters/catch_reporter_compact.h @@ -0,0 +1,41 @@ +/* + * Created by Martin Moene on 2013-12-05. + * Copyright 2012 Martin Moene. 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_CATCH_REPORTER_COMPACT_H_INCLUDED +#define TWOBLUECUBES_CATCH_REPORTER_COMPACT_H_INCLUDED + + +#include "catch_reporter_bases.hpp" + + +namespace Catch { + + struct CompactReporter : StreamingReporterBase { + + using StreamingReporterBase::StreamingReporterBase; + + ~CompactReporter() override; + + static std::string getDescription(); + + ReporterPreferences getPreferences() const override; + + void noMatchingTestCases(std::string const& spec) override; + + void assertionStarting(AssertionInfo const&) override; + + bool assertionEnded(AssertionStats const& _assertionStats) override; + + void sectionEnded(SectionStats const& _sectionStats) override; + + void testRunEnded(TestRunStats const& _testRunStats) override; + + }; + +} // end namespace Catch + +#endif // TWOBLUECUBES_CATCH_REPORTER_COMPACT_H_INCLUDED diff --git a/src/third_party/cppcodec/test/catch/include/reporters/catch_reporter_console.cpp b/src/third_party/cppcodec/test/catch/include/reporters/catch_reporter_console.cpp new file mode 100644 index 0000000000..54b62cd808 --- /dev/null +++ b/src/third_party/cppcodec/test/catch/include/reporters/catch_reporter_console.cpp @@ -0,0 +1,633 @@ +/* + * Created by Phil on 5/12/2012. + * Copyright 2012 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) + */ + +#include "catch_reporter_console.h" + +#include "../internal/catch_reporter_registrars.hpp" +#include "internal/catch_console_colour.h" +#include "../internal/catch_version.h" +#include "../internal/catch_text.h" +#include "../internal/catch_stringref.h" + +#include +#include + +#if defined(_MSC_VER) +#pragma warning(push) +#pragma warning(disable:4061) // Not all labels are EXPLICITLY handled in switch + // Note that 4062 (not all labels are handled + // and default is missing) is enabled +#endif + + +namespace Catch { + +namespace { + +// Formatter impl for ConsoleReporter +class ConsoleAssertionPrinter { +public: + ConsoleAssertionPrinter& operator= (ConsoleAssertionPrinter const&) = delete; + ConsoleAssertionPrinter(ConsoleAssertionPrinter const&) = delete; + ConsoleAssertionPrinter(std::ostream& _stream, AssertionStats const& _stats, bool _printInfoMessages) + : stream(_stream), + stats(_stats), + result(_stats.assertionResult), + colour(Colour::None), + message(result.getMessage()), + messages(_stats.infoMessages), + printInfoMessages(_printInfoMessages) { + switch (result.getResultType()) { + case ResultWas::Ok: + colour = Colour::Success; + passOrFail = "PASSED"; + //if( result.hasMessage() ) + if (_stats.infoMessages.size() == 1) + messageLabel = "with message"; + if (_stats.infoMessages.size() > 1) + messageLabel = "with messages"; + break; + case ResultWas::ExpressionFailed: + if (result.isOk()) { + colour = Colour::Success; + passOrFail = "FAILED - but was ok"; + } else { + colour = Colour::Error; + passOrFail = "FAILED"; + } + if (_stats.infoMessages.size() == 1) + messageLabel = "with message"; + if (_stats.infoMessages.size() > 1) + messageLabel = "with messages"; + break; + case ResultWas::ThrewException: + colour = Colour::Error; + passOrFail = "FAILED"; + messageLabel = "due to unexpected exception with "; + if (_stats.infoMessages.size() == 1) + messageLabel += "message"; + if (_stats.infoMessages.size() > 1) + messageLabel += "messages"; + break; + case ResultWas::FatalErrorCondition: + colour = Colour::Error; + passOrFail = "FAILED"; + messageLabel = "due to a fatal error condition"; + break; + case ResultWas::DidntThrowException: + colour = Colour::Error; + passOrFail = "FAILED"; + messageLabel = "because no exception was thrown where one was expected"; + break; + case ResultWas::Info: + messageLabel = "info"; + break; + case ResultWas::Warning: + messageLabel = "warning"; + break; + case ResultWas::ExplicitFailure: + passOrFail = "FAILED"; + colour = Colour::Error; + if (_stats.infoMessages.size() == 1) + messageLabel = "explicitly with message"; + if (_stats.infoMessages.size() > 1) + messageLabel = "explicitly with messages"; + break; + // These cases are here to prevent compiler warnings + case ResultWas::Unknown: + case ResultWas::FailureBit: + case ResultWas::Exception: + passOrFail = "** internal error **"; + colour = Colour::Error; + break; + } + } + + void print() const { + printSourceInfo(); + if (stats.totals.assertions.total() > 0) { + if (result.isOk()) + stream << '\n'; + printResultType(); + printOriginalExpression(); + printReconstructedExpression(); + } else { + stream << '\n'; + } + printMessage(); + } + +private: + void printResultType() const { + if (!passOrFail.empty()) { + Colour colourGuard(colour); + stream << passOrFail << ":\n"; + } + } + void printOriginalExpression() const { + if (result.hasExpression()) { + Colour colourGuard(Colour::OriginalExpression); + stream << " "; + stream << result.getExpressionInMacro(); + stream << '\n'; + } + } + void printReconstructedExpression() const { + if (result.hasExpandedExpression()) { + stream << "with expansion:\n"; + Colour colourGuard(Colour::ReconstructedExpression); + stream << Column(result.getExpandedExpression()).indent(2) << '\n'; + } + } + void printMessage() const { + if (!messageLabel.empty()) + stream << messageLabel << ':' << '\n'; + for (auto const& msg : messages) { + // If this assertion is a warning ignore any INFO messages + if (printInfoMessages || msg.type != ResultWas::Info) + stream << Column(msg.message).indent(2) << '\n'; + } + } + void printSourceInfo() const { + Colour colourGuard(Colour::FileName); + stream << result.getSourceInfo() << ": "; + } + + std::ostream& stream; + AssertionStats const& stats; + AssertionResult const& result; + Colour::Code colour; + std::string passOrFail; + std::string messageLabel; + std::string message; + std::vector messages; + bool printInfoMessages; +}; + +std::size_t makeRatio(std::size_t number, std::size_t total) { + std::size_t ratio = total > 0 ? CATCH_CONFIG_CONSOLE_WIDTH * number / total : 0; + return (ratio == 0 && number > 0) ? 1 : ratio; +} + +std::size_t& findMax(std::size_t& i, std::size_t& j, std::size_t& k) { + if (i > j && i > k) + return i; + else if (j > k) + return j; + else + return k; +} + +struct ColumnInfo { + enum Justification { Left, Right }; + std::string name; + int width; + Justification justification; +}; +struct ColumnBreak {}; +struct RowBreak {}; + +class Duration { + enum class Unit { + Auto, + Nanoseconds, + Microseconds, + Milliseconds, + Seconds, + Minutes + }; + static const uint64_t s_nanosecondsInAMicrosecond = 1000; + static const uint64_t s_nanosecondsInAMillisecond = 1000 * s_nanosecondsInAMicrosecond; + static const uint64_t s_nanosecondsInASecond = 1000 * s_nanosecondsInAMillisecond; + static const uint64_t s_nanosecondsInAMinute = 60 * s_nanosecondsInASecond; + + uint64_t m_inNanoseconds; + Unit m_units; + +public: + explicit Duration(uint64_t inNanoseconds, Unit units = Unit::Auto) + : m_inNanoseconds(inNanoseconds), + m_units(units) { + if (m_units == Unit::Auto) { + if (m_inNanoseconds < s_nanosecondsInAMicrosecond) + m_units = Unit::Nanoseconds; + else if (m_inNanoseconds < s_nanosecondsInAMillisecond) + m_units = Unit::Microseconds; + else if (m_inNanoseconds < s_nanosecondsInASecond) + m_units = Unit::Milliseconds; + else if (m_inNanoseconds < s_nanosecondsInAMinute) + m_units = Unit::Seconds; + else + m_units = Unit::Minutes; + } + + } + + auto value() const -> double { + switch (m_units) { + case Unit::Microseconds: + return m_inNanoseconds / static_cast(s_nanosecondsInAMicrosecond); + case Unit::Milliseconds: + return m_inNanoseconds / static_cast(s_nanosecondsInAMillisecond); + case Unit::Seconds: + return m_inNanoseconds / static_cast(s_nanosecondsInASecond); + case Unit::Minutes: + return m_inNanoseconds / static_cast(s_nanosecondsInAMinute); + default: + return static_cast(m_inNanoseconds); + } + } + auto unitsAsString() const -> std::string { + switch (m_units) { + case Unit::Nanoseconds: + return "ns"; + case Unit::Microseconds: + return "µs"; + case Unit::Milliseconds: + return "ms"; + case Unit::Seconds: + return "s"; + case Unit::Minutes: + return "m"; + default: + return "** internal error **"; + } + + } + friend auto operator << (std::ostream& os, Duration const& duration) -> std::ostream& { + return os << duration.value() << " " << duration.unitsAsString(); + } +}; +} // end anon namespace + +class TablePrinter { + std::ostream& m_os; + std::vector m_columnInfos; + std::ostringstream m_oss; + int m_currentColumn = -1; + bool m_isOpen = false; + +public: + TablePrinter( std::ostream& os, std::vector columnInfos ) + : m_os( os ), + m_columnInfos( std::move( columnInfos ) ) {} + + auto columnInfos() const -> std::vector const& { + return m_columnInfos; + } + + void open() { + if (!m_isOpen) { + m_isOpen = true; + *this << RowBreak(); + for (auto const& info : m_columnInfos) + *this << info.name << ColumnBreak(); + *this << RowBreak(); + m_os << Catch::getLineOfChars<'-'>() << "\n"; + } + } + void close() { + if (m_isOpen) { + *this << RowBreak(); + m_os << std::endl; + m_isOpen = false; + } + } + + template + friend TablePrinter& operator << (TablePrinter& tp, T const& value) { + tp.m_oss << value; + return tp; + } + + friend TablePrinter& operator << (TablePrinter& tp, ColumnBreak) { + auto colStr = tp.m_oss.str(); + // This takes account of utf8 encodings + auto strSize = Catch::StringRef(colStr).numberOfCharacters(); + tp.m_oss.str(""); + tp.open(); + if (tp.m_currentColumn == static_cast(tp.m_columnInfos.size() - 1)) { + tp.m_currentColumn = -1; + tp.m_os << "\n"; + } + tp.m_currentColumn++; + + auto colInfo = tp.m_columnInfos[tp.m_currentColumn]; + auto padding = (strSize + 2 < static_cast(colInfo.width)) + ? std::string(colInfo.width - (strSize + 2), ' ') + : std::string(); + if (colInfo.justification == ColumnInfo::Left) + tp.m_os << colStr << padding << " "; + else + tp.m_os << padding << colStr << " "; + return tp; + } + + friend TablePrinter& operator << (TablePrinter& tp, RowBreak) { + if (tp.m_currentColumn > 0) { + tp.m_os << "\n"; + tp.m_currentColumn = -1; + } + return tp; + } +}; + +ConsoleReporter::ConsoleReporter(ReporterConfig const& config) + : StreamingReporterBase(config), + m_tablePrinter(new TablePrinter(config.stream(), + { + { "benchmark name", CATCH_CONFIG_CONSOLE_WIDTH - 32, ColumnInfo::Left }, + { "iters", 8, ColumnInfo::Right }, + { "elapsed ns", 14, ColumnInfo::Right }, + { "average", 14, ColumnInfo::Right } + })) {} +ConsoleReporter::~ConsoleReporter() = default; + +std::string ConsoleReporter::getDescription() { + return "Reports test results as plain lines of text"; +} + +void ConsoleReporter::noMatchingTestCases(std::string const& spec) { + stream << "No test cases matched '" << spec << '\'' << std::endl; +} + +void ConsoleReporter::assertionStarting(AssertionInfo const&) {} + +bool ConsoleReporter::assertionEnded(AssertionStats const& _assertionStats) { + AssertionResult const& result = _assertionStats.assertionResult; + + bool includeResults = m_config->includeSuccessfulResults() || !result.isOk(); + + // Drop out if result was successful but we're not printing them. + if (!includeResults && result.getResultType() != ResultWas::Warning) + return false; + + lazyPrint(); + + ConsoleAssertionPrinter printer(stream, _assertionStats, includeResults); + printer.print(); + stream << std::endl; + return true; +} + +void ConsoleReporter::sectionStarting(SectionInfo const& _sectionInfo) { + m_headerPrinted = false; + StreamingReporterBase::sectionStarting(_sectionInfo); +} +void ConsoleReporter::sectionEnded(SectionStats const& _sectionStats) { + m_tablePrinter->close(); + if (_sectionStats.missingAssertions) { + lazyPrint(); + Colour colour(Colour::ResultError); + if (m_sectionStack.size() > 1) + stream << "\nNo assertions in section"; + else + stream << "\nNo assertions in test case"; + stream << " '" << _sectionStats.sectionInfo.name << "'\n" << std::endl; + } + if (m_config->showDurations() == ShowDurations::Always) { + stream << getFormattedDuration(_sectionStats.durationInSeconds) << " s: " << _sectionStats.sectionInfo.name << std::endl; + } + if (m_headerPrinted) { + m_headerPrinted = false; + } + StreamingReporterBase::sectionEnded(_sectionStats); +} + + +void ConsoleReporter::benchmarkStarting(BenchmarkInfo const& info) { + lazyPrintWithoutClosingBenchmarkTable(); + + auto nameCol = Column( info.name ).width( static_cast( m_tablePrinter->columnInfos()[0].width - 2 ) ); + + bool firstLine = true; + for (auto line : nameCol) { + if (!firstLine) + (*m_tablePrinter) << ColumnBreak() << ColumnBreak() << ColumnBreak(); + else + firstLine = false; + + (*m_tablePrinter) << line << ColumnBreak(); + } +} +void ConsoleReporter::benchmarkEnded(BenchmarkStats const& stats) { + Duration average(stats.elapsedTimeInNanoseconds / stats.iterations); + (*m_tablePrinter) + << stats.iterations << ColumnBreak() + << stats.elapsedTimeInNanoseconds << ColumnBreak() + << average << ColumnBreak(); +} + +void ConsoleReporter::testCaseEnded(TestCaseStats const& _testCaseStats) { + m_tablePrinter->close(); + StreamingReporterBase::testCaseEnded(_testCaseStats); + m_headerPrinted = false; +} +void ConsoleReporter::testGroupEnded(TestGroupStats const& _testGroupStats) { + if (currentGroupInfo.used) { + printSummaryDivider(); + stream << "Summary for group '" << _testGroupStats.groupInfo.name << "':\n"; + printTotals(_testGroupStats.totals); + stream << '\n' << std::endl; + } + StreamingReporterBase::testGroupEnded(_testGroupStats); +} +void ConsoleReporter::testRunEnded(TestRunStats const& _testRunStats) { + printTotalsDivider(_testRunStats.totals); + printTotals(_testRunStats.totals); + stream << std::endl; + StreamingReporterBase::testRunEnded(_testRunStats); +} + +void ConsoleReporter::lazyPrint() { + + m_tablePrinter->close(); + lazyPrintWithoutClosingBenchmarkTable(); +} + +void ConsoleReporter::lazyPrintWithoutClosingBenchmarkTable() { + + if (!currentTestRunInfo.used) + lazyPrintRunInfo(); + if (!currentGroupInfo.used) + lazyPrintGroupInfo(); + + if (!m_headerPrinted) { + printTestCaseAndSectionHeader(); + m_headerPrinted = true; + } +} +void ConsoleReporter::lazyPrintRunInfo() { + stream << '\n' << getLineOfChars<'~'>() << '\n'; + Colour colour(Colour::SecondaryText); + stream << currentTestRunInfo->name + << " is a Catch v" << libraryVersion() << " host application.\n" + << "Run with -? for options\n\n"; + + if (m_config->rngSeed() != 0) + stream << "Randomness seeded to: " << m_config->rngSeed() << "\n\n"; + + currentTestRunInfo.used = true; +} +void ConsoleReporter::lazyPrintGroupInfo() { + if (!currentGroupInfo->name.empty() && currentGroupInfo->groupsCounts > 1) { + printClosedHeader("Group: " + currentGroupInfo->name); + currentGroupInfo.used = true; + } +} +void ConsoleReporter::printTestCaseAndSectionHeader() { + assert(!m_sectionStack.empty()); + printOpenHeader(currentTestCaseInfo->name); + + if (m_sectionStack.size() > 1) { + Colour colourGuard(Colour::Headers); + + auto + it = m_sectionStack.begin() + 1, // Skip first section (test case) + itEnd = m_sectionStack.end(); + for (; it != itEnd; ++it) + printHeaderString(it->name, 2); + } + + SourceLineInfo lineInfo = m_sectionStack.back().lineInfo; + + if (!lineInfo.empty()) { + stream << getLineOfChars<'-'>() << '\n'; + Colour colourGuard(Colour::FileName); + stream << lineInfo << '\n'; + } + stream << getLineOfChars<'.'>() << '\n' << std::endl; +} + +void ConsoleReporter::printClosedHeader(std::string const& _name) { + printOpenHeader(_name); + stream << getLineOfChars<'.'>() << '\n'; +} +void ConsoleReporter::printOpenHeader(std::string const& _name) { + stream << getLineOfChars<'-'>() << '\n'; + { + Colour colourGuard(Colour::Headers); + printHeaderString(_name); + } +} + +// if string has a : in first line will set indent to follow it on +// subsequent lines +void ConsoleReporter::printHeaderString(std::string const& _string, std::size_t indent) { + std::size_t i = _string.find(": "); + if (i != std::string::npos) + i += 2; + else + i = 0; + stream << Column(_string).indent(indent + i).initialIndent(indent) << '\n'; +} + +struct SummaryColumn { + + SummaryColumn( std::string _label, Colour::Code _colour ) + : label( std::move( _label ) ), + colour( _colour ) {} + SummaryColumn addRow( std::size_t count ) { + ReusableStringStream rss; + rss << count; + std::string row = rss.str(); + for (auto& oldRow : rows) { + while (oldRow.size() < row.size()) + oldRow = ' ' + oldRow; + while (oldRow.size() > row.size()) + row = ' ' + row; + } + rows.push_back(row); + return *this; + } + + std::string label; + Colour::Code colour; + std::vector rows; + +}; + +void ConsoleReporter::printTotals( Totals const& totals ) { + if (totals.testCases.total() == 0) { + stream << Colour(Colour::Warning) << "No tests ran\n"; + } else if (totals.assertions.total() > 0 && totals.testCases.allPassed()) { + stream << Colour(Colour::ResultSuccess) << "All tests passed"; + stream << " (" + << pluralise(totals.assertions.passed, "assertion") << " in " + << pluralise(totals.testCases.passed, "test case") << ')' + << '\n'; + } else { + + std::vector columns; + columns.push_back(SummaryColumn("", Colour::None) + .addRow(totals.testCases.total()) + .addRow(totals.assertions.total())); + columns.push_back(SummaryColumn("passed", Colour::Success) + .addRow(totals.testCases.passed) + .addRow(totals.assertions.passed)); + columns.push_back(SummaryColumn("failed", Colour::ResultError) + .addRow(totals.testCases.failed) + .addRow(totals.assertions.failed)); + columns.push_back(SummaryColumn("failed as expected", Colour::ResultExpectedFailure) + .addRow(totals.testCases.failedButOk) + .addRow(totals.assertions.failedButOk)); + + printSummaryRow("test cases", columns, 0); + printSummaryRow("assertions", columns, 1); + } +} +void ConsoleReporter::printSummaryRow(std::string const& label, std::vector const& cols, std::size_t row) { + for (auto col : cols) { + std::string value = col.rows[row]; + if (col.label.empty()) { + stream << label << ": "; + if (value != "0") + stream << value; + else + stream << Colour(Colour::Warning) << "- none -"; + } else if (value != "0") { + stream << Colour(Colour::LightGrey) << " | "; + stream << Colour(col.colour) + << value << ' ' << col.label; + } + } + stream << '\n'; +} + +void ConsoleReporter::printTotalsDivider(Totals const& totals) { + if (totals.testCases.total() > 0) { + std::size_t failedRatio = makeRatio(totals.testCases.failed, totals.testCases.total()); + std::size_t failedButOkRatio = makeRatio(totals.testCases.failedButOk, totals.testCases.total()); + std::size_t passedRatio = makeRatio(totals.testCases.passed, totals.testCases.total()); + while (failedRatio + failedButOkRatio + passedRatio < CATCH_CONFIG_CONSOLE_WIDTH - 1) + findMax(failedRatio, failedButOkRatio, passedRatio)++; + while (failedRatio + failedButOkRatio + passedRatio > CATCH_CONFIG_CONSOLE_WIDTH - 1) + findMax(failedRatio, failedButOkRatio, passedRatio)--; + + stream << Colour(Colour::Error) << std::string(failedRatio, '='); + stream << Colour(Colour::ResultExpectedFailure) << std::string(failedButOkRatio, '='); + if (totals.testCases.allPassed()) + stream << Colour(Colour::ResultSuccess) << std::string(passedRatio, '='); + else + stream << Colour(Colour::Success) << std::string(passedRatio, '='); + } else { + stream << Colour(Colour::Warning) << std::string(CATCH_CONFIG_CONSOLE_WIDTH - 1, '='); + } + stream << '\n'; +} +void ConsoleReporter::printSummaryDivider() { + stream << getLineOfChars<'-'>() << '\n'; +} + +CATCH_REGISTER_REPORTER("console", ConsoleReporter) + +} // end namespace Catch + +#if defined(_MSC_VER) +#pragma warning(pop) +#endif diff --git a/src/third_party/cppcodec/test/catch/include/reporters/catch_reporter_console.h b/src/third_party/cppcodec/test/catch/include/reporters/catch_reporter_console.h new file mode 100644 index 0000000000..10cea49ab1 --- /dev/null +++ b/src/third_party/cppcodec/test/catch/include/reporters/catch_reporter_console.h @@ -0,0 +1,83 @@ +/* + * Created by Phil on 5/12/2012. + * Copyright 2012 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_CATCH_REPORTER_CONSOLE_H_INCLUDED +#define TWOBLUECUBES_CATCH_REPORTER_CONSOLE_H_INCLUDED + +#include "catch_reporter_bases.hpp" + +#if defined(_MSC_VER) +#pragma warning(push) +#pragma warning(disable:4061) // Not all labels are EXPLICITLY handled in switch + // Note that 4062 (not all labels are handled + // and default is missing) is enabled +#endif + + +namespace Catch { + // Fwd decls + struct SummaryColumn; + class TablePrinter; + + struct ConsoleReporter : StreamingReporterBase { + std::unique_ptr m_tablePrinter; + + ConsoleReporter(ReporterConfig const& config); + ~ConsoleReporter() override; + static std::string getDescription(); + + void noMatchingTestCases(std::string const& spec) override; + + void assertionStarting(AssertionInfo const&) override; + + bool assertionEnded(AssertionStats const& _assertionStats) override; + + void sectionStarting(SectionInfo const& _sectionInfo) override; + void sectionEnded(SectionStats const& _sectionStats) override; + + + void benchmarkStarting(BenchmarkInfo const& info) override; + void benchmarkEnded(BenchmarkStats const& stats) override; + + void testCaseEnded(TestCaseStats const& _testCaseStats) override; + void testGroupEnded(TestGroupStats const& _testGroupStats) override; + void testRunEnded(TestRunStats const& _testRunStats) override; + + private: + + void lazyPrint(); + + void lazyPrintWithoutClosingBenchmarkTable(); + void lazyPrintRunInfo(); + void lazyPrintGroupInfo(); + void printTestCaseAndSectionHeader(); + + void printClosedHeader(std::string const& _name); + void printOpenHeader(std::string const& _name); + + // if string has a : in first line will set indent to follow it on + // subsequent lines + void printHeaderString(std::string const& _string, std::size_t indent = 0); + + + void printTotals(Totals const& totals); + void printSummaryRow(std::string const& label, std::vector const& cols, std::size_t row); + + void printTotalsDivider(Totals const& totals); + void printSummaryDivider(); + + private: + bool m_headerPrinted = false; + }; + +} // end namespace Catch + +#if defined(_MSC_VER) +#pragma warning(pop) +#endif + +#endif // TWOBLUECUBES_CATCH_REPORTER_CONSOLE_H_INCLUDED diff --git a/src/third_party/cppcodec/test/catch/include/reporters/catch_reporter_junit.cpp b/src/third_party/cppcodec/test/catch/include/reporters/catch_reporter_junit.cpp new file mode 100644 index 0000000000..03dc35c1bc --- /dev/null +++ b/src/third_party/cppcodec/test/catch/include/reporters/catch_reporter_junit.cpp @@ -0,0 +1,248 @@ +/* + * Created by Phil on 26/11/2010. + * Copyright 2010 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) + */ + +#include "catch_reporter_bases.hpp" + +#include "catch_reporter_junit.h" + +#include "../internal/catch_tostring.h" +#include "../internal/catch_reporter_registrars.hpp" + +#include +#include +#include +#include + +namespace Catch { + + namespace { + std::string getCurrentTimestamp() { + // Beware, this is not reentrant because of backward compatibility issues + // Also, UTC only, again because of backward compatibility (%z is C++11) + time_t rawtime; + std::time(&rawtime); + auto const timeStampSize = sizeof("2017-01-16T17:06:45Z"); + +#ifdef _MSC_VER + std::tm timeInfo = {}; + gmtime_s(&timeInfo, &rawtime); +#else + std::tm* timeInfo; + timeInfo = std::gmtime(&rawtime); +#endif + + char timeStamp[timeStampSize]; + const char * const fmt = "%Y-%m-%dT%H:%M:%SZ"; + +#ifdef _MSC_VER + std::strftime(timeStamp, timeStampSize, fmt, &timeInfo); +#else + std::strftime(timeStamp, timeStampSize, fmt, timeInfo); +#endif + return std::string(timeStamp); + } + + std::string fileNameTag(const std::vector &tags) { + auto it = std::find_if(begin(tags), + end(tags), + [] (std::string const& tag) {return tag.front() == '#'; }); + if (it != tags.end()) + return it->substr(1); + return std::string(); + } + } // anonymous namespace + + JunitReporter::JunitReporter( ReporterConfig const& _config ) + : CumulativeReporterBase( _config ), + xml( _config.stream() ) + { + m_reporterPrefs.shouldRedirectStdOut = true; + m_reporterPrefs.shouldReportAllAssertions = true; + } + + JunitReporter::~JunitReporter() {} + + std::string JunitReporter::getDescription() { + return "Reports test results in an XML format that looks like Ant's junitreport target"; + } + + void JunitReporter::noMatchingTestCases( std::string const& /*spec*/ ) {} + + void JunitReporter::testRunStarting( TestRunInfo const& runInfo ) { + CumulativeReporterBase::testRunStarting( runInfo ); + xml.startElement( "testsuites" ); + } + + void JunitReporter::testGroupStarting( GroupInfo const& groupInfo ) { + suiteTimer.start(); + stdOutForSuite.clear(); + stdErrForSuite.clear(); + unexpectedExceptions = 0; + CumulativeReporterBase::testGroupStarting( groupInfo ); + } + + void JunitReporter::testCaseStarting( TestCaseInfo const& testCaseInfo ) { + m_okToFail = testCaseInfo.okToFail(); + } + + bool JunitReporter::assertionEnded( AssertionStats const& assertionStats ) { + if( assertionStats.assertionResult.getResultType() == ResultWas::ThrewException && !m_okToFail ) + unexpectedExceptions++; + return CumulativeReporterBase::assertionEnded( assertionStats ); + } + + void JunitReporter::testCaseEnded( TestCaseStats const& testCaseStats ) { + stdOutForSuite += testCaseStats.stdOut; + stdErrForSuite += testCaseStats.stdErr; + CumulativeReporterBase::testCaseEnded( testCaseStats ); + } + + void JunitReporter::testGroupEnded( TestGroupStats const& testGroupStats ) { + double suiteTime = suiteTimer.getElapsedSeconds(); + CumulativeReporterBase::testGroupEnded( testGroupStats ); + writeGroup( *m_testGroups.back(), suiteTime ); + } + + void JunitReporter::testRunEndedCumulative() { + xml.endElement(); + } + + void JunitReporter::writeGroup( TestGroupNode const& groupNode, double suiteTime ) { + XmlWriter::ScopedElement e = xml.scopedElement( "testsuite" ); + TestGroupStats const& stats = groupNode.value; + xml.writeAttribute( "name", stats.groupInfo.name ); + xml.writeAttribute( "errors", unexpectedExceptions ); + xml.writeAttribute( "failures", stats.totals.assertions.failed-unexpectedExceptions ); + xml.writeAttribute( "tests", stats.totals.assertions.total() ); + xml.writeAttribute( "hostname", "tbd" ); // !TBD + if( m_config->showDurations() == ShowDurations::Never ) + xml.writeAttribute( "time", "" ); + else + xml.writeAttribute( "time", suiteTime ); + xml.writeAttribute( "timestamp", getCurrentTimestamp() ); + + // Write test cases + for( auto const& child : groupNode.children ) + writeTestCase( *child ); + + xml.scopedElement( "system-out" ).writeText( trim( stdOutForSuite ), false ); + xml.scopedElement( "system-err" ).writeText( trim( stdErrForSuite ), false ); + } + + void JunitReporter::writeTestCase( TestCaseNode const& testCaseNode ) { + TestCaseStats const& stats = testCaseNode.value; + + // All test cases have exactly one section - which represents the + // test case itself. That section may have 0-n nested sections + assert( testCaseNode.children.size() == 1 ); + SectionNode const& rootSection = *testCaseNode.children.front(); + + std::string className = stats.testInfo.className; + + if( className.empty() ) { + className = fileNameTag(stats.testInfo.tags); + if ( className.empty() ) + className = "global"; + } + + if ( !m_config->name().empty() ) + className = m_config->name() + "." + className; + + writeSection( className, "", rootSection ); + } + + void JunitReporter::writeSection( std::string const& className, + std::string const& rootName, + SectionNode const& sectionNode ) { + std::string name = trim( sectionNode.stats.sectionInfo.name ); + if( !rootName.empty() ) + name = rootName + '/' + name; + + if( !sectionNode.assertions.empty() || + !sectionNode.stdOut.empty() || + !sectionNode.stdErr.empty() ) { + XmlWriter::ScopedElement e = xml.scopedElement( "testcase" ); + if( className.empty() ) { + xml.writeAttribute( "classname", name ); + xml.writeAttribute( "name", "root" ); + } + else { + xml.writeAttribute( "classname", className ); + xml.writeAttribute( "name", name ); + } + xml.writeAttribute( "time", ::Catch::Detail::stringify( sectionNode.stats.durationInSeconds ) ); + + writeAssertions( sectionNode ); + + if( !sectionNode.stdOut.empty() ) + xml.scopedElement( "system-out" ).writeText( trim( sectionNode.stdOut ), false ); + if( !sectionNode.stdErr.empty() ) + xml.scopedElement( "system-err" ).writeText( trim( sectionNode.stdErr ), false ); + } + for( auto const& childNode : sectionNode.childSections ) + if( className.empty() ) + writeSection( name, "", *childNode ); + else + writeSection( className, name, *childNode ); + } + + void JunitReporter::writeAssertions( SectionNode const& sectionNode ) { + for( auto const& assertion : sectionNode.assertions ) + writeAssertion( assertion ); + } + + void JunitReporter::writeAssertion( AssertionStats const& stats ) { + AssertionResult const& result = stats.assertionResult; + if( !result.isOk() ) { + std::string elementName; + switch( result.getResultType() ) { + case ResultWas::ThrewException: + case ResultWas::FatalErrorCondition: + elementName = "error"; + break; + case ResultWas::ExplicitFailure: + elementName = "failure"; + break; + case ResultWas::ExpressionFailed: + elementName = "failure"; + break; + case ResultWas::DidntThrowException: + elementName = "failure"; + break; + + // We should never see these here: + case ResultWas::Info: + case ResultWas::Warning: + case ResultWas::Ok: + case ResultWas::Unknown: + case ResultWas::FailureBit: + case ResultWas::Exception: + elementName = "internalError"; + break; + } + + XmlWriter::ScopedElement e = xml.scopedElement( elementName ); + + xml.writeAttribute( "message", result.getExpandedExpression() ); + xml.writeAttribute( "type", result.getTestMacroName() ); + + ReusableStringStream rss; + if( !result.getMessage().empty() ) + rss << result.getMessage() << '\n'; + for( auto const& msg : stats.infoMessages ) + if( msg.type == ResultWas::Info ) + rss << msg.message << '\n'; + + rss << "at " << result.getSourceInfo(); + xml.writeText( rss.str(), false ); + } + } + + CATCH_REGISTER_REPORTER( "junit", JunitReporter ) + +} // end namespace Catch diff --git a/src/third_party/cppcodec/test/catch/include/reporters/catch_reporter_junit.h b/src/third_party/cppcodec/test/catch/include/reporters/catch_reporter_junit.h new file mode 100644 index 0000000000..5ee3a57004 --- /dev/null +++ b/src/third_party/cppcodec/test/catch/include/reporters/catch_reporter_junit.h @@ -0,0 +1,61 @@ +/* + * Created by Martin on 14/11/2017. + * + * 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_CATCH_REPORTER_JUNIT_H_INCLUDED +#define TWOBLUECUBES_CATCH_REPORTER_JUNIT_H_INCLUDED + + +#include "catch_reporter_bases.hpp" +#include "../internal/catch_xmlwriter.h" +#include "../internal/catch_timer.h" + +namespace Catch { + + class JunitReporter : public CumulativeReporterBase { + public: + JunitReporter(ReporterConfig const& _config); + + ~JunitReporter() override; + + static std::string getDescription(); + + void noMatchingTestCases(std::string const& /*spec*/) override; + + void testRunStarting(TestRunInfo const& runInfo) override; + + void testGroupStarting(GroupInfo const& groupInfo) override; + + void testCaseStarting(TestCaseInfo const& testCaseInfo) override; + bool assertionEnded(AssertionStats const& assertionStats) override; + + void testCaseEnded(TestCaseStats const& testCaseStats) override; + + void testGroupEnded(TestGroupStats const& testGroupStats) override; + + void testRunEndedCumulative() override; + + void writeGroup(TestGroupNode const& groupNode, double suiteTime); + + void writeTestCase(TestCaseNode const& testCaseNode); + + void writeSection(std::string const& className, + std::string const& rootName, + SectionNode const& sectionNode); + + void writeAssertions(SectionNode const& sectionNode); + void writeAssertion(AssertionStats const& stats); + + XmlWriter xml; + Timer suiteTimer; + std::string stdOutForSuite; + std::string stdErrForSuite; + unsigned int unexpectedExceptions = 0; + bool m_okToFail = false; + }; + +} // end namespace Catch + +#endif // TWOBLUECUBES_CATCH_REPORTER_JUNIT_H_INCLUDED diff --git a/src/third_party/cppcodec/test/catch/include/reporters/catch_reporter_listening.cpp b/src/third_party/cppcodec/test/catch/include/reporters/catch_reporter_listening.cpp new file mode 100644 index 0000000000..9ddae2f2ed --- /dev/null +++ b/src/third_party/cppcodec/test/catch/include/reporters/catch_reporter_listening.cpp @@ -0,0 +1,142 @@ +/* + * Created by Phil on 5/08/2015. + * Copyright 2015 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) + */ + + #include "catch_reporter_listening.h" +#include + +namespace Catch { + + ListeningReporter::ListeningReporter() { + // We will assume that listeners will always want all assertions + m_preferences.shouldReportAllAssertions = true; + } + + void ListeningReporter::addListener( IStreamingReporterPtr&& listener ) { + m_listeners.push_back( std::move( listener ) ); + } + + void ListeningReporter::addReporter(IStreamingReporterPtr&& reporter) { + assert(!m_reporter && "Listening reporter can wrap only 1 real reporter"); + m_reporter = std::move( reporter ); + m_preferences.shouldRedirectStdOut = m_reporter->getPreferences().shouldRedirectStdOut; + } + + ReporterPreferences ListeningReporter::getPreferences() const { + return m_preferences; + } + + std::set ListeningReporter::getSupportedVerbosities() { + return std::set{ }; + } + + + void ListeningReporter::noMatchingTestCases( std::string const& spec ) { + for ( auto const& listener : m_listeners ) { + listener->noMatchingTestCases( spec ); + } + m_reporter->noMatchingTestCases( spec ); + } + + void ListeningReporter::benchmarkStarting( BenchmarkInfo const& benchmarkInfo ) { + for ( auto const& listener : m_listeners ) { + listener->benchmarkStarting( benchmarkInfo ); + } + m_reporter->benchmarkStarting( benchmarkInfo ); + } + void ListeningReporter::benchmarkEnded( BenchmarkStats const& benchmarkStats ) { + for ( auto const& listener : m_listeners ) { + listener->benchmarkEnded( benchmarkStats ); + } + m_reporter->benchmarkEnded( benchmarkStats ); + } + + void ListeningReporter::testRunStarting( TestRunInfo const& testRunInfo ) { + for ( auto const& listener : m_listeners ) { + listener->testRunStarting( testRunInfo ); + } + m_reporter->testRunStarting( testRunInfo ); + } + + void ListeningReporter::testGroupStarting( GroupInfo const& groupInfo ) { + for ( auto const& listener : m_listeners ) { + listener->testGroupStarting( groupInfo ); + } + m_reporter->testGroupStarting( groupInfo ); + } + + + void ListeningReporter::testCaseStarting( TestCaseInfo const& testInfo ) { + for ( auto const& listener : m_listeners ) { + listener->testCaseStarting( testInfo ); + } + m_reporter->testCaseStarting( testInfo ); + } + + void ListeningReporter::sectionStarting( SectionInfo const& sectionInfo ) { + for ( auto const& listener : m_listeners ) { + listener->sectionStarting( sectionInfo ); + } + m_reporter->sectionStarting( sectionInfo ); + } + + void ListeningReporter::assertionStarting( AssertionInfo const& assertionInfo ) { + for ( auto const& listener : m_listeners ) { + listener->assertionStarting( assertionInfo ); + } + m_reporter->assertionStarting( assertionInfo ); + } + + // The return value indicates if the messages buffer should be cleared: + bool ListeningReporter::assertionEnded( AssertionStats const& assertionStats ) { + for( auto const& listener : m_listeners ) { + static_cast( listener->assertionEnded( assertionStats ) ); + } + return m_reporter->assertionEnded( assertionStats ); + } + + void ListeningReporter::sectionEnded( SectionStats const& sectionStats ) { + for ( auto const& listener : m_listeners ) { + listener->sectionEnded( sectionStats ); + } + m_reporter->sectionEnded( sectionStats ); + } + + void ListeningReporter::testCaseEnded( TestCaseStats const& testCaseStats ) { + for ( auto const& listener : m_listeners ) { + listener->testCaseEnded( testCaseStats ); + } + m_reporter->testCaseEnded( testCaseStats ); + } + + void ListeningReporter::testGroupEnded( TestGroupStats const& testGroupStats ) { + for ( auto const& listener : m_listeners ) { + listener->testGroupEnded( testGroupStats ); + } + m_reporter->testGroupEnded( testGroupStats ); + } + + void ListeningReporter::testRunEnded( TestRunStats const& testRunStats ) { + for ( auto const& listener : m_listeners ) { + listener->testRunEnded( testRunStats ); + } + m_reporter->testRunEnded( testRunStats ); + } + + + void ListeningReporter::skipTest( TestCaseInfo const& testInfo ) { + for ( auto const& listener : m_listeners ) { + listener->skipTest( testInfo ); + } + m_reporter->skipTest( testInfo ); + } + + bool ListeningReporter::isMulti() const { + return true; + } + +} // end namespace Catch diff --git a/src/third_party/cppcodec/test/catch/include/reporters/catch_reporter_listening.h b/src/third_party/cppcodec/test/catch/include/reporters/catch_reporter_listening.h new file mode 100644 index 0000000000..dddd7a5186 --- /dev/null +++ b/src/third_party/cppcodec/test/catch/include/reporters/catch_reporter_listening.h @@ -0,0 +1,57 @@ +/* + * Created by Martin on 19/07/2017. + * + * 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_CATCH_MULTI_REPORTER_H_INCLUDED +#define TWOBLUECUBES_CATCH_MULTI_REPORTER_H_INCLUDED + +#include "../internal/catch_interfaces_reporter.h" + +namespace Catch { + + class ListeningReporter : public IStreamingReporter { + using Reporters = std::vector; + Reporters m_listeners; + IStreamingReporterPtr m_reporter = nullptr; + ReporterPreferences m_preferences; + + public: + ListeningReporter(); + + void addListener( IStreamingReporterPtr&& listener ); + void addReporter( IStreamingReporterPtr&& reporter ); + + public: // IStreamingReporter + + ReporterPreferences getPreferences() const override; + + void noMatchingTestCases( std::string const& spec ) override; + + static std::set getSupportedVerbosities(); + + void benchmarkStarting( BenchmarkInfo const& benchmarkInfo ) override; + void benchmarkEnded( BenchmarkStats const& benchmarkStats ) override; + + void testRunStarting( TestRunInfo const& testRunInfo ) override; + void testGroupStarting( GroupInfo const& groupInfo ) override; + void testCaseStarting( TestCaseInfo const& testInfo ) override; + void sectionStarting( SectionInfo const& sectionInfo ) override; + void assertionStarting( AssertionInfo const& assertionInfo ) override; + + // The return value indicates if the messages buffer should be cleared: + bool assertionEnded( AssertionStats const& assertionStats ) override; + void sectionEnded( SectionStats const& sectionStats ) override; + void testCaseEnded( TestCaseStats const& testCaseStats ) override; + void testGroupEnded( TestGroupStats const& testGroupStats ) override; + void testRunEnded( TestRunStats const& testRunStats ) override; + + void skipTest( TestCaseInfo const& testInfo ) override; + bool isMulti() const override; + + }; + +} // end namespace Catch + +#endif // TWOBLUECUBES_CATCH_MULTI_REPORTER_H_INCLUDED diff --git a/src/third_party/cppcodec/test/catch/include/reporters/catch_reporter_tap.hpp b/src/third_party/cppcodec/test/catch/include/reporters/catch_reporter_tap.hpp new file mode 100644 index 0000000000..ccc4051be0 --- /dev/null +++ b/src/third_party/cppcodec/test/catch/include/reporters/catch_reporter_tap.hpp @@ -0,0 +1,253 @@ +/* + * Created by Colton Wolkins on 2015-08-15. + * Copyright 2015 Martin Moene. 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_CATCH_REPORTER_TAP_HPP_INCLUDED +#define TWOBLUECUBES_CATCH_REPORTER_TAP_HPP_INCLUDED + + +// Don't #include any Catch headers here - we can assume they are already +// included before this header. +// This is not good practice in general but is necessary in this case so this +// file can be distributed as a single header that works with the main +// Catch single header. + +#include + +namespace Catch { + + struct TAPReporter : StreamingReporterBase { + + using StreamingReporterBase::StreamingReporterBase; + + ~TAPReporter() override; + + static std::string getDescription() { + return "Reports test results in TAP format, suitable for test harnesses"; + } + + ReporterPreferences getPreferences() const override { + return m_reporterPrefs; + } + + void noMatchingTestCases( std::string const& spec ) override { + stream << "# No test cases matched '" << spec << "'" << std::endl; + } + + void assertionStarting( AssertionInfo const& ) override {} + + bool assertionEnded( AssertionStats const& _assertionStats ) override { + ++counter; + + AssertionPrinter printer( stream, _assertionStats, counter ); + printer.print(); + stream << " # " << currentTestCaseInfo->name ; + + stream << std::endl; + return true; + } + + void testRunEnded( TestRunStats const& _testRunStats ) override { + printTotals( _testRunStats.totals ); + stream << "\n" << std::endl; + StreamingReporterBase::testRunEnded( _testRunStats ); + } + + private: + std::size_t counter = 0; + class AssertionPrinter { + public: + AssertionPrinter& operator= ( AssertionPrinter const& ) = delete; + AssertionPrinter( AssertionPrinter const& ) = delete; + AssertionPrinter( std::ostream& _stream, AssertionStats const& _stats, std::size_t _counter ) + : stream( _stream ) + , result( _stats.assertionResult ) + , messages( _stats.infoMessages ) + , itMessage( _stats.infoMessages.begin() ) + , printInfoMessages( true ) + , counter(_counter) + {} + + void print() { + itMessage = messages.begin(); + + switch( result.getResultType() ) { + case ResultWas::Ok: + printResultType( passedString() ); + printOriginalExpression(); + printReconstructedExpression(); + if ( ! result.hasExpression() ) + printRemainingMessages( Colour::None ); + else + printRemainingMessages(); + break; + case ResultWas::ExpressionFailed: + if (result.isOk()) { + printResultType(passedString()); + } else { + printResultType(failedString()); + } + printOriginalExpression(); + printReconstructedExpression(); + if (result.isOk()) { + printIssue(" # TODO"); + } + printRemainingMessages(); + break; + case ResultWas::ThrewException: + printResultType( failedString() ); + printIssue( "unexpected exception with message:" ); + printMessage(); + printExpressionWas(); + printRemainingMessages(); + break; + case ResultWas::FatalErrorCondition: + printResultType( failedString() ); + printIssue( "fatal error condition with message:" ); + printMessage(); + printExpressionWas(); + printRemainingMessages(); + break; + case ResultWas::DidntThrowException: + printResultType( failedString() ); + printIssue( "expected exception, got none" ); + printExpressionWas(); + printRemainingMessages(); + break; + case ResultWas::Info: + printResultType( "info" ); + printMessage(); + printRemainingMessages(); + break; + case ResultWas::Warning: + printResultType( "warning" ); + printMessage(); + printRemainingMessages(); + break; + case ResultWas::ExplicitFailure: + printResultType( failedString() ); + printIssue( "explicitly" ); + printRemainingMessages( Colour::None ); + break; + // These cases are here to prevent compiler warnings + case ResultWas::Unknown: + case ResultWas::FailureBit: + case ResultWas::Exception: + printResultType( "** internal error **" ); + break; + } + } + + private: + static Colour::Code dimColour() { return Colour::FileName; } + + static const char* failedString() { return "not ok"; } + static const char* passedString() { return "ok"; } + + void printSourceInfo() const { + Colour colourGuard( dimColour() ); + stream << result.getSourceInfo() << ":"; + } + + void printResultType( std::string const& passOrFail ) const { + if( !passOrFail.empty() ) { + stream << passOrFail << ' ' << counter << " -"; + } + } + + void printIssue( std::string const& issue ) const { + stream << " " << issue; + } + + void printExpressionWas() { + if( result.hasExpression() ) { + stream << ";"; + { + Colour colour( dimColour() ); + stream << " expression was:"; + } + printOriginalExpression(); + } + } + + void printOriginalExpression() const { + if( result.hasExpression() ) { + stream << " " << result.getExpression(); + } + } + + void printReconstructedExpression() const { + if( result.hasExpandedExpression() ) { + { + Colour colour( dimColour() ); + stream << " for: "; + } + std::string expr = result.getExpandedExpression(); + std::replace( expr.begin(), expr.end(), '\n', ' '); + stream << expr; + } + } + + void printMessage() { + if ( itMessage != messages.end() ) { + stream << " '" << itMessage->message << "'"; + ++itMessage; + } + } + + void printRemainingMessages( Colour::Code colour = dimColour() ) { + if (itMessage == messages.end()) { + return; + } + + // using messages.end() directly (or auto) yields compilation error: + std::vector::const_iterator itEnd = messages.end(); + const std::size_t N = static_cast( std::distance( itMessage, itEnd ) ); + + { + Colour colourGuard( colour ); + stream << " with " << pluralise( N, "message" ) << ":"; + } + + for(; itMessage != itEnd; ) { + // If this assertion is a warning ignore any INFO messages + if( printInfoMessages || itMessage->type != ResultWas::Info ) { + stream << " '" << itMessage->message << "'"; + if ( ++itMessage != itEnd ) { + Colour colourGuard( dimColour() ); + stream << " and"; + } + } + } + } + + private: + std::ostream& stream; + AssertionResult const& result; + std::vector messages; + std::vector::const_iterator itMessage; + bool printInfoMessages; + std::size_t counter; + }; + + void printTotals( const Totals& totals ) const { + if( totals.testCases.total() == 0 ) { + stream << "1..0 # Skipped: No tests ran."; + } else { + stream << "1.." << counter; + } + } + }; + +#ifdef CATCH_IMPL + TAPReporter::~TAPReporter() {} +#endif + + CATCH_REGISTER_REPORTER( "tap", TAPReporter ) + +} // end namespace Catch + +#endif // TWOBLUECUBES_CATCH_REPORTER_TAP_HPP_INCLUDED diff --git a/src/third_party/cppcodec/test/catch/include/reporters/catch_reporter_teamcity.hpp b/src/third_party/cppcodec/test/catch/include/reporters/catch_reporter_teamcity.hpp new file mode 100644 index 0000000000..dbd0db532c --- /dev/null +++ b/src/third_party/cppcodec/test/catch/include/reporters/catch_reporter_teamcity.hpp @@ -0,0 +1,220 @@ +/* + * Created by Phil Nash on 19th December 2014 + * Copyright 2014 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_CATCH_REPORTER_TEAMCITY_HPP_INCLUDED +#define TWOBLUECUBES_CATCH_REPORTER_TEAMCITY_HPP_INCLUDED + +// Don't #include any Catch headers here - we can assume they are already +// included before this header. +// This is not good practice in general but is necessary in this case so this +// file can be distributed as a single header that works with the main +// Catch single header. + +#include + +#ifdef __clang__ +# pragma clang diagnostic push +# pragma clang diagnostic ignored "-Wpadded" +#endif + +namespace Catch { + + struct TeamCityReporter : StreamingReporterBase { + TeamCityReporter( ReporterConfig const& _config ) + : StreamingReporterBase( _config ) + { + m_reporterPrefs.shouldRedirectStdOut = true; + } + + static std::string escape( std::string const& str ) { + std::string escaped = str; + replaceInPlace( escaped, "|", "||" ); + replaceInPlace( escaped, "'", "|'" ); + replaceInPlace( escaped, "\n", "|n" ); + replaceInPlace( escaped, "\r", "|r" ); + replaceInPlace( escaped, "[", "|[" ); + replaceInPlace( escaped, "]", "|]" ); + return escaped; + } + ~TeamCityReporter() override; + + static std::string getDescription() { + return "Reports test results as TeamCity service messages"; + } + + void skipTest( TestCaseInfo const& /* testInfo */ ) override { + } + + void noMatchingTestCases( std::string const& /* spec */ ) override {} + + void testGroupStarting( GroupInfo const& groupInfo ) override { + StreamingReporterBase::testGroupStarting( groupInfo ); + stream << "##teamcity[testSuiteStarted name='" + << escape( groupInfo.name ) << "']\n"; + } + void testGroupEnded( TestGroupStats const& testGroupStats ) override { + StreamingReporterBase::testGroupEnded( testGroupStats ); + stream << "##teamcity[testSuiteFinished name='" + << escape( testGroupStats.groupInfo.name ) << "']\n"; + } + + + void assertionStarting( AssertionInfo const& ) override {} + + bool assertionEnded( AssertionStats const& assertionStats ) override { + AssertionResult const& result = assertionStats.assertionResult; + if( !result.isOk() ) { + + ReusableStringStream msg; + if( !m_headerPrintedForThisSection ) + printSectionHeader( msg.get() ); + m_headerPrintedForThisSection = true; + + msg << result.getSourceInfo() << "\n"; + + switch( result.getResultType() ) { + case ResultWas::ExpressionFailed: + msg << "expression failed"; + break; + case ResultWas::ThrewException: + msg << "unexpected exception"; + break; + case ResultWas::FatalErrorCondition: + msg << "fatal error condition"; + break; + case ResultWas::DidntThrowException: + msg << "no exception was thrown where one was expected"; + break; + case ResultWas::ExplicitFailure: + msg << "explicit failure"; + break; + + // We shouldn't get here because of the isOk() test + case ResultWas::Ok: + case ResultWas::Info: + case ResultWas::Warning: + throw std::domain_error( "Internal error in TeamCity reporter" ); + // These cases are here to prevent compiler warnings + case ResultWas::Unknown: + case ResultWas::FailureBit: + case ResultWas::Exception: + throw std::domain_error( "Not implemented" ); + } + if( assertionStats.infoMessages.size() == 1 ) + msg << " with message:"; + if( assertionStats.infoMessages.size() > 1 ) + msg << " with messages:"; + for( auto const& messageInfo : assertionStats.infoMessages ) + msg << "\n \"" << messageInfo.message << "\""; + + + if( result.hasExpression() ) { + msg << + "\n " << result.getExpressionInMacro() << "\n" + "with expansion:\n" << + " " << result.getExpandedExpression() << "\n"; + } + + if( currentTestCaseInfo->okToFail() ) { + msg << "- failure ignore as test marked as 'ok to fail'\n"; + stream << "##teamcity[testIgnored" + << " name='" << escape( currentTestCaseInfo->name )<< "'" + << " message='" << escape( msg.str() ) << "'" + << "]\n"; + } + else { + stream << "##teamcity[testFailed" + << " name='" << escape( currentTestCaseInfo->name )<< "'" + << " message='" << escape( msg.str() ) << "'" + << "]\n"; + } + } + stream.flush(); + return true; + } + + void sectionStarting( SectionInfo const& sectionInfo ) override { + m_headerPrintedForThisSection = false; + StreamingReporterBase::sectionStarting( sectionInfo ); + } + + void testCaseStarting( TestCaseInfo const& testInfo ) override { + m_testTimer.start(); + StreamingReporterBase::testCaseStarting( testInfo ); + stream << "##teamcity[testStarted name='" + << escape( testInfo.name ) << "']\n"; + stream.flush(); + } + + void testCaseEnded( TestCaseStats const& testCaseStats ) override { + StreamingReporterBase::testCaseEnded( testCaseStats ); + if( !testCaseStats.stdOut.empty() ) + stream << "##teamcity[testStdOut name='" + << escape( testCaseStats.testInfo.name ) + << "' out='" << escape( testCaseStats.stdOut ) << "']\n"; + if( !testCaseStats.stdErr.empty() ) + stream << "##teamcity[testStdErr name='" + << escape( testCaseStats.testInfo.name ) + << "' out='" << escape( testCaseStats.stdErr ) << "']\n"; + stream << "##teamcity[testFinished name='" + << escape( testCaseStats.testInfo.name ) << "' duration='" + << m_testTimer.getElapsedMilliseconds() << "']\n"; + stream.flush(); + } + + private: + void printSectionHeader( std::ostream& os ) { + assert( !m_sectionStack.empty() ); + + if( m_sectionStack.size() > 1 ) { + os << getLineOfChars<'-'>() << "\n"; + + std::vector::const_iterator + it = m_sectionStack.begin()+1, // Skip first section (test case) + itEnd = m_sectionStack.end(); + for( ; it != itEnd; ++it ) + printHeaderString( os, it->name ); + os << getLineOfChars<'-'>() << "\n"; + } + + SourceLineInfo lineInfo = m_sectionStack.front().lineInfo; + + if( !lineInfo.empty() ) + os << lineInfo << "\n"; + os << getLineOfChars<'.'>() << "\n\n"; + } + + // if string has a : in first line will set indent to follow it on + // subsequent lines + static void printHeaderString( std::ostream& os, std::string const& _string, std::size_t indent = 0 ) { + std::size_t i = _string.find( ": " ); + if( i != std::string::npos ) + i+=2; + else + i = 0; + os << Column( _string ) + .indent( indent+i) + .initialIndent( indent ) << "\n"; + } + private: + bool m_headerPrintedForThisSection = false; + Timer m_testTimer; + }; + +#ifdef CATCH_IMPL + TeamCityReporter::~TeamCityReporter() {} +#endif + + CATCH_REGISTER_REPORTER( "teamcity", TeamCityReporter ) + +} // end namespace Catch + +#ifdef __clang__ +# pragma clang diagnostic pop +#endif + +#endif // TWOBLUECUBES_CATCH_REPORTER_TEAMCITY_HPP_INCLUDED diff --git a/src/third_party/cppcodec/test/catch/include/reporters/catch_reporter_xml.cpp b/src/third_party/cppcodec/test/catch/include/reporters/catch_reporter_xml.cpp new file mode 100644 index 0000000000..c32005370d --- /dev/null +++ b/src/third_party/cppcodec/test/catch/include/reporters/catch_reporter_xml.cpp @@ -0,0 +1,223 @@ +/* + * Created by Phil on 28/10/2010. + * Copyright 2010 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) + */ + +#include "catch_reporter_xml.h" + +#include "../internal/catch_capture.hpp" +#include "../internal/catch_reporter_registrars.hpp" + +#if defined(_MSC_VER) +#pragma warning(push) +#pragma warning(disable:4061) // Not all labels are EXPLICITLY handled in switch + // Note that 4062 (not all labels are handled + // and default is missing) is enabled +#endif + +namespace Catch { + XmlReporter::XmlReporter( ReporterConfig const& _config ) + : StreamingReporterBase( _config ), + m_xml(_config.stream()) + { + m_reporterPrefs.shouldRedirectStdOut = true; + m_reporterPrefs.shouldReportAllAssertions = true; + } + + XmlReporter::~XmlReporter() = default; + + std::string XmlReporter::getDescription() { + return "Reports test results as an XML document"; + } + + std::string XmlReporter::getStylesheetRef() const { + return std::string(); + } + + void XmlReporter::writeSourceInfo( SourceLineInfo const& sourceInfo ) { + m_xml + .writeAttribute( "filename", sourceInfo.file ) + .writeAttribute( "line", sourceInfo.line ); + } + + void XmlReporter::noMatchingTestCases( std::string const& s ) { + StreamingReporterBase::noMatchingTestCases( s ); + } + + void XmlReporter::testRunStarting( TestRunInfo const& testInfo ) { + StreamingReporterBase::testRunStarting( testInfo ); + std::string stylesheetRef = getStylesheetRef(); + if( !stylesheetRef.empty() ) + m_xml.writeStylesheetRef( stylesheetRef ); + m_xml.startElement( "Catch" ); + if( !m_config->name().empty() ) + m_xml.writeAttribute( "name", m_config->name() ); + } + + void XmlReporter::testGroupStarting( GroupInfo const& groupInfo ) { + StreamingReporterBase::testGroupStarting( groupInfo ); + m_xml.startElement( "Group" ) + .writeAttribute( "name", groupInfo.name ); + } + + void XmlReporter::testCaseStarting( TestCaseInfo const& testInfo ) { + StreamingReporterBase::testCaseStarting(testInfo); + m_xml.startElement( "TestCase" ) + .writeAttribute( "name", trim( testInfo.name ) ) + .writeAttribute( "description", testInfo.description ) + .writeAttribute( "tags", testInfo.tagsAsString() ); + + writeSourceInfo( testInfo.lineInfo ); + + if ( m_config->showDurations() == ShowDurations::Always ) + m_testCaseTimer.start(); + m_xml.ensureTagClosed(); + } + + void XmlReporter::sectionStarting( SectionInfo const& sectionInfo ) { + StreamingReporterBase::sectionStarting( sectionInfo ); + if( m_sectionDepth++ > 0 ) { + m_xml.startElement( "Section" ) + .writeAttribute( "name", trim( sectionInfo.name ) ); + writeSourceInfo( sectionInfo.lineInfo ); + m_xml.ensureTagClosed(); + } + } + + void XmlReporter::assertionStarting( AssertionInfo const& ) { } + + bool XmlReporter::assertionEnded( AssertionStats const& assertionStats ) { + + AssertionResult const& result = assertionStats.assertionResult; + + bool includeResults = m_config->includeSuccessfulResults() || !result.isOk(); + + if( includeResults || result.getResultType() == ResultWas::Warning ) { + // Print any info messages in tags. + for( auto const& msg : assertionStats.infoMessages ) { + if( msg.type == ResultWas::Info && includeResults ) { + m_xml.scopedElement( "Info" ) + .writeText( msg.message ); + } else if ( msg.type == ResultWas::Warning ) { + m_xml.scopedElement( "Warning" ) + .writeText( msg.message ); + } + } + } + + // Drop out if result was successful but we're not printing them. + if( !includeResults && result.getResultType() != ResultWas::Warning ) + return true; + + + // Print the expression if there is one. + if( result.hasExpression() ) { + m_xml.startElement( "Expression" ) + .writeAttribute( "success", result.succeeded() ) + .writeAttribute( "type", result.getTestMacroName() ); + + writeSourceInfo( result.getSourceInfo() ); + + m_xml.scopedElement( "Original" ) + .writeText( result.getExpression() ); + m_xml.scopedElement( "Expanded" ) + .writeText( result.getExpandedExpression() ); + } + + // And... Print a result applicable to each result type. + switch( result.getResultType() ) { + case ResultWas::ThrewException: + m_xml.startElement( "Exception" ); + writeSourceInfo( result.getSourceInfo() ); + m_xml.writeText( result.getMessage() ); + m_xml.endElement(); + break; + case ResultWas::FatalErrorCondition: + m_xml.startElement( "FatalErrorCondition" ); + writeSourceInfo( result.getSourceInfo() ); + m_xml.writeText( result.getMessage() ); + m_xml.endElement(); + break; + case ResultWas::Info: + m_xml.scopedElement( "Info" ) + .writeText( result.getMessage() ); + break; + case ResultWas::Warning: + // Warning will already have been written + break; + case ResultWas::ExplicitFailure: + m_xml.startElement( "Failure" ); + writeSourceInfo( result.getSourceInfo() ); + m_xml.writeText( result.getMessage() ); + m_xml.endElement(); + break; + default: + break; + } + + if( result.hasExpression() ) + m_xml.endElement(); + + return true; + } + + void XmlReporter::sectionEnded( SectionStats const& sectionStats ) { + StreamingReporterBase::sectionEnded( sectionStats ); + if( --m_sectionDepth > 0 ) { + XmlWriter::ScopedElement e = m_xml.scopedElement( "OverallResults" ); + e.writeAttribute( "successes", sectionStats.assertions.passed ); + e.writeAttribute( "failures", sectionStats.assertions.failed ); + e.writeAttribute( "expectedFailures", sectionStats.assertions.failedButOk ); + + if ( m_config->showDurations() == ShowDurations::Always ) + e.writeAttribute( "durationInSeconds", sectionStats.durationInSeconds ); + + m_xml.endElement(); + } + } + + void XmlReporter::testCaseEnded( TestCaseStats const& testCaseStats ) { + StreamingReporterBase::testCaseEnded( testCaseStats ); + XmlWriter::ScopedElement e = m_xml.scopedElement( "OverallResult" ); + e.writeAttribute( "success", testCaseStats.totals.assertions.allOk() ); + + if ( m_config->showDurations() == ShowDurations::Always ) + e.writeAttribute( "durationInSeconds", m_testCaseTimer.getElapsedSeconds() ); + + if( !testCaseStats.stdOut.empty() ) + m_xml.scopedElement( "StdOut" ).writeText( trim( testCaseStats.stdOut ), false ); + if( !testCaseStats.stdErr.empty() ) + m_xml.scopedElement( "StdErr" ).writeText( trim( testCaseStats.stdErr ), false ); + + m_xml.endElement(); + } + + void XmlReporter::testGroupEnded( TestGroupStats const& testGroupStats ) { + StreamingReporterBase::testGroupEnded( testGroupStats ); + // TODO: Check testGroupStats.aborting and act accordingly. + m_xml.scopedElement( "OverallResults" ) + .writeAttribute( "successes", testGroupStats.totals.assertions.passed ) + .writeAttribute( "failures", testGroupStats.totals.assertions.failed ) + .writeAttribute( "expectedFailures", testGroupStats.totals.assertions.failedButOk ); + m_xml.endElement(); + } + + void XmlReporter::testRunEnded( TestRunStats const& testRunStats ) { + StreamingReporterBase::testRunEnded( testRunStats ); + m_xml.scopedElement( "OverallResults" ) + .writeAttribute( "successes", testRunStats.totals.assertions.passed ) + .writeAttribute( "failures", testRunStats.totals.assertions.failed ) + .writeAttribute( "expectedFailures", testRunStats.totals.assertions.failedButOk ); + m_xml.endElement(); + } + + CATCH_REGISTER_REPORTER( "xml", XmlReporter ) + +} // end namespace Catch + +#if defined(_MSC_VER) +#pragma warning(pop) +#endif diff --git a/src/third_party/cppcodec/test/catch/include/reporters/catch_reporter_xml.h b/src/third_party/cppcodec/test/catch/include/reporters/catch_reporter_xml.h new file mode 100644 index 0000000000..7926f93a85 --- /dev/null +++ b/src/third_party/cppcodec/test/catch/include/reporters/catch_reporter_xml.h @@ -0,0 +1,61 @@ +/* + * Created by Martin on 14/11/2017. + * + * 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_CATCH_REPORTER_XML_H_INCLUDED +#define TWOBLUECUBES_CATCH_REPORTER_XML_H_INCLUDED + +#include "catch_reporter_bases.hpp" + +#include "../internal/catch_xmlwriter.h" +#include "../internal/catch_timer.h" + + +namespace Catch { + class XmlReporter : public StreamingReporterBase { + public: + XmlReporter(ReporterConfig const& _config); + + ~XmlReporter() override; + + static std::string getDescription(); + + virtual std::string getStylesheetRef() const; + + void writeSourceInfo(SourceLineInfo const& sourceInfo); + + public: // StreamingReporterBase + + void noMatchingTestCases(std::string const& s) override; + + void testRunStarting(TestRunInfo const& testInfo) override; + + void testGroupStarting(GroupInfo const& groupInfo) override; + + void testCaseStarting(TestCaseInfo const& testInfo) override; + + void sectionStarting(SectionInfo const& sectionInfo) override; + + void assertionStarting(AssertionInfo const&) override; + + bool assertionEnded(AssertionStats const& assertionStats) override; + + void sectionEnded(SectionStats const& sectionStats) override; + + void testCaseEnded(TestCaseStats const& testCaseStats) override; + + void testGroupEnded(TestGroupStats const& testGroupStats) override; + + void testRunEnded(TestRunStats const& testRunStats) override; + + private: + Timer m_testCaseTimer; + XmlWriter m_xml; + int m_sectionDepth = 0; + }; + +} // end namespace Catch + +#endif // TWOBLUECUBES_CATCH_REPORTER_XML_H_INCLUDED diff --git a/src/third_party/cppcodec/test/catch/misc/CMakeLists.txt b/src/third_party/cppcodec/test/catch/misc/CMakeLists.txt new file mode 100644 index 0000000000..bf80846cdc --- /dev/null +++ b/src/third_party/cppcodec/test/catch/misc/CMakeLists.txt @@ -0,0 +1,11 @@ +cmake_minimum_required(VERSION 3.0) + +project(CatchCoverageHelper) + +add_executable(CoverageHelper coverage-helper.cpp) +set_property(TARGET CoverageHelper PROPERTY CXX_STANDARD 11) +set_property(TARGET CoverageHelper PROPERTY CXX_STANDARD_REQUIRED ON) +set_property(TARGET CoverageHelper PROPERTY CXX_EXTENSIONS OFF) +if (MSVC) + target_compile_options( CoverageHelper PRIVATE /W4 /w44265 /WX /w44061 /w44062 ) +endif() diff --git a/src/third_party/cppcodec/test/catch/misc/appveyorBuildConfigurationScript.bat b/src/third_party/cppcodec/test/catch/misc/appveyorBuildConfigurationScript.bat new file mode 100644 index 0000000000..1e91a588f7 --- /dev/null +++ b/src/third_party/cppcodec/test/catch/misc/appveyorBuildConfigurationScript.bat @@ -0,0 +1,27 @@ + +@REM # Possibilities: +@REM # Debug build + coverage +@REM # Debug build + examples +@REM # Debug build + --- +@REM # Release build +if "%CONFIGURATION%"=="Debug" ( + if "%coverage%"=="1" ( + @REM # coverage needs to build the special helper as well as the main + cmake -Hmisc -Bbuild-misc -A%PLATFORM% + cmake --build build-misc + cmake -H. -BBuild -A%PLATFORM% -DUSE_WMAIN=%wmain% -DMEMORYCHECK_COMMAND=build-misc\Debug\CoverageHelper.exe -DMEMORYCHECK_COMMAND_OPTIONS=--sep-- -DMEMORYCHECK_TYPE=Valgrind + ) else ( + @REM # We know that coverage is 0 + if "%examples%"=="1" ( + @REM # Examples live off the single header, so it needs to be regenerated + python scripts\generateSingleHeader.py + cmake -H. -BBuild -A%PLATFORM% -DUSE_WMAIN=%wmain% -DCATCH_BUILD_EXAMPLES=ON + ) else ( + @REM # This is just a plain debug build + cmake -H. -BBuild -A%PLATFORM% -DUSE_WMAIN=%wmain% + ) + ) +) +if "%CONFIGURATION%"=="Release" ( + cmake -H. -BBuild -A%PLATFORM% -DUSE_WMAIN=%wmain% +) diff --git a/src/third_party/cppcodec/test/catch/misc/appveyorMergeCoverageScript.py b/src/third_party/cppcodec/test/catch/misc/appveyorMergeCoverageScript.py new file mode 100644 index 0000000000..a74e6e0e81 --- /dev/null +++ b/src/third_party/cppcodec/test/catch/misc/appveyorMergeCoverageScript.py @@ -0,0 +1,9 @@ +#!/usr/bin/env python2 + +import glob +import subprocess + +if __name__ == '__main__': + cov_files = list(glob.glob('cov-report*.bin')) + base_cmd = ['OpenCppCoverage', '--quiet', '--export_type=cobertura:cobertura.xml'] + ['--input_coverage={}'.format(f) for f in cov_files] + subprocess.call(base_cmd) diff --git a/src/third_party/cppcodec/test/catch/misc/appveyorTestRunScript.bat b/src/third_party/cppcodec/test/catch/misc/appveyorTestRunScript.bat new file mode 100644 index 0000000000..19a364be12 --- /dev/null +++ b/src/third_party/cppcodec/test/catch/misc/appveyorTestRunScript.bat @@ -0,0 +1,13 @@ +cd Build +if "%CONFIGURATION%"=="Debug" ( + if "%coverage%"=="1" ( + ctest -j 2 -C %CONFIGURATION% -D ExperimentalMemCheck + python ..\misc\appveyorMergeCoverageScript.py + codecov --root .. --no-color --disable gcov -f cobertura.xml -t %CODECOV_TOKEN% + ) else ( + ctest -j 2 -C %CONFIGURATION% + ) +) +if "%CONFIGURATION%"=="Release" ( + ctest -j 2 -C %CONFIGURATION% +) diff --git a/src/third_party/cppcodec/test/catch/misc/coverage-helper.cpp b/src/third_party/cppcodec/test/catch/misc/coverage-helper.cpp new file mode 100644 index 0000000000..1721890557 --- /dev/null +++ b/src/third_party/cppcodec/test/catch/misc/coverage-helper.cpp @@ -0,0 +1,105 @@ +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + + +void create_empty_file(std::string const& path) { + std::ofstream ofs(path); + ofs << '\n'; +} + +const std::string separator = "--sep--"; +const std::string logfile_prefix = "--log-file="; + +bool starts_with(std::string const& str, std::string const& pref) { + return str.find(pref) == 0; +} + +int parse_log_file_arg(std::string const& arg) { + assert(starts_with(arg, logfile_prefix) && "Attempting to parse incorrect arg!"); + auto fname = arg.substr(logfile_prefix.size()); + create_empty_file(fname); + std::regex regex("MemoryChecker\\.(\\d+)\\.log", std::regex::icase); + std::smatch match; + if (std::regex_search(fname, match, regex)) { + return std::stoi(match[1]); + } else { + throw std::domain_error("Couldn't find desired expression in string: " + fname); + } +} + +std::string catch_path(std::string path) { + auto start = path.find("catch"); + // try capitalized instead + if (start == std::string::npos) { + start = path.find("Catch"); + } + if (start == std::string::npos) { + throw std::domain_error("Couldn't find Catch's base path"); + } + auto end = path.find_first_of("\\/", start); + return path.substr(0, end); +} + +std::string windowsify_path(std::string path) { + for (auto& c : path) { + if (c == '/') { + c = '\\'; + } + } + return path; +} + +void exec_cmd(std::string const& cmd, int log_num, std::string const& path) { + std::array buffer; +#if defined(_WIN32) + auto real_cmd = "OpenCppCoverage --export_type binary:cov-report" + std::to_string(log_num) + + ".bin --quiet " + "--sources " + path + " --cover_children -- " + cmd; + std::cout << "=== Marker ===: Cmd: " << real_cmd << '\n'; + std::shared_ptr pipe(_popen(real_cmd.c_str(), "r"), _pclose); +#else // Just for testing, in the real world we will always work under WIN32 + (void)log_num; (void)path; + std::shared_ptr pipe(popen(cmd.c_str(), "r"), pclose); +#endif + + if (!pipe) { + throw std::runtime_error("popen() failed!"); + } + while (!feof(pipe.get())) { + if (fgets(buffer.data(), 128, pipe.get()) != nullptr) { + std::cout << buffer.data(); + } + } +} + +// argv should be: +// [0]: our path +// [1]: "--log-file=" +// [2]: "--sep--" +// [3]+: the actual command + +int main(int argc, char** argv) { + std::vector args(argv, argv + argc); + auto sep = std::find(begin(args), end(args), separator); + assert(sep - begin(args) == 2 && "Structure differs from expected!"); + + auto num = parse_log_file_arg(args[1]); + + auto cmdline = std::accumulate(++sep, end(args), std::string{}, [] (const std::string& lhs, const std::string& rhs) { + return lhs + ' ' + rhs; + }); + + try { + return exec_cmd(cmdline, num, windowsify_path(catch_path(args[0]))); + } catch (std::exception const& ex) { + std::cerr << "Helper failed with: '" << ex.what() << "'\n"; + return 12; + } +} diff --git a/src/third_party/cppcodec/test/catch/misc/installOpenCppCoverage.ps1 b/src/third_party/cppcodec/test/catch/misc/installOpenCppCoverage.ps1 new file mode 100644 index 0000000000..d277a55deb --- /dev/null +++ b/src/third_party/cppcodec/test/catch/misc/installOpenCppCoverage.ps1 @@ -0,0 +1,19 @@ +# Downloads are done from the official github release page links +$downloadUrl = "https://github.com/OpenCppCoverage/OpenCppCoverage/releases/download/release-0.9.7.0/OpenCppCoverageSetup-x64-0.9.7.0.exe" +$installerPath = [System.IO.Path]::Combine($Env:USERPROFILE, "Downloads", "OpenCppCoverageSetup.exe") + +if(-Not (Test-Path $installerPath)) { + Write-Host -ForegroundColor White ("Downloading OpenCppCoverage from: " + $downloadUrl) + Start-FileDownload $downloadUrl -FileName $installerPath +} + +Write-Host -ForegroundColor White "About to install OpenCppCoverage..." + +$installProcess = (Start-Process $installerPath -ArgumentList '/VERYSILENT' -PassThru -Wait) +if($installProcess.ExitCode -ne 0) { + throw [System.String]::Format("Failed to install OpenCppCoverage, ExitCode: {0}.", $installProcess.ExitCode) +} + +# Assume standard, boring, installation path of ".../Program Files/OpenCppCoverage" +$installPath = [System.IO.Path]::Combine(${Env:ProgramFiles}, "OpenCppCoverage") +$env:Path="$env:Path;$installPath" diff --git a/src/third_party/cppcodec/test/catch/projects/CMakeLists.txt b/src/third_party/cppcodec/test/catch/projects/CMakeLists.txt new file mode 100644 index 0000000000..2084c74560 --- /dev/null +++ b/src/third_party/cppcodec/test/catch/projects/CMakeLists.txt @@ -0,0 +1,329 @@ +include(MiscFunctions) + +# define the sources of the self test +# Please keep these ordered alphabetically +set(TEST_SOURCES + ${SELF_TEST_DIR}/TestMain.cpp + ${SELF_TEST_DIR}/IntrospectiveTests/CmdLine.tests.cpp + ${SELF_TEST_DIR}/IntrospectiveTests/PartTracker.tests.cpp + ${SELF_TEST_DIR}/IntrospectiveTests/TagAlias.tests.cpp + ${SELF_TEST_DIR}/IntrospectiveTests/String.tests.cpp + ${SELF_TEST_DIR}/IntrospectiveTests/Xml.tests.cpp + ${SELF_TEST_DIR}/UsageTests/Approx.tests.cpp + ${SELF_TEST_DIR}/UsageTests/BDD.tests.cpp + ${SELF_TEST_DIR}/UsageTests/Benchmark.tests.cpp + ${SELF_TEST_DIR}/UsageTests/Class.tests.cpp + ${SELF_TEST_DIR}/UsageTests/Compilation.tests.cpp + ${SELF_TEST_DIR}/UsageTests/Condition.tests.cpp + ${SELF_TEST_DIR}/UsageTests/Decomposition.tests.cpp + ${SELF_TEST_DIR}/UsageTests/EnumToString.tests.cpp + ${SELF_TEST_DIR}/UsageTests/Exception.tests.cpp + ${SELF_TEST_DIR}/UsageTests/Message.tests.cpp + ${SELF_TEST_DIR}/UsageTests/Misc.tests.cpp + ${SELF_TEST_DIR}/UsageTests/ToStringChrono.tests.cpp + ${SELF_TEST_DIR}/UsageTests/ToStringGeneral.tests.cpp + ${SELF_TEST_DIR}/UsageTests/ToStringPair.tests.cpp + ${SELF_TEST_DIR}/UsageTests/ToStringTuple.tests.cpp + ${SELF_TEST_DIR}/UsageTests/ToStringVector.tests.cpp + ${SELF_TEST_DIR}/UsageTests/ToStringWhich.tests.cpp + ${SELF_TEST_DIR}/UsageTests/Tricky.tests.cpp + ${SELF_TEST_DIR}/UsageTests/VariadicMacros.tests.cpp + ${SELF_TEST_DIR}/UsageTests/Matchers.tests.cpp + ) +CheckFileList(TEST_SOURCES ${SELF_TEST_DIR}) + +# A set of impl files that just #include a single header +# Please keep these ordered alphabetically +set(SURROGATE_SOURCES + ${SELF_TEST_DIR}/SurrogateCpps/catch_console_colour.cpp + ${SELF_TEST_DIR}/SurrogateCpps/catch_debugger.cpp + ${SELF_TEST_DIR}/SurrogateCpps/catch_interfaces_reporter.cpp + ${SELF_TEST_DIR}/SurrogateCpps/catch_option.cpp + ${SELF_TEST_DIR}/SurrogateCpps/catch_stream.cpp + ${SELF_TEST_DIR}/SurrogateCpps/catch_test_case_tracker.cpp + ${SELF_TEST_DIR}/SurrogateCpps/catch_test_spec.cpp + ${SELF_TEST_DIR}/SurrogateCpps/catch_xmlwriter.cpp + ) +CheckFileList(SURROGATE_SOURCES ${SELF_TEST_DIR}/SurrogateCpps) + + +# Please keep these ordered alphabetically +set(TOP_LEVEL_HEADERS + ${HEADER_DIR}/catch.hpp + ${HEADER_DIR}/catch_with_main.hpp + ) +CheckFileList(TOP_LEVEL_HEADERS ${HEADER_DIR}) + +# Please keep these ordered alphabetically +set(EXTERNAL_HEADERS + ${HEADER_DIR}/external/clara.hpp + ) +CheckFileList(EXTERNAL_HEADERS ${HEADER_DIR}/external) + + +# Please keep these ordered alphabetically +set(INTERNAL_HEADERS + ${HEADER_DIR}/internal/catch_approx.h + ${HEADER_DIR}/internal/catch_assertionhandler.h + ${HEADER_DIR}/internal/catch_assertioninfo.h + ${HEADER_DIR}/internal/catch_assertionresult.h + ${HEADER_DIR}/internal/catch_capture.hpp + ${HEADER_DIR}/internal/catch_capture_matchers.h + ${HEADER_DIR}/internal/catch_clara.h + ${HEADER_DIR}/internal/catch_commandline.h + ${HEADER_DIR}/internal/catch_common.h + ${HEADER_DIR}/internal/catch_compiler_capabilities.h + ${HEADER_DIR}/internal/catch_config.hpp + ${HEADER_DIR}/internal/catch_console_colour.h + ${HEADER_DIR}/internal/catch_context.h + ${HEADER_DIR}/internal/catch_debug_console.h + ${HEADER_DIR}/internal/catch_debugger.h + ${HEADER_DIR}/internal/catch_decomposer.h + ${HEADER_DIR}/internal/catch_default_main.hpp + ${HEADER_DIR}/internal/catch_enforce.h + ${HEADER_DIR}/internal/catch_errno_guard.h + ${HEADER_DIR}/internal/catch_exception_translator_registry.h + ${HEADER_DIR}/internal/catch_external_interfaces.h + ${HEADER_DIR}/internal/catch_fatal_condition.h + ${HEADER_DIR}/internal/catch_impl.hpp + ${HEADER_DIR}/internal/catch_interfaces_capture.h + ${HEADER_DIR}/internal/catch_interfaces_config.h + ${HEADER_DIR}/internal/catch_interfaces_exception.h + ${HEADER_DIR}/internal/catch_interfaces_registry_hub.h + ${HEADER_DIR}/internal/catch_interfaces_reporter.h + ${HEADER_DIR}/internal/catch_interfaces_runner.h + ${HEADER_DIR}/internal/catch_interfaces_tag_alias_registry.h + ${HEADER_DIR}/internal/catch_interfaces_testcase.h + ${HEADER_DIR}/internal/catch_leak_detector.h + ${HEADER_DIR}/internal/catch_list.h + ${HEADER_DIR}/internal/catch_matchers.h + ${HEADER_DIR}/internal/catch_matchers_floating.h + ${HEADER_DIR}/internal/catch_matchers_generic.hpp + ${HEADER_DIR}/internal/catch_matchers_string.h + ${HEADER_DIR}/internal/catch_matchers_vector.h + ${HEADER_DIR}/internal/catch_message.h + ${HEADER_DIR}/internal/catch_objc.hpp + ${HEADER_DIR}/internal/catch_objc_arc.hpp + ${HEADER_DIR}/internal/catch_option.hpp + ${HEADER_DIR}/internal/catch_output_redirect.h + ${HEADER_DIR}/internal/catch_platform.h + ${HEADER_DIR}/internal/catch_random_number_generator.h + ${HEADER_DIR}/internal/catch_reenable_warnings.h + ${HEADER_DIR}/internal/catch_reporter_registrars.hpp + ${HEADER_DIR}/internal/catch_reporter_registry.h + ${HEADER_DIR}/internal/catch_result_type.h + ${HEADER_DIR}/internal/catch_run_context.h + ${HEADER_DIR}/internal/catch_benchmark.h + ${HEADER_DIR}/internal/catch_section.h + ${HEADER_DIR}/internal/catch_section_info.h + ${HEADER_DIR}/internal/catch_session.h + ${HEADER_DIR}/internal/catch_startup_exception_registry.h + ${HEADER_DIR}/internal/catch_stream.h + ${HEADER_DIR}/internal/catch_stringref.h + ${HEADER_DIR}/internal/catch_string_manip.h + ${HEADER_DIR}/internal/catch_suppress_warnings.h + ${HEADER_DIR}/internal/catch_tag_alias.h + ${HEADER_DIR}/internal/catch_tag_alias_autoregistrar.h + ${HEADER_DIR}/internal/catch_tag_alias_registry.h + ${HEADER_DIR}/internal/catch_test_case_info.h + ${HEADER_DIR}/internal/catch_test_case_registry_impl.h + ${HEADER_DIR}/internal/catch_test_case_tracker.h + ${HEADER_DIR}/internal/catch_test_registry.h + ${HEADER_DIR}/internal/catch_test_spec.h + ${HEADER_DIR}/internal/catch_test_spec_parser.h + ${HEADER_DIR}/internal/catch_text.h + ${HEADER_DIR}/internal/catch_timer.h + ${HEADER_DIR}/internal/catch_to_string.hpp + ${HEADER_DIR}/internal/catch_tostring.h + ${HEADER_DIR}/internal/catch_totals.h + ${HEADER_DIR}/internal/catch_uncaught_exceptions.h + ${HEADER_DIR}/internal/catch_user_interfaces.h + ${HEADER_DIR}/internal/catch_version.h + ${HEADER_DIR}/internal/catch_wildcard_pattern.h + ${HEADER_DIR}/internal/catch_windows_h_proxy.h + ${HEADER_DIR}/internal/catch_xmlwriter.h + ) +set(IMPL_SOURCES + ${HEADER_DIR}/internal/catch_approx.cpp + ${HEADER_DIR}/internal/catch_assertionhandler.cpp + ${HEADER_DIR}/internal/catch_assertionresult.cpp + ${HEADER_DIR}/internal/catch_benchmark.cpp + ${HEADER_DIR}/internal/catch_capture_matchers.cpp + ${HEADER_DIR}/internal/catch_commandline.cpp + ${HEADER_DIR}/internal/catch_common.cpp + ${HEADER_DIR}/internal/catch_config.cpp + ${HEADER_DIR}/internal/catch_console_colour.cpp + ${HEADER_DIR}/internal/catch_context.cpp + ${HEADER_DIR}/internal/catch_debug_console.cpp + ${HEADER_DIR}/internal/catch_debugger.cpp + ${HEADER_DIR}/internal/catch_decomposer.cpp + ${HEADER_DIR}/internal/catch_errno_guard.cpp + ${HEADER_DIR}/internal/catch_exception_translator_registry.cpp + ${HEADER_DIR}/internal/catch_fatal_condition.cpp + ${HEADER_DIR}/internal/catch_interfaces_capture.cpp + ${HEADER_DIR}/internal/catch_interfaces_config.cpp + ${HEADER_DIR}/internal/catch_interfaces_exception.cpp + ${HEADER_DIR}/internal/catch_interfaces_registry_hub.cpp + ${HEADER_DIR}/internal/catch_interfaces_runner.cpp + ${HEADER_DIR}/internal/catch_interfaces_testcase.cpp + ${HEADER_DIR}/internal/catch_list.cpp + ${HEADER_DIR}/internal/catch_leak_detector.cpp + ${HEADER_DIR}/internal/catch_matchers.cpp + ${HEADER_DIR}/internal/catch_matchers_floating.cpp + ${HEADER_DIR}/internal/catch_matchers_generic.cpp + ${HEADER_DIR}/internal/catch_matchers_string.cpp + ${HEADER_DIR}/internal/catch_message.cpp + ${HEADER_DIR}/internal/catch_output_redirect.cpp + ${HEADER_DIR}/internal/catch_registry_hub.cpp + ${HEADER_DIR}/internal/catch_interfaces_reporter.cpp + ${HEADER_DIR}/internal/catch_random_number_generator.cpp + ${HEADER_DIR}/internal/catch_reporter_registry.cpp + ${HEADER_DIR}/internal/catch_result_type.cpp + ${HEADER_DIR}/internal/catch_run_context.cpp + ${HEADER_DIR}/internal/catch_section.cpp + ${HEADER_DIR}/internal/catch_section_info.cpp + ${HEADER_DIR}/internal/catch_session.cpp + ${HEADER_DIR}/internal/catch_startup_exception_registry.cpp + ${HEADER_DIR}/internal/catch_stream.cpp + ${HEADER_DIR}/internal/catch_stringref.cpp + ${HEADER_DIR}/internal/catch_string_manip.cpp + ${HEADER_DIR}/internal/catch_tag_alias.cpp + ${HEADER_DIR}/internal/catch_tag_alias_autoregistrar.cpp + ${HEADER_DIR}/internal/catch_tag_alias_registry.cpp + ${HEADER_DIR}/internal/catch_test_case_info.cpp + ${HEADER_DIR}/internal/catch_test_case_registry_impl.cpp + ${HEADER_DIR}/internal/catch_test_case_tracker.cpp + ${HEADER_DIR}/internal/catch_test_registry.cpp + ${HEADER_DIR}/internal/catch_test_spec.cpp + ${HEADER_DIR}/internal/catch_test_spec_parser.cpp + ${HEADER_DIR}/internal/catch_timer.cpp + ${HEADER_DIR}/internal/catch_tostring.cpp + ${HEADER_DIR}/internal/catch_totals.cpp + ${HEADER_DIR}/internal/catch_uncaught_exceptions.cpp + ${HEADER_DIR}/internal/catch_version.cpp + ${HEADER_DIR}/internal/catch_wildcard_pattern.cpp + ${HEADER_DIR}/internal/catch_xmlwriter.cpp + ) +set(INTERNAL_FILES ${IMPL_SOURCES} ${INTERNAL_HEADERS}) +CheckFileList(INTERNAL_FILES ${HEADER_DIR}/internal) + +# Please keep these ordered alphabetically +set(REPORTER_HEADERS + ${HEADER_DIR}/reporters/catch_reporter_automake.hpp + ${HEADER_DIR}/reporters/catch_reporter_bases.hpp + ${HEADER_DIR}/reporters/catch_reporter_compact.h + ${HEADER_DIR}/reporters/catch_reporter_console.h + ${HEADER_DIR}/reporters/catch_reporter_junit.h + ${HEADER_DIR}/reporters/catch_reporter_listening.h + ${HEADER_DIR}/reporters/catch_reporter_tap.hpp + ${HEADER_DIR}/reporters/catch_reporter_teamcity.hpp + ${HEADER_DIR}/reporters/catch_reporter_xml.h + ) +set(REPORTER_SOURCES + ${HEADER_DIR}/reporters/catch_reporter_bases.cpp + ${HEADER_DIR}/reporters/catch_reporter_compact.cpp + ${HEADER_DIR}/reporters/catch_reporter_console.cpp + ${HEADER_DIR}/reporters/catch_reporter_junit.cpp + ${HEADER_DIR}/reporters/catch_reporter_listening.cpp + ${HEADER_DIR}/reporters/catch_reporter_xml.cpp + ) +set(REPORTER_FILES ${REPORTER_HEADERS} ${REPORTER_SOURCES}) +CheckFileList(REPORTER_FILES ${HEADER_DIR}/reporters) + +# Specify the headers, too, so CLion recognises them as project files +set(HEADERS + ${TOP_LEVEL_HEADERS} + ${EXTERNAL_HEADERS} + ${INTERNAL_HEADERS} + ${REPORTER_HEADERS} + ) + +# Provide some groupings for IDEs +SOURCE_GROUP("Tests" FILES ${TEST_SOURCES}) +SOURCE_GROUP("Surrogates" FILES ${SURROGATE_SOURCES}) + +include(CTest) + +add_executable(SelfTest ${TEST_SOURCES} ${IMPL_SOURCES} ${REPORTER_SOURCES} ${SURROGATE_SOURCES} ${HEADERS}) +target_include_directories(SelfTest PRIVATE ${HEADER_DIR}) + +if(USE_CPP14) + message(STATUS "Enabling C++14") + set_property(TARGET SelfTest PROPERTY CXX_STANDARD 14) +else() + message(STATUS "Enabling C++11") + set_property(TARGET SelfTest PROPERTY CXX_STANDARD 11) +endif() + +set_property(TARGET SelfTest PROPERTY CXX_STANDARD_REQUIRED ON) +set_property(TARGET SelfTest PROPERTY CXX_EXTENSIONS OFF) + +if (CATCH_ENABLE_COVERAGE) + set(ENABLE_COVERAGE ON CACHE BOOL "Enable coverage build." FORCE) + find_package(codecov) + add_coverage(SelfTest) + list(APPEND LCOV_REMOVE_PATTERNS "'/usr/*'") + coverage_evaluate() +endif() + +# Add per compiler options +if ( CMAKE_CXX_COMPILER_ID MATCHES "Clang|AppleClang|GNU" ) + target_compile_options( SelfTest PRIVATE -Wall -Wextra -Wunreachable-code -Wpedantic -Wmissing-declarations ) + if (CATCH_ENABLE_WERROR) + target_compile_options( SelfTest PRIVATE -Werror) + endif() +endif() +# Clang specific options go here +if ( CMAKE_CXX_COMPILER_ID MATCHES "Clang" ) + target_compile_options( SelfTest PRIVATE -Wweak-vtables -Wexit-time-destructors -Wglobal-constructors -Wmissing-noreturn ) +endif() +if ( CMAKE_CXX_COMPILER_ID MATCHES "MSVC" ) + STRING(REGEX REPLACE "/W[0-9]" "/W4" CMAKE_CXX_FLAGS ${CMAKE_CXX_FLAGS}) # override default warning level + target_compile_options( SelfTest PRIVATE /w44265 /w44061 /w44062 ) + if (CATCH_ENABLE_WERROR) + target_compile_options( SelfTest PRIVATE /WX) + endif() + # Force MSVC to consider everything as encoded in utf-8 + target_compile_options( SelfTest PRIVATE /utf-8 ) +endif() + + +# configure unit tests via CTest +add_test(NAME RunTests COMMAND $) + +add_test(NAME ListTests COMMAND $ --list-tests --verbosity high) +set_tests_properties(ListTests PROPERTIES + PASS_REGULAR_EXPRESSION "[0-9]+ test cases" + FAIL_REGULAR_EXPRESSION "Hidden Test" +) + +add_test(NAME ListTags COMMAND $ --list-tags) +set_tests_properties(ListTags PROPERTIES + PASS_REGULAR_EXPRESSION "[0-9]+ tags" + FAIL_REGULAR_EXPRESSION "[.]") + +add_test(NAME ListReporters COMMAND $ --list-reporters) +set_tests_properties(ListReporters PROPERTIES PASS_REGULAR_EXPRESSION "Available reporters:") + +add_test(NAME ListTestNamesOnly COMMAND $ --list-test-names-only) +set_tests_properties(ListTestNamesOnly PROPERTIES + PASS_REGULAR_EXPRESSION "Regex string matcher" + FAIL_REGULAR_EXPRESSION "Hidden Test") + +add_test(NAME NoAssertions COMMAND $ -w NoAssertions) +set_tests_properties(NoAssertions PROPERTIES PASS_REGULAR_EXPRESSION "No assertions in test case") + +add_test(NAME NoTest COMMAND $ -w NoTests "___nonexistent_test___") +set_tests_properties(NoTest PROPERTIES PASS_REGULAR_EXPRESSION "No test cases matched") + +# AppVeyor has a Python 2.7 in path, but doesn't have .py files as autorunnable +add_test(NAME ApprovalTests COMMAND python ${CATCH_DIR}/scripts/approvalTests.py $) +set_tests_properties(ApprovalTests PROPERTIES FAIL_REGULAR_EXPRESSION "Results differed") + +if (CATCH_USE_VALGRIND) + add_test(NAME ValgrindRunTests COMMAND valgrind --leak-check=full --error-exitcode=1 $) + add_test(NAME ValgrindListTests COMMAND valgrind --leak-check=full --error-exitcode=1 $ --list-tests --verbosity high) + set_tests_properties(ValgrindListTests PROPERTIES PASS_REGULAR_EXPRESSION "definitely lost: 0 bytes in 0 blocks") + add_test(NAME ValgrindListTags COMMAND valgrind --leak-check=full --error-exitcode=1 $ --list-tags) + set_tests_properties(ValgrindListTags PROPERTIES PASS_REGULAR_EXPRESSION "definitely lost: 0 bytes in 0 blocks") +endif() diff --git a/src/third_party/cppcodec/test/catch/projects/SelfTest/Baselines/automake.std.approved.txt b/src/third_party/cppcodec/test/catch/projects/SelfTest/Baselines/automake.std.approved.txt new file mode 100644 index 0000000000..057be069f4 --- /dev/null +++ b/src/third_party/cppcodec/test/catch/projects/SelfTest/Baselines/automake.std.approved.txt @@ -0,0 +1,168 @@ +:test-result: PASS # A test name that starts with a # +:test-result: PASS #542 +:test-result: PASS #809 +:test-result: FAIL 'Not' checks that should fail +:test-result: PASS 'Not' checks that should succeed +:test-result: PASS (unimplemented) static bools can be evaluated +:test-result: FAIL A METHOD_AS_TEST_CASE based test run that fails +:test-result: PASS A METHOD_AS_TEST_CASE based test run that succeeds +:test-result: FAIL A TEST_CASE_METHOD based test run that fails +:test-result: PASS A TEST_CASE_METHOD based test run that succeeds +:test-result: FAIL A couple of nested sections followed by a failure +:test-result: FAIL A failing expression with a non streamable type is still captured +:test-result: PASS AllOf matcher +:test-result: PASS An empty test with no assertions +:test-result: PASS An expression with side-effects should only be evaluated once +:test-result: FAIL An unchecked exception reports the line of the last assertion +:test-result: PASS Anonymous test case 1 +:test-result: PASS AnyOf matcher +:test-result: PASS Approximate PI +:test-result: PASS Approximate comparisons with different epsilons +:test-result: PASS Approximate comparisons with floats +:test-result: PASS Approximate comparisons with ints +:test-result: PASS Approximate comparisons with mixed numeric types +:test-result: PASS Assertions then sections +:test-result: PASS Character pretty printing +:test-result: PASS Comparing function pointers +:test-result: PASS Comparing member function pointers +:test-result: PASS Comparisons between ints where one side is computed +:test-result: PASS Comparisons between unsigned ints and negative signed ints match c++ standard behaviour +:test-result: PASS Comparisons with int literals don't warn when mixing signed/ unsigned +:test-result: FAIL Contains string matcher +:test-result: FAIL Custom exceptions can be translated when testing for nothrow +:test-result: FAIL Custom exceptions can be translated when testing for throwing as something else +:test-result: FAIL Custom std-exceptions can be custom translated +:test-result: PASS Demonstrate that a non-const == is not used +:test-result: FAIL EndsWith string matcher +:test-result: XFAIL Equality checks that should fail +:test-result: PASS Equality checks that should succeed +:test-result: PASS Equals +:test-result: FAIL Equals string matcher +:test-result: PASS Exception messages can be tested for +:test-result: FAIL Expected exceptions that don't throw or unexpected exceptions fail the test +:test-result: FAIL FAIL aborts the test +:test-result: FAIL FAIL does not require an argument +:test-result: PASS Factorials are computed +:test-result: PASS Generator over a range of pairs +:test-result: PASS Generators over two ranges +:test-result: PASS Greater-than inequalities with different epsilons +:test-result: PASS INFO and WARN do not abort tests +:test-result: FAIL INFO gets logged on failure +:test-result: FAIL INFO gets logged on failure, even if captured before successful assertions +:test-result: XFAIL Inequality checks that should fail +:test-result: PASS Inequality checks that should succeed +:test-result: PASS Less-than inequalities with different epsilons +:test-result: PASS Long strings can be wrapped +:test-result: PASS Long text is truncated +:test-result: PASS ManuallyRegistered +:test-result: PASS Matchers can be (AllOf) composed with the && operator +:test-result: PASS Matchers can be (AnyOf) composed with the || operator +:test-result: PASS Matchers can be composed with both && and || +:test-result: FAIL Matchers can be composed with both && and || - failing +:test-result: PASS Matchers can be negated (Not) with the ! operator +:test-result: FAIL Matchers can be negated (Not) with the ! operator - failing +:test-result: FAIL Mismatching exception messages failing the test +:test-result: PASS Nice descriptive name +:test-result: FAIL Non-std exceptions can be translated +:test-result: PASS NotImplemented exception +:test-result: PASS Objects that evaluated in boolean contexts can be checked +:test-result: PASS Operators at different namespace levels not hijacked by Koenig lookup +:test-result: FAIL Ordering comparison checks that should fail +:test-result: PASS Ordering comparison checks that should succeed +:test-result: FAIL Output from all sections is reported +:test-result: PASS Parse test names and tags +:test-result: PASS Parsing a std::pair +:test-result: PASS Pointers can be compared to null +:test-result: PASS Pointers can be converted to strings +:test-result: PASS Process can be configured on command line +:test-result: FAIL SCOPED_INFO is reset for each loop +:test-result: PASS SUCCEED counts as a test pass +:test-result: PASS SUCCESS does not require an argument +:test-result: PASS Scenario: BDD tests requiring Fixtures to provide commonly-accessed data or methods +:test-result: PASS Scenario: Do that thing with the thing +:test-result: PASS Scenario: This is a really long scenario name to see how the list command deals with wrapping +:test-result: PASS Scenario: Vector resizing affects size and capacity +A string sent directly to stdout +A string sent directly to stderr +:test-result: PASS Sends stuff to stdout and stderr +:test-result: PASS Some simple comparisons between doubles +Message from section one +Message from section two +:test-result: PASS Standard output from all sections is reported +:test-result: FAIL StartsWith string matcher +:test-result: PASS String matchers +hello +hello +:test-result: PASS Strings can be rendered with colour +:test-result: FAIL Tabs and newlines show in output +:test-result: PASS Tag alias can be registered against tag patterns +:test-result: PASS Test case with one argument +:test-result: PASS Test enum bit values +:test-result: PASS Text can be formatted using the Text class +:test-result: PASS The NO_FAIL macro reports a failure but does not fail the test +:test-result: FAIL This test 'should' fail but doesn't +:test-result: PASS Tracker +:test-result: FAIL Unexpected exceptions can be translated +:test-result: PASS Use a custom approx +:test-result: PASS Variadic macros +:test-result: PASS When checked exceptions are thrown they can be expected or unexpected +:test-result: FAIL When unchecked exceptions are thrown directly they are always failures +:test-result: FAIL When unchecked exceptions are thrown during a CHECK the test should continue +:test-result: FAIL When unchecked exceptions are thrown during a REQUIRE the test should abort fail +:test-result: FAIL When unchecked exceptions are thrown from functions they are always failures +:test-result: FAIL When unchecked exceptions are thrown from sections they are always failures +:test-result: PASS When unchecked exceptions are thrown, but caught, they do not affect the test +:test-result: PASS Where the LHS is not a simple value +:test-result: PASS Where there is more to the expression after the RHS +:test-result: PASS X/level/0/a +:test-result: PASS X/level/0/b +:test-result: PASS X/level/1/a +:test-result: PASS X/level/1/b +:test-result: PASS XmlEncode +:test-result: PASS atomic if +:test-result: PASS boolean member +:test-result: PASS checkedElse +:test-result: FAIL checkedElse, failing +:test-result: PASS checkedIf +:test-result: FAIL checkedIf, failing +:test-result: PASS comparisons between const int variables +:test-result: PASS comparisons between int variables +:test-result: PASS even more nested SECTION tests +:test-result: PASS first tag +spanner:test-result: PASS has printf +:test-result: FAIL just failure +:test-result: PASS just info +:test-result: FAIL looped SECTION tests +:test-result: FAIL looped tests +:test-result: FAIL more nested SECTION tests +:test-result: PASS nested SECTION tests +:test-result: PASS non streamable - with conv. op +:test-result: PASS not allowed +:test-result: PASS null strings +:test-result: PASS pair > -> toString +:test-result: PASS pointer to class +:test-result: PASS random SECTION tests +:test-result: PASS replaceInPlace +:test-result: PASS second tag +:test-result: FAIL send a single char to INFO +:test-result: FAIL sends information to INFO +:test-result: PASS std::pair -> toString +:test-result: PASS std::pair -> toString +:test-result: PASS std::vector > -> toString +:test-result: FAIL string literals of different sizes can be compared +:test-result: PASS toString on const wchar_t const pointer returns the string contents +:test-result: PASS toString on const wchar_t pointer returns the string contents +:test-result: PASS toString on wchar_t const pointer returns the string contents +:test-result: PASS toString on wchar_t returns the string contents +:test-result: PASS toString( has_maker ) +:test-result: PASS toString( has_maker_and_toString ) +:test-result: PASS toString( has_toString ) +:test-result: PASS toString( vectors -> toString +:test-result: PASS vector -> toString +:test-result: PASS vectors can be sized and resized +:test-result: PASS xmlentitycheck diff --git a/src/third_party/cppcodec/test/catch/projects/SelfTest/Baselines/compact.sw.approved.txt b/src/third_party/cppcodec/test/catch/projects/SelfTest/Baselines/compact.sw.approved.txt new file mode 100644 index 0000000000..4386582c9e --- /dev/null +++ b/src/third_party/cppcodec/test/catch/projects/SelfTest/Baselines/compact.sw.approved.txt @@ -0,0 +1,1164 @@ +Misc.tests.cpp:: passed: with 1 message: 'yay' +Decomposition.tests.cpp:: passed: fptr == 0 for: 0 == 0 +Decomposition.tests.cpp:: passed: fptr == 0l for: 0 == 0 +Compilation.tests.cpp:: passed: y.v == 0 for: 0 == 0 +Compilation.tests.cpp:: passed: 0 == y.v for: 0 == 0 +Compilation.tests.cpp:: passed: t1 == t2 for: {?} == {?} +Compilation.tests.cpp:: passed: t1 != t2 for: {?} != {?} +Compilation.tests.cpp:: passed: t1 < t2 for: {?} < {?} +Compilation.tests.cpp:: passed: t1 > t2 for: {?} > {?} +Compilation.tests.cpp:: passed: t1 <= t2 for: {?} <= {?} +Compilation.tests.cpp:: passed: t1 >= t2 for: {?} >= {?} +Misc.tests.cpp:: passed: +Compilation.tests.cpp:: passed: std::memcmp(uarr, "123", sizeof(uarr)) == 0 for: 0 == 0 with 2 messages: 'uarr := "123"' and 'sarr := "456"' +Compilation.tests.cpp:: passed: std::memcmp(sarr, "456", sizeof(sarr)) == 0 for: 0 == 0 with 2 messages: 'uarr := "123"' and 'sarr := "456"' +Compilation.tests.cpp:: passed: +Exception.tests.cpp:: failed: unexpected exception with message: 'answer := 42' with 1 message: 'expected exception' +Exception.tests.cpp:: failed: unexpected exception with message: 'answer := 42'; expression was: thisThrows() with 1 message: 'expected exception' +Exception.tests.cpp:: passed: thisThrows() with 1 message: 'answer := 42' +Compilation.tests.cpp:: passed: 42 == f for: 42 == {?} +Compilation.tests.cpp:: passed: a == t for: 3 == 3 +Compilation.tests.cpp:: passed: a == t for: 3 == 3 +Compilation.tests.cpp:: passed: throws_int(true) +Compilation.tests.cpp:: passed: throws_int(true), int +Compilation.tests.cpp:: passed: throws_int(false) +Compilation.tests.cpp:: passed: "aaa", Catch::EndsWith("aaa") for: "aaa" ends with: "aaa" +Compilation.tests.cpp:: passed: templated_tests(3) for: true +Misc.tests.cpp:: failed: f() == 0 for: 1 == 0 +Misc.tests.cpp:: passed: errno == 1 for: 1 == 1 +Compilation.tests.cpp:: passed: x == 4 for: {?} == 4 with 1 message: 'dummy := 0' +Misc.tests.cpp:: passed: with 1 message: 'Everything is OK' +Misc.tests.cpp:: passed: with 1 message: 'Everything is OK' +Misc.tests.cpp:: passed: with 1 message: 'Everything is OK' +Misc.tests.cpp:: passed: with 1 message: 'Everything is OK' +Misc.tests.cpp:: passed: with 1 message: 'Everything is OK' +Condition.tests.cpp:: failed: false != false +Condition.tests.cpp:: failed: true != true +Condition.tests.cpp:: failed: !true for: false +Condition.tests.cpp:: failed: !(true) for: !true +Condition.tests.cpp:: failed: !trueValue for: false +Condition.tests.cpp:: failed: !(trueValue) for: !true +Condition.tests.cpp:: failed: !(1 == 1) for: false +Condition.tests.cpp:: failed: !(1 == 1) +Condition.tests.cpp:: passed: false == false +Condition.tests.cpp:: passed: true == true +Condition.tests.cpp:: passed: !false for: true +Condition.tests.cpp:: passed: !(false) for: !false +Condition.tests.cpp:: passed: !falseValue for: true +Condition.tests.cpp:: passed: !(falseValue) for: !false +Condition.tests.cpp:: passed: !(1 == 2) for: true +Condition.tests.cpp:: passed: !(1 == 2) +Tricky.tests.cpp:: passed: is_true::value == true for: true == true +Tricky.tests.cpp:: passed: true == is_true::value for: true == true +Tricky.tests.cpp:: passed: is_true::value == false for: false == false +Tricky.tests.cpp:: passed: false == is_true::value for: false == false +Tricky.tests.cpp:: passed: !is_true::value for: true +Tricky.tests.cpp:: passed: !!is_true::value for: true +Tricky.tests.cpp:: passed: is_true::value for: true +Tricky.tests.cpp:: passed: !(is_true::value) for: !false +Class.tests.cpp:: failed: s == "world" for: "hello" == "world" +Class.tests.cpp:: passed: s == "hello" for: "hello" == "hello" +Class.tests.cpp:: failed: m_a == 2 for: 1 == 2 +Class.tests.cpp:: passed: m_a == 1 for: 1 == 1 +Approx.tests.cpp:: passed: d == 1.23_a for: 1.23 == Approx( 1.23 ) +Approx.tests.cpp:: passed: d != 1.22_a for: 1.23 != Approx( 1.22 ) +Approx.tests.cpp:: passed: -d == -1.23_a for: -1.23 == Approx( -1.23 ) +Approx.tests.cpp:: passed: d == 1.2_a .epsilon(.1) for: 1.23 == Approx( 1.2 ) +Approx.tests.cpp:: passed: d != 1.2_a .epsilon(.001) for: 1.23 != Approx( 1.2 ) +Approx.tests.cpp:: passed: d == 1_a .epsilon(.3) for: 1.23 == Approx( 1.0 ) +Misc.tests.cpp:: passed: with 1 message: 'that's not flying - that's failing in style' +Misc.tests.cpp:: failed: explicitly with 1 message: 'to infinity and beyond' +Tricky.tests.cpp:: failed: &o1 == &o2 for: 0x == 0x +Tricky.tests.cpp:: failed: o1 == o2 for: {?} == {?} +Approx.tests.cpp:: passed: 104.0 != Approx(100.0) for: 104.0 != Approx( 100.0 ) +Approx.tests.cpp:: passed: 104.0 == Approx(100.0).margin(5) for: 104.0 == Approx( 100.0 ) +Approx.tests.cpp:: passed: 104.0 == Approx(100.0).margin(4) for: 104.0 == Approx( 100.0 ) +Approx.tests.cpp:: passed: 104.0 != Approx(100.0).margin(3) for: 104.0 != Approx( 100.0 ) +Approx.tests.cpp:: passed: 100.3 != Approx(100.0) for: 100.3 != Approx( 100.0 ) +Approx.tests.cpp:: passed: 100.3 == Approx(100.0).margin(0.5) for: 100.3 == Approx( 100.0 ) +Tricky.tests.cpp:: passed: i++ == 7 for: 7 == 7 +Tricky.tests.cpp:: passed: i++ == 8 for: 8 == 8 +Exception.tests.cpp:: passed: 1 == 1 +Exception.tests.cpp:: failed: unexpected exception with message: 'unexpected exception'; expression was: {Unknown expression after the reported line} +VariadicMacros.tests.cpp:: passed: with 1 message: 'anonymous test case' +Approx.tests.cpp:: passed: Approx(0).margin(0) +Approx.tests.cpp:: passed: Approx(0).margin(1234656) +Approx.tests.cpp:: passed: Approx(0).margin(-2), std::domain_error +Approx.tests.cpp:: passed: Approx(0).epsilon(0) +Approx.tests.cpp:: passed: Approx(0).epsilon(1) +Approx.tests.cpp:: passed: Approx(0).epsilon(-0.001), std::domain_error +Approx.tests.cpp:: passed: Approx(0).epsilon(1.0001), std::domain_error +Approx.tests.cpp:: passed: 0.25f == Approx(0.0f).margin(0.25f) for: 0.25f == Approx( 0.0 ) +Approx.tests.cpp:: passed: 0.0f == Approx(0.25f).margin(0.25f) for: 0.0f == Approx( 0.25 ) +Approx.tests.cpp:: passed: 0.5f == Approx(0.25f).margin(0.25f) for: 0.5f == Approx( 0.25 ) +Approx.tests.cpp:: passed: 245.0f == Approx(245.25f).margin(0.25f) for: 245.0f == Approx( 245.25 ) +Approx.tests.cpp:: passed: 245.5f == Approx(245.25f).margin(0.25f) for: 245.5f == Approx( 245.25 ) +Approx.tests.cpp:: passed: divide( 22, 7 ) == Approx( 3.141 ).epsilon( 0.001 ) for: 3.1428571429 == Approx( 3.141 ) +Approx.tests.cpp:: passed: divide( 22, 7 ) != Approx( 3.141 ).epsilon( 0.0001 ) for: 3.1428571429 != Approx( 3.141 ) +Approx.tests.cpp:: passed: d != Approx( 1.231 ) for: 1.23 != Approx( 1.231 ) +Approx.tests.cpp:: passed: d == Approx( 1.231 ).epsilon( 0.1 ) for: 1.23 == Approx( 1.231 ) +Approx.tests.cpp:: passed: 1.23f == Approx( 1.23f ) for: 1.23f == Approx( 1.2300000191 ) +Approx.tests.cpp:: passed: 0.0f == Approx( 0.0f ) for: 0.0f == Approx( 0.0 ) +Approx.tests.cpp:: passed: 1 == Approx( 1 ) for: 1 == Approx( 1.0 ) +Approx.tests.cpp:: passed: 0 == Approx( 0 ) for: 0 == Approx( 0.0 ) +Approx.tests.cpp:: passed: 1.0f == Approx( 1 ) for: 1.0f == Approx( 1.0 ) +Approx.tests.cpp:: passed: 0 == Approx( dZero) for: 0 == Approx( 0.0 ) +Approx.tests.cpp:: passed: 0 == Approx( dSmall ).margin( 0.001 ) for: 0 == Approx( 0.00001 ) +Approx.tests.cpp:: passed: 1.234f == Approx( dMedium ) for: 1.234f == Approx( 1.234 ) +Approx.tests.cpp:: passed: dMedium == Approx( 1.234f ) for: 1.234 == Approx( 1.2339999676 ) +Matchers.tests.cpp:: passed: 1, Predicate(alwaysTrue, "always true") for: 1 matches predicate: "always true" +Matchers.tests.cpp:: passed: 1, !Predicate(alwaysFalse, "always false") for: 1 not matches predicate: "always false" +Matchers.tests.cpp:: passed: "Hello olleH", Predicate( [] (std::string const& str) -> bool { return str.front() == str.back(); }, "First and last character should be equal") for: "Hello olleH" matches predicate: "First and last character should be equal" +Matchers.tests.cpp:: passed: "This wouldn't pass", !Predicate( [] (std::string const& str) -> bool { return str.front() == str.back(); } ) for: "This wouldn't pass" not matches undescribed predicate +Tricky.tests.cpp:: passed: true +Tricky.tests.cpp:: passed: true +Tricky.tests.cpp:: passed: true +Tricky.tests.cpp:: passed: true +Tricky.tests.cpp:: passed: true +Tricky.tests.cpp:: passed: true +Approx.tests.cpp:: passed: INFINITY == Approx(INFINITY) for: inff == Approx( inf ) +Approx.tests.cpp:: passed: NAN != Approx(NAN) for: nanf != Approx( nan ) +Approx.tests.cpp:: passed: !(NAN == Approx(NAN)) for: !(nanf == Approx( nan )) +Tricky.tests.cpp:: passed: y.v == 0 for: 0 == 0 +Tricky.tests.cpp:: passed: 0 == y.v for: 0 == 0 +ToStringGeneral.tests.cpp:: passed: true with 1 message: 'i := 2' +ToStringGeneral.tests.cpp:: passed: true with 1 message: '3' +ToStringGeneral.tests.cpp:: passed: tab == '/t' for: '/t' == '/t' +ToStringGeneral.tests.cpp:: passed: newline == '/n' for: '/n' == '/n' +ToStringGeneral.tests.cpp:: passed: carr_return == '/r' for: '/r' == '/r' +ToStringGeneral.tests.cpp:: passed: form_feed == '/f' for: '/f' == '/f' +ToStringGeneral.tests.cpp:: passed: space == ' ' for: ' ' == ' ' +ToStringGeneral.tests.cpp:: passed: c == chars[i] for: 'a' == 'a' +ToStringGeneral.tests.cpp:: passed: c == chars[i] for: 'z' == 'z' +ToStringGeneral.tests.cpp:: passed: c == chars[i] for: 'A' == 'A' +ToStringGeneral.tests.cpp:: passed: c == chars[i] for: 'Z' == 'Z' +ToStringGeneral.tests.cpp:: passed: null_terminator == '/0' for: 0 == 0 +ToStringGeneral.tests.cpp:: passed: c == i for: 2 == 2 +ToStringGeneral.tests.cpp:: passed: c == i for: 3 == 3 +ToStringGeneral.tests.cpp:: passed: c == i for: 4 == 4 +ToStringGeneral.tests.cpp:: passed: c == i for: 5 == 5 +Tricky.tests.cpp:: passed: std::vector{constructor_throws{}, constructor_throws{}} +Tricky.tests.cpp:: passed: std::vector{constructor_throws{}, constructor_throws{}} +Tricky.tests.cpp:: passed: std::vector{1, 2, 3} == std::vector{1, 2, 3} +Tricky.tests.cpp:: passed: std::vector{1, 2, 3} == std::vector{1, 2, 3} +Tricky.tests.cpp:: passed: std::vector{1, 2} == std::vector{1, 2} for: { 1, 2 } == { 1, 2 } +Tricky.tests.cpp:: passed: std::vector{1, 2} == std::vector{1, 2} for: { 1, 2 } == { 1, 2 } +Tricky.tests.cpp:: passed: !(std::vector{1, 2} == std::vector{1, 2, 3}) for: !({ 1, 2 } == { 1, 2, 3 }) +Tricky.tests.cpp:: passed: !(std::vector{1, 2} == std::vector{1, 2, 3}) for: !({ 1, 2 } == { 1, 2, 3 }) +Tricky.tests.cpp:: passed: std::vector{1, 2} == std::vector{1, 2} for: { 1, 2 } == { 1, 2 } +Tricky.tests.cpp:: passed: std::vector{1, 2} == std::vector{1, 2} for: { 1, 2 } == { 1, 2 } +Tricky.tests.cpp:: passed: true +Tricky.tests.cpp:: passed: std::vector{1, 2} == std::vector{1, 2} for: { 1, 2 } == { 1, 2 } +Tricky.tests.cpp:: passed: a for: 0x +Tricky.tests.cpp:: passed: a == &foo for: 0x == 0x +Approx.tests.cpp:: passed: td == Approx(10.0) for: StrongDoubleTypedef(10) == Approx( 10.0 ) +Approx.tests.cpp:: passed: Approx(10.0) == td for: Approx( 10.0 ) == StrongDoubleTypedef(10) +Approx.tests.cpp:: passed: td != Approx(11.0) for: StrongDoubleTypedef(10) != Approx( 11.0 ) +Approx.tests.cpp:: passed: Approx(11.0) != td for: Approx( 11.0 ) != StrongDoubleTypedef(10) +Approx.tests.cpp:: passed: td <= Approx(10.0) for: StrongDoubleTypedef(10) <= Approx( 10.0 ) +Approx.tests.cpp:: passed: td <= Approx(11.0) for: StrongDoubleTypedef(10) <= Approx( 11.0 ) +Approx.tests.cpp:: passed: Approx(10.0) <= td for: Approx( 10.0 ) <= StrongDoubleTypedef(10) +Approx.tests.cpp:: passed: Approx(9.0) <= td for: Approx( 9.0 ) <= StrongDoubleTypedef(10) +Approx.tests.cpp:: passed: td >= Approx(9.0) for: StrongDoubleTypedef(10) >= Approx( 9.0 ) +Approx.tests.cpp:: passed: td >= Approx(td) for: StrongDoubleTypedef(10) >= Approx( 10.0 ) +Approx.tests.cpp:: passed: Approx(td) >= td for: Approx( 10.0 ) >= StrongDoubleTypedef(10) +Approx.tests.cpp:: passed: Approx(11.0) >= td for: Approx( 11.0 ) >= StrongDoubleTypedef(10) +Condition.tests.cpp:: passed: 54 == 6*9 for: 54 == 54 +Condition.tests.cpp:: passed: ( -1 > 2u ) for: true +Condition.tests.cpp:: passed: -1 > 2u for: -1 > 2 +Condition.tests.cpp:: passed: ( 2u < -1 ) for: true +Condition.tests.cpp:: passed: 2u < -1 for: 2 < -1 +Condition.tests.cpp:: passed: ( minInt > 2u ) for: true +Condition.tests.cpp:: passed: minInt > 2u for: -2147483648 > 2 +Condition.tests.cpp:: passed: i == 1 for: 1 == 1 +Condition.tests.cpp:: passed: ui == 2 for: 2 == 2 +Condition.tests.cpp:: passed: l == 3 for: 3 == 3 +Condition.tests.cpp:: passed: ul == 4 for: 4 == 4 +Condition.tests.cpp:: passed: c == 5 for: 5 == 5 +Condition.tests.cpp:: passed: uc == 6 for: 6 == 6 +Condition.tests.cpp:: passed: 1 == i for: 1 == 1 +Condition.tests.cpp:: passed: 2 == ui for: 2 == 2 +Condition.tests.cpp:: passed: 3 == l for: 3 == 3 +Condition.tests.cpp:: passed: 4 == ul for: 4 == 4 +Condition.tests.cpp:: passed: 5 == c for: 5 == 5 +Condition.tests.cpp:: passed: 6 == uc for: 6 == 6 +Condition.tests.cpp:: passed: (std::numeric_limits::max)() > ul for: 4294967295 (0x) > 4 +Matchers.tests.cpp:: failed: testStringForMatching(), Contains("not there", Catch::CaseSensitive::No) for: "this string contains 'abc' as a substring" contains: "not there" (case insensitive) +Matchers.tests.cpp:: failed: testStringForMatching(), Contains("STRING") for: "this string contains 'abc' as a substring" contains: "STRING" +Exception.tests.cpp:: failed: unexpected exception with message: 'custom exception - not std'; expression was: throwCustom() +Exception.tests.cpp:: failed: unexpected exception with message: 'custom exception - not std'; expression was: throwCustom(), std::exception +Exception.tests.cpp:: failed: unexpected exception with message: 'custom std exception' +Approx.tests.cpp:: passed: 101.000001 != Approx(100).epsilon(0.01) for: 101.000001 != Approx( 100.0 ) +Approx.tests.cpp:: passed: std::pow(10, -5) != Approx(std::pow(10, -7)) for: 0.00001 != Approx( 0.0000001 ) +Matchers.tests.cpp:: failed: testStringForMatching(), EndsWith("Substring") for: "this string contains 'abc' as a substring" ends with: "Substring" +Matchers.tests.cpp:: failed: testStringForMatching(), EndsWith("this", Catch::CaseSensitive::No) for: "this string contains 'abc' as a substring" ends with: "this" (case insensitive) +Approx.tests.cpp:: passed: 101.01 != Approx(100).epsilon(0.01) for: 101.01 != Approx( 100.0 ) +Condition.tests.cpp:: failed: data.int_seven == 6 for: 7 == 6 +Condition.tests.cpp:: failed: data.int_seven == 8 for: 7 == 8 +Condition.tests.cpp:: failed: data.int_seven == 0 for: 7 == 0 +Condition.tests.cpp:: failed: data.float_nine_point_one == Approx( 9.11f ) for: 9.1f == Approx( 9.1099996567 ) +Condition.tests.cpp:: failed: data.float_nine_point_one == Approx( 9.0f ) for: 9.1f == Approx( 9.0 ) +Condition.tests.cpp:: failed: data.float_nine_point_one == Approx( 1 ) for: 9.1f == Approx( 1.0 ) +Condition.tests.cpp:: failed: data.float_nine_point_one == Approx( 0 ) for: 9.1f == Approx( 0.0 ) +Condition.tests.cpp:: failed: data.double_pi == Approx( 3.1415 ) for: 3.1415926535 == Approx( 3.1415 ) +Condition.tests.cpp:: failed: data.str_hello == "goodbye" for: "hello" == "goodbye" +Condition.tests.cpp:: failed: data.str_hello == "hell" for: "hello" == "hell" +Condition.tests.cpp:: failed: data.str_hello == "hello1" for: "hello" == "hello1" +Condition.tests.cpp:: failed: data.str_hello.size() == 6 for: 5 == 6 +Condition.tests.cpp:: failed: x == Approx( 1.301 ) for: 1.3 == Approx( 1.301 ) +Condition.tests.cpp:: passed: data.int_seven == 7 for: 7 == 7 +Condition.tests.cpp:: passed: data.float_nine_point_one == Approx( 9.1f ) for: 9.1f == Approx( 9.1000003815 ) +Condition.tests.cpp:: passed: data.double_pi == Approx( 3.1415926535 ) for: 3.1415926535 == Approx( 3.1415926535 ) +Condition.tests.cpp:: passed: data.str_hello == "hello" for: "hello" == "hello" +Condition.tests.cpp:: passed: "hello" == data.str_hello for: "hello" == "hello" +Condition.tests.cpp:: passed: data.str_hello.size() == 5 for: 5 == 5 +Condition.tests.cpp:: passed: x == Approx( 1.3 ) for: 1.3 == Approx( 1.3 ) +Matchers.tests.cpp:: passed: testStringForMatching(), Equals("this string contains 'abc' as a substring") for: "this string contains 'abc' as a substring" equals: "this string contains 'abc' as a substring" +Matchers.tests.cpp:: passed: testStringForMatching(), Equals("this string contains 'ABC' as a substring", Catch::CaseSensitive::No) for: "this string contains 'abc' as a substring" equals: "this string contains 'abc' as a substring" (case insensitive) +Matchers.tests.cpp:: failed: testStringForMatching(), Equals("this string contains 'ABC' as a substring") for: "this string contains 'abc' as a substring" equals: "this string contains 'ABC' as a substring" +Matchers.tests.cpp:: failed: testStringForMatching(), Equals("something else", Catch::CaseSensitive::No) for: "this string contains 'abc' as a substring" equals: "something else" (case insensitive) +ToStringGeneral.tests.cpp:: passed: ::Catch::Detail::stringify(WhatException{}) == "This exception has overriden what() method" for: "This exception has overriden what() method" +== +"This exception has overriden what() method" +ToStringGeneral.tests.cpp:: passed: ::Catch::Detail::stringify(OperatorException{}) == "OperatorException" for: "OperatorException" == "OperatorException" +ToStringGeneral.tests.cpp:: passed: ::Catch::Detail::stringify(StringMakerException{}) == "StringMakerException" for: "StringMakerException" +== +"StringMakerException" +Matchers.tests.cpp:: failed: expected exception, got none; expression was: doesNotThrow(), SpecialException, ExceptionMatcher{1} +Matchers.tests.cpp:: failed: expected exception, got none; expression was: doesNotThrow(), SpecialException, ExceptionMatcher{1} +Matchers.tests.cpp:: failed: unexpected exception with message: 'Unknown exception'; expression was: throwsAsInt(1), SpecialException, ExceptionMatcher{1} +Matchers.tests.cpp:: failed: unexpected exception with message: 'Unknown exception'; expression was: throwsAsInt(1), SpecialException, ExceptionMatcher{1} +Matchers.tests.cpp:: failed: throws(3), SpecialException, ExceptionMatcher{1} for: SpecialException::what special exception has value of 1 +Matchers.tests.cpp:: failed: throws(4), SpecialException, ExceptionMatcher{1} for: SpecialException::what special exception has value of 1 +Matchers.tests.cpp:: passed: throws(1), SpecialException, ExceptionMatcher{1} for: SpecialException::what special exception has value of 1 +Matchers.tests.cpp:: passed: throws(2), SpecialException, ExceptionMatcher{2} for: SpecialException::what special exception has value of 2 +Exception.tests.cpp:: passed: thisThrows(), "expected exception" for: "expected exception" equals: "expected exception" +Exception.tests.cpp:: passed: thisThrows(), Equals( "expecteD Exception", Catch::CaseSensitive::No ) for: "expected exception" equals: "expected exception" (case insensitive) +Exception.tests.cpp:: passed: thisThrows(), StartsWith( "expected" ) for: "expected exception" starts with: "expected" +Exception.tests.cpp:: passed: thisThrows(), EndsWith( "exception" ) for: "expected exception" ends with: "exception" +Exception.tests.cpp:: passed: thisThrows(), Contains( "except" ) for: "expected exception" contains: "except" +Exception.tests.cpp:: passed: thisThrows(), Contains( "exCept", Catch::CaseSensitive::No ) for: "expected exception" contains: "except" (case insensitive) +Exception.tests.cpp:: failed: unexpected exception with message: 'expected exception'; expression was: thisThrows(), std::string +Exception.tests.cpp:: failed: expected exception, got none; expression was: thisDoesntThrow(), std::domain_error +Exception.tests.cpp:: failed: unexpected exception with message: 'expected exception'; expression was: thisThrows() +Message.tests.cpp:: failed: explicitly with 1 message: 'This is a failure' +Message.tests.cpp:: failed: explicitly +Message.tests.cpp:: failed: explicitly with 1 message: 'This is a failure' +Message.tests.cpp:: warning: 'This message appears in the output' +Misc.tests.cpp:: passed: Factorial(0) == 1 for: 1 == 1 +Misc.tests.cpp:: passed: Factorial(1) == 1 for: 1 == 1 +Misc.tests.cpp:: passed: Factorial(2) == 2 for: 2 == 2 +Misc.tests.cpp:: passed: Factorial(3) == 6 for: 6 == 6 +Misc.tests.cpp:: passed: Factorial(10) == 3628800 for: 3628800 (0x) == 3628800 (0x) +Matchers.tests.cpp:: passed: 1., WithinAbs(1., 0) for: 1.0 is within 0.0 of 1.0 +Matchers.tests.cpp:: passed: 0., WithinAbs(1., 1) for: 0.0 is within 1.0 of 1.0 +Matchers.tests.cpp:: passed: 0., !WithinAbs(1., 0.99) for: 0.0 not is within 0.99 of 1.0 +Matchers.tests.cpp:: passed: 0., !WithinAbs(1., 0.99) for: 0.0 not is within 0.99 of 1.0 +Matchers.tests.cpp:: passed: NAN, !WithinAbs(NAN, 0) for: nanf not is within 0.0 of nan +Matchers.tests.cpp:: passed: 11., !WithinAbs(10., 0.5) for: 11.0 not is within 0.5 of 10.0 +Matchers.tests.cpp:: passed: 10., !WithinAbs(11., 0.5) for: 10.0 not is within 0.5 of 11.0 +Matchers.tests.cpp:: passed: -10., WithinAbs(-10., 0.5) for: -10.0 is within 0.5 of -10.0 +Matchers.tests.cpp:: passed: -10., WithinAbs(-9.6, 0.5) for: -10.0 is within 0.5 of -9.6 +Matchers.tests.cpp:: passed: 1., WithinULP(1., 0) for: 1.0 is within 0 ULPs of 1.0 +Matchers.tests.cpp:: passed: nextafter(1., 2.), WithinULP(1., 1) for: 1.0 is within 1 ULPs of 1.0 +Matchers.tests.cpp:: passed: nextafter(1., 0.), WithinULP(1., 1) for: 1.0 is within 1 ULPs of 1.0 +Matchers.tests.cpp:: passed: nextafter(1., 2.), !WithinULP(1., 0) for: 1.0 not is within 0 ULPs of 1.0 +Matchers.tests.cpp:: passed: 1., WithinULP(1., 0) for: 1.0 is within 0 ULPs of 1.0 +Matchers.tests.cpp:: passed: -0., WithinULP(0., 0) for: -0.0 is within 0 ULPs of 0.0 +Matchers.tests.cpp:: passed: NAN, !WithinULP(NAN, 123) for: nanf not is within 123 ULPs of nanf +Matchers.tests.cpp:: passed: 1., WithinAbs(1., 0.5) || WithinULP(2., 1) for: 1.0 ( is within 0.5 of 1.0 or is within 1 ULPs of 2.0 ) +Matchers.tests.cpp:: passed: 1., WithinAbs(2., 0.5) || WithinULP(1., 0) for: 1.0 ( is within 0.5 of 2.0 or is within 0 ULPs of 1.0 ) +Matchers.tests.cpp:: passed: NAN, !(WithinAbs(NAN, 100) || WithinULP(NAN, 123)) for: nanf not ( is within 100.0 of nan or is within 123 ULPs of nanf ) +Matchers.tests.cpp:: passed: WithinAbs(1., 0.) +Matchers.tests.cpp:: passed: WithinAbs(1., -1.), std::domain_error +Matchers.tests.cpp:: passed: WithinULP(1., 0) +Matchers.tests.cpp:: passed: WithinULP(1., -1), std::domain_error +Matchers.tests.cpp:: passed: 1.f, WithinAbs(1.f, 0) for: 1.0f is within 0.0 of 1.0 +Matchers.tests.cpp:: passed: 0.f, WithinAbs(1.f, 1) for: 0.0f is within 1.0 of 1.0 +Matchers.tests.cpp:: passed: 0.f, !WithinAbs(1.f, 0.99f) for: 0.0f not is within 0.9900000095 of 1.0 +Matchers.tests.cpp:: passed: 0.f, !WithinAbs(1.f, 0.99f) for: 0.0f not is within 0.9900000095 of 1.0 +Matchers.tests.cpp:: passed: 0.f, WithinAbs(-0.f, 0) for: 0.0f is within 0.0 of -0.0 +Matchers.tests.cpp:: passed: NAN, !WithinAbs(NAN, 0) for: nanf not is within 0.0 of nan +Matchers.tests.cpp:: passed: 11.f, !WithinAbs(10.f, 0.5f) for: 11.0f not is within 0.5 of 10.0 +Matchers.tests.cpp:: passed: 10.f, !WithinAbs(11.f, 0.5f) for: 10.0f not is within 0.5 of 11.0 +Matchers.tests.cpp:: passed: -10.f, WithinAbs(-10.f, 0.5f) for: -10.0f is within 0.5 of -10.0 +Matchers.tests.cpp:: passed: -10.f, WithinAbs(-9.6f, 0.5f) for: -10.0f is within 0.5 of -9.6000003815 +Matchers.tests.cpp:: passed: 1.f, WithinULP(1.f, 0) for: 1.0f is within 0 ULPs of 1.0f +Matchers.tests.cpp:: passed: nextafter(1.f, 2.f), WithinULP(1.f, 1) for: 1.0f is within 1 ULPs of 1.0f +Matchers.tests.cpp:: passed: nextafter(1.f, 0.f), WithinULP(1.f, 1) for: 1.0f is within 1 ULPs of 1.0f +Matchers.tests.cpp:: passed: nextafter(1.f, 2.f), !WithinULP(1.f, 0) for: 1.0f not is within 0 ULPs of 1.0f +Matchers.tests.cpp:: passed: 1.f, WithinULP(1.f, 0) for: 1.0f is within 0 ULPs of 1.0f +Matchers.tests.cpp:: passed: -0.f, WithinULP(0.f, 0) for: -0.0f is within 0 ULPs of 0.0f +Matchers.tests.cpp:: passed: NAN, !WithinULP(NAN, 123) for: nanf not is within 123 ULPs of nanf +Matchers.tests.cpp:: passed: 1.f, WithinAbs(1.f, 0.5) || WithinULP(1.f, 1) for: 1.0f ( is within 0.5 of 1.0 or is within 1 ULPs of 1.0f ) +Matchers.tests.cpp:: passed: 1.f, WithinAbs(2.f, 0.5) || WithinULP(1.f, 0) for: 1.0f ( is within 0.5 of 2.0 or is within 0 ULPs of 1.0f ) +Matchers.tests.cpp:: passed: NAN, !(WithinAbs(NAN, 100) || WithinULP(NAN, 123)) for: nanf not ( is within 100.0 of nan or is within 123 ULPs of nanf ) +Matchers.tests.cpp:: passed: WithinAbs(1.f, 0.f) +Matchers.tests.cpp:: passed: WithinAbs(1.f, -1.f), std::domain_error +Matchers.tests.cpp:: passed: WithinULP(1.f, 0) +Matchers.tests.cpp:: passed: WithinULP(1.f, -1), std::domain_error +Approx.tests.cpp:: passed: d >= Approx( 1.22 ) for: 1.23 >= Approx( 1.22 ) +Approx.tests.cpp:: passed: d >= Approx( 1.23 ) for: 1.23 >= Approx( 1.23 ) +Approx.tests.cpp:: passed: !(d >= Approx( 1.24 )) for: !(1.23 >= Approx( 1.24 )) +Approx.tests.cpp:: passed: d >= Approx( 1.24 ).epsilon(0.1) for: 1.23 >= Approx( 1.24 ) +Message.tests.cpp:: warning: 'this is a message' with 1 message: 'this is a warning' +Message.tests.cpp:: failed: a == 1 for: 2 == 1 with 2 messages: 'this message should be logged' and 'so should this' +Message.tests.cpp:: passed: a == 2 for: 2 == 2 with 1 message: 'this message may be logged later' +Message.tests.cpp:: failed: a == 1 for: 2 == 1 with 2 messages: 'this message may be logged later' and 'this message should be logged' +Message.tests.cpp:: failed: a == 0 for: 2 == 0 with 3 messages: 'this message may be logged later' and 'this message should be logged' and 'and this, but later' +Message.tests.cpp:: passed: a == 2 for: 2 == 2 with 4 messages: 'this message may be logged later' and 'this message should be logged' and 'and this, but later' and 'but not this' +Message.tests.cpp:: passed: i < 10 for: 0 < 10 with 2 messages: 'current counter 0' and 'i := 0' +Message.tests.cpp:: passed: i < 10 for: 1 < 10 with 2 messages: 'current counter 1' and 'i := 1' +Message.tests.cpp:: passed: i < 10 for: 2 < 10 with 2 messages: 'current counter 2' and 'i := 2' +Message.tests.cpp:: passed: i < 10 for: 3 < 10 with 2 messages: 'current counter 3' and 'i := 3' +Message.tests.cpp:: passed: i < 10 for: 4 < 10 with 2 messages: 'current counter 4' and 'i := 4' +Message.tests.cpp:: passed: i < 10 for: 5 < 10 with 2 messages: 'current counter 5' and 'i := 5' +Message.tests.cpp:: passed: i < 10 for: 6 < 10 with 2 messages: 'current counter 6' and 'i := 6' +Message.tests.cpp:: passed: i < 10 for: 7 < 10 with 2 messages: 'current counter 7' and 'i := 7' +Message.tests.cpp:: passed: i < 10 for: 8 < 10 with 2 messages: 'current counter 8' and 'i := 8' +Message.tests.cpp:: passed: i < 10 for: 9 < 10 with 2 messages: 'current counter 9' and 'i := 9' +Message.tests.cpp:: failed: i < 10 for: 10 < 10 with 2 messages: 'current counter 10' and 'i := 10' +Condition.tests.cpp:: failed: data.int_seven != 7 for: 7 != 7 +Condition.tests.cpp:: failed: data.float_nine_point_one != Approx( 9.1f ) for: 9.1f != Approx( 9.1000003815 ) +Condition.tests.cpp:: failed: data.double_pi != Approx( 3.1415926535 ) for: 3.1415926535 != Approx( 3.1415926535 ) +Condition.tests.cpp:: failed: data.str_hello != "hello" for: "hello" != "hello" +Condition.tests.cpp:: failed: data.str_hello.size() != 5 for: 5 != 5 +Condition.tests.cpp:: passed: data.int_seven != 6 for: 7 != 6 +Condition.tests.cpp:: passed: data.int_seven != 8 for: 7 != 8 +Condition.tests.cpp:: passed: data.float_nine_point_one != Approx( 9.11f ) for: 9.1f != Approx( 9.1099996567 ) +Condition.tests.cpp:: passed: data.float_nine_point_one != Approx( 9.0f ) for: 9.1f != Approx( 9.0 ) +Condition.tests.cpp:: passed: data.float_nine_point_one != Approx( 1 ) for: 9.1f != Approx( 1.0 ) +Condition.tests.cpp:: passed: data.float_nine_point_one != Approx( 0 ) for: 9.1f != Approx( 0.0 ) +Condition.tests.cpp:: passed: data.double_pi != Approx( 3.1415 ) for: 3.1415926535 != Approx( 3.1415 ) +Condition.tests.cpp:: passed: data.str_hello != "goodbye" for: "hello" != "goodbye" +Condition.tests.cpp:: passed: data.str_hello != "hell" for: "hello" != "hell" +Condition.tests.cpp:: passed: data.str_hello != "hello1" for: "hello" != "hello1" +Condition.tests.cpp:: passed: data.str_hello.size() != 6 for: 5 != 6 +Approx.tests.cpp:: passed: d <= Approx( 1.24 ) for: 1.23 <= Approx( 1.24 ) +Approx.tests.cpp:: passed: d <= Approx( 1.23 ) for: 1.23 <= Approx( 1.23 ) +Approx.tests.cpp:: passed: !(d <= Approx( 1.22 )) for: !(1.23 <= Approx( 1.22 )) +Approx.tests.cpp:: passed: d <= Approx( 1.22 ).epsilon(0.1) for: 1.23 <= Approx( 1.22 ) +Misc.tests.cpp:: passed: with 1 message: 'was called' +Matchers.tests.cpp:: passed: testStringForMatching(), Contains("string") && Contains("abc") && Contains("substring") && Contains("contains") for: "this string contains 'abc' as a substring" ( contains: "string" and contains: "abc" and contains: "substring" and contains: "contains" ) +Matchers.tests.cpp:: passed: testStringForMatching(), Contains("string") || Contains("different") || Contains("random") for: "this string contains 'abc' as a substring" ( contains: "string" or contains: "different" or contains: "random" ) +Matchers.tests.cpp:: passed: testStringForMatching2(), Contains("string") || Contains("different") || Contains("random") for: "some completely different text that contains one common word" ( contains: "string" or contains: "different" or contains: "random" ) +Matchers.tests.cpp:: passed: testStringForMatching(), (Contains("string") || Contains("different")) && Contains("substring") for: "this string contains 'abc' as a substring" ( ( contains: "string" or contains: "different" ) and contains: "substring" ) +Matchers.tests.cpp:: failed: testStringForMatching(), (Contains("string") || Contains("different")) && Contains("random") for: "this string contains 'abc' as a substring" ( ( contains: "string" or contains: "different" ) and contains: "random" ) +Matchers.tests.cpp:: passed: testStringForMatching(), !Contains("different") for: "this string contains 'abc' as a substring" not contains: "different" +Matchers.tests.cpp:: failed: testStringForMatching(), !Contains("substring") for: "this string contains 'abc' as a substring" not contains: "substring" +Exception.tests.cpp:: passed: thisThrows(), "expected exception" for: "expected exception" equals: "expected exception" +Exception.tests.cpp:: failed: thisThrows(), "should fail" for: "expected exception" equals: "should fail" +Misc.tests.cpp:: warning: 'This one ran' +Exception.tests.cpp:: failed: unexpected exception with message: 'custom exception' +Tricky.tests.cpp:: passed: True for: {?} +Tricky.tests.cpp:: passed: !False for: true +Tricky.tests.cpp:: passed: !(False) for: !{?} +Condition.tests.cpp:: failed: data.int_seven > 7 for: 7 > 7 +Condition.tests.cpp:: failed: data.int_seven < 7 for: 7 < 7 +Condition.tests.cpp:: failed: data.int_seven > 8 for: 7 > 8 +Condition.tests.cpp:: failed: data.int_seven < 6 for: 7 < 6 +Condition.tests.cpp:: failed: data.int_seven < 0 for: 7 < 0 +Condition.tests.cpp:: failed: data.int_seven < -1 for: 7 < -1 +Condition.tests.cpp:: failed: data.int_seven >= 8 for: 7 >= 8 +Condition.tests.cpp:: failed: data.int_seven <= 6 for: 7 <= 6 +Condition.tests.cpp:: failed: data.float_nine_point_one < 9 for: 9.1f < 9 +Condition.tests.cpp:: failed: data.float_nine_point_one > 10 for: 9.1f > 10 +Condition.tests.cpp:: failed: data.float_nine_point_one > 9.2 for: 9.1f > 9.2 +Condition.tests.cpp:: failed: data.str_hello > "hello" for: "hello" > "hello" +Condition.tests.cpp:: failed: data.str_hello < "hello" for: "hello" < "hello" +Condition.tests.cpp:: failed: data.str_hello > "hellp" for: "hello" > "hellp" +Condition.tests.cpp:: failed: data.str_hello > "z" for: "hello" > "z" +Condition.tests.cpp:: failed: data.str_hello < "hellm" for: "hello" < "hellm" +Condition.tests.cpp:: failed: data.str_hello < "a" for: "hello" < "a" +Condition.tests.cpp:: failed: data.str_hello >= "z" for: "hello" >= "z" +Condition.tests.cpp:: failed: data.str_hello <= "a" for: "hello" <= "a" +Condition.tests.cpp:: passed: data.int_seven < 8 for: 7 < 8 +Condition.tests.cpp:: passed: data.int_seven > 6 for: 7 > 6 +Condition.tests.cpp:: passed: data.int_seven > 0 for: 7 > 0 +Condition.tests.cpp:: passed: data.int_seven > -1 for: 7 > -1 +Condition.tests.cpp:: passed: data.int_seven >= 7 for: 7 >= 7 +Condition.tests.cpp:: passed: data.int_seven >= 6 for: 7 >= 6 +Condition.tests.cpp:: passed: data.int_seven <= 7 for: 7 <= 7 +Condition.tests.cpp:: passed: data.int_seven <= 8 for: 7 <= 8 +Condition.tests.cpp:: passed: data.float_nine_point_one > 9 for: 9.1f > 9 +Condition.tests.cpp:: passed: data.float_nine_point_one < 10 for: 9.1f < 10 +Condition.tests.cpp:: passed: data.float_nine_point_one < 9.2 for: 9.1f < 9.2 +Condition.tests.cpp:: passed: data.str_hello <= "hello" for: "hello" <= "hello" +Condition.tests.cpp:: passed: data.str_hello >= "hello" for: "hello" >= "hello" +Condition.tests.cpp:: passed: data.str_hello < "hellp" for: "hello" < "hellp" +Condition.tests.cpp:: passed: data.str_hello < "zebra" for: "hello" < "zebra" +Condition.tests.cpp:: passed: data.str_hello > "hellm" for: "hello" > "hellm" +Condition.tests.cpp:: passed: data.str_hello > "a" for: "hello" > "a" +Message.tests.cpp:: failed: explicitly with 1 message: 'Message from section one' +Message.tests.cpp:: failed: explicitly with 1 message: 'Message from section two' +CmdLine.tests.cpp:: passed: spec.hasFilters() == false for: false == false +CmdLine.tests.cpp:: passed: spec.matches( tcA ) == false for: false == false +CmdLine.tests.cpp:: passed: spec.matches( tcB ) == false for: false == false +CmdLine.tests.cpp:: passed: spec.hasFilters() == false for: false == false +CmdLine.tests.cpp:: passed: spec.matches(tcA ) == false for: false == false +CmdLine.tests.cpp:: passed: spec.matches( tcB ) == false for: false == false +CmdLine.tests.cpp:: passed: spec.hasFilters() == false for: false == false +CmdLine.tests.cpp:: passed: spec.matches( tcA ) == false for: false == false +CmdLine.tests.cpp:: passed: spec.matches( tcB ) == false for: false == false +CmdLine.tests.cpp:: passed: spec.hasFilters() == true for: true == true +CmdLine.tests.cpp:: passed: spec.matches( tcA ) == false for: false == false +CmdLine.tests.cpp:: passed: spec.matches( tcB ) == true for: true == true +CmdLine.tests.cpp:: passed: spec.hasFilters() == true for: true == true +CmdLine.tests.cpp:: passed: spec.matches( tcA ) == false for: false == false +CmdLine.tests.cpp:: passed: spec.matches( tcB ) == true for: true == true +CmdLine.tests.cpp:: passed: spec.hasFilters() == true for: true == true +CmdLine.tests.cpp:: passed: spec.matches( tcA ) == false for: false == false +CmdLine.tests.cpp:: passed: spec.matches( tcB ) == true for: true == true +CmdLine.tests.cpp:: passed: spec.matches( tcC ) == false for: false == false +CmdLine.tests.cpp:: passed: spec.hasFilters() == true for: true == true +CmdLine.tests.cpp:: passed: spec.matches( tcA ) == false for: false == false +CmdLine.tests.cpp:: passed: spec.matches( tcB ) == false for: false == false +CmdLine.tests.cpp:: passed: spec.matches( tcC ) == true for: true == true +CmdLine.tests.cpp:: passed: spec.matches( tcD ) == false for: false == false +CmdLine.tests.cpp:: passed: parseTestSpec( "*a" ).matches( tcA ) == true for: true == true +CmdLine.tests.cpp:: passed: spec.hasFilters() == true for: true == true +CmdLine.tests.cpp:: passed: spec.matches( tcA ) == false for: false == false +CmdLine.tests.cpp:: passed: spec.matches( tcB ) == false for: false == false +CmdLine.tests.cpp:: passed: spec.matches( tcC ) == true for: true == true +CmdLine.tests.cpp:: passed: spec.matches( tcD ) == false for: false == false +CmdLine.tests.cpp:: passed: parseTestSpec( "a*" ).matches( tcA ) == true for: true == true +CmdLine.tests.cpp:: passed: spec.hasFilters() == true for: true == true +CmdLine.tests.cpp:: passed: spec.matches( tcA ) == false for: false == false +CmdLine.tests.cpp:: passed: spec.matches( tcB ) == false for: false == false +CmdLine.tests.cpp:: passed: spec.matches( tcC ) == true for: true == true +CmdLine.tests.cpp:: passed: spec.matches( tcD ) == true for: true == true +CmdLine.tests.cpp:: passed: parseTestSpec( "*a*" ).matches( tcA ) == true for: true == true +CmdLine.tests.cpp:: passed: spec.hasFilters() == true for: true == true +CmdLine.tests.cpp:: passed: spec.matches( tcA ) == true for: true == true +CmdLine.tests.cpp:: passed: spec.matches( tcB ) == false for: false == false +CmdLine.tests.cpp:: passed: spec.hasFilters() == true for: true == true +CmdLine.tests.cpp:: passed: spec.matches( tcA ) == true for: true == true +CmdLine.tests.cpp:: passed: spec.matches( tcB ) == false for: false == false +CmdLine.tests.cpp:: passed: spec.hasFilters() == true for: true == true +CmdLine.tests.cpp:: passed: spec.matches( tcA ) == true for: true == true +CmdLine.tests.cpp:: passed: spec.matches( tcB ) == false for: false == false +CmdLine.tests.cpp:: passed: spec.hasFilters() == true for: true == true +CmdLine.tests.cpp:: passed: spec.matches( tcA ) == false for: false == false +CmdLine.tests.cpp:: passed: spec.matches( tcB ) == false for: false == false +CmdLine.tests.cpp:: passed: spec.matches( tcC ) == true for: true == true +CmdLine.tests.cpp:: passed: spec.matches( tcD ) == true for: true == true +CmdLine.tests.cpp:: passed: spec.hasFilters() == true for: true == true +CmdLine.tests.cpp:: passed: spec.matches( tcA ) == true for: true == true +CmdLine.tests.cpp:: passed: spec.matches( tcB ) == true for: true == true +CmdLine.tests.cpp:: passed: spec.matches( tcC ) == true for: true == true +CmdLine.tests.cpp:: passed: spec.matches( tcD ) == true for: true == true +CmdLine.tests.cpp:: passed: spec.hasFilters() == true for: true == true +CmdLine.tests.cpp:: passed: spec.matches( tcA ) == false for: false == false +CmdLine.tests.cpp:: passed: spec.matches( tcB ) == true for: true == true +CmdLine.tests.cpp:: passed: spec.matches( tcC ) == false for: false == false +CmdLine.tests.cpp:: passed: spec.hasFilters() == true for: true == true +CmdLine.tests.cpp:: passed: spec.matches( tcA ) == false for: false == false +CmdLine.tests.cpp:: passed: spec.matches( tcB ) == true for: true == true +CmdLine.tests.cpp:: passed: spec.matches( tcC ) == true for: true == true +CmdLine.tests.cpp:: passed: spec.hasFilters() == true for: true == true +CmdLine.tests.cpp:: passed: spec.matches( tcA ) == false for: false == false +CmdLine.tests.cpp:: passed: spec.matches( tcB ) == false for: false == false +CmdLine.tests.cpp:: passed: spec.matches( tcC ) == true for: true == true +CmdLine.tests.cpp:: passed: spec.hasFilters() == true for: true == true +CmdLine.tests.cpp:: passed: spec.matches( tcA ) == false for: false == false +CmdLine.tests.cpp:: passed: spec.matches( tcB ) == false for: false == false +CmdLine.tests.cpp:: passed: spec.matches( tcC ) == true for: true == true +CmdLine.tests.cpp:: passed: spec.hasFilters() == true for: true == true +CmdLine.tests.cpp:: passed: spec.matches( tcA ) == false for: false == false +CmdLine.tests.cpp:: passed: spec.matches( tcB ) == false for: false == false +CmdLine.tests.cpp:: passed: spec.matches( tcC ) == true for: true == true +CmdLine.tests.cpp:: passed: spec.matches( tcD ) == false for: false == false +CmdLine.tests.cpp:: passed: spec.hasFilters() == true for: true == true +CmdLine.tests.cpp:: passed: spec.matches( tcA ) == true for: true == true +CmdLine.tests.cpp:: passed: spec.matches( tcB ) == false for: false == false +CmdLine.tests.cpp:: passed: spec.matches( tcC ) == true for: true == true +CmdLine.tests.cpp:: passed: spec.hasFilters() == true for: true == true +CmdLine.tests.cpp:: passed: spec.matches( tcA ) == false for: false == false +CmdLine.tests.cpp:: passed: spec.matches( tcB ) == true for: true == true +CmdLine.tests.cpp:: passed: spec.matches( tcC ) == false for: false == false +CmdLine.tests.cpp:: passed: spec.hasFilters() == true for: true == true +CmdLine.tests.cpp:: passed: spec.matches( tcA ) == false for: false == false +CmdLine.tests.cpp:: passed: spec.matches( tcB ) == false for: false == false +CmdLine.tests.cpp:: passed: spec.matches( tcC ) == false for: false == false +CmdLine.tests.cpp:: passed: spec.matches( tcD ) == true for: true == true +CmdLine.tests.cpp:: passed: spec.hasFilters() == true for: true == true +CmdLine.tests.cpp:: passed: spec.matches( tcA ) == false for: false == false +CmdLine.tests.cpp:: passed: spec.matches( tcB ) == false for: false == false +CmdLine.tests.cpp:: passed: spec.matches( tcC ) == false for: false == false +CmdLine.tests.cpp:: passed: spec.matches( tcD ) == true for: true == true +CmdLine.tests.cpp:: passed: spec.hasFilters() == true for: true == true +CmdLine.tests.cpp:: passed: spec.matches( tcA ) == true for: true == true +CmdLine.tests.cpp:: passed: spec.matches( tcB ) == false for: false == false +CmdLine.tests.cpp:: passed: spec.matches( tcC ) == true for: true == true +CmdLine.tests.cpp:: passed: spec.matches( tcD ) == true for: true == true +CmdLine.tests.cpp:: passed: spec.hasFilters() == true for: true == true +CmdLine.tests.cpp:: passed: spec.matches( tcA ) == true for: true == true +CmdLine.tests.cpp:: passed: spec.matches( tcB ) == true for: true == true +CmdLine.tests.cpp:: passed: spec.matches( tcC ) == false for: false == false +CmdLine.tests.cpp:: passed: spec.matches( tcD ) == false for: false == false +CmdLine.tests.cpp:: passed: spec.hasFilters() == true for: true == true +CmdLine.tests.cpp:: passed: spec.matches( tcA ) == true for: true == true +CmdLine.tests.cpp:: passed: spec.matches( tcB ) == true for: true == true +CmdLine.tests.cpp:: passed: spec.matches( tcC ) == true for: true == true +CmdLine.tests.cpp:: passed: spec.matches( tcD ) == false for: false == false +CmdLine.tests.cpp:: passed: spec.hasFilters() == true for: true == true +CmdLine.tests.cpp:: passed: spec.matches( tcA ) == true for: true == true +CmdLine.tests.cpp:: passed: spec.matches( tcB ) == true for: true == true +CmdLine.tests.cpp:: passed: spec.matches( tcC ) == true for: true == true +CmdLine.tests.cpp:: passed: spec.matches( tcD ) == false for: false == false +CmdLine.tests.cpp:: passed: spec.hasFilters() == true for: true == true +CmdLine.tests.cpp:: passed: spec.matches( tcA ) == false for: false == false +CmdLine.tests.cpp:: passed: spec.matches( tcB ) == false for: false == false +CmdLine.tests.cpp:: passed: spec.matches( tcC ) == true for: true == true +CmdLine.tests.cpp:: passed: spec.matches( tcD ) == false for: false == false +CmdLine.tests.cpp:: passed: spec.hasFilters() == false for: false == false +CmdLine.tests.cpp:: passed: spec.matches( tcA ) == false for: false == false +CmdLine.tests.cpp:: passed: spec.matches( tcB ) == false for: false == false +CmdLine.tests.cpp:: passed: spec.matches( tcC ) == false for: false == false +CmdLine.tests.cpp:: passed: spec.matches( tcD ) == false for: false == false +CmdLine.tests.cpp:: passed: spec.hasFilters() == false for: false == false +CmdLine.tests.cpp:: passed: spec.matches( tcA ) == false for: false == false +CmdLine.tests.cpp:: passed: spec.matches( tcB ) == false for: false == false +CmdLine.tests.cpp:: passed: spec.matches( tcC ) == false for: false == false +CmdLine.tests.cpp:: passed: spec.matches( tcD ) == false for: false == false +CmdLine.tests.cpp:: passed: spec.hasFilters() == true for: true == true +CmdLine.tests.cpp:: passed: spec.matches( tcA ) == false for: false == false +CmdLine.tests.cpp:: passed: spec.matches( tcB ) == false for: false == false +CmdLine.tests.cpp:: passed: spec.matches( tcC ) == false for: false == false +CmdLine.tests.cpp:: passed: spec.matches( tcD ) == true for: true == true +Condition.tests.cpp:: passed: p == 0 for: 0 == 0 +Condition.tests.cpp:: passed: p == pNULL for: 0 == 0 +Condition.tests.cpp:: passed: p != 0 for: 0x != 0 +Condition.tests.cpp:: passed: cp != 0 for: 0x != 0 +Condition.tests.cpp:: passed: cpc != 0 for: 0x != 0 +Condition.tests.cpp:: passed: returnsNull() == 0 for: {null string} == 0 +Condition.tests.cpp:: passed: returnsConstNull() == 0 for: {null string} == 0 +Condition.tests.cpp:: passed: 0 != p for: 0 != 0x +CmdLine.tests.cpp:: passed: result for: {?} +CmdLine.tests.cpp:: passed: config.processName == "" for: "" == "" +CmdLine.tests.cpp:: passed: result for: {?} +CmdLine.tests.cpp:: passed: config.processName == "test" for: "test" == "test" +CmdLine.tests.cpp:: passed: config.shouldDebugBreak == false for: false == false +CmdLine.tests.cpp:: passed: config.abortAfter == -1 for: -1 == -1 +CmdLine.tests.cpp:: passed: config.noThrow == false for: false == false +CmdLine.tests.cpp:: passed: config.reporterName == "console" for: "console" == "console" +CmdLine.tests.cpp:: passed: !(cfg.hasTestFilters()) for: !false +CmdLine.tests.cpp:: passed: result for: {?} +CmdLine.tests.cpp:: passed: cfg.hasTestFilters() for: true +CmdLine.tests.cpp:: passed: cfg.testSpec().matches(fakeTestCase("notIncluded")) == false for: false == false +CmdLine.tests.cpp:: passed: cfg.testSpec().matches(fakeTestCase("test1")) for: true +CmdLine.tests.cpp:: passed: result for: {?} +CmdLine.tests.cpp:: passed: cfg.hasTestFilters() for: true +CmdLine.tests.cpp:: passed: cfg.testSpec().matches(fakeTestCase("test1")) == false for: false == false +CmdLine.tests.cpp:: passed: cfg.testSpec().matches(fakeTestCase("alwaysIncluded")) for: true +CmdLine.tests.cpp:: passed: result for: {?} +CmdLine.tests.cpp:: passed: cfg.hasTestFilters() for: true +CmdLine.tests.cpp:: passed: cfg.testSpec().matches(fakeTestCase("test1")) == false for: false == false +CmdLine.tests.cpp:: passed: cfg.testSpec().matches(fakeTestCase("alwaysIncluded")) for: true +CmdLine.tests.cpp:: passed: cli.parse({"test", "-r", "console"}) for: {?} +CmdLine.tests.cpp:: passed: config.reporterName == "console" for: "console" == "console" +CmdLine.tests.cpp:: passed: cli.parse({"test", "-r", "xml"}) for: {?} +CmdLine.tests.cpp:: passed: config.reporterName == "xml" for: "xml" == "xml" +CmdLine.tests.cpp:: passed: cli.parse({"test", "--reporter", "junit"}) for: {?} +CmdLine.tests.cpp:: passed: config.reporterName == "junit" for: "junit" == "junit" +CmdLine.tests.cpp:: passed: !(cli.parse({ "test", "-r", "xml", "-r", "junit" })) for: !{?} +CmdLine.tests.cpp:: passed: cli.parse({"test", "-b"}) for: {?} +CmdLine.tests.cpp:: passed: config.shouldDebugBreak == true for: true == true +CmdLine.tests.cpp:: passed: cli.parse({"test", "--break"}) for: {?} +CmdLine.tests.cpp:: passed: config.shouldDebugBreak for: true +CmdLine.tests.cpp:: passed: cli.parse({"test", "-a"}) for: {?} +CmdLine.tests.cpp:: passed: config.abortAfter == 1 for: 1 == 1 +CmdLine.tests.cpp:: passed: cli.parse({"test", "-x", "2"}) for: {?} +CmdLine.tests.cpp:: passed: config.abortAfter == 2 for: 2 == 2 +CmdLine.tests.cpp:: passed: !result for: true +CmdLine.tests.cpp:: passed: result.errorMessage(), Contains("convert") && Contains("oops") for: "Unable to convert 'oops' to destination type" ( contains: "convert" and contains: "oops" ) +CmdLine.tests.cpp:: passed: cli.parse({"test", "-e"}) for: {?} +CmdLine.tests.cpp:: passed: config.noThrow for: true +CmdLine.tests.cpp:: passed: cli.parse({"test", "--nothrow"}) for: {?} +CmdLine.tests.cpp:: passed: config.noThrow for: true +CmdLine.tests.cpp:: passed: cli.parse({"test", "-o", "filename.ext"}) for: {?} +CmdLine.tests.cpp:: passed: config.outputFilename == "filename.ext" for: "filename.ext" == "filename.ext" +CmdLine.tests.cpp:: passed: cli.parse({"test", "--out", "filename.ext"}) for: {?} +CmdLine.tests.cpp:: passed: config.outputFilename == "filename.ext" for: "filename.ext" == "filename.ext" +CmdLine.tests.cpp:: passed: cli.parse({"test", "-abe"}) for: {?} +CmdLine.tests.cpp:: passed: config.abortAfter == 1 for: 1 == 1 +CmdLine.tests.cpp:: passed: config.shouldDebugBreak for: true +CmdLine.tests.cpp:: passed: config.noThrow == true for: true == true +CmdLine.tests.cpp:: passed: cli.parse({"test"}) for: {?} +CmdLine.tests.cpp:: passed: config.useColour == UseColour::Auto for: 0 == 0 +CmdLine.tests.cpp:: passed: cli.parse({"test", "--use-colour", "auto"}) for: {?} +CmdLine.tests.cpp:: passed: config.useColour == UseColour::Auto for: 0 == 0 +CmdLine.tests.cpp:: passed: cli.parse({"test", "--use-colour", "yes"}) for: {?} +CmdLine.tests.cpp:: passed: config.useColour == UseColour::Yes for: 1 == 1 +CmdLine.tests.cpp:: passed: cli.parse({"test", "--use-colour", "no"}) for: {?} +CmdLine.tests.cpp:: passed: config.useColour == UseColour::No for: 2 == 2 +CmdLine.tests.cpp:: passed: !result for: true +CmdLine.tests.cpp:: passed: result.errorMessage(), Contains( "colour mode must be one of" ) for: "colour mode must be one of: auto, yes or no. 'wrong' not recognised" contains: "colour mode must be one of" +Decomposition.tests.cpp:: failed: truthy(false) for: Hey, its truthy! +Matchers.tests.cpp:: failed: testStringForMatching(), Matches("this STRING contains 'abc' as a substring") for: "this string contains 'abc' as a substring" matches "this STRING contains 'abc' as a substring" case sensitively +Matchers.tests.cpp:: failed: testStringForMatching(), Matches("contains 'abc' as a substring") for: "this string contains 'abc' as a substring" matches "contains 'abc' as a substring" case sensitively +Matchers.tests.cpp:: failed: testStringForMatching(), Matches("this string contains 'abc' as a") for: "this string contains 'abc' as a substring" matches "this string contains 'abc' as a" case sensitively +Message.tests.cpp:: passed: with 1 message: 'this is a success' +Message.tests.cpp:: passed: +BDD.tests.cpp:: passed: before == 0 for: 0 == 0 +BDD.tests.cpp:: passed: after > before for: 1 > 0 +BDD.tests.cpp:: passed: itDoesThis() for: true +BDD.tests.cpp:: passed: itDoesThat() for: true +BDD.tests.cpp:: passed: with 1 message: 'boo!' +BDD.tests.cpp:: passed: v.size() == 0 for: 0 == 0 +BDD.tests.cpp:: passed: v.size() == 10 for: 10 == 10 +BDD.tests.cpp:: passed: v.capacity() >= 10 for: 10 >= 10 +BDD.tests.cpp:: passed: v.size() == 5 for: 5 == 5 +BDD.tests.cpp:: passed: v.capacity() >= 10 for: 10 >= 10 +BDD.tests.cpp:: passed: v.size() == 0 for: 0 == 0 +BDD.tests.cpp:: passed: v.capacity() >= 10 for: 10 >= 10 +BDD.tests.cpp:: passed: v.size() == 0 for: 0 == 0 +A string sent directly to stdout +A string sent directly to stderr +A string sent to stderr via clog +Approx.tests.cpp:: passed: d == Approx( 1.23 ) for: 1.23 == Approx( 1.23 ) +Approx.tests.cpp:: passed: d != Approx( 1.22 ) for: 1.23 != Approx( 1.22 ) +Approx.tests.cpp:: passed: d != Approx( 1.24 ) for: 1.23 != Approx( 1.24 ) +Approx.tests.cpp:: passed: d == 1.23_a for: 1.23 == Approx( 1.23 ) +Approx.tests.cpp:: passed: d != 1.22_a for: 1.23 != Approx( 1.22 ) +Approx.tests.cpp:: passed: Approx( d ) == 1.23 for: Approx( 1.23 ) == 1.23 +Approx.tests.cpp:: passed: Approx( d ) != 1.22 for: Approx( 1.23 ) != 1.22 +Approx.tests.cpp:: passed: Approx( d ) != 1.24 for: Approx( 1.23 ) != 1.24 +Approx.tests.cpp:: passed: INFINITY == Approx(INFINITY) for: inff == Approx( inf ) +Message from section one +Message from section two +Matchers.tests.cpp:: failed: testStringForMatching(), StartsWith("This String") for: "this string contains 'abc' as a substring" starts with: "This String" +Matchers.tests.cpp:: failed: testStringForMatching(), StartsWith("string", Catch::CaseSensitive::No) for: "this string contains 'abc' as a substring" starts with: "string" (case insensitive) +ToStringGeneral.tests.cpp:: passed: Catch::Detail::stringify(singular) == "{ 1 }" for: "{ 1 }" == "{ 1 }" +ToStringGeneral.tests.cpp:: passed: Catch::Detail::stringify(arr) == "{ 3, 2, 1 }" for: "{ 3, 2, 1 }" == "{ 3, 2, 1 }" +ToStringGeneral.tests.cpp:: passed: Catch::Detail::stringify(arr) == R"({ { "1:1", "1:2", "1:3" }, { "2:1", "2:2" } })" for: "{ { "1:1", "1:2", "1:3" }, { "2:1", "2:2" } }" +== +"{ { "1:1", "1:2", "1:3" }, { "2:1", "2:2" } }" +Matchers.tests.cpp:: passed: testStringForMatching(), Contains("string") for: "this string contains 'abc' as a substring" contains: "string" +Matchers.tests.cpp:: passed: testStringForMatching(), Contains("string", Catch::CaseSensitive::No) for: "this string contains 'abc' as a substring" contains: "string" (case insensitive) +Matchers.tests.cpp:: passed: testStringForMatching(), Contains("abc") for: "this string contains 'abc' as a substring" contains: "abc" +Matchers.tests.cpp:: passed: testStringForMatching(), Contains("aBC", Catch::CaseSensitive::No) for: "this string contains 'abc' as a substring" contains: "abc" (case insensitive) +Matchers.tests.cpp:: passed: testStringForMatching(), StartsWith("this") for: "this string contains 'abc' as a substring" starts with: "this" +Matchers.tests.cpp:: passed: testStringForMatching(), StartsWith("THIS", Catch::CaseSensitive::No) for: "this string contains 'abc' as a substring" starts with: "this" (case insensitive) +Matchers.tests.cpp:: passed: testStringForMatching(), EndsWith("substring") for: "this string contains 'abc' as a substring" ends with: "substring" +Matchers.tests.cpp:: passed: testStringForMatching(), EndsWith(" SuBsTrInG", Catch::CaseSensitive::No) for: "this string contains 'abc' as a substring" ends with: " substring" (case insensitive) +String.tests.cpp:: passed: empty.empty() for: true +String.tests.cpp:: passed: empty.size() == 0 for: 0 == 0 +String.tests.cpp:: passed: std::strcmp( empty.c_str(), "" ) == 0 for: 0 == 0 +String.tests.cpp:: passed: s.empty() == false for: false == false +String.tests.cpp:: passed: s.size() == 5 for: 5 == 5 +String.tests.cpp:: passed: isSubstring( s ) == false for: false == false +String.tests.cpp:: passed: std::strcmp( rawChars, "hello" ) == 0 for: 0 == 0 +String.tests.cpp:: passed: isOwned( s ) == false for: false == false +String.tests.cpp:: passed: s.c_str() == rawChars for: "hello" == "hello" +String.tests.cpp:: passed: isOwned( s ) == false for: false == false +String.tests.cpp:: passed: original == "original" +String.tests.cpp:: passed: isSubstring( original ) for: true +String.tests.cpp:: passed: isOwned( original ) == false for: false == false +String.tests.cpp:: passed: isSubstring( original ) == false for: false == false +String.tests.cpp:: passed: isOwned( original ) for: true +String.tests.cpp:: passed: ss.empty() == false for: false == false +String.tests.cpp:: passed: ss.size() == 5 for: 5 == 5 +String.tests.cpp:: passed: std::strcmp( ss.c_str(), "hello" ) == 0 for: 0 == 0 +String.tests.cpp:: passed: ss == "hello" for: hello == "hello" +String.tests.cpp:: passed: isSubstring( ss ) for: true +String.tests.cpp:: passed: isOwned( ss ) == false for: false == false +String.tests.cpp:: passed: rawChars == s.currentData() for: "hello world!" == "hello world!" +String.tests.cpp:: passed: ss.c_str() != rawChars for: "hello" != "hello world!" +String.tests.cpp:: passed: isSubstring( ss ) == false for: false == false +String.tests.cpp:: passed: isOwned( ss ) for: true +String.tests.cpp:: passed: ss.currentData() != s.currentData() for: "hello" != "hello world!" +String.tests.cpp:: passed: ss.size() == 6 for: 6 == 6 +String.tests.cpp:: passed: std::strcmp( ss.c_str(), "world!" ) == 0 for: 0 == 0 +String.tests.cpp:: passed: s.c_str() == s2.c_str() for: "hello world!" == "hello world!" +String.tests.cpp:: passed: s.c_str() != ss.c_str() for: "hello world!" != "hello" +String.tests.cpp:: passed: StringRef("hello") == StringRef("hello") for: hello == hello +String.tests.cpp:: passed: StringRef("hello") != StringRef("cello") for: hello != cello +String.tests.cpp:: passed: sr == "a standard string" for: a standard string == "a standard string" +String.tests.cpp:: passed: sr.size() == stdStr.size() for: 17 == 17 +String.tests.cpp:: passed: sr == "a standard string" for: a standard string == "a standard string" +String.tests.cpp:: passed: sr.size() == stdStr.size() for: 17 == 17 +String.tests.cpp:: passed: sr == "a standard string" for: a standard string == "a standard string" +String.tests.cpp:: passed: sr.size() == stdStr.size() for: 17 == 17 +String.tests.cpp:: passed: stdStr == "a stringref" for: "a stringref" == "a stringref" +String.tests.cpp:: passed: stdStr.size() == sr.size() for: 11 == 11 +String.tests.cpp:: passed: stdStr == "a stringref" for: "a stringref" == "a stringref" +String.tests.cpp:: passed: stdStr.size() == sr.size() for: 11 == 11 +String.tests.cpp:: passed: stdStr == "a stringref" for: "a stringref" == "a stringref" +String.tests.cpp:: passed: stdStr.size() == sr.size() for: 11 == 11 +String.tests.cpp:: passed: ascii.numberOfCharacters() == ascii.size() for: 39 == 39 +String.tests.cpp:: passed: simpleu8.numberOfCharacters() == 30 for: 30 == 30 +String.tests.cpp:: passed: emojis.numberOfCharacters() == 9 for: 9 == 9 +ToStringChrono.tests.cpp:: passed: minute == seconds for: 1 m == 60 s +ToStringChrono.tests.cpp:: passed: hour != seconds for: 1 h != 60 s +ToStringChrono.tests.cpp:: passed: micro != milli for: 1 us != 1 ms +ToStringChrono.tests.cpp:: passed: nano != micro for: 1 ns != 1 us +ToStringChrono.tests.cpp:: passed: half_minute != femto_second for: 1 [30/1]s != 1 fs +ToStringChrono.tests.cpp:: passed: pico_second != atto_second for: 1 ps != 1 as +ToStringChrono.tests.cpp:: passed: now != later for: {iso8601-timestamp} +!= +{iso8601-timestamp} +Misc.tests.cpp:: failed: s1 == s2 for: "if ($b == 10) { + $a = 20; +}" +== +"if ($b == 10) { + $a = 20; +} +" +TagAlias.tests.cpp:: passed: what, Contains( "[@zzz]" ) for: "error: tag alias, '[@zzz]' already registered. + First seen at: file:2 + Redefined at: file:10" contains: "[@zzz]" +TagAlias.tests.cpp:: passed: what, Contains( "file" ) for: "error: tag alias, '[@zzz]' already registered. + First seen at: file:2 + Redefined at: file:10" contains: "file" +TagAlias.tests.cpp:: passed: what, Contains( "2" ) for: "error: tag alias, '[@zzz]' already registered. + First seen at: file:2 + Redefined at: file:10" contains: "2" +TagAlias.tests.cpp:: passed: what, Contains( "10" ) for: "error: tag alias, '[@zzz]' already registered. + First seen at: file:2 + Redefined at: file:10" contains: "10" +TagAlias.tests.cpp:: passed: registry.add( "[no ampersat]", "", Catch::SourceLineInfo( "file", 3 ) ) +TagAlias.tests.cpp:: passed: registry.add( "[the @ is not at the start]", "", Catch::SourceLineInfo( "file", 3 ) ) +TagAlias.tests.cpp:: passed: registry.add( "@no square bracket at start]", "", Catch::SourceLineInfo( "file", 3 ) ) +TagAlias.tests.cpp:: passed: registry.add( "[@no square bracket at end", "", Catch::SourceLineInfo( "file", 3 ) ) +VariadicMacros.tests.cpp:: passed: with 1 message: 'no assertions' +Tricky.tests.cpp:: passed: 0x == bit30and31 for: 3221225472 (0x) == 3221225472 +Message.tests.cpp:: failed - but was ok: 1 == 2 +Misc.tests.cpp:: passed: with 1 message: 'oops!' +Exception.tests.cpp:: failed: unexpected exception with message: 'For some reason someone is throwing a string literal!' +PartTracker.tests.cpp:: passed: testCase.isOpen() for: true +PartTracker.tests.cpp:: passed: s1.isOpen() for: true +PartTracker.tests.cpp:: passed: s1.isSuccessfullyCompleted() for: true +PartTracker.tests.cpp:: passed: testCase.isComplete() == false for: false == false +PartTracker.tests.cpp:: passed: ctx.completedCycle() for: true +PartTracker.tests.cpp:: passed: testCase.isSuccessfullyCompleted() for: true +PartTracker.tests.cpp:: passed: testCase.isOpen() for: true +PartTracker.tests.cpp:: passed: s1.isOpen() for: true +PartTracker.tests.cpp:: passed: s1.isComplete() for: true +PartTracker.tests.cpp:: passed: s1.isSuccessfullyCompleted() == false for: false == false +PartTracker.tests.cpp:: passed: testCase.isComplete() == false for: false == false +PartTracker.tests.cpp:: passed: ctx.completedCycle() for: true +PartTracker.tests.cpp:: passed: testCase.isSuccessfullyCompleted() == false for: false == false +PartTracker.tests.cpp:: passed: testCase2.isOpen() for: true +PartTracker.tests.cpp:: passed: s1b.isOpen() == false for: false == false +PartTracker.tests.cpp:: passed: ctx.completedCycle() for: true +PartTracker.tests.cpp:: passed: testCase.isComplete() for: true +PartTracker.tests.cpp:: passed: testCase.isSuccessfullyCompleted() for: true +PartTracker.tests.cpp:: passed: testCase.isOpen() for: true +PartTracker.tests.cpp:: passed: s1.isOpen() for: true +PartTracker.tests.cpp:: passed: s1.isComplete() for: true +PartTracker.tests.cpp:: passed: s1.isSuccessfullyCompleted() == false for: false == false +PartTracker.tests.cpp:: passed: testCase.isComplete() == false for: false == false +PartTracker.tests.cpp:: passed: ctx.completedCycle() for: true +PartTracker.tests.cpp:: passed: testCase.isSuccessfullyCompleted() == false for: false == false +PartTracker.tests.cpp:: passed: testCase2.isOpen() for: true +PartTracker.tests.cpp:: passed: s1b.isOpen() == false for: false == false +PartTracker.tests.cpp:: passed: s2.isOpen() for: true +PartTracker.tests.cpp:: passed: ctx.completedCycle() for: true +PartTracker.tests.cpp:: passed: testCase.isComplete() for: true +PartTracker.tests.cpp:: passed: testCase.isSuccessfullyCompleted() for: true +PartTracker.tests.cpp:: passed: testCase.isOpen() for: true +PartTracker.tests.cpp:: passed: s1.isOpen() for: true +PartTracker.tests.cpp:: passed: s2.isOpen() == false for: false == false +PartTracker.tests.cpp:: passed: testCase.isComplete() == false for: false == false +PartTracker.tests.cpp:: passed: testCase2.isOpen() for: true +PartTracker.tests.cpp:: passed: s1b.isOpen() == false for: false == false +PartTracker.tests.cpp:: passed: s2b.isOpen() for: true +PartTracker.tests.cpp:: passed: ctx.completedCycle() == false for: false == false +PartTracker.tests.cpp:: passed: ctx.completedCycle() for: true +PartTracker.tests.cpp:: passed: s2b.isSuccessfullyCompleted() for: true +PartTracker.tests.cpp:: passed: testCase2.isComplete() == false for: false == false +PartTracker.tests.cpp:: passed: testCase2.isSuccessfullyCompleted() for: true +PartTracker.tests.cpp:: passed: testCase.isOpen() for: true +PartTracker.tests.cpp:: passed: s1.isOpen() for: true +PartTracker.tests.cpp:: passed: s2.isOpen() == false for: false == false +PartTracker.tests.cpp:: passed: testCase.isComplete() == false for: false == false +PartTracker.tests.cpp:: passed: testCase2.isOpen() for: true +PartTracker.tests.cpp:: passed: s1b.isOpen() == false for: false == false +PartTracker.tests.cpp:: passed: s2b.isOpen() for: true +PartTracker.tests.cpp:: passed: ctx.completedCycle() == false for: false == false +PartTracker.tests.cpp:: passed: ctx.completedCycle() for: true +PartTracker.tests.cpp:: passed: s2b.isComplete() for: true +PartTracker.tests.cpp:: passed: s2b.isSuccessfullyCompleted() == false for: false == false +PartTracker.tests.cpp:: passed: testCase2.isSuccessfullyCompleted() == false for: false == false +PartTracker.tests.cpp:: passed: testCase3.isOpen() for: true +PartTracker.tests.cpp:: passed: s1c.isOpen() == false for: false == false +PartTracker.tests.cpp:: passed: s2c.isOpen() == false for: false == false +PartTracker.tests.cpp:: passed: testCase3.isSuccessfullyCompleted() for: true +PartTracker.tests.cpp:: passed: testCase.isOpen() for: true +PartTracker.tests.cpp:: passed: s1.isOpen() for: true +PartTracker.tests.cpp:: passed: s2.isOpen() for: true +PartTracker.tests.cpp:: passed: s2.isComplete() for: true +PartTracker.tests.cpp:: passed: s1.isComplete() == false for: false == false +PartTracker.tests.cpp:: passed: s1.isComplete() for: true +PartTracker.tests.cpp:: passed: testCase.isComplete() == false for: false == false +PartTracker.tests.cpp:: passed: testCase.isComplete() for: true +PartTracker.tests.cpp:: passed: testCase.isOpen() for: true +PartTracker.tests.cpp:: passed: s1.isOpen() for: true +PartTracker.tests.cpp:: passed: g1.isOpen() for: true +PartTracker.tests.cpp:: passed: g1.index() == 0 for: 0 == 0 +PartTracker.tests.cpp:: passed: g1.isComplete() == false for: false == false +PartTracker.tests.cpp:: passed: s1.isComplete() == false for: false == false +PartTracker.tests.cpp:: passed: s1.isComplete() == false for: false == false +PartTracker.tests.cpp:: passed: testCase.isSuccessfullyCompleted() == false for: false == false +PartTracker.tests.cpp:: passed: testCase2.isOpen() for: true +PartTracker.tests.cpp:: passed: s1b.isOpen() for: true +PartTracker.tests.cpp:: passed: g1b.isOpen() for: true +PartTracker.tests.cpp:: passed: g1b.index() == 1 for: 1 == 1 +PartTracker.tests.cpp:: passed: s1.isComplete() == false for: false == false +PartTracker.tests.cpp:: passed: s1b.isComplete() for: true +PartTracker.tests.cpp:: passed: g1b.isComplete() for: true +PartTracker.tests.cpp:: passed: testCase2.isComplete() for: true +PartTracker.tests.cpp:: passed: testCase.isOpen() for: true +PartTracker.tests.cpp:: passed: s1.isOpen() for: true +PartTracker.tests.cpp:: passed: g1.isOpen() for: true +PartTracker.tests.cpp:: passed: g1.index() == 0 for: 0 == 0 +PartTracker.tests.cpp:: passed: g1.isComplete() == false for: false == false +PartTracker.tests.cpp:: passed: s1.isComplete() == false for: false == false +PartTracker.tests.cpp:: passed: s2.isOpen() for: true +PartTracker.tests.cpp:: passed: s2.isComplete() for: true +PartTracker.tests.cpp:: passed: s1.isComplete() == false for: false == false +PartTracker.tests.cpp:: passed: testCase.isComplete() == false for: false == false +PartTracker.tests.cpp:: passed: testCase2.isOpen() for: true +PartTracker.tests.cpp:: passed: s1b.isOpen() for: true +PartTracker.tests.cpp:: passed: g1b.isOpen() for: true +PartTracker.tests.cpp:: passed: g1b.index() == 1 for: 1 == 1 +PartTracker.tests.cpp:: passed: s2b.isOpen() for: true +PartTracker.tests.cpp:: passed: s2b.isComplete() for: true +PartTracker.tests.cpp:: passed: g1b.isComplete() for: true +PartTracker.tests.cpp:: passed: s1b.isComplete() for: true +PartTracker.tests.cpp:: passed: testCase2.isComplete() for: true +PartTracker.tests.cpp:: passed: testCase.isOpen() for: true +PartTracker.tests.cpp:: passed: s1.isOpen() for: true +PartTracker.tests.cpp:: passed: g1.isOpen() for: true +PartTracker.tests.cpp:: passed: g1.index() == 0 for: 0 == 0 +PartTracker.tests.cpp:: passed: g1.isComplete() == false for: false == false +PartTracker.tests.cpp:: passed: s1.isComplete() == false for: false == false +PartTracker.tests.cpp:: passed: s2.isOpen() for: true +PartTracker.tests.cpp:: passed: s2.isComplete() for: true +PartTracker.tests.cpp:: passed: s2.isSuccessfullyCompleted() == false for: false == false +PartTracker.tests.cpp:: passed: s1.isComplete() == false for: false == false +PartTracker.tests.cpp:: passed: testCase.isComplete() == false for: false == false +PartTracker.tests.cpp:: passed: testCase2.isOpen() for: true +PartTracker.tests.cpp:: passed: s1b.isOpen() for: true +PartTracker.tests.cpp:: passed: g1b.isOpen() for: true +PartTracker.tests.cpp:: passed: g1b.index() == 0 for: 0 == 0 +PartTracker.tests.cpp:: passed: s2b.isOpen() == false for: false == false +PartTracker.tests.cpp:: passed: g1b.isComplete() == false for: false == false +PartTracker.tests.cpp:: passed: s1b.isComplete() == false for: false == false +PartTracker.tests.cpp:: passed: testCase2.isComplete() == false for: false == false +PartTracker.tests.cpp:: passed: testCase3.isOpen() for: true +PartTracker.tests.cpp:: passed: s1c.isOpen() for: true +PartTracker.tests.cpp:: passed: g1c.isOpen() for: true +PartTracker.tests.cpp:: passed: g1c.index() == 1 for: 1 == 1 +PartTracker.tests.cpp:: passed: s2c.isOpen() for: true +PartTracker.tests.cpp:: passed: s2c.isComplete() for: true +PartTracker.tests.cpp:: passed: g1c.isComplete() for: true +PartTracker.tests.cpp:: passed: s1c.isComplete() for: true +PartTracker.tests.cpp:: passed: testCase3.isComplete() for: true +Exception.tests.cpp:: failed: unexpected exception with message: '3.14' +Approx.tests.cpp:: passed: d == approx( 1.23 ) for: 1.23 == Approx( 1.23 ) +Approx.tests.cpp:: passed: d == approx( 1.22 ) for: 1.23 == Approx( 1.22 ) +Approx.tests.cpp:: passed: d == approx( 1.24 ) for: 1.23 == Approx( 1.24 ) +Approx.tests.cpp:: passed: d != approx( 1.25 ) for: 1.23 != Approx( 1.25 ) +Approx.tests.cpp:: passed: approx( d ) == 1.23 for: Approx( 1.23 ) == 1.23 +Approx.tests.cpp:: passed: approx( d ) == 1.22 for: Approx( 1.23 ) == 1.22 +Approx.tests.cpp:: passed: approx( d ) == 1.24 for: Approx( 1.23 ) == 1.24 +Approx.tests.cpp:: passed: approx( d ) != 1.25 for: Approx( 1.23 ) != 1.25 +VariadicMacros.tests.cpp:: passed: with 1 message: 'no assertions' +Matchers.tests.cpp:: passed: v, VectorContains(1) for: { 1, 2, 3 } Contains: 1 +Matchers.tests.cpp:: passed: v, VectorContains(2) for: { 1, 2, 3 } Contains: 2 +Matchers.tests.cpp:: passed: v, Contains(v2) for: { 1, 2, 3 } Contains: { 1, 2 } +Matchers.tests.cpp:: passed: v, Contains(v2) for: { 1, 2, 3 } Contains: { 1, 2, 3 } +Matchers.tests.cpp:: passed: v, Contains(empty) for: { 1, 2, 3 } Contains: { } +Matchers.tests.cpp:: passed: empty, Contains(empty) for: { } Contains: { } +Matchers.tests.cpp:: passed: v, VectorContains(1) && VectorContains(2) for: { 1, 2, 3 } ( Contains: 1 and Contains: 2 ) +Matchers.tests.cpp:: passed: v, Equals(v) for: { 1, 2, 3 } Equals: { 1, 2, 3 } +Matchers.tests.cpp:: passed: empty, Equals(empty) for: { } Equals: { } +Matchers.tests.cpp:: passed: v, Equals(v2) for: { 1, 2, 3 } Equals: { 1, 2, 3 } +Matchers.tests.cpp:: passed: v, UnorderedEquals(v) for: { 1, 2, 3 } UnorderedEquals: { 1, 2, 3 } +Matchers.tests.cpp:: passed: empty, UnorderedEquals(empty) for: { } UnorderedEquals: { } +Matchers.tests.cpp:: passed: permuted, UnorderedEquals(v) for: { 1, 3, 2 } UnorderedEquals: { 1, 2, 3 } +Matchers.tests.cpp:: passed: permuted, UnorderedEquals(v) for: { 2, 3, 1 } UnorderedEquals: { 1, 2, 3 } +Matchers.tests.cpp:: failed: v, VectorContains(-1) for: { 1, 2, 3 } Contains: -1 +Matchers.tests.cpp:: failed: empty, VectorContains(1) for: { } Contains: 1 +Matchers.tests.cpp:: failed: empty, Contains(v) for: { } Contains: { 1, 2, 3 } +Matchers.tests.cpp:: failed: v, Contains(v2) for: { 1, 2, 3 } Contains: { 1, 2, 4 } +Matchers.tests.cpp:: failed: v, Equals(v2) for: { 1, 2, 3 } Equals: { 1, 2 } +Matchers.tests.cpp:: failed: v2, Equals(v) for: { 1, 2 } Equals: { 1, 2, 3 } +Matchers.tests.cpp:: failed: empty, Equals(v) for: { } Equals: { 1, 2, 3 } +Matchers.tests.cpp:: failed: v, Equals(empty) for: { 1, 2, 3 } Equals: { } +Matchers.tests.cpp:: failed: v, UnorderedEquals(empty) for: { 1, 2, 3 } UnorderedEquals: { } +Matchers.tests.cpp:: failed: empty, UnorderedEquals(v) for: { } UnorderedEquals: { 1, 2, 3 } +Matchers.tests.cpp:: failed: permuted, UnorderedEquals(v) for: { 1, 3 } UnorderedEquals: { 1, 2, 3 } +Matchers.tests.cpp:: failed: permuted, UnorderedEquals(v) for: { 3, 1 } UnorderedEquals: { 1, 2, 3 } +Exception.tests.cpp:: passed: thisThrows(), std::domain_error +Exception.tests.cpp:: passed: thisDoesntThrow() +Exception.tests.cpp:: passed: thisThrows() +Exception.tests.cpp:: failed: unexpected exception with message: 'unexpected exception' +Exception.tests.cpp:: failed: unexpected exception with message: 'expected exception'; expression was: thisThrows() == 0 +Exception.tests.cpp:: failed: unexpected exception with message: 'expected exception'; expression was: thisThrows() == 0 +Exception.tests.cpp:: failed: unexpected exception with message: 'expected exception'; expression was: thisThrows() == 0 +Exception.tests.cpp:: failed: unexpected exception with message: 'unexpected exception' +Tricky.tests.cpp:: warning: 'Uncomment the code in this test to check that it gives a sensible compiler error' +Tricky.tests.cpp:: warning: 'Uncomment the code in this test to check that it gives a sensible compiler error' +Tricky.tests.cpp:: passed: +Tricky.tests.cpp:: passed: +Tricky.tests.cpp:: passed: +Tricky.tests.cpp:: passed: +Xml.tests.cpp:: passed: encode( "normal string" ) == "normal string" for: "normal string" == "normal string" +Xml.tests.cpp:: passed: encode( "" ) == "" for: "" == "" +Xml.tests.cpp:: passed: encode( "smith & jones" ) == "smith & jones" for: "smith & jones" == "smith & jones" +Xml.tests.cpp:: passed: encode( "smith < jones" ) == "smith < jones" for: "smith < jones" == "smith < jones" +Xml.tests.cpp:: passed: encode( "smith > jones" ) == "smith > jones" for: "smith > jones" == "smith > jones" +Xml.tests.cpp:: passed: encode( "smith ]]> jones" ) == "smith ]]> jones" for: "smith ]]> jones" +== +"smith ]]> jones" +Xml.tests.cpp:: passed: encode( stringWithQuotes ) == stringWithQuotes for: "don't "quote" me on that" +== +"don't "quote" me on that" +Xml.tests.cpp:: passed: encode( stringWithQuotes, Catch::XmlEncode::ForAttributes ) == "don't "quote" me on that" for: "don't "quote" me on that" +== +"don't "quote" me on that" +Xml.tests.cpp:: passed: encode( "[/x01]" ) == "[//x01]" for: "[/x01]" == "[/x01]" +Xml.tests.cpp:: passed: encode( "[/x7F]" ) == "[//x7F]" for: "[/x7F]" == "[/x7F]" +Xml.tests.cpp:: passed: encode(u8"Here be 👾") == u8"Here be 👾" for: "Here be 👾" == "Here be 👾" +Xml.tests.cpp:: passed: encode(u8"Å¡Å¡") == u8"Å¡Å¡" for: "Å¡Å¡" == "Å¡Å¡" +Xml.tests.cpp:: passed: encode("/xDF/xBF") == "/xDF/xBF" for: "ß¿" == "ß¿" +Xml.tests.cpp:: passed: encode("/xE0/xA0/x80") == "/xE0/xA0/x80" for: "à €" == "à €" +Xml.tests.cpp:: passed: encode("/xED/x9F/xBF") == "/xED/x9F/xBF" for: "퟿" == "퟿" +Xml.tests.cpp:: passed: encode("/xEE/x80/x80") == "/xEE/x80/x80" for: "" == "" +Xml.tests.cpp:: passed: encode("/xEF/xBF/xBF") == "/xEF/xBF/xBF" for: "ï¿¿" == "ï¿¿" +Xml.tests.cpp:: passed: encode("/xF0/x90/x80/x80") == "/xF0/x90/x80/x80" for: "ð€€" == "ð€€" +Xml.tests.cpp:: passed: encode("/xF4/x8F/xBF/xBF") == "/xF4/x8F/xBF/xBF" for: "ô¿¿" == "ô¿¿" +Xml.tests.cpp:: passed: encode("Here /xFF be 👾") == u8"Here //xFF be 👾" for: "Here /xFF be 👾" == "Here /xFF be 👾" +Xml.tests.cpp:: passed: encode("/xFF") == "//xFF" for: "/xFF" == "/xFF" +Xml.tests.cpp:: passed: encode("/xC5/xC5/xA0") == u8"//xC5Å " for: "/xC5Å " == "/xC5Å " +Xml.tests.cpp:: passed: encode("/xF4/x90/x80/x80") == u8"//xF4//x90//x80//x80" for: "/xF4/x90/x80/x80" == "/xF4/x90/x80/x80" +Xml.tests.cpp:: passed: encode("/xC0/x80") == u8"//xC0//x80" for: "/xC0/x80" == "/xC0/x80" +Xml.tests.cpp:: passed: encode("/xF0/x80/x80/x80") == u8"//xF0//x80//x80//x80" for: "/xF0/x80/x80/x80" == "/xF0/x80/x80/x80" +Xml.tests.cpp:: passed: encode("/xC1/xBF") == u8"//xC1//xBF" for: "/xC1/xBF" == "/xC1/xBF" +Xml.tests.cpp:: passed: encode("/xE0/x9F/xBF") == u8"//xE0//x9F//xBF" for: "/xE0/x9F/xBF" == "/xE0/x9F/xBF" +Xml.tests.cpp:: passed: encode("/xF0/x8F/xBF/xBF") == u8"//xF0//x8F//xBF//xBF" for: "/xF0/x8F/xBF/xBF" == "/xF0/x8F/xBF/xBF" +Xml.tests.cpp:: passed: encode("/xED/xA0/x80") == "/xED/xA0/x80" for: "í €" == "í €" +Xml.tests.cpp:: passed: encode("/xED/xAF/xBF") == "/xED/xAF/xBF" for: "í¯¿" == "í¯¿" +Xml.tests.cpp:: passed: encode("/xED/xB0/x80") == "/xED/xB0/x80" for: "í°€" == "í°€" +Xml.tests.cpp:: passed: encode("/xED/xBF/xBF") == "/xED/xBF/xBF" for: "í¿¿" == "í¿¿" +Xml.tests.cpp:: passed: encode("/x80") == u8"//x80" for: "/x80" == "/x80" +Xml.tests.cpp:: passed: encode("/x81") == u8"//x81" for: "/x81" == "/x81" +Xml.tests.cpp:: passed: encode("/xBC") == u8"//xBC" for: "/xBC" == "/xBC" +Xml.tests.cpp:: passed: encode("/xBF") == u8"//xBF" for: "/xBF" == "/xBF" +Xml.tests.cpp:: passed: encode("/xF5/x80/x80/x80") == u8"//xF5//x80//x80//x80" for: "/xF5/x80/x80/x80" == "/xF5/x80/x80/x80" +Xml.tests.cpp:: passed: encode("/xF6/x80/x80/x80") == u8"//xF6//x80//x80//x80" for: "/xF6/x80/x80/x80" == "/xF6/x80/x80/x80" +Xml.tests.cpp:: passed: encode("/xF7/x80/x80/x80") == u8"//xF7//x80//x80//x80" for: "/xF7/x80/x80/x80" == "/xF7/x80/x80/x80" +Xml.tests.cpp:: passed: encode("/xDE") == u8"//xDE" for: "/xDE" == "/xDE" +Xml.tests.cpp:: passed: encode("/xDF") == u8"//xDF" for: "/xDF" == "/xDF" +Xml.tests.cpp:: passed: encode("/xE0") == u8"//xE0" for: "/xE0" == "/xE0" +Xml.tests.cpp:: passed: encode("/xEF") == u8"//xEF" for: "/xEF" == "/xEF" +Xml.tests.cpp:: passed: encode("/xF0") == u8"//xF0" for: "/xF0" == "/xF0" +Xml.tests.cpp:: passed: encode("/xF4") == u8"//xF4" for: "/xF4" == "/xF4" +Xml.tests.cpp:: passed: encode("/xE0/x80") == u8"//xE0//x80" for: "/xE0/x80" == "/xE0/x80" +Xml.tests.cpp:: passed: encode("/xE0/xBF") == u8"//xE0//xBF" for: "/xE0/xBF" == "/xE0/xBF" +Xml.tests.cpp:: passed: encode("/xE1/x80") == u8"//xE1//x80" for: "/xE1/x80" == "/xE1/x80" +Xml.tests.cpp:: passed: encode("/xF0/x80") == u8"//xF0//x80" for: "/xF0/x80" == "/xF0/x80" +Xml.tests.cpp:: passed: encode("/xF4/x80") == u8"//xF4//x80" for: "/xF4/x80" == "/xF4/x80" +Xml.tests.cpp:: passed: encode("/xF0/x80/x80") == u8"//xF0//x80//x80" for: "/xF0/x80/x80" == "/xF0/x80/x80" +Xml.tests.cpp:: passed: encode("/xF4/x80/x80") == u8"//xF4//x80//x80" for: "/xF4/x80/x80" == "/xF4/x80/x80" +ToStringVector.tests.cpp:: passed: Catch::Detail::stringify( empty ) == "{ }" for: "{ }" == "{ }" +ToStringVector.tests.cpp:: passed: Catch::Detail::stringify( oneValue ) == "{ 42 }" for: "{ 42 }" == "{ 42 }" +ToStringVector.tests.cpp:: passed: Catch::Detail::stringify( twoValues ) == "{ 42, 250 }" for: "{ 42, 250 }" == "{ 42, 250 }" +Misc.tests.cpp:: passed: x == 0 for: 0 == 0 +Tricky.tests.cpp:: passed: obj.prop != 0 for: 0x != 0 +Misc.tests.cpp:: passed: flag for: true +Misc.tests.cpp:: passed: testCheckedElse( true ) for: true +Misc.tests.cpp:: failed: flag for: false +Misc.tests.cpp:: failed: testCheckedElse( false ) for: false +Misc.tests.cpp:: passed: flag for: true +Misc.tests.cpp:: passed: testCheckedIf( true ) for: true +Misc.tests.cpp:: failed: flag for: false +Misc.tests.cpp:: failed: testCheckedIf( false ) for: false +Condition.tests.cpp:: passed: unsigned_char_var == 1 for: 1 == 1 +Condition.tests.cpp:: passed: unsigned_short_var == 1 for: 1 == 1 +Condition.tests.cpp:: passed: unsigned_int_var == 1 for: 1 == 1 +Condition.tests.cpp:: passed: unsigned_long_var == 1 for: 1 == 1 +Condition.tests.cpp:: passed: long_var == unsigned_char_var for: 1 == 1 +Condition.tests.cpp:: passed: long_var == unsigned_short_var for: 1 == 1 +Condition.tests.cpp:: passed: long_var == unsigned_int_var for: 1 == 1 +Condition.tests.cpp:: passed: long_var == unsigned_long_var for: 1 == 1 +Misc.tests.cpp:: passed: +Misc.tests.cpp:: passed: +Misc.tests.cpp:: passed: +loose text artifact +Message.tests.cpp:: failed: explicitly with 1 message: 'Previous info should not be seen' +Misc.tests.cpp:: passed: l == std::numeric_limits::max() for: 9223372036854775807 (0x) +== +9223372036854775807 (0x) +Misc.tests.cpp:: failed: b > a for: 0 > 1 +Misc.tests.cpp:: failed: b > a for: 1 > 1 +Misc.tests.cpp:: passed: b > a for: 2 > 1 +Misc.tests.cpp:: passed: b > a for: 3 > 1 +Misc.tests.cpp:: passed: b > a for: 4 > 1 +Misc.tests.cpp:: passed: b > a for: 5 > 1 +Misc.tests.cpp:: passed: b > a for: 6 > 1 +Misc.tests.cpp:: passed: b > a for: 7 > 1 +Misc.tests.cpp:: passed: b > a for: 8 > 1 +Misc.tests.cpp:: passed: b > a for: 9 > 1 +Misc.tests.cpp:: failed: ( fib[i] % 2 ) == 0 for: 1 == 0 with 1 message: 'Testing if fib[0] (1) is even' +Misc.tests.cpp:: failed: ( fib[i] % 2 ) == 0 for: 1 == 0 with 1 message: 'Testing if fib[1] (1) is even' +Misc.tests.cpp:: passed: ( fib[i] % 2 ) == 0 for: 0 == 0 with 1 message: 'Testing if fib[2] (2) is even' +Misc.tests.cpp:: failed: ( fib[i] % 2 ) == 0 for: 1 == 0 with 1 message: 'Testing if fib[3] (3) is even' +Misc.tests.cpp:: failed: ( fib[i] % 2 ) == 0 for: 1 == 0 with 1 message: 'Testing if fib[4] (5) is even' +Misc.tests.cpp:: passed: ( fib[i] % 2 ) == 0 for: 0 == 0 with 1 message: 'Testing if fib[5] (8) is even' +Misc.tests.cpp:: failed: ( fib[i] % 2 ) == 0 for: 1 == 0 with 1 message: 'Testing if fib[6] (13) is even' +Misc.tests.cpp:: failed: ( fib[i] % 2 ) == 0 for: 1 == 0 with 1 message: 'Testing if fib[7] (21) is even' +Misc.tests.cpp:: failed: a == b for: 1 == 2 +Misc.tests.cpp:: passed: a != b for: 1 != 2 +Misc.tests.cpp:: passed: a < b for: 1 < 2 +Misc.tests.cpp:: passed: a != b for: 1 != 2 +Misc.tests.cpp:: passed: b != a for: 2 != 1 +Misc.tests.cpp:: passed: a != b for: 1 != 2 +Tricky.tests.cpp:: passed: s == "7" for: "7" == "7" +Tricky.tests.cpp:: passed: ti == typeid(int) for: {?} == {?} +Misc.tests.cpp:: passed: +Misc.tests.cpp:: passed: makeString( false ) != static_cast(0) for: "valid string" != {null string} +Misc.tests.cpp:: passed: makeString( true ) == static_cast(0) for: {null string} == {null string} +Tricky.tests.cpp:: passed: ptr.get() == 0 for: 0 == 0 +ToStringPair.tests.cpp:: passed: ::Catch::Detail::stringify( pair ) == "{ { 42, /"Arthur/" }, { /"Ford/", 24 } }" for: "{ { 42, "Arthur" }, { "Ford", 24 } }" +== +"{ { 42, "Arthur" }, { "Ford", 24 } }" +Tricky.tests.cpp:: passed: p == 0 for: 0 == 0 +Misc.tests.cpp:: passed: a != b for: 1 != 2 +Misc.tests.cpp:: passed: b != a for: 2 != 1 +Misc.tests.cpp:: passed: a != b for: 1 != 2 +String.tests.cpp:: passed: Catch::replaceInPlace( letters, "b", "z" ) for: true +String.tests.cpp:: passed: letters == "azcdefcg" for: "azcdefcg" == "azcdefcg" +String.tests.cpp:: passed: Catch::replaceInPlace( letters, "c", "z" ) for: true +String.tests.cpp:: passed: letters == "abzdefzg" for: "abzdefzg" == "abzdefzg" +String.tests.cpp:: passed: Catch::replaceInPlace( letters, "a", "z" ) for: true +String.tests.cpp:: passed: letters == "zbcdefcg" for: "zbcdefcg" == "zbcdefcg" +String.tests.cpp:: passed: Catch::replaceInPlace( letters, "g", "z" ) for: true +String.tests.cpp:: passed: letters == "abcdefcz" for: "abcdefcz" == "abcdefcz" +String.tests.cpp:: passed: Catch::replaceInPlace( letters, letters, "replaced" ) for: true +String.tests.cpp:: passed: letters == "replaced" for: "replaced" == "replaced" +String.tests.cpp:: passed: !(Catch::replaceInPlace( letters, "x", "z" )) for: !false +String.tests.cpp:: passed: letters == letters for: "abcdefcg" == "abcdefcg" +String.tests.cpp:: passed: Catch::replaceInPlace( s, "'", "|'" ) for: true +String.tests.cpp:: passed: s == "didn|'t" for: "didn|'t" == "didn|'t" +Misc.tests.cpp:: failed: false with 1 message: '3' +Message.tests.cpp:: failed: false with 2 messages: 'hi' and 'i := 7' +ToStringGeneral.tests.cpp:: passed: Catch::Detail::stringify( emptyMap ) == "{ }" for: "{ }" == "{ }" +ToStringGeneral.tests.cpp:: passed: Catch::Detail::stringify( map ) == "{ { /"one/", 1 } }" for: "{ { "one", 1 } }" == "{ { "one", 1 } }" +ToStringGeneral.tests.cpp:: passed: Catch::Detail::stringify( map ) == "{ { /"abc/", 1 }, { /"def/", 2 }, { /"ghi/", 3 } }" for: "{ { "abc", 1 }, { "def", 2 }, { "ghi", 3 } }" +== +"{ { "abc", 1 }, { "def", 2 }, { "ghi", 3 } }" +ToStringPair.tests.cpp:: passed: ::Catch::Detail::stringify(value) == "{ 34, /"xyzzy/" }" for: "{ 34, "xyzzy" }" == "{ 34, "xyzzy" }" +ToStringPair.tests.cpp:: passed: ::Catch::Detail::stringify( value ) == "{ 34, /"xyzzy/" }" for: "{ 34, "xyzzy" }" == "{ 34, "xyzzy" }" +ToStringGeneral.tests.cpp:: passed: Catch::Detail::stringify( emptySet ) == "{ }" for: "{ }" == "{ }" +ToStringGeneral.tests.cpp:: passed: Catch::Detail::stringify( set ) == "{ /"one/" }" for: "{ "one" }" == "{ "one" }" +ToStringGeneral.tests.cpp:: passed: Catch::Detail::stringify( set ) == "{ /"abc/", /"def/", /"ghi/" }" for: "{ "abc", "def", "ghi" }" +== +"{ "abc", "def", "ghi" }" +ToStringPair.tests.cpp:: passed: ::Catch::Detail::stringify( pr ) == "{ { /"green/", 55 } }" for: "{ { "green", 55 } }" +== +"{ { "green", 55 } }" +Tricky.tests.cpp:: failed: std::string( "first" ) == "second" for: "first" == "second" +ToStringWhich.tests.cpp:: passed: ::Catch::Detail::stringify(streamable_range{}) == "op<<(streamable_range)" for: "op<<(streamable_range)" +== +"op<<(streamable_range)" +ToStringWhich.tests.cpp:: passed: ::Catch::Detail::stringify(stringmaker_range{}) == "stringmaker(streamable_range)" for: "stringmaker(streamable_range)" +== +"stringmaker(streamable_range)" +ToStringWhich.tests.cpp:: passed: ::Catch::Detail::stringify(just_range{}) == "{ 1, 2, 3, 4 }" for: "{ 1, 2, 3, 4 }" == "{ 1, 2, 3, 4 }" +ToStringWhich.tests.cpp:: passed: ::Catch::Detail::stringify(disabled_range{}) == "{ !!! }" for: "{ !!! }" == "{ !!! }" +ToStringWhich.tests.cpp:: passed: ::Catch::Detail::stringify( item ) == "StringMaker" for: "StringMaker" +== +"StringMaker" +ToStringWhich.tests.cpp:: passed: ::Catch::Detail::stringify( item ) == "StringMaker" for: "StringMaker" +== +"StringMaker" +ToStringWhich.tests.cpp:: passed: ::Catch::Detail::stringify(item) == "{ !!! }" for: "{ !!! }" == "{ !!! }" +ToStringWhich.tests.cpp:: passed: ::Catch::Detail::stringify( item ) == "operator<<( has_operator )" for: "operator<<( has_operator )" +== +"operator<<( has_operator )" +ToStringWhich.tests.cpp:: passed: ::Catch::Detail::stringify( item ) == "operator<<( has_template_operator )" for: "operator<<( has_template_operator )" +== +"operator<<( has_template_operator )" +ToStringWhich.tests.cpp:: passed: ::Catch::Detail::stringify( v ) == "{ StringMaker }" for: "{ StringMaker }" +== +"{ StringMaker }" +ToStringWhich.tests.cpp:: passed: ::Catch::Detail::stringify( v ) == "{ StringMaker }" for: "{ StringMaker }" +== +"{ StringMaker }" +ToStringWhich.tests.cpp:: passed: ::Catch::Detail::stringify( v ) == "{ operator<<( has_operator ) }" for: "{ operator<<( has_operator ) }" +== +"{ operator<<( has_operator ) }" +Exception.tests.cpp:: failed: unexpected exception with message: 'Why would you throw a std::string?' +Misc.tests.cpp:: passed: result == "/"wide load/"" for: ""wide load"" == ""wide load"" +Misc.tests.cpp:: passed: result == "/"wide load/"" for: ""wide load"" == ""wide load"" +Misc.tests.cpp:: passed: result == "/"wide load/"" for: ""wide load"" == ""wide load"" +Misc.tests.cpp:: passed: result == "/"wide load/"" for: ""wide load"" == ""wide load"" +EnumToString.tests.cpp:: passed: ::Catch::Detail::stringify(e0) == "E2/V0" for: "E2/V0" == "E2/V0" +EnumToString.tests.cpp:: passed: ::Catch::Detail::stringify(e1) == "E2/V1" for: "E2/V1" == "E2/V1" +EnumToString.tests.cpp:: passed: ::Catch::Detail::stringify(e3) == "Unknown enum value 10" for: "Unknown enum value 10" +== +"Unknown enum value 10" +EnumToString.tests.cpp:: passed: ::Catch::Detail::stringify(e0) == "0" for: "0" == "0" +EnumToString.tests.cpp:: passed: ::Catch::Detail::stringify(e1) == "1" for: "1" == "1" +EnumToString.tests.cpp:: passed: ::Catch::Detail::stringify(e0) == "E2{0}" for: "E2{0}" == "E2{0}" +EnumToString.tests.cpp:: passed: ::Catch::Detail::stringify(e1) == "E2{1}" for: "E2{1}" == "E2{1}" +EnumToString.tests.cpp:: passed: ::Catch::Detail::stringify(e0) == "0" for: "0" == "0" +EnumToString.tests.cpp:: passed: ::Catch::Detail::stringify(e1) == "1" for: "1" == "1" +ToStringTuple.tests.cpp:: passed: "{ }" == ::Catch::Detail::stringify(type{}) for: "{ }" == "{ }" +ToStringTuple.tests.cpp:: passed: "{ }" == ::Catch::Detail::stringify(value) for: "{ }" == "{ }" +ToStringTuple.tests.cpp:: passed: "1.2f" == ::Catch::Detail::stringify(float(1.2)) for: "1.2f" == "1.2f" +ToStringTuple.tests.cpp:: passed: "{ 1.2f, 0 }" == ::Catch::Detail::stringify(type{1.2f,0}) for: "{ 1.2f, 0 }" == "{ 1.2f, 0 }" +ToStringTuple.tests.cpp:: passed: "{ 0 }" == ::Catch::Detail::stringify(type{0}) for: "{ 0 }" == "{ 0 }" +ToStringTuple.tests.cpp:: passed: "{ 0, 42, /"Catch me/" }" == ::Catch::Detail::stringify(value) for: "{ 0, 42, "Catch me" }" +== +"{ 0, 42, "Catch me" }" +ToStringTuple.tests.cpp:: passed: "{ /"hello/", /"world/" }" == ::Catch::Detail::stringify(type{"hello","world"}) for: "{ "hello", "world" }" +== +"{ "hello", "world" }" +ToStringTuple.tests.cpp:: passed: "{ { 42 }, { }, 1.2f }" == ::Catch::Detail::stringify(value) for: "{ { 42 }, { }, 1.2f }" +== +"{ { 42 }, { }, 1.2f }" +ToStringVector.tests.cpp:: passed: ::Catch::Detail::stringify(v) == "{ }" for: "{ }" == "{ }" +ToStringVector.tests.cpp:: passed: ::Catch::Detail::stringify(v) == "{ { /"hello/" }, { /"world/" } }" for: "{ { "hello" }, { "world" } }" +== +"{ { "hello" }, { "world" } }" +ToStringVector.tests.cpp:: passed: ::Catch::Detail::stringify(bools) == "{ }" for: "{ }" == "{ }" +ToStringVector.tests.cpp:: passed: ::Catch::Detail::stringify(bools) == "{ true }" for: "{ true }" == "{ true }" +ToStringVector.tests.cpp:: passed: ::Catch::Detail::stringify(bools) == "{ true, false }" for: "{ true, false }" == "{ true, false }" +ToStringVector.tests.cpp:: passed: ::Catch::Detail::stringify(vv) == "{ }" for: "{ }" == "{ }" +ToStringVector.tests.cpp:: passed: ::Catch::Detail::stringify(vv) == "{ 42 }" for: "{ 42 }" == "{ 42 }" +ToStringVector.tests.cpp:: passed: ::Catch::Detail::stringify(vv) == "{ 42, 250 }" for: "{ 42, 250 }" == "{ 42, 250 }" +ToStringVector.tests.cpp:: passed: ::Catch::Detail::stringify(vv) == "{ }" for: "{ }" == "{ }" +ToStringVector.tests.cpp:: passed: ::Catch::Detail::stringify(vv) == "{ 42 }" for: "{ 42 }" == "{ 42 }" +ToStringVector.tests.cpp:: passed: ::Catch::Detail::stringify(vv) == "{ 42, 250 }" for: "{ 42, 250 }" == "{ 42, 250 }" +ToStringVector.tests.cpp:: passed: ::Catch::Detail::stringify(vv) == "{ }" for: "{ }" == "{ }" +ToStringVector.tests.cpp:: passed: ::Catch::Detail::stringify(vv) == "{ /"hello/" }" for: "{ "hello" }" == "{ "hello" }" +ToStringVector.tests.cpp:: passed: ::Catch::Detail::stringify(vv) == "{ /"hello/", /"world/" }" for: "{ "hello", "world" }" +== +"{ "hello", "world" }" +Misc.tests.cpp:: passed: v.size() == 5 for: 5 == 5 +Misc.tests.cpp:: passed: v.capacity() >= 5 for: 5 >= 5 +Misc.tests.cpp:: passed: v.size() == 10 for: 10 == 10 +Misc.tests.cpp:: passed: v.capacity() >= 10 for: 10 >= 10 +Misc.tests.cpp:: passed: v.size() == 5 for: 5 == 5 +Misc.tests.cpp:: passed: v.capacity() >= 5 for: 5 >= 5 +Misc.tests.cpp:: passed: v.size() == 0 for: 0 == 0 +Misc.tests.cpp:: passed: v.capacity() >= 5 for: 5 >= 5 +Misc.tests.cpp:: passed: v.capacity() == 0 for: 0 == 0 +Misc.tests.cpp:: passed: v.size() == 5 for: 5 == 5 +Misc.tests.cpp:: passed: v.capacity() >= 5 for: 5 >= 5 +Misc.tests.cpp:: passed: v.size() == 5 for: 5 == 5 +Misc.tests.cpp:: passed: v.capacity() >= 10 for: 10 >= 10 +Misc.tests.cpp:: passed: v.size() == 5 for: 5 == 5 +Misc.tests.cpp:: passed: v.capacity() >= 5 for: 5 >= 5 +Misc.tests.cpp:: passed: v.size() == 5 for: 5 == 5 +Misc.tests.cpp:: passed: v.capacity() >= 5 for: 5 >= 5 +Misc.tests.cpp:: passed: +Misc.tests.cpp:: passed: +Failed 62 test cases, failed 122 assertions. + diff --git a/src/third_party/cppcodec/test/catch/projects/SelfTest/Baselines/console.std.approved.txt b/src/third_party/cppcodec/test/catch/projects/SelfTest/Baselines/console.std.approved.txt new file mode 100644 index 0000000000..4c8b554053 --- /dev/null +++ b/src/third_party/cppcodec/test/catch/projects/SelfTest/Baselines/console.std.approved.txt @@ -0,0 +1,1101 @@ + +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + is a host application. +Run with -? for options + +------------------------------------------------------------------------------- +#748 - captures with unexpected exceptions + outside assertions +------------------------------------------------------------------------------- +Exception.tests.cpp: +............................................................................... + +Exception.tests.cpp:: FAILED: +due to unexpected exception with messages: + answer := 42 + expected exception + +------------------------------------------------------------------------------- +#748 - captures with unexpected exceptions + inside REQUIRE_NOTHROW +------------------------------------------------------------------------------- +Exception.tests.cpp: +............................................................................... + +Exception.tests.cpp:: FAILED: + REQUIRE_NOTHROW( thisThrows() ) +due to unexpected exception with messages: + answer := 42 + expected exception + +------------------------------------------------------------------------------- +#835 -- errno should not be touched by Catch +------------------------------------------------------------------------------- +Misc.tests.cpp: +............................................................................... + +Misc.tests.cpp:: FAILED: + CHECK( f() == 0 ) +with expansion: + 1 == 0 + +------------------------------------------------------------------------------- +'Not' checks that should fail +------------------------------------------------------------------------------- +Condition.tests.cpp: +............................................................................... + +Condition.tests.cpp:: FAILED: + CHECK( false != false ) + +Condition.tests.cpp:: FAILED: + CHECK( true != true ) + +Condition.tests.cpp:: FAILED: + CHECK( !true ) +with expansion: + false + +Condition.tests.cpp:: FAILED: + CHECK_FALSE( true ) +with expansion: + !true + +Condition.tests.cpp:: FAILED: + CHECK( !trueValue ) +with expansion: + false + +Condition.tests.cpp:: FAILED: + CHECK_FALSE( trueValue ) +with expansion: + !true + +Condition.tests.cpp:: FAILED: + CHECK( !(1 == 1) ) +with expansion: + false + +Condition.tests.cpp:: FAILED: + CHECK_FALSE( 1 == 1 ) + +------------------------------------------------------------------------------- +A METHOD_AS_TEST_CASE based test run that fails +------------------------------------------------------------------------------- +Class.tests.cpp: +............................................................................... + +Class.tests.cpp:: FAILED: + REQUIRE( s == "world" ) +with expansion: + "hello" == "world" + +------------------------------------------------------------------------------- +A TEST_CASE_METHOD based test run that fails +------------------------------------------------------------------------------- +Class.tests.cpp: +............................................................................... + +Class.tests.cpp:: FAILED: + REQUIRE( m_a == 2 ) +with expansion: + 1 == 2 + +------------------------------------------------------------------------------- +A couple of nested sections followed by a failure +------------------------------------------------------------------------------- +Misc.tests.cpp: +............................................................................... + +Misc.tests.cpp:: FAILED: +explicitly with message: + to infinity and beyond + +------------------------------------------------------------------------------- +A failing expression with a non streamable type is still captured +------------------------------------------------------------------------------- +Tricky.tests.cpp: +............................................................................... + +Tricky.tests.cpp:: FAILED: + CHECK( &o1 == &o2 ) +with expansion: + 0x == 0x + +Tricky.tests.cpp:: FAILED: + CHECK( o1 == o2 ) +with expansion: + {?} == {?} + +------------------------------------------------------------------------------- +An unchecked exception reports the line of the last assertion +------------------------------------------------------------------------------- +Exception.tests.cpp: +............................................................................... + +Exception.tests.cpp:: FAILED: + {Unknown expression after the reported line} +due to unexpected exception with message: + unexpected exception + +------------------------------------------------------------------------------- +Contains string matcher +------------------------------------------------------------------------------- +Matchers.tests.cpp: +............................................................................... + +Matchers.tests.cpp:: FAILED: + CHECK_THAT( testStringForMatching(), Contains("not there", Catch::CaseSensitive::No) ) +with expansion: + "this string contains 'abc' as a substring" contains: "not there" (case + insensitive) + +Matchers.tests.cpp:: FAILED: + CHECK_THAT( testStringForMatching(), Contains("STRING") ) +with expansion: + "this string contains 'abc' as a substring" contains: "STRING" + +------------------------------------------------------------------------------- +Custom exceptions can be translated when testing for nothrow +------------------------------------------------------------------------------- +Exception.tests.cpp: +............................................................................... + +Exception.tests.cpp:: FAILED: + REQUIRE_NOTHROW( throwCustom() ) +due to unexpected exception with message: + custom exception - not std + +------------------------------------------------------------------------------- +Custom exceptions can be translated when testing for throwing as something else +------------------------------------------------------------------------------- +Exception.tests.cpp: +............................................................................... + +Exception.tests.cpp:: FAILED: + REQUIRE_THROWS_AS( throwCustom(), std::exception ) +due to unexpected exception with message: + custom exception - not std + +------------------------------------------------------------------------------- +Custom std-exceptions can be custom translated +------------------------------------------------------------------------------- +Exception.tests.cpp: +............................................................................... + +Exception.tests.cpp:: FAILED: +due to unexpected exception with message: + custom std exception + +------------------------------------------------------------------------------- +EndsWith string matcher +------------------------------------------------------------------------------- +Matchers.tests.cpp: +............................................................................... + +Matchers.tests.cpp:: FAILED: + CHECK_THAT( testStringForMatching(), EndsWith("Substring") ) +with expansion: + "this string contains 'abc' as a substring" ends with: "Substring" + +Matchers.tests.cpp:: FAILED: + CHECK_THAT( testStringForMatching(), EndsWith("this", Catch::CaseSensitive::No) ) +with expansion: + "this string contains 'abc' as a substring" ends with: "this" (case + insensitive) + +------------------------------------------------------------------------------- +Equality checks that should fail +------------------------------------------------------------------------------- +Condition.tests.cpp: +............................................................................... + +Condition.tests.cpp:: FAILED: + CHECK( data.int_seven == 6 ) +with expansion: + 7 == 6 + +Condition.tests.cpp:: FAILED: + CHECK( data.int_seven == 8 ) +with expansion: + 7 == 8 + +Condition.tests.cpp:: FAILED: + CHECK( data.int_seven == 0 ) +with expansion: + 7 == 0 + +Condition.tests.cpp:: FAILED: + CHECK( data.float_nine_point_one == Approx( 9.11f ) ) +with expansion: + 9.1f == Approx( 9.1099996567 ) + +Condition.tests.cpp:: FAILED: + CHECK( data.float_nine_point_one == Approx( 9.0f ) ) +with expansion: + 9.1f == Approx( 9.0 ) + +Condition.tests.cpp:: FAILED: + CHECK( data.float_nine_point_one == Approx( 1 ) ) +with expansion: + 9.1f == Approx( 1.0 ) + +Condition.tests.cpp:: FAILED: + CHECK( data.float_nine_point_one == Approx( 0 ) ) +with expansion: + 9.1f == Approx( 0.0 ) + +Condition.tests.cpp:: FAILED: + CHECK( data.double_pi == Approx( 3.1415 ) ) +with expansion: + 3.1415926535 == Approx( 3.1415 ) + +Condition.tests.cpp:: FAILED: + CHECK( data.str_hello == "goodbye" ) +with expansion: + "hello" == "goodbye" + +Condition.tests.cpp:: FAILED: + CHECK( data.str_hello == "hell" ) +with expansion: + "hello" == "hell" + +Condition.tests.cpp:: FAILED: + CHECK( data.str_hello == "hello1" ) +with expansion: + "hello" == "hello1" + +Condition.tests.cpp:: FAILED: + CHECK( data.str_hello.size() == 6 ) +with expansion: + 5 == 6 + +Condition.tests.cpp:: FAILED: + CHECK( x == Approx( 1.301 ) ) +with expansion: + 1.3 == Approx( 1.301 ) + +------------------------------------------------------------------------------- +Equals string matcher +------------------------------------------------------------------------------- +Matchers.tests.cpp: +............................................................................... + +Matchers.tests.cpp:: FAILED: + CHECK_THAT( testStringForMatching(), Equals("this string contains 'ABC' as a substring") ) +with expansion: + "this string contains 'abc' as a substring" equals: "this string contains + 'ABC' as a substring" + +Matchers.tests.cpp:: FAILED: + CHECK_THAT( testStringForMatching(), Equals("something else", Catch::CaseSensitive::No) ) +with expansion: + "this string contains 'abc' as a substring" equals: "something else" (case + insensitive) + +------------------------------------------------------------------------------- +Exception matchers that fail + No exception +------------------------------------------------------------------------------- +Matchers.tests.cpp: +............................................................................... + +Matchers.tests.cpp:: FAILED: + CHECK_THROWS_MATCHES( doesNotThrow(), SpecialException, ExceptionMatcher{1} ) +because no exception was thrown where one was expected: + +Matchers.tests.cpp:: FAILED: + REQUIRE_THROWS_MATCHES( doesNotThrow(), SpecialException, ExceptionMatcher{1} ) +because no exception was thrown where one was expected: + +------------------------------------------------------------------------------- +Exception matchers that fail + Type mismatch +------------------------------------------------------------------------------- +Matchers.tests.cpp: +............................................................................... + +Matchers.tests.cpp:: FAILED: + CHECK_THROWS_MATCHES( throwsAsInt(1), SpecialException, ExceptionMatcher{1} ) +due to unexpected exception with message: + Unknown exception + +Matchers.tests.cpp:: FAILED: + REQUIRE_THROWS_MATCHES( throwsAsInt(1), SpecialException, ExceptionMatcher{1} ) +due to unexpected exception with message: + Unknown exception + +------------------------------------------------------------------------------- +Exception matchers that fail + Contents are wrong +------------------------------------------------------------------------------- +Matchers.tests.cpp: +............................................................................... + +Matchers.tests.cpp:: FAILED: + CHECK_THROWS_MATCHES( throws(3), SpecialException, ExceptionMatcher{1} ) +with expansion: + SpecialException::what special exception has value of 1 + +Matchers.tests.cpp:: FAILED: + REQUIRE_THROWS_MATCHES( throws(4), SpecialException, ExceptionMatcher{1} ) +with expansion: + SpecialException::what special exception has value of 1 + +------------------------------------------------------------------------------- +Expected exceptions that don't throw or unexpected exceptions fail the test +------------------------------------------------------------------------------- +Exception.tests.cpp: +............................................................................... + +Exception.tests.cpp:: FAILED: + CHECK_THROWS_AS( thisThrows(), std::string ) +due to unexpected exception with message: + expected exception + +Exception.tests.cpp:: FAILED: + CHECK_THROWS_AS( thisDoesntThrow(), std::domain_error ) +because no exception was thrown where one was expected: + +Exception.tests.cpp:: FAILED: + CHECK_NOTHROW( thisThrows() ) +due to unexpected exception with message: + expected exception + +------------------------------------------------------------------------------- +FAIL aborts the test +------------------------------------------------------------------------------- +Message.tests.cpp: +............................................................................... + +Message.tests.cpp:: FAILED: +explicitly with message: + This is a failure + +------------------------------------------------------------------------------- +FAIL does not require an argument +------------------------------------------------------------------------------- +Message.tests.cpp: +............................................................................... + +Message.tests.cpp:: FAILED: + +------------------------------------------------------------------------------- +FAIL_CHECK does not abort the test +------------------------------------------------------------------------------- +Message.tests.cpp: +............................................................................... + +Message.tests.cpp:: FAILED: +explicitly with message: + This is a failure + +Message.tests.cpp:: +warning: + This message appears in the output + +------------------------------------------------------------------------------- +INFO and WARN do not abort tests +------------------------------------------------------------------------------- +Message.tests.cpp: +............................................................................... + +Message.tests.cpp:: +warning: + this is a warning + +------------------------------------------------------------------------------- +INFO gets logged on failure +------------------------------------------------------------------------------- +Message.tests.cpp: +............................................................................... + +Message.tests.cpp:: FAILED: + REQUIRE( a == 1 ) +with expansion: + 2 == 1 +with messages: + this message should be logged + so should this + +------------------------------------------------------------------------------- +INFO gets logged on failure, even if captured before successful assertions +------------------------------------------------------------------------------- +Message.tests.cpp: +............................................................................... + +Message.tests.cpp:: FAILED: + CHECK( a == 1 ) +with expansion: + 2 == 1 +with messages: + this message may be logged later + this message should be logged + +Message.tests.cpp:: FAILED: + CHECK( a == 0 ) +with expansion: + 2 == 0 +with messages: + this message may be logged later + this message should be logged + and this, but later + +------------------------------------------------------------------------------- +INFO is reset for each loop +------------------------------------------------------------------------------- +Message.tests.cpp: +............................................................................... + +Message.tests.cpp:: FAILED: + REQUIRE( i < 10 ) +with expansion: + 10 < 10 +with messages: + current counter 10 + i := 10 + +------------------------------------------------------------------------------- +Inequality checks that should fail +------------------------------------------------------------------------------- +Condition.tests.cpp: +............................................................................... + +Condition.tests.cpp:: FAILED: + CHECK( data.int_seven != 7 ) +with expansion: + 7 != 7 + +Condition.tests.cpp:: FAILED: + CHECK( data.float_nine_point_one != Approx( 9.1f ) ) +with expansion: + 9.1f != Approx( 9.1000003815 ) + +Condition.tests.cpp:: FAILED: + CHECK( data.double_pi != Approx( 3.1415926535 ) ) +with expansion: + 3.1415926535 != Approx( 3.1415926535 ) + +Condition.tests.cpp:: FAILED: + CHECK( data.str_hello != "hello" ) +with expansion: + "hello" != "hello" + +Condition.tests.cpp:: FAILED: + CHECK( data.str_hello.size() != 5 ) +with expansion: + 5 != 5 + +------------------------------------------------------------------------------- +Matchers can be composed with both && and || - failing +------------------------------------------------------------------------------- +Matchers.tests.cpp: +............................................................................... + +Matchers.tests.cpp:: FAILED: + CHECK_THAT( testStringForMatching(), (Contains("string") || Contains("different")) && Contains("random") ) +with expansion: + "this string contains 'abc' as a substring" ( ( contains: "string" or + contains: "different" ) and contains: "random" ) + +------------------------------------------------------------------------------- +Matchers can be negated (Not) with the ! operator - failing +------------------------------------------------------------------------------- +Matchers.tests.cpp: +............................................................................... + +Matchers.tests.cpp:: FAILED: + CHECK_THAT( testStringForMatching(), !Contains("substring") ) +with expansion: + "this string contains 'abc' as a substring" not contains: "substring" + +------------------------------------------------------------------------------- +Mismatching exception messages failing the test +------------------------------------------------------------------------------- +Exception.tests.cpp: +............................................................................... + +Exception.tests.cpp:: FAILED: + REQUIRE_THROWS_WITH( thisThrows(), "should fail" ) +with expansion: + "expected exception" equals: "should fail" + +------------------------------------------------------------------------------- +Nice descriptive name +------------------------------------------------------------------------------- +Misc.tests.cpp: +............................................................................... + +Misc.tests.cpp:: +warning: + This one ran + +------------------------------------------------------------------------------- +Non-std exceptions can be translated +------------------------------------------------------------------------------- +Exception.tests.cpp: +............................................................................... + +Exception.tests.cpp:: FAILED: +due to unexpected exception with message: + custom exception + +------------------------------------------------------------------------------- +Ordering comparison checks that should fail +------------------------------------------------------------------------------- +Condition.tests.cpp: +............................................................................... + +Condition.tests.cpp:: FAILED: + CHECK( data.int_seven > 7 ) +with expansion: + 7 > 7 + +Condition.tests.cpp:: FAILED: + CHECK( data.int_seven < 7 ) +with expansion: + 7 < 7 + +Condition.tests.cpp:: FAILED: + CHECK( data.int_seven > 8 ) +with expansion: + 7 > 8 + +Condition.tests.cpp:: FAILED: + CHECK( data.int_seven < 6 ) +with expansion: + 7 < 6 + +Condition.tests.cpp:: FAILED: + CHECK( data.int_seven < 0 ) +with expansion: + 7 < 0 + +Condition.tests.cpp:: FAILED: + CHECK( data.int_seven < -1 ) +with expansion: + 7 < -1 + +Condition.tests.cpp:: FAILED: + CHECK( data.int_seven >= 8 ) +with expansion: + 7 >= 8 + +Condition.tests.cpp:: FAILED: + CHECK( data.int_seven <= 6 ) +with expansion: + 7 <= 6 + +Condition.tests.cpp:: FAILED: + CHECK( data.float_nine_point_one < 9 ) +with expansion: + 9.1f < 9 + +Condition.tests.cpp:: FAILED: + CHECK( data.float_nine_point_one > 10 ) +with expansion: + 9.1f > 10 + +Condition.tests.cpp:: FAILED: + CHECK( data.float_nine_point_one > 9.2 ) +with expansion: + 9.1f > 9.2 + +Condition.tests.cpp:: FAILED: + CHECK( data.str_hello > "hello" ) +with expansion: + "hello" > "hello" + +Condition.tests.cpp:: FAILED: + CHECK( data.str_hello < "hello" ) +with expansion: + "hello" < "hello" + +Condition.tests.cpp:: FAILED: + CHECK( data.str_hello > "hellp" ) +with expansion: + "hello" > "hellp" + +Condition.tests.cpp:: FAILED: + CHECK( data.str_hello > "z" ) +with expansion: + "hello" > "z" + +Condition.tests.cpp:: FAILED: + CHECK( data.str_hello < "hellm" ) +with expansion: + "hello" < "hellm" + +Condition.tests.cpp:: FAILED: + CHECK( data.str_hello < "a" ) +with expansion: + "hello" < "a" + +Condition.tests.cpp:: FAILED: + CHECK( data.str_hello >= "z" ) +with expansion: + "hello" >= "z" + +Condition.tests.cpp:: FAILED: + CHECK( data.str_hello <= "a" ) +with expansion: + "hello" <= "a" + +------------------------------------------------------------------------------- +Output from all sections is reported + one +------------------------------------------------------------------------------- +Message.tests.cpp: +............................................................................... + +Message.tests.cpp:: FAILED: +explicitly with message: + Message from section one + +------------------------------------------------------------------------------- +Output from all sections is reported + two +------------------------------------------------------------------------------- +Message.tests.cpp: +............................................................................... + +Message.tests.cpp:: FAILED: +explicitly with message: + Message from section two + +------------------------------------------------------------------------------- +Reconstruction should be based on stringification: #914 +------------------------------------------------------------------------------- +Decomposition.tests.cpp: +............................................................................... + +Decomposition.tests.cpp:: FAILED: + CHECK( truthy(false) ) +with expansion: + Hey, its truthy! + +------------------------------------------------------------------------------- +Regex string matcher +------------------------------------------------------------------------------- +Matchers.tests.cpp: +............................................................................... + +Matchers.tests.cpp:: FAILED: + CHECK_THAT( testStringForMatching(), Matches("this STRING contains 'abc' as a substring") ) +with expansion: + "this string contains 'abc' as a substring" matches "this STRING contains + 'abc' as a substring" case sensitively + +Matchers.tests.cpp:: FAILED: + CHECK_THAT( testStringForMatching(), Matches("contains 'abc' as a substring") ) +with expansion: + "this string contains 'abc' as a substring" matches "contains 'abc' as a + substring" case sensitively + +Matchers.tests.cpp:: FAILED: + CHECK_THAT( testStringForMatching(), Matches("this string contains 'abc' as a") ) +with expansion: + "this string contains 'abc' as a substring" matches "this string contains + 'abc' as a" case sensitively + +A string sent directly to stdout +A string sent directly to stderr +A string sent to stderr via clog +Message from section one +Message from section two +------------------------------------------------------------------------------- +StartsWith string matcher +------------------------------------------------------------------------------- +Matchers.tests.cpp: +............................................................................... + +Matchers.tests.cpp:: FAILED: + CHECK_THAT( testStringForMatching(), StartsWith("This String") ) +with expansion: + "this string contains 'abc' as a substring" starts with: "This String" + +Matchers.tests.cpp:: FAILED: + CHECK_THAT( testStringForMatching(), StartsWith("string", Catch::CaseSensitive::No) ) +with expansion: + "this string contains 'abc' as a substring" starts with: "string" (case + insensitive) + +------------------------------------------------------------------------------- +Tabs and newlines show in output +------------------------------------------------------------------------------- +Misc.tests.cpp: +............................................................................... + +Misc.tests.cpp:: FAILED: + CHECK( s1 == s2 ) +with expansion: + "if ($b == 10) { + $a = 20; + }" + == + "if ($b == 10) { + $a = 20; + } + " + +------------------------------------------------------------------------------- +Thrown string literals are translated +------------------------------------------------------------------------------- +Exception.tests.cpp: +............................................................................... + +Exception.tests.cpp:: FAILED: +due to unexpected exception with message: + For some reason someone is throwing a string literal! + +------------------------------------------------------------------------------- +Unexpected exceptions can be translated +------------------------------------------------------------------------------- +Exception.tests.cpp: +............................................................................... + +Exception.tests.cpp:: FAILED: +due to unexpected exception with message: + 3.14 + +------------------------------------------------------------------------------- +Vector matchers that fail + Contains (element) +------------------------------------------------------------------------------- +Matchers.tests.cpp: +............................................................................... + +Matchers.tests.cpp:: FAILED: + CHECK_THAT( v, VectorContains(-1) ) +with expansion: + { 1, 2, 3 } Contains: -1 + +Matchers.tests.cpp:: FAILED: + CHECK_THAT( empty, VectorContains(1) ) +with expansion: + { } Contains: 1 + +------------------------------------------------------------------------------- +Vector matchers that fail + Contains (vector) +------------------------------------------------------------------------------- +Matchers.tests.cpp: +............................................................................... + +Matchers.tests.cpp:: FAILED: + CHECK_THAT( empty, Contains(v) ) +with expansion: + { } Contains: { 1, 2, 3 } + +Matchers.tests.cpp:: FAILED: + CHECK_THAT( v, Contains(v2) ) +with expansion: + { 1, 2, 3 } Contains: { 1, 2, 4 } + +------------------------------------------------------------------------------- +Vector matchers that fail + Equals +------------------------------------------------------------------------------- +Matchers.tests.cpp: +............................................................................... + +Matchers.tests.cpp:: FAILED: + CHECK_THAT( v, Equals(v2) ) +with expansion: + { 1, 2, 3 } Equals: { 1, 2 } + +Matchers.tests.cpp:: FAILED: + CHECK_THAT( v2, Equals(v) ) +with expansion: + { 1, 2 } Equals: { 1, 2, 3 } + +Matchers.tests.cpp:: FAILED: + CHECK_THAT( empty, Equals(v) ) +with expansion: + { } Equals: { 1, 2, 3 } + +Matchers.tests.cpp:: FAILED: + CHECK_THAT( v, Equals(empty) ) +with expansion: + { 1, 2, 3 } Equals: { } + +------------------------------------------------------------------------------- +Vector matchers that fail + UnorderedEquals +------------------------------------------------------------------------------- +Matchers.tests.cpp: +............................................................................... + +Matchers.tests.cpp:: FAILED: + CHECK_THAT( v, UnorderedEquals(empty) ) +with expansion: + { 1, 2, 3 } UnorderedEquals: { } + +Matchers.tests.cpp:: FAILED: + CHECK_THAT( empty, UnorderedEquals(v) ) +with expansion: + { } UnorderedEquals: { 1, 2, 3 } + +Matchers.tests.cpp:: FAILED: + CHECK_THAT( permuted, UnorderedEquals(v) ) +with expansion: + { 1, 3 } UnorderedEquals: { 1, 2, 3 } + +Matchers.tests.cpp:: FAILED: + CHECK_THAT( permuted, UnorderedEquals(v) ) +with expansion: + { 3, 1 } UnorderedEquals: { 1, 2, 3 } + +------------------------------------------------------------------------------- +When unchecked exceptions are thrown directly they are always failures +------------------------------------------------------------------------------- +Exception.tests.cpp: +............................................................................... + +Exception.tests.cpp:: FAILED: +due to unexpected exception with message: + unexpected exception + +------------------------------------------------------------------------------- +When unchecked exceptions are thrown during a CHECK the test should continue +------------------------------------------------------------------------------- +Exception.tests.cpp: +............................................................................... + +Exception.tests.cpp:: FAILED: + CHECK( thisThrows() == 0 ) +due to unexpected exception with message: + expected exception + +------------------------------------------------------------------------------- +When unchecked exceptions are thrown during a REQUIRE the test should abort +fail +------------------------------------------------------------------------------- +Exception.tests.cpp: +............................................................................... + +Exception.tests.cpp:: FAILED: + REQUIRE( thisThrows() == 0 ) +due to unexpected exception with message: + expected exception + +------------------------------------------------------------------------------- +When unchecked exceptions are thrown from functions they are always failures +------------------------------------------------------------------------------- +Exception.tests.cpp: +............................................................................... + +Exception.tests.cpp:: FAILED: + CHECK( thisThrows() == 0 ) +due to unexpected exception with message: + expected exception + +------------------------------------------------------------------------------- +When unchecked exceptions are thrown from sections they are always failures + section name +------------------------------------------------------------------------------- +Exception.tests.cpp: +............................................................................... + +Exception.tests.cpp:: FAILED: +due to unexpected exception with message: + unexpected exception + +------------------------------------------------------------------------------- +Where the LHS is not a simple value +------------------------------------------------------------------------------- +Tricky.tests.cpp: +............................................................................... + +Tricky.tests.cpp:: +warning: + Uncomment the code in this test to check that it gives a sensible compiler + error + +------------------------------------------------------------------------------- +Where there is more to the expression after the RHS +------------------------------------------------------------------------------- +Tricky.tests.cpp: +............................................................................... + +Tricky.tests.cpp:: +warning: + Uncomment the code in this test to check that it gives a sensible compiler + error + +------------------------------------------------------------------------------- +checkedElse, failing +------------------------------------------------------------------------------- +Misc.tests.cpp: +............................................................................... + +Misc.tests.cpp:: FAILED: + CHECKED_ELSE( flag ) +with expansion: + false + +Misc.tests.cpp:: FAILED: + REQUIRE( testCheckedElse( false ) ) +with expansion: + false + +------------------------------------------------------------------------------- +checkedIf, failing +------------------------------------------------------------------------------- +Misc.tests.cpp: +............................................................................... + +Misc.tests.cpp:: FAILED: + CHECKED_IF( flag ) +with expansion: + false + +Misc.tests.cpp:: FAILED: + REQUIRE( testCheckedIf( false ) ) +with expansion: + false + +loose text artifact +------------------------------------------------------------------------------- +just failure +------------------------------------------------------------------------------- +Message.tests.cpp: +............................................................................... + +Message.tests.cpp:: FAILED: +explicitly with message: + Previous info should not be seen + +------------------------------------------------------------------------------- +looped SECTION tests + b is currently: 0 +------------------------------------------------------------------------------- +Misc.tests.cpp: +............................................................................... + +Misc.tests.cpp:: FAILED: + CHECK( b > a ) +with expansion: + 0 > 1 + +------------------------------------------------------------------------------- +looped SECTION tests + b is currently: 1 +------------------------------------------------------------------------------- +Misc.tests.cpp: +............................................................................... + +Misc.tests.cpp:: FAILED: + CHECK( b > a ) +with expansion: + 1 > 1 + +------------------------------------------------------------------------------- +looped tests +------------------------------------------------------------------------------- +Misc.tests.cpp: +............................................................................... + +Misc.tests.cpp:: FAILED: + CHECK( ( fib[i] % 2 ) == 0 ) +with expansion: + 1 == 0 +with message: + Testing if fib[0] (1) is even + +Misc.tests.cpp:: FAILED: + CHECK( ( fib[i] % 2 ) == 0 ) +with expansion: + 1 == 0 +with message: + Testing if fib[1] (1) is even + +Misc.tests.cpp:: FAILED: + CHECK( ( fib[i] % 2 ) == 0 ) +with expansion: + 1 == 0 +with message: + Testing if fib[3] (3) is even + +Misc.tests.cpp:: FAILED: + CHECK( ( fib[i] % 2 ) == 0 ) +with expansion: + 1 == 0 +with message: + Testing if fib[4] (5) is even + +Misc.tests.cpp:: FAILED: + CHECK( ( fib[i] % 2 ) == 0 ) +with expansion: + 1 == 0 +with message: + Testing if fib[6] (13) is even + +Misc.tests.cpp:: FAILED: + CHECK( ( fib[i] % 2 ) == 0 ) +with expansion: + 1 == 0 +with message: + Testing if fib[7] (21) is even + +------------------------------------------------------------------------------- +more nested SECTION tests + doesn't equal + equal +------------------------------------------------------------------------------- +Misc.tests.cpp: +............................................................................... + +Misc.tests.cpp:: FAILED: + REQUIRE( a == b ) +with expansion: + 1 == 2 + +------------------------------------------------------------------------------- +send a single char to INFO +------------------------------------------------------------------------------- +Misc.tests.cpp: +............................................................................... + +Misc.tests.cpp:: FAILED: + REQUIRE( false ) +with message: + 3 + +------------------------------------------------------------------------------- +sends information to INFO +------------------------------------------------------------------------------- +Message.tests.cpp: +............................................................................... + +Message.tests.cpp:: FAILED: + REQUIRE( false ) +with messages: + hi + i := 7 + +------------------------------------------------------------------------------- +string literals of different sizes can be compared +------------------------------------------------------------------------------- +Tricky.tests.cpp: +............................................................................... + +Tricky.tests.cpp:: FAILED: + REQUIRE( std::string( "first" ) == "second" ) +with expansion: + "first" == "second" + +------------------------------------------------------------------------------- +thrown std::strings are translated +------------------------------------------------------------------------------- +Exception.tests.cpp: +............................................................................... + +Exception.tests.cpp:: FAILED: +due to unexpected exception with message: + Why would you throw a std::string? + +=============================================================================== +test cases: 208 | 155 passed | 49 failed | 4 failed as expected +assertions: 1081 | 952 passed | 108 failed | 21 failed as expected + diff --git a/src/third_party/cppcodec/test/catch/projects/SelfTest/Baselines/console.sw.approved.txt b/src/third_party/cppcodec/test/catch/projects/SelfTest/Baselines/console.sw.approved.txt new file mode 100644 index 0000000000..533fba1551 --- /dev/null +++ b/src/third_party/cppcodec/test/catch/projects/SelfTest/Baselines/console.sw.approved.txt @@ -0,0 +1,9157 @@ + +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + is a host application. +Run with -? for options + +------------------------------------------------------------------------------- +# A test name that starts with a # +------------------------------------------------------------------------------- +Misc.tests.cpp: +............................................................................... + +Misc.tests.cpp:: +PASSED: +with message: + yay + +------------------------------------------------------------------------------- +#1005: Comparing pointer to int and long (NULL can be either on various + systems) +------------------------------------------------------------------------------- +Decomposition.tests.cpp: +............................................................................... + +Decomposition.tests.cpp:: +PASSED: + REQUIRE( fptr == 0 ) +with expansion: + 0 == 0 + +Decomposition.tests.cpp:: +PASSED: + REQUIRE( fptr == 0l ) +with expansion: + 0 == 0 + +------------------------------------------------------------------------------- +#1027 +------------------------------------------------------------------------------- +Compilation.tests.cpp: +............................................................................... + +Compilation.tests.cpp:: +PASSED: + REQUIRE( y.v == 0 ) +with expansion: + 0 == 0 + +Compilation.tests.cpp:: +PASSED: + REQUIRE( 0 == y.v ) +with expansion: + 0 == 0 + +------------------------------------------------------------------------------- +#1147 +------------------------------------------------------------------------------- +Compilation.tests.cpp: +............................................................................... + +Compilation.tests.cpp:: +PASSED: + REQUIRE( t1 == t2 ) +with expansion: + {?} == {?} + +Compilation.tests.cpp:: +PASSED: + REQUIRE( t1 != t2 ) +with expansion: + {?} != {?} + +Compilation.tests.cpp:: +PASSED: + REQUIRE( t1 < t2 ) +with expansion: + {?} < {?} + +Compilation.tests.cpp:: +PASSED: + REQUIRE( t1 > t2 ) +with expansion: + {?} > {?} + +Compilation.tests.cpp:: +PASSED: + REQUIRE( t1 <= t2 ) +with expansion: + {?} <= {?} + +Compilation.tests.cpp:: +PASSED: + REQUIRE( t1 >= t2 ) +with expansion: + {?} >= {?} + +------------------------------------------------------------------------------- +#1175 - Hidden Test +------------------------------------------------------------------------------- +Misc.tests.cpp: +............................................................................... + +Misc.tests.cpp:: +PASSED: + +------------------------------------------------------------------------------- +#1238 +------------------------------------------------------------------------------- +Compilation.tests.cpp: +............................................................................... + +Compilation.tests.cpp:: +PASSED: + REQUIRE( std::memcmp(uarr, "123", sizeof(uarr)) == 0 ) +with expansion: + 0 == 0 +with messages: + uarr := "123" + sarr := "456" + +Compilation.tests.cpp:: +PASSED: + REQUIRE( std::memcmp(sarr, "456", sizeof(sarr)) == 0 ) +with expansion: + 0 == 0 +with messages: + uarr := "123" + sarr := "456" + +------------------------------------------------------------------------------- +#1245 +------------------------------------------------------------------------------- +Compilation.tests.cpp: +............................................................................... + +Compilation.tests.cpp:: +PASSED: + +------------------------------------------------------------------------------- +#748 - captures with unexpected exceptions + outside assertions +------------------------------------------------------------------------------- +Exception.tests.cpp: +............................................................................... + +Exception.tests.cpp:: FAILED: +due to unexpected exception with messages: + answer := 42 + expected exception + +------------------------------------------------------------------------------- +#748 - captures with unexpected exceptions + inside REQUIRE_NOTHROW +------------------------------------------------------------------------------- +Exception.tests.cpp: +............................................................................... + +Exception.tests.cpp:: FAILED: + REQUIRE_NOTHROW( thisThrows() ) +due to unexpected exception with messages: + answer := 42 + expected exception + +------------------------------------------------------------------------------- +#748 - captures with unexpected exceptions + inside REQUIRE_THROWS +------------------------------------------------------------------------------- +Exception.tests.cpp: +............................................................................... + +Exception.tests.cpp:: +PASSED: + REQUIRE_THROWS( thisThrows() ) +with message: + answer := 42 + +------------------------------------------------------------------------------- +#809 +------------------------------------------------------------------------------- +Compilation.tests.cpp: +............................................................................... + +Compilation.tests.cpp:: +PASSED: + REQUIRE( 42 == f ) +with expansion: + 42 == {?} + +------------------------------------------------------------------------------- +#833 +------------------------------------------------------------------------------- +Compilation.tests.cpp: +............................................................................... + +Compilation.tests.cpp:: +PASSED: + REQUIRE( a == t ) +with expansion: + 3 == 3 + +Compilation.tests.cpp:: +PASSED: + CHECK( a == t ) +with expansion: + 3 == 3 + +Compilation.tests.cpp:: +PASSED: + REQUIRE_THROWS( throws_int(true) ) + +Compilation.tests.cpp:: +PASSED: + CHECK_THROWS_AS( throws_int(true), int ) + +Compilation.tests.cpp:: +PASSED: + REQUIRE_NOTHROW( throws_int(false) ) + +Compilation.tests.cpp:: +PASSED: + REQUIRE_THAT( "aaa", Catch::EndsWith("aaa") ) +with expansion: + "aaa" ends with: "aaa" + +Compilation.tests.cpp:: +PASSED: + REQUIRE( templated_tests(3) ) +with expansion: + true + +------------------------------------------------------------------------------- +#835 -- errno should not be touched by Catch +------------------------------------------------------------------------------- +Misc.tests.cpp: +............................................................................... + +Misc.tests.cpp:: FAILED: + CHECK( f() == 0 ) +with expansion: + 1 == 0 + +Misc.tests.cpp:: +PASSED: + REQUIRE( errno == 1 ) +with expansion: + 1 == 1 + +------------------------------------------------------------------------------- +#872 +------------------------------------------------------------------------------- +Compilation.tests.cpp: +............................................................................... + +Compilation.tests.cpp:: +PASSED: + REQUIRE( x == 4 ) +with expansion: + {?} == 4 +with message: + dummy := 0 + +------------------------------------------------------------------------------- +#961 -- Dynamically created sections should all be reported + Looped section 0 +------------------------------------------------------------------------------- +Misc.tests.cpp: +............................................................................... + +Misc.tests.cpp:: +PASSED: +with message: + Everything is OK + +------------------------------------------------------------------------------- +#961 -- Dynamically created sections should all be reported + Looped section 1 +------------------------------------------------------------------------------- +Misc.tests.cpp: +............................................................................... + +Misc.tests.cpp:: +PASSED: +with message: + Everything is OK + +------------------------------------------------------------------------------- +#961 -- Dynamically created sections should all be reported + Looped section 2 +------------------------------------------------------------------------------- +Misc.tests.cpp: +............................................................................... + +Misc.tests.cpp:: +PASSED: +with message: + Everything is OK + +------------------------------------------------------------------------------- +#961 -- Dynamically created sections should all be reported + Looped section 3 +------------------------------------------------------------------------------- +Misc.tests.cpp: +............................................................................... + +Misc.tests.cpp:: +PASSED: +with message: + Everything is OK + +------------------------------------------------------------------------------- +#961 -- Dynamically created sections should all be reported + Looped section 4 +------------------------------------------------------------------------------- +Misc.tests.cpp: +............................................................................... + +Misc.tests.cpp:: +PASSED: +with message: + Everything is OK + +------------------------------------------------------------------------------- +'Not' checks that should fail +------------------------------------------------------------------------------- +Condition.tests.cpp: +............................................................................... + +Condition.tests.cpp:: FAILED: + CHECK( false != false ) + +Condition.tests.cpp:: FAILED: + CHECK( true != true ) + +Condition.tests.cpp:: FAILED: + CHECK( !true ) +with expansion: + false + +Condition.tests.cpp:: FAILED: + CHECK_FALSE( true ) +with expansion: + !true + +Condition.tests.cpp:: FAILED: + CHECK( !trueValue ) +with expansion: + false + +Condition.tests.cpp:: FAILED: + CHECK_FALSE( trueValue ) +with expansion: + !true + +Condition.tests.cpp:: FAILED: + CHECK( !(1 == 1) ) +with expansion: + false + +Condition.tests.cpp:: FAILED: + CHECK_FALSE( 1 == 1 ) + +------------------------------------------------------------------------------- +'Not' checks that should succeed +------------------------------------------------------------------------------- +Condition.tests.cpp: +............................................................................... + +Condition.tests.cpp:: +PASSED: + REQUIRE( false == false ) + +Condition.tests.cpp:: +PASSED: + REQUIRE( true == true ) + +Condition.tests.cpp:: +PASSED: + REQUIRE( !false ) +with expansion: + true + +Condition.tests.cpp:: +PASSED: + REQUIRE_FALSE( false ) +with expansion: + !false + +Condition.tests.cpp:: +PASSED: + REQUIRE( !falseValue ) +with expansion: + true + +Condition.tests.cpp:: +PASSED: + REQUIRE_FALSE( falseValue ) +with expansion: + !false + +Condition.tests.cpp:: +PASSED: + REQUIRE( !(1 == 2) ) +with expansion: + true + +Condition.tests.cpp:: +PASSED: + REQUIRE_FALSE( 1 == 2 ) + +------------------------------------------------------------------------------- +(unimplemented) static bools can be evaluated + compare to true +------------------------------------------------------------------------------- +Tricky.tests.cpp: +............................................................................... + +Tricky.tests.cpp:: +PASSED: + REQUIRE( is_true::value == true ) +with expansion: + true == true + +Tricky.tests.cpp:: +PASSED: + REQUIRE( true == is_true::value ) +with expansion: + true == true + +------------------------------------------------------------------------------- +(unimplemented) static bools can be evaluated + compare to false +------------------------------------------------------------------------------- +Tricky.tests.cpp: +............................................................................... + +Tricky.tests.cpp:: +PASSED: + REQUIRE( is_true::value == false ) +with expansion: + false == false + +Tricky.tests.cpp:: +PASSED: + REQUIRE( false == is_true::value ) +with expansion: + false == false + +------------------------------------------------------------------------------- +(unimplemented) static bools can be evaluated + negation +------------------------------------------------------------------------------- +Tricky.tests.cpp: +............................................................................... + +Tricky.tests.cpp:: +PASSED: + REQUIRE( !is_true::value ) +with expansion: + true + +------------------------------------------------------------------------------- +(unimplemented) static bools can be evaluated + double negation +------------------------------------------------------------------------------- +Tricky.tests.cpp: +............................................................................... + +Tricky.tests.cpp:: +PASSED: + REQUIRE( !!is_true::value ) +with expansion: + true + +------------------------------------------------------------------------------- +(unimplemented) static bools can be evaluated + direct +------------------------------------------------------------------------------- +Tricky.tests.cpp: +............................................................................... + +Tricky.tests.cpp:: +PASSED: + REQUIRE( is_true::value ) +with expansion: + true + +Tricky.tests.cpp:: +PASSED: + REQUIRE_FALSE( is_true::value ) +with expansion: + !false + +------------------------------------------------------------------------------- +A METHOD_AS_TEST_CASE based test run that fails +------------------------------------------------------------------------------- +Class.tests.cpp: +............................................................................... + +Class.tests.cpp:: FAILED: + REQUIRE( s == "world" ) +with expansion: + "hello" == "world" + +------------------------------------------------------------------------------- +A METHOD_AS_TEST_CASE based test run that succeeds +------------------------------------------------------------------------------- +Class.tests.cpp: +............................................................................... + +Class.tests.cpp:: +PASSED: + REQUIRE( s == "hello" ) +with expansion: + "hello" == "hello" + +------------------------------------------------------------------------------- +A TEST_CASE_METHOD based test run that fails +------------------------------------------------------------------------------- +Class.tests.cpp: +............................................................................... + +Class.tests.cpp:: FAILED: + REQUIRE( m_a == 2 ) +with expansion: + 1 == 2 + +------------------------------------------------------------------------------- +A TEST_CASE_METHOD based test run that succeeds +------------------------------------------------------------------------------- +Class.tests.cpp: +............................................................................... + +Class.tests.cpp:: +PASSED: + REQUIRE( m_a == 1 ) +with expansion: + 1 == 1 + +------------------------------------------------------------------------------- +A comparison that uses literals instead of the normal constructor +------------------------------------------------------------------------------- +Approx.tests.cpp: +............................................................................... + +Approx.tests.cpp:: +PASSED: + REQUIRE( d == 1.23_a ) +with expansion: + 1.23 == Approx( 1.23 ) + +Approx.tests.cpp:: +PASSED: + REQUIRE( d != 1.22_a ) +with expansion: + 1.23 != Approx( 1.22 ) + +Approx.tests.cpp:: +PASSED: + REQUIRE( -d == -1.23_a ) +with expansion: + -1.23 == Approx( -1.23 ) + +Approx.tests.cpp:: +PASSED: + REQUIRE( d == 1.2_a .epsilon(.1) ) +with expansion: + 1.23 == Approx( 1.2 ) + +Approx.tests.cpp:: +PASSED: + REQUIRE( d != 1.2_a .epsilon(.001) ) +with expansion: + 1.23 != Approx( 1.2 ) + +Approx.tests.cpp:: +PASSED: + REQUIRE( d == 1_a .epsilon(.3) ) +with expansion: + 1.23 == Approx( 1.0 ) + +------------------------------------------------------------------------------- +A couple of nested sections followed by a failure + Outer + Inner +------------------------------------------------------------------------------- +Misc.tests.cpp: +............................................................................... + +Misc.tests.cpp:: +PASSED: +with message: + that's not flying - that's failing in style + +------------------------------------------------------------------------------- +A couple of nested sections followed by a failure +------------------------------------------------------------------------------- +Misc.tests.cpp: +............................................................................... + +Misc.tests.cpp:: FAILED: +explicitly with message: + to infinity and beyond + +------------------------------------------------------------------------------- +A failing expression with a non streamable type is still captured +------------------------------------------------------------------------------- +Tricky.tests.cpp: +............................................................................... + +Tricky.tests.cpp:: FAILED: + CHECK( &o1 == &o2 ) +with expansion: + 0x == 0x + +Tricky.tests.cpp:: FAILED: + CHECK( o1 == o2 ) +with expansion: + {?} == {?} + +------------------------------------------------------------------------------- +Absolute margin +------------------------------------------------------------------------------- +Approx.tests.cpp: +............................................................................... + +Approx.tests.cpp:: +PASSED: + REQUIRE( 104.0 != Approx(100.0) ) +with expansion: + 104.0 != Approx( 100.0 ) + +Approx.tests.cpp:: +PASSED: + REQUIRE( 104.0 == Approx(100.0).margin(5) ) +with expansion: + 104.0 == Approx( 100.0 ) + +Approx.tests.cpp:: +PASSED: + REQUIRE( 104.0 == Approx(100.0).margin(4) ) +with expansion: + 104.0 == Approx( 100.0 ) + +Approx.tests.cpp:: +PASSED: + REQUIRE( 104.0 != Approx(100.0).margin(3) ) +with expansion: + 104.0 != Approx( 100.0 ) + +Approx.tests.cpp:: +PASSED: + REQUIRE( 100.3 != Approx(100.0) ) +with expansion: + 100.3 != Approx( 100.0 ) + +Approx.tests.cpp:: +PASSED: + REQUIRE( 100.3 == Approx(100.0).margin(0.5) ) +with expansion: + 100.3 == Approx( 100.0 ) + +------------------------------------------------------------------------------- +An empty test with no assertions +------------------------------------------------------------------------------- +Misc.tests.cpp: +............................................................................... + + +No assertions in test case 'An empty test with no assertions' + +------------------------------------------------------------------------------- +An expression with side-effects should only be evaluated once +------------------------------------------------------------------------------- +Tricky.tests.cpp: +............................................................................... + +Tricky.tests.cpp:: +PASSED: + REQUIRE( i++ == 7 ) +with expansion: + 7 == 7 + +Tricky.tests.cpp:: +PASSED: + REQUIRE( i++ == 8 ) +with expansion: + 8 == 8 + +------------------------------------------------------------------------------- +An unchecked exception reports the line of the last assertion +------------------------------------------------------------------------------- +Exception.tests.cpp: +............................................................................... + +Exception.tests.cpp:: +PASSED: + CHECK( 1 == 1 ) + +Exception.tests.cpp:: FAILED: + {Unknown expression after the reported line} +due to unexpected exception with message: + unexpected exception + +------------------------------------------------------------------------------- +Anonymous test case 1 +------------------------------------------------------------------------------- +VariadicMacros.tests.cpp: +............................................................................... + +VariadicMacros.tests.cpp:: +PASSED: +with message: + anonymous test case + +------------------------------------------------------------------------------- +Approx setters validate their arguments +------------------------------------------------------------------------------- +Approx.tests.cpp: +............................................................................... + +Approx.tests.cpp:: +PASSED: + REQUIRE_NOTHROW( Approx(0).margin(0) ) + +Approx.tests.cpp:: +PASSED: + REQUIRE_NOTHROW( Approx(0).margin(1234656) ) + +Approx.tests.cpp:: +PASSED: + REQUIRE_THROWS_AS( Approx(0).margin(-2), std::domain_error ) + +Approx.tests.cpp:: +PASSED: + REQUIRE_NOTHROW( Approx(0).epsilon(0) ) + +Approx.tests.cpp:: +PASSED: + REQUIRE_NOTHROW( Approx(0).epsilon(1) ) + +Approx.tests.cpp:: +PASSED: + REQUIRE_THROWS_AS( Approx(0).epsilon(-0.001), std::domain_error ) + +Approx.tests.cpp:: +PASSED: + REQUIRE_THROWS_AS( Approx(0).epsilon(1.0001), std::domain_error ) + +------------------------------------------------------------------------------- +Approx with exactly-representable margin +------------------------------------------------------------------------------- +Approx.tests.cpp: +............................................................................... + +Approx.tests.cpp:: +PASSED: + CHECK( 0.25f == Approx(0.0f).margin(0.25f) ) +with expansion: + 0.25f == Approx( 0.0 ) + +Approx.tests.cpp:: +PASSED: + CHECK( 0.0f == Approx(0.25f).margin(0.25f) ) +with expansion: + 0.0f == Approx( 0.25 ) + +Approx.tests.cpp:: +PASSED: + CHECK( 0.5f == Approx(0.25f).margin(0.25f) ) +with expansion: + 0.5f == Approx( 0.25 ) + +Approx.tests.cpp:: +PASSED: + CHECK( 245.0f == Approx(245.25f).margin(0.25f) ) +with expansion: + 245.0f == Approx( 245.25 ) + +Approx.tests.cpp:: +PASSED: + CHECK( 245.5f == Approx(245.25f).margin(0.25f) ) +with expansion: + 245.5f == Approx( 245.25 ) + +------------------------------------------------------------------------------- +Approximate PI +------------------------------------------------------------------------------- +Approx.tests.cpp: +............................................................................... + +Approx.tests.cpp:: +PASSED: + REQUIRE( divide( 22, 7 ) == Approx( 3.141 ).epsilon( 0.001 ) ) +with expansion: + 3.1428571429 == Approx( 3.141 ) + +Approx.tests.cpp:: +PASSED: + REQUIRE( divide( 22, 7 ) != Approx( 3.141 ).epsilon( 0.0001 ) ) +with expansion: + 3.1428571429 != Approx( 3.141 ) + +------------------------------------------------------------------------------- +Approximate comparisons with different epsilons +------------------------------------------------------------------------------- +Approx.tests.cpp: +............................................................................... + +Approx.tests.cpp:: +PASSED: + REQUIRE( d != Approx( 1.231 ) ) +with expansion: + 1.23 != Approx( 1.231 ) + +Approx.tests.cpp:: +PASSED: + REQUIRE( d == Approx( 1.231 ).epsilon( 0.1 ) ) +with expansion: + 1.23 == Approx( 1.231 ) + +------------------------------------------------------------------------------- +Approximate comparisons with floats +------------------------------------------------------------------------------- +Approx.tests.cpp: +............................................................................... + +Approx.tests.cpp:: +PASSED: + REQUIRE( 1.23f == Approx( 1.23f ) ) +with expansion: + 1.23f == Approx( 1.2300000191 ) + +Approx.tests.cpp:: +PASSED: + REQUIRE( 0.0f == Approx( 0.0f ) ) +with expansion: + 0.0f == Approx( 0.0 ) + +------------------------------------------------------------------------------- +Approximate comparisons with ints +------------------------------------------------------------------------------- +Approx.tests.cpp: +............................................................................... + +Approx.tests.cpp:: +PASSED: + REQUIRE( 1 == Approx( 1 ) ) +with expansion: + 1 == Approx( 1.0 ) + +Approx.tests.cpp:: +PASSED: + REQUIRE( 0 == Approx( 0 ) ) +with expansion: + 0 == Approx( 0.0 ) + +------------------------------------------------------------------------------- +Approximate comparisons with mixed numeric types +------------------------------------------------------------------------------- +Approx.tests.cpp: +............................................................................... + +Approx.tests.cpp:: +PASSED: + REQUIRE( 1.0f == Approx( 1 ) ) +with expansion: + 1.0f == Approx( 1.0 ) + +Approx.tests.cpp:: +PASSED: + REQUIRE( 0 == Approx( dZero) ) +with expansion: + 0 == Approx( 0.0 ) + +Approx.tests.cpp:: +PASSED: + REQUIRE( 0 == Approx( dSmall ).margin( 0.001 ) ) +with expansion: + 0 == Approx( 0.00001 ) + +Approx.tests.cpp:: +PASSED: + REQUIRE( 1.234f == Approx( dMedium ) ) +with expansion: + 1.234f == Approx( 1.234 ) + +Approx.tests.cpp:: +PASSED: + REQUIRE( dMedium == Approx( 1.234f ) ) +with expansion: + 1.234 == Approx( 1.2339999676 ) + +------------------------------------------------------------------------------- +Arbitrary predicate matcher + Function pointer +------------------------------------------------------------------------------- +Matchers.tests.cpp: +............................................................................... + +Matchers.tests.cpp:: +PASSED: + REQUIRE_THAT( 1, Predicate(alwaysTrue, "always true") ) +with expansion: + 1 matches predicate: "always true" + +Matchers.tests.cpp:: +PASSED: + REQUIRE_THAT( 1, !Predicate(alwaysFalse, "always false") ) +with expansion: + 1 not matches predicate: "always false" + +------------------------------------------------------------------------------- +Arbitrary predicate matcher + Lambdas + different type +------------------------------------------------------------------------------- +Matchers.tests.cpp: +............................................................................... + +Matchers.tests.cpp:: +PASSED: + REQUIRE_THAT( "Hello olleH", Predicate( [] (std::string const& str) -> bool { return str.front() == str.back(); }, "First and last character should be equal") ) +with expansion: + "Hello olleH" matches predicate: "First and last character should be equal" + +Matchers.tests.cpp:: +PASSED: + REQUIRE_THAT( "This wouldn't pass", !Predicate( [] (std::string const& str) -> bool { return str.front() == str.back(); } ) ) +with expansion: + "This wouldn't pass" not matches undescribed predicate + +------------------------------------------------------------------------------- +Assertions then sections +------------------------------------------------------------------------------- +Tricky.tests.cpp: +............................................................................... + +Tricky.tests.cpp:: +PASSED: + REQUIRE( true ) + +------------------------------------------------------------------------------- +Assertions then sections + A section +------------------------------------------------------------------------------- +Tricky.tests.cpp: +............................................................................... + +Tricky.tests.cpp:: +PASSED: + REQUIRE( true ) + +------------------------------------------------------------------------------- +Assertions then sections + A section + Another section +------------------------------------------------------------------------------- +Tricky.tests.cpp: +............................................................................... + +Tricky.tests.cpp:: +PASSED: + REQUIRE( true ) + +------------------------------------------------------------------------------- +Assertions then sections +------------------------------------------------------------------------------- +Tricky.tests.cpp: +............................................................................... + +Tricky.tests.cpp:: +PASSED: + REQUIRE( true ) + +------------------------------------------------------------------------------- +Assertions then sections + A section +------------------------------------------------------------------------------- +Tricky.tests.cpp: +............................................................................... + +Tricky.tests.cpp:: +PASSED: + REQUIRE( true ) + +------------------------------------------------------------------------------- +Assertions then sections + A section + Another other section +------------------------------------------------------------------------------- +Tricky.tests.cpp: +............................................................................... + +Tricky.tests.cpp:: +PASSED: + REQUIRE( true ) + +------------------------------------------------------------------------------- +Assorted miscellaneous tests +------------------------------------------------------------------------------- +Approx.tests.cpp: +............................................................................... + +Approx.tests.cpp:: +PASSED: + REQUIRE( INFINITY == Approx(INFINITY) ) +with expansion: + inff == Approx( inf ) + +Approx.tests.cpp:: +PASSED: + REQUIRE( NAN != Approx(NAN) ) +with expansion: + nanf != Approx( nan ) + +Approx.tests.cpp:: +PASSED: + REQUIRE_FALSE( NAN == Approx(NAN) ) +with expansion: + !(nanf == Approx( nan )) + +------------------------------------------------------------------------------- +Bitfields can be captured (#1027) +------------------------------------------------------------------------------- +Tricky.tests.cpp: +............................................................................... + +Tricky.tests.cpp:: +PASSED: + REQUIRE( y.v == 0 ) +with expansion: + 0 == 0 + +Tricky.tests.cpp:: +PASSED: + REQUIRE( 0 == y.v ) +with expansion: + 0 == 0 + +------------------------------------------------------------------------------- +Capture and info messages + Capture should stringify like assertions +------------------------------------------------------------------------------- +ToStringGeneral.tests.cpp: +............................................................................... + +ToStringGeneral.tests.cpp:: +PASSED: + REQUIRE( true ) +with message: + i := 2 + +------------------------------------------------------------------------------- +Capture and info messages + Info should NOT stringify the way assertions do +------------------------------------------------------------------------------- +ToStringGeneral.tests.cpp: +............................................................................... + +ToStringGeneral.tests.cpp:: +PASSED: + REQUIRE( true ) +with message: + 3 + +------------------------------------------------------------------------------- +Character pretty printing + Specifically escaped +------------------------------------------------------------------------------- +ToStringGeneral.tests.cpp: +............................................................................... + +ToStringGeneral.tests.cpp:: +PASSED: + CHECK( tab == '\t' ) +with expansion: + '\t' == '\t' + +ToStringGeneral.tests.cpp:: +PASSED: + CHECK( newline == '\n' ) +with expansion: + '\n' == '\n' + +ToStringGeneral.tests.cpp:: +PASSED: + CHECK( carr_return == '\r' ) +with expansion: + '\r' == '\r' + +ToStringGeneral.tests.cpp:: +PASSED: + CHECK( form_feed == '\f' ) +with expansion: + '\f' == '\f' + +------------------------------------------------------------------------------- +Character pretty printing + General chars +------------------------------------------------------------------------------- +ToStringGeneral.tests.cpp: +............................................................................... + +ToStringGeneral.tests.cpp:: +PASSED: + CHECK( space == ' ' ) +with expansion: + ' ' == ' ' + +ToStringGeneral.tests.cpp:: +PASSED: + REQUIRE( c == chars[i] ) +with expansion: + 'a' == 'a' + +ToStringGeneral.tests.cpp:: +PASSED: + REQUIRE( c == chars[i] ) +with expansion: + 'z' == 'z' + +ToStringGeneral.tests.cpp:: +PASSED: + REQUIRE( c == chars[i] ) +with expansion: + 'A' == 'A' + +ToStringGeneral.tests.cpp:: +PASSED: + REQUIRE( c == chars[i] ) +with expansion: + 'Z' == 'Z' + +------------------------------------------------------------------------------- +Character pretty printing + Low ASCII +------------------------------------------------------------------------------- +ToStringGeneral.tests.cpp: +............................................................................... + +ToStringGeneral.tests.cpp:: +PASSED: + CHECK( null_terminator == '\0' ) +with expansion: + 0 == 0 + +ToStringGeneral.tests.cpp:: +PASSED: + REQUIRE( c == i ) +with expansion: + 2 == 2 + +ToStringGeneral.tests.cpp:: +PASSED: + REQUIRE( c == i ) +with expansion: + 3 == 3 + +ToStringGeneral.tests.cpp:: +PASSED: + REQUIRE( c == i ) +with expansion: + 4 == 4 + +ToStringGeneral.tests.cpp:: +PASSED: + REQUIRE( c == i ) +with expansion: + 5 == 5 + +------------------------------------------------------------------------------- +Commas in various macros are allowed +------------------------------------------------------------------------------- +Tricky.tests.cpp: +............................................................................... + +Tricky.tests.cpp:: +PASSED: + REQUIRE_THROWS( std::vector{constructor_throws{}, constructor_throws{}} ) + +Tricky.tests.cpp:: +PASSED: + CHECK_THROWS( std::vector{constructor_throws{}, constructor_throws{}} ) + +Tricky.tests.cpp:: +PASSED: + REQUIRE_NOTHROW( std::vector{1, 2, 3} == std::vector{1, 2, 3} ) + +Tricky.tests.cpp:: +PASSED: + CHECK_NOTHROW( std::vector{1, 2, 3} == std::vector{1, 2, 3} ) + +Tricky.tests.cpp:: +PASSED: + REQUIRE( std::vector{1, 2} == std::vector{1, 2} ) +with expansion: + { 1, 2 } == { 1, 2 } + +Tricky.tests.cpp:: +PASSED: + CHECK( std::vector{1, 2} == std::vector{1, 2} ) +with expansion: + { 1, 2 } == { 1, 2 } + +Tricky.tests.cpp:: +PASSED: + REQUIRE_FALSE( std::vector{1, 2} == std::vector{1, 2, 3} ) +with expansion: + !({ 1, 2 } == { 1, 2, 3 }) + +Tricky.tests.cpp:: +PASSED: + CHECK_FALSE( std::vector{1, 2} == std::vector{1, 2, 3} ) +with expansion: + !({ 1, 2 } == { 1, 2, 3 }) + +Tricky.tests.cpp:: +PASSED: + CHECK_NOFAIL( std::vector{1, 2} == std::vector{1, 2} ) +with expansion: + { 1, 2 } == { 1, 2 } + +Tricky.tests.cpp:: +PASSED: + CHECKED_IF( std::vector{1, 2} == std::vector{1, 2} ) +with expansion: + { 1, 2 } == { 1, 2 } + +Tricky.tests.cpp:: +PASSED: + REQUIRE( true ) + +Tricky.tests.cpp:: +PASSED: + CHECKED_ELSE( std::vector{1, 2} == std::vector{1, 2} ) +with expansion: + { 1, 2 } == { 1, 2 } + +------------------------------------------------------------------------------- +Comparing function pointers +------------------------------------------------------------------------------- +Tricky.tests.cpp: +............................................................................... + +Tricky.tests.cpp:: +PASSED: + REQUIRE( a ) +with expansion: + 0x + +Tricky.tests.cpp:: +PASSED: + REQUIRE( a == &foo ) +with expansion: + 0x == 0x + +------------------------------------------------------------------------------- +Comparison with explicitly convertible types +------------------------------------------------------------------------------- +Approx.tests.cpp: +............................................................................... + +Approx.tests.cpp:: +PASSED: + REQUIRE( td == Approx(10.0) ) +with expansion: + StrongDoubleTypedef(10) == Approx( 10.0 ) + +Approx.tests.cpp:: +PASSED: + REQUIRE( Approx(10.0) == td ) +with expansion: + Approx( 10.0 ) == StrongDoubleTypedef(10) + +Approx.tests.cpp:: +PASSED: + REQUIRE( td != Approx(11.0) ) +with expansion: + StrongDoubleTypedef(10) != Approx( 11.0 ) + +Approx.tests.cpp:: +PASSED: + REQUIRE( Approx(11.0) != td ) +with expansion: + Approx( 11.0 ) != StrongDoubleTypedef(10) + +Approx.tests.cpp:: +PASSED: + REQUIRE( td <= Approx(10.0) ) +with expansion: + StrongDoubleTypedef(10) <= Approx( 10.0 ) + +Approx.tests.cpp:: +PASSED: + REQUIRE( td <= Approx(11.0) ) +with expansion: + StrongDoubleTypedef(10) <= Approx( 11.0 ) + +Approx.tests.cpp:: +PASSED: + REQUIRE( Approx(10.0) <= td ) +with expansion: + Approx( 10.0 ) <= StrongDoubleTypedef(10) + +Approx.tests.cpp:: +PASSED: + REQUIRE( Approx(9.0) <= td ) +with expansion: + Approx( 9.0 ) <= StrongDoubleTypedef(10) + +Approx.tests.cpp:: +PASSED: + REQUIRE( td >= Approx(9.0) ) +with expansion: + StrongDoubleTypedef(10) >= Approx( 9.0 ) + +Approx.tests.cpp:: +PASSED: + REQUIRE( td >= Approx(td) ) +with expansion: + StrongDoubleTypedef(10) >= Approx( 10.0 ) + +Approx.tests.cpp:: +PASSED: + REQUIRE( Approx(td) >= td ) +with expansion: + Approx( 10.0 ) >= StrongDoubleTypedef(10) + +Approx.tests.cpp:: +PASSED: + REQUIRE( Approx(11.0) >= td ) +with expansion: + Approx( 11.0 ) >= StrongDoubleTypedef(10) + +------------------------------------------------------------------------------- +Comparisons between ints where one side is computed +------------------------------------------------------------------------------- +Condition.tests.cpp: +............................................................................... + +Condition.tests.cpp:: +PASSED: + CHECK( 54 == 6*9 ) +with expansion: + 54 == 54 + +------------------------------------------------------------------------------- +Comparisons between unsigned ints and negative signed ints match c++ standard +behaviour +------------------------------------------------------------------------------- +Condition.tests.cpp: +............................................................................... + +Condition.tests.cpp:: +PASSED: + CHECK( ( -1 > 2u ) ) +with expansion: + true + +Condition.tests.cpp:: +PASSED: + CHECK( -1 > 2u ) +with expansion: + -1 > 2 + +Condition.tests.cpp:: +PASSED: + CHECK( ( 2u < -1 ) ) +with expansion: + true + +Condition.tests.cpp:: +PASSED: + CHECK( 2u < -1 ) +with expansion: + 2 < -1 + +Condition.tests.cpp:: +PASSED: + CHECK( ( minInt > 2u ) ) +with expansion: + true + +Condition.tests.cpp:: +PASSED: + CHECK( minInt > 2u ) +with expansion: + -2147483648 > 2 + +------------------------------------------------------------------------------- +Comparisons with int literals don't warn when mixing signed/ unsigned +------------------------------------------------------------------------------- +Condition.tests.cpp: +............................................................................... + +Condition.tests.cpp:: +PASSED: + REQUIRE( i == 1 ) +with expansion: + 1 == 1 + +Condition.tests.cpp:: +PASSED: + REQUIRE( ui == 2 ) +with expansion: + 2 == 2 + +Condition.tests.cpp:: +PASSED: + REQUIRE( l == 3 ) +with expansion: + 3 == 3 + +Condition.tests.cpp:: +PASSED: + REQUIRE( ul == 4 ) +with expansion: + 4 == 4 + +Condition.tests.cpp:: +PASSED: + REQUIRE( c == 5 ) +with expansion: + 5 == 5 + +Condition.tests.cpp:: +PASSED: + REQUIRE( uc == 6 ) +with expansion: + 6 == 6 + +Condition.tests.cpp:: +PASSED: + REQUIRE( 1 == i ) +with expansion: + 1 == 1 + +Condition.tests.cpp:: +PASSED: + REQUIRE( 2 == ui ) +with expansion: + 2 == 2 + +Condition.tests.cpp:: +PASSED: + REQUIRE( 3 == l ) +with expansion: + 3 == 3 + +Condition.tests.cpp:: +PASSED: + REQUIRE( 4 == ul ) +with expansion: + 4 == 4 + +Condition.tests.cpp:: +PASSED: + REQUIRE( 5 == c ) +with expansion: + 5 == 5 + +Condition.tests.cpp:: +PASSED: + REQUIRE( 6 == uc ) +with expansion: + 6 == 6 + +Condition.tests.cpp:: +PASSED: + REQUIRE( (std::numeric_limits::max)() > ul ) +with expansion: + 4294967295 (0x) > 4 + +------------------------------------------------------------------------------- +Contains string matcher +------------------------------------------------------------------------------- +Matchers.tests.cpp: +............................................................................... + +Matchers.tests.cpp:: FAILED: + CHECK_THAT( testStringForMatching(), Contains("not there", Catch::CaseSensitive::No) ) +with expansion: + "this string contains 'abc' as a substring" contains: "not there" (case + insensitive) + +Matchers.tests.cpp:: FAILED: + CHECK_THAT( testStringForMatching(), Contains("STRING") ) +with expansion: + "this string contains 'abc' as a substring" contains: "STRING" + +------------------------------------------------------------------------------- +Custom exceptions can be translated when testing for nothrow +------------------------------------------------------------------------------- +Exception.tests.cpp: +............................................................................... + +Exception.tests.cpp:: FAILED: + REQUIRE_NOTHROW( throwCustom() ) +due to unexpected exception with message: + custom exception - not std + +------------------------------------------------------------------------------- +Custom exceptions can be translated when testing for throwing as something else +------------------------------------------------------------------------------- +Exception.tests.cpp: +............................................................................... + +Exception.tests.cpp:: FAILED: + REQUIRE_THROWS_AS( throwCustom(), std::exception ) +due to unexpected exception with message: + custom exception - not std + +------------------------------------------------------------------------------- +Custom std-exceptions can be custom translated +------------------------------------------------------------------------------- +Exception.tests.cpp: +............................................................................... + +Exception.tests.cpp:: FAILED: +due to unexpected exception with message: + custom std exception + +------------------------------------------------------------------------------- +Default scale is invisible to comparison +------------------------------------------------------------------------------- +Approx.tests.cpp: +............................................................................... + +Approx.tests.cpp:: +PASSED: + REQUIRE( 101.000001 != Approx(100).epsilon(0.01) ) +with expansion: + 101.000001 != Approx( 100.0 ) + +Approx.tests.cpp:: +PASSED: + REQUIRE( std::pow(10, -5) != Approx(std::pow(10, -7)) ) +with expansion: + 0.00001 != Approx( 0.0000001 ) + +------------------------------------------------------------------------------- +EndsWith string matcher +------------------------------------------------------------------------------- +Matchers.tests.cpp: +............................................................................... + +Matchers.tests.cpp:: FAILED: + CHECK_THAT( testStringForMatching(), EndsWith("Substring") ) +with expansion: + "this string contains 'abc' as a substring" ends with: "Substring" + +Matchers.tests.cpp:: FAILED: + CHECK_THAT( testStringForMatching(), EndsWith("this", Catch::CaseSensitive::No) ) +with expansion: + "this string contains 'abc' as a substring" ends with: "this" (case + insensitive) + +------------------------------------------------------------------------------- +Epsilon only applies to Approx's value +------------------------------------------------------------------------------- +Approx.tests.cpp: +............................................................................... + +Approx.tests.cpp:: +PASSED: + REQUIRE( 101.01 != Approx(100).epsilon(0.01) ) +with expansion: + 101.01 != Approx( 100.0 ) + +------------------------------------------------------------------------------- +Equality checks that should fail +------------------------------------------------------------------------------- +Condition.tests.cpp: +............................................................................... + +Condition.tests.cpp:: FAILED: + CHECK( data.int_seven == 6 ) +with expansion: + 7 == 6 + +Condition.tests.cpp:: FAILED: + CHECK( data.int_seven == 8 ) +with expansion: + 7 == 8 + +Condition.tests.cpp:: FAILED: + CHECK( data.int_seven == 0 ) +with expansion: + 7 == 0 + +Condition.tests.cpp:: FAILED: + CHECK( data.float_nine_point_one == Approx( 9.11f ) ) +with expansion: + 9.1f == Approx( 9.1099996567 ) + +Condition.tests.cpp:: FAILED: + CHECK( data.float_nine_point_one == Approx( 9.0f ) ) +with expansion: + 9.1f == Approx( 9.0 ) + +Condition.tests.cpp:: FAILED: + CHECK( data.float_nine_point_one == Approx( 1 ) ) +with expansion: + 9.1f == Approx( 1.0 ) + +Condition.tests.cpp:: FAILED: + CHECK( data.float_nine_point_one == Approx( 0 ) ) +with expansion: + 9.1f == Approx( 0.0 ) + +Condition.tests.cpp:: FAILED: + CHECK( data.double_pi == Approx( 3.1415 ) ) +with expansion: + 3.1415926535 == Approx( 3.1415 ) + +Condition.tests.cpp:: FAILED: + CHECK( data.str_hello == "goodbye" ) +with expansion: + "hello" == "goodbye" + +Condition.tests.cpp:: FAILED: + CHECK( data.str_hello == "hell" ) +with expansion: + "hello" == "hell" + +Condition.tests.cpp:: FAILED: + CHECK( data.str_hello == "hello1" ) +with expansion: + "hello" == "hello1" + +Condition.tests.cpp:: FAILED: + CHECK( data.str_hello.size() == 6 ) +with expansion: + 5 == 6 + +Condition.tests.cpp:: FAILED: + CHECK( x == Approx( 1.301 ) ) +with expansion: + 1.3 == Approx( 1.301 ) + +------------------------------------------------------------------------------- +Equality checks that should succeed +------------------------------------------------------------------------------- +Condition.tests.cpp: +............................................................................... + +Condition.tests.cpp:: +PASSED: + REQUIRE( data.int_seven == 7 ) +with expansion: + 7 == 7 + +Condition.tests.cpp:: +PASSED: + REQUIRE( data.float_nine_point_one == Approx( 9.1f ) ) +with expansion: + 9.1f == Approx( 9.1000003815 ) + +Condition.tests.cpp:: +PASSED: + REQUIRE( data.double_pi == Approx( 3.1415926535 ) ) +with expansion: + 3.1415926535 == Approx( 3.1415926535 ) + +Condition.tests.cpp:: +PASSED: + REQUIRE( data.str_hello == "hello" ) +with expansion: + "hello" == "hello" + +Condition.tests.cpp:: +PASSED: + REQUIRE( "hello" == data.str_hello ) +with expansion: + "hello" == "hello" + +Condition.tests.cpp:: +PASSED: + REQUIRE( data.str_hello.size() == 5 ) +with expansion: + 5 == 5 + +Condition.tests.cpp:: +PASSED: + REQUIRE( x == Approx( 1.3 ) ) +with expansion: + 1.3 == Approx( 1.3 ) + +------------------------------------------------------------------------------- +Equals +------------------------------------------------------------------------------- +Matchers.tests.cpp: +............................................................................... + +Matchers.tests.cpp:: +PASSED: + CHECK_THAT( testStringForMatching(), Equals("this string contains 'abc' as a substring") ) +with expansion: + "this string contains 'abc' as a substring" equals: "this string contains + 'abc' as a substring" + +Matchers.tests.cpp:: +PASSED: + CHECK_THAT( testStringForMatching(), Equals("this string contains 'ABC' as a substring", Catch::CaseSensitive::No) ) +with expansion: + "this string contains 'abc' as a substring" equals: "this string contains + 'abc' as a substring" (case insensitive) + +------------------------------------------------------------------------------- +Equals string matcher +------------------------------------------------------------------------------- +Matchers.tests.cpp: +............................................................................... + +Matchers.tests.cpp:: FAILED: + CHECK_THAT( testStringForMatching(), Equals("this string contains 'ABC' as a substring") ) +with expansion: + "this string contains 'abc' as a substring" equals: "this string contains + 'ABC' as a substring" + +Matchers.tests.cpp:: FAILED: + CHECK_THAT( testStringForMatching(), Equals("something else", Catch::CaseSensitive::No) ) +with expansion: + "this string contains 'abc' as a substring" equals: "something else" (case + insensitive) + +------------------------------------------------------------------------------- +Exception as a value (e.g. in REQUIRE_THROWS_MATCHES) can be stringified +------------------------------------------------------------------------------- +ToStringGeneral.tests.cpp: +............................................................................... + +ToStringGeneral.tests.cpp:: +PASSED: + REQUIRE( ::Catch::Detail::stringify(WhatException{}) == "This exception has overriden what() method" ) +with expansion: + "This exception has overriden what() method" + == + "This exception has overriden what() method" + +ToStringGeneral.tests.cpp:: +PASSED: + REQUIRE( ::Catch::Detail::stringify(OperatorException{}) == "OperatorException" ) +with expansion: + "OperatorException" == "OperatorException" + +ToStringGeneral.tests.cpp:: +PASSED: + REQUIRE( ::Catch::Detail::stringify(StringMakerException{}) == "StringMakerException" ) +with expansion: + "StringMakerException" + == + "StringMakerException" + +------------------------------------------------------------------------------- +Exception matchers that fail + No exception +------------------------------------------------------------------------------- +Matchers.tests.cpp: +............................................................................... + +Matchers.tests.cpp:: FAILED: + CHECK_THROWS_MATCHES( doesNotThrow(), SpecialException, ExceptionMatcher{1} ) +because no exception was thrown where one was expected: + +Matchers.tests.cpp:: FAILED: + REQUIRE_THROWS_MATCHES( doesNotThrow(), SpecialException, ExceptionMatcher{1} ) +because no exception was thrown where one was expected: + +------------------------------------------------------------------------------- +Exception matchers that fail + Type mismatch +------------------------------------------------------------------------------- +Matchers.tests.cpp: +............................................................................... + +Matchers.tests.cpp:: FAILED: + CHECK_THROWS_MATCHES( throwsAsInt(1), SpecialException, ExceptionMatcher{1} ) +due to unexpected exception with message: + Unknown exception + +Matchers.tests.cpp:: FAILED: + REQUIRE_THROWS_MATCHES( throwsAsInt(1), SpecialException, ExceptionMatcher{1} ) +due to unexpected exception with message: + Unknown exception + +------------------------------------------------------------------------------- +Exception matchers that fail + Contents are wrong +------------------------------------------------------------------------------- +Matchers.tests.cpp: +............................................................................... + +Matchers.tests.cpp:: FAILED: + CHECK_THROWS_MATCHES( throws(3), SpecialException, ExceptionMatcher{1} ) +with expansion: + SpecialException::what special exception has value of 1 + +Matchers.tests.cpp:: FAILED: + REQUIRE_THROWS_MATCHES( throws(4), SpecialException, ExceptionMatcher{1} ) +with expansion: + SpecialException::what special exception has value of 1 + +------------------------------------------------------------------------------- +Exception matchers that succeed +------------------------------------------------------------------------------- +Matchers.tests.cpp: +............................................................................... + +Matchers.tests.cpp:: +PASSED: + CHECK_THROWS_MATCHES( throws(1), SpecialException, ExceptionMatcher{1} ) +with expansion: + SpecialException::what special exception has value of 1 + +Matchers.tests.cpp:: +PASSED: + REQUIRE_THROWS_MATCHES( throws(2), SpecialException, ExceptionMatcher{2} ) +with expansion: + SpecialException::what special exception has value of 2 + +------------------------------------------------------------------------------- +Exception messages can be tested for + exact match +------------------------------------------------------------------------------- +Exception.tests.cpp: +............................................................................... + +Exception.tests.cpp:: +PASSED: + REQUIRE_THROWS_WITH( thisThrows(), "expected exception" ) +with expansion: + "expected exception" equals: "expected exception" + +------------------------------------------------------------------------------- +Exception messages can be tested for + different case +------------------------------------------------------------------------------- +Exception.tests.cpp: +............................................................................... + +Exception.tests.cpp:: +PASSED: + REQUIRE_THROWS_WITH( thisThrows(), Equals( "expecteD Exception", Catch::CaseSensitive::No ) ) +with expansion: + "expected exception" equals: "expected exception" (case insensitive) + +------------------------------------------------------------------------------- +Exception messages can be tested for + wildcarded +------------------------------------------------------------------------------- +Exception.tests.cpp: +............................................................................... + +Exception.tests.cpp:: +PASSED: + REQUIRE_THROWS_WITH( thisThrows(), StartsWith( "expected" ) ) +with expansion: + "expected exception" starts with: "expected" + +Exception.tests.cpp:: +PASSED: + REQUIRE_THROWS_WITH( thisThrows(), EndsWith( "exception" ) ) +with expansion: + "expected exception" ends with: "exception" + +Exception.tests.cpp:: +PASSED: + REQUIRE_THROWS_WITH( thisThrows(), Contains( "except" ) ) +with expansion: + "expected exception" contains: "except" + +Exception.tests.cpp:: +PASSED: + REQUIRE_THROWS_WITH( thisThrows(), Contains( "exCept", Catch::CaseSensitive::No ) ) +with expansion: + "expected exception" contains: "except" (case insensitive) + +------------------------------------------------------------------------------- +Expected exceptions that don't throw or unexpected exceptions fail the test +------------------------------------------------------------------------------- +Exception.tests.cpp: +............................................................................... + +Exception.tests.cpp:: FAILED: + CHECK_THROWS_AS( thisThrows(), std::string ) +due to unexpected exception with message: + expected exception + +Exception.tests.cpp:: FAILED: + CHECK_THROWS_AS( thisDoesntThrow(), std::domain_error ) +because no exception was thrown where one was expected: + +Exception.tests.cpp:: FAILED: + CHECK_NOTHROW( thisThrows() ) +due to unexpected exception with message: + expected exception + +------------------------------------------------------------------------------- +FAIL aborts the test +------------------------------------------------------------------------------- +Message.tests.cpp: +............................................................................... + +Message.tests.cpp:: FAILED: +explicitly with message: + This is a failure + +------------------------------------------------------------------------------- +FAIL does not require an argument +------------------------------------------------------------------------------- +Message.tests.cpp: +............................................................................... + +Message.tests.cpp:: FAILED: + +------------------------------------------------------------------------------- +FAIL_CHECK does not abort the test +------------------------------------------------------------------------------- +Message.tests.cpp: +............................................................................... + +Message.tests.cpp:: FAILED: +explicitly with message: + This is a failure + +Message.tests.cpp:: +warning: + This message appears in the output + +------------------------------------------------------------------------------- +Factorials are computed +------------------------------------------------------------------------------- +Misc.tests.cpp: +............................................................................... + +Misc.tests.cpp:: +PASSED: + REQUIRE( Factorial(0) == 1 ) +with expansion: + 1 == 1 + +Misc.tests.cpp:: +PASSED: + REQUIRE( Factorial(1) == 1 ) +with expansion: + 1 == 1 + +Misc.tests.cpp:: +PASSED: + REQUIRE( Factorial(2) == 2 ) +with expansion: + 2 == 2 + +Misc.tests.cpp:: +PASSED: + REQUIRE( Factorial(3) == 6 ) +with expansion: + 6 == 6 + +Misc.tests.cpp:: +PASSED: + REQUIRE( Factorial(10) == 3628800 ) +with expansion: + 3628800 (0x) == 3628800 (0x) + +------------------------------------------------------------------------------- +Floating point matchers: double + Margin +------------------------------------------------------------------------------- +Matchers.tests.cpp: +............................................................................... + +Matchers.tests.cpp:: +PASSED: + REQUIRE_THAT( 1., WithinAbs(1., 0) ) +with expansion: + 1.0 is within 0.0 of 1.0 + +Matchers.tests.cpp:: +PASSED: + REQUIRE_THAT( 0., WithinAbs(1., 1) ) +with expansion: + 0.0 is within 1.0 of 1.0 + +Matchers.tests.cpp:: +PASSED: + REQUIRE_THAT( 0., !WithinAbs(1., 0.99) ) +with expansion: + 0.0 not is within 0.99 of 1.0 + +Matchers.tests.cpp:: +PASSED: + REQUIRE_THAT( 0., !WithinAbs(1., 0.99) ) +with expansion: + 0.0 not is within 0.99 of 1.0 + +Matchers.tests.cpp:: +PASSED: + REQUIRE_THAT( NAN, !WithinAbs(NAN, 0) ) +with expansion: + nanf not is within 0.0 of nan + +Matchers.tests.cpp:: +PASSED: + REQUIRE_THAT( 11., !WithinAbs(10., 0.5) ) +with expansion: + 11.0 not is within 0.5 of 10.0 + +Matchers.tests.cpp:: +PASSED: + REQUIRE_THAT( 10., !WithinAbs(11., 0.5) ) +with expansion: + 10.0 not is within 0.5 of 11.0 + +Matchers.tests.cpp:: +PASSED: + REQUIRE_THAT( -10., WithinAbs(-10., 0.5) ) +with expansion: + -10.0 is within 0.5 of -10.0 + +Matchers.tests.cpp:: +PASSED: + REQUIRE_THAT( -10., WithinAbs(-9.6, 0.5) ) +with expansion: + -10.0 is within 0.5 of -9.6 + +------------------------------------------------------------------------------- +Floating point matchers: double + ULPs +------------------------------------------------------------------------------- +Matchers.tests.cpp: +............................................................................... + +Matchers.tests.cpp:: +PASSED: + REQUIRE_THAT( 1., WithinULP(1., 0) ) +with expansion: + 1.0 is within 0 ULPs of 1.0 + +Matchers.tests.cpp:: +PASSED: + REQUIRE_THAT( nextafter(1., 2.), WithinULP(1., 1) ) +with expansion: + 1.0 is within 1 ULPs of 1.0 + +Matchers.tests.cpp:: +PASSED: + REQUIRE_THAT( nextafter(1., 0.), WithinULP(1., 1) ) +with expansion: + 1.0 is within 1 ULPs of 1.0 + +Matchers.tests.cpp:: +PASSED: + REQUIRE_THAT( nextafter(1., 2.), !WithinULP(1., 0) ) +with expansion: + 1.0 not is within 0 ULPs of 1.0 + +Matchers.tests.cpp:: +PASSED: + REQUIRE_THAT( 1., WithinULP(1., 0) ) +with expansion: + 1.0 is within 0 ULPs of 1.0 + +Matchers.tests.cpp:: +PASSED: + REQUIRE_THAT( -0., WithinULP(0., 0) ) +with expansion: + -0.0 is within 0 ULPs of 0.0 + +Matchers.tests.cpp:: +PASSED: + REQUIRE_THAT( NAN, !WithinULP(NAN, 123) ) +with expansion: + nanf not is within 123 ULPs of nanf + +------------------------------------------------------------------------------- +Floating point matchers: double + Composed +------------------------------------------------------------------------------- +Matchers.tests.cpp: +............................................................................... + +Matchers.tests.cpp:: +PASSED: + REQUIRE_THAT( 1., WithinAbs(1., 0.5) || WithinULP(2., 1) ) +with expansion: + 1.0 ( is within 0.5 of 1.0 or is within 1 ULPs of 2.0 ) + +Matchers.tests.cpp:: +PASSED: + REQUIRE_THAT( 1., WithinAbs(2., 0.5) || WithinULP(1., 0) ) +with expansion: + 1.0 ( is within 0.5 of 2.0 or is within 0 ULPs of 1.0 ) + +Matchers.tests.cpp:: +PASSED: + REQUIRE_THAT( NAN, !(WithinAbs(NAN, 100) || WithinULP(NAN, 123)) ) +with expansion: + nanf not ( is within 100.0 of nan or is within 123 ULPs of nanf ) + +------------------------------------------------------------------------------- +Floating point matchers: double + Constructor validation +------------------------------------------------------------------------------- +Matchers.tests.cpp: +............................................................................... + +Matchers.tests.cpp:: +PASSED: + REQUIRE_NOTHROW( WithinAbs(1., 0.) ) + +Matchers.tests.cpp:: +PASSED: + REQUIRE_THROWS_AS( WithinAbs(1., -1.), std::domain_error ) + +Matchers.tests.cpp:: +PASSED: + REQUIRE_NOTHROW( WithinULP(1., 0) ) + +Matchers.tests.cpp:: +PASSED: + REQUIRE_THROWS_AS( WithinULP(1., -1), std::domain_error ) + +------------------------------------------------------------------------------- +Floating point matchers: float + Margin +------------------------------------------------------------------------------- +Matchers.tests.cpp: +............................................................................... + +Matchers.tests.cpp:: +PASSED: + REQUIRE_THAT( 1.f, WithinAbs(1.f, 0) ) +with expansion: + 1.0f is within 0.0 of 1.0 + +Matchers.tests.cpp:: +PASSED: + REQUIRE_THAT( 0.f, WithinAbs(1.f, 1) ) +with expansion: + 0.0f is within 1.0 of 1.0 + +Matchers.tests.cpp:: +PASSED: + REQUIRE_THAT( 0.f, !WithinAbs(1.f, 0.99f) ) +with expansion: + 0.0f not is within 0.9900000095 of 1.0 + +Matchers.tests.cpp:: +PASSED: + REQUIRE_THAT( 0.f, !WithinAbs(1.f, 0.99f) ) +with expansion: + 0.0f not is within 0.9900000095 of 1.0 + +Matchers.tests.cpp:: +PASSED: + REQUIRE_THAT( 0.f, WithinAbs(-0.f, 0) ) +with expansion: + 0.0f is within 0.0 of -0.0 + +Matchers.tests.cpp:: +PASSED: + REQUIRE_THAT( NAN, !WithinAbs(NAN, 0) ) +with expansion: + nanf not is within 0.0 of nan + +Matchers.tests.cpp:: +PASSED: + REQUIRE_THAT( 11.f, !WithinAbs(10.f, 0.5f) ) +with expansion: + 11.0f not is within 0.5 of 10.0 + +Matchers.tests.cpp:: +PASSED: + REQUIRE_THAT( 10.f, !WithinAbs(11.f, 0.5f) ) +with expansion: + 10.0f not is within 0.5 of 11.0 + +Matchers.tests.cpp:: +PASSED: + REQUIRE_THAT( -10.f, WithinAbs(-10.f, 0.5f) ) +with expansion: + -10.0f is within 0.5 of -10.0 + +Matchers.tests.cpp:: +PASSED: + REQUIRE_THAT( -10.f, WithinAbs(-9.6f, 0.5f) ) +with expansion: + -10.0f is within 0.5 of -9.6000003815 + +------------------------------------------------------------------------------- +Floating point matchers: float + ULPs +------------------------------------------------------------------------------- +Matchers.tests.cpp: +............................................................................... + +Matchers.tests.cpp:: +PASSED: + REQUIRE_THAT( 1.f, WithinULP(1.f, 0) ) +with expansion: + 1.0f is within 0 ULPs of 1.0f + +Matchers.tests.cpp:: +PASSED: + REQUIRE_THAT( nextafter(1.f, 2.f), WithinULP(1.f, 1) ) +with expansion: + 1.0f is within 1 ULPs of 1.0f + +Matchers.tests.cpp:: +PASSED: + REQUIRE_THAT( nextafter(1.f, 0.f), WithinULP(1.f, 1) ) +with expansion: + 1.0f is within 1 ULPs of 1.0f + +Matchers.tests.cpp:: +PASSED: + REQUIRE_THAT( nextafter(1.f, 2.f), !WithinULP(1.f, 0) ) +with expansion: + 1.0f not is within 0 ULPs of 1.0f + +Matchers.tests.cpp:: +PASSED: + REQUIRE_THAT( 1.f, WithinULP(1.f, 0) ) +with expansion: + 1.0f is within 0 ULPs of 1.0f + +Matchers.tests.cpp:: +PASSED: + REQUIRE_THAT( -0.f, WithinULP(0.f, 0) ) +with expansion: + -0.0f is within 0 ULPs of 0.0f + +Matchers.tests.cpp:: +PASSED: + REQUIRE_THAT( NAN, !WithinULP(NAN, 123) ) +with expansion: + nanf not is within 123 ULPs of nanf + +------------------------------------------------------------------------------- +Floating point matchers: float + Composed +------------------------------------------------------------------------------- +Matchers.tests.cpp: +............................................................................... + +Matchers.tests.cpp:: +PASSED: + REQUIRE_THAT( 1.f, WithinAbs(1.f, 0.5) || WithinULP(1.f, 1) ) +with expansion: + 1.0f ( is within 0.5 of 1.0 or is within 1 ULPs of 1.0f ) + +Matchers.tests.cpp:: +PASSED: + REQUIRE_THAT( 1.f, WithinAbs(2.f, 0.5) || WithinULP(1.f, 0) ) +with expansion: + 1.0f ( is within 0.5 of 2.0 or is within 0 ULPs of 1.0f ) + +Matchers.tests.cpp:: +PASSED: + REQUIRE_THAT( NAN, !(WithinAbs(NAN, 100) || WithinULP(NAN, 123)) ) +with expansion: + nanf not ( is within 100.0 of nan or is within 123 ULPs of nanf ) + +------------------------------------------------------------------------------- +Floating point matchers: float + Constructor validation +------------------------------------------------------------------------------- +Matchers.tests.cpp: +............................................................................... + +Matchers.tests.cpp:: +PASSED: + REQUIRE_NOTHROW( WithinAbs(1.f, 0.f) ) + +Matchers.tests.cpp:: +PASSED: + REQUIRE_THROWS_AS( WithinAbs(1.f, -1.f), std::domain_error ) + +Matchers.tests.cpp:: +PASSED: + REQUIRE_NOTHROW( WithinULP(1.f, 0) ) + +Matchers.tests.cpp:: +PASSED: + REQUIRE_THROWS_AS( WithinULP(1.f, -1), std::domain_error ) + +------------------------------------------------------------------------------- +Greater-than inequalities with different epsilons +------------------------------------------------------------------------------- +Approx.tests.cpp: +............................................................................... + +Approx.tests.cpp:: +PASSED: + REQUIRE( d >= Approx( 1.22 ) ) +with expansion: + 1.23 >= Approx( 1.22 ) + +Approx.tests.cpp:: +PASSED: + REQUIRE( d >= Approx( 1.23 ) ) +with expansion: + 1.23 >= Approx( 1.23 ) + +Approx.tests.cpp:: +PASSED: + REQUIRE_FALSE( d >= Approx( 1.24 ) ) +with expansion: + !(1.23 >= Approx( 1.24 )) + +Approx.tests.cpp:: +PASSED: + REQUIRE( d >= Approx( 1.24 ).epsilon(0.1) ) +with expansion: + 1.23 >= Approx( 1.24 ) + +------------------------------------------------------------------------------- +INFO and WARN do not abort tests +------------------------------------------------------------------------------- +Message.tests.cpp: +............................................................................... + +Message.tests.cpp:: +warning: + this is a message + this is a warning + + +No assertions in test case 'INFO and WARN do not abort tests' + +------------------------------------------------------------------------------- +INFO gets logged on failure +------------------------------------------------------------------------------- +Message.tests.cpp: +............................................................................... + +Message.tests.cpp:: FAILED: + REQUIRE( a == 1 ) +with expansion: + 2 == 1 +with messages: + this message should be logged + so should this + +------------------------------------------------------------------------------- +INFO gets logged on failure, even if captured before successful assertions +------------------------------------------------------------------------------- +Message.tests.cpp: +............................................................................... + +Message.tests.cpp:: +PASSED: + CHECK( a == 2 ) +with expansion: + 2 == 2 +with message: + this message may be logged later + +Message.tests.cpp:: FAILED: + CHECK( a == 1 ) +with expansion: + 2 == 1 +with messages: + this message may be logged later + this message should be logged + +Message.tests.cpp:: FAILED: + CHECK( a == 0 ) +with expansion: + 2 == 0 +with messages: + this message may be logged later + this message should be logged + and this, but later + +Message.tests.cpp:: +PASSED: + CHECK( a == 2 ) +with expansion: + 2 == 2 +with messages: + this message may be logged later + this message should be logged + and this, but later + but not this + +------------------------------------------------------------------------------- +INFO is reset for each loop +------------------------------------------------------------------------------- +Message.tests.cpp: +............................................................................... + +Message.tests.cpp:: +PASSED: + REQUIRE( i < 10 ) +with expansion: + 0 < 10 +with messages: + current counter 0 + i := 0 + +Message.tests.cpp:: +PASSED: + REQUIRE( i < 10 ) +with expansion: + 1 < 10 +with messages: + current counter 1 + i := 1 + +Message.tests.cpp:: +PASSED: + REQUIRE( i < 10 ) +with expansion: + 2 < 10 +with messages: + current counter 2 + i := 2 + +Message.tests.cpp:: +PASSED: + REQUIRE( i < 10 ) +with expansion: + 3 < 10 +with messages: + current counter 3 + i := 3 + +Message.tests.cpp:: +PASSED: + REQUIRE( i < 10 ) +with expansion: + 4 < 10 +with messages: + current counter 4 + i := 4 + +Message.tests.cpp:: +PASSED: + REQUIRE( i < 10 ) +with expansion: + 5 < 10 +with messages: + current counter 5 + i := 5 + +Message.tests.cpp:: +PASSED: + REQUIRE( i < 10 ) +with expansion: + 6 < 10 +with messages: + current counter 6 + i := 6 + +Message.tests.cpp:: +PASSED: + REQUIRE( i < 10 ) +with expansion: + 7 < 10 +with messages: + current counter 7 + i := 7 + +Message.tests.cpp:: +PASSED: + REQUIRE( i < 10 ) +with expansion: + 8 < 10 +with messages: + current counter 8 + i := 8 + +Message.tests.cpp:: +PASSED: + REQUIRE( i < 10 ) +with expansion: + 9 < 10 +with messages: + current counter 9 + i := 9 + +Message.tests.cpp:: FAILED: + REQUIRE( i < 10 ) +with expansion: + 10 < 10 +with messages: + current counter 10 + i := 10 + +------------------------------------------------------------------------------- +Inequality checks that should fail +------------------------------------------------------------------------------- +Condition.tests.cpp: +............................................................................... + +Condition.tests.cpp:: FAILED: + CHECK( data.int_seven != 7 ) +with expansion: + 7 != 7 + +Condition.tests.cpp:: FAILED: + CHECK( data.float_nine_point_one != Approx( 9.1f ) ) +with expansion: + 9.1f != Approx( 9.1000003815 ) + +Condition.tests.cpp:: FAILED: + CHECK( data.double_pi != Approx( 3.1415926535 ) ) +with expansion: + 3.1415926535 != Approx( 3.1415926535 ) + +Condition.tests.cpp:: FAILED: + CHECK( data.str_hello != "hello" ) +with expansion: + "hello" != "hello" + +Condition.tests.cpp:: FAILED: + CHECK( data.str_hello.size() != 5 ) +with expansion: + 5 != 5 + +------------------------------------------------------------------------------- +Inequality checks that should succeed +------------------------------------------------------------------------------- +Condition.tests.cpp: +............................................................................... + +Condition.tests.cpp:: +PASSED: + REQUIRE( data.int_seven != 6 ) +with expansion: + 7 != 6 + +Condition.tests.cpp:: +PASSED: + REQUIRE( data.int_seven != 8 ) +with expansion: + 7 != 8 + +Condition.tests.cpp:: +PASSED: + REQUIRE( data.float_nine_point_one != Approx( 9.11f ) ) +with expansion: + 9.1f != Approx( 9.1099996567 ) + +Condition.tests.cpp:: +PASSED: + REQUIRE( data.float_nine_point_one != Approx( 9.0f ) ) +with expansion: + 9.1f != Approx( 9.0 ) + +Condition.tests.cpp:: +PASSED: + REQUIRE( data.float_nine_point_one != Approx( 1 ) ) +with expansion: + 9.1f != Approx( 1.0 ) + +Condition.tests.cpp:: +PASSED: + REQUIRE( data.float_nine_point_one != Approx( 0 ) ) +with expansion: + 9.1f != Approx( 0.0 ) + +Condition.tests.cpp:: +PASSED: + REQUIRE( data.double_pi != Approx( 3.1415 ) ) +with expansion: + 3.1415926535 != Approx( 3.1415 ) + +Condition.tests.cpp:: +PASSED: + REQUIRE( data.str_hello != "goodbye" ) +with expansion: + "hello" != "goodbye" + +Condition.tests.cpp:: +PASSED: + REQUIRE( data.str_hello != "hell" ) +with expansion: + "hello" != "hell" + +Condition.tests.cpp:: +PASSED: + REQUIRE( data.str_hello != "hello1" ) +with expansion: + "hello" != "hello1" + +Condition.tests.cpp:: +PASSED: + REQUIRE( data.str_hello.size() != 6 ) +with expansion: + 5 != 6 + +------------------------------------------------------------------------------- +Less-than inequalities with different epsilons +------------------------------------------------------------------------------- +Approx.tests.cpp: +............................................................................... + +Approx.tests.cpp:: +PASSED: + REQUIRE( d <= Approx( 1.24 ) ) +with expansion: + 1.23 <= Approx( 1.24 ) + +Approx.tests.cpp:: +PASSED: + REQUIRE( d <= Approx( 1.23 ) ) +with expansion: + 1.23 <= Approx( 1.23 ) + +Approx.tests.cpp:: +PASSED: + REQUIRE_FALSE( d <= Approx( 1.22 ) ) +with expansion: + !(1.23 <= Approx( 1.22 )) + +Approx.tests.cpp:: +PASSED: + REQUIRE( d <= Approx( 1.22 ).epsilon(0.1) ) +with expansion: + 1.23 <= Approx( 1.22 ) + +------------------------------------------------------------------------------- +ManuallyRegistered +------------------------------------------------------------------------------- +Misc.tests.cpp: +............................................................................... + +Misc.tests.cpp:: +PASSED: +with message: + was called + +------------------------------------------------------------------------------- +Matchers can be (AllOf) composed with the && operator +------------------------------------------------------------------------------- +Matchers.tests.cpp: +............................................................................... + +Matchers.tests.cpp:: +PASSED: + CHECK_THAT( testStringForMatching(), Contains("string") && Contains("abc") && Contains("substring") && Contains("contains") ) +with expansion: + "this string contains 'abc' as a substring" ( contains: "string" and + contains: "abc" and contains: "substring" and contains: "contains" ) + +------------------------------------------------------------------------------- +Matchers can be (AnyOf) composed with the || operator +------------------------------------------------------------------------------- +Matchers.tests.cpp: +............................................................................... + +Matchers.tests.cpp:: +PASSED: + CHECK_THAT( testStringForMatching(), Contains("string") || Contains("different") || Contains("random") ) +with expansion: + "this string contains 'abc' as a substring" ( contains: "string" or contains: + "different" or contains: "random" ) + +Matchers.tests.cpp:: +PASSED: + CHECK_THAT( testStringForMatching2(), Contains("string") || Contains("different") || Contains("random") ) +with expansion: + "some completely different text that contains one common word" ( contains: + "string" or contains: "different" or contains: "random" ) + +------------------------------------------------------------------------------- +Matchers can be composed with both && and || +------------------------------------------------------------------------------- +Matchers.tests.cpp: +............................................................................... + +Matchers.tests.cpp:: +PASSED: + CHECK_THAT( testStringForMatching(), (Contains("string") || Contains("different")) && Contains("substring") ) +with expansion: + "this string contains 'abc' as a substring" ( ( contains: "string" or + contains: "different" ) and contains: "substring" ) + +------------------------------------------------------------------------------- +Matchers can be composed with both && and || - failing +------------------------------------------------------------------------------- +Matchers.tests.cpp: +............................................................................... + +Matchers.tests.cpp:: FAILED: + CHECK_THAT( testStringForMatching(), (Contains("string") || Contains("different")) && Contains("random") ) +with expansion: + "this string contains 'abc' as a substring" ( ( contains: "string" or + contains: "different" ) and contains: "random" ) + +------------------------------------------------------------------------------- +Matchers can be negated (Not) with the ! operator +------------------------------------------------------------------------------- +Matchers.tests.cpp: +............................................................................... + +Matchers.tests.cpp:: +PASSED: + CHECK_THAT( testStringForMatching(), !Contains("different") ) +with expansion: + "this string contains 'abc' as a substring" not contains: "different" + +------------------------------------------------------------------------------- +Matchers can be negated (Not) with the ! operator - failing +------------------------------------------------------------------------------- +Matchers.tests.cpp: +............................................................................... + +Matchers.tests.cpp:: FAILED: + CHECK_THAT( testStringForMatching(), !Contains("substring") ) +with expansion: + "this string contains 'abc' as a substring" not contains: "substring" + +------------------------------------------------------------------------------- +Mismatching exception messages failing the test +------------------------------------------------------------------------------- +Exception.tests.cpp: +............................................................................... + +Exception.tests.cpp:: +PASSED: + REQUIRE_THROWS_WITH( thisThrows(), "expected exception" ) +with expansion: + "expected exception" equals: "expected exception" + +Exception.tests.cpp:: FAILED: + REQUIRE_THROWS_WITH( thisThrows(), "should fail" ) +with expansion: + "expected exception" equals: "should fail" + +------------------------------------------------------------------------------- +Nice descriptive name +------------------------------------------------------------------------------- +Misc.tests.cpp: +............................................................................... + +Misc.tests.cpp:: +warning: + This one ran + + +No assertions in test case 'Nice descriptive name' + +------------------------------------------------------------------------------- +Non-std exceptions can be translated +------------------------------------------------------------------------------- +Exception.tests.cpp: +............................................................................... + +Exception.tests.cpp:: FAILED: +due to unexpected exception with message: + custom exception + +------------------------------------------------------------------------------- +Objects that evaluated in boolean contexts can be checked +------------------------------------------------------------------------------- +Tricky.tests.cpp: +............................................................................... + +Tricky.tests.cpp:: +PASSED: + CHECK( True ) +with expansion: + {?} + +Tricky.tests.cpp:: +PASSED: + CHECK( !False ) +with expansion: + true + +Tricky.tests.cpp:: +PASSED: + CHECK_FALSE( False ) +with expansion: + !{?} + +------------------------------------------------------------------------------- +Ordering comparison checks that should fail +------------------------------------------------------------------------------- +Condition.tests.cpp: +............................................................................... + +Condition.tests.cpp:: FAILED: + CHECK( data.int_seven > 7 ) +with expansion: + 7 > 7 + +Condition.tests.cpp:: FAILED: + CHECK( data.int_seven < 7 ) +with expansion: + 7 < 7 + +Condition.tests.cpp:: FAILED: + CHECK( data.int_seven > 8 ) +with expansion: + 7 > 8 + +Condition.tests.cpp:: FAILED: + CHECK( data.int_seven < 6 ) +with expansion: + 7 < 6 + +Condition.tests.cpp:: FAILED: + CHECK( data.int_seven < 0 ) +with expansion: + 7 < 0 + +Condition.tests.cpp:: FAILED: + CHECK( data.int_seven < -1 ) +with expansion: + 7 < -1 + +Condition.tests.cpp:: FAILED: + CHECK( data.int_seven >= 8 ) +with expansion: + 7 >= 8 + +Condition.tests.cpp:: FAILED: + CHECK( data.int_seven <= 6 ) +with expansion: + 7 <= 6 + +Condition.tests.cpp:: FAILED: + CHECK( data.float_nine_point_one < 9 ) +with expansion: + 9.1f < 9 + +Condition.tests.cpp:: FAILED: + CHECK( data.float_nine_point_one > 10 ) +with expansion: + 9.1f > 10 + +Condition.tests.cpp:: FAILED: + CHECK( data.float_nine_point_one > 9.2 ) +with expansion: + 9.1f > 9.2 + +Condition.tests.cpp:: FAILED: + CHECK( data.str_hello > "hello" ) +with expansion: + "hello" > "hello" + +Condition.tests.cpp:: FAILED: + CHECK( data.str_hello < "hello" ) +with expansion: + "hello" < "hello" + +Condition.tests.cpp:: FAILED: + CHECK( data.str_hello > "hellp" ) +with expansion: + "hello" > "hellp" + +Condition.tests.cpp:: FAILED: + CHECK( data.str_hello > "z" ) +with expansion: + "hello" > "z" + +Condition.tests.cpp:: FAILED: + CHECK( data.str_hello < "hellm" ) +with expansion: + "hello" < "hellm" + +Condition.tests.cpp:: FAILED: + CHECK( data.str_hello < "a" ) +with expansion: + "hello" < "a" + +Condition.tests.cpp:: FAILED: + CHECK( data.str_hello >= "z" ) +with expansion: + "hello" >= "z" + +Condition.tests.cpp:: FAILED: + CHECK( data.str_hello <= "a" ) +with expansion: + "hello" <= "a" + +------------------------------------------------------------------------------- +Ordering comparison checks that should succeed +------------------------------------------------------------------------------- +Condition.tests.cpp: +............................................................................... + +Condition.tests.cpp:: +PASSED: + REQUIRE( data.int_seven < 8 ) +with expansion: + 7 < 8 + +Condition.tests.cpp:: +PASSED: + REQUIRE( data.int_seven > 6 ) +with expansion: + 7 > 6 + +Condition.tests.cpp:: +PASSED: + REQUIRE( data.int_seven > 0 ) +with expansion: + 7 > 0 + +Condition.tests.cpp:: +PASSED: + REQUIRE( data.int_seven > -1 ) +with expansion: + 7 > -1 + +Condition.tests.cpp:: +PASSED: + REQUIRE( data.int_seven >= 7 ) +with expansion: + 7 >= 7 + +Condition.tests.cpp:: +PASSED: + REQUIRE( data.int_seven >= 6 ) +with expansion: + 7 >= 6 + +Condition.tests.cpp:: +PASSED: + REQUIRE( data.int_seven <= 7 ) +with expansion: + 7 <= 7 + +Condition.tests.cpp:: +PASSED: + REQUIRE( data.int_seven <= 8 ) +with expansion: + 7 <= 8 + +Condition.tests.cpp:: +PASSED: + REQUIRE( data.float_nine_point_one > 9 ) +with expansion: + 9.1f > 9 + +Condition.tests.cpp:: +PASSED: + REQUIRE( data.float_nine_point_one < 10 ) +with expansion: + 9.1f < 10 + +Condition.tests.cpp:: +PASSED: + REQUIRE( data.float_nine_point_one < 9.2 ) +with expansion: + 9.1f < 9.2 + +Condition.tests.cpp:: +PASSED: + REQUIRE( data.str_hello <= "hello" ) +with expansion: + "hello" <= "hello" + +Condition.tests.cpp:: +PASSED: + REQUIRE( data.str_hello >= "hello" ) +with expansion: + "hello" >= "hello" + +Condition.tests.cpp:: +PASSED: + REQUIRE( data.str_hello < "hellp" ) +with expansion: + "hello" < "hellp" + +Condition.tests.cpp:: +PASSED: + REQUIRE( data.str_hello < "zebra" ) +with expansion: + "hello" < "zebra" + +Condition.tests.cpp:: +PASSED: + REQUIRE( data.str_hello > "hellm" ) +with expansion: + "hello" > "hellm" + +Condition.tests.cpp:: +PASSED: + REQUIRE( data.str_hello > "a" ) +with expansion: + "hello" > "a" + +------------------------------------------------------------------------------- +Output from all sections is reported + one +------------------------------------------------------------------------------- +Message.tests.cpp: +............................................................................... + +Message.tests.cpp:: FAILED: +explicitly with message: + Message from section one + +------------------------------------------------------------------------------- +Output from all sections is reported + two +------------------------------------------------------------------------------- +Message.tests.cpp: +............................................................................... + +Message.tests.cpp:: FAILED: +explicitly with message: + Message from section two + +------------------------------------------------------------------------------- +Parse test names and tags + Empty test spec should have no filters +------------------------------------------------------------------------------- +CmdLine.tests.cpp: +............................................................................... + +CmdLine.tests.cpp:: +PASSED: + CHECK( spec.hasFilters() == false ) +with expansion: + false == false + +CmdLine.tests.cpp:: +PASSED: + CHECK( spec.matches( tcA ) == false ) +with expansion: + false == false + +CmdLine.tests.cpp:: +PASSED: + CHECK( spec.matches( tcB ) == false ) +with expansion: + false == false + +------------------------------------------------------------------------------- +Parse test names and tags + Test spec from empty string should have no filters +------------------------------------------------------------------------------- +CmdLine.tests.cpp: +............................................................................... + +CmdLine.tests.cpp:: +PASSED: + CHECK( spec.hasFilters() == false ) +with expansion: + false == false + +CmdLine.tests.cpp:: +PASSED: + CHECK( spec.matches(tcA ) == false ) +with expansion: + false == false + +CmdLine.tests.cpp:: +PASSED: + CHECK( spec.matches( tcB ) == false ) +with expansion: + false == false + +------------------------------------------------------------------------------- +Parse test names and tags + Test spec from just a comma should have no filters +------------------------------------------------------------------------------- +CmdLine.tests.cpp: +............................................................................... + +CmdLine.tests.cpp:: +PASSED: + CHECK( spec.hasFilters() == false ) +with expansion: + false == false + +CmdLine.tests.cpp:: +PASSED: + CHECK( spec.matches( tcA ) == false ) +with expansion: + false == false + +CmdLine.tests.cpp:: +PASSED: + CHECK( spec.matches( tcB ) == false ) +with expansion: + false == false + +------------------------------------------------------------------------------- +Parse test names and tags + Test spec from name should have one filter +------------------------------------------------------------------------------- +CmdLine.tests.cpp: +............................................................................... + +CmdLine.tests.cpp:: +PASSED: + CHECK( spec.hasFilters() == true ) +with expansion: + true == true + +CmdLine.tests.cpp:: +PASSED: + CHECK( spec.matches( tcA ) == false ) +with expansion: + false == false + +CmdLine.tests.cpp:: +PASSED: + CHECK( spec.matches( tcB ) == true ) +with expansion: + true == true + +------------------------------------------------------------------------------- +Parse test names and tags + Test spec from quoted name should have one filter +------------------------------------------------------------------------------- +CmdLine.tests.cpp: +............................................................................... + +CmdLine.tests.cpp:: +PASSED: + CHECK( spec.hasFilters() == true ) +with expansion: + true == true + +CmdLine.tests.cpp:: +PASSED: + CHECK( spec.matches( tcA ) == false ) +with expansion: + false == false + +CmdLine.tests.cpp:: +PASSED: + CHECK( spec.matches( tcB ) == true ) +with expansion: + true == true + +------------------------------------------------------------------------------- +Parse test names and tags + Test spec from name should have one filter +------------------------------------------------------------------------------- +CmdLine.tests.cpp: +............................................................................... + +CmdLine.tests.cpp:: +PASSED: + CHECK( spec.hasFilters() == true ) +with expansion: + true == true + +CmdLine.tests.cpp:: +PASSED: + CHECK( spec.matches( tcA ) == false ) +with expansion: + false == false + +CmdLine.tests.cpp:: +PASSED: + CHECK( spec.matches( tcB ) == true ) +with expansion: + true == true + +CmdLine.tests.cpp:: +PASSED: + CHECK( spec.matches( tcC ) == false ) +with expansion: + false == false + +------------------------------------------------------------------------------- +Parse test names and tags + Wildcard at the start +------------------------------------------------------------------------------- +CmdLine.tests.cpp: +............................................................................... + +CmdLine.tests.cpp:: +PASSED: + CHECK( spec.hasFilters() == true ) +with expansion: + true == true + +CmdLine.tests.cpp:: +PASSED: + CHECK( spec.matches( tcA ) == false ) +with expansion: + false == false + +CmdLine.tests.cpp:: +PASSED: + CHECK( spec.matches( tcB ) == false ) +with expansion: + false == false + +CmdLine.tests.cpp:: +PASSED: + CHECK( spec.matches( tcC ) == true ) +with expansion: + true == true + +CmdLine.tests.cpp:: +PASSED: + CHECK( spec.matches( tcD ) == false ) +with expansion: + false == false + +CmdLine.tests.cpp:: +PASSED: + CHECK( parseTestSpec( "*a" ).matches( tcA ) == true ) +with expansion: + true == true + +------------------------------------------------------------------------------- +Parse test names and tags + Wildcard at the end +------------------------------------------------------------------------------- +CmdLine.tests.cpp: +............................................................................... + +CmdLine.tests.cpp:: +PASSED: + CHECK( spec.hasFilters() == true ) +with expansion: + true == true + +CmdLine.tests.cpp:: +PASSED: + CHECK( spec.matches( tcA ) == false ) +with expansion: + false == false + +CmdLine.tests.cpp:: +PASSED: + CHECK( spec.matches( tcB ) == false ) +with expansion: + false == false + +CmdLine.tests.cpp:: +PASSED: + CHECK( spec.matches( tcC ) == true ) +with expansion: + true == true + +CmdLine.tests.cpp:: +PASSED: + CHECK( spec.matches( tcD ) == false ) +with expansion: + false == false + +CmdLine.tests.cpp:: +PASSED: + CHECK( parseTestSpec( "a*" ).matches( tcA ) == true ) +with expansion: + true == true + +------------------------------------------------------------------------------- +Parse test names and tags + Wildcard at both ends +------------------------------------------------------------------------------- +CmdLine.tests.cpp: +............................................................................... + +CmdLine.tests.cpp:: +PASSED: + CHECK( spec.hasFilters() == true ) +with expansion: + true == true + +CmdLine.tests.cpp:: +PASSED: + CHECK( spec.matches( tcA ) == false ) +with expansion: + false == false + +CmdLine.tests.cpp:: +PASSED: + CHECK( spec.matches( tcB ) == false ) +with expansion: + false == false + +CmdLine.tests.cpp:: +PASSED: + CHECK( spec.matches( tcC ) == true ) +with expansion: + true == true + +CmdLine.tests.cpp:: +PASSED: + CHECK( spec.matches( tcD ) == true ) +with expansion: + true == true + +CmdLine.tests.cpp:: +PASSED: + CHECK( parseTestSpec( "*a*" ).matches( tcA ) == true ) +with expansion: + true == true + +------------------------------------------------------------------------------- +Parse test names and tags + Redundant wildcard at the start +------------------------------------------------------------------------------- +CmdLine.tests.cpp: +............................................................................... + +CmdLine.tests.cpp:: +PASSED: + CHECK( spec.hasFilters() == true ) +with expansion: + true == true + +CmdLine.tests.cpp:: +PASSED: + CHECK( spec.matches( tcA ) == true ) +with expansion: + true == true + +CmdLine.tests.cpp:: +PASSED: + CHECK( spec.matches( tcB ) == false ) +with expansion: + false == false + +------------------------------------------------------------------------------- +Parse test names and tags + Redundant wildcard at the end +------------------------------------------------------------------------------- +CmdLine.tests.cpp: +............................................................................... + +CmdLine.tests.cpp:: +PASSED: + CHECK( spec.hasFilters() == true ) +with expansion: + true == true + +CmdLine.tests.cpp:: +PASSED: + CHECK( spec.matches( tcA ) == true ) +with expansion: + true == true + +CmdLine.tests.cpp:: +PASSED: + CHECK( spec.matches( tcB ) == false ) +with expansion: + false == false + +------------------------------------------------------------------------------- +Parse test names and tags + Redundant wildcard at both ends +------------------------------------------------------------------------------- +CmdLine.tests.cpp: +............................................................................... + +CmdLine.tests.cpp:: +PASSED: + CHECK( spec.hasFilters() == true ) +with expansion: + true == true + +CmdLine.tests.cpp:: +PASSED: + CHECK( spec.matches( tcA ) == true ) +with expansion: + true == true + +CmdLine.tests.cpp:: +PASSED: + CHECK( spec.matches( tcB ) == false ) +with expansion: + false == false + +------------------------------------------------------------------------------- +Parse test names and tags + Wildcard at both ends, redundant at start +------------------------------------------------------------------------------- +CmdLine.tests.cpp: +............................................................................... + +CmdLine.tests.cpp:: +PASSED: + CHECK( spec.hasFilters() == true ) +with expansion: + true == true + +CmdLine.tests.cpp:: +PASSED: + CHECK( spec.matches( tcA ) == false ) +with expansion: + false == false + +CmdLine.tests.cpp:: +PASSED: + CHECK( spec.matches( tcB ) == false ) +with expansion: + false == false + +CmdLine.tests.cpp:: +PASSED: + CHECK( spec.matches( tcC ) == true ) +with expansion: + true == true + +CmdLine.tests.cpp:: +PASSED: + CHECK( spec.matches( tcD ) == true ) +with expansion: + true == true + +------------------------------------------------------------------------------- +Parse test names and tags + Just wildcard +------------------------------------------------------------------------------- +CmdLine.tests.cpp: +............................................................................... + +CmdLine.tests.cpp:: +PASSED: + CHECK( spec.hasFilters() == true ) +with expansion: + true == true + +CmdLine.tests.cpp:: +PASSED: + CHECK( spec.matches( tcA ) == true ) +with expansion: + true == true + +CmdLine.tests.cpp:: +PASSED: + CHECK( spec.matches( tcB ) == true ) +with expansion: + true == true + +CmdLine.tests.cpp:: +PASSED: + CHECK( spec.matches( tcC ) == true ) +with expansion: + true == true + +CmdLine.tests.cpp:: +PASSED: + CHECK( spec.matches( tcD ) == true ) +with expansion: + true == true + +------------------------------------------------------------------------------- +Parse test names and tags + Single tag +------------------------------------------------------------------------------- +CmdLine.tests.cpp: +............................................................................... + +CmdLine.tests.cpp:: +PASSED: + CHECK( spec.hasFilters() == true ) +with expansion: + true == true + +CmdLine.tests.cpp:: +PASSED: + CHECK( spec.matches( tcA ) == false ) +with expansion: + false == false + +CmdLine.tests.cpp:: +PASSED: + CHECK( spec.matches( tcB ) == true ) +with expansion: + true == true + +CmdLine.tests.cpp:: +PASSED: + CHECK( spec.matches( tcC ) == false ) +with expansion: + false == false + +------------------------------------------------------------------------------- +Parse test names and tags + Single tag, two matches +------------------------------------------------------------------------------- +CmdLine.tests.cpp: +............................................................................... + +CmdLine.tests.cpp:: +PASSED: + CHECK( spec.hasFilters() == true ) +with expansion: + true == true + +CmdLine.tests.cpp:: +PASSED: + CHECK( spec.matches( tcA ) == false ) +with expansion: + false == false + +CmdLine.tests.cpp:: +PASSED: + CHECK( spec.matches( tcB ) == true ) +with expansion: + true == true + +CmdLine.tests.cpp:: +PASSED: + CHECK( spec.matches( tcC ) == true ) +with expansion: + true == true + +------------------------------------------------------------------------------- +Parse test names and tags + Two tags +------------------------------------------------------------------------------- +CmdLine.tests.cpp: +............................................................................... + +CmdLine.tests.cpp:: +PASSED: + CHECK( spec.hasFilters() == true ) +with expansion: + true == true + +CmdLine.tests.cpp:: +PASSED: + CHECK( spec.matches( tcA ) == false ) +with expansion: + false == false + +CmdLine.tests.cpp:: +PASSED: + CHECK( spec.matches( tcB ) == false ) +with expansion: + false == false + +CmdLine.tests.cpp:: +PASSED: + CHECK( spec.matches( tcC ) == true ) +with expansion: + true == true + +------------------------------------------------------------------------------- +Parse test names and tags + Two tags, spare separated +------------------------------------------------------------------------------- +CmdLine.tests.cpp: +............................................................................... + +CmdLine.tests.cpp:: +PASSED: + CHECK( spec.hasFilters() == true ) +with expansion: + true == true + +CmdLine.tests.cpp:: +PASSED: + CHECK( spec.matches( tcA ) == false ) +with expansion: + false == false + +CmdLine.tests.cpp:: +PASSED: + CHECK( spec.matches( tcB ) == false ) +with expansion: + false == false + +CmdLine.tests.cpp:: +PASSED: + CHECK( spec.matches( tcC ) == true ) +with expansion: + true == true + +------------------------------------------------------------------------------- +Parse test names and tags + Wildcarded name and tag +------------------------------------------------------------------------------- +CmdLine.tests.cpp: +............................................................................... + +CmdLine.tests.cpp:: +PASSED: + CHECK( spec.hasFilters() == true ) +with expansion: + true == true + +CmdLine.tests.cpp:: +PASSED: + CHECK( spec.matches( tcA ) == false ) +with expansion: + false == false + +CmdLine.tests.cpp:: +PASSED: + CHECK( spec.matches( tcB ) == false ) +with expansion: + false == false + +CmdLine.tests.cpp:: +PASSED: + CHECK( spec.matches( tcC ) == true ) +with expansion: + true == true + +CmdLine.tests.cpp:: +PASSED: + CHECK( spec.matches( tcD ) == false ) +with expansion: + false == false + +------------------------------------------------------------------------------- +Parse test names and tags + Single tag exclusion +------------------------------------------------------------------------------- +CmdLine.tests.cpp: +............................................................................... + +CmdLine.tests.cpp:: +PASSED: + CHECK( spec.hasFilters() == true ) +with expansion: + true == true + +CmdLine.tests.cpp:: +PASSED: + CHECK( spec.matches( tcA ) == true ) +with expansion: + true == true + +CmdLine.tests.cpp:: +PASSED: + CHECK( spec.matches( tcB ) == false ) +with expansion: + false == false + +CmdLine.tests.cpp:: +PASSED: + CHECK( spec.matches( tcC ) == true ) +with expansion: + true == true + +------------------------------------------------------------------------------- +Parse test names and tags + One tag exclusion and one tag inclusion +------------------------------------------------------------------------------- +CmdLine.tests.cpp: +............................................................................... + +CmdLine.tests.cpp:: +PASSED: + CHECK( spec.hasFilters() == true ) +with expansion: + true == true + +CmdLine.tests.cpp:: +PASSED: + CHECK( spec.matches( tcA ) == false ) +with expansion: + false == false + +CmdLine.tests.cpp:: +PASSED: + CHECK( spec.matches( tcB ) == true ) +with expansion: + true == true + +CmdLine.tests.cpp:: +PASSED: + CHECK( spec.matches( tcC ) == false ) +with expansion: + false == false + +------------------------------------------------------------------------------- +Parse test names and tags + One tag exclusion and one wldcarded name inclusion +------------------------------------------------------------------------------- +CmdLine.tests.cpp: +............................................................................... + +CmdLine.tests.cpp:: +PASSED: + CHECK( spec.hasFilters() == true ) +with expansion: + true == true + +CmdLine.tests.cpp:: +PASSED: + CHECK( spec.matches( tcA ) == false ) +with expansion: + false == false + +CmdLine.tests.cpp:: +PASSED: + CHECK( spec.matches( tcB ) == false ) +with expansion: + false == false + +CmdLine.tests.cpp:: +PASSED: + CHECK( spec.matches( tcC ) == false ) +with expansion: + false == false + +CmdLine.tests.cpp:: +PASSED: + CHECK( spec.matches( tcD ) == true ) +with expansion: + true == true + +------------------------------------------------------------------------------- +Parse test names and tags + One tag exclusion, using exclude:, and one wldcarded name inclusion +------------------------------------------------------------------------------- +CmdLine.tests.cpp: +............................................................................... + +CmdLine.tests.cpp:: +PASSED: + CHECK( spec.hasFilters() == true ) +with expansion: + true == true + +CmdLine.tests.cpp:: +PASSED: + CHECK( spec.matches( tcA ) == false ) +with expansion: + false == false + +CmdLine.tests.cpp:: +PASSED: + CHECK( spec.matches( tcB ) == false ) +with expansion: + false == false + +CmdLine.tests.cpp:: +PASSED: + CHECK( spec.matches( tcC ) == false ) +with expansion: + false == false + +CmdLine.tests.cpp:: +PASSED: + CHECK( spec.matches( tcD ) == true ) +with expansion: + true == true + +------------------------------------------------------------------------------- +Parse test names and tags + name exclusion +------------------------------------------------------------------------------- +CmdLine.tests.cpp: +............................................................................... + +CmdLine.tests.cpp:: +PASSED: + CHECK( spec.hasFilters() == true ) +with expansion: + true == true + +CmdLine.tests.cpp:: +PASSED: + CHECK( spec.matches( tcA ) == true ) +with expansion: + true == true + +CmdLine.tests.cpp:: +PASSED: + CHECK( spec.matches( tcB ) == false ) +with expansion: + false == false + +CmdLine.tests.cpp:: +PASSED: + CHECK( spec.matches( tcC ) == true ) +with expansion: + true == true + +CmdLine.tests.cpp:: +PASSED: + CHECK( spec.matches( tcD ) == true ) +with expansion: + true == true + +------------------------------------------------------------------------------- +Parse test names and tags + wildcarded name exclusion +------------------------------------------------------------------------------- +CmdLine.tests.cpp: +............................................................................... + +CmdLine.tests.cpp:: +PASSED: + CHECK( spec.hasFilters() == true ) +with expansion: + true == true + +CmdLine.tests.cpp:: +PASSED: + CHECK( spec.matches( tcA ) == true ) +with expansion: + true == true + +CmdLine.tests.cpp:: +PASSED: + CHECK( spec.matches( tcB ) == true ) +with expansion: + true == true + +CmdLine.tests.cpp:: +PASSED: + CHECK( spec.matches( tcC ) == false ) +with expansion: + false == false + +CmdLine.tests.cpp:: +PASSED: + CHECK( spec.matches( tcD ) == false ) +with expansion: + false == false + +------------------------------------------------------------------------------- +Parse test names and tags + wildcarded name exclusion with tag inclusion +------------------------------------------------------------------------------- +CmdLine.tests.cpp: +............................................................................... + +CmdLine.tests.cpp:: +PASSED: + CHECK( spec.hasFilters() == true ) +with expansion: + true == true + +CmdLine.tests.cpp:: +PASSED: + CHECK( spec.matches( tcA ) == true ) +with expansion: + true == true + +CmdLine.tests.cpp:: +PASSED: + CHECK( spec.matches( tcB ) == true ) +with expansion: + true == true + +CmdLine.tests.cpp:: +PASSED: + CHECK( spec.matches( tcC ) == true ) +with expansion: + true == true + +CmdLine.tests.cpp:: +PASSED: + CHECK( spec.matches( tcD ) == false ) +with expansion: + false == false + +------------------------------------------------------------------------------- +Parse test names and tags + wildcarded name exclusion, using exclude:, with tag inclusion +------------------------------------------------------------------------------- +CmdLine.tests.cpp: +............................................................................... + +CmdLine.tests.cpp:: +PASSED: + CHECK( spec.hasFilters() == true ) +with expansion: + true == true + +CmdLine.tests.cpp:: +PASSED: + CHECK( spec.matches( tcA ) == true ) +with expansion: + true == true + +CmdLine.tests.cpp:: +PASSED: + CHECK( spec.matches( tcB ) == true ) +with expansion: + true == true + +CmdLine.tests.cpp:: +PASSED: + CHECK( spec.matches( tcC ) == true ) +with expansion: + true == true + +CmdLine.tests.cpp:: +PASSED: + CHECK( spec.matches( tcD ) == false ) +with expansion: + false == false + +------------------------------------------------------------------------------- +Parse test names and tags + two wildcarded names +------------------------------------------------------------------------------- +CmdLine.tests.cpp: +............................................................................... + +CmdLine.tests.cpp:: +PASSED: + CHECK( spec.hasFilters() == true ) +with expansion: + true == true + +CmdLine.tests.cpp:: +PASSED: + CHECK( spec.matches( tcA ) == false ) +with expansion: + false == false + +CmdLine.tests.cpp:: +PASSED: + CHECK( spec.matches( tcB ) == false ) +with expansion: + false == false + +CmdLine.tests.cpp:: +PASSED: + CHECK( spec.matches( tcC ) == true ) +with expansion: + true == true + +CmdLine.tests.cpp:: +PASSED: + CHECK( spec.matches( tcD ) == false ) +with expansion: + false == false + +------------------------------------------------------------------------------- +Parse test names and tags + empty tag +------------------------------------------------------------------------------- +CmdLine.tests.cpp: +............................................................................... + +CmdLine.tests.cpp:: +PASSED: + CHECK( spec.hasFilters() == false ) +with expansion: + false == false + +CmdLine.tests.cpp:: +PASSED: + CHECK( spec.matches( tcA ) == false ) +with expansion: + false == false + +CmdLine.tests.cpp:: +PASSED: + CHECK( spec.matches( tcB ) == false ) +with expansion: + false == false + +CmdLine.tests.cpp:: +PASSED: + CHECK( spec.matches( tcC ) == false ) +with expansion: + false == false + +CmdLine.tests.cpp:: +PASSED: + CHECK( spec.matches( tcD ) == false ) +with expansion: + false == false + +------------------------------------------------------------------------------- +Parse test names and tags + empty quoted name +------------------------------------------------------------------------------- +CmdLine.tests.cpp: +............................................................................... + +CmdLine.tests.cpp:: +PASSED: + CHECK( spec.hasFilters() == false ) +with expansion: + false == false + +CmdLine.tests.cpp:: +PASSED: + CHECK( spec.matches( tcA ) == false ) +with expansion: + false == false + +CmdLine.tests.cpp:: +PASSED: + CHECK( spec.matches( tcB ) == false ) +with expansion: + false == false + +CmdLine.tests.cpp:: +PASSED: + CHECK( spec.matches( tcC ) == false ) +with expansion: + false == false + +CmdLine.tests.cpp:: +PASSED: + CHECK( spec.matches( tcD ) == false ) +with expansion: + false == false + +------------------------------------------------------------------------------- +Parse test names and tags + quoted string followed by tag exclusion +------------------------------------------------------------------------------- +CmdLine.tests.cpp: +............................................................................... + +CmdLine.tests.cpp:: +PASSED: + CHECK( spec.hasFilters() == true ) +with expansion: + true == true + +CmdLine.tests.cpp:: +PASSED: + CHECK( spec.matches( tcA ) == false ) +with expansion: + false == false + +CmdLine.tests.cpp:: +PASSED: + CHECK( spec.matches( tcB ) == false ) +with expansion: + false == false + +CmdLine.tests.cpp:: +PASSED: + CHECK( spec.matches( tcC ) == false ) +with expansion: + false == false + +CmdLine.tests.cpp:: +PASSED: + CHECK( spec.matches( tcD ) == true ) +with expansion: + true == true + +------------------------------------------------------------------------------- +Pointers can be compared to null +------------------------------------------------------------------------------- +Condition.tests.cpp: +............................................................................... + +Condition.tests.cpp:: +PASSED: + REQUIRE( p == 0 ) +with expansion: + 0 == 0 + +Condition.tests.cpp:: +PASSED: + REQUIRE( p == pNULL ) +with expansion: + 0 == 0 + +Condition.tests.cpp:: +PASSED: + REQUIRE( p != 0 ) +with expansion: + 0x != 0 + +Condition.tests.cpp:: +PASSED: + REQUIRE( cp != 0 ) +with expansion: + 0x != 0 + +Condition.tests.cpp:: +PASSED: + REQUIRE( cpc != 0 ) +with expansion: + 0x != 0 + +Condition.tests.cpp:: +PASSED: + REQUIRE( returnsNull() == 0 ) +with expansion: + {null string} == 0 + +Condition.tests.cpp:: +PASSED: + REQUIRE( returnsConstNull() == 0 ) +with expansion: + {null string} == 0 + +Condition.tests.cpp:: +PASSED: + REQUIRE( 0 != p ) +with expansion: + 0 != 0x + +------------------------------------------------------------------------------- +Process can be configured on command line + empty args don't cause a crash +------------------------------------------------------------------------------- +CmdLine.tests.cpp: +............................................................................... + +CmdLine.tests.cpp:: +PASSED: + CHECK( result ) +with expansion: + {?} + +CmdLine.tests.cpp:: +PASSED: + CHECK( config.processName == "" ) +with expansion: + "" == "" + +------------------------------------------------------------------------------- +Process can be configured on command line + default - no arguments +------------------------------------------------------------------------------- +CmdLine.tests.cpp: +............................................................................... + +CmdLine.tests.cpp:: +PASSED: + CHECK( result ) +with expansion: + {?} + +CmdLine.tests.cpp:: +PASSED: + CHECK( config.processName == "test" ) +with expansion: + "test" == "test" + +CmdLine.tests.cpp:: +PASSED: + CHECK( config.shouldDebugBreak == false ) +with expansion: + false == false + +CmdLine.tests.cpp:: +PASSED: + CHECK( config.abortAfter == -1 ) +with expansion: + -1 == -1 + +CmdLine.tests.cpp:: +PASSED: + CHECK( config.noThrow == false ) +with expansion: + false == false + +CmdLine.tests.cpp:: +PASSED: + CHECK( config.reporterName == "console" ) +with expansion: + "console" == "console" + +CmdLine.tests.cpp:: +PASSED: + CHECK_FALSE( cfg.hasTestFilters() ) +with expansion: + !false + +------------------------------------------------------------------------------- +Process can be configured on command line + test lists + Specify one test case using +------------------------------------------------------------------------------- +CmdLine.tests.cpp: +............................................................................... + +CmdLine.tests.cpp:: +PASSED: + CHECK( result ) +with expansion: + {?} + +CmdLine.tests.cpp:: +PASSED: + REQUIRE( cfg.hasTestFilters() ) +with expansion: + true + +CmdLine.tests.cpp:: +PASSED: + REQUIRE( cfg.testSpec().matches(fakeTestCase("notIncluded")) == false ) +with expansion: + false == false + +CmdLine.tests.cpp:: +PASSED: + REQUIRE( cfg.testSpec().matches(fakeTestCase("test1")) ) +with expansion: + true + +------------------------------------------------------------------------------- +Process can be configured on command line + test lists + Specify one test case exclusion using exclude: +------------------------------------------------------------------------------- +CmdLine.tests.cpp: +............................................................................... + +CmdLine.tests.cpp:: +PASSED: + CHECK( result ) +with expansion: + {?} + +CmdLine.tests.cpp:: +PASSED: + REQUIRE( cfg.hasTestFilters() ) +with expansion: + true + +CmdLine.tests.cpp:: +PASSED: + REQUIRE( cfg.testSpec().matches(fakeTestCase("test1")) == false ) +with expansion: + false == false + +CmdLine.tests.cpp:: +PASSED: + REQUIRE( cfg.testSpec().matches(fakeTestCase("alwaysIncluded")) ) +with expansion: + true + +------------------------------------------------------------------------------- +Process can be configured on command line + test lists + Specify one test case exclusion using ~ +------------------------------------------------------------------------------- +CmdLine.tests.cpp: +............................................................................... + +CmdLine.tests.cpp:: +PASSED: + CHECK( result ) +with expansion: + {?} + +CmdLine.tests.cpp:: +PASSED: + REQUIRE( cfg.hasTestFilters() ) +with expansion: + true + +CmdLine.tests.cpp:: +PASSED: + REQUIRE( cfg.testSpec().matches(fakeTestCase("test1")) == false ) +with expansion: + false == false + +CmdLine.tests.cpp:: +PASSED: + REQUIRE( cfg.testSpec().matches(fakeTestCase("alwaysIncluded")) ) +with expansion: + true + +------------------------------------------------------------------------------- +Process can be configured on command line + reporter + -r/console +------------------------------------------------------------------------------- +CmdLine.tests.cpp: +............................................................................... + +CmdLine.tests.cpp:: +PASSED: + CHECK( cli.parse({"test", "-r", "console"}) ) +with expansion: + {?} + +CmdLine.tests.cpp:: +PASSED: + REQUIRE( config.reporterName == "console" ) +with expansion: + "console" == "console" + +------------------------------------------------------------------------------- +Process can be configured on command line + reporter + -r/xml +------------------------------------------------------------------------------- +CmdLine.tests.cpp: +............................................................................... + +CmdLine.tests.cpp:: +PASSED: + CHECK( cli.parse({"test", "-r", "xml"}) ) +with expansion: + {?} + +CmdLine.tests.cpp:: +PASSED: + REQUIRE( config.reporterName == "xml" ) +with expansion: + "xml" == "xml" + +------------------------------------------------------------------------------- +Process can be configured on command line + reporter + --reporter/junit +------------------------------------------------------------------------------- +CmdLine.tests.cpp: +............................................................................... + +CmdLine.tests.cpp:: +PASSED: + CHECK( cli.parse({"test", "--reporter", "junit"}) ) +with expansion: + {?} + +CmdLine.tests.cpp:: +PASSED: + REQUIRE( config.reporterName == "junit" ) +with expansion: + "junit" == "junit" + +------------------------------------------------------------------------------- +Process can be configured on command line + reporter + Only one reporter is accepted +------------------------------------------------------------------------------- +CmdLine.tests.cpp: +............................................................................... + +CmdLine.tests.cpp:: +PASSED: + REQUIRE_FALSE( cli.parse({ "test", "-r", "xml", "-r", "junit" }) ) +with expansion: + !{?} + +------------------------------------------------------------------------------- +Process can be configured on command line + debugger + -b +------------------------------------------------------------------------------- +CmdLine.tests.cpp: +............................................................................... + +CmdLine.tests.cpp:: +PASSED: + CHECK( cli.parse({"test", "-b"}) ) +with expansion: + {?} + +CmdLine.tests.cpp:: +PASSED: + REQUIRE( config.shouldDebugBreak == true ) +with expansion: + true == true + +------------------------------------------------------------------------------- +Process can be configured on command line + debugger + --break +------------------------------------------------------------------------------- +CmdLine.tests.cpp: +............................................................................... + +CmdLine.tests.cpp:: +PASSED: + CHECK( cli.parse({"test", "--break"}) ) +with expansion: + {?} + +CmdLine.tests.cpp:: +PASSED: + REQUIRE( config.shouldDebugBreak ) +with expansion: + true + +------------------------------------------------------------------------------- +Process can be configured on command line + abort + -a aborts after first failure +------------------------------------------------------------------------------- +CmdLine.tests.cpp: +............................................................................... + +CmdLine.tests.cpp:: +PASSED: + CHECK( cli.parse({"test", "-a"}) ) +with expansion: + {?} + +CmdLine.tests.cpp:: +PASSED: + REQUIRE( config.abortAfter == 1 ) +with expansion: + 1 == 1 + +------------------------------------------------------------------------------- +Process can be configured on command line + abort + -x 2 aborts after two failures +------------------------------------------------------------------------------- +CmdLine.tests.cpp: +............................................................................... + +CmdLine.tests.cpp:: +PASSED: + CHECK( cli.parse({"test", "-x", "2"}) ) +with expansion: + {?} + +CmdLine.tests.cpp:: +PASSED: + REQUIRE( config.abortAfter == 2 ) +with expansion: + 2 == 2 + +------------------------------------------------------------------------------- +Process can be configured on command line + abort + -x must be numeric +------------------------------------------------------------------------------- +CmdLine.tests.cpp: +............................................................................... + +CmdLine.tests.cpp:: +PASSED: + CHECK( !result ) +with expansion: + true + +CmdLine.tests.cpp:: +PASSED: + REQUIRE_THAT( result.errorMessage(), Contains("convert") && Contains("oops") ) +with expansion: + "Unable to convert 'oops' to destination type" ( contains: "convert" and + contains: "oops" ) + +------------------------------------------------------------------------------- +Process can be configured on command line + nothrow + -e +------------------------------------------------------------------------------- +CmdLine.tests.cpp: +............................................................................... + +CmdLine.tests.cpp:: +PASSED: + CHECK( cli.parse({"test", "-e"}) ) +with expansion: + {?} + +CmdLine.tests.cpp:: +PASSED: + REQUIRE( config.noThrow ) +with expansion: + true + +------------------------------------------------------------------------------- +Process can be configured on command line + nothrow + --nothrow +------------------------------------------------------------------------------- +CmdLine.tests.cpp: +............................................................................... + +CmdLine.tests.cpp:: +PASSED: + CHECK( cli.parse({"test", "--nothrow"}) ) +with expansion: + {?} + +CmdLine.tests.cpp:: +PASSED: + REQUIRE( config.noThrow ) +with expansion: + true + +------------------------------------------------------------------------------- +Process can be configured on command line + output filename + -o filename +------------------------------------------------------------------------------- +CmdLine.tests.cpp: +............................................................................... + +CmdLine.tests.cpp:: +PASSED: + CHECK( cli.parse({"test", "-o", "filename.ext"}) ) +with expansion: + {?} + +CmdLine.tests.cpp:: +PASSED: + REQUIRE( config.outputFilename == "filename.ext" ) +with expansion: + "filename.ext" == "filename.ext" + +------------------------------------------------------------------------------- +Process can be configured on command line + output filename + --out +------------------------------------------------------------------------------- +CmdLine.tests.cpp: +............................................................................... + +CmdLine.tests.cpp:: +PASSED: + CHECK( cli.parse({"test", "--out", "filename.ext"}) ) +with expansion: + {?} + +CmdLine.tests.cpp:: +PASSED: + REQUIRE( config.outputFilename == "filename.ext" ) +with expansion: + "filename.ext" == "filename.ext" + +------------------------------------------------------------------------------- +Process can be configured on command line + combinations + Single character flags can be combined +------------------------------------------------------------------------------- +CmdLine.tests.cpp: +............................................................................... + +CmdLine.tests.cpp:: +PASSED: + CHECK( cli.parse({"test", "-abe"}) ) +with expansion: + {?} + +CmdLine.tests.cpp:: +PASSED: + CHECK( config.abortAfter == 1 ) +with expansion: + 1 == 1 + +CmdLine.tests.cpp:: +PASSED: + CHECK( config.shouldDebugBreak ) +with expansion: + true + +CmdLine.tests.cpp:: +PASSED: + CHECK( config.noThrow == true ) +with expansion: + true == true + +------------------------------------------------------------------------------- +Process can be configured on command line + use-colour + without option +------------------------------------------------------------------------------- +CmdLine.tests.cpp: +............................................................................... + +CmdLine.tests.cpp:: +PASSED: + CHECK( cli.parse({"test"}) ) +with expansion: + {?} + +CmdLine.tests.cpp:: +PASSED: + REQUIRE( config.useColour == UseColour::Auto ) +with expansion: + 0 == 0 + +------------------------------------------------------------------------------- +Process can be configured on command line + use-colour + auto +------------------------------------------------------------------------------- +CmdLine.tests.cpp: +............................................................................... + +CmdLine.tests.cpp:: +PASSED: + CHECK( cli.parse({"test", "--use-colour", "auto"}) ) +with expansion: + {?} + +CmdLine.tests.cpp:: +PASSED: + REQUIRE( config.useColour == UseColour::Auto ) +with expansion: + 0 == 0 + +------------------------------------------------------------------------------- +Process can be configured on command line + use-colour + yes +------------------------------------------------------------------------------- +CmdLine.tests.cpp: +............................................................................... + +CmdLine.tests.cpp:: +PASSED: + CHECK( cli.parse({"test", "--use-colour", "yes"}) ) +with expansion: + {?} + +CmdLine.tests.cpp:: +PASSED: + REQUIRE( config.useColour == UseColour::Yes ) +with expansion: + 1 == 1 + +------------------------------------------------------------------------------- +Process can be configured on command line + use-colour + no +------------------------------------------------------------------------------- +CmdLine.tests.cpp: +............................................................................... + +CmdLine.tests.cpp:: +PASSED: + CHECK( cli.parse({"test", "--use-colour", "no"}) ) +with expansion: + {?} + +CmdLine.tests.cpp:: +PASSED: + REQUIRE( config.useColour == UseColour::No ) +with expansion: + 2 == 2 + +------------------------------------------------------------------------------- +Process can be configured on command line + use-colour + error +------------------------------------------------------------------------------- +CmdLine.tests.cpp: +............................................................................... + +CmdLine.tests.cpp:: +PASSED: + CHECK( !result ) +with expansion: + true + +CmdLine.tests.cpp:: +PASSED: + CHECK_THAT( result.errorMessage(), Contains( "colour mode must be one of" ) ) +with expansion: + "colour mode must be one of: auto, yes or no. 'wrong' not recognised" + contains: "colour mode must be one of" + +------------------------------------------------------------------------------- +Reconstruction should be based on stringification: #914 +------------------------------------------------------------------------------- +Decomposition.tests.cpp: +............................................................................... + +Decomposition.tests.cpp:: FAILED: + CHECK( truthy(false) ) +with expansion: + Hey, its truthy! + +------------------------------------------------------------------------------- +Regex string matcher +------------------------------------------------------------------------------- +Matchers.tests.cpp: +............................................................................... + +Matchers.tests.cpp:: FAILED: + CHECK_THAT( testStringForMatching(), Matches("this STRING contains 'abc' as a substring") ) +with expansion: + "this string contains 'abc' as a substring" matches "this STRING contains + 'abc' as a substring" case sensitively + +Matchers.tests.cpp:: FAILED: + CHECK_THAT( testStringForMatching(), Matches("contains 'abc' as a substring") ) +with expansion: + "this string contains 'abc' as a substring" matches "contains 'abc' as a + substring" case sensitively + +Matchers.tests.cpp:: FAILED: + CHECK_THAT( testStringForMatching(), Matches("this string contains 'abc' as a") ) +with expansion: + "this string contains 'abc' as a substring" matches "this string contains + 'abc' as a" case sensitively + +------------------------------------------------------------------------------- +SUCCEED counts as a test pass +------------------------------------------------------------------------------- +Message.tests.cpp: +............................................................................... + +Message.tests.cpp:: +PASSED: +with message: + this is a success + +------------------------------------------------------------------------------- +SUCCEED does not require an argument +------------------------------------------------------------------------------- +Message.tests.cpp: +............................................................................... + +Message.tests.cpp:: +PASSED: + +------------------------------------------------------------------------------- +Scenario: BDD tests requiring Fixtures to provide commonly-accessed data or + methods + Given: No operations precede me +------------------------------------------------------------------------------- +BDD.tests.cpp: +............................................................................... + +BDD.tests.cpp:: +PASSED: + REQUIRE( before == 0 ) +with expansion: + 0 == 0 + +------------------------------------------------------------------------------- +Scenario: BDD tests requiring Fixtures to provide commonly-accessed data or + methods + Given: No operations precede me + When: We get the count + Then: Subsequently values are higher +------------------------------------------------------------------------------- +BDD.tests.cpp: +............................................................................... + +BDD.tests.cpp:: +PASSED: + REQUIRE( after > before ) +with expansion: + 1 > 0 + +------------------------------------------------------------------------------- +Scenario: Do that thing with the thing + Given: This stuff exists + When: I do this + Then: it should do this +------------------------------------------------------------------------------- +BDD.tests.cpp: +............................................................................... + +BDD.tests.cpp:: +PASSED: + REQUIRE( itDoesThis() ) +with expansion: + true + +------------------------------------------------------------------------------- +Scenario: Do that thing with the thing + Given: This stuff exists + When: I do this + Then: it should do this + And: do that +------------------------------------------------------------------------------- +BDD.tests.cpp: +............................................................................... + +BDD.tests.cpp:: +PASSED: + REQUIRE( itDoesThat() ) +with expansion: + true + +------------------------------------------------------------------------------- +Scenario: This is a really long scenario name to see how the list command deals + with wrapping + Given: A section name that is so long that it cannot fit in a single + console width + When: The test headers are printed as part of the normal running of the + scenario + Then: The, deliberately very long and overly verbose (you see what I did + there?) section names must wrap, along with an indent +------------------------------------------------------------------------------- +BDD.tests.cpp: +............................................................................... + +BDD.tests.cpp:: +PASSED: +with message: + boo! + +------------------------------------------------------------------------------- +Scenario: Vector resizing affects size and capacity + Given: an empty vector +------------------------------------------------------------------------------- +BDD.tests.cpp: +............................................................................... + +BDD.tests.cpp:: +PASSED: + REQUIRE( v.size() == 0 ) +with expansion: + 0 == 0 + +------------------------------------------------------------------------------- +Scenario: Vector resizing affects size and capacity + Given: an empty vector + When: it is made larger + Then: the size and capacity go up +------------------------------------------------------------------------------- +BDD.tests.cpp: +............................................................................... + +BDD.tests.cpp:: +PASSED: + REQUIRE( v.size() == 10 ) +with expansion: + 10 == 10 + +BDD.tests.cpp:: +PASSED: + REQUIRE( v.capacity() >= 10 ) +with expansion: + 10 >= 10 + +------------------------------------------------------------------------------- +Scenario: Vector resizing affects size and capacity + Given: an empty vector + When: it is made larger + Then: the size and capacity go up + And when: it is made smaller again + Then: the size goes down but the capacity stays the same +------------------------------------------------------------------------------- +BDD.tests.cpp: +............................................................................... + +BDD.tests.cpp:: +PASSED: + REQUIRE( v.size() == 5 ) +with expansion: + 5 == 5 + +BDD.tests.cpp:: +PASSED: + REQUIRE( v.capacity() >= 10 ) +with expansion: + 10 >= 10 + +------------------------------------------------------------------------------- +Scenario: Vector resizing affects size and capacity + Given: an empty vector +------------------------------------------------------------------------------- +BDD.tests.cpp: +............................................................................... + +BDD.tests.cpp:: +PASSED: + REQUIRE( v.size() == 0 ) +with expansion: + 0 == 0 + +------------------------------------------------------------------------------- +Scenario: Vector resizing affects size and capacity + Given: an empty vector + When: we reserve more space + Then: The capacity is increased but the size remains the same +------------------------------------------------------------------------------- +BDD.tests.cpp: +............................................................................... + +BDD.tests.cpp:: +PASSED: + REQUIRE( v.capacity() >= 10 ) +with expansion: + 10 >= 10 + +BDD.tests.cpp:: +PASSED: + REQUIRE( v.size() == 0 ) +with expansion: + 0 == 0 + +A string sent directly to stdout +A string sent directly to stderr +A string sent to stderr via clog +------------------------------------------------------------------------------- +Sends stuff to stdout and stderr +------------------------------------------------------------------------------- +Misc.tests.cpp: +............................................................................... + + +No assertions in test case 'Sends stuff to stdout and stderr' + +------------------------------------------------------------------------------- +Some simple comparisons between doubles +------------------------------------------------------------------------------- +Approx.tests.cpp: +............................................................................... + +Approx.tests.cpp:: +PASSED: + REQUIRE( d == Approx( 1.23 ) ) +with expansion: + 1.23 == Approx( 1.23 ) + +Approx.tests.cpp:: +PASSED: + REQUIRE( d != Approx( 1.22 ) ) +with expansion: + 1.23 != Approx( 1.22 ) + +Approx.tests.cpp:: +PASSED: + REQUIRE( d != Approx( 1.24 ) ) +with expansion: + 1.23 != Approx( 1.24 ) + +Approx.tests.cpp:: +PASSED: + REQUIRE( d == 1.23_a ) +with expansion: + 1.23 == Approx( 1.23 ) + +Approx.tests.cpp:: +PASSED: + REQUIRE( d != 1.22_a ) +with expansion: + 1.23 != Approx( 1.22 ) + +Approx.tests.cpp:: +PASSED: + REQUIRE( Approx( d ) == 1.23 ) +with expansion: + Approx( 1.23 ) == 1.23 + +Approx.tests.cpp:: +PASSED: + REQUIRE( Approx( d ) != 1.22 ) +with expansion: + Approx( 1.23 ) != 1.22 + +Approx.tests.cpp:: +PASSED: + REQUIRE( Approx( d ) != 1.24 ) +with expansion: + Approx( 1.23 ) != 1.24 + +Approx.tests.cpp:: +PASSED: + REQUIRE( INFINITY == Approx(INFINITY) ) +with expansion: + inff == Approx( inf ) + +Message from section one +------------------------------------------------------------------------------- +Standard output from all sections is reported + one +------------------------------------------------------------------------------- +Message.tests.cpp: +............................................................................... + + +No assertions in section 'one' + +Message from section two +------------------------------------------------------------------------------- +Standard output from all sections is reported + two +------------------------------------------------------------------------------- +Message.tests.cpp: +............................................................................... + + +No assertions in section 'two' + +------------------------------------------------------------------------------- +StartsWith string matcher +------------------------------------------------------------------------------- +Matchers.tests.cpp: +............................................................................... + +Matchers.tests.cpp:: FAILED: + CHECK_THAT( testStringForMatching(), StartsWith("This String") ) +with expansion: + "this string contains 'abc' as a substring" starts with: "This String" + +Matchers.tests.cpp:: FAILED: + CHECK_THAT( testStringForMatching(), StartsWith("string", Catch::CaseSensitive::No) ) +with expansion: + "this string contains 'abc' as a substring" starts with: "string" (case + insensitive) + +------------------------------------------------------------------------------- +Static arrays are convertible to string + Single item +------------------------------------------------------------------------------- +ToStringGeneral.tests.cpp: +............................................................................... + +ToStringGeneral.tests.cpp:: +PASSED: + REQUIRE( Catch::Detail::stringify(singular) == "{ 1 }" ) +with expansion: + "{ 1 }" == "{ 1 }" + +------------------------------------------------------------------------------- +Static arrays are convertible to string + Multiple +------------------------------------------------------------------------------- +ToStringGeneral.tests.cpp: +............................................................................... + +ToStringGeneral.tests.cpp:: +PASSED: + REQUIRE( Catch::Detail::stringify(arr) == "{ 3, 2, 1 }" ) +with expansion: + "{ 3, 2, 1 }" == "{ 3, 2, 1 }" + +------------------------------------------------------------------------------- +Static arrays are convertible to string + Non-trivial inner items +------------------------------------------------------------------------------- +ToStringGeneral.tests.cpp: +............................................................................... + +ToStringGeneral.tests.cpp:: +PASSED: + REQUIRE( Catch::Detail::stringify(arr) == R"({ { "1:1", "1:2", "1:3" }, { "2:1", "2:2" } })" ) +with expansion: + "{ { "1:1", "1:2", "1:3" }, { "2:1", "2:2" } }" + == + "{ { "1:1", "1:2", "1:3" }, { "2:1", "2:2" } }" + +------------------------------------------------------------------------------- +String matchers +------------------------------------------------------------------------------- +Matchers.tests.cpp: +............................................................................... + +Matchers.tests.cpp:: +PASSED: + REQUIRE_THAT( testStringForMatching(), Contains("string") ) +with expansion: + "this string contains 'abc' as a substring" contains: "string" + +Matchers.tests.cpp:: +PASSED: + REQUIRE_THAT( testStringForMatching(), Contains("string", Catch::CaseSensitive::No) ) +with expansion: + "this string contains 'abc' as a substring" contains: "string" (case + insensitive) + +Matchers.tests.cpp:: +PASSED: + CHECK_THAT( testStringForMatching(), Contains("abc") ) +with expansion: + "this string contains 'abc' as a substring" contains: "abc" + +Matchers.tests.cpp:: +PASSED: + CHECK_THAT( testStringForMatching(), Contains("aBC", Catch::CaseSensitive::No) ) +with expansion: + "this string contains 'abc' as a substring" contains: "abc" (case insensitive) + insensitive) + +Matchers.tests.cpp:: +PASSED: + CHECK_THAT( testStringForMatching(), StartsWith("this") ) +with expansion: + "this string contains 'abc' as a substring" starts with: "this" + +Matchers.tests.cpp:: +PASSED: + CHECK_THAT( testStringForMatching(), StartsWith("THIS", Catch::CaseSensitive::No) ) +with expansion: + "this string contains 'abc' as a substring" starts with: "this" (case + insensitive) + +Matchers.tests.cpp:: +PASSED: + CHECK_THAT( testStringForMatching(), EndsWith("substring") ) +with expansion: + "this string contains 'abc' as a substring" ends with: "substring" + +Matchers.tests.cpp:: +PASSED: + CHECK_THAT( testStringForMatching(), EndsWith(" SuBsTrInG", Catch::CaseSensitive::No) ) +with expansion: + "this string contains 'abc' as a substring" ends with: " substring" (case + insensitive) + +------------------------------------------------------------------------------- +StringRef + Empty string +------------------------------------------------------------------------------- +String.tests.cpp: +............................................................................... + +String.tests.cpp:: +PASSED: + REQUIRE( empty.empty() ) +with expansion: + true + +String.tests.cpp:: +PASSED: + REQUIRE( empty.size() == 0 ) +with expansion: + 0 == 0 + +String.tests.cpp:: +PASSED: + REQUIRE( std::strcmp( empty.c_str(), "" ) == 0 ) +with expansion: + 0 == 0 + +------------------------------------------------------------------------------- +StringRef + From string literal +------------------------------------------------------------------------------- +String.tests.cpp: +............................................................................... + +String.tests.cpp:: +PASSED: + REQUIRE( s.empty() == false ) +with expansion: + false == false + +String.tests.cpp:: +PASSED: + REQUIRE( s.size() == 5 ) +with expansion: + 5 == 5 + +String.tests.cpp:: +PASSED: + REQUIRE( isSubstring( s ) == false ) +with expansion: + false == false + +String.tests.cpp:: +PASSED: + REQUIRE( std::strcmp( rawChars, "hello" ) == 0 ) +with expansion: + 0 == 0 + +------------------------------------------------------------------------------- +StringRef + From string literal + c_str() does not cause copy +------------------------------------------------------------------------------- +String.tests.cpp: +............................................................................... + +String.tests.cpp:: +PASSED: + REQUIRE( isOwned( s ) == false ) +with expansion: + false == false + +String.tests.cpp:: +PASSED: + REQUIRE( s.c_str() == rawChars ) +with expansion: + "hello" == "hello" + +String.tests.cpp:: +PASSED: + REQUIRE( isOwned( s ) == false ) +with expansion: + false == false + +------------------------------------------------------------------------------- +StringRef + From sub-string +------------------------------------------------------------------------------- +String.tests.cpp: +............................................................................... + +String.tests.cpp:: +PASSED: + REQUIRE( original == "original" ) + +String.tests.cpp:: +PASSED: + REQUIRE( isSubstring( original ) ) +with expansion: + true + +String.tests.cpp:: +PASSED: + REQUIRE( isOwned( original ) == false ) +with expansion: + false == false + +String.tests.cpp:: +PASSED: + REQUIRE( isSubstring( original ) == false ) +with expansion: + false == false + +String.tests.cpp:: +PASSED: + REQUIRE( isOwned( original ) ) +with expansion: + true + +------------------------------------------------------------------------------- +StringRef + Substrings + zero-based substring +------------------------------------------------------------------------------- +String.tests.cpp: +............................................................................... + +String.tests.cpp:: +PASSED: + REQUIRE( ss.empty() == false ) +with expansion: + false == false + +String.tests.cpp:: +PASSED: + REQUIRE( ss.size() == 5 ) +with expansion: + 5 == 5 + +String.tests.cpp:: +PASSED: + REQUIRE( std::strcmp( ss.c_str(), "hello" ) == 0 ) +with expansion: + 0 == 0 + +String.tests.cpp:: +PASSED: + REQUIRE( ss == "hello" ) +with expansion: + hello == "hello" + +------------------------------------------------------------------------------- +StringRef + Substrings + c_str() causes copy +------------------------------------------------------------------------------- +String.tests.cpp: +............................................................................... + +String.tests.cpp:: +PASSED: + REQUIRE( isSubstring( ss ) ) +with expansion: + true + +String.tests.cpp:: +PASSED: + REQUIRE( isOwned( ss ) == false ) +with expansion: + false == false + +String.tests.cpp:: +PASSED: + REQUIRE( rawChars == s.currentData() ) +with expansion: + "hello world!" == "hello world!" + +String.tests.cpp:: +PASSED: + REQUIRE( ss.c_str() != rawChars ) +with expansion: + "hello" != "hello world!" + +String.tests.cpp:: +PASSED: + REQUIRE( isSubstring( ss ) == false ) +with expansion: + false == false + +String.tests.cpp:: +PASSED: + REQUIRE( isOwned( ss ) ) +with expansion: + true + +String.tests.cpp:: +PASSED: + REQUIRE( ss.currentData() != s.currentData() ) +with expansion: + "hello" != "hello world!" + +------------------------------------------------------------------------------- +StringRef + Substrings + non-zero-based substring +------------------------------------------------------------------------------- +String.tests.cpp: +............................................................................... + +String.tests.cpp:: +PASSED: + REQUIRE( ss.size() == 6 ) +with expansion: + 6 == 6 + +String.tests.cpp:: +PASSED: + REQUIRE( std::strcmp( ss.c_str(), "world!" ) == 0 ) +with expansion: + 0 == 0 + +------------------------------------------------------------------------------- +StringRef + Substrings + Pointer values of full refs should match +------------------------------------------------------------------------------- +String.tests.cpp: +............................................................................... + +String.tests.cpp:: +PASSED: + REQUIRE( s.c_str() == s2.c_str() ) +with expansion: + "hello world!" == "hello world!" + +------------------------------------------------------------------------------- +StringRef + Substrings + Pointer values of substring refs should not match +------------------------------------------------------------------------------- +String.tests.cpp: +............................................................................... + +String.tests.cpp:: +PASSED: + REQUIRE( s.c_str() != ss.c_str() ) +with expansion: + "hello world!" != "hello" + +------------------------------------------------------------------------------- +StringRef + Comparisons +------------------------------------------------------------------------------- +String.tests.cpp: +............................................................................... + +String.tests.cpp:: +PASSED: + REQUIRE( StringRef("hello") == StringRef("hello") ) +with expansion: + hello == hello + +String.tests.cpp:: +PASSED: + REQUIRE( StringRef("hello") != StringRef("cello") ) +with expansion: + hello != cello + +------------------------------------------------------------------------------- +StringRef + from std::string + implicitly constructed +------------------------------------------------------------------------------- +String.tests.cpp: +............................................................................... + +String.tests.cpp:: +PASSED: + REQUIRE( sr == "a standard string" ) +with expansion: + a standard string == "a standard string" + +String.tests.cpp:: +PASSED: + REQUIRE( sr.size() == stdStr.size() ) +with expansion: + 17 == 17 + +------------------------------------------------------------------------------- +StringRef + from std::string + explicitly constructed +------------------------------------------------------------------------------- +String.tests.cpp: +............................................................................... + +String.tests.cpp:: +PASSED: + REQUIRE( sr == "a standard string" ) +with expansion: + a standard string == "a standard string" + +String.tests.cpp:: +PASSED: + REQUIRE( sr.size() == stdStr.size() ) +with expansion: + 17 == 17 + +------------------------------------------------------------------------------- +StringRef + from std::string + assigned +------------------------------------------------------------------------------- +String.tests.cpp: +............................................................................... + +String.tests.cpp:: +PASSED: + REQUIRE( sr == "a standard string" ) +with expansion: + a standard string == "a standard string" + +String.tests.cpp:: +PASSED: + REQUIRE( sr.size() == stdStr.size() ) +with expansion: + 17 == 17 + +------------------------------------------------------------------------------- +StringRef + to std::string + implicitly constructed +------------------------------------------------------------------------------- +String.tests.cpp: +............................................................................... + +String.tests.cpp:: +PASSED: + REQUIRE( stdStr == "a stringref" ) +with expansion: + "a stringref" == "a stringref" + +String.tests.cpp:: +PASSED: + REQUIRE( stdStr.size() == sr.size() ) +with expansion: + 11 == 11 + +------------------------------------------------------------------------------- +StringRef + to std::string + explicitly constructed +------------------------------------------------------------------------------- +String.tests.cpp: +............................................................................... + +String.tests.cpp:: +PASSED: + REQUIRE( stdStr == "a stringref" ) +with expansion: + "a stringref" == "a stringref" + +String.tests.cpp:: +PASSED: + REQUIRE( stdStr.size() == sr.size() ) +with expansion: + 11 == 11 + +------------------------------------------------------------------------------- +StringRef + to std::string + assigned +------------------------------------------------------------------------------- +String.tests.cpp: +............................................................................... + +String.tests.cpp:: +PASSED: + REQUIRE( stdStr == "a stringref" ) +with expansion: + "a stringref" == "a stringref" + +String.tests.cpp:: +PASSED: + REQUIRE( stdStr.size() == sr.size() ) +with expansion: + 11 == 11 + +------------------------------------------------------------------------------- +StringRef + Counting utf-8 codepoints +------------------------------------------------------------------------------- +String.tests.cpp: +............................................................................... + +String.tests.cpp:: +PASSED: + REQUIRE( ascii.numberOfCharacters() == ascii.size() ) +with expansion: + 39 == 39 + +String.tests.cpp:: +PASSED: + REQUIRE( simpleu8.numberOfCharacters() == 30 ) +with expansion: + 30 == 30 + +String.tests.cpp:: +PASSED: + REQUIRE( emojis.numberOfCharacters() == 9 ) +with expansion: + 9 == 9 + +------------------------------------------------------------------------------- +Stringifying std::chrono::duration helpers +------------------------------------------------------------------------------- +ToStringChrono.tests.cpp: +............................................................................... + +ToStringChrono.tests.cpp:: +PASSED: + REQUIRE( minute == seconds ) +with expansion: + 1 m == 60 s + +ToStringChrono.tests.cpp:: +PASSED: + REQUIRE( hour != seconds ) +with expansion: + 1 h != 60 s + +ToStringChrono.tests.cpp:: +PASSED: + REQUIRE( micro != milli ) +with expansion: + 1 us != 1 ms + +ToStringChrono.tests.cpp:: +PASSED: + REQUIRE( nano != micro ) +with expansion: + 1 ns != 1 us + +------------------------------------------------------------------------------- +Stringifying std::chrono::duration with weird ratios +------------------------------------------------------------------------------- +ToStringChrono.tests.cpp: +............................................................................... + +ToStringChrono.tests.cpp:: +PASSED: + REQUIRE( half_minute != femto_second ) +with expansion: + 1 [30/1]s != 1 fs + +ToStringChrono.tests.cpp:: +PASSED: + REQUIRE( pico_second != atto_second ) +with expansion: + 1 ps != 1 as + +------------------------------------------------------------------------------- +Stringifying std::chrono::time_point +------------------------------------------------------------------------------- +ToStringChrono.tests.cpp: +............................................................................... + +ToStringChrono.tests.cpp:: +PASSED: + REQUIRE( now != later ) +with expansion: + {iso8601-timestamp} + != + {iso8601-timestamp} + +------------------------------------------------------------------------------- +Tabs and newlines show in output +------------------------------------------------------------------------------- +Misc.tests.cpp: +............................................................................... + +Misc.tests.cpp:: FAILED: + CHECK( s1 == s2 ) +with expansion: + "if ($b == 10) { + $a = 20; + }" + == + "if ($b == 10) { + $a = 20; + } + " + +------------------------------------------------------------------------------- +Tag alias can be registered against tag patterns + The same tag alias can only be registered once +------------------------------------------------------------------------------- +TagAlias.tests.cpp: +............................................................................... + +TagAlias.tests.cpp:: +PASSED: + CHECK_THAT( what, Contains( "[@zzz]" ) ) +with expansion: + "error: tag alias, '[@zzz]' already registered. + First seen at: file:2 + Redefined at: file:10" contains: "[@zzz]" + +TagAlias.tests.cpp:: +PASSED: + CHECK_THAT( what, Contains( "file" ) ) +with expansion: + "error: tag alias, '[@zzz]' already registered. + First seen at: file:2 + Redefined at: file:10" contains: "file" + +TagAlias.tests.cpp:: +PASSED: + CHECK_THAT( what, Contains( "2" ) ) +with expansion: + "error: tag alias, '[@zzz]' already registered. + First seen at: file:2 + Redefined at: file:10" contains: "2" + +TagAlias.tests.cpp:: +PASSED: + CHECK_THAT( what, Contains( "10" ) ) +with expansion: + "error: tag alias, '[@zzz]' already registered. + First seen at: file:2 + Redefined at: file:10" contains: "10" + +------------------------------------------------------------------------------- +Tag alias can be registered against tag patterns + Tag aliases must be of the form [@name] +------------------------------------------------------------------------------- +TagAlias.tests.cpp: +............................................................................... + +TagAlias.tests.cpp:: +PASSED: + CHECK_THROWS( registry.add( "[no ampersat]", "", Catch::SourceLineInfo( "file", 3 ) ) ) + +TagAlias.tests.cpp:: +PASSED: + CHECK_THROWS( registry.add( "[the @ is not at the start]", "", Catch::SourceLineInfo( "file", 3 ) ) ) + +TagAlias.tests.cpp:: +PASSED: + CHECK_THROWS( registry.add( "@no square bracket at start]", "", Catch::SourceLineInfo( "file", 3 ) ) ) + +TagAlias.tests.cpp:: +PASSED: + CHECK_THROWS( registry.add( "[@no square bracket at end", "", Catch::SourceLineInfo( "file", 3 ) ) ) + +------------------------------------------------------------------------------- +Test case with one argument +------------------------------------------------------------------------------- +VariadicMacros.tests.cpp: +............................................................................... + +VariadicMacros.tests.cpp:: +PASSED: +with message: + no assertions + +------------------------------------------------------------------------------- +Test enum bit values +------------------------------------------------------------------------------- +Tricky.tests.cpp: +............................................................................... + +Tricky.tests.cpp:: +PASSED: + REQUIRE( 0x == bit30and31 ) +with expansion: + 3221225472 (0x) == 3221225472 + +------------------------------------------------------------------------------- +The NO_FAIL macro reports a failure but does not fail the test +------------------------------------------------------------------------------- +Message.tests.cpp: +............................................................................... + +Message.tests.cpp:: +FAILED - but was ok: + CHECK_NOFAIL( 1 == 2 ) + + +No assertions in test case 'The NO_FAIL macro reports a failure but does not fail the test' + +------------------------------------------------------------------------------- +This test 'should' fail but doesn't +------------------------------------------------------------------------------- +Misc.tests.cpp: +............................................................................... + +Misc.tests.cpp:: +PASSED: +with message: + oops! + +------------------------------------------------------------------------------- +Thrown string literals are translated +------------------------------------------------------------------------------- +Exception.tests.cpp: +............................................................................... + +Exception.tests.cpp:: FAILED: +due to unexpected exception with message: + For some reason someone is throwing a string literal! + +------------------------------------------------------------------------------- +Tracker +------------------------------------------------------------------------------- +PartTracker.tests.cpp: +............................................................................... + +PartTracker.tests.cpp:: +PASSED: + REQUIRE( testCase.isOpen() ) +with expansion: + true + +PartTracker.tests.cpp:: +PASSED: + REQUIRE( s1.isOpen() ) +with expansion: + true + +------------------------------------------------------------------------------- +Tracker + successfully close one section +------------------------------------------------------------------------------- +PartTracker.tests.cpp: +............................................................................... + +PartTracker.tests.cpp:: +PASSED: + REQUIRE( s1.isSuccessfullyCompleted() ) +with expansion: + true + +PartTracker.tests.cpp:: +PASSED: + REQUIRE( testCase.isComplete() == false ) +with expansion: + false == false + +PartTracker.tests.cpp:: +PASSED: + REQUIRE( ctx.completedCycle() ) +with expansion: + true + +PartTracker.tests.cpp:: +PASSED: + REQUIRE( testCase.isSuccessfullyCompleted() ) +with expansion: + true + +------------------------------------------------------------------------------- +Tracker +------------------------------------------------------------------------------- +PartTracker.tests.cpp: +............................................................................... + +PartTracker.tests.cpp:: +PASSED: + REQUIRE( testCase.isOpen() ) +with expansion: + true + +PartTracker.tests.cpp:: +PASSED: + REQUIRE( s1.isOpen() ) +with expansion: + true + +------------------------------------------------------------------------------- +Tracker + fail one section +------------------------------------------------------------------------------- +PartTracker.tests.cpp: +............................................................................... + +PartTracker.tests.cpp:: +PASSED: + REQUIRE( s1.isComplete() ) +with expansion: + true + +PartTracker.tests.cpp:: +PASSED: + REQUIRE( s1.isSuccessfullyCompleted() == false ) +with expansion: + false == false + +PartTracker.tests.cpp:: +PASSED: + REQUIRE( testCase.isComplete() == false ) +with expansion: + false == false + +PartTracker.tests.cpp:: +PASSED: + REQUIRE( ctx.completedCycle() ) +with expansion: + true + +PartTracker.tests.cpp:: +PASSED: + REQUIRE( testCase.isSuccessfullyCompleted() == false ) +with expansion: + false == false + +------------------------------------------------------------------------------- +Tracker + fail one section + re-enter after failed section +------------------------------------------------------------------------------- +PartTracker.tests.cpp: +............................................................................... + +PartTracker.tests.cpp:: +PASSED: + REQUIRE( testCase2.isOpen() ) +with expansion: + true + +PartTracker.tests.cpp:: +PASSED: + REQUIRE( s1b.isOpen() == false ) +with expansion: + false == false + +PartTracker.tests.cpp:: +PASSED: + REQUIRE( ctx.completedCycle() ) +with expansion: + true + +PartTracker.tests.cpp:: +PASSED: + REQUIRE( testCase.isComplete() ) +with expansion: + true + +PartTracker.tests.cpp:: +PASSED: + REQUIRE( testCase.isSuccessfullyCompleted() ) +with expansion: + true + +------------------------------------------------------------------------------- +Tracker +------------------------------------------------------------------------------- +PartTracker.tests.cpp: +............................................................................... + +PartTracker.tests.cpp:: +PASSED: + REQUIRE( testCase.isOpen() ) +with expansion: + true + +PartTracker.tests.cpp:: +PASSED: + REQUIRE( s1.isOpen() ) +with expansion: + true + +------------------------------------------------------------------------------- +Tracker + fail one section +------------------------------------------------------------------------------- +PartTracker.tests.cpp: +............................................................................... + +PartTracker.tests.cpp:: +PASSED: + REQUIRE( s1.isComplete() ) +with expansion: + true + +PartTracker.tests.cpp:: +PASSED: + REQUIRE( s1.isSuccessfullyCompleted() == false ) +with expansion: + false == false + +PartTracker.tests.cpp:: +PASSED: + REQUIRE( testCase.isComplete() == false ) +with expansion: + false == false + +PartTracker.tests.cpp:: +PASSED: + REQUIRE( ctx.completedCycle() ) +with expansion: + true + +PartTracker.tests.cpp:: +PASSED: + REQUIRE( testCase.isSuccessfullyCompleted() == false ) +with expansion: + false == false + +------------------------------------------------------------------------------- +Tracker + fail one section + re-enter after failed section and find next section +------------------------------------------------------------------------------- +PartTracker.tests.cpp: +............................................................................... + +PartTracker.tests.cpp:: +PASSED: + REQUIRE( testCase2.isOpen() ) +with expansion: + true + +PartTracker.tests.cpp:: +PASSED: + REQUIRE( s1b.isOpen() == false ) +with expansion: + false == false + +PartTracker.tests.cpp:: +PASSED: + REQUIRE( s2.isOpen() ) +with expansion: + true + +PartTracker.tests.cpp:: +PASSED: + REQUIRE( ctx.completedCycle() ) +with expansion: + true + +PartTracker.tests.cpp:: +PASSED: + REQUIRE( testCase.isComplete() ) +with expansion: + true + +PartTracker.tests.cpp:: +PASSED: + REQUIRE( testCase.isSuccessfullyCompleted() ) +with expansion: + true + +------------------------------------------------------------------------------- +Tracker +------------------------------------------------------------------------------- +PartTracker.tests.cpp: +............................................................................... + +PartTracker.tests.cpp:: +PASSED: + REQUIRE( testCase.isOpen() ) +with expansion: + true + +PartTracker.tests.cpp:: +PASSED: + REQUIRE( s1.isOpen() ) +with expansion: + true + +------------------------------------------------------------------------------- +Tracker + successfully close one section, then find another +------------------------------------------------------------------------------- +PartTracker.tests.cpp: +............................................................................... + +PartTracker.tests.cpp:: +PASSED: + REQUIRE( s2.isOpen() == false ) +with expansion: + false == false + +PartTracker.tests.cpp:: +PASSED: + REQUIRE( testCase.isComplete() == false ) +with expansion: + false == false + +------------------------------------------------------------------------------- +Tracker + successfully close one section, then find another + Re-enter - skips S1 and enters S2 +------------------------------------------------------------------------------- +PartTracker.tests.cpp: +............................................................................... + +PartTracker.tests.cpp:: +PASSED: + REQUIRE( testCase2.isOpen() ) +with expansion: + true + +PartTracker.tests.cpp:: +PASSED: + REQUIRE( s1b.isOpen() == false ) +with expansion: + false == false + +PartTracker.tests.cpp:: +PASSED: + REQUIRE( s2b.isOpen() ) +with expansion: + true + +PartTracker.tests.cpp:: +PASSED: + REQUIRE( ctx.completedCycle() == false ) +with expansion: + false == false + +------------------------------------------------------------------------------- +Tracker + successfully close one section, then find another + Re-enter - skips S1 and enters S2 + Successfully close S2 +------------------------------------------------------------------------------- +PartTracker.tests.cpp: +............................................................................... + +PartTracker.tests.cpp:: +PASSED: + REQUIRE( ctx.completedCycle() ) +with expansion: + true + +PartTracker.tests.cpp:: +PASSED: + REQUIRE( s2b.isSuccessfullyCompleted() ) +with expansion: + true + +PartTracker.tests.cpp:: +PASSED: + REQUIRE( testCase2.isComplete() == false ) +with expansion: + false == false + +PartTracker.tests.cpp:: +PASSED: + REQUIRE( testCase2.isSuccessfullyCompleted() ) +with expansion: + true + +------------------------------------------------------------------------------- +Tracker +------------------------------------------------------------------------------- +PartTracker.tests.cpp: +............................................................................... + +PartTracker.tests.cpp:: +PASSED: + REQUIRE( testCase.isOpen() ) +with expansion: + true + +PartTracker.tests.cpp:: +PASSED: + REQUIRE( s1.isOpen() ) +with expansion: + true + +------------------------------------------------------------------------------- +Tracker + successfully close one section, then find another +------------------------------------------------------------------------------- +PartTracker.tests.cpp: +............................................................................... + +PartTracker.tests.cpp:: +PASSED: + REQUIRE( s2.isOpen() == false ) +with expansion: + false == false + +PartTracker.tests.cpp:: +PASSED: + REQUIRE( testCase.isComplete() == false ) +with expansion: + false == false + +------------------------------------------------------------------------------- +Tracker + successfully close one section, then find another + Re-enter - skips S1 and enters S2 +------------------------------------------------------------------------------- +PartTracker.tests.cpp: +............................................................................... + +PartTracker.tests.cpp:: +PASSED: + REQUIRE( testCase2.isOpen() ) +with expansion: + true + +PartTracker.tests.cpp:: +PASSED: + REQUIRE( s1b.isOpen() == false ) +with expansion: + false == false + +PartTracker.tests.cpp:: +PASSED: + REQUIRE( s2b.isOpen() ) +with expansion: + true + +PartTracker.tests.cpp:: +PASSED: + REQUIRE( ctx.completedCycle() == false ) +with expansion: + false == false + +------------------------------------------------------------------------------- +Tracker + successfully close one section, then find another + Re-enter - skips S1 and enters S2 + fail S2 +------------------------------------------------------------------------------- +PartTracker.tests.cpp: +............................................................................... + +PartTracker.tests.cpp:: +PASSED: + REQUIRE( ctx.completedCycle() ) +with expansion: + true + +PartTracker.tests.cpp:: +PASSED: + REQUIRE( s2b.isComplete() ) +with expansion: + true + +PartTracker.tests.cpp:: +PASSED: + REQUIRE( s2b.isSuccessfullyCompleted() == false ) +with expansion: + false == false + +PartTracker.tests.cpp:: +PASSED: + REQUIRE( testCase2.isSuccessfullyCompleted() == false ) +with expansion: + false == false + +PartTracker.tests.cpp:: +PASSED: + REQUIRE( testCase3.isOpen() ) +with expansion: + true + +PartTracker.tests.cpp:: +PASSED: + REQUIRE( s1c.isOpen() == false ) +with expansion: + false == false + +PartTracker.tests.cpp:: +PASSED: + REQUIRE( s2c.isOpen() == false ) +with expansion: + false == false + +PartTracker.tests.cpp:: +PASSED: + REQUIRE( testCase3.isSuccessfullyCompleted() ) +with expansion: + true + +------------------------------------------------------------------------------- +Tracker +------------------------------------------------------------------------------- +PartTracker.tests.cpp: +............................................................................... + +PartTracker.tests.cpp:: +PASSED: + REQUIRE( testCase.isOpen() ) +with expansion: + true + +PartTracker.tests.cpp:: +PASSED: + REQUIRE( s1.isOpen() ) +with expansion: + true + +------------------------------------------------------------------------------- +Tracker + open a nested section +------------------------------------------------------------------------------- +PartTracker.tests.cpp: +............................................................................... + +PartTracker.tests.cpp:: +PASSED: + REQUIRE( s2.isOpen() ) +with expansion: + true + +PartTracker.tests.cpp:: +PASSED: + REQUIRE( s2.isComplete() ) +with expansion: + true + +PartTracker.tests.cpp:: +PASSED: + REQUIRE( s1.isComplete() == false ) +with expansion: + false == false + +PartTracker.tests.cpp:: +PASSED: + REQUIRE( s1.isComplete() ) +with expansion: + true + +PartTracker.tests.cpp:: +PASSED: + REQUIRE( testCase.isComplete() == false ) +with expansion: + false == false + +PartTracker.tests.cpp:: +PASSED: + REQUIRE( testCase.isComplete() ) +with expansion: + true + +------------------------------------------------------------------------------- +Tracker +------------------------------------------------------------------------------- +PartTracker.tests.cpp: +............................................................................... + +PartTracker.tests.cpp:: +PASSED: + REQUIRE( testCase.isOpen() ) +with expansion: + true + +PartTracker.tests.cpp:: +PASSED: + REQUIRE( s1.isOpen() ) +with expansion: + true + +------------------------------------------------------------------------------- +Tracker + start a generator +------------------------------------------------------------------------------- +PartTracker.tests.cpp: +............................................................................... + +PartTracker.tests.cpp:: +PASSED: + REQUIRE( g1.isOpen() ) +with expansion: + true + +PartTracker.tests.cpp:: +PASSED: + REQUIRE( g1.index() == 0 ) +with expansion: + 0 == 0 + +PartTracker.tests.cpp:: +PASSED: + REQUIRE( g1.isComplete() == false ) +with expansion: + false == false + +PartTracker.tests.cpp:: +PASSED: + REQUIRE( s1.isComplete() == false ) +with expansion: + false == false + +------------------------------------------------------------------------------- +Tracker + start a generator + close outer section +------------------------------------------------------------------------------- +PartTracker.tests.cpp: +............................................................................... + +PartTracker.tests.cpp:: +PASSED: + REQUIRE( s1.isComplete() == false ) +with expansion: + false == false + +PartTracker.tests.cpp:: +PASSED: + REQUIRE( testCase.isSuccessfullyCompleted() == false ) +with expansion: + false == false + +------------------------------------------------------------------------------- +Tracker + start a generator + close outer section + Re-enter for second generation +------------------------------------------------------------------------------- +PartTracker.tests.cpp: +............................................................................... + +PartTracker.tests.cpp:: +PASSED: + REQUIRE( testCase2.isOpen() ) +with expansion: + true + +PartTracker.tests.cpp:: +PASSED: + REQUIRE( s1b.isOpen() ) +with expansion: + true + +PartTracker.tests.cpp:: +PASSED: + REQUIRE( g1b.isOpen() ) +with expansion: + true + +PartTracker.tests.cpp:: +PASSED: + REQUIRE( g1b.index() == 1 ) +with expansion: + 1 == 1 + +PartTracker.tests.cpp:: +PASSED: + REQUIRE( s1.isComplete() == false ) +with expansion: + false == false + +PartTracker.tests.cpp:: +PASSED: + REQUIRE( s1b.isComplete() ) +with expansion: + true + +PartTracker.tests.cpp:: +PASSED: + REQUIRE( g1b.isComplete() ) +with expansion: + true + +PartTracker.tests.cpp:: +PASSED: + REQUIRE( testCase2.isComplete() ) +with expansion: + true + +------------------------------------------------------------------------------- +Tracker +------------------------------------------------------------------------------- +PartTracker.tests.cpp: +............................................................................... + +PartTracker.tests.cpp:: +PASSED: + REQUIRE( testCase.isOpen() ) +with expansion: + true + +PartTracker.tests.cpp:: +PASSED: + REQUIRE( s1.isOpen() ) +with expansion: + true + +------------------------------------------------------------------------------- +Tracker + start a generator +------------------------------------------------------------------------------- +PartTracker.tests.cpp: +............................................................................... + +PartTracker.tests.cpp:: +PASSED: + REQUIRE( g1.isOpen() ) +with expansion: + true + +PartTracker.tests.cpp:: +PASSED: + REQUIRE( g1.index() == 0 ) +with expansion: + 0 == 0 + +PartTracker.tests.cpp:: +PASSED: + REQUIRE( g1.isComplete() == false ) +with expansion: + false == false + +PartTracker.tests.cpp:: +PASSED: + REQUIRE( s1.isComplete() == false ) +with expansion: + false == false + +------------------------------------------------------------------------------- +Tracker + start a generator + Start a new inner section +------------------------------------------------------------------------------- +PartTracker.tests.cpp: +............................................................................... + +PartTracker.tests.cpp:: +PASSED: + REQUIRE( s2.isOpen() ) +with expansion: + true + +PartTracker.tests.cpp:: +PASSED: + REQUIRE( s2.isComplete() ) +with expansion: + true + +PartTracker.tests.cpp:: +PASSED: + REQUIRE( s1.isComplete() == false ) +with expansion: + false == false + +PartTracker.tests.cpp:: +PASSED: + REQUIRE( testCase.isComplete() == false ) +with expansion: + false == false + +------------------------------------------------------------------------------- +Tracker + start a generator + Start a new inner section + Re-enter for second generation +------------------------------------------------------------------------------- +PartTracker.tests.cpp: +............................................................................... + +PartTracker.tests.cpp:: +PASSED: + REQUIRE( testCase2.isOpen() ) +with expansion: + true + +PartTracker.tests.cpp:: +PASSED: + REQUIRE( s1b.isOpen() ) +with expansion: + true + +PartTracker.tests.cpp:: +PASSED: + REQUIRE( g1b.isOpen() ) +with expansion: + true + +PartTracker.tests.cpp:: +PASSED: + REQUIRE( g1b.index() == 1 ) +with expansion: + 1 == 1 + +PartTracker.tests.cpp:: +PASSED: + REQUIRE( s2b.isOpen() ) +with expansion: + true + +PartTracker.tests.cpp:: +PASSED: + REQUIRE( s2b.isComplete() ) +with expansion: + true + +PartTracker.tests.cpp:: +PASSED: + REQUIRE( g1b.isComplete() ) +with expansion: + true + +PartTracker.tests.cpp:: +PASSED: + REQUIRE( s1b.isComplete() ) +with expansion: + true + +PartTracker.tests.cpp:: +PASSED: + REQUIRE( testCase2.isComplete() ) +with expansion: + true + +------------------------------------------------------------------------------- +Tracker +------------------------------------------------------------------------------- +PartTracker.tests.cpp: +............................................................................... + +PartTracker.tests.cpp:: +PASSED: + REQUIRE( testCase.isOpen() ) +with expansion: + true + +PartTracker.tests.cpp:: +PASSED: + REQUIRE( s1.isOpen() ) +with expansion: + true + +------------------------------------------------------------------------------- +Tracker + start a generator +------------------------------------------------------------------------------- +PartTracker.tests.cpp: +............................................................................... + +PartTracker.tests.cpp:: +PASSED: + REQUIRE( g1.isOpen() ) +with expansion: + true + +PartTracker.tests.cpp:: +PASSED: + REQUIRE( g1.index() == 0 ) +with expansion: + 0 == 0 + +PartTracker.tests.cpp:: +PASSED: + REQUIRE( g1.isComplete() == false ) +with expansion: + false == false + +PartTracker.tests.cpp:: +PASSED: + REQUIRE( s1.isComplete() == false ) +with expansion: + false == false + +------------------------------------------------------------------------------- +Tracker + start a generator + Fail an inner section +------------------------------------------------------------------------------- +PartTracker.tests.cpp: +............................................................................... + +PartTracker.tests.cpp:: +PASSED: + REQUIRE( s2.isOpen() ) +with expansion: + true + +PartTracker.tests.cpp:: +PASSED: + REQUIRE( s2.isComplete() ) +with expansion: + true + +PartTracker.tests.cpp:: +PASSED: + REQUIRE( s2.isSuccessfullyCompleted() == false ) +with expansion: + false == false + +PartTracker.tests.cpp:: +PASSED: + REQUIRE( s1.isComplete() == false ) +with expansion: + false == false + +PartTracker.tests.cpp:: +PASSED: + REQUIRE( testCase.isComplete() == false ) +with expansion: + false == false + +------------------------------------------------------------------------------- +Tracker + start a generator + Fail an inner section + Re-enter for second generation +------------------------------------------------------------------------------- +PartTracker.tests.cpp: +............................................................................... + +PartTracker.tests.cpp:: +PASSED: + REQUIRE( testCase2.isOpen() ) +with expansion: + true + +PartTracker.tests.cpp:: +PASSED: + REQUIRE( s1b.isOpen() ) +with expansion: + true + +PartTracker.tests.cpp:: +PASSED: + REQUIRE( g1b.isOpen() ) +with expansion: + true + +PartTracker.tests.cpp:: +PASSED: + REQUIRE( g1b.index() == 0 ) +with expansion: + 0 == 0 + +PartTracker.tests.cpp:: +PASSED: + REQUIRE( s2b.isOpen() == false ) +with expansion: + false == false + +PartTracker.tests.cpp:: +PASSED: + REQUIRE( g1b.isComplete() == false ) +with expansion: + false == false + +PartTracker.tests.cpp:: +PASSED: + REQUIRE( s1b.isComplete() == false ) +with expansion: + false == false + +PartTracker.tests.cpp:: +PASSED: + REQUIRE( testCase2.isComplete() == false ) +with expansion: + false == false + +PartTracker.tests.cpp:: +PASSED: + REQUIRE( testCase3.isOpen() ) +with expansion: + true + +PartTracker.tests.cpp:: +PASSED: + REQUIRE( s1c.isOpen() ) +with expansion: + true + +PartTracker.tests.cpp:: +PASSED: + REQUIRE( g1c.isOpen() ) +with expansion: + true + +PartTracker.tests.cpp:: +PASSED: + REQUIRE( g1c.index() == 1 ) +with expansion: + 1 == 1 + +PartTracker.tests.cpp:: +PASSED: + REQUIRE( s2c.isOpen() ) +with expansion: + true + +PartTracker.tests.cpp:: +PASSED: + REQUIRE( s2c.isComplete() ) +with expansion: + true + +PartTracker.tests.cpp:: +PASSED: + REQUIRE( g1c.isComplete() ) +with expansion: + true + +PartTracker.tests.cpp:: +PASSED: + REQUIRE( s1c.isComplete() ) +with expansion: + true + +PartTracker.tests.cpp:: +PASSED: + REQUIRE( testCase3.isComplete() ) +with expansion: + true + +------------------------------------------------------------------------------- +Unexpected exceptions can be translated +------------------------------------------------------------------------------- +Exception.tests.cpp: +............................................................................... + +Exception.tests.cpp:: FAILED: +due to unexpected exception with message: + 3.14 + +------------------------------------------------------------------------------- +Use a custom approx +------------------------------------------------------------------------------- +Approx.tests.cpp: +............................................................................... + +Approx.tests.cpp:: +PASSED: + REQUIRE( d == approx( 1.23 ) ) +with expansion: + 1.23 == Approx( 1.23 ) + +Approx.tests.cpp:: +PASSED: + REQUIRE( d == approx( 1.22 ) ) +with expansion: + 1.23 == Approx( 1.22 ) + +Approx.tests.cpp:: +PASSED: + REQUIRE( d == approx( 1.24 ) ) +with expansion: + 1.23 == Approx( 1.24 ) + +Approx.tests.cpp:: +PASSED: + REQUIRE( d != approx( 1.25 ) ) +with expansion: + 1.23 != Approx( 1.25 ) + +Approx.tests.cpp:: +PASSED: + REQUIRE( approx( d ) == 1.23 ) +with expansion: + Approx( 1.23 ) == 1.23 + +Approx.tests.cpp:: +PASSED: + REQUIRE( approx( d ) == 1.22 ) +with expansion: + Approx( 1.23 ) == 1.22 + +Approx.tests.cpp:: +PASSED: + REQUIRE( approx( d ) == 1.24 ) +with expansion: + Approx( 1.23 ) == 1.24 + +Approx.tests.cpp:: +PASSED: + REQUIRE( approx( d ) != 1.25 ) +with expansion: + Approx( 1.23 ) != 1.25 + +------------------------------------------------------------------------------- +Variadic macros + Section with one argument +------------------------------------------------------------------------------- +VariadicMacros.tests.cpp: +............................................................................... + +VariadicMacros.tests.cpp:: +PASSED: +with message: + no assertions + +------------------------------------------------------------------------------- +Vector matchers + Contains (element) +------------------------------------------------------------------------------- +Matchers.tests.cpp: +............................................................................... + +Matchers.tests.cpp:: +PASSED: + CHECK_THAT( v, VectorContains(1) ) +with expansion: + { 1, 2, 3 } Contains: 1 + +Matchers.tests.cpp:: +PASSED: + CHECK_THAT( v, VectorContains(2) ) +with expansion: + { 1, 2, 3 } Contains: 2 + +------------------------------------------------------------------------------- +Vector matchers + Contains (vector) +------------------------------------------------------------------------------- +Matchers.tests.cpp: +............................................................................... + +Matchers.tests.cpp:: +PASSED: + CHECK_THAT( v, Contains(v2) ) +with expansion: + { 1, 2, 3 } Contains: { 1, 2 } + +Matchers.tests.cpp:: +PASSED: + CHECK_THAT( v, Contains(v2) ) +with expansion: + { 1, 2, 3 } Contains: { 1, 2, 3 } + +Matchers.tests.cpp:: +PASSED: + CHECK_THAT( v, Contains(empty) ) +with expansion: + { 1, 2, 3 } Contains: { } + +Matchers.tests.cpp:: +PASSED: + CHECK_THAT( empty, Contains(empty) ) +with expansion: + { } Contains: { } + +------------------------------------------------------------------------------- +Vector matchers + Contains (element), composed +------------------------------------------------------------------------------- +Matchers.tests.cpp: +............................................................................... + +Matchers.tests.cpp:: +PASSED: + CHECK_THAT( v, VectorContains(1) && VectorContains(2) ) +with expansion: + { 1, 2, 3 } ( Contains: 1 and Contains: 2 ) + +------------------------------------------------------------------------------- +Vector matchers + Equals +------------------------------------------------------------------------------- +Matchers.tests.cpp: +............................................................................... + +Matchers.tests.cpp:: +PASSED: + CHECK_THAT( v, Equals(v) ) +with expansion: + { 1, 2, 3 } Equals: { 1, 2, 3 } + +Matchers.tests.cpp:: +PASSED: + CHECK_THAT( empty, Equals(empty) ) +with expansion: + { } Equals: { } + +Matchers.tests.cpp:: +PASSED: + CHECK_THAT( v, Equals(v2) ) +with expansion: + { 1, 2, 3 } Equals: { 1, 2, 3 } + +------------------------------------------------------------------------------- +Vector matchers + UnorderedEquals +------------------------------------------------------------------------------- +Matchers.tests.cpp: +............................................................................... + +Matchers.tests.cpp:: +PASSED: + CHECK_THAT( v, UnorderedEquals(v) ) +with expansion: + { 1, 2, 3 } UnorderedEquals: { 1, 2, 3 } + +Matchers.tests.cpp:: +PASSED: + CHECK_THAT( empty, UnorderedEquals(empty) ) +with expansion: + { } UnorderedEquals: { } + +Matchers.tests.cpp:: +PASSED: + REQUIRE_THAT( permuted, UnorderedEquals(v) ) +with expansion: + { 1, 3, 2 } UnorderedEquals: { 1, 2, 3 } + +Matchers.tests.cpp:: +PASSED: + REQUIRE_THAT( permuted, UnorderedEquals(v) ) +with expansion: + { 2, 3, 1 } UnorderedEquals: { 1, 2, 3 } + +------------------------------------------------------------------------------- +Vector matchers that fail + Contains (element) +------------------------------------------------------------------------------- +Matchers.tests.cpp: +............................................................................... + +Matchers.tests.cpp:: FAILED: + CHECK_THAT( v, VectorContains(-1) ) +with expansion: + { 1, 2, 3 } Contains: -1 + +Matchers.tests.cpp:: FAILED: + CHECK_THAT( empty, VectorContains(1) ) +with expansion: + { } Contains: 1 + +------------------------------------------------------------------------------- +Vector matchers that fail + Contains (vector) +------------------------------------------------------------------------------- +Matchers.tests.cpp: +............................................................................... + +Matchers.tests.cpp:: FAILED: + CHECK_THAT( empty, Contains(v) ) +with expansion: + { } Contains: { 1, 2, 3 } + +Matchers.tests.cpp:: FAILED: + CHECK_THAT( v, Contains(v2) ) +with expansion: + { 1, 2, 3 } Contains: { 1, 2, 4 } + +------------------------------------------------------------------------------- +Vector matchers that fail + Equals +------------------------------------------------------------------------------- +Matchers.tests.cpp: +............................................................................... + +Matchers.tests.cpp:: FAILED: + CHECK_THAT( v, Equals(v2) ) +with expansion: + { 1, 2, 3 } Equals: { 1, 2 } + +Matchers.tests.cpp:: FAILED: + CHECK_THAT( v2, Equals(v) ) +with expansion: + { 1, 2 } Equals: { 1, 2, 3 } + +Matchers.tests.cpp:: FAILED: + CHECK_THAT( empty, Equals(v) ) +with expansion: + { } Equals: { 1, 2, 3 } + +Matchers.tests.cpp:: FAILED: + CHECK_THAT( v, Equals(empty) ) +with expansion: + { 1, 2, 3 } Equals: { } + +------------------------------------------------------------------------------- +Vector matchers that fail + UnorderedEquals +------------------------------------------------------------------------------- +Matchers.tests.cpp: +............................................................................... + +Matchers.tests.cpp:: FAILED: + CHECK_THAT( v, UnorderedEquals(empty) ) +with expansion: + { 1, 2, 3 } UnorderedEquals: { } + +Matchers.tests.cpp:: FAILED: + CHECK_THAT( empty, UnorderedEquals(v) ) +with expansion: + { } UnorderedEquals: { 1, 2, 3 } + +Matchers.tests.cpp:: FAILED: + CHECK_THAT( permuted, UnorderedEquals(v) ) +with expansion: + { 1, 3 } UnorderedEquals: { 1, 2, 3 } + +Matchers.tests.cpp:: FAILED: + CHECK_THAT( permuted, UnorderedEquals(v) ) +with expansion: + { 3, 1 } UnorderedEquals: { 1, 2, 3 } + +------------------------------------------------------------------------------- +When checked exceptions are thrown they can be expected or unexpected +------------------------------------------------------------------------------- +Exception.tests.cpp: +............................................................................... + +Exception.tests.cpp:: +PASSED: + REQUIRE_THROWS_AS( thisThrows(), std::domain_error ) + +Exception.tests.cpp:: +PASSED: + REQUIRE_NOTHROW( thisDoesntThrow() ) + +Exception.tests.cpp:: +PASSED: + REQUIRE_THROWS( thisThrows() ) + +------------------------------------------------------------------------------- +When unchecked exceptions are thrown directly they are always failures +------------------------------------------------------------------------------- +Exception.tests.cpp: +............................................................................... + +Exception.tests.cpp:: FAILED: +due to unexpected exception with message: + unexpected exception + +------------------------------------------------------------------------------- +When unchecked exceptions are thrown during a CHECK the test should continue +------------------------------------------------------------------------------- +Exception.tests.cpp: +............................................................................... + +Exception.tests.cpp:: FAILED: + CHECK( thisThrows() == 0 ) +due to unexpected exception with message: + expected exception + +------------------------------------------------------------------------------- +When unchecked exceptions are thrown during a REQUIRE the test should abort +fail +------------------------------------------------------------------------------- +Exception.tests.cpp: +............................................................................... + +Exception.tests.cpp:: FAILED: + REQUIRE( thisThrows() == 0 ) +due to unexpected exception with message: + expected exception + +------------------------------------------------------------------------------- +When unchecked exceptions are thrown from functions they are always failures +------------------------------------------------------------------------------- +Exception.tests.cpp: +............................................................................... + +Exception.tests.cpp:: FAILED: + CHECK( thisThrows() == 0 ) +due to unexpected exception with message: + expected exception + +------------------------------------------------------------------------------- +When unchecked exceptions are thrown from sections they are always failures + section name +------------------------------------------------------------------------------- +Exception.tests.cpp: +............................................................................... + +Exception.tests.cpp:: FAILED: +due to unexpected exception with message: + unexpected exception + +------------------------------------------------------------------------------- +When unchecked exceptions are thrown, but caught, they do not affect the test +------------------------------------------------------------------------------- +Exception.tests.cpp: +............................................................................... + + +No assertions in test case 'When unchecked exceptions are thrown, but caught, they do not affect the test' + +------------------------------------------------------------------------------- +Where the LHS is not a simple value +------------------------------------------------------------------------------- +Tricky.tests.cpp: +............................................................................... + +Tricky.tests.cpp:: +warning: + Uncomment the code in this test to check that it gives a sensible compiler + error + + +No assertions in test case 'Where the LHS is not a simple value' + +------------------------------------------------------------------------------- +Where there is more to the expression after the RHS +------------------------------------------------------------------------------- +Tricky.tests.cpp: +............................................................................... + +Tricky.tests.cpp:: +warning: + Uncomment the code in this test to check that it gives a sensible compiler + error + + +No assertions in test case 'Where there is more to the expression after the RHS' + +------------------------------------------------------------------------------- +X/level/0/a +------------------------------------------------------------------------------- +Tricky.tests.cpp: +............................................................................... + +Tricky.tests.cpp:: +PASSED: + +------------------------------------------------------------------------------- +X/level/0/b +------------------------------------------------------------------------------- +Tricky.tests.cpp: +............................................................................... + +Tricky.tests.cpp:: +PASSED: + +------------------------------------------------------------------------------- +X/level/1/a +------------------------------------------------------------------------------- +Tricky.tests.cpp: +............................................................................... + +Tricky.tests.cpp:: +PASSED: + +------------------------------------------------------------------------------- +X/level/1/b +------------------------------------------------------------------------------- +Tricky.tests.cpp: +............................................................................... + +Tricky.tests.cpp:: +PASSED: + +------------------------------------------------------------------------------- +XmlEncode + normal string +------------------------------------------------------------------------------- +Xml.tests.cpp: +............................................................................... + +Xml.tests.cpp:: +PASSED: + REQUIRE( encode( "normal string" ) == "normal string" ) +with expansion: + "normal string" == "normal string" + +------------------------------------------------------------------------------- +XmlEncode + empty string +------------------------------------------------------------------------------- +Xml.tests.cpp: +............................................................................... + +Xml.tests.cpp:: +PASSED: + REQUIRE( encode( "" ) == "" ) +with expansion: + "" == "" + +------------------------------------------------------------------------------- +XmlEncode + string with ampersand +------------------------------------------------------------------------------- +Xml.tests.cpp: +............................................................................... + +Xml.tests.cpp:: +PASSED: + REQUIRE( encode( "smith & jones" ) == "smith & jones" ) +with expansion: + "smith & jones" == "smith & jones" + +------------------------------------------------------------------------------- +XmlEncode + string with less-than +------------------------------------------------------------------------------- +Xml.tests.cpp: +............................................................................... + +Xml.tests.cpp:: +PASSED: + REQUIRE( encode( "smith < jones" ) == "smith < jones" ) +with expansion: + "smith < jones" == "smith < jones" + +------------------------------------------------------------------------------- +XmlEncode + string with greater-than +------------------------------------------------------------------------------- +Xml.tests.cpp: +............................................................................... + +Xml.tests.cpp:: +PASSED: + REQUIRE( encode( "smith > jones" ) == "smith > jones" ) +with expansion: + "smith > jones" == "smith > jones" + +Xml.tests.cpp:: +PASSED: + REQUIRE( encode( "smith ]]> jones" ) == "smith ]]> jones" ) +with expansion: + "smith ]]> jones" + == + "smith ]]> jones" + +------------------------------------------------------------------------------- +XmlEncode + string with quotes +------------------------------------------------------------------------------- +Xml.tests.cpp: +............................................................................... + +Xml.tests.cpp:: +PASSED: + REQUIRE( encode( stringWithQuotes ) == stringWithQuotes ) +with expansion: + "don't "quote" me on that" + == + "don't "quote" me on that" + +Xml.tests.cpp:: +PASSED: + REQUIRE( encode( stringWithQuotes, Catch::XmlEncode::ForAttributes ) == "don't "quote" me on that" ) +with expansion: + "don't "quote" me on that" + == + "don't "quote" me on that" + +------------------------------------------------------------------------------- +XmlEncode + string with control char (1) +------------------------------------------------------------------------------- +Xml.tests.cpp: +............................................................................... + +Xml.tests.cpp:: +PASSED: + REQUIRE( encode( "[\x01]" ) == "[\\x01]" ) +with expansion: + "[\x01]" == "[\x01]" + +------------------------------------------------------------------------------- +XmlEncode + string with control char (x7F) +------------------------------------------------------------------------------- +Xml.tests.cpp: +............................................................................... + +Xml.tests.cpp:: +PASSED: + REQUIRE( encode( "[\x7F]" ) == "[\\x7F]" ) +with expansion: + "[\x7F]" == "[\x7F]" + +------------------------------------------------------------------------------- +XmlEncode: UTF-8 + Valid utf-8 strings +------------------------------------------------------------------------------- +Xml.tests.cpp: +............................................................................... + +Xml.tests.cpp:: +PASSED: + CHECK( encode(u8"Here be 👾") == u8"Here be 👾" ) +with expansion: + "Here be 👾" == "Here be 👾" + +Xml.tests.cpp:: +PASSED: + CHECK( encode(u8"Å¡Å¡") == u8"Å¡Å¡" ) +with expansion: + "Å¡Å¡" == "Å¡Å¡" + +Xml.tests.cpp:: +PASSED: + CHECK( encode("\xDF\xBF") == "\xDF\xBF" ) +with expansion: + "ß¿" == "ß¿" + +Xml.tests.cpp:: +PASSED: + CHECK( encode("\xE0\xA0\x80") == "\xE0\xA0\x80" ) +with expansion: + "à €" == "à €" + +Xml.tests.cpp:: +PASSED: + CHECK( encode("\xED\x9F\xBF") == "\xED\x9F\xBF" ) +with expansion: + "퟿" == "퟿" + +Xml.tests.cpp:: +PASSED: + CHECK( encode("\xEE\x80\x80") == "\xEE\x80\x80" ) +with expansion: + "" == "" + +Xml.tests.cpp:: +PASSED: + CHECK( encode("\xEF\xBF\xBF") == "\xEF\xBF\xBF" ) +with expansion: + "ï¿¿" == "ï¿¿" + +Xml.tests.cpp:: +PASSED: + CHECK( encode("\xF0\x90\x80\x80") == "\xF0\x90\x80\x80" ) +with expansion: + "ð€€" == "ð€€" + +Xml.tests.cpp:: +PASSED: + CHECK( encode("\xF4\x8F\xBF\xBF") == "\xF4\x8F\xBF\xBF" ) +with expansion: + "ô¿¿" == "ô¿¿" + +------------------------------------------------------------------------------- +XmlEncode: UTF-8 + Invalid utf-8 strings + Various broken strings +------------------------------------------------------------------------------- +Xml.tests.cpp: +............................................................................... + +Xml.tests.cpp:: +PASSED: + CHECK( encode("Here \xFF be 👾") == u8"Here \\xFF be 👾" ) +with expansion: + "Here \xFF be 👾" == "Here \xFF be 👾" + +Xml.tests.cpp:: +PASSED: + CHECK( encode("\xFF") == "\\xFF" ) +with expansion: + "\xFF" == "\xFF" + +Xml.tests.cpp:: +PASSED: + CHECK( encode("\xC5\xC5\xA0") == u8"\\xC5Å " ) +with expansion: + "\xC5Å " == "\xC5Å " + +Xml.tests.cpp:: +PASSED: + CHECK( encode("\xF4\x90\x80\x80") == u8"\\xF4\\x90\\x80\\x80" ) +with expansion: + "\xF4\x90\x80\x80" == "\xF4\x90\x80\x80" + +------------------------------------------------------------------------------- +XmlEncode: UTF-8 + Invalid utf-8 strings + Overlong encodings +------------------------------------------------------------------------------- +Xml.tests.cpp: +............................................................................... + +Xml.tests.cpp:: +PASSED: + CHECK( encode("\xC0\x80") == u8"\\xC0\\x80" ) +with expansion: + "\xC0\x80" == "\xC0\x80" + +Xml.tests.cpp:: +PASSED: + CHECK( encode("\xF0\x80\x80\x80") == u8"\\xF0\\x80\\x80\\x80" ) +with expansion: + "\xF0\x80\x80\x80" == "\xF0\x80\x80\x80" + +Xml.tests.cpp:: +PASSED: + CHECK( encode("\xC1\xBF") == u8"\\xC1\\xBF" ) +with expansion: + "\xC1\xBF" == "\xC1\xBF" + +Xml.tests.cpp:: +PASSED: + CHECK( encode("\xE0\x9F\xBF") == u8"\\xE0\\x9F\\xBF" ) +with expansion: + "\xE0\x9F\xBF" == "\xE0\x9F\xBF" + +Xml.tests.cpp:: +PASSED: + CHECK( encode("\xF0\x8F\xBF\xBF") == u8"\\xF0\\x8F\\xBF\\xBF" ) +with expansion: + "\xF0\x8F\xBF\xBF" == "\xF0\x8F\xBF\xBF" + +------------------------------------------------------------------------------- +XmlEncode: UTF-8 + Invalid utf-8 strings + Surrogate pairs +------------------------------------------------------------------------------- +Xml.tests.cpp: +............................................................................... + +Xml.tests.cpp:: +PASSED: + CHECK( encode("\xED\xA0\x80") == "\xED\xA0\x80" ) +with expansion: + "í €" == "í €" + +Xml.tests.cpp:: +PASSED: + CHECK( encode("\xED\xAF\xBF") == "\xED\xAF\xBF" ) +with expansion: + "í¯¿" == "í¯¿" + +Xml.tests.cpp:: +PASSED: + CHECK( encode("\xED\xB0\x80") == "\xED\xB0\x80" ) +with expansion: + "í°€" == "í°€" + +Xml.tests.cpp:: +PASSED: + CHECK( encode("\xED\xBF\xBF") == "\xED\xBF\xBF" ) +with expansion: + "í¿¿" == "í¿¿" + +------------------------------------------------------------------------------- +XmlEncode: UTF-8 + Invalid utf-8 strings + Invalid start byte +------------------------------------------------------------------------------- +Xml.tests.cpp: +............................................................................... + +Xml.tests.cpp:: +PASSED: + CHECK( encode("\x80") == u8"\\x80" ) +with expansion: + "\x80" == "\x80" + +Xml.tests.cpp:: +PASSED: + CHECK( encode("\x81") == u8"\\x81" ) +with expansion: + "\x81" == "\x81" + +Xml.tests.cpp:: +PASSED: + CHECK( encode("\xBC") == u8"\\xBC" ) +with expansion: + "\xBC" == "\xBC" + +Xml.tests.cpp:: +PASSED: + CHECK( encode("\xBF") == u8"\\xBF" ) +with expansion: + "\xBF" == "\xBF" + +Xml.tests.cpp:: +PASSED: + CHECK( encode("\xF5\x80\x80\x80") == u8"\\xF5\\x80\\x80\\x80" ) +with expansion: + "\xF5\x80\x80\x80" == "\xF5\x80\x80\x80" + +Xml.tests.cpp:: +PASSED: + CHECK( encode("\xF6\x80\x80\x80") == u8"\\xF6\\x80\\x80\\x80" ) +with expansion: + "\xF6\x80\x80\x80" == "\xF6\x80\x80\x80" + +Xml.tests.cpp:: +PASSED: + CHECK( encode("\xF7\x80\x80\x80") == u8"\\xF7\\x80\\x80\\x80" ) +with expansion: + "\xF7\x80\x80\x80" == "\xF7\x80\x80\x80" + +------------------------------------------------------------------------------- +XmlEncode: UTF-8 + Invalid utf-8 strings + Missing continuation byte(s) +------------------------------------------------------------------------------- +Xml.tests.cpp: +............................................................................... + +Xml.tests.cpp:: +PASSED: + CHECK( encode("\xDE") == u8"\\xDE" ) +with expansion: + "\xDE" == "\xDE" + +Xml.tests.cpp:: +PASSED: + CHECK( encode("\xDF") == u8"\\xDF" ) +with expansion: + "\xDF" == "\xDF" + +Xml.tests.cpp:: +PASSED: + CHECK( encode("\xE0") == u8"\\xE0" ) +with expansion: + "\xE0" == "\xE0" + +Xml.tests.cpp:: +PASSED: + CHECK( encode("\xEF") == u8"\\xEF" ) +with expansion: + "\xEF" == "\xEF" + +Xml.tests.cpp:: +PASSED: + CHECK( encode("\xF0") == u8"\\xF0" ) +with expansion: + "\xF0" == "\xF0" + +Xml.tests.cpp:: +PASSED: + CHECK( encode("\xF4") == u8"\\xF4" ) +with expansion: + "\xF4" == "\xF4" + +Xml.tests.cpp:: +PASSED: + CHECK( encode("\xE0\x80") == u8"\\xE0\\x80" ) +with expansion: + "\xE0\x80" == "\xE0\x80" + +Xml.tests.cpp:: +PASSED: + CHECK( encode("\xE0\xBF") == u8"\\xE0\\xBF" ) +with expansion: + "\xE0\xBF" == "\xE0\xBF" + +Xml.tests.cpp:: +PASSED: + CHECK( encode("\xE1\x80") == u8"\\xE1\\x80" ) +with expansion: + "\xE1\x80" == "\xE1\x80" + +Xml.tests.cpp:: +PASSED: + CHECK( encode("\xF0\x80") == u8"\\xF0\\x80" ) +with expansion: + "\xF0\x80" == "\xF0\x80" + +Xml.tests.cpp:: +PASSED: + CHECK( encode("\xF4\x80") == u8"\\xF4\\x80" ) +with expansion: + "\xF4\x80" == "\xF4\x80" + +Xml.tests.cpp:: +PASSED: + CHECK( encode("\xF0\x80\x80") == u8"\\xF0\\x80\\x80" ) +with expansion: + "\xF0\x80\x80" == "\xF0\x80\x80" + +Xml.tests.cpp:: +PASSED: + CHECK( encode("\xF4\x80\x80") == u8"\\xF4\\x80\\x80" ) +with expansion: + "\xF4\x80\x80" == "\xF4\x80\x80" + +------------------------------------------------------------------------------- +array -> toString +------------------------------------------------------------------------------- +ToStringVector.tests.cpp: +............................................................................... + +ToStringVector.tests.cpp:: +PASSED: + REQUIRE( Catch::Detail::stringify( empty ) == "{ }" ) +with expansion: + "{ }" == "{ }" + +ToStringVector.tests.cpp:: +PASSED: + REQUIRE( Catch::Detail::stringify( oneValue ) == "{ 42 }" ) +with expansion: + "{ 42 }" == "{ 42 }" + +ToStringVector.tests.cpp:: +PASSED: + REQUIRE( Catch::Detail::stringify( twoValues ) == "{ 42, 250 }" ) +with expansion: + "{ 42, 250 }" == "{ 42, 250 }" + +------------------------------------------------------------------------------- +atomic if +------------------------------------------------------------------------------- +Misc.tests.cpp: +............................................................................... + +Misc.tests.cpp:: +PASSED: + REQUIRE( x == 0 ) +with expansion: + 0 == 0 + +------------------------------------------------------------------------------- +boolean member +------------------------------------------------------------------------------- +Tricky.tests.cpp: +............................................................................... + +Tricky.tests.cpp:: +PASSED: + REQUIRE( obj.prop != 0 ) +with expansion: + 0x != 0 + +------------------------------------------------------------------------------- +checkedElse +------------------------------------------------------------------------------- +Misc.tests.cpp: +............................................................................... + +Misc.tests.cpp:: +PASSED: + CHECKED_ELSE( flag ) +with expansion: + true + +Misc.tests.cpp:: +PASSED: + REQUIRE( testCheckedElse( true ) ) +with expansion: + true + +------------------------------------------------------------------------------- +checkedElse, failing +------------------------------------------------------------------------------- +Misc.tests.cpp: +............................................................................... + +Misc.tests.cpp:: FAILED: + CHECKED_ELSE( flag ) +with expansion: + false + +Misc.tests.cpp:: FAILED: + REQUIRE( testCheckedElse( false ) ) +with expansion: + false + +------------------------------------------------------------------------------- +checkedIf +------------------------------------------------------------------------------- +Misc.tests.cpp: +............................................................................... + +Misc.tests.cpp:: +PASSED: + CHECKED_IF( flag ) +with expansion: + true + +Misc.tests.cpp:: +PASSED: + REQUIRE( testCheckedIf( true ) ) +with expansion: + true + +------------------------------------------------------------------------------- +checkedIf, failing +------------------------------------------------------------------------------- +Misc.tests.cpp: +............................................................................... + +Misc.tests.cpp:: FAILED: + CHECKED_IF( flag ) +with expansion: + false + +Misc.tests.cpp:: FAILED: + REQUIRE( testCheckedIf( false ) ) +with expansion: + false + +------------------------------------------------------------------------------- +comparisons between const int variables +------------------------------------------------------------------------------- +Condition.tests.cpp: +............................................................................... + +Condition.tests.cpp:: +PASSED: + REQUIRE( unsigned_char_var == 1 ) +with expansion: + 1 == 1 + +Condition.tests.cpp:: +PASSED: + REQUIRE( unsigned_short_var == 1 ) +with expansion: + 1 == 1 + +Condition.tests.cpp:: +PASSED: + REQUIRE( unsigned_int_var == 1 ) +with expansion: + 1 == 1 + +Condition.tests.cpp:: +PASSED: + REQUIRE( unsigned_long_var == 1 ) +with expansion: + 1 == 1 + +------------------------------------------------------------------------------- +comparisons between int variables +------------------------------------------------------------------------------- +Condition.tests.cpp: +............................................................................... + +Condition.tests.cpp:: +PASSED: + REQUIRE( long_var == unsigned_char_var ) +with expansion: + 1 == 1 + +Condition.tests.cpp:: +PASSED: + REQUIRE( long_var == unsigned_short_var ) +with expansion: + 1 == 1 + +Condition.tests.cpp:: +PASSED: + REQUIRE( long_var == unsigned_int_var ) +with expansion: + 1 == 1 + +Condition.tests.cpp:: +PASSED: + REQUIRE( long_var == unsigned_long_var ) +with expansion: + 1 == 1 + +------------------------------------------------------------------------------- +even more nested SECTION tests + c + d (leaf) +------------------------------------------------------------------------------- +Misc.tests.cpp: +............................................................................... + +Misc.tests.cpp:: +PASSED: + +------------------------------------------------------------------------------- +even more nested SECTION tests + c + e (leaf) +------------------------------------------------------------------------------- +Misc.tests.cpp: +............................................................................... + +Misc.tests.cpp:: +PASSED: + +------------------------------------------------------------------------------- +even more nested SECTION tests + f (leaf) +------------------------------------------------------------------------------- +Misc.tests.cpp: +............................................................................... + +Misc.tests.cpp:: +PASSED: + +------------------------------------------------------------------------------- +first tag +------------------------------------------------------------------------------- +Misc.tests.cpp: +............................................................................... + + +No assertions in test case 'first tag' + +loose text artifact +------------------------------------------------------------------------------- +has printf +------------------------------------------------------------------------------- +Tricky.tests.cpp: +............................................................................... + + +No assertions in test case 'has printf' + +------------------------------------------------------------------------------- +just failure +------------------------------------------------------------------------------- +Message.tests.cpp: +............................................................................... + +Message.tests.cpp:: FAILED: +explicitly with message: + Previous info should not be seen + +------------------------------------------------------------------------------- +just info +------------------------------------------------------------------------------- +Message.tests.cpp: +............................................................................... + + +No assertions in test case 'just info' + +------------------------------------------------------------------------------- +long long +------------------------------------------------------------------------------- +Misc.tests.cpp: +............................................................................... + +Misc.tests.cpp:: +PASSED: + REQUIRE( l == std::numeric_limits::max() ) +with expansion: + 9223372036854775807 (0x) + == + 9223372036854775807 (0x) + +------------------------------------------------------------------------------- +looped SECTION tests + b is currently: 0 +------------------------------------------------------------------------------- +Misc.tests.cpp: +............................................................................... + +Misc.tests.cpp:: FAILED: + CHECK( b > a ) +with expansion: + 0 > 1 + +------------------------------------------------------------------------------- +looped SECTION tests + b is currently: 1 +------------------------------------------------------------------------------- +Misc.tests.cpp: +............................................................................... + +Misc.tests.cpp:: FAILED: + CHECK( b > a ) +with expansion: + 1 > 1 + +------------------------------------------------------------------------------- +looped SECTION tests + b is currently: 2 +------------------------------------------------------------------------------- +Misc.tests.cpp: +............................................................................... + +Misc.tests.cpp:: +PASSED: + CHECK( b > a ) +with expansion: + 2 > 1 + +------------------------------------------------------------------------------- +looped SECTION tests + b is currently: 3 +------------------------------------------------------------------------------- +Misc.tests.cpp: +............................................................................... + +Misc.tests.cpp:: +PASSED: + CHECK( b > a ) +with expansion: + 3 > 1 + +------------------------------------------------------------------------------- +looped SECTION tests + b is currently: 4 +------------------------------------------------------------------------------- +Misc.tests.cpp: +............................................................................... + +Misc.tests.cpp:: +PASSED: + CHECK( b > a ) +with expansion: + 4 > 1 + +------------------------------------------------------------------------------- +looped SECTION tests + b is currently: 5 +------------------------------------------------------------------------------- +Misc.tests.cpp: +............................................................................... + +Misc.tests.cpp:: +PASSED: + CHECK( b > a ) +with expansion: + 5 > 1 + +------------------------------------------------------------------------------- +looped SECTION tests + b is currently: 6 +------------------------------------------------------------------------------- +Misc.tests.cpp: +............................................................................... + +Misc.tests.cpp:: +PASSED: + CHECK( b > a ) +with expansion: + 6 > 1 + +------------------------------------------------------------------------------- +looped SECTION tests + b is currently: 7 +------------------------------------------------------------------------------- +Misc.tests.cpp: +............................................................................... + +Misc.tests.cpp:: +PASSED: + CHECK( b > a ) +with expansion: + 7 > 1 + +------------------------------------------------------------------------------- +looped SECTION tests + b is currently: 8 +------------------------------------------------------------------------------- +Misc.tests.cpp: +............................................................................... + +Misc.tests.cpp:: +PASSED: + CHECK( b > a ) +with expansion: + 8 > 1 + +------------------------------------------------------------------------------- +looped SECTION tests + b is currently: 9 +------------------------------------------------------------------------------- +Misc.tests.cpp: +............................................................................... + +Misc.tests.cpp:: +PASSED: + CHECK( b > a ) +with expansion: + 9 > 1 + +------------------------------------------------------------------------------- +looped tests +------------------------------------------------------------------------------- +Misc.tests.cpp: +............................................................................... + +Misc.tests.cpp:: FAILED: + CHECK( ( fib[i] % 2 ) == 0 ) +with expansion: + 1 == 0 +with message: + Testing if fib[0] (1) is even + +Misc.tests.cpp:: FAILED: + CHECK( ( fib[i] % 2 ) == 0 ) +with expansion: + 1 == 0 +with message: + Testing if fib[1] (1) is even + +Misc.tests.cpp:: +PASSED: + CHECK( ( fib[i] % 2 ) == 0 ) +with expansion: + 0 == 0 +with message: + Testing if fib[2] (2) is even + +Misc.tests.cpp:: FAILED: + CHECK( ( fib[i] % 2 ) == 0 ) +with expansion: + 1 == 0 +with message: + Testing if fib[3] (3) is even + +Misc.tests.cpp:: FAILED: + CHECK( ( fib[i] % 2 ) == 0 ) +with expansion: + 1 == 0 +with message: + Testing if fib[4] (5) is even + +Misc.tests.cpp:: +PASSED: + CHECK( ( fib[i] % 2 ) == 0 ) +with expansion: + 0 == 0 +with message: + Testing if fib[5] (8) is even + +Misc.tests.cpp:: FAILED: + CHECK( ( fib[i] % 2 ) == 0 ) +with expansion: + 1 == 0 +with message: + Testing if fib[6] (13) is even + +Misc.tests.cpp:: FAILED: + CHECK( ( fib[i] % 2 ) == 0 ) +with expansion: + 1 == 0 +with message: + Testing if fib[7] (21) is even + +------------------------------------------------------------------------------- +more nested SECTION tests + doesn't equal + equal +------------------------------------------------------------------------------- +Misc.tests.cpp: +............................................................................... + +Misc.tests.cpp:: FAILED: + REQUIRE( a == b ) +with expansion: + 1 == 2 + +------------------------------------------------------------------------------- +more nested SECTION tests + doesn't equal + not equal +------------------------------------------------------------------------------- +Misc.tests.cpp: +............................................................................... + +Misc.tests.cpp:: +PASSED: + REQUIRE( a != b ) +with expansion: + 1 != 2 + +------------------------------------------------------------------------------- +more nested SECTION tests + doesn't equal + less than +------------------------------------------------------------------------------- +Misc.tests.cpp: +............................................................................... + +Misc.tests.cpp:: +PASSED: + REQUIRE( a < b ) +with expansion: + 1 < 2 + +------------------------------------------------------------------------------- +nested SECTION tests + doesn't equal +------------------------------------------------------------------------------- +Misc.tests.cpp: +............................................................................... + +Misc.tests.cpp:: +PASSED: + REQUIRE( a != b ) +with expansion: + 1 != 2 + +Misc.tests.cpp:: +PASSED: + REQUIRE( b != a ) +with expansion: + 2 != 1 + +------------------------------------------------------------------------------- +nested SECTION tests + doesn't equal + not equal +------------------------------------------------------------------------------- +Misc.tests.cpp: +............................................................................... + +Misc.tests.cpp:: +PASSED: + REQUIRE( a != b ) +with expansion: + 1 != 2 + +------------------------------------------------------------------------------- +non streamable - with conv. op +------------------------------------------------------------------------------- +Tricky.tests.cpp: +............................................................................... + +Tricky.tests.cpp:: +PASSED: + REQUIRE( s == "7" ) +with expansion: + "7" == "7" + +------------------------------------------------------------------------------- +non-copyable objects +------------------------------------------------------------------------------- +Tricky.tests.cpp: +............................................................................... + +Tricky.tests.cpp:: +PASSED: + CHECK( ti == typeid(int) ) +with expansion: + {?} == {?} + +------------------------------------------------------------------------------- +not allowed +------------------------------------------------------------------------------- +Misc.tests.cpp: +............................................................................... + +Misc.tests.cpp:: +PASSED: + +------------------------------------------------------------------------------- +null strings +------------------------------------------------------------------------------- +Misc.tests.cpp: +............................................................................... + +Misc.tests.cpp:: +PASSED: + REQUIRE( makeString( false ) != static_cast(0) ) +with expansion: + "valid string" != {null string} + +Misc.tests.cpp:: +PASSED: + REQUIRE( makeString( true ) == static_cast(0) ) +with expansion: + {null string} == {null string} + +------------------------------------------------------------------------------- +null_ptr +------------------------------------------------------------------------------- +Tricky.tests.cpp: +............................................................................... + +Tricky.tests.cpp:: +PASSED: + REQUIRE( ptr.get() == 0 ) +with expansion: + 0 == 0 + +------------------------------------------------------------------------------- +pair > -> toString +------------------------------------------------------------------------------- +ToStringPair.tests.cpp: +............................................................................... + +ToStringPair.tests.cpp:: +PASSED: + REQUIRE( ::Catch::Detail::stringify( pair ) == "{ { 42, \"Arthur\" }, { \"Ford\", 24 } }" ) +with expansion: + "{ { 42, "Arthur" }, { "Ford", 24 } }" + == + "{ { 42, "Arthur" }, { "Ford", 24 } }" + +------------------------------------------------------------------------------- +pointer to class +------------------------------------------------------------------------------- +Tricky.tests.cpp: +............................................................................... + +Tricky.tests.cpp:: +PASSED: + REQUIRE( p == 0 ) +with expansion: + 0 == 0 + +------------------------------------------------------------------------------- +random SECTION tests + doesn't equal +------------------------------------------------------------------------------- +Misc.tests.cpp: +............................................................................... + +Misc.tests.cpp:: +PASSED: + REQUIRE( a != b ) +with expansion: + 1 != 2 + +Misc.tests.cpp:: +PASSED: + REQUIRE( b != a ) +with expansion: + 2 != 1 + +------------------------------------------------------------------------------- +random SECTION tests + not equal +------------------------------------------------------------------------------- +Misc.tests.cpp: +............................................................................... + +Misc.tests.cpp:: +PASSED: + REQUIRE( a != b ) +with expansion: + 1 != 2 + +------------------------------------------------------------------------------- +replaceInPlace + replace single char +------------------------------------------------------------------------------- +String.tests.cpp: +............................................................................... + +String.tests.cpp:: +PASSED: + CHECK( Catch::replaceInPlace( letters, "b", "z" ) ) +with expansion: + true + +String.tests.cpp:: +PASSED: + CHECK( letters == "azcdefcg" ) +with expansion: + "azcdefcg" == "azcdefcg" + +------------------------------------------------------------------------------- +replaceInPlace + replace two chars +------------------------------------------------------------------------------- +String.tests.cpp: +............................................................................... + +String.tests.cpp:: +PASSED: + CHECK( Catch::replaceInPlace( letters, "c", "z" ) ) +with expansion: + true + +String.tests.cpp:: +PASSED: + CHECK( letters == "abzdefzg" ) +with expansion: + "abzdefzg" == "abzdefzg" + +------------------------------------------------------------------------------- +replaceInPlace + replace first char +------------------------------------------------------------------------------- +String.tests.cpp: +............................................................................... + +String.tests.cpp:: +PASSED: + CHECK( Catch::replaceInPlace( letters, "a", "z" ) ) +with expansion: + true + +String.tests.cpp:: +PASSED: + CHECK( letters == "zbcdefcg" ) +with expansion: + "zbcdefcg" == "zbcdefcg" + +------------------------------------------------------------------------------- +replaceInPlace + replace last char +------------------------------------------------------------------------------- +String.tests.cpp: +............................................................................... + +String.tests.cpp:: +PASSED: + CHECK( Catch::replaceInPlace( letters, "g", "z" ) ) +with expansion: + true + +String.tests.cpp:: +PASSED: + CHECK( letters == "abcdefcz" ) +with expansion: + "abcdefcz" == "abcdefcz" + +------------------------------------------------------------------------------- +replaceInPlace + replace all chars +------------------------------------------------------------------------------- +String.tests.cpp: +............................................................................... + +String.tests.cpp:: +PASSED: + CHECK( Catch::replaceInPlace( letters, letters, "replaced" ) ) +with expansion: + true + +String.tests.cpp:: +PASSED: + CHECK( letters == "replaced" ) +with expansion: + "replaced" == "replaced" + +------------------------------------------------------------------------------- +replaceInPlace + replace no chars +------------------------------------------------------------------------------- +String.tests.cpp: +............................................................................... + +String.tests.cpp:: +PASSED: + CHECK_FALSE( Catch::replaceInPlace( letters, "x", "z" ) ) +with expansion: + !false + +String.tests.cpp:: +PASSED: + CHECK( letters == letters ) +with expansion: + "abcdefcg" == "abcdefcg" + +------------------------------------------------------------------------------- +replaceInPlace + escape ' +------------------------------------------------------------------------------- +String.tests.cpp: +............................................................................... + +String.tests.cpp:: +PASSED: + CHECK( Catch::replaceInPlace( s, "'", "|'" ) ) +with expansion: + true + +String.tests.cpp:: +PASSED: + CHECK( s == "didn|'t" ) +with expansion: + "didn|'t" == "didn|'t" + +------------------------------------------------------------------------------- +second tag +------------------------------------------------------------------------------- +Misc.tests.cpp: +............................................................................... + + +No assertions in test case 'second tag' + +------------------------------------------------------------------------------- +send a single char to INFO +------------------------------------------------------------------------------- +Misc.tests.cpp: +............................................................................... + +Misc.tests.cpp:: FAILED: + REQUIRE( false ) +with message: + 3 + +------------------------------------------------------------------------------- +sends information to INFO +------------------------------------------------------------------------------- +Message.tests.cpp: +............................................................................... + +Message.tests.cpp:: FAILED: + REQUIRE( false ) +with messages: + hi + i := 7 + +------------------------------------------------------------------------------- +std::map is convertible string + empty +------------------------------------------------------------------------------- +ToStringGeneral.tests.cpp: +............................................................................... + +ToStringGeneral.tests.cpp:: +PASSED: + REQUIRE( Catch::Detail::stringify( emptyMap ) == "{ }" ) +with expansion: + "{ }" == "{ }" + +------------------------------------------------------------------------------- +std::map is convertible string + single item +------------------------------------------------------------------------------- +ToStringGeneral.tests.cpp: +............................................................................... + +ToStringGeneral.tests.cpp:: +PASSED: + REQUIRE( Catch::Detail::stringify( map ) == "{ { \"one\", 1 } }" ) +with expansion: + "{ { "one", 1 } }" == "{ { "one", 1 } }" + +------------------------------------------------------------------------------- +std::map is convertible string + several items +------------------------------------------------------------------------------- +ToStringGeneral.tests.cpp: +............................................................................... + +ToStringGeneral.tests.cpp:: +PASSED: + REQUIRE( Catch::Detail::stringify( map ) == "{ { \"abc\", 1 }, { \"def\", 2 }, { \"ghi\", 3 } }" ) +with expansion: + "{ { "abc", 1 }, { "def", 2 }, { "ghi", 3 } }" + == + "{ { "abc", 1 }, { "def", 2 }, { "ghi", 3 } }" + +------------------------------------------------------------------------------- +std::pair -> toString +------------------------------------------------------------------------------- +ToStringPair.tests.cpp: +............................................................................... + +ToStringPair.tests.cpp:: +PASSED: + REQUIRE( ::Catch::Detail::stringify(value) == "{ 34, \"xyzzy\" }" ) +with expansion: + "{ 34, "xyzzy" }" == "{ 34, "xyzzy" }" + +------------------------------------------------------------------------------- +std::pair -> toString +------------------------------------------------------------------------------- +ToStringPair.tests.cpp: +............................................................................... + +ToStringPair.tests.cpp:: +PASSED: + REQUIRE( ::Catch::Detail::stringify( value ) == "{ 34, \"xyzzy\" }" ) +with expansion: + "{ 34, "xyzzy" }" == "{ 34, "xyzzy" }" + +------------------------------------------------------------------------------- +std::set is convertible string + empty +------------------------------------------------------------------------------- +ToStringGeneral.tests.cpp: +............................................................................... + +ToStringGeneral.tests.cpp:: +PASSED: + REQUIRE( Catch::Detail::stringify( emptySet ) == "{ }" ) +with expansion: + "{ }" == "{ }" + +------------------------------------------------------------------------------- +std::set is convertible string + single item +------------------------------------------------------------------------------- +ToStringGeneral.tests.cpp: +............................................................................... + +ToStringGeneral.tests.cpp:: +PASSED: + REQUIRE( Catch::Detail::stringify( set ) == "{ \"one\" }" ) +with expansion: + "{ "one" }" == "{ "one" }" + +------------------------------------------------------------------------------- +std::set is convertible string + several items +------------------------------------------------------------------------------- +ToStringGeneral.tests.cpp: +............................................................................... + +ToStringGeneral.tests.cpp:: +PASSED: + REQUIRE( Catch::Detail::stringify( set ) == "{ \"abc\", \"def\", \"ghi\" }" ) +with expansion: + "{ "abc", "def", "ghi" }" + == + "{ "abc", "def", "ghi" }" + +------------------------------------------------------------------------------- +std::vector > -> toString +------------------------------------------------------------------------------- +ToStringPair.tests.cpp: +............................................................................... + +ToStringPair.tests.cpp:: +PASSED: + REQUIRE( ::Catch::Detail::stringify( pr ) == "{ { \"green\", 55 } }" ) +with expansion: + "{ { "green", 55 } }" + == + "{ { "green", 55 } }" + +------------------------------------------------------------------------------- +string literals of different sizes can be compared +------------------------------------------------------------------------------- +Tricky.tests.cpp: +............................................................................... + +Tricky.tests.cpp:: FAILED: + REQUIRE( std::string( "first" ) == "second" ) +with expansion: + "first" == "second" + +------------------------------------------------------------------------------- +stringify ranges +------------------------------------------------------------------------------- +ToStringWhich.tests.cpp: +............................................................................... + +ToStringWhich.tests.cpp:: +PASSED: + REQUIRE( ::Catch::Detail::stringify(streamable_range{}) == "op<<(streamable_range)" ) +with expansion: + "op<<(streamable_range)" + == + "op<<(streamable_range)" + +ToStringWhich.tests.cpp:: +PASSED: + REQUIRE( ::Catch::Detail::stringify(stringmaker_range{}) == "stringmaker(streamable_range)" ) +with expansion: + "stringmaker(streamable_range)" + == + "stringmaker(streamable_range)" + +ToStringWhich.tests.cpp:: +PASSED: + REQUIRE( ::Catch::Detail::stringify(just_range{}) == "{ 1, 2, 3, 4 }" ) +with expansion: + "{ 1, 2, 3, 4 }" == "{ 1, 2, 3, 4 }" + +ToStringWhich.tests.cpp:: +PASSED: + REQUIRE( ::Catch::Detail::stringify(disabled_range{}) == "{ !!! }" ) +with expansion: + "{ !!! }" == "{ !!! }" + +------------------------------------------------------------------------------- +stringify( has_maker ) +------------------------------------------------------------------------------- +ToStringWhich.tests.cpp: +............................................................................... + +ToStringWhich.tests.cpp:: +PASSED: + REQUIRE( ::Catch::Detail::stringify( item ) == "StringMaker" ) +with expansion: + "StringMaker" + == + "StringMaker" + +------------------------------------------------------------------------------- +stringify( has_maker_and_operator ) +------------------------------------------------------------------------------- +ToStringWhich.tests.cpp: +............................................................................... + +ToStringWhich.tests.cpp:: +PASSED: + REQUIRE( ::Catch::Detail::stringify( item ) == "StringMaker" ) +with expansion: + "StringMaker" + == + "StringMaker" + +------------------------------------------------------------------------------- +stringify( has_neither ) +------------------------------------------------------------------------------- +ToStringWhich.tests.cpp: +............................................................................... + +ToStringWhich.tests.cpp:: +PASSED: + REQUIRE( ::Catch::Detail::stringify(item) == "{ !!! }" ) +with expansion: + "{ !!! }" == "{ !!! }" + +------------------------------------------------------------------------------- +stringify( has_operator ) +------------------------------------------------------------------------------- +ToStringWhich.tests.cpp: +............................................................................... + +ToStringWhich.tests.cpp:: +PASSED: + REQUIRE( ::Catch::Detail::stringify( item ) == "operator<<( has_operator )" ) +with expansion: + "operator<<( has_operator )" + == + "operator<<( has_operator )" + +------------------------------------------------------------------------------- +stringify( has_template_operator ) +------------------------------------------------------------------------------- +ToStringWhich.tests.cpp: +............................................................................... + +ToStringWhich.tests.cpp:: +PASSED: + REQUIRE( ::Catch::Detail::stringify( item ) == "operator<<( has_template_operator )" ) +with expansion: + "operator<<( has_template_operator )" + == + "operator<<( has_template_operator )" + +------------------------------------------------------------------------------- +stringify( vectors ) +------------------------------------------------------------------------------- +ToStringWhich.tests.cpp: +............................................................................... + +ToStringWhich.tests.cpp:: +PASSED: + REQUIRE( ::Catch::Detail::stringify( v ) == "{ StringMaker }" ) +with expansion: + "{ StringMaker }" + == + "{ StringMaker }" + +------------------------------------------------------------------------------- +stringify( vectors ) +------------------------------------------------------------------------------- +ToStringWhich.tests.cpp: +............................................................................... + +ToStringWhich.tests.cpp:: +PASSED: + REQUIRE( ::Catch::Detail::stringify( v ) == "{ StringMaker }" ) +with expansion: + "{ StringMaker }" + == + "{ StringMaker }" + +------------------------------------------------------------------------------- +stringify( vectors ) +------------------------------------------------------------------------------- +ToStringWhich.tests.cpp: +............................................................................... + +ToStringWhich.tests.cpp:: +PASSED: + REQUIRE( ::Catch::Detail::stringify( v ) == "{ operator<<( has_operator ) }" ) +with expansion: + "{ operator<<( has_operator ) }" + == + "{ operator<<( has_operator ) }" + +------------------------------------------------------------------------------- +thrown std::strings are translated +------------------------------------------------------------------------------- +Exception.tests.cpp: +............................................................................... + +Exception.tests.cpp:: FAILED: +due to unexpected exception with message: + Why would you throw a std::string? + +------------------------------------------------------------------------------- +toString on const wchar_t const pointer returns the string contents +------------------------------------------------------------------------------- +Misc.tests.cpp: +............................................................................... + +Misc.tests.cpp:: +PASSED: + CHECK( result == "\"wide load\"" ) +with expansion: + ""wide load"" == ""wide load"" + +------------------------------------------------------------------------------- +toString on const wchar_t pointer returns the string contents +------------------------------------------------------------------------------- +Misc.tests.cpp: +............................................................................... + +Misc.tests.cpp:: +PASSED: + CHECK( result == "\"wide load\"" ) +with expansion: + ""wide load"" == ""wide load"" + +------------------------------------------------------------------------------- +toString on wchar_t const pointer returns the string contents +------------------------------------------------------------------------------- +Misc.tests.cpp: +............................................................................... + +Misc.tests.cpp:: +PASSED: + CHECK( result == "\"wide load\"" ) +with expansion: + ""wide load"" == ""wide load"" + +------------------------------------------------------------------------------- +toString on wchar_t returns the string contents +------------------------------------------------------------------------------- +Misc.tests.cpp: +............................................................................... + +Misc.tests.cpp:: +PASSED: + CHECK( result == "\"wide load\"" ) +with expansion: + ""wide load"" == ""wide load"" + +------------------------------------------------------------------------------- +toString(enum class w/operator<<) +------------------------------------------------------------------------------- +EnumToString.tests.cpp: +............................................................................... + +EnumToString.tests.cpp:: +PASSED: + CHECK( ::Catch::Detail::stringify(e0) == "E2/V0" ) +with expansion: + "E2/V0" == "E2/V0" + +EnumToString.tests.cpp:: +PASSED: + CHECK( ::Catch::Detail::stringify(e1) == "E2/V1" ) +with expansion: + "E2/V1" == "E2/V1" + +EnumToString.tests.cpp:: +PASSED: + CHECK( ::Catch::Detail::stringify(e3) == "Unknown enum value 10" ) +with expansion: + "Unknown enum value 10" + == + "Unknown enum value 10" + +------------------------------------------------------------------------------- +toString(enum class) +------------------------------------------------------------------------------- +EnumToString.tests.cpp: +............................................................................... + +EnumToString.tests.cpp:: +PASSED: + CHECK( ::Catch::Detail::stringify(e0) == "0" ) +with expansion: + "0" == "0" + +EnumToString.tests.cpp:: +PASSED: + CHECK( ::Catch::Detail::stringify(e1) == "1" ) +with expansion: + "1" == "1" + +------------------------------------------------------------------------------- +toString(enum w/operator<<) +------------------------------------------------------------------------------- +EnumToString.tests.cpp: +............................................................................... + +EnumToString.tests.cpp:: +PASSED: + CHECK( ::Catch::Detail::stringify(e0) == "E2{0}" ) +with expansion: + "E2{0}" == "E2{0}" + +EnumToString.tests.cpp:: +PASSED: + CHECK( ::Catch::Detail::stringify(e1) == "E2{1}" ) +with expansion: + "E2{1}" == "E2{1}" + +------------------------------------------------------------------------------- +toString(enum) +------------------------------------------------------------------------------- +EnumToString.tests.cpp: +............................................................................... + +EnumToString.tests.cpp:: +PASSED: + CHECK( ::Catch::Detail::stringify(e0) == "0" ) +with expansion: + "0" == "0" + +EnumToString.tests.cpp:: +PASSED: + CHECK( ::Catch::Detail::stringify(e1) == "1" ) +with expansion: + "1" == "1" + +------------------------------------------------------------------------------- +tuple<> +------------------------------------------------------------------------------- +ToStringTuple.tests.cpp: +............................................................................... + +ToStringTuple.tests.cpp:: +PASSED: + CHECK( "{ }" == ::Catch::Detail::stringify(type{}) ) +with expansion: + "{ }" == "{ }" + +ToStringTuple.tests.cpp:: +PASSED: + CHECK( "{ }" == ::Catch::Detail::stringify(value) ) +with expansion: + "{ }" == "{ }" + +------------------------------------------------------------------------------- +tuple +------------------------------------------------------------------------------- +ToStringTuple.tests.cpp: +............................................................................... + +ToStringTuple.tests.cpp:: +PASSED: + CHECK( "1.2f" == ::Catch::Detail::stringify(float(1.2)) ) +with expansion: + "1.2f" == "1.2f" + +ToStringTuple.tests.cpp:: +PASSED: + CHECK( "{ 1.2f, 0 }" == ::Catch::Detail::stringify(type{1.2f,0}) ) +with expansion: + "{ 1.2f, 0 }" == "{ 1.2f, 0 }" + +------------------------------------------------------------------------------- +tuple +------------------------------------------------------------------------------- +ToStringTuple.tests.cpp: +............................................................................... + +ToStringTuple.tests.cpp:: +PASSED: + CHECK( "{ 0 }" == ::Catch::Detail::stringify(type{0}) ) +with expansion: + "{ 0 }" == "{ 0 }" + +------------------------------------------------------------------------------- +tuple<0,int,const char *> +------------------------------------------------------------------------------- +ToStringTuple.tests.cpp: +............................................................................... + +ToStringTuple.tests.cpp:: +PASSED: + CHECK( "{ 0, 42, \"Catch me\" }" == ::Catch::Detail::stringify(value) ) +with expansion: + "{ 0, 42, "Catch me" }" + == + "{ 0, 42, "Catch me" }" + +------------------------------------------------------------------------------- +tuple +------------------------------------------------------------------------------- +ToStringTuple.tests.cpp: +............................................................................... + +ToStringTuple.tests.cpp:: +PASSED: + CHECK( "{ \"hello\", \"world\" }" == ::Catch::Detail::stringify(type{"hello","world"}) ) +with expansion: + "{ "hello", "world" }" + == + "{ "hello", "world" }" + +------------------------------------------------------------------------------- +tuple,tuple<>,float> +------------------------------------------------------------------------------- +ToStringTuple.tests.cpp: +............................................................................... + +ToStringTuple.tests.cpp:: +PASSED: + CHECK( "{ { 42 }, { }, 1.2f }" == ::Catch::Detail::stringify(value) ) +with expansion: + "{ { 42 }, { }, 1.2f }" + == + "{ { 42 }, { }, 1.2f }" + +------------------------------------------------------------------------------- +vec> -> toString +------------------------------------------------------------------------------- +ToStringVector.tests.cpp: +............................................................................... + +ToStringVector.tests.cpp:: +PASSED: + REQUIRE( ::Catch::Detail::stringify(v) == "{ }" ) +with expansion: + "{ }" == "{ }" + +ToStringVector.tests.cpp:: +PASSED: + REQUIRE( ::Catch::Detail::stringify(v) == "{ { \"hello\" }, { \"world\" } }" ) +with expansion: + "{ { "hello" }, { "world" } }" + == + "{ { "hello" }, { "world" } }" + +------------------------------------------------------------------------------- +vector -> toString +------------------------------------------------------------------------------- +ToStringVector.tests.cpp: +............................................................................... + +ToStringVector.tests.cpp:: +PASSED: + REQUIRE( ::Catch::Detail::stringify(bools) == "{ }" ) +with expansion: + "{ }" == "{ }" + +ToStringVector.tests.cpp:: +PASSED: + REQUIRE( ::Catch::Detail::stringify(bools) == "{ true }" ) +with expansion: + "{ true }" == "{ true }" + +ToStringVector.tests.cpp:: +PASSED: + REQUIRE( ::Catch::Detail::stringify(bools) == "{ true, false }" ) +with expansion: + "{ true, false }" == "{ true, false }" + +------------------------------------------------------------------------------- +vector -> toString +------------------------------------------------------------------------------- +ToStringVector.tests.cpp: +............................................................................... + +ToStringVector.tests.cpp:: +PASSED: + REQUIRE( ::Catch::Detail::stringify(vv) == "{ }" ) +with expansion: + "{ }" == "{ }" + +ToStringVector.tests.cpp:: +PASSED: + REQUIRE( ::Catch::Detail::stringify(vv) == "{ 42 }" ) +with expansion: + "{ 42 }" == "{ 42 }" + +ToStringVector.tests.cpp:: +PASSED: + REQUIRE( ::Catch::Detail::stringify(vv) == "{ 42, 250 }" ) +with expansion: + "{ 42, 250 }" == "{ 42, 250 }" + +------------------------------------------------------------------------------- +vector -> toString +------------------------------------------------------------------------------- +ToStringVector.tests.cpp: +............................................................................... + +ToStringVector.tests.cpp:: +PASSED: + REQUIRE( ::Catch::Detail::stringify(vv) == "{ }" ) +with expansion: + "{ }" == "{ }" + +ToStringVector.tests.cpp:: +PASSED: + REQUIRE( ::Catch::Detail::stringify(vv) == "{ 42 }" ) +with expansion: + "{ 42 }" == "{ 42 }" + +ToStringVector.tests.cpp:: +PASSED: + REQUIRE( ::Catch::Detail::stringify(vv) == "{ 42, 250 }" ) +with expansion: + "{ 42, 250 }" == "{ 42, 250 }" + +------------------------------------------------------------------------------- +vector -> toString +------------------------------------------------------------------------------- +ToStringVector.tests.cpp: +............................................................................... + +ToStringVector.tests.cpp:: +PASSED: + REQUIRE( ::Catch::Detail::stringify(vv) == "{ }" ) +with expansion: + "{ }" == "{ }" + +ToStringVector.tests.cpp:: +PASSED: + REQUIRE( ::Catch::Detail::stringify(vv) == "{ \"hello\" }" ) +with expansion: + "{ "hello" }" == "{ "hello" }" + +ToStringVector.tests.cpp:: +PASSED: + REQUIRE( ::Catch::Detail::stringify(vv) == "{ \"hello\", \"world\" }" ) +with expansion: + "{ "hello", "world" }" + == + "{ "hello", "world" }" + +------------------------------------------------------------------------------- +vectors can be sized and resized +------------------------------------------------------------------------------- +Misc.tests.cpp: +............................................................................... + +Misc.tests.cpp:: +PASSED: + REQUIRE( v.size() == 5 ) +with expansion: + 5 == 5 + +Misc.tests.cpp:: +PASSED: + REQUIRE( v.capacity() >= 5 ) +with expansion: + 5 >= 5 + +------------------------------------------------------------------------------- +vectors can be sized and resized + resizing bigger changes size and capacity +------------------------------------------------------------------------------- +Misc.tests.cpp: +............................................................................... + +Misc.tests.cpp:: +PASSED: + REQUIRE( v.size() == 10 ) +with expansion: + 10 == 10 + +Misc.tests.cpp:: +PASSED: + REQUIRE( v.capacity() >= 10 ) +with expansion: + 10 >= 10 + +------------------------------------------------------------------------------- +vectors can be sized and resized +------------------------------------------------------------------------------- +Misc.tests.cpp: +............................................................................... + +Misc.tests.cpp:: +PASSED: + REQUIRE( v.size() == 5 ) +with expansion: + 5 == 5 + +Misc.tests.cpp:: +PASSED: + REQUIRE( v.capacity() >= 5 ) +with expansion: + 5 >= 5 + +------------------------------------------------------------------------------- +vectors can be sized and resized + resizing smaller changes size but not capacity +------------------------------------------------------------------------------- +Misc.tests.cpp: +............................................................................... + +Misc.tests.cpp:: +PASSED: + REQUIRE( v.size() == 0 ) +with expansion: + 0 == 0 + +Misc.tests.cpp:: +PASSED: + REQUIRE( v.capacity() >= 5 ) +with expansion: + 5 >= 5 + +------------------------------------------------------------------------------- +vectors can be sized and resized + resizing smaller changes size but not capacity + We can use the 'swap trick' to reset the capacity +------------------------------------------------------------------------------- +Misc.tests.cpp: +............................................................................... + +Misc.tests.cpp:: +PASSED: + REQUIRE( v.capacity() == 0 ) +with expansion: + 0 == 0 + +------------------------------------------------------------------------------- +vectors can be sized and resized +------------------------------------------------------------------------------- +Misc.tests.cpp: +............................................................................... + +Misc.tests.cpp:: +PASSED: + REQUIRE( v.size() == 5 ) +with expansion: + 5 == 5 + +Misc.tests.cpp:: +PASSED: + REQUIRE( v.capacity() >= 5 ) +with expansion: + 5 >= 5 + +------------------------------------------------------------------------------- +vectors can be sized and resized + reserving bigger changes capacity but not size +------------------------------------------------------------------------------- +Misc.tests.cpp: +............................................................................... + +Misc.tests.cpp:: +PASSED: + REQUIRE( v.size() == 5 ) +with expansion: + 5 == 5 + +Misc.tests.cpp:: +PASSED: + REQUIRE( v.capacity() >= 10 ) +with expansion: + 10 >= 10 + +------------------------------------------------------------------------------- +vectors can be sized and resized +------------------------------------------------------------------------------- +Misc.tests.cpp: +............................................................................... + +Misc.tests.cpp:: +PASSED: + REQUIRE( v.size() == 5 ) +with expansion: + 5 == 5 + +Misc.tests.cpp:: +PASSED: + REQUIRE( v.capacity() >= 5 ) +with expansion: + 5 >= 5 + +------------------------------------------------------------------------------- +vectors can be sized and resized + reserving smaller does not change size or capacity +------------------------------------------------------------------------------- +Misc.tests.cpp: +............................................................................... + +Misc.tests.cpp:: +PASSED: + REQUIRE( v.size() == 5 ) +with expansion: + 5 == 5 + +Misc.tests.cpp:: +PASSED: + REQUIRE( v.capacity() >= 5 ) +with expansion: + 5 >= 5 + +------------------------------------------------------------------------------- +xmlentitycheck + embedded xml: it should be possible to embed xml characters, such as <, + " or &, or even whole documents within an attribute + +------------------------------------------------------------------------------- +Misc.tests.cpp: +............................................................................... + +Misc.tests.cpp:: +PASSED: + +------------------------------------------------------------------------------- +xmlentitycheck + encoded chars: these should all be encoded: &&&"""<<<&"<<&" +------------------------------------------------------------------------------- +Misc.tests.cpp: +............................................................................... + +Misc.tests.cpp:: +PASSED: + +=============================================================================== +test cases: 208 | 142 passed | 62 failed | 4 failed as expected +assertions: 1095 | 952 passed | 122 failed | 21 failed as expected + diff --git a/src/third_party/cppcodec/test/catch/projects/SelfTest/Baselines/console.swa4.approved.txt b/src/third_party/cppcodec/test/catch/projects/SelfTest/Baselines/console.swa4.approved.txt new file mode 100644 index 0000000000..d69844d8b5 --- /dev/null +++ b/src/third_party/cppcodec/test/catch/projects/SelfTest/Baselines/console.swa4.approved.txt @@ -0,0 +1,346 @@ + +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + is a host application. +Run with -? for options + +------------------------------------------------------------------------------- +# A test name that starts with a # +------------------------------------------------------------------------------- +Misc.tests.cpp: +............................................................................... + +Misc.tests.cpp:: +PASSED: +with message: + yay + +------------------------------------------------------------------------------- +#1005: Comparing pointer to int and long (NULL can be either on various + systems) +------------------------------------------------------------------------------- +Decomposition.tests.cpp: +............................................................................... + +Decomposition.tests.cpp:: +PASSED: + REQUIRE( fptr == 0 ) +with expansion: + 0 == 0 + +Decomposition.tests.cpp:: +PASSED: + REQUIRE( fptr == 0l ) +with expansion: + 0 == 0 + +------------------------------------------------------------------------------- +#1027 +------------------------------------------------------------------------------- +Compilation.tests.cpp: +............................................................................... + +Compilation.tests.cpp:: +PASSED: + REQUIRE( y.v == 0 ) +with expansion: + 0 == 0 + +Compilation.tests.cpp:: +PASSED: + REQUIRE( 0 == y.v ) +with expansion: + 0 == 0 + +------------------------------------------------------------------------------- +#1147 +------------------------------------------------------------------------------- +Compilation.tests.cpp: +............................................................................... + +Compilation.tests.cpp:: +PASSED: + REQUIRE( t1 == t2 ) +with expansion: + {?} == {?} + +Compilation.tests.cpp:: +PASSED: + REQUIRE( t1 != t2 ) +with expansion: + {?} != {?} + +Compilation.tests.cpp:: +PASSED: + REQUIRE( t1 < t2 ) +with expansion: + {?} < {?} + +Compilation.tests.cpp:: +PASSED: + REQUIRE( t1 > t2 ) +with expansion: + {?} > {?} + +Compilation.tests.cpp:: +PASSED: + REQUIRE( t1 <= t2 ) +with expansion: + {?} <= {?} + +Compilation.tests.cpp:: +PASSED: + REQUIRE( t1 >= t2 ) +with expansion: + {?} >= {?} + +------------------------------------------------------------------------------- +#1175 - Hidden Test +------------------------------------------------------------------------------- +Misc.tests.cpp: +............................................................................... + +Misc.tests.cpp:: +PASSED: + +------------------------------------------------------------------------------- +#1238 +------------------------------------------------------------------------------- +Compilation.tests.cpp: +............................................................................... + +Compilation.tests.cpp:: +PASSED: + REQUIRE( std::memcmp(uarr, "123", sizeof(uarr)) == 0 ) +with expansion: + 0 == 0 +with messages: + uarr := "123" + sarr := "456" + +Compilation.tests.cpp:: +PASSED: + REQUIRE( std::memcmp(sarr, "456", sizeof(sarr)) == 0 ) +with expansion: + 0 == 0 +with messages: + uarr := "123" + sarr := "456" + +------------------------------------------------------------------------------- +#1245 +------------------------------------------------------------------------------- +Compilation.tests.cpp: +............................................................................... + +Compilation.tests.cpp:: +PASSED: + +------------------------------------------------------------------------------- +#748 - captures with unexpected exceptions + outside assertions +------------------------------------------------------------------------------- +Exception.tests.cpp: +............................................................................... + +Exception.tests.cpp:: FAILED: +due to unexpected exception with messages: + answer := 42 + expected exception + +------------------------------------------------------------------------------- +#748 - captures with unexpected exceptions + inside REQUIRE_NOTHROW +------------------------------------------------------------------------------- +Exception.tests.cpp: +............................................................................... + +Exception.tests.cpp:: FAILED: + REQUIRE_NOTHROW( thisThrows() ) +due to unexpected exception with messages: + answer := 42 + expected exception + +------------------------------------------------------------------------------- +#748 - captures with unexpected exceptions + inside REQUIRE_THROWS +------------------------------------------------------------------------------- +Exception.tests.cpp: +............................................................................... + +Exception.tests.cpp:: +PASSED: + REQUIRE_THROWS( thisThrows() ) +with message: + answer := 42 + +------------------------------------------------------------------------------- +#809 +------------------------------------------------------------------------------- +Compilation.tests.cpp: +............................................................................... + +Compilation.tests.cpp:: +PASSED: + REQUIRE( 42 == f ) +with expansion: + 42 == {?} + +------------------------------------------------------------------------------- +#833 +------------------------------------------------------------------------------- +Compilation.tests.cpp: +............................................................................... + +Compilation.tests.cpp:: +PASSED: + REQUIRE( a == t ) +with expansion: + 3 == 3 + +Compilation.tests.cpp:: +PASSED: + CHECK( a == t ) +with expansion: + 3 == 3 + +Compilation.tests.cpp:: +PASSED: + REQUIRE_THROWS( throws_int(true) ) + +Compilation.tests.cpp:: +PASSED: + CHECK_THROWS_AS( throws_int(true), int ) + +Compilation.tests.cpp:: +PASSED: + REQUIRE_NOTHROW( throws_int(false) ) + +Compilation.tests.cpp:: +PASSED: + REQUIRE_THAT( "aaa", Catch::EndsWith("aaa") ) +with expansion: + "aaa" ends with: "aaa" + +Compilation.tests.cpp:: +PASSED: + REQUIRE( templated_tests(3) ) +with expansion: + true + +------------------------------------------------------------------------------- +#835 -- errno should not be touched by Catch +------------------------------------------------------------------------------- +Misc.tests.cpp: +............................................................................... + +Misc.tests.cpp:: FAILED: + CHECK( f() == 0 ) +with expansion: + 1 == 0 + +Misc.tests.cpp:: +PASSED: + REQUIRE( errno == 1 ) +with expansion: + 1 == 1 + +------------------------------------------------------------------------------- +#872 +------------------------------------------------------------------------------- +Compilation.tests.cpp: +............................................................................... + +Compilation.tests.cpp:: +PASSED: + REQUIRE( x == 4 ) +with expansion: + {?} == 4 +with message: + dummy := 0 + +------------------------------------------------------------------------------- +#961 -- Dynamically created sections should all be reported + Looped section 0 +------------------------------------------------------------------------------- +Misc.tests.cpp: +............................................................................... + +Misc.tests.cpp:: +PASSED: +with message: + Everything is OK + +------------------------------------------------------------------------------- +#961 -- Dynamically created sections should all be reported + Looped section 1 +------------------------------------------------------------------------------- +Misc.tests.cpp: +............................................................................... + +Misc.tests.cpp:: +PASSED: +with message: + Everything is OK + +------------------------------------------------------------------------------- +#961 -- Dynamically created sections should all be reported + Looped section 2 +------------------------------------------------------------------------------- +Misc.tests.cpp: +............................................................................... + +Misc.tests.cpp:: +PASSED: +with message: + Everything is OK + +------------------------------------------------------------------------------- +#961 -- Dynamically created sections should all be reported + Looped section 3 +------------------------------------------------------------------------------- +Misc.tests.cpp: +............................................................................... + +Misc.tests.cpp:: +PASSED: +with message: + Everything is OK + +------------------------------------------------------------------------------- +#961 -- Dynamically created sections should all be reported + Looped section 4 +------------------------------------------------------------------------------- +Misc.tests.cpp: +............................................................................... + +Misc.tests.cpp:: +PASSED: +with message: + Everything is OK + +------------------------------------------------------------------------------- +'Not' checks that should fail +------------------------------------------------------------------------------- +Condition.tests.cpp: +............................................................................... + +Condition.tests.cpp:: FAILED: + CHECK( false != false ) + +Condition.tests.cpp:: FAILED: + CHECK( true != true ) + +Condition.tests.cpp:: FAILED: + CHECK( !true ) +with expansion: + false + +Condition.tests.cpp:: FAILED: + CHECK_FALSE( true ) +with expansion: + !true + +=============================================================================== +test cases: 14 | 11 passed | 1 failed | 2 failed as expected +assertions: 38 | 31 passed | 4 failed | 3 failed as expected + diff --git a/src/third_party/cppcodec/test/catch/projects/SelfTest/Baselines/junit.sw.approved.txt b/src/third_party/cppcodec/test/catch/projects/SelfTest/Baselines/junit.sw.approved.txt new file mode 100644 index 0000000000..fb66299d27 --- /dev/null +++ b/src/third_party/cppcodec/test/catch/projects/SelfTest/Baselines/junit.sw.approved.txt @@ -0,0 +1,901 @@ + + + + + + + + + + + + +expected exception +answer := 42 +Exception.tests.cpp: + + + + +expected exception +answer := 42 +Exception.tests.cpp: + + + + + + + +Misc.tests.cpp: + + + + + + + + + + +Condition.tests.cpp: + + +Condition.tests.cpp: + + +Condition.tests.cpp: + + +Condition.tests.cpp: + + +Condition.tests.cpp: + + +Condition.tests.cpp: + + +Condition.tests.cpp: + + +Condition.tests.cpp: + + + + + + + + + + +Class.tests.cpp: + + + + + +Class.tests.cpp: + + + + + + +to infinity and beyond +Misc.tests.cpp: + + + + + +Tricky.tests.cpp: + + +Tricky.tests.cpp: + + + + + + +unexpected exception +Exception.tests.cpp: + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +Matchers.tests.cpp: + + +Matchers.tests.cpp: + + + + +custom exception - not std +Exception.tests.cpp: + + + + +custom exception - not std +Exception.tests.cpp: + + + + +custom std exception +Exception.tests.cpp: + + + + + +Matchers.tests.cpp: + + +Matchers.tests.cpp: + + + + + +Condition.tests.cpp: + + +Condition.tests.cpp: + + +Condition.tests.cpp: + + +Condition.tests.cpp: + + +Condition.tests.cpp: + + +Condition.tests.cpp: + + +Condition.tests.cpp: + + +Condition.tests.cpp: + + +Condition.tests.cpp: + + +Condition.tests.cpp: + + +Condition.tests.cpp: + + +Condition.tests.cpp: + + +Condition.tests.cpp: + + + + + + +Matchers.tests.cpp: + + +Matchers.tests.cpp: + + + + + +Matchers.tests.cpp: + + +Matchers.tests.cpp: + + + + +Unknown exception +Matchers.tests.cpp: + + +Unknown exception +Matchers.tests.cpp: + + + + +Matchers.tests.cpp: + + +Matchers.tests.cpp: + + + + + + + + +expected exception +Exception.tests.cpp: + + +Exception.tests.cpp: + + +expected exception +Exception.tests.cpp: + + + + +This is a failure +Message.tests.cpp: + + + + +Message.tests.cpp: + + + + +This is a failure +Message.tests.cpp: + + + + + + + + + + + + + + + +this message should be logged +so should this +Message.tests.cpp: + + + + +this message may be logged later +this message should be logged +Message.tests.cpp: + + +this message may be logged later +this message should be logged +and this, but later +Message.tests.cpp: + + + + +current counter 10 +i := 10 +Message.tests.cpp: + + + + +Condition.tests.cpp: + + +Condition.tests.cpp: + + +Condition.tests.cpp: + + +Condition.tests.cpp: + + +Condition.tests.cpp: + + + + + + + + + + +Matchers.tests.cpp: + + + + + +Matchers.tests.cpp: + + + + +Exception.tests.cpp: + + + + + +custom exception +Exception.tests.cpp: + + + + + +Condition.tests.cpp: + + +Condition.tests.cpp: + + +Condition.tests.cpp: + + +Condition.tests.cpp: + + +Condition.tests.cpp: + + +Condition.tests.cpp: + + +Condition.tests.cpp: + + +Condition.tests.cpp: + + +Condition.tests.cpp: + + +Condition.tests.cpp: + + +Condition.tests.cpp: + + +Condition.tests.cpp: + + +Condition.tests.cpp: + + +Condition.tests.cpp: + + +Condition.tests.cpp: + + +Condition.tests.cpp: + + +Condition.tests.cpp: + + +Condition.tests.cpp: + + +Condition.tests.cpp: + + + + + +Message from section one +Message.tests.cpp: + + + + +Message from section two +Message.tests.cpp: + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +Decomposition.tests.cpp: + + + + +Matchers.tests.cpp: + + +Matchers.tests.cpp: + + +Matchers.tests.cpp: + + + + + + + + + + + + + + + +A string sent directly to stdout + + +A string sent directly to stderr +A string sent to stderr via clog + + + + + +Message from section one +Message from section two + + + + +Matchers.tests.cpp: + + +Matchers.tests.cpp: + + + + + + + + + + + + + + + + + + + + + + + + + + + + +Misc.tests.cpp: + + + + + + + + + + +For some reason someone is throwing a string literal! +Exception.tests.cpp: + + + + + + + + + + + + + + + + + + + + + +3.14 +Exception.tests.cpp: + + + + + + + + + + + +Matchers.tests.cpp: + + +Matchers.tests.cpp: + + + + +Matchers.tests.cpp: + + +Matchers.tests.cpp: + + + + +Matchers.tests.cpp: + + +Matchers.tests.cpp: + + +Matchers.tests.cpp: + + +Matchers.tests.cpp: + + + + +Matchers.tests.cpp: + + +Matchers.tests.cpp: + + +Matchers.tests.cpp: + + +Matchers.tests.cpp: + + + + + +unexpected exception +Exception.tests.cpp: + + + + +expected exception +Exception.tests.cpp: + + + + +expected exception +Exception.tests.cpp: + + + + +expected exception +Exception.tests.cpp: + + + + +unexpected exception +Exception.tests.cpp: + + + + + + + + + + + + + + + + + + + + + + + + + + + + +Misc.tests.cpp: + + +Misc.tests.cpp: + + + + + +Misc.tests.cpp: + + +Misc.tests.cpp: + + + + + + + + + +Previous info should not be seen +Message.tests.cpp: + + + + + +Misc.tests.cpp: + + + + +Misc.tests.cpp: + + + + + + + + + + + + +Testing if fib[0] (1) is even +Misc.tests.cpp: + + +Testing if fib[1] (1) is even +Misc.tests.cpp: + + +Testing if fib[3] (3) is even +Misc.tests.cpp: + + +Testing if fib[4] (5) is even +Misc.tests.cpp: + + +Testing if fib[6] (13) is even +Misc.tests.cpp: + + +Testing if fib[7] (21) is even +Misc.tests.cpp: + + + + +Misc.tests.cpp: + + + + + + + + + + + + + + + + + + + + + + + + +3 +Misc.tests.cpp: + + + + +hi +i := 7 +Message.tests.cpp: + + + + + + + + + + + + + +Tricky.tests.cpp: + + + + + + + + + + + + + +Why would you throw a std::string? +Exception.tests.cpp: + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +A string sent directly to stdout +Message from section one +Message from section two + + +A string sent directly to stderr +A string sent to stderr via clog + + + diff --git a/src/third_party/cppcodec/test/catch/projects/SelfTest/Baselines/xml.sw.approved.txt b/src/third_party/cppcodec/test/catch/projects/SelfTest/Baselines/xml.sw.approved.txt new file mode 100644 index 0000000000..449448ce2a --- /dev/null +++ b/src/third_party/cppcodec/test/catch/projects/SelfTest/Baselines/xml.sw.approved.txt @@ -0,0 +1,10097 @@ + + + + + + + + + + fptr == 0 + + + 0 == 0 + + + + + fptr == 0l + + + 0 == 0 + + + + + + + + y.v == 0 + + + 0 == 0 + + + + + 0 == y.v + + + 0 == 0 + + + + + + + + t1 == t2 + + + {?} == {?} + + + + + t1 != t2 + + + {?} != {?} + + + + + t1 < t2 + + + {?} < {?} + + + + + t1 > t2 + + + {?} > {?} + + + + + t1 <= t2 + + + {?} <= {?} + + + + + t1 >= t2 + + + {?} >= {?} + + + + + + + + + + uarr := "123" + + + sarr := "456" + + + + std::memcmp(uarr, "123", sizeof(uarr)) == 0 + + + 0 == 0 + + + + uarr := "123" + + + sarr := "456" + + + + std::memcmp(sarr, "456", sizeof(sarr)) == 0 + + + 0 == 0 + + + + + + + + +
+ + answer := 42 + + + expected exception + + +
+
+ + answer := 42 + + + + thisThrows() + + + thisThrows() + + + expected exception + + + +
+
+ + answer := 42 + + + + thisThrows() + + + thisThrows() + + + +
+ +
+ + + + 42 == f + + + 42 == {?} + + + + + + + + a == t + + + 3 == 3 + + + + + a == t + + + 3 == 3 + + + + + throws_int(true) + + + throws_int(true) + + + + + throws_int(true), int + + + throws_int(true), int + + + + + throws_int(false) + + + throws_int(false) + + + + + "aaa", Catch::EndsWith("aaa") + + + "aaa" ends with: "aaa" + + + + + templated_tests<int>(3) + + + true + + + + + + + + f() == 0 + + + 1 == 0 + + + + + errno == 1 + + + 1 == 1 + + + + + + + dummy := 0 + + + + x == 4 + + + {?} == 4 + + + + + +
+ +
+
+ +
+
+ +
+
+ +
+
+ +
+ +
+ + + + false != false + + + false != false + + + + + true != true + + + true != true + + + + + !true + + + false + + + + + !(true) + + + !true + + + + + !trueValue + + + false + + + + + !(trueValue) + + + !true + + + + + !(1 == 1) + + + false + + + + + !(1 == 1) + + + !(1 == 1) + + + + + + + + false == false + + + false == false + + + + + true == true + + + true == true + + + + + !false + + + true + + + + + !(false) + + + !false + + + + + !falseValue + + + true + + + + + !(falseValue) + + + !false + + + + + !(1 == 2) + + + true + + + + + !(1 == 2) + + + !(1 == 2) + + + + + +
+ + + is_true<true>::value == true + + + true == true + + + + + true == is_true<true>::value + + + true == true + + + +
+
+ + + is_true<false>::value == false + + + false == false + + + + + false == is_true<false>::value + + + false == false + + + +
+
+ + + !is_true<false>::value + + + true + + + +
+
+ + + !!is_true<true>::value + + + true + + + +
+
+ + + is_true<true>::value + + + true + + + + + !(is_true<false>::value) + + + !false + + + +
+ +
+ + + + s == "world" + + + "hello" == "world" + + + + + + + + s == "hello" + + + "hello" == "hello" + + + + + + + + m_a == 2 + + + 1 == 2 + + + + + + + + m_a == 1 + + + 1 == 1 + + + + + + + + d == 1.23_a + + + 1.23 == Approx( 1.23 ) + + + + + d != 1.22_a + + + 1.23 != Approx( 1.22 ) + + + + + -d == -1.23_a + + + -1.23 == Approx( -1.23 ) + + + + + d == 1.2_a .epsilon(.1) + + + 1.23 == Approx( 1.2 ) + + + + + d != 1.2_a .epsilon(.001) + + + 1.23 != Approx( 1.2 ) + + + + + d == 1_a .epsilon(.3) + + + 1.23 == Approx( 1.0 ) + + + + + +
+
+ +
+ +
+ + to infinity and beyond + + +
+ + + + &o1 == &o2 + + + 0x == 0x + + + + + o1 == o2 + + + {?} == {?} + + + + + + + + 104.0 != Approx(100.0) + + + 104.0 != Approx( 100.0 ) + + + + + 104.0 == Approx(100.0).margin(5) + + + 104.0 == Approx( 100.0 ) + + + + + 104.0 == Approx(100.0).margin(4) + + + 104.0 == Approx( 100.0 ) + + + + + 104.0 != Approx(100.0).margin(3) + + + 104.0 != Approx( 100.0 ) + + + + + 100.3 != Approx(100.0) + + + 100.3 != Approx( 100.0 ) + + + + + 100.3 == Approx(100.0).margin(0.5) + + + 100.3 == Approx( 100.0 ) + + + + + + + + + + + i++ == 7 + + + 7 == 7 + + + + + i++ == 8 + + + 8 == 8 + + + + + + + + 1 == 1 + + + 1 == 1 + + + + + {Unknown expression after the reported line} + + + {Unknown expression after the reported line} + + + unexpected exception + + + + + + + + + + + Approx(0).margin(0) + + + Approx(0).margin(0) + + + + + Approx(0).margin(1234656) + + + Approx(0).margin(1234656) + + + + + Approx(0).margin(-2), std::domain_error + + + Approx(0).margin(-2), std::domain_error + + + + + Approx(0).epsilon(0) + + + Approx(0).epsilon(0) + + + + + Approx(0).epsilon(1) + + + Approx(0).epsilon(1) + + + + + Approx(0).epsilon(-0.001), std::domain_error + + + Approx(0).epsilon(-0.001), std::domain_error + + + + + Approx(0).epsilon(1.0001), std::domain_error + + + Approx(0).epsilon(1.0001), std::domain_error + + + + + + + + 0.25f == Approx(0.0f).margin(0.25f) + + + 0.25f == Approx( 0.0 ) + + + + + 0.0f == Approx(0.25f).margin(0.25f) + + + 0.0f == Approx( 0.25 ) + + + + + 0.5f == Approx(0.25f).margin(0.25f) + + + 0.5f == Approx( 0.25 ) + + + + + 245.0f == Approx(245.25f).margin(0.25f) + + + 245.0f == Approx( 245.25 ) + + + + + 245.5f == Approx(245.25f).margin(0.25f) + + + 245.5f == Approx( 245.25 ) + + + + + + + + divide( 22, 7 ) == Approx( 3.141 ).epsilon( 0.001 ) + + + 3.1428571429 == Approx( 3.141 ) + + + + + divide( 22, 7 ) != Approx( 3.141 ).epsilon( 0.0001 ) + + + 3.1428571429 != Approx( 3.141 ) + + + + + + + + d != Approx( 1.231 ) + + + 1.23 != Approx( 1.231 ) + + + + + d == Approx( 1.231 ).epsilon( 0.1 ) + + + 1.23 == Approx( 1.231 ) + + + + + + + + 1.23f == Approx( 1.23f ) + + + 1.23f == Approx( 1.2300000191 ) + + + + + 0.0f == Approx( 0.0f ) + + + 0.0f == Approx( 0.0 ) + + + + + + + + 1 == Approx( 1 ) + + + 1 == Approx( 1.0 ) + + + + + 0 == Approx( 0 ) + + + 0 == Approx( 0.0 ) + + + + + + + + 1.0f == Approx( 1 ) + + + 1.0f == Approx( 1.0 ) + + + + + 0 == Approx( dZero) + + + 0 == Approx( 0.0 ) + + + + + 0 == Approx( dSmall ).margin( 0.001 ) + + + 0 == Approx( 0.00001 ) + + + + + 1.234f == Approx( dMedium ) + + + 1.234f == Approx( 1.234 ) + + + + + dMedium == Approx( 1.234f ) + + + 1.234 == Approx( 1.2339999676 ) + + + + + +
+ + + 1, Predicate<int>(alwaysTrue, "always true") + + + 1 matches predicate: "always true" + + + + + 1, !Predicate<int>(alwaysFalse, "always false") + + + 1 not matches predicate: "always false" + + + +
+
+ + + "Hello olleH", Predicate<std::string>( [] (std::string const& str) -> bool { return str.front() == str.back(); }, "First and last character should be equal") + + + "Hello olleH" matches predicate: "First and last character should be equal" + + + + + "This wouldn't pass", !Predicate<std::string>( [] (std::string const& str) -> bool { return str.front() == str.back(); } ) + + + "This wouldn't pass" not matches undescribed predicate + + + +
+ +
+ + + + true + + + true + + +
+ + + true + + + true + + +
+ + + true + + + true + + + +
+ +
+ + + true + + + true + + +
+ + + true + + + true + + +
+ + + true + + + true + + + +
+ +
+ +
+ + + + INFINITY == Approx(INFINITY) + + + inff == Approx( inf ) + + + + + NAN != Approx(NAN) + + + nanf != Approx( nan ) + + + + + !(NAN == Approx(NAN)) + + + !(nanf == Approx( nan )) + + + + + + + + y.v == 0 + + + 0 == 0 + + + + + 0 == y.v + + + 0 == 0 + + + + + +
+ + i := 2 + + + + true + + + true + + + +
+
+ + 3 + + + + true + + + true + + + +
+ +
+ +
+ + + tab == '\t' + + + '\t' == '\t' + + + + + newline == '\n' + + + '\n' == '\n' + + + + + carr_return == '\r' + + + '\r' == '\r' + + + + + form_feed == '\f' + + + '\f' == '\f' + + + +
+
+ + + space == ' ' + + + ' ' == ' ' + + + + + c == chars[i] + + + 'a' == 'a' + + + + + c == chars[i] + + + 'z' == 'z' + + + + + c == chars[i] + + + 'A' == 'A' + + + + + c == chars[i] + + + 'Z' == 'Z' + + + +
+
+ + + null_terminator == '\0' + + + 0 == 0 + + + + + c == i + + + 2 == 2 + + + + + c == i + + + 3 == 3 + + + + + c == i + + + 4 == 4 + + + + + c == i + + + 5 == 5 + + + +
+ +
+ + + + std::vector<constructor_throws>{constructor_throws{}, constructor_throws{}} + + + std::vector<constructor_throws>{constructor_throws{}, constructor_throws{}} + + + + + std::vector<constructor_throws>{constructor_throws{}, constructor_throws{}} + + + std::vector<constructor_throws>{constructor_throws{}, constructor_throws{}} + + + + + std::vector<int>{1, 2, 3} == std::vector<int>{1, 2, 3} + + + std::vector<int>{1, 2, 3} == std::vector<int>{1, 2, 3} + + + + + std::vector<int>{1, 2, 3} == std::vector<int>{1, 2, 3} + + + std::vector<int>{1, 2, 3} == std::vector<int>{1, 2, 3} + + + + + std::vector<int>{1, 2} == std::vector<int>{1, 2} + + + { 1, 2 } == { 1, 2 } + + + + + std::vector<int>{1, 2} == std::vector<int>{1, 2} + + + { 1, 2 } == { 1, 2 } + + + + + !(std::vector<int>{1, 2} == std::vector<int>{1, 2, 3}) + + + !({ 1, 2 } == { 1, 2, 3 }) + + + + + !(std::vector<int>{1, 2} == std::vector<int>{1, 2, 3}) + + + !({ 1, 2 } == { 1, 2, 3 }) + + + + + std::vector<int>{1, 2} == std::vector<int>{1, 2} + + + { 1, 2 } == { 1, 2 } + + + + + std::vector<int>{1, 2} == std::vector<int>{1, 2} + + + { 1, 2 } == { 1, 2 } + + + + + true + + + true + + + + + std::vector<int>{1, 2} == std::vector<int>{1, 2} + + + { 1, 2 } == { 1, 2 } + + + + + + + + a + + + 0x + + + + + a == &foo + + + 0x == 0x + + + + + + + + td == Approx(10.0) + + + StrongDoubleTypedef(10) == Approx( 10.0 ) + + + + + Approx(10.0) == td + + + Approx( 10.0 ) == StrongDoubleTypedef(10) + + + + + td != Approx(11.0) + + + StrongDoubleTypedef(10) != Approx( 11.0 ) + + + + + Approx(11.0) != td + + + Approx( 11.0 ) != StrongDoubleTypedef(10) + + + + + td <= Approx(10.0) + + + StrongDoubleTypedef(10) <= Approx( 10.0 ) + + + + + td <= Approx(11.0) + + + StrongDoubleTypedef(10) <= Approx( 11.0 ) + + + + + Approx(10.0) <= td + + + Approx( 10.0 ) <= StrongDoubleTypedef(10) + + + + + Approx(9.0) <= td + + + Approx( 9.0 ) <= StrongDoubleTypedef(10) + + + + + td >= Approx(9.0) + + + StrongDoubleTypedef(10) >= Approx( 9.0 ) + + + + + td >= Approx(td) + + + StrongDoubleTypedef(10) >= Approx( 10.0 ) + + + + + Approx(td) >= td + + + Approx( 10.0 ) >= StrongDoubleTypedef(10) + + + + + Approx(11.0) >= td + + + Approx( 11.0 ) >= StrongDoubleTypedef(10) + + + + + + + + 54 == 6*9 + + + 54 == 54 + + + + + + + + ( -1 > 2u ) + + + true + + + + + -1 > 2u + + + -1 > 2 + + + + + ( 2u < -1 ) + + + true + + + + + 2u < -1 + + + 2 < -1 + + + + + ( minInt > 2u ) + + + true + + + + + minInt > 2u + + + -2147483648 > 2 + + + + + + + + i == 1 + + + 1 == 1 + + + + + ui == 2 + + + 2 == 2 + + + + + l == 3 + + + 3 == 3 + + + + + ul == 4 + + + 4 == 4 + + + + + c == 5 + + + 5 == 5 + + + + + uc == 6 + + + 6 == 6 + + + + + 1 == i + + + 1 == 1 + + + + + 2 == ui + + + 2 == 2 + + + + + 3 == l + + + 3 == 3 + + + + + 4 == ul + + + 4 == 4 + + + + + 5 == c + + + 5 == 5 + + + + + 6 == uc + + + 6 == 6 + + + + + (std::numeric_limits<uint32_t>::max)() > ul + + + 4294967295 (0x) > 4 + + + + + + + + testStringForMatching(), Contains("not there", Catch::CaseSensitive::No) + + + "this string contains 'abc' as a substring" contains: "not there" (case insensitive) + + + + + testStringForMatching(), Contains("STRING") + + + "this string contains 'abc' as a substring" contains: "STRING" + + + + + + + + throwCustom() + + + throwCustom() + + + custom exception - not std + + + + + + + + throwCustom(), std::exception + + + throwCustom(), std::exception + + + custom exception - not std + + + + + + + custom std exception + + + + + + + 101.000001 != Approx(100).epsilon(0.01) + + + 101.000001 != Approx( 100.0 ) + + + + + std::pow(10, -5) != Approx(std::pow(10, -7)) + + + 0.00001 != Approx( 0.0000001 ) + + + + + + + + testStringForMatching(), EndsWith("Substring") + + + "this string contains 'abc' as a substring" ends with: "Substring" + + + + + testStringForMatching(), EndsWith("this", Catch::CaseSensitive::No) + + + "this string contains 'abc' as a substring" ends with: "this" (case insensitive) + + + + + + + + 101.01 != Approx(100).epsilon(0.01) + + + 101.01 != Approx( 100.0 ) + + + + + + + + data.int_seven == 6 + + + 7 == 6 + + + + + data.int_seven == 8 + + + 7 == 8 + + + + + data.int_seven == 0 + + + 7 == 0 + + + + + data.float_nine_point_one == Approx( 9.11f ) + + + 9.1f == Approx( 9.1099996567 ) + + + + + data.float_nine_point_one == Approx( 9.0f ) + + + 9.1f == Approx( 9.0 ) + + + + + data.float_nine_point_one == Approx( 1 ) + + + 9.1f == Approx( 1.0 ) + + + + + data.float_nine_point_one == Approx( 0 ) + + + 9.1f == Approx( 0.0 ) + + + + + data.double_pi == Approx( 3.1415 ) + + + 3.1415926535 == Approx( 3.1415 ) + + + + + data.str_hello == "goodbye" + + + "hello" == "goodbye" + + + + + data.str_hello == "hell" + + + "hello" == "hell" + + + + + data.str_hello == "hello1" + + + "hello" == "hello1" + + + + + data.str_hello.size() == 6 + + + 5 == 6 + + + + + x == Approx( 1.301 ) + + + 1.3 == Approx( 1.301 ) + + + + + + + + data.int_seven == 7 + + + 7 == 7 + + + + + data.float_nine_point_one == Approx( 9.1f ) + + + 9.1f == Approx( 9.1000003815 ) + + + + + data.double_pi == Approx( 3.1415926535 ) + + + 3.1415926535 == Approx( 3.1415926535 ) + + + + + data.str_hello == "hello" + + + "hello" == "hello" + + + + + "hello" == data.str_hello + + + "hello" == "hello" + + + + + data.str_hello.size() == 5 + + + 5 == 5 + + + + + x == Approx( 1.3 ) + + + 1.3 == Approx( 1.3 ) + + + + + + + + testStringForMatching(), Equals("this string contains 'abc' as a substring") + + + "this string contains 'abc' as a substring" equals: "this string contains 'abc' as a substring" + + + + + testStringForMatching(), Equals("this string contains 'ABC' as a substring", Catch::CaseSensitive::No) + + + "this string contains 'abc' as a substring" equals: "this string contains 'abc' as a substring" (case insensitive) + + + + + + + + testStringForMatching(), Equals("this string contains 'ABC' as a substring") + + + "this string contains 'abc' as a substring" equals: "this string contains 'ABC' as a substring" + + + + + testStringForMatching(), Equals("something else", Catch::CaseSensitive::No) + + + "this string contains 'abc' as a substring" equals: "something else" (case insensitive) + + + + + + + + ::Catch::Detail::stringify(WhatException{}) == "This exception has overriden what() method" + + + "This exception has overriden what() method" +== +"This exception has overriden what() method" + + + + + ::Catch::Detail::stringify(OperatorException{}) == "OperatorException" + + + "OperatorException" == "OperatorException" + + + + + ::Catch::Detail::stringify(StringMakerException{}) == "StringMakerException" + + + "StringMakerException" +== +"StringMakerException" + + + + + +
+ + + doesNotThrow(), SpecialException, ExceptionMatcher{1} + + + doesNotThrow(), SpecialException, ExceptionMatcher{1} + + + + + doesNotThrow(), SpecialException, ExceptionMatcher{1} + + + doesNotThrow(), SpecialException, ExceptionMatcher{1} + + + +
+
+ + + throwsAsInt(1), SpecialException, ExceptionMatcher{1} + + + throwsAsInt(1), SpecialException, ExceptionMatcher{1} + + + Unknown exception + + + + + throwsAsInt(1), SpecialException, ExceptionMatcher{1} + + + throwsAsInt(1), SpecialException, ExceptionMatcher{1} + + + Unknown exception + + + +
+
+ + + throws(3), SpecialException, ExceptionMatcher{1} + + + SpecialException::what special exception has value of 1 + + + + + throws(4), SpecialException, ExceptionMatcher{1} + + + SpecialException::what special exception has value of 1 + + + +
+ +
+ + + + throws(1), SpecialException, ExceptionMatcher{1} + + + SpecialException::what special exception has value of 1 + + + + + throws(2), SpecialException, ExceptionMatcher{2} + + + SpecialException::what special exception has value of 2 + + + + + +
+ + + thisThrows(), "expected exception" + + + "expected exception" equals: "expected exception" + + + +
+
+ + + thisThrows(), Equals( "expecteD Exception", Catch::CaseSensitive::No ) + + + "expected exception" equals: "expected exception" (case insensitive) + + + +
+
+ + + thisThrows(), StartsWith( "expected" ) + + + "expected exception" starts with: "expected" + + + + + thisThrows(), EndsWith( "exception" ) + + + "expected exception" ends with: "exception" + + + + + thisThrows(), Contains( "except" ) + + + "expected exception" contains: "except" + + + + + thisThrows(), Contains( "exCept", Catch::CaseSensitive::No ) + + + "expected exception" contains: "except" (case insensitive) + + + +
+ +
+ + + + thisThrows(), std::string + + + thisThrows(), std::string + + + expected exception + + + + + thisDoesntThrow(), std::domain_error + + + thisDoesntThrow(), std::domain_error + + + + + thisThrows() + + + thisThrows() + + + expected exception + + + + + + + This is a failure + + + + + + + + + + This is a failure + + + This message appears in the output + + + + + + + Factorial(0) == 1 + + + 1 == 1 + + + + + Factorial(1) == 1 + + + 1 == 1 + + + + + Factorial(2) == 2 + + + 2 == 2 + + + + + Factorial(3) == 6 + + + 6 == 6 + + + + + Factorial(10) == 3628800 + + + 3628800 (0x) == 3628800 (0x) + + + + + +
+ + + 1., WithinAbs(1., 0) + + + 1.0 is within 0.0 of 1.0 + + + + + 0., WithinAbs(1., 1) + + + 0.0 is within 1.0 of 1.0 + + + + + 0., !WithinAbs(1., 0.99) + + + 0.0 not is within 0.99 of 1.0 + + + + + 0., !WithinAbs(1., 0.99) + + + 0.0 not is within 0.99 of 1.0 + + + + + NAN, !WithinAbs(NAN, 0) + + + nanf not is within 0.0 of nan + + + + + 11., !WithinAbs(10., 0.5) + + + 11.0 not is within 0.5 of 10.0 + + + + + 10., !WithinAbs(11., 0.5) + + + 10.0 not is within 0.5 of 11.0 + + + + + -10., WithinAbs(-10., 0.5) + + + -10.0 is within 0.5 of -10.0 + + + + + -10., WithinAbs(-9.6, 0.5) + + + -10.0 is within 0.5 of -9.6 + + + +
+
+ + + 1., WithinULP(1., 0) + + + 1.0 is within 0 ULPs of 1.0 + + + + + nextafter(1., 2.), WithinULP(1., 1) + + + 1.0 is within 1 ULPs of 1.0 + + + + + nextafter(1., 0.), WithinULP(1., 1) + + + 1.0 is within 1 ULPs of 1.0 + + + + + nextafter(1., 2.), !WithinULP(1., 0) + + + 1.0 not is within 0 ULPs of 1.0 + + + + + 1., WithinULP(1., 0) + + + 1.0 is within 0 ULPs of 1.0 + + + + + -0., WithinULP(0., 0) + + + -0.0 is within 0 ULPs of 0.0 + + + + + NAN, !WithinULP(NAN, 123) + + + nanf not is within 123 ULPs of nanf + + + +
+
+ + + 1., WithinAbs(1., 0.5) || WithinULP(2., 1) + + + 1.0 ( is within 0.5 of 1.0 or is within 1 ULPs of 2.0 ) + + + + + 1., WithinAbs(2., 0.5) || WithinULP(1., 0) + + + 1.0 ( is within 0.5 of 2.0 or is within 0 ULPs of 1.0 ) + + + + + NAN, !(WithinAbs(NAN, 100) || WithinULP(NAN, 123)) + + + nanf not ( is within 100.0 of nan or is within 123 ULPs of nanf ) + + + +
+
+ + + WithinAbs(1., 0.) + + + WithinAbs(1., 0.) + + + + + WithinAbs(1., -1.), std::domain_error + + + WithinAbs(1., -1.), std::domain_error + + + + + WithinULP(1., 0) + + + WithinULP(1., 0) + + + + + WithinULP(1., -1), std::domain_error + + + WithinULP(1., -1), std::domain_error + + + +
+ +
+ +
+ + + 1.f, WithinAbs(1.f, 0) + + + 1.0f is within 0.0 of 1.0 + + + + + 0.f, WithinAbs(1.f, 1) + + + 0.0f is within 1.0 of 1.0 + + + + + 0.f, !WithinAbs(1.f, 0.99f) + + + 0.0f not is within 0.9900000095 of 1.0 + + + + + 0.f, !WithinAbs(1.f, 0.99f) + + + 0.0f not is within 0.9900000095 of 1.0 + + + + + 0.f, WithinAbs(-0.f, 0) + + + 0.0f is within 0.0 of -0.0 + + + + + NAN, !WithinAbs(NAN, 0) + + + nanf not is within 0.0 of nan + + + + + 11.f, !WithinAbs(10.f, 0.5f) + + + 11.0f not is within 0.5 of 10.0 + + + + + 10.f, !WithinAbs(11.f, 0.5f) + + + 10.0f not is within 0.5 of 11.0 + + + + + -10.f, WithinAbs(-10.f, 0.5f) + + + -10.0f is within 0.5 of -10.0 + + + + + -10.f, WithinAbs(-9.6f, 0.5f) + + + -10.0f is within 0.5 of -9.6000003815 + + + +
+
+ + + 1.f, WithinULP(1.f, 0) + + + 1.0f is within 0 ULPs of 1.0f + + + + + nextafter(1.f, 2.f), WithinULP(1.f, 1) + + + 1.0f is within 1 ULPs of 1.0f + + + + + nextafter(1.f, 0.f), WithinULP(1.f, 1) + + + 1.0f is within 1 ULPs of 1.0f + + + + + nextafter(1.f, 2.f), !WithinULP(1.f, 0) + + + 1.0f not is within 0 ULPs of 1.0f + + + + + 1.f, WithinULP(1.f, 0) + + + 1.0f is within 0 ULPs of 1.0f + + + + + -0.f, WithinULP(0.f, 0) + + + -0.0f is within 0 ULPs of 0.0f + + + + + NAN, !WithinULP(NAN, 123) + + + nanf not is within 123 ULPs of nanf + + + +
+
+ + + 1.f, WithinAbs(1.f, 0.5) || WithinULP(1.f, 1) + + + 1.0f ( is within 0.5 of 1.0 or is within 1 ULPs of 1.0f ) + + + + + 1.f, WithinAbs(2.f, 0.5) || WithinULP(1.f, 0) + + + 1.0f ( is within 0.5 of 2.0 or is within 0 ULPs of 1.0f ) + + + + + NAN, !(WithinAbs(NAN, 100) || WithinULP(NAN, 123)) + + + nanf not ( is within 100.0 of nan or is within 123 ULPs of nanf ) + + + +
+
+ + + WithinAbs(1.f, 0.f) + + + WithinAbs(1.f, 0.f) + + + + + WithinAbs(1.f, -1.f), std::domain_error + + + WithinAbs(1.f, -1.f), std::domain_error + + + + + WithinULP(1.f, 0) + + + WithinULP(1.f, 0) + + + + + WithinULP(1.f, -1), std::domain_error + + + WithinULP(1.f, -1), std::domain_error + + + +
+ +
+ + + + d >= Approx( 1.22 ) + + + 1.23 >= Approx( 1.22 ) + + + + + d >= Approx( 1.23 ) + + + 1.23 >= Approx( 1.23 ) + + + + + !(d >= Approx( 1.24 )) + + + !(1.23 >= Approx( 1.24 )) + + + + + d >= Approx( 1.24 ).epsilon(0.1) + + + 1.23 >= Approx( 1.24 ) + + + + + + + this is a message + + + this is a warning + + + + + + this message should be logged + + + so should this + + + + a == 1 + + + 2 == 1 + + + + + + + this message may be logged later + + + + a == 2 + + + 2 == 2 + + + + this message may be logged later + + + this message should be logged + + + + a == 1 + + + 2 == 1 + + + + this message may be logged later + + + this message should be logged + + + and this, but later + + + + a == 0 + + + 2 == 0 + + + + this message may be logged later + + + this message should be logged + + + and this, but later + + + but not this + + + + a == 2 + + + 2 == 2 + + + + + + + current counter 0 + + + i := 0 + + + + i < 10 + + + 0 < 10 + + + + current counter 1 + + + i := 1 + + + + i < 10 + + + 1 < 10 + + + + current counter 2 + + + i := 2 + + + + i < 10 + + + 2 < 10 + + + + current counter 3 + + + i := 3 + + + + i < 10 + + + 3 < 10 + + + + current counter 4 + + + i := 4 + + + + i < 10 + + + 4 < 10 + + + + current counter 5 + + + i := 5 + + + + i < 10 + + + 5 < 10 + + + + current counter 6 + + + i := 6 + + + + i < 10 + + + 6 < 10 + + + + current counter 7 + + + i := 7 + + + + i < 10 + + + 7 < 10 + + + + current counter 8 + + + i := 8 + + + + i < 10 + + + 8 < 10 + + + + current counter 9 + + + i := 9 + + + + i < 10 + + + 9 < 10 + + + + current counter 10 + + + i := 10 + + + + i < 10 + + + 10 < 10 + + + + + + + + data.int_seven != 7 + + + 7 != 7 + + + + + data.float_nine_point_one != Approx( 9.1f ) + + + 9.1f != Approx( 9.1000003815 ) + + + + + data.double_pi != Approx( 3.1415926535 ) + + + 3.1415926535 != Approx( 3.1415926535 ) + + + + + data.str_hello != "hello" + + + "hello" != "hello" + + + + + data.str_hello.size() != 5 + + + 5 != 5 + + + + + + + + data.int_seven != 6 + + + 7 != 6 + + + + + data.int_seven != 8 + + + 7 != 8 + + + + + data.float_nine_point_one != Approx( 9.11f ) + + + 9.1f != Approx( 9.1099996567 ) + + + + + data.float_nine_point_one != Approx( 9.0f ) + + + 9.1f != Approx( 9.0 ) + + + + + data.float_nine_point_one != Approx( 1 ) + + + 9.1f != Approx( 1.0 ) + + + + + data.float_nine_point_one != Approx( 0 ) + + + 9.1f != Approx( 0.0 ) + + + + + data.double_pi != Approx( 3.1415 ) + + + 3.1415926535 != Approx( 3.1415 ) + + + + + data.str_hello != "goodbye" + + + "hello" != "goodbye" + + + + + data.str_hello != "hell" + + + "hello" != "hell" + + + + + data.str_hello != "hello1" + + + "hello" != "hello1" + + + + + data.str_hello.size() != 6 + + + 5 != 6 + + + + + + + + d <= Approx( 1.24 ) + + + 1.23 <= Approx( 1.24 ) + + + + + d <= Approx( 1.23 ) + + + 1.23 <= Approx( 1.23 ) + + + + + !(d <= Approx( 1.22 )) + + + !(1.23 <= Approx( 1.22 )) + + + + + d <= Approx( 1.22 ).epsilon(0.1) + + + 1.23 <= Approx( 1.22 ) + + + + + + + + + + + testStringForMatching(), Contains("string") && Contains("abc") && Contains("substring") && Contains("contains") + + + "this string contains 'abc' as a substring" ( contains: "string" and contains: "abc" and contains: "substring" and contains: "contains" ) + + + + + + + + testStringForMatching(), Contains("string") || Contains("different") || Contains("random") + + + "this string contains 'abc' as a substring" ( contains: "string" or contains: "different" or contains: "random" ) + + + + + testStringForMatching2(), Contains("string") || Contains("different") || Contains("random") + + + "some completely different text that contains one common word" ( contains: "string" or contains: "different" or contains: "random" ) + + + + + + + + testStringForMatching(), (Contains("string") || Contains("different")) && Contains("substring") + + + "this string contains 'abc' as a substring" ( ( contains: "string" or contains: "different" ) and contains: "substring" ) + + + + + + + + testStringForMatching(), (Contains("string") || Contains("different")) && Contains("random") + + + "this string contains 'abc' as a substring" ( ( contains: "string" or contains: "different" ) and contains: "random" ) + + + + + + + + testStringForMatching(), !Contains("different") + + + "this string contains 'abc' as a substring" not contains: "different" + + + + + + + + testStringForMatching(), !Contains("substring") + + + "this string contains 'abc' as a substring" not contains: "substring" + + + + + + + + thisThrows(), "expected exception" + + + "expected exception" equals: "expected exception" + + + + + thisThrows(), "should fail" + + + "expected exception" equals: "should fail" + + + + + + + This one ran + + + + + + custom exception + + + + + + + True + + + {?} + + + + + !False + + + true + + + + + !(False) + + + !{?} + + + + + + + + data.int_seven > 7 + + + 7 > 7 + + + + + data.int_seven < 7 + + + 7 < 7 + + + + + data.int_seven > 8 + + + 7 > 8 + + + + + data.int_seven < 6 + + + 7 < 6 + + + + + data.int_seven < 0 + + + 7 < 0 + + + + + data.int_seven < -1 + + + 7 < -1 + + + + + data.int_seven >= 8 + + + 7 >= 8 + + + + + data.int_seven <= 6 + + + 7 <= 6 + + + + + data.float_nine_point_one < 9 + + + 9.1f < 9 + + + + + data.float_nine_point_one > 10 + + + 9.1f > 10 + + + + + data.float_nine_point_one > 9.2 + + + 9.1f > 9.2 + + + + + data.str_hello > "hello" + + + "hello" > "hello" + + + + + data.str_hello < "hello" + + + "hello" < "hello" + + + + + data.str_hello > "hellp" + + + "hello" > "hellp" + + + + + data.str_hello > "z" + + + "hello" > "z" + + + + + data.str_hello < "hellm" + + + "hello" < "hellm" + + + + + data.str_hello < "a" + + + "hello" < "a" + + + + + data.str_hello >= "z" + + + "hello" >= "z" + + + + + data.str_hello <= "a" + + + "hello" <= "a" + + + + + + + + data.int_seven < 8 + + + 7 < 8 + + + + + data.int_seven > 6 + + + 7 > 6 + + + + + data.int_seven > 0 + + + 7 > 0 + + + + + data.int_seven > -1 + + + 7 > -1 + + + + + data.int_seven >= 7 + + + 7 >= 7 + + + + + data.int_seven >= 6 + + + 7 >= 6 + + + + + data.int_seven <= 7 + + + 7 <= 7 + + + + + data.int_seven <= 8 + + + 7 <= 8 + + + + + data.float_nine_point_one > 9 + + + 9.1f > 9 + + + + + data.float_nine_point_one < 10 + + + 9.1f < 10 + + + + + data.float_nine_point_one < 9.2 + + + 9.1f < 9.2 + + + + + data.str_hello <= "hello" + + + "hello" <= "hello" + + + + + data.str_hello >= "hello" + + + "hello" >= "hello" + + + + + data.str_hello < "hellp" + + + "hello" < "hellp" + + + + + data.str_hello < "zebra" + + + "hello" < "zebra" + + + + + data.str_hello > "hellm" + + + "hello" > "hellm" + + + + + data.str_hello > "a" + + + "hello" > "a" + + + + + +
+ + Message from section one + + +
+
+ + Message from section two + + +
+ +
+ +
+ + + spec.hasFilters() == false + + + false == false + + + + + spec.matches( tcA ) == false + + + false == false + + + + + spec.matches( tcB ) == false + + + false == false + + + +
+
+ + + spec.hasFilters() == false + + + false == false + + + + + spec.matches(tcA ) == false + + + false == false + + + + + spec.matches( tcB ) == false + + + false == false + + + +
+
+ + + spec.hasFilters() == false + + + false == false + + + + + spec.matches( tcA ) == false + + + false == false + + + + + spec.matches( tcB ) == false + + + false == false + + + +
+
+ + + spec.hasFilters() == true + + + true == true + + + + + spec.matches( tcA ) == false + + + false == false + + + + + spec.matches( tcB ) == true + + + true == true + + + +
+
+ + + spec.hasFilters() == true + + + true == true + + + + + spec.matches( tcA ) == false + + + false == false + + + + + spec.matches( tcB ) == true + + + true == true + + + +
+
+ + + spec.hasFilters() == true + + + true == true + + + + + spec.matches( tcA ) == false + + + false == false + + + + + spec.matches( tcB ) == true + + + true == true + + + + + spec.matches( tcC ) == false + + + false == false + + + +
+
+ + + spec.hasFilters() == true + + + true == true + + + + + spec.matches( tcA ) == false + + + false == false + + + + + spec.matches( tcB ) == false + + + false == false + + + + + spec.matches( tcC ) == true + + + true == true + + + + + spec.matches( tcD ) == false + + + false == false + + + + + parseTestSpec( "*a" ).matches( tcA ) == true + + + true == true + + + +
+
+ + + spec.hasFilters() == true + + + true == true + + + + + spec.matches( tcA ) == false + + + false == false + + + + + spec.matches( tcB ) == false + + + false == false + + + + + spec.matches( tcC ) == true + + + true == true + + + + + spec.matches( tcD ) == false + + + false == false + + + + + parseTestSpec( "a*" ).matches( tcA ) == true + + + true == true + + + +
+
+ + + spec.hasFilters() == true + + + true == true + + + + + spec.matches( tcA ) == false + + + false == false + + + + + spec.matches( tcB ) == false + + + false == false + + + + + spec.matches( tcC ) == true + + + true == true + + + + + spec.matches( tcD ) == true + + + true == true + + + + + parseTestSpec( "*a*" ).matches( tcA ) == true + + + true == true + + + +
+
+ + + spec.hasFilters() == true + + + true == true + + + + + spec.matches( tcA ) == true + + + true == true + + + + + spec.matches( tcB ) == false + + + false == false + + + +
+
+ + + spec.hasFilters() == true + + + true == true + + + + + spec.matches( tcA ) == true + + + true == true + + + + + spec.matches( tcB ) == false + + + false == false + + + +
+
+ + + spec.hasFilters() == true + + + true == true + + + + + spec.matches( tcA ) == true + + + true == true + + + + + spec.matches( tcB ) == false + + + false == false + + + +
+
+ + + spec.hasFilters() == true + + + true == true + + + + + spec.matches( tcA ) == false + + + false == false + + + + + spec.matches( tcB ) == false + + + false == false + + + + + spec.matches( tcC ) == true + + + true == true + + + + + spec.matches( tcD ) == true + + + true == true + + + +
+
+ + + spec.hasFilters() == true + + + true == true + + + + + spec.matches( tcA ) == true + + + true == true + + + + + spec.matches( tcB ) == true + + + true == true + + + + + spec.matches( tcC ) == true + + + true == true + + + + + spec.matches( tcD ) == true + + + true == true + + + +
+
+ + + spec.hasFilters() == true + + + true == true + + + + + spec.matches( tcA ) == false + + + false == false + + + + + spec.matches( tcB ) == true + + + true == true + + + + + spec.matches( tcC ) == false + + + false == false + + + +
+
+ + + spec.hasFilters() == true + + + true == true + + + + + spec.matches( tcA ) == false + + + false == false + + + + + spec.matches( tcB ) == true + + + true == true + + + + + spec.matches( tcC ) == true + + + true == true + + + +
+
+ + + spec.hasFilters() == true + + + true == true + + + + + spec.matches( tcA ) == false + + + false == false + + + + + spec.matches( tcB ) == false + + + false == false + + + + + spec.matches( tcC ) == true + + + true == true + + + +
+
+ + + spec.hasFilters() == true + + + true == true + + + + + spec.matches( tcA ) == false + + + false == false + + + + + spec.matches( tcB ) == false + + + false == false + + + + + spec.matches( tcC ) == true + + + true == true + + + +
+
+ + + spec.hasFilters() == true + + + true == true + + + + + spec.matches( tcA ) == false + + + false == false + + + + + spec.matches( tcB ) == false + + + false == false + + + + + spec.matches( tcC ) == true + + + true == true + + + + + spec.matches( tcD ) == false + + + false == false + + + +
+
+ + + spec.hasFilters() == true + + + true == true + + + + + spec.matches( tcA ) == true + + + true == true + + + + + spec.matches( tcB ) == false + + + false == false + + + + + spec.matches( tcC ) == true + + + true == true + + + +
+
+ + + spec.hasFilters() == true + + + true == true + + + + + spec.matches( tcA ) == false + + + false == false + + + + + spec.matches( tcB ) == true + + + true == true + + + + + spec.matches( tcC ) == false + + + false == false + + + +
+
+ + + spec.hasFilters() == true + + + true == true + + + + + spec.matches( tcA ) == false + + + false == false + + + + + spec.matches( tcB ) == false + + + false == false + + + + + spec.matches( tcC ) == false + + + false == false + + + + + spec.matches( tcD ) == true + + + true == true + + + +
+
+ + + spec.hasFilters() == true + + + true == true + + + + + spec.matches( tcA ) == false + + + false == false + + + + + spec.matches( tcB ) == false + + + false == false + + + + + spec.matches( tcC ) == false + + + false == false + + + + + spec.matches( tcD ) == true + + + true == true + + + +
+
+ + + spec.hasFilters() == true + + + true == true + + + + + spec.matches( tcA ) == true + + + true == true + + + + + spec.matches( tcB ) == false + + + false == false + + + + + spec.matches( tcC ) == true + + + true == true + + + + + spec.matches( tcD ) == true + + + true == true + + + +
+
+ + + spec.hasFilters() == true + + + true == true + + + + + spec.matches( tcA ) == true + + + true == true + + + + + spec.matches( tcB ) == true + + + true == true + + + + + spec.matches( tcC ) == false + + + false == false + + + + + spec.matches( tcD ) == false + + + false == false + + + +
+
+ + + spec.hasFilters() == true + + + true == true + + + + + spec.matches( tcA ) == true + + + true == true + + + + + spec.matches( tcB ) == true + + + true == true + + + + + spec.matches( tcC ) == true + + + true == true + + + + + spec.matches( tcD ) == false + + + false == false + + + +
+
+ + + spec.hasFilters() == true + + + true == true + + + + + spec.matches( tcA ) == true + + + true == true + + + + + spec.matches( tcB ) == true + + + true == true + + + + + spec.matches( tcC ) == true + + + true == true + + + + + spec.matches( tcD ) == false + + + false == false + + + +
+
+ + + spec.hasFilters() == true + + + true == true + + + + + spec.matches( tcA ) == false + + + false == false + + + + + spec.matches( tcB ) == false + + + false == false + + + + + spec.matches( tcC ) == true + + + true == true + + + + + spec.matches( tcD ) == false + + + false == false + + + +
+
+ + + spec.hasFilters() == false + + + false == false + + + + + spec.matches( tcA ) == false + + + false == false + + + + + spec.matches( tcB ) == false + + + false == false + + + + + spec.matches( tcC ) == false + + + false == false + + + + + spec.matches( tcD ) == false + + + false == false + + + +
+
+ + + spec.hasFilters() == false + + + false == false + + + + + spec.matches( tcA ) == false + + + false == false + + + + + spec.matches( tcB ) == false + + + false == false + + + + + spec.matches( tcC ) == false + + + false == false + + + + + spec.matches( tcD ) == false + + + false == false + + + +
+
+ + + spec.hasFilters() == true + + + true == true + + + + + spec.matches( tcA ) == false + + + false == false + + + + + spec.matches( tcB ) == false + + + false == false + + + + + spec.matches( tcC ) == false + + + false == false + + + + + spec.matches( tcD ) == true + + + true == true + + + +
+ +
+ + + + p == 0 + + + 0 == 0 + + + + + p == pNULL + + + 0 == 0 + + + + + p != 0 + + + 0x != 0 + + + + + cp != 0 + + + 0x != 0 + + + + + cpc != 0 + + + 0x != 0 + + + + + returnsNull() == 0 + + + {null string} == 0 + + + + + returnsConstNull() == 0 + + + {null string} == 0 + + + + + 0 != p + + + 0 != 0x + + + + + +
+ + + result + + + {?} + + + + + config.processName == "" + + + "" == "" + + + +
+
+ + + result + + + {?} + + + + + config.processName == "test" + + + "test" == "test" + + + + + config.shouldDebugBreak == false + + + false == false + + + + + config.abortAfter == -1 + + + -1 == -1 + + + + + config.noThrow == false + + + false == false + + + + + config.reporterName == "console" + + + "console" == "console" + + + + + !(cfg.hasTestFilters()) + + + !false + + + +
+
+
+ + + result + + + {?} + + + + + cfg.hasTestFilters() + + + true + + + + + cfg.testSpec().matches(fakeTestCase("notIncluded")) == false + + + false == false + + + + + cfg.testSpec().matches(fakeTestCase("test1")) + + + true + + + +
+ +
+
+
+ + + result + + + {?} + + + + + cfg.hasTestFilters() + + + true + + + + + cfg.testSpec().matches(fakeTestCase("test1")) == false + + + false == false + + + + + cfg.testSpec().matches(fakeTestCase("alwaysIncluded")) + + + true + + + +
+ +
+
+
+ + + result + + + {?} + + + + + cfg.hasTestFilters() + + + true + + + + + cfg.testSpec().matches(fakeTestCase("test1")) == false + + + false == false + + + + + cfg.testSpec().matches(fakeTestCase("alwaysIncluded")) + + + true + + + +
+ +
+
+
+ + + cli.parse({"test", "-r", "console"}) + + + {?} + + + + + config.reporterName == "console" + + + "console" == "console" + + + +
+ +
+
+
+ + + cli.parse({"test", "-r", "xml"}) + + + {?} + + + + + config.reporterName == "xml" + + + "xml" == "xml" + + + +
+ +
+
+
+ + + cli.parse({"test", "--reporter", "junit"}) + + + {?} + + + + + config.reporterName == "junit" + + + "junit" == "junit" + + + +
+ +
+
+
+ + + !(cli.parse({ "test", "-r", "xml", "-r", "junit" })) + + + !{?} + + + +
+ +
+
+
+ + + cli.parse({"test", "-b"}) + + + {?} + + + + + config.shouldDebugBreak == true + + + true == true + + + +
+ +
+
+
+ + + cli.parse({"test", "--break"}) + + + {?} + + + + + config.shouldDebugBreak + + + true + + + +
+ +
+
+
+ + + cli.parse({"test", "-a"}) + + + {?} + + + + + config.abortAfter == 1 + + + 1 == 1 + + + +
+ +
+
+
+ + + cli.parse({"test", "-x", "2"}) + + + {?} + + + + + config.abortAfter == 2 + + + 2 == 2 + + + +
+ +
+
+
+ + + !result + + + true + + + + + result.errorMessage(), Contains("convert") && Contains("oops") + + + "Unable to convert 'oops' to destination type" ( contains: "convert" and contains: "oops" ) + + + +
+ +
+
+
+ + + cli.parse({"test", "-e"}) + + + {?} + + + + + config.noThrow + + + true + + + +
+ +
+
+
+ + + cli.parse({"test", "--nothrow"}) + + + {?} + + + + + config.noThrow + + + true + + + +
+ +
+
+
+ + + cli.parse({"test", "-o", "filename.ext"}) + + + {?} + + + + + config.outputFilename == "filename.ext" + + + "filename.ext" == "filename.ext" + + + +
+ +
+
+
+ + + cli.parse({"test", "--out", "filename.ext"}) + + + {?} + + + + + config.outputFilename == "filename.ext" + + + "filename.ext" == "filename.ext" + + + +
+ +
+
+
+ + + cli.parse({"test", "-abe"}) + + + {?} + + + + + config.abortAfter == 1 + + + 1 == 1 + + + + + config.shouldDebugBreak + + + true + + + + + config.noThrow == true + + + true == true + + + +
+ +
+
+
+ + + cli.parse({"test"}) + + + {?} + + + + + config.useColour == UseColour::Auto + + + 0 == 0 + + + +
+ +
+
+
+ + + cli.parse({"test", "--use-colour", "auto"}) + + + {?} + + + + + config.useColour == UseColour::Auto + + + 0 == 0 + + + +
+ +
+
+
+ + + cli.parse({"test", "--use-colour", "yes"}) + + + {?} + + + + + config.useColour == UseColour::Yes + + + 1 == 1 + + + +
+ +
+
+
+ + + cli.parse({"test", "--use-colour", "no"}) + + + {?} + + + + + config.useColour == UseColour::No + + + 2 == 2 + + + +
+ +
+
+
+ + + !result + + + true + + + + + result.errorMessage(), Contains( "colour mode must be one of" ) + + + "colour mode must be one of: auto, yes or no. 'wrong' not recognised" contains: "colour mode must be one of" + + + +
+ +
+ +
+ + + + truthy(false) + + + Hey, its truthy! + + + + + + + + testStringForMatching(), Matches("this STRING contains 'abc' as a substring") + + + "this string contains 'abc' as a substring" matches "this STRING contains 'abc' as a substring" case sensitively + + + + + testStringForMatching(), Matches("contains 'abc' as a substring") + + + "this string contains 'abc' as a substring" matches "contains 'abc' as a substring" case sensitively + + + + + testStringForMatching(), Matches("this string contains 'abc' as a") + + + "this string contains 'abc' as a substring" matches "this string contains 'abc' as a" case sensitively + + + + + + + + + + + +
+ + + before == 0 + + + 0 == 0 + + +
+
+ + + after > before + + + 1 > 0 + + + +
+ +
+ +
+ +
+ +
+
+
+ + + itDoesThis() + + + true + + +
+ + + itDoesThat() + + + true + + + +
+ +
+ +
+ +
+ +
+ +
+
+
+ +
+ +
+ +
+ +
+ +
+ + + v.size() == 0 + + + 0 == 0 + + +
+
+ + + v.size() == 10 + + + 10 == 10 + + + + + v.capacity() >= 10 + + + 10 >= 10 + + +
+
+ + + v.size() == 5 + + + 5 == 5 + + + + + v.capacity() >= 10 + + + 10 >= 10 + + + +
+ +
+ +
+ +
+ +
+
+ + + v.size() == 0 + + + 0 == 0 + + +
+
+ + + v.capacity() >= 10 + + + 10 >= 10 + + + + + v.size() == 0 + + + 0 == 0 + + + +
+ +
+ +
+ +
+ + + +A string sent directly to stdout + + +A string sent directly to stderr +A string sent to stderr via clog + + + + + + + d == Approx( 1.23 ) + + + 1.23 == Approx( 1.23 ) + + + + + d != Approx( 1.22 ) + + + 1.23 != Approx( 1.22 ) + + + + + d != Approx( 1.24 ) + + + 1.23 != Approx( 1.24 ) + + + + + d == 1.23_a + + + 1.23 == Approx( 1.23 ) + + + + + d != 1.22_a + + + 1.23 != Approx( 1.22 ) + + + + + Approx( d ) == 1.23 + + + Approx( 1.23 ) == 1.23 + + + + + Approx( d ) != 1.22 + + + Approx( 1.23 ) != 1.22 + + + + + Approx( d ) != 1.24 + + + Approx( 1.23 ) != 1.24 + + + + + INFINITY == Approx(INFINITY) + + + inff == Approx( inf ) + + + + + +
+ +
+
+ +
+ + +Message from section one +Message from section two + + +
+ + + + testStringForMatching(), StartsWith("This String") + + + "this string contains 'abc' as a substring" starts with: "This String" + + + + + testStringForMatching(), StartsWith("string", Catch::CaseSensitive::No) + + + "this string contains 'abc' as a substring" starts with: "string" (case insensitive) + + + + + +
+ + + Catch::Detail::stringify(singular) == "{ 1 }" + + + "{ 1 }" == "{ 1 }" + + + +
+
+ + + Catch::Detail::stringify(arr) == "{ 3, 2, 1 }" + + + "{ 3, 2, 1 }" == "{ 3, 2, 1 }" + + + +
+
+ + + Catch::Detail::stringify(arr) == R"({ { "1:1", "1:2", "1:3" }, { "2:1", "2:2" } })" + + + "{ { "1:1", "1:2", "1:3" }, { "2:1", "2:2" } }" +== +"{ { "1:1", "1:2", "1:3" }, { "2:1", "2:2" } }" + + + +
+ +
+ + + + testStringForMatching(), Contains("string") + + + "this string contains 'abc' as a substring" contains: "string" + + + + + testStringForMatching(), Contains("string", Catch::CaseSensitive::No) + + + "this string contains 'abc' as a substring" contains: "string" (case insensitive) + + + + + testStringForMatching(), Contains("abc") + + + "this string contains 'abc' as a substring" contains: "abc" + + + + + testStringForMatching(), Contains("aBC", Catch::CaseSensitive::No) + + + "this string contains 'abc' as a substring" contains: "abc" (case insensitive) + + + + + testStringForMatching(), StartsWith("this") + + + "this string contains 'abc' as a substring" starts with: "this" + + + + + testStringForMatching(), StartsWith("THIS", Catch::CaseSensitive::No) + + + "this string contains 'abc' as a substring" starts with: "this" (case insensitive) + + + + + testStringForMatching(), EndsWith("substring") + + + "this string contains 'abc' as a substring" ends with: "substring" + + + + + testStringForMatching(), EndsWith(" SuBsTrInG", Catch::CaseSensitive::No) + + + "this string contains 'abc' as a substring" ends with: " substring" (case insensitive) + + + + + +
+ + + empty.empty() + + + true + + + + + empty.size() == 0 + + + 0 == 0 + + + + + std::strcmp( empty.c_str(), "" ) == 0 + + + 0 == 0 + + + +
+
+ + + s.empty() == false + + + false == false + + + + + s.size() == 5 + + + 5 == 5 + + + + + isSubstring( s ) == false + + + false == false + + + + + std::strcmp( rawChars, "hello" ) == 0 + + + 0 == 0 + + +
+ + + isOwned( s ) == false + + + false == false + + + + + s.c_str() == rawChars + + + "hello" == "hello" + + + + + isOwned( s ) == false + + + false == false + + + +
+ +
+
+ + + original == "original" + + + original == "original" + + + + + isSubstring( original ) + + + true + + + + + isOwned( original ) == false + + + false == false + + + + + isSubstring( original ) == false + + + false == false + + + + + isOwned( original ) + + + true + + + +
+
+
+ + + ss.empty() == false + + + false == false + + + + + ss.size() == 5 + + + 5 == 5 + + + + + std::strcmp( ss.c_str(), "hello" ) == 0 + + + 0 == 0 + + + + + ss == "hello" + + + hello == "hello" + + + +
+ +
+
+
+ + + isSubstring( ss ) + + + true + + + + + isOwned( ss ) == false + + + false == false + + + + + rawChars == s.currentData() + + + "hello world!" == "hello world!" + + + + + ss.c_str() != rawChars + + + "hello" != "hello world!" + + + + + isSubstring( ss ) == false + + + false == false + + + + + isOwned( ss ) + + + true + + + + + ss.currentData() != s.currentData() + + + "hello" != "hello world!" + + + +
+ +
+
+
+ + + ss.size() == 6 + + + 6 == 6 + + + + + std::strcmp( ss.c_str(), "world!" ) == 0 + + + 0 == 0 + + + +
+ +
+
+
+ + + s.c_str() == s2.c_str() + + + "hello world!" == "hello world!" + + + +
+ +
+
+
+ + + s.c_str() != ss.c_str() + + + "hello world!" != "hello" + + + +
+ +
+
+ + + StringRef("hello") == StringRef("hello") + + + hello == hello + + + + + StringRef("hello") != StringRef("cello") + + + hello != cello + + + +
+
+
+ + + sr == "a standard string" + + + a standard string == "a standard string" + + + + + sr.size() == stdStr.size() + + + 17 == 17 + + + +
+ +
+
+
+ + + sr == "a standard string" + + + a standard string == "a standard string" + + + + + sr.size() == stdStr.size() + + + 17 == 17 + + + +
+ +
+
+
+ + + sr == "a standard string" + + + a standard string == "a standard string" + + + + + sr.size() == stdStr.size() + + + 17 == 17 + + + +
+ +
+
+
+ + + stdStr == "a stringref" + + + "a stringref" == "a stringref" + + + + + stdStr.size() == sr.size() + + + 11 == 11 + + + +
+ +
+
+
+ + + stdStr == "a stringref" + + + "a stringref" == "a stringref" + + + + + stdStr.size() == sr.size() + + + 11 == 11 + + + +
+ +
+
+
+ + + stdStr == "a stringref" + + + "a stringref" == "a stringref" + + + + + stdStr.size() == sr.size() + + + 11 == 11 + + + +
+ +
+
+ + + ascii.numberOfCharacters() == ascii.size() + + + 39 == 39 + + + + + simpleu8.numberOfCharacters() == 30 + + + 30 == 30 + + + + + emojis.numberOfCharacters() == 9 + + + 9 == 9 + + + +
+ +
+ + + + minute == seconds + + + 1 m == 60 s + + + + + hour != seconds + + + 1 h != 60 s + + + + + micro != milli + + + 1 us != 1 ms + + + + + nano != micro + + + 1 ns != 1 us + + + + + + + + half_minute != femto_second + + + 1 [30/1]s != 1 fs + + + + + pico_second != atto_second + + + 1 ps != 1 as + + + + + + + + now != later + + + {iso8601-timestamp} +!= +{iso8601-timestamp} + + + + + + + + s1 == s2 + + + "if ($b == 10) { + $a = 20; +}" +== +"if ($b == 10) { + $a = 20; +} +" + + + + + +
+ + + what, Contains( "[@zzz]" ) + + + "error: tag alias, '[@zzz]' already registered. + First seen at: file:2 + Redefined at: file:10" contains: "[@zzz]" + + + + + what, Contains( "file" ) + + + "error: tag alias, '[@zzz]' already registered. + First seen at: file:2 + Redefined at: file:10" contains: "file" + + + + + what, Contains( "2" ) + + + "error: tag alias, '[@zzz]' already registered. + First seen at: file:2 + Redefined at: file:10" contains: "2" + + + + + what, Contains( "10" ) + + + "error: tag alias, '[@zzz]' already registered. + First seen at: file:2 + Redefined at: file:10" contains: "10" + + + +
+
+ + + registry.add( "[no ampersat]", "", Catch::SourceLineInfo( "file", 3 ) ) + + + registry.add( "[no ampersat]", "", Catch::SourceLineInfo( "file", 3 ) ) + + + + + registry.add( "[the @ is not at the start]", "", Catch::SourceLineInfo( "file", 3 ) ) + + + registry.add( "[the @ is not at the start]", "", Catch::SourceLineInfo( "file", 3 ) ) + + + + + registry.add( "@no square bracket at start]", "", Catch::SourceLineInfo( "file", 3 ) ) + + + registry.add( "@no square bracket at start]", "", Catch::SourceLineInfo( "file", 3 ) ) + + + + + registry.add( "[@no square bracket at end", "", Catch::SourceLineInfo( "file", 3 ) ) + + + registry.add( "[@no square bracket at end", "", Catch::SourceLineInfo( "file", 3 ) ) + + + +
+ +
+ + + + + + + 0x == bit30and31 + + + 3221225472 (0x) == 3221225472 + + + + + + + + 1 == 2 + + + 1 == 2 + + + + + + + + + + For some reason someone is throwing a string literal! + + + + + + + testCase.isOpen() + + + true + + + + + s1.isOpen() + + + true + + +
+ + + s1.isSuccessfullyCompleted() + + + true + + + + + testCase.isComplete() == false + + + false == false + + + + + ctx.completedCycle() + + + true + + + + + testCase.isSuccessfullyCompleted() + + + true + + + +
+ + + testCase.isOpen() + + + true + + + + + s1.isOpen() + + + true + + +
+ + + s1.isComplete() + + + true + + + + + s1.isSuccessfullyCompleted() == false + + + false == false + + + + + testCase.isComplete() == false + + + false == false + + + + + ctx.completedCycle() + + + true + + + + + testCase.isSuccessfullyCompleted() == false + + + false == false + + +
+ + + testCase2.isOpen() + + + true + + + + + s1b.isOpen() == false + + + false == false + + + + + ctx.completedCycle() + + + true + + + + + testCase.isComplete() + + + true + + + + + testCase.isSuccessfullyCompleted() + + + true + + + +
+ +
+ + + testCase.isOpen() + + + true + + + + + s1.isOpen() + + + true + + +
+ + + s1.isComplete() + + + true + + + + + s1.isSuccessfullyCompleted() == false + + + false == false + + + + + testCase.isComplete() == false + + + false == false + + + + + ctx.completedCycle() + + + true + + + + + testCase.isSuccessfullyCompleted() == false + + + false == false + + +
+ + + testCase2.isOpen() + + + true + + + + + s1b.isOpen() == false + + + false == false + + + + + s2.isOpen() + + + true + + + + + ctx.completedCycle() + + + true + + + + + testCase.isComplete() + + + true + + + + + testCase.isSuccessfullyCompleted() + + + true + + + +
+ +
+ + + testCase.isOpen() + + + true + + + + + s1.isOpen() + + + true + + +
+ + + s2.isOpen() == false + + + false == false + + + + + testCase.isComplete() == false + + + false == false + + +
+ + + testCase2.isOpen() + + + true + + + + + s1b.isOpen() == false + + + false == false + + + + + s2b.isOpen() + + + true + + + + + ctx.completedCycle() == false + + + false == false + + +
+ + + ctx.completedCycle() + + + true + + + + + s2b.isSuccessfullyCompleted() + + + true + + + + + testCase2.isComplete() == false + + + false == false + + + + + testCase2.isSuccessfullyCompleted() + + + true + + + +
+ +
+ +
+ + + testCase.isOpen() + + + true + + + + + s1.isOpen() + + + true + + +
+ + + s2.isOpen() == false + + + false == false + + + + + testCase.isComplete() == false + + + false == false + + +
+ + + testCase2.isOpen() + + + true + + + + + s1b.isOpen() == false + + + false == false + + + + + s2b.isOpen() + + + true + + + + + ctx.completedCycle() == false + + + false == false + + +
+ + + ctx.completedCycle() + + + true + + + + + s2b.isComplete() + + + true + + + + + s2b.isSuccessfullyCompleted() == false + + + false == false + + + + + testCase2.isSuccessfullyCompleted() == false + + + false == false + + + + + testCase3.isOpen() + + + true + + + + + s1c.isOpen() == false + + + false == false + + + + + s2c.isOpen() == false + + + false == false + + + + + testCase3.isSuccessfullyCompleted() + + + true + + + +
+ +
+ +
+ + + testCase.isOpen() + + + true + + + + + s1.isOpen() + + + true + + +
+ + + s2.isOpen() + + + true + + + + + s2.isComplete() + + + true + + + + + s1.isComplete() == false + + + false == false + + + + + s1.isComplete() + + + true + + + + + testCase.isComplete() == false + + + false == false + + + + + testCase.isComplete() + + + true + + + +
+ + + testCase.isOpen() + + + true + + + + + s1.isOpen() + + + true + + +
+ + + g1.isOpen() + + + true + + + + + g1.index() == 0 + + + 0 == 0 + + + + + g1.isComplete() == false + + + false == false + + + + + s1.isComplete() == false + + + false == false + + +
+ + + s1.isComplete() == false + + + false == false + + + + + testCase.isSuccessfullyCompleted() == false + + + false == false + + +
+ + + testCase2.isOpen() + + + true + + + + + s1b.isOpen() + + + true + + + + + g1b.isOpen() + + + true + + + + + g1b.index() == 1 + + + 1 == 1 + + + + + s1.isComplete() == false + + + false == false + + + + + s1b.isComplete() + + + true + + + + + g1b.isComplete() + + + true + + + + + testCase2.isComplete() + + + true + + + +
+ +
+ +
+ + + testCase.isOpen() + + + true + + + + + s1.isOpen() + + + true + + +
+ + + g1.isOpen() + + + true + + + + + g1.index() == 0 + + + 0 == 0 + + + + + g1.isComplete() == false + + + false == false + + + + + s1.isComplete() == false + + + false == false + + +
+ + + s2.isOpen() + + + true + + + + + s2.isComplete() + + + true + + + + + s1.isComplete() == false + + + false == false + + + + + testCase.isComplete() == false + + + false == false + + +
+ + + testCase2.isOpen() + + + true + + + + + s1b.isOpen() + + + true + + + + + g1b.isOpen() + + + true + + + + + g1b.index() == 1 + + + 1 == 1 + + + + + s2b.isOpen() + + + true + + + + + s2b.isComplete() + + + true + + + + + g1b.isComplete() + + + true + + + + + s1b.isComplete() + + + true + + + + + testCase2.isComplete() + + + true + + + +
+ +
+ +
+ + + testCase.isOpen() + + + true + + + + + s1.isOpen() + + + true + + +
+ + + g1.isOpen() + + + true + + + + + g1.index() == 0 + + + 0 == 0 + + + + + g1.isComplete() == false + + + false == false + + + + + s1.isComplete() == false + + + false == false + + +
+ + + s2.isOpen() + + + true + + + + + s2.isComplete() + + + true + + + + + s2.isSuccessfullyCompleted() == false + + + false == false + + + + + s1.isComplete() == false + + + false == false + + + + + testCase.isComplete() == false + + + false == false + + +
+ + + testCase2.isOpen() + + + true + + + + + s1b.isOpen() + + + true + + + + + g1b.isOpen() + + + true + + + + + g1b.index() == 0 + + + 0 == 0 + + + + + s2b.isOpen() == false + + + false == false + + + + + g1b.isComplete() == false + + + false == false + + + + + s1b.isComplete() == false + + + false == false + + + + + testCase2.isComplete() == false + + + false == false + + + + + testCase3.isOpen() + + + true + + + + + s1c.isOpen() + + + true + + + + + g1c.isOpen() + + + true + + + + + g1c.index() == 1 + + + 1 == 1 + + + + + s2c.isOpen() + + + true + + + + + s2c.isComplete() + + + true + + + + + g1c.isComplete() + + + true + + + + + s1c.isComplete() + + + true + + + + + testCase3.isComplete() + + + true + + + +
+ +
+ +
+ +
+ + + 3.14 + + + + + + + d == approx( 1.23 ) + + + 1.23 == Approx( 1.23 ) + + + + + d == approx( 1.22 ) + + + 1.23 == Approx( 1.22 ) + + + + + d == approx( 1.24 ) + + + 1.23 == Approx( 1.24 ) + + + + + d != approx( 1.25 ) + + + 1.23 != Approx( 1.25 ) + + + + + approx( d ) == 1.23 + + + Approx( 1.23 ) == 1.23 + + + + + approx( d ) == 1.22 + + + Approx( 1.23 ) == 1.22 + + + + + approx( d ) == 1.24 + + + Approx( 1.23 ) == 1.24 + + + + + approx( d ) != 1.25 + + + Approx( 1.23 ) != 1.25 + + + + + +
+ +
+ +
+ +
+ + + v, VectorContains(1) + + + { 1, 2, 3 } Contains: 1 + + + + + v, VectorContains(2) + + + { 1, 2, 3 } Contains: 2 + + + +
+
+ + + v, Contains(v2) + + + { 1, 2, 3 } Contains: { 1, 2 } + + + + + v, Contains(v2) + + + { 1, 2, 3 } Contains: { 1, 2, 3 } + + + + + v, Contains(empty) + + + { 1, 2, 3 } Contains: { } + + + + + empty, Contains(empty) + + + { } Contains: { } + + + +
+
+ + + v, VectorContains(1) && VectorContains(2) + + + { 1, 2, 3 } ( Contains: 1 and Contains: 2 ) + + + +
+
+ + + v, Equals(v) + + + { 1, 2, 3 } Equals: { 1, 2, 3 } + + + + + empty, Equals(empty) + + + { } Equals: { } + + + + + v, Equals(v2) + + + { 1, 2, 3 } Equals: { 1, 2, 3 } + + + +
+
+ + + v, UnorderedEquals(v) + + + { 1, 2, 3 } UnorderedEquals: { 1, 2, 3 } + + + + + empty, UnorderedEquals(empty) + + + { } UnorderedEquals: { } + + + + + permuted, UnorderedEquals(v) + + + { 1, 3, 2 } UnorderedEquals: { 1, 2, 3 } + + + + + permuted, UnorderedEquals(v) + + + { 2, 3, 1 } UnorderedEquals: { 1, 2, 3 } + + + +
+ +
+ +
+ + + v, VectorContains(-1) + + + { 1, 2, 3 } Contains: -1 + + + + + empty, VectorContains(1) + + + { } Contains: 1 + + + +
+
+ + + empty, Contains(v) + + + { } Contains: { 1, 2, 3 } + + + + + v, Contains(v2) + + + { 1, 2, 3 } Contains: { 1, 2, 4 } + + + +
+
+ + + v, Equals(v2) + + + { 1, 2, 3 } Equals: { 1, 2 } + + + + + v2, Equals(v) + + + { 1, 2 } Equals: { 1, 2, 3 } + + + + + empty, Equals(v) + + + { } Equals: { 1, 2, 3 } + + + + + v, Equals(empty) + + + { 1, 2, 3 } Equals: { } + + + +
+
+ + + v, UnorderedEquals(empty) + + + { 1, 2, 3 } UnorderedEquals: { } + + + + + empty, UnorderedEquals(v) + + + { } UnorderedEquals: { 1, 2, 3 } + + + + + permuted, UnorderedEquals(v) + + + { 1, 3 } UnorderedEquals: { 1, 2, 3 } + + + + + permuted, UnorderedEquals(v) + + + { 3, 1 } UnorderedEquals: { 1, 2, 3 } + + + +
+ +
+ + + + thisThrows(), std::domain_error + + + thisThrows(), std::domain_error + + + + + thisDoesntThrow() + + + thisDoesntThrow() + + + + + thisThrows() + + + thisThrows() + + + + + + + unexpected exception + + + + + + + thisThrows() == 0 + + + thisThrows() == 0 + + + expected exception + + + + + + + + thisThrows() == 0 + + + thisThrows() == 0 + + + expected exception + + + + + + + + thisThrows() == 0 + + + thisThrows() == 0 + + + expected exception + + + + + +
+ + unexpected exception + + +
+ +
+ + + + + + Uncomment the code in this test to check that it gives a sensible compiler error + + + + + + Uncomment the code in this test to check that it gives a sensible compiler error + + + + + + + + + + + + + + + + +
+ + + encode( "normal string" ) == "normal string" + + + "normal string" == "normal string" + + + +
+
+ + + encode( "" ) == "" + + + "" == "" + + + +
+
+ + + encode( "smith & jones" ) == "smith &amp; jones" + + + "smith &amp; jones" == "smith &amp; jones" + + + +
+
+ + + encode( "smith < jones" ) == "smith &lt; jones" + + + "smith &lt; jones" == "smith &lt; jones" + + + +
+
+ + + encode( "smith > jones" ) == "smith > jones" + + + "smith > jones" == "smith > jones" + + + + + encode( "smith ]]> jones" ) == "smith ]]&gt; jones" + + + "smith ]]&gt; jones" +== +"smith ]]&gt; jones" + + + +
+
+ + + encode( stringWithQuotes ) == stringWithQuotes + + + "don't "quote" me on that" +== +"don't "quote" me on that" + + + + + encode( stringWithQuotes, Catch::XmlEncode::ForAttributes ) == "don't &quot;quote&quot; me on that" + + + "don't &quot;quote&quot; me on that" +== +"don't &quot;quote&quot; me on that" + + + +
+
+ + + encode( "[\x01]" ) == "[\\x01]" + + + "[\x01]" == "[\x01]" + + + +
+
+ + + encode( "[\x7F]" ) == "[\\x7F]" + + + "[\x7F]" == "[\x7F]" + + + +
+ +
+ +
+ + + encode(u8"Here be 👾") == u8"Here be 👾" + + + "Here be 👾" == "Here be 👾" + + + + + encode(u8"Å¡Å¡") == u8"Å¡Å¡" + + + "Å¡Å¡" == "Å¡Å¡" + + + + + encode("\xDF\xBF") == "\xDF\xBF" + + + "ß¿" == "ß¿" + + + + + encode("\xE0\xA0\x80") == "\xE0\xA0\x80" + + + "à €" == "à €" + + + + + encode("\xED\x9F\xBF") == "\xED\x9F\xBF" + + + "퟿" == "퟿" + + + + + encode("\xEE\x80\x80") == "\xEE\x80\x80" + + + "" == "" + + + + + encode("\xEF\xBF\xBF") == "\xEF\xBF\xBF" + + + "ï¿¿" == "ï¿¿" + + + + + encode("\xF0\x90\x80\x80") == "\xF0\x90\x80\x80" + + + "ð€€" == "ð€€" + + + + + encode("\xF4\x8F\xBF\xBF") == "\xF4\x8F\xBF\xBF" + + + "ô¿¿" == "ô¿¿" + + + +
+
+
+ + + encode("Here \xFF be 👾") == u8"Here \\xFF be 👾" + + + "Here \xFF be 👾" == "Here \xFF be 👾" + + + + + encode("\xFF") == "\\xFF" + + + "\xFF" == "\xFF" + + + + + encode("\xC5\xC5\xA0") == u8"\\xC5Š" + + + "\xC5Š" == "\xC5Š" + + + + + encode("\xF4\x90\x80\x80") == u8"\\xF4\\x90\\x80\\x80" + + + "\xF4\x90\x80\x80" == "\xF4\x90\x80\x80" + + + +
+ +
+
+
+ + + encode("\xC0\x80") == u8"\\xC0\\x80" + + + "\xC0\x80" == "\xC0\x80" + + + + + encode("\xF0\x80\x80\x80") == u8"\\xF0\\x80\\x80\\x80" + + + "\xF0\x80\x80\x80" == "\xF0\x80\x80\x80" + + + + + encode("\xC1\xBF") == u8"\\xC1\\xBF" + + + "\xC1\xBF" == "\xC1\xBF" + + + + + encode("\xE0\x9F\xBF") == u8"\\xE0\\x9F\\xBF" + + + "\xE0\x9F\xBF" == "\xE0\x9F\xBF" + + + + + encode("\xF0\x8F\xBF\xBF") == u8"\\xF0\\x8F\\xBF\\xBF" + + + "\xF0\x8F\xBF\xBF" == "\xF0\x8F\xBF\xBF" + + + +
+ +
+
+
+ + + encode("\xED\xA0\x80") == "\xED\xA0\x80" + + + "í €" == "í €" + + + + + encode("\xED\xAF\xBF") == "\xED\xAF\xBF" + + + "í¯¿" == "í¯¿" + + + + + encode("\xED\xB0\x80") == "\xED\xB0\x80" + + + "í°€" == "í°€" + + + + + encode("\xED\xBF\xBF") == "\xED\xBF\xBF" + + + "í¿¿" == "í¿¿" + + + +
+ +
+
+
+ + + encode("\x80") == u8"\\x80" + + + "\x80" == "\x80" + + + + + encode("\x81") == u8"\\x81" + + + "\x81" == "\x81" + + + + + encode("\xBC") == u8"\\xBC" + + + "\xBC" == "\xBC" + + + + + encode("\xBF") == u8"\\xBF" + + + "\xBF" == "\xBF" + + + + + encode("\xF5\x80\x80\x80") == u8"\\xF5\\x80\\x80\\x80" + + + "\xF5\x80\x80\x80" == "\xF5\x80\x80\x80" + + + + + encode("\xF6\x80\x80\x80") == u8"\\xF6\\x80\\x80\\x80" + + + "\xF6\x80\x80\x80" == "\xF6\x80\x80\x80" + + + + + encode("\xF7\x80\x80\x80") == u8"\\xF7\\x80\\x80\\x80" + + + "\xF7\x80\x80\x80" == "\xF7\x80\x80\x80" + + + +
+ +
+
+
+ + + encode("\xDE") == u8"\\xDE" + + + "\xDE" == "\xDE" + + + + + encode("\xDF") == u8"\\xDF" + + + "\xDF" == "\xDF" + + + + + encode("\xE0") == u8"\\xE0" + + + "\xE0" == "\xE0" + + + + + encode("\xEF") == u8"\\xEF" + + + "\xEF" == "\xEF" + + + + + encode("\xF0") == u8"\\xF0" + + + "\xF0" == "\xF0" + + + + + encode("\xF4") == u8"\\xF4" + + + "\xF4" == "\xF4" + + + + + encode("\xE0\x80") == u8"\\xE0\\x80" + + + "\xE0\x80" == "\xE0\x80" + + + + + encode("\xE0\xBF") == u8"\\xE0\\xBF" + + + "\xE0\xBF" == "\xE0\xBF" + + + + + encode("\xE1\x80") == u8"\\xE1\\x80" + + + "\xE1\x80" == "\xE1\x80" + + + + + encode("\xF0\x80") == u8"\\xF0\\x80" + + + "\xF0\x80" == "\xF0\x80" + + + + + encode("\xF4\x80") == u8"\\xF4\\x80" + + + "\xF4\x80" == "\xF4\x80" + + + + + encode("\xF0\x80\x80") == u8"\\xF0\\x80\\x80" + + + "\xF0\x80\x80" == "\xF0\x80\x80" + + + + + encode("\xF4\x80\x80") == u8"\\xF4\\x80\\x80" + + + "\xF4\x80\x80" == "\xF4\x80\x80" + + + +
+ +
+ +
+ + + + Catch::Detail::stringify( empty ) == "{ }" + + + "{ }" == "{ }" + + + + + Catch::Detail::stringify( oneValue ) == "{ 42 }" + + + "{ 42 }" == "{ 42 }" + + + + + Catch::Detail::stringify( twoValues ) == "{ 42, 250 }" + + + "{ 42, 250 }" == "{ 42, 250 }" + + + + + + + + x == 0 + + + 0 == 0 + + + + + + + + obj.prop != 0 + + + 0x != 0 + + + + + + + + flag + + + true + + + + + testCheckedElse( true ) + + + true + + + + + + + + flag + + + false + + + + + testCheckedElse( false ) + + + false + + + + + + + + flag + + + true + + + + + testCheckedIf( true ) + + + true + + + + + + + + flag + + + false + + + + + testCheckedIf( false ) + + + false + + + + + + + + unsigned_char_var == 1 + + + 1 == 1 + + + + + unsigned_short_var == 1 + + + 1 == 1 + + + + + unsigned_int_var == 1 + + + 1 == 1 + + + + + unsigned_long_var == 1 + + + 1 == 1 + + + + + + + + long_var == unsigned_char_var + + + 1 == 1 + + + + + long_var == unsigned_short_var + + + 1 == 1 + + + + + long_var == unsigned_int_var + + + 1 == 1 + + + + + long_var == unsigned_long_var + + + 1 == 1 + + + + + +
+
+ +
+ +
+
+
+ +
+ +
+
+ +
+ +
+ + + + +loose text artifact + + + + + Previous info should not be seen + + + + + + + + + + l == std::numeric_limits<long long>::max() + + + 9223372036854775807 (0x) +== +9223372036854775807 (0x) + + + + + +
+ + + b > a + + + 0 > 1 + + + +
+
+ + + b > a + + + 1 > 1 + + + +
+
+ + + b > a + + + 2 > 1 + + + +
+
+ + + b > a + + + 3 > 1 + + + +
+
+ + + b > a + + + 4 > 1 + + + +
+
+ + + b > a + + + 5 > 1 + + + +
+
+ + + b > a + + + 6 > 1 + + + +
+
+ + + b > a + + + 7 > 1 + + + +
+
+ + + b > a + + + 8 > 1 + + + +
+
+ + + b > a + + + 9 > 1 + + + +
+ +
+ + + Testing if fib[0] (1) is even + + + + ( fib[i] % 2 ) == 0 + + + 1 == 0 + + + + Testing if fib[1] (1) is even + + + + ( fib[i] % 2 ) == 0 + + + 1 == 0 + + + + Testing if fib[2] (2) is even + + + + ( fib[i] % 2 ) == 0 + + + 0 == 0 + + + + Testing if fib[3] (3) is even + + + + ( fib[i] % 2 ) == 0 + + + 1 == 0 + + + + Testing if fib[4] (5) is even + + + + ( fib[i] % 2 ) == 0 + + + 1 == 0 + + + + Testing if fib[5] (8) is even + + + + ( fib[i] % 2 ) == 0 + + + 0 == 0 + + + + Testing if fib[6] (13) is even + + + + ( fib[i] % 2 ) == 0 + + + 1 == 0 + + + + Testing if fib[7] (21) is even + + + + ( fib[i] % 2 ) == 0 + + + 1 == 0 + + + + + +
+
+ + + a == b + + + 1 == 2 + + + +
+ +
+
+
+ + + a != b + + + 1 != 2 + + + +
+ +
+
+
+ + + a < b + + + 1 < 2 + + + +
+ +
+ +
+ +
+ + + a != b + + + 1 != 2 + + + + + b != a + + + 2 != 1 + + +
+ + + a != b + + + 1 != 2 + + + +
+ +
+ +
+ + + + s == "7" + + + "7" == "7" + + + + + + + + ti == typeid(int) + + + {?} == {?} + + + + + + + + + + + makeString( false ) != static_cast<char*>(0) + + + "valid string" != {null string} + + + + + makeString( true ) == static_cast<char*>(0) + + + {null string} == {null string} + + + + + + + + ptr.get() == 0 + + + 0 == 0 + + + + + + + + ::Catch::Detail::stringify( pair ) == "{ { 42, \"Arthur\" }, { \"Ford\", 24 } }" + + + "{ { 42, "Arthur" }, { "Ford", 24 } }" +== +"{ { 42, "Arthur" }, { "Ford", 24 } }" + + + + + + + + p == 0 + + + 0 == 0 + + + + + +
+ + + a != b + + + 1 != 2 + + + + + b != a + + + 2 != 1 + + + +
+
+ + + a != b + + + 1 != 2 + + + +
+ +
+ +
+ + + Catch::replaceInPlace( letters, "b", "z" ) + + + true + + + + + letters == "azcdefcg" + + + "azcdefcg" == "azcdefcg" + + + +
+
+ + + Catch::replaceInPlace( letters, "c", "z" ) + + + true + + + + + letters == "abzdefzg" + + + "abzdefzg" == "abzdefzg" + + + +
+
+ + + Catch::replaceInPlace( letters, "a", "z" ) + + + true + + + + + letters == "zbcdefcg" + + + "zbcdefcg" == "zbcdefcg" + + + +
+
+ + + Catch::replaceInPlace( letters, "g", "z" ) + + + true + + + + + letters == "abcdefcz" + + + "abcdefcz" == "abcdefcz" + + + +
+
+ + + Catch::replaceInPlace( letters, letters, "replaced" ) + + + true + + + + + letters == "replaced" + + + "replaced" == "replaced" + + + +
+
+ + + !(Catch::replaceInPlace( letters, "x", "z" )) + + + !false + + + + + letters == letters + + + "abcdefcg" == "abcdefcg" + + + +
+
+ + + Catch::replaceInPlace( s, "'", "|'" ) + + + true + + + + + s == "didn|'t" + + + "didn|'t" == "didn|'t" + + + +
+ +
+ + + + + + 3 + + + + false + + + false + + + + + + + hi + + + i := 7 + + + + false + + + false + + + + + +
+ + + Catch::Detail::stringify( emptyMap ) == "{ }" + + + "{ }" == "{ }" + + + +
+
+ + + Catch::Detail::stringify( map ) == "{ { \"one\", 1 } }" + + + "{ { "one", 1 } }" == "{ { "one", 1 } }" + + + +
+
+ + + Catch::Detail::stringify( map ) == "{ { \"abc\", 1 }, { \"def\", 2 }, { \"ghi\", 3 } }" + + + "{ { "abc", 1 }, { "def", 2 }, { "ghi", 3 } }" +== +"{ { "abc", 1 }, { "def", 2 }, { "ghi", 3 } }" + + + +
+ +
+ + + + ::Catch::Detail::stringify(value) == "{ 34, \"xyzzy\" }" + + + "{ 34, "xyzzy" }" == "{ 34, "xyzzy" }" + + + + + + + + ::Catch::Detail::stringify( value ) == "{ 34, \"xyzzy\" }" + + + "{ 34, "xyzzy" }" == "{ 34, "xyzzy" }" + + + + + +
+ + + Catch::Detail::stringify( emptySet ) == "{ }" + + + "{ }" == "{ }" + + + +
+
+ + + Catch::Detail::stringify( set ) == "{ \"one\" }" + + + "{ "one" }" == "{ "one" }" + + + +
+
+ + + Catch::Detail::stringify( set ) == "{ \"abc\", \"def\", \"ghi\" }" + + + "{ "abc", "def", "ghi" }" +== +"{ "abc", "def", "ghi" }" + + + +
+ +
+ + + + ::Catch::Detail::stringify( pr ) == "{ { \"green\", 55 } }" + + + "{ { "green", 55 } }" +== +"{ { "green", 55 } }" + + + + + + + + std::string( "first" ) == "second" + + + "first" == "second" + + + + + + + + ::Catch::Detail::stringify(streamable_range{}) == "op<<(streamable_range)" + + + "op<<(streamable_range)" +== +"op<<(streamable_range)" + + + + + ::Catch::Detail::stringify(stringmaker_range{}) == "stringmaker(streamable_range)" + + + "stringmaker(streamable_range)" +== +"stringmaker(streamable_range)" + + + + + ::Catch::Detail::stringify(just_range{}) == "{ 1, 2, 3, 4 }" + + + "{ 1, 2, 3, 4 }" == "{ 1, 2, 3, 4 }" + + + + + ::Catch::Detail::stringify(disabled_range{}) == "{ !!! }" + + + "{ !!! }" == "{ !!! }" + + + + + + + + ::Catch::Detail::stringify( item ) == "StringMaker<has_maker>" + + + "StringMaker<has_maker>" +== +"StringMaker<has_maker>" + + + + + + + + ::Catch::Detail::stringify( item ) == "StringMaker<has_maker_and_operator>" + + + "StringMaker<has_maker_and_operator>" +== +"StringMaker<has_maker_and_operator>" + + + + + + + + ::Catch::Detail::stringify(item) == "{ !!! }" + + + "{ !!! }" == "{ !!! }" + + + + + + + + ::Catch::Detail::stringify( item ) == "operator<<( has_operator )" + + + "operator<<( has_operator )" +== +"operator<<( has_operator )" + + + + + + + + ::Catch::Detail::stringify( item ) == "operator<<( has_template_operator )" + + + "operator<<( has_template_operator )" +== +"operator<<( has_template_operator )" + + + + + + + + ::Catch::Detail::stringify( v ) == "{ StringMaker<has_maker> }" + + + "{ StringMaker<has_maker> }" +== +"{ StringMaker<has_maker> }" + + + + + + + + ::Catch::Detail::stringify( v ) == "{ StringMaker<has_maker_and_operator> }" + + + "{ StringMaker<has_maker_and_operator> }" +== +"{ StringMaker<has_maker_and_operator> }" + + + + + + + + ::Catch::Detail::stringify( v ) == "{ operator<<( has_operator ) }" + + + "{ operator<<( has_operator ) }" +== +"{ operator<<( has_operator ) }" + + + + + + + Why would you throw a std::string? + + + + + + + result == "\"wide load\"" + + + ""wide load"" == ""wide load"" + + + + + + + + result == "\"wide load\"" + + + ""wide load"" == ""wide load"" + + + + + + + + result == "\"wide load\"" + + + ""wide load"" == ""wide load"" + + + + + + + + result == "\"wide load\"" + + + ""wide load"" == ""wide load"" + + + + + + + + ::Catch::Detail::stringify(e0) == "E2/V0" + + + "E2/V0" == "E2/V0" + + + + + ::Catch::Detail::stringify(e1) == "E2/V1" + + + "E2/V1" == "E2/V1" + + + + + ::Catch::Detail::stringify(e3) == "Unknown enum value 10" + + + "Unknown enum value 10" +== +"Unknown enum value 10" + + + + + + + + ::Catch::Detail::stringify(e0) == "0" + + + "0" == "0" + + + + + ::Catch::Detail::stringify(e1) == "1" + + + "1" == "1" + + + + + + + + ::Catch::Detail::stringify(e0) == "E2{0}" + + + "E2{0}" == "E2{0}" + + + + + ::Catch::Detail::stringify(e1) == "E2{1}" + + + "E2{1}" == "E2{1}" + + + + + + + + ::Catch::Detail::stringify(e0) == "0" + + + "0" == "0" + + + + + ::Catch::Detail::stringify(e1) == "1" + + + "1" == "1" + + + + + + + + "{ }" == ::Catch::Detail::stringify(type{}) + + + "{ }" == "{ }" + + + + + "{ }" == ::Catch::Detail::stringify(value) + + + "{ }" == "{ }" + + + + + + + + "1.2f" == ::Catch::Detail::stringify(float(1.2)) + + + "1.2f" == "1.2f" + + + + + "{ 1.2f, 0 }" == ::Catch::Detail::stringify(type{1.2f,0}) + + + "{ 1.2f, 0 }" == "{ 1.2f, 0 }" + + + + + + + + "{ 0 }" == ::Catch::Detail::stringify(type{0}) + + + "{ 0 }" == "{ 0 }" + + + + + + + + "{ 0, 42, \"Catch me\" }" == ::Catch::Detail::stringify(value) + + + "{ 0, 42, "Catch me" }" +== +"{ 0, 42, "Catch me" }" + + + + + + + + "{ \"hello\", \"world\" }" == ::Catch::Detail::stringify(type{"hello","world"}) + + + "{ "hello", "world" }" +== +"{ "hello", "world" }" + + + + + + + + "{ { 42 }, { }, 1.2f }" == ::Catch::Detail::stringify(value) + + + "{ { 42 }, { }, 1.2f }" +== +"{ { 42 }, { }, 1.2f }" + + + + + + + + ::Catch::Detail::stringify(v) == "{ }" + + + "{ }" == "{ }" + + + + + ::Catch::Detail::stringify(v) == "{ { \"hello\" }, { \"world\" } }" + + + "{ { "hello" }, { "world" } }" +== +"{ { "hello" }, { "world" } }" + + + + + + + + ::Catch::Detail::stringify(bools) == "{ }" + + + "{ }" == "{ }" + + + + + ::Catch::Detail::stringify(bools) == "{ true }" + + + "{ true }" == "{ true }" + + + + + ::Catch::Detail::stringify(bools) == "{ true, false }" + + + "{ true, false }" == "{ true, false }" + + + + + + + + ::Catch::Detail::stringify(vv) == "{ }" + + + "{ }" == "{ }" + + + + + ::Catch::Detail::stringify(vv) == "{ 42 }" + + + "{ 42 }" == "{ 42 }" + + + + + ::Catch::Detail::stringify(vv) == "{ 42, 250 }" + + + "{ 42, 250 }" == "{ 42, 250 }" + + + + + + + + ::Catch::Detail::stringify(vv) == "{ }" + + + "{ }" == "{ }" + + + + + ::Catch::Detail::stringify(vv) == "{ 42 }" + + + "{ 42 }" == "{ 42 }" + + + + + ::Catch::Detail::stringify(vv) == "{ 42, 250 }" + + + "{ 42, 250 }" == "{ 42, 250 }" + + + + + + + + ::Catch::Detail::stringify(vv) == "{ }" + + + "{ }" == "{ }" + + + + + ::Catch::Detail::stringify(vv) == "{ \"hello\" }" + + + "{ "hello" }" == "{ "hello" }" + + + + + ::Catch::Detail::stringify(vv) == "{ \"hello\", \"world\" }" + + + "{ "hello", "world" }" +== +"{ "hello", "world" }" + + + + + + + + v.size() == 5 + + + 5 == 5 + + + + + v.capacity() >= 5 + + + 5 >= 5 + + +
+ + + v.size() == 10 + + + 10 == 10 + + + + + v.capacity() >= 10 + + + 10 >= 10 + + + +
+ + + v.size() == 5 + + + 5 == 5 + + + + + v.capacity() >= 5 + + + 5 >= 5 + + +
+ + + v.size() == 0 + + + 0 == 0 + + + + + v.capacity() >= 5 + + + 5 >= 5 + + +
+ + + v.capacity() == 0 + + + 0 == 0 + + + +
+ +
+ + + v.size() == 5 + + + 5 == 5 + + + + + v.capacity() >= 5 + + + 5 >= 5 + + +
+ + + v.size() == 5 + + + 5 == 5 + + + + + v.capacity() >= 10 + + + 10 >= 10 + + + +
+ + + v.size() == 5 + + + 5 == 5 + + + + + v.capacity() >= 5 + + + 5 >= 5 + + +
+ + + v.size() == 5 + + + 5 == 5 + + + + + v.capacity() >= 5 + + + 5 >= 5 + + + +
+ +
+ +
+ +
+
+ +
+ +
+ +
+ +
diff --git a/src/third_party/cppcodec/test/catch/projects/SelfTest/CompileTimePerfTests/10.tests.cpp b/src/third_party/cppcodec/test/catch/projects/SelfTest/CompileTimePerfTests/10.tests.cpp new file mode 100644 index 0000000000..01cd072d9f --- /dev/null +++ b/src/third_party/cppcodec/test/catch/projects/SelfTest/CompileTimePerfTests/10.tests.cpp @@ -0,0 +1,13 @@ +// Include set of usage tests multiple times - for compile-time performance testing +// (do not run) + +#include "All.tests.cpp" +#include "All.tests.cpp" +#include "All.tests.cpp" +#include "All.tests.cpp" +#include "All.tests.cpp" +#include "All.tests.cpp" +#include "All.tests.cpp" +#include "All.tests.cpp" +#include "All.tests.cpp" +#include "All.tests.cpp" diff --git a/src/third_party/cppcodec/test/catch/projects/SelfTest/CompileTimePerfTests/100.tests.cpp b/src/third_party/cppcodec/test/catch/projects/SelfTest/CompileTimePerfTests/100.tests.cpp new file mode 100644 index 0000000000..e03ca83828 --- /dev/null +++ b/src/third_party/cppcodec/test/catch/projects/SelfTest/CompileTimePerfTests/100.tests.cpp @@ -0,0 +1,13 @@ +// Include set of usage tests multiple times - for compile-time performance testing +// (do not run) + +#include "10.tests.cpp" +#include "10.tests.cpp" +#include "10.tests.cpp" +#include "10.tests.cpp" +#include "10.tests.cpp" +#include "10.tests.cpp" +#include "10.tests.cpp" +#include "10.tests.cpp" +#include "10.tests.cpp" +#include "10.tests.cpp" diff --git a/src/third_party/cppcodec/test/catch/projects/SelfTest/CompileTimePerfTests/All.tests.cpp b/src/third_party/cppcodec/test/catch/projects/SelfTest/CompileTimePerfTests/All.tests.cpp new file mode 100644 index 0000000000..2b6a102914 --- /dev/null +++ b/src/third_party/cppcodec/test/catch/projects/SelfTest/CompileTimePerfTests/All.tests.cpp @@ -0,0 +1,15 @@ +// include set of usage tests into one file for compiler performance test purposes +// This whole file can now be included multiple times in 10.tests.cpp, and *that* +// file included multiple times (in 100.tests.cpp) + +// Note that the intention is only for these files to be compiled. They will +// fail at runtime due to the re-user of test case names + +#include "../UsageTests/Approx.tests.cpp" +#include "../UsageTests/BDD.tests.cpp" +#include "../UsageTests/Class.tests.cpp" +#include "../UsageTests/Compilation.tests.cpp" +#include "../UsageTests/Condition.tests.cpp" +#include "../UsageTests/Exception.tests.cpp" +#include "../UsageTests/Matchers.tests.cpp" +#include "../UsageTests/Misc.tests.cpp" diff --git a/src/third_party/cppcodec/test/catch/projects/SelfTest/IntrospectiveTests/CmdLine.tests.cpp b/src/third_party/cppcodec/test/catch/projects/SelfTest/IntrospectiveTests/CmdLine.tests.cpp new file mode 100644 index 0000000000..cb635eade9 --- /dev/null +++ b/src/third_party/cppcodec/test/catch/projects/SelfTest/IntrospectiveTests/CmdLine.tests.cpp @@ -0,0 +1,459 @@ +/* + * Created by Phil on 13/5/2013. + * Copyright 2014 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) + */ + +#include "catch.hpp" +#include "internal/catch_test_spec_parser.h" +#include "internal/catch_config.hpp" +#include "internal/catch_commandline.h" + +#ifdef __clang__ +# pragma clang diagnostic ignored "-Wc++98-compat" +#endif + +inline Catch::TestCase fakeTestCase(const char* name, const char* desc = "") { return Catch::makeTestCase(nullptr, "", { name, desc }, CATCH_INTERNAL_LINEINFO); } + +TEST_CASE( "Parse test names and tags" ) { + + using Catch::parseTestSpec; + using Catch::TestSpec; + + Catch::TestCase tcA = fakeTestCase( "a" ); + Catch::TestCase tcB = fakeTestCase( "b", "[one][x]" ); + Catch::TestCase tcC = fakeTestCase( "longer name with spaces", "[two][three][.][x]" ); + Catch::TestCase tcD = fakeTestCase( "zlonger name with spacesz" ); + + SECTION( "Empty test spec should have no filters" ) { + TestSpec spec; + CHECK( spec.hasFilters() == false ); + CHECK( spec.matches( tcA ) == false ); + CHECK( spec.matches( tcB ) == false ); + } + + SECTION( "Test spec from empty string should have no filters" ) { + TestSpec spec = parseTestSpec( "" ); + CHECK( spec.hasFilters() == false ); + CHECK( spec.matches(tcA ) == false ); + CHECK( spec.matches( tcB ) == false ); + } + + SECTION( "Test spec from just a comma should have no filters" ) { + TestSpec spec = parseTestSpec( "," ); + CHECK( spec.hasFilters() == false ); + CHECK( spec.matches( tcA ) == false ); + CHECK( spec.matches( tcB ) == false ); + } + + SECTION( "Test spec from name should have one filter" ) { + TestSpec spec = parseTestSpec( "b" ); + CHECK( spec.hasFilters() == true ); + CHECK( spec.matches( tcA ) == false ); + CHECK( spec.matches( tcB ) == true ); + } + + SECTION( "Test spec from quoted name should have one filter" ) { + TestSpec spec = parseTestSpec( "\"b\"" ); + CHECK( spec.hasFilters() == true ); + CHECK( spec.matches( tcA ) == false ); + CHECK( spec.matches( tcB ) == true ); + } + + SECTION( "Test spec from name should have one filter" ) { + TestSpec spec = parseTestSpec( "b" ); + CHECK( spec.hasFilters() == true ); + CHECK( spec.matches( tcA ) == false ); + CHECK( spec.matches( tcB ) == true ); + CHECK( spec.matches( tcC ) == false ); + } + + SECTION( "Wildcard at the start" ) { + TestSpec spec = parseTestSpec( "*spaces" ); + CHECK( spec.hasFilters() == true ); + CHECK( spec.matches( tcA ) == false ); + CHECK( spec.matches( tcB ) == false ); + CHECK( spec.matches( tcC ) == true ); + CHECK( spec.matches( tcD ) == false ); + CHECK( parseTestSpec( "*a" ).matches( tcA ) == true ); + } + SECTION( "Wildcard at the end" ) { + TestSpec spec = parseTestSpec( "long*" ); + CHECK( spec.hasFilters() == true ); + CHECK( spec.matches( tcA ) == false ); + CHECK( spec.matches( tcB ) == false ); + CHECK( spec.matches( tcC ) == true ); + CHECK( spec.matches( tcD ) == false ); + CHECK( parseTestSpec( "a*" ).matches( tcA ) == true ); + } + SECTION( "Wildcard at both ends" ) { + TestSpec spec = parseTestSpec( "*name*" ); + CHECK( spec.hasFilters() == true ); + CHECK( spec.matches( tcA ) == false ); + CHECK( spec.matches( tcB ) == false ); + CHECK( spec.matches( tcC ) == true ); + CHECK( spec.matches( tcD ) == true ); + CHECK( parseTestSpec( "*a*" ).matches( tcA ) == true ); + } + SECTION( "Redundant wildcard at the start" ) { + TestSpec spec = parseTestSpec( "*a" ); + CHECK( spec.hasFilters() == true ); + CHECK( spec.matches( tcA ) == true ); + CHECK( spec.matches( tcB ) == false ); + } + SECTION( "Redundant wildcard at the end" ) { + TestSpec spec = parseTestSpec( "a*" ); + CHECK( spec.hasFilters() == true ); + CHECK( spec.matches( tcA ) == true ); + CHECK( spec.matches( tcB ) == false ); + } + SECTION( "Redundant wildcard at both ends" ) { + TestSpec spec = parseTestSpec( "*a*" ); + CHECK( spec.hasFilters() == true ); + CHECK( spec.matches( tcA ) == true ); + CHECK( spec.matches( tcB ) == false ); + } + SECTION( "Wildcard at both ends, redundant at start" ) { + TestSpec spec = parseTestSpec( "*longer*" ); + CHECK( spec.hasFilters() == true ); + CHECK( spec.matches( tcA ) == false ); + CHECK( spec.matches( tcB ) == false ); + CHECK( spec.matches( tcC ) == true ); + CHECK( spec.matches( tcD ) == true ); + } + SECTION( "Just wildcard" ) { + TestSpec spec = parseTestSpec( "*" ); + CHECK( spec.hasFilters() == true ); + CHECK( spec.matches( tcA ) == true ); + CHECK( spec.matches( tcB ) == true ); + CHECK( spec.matches( tcC ) == true ); + CHECK( spec.matches( tcD ) == true ); + } + + SECTION( "Single tag" ) { + TestSpec spec = parseTestSpec( "[one]" ); + CHECK( spec.hasFilters() == true ); + CHECK( spec.matches( tcA ) == false ); + CHECK( spec.matches( tcB ) == true ); + CHECK( spec.matches( tcC ) == false ); + } + SECTION( "Single tag, two matches" ) { + TestSpec spec = parseTestSpec( "[x]" ); + CHECK( spec.hasFilters() == true ); + CHECK( spec.matches( tcA ) == false ); + CHECK( spec.matches( tcB ) == true ); + CHECK( spec.matches( tcC ) == true ); + } + SECTION( "Two tags" ) { + TestSpec spec = parseTestSpec( "[two][x]" ); + CHECK( spec.hasFilters() == true ); + CHECK( spec.matches( tcA ) == false ); + CHECK( spec.matches( tcB ) == false ); + CHECK( spec.matches( tcC ) == true ); + } + SECTION( "Two tags, spare separated" ) { + TestSpec spec = parseTestSpec( "[two] [x]" ); + CHECK( spec.hasFilters() == true ); + CHECK( spec.matches( tcA ) == false ); + CHECK( spec.matches( tcB ) == false ); + CHECK( spec.matches( tcC ) == true ); + } + SECTION( "Wildcarded name and tag" ) { + TestSpec spec = parseTestSpec( "*name*[x]" ); + CHECK( spec.hasFilters() == true ); + CHECK( spec.matches( tcA ) == false ); + CHECK( spec.matches( tcB ) == false ); + CHECK( spec.matches( tcC ) == true ); + CHECK( spec.matches( tcD ) == false ); + } + SECTION( "Single tag exclusion" ) { + TestSpec spec = parseTestSpec( "~[one]" ); + CHECK( spec.hasFilters() == true ); + CHECK( spec.matches( tcA ) == true ); + CHECK( spec.matches( tcB ) == false ); + CHECK( spec.matches( tcC ) == true ); + } + SECTION( "One tag exclusion and one tag inclusion" ) { + TestSpec spec = parseTestSpec( "~[two][x]" ); + CHECK( spec.hasFilters() == true ); + CHECK( spec.matches( tcA ) == false ); + CHECK( spec.matches( tcB ) == true ); + CHECK( spec.matches( tcC ) == false ); + } + SECTION( "One tag exclusion and one wldcarded name inclusion" ) { + TestSpec spec = parseTestSpec( "~[two]*name*" ); + CHECK( spec.hasFilters() == true ); + CHECK( spec.matches( tcA ) == false ); + CHECK( spec.matches( tcB ) == false ); + CHECK( spec.matches( tcC ) == false ); + CHECK( spec.matches( tcD ) == true ); + } + SECTION( "One tag exclusion, using exclude:, and one wldcarded name inclusion" ) { + TestSpec spec = parseTestSpec( "exclude:[two]*name*" ); + CHECK( spec.hasFilters() == true ); + CHECK( spec.matches( tcA ) == false ); + CHECK( spec.matches( tcB ) == false ); + CHECK( spec.matches( tcC ) == false ); + CHECK( spec.matches( tcD ) == true ); + } + SECTION( "name exclusion" ) { + TestSpec spec = parseTestSpec( "~b" ); + CHECK( spec.hasFilters() == true ); + CHECK( spec.matches( tcA ) == true ); + CHECK( spec.matches( tcB ) == false ); + CHECK( spec.matches( tcC ) == true ); + CHECK( spec.matches( tcD ) == true ); + } + SECTION( "wildcarded name exclusion" ) { + TestSpec spec = parseTestSpec( "~*name*" ); + CHECK( spec.hasFilters() == true ); + CHECK( spec.matches( tcA ) == true ); + CHECK( spec.matches( tcB ) == true ); + CHECK( spec.matches( tcC ) == false ); + CHECK( spec.matches( tcD ) == false ); + } + SECTION( "wildcarded name exclusion with tag inclusion" ) { + TestSpec spec = parseTestSpec( "~*name*,[three]" ); + CHECK( spec.hasFilters() == true ); + CHECK( spec.matches( tcA ) == true ); + CHECK( spec.matches( tcB ) == true ); + CHECK( spec.matches( tcC ) == true ); + CHECK( spec.matches( tcD ) == false ); + } + SECTION( "wildcarded name exclusion, using exclude:, with tag inclusion" ) { + TestSpec spec = parseTestSpec( "exclude:*name*,[three]" ); + CHECK( spec.hasFilters() == true ); + CHECK( spec.matches( tcA ) == true ); + CHECK( spec.matches( tcB ) == true ); + CHECK( spec.matches( tcC ) == true ); + CHECK( spec.matches( tcD ) == false ); + } + SECTION( "two wildcarded names" ) { + TestSpec spec = parseTestSpec( "\"longer*\"\"*spaces\"" ); + CHECK( spec.hasFilters() == true ); + CHECK( spec.matches( tcA ) == false ); + CHECK( spec.matches( tcB ) == false ); + CHECK( spec.matches( tcC ) == true ); + CHECK( spec.matches( tcD ) == false ); + } + SECTION( "empty tag" ) { + TestSpec spec = parseTestSpec( "[]" ); + CHECK( spec.hasFilters() == false ); + CHECK( spec.matches( tcA ) == false ); + CHECK( spec.matches( tcB ) == false ); + CHECK( spec.matches( tcC ) == false ); + CHECK( spec.matches( tcD ) == false ); + } + SECTION( "empty quoted name" ) { + TestSpec spec = parseTestSpec( "\"\"" ); + CHECK( spec.hasFilters() == false ); + CHECK( spec.matches( tcA ) == false ); + CHECK( spec.matches( tcB ) == false ); + CHECK( spec.matches( tcC ) == false ); + CHECK( spec.matches( tcD ) == false ); + } + SECTION( "quoted string followed by tag exclusion" ) { + TestSpec spec = parseTestSpec( "\"*name*\"~[.]" ); + CHECK( spec.hasFilters() == true ); + CHECK( spec.matches( tcA ) == false ); + CHECK( spec.matches( tcB ) == false ); + CHECK( spec.matches( tcC ) == false ); + CHECK( spec.matches( tcD ) == true ); + } + +} + +TEST_CASE( "Process can be configured on command line", "[config][command-line]" ) { + +#ifndef CATCH_CONFIG_DISABLE_MATCHERS + using namespace Catch::Matchers; +#endif + + Catch::ConfigData config; + auto cli = Catch::makeCommandLineParser(config); + + SECTION("empty args don't cause a crash") { + auto result = cli.parse({""}); + CHECK(result); + CHECK(config.processName == ""); + } + + + SECTION("default - no arguments") { + auto result = cli.parse({"test"}); + CHECK(result); + CHECK(config.processName == "test"); + CHECK(config.shouldDebugBreak == false); + CHECK(config.abortAfter == -1); + CHECK(config.noThrow == false); + CHECK(config.reporterName == "console"); + + Catch::Config cfg(config); + CHECK_FALSE(cfg.hasTestFilters()); + } + + SECTION("test lists") { + SECTION("Specify one test case using") { + auto result = cli.parse({"test", "test1"}); + CHECK(result); + + Catch::Config cfg(config); + REQUIRE(cfg.hasTestFilters()); + REQUIRE(cfg.testSpec().matches(fakeTestCase("notIncluded")) == false); + REQUIRE(cfg.testSpec().matches(fakeTestCase("test1"))); + } + SECTION("Specify one test case exclusion using exclude:") { + auto result = cli.parse({"test", "exclude:test1"}); + CHECK(result); + + Catch::Config cfg(config); + REQUIRE(cfg.hasTestFilters()); + REQUIRE(cfg.testSpec().matches(fakeTestCase("test1")) == false); + REQUIRE(cfg.testSpec().matches(fakeTestCase("alwaysIncluded"))); + } + + SECTION("Specify one test case exclusion using ~") { + auto result = cli.parse({"test", "~test1"}); + CHECK(result); + + Catch::Config cfg(config); + REQUIRE(cfg.hasTestFilters()); + REQUIRE(cfg.testSpec().matches(fakeTestCase("test1")) == false); + REQUIRE(cfg.testSpec().matches(fakeTestCase("alwaysIncluded"))); + } + + } + + SECTION("reporter") { + SECTION("-r/console") { + CHECK(cli.parse({"test", "-r", "console"})); + + REQUIRE(config.reporterName == "console"); + } + SECTION("-r/xml") { + CHECK(cli.parse({"test", "-r", "xml"})); + + REQUIRE(config.reporterName == "xml"); + } + SECTION("--reporter/junit") { + CHECK(cli.parse({"test", "--reporter", "junit"})); + + REQUIRE(config.reporterName == "junit"); + } + SECTION("Only one reporter is accepted") { + REQUIRE_FALSE(cli.parse({ "test", "-r", "xml", "-r", "junit" })); + } + } + + + SECTION("debugger") { + SECTION("-b") { + CHECK(cli.parse({"test", "-b"})); + + REQUIRE(config.shouldDebugBreak == true); + } + SECTION("--break") { + CHECK(cli.parse({"test", "--break"})); + + REQUIRE(config.shouldDebugBreak); + } + } + + + SECTION("abort") { + SECTION("-a aborts after first failure") { + CHECK(cli.parse({"test", "-a"})); + + REQUIRE(config.abortAfter == 1); + } + SECTION("-x 2 aborts after two failures") { + CHECK(cli.parse({"test", "-x", "2"})); + + REQUIRE(config.abortAfter == 2); + } + SECTION("-x must be numeric") { + auto result = cli.parse({"test", "-x", "oops"}); + CHECK(!result); + +#ifndef CATCH_CONFIG_DISABLE_MATCHERS + REQUIRE_THAT(result.errorMessage(), Contains("convert") && Contains("oops")); +#endif + } + } + + SECTION("nothrow") { + SECTION("-e") { + CHECK(cli.parse({"test", "-e"})); + + REQUIRE(config.noThrow); + } + SECTION("--nothrow") { + CHECK(cli.parse({"test", "--nothrow"})); + + REQUIRE(config.noThrow); + } + } + + SECTION("output filename") { + SECTION("-o filename") { + CHECK(cli.parse({"test", "-o", "filename.ext"})); + + REQUIRE(config.outputFilename == "filename.ext"); + } + SECTION("--out") { + CHECK(cli.parse({"test", "--out", "filename.ext"})); + + REQUIRE(config.outputFilename == "filename.ext"); + } + } + + SECTION("combinations") { + SECTION("Single character flags can be combined") { + CHECK(cli.parse({"test", "-abe"})); + + CHECK(config.abortAfter == 1); + CHECK(config.shouldDebugBreak); + CHECK(config.noThrow == true); + } + } + + + SECTION( "use-colour") { + + using Catch::UseColour; + + SECTION( "without option" ) { + CHECK(cli.parse({"test"})); + + REQUIRE( config.useColour == UseColour::Auto ); + } + + SECTION( "auto" ) { + CHECK(cli.parse({"test", "--use-colour", "auto"})); + + REQUIRE( config.useColour == UseColour::Auto ); + } + + SECTION( "yes" ) { + CHECK(cli.parse({"test", "--use-colour", "yes"})); + + REQUIRE( config.useColour == UseColour::Yes ); + } + + SECTION( "no" ) { + CHECK(cli.parse({"test", "--use-colour", "no"})); + + REQUIRE( config.useColour == UseColour::No ); + } + + SECTION( "error" ) { + auto result = cli.parse({"test", "--use-colour", "wrong"}); + CHECK( !result ); +#ifndef CATCH_CONFIG_DISABLE_MATCHERS + CHECK_THAT( result.errorMessage(), Contains( "colour mode must be one of" ) ); +#endif + } + } +} diff --git a/src/third_party/cppcodec/test/catch/projects/SelfTest/IntrospectiveTests/PartTracker.tests.cpp b/src/third_party/cppcodec/test/catch/projects/SelfTest/IntrospectiveTests/PartTracker.tests.cpp new file mode 100644 index 0000000000..7e7f14b457 --- /dev/null +++ b/src/third_party/cppcodec/test/catch/projects/SelfTest/IntrospectiveTests/PartTracker.tests.cpp @@ -0,0 +1,326 @@ +/* + * Created by Phil on 1/10/2015. + * Copyright 2015 Two Blue Cubes Ltd + * + * 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) + */ +#include "internal/catch_suppress_warnings.h" +#include "internal/catch_test_case_tracker.h" + + +namespace Catch +{ + class LocalContext { + + public: + TrackerContext& operator()() const { + return TrackerContext::instance(); + } + }; + +} // namespace Catch + +// ------------------- + +#include "catch.hpp" + +using namespace Catch; + +namespace { +Catch::TestCaseTracking::NameAndLocation makeNAL( std::string const& name ) { + return Catch::TestCaseTracking::NameAndLocation( name, Catch::SourceLineInfo("",0) ); +} +} + +TEST_CASE( "Tracker" ) { + + TrackerContext ctx; + ctx.startRun(); + ctx.startCycle(); + + + ITracker& testCase = SectionTracker::acquire( ctx, makeNAL( "Testcase" ) ); + REQUIRE( testCase.isOpen() ); + + ITracker& s1 = SectionTracker::acquire( ctx, makeNAL( "S1" ) ); + REQUIRE( s1.isOpen() ); + + SECTION( "successfully close one section" ) { + s1.close(); + REQUIRE( s1.isSuccessfullyCompleted() ); + REQUIRE( testCase.isComplete() == false ); + + testCase.close(); + REQUIRE( ctx.completedCycle() ); + REQUIRE( testCase.isSuccessfullyCompleted() ); + } + + SECTION( "fail one section" ) { + s1.fail(); + REQUIRE( s1.isComplete() ); + REQUIRE( s1.isSuccessfullyCompleted() == false ); + REQUIRE( testCase.isComplete() == false ); + + testCase.close(); + REQUIRE( ctx.completedCycle() ); + REQUIRE( testCase.isSuccessfullyCompleted() == false ); + + SECTION( "re-enter after failed section" ) { + ctx.startCycle(); + ITracker& testCase2 = SectionTracker::acquire( ctx, makeNAL( "Testcase" ) ); + REQUIRE( testCase2.isOpen() ); + + ITracker& s1b = SectionTracker::acquire( ctx, makeNAL( "S1" ) ); + REQUIRE( s1b.isOpen() == false ); + + testCase2.close(); + REQUIRE( ctx.completedCycle() ); + REQUIRE( testCase.isComplete() ); + REQUIRE( testCase.isSuccessfullyCompleted() ); + } + SECTION( "re-enter after failed section and find next section" ) { + ctx.startCycle(); + ITracker& testCase2 = SectionTracker::acquire( ctx, makeNAL( "Testcase" ) ); + REQUIRE( testCase2.isOpen() ); + + ITracker& s1b = SectionTracker::acquire( ctx, makeNAL( "S1" ) ); + REQUIRE( s1b.isOpen() == false ); + + ITracker& s2 = SectionTracker::acquire( ctx, makeNAL( "S2" ) ); + REQUIRE( s2.isOpen() ); + + s2.close(); + REQUIRE( ctx.completedCycle() ); + + testCase2.close(); + REQUIRE( testCase.isComplete() ); + REQUIRE( testCase.isSuccessfullyCompleted() ); + } + } + + SECTION( "successfully close one section, then find another" ) { + s1.close(); + + ITracker& s2 = SectionTracker::acquire( ctx, makeNAL( "S2" ) ); + REQUIRE( s2.isOpen() == false ); + + testCase.close(); + REQUIRE( testCase.isComplete() == false ); + + SECTION( "Re-enter - skips S1 and enters S2" ) { + ctx.startCycle(); + ITracker& testCase2 = SectionTracker::acquire( ctx, makeNAL( "Testcase" ) ); + REQUIRE( testCase2.isOpen() ); + + ITracker& s1b = SectionTracker::acquire( ctx, makeNAL( "S1" ) ); + REQUIRE( s1b.isOpen() == false ); + + ITracker& s2b = SectionTracker::acquire( ctx, makeNAL( "S2" ) ); + REQUIRE( s2b.isOpen() ); + + REQUIRE( ctx.completedCycle() == false ); + + SECTION ("Successfully close S2") { + s2b.close(); + REQUIRE( ctx.completedCycle() ); + + REQUIRE( s2b.isSuccessfullyCompleted() ); + REQUIRE( testCase2.isComplete() == false ); + + testCase2.close(); + REQUIRE( testCase2.isSuccessfullyCompleted() ); + } + SECTION ("fail S2") { + s2b.fail(); + REQUIRE( ctx.completedCycle() ); + + REQUIRE( s2b.isComplete() ); + REQUIRE( s2b.isSuccessfullyCompleted() == false ); + + testCase2.close(); + REQUIRE( testCase2.isSuccessfullyCompleted() == false ); + + // Need a final cycle + ctx.startCycle(); + ITracker& testCase3 = SectionTracker::acquire( ctx, makeNAL( "Testcase" ) ); + REQUIRE( testCase3.isOpen() ); + + ITracker& s1c = SectionTracker::acquire( ctx, makeNAL( "S1" ) ); + REQUIRE( s1c.isOpen() == false ); + + ITracker& s2c = SectionTracker::acquire( ctx, makeNAL( "S2" ) ); + REQUIRE( s2c.isOpen() == false ); + + testCase3.close(); + REQUIRE( testCase3.isSuccessfullyCompleted() ); + } + } + } + + SECTION( "open a nested section" ) { + ITracker& s2 = SectionTracker::acquire( ctx, makeNAL( "S2" ) ); + REQUIRE( s2.isOpen() ); + + s2.close(); + REQUIRE( s2.isComplete() ); + REQUIRE( s1.isComplete() == false ); + + s1.close(); + REQUIRE( s1.isComplete() ); + REQUIRE( testCase.isComplete() == false ); + + testCase.close(); + REQUIRE( testCase.isComplete() ); + } + + SECTION( "start a generator" ) { + IndexTracker& g1 = IndexTracker::acquire( ctx, makeNAL( "G1" ), 2 ); + REQUIRE( g1.isOpen() ); + REQUIRE( g1.index() == 0 ); + + REQUIRE( g1.isComplete() == false ); + REQUIRE( s1.isComplete() == false ); + + SECTION( "close outer section" ) + { + s1.close(); + REQUIRE( s1.isComplete() == false ); + testCase.close(); + REQUIRE( testCase.isSuccessfullyCompleted() == false ); + + SECTION( "Re-enter for second generation" ) { + ctx.startCycle(); + ITracker& testCase2 = SectionTracker::acquire( ctx, makeNAL( "Testcase" ) ); + REQUIRE( testCase2.isOpen() ); + + ITracker& s1b = SectionTracker::acquire( ctx, makeNAL( "S1" ) ); + REQUIRE( s1b.isOpen() ); + + + IndexTracker& g1b = IndexTracker::acquire( ctx, makeNAL( "G1" ), 2 ); + REQUIRE( g1b.isOpen() ); + REQUIRE( g1b.index() == 1 ); + + REQUIRE( s1.isComplete() == false ); + + s1b.close(); + REQUIRE( s1b.isComplete() ); + REQUIRE( g1b.isComplete() ); + testCase2.close(); + REQUIRE( testCase2.isComplete() ); + } + } + SECTION( "Start a new inner section" ) { + ITracker& s2 = SectionTracker::acquire( ctx, makeNAL( "S2" ) ); + REQUIRE( s2.isOpen() ); + + s2.close(); + REQUIRE( s2.isComplete() ); + + s1.close(); + REQUIRE( s1.isComplete() == false ); + + testCase.close(); + REQUIRE( testCase.isComplete() == false ); + + SECTION( "Re-enter for second generation" ) { + ctx.startCycle(); + ITracker& testCase2 = SectionTracker::acquire( ctx, makeNAL( "Testcase" ) ); + REQUIRE( testCase2.isOpen() ); + + ITracker& s1b = SectionTracker::acquire( ctx, makeNAL( "S1" ) ); + REQUIRE( s1b.isOpen() ); + + // generator - next value + IndexTracker& g1b = IndexTracker::acquire( ctx, makeNAL( "G1" ), 2 ); + REQUIRE( g1b.isOpen() ); + REQUIRE( g1b.index() == 1 ); + + // inner section again + ITracker& s2b = SectionTracker::acquire( ctx, makeNAL( "S2" ) ); + REQUIRE( s2b.isOpen() ); + + s2b.close(); + REQUIRE( s2b.isComplete() ); + + s1b.close(); + REQUIRE( g1b.isComplete() ); + REQUIRE( s1b.isComplete() ); + + testCase2.close(); + REQUIRE( testCase2.isComplete() ); + } + } + + SECTION( "Fail an inner section" ) { + ITracker& s2 = SectionTracker::acquire( ctx, makeNAL( "S2" ) ); + REQUIRE( s2.isOpen() ); + + s2.fail(); + REQUIRE( s2.isComplete() ); + REQUIRE( s2.isSuccessfullyCompleted() == false ); + + s1.close(); + REQUIRE( s1.isComplete() == false ); + + testCase.close(); + REQUIRE( testCase.isComplete() == false ); + + SECTION( "Re-enter for second generation" ) { + ctx.startCycle(); + ITracker& testCase2 = SectionTracker::acquire( ctx, makeNAL( "Testcase" ) ); + REQUIRE( testCase2.isOpen() ); + + ITracker& s1b = SectionTracker::acquire( ctx, makeNAL( "S1" ) ); + REQUIRE( s1b.isOpen() ); + + // generator - still same value + IndexTracker& g1b = IndexTracker::acquire( ctx, makeNAL( "G1" ), 2 ); + REQUIRE( g1b.isOpen() ); + REQUIRE( g1b.index() == 0 ); + + // inner section again - this time won't open + ITracker& s2b = SectionTracker::acquire( ctx, makeNAL( "S2" ) ); + REQUIRE( s2b.isOpen() == false ); + + s1b.close(); + REQUIRE( g1b.isComplete() == false ); + REQUIRE( s1b.isComplete() == false ); + + testCase2.close(); + REQUIRE( testCase2.isComplete() == false ); + + // Another cycle - now should complete + ctx.startCycle(); + ITracker& testCase3 = SectionTracker::acquire( ctx, makeNAL( "Testcase" ) ); + REQUIRE( testCase3.isOpen() ); + + ITracker& s1c = SectionTracker::acquire( ctx, makeNAL( "S1" ) ); + REQUIRE( s1c.isOpen() ); + + // generator - now next value + IndexTracker& g1c = IndexTracker::acquire( ctx, makeNAL( "G1" ), 2 ); + REQUIRE( g1c.isOpen() ); + REQUIRE( g1c.index() == 1 ); + + // inner section - now should open again + ITracker& s2c = SectionTracker::acquire( ctx, makeNAL( "S2" ) ); + REQUIRE( s2c.isOpen() ); + + s2c.close(); + REQUIRE( s2c.isComplete() ); + + s1c.close(); + REQUIRE( g1c.isComplete() ); + REQUIRE( s1c.isComplete() ); + + testCase3.close(); + REQUIRE( testCase3.isComplete() ); + } + } + // !TBD" + // nested generator + // two sections within a generator + } +} diff --git a/src/third_party/cppcodec/test/catch/projects/SelfTest/IntrospectiveTests/String.tests.cpp b/src/third_party/cppcodec/test/catch/projects/SelfTest/IntrospectiveTests/String.tests.cpp new file mode 100644 index 0000000000..ae21bb3ce8 --- /dev/null +++ b/src/third_party/cppcodec/test/catch/projects/SelfTest/IntrospectiveTests/String.tests.cpp @@ -0,0 +1,204 @@ +#include "internal/catch_stringref.h" + +#include "catch.hpp" + +#include + +namespace Catch { + + // Implementation of test accessors + struct StringRefTestAccess { + static auto isOwned( StringRef const& stringRef ) -> bool { + return stringRef.isOwned(); + } + static auto isSubstring( StringRef const& stringRef ) -> bool { + return stringRef.isSubstring(); + } + }; + + + namespace { + auto isOwned( StringRef const& stringRef ) -> bool { + return StringRefTestAccess::isOwned( stringRef ); + } + auto isSubstring( StringRef const& stringRef ) -> bool { + return StringRefTestAccess::isSubstring( stringRef ); + } + } // end anonymous namespace + +} // namespace Catch + +TEST_CASE( "StringRef", "[Strings][StringRef]" ) { + + using Catch::StringRef; + using Catch::isOwned; using Catch::isSubstring; + + SECTION( "Empty string" ) { + StringRef empty; + REQUIRE( empty.empty() ); + REQUIRE( empty.size() == 0 ); + REQUIRE( std::strcmp( empty.c_str(), "" ) == 0 ); + } + + SECTION( "From string literal" ) { + StringRef s = "hello"; + REQUIRE( s.empty() == false ); + REQUIRE( s.size() == 5 ); + REQUIRE( isSubstring( s ) == false ); + + auto rawChars = s.currentData(); + REQUIRE( std::strcmp( rawChars, "hello" ) == 0 ); + + SECTION( "c_str() does not cause copy" ) { + REQUIRE( isOwned( s ) == false ); + + REQUIRE( s.c_str() == rawChars ); + + REQUIRE( isOwned( s ) == false ); + } + } + SECTION( "From sub-string" ) { + StringRef original = StringRef( "original string" ).substr(0, 8); + REQUIRE( original == "original" ); + REQUIRE( isSubstring( original ) ); + REQUIRE( isOwned( original ) == false ); + + original.c_str(); // Forces it to take ownership + + REQUIRE( isSubstring( original ) == false ); + REQUIRE( isOwned( original ) ); + } + + + SECTION( "Substrings" ) { + StringRef s = "hello world!"; + StringRef ss = s.substr(0, 5); + + SECTION( "zero-based substring" ) { + REQUIRE( ss.empty() == false ); + REQUIRE( ss.size() == 5 ); + REQUIRE( std::strcmp( ss.c_str(), "hello" ) == 0 ); + REQUIRE( ss == "hello" ); + } + SECTION( "c_str() causes copy" ) { + REQUIRE( isSubstring( ss ) ); + REQUIRE( isOwned( ss ) == false ); + + auto rawChars = ss.currentData(); + REQUIRE( rawChars == s.currentData() ); // same pointer value + REQUIRE( ss.c_str() != rawChars ); + + REQUIRE( isSubstring( ss ) == false ); + REQUIRE( isOwned( ss ) ); + + REQUIRE( ss.currentData() != s.currentData() ); // different pointer value + } + + SECTION( "non-zero-based substring") { + ss = s.substr( 6, 6 ); + REQUIRE( ss.size() == 6 ); + REQUIRE( std::strcmp( ss.c_str(), "world!" ) == 0 ); + } + + SECTION( "Pointer values of full refs should match" ) { + StringRef s2 = s; + REQUIRE( s.c_str() == s2.c_str() ); + } + + SECTION( "Pointer values of substring refs should not match" ) { + REQUIRE( s.c_str() != ss.c_str() ); + } + } + + SECTION( "Comparisons" ) { + REQUIRE( StringRef("hello") == StringRef("hello") ); + REQUIRE( StringRef("hello") != StringRef("cello") ); + } + + SECTION( "from std::string" ) { + std::string stdStr = "a standard string"; + + SECTION( "implicitly constructed" ) { + StringRef sr = stdStr; + REQUIRE( sr == "a standard string" ); + REQUIRE( sr.size() == stdStr.size() ); + } + SECTION( "explicitly constructed" ) { + StringRef sr( stdStr ); + REQUIRE( sr == "a standard string" ); + REQUIRE( sr.size() == stdStr.size() ); + } + SECTION( "assigned" ) { + StringRef sr; + sr = stdStr; + REQUIRE( sr == "a standard string" ); + REQUIRE( sr.size() == stdStr.size() ); + } + } + + SECTION( "to std::string" ) { + StringRef sr = "a stringref"; + + SECTION( "implicitly constructed" ) { + std::string stdStr = sr; + REQUIRE( stdStr == "a stringref" ); + REQUIRE( stdStr.size() == sr.size() ); + } + SECTION( "explicitly constructed" ) { + std::string stdStr( sr ); + REQUIRE( stdStr == "a stringref" ); + REQUIRE( stdStr.size() == sr.size() ); + } + SECTION( "assigned" ) { + std::string stdStr; + stdStr = sr; + REQUIRE( stdStr == "a stringref" ); + REQUIRE( stdStr.size() == sr.size() ); + } + } + + SECTION( "Counting utf-8 codepoints" ) { + StringRef ascii = "just a plain old boring ascii string..."; + REQUIRE(ascii.numberOfCharacters() == ascii.size()); + + StringRef simpleu8 = u8"Trocha ÄeÅ¡tiny nikoho nezabila"; + REQUIRE(simpleu8.numberOfCharacters() == 30); + + StringRef emojis = u8"Here be 👾"; + REQUIRE(emojis.numberOfCharacters() == 9); + } + +} + +TEST_CASE( "replaceInPlace", "[Strings][StringManip]" ) { + std::string letters = "abcdefcg"; + SECTION( "replace single char" ) { + CHECK( Catch::replaceInPlace( letters, "b", "z" ) ); + CHECK( letters == "azcdefcg" ); + } + SECTION( "replace two chars" ) { + CHECK( Catch::replaceInPlace( letters, "c", "z" ) ); + CHECK( letters == "abzdefzg" ); + } + SECTION( "replace first char" ) { + CHECK( Catch::replaceInPlace( letters, "a", "z" ) ); + CHECK( letters == "zbcdefcg" ); + } + SECTION( "replace last char" ) { + CHECK( Catch::replaceInPlace( letters, "g", "z" ) ); + CHECK( letters == "abcdefcz" ); + } + SECTION( "replace all chars" ) { + CHECK( Catch::replaceInPlace( letters, letters, "replaced" ) ); + CHECK( letters == "replaced" ); + } + SECTION( "replace no chars" ) { + CHECK_FALSE( Catch::replaceInPlace( letters, "x", "z" ) ); + CHECK( letters == letters ); + } + SECTION( "escape '" ) { + std::string s = "didn't"; + CHECK( Catch::replaceInPlace( s, "'", "|'" ) ); + CHECK( s == "didn|'t" ); + } +} diff --git a/src/third_party/cppcodec/test/catch/projects/SelfTest/IntrospectiveTests/TagAlias.tests.cpp b/src/third_party/cppcodec/test/catch/projects/SelfTest/IntrospectiveTests/TagAlias.tests.cpp new file mode 100644 index 0000000000..b533c45447 --- /dev/null +++ b/src/third_party/cppcodec/test/catch/projects/SelfTest/IntrospectiveTests/TagAlias.tests.cpp @@ -0,0 +1,42 @@ +/* + * Created by Phil on 27/06/2014. + * Copyright 2014 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) + */ + +#include "catch.hpp" +#include "internal/catch_tag_alias_registry.h" + +TEST_CASE( "Tag alias can be registered against tag patterns" ) { + + Catch::TagAliasRegistry registry; + + registry.add( "[@zzz]", "[one][two]", Catch::SourceLineInfo( "file", 2 ) ); + + SECTION( "The same tag alias can only be registered once" ) { + + try { + registry.add( "[@zzz]", "[one][two]", Catch::SourceLineInfo( "file", 10 ) ); + FAIL( "expected exception" ); + } + catch( std::exception& ex ) { +#ifndef CATCH_CONFIG_DISABLE_MATCHERS + std::string what = ex.what(); + using namespace Catch::Matchers; + CHECK_THAT( what, Contains( "[@zzz]" ) ); + CHECK_THAT( what, Contains( "file" ) ); + CHECK_THAT( what, Contains( "2" ) ); + CHECK_THAT( what, Contains( "10" ) ); +#endif + } + } + + SECTION( "Tag aliases must be of the form [@name]" ) { + CHECK_THROWS( registry.add( "[no ampersat]", "", Catch::SourceLineInfo( "file", 3 ) ) ); + CHECK_THROWS( registry.add( "[the @ is not at the start]", "", Catch::SourceLineInfo( "file", 3 ) ) ); + CHECK_THROWS( registry.add( "@no square bracket at start]", "", Catch::SourceLineInfo( "file", 3 ) ) ); + CHECK_THROWS( registry.add( "[@no square bracket at end", "", Catch::SourceLineInfo( "file", 3 ) ) ); + } +} diff --git a/src/third_party/cppcodec/test/catch/projects/SelfTest/IntrospectiveTests/Xml.tests.cpp b/src/third_party/cppcodec/test/catch/projects/SelfTest/IntrospectiveTests/Xml.tests.cpp new file mode 100644 index 0000000000..c3886ab282 --- /dev/null +++ b/src/third_party/cppcodec/test/catch/projects/SelfTest/IntrospectiveTests/Xml.tests.cpp @@ -0,0 +1,112 @@ +#include "catch.hpp" +#include "internal/catch_xmlwriter.h" + +#include + +inline std::string encode( std::string const& str, Catch::XmlEncode::ForWhat forWhat = Catch::XmlEncode::ForTextNodes ) { + std::ostringstream oss; + oss << Catch::XmlEncode( str, forWhat ); + return oss.str(); +} + +TEST_CASE( "XmlEncode", "[XML]" ) { + SECTION( "normal string" ) { + REQUIRE( encode( "normal string" ) == "normal string" ); + } + SECTION( "empty string" ) { + REQUIRE( encode( "" ) == "" ); + } + SECTION( "string with ampersand" ) { + REQUIRE( encode( "smith & jones" ) == "smith & jones" ); + } + SECTION( "string with less-than" ) { + REQUIRE( encode( "smith < jones" ) == "smith < jones" ); + } + SECTION( "string with greater-than" ) { + REQUIRE( encode( "smith > jones" ) == "smith > jones" ); + REQUIRE( encode( "smith ]]> jones" ) == "smith ]]> jones" ); + } + SECTION( "string with quotes" ) { + std::string stringWithQuotes = "don't \"quote\" me on that"; + REQUIRE( encode( stringWithQuotes ) == stringWithQuotes ); + REQUIRE( encode( stringWithQuotes, Catch::XmlEncode::ForAttributes ) == "don't "quote" me on that" ); + } + SECTION( "string with control char (1)" ) { + REQUIRE( encode( "[\x01]" ) == "[\\x01]" ); + } + SECTION( "string with control char (x7F)" ) { + REQUIRE( encode( "[\x7F]" ) == "[\\x7F]" ); + } +} + +// Thanks to Peter Bindels (dascandy) for some of the tests +TEST_CASE("XmlEncode: UTF-8", "[XML][UTF-8]") { + SECTION("Valid utf-8 strings") { + CHECK(encode(u8"Here be 👾") == u8"Here be 👾"); + CHECK(encode(u8"Å¡Å¡") == u8"Å¡Å¡"); + + CHECK(encode("\xDF\xBF") == "\xDF\xBF"); // 0x7FF + CHECK(encode("\xE0\xA0\x80") == "\xE0\xA0\x80"); // 0x800 + CHECK(encode("\xED\x9F\xBF") == "\xED\x9F\xBF"); // 0xD7FF + CHECK(encode("\xEE\x80\x80") == "\xEE\x80\x80"); // 0xE000 + CHECK(encode("\xEF\xBF\xBF") == "\xEF\xBF\xBF"); // 0xFFFF + CHECK(encode("\xF0\x90\x80\x80") == "\xF0\x90\x80\x80"); // 0x10000 + CHECK(encode("\xF4\x8F\xBF\xBF") == "\xF4\x8F\xBF\xBF"); // 0x10FFFF + } + SECTION("Invalid utf-8 strings") { + SECTION("Various broken strings") { + CHECK(encode("Here \xFF be 👾") == u8"Here \\xFF be 👾"); + CHECK(encode("\xFF") == "\\xFF"); + CHECK(encode("\xC5\xC5\xA0") == u8"\\xC5Å "); + CHECK(encode("\xF4\x90\x80\x80") == u8"\\xF4\\x90\\x80\\x80"); // 0x110000 -- out of unicode range + } + + SECTION("Overlong encodings") { + CHECK(encode("\xC0\x80") == u8"\\xC0\\x80"); // \0 + CHECK(encode("\xF0\x80\x80\x80") == u8"\\xF0\\x80\\x80\\x80"); // Super-over-long \0 + CHECK(encode("\xC1\xBF") == u8"\\xC1\\xBF"); // ASCII char as UTF-8 (0x7F) + CHECK(encode("\xE0\x9F\xBF") == u8"\\xE0\\x9F\\xBF"); // 0x7FF + CHECK(encode("\xF0\x8F\xBF\xBF") == u8"\\xF0\\x8F\\xBF\\xBF"); // 0xFFFF + } + + // Note that we actually don't modify surrogate pairs, as we do not do strict checking + SECTION("Surrogate pairs") { + CHECK(encode("\xED\xA0\x80") == "\xED\xA0\x80"); // Invalid surrogate half 0xD800 + CHECK(encode("\xED\xAF\xBF") == "\xED\xAF\xBF"); // Invalid surrogate half 0xDBFF + CHECK(encode("\xED\xB0\x80") == "\xED\xB0\x80"); // Invalid surrogate half 0xDC00 + CHECK(encode("\xED\xBF\xBF") == "\xED\xBF\xBF"); // Invalid surrogate half 0xDFFF + } + + SECTION("Invalid start byte") { + CHECK(encode("\x80") == u8"\\x80"); + CHECK(encode("\x81") == u8"\\x81"); + CHECK(encode("\xBC") == u8"\\xBC"); + CHECK(encode("\xBF") == u8"\\xBF"); + // Out of range + CHECK(encode("\xF5\x80\x80\x80") == u8"\\xF5\\x80\\x80\\x80"); + CHECK(encode("\xF6\x80\x80\x80") == u8"\\xF6\\x80\\x80\\x80"); + CHECK(encode("\xF7\x80\x80\x80") == u8"\\xF7\\x80\\x80\\x80"); + } + + SECTION("Missing continuation byte(s)") { + // Missing first continuation byte + CHECK(encode("\xDE") == u8"\\xDE"); + CHECK(encode("\xDF") == u8"\\xDF"); + CHECK(encode("\xE0") == u8"\\xE0"); + CHECK(encode("\xEF") == u8"\\xEF"); + CHECK(encode("\xF0") == u8"\\xF0"); + CHECK(encode("\xF4") == u8"\\xF4"); + + // Missing second continuation byte + CHECK(encode("\xE0\x80") == u8"\\xE0\\x80"); + CHECK(encode("\xE0\xBF") == u8"\\xE0\\xBF"); + CHECK(encode("\xE1\x80") == u8"\\xE1\\x80"); + CHECK(encode("\xF0\x80") == u8"\\xF0\\x80"); + CHECK(encode("\xF4\x80") == u8"\\xF4\\x80"); + + // Missing third continuation byte + CHECK(encode("\xF0\x80\x80") == u8"\\xF0\\x80\\x80"); + CHECK(encode("\xF4\x80\x80") == u8"\\xF4\\x80\\x80"); + } + } +} diff --git a/src/third_party/cppcodec/test/catch/projects/SelfTest/SurrogateCpps/catch_console_colour.cpp b/src/third_party/cppcodec/test/catch/projects/SelfTest/SurrogateCpps/catch_console_colour.cpp new file mode 100644 index 0000000000..a2377500ec --- /dev/null +++ b/src/third_party/cppcodec/test/catch/projects/SelfTest/SurrogateCpps/catch_console_colour.cpp @@ -0,0 +1,3 @@ +// This file is only here to verify (to the extent possible) the self sufficiency of the header +#include "internal/catch_suppress_warnings.h" +#include "internal/catch_console_colour.h" diff --git a/src/third_party/cppcodec/test/catch/projects/SelfTest/SurrogateCpps/catch_debugger.cpp b/src/third_party/cppcodec/test/catch/projects/SelfTest/SurrogateCpps/catch_debugger.cpp new file mode 100644 index 0000000000..04f4e071a0 --- /dev/null +++ b/src/third_party/cppcodec/test/catch/projects/SelfTest/SurrogateCpps/catch_debugger.cpp @@ -0,0 +1,2 @@ +// This file is only here to verify (to the extent possible) the self sufficiency of the header +#include "internal/catch_debugger.h" diff --git a/src/third_party/cppcodec/test/catch/projects/SelfTest/SurrogateCpps/catch_interfaces_reporter.cpp b/src/third_party/cppcodec/test/catch/projects/SelfTest/SurrogateCpps/catch_interfaces_reporter.cpp new file mode 100644 index 0000000000..f3c715854f --- /dev/null +++ b/src/third_party/cppcodec/test/catch/projects/SelfTest/SurrogateCpps/catch_interfaces_reporter.cpp @@ -0,0 +1,2 @@ +#include "internal/catch_suppress_warnings.h" +#include "internal/catch_interfaces_reporter.h" diff --git a/src/third_party/cppcodec/test/catch/projects/SelfTest/SurrogateCpps/catch_option.cpp b/src/third_party/cppcodec/test/catch/projects/SelfTest/SurrogateCpps/catch_option.cpp new file mode 100644 index 0000000000..a4ca37c222 --- /dev/null +++ b/src/third_party/cppcodec/test/catch/projects/SelfTest/SurrogateCpps/catch_option.cpp @@ -0,0 +1,3 @@ +// This file is only here to verify (to the extent possible) the self sufficiency of the header +#include "internal/catch_suppress_warnings.h" +#include "internal/catch_option.hpp" diff --git a/src/third_party/cppcodec/test/catch/projects/SelfTest/SurrogateCpps/catch_stream.cpp b/src/third_party/cppcodec/test/catch/projects/SelfTest/SurrogateCpps/catch_stream.cpp new file mode 100644 index 0000000000..a76d8413ba --- /dev/null +++ b/src/third_party/cppcodec/test/catch/projects/SelfTest/SurrogateCpps/catch_stream.cpp @@ -0,0 +1,3 @@ +// This file is only here to verify (to the extent possible) the self sufficiency of the header +#include "internal/catch_suppress_warnings.h" +#include "internal/catch_stream.h" diff --git a/src/third_party/cppcodec/test/catch/projects/SelfTest/SurrogateCpps/catch_test_case_tracker.cpp b/src/third_party/cppcodec/test/catch/projects/SelfTest/SurrogateCpps/catch_test_case_tracker.cpp new file mode 100644 index 0000000000..0d697b0fcd --- /dev/null +++ b/src/third_party/cppcodec/test/catch/projects/SelfTest/SurrogateCpps/catch_test_case_tracker.cpp @@ -0,0 +1,2 @@ +// This file is only here to verify (to the extent possible) the self sufficiency of the header +#include "internal/catch_test_case_tracker.h" diff --git a/src/third_party/cppcodec/test/catch/projects/SelfTest/SurrogateCpps/catch_test_spec.cpp b/src/third_party/cppcodec/test/catch/projects/SelfTest/SurrogateCpps/catch_test_spec.cpp new file mode 100644 index 0000000000..8be135ecfe --- /dev/null +++ b/src/third_party/cppcodec/test/catch/projects/SelfTest/SurrogateCpps/catch_test_spec.cpp @@ -0,0 +1,3 @@ +// This file is only here to verify (to the extent possible) the self sufficiency of the header +#include "internal/catch_suppress_warnings.h" +#include "internal/catch_test_spec.h" diff --git a/src/third_party/cppcodec/test/catch/projects/SelfTest/SurrogateCpps/catch_xmlwriter.cpp b/src/third_party/cppcodec/test/catch/projects/SelfTest/SurrogateCpps/catch_xmlwriter.cpp new file mode 100644 index 0000000000..930e3825a8 --- /dev/null +++ b/src/third_party/cppcodec/test/catch/projects/SelfTest/SurrogateCpps/catch_xmlwriter.cpp @@ -0,0 +1,4 @@ +// This file is only here to verify (to the extent possible) the self sufficiency of the header +#include "internal/catch_suppress_warnings.h" +#include "internal/catch_xmlwriter.h" +#include "internal/catch_reenable_warnings.h" diff --git a/src/third_party/cppcodec/test/catch/projects/SelfTest/TestMain.cpp b/src/third_party/cppcodec/test/catch/projects/SelfTest/TestMain.cpp new file mode 100644 index 0000000000..1c023ce91f --- /dev/null +++ b/src/third_party/cppcodec/test/catch/projects/SelfTest/TestMain.cpp @@ -0,0 +1,33 @@ +/* + * Created by Phil on 22/10/2010. + * Copyright 2010 Two Blue Cubes Ltd + * + * 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) + */ + +#define CATCH_CONFIG_MAIN +#include "catch.hpp" + +// These reporters are not included in the single include, so must be included separately in the main file +#include "reporters/catch_reporter_teamcity.hpp" +#include "reporters/catch_reporter_tap.hpp" +#include "reporters/catch_reporter_automake.hpp" + + +// Some example tag aliases +CATCH_REGISTER_TAG_ALIAS( "[@nhf]", "[failing]~[.]" ) +CATCH_REGISTER_TAG_ALIAS( "[@tricky]", "[tricky]~[.]" ) + + +#ifdef __clang__ +# pragma clang diagnostic ignored "-Wpadded" +# pragma clang diagnostic ignored "-Wweak-vtables" +# pragma clang diagnostic ignored "-Wc++98-compat" +#endif + +struct TestListener : Catch::TestEventListenerBase { + using TestEventListenerBase::TestEventListenerBase; // inherit constructor +}; +CATCH_REGISTER_LISTENER( TestListener ) + diff --git a/src/third_party/cppcodec/test/catch/projects/SelfTest/UsageTests/Approx.tests.cpp b/src/third_party/cppcodec/test/catch/projects/SelfTest/UsageTests/Approx.tests.cpp new file mode 100644 index 0000000000..b95394a06b --- /dev/null +++ b/src/third_party/cppcodec/test/catch/projects/SelfTest/UsageTests/Approx.tests.cpp @@ -0,0 +1,214 @@ +/* + * Created by Phil on 28/04/2011. + * Copyright 2011 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) + */ + +#include "catch.hpp" + +#include + +namespace { namespace ApproxTests { + +#ifndef APPROX_TEST_HELPERS_INCLUDED // Don't compile this more than once per TU +#define APPROX_TEST_HELPERS_INCLUDED + + inline double divide( double a, double b ) { + return a/b; + } + + class StrongDoubleTypedef { + double d_ = 0.0; + + public: + explicit StrongDoubleTypedef(double d) : d_(d) {} + explicit operator double() const { return d_; } + }; + + inline std::ostream& operator<<( std::ostream& os, StrongDoubleTypedef td ) { + return os << "StrongDoubleTypedef(" << static_cast(td) << ")"; + } + +#endif + +using namespace Catch::literals; + +/////////////////////////////////////////////////////////////////////////////// +TEST_CASE( "A comparison that uses literals instead of the normal constructor", "[Approx]" ) { + double d = 1.23; + + REQUIRE( d == 1.23_a ); + REQUIRE( d != 1.22_a ); + REQUIRE( -d == -1.23_a ); + + REQUIRE( d == 1.2_a .epsilon(.1) ); + REQUIRE( d != 1.2_a .epsilon(.001) ); + REQUIRE( d == 1_a .epsilon(.3) ); +} + +TEST_CASE( "Some simple comparisons between doubles", "[Approx]" ) { + double d = 1.23; + + REQUIRE( d == Approx( 1.23 ) ); + REQUIRE( d != Approx( 1.22 ) ); + REQUIRE( d != Approx( 1.24 ) ); + + REQUIRE( d == 1.23_a ); + REQUIRE( d != 1.22_a ); + + REQUIRE( Approx( d ) == 1.23 ); + REQUIRE( Approx( d ) != 1.22 ); + REQUIRE( Approx( d ) != 1.24 ); + + REQUIRE(INFINITY == Approx(INFINITY)); +} + +/////////////////////////////////////////////////////////////////////////////// +TEST_CASE( "Approximate comparisons with different epsilons", "[Approx]" ) { + double d = 1.23; + + REQUIRE( d != Approx( 1.231 ) ); + REQUIRE( d == Approx( 1.231 ).epsilon( 0.1 ) ); +} + +/////////////////////////////////////////////////////////////////////////////// +TEST_CASE( "Less-than inequalities with different epsilons", "[Approx]" ) { + double d = 1.23; + + REQUIRE( d <= Approx( 1.24 ) ); + REQUIRE( d <= Approx( 1.23 ) ); + REQUIRE_FALSE( d <= Approx( 1.22 ) ); + REQUIRE( d <= Approx( 1.22 ).epsilon(0.1) ); +} + +/////////////////////////////////////////////////////////////////////////////// +TEST_CASE( "Greater-than inequalities with different epsilons", "[Approx]" ) { + double d = 1.23; + + REQUIRE( d >= Approx( 1.22 ) ); + REQUIRE( d >= Approx( 1.23 ) ); + REQUIRE_FALSE( d >= Approx( 1.24 ) ); + REQUIRE( d >= Approx( 1.24 ).epsilon(0.1) ); +} + +/////////////////////////////////////////////////////////////////////////////// +TEST_CASE( "Approximate comparisons with floats", "[Approx]" ) { + REQUIRE( 1.23f == Approx( 1.23f ) ); + REQUIRE( 0.0f == Approx( 0.0f ) ); +} + +/////////////////////////////////////////////////////////////////////////////// +TEST_CASE( "Approximate comparisons with ints", "[Approx]" ) { + REQUIRE( 1 == Approx( 1 ) ); + REQUIRE( 0 == Approx( 0 ) ); +} + +/////////////////////////////////////////////////////////////////////////////// +TEST_CASE( "Approximate comparisons with mixed numeric types", "[Approx]" ) { + const double dZero = 0; + const double dSmall = 0.00001; + const double dMedium = 1.234; + + REQUIRE( 1.0f == Approx( 1 ) ); + REQUIRE( 0 == Approx( dZero) ); + REQUIRE( 0 == Approx( dSmall ).margin( 0.001 ) ); + REQUIRE( 1.234f == Approx( dMedium ) ); + REQUIRE( dMedium == Approx( 1.234f ) ); +} + +/////////////////////////////////////////////////////////////////////////////// +TEST_CASE( "Use a custom approx", "[Approx][custom]" ) { + double d = 1.23; + + Approx approx = Approx::custom().epsilon( 0.01 ); + + REQUIRE( d == approx( 1.23 ) ); + REQUIRE( d == approx( 1.22 ) ); + REQUIRE( d == approx( 1.24 ) ); + REQUIRE( d != approx( 1.25 ) ); + + REQUIRE( approx( d ) == 1.23 ); + REQUIRE( approx( d ) == 1.22 ); + REQUIRE( approx( d ) == 1.24 ); + REQUIRE( approx( d ) != 1.25 ); +} + +TEST_CASE( "Approximate PI", "[Approx][PI]" ) { + REQUIRE( divide( 22, 7 ) == Approx( 3.141 ).epsilon( 0.001 ) ); + REQUIRE( divide( 22, 7 ) != Approx( 3.141 ).epsilon( 0.0001 ) ); +} + +/////////////////////////////////////////////////////////////////////////////// + +TEST_CASE( "Absolute margin", "[Approx]" ) { + REQUIRE( 104.0 != Approx(100.0) ); + REQUIRE( 104.0 == Approx(100.0).margin(5) ); + REQUIRE( 104.0 == Approx(100.0).margin(4) ); + REQUIRE( 104.0 != Approx(100.0).margin(3) ); + REQUIRE( 100.3 != Approx(100.0) ); + REQUIRE( 100.3 == Approx(100.0).margin(0.5) ); +} + +TEST_CASE("Approx with exactly-representable margin", "[Approx]") { + CHECK( 0.25f == Approx(0.0f).margin(0.25f) ); + + CHECK( 0.0f == Approx(0.25f).margin(0.25f) ); + CHECK( 0.5f == Approx(0.25f).margin(0.25f) ); + + CHECK( 245.0f == Approx(245.25f).margin(0.25f) ); + CHECK( 245.5f == Approx(245.25f).margin(0.25f) ); +} + +TEST_CASE("Approx setters validate their arguments", "[Approx]") { + REQUIRE_NOTHROW(Approx(0).margin(0)); + REQUIRE_NOTHROW(Approx(0).margin(1234656)); + + REQUIRE_THROWS_AS(Approx(0).margin(-2), std::domain_error); + + REQUIRE_NOTHROW(Approx(0).epsilon(0)); + REQUIRE_NOTHROW(Approx(0).epsilon(1)); + + REQUIRE_THROWS_AS(Approx(0).epsilon(-0.001), std::domain_error); + REQUIRE_THROWS_AS(Approx(0).epsilon(1.0001), std::domain_error); +} + +TEST_CASE("Default scale is invisible to comparison", "[Approx]") { + REQUIRE(101.000001 != Approx(100).epsilon(0.01)); + REQUIRE(std::pow(10, -5) != Approx(std::pow(10, -7))); +} + +TEST_CASE("Epsilon only applies to Approx's value", "[Approx]") { + REQUIRE(101.01 != Approx(100).epsilon(0.01)); +} + +TEST_CASE("Assorted miscellaneous tests", "[Approx]") { + REQUIRE(INFINITY == Approx(INFINITY)); + REQUIRE(NAN != Approx(NAN)); + REQUIRE_FALSE(NAN == Approx(NAN)); +} + +TEST_CASE( "Comparison with explicitly convertible types", "[Approx]" ) +{ + StrongDoubleTypedef td(10.0); + + REQUIRE(td == Approx(10.0)); + REQUIRE(Approx(10.0) == td); + + REQUIRE(td != Approx(11.0)); + REQUIRE(Approx(11.0) != td); + + REQUIRE(td <= Approx(10.0)); + REQUIRE(td <= Approx(11.0)); + REQUIRE(Approx(10.0) <= td); + REQUIRE(Approx(9.0) <= td); + + REQUIRE(td >= Approx(9.0)); + REQUIRE(td >= Approx(td)); + REQUIRE(Approx(td) >= td); + REQUIRE(Approx(11.0) >= td); + +} + +}} // namespace ApproxTests diff --git a/src/third_party/cppcodec/test/catch/projects/SelfTest/UsageTests/BDD.tests.cpp b/src/third_party/cppcodec/test/catch/projects/SelfTest/UsageTests/BDD.tests.cpp new file mode 100644 index 0000000000..f43fd96dc2 --- /dev/null +++ b/src/third_party/cppcodec/test/catch/projects/SelfTest/UsageTests/BDD.tests.cpp @@ -0,0 +1,107 @@ +/* + * Created by Phil on 29/11/2010. + * Copyright 2010 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) + */ + +#include "catch.hpp" + +namespace { namespace BDDTests { + +#ifndef BDD_TEST_HELPERS_INCLUDED // Don't compile this more than once per TU +#define BDD_TEST_HELPERS_INCLUDED + + inline bool itDoesThis() { return true; } + + inline bool itDoesThat() { return true; } + + namespace { + +// a trivial fixture example to support SCENARIO_METHOD tests + struct Fixture { + Fixture() + : d_counter(0) { + } + + int counter() { + return d_counter++; + } + + int d_counter; + }; + + } +#endif + + SCENARIO("Do that thing with the thing", "[Tags]") { + GIVEN("This stuff exists") { + // make stuff exist + WHEN("I do this") { + // do this + THEN("it should do this") { + REQUIRE(itDoesThis()); + AND_THEN("do that")REQUIRE(itDoesThat()); + } + } + } + } + + SCENARIO("Vector resizing affects size and capacity", "[vector][bdd][size][capacity]") { + GIVEN("an empty vector") { + std::vector v; + REQUIRE(v.size() == 0); + + WHEN("it is made larger") { + v.resize(10); + THEN("the size and capacity go up") { + REQUIRE(v.size() == 10); + REQUIRE(v.capacity() >= 10); + + AND_WHEN("it is made smaller again") { + v.resize(5); + THEN("the size goes down but the capacity stays the same") { + REQUIRE(v.size() == 5); + REQUIRE(v.capacity() >= 10); + } + } + } + } + + WHEN("we reserve more space") { + v.reserve(10); + THEN("The capacity is increased but the size remains the same") { + REQUIRE(v.capacity() >= 10); + REQUIRE(v.size() == 0); + } + } + } + } + + SCENARIO("This is a really long scenario name to see how the list command deals with wrapping", + "[very long tags][lots][long][tags][verbose]" + "[one very long tag name that should cause line wrapping writing out using the list command]" + "[anotherReallyLongTagNameButThisOneHasNoObviousWrapPointsSoShouldSplitWithinAWordUsingADashCharacter]") { + GIVEN("A section name that is so long that it cannot fit in a single console width")WHEN( + "The test headers are printed as part of the normal running of the scenario")THEN( + "The, deliberately very long and overly verbose (you see what I did there?) section names must wrap, along with an indent")SUCCEED( + "boo!"); + } + + SCENARIO_METHOD(Fixture, + "BDD tests requiring Fixtures to provide commonly-accessed data or methods", + "[bdd][fixtures]") { + const int before(counter()); + GIVEN("No operations precede me") { + REQUIRE(before == 0); + WHEN("We get the count") { + const int after(counter()); + THEN("Subsequently values are higher") { + REQUIRE(after > before); + } + } + } + } + +}} // namespace BDDtests diff --git a/src/third_party/cppcodec/test/catch/projects/SelfTest/UsageTests/Benchmark.tests.cpp b/src/third_party/cppcodec/test/catch/projects/SelfTest/UsageTests/Benchmark.tests.cpp new file mode 100644 index 0000000000..ddf6950457 --- /dev/null +++ b/src/third_party/cppcodec/test/catch/projects/SelfTest/UsageTests/Benchmark.tests.cpp @@ -0,0 +1,43 @@ +#include "catch.hpp" + +#include + +TEST_CASE( "benchmarked", "[!benchmark]" ) { + + static const int size = 100; + + std::vector v; + std::map m; + + BENCHMARK( "Load up a vector" ) { + v = std::vector(); + for(int i =0; i < size; ++i ) + v.push_back( i ); + } + REQUIRE( v.size() == size ); + + BENCHMARK( "Load up a map" ) { + m = std::map(); + for(int i =0; i < size; ++i ) + m.insert( { i, i+1 } ); + } + REQUIRE( m.size() == size ); + + BENCHMARK( "Reserved vector" ) { + v = std::vector(); + v.reserve(size); + for(int i =0; i < size; ++i ) + v.push_back( i ); + } + REQUIRE( v.size() == size ); + + int array[size]; + BENCHMARK( "A fixed size array that should require no allocations" ) { + for(int i =0; i < size; ++i ) + array[i] = i; + } + int sum = 0; + for(int i =0; i < size; ++i ) + sum += array[i]; + REQUIRE( sum > size ); +} diff --git a/src/third_party/cppcodec/test/catch/projects/SelfTest/UsageTests/Class.tests.cpp b/src/third_party/cppcodec/test/catch/projects/SelfTest/UsageTests/Class.tests.cpp new file mode 100644 index 0000000000..c19a5172cf --- /dev/null +++ b/src/third_party/cppcodec/test/catch/projects/SelfTest/UsageTests/Class.tests.cpp @@ -0,0 +1,63 @@ +/* + * Created by Phil on 09/11/2010. + * Copyright 2010 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) + */ + +#include "catch.hpp" + +namespace{ namespace ClassTests { + +#ifndef CLASS_TEST_HELPERS_INCLUDED // Don't compile this more than once per TU +#define CLASS_TEST_HELPERS_INCLUDED + +class TestClass +{ + std::string s; + +public: + TestClass() + : s( "hello" ) + {} + + void succeedingCase() + { + REQUIRE( s == "hello" ); + } + void failingCase() + { + REQUIRE( s == "world" ); + } +}; + +struct Fixture +{ + Fixture() : m_a( 1 ) {} + + int m_a; +}; + +#endif + + + +METHOD_AS_TEST_CASE( TestClass::succeedingCase, "A METHOD_AS_TEST_CASE based test run that succeeds", "[class]" ) +METHOD_AS_TEST_CASE( TestClass::failingCase, "A METHOD_AS_TEST_CASE based test run that fails", "[.][class][failing]" ) + +TEST_CASE_METHOD( Fixture, "A TEST_CASE_METHOD based test run that succeeds", "[class]" ) +{ + REQUIRE( m_a == 1 ); +} + +// We should be able to write our tests within a different namespace +namespace Inner +{ + TEST_CASE_METHOD( Fixture, "A TEST_CASE_METHOD based test run that fails", "[.][class][failing]" ) + { + REQUIRE( m_a == 2 ); + } +} + +}} // namespace ClassTests diff --git a/src/third_party/cppcodec/test/catch/projects/SelfTest/UsageTests/Compilation.tests.cpp b/src/third_party/cppcodec/test/catch/projects/SelfTest/UsageTests/Compilation.tests.cpp new file mode 100644 index 0000000000..2e518ef205 --- /dev/null +++ b/src/third_party/cppcodec/test/catch/projects/SelfTest/UsageTests/Compilation.tests.cpp @@ -0,0 +1,157 @@ +/* + * Created by Martin on 17/02/2017. + * + * 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) + */ + +#include "catch.hpp" + +#include + +namespace { namespace CompilationTests { + +#ifndef COMPILATION_TEST_HELPERS_INCLUDED // Don't compile this more than once per TU +#define COMPILATION_TEST_HELPERS_INCLUDED + + // Comparison operators can return non-booleans. + // This is unusual, but should be supported. + struct logic_t { + logic_t operator< (logic_t) const { return {}; } + logic_t operator<=(logic_t) const { return {}; } + logic_t operator> (logic_t) const { return {}; } + logic_t operator>=(logic_t) const { return {}; } + logic_t operator==(logic_t) const { return {}; } + logic_t operator!=(logic_t) const { return {}; } + explicit operator bool() const { return true; } + }; + + +// This is a minimal example for an issue we have found in 1.7.0 + struct foo { + int i; + }; + + template + bool operator==(const T &val, foo f) { + return val == f.i; + } + + struct Y { + uint32_t v : 1; + }; + + void throws_int(bool b) { + if (b) { + throw 1; + } + } + + template + bool templated_tests(T t) { + int a = 3; + REQUIRE(a == t); + CHECK(a == t); + REQUIRE_THROWS(throws_int(true)); + CHECK_THROWS_AS(throws_int(true), int); + REQUIRE_NOTHROW(throws_int(false)); +#ifndef CATCH_CONFIG_DISABLE_MATCHERS + REQUIRE_THAT("aaa", Catch::EndsWith("aaa")); +#endif + return true; + } + + struct A { + }; + + std::ostream &operator<<(std::ostream &o, const A &) { return o << 0; } + + struct B : private A { + bool operator==(int) const { return true; } + }; + +#ifdef __clang__ +#pragma clang diagnostic push +#pragma clang diagnostic ignored "-Wunused-function" +#endif +#ifdef __GNUC__ +// Note that because -~GCC~-, this warning cannot be silenced temporarily, by pushing diagnostic stack... +// Luckily it is firing in test files and thus can be silenced for the whole file, without losing much. +#pragma GCC diagnostic ignored "-Wunused-function" +#endif + + B f(); + + std::ostream g(); + +#ifdef __clang__ +#pragma clang diagnostic pop +#endif + + template + struct Fixture_1245 {}; + +#endif + + TEST_CASE("#809") { + foo f; + f.i = 42; + REQUIRE(42 == f); + } + + +// ------------------------------------------------------------------ +// Changes to REQUIRE_THROWS_AS made it stop working in a template in +// an unfixable way (as long as C++03 compatibility is being kept). +// To prevent these from happening in the future, this needs to compile + + TEST_CASE("#833") { + REQUIRE(templated_tests(3)); + } + + +// Test containing example where original stream insertable check breaks compilation + + + TEST_CASE("#872") { + A dummy; + CAPTURE(dummy); + B x; + REQUIRE (x == 4); + } + + + TEST_CASE("#1027") { + Y y{0}; + REQUIRE(y.v == 0); + REQUIRE(0 == y.v); + } + + // Comparison operators can return non-booleans. + // This is unusual, but should be supported. + TEST_CASE("#1147") { + logic_t t1, t2; + REQUIRE(t1 == t2); + REQUIRE(t1 != t2); + REQUIRE(t1 < t2); + REQUIRE(t1 > t2); + REQUIRE(t1 <= t2); + REQUIRE(t1 >= t2); + } + + // unsigned array + TEST_CASE("#1238") { + unsigned char uarr[] = "123"; + CAPTURE(uarr); + signed char sarr[] = "456"; + CAPTURE(sarr); + + REQUIRE(std::memcmp(uarr, "123", sizeof(uarr)) == 0); + REQUIRE(std::memcmp(sarr, "456", sizeof(sarr)) == 0); + } + + TEST_CASE_METHOD((Fixture_1245), "#1245", "[compilation]") { + SUCCEED(); + } + +}} // namespace CompilationTests diff --git a/src/third_party/cppcodec/test/catch/projects/SelfTest/UsageTests/Condition.tests.cpp b/src/third_party/cppcodec/test/catch/projects/SelfTest/UsageTests/Condition.tests.cpp new file mode 100644 index 0000000000..9aed5e2c76 --- /dev/null +++ b/src/third_party/cppcodec/test/catch/projects/SelfTest/UsageTests/Condition.tests.cpp @@ -0,0 +1,334 @@ +/* + * Created by Phil on 08/11/2010. + * Copyright 2010 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) + */ +#ifdef __clang__ +# pragma clang diagnostic push +# pragma clang diagnostic ignored "-Wpadded" +// Wdouble-promotion is not supported until 3.8 +# if (__clang_major__ > 3) || (__clang_major__ == 3 && __clang_minor__ > 7) +# pragma clang diagnostic ignored "-Wdouble-promotion" +# endif +#endif + +#include "catch.hpp" + +#include +#include +#include + +namespace { namespace ConditionTests { + +#ifndef CONDITION_TEST_HELPERS_INCLUDED // Don't compile this more than once per TU +#define CONDITION_TEST_HELPERS_INCLUDED + +struct TestData { + int int_seven = 7; + std::string str_hello = "hello"; + float float_nine_point_one = 9.1f; + double double_pi = 3.1415926535; +}; + +struct TestDef { + TestDef& operator + ( const std::string& ) { + return *this; + } + TestDef& operator[]( const std::string& ) { + return *this; + } +}; + +inline const char* returnsConstNull(){ return nullptr; } +inline char* returnsNull(){ return nullptr; } + +#endif + +// The "failing" tests all use the CHECK macro, which continues if the specific test fails. +// This allows us to see all results, even if an earlier check fails + +// Equality tests +TEST_CASE( "Equality checks that should succeed" ) +{ + TestDef td; + td + "hello" + "hello"; + + TestData data; + + REQUIRE( data.int_seven == 7 ); + REQUIRE( data.float_nine_point_one == Approx( 9.1f ) ); + REQUIRE( data.double_pi == Approx( 3.1415926535 ) ); + REQUIRE( data.str_hello == "hello" ); + REQUIRE( "hello" == data.str_hello ); + REQUIRE( data.str_hello.size() == 5 ); + + double x = 1.1 + 0.1 + 0.1; + REQUIRE( x == Approx( 1.3 ) ); +} + +TEST_CASE( "Equality checks that should fail", "[.][failing][!mayfail]" ) +{ + TestData data; + + CHECK( data.int_seven == 6 ); + CHECK( data.int_seven == 8 ); + CHECK( data.int_seven == 0 ); + CHECK( data.float_nine_point_one == Approx( 9.11f ) ); + CHECK( data.float_nine_point_one == Approx( 9.0f ) ); + CHECK( data.float_nine_point_one == Approx( 1 ) ); + CHECK( data.float_nine_point_one == Approx( 0 ) ); + CHECK( data.double_pi == Approx( 3.1415 ) ); + CHECK( data.str_hello == "goodbye" ); + CHECK( data.str_hello == "hell" ); + CHECK( data.str_hello == "hello1" ); + CHECK( data.str_hello.size() == 6 ); + + double x = 1.1 + 0.1 + 0.1; + CHECK( x == Approx( 1.301 ) ); +} + +TEST_CASE( "Inequality checks that should succeed" ) +{ + TestData data; + + REQUIRE( data.int_seven != 6 ); + REQUIRE( data.int_seven != 8 ); + REQUIRE( data.float_nine_point_one != Approx( 9.11f ) ); + REQUIRE( data.float_nine_point_one != Approx( 9.0f ) ); + REQUIRE( data.float_nine_point_one != Approx( 1 ) ); + REQUIRE( data.float_nine_point_one != Approx( 0 ) ); + REQUIRE( data.double_pi != Approx( 3.1415 ) ); + REQUIRE( data.str_hello != "goodbye" ); + REQUIRE( data.str_hello != "hell" ); + REQUIRE( data.str_hello != "hello1" ); + REQUIRE( data.str_hello.size() != 6 ); +} + +TEST_CASE( "Inequality checks that should fail", "[.][failing][!shouldfail]" ) +{ + TestData data; + + CHECK( data.int_seven != 7 ); + CHECK( data.float_nine_point_one != Approx( 9.1f ) ); + CHECK( data.double_pi != Approx( 3.1415926535 ) ); + CHECK( data.str_hello != "hello" ); + CHECK( data.str_hello.size() != 5 ); +} + +// Ordering comparison tests +TEST_CASE( "Ordering comparison checks that should succeed" ) +{ + TestData data; + + REQUIRE( data.int_seven < 8 ); + REQUIRE( data.int_seven > 6 ); + REQUIRE( data.int_seven > 0 ); + REQUIRE( data.int_seven > -1 ); + + REQUIRE( data.int_seven >= 7 ); + REQUIRE( data.int_seven >= 6 ); + REQUIRE( data.int_seven <= 7 ); + REQUIRE( data.int_seven <= 8 ); + + REQUIRE( data.float_nine_point_one > 9 ); + REQUIRE( data.float_nine_point_one < 10 ); + REQUIRE( data.float_nine_point_one < 9.2 ); + + REQUIRE( data.str_hello <= "hello" ); + REQUIRE( data.str_hello >= "hello" ); + + REQUIRE( data.str_hello < "hellp" ); + REQUIRE( data.str_hello < "zebra" ); + REQUIRE( data.str_hello > "hellm" ); + REQUIRE( data.str_hello > "a" ); +} + +TEST_CASE( "Ordering comparison checks that should fail", "[.][failing]" ) +{ + TestData data; + + CHECK( data.int_seven > 7 ); + CHECK( data.int_seven < 7 ); + CHECK( data.int_seven > 8 ); + CHECK( data.int_seven < 6 ); + CHECK( data.int_seven < 0 ); + CHECK( data.int_seven < -1 ); + + CHECK( data.int_seven >= 8 ); + CHECK( data.int_seven <= 6 ); + + CHECK( data.float_nine_point_one < 9 ); + CHECK( data.float_nine_point_one > 10 ); + CHECK( data.float_nine_point_one > 9.2 ); + + CHECK( data.str_hello > "hello" ); + CHECK( data.str_hello < "hello" ); + CHECK( data.str_hello > "hellp" ); + CHECK( data.str_hello > "z" ); + CHECK( data.str_hello < "hellm" ); + CHECK( data.str_hello < "a" ); + + CHECK( data.str_hello >= "z" ); + CHECK( data.str_hello <= "a" ); +} + +#ifdef __clang__ +# pragma clang diagnostic pop +#endif + + +// Comparisons with int literals +TEST_CASE( "Comparisons with int literals don't warn when mixing signed/ unsigned" ) +{ + int i = 1; + unsigned int ui = 2; + long l = 3; + unsigned long ul = 4; + char c = 5; + unsigned char uc = 6; + + REQUIRE( i == 1 ); + REQUIRE( ui == 2 ); + REQUIRE( l == 3 ); + REQUIRE( ul == 4 ); + REQUIRE( c == 5 ); + REQUIRE( uc == 6 ); + + REQUIRE( 1 == i ); + REQUIRE( 2 == ui ); + REQUIRE( 3 == l ); + REQUIRE( 4 == ul ); + REQUIRE( 5 == c ); + REQUIRE( 6 == uc ); + + REQUIRE( (std::numeric_limits::max)() > ul ); +} + +// Disable warnings about sign conversions for the next two tests +// (as we are deliberately invoking them) +// - Currently only disabled for GCC/ LLVM. Should add VC++ too +#ifdef __GNUC__ +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wsign-compare" +#pragma GCC diagnostic ignored "-Wsign-conversion" +#endif +#ifdef _MSC_VER +#pragma warning(disable:4389) // '==' : signed/unsigned mismatch +#endif + +TEST_CASE( "comparisons between int variables" ) +{ + long long_var = 1L; + unsigned char unsigned_char_var = 1; + unsigned short unsigned_short_var = 1; + unsigned int unsigned_int_var = 1; + unsigned long unsigned_long_var = 1L; + + REQUIRE( long_var == unsigned_char_var ); + REQUIRE( long_var == unsigned_short_var ); + REQUIRE( long_var == unsigned_int_var ); + REQUIRE( long_var == unsigned_long_var ); +} + +TEST_CASE( "comparisons between const int variables" ) +{ + const unsigned char unsigned_char_var = 1; + const unsigned short unsigned_short_var = 1; + const unsigned int unsigned_int_var = 1; + const unsigned long unsigned_long_var = 1L; + + REQUIRE( unsigned_char_var == 1 ); + REQUIRE( unsigned_short_var == 1 ); + REQUIRE( unsigned_int_var == 1 ); + REQUIRE( unsigned_long_var == 1 ); +} + +TEST_CASE( "Comparisons between unsigned ints and negative signed ints match c++ standard behaviour" ) +{ + CHECK( ( -1 > 2u ) ); + CHECK( -1 > 2u ); + + CHECK( ( 2u < -1 ) ); + CHECK( 2u < -1 ); + + const int minInt = (std::numeric_limits::min)(); + CHECK( ( minInt > 2u ) ); + CHECK( minInt > 2u ); +} + +TEST_CASE( "Comparisons between ints where one side is computed" ) +{ + CHECK( 54 == 6*9 ); +} + +#ifdef __GNUC__ +#pragma GCC diagnostic pop +#endif + +TEST_CASE( "Pointers can be compared to null" ) +{ + TestData* p = nullptr; + TestData* pNULL = nullptr; + + REQUIRE( p == nullptr ); + REQUIRE( p == pNULL ); + + TestData data; + p = &data; + + REQUIRE( p != nullptr ); + + const TestData* cp = p; + REQUIRE( cp != nullptr ); + + const TestData* const cpc = p; + REQUIRE( cpc != nullptr ); + + REQUIRE( returnsNull() == nullptr ); + REQUIRE( returnsConstNull() == nullptr ); + + REQUIRE( nullptr != p ); +} + +// Not (!) tests +// The problem with the ! operator is that it has right-to-left associativity. +// This means we can't isolate it when we decompose. The simple REQUIRE( !false ) form, therefore, +// cannot have the operand value extracted. The test will work correctly, and the situation +// is detected and a warning issued. +// An alternative form of the macros (CHECK_FALSE and REQUIRE_FALSE) can be used instead to capture +// the operand value. +TEST_CASE( "'Not' checks that should succeed" ) +{ + bool falseValue = false; + + REQUIRE( false == false ); + REQUIRE( true == true ); + REQUIRE( !false ); + REQUIRE_FALSE( false ); + + REQUIRE( !falseValue ); + REQUIRE_FALSE( falseValue ); + + REQUIRE( !(1 == 2) ); + REQUIRE_FALSE( 1 == 2 ); +} + +TEST_CASE( "'Not' checks that should fail", "[.][failing]" ) +{ + bool trueValue = true; + + CHECK( false != false ); + CHECK( true != true ); + CHECK( !true ); + CHECK_FALSE( true ); + + CHECK( !trueValue ); + CHECK_FALSE( trueValue ); + + CHECK( !(1 == 1) ); + CHECK_FALSE( 1 == 1 ); +} + +}} // namespace ConditionTests diff --git a/src/third_party/cppcodec/test/catch/projects/SelfTest/UsageTests/Decomposition.tests.cpp b/src/third_party/cppcodec/test/catch/projects/SelfTest/UsageTests/Decomposition.tests.cpp new file mode 100644 index 0000000000..5bb19cd6d3 --- /dev/null +++ b/src/third_party/cppcodec/test/catch/projects/SelfTest/UsageTests/Decomposition.tests.cpp @@ -0,0 +1,39 @@ +/* + * Created by Martin on 27/5/2017. + * Copyright 2017 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) + */ + +#include +#include + +namespace { + +struct truthy { + truthy(bool b):m_value(b){} + operator bool() const { + return false; + } + bool m_value; +}; + +std::ostream& operator<<(std::ostream& o, truthy) { + o << "Hey, its truthy!"; + return o; +} + +} // end anonymous namespace + +#include "catch.hpp" + +TEST_CASE( "Reconstruction should be based on stringification: #914" , "[Decomposition][failing][.]") { + CHECK(truthy(false)); +} + +TEST_CASE("#1005: Comparing pointer to int and long (NULL can be either on various systems)", "[Decomposition]") { + FILE* fptr = nullptr; + REQUIRE(fptr == 0); + REQUIRE(fptr == 0l); +} diff --git a/src/third_party/cppcodec/test/catch/projects/SelfTest/UsageTests/EnumToString.tests.cpp b/src/third_party/cppcodec/test/catch/projects/SelfTest/UsageTests/EnumToString.tests.cpp new file mode 100644 index 0000000000..0b188a8262 --- /dev/null +++ b/src/third_party/cppcodec/test/catch/projects/SelfTest/UsageTests/EnumToString.tests.cpp @@ -0,0 +1,66 @@ +#include "catch.hpp" + + +namespace { +// Enum without user-provided stream operator +enum Enum1 { Enum1Value0, Enum1Value1 }; + +// Enum with user-provided stream operator +enum Enum2 { Enum2Value0, Enum2Value1 }; + +std::ostream& operator<<( std::ostream& os, Enum2 v ) { + return os << "E2{" << static_cast(v) << "}"; +} +} // end anonymous namespace + +TEST_CASE( "toString(enum)", "[toString][enum]" ) { + Enum1 e0 = Enum1Value0; + CHECK( ::Catch::Detail::stringify(e0) == "0" ); + Enum1 e1 = Enum1Value1; + CHECK( ::Catch::Detail::stringify(e1) == "1" ); +} + +TEST_CASE( "toString(enum w/operator<<)", "[toString][enum]" ) { + Enum2 e0 = Enum2Value0; + CHECK( ::Catch::Detail::stringify(e0) == "E2{0}" ); + Enum2 e1 = Enum2Value1; + CHECK( ::Catch::Detail::stringify(e1) == "E2{1}" ); +} + +// Enum class without user-provided stream operator +namespace { +enum class EnumClass1 { EnumClass1Value0, EnumClass1Value1 }; + +// Enum class with user-provided stream operator +enum class EnumClass2 { EnumClass2Value0, EnumClass2Value1 }; + +std::ostream& operator<<( std::ostream& os, EnumClass2 e2 ) { + switch( static_cast( e2 ) ) { + case static_cast( EnumClass2::EnumClass2Value0 ): + return os << "E2/V0"; + case static_cast( EnumClass2::EnumClass2Value1 ): + return os << "E2/V1"; + default: + return os << "Unknown enum value " << static_cast( e2 ); + } +} + +} // end anonymous namespace + +TEST_CASE( "toString(enum class)", "[toString][enum][enumClass]" ) { + EnumClass1 e0 = EnumClass1::EnumClass1Value0; + CHECK( ::Catch::Detail::stringify(e0) == "0" ); + EnumClass1 e1 = EnumClass1::EnumClass1Value1; + CHECK( ::Catch::Detail::stringify(e1) == "1" ); +} + + +TEST_CASE( "toString(enum class w/operator<<)", "[toString][enum][enumClass]" ) { + EnumClass2 e0 = EnumClass2::EnumClass2Value0; + CHECK( ::Catch::Detail::stringify(e0) == "E2/V0" ); + EnumClass2 e1 = EnumClass2::EnumClass2Value1; + CHECK( ::Catch::Detail::stringify(e1) == "E2/V1" ); + + EnumClass2 e3 = static_cast(10); + CHECK( ::Catch::Detail::stringify(e3) == "Unknown enum value 10" ); +} diff --git a/src/third_party/cppcodec/test/catch/projects/SelfTest/UsageTests/Exception.tests.cpp b/src/third_party/cppcodec/test/catch/projects/SelfTest/UsageTests/Exception.tests.cpp new file mode 100644 index 0000000000..f9c73ed538 --- /dev/null +++ b/src/third_party/cppcodec/test/catch/projects/SelfTest/UsageTests/Exception.tests.cpp @@ -0,0 +1,209 @@ +/* + * Created by Phil on 09/11/2010. + * Copyright 2010 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) + */ + +#include "catch.hpp" + +#include +#include + +#ifdef _MSC_VER +#pragma warning(disable:4702) // Unreachable code -- unconditional throws and so on +#endif +#ifdef __clang__ +#pragma clang diagnostic push +#pragma clang diagnostic ignored "-Wweak-vtables" +#pragma clang diagnostic ignored "-Wmissing-noreturn" +#endif + +namespace { namespace ExceptionTests { + +#ifndef EXCEPTION_TEST_HELPERS_INCLUDED // Don't compile this more than once per TU +#define EXCEPTION_TEST_HELPERS_INCLUDED + +int thisThrows() { + throw std::domain_error( "expected exception" ); + return 1; +} + +int thisDoesntThrow() { + return 0; +} + +class CustomException { +public: + explicit CustomException( const std::string& msg ) + : m_msg( msg ) + {} + + std::string getMessage() const { + return m_msg; + } + +private: + std::string m_msg; +}; + +class CustomStdException : public std::exception { +public: + explicit CustomStdException( const std::string& msg ) + : m_msg( msg ) + {} + ~CustomStdException() noexcept override {} + + std::string getMessage() const { + return m_msg; + } + +private: + std::string m_msg; +}; + +[[noreturn]] void throwCustom() { + throw CustomException( "custom exception - not std" ); +} + +#endif + +TEST_CASE( "When checked exceptions are thrown they can be expected or unexpected", "[!throws]" ) { + REQUIRE_THROWS_AS( thisThrows(), std::domain_error ); + REQUIRE_NOTHROW( thisDoesntThrow() ); + REQUIRE_THROWS( thisThrows() ); +} + +TEST_CASE( "Expected exceptions that don't throw or unexpected exceptions fail the test", "[.][failing][!throws]" ) { + CHECK_THROWS_AS( thisThrows(), std::string ); + CHECK_THROWS_AS( thisDoesntThrow(), std::domain_error ); + CHECK_NOTHROW( thisThrows() ); +} + +TEST_CASE( "When unchecked exceptions are thrown directly they are always failures", "[.][failing][!throws]" ) { + throw std::domain_error( "unexpected exception" ); +} + +TEST_CASE( "An unchecked exception reports the line of the last assertion", "[.][failing][!throws]" ) { + CHECK( 1 == 1 ); + throw std::domain_error( "unexpected exception" ); +} + +TEST_CASE( "When unchecked exceptions are thrown from sections they are always failures", "[.][failing][!throws]" ) { + SECTION( "section name" ) { + throw std::domain_error("unexpected exception"); + } +} + +TEST_CASE( "When unchecked exceptions are thrown from functions they are always failures", "[.][failing][!throws]" ) { + CHECK( thisThrows() == 0 ); +} + +TEST_CASE( "When unchecked exceptions are thrown during a REQUIRE the test should abort fail", "[.][failing][!throws]" ) { + REQUIRE( thisThrows() == 0 ); + FAIL( "This should never happen" ); +} + +TEST_CASE( "When unchecked exceptions are thrown during a CHECK the test should continue", "[.][failing][!throws]" ) { + try { + CHECK(thisThrows() == 0); + } + catch(...) { + FAIL( "This should never happen" ); + } +} + +TEST_CASE( "When unchecked exceptions are thrown, but caught, they do not affect the test", "[!throws]" ) { + try { + throw std::domain_error( "unexpected exception" ); + } + catch(...) {} +} + + +CATCH_TRANSLATE_EXCEPTION( CustomException& ex ) { + return ex.getMessage(); +} + +CATCH_TRANSLATE_EXCEPTION( CustomStdException& ex ) { + return ex.getMessage(); +} + +CATCH_TRANSLATE_EXCEPTION( double& ex ) { + return Catch::Detail::stringify( ex ); +} + +TEST_CASE("Non-std exceptions can be translated", "[.][failing][!throws]" ) { + throw CustomException( "custom exception" ); +} + +TEST_CASE("Custom std-exceptions can be custom translated", "[.][failing][!throws]" ) { + throw CustomException( "custom std exception" ); +} + +TEST_CASE( "Custom exceptions can be translated when testing for nothrow", "[.][failing][!throws]" ) { + REQUIRE_NOTHROW( throwCustom() ); +} + +TEST_CASE( "Custom exceptions can be translated when testing for throwing as something else", "[.][failing][!throws]" ) { + REQUIRE_THROWS_AS( throwCustom(), std::exception ); +} + +TEST_CASE( "Unexpected exceptions can be translated", "[.][failing][!throws]" ) { + throw double( 3.14 ); +} + +TEST_CASE("Thrown string literals are translated", "[.][failing][!throws]") { + throw "For some reason someone is throwing a string literal!"; +} + +TEST_CASE("thrown std::strings are translated", "[.][failing][!throws]") { + throw std::string{ "Why would you throw a std::string?" }; +} + + +#ifndef CATCH_CONFIG_DISABLE_MATCHERS + +TEST_CASE( "Exception messages can be tested for", "[!throws]" ) { + using namespace Catch::Matchers; + SECTION( "exact match" ) + REQUIRE_THROWS_WITH( thisThrows(), "expected exception" ); + SECTION( "different case" ) + REQUIRE_THROWS_WITH( thisThrows(), Equals( "expecteD Exception", Catch::CaseSensitive::No ) ); + SECTION( "wildcarded" ) { + REQUIRE_THROWS_WITH( thisThrows(), StartsWith( "expected" ) ); + REQUIRE_THROWS_WITH( thisThrows(), EndsWith( "exception" ) ); + REQUIRE_THROWS_WITH( thisThrows(), Contains( "except" ) ); + REQUIRE_THROWS_WITH( thisThrows(), Contains( "exCept", Catch::CaseSensitive::No ) ); + } +} + +#endif + +TEST_CASE( "Mismatching exception messages failing the test", "[.][failing][!throws]" ) { + REQUIRE_THROWS_WITH( thisThrows(), "expected exception" ); + REQUIRE_THROWS_WITH( thisThrows(), "should fail" ); + REQUIRE_THROWS_WITH( thisThrows(), "expected exception" ); +} + +TEST_CASE( "#748 - captures with unexpected exceptions", "[.][failing][!throws][!shouldfail]" ) { + int answer = 42; + CAPTURE( answer ); + // the message should be printed on the first two sections but not on the third + SECTION( "outside assertions" ) { + thisThrows(); + } + SECTION( "inside REQUIRE_NOTHROW" ) { + REQUIRE_NOTHROW( thisThrows() ); + } + SECTION( "inside REQUIRE_THROWS" ) { + REQUIRE_THROWS( thisThrows() ); + } +} + +}} // namespace ExceptionTests + +#ifdef __clang__ +#pragma clang diagnostic pop +#endif diff --git a/src/third_party/cppcodec/test/catch/projects/SelfTest/UsageTests/Matchers.tests.cpp b/src/third_party/cppcodec/test/catch/projects/SelfTest/UsageTests/Matchers.tests.cpp new file mode 100644 index 0000000000..71abb8688d --- /dev/null +++ b/src/third_party/cppcodec/test/catch/projects/SelfTest/UsageTests/Matchers.tests.cpp @@ -0,0 +1,432 @@ +/* + * Created by Phil on 21/02/2017. + * Copyright 2017 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) + */ + +#include "catch.hpp" + +#include +#include + +#ifdef __clang__ +#pragma clang diagnostic push +#pragma clang diagnostic ignored "-Wweak-vtables" +#pragma clang diagnostic ignored "-Wpadded" +#endif + +namespace { namespace MatchersTests { + +#ifndef CATCH_CONFIG_DISABLE_MATCHERS + +#ifndef MATCHERS_TEST_HELPERS_INCLUDED // Don't compile this more than once per TU +#define MATCHERS_TEST_HELPERS_INCLUDED + + inline const char *testStringForMatching() { + return "this string contains 'abc' as a substring"; + } + + inline const char *testStringForMatching2() { + return "some completely different text that contains one common word"; + } + + inline bool alwaysTrue(int) { return true; } + inline bool alwaysFalse(int) { return false; } + + +#ifdef _MSC_VER +#pragma warning(disable:4702) // Unreachable code -- MSVC 19 (VS 2015) sees right through the indirection +#endif + +#include + + struct SpecialException : std::exception { + SpecialException(int i_) : i(i_) {} + + char const* what() const noexcept override { + return "SpecialException::what"; + } + + int i; + }; + + void doesNotThrow() {} + + [[noreturn]] + void throws(int i) { + throw SpecialException{i}; + } + + [[noreturn]] + void throwsAsInt(int i) { + throw i; + } + + class ExceptionMatcher : public Catch::MatcherBase { + int m_expected; + public: + ExceptionMatcher(int i) : m_expected(i) {} + + bool match(SpecialException const &se) const override { + return se.i == m_expected; + } + + std::string describe() const override { + std::ostringstream ss; + ss << "special exception has value of " << m_expected; + return ss.str(); + } + }; + +#endif + + using namespace Catch::Matchers; + +#ifdef __DJGPP__ + float nextafter(float from, float to) + { + return ::nextafterf(from, to); + } + + double nextafter(double from, double to) + { + return ::nextafter(from, to); + } +#else + using std::nextafter; +#endif + + TEST_CASE("String matchers", "[matchers]") { + REQUIRE_THAT(testStringForMatching(), Contains("string")); + REQUIRE_THAT(testStringForMatching(), Contains("string", Catch::CaseSensitive::No)); + CHECK_THAT(testStringForMatching(), Contains("abc")); + CHECK_THAT(testStringForMatching(), Contains("aBC", Catch::CaseSensitive::No)); + + CHECK_THAT(testStringForMatching(), StartsWith("this")); + CHECK_THAT(testStringForMatching(), StartsWith("THIS", Catch::CaseSensitive::No)); + CHECK_THAT(testStringForMatching(), EndsWith("substring")); + CHECK_THAT(testStringForMatching(), EndsWith(" SuBsTrInG", Catch::CaseSensitive::No)); + } + + TEST_CASE("Contains string matcher", "[.][failing][matchers]") { + CHECK_THAT(testStringForMatching(), Contains("not there", Catch::CaseSensitive::No)); + CHECK_THAT(testStringForMatching(), Contains("STRING")); + } + + TEST_CASE("StartsWith string matcher", "[.][failing][matchers]") { + CHECK_THAT(testStringForMatching(), StartsWith("This String")); + CHECK_THAT(testStringForMatching(), StartsWith("string", Catch::CaseSensitive::No)); + } + + TEST_CASE("EndsWith string matcher", "[.][failing][matchers]") { + CHECK_THAT(testStringForMatching(), EndsWith("Substring")); + CHECK_THAT(testStringForMatching(), EndsWith("this", Catch::CaseSensitive::No)); + } + + TEST_CASE("Equals string matcher", "[.][failing][matchers]") { + CHECK_THAT(testStringForMatching(), Equals("this string contains 'ABC' as a substring")); + CHECK_THAT(testStringForMatching(), Equals("something else", Catch::CaseSensitive::No)); + } + + TEST_CASE("Equals", "[matchers]") { + CHECK_THAT(testStringForMatching(), Equals("this string contains 'abc' as a substring")); + CHECK_THAT(testStringForMatching(), + Equals("this string contains 'ABC' as a substring", Catch::CaseSensitive::No)); + } + +// does not work in libstdc++ 4.8, so we have to enable these tests only when they +// are expected to pass and cannot have them in baselines + TEST_CASE("Regex string matcher -- libstdc++-4.8 workaround", "[matchers][approvals]") { + +// This is fiiiine +// Taken from an answer at +// https://stackoverflow.com/questions/12530406/is-gcc-4-8-or-earlier-buggy-about-regular-expressions +#if (!defined(__GNUC__)) || \ + (__cplusplus >= 201103L && \ + (!defined(__GLIBCXX__) || (__cplusplus >= 201402L) || \ + (defined(_GLIBCXX_REGEX_DFS_QUANTIFIERS_LIMIT) || \ + defined(_GLIBCXX_REGEX_STATE_LIMIT) || \ + (defined(_GLIBCXX_RELEASE) && \ + _GLIBCXX_RELEASE > 4)))) + +// DJGPP meets the above condition but does not work properly anyway +#ifndef __DJGPP__ + REQUIRE_THAT(testStringForMatching(), Matches("this string contains 'abc' as a substring")); + REQUIRE_THAT(testStringForMatching(), + Matches("this string CONTAINS 'abc' as a substring", Catch::CaseSensitive::No)); + REQUIRE_THAT(testStringForMatching(), Matches("^this string contains 'abc' as a substring$")); + REQUIRE_THAT(testStringForMatching(), Matches("^.* 'abc' .*$")); + REQUIRE_THAT(testStringForMatching(), Matches("^.* 'ABC' .*$", Catch::CaseSensitive::No)); +#endif + +#endif + + REQUIRE_THAT(testStringForMatching2(), !Matches("this string contains 'abc' as a substring")); + } + + TEST_CASE("Regex string matcher", "[matchers][.failing]") { + CHECK_THAT(testStringForMatching(), Matches("this STRING contains 'abc' as a substring")); + CHECK_THAT(testStringForMatching(), Matches("contains 'abc' as a substring")); + CHECK_THAT(testStringForMatching(), Matches("this string contains 'abc' as a")); + } + + TEST_CASE("Matchers can be (AllOf) composed with the && operator", "[matchers][operators][operator&&]") { + CHECK_THAT(testStringForMatching(), + Contains("string") && + Contains("abc") && + Contains("substring") && + Contains("contains")); + } + + TEST_CASE("Matchers can be (AnyOf) composed with the || operator", "[matchers][operators][operator||]") { + CHECK_THAT(testStringForMatching(), Contains("string") || Contains("different") || Contains("random")); + CHECK_THAT(testStringForMatching2(), Contains("string") || Contains("different") || Contains("random")); + } + + TEST_CASE("Matchers can be composed with both && and ||", "[matchers][operators][operator||][operator&&]") { + CHECK_THAT(testStringForMatching(), (Contains("string") || Contains("different")) && Contains("substring")); + } + + TEST_CASE("Matchers can be composed with both && and || - failing", + "[matchers][operators][operator||][operator&&][.failing]") { + CHECK_THAT(testStringForMatching(), (Contains("string") || Contains("different")) && Contains("random")); + } + + TEST_CASE("Matchers can be negated (Not) with the ! operator", "[matchers][operators][not]") { + CHECK_THAT(testStringForMatching(), !Contains("different")); + } + + TEST_CASE("Matchers can be negated (Not) with the ! operator - failing", + "[matchers][operators][not][.failing]") { + CHECK_THAT(testStringForMatching(), !Contains("substring")); + } + + TEST_CASE("Vector matchers", "[matchers][vector]") { + std::vector v; + v.push_back(1); + v.push_back(2); + v.push_back(3); + + std::vector v2; + v2.push_back(1); + v2.push_back(2); + + std::vector empty; + + SECTION("Contains (element)") { + CHECK_THAT(v, VectorContains(1)); + CHECK_THAT(v, VectorContains(2)); + } + SECTION("Contains (vector)") { + CHECK_THAT(v, Contains(v2)); + v2.push_back(3); // now exactly matches + CHECK_THAT(v, Contains(v2)); + + CHECK_THAT(v, Contains(empty)); + CHECK_THAT(empty, Contains(empty)); + } + SECTION("Contains (element), composed") { + CHECK_THAT(v, VectorContains(1) && VectorContains(2)); + } + + SECTION("Equals") { + + // Same vector + CHECK_THAT(v, Equals(v)); + + CHECK_THAT(empty, Equals(empty)); + + // Different vector with same elements + v2.push_back(3); + CHECK_THAT(v, Equals(v2)); + } + SECTION("UnorderedEquals") { + CHECK_THAT(v, UnorderedEquals(v)); + CHECK_THAT(empty, UnorderedEquals(empty)); + + auto permuted = v; + std::next_permutation(begin(permuted), end(permuted)); + REQUIRE_THAT(permuted, UnorderedEquals(v)); + + std::reverse(begin(permuted), end(permuted)); + REQUIRE_THAT(permuted, UnorderedEquals(v)); + } + } + + TEST_CASE("Vector matchers that fail", "[matchers][vector][.][failing]") { + std::vector v; + v.push_back(1); + v.push_back(2); + v.push_back(3); + + std::vector v2; + v2.push_back(1); + v2.push_back(2); + + std::vector empty; + + SECTION("Contains (element)") { + CHECK_THAT(v, VectorContains(-1)); + CHECK_THAT(empty, VectorContains(1)); + } + SECTION("Contains (vector)") { + CHECK_THAT(empty, Contains(v)); + v2.push_back(4); + CHECK_THAT(v, Contains(v2)); + } + + SECTION("Equals") { + + CHECK_THAT(v, Equals(v2)); + CHECK_THAT(v2, Equals(v)); + CHECK_THAT(empty, Equals(v)); + CHECK_THAT(v, Equals(empty)); + } + SECTION("UnorderedEquals") { + CHECK_THAT(v, UnorderedEquals(empty)); + CHECK_THAT(empty, UnorderedEquals(v)); + + auto permuted = v; + std::next_permutation(begin(permuted), end(permuted)); + permuted.pop_back(); + CHECK_THAT(permuted, UnorderedEquals(v)); + + std::reverse(begin(permuted), end(permuted)); + CHECK_THAT(permuted, UnorderedEquals(v)); + } + } + + TEST_CASE("Exception matchers that succeed", "[matchers][exceptions][!throws]") { + CHECK_THROWS_MATCHES(throws(1), SpecialException, ExceptionMatcher{1}); + REQUIRE_THROWS_MATCHES(throws(2), SpecialException, ExceptionMatcher{2}); + } + + TEST_CASE("Exception matchers that fail", "[matchers][exceptions][!throws][.failing]") { + SECTION("No exception") { + CHECK_THROWS_MATCHES(doesNotThrow(), SpecialException, ExceptionMatcher{1}); + REQUIRE_THROWS_MATCHES(doesNotThrow(), SpecialException, ExceptionMatcher{1}); + } + SECTION("Type mismatch") { + CHECK_THROWS_MATCHES(throwsAsInt(1), SpecialException, ExceptionMatcher{1}); + REQUIRE_THROWS_MATCHES(throwsAsInt(1), SpecialException, ExceptionMatcher{1}); + } + SECTION("Contents are wrong") { + CHECK_THROWS_MATCHES(throws(3), SpecialException, ExceptionMatcher{1}); + REQUIRE_THROWS_MATCHES(throws(4), SpecialException, ExceptionMatcher{1}); + } + } + + TEST_CASE("Floating point matchers: float", "[matchers][floating-point]") { + SECTION("Margin") { + REQUIRE_THAT(1.f, WithinAbs(1.f, 0)); + REQUIRE_THAT(0.f, WithinAbs(1.f, 1)); + + REQUIRE_THAT(0.f, !WithinAbs(1.f, 0.99f)); + REQUIRE_THAT(0.f, !WithinAbs(1.f, 0.99f)); + + REQUIRE_THAT(0.f, WithinAbs(-0.f, 0)); + REQUIRE_THAT(NAN, !WithinAbs(NAN, 0)); + + REQUIRE_THAT(11.f, !WithinAbs(10.f, 0.5f)); + REQUIRE_THAT(10.f, !WithinAbs(11.f, 0.5f)); + REQUIRE_THAT(-10.f, WithinAbs(-10.f, 0.5f)); + REQUIRE_THAT(-10.f, WithinAbs(-9.6f, 0.5f)); + } + SECTION("ULPs") { + REQUIRE_THAT(1.f, WithinULP(1.f, 0)); + + REQUIRE_THAT(nextafter(1.f, 2.f), WithinULP(1.f, 1)); + REQUIRE_THAT(nextafter(1.f, 0.f), WithinULP(1.f, 1)); + REQUIRE_THAT(nextafter(1.f, 2.f), !WithinULP(1.f, 0)); + + REQUIRE_THAT(1.f, WithinULP(1.f, 0)); + REQUIRE_THAT(-0.f, WithinULP(0.f, 0)); + + REQUIRE_THAT(NAN, !WithinULP(NAN, 123)); + } + SECTION("Composed") { + REQUIRE_THAT(1.f, WithinAbs(1.f, 0.5) || WithinULP(1.f, 1)); + REQUIRE_THAT(1.f, WithinAbs(2.f, 0.5) || WithinULP(1.f, 0)); + + REQUIRE_THAT(NAN, !(WithinAbs(NAN, 100) || WithinULP(NAN, 123))); + } + SECTION("Constructor validation") { + REQUIRE_NOTHROW(WithinAbs(1.f, 0.f)); + REQUIRE_THROWS_AS(WithinAbs(1.f, -1.f), std::domain_error); + + REQUIRE_NOTHROW(WithinULP(1.f, 0)); + REQUIRE_THROWS_AS(WithinULP(1.f, -1), std::domain_error); + } + } + + TEST_CASE("Floating point matchers: double", "[matchers][floating-point]") { + SECTION("Margin") { + REQUIRE_THAT(1., WithinAbs(1., 0)); + REQUIRE_THAT(0., WithinAbs(1., 1)); + + REQUIRE_THAT(0., !WithinAbs(1., 0.99)); + REQUIRE_THAT(0., !WithinAbs(1., 0.99)); + + REQUIRE_THAT(NAN, !WithinAbs(NAN, 0)); + + REQUIRE_THAT(11., !WithinAbs(10., 0.5)); + REQUIRE_THAT(10., !WithinAbs(11., 0.5)); + REQUIRE_THAT(-10., WithinAbs(-10., 0.5)); + REQUIRE_THAT(-10., WithinAbs(-9.6, 0.5)); + } + SECTION("ULPs") { + REQUIRE_THAT(1., WithinULP(1., 0)); + + REQUIRE_THAT(nextafter(1., 2.), WithinULP(1., 1)); + REQUIRE_THAT(nextafter(1., 0.), WithinULP(1., 1)); + REQUIRE_THAT(nextafter(1., 2.), !WithinULP(1., 0)); + + REQUIRE_THAT(1., WithinULP(1., 0)); + REQUIRE_THAT(-0., WithinULP(0., 0)); + + REQUIRE_THAT(NAN, !WithinULP(NAN, 123)); + } + SECTION("Composed") { + REQUIRE_THAT(1., WithinAbs(1., 0.5) || WithinULP(2., 1)); + REQUIRE_THAT(1., WithinAbs(2., 0.5) || WithinULP(1., 0)); + + REQUIRE_THAT(NAN, !(WithinAbs(NAN, 100) || WithinULP(NAN, 123))); + } + SECTION("Constructor validation") { + REQUIRE_NOTHROW(WithinAbs(1., 0.)); + REQUIRE_THROWS_AS(WithinAbs(1., -1.), std::domain_error); + + REQUIRE_NOTHROW(WithinULP(1., 0)); + REQUIRE_THROWS_AS(WithinULP(1., -1), std::domain_error); + } + } + + TEST_CASE("Arbitrary predicate matcher", "[matchers][generic]") { + SECTION("Function pointer") { + REQUIRE_THAT(1, Predicate(alwaysTrue, "always true")); + REQUIRE_THAT(1, !Predicate(alwaysFalse, "always false")); + } + SECTION("Lambdas + different type") { + REQUIRE_THAT("Hello olleH", + Predicate( + [] (std::string const& str) -> bool { return str.front() == str.back(); }, + "First and last character should be equal") + ); + + REQUIRE_THAT("This wouldn't pass", + !Predicate( + [] (std::string const& str) -> bool { return str.front() == str.back(); } + ) + ); + } + } + +} } // namespace MatchersTests + +#endif // CATCH_CONFIG_DISABLE_MATCHERS + +#ifdef __clang__ +#pragma clang diagnostic pop +#endif diff --git a/src/third_party/cppcodec/test/catch/projects/SelfTest/UsageTests/Message.tests.cpp b/src/third_party/cppcodec/test/catch/projects/SelfTest/UsageTests/Message.tests.cpp new file mode 100644 index 0000000000..f3ac02a1fa --- /dev/null +++ b/src/third_party/cppcodec/test/catch/projects/SelfTest/UsageTests/Message.tests.cpp @@ -0,0 +1,137 @@ +/* + * Created by Phil on 09/11/2010. + * Copyright 2010 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) + */ + +#include "catch.hpp" +#include + +#ifdef __clang__ +#pragma clang diagnostic ignored "-Wc++98-compat-pedantic" +#endif + +TEST_CASE( "INFO and WARN do not abort tests", "[messages][.]" ) { + INFO( "this is a " << "message" ); // This should output the message if a failure occurs + WARN( "this is a " << "warning" ); // This should always output the message but then continue +} + +TEST_CASE( "SUCCEED counts as a test pass", "[messages]" ) { + SUCCEED( "this is a " << "success" ); +} + +TEST_CASE( "INFO gets logged on failure", "[failing][messages][.]" ) { + INFO( "this message should be logged" ); + INFO( "so should this" ); + int a = 2; + REQUIRE( a == 1 ); +} + +TEST_CASE( "INFO gets logged on failure, even if captured before successful assertions", "[failing][messages][.]" ) { + INFO( "this message may be logged later" ); + int a = 2; + CHECK( a == 2 ); + + INFO( "this message should be logged" ); + + CHECK( a == 1 ); + + INFO( "and this, but later" ); + + CHECK( a == 0 ); + + INFO( "but not this" ); + + CHECK( a == 2 ); +} + +TEST_CASE( "FAIL aborts the test", "[failing][messages][.]" ) { + FAIL( "This is a " << "failure" ); // This should output the message and abort + WARN( "We should never see this"); +} + +TEST_CASE( "FAIL_CHECK does not abort the test", "[failing][messages][.]" ) { + FAIL_CHECK( "This is a " << "failure" ); // This should output the message then continue + WARN( "This message appears in the output"); +} + +TEST_CASE( "FAIL does not require an argument", "[failing][messages][.]" ) { + FAIL(); +} + +TEST_CASE( "SUCCEED does not require an argument", "[messages][.]" ) { + SUCCEED(); +} + +TEST_CASE( "Output from all sections is reported", "[failing][messages][.]" ) { + SECTION( "one" ) { + FAIL( "Message from section one" ); + } + + SECTION( "two" ) { + FAIL( "Message from section two" ); + } +} + +TEST_CASE( "Standard output from all sections is reported", "[messages][.]" ) { + SECTION( "one" ) { + std::cout << "Message from section one" << std::endl; + } + + SECTION( "two" ) { + std::cout << "Message from section two" << std::endl; + } +} + +TEST_CASE( "Standard error is reported and redirected", "[messages][.][approvals]" ) { + SECTION( "std::cerr" ) { + std::cerr << "Write to std::cerr" << std::endl; + } + SECTION( "std::clog" ) { + std::clog << "Write to std::clog" << std::endl; + } + SECTION( "Interleaved writes to cerr and clog" ) { + std::cerr << "Inter"; + std::clog << "leaved"; + std::cerr << ' '; + std::clog << "writes"; + std::cerr << " to error"; + std::clog << " streams" << std::endl; + } +} + +TEST_CASE( "INFO is reset for each loop", "[messages][failing][.]" ) { + for( int i=0; i<100; i++ ) + { + INFO( "current counter " << i ); + CAPTURE( i ); + REQUIRE( i < 10 ); + } +} + +TEST_CASE( "The NO_FAIL macro reports a failure but does not fail the test", "[messages]" ) { + CHECK_NOFAIL( 1 == 2 ); +} + +TEST_CASE( "just info", "[info][isolated info][messages]" ) { + INFO( "this should never be seen" ); +} +TEST_CASE( "just failure", "[fail][isolated info][.][messages]" ) { + FAIL( "Previous info should not be seen" ); +} + + +TEST_CASE( "sends information to INFO", "[.][failing]" ) { + INFO( "hi" ); + int i = 7; + CAPTURE( i ); + REQUIRE( false ); +} + +TEST_CASE( "Pointers can be converted to strings", "[messages][.][approvals]" ) { + int p; + WARN( "actual address of p: " << &p ); + WARN( "toString(p): " << ::Catch::Detail::stringify( &p ) ); +} diff --git a/src/third_party/cppcodec/test/catch/projects/SelfTest/UsageTests/Misc.tests.cpp b/src/third_party/cppcodec/test/catch/projects/SelfTest/UsageTests/Misc.tests.cpp new file mode 100644 index 0000000000..820e801976 --- /dev/null +++ b/src/third_party/cppcodec/test/catch/projects/SelfTest/UsageTests/Misc.tests.cpp @@ -0,0 +1,356 @@ +/* + * Created by Phil on 29/11/2010. + * Copyright 2010 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) + */ + +#include "catch.hpp" + +#ifdef __clang__ +# pragma clang diagnostic ignored "-Wc++98-compat" +# pragma clang diagnostic ignored "-Wc++98-compat-pedantic" +#endif + + +#include +#include +#include +#include + +namespace { namespace MiscTests { + +#ifndef MISC_TEST_HELPERS_INCLUDED // Don't compile this more than once per TU +#define MISC_TEST_HELPERS_INCLUDED + +inline const char* makeString( bool makeNull ) { + return makeNull ? nullptr : "valid string"; +} +inline bool testCheckedIf( bool flag ) { + CHECKED_IF( flag ) + return true; + else + return false; +} +inline bool testCheckedElse( bool flag ) { + CHECKED_ELSE( flag ) + return false; + + return true; +} + +inline unsigned int Factorial( unsigned int number ) { + return number > 1 ? Factorial(number-1)*number : 1; +} + +static int f() { + return 1; +} + +inline void manuallyRegisteredTestFunction() { + SUCCEED( "was called" ); +} + +struct AutoTestReg { + AutoTestReg() { + REGISTER_TEST_CASE( manuallyRegisteredTestFunction, "ManuallyRegistered" ); + } +}; +CATCH_INTERNAL_SUPPRESS_GLOBALS_WARNINGS +static AutoTestReg autoTestReg; +CATCH_INTERNAL_UNSUPPRESS_GLOBALS_WARNINGS + +#endif + +TEST_CASE( "random SECTION tests", "[.][sections][failing]" ) { + int a = 1; + int b = 2; + + SECTION( "doesn't equal" ) { + REQUIRE( a != b ); + REQUIRE( b != a ); + } + + SECTION( "not equal" ) { + REQUIRE( a != b); + } +} + +TEST_CASE( "nested SECTION tests", "[.][sections][failing]" ) { + int a = 1; + int b = 2; + + SECTION( "doesn't equal" ) { + REQUIRE( a != b ); + REQUIRE( b != a ); + + SECTION( "not equal" ) { + REQUIRE( a != b); + } + } +} + +TEST_CASE( "more nested SECTION tests", "[sections][failing][.]" ) { + int a = 1; + int b = 2; + + SECTION( "doesn't equal" ) { + SECTION( "equal" ) { + REQUIRE( a == b ); + } + + SECTION( "not equal" ) { + REQUIRE( a != b ); + } + SECTION( "less than" ) { + REQUIRE( a < b ); + } + } +} + +TEST_CASE( "even more nested SECTION tests", "[sections]" ) { + SECTION( "c" ) { + SECTION( "d (leaf)" ) { + SUCCEED(); // avoid failing due to no tests + } + + SECTION( "e (leaf)" ) { + SUCCEED(); // avoid failing due to no tests + } + } + + SECTION( "f (leaf)" ) { + SUCCEED(); // avoid failing due to no tests + } +} + +TEST_CASE( "looped SECTION tests", "[.][failing][sections]" ) { + int a = 1; + + for( int b = 0; b < 10; ++b ) { + DYNAMIC_SECTION( "b is currently: " << b ) { + CHECK( b > a ); + } + } +} + +TEST_CASE( "looped tests", "[.][failing]" ) { + static const int fib[] = { 1, 1, 2, 3, 5, 8, 13, 21 }; + + for( std::size_t i=0; i < sizeof(fib)/sizeof(int); ++i ) { + INFO( "Testing if fib[" << i << "] (" << fib[i] << ") is even" ); + CHECK( ( fib[i] % 2 ) == 0 ); + } +} + +TEST_CASE( "Sends stuff to stdout and stderr", "[.]" ) { + std::cout << "A string sent directly to stdout" << std::endl; + std::cerr << "A string sent directly to stderr" << std::endl; + std::clog << "A string sent to stderr via clog" << std::endl; +} + +TEST_CASE( "null strings" ) { + REQUIRE( makeString( false ) != static_cast(nullptr)); + REQUIRE( makeString( true ) == static_cast(nullptr)); +} + +TEST_CASE( "checkedIf" ) { + REQUIRE( testCheckedIf( true ) ); +} + +TEST_CASE( "checkedIf, failing", "[failing][.]" ) { + REQUIRE( testCheckedIf( false ) ); +} + +TEST_CASE( "checkedElse" ) { + REQUIRE( testCheckedElse( true ) ); +} + +TEST_CASE( "checkedElse, failing", "[failing][.]" ) { + REQUIRE( testCheckedElse( false ) ); +} + +TEST_CASE( "xmlentitycheck" ) { + SECTION( "embedded xml: it should be possible to embed xml characters, such as <, \" or &, or even whole documents within an attribute" ) { + SUCCEED(); // We need this here to stop it failing due to no tests + } + SECTION( "encoded chars: these should all be encoded: &&&\"\"\"<<<&\"<<&\"" ) { + SUCCEED(); // We need this here to stop it failing due to no tests + } +} + +TEST_CASE( "send a single char to INFO", "[failing][.]" ) { + INFO(3); + REQUIRE(false); +} + +TEST_CASE( "atomic if", "[failing][0]") { + std::size_t x = 0; + + if( x ) + REQUIRE(x > 0); + else + REQUIRE(x == 0); +} + + +TEST_CASE( "Factorials are computed", "[factorial]" ) { + REQUIRE( Factorial(0) == 1 ); + REQUIRE( Factorial(1) == 1 ); + REQUIRE( Factorial(2) == 2 ); + REQUIRE( Factorial(3) == 6 ); + REQUIRE( Factorial(10) == 3628800 ); +} + +TEST_CASE( "An empty test with no assertions", "[empty]" ) {} + +TEST_CASE( "Nice descriptive name", "[tag1][tag2][tag3][.]" ) { + WARN( "This one ran" ); +} +TEST_CASE( "first tag", "[tag1]" ) {} +TEST_CASE( "second tag", "[tag2]" ) {} + +// +//TEST_CASE( "spawn a new process", "[.]" ) +//{ +// // !TBD Work in progress +// char line[200]; +// FILE* output = popen("./CatchSelfTest ./failing/matchers/StartsWith", "r"); +// while ( fgets(line, 199, output) ) +// std::cout << line; +//} + +TEST_CASE( "vectors can be sized and resized", "[vector]" ) { + + std::vector v( 5 ); + + REQUIRE( v.size() == 5 ); + REQUIRE( v.capacity() >= 5 ); + + SECTION( "resizing bigger changes size and capacity" ) { + v.resize( 10 ); + + REQUIRE( v.size() == 10 ); + REQUIRE( v.capacity() >= 10 ); + } + SECTION( "resizing smaller changes size but not capacity" ) { + v.resize( 0 ); + + REQUIRE( v.size() == 0 ); + REQUIRE( v.capacity() >= 5 ); + + SECTION( "We can use the 'swap trick' to reset the capacity" ) { + std::vector empty; + empty.swap( v ); + + REQUIRE( v.capacity() == 0 ); + } + } + SECTION( "reserving bigger changes capacity but not size" ) { + v.reserve( 10 ); + + REQUIRE( v.size() == 5 ); + REQUIRE( v.capacity() >= 10 ); + } + SECTION( "reserving smaller does not change size or capacity" ) { + v.reserve( 0 ); + + REQUIRE( v.size() == 5 ); + REQUIRE( v.capacity() >= 5 ); + } +} + +// https://github.com/philsquared/Catch/issues/166 +TEST_CASE("A couple of nested sections followed by a failure", "[failing][.]") { + SECTION("Outer") + SECTION("Inner") + SUCCEED("that's not flying - that's failing in style"); + + FAIL("to infinity and beyond"); +} + +TEST_CASE("not allowed", "[!throws]") { + // This test case should not be included if you run with -e on the command line + SUCCEED(); +} + +//TEST_CASE( "Is big endian" ) { +// CHECK( Catch::Detail::Endianness::which() == Catch::Detail::Endianness::Little ); +//} + +TEST_CASE( "Tabs and newlines show in output", "[.][whitespace][failing]" ) { + + // Based on issue #242 + std::string s1 = "if ($b == 10) {\n\t\t$a\t= 20;\n}"; + std::string s2 = "if ($b == 10) {\n\t$a = 20;\n}\n"; + CHECK( s1 == s2 ); +} + + +#ifdef CATCH_CONFIG_WCHAR +TEST_CASE( "toString on const wchar_t const pointer returns the string contents", "[toString]" ) { + const wchar_t * const s = L"wide load"; + std::string result = ::Catch::Detail::stringify( s ); + CHECK( result == "\"wide load\"" ); +} + +TEST_CASE( "toString on const wchar_t pointer returns the string contents", "[toString]" ) { + const wchar_t * s = L"wide load"; + std::string result = ::Catch::Detail::stringify( s ); + CHECK( result == "\"wide load\"" ); +} + +TEST_CASE( "toString on wchar_t const pointer returns the string contents", "[toString]" ) { + auto const s = const_cast( L"wide load" ); + std::string result = ::Catch::Detail::stringify( s ); + CHECK( result == "\"wide load\"" ); +} + +TEST_CASE( "toString on wchar_t returns the string contents", "[toString]" ) { + auto s = const_cast( L"wide load" ); + std::string result = ::Catch::Detail::stringify( s ); + CHECK( result == "\"wide load\"" ); +} +#endif + +TEST_CASE( "long long" ) { + long long l = std::numeric_limits::max(); + + REQUIRE( l == std::numeric_limits::max() ); +} + +//TEST_CASE( "Divide by Zero signal handler", "[.][sig]" ) { +// int i = 0; +// int x = 10/i; // This should cause the signal to fire +// CHECK( x == 0 ); +//} + +TEST_CASE( "This test 'should' fail but doesn't", "[.][failing][!shouldfail]" ) { + SUCCEED( "oops!" ); +} + +TEST_CASE( "# A test name that starts with a #" ) { + SUCCEED( "yay" ); +} + +TEST_CASE( "#835 -- errno should not be touched by Catch", "[.][failing][!shouldfail]" ) { + errno = 1; + CHECK(f() == 0); + REQUIRE(errno == 1); // Check that f() doesn't touch errno. +} + +TEST_CASE( "#961 -- Dynamically created sections should all be reported", "[.]" ) { + for (char i = '0'; i < '5'; ++i) { + SECTION(std::string("Looped section ") + i) { + SUCCEED( "Everything is OK" ); + } + } +} + +TEST_CASE( "#1175 - Hidden Test", "[.]" ) { + // Just for checking that hidden test is not listed by default + SUCCEED(); +} + +}} // namespace MiscTests diff --git a/src/third_party/cppcodec/test/catch/projects/SelfTest/UsageTests/ToStringChrono.tests.cpp b/src/third_party/cppcodec/test/catch/projects/SelfTest/UsageTests/ToStringChrono.tests.cpp new file mode 100644 index 0000000000..c2c0829f02 --- /dev/null +++ b/src/third_party/cppcodec/test/catch/projects/SelfTest/UsageTests/ToStringChrono.tests.cpp @@ -0,0 +1,44 @@ +#define CATCH_CONFIG_ENABLE_CHRONO_STRINGMAKER +#include "catch.hpp" + +#include +#include + +TEST_CASE("Stringifying std::chrono::duration helpers", "[toString][chrono]") { + // No literals because we still support c++11 + auto hour = std::chrono::hours(1); + auto minute = std::chrono::minutes(1); + auto seconds = std::chrono::seconds(60); + auto micro = std::chrono::microseconds(1); + auto milli = std::chrono::milliseconds(1); + auto nano = std::chrono::nanoseconds(1); + REQUIRE(minute == seconds); + REQUIRE(hour != seconds); + REQUIRE(micro != milli); + REQUIRE(nano != micro); +} + +TEST_CASE("Stringifying std::chrono::duration with weird ratios", "[toString][chrono]") { + std::chrono::duration> half_minute(1); + std::chrono::duration> pico_second(1); + std::chrono::duration> femto_second(1); + std::chrono::duration> atto_second(1); + REQUIRE(half_minute != femto_second); + REQUIRE(pico_second != atto_second); +} + +TEST_CASE("Stringifying std::chrono::time_point", "[toString][chrono]") { + auto now = std::chrono::system_clock::now(); + auto later = now + std::chrono::minutes(2); + REQUIRE(now != later); +} + +TEST_CASE("Stringifying std::chrono::time_point", "[toString][chrono][!nonportable]") { + auto now = std::chrono::high_resolution_clock::now(); + auto later = now + std::chrono::minutes(2); + REQUIRE(now != later); + + auto now2 = std::chrono::steady_clock::now(); + auto later2 = now2 + std::chrono::minutes(2); + REQUIRE(now2 != later2); +} diff --git a/src/third_party/cppcodec/test/catch/projects/SelfTest/UsageTests/ToStringGeneral.tests.cpp b/src/third_party/cppcodec/test/catch/projects/SelfTest/UsageTests/ToStringGeneral.tests.cpp new file mode 100644 index 0000000000..3f6fa05f7a --- /dev/null +++ b/src/third_party/cppcodec/test/catch/projects/SelfTest/UsageTests/ToStringGeneral.tests.cpp @@ -0,0 +1,164 @@ +/* + * Created by Martin on 17/02/2017. + * + * 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) + */ + +#define CATCH_CONFIG_ENABLE_PAIR_STRINGMAKER +#include "catch.hpp" + +#include +#include + +TEST_CASE( "Character pretty printing" ){ + SECTION("Specifically escaped"){ + char tab = '\t'; + char newline = '\n'; + char carr_return = '\r'; + char form_feed = '\f'; + CHECK(tab == '\t'); + CHECK(newline == '\n'); + CHECK(carr_return == '\r'); + CHECK(form_feed == '\f'); + } + SECTION("General chars"){ + char space = ' '; + CHECK(space == ' '); + char chars[] = {'a', 'z', 'A', 'Z'}; + for (int i = 0; i < 4; ++i){ + char c = chars[i]; + REQUIRE(c == chars[i]); + } + } + SECTION("Low ASCII"){ + char null_terminator = '\0'; + CHECK(null_terminator == '\0'); + for (int i = 2; i < 6; ++i){ + char c = static_cast(i); + REQUIRE(c == i); + } + } +} + + +TEST_CASE( "Capture and info messages" ) { + SECTION("Capture should stringify like assertions") { + int i = 2; + CAPTURE(i); + REQUIRE(true); + } + SECTION("Info should NOT stringify the way assertions do") { + int i = 3; + INFO(i); + REQUIRE(true); + } +} + +TEST_CASE( "std::map is convertible string", "[toString]" ) { + + SECTION( "empty" ) { + std::map emptyMap; + + REQUIRE( Catch::Detail::stringify( emptyMap ) == "{ }" ); + } + + SECTION( "single item" ) { + std::map map = { { "one", 1 } }; + + REQUIRE( Catch::Detail::stringify( map ) == "{ { \"one\", 1 } }" ); + } + + SECTION( "several items" ) { + std::map map = { + { "abc", 1 }, + { "def", 2 }, + { "ghi", 3 } + }; + + REQUIRE( Catch::Detail::stringify( map ) == "{ { \"abc\", 1 }, { \"def\", 2 }, { \"ghi\", 3 } }" ); + } +} + +TEST_CASE( "std::set is convertible string", "[toString]" ) { + + SECTION( "empty" ) { + std::set emptySet; + + REQUIRE( Catch::Detail::stringify( emptySet ) == "{ }" ); + } + + SECTION( "single item" ) { + std::set set = { "one" }; + + REQUIRE( Catch::Detail::stringify( set ) == "{ \"one\" }" ); + } + + SECTION( "several items" ) { + std::set set = { "abc", "def", "ghi" }; + + REQUIRE( Catch::Detail::stringify( set ) == "{ \"abc\", \"def\", \"ghi\" }" ); + } +} + +TEST_CASE("Static arrays are convertible to string", "[toString]") { + SECTION("Single item") { + int singular[1] = { 1 }; + REQUIRE(Catch::Detail::stringify(singular) == "{ 1 }"); + } + SECTION("Multiple") { + int arr[3] = { 3, 2, 1 }; + REQUIRE(Catch::Detail::stringify(arr) == "{ 3, 2, 1 }"); + } + SECTION("Non-trivial inner items") { + std::vector arr[2] = { {"1:1", "1:2", "1:3"}, {"2:1", "2:2"} }; + REQUIRE(Catch::Detail::stringify(arr) == R"({ { "1:1", "1:2", "1:3" }, { "2:1", "2:2" } })"); + } +} + +namespace { + +struct WhatException : std::exception { + char const* what() const noexcept override { + return "This exception has overriden what() method"; + } + ~WhatException() override; +}; + +struct OperatorException : std::exception { + ~OperatorException() override; +}; + +std::ostream& operator<<(std::ostream& out, OperatorException const&) { + out << "OperatorException"; + return out; +} + +struct StringMakerException : std::exception { + ~StringMakerException() override; +}; + +} // end anonymous namespace + +namespace Catch { +template <> +struct StringMaker { + static std::string convert(StringMakerException const&) { + return "StringMakerException"; + } +}; +} + +// Avoid -Wweak-tables +WhatException::~WhatException() = default; +OperatorException::~OperatorException() = default; +StringMakerException::~StringMakerException() = default; + + + + +TEST_CASE("Exception as a value (e.g. in REQUIRE_THROWS_MATCHES) can be stringified", "[toString][exception]") { + REQUIRE(::Catch::Detail::stringify(WhatException{}) == "This exception has overriden what() method"); + REQUIRE(::Catch::Detail::stringify(OperatorException{}) == "OperatorException"); + REQUIRE(::Catch::Detail::stringify(StringMakerException{}) == "StringMakerException"); +} diff --git a/src/third_party/cppcodec/test/catch/projects/SelfTest/UsageTests/ToStringPair.tests.cpp b/src/third_party/cppcodec/test/catch/projects/SelfTest/UsageTests/ToStringPair.tests.cpp new file mode 100644 index 0000000000..1445c54f75 --- /dev/null +++ b/src/third_party/cppcodec/test/catch/projects/SelfTest/UsageTests/ToStringPair.tests.cpp @@ -0,0 +1,30 @@ +#define CATCH_CONFIG_ENABLE_PAIR_STRINGMAKER +#include "catch.hpp" + +TEST_CASE( "std::pair -> toString", "[toString][pair]" ) { + std::pair value( 34, "xyzzy" ); + REQUIRE( ::Catch::Detail::stringify( value ) == "{ 34, \"xyzzy\" }" ); +} + +TEST_CASE( "std::pair -> toString", "[toString][pair]" ) { + std::pair value( 34, "xyzzy" ); + REQUIRE( ::Catch::Detail::stringify(value) == "{ 34, \"xyzzy\" }" ); +} + +TEST_CASE( "std::vector > -> toString", "[toString][pair]" ) { + std::vector > pr; + pr.push_back( std::make_pair("green", 55 ) ); + REQUIRE( ::Catch::Detail::stringify( pr ) == "{ { \"green\", 55 } }" ); +} + +// This is pretty contrived - I figure if this works, anything will... +TEST_CASE( "pair > -> toString", "[toString][pair]" ) { + typedef std::pair left_t; + typedef std::pair right_t; + + left_t left( 42, "Arthur" ); + right_t right( "Ford", 24 ); + + std::pair pair( left, right ); + REQUIRE( ::Catch::Detail::stringify( pair ) == "{ { 42, \"Arthur\" }, { \"Ford\", 24 } }" ); +} diff --git a/src/third_party/cppcodec/test/catch/projects/SelfTest/UsageTests/ToStringTuple.tests.cpp b/src/third_party/cppcodec/test/catch/projects/SelfTest/UsageTests/ToStringTuple.tests.cpp new file mode 100644 index 0000000000..fe19ce01f9 --- /dev/null +++ b/src/third_party/cppcodec/test/catch/projects/SelfTest/UsageTests/ToStringTuple.tests.cpp @@ -0,0 +1,47 @@ +#define CATCH_CONFIG_ENABLE_TUPLE_STRINGMAKER +#include "catch.hpp" + +#include + +TEST_CASE( "tuple<>", "[toString][tuple]" ) +{ + typedef std::tuple<> type; + CHECK( "{ }" == ::Catch::Detail::stringify(type{}) ); + type value {}; + CHECK( "{ }" == ::Catch::Detail::stringify(value) ); +} + +TEST_CASE( "tuple", "[toString][tuple]" ) +{ + typedef std::tuple type; + CHECK( "{ 0 }" == ::Catch::Detail::stringify(type{0}) ); +} + + +TEST_CASE( "tuple", "[toString][tuple]" ) +{ + typedef std::tuple type; + CHECK( "1.2f" == ::Catch::Detail::stringify(float(1.2)) ); + CHECK( "{ 1.2f, 0 }" == ::Catch::Detail::stringify(type{1.2f,0}) ); +} + +TEST_CASE( "tuple", "[toString][tuple]" ) +{ + typedef std::tuple type; + CHECK( "{ \"hello\", \"world\" }" == ::Catch::Detail::stringify(type{"hello","world"}) ); +} + +TEST_CASE( "tuple,tuple<>,float>", "[toString][tuple]" ) +{ + typedef std::tuple,std::tuple<>,float> type; + type value { std::tuple{42}, {}, 1.2f }; + CHECK( "{ { 42 }, { }, 1.2f }" == ::Catch::Detail::stringify(value) ); +} + +TEST_CASE( "tuple", "[toString][tuple]" ) +{ + typedef std::tuple type; + type value { nullptr, 42, "Catch me" }; + CHECK( "{ nullptr, 42, \"Catch me\" }" == ::Catch::Detail::stringify(value) ); +} + diff --git a/src/third_party/cppcodec/test/catch/projects/SelfTest/UsageTests/ToStringVector.tests.cpp b/src/third_party/cppcodec/test/catch/projects/SelfTest/UsageTests/ToStringVector.tests.cpp new file mode 100644 index 0000000000..63b49e5026 --- /dev/null +++ b/src/third_party/cppcodec/test/catch/projects/SelfTest/UsageTests/ToStringVector.tests.cpp @@ -0,0 +1,86 @@ +#include "catch.hpp" +#include +#include + +// vector +TEST_CASE( "vector -> toString", "[toString][vector]" ) +{ + std::vector vv; + REQUIRE( ::Catch::Detail::stringify(vv) == "{ }" ); + vv.push_back( 42 ); + REQUIRE( ::Catch::Detail::stringify(vv) == "{ 42 }" ); + vv.push_back( 250 ); + REQUIRE( ::Catch::Detail::stringify(vv) == "{ 42, 250 }" ); +} + +TEST_CASE( "vector -> toString", "[toString][vector]" ) +{ + std::vector vv; + REQUIRE( ::Catch::Detail::stringify(vv) == "{ }" ); + vv.push_back( "hello" ); + REQUIRE( ::Catch::Detail::stringify(vv) == "{ \"hello\" }" ); + vv.push_back( "world" ); + REQUIRE( ::Catch::Detail::stringify(vv) == "{ \"hello\", \"world\" }" ); +} + +namespace { + /* Minimal Allocator */ + template + struct minimal_allocator { + using value_type = T; + using size_type = std::size_t; + + minimal_allocator() = default; + template + minimal_allocator(const minimal_allocator&) {} + + + T *allocate( size_type n ) { + return static_cast( ::operator new( n * sizeof(T) ) ); + } + void deallocate( T *p, size_type /*n*/ ) { + ::operator delete( static_cast(p) ); + } + template + bool operator==( const minimal_allocator& ) const { return true; } + template + bool operator!=( const minimal_allocator& ) const { return false; } + }; +} + +TEST_CASE( "vector -> toString", "[toString][vector,allocator]" ) { + std::vector > vv; + REQUIRE( ::Catch::Detail::stringify(vv) == "{ }" ); + vv.push_back( 42 ); + REQUIRE( ::Catch::Detail::stringify(vv) == "{ 42 }" ); + vv.push_back( 250 ); + REQUIRE( ::Catch::Detail::stringify(vv) == "{ 42, 250 }" ); +} + +TEST_CASE( "vec> -> toString", "[toString][vector,allocator]" ) { + using inner = std::vector>; + using vector = std::vector; + vector v; + REQUIRE( ::Catch::Detail::stringify(v) == "{ }" ); + v.push_back( inner { "hello" } ); + v.push_back( inner { "world" } ); + REQUIRE( ::Catch::Detail::stringify(v) == "{ { \"hello\" }, { \"world\" } }" ); +} + +// Based on PR by mat-so: https://github.com/catchorg/Catch2/pull/606/files#diff-43562f40f8c6dcfe2c54557316e0f852 +TEST_CASE( "vector -> toString", "[toString][containers][vector]" ) { + std::vector bools; + REQUIRE( ::Catch::Detail::stringify(bools) == "{ }"); + bools.push_back(true); + REQUIRE( ::Catch::Detail::stringify(bools) == "{ true }"); + bools.push_back(false); + REQUIRE( ::Catch::Detail::stringify(bools) == "{ true, false }"); +} +TEST_CASE( "array -> toString", "[toString][containers][array]" ) { + std::array empty; + REQUIRE( Catch::Detail::stringify( empty ) == "{ }" ); + std::array oneValue = {{ 42 }}; + REQUIRE( Catch::Detail::stringify( oneValue ) == "{ 42 }" ); + std::array twoValues = {{ 42, 250 }}; + REQUIRE( Catch::Detail::stringify( twoValues ) == "{ 42, 250 }" ); +} \ No newline at end of file diff --git a/src/third_party/cppcodec/test/catch/projects/SelfTest/UsageTests/ToStringWhich.tests.cpp b/src/third_party/cppcodec/test/catch/projects/SelfTest/UsageTests/ToStringWhich.tests.cpp new file mode 100644 index 0000000000..cd4a15183b --- /dev/null +++ b/src/third_party/cppcodec/test/catch/projects/SelfTest/UsageTests/ToStringWhich.tests.cpp @@ -0,0 +1,193 @@ +/* + * Demonstrate which version of toString/StringMaker is being used + * for various types + */ + +// Replace fallback stringifier for this TU +// We should avoid ODR violations because these specific types aren't +// present in different TUs +#include +template +std::string fallbackStringifier(T const&) { + return "{ !!! }"; +} + +#define CATCH_CONFIG_FALLBACK_STRINGIFIER fallbackStringifier +#include "catch.hpp" + + + +#if defined(__GNUC__) +// This has to be left enabled until end of the TU, because the GCC +// frontend reports operator<<(std::ostream& os, const has_maker_and_operator&) +// as unused anyway +# pragma GCC diagnostic ignored "-Wunused-function" +#endif + +namespace { + +struct has_operator { }; +struct has_maker {}; +struct has_maker_and_operator {}; +struct has_neither {}; +struct has_template_operator {}; + +std::ostream& operator<<(std::ostream& os, const has_operator&) { + os << "operator<<( has_operator )"; + return os; +} + +std::ostream& operator<<(std::ostream& os, const has_maker_and_operator&) { + os << "operator<<( has_maker_and_operator )"; + return os; +} + +template +StreamT& operator<<(StreamT& os, const has_template_operator&) { + os << "operator<<( has_template_operator )"; + return os; +} + +} // end anonymous namespace + +namespace Catch { + template<> + struct StringMaker { + static std::string convert( const has_maker& ) { + return "StringMaker"; + } + }; + template<> + struct StringMaker { + static std::string convert( const has_maker_and_operator& ) { + return "StringMaker"; + } + }; +} + +// Call the operator +TEST_CASE( "stringify( has_operator )", "[toString]" ) { + has_operator item; + REQUIRE( ::Catch::Detail::stringify( item ) == "operator<<( has_operator )" ); +} + +// Call the stringmaker +TEST_CASE( "stringify( has_maker )", "[toString]" ) { + has_maker item; + REQUIRE( ::Catch::Detail::stringify( item ) == "StringMaker" ); +} + +// Call the stringmaker +TEST_CASE( "stringify( has_maker_and_operator )", "[toString]" ) { + has_maker_and_operator item; + REQUIRE( ::Catch::Detail::stringify( item ) == "StringMaker" ); +} + +TEST_CASE("stringify( has_neither )", "[toString]") { + has_neither item; + REQUIRE( ::Catch::Detail::stringify(item) == "{ !!! }" ); +} + +// Call the templated operator +TEST_CASE( "stringify( has_template_operator )", "[toString]" ) { + has_template_operator item; + REQUIRE( ::Catch::Detail::stringify( item ) == "operator<<( has_template_operator )" ); +} + + +// Vectors... + +TEST_CASE( "stringify( vectors )", "[toString]" ) { + std::vector v(1); + REQUIRE( ::Catch::Detail::stringify( v ) == "{ operator<<( has_operator ) }" ); +} + +TEST_CASE( "stringify( vectors )", "[toString]" ) { + std::vector v(1); + REQUIRE( ::Catch::Detail::stringify( v ) == "{ StringMaker }" ); +} + +TEST_CASE( "stringify( vectors )", "[toString]" ) { + std::vector v(1); + REQUIRE( ::Catch::Detail::stringify( v ) == "{ StringMaker }" ); +} + +namespace { + +// Range-based conversion should only be used if other possibilities fail +struct int_iterator { + using iterator_category = std::input_iterator_tag; + using difference_type = std::ptrdiff_t; + using value_type = int; + using reference = int&; + using pointer = int*; + + int_iterator() = default; + int_iterator(int i) :val(i) {} + + value_type operator*() const { return val; } + bool operator==(int_iterator rhs) const { return val == rhs.val; } + bool operator!=(int_iterator rhs) const { return val != rhs.val; } + int_iterator operator++() { ++val; return *this; } + int_iterator operator++(int) { + auto temp(*this); + ++val; + return temp; + } +private: + int val = 5; +}; + +struct streamable_range { + int_iterator begin() const { return int_iterator{ 1 }; } + int_iterator end() const { return {}; } +}; + +std::ostream& operator<<(std::ostream& os, const streamable_range&) { + os << "op<<(streamable_range)"; + return os; +} + +struct stringmaker_range { + int_iterator begin() const { return int_iterator{ 1 }; } + int_iterator end() const { return {}; } +}; + +} // end anonymous namespace + +namespace Catch { +template <> +struct StringMaker { + static std::string convert(stringmaker_range const&) { + return "stringmaker(streamable_range)"; + } +}; +} + +namespace { + +struct just_range { + int_iterator begin() const { return int_iterator{ 1 }; } + int_iterator end() const { return {}; } +}; + +struct disabled_range { + int_iterator begin() const { return int_iterator{ 1 }; } + int_iterator end() const { return {}; } +}; + +} // end anonymous namespace + +namespace Catch { +template <> +struct is_range { + static const bool value = false; +}; +} + +TEST_CASE("stringify ranges", "[toString]") { + REQUIRE(::Catch::Detail::stringify(streamable_range{}) == "op<<(streamable_range)"); + REQUIRE(::Catch::Detail::stringify(stringmaker_range{}) == "stringmaker(streamable_range)"); + REQUIRE(::Catch::Detail::stringify(just_range{}) == "{ 1, 2, 3, 4 }"); + REQUIRE(::Catch::Detail::stringify(disabled_range{}) == "{ !!! }"); +} diff --git a/src/third_party/cppcodec/test/catch/projects/SelfTest/UsageTests/Tricky.tests.cpp b/src/third_party/cppcodec/test/catch/projects/SelfTest/UsageTests/Tricky.tests.cpp new file mode 100644 index 0000000000..b0363d4202 --- /dev/null +++ b/src/third_party/cppcodec/test/catch/projects/SelfTest/UsageTests/Tricky.tests.cpp @@ -0,0 +1,428 @@ +/* + * Created by Phil on 09/11/2010. + * Copyright 2010 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) + */ + +#ifdef __clang__ +#pragma clang diagnostic ignored "-Wpadded" +#endif + +#ifdef _MSC_VER +#pragma warning (disable : 4702) // Disable unreachable code warning for the last test + // that is triggered when compiling as Win32|Release +#endif + +#include "catch.hpp" + +#include +#include + +/////////////////////////////////////////////////////////////////////////////// +TEST_CASE +( + "Where there is more to the expression after the RHS", + "[Tricky][failing][.]" +) +{ +// int a = 1, b = 2; +// REQUIRE( a == 2 || b == 2 ); + WARN( "Uncomment the code in this test to check that it gives a sensible compiler error" ); +} +/////////////////////////////////////////////////////////////////////////////// +TEST_CASE +( + "Where the LHS is not a simple value", + "[Tricky][failing][.]" +) +{ + /* + int a = 1; + int b = 2; + + // This only captures part of the expression, but issues a warning about the rest + REQUIRE( a+1 == b-1 ); + */ + WARN( "Uncomment the code in this test to check that it gives a sensible compiler error" ); +} + +struct Opaque +{ + int val; + bool operator ==( const Opaque& o ) const + { + return val == o.val; + } +}; + +/////////////////////////////////////////////////////////////////////////////// +TEST_CASE +( + "A failing expression with a non streamable type is still captured", + "[Tricky][failing][.]" +) +{ + + Opaque o1, o2; + o1.val = 7; + o2.val = 8; + + CHECK( &o1 == &o2 ); + CHECK( o1 == o2 ); +} + +/////////////////////////////////////////////////////////////////////////////// +TEST_CASE +( + "string literals of different sizes can be compared", + "[Tricky][failing][.]" +) +{ + REQUIRE( std::string( "first" ) == "second" ); + +} + +/////////////////////////////////////////////////////////////////////////////// +TEST_CASE +( + "An expression with side-effects should only be evaluated once", + "[Tricky]" +) +{ + int i = 7; + + REQUIRE( i++ == 7 ); + REQUIRE( i++ == 8 ); + +} + +namespace A { + struct X + { + X() : a(4), b(2), c(7) {} + X(int v) : a(v), b(2), c(7) {} + int a; + int b; + int c; + }; +} + +namespace B { + struct Y + { + Y() : a(4), b(2), c(7) {} + Y(int v) : a(v), b(2), c(7) {} + int a; + int b; + int c; + }; +} + +inline bool operator==(const A::X& lhs, const B::Y& rhs) +{ + return (lhs.a == rhs.a); +} + +inline bool operator==(const B::Y& lhs, const A::X& rhs) +{ + return (lhs.a == rhs.a); +} + + +/////////////////////////////////////////////////////////////////////////////// +/* This, currently, does not compile with LLVM +TEST_CASE +( + "Operators at different namespace levels not hijacked by Koenig lookup" + "[Tricky]" +) +{ + A::X x; + B::Y y; + REQUIRE( x == y ); +} +*/ + +namespace ObjectWithConversions +{ + struct Object + { + operator unsigned int() const {return 0xc0000000;} + }; + + /////////////////////////////////////////////////////////////////////////////// + TEST_CASE + ( + "Implicit conversions are supported inside assertion macros", + "[Tricky][approvals]" + ) + { + Object o; + REQUIRE(0xc0000000 == o ); + } +} + +namespace EnumBitFieldTests +{ + enum Bits : uint32_t { + bit0 = 0x0001, + bit1 = 0x0002, + bit2 = 0x0004, + bit3 = 0x0008, + bit1and2 = bit1 | bit2, + bit30 = 0x40000000, + bit31 = 0x80000000, + bit30and31 = bit30 | bit31 + }; + + TEST_CASE( "Test enum bit values", "[Tricky]" ) + { + REQUIRE( 0xc0000000 == bit30and31 ); + } +} + +struct Obj +{ + Obj():prop(&p){} + + int p; + int* prop; +}; + +TEST_CASE("boolean member", "[Tricky]") +{ + Obj obj; + REQUIRE( obj.prop != nullptr ); +} + +// Tests for a problem submitted by Ralph McArdell +// +// The static bool value should not need to be defined outside the +// struct it is declared in - but when evaluating it in a deduced +// context it appears to require the extra definition. +// The issue was fixed by adding bool overloads to bypass the +// templates that were there to deduce it. +template +struct is_true +{ + static const bool value = B; +}; + +TEST_CASE( "(unimplemented) static bools can be evaluated", "[Tricky]" ) +{ + SECTION("compare to true") + { + REQUIRE( is_true::value == true ); + REQUIRE( true == is_true::value ); + } + SECTION("compare to false") + { + REQUIRE( is_true::value == false ); + REQUIRE( false == is_true::value ); + } + + SECTION("negation") + { + REQUIRE( !is_true::value ); + } + + SECTION("double negation") + { + REQUIRE( !!is_true::value ); + } + + SECTION("direct") + { + REQUIRE( is_true::value ); + REQUIRE_FALSE( is_true::value ); + } +} + +// Uncomment these tests to produce an error at test registration time +/* +TEST_CASE( "Tests with the same name are not allowed", "[Tricky]" ) +{ + +} +TEST_CASE( "Tests with the same name are not allowed", "[Tricky]" ) +{ + +} +*/ + +struct Boolable +{ + explicit Boolable( bool value ) : m_value( value ) {} + + explicit operator bool() const { + return m_value; + } + + bool m_value; +}; + +TEST_CASE( "Objects that evaluated in boolean contexts can be checked", "[Tricky][SafeBool]" ) +{ + Boolable True( true ); + Boolable False( false ); + + CHECK( True ); + CHECK( !False ); + CHECK_FALSE( False ); +} + +TEST_CASE( "Assertions then sections", "[Tricky]" ) +{ + // This was causing a failure due to the way the console reporter was handling + // the current section + + REQUIRE( true ); + + SECTION( "A section" ) + { + REQUIRE( true ); + + SECTION( "Another section" ) + { + REQUIRE( true ); + } + SECTION( "Another other section" ) + { + REQUIRE( true ); + } + } +} + +struct Awkward +{ + operator int() const { return 7; } +}; + +TEST_CASE( "non streamable - with conv. op", "[Tricky]" ) +{ + Awkward awkward; + std::string s = ::Catch::Detail::stringify( awkward ); + REQUIRE( s == "7" ); +} + +inline void foo() {} + +typedef void (*fooptr_t)(); + +TEST_CASE( "Comparing function pointers", "[Tricky][function pointer]" ) +{ + // This was giving a warning in VS2010 + // #179 + fooptr_t a = foo; + + REQUIRE( a ); + REQUIRE( a == &foo ); +} + +struct S +{ + void f() {} +}; + + +TEST_CASE( "Comparing member function pointers", "[Tricky][member function pointer][approvals]" ) +{ + typedef void (S::*MF)(); + MF m = &S::f; + + CHECK( m == &S::f ); +} + +class ClassName {}; + +TEST_CASE( "pointer to class", "[Tricky]" ) +{ + ClassName *p = 0; + REQUIRE( p == 0 ); +} + +#include + +TEST_CASE( "null_ptr", "[Tricky]" ) +{ + std::unique_ptr ptr; + REQUIRE(ptr.get() == nullptr); +} + +TEST_CASE( "X/level/0/a", "[Tricky]" ) { SUCCEED(""); } +TEST_CASE( "X/level/0/b", "[Tricky][fizz]" ){ SUCCEED(""); } +TEST_CASE( "X/level/1/a", "[Tricky]" ) { SUCCEED(""); } +TEST_CASE( "X/level/1/b", "[Tricky]" ) { SUCCEED(""); } + +TEST_CASE( "has printf" ) { + + // This can cause problems as, currently, stdout itself is not redirected - only the cout (and cerr) buffer + printf( "loose text artifact\n" ); +} + +namespace { + struct constructor_throws { + [[noreturn]] constructor_throws() { + throw 1; + } + }; +} + +TEST_CASE("Commas in various macros are allowed") { + REQUIRE_THROWS( std::vector{constructor_throws{}, constructor_throws{}} ); + CHECK_THROWS( std::vector{constructor_throws{}, constructor_throws{}} ); + REQUIRE_NOTHROW( std::vector{1, 2, 3} == std::vector{1, 2, 3} ); + CHECK_NOTHROW( std::vector{1, 2, 3} == std::vector{1, 2, 3} ); + + REQUIRE(std::vector{1, 2} == std::vector{1, 2}); + CHECK( std::vector{1, 2} == std::vector{1, 2} ); + REQUIRE_FALSE(std::vector{1, 2} == std::vector{1, 2, 3}); + CHECK_FALSE( std::vector{1, 2} == std::vector{1, 2, 3} ); + + CHECK_NOFAIL( std::vector{1, 2} == std::vector{1, 2} ); + CHECKED_IF( std::vector{1, 2} == std::vector{1, 2} ) { + REQUIRE(true); + } CHECKED_ELSE( std::vector{1, 2} == std::vector{1, 2} ) { + CHECK(true); + } +} + +TEST_CASE( "null deref", "[.][failing][!nonportable]" ) { + CHECK( false ); + int *x = NULL; + *x = 1; +} + +TEST_CASE( "non-copyable objects", "[.][failing]" ) { + // Thanks to Agustin Bergé (@k-ballo on the cpplang Slack) for raising this + std::type_info const& ti = typeid(int); + CHECK( ti == typeid(int) ); +} + +// #925 +using signal_t = void (*) (void*); + +struct TestClass { + signal_t testMethod_uponComplete_arg = nullptr; +}; + +namespace utility { + inline static void synchronizing_callback( void * ) { } +} + +TEST_CASE("#925: comparing function pointer to function address failed to compile", "[!nonportable]" ) { + + TestClass test; + REQUIRE(utility::synchronizing_callback != test.testMethod_uponComplete_arg); +} + +TEST_CASE( "Bitfields can be captured (#1027)" ) { + struct Y { + uint32_t v : 1; + }; + Y y{ 0 }; + REQUIRE( y.v == 0 ); + REQUIRE( 0 == y.v ); +} diff --git a/src/third_party/cppcodec/test/catch/projects/SelfTest/UsageTests/VariadicMacros.tests.cpp b/src/third_party/cppcodec/test/catch/projects/SelfTest/UsageTests/VariadicMacros.tests.cpp new file mode 100644 index 0000000000..fd651c5e40 --- /dev/null +++ b/src/third_party/cppcodec/test/catch/projects/SelfTest/UsageTests/VariadicMacros.tests.cpp @@ -0,0 +1,29 @@ +/* + * Created by Phil on 15/03/2013. + * Copyright 2013 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) + */ + +#include "catch.hpp" + + +TEST_CASE() +{ + SUCCEED( "anonymous test case" ); +} + +TEST_CASE( "Test case with one argument" ) +{ + SUCCEED( "no assertions" ); +} + +TEST_CASE( "Variadic macros", "[variadic][sections]" ) +{ + SECTION( "Section with one argument" ) + { + SUCCEED( "no assertions" ); + } +} + diff --git a/src/third_party/cppcodec/test/catch/projects/Where did the projects go.txt b/src/third_party/cppcodec/test/catch/projects/Where did the projects go.txt new file mode 100644 index 0000000000..c7b011d55e --- /dev/null +++ b/src/third_party/cppcodec/test/catch/projects/Where did the projects go.txt @@ -0,0 +1,13 @@ +The canonical project format is now CMake. +To generate an XCode or Visual Studio project you'll need CMake, which you can download from https://cmake.org if necessary. + +To generate the project files open a terminal/ console within the projects directory (where this file is located), create a directory called "Generated" (using mkdir or md), cd into it, then type: + +CMake -G ../.. + +Where is XCode for XCode projects, or "Visual Studio 14" for Visual Studio 2015 (replace 14 with the major version number for any other supported Visual Studio version - or execute CMake -help for the full list) + +Remember to re-run CMake any time you pull from GitHub. +Note that the projects/Generated folder is excluded in .gitignore. So it is recommended to use this. + +CMake can also generate make files or projects for other build systems. Run CMake -help for the full set of options. diff --git a/src/third_party/cppcodec/test/catch/projects/XCode/OCTest/OCTest.xcodeproj/project.pbxproj b/src/third_party/cppcodec/test/catch/projects/XCode/OCTest/OCTest.xcodeproj/project.pbxproj new file mode 100644 index 0000000000..7153203604 --- /dev/null +++ b/src/third_party/cppcodec/test/catch/projects/XCode/OCTest/OCTest.xcodeproj/project.pbxproj @@ -0,0 +1,294 @@ +// !$*UTF8*$! +{ + archiveVersion = 1; + classes = { + }; + objectVersion = 46; + objects = { + +/* Begin PBXBuildFile section */ + 4A5C29AA1F715603007CB94C /* catch_objc_impl.mm in Sources */ = {isa = PBXBuildFile; fileRef = 4A5C29A91F715603007CB94C /* catch_objc_impl.mm */; }; + 4A63D2AC14E3C1A900F615CB /* OCTest.1 in CopyFiles */ = {isa = PBXBuildFile; fileRef = 4A63D2AB14E3C1A900F615CB /* OCTest.1 */; }; + 4A63D2B314E3C1E600F615CB /* Main.mm in Sources */ = {isa = PBXBuildFile; fileRef = 4A63D2B214E3C1E600F615CB /* Main.mm */; }; + 4A63D2C014E4544700F615CB /* Foundation.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 4A63D2BF14E4544700F615CB /* Foundation.framework */; }; + 4A63D2C614E454CC00F615CB /* CatchOCTestCase.mm in Sources */ = {isa = PBXBuildFile; fileRef = 4A63D2C214E454CC00F615CB /* CatchOCTestCase.mm */; }; + 4A63D2C714E454CC00F615CB /* OCTest.mm in Sources */ = {isa = PBXBuildFile; fileRef = 4A63D2C314E454CC00F615CB /* OCTest.mm */; }; + 4A63D2C814E454CC00F615CB /* TestObj.m in Sources */ = {isa = PBXBuildFile; fileRef = 4A63D2C514E454CC00F615CB /* TestObj.m */; }; +/* End PBXBuildFile section */ + +/* Begin PBXCopyFilesBuildPhase section */ + 4A63D2A314E3C1A900F615CB /* CopyFiles */ = { + isa = PBXCopyFilesBuildPhase; + buildActionMask = 2147483647; + dstPath = /usr/share/man/man1/; + dstSubfolderSpec = 0; + files = ( + 4A63D2AC14E3C1A900F615CB /* OCTest.1 in CopyFiles */, + ); + runOnlyForDeploymentPostprocessing = 1; + }; +/* End PBXCopyFilesBuildPhase section */ + +/* Begin PBXFileReference section */ + 4A5C29A91F715603007CB94C /* catch_objc_impl.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = catch_objc_impl.mm; sourceTree = ""; }; + 4A63D2A514E3C1A900F615CB /* OCTest */ = {isa = PBXFileReference; explicitFileType = "compiled.mach-o.executable"; includeInIndex = 0; path = OCTest; sourceTree = BUILT_PRODUCTS_DIR; }; + 4A63D2AB14E3C1A900F615CB /* OCTest.1 */ = {isa = PBXFileReference; lastKnownFileType = text.man; path = OCTest.1; sourceTree = ""; }; + 4A63D2B214E3C1E600F615CB /* Main.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = Main.mm; sourceTree = ""; }; + 4A63D2BF14E4544700F615CB /* Foundation.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Foundation.framework; path = System/Library/Frameworks/Foundation.framework; sourceTree = SDKROOT; }; + 4A63D2C114E454CC00F615CB /* CatchOCTestCase.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CatchOCTestCase.h; sourceTree = ""; }; + 4A63D2C214E454CC00F615CB /* CatchOCTestCase.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = CatchOCTestCase.mm; sourceTree = ""; }; + 4A63D2C314E454CC00F615CB /* OCTest.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = OCTest.mm; sourceTree = ""; }; + 4A63D2C414E454CC00F615CB /* TestObj.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = TestObj.h; sourceTree = ""; }; + 4A63D2C514E454CC00F615CB /* TestObj.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = TestObj.m; sourceTree = ""; }; +/* End PBXFileReference section */ + +/* Begin PBXFrameworksBuildPhase section */ + 4A63D2A214E3C1A900F615CB /* Frameworks */ = { + isa = PBXFrameworksBuildPhase; + buildActionMask = 2147483647; + files = ( + 4A63D2C014E4544700F615CB /* Foundation.framework in Frameworks */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; +/* End PBXFrameworksBuildPhase section */ + +/* Begin PBXGroup section */ + 4A63D29A14E3C1A900F615CB = { + isa = PBXGroup; + children = ( + 4AA0D94F154C0A63004B4193 /* Catch */, + 4A63D2BF14E4544700F615CB /* Foundation.framework */, + 4A63D2A814E3C1A900F615CB /* OCTest */, + 4A63D2A614E3C1A900F615CB /* Products */, + ); + sourceTree = ""; + }; + 4A63D2A614E3C1A900F615CB /* Products */ = { + isa = PBXGroup; + children = ( + 4A63D2A514E3C1A900F615CB /* OCTest */, + ); + name = Products; + sourceTree = ""; + }; + 4A63D2A814E3C1A900F615CB /* OCTest */ = { + isa = PBXGroup; + children = ( + 4A63D2C114E454CC00F615CB /* CatchOCTestCase.h */, + 4A63D2C214E454CC00F615CB /* CatchOCTestCase.mm */, + 4A63D2C314E454CC00F615CB /* OCTest.mm */, + 4A63D2C414E454CC00F615CB /* TestObj.h */, + 4A63D2C514E454CC00F615CB /* TestObj.m */, + 4A63D2B214E3C1E600F615CB /* Main.mm */, + 4A63D2AB14E3C1A900F615CB /* OCTest.1 */, + ); + path = OCTest; + sourceTree = ""; + }; + 4AA0D94F154C0A63004B4193 /* Catch */ = { + isa = PBXGroup; + children = ( + 4A5C29A91F715603007CB94C /* catch_objc_impl.mm */, + ); + name = Catch; + sourceTree = ""; + }; +/* End PBXGroup section */ + +/* Begin PBXNativeTarget section */ + 4A63D2A414E3C1A900F615CB /* OCTest */ = { + isa = PBXNativeTarget; + buildConfigurationList = 4A63D2AF14E3C1A900F615CB /* Build configuration list for PBXNativeTarget "OCTest" */; + buildPhases = ( + 4A63D2A114E3C1A900F615CB /* Sources */, + 4A63D2A214E3C1A900F615CB /* Frameworks */, + 4A63D2A314E3C1A900F615CB /* CopyFiles */, + ); + buildRules = ( + ); + dependencies = ( + ); + name = OCTest; + productName = OCTest; + productReference = 4A63D2A514E3C1A900F615CB /* OCTest */; + productType = "com.apple.product-type.tool"; + }; +/* End PBXNativeTarget section */ + +/* Begin PBXProject section */ + 4A63D29C14E3C1A900F615CB /* Project object */ = { + isa = PBXProject; + attributes = { + LastUpgradeCheck = 0940; + }; + buildConfigurationList = 4A63D29F14E3C1A900F615CB /* Build configuration list for PBXProject "OCTest" */; + compatibilityVersion = "Xcode 3.2"; + developmentRegion = English; + hasScannedForEncodings = 0; + knownRegions = ( + en, + ); + mainGroup = 4A63D29A14E3C1A900F615CB; + productRefGroup = 4A63D2A614E3C1A900F615CB /* Products */; + projectDirPath = ""; + projectRoot = ""; + targets = ( + 4A63D2A414E3C1A900F615CB /* OCTest */, + ); + }; +/* End PBXProject section */ + +/* Begin PBXSourcesBuildPhase section */ + 4A63D2A114E3C1A900F615CB /* Sources */ = { + isa = PBXSourcesBuildPhase; + buildActionMask = 2147483647; + files = ( + 4A63D2B314E3C1E600F615CB /* Main.mm in Sources */, + 4A5C29AA1F715603007CB94C /* catch_objc_impl.mm in Sources */, + 4A63D2C614E454CC00F615CB /* CatchOCTestCase.mm in Sources */, + 4A63D2C714E454CC00F615CB /* OCTest.mm in Sources */, + 4A63D2C814E454CC00F615CB /* TestObj.m in Sources */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; +/* End PBXSourcesBuildPhase section */ + +/* Begin XCBuildConfiguration section */ + 4A63D2AD14E3C1A900F615CB /* Debug */ = { + isa = XCBuildConfiguration; + buildSettings = { + ALWAYS_SEARCH_USER_PATHS = NO; + CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; + CLANG_WARN_BOOL_CONVERSION = YES; + CLANG_WARN_COMMA = YES; + CLANG_WARN_CONSTANT_CONVERSION = YES; + CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES; + CLANG_WARN_EMPTY_BODY = YES; + CLANG_WARN_ENUM_CONVERSION = YES; + CLANG_WARN_INFINITE_RECURSION = YES; + CLANG_WARN_INT_CONVERSION = YES; + CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES; + CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES; + CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; + CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; + CLANG_WARN_STRICT_PROTOTYPES = YES; + CLANG_WARN_SUSPICIOUS_MOVE = YES; + CLANG_WARN_UNREACHABLE_CODE = YES; + CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; + COPY_PHASE_STRIP = NO; + ENABLE_STRICT_OBJC_MSGSEND = YES; + ENABLE_TESTABILITY = YES; + GCC_C_LANGUAGE_STANDARD = gnu99; + GCC_DYNAMIC_NO_PIC = NO; + GCC_ENABLE_OBJC_EXCEPTIONS = YES; + GCC_NO_COMMON_BLOCKS = YES; + GCC_OPTIMIZATION_LEVEL = 0; + GCC_PREPROCESSOR_DEFINITIONS = ( + "DEBUG=1", + "$(inherited)", + ); + GCC_SYMBOLS_PRIVATE_EXTERN = NO; + GCC_VERSION = com.apple.compilers.llvm.clang.1_0; + GCC_WARN_64_TO_32_BIT_CONVERSION = YES; + GCC_WARN_ABOUT_MISSING_PROTOTYPES = YES; + GCC_WARN_ABOUT_RETURN_TYPE = YES; + GCC_WARN_UNDECLARED_SELECTOR = YES; + GCC_WARN_UNINITIALIZED_AUTOS = YES; + GCC_WARN_UNUSED_FUNCTION = YES; + GCC_WARN_UNUSED_VARIABLE = YES; + HEADER_SEARCH_PATHS = ../../../include; + MACOSX_DEPLOYMENT_TARGET = 10.7; + ONLY_ACTIVE_ARCH = YES; + SDKROOT = macosx; + }; + name = Debug; + }; + 4A63D2AE14E3C1A900F615CB /* Release */ = { + isa = XCBuildConfiguration; + buildSettings = { + ALWAYS_SEARCH_USER_PATHS = NO; + CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; + CLANG_WARN_BOOL_CONVERSION = YES; + CLANG_WARN_COMMA = YES; + CLANG_WARN_CONSTANT_CONVERSION = YES; + CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES; + CLANG_WARN_EMPTY_BODY = YES; + CLANG_WARN_ENUM_CONVERSION = YES; + CLANG_WARN_INFINITE_RECURSION = YES; + CLANG_WARN_INT_CONVERSION = YES; + CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES; + CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES; + CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; + CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; + CLANG_WARN_STRICT_PROTOTYPES = YES; + CLANG_WARN_SUSPICIOUS_MOVE = YES; + CLANG_WARN_UNREACHABLE_CODE = YES; + CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; + COPY_PHASE_STRIP = YES; + DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; + ENABLE_STRICT_OBJC_MSGSEND = YES; + GCC_C_LANGUAGE_STANDARD = gnu99; + GCC_ENABLE_OBJC_EXCEPTIONS = YES; + GCC_NO_COMMON_BLOCKS = YES; + GCC_VERSION = com.apple.compilers.llvm.clang.1_0; + GCC_WARN_64_TO_32_BIT_CONVERSION = YES; + GCC_WARN_ABOUT_MISSING_PROTOTYPES = YES; + GCC_WARN_ABOUT_RETURN_TYPE = YES; + GCC_WARN_UNDECLARED_SELECTOR = YES; + GCC_WARN_UNINITIALIZED_AUTOS = YES; + GCC_WARN_UNUSED_FUNCTION = YES; + GCC_WARN_UNUSED_VARIABLE = YES; + HEADER_SEARCH_PATHS = ../../../include; + MACOSX_DEPLOYMENT_TARGET = 10.7; + SDKROOT = macosx; + }; + name = Release; + }; + 4A63D2B014E3C1A900F615CB /* Debug */ = { + isa = XCBuildConfiguration; + buildSettings = { + CLANG_CXX_LANGUAGE_STANDARD = "c++0x"; + CLANG_CXX_LIBRARY = "libc++"; + CLANG_ENABLE_OBJC_ARC = YES; + HEADER_SEARCH_PATHS = ../../../include; + PRODUCT_NAME = "$(TARGET_NAME)"; + }; + name = Debug; + }; + 4A63D2B114E3C1A900F615CB /* Release */ = { + isa = XCBuildConfiguration; + buildSettings = { + CLANG_CXX_LANGUAGE_STANDARD = "c++0x"; + CLANG_CXX_LIBRARY = "libc++"; + CLANG_ENABLE_OBJC_ARC = YES; + HEADER_SEARCH_PATHS = ../../../include; + PRODUCT_NAME = "$(TARGET_NAME)"; + }; + name = Release; + }; +/* End XCBuildConfiguration section */ + +/* Begin XCConfigurationList section */ + 4A63D29F14E3C1A900F615CB /* Build configuration list for PBXProject "OCTest" */ = { + isa = XCConfigurationList; + buildConfigurations = ( + 4A63D2AD14E3C1A900F615CB /* Debug */, + 4A63D2AE14E3C1A900F615CB /* Release */, + ); + defaultConfigurationIsVisible = 0; + defaultConfigurationName = Release; + }; + 4A63D2AF14E3C1A900F615CB /* Build configuration list for PBXNativeTarget "OCTest" */ = { + isa = XCConfigurationList; + buildConfigurations = ( + 4A63D2B014E3C1A900F615CB /* Debug */, + 4A63D2B114E3C1A900F615CB /* Release */, + ); + defaultConfigurationIsVisible = 0; + defaultConfigurationName = Release; + }; +/* End XCConfigurationList section */ + }; + rootObject = 4A63D29C14E3C1A900F615CB /* Project object */; +} diff --git a/src/third_party/cppcodec/test/catch/projects/XCode/OCTest/OCTest.xcodeproj/project.xcworkspace/contents.xcworkspacedata b/src/third_party/cppcodec/test/catch/projects/XCode/OCTest/OCTest.xcodeproj/project.xcworkspace/contents.xcworkspacedata new file mode 100644 index 0000000000..119e61c58c --- /dev/null +++ b/src/third_party/cppcodec/test/catch/projects/XCode/OCTest/OCTest.xcodeproj/project.xcworkspace/contents.xcworkspacedata @@ -0,0 +1,7 @@ + + + + + diff --git a/src/third_party/cppcodec/test/catch/projects/XCode/OCTest/OCTest/CatchOCTestCase.h b/src/third_party/cppcodec/test/catch/projects/XCode/OCTest/OCTest/CatchOCTestCase.h new file mode 100644 index 0000000000..bd26239ae1 --- /dev/null +++ b/src/third_party/cppcodec/test/catch/projects/XCode/OCTest/OCTest/CatchOCTestCase.h @@ -0,0 +1,25 @@ +// +// CatchOCTestCase.h +// OCTest +// +// Created by Phil on 13/11/2010. +// Copyright 2010 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_CATCHOCTESTCASE_H_INCLUDED +#define TWOBLUECUBES_CATCHOCTESTCASE_H_INCLUDED + +#include "catch.hpp" + +#import +#import "TestObj.h" + +@interface TestFixture : NSObject +{ + TestObj* obj; +} + +@end + +#endif // TWOBLUECUBES_CATCHOCTESTCASE_H_INCLUDED diff --git a/src/third_party/cppcodec/test/catch/projects/XCode/OCTest/OCTest/CatchOCTestCase.mm b/src/third_party/cppcodec/test/catch/projects/XCode/OCTest/OCTest/CatchOCTestCase.mm new file mode 100644 index 0000000000..9bd1fa09df --- /dev/null +++ b/src/third_party/cppcodec/test/catch/projects/XCode/OCTest/OCTest/CatchOCTestCase.mm @@ -0,0 +1,87 @@ +// +// CatchOCTestCase.mm +// OCTest +// +// Created by Phil Nash on 13/11/2010. +// Copyright 2010 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) + +#import "CatchOCTestCase.h" + + +@implementation TestFixture + + +-(void) setUp +{ + obj = [[TestObj alloc] init]; +} + +-(void) tearDown +{ + arcSafeRelease( obj ); +} + +OC_TEST_CASE( "This is a test case", "" ) +{ + REQUIRE( obj.int_val == 0 ); + + obj.int_val = 1; + + REQUIRE( obj.int_val == 1 ); +} + +OC_TEST_CASE( "This is another test case", "" ) +{ + REQUIRE( obj.int_val == 0 ); + + obj.int_val = 2; + + REQUIRE( obj.int_val == 2 ); +} + +OC_TEST_CASE( "tests a boolean value", "[!shouldfail]" ) +{ + CHECK( [obj isTrue] == NO ); + CHECK( [obj isFalse] == YES ); +} + +OC_TEST_CASE( "throws an Objective-C exception", "[!throws][!shouldfail]" ) +{ + @throw [[NSException alloc] initWithName: NSGenericException + reason: @"Objective-C exception" + userInfo: nil]; +} +OC_TEST_CASE( "throws a std c++ exception", "[!throws][!shouldfail]" ) +{ + throw std::domain_error( "std C++ exception" ); +} + +/////////////////////////////////////////////////////////////////////////// +template +void useObject( const T& object ){} + +template +void useObject( const T* object ){} + +OC_TEST_CASE( "Matches work with OC types (NSString so far)", "[!shouldfail]" ) +{ + using namespace Catch::Matchers; + + REQUIRE_THAT( @"This is a string", Equals( @"This isnt a string" ) ); + REQUIRE_THAT( @"This is a string", Contains( @"is a" ) ); + REQUIRE_THAT( @"This is a string", StartsWith( @"This" ) ); + REQUIRE_THAT( @"This is a string", EndsWith( @"string" ) ); +} + +OC_TEST_CASE( "nil NSString should not crash the test", "[!shouldfail]" ) +{ + using namespace Catch::Matchers; + + CHECK_THAT( (NSString*)nil, Equals( @"This should fail, but not crash" ) ); + CHECK_THAT( (NSString*)nil, StartsWith( @"anything" ) ); +} + +@end diff --git a/src/third_party/cppcodec/test/catch/projects/XCode/OCTest/OCTest/Main.mm b/src/third_party/cppcodec/test/catch/projects/XCode/OCTest/OCTest/Main.mm new file mode 100644 index 0000000000..569dc4d9ca --- /dev/null +++ b/src/third_party/cppcodec/test/catch/projects/XCode/OCTest/OCTest/Main.mm @@ -0,0 +1,2 @@ +#define CATCH_CONFIG_MAIN +#import "catch.hpp" diff --git a/src/third_party/cppcodec/test/catch/projects/XCode/OCTest/OCTest/OCTest.1 b/src/third_party/cppcodec/test/catch/projects/XCode/OCTest/OCTest/OCTest.1 new file mode 100644 index 0000000000..1cd333e291 --- /dev/null +++ b/src/third_party/cppcodec/test/catch/projects/XCode/OCTest/OCTest/OCTest.1 @@ -0,0 +1,79 @@ +.\"Modified from man(1) of FreeBSD, the NetBSD mdoc.template, and mdoc.samples. +.\"See Also: +.\"man mdoc.samples for a complete listing of options +.\"man mdoc for the short list of editing options +.\"/usr/share/misc/mdoc.template +.Dd 09/02/2012 \" DATE +.Dt OCTest 1 \" Program name and manual section number +.Os Darwin +.Sh NAME \" Section Header - required - don't modify +.Nm OCTest, +.\" The following lines are read in generating the apropos(man -k) database. Use only key +.\" words here as the database is built based on the words here and in the .ND line. +.Nm Other_name_for_same_program(), +.Nm Yet another name for the same program. +.\" Use .Nm macro to designate other names for the documented program. +.Nd This line parsed for whatis database. +.Sh SYNOPSIS \" Section Header - required - don't modify +.Nm +.Op Fl abcd \" [-abcd] +.Op Fl a Ar path \" [-a path] +.Op Ar file \" [file] +.Op Ar \" [file ...] +.Ar arg0 \" Underlined argument - use .Ar anywhere to underline +arg2 ... \" Arguments +.Sh DESCRIPTION \" Section Header - required - don't modify +Use the .Nm macro to refer to your program throughout the man page like such: +.Nm +Underlining is accomplished with the .Ar macro like this: +.Ar underlined text . +.Pp \" Inserts a space +A list of items with descriptions: +.Bl -tag -width -indent \" Begins a tagged list +.It item a \" Each item preceded by .It macro +Description of item a +.It item b +Description of item b +.El \" Ends the list +.Pp +A list of flags and their descriptions: +.Bl -tag -width -indent \" Differs from above in tag removed +.It Fl a \"-a flag as a list item +Description of -a flag +.It Fl b +Description of -b flag +.El \" Ends the list +.Pp +.\" .Sh ENVIRONMENT \" May not be needed +.\" .Bl -tag -width "ENV_VAR_1" -indent \" ENV_VAR_1 is width of the string ENV_VAR_1 +.\" .It Ev ENV_VAR_1 +.\" Description of ENV_VAR_1 +.\" .It Ev ENV_VAR_2 +.\" Description of ENV_VAR_2 +.\" .El +.Sh FILES \" File used or created by the topic of the man page +.Bl -tag -width "/Users/joeuser/Library/really_long_file_name" -compact +.It Pa /usr/share/file_name +FILE_1 description +.It Pa /Users/joeuser/Library/really_long_file_name +FILE_2 description +.El \" Ends the list +.\" .Sh DIAGNOSTICS \" May not be needed +.\" .Bl -diag +.\" .It Diagnostic Tag +.\" Diagnostic information here. +.\" .It Diagnostic Tag +.\" Diagnostic information here. +.\" .El +.Sh SEE ALSO +.\" List links in ascending order by section, alphabetically within a section. +.\" Please do not reference files that do not exist without filing a bug report +.Xr a 1 , +.Xr b 1 , +.Xr c 1 , +.Xr a 2 , +.Xr b 2 , +.Xr a 3 , +.Xr b 3 +.\" .Sh BUGS \" Document known, unremedied bugs +.\" .Sh HISTORY \" Document history if command behaves in a unique manner \ No newline at end of file diff --git a/src/third_party/cppcodec/test/catch/projects/XCode/OCTest/OCTest/OCTest.mm b/src/third_party/cppcodec/test/catch/projects/XCode/OCTest/OCTest/OCTest.mm new file mode 100644 index 0000000000..fa3ffea617 --- /dev/null +++ b/src/third_party/cppcodec/test/catch/projects/XCode/OCTest/OCTest/OCTest.mm @@ -0,0 +1,28 @@ +/* + * OCTest.mm + * OCTest + * + * Created by Phil on 13/11/2010. + * Copyright 2010 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) + * + */ + +#import "catch.hpp" + +#import "TestObj.h" + +TEST_CASE( "OCTest/TestObj", "tests TestObj" ) +{ + TestObj* obj = [[TestObj alloc] init]; + + REQUIRE( obj.int_val == 0 ); + + obj.int_val = 1; + + REQUIRE( obj.int_val == 1 ); + + arcSafeRelease( obj ); +} diff --git a/src/third_party/cppcodec/test/catch/projects/XCode/OCTest/OCTest/TestObj.h b/src/third_party/cppcodec/test/catch/projects/XCode/OCTest/OCTest/TestObj.h new file mode 100644 index 0000000000..8443921ffe --- /dev/null +++ b/src/third_party/cppcodec/test/catch/projects/XCode/OCTest/OCTest/TestObj.h @@ -0,0 +1,28 @@ +// +// TestObj.h +// OCTest +// +// Created by Phil on 13/11/2010. +// Copyright 2010 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_TESTOBJ_H_INCLUDED +#define TWOBLUECUBES_TESTOBJ_H_INCLUDED + +#import + + +@interface TestObj : NSObject { + + int int_val; +} + +-(BOOL) isTrue; +-(BOOL) isFalse; + +@property (nonatomic, assign ) int int_val; + +@end + +#endif // TWOBLUECUBES_TESTOBJ_H_INCLUDED diff --git a/src/third_party/cppcodec/test/catch/projects/XCode/OCTest/OCTest/TestObj.m b/src/third_party/cppcodec/test/catch/projects/XCode/OCTest/OCTest/TestObj.m new file mode 100644 index 0000000000..2c7dc99b8f --- /dev/null +++ b/src/third_party/cppcodec/test/catch/projects/XCode/OCTest/OCTest/TestObj.m @@ -0,0 +1,25 @@ +// +// TestObj.m +// OCTest +// +// Created by Phil on 13/11/2010. +// Copyright 2010 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) + +#import "TestObj.h" + + +@implementation TestObj + +@synthesize int_val; + +-(BOOL) isTrue { + return YES; +} +-(BOOL) isFalse { + return NO; +} + +@end diff --git a/src/third_party/cppcodec/test/catch/projects/XCode/OCTest/catch_objc_impl.mm b/src/third_party/cppcodec/test/catch/projects/XCode/OCTest/catch_objc_impl.mm new file mode 100644 index 0000000000..e439a3ab7c --- /dev/null +++ b/src/third_party/cppcodec/test/catch/projects/XCode/OCTest/catch_objc_impl.mm @@ -0,0 +1,69 @@ +// This file #includes all the .cpp files into a single .mm +// - so they get compiled as ObjectiveC++ + +#include "../../../include/internal/catch_tostring.cpp" +#include "../../../include/internal/catch_approx.cpp" +#include "../../../include/internal/catch_assertionhandler.cpp" +#include "../../../include/internal/catch_assertionresult.cpp" +#include "../../../include/internal/catch_benchmark.cpp" +#include "../../../include/internal/catch_capture_matchers.cpp" +#include "../../../include/internal/catch_commandline.cpp" +#include "../../../include/internal/catch_common.cpp" +#include "../../../include/internal/catch_config.cpp" +#include "../../../include/internal/catch_console_colour.cpp" +#include "../../../include/internal/catch_context.cpp" +#include "../../../include/internal/catch_debug_console.cpp" +#include "../../../include/internal/catch_debugger.cpp" +#include "../../../include/internal/catch_decomposer.cpp" +#include "../../../include/internal/catch_errno_guard.cpp" +#include "../../../include/internal/catch_exception_translator_registry.cpp" +#include "../../../include/internal/catch_fatal_condition.cpp" +#include "../../../include/internal/catch_interfaces_capture.cpp" +#include "../../../include/internal/catch_interfaces_config.cpp" +#include "../../../include/internal/catch_interfaces_exception.cpp" +#include "../../../include/internal/catch_interfaces_registry_hub.cpp" +#include "../../../include/internal/catch_interfaces_reporter.cpp" +#include "../../../include/internal/catch_interfaces_runner.cpp" +#include "../../../include/internal/catch_interfaces_testcase.cpp" +#include "../../../include/internal/catch_leak_detector.cpp" +#include "../../../include/internal/catch_list.cpp" +#include "../../../include/internal/catch_matchers.cpp" +#include "../../../include/internal/catch_matchers_string.cpp" +#include "../../../include/internal/catch_message.cpp" +#include "../../../include/internal/catch_output_redirect.cpp" +#include "../../../include/internal/catch_random_number_generator.cpp" +#include "../../../include/internal/catch_registry_hub.cpp" +#include "../../../include/internal/catch_reporter_registry.cpp" +#include "../../../include/internal/catch_result_type.cpp" +#include "../../../include/internal/catch_run_context.cpp" +#include "../../../include/internal/catch_section.cpp" +#include "../../../include/internal/catch_section_info.cpp" +#include "../../../include/internal/catch_session.cpp" +#include "../../../include/internal/catch_startup_exception_registry.cpp" +#include "../../../include/internal/catch_stream.cpp" +#include "../../../include/internal/catch_string_manip.cpp" +#include "../../../include/internal/catch_stringref.cpp" +#include "../../../include/internal/catch_tag_alias.cpp" +#include "../../../include/internal/catch_tag_alias_autoregistrar.cpp" +#include "../../../include/internal/catch_tag_alias_registry.cpp" +#include "../../../include/internal/catch_test_case_info.cpp" +#include "../../../include/internal/catch_test_case_registry_impl.cpp" +#include "../../../include/internal/catch_test_case_tracker.cpp" +#include "../../../include/internal/catch_test_registry.cpp" +#include "../../../include/internal/catch_test_spec.cpp" +#include "../../../include/internal/catch_test_spec_parser.cpp" +#include "../../../include/internal/catch_timer.cpp" +#include "../../../include/internal/catch_totals.cpp" +#include "../../../include/internal/catch_uncaught_exceptions.cpp" +#include "../../../include/internal/catch_version.cpp" +#include "../../../include/internal/catch_wildcard_pattern.cpp" +#include "../../../include/internal/catch_xmlwriter.cpp" + + +// Reporters +#include "../../../include/reporters/catch_reporter_bases.cpp" +#include "../../../include/reporters/catch_reporter_compact.cpp" +#include "../../../include/reporters/catch_reporter_console.cpp" +#include "../../../include/reporters/catch_reporter_junit.cpp" +#include "../../../include/reporters/catch_reporter_listening.cpp" +#include "../../../include/reporters/catch_reporter_xml.cpp" diff --git a/src/third_party/cppcodec/test/catch/scripts/approvalTests.py b/src/third_party/cppcodec/test/catch/scripts/approvalTests.py new file mode 100755 index 0000000000..3293c93888 --- /dev/null +++ b/src/third_party/cppcodec/test/catch/scripts/approvalTests.py @@ -0,0 +1,199 @@ +#!/usr/bin/env python + +from __future__ import print_function + +import io +import os +import sys +import subprocess +import re +import difflib + +import scriptCommon +from scriptCommon import catchPath + +if os.name == 'nt': + # Enable console colours on windows + os.system('') + +rootPath = os.path.join(catchPath, 'projects/SelfTest/Baselines') + + +filelocParser = re.compile(r''' + .*/ + (.+\.[ch]pp) # filename + (?::|\() # : is starting separator between filename and line number on Linux, ( on Windows + ([0-9]*) # line number + \)? # Windows also has an ending separator, ) +''', re.VERBOSE) +lineNumberParser = re.compile(r' line="[0-9]*"') +hexParser = re.compile(r'\b(0[xX][0-9a-fA-F]+)\b') +durationsParser = re.compile(r' time="[0-9]*\.[0-9]*"') +timestampsParser = re.compile(r'\d{4}-\d{2}-\d{2}T\d{2}\:\d{2}\:\d{2}Z') +versionParser = re.compile(r'Catch v[0-9]+\.[0-9]+\.[0-9]+(-develop\.[0-9]+)?') +nullParser = re.compile(r'\b(__null|nullptr)\b') +exeNameParser = re.compile(r''' + \b + (CatchSelfTest|SelfTest) # Expected executable name + (?:.exe)? # Executable name contains .exe on Windows. + \b +''', re.VERBOSE) +# This is a hack until something more reasonable is figured out +specialCaseParser = re.compile(r'file\((\d+)\)') + +# errno macro expands into various names depending on platform, so we need to fix them up as well +errnoParser = re.compile(r''' + \(\*__errno_location\ \(\)\) + | + \(\*__error\(\)\) + | + \(\*_errno\(\)\) +''', re.VERBOSE) +sinceEpochParser = re.compile(r'\d+ .+ since epoch') +infParser = re.compile(r''' + \(\(float\)\(1e\+300\ \*\ 1e\+300\)\) # MSVC INFINITY macro + | + \(__builtin_inff\(\)\) # Linux (ubuntu) INFINITY macro + | + \(__builtin_inff\ \(\)\) # Fedora INFINITY macro + | + __builtin_huge_valf\(\) # OSX macro +''', re.VERBOSE) +nanParser = re.compile(r''' + \(\(float\)\(\(\(float\)\(1e\+300\ \*\ 1e\+300\)\)\ \*\ 0\.0F\)\) # MSVC NAN macro + | + \(\(float\)\(INFINITY\ \*\ 0\.0F\)\) # Yet another MSVC NAN macro + | + \(__builtin_nanf\ \(""\)\) # Linux (ubuntu) NAN macro + | + __builtin_nanf\("0x"\) # The weird content of the brackets is there because a different parser has already ran before this one +''', re.VERBOSE) + + +if len(sys.argv) == 2: + cmdPath = sys.argv[1] +else: + cmdPath = os.path.join(catchPath, scriptCommon.getBuildExecutable()) + +overallResult = 0 + + +def diffFiles(fileA, fileB): + with io.open(fileA, 'r', encoding='utf-8', errors='surrogateescape') as file: + aLines = [line.rstrip() for line in file.readlines()] + with io.open(fileB, 'r', encoding='utf-8', errors='surrogateescape') as file: + bLines = [line.rstrip() for line in file.readlines()] + + shortenedFilenameA = fileA.rsplit(os.sep, 1)[-1] + shortenedFilenameB = fileB.rsplit(os.sep, 1)[-1] + + diff = difflib.unified_diff(aLines, bLines, fromfile=shortenedFilenameA, tofile=shortenedFilenameB, n=0) + return [line for line in diff if line[0] in ('+', '-')] + + +def filterLine(line, isCompact): + if catchPath in line: + # make paths relative to Catch root + line = line.replace(catchPath + os.sep, '') + # go from \ in windows paths to / + line = line.replace('\\', '/') + + + # strip source line numbers + m = filelocParser.match(line) + if m: + # note that this also strips directories, leaving only the filename + filename, lnum = m.groups() + lnum = ":" if lnum else "" + line = filename + lnum + line[m.end():] + else: + line = lineNumberParser.sub(" ", line) + + if isCompact: + line = line.replace(': FAILED', ': failed') + line = line.replace(': PASSED', ': passed') + + # strip Catch version number + line = versionParser.sub("", line) + + # replace *null* with 0 + line = nullParser.sub("0", line) + + # strip executable name + line = exeNameParser.sub("", line) + + # strip hexadecimal numbers (presumably pointer values) + line = hexParser.sub("0x", line) + + # strip durations and timestamps + line = durationsParser.sub(' time="{duration}"', line) + line = timestampsParser.sub('{iso8601-timestamp}', line) + line = specialCaseParser.sub('file:\g<1>', line) + line = errnoParser.sub('errno', line) + line = sinceEpochParser.sub('{since-epoch-report}', line) + line = infParser.sub('INFINITY', line) + line = nanParser.sub('NAN', line) + return line + + +def approve(baseName, args): + global overallResult + args[0:0] = [cmdPath] + if not os.path.exists(cmdPath): + raise Exception("Executable doesn't exist at " + cmdPath) + baselinesPath = os.path.join(rootPath, '{0}.approved.txt'.format(baseName)) + rawResultsPath = os.path.join(rootPath, '_{0}.tmp'.format(baseName)) + filteredResultsPath = os.path.join(rootPath, '{0}.unapproved.txt'.format(baseName)) + + f = open(rawResultsPath, 'w') + subprocess.call(args, stdout=f, stderr=f) + f.close() + + rawFile = io.open(rawResultsPath, 'r', encoding='utf-8', errors='surrogateescape') + filteredFile = io.open(filteredResultsPath, 'w', encoding='utf-8', errors='surrogateescape') + for line in rawFile: + filteredFile.write(filterLine(line, 'compact' in baseName).rstrip() + "\n") + filteredFile.close() + rawFile.close() + + os.remove(rawResultsPath) + print() + print(baseName + ":") + if os.path.exists(baselinesPath): + diffResult = diffFiles(baselinesPath, filteredResultsPath) + if diffResult: + print('\n'.join(diffResult)) + print(" \n****************************\n \033[91mResults differed") + if len(diffResult) > overallResult: + overallResult = len(diffResult) + else: + os.remove(filteredResultsPath) + print(" \033[92mResults matched") + print("\033[0m") + else: + print(" first approval") + if overallResult == 0: + overallResult = 1 + + +print("Running approvals against executable:") +print(" " + cmdPath) + + +### Keep default reporters here +# Standard console reporter +approve("console.std", ["~[!nonportable]~[!benchmark]~[approvals]", "--order", "lex"]) +# console reporter, include passes, warn about No Assertions +approve("console.sw", ["~[!nonportable]~[!benchmark]~[approvals]", "-s", "-w", "NoAssertions", "--order", "lex"]) +# console reporter, include passes, warn about No Assertions, limit failures to first 4 +approve("console.swa4", ["~[!nonportable]~[!benchmark]~[approvals]", "-s", "-w", "NoAssertions", "-x", "4", "--order", "lex"]) +# junit reporter, include passes, warn about No Assertions +approve("junit.sw", ["~[!nonportable]~[!benchmark]~[approvals]", "-s", "-w", "NoAssertions", "-r", "junit", "--order", "lex"]) +# xml reporter, include passes, warn about No Assertions +approve("xml.sw", ["~[!nonportable]~[!benchmark]~[approvals]", "-s", "-w", "NoAssertions", "-r", "xml", "--order", "lex"]) +# compact reporter, include passes, warn about No Assertions +approve('compact.sw', ['~[!nonportable]~[!benchmark]~[approvals]', '-s', '-w', 'NoAssertions', '-r', 'compact', '--order', 'lex']) + +if overallResult != 0: + print("If these differences are expected, run approve.py to approve new baselines.") +exit(overallResult) diff --git a/src/third_party/cppcodec/test/catch/scripts/approve.py b/src/third_party/cppcodec/test/catch/scripts/approve.py new file mode 100755 index 0000000000..f03417dcb3 --- /dev/null +++ b/src/third_party/cppcodec/test/catch/scripts/approve.py @@ -0,0 +1,33 @@ +#!/usr/bin/env python + +from __future__ import print_function + +import os +import sys +import shutil +import glob +from scriptCommon import catchPath + +rootPath = os.path.join( catchPath, 'projects/SelfTest/Baselines' ) + +if len(sys.argv) > 1: + files = [os.path.join( rootPath, f ) for f in sys.argv[1:]] +else: + files = glob.glob( os.path.join( rootPath, "*.unapproved.txt" ) ) + + +def approveFile( approvedFile, unapprovedFile ): + justFilename = unapprovedFile[len(rootPath)+1:] + if os.path.exists( unapprovedFile ): + if os.path.exists( approvedFile ): + os.remove( approvedFile ) + os.rename( unapprovedFile, approvedFile ) + print( "approved " + justFilename ) + else: + print( "approval file " + justFilename + " does not exist" ) + +if files: + for unapprovedFile in files: + approveFile( unapprovedFile.replace( "unapproved.txt", "approved.txt" ), unapprovedFile ) +else: + print( "no files to approve" ) diff --git a/src/third_party/cppcodec/test/catch/scripts/benchmarkCompile.py b/src/third_party/cppcodec/test/catch/scripts/benchmarkCompile.py new file mode 100755 index 0000000000..586c26ac01 --- /dev/null +++ b/src/third_party/cppcodec/test/catch/scripts/benchmarkCompile.py @@ -0,0 +1,148 @@ +#!/usr/bin/env python + +from __future__ import print_function + +import time, subprocess, sys, os, shutil, glob, random +import argparse + +def median(lst): + lst = sorted(lst) + mid, odd = divmod(len(lst), 2) + if odd: + return lst[mid] + else: + return (lst[mid - 1] + lst[mid]) / 2.0 + +def mean(lst): + return float(sum(lst)) / max(len(lst), 1) + +compiler_path = '' +flags = [] + +main_file = r''' +#define CATCH_CONFIG_MAIN +#include "catch.hpp" +''' +main_name = 'catch-main.cpp' + +dir_name = 'benchmark-dir' + +files = 20 +test_cases_in_file = 20 +sections_in_file = 4 +assertions_per_section = 5 + +checks = [ + 'a != b', 'a != c', 'a != d', 'a != e', 'b != c', 'b != d', 'b != e', 'c != d', 'c != e', 'd != e', 'a + a == a', + 'a + b == b', 'a + c == c', 'a + d == d', 'a + e == e', 'b + a == b', 'b + b == c', 'b + c == d', + 'b + d == e', 'c + a == c', 'c + b == d', 'c + c == e', 'd + a == d', 'd + b == e', 'e + a == e', + 'a + a + a == a', 'b + c == a + d', 'c + a + a == a + b + b + a', + 'a < b', 'b < c', 'c < d', 'd < e', 'a >= a', 'd >= b', +] + +def create_temp_dir(): + if os.path.exists(dir_name): + shutil.rmtree(dir_name) + os.mkdir(dir_name) + +def copy_catch(path_to_catch): + shutil.copy(path_to_catch, dir_name) + +def create_catch_main(): + with open(main_name, 'w') as f: + f.write(main_file) + +def compile_main(): + start_t = time.time() + subprocess.check_call([compiler_path, main_name, '-c'] + flags) + end_t = time.time() + return end_t - start_t + +def compile_files(): + cpp_files = glob.glob('tests*.cpp') + start_t = time.time() + subprocess.check_call([compiler_path, '-c'] + flags + cpp_files) + end_t = time.time() + return end_t - start_t + +def link_files(): + obj_files = glob.glob('*.o') + start_t = time.time() + subprocess.check_call([compiler_path] + flags + obj_files) + end_t = time.time() + return end_t - start_t + +def benchmark(func): + results = [func() for i in range(10)] + return mean(results), median(results) + +def char_range(start, end): + for c in range(ord(start), ord(end)): + yield chr(c) + +def generate_sections(fd): + for i in range(sections_in_file): + fd.write(' SECTION("Section {}") {{\n'.format(i)) + fd.write('\n'.join(' CHECK({});'.format(check) for check in random.sample(checks, assertions_per_section))) + fd.write(' }\n') + + +def generate_file(file_no): + with open('tests{}.cpp'.format(file_no), 'w') as f: + f.write('#include "catch.hpp"\n\n') + for i in range(test_cases_in_file): + f.write('TEST_CASE("File {} test {}", "[.compile]"){{\n'.format(file_no, i)) + for i, c in enumerate(char_range('a', 'f')): + f.write(' int {} = {};\n'.format(c, i)) + generate_sections(f) + f.write('}\n\n') + + +def generate_files(): + create_catch_main() + for i in range(files): + generate_file(i) + + +options = ['all', 'main', 'files', 'link'] + +parser = argparse.ArgumentParser(description='Benchmarks Catch\'s compile times against some synthetic tests') +# Add first arg -- benchmark type +parser.add_argument('benchmark_kind', nargs='?', default='all', choices=options, help='What kind of benchmark to run, default: all') + +# Args to allow changing header/compiler +parser.add_argument('-I', '--catch-header', default='catch.hpp', help = 'Path to catch.hpp, default: catch.hpp') +parser.add_argument('-c', '--compiler', default='g++', help = 'Compiler to use, default: g++') + +parser.add_argument('-f', '--flags', help = 'Flags to be passed to the compiler. Pass as "," separated list') + +# Allow creating files only, without running the whole thing +parser.add_argument('-g', '--generate-files', action='store_true', help='Generate test files and quit') + +args = parser.parse_args() + +compiler_path = args.compiler +catch_path = args.catch_header + +if args.generate_files: + create_temp_dir() + copy_catch(catch_path) + os.chdir(dir_name) + # now create the fake test files + generate_files() + # Early exit + print('Finished generating files') + exit(1) + +os.chdir(dir_name) + +if args.flags: + flags = args.flags.split(',') + +print('Time needed for ...') +if args.benchmark_kind in ('all', 'main'): + print(' ... compiling main, mean: {:.2f}, median: {:.2f} s'.format(*benchmark(compile_main))) +if args.benchmark_kind in ('all', 'files'): + print(' ... compiling test files, mean: {:.2f}, median: {:.2f} s'.format(*benchmark(compile_files))) +if args.benchmark_kind in ('all', 'link'): + print(' ... linking everything, mean: {:.2f}, median: {:.2f} s'.format(*benchmark(link_files))) diff --git a/src/third_party/cppcodec/test/catch/scripts/benchmarkRunner.py b/src/third_party/cppcodec/test/catch/scripts/benchmarkRunner.py new file mode 100755 index 0000000000..dc753cf005 --- /dev/null +++ b/src/third_party/cppcodec/test/catch/scripts/benchmarkRunner.py @@ -0,0 +1,56 @@ +#!/usr/bin/env python3 + +import subprocess, os, sys +import xml.etree.ElementTree as ET +from collections import defaultdict +from statistics import median, stdev +from datetime import datetime + +def get_commit_hash(): + res = subprocess.run('git rev-parse HEAD'.split(), check=True, stdout=subprocess.PIPE, universal_newlines=True) + return res.stdout.strip() + +if len(sys.argv) < 2: + print('Usage: {} benchmark-binary'.format(sys.argv[0])) + exit(1) + + +num_runs = 10 +data = defaultdict(list) + + +def parse_file(file): + + def recursive_search(node): + if node.tag == 'TestCase': + results = node.find('OverallResult') + time = results.get('durationInSeconds') + data[node.get('name')].append(float(time)) + elif node.tag in ('Group', 'Catch'): + for child in node: + recursive_search(child) + + tree = ET.parse(file) + recursive_search(tree.getroot()) + +def run_benchmarks(binary): + call = [binary] + '-d yes -r xml -o'.split() + for i in range(num_runs): + file = 'temp{}.xml'.format(i) + print('Run number {}'.format(i)) + subprocess.run(call + [file]) + parse_file(file) + # Remove file right after parsing, because benchmark output can be big + os.remove(file) + + +# Run benchmarks +run_benchmarks(sys.argv[1]) + +result_file = '{:%Y-%m-%dT%H-%M-%S}-{}.result'.format(datetime.now(), get_commit_hash()) + + +print('Writing results to {}'.format(result_file)) +with open(result_file, 'w') as file: + for k in sorted(data): + file.write('{}: median: {} (s), stddev: {} (s)\n'.format(k, median(data[k]), stdev(data[k]))) diff --git a/src/third_party/cppcodec/test/catch/scripts/developBuild.py b/src/third_party/cppcodec/test/catch/scripts/developBuild.py new file mode 100755 index 0000000000..a8115fe2c8 --- /dev/null +++ b/src/third_party/cppcodec/test/catch/scripts/developBuild.py @@ -0,0 +1,10 @@ +#!/usr/bin/env python + +from __future__ import print_function +import releaseCommon + +v = releaseCommon.Version() +v.incrementBuildNumber() +releaseCommon.performUpdates(v) + +print( "Updated Version.hpp, README and Conan to v{0}".format( v.getVersionString() ) ) diff --git a/src/third_party/cppcodec/test/catch/scripts/embed.py b/src/third_party/cppcodec/test/catch/scripts/embed.py new file mode 100644 index 0000000000..6675703314 --- /dev/null +++ b/src/third_party/cppcodec/test/catch/scripts/embed.py @@ -0,0 +1,63 @@ +import re + +preprocessorRe = re.compile( r'\s*#.*' ) + +fdefineRe = re.compile( r'\s*#\s*define\s*(\S*)\s*\(' ) # #defines that take arguments +defineRe = re.compile( r'\s*#\s*define\s*(\S*)(\s+)(.*)' ) # all #defines +undefRe = re.compile( r'\s*#\s*undef\s*(\S*)' ) # all #undefs + +ifdefCommonRe = re.compile( r'\s*#\s*if' ) # all #ifdefs +ifdefRe = re.compile( r'\s*#\s*ifdef\s*(\S*)' ) +ifndefRe = re.compile( r'\s*#\s*ifndef\s*(\S*)' ) +endifRe = re.compile( r'\s*#\s*endif\s*//\s*(.*)' ) +elseRe = re.compile( r'\s*#\s*else' ) +ifRe = re.compile( r'\s*#\s*if\s+(.*)' ) + +nsRe = re.compile( r'(.*?\s*\s*namespace\s+)(\w+)(\s*{?)(.*)' ) +nsCloseRe = re.compile( r'(.*\s*})(\s*\/\/\s*namespace\s+)(\w+)(\s*)(.*)' ) + + +class LineMapper: + def __init__( self, idMap, outerNamespace ): + self.idMap = idMap + self.outerNamespace = outerNamespace + + # TBD: + # #if, #ifdef, comments after #else + def mapLine( self, lineNo, line ): + for idFrom, idTo in self.idMap.items(): + r = re.compile("(.*)" + idFrom + "(.*)") + + m = r.match( line ) + if m: + line = m.group(1) + idTo + m.group(2) + "\n" + + m = nsCloseRe.match( line ) + if m: + originalNs = m.group(3) + # print("[{0}] originalNs: '{1}' - closing".format(lineNo, originalNs)) + # print( " " + line ) + # print( " 1:[{0}]\n 2:[{1}]\n 3:[{2}]\n 4:[{3}]\n 5:[{4}]".format( m.group(1), m.group(2), m.group(3), m.group(4), m.group(5) ) ) + if originalNs in self.outerNamespace: + outerNs, innerNs = self.outerNamespace[originalNs] + return "{0}}}{1}{2}::{3}{4}{5}\n".format( m.group(1), m.group(2), outerNs, innerNs, m.group(4), m.group(5)) + m = nsRe.match( line ) + if m: + originalNs = m.group(2) + # print("[{0}] originalNs: '{1}'".format(lineNo, originalNs)) + # print( " " + line ) + # print( " 1:[{0}]\n 2:[{1}]\n 3:[{2}]\n 4:[{3}]".format( m.group(1), m.group(2), m.group(3), m.group(4) ) ) + if originalNs in self.outerNamespace: + outerNs, innerNs = self.outerNamespace[originalNs] + return "{0}{1} {{ namespace {2}{3}{4}\n".format( m.group(1), outerNs, innerNs, m.group(3), m.group(4) ) + + return line + + def mapFile(self, filenameIn, filenameOut ): + print( "Embedding:\n {0}\nas:\n {1}".format( filenameIn, filenameOut ) ) + with open( filenameIn, 'r' ) as f, open( filenameOut, 'w' ) as outf: + lineNo = 1 + for line in f: + outf.write( self.mapLine( lineNo, line ) ) + lineNo = lineNo + 1 + print( "Written {0} lines".format( lineNo ) ) \ No newline at end of file diff --git a/src/third_party/cppcodec/test/catch/scripts/embedClara.py b/src/third_party/cppcodec/test/catch/scripts/embedClara.py new file mode 100755 index 0000000000..7ceb3e32e2 --- /dev/null +++ b/src/third_party/cppcodec/test/catch/scripts/embedClara.py @@ -0,0 +1,27 @@ +#!/usr/bin/env python + +# Execute this script any time you import a new copy of Clara into the third_party area +import os +import sys +import embed + +rootPath = os.path.dirname(os.path.realpath( os.path.dirname(sys.argv[0]))) + +filename = os.path.join( rootPath, "third_party", "clara.hpp" ) +outfilename = os.path.join( rootPath, "include", "external", "clara.hpp" ) + + +# Mapping of pre-processor identifiers +idMap = { + "CLARA_HPP_INCLUDED": "CATCH_CLARA_HPP_INCLUDED", + "CLARA_CONFIG_CONSOLE_WIDTH": "CATCH_CLARA_CONFIG_CONSOLE_WIDTH", + "CLARA_TEXTFLOW_HPP_INCLUDED": "CATCH_CLARA_TEXTFLOW_HPP_INCLUDED", + "CLARA_TEXTFLOW_CONFIG_CONSOLE_WIDTH": "CATCH_CLARA_TEXTFLOW_CONFIG_CONSOLE_WIDTH", + "CLARA_PLATFORM_WINDOWS": "CATCH_PLATFORM_WINDOWS" + } + +# outer namespace to add +outerNamespace = { "clara": ("Catch", "clara") } + +mapper = embed.LineMapper( idMap, outerNamespace ) +mapper.mapFile( filename, outfilename ) \ No newline at end of file diff --git a/src/third_party/cppcodec/test/catch/scripts/fixWhitespace.py b/src/third_party/cppcodec/test/catch/scripts/fixWhitespace.py new file mode 100755 index 0000000000..bfa4aa08e6 --- /dev/null +++ b/src/third_party/cppcodec/test/catch/scripts/fixWhitespace.py @@ -0,0 +1,52 @@ +#!/usr/bin/env python + +from __future__ import print_function +import os +from scriptCommon import catchPath + +def isSourceFile( path ): + return path.endswith( ".cpp" ) or path.endswith( ".h" ) or path.endswith( ".hpp" ) + +def fixAllFilesInDir( dir ): + changedFiles = 0 + for f in os.listdir( dir ): + path = os.path.join( dir,f ) + if os.path.isfile( path ): + if isSourceFile( path ): + if fixFile( path ): + changedFiles += 1 + else: + fixAllFilesInDir( path ) + return changedFiles + +def fixFile( path ): + f = open( path, 'r' ) + lines = [] + changed = 0 + for line in f: + trimmed = line.rstrip() + "\n" + trimmed = trimmed.replace('\t', ' ') + if trimmed != line: + changed = changed +1 + lines.append( trimmed ) + f.close() + if changed > 0: + global changedFiles + changedFiles = changedFiles + 1 + print( path + ":" ) + print( " - fixed " + str(changed) + " line(s)" ) + altPath = path + ".backup" + os.rename( path, altPath ) + f2 = open( path, 'w' ) + for line in lines: + f2.write( line ) + f2.close() + os.remove( altPath ) + return True + return False + +changedFiles = fixAllFilesInDir(catchPath) +if changedFiles > 0: + print( "Fixed " + str(changedFiles) + " file(s)" ) +else: + print( "No trailing whitespace found" ) diff --git a/src/third_party/cppcodec/test/catch/scripts/generateSingleHeader.py b/src/third_party/cppcodec/test/catch/scripts/generateSingleHeader.py new file mode 100755 index 0000000000..22b882abf1 --- /dev/null +++ b/src/third_party/cppcodec/test/catch/scripts/generateSingleHeader.py @@ -0,0 +1,129 @@ +#!/usr/bin/env python + +from __future__ import print_function + +import os +import io +import sys +import re +import datetime +from glob import glob + +from scriptCommon import catchPath + +def generate(v): + includesParser = re.compile( r'\s*#\s*include\s*"(.*)"' ) + guardParser = re.compile( r'\s*#.*(TWOBLUECUBES_)?CATCH_.*_INCLUDED') + defineParser = re.compile( r'\s*#define\s+(TWOBLUECUBES_)?CATCH_.*_INCLUDED') + ifParser = re.compile( r'\s*#ifndef (TWOBLUECUBES_)?CATCH_.*_INCLUDED') + endIfParser = re.compile( r'\s*#endif // (TWOBLUECUBES_)?CATCH_.*_INCLUDED') + ifImplParser = re.compile( r'\s*#ifdef CATCH_CONFIG_RUNNER' ) + commentParser1 = re.compile( r'^\s*/\*') + commentParser2 = re.compile( r'^ \*') + blankParser = re.compile( r'^\s*$') + + seenHeaders = set([]) + rootPath = os.path.join( catchPath, 'include/' ) + outputPath = os.path.join( catchPath, 'single_include/catch2/catch.hpp' ) + + globals = { + 'includeImpl' : True, + 'ifdefs' : 0, + 'implIfDefs' : -1 + } + + for arg in sys.argv[1:]: + arg = arg.lower() + if arg == "noimpl": + globals['includeImpl'] = False + print( "Not including impl code" ) + else: + print( "\n** Unrecognised argument: " + arg + " **\n" ) + exit(1) + + + # ensure that the output directory exists (hopefully no races) + outDir = os.path.dirname(outputPath) + if not os.path.exists(outDir): + os.makedirs(outDir) + out = io.open( outputPath, 'w', newline='\n') + + def write( line ): + if globals['includeImpl'] or globals['implIfDefs'] == -1: + out.write( line ) + + def insertCpps(): + dirs = [os.path.join( rootPath, s) for s in ['', 'internal', 'reporters']] + cppFiles = [] + for dir in dirs: + cppFiles += glob(os.path.join(dir, '*.cpp')) + # To minimize random diffs, sort the files before processing them + for fname in sorted(cppFiles): + dir, name = fname.rsplit(os.path.sep, 1) + dir += os.path.sep + parseFile(dir, name) + + def parseFile( path, filename ): + f = io.open( os.path.join(path, filename), 'r', encoding='utf-8' ) + blanks = 0 + write( u"// start {0}\n".format( filename ) ) + for line in f: + if '// ~*~* CATCH_CPP_STITCH_PLACE *~*~' in line: + insertCpps() + continue + elif ifParser.match( line ): + globals['ifdefs'] += 1 + elif endIfParser.match( line ): + globals['ifdefs'] -= 1 + if globals['ifdefs'] == globals['implIfDefs']: + globals['implIfDefs'] = -1 + m = includesParser.match( line ) + if m: + header = m.group(1) + headerPath, sep, headerFile = header.rpartition( "/" ) + if headerFile not in seenHeaders: + if headerFile != "tbc_text_format.h" and headerFile != "clara.h": + seenHeaders.add( headerFile ) + if headerPath == "internal" and path.endswith("internal/"): + headerPath = "" + sep = "" + if os.path.exists( path + headerPath + sep + headerFile ): + parseFile( path + headerPath + sep, headerFile ) + else: + parseFile( rootPath + headerPath + sep, headerFile ) + else: + if ifImplParser.match(line): + globals['implIfDefs'] = globals['ifdefs'] + if (not guardParser.match( line ) or defineParser.match( line ) ) and not commentParser1.match( line )and not commentParser2.match( line ): + if blankParser.match( line ): + blanks = blanks + 1 + else: + blanks = 0 + if blanks < 2 and not defineParser.match(line): + write( line.rstrip() + "\n" ) + write( u'// end {}\n'.format(filename) ) + + + write( u"/*\n" ) + write( u" * Catch v{0}\n".format( v.getVersionString() ) ) + write( u" * Generated: {0}\n".format( datetime.datetime.now() ) ) + write( u" * ----------------------------------------------------------\n" ) + write( u" * This file has been merged from multiple headers. Please don't edit it directly\n" ) + write( u" * Copyright (c) {} Two Blue Cubes Ltd. All rights reserved.\n".format( datetime.date.today().year ) ) + write( u" *\n" ) + write( u" * Distributed under the Boost Software License, Version 1.0. (See accompanying\n" ) + write( u" * file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)\n" ) + write( u" */\n" ) + write( u"#ifndef TWOBLUECUBES_SINGLE_INCLUDE_CATCH_HPP_INCLUDED\n" ) + write( u"#define TWOBLUECUBES_SINGLE_INCLUDE_CATCH_HPP_INCLUDED\n" ) + + parseFile( rootPath, 'catch.hpp' ) + + write( u"#endif // TWOBLUECUBES_SINGLE_INCLUDE_CATCH_HPP_INCLUDED\n\n" ) + out.close() + print ("Generated single include for Catch v{0}\n".format( v.getVersionString() ) ) + + +if __name__ == '__main__': + from releaseCommon import Version + generate(Version()) diff --git a/src/third_party/cppcodec/test/catch/scripts/majorRelease.py b/src/third_party/cppcodec/test/catch/scripts/majorRelease.py new file mode 100755 index 0000000000..8da34066c5 --- /dev/null +++ b/src/third_party/cppcodec/test/catch/scripts/majorRelease.py @@ -0,0 +1,10 @@ +#!/usr/bin/env python + +from __future__ import print_function +import releaseCommon + +v = releaseCommon.Version() +v.incrementMajorVersion() +releaseCommon.performUpdates(v) + +print( "Updated Version.hpp, README and Conan to v{0}".format( v.getVersionString() ) ) diff --git a/src/third_party/cppcodec/test/catch/scripts/minorRelease.py b/src/third_party/cppcodec/test/catch/scripts/minorRelease.py new file mode 100755 index 0000000000..6e71cd80ec --- /dev/null +++ b/src/third_party/cppcodec/test/catch/scripts/minorRelease.py @@ -0,0 +1,10 @@ +#!/usr/bin/env python + +from __future__ import print_function +import releaseCommon + +v = releaseCommon.Version() +v.incrementMinorVersion() +releaseCommon.performUpdates(v) + +print( "Updated Version.hpp, README and Conan to v{0}".format( v.getVersionString() ) ) diff --git a/src/third_party/cppcodec/test/catch/scripts/patchRelease.py b/src/third_party/cppcodec/test/catch/scripts/patchRelease.py new file mode 100755 index 0000000000..1417642065 --- /dev/null +++ b/src/third_party/cppcodec/test/catch/scripts/patchRelease.py @@ -0,0 +1,10 @@ +#!/usr/bin/env python + +from __future__ import print_function +import releaseCommon + +v = releaseCommon.Version() +v.incrementPatchNumber() +releaseCommon.performUpdates(v) + +print( "Updated Version.hpp, README and Conan to v{0}".format( v.getVersionString() ) ) diff --git a/src/third_party/cppcodec/test/catch/scripts/releaseCommon.py b/src/third_party/cppcodec/test/catch/scripts/releaseCommon.py new file mode 100644 index 0000000000..1a8ee2c87e --- /dev/null +++ b/src/third_party/cppcodec/test/catch/scripts/releaseCommon.py @@ -0,0 +1,178 @@ +from __future__ import print_function + +import os +import sys +import re +import string + +from scriptCommon import catchPath + +versionParser = re.compile( r'(\s*static\sVersion\sversion)\s*\(\s*(.*)\s*,\s*(.*)\s*,\s*(.*)\s*,\s*\"(.*)\"\s*,\s*(.*)\s*\).*' ) +rootPath = os.path.join( catchPath, 'include/' ) +versionPath = os.path.join( rootPath, "internal/catch_version.cpp" ) +definePath = os.path.join(rootPath, 'catch.hpp') +readmePath = os.path.join( catchPath, "README.md" ) +conanPath = os.path.join(catchPath, 'conanfile.py') +conanTestPath = os.path.join(catchPath, 'test_package', 'conanfile.py') +cmakePath = os.path.join(catchPath, 'CMakeLists.txt') + +class Version: + def __init__(self): + f = open( versionPath, 'r' ) + for line in f: + m = versionParser.match( line ) + if m: + self.variableDecl = m.group(1) + self.majorVersion = int(m.group(2)) + self.minorVersion = int(m.group(3)) + self.patchNumber = int(m.group(4)) + self.branchName = m.group(5) + self.buildNumber = int(m.group(6)) + f.close() + + def nonDevelopRelease(self): + if self.branchName != "": + self.branchName = "" + self.buildNumber = 0 + def developBuild(self): + if self.branchName == "": + self.branchName = "develop" + self.buildNumber = 0 + + def incrementBuildNumber(self): + self.developBuild() + self.buildNumber = self.buildNumber+1 + + def incrementPatchNumber(self): + self.nonDevelopRelease() + self.patchNumber = self.patchNumber+1 + + def incrementMinorVersion(self): + self.nonDevelopRelease() + self.patchNumber = 0 + self.minorVersion = self.minorVersion+1 + + def incrementMajorVersion(self): + self.nonDevelopRelease() + self.patchNumber = 0 + self.minorVersion = 0 + self.majorVersion = self.majorVersion+1 + + def getVersionString(self): + versionString = '{0}.{1}.{2}'.format( self.majorVersion, self.minorVersion, self.patchNumber ) + if self.branchName != "": + versionString = versionString + '-{0}.{1}'.format( self.branchName, self.buildNumber ) + return versionString + + def updateVersionFile(self): + f = open( versionPath, 'r' ) + lines = [] + for line in f: + m = versionParser.match( line ) + if m: + lines.append( '{0}( {1}, {2}, {3}, "{4}", {5} );'.format( self.variableDecl, self.majorVersion, self.minorVersion, self.patchNumber, self.branchName, self.buildNumber ) ) + else: + lines.append( line.rstrip() ) + f.close() + f = open( versionPath, 'w' ) + for line in lines: + f.write( line + "\n" ) + +def updateReadmeFile(version): + import updateWandbox + + downloadParser = re.compile( r'' ) + success, wandboxLink = updateWandbox.uploadFiles() + if not success: + print('Error when uploading to wandbox: {}'.format(wandboxLink)) + exit(1) + f = open( readmePath, 'r' ) + lines = [] + for line in f: + lines.append( line.rstrip() ) + f.close() + f = open( readmePath, 'w' ) + for line in lines: + line = downloadParser.sub( r''.format(version.getVersionString()) , line) + if '[![Try online](https://img.shields.io/badge/try-online-blue.svg)]' in line: + line = '[![Try online](https://img.shields.io/badge/try-online-blue.svg)]({0})'.format(wandboxLink) + f.write( line + "\n" ) + +def updateConanFile(version): + conanParser = re.compile( r' version = "\d+\.\d+\.\d+.*"') + f = open( conanPath, 'r' ) + lines = [] + for line in f: + m = conanParser.match( line ) + if m: + lines.append( ' version = "{0}"'.format(format(version.getVersionString())) ) + else: + lines.append( line.rstrip() ) + f.close() + f = open( conanPath, 'w' ) + for line in lines: + f.write( line + "\n" ) + +def updateConanTestFile(version): + conanParser = re.compile( r' requires = \"Catch\/\d+\.\d+\.\d+.*@%s\/%s\" % \(username, channel\)') + f = open( conanTestPath, 'r' ) + lines = [] + for line in f: + m = conanParser.match( line ) + if m: + lines.append( ' requires = "Catch/{0}@%s/%s" % (username, channel)'.format(format(version.getVersionString())) ) + else: + lines.append( line.rstrip() ) + f.close() + f = open( conanTestPath, 'w' ) + for line in lines: + f.write( line + "\n" ) + +def updateCmakeFile(version): + with open(cmakePath, 'r') as file: + lines = file.readlines() + with open(cmakePath, 'w') as file: + for line in lines: + if 'project(Catch2 LANGUAGES CXX VERSION ' in line: + file.write('project(Catch2 LANGUAGES CXX VERSION {0})\n'.format(version.getVersionString())) + else: + file.write(line) + + +def updateVersionDefine(version): + with open(definePath, 'r') as file: + lines = file.readlines() + with open(definePath, 'w') as file: + for line in lines: + if '#define CATCH_VERSION_MAJOR' in line: + file.write('#define CATCH_VERSION_MAJOR {}\n'.format(version.majorVersion)) + elif '#define CATCH_VERSION_MINOR' in line: + file.write('#define CATCH_VERSION_MINOR {}\n'.format(version.minorVersion)) + elif '#define CATCH_VERSION_PATCH' in line: + file.write('#define CATCH_VERSION_PATCH {}\n'.format(version.patchNumber)) + else: + file.write(line) + + +def performUpdates(version): + # First update version file, so we can regenerate single header and + # have it ready for upload to wandbox, when updating readme + version.updateVersionFile() + updateVersionDefine(version) + + import generateSingleHeader + generateSingleHeader.generate(version) + + # Then copy the reporters to single include folder to keep them in sync + # We probably should have some kind of convention to select which reporters need to be copied automagically, + # but this works for now + import shutil + for rep in ('automake', 'tap', 'teamcity'): + sourceFile = os.path.join(catchPath, 'include/reporters/catch_reporter_{}.hpp'.format(rep)) + destFile = os.path.join(catchPath, 'single_include', 'catch2', 'catch_reporter_{}.hpp'.format(rep)) + shutil.copyfile(sourceFile, destFile) + + updateReadmeFile(version) + updateConanFile(version) + updateConanTestFile(version) + updateCmakeFile(version) diff --git a/src/third_party/cppcodec/test/catch/scripts/releaseNotes.py b/src/third_party/cppcodec/test/catch/scripts/releaseNotes.py new file mode 100755 index 0000000000..5e770bba76 --- /dev/null +++ b/src/third_party/cppcodec/test/catch/scripts/releaseNotes.py @@ -0,0 +1,65 @@ +#!/usr/bin/env python + +from __future__ import print_function + +import os +import re +import urllib2 +import json + +from scriptCommon import catchPath +from scriptCommon import runAndCapture + +issueNumberRe = re.compile( r'(.*?)#([0-9]*)([^0-9]?.*)' ) + +rootPath = os.path.join( catchPath, 'include/' ) +versionPath = os.path.join( rootPath, "internal/catch_version.hpp" ) + + +hashes = runAndCapture( ['git', 'log', '-2', '--format="%H"', versionPath] ) +lines = runAndCapture( ['git', 'log', hashes[1] + ".." + hashes[0], catchPath] ) + +prevLine = "" +messages = [] +dates = [] +issues = {} + +def getIssueTitle( issueNumber ): + try: + s = urllib2.urlopen("https://api.github.com/repos/philsquared/catch/issues/" + issueNumber ).read() + except: + return "#HTTP Error#" + + try: + j = json.loads( s ) + return j["title"] + except: + return "#JSON Error#" + +for line in lines: + if line.startswith( "commit"): + pass + elif line.startswith( "Author:"): + pass + elif line.startswith( "Date:"): + dates.append( line[5:].lstrip() ) + elif line == "" and prevLine == "": + pass + else: + prevLine = line + match = issueNumberRe.match( line ) + line2 = "" + while match: + issueNumber = match.group(2) + issue = '#{0} ("{1}")'.format( issueNumber, getIssueTitle( issueNumber ) ) + line2 = line2 + match.group(1) + issue + match = issueNumberRe.match( match.group(3) ) + if line2 == "": + messages.append( line ) + else: + messages.append( line2 ) + +print("All changes between {0} and {1}:\n".format( dates[-1], dates[0] )) + +for line in messages: + print(line) diff --git a/src/third_party/cppcodec/test/catch/scripts/scriptCommon.py b/src/third_party/cppcodec/test/catch/scripts/scriptCommon.py new file mode 100644 index 0000000000..4b70f9613c --- /dev/null +++ b/src/third_party/cppcodec/test/catch/scripts/scriptCommon.py @@ -0,0 +1,26 @@ +import os +import sys +import subprocess + + +catchPath = os.path.dirname(os.path.realpath( os.path.dirname(sys.argv[0]))) + +def getBuildExecutable(): + dir = os.environ.get('CATCH_DEV_OUT_DIR', "cmake-build-debug/projects/SelfTest") + return dir + +def runAndCapture( args ): + child = subprocess.Popen(" ".join( args ), shell=True, stdout=subprocess.PIPE) + lines = [] + line = "" + while True: + out = child.stdout.read(1) + if out == '' and child.poll(): + break + if out != '': + if out == '\n': + lines.append( line ) + line = "" + else: + line = line + out + return lines diff --git a/src/third_party/cppcodec/test/catch/scripts/updateDocumentToC.py b/src/third_party/cppcodec/test/catch/scripts/updateDocumentToC.py new file mode 100644 index 0000000000..d3b8bf0ffe --- /dev/null +++ b/src/third_party/cppcodec/test/catch/scripts/updateDocumentToC.py @@ -0,0 +1,447 @@ +#!/usr/bin/env python + +# +# updateDocumentToC.py +# +# Insert table of contents at top of Catch markdown documents. +# +# This script is distributed under the GNU General Public License v3.0 +# +# It is based on markdown-toclify version 1.7.1 by Sebastian Raschka, +# https://github.com/rasbt/markdown-toclify +# + +from __future__ import print_function + +import argparse +import glob +import os +import re +import sys + +from scriptCommon import catchPath + +# Configuration: + +minTocEntries = 4 + +headingExcludeDefault = [1,3,4,5] # use level 2 headers for at default +headingExcludeRelease = [2,3,4,5] # use level 1 headers for release-notes.md + +documentsDefault = os.path.join(os.path.relpath(catchPath), 'docs/*.md') +releaseNotesName = 'release-notes.md' + +contentTitle = '**Contents**' +contentLineNo = 4 +contentLineNdx = contentLineNo - 1 + +# End configuration + +VALIDS = '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ_-&' + +def readLines(in_file): + """Returns a list of lines from a input markdown file.""" + + with open(in_file, 'r') as inf: + in_contents = inf.read().split('\n') + return in_contents + +def removeLines(lines, remove=('[[back to top]', ' tags.""" + + if not remove: + return lines[:] + + out = [] + for l in lines: + if l.startswith(remove): + continue + out.append(l) + return out + +def removeToC(lines): + """Removes existing table of contents starting at index contentLineNdx.""" + if not lines[contentLineNdx ].startswith(contentTitle): + return lines[:] + + result_top = lines[:contentLineNdx] + + pos = contentLineNdx + 1 + while lines[pos].startswith('['): + pos = pos + 1 + + result_bottom = lines[pos + 1:] + + return result_top + result_bottom + +def dashifyHeadline(line): + """ + Takes a header line from a Markdown document and + returns a tuple of the + '#'-stripped version of the head line, + a string version for anchor tags, + and the level of the headline as integer. + E.g., + >>> dashifyHeadline('### some header lvl3') + ('Some header lvl3', 'some-header-lvl3', 3) + + """ + stripped_right = line.rstrip('#') + stripped_both = stripped_right.lstrip('#') + level = len(stripped_right) - len(stripped_both) + stripped_wspace = stripped_both.strip() + + # character replacements + replaced_colon = stripped_wspace.replace('.', '') + replaced_slash = replaced_colon.replace('/', '') + rem_nonvalids = ''.join([c if c in VALIDS + else '-' for c in replaced_slash]) + + lowered = rem_nonvalids.lower() + dashified = re.sub(r'(-)\1+', r'\1', lowered) # remove duplicate dashes + dashified = dashified.strip('-') # strip dashes from start and end + + # exception '&' (double-dash in github) + dashified = dashified.replace('-&-', '--') + + return [stripped_wspace, dashified, level] + +def tagAndCollect(lines, id_tag=True, back_links=False, exclude_h=None): + """ + Gets headlines from the markdown document and creates anchor tags. + + Keyword arguments: + lines: a list of sublists where every sublist + represents a line from a Markdown document. + id_tag: if true, creates inserts a the tags (not req. by GitHub) + back_links: if true, adds "back to top" links below each headline + exclude_h: header levels to exclude. E.g., [2, 3] + excludes level 2 and 3 headings. + + Returns a tuple of 2 lists: + 1st list: + A modified version of the input list where + anchor tags where inserted + above the header lines (if github is False). + + 2nd list: + A list of 3-value sublists, where the first value + represents the heading, the second value the string + that was inserted assigned to the IDs in the anchor tags, + and the third value is an integer that represents the headline level. + E.g., + [['some header lvl3', 'some-header-lvl3', 3], ...] + + """ + out_contents = [] + headlines = [] + for l in lines: + saw_headline = False + + orig_len = len(l) + l_stripped = l.lstrip() + + if l_stripped.startswith(('# ', '## ', '### ', '#### ', '##### ', '###### ')): + + # comply with new markdown standards + + # not a headline if '#' not followed by whitespace '##no-header': + if not l.lstrip('#').startswith(' '): + continue + # not a headline if more than 6 '#': + if len(l) - len(l.lstrip('#')) > 6: + continue + # headers can be indented by at most 3 spaces: + if orig_len - len(l_stripped) > 3: + continue + + # ignore empty headers + if not set(l) - {'#', ' '}: + continue + + saw_headline = True + dashified = dashifyHeadline(l) + + if not exclude_h or not dashified[-1] in exclude_h: + if id_tag: + id_tag = ''\ + % (dashified[1]) + out_contents.append(id_tag) + headlines.append(dashified) + + out_contents.append(l) + if back_links and saw_headline: + out_contents.append('[[back to top](#table-of-contents)]') + return out_contents, headlines + +def positioningHeadlines(headlines): + """ + Strips unnecessary whitespaces/tabs if first header is not left-aligned + """ + left_just = False + for row in headlines: + if row[-1] == 1: + left_just = True + break + if not left_just: + for row in headlines: + row[-1] -= 1 + return headlines + +def createToc(headlines, hyperlink=True, top_link=False, no_toc_header=False): + """ + Creates the table of contents from the headline list + that was returned by the tagAndCollect function. + + Keyword Arguments: + headlines: list of lists + e.g., ['Some header lvl3', 'some-header-lvl3', 3] + hyperlink: Creates hyperlinks in Markdown format if True, + e.g., '- [Some header lvl1](#some-header-lvl1)' + top_link: if True, add a id tag for linking the table + of contents itself (for the back-to-top-links) + no_toc_header: suppresses TOC header if True. + + Returns a list of headlines for a table of contents + in Markdown format, + e.g., [' - [Some header lvl3](#some-header-lvl3)', ...] + + """ + processed = [] + if not no_toc_header: + if top_link: + processed.append('\n') + processed.append(contentTitle + '
') + + for line in headlines: + if hyperlink: + item = '[%s](#%s)' % (line[0], line[1]) + else: + item = '%s- %s' % ((line[2]-1)*' ', line[0]) + processed.append(item + '
') + processed.append('\n') + return processed + +def buildMarkdown(toc_headlines, body, spacer=0, placeholder=None): + """ + Returns a string with the Markdown output contents incl. + the table of contents. + + Keyword arguments: + toc_headlines: lines for the table of contents + as created by the createToc function. + body: contents of the Markdown file including + ID-anchor tags as returned by the + tagAndCollect function. + spacer: Adds vertical space after the table + of contents. Height in pixels. + placeholder: If a placeholder string is provided, the placeholder + will be replaced by the TOC instead of inserting the TOC at + the top of the document + + """ + if spacer: + spacer_line = ['\n
\n' % (spacer)] + toc_markdown = "\n".join(toc_headlines + spacer_line) + else: + toc_markdown = "\n".join(toc_headlines) + + if placeholder: + body_markdown = "\n".join(body) + markdown = body_markdown.replace(placeholder, toc_markdown) + else: + body_markdown_p1 = "\n".join(body[:contentLineNdx ]) + '\n' + body_markdown_p2 = "\n".join(body[ contentLineNdx:]) + markdown = body_markdown_p1 + toc_markdown + body_markdown_p2 + + return markdown + +def outputMarkdown(markdown_cont, output_file): + """ + Writes to an output file if `outfile` is a valid path. + + """ + if output_file: + with open(output_file, 'w') as out: + out.write(markdown_cont) + +def markdownToclify( + input_file, + output_file=None, + min_toc_len=2, + github=False, + back_to_top=False, + nolink=False, + no_toc_header=False, + spacer=0, + placeholder=None, + exclude_h=None): + """ Function to add table of contents to markdown files. + + Parameters + ----------- + input_file: str + Path to the markdown input file. + + output_file: str (default: None) + Path to the markdown output file. + + min_toc_len: int (default: 2) + Miniumum number of entries to create a table of contents for. + + github: bool (default: False) + Uses GitHub TOC syntax if True. + + back_to_top: bool (default: False) + Inserts back-to-top links below headings if True. + + nolink: bool (default: False) + Creates the table of contents without internal links if True. + + no_toc_header: bool (default: False) + Suppresses the Table of Contents header if True + + spacer: int (default: 0) + Inserts horizontal space (in pixels) after the table of contents. + + placeholder: str (default: None) + Inserts the TOC at the placeholder string instead + of inserting the TOC at the top of the document. + + exclude_h: list (default None) + Excludes header levels, e.g., if [2, 3], ignores header + levels 2 and 3 in the TOC. + + Returns + ----------- + changed: Boolean + True if the file has been updated, False otherwise. + + """ + cleaned_contents = removeLines( + removeToC(readLines(input_file)), + remove=('[[back to top]', '= (3, 3): + os.replace(output_file, input_file) + else: + os.remove(input_file) + os.rename(output_file, input_file) + + return 1 + +def updateDocumentToC(paths, min_toc_len, verbose): + """Add or update table of contents to specified paths. Return number of changed files""" + n = 0 + for g in paths: + for f in glob.glob(g): + if os.path.isfile(f): + n = n + updateSingleDocumentToC(input_file=f, min_toc_len=min_toc_len, verbose=verbose) + return n + +def updateDocumentToCMain(): + """Add or update table of contents to specified paths.""" + + parser = argparse.ArgumentParser( + description='Add or update table of contents in markdown documents.', + epilog="""""", + formatter_class=argparse.RawTextHelpFormatter) + + parser.add_argument( + 'Input', + metavar='file', + type=str, + nargs=argparse.REMAINDER, + help='files to process, at default: docs/*.md') + + parser.add_argument( + '-v', '--verbose', + action='store_true', + help='report the name of the file being processed') + + parser.add_argument( + '--min-toc-entries', + dest='minTocEntries', + default=minTocEntries, + type=int, + metavar='N', + help='the minimum number of entries to create a table of contents for [{default}]'.format(default=minTocEntries)) + + parser.add_argument( + '--remove-toc', + action='store_const', + dest='minTocEntries', + const=99, + help='remove all tables of contents') + + args = parser.parse_args() + + paths = args.Input if args.Input else [documentsDefault] + + changedFiles = updateDocumentToC(paths=paths, min_toc_len=args.minTocEntries, verbose=args.verbose) + + if changedFiles > 0: + print( "Processed table of contents in " + str(changedFiles) + " file(s)" ) + else: + print( "No table of contents added or updated" ) + +if __name__ == '__main__': + updateDocumentToCMain() + +# end of file diff --git a/src/third_party/cppcodec/test/catch/scripts/updateWandbox.py b/src/third_party/cppcodec/test/catch/scripts/updateWandbox.py new file mode 100644 index 0000000000..564f94890d --- /dev/null +++ b/src/third_party/cppcodec/test/catch/scripts/updateWandbox.py @@ -0,0 +1,47 @@ +#!/usr/bin/env python + +import json +import os +import urllib2 + +from scriptCommon import catchPath + +def upload(options): + request = urllib2.Request('http://melpon.org/wandbox/api/compile.json') + request.add_header('Content-Type', 'application/json') + response = urllib2.urlopen(request, json.dumps(options)) + return json.loads(response.read()) + +main_file = ''' +#define CATCH_CONFIG_MAIN // This tells Catch to provide a main() - only do this in one cpp file +#include "catch.hpp" + +unsigned int Factorial( unsigned int number ) { + return number <= 1 ? number : Factorial(number-1)*number; +} + +TEST_CASE( "Factorials are computed", "[factorial]" ) { + REQUIRE( Factorial(1) == 1 ); + REQUIRE( Factorial(2) == 2 ); + REQUIRE( Factorial(3) == 6 ); + REQUIRE( Factorial(10) == 3628800 ); +} +''' + +def uploadFiles(): + response = upload({ + 'compiler': 'gcc-head', + 'code': main_file, + 'codes': [{ + 'file': 'catch.hpp', + 'code': open(os.path.join(catchPath, 'single_include', 'catch2', 'catch.hpp')).read() + }], + 'options': 'c++11,cpp-no-pedantic,boost-nothing', + 'compiler-option-raw': '-DCATCH_CONFIG_FAST_COMPILE', + 'save': True + }) + + if 'status' in response and 'compiler_error' not in response: + return True, response['url'] + else: + return False, response diff --git a/src/third_party/cppcodec/test/catch/single_include/catch2/catch.hpp b/src/third_party/cppcodec/test/catch/single_include/catch2/catch.hpp new file mode 100644 index 0000000000..bdc2f74a9a --- /dev/null +++ b/src/third_party/cppcodec/test/catch/single_include/catch2/catch.hpp @@ -0,0 +1,13359 @@ +/* + * Catch v2.3.0 + * Generated: 2018-07-23 10:09:14.936841 + * ---------------------------------------------------------- + * This file has been merged from multiple headers. Please don't edit it directly + * Copyright (c) 2018 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 3 +#define CATCH_VERSION_PATCH 0 + +#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__ + // GCC likes to warn on REQUIREs, and we cannot suppress them + // locally because g++'s support for _Pragma is lacking in older, + // still supported, versions +# pragma GCC diagnostic ignored "-Wparentheses" +# 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 + +#ifdef __APPLE__ +# include +# if TARGET_OS_OSX == 1 +# define CATCH_PLATFORM_MAC +# elif 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? +// **************** +// 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 +# define CATCH_CPP14_OR_GREATER +# endif + +# if __cplusplus >= 201703L +# define CATCH_CPP17_OR_GREATER +# endif + +#endif + +#if defined(CATCH_CPP17_OR_GREATER) +# define CATCH_INTERNAL_CONFIG_CPP17_UNCAUGHT_EXCEPTIONS +#endif + +#ifdef __clang__ + +# define CATCH_INTERNAL_SUPPRESS_GLOBALS_WARNINGS \ + _Pragma( "clang diagnostic push" ) \ + _Pragma( "clang diagnostic ignored \"-Wexit-time-destructors\"" ) \ + _Pragma( "clang diagnostic ignored \"-Wglobal-constructors\"") +# define CATCH_INTERNAL_UNSUPPRESS_GLOBALS_WARNINGS \ + _Pragma( "clang diagnostic pop" ) + +# define CATCH_INTERNAL_SUPPRESS_PARENTHESES_WARNINGS \ + _Pragma( "clang diagnostic push" ) \ + _Pragma( "clang diagnostic ignored \"-Wparentheses\"" ) +# define CATCH_INTERNAL_UNSUPPRESS_PARENTHESES_WARNINGS \ + _Pragma( "clang diagnostic pop" ) + +# define CATCH_INTERNAL_SUPPRESS_UNUSED_WARNINGS \ + _Pragma( "clang diagnostic push" ) \ + _Pragma( "clang diagnostic ignored \"-Wunused-variable\"" ) +# define CATCH_INTERNAL_UNSUPPRESS_UNUSED_WARNINGS \ + _Pragma( "clang diagnostic pop" ) + +#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 +#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 + +#endif // __CYGWIN__ + +//////////////////////////////////////////////////////////////////////////////// +// Visual C++ +#ifdef _MSC_VER + +# if _MSC_VER >= 1900 // Visual Studio 2015 or newer +# define CATCH_INTERNAL_CONFIG_CPP17_UNCAUGHT_EXCEPTIONS +# endif + +// 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 + +#endif // _MSC_VER + +//////////////////////////////////////////////////////////////////////////////// + +// DJGPP +#ifdef __DJGPP__ +# define CATCH_INTERNAL_CONFIG_NO_WCHAR +#endif // __DJGPP__ + +//////////////////////////////////////////////////////////////////////////////// + +// 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 + +#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_UNCAUGHT_EXCEPTIONS) && !defined(CATCH_CONFIG_NO_CPP17_UNCAUGHT_EXCEPTIONS) && !defined(CATCH_CONFIG_CPP17_UNCAUGHT_EXCEPTIONS) +# define CATCH_CONFIG_CPP17_UNCAUGHT_EXCEPTIONS +#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_SUPPRESS_PARENTHESES_WARNINGS) +# define CATCH_INTERNAL_SUPPRESS_PARENTHESES_WARNINGS +# define CATCH_INTERNAL_UNSUPPRESS_PARENTHESES_WARNINGS +#endif +#if !defined(CATCH_INTERNAL_SUPPRESS_GLOBALS_WARNINGS) +# define CATCH_INTERNAL_SUPPRESS_GLOBALS_WARNINGS +# define CATCH_INTERNAL_UNSUPPRESS_GLOBALS_WARNINGS +#endif +#if !defined(CATCH_INTERNAL_SUPPRESS_UNUSED_WARNINGS) +# define CATCH_INTERNAL_SUPPRESS_UNUSED_WARNINGS +# define CATCH_INTERNAL_UNSUPPRESS_UNUSED_WARNINGS +#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 + +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( SourceLineInfo && ) = default; + SourceLineInfo& operator = ( SourceLineInfo const& ) = default; + SourceLineInfo& operator = ( SourceLineInfo && ) = default; + + bool empty() const noexcept; + 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 ); + + // 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_SUPPRESS_GLOBALS_WARNINGS \ + namespace{ Catch::RegistrarForTagAliases INTERNAL_CATCH_UNIQUE_NAME( AutoRegisterTagAlias )( alias, spec, CATCH_INTERNAL_LINEINFO ); } \ + CATCH_INTERNAL_UNSUPPRESS_GLOBALS_WARNINGS + +// end catch_tag_alias_autoregistrar.h +// start catch_test_registry.h + +// start catch_interfaces_testcase.h + +#include +#include + +namespace Catch { + + class TestSpec; + + struct ITestInvoker { + virtual void invoke () const = 0; + virtual ~ITestInvoker(); + }; + + using ITestCasePtr = std::shared_ptr; + + 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 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 + +namespace Catch { + + class StringData; + + /// 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. c_str() must return a null terminated + /// string, however, and so the StringRef will internally take ownership + /// (taking a copy), if necessary. In theory this ownership is not externally + /// visible - but it does mean (substring) StringRefs should not be shared between + /// threads. + class StringRef { + public: + using size_type = std::size_t; + + private: + friend struct StringRefTestAccess; + + char const* m_start; + size_type m_size; + + char* m_data = nullptr; + + void takeOwnership(); + + static constexpr char const* const s_empty = ""; + + public: // construction/ assignment + StringRef() noexcept + : StringRef( s_empty, 0 ) + {} + + StringRef( StringRef const& other ) noexcept + : m_start( other.m_start ), + m_size( other.m_size ) + {} + + StringRef( StringRef&& other ) noexcept + : m_start( other.m_start ), + m_size( other.m_size ), + m_data( other.m_data ) + { + other.m_data = nullptr; + } + + StringRef( char const* rawChars ) noexcept; + + 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() ) + {} + + ~StringRef() noexcept { + delete[] m_data; + } + + auto operator = ( StringRef const &other ) noexcept -> StringRef& { + delete[] m_data; + m_data = nullptr; + m_start = other.m_start; + m_size = other.m_size; + return *this; + } + + operator std::string() const; + + void swap( StringRef& other ) noexcept; + + public: // operators + auto operator == ( StringRef const& other ) const noexcept -> bool; + auto operator != ( StringRef const& other ) const noexcept -> bool; + + auto operator[] ( size_type index ) const noexcept -> char; + + public: // named queries + auto empty() const noexcept -> bool { + return m_size == 0; + } + auto size() const noexcept -> size_type { + return m_size; + } + + auto numberOfCharacters() const noexcept -> size_type; + auto c_str() const -> char const*; + + public: // substrings and searches + auto substr( size_type start, size_type size ) const noexcept -> StringRef; + + // Returns the current start pointer. + // Note that the pointer can change when if the StringRef is a substring + auto currentData() const noexcept -> char const*; + + private: // ownership queries - may not be consistent between calls + auto isOwned() const noexcept -> bool; + auto isSubstring() const noexcept -> bool; + }; + + auto operator + ( StringRef const& lhs, StringRef const& rhs ) -> std::string; + auto operator + ( StringRef const& lhs, char const* rhs ) -> std::string; + auto operator + ( char const* lhs, StringRef const& rhs ) -> std::string; + + auto operator += ( std::string& lhs, StringRef const& sr ) -> std::string&; + auto operator << ( std::ostream& os, StringRef const& sr ) -> std::ostream&; + + inline auto operator "" _sr( char const* rawChars, std::size_t size ) noexcept -> StringRef { + return StringRef( rawChars, size ); + } + +} // namespace Catch + +// end catch_stringref.h +namespace Catch { + +template +class TestInvokerAsMethod : public ITestInvoker { + void (C::*m_testAsMethod)(); +public: + TestInvokerAsMethod( void (C::*testAsMethod)() ) noexcept : m_testAsMethod( testAsMethod ) {} + + void invoke() const override { + C obj; + (obj.*m_testAsMethod)(); + } +}; + +auto makeTestInvoker( void(*testAsFunction)() ) noexcept -> ITestInvoker*; + +template +auto makeTestInvoker( void (C::*testAsMethod)() ) noexcept -> ITestInvoker* { + return new(std::nothrow) TestInvokerAsMethod( testAsMethod ); +} + +struct NameAndTags { + NameAndTags( StringRef const& name_ = StringRef(), StringRef const& tags_ = StringRef() ) noexcept; + StringRef name; + StringRef tags; +}; + +struct AutoReg : NonCopyable { + AutoReg( ITestInvoker* invoker, SourceLineInfo const& lineInfo, StringRef const& classOrMethod, NameAndTags const& nameAndTags ) noexcept; + ~AutoReg(); +}; + +} // end namespace Catch + +#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 + +#if defined(CATCH_CONFIG_DISABLE) + #define INTERNAL_CATCH_TESTCASE_NO_REGISTRATION( TestName, ... ) \ + static void TestName() + #define INTERNAL_CATCH_TESTCASE_METHOD_NO_REGISTRATION( TestName, ClassName, ... ) \ + namespace{ \ + struct TestName : INTERNAL_CATCH_EXPAND1(INTERNAL_CATCH_DEF ClassName) { \ + void test(); \ + }; \ + } \ + void TestName::test() + +#endif + + /////////////////////////////////////////////////////////////////////////////// + #define INTERNAL_CATCH_TESTCASE2( TestName, ... ) \ + static void TestName(); \ + CATCH_INTERNAL_SUPPRESS_GLOBALS_WARNINGS \ + namespace{ Catch::AutoReg INTERNAL_CATCH_UNIQUE_NAME( autoRegistrar )( Catch::makeTestInvoker( &TestName ), CATCH_INTERNAL_LINEINFO, Catch::StringRef(), Catch::NameAndTags{ __VA_ARGS__ } ); } /* NOLINT */ \ + CATCH_INTERNAL_UNSUPPRESS_GLOBALS_WARNINGS \ + static void TestName() + #define INTERNAL_CATCH_TESTCASE( ... ) \ + INTERNAL_CATCH_TESTCASE2( INTERNAL_CATCH_UNIQUE_NAME( ____C_A_T_C_H____T_E_S_T____ ), __VA_ARGS__ ) + + /////////////////////////////////////////////////////////////////////////////// + #define INTERNAL_CATCH_METHOD_AS_TEST_CASE( QualifiedMethod, ... ) \ + CATCH_INTERNAL_SUPPRESS_GLOBALS_WARNINGS \ + namespace{ Catch::AutoReg INTERNAL_CATCH_UNIQUE_NAME( autoRegistrar )( Catch::makeTestInvoker( &QualifiedMethod ), CATCH_INTERNAL_LINEINFO, "&" #QualifiedMethod, Catch::NameAndTags{ __VA_ARGS__ } ); } /* NOLINT */ \ + CATCH_INTERNAL_UNSUPPRESS_GLOBALS_WARNINGS + + /////////////////////////////////////////////////////////////////////////////// + #define INTERNAL_CATCH_TEST_CASE_METHOD2( TestName, ClassName, ... )\ + CATCH_INTERNAL_SUPPRESS_GLOBALS_WARNINGS \ + namespace{ \ + struct TestName : INTERNAL_CATCH_EXPAND1(INTERNAL_CATCH_DEF ClassName) { \ + void test(); \ + }; \ + Catch::AutoReg INTERNAL_CATCH_UNIQUE_NAME( autoRegistrar ) ( Catch::makeTestInvoker( &TestName::test ), CATCH_INTERNAL_LINEINFO, #ClassName, Catch::NameAndTags{ __VA_ARGS__ } ); /* NOLINT */ \ + } \ + CATCH_INTERNAL_UNSUPPRESS_GLOBALS_WARNINGS \ + void TestName::test() + #define INTERNAL_CATCH_TEST_CASE_METHOD( ClassName, ... ) \ + INTERNAL_CATCH_TEST_CASE_METHOD2( INTERNAL_CATCH_UNIQUE_NAME( ____C_A_T_C_H____T_E_S_T____ ), ClassName, __VA_ARGS__ ) + + /////////////////////////////////////////////////////////////////////////////// + #define INTERNAL_CATCH_REGISTER_TESTCASE( Function, ... ) \ + CATCH_INTERNAL_SUPPRESS_GLOBALS_WARNINGS \ + Catch::AutoReg INTERNAL_CATCH_UNIQUE_NAME( autoRegistrar )( Catch::makeTestInvoker( Function ), CATCH_INTERNAL_LINEINFO, Catch::StringRef(), Catch::NameAndTags{ __VA_ARGS__ } ); /* NOLINT */ \ + CATCH_INTERNAL_UNSUPPRESS_GLOBALS_WARNINGS + +// end catch_test_registry.h +// start catch_capture.hpp + +// start catch_assertionhandler.h + +// start catch_assertioninfo.h + +// start catch_result_type.h + +namespace Catch { + + // ResultWas::OfType enum + struct ResultWas { enum OfType { + Unknown = -1, + Ok = 0, + Info = 1, + Warning = 2, + + FailureBit = 0x10, + + ExpressionFailed = FailureBit | 1, + ExplicitFailure = FailureBit | 2, + + Exception = 0x100 | FailureBit, + + ThrewException = Exception | 1, + DidntThrowException = Exception | 2, + + FatalErrorCondition = 0x200 | FailureBit + + }; }; + + bool isOk( ResultWas::OfType resultType ); + bool isJustInfo( int flags ); + + // ResultDisposition::Flags enum + struct ResultDisposition { enum Flags { + Normal = 0x01, + + ContinueOnFailure = 0x02, // Failures fail test, but execution continues + FalseTest = 0x04, // Prefix expression with ! + SuppressFail = 0x08 // Failures are reported but do not fail the test + }; }; + + ResultDisposition::Flags operator | ( ResultDisposition::Flags lhs, ResultDisposition::Flags rhs ); + + bool shouldContinueOnFailure( int flags ); + inline bool isFalseTest( int flags ) { return ( flags & ResultDisposition::FalseTest ) != 0; } + bool shouldSuppressFailure( int flags ); + +} // end namespace Catch + +// end catch_result_type.h +namespace Catch { + + struct AssertionInfo + { + StringRef macroName; + SourceLineInfo lineInfo; + StringRef capturedExpression; + ResultDisposition::Flags resultDisposition; + + // We want to delete this constructor but a compiler bug in 4.8 means + // the struct is then treated as non-aggregate + //AssertionInfo() = delete; + }; + +} // end namespace Catch + +// end catch_assertioninfo.h +// start catch_decomposer.h + +// start catch_tostring.h + +#include +#include +#include +#include +// start catch_stream.h + +#include +#include +#include + +namespace Catch { + + std::ostream& cout(); + std::ostream& cerr(); + std::ostream& clog(); + + class StringRef; + + struct IStream { + virtual ~IStream(); + virtual std::ostream& stream() const = 0; + }; + + auto makeStream( StringRef const &filename ) -> IStream const*; + + class ReusableStringStream { + std::size_t m_index; + std::ostream* m_oss; + public: + ReusableStringStream(); + ~ReusableStringStream(); + + auto str() const -> std::string; + + template + auto operator << ( T const& value ) -> ReusableStringStream& { + *m_oss << value; + return *this; + } + auto get() -> std::ostream& { return *m_oss; } + + static void cleanup(); + }; +} + +// end catch_stream.h + +#ifdef __OBJC__ +// start catch_objc_arc.hpp + +#import + +#ifdef __has_feature +#define CATCH_ARC_ENABLED __has_feature(objc_arc) +#else +#define CATCH_ARC_ENABLED 0 +#endif + +void arcSafeRelease( NSObject* obj ); +id performOptionalSelector( id obj, SEL sel ); + +#if !CATCH_ARC_ENABLED +inline void arcSafeRelease( NSObject* obj ) { + [obj release]; +} +inline id performOptionalSelector( id obj, SEL sel ) { + if( [obj respondsToSelector: sel] ) + return [obj performSelector: sel]; + return nil; +} +#define CATCH_UNSAFE_UNRETAINED +#define CATCH_ARC_STRONG +#else +inline void arcSafeRelease( NSObject* ){} +inline id performOptionalSelector( id obj, SEL sel ) { +#ifdef __clang__ +#pragma clang diagnostic push +#pragma clang diagnostic ignored "-Warc-performSelector-leaks" +#endif + if( [obj respondsToSelector: sel] ) + return [obj performSelector: sel]; +#ifdef __clang__ +#pragma clang diagnostic pop +#endif + return nil; +} +#define CATCH_UNSAFE_UNRETAINED __unsafe_unretained +#define CATCH_ARC_STRONG __strong +#endif + +// end catch_objc_arc.hpp +#endif + +#ifdef _MSC_VER +#pragma warning(push) +#pragma warning(disable:4180) // We attempt to stream a function (address) by const&, which MSVC complains about but is harmless +#endif + +// 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 { + // Bring in operator<< from global namespace into Catch namespace + using ::operator<<; + + namespace Detail { + + extern const std::string unprintableString; + + std::string rawMemoryToString( const void *object, std::size_t size ); + + template + std::string rawMemoryToString( const T& object ) { + return rawMemoryToString( &object, sizeof(object) ); + } + + template + class IsStreamInsertable { + template + static auto test(int) + -> decltype(std::declval() << std::declval(), std::true_type()); + + template + static auto test(...)->std::false_type; + + public: + static const bool value = decltype(test(0))::value; + }; + + template + std::string convertUnknownEnumToString( E e ); + + template + typename std::enable_if< + !std::is_enum::value && !std::is_base_of::value, + std::string>::type convertUnstreamable( T const& ) { + return Detail::unprintableString; + } + template + typename std::enable_if< + !std::is_enum::value && std::is_base_of::value, + std::string>::type convertUnstreamable(T const& ex) { + return ex.what(); + } + + template + typename std::enable_if< + std::is_enum::value + , std::string>::type convertUnstreamable( T const& value ) { + return convertUnknownEnumToString( value ); + } + +#if defined(_MANAGED) + //! Convert a CLR string to a utf8 std::string + template + std::string clrReferenceToString( T^ ref ) { + if (ref == nullptr) + return std::string("null"); + auto bytes = System::Text::Encoding::UTF8->GetBytes(ref->ToString()); + cli::pin_ptr p = &bytes[0]; + return std::string(reinterpret_cast(p), bytes->Length); + } +#endif + + } // namespace Detail + + // If we decide for C++14, change these to enable_if_ts + template + struct StringMaker { + template + static + typename std::enable_if<::Catch::Detail::IsStreamInsertable::value, std::string>::type + convert(const Fake& value) { + ReusableStringStream rss; + // NB: call using the function-like syntax to avoid ambiguity with + // user-defined templated operator<< under clang. + rss.operator<<(value); + return rss.str(); + } + + template + static + typename std::enable_if::value, std::string>::type + convert( const Fake& value ) { +#if !defined(CATCH_CONFIG_FALLBACK_STRINGIFIER) + return Detail::convertUnstreamable(value); +#else + return CATCH_CONFIG_FALLBACK_STRINGIFIER(value); +#endif + } + }; + + namespace Detail { + + // This function dispatches all stringification requests inside of Catch. + // Should be preferably called fully qualified, like ::Catch::Detail::stringify + template + std::string stringify(const T& e) { + return ::Catch::StringMaker::type>::type>::convert(e); + } + + template + std::string convertUnknownEnumToString( E e ) { + return ::Catch::Detail::stringify(static_cast::type>(e)); + } + +#if defined(_MANAGED) + template + std::string stringify( T^ e ) { + return ::Catch::StringMaker::convert(e); + } +#endif + + } // namespace Detail + + // Some predefined specializations + + template<> + struct StringMaker { + static std::string convert(const std::string& str); + }; +#ifdef CATCH_CONFIG_WCHAR + template<> + struct StringMaker { + static std::string convert(const std::wstring& wstr); + }; +#endif + + template<> + struct StringMaker { + static std::string convert(char const * str); + }; + template<> + struct StringMaker { + static std::string convert(char * str); + }; + +#ifdef CATCH_CONFIG_WCHAR + template<> + struct StringMaker { + static std::string convert(wchar_t const * str); + }; + template<> + struct StringMaker { + static std::string convert(wchar_t * str); + }; +#endif + + // TBD: Should we use `strnlen` to ensure that we don't go out of the buffer, + // while keeping string semantics? + template + struct StringMaker { + static std::string convert(char const* str) { + return ::Catch::Detail::stringify(std::string{ str }); + } + }; + template + struct StringMaker { + static std::string convert(signed char const* str) { + return ::Catch::Detail::stringify(std::string{ reinterpret_cast(str) }); + } + }; + template + struct StringMaker { + static std::string convert(unsigned char const* str) { + return ::Catch::Detail::stringify(std::string{ reinterpret_cast(str) }); + } + }; + + template<> + struct StringMaker { + static std::string convert(int value); + }; + template<> + struct StringMaker { + static std::string convert(long value); + }; + template<> + struct StringMaker { + static std::string convert(long long value); + }; + template<> + struct StringMaker { + static std::string convert(unsigned int value); + }; + template<> + struct StringMaker { + static std::string convert(unsigned long value); + }; + template<> + struct StringMaker { + static std::string convert(unsigned long long value); + }; + + template<> + struct StringMaker { + static std::string convert(bool b); + }; + + template<> + struct StringMaker { + static std::string convert(char c); + }; + template<> + struct StringMaker { + static std::string convert(signed char c); + }; + template<> + struct StringMaker { + static std::string convert(unsigned char c); + }; + + template<> + struct StringMaker { + static std::string convert(std::nullptr_t); + }; + + template<> + struct StringMaker { + static std::string convert(float value); + }; + template<> + struct StringMaker { + static std::string convert(double value); + }; + + template + struct StringMaker { + template + static std::string convert(U* p) { + if (p) { + return ::Catch::Detail::rawMemoryToString(p); + } else { + return "nullptr"; + } + } + }; + + template + struct StringMaker { + static std::string convert(R C::* p) { + if (p) { + return ::Catch::Detail::rawMemoryToString(p); + } else { + return "nullptr"; + } + } + }; + +#if defined(_MANAGED) + template + struct StringMaker { + static std::string convert( T^ ref ) { + return ::Catch::Detail::clrReferenceToString(ref); + } + }; +#endif + + namespace Detail { + template + std::string rangeToString(InputIterator first, InputIterator last) { + ReusableStringStream rss; + rss << "{ "; + if (first != last) { + rss << ::Catch::Detail::stringify(*first); + for (++first; first != last; ++first) + rss << ", " << ::Catch::Detail::stringify(*first); + } + rss << " }"; + return rss.str(); + } + } + +#ifdef __OBJC__ + template<> + struct StringMaker { + static std::string convert(NSString * nsstring) { + if (!nsstring) + return "nil"; + return std::string("@") + [nsstring UTF8String]; + } + }; + template<> + struct StringMaker { + static std::string convert(NSObject* nsObject) { + return ::Catch::Detail::stringify([nsObject description]); + } + + }; + namespace Detail { + inline std::string stringify( NSString* nsstring ) { + return StringMaker::convert( nsstring ); + } + + } // namespace Detail +#endif // __OBJC__ + +} // namespace Catch + +////////////////////////////////////////////////////// +// Separate std-lib types stringification, so it can be selectively enabled +// This means that we do not bring in + +#if defined(CATCH_CONFIG_ENABLE_ALL_STRINGMAKERS) +# define CATCH_CONFIG_ENABLE_PAIR_STRINGMAKER +# define CATCH_CONFIG_ENABLE_TUPLE_STRINGMAKER +# define CATCH_CONFIG_ENABLE_CHRONO_STRINGMAKER +#endif + +// Separate std::pair specialization +#if defined(CATCH_CONFIG_ENABLE_PAIR_STRINGMAKER) +#include +namespace Catch { + template + struct StringMaker > { + static std::string convert(const std::pair& pair) { + ReusableStringStream rss; + rss << "{ " + << ::Catch::Detail::stringify(pair.first) + << ", " + << ::Catch::Detail::stringify(pair.second) + << " }"; + return rss.str(); + } + }; +} +#endif // CATCH_CONFIG_ENABLE_PAIR_STRINGMAKER + +// Separate std::tuple specialization +#if defined(CATCH_CONFIG_ENABLE_TUPLE_STRINGMAKER) +#include +namespace Catch { + namespace Detail { + template< + typename Tuple, + std::size_t N = 0, + bool = (N < std::tuple_size::value) + > + struct TupleElementPrinter { + static void print(const Tuple& tuple, std::ostream& os) { + os << (N ? ", " : " ") + << ::Catch::Detail::stringify(std::get(tuple)); + TupleElementPrinter::print(tuple, os); + } + }; + + template< + typename Tuple, + std::size_t N + > + struct TupleElementPrinter { + static void print(const Tuple&, std::ostream&) {} + }; + + } + + template + struct StringMaker> { + static std::string convert(const std::tuple& tuple) { + ReusableStringStream rss; + rss << '{'; + Detail::TupleElementPrinter>::print(tuple, rss.get()); + rss << " }"; + return rss.str(); + } + }; +} +#endif // CATCH_CONFIG_ENABLE_TUPLE_STRINGMAKER + +namespace Catch { + struct not_this_one {}; // Tag type for detecting which begin/ end are being selected + + // Import begin/ end from std here so they are considered alongside the fallback (...) overloads in this namespace + using std::begin; + using std::end; + + not_this_one begin( ... ); + not_this_one end( ... ); + + template + struct is_range { + static const bool value = + !std::is_same())), not_this_one>::value && + !std::is_same())), not_this_one>::value; + }; + +#if defined(_MANAGED) // Managed types are never ranges + template + struct is_range { + static const bool value = false; + }; +#endif + + template + std::string rangeToString( Range const& range ) { + return ::Catch::Detail::rangeToString( begin( range ), end( range ) ); + } + + // Handle vector specially + template + std::string rangeToString( std::vector const& v ) { + ReusableStringStream rss; + rss << "{ "; + bool first = true; + for( bool b : v ) { + if( first ) + first = false; + else + rss << ", "; + rss << ::Catch::Detail::stringify( b ); + } + rss << " }"; + return rss.str(); + } + + template + struct StringMaker::value && !::Catch::Detail::IsStreamInsertable::value>::type> { + static std::string convert( R const& range ) { + return rangeToString( range ); + } + }; + + template + struct StringMaker { + static std::string convert(T const(&arr)[SZ]) { + return rangeToString(arr); + } + }; + +} // namespace Catch + +// Separate std::chrono::duration specialization +#if defined(CATCH_CONFIG_ENABLE_CHRONO_STRINGMAKER) +#include +#include +#include + +namespace Catch { + +template +struct ratio_string { + static std::string symbol(); +}; + +template +std::string ratio_string::symbol() { + Catch::ReusableStringStream rss; + rss << '[' << Ratio::num << '/' + << Ratio::den << ']'; + return rss.str(); +} +template <> +struct ratio_string { + static std::string symbol(); +}; +template <> +struct ratio_string { + static std::string symbol(); +}; +template <> +struct ratio_string { + static std::string symbol(); +}; +template <> +struct ratio_string { + static std::string symbol(); +}; +template <> +struct ratio_string { + static std::string symbol(); +}; +template <> +struct ratio_string { + static std::string symbol(); +}; + + //////////// + // std::chrono::duration specializations + template + struct StringMaker> { + static std::string convert(std::chrono::duration const& duration) { + ReusableStringStream rss; + rss << duration.count() << ' ' << ratio_string::symbol() << 's'; + return rss.str(); + } + }; + template + struct StringMaker>> { + static std::string convert(std::chrono::duration> const& duration) { + ReusableStringStream rss; + rss << duration.count() << " s"; + return rss.str(); + } + }; + template + struct StringMaker>> { + static std::string convert(std::chrono::duration> const& duration) { + ReusableStringStream rss; + rss << duration.count() << " m"; + return rss.str(); + } + }; + template + struct StringMaker>> { + static std::string convert(std::chrono::duration> const& duration) { + ReusableStringStream rss; + rss << duration.count() << " h"; + return rss.str(); + } + }; + + //////////// + // std::chrono::time_point specialization + // Generic time_point cannot be specialized, only std::chrono::time_point + template + struct StringMaker> { + static std::string convert(std::chrono::time_point const& time_point) { + return ::Catch::Detail::stringify(time_point.time_since_epoch()) + " since epoch"; + } + }; + // std::chrono::time_point specialization + template + struct StringMaker> { + static std::string convert(std::chrono::time_point const& time_point) { + auto converted = std::chrono::system_clock::to_time_t(time_point); + +#ifdef _MSC_VER + std::tm timeInfo = {}; + gmtime_s(&timeInfo, &converted); +#else + std::tm* timeInfo = std::gmtime(&converted); +#endif + + auto const timeStampSize = sizeof("2017-01-16T17:06:45Z"); + char timeStamp[timeStampSize]; + const char * const fmt = "%Y-%m-%dT%H:%M:%SZ"; + +#ifdef _MSC_VER + std::strftime(timeStamp, timeStampSize, fmt, &timeInfo); +#else + std::strftime(timeStamp, timeStampSize, fmt, timeInfo); +#endif + return std::string(timeStamp); + } + }; +} +#endif // CATCH_CONFIG_ENABLE_CHRONO_STRINGMAKER + +#ifdef _MSC_VER +#pragma warning(pop) +#endif + +// end catch_tostring.h +#include + +#ifdef _MSC_VER +#pragma warning(push) +#pragma warning(disable:4389) // '==' : signed/unsigned mismatch +#pragma warning(disable:4018) // more "signed/unsigned mismatch" +#pragma warning(disable:4312) // Converting int to T* using reinterpret_cast (issue on x64 platform) +#pragma warning(disable:4180) // qualifier applied to function type has no meaning +#endif + +namespace Catch { + + struct ITransientExpression { + auto isBinaryExpression() const -> bool { return m_isBinaryExpression; } + auto getResult() const -> bool { return m_result; } + virtual void streamReconstructedExpression( std::ostream &os ) const = 0; + + ITransientExpression( bool isBinaryExpression, bool result ) + : m_isBinaryExpression( isBinaryExpression ), + m_result( result ) + {} + + // We don't actually need a virtual destructor, but many static analysers + // complain if it's not here :-( + virtual ~ITransientExpression(); + + bool m_isBinaryExpression; + bool m_result; + + }; + + void formatReconstructedExpression( std::ostream &os, std::string const& lhs, StringRef op, std::string const& rhs ); + + template + class BinaryExpr : public ITransientExpression { + LhsT m_lhs; + StringRef m_op; + RhsT m_rhs; + + void streamReconstructedExpression( std::ostream &os ) const override { + formatReconstructedExpression + ( os, Catch::Detail::stringify( m_lhs ), m_op, Catch::Detail::stringify( m_rhs ) ); + } + + public: + BinaryExpr( bool comparisonResult, LhsT lhs, StringRef op, RhsT rhs ) + : ITransientExpression{ true, comparisonResult }, + m_lhs( lhs ), + m_op( op ), + m_rhs( rhs ) + {} + }; + + template + class UnaryExpr : public ITransientExpression { + LhsT m_lhs; + + void streamReconstructedExpression( std::ostream &os ) const override { + os << Catch::Detail::stringify( m_lhs ); + } + + public: + explicit UnaryExpr( LhsT lhs ) + : ITransientExpression{ false, lhs ? true : false }, + m_lhs( lhs ) + {} + }; + + // Specialised comparison functions to handle equality comparisons between ints and pointers (NULL deduces as an int) + template + auto compareEqual( LhsT const& lhs, RhsT const& rhs ) -> bool { return static_cast(lhs == rhs); } + template + auto compareEqual( T* const& lhs, int rhs ) -> bool { return lhs == reinterpret_cast( rhs ); } + template + auto compareEqual( T* const& lhs, long rhs ) -> bool { return lhs == reinterpret_cast( rhs ); } + template + auto compareEqual( int lhs, T* const& rhs ) -> bool { return reinterpret_cast( lhs ) == rhs; } + template + auto compareEqual( long lhs, T* const& rhs ) -> bool { return reinterpret_cast( lhs ) == rhs; } + + template + auto compareNotEqual( LhsT const& lhs, RhsT&& rhs ) -> bool { return static_cast(lhs != rhs); } + template + auto compareNotEqual( T* const& lhs, int rhs ) -> bool { return lhs != reinterpret_cast( rhs ); } + template + auto compareNotEqual( T* const& lhs, long rhs ) -> bool { return lhs != reinterpret_cast( rhs ); } + template + auto compareNotEqual( int lhs, T* const& rhs ) -> bool { return reinterpret_cast( lhs ) != rhs; } + template + auto compareNotEqual( long lhs, T* const& rhs ) -> bool { return reinterpret_cast( lhs ) != rhs; } + + template + class ExprLhs { + LhsT m_lhs; + public: + explicit ExprLhs( LhsT lhs ) : m_lhs( lhs ) {} + + template + auto operator == ( RhsT const& rhs ) -> BinaryExpr const { + return { compareEqual( m_lhs, rhs ), m_lhs, "==", rhs }; + } + auto operator == ( bool rhs ) -> BinaryExpr const { + return { m_lhs == rhs, m_lhs, "==", rhs }; + } + + template + auto operator != ( RhsT const& rhs ) -> BinaryExpr const { + return { compareNotEqual( m_lhs, rhs ), m_lhs, "!=", rhs }; + } + auto operator != ( bool rhs ) -> BinaryExpr const { + return { m_lhs != rhs, m_lhs, "!=", rhs }; + } + + template + auto operator > ( RhsT const& rhs ) -> BinaryExpr const { + return { static_cast(m_lhs > rhs), m_lhs, ">", rhs }; + } + template + auto operator < ( RhsT const& rhs ) -> BinaryExpr const { + return { static_cast(m_lhs < rhs), m_lhs, "<", rhs }; + } + template + auto operator >= ( RhsT const& rhs ) -> BinaryExpr const { + return { static_cast(m_lhs >= rhs), m_lhs, ">=", rhs }; + } + template + auto operator <= ( RhsT const& rhs ) -> BinaryExpr const { + return { static_cast(m_lhs <= rhs), m_lhs, "<=", rhs }; + } + + auto makeUnaryExpr() const -> UnaryExpr { + return UnaryExpr{ m_lhs }; + } + }; + + void handleExpression( ITransientExpression const& expr ); + + template + void handleExpression( ExprLhs const& expr ) { + handleExpression( expr.makeUnaryExpr() ); + } + + struct Decomposer { + template + auto operator <= ( T const& lhs ) -> ExprLhs { + return ExprLhs{ lhs }; + } + + auto operator <=( bool value ) -> ExprLhs { + return ExprLhs{ value }; + } + }; + +} // end namespace Catch + +#ifdef _MSC_VER +#pragma warning(pop) +#endif + +// end catch_decomposer.h +// start catch_interfaces_capture.h + +#include + +namespace Catch { + + class AssertionResult; + struct AssertionInfo; + struct SectionInfo; + struct SectionEndInfo; + struct MessageInfo; + struct Counts; + struct BenchmarkInfo; + struct BenchmarkStats; + struct AssertionReaction; + + struct ITransientExpression; + + struct IResultCapture { + + virtual ~IResultCapture(); + + virtual bool sectionStarted( SectionInfo const& sectionInfo, + Counts& assertions ) = 0; + virtual void sectionEnded( SectionEndInfo const& endInfo ) = 0; + virtual void sectionEndedEarly( SectionEndInfo const& endInfo ) = 0; + + virtual void benchmarkStarting( BenchmarkInfo const& info ) = 0; + virtual void benchmarkEnded( BenchmarkStats const& stats ) = 0; + + virtual void pushScopedMessage( MessageInfo const& message ) = 0; + virtual void popScopedMessage( MessageInfo const& message ) = 0; + + virtual void handleFatalErrorCondition( StringRef message ) = 0; + + virtual void handleExpr + ( AssertionInfo const& info, + ITransientExpression const& expr, + AssertionReaction& reaction ) = 0; + virtual void handleMessage + ( AssertionInfo const& info, + ResultWas::OfType resultType, + StringRef const& message, + AssertionReaction& reaction ) = 0; + virtual void handleUnexpectedExceptionNotThrown + ( AssertionInfo const& info, + AssertionReaction& reaction ) = 0; + virtual void handleUnexpectedInflightException + ( AssertionInfo const& info, + std::string const& message, + AssertionReaction& reaction ) = 0; + virtual void handleIncomplete + ( AssertionInfo const& info ) = 0; + virtual void handleNonExpr + ( AssertionInfo const &info, + ResultWas::OfType resultType, + AssertionReaction &reaction ) = 0; + + virtual bool lastAssertionPassed() = 0; + virtual void assertionPassed() = 0; + + // Deprecated, do not use: + virtual std::string getCurrentTestName() const = 0; + virtual const AssertionResult* getLastResult() const = 0; + virtual void exceptionEarlyReported() = 0; + }; + + IResultCapture& getResultCapture(); +} + +// end catch_interfaces_capture.h +namespace Catch { + + struct TestFailureException{}; + struct AssertionResultData; + struct IResultCapture; + class RunContext; + + class LazyExpression { + friend class AssertionHandler; + friend struct AssertionStats; + friend class RunContext; + + ITransientExpression const* m_transientExpression = nullptr; + bool m_isNegated; + public: + LazyExpression( bool isNegated ); + LazyExpression( LazyExpression const& other ); + LazyExpression& operator = ( LazyExpression const& ) = delete; + + explicit operator bool() const; + + friend auto operator << ( std::ostream& os, LazyExpression const& lazyExpr ) -> std::ostream&; + }; + + struct AssertionReaction { + bool shouldDebugBreak = false; + bool shouldThrow = false; + }; + + class AssertionHandler { + AssertionInfo m_assertionInfo; + AssertionReaction m_reaction; + bool m_completed = false; + IResultCapture& m_resultCapture; + + public: + AssertionHandler + ( StringRef macroName, + SourceLineInfo const& lineInfo, + StringRef capturedExpression, + ResultDisposition::Flags resultDisposition ); + ~AssertionHandler() { + if ( !m_completed ) { + m_resultCapture.handleIncomplete( m_assertionInfo ); + } + } + + template + void handleExpr( ExprLhs const& expr ) { + handleExpr( expr.makeUnaryExpr() ); + } + void handleExpr( ITransientExpression const& expr ); + + void handleMessage(ResultWas::OfType resultType, StringRef const& message); + + void handleExceptionThrownAsExpected(); + void handleUnexpectedExceptionNotThrown(); + void handleExceptionNotThrownAsExpected(); + void handleThrowingCallSkipped(); + void handleUnexpectedInflightException(); + + void complete(); + void setCompleted(); + + // query + auto allowThrows() const -> bool; + }; + + void handleExceptionMatchExpr( AssertionHandler& handler, std::string const& str, StringRef matcherString ); + +} // namespace Catch + +// end catch_assertionhandler.h +// start catch_message.h + +#include + +namespace Catch { + + struct MessageInfo { + MessageInfo( std::string const& _macroName, + SourceLineInfo const& _lineInfo, + ResultWas::OfType _type ); + + std::string macroName; + std::string message; + SourceLineInfo lineInfo; + ResultWas::OfType type; + unsigned int sequence; + + bool operator == ( MessageInfo const& other ) const; + bool operator < ( MessageInfo const& other ) const; + private: + static unsigned int globalCount; + }; + + struct MessageStream { + + template + MessageStream& operator << ( T const& value ) { + m_stream << value; + return *this; + } + + ReusableStringStream m_stream; + }; + + struct MessageBuilder : MessageStream { + MessageBuilder( std::string const& macroName, + SourceLineInfo const& lineInfo, + ResultWas::OfType type ); + + template + MessageBuilder& operator << ( T const& value ) { + m_stream << value; + return *this; + } + + MessageInfo m_info; + }; + + class ScopedMessage { + public: + explicit ScopedMessage( MessageBuilder const& builder ); + ~ScopedMessage(); + + MessageInfo m_info; + }; + +} // end namespace Catch + +// end catch_message.h +#if !defined(CATCH_CONFIG_DISABLE) + +#if !defined(CATCH_CONFIG_DISABLE_STRINGIFICATION) + #define CATCH_INTERNAL_STRINGIFY(...) #__VA_ARGS__ +#else + #define CATCH_INTERNAL_STRINGIFY(...) "Disabled by CATCH_CONFIG_DISABLE_STRINGIFICATION" +#endif + +#if defined(CATCH_CONFIG_FAST_COMPILE) + +/////////////////////////////////////////////////////////////////////////////// +// Another way to speed-up compilation is to omit local try-catch for REQUIRE* +// macros. +#define INTERNAL_CATCH_TRY +#define INTERNAL_CATCH_CATCH( capturer ) + +#else // CATCH_CONFIG_FAST_COMPILE + +#define INTERNAL_CATCH_TRY try +#define INTERNAL_CATCH_CATCH( handler ) catch(...) { handler.handleUnexpectedInflightException(); } + +#endif + +#define INTERNAL_CATCH_REACT( handler ) handler.complete(); + +/////////////////////////////////////////////////////////////////////////////// +#define INTERNAL_CATCH_TEST( macroName, resultDisposition, ... ) \ + do { \ + Catch::AssertionHandler catchAssertionHandler( macroName, CATCH_INTERNAL_LINEINFO, CATCH_INTERNAL_STRINGIFY(__VA_ARGS__), resultDisposition ); \ + INTERNAL_CATCH_TRY { \ + CATCH_INTERNAL_SUPPRESS_PARENTHESES_WARNINGS \ + catchAssertionHandler.handleExpr( Catch::Decomposer() <= __VA_ARGS__ ); \ + CATCH_INTERNAL_UNSUPPRESS_PARENTHESES_WARNINGS \ + } INTERNAL_CATCH_CATCH( catchAssertionHandler ) \ + INTERNAL_CATCH_REACT( catchAssertionHandler ) \ + } while( (void)0, false && static_cast( !!(__VA_ARGS__) ) ) // the expression here is never evaluated at runtime but it forces the compiler to give it a look + // The double negation silences MSVC's C4800 warning, the static_cast forces short-circuit evaluation if the type has overloaded &&. + +/////////////////////////////////////////////////////////////////////////////// +#define INTERNAL_CATCH_IF( macroName, resultDisposition, ... ) \ + INTERNAL_CATCH_TEST( macroName, resultDisposition, __VA_ARGS__ ); \ + if( Catch::getResultCapture().lastAssertionPassed() ) + +/////////////////////////////////////////////////////////////////////////////// +#define INTERNAL_CATCH_ELSE( macroName, resultDisposition, ... ) \ + INTERNAL_CATCH_TEST( macroName, resultDisposition, __VA_ARGS__ ); \ + if( !Catch::getResultCapture().lastAssertionPassed() ) + +/////////////////////////////////////////////////////////////////////////////// +#define INTERNAL_CATCH_NO_THROW( macroName, resultDisposition, ... ) \ + do { \ + Catch::AssertionHandler catchAssertionHandler( macroName, CATCH_INTERNAL_LINEINFO, CATCH_INTERNAL_STRINGIFY(__VA_ARGS__), resultDisposition ); \ + try { \ + static_cast(__VA_ARGS__); \ + catchAssertionHandler.handleExceptionNotThrownAsExpected(); \ + } \ + catch( ... ) { \ + catchAssertionHandler.handleUnexpectedInflightException(); \ + } \ + INTERNAL_CATCH_REACT( catchAssertionHandler ) \ + } while( false ) + +/////////////////////////////////////////////////////////////////////////////// +#define INTERNAL_CATCH_THROWS( macroName, resultDisposition, ... ) \ + do { \ + Catch::AssertionHandler catchAssertionHandler( macroName, CATCH_INTERNAL_LINEINFO, CATCH_INTERNAL_STRINGIFY(__VA_ARGS__), resultDisposition); \ + if( catchAssertionHandler.allowThrows() ) \ + try { \ + static_cast(__VA_ARGS__); \ + catchAssertionHandler.handleUnexpectedExceptionNotThrown(); \ + } \ + catch( ... ) { \ + catchAssertionHandler.handleExceptionThrownAsExpected(); \ + } \ + else \ + catchAssertionHandler.handleThrowingCallSkipped(); \ + INTERNAL_CATCH_REACT( catchAssertionHandler ) \ + } while( false ) + +/////////////////////////////////////////////////////////////////////////////// +#define INTERNAL_CATCH_THROWS_AS( macroName, exceptionType, resultDisposition, expr ) \ + do { \ + Catch::AssertionHandler catchAssertionHandler( macroName, CATCH_INTERNAL_LINEINFO, CATCH_INTERNAL_STRINGIFY(expr) ", " CATCH_INTERNAL_STRINGIFY(exceptionType), resultDisposition ); \ + if( catchAssertionHandler.allowThrows() ) \ + try { \ + static_cast(expr); \ + catchAssertionHandler.handleUnexpectedExceptionNotThrown(); \ + } \ + catch( exceptionType const& ) { \ + catchAssertionHandler.handleExceptionThrownAsExpected(); \ + } \ + catch( ... ) { \ + catchAssertionHandler.handleUnexpectedInflightException(); \ + } \ + else \ + catchAssertionHandler.handleThrowingCallSkipped(); \ + INTERNAL_CATCH_REACT( catchAssertionHandler ) \ + } while( false ) + +/////////////////////////////////////////////////////////////////////////////// +#define INTERNAL_CATCH_MSG( macroName, messageType, resultDisposition, ... ) \ + do { \ + Catch::AssertionHandler catchAssertionHandler( macroName, CATCH_INTERNAL_LINEINFO, Catch::StringRef(), resultDisposition ); \ + catchAssertionHandler.handleMessage( messageType, ( Catch::MessageStream() << __VA_ARGS__ + ::Catch::StreamEndStop() ).m_stream.str() ); \ + INTERNAL_CATCH_REACT( catchAssertionHandler ) \ + } while( false ) + +/////////////////////////////////////////////////////////////////////////////// +#define INTERNAL_CATCH_INFO( macroName, log ) \ + Catch::ScopedMessage INTERNAL_CATCH_UNIQUE_NAME( scopedMessage )( Catch::MessageBuilder( macroName, CATCH_INTERNAL_LINEINFO, Catch::ResultWas::Info ) << log ); + +/////////////////////////////////////////////////////////////////////////////// +// Although this is matcher-based, it can be used with just a string +#define INTERNAL_CATCH_THROWS_STR_MATCHES( macroName, resultDisposition, matcher, ... ) \ + do { \ + Catch::AssertionHandler catchAssertionHandler( macroName, CATCH_INTERNAL_LINEINFO, CATCH_INTERNAL_STRINGIFY(__VA_ARGS__) ", " CATCH_INTERNAL_STRINGIFY(matcher), resultDisposition ); \ + if( catchAssertionHandler.allowThrows() ) \ + try { \ + static_cast(__VA_ARGS__); \ + catchAssertionHandler.handleUnexpectedExceptionNotThrown(); \ + } \ + catch( ... ) { \ + Catch::handleExceptionMatchExpr( catchAssertionHandler, matcher, #matcher ); \ + } \ + else \ + catchAssertionHandler.handleThrowingCallSkipped(); \ + INTERNAL_CATCH_REACT( catchAssertionHandler ) \ + } while( false ) + +#endif // CATCH_CONFIG_DISABLE + +// end catch_capture.hpp +// start catch_section.h + +// start catch_section_info.h + +// start catch_totals.h + +#include + +namespace Catch { + + struct Counts { + Counts operator - ( Counts const& other ) const; + Counts& operator += ( Counts const& other ); + + std::size_t total() const; + bool allPassed() const; + bool allOk() const; + + std::size_t passed = 0; + std::size_t failed = 0; + std::size_t failedButOk = 0; + }; + + struct Totals { + + Totals operator - ( Totals const& other ) const; + Totals& operator += ( Totals const& other ); + + Totals delta( Totals const& prevTotals ) const; + + int error = 0; + Counts assertions; + Counts testCases; + }; +} + +// end catch_totals.h +#include + +namespace Catch { + + struct SectionInfo { + SectionInfo + ( SourceLineInfo const& _lineInfo, + std::string const& _name ); + + // Deprecated + SectionInfo + ( SourceLineInfo const& _lineInfo, + std::string const& _name, + std::string const& ) : SectionInfo( _lineInfo, _name ) {} + + std::string name; + std::string description; // !Deprecated: this will always be empty + SourceLineInfo lineInfo; + }; + + struct SectionEndInfo { + SectionInfo sectionInfo; + Counts prevAssertions; + double durationInSeconds; + }; + +} // end namespace Catch + +// end catch_section_info.h +// start catch_timer.h + +#include + +namespace Catch { + + auto getCurrentNanosecondsSinceEpoch() -> uint64_t; + auto getEstimatedClockResolution() -> uint64_t; + + class Timer { + uint64_t m_nanoseconds = 0; + public: + void start(); + auto getElapsedNanoseconds() const -> uint64_t; + auto getElapsedMicroseconds() const -> uint64_t; + auto getElapsedMilliseconds() const -> unsigned int; + auto getElapsedSeconds() const -> double; + }; + +} // namespace Catch + +// end catch_timer.h +#include + +namespace Catch { + + class Section : NonCopyable { + public: + Section( SectionInfo const& info ); + ~Section(); + + // This indicates whether the section should be executed or not + explicit operator bool() const; + + private: + SectionInfo m_info; + + std::string m_name; + Counts m_assertions; + bool m_sectionIncluded; + Timer m_timer; + }; + +} // end namespace Catch + +#define INTERNAL_CATCH_SECTION( ... ) \ + CATCH_INTERNAL_SUPPRESS_UNUSED_WARNINGS \ + if( Catch::Section const& INTERNAL_CATCH_UNIQUE_NAME( catch_internal_Section ) = Catch::SectionInfo( CATCH_INTERNAL_LINEINFO, __VA_ARGS__ ) ) \ + CATCH_INTERNAL_UNSUPPRESS_UNUSED_WARNINGS + +#define INTERNAL_CATCH_DYNAMIC_SECTION( ... ) \ + CATCH_INTERNAL_SUPPRESS_UNUSED_WARNINGS \ + if( Catch::Section const& INTERNAL_CATCH_UNIQUE_NAME( catch_internal_Section ) = Catch::SectionInfo( CATCH_INTERNAL_LINEINFO, (Catch::ReusableStringStream() << __VA_ARGS__).str() ) ) \ + CATCH_INTERNAL_UNSUPPRESS_UNUSED_WARNINGS + +// end catch_section.h +// start catch_benchmark.h + +#include +#include + +namespace Catch { + + class BenchmarkLooper { + + std::string m_name; + std::size_t m_count = 0; + std::size_t m_iterationsToRun = 1; + uint64_t m_resolution; + Timer m_timer; + + static auto getResolution() -> uint64_t; + public: + // Keep most of this inline as it's on the code path that is being timed + BenchmarkLooper( StringRef name ) + : m_name( name ), + m_resolution( getResolution() ) + { + reportStart(); + m_timer.start(); + } + + explicit operator bool() { + if( m_count < m_iterationsToRun ) + return true; + return needsMoreIterations(); + } + + void increment() { + ++m_count; + } + + void reportStart(); + auto needsMoreIterations() -> bool; + }; + +} // end namespace Catch + +#define BENCHMARK( name ) \ + for( Catch::BenchmarkLooper looper( name ); looper; looper.increment() ) + +// end catch_benchmark.h +// start catch_interfaces_exception.h + +// start catch_interfaces_registry_hub.h + +#include +#include + +namespace Catch { + + class TestCase; + struct ITestCaseRegistry; + struct IExceptionTranslatorRegistry; + struct IExceptionTranslator; + struct IReporterRegistry; + struct IReporterFactory; + struct ITagAliasRegistry; + class StartupExceptionRegistry; + + using IReporterFactoryPtr = std::shared_ptr; + + struct IRegistryHub { + virtual ~IRegistryHub(); + + virtual IReporterRegistry const& getReporterRegistry() const = 0; + virtual ITestCaseRegistry const& getTestCaseRegistry() const = 0; + virtual ITagAliasRegistry const& getTagAliasRegistry() const = 0; + + virtual IExceptionTranslatorRegistry& getExceptionTranslatorRegistry() = 0; + + virtual StartupExceptionRegistry const& getStartupExceptionRegistry() const = 0; + }; + + struct IMutableRegistryHub { + virtual ~IMutableRegistryHub(); + virtual void registerReporter( std::string const& name, IReporterFactoryPtr const& factory ) = 0; + virtual void registerListener( IReporterFactoryPtr const& factory ) = 0; + virtual void registerTest( TestCase const& testInfo ) = 0; + virtual void registerTranslator( const IExceptionTranslator* translator ) = 0; + virtual void registerTagAlias( std::string const& alias, std::string const& tag, SourceLineInfo const& lineInfo ) = 0; + virtual void registerStartupException() noexcept = 0; + }; + + IRegistryHub& getRegistryHub(); + IMutableRegistryHub& getMutableRegistryHub(); + void cleanUp(); + std::string translateActiveException(); + +} + +// end catch_interfaces_registry_hub.h +#if defined(CATCH_CONFIG_DISABLE) + #define INTERNAL_CATCH_TRANSLATE_EXCEPTION_NO_REG( translatorName, signature) \ + static std::string translatorName( signature ) +#endif + +#include +#include +#include + +namespace Catch { + using exceptionTranslateFunction = std::string(*)(); + + struct IExceptionTranslator; + using ExceptionTranslators = std::vector>; + + struct IExceptionTranslator { + virtual ~IExceptionTranslator(); + virtual std::string translate( ExceptionTranslators::const_iterator it, ExceptionTranslators::const_iterator itEnd ) const = 0; + }; + + struct IExceptionTranslatorRegistry { + virtual ~IExceptionTranslatorRegistry(); + + virtual std::string translateActiveException() const = 0; + }; + + class ExceptionTranslatorRegistrar { + template + class ExceptionTranslator : public IExceptionTranslator { + public: + + ExceptionTranslator( std::string(*translateFunction)( T& ) ) + : m_translateFunction( translateFunction ) + {} + + std::string translate( ExceptionTranslators::const_iterator it, ExceptionTranslators::const_iterator itEnd ) const override { + try { + if( it == itEnd ) + std::rethrow_exception(std::current_exception()); + else + return (*it)->translate( it+1, itEnd ); + } + catch( T& ex ) { + return m_translateFunction( ex ); + } + } + + protected: + std::string(*m_translateFunction)( T& ); + }; + + public: + template + ExceptionTranslatorRegistrar( std::string(*translateFunction)( T& ) ) { + getMutableRegistryHub().registerTranslator + ( new ExceptionTranslator( translateFunction ) ); + } + }; +} + +/////////////////////////////////////////////////////////////////////////////// +#define INTERNAL_CATCH_TRANSLATE_EXCEPTION2( translatorName, signature ) \ + static std::string translatorName( signature ); \ + CATCH_INTERNAL_SUPPRESS_GLOBALS_WARNINGS \ + namespace{ Catch::ExceptionTranslatorRegistrar INTERNAL_CATCH_UNIQUE_NAME( catch_internal_ExceptionRegistrar )( &translatorName ); } \ + CATCH_INTERNAL_UNSUPPRESS_GLOBALS_WARNINGS \ + static std::string translatorName( signature ) + +#define INTERNAL_CATCH_TRANSLATE_EXCEPTION( signature ) INTERNAL_CATCH_TRANSLATE_EXCEPTION2( INTERNAL_CATCH_UNIQUE_NAME( catch_internal_ExceptionTranslator ), signature ) + +// end catch_interfaces_exception.h +// start catch_approx.h + +#include +#include + +namespace Catch { +namespace Detail { + + class Approx { + private: + bool equalityComparisonImpl(double other) const; + + public: + explicit Approx ( double value ); + + static Approx custom(); + + Approx operator-() const; + + template ::value>::type> + Approx operator()( T const& value ) { + Approx approx( static_cast(value) ); + approx.epsilon( m_epsilon ); + approx.margin( m_margin ); + approx.scale( m_scale ); + return approx; + } + + template ::value>::type> + explicit Approx( T const& value ): Approx(static_cast(value)) + {} + + template ::value>::type> + friend bool operator == ( const T& lhs, Approx const& rhs ) { + auto lhs_v = static_cast(lhs); + return rhs.equalityComparisonImpl(lhs_v); + } + + template ::value>::type> + friend bool operator == ( Approx const& lhs, const T& rhs ) { + return operator==( rhs, lhs ); + } + + template ::value>::type> + friend bool operator != ( T const& lhs, Approx const& rhs ) { + return !operator==( lhs, rhs ); + } + + template ::value>::type> + friend bool operator != ( Approx const& lhs, T const& rhs ) { + return !operator==( rhs, lhs ); + } + + template ::value>::type> + friend bool operator <= ( T const& lhs, Approx const& rhs ) { + return static_cast(lhs) < rhs.m_value || lhs == rhs; + } + + template ::value>::type> + friend bool operator <= ( Approx const& lhs, T const& rhs ) { + return lhs.m_value < static_cast(rhs) || lhs == rhs; + } + + template ::value>::type> + friend bool operator >= ( T const& lhs, Approx const& rhs ) { + return static_cast(lhs) > rhs.m_value || lhs == rhs; + } + + template ::value>::type> + friend bool operator >= ( Approx const& lhs, T const& rhs ) { + return lhs.m_value > static_cast(rhs) || lhs == rhs; + } + + template ::value>::type> + Approx& epsilon( T const& newEpsilon ) { + double epsilonAsDouble = static_cast(newEpsilon); + if( epsilonAsDouble < 0 || epsilonAsDouble > 1.0 ) { + throw std::domain_error + ( "Invalid Approx::epsilon: " + + Catch::Detail::stringify( epsilonAsDouble ) + + ", Approx::epsilon has to be between 0 and 1" ); + } + m_epsilon = epsilonAsDouble; + return *this; + } + + template ::value>::type> + Approx& margin( T const& newMargin ) { + double marginAsDouble = static_cast(newMargin); + if( marginAsDouble < 0 ) { + throw std::domain_error + ( "Invalid Approx::margin: " + + Catch::Detail::stringify( marginAsDouble ) + + ", Approx::Margin has to be non-negative." ); + + } + m_margin = marginAsDouble; + return *this; + } + + template ::value>::type> + Approx& scale( T const& newScale ) { + m_scale = static_cast(newScale); + return *this; + } + + std::string toString() const; + + private: + double m_epsilon; + double m_margin; + double m_scale; + double m_value; + }; +} // end namespace Detail + +namespace literals { + Detail::Approx operator "" _a(long double val); + Detail::Approx operator "" _a(unsigned long long val); +} // end namespace literals + +template<> +struct StringMaker { + static std::string convert(Catch::Detail::Approx const& value); +}; + +} // end namespace Catch + +// end catch_approx.h +// start catch_string_manip.h + +#include +#include + +namespace Catch { + + bool startsWith( std::string const& s, std::string const& prefix ); + bool startsWith( std::string const& s, char prefix ); + bool endsWith( std::string const& s, std::string const& suffix ); + bool endsWith( std::string const& s, char suffix ); + bool contains( std::string const& s, std::string const& infix ); + void toLowerInPlace( std::string& s ); + std::string toLower( std::string const& s ); + std::string trim( std::string const& str ); + bool replaceInPlace( std::string& str, std::string const& replaceThis, std::string const& withThis ); + + struct pluralise { + pluralise( std::size_t count, std::string const& label ); + + friend std::ostream& operator << ( std::ostream& os, pluralise const& pluraliser ); + + std::size_t m_count; + std::string m_label; + }; +} + +// end catch_string_manip.h +#ifndef CATCH_CONFIG_DISABLE_MATCHERS +// start catch_capture_matchers.h + +// start catch_matchers.h + +#include +#include + +namespace Catch { +namespace Matchers { + namespace Impl { + + template struct MatchAllOf; + template struct MatchAnyOf; + template struct MatchNotOf; + + class MatcherUntypedBase { + public: + MatcherUntypedBase() = default; + MatcherUntypedBase ( MatcherUntypedBase const& ) = default; + MatcherUntypedBase& operator = ( MatcherUntypedBase const& ) = delete; + std::string toString() const; + + protected: + virtual ~MatcherUntypedBase(); + virtual std::string describe() const = 0; + mutable std::string m_cachedToString; + }; + + template + struct MatcherMethod { + virtual bool match( ObjectT const& arg ) const = 0; + }; + template + struct MatcherMethod { + virtual bool match( PtrT* arg ) const = 0; + }; + + template + struct MatcherBase : MatcherUntypedBase, MatcherMethod { + + MatchAllOf operator && ( MatcherBase const& other ) const; + MatchAnyOf operator || ( MatcherBase const& other ) const; + MatchNotOf operator ! () const; + }; + + template + struct MatchAllOf : MatcherBase { + bool match( ArgT const& arg ) const override { + for( auto matcher : m_matchers ) { + if (!matcher->match(arg)) + return false; + } + return true; + } + std::string describe() const override { + std::string description; + description.reserve( 4 + m_matchers.size()*32 ); + description += "( "; + bool first = true; + for( auto matcher : m_matchers ) { + if( first ) + first = false; + else + description += " and "; + description += matcher->toString(); + } + description += " )"; + return description; + } + + MatchAllOf& operator && ( MatcherBase const& other ) { + m_matchers.push_back( &other ); + return *this; + } + + std::vector const*> m_matchers; + }; + template + struct MatchAnyOf : MatcherBase { + + bool match( ArgT const& arg ) const override { + for( auto matcher : m_matchers ) { + if (matcher->match(arg)) + return true; + } + return false; + } + std::string describe() const override { + std::string description; + description.reserve( 4 + m_matchers.size()*32 ); + description += "( "; + bool first = true; + for( auto matcher : m_matchers ) { + if( first ) + first = false; + else + description += " or "; + description += matcher->toString(); + } + description += " )"; + return description; + } + + MatchAnyOf& operator || ( MatcherBase const& other ) { + m_matchers.push_back( &other ); + return *this; + } + + std::vector const*> m_matchers; + }; + + template + struct MatchNotOf : MatcherBase { + + MatchNotOf( MatcherBase const& underlyingMatcher ) : m_underlyingMatcher( underlyingMatcher ) {} + + bool match( ArgT const& arg ) const override { + return !m_underlyingMatcher.match( arg ); + } + + std::string describe() const override { + return "not " + m_underlyingMatcher.toString(); + } + MatcherBase const& m_underlyingMatcher; + }; + + template + MatchAllOf MatcherBase::operator && ( MatcherBase const& other ) const { + return MatchAllOf() && *this && other; + } + template + MatchAnyOf MatcherBase::operator || ( MatcherBase const& other ) const { + return MatchAnyOf() || *this || other; + } + template + MatchNotOf MatcherBase::operator ! () const { + return MatchNotOf( *this ); + } + + } // namespace Impl + +} // namespace Matchers + +using namespace Matchers; +using Matchers::Impl::MatcherBase; + +} // namespace Catch + +// end catch_matchers.h +// start catch_matchers_floating.h + +#include +#include + +namespace Catch { +namespace Matchers { + + namespace Floating { + + enum class FloatingPointKind : uint8_t; + + struct WithinAbsMatcher : MatcherBase { + WithinAbsMatcher(double target, double margin); + bool match(double const& matchee) const override; + std::string describe() const override; + private: + double m_target; + double m_margin; + }; + + struct WithinUlpsMatcher : MatcherBase { + WithinUlpsMatcher(double target, int ulps, FloatingPointKind baseType); + bool match(double const& matchee) const override; + std::string describe() const override; + private: + double m_target; + int m_ulps; + FloatingPointKind m_type; + }; + + } // namespace Floating + + // The following functions create the actual matcher objects. + // This allows the types to be inferred + Floating::WithinUlpsMatcher WithinULP(double target, int maxUlpDiff); + Floating::WithinUlpsMatcher WithinULP(float target, int maxUlpDiff); + Floating::WithinAbsMatcher WithinAbs(double target, double margin); + +} // namespace Matchers +} // namespace Catch + +// end catch_matchers_floating.h +// start catch_matchers_generic.hpp + +#include +#include + +namespace Catch { +namespace Matchers { +namespace Generic { + +namespace Detail { + std::string finalizeDescription(const std::string& desc); +} + +template +class PredicateMatcher : public MatcherBase { + std::function m_predicate; + std::string m_description; +public: + + PredicateMatcher(std::function const& elem, std::string const& descr) + :m_predicate(std::move(elem)), + m_description(Detail::finalizeDescription(descr)) + {} + + bool match( T const& item ) const override { + return m_predicate(item); + } + + std::string describe() const override { + return m_description; + } +}; + +} // namespace Generic + + // The following functions create the actual matcher objects. + // The user has to explicitly specify type to the function, because + // infering std::function is hard (but possible) and + // requires a lot of TMP. + template + Generic::PredicateMatcher Predicate(std::function const& predicate, std::string const& description = "") { + return Generic::PredicateMatcher(predicate, description); + } + +} // namespace Matchers +} // namespace Catch + +// end catch_matchers_generic.hpp +// start catch_matchers_string.h + +#include + +namespace Catch { +namespace Matchers { + + namespace StdString { + + struct CasedString + { + CasedString( std::string const& str, CaseSensitive::Choice caseSensitivity ); + std::string adjustString( std::string const& str ) const; + std::string caseSensitivitySuffix() const; + + CaseSensitive::Choice m_caseSensitivity; + std::string m_str; + }; + + struct StringMatcherBase : MatcherBase { + StringMatcherBase( std::string const& operation, CasedString const& comparator ); + std::string describe() const override; + + CasedString m_comparator; + std::string m_operation; + }; + + struct EqualsMatcher : StringMatcherBase { + EqualsMatcher( CasedString const& comparator ); + bool match( std::string const& source ) const override; + }; + struct ContainsMatcher : StringMatcherBase { + ContainsMatcher( CasedString const& comparator ); + bool match( std::string const& source ) const override; + }; + struct StartsWithMatcher : StringMatcherBase { + StartsWithMatcher( CasedString const& comparator ); + bool match( std::string const& source ) const override; + }; + struct EndsWithMatcher : StringMatcherBase { + EndsWithMatcher( CasedString const& comparator ); + bool match( std::string const& source ) const override; + }; + + struct RegexMatcher : MatcherBase { + RegexMatcher( std::string regex, CaseSensitive::Choice caseSensitivity ); + bool match( std::string const& matchee ) const override; + std::string describe() const override; + + private: + std::string m_regex; + CaseSensitive::Choice m_caseSensitivity; + }; + + } // namespace StdString + + // The following functions create the actual matcher objects. + // This allows the types to be inferred + + StdString::EqualsMatcher Equals( std::string const& str, CaseSensitive::Choice caseSensitivity = CaseSensitive::Yes ); + StdString::ContainsMatcher Contains( std::string const& str, CaseSensitive::Choice caseSensitivity = CaseSensitive::Yes ); + StdString::EndsWithMatcher EndsWith( std::string const& str, CaseSensitive::Choice caseSensitivity = CaseSensitive::Yes ); + StdString::StartsWithMatcher StartsWith( std::string const& str, CaseSensitive::Choice caseSensitivity = CaseSensitive::Yes ); + StdString::RegexMatcher Matches( std::string const& regex, CaseSensitive::Choice caseSensitivity = CaseSensitive::Yes ); + +} // namespace Matchers +} // namespace Catch + +// end catch_matchers_string.h +// start catch_matchers_vector.h + +#include + +namespace Catch { +namespace Matchers { + + namespace Vector { + namespace Detail { + template + size_t count(InputIterator first, InputIterator last, T const& item) { + size_t cnt = 0; + for (; first != last; ++first) { + if (*first == item) { + ++cnt; + } + } + return cnt; + } + template + bool contains(InputIterator first, InputIterator last, T const& item) { + for (; first != last; ++first) { + if (*first == item) { + return true; + } + } + return false; + } + } + + template + struct ContainsElementMatcher : MatcherBase> { + + ContainsElementMatcher(T const &comparator) : m_comparator( comparator) {} + + bool match(std::vector const &v) const override { + for (auto const& el : v) { + if (el == m_comparator) { + return true; + } + } + return false; + } + + std::string describe() const override { + return "Contains: " + ::Catch::Detail::stringify( m_comparator ); + } + + T const& m_comparator; + }; + + template + struct ContainsMatcher : MatcherBase> { + + ContainsMatcher(std::vector const &comparator) : m_comparator( comparator ) {} + + bool match(std::vector const &v) const override { + // !TBD: see note in EqualsMatcher + if (m_comparator.size() > v.size()) + return false; + for (auto const& comparator : m_comparator) { + auto present = false; + for (const auto& el : v) { + if (el == comparator) { + present = true; + break; + } + } + if (!present) { + return false; + } + } + return true; + } + std::string describe() const override { + return "Contains: " + ::Catch::Detail::stringify( m_comparator ); + } + + std::vector const& m_comparator; + }; + + template + struct EqualsMatcher : MatcherBase> { + + EqualsMatcher(std::vector const &comparator) : m_comparator( comparator ) {} + + bool match(std::vector const &v) const override { + // !TBD: This currently works if all elements can be compared using != + // - a more general approach would be via a compare template that defaults + // to using !=. but could be specialised for, e.g. std::vector etc + // - then just call that directly + if (m_comparator.size() != v.size()) + return false; + for (std::size_t i = 0; i < v.size(); ++i) + if (m_comparator[i] != v[i]) + return false; + return true; + } + std::string describe() const override { + return "Equals: " + ::Catch::Detail::stringify( m_comparator ); + } + std::vector const& m_comparator; + }; + + template + struct UnorderedEqualsMatcher : MatcherBase> { + UnorderedEqualsMatcher(std::vector const& target) : m_target(target) {} + bool match(std::vector const& vec) const override { + // Note: This is a reimplementation of std::is_permutation, + // because I don't want to include inside the common path + if (m_target.size() != vec.size()) { + return false; + } + auto lfirst = m_target.begin(), llast = m_target.end(); + auto rfirst = vec.begin(), rlast = vec.end(); + // Cut common prefix to optimize checking of permuted parts + while (lfirst != llast && *lfirst != *rfirst) { + ++lfirst; ++rfirst; + } + if (lfirst == llast) { + return true; + } + + for (auto mid = lfirst; mid != llast; ++mid) { + // Skip already counted items + if (Detail::contains(lfirst, mid, *mid)) { + continue; + } + size_t num_vec = Detail::count(rfirst, rlast, *mid); + if (num_vec == 0 || Detail::count(lfirst, llast, *mid) != num_vec) { + return false; + } + } + + return true; + } + + std::string describe() const override { + return "UnorderedEquals: " + ::Catch::Detail::stringify(m_target); + } + private: + std::vector const& m_target; + }; + + } // namespace Vector + + // The following functions create the actual matcher objects. + // This allows the types to be inferred + + template + Vector::ContainsMatcher Contains( std::vector const& comparator ) { + return Vector::ContainsMatcher( comparator ); + } + + template + Vector::ContainsElementMatcher VectorContains( T const& comparator ) { + return Vector::ContainsElementMatcher( comparator ); + } + + template + Vector::EqualsMatcher Equals( std::vector const& comparator ) { + return Vector::EqualsMatcher( comparator ); + } + + template + Vector::UnorderedEqualsMatcher UnorderedEquals(std::vector const& target) { + return Vector::UnorderedEqualsMatcher(target); + } + +} // namespace Matchers +} // namespace Catch + +// end catch_matchers_vector.h +namespace Catch { + + template + class MatchExpr : public ITransientExpression { + ArgT const& m_arg; + MatcherT m_matcher; + StringRef m_matcherString; + public: + MatchExpr( ArgT const& arg, MatcherT const& matcher, StringRef matcherString ) + : ITransientExpression{ true, matcher.match( arg ) }, + m_arg( arg ), + m_matcher( matcher ), + m_matcherString( matcherString ) + {} + + void streamReconstructedExpression( std::ostream &os ) const override { + auto matcherAsString = m_matcher.toString(); + os << Catch::Detail::stringify( m_arg ) << ' '; + if( matcherAsString == Detail::unprintableString ) + os << m_matcherString; + else + os << matcherAsString; + } + }; + + using StringMatcher = Matchers::Impl::MatcherBase; + + void handleExceptionMatchExpr( AssertionHandler& handler, StringMatcher const& matcher, StringRef matcherString ); + + template + auto makeMatchExpr( ArgT const& arg, MatcherT const& matcher, StringRef matcherString ) -> MatchExpr { + return MatchExpr( arg, matcher, matcherString ); + } + +} // namespace Catch + +/////////////////////////////////////////////////////////////////////////////// +#define INTERNAL_CHECK_THAT( macroName, matcher, resultDisposition, arg ) \ + do { \ + Catch::AssertionHandler catchAssertionHandler( macroName, CATCH_INTERNAL_LINEINFO, CATCH_INTERNAL_STRINGIFY(arg) ", " CATCH_INTERNAL_STRINGIFY(matcher), resultDisposition ); \ + INTERNAL_CATCH_TRY { \ + catchAssertionHandler.handleExpr( Catch::makeMatchExpr( arg, matcher, #matcher ) ); \ + } INTERNAL_CATCH_CATCH( catchAssertionHandler ) \ + INTERNAL_CATCH_REACT( catchAssertionHandler ) \ + } while( false ) + +/////////////////////////////////////////////////////////////////////////////// +#define INTERNAL_CATCH_THROWS_MATCHES( macroName, exceptionType, resultDisposition, matcher, ... ) \ + do { \ + Catch::AssertionHandler catchAssertionHandler( macroName, CATCH_INTERNAL_LINEINFO, CATCH_INTERNAL_STRINGIFY(__VA_ARGS__) ", " CATCH_INTERNAL_STRINGIFY(exceptionType) ", " CATCH_INTERNAL_STRINGIFY(matcher), resultDisposition ); \ + if( catchAssertionHandler.allowThrows() ) \ + try { \ + static_cast(__VA_ARGS__ ); \ + catchAssertionHandler.handleUnexpectedExceptionNotThrown(); \ + } \ + catch( exceptionType const& ex ) { \ + catchAssertionHandler.handleExpr( Catch::makeMatchExpr( ex, matcher, #matcher ) ); \ + } \ + catch( ... ) { \ + catchAssertionHandler.handleUnexpectedInflightException(); \ + } \ + else \ + catchAssertionHandler.handleThrowingCallSkipped(); \ + INTERNAL_CATCH_REACT( catchAssertionHandler ) \ + } while( false ) + +// end catch_capture_matchers.h +#endif + +// These files are included here so the single_include script doesn't put them +// in the conditionally compiled sections +// start catch_test_case_info.h + +#include +#include +#include + +#ifdef __clang__ +#pragma clang diagnostic push +#pragma clang diagnostic ignored "-Wpadded" +#endif + +namespace Catch { + + struct ITestInvoker; + + struct TestCaseInfo { + enum SpecialProperties{ + None = 0, + IsHidden = 1 << 1, + ShouldFail = 1 << 2, + MayFail = 1 << 3, + Throws = 1 << 4, + NonPortable = 1 << 5, + Benchmark = 1 << 6 + }; + + TestCaseInfo( std::string const& _name, + std::string const& _className, + std::string const& _description, + std::vector const& _tags, + SourceLineInfo const& _lineInfo ); + + friend void setTags( TestCaseInfo& testCaseInfo, std::vector tags ); + + bool isHidden() const; + bool throws() const; + bool okToFail() const; + bool expectedToFail() const; + + std::string tagsAsString() const; + + std::string name; + std::string className; + std::string description; + std::vector tags; + std::vector lcaseTags; + SourceLineInfo lineInfo; + SpecialProperties properties; + }; + + class TestCase : public TestCaseInfo { + public: + + TestCase( ITestInvoker* testCase, TestCaseInfo&& info ); + + TestCase withName( std::string const& _newName ) const; + + void invoke() const; + + TestCaseInfo const& getTestCaseInfo() const; + + bool operator == ( TestCase const& other ) const; + bool operator < ( TestCase const& other ) const; + + private: + std::shared_ptr test; + }; + + TestCase makeTestCase( ITestInvoker* testCase, + std::string const& className, + NameAndTags const& nameAndTags, + SourceLineInfo const& lineInfo ); +} + +#ifdef __clang__ +#pragma clang diagnostic pop +#endif + +// end catch_test_case_info.h +// start catch_interfaces_runner.h + +namespace Catch { + + struct IRunner { + virtual ~IRunner(); + virtual bool aborting() const = 0; + }; +} + +// end catch_interfaces_runner.h + +#ifdef __OBJC__ +// start catch_objc.hpp + +#import + +#include + +// NB. Any general catch headers included here must be included +// in catch.hpp first to make sure they are included by the single +// header for non obj-usage + +/////////////////////////////////////////////////////////////////////////////// +// This protocol is really only here for (self) documenting purposes, since +// all its methods are optional. +@protocol OcFixture + +@optional + +-(void) setUp; +-(void) tearDown; + +@end + +namespace Catch { + + class OcMethod : public ITestInvoker { + + public: + OcMethod( Class cls, SEL sel ) : m_cls( cls ), m_sel( sel ) {} + + virtual void invoke() const { + id obj = [[m_cls alloc] init]; + + performOptionalSelector( obj, @selector(setUp) ); + performOptionalSelector( obj, m_sel ); + performOptionalSelector( obj, @selector(tearDown) ); + + arcSafeRelease( obj ); + } + private: + virtual ~OcMethod() {} + + Class m_cls; + SEL m_sel; + }; + + namespace Detail{ + + inline std::string getAnnotation( Class cls, + std::string const& annotationName, + std::string const& testCaseName ) { + NSString* selStr = [[NSString alloc] initWithFormat:@"Catch_%s_%s", annotationName.c_str(), testCaseName.c_str()]; + SEL sel = NSSelectorFromString( selStr ); + arcSafeRelease( selStr ); + id value = performOptionalSelector( cls, sel ); + if( value ) + return [(NSString*)value UTF8String]; + return ""; + } + } + + inline std::size_t registerTestMethods() { + std::size_t noTestMethods = 0; + int noClasses = objc_getClassList( nullptr, 0 ); + + Class* classes = (CATCH_UNSAFE_UNRETAINED Class *)malloc( sizeof(Class) * noClasses); + objc_getClassList( classes, noClasses ); + + for( int c = 0; c < noClasses; c++ ) { + Class cls = classes[c]; + { + u_int count; + Method* methods = class_copyMethodList( cls, &count ); + for( u_int m = 0; m < count ; m++ ) { + SEL selector = method_getName(methods[m]); + std::string methodName = sel_getName(selector); + if( startsWith( methodName, "Catch_TestCase_" ) ) { + std::string testCaseName = methodName.substr( 15 ); + std::string name = Detail::getAnnotation( cls, "Name", testCaseName ); + std::string desc = Detail::getAnnotation( cls, "Description", testCaseName ); + const char* className = class_getName( cls ); + + getMutableRegistryHub().registerTest( makeTestCase( new OcMethod( cls, selector ), className, NameAndTags( name.c_str(), desc.c_str() ), SourceLineInfo("",0) ) ); + noTestMethods++; + } + } + free(methods); + } + } + return noTestMethods; + } + +#if !defined(CATCH_CONFIG_DISABLE_MATCHERS) + + namespace Matchers { + namespace Impl { + namespace NSStringMatchers { + + struct StringHolder : MatcherBase{ + StringHolder( NSString* substr ) : m_substr( [substr copy] ){} + StringHolder( StringHolder const& other ) : m_substr( [other.m_substr copy] ){} + StringHolder() { + arcSafeRelease( m_substr ); + } + + bool match( NSString* arg ) const override { + return false; + } + + NSString* CATCH_ARC_STRONG m_substr; + }; + + struct Equals : StringHolder { + Equals( NSString* substr ) : StringHolder( substr ){} + + bool match( NSString* str ) const override { + return (str != nil || m_substr == nil ) && + [str isEqualToString:m_substr]; + } + + std::string describe() const override { + return "equals string: " + Catch::Detail::stringify( m_substr ); + } + }; + + struct Contains : StringHolder { + Contains( NSString* substr ) : StringHolder( substr ){} + + bool match( NSString* str ) const { + return (str != nil || m_substr == nil ) && + [str rangeOfString:m_substr].location != NSNotFound; + } + + std::string describe() const override { + return "contains string: " + Catch::Detail::stringify( m_substr ); + } + }; + + struct StartsWith : StringHolder { + StartsWith( NSString* substr ) : StringHolder( substr ){} + + bool match( NSString* str ) const override { + return (str != nil || m_substr == nil ) && + [str rangeOfString:m_substr].location == 0; + } + + std::string describe() const override { + return "starts with: " + Catch::Detail::stringify( m_substr ); + } + }; + struct EndsWith : StringHolder { + EndsWith( NSString* substr ) : StringHolder( substr ){} + + bool match( NSString* str ) const override { + return (str != nil || m_substr == nil ) && + [str rangeOfString:m_substr].location == [str length] - [m_substr length]; + } + + std::string describe() const override { + return "ends with: " + Catch::Detail::stringify( m_substr ); + } + }; + + } // namespace NSStringMatchers + } // namespace Impl + + inline Impl::NSStringMatchers::Equals + Equals( NSString* substr ){ return Impl::NSStringMatchers::Equals( substr ); } + + inline Impl::NSStringMatchers::Contains + Contains( NSString* substr ){ return Impl::NSStringMatchers::Contains( substr ); } + + inline Impl::NSStringMatchers::StartsWith + StartsWith( NSString* substr ){ return Impl::NSStringMatchers::StartsWith( substr ); } + + inline Impl::NSStringMatchers::EndsWith + EndsWith( NSString* substr ){ return Impl::NSStringMatchers::EndsWith( substr ); } + + } // namespace Matchers + + using namespace Matchers; + +#endif // CATCH_CONFIG_DISABLE_MATCHERS + +} // namespace Catch + +/////////////////////////////////////////////////////////////////////////////// +#define OC_MAKE_UNIQUE_NAME( root, uniqueSuffix ) root##uniqueSuffix +#define OC_TEST_CASE2( name, desc, uniqueSuffix ) \ ++(NSString*) OC_MAKE_UNIQUE_NAME( Catch_Name_test_, uniqueSuffix ) \ +{ \ +return @ name; \ +} \ ++(NSString*) OC_MAKE_UNIQUE_NAME( Catch_Description_test_, uniqueSuffix ) \ +{ \ +return @ desc; \ +} \ +-(void) OC_MAKE_UNIQUE_NAME( Catch_TestCase_test_, uniqueSuffix ) + +#define OC_TEST_CASE( name, desc ) OC_TEST_CASE2( name, desc, __LINE__ ) + +// end catch_objc.hpp +#endif + +#ifdef CATCH_CONFIG_EXTERNAL_INTERFACES +// start catch_external_interfaces.h + +// start catch_reporter_bases.hpp + +// start catch_interfaces_reporter.h + +// start catch_config.hpp + +// start catch_test_spec_parser.h + +#ifdef __clang__ +#pragma clang diagnostic push +#pragma clang diagnostic ignored "-Wpadded" +#endif + +// start catch_test_spec.h + +#ifdef __clang__ +#pragma clang diagnostic push +#pragma clang diagnostic ignored "-Wpadded" +#endif + +// start catch_wildcard_pattern.h + +namespace Catch +{ + class WildcardPattern { + enum WildcardPosition { + NoWildcard = 0, + WildcardAtStart = 1, + WildcardAtEnd = 2, + WildcardAtBothEnds = WildcardAtStart | WildcardAtEnd + }; + + public: + + WildcardPattern( std::string const& pattern, CaseSensitive::Choice caseSensitivity ); + virtual ~WildcardPattern() = default; + virtual bool matches( std::string const& str ) const; + + private: + std::string adjustCase( std::string const& str ) const; + CaseSensitive::Choice m_caseSensitivity; + WildcardPosition m_wildcard = NoWildcard; + std::string m_pattern; + }; +} + +// end catch_wildcard_pattern.h +#include +#include +#include + +namespace Catch { + + class TestSpec { + struct Pattern { + virtual ~Pattern(); + virtual bool matches( TestCaseInfo const& testCase ) const = 0; + }; + using PatternPtr = std::shared_ptr; + + class NamePattern : public Pattern { + public: + NamePattern( std::string const& name ); + virtual ~NamePattern(); + virtual bool matches( TestCaseInfo const& testCase ) const override; + private: + WildcardPattern m_wildcardPattern; + }; + + class TagPattern : public Pattern { + public: + TagPattern( std::string const& tag ); + virtual ~TagPattern(); + virtual bool matches( TestCaseInfo const& testCase ) const override; + private: + std::string m_tag; + }; + + class ExcludedPattern : public Pattern { + public: + ExcludedPattern( PatternPtr const& underlyingPattern ); + virtual ~ExcludedPattern(); + virtual bool matches( TestCaseInfo const& testCase ) const override; + private: + PatternPtr m_underlyingPattern; + }; + + struct Filter { + std::vector m_patterns; + + bool matches( TestCaseInfo const& testCase ) const; + }; + + public: + bool hasFilters() const; + bool matches( TestCaseInfo const& testCase ) const; + + private: + std::vector m_filters; + + friend class TestSpecParser; + }; +} + +#ifdef __clang__ +#pragma clang diagnostic pop +#endif + +// end catch_test_spec.h +// start catch_interfaces_tag_alias_registry.h + +#include + +namespace Catch { + + struct TagAlias; + + struct ITagAliasRegistry { + virtual ~ITagAliasRegistry(); + // Nullptr if not present + virtual TagAlias const* find( std::string const& alias ) const = 0; + virtual std::string expandAliases( std::string const& unexpandedTestSpec ) const = 0; + + static ITagAliasRegistry const& get(); + }; + +} // end namespace Catch + +// end catch_interfaces_tag_alias_registry.h +namespace Catch { + + class TestSpecParser { + enum Mode{ None, Name, QuotedName, Tag, EscapedName }; + Mode m_mode = None; + bool m_exclusion = false; + std::size_t m_start = std::string::npos, m_pos = 0; + std::string m_arg; + std::vector m_escapeChars; + TestSpec::Filter m_currentFilter; + TestSpec m_testSpec; + ITagAliasRegistry const* m_tagAliases = nullptr; + + public: + TestSpecParser( ITagAliasRegistry const& tagAliases ); + + TestSpecParser& parse( std::string const& arg ); + TestSpec testSpec(); + + private: + void visitChar( char c ); + void startNewMode( Mode mode, std::size_t start ); + void escape(); + std::string subString() const; + + template + void addPattern() { + std::string token = subString(); + for( std::size_t i = 0; i < m_escapeChars.size(); ++i ) + token = token.substr( 0, m_escapeChars[i]-m_start-i ) + token.substr( m_escapeChars[i]-m_start-i+1 ); + m_escapeChars.clear(); + if( startsWith( token, "exclude:" ) ) { + m_exclusion = true; + token = token.substr( 8 ); + } + if( !token.empty() ) { + TestSpec::PatternPtr pattern = std::make_shared( token ); + if( m_exclusion ) + pattern = std::make_shared( pattern ); + m_currentFilter.m_patterns.push_back( pattern ); + } + m_exclusion = false; + m_mode = None; + } + + void addFilter(); + }; + TestSpec parseTestSpec( std::string const& arg ); + +} // namespace Catch + +#ifdef __clang__ +#pragma clang diagnostic pop +#endif + +// end catch_test_spec_parser.h +// start catch_interfaces_config.h + +#include +#include +#include +#include + +namespace Catch { + + enum class Verbosity { + Quiet = 0, + Normal, + High + }; + + struct WarnAbout { enum What { + Nothing = 0x00, + NoAssertions = 0x01, + NoTests = 0x02 + }; }; + + struct ShowDurations { enum OrNot { + DefaultForReporter, + Always, + Never + }; }; + struct RunTests { enum InWhatOrder { + InDeclarationOrder, + InLexicographicalOrder, + InRandomOrder + }; }; + struct UseColour { enum YesOrNo { + Auto, + Yes, + No + }; }; + struct WaitForKeypress { enum When { + Never, + BeforeStart = 1, + BeforeExit = 2, + BeforeStartAndExit = BeforeStart | BeforeExit + }; }; + + class TestSpec; + + struct IConfig : NonCopyable { + + virtual ~IConfig(); + + virtual bool allowThrows() const = 0; + virtual std::ostream& stream() const = 0; + virtual std::string name() const = 0; + virtual bool includeSuccessfulResults() const = 0; + virtual bool shouldDebugBreak() const = 0; + virtual bool warnAboutMissingAssertions() const = 0; + virtual bool warnAboutNoTests() const = 0; + virtual int abortAfter() const = 0; + virtual bool showInvisibles() const = 0; + virtual ShowDurations::OrNot showDurations() const = 0; + virtual TestSpec const& testSpec() const = 0; + virtual bool hasTestFilters() const = 0; + virtual RunTests::InWhatOrder runOrder() const = 0; + virtual unsigned int rngSeed() const = 0; + virtual int benchmarkResolutionMultiple() const = 0; + virtual UseColour::YesOrNo useColour() const = 0; + virtual std::vector const& getSectionsToRun() const = 0; + virtual Verbosity verbosity() const = 0; + }; + + using IConfigPtr = std::shared_ptr; +} + +// end catch_interfaces_config.h +// Libstdc++ doesn't like incomplete classes for unique_ptr + +#include +#include +#include + +#ifndef CATCH_CONFIG_CONSOLE_WIDTH +#define CATCH_CONFIG_CONSOLE_WIDTH 80 +#endif + +namespace Catch { + + struct IStream; + + struct ConfigData { + bool listTests = false; + bool listTags = false; + bool listReporters = false; + bool listTestNamesOnly = false; + + bool showSuccessfulTests = false; + bool shouldDebugBreak = false; + bool noThrow = false; + bool showHelp = false; + bool showInvisibles = false; + bool filenamesAsTags = false; + bool libIdentify = false; + + int abortAfter = -1; + unsigned int rngSeed = 0; + int benchmarkResolutionMultiple = 100; + + Verbosity verbosity = Verbosity::Normal; + WarnAbout::What warnings = WarnAbout::Nothing; + ShowDurations::OrNot showDurations = ShowDurations::DefaultForReporter; + RunTests::InWhatOrder runOrder = RunTests::InDeclarationOrder; + UseColour::YesOrNo useColour = UseColour::Auto; + WaitForKeypress::When waitForKeypress = WaitForKeypress::Never; + + std::string outputFilename; + std::string name; + std::string processName; +#ifndef CATCH_CONFIG_DEFAULT_REPORTER +#define CATCH_CONFIG_DEFAULT_REPORTER "console" +#endif + std::string reporterName = CATCH_CONFIG_DEFAULT_REPORTER; +#undef CATCH_CONFIG_DEFAULT_REPORTER + + std::vector testsOrTags; + std::vector sectionsToRun; + }; + + class Config : public IConfig { + public: + + Config() = default; + Config( ConfigData const& data ); + virtual ~Config() = default; + + std::string const& getFilename() const; + + bool listTests() const; + bool listTestNamesOnly() const; + bool listTags() const; + bool listReporters() const; + + std::string getProcessName() const; + std::string const& getReporterName() const; + + std::vector const& getTestsOrTags() const; + std::vector const& getSectionsToRun() const override; + + virtual TestSpec const& testSpec() const override; + bool hasTestFilters() const override; + + bool showHelp() const; + + // IConfig interface + bool allowThrows() const override; + std::ostream& stream() const override; + std::string name() const override; + bool includeSuccessfulResults() const override; + bool warnAboutMissingAssertions() const override; + bool warnAboutNoTests() const override; + ShowDurations::OrNot showDurations() const override; + RunTests::InWhatOrder runOrder() const override; + unsigned int rngSeed() const override; + int benchmarkResolutionMultiple() const override; + UseColour::YesOrNo useColour() const override; + bool shouldDebugBreak() const override; + int abortAfter() const override; + bool showInvisibles() const override; + Verbosity verbosity() const override; + + private: + + IStream const* openStream(); + ConfigData m_data; + + std::unique_ptr m_stream; + TestSpec m_testSpec; + bool m_hasTestFilters = false; + }; + +} // end namespace Catch + +// end catch_config.hpp +// start catch_assertionresult.h + +#include + +namespace Catch { + + struct AssertionResultData + { + AssertionResultData() = delete; + + AssertionResultData( ResultWas::OfType _resultType, LazyExpression const& _lazyExpression ); + + std::string message; + mutable std::string reconstructedExpression; + LazyExpression lazyExpression; + ResultWas::OfType resultType; + + std::string reconstructExpression() const; + }; + + class AssertionResult { + public: + AssertionResult() = delete; + AssertionResult( AssertionInfo const& info, AssertionResultData const& data ); + + bool isOk() const; + bool succeeded() const; + ResultWas::OfType getResultType() const; + bool hasExpression() const; + bool hasMessage() const; + std::string getExpression() const; + std::string getExpressionInMacro() const; + bool hasExpandedExpression() const; + std::string getExpandedExpression() const; + std::string getMessage() const; + SourceLineInfo getSourceInfo() const; + StringRef getTestMacroName() const; + + //protected: + AssertionInfo m_info; + AssertionResultData m_resultData; + }; + +} // end namespace Catch + +// end catch_assertionresult.h +// start catch_option.hpp + +namespace Catch { + + // An optional type + template + class Option { + public: + Option() : nullableValue( nullptr ) {} + Option( T const& _value ) + : nullableValue( new( storage ) T( _value ) ) + {} + Option( Option const& _other ) + : nullableValue( _other ? new( storage ) T( *_other ) : nullptr ) + {} + + ~Option() { + reset(); + } + + Option& operator= ( Option const& _other ) { + if( &_other != this ) { + reset(); + if( _other ) + nullableValue = new( storage ) T( *_other ); + } + return *this; + } + Option& operator = ( T const& _value ) { + reset(); + nullableValue = new( storage ) T( _value ); + return *this; + } + + void reset() { + if( nullableValue ) + nullableValue->~T(); + nullableValue = nullptr; + } + + T& operator*() { return *nullableValue; } + T const& operator*() const { return *nullableValue; } + T* operator->() { return nullableValue; } + const T* operator->() const { return nullableValue; } + + T valueOr( T const& defaultValue ) const { + return nullableValue ? *nullableValue : defaultValue; + } + + bool some() const { return nullableValue != nullptr; } + bool none() const { return nullableValue == nullptr; } + + bool operator !() const { return nullableValue == nullptr; } + explicit operator bool() const { + return some(); + } + + private: + T *nullableValue; + alignas(alignof(T)) char storage[sizeof(T)]; + }; + +} // end namespace Catch + +// end catch_option.hpp +#include +#include +#include +#include +#include + +namespace Catch { + + struct ReporterConfig { + explicit ReporterConfig( IConfigPtr const& _fullConfig ); + + ReporterConfig( IConfigPtr const& _fullConfig, std::ostream& _stream ); + + std::ostream& stream() const; + IConfigPtr fullConfig() const; + + private: + std::ostream* m_stream; + IConfigPtr m_fullConfig; + }; + + struct ReporterPreferences { + bool shouldRedirectStdOut = false; + bool shouldReportAllAssertions = false; + }; + + template + struct LazyStat : Option { + LazyStat& operator=( T const& _value ) { + Option::operator=( _value ); + used = false; + return *this; + } + void reset() { + Option::reset(); + used = false; + } + bool used = false; + }; + + struct TestRunInfo { + TestRunInfo( std::string const& _name ); + std::string name; + }; + struct GroupInfo { + GroupInfo( std::string const& _name, + std::size_t _groupIndex, + std::size_t _groupsCount ); + + std::string name; + std::size_t groupIndex; + std::size_t groupsCounts; + }; + + struct AssertionStats { + AssertionStats( AssertionResult const& _assertionResult, + std::vector const& _infoMessages, + Totals const& _totals ); + + AssertionStats( AssertionStats const& ) = default; + AssertionStats( AssertionStats && ) = default; + AssertionStats& operator = ( AssertionStats const& ) = default; + AssertionStats& operator = ( AssertionStats && ) = default; + virtual ~AssertionStats(); + + AssertionResult assertionResult; + std::vector infoMessages; + Totals totals; + }; + + struct SectionStats { + SectionStats( SectionInfo const& _sectionInfo, + Counts const& _assertions, + double _durationInSeconds, + bool _missingAssertions ); + SectionStats( SectionStats const& ) = default; + SectionStats( SectionStats && ) = default; + SectionStats& operator = ( SectionStats const& ) = default; + SectionStats& operator = ( SectionStats && ) = default; + virtual ~SectionStats(); + + SectionInfo sectionInfo; + Counts assertions; + double durationInSeconds; + bool missingAssertions; + }; + + struct TestCaseStats { + TestCaseStats( TestCaseInfo const& _testInfo, + Totals const& _totals, + std::string const& _stdOut, + std::string const& _stdErr, + bool _aborting ); + + TestCaseStats( TestCaseStats const& ) = default; + TestCaseStats( TestCaseStats && ) = default; + TestCaseStats& operator = ( TestCaseStats const& ) = default; + TestCaseStats& operator = ( TestCaseStats && ) = default; + virtual ~TestCaseStats(); + + TestCaseInfo testInfo; + Totals totals; + std::string stdOut; + std::string stdErr; + bool aborting; + }; + + struct TestGroupStats { + TestGroupStats( GroupInfo const& _groupInfo, + Totals const& _totals, + bool _aborting ); + TestGroupStats( GroupInfo const& _groupInfo ); + + TestGroupStats( TestGroupStats const& ) = default; + TestGroupStats( TestGroupStats && ) = default; + TestGroupStats& operator = ( TestGroupStats const& ) = default; + TestGroupStats& operator = ( TestGroupStats && ) = default; + virtual ~TestGroupStats(); + + GroupInfo groupInfo; + Totals totals; + bool aborting; + }; + + struct TestRunStats { + TestRunStats( TestRunInfo const& _runInfo, + Totals const& _totals, + bool _aborting ); + + TestRunStats( TestRunStats const& ) = default; + TestRunStats( TestRunStats && ) = default; + TestRunStats& operator = ( TestRunStats const& ) = default; + TestRunStats& operator = ( TestRunStats && ) = default; + virtual ~TestRunStats(); + + TestRunInfo runInfo; + Totals totals; + bool aborting; + }; + + struct BenchmarkInfo { + std::string name; + }; + struct BenchmarkStats { + BenchmarkInfo info; + std::size_t iterations; + uint64_t elapsedTimeInNanoseconds; + }; + + struct IStreamingReporter { + virtual ~IStreamingReporter() = default; + + // Implementing class must also provide the following static methods: + // static std::string getDescription(); + // static std::set getSupportedVerbosities() + + virtual ReporterPreferences getPreferences() const = 0; + + virtual void noMatchingTestCases( std::string const& spec ) = 0; + + virtual void testRunStarting( TestRunInfo const& testRunInfo ) = 0; + virtual void testGroupStarting( GroupInfo const& groupInfo ) = 0; + + virtual void testCaseStarting( TestCaseInfo const& testInfo ) = 0; + virtual void sectionStarting( SectionInfo const& sectionInfo ) = 0; + + // *** experimental *** + virtual void benchmarkStarting( BenchmarkInfo const& ) {} + + virtual void assertionStarting( AssertionInfo const& assertionInfo ) = 0; + + // The return value indicates if the messages buffer should be cleared: + virtual bool assertionEnded( AssertionStats const& assertionStats ) = 0; + + // *** experimental *** + virtual void benchmarkEnded( BenchmarkStats const& ) {} + + virtual void sectionEnded( SectionStats const& sectionStats ) = 0; + virtual void testCaseEnded( TestCaseStats const& testCaseStats ) = 0; + virtual void testGroupEnded( TestGroupStats const& testGroupStats ) = 0; + virtual void testRunEnded( TestRunStats const& testRunStats ) = 0; + + virtual void skipTest( TestCaseInfo const& testInfo ) = 0; + + // Default empty implementation provided + virtual void fatalErrorEncountered( StringRef name ); + + virtual bool isMulti() const; + }; + using IStreamingReporterPtr = std::unique_ptr; + + struct IReporterFactory { + virtual ~IReporterFactory(); + virtual IStreamingReporterPtr create( ReporterConfig const& config ) const = 0; + virtual std::string getDescription() const = 0; + }; + using IReporterFactoryPtr = std::shared_ptr; + + struct IReporterRegistry { + using FactoryMap = std::map; + using Listeners = std::vector; + + virtual ~IReporterRegistry(); + virtual IStreamingReporterPtr create( std::string const& name, IConfigPtr const& config ) const = 0; + virtual FactoryMap const& getFactories() const = 0; + virtual Listeners const& getListeners() const = 0; + }; + +} // end namespace Catch + +// end catch_interfaces_reporter.h +#include +#include +#include +#include +#include +#include +#include + +namespace Catch { + void prepareExpandedExpression(AssertionResult& result); + + // Returns double formatted as %.3f (format expected on output) + std::string getFormattedDuration( double duration ); + + template + struct StreamingReporterBase : IStreamingReporter { + + StreamingReporterBase( ReporterConfig const& _config ) + : m_config( _config.fullConfig() ), + stream( _config.stream() ) + { + m_reporterPrefs.shouldRedirectStdOut = false; + if( !DerivedT::getSupportedVerbosities().count( m_config->verbosity() ) ) + throw std::domain_error( "Verbosity level not supported by this reporter" ); + } + + ReporterPreferences getPreferences() const override { + return m_reporterPrefs; + } + + static std::set getSupportedVerbosities() { + return { Verbosity::Normal }; + } + + ~StreamingReporterBase() override = default; + + void noMatchingTestCases(std::string const&) override {} + + void testRunStarting(TestRunInfo const& _testRunInfo) override { + currentTestRunInfo = _testRunInfo; + } + void testGroupStarting(GroupInfo const& _groupInfo) override { + currentGroupInfo = _groupInfo; + } + + void testCaseStarting(TestCaseInfo const& _testInfo) override { + currentTestCaseInfo = _testInfo; + } + void sectionStarting(SectionInfo const& _sectionInfo) override { + m_sectionStack.push_back(_sectionInfo); + } + + void sectionEnded(SectionStats const& /* _sectionStats */) override { + m_sectionStack.pop_back(); + } + void testCaseEnded(TestCaseStats const& /* _testCaseStats */) override { + currentTestCaseInfo.reset(); + } + void testGroupEnded(TestGroupStats const& /* _testGroupStats */) override { + currentGroupInfo.reset(); + } + void testRunEnded(TestRunStats const& /* _testRunStats */) override { + currentTestCaseInfo.reset(); + currentGroupInfo.reset(); + currentTestRunInfo.reset(); + } + + void skipTest(TestCaseInfo const&) override { + // Don't do anything with this by default. + // It can optionally be overridden in the derived class. + } + + IConfigPtr m_config; + std::ostream& stream; + + LazyStat currentTestRunInfo; + LazyStat currentGroupInfo; + LazyStat currentTestCaseInfo; + + std::vector m_sectionStack; + ReporterPreferences m_reporterPrefs; + }; + + template + struct CumulativeReporterBase : IStreamingReporter { + template + struct Node { + explicit Node( T const& _value ) : value( _value ) {} + virtual ~Node() {} + + using ChildNodes = std::vector>; + T value; + ChildNodes children; + }; + struct SectionNode { + explicit SectionNode(SectionStats const& _stats) : stats(_stats) {} + virtual ~SectionNode() = default; + + bool operator == (SectionNode const& other) const { + return stats.sectionInfo.lineInfo == other.stats.sectionInfo.lineInfo; + } + bool operator == (std::shared_ptr const& other) const { + return operator==(*other); + } + + SectionStats stats; + using ChildSections = std::vector>; + using Assertions = std::vector; + ChildSections childSections; + Assertions assertions; + std::string stdOut; + std::string stdErr; + }; + + struct BySectionInfo { + BySectionInfo( SectionInfo const& other ) : m_other( other ) {} + BySectionInfo( BySectionInfo const& other ) : m_other( other.m_other ) {} + bool operator() (std::shared_ptr const& node) const { + return ((node->stats.sectionInfo.name == m_other.name) && + (node->stats.sectionInfo.lineInfo == m_other.lineInfo)); + } + void operator=(BySectionInfo const&) = delete; + + private: + SectionInfo const& m_other; + }; + + using TestCaseNode = Node; + using TestGroupNode = Node; + using TestRunNode = Node; + + CumulativeReporterBase( ReporterConfig const& _config ) + : m_config( _config.fullConfig() ), + stream( _config.stream() ) + { + m_reporterPrefs.shouldRedirectStdOut = false; + if( !DerivedT::getSupportedVerbosities().count( m_config->verbosity() ) ) + throw std::domain_error( "Verbosity level not supported by this reporter" ); + } + ~CumulativeReporterBase() override = default; + + ReporterPreferences getPreferences() const override { + return m_reporterPrefs; + } + + static std::set getSupportedVerbosities() { + return { Verbosity::Normal }; + } + + void testRunStarting( TestRunInfo const& ) override {} + void testGroupStarting( GroupInfo const& ) override {} + + void testCaseStarting( TestCaseInfo const& ) override {} + + void sectionStarting( SectionInfo const& sectionInfo ) override { + SectionStats incompleteStats( sectionInfo, Counts(), 0, false ); + std::shared_ptr node; + if( m_sectionStack.empty() ) { + if( !m_rootSection ) + m_rootSection = std::make_shared( incompleteStats ); + node = m_rootSection; + } + else { + SectionNode& parentNode = *m_sectionStack.back(); + auto it = + std::find_if( parentNode.childSections.begin(), + parentNode.childSections.end(), + BySectionInfo( sectionInfo ) ); + if( it == parentNode.childSections.end() ) { + node = std::make_shared( incompleteStats ); + parentNode.childSections.push_back( node ); + } + else + node = *it; + } + m_sectionStack.push_back( node ); + m_deepestSection = std::move(node); + } + + void assertionStarting(AssertionInfo const&) override {} + + bool assertionEnded(AssertionStats const& assertionStats) override { + assert(!m_sectionStack.empty()); + // AssertionResult holds a pointer to a temporary DecomposedExpression, + // which getExpandedExpression() calls to build the expression string. + // Our section stack copy of the assertionResult will likely outlive the + // temporary, so it must be expanded or discarded now to avoid calling + // a destroyed object later. + prepareExpandedExpression(const_cast( assertionStats.assertionResult ) ); + SectionNode& sectionNode = *m_sectionStack.back(); + sectionNode.assertions.push_back(assertionStats); + return true; + } + void sectionEnded(SectionStats const& sectionStats) override { + assert(!m_sectionStack.empty()); + SectionNode& node = *m_sectionStack.back(); + node.stats = sectionStats; + m_sectionStack.pop_back(); + } + void testCaseEnded(TestCaseStats const& testCaseStats) override { + auto node = std::make_shared(testCaseStats); + assert(m_sectionStack.size() == 0); + node->children.push_back(m_rootSection); + m_testCases.push_back(node); + m_rootSection.reset(); + + assert(m_deepestSection); + m_deepestSection->stdOut = testCaseStats.stdOut; + m_deepestSection->stdErr = testCaseStats.stdErr; + } + void testGroupEnded(TestGroupStats const& testGroupStats) override { + auto node = std::make_shared(testGroupStats); + node->children.swap(m_testCases); + m_testGroups.push_back(node); + } + void testRunEnded(TestRunStats const& testRunStats) override { + auto node = std::make_shared(testRunStats); + node->children.swap(m_testGroups); + m_testRuns.push_back(node); + testRunEndedCumulative(); + } + virtual void testRunEndedCumulative() = 0; + + void skipTest(TestCaseInfo const&) override {} + + IConfigPtr m_config; + std::ostream& stream; + std::vector m_assertions; + std::vector>> m_sections; + std::vector> m_testCases; + std::vector> m_testGroups; + + std::vector> m_testRuns; + + std::shared_ptr m_rootSection; + std::shared_ptr m_deepestSection; + std::vector> m_sectionStack; + ReporterPreferences m_reporterPrefs; + }; + + template + char const* getLineOfChars() { + static char line[CATCH_CONFIG_CONSOLE_WIDTH] = {0}; + if( !*line ) { + std::memset( line, C, CATCH_CONFIG_CONSOLE_WIDTH-1 ); + line[CATCH_CONFIG_CONSOLE_WIDTH-1] = 0; + } + return line; + } + + struct TestEventListenerBase : StreamingReporterBase { + TestEventListenerBase( ReporterConfig const& _config ); + + void assertionStarting(AssertionInfo const&) override; + bool assertionEnded(AssertionStats const&) override; + }; + +} // end namespace Catch + +// end catch_reporter_bases.hpp +// start catch_console_colour.h + +namespace Catch { + + struct Colour { + enum Code { + None = 0, + + White, + Red, + Green, + Blue, + Cyan, + Yellow, + Grey, + + Bright = 0x10, + + BrightRed = Bright | Red, + BrightGreen = Bright | Green, + LightGrey = Bright | Grey, + BrightWhite = Bright | White, + BrightYellow = Bright | Yellow, + + // By intention + FileName = LightGrey, + Warning = BrightYellow, + ResultError = BrightRed, + ResultSuccess = BrightGreen, + ResultExpectedFailure = Warning, + + Error = BrightRed, + Success = Green, + + OriginalExpression = Cyan, + ReconstructedExpression = BrightYellow, + + SecondaryText = LightGrey, + Headers = White + }; + + // Use constructed object for RAII guard + Colour( Code _colourCode ); + Colour( Colour&& other ) noexcept; + Colour& operator=( Colour&& other ) noexcept; + ~Colour(); + + // Use static method for one-shot changes + static void use( Code _colourCode ); + + private: + bool m_moved = false; + }; + + std::ostream& operator << ( std::ostream& os, Colour const& ); + +} // end namespace Catch + +// end catch_console_colour.h +// start catch_reporter_registrars.hpp + + +namespace Catch { + + template + class ReporterRegistrar { + + class ReporterFactory : public IReporterFactory { + + virtual IStreamingReporterPtr create( ReporterConfig const& config ) const override { + return std::unique_ptr( new T( config ) ); + } + + virtual std::string getDescription() const override { + return T::getDescription(); + } + }; + + public: + + explicit ReporterRegistrar( std::string const& name ) { + getMutableRegistryHub().registerReporter( name, std::make_shared() ); + } + }; + + template + class ListenerRegistrar { + + class ListenerFactory : public IReporterFactory { + + virtual IStreamingReporterPtr create( ReporterConfig const& config ) const override { + return std::unique_ptr( new T( config ) ); + } + virtual std::string getDescription() const override { + return std::string(); + } + }; + + public: + + ListenerRegistrar() { + getMutableRegistryHub().registerListener( std::make_shared() ); + } + }; +} + +#if !defined(CATCH_CONFIG_DISABLE) + +#define CATCH_REGISTER_REPORTER( name, reporterType ) \ + CATCH_INTERNAL_SUPPRESS_GLOBALS_WARNINGS \ + namespace{ Catch::ReporterRegistrar catch_internal_RegistrarFor##reporterType( name ); } \ + CATCH_INTERNAL_UNSUPPRESS_GLOBALS_WARNINGS + +#define CATCH_REGISTER_LISTENER( listenerType ) \ + CATCH_INTERNAL_SUPPRESS_GLOBALS_WARNINGS \ + namespace{ Catch::ListenerRegistrar catch_internal_RegistrarFor##listenerType; } \ + CATCH_INTERNAL_SUPPRESS_GLOBALS_WARNINGS +#else // CATCH_CONFIG_DISABLE + +#define CATCH_REGISTER_REPORTER(name, reporterType) +#define CATCH_REGISTER_LISTENER(listenerType) + +#endif // CATCH_CONFIG_DISABLE + +// end catch_reporter_registrars.hpp +// Allow users to base their work off existing reporters +// start catch_reporter_compact.h + +namespace Catch { + + struct CompactReporter : StreamingReporterBase { + + using StreamingReporterBase::StreamingReporterBase; + + ~CompactReporter() override; + + static std::string getDescription(); + + ReporterPreferences getPreferences() const override; + + void noMatchingTestCases(std::string const& spec) override; + + void assertionStarting(AssertionInfo const&) override; + + bool assertionEnded(AssertionStats const& _assertionStats) override; + + void sectionEnded(SectionStats const& _sectionStats) override; + + void testRunEnded(TestRunStats const& _testRunStats) override; + + }; + +} // end namespace Catch + +// end catch_reporter_compact.h +// start catch_reporter_console.h + +#if defined(_MSC_VER) +#pragma warning(push) +#pragma warning(disable:4061) // Not all labels are EXPLICITLY handled in switch + // Note that 4062 (not all labels are handled + // and default is missing) is enabled +#endif + +namespace Catch { + // Fwd decls + struct SummaryColumn; + class TablePrinter; + + struct ConsoleReporter : StreamingReporterBase { + std::unique_ptr m_tablePrinter; + + ConsoleReporter(ReporterConfig const& config); + ~ConsoleReporter() override; + static std::string getDescription(); + + void noMatchingTestCases(std::string const& spec) override; + + void assertionStarting(AssertionInfo const&) override; + + bool assertionEnded(AssertionStats const& _assertionStats) override; + + void sectionStarting(SectionInfo const& _sectionInfo) override; + void sectionEnded(SectionStats const& _sectionStats) override; + + void benchmarkStarting(BenchmarkInfo const& info) override; + void benchmarkEnded(BenchmarkStats const& stats) override; + + void testCaseEnded(TestCaseStats const& _testCaseStats) override; + void testGroupEnded(TestGroupStats const& _testGroupStats) override; + void testRunEnded(TestRunStats const& _testRunStats) override; + + private: + + void lazyPrint(); + + void lazyPrintWithoutClosingBenchmarkTable(); + void lazyPrintRunInfo(); + void lazyPrintGroupInfo(); + void printTestCaseAndSectionHeader(); + + void printClosedHeader(std::string const& _name); + void printOpenHeader(std::string const& _name); + + // if string has a : in first line will set indent to follow it on + // subsequent lines + void printHeaderString(std::string const& _string, std::size_t indent = 0); + + void printTotals(Totals const& totals); + void printSummaryRow(std::string const& label, std::vector const& cols, std::size_t row); + + void printTotalsDivider(Totals const& totals); + void printSummaryDivider(); + + private: + bool m_headerPrinted = false; + }; + +} // end namespace Catch + +#if defined(_MSC_VER) +#pragma warning(pop) +#endif + +// end catch_reporter_console.h +// start catch_reporter_junit.h + +// start catch_xmlwriter.h + +#include + +namespace Catch { + + class XmlEncode { + public: + enum ForWhat { ForTextNodes, ForAttributes }; + + XmlEncode( std::string const& str, ForWhat forWhat = ForTextNodes ); + + void encodeTo( std::ostream& os ) const; + + friend std::ostream& operator << ( std::ostream& os, XmlEncode const& xmlEncode ); + + private: + std::string m_str; + ForWhat m_forWhat; + }; + + class XmlWriter { + public: + + class ScopedElement { + public: + ScopedElement( XmlWriter* writer ); + + ScopedElement( ScopedElement&& other ) noexcept; + ScopedElement& operator=( ScopedElement&& other ) noexcept; + + ~ScopedElement(); + + ScopedElement& writeText( std::string const& text, bool indent = true ); + + template + ScopedElement& writeAttribute( std::string const& name, T const& attribute ) { + m_writer->writeAttribute( name, attribute ); + return *this; + } + + private: + mutable XmlWriter* m_writer = nullptr; + }; + + XmlWriter( std::ostream& os = Catch::cout() ); + ~XmlWriter(); + + XmlWriter( XmlWriter const& ) = delete; + XmlWriter& operator=( XmlWriter const& ) = delete; + + XmlWriter& startElement( std::string const& name ); + + ScopedElement scopedElement( std::string const& name ); + + XmlWriter& endElement(); + + XmlWriter& writeAttribute( std::string const& name, std::string const& attribute ); + + XmlWriter& writeAttribute( std::string const& name, bool attribute ); + + template + XmlWriter& writeAttribute( std::string const& name, T const& attribute ) { + ReusableStringStream rss; + rss << attribute; + return writeAttribute( name, rss.str() ); + } + + XmlWriter& writeText( std::string const& text, bool indent = true ); + + XmlWriter& writeComment( std::string const& text ); + + void writeStylesheetRef( std::string const& url ); + + XmlWriter& writeBlankLine(); + + void ensureTagClosed(); + + private: + + void writeDeclaration(); + + void newlineIfNecessary(); + + bool m_tagIsOpen = false; + bool m_needsNewline = false; + std::vector m_tags; + std::string m_indent; + std::ostream& m_os; + }; + +} + +// end catch_xmlwriter.h +namespace Catch { + + class JunitReporter : public CumulativeReporterBase { + public: + JunitReporter(ReporterConfig const& _config); + + ~JunitReporter() override; + + static std::string getDescription(); + + void noMatchingTestCases(std::string const& /*spec*/) override; + + void testRunStarting(TestRunInfo const& runInfo) override; + + void testGroupStarting(GroupInfo const& groupInfo) override; + + void testCaseStarting(TestCaseInfo const& testCaseInfo) override; + bool assertionEnded(AssertionStats const& assertionStats) override; + + void testCaseEnded(TestCaseStats const& testCaseStats) override; + + void testGroupEnded(TestGroupStats const& testGroupStats) override; + + void testRunEndedCumulative() override; + + void writeGroup(TestGroupNode const& groupNode, double suiteTime); + + void writeTestCase(TestCaseNode const& testCaseNode); + + void writeSection(std::string const& className, + std::string const& rootName, + SectionNode const& sectionNode); + + void writeAssertions(SectionNode const& sectionNode); + void writeAssertion(AssertionStats const& stats); + + XmlWriter xml; + Timer suiteTimer; + std::string stdOutForSuite; + std::string stdErrForSuite; + unsigned int unexpectedExceptions = 0; + bool m_okToFail = false; + }; + +} // end namespace Catch + +// end catch_reporter_junit.h +// start catch_reporter_xml.h + +namespace Catch { + class XmlReporter : public StreamingReporterBase { + public: + XmlReporter(ReporterConfig const& _config); + + ~XmlReporter() override; + + static std::string getDescription(); + + virtual std::string getStylesheetRef() const; + + void writeSourceInfo(SourceLineInfo const& sourceInfo); + + public: // StreamingReporterBase + + void noMatchingTestCases(std::string const& s) override; + + void testRunStarting(TestRunInfo const& testInfo) override; + + void testGroupStarting(GroupInfo const& groupInfo) override; + + void testCaseStarting(TestCaseInfo const& testInfo) override; + + void sectionStarting(SectionInfo const& sectionInfo) override; + + void assertionStarting(AssertionInfo const&) override; + + bool assertionEnded(AssertionStats const& assertionStats) override; + + void sectionEnded(SectionStats const& sectionStats) override; + + void testCaseEnded(TestCaseStats const& testCaseStats) override; + + void testGroupEnded(TestGroupStats const& testGroupStats) override; + + void testRunEnded(TestRunStats const& testRunStats) override; + + private: + Timer m_testCaseTimer; + XmlWriter m_xml; + int m_sectionDepth = 0; + }; + +} // end namespace Catch + +// end catch_reporter_xml.h + +// end catch_external_interfaces.h +#endif + +#endif // ! CATCH_CONFIG_IMPL_ONLY + +#ifdef CATCH_IMPL +// start catch_impl.hpp + +#ifdef __clang__ +#pragma clang diagnostic push +#pragma clang diagnostic ignored "-Wweak-vtables" +#endif + +// Keep these here for external reporters +// start catch_test_case_tracker.h + +#include +#include +#include + +namespace Catch { +namespace TestCaseTracking { + + struct NameAndLocation { + std::string name; + SourceLineInfo location; + + NameAndLocation( std::string const& _name, SourceLineInfo const& _location ); + }; + + struct ITracker; + + using ITrackerPtr = std::shared_ptr; + + struct ITracker { + virtual ~ITracker(); + + // static queries + virtual NameAndLocation const& nameAndLocation() const = 0; + + // dynamic queries + virtual bool isComplete() const = 0; // Successfully completed or failed + virtual bool isSuccessfullyCompleted() const = 0; + virtual bool isOpen() const = 0; // Started but not complete + virtual bool hasChildren() const = 0; + + virtual ITracker& parent() = 0; + + // actions + virtual void close() = 0; // Successfully complete + virtual void fail() = 0; + virtual void markAsNeedingAnotherRun() = 0; + + virtual void addChild( ITrackerPtr const& child ) = 0; + virtual ITrackerPtr findChild( NameAndLocation const& nameAndLocation ) = 0; + virtual void openChild() = 0; + + // Debug/ checking + virtual bool isSectionTracker() const = 0; + virtual bool isIndexTracker() const = 0; + }; + + class TrackerContext { + + enum RunState { + NotStarted, + Executing, + CompletedCycle + }; + + ITrackerPtr m_rootTracker; + ITracker* m_currentTracker = nullptr; + RunState m_runState = NotStarted; + + public: + + static TrackerContext& instance(); + + ITracker& startRun(); + void endRun(); + + void startCycle(); + void completeCycle(); + + bool completedCycle() const; + ITracker& currentTracker(); + void setCurrentTracker( ITracker* tracker ); + }; + + class TrackerBase : public ITracker { + protected: + enum CycleState { + NotStarted, + Executing, + ExecutingChildren, + NeedsAnotherRun, + CompletedSuccessfully, + Failed + }; + + class TrackerHasName { + NameAndLocation m_nameAndLocation; + public: + TrackerHasName( NameAndLocation const& nameAndLocation ); + bool operator ()( ITrackerPtr const& tracker ) const; + }; + + using Children = std::vector; + NameAndLocation m_nameAndLocation; + TrackerContext& m_ctx; + ITracker* m_parent; + Children m_children; + CycleState m_runState = NotStarted; + + public: + TrackerBase( NameAndLocation const& nameAndLocation, TrackerContext& ctx, ITracker* parent ); + + NameAndLocation const& nameAndLocation() const override; + bool isComplete() const override; + bool isSuccessfullyCompleted() const override; + bool isOpen() const override; + bool hasChildren() const override; + + void addChild( ITrackerPtr const& child ) override; + + ITrackerPtr findChild( NameAndLocation const& nameAndLocation ) override; + ITracker& parent() override; + + void openChild() override; + + bool isSectionTracker() const override; + bool isIndexTracker() const override; + + void open(); + + void close() override; + void fail() override; + void markAsNeedingAnotherRun() override; + + private: + void moveToParent(); + void moveToThis(); + }; + + class SectionTracker : public TrackerBase { + std::vector m_filters; + public: + SectionTracker( NameAndLocation const& nameAndLocation, TrackerContext& ctx, ITracker* parent ); + + bool isSectionTracker() const override; + + static SectionTracker& acquire( TrackerContext& ctx, NameAndLocation const& nameAndLocation ); + + void tryOpen(); + + void addInitialFilters( std::vector const& filters ); + void addNextFilters( std::vector const& filters ); + }; + + class IndexTracker : public TrackerBase { + int m_size; + int m_index = -1; + public: + IndexTracker( NameAndLocation const& nameAndLocation, TrackerContext& ctx, ITracker* parent, int size ); + + bool isIndexTracker() const override; + void close() override; + + static IndexTracker& acquire( TrackerContext& ctx, NameAndLocation const& nameAndLocation, int size ); + + int index() const; + + void moveNext(); + }; + +} // namespace TestCaseTracking + +using TestCaseTracking::ITracker; +using TestCaseTracking::TrackerContext; +using TestCaseTracking::SectionTracker; +using TestCaseTracking::IndexTracker; + +} // namespace Catch + +// end catch_test_case_tracker.h + +// start catch_leak_detector.h + +namespace Catch { + + struct LeakDetector { + LeakDetector(); + }; + +} +// end catch_leak_detector.h +// Cpp files will be included in the single-header file here +// start catch_approx.cpp + +#include +#include + +namespace { + +// Performs equivalent check of std::fabs(lhs - rhs) <= margin +// But without the subtraction to allow for INFINITY in comparison +bool marginComparison(double lhs, double rhs, double margin) { + return (lhs + margin >= rhs) && (rhs + margin >= lhs); +} + +} + +namespace Catch { +namespace Detail { + + Approx::Approx ( double value ) + : m_epsilon( std::numeric_limits::epsilon()*100 ), + m_margin( 0.0 ), + m_scale( 0.0 ), + m_value( value ) + {} + + Approx Approx::custom() { + return Approx( 0 ); + } + + Approx Approx::operator-() const { + auto temp(*this); + temp.m_value = -temp.m_value; + return temp; + } + + std::string Approx::toString() const { + ReusableStringStream rss; + rss << "Approx( " << ::Catch::Detail::stringify( m_value ) << " )"; + return rss.str(); + } + + bool Approx::equalityComparisonImpl(const double other) const { + // First try with fixed margin, then compute margin based on epsilon, scale and Approx's value + // Thanks to Richard Harris for his help refining the scaled margin value + return marginComparison(m_value, other, m_margin) || marginComparison(m_value, other, m_epsilon * (m_scale + std::fabs(m_value))); + } + +} // end namespace Detail + +namespace literals { + Detail::Approx operator "" _a(long double val) { + return Detail::Approx(val); + } + Detail::Approx operator "" _a(unsigned long long val) { + return Detail::Approx(val); + } +} // end namespace literals + +std::string StringMaker::convert(Catch::Detail::Approx const& value) { + return value.toString(); +} + +} // end namespace Catch +// end catch_approx.cpp +// start catch_assertionhandler.cpp + +// start catch_context.h + +#include + +namespace Catch { + + struct IResultCapture; + struct IRunner; + struct IConfig; + struct IMutableContext; + + using IConfigPtr = std::shared_ptr; + + struct IContext + { + virtual ~IContext(); + + virtual IResultCapture* getResultCapture() = 0; + virtual IRunner* getRunner() = 0; + virtual IConfigPtr const& getConfig() const = 0; + }; + + struct IMutableContext : IContext + { + virtual ~IMutableContext(); + virtual void setResultCapture( IResultCapture* resultCapture ) = 0; + virtual void setRunner( IRunner* runner ) = 0; + virtual void setConfig( IConfigPtr const& config ) = 0; + + private: + static IMutableContext *currentContext; + friend IMutableContext& getCurrentMutableContext(); + friend void cleanUpContext(); + static void createContext(); + }; + + inline IMutableContext& getCurrentMutableContext() + { + if( !IMutableContext::currentContext ) + IMutableContext::createContext(); + return *IMutableContext::currentContext; + } + + inline IContext& getCurrentContext() + { + return getCurrentMutableContext(); + } + + void cleanUpContext(); +} + +// end catch_context.h +// start catch_debugger.h + +namespace Catch { + bool isDebuggerActive(); +} + +#ifdef CATCH_PLATFORM_MAC + + #define CATCH_TRAP() __asm__("int $3\n" : : ) /* NOLINT */ + +#elif defined(CATCH_PLATFORM_LINUX) + // If we can use inline assembler, do it because this allows us to break + // directly at the location of the failing check instead of breaking inside + // raise() called from it, i.e. one stack frame below. + #if defined(__GNUC__) && (defined(__i386) || defined(__x86_64)) + #define CATCH_TRAP() asm volatile ("int $3") /* NOLINT */ + #else // Fall back to the generic way. + #include + + #define CATCH_TRAP() raise(SIGTRAP) + #endif +#elif defined(_MSC_VER) + #define CATCH_TRAP() __debugbreak() +#elif defined(__MINGW32__) + extern "C" __declspec(dllimport) void __stdcall DebugBreak(); + #define CATCH_TRAP() DebugBreak() +#endif + +#ifdef CATCH_TRAP + #define CATCH_BREAK_INTO_DEBUGGER() if( Catch::isDebuggerActive() ) { CATCH_TRAP(); } +#else + namespace Catch { + inline void doNothing() {} + } + #define CATCH_BREAK_INTO_DEBUGGER() Catch::doNothing() +#endif + +// end catch_debugger.h +// start catch_run_context.h + +// start catch_fatal_condition.h + +// start catch_windows_h_proxy.h + + +#if defined(CATCH_PLATFORM_WINDOWS) + +#if !defined(NOMINMAX) && !defined(CATCH_CONFIG_NO_NOMINMAX) +# define CATCH_DEFINED_NOMINMAX +# define NOMINMAX +#endif +#if !defined(WIN32_LEAN_AND_MEAN) && !defined(CATCH_CONFIG_NO_WIN32_LEAN_AND_MEAN) +# define CATCH_DEFINED_WIN32_LEAN_AND_MEAN +# define WIN32_LEAN_AND_MEAN +#endif + +#ifdef __AFXDLL +#include +#else +#include +#endif + +#ifdef CATCH_DEFINED_NOMINMAX +# undef NOMINMAX +#endif +#ifdef CATCH_DEFINED_WIN32_LEAN_AND_MEAN +# undef WIN32_LEAN_AND_MEAN +#endif + +#endif // defined(CATCH_PLATFORM_WINDOWS) + +// end catch_windows_h_proxy.h +#if defined( CATCH_CONFIG_WINDOWS_SEH ) + +namespace Catch { + + struct FatalConditionHandler { + + static LONG CALLBACK handleVectoredException(PEXCEPTION_POINTERS ExceptionInfo); + FatalConditionHandler(); + static void reset(); + ~FatalConditionHandler(); + + private: + static bool isSet; + static ULONG guaranteeSize; + static PVOID exceptionHandlerHandle; + }; + +} // namespace Catch + +#elif defined ( CATCH_CONFIG_POSIX_SIGNALS ) + +#include + +namespace Catch { + + struct FatalConditionHandler { + + static bool isSet; + static struct sigaction oldSigActions[]; + static stack_t oldSigStack; + static char altStackMem[]; + + static void handleSignal( int sig ); + + FatalConditionHandler(); + ~FatalConditionHandler(); + static void reset(); + }; + +} // namespace Catch + +#else + +namespace Catch { + struct FatalConditionHandler { + void reset(); + }; +} + +#endif + +// end catch_fatal_condition.h +#include + +namespace Catch { + + struct IMutableContext; + + /////////////////////////////////////////////////////////////////////////// + + class RunContext : public IResultCapture, public IRunner { + + public: + RunContext( RunContext const& ) = delete; + RunContext& operator =( RunContext const& ) = delete; + + explicit RunContext( IConfigPtr const& _config, IStreamingReporterPtr&& reporter ); + + ~RunContext() override; + + void testGroupStarting( std::string const& testSpec, std::size_t groupIndex, std::size_t groupsCount ); + void testGroupEnded( std::string const& testSpec, Totals const& totals, std::size_t groupIndex, std::size_t groupsCount ); + + Totals runTest(TestCase const& testCase); + + IConfigPtr config() const; + IStreamingReporter& reporter() const; + + public: // IResultCapture + + // Assertion handlers + void handleExpr + ( AssertionInfo const& info, + ITransientExpression const& expr, + AssertionReaction& reaction ) override; + void handleMessage + ( AssertionInfo const& info, + ResultWas::OfType resultType, + StringRef const& message, + AssertionReaction& reaction ) override; + void handleUnexpectedExceptionNotThrown + ( AssertionInfo const& info, + AssertionReaction& reaction ) override; + void handleUnexpectedInflightException + ( AssertionInfo const& info, + std::string const& message, + AssertionReaction& reaction ) override; + void handleIncomplete + ( AssertionInfo const& info ) override; + void handleNonExpr + ( AssertionInfo const &info, + ResultWas::OfType resultType, + AssertionReaction &reaction ) override; + + bool sectionStarted( SectionInfo const& sectionInfo, Counts& assertions ) override; + + void sectionEnded( SectionEndInfo const& endInfo ) override; + void sectionEndedEarly( SectionEndInfo const& endInfo ) override; + + void benchmarkStarting( BenchmarkInfo const& info ) override; + void benchmarkEnded( BenchmarkStats const& stats ) override; + + void pushScopedMessage( MessageInfo const& message ) override; + void popScopedMessage( MessageInfo const& message ) override; + + std::string getCurrentTestName() const override; + + const AssertionResult* getLastResult() const override; + + void exceptionEarlyReported() override; + + void handleFatalErrorCondition( StringRef message ) override; + + bool lastAssertionPassed() override; + + void assertionPassed() override; + + public: + // !TBD We need to do this another way! + bool aborting() const final; + + private: + + void runCurrentTest( std::string& redirectedCout, std::string& redirectedCerr ); + void invokeActiveTestCase(); + + void resetAssertionInfo(); + bool testForMissingAssertions( Counts& assertions ); + + void assertionEnded( AssertionResult const& result ); + void reportExpr + ( AssertionInfo const &info, + ResultWas::OfType resultType, + ITransientExpression const *expr, + bool negated ); + + void populateReaction( AssertionReaction& reaction ); + + private: + + void handleUnfinishedSections(); + + TestRunInfo m_runInfo; + IMutableContext& m_context; + TestCase const* m_activeTestCase = nullptr; + ITracker* m_testCaseTracker; + Option m_lastResult; + + IConfigPtr m_config; + Totals m_totals; + IStreamingReporterPtr m_reporter; + std::vector m_messages; + AssertionInfo m_lastAssertionInfo; + std::vector m_unfinishedSections; + std::vector m_activeSections; + TrackerContext m_trackerContext; + bool m_lastAssertionPassed = false; + bool m_shouldReportUnexpected = true; + bool m_includeSuccessfulResults; + }; + +} // end namespace Catch + +// end catch_run_context.h +namespace Catch { + + namespace { + auto operator <<( std::ostream& os, ITransientExpression const& expr ) -> std::ostream& { + expr.streamReconstructedExpression( os ); + return os; + } + } + + LazyExpression::LazyExpression( bool isNegated ) + : m_isNegated( isNegated ) + {} + + LazyExpression::LazyExpression( LazyExpression const& other ) : m_isNegated( other.m_isNegated ) {} + + LazyExpression::operator bool() const { + return m_transientExpression != nullptr; + } + + auto operator << ( std::ostream& os, LazyExpression const& lazyExpr ) -> std::ostream& { + if( lazyExpr.m_isNegated ) + os << "!"; + + if( lazyExpr ) { + if( lazyExpr.m_isNegated && lazyExpr.m_transientExpression->isBinaryExpression() ) + os << "(" << *lazyExpr.m_transientExpression << ")"; + else + os << *lazyExpr.m_transientExpression; + } + else { + os << "{** error - unchecked empty expression requested **}"; + } + return os; + } + + AssertionHandler::AssertionHandler + ( StringRef macroName, + SourceLineInfo const& lineInfo, + StringRef capturedExpression, + ResultDisposition::Flags resultDisposition ) + : m_assertionInfo{ macroName, lineInfo, capturedExpression, resultDisposition }, + m_resultCapture( getResultCapture() ) + {} + + void AssertionHandler::handleExpr( ITransientExpression const& expr ) { + m_resultCapture.handleExpr( m_assertionInfo, expr, m_reaction ); + } + void AssertionHandler::handleMessage(ResultWas::OfType resultType, StringRef const& message) { + m_resultCapture.handleMessage( m_assertionInfo, resultType, message, m_reaction ); + } + + auto AssertionHandler::allowThrows() const -> bool { + return getCurrentContext().getConfig()->allowThrows(); + } + + void AssertionHandler::complete() { + setCompleted(); + if( m_reaction.shouldDebugBreak ) { + + // If you find your debugger stopping you here then go one level up on the + // call-stack for the code that caused it (typically a failed assertion) + + // (To go back to the test and change execution, jump over the throw, next) + CATCH_BREAK_INTO_DEBUGGER(); + } + if( m_reaction.shouldThrow ) + throw Catch::TestFailureException(); + } + void AssertionHandler::setCompleted() { + m_completed = true; + } + + void AssertionHandler::handleUnexpectedInflightException() { + m_resultCapture.handleUnexpectedInflightException( m_assertionInfo, Catch::translateActiveException(), m_reaction ); + } + + void AssertionHandler::handleExceptionThrownAsExpected() { + m_resultCapture.handleNonExpr(m_assertionInfo, ResultWas::Ok, m_reaction); + } + void AssertionHandler::handleExceptionNotThrownAsExpected() { + m_resultCapture.handleNonExpr(m_assertionInfo, ResultWas::Ok, m_reaction); + } + + void AssertionHandler::handleUnexpectedExceptionNotThrown() { + m_resultCapture.handleUnexpectedExceptionNotThrown( m_assertionInfo, m_reaction ); + } + + void AssertionHandler::handleThrowingCallSkipped() { + m_resultCapture.handleNonExpr(m_assertionInfo, ResultWas::Ok, m_reaction); + } + + // This is the overload that takes a string and infers the Equals matcher from it + // The more general overload, that takes any string matcher, is in catch_capture_matchers.cpp + void handleExceptionMatchExpr( AssertionHandler& handler, std::string const& str, StringRef matcherString ) { + handleExceptionMatchExpr( handler, Matchers::Equals( str ), matcherString ); + } + +} // namespace Catch +// end catch_assertionhandler.cpp +// start catch_assertionresult.cpp + +namespace Catch { + AssertionResultData::AssertionResultData(ResultWas::OfType _resultType, LazyExpression const & _lazyExpression): + lazyExpression(_lazyExpression), + resultType(_resultType) {} + + std::string AssertionResultData::reconstructExpression() const { + + if( reconstructedExpression.empty() ) { + if( lazyExpression ) { + ReusableStringStream rss; + rss << lazyExpression; + reconstructedExpression = rss.str(); + } + } + return reconstructedExpression; + } + + AssertionResult::AssertionResult( AssertionInfo const& info, AssertionResultData const& data ) + : m_info( info ), + m_resultData( data ) + {} + + // Result was a success + bool AssertionResult::succeeded() const { + return Catch::isOk( m_resultData.resultType ); + } + + // Result was a success, or failure is suppressed + bool AssertionResult::isOk() const { + return Catch::isOk( m_resultData.resultType ) || shouldSuppressFailure( m_info.resultDisposition ); + } + + ResultWas::OfType AssertionResult::getResultType() const { + return m_resultData.resultType; + } + + bool AssertionResult::hasExpression() const { + return m_info.capturedExpression[0] != 0; + } + + bool AssertionResult::hasMessage() const { + return !m_resultData.message.empty(); + } + + std::string AssertionResult::getExpression() const { + if( isFalseTest( m_info.resultDisposition ) ) + return "!(" + m_info.capturedExpression + ")"; + else + return m_info.capturedExpression; + } + + std::string AssertionResult::getExpressionInMacro() const { + std::string expr; + if( m_info.macroName[0] == 0 ) + expr = m_info.capturedExpression; + else { + expr.reserve( m_info.macroName.size() + m_info.capturedExpression.size() + 4 ); + expr += m_info.macroName; + expr += "( "; + expr += m_info.capturedExpression; + expr += " )"; + } + return expr; + } + + bool AssertionResult::hasExpandedExpression() const { + return hasExpression() && getExpandedExpression() != getExpression(); + } + + std::string AssertionResult::getExpandedExpression() const { + std::string expr = m_resultData.reconstructExpression(); + return expr.empty() + ? getExpression() + : expr; + } + + std::string AssertionResult::getMessage() const { + return m_resultData.message; + } + SourceLineInfo AssertionResult::getSourceInfo() const { + return m_info.lineInfo; + } + + StringRef AssertionResult::getTestMacroName() const { + return m_info.macroName; + } + +} // end namespace Catch +// end catch_assertionresult.cpp +// start catch_benchmark.cpp + +namespace Catch { + + auto BenchmarkLooper::getResolution() -> uint64_t { + return getEstimatedClockResolution() * getCurrentContext().getConfig()->benchmarkResolutionMultiple(); + } + + void BenchmarkLooper::reportStart() { + getResultCapture().benchmarkStarting( { m_name } ); + } + auto BenchmarkLooper::needsMoreIterations() -> bool { + auto elapsed = m_timer.getElapsedNanoseconds(); + + // Exponentially increasing iterations until we're confident in our timer resolution + if( elapsed < m_resolution ) { + m_iterationsToRun *= 10; + return true; + } + + getResultCapture().benchmarkEnded( { { m_name }, m_count, elapsed } ); + return false; + } + +} // end namespace Catch +// end catch_benchmark.cpp +// start catch_capture_matchers.cpp + +namespace Catch { + + using StringMatcher = Matchers::Impl::MatcherBase; + + // This is the general overload that takes a any string matcher + // There is another overload, in catch_assertionhandler.h/.cpp, that only takes a string and infers + // the Equals matcher (so the header does not mention matchers) + void handleExceptionMatchExpr( AssertionHandler& handler, StringMatcher const& matcher, StringRef matcherString ) { + std::string exceptionMessage = Catch::translateActiveException(); + MatchExpr expr( exceptionMessage, matcher, matcherString ); + handler.handleExpr( expr ); + } + +} // namespace Catch +// end catch_capture_matchers.cpp +// start catch_commandline.cpp + +// start catch_commandline.h + +// start catch_clara.h + +// Use Catch's value for console width (store Clara's off to the side, if present) +#ifdef CLARA_CONFIG_CONSOLE_WIDTH +#define CATCH_TEMP_CLARA_CONFIG_CONSOLE_WIDTH CATCH_CLARA_TEXTFLOW_CONFIG_CONSOLE_WIDTH +#undef CATCH_CLARA_TEXTFLOW_CONFIG_CONSOLE_WIDTH +#endif +#define CATCH_CLARA_TEXTFLOW_CONFIG_CONSOLE_WIDTH CATCH_CONFIG_CONSOLE_WIDTH-1 + +#ifdef __clang__ +#pragma clang diagnostic push +#pragma clang diagnostic ignored "-Wweak-vtables" +#pragma clang diagnostic ignored "-Wexit-time-destructors" +#pragma clang diagnostic ignored "-Wshadow" +#endif + +// start clara.hpp +// Copyright 2017 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) +// +// See https://github.com/philsquared/Clara for more details + +// Clara v1.1.4 + + +#ifndef CATCH_CLARA_CONFIG_CONSOLE_WIDTH +#define CATCH_CLARA_CONFIG_CONSOLE_WIDTH 80 +#endif + +#ifndef CATCH_CLARA_TEXTFLOW_CONFIG_CONSOLE_WIDTH +#define CATCH_CLARA_TEXTFLOW_CONFIG_CONSOLE_WIDTH CATCH_CLARA_CONFIG_CONSOLE_WIDTH +#endif + +#ifndef CLARA_CONFIG_OPTIONAL_TYPE +#ifdef __has_include +#if __has_include() && __cplusplus >= 201703L +#include +#define CLARA_CONFIG_OPTIONAL_TYPE std::optional +#endif +#endif +#endif + +// ----------- #included from clara_textflow.hpp ----------- + +// TextFlowCpp +// +// A single-header library for wrapping and laying out basic text, by Phil Nash +// +// This work is licensed under the BSD 2-Clause license. +// See the accompanying LICENSE file, or the one at https://opensource.org/licenses/BSD-2-Clause +// +// This project is hosted at https://github.com/philsquared/textflowcpp + + +#include +#include +#include +#include + +#ifndef CATCH_CLARA_TEXTFLOW_CONFIG_CONSOLE_WIDTH +#define CATCH_CLARA_TEXTFLOW_CONFIG_CONSOLE_WIDTH 80 +#endif + +namespace Catch { namespace clara { namespace TextFlow { + + inline auto isWhitespace( char c ) -> bool { + static std::string chars = " \t\n\r"; + return chars.find( c ) != std::string::npos; + } + inline auto isBreakableBefore( char c ) -> bool { + static std::string chars = "[({<|"; + return chars.find( c ) != std::string::npos; + } + inline auto isBreakableAfter( char c ) -> bool { + static std::string chars = "])}>.,:;*+-=&/\\"; + return chars.find( c ) != std::string::npos; + } + + class Columns; + + class Column { + std::vector m_strings; + size_t m_width = CATCH_CLARA_TEXTFLOW_CONFIG_CONSOLE_WIDTH; + size_t m_indent = 0; + size_t m_initialIndent = std::string::npos; + + public: + class iterator { + friend Column; + + Column const& m_column; + size_t m_stringIndex = 0; + size_t m_pos = 0; + + size_t m_len = 0; + size_t m_end = 0; + bool m_suffix = false; + + iterator( Column const& column, size_t stringIndex ) + : m_column( column ), + m_stringIndex( stringIndex ) + {} + + auto line() const -> std::string const& { return m_column.m_strings[m_stringIndex]; } + + auto isBoundary( size_t at ) const -> bool { + assert( at > 0 ); + assert( at <= line().size() ); + + return at == line().size() || + ( isWhitespace( line()[at] ) && !isWhitespace( line()[at-1] ) ) || + isBreakableBefore( line()[at] ) || + isBreakableAfter( line()[at-1] ); + } + + void calcLength() { + assert( m_stringIndex < m_column.m_strings.size() ); + + m_suffix = false; + auto width = m_column.m_width-indent(); + m_end = m_pos; + while( m_end < line().size() && line()[m_end] != '\n' ) + ++m_end; + + if( m_end < m_pos + width ) { + m_len = m_end - m_pos; + } + else { + size_t len = width; + while (len > 0 && !isBoundary(m_pos + len)) + --len; + while (len > 0 && isWhitespace( line()[m_pos + len - 1] )) + --len; + + if (len > 0) { + m_len = len; + } else { + m_suffix = true; + m_len = width - 1; + } + } + } + + auto indent() const -> size_t { + auto initial = m_pos == 0 && m_stringIndex == 0 ? m_column.m_initialIndent : std::string::npos; + return initial == std::string::npos ? m_column.m_indent : initial; + } + + auto addIndentAndSuffix(std::string const &plain) const -> std::string { + return std::string( indent(), ' ' ) + (m_suffix ? plain + "-" : plain); + } + + public: + explicit iterator( Column const& column ) : m_column( column ) { + assert( m_column.m_width > m_column.m_indent ); + assert( m_column.m_initialIndent == std::string::npos || m_column.m_width > m_column.m_initialIndent ); + calcLength(); + if( m_len == 0 ) + m_stringIndex++; // Empty string + } + + auto operator *() const -> std::string { + assert( m_stringIndex < m_column.m_strings.size() ); + assert( m_pos <= m_end ); + if( m_pos + m_column.m_width < m_end ) + return addIndentAndSuffix(line().substr(m_pos, m_len)); + else + return addIndentAndSuffix(line().substr(m_pos, m_end - m_pos)); + } + + auto operator ++() -> iterator& { + m_pos += m_len; + if( m_pos < line().size() && line()[m_pos] == '\n' ) + m_pos += 1; + else + while( m_pos < line().size() && isWhitespace( line()[m_pos] ) ) + ++m_pos; + + if( m_pos == line().size() ) { + m_pos = 0; + ++m_stringIndex; + } + if( m_stringIndex < m_column.m_strings.size() ) + calcLength(); + return *this; + } + auto operator ++(int) -> iterator { + iterator prev( *this ); + operator++(); + return prev; + } + + auto operator ==( iterator const& other ) const -> bool { + return + m_pos == other.m_pos && + m_stringIndex == other.m_stringIndex && + &m_column == &other.m_column; + } + auto operator !=( iterator const& other ) const -> bool { + return !operator==( other ); + } + }; + using const_iterator = iterator; + + explicit Column( std::string const& text ) { m_strings.push_back( text ); } + + auto width( size_t newWidth ) -> Column& { + assert( newWidth > 0 ); + m_width = newWidth; + return *this; + } + auto indent( size_t newIndent ) -> Column& { + m_indent = newIndent; + return *this; + } + auto initialIndent( size_t newIndent ) -> Column& { + m_initialIndent = newIndent; + return *this; + } + + auto width() const -> size_t { return m_width; } + auto begin() const -> iterator { return iterator( *this ); } + auto end() const -> iterator { return { *this, m_strings.size() }; } + + inline friend std::ostream& operator << ( std::ostream& os, Column const& col ) { + bool first = true; + for( auto line : col ) { + if( first ) + first = false; + else + os << "\n"; + os << line; + } + return os; + } + + auto operator + ( Column const& other ) -> Columns; + + auto toString() const -> std::string { + std::ostringstream oss; + oss << *this; + return oss.str(); + } + }; + + class Spacer : public Column { + + public: + explicit Spacer( size_t spaceWidth ) : Column( "" ) { + width( spaceWidth ); + } + }; + + class Columns { + std::vector m_columns; + + public: + + class iterator { + friend Columns; + struct EndTag {}; + + std::vector const& m_columns; + std::vector m_iterators; + size_t m_activeIterators; + + iterator( Columns const& columns, EndTag ) + : m_columns( columns.m_columns ), + m_activeIterators( 0 ) + { + m_iterators.reserve( m_columns.size() ); + + for( auto const& col : m_columns ) + m_iterators.push_back( col.end() ); + } + + public: + explicit iterator( Columns const& columns ) + : m_columns( columns.m_columns ), + m_activeIterators( m_columns.size() ) + { + m_iterators.reserve( m_columns.size() ); + + for( auto const& col : m_columns ) + m_iterators.push_back( col.begin() ); + } + + auto operator ==( iterator const& other ) const -> bool { + return m_iterators == other.m_iterators; + } + auto operator !=( iterator const& other ) const -> bool { + return m_iterators != other.m_iterators; + } + auto operator *() const -> std::string { + std::string row, padding; + + for( size_t i = 0; i < m_columns.size(); ++i ) { + auto width = m_columns[i].width(); + if( m_iterators[i] != m_columns[i].end() ) { + std::string col = *m_iterators[i]; + row += padding + col; + if( col.size() < width ) + padding = std::string( width - col.size(), ' ' ); + else + padding = ""; + } + else { + padding += std::string( width, ' ' ); + } + } + return row; + } + auto operator ++() -> iterator& { + for( size_t i = 0; i < m_columns.size(); ++i ) { + if (m_iterators[i] != m_columns[i].end()) + ++m_iterators[i]; + } + return *this; + } + auto operator ++(int) -> iterator { + iterator prev( *this ); + operator++(); + return prev; + } + }; + using const_iterator = iterator; + + auto begin() const -> iterator { return iterator( *this ); } + auto end() const -> iterator { return { *this, iterator::EndTag() }; } + + auto operator += ( Column const& col ) -> Columns& { + m_columns.push_back( col ); + return *this; + } + auto operator + ( Column const& col ) -> Columns { + Columns combined = *this; + combined += col; + return combined; + } + + inline friend std::ostream& operator << ( std::ostream& os, Columns const& cols ) { + + bool first = true; + for( auto line : cols ) { + if( first ) + first = false; + else + os << "\n"; + os << line; + } + return os; + } + + auto toString() const -> std::string { + std::ostringstream oss; + oss << *this; + return oss.str(); + } + }; + + inline auto Column::operator + ( Column const& other ) -> Columns { + Columns cols; + cols += *this; + cols += other; + return cols; + } +}}} // namespace Catch::clara::TextFlow + +// ----------- end of #include from clara_textflow.hpp ----------- +// ........... back in clara.hpp + +#include +#include +#include + +#if !defined(CATCH_PLATFORM_WINDOWS) && ( defined(WIN32) || defined(__WIN32__) || defined(_WIN32) || defined(_MSC_VER) ) +#define CATCH_PLATFORM_WINDOWS +#endif + +namespace Catch { namespace clara { +namespace detail { + + // Traits for extracting arg and return type of lambdas (for single argument lambdas) + template + struct UnaryLambdaTraits : UnaryLambdaTraits {}; + + template + struct UnaryLambdaTraits { + static const bool isValid = false; + }; + + template + struct UnaryLambdaTraits { + static const bool isValid = true; + using ArgType = typename std::remove_const::type>::type; + using ReturnType = ReturnT; + }; + + class TokenStream; + + // Transport for raw args (copied from main args, or supplied via init list for testing) + class Args { + friend TokenStream; + std::string m_exeName; + std::vector m_args; + + public: + Args( int argc, char const* const* argv ) + : m_exeName(argv[0]), + m_args(argv + 1, argv + argc) {} + + Args( std::initializer_list args ) + : m_exeName( *args.begin() ), + m_args( args.begin()+1, args.end() ) + {} + + auto exeName() const -> std::string { + return m_exeName; + } + }; + + // Wraps a token coming from a token stream. These may not directly correspond to strings as a single string + // may encode an option + its argument if the : or = form is used + enum class TokenType { + Option, Argument + }; + struct Token { + TokenType type; + std::string token; + }; + + inline auto isOptPrefix( char c ) -> bool { + return c == '-' +#ifdef CATCH_PLATFORM_WINDOWS + || c == '/' +#endif + ; + } + + // Abstracts iterators into args as a stream of tokens, with option arguments uniformly handled + class TokenStream { + using Iterator = std::vector::const_iterator; + Iterator it; + Iterator itEnd; + std::vector m_tokenBuffer; + + void loadBuffer() { + m_tokenBuffer.resize( 0 ); + + // Skip any empty strings + while( it != itEnd && it->empty() ) + ++it; + + if( it != itEnd ) { + auto const &next = *it; + if( isOptPrefix( next[0] ) ) { + auto delimiterPos = next.find_first_of( " :=" ); + if( delimiterPos != std::string::npos ) { + m_tokenBuffer.push_back( { TokenType::Option, next.substr( 0, delimiterPos ) } ); + m_tokenBuffer.push_back( { TokenType::Argument, next.substr( delimiterPos + 1 ) } ); + } else { + if( next[1] != '-' && next.size() > 2 ) { + std::string opt = "- "; + for( size_t i = 1; i < next.size(); ++i ) { + opt[1] = next[i]; + m_tokenBuffer.push_back( { TokenType::Option, opt } ); + } + } else { + m_tokenBuffer.push_back( { TokenType::Option, next } ); + } + } + } else { + m_tokenBuffer.push_back( { TokenType::Argument, next } ); + } + } + } + + public: + explicit TokenStream( Args const &args ) : TokenStream( args.m_args.begin(), args.m_args.end() ) {} + + TokenStream( Iterator it, Iterator itEnd ) : it( it ), itEnd( itEnd ) { + loadBuffer(); + } + + explicit operator bool() const { + return !m_tokenBuffer.empty() || it != itEnd; + } + + auto count() const -> size_t { return m_tokenBuffer.size() + (itEnd - it); } + + auto operator*() const -> Token { + assert( !m_tokenBuffer.empty() ); + return m_tokenBuffer.front(); + } + + auto operator->() const -> Token const * { + assert( !m_tokenBuffer.empty() ); + return &m_tokenBuffer.front(); + } + + auto operator++() -> TokenStream & { + if( m_tokenBuffer.size() >= 2 ) { + m_tokenBuffer.erase( m_tokenBuffer.begin() ); + } else { + if( it != itEnd ) + ++it; + loadBuffer(); + } + return *this; + } + }; + + class ResultBase { + public: + enum Type { + Ok, LogicError, RuntimeError + }; + + protected: + ResultBase( Type type ) : m_type( type ) {} + virtual ~ResultBase() = default; + + virtual void enforceOk() const = 0; + + Type m_type; + }; + + template + class ResultValueBase : public ResultBase { + public: + auto value() const -> T const & { + enforceOk(); + return m_value; + } + + protected: + ResultValueBase( Type type ) : ResultBase( type ) {} + + ResultValueBase( ResultValueBase const &other ) : ResultBase( other ) { + if( m_type == ResultBase::Ok ) + new( &m_value ) T( other.m_value ); + } + + ResultValueBase( Type, T const &value ) : ResultBase( Ok ) { + new( &m_value ) T( value ); + } + + auto operator=( ResultValueBase const &other ) -> ResultValueBase & { + if( m_type == ResultBase::Ok ) + m_value.~T(); + ResultBase::operator=(other); + if( m_type == ResultBase::Ok ) + new( &m_value ) T( other.m_value ); + return *this; + } + + ~ResultValueBase() override { + if( m_type == Ok ) + m_value.~T(); + } + + union { + T m_value; + }; + }; + + template<> + class ResultValueBase : public ResultBase { + protected: + using ResultBase::ResultBase; + }; + + template + class BasicResult : public ResultValueBase { + public: + template + explicit BasicResult( BasicResult const &other ) + : ResultValueBase( other.type() ), + m_errorMessage( other.errorMessage() ) + { + assert( type() != ResultBase::Ok ); + } + + template + static auto ok( U const &value ) -> BasicResult { return { ResultBase::Ok, value }; } + static auto ok() -> BasicResult { return { ResultBase::Ok }; } + static auto logicError( std::string const &message ) -> BasicResult { return { ResultBase::LogicError, message }; } + static auto runtimeError( std::string const &message ) -> BasicResult { return { ResultBase::RuntimeError, message }; } + + explicit operator bool() const { return m_type == ResultBase::Ok; } + auto type() const -> ResultBase::Type { return m_type; } + auto errorMessage() const -> std::string { return m_errorMessage; } + + protected: + void enforceOk() const override { + + // Errors shouldn't reach this point, but if they do + // the actual error message will be in m_errorMessage + assert( m_type != ResultBase::LogicError ); + assert( m_type != ResultBase::RuntimeError ); + if( m_type != ResultBase::Ok ) + std::abort(); + } + + std::string m_errorMessage; // Only populated if resultType is an error + + BasicResult( ResultBase::Type type, std::string const &message ) + : ResultValueBase(type), + m_errorMessage(message) + { + assert( m_type != ResultBase::Ok ); + } + + using ResultValueBase::ResultValueBase; + using ResultBase::m_type; + }; + + enum class ParseResultType { + Matched, NoMatch, ShortCircuitAll, ShortCircuitSame + }; + + class ParseState { + public: + + ParseState( ParseResultType type, TokenStream const &remainingTokens ) + : m_type(type), + m_remainingTokens( remainingTokens ) + {} + + auto type() const -> ParseResultType { return m_type; } + auto remainingTokens() const -> TokenStream { return m_remainingTokens; } + + private: + ParseResultType m_type; + TokenStream m_remainingTokens; + }; + + using Result = BasicResult; + using ParserResult = BasicResult; + using InternalParseResult = BasicResult; + + struct HelpColumns { + std::string left; + std::string right; + }; + + template + inline auto convertInto( std::string const &source, T& target ) -> ParserResult { + std::stringstream ss; + ss << source; + ss >> target; + if( ss.fail() ) + return ParserResult::runtimeError( "Unable to convert '" + source + "' to destination type" ); + else + return ParserResult::ok( ParseResultType::Matched ); + } + inline auto convertInto( std::string const &source, std::string& target ) -> ParserResult { + target = source; + return ParserResult::ok( ParseResultType::Matched ); + } + inline auto convertInto( std::string const &source, bool &target ) -> ParserResult { + std::string srcLC = source; + std::transform( srcLC.begin(), srcLC.end(), srcLC.begin(), []( char c ) { return static_cast( ::tolower(c) ); } ); + if (srcLC == "y" || srcLC == "1" || srcLC == "true" || srcLC == "yes" || srcLC == "on") + target = true; + else if (srcLC == "n" || srcLC == "0" || srcLC == "false" || srcLC == "no" || srcLC == "off") + target = false; + else + return ParserResult::runtimeError( "Expected a boolean value but did not recognise: '" + source + "'" ); + return ParserResult::ok( ParseResultType::Matched ); + } +#ifdef CLARA_CONFIG_OPTIONAL_TYPE + template + inline auto convertInto( std::string const &source, CLARA_CONFIG_OPTIONAL_TYPE& target ) -> ParserResult { + T temp; + auto result = convertInto( source, temp ); + if( result ) + target = std::move(temp); + return result; + } +#endif // CLARA_CONFIG_OPTIONAL_TYPE + + struct NonCopyable { + NonCopyable() = default; + NonCopyable( NonCopyable const & ) = delete; + NonCopyable( NonCopyable && ) = delete; + NonCopyable &operator=( NonCopyable const & ) = delete; + NonCopyable &operator=( NonCopyable && ) = delete; + }; + + struct BoundRef : NonCopyable { + virtual ~BoundRef() = default; + virtual auto isContainer() const -> bool { return false; } + virtual auto isFlag() const -> bool { return false; } + }; + struct BoundValueRefBase : BoundRef { + virtual auto setValue( std::string const &arg ) -> ParserResult = 0; + }; + struct BoundFlagRefBase : BoundRef { + virtual auto setFlag( bool flag ) -> ParserResult = 0; + virtual auto isFlag() const -> bool { return true; } + }; + + template + struct BoundValueRef : BoundValueRefBase { + T &m_ref; + + explicit BoundValueRef( T &ref ) : m_ref( ref ) {} + + auto setValue( std::string const &arg ) -> ParserResult override { + return convertInto( arg, m_ref ); + } + }; + + template + struct BoundValueRef> : BoundValueRefBase { + std::vector &m_ref; + + explicit BoundValueRef( std::vector &ref ) : m_ref( ref ) {} + + auto isContainer() const -> bool override { return true; } + + auto setValue( std::string const &arg ) -> ParserResult override { + T temp; + auto result = convertInto( arg, temp ); + if( result ) + m_ref.push_back( temp ); + return result; + } + }; + + struct BoundFlagRef : BoundFlagRefBase { + bool &m_ref; + + explicit BoundFlagRef( bool &ref ) : m_ref( ref ) {} + + auto setFlag( bool flag ) -> ParserResult override { + m_ref = flag; + return ParserResult::ok( ParseResultType::Matched ); + } + }; + + template + struct LambdaInvoker { + static_assert( std::is_same::value, "Lambda must return void or clara::ParserResult" ); + + template + static auto invoke( L const &lambda, ArgType const &arg ) -> ParserResult { + return lambda( arg ); + } + }; + + template<> + struct LambdaInvoker { + template + static auto invoke( L const &lambda, ArgType const &arg ) -> ParserResult { + lambda( arg ); + return ParserResult::ok( ParseResultType::Matched ); + } + }; + + template + inline auto invokeLambda( L const &lambda, std::string const &arg ) -> ParserResult { + ArgType temp{}; + auto result = convertInto( arg, temp ); + return !result + ? result + : LambdaInvoker::ReturnType>::invoke( lambda, temp ); + } + + template + struct BoundLambda : BoundValueRefBase { + L m_lambda; + + static_assert( UnaryLambdaTraits::isValid, "Supplied lambda must take exactly one argument" ); + explicit BoundLambda( L const &lambda ) : m_lambda( lambda ) {} + + auto setValue( std::string const &arg ) -> ParserResult override { + return invokeLambda::ArgType>( m_lambda, arg ); + } + }; + + template + struct BoundFlagLambda : BoundFlagRefBase { + L m_lambda; + + static_assert( UnaryLambdaTraits::isValid, "Supplied lambda must take exactly one argument" ); + static_assert( std::is_same::ArgType, bool>::value, "flags must be boolean" ); + + explicit BoundFlagLambda( L const &lambda ) : m_lambda( lambda ) {} + + auto setFlag( bool flag ) -> ParserResult override { + return LambdaInvoker::ReturnType>::invoke( m_lambda, flag ); + } + }; + + enum class Optionality { Optional, Required }; + + struct Parser; + + class ParserBase { + public: + virtual ~ParserBase() = default; + virtual auto validate() const -> Result { return Result::ok(); } + virtual auto parse( std::string const& exeName, TokenStream const &tokens) const -> InternalParseResult = 0; + virtual auto cardinality() const -> size_t { return 1; } + + auto parse( Args const &args ) const -> InternalParseResult { + return parse( args.exeName(), TokenStream( args ) ); + } + }; + + template + class ComposableParserImpl : public ParserBase { + public: + template + auto operator|( T const &other ) const -> Parser; + + template + auto operator+( T const &other ) const -> Parser; + }; + + // Common code and state for Args and Opts + template + class ParserRefImpl : public ComposableParserImpl { + protected: + Optionality m_optionality = Optionality::Optional; + std::shared_ptr m_ref; + std::string m_hint; + std::string m_description; + + explicit ParserRefImpl( std::shared_ptr const &ref ) : m_ref( ref ) {} + + public: + template + ParserRefImpl( T &ref, std::string const &hint ) + : m_ref( std::make_shared>( ref ) ), + m_hint( hint ) + {} + + template + ParserRefImpl( LambdaT const &ref, std::string const &hint ) + : m_ref( std::make_shared>( ref ) ), + m_hint(hint) + {} + + auto operator()( std::string const &description ) -> DerivedT & { + m_description = description; + return static_cast( *this ); + } + + auto optional() -> DerivedT & { + m_optionality = Optionality::Optional; + return static_cast( *this ); + }; + + auto required() -> DerivedT & { + m_optionality = Optionality::Required; + return static_cast( *this ); + }; + + auto isOptional() const -> bool { + return m_optionality == Optionality::Optional; + } + + auto cardinality() const -> size_t override { + if( m_ref->isContainer() ) + return 0; + else + return 1; + } + + auto hint() const -> std::string { return m_hint; } + }; + + class ExeName : public ComposableParserImpl { + std::shared_ptr m_name; + std::shared_ptr m_ref; + + template + static auto makeRef(LambdaT const &lambda) -> std::shared_ptr { + return std::make_shared>( lambda) ; + } + + public: + ExeName() : m_name( std::make_shared( "" ) ) {} + + explicit ExeName( std::string &ref ) : ExeName() { + m_ref = std::make_shared>( ref ); + } + + template + explicit ExeName( LambdaT const& lambda ) : ExeName() { + m_ref = std::make_shared>( lambda ); + } + + // The exe name is not parsed out of the normal tokens, but is handled specially + auto parse( std::string const&, TokenStream const &tokens ) const -> InternalParseResult override { + return InternalParseResult::ok( ParseState( ParseResultType::NoMatch, tokens ) ); + } + + auto name() const -> std::string { return *m_name; } + auto set( std::string const& newName ) -> ParserResult { + + auto lastSlash = newName.find_last_of( "\\/" ); + auto filename = ( lastSlash == std::string::npos ) + ? newName + : newName.substr( lastSlash+1 ); + + *m_name = filename; + if( m_ref ) + return m_ref->setValue( filename ); + else + return ParserResult::ok( ParseResultType::Matched ); + } + }; + + class Arg : public ParserRefImpl { + public: + using ParserRefImpl::ParserRefImpl; + + auto parse( std::string const &, TokenStream const &tokens ) const -> InternalParseResult override { + auto validationResult = validate(); + if( !validationResult ) + return InternalParseResult( validationResult ); + + auto remainingTokens = tokens; + auto const &token = *remainingTokens; + if( token.type != TokenType::Argument ) + return InternalParseResult::ok( ParseState( ParseResultType::NoMatch, remainingTokens ) ); + + assert( !m_ref->isFlag() ); + auto valueRef = static_cast( m_ref.get() ); + + auto result = valueRef->setValue( remainingTokens->token ); + if( !result ) + return InternalParseResult( result ); + else + return InternalParseResult::ok( ParseState( ParseResultType::Matched, ++remainingTokens ) ); + } + }; + + inline auto normaliseOpt( std::string const &optName ) -> std::string { +#ifdef CATCH_PLATFORM_WINDOWS + if( optName[0] == '/' ) + return "-" + optName.substr( 1 ); + else +#endif + return optName; + } + + class Opt : public ParserRefImpl { + protected: + std::vector m_optNames; + + public: + template + explicit Opt( LambdaT const &ref ) : ParserRefImpl( std::make_shared>( ref ) ) {} + + explicit Opt( bool &ref ) : ParserRefImpl( std::make_shared( ref ) ) {} + + template + Opt( LambdaT const &ref, std::string const &hint ) : ParserRefImpl( ref, hint ) {} + + template + Opt( T &ref, std::string const &hint ) : ParserRefImpl( ref, hint ) {} + + auto operator[]( std::string const &optName ) -> Opt & { + m_optNames.push_back( optName ); + return *this; + } + + auto getHelpColumns() const -> std::vector { + std::ostringstream oss; + bool first = true; + for( auto const &opt : m_optNames ) { + if (first) + first = false; + else + oss << ", "; + oss << opt; + } + if( !m_hint.empty() ) + oss << " <" << m_hint << ">"; + return { { oss.str(), m_description } }; + } + + auto isMatch( std::string const &optToken ) const -> bool { + auto normalisedToken = normaliseOpt( optToken ); + for( auto const &name : m_optNames ) { + if( normaliseOpt( name ) == normalisedToken ) + return true; + } + return false; + } + + using ParserBase::parse; + + auto parse( std::string const&, TokenStream const &tokens ) const -> InternalParseResult override { + auto validationResult = validate(); + if( !validationResult ) + return InternalParseResult( validationResult ); + + auto remainingTokens = tokens; + if( remainingTokens && remainingTokens->type == TokenType::Option ) { + auto const &token = *remainingTokens; + if( isMatch(token.token ) ) { + if( m_ref->isFlag() ) { + auto flagRef = static_cast( m_ref.get() ); + auto result = flagRef->setFlag( true ); + if( !result ) + return InternalParseResult( result ); + if( result.value() == ParseResultType::ShortCircuitAll ) + return InternalParseResult::ok( ParseState( result.value(), remainingTokens ) ); + } else { + auto valueRef = static_cast( m_ref.get() ); + ++remainingTokens; + if( !remainingTokens ) + return InternalParseResult::runtimeError( "Expected argument following " + token.token ); + auto const &argToken = *remainingTokens; + if( argToken.type != TokenType::Argument ) + return InternalParseResult::runtimeError( "Expected argument following " + token.token ); + auto result = valueRef->setValue( argToken.token ); + if( !result ) + return InternalParseResult( result ); + if( result.value() == ParseResultType::ShortCircuitAll ) + return InternalParseResult::ok( ParseState( result.value(), remainingTokens ) ); + } + return InternalParseResult::ok( ParseState( ParseResultType::Matched, ++remainingTokens ) ); + } + } + return InternalParseResult::ok( ParseState( ParseResultType::NoMatch, remainingTokens ) ); + } + + auto validate() const -> Result override { + if( m_optNames.empty() ) + return Result::logicError( "No options supplied to Opt" ); + for( auto const &name : m_optNames ) { + if( name.empty() ) + return Result::logicError( "Option name cannot be empty" ); +#ifdef CATCH_PLATFORM_WINDOWS + if( name[0] != '-' && name[0] != '/' ) + return Result::logicError( "Option name must begin with '-' or '/'" ); +#else + if( name[0] != '-' ) + return Result::logicError( "Option name must begin with '-'" ); +#endif + } + return ParserRefImpl::validate(); + } + }; + + struct Help : Opt { + Help( bool &showHelpFlag ) + : Opt([&]( bool flag ) { + showHelpFlag = flag; + return ParserResult::ok( ParseResultType::ShortCircuitAll ); + }) + { + static_cast( *this ) + ("display usage information") + ["-?"]["-h"]["--help"] + .optional(); + } + }; + + struct Parser : ParserBase { + + mutable ExeName m_exeName; + std::vector m_options; + std::vector m_args; + + auto operator|=( ExeName const &exeName ) -> Parser & { + m_exeName = exeName; + return *this; + } + + auto operator|=( Arg const &arg ) -> Parser & { + m_args.push_back(arg); + return *this; + } + + auto operator|=( Opt const &opt ) -> Parser & { + m_options.push_back(opt); + return *this; + } + + auto operator|=( Parser const &other ) -> Parser & { + m_options.insert(m_options.end(), other.m_options.begin(), other.m_options.end()); + m_args.insert(m_args.end(), other.m_args.begin(), other.m_args.end()); + return *this; + } + + template + auto operator|( T const &other ) const -> Parser { + return Parser( *this ) |= other; + } + + // Forward deprecated interface with '+' instead of '|' + template + auto operator+=( T const &other ) -> Parser & { return operator|=( other ); } + template + auto operator+( T const &other ) const -> Parser { return operator|( other ); } + + auto getHelpColumns() const -> std::vector { + std::vector cols; + for (auto const &o : m_options) { + auto childCols = o.getHelpColumns(); + cols.insert( cols.end(), childCols.begin(), childCols.end() ); + } + return cols; + } + + void writeToStream( std::ostream &os ) const { + if (!m_exeName.name().empty()) { + os << "usage:\n" << " " << m_exeName.name() << " "; + bool required = true, first = true; + for( auto const &arg : m_args ) { + if (first) + first = false; + else + os << " "; + if( arg.isOptional() && required ) { + os << "["; + required = false; + } + os << "<" << arg.hint() << ">"; + if( arg.cardinality() == 0 ) + os << " ... "; + } + if( !required ) + os << "]"; + if( !m_options.empty() ) + os << " options"; + os << "\n\nwhere options are:" << std::endl; + } + + auto rows = getHelpColumns(); + size_t consoleWidth = CATCH_CLARA_CONFIG_CONSOLE_WIDTH; + size_t optWidth = 0; + for( auto const &cols : rows ) + optWidth = (std::max)(optWidth, cols.left.size() + 2); + + optWidth = (std::min)(optWidth, consoleWidth/2); + + for( auto const &cols : rows ) { + auto row = + TextFlow::Column( cols.left ).width( optWidth ).indent( 2 ) + + TextFlow::Spacer(4) + + TextFlow::Column( cols.right ).width( consoleWidth - 7 - optWidth ); + os << row << std::endl; + } + } + + friend auto operator<<( std::ostream &os, Parser const &parser ) -> std::ostream& { + parser.writeToStream( os ); + return os; + } + + auto validate() const -> Result override { + for( auto const &opt : m_options ) { + auto result = opt.validate(); + if( !result ) + return result; + } + for( auto const &arg : m_args ) { + auto result = arg.validate(); + if( !result ) + return result; + } + return Result::ok(); + } + + using ParserBase::parse; + + auto parse( std::string const& exeName, TokenStream const &tokens ) const -> InternalParseResult override { + + struct ParserInfo { + ParserBase const* parser = nullptr; + size_t count = 0; + }; + const size_t totalParsers = m_options.size() + m_args.size(); + assert( totalParsers < 512 ); + // ParserInfo parseInfos[totalParsers]; // <-- this is what we really want to do + ParserInfo parseInfos[512]; + + { + size_t i = 0; + for (auto const &opt : m_options) parseInfos[i++].parser = &opt; + for (auto const &arg : m_args) parseInfos[i++].parser = &arg; + } + + m_exeName.set( exeName ); + + auto result = InternalParseResult::ok( ParseState( ParseResultType::NoMatch, tokens ) ); + while( result.value().remainingTokens() ) { + bool tokenParsed = false; + + for( size_t i = 0; i < totalParsers; ++i ) { + auto& parseInfo = parseInfos[i]; + if( parseInfo.parser->cardinality() == 0 || parseInfo.count < parseInfo.parser->cardinality() ) { + result = parseInfo.parser->parse(exeName, result.value().remainingTokens()); + if (!result) + return result; + if (result.value().type() != ParseResultType::NoMatch) { + tokenParsed = true; + ++parseInfo.count; + break; + } + } + } + + if( result.value().type() == ParseResultType::ShortCircuitAll ) + return result; + if( !tokenParsed ) + return InternalParseResult::runtimeError( "Unrecognised token: " + result.value().remainingTokens()->token ); + } + // !TBD Check missing required options + return result; + } + }; + + template + template + auto ComposableParserImpl::operator|( T const &other ) const -> Parser { + return Parser() | static_cast( *this ) | other; + } +} // namespace detail + +// A Combined parser +using detail::Parser; + +// A parser for options +using detail::Opt; + +// A parser for arguments +using detail::Arg; + +// Wrapper for argc, argv from main() +using detail::Args; + +// Specifies the name of the executable +using detail::ExeName; + +// Convenience wrapper for option parser that specifies the help option +using detail::Help; + +// enum of result types from a parse +using detail::ParseResultType; + +// Result type for parser operation +using detail::ParserResult; + +}} // namespace Catch::clara + +// end clara.hpp +#ifdef __clang__ +#pragma clang diagnostic pop +#endif + +// Restore Clara's value for console width, if present +#ifdef CATCH_TEMP_CLARA_CONFIG_CONSOLE_WIDTH +#define CATCH_CLARA_TEXTFLOW_CONFIG_CONSOLE_WIDTH CATCH_TEMP_CLARA_CONFIG_CONSOLE_WIDTH +#undef CATCH_TEMP_CLARA_CONFIG_CONSOLE_WIDTH +#endif + +// end catch_clara.h +namespace Catch { + + clara::Parser makeCommandLineParser( ConfigData& config ); + +} // end namespace Catch + +// end catch_commandline.h +#include +#include + +namespace Catch { + + clara::Parser makeCommandLineParser( ConfigData& config ) { + + using namespace clara; + + auto const setWarning = [&]( std::string const& warning ) { + auto warningSet = [&]() { + if( warning == "NoAssertions" ) + return WarnAbout::NoAssertions; + + if ( warning == "NoTests" ) + return WarnAbout::NoTests; + + return WarnAbout::Nothing; + }(); + + if (warningSet == WarnAbout::Nothing) + return ParserResult::runtimeError( "Unrecognised warning: '" + warning + "'" ); + config.warnings = static_cast( config.warnings | warningSet ); + return ParserResult::ok( ParseResultType::Matched ); + }; + auto const loadTestNamesFromFile = [&]( std::string const& filename ) { + std::ifstream f( filename.c_str() ); + if( !f.is_open() ) + return ParserResult::runtimeError( "Unable to load input file: '" + filename + "'" ); + + std::string line; + while( std::getline( f, line ) ) { + line = trim(line); + if( !line.empty() && !startsWith( line, '#' ) ) { + if( !startsWith( line, '"' ) ) + line = '"' + line + '"'; + config.testsOrTags.push_back( line + ',' ); + } + } + return ParserResult::ok( ParseResultType::Matched ); + }; + auto const setTestOrder = [&]( std::string const& order ) { + if( startsWith( "declared", order ) ) + config.runOrder = RunTests::InDeclarationOrder; + else if( startsWith( "lexical", order ) ) + config.runOrder = RunTests::InLexicographicalOrder; + else if( startsWith( "random", order ) ) + config.runOrder = RunTests::InRandomOrder; + else + return clara::ParserResult::runtimeError( "Unrecognised ordering: '" + order + "'" ); + return ParserResult::ok( ParseResultType::Matched ); + }; + auto const setRngSeed = [&]( std::string const& seed ) { + if( seed != "time" ) + return clara::detail::convertInto( seed, config.rngSeed ); + config.rngSeed = static_cast( std::time(nullptr) ); + return ParserResult::ok( ParseResultType::Matched ); + }; + auto const setColourUsage = [&]( std::string const& useColour ) { + auto mode = toLower( useColour ); + + if( mode == "yes" ) + config.useColour = UseColour::Yes; + else if( mode == "no" ) + config.useColour = UseColour::No; + else if( mode == "auto" ) + config.useColour = UseColour::Auto; + else + return ParserResult::runtimeError( "colour mode must be one of: auto, yes or no. '" + useColour + "' not recognised" ); + return ParserResult::ok( ParseResultType::Matched ); + }; + auto const setWaitForKeypress = [&]( std::string const& keypress ) { + auto keypressLc = toLower( keypress ); + if( keypressLc == "start" ) + config.waitForKeypress = WaitForKeypress::BeforeStart; + else if( keypressLc == "exit" ) + config.waitForKeypress = WaitForKeypress::BeforeExit; + else if( keypressLc == "both" ) + config.waitForKeypress = WaitForKeypress::BeforeStartAndExit; + else + return ParserResult::runtimeError( "keypress argument must be one of: start, exit or both. '" + keypress + "' not recognised" ); + return ParserResult::ok( ParseResultType::Matched ); + }; + auto const setVerbosity = [&]( std::string const& verbosity ) { + auto lcVerbosity = toLower( verbosity ); + if( lcVerbosity == "quiet" ) + config.verbosity = Verbosity::Quiet; + else if( lcVerbosity == "normal" ) + config.verbosity = Verbosity::Normal; + else if( lcVerbosity == "high" ) + config.verbosity = Verbosity::High; + else + return ParserResult::runtimeError( "Unrecognised verbosity, '" + verbosity + "'" ); + return ParserResult::ok( ParseResultType::Matched ); + }; + + auto cli + = ExeName( config.processName ) + | Help( config.showHelp ) + | Opt( config.listTests ) + ["-l"]["--list-tests"] + ( "list all/matching test cases" ) + | Opt( config.listTags ) + ["-t"]["--list-tags"] + ( "list all/matching tags" ) + | Opt( config.showSuccessfulTests ) + ["-s"]["--success"] + ( "include successful tests in output" ) + | Opt( config.shouldDebugBreak ) + ["-b"]["--break"] + ( "break into debugger on failure" ) + | Opt( config.noThrow ) + ["-e"]["--nothrow"] + ( "skip exception tests" ) + | Opt( config.showInvisibles ) + ["-i"]["--invisibles"] + ( "show invisibles (tabs, newlines)" ) + | Opt( config.outputFilename, "filename" ) + ["-o"]["--out"] + ( "output filename" ) + | Opt( config.reporterName, "name" ) + ["-r"]["--reporter"] + ( "reporter to use (defaults to console)" ) + | Opt( config.name, "name" ) + ["-n"]["--name"] + ( "suite name" ) + | Opt( [&]( bool ){ config.abortAfter = 1; } ) + ["-a"]["--abort"] + ( "abort at first failure" ) + | Opt( [&]( int x ){ config.abortAfter = x; }, "no. failures" ) + ["-x"]["--abortx"] + ( "abort after x failures" ) + | Opt( setWarning, "warning name" ) + ["-w"]["--warn"] + ( "enable warnings" ) + | Opt( [&]( bool flag ) { config.showDurations = flag ? ShowDurations::Always : ShowDurations::Never; }, "yes|no" ) + ["-d"]["--durations"] + ( "show test durations" ) + | Opt( loadTestNamesFromFile, "filename" ) + ["-f"]["--input-file"] + ( "load test names to run from a file" ) + | Opt( config.filenamesAsTags ) + ["-#"]["--filenames-as-tags"] + ( "adds a tag for the filename" ) + | Opt( config.sectionsToRun, "section name" ) + ["-c"]["--section"] + ( "specify section to run" ) + | Opt( setVerbosity, "quiet|normal|high" ) + ["-v"]["--verbosity"] + ( "set output verbosity" ) + | Opt( config.listTestNamesOnly ) + ["--list-test-names-only"] + ( "list all/matching test cases names only" ) + | Opt( config.listReporters ) + ["--list-reporters"] + ( "list all reporters" ) + | Opt( setTestOrder, "decl|lex|rand" ) + ["--order"] + ( "test case order (defaults to decl)" ) + | Opt( setRngSeed, "'time'|number" ) + ["--rng-seed"] + ( "set a specific seed for random numbers" ) + | Opt( setColourUsage, "yes|no" ) + ["--use-colour"] + ( "should output be colourised" ) + | Opt( config.libIdentify ) + ["--libidentify"] + ( "report name and version according to libidentify standard" ) + | Opt( setWaitForKeypress, "start|exit|both" ) + ["--wait-for-keypress"] + ( "waits for a keypress before exiting" ) + | Opt( config.benchmarkResolutionMultiple, "multiplier" ) + ["--benchmark-resolution-multiple"] + ( "multiple of clock resolution to run benchmarks" ) + + | Arg( config.testsOrTags, "test name|pattern|tags" ) + ( "which test or tests to use" ); + + return cli; + } + +} // end namespace Catch +// end catch_commandline.cpp +// start catch_common.cpp + +#include +#include + +namespace Catch { + + bool SourceLineInfo::empty() const noexcept { + return file[0] == '\0'; + } + bool SourceLineInfo::operator == ( SourceLineInfo const& other ) const noexcept { + return line == other.line && (file == other.file || std::strcmp(file, other.file) == 0); + } + bool SourceLineInfo::operator < ( SourceLineInfo const& other ) const noexcept { + return line < other.line || ( line == other.line && (std::strcmp(file, other.file) < 0)); + } + + std::ostream& operator << ( std::ostream& os, SourceLineInfo const& info ) { +#ifndef __GNUG__ + os << info.file << '(' << info.line << ')'; +#else + os << info.file << ':' << info.line; +#endif + return os; + } + + std::string StreamEndStop::operator+() const { + return std::string(); + } + + NonCopyable::NonCopyable() = default; + NonCopyable::~NonCopyable() = default; + +} +// end catch_common.cpp +// start catch_config.cpp + +// start catch_enforce.h + +#include + +#define CATCH_PREPARE_EXCEPTION( type, msg ) \ + type( ( Catch::ReusableStringStream() << msg ).str() ) +#define CATCH_INTERNAL_ERROR( msg ) \ + throw CATCH_PREPARE_EXCEPTION( std::logic_error, CATCH_INTERNAL_LINEINFO << ": Internal Catch error: " << msg); +#define CATCH_ERROR( msg ) \ + throw CATCH_PREPARE_EXCEPTION( std::domain_error, msg ) +#define CATCH_ENFORCE( condition, msg ) \ + do{ if( !(condition) ) CATCH_ERROR( msg ); } while(false) + +// end catch_enforce.h +namespace Catch { + + Config::Config( ConfigData const& data ) + : m_data( data ), + m_stream( openStream() ) + { + TestSpecParser parser(ITagAliasRegistry::get()); + if (data.testsOrTags.empty()) { + parser.parse("~[.]"); // All not hidden tests + } + else { + m_hasTestFilters = true; + for( auto const& testOrTags : data.testsOrTags ) + parser.parse( testOrTags ); + } + m_testSpec = parser.testSpec(); + } + + std::string const& Config::getFilename() const { + return m_data.outputFilename ; + } + + bool Config::listTests() const { return m_data.listTests; } + bool Config::listTestNamesOnly() const { return m_data.listTestNamesOnly; } + bool Config::listTags() const { return m_data.listTags; } + bool Config::listReporters() const { return m_data.listReporters; } + + std::string Config::getProcessName() const { return m_data.processName; } + std::string const& Config::getReporterName() const { return m_data.reporterName; } + + std::vector const& Config::getTestsOrTags() const { return m_data.testsOrTags; } + std::vector const& Config::getSectionsToRun() const { return m_data.sectionsToRun; } + + TestSpec const& Config::testSpec() const { return m_testSpec; } + bool Config::hasTestFilters() const { return m_hasTestFilters; } + + bool Config::showHelp() const { return m_data.showHelp; } + + // IConfig interface + bool Config::allowThrows() const { return !m_data.noThrow; } + std::ostream& Config::stream() const { return m_stream->stream(); } + std::string Config::name() const { return m_data.name.empty() ? m_data.processName : m_data.name; } + bool Config::includeSuccessfulResults() const { return m_data.showSuccessfulTests; } + bool Config::warnAboutMissingAssertions() const { return !!(m_data.warnings & WarnAbout::NoAssertions); } + bool Config::warnAboutNoTests() const { return !!(m_data.warnings & WarnAbout::NoTests); } + ShowDurations::OrNot Config::showDurations() const { return m_data.showDurations; } + RunTests::InWhatOrder Config::runOrder() const { return m_data.runOrder; } + unsigned int Config::rngSeed() const { return m_data.rngSeed; } + int Config::benchmarkResolutionMultiple() const { return m_data.benchmarkResolutionMultiple; } + UseColour::YesOrNo Config::useColour() const { return m_data.useColour; } + bool Config::shouldDebugBreak() const { return m_data.shouldDebugBreak; } + int Config::abortAfter() const { return m_data.abortAfter; } + bool Config::showInvisibles() const { return m_data.showInvisibles; } + Verbosity Config::verbosity() const { return m_data.verbosity; } + + IStream const* Config::openStream() { + return Catch::makeStream(m_data.outputFilename); + } + +} // end namespace Catch +// end catch_config.cpp +// start catch_console_colour.cpp + +#if defined(__clang__) +# pragma clang diagnostic push +# pragma clang diagnostic ignored "-Wexit-time-destructors" +#endif + +// start catch_errno_guard.h + +namespace Catch { + + class ErrnoGuard { + public: + ErrnoGuard(); + ~ErrnoGuard(); + private: + int m_oldErrno; + }; + +} + +// end catch_errno_guard.h +#include + +namespace Catch { + namespace { + + struct IColourImpl { + virtual ~IColourImpl() = default; + virtual void use( Colour::Code _colourCode ) = 0; + }; + + struct NoColourImpl : IColourImpl { + void use( Colour::Code ) {} + + static IColourImpl* instance() { + static NoColourImpl s_instance; + return &s_instance; + } + }; + + } // anon namespace +} // namespace Catch + +#if !defined( CATCH_CONFIG_COLOUR_NONE ) && !defined( CATCH_CONFIG_COLOUR_WINDOWS ) && !defined( CATCH_CONFIG_COLOUR_ANSI ) +# ifdef CATCH_PLATFORM_WINDOWS +# define CATCH_CONFIG_COLOUR_WINDOWS +# else +# define CATCH_CONFIG_COLOUR_ANSI +# endif +#endif + +#if defined ( CATCH_CONFIG_COLOUR_WINDOWS ) ///////////////////////////////////////// + +namespace Catch { +namespace { + + class Win32ColourImpl : public IColourImpl { + public: + Win32ColourImpl() : stdoutHandle( GetStdHandle(STD_OUTPUT_HANDLE) ) + { + CONSOLE_SCREEN_BUFFER_INFO csbiInfo; + GetConsoleScreenBufferInfo( stdoutHandle, &csbiInfo ); + originalForegroundAttributes = csbiInfo.wAttributes & ~( BACKGROUND_GREEN | BACKGROUND_RED | BACKGROUND_BLUE | BACKGROUND_INTENSITY ); + originalBackgroundAttributes = csbiInfo.wAttributes & ~( FOREGROUND_GREEN | FOREGROUND_RED | FOREGROUND_BLUE | FOREGROUND_INTENSITY ); + } + + virtual void use( Colour::Code _colourCode ) override { + switch( _colourCode ) { + case Colour::None: return setTextAttribute( originalForegroundAttributes ); + case Colour::White: return setTextAttribute( FOREGROUND_GREEN | FOREGROUND_RED | FOREGROUND_BLUE ); + case Colour::Red: return setTextAttribute( FOREGROUND_RED ); + case Colour::Green: return setTextAttribute( FOREGROUND_GREEN ); + case Colour::Blue: return setTextAttribute( FOREGROUND_BLUE ); + case Colour::Cyan: return setTextAttribute( FOREGROUND_BLUE | FOREGROUND_GREEN ); + case Colour::Yellow: return setTextAttribute( FOREGROUND_RED | FOREGROUND_GREEN ); + case Colour::Grey: return setTextAttribute( 0 ); + + case Colour::LightGrey: return setTextAttribute( FOREGROUND_INTENSITY ); + case Colour::BrightRed: return setTextAttribute( FOREGROUND_INTENSITY | FOREGROUND_RED ); + case Colour::BrightGreen: return setTextAttribute( FOREGROUND_INTENSITY | FOREGROUND_GREEN ); + case Colour::BrightWhite: return setTextAttribute( FOREGROUND_INTENSITY | FOREGROUND_GREEN | FOREGROUND_RED | FOREGROUND_BLUE ); + case Colour::BrightYellow: return setTextAttribute( FOREGROUND_INTENSITY | FOREGROUND_RED | FOREGROUND_GREEN ); + + case Colour::Bright: CATCH_INTERNAL_ERROR( "not a colour" ); + + default: + CATCH_ERROR( "Unknown colour requested" ); + } + } + + private: + void setTextAttribute( WORD _textAttribute ) { + SetConsoleTextAttribute( stdoutHandle, _textAttribute | originalBackgroundAttributes ); + } + HANDLE stdoutHandle; + WORD originalForegroundAttributes; + WORD originalBackgroundAttributes; + }; + + IColourImpl* platformColourInstance() { + static Win32ColourImpl s_instance; + + IConfigPtr config = getCurrentContext().getConfig(); + UseColour::YesOrNo colourMode = config + ? config->useColour() + : UseColour::Auto; + if( colourMode == UseColour::Auto ) + colourMode = UseColour::Yes; + return colourMode == UseColour::Yes + ? &s_instance + : NoColourImpl::instance(); + } + +} // end anon namespace +} // end namespace Catch + +#elif defined( CATCH_CONFIG_COLOUR_ANSI ) ////////////////////////////////////// + +#include + +namespace Catch { +namespace { + + // use POSIX/ ANSI console terminal codes + // Thanks to Adam Strzelecki for original contribution + // (http://github.com/nanoant) + // https://github.com/philsquared/Catch/pull/131 + class PosixColourImpl : public IColourImpl { + public: + virtual void use( Colour::Code _colourCode ) override { + switch( _colourCode ) { + case Colour::None: + case Colour::White: return setColour( "[0m" ); + case Colour::Red: return setColour( "[0;31m" ); + case Colour::Green: return setColour( "[0;32m" ); + case Colour::Blue: return setColour( "[0;34m" ); + case Colour::Cyan: return setColour( "[0;36m" ); + case Colour::Yellow: return setColour( "[0;33m" ); + case Colour::Grey: return setColour( "[1;30m" ); + + case Colour::LightGrey: return setColour( "[0;37m" ); + case Colour::BrightRed: return setColour( "[1;31m" ); + case Colour::BrightGreen: return setColour( "[1;32m" ); + case Colour::BrightWhite: return setColour( "[1;37m" ); + case Colour::BrightYellow: return setColour( "[1;33m" ); + + case Colour::Bright: CATCH_INTERNAL_ERROR( "not a colour" ); + default: CATCH_INTERNAL_ERROR( "Unknown colour requested" ); + } + } + static IColourImpl* instance() { + static PosixColourImpl s_instance; + return &s_instance; + } + + private: + void setColour( const char* _escapeCode ) { + Catch::cout() << '\033' << _escapeCode; + } + }; + + bool useColourOnPlatform() { + return +#ifdef CATCH_PLATFORM_MAC + !isDebuggerActive() && +#endif +#if !(defined(__DJGPP__) && defined(__STRICT_ANSI__)) + isatty(STDOUT_FILENO) +#else + false +#endif + ; + } + IColourImpl* platformColourInstance() { + ErrnoGuard guard; + IConfigPtr config = getCurrentContext().getConfig(); + UseColour::YesOrNo colourMode = config + ? config->useColour() + : UseColour::Auto; + if( colourMode == UseColour::Auto ) + colourMode = useColourOnPlatform() + ? UseColour::Yes + : UseColour::No; + return colourMode == UseColour::Yes + ? PosixColourImpl::instance() + : NoColourImpl::instance(); + } + +} // end anon namespace +} // end namespace Catch + +#else // not Windows or ANSI /////////////////////////////////////////////// + +namespace Catch { + + static IColourImpl* platformColourInstance() { return NoColourImpl::instance(); } + +} // end namespace Catch + +#endif // Windows/ ANSI/ None + +namespace Catch { + + Colour::Colour( Code _colourCode ) { use( _colourCode ); } + Colour::Colour( Colour&& rhs ) noexcept { + m_moved = rhs.m_moved; + rhs.m_moved = true; + } + Colour& Colour::operator=( Colour&& rhs ) noexcept { + m_moved = rhs.m_moved; + rhs.m_moved = true; + return *this; + } + + Colour::~Colour(){ if( !m_moved ) use( None ); } + + void Colour::use( Code _colourCode ) { + static IColourImpl* impl = platformColourInstance(); + impl->use( _colourCode ); + } + + std::ostream& operator << ( std::ostream& os, Colour const& ) { + return os; + } + +} // end namespace Catch + +#if defined(__clang__) +# pragma clang diagnostic pop +#endif + +// end catch_console_colour.cpp +// start catch_context.cpp + +namespace Catch { + + class Context : public IMutableContext, NonCopyable { + + public: // IContext + virtual IResultCapture* getResultCapture() override { + return m_resultCapture; + } + virtual IRunner* getRunner() override { + return m_runner; + } + + virtual IConfigPtr const& getConfig() const override { + return m_config; + } + + virtual ~Context() override; + + public: // IMutableContext + virtual void setResultCapture( IResultCapture* resultCapture ) override { + m_resultCapture = resultCapture; + } + virtual void setRunner( IRunner* runner ) override { + m_runner = runner; + } + virtual void setConfig( IConfigPtr const& config ) override { + m_config = config; + } + + friend IMutableContext& getCurrentMutableContext(); + + private: + IConfigPtr m_config; + IRunner* m_runner = nullptr; + IResultCapture* m_resultCapture = nullptr; + }; + + IMutableContext *IMutableContext::currentContext = nullptr; + + void IMutableContext::createContext() + { + currentContext = new Context(); + } + + void cleanUpContext() { + delete IMutableContext::currentContext; + IMutableContext::currentContext = nullptr; + } + IContext::~IContext() = default; + IMutableContext::~IMutableContext() = default; + Context::~Context() = default; +} +// end catch_context.cpp +// start catch_debug_console.cpp + +// start catch_debug_console.h + +#include + +namespace Catch { + void writeToDebugConsole( std::string const& text ); +} + +// end catch_debug_console.h +#ifdef CATCH_PLATFORM_WINDOWS + + namespace Catch { + void writeToDebugConsole( std::string const& text ) { + ::OutputDebugStringA( text.c_str() ); + } + } + +#else + + namespace Catch { + void writeToDebugConsole( std::string const& text ) { + // !TBD: Need a version for Mac/ XCode and other IDEs + Catch::cout() << text; + } + } + +#endif // Platform +// end catch_debug_console.cpp +// start catch_debugger.cpp + +#ifdef CATCH_PLATFORM_MAC + +# include +# include +# include +# include +# include +# include +# include + +namespace Catch { + + // The following function is taken directly from the following technical note: + // http://developer.apple.com/library/mac/#qa/qa2004/qa1361.html + + // Returns true if the current process is being debugged (either + // running under the debugger or has a debugger attached post facto). + bool isDebuggerActive(){ + + int mib[4]; + struct kinfo_proc info; + std::size_t size; + + // Initialize the flags so that, if sysctl fails for some bizarre + // reason, we get a predictable result. + + info.kp_proc.p_flag = 0; + + // Initialize mib, which tells sysctl the info we want, in this case + // we're looking for information about a specific process ID. + + mib[0] = CTL_KERN; + mib[1] = KERN_PROC; + mib[2] = KERN_PROC_PID; + mib[3] = getpid(); + + // Call sysctl. + + size = sizeof(info); + if( sysctl(mib, sizeof(mib) / sizeof(*mib), &info, &size, nullptr, 0) != 0 ) { + Catch::cerr() << "\n** Call to sysctl failed - unable to determine if debugger is active **\n" << std::endl; + return false; + } + + // We're being debugged if the P_TRACED flag is set. + + return ( (info.kp_proc.p_flag & P_TRACED) != 0 ); + } + } // namespace Catch + +#elif defined(CATCH_PLATFORM_LINUX) + #include + #include + + namespace Catch{ + // The standard POSIX way of detecting a debugger is to attempt to + // ptrace() the process, but this needs to be done from a child and not + // this process itself to still allow attaching to this process later + // if wanted, so is rather heavy. Under Linux we have the PID of the + // "debugger" (which doesn't need to be gdb, of course, it could also + // be strace, for example) in /proc/$PID/status, so just get it from + // there instead. + bool isDebuggerActive(){ + // Libstdc++ has a bug, where std::ifstream sets errno to 0 + // This way our users can properly assert over errno values + ErrnoGuard guard; + std::ifstream in("/proc/self/status"); + for( std::string line; std::getline(in, line); ) { + static const int PREFIX_LEN = 11; + if( line.compare(0, PREFIX_LEN, "TracerPid:\t") == 0 ) { + // We're traced if the PID is not 0 and no other PID starts + // with 0 digit, so it's enough to check for just a single + // character. + return line.length() > PREFIX_LEN && line[PREFIX_LEN] != '0'; + } + } + + return false; + } + } // namespace Catch +#elif defined(_MSC_VER) + extern "C" __declspec(dllimport) int __stdcall IsDebuggerPresent(); + namespace Catch { + bool isDebuggerActive() { + return IsDebuggerPresent() != 0; + } + } +#elif defined(__MINGW32__) + extern "C" __declspec(dllimport) int __stdcall IsDebuggerPresent(); + namespace Catch { + bool isDebuggerActive() { + return IsDebuggerPresent() != 0; + } + } +#else + namespace Catch { + bool isDebuggerActive() { return false; } + } +#endif // Platform +// end catch_debugger.cpp +// start catch_decomposer.cpp + +namespace Catch { + + ITransientExpression::~ITransientExpression() = default; + + void formatReconstructedExpression( std::ostream &os, std::string const& lhs, StringRef op, std::string const& rhs ) { + if( lhs.size() + rhs.size() < 40 && + lhs.find('\n') == std::string::npos && + rhs.find('\n') == std::string::npos ) + os << lhs << " " << op << " " << rhs; + else + os << lhs << "\n" << op << "\n" << rhs; + } +} +// end catch_decomposer.cpp +// start catch_errno_guard.cpp + +#include + +namespace Catch { + ErrnoGuard::ErrnoGuard():m_oldErrno(errno){} + ErrnoGuard::~ErrnoGuard() { errno = m_oldErrno; } +} +// end catch_errno_guard.cpp +// start catch_exception_translator_registry.cpp + +// start catch_exception_translator_registry.h + +#include +#include +#include + +namespace Catch { + + class ExceptionTranslatorRegistry : public IExceptionTranslatorRegistry { + public: + ~ExceptionTranslatorRegistry(); + virtual void registerTranslator( const IExceptionTranslator* translator ); + virtual std::string translateActiveException() const override; + std::string tryTranslators() const; + + private: + std::vector> m_translators; + }; +} + +// end catch_exception_translator_registry.h +#ifdef __OBJC__ +#import "Foundation/Foundation.h" +#endif + +namespace Catch { + + ExceptionTranslatorRegistry::~ExceptionTranslatorRegistry() { + } + + void ExceptionTranslatorRegistry::registerTranslator( const IExceptionTranslator* translator ) { + m_translators.push_back( std::unique_ptr( translator ) ); + } + + std::string ExceptionTranslatorRegistry::translateActiveException() const { + try { +#ifdef __OBJC__ + // In Objective-C try objective-c exceptions first + @try { + return tryTranslators(); + } + @catch (NSException *exception) { + return Catch::Detail::stringify( [exception description] ); + } +#else + // Compiling a mixed mode project with MSVC means that CLR + // exceptions will be caught in (...) as well. However, these + // do not fill-in std::current_exception and thus lead to crash + // when attempting rethrow. + // /EHa switch also causes structured exceptions to be caught + // here, but they fill-in current_exception properly, so + // at worst the output should be a little weird, instead of + // causing a crash. + if (std::current_exception() == nullptr) { + return "Non C++ exception. Possibly a CLR exception."; + } + return tryTranslators(); +#endif + } + catch( TestFailureException& ) { + std::rethrow_exception(std::current_exception()); + } + catch( std::exception& ex ) { + return ex.what(); + } + catch( std::string& msg ) { + return msg; + } + catch( const char* msg ) { + return msg; + } + catch(...) { + return "Unknown exception"; + } + } + + std::string ExceptionTranslatorRegistry::tryTranslators() const { + if( m_translators.empty() ) + std::rethrow_exception(std::current_exception()); + else + return m_translators[0]->translate( m_translators.begin()+1, m_translators.end() ); + } +} +// end catch_exception_translator_registry.cpp +// start catch_fatal_condition.cpp + +#if defined(__GNUC__) +# pragma GCC diagnostic push +# pragma GCC diagnostic ignored "-Wmissing-field-initializers" +#endif + +#if defined( CATCH_CONFIG_WINDOWS_SEH ) || defined( CATCH_CONFIG_POSIX_SIGNALS ) + +namespace { + // Report the error condition + void reportFatal( char const * const message ) { + Catch::getCurrentContext().getResultCapture()->handleFatalErrorCondition( message ); + } +} + +#endif // signals/SEH handling + +#if defined( CATCH_CONFIG_WINDOWS_SEH ) + +namespace Catch { + struct SignalDefs { DWORD id; const char* name; }; + + // There is no 1-1 mapping between signals and windows exceptions. + // Windows can easily distinguish between SO and SigSegV, + // but SigInt, SigTerm, etc are handled differently. + static SignalDefs signalDefs[] = { + { EXCEPTION_ILLEGAL_INSTRUCTION, "SIGILL - Illegal instruction signal" }, + { EXCEPTION_STACK_OVERFLOW, "SIGSEGV - Stack overflow" }, + { EXCEPTION_ACCESS_VIOLATION, "SIGSEGV - Segmentation violation signal" }, + { EXCEPTION_INT_DIVIDE_BY_ZERO, "Divide by zero error" }, + }; + + LONG CALLBACK FatalConditionHandler::handleVectoredException(PEXCEPTION_POINTERS ExceptionInfo) { + for (auto const& def : signalDefs) { + if (ExceptionInfo->ExceptionRecord->ExceptionCode == def.id) { + reportFatal(def.name); + } + } + // If its not an exception we care about, pass it along. + // This stops us from eating debugger breaks etc. + return EXCEPTION_CONTINUE_SEARCH; + } + + FatalConditionHandler::FatalConditionHandler() { + isSet = true; + // 32k seems enough for Catch to handle stack overflow, + // but the value was found experimentally, so there is no strong guarantee + guaranteeSize = 32 * 1024; + exceptionHandlerHandle = nullptr; + // Register as first handler in current chain + exceptionHandlerHandle = AddVectoredExceptionHandler(1, handleVectoredException); + // Pass in guarantee size to be filled + SetThreadStackGuarantee(&guaranteeSize); + } + + void FatalConditionHandler::reset() { + if (isSet) { + RemoveVectoredExceptionHandler(exceptionHandlerHandle); + SetThreadStackGuarantee(&guaranteeSize); + exceptionHandlerHandle = nullptr; + isSet = false; + } + } + + FatalConditionHandler::~FatalConditionHandler() { + reset(); + } + +bool FatalConditionHandler::isSet = false; +ULONG FatalConditionHandler::guaranteeSize = 0; +PVOID FatalConditionHandler::exceptionHandlerHandle = nullptr; + +} // namespace Catch + +#elif defined( CATCH_CONFIG_POSIX_SIGNALS ) + +namespace Catch { + + struct SignalDefs { + int id; + const char* name; + }; + + // 32kb for the alternate stack seems to be sufficient. However, this value + // is experimentally determined, so that's not guaranteed. + constexpr static std::size_t sigStackSize = 32768 >= MINSIGSTKSZ ? 32768 : MINSIGSTKSZ; + + static SignalDefs signalDefs[] = { + { SIGINT, "SIGINT - Terminal interrupt signal" }, + { SIGILL, "SIGILL - Illegal instruction signal" }, + { SIGFPE, "SIGFPE - Floating point error signal" }, + { SIGSEGV, "SIGSEGV - Segmentation violation signal" }, + { SIGTERM, "SIGTERM - Termination request signal" }, + { SIGABRT, "SIGABRT - Abort (abnormal termination) signal" } + }; + + void FatalConditionHandler::handleSignal( int sig ) { + char const * name = ""; + for (auto const& def : signalDefs) { + if (sig == def.id) { + name = def.name; + break; + } + } + reset(); + reportFatal(name); + raise( sig ); + } + + FatalConditionHandler::FatalConditionHandler() { + isSet = true; + stack_t sigStack; + sigStack.ss_sp = altStackMem; + sigStack.ss_size = sigStackSize; + sigStack.ss_flags = 0; + sigaltstack(&sigStack, &oldSigStack); + struct sigaction sa = { }; + + sa.sa_handler = handleSignal; + sa.sa_flags = SA_ONSTACK; + for (std::size_t i = 0; i < sizeof(signalDefs)/sizeof(SignalDefs); ++i) { + sigaction(signalDefs[i].id, &sa, &oldSigActions[i]); + } + } + + FatalConditionHandler::~FatalConditionHandler() { + reset(); + } + + void FatalConditionHandler::reset() { + if( isSet ) { + // Set signals back to previous values -- hopefully nobody overwrote them in the meantime + for( std::size_t i = 0; i < sizeof(signalDefs)/sizeof(SignalDefs); ++i ) { + sigaction(signalDefs[i].id, &oldSigActions[i], nullptr); + } + // Return the old stack + sigaltstack(&oldSigStack, nullptr); + isSet = false; + } + } + + bool FatalConditionHandler::isSet = false; + struct sigaction FatalConditionHandler::oldSigActions[sizeof(signalDefs)/sizeof(SignalDefs)] = {}; + stack_t FatalConditionHandler::oldSigStack = {}; + char FatalConditionHandler::altStackMem[sigStackSize] = {}; + +} // namespace Catch + +#else + +namespace Catch { + void FatalConditionHandler::reset() {} +} + +#endif // signals/SEH handling + +#if defined(__GNUC__) +# pragma GCC diagnostic pop +#endif +// end catch_fatal_condition.cpp +// start catch_interfaces_capture.cpp + +namespace Catch { + IResultCapture::~IResultCapture() = default; +} +// end catch_interfaces_capture.cpp +// start catch_interfaces_config.cpp + +namespace Catch { + IConfig::~IConfig() = default; +} +// end catch_interfaces_config.cpp +// start catch_interfaces_exception.cpp + +namespace Catch { + IExceptionTranslator::~IExceptionTranslator() = default; + IExceptionTranslatorRegistry::~IExceptionTranslatorRegistry() = default; +} +// end catch_interfaces_exception.cpp +// start catch_interfaces_registry_hub.cpp + +namespace Catch { + IRegistryHub::~IRegistryHub() = default; + IMutableRegistryHub::~IMutableRegistryHub() = default; +} +// end catch_interfaces_registry_hub.cpp +// start catch_interfaces_reporter.cpp + +// start catch_reporter_listening.h + +namespace Catch { + + class ListeningReporter : public IStreamingReporter { + using Reporters = std::vector; + Reporters m_listeners; + IStreamingReporterPtr m_reporter = nullptr; + ReporterPreferences m_preferences; + + public: + ListeningReporter(); + + void addListener( IStreamingReporterPtr&& listener ); + void addReporter( IStreamingReporterPtr&& reporter ); + + public: // IStreamingReporter + + ReporterPreferences getPreferences() const override; + + void noMatchingTestCases( std::string const& spec ) override; + + static std::set getSupportedVerbosities(); + + void benchmarkStarting( BenchmarkInfo const& benchmarkInfo ) override; + void benchmarkEnded( BenchmarkStats const& benchmarkStats ) override; + + void testRunStarting( TestRunInfo const& testRunInfo ) override; + void testGroupStarting( GroupInfo const& groupInfo ) override; + void testCaseStarting( TestCaseInfo const& testInfo ) override; + void sectionStarting( SectionInfo const& sectionInfo ) override; + void assertionStarting( AssertionInfo const& assertionInfo ) override; + + // The return value indicates if the messages buffer should be cleared: + bool assertionEnded( AssertionStats const& assertionStats ) override; + void sectionEnded( SectionStats const& sectionStats ) override; + void testCaseEnded( TestCaseStats const& testCaseStats ) override; + void testGroupEnded( TestGroupStats const& testGroupStats ) override; + void testRunEnded( TestRunStats const& testRunStats ) override; + + void skipTest( TestCaseInfo const& testInfo ) override; + bool isMulti() const override; + + }; + +} // end namespace Catch + +// end catch_reporter_listening.h +namespace Catch { + + ReporterConfig::ReporterConfig( IConfigPtr const& _fullConfig ) + : m_stream( &_fullConfig->stream() ), m_fullConfig( _fullConfig ) {} + + ReporterConfig::ReporterConfig( IConfigPtr const& _fullConfig, std::ostream& _stream ) + : m_stream( &_stream ), m_fullConfig( _fullConfig ) {} + + std::ostream& ReporterConfig::stream() const { return *m_stream; } + IConfigPtr ReporterConfig::fullConfig() const { return m_fullConfig; } + + TestRunInfo::TestRunInfo( std::string const& _name ) : name( _name ) {} + + GroupInfo::GroupInfo( std::string const& _name, + std::size_t _groupIndex, + std::size_t _groupsCount ) + : name( _name ), + groupIndex( _groupIndex ), + groupsCounts( _groupsCount ) + {} + + AssertionStats::AssertionStats( AssertionResult const& _assertionResult, + std::vector const& _infoMessages, + Totals const& _totals ) + : assertionResult( _assertionResult ), + infoMessages( _infoMessages ), + totals( _totals ) + { + assertionResult.m_resultData.lazyExpression.m_transientExpression = _assertionResult.m_resultData.lazyExpression.m_transientExpression; + + if( assertionResult.hasMessage() ) { + // Copy message into messages list. + // !TBD This should have been done earlier, somewhere + MessageBuilder builder( assertionResult.getTestMacroName(), assertionResult.getSourceInfo(), assertionResult.getResultType() ); + builder << assertionResult.getMessage(); + builder.m_info.message = builder.m_stream.str(); + + infoMessages.push_back( builder.m_info ); + } + } + + AssertionStats::~AssertionStats() = default; + + SectionStats::SectionStats( SectionInfo const& _sectionInfo, + Counts const& _assertions, + double _durationInSeconds, + bool _missingAssertions ) + : sectionInfo( _sectionInfo ), + assertions( _assertions ), + durationInSeconds( _durationInSeconds ), + missingAssertions( _missingAssertions ) + {} + + SectionStats::~SectionStats() = default; + + TestCaseStats::TestCaseStats( TestCaseInfo const& _testInfo, + Totals const& _totals, + std::string const& _stdOut, + std::string const& _stdErr, + bool _aborting ) + : testInfo( _testInfo ), + totals( _totals ), + stdOut( _stdOut ), + stdErr( _stdErr ), + aborting( _aborting ) + {} + + TestCaseStats::~TestCaseStats() = default; + + TestGroupStats::TestGroupStats( GroupInfo const& _groupInfo, + Totals const& _totals, + bool _aborting ) + : groupInfo( _groupInfo ), + totals( _totals ), + aborting( _aborting ) + {} + + TestGroupStats::TestGroupStats( GroupInfo const& _groupInfo ) + : groupInfo( _groupInfo ), + aborting( false ) + {} + + TestGroupStats::~TestGroupStats() = default; + + TestRunStats::TestRunStats( TestRunInfo const& _runInfo, + Totals const& _totals, + bool _aborting ) + : runInfo( _runInfo ), + totals( _totals ), + aborting( _aborting ) + {} + + TestRunStats::~TestRunStats() = default; + + void IStreamingReporter::fatalErrorEncountered( StringRef ) {} + bool IStreamingReporter::isMulti() const { return false; } + + IReporterFactory::~IReporterFactory() = default; + IReporterRegistry::~IReporterRegistry() = default; + +} // end namespace Catch +// end catch_interfaces_reporter.cpp +// start catch_interfaces_runner.cpp + +namespace Catch { + IRunner::~IRunner() = default; +} +// end catch_interfaces_runner.cpp +// start catch_interfaces_testcase.cpp + +namespace Catch { + ITestInvoker::~ITestInvoker() = default; + ITestCaseRegistry::~ITestCaseRegistry() = default; +} +// end catch_interfaces_testcase.cpp +// start catch_leak_detector.cpp + +#ifdef CATCH_CONFIG_WINDOWS_CRTDBG +#include + +namespace Catch { + + LeakDetector::LeakDetector() { + int flag = _CrtSetDbgFlag(_CRTDBG_REPORT_FLAG); + flag |= _CRTDBG_LEAK_CHECK_DF; + flag |= _CRTDBG_ALLOC_MEM_DF; + _CrtSetDbgFlag(flag); + _CrtSetReportMode(_CRT_WARN, _CRTDBG_MODE_FILE | _CRTDBG_MODE_DEBUG); + _CrtSetReportFile(_CRT_WARN, _CRTDBG_FILE_STDERR); + // Change this to leaking allocation's number to break there + _CrtSetBreakAlloc(-1); + } +} + +#else + + Catch::LeakDetector::LeakDetector() {} + +#endif +// end catch_leak_detector.cpp +// start catch_list.cpp + +// start catch_list.h + +#include + +namespace Catch { + + std::size_t listTests( Config const& config ); + + std::size_t listTestsNamesOnly( Config const& config ); + + struct TagInfo { + void add( std::string const& spelling ); + std::string all() const; + + std::set spellings; + std::size_t count = 0; + }; + + std::size_t listTags( Config const& config ); + + std::size_t listReporters( Config const& /*config*/ ); + + Option list( Config const& config ); + +} // end namespace Catch + +// end catch_list.h +// start catch_text.h + +namespace Catch { + using namespace clara::TextFlow; +} + +// end catch_text.h +#include +#include +#include + +namespace Catch { + + std::size_t listTests( Config const& config ) { + TestSpec testSpec = config.testSpec(); + if( config.hasTestFilters() ) + Catch::cout() << "Matching test cases:\n"; + else { + Catch::cout() << "All available test cases:\n"; + } + + auto matchedTestCases = filterTests( getAllTestCasesSorted( config ), testSpec, config ); + for( auto const& testCaseInfo : matchedTestCases ) { + Colour::Code colour = testCaseInfo.isHidden() + ? Colour::SecondaryText + : Colour::None; + Colour colourGuard( colour ); + + Catch::cout() << Column( testCaseInfo.name ).initialIndent( 2 ).indent( 4 ) << "\n"; + if( config.verbosity() >= Verbosity::High ) { + Catch::cout() << Column( Catch::Detail::stringify( testCaseInfo.lineInfo ) ).indent(4) << std::endl; + std::string description = testCaseInfo.description; + if( description.empty() ) + description = "(NO DESCRIPTION)"; + Catch::cout() << Column( description ).indent(4) << std::endl; + } + if( !testCaseInfo.tags.empty() ) + Catch::cout() << Column( testCaseInfo.tagsAsString() ).indent( 6 ) << "\n"; + } + + if( !config.hasTestFilters() ) + Catch::cout() << pluralise( matchedTestCases.size(), "test case" ) << '\n' << std::endl; + else + Catch::cout() << pluralise( matchedTestCases.size(), "matching test case" ) << '\n' << std::endl; + return matchedTestCases.size(); + } + + std::size_t listTestsNamesOnly( Config const& config ) { + TestSpec testSpec = config.testSpec(); + std::size_t matchedTests = 0; + std::vector matchedTestCases = filterTests( getAllTestCasesSorted( config ), testSpec, config ); + for( auto const& testCaseInfo : matchedTestCases ) { + matchedTests++; + if( startsWith( testCaseInfo.name, '#' ) ) + Catch::cout() << '"' << testCaseInfo.name << '"'; + else + Catch::cout() << testCaseInfo.name; + if ( config.verbosity() >= Verbosity::High ) + Catch::cout() << "\t@" << testCaseInfo.lineInfo; + Catch::cout() << std::endl; + } + return matchedTests; + } + + void TagInfo::add( std::string const& spelling ) { + ++count; + spellings.insert( spelling ); + } + + std::string TagInfo::all() const { + std::string out; + for( auto const& spelling : spellings ) + out += "[" + spelling + "]"; + return out; + } + + std::size_t listTags( Config const& config ) { + TestSpec testSpec = config.testSpec(); + if( config.hasTestFilters() ) + Catch::cout() << "Tags for matching test cases:\n"; + else { + Catch::cout() << "All available tags:\n"; + } + + std::map tagCounts; + + std::vector matchedTestCases = filterTests( getAllTestCasesSorted( config ), testSpec, config ); + for( auto const& testCase : matchedTestCases ) { + for( auto const& tagName : testCase.getTestCaseInfo().tags ) { + std::string lcaseTagName = toLower( tagName ); + auto countIt = tagCounts.find( lcaseTagName ); + if( countIt == tagCounts.end() ) + countIt = tagCounts.insert( std::make_pair( lcaseTagName, TagInfo() ) ).first; + countIt->second.add( tagName ); + } + } + + for( auto const& tagCount : tagCounts ) { + ReusableStringStream rss; + rss << " " << std::setw(2) << tagCount.second.count << " "; + auto str = rss.str(); + auto wrapper = Column( tagCount.second.all() ) + .initialIndent( 0 ) + .indent( str.size() ) + .width( CATCH_CONFIG_CONSOLE_WIDTH-10 ); + Catch::cout() << str << wrapper << '\n'; + } + Catch::cout() << pluralise( tagCounts.size(), "tag" ) << '\n' << std::endl; + return tagCounts.size(); + } + + std::size_t listReporters( Config const& /*config*/ ) { + Catch::cout() << "Available reporters:\n"; + IReporterRegistry::FactoryMap const& factories = getRegistryHub().getReporterRegistry().getFactories(); + std::size_t maxNameLen = 0; + for( auto const& factoryKvp : factories ) + maxNameLen = (std::max)( maxNameLen, factoryKvp.first.size() ); + + for( auto const& factoryKvp : factories ) { + Catch::cout() + << Column( factoryKvp.first + ":" ) + .indent(2) + .width( 5+maxNameLen ) + + Column( factoryKvp.second->getDescription() ) + .initialIndent(0) + .indent(2) + .width( CATCH_CONFIG_CONSOLE_WIDTH - maxNameLen-8 ) + << "\n"; + } + Catch::cout() << std::endl; + return factories.size(); + } + + Option list( Config const& config ) { + Option listedCount; + if( config.listTests() ) + listedCount = listedCount.valueOr(0) + listTests( config ); + if( config.listTestNamesOnly() ) + listedCount = listedCount.valueOr(0) + listTestsNamesOnly( config ); + if( config.listTags() ) + listedCount = listedCount.valueOr(0) + listTags( config ); + if( config.listReporters() ) + listedCount = listedCount.valueOr(0) + listReporters( config ); + return listedCount; + } + +} // end namespace Catch +// end catch_list.cpp +// start catch_matchers.cpp + +namespace Catch { +namespace Matchers { + namespace Impl { + + std::string MatcherUntypedBase::toString() const { + if( m_cachedToString.empty() ) + m_cachedToString = describe(); + return m_cachedToString; + } + + MatcherUntypedBase::~MatcherUntypedBase() = default; + + } // namespace Impl +} // namespace Matchers + +using namespace Matchers; +using Matchers::Impl::MatcherBase; + +} // namespace Catch +// end catch_matchers.cpp +// start catch_matchers_floating.cpp + +// start catch_to_string.hpp + +#include + +namespace Catch { + template + std::string to_string(T const& t) { +#if defined(CATCH_CONFIG_CPP11_TO_STRING) + return std::to_string(t); +#else + ReusableStringStream rss; + rss << t; + return rss.str(); +#endif + } +} // end namespace Catch + +// end catch_to_string.hpp +#include +#include +#include +#include + +namespace Catch { +namespace Matchers { +namespace Floating { +enum class FloatingPointKind : uint8_t { + Float, + Double +}; +} +} +} + +namespace { + +template +struct Converter; + +template <> +struct Converter { + static_assert(sizeof(float) == sizeof(int32_t), "Important ULP matcher assumption violated"); + Converter(float f) { + std::memcpy(&i, &f, sizeof(f)); + } + int32_t i; +}; + +template <> +struct Converter { + static_assert(sizeof(double) == sizeof(int64_t), "Important ULP matcher assumption violated"); + Converter(double d) { + std::memcpy(&i, &d, sizeof(d)); + } + int64_t i; +}; + +template +auto convert(T t) -> Converter { + return Converter(t); +} + +template +bool almostEqualUlps(FP lhs, FP rhs, int maxUlpDiff) { + // Comparison with NaN should always be false. + // This way we can rule it out before getting into the ugly details + if (std::isnan(lhs) || std::isnan(rhs)) { + return false; + } + + auto lc = convert(lhs); + auto rc = convert(rhs); + + if ((lc.i < 0) != (rc.i < 0)) { + // Potentially we can have +0 and -0 + return lhs == rhs; + } + + auto ulpDiff = std::abs(lc.i - rc.i); + return ulpDiff <= maxUlpDiff; +} + +} + +namespace Catch { +namespace Matchers { +namespace Floating { + WithinAbsMatcher::WithinAbsMatcher(double target, double margin) + :m_target{ target }, m_margin{ margin } { + if (m_margin < 0) { + throw std::domain_error("Allowed margin difference has to be >= 0"); + } + } + + // Performs equivalent check of std::fabs(lhs - rhs) <= margin + // But without the subtraction to allow for INFINITY in comparison + bool WithinAbsMatcher::match(double const& matchee) const { + return (matchee + m_margin >= m_target) && (m_target + m_margin >= matchee); + } + + std::string WithinAbsMatcher::describe() const { + return "is within " + ::Catch::Detail::stringify(m_margin) + " of " + ::Catch::Detail::stringify(m_target); + } + + WithinUlpsMatcher::WithinUlpsMatcher(double target, int ulps, FloatingPointKind baseType) + :m_target{ target }, m_ulps{ ulps }, m_type{ baseType } { + if (m_ulps < 0) { + throw std::domain_error("Allowed ulp difference has to be >= 0"); + } + } + + bool WithinUlpsMatcher::match(double const& matchee) const { + switch (m_type) { + case FloatingPointKind::Float: + return almostEqualUlps(static_cast(matchee), static_cast(m_target), m_ulps); + case FloatingPointKind::Double: + return almostEqualUlps(matchee, m_target, m_ulps); + default: + throw std::domain_error("Unknown FloatingPointKind value"); + } + } + + std::string WithinUlpsMatcher::describe() const { + return "is within " + Catch::to_string(m_ulps) + " ULPs of " + ::Catch::Detail::stringify(m_target) + ((m_type == FloatingPointKind::Float)? "f" : ""); + } + +}// namespace Floating + +Floating::WithinUlpsMatcher WithinULP(double target, int maxUlpDiff) { + return Floating::WithinUlpsMatcher(target, maxUlpDiff, Floating::FloatingPointKind::Double); +} + +Floating::WithinUlpsMatcher WithinULP(float target, int maxUlpDiff) { + return Floating::WithinUlpsMatcher(target, maxUlpDiff, Floating::FloatingPointKind::Float); +} + +Floating::WithinAbsMatcher WithinAbs(double target, double margin) { + return Floating::WithinAbsMatcher(target, margin); +} + +} // namespace Matchers +} // namespace Catch + +// end catch_matchers_floating.cpp +// start catch_matchers_generic.cpp + +std::string Catch::Matchers::Generic::Detail::finalizeDescription(const std::string& desc) { + if (desc.empty()) { + return "matches undescribed predicate"; + } else { + return "matches predicate: \"" + desc + '"'; + } +} +// end catch_matchers_generic.cpp +// start catch_matchers_string.cpp + +#include + +namespace Catch { +namespace Matchers { + + namespace StdString { + + CasedString::CasedString( std::string const& str, CaseSensitive::Choice caseSensitivity ) + : m_caseSensitivity( caseSensitivity ), + m_str( adjustString( str ) ) + {} + std::string CasedString::adjustString( std::string const& str ) const { + return m_caseSensitivity == CaseSensitive::No + ? toLower( str ) + : str; + } + std::string CasedString::caseSensitivitySuffix() const { + return m_caseSensitivity == CaseSensitive::No + ? " (case insensitive)" + : std::string(); + } + + StringMatcherBase::StringMatcherBase( std::string const& operation, CasedString const& comparator ) + : m_comparator( comparator ), + m_operation( operation ) { + } + + std::string StringMatcherBase::describe() const { + std::string description; + description.reserve(5 + m_operation.size() + m_comparator.m_str.size() + + m_comparator.caseSensitivitySuffix().size()); + description += m_operation; + description += ": \""; + description += m_comparator.m_str; + description += "\""; + description += m_comparator.caseSensitivitySuffix(); + return description; + } + + EqualsMatcher::EqualsMatcher( CasedString const& comparator ) : StringMatcherBase( "equals", comparator ) {} + + bool EqualsMatcher::match( std::string const& source ) const { + return m_comparator.adjustString( source ) == m_comparator.m_str; + } + + ContainsMatcher::ContainsMatcher( CasedString const& comparator ) : StringMatcherBase( "contains", comparator ) {} + + bool ContainsMatcher::match( std::string const& source ) const { + return contains( m_comparator.adjustString( source ), m_comparator.m_str ); + } + + StartsWithMatcher::StartsWithMatcher( CasedString const& comparator ) : StringMatcherBase( "starts with", comparator ) {} + + bool StartsWithMatcher::match( std::string const& source ) const { + return startsWith( m_comparator.adjustString( source ), m_comparator.m_str ); + } + + EndsWithMatcher::EndsWithMatcher( CasedString const& comparator ) : StringMatcherBase( "ends with", comparator ) {} + + bool EndsWithMatcher::match( std::string const& source ) const { + return endsWith( m_comparator.adjustString( source ), m_comparator.m_str ); + } + + RegexMatcher::RegexMatcher(std::string regex, CaseSensitive::Choice caseSensitivity): m_regex(std::move(regex)), m_caseSensitivity(caseSensitivity) {} + + bool RegexMatcher::match(std::string const& matchee) const { + auto flags = std::regex::ECMAScript; // ECMAScript is the default syntax option anyway + if (m_caseSensitivity == CaseSensitive::Choice::No) { + flags |= std::regex::icase; + } + auto reg = std::regex(m_regex, flags); + return std::regex_match(matchee, reg); + } + + std::string RegexMatcher::describe() const { + return "matches " + ::Catch::Detail::stringify(m_regex) + ((m_caseSensitivity == CaseSensitive::Choice::Yes)? " case sensitively" : " case insensitively"); + } + + } // namespace StdString + + StdString::EqualsMatcher Equals( std::string const& str, CaseSensitive::Choice caseSensitivity ) { + return StdString::EqualsMatcher( StdString::CasedString( str, caseSensitivity) ); + } + StdString::ContainsMatcher Contains( std::string const& str, CaseSensitive::Choice caseSensitivity ) { + return StdString::ContainsMatcher( StdString::CasedString( str, caseSensitivity) ); + } + StdString::EndsWithMatcher EndsWith( std::string const& str, CaseSensitive::Choice caseSensitivity ) { + return StdString::EndsWithMatcher( StdString::CasedString( str, caseSensitivity) ); + } + StdString::StartsWithMatcher StartsWith( std::string const& str, CaseSensitive::Choice caseSensitivity ) { + return StdString::StartsWithMatcher( StdString::CasedString( str, caseSensitivity) ); + } + + StdString::RegexMatcher Matches(std::string const& regex, CaseSensitive::Choice caseSensitivity) { + return StdString::RegexMatcher(regex, caseSensitivity); + } + +} // namespace Matchers +} // namespace Catch +// end catch_matchers_string.cpp +// start catch_message.cpp + +// start catch_uncaught_exceptions.h + +namespace Catch { + bool uncaught_exceptions(); +} // end namespace Catch + +// end catch_uncaught_exceptions.h +namespace Catch { + + MessageInfo::MessageInfo( std::string const& _macroName, + SourceLineInfo const& _lineInfo, + ResultWas::OfType _type ) + : macroName( _macroName ), + lineInfo( _lineInfo ), + type( _type ), + sequence( ++globalCount ) + {} + + bool MessageInfo::operator==( MessageInfo const& other ) const { + return sequence == other.sequence; + } + + bool MessageInfo::operator<( MessageInfo const& other ) const { + return sequence < other.sequence; + } + + // This may need protecting if threading support is added + unsigned int MessageInfo::globalCount = 0; + + //////////////////////////////////////////////////////////////////////////// + + Catch::MessageBuilder::MessageBuilder( std::string const& macroName, + SourceLineInfo const& lineInfo, + ResultWas::OfType type ) + :m_info(macroName, lineInfo, type) {} + + //////////////////////////////////////////////////////////////////////////// + + ScopedMessage::ScopedMessage( MessageBuilder const& builder ) + : m_info( builder.m_info ) + { + m_info.message = builder.m_stream.str(); + getResultCapture().pushScopedMessage( m_info ); + } + + ScopedMessage::~ScopedMessage() { + if ( !uncaught_exceptions() ){ + getResultCapture().popScopedMessage(m_info); + } + } +} // end namespace Catch +// end catch_message.cpp +// start catch_output_redirect.cpp + +// start catch_output_redirect.h +#ifndef TWOBLUECUBES_CATCH_OUTPUT_REDIRECT_H +#define TWOBLUECUBES_CATCH_OUTPUT_REDIRECT_H + +#include +#include +#include + +namespace Catch { + + class RedirectedStream { + std::ostream& m_originalStream; + std::ostream& m_redirectionStream; + std::streambuf* m_prevBuf; + + public: + RedirectedStream( std::ostream& originalStream, std::ostream& redirectionStream ); + ~RedirectedStream(); + }; + + class RedirectedStdOut { + ReusableStringStream m_rss; + RedirectedStream m_cout; + public: + RedirectedStdOut(); + auto str() const -> std::string; + }; + + // StdErr has two constituent streams in C++, std::cerr and std::clog + // This means that we need to redirect 2 streams into 1 to keep proper + // order of writes + class RedirectedStdErr { + ReusableStringStream m_rss; + RedirectedStream m_cerr; + RedirectedStream m_clog; + public: + RedirectedStdErr(); + auto str() const -> std::string; + }; + +#if defined(CATCH_CONFIG_NEW_CAPTURE) + + // Windows's implementation of std::tmpfile is terrible (it tries + // to create a file inside system folder, thus requiring elevated + // privileges for the binary), so we have to use tmpnam(_s) and + // create the file ourselves there. + class TempFile { + public: + TempFile(TempFile const&) = delete; + TempFile& operator=(TempFile const&) = delete; + TempFile(TempFile&&) = delete; + TempFile& operator=(TempFile&&) = delete; + + TempFile(); + ~TempFile(); + + std::FILE* getFile(); + std::string getContents(); + + private: + std::FILE* m_file = nullptr; + #if defined(_MSC_VER) + char m_buffer[L_tmpnam] = { 0 }; + #endif + }; + + class OutputRedirect { + public: + OutputRedirect(OutputRedirect const&) = delete; + OutputRedirect& operator=(OutputRedirect const&) = delete; + OutputRedirect(OutputRedirect&&) = delete; + OutputRedirect& operator=(OutputRedirect&&) = delete; + + OutputRedirect(std::string& stdout_dest, std::string& stderr_dest); + ~OutputRedirect(); + + private: + int m_originalStdout = -1; + int m_originalStderr = -1; + TempFile m_stdoutFile; + TempFile m_stderrFile; + std::string& m_stdoutDest; + std::string& m_stderrDest; + }; + +#endif + +} // end namespace Catch + +#endif // TWOBLUECUBES_CATCH_OUTPUT_REDIRECT_H +// end catch_output_redirect.h +#include +#include +#include +#include +#include + +#if defined(CATCH_CONFIG_NEW_CAPTURE) + #if defined(_MSC_VER) + #include //_dup and _dup2 + #define dup _dup + #define dup2 _dup2 + #define fileno _fileno + #else + #include // dup and dup2 + #endif +#endif + +namespace Catch { + + RedirectedStream::RedirectedStream( std::ostream& originalStream, std::ostream& redirectionStream ) + : m_originalStream( originalStream ), + m_redirectionStream( redirectionStream ), + m_prevBuf( m_originalStream.rdbuf() ) + { + m_originalStream.rdbuf( m_redirectionStream.rdbuf() ); + } + + RedirectedStream::~RedirectedStream() { + m_originalStream.rdbuf( m_prevBuf ); + } + + RedirectedStdOut::RedirectedStdOut() : m_cout( Catch::cout(), m_rss.get() ) {} + auto RedirectedStdOut::str() const -> std::string { return m_rss.str(); } + + RedirectedStdErr::RedirectedStdErr() + : m_cerr( Catch::cerr(), m_rss.get() ), + m_clog( Catch::clog(), m_rss.get() ) + {} + auto RedirectedStdErr::str() const -> std::string { return m_rss.str(); } + +#if defined(CATCH_CONFIG_NEW_CAPTURE) + +#if defined(_MSC_VER) + TempFile::TempFile() { + if (tmpnam_s(m_buffer)) { + throw std::runtime_error("Could not get a temp filename"); + } + if (fopen_s(&m_file, m_buffer, "w")) { + char buffer[100]; + if (strerror_s(buffer, errno)) { + throw std::runtime_error("Could not translate errno to string"); + } + throw std::runtime_error("Could not open the temp file: " + std::string(m_buffer) + buffer); + } + } +#else + TempFile::TempFile() { + m_file = std::tmpfile(); + if (!m_file) { + throw std::runtime_error("Could not create a temp file."); + } + } + +#endif + + TempFile::~TempFile() { + // TBD: What to do about errors here? + std::fclose(m_file); + // We manually create the file on Windows only, on Linux + // it will be autodeleted +#if defined(_MSC_VER) + std::remove(m_buffer); +#endif + } + + FILE* TempFile::getFile() { + return m_file; + } + + std::string TempFile::getContents() { + std::stringstream sstr; + char buffer[100] = {}; + std::rewind(m_file); + while (std::fgets(buffer, sizeof(buffer), m_file)) { + sstr << buffer; + } + return sstr.str(); + } + + OutputRedirect::OutputRedirect(std::string& stdout_dest, std::string& stderr_dest) : + m_originalStdout(dup(1)), + m_originalStderr(dup(2)), + m_stdoutDest(stdout_dest), + m_stderrDest(stderr_dest) { + dup2(fileno(m_stdoutFile.getFile()), 1); + dup2(fileno(m_stderrFile.getFile()), 2); + } + + OutputRedirect::~OutputRedirect() { + Catch::cout() << std::flush; + fflush(stdout); + // Since we support overriding these streams, we flush cerr + // even though std::cerr is unbuffered + Catch::cerr() << std::flush; + Catch::clog() << std::flush; + fflush(stderr); + + dup2(m_originalStdout, 1); + dup2(m_originalStderr, 2); + + m_stdoutDest += m_stdoutFile.getContents(); + m_stderrDest += m_stderrFile.getContents(); + } + +#endif // CATCH_CONFIG_NEW_CAPTURE + +} // namespace Catch + +#if defined(CATCH_CONFIG_NEW_CAPTURE) + #if defined(_MSC_VER) + #undef dup + #undef dup2 + #undef fileno + #endif +#endif +// end catch_output_redirect.cpp +// start catch_random_number_generator.cpp + +// start catch_random_number_generator.h + +#include +#include + +namespace Catch { + + struct IConfig; + + std::mt19937& rng(); + void seedRng( IConfig const& config ); + unsigned int rngSeed(); + +} + +// end catch_random_number_generator.h +namespace Catch { + + std::mt19937& rng() { + static std::mt19937 s_rng; + return s_rng; + } + + void seedRng( IConfig const& config ) { + if( config.rngSeed() != 0 ) { + std::srand( config.rngSeed() ); + rng().seed( config.rngSeed() ); + } + } + + unsigned int rngSeed() { + return getCurrentContext().getConfig()->rngSeed(); + } +} +// end catch_random_number_generator.cpp +// start catch_registry_hub.cpp + +// start catch_test_case_registry_impl.h + +#include +#include +#include +#include + +namespace Catch { + + class TestCase; + struct IConfig; + + std::vector sortTests( IConfig const& config, std::vector const& unsortedTestCases ); + bool matchTest( TestCase const& testCase, TestSpec const& testSpec, IConfig const& config ); + + void enforceNoDuplicateTestCases( std::vector const& functions ); + + std::vector filterTests( std::vector const& testCases, TestSpec const& testSpec, IConfig const& config ); + std::vector const& getAllTestCasesSorted( IConfig const& config ); + + class TestRegistry : public ITestCaseRegistry { + public: + virtual ~TestRegistry() = default; + + virtual void registerTest( TestCase const& testCase ); + + std::vector const& getAllTests() const override; + std::vector const& getAllTestsSorted( IConfig const& config ) const override; + + private: + std::vector m_functions; + mutable RunTests::InWhatOrder m_currentSortOrder = RunTests::InDeclarationOrder; + mutable std::vector m_sortedFunctions; + std::size_t m_unnamedCount = 0; + std::ios_base::Init m_ostreamInit; // Forces cout/ cerr to be initialised + }; + + /////////////////////////////////////////////////////////////////////////// + + class TestInvokerAsFunction : public ITestInvoker { + void(*m_testAsFunction)(); + public: + TestInvokerAsFunction( void(*testAsFunction)() ) noexcept; + + void invoke() const override; + }; + + std::string extractClassName( StringRef const& classOrQualifiedMethodName ); + + /////////////////////////////////////////////////////////////////////////// + +} // end namespace Catch + +// end catch_test_case_registry_impl.h +// start catch_reporter_registry.h + +#include + +namespace Catch { + + class ReporterRegistry : public IReporterRegistry { + + public: + + ~ReporterRegistry() override; + + IStreamingReporterPtr create( std::string const& name, IConfigPtr const& config ) const override; + + void registerReporter( std::string const& name, IReporterFactoryPtr const& factory ); + void registerListener( IReporterFactoryPtr const& factory ); + + FactoryMap const& getFactories() const override; + Listeners const& getListeners() const override; + + private: + FactoryMap m_factories; + Listeners m_listeners; + }; +} + +// end catch_reporter_registry.h +// start catch_tag_alias_registry.h + +// start catch_tag_alias.h + +#include + +namespace Catch { + + struct TagAlias { + TagAlias(std::string const& _tag, SourceLineInfo _lineInfo); + + std::string tag; + SourceLineInfo lineInfo; + }; + +} // end namespace Catch + +// end catch_tag_alias.h +#include + +namespace Catch { + + class TagAliasRegistry : public ITagAliasRegistry { + public: + ~TagAliasRegistry() override; + TagAlias const* find( std::string const& alias ) const override; + std::string expandAliases( std::string const& unexpandedTestSpec ) const override; + void add( std::string const& alias, std::string const& tag, SourceLineInfo const& lineInfo ); + + private: + std::map m_registry; + }; + +} // end namespace Catch + +// end catch_tag_alias_registry.h +// start catch_startup_exception_registry.h + +#include +#include + +namespace Catch { + + class StartupExceptionRegistry { + public: + void add(std::exception_ptr const& exception) noexcept; + std::vector const& getExceptions() const noexcept; + private: + std::vector m_exceptions; + }; + +} // end namespace Catch + +// end catch_startup_exception_registry.h +namespace Catch { + + namespace { + + class RegistryHub : public IRegistryHub, public IMutableRegistryHub, + private NonCopyable { + + public: // IRegistryHub + RegistryHub() = default; + IReporterRegistry const& getReporterRegistry() const override { + return m_reporterRegistry; + } + ITestCaseRegistry const& getTestCaseRegistry() const override { + return m_testCaseRegistry; + } + IExceptionTranslatorRegistry& getExceptionTranslatorRegistry() override { + return m_exceptionTranslatorRegistry; + } + ITagAliasRegistry const& getTagAliasRegistry() const override { + return m_tagAliasRegistry; + } + StartupExceptionRegistry const& getStartupExceptionRegistry() const override { + return m_exceptionRegistry; + } + + public: // IMutableRegistryHub + void registerReporter( std::string const& name, IReporterFactoryPtr const& factory ) override { + m_reporterRegistry.registerReporter( name, factory ); + } + void registerListener( IReporterFactoryPtr const& factory ) override { + m_reporterRegistry.registerListener( factory ); + } + void registerTest( TestCase const& testInfo ) override { + m_testCaseRegistry.registerTest( testInfo ); + } + void registerTranslator( const IExceptionTranslator* translator ) override { + m_exceptionTranslatorRegistry.registerTranslator( translator ); + } + void registerTagAlias( std::string const& alias, std::string const& tag, SourceLineInfo const& lineInfo ) override { + m_tagAliasRegistry.add( alias, tag, lineInfo ); + } + void registerStartupException() noexcept override { + m_exceptionRegistry.add(std::current_exception()); + } + + private: + TestRegistry m_testCaseRegistry; + ReporterRegistry m_reporterRegistry; + ExceptionTranslatorRegistry m_exceptionTranslatorRegistry; + TagAliasRegistry m_tagAliasRegistry; + StartupExceptionRegistry m_exceptionRegistry; + }; + + // Single, global, instance + RegistryHub*& getTheRegistryHub() { + static RegistryHub* theRegistryHub = nullptr; + if( !theRegistryHub ) + theRegistryHub = new RegistryHub(); + return theRegistryHub; + } + } + + IRegistryHub& getRegistryHub() { + return *getTheRegistryHub(); + } + IMutableRegistryHub& getMutableRegistryHub() { + return *getTheRegistryHub(); + } + void cleanUp() { + delete getTheRegistryHub(); + getTheRegistryHub() = nullptr; + cleanUpContext(); + ReusableStringStream::cleanup(); + } + std::string translateActiveException() { + return getRegistryHub().getExceptionTranslatorRegistry().translateActiveException(); + } + +} // end namespace Catch +// end catch_registry_hub.cpp +// start catch_reporter_registry.cpp + +namespace Catch { + + ReporterRegistry::~ReporterRegistry() = default; + + IStreamingReporterPtr ReporterRegistry::create( std::string const& name, IConfigPtr const& config ) const { + auto it = m_factories.find( name ); + if( it == m_factories.end() ) + return nullptr; + return it->second->create( ReporterConfig( config ) ); + } + + void ReporterRegistry::registerReporter( std::string const& name, IReporterFactoryPtr const& factory ) { + m_factories.emplace(name, factory); + } + void ReporterRegistry::registerListener( IReporterFactoryPtr const& factory ) { + m_listeners.push_back( factory ); + } + + IReporterRegistry::FactoryMap const& ReporterRegistry::getFactories() const { + return m_factories; + } + IReporterRegistry::Listeners const& ReporterRegistry::getListeners() const { + return m_listeners; + } + +} +// end catch_reporter_registry.cpp +// start catch_result_type.cpp + +namespace Catch { + + bool isOk( ResultWas::OfType resultType ) { + return ( resultType & ResultWas::FailureBit ) == 0; + } + bool isJustInfo( int flags ) { + return flags == ResultWas::Info; + } + + ResultDisposition::Flags operator | ( ResultDisposition::Flags lhs, ResultDisposition::Flags rhs ) { + return static_cast( static_cast( lhs ) | static_cast( rhs ) ); + } + + bool shouldContinueOnFailure( int flags ) { return ( flags & ResultDisposition::ContinueOnFailure ) != 0; } + bool shouldSuppressFailure( int flags ) { return ( flags & ResultDisposition::SuppressFail ) != 0; } + +} // end namespace Catch +// end catch_result_type.cpp +// start catch_run_context.cpp + +#include +#include +#include + +namespace Catch { + + RunContext::RunContext(IConfigPtr const& _config, IStreamingReporterPtr&& reporter) + : m_runInfo(_config->name()), + m_context(getCurrentMutableContext()), + m_config(_config), + m_reporter(std::move(reporter)), + m_lastAssertionInfo{ StringRef(), SourceLineInfo("",0), StringRef(), ResultDisposition::Normal }, + m_includeSuccessfulResults( m_config->includeSuccessfulResults() || m_reporter->getPreferences().shouldReportAllAssertions ) + { + m_context.setRunner(this); + m_context.setConfig(m_config); + m_context.setResultCapture(this); + m_reporter->testRunStarting(m_runInfo); + } + + RunContext::~RunContext() { + m_reporter->testRunEnded(TestRunStats(m_runInfo, m_totals, aborting())); + } + + void RunContext::testGroupStarting(std::string const& testSpec, std::size_t groupIndex, std::size_t groupsCount) { + m_reporter->testGroupStarting(GroupInfo(testSpec, groupIndex, groupsCount)); + } + + void RunContext::testGroupEnded(std::string const& testSpec, Totals const& totals, std::size_t groupIndex, std::size_t groupsCount) { + m_reporter->testGroupEnded(TestGroupStats(GroupInfo(testSpec, groupIndex, groupsCount), totals, aborting())); + } + + Totals RunContext::runTest(TestCase const& testCase) { + Totals prevTotals = m_totals; + + std::string redirectedCout; + std::string redirectedCerr; + + auto const& testInfo = testCase.getTestCaseInfo(); + + m_reporter->testCaseStarting(testInfo); + + m_activeTestCase = &testCase; + + ITracker& rootTracker = m_trackerContext.startRun(); + assert(rootTracker.isSectionTracker()); + static_cast(rootTracker).addInitialFilters(m_config->getSectionsToRun()); + do { + m_trackerContext.startCycle(); + m_testCaseTracker = &SectionTracker::acquire(m_trackerContext, TestCaseTracking::NameAndLocation(testInfo.name, testInfo.lineInfo)); + runCurrentTest(redirectedCout, redirectedCerr); + } while (!m_testCaseTracker->isSuccessfullyCompleted() && !aborting()); + + Totals deltaTotals = m_totals.delta(prevTotals); + if (testInfo.expectedToFail() && deltaTotals.testCases.passed > 0) { + deltaTotals.assertions.failed++; + deltaTotals.testCases.passed--; + deltaTotals.testCases.failed++; + } + m_totals.testCases += deltaTotals.testCases; + m_reporter->testCaseEnded(TestCaseStats(testInfo, + deltaTotals, + redirectedCout, + redirectedCerr, + aborting())); + + m_activeTestCase = nullptr; + m_testCaseTracker = nullptr; + + return deltaTotals; + } + + IConfigPtr RunContext::config() const { + return m_config; + } + + IStreamingReporter& RunContext::reporter() const { + return *m_reporter; + } + + void RunContext::assertionEnded(AssertionResult const & result) { + if (result.getResultType() == ResultWas::Ok) { + m_totals.assertions.passed++; + m_lastAssertionPassed = true; + } else if (!result.isOk()) { + m_lastAssertionPassed = false; + if( m_activeTestCase->getTestCaseInfo().okToFail() ) + m_totals.assertions.failedButOk++; + else + m_totals.assertions.failed++; + } + else { + m_lastAssertionPassed = true; + } + + // We have no use for the return value (whether messages should be cleared), because messages were made scoped + // and should be let to clear themselves out. + static_cast(m_reporter->assertionEnded(AssertionStats(result, m_messages, m_totals))); + + // Reset working state + resetAssertionInfo(); + m_lastResult = result; + } + void RunContext::resetAssertionInfo() { + m_lastAssertionInfo.macroName = StringRef(); + m_lastAssertionInfo.capturedExpression = "{Unknown expression after the reported line}"_sr; + } + + bool RunContext::sectionStarted(SectionInfo const & sectionInfo, Counts & assertions) { + ITracker& sectionTracker = SectionTracker::acquire(m_trackerContext, TestCaseTracking::NameAndLocation(sectionInfo.name, sectionInfo.lineInfo)); + if (!sectionTracker.isOpen()) + return false; + m_activeSections.push_back(§ionTracker); + + m_lastAssertionInfo.lineInfo = sectionInfo.lineInfo; + + m_reporter->sectionStarting(sectionInfo); + + assertions = m_totals.assertions; + + return true; + } + + bool RunContext::testForMissingAssertions(Counts& assertions) { + if (assertions.total() != 0) + return false; + if (!m_config->warnAboutMissingAssertions()) + return false; + if (m_trackerContext.currentTracker().hasChildren()) + return false; + m_totals.assertions.failed++; + assertions.failed++; + return true; + } + + void RunContext::sectionEnded(SectionEndInfo const & endInfo) { + Counts assertions = m_totals.assertions - endInfo.prevAssertions; + bool missingAssertions = testForMissingAssertions(assertions); + + if (!m_activeSections.empty()) { + m_activeSections.back()->close(); + m_activeSections.pop_back(); + } + + m_reporter->sectionEnded(SectionStats(endInfo.sectionInfo, assertions, endInfo.durationInSeconds, missingAssertions)); + m_messages.clear(); + } + + void RunContext::sectionEndedEarly(SectionEndInfo const & endInfo) { + if (m_unfinishedSections.empty()) + m_activeSections.back()->fail(); + else + m_activeSections.back()->close(); + m_activeSections.pop_back(); + + m_unfinishedSections.push_back(endInfo); + } + void RunContext::benchmarkStarting( BenchmarkInfo const& info ) { + m_reporter->benchmarkStarting( info ); + } + void RunContext::benchmarkEnded( BenchmarkStats const& stats ) { + m_reporter->benchmarkEnded( stats ); + } + + void RunContext::pushScopedMessage(MessageInfo const & message) { + m_messages.push_back(message); + } + + void RunContext::popScopedMessage(MessageInfo const & message) { + m_messages.erase(std::remove(m_messages.begin(), m_messages.end(), message), m_messages.end()); + } + + std::string RunContext::getCurrentTestName() const { + return m_activeTestCase + ? m_activeTestCase->getTestCaseInfo().name + : std::string(); + } + + const AssertionResult * RunContext::getLastResult() const { + return &(*m_lastResult); + } + + void RunContext::exceptionEarlyReported() { + m_shouldReportUnexpected = false; + } + + void RunContext::handleFatalErrorCondition( StringRef message ) { + // First notify reporter that bad things happened + m_reporter->fatalErrorEncountered(message); + + // Don't rebuild the result -- the stringification itself can cause more fatal errors + // Instead, fake a result data. + AssertionResultData tempResult( ResultWas::FatalErrorCondition, { false } ); + tempResult.message = message; + AssertionResult result(m_lastAssertionInfo, tempResult); + + assertionEnded(result); + + handleUnfinishedSections(); + + // Recreate section for test case (as we will lose the one that was in scope) + auto const& testCaseInfo = m_activeTestCase->getTestCaseInfo(); + SectionInfo testCaseSection(testCaseInfo.lineInfo, testCaseInfo.name); + + Counts assertions; + assertions.failed = 1; + SectionStats testCaseSectionStats(testCaseSection, assertions, 0, false); + m_reporter->sectionEnded(testCaseSectionStats); + + auto const& testInfo = m_activeTestCase->getTestCaseInfo(); + + Totals deltaTotals; + deltaTotals.testCases.failed = 1; + deltaTotals.assertions.failed = 1; + m_reporter->testCaseEnded(TestCaseStats(testInfo, + deltaTotals, + std::string(), + std::string(), + false)); + m_totals.testCases.failed++; + testGroupEnded(std::string(), m_totals, 1, 1); + m_reporter->testRunEnded(TestRunStats(m_runInfo, m_totals, false)); + } + + bool RunContext::lastAssertionPassed() { + return m_lastAssertionPassed; + } + + void RunContext::assertionPassed() { + m_lastAssertionPassed = true; + ++m_totals.assertions.passed; + resetAssertionInfo(); + } + + bool RunContext::aborting() const { + return m_totals.assertions.failed == static_cast(m_config->abortAfter()); + } + + void RunContext::runCurrentTest(std::string & redirectedCout, std::string & redirectedCerr) { + auto const& testCaseInfo = m_activeTestCase->getTestCaseInfo(); + SectionInfo testCaseSection(testCaseInfo.lineInfo, testCaseInfo.name); + m_reporter->sectionStarting(testCaseSection); + Counts prevAssertions = m_totals.assertions; + double duration = 0; + m_shouldReportUnexpected = true; + m_lastAssertionInfo = { "TEST_CASE"_sr, testCaseInfo.lineInfo, StringRef(), ResultDisposition::Normal }; + + seedRng(*m_config); + + Timer timer; + try { + if (m_reporter->getPreferences().shouldRedirectStdOut) { +#if !defined(CATCH_CONFIG_EXPERIMENTAL_REDIRECT) + RedirectedStdOut redirectedStdOut; + RedirectedStdErr redirectedStdErr; + + timer.start(); + invokeActiveTestCase(); + redirectedCout += redirectedStdOut.str(); + redirectedCerr += redirectedStdErr.str(); +#else + OutputRedirect r(redirectedCout, redirectedCerr); + timer.start(); + invokeActiveTestCase(); +#endif + } else { + timer.start(); + invokeActiveTestCase(); + } + duration = timer.getElapsedSeconds(); + } catch (TestFailureException&) { + // This just means the test was aborted due to failure + } catch (...) { + // Under CATCH_CONFIG_FAST_COMPILE, unexpected exceptions under REQUIRE assertions + // are reported without translation at the point of origin. + if( m_shouldReportUnexpected ) { + AssertionReaction dummyReaction; + handleUnexpectedInflightException( m_lastAssertionInfo, translateActiveException(), dummyReaction ); + } + } + Counts assertions = m_totals.assertions - prevAssertions; + bool missingAssertions = testForMissingAssertions(assertions); + + m_testCaseTracker->close(); + handleUnfinishedSections(); + m_messages.clear(); + + SectionStats testCaseSectionStats(testCaseSection, assertions, duration, missingAssertions); + m_reporter->sectionEnded(testCaseSectionStats); + } + + void RunContext::invokeActiveTestCase() { + FatalConditionHandler fatalConditionHandler; // Handle signals + m_activeTestCase->invoke(); + fatalConditionHandler.reset(); + } + + void RunContext::handleUnfinishedSections() { + // If sections ended prematurely due to an exception we stored their + // infos here so we can tear them down outside the unwind process. + for (auto it = m_unfinishedSections.rbegin(), + itEnd = m_unfinishedSections.rend(); + it != itEnd; + ++it) + sectionEnded(*it); + m_unfinishedSections.clear(); + } + + void RunContext::handleExpr( + AssertionInfo const& info, + ITransientExpression const& expr, + AssertionReaction& reaction + ) { + m_reporter->assertionStarting( info ); + + bool negated = isFalseTest( info.resultDisposition ); + bool result = expr.getResult() != negated; + + if( result ) { + if (!m_includeSuccessfulResults) { + assertionPassed(); + } + else { + reportExpr(info, ResultWas::Ok, &expr, negated); + } + } + else { + reportExpr(info, ResultWas::ExpressionFailed, &expr, negated ); + populateReaction( reaction ); + } + } + void RunContext::reportExpr( + AssertionInfo const &info, + ResultWas::OfType resultType, + ITransientExpression const *expr, + bool negated ) { + + m_lastAssertionInfo = info; + AssertionResultData data( resultType, LazyExpression( negated ) ); + + AssertionResult assertionResult{ info, data }; + assertionResult.m_resultData.lazyExpression.m_transientExpression = expr; + + assertionEnded( assertionResult ); + } + + void RunContext::handleMessage( + AssertionInfo const& info, + ResultWas::OfType resultType, + StringRef const& message, + AssertionReaction& reaction + ) { + m_reporter->assertionStarting( info ); + + m_lastAssertionInfo = info; + + AssertionResultData data( resultType, LazyExpression( false ) ); + data.message = message; + AssertionResult assertionResult{ m_lastAssertionInfo, data }; + assertionEnded( assertionResult ); + if( !assertionResult.isOk() ) + populateReaction( reaction ); + } + void RunContext::handleUnexpectedExceptionNotThrown( + AssertionInfo const& info, + AssertionReaction& reaction + ) { + handleNonExpr(info, Catch::ResultWas::DidntThrowException, reaction); + } + + void RunContext::handleUnexpectedInflightException( + AssertionInfo const& info, + std::string const& message, + AssertionReaction& reaction + ) { + m_lastAssertionInfo = info; + + AssertionResultData data( ResultWas::ThrewException, LazyExpression( false ) ); + data.message = message; + AssertionResult assertionResult{ info, data }; + assertionEnded( assertionResult ); + populateReaction( reaction ); + } + + void RunContext::populateReaction( AssertionReaction& reaction ) { + reaction.shouldDebugBreak = m_config->shouldDebugBreak(); + reaction.shouldThrow = aborting() || (m_lastAssertionInfo.resultDisposition & ResultDisposition::Normal); + } + + void RunContext::handleIncomplete( + AssertionInfo const& info + ) { + m_lastAssertionInfo = info; + + AssertionResultData data( ResultWas::ThrewException, LazyExpression( false ) ); + data.message = "Exception translation was disabled by CATCH_CONFIG_FAST_COMPILE"; + AssertionResult assertionResult{ info, data }; + assertionEnded( assertionResult ); + } + void RunContext::handleNonExpr( + AssertionInfo const &info, + ResultWas::OfType resultType, + AssertionReaction &reaction + ) { + m_lastAssertionInfo = info; + + AssertionResultData data( resultType, LazyExpression( false ) ); + AssertionResult assertionResult{ info, data }; + assertionEnded( assertionResult ); + + if( !assertionResult.isOk() ) + populateReaction( reaction ); + } + + IResultCapture& getResultCapture() { + if (auto* capture = getCurrentContext().getResultCapture()) + return *capture; + else + CATCH_INTERNAL_ERROR("No result capture instance"); + } +} +// end catch_run_context.cpp +// start catch_section.cpp + +namespace Catch { + + Section::Section( SectionInfo const& info ) + : m_info( info ), + m_sectionIncluded( getResultCapture().sectionStarted( m_info, m_assertions ) ) + { + m_timer.start(); + } + + Section::~Section() { + if( m_sectionIncluded ) { + SectionEndInfo endInfo{ m_info, m_assertions, m_timer.getElapsedSeconds() }; + if( uncaught_exceptions() ) + getResultCapture().sectionEndedEarly( endInfo ); + else + getResultCapture().sectionEnded( endInfo ); + } + } + + // This indicates whether the section should be executed or not + Section::operator bool() const { + return m_sectionIncluded; + } + +} // end namespace Catch +// end catch_section.cpp +// start catch_section_info.cpp + +namespace Catch { + + SectionInfo::SectionInfo + ( SourceLineInfo const& _lineInfo, + std::string const& _name ) + : name( _name ), + lineInfo( _lineInfo ) + {} + +} // end namespace Catch +// end catch_section_info.cpp +// start catch_session.cpp + +// start catch_session.h + +#include + +namespace Catch { + + class Session : NonCopyable { + public: + + Session(); + ~Session() override; + + void showHelp() const; + void libIdentify(); + + int applyCommandLine( int argc, char const * const * argv ); + + void useConfigData( ConfigData const& configData ); + + int run( int argc, char* argv[] ); + #if defined(CATCH_CONFIG_WCHAR) && defined(WIN32) && defined(UNICODE) + int run( int argc, wchar_t* const argv[] ); + #endif + int run(); + + clara::Parser const& cli() const; + void cli( clara::Parser const& newParser ); + ConfigData& configData(); + Config& config(); + private: + int runInternal(); + + clara::Parser m_cli; + ConfigData m_configData; + std::shared_ptr m_config; + bool m_startupExceptions = false; + }; + +} // end namespace Catch + +// end catch_session.h +// start catch_version.h + +#include + +namespace Catch { + + // Versioning information + struct Version { + Version( Version const& ) = delete; + Version& operator=( Version const& ) = delete; + Version( unsigned int _majorVersion, + unsigned int _minorVersion, + unsigned int _patchNumber, + char const * const _branchName, + unsigned int _buildNumber ); + + unsigned int const majorVersion; + unsigned int const minorVersion; + unsigned int const patchNumber; + + // buildNumber is only used if branchName is not null + char const * const branchName; + unsigned int const buildNumber; + + friend std::ostream& operator << ( std::ostream& os, Version const& version ); + }; + + Version const& libraryVersion(); +} + +// end catch_version.h +#include +#include + +namespace Catch { + + namespace { + const int MaxExitCode = 255; + + IStreamingReporterPtr createReporter(std::string const& reporterName, IConfigPtr const& config) { + auto reporter = Catch::getRegistryHub().getReporterRegistry().create(reporterName, config); + CATCH_ENFORCE(reporter, "No reporter registered with name: '" << reporterName << "'"); + + return reporter; + } + + IStreamingReporterPtr makeReporter(std::shared_ptr const& config) { + if (Catch::getRegistryHub().getReporterRegistry().getListeners().empty()) { + return createReporter(config->getReporterName(), config); + } + + auto multi = std::unique_ptr(new ListeningReporter); + + auto const& listeners = Catch::getRegistryHub().getReporterRegistry().getListeners(); + for (auto const& listener : listeners) { + multi->addListener(listener->create(Catch::ReporterConfig(config))); + } + multi->addReporter(createReporter(config->getReporterName(), config)); + return std::move(multi); + } + + Catch::Totals runTests(std::shared_ptr const& config) { + // FixMe: Add listeners in order first, then add reporters. + + auto reporter = makeReporter(config); + + RunContext context(config, std::move(reporter)); + + Totals totals; + + context.testGroupStarting(config->name(), 1, 1); + + TestSpec testSpec = config->testSpec(); + + auto const& allTestCases = getAllTestCasesSorted(*config); + for (auto const& testCase : allTestCases) { + if (!context.aborting() && matchTest(testCase, testSpec, *config)) + totals += context.runTest(testCase); + else + context.reporter().skipTest(testCase); + } + + if (config->warnAboutNoTests() && totals.testCases.total() == 0) { + ReusableStringStream testConfig; + + bool first = true; + for (const auto& input : config->getTestsOrTags()) { + if (!first) { testConfig << ' '; } + first = false; + testConfig << input; + } + + context.reporter().noMatchingTestCases(testConfig.str()); + totals.error = -1; + } + + context.testGroupEnded(config->name(), totals, 1, 1); + return totals; + } + + void applyFilenamesAsTags(Catch::IConfig const& config) { + auto& tests = const_cast&>(getAllTestCasesSorted(config)); + for (auto& testCase : tests) { + auto tags = testCase.tags; + + std::string filename = testCase.lineInfo.file; + auto lastSlash = filename.find_last_of("\\/"); + if (lastSlash != std::string::npos) { + filename.erase(0, lastSlash); + filename[0] = '#'; + } + + auto lastDot = filename.find_last_of('.'); + if (lastDot != std::string::npos) { + filename.erase(lastDot); + } + + tags.push_back(std::move(filename)); + setTags(testCase, tags); + } + } + + } // anon namespace + + Session::Session() { + static bool alreadyInstantiated = false; + if( alreadyInstantiated ) { + try { CATCH_INTERNAL_ERROR( "Only one instance of Catch::Session can ever be used" ); } + catch(...) { getMutableRegistryHub().registerStartupException(); } + } + + const auto& exceptions = getRegistryHub().getStartupExceptionRegistry().getExceptions(); + if ( !exceptions.empty() ) { + m_startupExceptions = true; + Colour colourGuard( Colour::Red ); + Catch::cerr() << "Errors occurred during startup!" << '\n'; + // iterate over all exceptions and notify user + for ( const auto& ex_ptr : exceptions ) { + try { + std::rethrow_exception(ex_ptr); + } catch ( std::exception const& ex ) { + Catch::cerr() << Column( ex.what() ).indent(2) << '\n'; + } + } + } + + alreadyInstantiated = true; + m_cli = makeCommandLineParser( m_configData ); + } + Session::~Session() { + Catch::cleanUp(); + } + + void Session::showHelp() const { + Catch::cout() + << "\nCatch v" << libraryVersion() << "\n" + << m_cli << std::endl + << "For more detailed usage please see the project docs\n" << std::endl; + } + void Session::libIdentify() { + Catch::cout() + << std::left << std::setw(16) << "description: " << "A Catch test executable\n" + << std::left << std::setw(16) << "category: " << "testframework\n" + << std::left << std::setw(16) << "framework: " << "Catch Test\n" + << std::left << std::setw(16) << "version: " << libraryVersion() << std::endl; + } + + int Session::applyCommandLine( int argc, char const * const * argv ) { + if( m_startupExceptions ) + return 1; + + auto result = m_cli.parse( clara::Args( argc, argv ) ); + if( !result ) { + Catch::cerr() + << Colour( Colour::Red ) + << "\nError(s) in input:\n" + << Column( result.errorMessage() ).indent( 2 ) + << "\n\n"; + Catch::cerr() << "Run with -? for usage\n" << std::endl; + return MaxExitCode; + } + + if( m_configData.showHelp ) + showHelp(); + if( m_configData.libIdentify ) + libIdentify(); + m_config.reset(); + return 0; + } + + void Session::useConfigData( ConfigData const& configData ) { + m_configData = configData; + m_config.reset(); + } + + int Session::run( int argc, char* argv[] ) { + if( m_startupExceptions ) + return 1; + int returnCode = applyCommandLine( argc, argv ); + if( returnCode == 0 ) + returnCode = run(); + return returnCode; + } + +#if defined(CATCH_CONFIG_WCHAR) && defined(WIN32) && defined(UNICODE) + int Session::run( int argc, wchar_t* const argv[] ) { + + char **utf8Argv = new char *[ argc ]; + + for ( int i = 0; i < argc; ++i ) { + int bufSize = WideCharToMultiByte( CP_UTF8, 0, argv[i], -1, NULL, 0, NULL, NULL ); + + utf8Argv[ i ] = new char[ bufSize ]; + + WideCharToMultiByte( CP_UTF8, 0, argv[i], -1, utf8Argv[i], bufSize, NULL, NULL ); + } + + int returnCode = run( argc, utf8Argv ); + + for ( int i = 0; i < argc; ++i ) + delete [] utf8Argv[ i ]; + + delete [] utf8Argv; + + return returnCode; + } +#endif + int Session::run() { + if( ( m_configData.waitForKeypress & WaitForKeypress::BeforeStart ) != 0 ) { + Catch::cout() << "...waiting for enter/ return before starting" << std::endl; + static_cast(std::getchar()); + } + int exitCode = runInternal(); + if( ( m_configData.waitForKeypress & WaitForKeypress::BeforeExit ) != 0 ) { + Catch::cout() << "...waiting for enter/ return before exiting, with code: " << exitCode << std::endl; + static_cast(std::getchar()); + } + return exitCode; + } + + clara::Parser const& Session::cli() const { + return m_cli; + } + void Session::cli( clara::Parser const& newParser ) { + m_cli = newParser; + } + ConfigData& Session::configData() { + return m_configData; + } + Config& Session::config() { + if( !m_config ) + m_config = std::make_shared( m_configData ); + return *m_config; + } + + int Session::runInternal() { + if( m_startupExceptions ) + return 1; + + if( m_configData.showHelp || m_configData.libIdentify ) + return 0; + + try + { + config(); // Force config to be constructed + + seedRng( *m_config ); + + if( m_configData.filenamesAsTags ) + applyFilenamesAsTags( *m_config ); + + // Handle list request + if( Option listed = list( config() ) ) + return static_cast( *listed ); + + auto totals = runTests( m_config ); + // Note that on unices only the lower 8 bits are usually used, clamping + // the return value to 255 prevents false negative when some multiple + // of 256 tests has failed + return (std::min) (MaxExitCode, (std::max) (totals.error, static_cast(totals.assertions.failed))); + } + catch( std::exception& ex ) { + Catch::cerr() << ex.what() << std::endl; + return MaxExitCode; + } + } + +} // end namespace Catch +// end catch_session.cpp +// start catch_startup_exception_registry.cpp + +namespace Catch { + void StartupExceptionRegistry::add( std::exception_ptr const& exception ) noexcept { + try { + m_exceptions.push_back(exception); + } + catch(...) { + // If we run out of memory during start-up there's really not a lot more we can do about it + std::terminate(); + } + } + + std::vector const& StartupExceptionRegistry::getExceptions() const noexcept { + return m_exceptions; + } + +} // end namespace Catch +// end catch_startup_exception_registry.cpp +// start catch_stream.cpp + +#include +#include +#include +#include +#include +#include + +#if defined(__clang__) +# pragma clang diagnostic push +# pragma clang diagnostic ignored "-Wexit-time-destructors" +#endif + +namespace Catch { + + Catch::IStream::~IStream() = default; + + namespace detail { namespace { + template + class StreamBufImpl : public std::streambuf { + char data[bufferSize]; + WriterF m_writer; + + public: + StreamBufImpl() { + setp( data, data + sizeof(data) ); + } + + ~StreamBufImpl() noexcept { + StreamBufImpl::sync(); + } + + private: + int overflow( int c ) override { + sync(); + + if( c != EOF ) { + if( pbase() == epptr() ) + m_writer( std::string( 1, static_cast( c ) ) ); + else + sputc( static_cast( c ) ); + } + return 0; + } + + int sync() override { + if( pbase() != pptr() ) { + m_writer( std::string( pbase(), static_cast( pptr() - pbase() ) ) ); + setp( pbase(), epptr() ); + } + return 0; + } + }; + + /////////////////////////////////////////////////////////////////////////// + + struct OutputDebugWriter { + + void operator()( std::string const&str ) { + writeToDebugConsole( str ); + } + }; + + /////////////////////////////////////////////////////////////////////////// + + class FileStream : public IStream { + mutable std::ofstream m_ofs; + public: + FileStream( StringRef filename ) { + m_ofs.open( filename.c_str() ); + CATCH_ENFORCE( !m_ofs.fail(), "Unable to open file: '" << filename << "'" ); + } + ~FileStream() override = default; + public: // IStream + std::ostream& stream() const override { + return m_ofs; + } + }; + + /////////////////////////////////////////////////////////////////////////// + + class CoutStream : public IStream { + mutable std::ostream m_os; + public: + // Store the streambuf from cout up-front because + // cout may get redirected when running tests + CoutStream() : m_os( Catch::cout().rdbuf() ) {} + ~CoutStream() override = default; + + public: // IStream + std::ostream& stream() const override { return m_os; } + }; + + /////////////////////////////////////////////////////////////////////////// + + class DebugOutStream : public IStream { + std::unique_ptr> m_streamBuf; + mutable std::ostream m_os; + public: + DebugOutStream() + : m_streamBuf( new StreamBufImpl() ), + m_os( m_streamBuf.get() ) + {} + + ~DebugOutStream() override = default; + + public: // IStream + std::ostream& stream() const override { return m_os; } + }; + + }} // namespace anon::detail + + /////////////////////////////////////////////////////////////////////////// + + auto makeStream( StringRef const &filename ) -> IStream const* { + if( filename.empty() ) + return new detail::CoutStream(); + else if( filename[0] == '%' ) { + if( filename == "%debug" ) + return new detail::DebugOutStream(); + else + CATCH_ERROR( "Unrecognised stream: '" << filename << "'" ); + } + else + return new detail::FileStream( filename ); + } + + // This class encapsulates the idea of a pool of ostringstreams that can be reused. + struct StringStreams { + std::vector> m_streams; + std::vector m_unused; + std::ostringstream m_referenceStream; // Used for copy state/ flags from + static StringStreams* s_instance; + + auto add() -> std::size_t { + if( m_unused.empty() ) { + m_streams.push_back( std::unique_ptr( new std::ostringstream ) ); + return m_streams.size()-1; + } + else { + auto index = m_unused.back(); + m_unused.pop_back(); + return index; + } + } + + void release( std::size_t index ) { + m_streams[index]->copyfmt( m_referenceStream ); // Restore initial flags and other state + m_unused.push_back(index); + } + + // !TBD: put in TLS + static auto instance() -> StringStreams& { + if( !s_instance ) + s_instance = new StringStreams(); + return *s_instance; + } + static void cleanup() { + delete s_instance; + s_instance = nullptr; + } + }; + + StringStreams* StringStreams::s_instance = nullptr; + + void ReusableStringStream::cleanup() { + StringStreams::cleanup(); + } + + ReusableStringStream::ReusableStringStream() + : m_index( StringStreams::instance().add() ), + m_oss( StringStreams::instance().m_streams[m_index].get() ) + {} + + ReusableStringStream::~ReusableStringStream() { + static_cast( m_oss )->str(""); + m_oss->clear(); + StringStreams::instance().release( m_index ); + } + + auto ReusableStringStream::str() const -> std::string { + return static_cast( m_oss )->str(); + } + + /////////////////////////////////////////////////////////////////////////// + +#ifndef CATCH_CONFIG_NOSTDOUT // If you #define this you must implement these functions + std::ostream& cout() { return std::cout; } + std::ostream& cerr() { return std::cerr; } + std::ostream& clog() { return std::clog; } +#endif +} + +#if defined(__clang__) +# pragma clang diagnostic pop +#endif +// end catch_stream.cpp +// start catch_string_manip.cpp + +#include +#include +#include +#include + +namespace Catch { + + namespace { + char toLowerCh(char c) { + return static_cast( std::tolower( c ) ); + } + } + + bool startsWith( std::string const& s, std::string const& prefix ) { + return s.size() >= prefix.size() && std::equal(prefix.begin(), prefix.end(), s.begin()); + } + bool startsWith( std::string const& s, char prefix ) { + return !s.empty() && s[0] == prefix; + } + bool endsWith( std::string const& s, std::string const& suffix ) { + return s.size() >= suffix.size() && std::equal(suffix.rbegin(), suffix.rend(), s.rbegin()); + } + bool endsWith( std::string const& s, char suffix ) { + return !s.empty() && s[s.size()-1] == suffix; + } + bool contains( std::string const& s, std::string const& infix ) { + return s.find( infix ) != std::string::npos; + } + void toLowerInPlace( std::string& s ) { + std::transform( s.begin(), s.end(), s.begin(), toLowerCh ); + } + std::string toLower( std::string const& s ) { + std::string lc = s; + toLowerInPlace( lc ); + return lc; + } + std::string trim( std::string const& str ) { + static char const* whitespaceChars = "\n\r\t "; + std::string::size_type start = str.find_first_not_of( whitespaceChars ); + std::string::size_type end = str.find_last_not_of( whitespaceChars ); + + return start != std::string::npos ? str.substr( start, 1+end-start ) : std::string(); + } + + bool replaceInPlace( std::string& str, std::string const& replaceThis, std::string const& withThis ) { + bool replaced = false; + std::size_t i = str.find( replaceThis ); + while( i != std::string::npos ) { + replaced = true; + str = str.substr( 0, i ) + withThis + str.substr( i+replaceThis.size() ); + if( i < str.size()-withThis.size() ) + i = str.find( replaceThis, i+withThis.size() ); + else + i = std::string::npos; + } + return replaced; + } + + pluralise::pluralise( std::size_t count, std::string const& label ) + : m_count( count ), + m_label( label ) + {} + + std::ostream& operator << ( std::ostream& os, pluralise const& pluraliser ) { + os << pluraliser.m_count << ' ' << pluraliser.m_label; + if( pluraliser.m_count != 1 ) + os << 's'; + return os; + } + +} +// end catch_string_manip.cpp +// start catch_stringref.cpp + +#if defined(__clang__) +# pragma clang diagnostic push +# pragma clang diagnostic ignored "-Wexit-time-destructors" +#endif + +#include +#include +#include + +namespace { + const uint32_t byte_2_lead = 0xC0; + const uint32_t byte_3_lead = 0xE0; + const uint32_t byte_4_lead = 0xF0; +} + +namespace Catch { + StringRef::StringRef( char const* rawChars ) noexcept + : StringRef( rawChars, static_cast(std::strlen(rawChars) ) ) + {} + + StringRef::operator std::string() const { + return std::string( m_start, m_size ); + } + + void StringRef::swap( StringRef& other ) noexcept { + std::swap( m_start, other.m_start ); + std::swap( m_size, other.m_size ); + std::swap( m_data, other.m_data ); + } + + auto StringRef::c_str() const -> char const* { + if( isSubstring() ) + const_cast( this )->takeOwnership(); + return m_start; + } + auto StringRef::currentData() const noexcept -> char const* { + return m_start; + } + + auto StringRef::isOwned() const noexcept -> bool { + return m_data != nullptr; + } + auto StringRef::isSubstring() const noexcept -> bool { + return m_start[m_size] != '\0'; + } + + void StringRef::takeOwnership() { + if( !isOwned() ) { + m_data = new char[m_size+1]; + memcpy( m_data, m_start, m_size ); + m_data[m_size] = '\0'; + m_start = m_data; + } + } + auto StringRef::substr( size_type start, size_type size ) const noexcept -> StringRef { + if( start < m_size ) + return StringRef( m_start+start, size ); + else + return StringRef(); + } + auto StringRef::operator == ( StringRef const& other ) const noexcept -> bool { + return + size() == other.size() && + (std::strncmp( m_start, other.m_start, size() ) == 0); + } + auto StringRef::operator != ( StringRef const& other ) const noexcept -> bool { + return !operator==( other ); + } + + auto StringRef::operator[](size_type index) const noexcept -> char { + return m_start[index]; + } + + auto StringRef::numberOfCharacters() const noexcept -> size_type { + size_type noChars = m_size; + // Make adjustments for uft encodings + for( size_type i=0; i < m_size; ++i ) { + char c = m_start[i]; + if( ( c & byte_2_lead ) == byte_2_lead ) { + noChars--; + if (( c & byte_3_lead ) == byte_3_lead ) + noChars--; + if( ( c & byte_4_lead ) == byte_4_lead ) + noChars--; + } + } + return noChars; + } + + auto operator + ( StringRef const& lhs, StringRef const& rhs ) -> std::string { + std::string str; + str.reserve( lhs.size() + rhs.size() ); + str += lhs; + str += rhs; + return str; + } + auto operator + ( StringRef const& lhs, const char* rhs ) -> std::string { + return std::string( lhs ) + std::string( rhs ); + } + auto operator + ( char const* lhs, StringRef const& rhs ) -> std::string { + return std::string( lhs ) + std::string( rhs ); + } + + auto operator << ( std::ostream& os, StringRef const& str ) -> std::ostream& { + return os.write(str.currentData(), str.size()); + } + + auto operator+=( std::string& lhs, StringRef const& rhs ) -> std::string& { + lhs.append(rhs.currentData(), rhs.size()); + return lhs; + } + +} // namespace Catch + +#if defined(__clang__) +# pragma clang diagnostic pop +#endif +// end catch_stringref.cpp +// start catch_tag_alias.cpp + +namespace Catch { + TagAlias::TagAlias(std::string const & _tag, SourceLineInfo _lineInfo): tag(_tag), lineInfo(_lineInfo) {} +} +// end catch_tag_alias.cpp +// start catch_tag_alias_autoregistrar.cpp + +namespace Catch { + + RegistrarForTagAliases::RegistrarForTagAliases(char const* alias, char const* tag, SourceLineInfo const& lineInfo) { + try { + getMutableRegistryHub().registerTagAlias(alias, tag, lineInfo); + } catch (...) { + // Do not throw when constructing global objects, instead register the exception to be processed later + getMutableRegistryHub().registerStartupException(); + } + } + +} +// end catch_tag_alias_autoregistrar.cpp +// start catch_tag_alias_registry.cpp + +#include + +namespace Catch { + + TagAliasRegistry::~TagAliasRegistry() {} + + TagAlias const* TagAliasRegistry::find( std::string const& alias ) const { + auto it = m_registry.find( alias ); + if( it != m_registry.end() ) + return &(it->second); + else + return nullptr; + } + + std::string TagAliasRegistry::expandAliases( std::string const& unexpandedTestSpec ) const { + std::string expandedTestSpec = unexpandedTestSpec; + for( auto const& registryKvp : m_registry ) { + std::size_t pos = expandedTestSpec.find( registryKvp.first ); + if( pos != std::string::npos ) { + expandedTestSpec = expandedTestSpec.substr( 0, pos ) + + registryKvp.second.tag + + expandedTestSpec.substr( pos + registryKvp.first.size() ); + } + } + return expandedTestSpec; + } + + void TagAliasRegistry::add( std::string const& alias, std::string const& tag, SourceLineInfo const& lineInfo ) { + CATCH_ENFORCE( startsWith(alias, "[@") && endsWith(alias, ']'), + "error: tag alias, '" << alias << "' is not of the form [@alias name].\n" << lineInfo ); + + CATCH_ENFORCE( m_registry.insert(std::make_pair(alias, TagAlias(tag, lineInfo))).second, + "error: tag alias, '" << alias << "' already registered.\n" + << "\tFirst seen at: " << find(alias)->lineInfo << "\n" + << "\tRedefined at: " << lineInfo ); + } + + ITagAliasRegistry::~ITagAliasRegistry() {} + + ITagAliasRegistry const& ITagAliasRegistry::get() { + return getRegistryHub().getTagAliasRegistry(); + } + +} // end namespace Catch +// end catch_tag_alias_registry.cpp +// start catch_test_case_info.cpp + +#include +#include +#include +#include + +namespace Catch { + + namespace { + TestCaseInfo::SpecialProperties parseSpecialTag( std::string const& tag ) { + if( startsWith( tag, '.' ) || + tag == "!hide" ) + return TestCaseInfo::IsHidden; + else if( tag == "!throws" ) + return TestCaseInfo::Throws; + else if( tag == "!shouldfail" ) + return TestCaseInfo::ShouldFail; + else if( tag == "!mayfail" ) + return TestCaseInfo::MayFail; + else if( tag == "!nonportable" ) + return TestCaseInfo::NonPortable; + else if( tag == "!benchmark" ) + return static_cast( TestCaseInfo::Benchmark | TestCaseInfo::IsHidden ); + else + return TestCaseInfo::None; + } + bool isReservedTag( std::string const& tag ) { + return parseSpecialTag( tag ) == TestCaseInfo::None && tag.size() > 0 && !std::isalnum( static_cast(tag[0]) ); + } + void enforceNotReservedTag( std::string const& tag, SourceLineInfo const& _lineInfo ) { + CATCH_ENFORCE( !isReservedTag(tag), + "Tag name: [" << tag << "] is not allowed.\n" + << "Tag names starting with non alpha-numeric characters are reserved\n" + << _lineInfo ); + } + } + + TestCase makeTestCase( ITestInvoker* _testCase, + std::string const& _className, + NameAndTags const& nameAndTags, + SourceLineInfo const& _lineInfo ) + { + bool isHidden = false; + + // Parse out tags + std::vector tags; + std::string desc, tag; + bool inTag = false; + std::string _descOrTags = nameAndTags.tags; + for (char c : _descOrTags) { + if( !inTag ) { + if( c == '[' ) + inTag = true; + else + desc += c; + } + else { + if( c == ']' ) { + TestCaseInfo::SpecialProperties prop = parseSpecialTag( tag ); + if( ( prop & TestCaseInfo::IsHidden ) != 0 ) + isHidden = true; + else if( prop == TestCaseInfo::None ) + enforceNotReservedTag( tag, _lineInfo ); + + tags.push_back( tag ); + tag.clear(); + inTag = false; + } + else + tag += c; + } + } + if( isHidden ) { + tags.push_back( "." ); + } + + TestCaseInfo info( nameAndTags.name, _className, desc, tags, _lineInfo ); + return TestCase( _testCase, std::move(info) ); + } + + void setTags( TestCaseInfo& testCaseInfo, std::vector tags ) { + std::sort(begin(tags), end(tags)); + tags.erase(std::unique(begin(tags), end(tags)), end(tags)); + testCaseInfo.lcaseTags.clear(); + + for( auto const& tag : tags ) { + std::string lcaseTag = toLower( tag ); + testCaseInfo.properties = static_cast( testCaseInfo.properties | parseSpecialTag( lcaseTag ) ); + testCaseInfo.lcaseTags.push_back( lcaseTag ); + } + testCaseInfo.tags = std::move(tags); + } + + TestCaseInfo::TestCaseInfo( std::string const& _name, + std::string const& _className, + std::string const& _description, + std::vector const& _tags, + SourceLineInfo const& _lineInfo ) + : name( _name ), + className( _className ), + description( _description ), + lineInfo( _lineInfo ), + properties( None ) + { + setTags( *this, _tags ); + } + + bool TestCaseInfo::isHidden() const { + return ( properties & IsHidden ) != 0; + } + bool TestCaseInfo::throws() const { + return ( properties & Throws ) != 0; + } + bool TestCaseInfo::okToFail() const { + return ( properties & (ShouldFail | MayFail ) ) != 0; + } + bool TestCaseInfo::expectedToFail() const { + return ( properties & (ShouldFail ) ) != 0; + } + + std::string TestCaseInfo::tagsAsString() const { + std::string ret; + // '[' and ']' per tag + std::size_t full_size = 2 * tags.size(); + for (const auto& tag : tags) { + full_size += tag.size(); + } + ret.reserve(full_size); + for (const auto& tag : tags) { + ret.push_back('['); + ret.append(tag); + ret.push_back(']'); + } + + return ret; + } + + TestCase::TestCase( ITestInvoker* testCase, TestCaseInfo&& info ) : TestCaseInfo( std::move(info) ), test( testCase ) {} + + TestCase TestCase::withName( std::string const& _newName ) const { + TestCase other( *this ); + other.name = _newName; + return other; + } + + void TestCase::invoke() const { + test->invoke(); + } + + bool TestCase::operator == ( TestCase const& other ) const { + return test.get() == other.test.get() && + name == other.name && + className == other.className; + } + + bool TestCase::operator < ( TestCase const& other ) const { + return name < other.name; + } + + TestCaseInfo const& TestCase::getTestCaseInfo() const + { + return *this; + } + +} // end namespace Catch +// end catch_test_case_info.cpp +// start catch_test_case_registry_impl.cpp + +#include + +namespace Catch { + + std::vector sortTests( IConfig const& config, std::vector const& unsortedTestCases ) { + + std::vector sorted = unsortedTestCases; + + switch( config.runOrder() ) { + case RunTests::InLexicographicalOrder: + std::sort( sorted.begin(), sorted.end() ); + break; + case RunTests::InRandomOrder: + seedRng( config ); + std::shuffle( sorted.begin(), sorted.end(), rng() ); + break; + case RunTests::InDeclarationOrder: + // already in declaration order + break; + } + return sorted; + } + bool matchTest( TestCase const& testCase, TestSpec const& testSpec, IConfig const& config ) { + return testSpec.matches( testCase ) && ( config.allowThrows() || !testCase.throws() ); + } + + void enforceNoDuplicateTestCases( std::vector const& functions ) { + std::set seenFunctions; + for( auto const& function : functions ) { + auto prev = seenFunctions.insert( function ); + CATCH_ENFORCE( prev.second, + "error: TEST_CASE( \"" << function.name << "\" ) already defined.\n" + << "\tFirst seen at " << prev.first->getTestCaseInfo().lineInfo << "\n" + << "\tRedefined at " << function.getTestCaseInfo().lineInfo ); + } + } + + std::vector filterTests( std::vector const& testCases, TestSpec const& testSpec, IConfig const& config ) { + std::vector filtered; + filtered.reserve( testCases.size() ); + for( auto const& testCase : testCases ) + if( matchTest( testCase, testSpec, config ) ) + filtered.push_back( testCase ); + return filtered; + } + std::vector const& getAllTestCasesSorted( IConfig const& config ) { + return getRegistryHub().getTestCaseRegistry().getAllTestsSorted( config ); + } + + void TestRegistry::registerTest( TestCase const& testCase ) { + std::string name = testCase.getTestCaseInfo().name; + if( name.empty() ) { + ReusableStringStream rss; + rss << "Anonymous test case " << ++m_unnamedCount; + return registerTest( testCase.withName( rss.str() ) ); + } + m_functions.push_back( testCase ); + } + + std::vector const& TestRegistry::getAllTests() const { + return m_functions; + } + std::vector const& TestRegistry::getAllTestsSorted( IConfig const& config ) const { + if( m_sortedFunctions.empty() ) + enforceNoDuplicateTestCases( m_functions ); + + if( m_currentSortOrder != config.runOrder() || m_sortedFunctions.empty() ) { + m_sortedFunctions = sortTests( config, m_functions ); + m_currentSortOrder = config.runOrder(); + } + return m_sortedFunctions; + } + + /////////////////////////////////////////////////////////////////////////// + TestInvokerAsFunction::TestInvokerAsFunction( void(*testAsFunction)() ) noexcept : m_testAsFunction( testAsFunction ) {} + + void TestInvokerAsFunction::invoke() const { + m_testAsFunction(); + } + + std::string extractClassName( StringRef const& classOrQualifiedMethodName ) { + std::string className = classOrQualifiedMethodName; + if( startsWith( className, '&' ) ) + { + std::size_t lastColons = className.rfind( "::" ); + std::size_t penultimateColons = className.rfind( "::", lastColons-1 ); + if( penultimateColons == std::string::npos ) + penultimateColons = 1; + className = className.substr( penultimateColons, lastColons-penultimateColons ); + } + return className; + } + +} // end namespace Catch +// end catch_test_case_registry_impl.cpp +// start catch_test_case_tracker.cpp + +#include +#include +#include +#include +#include + +#if defined(__clang__) +# pragma clang diagnostic push +# pragma clang diagnostic ignored "-Wexit-time-destructors" +#endif + +namespace Catch { +namespace TestCaseTracking { + + NameAndLocation::NameAndLocation( std::string const& _name, SourceLineInfo const& _location ) + : name( _name ), + location( _location ) + {} + + ITracker::~ITracker() = default; + + TrackerContext& TrackerContext::instance() { + static TrackerContext s_instance; + return s_instance; + } + + ITracker& TrackerContext::startRun() { + m_rootTracker = std::make_shared( NameAndLocation( "{root}", CATCH_INTERNAL_LINEINFO ), *this, nullptr ); + m_currentTracker = nullptr; + m_runState = Executing; + return *m_rootTracker; + } + + void TrackerContext::endRun() { + m_rootTracker.reset(); + m_currentTracker = nullptr; + m_runState = NotStarted; + } + + void TrackerContext::startCycle() { + m_currentTracker = m_rootTracker.get(); + m_runState = Executing; + } + void TrackerContext::completeCycle() { + m_runState = CompletedCycle; + } + + bool TrackerContext::completedCycle() const { + return m_runState == CompletedCycle; + } + ITracker& TrackerContext::currentTracker() { + return *m_currentTracker; + } + void TrackerContext::setCurrentTracker( ITracker* tracker ) { + m_currentTracker = tracker; + } + + TrackerBase::TrackerHasName::TrackerHasName( NameAndLocation const& nameAndLocation ) : m_nameAndLocation( nameAndLocation ) {} + bool TrackerBase::TrackerHasName::operator ()( ITrackerPtr const& tracker ) const { + return + tracker->nameAndLocation().location == m_nameAndLocation.location && + tracker->nameAndLocation().name == m_nameAndLocation.name; + } + + TrackerBase::TrackerBase( NameAndLocation const& nameAndLocation, TrackerContext& ctx, ITracker* parent ) + : m_nameAndLocation( nameAndLocation ), + m_ctx( ctx ), + m_parent( parent ) + {} + + NameAndLocation const& TrackerBase::nameAndLocation() const { + return m_nameAndLocation; + } + bool TrackerBase::isComplete() const { + return m_runState == CompletedSuccessfully || m_runState == Failed; + } + bool TrackerBase::isSuccessfullyCompleted() const { + return m_runState == CompletedSuccessfully; + } + bool TrackerBase::isOpen() const { + return m_runState != NotStarted && !isComplete(); + } + bool TrackerBase::hasChildren() const { + return !m_children.empty(); + } + + void TrackerBase::addChild( ITrackerPtr const& child ) { + m_children.push_back( child ); + } + + ITrackerPtr TrackerBase::findChild( NameAndLocation const& nameAndLocation ) { + auto it = std::find_if( m_children.begin(), m_children.end(), TrackerHasName( nameAndLocation ) ); + return( it != m_children.end() ) + ? *it + : nullptr; + } + ITracker& TrackerBase::parent() { + assert( m_parent ); // Should always be non-null except for root + return *m_parent; + } + + void TrackerBase::openChild() { + if( m_runState != ExecutingChildren ) { + m_runState = ExecutingChildren; + if( m_parent ) + m_parent->openChild(); + } + } + + bool TrackerBase::isSectionTracker() const { return false; } + bool TrackerBase::isIndexTracker() const { return false; } + + void TrackerBase::open() { + m_runState = Executing; + moveToThis(); + if( m_parent ) + m_parent->openChild(); + } + + void TrackerBase::close() { + + // Close any still open children (e.g. generators) + while( &m_ctx.currentTracker() != this ) + m_ctx.currentTracker().close(); + + switch( m_runState ) { + case NeedsAnotherRun: + break; + + case Executing: + m_runState = CompletedSuccessfully; + break; + case ExecutingChildren: + if( m_children.empty() || m_children.back()->isComplete() ) + m_runState = CompletedSuccessfully; + break; + + case NotStarted: + case CompletedSuccessfully: + case Failed: + CATCH_INTERNAL_ERROR( "Illogical state: " << m_runState ); + + default: + CATCH_INTERNAL_ERROR( "Unknown state: " << m_runState ); + } + moveToParent(); + m_ctx.completeCycle(); + } + void TrackerBase::fail() { + m_runState = Failed; + if( m_parent ) + m_parent->markAsNeedingAnotherRun(); + moveToParent(); + m_ctx.completeCycle(); + } + void TrackerBase::markAsNeedingAnotherRun() { + m_runState = NeedsAnotherRun; + } + + void TrackerBase::moveToParent() { + assert( m_parent ); + m_ctx.setCurrentTracker( m_parent ); + } + void TrackerBase::moveToThis() { + m_ctx.setCurrentTracker( this ); + } + + SectionTracker::SectionTracker( NameAndLocation const& nameAndLocation, TrackerContext& ctx, ITracker* parent ) + : TrackerBase( nameAndLocation, ctx, parent ) + { + if( parent ) { + while( !parent->isSectionTracker() ) + parent = &parent->parent(); + + SectionTracker& parentSection = static_cast( *parent ); + addNextFilters( parentSection.m_filters ); + } + } + + bool SectionTracker::isSectionTracker() const { return true; } + + SectionTracker& SectionTracker::acquire( TrackerContext& ctx, NameAndLocation const& nameAndLocation ) { + std::shared_ptr section; + + ITracker& currentTracker = ctx.currentTracker(); + if( ITrackerPtr childTracker = currentTracker.findChild( nameAndLocation ) ) { + assert( childTracker ); + assert( childTracker->isSectionTracker() ); + section = std::static_pointer_cast( childTracker ); + } + else { + section = std::make_shared( nameAndLocation, ctx, ¤tTracker ); + currentTracker.addChild( section ); + } + if( !ctx.completedCycle() ) + section->tryOpen(); + return *section; + } + + void SectionTracker::tryOpen() { + if( !isComplete() && (m_filters.empty() || m_filters[0].empty() || m_filters[0] == m_nameAndLocation.name ) ) + open(); + } + + void SectionTracker::addInitialFilters( std::vector const& filters ) { + if( !filters.empty() ) { + m_filters.push_back(""); // Root - should never be consulted + m_filters.push_back(""); // Test Case - not a section filter + m_filters.insert( m_filters.end(), filters.begin(), filters.end() ); + } + } + void SectionTracker::addNextFilters( std::vector const& filters ) { + if( filters.size() > 1 ) + m_filters.insert( m_filters.end(), ++filters.begin(), filters.end() ); + } + + IndexTracker::IndexTracker( NameAndLocation const& nameAndLocation, TrackerContext& ctx, ITracker* parent, int size ) + : TrackerBase( nameAndLocation, ctx, parent ), + m_size( size ) + {} + + bool IndexTracker::isIndexTracker() const { return true; } + + IndexTracker& IndexTracker::acquire( TrackerContext& ctx, NameAndLocation const& nameAndLocation, int size ) { + std::shared_ptr tracker; + + ITracker& currentTracker = ctx.currentTracker(); + if( ITrackerPtr childTracker = currentTracker.findChild( nameAndLocation ) ) { + assert( childTracker ); + assert( childTracker->isIndexTracker() ); + tracker = std::static_pointer_cast( childTracker ); + } + else { + tracker = std::make_shared( nameAndLocation, ctx, ¤tTracker, size ); + currentTracker.addChild( tracker ); + } + + if( !ctx.completedCycle() && !tracker->isComplete() ) { + if( tracker->m_runState != ExecutingChildren && tracker->m_runState != NeedsAnotherRun ) + tracker->moveNext(); + tracker->open(); + } + + return *tracker; + } + + int IndexTracker::index() const { return m_index; } + + void IndexTracker::moveNext() { + m_index++; + m_children.clear(); + } + + void IndexTracker::close() { + TrackerBase::close(); + if( m_runState == CompletedSuccessfully && m_index < m_size-1 ) + m_runState = Executing; + } + +} // namespace TestCaseTracking + +using TestCaseTracking::ITracker; +using TestCaseTracking::TrackerContext; +using TestCaseTracking::SectionTracker; +using TestCaseTracking::IndexTracker; + +} // namespace Catch + +#if defined(__clang__) +# pragma clang diagnostic pop +#endif +// end catch_test_case_tracker.cpp +// start catch_test_registry.cpp + +namespace Catch { + + auto makeTestInvoker( void(*testAsFunction)() ) noexcept -> ITestInvoker* { + return new(std::nothrow) TestInvokerAsFunction( testAsFunction ); + } + + NameAndTags::NameAndTags( StringRef const& name_ , StringRef const& tags_ ) noexcept : name( name_ ), tags( tags_ ) {} + + AutoReg::AutoReg( ITestInvoker* invoker, SourceLineInfo const& lineInfo, StringRef const& classOrMethod, NameAndTags const& nameAndTags ) noexcept { + try { + getMutableRegistryHub() + .registerTest( + makeTestCase( + invoker, + extractClassName( classOrMethod ), + nameAndTags, + lineInfo)); + } catch (...) { + // Do not throw when constructing global objects, instead register the exception to be processed later + getMutableRegistryHub().registerStartupException(); + } + } + + AutoReg::~AutoReg() = default; +} +// end catch_test_registry.cpp +// start catch_test_spec.cpp + +#include +#include +#include +#include + +namespace Catch { + + TestSpec::Pattern::~Pattern() = default; + TestSpec::NamePattern::~NamePattern() = default; + TestSpec::TagPattern::~TagPattern() = default; + TestSpec::ExcludedPattern::~ExcludedPattern() = default; + + TestSpec::NamePattern::NamePattern( std::string const& name ) + : m_wildcardPattern( toLower( name ), CaseSensitive::No ) + {} + bool TestSpec::NamePattern::matches( TestCaseInfo const& testCase ) const { + return m_wildcardPattern.matches( toLower( testCase.name ) ); + } + + TestSpec::TagPattern::TagPattern( std::string const& tag ) : m_tag( toLower( tag ) ) {} + bool TestSpec::TagPattern::matches( TestCaseInfo const& testCase ) const { + return std::find(begin(testCase.lcaseTags), + end(testCase.lcaseTags), + m_tag) != end(testCase.lcaseTags); + } + + TestSpec::ExcludedPattern::ExcludedPattern( PatternPtr const& underlyingPattern ) : m_underlyingPattern( underlyingPattern ) {} + bool TestSpec::ExcludedPattern::matches( TestCaseInfo const& testCase ) const { return !m_underlyingPattern->matches( testCase ); } + + bool TestSpec::Filter::matches( TestCaseInfo const& testCase ) const { + // All patterns in a filter must match for the filter to be a match + for( auto const& pattern : m_patterns ) { + if( !pattern->matches( testCase ) ) + return false; + } + return true; + } + + bool TestSpec::hasFilters() const { + return !m_filters.empty(); + } + bool TestSpec::matches( TestCaseInfo const& testCase ) const { + // A TestSpec matches if any filter matches + for( auto const& filter : m_filters ) + if( filter.matches( testCase ) ) + return true; + return false; + } +} +// end catch_test_spec.cpp +// start catch_test_spec_parser.cpp + +namespace Catch { + + TestSpecParser::TestSpecParser( ITagAliasRegistry const& tagAliases ) : m_tagAliases( &tagAliases ) {} + + TestSpecParser& TestSpecParser::parse( std::string const& arg ) { + m_mode = None; + m_exclusion = false; + m_start = std::string::npos; + m_arg = m_tagAliases->expandAliases( arg ); + m_escapeChars.clear(); + for( m_pos = 0; m_pos < m_arg.size(); ++m_pos ) + visitChar( m_arg[m_pos] ); + if( m_mode == Name ) + addPattern(); + return *this; + } + TestSpec TestSpecParser::testSpec() { + addFilter(); + return m_testSpec; + } + + void TestSpecParser::visitChar( char c ) { + if( m_mode == None ) { + switch( c ) { + case ' ': return; + case '~': m_exclusion = true; return; + case '[': return startNewMode( Tag, ++m_pos ); + case '"': return startNewMode( QuotedName, ++m_pos ); + case '\\': return escape(); + default: startNewMode( Name, m_pos ); break; + } + } + if( m_mode == Name ) { + if( c == ',' ) { + addPattern(); + addFilter(); + } + else if( c == '[' ) { + if( subString() == "exclude:" ) + m_exclusion = true; + else + addPattern(); + startNewMode( Tag, ++m_pos ); + } + else if( c == '\\' ) + escape(); + } + else if( m_mode == EscapedName ) + m_mode = Name; + else if( m_mode == QuotedName && c == '"' ) + addPattern(); + else if( m_mode == Tag && c == ']' ) + addPattern(); + } + void TestSpecParser::startNewMode( Mode mode, std::size_t start ) { + m_mode = mode; + m_start = start; + } + void TestSpecParser::escape() { + if( m_mode == None ) + m_start = m_pos; + m_mode = EscapedName; + m_escapeChars.push_back( m_pos ); + } + std::string TestSpecParser::subString() const { return m_arg.substr( m_start, m_pos - m_start ); } + + void TestSpecParser::addFilter() { + if( !m_currentFilter.m_patterns.empty() ) { + m_testSpec.m_filters.push_back( m_currentFilter ); + m_currentFilter = TestSpec::Filter(); + } + } + + TestSpec parseTestSpec( std::string const& arg ) { + return TestSpecParser( ITagAliasRegistry::get() ).parse( arg ).testSpec(); + } + +} // namespace Catch +// end catch_test_spec_parser.cpp +// start catch_timer.cpp + +#include + +static const uint64_t nanosecondsInSecond = 1000000000; + +namespace Catch { + + auto getCurrentNanosecondsSinceEpoch() -> uint64_t { + return std::chrono::duration_cast( std::chrono::high_resolution_clock::now().time_since_epoch() ).count(); + } + + namespace { + auto estimateClockResolution() -> uint64_t { + uint64_t sum = 0; + static const uint64_t iterations = 1000000; + + auto startTime = getCurrentNanosecondsSinceEpoch(); + + for( std::size_t i = 0; i < iterations; ++i ) { + + uint64_t ticks; + uint64_t baseTicks = getCurrentNanosecondsSinceEpoch(); + do { + ticks = getCurrentNanosecondsSinceEpoch(); + } while( ticks == baseTicks ); + + auto delta = ticks - baseTicks; + sum += delta; + + // If we have been calibrating for over 3 seconds -- the clock + // is terrible and we should move on. + // TBD: How to signal that the measured resolution is probably wrong? + if (ticks > startTime + 3 * nanosecondsInSecond) { + return sum / i; + } + } + + // We're just taking the mean, here. To do better we could take the std. dev and exclude outliers + // - and potentially do more iterations if there's a high variance. + return sum/iterations; + } + } + auto getEstimatedClockResolution() -> uint64_t { + static auto s_resolution = estimateClockResolution(); + return s_resolution; + } + + void Timer::start() { + m_nanoseconds = getCurrentNanosecondsSinceEpoch(); + } + auto Timer::getElapsedNanoseconds() const -> uint64_t { + return getCurrentNanosecondsSinceEpoch() - m_nanoseconds; + } + auto Timer::getElapsedMicroseconds() const -> uint64_t { + return getElapsedNanoseconds()/1000; + } + auto Timer::getElapsedMilliseconds() const -> unsigned int { + return static_cast(getElapsedMicroseconds()/1000); + } + auto Timer::getElapsedSeconds() const -> double { + return getElapsedMicroseconds()/1000000.0; + } + +} // namespace Catch +// end catch_timer.cpp +// start catch_tostring.cpp + +#if defined(__clang__) +# pragma clang diagnostic push +# pragma clang diagnostic ignored "-Wexit-time-destructors" +# pragma clang diagnostic ignored "-Wglobal-constructors" +#endif + +// Enable specific decls locally +#if !defined(CATCH_CONFIG_ENABLE_CHRONO_STRINGMAKER) +#define CATCH_CONFIG_ENABLE_CHRONO_STRINGMAKER +#endif + +#include +#include + +namespace Catch { + +namespace Detail { + + const std::string unprintableString = "{?}"; + + namespace { + const int hexThreshold = 255; + + struct Endianness { + enum Arch { Big, Little }; + + static Arch which() { + union _{ + int asInt; + char asChar[sizeof (int)]; + } u; + + u.asInt = 1; + return ( u.asChar[sizeof(int)-1] == 1 ) ? Big : Little; + } + }; + } + + std::string rawMemoryToString( const void *object, std::size_t size ) { + // Reverse order for little endian architectures + int i = 0, end = static_cast( size ), inc = 1; + if( Endianness::which() == Endianness::Little ) { + i = end-1; + end = inc = -1; + } + + unsigned char const *bytes = static_cast(object); + ReusableStringStream rss; + rss << "0x" << std::setfill('0') << std::hex; + for( ; i != end; i += inc ) + rss << std::setw(2) << static_cast(bytes[i]); + return rss.str(); + } +} + +template +std::string fpToString( T value, int precision ) { + if (std::isnan(value)) { + return "nan"; + } + + ReusableStringStream rss; + rss << std::setprecision( precision ) + << std::fixed + << value; + std::string d = rss.str(); + std::size_t i = d.find_last_not_of( '0' ); + if( i != std::string::npos && i != d.size()-1 ) { + if( d[i] == '.' ) + i++; + d = d.substr( 0, i+1 ); + } + return d; +} + +//// ======================================================= //// +// +// Out-of-line defs for full specialization of StringMaker +// +//// ======================================================= //// + +std::string StringMaker::convert(const std::string& str) { + if (!getCurrentContext().getConfig()->showInvisibles()) { + return '"' + str + '"'; + } + + std::string s("\""); + for (char c : str) { + switch (c) { + case '\n': + s.append("\\n"); + break; + case '\t': + s.append("\\t"); + break; + default: + s.push_back(c); + break; + } + } + s.append("\""); + return s; +} + +#ifdef CATCH_CONFIG_WCHAR +std::string StringMaker::convert(const std::wstring& wstr) { + std::string s; + s.reserve(wstr.size()); + for (auto c : wstr) { + s += (c <= 0xff) ? static_cast(c) : '?'; + } + return ::Catch::Detail::stringify(s); +} +#endif + +std::string StringMaker::convert(char const* str) { + if (str) { + return ::Catch::Detail::stringify(std::string{ str }); + } else { + return{ "{null string}" }; + } +} +std::string StringMaker::convert(char* str) { + if (str) { + return ::Catch::Detail::stringify(std::string{ str }); + } else { + return{ "{null string}" }; + } +} +#ifdef CATCH_CONFIG_WCHAR +std::string StringMaker::convert(wchar_t const * str) { + if (str) { + return ::Catch::Detail::stringify(std::wstring{ str }); + } else { + return{ "{null string}" }; + } +} +std::string StringMaker::convert(wchar_t * str) { + if (str) { + return ::Catch::Detail::stringify(std::wstring{ str }); + } else { + return{ "{null string}" }; + } +} +#endif + +std::string StringMaker::convert(int value) { + return ::Catch::Detail::stringify(static_cast(value)); +} +std::string StringMaker::convert(long value) { + return ::Catch::Detail::stringify(static_cast(value)); +} +std::string StringMaker::convert(long long value) { + ReusableStringStream rss; + rss << value; + if (value > Detail::hexThreshold) { + rss << " (0x" << std::hex << value << ')'; + } + return rss.str(); +} + +std::string StringMaker::convert(unsigned int value) { + return ::Catch::Detail::stringify(static_cast(value)); +} +std::string StringMaker::convert(unsigned long value) { + return ::Catch::Detail::stringify(static_cast(value)); +} +std::string StringMaker::convert(unsigned long long value) { + ReusableStringStream rss; + rss << value; + if (value > Detail::hexThreshold) { + rss << " (0x" << std::hex << value << ')'; + } + return rss.str(); +} + +std::string StringMaker::convert(bool b) { + return b ? "true" : "false"; +} + +std::string StringMaker::convert(char value) { + if (value == '\r') { + return "'\\r'"; + } else if (value == '\f') { + return "'\\f'"; + } else if (value == '\n') { + return "'\\n'"; + } else if (value == '\t') { + return "'\\t'"; + } else if ('\0' <= value && value < ' ') { + return ::Catch::Detail::stringify(static_cast(value)); + } else { + char chstr[] = "' '"; + chstr[1] = value; + return chstr; + } +} +std::string StringMaker::convert(signed char c) { + return ::Catch::Detail::stringify(static_cast(c)); +} +std::string StringMaker::convert(unsigned char c) { + return ::Catch::Detail::stringify(static_cast(c)); +} + +std::string StringMaker::convert(std::nullptr_t) { + return "nullptr"; +} + +std::string StringMaker::convert(float value) { + return fpToString(value, 5) + 'f'; +} +std::string StringMaker::convert(double value) { + return fpToString(value, 10); +} + +std::string ratio_string::symbol() { return "a"; } +std::string ratio_string::symbol() { return "f"; } +std::string ratio_string::symbol() { return "p"; } +std::string ratio_string::symbol() { return "n"; } +std::string ratio_string::symbol() { return "u"; } +std::string ratio_string::symbol() { return "m"; } + +} // end namespace Catch + +#if defined(__clang__) +# pragma clang diagnostic pop +#endif + +// end catch_tostring.cpp +// start catch_totals.cpp + +namespace Catch { + + Counts Counts::operator - ( Counts const& other ) const { + Counts diff; + diff.passed = passed - other.passed; + diff.failed = failed - other.failed; + diff.failedButOk = failedButOk - other.failedButOk; + return diff; + } + + Counts& Counts::operator += ( Counts const& other ) { + passed += other.passed; + failed += other.failed; + failedButOk += other.failedButOk; + return *this; + } + + std::size_t Counts::total() const { + return passed + failed + failedButOk; + } + bool Counts::allPassed() const { + return failed == 0 && failedButOk == 0; + } + bool Counts::allOk() const { + return failed == 0; + } + + Totals Totals::operator - ( Totals const& other ) const { + Totals diff; + diff.assertions = assertions - other.assertions; + diff.testCases = testCases - other.testCases; + return diff; + } + + Totals& Totals::operator += ( Totals const& other ) { + assertions += other.assertions; + testCases += other.testCases; + return *this; + } + + Totals Totals::delta( Totals const& prevTotals ) const { + Totals diff = *this - prevTotals; + if( diff.assertions.failed > 0 ) + ++diff.testCases.failed; + else if( diff.assertions.failedButOk > 0 ) + ++diff.testCases.failedButOk; + else + ++diff.testCases.passed; + return diff; + } + +} +// end catch_totals.cpp +// start catch_uncaught_exceptions.cpp + +#include + +namespace Catch { + bool uncaught_exceptions() { +#if defined(CATCH_CONFIG_CPP17_UNCAUGHT_EXCEPTIONS) + return std::uncaught_exceptions() > 0; +#else + return std::uncaught_exception(); +#endif + } +} // end namespace Catch +// end catch_uncaught_exceptions.cpp +// start catch_version.cpp + +#include + +namespace Catch { + + Version::Version + ( unsigned int _majorVersion, + unsigned int _minorVersion, + unsigned int _patchNumber, + char const * const _branchName, + unsigned int _buildNumber ) + : majorVersion( _majorVersion ), + minorVersion( _minorVersion ), + patchNumber( _patchNumber ), + branchName( _branchName ), + buildNumber( _buildNumber ) + {} + + std::ostream& operator << ( std::ostream& os, Version const& version ) { + os << version.majorVersion << '.' + << version.minorVersion << '.' + << version.patchNumber; + // branchName is never null -> 0th char is \0 if it is empty + if (version.branchName[0]) { + os << '-' << version.branchName + << '.' << version.buildNumber; + } + return os; + } + + Version const& libraryVersion() { + static Version version( 2, 3, 0, "", 0 ); + return version; + } + +} +// end catch_version.cpp +// start catch_wildcard_pattern.cpp + +#include + +namespace Catch { + + WildcardPattern::WildcardPattern( std::string const& pattern, + CaseSensitive::Choice caseSensitivity ) + : m_caseSensitivity( caseSensitivity ), + m_pattern( adjustCase( pattern ) ) + { + if( startsWith( m_pattern, '*' ) ) { + m_pattern = m_pattern.substr( 1 ); + m_wildcard = WildcardAtStart; + } + if( endsWith( m_pattern, '*' ) ) { + m_pattern = m_pattern.substr( 0, m_pattern.size()-1 ); + m_wildcard = static_cast( m_wildcard | WildcardAtEnd ); + } + } + + bool WildcardPattern::matches( std::string const& str ) const { + switch( m_wildcard ) { + case NoWildcard: + return m_pattern == adjustCase( str ); + case WildcardAtStart: + return endsWith( adjustCase( str ), m_pattern ); + case WildcardAtEnd: + return startsWith( adjustCase( str ), m_pattern ); + case WildcardAtBothEnds: + return contains( adjustCase( str ), m_pattern ); + default: + CATCH_INTERNAL_ERROR( "Unknown enum" ); + } + } + + std::string WildcardPattern::adjustCase( std::string const& str ) const { + return m_caseSensitivity == CaseSensitive::No ? toLower( str ) : str; + } +} +// end catch_wildcard_pattern.cpp +// start catch_xmlwriter.cpp + +#include + +using uchar = unsigned char; + +namespace Catch { + +namespace { + + size_t trailingBytes(unsigned char c) { + if ((c & 0xE0) == 0xC0) { + return 2; + } + if ((c & 0xF0) == 0xE0) { + return 3; + } + if ((c & 0xF8) == 0xF0) { + return 4; + } + CATCH_INTERNAL_ERROR("Invalid multibyte utf-8 start byte encountered"); + } + + uint32_t headerValue(unsigned char c) { + if ((c & 0xE0) == 0xC0) { + return c & 0x1F; + } + if ((c & 0xF0) == 0xE0) { + return c & 0x0F; + } + if ((c & 0xF8) == 0xF0) { + return c & 0x07; + } + CATCH_INTERNAL_ERROR("Invalid multibyte utf-8 start byte encountered"); + } + + void hexEscapeChar(std::ostream& os, unsigned char c) { + os << "\\x" + << std::uppercase << std::hex << std::setfill('0') << std::setw(2) + << static_cast(c); + } + +} // anonymous namespace + + XmlEncode::XmlEncode( std::string const& str, ForWhat forWhat ) + : m_str( str ), + m_forWhat( forWhat ) + {} + + void XmlEncode::encodeTo( std::ostream& os ) const { + // Apostrophe escaping not necessary if we always use " to write attributes + // (see: http://www.w3.org/TR/xml/#syntax) + + for( std::size_t idx = 0; idx < m_str.size(); ++ idx ) { + uchar c = m_str[idx]; + switch (c) { + case '<': os << "<"; break; + case '&': os << "&"; break; + + case '>': + // See: http://www.w3.org/TR/xml/#syntax + if (idx > 2 && m_str[idx - 1] == ']' && m_str[idx - 2] == ']') + os << ">"; + else + os << c; + break; + + case '\"': + if (m_forWhat == ForAttributes) + os << """; + else + os << c; + break; + + default: + // Check for control characters and invalid utf-8 + + // Escape control characters in standard ascii + // see http://stackoverflow.com/questions/404107/why-are-control-characters-illegal-in-xml-1-0 + if (c < 0x09 || (c > 0x0D && c < 0x20) || c == 0x7F) { + hexEscapeChar(os, c); + break; + } + + // Plain ASCII: Write it to stream + if (c < 0x7F) { + os << c; + break; + } + + // UTF-8 territory + // Check if the encoding is valid and if it is not, hex escape bytes. + // Important: We do not check the exact decoded values for validity, only the encoding format + // First check that this bytes is a valid lead byte: + // This means that it is not encoded as 1111 1XXX + // Or as 10XX XXXX + if (c < 0xC0 || + c >= 0xF8) { + hexEscapeChar(os, c); + break; + } + + auto encBytes = trailingBytes(c); + // Are there enough bytes left to avoid accessing out-of-bounds memory? + if (idx + encBytes - 1 >= m_str.size()) { + hexEscapeChar(os, c); + break; + } + // The header is valid, check data + // The next encBytes bytes must together be a valid utf-8 + // This means: bitpattern 10XX XXXX and the extracted value is sane (ish) + bool valid = true; + uint32_t value = headerValue(c); + for (std::size_t n = 1; n < encBytes; ++n) { + uchar nc = m_str[idx + n]; + valid &= ((nc & 0xC0) == 0x80); + value = (value << 6) | (nc & 0x3F); + } + + if ( + // Wrong bit pattern of following bytes + (!valid) || + // Overlong encodings + (value < 0x80) || + (0x80 <= value && value < 0x800 && encBytes > 2) || + (0x800 < value && value < 0x10000 && encBytes > 3) || + // Encoded value out of range + (value >= 0x110000) + ) { + hexEscapeChar(os, c); + break; + } + + // If we got here, this is in fact a valid(ish) utf-8 sequence + for (std::size_t n = 0; n < encBytes; ++n) { + os << m_str[idx + n]; + } + idx += encBytes - 1; + break; + } + } + } + + std::ostream& operator << ( std::ostream& os, XmlEncode const& xmlEncode ) { + xmlEncode.encodeTo( os ); + return os; + } + + XmlWriter::ScopedElement::ScopedElement( XmlWriter* writer ) + : m_writer( writer ) + {} + + XmlWriter::ScopedElement::ScopedElement( ScopedElement&& other ) noexcept + : m_writer( other.m_writer ){ + other.m_writer = nullptr; + } + XmlWriter::ScopedElement& XmlWriter::ScopedElement::operator=( ScopedElement&& other ) noexcept { + if ( m_writer ) { + m_writer->endElement(); + } + m_writer = other.m_writer; + other.m_writer = nullptr; + return *this; + } + + XmlWriter::ScopedElement::~ScopedElement() { + if( m_writer ) + m_writer->endElement(); + } + + XmlWriter::ScopedElement& XmlWriter::ScopedElement::writeText( std::string const& text, bool indent ) { + m_writer->writeText( text, indent ); + return *this; + } + + XmlWriter::XmlWriter( std::ostream& os ) : m_os( os ) + { + writeDeclaration(); + } + + XmlWriter::~XmlWriter() { + while( !m_tags.empty() ) + endElement(); + } + + XmlWriter& XmlWriter::startElement( std::string const& name ) { + ensureTagClosed(); + newlineIfNecessary(); + m_os << m_indent << '<' << name; + m_tags.push_back( name ); + m_indent += " "; + m_tagIsOpen = true; + return *this; + } + + XmlWriter::ScopedElement XmlWriter::scopedElement( std::string const& name ) { + ScopedElement scoped( this ); + startElement( name ); + return scoped; + } + + XmlWriter& XmlWriter::endElement() { + newlineIfNecessary(); + m_indent = m_indent.substr( 0, m_indent.size()-2 ); + if( m_tagIsOpen ) { + m_os << "/>"; + m_tagIsOpen = false; + } + else { + m_os << m_indent << ""; + } + m_os << std::endl; + m_tags.pop_back(); + return *this; + } + + XmlWriter& XmlWriter::writeAttribute( std::string const& name, std::string const& attribute ) { + if( !name.empty() && !attribute.empty() ) + m_os << ' ' << name << "=\"" << XmlEncode( attribute, XmlEncode::ForAttributes ) << '"'; + return *this; + } + + XmlWriter& XmlWriter::writeAttribute( std::string const& name, bool attribute ) { + m_os << ' ' << name << "=\"" << ( attribute ? "true" : "false" ) << '"'; + return *this; + } + + XmlWriter& XmlWriter::writeText( std::string const& text, bool indent ) { + if( !text.empty() ){ + bool tagWasOpen = m_tagIsOpen; + ensureTagClosed(); + if( tagWasOpen && indent ) + m_os << m_indent; + m_os << XmlEncode( text ); + m_needsNewline = true; + } + return *this; + } + + XmlWriter& XmlWriter::writeComment( std::string const& text ) { + ensureTagClosed(); + m_os << m_indent << ""; + m_needsNewline = true; + return *this; + } + + void XmlWriter::writeStylesheetRef( std::string const& url ) { + m_os << "\n"; + } + + XmlWriter& XmlWriter::writeBlankLine() { + ensureTagClosed(); + m_os << '\n'; + return *this; + } + + void XmlWriter::ensureTagClosed() { + if( m_tagIsOpen ) { + m_os << ">" << std::endl; + m_tagIsOpen = false; + } + } + + void XmlWriter::writeDeclaration() { + m_os << "\n"; + } + + void XmlWriter::newlineIfNecessary() { + if( m_needsNewline ) { + m_os << std::endl; + m_needsNewline = false; + } + } +} +// end catch_xmlwriter.cpp +// start catch_reporter_bases.cpp + +#include +#include +#include +#include +#include + +namespace Catch { + void prepareExpandedExpression(AssertionResult& result) { + result.getExpandedExpression(); + } + + // Because formatting using c++ streams is stateful, drop down to C is required + // Alternatively we could use stringstream, but its performance is... not good. + std::string getFormattedDuration( double duration ) { + // Max exponent + 1 is required to represent the whole part + // + 1 for decimal point + // + 3 for the 3 decimal places + // + 1 for null terminator + const std::size_t maxDoubleSize = DBL_MAX_10_EXP + 1 + 1 + 3 + 1; + char buffer[maxDoubleSize]; + + // Save previous errno, to prevent sprintf from overwriting it + ErrnoGuard guard; +#ifdef _MSC_VER + sprintf_s(buffer, "%.3f", duration); +#else + sprintf(buffer, "%.3f", duration); +#endif + return std::string(buffer); + } + + TestEventListenerBase::TestEventListenerBase(ReporterConfig const & _config) + :StreamingReporterBase(_config) {} + + void TestEventListenerBase::assertionStarting(AssertionInfo const &) {} + + bool TestEventListenerBase::assertionEnded(AssertionStats const &) { + return false; + } + +} // end namespace Catch +// end catch_reporter_bases.cpp +// start catch_reporter_compact.cpp + +namespace { + +#ifdef CATCH_PLATFORM_MAC + const char* failedString() { return "FAILED"; } + const char* passedString() { return "PASSED"; } +#else + const char* failedString() { return "failed"; } + const char* passedString() { return "passed"; } +#endif + + // Colour::LightGrey + Catch::Colour::Code dimColour() { return Catch::Colour::FileName; } + + std::string bothOrAll( std::size_t count ) { + return count == 1 ? std::string() : + count == 2 ? "both " : "all " ; + } + +} // anon namespace + +namespace Catch { +namespace { +// Colour, message variants: +// - white: No tests ran. +// - red: Failed [both/all] N test cases, failed [both/all] M assertions. +// - white: Passed [both/all] N test cases (no assertions). +// - red: Failed N tests cases, failed M assertions. +// - green: Passed [both/all] N tests cases with M assertions. +void printTotals(std::ostream& out, const Totals& totals) { + if (totals.testCases.total() == 0) { + out << "No tests ran."; + } else if (totals.testCases.failed == totals.testCases.total()) { + Colour colour(Colour::ResultError); + const std::string qualify_assertions_failed = + totals.assertions.failed == totals.assertions.total() ? + bothOrAll(totals.assertions.failed) : std::string(); + out << + "Failed " << bothOrAll(totals.testCases.failed) + << pluralise(totals.testCases.failed, "test case") << ", " + "failed " << qualify_assertions_failed << + pluralise(totals.assertions.failed, "assertion") << '.'; + } else if (totals.assertions.total() == 0) { + out << + "Passed " << bothOrAll(totals.testCases.total()) + << pluralise(totals.testCases.total(), "test case") + << " (no assertions)."; + } else if (totals.assertions.failed) { + Colour colour(Colour::ResultError); + out << + "Failed " << pluralise(totals.testCases.failed, "test case") << ", " + "failed " << pluralise(totals.assertions.failed, "assertion") << '.'; + } else { + Colour colour(Colour::ResultSuccess); + out << + "Passed " << bothOrAll(totals.testCases.passed) + << pluralise(totals.testCases.passed, "test case") << + " with " << pluralise(totals.assertions.passed, "assertion") << '.'; + } +} + +// Implementation of CompactReporter formatting +class AssertionPrinter { +public: + AssertionPrinter& operator= (AssertionPrinter const&) = delete; + AssertionPrinter(AssertionPrinter const&) = delete; + AssertionPrinter(std::ostream& _stream, AssertionStats const& _stats, bool _printInfoMessages) + : stream(_stream) + , result(_stats.assertionResult) + , messages(_stats.infoMessages) + , itMessage(_stats.infoMessages.begin()) + , printInfoMessages(_printInfoMessages) {} + + void print() { + printSourceInfo(); + + itMessage = messages.begin(); + + switch (result.getResultType()) { + case ResultWas::Ok: + printResultType(Colour::ResultSuccess, passedString()); + printOriginalExpression(); + printReconstructedExpression(); + if (!result.hasExpression()) + printRemainingMessages(Colour::None); + else + printRemainingMessages(); + break; + case ResultWas::ExpressionFailed: + if (result.isOk()) + printResultType(Colour::ResultSuccess, failedString() + std::string(" - but was ok")); + else + printResultType(Colour::Error, failedString()); + printOriginalExpression(); + printReconstructedExpression(); + printRemainingMessages(); + break; + case ResultWas::ThrewException: + printResultType(Colour::Error, failedString()); + printIssue("unexpected exception with message:"); + printMessage(); + printExpressionWas(); + printRemainingMessages(); + break; + case ResultWas::FatalErrorCondition: + printResultType(Colour::Error, failedString()); + printIssue("fatal error condition with message:"); + printMessage(); + printExpressionWas(); + printRemainingMessages(); + break; + case ResultWas::DidntThrowException: + printResultType(Colour::Error, failedString()); + printIssue("expected exception, got none"); + printExpressionWas(); + printRemainingMessages(); + break; + case ResultWas::Info: + printResultType(Colour::None, "info"); + printMessage(); + printRemainingMessages(); + break; + case ResultWas::Warning: + printResultType(Colour::None, "warning"); + printMessage(); + printRemainingMessages(); + break; + case ResultWas::ExplicitFailure: + printResultType(Colour::Error, failedString()); + printIssue("explicitly"); + printRemainingMessages(Colour::None); + break; + // These cases are here to prevent compiler warnings + case ResultWas::Unknown: + case ResultWas::FailureBit: + case ResultWas::Exception: + printResultType(Colour::Error, "** internal error **"); + break; + } + } + +private: + void printSourceInfo() const { + Colour colourGuard(Colour::FileName); + stream << result.getSourceInfo() << ':'; + } + + void printResultType(Colour::Code colour, std::string const& passOrFail) const { + if (!passOrFail.empty()) { + { + Colour colourGuard(colour); + stream << ' ' << passOrFail; + } + stream << ':'; + } + } + + void printIssue(std::string const& issue) const { + stream << ' ' << issue; + } + + void printExpressionWas() { + if (result.hasExpression()) { + stream << ';'; + { + Colour colour(dimColour()); + stream << " expression was:"; + } + printOriginalExpression(); + } + } + + void printOriginalExpression() const { + if (result.hasExpression()) { + stream << ' ' << result.getExpression(); + } + } + + void printReconstructedExpression() const { + if (result.hasExpandedExpression()) { + { + Colour colour(dimColour()); + stream << " for: "; + } + stream << result.getExpandedExpression(); + } + } + + void printMessage() { + if (itMessage != messages.end()) { + stream << " '" << itMessage->message << '\''; + ++itMessage; + } + } + + void printRemainingMessages(Colour::Code colour = dimColour()) { + if (itMessage == messages.end()) + return; + + // using messages.end() directly yields (or auto) compilation error: + std::vector::const_iterator itEnd = messages.end(); + const std::size_t N = static_cast(std::distance(itMessage, itEnd)); + + { + Colour colourGuard(colour); + stream << " with " << pluralise(N, "message") << ':'; + } + + for (; itMessage != itEnd; ) { + // If this assertion is a warning ignore any INFO messages + if (printInfoMessages || itMessage->type != ResultWas::Info) { + stream << " '" << itMessage->message << '\''; + if (++itMessage != itEnd) { + Colour colourGuard(dimColour()); + stream << " and"; + } + } + } + } + +private: + std::ostream& stream; + AssertionResult const& result; + std::vector messages; + std::vector::const_iterator itMessage; + bool printInfoMessages; +}; + +} // anon namespace + + std::string CompactReporter::getDescription() { + return "Reports test results on a single line, suitable for IDEs"; + } + + ReporterPreferences CompactReporter::getPreferences() const { + return m_reporterPrefs; + } + + void CompactReporter::noMatchingTestCases( std::string const& spec ) { + stream << "No test cases matched '" << spec << '\'' << std::endl; + } + + void CompactReporter::assertionStarting( AssertionInfo const& ) {} + + bool CompactReporter::assertionEnded( AssertionStats const& _assertionStats ) { + AssertionResult const& result = _assertionStats.assertionResult; + + bool printInfoMessages = true; + + // Drop out if result was successful and we're not printing those + if( !m_config->includeSuccessfulResults() && result.isOk() ) { + if( result.getResultType() != ResultWas::Warning ) + return false; + printInfoMessages = false; + } + + AssertionPrinter printer( stream, _assertionStats, printInfoMessages ); + printer.print(); + + stream << std::endl; + return true; + } + + void CompactReporter::sectionEnded(SectionStats const& _sectionStats) { + if (m_config->showDurations() == ShowDurations::Always) { + stream << getFormattedDuration(_sectionStats.durationInSeconds) << " s: " << _sectionStats.sectionInfo.name << std::endl; + } + } + + void CompactReporter::testRunEnded( TestRunStats const& _testRunStats ) { + printTotals( stream, _testRunStats.totals ); + stream << '\n' << std::endl; + StreamingReporterBase::testRunEnded( _testRunStats ); + } + + CompactReporter::~CompactReporter() {} + + CATCH_REGISTER_REPORTER( "compact", CompactReporter ) + +} // end namespace Catch +// end catch_reporter_compact.cpp +// start catch_reporter_console.cpp + +#include +#include + +#if defined(_MSC_VER) +#pragma warning(push) +#pragma warning(disable:4061) // Not all labels are EXPLICITLY handled in switch + // Note that 4062 (not all labels are handled + // and default is missing) is enabled +#endif + +namespace Catch { + +namespace { + +// Formatter impl for ConsoleReporter +class ConsoleAssertionPrinter { +public: + ConsoleAssertionPrinter& operator= (ConsoleAssertionPrinter const&) = delete; + ConsoleAssertionPrinter(ConsoleAssertionPrinter const&) = delete; + ConsoleAssertionPrinter(std::ostream& _stream, AssertionStats const& _stats, bool _printInfoMessages) + : stream(_stream), + stats(_stats), + result(_stats.assertionResult), + colour(Colour::None), + message(result.getMessage()), + messages(_stats.infoMessages), + printInfoMessages(_printInfoMessages) { + switch (result.getResultType()) { + case ResultWas::Ok: + colour = Colour::Success; + passOrFail = "PASSED"; + //if( result.hasMessage() ) + if (_stats.infoMessages.size() == 1) + messageLabel = "with message"; + if (_stats.infoMessages.size() > 1) + messageLabel = "with messages"; + break; + case ResultWas::ExpressionFailed: + if (result.isOk()) { + colour = Colour::Success; + passOrFail = "FAILED - but was ok"; + } else { + colour = Colour::Error; + passOrFail = "FAILED"; + } + if (_stats.infoMessages.size() == 1) + messageLabel = "with message"; + if (_stats.infoMessages.size() > 1) + messageLabel = "with messages"; + break; + case ResultWas::ThrewException: + colour = Colour::Error; + passOrFail = "FAILED"; + messageLabel = "due to unexpected exception with "; + if (_stats.infoMessages.size() == 1) + messageLabel += "message"; + if (_stats.infoMessages.size() > 1) + messageLabel += "messages"; + break; + case ResultWas::FatalErrorCondition: + colour = Colour::Error; + passOrFail = "FAILED"; + messageLabel = "due to a fatal error condition"; + break; + case ResultWas::DidntThrowException: + colour = Colour::Error; + passOrFail = "FAILED"; + messageLabel = "because no exception was thrown where one was expected"; + break; + case ResultWas::Info: + messageLabel = "info"; + break; + case ResultWas::Warning: + messageLabel = "warning"; + break; + case ResultWas::ExplicitFailure: + passOrFail = "FAILED"; + colour = Colour::Error; + if (_stats.infoMessages.size() == 1) + messageLabel = "explicitly with message"; + if (_stats.infoMessages.size() > 1) + messageLabel = "explicitly with messages"; + break; + // These cases are here to prevent compiler warnings + case ResultWas::Unknown: + case ResultWas::FailureBit: + case ResultWas::Exception: + passOrFail = "** internal error **"; + colour = Colour::Error; + break; + } + } + + void print() const { + printSourceInfo(); + if (stats.totals.assertions.total() > 0) { + if (result.isOk()) + stream << '\n'; + printResultType(); + printOriginalExpression(); + printReconstructedExpression(); + } else { + stream << '\n'; + } + printMessage(); + } + +private: + void printResultType() const { + if (!passOrFail.empty()) { + Colour colourGuard(colour); + stream << passOrFail << ":\n"; + } + } + void printOriginalExpression() const { + if (result.hasExpression()) { + Colour colourGuard(Colour::OriginalExpression); + stream << " "; + stream << result.getExpressionInMacro(); + stream << '\n'; + } + } + void printReconstructedExpression() const { + if (result.hasExpandedExpression()) { + stream << "with expansion:\n"; + Colour colourGuard(Colour::ReconstructedExpression); + stream << Column(result.getExpandedExpression()).indent(2) << '\n'; + } + } + void printMessage() const { + if (!messageLabel.empty()) + stream << messageLabel << ':' << '\n'; + for (auto const& msg : messages) { + // If this assertion is a warning ignore any INFO messages + if (printInfoMessages || msg.type != ResultWas::Info) + stream << Column(msg.message).indent(2) << '\n'; + } + } + void printSourceInfo() const { + Colour colourGuard(Colour::FileName); + stream << result.getSourceInfo() << ": "; + } + + std::ostream& stream; + AssertionStats const& stats; + AssertionResult const& result; + Colour::Code colour; + std::string passOrFail; + std::string messageLabel; + std::string message; + std::vector messages; + bool printInfoMessages; +}; + +std::size_t makeRatio(std::size_t number, std::size_t total) { + std::size_t ratio = total > 0 ? CATCH_CONFIG_CONSOLE_WIDTH * number / total : 0; + return (ratio == 0 && number > 0) ? 1 : ratio; +} + +std::size_t& findMax(std::size_t& i, std::size_t& j, std::size_t& k) { + if (i > j && i > k) + return i; + else if (j > k) + return j; + else + return k; +} + +struct ColumnInfo { + enum Justification { Left, Right }; + std::string name; + int width; + Justification justification; +}; +struct ColumnBreak {}; +struct RowBreak {}; + +class Duration { + enum class Unit { + Auto, + Nanoseconds, + Microseconds, + Milliseconds, + Seconds, + Minutes + }; + static const uint64_t s_nanosecondsInAMicrosecond = 1000; + static const uint64_t s_nanosecondsInAMillisecond = 1000 * s_nanosecondsInAMicrosecond; + static const uint64_t s_nanosecondsInASecond = 1000 * s_nanosecondsInAMillisecond; + static const uint64_t s_nanosecondsInAMinute = 60 * s_nanosecondsInASecond; + + uint64_t m_inNanoseconds; + Unit m_units; + +public: + explicit Duration(uint64_t inNanoseconds, Unit units = Unit::Auto) + : m_inNanoseconds(inNanoseconds), + m_units(units) { + if (m_units == Unit::Auto) { + if (m_inNanoseconds < s_nanosecondsInAMicrosecond) + m_units = Unit::Nanoseconds; + else if (m_inNanoseconds < s_nanosecondsInAMillisecond) + m_units = Unit::Microseconds; + else if (m_inNanoseconds < s_nanosecondsInASecond) + m_units = Unit::Milliseconds; + else if (m_inNanoseconds < s_nanosecondsInAMinute) + m_units = Unit::Seconds; + else + m_units = Unit::Minutes; + } + + } + + auto value() const -> double { + switch (m_units) { + case Unit::Microseconds: + return m_inNanoseconds / static_cast(s_nanosecondsInAMicrosecond); + case Unit::Milliseconds: + return m_inNanoseconds / static_cast(s_nanosecondsInAMillisecond); + case Unit::Seconds: + return m_inNanoseconds / static_cast(s_nanosecondsInASecond); + case Unit::Minutes: + return m_inNanoseconds / static_cast(s_nanosecondsInAMinute); + default: + return static_cast(m_inNanoseconds); + } + } + auto unitsAsString() const -> std::string { + switch (m_units) { + case Unit::Nanoseconds: + return "ns"; + case Unit::Microseconds: + return "µs"; + case Unit::Milliseconds: + return "ms"; + case Unit::Seconds: + return "s"; + case Unit::Minutes: + return "m"; + default: + return "** internal error **"; + } + + } + friend auto operator << (std::ostream& os, Duration const& duration) -> std::ostream& { + return os << duration.value() << " " << duration.unitsAsString(); + } +}; +} // end anon namespace + +class TablePrinter { + std::ostream& m_os; + std::vector m_columnInfos; + std::ostringstream m_oss; + int m_currentColumn = -1; + bool m_isOpen = false; + +public: + TablePrinter( std::ostream& os, std::vector columnInfos ) + : m_os( os ), + m_columnInfos( std::move( columnInfos ) ) {} + + auto columnInfos() const -> std::vector const& { + return m_columnInfos; + } + + void open() { + if (!m_isOpen) { + m_isOpen = true; + *this << RowBreak(); + for (auto const& info : m_columnInfos) + *this << info.name << ColumnBreak(); + *this << RowBreak(); + m_os << Catch::getLineOfChars<'-'>() << "\n"; + } + } + void close() { + if (m_isOpen) { + *this << RowBreak(); + m_os << std::endl; + m_isOpen = false; + } + } + + template + friend TablePrinter& operator << (TablePrinter& tp, T const& value) { + tp.m_oss << value; + return tp; + } + + friend TablePrinter& operator << (TablePrinter& tp, ColumnBreak) { + auto colStr = tp.m_oss.str(); + // This takes account of utf8 encodings + auto strSize = Catch::StringRef(colStr).numberOfCharacters(); + tp.m_oss.str(""); + tp.open(); + if (tp.m_currentColumn == static_cast(tp.m_columnInfos.size() - 1)) { + tp.m_currentColumn = -1; + tp.m_os << "\n"; + } + tp.m_currentColumn++; + + auto colInfo = tp.m_columnInfos[tp.m_currentColumn]; + auto padding = (strSize + 2 < static_cast(colInfo.width)) + ? std::string(colInfo.width - (strSize + 2), ' ') + : std::string(); + if (colInfo.justification == ColumnInfo::Left) + tp.m_os << colStr << padding << " "; + else + tp.m_os << padding << colStr << " "; + return tp; + } + + friend TablePrinter& operator << (TablePrinter& tp, RowBreak) { + if (tp.m_currentColumn > 0) { + tp.m_os << "\n"; + tp.m_currentColumn = -1; + } + return tp; + } +}; + +ConsoleReporter::ConsoleReporter(ReporterConfig const& config) + : StreamingReporterBase(config), + m_tablePrinter(new TablePrinter(config.stream(), + { + { "benchmark name", CATCH_CONFIG_CONSOLE_WIDTH - 32, ColumnInfo::Left }, + { "iters", 8, ColumnInfo::Right }, + { "elapsed ns", 14, ColumnInfo::Right }, + { "average", 14, ColumnInfo::Right } + })) {} +ConsoleReporter::~ConsoleReporter() = default; + +std::string ConsoleReporter::getDescription() { + return "Reports test results as plain lines of text"; +} + +void ConsoleReporter::noMatchingTestCases(std::string const& spec) { + stream << "No test cases matched '" << spec << '\'' << std::endl; +} + +void ConsoleReporter::assertionStarting(AssertionInfo const&) {} + +bool ConsoleReporter::assertionEnded(AssertionStats const& _assertionStats) { + AssertionResult const& result = _assertionStats.assertionResult; + + bool includeResults = m_config->includeSuccessfulResults() || !result.isOk(); + + // Drop out if result was successful but we're not printing them. + if (!includeResults && result.getResultType() != ResultWas::Warning) + return false; + + lazyPrint(); + + ConsoleAssertionPrinter printer(stream, _assertionStats, includeResults); + printer.print(); + stream << std::endl; + return true; +} + +void ConsoleReporter::sectionStarting(SectionInfo const& _sectionInfo) { + m_headerPrinted = false; + StreamingReporterBase::sectionStarting(_sectionInfo); +} +void ConsoleReporter::sectionEnded(SectionStats const& _sectionStats) { + m_tablePrinter->close(); + if (_sectionStats.missingAssertions) { + lazyPrint(); + Colour colour(Colour::ResultError); + if (m_sectionStack.size() > 1) + stream << "\nNo assertions in section"; + else + stream << "\nNo assertions in test case"; + stream << " '" << _sectionStats.sectionInfo.name << "'\n" << std::endl; + } + if (m_config->showDurations() == ShowDurations::Always) { + stream << getFormattedDuration(_sectionStats.durationInSeconds) << " s: " << _sectionStats.sectionInfo.name << std::endl; + } + if (m_headerPrinted) { + m_headerPrinted = false; + } + StreamingReporterBase::sectionEnded(_sectionStats); +} + +void ConsoleReporter::benchmarkStarting(BenchmarkInfo const& info) { + lazyPrintWithoutClosingBenchmarkTable(); + + auto nameCol = Column( info.name ).width( static_cast( m_tablePrinter->columnInfos()[0].width - 2 ) ); + + bool firstLine = true; + for (auto line : nameCol) { + if (!firstLine) + (*m_tablePrinter) << ColumnBreak() << ColumnBreak() << ColumnBreak(); + else + firstLine = false; + + (*m_tablePrinter) << line << ColumnBreak(); + } +} +void ConsoleReporter::benchmarkEnded(BenchmarkStats const& stats) { + Duration average(stats.elapsedTimeInNanoseconds / stats.iterations); + (*m_tablePrinter) + << stats.iterations << ColumnBreak() + << stats.elapsedTimeInNanoseconds << ColumnBreak() + << average << ColumnBreak(); +} + +void ConsoleReporter::testCaseEnded(TestCaseStats const& _testCaseStats) { + m_tablePrinter->close(); + StreamingReporterBase::testCaseEnded(_testCaseStats); + m_headerPrinted = false; +} +void ConsoleReporter::testGroupEnded(TestGroupStats const& _testGroupStats) { + if (currentGroupInfo.used) { + printSummaryDivider(); + stream << "Summary for group '" << _testGroupStats.groupInfo.name << "':\n"; + printTotals(_testGroupStats.totals); + stream << '\n' << std::endl; + } + StreamingReporterBase::testGroupEnded(_testGroupStats); +} +void ConsoleReporter::testRunEnded(TestRunStats const& _testRunStats) { + printTotalsDivider(_testRunStats.totals); + printTotals(_testRunStats.totals); + stream << std::endl; + StreamingReporterBase::testRunEnded(_testRunStats); +} + +void ConsoleReporter::lazyPrint() { + + m_tablePrinter->close(); + lazyPrintWithoutClosingBenchmarkTable(); +} + +void ConsoleReporter::lazyPrintWithoutClosingBenchmarkTable() { + + if (!currentTestRunInfo.used) + lazyPrintRunInfo(); + if (!currentGroupInfo.used) + lazyPrintGroupInfo(); + + if (!m_headerPrinted) { + printTestCaseAndSectionHeader(); + m_headerPrinted = true; + } +} +void ConsoleReporter::lazyPrintRunInfo() { + stream << '\n' << getLineOfChars<'~'>() << '\n'; + Colour colour(Colour::SecondaryText); + stream << currentTestRunInfo->name + << " is a Catch v" << libraryVersion() << " host application.\n" + << "Run with -? for options\n\n"; + + if (m_config->rngSeed() != 0) + stream << "Randomness seeded to: " << m_config->rngSeed() << "\n\n"; + + currentTestRunInfo.used = true; +} +void ConsoleReporter::lazyPrintGroupInfo() { + if (!currentGroupInfo->name.empty() && currentGroupInfo->groupsCounts > 1) { + printClosedHeader("Group: " + currentGroupInfo->name); + currentGroupInfo.used = true; + } +} +void ConsoleReporter::printTestCaseAndSectionHeader() { + assert(!m_sectionStack.empty()); + printOpenHeader(currentTestCaseInfo->name); + + if (m_sectionStack.size() > 1) { + Colour colourGuard(Colour::Headers); + + auto + it = m_sectionStack.begin() + 1, // Skip first section (test case) + itEnd = m_sectionStack.end(); + for (; it != itEnd; ++it) + printHeaderString(it->name, 2); + } + + SourceLineInfo lineInfo = m_sectionStack.back().lineInfo; + + if (!lineInfo.empty()) { + stream << getLineOfChars<'-'>() << '\n'; + Colour colourGuard(Colour::FileName); + stream << lineInfo << '\n'; + } + stream << getLineOfChars<'.'>() << '\n' << std::endl; +} + +void ConsoleReporter::printClosedHeader(std::string const& _name) { + printOpenHeader(_name); + stream << getLineOfChars<'.'>() << '\n'; +} +void ConsoleReporter::printOpenHeader(std::string const& _name) { + stream << getLineOfChars<'-'>() << '\n'; + { + Colour colourGuard(Colour::Headers); + printHeaderString(_name); + } +} + +// if string has a : in first line will set indent to follow it on +// subsequent lines +void ConsoleReporter::printHeaderString(std::string const& _string, std::size_t indent) { + std::size_t i = _string.find(": "); + if (i != std::string::npos) + i += 2; + else + i = 0; + stream << Column(_string).indent(indent + i).initialIndent(indent) << '\n'; +} + +struct SummaryColumn { + + SummaryColumn( std::string _label, Colour::Code _colour ) + : label( std::move( _label ) ), + colour( _colour ) {} + SummaryColumn addRow( std::size_t count ) { + ReusableStringStream rss; + rss << count; + std::string row = rss.str(); + for (auto& oldRow : rows) { + while (oldRow.size() < row.size()) + oldRow = ' ' + oldRow; + while (oldRow.size() > row.size()) + row = ' ' + row; + } + rows.push_back(row); + return *this; + } + + std::string label; + Colour::Code colour; + std::vector rows; + +}; + +void ConsoleReporter::printTotals( Totals const& totals ) { + if (totals.testCases.total() == 0) { + stream << Colour(Colour::Warning) << "No tests ran\n"; + } else if (totals.assertions.total() > 0 && totals.testCases.allPassed()) { + stream << Colour(Colour::ResultSuccess) << "All tests passed"; + stream << " (" + << pluralise(totals.assertions.passed, "assertion") << " in " + << pluralise(totals.testCases.passed, "test case") << ')' + << '\n'; + } else { + + std::vector columns; + columns.push_back(SummaryColumn("", Colour::None) + .addRow(totals.testCases.total()) + .addRow(totals.assertions.total())); + columns.push_back(SummaryColumn("passed", Colour::Success) + .addRow(totals.testCases.passed) + .addRow(totals.assertions.passed)); + columns.push_back(SummaryColumn("failed", Colour::ResultError) + .addRow(totals.testCases.failed) + .addRow(totals.assertions.failed)); + columns.push_back(SummaryColumn("failed as expected", Colour::ResultExpectedFailure) + .addRow(totals.testCases.failedButOk) + .addRow(totals.assertions.failedButOk)); + + printSummaryRow("test cases", columns, 0); + printSummaryRow("assertions", columns, 1); + } +} +void ConsoleReporter::printSummaryRow(std::string const& label, std::vector const& cols, std::size_t row) { + for (auto col : cols) { + std::string value = col.rows[row]; + if (col.label.empty()) { + stream << label << ": "; + if (value != "0") + stream << value; + else + stream << Colour(Colour::Warning) << "- none -"; + } else if (value != "0") { + stream << Colour(Colour::LightGrey) << " | "; + stream << Colour(col.colour) + << value << ' ' << col.label; + } + } + stream << '\n'; +} + +void ConsoleReporter::printTotalsDivider(Totals const& totals) { + if (totals.testCases.total() > 0) { + std::size_t failedRatio = makeRatio(totals.testCases.failed, totals.testCases.total()); + std::size_t failedButOkRatio = makeRatio(totals.testCases.failedButOk, totals.testCases.total()); + std::size_t passedRatio = makeRatio(totals.testCases.passed, totals.testCases.total()); + while (failedRatio + failedButOkRatio + passedRatio < CATCH_CONFIG_CONSOLE_WIDTH - 1) + findMax(failedRatio, failedButOkRatio, passedRatio)++; + while (failedRatio + failedButOkRatio + passedRatio > CATCH_CONFIG_CONSOLE_WIDTH - 1) + findMax(failedRatio, failedButOkRatio, passedRatio)--; + + stream << Colour(Colour::Error) << std::string(failedRatio, '='); + stream << Colour(Colour::ResultExpectedFailure) << std::string(failedButOkRatio, '='); + if (totals.testCases.allPassed()) + stream << Colour(Colour::ResultSuccess) << std::string(passedRatio, '='); + else + stream << Colour(Colour::Success) << std::string(passedRatio, '='); + } else { + stream << Colour(Colour::Warning) << std::string(CATCH_CONFIG_CONSOLE_WIDTH - 1, '='); + } + stream << '\n'; +} +void ConsoleReporter::printSummaryDivider() { + stream << getLineOfChars<'-'>() << '\n'; +} + +CATCH_REGISTER_REPORTER("console", ConsoleReporter) + +} // end namespace Catch + +#if defined(_MSC_VER) +#pragma warning(pop) +#endif +// end catch_reporter_console.cpp +// start catch_reporter_junit.cpp + +#include +#include +#include +#include + +namespace Catch { + + namespace { + std::string getCurrentTimestamp() { + // Beware, this is not reentrant because of backward compatibility issues + // Also, UTC only, again because of backward compatibility (%z is C++11) + time_t rawtime; + std::time(&rawtime); + auto const timeStampSize = sizeof("2017-01-16T17:06:45Z"); + +#ifdef _MSC_VER + std::tm timeInfo = {}; + gmtime_s(&timeInfo, &rawtime); +#else + std::tm* timeInfo; + timeInfo = std::gmtime(&rawtime); +#endif + + char timeStamp[timeStampSize]; + const char * const fmt = "%Y-%m-%dT%H:%M:%SZ"; + +#ifdef _MSC_VER + std::strftime(timeStamp, timeStampSize, fmt, &timeInfo); +#else + std::strftime(timeStamp, timeStampSize, fmt, timeInfo); +#endif + return std::string(timeStamp); + } + + std::string fileNameTag(const std::vector &tags) { + auto it = std::find_if(begin(tags), + end(tags), + [] (std::string const& tag) {return tag.front() == '#'; }); + if (it != tags.end()) + return it->substr(1); + return std::string(); + } + } // anonymous namespace + + JunitReporter::JunitReporter( ReporterConfig const& _config ) + : CumulativeReporterBase( _config ), + xml( _config.stream() ) + { + m_reporterPrefs.shouldRedirectStdOut = true; + m_reporterPrefs.shouldReportAllAssertions = true; + } + + JunitReporter::~JunitReporter() {} + + std::string JunitReporter::getDescription() { + return "Reports test results in an XML format that looks like Ant's junitreport target"; + } + + void JunitReporter::noMatchingTestCases( std::string const& /*spec*/ ) {} + + void JunitReporter::testRunStarting( TestRunInfo const& runInfo ) { + CumulativeReporterBase::testRunStarting( runInfo ); + xml.startElement( "testsuites" ); + } + + void JunitReporter::testGroupStarting( GroupInfo const& groupInfo ) { + suiteTimer.start(); + stdOutForSuite.clear(); + stdErrForSuite.clear(); + unexpectedExceptions = 0; + CumulativeReporterBase::testGroupStarting( groupInfo ); + } + + void JunitReporter::testCaseStarting( TestCaseInfo const& testCaseInfo ) { + m_okToFail = testCaseInfo.okToFail(); + } + + bool JunitReporter::assertionEnded( AssertionStats const& assertionStats ) { + if( assertionStats.assertionResult.getResultType() == ResultWas::ThrewException && !m_okToFail ) + unexpectedExceptions++; + return CumulativeReporterBase::assertionEnded( assertionStats ); + } + + void JunitReporter::testCaseEnded( TestCaseStats const& testCaseStats ) { + stdOutForSuite += testCaseStats.stdOut; + stdErrForSuite += testCaseStats.stdErr; + CumulativeReporterBase::testCaseEnded( testCaseStats ); + } + + void JunitReporter::testGroupEnded( TestGroupStats const& testGroupStats ) { + double suiteTime = suiteTimer.getElapsedSeconds(); + CumulativeReporterBase::testGroupEnded( testGroupStats ); + writeGroup( *m_testGroups.back(), suiteTime ); + } + + void JunitReporter::testRunEndedCumulative() { + xml.endElement(); + } + + void JunitReporter::writeGroup( TestGroupNode const& groupNode, double suiteTime ) { + XmlWriter::ScopedElement e = xml.scopedElement( "testsuite" ); + TestGroupStats const& stats = groupNode.value; + xml.writeAttribute( "name", stats.groupInfo.name ); + xml.writeAttribute( "errors", unexpectedExceptions ); + xml.writeAttribute( "failures", stats.totals.assertions.failed-unexpectedExceptions ); + xml.writeAttribute( "tests", stats.totals.assertions.total() ); + xml.writeAttribute( "hostname", "tbd" ); // !TBD + if( m_config->showDurations() == ShowDurations::Never ) + xml.writeAttribute( "time", "" ); + else + xml.writeAttribute( "time", suiteTime ); + xml.writeAttribute( "timestamp", getCurrentTimestamp() ); + + // Write test cases + for( auto const& child : groupNode.children ) + writeTestCase( *child ); + + xml.scopedElement( "system-out" ).writeText( trim( stdOutForSuite ), false ); + xml.scopedElement( "system-err" ).writeText( trim( stdErrForSuite ), false ); + } + + void JunitReporter::writeTestCase( TestCaseNode const& testCaseNode ) { + TestCaseStats const& stats = testCaseNode.value; + + // All test cases have exactly one section - which represents the + // test case itself. That section may have 0-n nested sections + assert( testCaseNode.children.size() == 1 ); + SectionNode const& rootSection = *testCaseNode.children.front(); + + std::string className = stats.testInfo.className; + + if( className.empty() ) { + className = fileNameTag(stats.testInfo.tags); + if ( className.empty() ) + className = "global"; + } + + if ( !m_config->name().empty() ) + className = m_config->name() + "." + className; + + writeSection( className, "", rootSection ); + } + + void JunitReporter::writeSection( std::string const& className, + std::string const& rootName, + SectionNode const& sectionNode ) { + std::string name = trim( sectionNode.stats.sectionInfo.name ); + if( !rootName.empty() ) + name = rootName + '/' + name; + + if( !sectionNode.assertions.empty() || + !sectionNode.stdOut.empty() || + !sectionNode.stdErr.empty() ) { + XmlWriter::ScopedElement e = xml.scopedElement( "testcase" ); + if( className.empty() ) { + xml.writeAttribute( "classname", name ); + xml.writeAttribute( "name", "root" ); + } + else { + xml.writeAttribute( "classname", className ); + xml.writeAttribute( "name", name ); + } + xml.writeAttribute( "time", ::Catch::Detail::stringify( sectionNode.stats.durationInSeconds ) ); + + writeAssertions( sectionNode ); + + if( !sectionNode.stdOut.empty() ) + xml.scopedElement( "system-out" ).writeText( trim( sectionNode.stdOut ), false ); + if( !sectionNode.stdErr.empty() ) + xml.scopedElement( "system-err" ).writeText( trim( sectionNode.stdErr ), false ); + } + for( auto const& childNode : sectionNode.childSections ) + if( className.empty() ) + writeSection( name, "", *childNode ); + else + writeSection( className, name, *childNode ); + } + + void JunitReporter::writeAssertions( SectionNode const& sectionNode ) { + for( auto const& assertion : sectionNode.assertions ) + writeAssertion( assertion ); + } + + void JunitReporter::writeAssertion( AssertionStats const& stats ) { + AssertionResult const& result = stats.assertionResult; + if( !result.isOk() ) { + std::string elementName; + switch( result.getResultType() ) { + case ResultWas::ThrewException: + case ResultWas::FatalErrorCondition: + elementName = "error"; + break; + case ResultWas::ExplicitFailure: + elementName = "failure"; + break; + case ResultWas::ExpressionFailed: + elementName = "failure"; + break; + case ResultWas::DidntThrowException: + elementName = "failure"; + break; + + // We should never see these here: + case ResultWas::Info: + case ResultWas::Warning: + case ResultWas::Ok: + case ResultWas::Unknown: + case ResultWas::FailureBit: + case ResultWas::Exception: + elementName = "internalError"; + break; + } + + XmlWriter::ScopedElement e = xml.scopedElement( elementName ); + + xml.writeAttribute( "message", result.getExpandedExpression() ); + xml.writeAttribute( "type", result.getTestMacroName() ); + + ReusableStringStream rss; + if( !result.getMessage().empty() ) + rss << result.getMessage() << '\n'; + for( auto const& msg : stats.infoMessages ) + if( msg.type == ResultWas::Info ) + rss << msg.message << '\n'; + + rss << "at " << result.getSourceInfo(); + xml.writeText( rss.str(), false ); + } + } + + CATCH_REGISTER_REPORTER( "junit", JunitReporter ) + +} // end namespace Catch +// end catch_reporter_junit.cpp +// start catch_reporter_listening.cpp + +#include + +namespace Catch { + + ListeningReporter::ListeningReporter() { + // We will assume that listeners will always want all assertions + m_preferences.shouldReportAllAssertions = true; + } + + void ListeningReporter::addListener( IStreamingReporterPtr&& listener ) { + m_listeners.push_back( std::move( listener ) ); + } + + void ListeningReporter::addReporter(IStreamingReporterPtr&& reporter) { + assert(!m_reporter && "Listening reporter can wrap only 1 real reporter"); + m_reporter = std::move( reporter ); + m_preferences.shouldRedirectStdOut = m_reporter->getPreferences().shouldRedirectStdOut; + } + + ReporterPreferences ListeningReporter::getPreferences() const { + return m_preferences; + } + + std::set ListeningReporter::getSupportedVerbosities() { + return std::set{ }; + } + + void ListeningReporter::noMatchingTestCases( std::string const& spec ) { + for ( auto const& listener : m_listeners ) { + listener->noMatchingTestCases( spec ); + } + m_reporter->noMatchingTestCases( spec ); + } + + void ListeningReporter::benchmarkStarting( BenchmarkInfo const& benchmarkInfo ) { + for ( auto const& listener : m_listeners ) { + listener->benchmarkStarting( benchmarkInfo ); + } + m_reporter->benchmarkStarting( benchmarkInfo ); + } + void ListeningReporter::benchmarkEnded( BenchmarkStats const& benchmarkStats ) { + for ( auto const& listener : m_listeners ) { + listener->benchmarkEnded( benchmarkStats ); + } + m_reporter->benchmarkEnded( benchmarkStats ); + } + + void ListeningReporter::testRunStarting( TestRunInfo const& testRunInfo ) { + for ( auto const& listener : m_listeners ) { + listener->testRunStarting( testRunInfo ); + } + m_reporter->testRunStarting( testRunInfo ); + } + + void ListeningReporter::testGroupStarting( GroupInfo const& groupInfo ) { + for ( auto const& listener : m_listeners ) { + listener->testGroupStarting( groupInfo ); + } + m_reporter->testGroupStarting( groupInfo ); + } + + void ListeningReporter::testCaseStarting( TestCaseInfo const& testInfo ) { + for ( auto const& listener : m_listeners ) { + listener->testCaseStarting( testInfo ); + } + m_reporter->testCaseStarting( testInfo ); + } + + void ListeningReporter::sectionStarting( SectionInfo const& sectionInfo ) { + for ( auto const& listener : m_listeners ) { + listener->sectionStarting( sectionInfo ); + } + m_reporter->sectionStarting( sectionInfo ); + } + + void ListeningReporter::assertionStarting( AssertionInfo const& assertionInfo ) { + for ( auto const& listener : m_listeners ) { + listener->assertionStarting( assertionInfo ); + } + m_reporter->assertionStarting( assertionInfo ); + } + + // The return value indicates if the messages buffer should be cleared: + bool ListeningReporter::assertionEnded( AssertionStats const& assertionStats ) { + for( auto const& listener : m_listeners ) { + static_cast( listener->assertionEnded( assertionStats ) ); + } + return m_reporter->assertionEnded( assertionStats ); + } + + void ListeningReporter::sectionEnded( SectionStats const& sectionStats ) { + for ( auto const& listener : m_listeners ) { + listener->sectionEnded( sectionStats ); + } + m_reporter->sectionEnded( sectionStats ); + } + + void ListeningReporter::testCaseEnded( TestCaseStats const& testCaseStats ) { + for ( auto const& listener : m_listeners ) { + listener->testCaseEnded( testCaseStats ); + } + m_reporter->testCaseEnded( testCaseStats ); + } + + void ListeningReporter::testGroupEnded( TestGroupStats const& testGroupStats ) { + for ( auto const& listener : m_listeners ) { + listener->testGroupEnded( testGroupStats ); + } + m_reporter->testGroupEnded( testGroupStats ); + } + + void ListeningReporter::testRunEnded( TestRunStats const& testRunStats ) { + for ( auto const& listener : m_listeners ) { + listener->testRunEnded( testRunStats ); + } + m_reporter->testRunEnded( testRunStats ); + } + + void ListeningReporter::skipTest( TestCaseInfo const& testInfo ) { + for ( auto const& listener : m_listeners ) { + listener->skipTest( testInfo ); + } + m_reporter->skipTest( testInfo ); + } + + bool ListeningReporter::isMulti() const { + return true; + } + +} // end namespace Catch +// end catch_reporter_listening.cpp +// start catch_reporter_xml.cpp + +#if defined(_MSC_VER) +#pragma warning(push) +#pragma warning(disable:4061) // Not all labels are EXPLICITLY handled in switch + // Note that 4062 (not all labels are handled + // and default is missing) is enabled +#endif + +namespace Catch { + XmlReporter::XmlReporter( ReporterConfig const& _config ) + : StreamingReporterBase( _config ), + m_xml(_config.stream()) + { + m_reporterPrefs.shouldRedirectStdOut = true; + m_reporterPrefs.shouldReportAllAssertions = true; + } + + XmlReporter::~XmlReporter() = default; + + std::string XmlReporter::getDescription() { + return "Reports test results as an XML document"; + } + + std::string XmlReporter::getStylesheetRef() const { + return std::string(); + } + + void XmlReporter::writeSourceInfo( SourceLineInfo const& sourceInfo ) { + m_xml + .writeAttribute( "filename", sourceInfo.file ) + .writeAttribute( "line", sourceInfo.line ); + } + + void XmlReporter::noMatchingTestCases( std::string const& s ) { + StreamingReporterBase::noMatchingTestCases( s ); + } + + void XmlReporter::testRunStarting( TestRunInfo const& testInfo ) { + StreamingReporterBase::testRunStarting( testInfo ); + std::string stylesheetRef = getStylesheetRef(); + if( !stylesheetRef.empty() ) + m_xml.writeStylesheetRef( stylesheetRef ); + m_xml.startElement( "Catch" ); + if( !m_config->name().empty() ) + m_xml.writeAttribute( "name", m_config->name() ); + } + + void XmlReporter::testGroupStarting( GroupInfo const& groupInfo ) { + StreamingReporterBase::testGroupStarting( groupInfo ); + m_xml.startElement( "Group" ) + .writeAttribute( "name", groupInfo.name ); + } + + void XmlReporter::testCaseStarting( TestCaseInfo const& testInfo ) { + StreamingReporterBase::testCaseStarting(testInfo); + m_xml.startElement( "TestCase" ) + .writeAttribute( "name", trim( testInfo.name ) ) + .writeAttribute( "description", testInfo.description ) + .writeAttribute( "tags", testInfo.tagsAsString() ); + + writeSourceInfo( testInfo.lineInfo ); + + if ( m_config->showDurations() == ShowDurations::Always ) + m_testCaseTimer.start(); + m_xml.ensureTagClosed(); + } + + void XmlReporter::sectionStarting( SectionInfo const& sectionInfo ) { + StreamingReporterBase::sectionStarting( sectionInfo ); + if( m_sectionDepth++ > 0 ) { + m_xml.startElement( "Section" ) + .writeAttribute( "name", trim( sectionInfo.name ) ); + writeSourceInfo( sectionInfo.lineInfo ); + m_xml.ensureTagClosed(); + } + } + + void XmlReporter::assertionStarting( AssertionInfo const& ) { } + + bool XmlReporter::assertionEnded( AssertionStats const& assertionStats ) { + + AssertionResult const& result = assertionStats.assertionResult; + + bool includeResults = m_config->includeSuccessfulResults() || !result.isOk(); + + if( includeResults || result.getResultType() == ResultWas::Warning ) { + // Print any info messages in tags. + for( auto const& msg : assertionStats.infoMessages ) { + if( msg.type == ResultWas::Info && includeResults ) { + m_xml.scopedElement( "Info" ) + .writeText( msg.message ); + } else if ( msg.type == ResultWas::Warning ) { + m_xml.scopedElement( "Warning" ) + .writeText( msg.message ); + } + } + } + + // Drop out if result was successful but we're not printing them. + if( !includeResults && result.getResultType() != ResultWas::Warning ) + return true; + + // Print the expression if there is one. + if( result.hasExpression() ) { + m_xml.startElement( "Expression" ) + .writeAttribute( "success", result.succeeded() ) + .writeAttribute( "type", result.getTestMacroName() ); + + writeSourceInfo( result.getSourceInfo() ); + + m_xml.scopedElement( "Original" ) + .writeText( result.getExpression() ); + m_xml.scopedElement( "Expanded" ) + .writeText( result.getExpandedExpression() ); + } + + // And... Print a result applicable to each result type. + switch( result.getResultType() ) { + case ResultWas::ThrewException: + m_xml.startElement( "Exception" ); + writeSourceInfo( result.getSourceInfo() ); + m_xml.writeText( result.getMessage() ); + m_xml.endElement(); + break; + case ResultWas::FatalErrorCondition: + m_xml.startElement( "FatalErrorCondition" ); + writeSourceInfo( result.getSourceInfo() ); + m_xml.writeText( result.getMessage() ); + m_xml.endElement(); + break; + case ResultWas::Info: + m_xml.scopedElement( "Info" ) + .writeText( result.getMessage() ); + break; + case ResultWas::Warning: + // Warning will already have been written + break; + case ResultWas::ExplicitFailure: + m_xml.startElement( "Failure" ); + writeSourceInfo( result.getSourceInfo() ); + m_xml.writeText( result.getMessage() ); + m_xml.endElement(); + break; + default: + break; + } + + if( result.hasExpression() ) + m_xml.endElement(); + + return true; + } + + void XmlReporter::sectionEnded( SectionStats const& sectionStats ) { + StreamingReporterBase::sectionEnded( sectionStats ); + if( --m_sectionDepth > 0 ) { + XmlWriter::ScopedElement e = m_xml.scopedElement( "OverallResults" ); + e.writeAttribute( "successes", sectionStats.assertions.passed ); + e.writeAttribute( "failures", sectionStats.assertions.failed ); + e.writeAttribute( "expectedFailures", sectionStats.assertions.failedButOk ); + + if ( m_config->showDurations() == ShowDurations::Always ) + e.writeAttribute( "durationInSeconds", sectionStats.durationInSeconds ); + + m_xml.endElement(); + } + } + + void XmlReporter::testCaseEnded( TestCaseStats const& testCaseStats ) { + StreamingReporterBase::testCaseEnded( testCaseStats ); + XmlWriter::ScopedElement e = m_xml.scopedElement( "OverallResult" ); + e.writeAttribute( "success", testCaseStats.totals.assertions.allOk() ); + + if ( m_config->showDurations() == ShowDurations::Always ) + e.writeAttribute( "durationInSeconds", m_testCaseTimer.getElapsedSeconds() ); + + if( !testCaseStats.stdOut.empty() ) + m_xml.scopedElement( "StdOut" ).writeText( trim( testCaseStats.stdOut ), false ); + if( !testCaseStats.stdErr.empty() ) + m_xml.scopedElement( "StdErr" ).writeText( trim( testCaseStats.stdErr ), false ); + + m_xml.endElement(); + } + + void XmlReporter::testGroupEnded( TestGroupStats const& testGroupStats ) { + StreamingReporterBase::testGroupEnded( testGroupStats ); + // TODO: Check testGroupStats.aborting and act accordingly. + m_xml.scopedElement( "OverallResults" ) + .writeAttribute( "successes", testGroupStats.totals.assertions.passed ) + .writeAttribute( "failures", testGroupStats.totals.assertions.failed ) + .writeAttribute( "expectedFailures", testGroupStats.totals.assertions.failedButOk ); + m_xml.endElement(); + } + + void XmlReporter::testRunEnded( TestRunStats const& testRunStats ) { + StreamingReporterBase::testRunEnded( testRunStats ); + m_xml.scopedElement( "OverallResults" ) + .writeAttribute( "successes", testRunStats.totals.assertions.passed ) + .writeAttribute( "failures", testRunStats.totals.assertions.failed ) + .writeAttribute( "expectedFailures", testRunStats.totals.assertions.failedButOk ); + m_xml.endElement(); + } + + CATCH_REGISTER_REPORTER( "xml", XmlReporter ) + +} // end namespace Catch + +#if defined(_MSC_VER) +#pragma warning(pop) +#endif +// end catch_reporter_xml.cpp + +namespace Catch { + LeakDetector leakDetector; +} + +#ifdef __clang__ +#pragma clang diagnostic pop +#endif + +// end catch_impl.hpp +#endif + +#ifdef CATCH_CONFIG_MAIN +// start catch_default_main.hpp + +#ifndef __OBJC__ + +#if defined(CATCH_CONFIG_WCHAR) && defined(WIN32) && defined(_UNICODE) && !defined(DO_NOT_USE_WMAIN) +// Standard C/C++ Win32 Unicode wmain entry point +extern "C" int wmain (int argc, wchar_t * argv[], wchar_t * []) { +#else +// Standard C/C++ main entry point +int main (int argc, char * argv[]) { +#endif + + return Catch::Session().run( argc, argv ); +} + +#else // __OBJC__ + +// Objective-C entry point +int main (int argc, char * const argv[]) { +#if !CATCH_ARC_ENABLED + NSAutoreleasePool * pool = [[NSAutoreleasePool alloc] init]; +#endif + + Catch::registerTestMethods(); + int result = Catch::Session().run( argc, (char**)argv ); + +#if !CATCH_ARC_ENABLED + [pool drain]; +#endif + + return result; +} + +#endif // __OBJC__ + +// end catch_default_main.hpp +#endif + +#if !defined(CATCH_CONFIG_IMPL_ONLY) + +#ifdef CLARA_CONFIG_MAIN_NOT_DEFINED +# undef CLARA_CONFIG_MAIN +#endif + +#if !defined(CATCH_CONFIG_DISABLE) +////// +// If this config identifier is defined then all CATCH macros are prefixed with CATCH_ +#ifdef CATCH_CONFIG_PREFIX_ALL + +#define CATCH_REQUIRE( ... ) INTERNAL_CATCH_TEST( "CATCH_REQUIRE", Catch::ResultDisposition::Normal, __VA_ARGS__ ) +#define CATCH_REQUIRE_FALSE( ... ) INTERNAL_CATCH_TEST( "CATCH_REQUIRE_FALSE", Catch::ResultDisposition::Normal | Catch::ResultDisposition::FalseTest, __VA_ARGS__ ) + +#define CATCH_REQUIRE_THROWS( ... ) INTERNAL_CATCH_THROWS( "CATCH_REQUIRE_THROWS", Catch::ResultDisposition::Normal, "", __VA_ARGS__ ) +#define CATCH_REQUIRE_THROWS_AS( expr, exceptionType ) INTERNAL_CATCH_THROWS_AS( "CATCH_REQUIRE_THROWS_AS", exceptionType, Catch::ResultDisposition::Normal, expr ) +#define CATCH_REQUIRE_THROWS_WITH( expr, matcher ) INTERNAL_CATCH_THROWS_STR_MATCHES( "CATCH_REQUIRE_THROWS_WITH", Catch::ResultDisposition::Normal, matcher, expr ) +#if !defined(CATCH_CONFIG_DISABLE_MATCHERS) +#define CATCH_REQUIRE_THROWS_MATCHES( expr, exceptionType, matcher ) INTERNAL_CATCH_THROWS_MATCHES( "CATCH_REQUIRE_THROWS_MATCHES", exceptionType, Catch::ResultDisposition::Normal, matcher, expr ) +#endif// CATCH_CONFIG_DISABLE_MATCHERS +#define CATCH_REQUIRE_NOTHROW( ... ) INTERNAL_CATCH_NO_THROW( "CATCH_REQUIRE_NOTHROW", Catch::ResultDisposition::Normal, __VA_ARGS__ ) + +#define CATCH_CHECK( ... ) INTERNAL_CATCH_TEST( "CATCH_CHECK", Catch::ResultDisposition::ContinueOnFailure, __VA_ARGS__ ) +#define CATCH_CHECK_FALSE( ... ) INTERNAL_CATCH_TEST( "CATCH_CHECK_FALSE", Catch::ResultDisposition::ContinueOnFailure | Catch::ResultDisposition::FalseTest, __VA_ARGS__ ) +#define CATCH_CHECKED_IF( ... ) INTERNAL_CATCH_IF( "CATCH_CHECKED_IF", Catch::ResultDisposition::ContinueOnFailure, __VA_ARGS__ ) +#define CATCH_CHECKED_ELSE( ... ) INTERNAL_CATCH_ELSE( "CATCH_CHECKED_ELSE", Catch::ResultDisposition::ContinueOnFailure, __VA_ARGS__ ) +#define CATCH_CHECK_NOFAIL( ... ) INTERNAL_CATCH_TEST( "CATCH_CHECK_NOFAIL", Catch::ResultDisposition::ContinueOnFailure | Catch::ResultDisposition::SuppressFail, __VA_ARGS__ ) + +#define CATCH_CHECK_THROWS( ... ) INTERNAL_CATCH_THROWS( "CATCH_CHECK_THROWS", Catch::ResultDisposition::ContinueOnFailure, "", __VA_ARGS__ ) +#define CATCH_CHECK_THROWS_AS( expr, exceptionType ) INTERNAL_CATCH_THROWS_AS( "CATCH_CHECK_THROWS_AS", exceptionType, Catch::ResultDisposition::ContinueOnFailure, expr ) +#define CATCH_CHECK_THROWS_WITH( expr, matcher ) INTERNAL_CATCH_THROWS_STR_MATCHES( "CATCH_CHECK_THROWS_WITH", Catch::ResultDisposition::ContinueOnFailure, matcher, expr ) +#if !defined(CATCH_CONFIG_DISABLE_MATCHERS) +#define CATCH_CHECK_THROWS_MATCHES( expr, exceptionType, matcher ) INTERNAL_CATCH_THROWS_MATCHES( "CATCH_CHECK_THROWS_MATCHES", exceptionType, Catch::ResultDisposition::ContinueOnFailure, matcher, expr ) +#endif // CATCH_CONFIG_DISABLE_MATCHERS +#define CATCH_CHECK_NOTHROW( ... ) INTERNAL_CATCH_NO_THROW( "CATCH_CHECK_NOTHROW", Catch::ResultDisposition::ContinueOnFailure, __VA_ARGS__ ) + +#if !defined(CATCH_CONFIG_DISABLE_MATCHERS) +#define CATCH_CHECK_THAT( arg, matcher ) INTERNAL_CHECK_THAT( "CATCH_CHECK_THAT", matcher, Catch::ResultDisposition::ContinueOnFailure, arg ) + +#define CATCH_REQUIRE_THAT( arg, matcher ) INTERNAL_CHECK_THAT( "CATCH_REQUIRE_THAT", matcher, Catch::ResultDisposition::Normal, arg ) +#endif // CATCH_CONFIG_DISABLE_MATCHERS + +#define CATCH_INFO( msg ) INTERNAL_CATCH_INFO( "CATCH_INFO", msg ) +#define CATCH_WARN( msg ) INTERNAL_CATCH_MSG( "CATCH_WARN", Catch::ResultWas::Warning, Catch::ResultDisposition::ContinueOnFailure, msg ) +#define CATCH_CAPTURE( msg ) INTERNAL_CATCH_INFO( "CATCH_CAPTURE", #msg " := " << ::Catch::Detail::stringify(msg) ) + +#define CATCH_TEST_CASE( ... ) INTERNAL_CATCH_TESTCASE( __VA_ARGS__ ) +#define CATCH_TEST_CASE_METHOD( className, ... ) INTERNAL_CATCH_TEST_CASE_METHOD( className, __VA_ARGS__ ) +#define CATCH_METHOD_AS_TEST_CASE( method, ... ) INTERNAL_CATCH_METHOD_AS_TEST_CASE( method, __VA_ARGS__ ) +#define CATCH_REGISTER_TEST_CASE( Function, ... ) INTERNAL_CATCH_REGISTER_TESTCASE( Function, __VA_ARGS__ ) +#define CATCH_SECTION( ... ) INTERNAL_CATCH_SECTION( __VA_ARGS__ ) +#define CATCH_DYNAMIC_SECTION( ... ) INTERNAL_CATCH_DYNAMIC_SECTION( __VA_ARGS__ ) +#define CATCH_FAIL( ... ) INTERNAL_CATCH_MSG( "CATCH_FAIL", Catch::ResultWas::ExplicitFailure, Catch::ResultDisposition::Normal, __VA_ARGS__ ) +#define CATCH_FAIL_CHECK( ... ) INTERNAL_CATCH_MSG( "CATCH_FAIL_CHECK", Catch::ResultWas::ExplicitFailure, Catch::ResultDisposition::ContinueOnFailure, __VA_ARGS__ ) +#define CATCH_SUCCEED( ... ) INTERNAL_CATCH_MSG( "CATCH_SUCCEED", Catch::ResultWas::Ok, Catch::ResultDisposition::ContinueOnFailure, __VA_ARGS__ ) + +#define CATCH_ANON_TEST_CASE() INTERNAL_CATCH_TESTCASE() + +// "BDD-style" convenience wrappers +#define CATCH_SCENARIO( ... ) CATCH_TEST_CASE( "Scenario: " __VA_ARGS__ ) +#define CATCH_SCENARIO_METHOD( className, ... ) INTERNAL_CATCH_TEST_CASE_METHOD( className, "Scenario: " __VA_ARGS__ ) +#define CATCH_GIVEN( desc ) INTERNAL_CATCH_DYNAMIC_SECTION( " Given: " << desc ) +#define CATCH_WHEN( desc ) INTERNAL_CATCH_DYNAMIC_SECTION( " When: " << desc ) +#define CATCH_AND_WHEN( desc ) INTERNAL_CATCH_DYNAMIC_SECTION( "And when: " << desc ) +#define CATCH_THEN( desc ) INTERNAL_CATCH_DYNAMIC_SECTION( " Then: " << desc ) +#define CATCH_AND_THEN( desc ) INTERNAL_CATCH_DYNAMIC_SECTION( " And: " << desc ) + +// If CATCH_CONFIG_PREFIX_ALL is not defined then the CATCH_ prefix is not required +#else + +#define REQUIRE( ... ) INTERNAL_CATCH_TEST( "REQUIRE", Catch::ResultDisposition::Normal, __VA_ARGS__ ) +#define REQUIRE_FALSE( ... ) INTERNAL_CATCH_TEST( "REQUIRE_FALSE", Catch::ResultDisposition::Normal | Catch::ResultDisposition::FalseTest, __VA_ARGS__ ) + +#define REQUIRE_THROWS( ... ) INTERNAL_CATCH_THROWS( "REQUIRE_THROWS", Catch::ResultDisposition::Normal, __VA_ARGS__ ) +#define REQUIRE_THROWS_AS( expr, exceptionType ) INTERNAL_CATCH_THROWS_AS( "REQUIRE_THROWS_AS", exceptionType, Catch::ResultDisposition::Normal, expr ) +#define REQUIRE_THROWS_WITH( expr, matcher ) INTERNAL_CATCH_THROWS_STR_MATCHES( "REQUIRE_THROWS_WITH", Catch::ResultDisposition::Normal, matcher, expr ) +#if !defined(CATCH_CONFIG_DISABLE_MATCHERS) +#define REQUIRE_THROWS_MATCHES( expr, exceptionType, matcher ) INTERNAL_CATCH_THROWS_MATCHES( "REQUIRE_THROWS_MATCHES", exceptionType, Catch::ResultDisposition::Normal, matcher, expr ) +#endif // CATCH_CONFIG_DISABLE_MATCHERS +#define REQUIRE_NOTHROW( ... ) INTERNAL_CATCH_NO_THROW( "REQUIRE_NOTHROW", Catch::ResultDisposition::Normal, __VA_ARGS__ ) + +#define CHECK( ... ) INTERNAL_CATCH_TEST( "CHECK", Catch::ResultDisposition::ContinueOnFailure, __VA_ARGS__ ) +#define CHECK_FALSE( ... ) INTERNAL_CATCH_TEST( "CHECK_FALSE", Catch::ResultDisposition::ContinueOnFailure | Catch::ResultDisposition::FalseTest, __VA_ARGS__ ) +#define CHECKED_IF( ... ) INTERNAL_CATCH_IF( "CHECKED_IF", Catch::ResultDisposition::ContinueOnFailure, __VA_ARGS__ ) +#define CHECKED_ELSE( ... ) INTERNAL_CATCH_ELSE( "CHECKED_ELSE", Catch::ResultDisposition::ContinueOnFailure, __VA_ARGS__ ) +#define CHECK_NOFAIL( ... ) INTERNAL_CATCH_TEST( "CHECK_NOFAIL", Catch::ResultDisposition::ContinueOnFailure | Catch::ResultDisposition::SuppressFail, __VA_ARGS__ ) + +#define CHECK_THROWS( ... ) INTERNAL_CATCH_THROWS( "CHECK_THROWS", Catch::ResultDisposition::ContinueOnFailure, __VA_ARGS__ ) +#define CHECK_THROWS_AS( expr, exceptionType ) INTERNAL_CATCH_THROWS_AS( "CHECK_THROWS_AS", exceptionType, Catch::ResultDisposition::ContinueOnFailure, expr ) +#define CHECK_THROWS_WITH( expr, matcher ) INTERNAL_CATCH_THROWS_STR_MATCHES( "CHECK_THROWS_WITH", Catch::ResultDisposition::ContinueOnFailure, matcher, expr ) +#if !defined(CATCH_CONFIG_DISABLE_MATCHERS) +#define CHECK_THROWS_MATCHES( expr, exceptionType, matcher ) INTERNAL_CATCH_THROWS_MATCHES( "CHECK_THROWS_MATCHES", exceptionType, Catch::ResultDisposition::ContinueOnFailure, matcher, expr ) +#endif // CATCH_CONFIG_DISABLE_MATCHERS +#define CHECK_NOTHROW( ... ) INTERNAL_CATCH_NO_THROW( "CHECK_NOTHROW", Catch::ResultDisposition::ContinueOnFailure, __VA_ARGS__ ) + +#if !defined(CATCH_CONFIG_DISABLE_MATCHERS) +#define CHECK_THAT( arg, matcher ) INTERNAL_CHECK_THAT( "CHECK_THAT", matcher, Catch::ResultDisposition::ContinueOnFailure, arg ) + +#define REQUIRE_THAT( arg, matcher ) INTERNAL_CHECK_THAT( "REQUIRE_THAT", matcher, Catch::ResultDisposition::Normal, arg ) +#endif // CATCH_CONFIG_DISABLE_MATCHERS + +#define INFO( msg ) INTERNAL_CATCH_INFO( "INFO", msg ) +#define WARN( msg ) INTERNAL_CATCH_MSG( "WARN", Catch::ResultWas::Warning, Catch::ResultDisposition::ContinueOnFailure, msg ) +#define CAPTURE( msg ) INTERNAL_CATCH_INFO( "CAPTURE", #msg " := " << ::Catch::Detail::stringify(msg) ) + +#define TEST_CASE( ... ) INTERNAL_CATCH_TESTCASE( __VA_ARGS__ ) +#define TEST_CASE_METHOD( className, ... ) INTERNAL_CATCH_TEST_CASE_METHOD( className, __VA_ARGS__ ) +#define METHOD_AS_TEST_CASE( method, ... ) INTERNAL_CATCH_METHOD_AS_TEST_CASE( method, __VA_ARGS__ ) +#define REGISTER_TEST_CASE( Function, ... ) INTERNAL_CATCH_REGISTER_TESTCASE( Function, __VA_ARGS__ ) +#define SECTION( ... ) INTERNAL_CATCH_SECTION( __VA_ARGS__ ) +#define DYNAMIC_SECTION( ... ) INTERNAL_CATCH_DYNAMIC_SECTION( __VA_ARGS__ ) +#define FAIL( ... ) INTERNAL_CATCH_MSG( "FAIL", Catch::ResultWas::ExplicitFailure, Catch::ResultDisposition::Normal, __VA_ARGS__ ) +#define FAIL_CHECK( ... ) INTERNAL_CATCH_MSG( "FAIL_CHECK", Catch::ResultWas::ExplicitFailure, Catch::ResultDisposition::ContinueOnFailure, __VA_ARGS__ ) +#define SUCCEED( ... ) INTERNAL_CATCH_MSG( "SUCCEED", Catch::ResultWas::Ok, Catch::ResultDisposition::ContinueOnFailure, __VA_ARGS__ ) +#define ANON_TEST_CASE() INTERNAL_CATCH_TESTCASE() + +#endif + +#define CATCH_TRANSLATE_EXCEPTION( signature ) INTERNAL_CATCH_TRANSLATE_EXCEPTION( signature ) + +// "BDD-style" convenience wrappers +#define SCENARIO( ... ) TEST_CASE( "Scenario: " __VA_ARGS__ ) +#define SCENARIO_METHOD( className, ... ) INTERNAL_CATCH_TEST_CASE_METHOD( className, "Scenario: " __VA_ARGS__ ) + +#define GIVEN( desc ) INTERNAL_CATCH_DYNAMIC_SECTION( " Given: " << desc ) +#define WHEN( desc ) INTERNAL_CATCH_DYNAMIC_SECTION( " When: " << desc ) +#define AND_WHEN( desc ) INTERNAL_CATCH_DYNAMIC_SECTION( "And when: " << desc ) +#define THEN( desc ) INTERNAL_CATCH_DYNAMIC_SECTION( " Then: " << desc ) +#define AND_THEN( desc ) INTERNAL_CATCH_DYNAMIC_SECTION( " And: " << desc ) + +using Catch::Detail::Approx; + +#else // CATCH_CONFIG_DISABLE + +////// +// If this config identifier is defined then all CATCH macros are prefixed with CATCH_ +#ifdef CATCH_CONFIG_PREFIX_ALL + +#define CATCH_REQUIRE( ... ) (void)(0) +#define CATCH_REQUIRE_FALSE( ... ) (void)(0) + +#define CATCH_REQUIRE_THROWS( ... ) (void)(0) +#define CATCH_REQUIRE_THROWS_AS( expr, exceptionType ) (void)(0) +#define CATCH_REQUIRE_THROWS_WITH( expr, matcher ) (void)(0) +#if !defined(CATCH_CONFIG_DISABLE_MATCHERS) +#define CATCH_REQUIRE_THROWS_MATCHES( expr, exceptionType, matcher ) (void)(0) +#endif// CATCH_CONFIG_DISABLE_MATCHERS +#define CATCH_REQUIRE_NOTHROW( ... ) (void)(0) + +#define CATCH_CHECK( ... ) (void)(0) +#define CATCH_CHECK_FALSE( ... ) (void)(0) +#define CATCH_CHECKED_IF( ... ) if (__VA_ARGS__) +#define CATCH_CHECKED_ELSE( ... ) if (!(__VA_ARGS__)) +#define CATCH_CHECK_NOFAIL( ... ) (void)(0) + +#define CATCH_CHECK_THROWS( ... ) (void)(0) +#define CATCH_CHECK_THROWS_AS( expr, exceptionType ) (void)(0) +#define CATCH_CHECK_THROWS_WITH( expr, matcher ) (void)(0) +#if !defined(CATCH_CONFIG_DISABLE_MATCHERS) +#define CATCH_CHECK_THROWS_MATCHES( expr, exceptionType, matcher ) (void)(0) +#endif // CATCH_CONFIG_DISABLE_MATCHERS +#define CATCH_CHECK_NOTHROW( ... ) (void)(0) + +#if !defined(CATCH_CONFIG_DISABLE_MATCHERS) +#define CATCH_CHECK_THAT( arg, matcher ) (void)(0) + +#define CATCH_REQUIRE_THAT( arg, matcher ) (void)(0) +#endif // CATCH_CONFIG_DISABLE_MATCHERS + +#define CATCH_INFO( msg ) (void)(0) +#define CATCH_WARN( msg ) (void)(0) +#define CATCH_CAPTURE( msg ) (void)(0) + +#define CATCH_TEST_CASE( ... ) INTERNAL_CATCH_TESTCASE_NO_REGISTRATION(INTERNAL_CATCH_UNIQUE_NAME( ____C_A_T_C_H____T_E_S_T____ )) +#define CATCH_TEST_CASE_METHOD( className, ... ) INTERNAL_CATCH_TESTCASE_NO_REGISTRATION(INTERNAL_CATCH_UNIQUE_NAME( ____C_A_T_C_H____T_E_S_T____ )) +#define CATCH_METHOD_AS_TEST_CASE( method, ... ) +#define CATCH_REGISTER_TEST_CASE( Function, ... ) (void)(0) +#define CATCH_SECTION( ... ) +#define CATCH_DYNAMIC_SECTION( ... ) +#define CATCH_FAIL( ... ) (void)(0) +#define CATCH_FAIL_CHECK( ... ) (void)(0) +#define CATCH_SUCCEED( ... ) (void)(0) + +#define CATCH_ANON_TEST_CASE() INTERNAL_CATCH_TESTCASE_NO_REGISTRATION(INTERNAL_CATCH_UNIQUE_NAME( ____C_A_T_C_H____T_E_S_T____ )) + +// "BDD-style" convenience wrappers +#define CATCH_SCENARIO( ... ) INTERNAL_CATCH_TESTCASE_NO_REGISTRATION(INTERNAL_CATCH_UNIQUE_NAME( ____C_A_T_C_H____T_E_S_T____ )) +#define CATCH_SCENARIO_METHOD( className, ... ) INTERNAL_CATCH_TESTCASE_METHOD_NO_REGISTRATION(INTERNAL_CATCH_UNIQUE_NAME( ____C_A_T_C_H____T_E_S_T____ ), className ) +#define CATCH_GIVEN( desc ) +#define CATCH_WHEN( desc ) +#define CATCH_AND_WHEN( desc ) +#define CATCH_THEN( desc ) +#define CATCH_AND_THEN( desc ) + +// If CATCH_CONFIG_PREFIX_ALL is not defined then the CATCH_ prefix is not required +#else + +#define REQUIRE( ... ) (void)(0) +#define REQUIRE_FALSE( ... ) (void)(0) + +#define REQUIRE_THROWS( ... ) (void)(0) +#define REQUIRE_THROWS_AS( expr, exceptionType ) (void)(0) +#define REQUIRE_THROWS_WITH( expr, matcher ) (void)(0) +#if !defined(CATCH_CONFIG_DISABLE_MATCHERS) +#define REQUIRE_THROWS_MATCHES( expr, exceptionType, matcher ) (void)(0) +#endif // CATCH_CONFIG_DISABLE_MATCHERS +#define REQUIRE_NOTHROW( ... ) (void)(0) + +#define CHECK( ... ) (void)(0) +#define CHECK_FALSE( ... ) (void)(0) +#define CHECKED_IF( ... ) if (__VA_ARGS__) +#define CHECKED_ELSE( ... ) if (!(__VA_ARGS__)) +#define CHECK_NOFAIL( ... ) (void)(0) + +#define CHECK_THROWS( ... ) (void)(0) +#define CHECK_THROWS_AS( expr, exceptionType ) (void)(0) +#define CHECK_THROWS_WITH( expr, matcher ) (void)(0) +#if !defined(CATCH_CONFIG_DISABLE_MATCHERS) +#define CHECK_THROWS_MATCHES( expr, exceptionType, matcher ) (void)(0) +#endif // CATCH_CONFIG_DISABLE_MATCHERS +#define CHECK_NOTHROW( ... ) (void)(0) + +#if !defined(CATCH_CONFIG_DISABLE_MATCHERS) +#define CHECK_THAT( arg, matcher ) (void)(0) + +#define REQUIRE_THAT( arg, matcher ) (void)(0) +#endif // CATCH_CONFIG_DISABLE_MATCHERS + +#define INFO( msg ) (void)(0) +#define WARN( msg ) (void)(0) +#define CAPTURE( msg ) (void)(0) + +#define TEST_CASE( ... ) INTERNAL_CATCH_TESTCASE_NO_REGISTRATION(INTERNAL_CATCH_UNIQUE_NAME( ____C_A_T_C_H____T_E_S_T____ )) +#define TEST_CASE_METHOD( className, ... ) INTERNAL_CATCH_TESTCASE_NO_REGISTRATION(INTERNAL_CATCH_UNIQUE_NAME( ____C_A_T_C_H____T_E_S_T____ )) +#define METHOD_AS_TEST_CASE( method, ... ) +#define REGISTER_TEST_CASE( Function, ... ) (void)(0) +#define SECTION( ... ) +#define DYNAMIC_SECTION( ... ) +#define FAIL( ... ) (void)(0) +#define FAIL_CHECK( ... ) (void)(0) +#define SUCCEED( ... ) (void)(0) +#define ANON_TEST_CASE() INTERNAL_CATCH_TESTCASE_NO_REGISTRATION(INTERNAL_CATCH_UNIQUE_NAME( ____C_A_T_C_H____T_E_S_T____ )) + +#endif + +#define CATCH_TRANSLATE_EXCEPTION( signature ) INTERNAL_CATCH_TRANSLATE_EXCEPTION_NO_REG( INTERNAL_CATCH_UNIQUE_NAME( catch_internal_ExceptionTranslator ), signature ) + +// "BDD-style" convenience wrappers +#define SCENARIO( ... ) INTERNAL_CATCH_TESTCASE_NO_REGISTRATION(INTERNAL_CATCH_UNIQUE_NAME( ____C_A_T_C_H____T_E_S_T____ ) ) +#define SCENARIO_METHOD( className, ... ) INTERNAL_CATCH_TESTCASE_METHOD_NO_REGISTRATION(INTERNAL_CATCH_UNIQUE_NAME( ____C_A_T_C_H____T_E_S_T____ ), className ) + +#define GIVEN( desc ) +#define WHEN( desc ) +#define AND_WHEN( desc ) +#define THEN( desc ) +#define AND_THEN( desc ) + +using Catch::Detail::Approx; + +#endif + +#endif // ! CATCH_CONFIG_IMPL_ONLY + +// start catch_reenable_warnings.h + + +#ifdef __clang__ +# ifdef __ICC // icpc defines the __clang__ macro +# pragma warning(pop) +# else +# pragma clang diagnostic pop +# endif +#elif defined __GNUC__ +# pragma GCC diagnostic pop +#endif + +// end catch_reenable_warnings.h +// end catch.hpp +#endif // TWOBLUECUBES_SINGLE_INCLUDE_CATCH_HPP_INCLUDED + diff --git a/src/third_party/cppcodec/test/catch/single_include/catch2/catch_reporter_automake.hpp b/src/third_party/cppcodec/test/catch/single_include/catch2/catch_reporter_automake.hpp new file mode 100644 index 0000000000..dbebe97516 --- /dev/null +++ b/src/third_party/cppcodec/test/catch/single_include/catch2/catch_reporter_automake.hpp @@ -0,0 +1,62 @@ +/* + * Created by Justin R. Wilson on 2/19/2017. + * Copyright 2017 Justin R. Wilson. 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_CATCH_REPORTER_AUTOMAKE_HPP_INCLUDED +#define TWOBLUECUBES_CATCH_REPORTER_AUTOMAKE_HPP_INCLUDED + +// Don't #include any Catch headers here - we can assume they are already +// included before this header. +// This is not good practice in general but is necessary in this case so this +// file can be distributed as a single header that works with the main +// Catch single header. + +namespace Catch { + + struct AutomakeReporter : StreamingReporterBase { + AutomakeReporter( ReporterConfig const& _config ) + : StreamingReporterBase( _config ) + {} + + ~AutomakeReporter() override; + + static std::string getDescription() { + return "Reports test results in the format of Automake .trs files"; + } + + void assertionStarting( AssertionInfo const& ) override {} + + bool assertionEnded( AssertionStats const& /*_assertionStats*/ ) override { return true; } + + void testCaseEnded( TestCaseStats const& _testCaseStats ) override { + // Possible values to emit are PASS, XFAIL, SKIP, FAIL, XPASS and ERROR. + stream << ":test-result: "; + if (_testCaseStats.totals.assertions.allPassed()) { + stream << "PASS"; + } else if (_testCaseStats.totals.assertions.allOk()) { + stream << "XFAIL"; + } else { + stream << "FAIL"; + } + stream << ' ' << _testCaseStats.testInfo.name << '\n'; + StreamingReporterBase::testCaseEnded( _testCaseStats ); + } + + void skipTest( TestCaseInfo const& testInfo ) override { + stream << ":test-result: SKIP " << testInfo.name << '\n'; + } + + }; + +#ifdef CATCH_IMPL + AutomakeReporter::~AutomakeReporter() {} +#endif + + CATCH_REGISTER_REPORTER( "automake", AutomakeReporter) + +} // end namespace Catch + +#endif // TWOBLUECUBES_CATCH_REPORTER_AUTOMAKE_HPP_INCLUDED diff --git a/src/third_party/cppcodec/test/catch/single_include/catch2/catch_reporter_tap.hpp b/src/third_party/cppcodec/test/catch/single_include/catch2/catch_reporter_tap.hpp new file mode 100644 index 0000000000..ccc4051be0 --- /dev/null +++ b/src/third_party/cppcodec/test/catch/single_include/catch2/catch_reporter_tap.hpp @@ -0,0 +1,253 @@ +/* + * Created by Colton Wolkins on 2015-08-15. + * Copyright 2015 Martin Moene. 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_CATCH_REPORTER_TAP_HPP_INCLUDED +#define TWOBLUECUBES_CATCH_REPORTER_TAP_HPP_INCLUDED + + +// Don't #include any Catch headers here - we can assume they are already +// included before this header. +// This is not good practice in general but is necessary in this case so this +// file can be distributed as a single header that works with the main +// Catch single header. + +#include + +namespace Catch { + + struct TAPReporter : StreamingReporterBase { + + using StreamingReporterBase::StreamingReporterBase; + + ~TAPReporter() override; + + static std::string getDescription() { + return "Reports test results in TAP format, suitable for test harnesses"; + } + + ReporterPreferences getPreferences() const override { + return m_reporterPrefs; + } + + void noMatchingTestCases( std::string const& spec ) override { + stream << "# No test cases matched '" << spec << "'" << std::endl; + } + + void assertionStarting( AssertionInfo const& ) override {} + + bool assertionEnded( AssertionStats const& _assertionStats ) override { + ++counter; + + AssertionPrinter printer( stream, _assertionStats, counter ); + printer.print(); + stream << " # " << currentTestCaseInfo->name ; + + stream << std::endl; + return true; + } + + void testRunEnded( TestRunStats const& _testRunStats ) override { + printTotals( _testRunStats.totals ); + stream << "\n" << std::endl; + StreamingReporterBase::testRunEnded( _testRunStats ); + } + + private: + std::size_t counter = 0; + class AssertionPrinter { + public: + AssertionPrinter& operator= ( AssertionPrinter const& ) = delete; + AssertionPrinter( AssertionPrinter const& ) = delete; + AssertionPrinter( std::ostream& _stream, AssertionStats const& _stats, std::size_t _counter ) + : stream( _stream ) + , result( _stats.assertionResult ) + , messages( _stats.infoMessages ) + , itMessage( _stats.infoMessages.begin() ) + , printInfoMessages( true ) + , counter(_counter) + {} + + void print() { + itMessage = messages.begin(); + + switch( result.getResultType() ) { + case ResultWas::Ok: + printResultType( passedString() ); + printOriginalExpression(); + printReconstructedExpression(); + if ( ! result.hasExpression() ) + printRemainingMessages( Colour::None ); + else + printRemainingMessages(); + break; + case ResultWas::ExpressionFailed: + if (result.isOk()) { + printResultType(passedString()); + } else { + printResultType(failedString()); + } + printOriginalExpression(); + printReconstructedExpression(); + if (result.isOk()) { + printIssue(" # TODO"); + } + printRemainingMessages(); + break; + case ResultWas::ThrewException: + printResultType( failedString() ); + printIssue( "unexpected exception with message:" ); + printMessage(); + printExpressionWas(); + printRemainingMessages(); + break; + case ResultWas::FatalErrorCondition: + printResultType( failedString() ); + printIssue( "fatal error condition with message:" ); + printMessage(); + printExpressionWas(); + printRemainingMessages(); + break; + case ResultWas::DidntThrowException: + printResultType( failedString() ); + printIssue( "expected exception, got none" ); + printExpressionWas(); + printRemainingMessages(); + break; + case ResultWas::Info: + printResultType( "info" ); + printMessage(); + printRemainingMessages(); + break; + case ResultWas::Warning: + printResultType( "warning" ); + printMessage(); + printRemainingMessages(); + break; + case ResultWas::ExplicitFailure: + printResultType( failedString() ); + printIssue( "explicitly" ); + printRemainingMessages( Colour::None ); + break; + // These cases are here to prevent compiler warnings + case ResultWas::Unknown: + case ResultWas::FailureBit: + case ResultWas::Exception: + printResultType( "** internal error **" ); + break; + } + } + + private: + static Colour::Code dimColour() { return Colour::FileName; } + + static const char* failedString() { return "not ok"; } + static const char* passedString() { return "ok"; } + + void printSourceInfo() const { + Colour colourGuard( dimColour() ); + stream << result.getSourceInfo() << ":"; + } + + void printResultType( std::string const& passOrFail ) const { + if( !passOrFail.empty() ) { + stream << passOrFail << ' ' << counter << " -"; + } + } + + void printIssue( std::string const& issue ) const { + stream << " " << issue; + } + + void printExpressionWas() { + if( result.hasExpression() ) { + stream << ";"; + { + Colour colour( dimColour() ); + stream << " expression was:"; + } + printOriginalExpression(); + } + } + + void printOriginalExpression() const { + if( result.hasExpression() ) { + stream << " " << result.getExpression(); + } + } + + void printReconstructedExpression() const { + if( result.hasExpandedExpression() ) { + { + Colour colour( dimColour() ); + stream << " for: "; + } + std::string expr = result.getExpandedExpression(); + std::replace( expr.begin(), expr.end(), '\n', ' '); + stream << expr; + } + } + + void printMessage() { + if ( itMessage != messages.end() ) { + stream << " '" << itMessage->message << "'"; + ++itMessage; + } + } + + void printRemainingMessages( Colour::Code colour = dimColour() ) { + if (itMessage == messages.end()) { + return; + } + + // using messages.end() directly (or auto) yields compilation error: + std::vector::const_iterator itEnd = messages.end(); + const std::size_t N = static_cast( std::distance( itMessage, itEnd ) ); + + { + Colour colourGuard( colour ); + stream << " with " << pluralise( N, "message" ) << ":"; + } + + for(; itMessage != itEnd; ) { + // If this assertion is a warning ignore any INFO messages + if( printInfoMessages || itMessage->type != ResultWas::Info ) { + stream << " '" << itMessage->message << "'"; + if ( ++itMessage != itEnd ) { + Colour colourGuard( dimColour() ); + stream << " and"; + } + } + } + } + + private: + std::ostream& stream; + AssertionResult const& result; + std::vector messages; + std::vector::const_iterator itMessage; + bool printInfoMessages; + std::size_t counter; + }; + + void printTotals( const Totals& totals ) const { + if( totals.testCases.total() == 0 ) { + stream << "1..0 # Skipped: No tests ran."; + } else { + stream << "1.." << counter; + } + } + }; + +#ifdef CATCH_IMPL + TAPReporter::~TAPReporter() {} +#endif + + CATCH_REGISTER_REPORTER( "tap", TAPReporter ) + +} // end namespace Catch + +#endif // TWOBLUECUBES_CATCH_REPORTER_TAP_HPP_INCLUDED diff --git a/src/third_party/cppcodec/test/catch/single_include/catch2/catch_reporter_teamcity.hpp b/src/third_party/cppcodec/test/catch/single_include/catch2/catch_reporter_teamcity.hpp new file mode 100644 index 0000000000..dbd0db532c --- /dev/null +++ b/src/third_party/cppcodec/test/catch/single_include/catch2/catch_reporter_teamcity.hpp @@ -0,0 +1,220 @@ +/* + * Created by Phil Nash on 19th December 2014 + * Copyright 2014 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_CATCH_REPORTER_TEAMCITY_HPP_INCLUDED +#define TWOBLUECUBES_CATCH_REPORTER_TEAMCITY_HPP_INCLUDED + +// Don't #include any Catch headers here - we can assume they are already +// included before this header. +// This is not good practice in general but is necessary in this case so this +// file can be distributed as a single header that works with the main +// Catch single header. + +#include + +#ifdef __clang__ +# pragma clang diagnostic push +# pragma clang diagnostic ignored "-Wpadded" +#endif + +namespace Catch { + + struct TeamCityReporter : StreamingReporterBase { + TeamCityReporter( ReporterConfig const& _config ) + : StreamingReporterBase( _config ) + { + m_reporterPrefs.shouldRedirectStdOut = true; + } + + static std::string escape( std::string const& str ) { + std::string escaped = str; + replaceInPlace( escaped, "|", "||" ); + replaceInPlace( escaped, "'", "|'" ); + replaceInPlace( escaped, "\n", "|n" ); + replaceInPlace( escaped, "\r", "|r" ); + replaceInPlace( escaped, "[", "|[" ); + replaceInPlace( escaped, "]", "|]" ); + return escaped; + } + ~TeamCityReporter() override; + + static std::string getDescription() { + return "Reports test results as TeamCity service messages"; + } + + void skipTest( TestCaseInfo const& /* testInfo */ ) override { + } + + void noMatchingTestCases( std::string const& /* spec */ ) override {} + + void testGroupStarting( GroupInfo const& groupInfo ) override { + StreamingReporterBase::testGroupStarting( groupInfo ); + stream << "##teamcity[testSuiteStarted name='" + << escape( groupInfo.name ) << "']\n"; + } + void testGroupEnded( TestGroupStats const& testGroupStats ) override { + StreamingReporterBase::testGroupEnded( testGroupStats ); + stream << "##teamcity[testSuiteFinished name='" + << escape( testGroupStats.groupInfo.name ) << "']\n"; + } + + + void assertionStarting( AssertionInfo const& ) override {} + + bool assertionEnded( AssertionStats const& assertionStats ) override { + AssertionResult const& result = assertionStats.assertionResult; + if( !result.isOk() ) { + + ReusableStringStream msg; + if( !m_headerPrintedForThisSection ) + printSectionHeader( msg.get() ); + m_headerPrintedForThisSection = true; + + msg << result.getSourceInfo() << "\n"; + + switch( result.getResultType() ) { + case ResultWas::ExpressionFailed: + msg << "expression failed"; + break; + case ResultWas::ThrewException: + msg << "unexpected exception"; + break; + case ResultWas::FatalErrorCondition: + msg << "fatal error condition"; + break; + case ResultWas::DidntThrowException: + msg << "no exception was thrown where one was expected"; + break; + case ResultWas::ExplicitFailure: + msg << "explicit failure"; + break; + + // We shouldn't get here because of the isOk() test + case ResultWas::Ok: + case ResultWas::Info: + case ResultWas::Warning: + throw std::domain_error( "Internal error in TeamCity reporter" ); + // These cases are here to prevent compiler warnings + case ResultWas::Unknown: + case ResultWas::FailureBit: + case ResultWas::Exception: + throw std::domain_error( "Not implemented" ); + } + if( assertionStats.infoMessages.size() == 1 ) + msg << " with message:"; + if( assertionStats.infoMessages.size() > 1 ) + msg << " with messages:"; + for( auto const& messageInfo : assertionStats.infoMessages ) + msg << "\n \"" << messageInfo.message << "\""; + + + if( result.hasExpression() ) { + msg << + "\n " << result.getExpressionInMacro() << "\n" + "with expansion:\n" << + " " << result.getExpandedExpression() << "\n"; + } + + if( currentTestCaseInfo->okToFail() ) { + msg << "- failure ignore as test marked as 'ok to fail'\n"; + stream << "##teamcity[testIgnored" + << " name='" << escape( currentTestCaseInfo->name )<< "'" + << " message='" << escape( msg.str() ) << "'" + << "]\n"; + } + else { + stream << "##teamcity[testFailed" + << " name='" << escape( currentTestCaseInfo->name )<< "'" + << " message='" << escape( msg.str() ) << "'" + << "]\n"; + } + } + stream.flush(); + return true; + } + + void sectionStarting( SectionInfo const& sectionInfo ) override { + m_headerPrintedForThisSection = false; + StreamingReporterBase::sectionStarting( sectionInfo ); + } + + void testCaseStarting( TestCaseInfo const& testInfo ) override { + m_testTimer.start(); + StreamingReporterBase::testCaseStarting( testInfo ); + stream << "##teamcity[testStarted name='" + << escape( testInfo.name ) << "']\n"; + stream.flush(); + } + + void testCaseEnded( TestCaseStats const& testCaseStats ) override { + StreamingReporterBase::testCaseEnded( testCaseStats ); + if( !testCaseStats.stdOut.empty() ) + stream << "##teamcity[testStdOut name='" + << escape( testCaseStats.testInfo.name ) + << "' out='" << escape( testCaseStats.stdOut ) << "']\n"; + if( !testCaseStats.stdErr.empty() ) + stream << "##teamcity[testStdErr name='" + << escape( testCaseStats.testInfo.name ) + << "' out='" << escape( testCaseStats.stdErr ) << "']\n"; + stream << "##teamcity[testFinished name='" + << escape( testCaseStats.testInfo.name ) << "' duration='" + << m_testTimer.getElapsedMilliseconds() << "']\n"; + stream.flush(); + } + + private: + void printSectionHeader( std::ostream& os ) { + assert( !m_sectionStack.empty() ); + + if( m_sectionStack.size() > 1 ) { + os << getLineOfChars<'-'>() << "\n"; + + std::vector::const_iterator + it = m_sectionStack.begin()+1, // Skip first section (test case) + itEnd = m_sectionStack.end(); + for( ; it != itEnd; ++it ) + printHeaderString( os, it->name ); + os << getLineOfChars<'-'>() << "\n"; + } + + SourceLineInfo lineInfo = m_sectionStack.front().lineInfo; + + if( !lineInfo.empty() ) + os << lineInfo << "\n"; + os << getLineOfChars<'.'>() << "\n\n"; + } + + // if string has a : in first line will set indent to follow it on + // subsequent lines + static void printHeaderString( std::ostream& os, std::string const& _string, std::size_t indent = 0 ) { + std::size_t i = _string.find( ": " ); + if( i != std::string::npos ) + i+=2; + else + i = 0; + os << Column( _string ) + .indent( indent+i) + .initialIndent( indent ) << "\n"; + } + private: + bool m_headerPrintedForThisSection = false; + Timer m_testTimer; + }; + +#ifdef CATCH_IMPL + TeamCityReporter::~TeamCityReporter() {} +#endif + + CATCH_REGISTER_REPORTER( "teamcity", TeamCityReporter ) + +} // end namespace Catch + +#ifdef __clang__ +# pragma clang diagnostic pop +#endif + +#endif // TWOBLUECUBES_CATCH_REPORTER_TEAMCITY_HPP_INCLUDED diff --git a/src/third_party/cppcodec/test/catch/test_package/CMakeLists.txt b/src/third_party/cppcodec/test/catch/test_package/CMakeLists.txt new file mode 100644 index 0000000000..339facbf17 --- /dev/null +++ b/src/third_party/cppcodec/test/catch/test_package/CMakeLists.txt @@ -0,0 +1,7 @@ +cmake_minimum_required(VERSION 3.0) +project(CatchTest CXX) + +include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) +conan_basic_setup() + +add_executable(${CMAKE_PROJECT_NAME} MainTest.cpp) diff --git a/src/third_party/cppcodec/test/catch/test_package/MainTest.cpp b/src/third_party/cppcodec/test/catch/test_package/MainTest.cpp new file mode 100644 index 0000000000..010feba21d --- /dev/null +++ b/src/third_party/cppcodec/test/catch/test_package/MainTest.cpp @@ -0,0 +1,21 @@ +/* + * Created by Phil on 22/10/2010. + * Copyright 2010 Two Blue Cubes Ltd + * + * 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) + */ +#define CATCH_CONFIG_MAIN +#include + +unsigned int Factorial( unsigned int number ) { + return number > 1 ? Factorial(number-1)*number : 1; +} + +TEST_CASE( "Factorials are computed", "[factorial]" ) { + REQUIRE( Factorial(0) == 1 ); + REQUIRE( Factorial(1) == 1 ); + REQUIRE( Factorial(2) == 2 ); + REQUIRE( Factorial(3) == 6 ); + REQUIRE( Factorial(10) == 3628800 ); +} diff --git a/src/third_party/cppcodec/test/catch/test_package/conanfile.py b/src/third_party/cppcodec/test/catch/test_package/conanfile.py new file mode 100644 index 0000000000..b9fc6f91e3 --- /dev/null +++ b/src/third_party/cppcodec/test/catch/test_package/conanfile.py @@ -0,0 +1,21 @@ +#!/usr/bin/env python +from os import getenv +from os import path +from conans import ConanFile +from conans import CMake + + +class CatchConanTest(ConanFile): + generators = "cmake" + settings = "os", "compiler", "arch", "build_type" + username = getenv("CONAN_USERNAME", "philsquared") + channel = getenv("CONAN_CHANNEL", "testing") + requires = "Catch/2.3.0@%s/%s" % (username, channel) + + def build(self): + cmake = CMake(self) + cmake.configure(build_dir="./") + cmake.build() + + def test(self): + self.run(path.join("bin", "CatchTest")) diff --git a/src/third_party/cppcodec/test/catch/third_party/clara.hpp b/src/third_party/cppcodec/test/catch/third_party/clara.hpp new file mode 100644 index 0000000000..43568cee2a --- /dev/null +++ b/src/third_party/cppcodec/test/catch/third_party/clara.hpp @@ -0,0 +1,1255 @@ +// Copyright 2017 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) +// +// See https://github.com/philsquared/Clara for more details + +// Clara v1.1.4 + +#ifndef CLARA_HPP_INCLUDED +#define CLARA_HPP_INCLUDED + +#ifndef CLARA_CONFIG_CONSOLE_WIDTH +#define CLARA_CONFIG_CONSOLE_WIDTH 80 +#endif + +#ifndef CLARA_TEXTFLOW_CONFIG_CONSOLE_WIDTH +#define CLARA_TEXTFLOW_CONFIG_CONSOLE_WIDTH CLARA_CONFIG_CONSOLE_WIDTH +#endif + +#ifndef CLARA_CONFIG_OPTIONAL_TYPE +#ifdef __has_include +#if __has_include() && __cplusplus >= 201703L +#include +#define CLARA_CONFIG_OPTIONAL_TYPE std::optional +#endif +#endif +#endif + + +// ----------- #included from clara_textflow.hpp ----------- + +// TextFlowCpp +// +// A single-header library for wrapping and laying out basic text, by Phil Nash +// +// This work is licensed under the BSD 2-Clause license. +// See the accompanying LICENSE file, or the one at https://opensource.org/licenses/BSD-2-Clause +// +// This project is hosted at https://github.com/philsquared/textflowcpp + +#ifndef CLARA_TEXTFLOW_HPP_INCLUDED +#define CLARA_TEXTFLOW_HPP_INCLUDED + +#include +#include +#include +#include + +#ifndef CLARA_TEXTFLOW_CONFIG_CONSOLE_WIDTH +#define CLARA_TEXTFLOW_CONFIG_CONSOLE_WIDTH 80 +#endif + + +namespace clara { namespace TextFlow { + + inline auto isWhitespace( char c ) -> bool { + static std::string chars = " \t\n\r"; + return chars.find( c ) != std::string::npos; + } + inline auto isBreakableBefore( char c ) -> bool { + static std::string chars = "[({<|"; + return chars.find( c ) != std::string::npos; + } + inline auto isBreakableAfter( char c ) -> bool { + static std::string chars = "])}>.,:;*+-=&/\\"; + return chars.find( c ) != std::string::npos; + } + + class Columns; + + class Column { + std::vector m_strings; + size_t m_width = CLARA_TEXTFLOW_CONFIG_CONSOLE_WIDTH; + size_t m_indent = 0; + size_t m_initialIndent = std::string::npos; + + public: + class iterator { + friend Column; + + Column const& m_column; + size_t m_stringIndex = 0; + size_t m_pos = 0; + + size_t m_len = 0; + size_t m_end = 0; + bool m_suffix = false; + + iterator( Column const& column, size_t stringIndex ) + : m_column( column ), + m_stringIndex( stringIndex ) + {} + + auto line() const -> std::string const& { return m_column.m_strings[m_stringIndex]; } + + auto isBoundary( size_t at ) const -> bool { + assert( at > 0 ); + assert( at <= line().size() ); + + return at == line().size() || + ( isWhitespace( line()[at] ) && !isWhitespace( line()[at-1] ) ) || + isBreakableBefore( line()[at] ) || + isBreakableAfter( line()[at-1] ); + } + + void calcLength() { + assert( m_stringIndex < m_column.m_strings.size() ); + + m_suffix = false; + auto width = m_column.m_width-indent(); + m_end = m_pos; + while( m_end < line().size() && line()[m_end] != '\n' ) + ++m_end; + + if( m_end < m_pos + width ) { + m_len = m_end - m_pos; + } + else { + size_t len = width; + while (len > 0 && !isBoundary(m_pos + len)) + --len; + while (len > 0 && isWhitespace( line()[m_pos + len - 1] )) + --len; + + if (len > 0) { + m_len = len; + } else { + m_suffix = true; + m_len = width - 1; + } + } + } + + auto indent() const -> size_t { + auto initial = m_pos == 0 && m_stringIndex == 0 ? m_column.m_initialIndent : std::string::npos; + return initial == std::string::npos ? m_column.m_indent : initial; + } + + auto addIndentAndSuffix(std::string const &plain) const -> std::string { + return std::string( indent(), ' ' ) + (m_suffix ? plain + "-" : plain); + } + + public: + explicit iterator( Column const& column ) : m_column( column ) { + assert( m_column.m_width > m_column.m_indent ); + assert( m_column.m_initialIndent == std::string::npos || m_column.m_width > m_column.m_initialIndent ); + calcLength(); + if( m_len == 0 ) + m_stringIndex++; // Empty string + } + + auto operator *() const -> std::string { + assert( m_stringIndex < m_column.m_strings.size() ); + assert( m_pos <= m_end ); + if( m_pos + m_column.m_width < m_end ) + return addIndentAndSuffix(line().substr(m_pos, m_len)); + else + return addIndentAndSuffix(line().substr(m_pos, m_end - m_pos)); + } + + auto operator ++() -> iterator& { + m_pos += m_len; + if( m_pos < line().size() && line()[m_pos] == '\n' ) + m_pos += 1; + else + while( m_pos < line().size() && isWhitespace( line()[m_pos] ) ) + ++m_pos; + + if( m_pos == line().size() ) { + m_pos = 0; + ++m_stringIndex; + } + if( m_stringIndex < m_column.m_strings.size() ) + calcLength(); + return *this; + } + auto operator ++(int) -> iterator { + iterator prev( *this ); + operator++(); + return prev; + } + + auto operator ==( iterator const& other ) const -> bool { + return + m_pos == other.m_pos && + m_stringIndex == other.m_stringIndex && + &m_column == &other.m_column; + } + auto operator !=( iterator const& other ) const -> bool { + return !operator==( other ); + } + }; + using const_iterator = iterator; + + explicit Column( std::string const& text ) { m_strings.push_back( text ); } + + auto width( size_t newWidth ) -> Column& { + assert( newWidth > 0 ); + m_width = newWidth; + return *this; + } + auto indent( size_t newIndent ) -> Column& { + m_indent = newIndent; + return *this; + } + auto initialIndent( size_t newIndent ) -> Column& { + m_initialIndent = newIndent; + return *this; + } + + auto width() const -> size_t { return m_width; } + auto begin() const -> iterator { return iterator( *this ); } + auto end() const -> iterator { return { *this, m_strings.size() }; } + + inline friend std::ostream& operator << ( std::ostream& os, Column const& col ) { + bool first = true; + for( auto line : col ) { + if( first ) + first = false; + else + os << "\n"; + os << line; + } + return os; + } + + auto operator + ( Column const& other ) -> Columns; + + auto toString() const -> std::string { + std::ostringstream oss; + oss << *this; + return oss.str(); + } + }; + + class Spacer : public Column { + + public: + explicit Spacer( size_t spaceWidth ) : Column( "" ) { + width( spaceWidth ); + } + }; + + class Columns { + std::vector m_columns; + + public: + + class iterator { + friend Columns; + struct EndTag {}; + + std::vector const& m_columns; + std::vector m_iterators; + size_t m_activeIterators; + + iterator( Columns const& columns, EndTag ) + : m_columns( columns.m_columns ), + m_activeIterators( 0 ) + { + m_iterators.reserve( m_columns.size() ); + + for( auto const& col : m_columns ) + m_iterators.push_back( col.end() ); + } + + public: + explicit iterator( Columns const& columns ) + : m_columns( columns.m_columns ), + m_activeIterators( m_columns.size() ) + { + m_iterators.reserve( m_columns.size() ); + + for( auto const& col : m_columns ) + m_iterators.push_back( col.begin() ); + } + + auto operator ==( iterator const& other ) const -> bool { + return m_iterators == other.m_iterators; + } + auto operator !=( iterator const& other ) const -> bool { + return m_iterators != other.m_iterators; + } + auto operator *() const -> std::string { + std::string row, padding; + + for( size_t i = 0; i < m_columns.size(); ++i ) { + auto width = m_columns[i].width(); + if( m_iterators[i] != m_columns[i].end() ) { + std::string col = *m_iterators[i]; + row += padding + col; + if( col.size() < width ) + padding = std::string( width - col.size(), ' ' ); + else + padding = ""; + } + else { + padding += std::string( width, ' ' ); + } + } + return row; + } + auto operator ++() -> iterator& { + for( size_t i = 0; i < m_columns.size(); ++i ) { + if (m_iterators[i] != m_columns[i].end()) + ++m_iterators[i]; + } + return *this; + } + auto operator ++(int) -> iterator { + iterator prev( *this ); + operator++(); + return prev; + } + }; + using const_iterator = iterator; + + auto begin() const -> iterator { return iterator( *this ); } + auto end() const -> iterator { return { *this, iterator::EndTag() }; } + + auto operator += ( Column const& col ) -> Columns& { + m_columns.push_back( col ); + return *this; + } + auto operator + ( Column const& col ) -> Columns { + Columns combined = *this; + combined += col; + return combined; + } + + inline friend std::ostream& operator << ( std::ostream& os, Columns const& cols ) { + + bool first = true; + for( auto line : cols ) { + if( first ) + first = false; + else + os << "\n"; + os << line; + } + return os; + } + + auto toString() const -> std::string { + std::ostringstream oss; + oss << *this; + return oss.str(); + } + }; + + inline auto Column::operator + ( Column const& other ) -> Columns { + Columns cols; + cols += *this; + cols += other; + return cols; + } +}} // namespace clara::TextFlow + +#endif // CLARA_TEXTFLOW_HPP_INCLUDED + +// ----------- end of #include from clara_textflow.hpp ----------- +// ........... back in clara.hpp + + +#include +#include +#include + +#if !defined(CLARA_PLATFORM_WINDOWS) && ( defined(WIN32) || defined(__WIN32__) || defined(_WIN32) || defined(_MSC_VER) ) +#define CLARA_PLATFORM_WINDOWS +#endif + +namespace clara { +namespace detail { + + // Traits for extracting arg and return type of lambdas (for single argument lambdas) + template + struct UnaryLambdaTraits : UnaryLambdaTraits {}; + + template + struct UnaryLambdaTraits { + static const bool isValid = false; + }; + + template + struct UnaryLambdaTraits { + static const bool isValid = true; + using ArgType = typename std::remove_const::type>::type; + using ReturnType = ReturnT; + }; + + class TokenStream; + + // Transport for raw args (copied from main args, or supplied via init list for testing) + class Args { + friend TokenStream; + std::string m_exeName; + std::vector m_args; + + public: + Args( int argc, char const* const* argv ) + : m_exeName(argv[0]), + m_args(argv + 1, argv + argc) {} + + Args( std::initializer_list args ) + : m_exeName( *args.begin() ), + m_args( args.begin()+1, args.end() ) + {} + + auto exeName() const -> std::string { + return m_exeName; + } + }; + + // Wraps a token coming from a token stream. These may not directly correspond to strings as a single string + // may encode an option + its argument if the : or = form is used + enum class TokenType { + Option, Argument + }; + struct Token { + TokenType type; + std::string token; + }; + + inline auto isOptPrefix( char c ) -> bool { + return c == '-' +#ifdef CLARA_PLATFORM_WINDOWS + || c == '/' +#endif + ; + } + + // Abstracts iterators into args as a stream of tokens, with option arguments uniformly handled + class TokenStream { + using Iterator = std::vector::const_iterator; + Iterator it; + Iterator itEnd; + std::vector m_tokenBuffer; + + void loadBuffer() { + m_tokenBuffer.resize( 0 ); + + // Skip any empty strings + while( it != itEnd && it->empty() ) + ++it; + + if( it != itEnd ) { + auto const &next = *it; + if( isOptPrefix( next[0] ) ) { + auto delimiterPos = next.find_first_of( " :=" ); + if( delimiterPos != std::string::npos ) { + m_tokenBuffer.push_back( { TokenType::Option, next.substr( 0, delimiterPos ) } ); + m_tokenBuffer.push_back( { TokenType::Argument, next.substr( delimiterPos + 1 ) } ); + } else { + if( next[1] != '-' && next.size() > 2 ) { + std::string opt = "- "; + for( size_t i = 1; i < next.size(); ++i ) { + opt[1] = next[i]; + m_tokenBuffer.push_back( { TokenType::Option, opt } ); + } + } else { + m_tokenBuffer.push_back( { TokenType::Option, next } ); + } + } + } else { + m_tokenBuffer.push_back( { TokenType::Argument, next } ); + } + } + } + + public: + explicit TokenStream( Args const &args ) : TokenStream( args.m_args.begin(), args.m_args.end() ) {} + + TokenStream( Iterator it, Iterator itEnd ) : it( it ), itEnd( itEnd ) { + loadBuffer(); + } + + explicit operator bool() const { + return !m_tokenBuffer.empty() || it != itEnd; + } + + auto count() const -> size_t { return m_tokenBuffer.size() + (itEnd - it); } + + auto operator*() const -> Token { + assert( !m_tokenBuffer.empty() ); + return m_tokenBuffer.front(); + } + + auto operator->() const -> Token const * { + assert( !m_tokenBuffer.empty() ); + return &m_tokenBuffer.front(); + } + + auto operator++() -> TokenStream & { + if( m_tokenBuffer.size() >= 2 ) { + m_tokenBuffer.erase( m_tokenBuffer.begin() ); + } else { + if( it != itEnd ) + ++it; + loadBuffer(); + } + return *this; + } + }; + + + class ResultBase { + public: + enum Type { + Ok, LogicError, RuntimeError + }; + + protected: + ResultBase( Type type ) : m_type( type ) {} + virtual ~ResultBase() = default; + + virtual void enforceOk() const = 0; + + Type m_type; + }; + + template + class ResultValueBase : public ResultBase { + public: + auto value() const -> T const & { + enforceOk(); + return m_value; + } + + protected: + ResultValueBase( Type type ) : ResultBase( type ) {} + + ResultValueBase( ResultValueBase const &other ) : ResultBase( other ) { + if( m_type == ResultBase::Ok ) + new( &m_value ) T( other.m_value ); + } + + ResultValueBase( Type, T const &value ) : ResultBase( Ok ) { + new( &m_value ) T( value ); + } + + auto operator=( ResultValueBase const &other ) -> ResultValueBase & { + if( m_type == ResultBase::Ok ) + m_value.~T(); + ResultBase::operator=(other); + if( m_type == ResultBase::Ok ) + new( &m_value ) T( other.m_value ); + return *this; + } + + ~ResultValueBase() override { + if( m_type == Ok ) + m_value.~T(); + } + + union { + T m_value; + }; + }; + + template<> + class ResultValueBase : public ResultBase { + protected: + using ResultBase::ResultBase; + }; + + template + class BasicResult : public ResultValueBase { + public: + template + explicit BasicResult( BasicResult const &other ) + : ResultValueBase( other.type() ), + m_errorMessage( other.errorMessage() ) + { + assert( type() != ResultBase::Ok ); + } + + template + static auto ok( U const &value ) -> BasicResult { return { ResultBase::Ok, value }; } + static auto ok() -> BasicResult { return { ResultBase::Ok }; } + static auto logicError( std::string const &message ) -> BasicResult { return { ResultBase::LogicError, message }; } + static auto runtimeError( std::string const &message ) -> BasicResult { return { ResultBase::RuntimeError, message }; } + + explicit operator bool() const { return m_type == ResultBase::Ok; } + auto type() const -> ResultBase::Type { return m_type; } + auto errorMessage() const -> std::string { return m_errorMessage; } + + protected: + void enforceOk() const override { + + // Errors shouldn't reach this point, but if they do + // the actual error message will be in m_errorMessage + assert( m_type != ResultBase::LogicError ); + assert( m_type != ResultBase::RuntimeError ); + if( m_type != ResultBase::Ok ) + std::abort(); + } + + std::string m_errorMessage; // Only populated if resultType is an error + + BasicResult( ResultBase::Type type, std::string const &message ) + : ResultValueBase(type), + m_errorMessage(message) + { + assert( m_type != ResultBase::Ok ); + } + + using ResultValueBase::ResultValueBase; + using ResultBase::m_type; + }; + + enum class ParseResultType { + Matched, NoMatch, ShortCircuitAll, ShortCircuitSame + }; + + class ParseState { + public: + + ParseState( ParseResultType type, TokenStream const &remainingTokens ) + : m_type(type), + m_remainingTokens( remainingTokens ) + {} + + auto type() const -> ParseResultType { return m_type; } + auto remainingTokens() const -> TokenStream { return m_remainingTokens; } + + private: + ParseResultType m_type; + TokenStream m_remainingTokens; + }; + + using Result = BasicResult; + using ParserResult = BasicResult; + using InternalParseResult = BasicResult; + + struct HelpColumns { + std::string left; + std::string right; + }; + + template + inline auto convertInto( std::string const &source, T& target ) -> ParserResult { + std::stringstream ss; + ss << source; + ss >> target; + if( ss.fail() ) + return ParserResult::runtimeError( "Unable to convert '" + source + "' to destination type" ); + else + return ParserResult::ok( ParseResultType::Matched ); + } + inline auto convertInto( std::string const &source, std::string& target ) -> ParserResult { + target = source; + return ParserResult::ok( ParseResultType::Matched ); + } + inline auto convertInto( std::string const &source, bool &target ) -> ParserResult { + std::string srcLC = source; + std::transform( srcLC.begin(), srcLC.end(), srcLC.begin(), []( char c ) { return static_cast( ::tolower(c) ); } ); + if (srcLC == "y" || srcLC == "1" || srcLC == "true" || srcLC == "yes" || srcLC == "on") + target = true; + else if (srcLC == "n" || srcLC == "0" || srcLC == "false" || srcLC == "no" || srcLC == "off") + target = false; + else + return ParserResult::runtimeError( "Expected a boolean value but did not recognise: '" + source + "'" ); + return ParserResult::ok( ParseResultType::Matched ); + } +#ifdef CLARA_CONFIG_OPTIONAL_TYPE + template + inline auto convertInto( std::string const &source, CLARA_CONFIG_OPTIONAL_TYPE& target ) -> ParserResult { + T temp; + auto result = convertInto( source, temp ); + if( result ) + target = std::move(temp); + return result; + } +#endif // CLARA_CONFIG_OPTIONAL_TYPE + + struct NonCopyable { + NonCopyable() = default; + NonCopyable( NonCopyable const & ) = delete; + NonCopyable( NonCopyable && ) = delete; + NonCopyable &operator=( NonCopyable const & ) = delete; + NonCopyable &operator=( NonCopyable && ) = delete; + }; + + struct BoundRef : NonCopyable { + virtual ~BoundRef() = default; + virtual auto isContainer() const -> bool { return false; } + virtual auto isFlag() const -> bool { return false; } + }; + struct BoundValueRefBase : BoundRef { + virtual auto setValue( std::string const &arg ) -> ParserResult = 0; + }; + struct BoundFlagRefBase : BoundRef { + virtual auto setFlag( bool flag ) -> ParserResult = 0; + virtual auto isFlag() const -> bool { return true; } + }; + + template + struct BoundValueRef : BoundValueRefBase { + T &m_ref; + + explicit BoundValueRef( T &ref ) : m_ref( ref ) {} + + auto setValue( std::string const &arg ) -> ParserResult override { + return convertInto( arg, m_ref ); + } + }; + + template + struct BoundValueRef> : BoundValueRefBase { + std::vector &m_ref; + + explicit BoundValueRef( std::vector &ref ) : m_ref( ref ) {} + + auto isContainer() const -> bool override { return true; } + + auto setValue( std::string const &arg ) -> ParserResult override { + T temp; + auto result = convertInto( arg, temp ); + if( result ) + m_ref.push_back( temp ); + return result; + } + }; + + struct BoundFlagRef : BoundFlagRefBase { + bool &m_ref; + + explicit BoundFlagRef( bool &ref ) : m_ref( ref ) {} + + auto setFlag( bool flag ) -> ParserResult override { + m_ref = flag; + return ParserResult::ok( ParseResultType::Matched ); + } + }; + + template + struct LambdaInvoker { + static_assert( std::is_same::value, "Lambda must return void or clara::ParserResult" ); + + template + static auto invoke( L const &lambda, ArgType const &arg ) -> ParserResult { + return lambda( arg ); + } + }; + + template<> + struct LambdaInvoker { + template + static auto invoke( L const &lambda, ArgType const &arg ) -> ParserResult { + lambda( arg ); + return ParserResult::ok( ParseResultType::Matched ); + } + }; + + template + inline auto invokeLambda( L const &lambda, std::string const &arg ) -> ParserResult { + ArgType temp{}; + auto result = convertInto( arg, temp ); + return !result + ? result + : LambdaInvoker::ReturnType>::invoke( lambda, temp ); + } + + + template + struct BoundLambda : BoundValueRefBase { + L m_lambda; + + static_assert( UnaryLambdaTraits::isValid, "Supplied lambda must take exactly one argument" ); + explicit BoundLambda( L const &lambda ) : m_lambda( lambda ) {} + + auto setValue( std::string const &arg ) -> ParserResult override { + return invokeLambda::ArgType>( m_lambda, arg ); + } + }; + + template + struct BoundFlagLambda : BoundFlagRefBase { + L m_lambda; + + static_assert( UnaryLambdaTraits::isValid, "Supplied lambda must take exactly one argument" ); + static_assert( std::is_same::ArgType, bool>::value, "flags must be boolean" ); + + explicit BoundFlagLambda( L const &lambda ) : m_lambda( lambda ) {} + + auto setFlag( bool flag ) -> ParserResult override { + return LambdaInvoker::ReturnType>::invoke( m_lambda, flag ); + } + }; + + enum class Optionality { Optional, Required }; + + struct Parser; + + class ParserBase { + public: + virtual ~ParserBase() = default; + virtual auto validate() const -> Result { return Result::ok(); } + virtual auto parse( std::string const& exeName, TokenStream const &tokens) const -> InternalParseResult = 0; + virtual auto cardinality() const -> size_t { return 1; } + + auto parse( Args const &args ) const -> InternalParseResult { + return parse( args.exeName(), TokenStream( args ) ); + } + }; + + template + class ComposableParserImpl : public ParserBase { + public: + template + auto operator|( T const &other ) const -> Parser; + + template + auto operator+( T const &other ) const -> Parser; + }; + + // Common code and state for Args and Opts + template + class ParserRefImpl : public ComposableParserImpl { + protected: + Optionality m_optionality = Optionality::Optional; + std::shared_ptr m_ref; + std::string m_hint; + std::string m_description; + + explicit ParserRefImpl( std::shared_ptr const &ref ) : m_ref( ref ) {} + + public: + template + ParserRefImpl( T &ref, std::string const &hint ) + : m_ref( std::make_shared>( ref ) ), + m_hint( hint ) + {} + + template + ParserRefImpl( LambdaT const &ref, std::string const &hint ) + : m_ref( std::make_shared>( ref ) ), + m_hint(hint) + {} + + auto operator()( std::string const &description ) -> DerivedT & { + m_description = description; + return static_cast( *this ); + } + + auto optional() -> DerivedT & { + m_optionality = Optionality::Optional; + return static_cast( *this ); + }; + + auto required() -> DerivedT & { + m_optionality = Optionality::Required; + return static_cast( *this ); + }; + + auto isOptional() const -> bool { + return m_optionality == Optionality::Optional; + } + + auto cardinality() const -> size_t override { + if( m_ref->isContainer() ) + return 0; + else + return 1; + } + + auto hint() const -> std::string { return m_hint; } + }; + + class ExeName : public ComposableParserImpl { + std::shared_ptr m_name; + std::shared_ptr m_ref; + + template + static auto makeRef(LambdaT const &lambda) -> std::shared_ptr { + return std::make_shared>( lambda) ; + } + + public: + ExeName() : m_name( std::make_shared( "" ) ) {} + + explicit ExeName( std::string &ref ) : ExeName() { + m_ref = std::make_shared>( ref ); + } + + template + explicit ExeName( LambdaT const& lambda ) : ExeName() { + m_ref = std::make_shared>( lambda ); + } + + // The exe name is not parsed out of the normal tokens, but is handled specially + auto parse( std::string const&, TokenStream const &tokens ) const -> InternalParseResult override { + return InternalParseResult::ok( ParseState( ParseResultType::NoMatch, tokens ) ); + } + + auto name() const -> std::string { return *m_name; } + auto set( std::string const& newName ) -> ParserResult { + + auto lastSlash = newName.find_last_of( "\\/" ); + auto filename = ( lastSlash == std::string::npos ) + ? newName + : newName.substr( lastSlash+1 ); + + *m_name = filename; + if( m_ref ) + return m_ref->setValue( filename ); + else + return ParserResult::ok( ParseResultType::Matched ); + } + }; + + class Arg : public ParserRefImpl { + public: + using ParserRefImpl::ParserRefImpl; + + auto parse( std::string const &, TokenStream const &tokens ) const -> InternalParseResult override { + auto validationResult = validate(); + if( !validationResult ) + return InternalParseResult( validationResult ); + + auto remainingTokens = tokens; + auto const &token = *remainingTokens; + if( token.type != TokenType::Argument ) + return InternalParseResult::ok( ParseState( ParseResultType::NoMatch, remainingTokens ) ); + + assert( !m_ref->isFlag() ); + auto valueRef = static_cast( m_ref.get() ); + + auto result = valueRef->setValue( remainingTokens->token ); + if( !result ) + return InternalParseResult( result ); + else + return InternalParseResult::ok( ParseState( ParseResultType::Matched, ++remainingTokens ) ); + } + }; + + inline auto normaliseOpt( std::string const &optName ) -> std::string { +#ifdef CLARA_PLATFORM_WINDOWS + if( optName[0] == '/' ) + return "-" + optName.substr( 1 ); + else +#endif + return optName; + } + + class Opt : public ParserRefImpl { + protected: + std::vector m_optNames; + + public: + template + explicit Opt( LambdaT const &ref ) : ParserRefImpl( std::make_shared>( ref ) ) {} + + explicit Opt( bool &ref ) : ParserRefImpl( std::make_shared( ref ) ) {} + + template + Opt( LambdaT const &ref, std::string const &hint ) : ParserRefImpl( ref, hint ) {} + + template + Opt( T &ref, std::string const &hint ) : ParserRefImpl( ref, hint ) {} + + auto operator[]( std::string const &optName ) -> Opt & { + m_optNames.push_back( optName ); + return *this; + } + + auto getHelpColumns() const -> std::vector { + std::ostringstream oss; + bool first = true; + for( auto const &opt : m_optNames ) { + if (first) + first = false; + else + oss << ", "; + oss << opt; + } + if( !m_hint.empty() ) + oss << " <" << m_hint << ">"; + return { { oss.str(), m_description } }; + } + + auto isMatch( std::string const &optToken ) const -> bool { + auto normalisedToken = normaliseOpt( optToken ); + for( auto const &name : m_optNames ) { + if( normaliseOpt( name ) == normalisedToken ) + return true; + } + return false; + } + + using ParserBase::parse; + + auto parse( std::string const&, TokenStream const &tokens ) const -> InternalParseResult override { + auto validationResult = validate(); + if( !validationResult ) + return InternalParseResult( validationResult ); + + auto remainingTokens = tokens; + if( remainingTokens && remainingTokens->type == TokenType::Option ) { + auto const &token = *remainingTokens; + if( isMatch(token.token ) ) { + if( m_ref->isFlag() ) { + auto flagRef = static_cast( m_ref.get() ); + auto result = flagRef->setFlag( true ); + if( !result ) + return InternalParseResult( result ); + if( result.value() == ParseResultType::ShortCircuitAll ) + return InternalParseResult::ok( ParseState( result.value(), remainingTokens ) ); + } else { + auto valueRef = static_cast( m_ref.get() ); + ++remainingTokens; + if( !remainingTokens ) + return InternalParseResult::runtimeError( "Expected argument following " + token.token ); + auto const &argToken = *remainingTokens; + if( argToken.type != TokenType::Argument ) + return InternalParseResult::runtimeError( "Expected argument following " + token.token ); + auto result = valueRef->setValue( argToken.token ); + if( !result ) + return InternalParseResult( result ); + if( result.value() == ParseResultType::ShortCircuitAll ) + return InternalParseResult::ok( ParseState( result.value(), remainingTokens ) ); + } + return InternalParseResult::ok( ParseState( ParseResultType::Matched, ++remainingTokens ) ); + } + } + return InternalParseResult::ok( ParseState( ParseResultType::NoMatch, remainingTokens ) ); + } + + auto validate() const -> Result override { + if( m_optNames.empty() ) + return Result::logicError( "No options supplied to Opt" ); + for( auto const &name : m_optNames ) { + if( name.empty() ) + return Result::logicError( "Option name cannot be empty" ); +#ifdef CLARA_PLATFORM_WINDOWS + if( name[0] != '-' && name[0] != '/' ) + return Result::logicError( "Option name must begin with '-' or '/'" ); +#else + if( name[0] != '-' ) + return Result::logicError( "Option name must begin with '-'" ); +#endif + } + return ParserRefImpl::validate(); + } + }; + + struct Help : Opt { + Help( bool &showHelpFlag ) + : Opt([&]( bool flag ) { + showHelpFlag = flag; + return ParserResult::ok( ParseResultType::ShortCircuitAll ); + }) + { + static_cast( *this ) + ("display usage information") + ["-?"]["-h"]["--help"] + .optional(); + } + }; + + + struct Parser : ParserBase { + + mutable ExeName m_exeName; + std::vector m_options; + std::vector m_args; + + auto operator|=( ExeName const &exeName ) -> Parser & { + m_exeName = exeName; + return *this; + } + + auto operator|=( Arg const &arg ) -> Parser & { + m_args.push_back(arg); + return *this; + } + + auto operator|=( Opt const &opt ) -> Parser & { + m_options.push_back(opt); + return *this; + } + + auto operator|=( Parser const &other ) -> Parser & { + m_options.insert(m_options.end(), other.m_options.begin(), other.m_options.end()); + m_args.insert(m_args.end(), other.m_args.begin(), other.m_args.end()); + return *this; + } + + template + auto operator|( T const &other ) const -> Parser { + return Parser( *this ) |= other; + } + + // Forward deprecated interface with '+' instead of '|' + template + auto operator+=( T const &other ) -> Parser & { return operator|=( other ); } + template + auto operator+( T const &other ) const -> Parser { return operator|( other ); } + + auto getHelpColumns() const -> std::vector { + std::vector cols; + for (auto const &o : m_options) { + auto childCols = o.getHelpColumns(); + cols.insert( cols.end(), childCols.begin(), childCols.end() ); + } + return cols; + } + + void writeToStream( std::ostream &os ) const { + if (!m_exeName.name().empty()) { + os << "usage:\n" << " " << m_exeName.name() << " "; + bool required = true, first = true; + for( auto const &arg : m_args ) { + if (first) + first = false; + else + os << " "; + if( arg.isOptional() && required ) { + os << "["; + required = false; + } + os << "<" << arg.hint() << ">"; + if( arg.cardinality() == 0 ) + os << " ... "; + } + if( !required ) + os << "]"; + if( !m_options.empty() ) + os << " options"; + os << "\n\nwhere options are:" << std::endl; + } + + auto rows = getHelpColumns(); + size_t consoleWidth = CLARA_CONFIG_CONSOLE_WIDTH; + size_t optWidth = 0; + for( auto const &cols : rows ) + optWidth = (std::max)(optWidth, cols.left.size() + 2); + + optWidth = (std::min)(optWidth, consoleWidth/2); + + for( auto const &cols : rows ) { + auto row = + TextFlow::Column( cols.left ).width( optWidth ).indent( 2 ) + + TextFlow::Spacer(4) + + TextFlow::Column( cols.right ).width( consoleWidth - 7 - optWidth ); + os << row << std::endl; + } + } + + friend auto operator<<( std::ostream &os, Parser const &parser ) -> std::ostream& { + parser.writeToStream( os ); + return os; + } + + auto validate() const -> Result override { + for( auto const &opt : m_options ) { + auto result = opt.validate(); + if( !result ) + return result; + } + for( auto const &arg : m_args ) { + auto result = arg.validate(); + if( !result ) + return result; + } + return Result::ok(); + } + + using ParserBase::parse; + + auto parse( std::string const& exeName, TokenStream const &tokens ) const -> InternalParseResult override { + + struct ParserInfo { + ParserBase const* parser = nullptr; + size_t count = 0; + }; + const size_t totalParsers = m_options.size() + m_args.size(); + assert( totalParsers < 512 ); + // ParserInfo parseInfos[totalParsers]; // <-- this is what we really want to do + ParserInfo parseInfos[512]; + + { + size_t i = 0; + for (auto const &opt : m_options) parseInfos[i++].parser = &opt; + for (auto const &arg : m_args) parseInfos[i++].parser = &arg; + } + + m_exeName.set( exeName ); + + auto result = InternalParseResult::ok( ParseState( ParseResultType::NoMatch, tokens ) ); + while( result.value().remainingTokens() ) { + bool tokenParsed = false; + + for( size_t i = 0; i < totalParsers; ++i ) { + auto& parseInfo = parseInfos[i]; + if( parseInfo.parser->cardinality() == 0 || parseInfo.count < parseInfo.parser->cardinality() ) { + result = parseInfo.parser->parse(exeName, result.value().remainingTokens()); + if (!result) + return result; + if (result.value().type() != ParseResultType::NoMatch) { + tokenParsed = true; + ++parseInfo.count; + break; + } + } + } + + if( result.value().type() == ParseResultType::ShortCircuitAll ) + return result; + if( !tokenParsed ) + return InternalParseResult::runtimeError( "Unrecognised token: " + result.value().remainingTokens()->token ); + } + // !TBD Check missing required options + return result; + } + }; + + template + template + auto ComposableParserImpl::operator|( T const &other ) const -> Parser { + return Parser() | static_cast( *this ) | other; + } +} // namespace detail + + +// A Combined parser +using detail::Parser; + +// A parser for options +using detail::Opt; + +// A parser for arguments +using detail::Arg; + +// Wrapper for argc, argv from main() +using detail::Args; + +// Specifies the name of the executable +using detail::ExeName; + +// Convenience wrapper for option parser that specifies the help option +using detail::Help; + +// enum of result types from a parse +using detail::ParseResultType; + +// Result type for parser operation +using detail::ParserResult; + + +} // namespace clara + +#endif // CLARA_HPP_INCLUDED diff --git a/src/third_party/cppcodec/test/minimal_decode.cpp b/src/third_party/cppcodec/test/minimal_decode.cpp new file mode 100644 index 0000000000..743f320fd6 --- /dev/null +++ b/src/third_party/cppcodec/test/minimal_decode.cpp @@ -0,0 +1,34 @@ +/** +* Copyright (C) 2018 Jakob Petsovits +* All rights reserved. +* +* Permission is hereby granted, free of charge, to any person obtaining a copy +* of this software and associated documentation files (the "Software"), to +* deal in the Software without restriction, including without limitation the +* rights to use, copy, modify, merge, publish, distribute, sublicense, and/or +* sell copies of the Software, and to permit persons to whom the Software is +* furnished to do so, subject to the following conditions: +* +* The above copyright notice and this permission notice shall be included in +* all copies or substantial portions of the Software. +* +* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL +* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING +* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS +* IN THE SOFTWARE. +*/ + +#include +#include + +int main() +{ + constexpr const char encoded[] = { "YW55IGNhcm5hbCBwbGVhc3U=" }; + char decoded[cppcodec::base64_rfc4648::decoded_max_size(sizeof(encoded))]; + cppcodec::base64_rfc4648::decode(decoded, sizeof(decoded), encoded); + std::cout << decoded << '\n'; + return 0; +} diff --git a/src/third_party/cppcodec/test/test_cppcodec.cpp b/src/third_party/cppcodec/test/test_cppcodec.cpp new file mode 100644 index 0000000000..d7e50bc98c --- /dev/null +++ b/src/third_party/cppcodec/test/test_cppcodec.cpp @@ -0,0 +1,991 @@ +/** + * Copyright (C) 2015 Topology LP + * All rights reserved. + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to + * deal in the Software without restriction, including without limitation the + * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or + * sell copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS + * IN THE SOFTWARE. + */ + +#define CATCH_CONFIG_MAIN +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include // for memcmp() +#include + +TEST_CASE("Douglas Crockford's base32", "[base32][crockford]") { + using base32 = cppcodec::base32_crockford; + + SECTION("encoded size calculation") { + REQUIRE(base32::encoded_size(0) == 0); + REQUIRE(base32::encoded_size(1) == 2); + REQUIRE(base32::encoded_size(2) == 4); + REQUIRE(base32::encoded_size(3) == 5); + REQUIRE(base32::encoded_size(4) == 7); + REQUIRE(base32::encoded_size(5) == 8); + REQUIRE(base32::encoded_size(6) == 10); + REQUIRE(base32::encoded_size(10) == 16); + } + + SECTION("maximum decoded size calculation") { + REQUIRE(base32::decoded_max_size(0) == 0); + REQUIRE(base32::decoded_max_size(1) == 0); + REQUIRE(base32::decoded_max_size(2) == 1); + REQUIRE(base32::decoded_max_size(3) == 1); + REQUIRE(base32::decoded_max_size(4) == 2); + REQUIRE(base32::decoded_max_size(5) == 3); + REQUIRE(base32::decoded_max_size(6) == 3); + REQUIRE(base32::decoded_max_size(7) == 4); + REQUIRE(base32::decoded_max_size(8) == 5); + REQUIRE(base32::decoded_max_size(9) == 5); + REQUIRE(base32::decoded_max_size(10) == 6); + REQUIRE(base32::decoded_max_size(16) == 10); + } + + std::string hello = "Hello World"; + std::string hello_encoded = "91JPRV3F41BPYWKCCG"; + std::string hello_encoded_null = "91JPRV3F41BPYWKCCG00"; + + const uint8_t* hello_uint_ptr = reinterpret_cast(hello.data()); + const uint8_t* hello_uint_ptr_encoded = reinterpret_cast(hello_encoded.data()); + + std::vector hello_uint_vector(hello_uint_ptr, hello_uint_ptr + hello.size()); + std::vector hello_char_vector_encoded( + hello_encoded.data(), hello_encoded.data() + hello_encoded.size()); + std::vector hello_uint_vector_encoded( + hello_uint_ptr_encoded, hello_uint_ptr_encoded + hello_encoded.size()); + + SECTION("encoding data") { + REQUIRE(base32::encode(std::vector()) == ""); + REQUIRE(base32::encode(std::vector({0})) == "00"); + REQUIRE(base32::encode(std::vector({0, 0})) == "0000"); + REQUIRE(base32::encode(std::vector({0, 0, 0})) == "00000"); + REQUIRE(base32::encode(std::vector({0, 0, 0, 0})) == "0000000"); + REQUIRE(base32::encode(std::vector({0, 0, 0, 0, 0})) == "00000000"); + REQUIRE(base32::encode(std::vector({0, 0, 0, 0, 0, 0})) == "0000000000"); + + // Constructing an std::string reduces the size of the char array by one (null terminator). + // Therefore, the result for passing the string literal directly ends up encoding + // one more character, which produces two more symbols in this particular case. + REQUIRE(base32::encode(std::string("Hello World")) == hello_encoded); + REQUIRE(base32::encode("Hello World") == hello_encoded_null); + + REQUIRE(base32::encode(std::string("foo")) == "CSQPY"); + REQUIRE(base32::encode(std::string("lowercase UPPERCASE 1434567 !@#$%^&*")) + == "DHQQESBJCDGQ6S90AN850HAJ8D0N6H9064T36D1N6RVJ08A04CJ2AQH658"); + REQUIRE(base32::encode(std::string("Wow, it really works!")) == "AXQQEB10D5T20WK5C5P6RY90EXQQ4TVK44"); + } + + SECTION("decoding data") { + REQUIRE(base32::decode("") == std::vector()); + REQUIRE(base32::decode("00") == std::vector({0})); + REQUIRE(base32::decode("0000") == std::vector({0, 0})); + REQUIRE(base32::decode("00000") == std::vector({0, 0, 0})); + REQUIRE(base32::decode("0000000") == std::vector({0, 0, 0, 0})); + REQUIRE(base32::decode("00000000") == std::vector({0, 0, 0, 0, 0})); + REQUIRE(base32::decode("0000000000") == std::vector({0, 0, 0, 0, 0, 0})); + + // For decoding data, the result should be the same whether or not there is + // a null terminator at the end, because the input is a string (not binary array). + REQUIRE(base32::decode(std::string("91JPRV3F41BPYWKCCG")) == hello_uint_vector); + REQUIRE(base32::decode("91JPRV3F41BPYWKCCG") == hello_uint_vector); + + REQUIRE(base32::decode("CSQPY") == "foo"); + REQUIRE(base32::decode("DHQQESBJCDGQ6S90AN850HAJ8D0N6H9064T36D1N6RVJ08A04CJ2AQH658") + == "lowercase UPPERCASE 1434567 !@#$%^&*"); + + // Lowercase should decode just as well as uppercase. + REQUIRE(base32::decode("AXQQEB10D5T20WK5C5P6RY90EXQQ4TVK44") == "Wow, it really works!"); + REQUIRE(base32::decode("axqqeb10d5t20wk5c5p6ry90exqq4tvk44") == "Wow, it really works!"); + + // Dashes are allowed for visual separation and ignored when decoding. + REQUIRE(base32::decode("-C-SQ--PY-") == "foo"); + + // An invalid number of symbols should throw the right kind of parse_error. + REQUIRE_THROWS_AS(base32::decode("0"), cppcodec::invalid_input_length); + REQUIRE_THROWS_AS(base32::decode("000"), cppcodec::invalid_input_length); + REQUIRE_THROWS_AS(base32::decode("000000"), cppcodec::invalid_input_length); + REQUIRE_THROWS_AS(base32::decode("000000000"), cppcodec::invalid_input_length); + + // An invalid symbol should throw a symbol error. + REQUIRE_THROWS_AS(base32::decode("00======"), cppcodec::symbol_error); // no padding for Crockford + REQUIRE_THROWS_AS(base32::decode("Uu"), cppcodec::symbol_error); // only a checksum symbol here + REQUIRE_THROWS_AS(base32::decode("++"), cppcodec::symbol_error); // make sure it's not base64 + REQUIRE_THROWS_AS(base32::decode("//"), cppcodec::symbol_error); // ...ditto + } + + // Only test overloads once (for base32_crockford, since it happens to be the first one). + // Since it's all templated, we assume that overloads work/behave similarly for other codecs. + SECTION("encode() overloads") { + // Other convenient overloads for taking raw pointer input. + REQUIRE(base32::encode(hello.data(), hello.size()) == hello_encoded); + REQUIRE(base32::encode(hello_uint_ptr, hello.size()) == hello_encoded); + + // Reused result pointer. Put the extra null terminator version in the middle to test resizing. + std::string result; + REQUIRE((base32::encode(result, hello_uint_ptr, hello.size()), result) == hello_encoded); + REQUIRE((base32::encode(result, "Hello World"), result) == hello_encoded_null); + REQUIRE((base32::encode(result, hello.data(), hello.size()), result) == hello_encoded); + + // Templated result. Use std::vector to exercise non-char array types. + REQUIRE(base32::encode>(hello) == hello_uint_vector_encoded); + REQUIRE(base32::encode>(hello.data(), hello.size()) == hello_uint_vector_encoded); + REQUIRE(base32::encode>(hello_uint_ptr, hello.size()) == hello_uint_vector_encoded); + + // Raw pointer output. + std::vector hello_char_result; + hello_char_result.resize(base32::encoded_size(hello.size())); + REQUIRE(hello_char_result.size() == hello_char_vector_encoded.size()); + + size_t result_size; + result_size = base32::encode(hello_char_result.data(), hello_char_result.size(), hello); + REQUIRE(result_size == hello_char_vector_encoded.size()); + REQUIRE(hello_char_result == hello_char_vector_encoded); + + result_size = base32::encode( + hello_char_result.data(), hello_char_result.size(), hello.data(), hello.size()); + REQUIRE(result_size == hello_char_vector_encoded.size()); + REQUIRE(hello_char_result == hello_char_vector_encoded); + + // Test that when passed a larger buffer, the null termination character will be written + // after the last proper symbol. (Also test uint8_t* overload.) + hello_char_result.resize(hello_char_result.size() + 1); + hello_char_result[hello_char_result.size() - 1] = 'x'; + result_size = base32::encode( + hello_char_result.data(), hello_char_result.size(), hello_uint_ptr, hello.size()); + REQUIRE(result_size == hello_char_vector_encoded.size()); + REQUIRE(hello_char_result[hello_char_result.size() - 1] == '\0'); + hello_char_result.resize(hello_char_result.size() - 1); + REQUIRE(hello_char_result == hello_char_vector_encoded); + } + + // Only test overloads once (for base32_crockford, since it happens to be the first one). + // Since it's all templated, we assume that overloads work/behave similarly for other codecs. + SECTION("decode() overloads") { + // Other convenient overloads for taking raw pointer input. + REQUIRE(base32::decode(hello_encoded.data(), hello_encoded.size()) == hello_uint_vector); + + // Reused result pointer. Put a different string in the middle to test resizing. + std::vector result; + REQUIRE((base32::decode(result, hello_encoded.data(), hello_encoded.size()), result) + == hello_uint_vector); + REQUIRE((base32::decode(result, "00"), result) == std::vector({0})); + REQUIRE((base32::decode(result, hello_encoded), result) == hello_uint_vector); + + // Templated result. Use std::string to exercise non-uint8_t array types. + REQUIRE(base32::decode(hello_encoded) == hello); + REQUIRE(base32::decode(hello_uint_vector_encoded) == hello); + REQUIRE(base32::decode(hello_encoded.data(), hello_encoded.size()) == hello); + + // Raw pointer output. + std::vector hello_uint_result; + std::vector hello_char_result; + size_t hello_decoded_max_size = base32::decoded_max_size(hello_encoded.size()); + REQUIRE(hello.size() <= hello_decoded_max_size); + + hello_char_result.resize(hello_decoded_max_size); + size_t result_size = base32::decode( + hello_char_result.data(), hello_char_result.size(), hello_encoded); + REQUIRE(result_size == hello.size()); + REQUIRE(std::string(hello_char_result.data(), hello_char_result.data() + result_size) == hello); + + hello_char_result.resize(hello_decoded_max_size); + result_size = base32::decode( + hello_char_result.data(), hello_char_result.size(), + hello_encoded.data(), hello_encoded.size()); + REQUIRE(result_size == hello.size()); + REQUIRE(std::string(hello_char_result.data(), hello_char_result.data() + result_size) == hello); + + hello_uint_result.resize(hello_decoded_max_size); + result_size = base32::decode( + hello_uint_result.data(), hello_uint_result.size(), hello_encoded); + REQUIRE(result_size == hello.size()); + hello_uint_result.resize(result_size); + REQUIRE(hello_uint_result == hello_uint_vector); + + hello_uint_result.resize(hello_decoded_max_size); + result_size = base32::decode( + hello_uint_result.data(), hello_uint_result.size(), + hello_encoded.data(), hello_encoded.size()); + REQUIRE(result_size == hello.size()); + hello_uint_result.resize(result_size); + REQUIRE(hello_uint_result == hello_uint_vector); + } +} + +TEST_CASE("base32hex", "[base32][hex]") { + using base32 = cppcodec::base32_hex; + + SECTION("encoded size calculation") { + REQUIRE(base32::encoded_size(0) == 0); + REQUIRE(base32::encoded_size(1) == 8); + REQUIRE(base32::encoded_size(2) == 8); + REQUIRE(base32::encoded_size(3) == 8); + REQUIRE(base32::encoded_size(4) == 8); + REQUIRE(base32::encoded_size(5) == 8); + REQUIRE(base32::encoded_size(6) == 16); + REQUIRE(base32::encoded_size(10) == 16); + } + + SECTION("maximum decoded size calculation") { + REQUIRE(base32::decoded_max_size(0) == 0); + REQUIRE(base32::decoded_max_size(1) == 0); + REQUIRE(base32::decoded_max_size(2) == 0); + REQUIRE(base32::decoded_max_size(3) == 0); + REQUIRE(base32::decoded_max_size(4) == 0); + REQUIRE(base32::decoded_max_size(5) == 0); + REQUIRE(base32::decoded_max_size(6) == 0); + REQUIRE(base32::decoded_max_size(7) == 0); + REQUIRE(base32::decoded_max_size(8) == 5); + REQUIRE(base32::decoded_max_size(9) == 5); + REQUIRE(base32::decoded_max_size(10) == 5); + REQUIRE(base32::decoded_max_size(16) == 10); + } + + SECTION("encoding data") { + REQUIRE(base32::encode(std::vector()) == ""); + REQUIRE(base32::encode(std::vector({0})) == "00======"); + REQUIRE(base32::encode(std::vector({0, 0})) == "0000===="); + REQUIRE(base32::encode(std::vector({0, 0, 0})) == "00000==="); + REQUIRE(base32::encode(std::vector({0, 0, 0, 0})) == "0000000="); + REQUIRE(base32::encode(std::vector({0, 0, 0, 0, 0})) == "00000000"); + REQUIRE(base32::encode(std::vector({0, 0, 0, 0, 0, 0})) == "0000000000======"); + + // Constructing an std::string reduces the size of the char array by one (null terminator). + // Therefore, the result for passing the string literal directly ends up encoding + // one more character, which produces two more symbols in this particular case. + REQUIRE(base32::encode(std::string("Hello")) == "91IMOR3F"); + REQUIRE(base32::encode("Hello") == "91IMOR3F00======"); + + // RFC 4648: 10. Test Vectors + REQUIRE(base32::encode(std::string("")) == ""); + REQUIRE(base32::encode(std::string("f")) == "CO======"); + REQUIRE(base32::encode(std::string("fo")) == "CPNG===="); + REQUIRE(base32::encode(std::string("foo")) == "CPNMU==="); + REQUIRE(base32::encode(std::string("foob")) == "CPNMUOG="); + REQUIRE(base32::encode(std::string("fooba")) == "CPNMUOJ1"); + REQUIRE(base32::encode(std::string("foobar")) == "CPNMUOJ1E8======"); + + // Other test strings. + REQUIRE(base32::encode(std::vector({255, 255, 255, 255, 255})) == "VVVVVVVV"); + } + + SECTION("decoding data") { + REQUIRE(base32::decode("") == std::vector()); + REQUIRE(base32::decode("00======") == std::vector({0})); + REQUIRE(base32::decode("0000====") == std::vector({0, 0})); + REQUIRE(base32::decode("00000===") == std::vector({0, 0, 0})); + REQUIRE(base32::decode("0000000=") == std::vector({0, 0, 0, 0})); + REQUIRE(base32::decode("00000000") == std::vector({0, 0, 0, 0, 0})); + REQUIRE(base32::decode("0000000000======") == std::vector({0, 0, 0, 0, 0, 0})); + + // For decoding data, the result should be the same whether or not there is + // a null terminator at the end, because the input is a string (not binary array). + REQUIRE(base32::decode(std::string("91IMOR3F")) == "Hello"); + REQUIRE(base32::decode("91IMOR3F") == "Hello"); + + // RFC 4648: 10. Test Vectors + REQUIRE(base32::decode("") == ""); + REQUIRE(base32::decode("CO======") == "f"); + REQUIRE(base32::decode("CPNG====") == "fo"); + REQUIRE(base32::decode("CPNMU===") == "foo"); + REQUIRE(base32::decode("CPNMUOG=") == "foob"); + REQUIRE(base32::decode("CPNMUOJ1") == "fooba"); + REQUIRE(base32::decode("CPNMUOJ1E8======") == "foobar"); + + // Other test strings. + REQUIRE(base32::decode("VVVVVVVV") == std::vector({255, 255, 255, 255, 255})); + + // Lowercase should decode just as well as uppercase. + REQUIRE(base32::decode("cpnmuoj1") == "fooba"); + REQUIRE(base32::decode("cPnMuOj1") == "fooba"); + + // An invalid number of symbols should throw the right kind of parse_error. + REQUIRE_THROWS_AS(base32::decode("0"), cppcodec::padding_error); + REQUIRE_THROWS_AS(base32::decode("00"), cppcodec::padding_error); + REQUIRE_THROWS_AS(base32::decode("00==="), cppcodec::padding_error); + REQUIRE_THROWS_AS(base32::decode("0======="), cppcodec::invalid_input_length); + REQUIRE_THROWS_AS(base32::decode("000====="), cppcodec::invalid_input_length); + REQUIRE_THROWS_AS(base32::decode("000000=="), cppcodec::invalid_input_length); + + // An invalid symbol should throw a symbol error. + REQUIRE_THROWS_AS(base32::decode("W0======"), cppcodec::symbol_error); + REQUIRE_THROWS_AS(base32::decode("X0======"), cppcodec::symbol_error); + REQUIRE_THROWS_AS(base32::decode("Y0======"), cppcodec::symbol_error); + REQUIRE_THROWS_AS(base32::decode("Z0======"), cppcodec::symbol_error); + REQUIRE_THROWS_AS(base32::decode("CPNM UOJ1"), cppcodec::symbol_error); // no spaces + REQUIRE_THROWS_AS(base32::decode("CPNM-UOJ1"), cppcodec::symbol_error); // no dashes + } +} + +TEST_CASE("base32 (RFC 4648)", "[base32][rfc4648]") { + using base32 = cppcodec::base32_rfc4648; + + SECTION("encoded size calculation") { + REQUIRE(base32::encoded_size(0) == 0); + REQUIRE(base32::encoded_size(1) == 8); + REQUIRE(base32::encoded_size(2) == 8); + REQUIRE(base32::encoded_size(3) == 8); + REQUIRE(base32::encoded_size(4) == 8); + REQUIRE(base32::encoded_size(5) == 8); + REQUIRE(base32::encoded_size(6) == 16); + REQUIRE(base32::encoded_size(10) == 16); + } + + SECTION("maximum decoded size calculation") { + REQUIRE(base32::decoded_max_size(0) == 0); + REQUIRE(base32::decoded_max_size(1) == 0); + REQUIRE(base32::decoded_max_size(2) == 0); + REQUIRE(base32::decoded_max_size(3) == 0); + REQUIRE(base32::decoded_max_size(4) == 0); + REQUIRE(base32::decoded_max_size(5) == 0); + REQUIRE(base32::decoded_max_size(6) == 0); + REQUIRE(base32::decoded_max_size(7) == 0); + REQUIRE(base32::decoded_max_size(8) == 5); + REQUIRE(base32::decoded_max_size(9) == 5); + REQUIRE(base32::decoded_max_size(10) == 5); + REQUIRE(base32::decoded_max_size(16) == 10); + } + + SECTION("encoding data") { + REQUIRE(base32::encode(std::vector()) == ""); + REQUIRE(base32::encode(std::vector({0})) == "AA======"); + REQUIRE(base32::encode(std::vector({0, 0})) == "AAAA===="); + REQUIRE(base32::encode(std::vector({0, 0, 0})) == "AAAAA==="); + REQUIRE(base32::encode(std::vector({0, 0, 0, 0})) == "AAAAAAA="); + REQUIRE(base32::encode(std::vector({0, 0, 0, 0, 0})) == "AAAAAAAA"); + REQUIRE(base32::encode(std::vector({0, 0, 0, 0, 0, 0})) == "AAAAAAAAAA======"); + + // Constructing an std::string reduces the size of the char array by one (null terminator). + // Therefore, the result for passing the string literal directly ends up encoding + // one more character, which produces two more symbols in this particular case. + REQUIRE(base32::encode(std::string("12345")) == "GEZDGNBV"); + REQUIRE(base32::encode("12345") == "GEZDGNBVAA======"); + + // RFC 4648: 10. Test Vectors + REQUIRE(base32::encode(std::string("")) == ""); + REQUIRE(base32::encode(std::string("f")) == "MY======"); + REQUIRE(base32::encode(std::string("fo")) == "MZXQ===="); + REQUIRE(base32::encode(std::string("foo")) == "MZXW6==="); + REQUIRE(base32::encode(std::string("foob")) == "MZXW6YQ="); + REQUIRE(base32::encode(std::string("fooba")) == "MZXW6YTB"); + REQUIRE(base32::encode(std::string("foobar")) == "MZXW6YTBOI======"); + + // Other test strings. + REQUIRE(base32::encode(std::string("ABCDE")) == "IFBEGRCF"); + REQUIRE(base32::encode(std::vector({255, 255, 255, 255, 255})) == "77777777"); + } + + SECTION("decoding data") { + REQUIRE(base32::decode("") == std::vector()); + REQUIRE(base32::decode("AA======") == std::vector({0})); + REQUIRE(base32::decode("AAAA====") == std::vector({0, 0})); + REQUIRE(base32::decode("AAAAA===") == std::vector({0, 0, 0})); + REQUIRE(base32::decode("AAAAAAA=") == std::vector({0, 0, 0, 0})); + REQUIRE(base32::decode("AAAAAAAA") == std::vector({0, 0, 0, 0, 0})); + REQUIRE(base32::decode("AAAAAAAAAA======") == std::vector({0, 0, 0, 0, 0, 0})); + + // For decoding data, the result should be the same whether or not there is + // a null terminator at the end, because the input is a string (not binary array). + REQUIRE(base32::decode(std::string("GEZDGNBV")) == "12345"); + REQUIRE(base32::decode("GEZDGNBV") == "12345"); + + // RFC 4648: 10. Test Vectors + REQUIRE(base32::decode("") == ""); + REQUIRE(base32::decode("MY======") == "f"); + REQUIRE(base32::decode("MZXQ====") == "fo"); + REQUIRE(base32::decode("MZXW6===") == "foo"); + REQUIRE(base32::decode("MZXW6YQ=") == "foob"); + REQUIRE(base32::decode("MZXW6YTB") == "fooba"); + REQUIRE(base32::decode("MZXW6YTBOI======") == "foobar"); + + // Other test strings. + REQUIRE(base32::decode("IFBEGRCF") == "ABCDE"); + REQUIRE(base32::decode("77777777") == std::vector({255, 255, 255, 255, 255})); + + // Lowercase should decode just as well as uppercase. + REQUIRE(base32::decode("mzxw6ytb") == "fooba"); + REQUIRE(base32::decode("mZxW6yTb") == "fooba"); + + // An invalid number of symbols should throw the right kind of parse_error. + REQUIRE_THROWS_AS(base32::decode("A"), cppcodec::padding_error); + REQUIRE_THROWS_AS(base32::decode("AA"), cppcodec::padding_error); + REQUIRE_THROWS_AS(base32::decode("AA==="), cppcodec::padding_error); + REQUIRE_THROWS_AS(base32::decode("A======="), cppcodec::invalid_input_length); + REQUIRE_THROWS_AS(base32::decode("AAA====="), cppcodec::invalid_input_length); + REQUIRE_THROWS_AS(base32::decode("AAAAAA=="), cppcodec::invalid_input_length); + + // An invalid symbol should throw a symbol error. + REQUIRE_THROWS_AS(base32::decode("0A======"), cppcodec::symbol_error); + REQUIRE_THROWS_AS(base32::decode("1A======"), cppcodec::symbol_error); + REQUIRE_THROWS_AS(base32::decode("8A======"), cppcodec::symbol_error); + REQUIRE_THROWS_AS(base32::decode("9A======"), cppcodec::symbol_error); + REQUIRE_THROWS_AS(base32::decode("GEZD GNBV"), cppcodec::symbol_error); // no spaces + REQUIRE_THROWS_AS(base32::decode("GEZD-GNBV"), cppcodec::symbol_error); // no dashes + } +} + +TEST_CASE("base64 (RFC 4648)", "[base64][rfc4648]") { + using base64 = cppcodec::base64_rfc4648; + + SECTION("encoded size calculation") { + REQUIRE(base64::encoded_size(0) == 0); + REQUIRE(base64::encoded_size(1) == 4); + REQUIRE(base64::encoded_size(2) == 4); + REQUIRE(base64::encoded_size(3) == 4); + REQUIRE(base64::encoded_size(4) == 8); + REQUIRE(base64::encoded_size(5) == 8); + REQUIRE(base64::encoded_size(6) == 8); + REQUIRE(base64::encoded_size(7) == 12); + REQUIRE(base64::encoded_size(12) == 16); + } + + SECTION("maximum decoded size calculation") { + REQUIRE(base64::decoded_max_size(0) == 0); + REQUIRE(base64::decoded_max_size(1) == 0); + REQUIRE(base64::decoded_max_size(2) == 0); + REQUIRE(base64::decoded_max_size(3) == 0); + REQUIRE(base64::decoded_max_size(4) == 3); + REQUIRE(base64::decoded_max_size(5) == 3); + REQUIRE(base64::decoded_max_size(6) == 3); + REQUIRE(base64::decoded_max_size(7) == 3); + REQUIRE(base64::decoded_max_size(8) == 6); + REQUIRE(base64::decoded_max_size(9) == 6); + REQUIRE(base64::decoded_max_size(10) == 6); + REQUIRE(base64::decoded_max_size(11) == 6); + REQUIRE(base64::decoded_max_size(12) == 9); + REQUIRE(base64::decoded_max_size(16) == 12); + } + + SECTION("encoding data") { + REQUIRE(base64::encode(std::vector()) == ""); + REQUIRE(base64::encode(std::vector({0})) == "AA=="); + REQUIRE(base64::encode(std::vector({0, 0})) == "AAA="); + REQUIRE(base64::encode(std::vector({0, 0, 0})) == "AAAA"); + REQUIRE(base64::encode(std::vector({0, 0, 0, 0})) == "AAAAAA=="); + REQUIRE(base64::encode(std::vector({0, 0, 0, 0, 0})) == "AAAAAAA="); + REQUIRE(base64::encode(std::vector({0, 0, 0, 0, 0, 0})) == "AAAAAAAA"); + + // Constructing an std::string reduces the size of the char array by one (null terminator). + // Therefore, the result for passing the string literal directly ends up encoding + // one more character, which produces two more symbols in this particular case. + REQUIRE(base64::encode(std::string("Man")) == "TWFu"); + REQUIRE(base64::encode("Man") == "TWFuAA=="); + + // Wikipedia + REQUIRE(base64::encode(std::string("pleasure.")) == "cGxlYXN1cmUu"); + REQUIRE(base64::encode(std::string("leasure.")) == "bGVhc3VyZS4="); + REQUIRE(base64::encode(std::string("easure.")) == "ZWFzdXJlLg=="); + REQUIRE(base64::encode(std::string("asure.")) == "YXN1cmUu"); + REQUIRE(base64::encode(std::string("sure.")) == "c3VyZS4="); + + REQUIRE(base64::encode(std::string("any carnal pleas")) == "YW55IGNhcm5hbCBwbGVhcw=="); + REQUIRE(base64::encode(std::string("any carnal pleasu")) == "YW55IGNhcm5hbCBwbGVhc3U="); + REQUIRE(base64::encode(std::string("any carnal pleasur")) == "YW55IGNhcm5hbCBwbGVhc3Vy"); + + // RFC 4648: 9. Illustrations and Examples, adapted for more special characters + REQUIRE(base64::encode(std::vector({0x14, 0xFB, 0xBF, 0x03, 0xD9, 0x7E})) == "FPu/A9l+"); + REQUIRE(base64::encode(std::vector({0x14, 0xFB, 0xBF, 0x03, 0xD9})) == "FPu/A9k="); + REQUIRE(base64::encode(std::vector({0x14, 0xFB, 0xBF, 0x03})) == "FPu/Aw=="); + + // RFC 4648: 10. Test Vectors + REQUIRE(base64::encode(std::string("")) == ""); + REQUIRE(base64::encode(std::string("f")) == "Zg=="); + REQUIRE(base64::encode(std::string("fo")) == "Zm8="); + REQUIRE(base64::encode(std::string("foo")) == "Zm9v"); + REQUIRE(base64::encode(std::string("foob")) == "Zm9vYg=="); + REQUIRE(base64::encode(std::string("fooba")) == "Zm9vYmE="); + REQUIRE(base64::encode(std::string("foobar")) == "Zm9vYmFy"); + + // Other test strings. + REQUIRE(base64::encode(std::string("123")) == "MTIz"); + REQUIRE(base64::encode(std::string("ABC")) == "QUJD"); + REQUIRE(base64::encode(std::string("\xFF\xFF\xFF")) == "////"); + } + + SECTION("decoding data") { + REQUIRE(base64::decode("") == std::vector()); + REQUIRE(base64::decode("AA==") == std::vector({0})); + REQUIRE(base64::decode("AAA=") == std::vector({0, 0})); + REQUIRE(base64::decode("AAAA") == std::vector({0, 0, 0})); + REQUIRE(base64::decode("AAAAAA==") == std::vector({0, 0, 0, 0})); + REQUIRE(base64::decode("AAAAAAA=") == std::vector({0, 0, 0, 0, 0})); + REQUIRE(base64::decode("AAAAAAAA") == std::vector({0, 0, 0, 0, 0, 0})); + + // For decoding data, the result should be the same whether or not there is + // a null terminator at the end, because the input is a string (not binary array). + REQUIRE(base64::decode(std::string("TWFu")) == "Man"); + REQUIRE(base64::decode("TWFu") == "Man"); + + // Wikipedia + REQUIRE(base64::decode("cGxlYXN1cmUu") == "pleasure."); + REQUIRE(base64::decode("bGVhc3VyZS4=") == "leasure."); + REQUIRE(base64::decode("ZWFzdXJlLg==") == "easure."); + REQUIRE(base64::decode("YXN1cmUu") == "asure."); + REQUIRE(base64::decode("c3VyZS4=") == "sure."); + + REQUIRE(base64::decode("YW55IGNhcm5hbCBwbGVhcw==") == "any carnal pleas"); + REQUIRE(base64::decode("YW55IGNhcm5hbCBwbGVhc3U=") == "any carnal pleasu"); + REQUIRE(base64::decode("YW55IGNhcm5hbCBwbGVhc3Vy") == "any carnal pleasur"); + + // RFC 4648: 9. Illustrations and Examples, adapted for more special characters + REQUIRE(base64::decode("FPu/A9l+") == std::vector({0x14, 0xFB, 0xBF, 0x03, 0xD9, 0x7E})); + REQUIRE(base64::decode("FPu/A9k=") == std::vector({0x14, 0xFB, 0xBF, 0x03, 0xD9})); + REQUIRE(base64::decode("FPu/Aw==") == std::vector({0x14, 0xFB, 0xBF, 0x03})); + + // RFC 4648: 10. Test Vectors + REQUIRE(base64::decode("") == ""); + REQUIRE(base64::decode("Zg==") == "f"); + REQUIRE(base64::decode("Zm8=") == "fo"); + REQUIRE(base64::decode("Zm9v") == "foo"); + REQUIRE(base64::decode("Zm9vYg==") == "foob"); + REQUIRE(base64::decode("Zm9vYmE=") == "fooba"); + REQUIRE(base64::decode("Zm9vYmFy") == "foobar"); + + // Other test strings. + REQUIRE(base64::decode("MTIz") == "123"); + REQUIRE(base64::decode("QUJD") == "ABC"); + REQUIRE(base64::decode("////") == std::vector({255, 255, 255})); + + // An invalid number of symbols should throw the right kind of parse_error. + REQUIRE_THROWS_AS(base64::decode("A"), cppcodec::padding_error); + REQUIRE_THROWS_AS(base64::decode("AA"), cppcodec::padding_error); + REQUIRE_THROWS_AS(base64::decode("ABCDE"), cppcodec::padding_error); + REQUIRE_THROWS_AS(base64::decode("A==="), cppcodec::invalid_input_length); + REQUIRE_THROWS_AS(base64::decode("AAAA===="), cppcodec::invalid_input_length); + REQUIRE_THROWS_AS(base64::decode("AAAAA==="), cppcodec::invalid_input_length); + + // An invalid symbol should throw a symbol error. + REQUIRE_THROWS_AS(base64::decode("A&B="), cppcodec::symbol_error); + REQUIRE_THROWS_AS(base64::decode("--"), cppcodec::symbol_error); // this is not base64url + REQUIRE_THROWS_AS(base64::decode("__"), cppcodec::symbol_error); // ...ditto + } +} + +TEST_CASE("base64 (unpadded URL-safe)", "[base64][url_unpadded]") { + using base64 = cppcodec::base64_url_unpadded; + + SECTION("encoded size calculation") { + REQUIRE(base64::encoded_size(0) == 0); + REQUIRE(base64::encoded_size(1) == 2); + REQUIRE(base64::encoded_size(2) == 3); + REQUIRE(base64::encoded_size(3) == 4); + REQUIRE(base64::encoded_size(4) == 6); + REQUIRE(base64::encoded_size(5) == 7); + REQUIRE(base64::encoded_size(6) == 8); + REQUIRE(base64::encoded_size(7) == 10); + REQUIRE(base64::encoded_size(12) == 16); + } + + SECTION("maximum decoded size calculation") { + REQUIRE(base64::decoded_max_size(0) == 0); + REQUIRE(base64::decoded_max_size(1) == 0); + REQUIRE(base64::decoded_max_size(2) == 1); + REQUIRE(base64::decoded_max_size(3) == 2); + REQUIRE(base64::decoded_max_size(4) == 3); + REQUIRE(base64::decoded_max_size(5) == 3); + REQUIRE(base64::decoded_max_size(6) == 4); + REQUIRE(base64::decoded_max_size(7) == 5); + REQUIRE(base64::decoded_max_size(8) == 6); + REQUIRE(base64::decoded_max_size(9) == 6); + REQUIRE(base64::decoded_max_size(10) == 7); + REQUIRE(base64::decoded_max_size(11) == 8); + REQUIRE(base64::decoded_max_size(12) == 9); + REQUIRE(base64::decoded_max_size(16) == 12); + } + + SECTION("encoding data") { + REQUIRE(base64::encode(std::vector()) == ""); + REQUIRE(base64::encode(std::vector({0})) == "AA"); + REQUIRE(base64::encode(std::vector({0, 0})) == "AAA"); + REQUIRE(base64::encode(std::vector({0, 0, 0})) == "AAAA"); + REQUIRE(base64::encode(std::vector({0, 0, 0, 0})) == "AAAAAA"); + REQUIRE(base64::encode(std::vector({0, 0, 0, 0, 0})) == "AAAAAAA"); + REQUIRE(base64::encode(std::vector({0, 0, 0, 0, 0, 0})) == "AAAAAAAA"); + + // RFC 4648: 9. Illustrations and Examples, adapted for more special characters + REQUIRE(base64::encode(std::vector({0x14, 0xFB, 0xBF, 0x03, 0xD9, 0x7E})) == "FPu_A9l-"); + REQUIRE(base64::encode(std::vector({0x14, 0xFB, 0xBF, 0x03, 0xD9})) == "FPu_A9k"); + REQUIRE(base64::encode(std::vector({0x14, 0xFB, 0xBF, 0x03})) == "FPu_Aw"); + + // RFC 4648: 10. Test Vectors + REQUIRE(base64::encode(std::string("")) == ""); + REQUIRE(base64::encode(std::string("f")) == "Zg"); + REQUIRE(base64::encode(std::string("fo")) == "Zm8"); + REQUIRE(base64::encode(std::string("foo")) == "Zm9v"); + REQUIRE(base64::encode(std::string("foob")) == "Zm9vYg"); + REQUIRE(base64::encode(std::string("fooba")) == "Zm9vYmE"); + REQUIRE(base64::encode(std::string("foobar")) == "Zm9vYmFy"); + + // Other test strings. + REQUIRE(base64::encode(std::string("123")) == "MTIz"); + REQUIRE(base64::encode(std::string("ABC")) == "QUJD"); + REQUIRE(base64::encode(std::string("\xFF\xFF\xFF")) == "____"); + } + + SECTION("decoding data") { + REQUIRE(base64::decode("") == std::vector()); + REQUIRE(base64::decode("AA") == std::vector({0})); + REQUIRE(base64::decode("AAA") == std::vector({0, 0})); + REQUIRE(base64::decode("AAAA") == std::vector({0, 0, 0})); + REQUIRE(base64::decode("AAAAAA") == std::vector({0, 0, 0, 0})); + REQUIRE(base64::decode("AAAAAAA") == std::vector({0, 0, 0, 0, 0})); + REQUIRE(base64::decode("AAAAAAAA") == std::vector({0, 0, 0, 0, 0, 0})); + + // RFC 4648: 9. Illustrations and Examples, adapted for more special characters + REQUIRE(base64::decode("FPu_A9l-") == std::vector({0x14, 0xFB, 0xBF, 0x03, 0xD9, 0x7E})); + REQUIRE(base64::decode("FPu_A9k") == std::vector({0x14, 0xFB, 0xBF, 0x03, 0xD9})); + REQUIRE(base64::decode("FPu_Aw") == std::vector({0x14, 0xFB, 0xBF, 0x03})); + + // RFC 4648: 10. Test Vectors + REQUIRE(base64::decode("") == ""); + REQUIRE(base64::decode("Zg") == "f"); + REQUIRE(base64::decode("Zg==") == "f"); + REQUIRE(base64::decode("Zm8") == "fo"); + REQUIRE(base64::decode("Zm8=") == "fo"); + REQUIRE(base64::decode("Zm9v") == "foo"); + REQUIRE(base64::decode("Zm9vYg") == "foob"); + REQUIRE(base64::decode("Zm9vYg==") == "foob"); + REQUIRE(base64::decode("Zm9vYmE") == "fooba"); + REQUIRE(base64::decode("Zm9vYmE=") == "fooba"); + REQUIRE(base64::decode("Zm9vYmFy") == "foobar"); + + // Unpadded base64_url allows padding, but an incorrect number of padding characters is still wrong. + REQUIRE_THROWS_AS(base64::decode("Zg="), cppcodec::padding_error); + + // Other test strings. + REQUIRE(base64::decode("MTIz") == "123"); + REQUIRE(base64::decode("QUJD") == "ABC"); + REQUIRE(base64::decode("____") == std::vector({255, 255, 255})); + + // An invalid number of symbols should throw the right kind of parse_error. + REQUIRE_THROWS_AS(base64::decode("A"), cppcodec::invalid_input_length); + REQUIRE_THROWS_AS(base64::decode("AAAAA"), cppcodec::invalid_input_length); + + // An invalid symbol should throw a symbol error. + REQUIRE_THROWS_AS(base64::decode("A&B"), cppcodec::symbol_error); + REQUIRE_THROWS_AS(base64::decode("++"), cppcodec::symbol_error); // this is not standard base64 + REQUIRE_THROWS_AS(base64::decode("//"), cppcodec::symbol_error); // ...ditto + } +} + +TEST_CASE("base64 (URL-safe)", "[base64][url]") { + using base64 = cppcodec::base64_url; + + SECTION("encoded size calculation") { + REQUIRE(base64::encoded_size(0) == 0); + REQUIRE(base64::encoded_size(1) == 4); + REQUIRE(base64::encoded_size(2) == 4); + REQUIRE(base64::encoded_size(3) == 4); + REQUIRE(base64::encoded_size(4) == 8); + REQUIRE(base64::encoded_size(5) == 8); + REQUIRE(base64::encoded_size(6) == 8); + REQUIRE(base64::encoded_size(7) == 12); + REQUIRE(base64::encoded_size(12) == 16); + } + + SECTION("maximum decoded size calculation") { + REQUIRE(base64::decoded_max_size(0) == 0); + REQUIRE(base64::decoded_max_size(1) == 0); + REQUIRE(base64::decoded_max_size(2) == 0); + REQUIRE(base64::decoded_max_size(3) == 0); + REQUIRE(base64::decoded_max_size(4) == 3); + REQUIRE(base64::decoded_max_size(5) == 3); + REQUIRE(base64::decoded_max_size(6) == 3); + REQUIRE(base64::decoded_max_size(7) == 3); + REQUIRE(base64::decoded_max_size(8) == 6); + REQUIRE(base64::decoded_max_size(9) == 6); + REQUIRE(base64::decoded_max_size(10) == 6); + REQUIRE(base64::decoded_max_size(11) == 6); + REQUIRE(base64::decoded_max_size(12) == 9); + REQUIRE(base64::decoded_max_size(16) == 12); + } + + SECTION("encoding data") { + REQUIRE(base64::encode(std::vector()) == ""); + REQUIRE(base64::encode(std::vector({0})) == "AA=="); + REQUIRE(base64::encode(std::vector({0, 0})) == "AAA="); + REQUIRE(base64::encode(std::vector({0, 0, 0})) == "AAAA"); + REQUIRE(base64::encode(std::vector({0, 0, 0, 0})) == "AAAAAA=="); + REQUIRE(base64::encode(std::vector({0, 0, 0, 0, 0})) == "AAAAAAA="); + REQUIRE(base64::encode(std::vector({0, 0, 0, 0, 0, 0})) == "AAAAAAAA"); + + // RFC 4648: 9. Illustrations and Examples, adapted for more special characters + REQUIRE(base64::encode(std::vector({0x14, 0xFB, 0xBF, 0x03, 0xD9, 0x7E})) == "FPu_A9l-"); + REQUIRE(base64::encode(std::vector({0x14, 0xFB, 0xBF, 0x03, 0xD9})) == "FPu_A9k="); + REQUIRE(base64::encode(std::vector({0x14, 0xFB, 0xBF, 0x03})) == "FPu_Aw=="); + + // RFC 4648: 10. Test Vectors + REQUIRE(base64::encode(std::string("")) == ""); + REQUIRE(base64::encode(std::string("f")) == "Zg=="); + REQUIRE(base64::encode(std::string("fo")) == "Zm8="); + REQUIRE(base64::encode(std::string("foo")) == "Zm9v"); + REQUIRE(base64::encode(std::string("foob")) == "Zm9vYg=="); + REQUIRE(base64::encode(std::string("fooba")) == "Zm9vYmE="); + REQUIRE(base64::encode(std::string("foobar")) == "Zm9vYmFy"); + + // Other test strings. + REQUIRE(base64::encode(std::string("123")) == "MTIz"); + REQUIRE(base64::encode(std::string("ABC")) == "QUJD"); + REQUIRE(base64::encode(std::string("\xFF\xFF\xFF")) == "____"); + } + + SECTION("decoding data") { + REQUIRE(base64::decode("") == std::vector()); + REQUIRE(base64::decode("AA==") == std::vector({0})); + REQUIRE(base64::decode("AAA=") == std::vector({0, 0})); + REQUIRE(base64::decode("AAAA") == std::vector({0, 0, 0})); + REQUIRE(base64::decode("AAAAAA==") == std::vector({0, 0, 0, 0})); + REQUIRE(base64::decode("AAAAAAA=") == std::vector({0, 0, 0, 0, 0})); + REQUIRE(base64::decode("AAAAAAAA") == std::vector({0, 0, 0, 0, 0, 0})); + + // RFC 4648: 9. Illustrations and Examples, adapted for more special characters + REQUIRE(base64::decode("FPu_A9l-") == std::vector({0x14, 0xFB, 0xBF, 0x03, 0xD9, 0x7E})); + REQUIRE(base64::decode("FPu_A9k=") == std::vector({0x14, 0xFB, 0xBF, 0x03, 0xD9})); + REQUIRE(base64::decode("FPu_Aw==") == std::vector({0x14, 0xFB, 0xBF, 0x03})); + + // RFC 4648: 10. Test Vectors + REQUIRE(base64::decode("") == ""); + REQUIRE(base64::decode("Zg==") == "f"); + REQUIRE(base64::decode("Zm8=") == "fo"); + REQUIRE(base64::decode("Zm9v") == "foo"); + REQUIRE(base64::decode("Zm9vYg==") == "foob"); + REQUIRE(base64::decode("Zm9vYmE=") == "fooba"); + REQUIRE(base64::decode("Zm9vYmFy") == "foobar"); + + // Other test strings. + REQUIRE(base64::decode("MTIz") == "123"); + REQUIRE(base64::decode("QUJD") == "ABC"); + REQUIRE(base64::decode("____") == std::vector({255, 255, 255})); + + // An invalid number of symbols should throw the right kind of parse_error. + REQUIRE_THROWS_AS(base64::decode("A"), cppcodec::padding_error); + REQUIRE_THROWS_AS(base64::decode("AA"), cppcodec::padding_error); + REQUIRE_THROWS_AS(base64::decode("ABCDE"), cppcodec::padding_error); + REQUIRE_THROWS_AS(base64::decode("A==="), cppcodec::invalid_input_length); + REQUIRE_THROWS_AS(base64::decode("AAAA===="), cppcodec::invalid_input_length); + REQUIRE_THROWS_AS(base64::decode("AAAAA==="), cppcodec::invalid_input_length); + + // An invalid symbol should throw a symbol error. + REQUIRE_THROWS_AS(base64::decode("A&B="), cppcodec::symbol_error); + REQUIRE_THROWS_AS(base64::decode("++"), cppcodec::symbol_error); // this is not standard base64 + REQUIRE_THROWS_AS(base64::decode("//"), cppcodec::symbol_error); // ...ditto + } +} + +TEST_CASE("hex (lowercase)", "[hex][lower]") { + using hex = cppcodec::hex_lower; + + SECTION("encoded size calculation") { + REQUIRE(hex::encoded_size(0) == 0); + REQUIRE(hex::encoded_size(1) == 2); + REQUIRE(hex::encoded_size(2) == 4); + REQUIRE(hex::encoded_size(3) == 6); + REQUIRE(hex::encoded_size(4) == 8); + REQUIRE(hex::encoded_size(5) == 10); + REQUIRE(hex::encoded_size(6) == 12); + REQUIRE(hex::encoded_size(8) == 16); + REQUIRE(hex::encoded_size(10) == 20); + } + + SECTION("maximum decoded size calculation") { + REQUIRE(hex::decoded_max_size(0) == 0); + REQUIRE(hex::decoded_max_size(1) == 0); + REQUIRE(hex::decoded_max_size(2) == 1); + REQUIRE(hex::decoded_max_size(3) == 1); + REQUIRE(hex::decoded_max_size(4) == 2); + REQUIRE(hex::decoded_max_size(5) == 2); + REQUIRE(hex::decoded_max_size(6) == 3); + REQUIRE(hex::decoded_max_size(7) == 3); + REQUIRE(hex::decoded_max_size(8) == 4); + REQUIRE(hex::decoded_max_size(9) == 4); + REQUIRE(hex::decoded_max_size(10) == 5); + REQUIRE(hex::decoded_max_size(16) == 8); + REQUIRE(hex::decoded_max_size(20) == 10); + } + + SECTION("encoding data") { + REQUIRE(hex::encode(std::vector()) == ""); + REQUIRE(hex::encode(std::vector({0})) == "00"); + REQUIRE(hex::encode(std::vector({0, 0})) == "0000"); + REQUIRE(hex::encode(std::vector({0, 0, 0})) == "000000"); + REQUIRE(hex::encode(std::vector({0, 0, 0, 0})) == "00000000"); + REQUIRE(hex::encode(std::vector({0, 0, 0, 0, 0})) == "0000000000"); + REQUIRE(hex::encode(std::vector({0, 0, 0, 0, 0, 0})) == "000000000000"); + + // Constructing an std::string reduces the size of the char array by one (null terminator). + // Therefore, the result for passing the string literal directly ends up encoding + // one more character, which produces two more symbols in this particular case. + REQUIRE(hex::encode(std::string("1")) == "31"); + REQUIRE(hex::encode("1") == "3100"); + + REQUIRE(hex::encode(std::string("A")) == "41"); + REQUIRE(hex::encode(std::vector({255})) == "ff"); + + // RFC 4648: 10. Test Vectors + REQUIRE(hex::encode(std::string("")) == ""); + REQUIRE(hex::encode(std::string("f")) == "66"); + REQUIRE(hex::encode(std::string("fo")) == "666f"); + REQUIRE(hex::encode(std::string("foo")) == "666f6f"); + REQUIRE(hex::encode(std::string("foob")) == "666f6f62"); + REQUIRE(hex::encode(std::string("fooba")) == "666f6f6261"); + REQUIRE(hex::encode(std::string("foobar")) == "666f6f626172"); + } + + SECTION("decoding data") { + REQUIRE(hex::decode("") == std::vector()); + REQUIRE(hex::decode("00") == std::vector({0})); + REQUIRE(hex::decode("0000") == std::vector({0, 0})); + REQUIRE(hex::decode("000000") == std::vector({0, 0, 0})); + REQUIRE(hex::decode("00000000") == std::vector({0, 0, 0, 0})); + REQUIRE(hex::decode("0000000000") == std::vector({0, 0, 0, 0, 0})); + REQUIRE(hex::decode("000000000000") == std::vector({0, 0, 0, 0, 0, 0})); + + // For decoding data, the result should be the same whether or not there is + // a null terminator at the end, because the input is a string (not binary array). + REQUIRE(hex::decode(std::string("31")) == "1"); + REQUIRE(hex::decode("31") == "1"); + + // RFC 4648: 10. Test Vectors + REQUIRE(hex::decode("") == ""); + REQUIRE(hex::decode("66") == "f"); + REQUIRE(hex::decode("666f") == "fo"); + REQUIRE(hex::decode("666f6f") == "foo"); + REQUIRE(hex::decode("666f6f62") == "foob"); + REQUIRE(hex::decode("666f6f6261") == "fooba"); + REQUIRE(hex::decode("666f6f626172") == "foobar"); + + // Uppercase should decode just as well as lowercase. + REQUIRE(hex::decode("666F6F6261") == "fooba"); + REQUIRE(hex::decode("666F6f6261") == "fooba"); + + // An invalid number of symbols should throw the right kind of parse_error. + REQUIRE_THROWS_AS(hex::decode("0"), cppcodec::invalid_input_length); + REQUIRE_THROWS_AS(hex::decode("000"), cppcodec::invalid_input_length); + + // An invalid symbol should throw a symbol error. + REQUIRE_THROWS_AS(hex::decode("1g"), cppcodec::symbol_error); + REQUIRE_THROWS_AS(hex::decode("66 6f"), cppcodec::symbol_error); // no spaces + REQUIRE_THROWS_AS(hex::decode("66-6f"), cppcodec::symbol_error); // no dashes + } +} + +TEST_CASE("hex (uppercase)", "[hex][upper]") { + using hex = cppcodec::hex_upper; + + SECTION("encoded size calculation") { + REQUIRE(hex::encoded_size(0) == 0); + REQUIRE(hex::encoded_size(1) == 2); + REQUIRE(hex::encoded_size(2) == 4); + REQUIRE(hex::encoded_size(3) == 6); + REQUIRE(hex::encoded_size(4) == 8); + REQUIRE(hex::encoded_size(5) == 10); + REQUIRE(hex::encoded_size(6) == 12); + REQUIRE(hex::encoded_size(8) == 16); + REQUIRE(hex::encoded_size(10) == 20); + } + + SECTION("maximum decoded size calculation") { + REQUIRE(hex::decoded_max_size(0) == 0); + REQUIRE(hex::decoded_max_size(1) == 0); + REQUIRE(hex::decoded_max_size(2) == 1); + REQUIRE(hex::decoded_max_size(3) == 1); + REQUIRE(hex::decoded_max_size(4) == 2); + REQUIRE(hex::decoded_max_size(5) == 2); + REQUIRE(hex::decoded_max_size(6) == 3); + REQUIRE(hex::decoded_max_size(7) == 3); + REQUIRE(hex::decoded_max_size(8) == 4); + REQUIRE(hex::decoded_max_size(9) == 4); + REQUIRE(hex::decoded_max_size(10) == 5); + REQUIRE(hex::decoded_max_size(16) == 8); + REQUIRE(hex::decoded_max_size(20) == 10); + } + + SECTION("encoding data") { + REQUIRE(hex::encode(std::vector()) == ""); + REQUIRE(hex::encode(std::vector({0})) == "00"); + REQUIRE(hex::encode(std::vector({0, 0})) == "0000"); + REQUIRE(hex::encode(std::vector({0, 0, 0})) == "000000"); + REQUIRE(hex::encode(std::vector({0, 0, 0, 0})) == "00000000"); + REQUIRE(hex::encode(std::vector({0, 0, 0, 0, 0})) == "0000000000"); + REQUIRE(hex::encode(std::vector({0, 0, 0, 0, 0, 0})) == "000000000000"); + + // Constructing an std::string reduces the size of the char array by one (null terminator). + // Therefore, the result for passing the string literal directly ends up encoding + // one more character, which produces two more symbols in this particular case. + REQUIRE(hex::encode(std::string("1")) == "31"); + REQUIRE(hex::encode("1") == "3100"); + + REQUIRE(hex::encode(std::string("A")) == "41"); + REQUIRE(hex::encode(std::vector({255})) == "FF"); + + // RFC 4648: 10. Test Vectors + REQUIRE(hex::encode(std::string("")) == ""); + REQUIRE(hex::encode(std::string("f")) == "66"); + REQUIRE(hex::encode(std::string("fo")) == "666F"); + REQUIRE(hex::encode(std::string("foo")) == "666F6F"); + REQUIRE(hex::encode(std::string("foob")) == "666F6F62"); + REQUIRE(hex::encode(std::string("fooba")) == "666F6F6261"); + REQUIRE(hex::encode(std::string("foobar")) == "666F6F626172"); + } + + SECTION("decoding data") { + REQUIRE(hex::decode("") == std::vector()); + REQUIRE(hex::decode("00") == std::vector({0})); + REQUIRE(hex::decode("0000") == std::vector({0, 0})); + REQUIRE(hex::decode("000000") == std::vector({0, 0, 0})); + REQUIRE(hex::decode("00000000") == std::vector({0, 0, 0, 0})); + REQUIRE(hex::decode("0000000000") == std::vector({0, 0, 0, 0, 0})); + REQUIRE(hex::decode("000000000000") == std::vector({0, 0, 0, 0, 0, 0})); + + // For decoding data, the result should be the same whether or not there is + // a null terminator at the end, because the input is a string (not binary array). + REQUIRE(hex::decode(std::string("31")) == "1"); + REQUIRE(hex::decode("31") == "1"); + + // RFC 4648: 10. Test Vectors + REQUIRE(hex::decode("") == ""); + REQUIRE(hex::decode("66") == "f"); + REQUIRE(hex::decode("666F") == "fo"); + REQUIRE(hex::decode("666F6F") == "foo"); + REQUIRE(hex::decode("666F6F62") == "foob"); + REQUIRE(hex::decode("666F6F6261") == "fooba"); + REQUIRE(hex::decode("666F6F626172") == "foobar"); + + // Lowercase should decode just as well as uppercase. + REQUIRE(hex::decode("666f6f6261") == "fooba"); + REQUIRE(hex::decode("666f6F6261") == "fooba"); + + // An invalid number of symbols should throw the right kind of parse_error. + REQUIRE_THROWS_AS(hex::decode("0"), cppcodec::invalid_input_length); + REQUIRE_THROWS_AS(hex::decode("000"), cppcodec::invalid_input_length); + + // An invalid symbol should throw a symbol error. + REQUIRE_THROWS_AS(hex::decode("1G"), cppcodec::symbol_error); + REQUIRE_THROWS_AS(hex::decode("66 6F"), cppcodec::symbol_error); // no spaces + REQUIRE_THROWS_AS(hex::decode("66-6F"), cppcodec::symbol_error); // no dashes + } +} diff --git a/src/third_party/cppcodec/tool/CMakeLists.txt b/src/third_party/cppcodec/tool/CMakeLists.txt new file mode 100644 index 0000000000..ba7de0864b --- /dev/null +++ b/src/third_party/cppcodec/tool/CMakeLists.txt @@ -0,0 +1,11 @@ +# For cppcodec itself, don't prefer system headers over development ones. +include_directories(BEFORE ${PROJECT_SOURCE_DIR}) + +add_executable(base32enc base32enc.cpp) +add_executable(base32dec base32dec.cpp) + +add_executable(base64enc base64enc.cpp) +add_executable(base64dec base64dec.cpp) + +add_executable(hexenc hexenc.cpp) +add_executable(hexdec hexdec.cpp) diff --git a/src/third_party/cppcodec/tool/base32dec.cpp b/src/third_party/cppcodec/tool/base32dec.cpp new file mode 100644 index 0000000000..a046a5236c --- /dev/null +++ b/src/third_party/cppcodec/tool/base32dec.cpp @@ -0,0 +1,49 @@ +/** + * Copyright (C) 2015 Topology LP + * All rights reserved. + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to + * deal in the Software without restriction, including without limitation the + * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or + * sell copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS + * IN THE SOFTWARE. + */ + +#include +#include + +#include +#include +#include + +int main(int argc, char *argv[]) +{ + for (int i = 1; i < argc; ++i) { + size_t arglen = strlen(argv[i]); + + try { + std::cout << cppcodec::base32_crockford::decode(argv[i], arglen) << std::endl; + } catch (const cppcodec::parse_error& e) { + std::cout << "#" << i << ": " << e.what() << std::endl; + } + + try { + std::cout << cppcodec::base32_rfc4648::decode(argv[i], arglen) << std::endl; + } catch (const cppcodec::parse_error& e) { + std::cout << "#" << i << ": " << e.what() << std::endl; + } + } + return 0; +} diff --git a/src/third_party/cppcodec/tool/base32enc.cpp b/src/third_party/cppcodec/tool/base32enc.cpp new file mode 100644 index 0000000000..d7f102dd28 --- /dev/null +++ b/src/third_party/cppcodec/tool/base32enc.cpp @@ -0,0 +1,40 @@ +/** + * Copyright (C) 2015 Topology LP + * All rights reserved. + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to + * deal in the Software without restriction, including without limitation the + * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or + * sell copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS + * IN THE SOFTWARE. + */ + +#include +#include + +#include +#include +#include + +int main(int argc, char *argv[]) +{ + for (int i = 1; i < argc; ++i) { + size_t arglen = strlen(argv[i]); + + std::cout << cppcodec::base32_crockford::encode(argv[i], arglen) << std::endl; + std::cout << cppcodec::base32_rfc4648::encode(argv[i], arglen) << std::endl; + } + return 0; +} diff --git a/src/third_party/cppcodec/tool/base64dec.cpp b/src/third_party/cppcodec/tool/base64dec.cpp new file mode 100644 index 0000000000..3b670fe38b --- /dev/null +++ b/src/third_party/cppcodec/tool/base64dec.cpp @@ -0,0 +1,49 @@ +/** + * Copyright (C) 2015 Topology LP + * All rights reserved. + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to + * deal in the Software without restriction, including without limitation the + * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or + * sell copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS + * IN THE SOFTWARE. + */ + +#include +#include + +#include +#include +#include + +int main(int argc, char *argv[]) +{ + for (int i = 1; i < argc; ++i) { + size_t arglen = strlen(argv[i]); + + try { + std::cout << cppcodec::base64_rfc4648::decode(argv[i], arglen) << std::endl; + } catch (const cppcodec::parse_error& e) { + std::cout << "#" << i << ": " << e.what() << std::endl; + } + + try { + std::cout << cppcodec::base64_url::decode(argv[i], arglen) << std::endl; + } catch (const cppcodec::parse_error& e) { + std::cout << "#" << i << ": " << e.what() << std::endl; + } + } + return 0; +} diff --git a/src/third_party/cppcodec/tool/base64enc.cpp b/src/third_party/cppcodec/tool/base64enc.cpp new file mode 100644 index 0000000000..d28f46bf62 --- /dev/null +++ b/src/third_party/cppcodec/tool/base64enc.cpp @@ -0,0 +1,40 @@ +/** + * Copyright (C) 2015 Topology LP + * All rights reserved. + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to + * deal in the Software without restriction, including without limitation the + * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or + * sell copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS + * IN THE SOFTWARE. + */ + +#include +#include + +#include +#include +#include + +int main(int argc, char *argv[]) +{ + for (int i = 1; i < argc; ++i) { + size_t arglen = strlen(argv[i]); + + std::cout << cppcodec::base64_rfc4648::encode(argv[i], arglen) << std::endl; + std::cout << cppcodec::base64_url::encode(argv[i], arglen) << std::endl; + } + return 0; +} diff --git a/src/third_party/cppcodec/tool/hexdec.cpp b/src/third_party/cppcodec/tool/hexdec.cpp new file mode 100644 index 0000000000..cb3c7252f0 --- /dev/null +++ b/src/third_party/cppcodec/tool/hexdec.cpp @@ -0,0 +1,49 @@ +/** + * Copyright (C) 2015 Topology LP + * All rights reserved. + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to + * deal in the Software without restriction, including without limitation the + * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or + * sell copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS + * IN THE SOFTWARE. + */ + +#include +#include + +#include +#include +#include + +int main(int argc, char *argv[]) +{ + for (int i = 1; i < argc; ++i) { + size_t arglen = strlen(argv[i]); + + try { + std::cout << cppcodec::hex_lower::decode(argv[i], arglen) << std::endl; + } catch (const cppcodec::parse_error& e) { + std::cout << "#" << i << ": " << e.what() << std::endl; + } + + try { + std::cout << cppcodec::hex_upper::decode(argv[i], arglen) << std::endl; + } catch (const cppcodec::parse_error& e) { + std::cout << "#" << i << ": " << e.what() << std::endl; + } + } + return 0; +} diff --git a/src/third_party/cppcodec/tool/hexenc.cpp b/src/third_party/cppcodec/tool/hexenc.cpp new file mode 100644 index 0000000000..02486da233 --- /dev/null +++ b/src/third_party/cppcodec/tool/hexenc.cpp @@ -0,0 +1,41 @@ +/** + * Copyright (C) 2015 Topology LP + * All rights reserved. + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to + * deal in the Software without restriction, including without limitation the + * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or + * sell copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS + * IN THE SOFTWARE. + */ + +#include +#include + +#include +#include +#include + +int main(int argc, char *argv[]) +{ + for (int i = 1; i < argc; ++i) { + size_t arglen = strlen(argv[i]); + + std::cout << cppcodec::hex_lower::encode(argv[i], arglen) << std::endl; + std::cout << cppcodec::hex_upper::encode(argv[i], arglen) << std::endl; + } + return 0; +} + diff --git a/src/third_party/simple-beast-client/CMakeLists.txt b/src/third_party/simple-beast-client/CMakeLists.txt new file mode 100644 index 0000000000..e93b10aa28 --- /dev/null +++ b/src/third_party/simple-beast-client/CMakeLists.txt @@ -0,0 +1,29 @@ +cmake_minimum_required(VERSION 3.10) +project(simple-beast-client VERSION 0.0.1 LANGUAGES CXX) + +add_library(simple-beast-client INTERFACE) +find_package(Boost 1.66 REQUIRED COMPONENTS + date_time regex) +find_package(OpenSSL) +find_package(Threads) +find_package(cppcodec) +target_include_directories(simple-beast-client INTERFACE + $ + $ +) +target_compile_definitions(simple-beast-client INTERFACE + ENABLE_DIGEST + ENABLE_HTTPS) + +install(DIRECTORY include + DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}" + FILES_MATCHING PATTERN *.hpp) + +install(TARGETS simple-beast-client + EXPORT GennyLibraryConfig + ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR} + LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} + RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}) # This is for Windows + +# example program is useful for validating the library +#add_subdirectory(example) diff --git a/src/third_party/simple-beast-client/LICENSE b/src/third_party/simple-beast-client/LICENSE new file mode 100644 index 0000000000..ae94b56270 --- /dev/null +++ b/src/third_party/simple-beast-client/LICENSE @@ -0,0 +1,21 @@ +MIT License + +Copyright (c) 2018 David Webb + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. diff --git a/src/third_party/simple-beast-client/README.md b/src/third_party/simple-beast-client/README.md new file mode 100644 index 0000000000..52fb43d892 --- /dev/null +++ b/src/third_party/simple-beast-client/README.md @@ -0,0 +1 @@ +This directory is vendored from https://github.com/RAvenGEr/simple-beast-client/commit/47007fc96e2cf1334cf4ebc4da9e0def69c5acd4. diff --git a/src/third_party/simple-beast-client/cmake/Findcppcodec.cmake b/src/third_party/simple-beast-client/cmake/Findcppcodec.cmake new file mode 100644 index 0000000000..7c1b718db4 --- /dev/null +++ b/src/third_party/simple-beast-client/cmake/Findcppcodec.cmake @@ -0,0 +1,14 @@ +message(STATUS "${CMAKE_CURRENT_LIST_DIR}") +find_path(cppcodec_INCLUDE_DIRS "cppcodec/base32_crockford.hpp" + PATHS "${CMAKE_CURRENT_LIST_DIR}/../../cppcodec" # We allow taking the embedded cppcodec +) +mark_as_advanced(cppcodec_INCLUDE_DIRS) + +find_package_handle_standard_args(cppcodec + REQUIRED_VARS cppcodec_INCLUDE_DIRS +) + +if(cppcodec_FOUND) + add_library(cppcodec::cppcodec IMPORTED INTERFACE) + target_include_directories(cppcodec::cppcodec INTERFACE "${cppcodec_INCLUDE_DIRS}") +endif() diff --git a/src/third_party/simple-beast-client/cmake/modules/Findcppcodec.cmake b/src/third_party/simple-beast-client/cmake/modules/Findcppcodec.cmake new file mode 100644 index 0000000000..052d47747e --- /dev/null +++ b/src/third_party/simple-beast-client/cmake/modules/Findcppcodec.cmake @@ -0,0 +1,13 @@ +find_path(cppcodec_INCLUDE_DIRS "cppcodec/base32_crockford.hpp" + PATHS "${CMAKE_CURRENT_LIST_DIR}/../../cppcodec" # We allow taking the embedded cppcodec +) +mark_as_advanced(cppcodec_INCLUDE_DIRS) + +find_package_handle_standard_args(cppcodec + REQUIRED_VARS cppcodec_INCLUDE_DIRS +) + +if(cppcodec_FOUND) + add_library(cppcodec::cppcodec IMPORTED INTERFACE) + target_include_directories(cppcodec::cppcodec INTERFACE "${cppcodec_INCLUDE_DIRS}") +endif() diff --git a/src/third_party/simple-beast-client/cmake/public_modules/Findcppcodec.cmake b/src/third_party/simple-beast-client/cmake/public_modules/Findcppcodec.cmake new file mode 100644 index 0000000000..ea7a18b237 --- /dev/null +++ b/src/third_party/simple-beast-client/cmake/public_modules/Findcppcodec.cmake @@ -0,0 +1,11 @@ +find_path(cppcodec_INCLUDE_DIRS "cppcodec/base32_crockford.hpp") +mark_as_advanced(cppcodec_INCLUDE_DIRS) + +find_package_handle_standard_args(cppcodec + REQUIRED_VARS cppcodec_INCLUDE_DIRS +) + +if(cppcodec_FOUND) + add_library(cppcodec::cppcodec IMPORTED INTERFACE) + target_include_directories(cppcodec::cppcodec INTERFACE "${cppcodec_INCLUDE_DIRS}") +endif() diff --git a/src/third_party/simple-beast-client/cmake/simple-beast-client-config.cmake b/src/third_party/simple-beast-client/cmake/simple-beast-client-config.cmake new file mode 100644 index 0000000000..c310e97bf3 --- /dev/null +++ b/src/third_party/simple-beast-client/cmake/simple-beast-client-config.cmake @@ -0,0 +1,10 @@ +include(CMakeFindDependencyMacro) + +list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_LIST_DIR}/modules") + +find_dependency(Boost 1.66 REQUIRED COMPONENTS date_time regex system) +find_dependency(OpenSSL REQUIRED) +find_dependency(cppcodec REQUIRED) +find_dependency(Threads REQUIRED) + +include("${CMAKE_CURRENT_LIST_DIR}/simple-beast-client-targets.cmake") diff --git a/src/third_party/simple-beast-client/example/CMakeLists.txt b/src/third_party/simple-beast-client/example/CMakeLists.txt new file mode 100644 index 0000000000..cc94060bda --- /dev/null +++ b/src/third_party/simple-beast-client/example/CMakeLists.txt @@ -0,0 +1,22 @@ +add_executable(http-example main.cpp) + +find_package(Boost 1.66 REQUIRED COMPONENTS + date_time regex) +find_package(OpenSSL) +find_package(Threads) + +include_directories( ${Boost_INCLUDE_DIRS} + ${OPENSSL_INCLUDE_DIR} + ${cppcodec_INCLUDE_DIRS} +) + +if(WIN32 AND NOT (CMAKE_CXX_COMPILER_VERSION VERSION_LESS 19.0.23026.0)) + target_compile_options(http-example PRIVATE "/bigobj") +endif() + +target_link_libraries(http-example PRIVATE + simple-beast-client + ${CMAKE_THREAD_LIBS_INIT} + ${OPENSSL_LIBRARIES} + ${Boost_LIBRARIES} +) diff --git a/src/third_party/simple-beast-client/example/main.cpp b/src/third_party/simple-beast-client/example/main.cpp new file mode 100644 index 0000000000..c88423fd64 --- /dev/null +++ b/src/third_party/simple-beast-client/example/main.cpp @@ -0,0 +1,160 @@ +/* +* simple-beast-client example +*/ + +#include +#include +#include +#include + +int main(int /*argc*/, char* /*argv*/[]) +{ + std::cout << "Start up\n"; + + try { + boost::asio::io_context ioContext; + + // URL parsing validation tests. + simple_http::url test{"http://test.com/target"}; + simple_http::url test2{"www.test.com/target2"}; +#ifdef ENABLE_HTTPS + simple_http::url test3{"https://test.com"}; +#endif + simple_http::url test4{"test.com:80"}; + simple_http::url test5{"http://33.com:400/target"}; +#ifdef ENABLE_DIGEST + simple_http::url test6{"http://user:pass@33.com"}; + simple_http::url test7{"http://user:pass@33.com:400/target?val=1&val2=2"}; +#endif + simple_http::url test8{"user@example.com"}; + + assert(test.scheme() == "http"); + + assert(test2.host() == "www.test.com"); + assert(test2.path() == "/target2"); + +#ifdef ENABLE_HTTPS + assert(test3.scheme() == "https"); +#endif + + assert(test4.host() == "test.com"); + assert(test4.port() == "80"); + + assert(test5.host() == "33.com"); + assert(test5.port() == "400"); + +#ifdef ENABLE_DIGEST + assert(test6.scheme() == "http"); + assert(test6.username() == "user"); + assert(test6.password() == "pass"); + + assert(test7.port() == "400"); + assert(test7.path() == "/target"); + assert(test7.query() == "val=1&val2=2"); +#endif + + assert(test8.username() == "user"); + assert(test8.host() == "example.com"); + + simple_http::url testUserNameAndPassword{"https://user76:myP@55w0rd@example.com/path"}; + + assert(testUserNameAndPassword.scheme() == "https"); + assert(testUserNameAndPassword.username() == "user76"); + assert(testUserNameAndPassword.password() == "myP@55w0rd"); + assert(testUserNameAndPassword.host() == "example.com"); + assert(testUserNameAndPassword.path() == "/path"); + + // Test an invalid url string + simple_http::url broken{"?this"}; + + assert(!broken.valid()); + assert(broken.scheme().empty()); + assert(broken.host().empty()); + assert(broken.query().empty()); + + simple_http::url copy = testUserNameAndPassword; + + assert(copy.scheme() == testUserNameAndPassword.scheme()); + assert(copy.username() == testUserNameAndPassword.username()); + assert(copy.password() == testUserNameAndPassword.password()); + assert(copy.host() == testUserNameAndPassword.host()); + assert(copy.target() == testUserNameAndPassword.target()); + + simple_http::url by_parts{"example.com", "/path?query", "https", "8443", "user", "pass"}; + + assert(by_parts.scheme() == "https"); + assert(by_parts.username() == "user"); + assert(by_parts.password() == "pass"); + assert(by_parts.host() == "example.com"); + assert(by_parts.port() == "8443"); + assert(by_parts.path() == "/path"); + assert(by_parts.query() == "query"); + + copy = by_parts; + + assert(copy.scheme() == "https"); + assert(copy.username() == "user"); + assert(copy.password() == "pass"); + assert(copy.host() == "example.com"); + assert(copy.port() == "8443"); + assert(copy.path() == "/path"); + assert(copy.query() == "query"); + + std::cout << "simple_http::url tests complete\n"; + + // Run an asynchronous client test - connect with Digest Authentication + { + auto client = std::make_shared( + ioContext, + [](simple_http::empty_body_request& /*req*/, + simple_http::string_body_response& resp) { + // Display the response to the console. + std::cout << resp << '\n'; + }); + + // Run the GET request to httpbin.org + client->get(simple_http::url{ + "https://user:passwd@httpbin.org/digest-auth/auth/user/passwd/MD5/never"}); + } + + // Run another asynchronous client test - redirection and HTTPS connect. + // This example shows the boost::beast request and response template classes. + { + auto client = std::make_shared( + ioContext, + [](boost::beast::http::request& /*req*/, + boost::beast::http::response& resp) { + std::cout << resp << '\n'; + }); + client->setFailHandler([](const simple_http::empty_body_request& /*req*/, + const simple_http::string_body_response& /*resp*/, + simple_http::fail_reason /*fr*/, boost::string_view message) { + std::cout << message << '\n'; + }); + // Connect to a url that redirects through a 301 response. + // The 1 argument is the number of redirects to follow. + client->get( + simple_http::url{ + "http://httpbin.org/redirect-to?url=https%3A%2F%2Fhttpbin.org&status_code=301"}, + 1); + } + + // Run a POST client test + { + auto client = std::make_shared( + ioContext, + [](simple_http::string_body_request& /*req*/, + simple_http::string_body_response& resp) { std::cout << resp << '\n'; }); + + client->post(simple_http::url{"http://httpbin.org/post"}, "username=RAvenGEr", + "application/x-www-form-urlencoded"); + } + + // Run the until requests are complete. + ioContext.run(); + } catch (std::exception& e) { + std::cerr << "exception: " << e.what() << "\n"; + } + + return 0; +} diff --git a/src/third_party/simple-beast-client/include/simple-beast-client/client_private.hpp b/src/third_party/simple-beast-client/include/simple-beast-client/client_private.hpp new file mode 100644 index 0000000000..a8e9de9859 --- /dev/null +++ b/src/third_party/simple-beast-client/include/simple-beast-client/client_private.hpp @@ -0,0 +1,367 @@ +#ifndef CLIENT_PRIVATE_HPP +#define CLIENT_PRIVATE_HPP + +#include "url.hpp" +#include +#include +#include +#include +#include +#include +#include // Used for basic authentication. +#include +#include +#include +#include +#include + +#if defined(ENABLE_HTTPS) || defined(ENABLE_DIGEST) +#ifndef ENABLE_DIGEST +#define ENABLE_DIGEST +#endif +#include "digestauthenticator.hpp" +#endif + +namespace simple_http { + +enum client_state +{ + Resolve, + Connect, + Handshake, + RequestSend, + Header, + Contents, + Complete +}; + +enum fail_reason +{ + Unknown, + FormatError, + ResolveError, + ConnectionError, + HandshakeError, + Timeout, + WriteError, + ReadError +}; + +using empty_body_request = boost::beast::http::request; +using string_body_request = boost::beast::http::request; +using empty_body_response = boost::beast::http::response; +using string_body_response = boost::beast::http::response; + +template +class client_private_http; + +template +class client_private_ssl; + +template +class basic_client; + +template +class client_private +{ + using ResponseParser = boost::beast::http::response_parser; + using HttpPrivate = client_private_http; + using SslPrivate = client_private_ssl; + using BodyValue = typename RequestBody::value_type; + +public: + static std::shared_ptr> privateForRequest( + const url& uri, std::shared_ptr> cl) + { + if (uri.scheme() == url::SchemeHttp()) { + return std::make_shared(cl->m_io, cl); + } +#ifdef ENABLE_HTTPS + if (uri.scheme() == url::SchemeHttps()) { + return std::make_shared(cl->m_io, cl); + } +#endif + cl->failure(FormatError, "Error unsupported scheme."); + return nullptr; + } + + void performRequest(const url& uri, boost::beast::http::verb method, BodyValue requestBody, + boost::string_view contentType, int maxRedirects, bool basicAuth, + int version) + { + c->m_maxRedirects = maxRedirects; + m_url = uri; + m_request.version(version); + m_request.method(method); + m_request.target(m_url.target()); + m_request.set(boost::beast::http::field::host, m_url.host()); + m_request.set(boost::beast::http::field::user_agent, c->userAgent()); + if (!contentType.empty()) { + m_request.set(boost::beast::http::field::content_type, contentType); + } + if (method == boost::beast::http::verb::post) { + m_request.body() = requestBody; + m_request.prepare_payload(); + } + if (basicAuth) { + generateBasicAuthentication(); + } + startTimeout(); + startResolve(); + } + + void abort() + { + boost::system::error_code ec; + c->m_state = Complete; + m_timeout.cancel(); + closeSocket(ec); + if (c->m_responseHandler) { + c->m_responseHandler = nullptr; + } + if (c->m_failHandler) { + c->m_failHandler = nullptr; + } + // not_connected happens sometimes so don't bother reporting it. + if (ec && ec != boost::system::errc::not_connected) { + c->failure(Unknown, "Unexpected Error: " + ec.message()); + } + } + +protected: + explicit client_private(boost::asio::io_context& io, + std::shared_ptr> cl) + : c{cl}, m_resolver{io}, m_timeout{io} + {} + + virtual ~client_private() {} + + void startTimeout() + { + m_timeout.expires_from_now(boost::posix_time::milliseconds{c->m_timeoutMs}); + m_timeout.async_wait( + std::bind(&client_private::checkTimeout, shared_from_this(), std::placeholders::_1)); + } + + void checkTimeout(const boost::system::error_code& ec) + { + if (!ec) { + std::string stateString; + switch (c->m_state) { + case Resolve: + stateString = "resolve"; + break; + case Connect: + stateString = "connect"; + break; + case Handshake: + stateString = "handshake"; + break; + case RequestSend: + stateString = "request"; + break; + case Header: + stateString = "header"; + break; + case Contents: + stateString = "contents"; + break; + case Complete: + return; + } + c->failure(Timeout, "Transfer timeout during " + stateString); + abort(); + } else if (ec != boost::asio::error::operation_aborted) { + fail(Timeout, "Transfer timer error: " + ec.message()); + } + } + + void resetTimeout(client_state state) + { + c->m_state = state; + auto self(shared_from_this()); + m_timeout.expires_from_now(boost::posix_time::milliseconds{c->m_timeoutMs}); + } + + void startResolve() + { + resetTimeout(Resolve); + m_resolver.async_resolve(m_url.host().to_string(), m_url.port().to_string(), + std::bind(&client_private::onResolve, shared_from_this(), + std::placeholders::_1, std::placeholders::_2)); + } + + void onResolve(boost::system::error_code ec, + boost::asio::ip::tcp::resolver::results_type results) + { + if (ec) { + fail(ResolveError, "Error resolving target: " + ec.message()); + return; + } + m_resolveResults = results; + connectSocket(); + } + + void onConnect(boost::system::error_code ec) + { + if (ec) { + fail(ConnectionError, "Error connecting: " + ec.message()); + return; + } + sendRequest(); + } + + void clearResponse() + { + m_responseParser.~ResponseParser(); + new (&m_responseParser) ResponseParser{}; + } + + void onWrite(boost::system::error_code ec, std::size_t bytes_transferred) + { + boost::ignore_unused(bytes_transferred); + if (ec) { + fail(WriteError, "Error writing request: " + ec.message()); + return; + } + initiateReadHeader(); + } + + void onReadHeader(boost::system::error_code ec, std::size_t bytes_transferred) + { + boost::ignore_unused(bytes_transferred); + if (ec) { + // Error during read of header. + fail(ReadError, "Error in response header: " + ec.message()); + return; + } + initiateRead(); + } + + void onRead(boost::system::error_code ec, std::size_t bytes_transferred) + { + boost::ignore_unused(bytes_transferred); + if (ec) { + fail(ReadError, "Error reading response: " + ec.message()); + return; + } + m_timeout.cancel(); // Finished with connection before this point. + if (handle()) { + abort(); // This gracefully closes the client connection. + } + } + + bool handle() + { + const std::set redirectCodes{ + boost::beast::http::status::moved_permanently, boost::beast::http::status::found, + boost::beast::http::status::temporary_redirect}; + if (m_responseParser.get().result() == boost::beast::http::status::unauthorized) { + if (generateAuthentication( + m_responseParser.get()[boost::beast::http::field::www_authenticate])) { + // Request again with authentication! + if (m_responseParser.keep_alive()) { + sendRequest(); + } else { + connectSocket(); + } + return false; + } + } else if (c->m_maxRedirects > 0 && redirectCodes.count(m_responseParser.get().result())) { + // follow redirect. + url newLocation{m_responseParser.get()[boost::beast::http::field::location]}; + if (newLocation.host() == m_url.host() && newLocation.port() == m_url.port()) { + m_url = std::move(newLocation); + if (m_responseParser.keep_alive()) { + sendRequest(); + } else { + connectSocket(); + } + } else { + // Request is for a new server + c->performRequest(std::move(newLocation), m_request.method(), m_request.body(), + m_request[boost::beast::http::field::content_type], + c->m_maxRedirects - 1, c->m_basicAuthForce, m_request.version()); + } + return false; + } + try { + c->m_responseHandler(m_request, m_responseParser.get()); + } catch (std::bad_function_call& /*f*/) { + // Discard silently. + } + return true; + } + + void fail(fail_reason reason, boost::string_view message) + { + try { + c->m_failHandler(m_request, m_responseParser.get(), reason, message); + } catch (std::bad_function_call& /*f*/) { + // Discard silently. + } + abort(); + } + + bool generateAuthentication(boost::string_view authenticate) + { + if (c->m_username.empty() || c->m_password.empty() || + !m_request[boost::beast::http::field::authorization].empty()) { + return false; + } + if (boost::ifind_first(authenticate, "digest")) { +#ifdef ENABLE_DIGEST + return generateDigestAuth(authenticate, boost::string_view()); +#else + return false; +#endif + } else { + generateBasicAuthentication(); + return true; + } + } + + void generateBasicAuthentication() + { + std::string credentials{c->m_username}; + credentials += ":" + c->m_password; + m_request.set(boost::beast::http::field::authorization, + "Basic " + base64::encode(credentials)); + } + +#ifdef ENABLE_DIGEST + bool generateDigestAuth(boost::string_view authenticate, boost::string_view body) + { + digest_authenticator authenticator(authenticate, c->m_username, c->m_password, + m_request.target(), to_string(m_request.method()), body); + if (authenticator.generateAuthorization()) { + m_request.set(boost::beast::http::field::authorization, authenticator.authorization()); + return true; + } + return false; + } +#endif + + virtual void connectSocket() = 0; + virtual void sendRequest() = 0; + virtual void initiateReadHeader() = 0; + virtual void initiateRead() = 0; + virtual void closeSocket(boost::system::error_code& ec) = 0; + + boost::beast::flat_buffer m_buffer; + ResponseParser m_responseParser; + boost::beast::http::request m_request; + boost::asio::ip::tcp::resolver::results_type m_resolveResults; + std::shared_ptr> c; + +private: + virtual std::shared_ptr shared_from_this() = 0; + + boost::asio::ip::tcp::resolver m_resolver; + boost::asio::deadline_timer m_timeout; + url m_url; +}; + +} // namespace simple_http + +#endif // CLIENT_PRIVATE_HPP diff --git a/src/third_party/simple-beast-client/include/simple-beast-client/client_private_http.hpp b/src/third_party/simple-beast-client/include/simple-beast-client/client_private_http.hpp new file mode 100644 index 0000000000..950b86191e --- /dev/null +++ b/src/third_party/simple-beast-client/include/simple-beast-client/client_private_http.hpp @@ -0,0 +1,87 @@ +#ifndef CLIENT_PRIVATE_HTTP_HPP +#define CLIENT_PRIVATE_HTTP_HPP + +#include "client_private.hpp" +#include +#include +#include + +namespace simple_http { + +template +class basic_client; + +template +class client_private_http + : public client_private + , public std::enable_shared_from_this> +{ +public: + explicit client_private_http(boost::asio::io_context& io, + std::shared_ptr> c) + : client_private{io, c}, m_socket{io} + {} + +private: + boost::asio::ip::tcp::socket m_socket; + + std::shared_ptr> shared_from_this() override + { + return std::enable_shared_from_this< + client_private_http>::shared_from_this(); + } + + std::shared_ptr> self() + { + return std::enable_shared_from_this< + client_private_http>::shared_from_this(); + } + + void connectSocket() + { + this->resetTimeout(Connect); + boost::asio::async_connect( + m_socket, this->m_resolveResults.begin(), this->m_resolveResults.end(), + std::bind(&client_private_http::onConnect, self(), + std::placeholders::_1)); + } + + void sendRequest() + { + this->resetTimeout(RequestSend); + this->clearResponse(); + boost::beast::http::async_write( + m_socket, this->m_request, + std::bind(&client_private_http::onWrite, self(), + std::placeholders::_1, std::placeholders::_2)); + } + + void initiateReadHeader() + { + this->resetTimeout(Header); + // Receive the HTTP response header + boost::beast::http::async_read_header( + m_socket, this->m_buffer, this->m_responseParser, + std::bind(&client_private_http::onReadHeader, self(), + std::placeholders::_1, std::placeholders::_2)); + } + + void initiateRead() + { + this->resetTimeout(Contents); + // Receive the HTTP response + boost::beast::http::async_read( + m_socket, this->m_buffer, this->m_responseParser, + std::bind(&client_private_http::onRead, self(), + std::placeholders::_1, std::placeholders::_2)); + } + + void closeSocket(boost::system::error_code& ec) + { + m_socket.shutdown(boost::asio::ip::tcp::socket::shutdown_both, ec); + } +}; + +} // namespace simple_http + +#endif // CLIENT_PRIVATE_HTTP_HPP diff --git a/src/third_party/simple-beast-client/include/simple-beast-client/client_private_ssl.hpp b/src/third_party/simple-beast-client/include/simple-beast-client/client_private_ssl.hpp new file mode 100644 index 0000000000..c48761385d --- /dev/null +++ b/src/third_party/simple-beast-client/include/simple-beast-client/client_private_ssl.hpp @@ -0,0 +1,177 @@ +#ifndef CLIENT_PRIVATE_SSL_HPP +#define CLIENT_PRIVATE_SSL_HPP + +#include "client_private.hpp" +#include +#include +#include +#include +#if BOOST_OS_WINDOWS +#include +#endif + +namespace simple_http { + +template +class basic_client; + +class SslContextManager +{ +public: + SslContextManager() + { + namespace ssl = boost::asio::ssl; + m_ctx.set_options(ssl::context::default_workarounds | ssl::context::no_sslv2 | + ssl::context::no_sslv3 | ssl::context::tlsv12_client); +#if BOOST_OS_WINDOWS + addWindowsRootCerts(); +#else + m_ctx.set_default_verify_paths(); +#endif + } + + auto& ctx() { return m_ctx; } + +private: +#if BOOST_OS_WINDOWS + void addWindowsRootCerts() + { + HCERTSTORE hStore = CertOpenSystemStoreA(0, "ROOT"); + if (hStore == NULL) { + return; + } + + X509_STORE* store = X509_STORE_new(); + PCCERT_CONTEXT pContext = NULL; + while ((pContext = CertEnumCertificatesInStore(hStore, pContext)) != NULL) { + X509* x509 = d2i_X509(NULL, (const unsigned char**)&pContext->pbCertEncoded, + pContext->cbCertEncoded); + if (x509 != NULL) { + X509_STORE_add_cert(store, x509); + X509_free(x509); + } + } + + CertFreeCertificateContext(pContext); + CertCloseStore(hStore, 0); + + SSL_CTX_set_cert_store(m_ctx.native_handle(), store); + } +#endif + + boost::asio::ssl::context m_ctx{boost::asio::ssl::context::tlsv12_client}; +}; + +inline boost::asio::ssl::context& ssl_context_g() +{ + static SslContextManager s{}; + return s.ctx(); +} + +template +class client_private_ssl + : public client_private + , public std::enable_shared_from_this> +{ +public: + explicit client_private_ssl(boost::asio::io_context& io, + std::shared_ptr> cl) + : client_private{io, cl}, m_stream{io, ssl_context_g()} + {} + +private: + boost::asio::ssl::stream m_stream; + + std::shared_ptr> shared_from_this() + { + return std::enable_shared_from_this< + client_private_ssl>::shared_from_this(); + } + + std::shared_ptr> self() + { + return std::enable_shared_from_this< + client_private_ssl>::shared_from_this(); + } + + void connectSocket() + { + this->resetTimeout(Connect); + boost::asio::async_connect( + m_stream.next_layer(), this->m_resolveResults.begin(), this->m_resolveResults.end(), + std::bind(&client_private_ssl::onSslConnect, self(), + std::placeholders::_1)); + } + + void onSslConnect(boost::system::error_code ec) + { + if (ec) { + this->fail(ConnectionError, "Error connecting: " + ec.message()); + return; + } + // Perform the SSL handshake + m_stream.async_handshake( + boost::asio::ssl::stream_base::client, + std::bind(&client_private_ssl::onHandshake, self(), + std::placeholders::_1)); + } + + void onHandshake(boost::system::error_code ec) + { + if (ec) { + this->fail(HandshakeError, "Error during handshake: " + ec.message()); + return; + } + sendRequest(); + } + + void sendRequest() + { + this->resetTimeout(RequestSend); + this->clearResponse(); + // Send the HTTP request to the remote host + boost::beast::http::async_write( + m_stream, this->m_request, + std::bind(&client_private_ssl::onWrite, self(), + std::placeholders::_1, std::placeholders::_2)); + } + + void initiateReadHeader() + { + this->resetTimeout(Header); + // Receive the HTTP response + boost::beast::http::async_read_header( + m_stream, this->m_buffer, this->m_responseParser, + std::bind(&client_private_ssl::onReadHeader, self(), + std::placeholders::_1, std::placeholders::_2)); + } + + void initiateRead() + { + this->resetTimeout(Contents); + // Receive the HTTP response + boost::beast::http::async_read( + m_stream, this->m_buffer, this->m_responseParser, + std::bind(&client_private_ssl::onRead, self(), + std::placeholders::_1, std::placeholders::_2)); + } + + void closeSocket(boost::system::error_code& ec) + { + // Gracefully close the stream + m_stream.async_shutdown( + std::bind(&client_private_ssl::onShutdown, self(), std::placeholders::_1)); + } + + void onShutdown(boost::system::error_code ec) + { + if (ec && ec != boost::asio::error::eof) { + this->c->failure(Unknown, "Unexpected error on shutdown: " + ec.message()); + } + // If we get here then the connection is closed gracefully + } +}; + +} // namespace simple_http + +#endif // CLIENT_PRIVATE_SSL_HPP diff --git a/src/third_party/simple-beast-client/include/simple-beast-client/digestauthenticator.hpp b/src/third_party/simple-beast-client/include/simple-beast-client/digestauthenticator.hpp new file mode 100644 index 0000000000..cb3bb0ad56 --- /dev/null +++ b/src/third_party/simple-beast-client/include/simple-beast-client/digestauthenticator.hpp @@ -0,0 +1,244 @@ +#ifndef DIGESTAUTHENTICATOR_H +#define DIGESTAUTHENTICATOR_H + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +namespace simple_http { + +class digest_authenticator +{ +public: + digest_authenticator(boost::string_view www_authenticate, boost::string_view username, + boost::string_view password, boost::string_view uri, + boost::string_view method, boost::string_view responseBody) noexcept + : m_authenticate{www_authenticate} + , m_username{username} + , m_password{password} + , m_uri{uri} + , m_method{method} + , m_body{responseBody} + , m_qop{None} + {} + + bool generateAuthorization() + { + // Nonce and realm are both required for digest athentication. + if (!findNonce() || !findRealm()) { + return false; + } + findOpaque(); + findQop(); + findAlgorithm(); + m_cnonce = generateNonce(); + m_nonceCount = updateNonceCount(); + MD5_hash ha1; + calculateHA1(ha1); + m_ha1 = hex::encode(ha1, sizeof(ha1)); + MD5_hash ha2; + calculateHA2(ha2); + m_ha2 = hex::encode(ha2, sizeof(ha2)); + MD5_hash response; + calculateResponse(response); + m_response = hex::encode(response, sizeof(response)); + m_authorization = "Digest username=\""; + m_authorization.reserve(128 + m_username.size() + m_realm.size() + m_nonce.size() + + m_uri.size() + m_nonceCount.size() + m_cnonce.size() + + m_response.size() + m_opaque.size()); + m_authorization.append(m_username.to_string()); + m_authorization.append("\", realm=\""); + m_authorization.append(m_realm.to_string()); + m_authorization.append("\", nonce=\""); + m_authorization.append(m_nonce.to_string()); + m_authorization.append("\", uri=\""); + m_authorization.append(m_uri.to_string()); + m_authorization.append("\", qop="); + m_authorization.append(m_qop == AuthInt ? "auth-int" : "auth"); + m_authorization.append(", algorithm=MD5, nc="); + m_authorization.append(m_nonceCount); + m_authorization.append(", cnonce=\""); + m_authorization.append(m_cnonce); + m_authorization.append("\", response=\""); + m_authorization.append(m_response); + if (!m_opaque.empty()) { + m_authorization.append("\", opaque=\""); + m_authorization.append(m_opaque.to_string()); + } + m_authorization.append("\""); + return true; + } + + std::string authorization() const noexcept { return m_authorization; } + + static std::string generateNonce() + { + std::random_device rd; + std::uniform_int_distribution length{8, 32}; + std::uniform_int_distribution distNum{0, 15}; + + std::string nonce; + nonce.resize(length(rd)); + constexpr char hex[16]{'0', '1', '2', '3', '4', '5', '6', '7', + '8', '9', 'a', 'b', 'c', 'd', 'e', 'f'}; + for (char& val : nonce) { + val = hex[distNum(rd)]; + } + return nonce; + } + +private: + enum QualityOfProtection + { + None, + Auth, + AuthInt + }; + + using MD5_hash = unsigned char[MD5_DIGEST_LENGTH]; + + static std::string updateNonceCount() + { + static unsigned int s_nonceCount{}; + return std::to_string(++s_nonceCount); + } + + bool findNonce() { return findSection("nonce", m_nonce); } + + bool findRealm() { return findSection("realm", m_realm); } + + bool findOpaque() { return findSection("opaque", m_opaque); } + + bool findAlgorithm() { return findSection("algorithm", m_algorithm); } + + bool findQop() + { + boost::string_view qop; + if (findSection("qop", qop)) { + // auth-int only with response body - working with tested implementations + if (boost::iequals(qop, "auth-int") && !m_body.empty()) { + m_qop = AuthInt; + } else { + m_qop = Auth; + } + } + return false; + } + + bool findSection(const std::string& key, boost::string_view& value) const + { + boost::regex reg{key + "=([^,]+)"}; + auto start = m_authenticate.cbegin(); + auto end = m_authenticate.cend(); + boost::match_results matches; + boost::match_flag_type flags = boost::match_default; + if (boost::regex_search(start, end, matches, reg, flags)) { + size_t size = static_cast(std::distance(matches[1].first, matches[1].second)); + start = matches[1].first; + end = matches[1].second - 1; + // Trim quotes if they are there. + if (*start == '"') { + ++start; + --size; + } + if (*end == '"') { + --size; + } + value = boost::string_view(start, size); + return true; + } + return false; + } + + void calculateHA1(MD5_hash ha1) noexcept + { + MD5_CTX Md5Ctx; + MD5_Init(&Md5Ctx); + MD5_Update(&Md5Ctx, m_username.data(), m_username.size()); + MD5_Update(&Md5Ctx, ":", 1); + MD5_Update(&Md5Ctx, m_realm.data(), m_realm.size()); + MD5_Update(&Md5Ctx, ":", 1); + MD5_Update(&Md5Ctx, m_password.data(), m_password.size()); + MD5_Final(ha1, &Md5Ctx); + if (boost::iequals(m_algorithm, "md5-sess")) { + MD5_Init(&Md5Ctx); + MD5_Update(&Md5Ctx, ha1, MD5_DIGEST_LENGTH); + MD5_Update(&Md5Ctx, ":", 1); + MD5_Update(&Md5Ctx, m_nonce.data(), m_nonce.size()); + MD5_Update(&Md5Ctx, ":", 1); + MD5_Update(&Md5Ctx, m_cnonce.data(), m_cnonce.size()); + MD5_Final(ha1, &Md5Ctx); + }; + } + + void calculateHA2(MD5_hash ha2) noexcept + { + MD5_CTX Md5Ctx; + + // calculate H(A2) + MD5_Init(&Md5Ctx); + MD5_Update(&Md5Ctx, m_method.data(), m_method.size()); + MD5_Update(&Md5Ctx, ":", 1); + MD5_Update(&Md5Ctx, m_uri.data(), m_uri.size()); + if (m_qop == AuthInt) { + MD5_Update(&Md5Ctx, ":", 1); + MD5_Update(&Md5Ctx, m_body.data(), m_body.size()); + }; + MD5_Final(ha2, &Md5Ctx); + } + + void calculateResponse(MD5_hash result) noexcept + { + MD5_CTX Md5Ctx; + // calculate response + MD5_Init(&Md5Ctx); + MD5_Update(&Md5Ctx, m_ha1.data(), m_ha1.size()); + MD5_Update(&Md5Ctx, ":", 1); + MD5_Update(&Md5Ctx, m_nonce.data(), m_nonce.size()); + MD5_Update(&Md5Ctx, ":", 1); + if (m_qop != None) { + MD5_Update(&Md5Ctx, m_nonceCount.data(), m_nonceCount.size()); + MD5_Update(&Md5Ctx, ":", 1); + MD5_Update(&Md5Ctx, m_cnonce.data(), m_cnonce.size()); + MD5_Update(&Md5Ctx, ":", 1); + if (m_qop == AuthInt) { + MD5_Update(&Md5Ctx, "auth-int", 8); + } else { + MD5_Update(&Md5Ctx, "auth", 4); + } + MD5_Update(&Md5Ctx, ":", 1); + }; + MD5_Update(&Md5Ctx, m_ha2.data(), m_ha2.size()); + MD5_Final(result, &Md5Ctx); + } + + boost::string_view m_authenticate; + boost::string_view m_username; + boost::string_view m_password; + boost::string_view m_realm; + boost::string_view m_nonce; + boost::string_view m_opaque; + boost::string_view m_algorithm; + boost::string_view m_uri; + boost::string_view m_method; + boost::string_view m_body; + + QualityOfProtection m_qop; + std::string m_cnonce; + std::string m_nonceCount; + std::string m_ha1; + std::string m_ha2; + std::string m_response; + std::string m_authorization; +}; + +} // namespace simple_http + +#endif // DIGESTAUTHENTICATOR_H diff --git a/src/third_party/simple-beast-client/include/simple-beast-client/httpclient.hpp b/src/third_party/simple-beast-client/include/simple-beast-client/httpclient.hpp new file mode 100644 index 0000000000..8409988809 --- /dev/null +++ b/src/third_party/simple-beast-client/include/simple-beast-client/httpclient.hpp @@ -0,0 +1,147 @@ +#ifndef SIMPLE_HTTPCLIENT_HPP +#define SIMPLE_HTTPCLIENT_HPP + +#include "client_private.hpp" +#include "client_private_http.hpp" +#include "url.hpp" +#include +#include +#include +#include +#include +#ifdef ENABLE_HTTPS +#include "client_private_ssl.hpp" +#endif + +namespace simple_http { + +/** + * @brief The simple_client class a client for HTTP + */ +template +class basic_client : public std::enable_shared_from_this> +{ +public: + explicit constexpr basic_client(boost::asio::io_context& io, int timeoutMs = 3000) noexcept + : m_io{io}, m_timeoutMs{timeoutMs}, m_state{Resolve} + {} + + explicit basic_client(boost::asio::io_context& io, + std::function&, + boost::beast::http::response&)> + responseHandler, + int timeoutMs = 3000) + : m_io{io}, m_responseHandler{responseHandler}, m_timeoutMs{timeoutMs} + {} + + void get(const url& uri, int maxRedirects = 0, bool basicAuth = false, int version = 11) + { + performRequest(uri, boost::beast::http::verb::get, typename RequestBody::value_type{}, + boost::string_view{}, maxRedirects, basicAuth, version); + } + + void post(const url& uri, typename RequestBody::value_type requestBody, + boost::string_view contentType, int maxRedirects = 0, bool basicAuth = false, + int version = 11) + { + performRequest(uri, boost::beast::http::verb::post, requestBody, contentType, + maxRedirects, basicAuth, version); + } + + void performRequest(const url& uri, boost::beast::http::verb method, int maxRedirects = 0, + bool basicAuth = false, int version = 11) + { + performRequest(uri, method, typename RequestBody::value_type{}, boost::string_view{}, + maxRedirects, basicAuth, version); + } + + void performRequest(const url& uri, boost::beast::http::verb method, + typename RequestBody::value_type requestBody, + boost::string_view contentType, int maxRedirects = 0, + bool basicAuth = false, int version = 11) + { + if (uri.hasAuthentication() && (m_username.empty() || m_password.empty())) { + setAuthorization(uri.username(), uri.password(), basicAuth); + } + std::shared_ptr> httpclient = + client_private::privateForRequest(uri, + this->shared_from_this()); + if (httpclient) { + httpclient->performRequest(uri, method, requestBody, contentType, maxRedirects, + basicAuth, version); + m_p = httpclient; + } + } + + void setAuthorization(boost::string_view username, boost::string_view password, + bool forceBasic = false) noexcept + { + m_basicAuthForce = forceBasic; + m_username = username.to_string(); + m_password = password.to_string(); + } + + void abort() + { + if (auto cl = m_p.lock()) { + cl->abort(); + } + } + + void setResponseHandler(std::function&, + boost::beast::http::response&)> + responseHandler) noexcept + { + m_responseHandler = responseHandler; + } + + void setFailHandler(std::function&, + const boost::beast::http::response&, + fail_reason, boost::string_view)> + failHandler) noexcept + { + m_failHandler = failHandler; + } + + client_state state() const noexcept { return m_state; } + +private: + boost::asio::io_context& m_io; + std::string m_username; + std::string m_password; + int m_maxRedirects; + int m_timeoutMs; + bool m_basicAuthForce; + + std::function&, + boost::beast::http::response&)> + m_responseHandler; + std::function&, + const boost::beast::http::response&, fail_reason, + boost::string_view)> + m_failHandler; + client_state m_state; + + boost::string_view userAgent() const noexcept { return "simple-beast-client/1.2"; } + + void failure(fail_reason reason, boost::string_view message) + { + const boost::beast::http::request req{}; + const boost::beast::http::response resp{}; + if (m_failHandler) { + m_failHandler(req, resp, reason, message); + } + } + + std::weak_ptr> m_p; + + friend class client_private; + friend class client_private_ssl; +}; + +typedef basic_client get_client; +typedef basic_client post_client; + +} // namespace simple_http + +#endif // SIMPLE_HTTPCLIENT_HPP diff --git a/src/third_party/simple-beast-client/include/simple-beast-client/url.hpp b/src/third_party/simple-beast-client/include/simple-beast-client/url.hpp new file mode 100644 index 0000000000..b63c6ced10 --- /dev/null +++ b/src/third_party/simple-beast-client/include/simple-beast-client/url.hpp @@ -0,0 +1,294 @@ +#ifndef URL_HPP +#define URL_HPP + +#include +#include + +#include +#include +#include + +namespace simple_http { + +/** + * @brief The url class a representation of an HTTP url with defaults for port and scheme + */ +class url +{ + static auto view_start(const std::string& representation, const boost::string_view& view) + { + return view.empty() ? 0 : std::distance(representation.data(), begin(view)); + } + +public: + static constexpr boost::string_view SchemeHttp() { return "http"; } + static constexpr boost::string_view SchemeHttps() { return "https"; } + static constexpr boost::string_view SchemeFtp() { return "ftp"; } + + url() noexcept = default; + + url(boost::string_view url) : m_representation{url.to_string()} { parseRepresentation(); } + + url(boost::string_view host, boost::string_view target, + boost::string_view scheme = boost::string_view{}, + boost::string_view port = boost::string_view{}, + boost::string_view username = boost::string_view{}, + boost::string_view password = boost::string_view{}) + { + size_t host_off{}; + size_t port_off{}; + size_t username_off{}; + size_t password_off{}; + size_t target_off{}; + m_representation.reserve(host.length() + scheme.length() + port.length() + + username.length() + password.length() + 6); + if (!scheme.empty()) { + m_representation = scheme.to_string(); + m_representation += "://"; + } + if (!username.empty()) { + username_off = m_representation.length(); + m_representation += username.to_string(); + if (!password.empty()) { + m_representation += ':'; + password_off = m_representation.length(); + m_representation += password.to_string(); + m_representation += '@'; + } + } + host_off = m_representation.length(); + m_representation += host.to_string(); + if (!port.empty()) { + m_representation += ':'; + port_off = m_representation.length(); + m_representation += port.to_string(); + } + target_off = m_representation.length(); + m_representation += target.to_string(); + m_host = boost::string_view{m_representation.data() + host_off, host.length()}; + m_target = boost::string_view{m_representation.data() + target_off, target.length()}; + if (!scheme.empty()) { + m_scheme = boost::string_view{m_representation.data(), scheme.length()}; + } + if (!username.empty()) { + m_username = + boost::string_view{m_representation.data() + username_off, username.length()}; + if (password_off > 0) { + m_password = + boost::string_view{m_representation.data() + password_off, password.length()}; + } + } + if (!port.empty()) { + m_port = boost::string_view{m_representation.data() + port_off, port.length()}; + } + const auto sep = m_target.find('?'); + if (sep != m_target.npos) { + size_t query_off = target_off + sep + 1; + m_path = boost::string_view{m_representation.data() + target_off, sep}; + m_query = + boost::string_view{m_representation.data() + query_off, target.length() - sep - 1}; + } else { + m_path = m_target; + } + } + + url(const url& other) noexcept : m_representation{other.m_representation} + { + viewsFromOther(other); + } + + url(url&& other) noexcept { *this = std::move(other); } + + url& operator=(boost::string_view url) + { + m_representation = url.to_string(); + parseRepresentation(); + return *this; + } + + url& operator=(const url& other) + { + m_representation = other.m_representation; + viewsFromOther(other); + return *this; + } + + url& operator=(url&& other) noexcept + { + m_representation = other.m_representation; + viewsFromOther(other); + return *this; + } + + bool valid() const noexcept + { + // Minimum is just a hostname + return !m_host.empty(); + } + + boost::string_view scheme() const + { + if (m_scheme.empty() && valid()) { + return SchemeHttp(); + } + return m_scheme; + } + + boost::string_view host() const { return m_host; } + + boost::string_view port() const + { + if (m_port.empty() && valid()) { + return m_scheme == SchemeHttps() + ? DefaultHttpsPort() + : m_scheme == SchemeFtp() ? DefaultFtpPort() : DefaultHttpPort(); + } + return m_port; + } + + boost::string_view username() const { return m_username; } + + boost::string_view password() const { return m_password; } + + boost::string_view target() const + { + if (m_target.empty() && valid()) { + return DefaultTarget(); + } + return m_target; + } + + boost::string_view path() const { return m_path; } + + boost::string_view query() const { return m_query; } + + bool hasAuthentication() const { return !m_username.empty() && !m_password.empty(); } + + void setUsername(boost::string_view username) { m_username = username; } + + void setPassword(boost::string_view password) { m_password = password; } + + void setScheme(boost::string_view scheme) { m_scheme = scheme; } + +private: + static constexpr boost::string_view DefaultTarget() { return "/"; } + static constexpr boost::string_view DefaultScheme() { return SchemeHttp(); }; + static constexpr boost::string_view DefaultHttpPort() { return "80"; } + static constexpr boost::string_view DefaultHttpsPort() { return "443"; } + static constexpr boost::string_view DefaultFtpPort() { return "21"; } + + void parseRepresentation() + { + constexpr size_t SchemeLoc{2}; + constexpr size_t UserLoc{4}; + constexpr size_t PassLoc{6}; + constexpr size_t HostLoc{7}; + constexpr size_t PortLoc{9}; + constexpr size_t TargetLoc{10}; + constexpr size_t PathLoc{11}; + constexpr size_t QueryLoc{14}; + + static const boost::regex http_reg( + "^((https?|ftp):\\/\\/)?" // scheme + "(([^\\s$.?#].?[^\\s\\/:]*)(:([^\\s$.?#].?[^\\s\\/]*))?@)?" // auth + "([^\\s$.?#].[^\\s\\/:]+)" // host + "(:([0-9]+))?" // port + "(([^\\s?#]*)?(([\\?#])([^\\s]*))?)?$"); // target (path?query) + boost::string_view represent{m_representation}; + auto start = represent.cbegin(); + auto end = represent.cend(); + boost::match_results matches; + boost::match_flag_type flags = boost::match_default; + if (boost::regex_match(start, end, matches, http_reg, flags)) { + boost::string_view::size_type size = static_cast( + std::distance(matches[SchemeLoc].first, matches[SchemeLoc].second)); + m_scheme = boost::string_view{matches[SchemeLoc].first, size}; + size = static_cast( + std::distance(matches[UserLoc].first, matches[UserLoc].second)); + m_username = boost::string_view{matches[UserLoc].first, size}; + size = static_cast( + std::distance(matches[PassLoc].first, matches[PassLoc].second)); + m_password = boost::string_view{matches[PassLoc].first, size}; + size = static_cast( + std::distance(matches[HostLoc].first, matches[HostLoc].second)); + m_host = boost::string_view{matches[HostLoc].first, size}; + size = static_cast( + std::distance(matches[PortLoc].first, matches[PortLoc].second)); + m_port = boost::string_view{matches[PortLoc].first, size}; + size = static_cast( + std::distance(matches[TargetLoc].first, matches[TargetLoc].second)); + m_target = boost::string_view{matches[TargetLoc].first, size}; + size = static_cast( + std::distance(matches[PathLoc].first, matches[PathLoc].second)); + m_path = boost::string_view{matches[PathLoc].first, size}; + size = static_cast( + std::distance(matches[QueryLoc].first, matches[QueryLoc].second)); + m_query = boost::string_view{matches[QueryLoc].first, size}; + } + } + + void viewsFromOther(const url& other) + { + if (!other.m_scheme.empty()) { + m_scheme = {m_representation.data(), other.m_scheme.size()}; + } else { + m_scheme.clear(); + } + if (!other.m_host.empty()) { + const auto hostStart = view_start(other.m_representation, other.m_host); + m_host = {m_representation.data() + hostStart, other.m_host.size()}; + } else { + m_host.clear(); + } + if (!other.m_port.empty()) { + const auto portStart = view_start(other.m_representation, other.m_port); + m_port = {m_representation.data() + portStart, other.m_port.size()}; + } else { + m_port.clear(); + } + if (!other.m_username.empty()) { + const auto usernameStart = view_start(other.m_representation, other.m_username); + m_username = {m_representation.data() + usernameStart, other.m_username.size()}; + } else { + m_username.clear(); + } + if (!other.m_password.empty()) { + const auto passwordStart = view_start(other.m_representation, other.m_password); + m_password = {m_representation.data() + passwordStart, other.m_password.size()}; + } else { + m_password.clear(); + } + if (!other.m_target.empty()) { + const auto targetStart = view_start(other.m_representation, other.m_target); + m_target = {m_representation.data() + targetStart, other.m_target.size()}; + } else { + m_path.clear(); + } + if (!other.m_path.empty()) { + const auto pathStart = view_start(other.m_representation, other.m_path); + m_path = {m_representation.data() + pathStart, other.m_path.size()}; + } else { + m_path.clear(); + } + if (!other.m_query.empty()) { + const auto queryStart = view_start(other.m_representation, other.m_query); + m_query = {m_representation.data() + queryStart, other.m_query.size()}; + } else { + m_query.clear(); + } + } + + std::string m_representation; + boost::string_view m_scheme; + boost::string_view m_host; + boost::string_view m_port; + boost::string_view m_username; + boost::string_view m_password; + boost::string_view m_path; + boost::string_view m_target; + boost::string_view m_query; +}; + +} // namespace simple_http + +#endif // URL_HPP