├── .clangd ├── cmake └── yacma │ ├── README.md │ └── LICENSE ├── test ├── simple.db ├── catch │ ├── .github │ │ ├── FUNDING.yml │ │ ├── ISSUE_TEMPLATE │ │ │ ├── feature_request.md │ │ │ └── bug_report.md │ │ ├── workflows │ │ │ ├── linux-bazel-builds.yml │ │ │ ├── package-manager-builds.yaml │ │ │ ├── validate-header-guards.yml │ │ │ ├── windows-simple-builds.yml │ │ │ ├── linux-meson-builds.yml │ │ │ └── mac-builds-m1.yml │ │ └── pull_request_template.md │ ├── tests │ │ ├── SelfTest │ │ │ ├── Misc │ │ │ │ ├── invalid-test-names.input │ │ │ │ ├── plain-old-tests.input │ │ │ │ └── special-characters-in-file.input │ │ │ ├── Baselines │ │ │ │ └── default.sw.multi.approved.txt │ │ │ ├── IntrospectiveTests │ │ │ │ ├── AssertionHandler.tests.cpp │ │ │ │ └── Stream.tests.cpp │ │ │ ├── helpers │ │ │ │ ├── parse_test_spec.hpp │ │ │ │ └── parse_test_spec.cpp │ │ │ ├── UsageTests │ │ │ │ ├── VariadicMacros.tests.cpp │ │ │ │ ├── ToStringByte.tests.cpp │ │ │ │ └── Decomposition.tests.cpp │ │ │ └── TimingTests │ │ │ │ └── Sleep.tests.cpp │ │ ├── ExtraTests │ │ │ ├── X92-NoTests.cpp │ │ │ ├── X93-AllSkipped.cpp │ │ │ ├── X30-BazelReporter.cpp │ │ │ ├── X31-DuplicatedTestCases.cpp │ │ │ ├── X32-DuplicatedTestCasesDifferentTags.cpp │ │ │ ├── ToDo.txt │ │ │ ├── X05-DeferredStaticChecks.cpp │ │ │ ├── X90-WindowsHeaderInclusion.cpp │ │ │ ├── X33-DuplicatedTestCaseMethods.cpp │ │ │ ├── X12-CustomDebugBreakMacro.cpp │ │ │ ├── X11-DisableStringification.cpp │ │ │ ├── X34-DuplicatedTestCaseMethodsDifferentFixtures.cpp │ │ │ ├── X36-ReportingCrashWithJunitReporter.cpp │ │ │ ├── X10-FallbackStringifier.cpp │ │ │ ├── X91-AmalgamatedCatch.cpp │ │ │ ├── X35-DuplicatedReporterNames.cpp │ │ │ ├── X04-DisabledExceptions-CustomHandler.cpp │ │ │ ├── X23-CasingInReporterNames.cpp │ │ │ └── X03-DisabledExceptions-DefaultHandler.cpp │ │ └── TestScripts │ │ │ └── DiscoverTests │ │ │ ├── CMakeLists.txt │ │ │ └── register-tests.cpp │ ├── data │ │ └── artwork │ │ │ ├── catch2-c-logo.png │ │ │ ├── catch2-hand-logo.png │ │ │ ├── catch2-logo-small.png │ │ │ └── catch2-logo-small-with-background.png │ ├── MODULE.bazel │ ├── tools │ │ ├── scripts │ │ │ ├── scriptCommon.py │ │ │ ├── developBuild.py │ │ │ ├── majorRelease.py │ │ │ ├── minorRelease.py │ │ │ ├── patchRelease.py │ │ │ ├── checkDuplicateFilenames.py │ │ │ ├── updateDocumentSnippets.py │ │ │ └── approve.py │ │ └── misc │ │ │ ├── appveyorMergeCoverageScript.py │ │ │ ├── CMakeLists.txt │ │ │ ├── appveyorTestRunScript.bat │ │ │ ├── installOpenCppCoverage.ps1 │ │ │ └── appveyorBuildConfigurationScript.bat │ ├── meson_options.txt │ ├── mdsnippets.json │ ├── .conan │ │ └── test_package │ │ │ ├── CMakeLists.txt │ │ │ └── test_package.cpp │ ├── CMake │ │ ├── Catch2Config.cmake.in │ │ ├── catch2.pc.in │ │ ├── catch2-with-main.pc.in │ │ └── llvm-cov-wrapper │ ├── codecov.yml │ ├── .bazelrc │ ├── src │ │ └── catch2 │ │ │ ├── interfaces │ │ │ ├── catch_interfaces_config.cpp │ │ │ ├── catch_interfaces_capture.cpp │ │ │ ├── catch_interfaces_testcase.cpp │ │ │ ├── catch_interfaces_registry_hub.cpp │ │ │ ├── catch_interfaces_reporter_factory.cpp │ │ │ ├── catch_interfaces_exception.cpp │ │ │ ├── catch_interfaces_test_invoker.hpp │ │ │ ├── catch_interfaces_tag_alias_registry.hpp │ │ │ ├── catch_interfaces_generatortracker.cpp │ │ │ ├── catch_interfaces_testcase.hpp │ │ │ └── catch_interfaces_exception.hpp │ │ │ ├── internal │ │ │ ├── catch_errno_guard.cpp │ │ │ ├── catch_uncaught_exceptions.hpp │ │ │ ├── catch_debug_console.hpp │ │ │ ├── catch_leak_detector.hpp │ │ │ ├── catch_stdstreams.hpp │ │ │ ├── catch_polyfills.hpp │ │ │ ├── catch_getenv.hpp │ │ │ ├── catch_commandline.hpp │ │ │ ├── catch_test_run_info.hpp │ │ │ ├── catch_console_width.hpp │ │ │ ├── catch_void_type.hpp │ │ │ ├── catch_stdstreams.cpp │ │ │ ├── catch_preprocessor_internal_stringify.hpp │ │ │ ├── catch_move_and_forward.hpp │ │ │ ├── catch_random_seed_generation.hpp │ │ │ ├── catch_errno_guard.hpp │ │ │ ├── catch_test_case_info_hasher.hpp │ │ │ ├── catch_uncaught_exceptions.cpp │ │ │ ├── catch_preprocessor_remove_parens.hpp │ │ │ ├── catch_message_info.cpp │ │ │ ├── catch_parse_numbers.hpp │ │ │ ├── catch_windows_h_proxy.hpp │ │ │ ├── catch_unique_name.hpp │ │ │ ├── catch_to_string.hpp │ │ │ ├── catch_startup_exception_registry.hpp │ │ │ ├── catch_noncopyable.hpp │ │ │ ├── catch_stream_end_stop.hpp │ │ │ ├── catch_test_failure_exception.cpp │ │ │ ├── catch_lazy_expr.cpp │ │ │ ├── catch_exception_translator_registry.hpp │ │ │ ├── catch_config_prefix_messages.hpp │ │ │ ├── catch_getenv.cpp │ │ │ ├── catch_config_android_logwrite.hpp │ │ │ ├── catch_startup_exception_registry.cpp │ │ │ ├── catch_list.hpp │ │ │ ├── catch_case_insensitive_comparisons.hpp │ │ │ ├── catch_random_seed_generation.cpp │ │ │ ├── catch_context.cpp │ │ │ ├── catch_config_counter.hpp │ │ │ ├── catch_singletons.cpp │ │ │ ├── catch_decomposer.cpp │ │ │ ├── catch_tag_alias_registry.hpp │ │ │ ├── catch_config_wchar.hpp │ │ │ ├── catch_test_failure_exception.hpp │ │ │ ├── catch_source_line_info.hpp │ │ │ ├── catch_wildcard_pattern.hpp │ │ │ ├── catch_enum_values_registry.hpp │ │ │ ├── catch_leak_detector.cpp │ │ │ ├── catch_enforce.cpp │ │ │ ├── catch_source_line_info.cpp │ │ │ ├── catch_case_insensitive_comparisons.cpp │ │ │ ├── catch_lazy_expr.hpp │ │ │ ├── catch_polyfills.cpp │ │ │ ├── catch_config_static_analysis_support.hpp │ │ │ ├── catch_message_info.hpp │ │ │ ├── catch_singletons.hpp │ │ │ ├── catch_debug_console.cpp │ │ │ └── catch_platform.hpp │ │ │ ├── catch_version_macros.hpp │ │ │ ├── generators │ │ │ ├── catch_generator_exception.cpp │ │ │ ├── catch_generator_exception.hpp │ │ │ └── catch_generators_all.hpp │ │ │ ├── catch_case_sensitive.hpp │ │ │ ├── catch_get_random_seed.cpp │ │ │ ├── catch_get_random_seed.hpp │ │ │ ├── benchmark │ │ │ ├── catch_chronometer.cpp │ │ │ ├── catch_estimate.hpp │ │ │ ├── detail │ │ │ │ ├── catch_benchmark_function.cpp │ │ │ │ ├── catch_analyse.hpp │ │ │ │ ├── catch_benchmark_stats_fwd.hpp │ │ │ │ ├── catch_timing.hpp │ │ │ │ ├── catch_run_for_at_least.cpp │ │ │ │ ├── catch_repeat.hpp │ │ │ │ └── catch_measure.hpp │ │ │ ├── catch_clock.hpp │ │ │ ├── catch_environment.hpp │ │ │ ├── catch_sample_analysis.hpp │ │ │ └── catch_outlier_classification.hpp │ │ │ ├── matchers │ │ │ ├── catch_matchers_predicate.cpp │ │ │ ├── catch_matchers.cpp │ │ │ ├── catch_matchers_exception.cpp │ │ │ ├── catch_matchers_quantifiers.cpp │ │ │ ├── catch_matchers_container_properties.cpp │ │ │ └── internal │ │ │ │ └── catch_matchers_impl.cpp │ │ │ ├── catch_translate_exception.cpp │ │ │ ├── reporters │ │ │ ├── catch_reporter_streaming_base.cpp │ │ │ ├── catch_reporter_compact.hpp │ │ │ ├── catch_reporter_registrars.cpp │ │ │ ├── catch_reporter_automake.hpp │ │ │ └── catch_reporter_automake.cpp │ │ │ ├── catch_tag_alias.hpp │ │ │ ├── catch_timer.hpp │ │ │ ├── catch_assertion_info.hpp │ │ │ ├── catch_tag_alias_autoregistrar.cpp │ │ │ ├── catch_totals.hpp │ │ │ ├── catch_tag_alias_autoregistrar.hpp │ │ │ ├── catch_version.hpp │ │ │ ├── catch_timer.cpp │ │ │ ├── catch_section_info.hpp │ │ │ └── catch_version.cpp │ ├── meson.build │ ├── fuzzing │ │ ├── NullOStream.cpp │ │ ├── fuzz_XmlWriter.cpp │ │ ├── fuzz_TestSpecParser.cpp │ │ ├── NullOStream.h │ │ └── CMakeLists.txt │ ├── docs │ │ └── commercial-users.md │ ├── extras │ │ ├── lldbinit │ │ └── gdbinit │ ├── .gitattributes │ ├── SECURITY.md │ ├── .gitignore │ ├── CMakePresets.json │ ├── .clang-format │ ├── LICENSE.txt │ └── examples │ │ └── 020-TestCase-1.cpp ├── fooable.cpp └── test_lib_s11n.cpp ├── codecov.yml ├── doc ├── case_studies.rst ├── api_reference.rst ├── tutorials.rst ├── installation.rst ├── Makefile ├── make.bat └── conf.py.in ├── .gitignore ├── .circleci └── config.yml ├── tools ├── gha_conda_docs.sh ├── gha_osx_clang_16.sh ├── gha_conda_gcc_10.sh ├── gha_osx_clang_18.sh ├── gha_conda_tidy.sh ├── gha_conda_ubsan.sh ├── gha_conda_asan.sh ├── circleci_ubuntu_arm64.sh └── gha_conda_coverage.sh ├── tutorial ├── emplace.cpp ├── nonintrusive.cpp ├── CMakeLists.txt ├── hello_world.cpp ├── ref_semantics.cpp ├── compose2.cpp └── custom_storage.cpp └── .github └── workflows └── static.yml /.clangd: -------------------------------------------------------------------------------- 1 | CompileFlags: 2 | Add: '-std=c++20' 3 | -------------------------------------------------------------------------------- /cmake/yacma/README.md: -------------------------------------------------------------------------------- 1 | # yacma 2 | 3 | Yet another CMake modules archive. 4 | -------------------------------------------------------------------------------- /test/simple.db: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bluescarni/tanuki/HEAD/test/simple.db -------------------------------------------------------------------------------- /test/catch/.github/FUNDING.yml: -------------------------------------------------------------------------------- 1 | github: "horenmar" 2 | custom: "https://www.paypal.me/horenmar" 3 | -------------------------------------------------------------------------------- /test/catch/tests/SelfTest/Misc/invalid-test-names.input: -------------------------------------------------------------------------------- 1 | Test with special, characters in \" name 2 | -------------------------------------------------------------------------------- /test/catch/tests/SelfTest/Misc/plain-old-tests.input: -------------------------------------------------------------------------------- 1 | random SECTION tests 2 | nested SECTION tests 3 | -------------------------------------------------------------------------------- /codecov.yml: -------------------------------------------------------------------------------- 1 | coverage: 2 | ignore: 3 | - "test/catch/.*" 4 | - "tutorial/.*" 5 | 6 | comment: off 7 | -------------------------------------------------------------------------------- /test/catch/tests/SelfTest/Misc/special-characters-in-file.input: -------------------------------------------------------------------------------- 1 | Test with special\, characters \"in name 2 | -------------------------------------------------------------------------------- /doc/case_studies.rst: -------------------------------------------------------------------------------- 1 | Case studies 2 | ============ 3 | 4 | .. toctree:: 5 | :maxdepth: 1 6 | 7 | std_function.rst 8 | -------------------------------------------------------------------------------- /test/catch/data/artwork/catch2-c-logo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bluescarni/tanuki/HEAD/test/catch/data/artwork/catch2-c-logo.png -------------------------------------------------------------------------------- /test/catch/data/artwork/catch2-hand-logo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bluescarni/tanuki/HEAD/test/catch/data/artwork/catch2-hand-logo.png -------------------------------------------------------------------------------- /test/catch/data/artwork/catch2-logo-small.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bluescarni/tanuki/HEAD/test/catch/data/artwork/catch2-logo-small.png -------------------------------------------------------------------------------- /test/catch/MODULE.bazel: -------------------------------------------------------------------------------- 1 | module(name = "catch2") 2 | 3 | bazel_dep(name = "bazel_skylib", version = "1.7.1") 4 | bazel_dep(name = "rules_cc", version = "0.0.17") 5 | -------------------------------------------------------------------------------- /test/catch/tools/scripts/scriptCommon.py: -------------------------------------------------------------------------------- 1 | import os 2 | import sys 3 | 4 | catchPath = os.path.dirname(os.path.dirname(os.path.realpath( os.path.dirname(sys.argv[0])))) 5 | -------------------------------------------------------------------------------- /test/catch/data/artwork/catch2-logo-small-with-background.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bluescarni/tanuki/HEAD/test/catch/data/artwork/catch2-logo-small-with-background.png -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # Editor stuff. 2 | .vscode/ 3 | .cache/ 4 | 5 | # Build dirs. 6 | build* 7 | 8 | # Documentation. 9 | doc/_build 10 | # This is auto-generated. 11 | doc/conf.py 12 | -------------------------------------------------------------------------------- /doc/api_reference.rst: -------------------------------------------------------------------------------- 1 | .. _api_reference: 2 | 3 | API reference 4 | ============= 5 | 6 | .. toctree:: 7 | :maxdepth: 1 8 | 9 | wrap.rst 10 | config.rst 11 | utils.rst 12 | -------------------------------------------------------------------------------- /test/catch/meson_options.txt: -------------------------------------------------------------------------------- 1 | option('tests', type: 'boolean', value: true, description: 'Build the unit tests') 2 | option('install', type: 'boolean', value: true, description: 'Install the library') 3 | -------------------------------------------------------------------------------- /test/catch/mdsnippets.json: -------------------------------------------------------------------------------- 1 | { 2 | "ReadOnly": false, 3 | "TocLevel": 5, 4 | "Exclude": [ 5 | "cmake-build" 6 | ], 7 | "WriteHeader": false, 8 | "Convention": "InPlaceOverwrite" 9 | } 10 | -------------------------------------------------------------------------------- /test/catch/tools/scripts/developBuild.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python3 2 | 3 | import releaseCommon 4 | 5 | v = releaseCommon.Version() 6 | v.incrementBuildNumber() 7 | releaseCommon.performUpdates(v) 8 | 9 | print( "Updated files to v{0}".format( v.getVersionString() ) ) 10 | -------------------------------------------------------------------------------- /test/catch/tools/scripts/majorRelease.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python3 2 | 3 | import releaseCommon 4 | 5 | v = releaseCommon.Version() 6 | v.incrementMajorVersion() 7 | releaseCommon.performUpdates(v) 8 | 9 | print( "Updated files to v{0}".format( v.getVersionString() ) ) 10 | -------------------------------------------------------------------------------- /test/catch/tools/scripts/minorRelease.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python3 2 | 3 | import releaseCommon 4 | 5 | v = releaseCommon.Version() 6 | v.incrementMinorVersion() 7 | releaseCommon.performUpdates(v) 8 | 9 | print( "Updated files to v{0}".format( v.getVersionString() ) ) 10 | -------------------------------------------------------------------------------- /test/catch/tools/scripts/patchRelease.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python3 2 | 3 | import releaseCommon 4 | 5 | v = releaseCommon.Version() 6 | v.incrementPatchNumber() 7 | releaseCommon.performUpdates(v) 8 | 9 | print( "Updated files to v{0}".format( v.getVersionString() ) ) 10 | -------------------------------------------------------------------------------- /test/catch/.conan/test_package/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required(VERSION 3.16) 2 | project(PackageTest CXX) 3 | 4 | find_package(Catch2 CONFIG REQUIRED) 5 | 6 | add_executable(test_package test_package.cpp) 7 | target_link_libraries(test_package Catch2::Catch2WithMain) 8 | target_compile_features(test_package PRIVATE cxx_std_14) 9 | -------------------------------------------------------------------------------- /test/catch/CMake/Catch2Config.cmake.in: -------------------------------------------------------------------------------- 1 | @PACKAGE_INIT@ 2 | 3 | 4 | # Avoid repeatedly including the targets 5 | if(NOT TARGET Catch2::Catch2) 6 | # Provide path for scripts 7 | list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_LIST_DIR}") 8 | 9 | include(${CMAKE_CURRENT_LIST_DIR}/Catch2Targets.cmake) 10 | endif() 11 | -------------------------------------------------------------------------------- /doc/tutorials.rst: -------------------------------------------------------------------------------- 1 | Tutorials 2 | ========= 3 | 4 | .. toctree:: 5 | :maxdepth: 1 6 | 7 | hello_world.rst 8 | simple_interface.rst 9 | ref_interface.rst 10 | custom_storage.rst 11 | wrap_reference.rst 12 | custom_construct.rst 13 | composite_interfaces.rst 14 | nonintrusive.rst 15 | ref_semantics.rst 16 | -------------------------------------------------------------------------------- /test/catch/tests/SelfTest/Baselines/default.sw.multi.approved.txt: -------------------------------------------------------------------------------- 1 | This would not be caught previously 2 | Nor would this 3 | A string sent directly to stdout 4 | A string sent directly to stderr 5 | A string sent to stderr via clog 6 | Message from section one 7 | Message from section two 8 | loose text artifact 9 | a! 10 | b1! 11 | ! 12 | -------------------------------------------------------------------------------- /test/catch/tools/scripts/checkDuplicateFilenames.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python3 2 | 3 | import os 4 | import sys 5 | 6 | files_set = set() 7 | 8 | for root, dir, files in os.walk("src/catch2"): 9 | for file in files: 10 | if file not in files_set: 11 | files_set.add(file) 12 | else: 13 | print("File %s is duplicate" % file) 14 | sys.exit(1) 15 | -------------------------------------------------------------------------------- /test/catch/CMake/catch2.pc.in: -------------------------------------------------------------------------------- 1 | prefix=@CMAKE_INSTALL_PREFIX@ 2 | exec_prefix=${prefix} 3 | includedir=@CMAKE_INSTALL_FULL_INCLUDEDIR@ 4 | libdir=@CMAKE_INSTALL_FULL_LIBDIR@ 5 | 6 | Name: Catch2 7 | Description: A modern, C++-native, test framework for C++14 and above 8 | URL: https://github.com/catchorg/Catch2 9 | Version: @Catch2_VERSION@ 10 | Cflags: -I${includedir} 11 | Libs: -L${libdir} -lCatch2 12 | -------------------------------------------------------------------------------- /test/catch/tools/misc/appveyorMergeCoverageScript.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python3 2 | 3 | import glob 4 | import subprocess 5 | 6 | if __name__ == '__main__': 7 | cov_files = list(glob.glob('tests/cov-report*.bin')) 8 | base_cmd = ['OpenCppCoverage', '--quiet', '--export_type=cobertura:cobertura.xml'] + ['--input_coverage={}'.format(f) for f in cov_files] 9 | subprocess.check_call(base_cmd) 10 | -------------------------------------------------------------------------------- /test/catch/tests/ExtraTests/X92-NoTests.cpp: -------------------------------------------------------------------------------- 1 | 2 | // Copyright Catch2 Authors 3 | // Distributed under the Boost Software License, Version 1.0. 4 | // (See accompanying file LICENSE.txt or copy at 5 | // https://www.boost.org/LICENSE_1_0.txt) 6 | 7 | // SPDX-License-Identifier: BSL-1.0 8 | 9 | /**\file 10 | * Links into executable with no tests which should fail when run 11 | */ 12 | -------------------------------------------------------------------------------- /test/catch/CMake/catch2-with-main.pc.in: -------------------------------------------------------------------------------- 1 | includedir=@CMAKE_INSTALL_FULL_INCLUDEDIR@ 2 | libdir=@CMAKE_INSTALL_FULL_LIBDIR@ 3 | pkg_version=@Catch2_VERSION@ 4 | 5 | Name: Catch2-With-Main 6 | Description: A modern, C++-native test framework for C++14 and above (links in default main) 7 | Version: ${pkg_version} 8 | Requires: catch2 = ${pkg_version} 9 | Cflags: -I${includedir} 10 | Libs: -L${libdir} -lCatch2Main 11 | -------------------------------------------------------------------------------- /test/catch/.github/ISSUE_TEMPLATE/feature_request.md: -------------------------------------------------------------------------------- 1 | --- 2 | name: Feature request 3 | about: Create an issue that requests a feature or other improvement 4 | title: '' 5 | labels: '' 6 | assignees: '' 7 | 8 | --- 9 | 10 | **Description** 11 | Describe the feature/change you request and why do you want it. 12 | 13 | **Additional context** 14 | Add any other context or screenshots about the feature request here. 15 | -------------------------------------------------------------------------------- /test/catch/codecov.yml: -------------------------------------------------------------------------------- 1 | coverage: 2 | precision: 2 3 | round: nearest 4 | range: "60...90" 5 | status: 6 | project: 7 | default: 8 | threshold: 2% 9 | patch: 10 | default: 11 | target: 80% 12 | ignore: 13 | - "**/external/clara.hpp" 14 | - "tests" 15 | 16 | 17 | codecov: 18 | branch: devel 19 | max_report_age: off 20 | 21 | comment: 22 | layout: "diff" 23 | -------------------------------------------------------------------------------- /test/catch/.bazelrc: -------------------------------------------------------------------------------- 1 | # Enable Bzlmod for every Bazel command 2 | common --enable_bzlmod 3 | 4 | build --enable_platform_specific_config 5 | 6 | build:gcc9 --cxxopt=-std=c++2a 7 | build:gcc11 --cxxopt=-std=c++2a 8 | build:clang13 --cxxopt=-std=c++17 9 | build:vs2019 --cxxopt=/std:c++17 10 | build:vs2022 --cxxopt=/std:c++17 11 | 12 | build:windows --config=vs2022 13 | build:linux --config=gcc11 14 | build:macos --cxxopt=-std=c++2b 15 | -------------------------------------------------------------------------------- /test/catch/.conan/test_package/test_package.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | int Factorial( int number ) { 4 | return number <= 1 ? 1 : Factorial( number - 1 ) * number; 5 | } 6 | 7 | TEST_CASE( "Factorial Tests", "[single-file]" ) { 8 | REQUIRE( Factorial(0) == 1 ); 9 | REQUIRE( Factorial(1) == 1 ); 10 | REQUIRE( Factorial(2) == 2 ); 11 | REQUIRE( Factorial(3) == 6 ); 12 | REQUIRE( Factorial(10) == 3628800 ); 13 | } -------------------------------------------------------------------------------- /test/catch/src/catch2/interfaces/catch_interfaces_config.cpp: -------------------------------------------------------------------------------- 1 | 2 | // Copyright Catch2 Authors 3 | // Distributed under the Boost Software License, Version 1.0. 4 | // (See accompanying file LICENSE.txt or copy at 5 | // https://www.boost.org/LICENSE_1_0.txt) 6 | 7 | // SPDX-License-Identifier: BSL-1.0 8 | 9 | #include 10 | 11 | namespace Catch { 12 | IConfig::~IConfig() = default; 13 | } 14 | -------------------------------------------------------------------------------- /test/catch/src/catch2/interfaces/catch_interfaces_capture.cpp: -------------------------------------------------------------------------------- 1 | 2 | // Copyright Catch2 Authors 3 | // Distributed under the Boost Software License, Version 1.0. 4 | // (See accompanying file LICENSE.txt or copy at 5 | // https://www.boost.org/LICENSE_1_0.txt) 6 | 7 | // SPDX-License-Identifier: BSL-1.0 8 | 9 | #include 10 | 11 | namespace Catch { 12 | IResultCapture::~IResultCapture() = default; 13 | } 14 | -------------------------------------------------------------------------------- /test/catch/src/catch2/interfaces/catch_interfaces_testcase.cpp: -------------------------------------------------------------------------------- 1 | 2 | // Copyright Catch2 Authors 3 | // Distributed under the Boost Software License, Version 1.0. 4 | // (See accompanying file LICENSE.txt or copy at 5 | // https://www.boost.org/LICENSE_1_0.txt) 6 | 7 | // SPDX-License-Identifier: BSL-1.0 8 | 9 | #include 10 | 11 | namespace Catch { 12 | ITestCaseRegistry::~ITestCaseRegistry() = default; 13 | } 14 | -------------------------------------------------------------------------------- /test/catch/tools/misc/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required(VERSION 3.16) 2 | 3 | project(CatchCoverageHelper) 4 | 5 | add_executable(CoverageHelper coverage-helper.cpp) 6 | set_property(TARGET CoverageHelper PROPERTY CXX_STANDARD 11) 7 | set_property(TARGET CoverageHelper PROPERTY CXX_STANDARD_REQUIRED ON) 8 | set_property(TARGET CoverageHelper PROPERTY CXX_EXTENSIONS OFF) 9 | if (MSVC) 10 | target_compile_options( CoverageHelper PRIVATE /W4 /w44265 /WX /w44061 /w44062 ) 11 | endif() 12 | -------------------------------------------------------------------------------- /.circleci/config.yml: -------------------------------------------------------------------------------- 1 | # Use the latest 2.1 version of CircleCI pipeline process engine. See: https://circleci.com/docs/2.0/configuration-reference 2 | version: 2.1 3 | 4 | jobs: 5 | ubuntu_arm64: 6 | machine: 7 | image: ubuntu-2204:current 8 | resource_class: arm.large 9 | steps: 10 | - checkout 11 | - run: 12 | name: Build and test 13 | command: bash ./tools/circleci_ubuntu_arm64.sh 14 | 15 | workflows: 16 | version: 2.1 17 | all_builds: 18 | jobs: 19 | - ubuntu_arm64 20 | -------------------------------------------------------------------------------- /test/catch/meson.build: -------------------------------------------------------------------------------- 1 | # Copyright Catch2 Authors 2 | # Distributed under the Boost Software License, Version 1.0. 3 | # (See accompanying file LICENSE.txt or copy at 4 | # https://www.boost.org/LICENSE_1_0.txt) 5 | 6 | # SPDX-License-Identifier: BSL-1.0 7 | 8 | project( 9 | 'catch2', 10 | 'cpp', 11 | version: '3.8.0', # CML version placeholder, don't delete 12 | license: 'BSL-1.0', 13 | meson_version: '>=0.54.1', 14 | ) 15 | 16 | subdir('src/catch2') 17 | if get_option('tests') 18 | subdir('tests') 19 | endif 20 | -------------------------------------------------------------------------------- /test/catch/src/catch2/interfaces/catch_interfaces_registry_hub.cpp: -------------------------------------------------------------------------------- 1 | 2 | // Copyright Catch2 Authors 3 | // Distributed under the Boost Software License, Version 1.0. 4 | // (See accompanying file LICENSE.txt or copy at 5 | // https://www.boost.org/LICENSE_1_0.txt) 6 | 7 | // SPDX-License-Identifier: BSL-1.0 8 | 9 | #include 10 | 11 | namespace Catch { 12 | IRegistryHub::~IRegistryHub() = default; 13 | IMutableRegistryHub::~IMutableRegistryHub() = default; 14 | } 15 | -------------------------------------------------------------------------------- /test/catch/src/catch2/internal/catch_errno_guard.cpp: -------------------------------------------------------------------------------- 1 | 2 | // Copyright Catch2 Authors 3 | // Distributed under the Boost Software License, Version 1.0. 4 | // (See accompanying file LICENSE.txt or copy at 5 | // https://www.boost.org/LICENSE_1_0.txt) 6 | 7 | // SPDX-License-Identifier: BSL-1.0 8 | 9 | #include 10 | 11 | #include 12 | 13 | namespace Catch { 14 | ErrnoGuard::ErrnoGuard():m_oldErrno(errno){} 15 | ErrnoGuard::~ErrnoGuard() { errno = m_oldErrno; } 16 | } 17 | -------------------------------------------------------------------------------- /test/catch/src/catch2/catch_version_macros.hpp: -------------------------------------------------------------------------------- 1 | 2 | // Copyright Catch2 Authors 3 | // Distributed under the Boost Software License, Version 1.0. 4 | // (See accompanying file LICENSE.txt or copy at 5 | // https://www.boost.org/LICENSE_1_0.txt) 6 | 7 | // SPDX-License-Identifier: BSL-1.0 8 | #ifndef CATCH_VERSION_MACROS_HPP_INCLUDED 9 | #define CATCH_VERSION_MACROS_HPP_INCLUDED 10 | 11 | #define CATCH_VERSION_MAJOR 3 12 | #define CATCH_VERSION_MINOR 8 13 | #define CATCH_VERSION_PATCH 0 14 | 15 | #endif // CATCH_VERSION_MACROS_HPP_INCLUDED 16 | -------------------------------------------------------------------------------- /test/catch/src/catch2/generators/catch_generator_exception.cpp: -------------------------------------------------------------------------------- 1 | 2 | // Copyright Catch2 Authors 3 | // Distributed under the Boost Software License, Version 1.0. 4 | // (See accompanying file LICENSE.txt or copy at 5 | // https://www.boost.org/LICENSE_1_0.txt) 6 | 7 | // SPDX-License-Identifier: BSL-1.0 8 | 9 | #include 10 | 11 | namespace Catch { 12 | 13 | const char* GeneratorException::what() const noexcept { 14 | return m_msg; 15 | } 16 | 17 | } // end namespace Catch 18 | -------------------------------------------------------------------------------- /test/catch/src/catch2/catch_case_sensitive.hpp: -------------------------------------------------------------------------------- 1 | 2 | // Copyright Catch2 Authors 3 | // Distributed under the Boost Software License, Version 1.0. 4 | // (See accompanying file LICENSE.txt or copy at 5 | // https://www.boost.org/LICENSE_1_0.txt) 6 | 7 | // SPDX-License-Identifier: BSL-1.0 8 | #ifndef CATCH_CASE_SENSITIVE_HPP_INCLUDED 9 | #define CATCH_CASE_SENSITIVE_HPP_INCLUDED 10 | 11 | namespace Catch { 12 | 13 | enum class CaseSensitive { Yes, No }; 14 | 15 | } // namespace Catch 16 | 17 | #endif // CATCH_CASE_SENSITIVE_HPP_INCLUDED 18 | -------------------------------------------------------------------------------- /test/catch/src/catch2/interfaces/catch_interfaces_reporter_factory.cpp: -------------------------------------------------------------------------------- 1 | 2 | // Copyright Catch2 Authors 3 | // Distributed under the Boost Software License, Version 1.0. 4 | // (See accompanying file LICENSE.txt or copy at 5 | // https://www.boost.org/LICENSE_1_0.txt) 6 | 7 | // SPDX-License-Identifier: BSL-1.0 8 | 9 | #include 10 | 11 | namespace Catch { 12 | IReporterFactory::~IReporterFactory() = default; 13 | EventListenerFactory::~EventListenerFactory() = default; 14 | } 15 | -------------------------------------------------------------------------------- /test/catch/src/catch2/interfaces/catch_interfaces_exception.cpp: -------------------------------------------------------------------------------- 1 | 2 | // Copyright Catch2 Authors 3 | // Distributed under the Boost Software License, Version 1.0. 4 | // (See accompanying file LICENSE.txt or copy at 5 | // https://www.boost.org/LICENSE_1_0.txt) 6 | 7 | // SPDX-License-Identifier: BSL-1.0 8 | 9 | #include 10 | 11 | namespace Catch { 12 | IExceptionTranslator::~IExceptionTranslator() = default; 13 | IExceptionTranslatorRegistry::~IExceptionTranslatorRegistry() = default; 14 | } 15 | -------------------------------------------------------------------------------- /test/catch/src/catch2/internal/catch_uncaught_exceptions.hpp: -------------------------------------------------------------------------------- 1 | 2 | // Copyright Catch2 Authors 3 | // Distributed under the Boost Software License, Version 1.0. 4 | // (See accompanying file LICENSE.txt or copy at 5 | // https://www.boost.org/LICENSE_1_0.txt) 6 | 7 | // SPDX-License-Identifier: BSL-1.0 8 | #ifndef CATCH_UNCAUGHT_EXCEPTIONS_HPP_INCLUDED 9 | #define CATCH_UNCAUGHT_EXCEPTIONS_HPP_INCLUDED 10 | 11 | namespace Catch { 12 | bool uncaught_exceptions(); 13 | } // end namespace Catch 14 | 15 | #endif // CATCH_UNCAUGHT_EXCEPTIONS_HPP_INCLUDED 16 | -------------------------------------------------------------------------------- /test/catch/fuzzing/NullOStream.cpp: -------------------------------------------------------------------------------- 1 | 2 | // Copyright Catch2 Authors 3 | // Distributed under the Boost Software License, Version 1.0. 4 | // (See accompanying file LICENSE.txt or copy at 5 | // https://www.boost.org/LICENSE_1_0.txt) 6 | 7 | // SPDX-License-Identifier: BSL-1.0 8 | 9 | #include "NullOStream.h" 10 | 11 | void NullOStream::avoidOutOfLineVirtualCompilerWarning() 12 | { 13 | } 14 | 15 | int NullStreambuf::overflow(int c){ 16 | setp(dummyBuffer, dummyBuffer + sizeof(dummyBuffer)); 17 | return (c == traits_type::eof()) ? '\0' : c; 18 | } 19 | -------------------------------------------------------------------------------- /test/catch/tests/ExtraTests/X93-AllSkipped.cpp: -------------------------------------------------------------------------------- 1 | 2 | // Copyright Catch2 Authors 3 | // Distributed under the Boost Software License, Version 1.0. 4 | // (See accompanying file LICENSE.txt or copy at 5 | // https://www.boost.org/LICENSE_1_0.txt) 6 | 7 | // SPDX-License-Identifier: BSL-1.0 8 | 9 | #include 10 | 11 | TEST_CASE( "this test case is being skipped" ) { SKIP(); } 12 | 13 | TEST_CASE( "all sections in this test case are being skipped" ) { 14 | SECTION( "A" ) { SKIP(); } 15 | SECTION( "B" ) { SKIP(); } 16 | } 17 | -------------------------------------------------------------------------------- /test/catch/src/catch2/internal/catch_debug_console.hpp: -------------------------------------------------------------------------------- 1 | 2 | // Copyright Catch2 Authors 3 | // Distributed under the Boost Software License, Version 1.0. 4 | // (See accompanying file LICENSE.txt or copy at 5 | // https://www.boost.org/LICENSE_1_0.txt) 6 | 7 | // SPDX-License-Identifier: BSL-1.0 8 | #ifndef CATCH_DEBUG_CONSOLE_HPP_INCLUDED 9 | #define CATCH_DEBUG_CONSOLE_HPP_INCLUDED 10 | 11 | #include 12 | 13 | namespace Catch { 14 | void writeToDebugConsole( std::string const& text ); 15 | } 16 | 17 | #endif // CATCH_DEBUG_CONSOLE_HPP_INCLUDED 18 | -------------------------------------------------------------------------------- /test/catch/src/catch2/catch_get_random_seed.cpp: -------------------------------------------------------------------------------- 1 | 2 | // Copyright Catch2 Authors 3 | // Distributed under the Boost Software License, Version 1.0. 4 | // (See accompanying file LICENSE.txt or copy at 5 | // https://www.boost.org/LICENSE_1_0.txt) 6 | 7 | // SPDX-License-Identifier: BSL-1.0 8 | 9 | #include 10 | 11 | #include 12 | #include 13 | 14 | namespace Catch { 15 | std::uint32_t getSeed() { 16 | return getCurrentContext().getConfig()->rngSeed(); 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /test/catch/src/catch2/internal/catch_leak_detector.hpp: -------------------------------------------------------------------------------- 1 | 2 | // Copyright Catch2 Authors 3 | // Distributed under the Boost Software License, Version 1.0. 4 | // (See accompanying file LICENSE.txt or copy at 5 | // https://www.boost.org/LICENSE_1_0.txt) 6 | 7 | // SPDX-License-Identifier: BSL-1.0 8 | #ifndef CATCH_LEAK_DETECTOR_HPP_INCLUDED 9 | #define CATCH_LEAK_DETECTOR_HPP_INCLUDED 10 | 11 | namespace Catch { 12 | 13 | struct LeakDetector { 14 | LeakDetector(); 15 | ~LeakDetector(); 16 | }; 17 | 18 | } 19 | #endif // CATCH_LEAK_DETECTOR_HPP_INCLUDED 20 | -------------------------------------------------------------------------------- /test/catch/src/catch2/catch_get_random_seed.hpp: -------------------------------------------------------------------------------- 1 | 2 | // Copyright Catch2 Authors 3 | // Distributed under the Boost Software License, Version 1.0. 4 | // (See accompanying file LICENSE.txt or copy at 5 | // https://www.boost.org/LICENSE_1_0.txt) 6 | 7 | // SPDX-License-Identifier: BSL-1.0 8 | #ifndef CATCH_GET_RANDOM_SEED_HPP_INCLUDED 9 | #define CATCH_GET_RANDOM_SEED_HPP_INCLUDED 10 | 11 | #include 12 | 13 | namespace Catch { 14 | //! Returns Catch2's current RNG seed. 15 | std::uint32_t getSeed(); 16 | } 17 | 18 | #endif // CATCH_GET_RANDOM_SEED_HPP_INCLUDED 19 | -------------------------------------------------------------------------------- /test/catch/src/catch2/internal/catch_stdstreams.hpp: -------------------------------------------------------------------------------- 1 | 2 | // Copyright Catch2 Authors 3 | // Distributed under the Boost Software License, Version 1.0. 4 | // (See accompanying file LICENSE.txt or copy at 5 | // https://www.boost.org/LICENSE_1_0.txt) 6 | 7 | // SPDX-License-Identifier: BSL-1.0 8 | 9 | #ifndef CATCH_STDSTREAMS_HPP_INCLUDED 10 | #define CATCH_STDSTREAMS_HPP_INCLUDED 11 | 12 | #include 13 | 14 | namespace Catch { 15 | 16 | std::ostream& cout(); 17 | std::ostream& cerr(); 18 | std::ostream& clog(); 19 | 20 | } // namespace Catch 21 | 22 | #endif 23 | -------------------------------------------------------------------------------- /test/catch/tests/ExtraTests/X30-BazelReporter.cpp: -------------------------------------------------------------------------------- 1 | 2 | // Copyright Catch2 Authors 3 | // Distributed under the Boost Software License, Version 1.0. 4 | // (See accompanying file LICENSE.txt or copy at 5 | // https://www.boost.org/LICENSE_1_0.txt) 6 | 7 | // SPDX-License-Identifier: BSL-1.0 8 | 9 | /**\file 10 | * Test the Bazel report functionality with a simple set 11 | * of dummy test cases. 12 | */ 13 | 14 | #include 15 | 16 | TEST_CASE( "Passing test case" ) { REQUIRE( 1 == 1 ); } 17 | TEST_CASE( "Failing test case" ) { REQUIRE( 2 == 1 ); } 18 | -------------------------------------------------------------------------------- /test/catch/src/catch2/benchmark/catch_chronometer.cpp: -------------------------------------------------------------------------------- 1 | 2 | // Copyright Catch2 Authors 3 | // Distributed under the Boost Software License, Version 1.0. 4 | // (See accompanying file LICENSE.txt or copy at 5 | // https://www.boost.org/LICENSE_1_0.txt) 6 | 7 | // SPDX-License-Identifier: BSL-1.0 8 | 9 | #include 10 | 11 | namespace Catch { 12 | namespace Benchmark { 13 | namespace Detail { 14 | ChronometerConcept::~ChronometerConcept() = default; 15 | } // namespace Detail 16 | } // namespace Benchmark 17 | } // namespace Catch 18 | -------------------------------------------------------------------------------- /test/catch/tests/ExtraTests/X31-DuplicatedTestCases.cpp: -------------------------------------------------------------------------------- 1 | 2 | // Copyright Catch2 Authors 3 | // Distributed under the Boost Software License, Version 1.0. 4 | // (See accompanying file LICENSE.txt or copy at 5 | // https://www.boost.org/LICENSE_1_0.txt) 6 | 7 | // SPDX-License-Identifier: BSL-1.0 8 | 9 | /**\file 10 | * Checks that test cases with identical name and tags are reported as error 11 | */ 12 | 13 | #include 14 | 15 | TEST_CASE("A test case with duplicated name and tags", "[tag1][tag2]") {} 16 | TEST_CASE("A test case with duplicated name and tags", "[tag1][tag2]") {} 17 | -------------------------------------------------------------------------------- /test/catch/src/catch2/internal/catch_polyfills.hpp: -------------------------------------------------------------------------------- 1 | 2 | // Copyright Catch2 Authors 3 | // Distributed under the Boost Software License, Version 1.0. 4 | // (See accompanying file LICENSE.txt or copy at 5 | // https://www.boost.org/LICENSE_1_0.txt) 6 | 7 | // SPDX-License-Identifier: BSL-1.0 8 | #ifndef CATCH_POLYFILLS_HPP_INCLUDED 9 | #define CATCH_POLYFILLS_HPP_INCLUDED 10 | 11 | namespace Catch { 12 | 13 | bool isnan(float f); 14 | bool isnan(double d); 15 | 16 | float nextafter(float x, float y); 17 | double nextafter(double x, double y); 18 | 19 | } 20 | 21 | #endif // CATCH_POLYFILLS_HPP_INCLUDED 22 | -------------------------------------------------------------------------------- /test/catch/src/catch2/internal/catch_getenv.hpp: -------------------------------------------------------------------------------- 1 | 2 | // Copyright Catch2 Authors 3 | // Distributed under the Boost Software License, Version 1.0. 4 | // (See accompanying file LICENSE.txt or copy at 5 | // https://www.boost.org/LICENSE_1_0.txt) 6 | 7 | // SPDX-License-Identifier: BSL-1.0 8 | #ifndef CATCH_GETENV_HPP_INCLUDED 9 | #define CATCH_GETENV_HPP_INCLUDED 10 | 11 | namespace Catch { 12 | namespace Detail { 13 | 14 | //! Wrapper over `std::getenv` that compiles on UWP (and always returns nullptr there) 15 | char const* getEnv(char const* varName); 16 | 17 | } 18 | } 19 | 20 | #endif // CATCH_GETENV_HPP_INCLUDED 21 | -------------------------------------------------------------------------------- /test/catch/src/catch2/matchers/catch_matchers_predicate.cpp: -------------------------------------------------------------------------------- 1 | 2 | // Copyright Catch2 Authors 3 | // Distributed under the Boost Software License, Version 1.0. 4 | // (See accompanying file LICENSE.txt or copy at 5 | // https://www.boost.org/LICENSE_1_0.txt) 6 | 7 | // SPDX-License-Identifier: BSL-1.0 8 | 9 | #include 10 | 11 | std::string Catch::Matchers::Detail::finalizeDescription(const std::string& desc) { 12 | if (desc.empty()) { 13 | return "matches undescribed predicate"; 14 | } else { 15 | return "matches predicate: \"" + desc + '"'; 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /doc/installation.rst: -------------------------------------------------------------------------------- 1 | Installation 2 | ============ 3 | 4 | tanuki currently consists of a self-contained single header, with no dependencies 5 | apart from the standard library. Just grab the ``include/tanuki.hpp`` header and copy it 6 | somewhere in your project. 7 | 8 | Supported platforms/compilers 9 | ----------------------------- 10 | 11 | tanuki requires a C++ compiler with decent support for several C++20 features. 12 | Currently the following compilers are tested in the CI pipeline: 13 | 14 | - GCC >= 10.4, 15 | - clang >= 14, 16 | - MSVC 2022. 17 | 18 | The CI pipeline is run on several platforms, including x86-64/arm64 Linux, x86-64 OSX and Windows. 19 | -------------------------------------------------------------------------------- /test/catch/fuzzing/fuzz_XmlWriter.cpp: -------------------------------------------------------------------------------- 1 | 2 | // Copyright Catch2 Authors 3 | // Distributed under the Boost Software License, Version 1.0. 4 | // (See accompanying file LICENSE.txt or copy at 5 | // https://www.boost.org/LICENSE_1_0.txt) 6 | 7 | // SPDX-License-Identifier: BSL-1.0 8 | //By Paul Dreik 2020 9 | 10 | #include 11 | 12 | #include "NullOStream.h" 13 | 14 | extern "C" int LLVMFuzzerTestOneInput(const uint8_t *Data, size_t Size) { 15 | 16 | std::string buf(Data,Data+Size); 17 | NullOStream nul; 18 | Catch::XmlEncode encode(buf); 19 | encode.encodeTo(nul); 20 | return 0; 21 | } 22 | 23 | -------------------------------------------------------------------------------- /test/catch/src/catch2/internal/catch_commandline.hpp: -------------------------------------------------------------------------------- 1 | 2 | // Copyright Catch2 Authors 3 | // Distributed under the Boost Software License, Version 1.0. 4 | // (See accompanying file LICENSE.txt or copy at 5 | // https://www.boost.org/LICENSE_1_0.txt) 6 | 7 | // SPDX-License-Identifier: BSL-1.0 8 | #ifndef CATCH_COMMANDLINE_HPP_INCLUDED 9 | #define CATCH_COMMANDLINE_HPP_INCLUDED 10 | 11 | #include 12 | 13 | namespace Catch { 14 | 15 | struct ConfigData; 16 | 17 | Clara::Parser makeCommandLineParser( ConfigData& config ); 18 | 19 | } // end namespace Catch 20 | 21 | #endif // CATCH_COMMANDLINE_HPP_INCLUDED 22 | -------------------------------------------------------------------------------- /test/catch/tests/SelfTest/IntrospectiveTests/AssertionHandler.tests.cpp: -------------------------------------------------------------------------------- 1 | 2 | // Copyright Catch2 Authors 3 | // Distributed under the Boost Software License, Version 1.0. 4 | // (See accompanying file LICENSE.txt or copy at 5 | // https://www.boost.org/LICENSE_1_0.txt) 6 | 7 | // SPDX-License-Identifier: BSL-1.0 8 | 9 | #include 10 | 11 | TEST_CASE( "Incomplete AssertionHandler", "[assertion-handler][!shouldfail]" ) { 12 | Catch::AssertionHandler catchAssertionHandler( 13 | "REQUIRE"_catch_sr, 14 | CATCH_INTERNAL_LINEINFO, 15 | "Dummy", 16 | Catch::ResultDisposition::Normal ); 17 | } 18 | -------------------------------------------------------------------------------- /test/catch/tests/SelfTest/helpers/parse_test_spec.hpp: -------------------------------------------------------------------------------- 1 | 2 | // Copyright Catch2 Authors 3 | // Distributed under the Boost Software License, Version 1.0. 4 | // (See accompanying file LICENSE.txt or copy at 5 | // https://www.boost.org/LICENSE_1_0.txt) 6 | 7 | // SPDX-License-Identifier: BSL-1.0 8 | 9 | #ifndef CATCH_TEST_HELPERS_PARSE_TEST_SPEC_HPP_INCLUDED 10 | #define CATCH_TEST_HELPERS_PARSE_TEST_SPEC_HPP_INCLUDED 11 | 12 | #include 13 | 14 | #include 15 | 16 | namespace Catch { 17 | TestSpec parseTestSpec( std::string const& arg ); 18 | } 19 | 20 | #endif // CATCH_TEST_HELPERS_PARSE_TEST_SPEC_HPP_INCLUDED 21 | -------------------------------------------------------------------------------- /test/catch/tests/ExtraTests/X32-DuplicatedTestCasesDifferentTags.cpp: -------------------------------------------------------------------------------- 1 | 2 | // Copyright Catch2 Authors 3 | // Distributed under the Boost Software License, Version 1.0. 4 | // (See accompanying file LICENSE.txt or copy at 5 | // https://www.boost.org/LICENSE_1_0.txt) 6 | 7 | // SPDX-License-Identifier: BSL-1.0 8 | 9 | /**\file 10 | * Checks that test cases with identical name but different tags are 11 | * not reported as an error. 12 | */ 13 | 14 | #include 15 | 16 | TEST_CASE("A test case with duplicated name but different tags", "[tag1]") {} 17 | TEST_CASE("A test case with duplicated name but different tags", "[tag2]") {} 18 | -------------------------------------------------------------------------------- /test/catch/.github/workflows/linux-bazel-builds.yml: -------------------------------------------------------------------------------- 1 | name: Bazel build 2 | 3 | on: [push, pull_request] 4 | 5 | jobs: 6 | build_and_test_ubuntu: 7 | name: Linux Ubuntu 22.04 Bazel build 8 | runs-on: ubuntu-22.04 9 | strategy: 10 | matrix: 11 | compilation_mode: [fastbuild, dbg, opt] 12 | 13 | steps: 14 | - uses: actions/checkout@v4 15 | 16 | - name: Mount bazel cache 17 | uses: actions/cache@v3 18 | with: 19 | path: "/home/runner/.cache/bazel" 20 | key: bazel-ubuntu22-gcc11 21 | 22 | - name: Build Catch2 23 | run: | 24 | bazelisk build --compilation_mode=${{matrix.compilation_mode}} //... 25 | -------------------------------------------------------------------------------- /test/catch/tests/ExtraTests/ToDo.txt: -------------------------------------------------------------------------------- 1 | Configuration options that are left default and thus are not properly tested 2 | yet: 3 | 4 | CATCH_CONFIG_COUNTER // Use __COUNTER__ to generate unique names for test cases 5 | CATCH_CONFIG_WINDOWS_SEH // Enable SEH handling on Windows 6 | CATCH_CONFIG_FAST_COMPILE // Sacrifices some (rather minor) features for compilation speed 7 | CATCH_CONFIG_POSIX_SIGNALS // Enable handling POSIX signals 8 | CATCH_CONFIG_WINDOWS_CRTDBG // Enable leak checking using Windows's CRT Debug Heap 9 | CATCH_CONFIG_DEFAULT_REPORTER 10 | CATCH_CONFIG_ENABLE_ALL_STRINGMAKERS 11 | -------------------------------------------------------------------------------- /test/catch/docs/commercial-users.md: -------------------------------------------------------------------------------- 1 | 2 | # Commercial users of Catch2 3 | 4 | Catch2 is also widely used in proprietary code bases. This page contains 5 | some of them that are willing to share this information. 6 | 7 | If you want to add your organisation, please check that there is no issue 8 | with you sharing this fact. 9 | 10 | - Bloomberg 11 | - [Bloomlife](https://bloomlife.com) 12 | - [Inscopix Inc.](https://www.inscopix.com/) 13 | - Locksley.CZ 14 | - [Makimo](https://makimo.pl/) 15 | - NASA 16 | - [Nexus Software Systems](https://nexwebsites.com) 17 | - [UX3D](https://ux3d.io) 18 | - [King](https://king.com) 19 | 20 | 21 | --- 22 | 23 | [Home](Readme.md#top) 24 | -------------------------------------------------------------------------------- /test/catch/extras/lldbinit: -------------------------------------------------------------------------------- 1 | # 2 | # This file provides a way to skip stepping into Catch code when debugging with lldb. 3 | # 4 | # With the setting "target.process.thread.step-avoid-regexp" you can tell lldb 5 | # to skip functions matching the regexp 6 | # 7 | # Basically the following line tells lldb to skip all functions containing the 8 | # regexp "Catch", which matches the complete Catch namespace. 9 | # If you want to skip just some parts of the Catch code you can modify the 10 | # regexp accordingly. 11 | # 12 | # If you want to permanently skip stepping into Catch code copy the following 13 | # line into your ~/.lldbinit file 14 | # 15 | 16 | settings set target.process.thread.step-avoid-regexp Catch -------------------------------------------------------------------------------- /test/catch/tests/ExtraTests/X05-DeferredStaticChecks.cpp: -------------------------------------------------------------------------------- 1 | 2 | // Copyright Catch2 Authors 3 | // Distributed under the Boost Software License, Version 1.0. 4 | // (See accompanying file LICENSE.txt or copy at 5 | // https://www.boost.org/LICENSE_1_0.txt) 6 | 7 | // SPDX-License-Identifier: BSL-1.0 8 | 9 | /**\file 10 | * Checks that when `STATIC_CHECK` is deferred to runtime and fails, it 11 | * does not abort the test case. 12 | */ 13 | 14 | #include 15 | 16 | TEST_CASE("Deferred static checks") { 17 | STATIC_CHECK(1 == 2); 18 | STATIC_CHECK_FALSE(1 != 2); 19 | // This last assertion must be executed too 20 | CHECK(1 == 2); 21 | } 22 | -------------------------------------------------------------------------------- /test/catch/tests/ExtraTests/X90-WindowsHeaderInclusion.cpp: -------------------------------------------------------------------------------- 1 | 2 | // Copyright Catch2 Authors 3 | // Distributed under the Boost Software License, Version 1.0. 4 | // (See accompanying file LICENSE.txt or copy at 5 | // https://www.boost.org/LICENSE_1_0.txt) 6 | 7 | // SPDX-License-Identifier: BSL-1.0 8 | 9 | /**\file 10 | * Test that the Catch2 header compiles even after including windows.h 11 | * without defining NOMINMAX first. 12 | * 13 | * As an FYI, if you do that, you are wrong. 14 | */ 15 | 16 | #include 17 | #include 18 | 19 | TEST_CASE("Catch2 did survive compilation with windows.h", "[compile-test]") { 20 | SUCCEED(); 21 | } 22 | -------------------------------------------------------------------------------- /test/fooable.cpp: -------------------------------------------------------------------------------- 1 | // Copyright 2023 Francesco Biscani (bluescarni@gmail.com) 2 | // 3 | // This file is part of the tanuki library. 4 | // 5 | // This Source Code Form is subject to the terms of the Mozilla 6 | // Public License v. 2.0. If a copy of the MPL was not distributed 7 | // with this file, You can obtain one at http://mozilla.org/MPL/2.0/. 8 | 9 | #include 10 | 11 | #include "fooable.hpp" 12 | 13 | namespace fooable 14 | { 15 | 16 | // LCOV_EXCL_START 17 | 18 | void foo_model::foo() const {} 19 | 20 | // LCOV_EXCL_STOP 21 | 22 | } // namespace fooable 23 | 24 | // NOLINTNEXTLINE(cert-err58-cpp) 25 | TANUKI_S11N_WRAP_EXPORT_IMPLEMENT(fooable::foo_model, fooable::foo_iface) 26 | -------------------------------------------------------------------------------- /doc/Makefile: -------------------------------------------------------------------------------- 1 | # Minimal makefile for Sphinx documentation 2 | # 3 | 4 | # You can set these variables from the command line, and also 5 | # from the environment for the first two. 6 | SPHINXOPTS ?= 7 | SPHINXBUILD ?= sphinx-build 8 | SOURCEDIR = . 9 | BUILDDIR = _build 10 | 11 | # Put it first so that "make" without argument is like "make help". 12 | help: 13 | @$(SPHINXBUILD) -M help "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O) 14 | 15 | .PHONY: help Makefile 16 | 17 | # Catch-all target: route all unknown targets to Sphinx using the new 18 | # "make mode" option. $(O) is meant as a shortcut for $(SPHINXOPTS). 19 | %: Makefile 20 | @$(SPHINXBUILD) -M $@ "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O) 21 | -------------------------------------------------------------------------------- /test/catch/fuzzing/fuzz_TestSpecParser.cpp: -------------------------------------------------------------------------------- 1 | 2 | // Copyright Catch2 Authors 3 | // Distributed under the Boost Software License, Version 1.0. 4 | // (See accompanying file LICENSE.txt or copy at 5 | // https://www.boost.org/LICENSE_1_0.txt) 6 | 7 | // SPDX-License-Identifier: BSL-1.0 8 | //By Paul Dreik 2020 9 | 10 | #include 11 | #include 12 | 13 | extern "C" int LLVMFuzzerTestOneInput(const uint8_t *Data, size_t Size) { 14 | 15 | Catch::TagAliasRegistry tar; 16 | Catch::TestSpecParser tsp(tar); 17 | 18 | std::string buf(Data,Data+Size); 19 | tsp.parse(buf); 20 | 21 | return 0; 22 | } 23 | -------------------------------------------------------------------------------- /test/catch/src/catch2/internal/catch_test_run_info.hpp: -------------------------------------------------------------------------------- 1 | 2 | // Copyright Catch2 Authors 3 | // Distributed under the Boost Software License, Version 1.0. 4 | // (See accompanying file LICENSE.txt or copy at 5 | // https://www.boost.org/LICENSE_1_0.txt) 6 | 7 | // SPDX-License-Identifier: BSL-1.0 8 | #ifndef CATCH_TEST_RUN_INFO_HPP_INCLUDED 9 | #define CATCH_TEST_RUN_INFO_HPP_INCLUDED 10 | 11 | #include 12 | 13 | namespace Catch { 14 | 15 | struct TestRunInfo { 16 | constexpr TestRunInfo(StringRef _name) : name(_name) {} 17 | StringRef name; 18 | }; 19 | 20 | } // end namespace Catch 21 | 22 | #endif // CATCH_TEST_RUN_INFO_HPP_INCLUDED 23 | -------------------------------------------------------------------------------- /test/catch/.gitattributes: -------------------------------------------------------------------------------- 1 | # This sets the default behaviour, overriding core.autocrlf 2 | * text=auto 3 | 4 | # All source files should have unix line-endings in the repository, 5 | # but convert to native line-endings on checkout 6 | *.cpp text 7 | *.h text 8 | *.hpp text 9 | 10 | # Windows specific files should retain windows line-endings 11 | *.sln text eol=crlf 12 | 13 | # Keep executable scripts with LFs so they can be run after being 14 | # checked out on Windows 15 | *.py text eol=lf 16 | 17 | 18 | # Keep the single include header with LFs to make sure it is uploaded, 19 | # hashed etc with LF 20 | single_include/**/*.hpp eol=lf 21 | # Also keep the LICENCE file with LFs for the same reason 22 | LICENCE.txt eol=lf 23 | -------------------------------------------------------------------------------- /test/catch/extras/gdbinit: -------------------------------------------------------------------------------- 1 | # 2 | # This file provides a way to skip stepping into Catch code when debugging with gdb. 3 | # 4 | # With the gdb "skip" command you can tell gdb to skip files or functions during debugging. 5 | # see https://xaizek.github.io/2016-05-26/skipping-standard-library-in-gdb/ for an example 6 | # 7 | # Basically the following line tells gdb to skip all functions containing the 8 | # regexp "Catch", which matches the complete Catch namespace. 9 | # If you want to skip just some parts of the Catch code you can modify the 10 | # regexp accordingly. 11 | # 12 | # If you want to permanently skip stepping into Catch code copy the following 13 | # line into your ~/.gdbinit file 14 | # 15 | 16 | skip -rfu Catch 17 | -------------------------------------------------------------------------------- /tools/gha_conda_docs.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | # Echo each command 4 | set -x 5 | 6 | # Exit on error. 7 | set -e 8 | 9 | # Core deps. 10 | sudo apt-get install wget 11 | 12 | # Install conda+deps. 13 | wget https://github.com/conda-forge/miniforge/releases/latest/download/Miniforge3-Linux-x86_64.sh -O miniconda.sh 14 | export deps_dir=$HOME/local 15 | export PATH="$HOME/miniconda/bin:$PATH" 16 | bash miniconda.sh -b -p $HOME/miniconda 17 | mamba create -y -q -p $deps_dir cmake python=3.11 'sphinx=7.*' 'sphinx-book-theme=1.*' make 18 | source activate $deps_dir 19 | 20 | # Create the build dir and cd into it. 21 | mkdir build 22 | cd build 23 | 24 | cmake ../ 25 | cd ../doc 26 | make html linkcheck 27 | 28 | set +e 29 | set +x 30 | -------------------------------------------------------------------------------- /tutorial/emplace.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | #include 5 | 6 | template 7 | struct any_iface_impl : public Base { 8 | }; 9 | 10 | struct any_iface { 11 | template 12 | using impl = any_iface_impl; 13 | }; 14 | 15 | int main() 16 | { 17 | using any_wrap = tanuki::wrap{.copyable = false, .movable = false, .swappable = false}>; 18 | 19 | // Emplace-construct with std::mutex. 20 | any_wrap w(std::in_place_type); 21 | 22 | // Reset to the invalid state. 23 | w = tanuki::invalid_wrap; 24 | 25 | // Emplace into existing wrap. 26 | emplace(w); 27 | } 28 | -------------------------------------------------------------------------------- /test/catch/src/catch2/internal/catch_console_width.hpp: -------------------------------------------------------------------------------- 1 | 2 | // Copyright Catch2 Authors 3 | // Distributed under the Boost Software License, Version 1.0. 4 | // (See accompanying file LICENSE.txt or copy at 5 | // https://www.boost.org/LICENSE_1_0.txt) 6 | 7 | // SPDX-License-Identifier: BSL-1.0 8 | #ifndef CATCH_CONSOLE_WIDTH_HPP_INCLUDED 9 | #define CATCH_CONSOLE_WIDTH_HPP_INCLUDED 10 | 11 | // This include must be kept so that user's configured value for CONSOLE_WIDTH 12 | // is used before we attempt to provide a default value 13 | #include 14 | 15 | #ifndef CATCH_CONFIG_CONSOLE_WIDTH 16 | #define CATCH_CONFIG_CONSOLE_WIDTH 80 17 | #endif 18 | 19 | #endif // CATCH_CONSOLE_WIDTH_HPP_INCLUDED 20 | -------------------------------------------------------------------------------- /test/catch/tests/SelfTest/UsageTests/VariadicMacros.tests.cpp: -------------------------------------------------------------------------------- 1 | 2 | // Copyright Catch2 Authors 3 | // Distributed under the Boost Software License, Version 1.0. 4 | // (See accompanying file LICENSE.txt or copy at 5 | // https://www.boost.org/LICENSE_1_0.txt) 6 | 7 | // SPDX-License-Identifier: BSL-1.0 8 | 9 | #include 10 | 11 | 12 | TEST_CASE() 13 | { 14 | SUCCEED( "anonymous test case" ); 15 | } 16 | 17 | TEST_CASE( "Test case with one argument" ) 18 | { 19 | SUCCEED( "no assertions" ); 20 | } 21 | 22 | TEST_CASE( "Variadic macros", "[variadic][sections]" ) 23 | { 24 | SECTION( "Section with one argument" ) 25 | { 26 | SUCCEED( "no assertions" ); 27 | } 28 | } 29 | 30 | -------------------------------------------------------------------------------- /test/catch/tests/SelfTest/helpers/parse_test_spec.cpp: -------------------------------------------------------------------------------- 1 | 2 | // Copyright Catch2 Authors 3 | // Distributed under the Boost Software License, Version 1.0. 4 | // (See accompanying file LICENSE.txt or copy at 5 | // https://www.boost.org/LICENSE_1_0.txt) 6 | 7 | // SPDX-License-Identifier: BSL-1.0 8 | 9 | #include 10 | 11 | #include 12 | #include 13 | 14 | namespace Catch { 15 | 16 | TestSpec parseTestSpec( std::string const& arg ) { 17 | return TestSpecParser( ITagAliasRegistry::get() ) 18 | .parse( arg ) 19 | .testSpec(); 20 | } 21 | 22 | } // namespace Catch 23 | -------------------------------------------------------------------------------- /test/catch/tests/TestScripts/DiscoverTests/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required(VERSION 3.16) 2 | 3 | project(discover-tests-test 4 | LANGUAGES CXX 5 | ) 6 | 7 | add_executable(tests 8 | register-tests.cpp 9 | ) 10 | 11 | add_subdirectory(${CATCH2_PATH} catch2-build) 12 | target_link_libraries(tests PRIVATE Catch2::Catch2WithMain) 13 | 14 | enable_testing() 15 | include(Catch) 16 | set(extra_args) 17 | if (CMAKE_VERSION GREATER_EQUAL 3.27) 18 | list(APPEND extra_args 19 | DL_PATHS "${CMAKE_CURRENT_LIST_DIR};${CMAKE_CURRENT_LIST_DIR}/.." 20 | ) 21 | endif () 22 | catch_discover_tests( 23 | tests 24 | ADD_TAGS_AS_LABELS 25 | DISCOVERY_MODE PRE_TEST 26 | ${extra_args} 27 | ) 28 | 29 | # DISCOVERY_MODE 30 | -------------------------------------------------------------------------------- /test/catch/src/catch2/internal/catch_void_type.hpp: -------------------------------------------------------------------------------- 1 | 2 | // Copyright Catch2 Authors 3 | // Distributed under the Boost Software License, Version 1.0. 4 | // (See accompanying file LICENSE.txt or copy at 5 | // https://www.boost.org/LICENSE_1_0.txt) 6 | 7 | // SPDX-License-Identifier: BSL-1.0 8 | #ifndef CATCH_VOID_TYPE_HPP_INCLUDED 9 | #define CATCH_VOID_TYPE_HPP_INCLUDED 10 | 11 | 12 | namespace Catch { 13 | namespace Detail { 14 | 15 | template 16 | struct make_void { using type = void; }; 17 | 18 | template 19 | using void_t = typename make_void::type; 20 | 21 | } // namespace Detail 22 | } // namespace Catch 23 | 24 | 25 | #endif // CATCH_VOID_TYPE_HPP_INCLUDED 26 | -------------------------------------------------------------------------------- /test/catch/src/catch2/matchers/catch_matchers.cpp: -------------------------------------------------------------------------------- 1 | 2 | // Copyright Catch2 Authors 3 | // Distributed under the Boost Software License, Version 1.0. 4 | // (See accompanying file LICENSE.txt or copy at 5 | // https://www.boost.org/LICENSE_1_0.txt) 6 | 7 | // SPDX-License-Identifier: BSL-1.0 8 | 9 | 10 | #include 11 | 12 | namespace Catch { 13 | namespace Matchers { 14 | 15 | std::string MatcherUntypedBase::toString() const { 16 | if (m_cachedToString.empty()) { 17 | m_cachedToString = describe(); 18 | } 19 | return m_cachedToString; 20 | } 21 | 22 | MatcherUntypedBase::~MatcherUntypedBase() = default; 23 | 24 | } // namespace Matchers 25 | } // namespace Catch 26 | -------------------------------------------------------------------------------- /test/catch/tests/ExtraTests/X33-DuplicatedTestCaseMethods.cpp: -------------------------------------------------------------------------------- 1 | 2 | // Copyright Catch2 Authors 3 | // Distributed under the Boost Software License, Version 1.0. 4 | // (See accompanying file LICENSE.txt or copy at 5 | // https://www.boost.org/LICENSE_1_0.txt) 6 | 7 | // SPDX-License-Identifier: BSL-1.0 8 | 9 | /**\file 10 | * Checks that test case methods with identical class, name and tags are 11 | * reported as error. 12 | */ 13 | 14 | #include 15 | 16 | class TestCaseFixture { 17 | public: 18 | int m_a; 19 | }; 20 | 21 | TEST_CASE_METHOD(TestCaseFixture, "A test case with duplicated name and tags", "[tag1]") {} 22 | TEST_CASE_METHOD(TestCaseFixture, "A test case with duplicated name and tags", "[tag1]") {} 23 | -------------------------------------------------------------------------------- /test/catch/SECURITY.md: -------------------------------------------------------------------------------- 1 | # Security Policy 2 | 3 | ## Supported Versions 4 | 5 | * Versions 1.x (branch Catch1.x) are no longer supported. 6 | * Versions 2.x (branch v2.x) are currently supported. 7 | * `devel` branch serves for stable-ish development and is supported, 8 | but branches `devel-*` are considered short lived and are not supported separately. 9 | 10 | 11 | ## Reporting a Vulnerability 12 | 13 | Due to its nature as a _unit_ test framework, Catch2 shouldn't interact 14 | with untrusted inputs and there shouldn't be many security vulnerabilities 15 | in it. 16 | 17 | However, if you find one you send email to martin horenovsky 18 | gmail com. If you want to encrypt the email, my pgp key is 19 | `E29C 46F3 B8A7 5028 6079 3B7D ECC9 C20E 314B 2360`. 20 | -------------------------------------------------------------------------------- /test/catch/tests/SelfTest/TimingTests/Sleep.tests.cpp: -------------------------------------------------------------------------------- 1 | 2 | // Copyright Catch2 Authors 3 | // Distributed under the Boost Software License, Version 1.0. 4 | // (See accompanying file LICENSE.txt or copy at 5 | // https://www.boost.org/LICENSE_1_0.txt) 6 | 7 | // SPDX-License-Identifier: BSL-1.0 8 | 9 | #include 10 | 11 | #include 12 | #include 13 | 14 | TEST_CASE( "sleep_for_100ms", "[.min_duration_test][approvals]" ) 15 | { 16 | std::this_thread::sleep_for( std::chrono::milliseconds( 100 ) ); 17 | CHECK( true ); 18 | } 19 | 20 | TEST_CASE( "sleep_for_1000ms", "[.min_duration_test][approvals]" ) 21 | { 22 | std::this_thread::sleep_for( std::chrono::milliseconds( 1'000 ) ); 23 | CHECK( true ); 24 | } 25 | -------------------------------------------------------------------------------- /test/catch/src/catch2/catch_translate_exception.cpp: -------------------------------------------------------------------------------- 1 | 2 | // Copyright Catch2 Authors 3 | // Distributed under the Boost Software License, Version 1.0. 4 | // (See accompanying file LICENSE.txt or copy at 5 | // https://www.boost.org/LICENSE_1_0.txt) 6 | 7 | // SPDX-License-Identifier: BSL-1.0 8 | 9 | #include 10 | #include 11 | 12 | namespace Catch { 13 | namespace Detail { 14 | void registerTranslatorImpl( 15 | Detail::unique_ptr&& translator ) { 16 | getMutableRegistryHub().registerTranslator( 17 | CATCH_MOVE( translator ) ); 18 | } 19 | } // namespace Detail 20 | } // namespace Catch 21 | -------------------------------------------------------------------------------- /test/catch/src/catch2/internal/catch_stdstreams.cpp: -------------------------------------------------------------------------------- 1 | 2 | // Copyright Catch2 Authors 3 | // Distributed under the Boost Software License, Version 1.0. 4 | // (See accompanying file LICENSE.txt or copy at 5 | // https://www.boost.org/LICENSE_1_0.txt) 6 | 7 | // SPDX-License-Identifier: BSL-1.0 8 | 9 | #include 10 | 11 | #include 12 | 13 | #include 14 | 15 | namespace Catch { 16 | 17 | // If you #define this you must implement these functions 18 | #if !defined( CATCH_CONFIG_NOSTDOUT ) 19 | std::ostream& cout() { return std::cout; } 20 | std::ostream& cerr() { return std::cerr; } 21 | std::ostream& clog() { return std::clog; } 22 | #endif 23 | 24 | } // namespace Catch 25 | -------------------------------------------------------------------------------- /test/catch/src/catch2/interfaces/catch_interfaces_test_invoker.hpp: -------------------------------------------------------------------------------- 1 | 2 | // Copyright Catch2 Authors 3 | // Distributed under the Boost Software License, Version 1.0. 4 | // (See accompanying file LICENSE.txt or copy at 5 | // https://www.boost.org/LICENSE_1_0.txt) 6 | 7 | // SPDX-License-Identifier: BSL-1.0 8 | #ifndef CATCH_INTERFACES_TEST_INVOKER_HPP_INCLUDED 9 | #define CATCH_INTERFACES_TEST_INVOKER_HPP_INCLUDED 10 | 11 | namespace Catch { 12 | 13 | class ITestInvoker { 14 | public: 15 | virtual void prepareTestCase(); 16 | virtual void tearDownTestCase(); 17 | virtual void invoke() const = 0; 18 | virtual ~ITestInvoker(); // = default 19 | }; 20 | 21 | } // namespace Catch 22 | 23 | #endif // CATCH_INTERFACES_TEST_INVOKER_HPP_INCLUDED 24 | -------------------------------------------------------------------------------- /test/catch/tests/ExtraTests/X12-CustomDebugBreakMacro.cpp: -------------------------------------------------------------------------------- 1 | 2 | // Copyright Catch2 Authors 3 | // Distributed under the Boost Software License, Version 1.0. 4 | // (See accompanying file LICENSE.txt or copy at 5 | // https://www.boost.org/LICENSE_1_0.txt) 6 | 7 | // SPDX-License-Identifier: BSL-1.0 8 | 9 | /**\file 10 | * Test that user-defined `CATCH_BREAK_INTO_DEBUGGER` is respected and used. 11 | */ 12 | 13 | #include 14 | 15 | void custom_debug_break() { 16 | std::cerr << "Pretty please, break into debugger\n"; 17 | } 18 | 19 | #define CATCH_BREAK_INTO_DEBUGGER() custom_debug_break() 20 | 21 | #define CATCH_CONFIG_MAIN 22 | #include 23 | 24 | TEST_CASE("Failing test that breaks into debugger", "[macros]") { 25 | REQUIRE(1 == 2); 26 | } 27 | -------------------------------------------------------------------------------- /test/catch/tests/ExtraTests/X11-DisableStringification.cpp: -------------------------------------------------------------------------------- 1 | 2 | // Copyright Catch2 Authors 3 | // Distributed under the Boost Software License, Version 1.0. 4 | // (See accompanying file LICENSE.txt or copy at 5 | // https://www.boost.org/LICENSE_1_0.txt) 6 | 7 | // SPDX-License-Identifier: BSL-1.0 8 | 9 | /**\file 10 | * Test that stringification of original expression can be disabled. 11 | * 12 | * This is a workaround for VS 2017, 2019 issue with Raw String literals 13 | * and preprocessor token pasting. 14 | */ 15 | 16 | 17 | #include 18 | 19 | namespace { 20 | struct Hidden {}; 21 | 22 | bool operator==(Hidden, Hidden) { return true; } 23 | } 24 | 25 | TEST_CASE("DisableStringification") { 26 | REQUIRE( Hidden{} == Hidden{} ); 27 | } 28 | -------------------------------------------------------------------------------- /test/catch/.gitignore: -------------------------------------------------------------------------------- 1 | *.build 2 | !meson.build 3 | *.pbxuser 4 | *.mode1v3 5 | *.ncb 6 | *.suo 7 | Debug 8 | Release 9 | *.user 10 | *.xcuserstate 11 | .DS_Store 12 | xcuserdata 13 | CatchSelfTest.xcscheme 14 | Breakpoints.xcbkptlist 15 | UpgradeLog.XML 16 | Resources/DWARF 17 | projects/Generated 18 | *.pyc 19 | DerivedData 20 | *.xccheckout 21 | Build 22 | .idea 23 | .vs 24 | .vscode 25 | cmake-build-* 26 | benchmark-dir 27 | .conan/test_package/build 28 | **/CMakeUserPresets.json 29 | bazel-* 30 | MODULE.bazel.lock 31 | build-fuzzers 32 | debug-build 33 | .vscode 34 | msvc-sln* 35 | # Currently we use Doxygen for dep graphs and the full docs are only slowly 36 | # being filled in, so we definitely do not want git to deal with the docs. 37 | docs/doxygen 38 | *.cache 39 | compile_commands.json 40 | **/*.unapproved.txt 41 | -------------------------------------------------------------------------------- /test/catch/src/catch2/reporters/catch_reporter_streaming_base.cpp: -------------------------------------------------------------------------------- 1 | 2 | // Copyright Catch2 Authors 3 | // Distributed under the Boost Software License, Version 1.0. 4 | // (See accompanying file LICENSE.txt or copy at 5 | // https://www.boost.org/LICENSE_1_0.txt) 6 | 7 | // SPDX-License-Identifier: BSL-1.0 8 | #include 9 | 10 | namespace Catch { 11 | 12 | StreamingReporterBase::~StreamingReporterBase() = default; 13 | 14 | void 15 | StreamingReporterBase::testRunStarting( TestRunInfo const& _testRunInfo ) { 16 | currentTestRunInfo = _testRunInfo; 17 | } 18 | 19 | void StreamingReporterBase::testRunEnded( TestRunStats const& ) { 20 | currentTestCaseInfo = nullptr; 21 | } 22 | 23 | } // end namespace Catch 24 | -------------------------------------------------------------------------------- /test/catch/src/catch2/benchmark/catch_estimate.hpp: -------------------------------------------------------------------------------- 1 | 2 | // Copyright Catch2 Authors 3 | // Distributed under the Boost Software License, Version 1.0. 4 | // (See accompanying file LICENSE.txt or copy at 5 | // https://www.boost.org/LICENSE_1_0.txt) 6 | 7 | // SPDX-License-Identifier: BSL-1.0 8 | // Adapted from donated nonius code. 9 | 10 | #ifndef CATCH_ESTIMATE_HPP_INCLUDED 11 | #define CATCH_ESTIMATE_HPP_INCLUDED 12 | 13 | namespace Catch { 14 | namespace Benchmark { 15 | template 16 | struct Estimate { 17 | Type point; 18 | Type lower_bound; 19 | Type upper_bound; 20 | double confidence_interval; 21 | }; 22 | } // namespace Benchmark 23 | } // namespace Catch 24 | 25 | #endif // CATCH_ESTIMATE_HPP_INCLUDED 26 | -------------------------------------------------------------------------------- /test/catch/tools/misc/appveyorTestRunScript.bat: -------------------------------------------------------------------------------- 1 | SETLOCAL EnableDelayedExpansion 2 | 3 | rem Disable launching the JIT debugger for ctest.exe 4 | reg add "HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion\AeDebug\AutoExclusionList" /v "ctest.ext" /t REG_DWORD /d 1 5 | cd Build 6 | if "%CONFIGURATION%"=="Debug" ( 7 | if "%coverage%"=="1" ( 8 | ctest -j 2 -C %CONFIGURATION% -D ExperimentalMemCheck -LE uses-signals || exit /b !ERRORLEVEL! 9 | python ..\tools\misc\appveyorMergeCoverageScript.py || exit /b !ERRORLEVEL! 10 | codecov --root .. --no-color --disable gcov -f cobertura.xml -t %CODECOV_TOKEN% || exit /b !ERRORLEVEL! 11 | ) else ( 12 | ctest -j 2 -C %CONFIGURATION% || exit /b !ERRORLEVEL! 13 | ) 14 | ) 15 | if "%CONFIGURATION%"=="Release" ( 16 | ctest -j 2 -C %CONFIGURATION% || exit /b !ERRORLEVEL! 17 | ) 18 | -------------------------------------------------------------------------------- /test/catch/src/catch2/internal/catch_preprocessor_internal_stringify.hpp: -------------------------------------------------------------------------------- 1 | 2 | // Copyright Catch2 Authors 3 | // Distributed under the Boost Software License, Version 1.0. 4 | // (See accompanying file LICENSE.txt or copy at 5 | // https://www.boost.org/LICENSE_1_0.txt) 6 | 7 | // SPDX-License-Identifier: BSL-1.0 8 | #ifndef CATCH_PREPROCESSOR_INTERNAL_STRINGIFY_HPP_INCLUDED 9 | #define CATCH_PREPROCESSOR_INTERNAL_STRINGIFY_HPP_INCLUDED 10 | 11 | #include 12 | 13 | #if !defined(CATCH_CONFIG_DISABLE_STRINGIFICATION) 14 | #define CATCH_INTERNAL_STRINGIFY(...) #__VA_ARGS__##_catch_sr 15 | #else 16 | #define CATCH_INTERNAL_STRINGIFY(...) "Disabled by CATCH_CONFIG_DISABLE_STRINGIFICATION"_catch_sr 17 | #endif 18 | 19 | #endif // CATCH_PREPROCESSOR_INTERNAL_STRINGIFY_HPP_INCLUDED 20 | -------------------------------------------------------------------------------- /test/catch/fuzzing/NullOStream.h: -------------------------------------------------------------------------------- 1 | 2 | // Copyright Catch2 Authors 3 | // Distributed under the Boost Software License, Version 1.0. 4 | // (See accompanying file LICENSE.txt or copy at 5 | // https://www.boost.org/LICENSE_1_0.txt) 6 | 7 | // SPDX-License-Identifier: BSL-1.0 8 | 9 | #pragma once 10 | 11 | #include 12 | #include 13 | 14 | // from https://stackoverflow.com/a/8244052 15 | class NullStreambuf : public std::streambuf { 16 | char dummyBuffer[64]; 17 | 18 | protected: 19 | virtual int overflow(int c) override final; 20 | }; 21 | 22 | class NullOStream final : private NullStreambuf, public std::ostream { 23 | public: 24 | NullOStream() : std::ostream(this) {} 25 | NullStreambuf *rdbuf() { return this; } 26 | virtual void avoidOutOfLineVirtualCompilerWarning(); 27 | }; 28 | 29 | -------------------------------------------------------------------------------- /test/catch/src/catch2/internal/catch_move_and_forward.hpp: -------------------------------------------------------------------------------- 1 | 2 | // Copyright Catch2 Authors 3 | // Distributed under the Boost Software License, Version 1.0. 4 | // (See accompanying file LICENSE.txt or copy at 5 | // https://www.boost.org/LICENSE_1_0.txt) 6 | 7 | // SPDX-License-Identifier: BSL-1.0 8 | #ifndef CATCH_MOVE_AND_FORWARD_HPP_INCLUDED 9 | #define CATCH_MOVE_AND_FORWARD_HPP_INCLUDED 10 | 11 | #include 12 | 13 | //! Replacement for std::move with better compile time performance 14 | #define CATCH_MOVE(...) static_cast&&>(__VA_ARGS__) 15 | 16 | //! Replacement for std::forward with better compile time performance 17 | #define CATCH_FORWARD(...) static_cast(__VA_ARGS__) 18 | 19 | #endif // CATCH_MOVE_AND_FORWARD_HPP_INCLUDED 20 | -------------------------------------------------------------------------------- /test/catch/src/catch2/internal/catch_random_seed_generation.hpp: -------------------------------------------------------------------------------- 1 | 2 | // Copyright Catch2 Authors 3 | // Distributed under the Boost Software License, Version 1.0. 4 | // (See accompanying file LICENSE.txt or copy at 5 | // https://www.boost.org/LICENSE_1_0.txt) 6 | 7 | // SPDX-License-Identifier: BSL-1.0 8 | #ifndef CATCH_RANDOM_SEED_GENERATION_HPP_INCLUDED 9 | #define CATCH_RANDOM_SEED_GENERATION_HPP_INCLUDED 10 | 11 | #include 12 | 13 | namespace Catch { 14 | 15 | enum class GenerateFrom { 16 | Time, 17 | RandomDevice, 18 | //! Currently equivalent to RandomDevice, but can change at any point 19 | Default 20 | }; 21 | 22 | std::uint32_t generateRandomSeed(GenerateFrom from); 23 | 24 | } // end namespace Catch 25 | 26 | #endif // CATCH_RANDOM_SEED_GENERATION_HPP_INCLUDED 27 | -------------------------------------------------------------------------------- /test/catch/fuzzing/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # License: Boost 1.0 2 | # By Paul Dreik 2020 3 | 4 | # add a library that brings in the main() function from libfuzzer 5 | # and has all the dependencies, so the individual fuzzers can be 6 | # added one line each. 7 | add_library(fuzzhelper NullOStream.h NullOStream.cpp) 8 | target_link_libraries(fuzzhelper PUBLIC Catch2::Catch2) 9 | 10 | # use C++17 so we can get string_view 11 | target_compile_features(fuzzhelper PUBLIC cxx_std_17) 12 | 13 | # This should be possible to set from the outside to be oss-fuzz compatible, 14 | # fix later. For now, target libFuzzer only. 15 | target_link_options(fuzzhelper PUBLIC "-fsanitize=fuzzer") 16 | 17 | foreach(fuzzer TestSpecParser XmlWriter textflow) 18 | add_executable(fuzz_${fuzzer} fuzz_${fuzzer}.cpp) 19 | target_link_libraries(fuzz_${fuzzer} PRIVATE fuzzhelper) 20 | endforeach() 21 | -------------------------------------------------------------------------------- /test/catch/src/catch2/catch_tag_alias.hpp: -------------------------------------------------------------------------------- 1 | 2 | // Copyright Catch2 Authors 3 | // Distributed under the Boost Software License, Version 1.0. 4 | // (See accompanying file LICENSE.txt or copy at 5 | // https://www.boost.org/LICENSE_1_0.txt) 6 | 7 | // SPDX-License-Identifier: BSL-1.0 8 | #ifndef CATCH_TAG_ALIAS_HPP_INCLUDED 9 | #define CATCH_TAG_ALIAS_HPP_INCLUDED 10 | 11 | #include 12 | 13 | #include 14 | 15 | namespace Catch { 16 | 17 | struct TagAlias { 18 | TagAlias(std::string const& _tag, SourceLineInfo _lineInfo): 19 | tag(_tag), 20 | lineInfo(_lineInfo) 21 | {} 22 | 23 | std::string tag; 24 | SourceLineInfo lineInfo; 25 | }; 26 | 27 | } // end namespace Catch 28 | 29 | #endif // CATCH_TAG_ALIAS_HPP_INCLUDED 30 | -------------------------------------------------------------------------------- /test/catch/src/catch2/internal/catch_errno_guard.hpp: -------------------------------------------------------------------------------- 1 | 2 | // Copyright Catch2 Authors 3 | // Distributed under the Boost Software License, Version 1.0. 4 | // (See accompanying file LICENSE.txt or copy at 5 | // https://www.boost.org/LICENSE_1_0.txt) 6 | 7 | // SPDX-License-Identifier: BSL-1.0 8 | #ifndef CATCH_ERRNO_GUARD_HPP_INCLUDED 9 | #define CATCH_ERRNO_GUARD_HPP_INCLUDED 10 | 11 | namespace Catch { 12 | 13 | //! Simple RAII class that stores the value of `errno` 14 | //! at construction and restores it at destruction. 15 | class ErrnoGuard { 16 | public: 17 | // Keep these outlined to avoid dragging in macros from 18 | 19 | ErrnoGuard(); 20 | ~ErrnoGuard(); 21 | private: 22 | int m_oldErrno; 23 | }; 24 | 25 | } 26 | 27 | #endif // CATCH_ERRNO_GUARD_HPP_INCLUDED 28 | -------------------------------------------------------------------------------- /test/catch/src/catch2/catch_timer.hpp: -------------------------------------------------------------------------------- 1 | 2 | // Copyright Catch2 Authors 3 | // Distributed under the Boost Software License, Version 1.0. 4 | // (See accompanying file LICENSE.txt or copy at 5 | // https://www.boost.org/LICENSE_1_0.txt) 6 | 7 | // SPDX-License-Identifier: BSL-1.0 8 | #ifndef CATCH_TIMER_HPP_INCLUDED 9 | #define CATCH_TIMER_HPP_INCLUDED 10 | 11 | #include 12 | 13 | namespace Catch { 14 | 15 | class Timer { 16 | uint64_t m_nanoseconds = 0; 17 | public: 18 | void start(); 19 | auto getElapsedNanoseconds() const -> uint64_t; 20 | auto getElapsedMicroseconds() const -> uint64_t; 21 | auto getElapsedMilliseconds() const -> unsigned int; 22 | auto getElapsedSeconds() const -> double; 23 | }; 24 | 25 | } // namespace Catch 26 | 27 | #endif // CATCH_TIMER_HPP_INCLUDED 28 | -------------------------------------------------------------------------------- /test/catch/src/catch2/benchmark/detail/catch_benchmark_function.cpp: -------------------------------------------------------------------------------- 1 | 2 | // Copyright Catch2 Authors 3 | // Distributed under the Boost Software License, Version 1.0. 4 | // (See accompanying file LICENSE.txt or copy at 5 | // https://www.boost.org/LICENSE_1_0.txt) 6 | 7 | // SPDX-License-Identifier: BSL-1.0 8 | 9 | #include 10 | 11 | namespace Catch { 12 | namespace Benchmark { 13 | namespace Detail { 14 | struct do_nothing { 15 | void operator()() const {} 16 | }; 17 | 18 | BenchmarkFunction::callable::~callable() = default; 19 | BenchmarkFunction::BenchmarkFunction(): 20 | f( new model{ {} } ){} 21 | } // namespace Detail 22 | } // namespace Benchmark 23 | } // namespace Catch 24 | -------------------------------------------------------------------------------- /test/catch/.github/ISSUE_TEMPLATE/bug_report.md: -------------------------------------------------------------------------------- 1 | --- 2 | name: Bug report 3 | about: Create an issue that documents a bug 4 | title: '' 5 | labels: '' 6 | assignees: '' 7 | 8 | --- 9 | 10 | **Describe the bug** 11 | A clear and concise description of what the bug is. 12 | 13 | **Expected behavior** 14 | A clear and concise description of what you expected to happen. 15 | 16 | **Reproduction steps** 17 | Steps to reproduce the bug. 18 | 19 | 20 | 21 | **Platform information:** 22 | 23 | - OS: **Windows NT** 24 | - Compiler+version: **GCC v2.9.5** 25 | - Catch version: **v1.2.3** 26 | 27 | 28 | **Additional context** 29 | Add any other context about the problem here. 30 | -------------------------------------------------------------------------------- /test/catch/.github/workflows/package-manager-builds.yaml: -------------------------------------------------------------------------------- 1 | name: Package Manager Builds 2 | 3 | on: [push, pull_request] 4 | 5 | jobs: 6 | conan_builds: 7 | name: Conan ${{matrix.conan_version}} 8 | runs-on: ubuntu-20.04 9 | strategy: 10 | matrix: 11 | conan_version: 12 | - '1.63' 13 | - '2.1' 14 | 15 | include: 16 | # Conan 1 has default profiles installed 17 | - conan_version: '1.63' 18 | profile_generate: 'false' 19 | 20 | steps: 21 | - uses: actions/checkout@v4 22 | 23 | - name: Install conan 24 | run: pip install conan==${{matrix.conan_version}} 25 | 26 | - name: Setup conan profiles 27 | if: matrix.profile_generate != 'false' 28 | run: conan profile detect 29 | 30 | - name: Run conan package create 31 | run: conan create . -tf .conan/test_package 32 | -------------------------------------------------------------------------------- /test/catch/src/catch2/matchers/catch_matchers_exception.cpp: -------------------------------------------------------------------------------- 1 | 2 | // Copyright Catch2 Authors 3 | // Distributed under the Boost Software License, Version 1.0. 4 | // (See accompanying file LICENSE.txt or copy at 5 | // https://www.boost.org/LICENSE_1_0.txt) 6 | 7 | // SPDX-License-Identifier: BSL-1.0 8 | #include 9 | 10 | namespace Catch { 11 | namespace Matchers { 12 | 13 | bool ExceptionMessageMatcher::match(std::exception const& ex) const { 14 | return ex.what() == m_message; 15 | } 16 | 17 | std::string ExceptionMessageMatcher::describe() const { 18 | return "exception message matches \"" + m_message + '"'; 19 | } 20 | 21 | ExceptionMessageMatcher Message(std::string const& message) { 22 | return ExceptionMessageMatcher(message); 23 | } 24 | 25 | } // namespace Matchers 26 | } // namespace Catch 27 | -------------------------------------------------------------------------------- /tools/gha_osx_clang_16.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | # Echo each command 4 | set -x 5 | 6 | # Exit on error. 7 | set -e 8 | 9 | # Install conda+deps. 10 | wget https://github.com/conda-forge/miniforge/releases/latest/download/Miniforge3-MacOSX-x86_64.sh -O miniconda.sh 11 | export deps_dir=$HOME/local 12 | export PATH="$HOME/miniconda/bin:$PATH" 13 | bash miniconda.sh -b -p $HOME/miniconda 14 | mamba create -y -q -p $deps_dir 'clangxx=16.*' cmake libboost-devel ninja 15 | source activate $deps_dir 16 | 17 | # Create the build dir and cd into it. 18 | mkdir build 19 | cd build 20 | 21 | cmake -G Ninja ../ -DCMAKE_PREFIX_PATH=$deps_dir \ 22 | -DCMAKE_CXX_COMPILER=clang++ \ 23 | -DCMAKE_BUILD_TYPE=Debug \ 24 | -DTANUKI_BUILD_TESTS=yes \ 25 | -DTANUKI_BUILD_TUTORIALS=yes \ 26 | -DTANUKI_WITH_BOOST_S11N=yes 27 | ninja 28 | ctest -V -j4 29 | 30 | set +e 31 | set +x 32 | -------------------------------------------------------------------------------- /test/catch/src/catch2/internal/catch_test_case_info_hasher.hpp: -------------------------------------------------------------------------------- 1 | 2 | // Copyright Catch2 Authors 3 | // Distributed under the Boost Software License, Version 1.0. 4 | // (See accompanying file LICENSE.txt or copy at 5 | // https://www.boost.org/LICENSE_1_0.txt) 6 | 7 | // SPDX-License-Identifier: BSL-1.0 8 | #ifndef CATCH_TEST_CASE_INFO_HASHER_HPP_INCLUDED 9 | #define CATCH_TEST_CASE_INFO_HASHER_HPP_INCLUDED 10 | 11 | #include 12 | 13 | namespace Catch { 14 | 15 | struct TestCaseInfo; 16 | 17 | class TestCaseInfoHasher { 18 | public: 19 | using hash_t = std::uint64_t; 20 | TestCaseInfoHasher( hash_t seed ); 21 | uint32_t operator()( TestCaseInfo const& t ) const; 22 | 23 | private: 24 | hash_t m_seed; 25 | }; 26 | 27 | } // namespace Catch 28 | 29 | #endif /* CATCH_TEST_CASE_INFO_HASHER_HPP_INCLUDED */ 30 | -------------------------------------------------------------------------------- /test/catch/src/catch2/internal/catch_uncaught_exceptions.cpp: -------------------------------------------------------------------------------- 1 | 2 | // Copyright Catch2 Authors 3 | // Distributed under the Boost Software License, Version 1.0. 4 | // (See accompanying file LICENSE.txt or copy at 5 | // https://www.boost.org/LICENSE_1_0.txt) 6 | 7 | // SPDX-License-Identifier: BSL-1.0 8 | 9 | #include 10 | #include 11 | #include 12 | 13 | #include 14 | 15 | namespace Catch { 16 | bool uncaught_exceptions() { 17 | #if defined(CATCH_CONFIG_DISABLE_EXCEPTIONS) 18 | return false; 19 | #elif defined(CATCH_CONFIG_CPP17_UNCAUGHT_EXCEPTIONS) 20 | return std::uncaught_exceptions() > 0; 21 | #else 22 | return std::uncaught_exception(); 23 | #endif 24 | } 25 | } // end namespace Catch 26 | -------------------------------------------------------------------------------- /test/catch/tests/ExtraTests/X34-DuplicatedTestCaseMethodsDifferentFixtures.cpp: -------------------------------------------------------------------------------- 1 | 2 | // Copyright Catch2 Authors 3 | // Distributed under the Boost Software License, Version 1.0. 4 | // (See accompanying file LICENSE.txt or copy at 5 | // https://www.boost.org/LICENSE_1_0.txt) 6 | 7 | // SPDX-License-Identifier: BSL-1.0 8 | 9 | /**\file 10 | * Checks that test case methods with different class, but same name and 11 | * tags name and tags are not reported as error. 12 | */ 13 | 14 | #include 15 | 16 | class TestCaseFixture1 { 17 | public: 18 | int m_a; 19 | }; 20 | 21 | class TestCaseFixture2 { 22 | public: 23 | int m_a; 24 | }; 25 | 26 | TEST_CASE_METHOD(TestCaseFixture1, "A test case with duplicated name and tags", "[tag1]") {} 27 | TEST_CASE_METHOD(TestCaseFixture2, "A test case with duplicated name and tags", "[tag1]") {} 28 | -------------------------------------------------------------------------------- /test/catch/src/catch2/internal/catch_preprocessor_remove_parens.hpp: -------------------------------------------------------------------------------- 1 | 2 | // Copyright Catch2 Authors 3 | // Distributed under the Boost Software License, Version 1.0. 4 | // (See accompanying file LICENSE.txt or copy at 5 | // https://www.boost.org/LICENSE_1_0.txt) 6 | 7 | // SPDX-License-Identifier: BSL-1.0 8 | #ifndef CATCH_PREPROCESSOR_REMOVE_PARENS_HPP_INCLUDED 9 | #define CATCH_PREPROCESSOR_REMOVE_PARENS_HPP_INCLUDED 10 | 11 | #define INTERNAL_CATCH_EXPAND1( param ) INTERNAL_CATCH_EXPAND2( param ) 12 | #define INTERNAL_CATCH_EXPAND2( ... ) INTERNAL_CATCH_NO##__VA_ARGS__ 13 | #define INTERNAL_CATCH_DEF( ... ) INTERNAL_CATCH_DEF __VA_ARGS__ 14 | #define INTERNAL_CATCH_NOINTERNAL_CATCH_DEF 15 | 16 | #define INTERNAL_CATCH_REMOVE_PARENS( ... ) \ 17 | INTERNAL_CATCH_EXPAND1( INTERNAL_CATCH_DEF __VA_ARGS__ ) 18 | 19 | #endif // CATCH_PREPROCESSOR_REMOVE_PARENS_HPP_INCLUDED 20 | -------------------------------------------------------------------------------- /test/catch/src/catch2/internal/catch_message_info.cpp: -------------------------------------------------------------------------------- 1 | 2 | // Copyright Catch2 Authors 3 | // Distributed under the Boost Software License, Version 1.0. 4 | // (See accompanying file LICENSE.txt or copy at 5 | // https://www.boost.org/LICENSE_1_0.txt) 6 | 7 | // SPDX-License-Identifier: BSL-1.0 8 | 9 | #include 10 | 11 | namespace Catch { 12 | 13 | MessageInfo::MessageInfo( StringRef _macroName, 14 | SourceLineInfo const& _lineInfo, 15 | ResultWas::OfType _type ) 16 | : macroName( _macroName ), 17 | lineInfo( _lineInfo ), 18 | type( _type ), 19 | sequence( ++globalCount ) 20 | {} 21 | 22 | // This may need protecting if threading support is added 23 | unsigned int MessageInfo::globalCount = 0; 24 | 25 | } // end namespace Catch 26 | -------------------------------------------------------------------------------- /test/catch/src/catch2/benchmark/detail/catch_analyse.hpp: -------------------------------------------------------------------------------- 1 | 2 | // Copyright Catch2 Authors 3 | // Distributed under the Boost Software License, Version 1.0. 4 | // (See accompanying file LICENSE.txt or copy at 5 | // https://www.boost.org/LICENSE_1_0.txt) 6 | 7 | // SPDX-License-Identifier: BSL-1.0 8 | // Adapted from donated nonius code. 9 | 10 | #ifndef CATCH_ANALYSE_HPP_INCLUDED 11 | #define CATCH_ANALYSE_HPP_INCLUDED 12 | 13 | #include 14 | #include 15 | 16 | 17 | namespace Catch { 18 | class IConfig; 19 | 20 | namespace Benchmark { 21 | namespace Detail { 22 | SampleAnalysis analyse(const IConfig &cfg, FDuration* first, FDuration* last); 23 | } // namespace Detail 24 | } // namespace Benchmark 25 | } // namespace Catch 26 | 27 | #endif // CATCH_ANALYSE_HPP_INCLUDED 28 | -------------------------------------------------------------------------------- /test/catch/tests/SelfTest/UsageTests/ToStringByte.tests.cpp: -------------------------------------------------------------------------------- 1 | 2 | // Copyright Catch2 Authors 3 | // Distributed under the Boost Software License, Version 1.0. 4 | // (See accompanying file LICENSE.txt or copy at 5 | // https://www.boost.org/LICENSE_1_0.txt) 6 | 7 | // SPDX-License-Identifier: BSL-1.0 8 | 9 | #include 10 | 11 | #if defined(CATCH_CONFIG_CPP17_BYTE) 12 | 13 | TEST_CASE( "std::byte -> toString", "[toString][byte][approvals]" ) { 14 | using type = std::byte; 15 | REQUIRE( "0" == ::Catch::Detail::stringify( type{ 0 } ) ); 16 | } 17 | 18 | TEST_CASE( "std::vector -> toString", "[toString][byte][approvals]" ) { 19 | using type = std::vector; 20 | REQUIRE( "{ 0, 1, 2 }" == ::Catch::Detail::stringify( type{ std::byte{0}, std::byte{1}, std::byte{2} } ) ); 21 | } 22 | 23 | #endif // CATCH_INTERNAL_CONFIG_CPP17_BYTE 24 | -------------------------------------------------------------------------------- /tutorial/nonintrusive.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | #include 5 | 6 | namespace ns 7 | { 8 | 9 | // An existing OO interface. 10 | struct my_iface { 11 | virtual ~my_iface() = default; 12 | virtual int foo() const = 0; 13 | }; 14 | 15 | } // namespace ns 16 | 17 | namespace tanuki 18 | { 19 | 20 | // Non-intrusive implementation for the ns::my_iface interface. 21 | template 22 | struct iface_impl : public Base { 23 | int foo() const override 24 | { 25 | return 42; 26 | } 27 | }; 28 | 29 | } // namespace tanuki 30 | 31 | int main() 32 | { 33 | // Define a wrap for ns::my_iface. 34 | using wrap_t = tanuki::wrap; 35 | 36 | wrap_t w1(123); 37 | wrap_t w2(std::string("hello world!")); 38 | 39 | std::cout << "The final answer is " << w1->foo() << '\n'; 40 | } 41 | -------------------------------------------------------------------------------- /test/catch/src/catch2/benchmark/catch_clock.hpp: -------------------------------------------------------------------------------- 1 | 2 | // Copyright Catch2 Authors 3 | // Distributed under the Boost Software License, Version 1.0. 4 | // (See accompanying file LICENSE.txt or copy at 5 | // https://www.boost.org/LICENSE_1_0.txt) 6 | 7 | // SPDX-License-Identifier: BSL-1.0 8 | // Adapted from donated nonius code. 9 | 10 | #ifndef CATCH_CLOCK_HPP_INCLUDED 11 | #define CATCH_CLOCK_HPP_INCLUDED 12 | 13 | #include 14 | 15 | namespace Catch { 16 | namespace Benchmark { 17 | using IDuration = std::chrono::nanoseconds; 18 | using FDuration = std::chrono::duration; 19 | 20 | template 21 | using TimePoint = typename Clock::time_point; 22 | 23 | using default_clock = std::chrono::steady_clock; 24 | } // namespace Benchmark 25 | } // namespace Catch 26 | 27 | #endif // CATCH_CLOCK_HPP_INCLUDED 28 | -------------------------------------------------------------------------------- /test/catch/src/catch2/benchmark/detail/catch_benchmark_stats_fwd.hpp: -------------------------------------------------------------------------------- 1 | 2 | // Copyright Catch2 Authors 3 | // Distributed under the Boost Software License, Version 1.0. 4 | // (See accompanying file LICENSE.txt or copy at 5 | // https://www.boost.org/LICENSE_1_0.txt) 6 | 7 | // SPDX-License-Identifier: BSL-1.0 8 | #ifndef CATCH_BENCHMARK_STATS_FWD_HPP_INCLUDED 9 | #define CATCH_BENCHMARK_STATS_FWD_HPP_INCLUDED 10 | 11 | #include 12 | 13 | namespace Catch { 14 | 15 | // We cannot forward declare the type with default template argument 16 | // multiple times, so it is split out into a separate header so that 17 | // we can prevent multiple declarations in dependees 18 | template 19 | struct BenchmarkStats; 20 | 21 | } // end namespace Catch 22 | 23 | #endif // CATCH_BENCHMARK_STATS_FWD_HPP_INCLUDED 24 | -------------------------------------------------------------------------------- /test/catch/src/catch2/internal/catch_parse_numbers.hpp: -------------------------------------------------------------------------------- 1 | 2 | // Copyright Catch2 Authors 3 | // Distributed under the Boost Software License, Version 1.0. 4 | // (See accompanying file LICENSE.txt or copy at 5 | // https://www.boost.org/LICENSE_1_0.txt) 6 | 7 | // SPDX-License-Identifier: BSL-1.0 8 | #ifndef CATCH_PARSE_NUMBERS_HPP_INCLUDED 9 | #define CATCH_PARSE_NUMBERS_HPP_INCLUDED 10 | 11 | #include 12 | 13 | #include 14 | 15 | namespace Catch { 16 | 17 | /** 18 | * Parses unsigned int from the input, using provided base 19 | * 20 | * Effectively a wrapper around std::stoul but with better error checking 21 | * e.g. "-1" is rejected, instead of being parsed as UINT_MAX. 22 | */ 23 | Optional parseUInt(std::string const& input, int base = 10); 24 | } 25 | 26 | #endif // CATCH_PARSE_NUMBERS_HPP_INCLUDED 27 | -------------------------------------------------------------------------------- /test/catch/src/catch2/internal/catch_windows_h_proxy.hpp: -------------------------------------------------------------------------------- 1 | 2 | // Copyright Catch2 Authors 3 | // Distributed under the Boost Software License, Version 1.0. 4 | // (See accompanying file LICENSE.txt or copy at 5 | // https://www.boost.org/LICENSE_1_0.txt) 6 | 7 | // SPDX-License-Identifier: BSL-1.0 8 | #ifndef CATCH_WINDOWS_H_PROXY_HPP_INCLUDED 9 | #define CATCH_WINDOWS_H_PROXY_HPP_INCLUDED 10 | 11 | #include 12 | 13 | #if defined(CATCH_PLATFORM_WINDOWS) 14 | 15 | // We might end up with the define made globally through the compiler, 16 | // and we don't want to trigger warnings for this 17 | #if !defined(NOMINMAX) 18 | # define NOMINMAX 19 | #endif 20 | #if !defined(WIN32_LEAN_AND_MEAN) 21 | # define WIN32_LEAN_AND_MEAN 22 | #endif 23 | 24 | #include 25 | 26 | #endif // defined(CATCH_PLATFORM_WINDOWS) 27 | 28 | #endif // CATCH_WINDOWS_H_PROXY_HPP_INCLUDED 29 | -------------------------------------------------------------------------------- /test/catch/src/catch2/internal/catch_unique_name.hpp: -------------------------------------------------------------------------------- 1 | 2 | // Copyright Catch2 Authors 3 | // Distributed under the Boost Software License, Version 1.0. 4 | // (See accompanying file LICENSE.txt or copy at 5 | // https://www.boost.org/LICENSE_1_0.txt) 6 | 7 | // SPDX-License-Identifier: BSL-1.0 8 | #ifndef CATCH_UNIQUE_NAME_HPP_INCLUDED 9 | #define CATCH_UNIQUE_NAME_HPP_INCLUDED 10 | 11 | #include 12 | #define INTERNAL_CATCH_UNIQUE_NAME_LINE2( name, line ) name##line 13 | #define INTERNAL_CATCH_UNIQUE_NAME_LINE( name, line ) INTERNAL_CATCH_UNIQUE_NAME_LINE2( name, line ) 14 | #ifdef CATCH_CONFIG_COUNTER 15 | # define INTERNAL_CATCH_UNIQUE_NAME( name ) INTERNAL_CATCH_UNIQUE_NAME_LINE( name, __COUNTER__ ) 16 | #else 17 | # define INTERNAL_CATCH_UNIQUE_NAME( name ) INTERNAL_CATCH_UNIQUE_NAME_LINE( name, __LINE__ ) 18 | #endif 19 | 20 | #endif // CATCH_UNIQUE_NAME_HPP_INCLUDED 21 | -------------------------------------------------------------------------------- /test/catch/src/catch2/internal/catch_to_string.hpp: -------------------------------------------------------------------------------- 1 | 2 | // Copyright Catch2 Authors 3 | // Distributed under the Boost Software License, Version 1.0. 4 | // (See accompanying file LICENSE.txt or copy at 5 | // https://www.boost.org/LICENSE_1_0.txt) 6 | 7 | // SPDX-License-Identifier: BSL-1.0 8 | #ifndef CATCH_TO_STRING_HPP_INCLUDED 9 | #define CATCH_TO_STRING_HPP_INCLUDED 10 | 11 | #include 12 | 13 | #include 14 | #include 15 | 16 | namespace Catch { 17 | template 18 | std::string to_string(T const& t) { 19 | #if defined(CATCH_CONFIG_CPP11_TO_STRING) 20 | return std::to_string(t); 21 | #else 22 | ReusableStringStream rss; 23 | rss << t; 24 | return rss.str(); 25 | #endif 26 | } 27 | } // end namespace Catch 28 | 29 | #endif // CATCH_TO_STRING_HPP_INCLUDED 30 | -------------------------------------------------------------------------------- /test/catch/src/catch2/catch_assertion_info.hpp: -------------------------------------------------------------------------------- 1 | 2 | // Copyright Catch2 Authors 3 | // Distributed under the Boost Software License, Version 1.0. 4 | // (See accompanying file LICENSE.txt or copy at 5 | // https://www.boost.org/LICENSE_1_0.txt) 6 | 7 | // SPDX-License-Identifier: BSL-1.0 8 | #ifndef CATCH_ASSERTION_INFO_HPP_INCLUDED 9 | #define CATCH_ASSERTION_INFO_HPP_INCLUDED 10 | 11 | #include 12 | #include 13 | #include 14 | 15 | namespace Catch { 16 | 17 | struct AssertionInfo { 18 | // AssertionInfo() = delete; 19 | 20 | StringRef macroName; 21 | SourceLineInfo lineInfo; 22 | StringRef capturedExpression; 23 | ResultDisposition::Flags resultDisposition; 24 | }; 25 | 26 | } // end namespace Catch 27 | 28 | #endif // CATCH_ASSERTION_INFO_HPP_INCLUDED 29 | -------------------------------------------------------------------------------- /tools/gha_conda_gcc_10.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | # Echo each command 4 | set -x 5 | 6 | # Exit on error. 7 | set -e 8 | 9 | # Core deps. 10 | sudo apt-get install wget 11 | 12 | # Install conda+deps. 13 | wget https://github.com/conda-forge/miniforge/releases/latest/download/Miniforge3-Linux-x86_64.sh -O miniconda.sh 14 | export deps_dir=$HOME/local 15 | export PATH="$HOME/miniconda/bin:$PATH" 16 | bash miniconda.sh -b -p $HOME/miniconda 17 | mamba create -y -q -p $deps_dir 'gxx=10.*' cmake libboost-devel ninja 18 | source activate $deps_dir 19 | 20 | # Create the build dir and cd into it. 21 | mkdir build 22 | cd build 23 | 24 | # GCC build. 25 | cmake -G Ninja ../ -DCMAKE_PREFIX_PATH=$deps_dir \ 26 | -DCMAKE_CXX_COMPILER=g++ \ 27 | -DCMAKE_BUILD_TYPE=Debug \ 28 | -DTANUKI_BUILD_TESTS=yes \ 29 | -DTANUKI_BUILD_TUTORIALS=yes \ 30 | -DTANUKI_WITH_BOOST_S11N=yes 31 | ninja 32 | ctest -V -j4 33 | 34 | set +e 35 | set +x 36 | -------------------------------------------------------------------------------- /test/catch/tools/scripts/updateDocumentSnippets.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python3 2 | 3 | from scriptCommon import catchPath 4 | import os 5 | import subprocess 6 | 7 | # --------------------------------------------------- 8 | # Update code examples 9 | # --------------------------------------------------- 10 | # For info on mdsnippets, see https://github.com/SimonCropp/MarkdownSnippets 11 | 12 | # install dotnet SDK from http://go.microsoft.com/fwlink/?LinkID=798306&clcid=0x409 13 | # Then install MarkdownSnippets.Tool with 14 | # dotnet tool install -g MarkdownSnippets.Tool 15 | # To update: 16 | # dotnet tool update -g MarkdownSnippets.Tool 17 | # To uninstall (e.g. to downgrade to a lower version) 18 | # dotnet tool uninstall -g MarkdownSnippets.Tool 19 | 20 | os.chdir(catchPath) 21 | 22 | subprocess.run('dotnet tool update -g MarkdownSnippets.Tool --version 21.2.0', shell=True, check=True) 23 | subprocess.run('mdsnippets', shell=True, check=True) 24 | -------------------------------------------------------------------------------- /test/test_lib_s11n.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | #include 5 | 6 | #include "fooable.hpp" 7 | 8 | // NOLINTBEGIN(cert-err58-cpp,misc-use-anonymous-namespace,cppcoreguidelines-avoid-do-while) 9 | 10 | // A test to check that registering the serialisation for a wrap 11 | // in a separate library works as expected. 12 | TEST_CASE("test s11n") 13 | { 14 | fooable::foo_wrap f{fooable::foo_model{.n = 5}}; 15 | 16 | std::stringstream ss; 17 | 18 | { 19 | boost::archive::binary_oarchive oa(ss); 20 | oa << f; 21 | } 22 | 23 | value_ref(f).n = 0; 24 | 25 | { 26 | boost::archive::binary_iarchive ia(ss); 27 | ia >> f; 28 | } 29 | 30 | REQUIRE(value_ref(f).n == 5); 31 | } 32 | 33 | // NOLINTEND(cert-err58-cpp,misc-use-anonymous-namespace,cppcoreguidelines-avoid-do-while) 34 | -------------------------------------------------------------------------------- /doc/make.bat: -------------------------------------------------------------------------------- 1 | @ECHO OFF 2 | 3 | pushd %~dp0 4 | 5 | REM Command file for Sphinx documentation 6 | 7 | if "%SPHINXBUILD%" == "" ( 8 | set SPHINXBUILD=sphinx-build 9 | ) 10 | set SOURCEDIR=. 11 | set BUILDDIR=_build 12 | 13 | %SPHINXBUILD% >NUL 2>NUL 14 | if errorlevel 9009 ( 15 | echo. 16 | echo.The 'sphinx-build' command was not found. Make sure you have Sphinx 17 | echo.installed, then set the SPHINXBUILD environment variable to point 18 | echo.to the full path of the 'sphinx-build' executable. Alternatively you 19 | echo.may add the Sphinx directory to PATH. 20 | echo. 21 | echo.If you don't have Sphinx installed, grab it from 22 | echo.https://www.sphinx-doc.org/ 23 | exit /b 1 24 | ) 25 | 26 | if "%1" == "" goto help 27 | 28 | %SPHINXBUILD% -M %1 %SOURCEDIR% %BUILDDIR% %SPHINXOPTS% %O% 29 | goto end 30 | 31 | :help 32 | %SPHINXBUILD% -M help %SOURCEDIR% %BUILDDIR% %SPHINXOPTS% %O% 33 | 34 | :end 35 | popd 36 | -------------------------------------------------------------------------------- /tools/gha_osx_clang_18.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | # Echo each command 4 | set -x 5 | 6 | # Exit on error. 7 | set -e 8 | 9 | # Install conda+deps. 10 | wget https://github.com/conda-forge/miniforge/releases/latest/download/Miniforge3-MacOSX-x86_64.sh -O miniconda.sh 11 | export deps_dir=$HOME/local 12 | export PATH="$HOME/miniconda/bin:$PATH" 13 | bash miniconda.sh -b -p $HOME/miniconda 14 | mamba create -y -q -p $deps_dir 'clangxx=18.*' cmake libboost-devel ninja 15 | source activate $deps_dir 16 | 17 | # Create the build dir and cd into it. 18 | mkdir build 19 | cd build 20 | 21 | export CXXFLAGS="$CXXFLAGS -D_LIBCPP_DISABLE_AVAILABILITY" 22 | cmake -G Ninja ../ -DCMAKE_PREFIX_PATH=$deps_dir \ 23 | -DCMAKE_CXX_STANDARD=23 \ 24 | -DCMAKE_CXX_COMPILER=clang++ \ 25 | -DCMAKE_BUILD_TYPE=Debug \ 26 | -DTANUKI_BUILD_TESTS=yes \ 27 | -DTANUKI_BUILD_TUTORIALS=yes \ 28 | -DTANUKI_WITH_BOOST_S11N=yes 29 | ninja 30 | ctest -V -j4 31 | 32 | set +e 33 | set +x 34 | -------------------------------------------------------------------------------- /tools/gha_conda_tidy.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | # Echo each command 4 | set -x 5 | 6 | # Exit on error. 7 | set -e 8 | 9 | # Core deps. 10 | sudo apt-get install wget 11 | 12 | # Install conda+deps. 13 | wget https://github.com/conda-forge/miniforge/releases/latest/download/Miniforge3-Linux-x86_64.sh -O miniconda.sh 14 | export deps_dir=$HOME/local 15 | export PATH="$HOME/miniconda/bin:$PATH" 16 | bash miniconda.sh -b -p $HOME/miniconda 17 | mamba create -y -q -p $deps_dir cxx-compiler clangxx cmake libboost-devel ninja clang-tools 18 | source activate $deps_dir 19 | 20 | # Create the build dir and cd into it. 21 | mkdir build 22 | cd build 23 | 24 | # GCC build. 25 | cmake -G Ninja ../ -DCMAKE_PREFIX_PATH=$deps_dir \ 26 | -DCMAKE_CXX_COMPILER=clang++ \ 27 | -DCMAKE_BUILD_TYPE=Debug \ 28 | -DTANUKI_BUILD_TESTS=yes \ 29 | -DTANUKI_BUILD_TUTORIALS=yes \ 30 | -DTANUKI_WITH_BOOST_S11N=yes \ 31 | -DTANUKI_CLANG_TIDY=yes 32 | ninja 33 | 34 | set +e 35 | set +x 36 | -------------------------------------------------------------------------------- /test/catch/src/catch2/internal/catch_startup_exception_registry.hpp: -------------------------------------------------------------------------------- 1 | 2 | // Copyright Catch2 Authors 3 | // Distributed under the Boost Software License, Version 1.0. 4 | // (See accompanying file LICENSE.txt or copy at 5 | // https://www.boost.org/LICENSE_1_0.txt) 6 | 7 | // SPDX-License-Identifier: BSL-1.0 8 | #ifndef CATCH_STARTUP_EXCEPTION_REGISTRY_HPP_INCLUDED 9 | #define CATCH_STARTUP_EXCEPTION_REGISTRY_HPP_INCLUDED 10 | 11 | 12 | #include 13 | #include 14 | 15 | namespace Catch { 16 | 17 | class StartupExceptionRegistry { 18 | #if !defined(CATCH_CONFIG_DISABLE_EXCEPTIONS) 19 | public: 20 | void add(std::exception_ptr const& exception) noexcept; 21 | std::vector const& getExceptions() const noexcept; 22 | private: 23 | std::vector m_exceptions; 24 | #endif 25 | }; 26 | 27 | } // end namespace Catch 28 | 29 | #endif // CATCH_STARTUP_EXCEPTION_REGISTRY_HPP_INCLUDED 30 | -------------------------------------------------------------------------------- /test/catch/src/catch2/matchers/catch_matchers_quantifiers.cpp: -------------------------------------------------------------------------------- 1 | 2 | // Copyright Catch2 Authors 3 | // Distributed under the Boost Software License, Version 1.0. 4 | // (See accompanying file LICENSE.txt or copy at 5 | // https://www.boost.org/LICENSE_1_0.txt) 6 | 7 | // SPDX-License-Identifier: BSL-1.0 8 | #include 9 | 10 | namespace Catch { 11 | namespace Matchers { 12 | std::string AllTrueMatcher::describe() const { return "contains only true"; } 13 | 14 | AllTrueMatcher AllTrue() { return AllTrueMatcher{}; } 15 | 16 | std::string NoneTrueMatcher::describe() const { return "contains no true"; } 17 | 18 | NoneTrueMatcher NoneTrue() { return NoneTrueMatcher{}; } 19 | 20 | std::string AnyTrueMatcher::describe() const { return "contains at least one true"; } 21 | 22 | AnyTrueMatcher AnyTrue() { return AnyTrueMatcher{}; } 23 | } // namespace Matchers 24 | } // namespace Catch 25 | -------------------------------------------------------------------------------- /test/catch/tests/ExtraTests/X36-ReportingCrashWithJunitReporter.cpp: -------------------------------------------------------------------------------- 1 | 2 | // Copyright Catch2 Authors 3 | // Distributed under the Boost Software License, Version 1.0. 4 | // (See accompanying file LICENSE.txt or copy at 5 | // https://www.boost.org/LICENSE_1_0.txt) 6 | 7 | // SPDX-License-Identifier: BSL-1.0 8 | 9 | /**\file 10 | * Checks that signals/SEH within open section does not hard crash JUnit 11 | * (or similar reporter) while we are trying to report fatal error. 12 | */ 13 | 14 | #include 15 | 16 | #include 17 | 18 | // On Windows we need to send SEH and not signal to test the 19 | // RunContext::handleFatalErrorCondition code path 20 | #if defined( _MSC_VER ) 21 | # include 22 | #endif 23 | 24 | TEST_CASE( "raises signal" ) { 25 | SECTION( "section" ) { 26 | #if defined( _MSC_VER ) 27 | RaiseException( 0xC0000005, 0, 0, NULL ); 28 | #else 29 | std::raise( SIGILL ); 30 | #endif 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /test/catch/tests/ExtraTests/X10-FallbackStringifier.cpp: -------------------------------------------------------------------------------- 1 | 2 | // Copyright Catch2 Authors 3 | // Distributed under the Boost Software License, Version 1.0. 4 | // (See accompanying file LICENSE.txt or copy at 5 | // https://www.boost.org/LICENSE_1_0.txt) 6 | 7 | // SPDX-License-Identifier: BSL-1.0 8 | 9 | /**\file 10 | * Test that the user can define custom fallbackStringifier 11 | * 12 | * This is done by defining a custom fallback stringifier that prints 13 | * out a specific string, and then asserting (to cause stringification) 14 | * over a type without stringification support. 15 | */ 16 | 17 | #include 18 | 19 | // A catch-all stringifier 20 | template 21 | std::string fallbackStringifier(T const&) { 22 | return "{ !!! }"; 23 | } 24 | 25 | #include 26 | 27 | struct foo { 28 | explicit operator bool() const { 29 | return true; 30 | } 31 | }; 32 | 33 | TEST_CASE("aa") { 34 | REQUIRE(foo{}); 35 | } 36 | -------------------------------------------------------------------------------- /test/catch/CMakePresets.json: -------------------------------------------------------------------------------- 1 | { 2 | "version": 3, 3 | "configurePresets": [ 4 | { 5 | "name": "basic-tests", 6 | "displayName": "Basic development build", 7 | "description": "Enables development build with basic tests that are cheap to build and run", 8 | "cacheVariables": { 9 | "CATCH_DEVELOPMENT_BUILD": "ON" 10 | } 11 | }, 12 | { 13 | "name": "all-tests", 14 | "inherits": "basic-tests", 15 | "displayName": "Full development build", 16 | "description": "Enables development build with examples and ALL tests", 17 | "cacheVariables": { 18 | "CATCH_BUILD_EXAMPLES": "ON", 19 | "CATCH_BUILD_EXTRA_TESTS": "ON", 20 | "CATCH_BUILD_SURROGATES": "ON", 21 | "CATCH_ENABLE_CONFIGURE_TESTS": "ON", 22 | "CATCH_ENABLE_CMAKE_HELPER_TESTS": "ON" 23 | } 24 | } 25 | ] 26 | } 27 | -------------------------------------------------------------------------------- /test/catch/src/catch2/benchmark/catch_environment.hpp: -------------------------------------------------------------------------------- 1 | 2 | // Copyright Catch2 Authors 3 | // Distributed under the Boost Software License, Version 1.0. 4 | // (See accompanying file LICENSE.txt or copy at 5 | // https://www.boost.org/LICENSE_1_0.txt) 6 | 7 | // SPDX-License-Identifier: BSL-1.0 8 | // Adapted from donated nonius code. 9 | 10 | #ifndef CATCH_ENVIRONMENT_HPP_INCLUDED 11 | #define CATCH_ENVIRONMENT_HPP_INCLUDED 12 | 13 | #include 14 | #include 15 | 16 | namespace Catch { 17 | namespace Benchmark { 18 | struct EnvironmentEstimate { 19 | FDuration mean; 20 | OutlierClassification outliers; 21 | }; 22 | struct Environment { 23 | EnvironmentEstimate clock_resolution; 24 | EnvironmentEstimate clock_cost; 25 | }; 26 | } // namespace Benchmark 27 | } // namespace Catch 28 | 29 | #endif // CATCH_ENVIRONMENT_HPP_INCLUDED 30 | -------------------------------------------------------------------------------- /test/catch/src/catch2/internal/catch_noncopyable.hpp: -------------------------------------------------------------------------------- 1 | 2 | // Copyright Catch2 Authors 3 | // Distributed under the Boost Software License, Version 1.0. 4 | // (See accompanying file LICENSE.txt or copy at 5 | // https://www.boost.org/LICENSE_1_0.txt) 6 | 7 | // SPDX-License-Identifier: BSL-1.0 8 | #ifndef CATCH_NONCOPYABLE_HPP_INCLUDED 9 | #define CATCH_NONCOPYABLE_HPP_INCLUDED 10 | 11 | namespace Catch { 12 | namespace Detail { 13 | 14 | //! Deriving classes become noncopyable and nonmovable 15 | class NonCopyable { 16 | NonCopyable( NonCopyable const& ) = delete; 17 | NonCopyable( NonCopyable&& ) = delete; 18 | NonCopyable& operator=( NonCopyable const& ) = delete; 19 | NonCopyable& operator=( NonCopyable&& ) = delete; 20 | 21 | protected: 22 | NonCopyable() noexcept = default; 23 | }; 24 | 25 | } // namespace Detail 26 | } // namespace Catch 27 | 28 | #endif // CATCH_NONCOPYABLE_HPP_INCLUDED 29 | -------------------------------------------------------------------------------- /test/catch/src/catch2/catch_tag_alias_autoregistrar.cpp: -------------------------------------------------------------------------------- 1 | 2 | // Copyright Catch2 Authors 3 | // Distributed under the Boost Software License, Version 1.0. 4 | // (See accompanying file LICENSE.txt or copy at 5 | // https://www.boost.org/LICENSE_1_0.txt) 6 | 7 | // SPDX-License-Identifier: BSL-1.0 8 | 9 | #include 10 | #include 11 | #include 12 | 13 | namespace Catch { 14 | 15 | RegistrarForTagAliases::RegistrarForTagAliases(char const* alias, char const* tag, SourceLineInfo const& lineInfo) { 16 | CATCH_TRY { 17 | getMutableRegistryHub().registerTagAlias(alias, tag, lineInfo); 18 | } CATCH_CATCH_ALL { 19 | // Do not throw when constructing global objects, instead register the exception to be processed later 20 | getMutableRegistryHub().registerStartupException(); 21 | } 22 | } 23 | 24 | } 25 | -------------------------------------------------------------------------------- /test/catch/src/catch2/internal/catch_stream_end_stop.hpp: -------------------------------------------------------------------------------- 1 | 2 | // Copyright Catch2 Authors 3 | // Distributed under the Boost Software License, Version 1.0. 4 | // (See accompanying file LICENSE.txt or copy at 5 | // https://www.boost.org/LICENSE_1_0.txt) 6 | 7 | // SPDX-License-Identifier: BSL-1.0 8 | #ifndef CATCH_STREAM_END_STOP_HPP_INCLUDED 9 | #define CATCH_STREAM_END_STOP_HPP_INCLUDED 10 | 11 | #include 12 | 13 | namespace Catch { 14 | 15 | // Use this in variadic streaming macros to allow 16 | // << +StreamEndStop 17 | // as well as 18 | // << stuff +StreamEndStop 19 | struct StreamEndStop { 20 | constexpr StringRef operator+() const { return StringRef(); } 21 | 22 | template 23 | constexpr friend T const& operator+( T const& value, StreamEndStop ) { 24 | return value; 25 | } 26 | }; 27 | 28 | } // namespace Catch 29 | 30 | #endif // CATCH_STREAM_END_STOP_HPP_INCLUDED 31 | -------------------------------------------------------------------------------- /test/catch/src/catch2/interfaces/catch_interfaces_tag_alias_registry.hpp: -------------------------------------------------------------------------------- 1 | 2 | // Copyright Catch2 Authors 3 | // Distributed under the Boost Software License, Version 1.0. 4 | // (See accompanying file LICENSE.txt or copy at 5 | // https://www.boost.org/LICENSE_1_0.txt) 6 | 7 | // SPDX-License-Identifier: BSL-1.0 8 | #ifndef CATCH_INTERFACES_TAG_ALIAS_REGISTRY_HPP_INCLUDED 9 | #define CATCH_INTERFACES_TAG_ALIAS_REGISTRY_HPP_INCLUDED 10 | 11 | #include 12 | 13 | namespace Catch { 14 | 15 | struct TagAlias; 16 | 17 | class ITagAliasRegistry { 18 | public: 19 | virtual ~ITagAliasRegistry(); // = default 20 | // Nullptr if not present 21 | virtual TagAlias const* find( std::string const& alias ) const = 0; 22 | virtual std::string expandAliases( std::string const& unexpandedTestSpec ) const = 0; 23 | 24 | static ITagAliasRegistry const& get(); 25 | }; 26 | 27 | } // end namespace Catch 28 | 29 | #endif // CATCH_INTERFACES_TAG_ALIAS_REGISTRY_HPP_INCLUDED 30 | -------------------------------------------------------------------------------- /tools/gha_conda_ubsan.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | # Echo each command 4 | set -x 5 | 6 | # Exit on error. 7 | set -e 8 | 9 | # Core deps. 10 | sudo apt-get install wget 11 | 12 | # Install conda+deps. 13 | wget https://github.com/conda-forge/miniforge/releases/latest/download/Miniforge3-Linux-x86_64.sh -O miniconda.sh 14 | export deps_dir=$HOME/local 15 | export PATH="$HOME/miniconda/bin:$PATH" 16 | bash miniconda.sh -b -p $HOME/miniconda 17 | mamba create -y -q -p $deps_dir cxx-compiler cmake ninja libboost-devel 18 | source activate $deps_dir 19 | 20 | # Create the build dir and cd into it. 21 | mkdir build 22 | cd build 23 | 24 | # GCC build. 25 | cmake -G Ninja ../ -DCMAKE_PREFIX_PATH=$deps_dir \ 26 | -DCMAKE_CXX_FLAGS="-fsanitize=undefined" \ 27 | -DCMAKE_C_FLAGS="-fsanitize=undefined" \ 28 | -DCMAKE_CXX_COMPILER=g++ \ 29 | -DCMAKE_BUILD_TYPE=Debug \ 30 | -DTANUKI_BUILD_TESTS=yes \ 31 | -DTANUKI_BUILD_TUTORIALS=yes \ 32 | -DTANUKI_WITH_BOOST_S11N=yes 33 | ninja 34 | ctest -V -j4 35 | 36 | set +e 37 | set +x 38 | -------------------------------------------------------------------------------- /test/catch/src/catch2/generators/catch_generator_exception.hpp: -------------------------------------------------------------------------------- 1 | 2 | // Copyright Catch2 Authors 3 | // Distributed under the Boost Software License, Version 1.0. 4 | // (See accompanying file LICENSE.txt or copy at 5 | // https://www.boost.org/LICENSE_1_0.txt) 6 | 7 | // SPDX-License-Identifier: BSL-1.0 8 | #ifndef CATCH_GENERATOR_EXCEPTION_HPP_INCLUDED 9 | #define CATCH_GENERATOR_EXCEPTION_HPP_INCLUDED 10 | 11 | #include 12 | 13 | namespace Catch { 14 | 15 | // Exception type to be thrown when a Generator runs into an error, 16 | // e.g. it cannot initialize the first return value based on 17 | // runtime information 18 | class GeneratorException : public std::exception { 19 | const char* const m_msg = ""; 20 | 21 | public: 22 | GeneratorException(const char* msg): 23 | m_msg(msg) 24 | {} 25 | 26 | const char* what() const noexcept override final; 27 | }; 28 | 29 | } // end namespace Catch 30 | 31 | #endif // CATCH_GENERATOR_EXCEPTION_HPP_INCLUDED 32 | -------------------------------------------------------------------------------- /test/catch/tests/TestScripts/DiscoverTests/register-tests.cpp: -------------------------------------------------------------------------------- 1 | 2 | // Copyright Catch2 Authors 3 | // Distributed under the Boost Software License, Version 1.0. 4 | // (See accompanying file LICENSE.txt or copy at 5 | // https://www.boost.org/LICENSE_1_0.txt) 6 | 7 | // SPDX-License-Identifier: BSL-1.0 8 | 9 | #include 10 | 11 | TEST_CASE("@Script[C:\\EPM1A]=x;\"SCALA_ZERO:\"", "[script regressions]"){} 12 | TEST_CASE("Some test") {} 13 | TEST_CASE( "Let's have a test case with a long name. Longer. No, even longer. " 14 | "Really looooooooooooong. Even longer than that. Multiple lines " 15 | "worth of test name. Yep, like this." ) {} 16 | TEST_CASE( "And now a test case with weird tags.", "[tl;dr][tl;dw][foo,bar]" ) {} 17 | // Also check that we handle tests on class, which have name in output as 'class-name', not 'name'. 18 | class TestCaseFixture { 19 | public: 20 | int m_a; 21 | }; 22 | 23 | TEST_CASE_METHOD(TestCaseFixture, "A test case as method", "[tagstagstags]") {} 24 | -------------------------------------------------------------------------------- /tools/gha_conda_asan.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | # Echo each command 4 | set -x 5 | 6 | # Exit on error. 7 | set -e 8 | 9 | # Core deps. 10 | sudo apt-get install wget 11 | 12 | # Install conda+deps. 13 | wget https://github.com/conda-forge/miniforge/releases/latest/download/Miniforge3-Linux-x86_64.sh -O miniconda.sh 14 | export deps_dir=$HOME/local 15 | export PATH="$HOME/miniconda/bin:$PATH" 16 | bash miniconda.sh -b -p $HOME/miniconda 17 | mamba create -y -q -p $deps_dir cxx-compiler cmake libboost-devel ninja 18 | source activate $deps_dir 19 | 20 | # Create the build dir and cd into it. 21 | mkdir build 22 | cd build 23 | 24 | unset CXXFLAGS 25 | unset CFLAGS 26 | 27 | # GCC build. 28 | cmake -G Ninja ../ -DCMAKE_PREFIX_PATH=$deps_dir \ 29 | -DCMAKE_BUILD_TYPE=Debug \ 30 | -DTANUKI_BUILD_TESTS=yes \ 31 | -DTANUKI_BUILD_TUTORIALS=yes \ 32 | -DTANUKI_WITH_BOOST_S11N=yes \ 33 | -DCMAKE_CXX_FLAGS="-fsanitize=address" \ 34 | -DCMAKE_C_FLAGS="-fsanitize=address" 35 | ninja -v 36 | ctest -V -j1 37 | 38 | set +e 39 | set +x 40 | -------------------------------------------------------------------------------- /tools/circleci_ubuntu_arm64.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | # Echo each command 4 | set -x 5 | 6 | # Exit on error. 7 | set -e 8 | 9 | # Core deps. 10 | sudo apt-get install wget 11 | 12 | # Install conda+deps. 13 | wget https://github.com/conda-forge/miniforge/releases/latest/download/Miniforge3-Linux-aarch64.sh -O miniconda.sh 14 | export deps_dir=$HOME/local 15 | export PATH="$HOME/miniconda/bin:$PATH" 16 | bash miniconda.sh -b -p $HOME/miniconda 17 | mamba create -y -q -p $deps_dir cxx-compiler cmake libboost-devel ninja 18 | source activate $deps_dir 19 | 20 | # Create the build dir and cd into it. 21 | mkdir build 22 | cd build 23 | 24 | unset CXXFLAGS 25 | unset CFLAGS 26 | 27 | # GCC build. 28 | cmake -G Ninja ../ -DCMAKE_PREFIX_PATH=$deps_dir \ 29 | -DCMAKE_BUILD_TYPE=Debug \ 30 | -DTANUKI_BUILD_TESTS=yes \ 31 | -DTANUKI_BUILD_TUTORIALS=yes \ 32 | -DTANUKI_WITH_BOOST_S11N=yes \ 33 | -DCMAKE_CXX_FLAGS="-fsanitize=address" \ 34 | -DCMAKE_C_FLAGS="-fsanitize=address" 35 | ninja -v 36 | ctest -V -j4 37 | 38 | set +e 39 | set +x 40 | -------------------------------------------------------------------------------- /test/catch/src/catch2/internal/catch_test_failure_exception.cpp: -------------------------------------------------------------------------------- 1 | 2 | // Copyright Catch2 Authors 3 | // Distributed under the Boost Software License, Version 1.0. 4 | // (See accompanying file LICENSE.txt or copy at 5 | // https://www.boost.org/LICENSE_1_0.txt) 6 | 7 | // SPDX-License-Identifier: BSL-1.0 8 | 9 | #include 10 | #include 11 | #include 12 | 13 | namespace Catch { 14 | 15 | void throw_test_failure_exception() { 16 | #if !defined( CATCH_CONFIG_DISABLE_EXCEPTIONS ) 17 | throw TestFailureException{}; 18 | #else 19 | CATCH_ERROR( "Test failure requires aborting test!" ); 20 | #endif 21 | } 22 | 23 | void throw_test_skip_exception() { 24 | #if !defined( CATCH_CONFIG_DISABLE_EXCEPTIONS ) 25 | throw Catch::TestSkipException(); 26 | #else 27 | CATCH_ERROR( "Explicitly skipping tests during runtime requires exceptions" ); 28 | #endif 29 | } 30 | 31 | } // namespace Catch 32 | -------------------------------------------------------------------------------- /test/catch/src/catch2/matchers/catch_matchers_container_properties.cpp: -------------------------------------------------------------------------------- 1 | 2 | // Copyright Catch2 Authors 3 | // Distributed under the Boost Software License, Version 1.0. 4 | // (See accompanying file LICENSE.txt or copy at 5 | // https://www.boost.org/LICENSE_1_0.txt) 6 | 7 | // SPDX-License-Identifier: BSL-1.0 8 | 9 | #include 10 | #include 11 | 12 | namespace Catch { 13 | namespace Matchers { 14 | 15 | std::string IsEmptyMatcher::describe() const { 16 | return "is empty"; 17 | } 18 | 19 | std::string HasSizeMatcher::describe() const { 20 | ReusableStringStream sstr; 21 | sstr << "has size == " << m_target_size; 22 | return sstr.str(); 23 | } 24 | 25 | IsEmptyMatcher IsEmpty() { 26 | return {}; 27 | } 28 | 29 | HasSizeMatcher SizeIs(std::size_t sz) { 30 | return HasSizeMatcher{ sz }; 31 | } 32 | 33 | } // end namespace Matchers 34 | } // end namespace Catch 35 | -------------------------------------------------------------------------------- /test/catch/tools/scripts/approve.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python3 2 | 3 | import os 4 | import sys 5 | import shutil 6 | import glob 7 | from scriptCommon import catchPath 8 | 9 | rootPath = os.path.join( catchPath, 'tests/SelfTest/Baselines' ) 10 | 11 | if len(sys.argv) > 1: 12 | files = [os.path.join( rootPath, f ) for f in sys.argv[1:]] 13 | else: 14 | files = glob.glob( os.path.join( rootPath, "*.unapproved.txt" ) ) 15 | 16 | 17 | def approveFile( approvedFile, unapprovedFile ): 18 | justFilename = unapprovedFile[len(rootPath)+1:] 19 | if os.path.exists( unapprovedFile ): 20 | if os.path.exists( approvedFile ): 21 | os.remove( approvedFile ) 22 | os.rename( unapprovedFile, approvedFile ) 23 | print( "approved " + justFilename ) 24 | else: 25 | print( "approval file " + justFilename + " does not exist" ) 26 | 27 | if files: 28 | for unapprovedFile in files: 29 | approveFile( unapprovedFile.replace( "unapproved.txt", "approved.txt" ), unapprovedFile ) 30 | else: 31 | print( "no files to approve" ) 32 | -------------------------------------------------------------------------------- /test/catch/src/catch2/internal/catch_lazy_expr.cpp: -------------------------------------------------------------------------------- 1 | 2 | // Copyright Catch2 Authors 3 | // Distributed under the Boost Software License, Version 1.0. 4 | // (See accompanying file LICENSE.txt or copy at 5 | // https://www.boost.org/LICENSE_1_0.txt) 6 | 7 | // SPDX-License-Identifier: BSL-1.0 8 | 9 | #include 10 | #include 11 | 12 | namespace Catch { 13 | 14 | auto operator << (std::ostream& os, LazyExpression const& lazyExpr) -> std::ostream& { 15 | if (lazyExpr.m_isNegated) 16 | os << '!'; 17 | 18 | if (lazyExpr) { 19 | if (lazyExpr.m_isNegated && lazyExpr.m_transientExpression->isBinaryExpression()) 20 | os << '(' << *lazyExpr.m_transientExpression << ')'; 21 | else 22 | os << *lazyExpr.m_transientExpression; 23 | } else { 24 | os << "{** error - unchecked empty expression requested **}"; 25 | } 26 | return os; 27 | } 28 | 29 | } // namespace Catch 30 | -------------------------------------------------------------------------------- /test/catch/src/catch2/benchmark/detail/catch_timing.hpp: -------------------------------------------------------------------------------- 1 | 2 | // Copyright Catch2 Authors 3 | // Distributed under the Boost Software License, Version 1.0. 4 | // (See accompanying file LICENSE.txt or copy at 5 | // https://www.boost.org/LICENSE_1_0.txt) 6 | 7 | // SPDX-License-Identifier: BSL-1.0 8 | // Adapted from donated nonius code. 9 | 10 | #ifndef CATCH_TIMING_HPP_INCLUDED 11 | #define CATCH_TIMING_HPP_INCLUDED 12 | 13 | #include 14 | #include 15 | 16 | #include 17 | 18 | namespace Catch { 19 | namespace Benchmark { 20 | template 21 | struct Timing { 22 | IDuration elapsed; 23 | Result result; 24 | int iterations; 25 | }; 26 | template 27 | using TimingOf = Timing>>; 28 | } // namespace Benchmark 29 | } // namespace Catch 30 | 31 | #endif // CATCH_TIMING_HPP_INCLUDED 32 | -------------------------------------------------------------------------------- /test/catch/src/catch2/interfaces/catch_interfaces_generatortracker.cpp: -------------------------------------------------------------------------------- 1 | 2 | // Copyright Catch2 Authors 3 | // Distributed under the Boost Software License, Version 1.0. 4 | // (See accompanying file LICENSE.txt or copy at 5 | // https://www.boost.org/LICENSE_1_0.txt) 6 | 7 | // SPDX-License-Identifier: BSL-1.0 8 | 9 | #include 10 | #include 11 | 12 | namespace Catch { 13 | namespace Generators { 14 | 15 | bool GeneratorUntypedBase::countedNext() { 16 | auto ret = next(); 17 | if ( ret ) { 18 | m_stringReprCache.clear(); 19 | ++m_currentElementIndex; 20 | } 21 | return ret; 22 | } 23 | 24 | StringRef GeneratorUntypedBase::currentElementAsString() const { 25 | if ( m_stringReprCache.empty() ) { 26 | m_stringReprCache = stringifyImpl(); 27 | } 28 | return m_stringReprCache; 29 | } 30 | 31 | } // namespace Generators 32 | } // namespace Catch 33 | -------------------------------------------------------------------------------- /test/catch/src/catch2/benchmark/catch_sample_analysis.hpp: -------------------------------------------------------------------------------- 1 | 2 | // Copyright Catch2 Authors 3 | // Distributed under the Boost Software License, Version 1.0. 4 | // (See accompanying file LICENSE.txt or copy at 5 | // https://www.boost.org/LICENSE_1_0.txt) 6 | 7 | // SPDX-License-Identifier: BSL-1.0 8 | // Adapted from donated nonius code. 9 | 10 | #ifndef CATCH_SAMPLE_ANALYSIS_HPP_INCLUDED 11 | #define CATCH_SAMPLE_ANALYSIS_HPP_INCLUDED 12 | 13 | #include 14 | #include 15 | #include 16 | 17 | #include 18 | 19 | namespace Catch { 20 | namespace Benchmark { 21 | struct SampleAnalysis { 22 | std::vector samples; 23 | Estimate mean; 24 | Estimate standard_deviation; 25 | OutlierClassification outliers; 26 | double outlier_variance; 27 | }; 28 | } // namespace Benchmark 29 | } // namespace Catch 30 | 31 | #endif // CATCH_SAMPLE_ANALYSIS_HPP_INCLUDED 32 | -------------------------------------------------------------------------------- /test/catch/src/catch2/internal/catch_exception_translator_registry.hpp: -------------------------------------------------------------------------------- 1 | 2 | // Copyright Catch2 Authors 3 | // Distributed under the Boost Software License, Version 1.0. 4 | // (See accompanying file LICENSE.txt or copy at 5 | // https://www.boost.org/LICENSE_1_0.txt) 6 | 7 | // SPDX-License-Identifier: BSL-1.0 8 | #ifndef CATCH_EXCEPTION_TRANSLATOR_REGISTRY_HPP_INCLUDED 9 | #define CATCH_EXCEPTION_TRANSLATOR_REGISTRY_HPP_INCLUDED 10 | 11 | #include 12 | #include 13 | 14 | #include 15 | #include 16 | 17 | namespace Catch { 18 | 19 | class ExceptionTranslatorRegistry : public IExceptionTranslatorRegistry { 20 | public: 21 | ~ExceptionTranslatorRegistry() override; 22 | void registerTranslator( Detail::unique_ptr&& translator ); 23 | std::string translateActiveException() const override; 24 | 25 | private: 26 | ExceptionTranslators m_translators; 27 | }; 28 | } 29 | 30 | #endif // CATCH_EXCEPTION_TRANSLATOR_REGISTRY_HPP_INCLUDED 31 | -------------------------------------------------------------------------------- /test/catch/src/catch2/internal/catch_config_prefix_messages.hpp: -------------------------------------------------------------------------------- 1 | 2 | // Copyright Catch2 Authors 3 | // Distributed under the Boost Software License, Version 1.0. 4 | // (See accompanying file LICENSE.txt or copy at 5 | // https://www.boost.org/LICENSE_1_0.txt) 6 | 7 | // SPDX-License-Identifier: BSL-1.0 8 | 9 | /** \file 10 | * Wrapper for the CATCH_CONFIG_PREFIX_MESSAGES configuration option 11 | * 12 | * CATCH_CONFIG_PREFIX_ALL can be used to avoid clashes with other macros 13 | * by prepending CATCH_. This may not be desirable if the only clashes are with 14 | * logger macros such as INFO and WARN. In this cases 15 | * CATCH_CONFIG_PREFIX_MESSAGES can be used to only prefix a small subset 16 | * of relevant macros. 17 | * 18 | */ 19 | 20 | #ifndef CATCH_CONFIG_PREFIX_MESSAGES_HPP_INCLUDED 21 | #define CATCH_CONFIG_PREFIX_MESSAGES_HPP_INCLUDED 22 | 23 | #include 24 | 25 | #if defined(CATCH_CONFIG_PREFIX_ALL) && !defined(CATCH_CONFIG_PREFIX_MESSAGES) 26 | #define CATCH_CONFIG_PREFIX_MESSAGES 27 | #endif 28 | 29 | #endif // CATCH_CONFIG_PREFIX_MESSAGES_HPP_INCLUDED 30 | -------------------------------------------------------------------------------- /test/catch/src/catch2/internal/catch_getenv.cpp: -------------------------------------------------------------------------------- 1 | 2 | // Copyright Catch2 Authors 3 | // Distributed under the Boost Software License, Version 1.0. 4 | // (See accompanying file LICENSE.txt or copy at 5 | // https://www.boost.org/LICENSE_1_0.txt) 6 | 7 | // SPDX-License-Identifier: BSL-1.0 8 | 9 | #include 10 | 11 | #include 12 | #include 13 | 14 | #include 15 | 16 | namespace Catch { 17 | namespace Detail { 18 | 19 | #if !defined (CATCH_CONFIG_GETENV) 20 | char const* getEnv( char const* ) { return nullptr; } 21 | #else 22 | 23 | char const* getEnv( char const* varName ) { 24 | # if defined( _MSC_VER ) 25 | # pragma warning( push ) 26 | # pragma warning( disable : 4996 ) // use getenv_s instead of getenv 27 | # endif 28 | 29 | return std::getenv( varName ); 30 | 31 | # if defined( _MSC_VER ) 32 | # pragma warning( pop ) 33 | # endif 34 | } 35 | #endif 36 | } // namespace Detail 37 | } // namespace Catch 38 | -------------------------------------------------------------------------------- /test/catch/tools/misc/installOpenCppCoverage.ps1: -------------------------------------------------------------------------------- 1 | # Downloads are done from the official github release page links 2 | $downloadUrl = "https://github.com/OpenCppCoverage/OpenCppCoverage/releases/download/release-0.9.9.0/OpenCppCoverageSetup-x64-0.9.9.0.exe" 3 | $installerPath = [System.IO.Path]::Combine($Env:USERPROFILE, "Downloads", "OpenCppCoverageSetup.exe") 4 | 5 | if(-Not (Test-Path $installerPath)) { 6 | Write-Host -ForegroundColor White ("Downloading OpenCppCoverage from: " + $downloadUrl) 7 | Start-FileDownload $downloadUrl -FileName $installerPath 8 | } 9 | 10 | Write-Host -ForegroundColor White "About to install OpenCppCoverage..." 11 | 12 | $installProcess = (Start-Process $installerPath -ArgumentList '/VERYSILENT' -PassThru -Wait) 13 | if($installProcess.ExitCode -ne 0) { 14 | throw [System.String]::Format("Failed to install OpenCppCoverage, ExitCode: {0}.", $installProcess.ExitCode) 15 | } 16 | 17 | # Assume standard, boring, installation path of ".../Program Files/OpenCppCoverage" 18 | $installPath = [System.IO.Path]::Combine(${Env:ProgramFiles}, "OpenCppCoverage") 19 | $env:Path="$env:Path;$installPath" 20 | -------------------------------------------------------------------------------- /test/catch/src/catch2/benchmark/detail/catch_run_for_at_least.cpp: -------------------------------------------------------------------------------- 1 | 2 | // Copyright Catch2 Authors 3 | // Distributed under the Boost Software License, Version 1.0. 4 | // (See accompanying file LICENSE.txt or copy at 5 | // https://www.boost.org/LICENSE_1_0.txt) 6 | 7 | // SPDX-License-Identifier: BSL-1.0 8 | 9 | #include 10 | #include 11 | 12 | #include 13 | 14 | namespace Catch { 15 | namespace Benchmark { 16 | namespace Detail { 17 | struct optimized_away_error : std::exception { 18 | const char* what() const noexcept override; 19 | }; 20 | 21 | const char* optimized_away_error::what() const noexcept { 22 | return "could not measure benchmark, maybe it was optimized away"; 23 | } 24 | 25 | void throw_optimized_away_error() { 26 | Catch::throw_exception(optimized_away_error{}); 27 | } 28 | 29 | } // namespace Detail 30 | } // namespace Benchmark 31 | } // namespace Catch 32 | -------------------------------------------------------------------------------- /test/catch/src/catch2/interfaces/catch_interfaces_testcase.hpp: -------------------------------------------------------------------------------- 1 | 2 | // Copyright Catch2 Authors 3 | // Distributed under the Boost Software License, Version 1.0. 4 | // (See accompanying file LICENSE.txt or copy at 5 | // https://www.boost.org/LICENSE_1_0.txt) 6 | 7 | // SPDX-License-Identifier: BSL-1.0 8 | #ifndef CATCH_INTERFACES_TESTCASE_HPP_INCLUDED 9 | #define CATCH_INTERFACES_TESTCASE_HPP_INCLUDED 10 | 11 | #include 12 | 13 | namespace Catch { 14 | 15 | struct TestCaseInfo; 16 | class TestCaseHandle; 17 | class IConfig; 18 | 19 | class ITestCaseRegistry { 20 | public: 21 | virtual ~ITestCaseRegistry(); // = default 22 | // TODO: this exists only for adding filenames to test cases -- let's expose this in a saner way later 23 | virtual std::vector const& getAllInfos() const = 0; 24 | virtual std::vector const& getAllTests() const = 0; 25 | virtual std::vector const& getAllTestsSorted( IConfig const& config ) const = 0; 26 | }; 27 | 28 | } 29 | 30 | #endif // CATCH_INTERFACES_TESTCASE_HPP_INCLUDED 31 | -------------------------------------------------------------------------------- /test/catch/src/catch2/internal/catch_config_android_logwrite.hpp: -------------------------------------------------------------------------------- 1 | 2 | // Copyright Catch2 Authors 3 | // Distributed under the Boost Software License, Version 1.0. 4 | // (See accompanying file LICENSE.txt or copy at 5 | // https://www.boost.org/LICENSE_1_0.txt) 6 | 7 | // SPDX-License-Identifier: BSL-1.0 8 | 9 | /** \file 10 | * Wrapper for ANDROID_LOGWRITE configuration option 11 | * 12 | * We want to default to enabling it when compiled for android, but 13 | * users of the library should also be able to disable it if they want 14 | * to. 15 | */ 16 | 17 | #ifndef CATCH_CONFIG_ANDROID_LOGWRITE_HPP_INCLUDED 18 | #define CATCH_CONFIG_ANDROID_LOGWRITE_HPP_INCLUDED 19 | 20 | #include 21 | 22 | #if defined(__ANDROID__) 23 | # define CATCH_INTERNAL_CONFIG_ANDROID_LOGWRITE 24 | #endif 25 | 26 | 27 | #if defined( CATCH_INTERNAL_CONFIG_ANDROID_LOGWRITE ) && \ 28 | !defined( CATCH_CONFIG_NO_ANDROID_LOGWRITE ) && \ 29 | !defined( CATCH_CONFIG_ANDROID_LOGWRITE ) 30 | # define CATCH_CONFIG_ANDROID_LOGWRITE 31 | #endif 32 | 33 | #endif // CATCH_CONFIG_ANDROID_LOGWRITE_HPP_INCLUDED 34 | -------------------------------------------------------------------------------- /test/catch/src/catch2/internal/catch_startup_exception_registry.cpp: -------------------------------------------------------------------------------- 1 | 2 | // Copyright Catch2 Authors 3 | // Distributed under the Boost Software License, Version 1.0. 4 | // (See accompanying file LICENSE.txt or copy at 5 | // https://www.boost.org/LICENSE_1_0.txt) 6 | 7 | // SPDX-License-Identifier: BSL-1.0 8 | 9 | #include 10 | #include 11 | #include 12 | 13 | namespace Catch { 14 | #if !defined(CATCH_CONFIG_DISABLE_EXCEPTIONS) 15 | void StartupExceptionRegistry::add( std::exception_ptr const& exception ) noexcept { 16 | CATCH_TRY { 17 | m_exceptions.push_back(exception); 18 | } CATCH_CATCH_ALL { 19 | // If we run out of memory during start-up there's really not a lot more we can do about it 20 | std::terminate(); 21 | } 22 | } 23 | 24 | std::vector const& StartupExceptionRegistry::getExceptions() const noexcept { 25 | return m_exceptions; 26 | } 27 | #endif 28 | 29 | } // end namespace Catch 30 | -------------------------------------------------------------------------------- /test/catch/src/catch2/internal/catch_list.hpp: -------------------------------------------------------------------------------- 1 | 2 | // Copyright Catch2 Authors 3 | // Distributed under the Boost Software License, Version 1.0. 4 | // (See accompanying file LICENSE.txt or copy at 5 | // https://www.boost.org/LICENSE_1_0.txt) 6 | 7 | // SPDX-License-Identifier: BSL-1.0 8 | #ifndef CATCH_LIST_HPP_INCLUDED 9 | #define CATCH_LIST_HPP_INCLUDED 10 | 11 | #include 12 | 13 | #include 14 | #include 15 | 16 | 17 | namespace Catch { 18 | 19 | class IEventListener; 20 | class Config; 21 | 22 | 23 | struct ReporterDescription { 24 | std::string name, description; 25 | }; 26 | struct ListenerDescription { 27 | StringRef name; 28 | std::string description; 29 | }; 30 | 31 | struct TagInfo { 32 | void add(StringRef spelling); 33 | std::string all() const; 34 | 35 | std::set spellings; 36 | std::size_t count = 0; 37 | }; 38 | 39 | bool list( IEventListener& reporter, Config const& config ); 40 | 41 | } // end namespace Catch 42 | 43 | #endif // CATCH_LIST_HPP_INCLUDED 44 | -------------------------------------------------------------------------------- /test/catch/tests/ExtraTests/X91-AmalgamatedCatch.cpp: -------------------------------------------------------------------------------- 1 | 2 | // Copyright Catch2 Authors 3 | // Distributed under the Boost Software License, Version 1.0. 4 | // (See accompanying file LICENSE.txt or copy at 5 | // https://www.boost.org/LICENSE_1_0.txt) 6 | 7 | // SPDX-License-Identifier: BSL-1.0 8 | 9 | /**\file 10 | * This file serves as a simple compilation test against the amalgamated 11 | * version of Catch2. 12 | */ 13 | 14 | #include "catch_amalgamated.hpp" 15 | 16 | TEST_CASE("Just a dummy test") { 17 | auto i = GENERATE(1, 2, 3); 18 | SECTION("a") { 19 | REQUIRE(i != 4); 20 | } 21 | SECTION("b") { 22 | CHECK(i != 5); 23 | } 24 | REQUIRE_THAT(1, 25 | Catch::Matchers::Predicate([](int i) { 26 | return i % 2 == 1; 27 | })); 28 | } 29 | 30 | TEMPLATE_TEST_CASE("Trivial template test case", "", char, short) { 31 | STATIC_REQUIRE(sizeof(TestType) <= sizeof(int)); 32 | } 33 | 34 | TEST_CASE("Benchmark test", "[!benchmark]") { 35 | BENCHMARK("Allocation benchmark") { 36 | return std::vector(10); 37 | }; 38 | } 39 | -------------------------------------------------------------------------------- /test/catch/src/catch2/internal/catch_case_insensitive_comparisons.hpp: -------------------------------------------------------------------------------- 1 | 2 | // Copyright Catch2 Authors 3 | // Distributed under the Boost Software License, Version 1.0. 4 | // (See accompanying file LICENSE.txt or copy at 5 | // https://www.boost.org/LICENSE_1_0.txt) 6 | 7 | // SPDX-License-Identifier: BSL-1.0 8 | #ifndef CATCH_CASE_INSENSITIVE_COMPARISONS_HPP_INCLUDED 9 | #define CATCH_CASE_INSENSITIVE_COMPARISONS_HPP_INCLUDED 10 | 11 | #include 12 | 13 | namespace Catch { 14 | namespace Detail { 15 | //! Provides case-insensitive `op<` semantics when called 16 | struct CaseInsensitiveLess { 17 | bool operator()( StringRef lhs, 18 | StringRef rhs ) const; 19 | }; 20 | 21 | //! Provides case-insensitive `op==` semantics when called 22 | struct CaseInsensitiveEqualTo { 23 | bool operator()( StringRef lhs, 24 | StringRef rhs ) const; 25 | }; 26 | 27 | } // namespace Detail 28 | } // namespace Catch 29 | 30 | #endif // CATCH_CASE_INSENSITIVE_COMPARISONS_HPP_INCLUDED 31 | -------------------------------------------------------------------------------- /test/catch/src/catch2/internal/catch_random_seed_generation.cpp: -------------------------------------------------------------------------------- 1 | 2 | // Copyright Catch2 Authors 3 | // Distributed under the Boost Software License, Version 1.0. 4 | // (See accompanying file LICENSE.txt or copy at 5 | // https://www.boost.org/LICENSE_1_0.txt) 6 | 7 | // SPDX-License-Identifier: BSL-1.0 8 | 9 | #include 10 | 11 | #include 12 | #include 13 | 14 | #include 15 | #include 16 | 17 | namespace Catch { 18 | 19 | std::uint32_t generateRandomSeed( GenerateFrom from ) { 20 | switch ( from ) { 21 | case GenerateFrom::Time: 22 | return static_cast( std::time( nullptr ) ); 23 | 24 | case GenerateFrom::Default: 25 | case GenerateFrom::RandomDevice: { 26 | std::random_device rd; 27 | return Detail::fillBitsFrom( rd ); 28 | } 29 | 30 | default: 31 | CATCH_ERROR("Unknown generation method"); 32 | } 33 | } 34 | 35 | } // end namespace Catch 36 | -------------------------------------------------------------------------------- /test/catch/tests/ExtraTests/X35-DuplicatedReporterNames.cpp: -------------------------------------------------------------------------------- 1 | 2 | // Copyright Catch2 Authors 3 | // Distributed under the Boost Software License, Version 1.0. 4 | // (See accompanying file LICENSE.txt or copy at 5 | // https://www.boost.org/LICENSE_1_0.txt) 6 | 7 | // SPDX-License-Identifier: BSL-1.0 8 | 9 | /**\file 10 | * Checks that reporter registration errors are caught and handled as 11 | * startup errors, by causing a registration error by registering multiple 12 | * reporters with the same name. 13 | */ 14 | 15 | #include 16 | 17 | #include 18 | #include 19 | 20 | namespace { 21 | //! Trivial custom reporter for registration 22 | class TestReporter : public Catch::StreamingReporterBase { 23 | public: 24 | using StreamingReporterBase::StreamingReporterBase; 25 | 26 | static std::string getDescription() { return "X35 test reporter"; } 27 | }; 28 | } 29 | 30 | CATCH_REGISTER_REPORTER( "test-reporter", TestReporter ) 31 | CATCH_REGISTER_REPORTER( "test-reporter", TestReporter ) 32 | -------------------------------------------------------------------------------- /tools/gha_conda_coverage.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | # Echo each command 4 | set -x 5 | 6 | # Exit on error. 7 | set -e 8 | 9 | # Core deps. 10 | sudo apt-get install wget 11 | 12 | # Install conda+deps. 13 | wget https://github.com/conda-forge/miniforge/releases/latest/download/Miniforge3-Linux-x86_64.sh -O miniconda.sh 14 | export deps_dir=$HOME/local 15 | export PATH="$HOME/miniconda/bin:$PATH" 16 | bash miniconda.sh -b -p $HOME/miniconda 17 | mamba create -y -p $deps_dir cxx-compiler cmake libboost-devel ninja lcov 18 | source activate $deps_dir 19 | 20 | # Create the build dir and cd into it. 21 | mkdir build 22 | cd build 23 | 24 | # GCC build. 25 | cmake -G Ninja ../ -DCMAKE_PREFIX_PATH=$deps_dir \ 26 | -DCMAKE_CXX_COMPILER=g++ \ 27 | -DCMAKE_BUILD_TYPE=Debug \ 28 | -DTANUKI_BUILD_TESTS=yes \ 29 | -DTANUKI_BUILD_TUTORIALS=yes \ 30 | -DTANUKI_WITH_BOOST_S11N=yes \ 31 | -DCMAKE_CXX_FLAGS="--coverage" 32 | ninja 33 | ctest -V -j4 34 | 35 | # Create lcov report. 36 | # NOTE: this is apparently picked up automatically 37 | # by the codecov action. 38 | lcov --capture --directory . --output-file coverage.info 39 | 40 | set +e 41 | set +x 42 | -------------------------------------------------------------------------------- /test/catch/.github/workflows/validate-header-guards.yml: -------------------------------------------------------------------------------- 1 | name: Check header guards 2 | 3 | on: [push, pull_request] 4 | 5 | jobs: 6 | build: 7 | # Set the type of machine to run on 8 | runs-on: ubuntu-20.04 9 | steps: 10 | 11 | - name: Checkout source code 12 | uses: actions/checkout@v4 13 | 14 | - name: Setup Dependencies 15 | uses: actions/setup-python@v2 16 | with: 17 | python-version: '3.7' 18 | - name: Install checkguard 19 | run: pip install guardonce 20 | 21 | - name: Check that include guards are properly named 22 | run: | 23 | wrong_files=$(checkguard -r src/catch2/ -p "name | append _INCLUDED | upper") 24 | if [[ $wrong_files ]]; then 25 | echo "Files with wrong header guard:" 26 | echo $wrong_files 27 | exit 1 28 | fi 29 | 30 | - name: Check that there are no duplicated filenames 31 | run: | 32 | ./tools/scripts/checkDuplicateFilenames.py 33 | 34 | - name: Check that all source files have the correct license header 35 | run: | 36 | ./tools/scripts/checkLicense.py 37 | -------------------------------------------------------------------------------- /cmake/yacma/LICENSE: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) 2016-2022 Francesco Biscani 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /test/catch/src/catch2/internal/catch_context.cpp: -------------------------------------------------------------------------------- 1 | 2 | // Copyright Catch2 Authors 3 | // Distributed under the Boost Software License, Version 1.0. 4 | // (See accompanying file LICENSE.txt or copy at 5 | // https://www.boost.org/LICENSE_1_0.txt) 6 | 7 | // SPDX-License-Identifier: BSL-1.0 8 | #include 9 | #include 10 | #include 11 | 12 | namespace Catch { 13 | 14 | Context* Context::currentContext = nullptr; 15 | 16 | void cleanUpContext() { 17 | delete Context::currentContext; 18 | Context::currentContext = nullptr; 19 | } 20 | void Context::createContext() { 21 | currentContext = new Context(); 22 | } 23 | 24 | Context& getCurrentMutableContext() { 25 | if ( !Context::currentContext ) { Context::createContext(); } 26 | // NOLINTNEXTLINE(clang-analyzer-core.uninitialized.UndefReturn) 27 | return *Context::currentContext; 28 | } 29 | 30 | SimplePcg32& sharedRng() { 31 | static SimplePcg32 s_rng; 32 | return s_rng; 33 | } 34 | 35 | } 36 | -------------------------------------------------------------------------------- /test/catch/src/catch2/benchmark/catch_outlier_classification.hpp: -------------------------------------------------------------------------------- 1 | 2 | // Copyright Catch2 Authors 3 | // Distributed under the Boost Software License, Version 1.0. 4 | // (See accompanying file LICENSE.txt or copy at 5 | // https://www.boost.org/LICENSE_1_0.txt) 6 | 7 | // SPDX-License-Identifier: BSL-1.0 8 | // Adapted from donated nonius code. 9 | 10 | #ifndef CATCH_OUTLIER_CLASSIFICATION_HPP_INCLUDED 11 | #define CATCH_OUTLIER_CLASSIFICATION_HPP_INCLUDED 12 | 13 | namespace Catch { 14 | namespace Benchmark { 15 | struct OutlierClassification { 16 | int samples_seen = 0; 17 | int low_severe = 0; // more than 3 times IQR below Q1 18 | int low_mild = 0; // 1.5 to 3 times IQR below Q1 19 | int high_mild = 0; // 1.5 to 3 times IQR above Q3 20 | int high_severe = 0; // more than 3 times IQR above Q3 21 | 22 | constexpr int total() const { 23 | return low_severe + low_mild + high_mild + high_severe; 24 | } 25 | }; 26 | } // namespace Benchmark 27 | } // namespace Catch 28 | 29 | #endif // CATCH_OUTLIERS_CLASSIFICATION_HPP_INCLUDED 30 | -------------------------------------------------------------------------------- /test/catch/src/catch2/internal/catch_config_counter.hpp: -------------------------------------------------------------------------------- 1 | 2 | // Copyright Catch2 Authors 3 | // Distributed under the Boost Software License, Version 1.0. 4 | // (See accompanying file LICENSE.txt or copy at 5 | // https://www.boost.org/LICENSE_1_0.txt) 6 | 7 | // SPDX-License-Identifier: BSL-1.0 8 | 9 | /** \file 10 | * Wrapper for the CONFIG configuration option 11 | * 12 | * When generating internal unique names, there are two options. Either 13 | * we mix in the current line number, or mix in an incrementing number. 14 | * We prefer the latter, using `__COUNTER__`, but users might want to 15 | * use the former. 16 | */ 17 | 18 | #ifndef CATCH_CONFIG_COUNTER_HPP_INCLUDED 19 | #define CATCH_CONFIG_COUNTER_HPP_INCLUDED 20 | 21 | #include 22 | 23 | #if ( !defined(__JETBRAINS_IDE__) || __JETBRAINS_IDE__ >= 20170300L ) 24 | #define CATCH_INTERNAL_CONFIG_COUNTER 25 | #endif 26 | 27 | #if defined( CATCH_INTERNAL_CONFIG_COUNTER ) && \ 28 | !defined( CATCH_CONFIG_NO_COUNTER ) && \ 29 | !defined( CATCH_CONFIG_COUNTER ) 30 | # define CATCH_CONFIG_COUNTER 31 | #endif 32 | 33 | 34 | #endif // CATCH_CONFIG_COUNTER_HPP_INCLUDED 35 | -------------------------------------------------------------------------------- /tutorial/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | function(ADD_TANUKI_TUTORIAL arg1) 2 | add_executable(${arg1} ${arg1}.cpp) 3 | target_link_libraries(${arg1} PRIVATE tanuki) 4 | if(TANUKI_WITH_BOOST_S11N) 5 | target_link_libraries(${arg1} PRIVATE tanuki_boost_s11n) 6 | endif() 7 | target_compile_options(${arg1} PRIVATE 8 | "$<$:${TANUKI_CXX_FLAGS_DEBUG}>" 9 | "$<$:${TANUKI_CXX_FLAGS_RELEASE}>" 10 | "$<$:${TANUKI_CXX_FLAGS_RELEASE}>" 11 | "$<$:${TANUKI_CXX_FLAGS_RELEASE}>" 12 | ) 13 | 14 | # Setup the C++ standard. 15 | target_compile_features(${arg1} PRIVATE cxx_std_20) 16 | set_property(TARGET ${arg1} PROPERTY CXX_EXTENSIONS NO) 17 | 18 | add_test(${arg1} ${arg1}) 19 | endfunction() 20 | 21 | ADD_TANUKI_TUTORIAL(hello_world) 22 | ADD_TANUKI_TUTORIAL(simple_interface) 23 | ADD_TANUKI_TUTORIAL(reference_interface) 24 | ADD_TANUKI_TUTORIAL(custom_storage) 25 | ADD_TANUKI_TUTORIAL(wrap_reference) 26 | ADD_TANUKI_TUTORIAL(emplace) 27 | ADD_TANUKI_TUTORIAL(compose1) 28 | ADD_TANUKI_TUTORIAL(compose2) 29 | ADD_TANUKI_TUTORIAL(nonintrusive) 30 | ADD_TANUKI_TUTORIAL(ref_semantics) 31 | ADD_TANUKI_TUTORIAL(std_function) 32 | -------------------------------------------------------------------------------- /tutorial/hello_world.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | 5 | #include 6 | 7 | template 8 | struct any_iface_impl : public Base { 9 | }; 10 | 11 | struct any_iface { 12 | virtual ~any_iface() = default; 13 | 14 | template 15 | using impl = any_iface_impl; 16 | }; 17 | 18 | // An empty implementation. 19 | struct any1 : any_iface { 20 | }; 21 | 22 | // An implementation storing a string. 23 | struct any2 : any_iface { 24 | std::string str_; 25 | 26 | explicit any2(std::string s) : str_(std::move(s)) {} 27 | }; 28 | 29 | int main() 30 | { 31 | // Traditional OO-style. 32 | std::unique_ptr ptr1 = std::make_unique(); 33 | std::unique_ptr ptr2 = std::make_unique("hello world"); 34 | 35 | // Type-erasure approach. 36 | using any_wrap = tanuki::wrap; 37 | 38 | // Store an integer. 39 | any_wrap w1(42); 40 | 41 | // Store a string. 42 | any_wrap w2(std::string("hello world")); 43 | 44 | // Store anything... 45 | struct foo { 46 | }; 47 | any_wrap w3(foo{}); 48 | } 49 | -------------------------------------------------------------------------------- /test/catch/src/catch2/internal/catch_singletons.cpp: -------------------------------------------------------------------------------- 1 | 2 | // Copyright Catch2 Authors 3 | // Distributed under the Boost Software License, Version 1.0. 4 | // (See accompanying file LICENSE.txt or copy at 5 | // https://www.boost.org/LICENSE_1_0.txt) 6 | 7 | // SPDX-License-Identifier: BSL-1.0 8 | #include 9 | 10 | #include 11 | 12 | namespace Catch { 13 | 14 | namespace { 15 | static auto getSingletons() -> std::vector*& { 16 | static std::vector* g_singletons = nullptr; 17 | if( !g_singletons ) 18 | g_singletons = new std::vector(); 19 | return g_singletons; 20 | } 21 | } 22 | 23 | ISingleton::~ISingleton() = default; 24 | 25 | void addSingleton(ISingleton* singleton ) { 26 | getSingletons()->push_back( singleton ); 27 | } 28 | void cleanupSingletons() { 29 | auto& singletons = getSingletons(); 30 | for( auto singleton : *singletons ) 31 | delete singleton; 32 | delete singletons; 33 | singletons = nullptr; 34 | } 35 | 36 | } // namespace Catch 37 | -------------------------------------------------------------------------------- /test/catch/src/catch2/matchers/internal/catch_matchers_impl.cpp: -------------------------------------------------------------------------------- 1 | 2 | // Copyright Catch2 Authors 3 | // Distributed under the Boost Software License, Version 1.0. 4 | // (See accompanying file LICENSE.txt or copy at 5 | // https://www.boost.org/LICENSE_1_0.txt) 6 | 7 | // SPDX-License-Identifier: BSL-1.0 8 | 9 | #include 10 | #include 11 | #include 12 | #include 13 | 14 | namespace Catch { 15 | 16 | // This is the general overload that takes a any string matcher 17 | // There is another overload, in catch_assertionhandler.h/.cpp, that only takes a string and infers 18 | // the Equals matcher (so the header does not mention matchers) 19 | void handleExceptionMatchExpr( AssertionHandler& handler, StringMatcher const& matcher ) { 20 | std::string exceptionMessage = Catch::translateActiveException(); 21 | MatchExpr expr( CATCH_MOVE(exceptionMessage), matcher ); 22 | handler.handleExpr( expr ); 23 | } 24 | 25 | } // namespace Catch 26 | -------------------------------------------------------------------------------- /test/catch/.github/pull_request_template.md: -------------------------------------------------------------------------------- 1 | 9 | 10 | 11 | ## Description 12 | 18 | 19 | ## GitHub Issues 20 | 29 | -------------------------------------------------------------------------------- /test/catch/src/catch2/internal/catch_decomposer.cpp: -------------------------------------------------------------------------------- 1 | 2 | // Copyright Catch2 Authors 3 | // Distributed under the Boost Software License, Version 1.0. 4 | // (See accompanying file LICENSE.txt or copy at 5 | // https://www.boost.org/LICENSE_1_0.txt) 6 | 7 | // SPDX-License-Identifier: BSL-1.0 8 | 9 | #include 10 | 11 | namespace Catch { 12 | 13 | void ITransientExpression::streamReconstructedExpression( 14 | std::ostream& os ) const { 15 | // We can't make this function pure virtual to keep ITransientExpression 16 | // constexpr, so we write error message instead 17 | os << "Some class derived from ITransientExpression without overriding streamReconstructedExpression"; 18 | } 19 | 20 | void formatReconstructedExpression( std::ostream &os, std::string const& lhs, StringRef op, std::string const& rhs ) { 21 | if( lhs.size() + rhs.size() < 40 && 22 | lhs.find('\n') == std::string::npos && 23 | rhs.find('\n') == std::string::npos ) 24 | os << lhs << ' ' << op << ' ' << rhs; 25 | else 26 | os << lhs << '\n' << op << '\n' << rhs; 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /test/catch/src/catch2/catch_totals.hpp: -------------------------------------------------------------------------------- 1 | 2 | // Copyright Catch2 Authors 3 | // Distributed under the Boost Software License, Version 1.0. 4 | // (See accompanying file LICENSE.txt or copy at 5 | // https://www.boost.org/LICENSE_1_0.txt) 6 | 7 | // SPDX-License-Identifier: BSL-1.0 8 | #ifndef CATCH_TOTALS_HPP_INCLUDED 9 | #define CATCH_TOTALS_HPP_INCLUDED 10 | 11 | #include 12 | 13 | namespace Catch { 14 | 15 | struct Counts { 16 | Counts operator - ( Counts const& other ) const; 17 | Counts& operator += ( Counts const& other ); 18 | 19 | std::uint64_t total() const; 20 | bool allPassed() const; 21 | bool allOk() const; 22 | 23 | std::uint64_t passed = 0; 24 | std::uint64_t failed = 0; 25 | std::uint64_t failedButOk = 0; 26 | std::uint64_t skipped = 0; 27 | }; 28 | 29 | struct Totals { 30 | 31 | Totals operator - ( Totals const& other ) const; 32 | Totals& operator += ( Totals const& other ); 33 | 34 | Totals delta( Totals const& prevTotals ) const; 35 | 36 | Counts assertions; 37 | Counts testCases; 38 | }; 39 | } 40 | 41 | #endif // CATCH_TOTALS_HPP_INCLUDED 42 | -------------------------------------------------------------------------------- /test/catch/tests/SelfTest/UsageTests/Decomposition.tests.cpp: -------------------------------------------------------------------------------- 1 | 2 | // Copyright Catch2 Authors 3 | // Distributed under the Boost Software License, Version 1.0. 4 | // (See accompanying file LICENSE.txt or copy at 5 | // https://www.boost.org/LICENSE_1_0.txt) 6 | 7 | // SPDX-License-Identifier: BSL-1.0 8 | 9 | #include 10 | #include 11 | 12 | namespace { 13 | 14 | struct truthy { 15 | truthy(bool b):m_value(b){} 16 | operator bool() const { 17 | return false; 18 | } 19 | bool m_value; 20 | }; 21 | 22 | std::ostream& operator<<(std::ostream& o, truthy) { 23 | o << "Hey, its truthy!"; 24 | return o; 25 | } 26 | 27 | } // end anonymous namespace 28 | 29 | #include 30 | 31 | TEST_CASE( "Reconstruction should be based on stringification: #914" , "[Decomposition][failing][.]") { 32 | CHECK(truthy(false)); 33 | } 34 | 35 | TEST_CASE("#1005: Comparing pointer to int and long (NULL can be either on various systems)", "[Decomposition][approvals]") { 36 | FILE* fptr = nullptr; 37 | REQUIRE( fptr == 0 ); 38 | REQUIRE_FALSE( fptr != 0 ); 39 | REQUIRE( fptr == 0l ); 40 | REQUIRE_FALSE( fptr != 0l ); 41 | } 42 | -------------------------------------------------------------------------------- /test/catch/src/catch2/internal/catch_tag_alias_registry.hpp: -------------------------------------------------------------------------------- 1 | 2 | // Copyright Catch2 Authors 3 | // Distributed under the Boost Software License, Version 1.0. 4 | // (See accompanying file LICENSE.txt or copy at 5 | // https://www.boost.org/LICENSE_1_0.txt) 6 | 7 | // SPDX-License-Identifier: BSL-1.0 8 | #ifndef CATCH_TAG_ALIAS_REGISTRY_HPP_INCLUDED 9 | #define CATCH_TAG_ALIAS_REGISTRY_HPP_INCLUDED 10 | 11 | #include 12 | #include 13 | 14 | #include 15 | #include 16 | 17 | namespace Catch { 18 | struct SourceLineInfo; 19 | 20 | class TagAliasRegistry : public ITagAliasRegistry { 21 | public: 22 | ~TagAliasRegistry() override; 23 | TagAlias const* find( std::string const& alias ) const override; 24 | std::string expandAliases( std::string const& unexpandedTestSpec ) const override; 25 | void add( std::string const& alias, std::string const& tag, SourceLineInfo const& lineInfo ); 26 | 27 | private: 28 | std::map m_registry; 29 | }; 30 | 31 | } // end namespace Catch 32 | 33 | #endif // CATCH_TAG_ALIAS_REGISTRY_HPP_INCLUDED 34 | -------------------------------------------------------------------------------- /test/catch/tests/SelfTest/IntrospectiveTests/Stream.tests.cpp: -------------------------------------------------------------------------------- 1 | 2 | // Copyright Catch2 Authors 3 | // Distributed under the Boost Software License, Version 1.0. 4 | // (See accompanying file LICENSE.txt or copy at 5 | // https://www.boost.org/LICENSE_1_0.txt) 6 | 7 | // SPDX-License-Identifier: BSL-1.0 8 | 9 | #include 10 | 11 | #include 12 | 13 | TEST_CASE( "Cout stream properly declares it writes to stdout", "[streams]" ) { 14 | REQUIRE( Catch::makeStream( "-" )->isConsole() ); 15 | } 16 | 17 | TEST_CASE( "Empty stream name opens cout stream", "[streams]" ) { 18 | REQUIRE( Catch::makeStream( "" )->isConsole() ); 19 | } 20 | 21 | TEST_CASE( "stdout and stderr streams have %-starting name", "[streams]" ) { 22 | REQUIRE( Catch::makeStream( "%stderr" )->isConsole() ); 23 | REQUIRE( Catch::makeStream( "%stdout" )->isConsole() ); 24 | } 25 | 26 | TEST_CASE( "request an unknown %-starting stream fails", "[streams]" ) { 27 | REQUIRE_THROWS( Catch::makeStream( "%somestream" ) ); 28 | } 29 | 30 | TEST_CASE( "makeStream recognizes %debug stream name", "[streams]" ) { 31 | REQUIRE_NOTHROW( Catch::makeStream( "%debug" ) ); 32 | } 33 | -------------------------------------------------------------------------------- /test/catch/src/catch2/benchmark/detail/catch_repeat.hpp: -------------------------------------------------------------------------------- 1 | 2 | // Copyright Catch2 Authors 3 | // Distributed under the Boost Software License, Version 1.0. 4 | // (See accompanying file LICENSE.txt or copy at 5 | // https://www.boost.org/LICENSE_1_0.txt) 6 | 7 | // SPDX-License-Identifier: BSL-1.0 8 | // Adapted from donated nonius code. 9 | 10 | #ifndef CATCH_REPEAT_HPP_INCLUDED 11 | #define CATCH_REPEAT_HPP_INCLUDED 12 | 13 | #include 14 | #include 15 | 16 | namespace Catch { 17 | namespace Benchmark { 18 | namespace Detail { 19 | template 20 | struct repeater { 21 | void operator()(int k) const { 22 | for (int i = 0; i < k; ++i) { 23 | fun(); 24 | } 25 | } 26 | Fun fun; 27 | }; 28 | template 29 | repeater> repeat(Fun&& fun) { 30 | return { CATCH_FORWARD(fun) }; 31 | } 32 | } // namespace Detail 33 | } // namespace Benchmark 34 | } // namespace Catch 35 | 36 | #endif // CATCH_REPEAT_HPP_INCLUDED 37 | -------------------------------------------------------------------------------- /test/catch/src/catch2/internal/catch_config_wchar.hpp: -------------------------------------------------------------------------------- 1 | 2 | // Copyright Catch2 Authors 3 | // Distributed under the Boost Software License, Version 1.0. 4 | // (See accompanying file LICENSE.txt or copy at 5 | // https://www.boost.org/LICENSE_1_0.txt) 6 | 7 | // SPDX-License-Identifier: BSL-1.0 8 | 9 | /** \file 10 | * Wrapper for the WCHAR configuration option 11 | * 12 | * We want to support platforms that do not provide `wchar_t`, so we 13 | * sometimes have to disable providing wchar_t overloads through Catch2, 14 | * e.g. the StringMaker specialization for `std::wstring`. 15 | */ 16 | 17 | #ifndef CATCH_CONFIG_WCHAR_HPP_INCLUDED 18 | #define CATCH_CONFIG_WCHAR_HPP_INCLUDED 19 | 20 | #include 21 | 22 | // We assume that WCHAR should be enabled by default, and only disabled 23 | // for a shortlist (so far only DJGPP) of compilers. 24 | 25 | #if defined(__DJGPP__) 26 | # define CATCH_INTERNAL_CONFIG_NO_WCHAR 27 | #endif // __DJGPP__ 28 | 29 | #if !defined( CATCH_INTERNAL_CONFIG_NO_WCHAR ) && \ 30 | !defined( CATCH_CONFIG_NO_WCHAR ) && \ 31 | !defined( CATCH_CONFIG_WCHAR ) 32 | # define CATCH_CONFIG_WCHAR 33 | #endif 34 | 35 | #endif // CATCH_CONFIG_WCHAR_HPP_INCLUDED 36 | -------------------------------------------------------------------------------- /test/catch/src/catch2/internal/catch_test_failure_exception.hpp: -------------------------------------------------------------------------------- 1 | 2 | // Copyright Catch2 Authors 3 | // Distributed under the Boost Software License, Version 1.0. 4 | // (See accompanying file LICENSE.txt or copy at 5 | // https://www.boost.org/LICENSE_1_0.txt) 6 | 7 | // SPDX-License-Identifier: BSL-1.0 8 | #ifndef CATCH_TEST_FAILURE_EXCEPTION_HPP_INCLUDED 9 | #define CATCH_TEST_FAILURE_EXCEPTION_HPP_INCLUDED 10 | 11 | namespace Catch { 12 | 13 | //! Used to signal that an assertion macro failed 14 | struct TestFailureException{}; 15 | //! Used to signal that the remainder of a test should be skipped 16 | struct TestSkipException {}; 17 | 18 | /** 19 | * Outlines throwing of `TestFailureException` into a single TU 20 | * 21 | * Also handles `CATCH_CONFIG_DISABLE_EXCEPTIONS` for callers. 22 | */ 23 | [[noreturn]] void throw_test_failure_exception(); 24 | 25 | /** 26 | * Outlines throwing of `TestSkipException` into a single TU 27 | * 28 | * Also handles `CATCH_CONFIG_DISABLE_EXCEPTIONS` for callers. 29 | */ 30 | [[noreturn]] void throw_test_skip_exception(); 31 | 32 | } // namespace Catch 33 | 34 | #endif // CATCH_TEST_FAILURE_EXCEPTION_HPP_INCLUDED 35 | -------------------------------------------------------------------------------- /test/catch/src/catch2/catch_tag_alias_autoregistrar.hpp: -------------------------------------------------------------------------------- 1 | 2 | // Copyright Catch2 Authors 3 | // Distributed under the Boost Software License, Version 1.0. 4 | // (See accompanying file LICENSE.txt or copy at 5 | // https://www.boost.org/LICENSE_1_0.txt) 6 | 7 | // SPDX-License-Identifier: BSL-1.0 8 | #ifndef CATCH_TAG_ALIAS_AUTOREGISTRAR_HPP_INCLUDED 9 | #define CATCH_TAG_ALIAS_AUTOREGISTRAR_HPP_INCLUDED 10 | 11 | #include 12 | #include 13 | #include 14 | 15 | namespace Catch { 16 | 17 | struct RegistrarForTagAliases { 18 | RegistrarForTagAliases( char const* alias, char const* tag, SourceLineInfo const& lineInfo ); 19 | }; 20 | 21 | } // end namespace Catch 22 | 23 | #define CATCH_REGISTER_TAG_ALIAS( alias, spec ) \ 24 | CATCH_INTERNAL_START_WARNINGS_SUPPRESSION \ 25 | CATCH_INTERNAL_SUPPRESS_GLOBALS_WARNINGS \ 26 | namespace{ Catch::RegistrarForTagAliases INTERNAL_CATCH_UNIQUE_NAME( AutoRegisterTagAlias )( alias, spec, CATCH_INTERNAL_LINEINFO ); } \ 27 | CATCH_INTERNAL_STOP_WARNINGS_SUPPRESSION 28 | 29 | #endif // CATCH_TAG_ALIAS_AUTOREGISTRAR_HPP_INCLUDED 30 | -------------------------------------------------------------------------------- /test/catch/src/catch2/internal/catch_source_line_info.hpp: -------------------------------------------------------------------------------- 1 | 2 | // Copyright Catch2 Authors 3 | // Distributed under the Boost Software License, Version 1.0. 4 | // (See accompanying file LICENSE.txt or copy at 5 | // https://www.boost.org/LICENSE_1_0.txt) 6 | 7 | // SPDX-License-Identifier: BSL-1.0 8 | #ifndef CATCH_SOURCE_LINE_INFO_HPP_INCLUDED 9 | #define CATCH_SOURCE_LINE_INFO_HPP_INCLUDED 10 | 11 | #include 12 | #include 13 | 14 | namespace Catch { 15 | 16 | struct SourceLineInfo { 17 | 18 | SourceLineInfo() = delete; 19 | constexpr SourceLineInfo( char const* _file, std::size_t _line ) noexcept: 20 | file( _file ), 21 | line( _line ) 22 | {} 23 | 24 | bool operator == ( SourceLineInfo const& other ) const noexcept; 25 | bool operator < ( SourceLineInfo const& other ) const noexcept; 26 | 27 | char const* file; 28 | std::size_t line; 29 | 30 | friend std::ostream& operator << (std::ostream& os, SourceLineInfo const& info); 31 | }; 32 | } 33 | 34 | #define CATCH_INTERNAL_LINEINFO \ 35 | ::Catch::SourceLineInfo( __FILE__, static_cast( __LINE__ ) ) 36 | 37 | #endif // CATCH_SOURCE_LINE_INFO_HPP_INCLUDED 38 | -------------------------------------------------------------------------------- /test/catch/src/catch2/internal/catch_wildcard_pattern.hpp: -------------------------------------------------------------------------------- 1 | 2 | // Copyright Catch2 Authors 3 | // Distributed under the Boost Software License, Version 1.0. 4 | // (See accompanying file LICENSE.txt or copy at 5 | // https://www.boost.org/LICENSE_1_0.txt) 6 | 7 | // SPDX-License-Identifier: BSL-1.0 8 | #ifndef CATCH_WILDCARD_PATTERN_HPP_INCLUDED 9 | #define CATCH_WILDCARD_PATTERN_HPP_INCLUDED 10 | 11 | #include 12 | 13 | #include 14 | 15 | namespace Catch 16 | { 17 | class WildcardPattern { 18 | enum WildcardPosition { 19 | NoWildcard = 0, 20 | WildcardAtStart = 1, 21 | WildcardAtEnd = 2, 22 | WildcardAtBothEnds = WildcardAtStart | WildcardAtEnd 23 | }; 24 | 25 | public: 26 | 27 | WildcardPattern( std::string const& pattern, CaseSensitive caseSensitivity ); 28 | bool matches( std::string const& str ) const; 29 | 30 | private: 31 | std::string normaliseString( std::string const& str ) const; 32 | CaseSensitive m_caseSensitivity; 33 | WildcardPosition m_wildcard = NoWildcard; 34 | std::string m_pattern; 35 | }; 36 | } 37 | 38 | #endif // CATCH_WILDCARD_PATTERN_HPP_INCLUDED 39 | -------------------------------------------------------------------------------- /tutorial/ref_semantics.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | 5 | #include 6 | 7 | template 8 | struct any_iface_impl : public Base { 9 | }; 10 | 11 | struct any_iface { 12 | template 13 | using impl = any_iface_impl; 14 | }; 15 | 16 | int main() 17 | { 18 | using any_wrap = tanuki::wrap{.semantics = tanuki::wrap_semantics::reference}>; 19 | 20 | any_wrap w1(std::string("hello world")); 21 | 22 | auto w2 = w1; 23 | 24 | std::cout << std::boolalpha; 25 | 26 | std::cout << "Address of the value wrapped by w1: " << tanuki::value_ptr(w1) << '\n'; 27 | std::cout << "Address of the value wrapped by w2: " << tanuki::value_ptr(w2) << '\n'; 28 | 29 | std::cout << "Do w1 and w2 share ownership? " << same_value(w1, w2) << '\n'; 30 | 31 | auto w3 = copy(w1); 32 | 33 | std::cout << "Address of the value wrapped by w1: " << tanuki::value_ptr(w1) << '\n'; 34 | std::cout << "Address of the value wrapped by w3: " << tanuki::value_ptr(w3) << '\n'; 35 | 36 | std::cout << "Do w1 and w3 share ownership? " << same_value(w1, w3) << '\n'; 37 | } 38 | -------------------------------------------------------------------------------- /test/catch/tests/ExtraTests/X04-DisabledExceptions-CustomHandler.cpp: -------------------------------------------------------------------------------- 1 | 2 | // Copyright Catch2 Authors 3 | // Distributed under the Boost Software License, Version 1.0. 4 | // (See accompanying file LICENSE.txt or copy at 5 | // https://www.boost.org/LICENSE_1_0.txt) 6 | 7 | // SPDX-License-Identifier: BSL-1.0 8 | 9 | #include 10 | 11 | #include 12 | 13 | namespace Catch { 14 | [[noreturn]] 15 | void throw_exception(std::exception const& e) { 16 | std::cerr << "====== CUSTOM HANDLER ====== run terminates because an exception was thrown.\n" 17 | << "The message was: " << e.what() << '\n'; 18 | // Avoid abort and other exceptional exits -- there is no way 19 | // to tell CMake that abort is the desired outcome of a test. 20 | exit(1); 21 | } 22 | } 23 | 24 | TEST_CASE("Tests that run") { 25 | // All of these should be run and be reported 26 | CHECK(1 == 2); 27 | CHECK(1 == 1); 28 | CHECK(1 != 3); 29 | CHECK(1 == 4); 30 | } 31 | 32 | 33 | 34 | TEST_CASE("Tests that abort") { 35 | REQUIRE(1 == 1); 36 | REQUIRE(1 != 2); 37 | REQUIRE(1 == 3); 38 | // We should not get here, because the test above aborts 39 | REQUIRE(1 != 4); 40 | } 41 | -------------------------------------------------------------------------------- /test/catch/src/catch2/reporters/catch_reporter_compact.hpp: -------------------------------------------------------------------------------- 1 | 2 | // Copyright Catch2 Authors 3 | // Distributed under the Boost Software License, Version 1.0. 4 | // (See accompanying file LICENSE.txt or copy at 5 | // https://www.boost.org/LICENSE_1_0.txt) 6 | 7 | // SPDX-License-Identifier: BSL-1.0 8 | #ifndef CATCH_REPORTER_COMPACT_HPP_INCLUDED 9 | #define CATCH_REPORTER_COMPACT_HPP_INCLUDED 10 | 11 | 12 | #include 13 | 14 | 15 | namespace Catch { 16 | 17 | class CompactReporter final : public StreamingReporterBase { 18 | public: 19 | using StreamingReporterBase::StreamingReporterBase; 20 | 21 | ~CompactReporter() override; 22 | 23 | static std::string getDescription(); 24 | 25 | void noMatchingTestCases( StringRef unmatchedSpec ) override; 26 | 27 | void testRunStarting( TestRunInfo const& _testInfo ) override; 28 | 29 | void assertionEnded(AssertionStats const& _assertionStats) override; 30 | 31 | void sectionEnded(SectionStats const& _sectionStats) override; 32 | 33 | void testRunEnded(TestRunStats const& _testRunStats) override; 34 | 35 | }; 36 | 37 | } // end namespace Catch 38 | 39 | #endif // CATCH_REPORTER_COMPACT_HPP_INCLUDED 40 | -------------------------------------------------------------------------------- /test/catch/src/catch2/benchmark/detail/catch_measure.hpp: -------------------------------------------------------------------------------- 1 | 2 | // Copyright Catch2 Authors 3 | // Distributed under the Boost Software License, Version 1.0. 4 | // (See accompanying file LICENSE.txt or copy at 5 | // https://www.boost.org/LICENSE_1_0.txt) 6 | 7 | // SPDX-License-Identifier: BSL-1.0 8 | // Adapted from donated nonius code. 9 | 10 | #ifndef CATCH_MEASURE_HPP_INCLUDED 11 | #define CATCH_MEASURE_HPP_INCLUDED 12 | 13 | #include 14 | #include 15 | #include 16 | 17 | namespace Catch { 18 | namespace Benchmark { 19 | namespace Detail { 20 | template 21 | TimingOf measure(Fun&& fun, Args&&... args) { 22 | auto start = Clock::now(); 23 | auto&& r = Detail::complete_invoke(CATCH_FORWARD(fun), CATCH_FORWARD(args)...); 24 | auto end = Clock::now(); 25 | auto delta = end - start; 26 | return { delta, CATCH_FORWARD(r), 1 }; 27 | } 28 | } // namespace Detail 29 | } // namespace Benchmark 30 | } // namespace Catch 31 | 32 | #endif // CATCH_MEASURE_HPP_INCLUDED 33 | -------------------------------------------------------------------------------- /test/catch/src/catch2/generators/catch_generators_all.hpp: -------------------------------------------------------------------------------- 1 | 2 | // Copyright Catch2 Authors 3 | // Distributed under the Boost Software License, Version 1.0. 4 | // (See accompanying file LICENSE.txt or copy at 5 | // https://www.boost.org/LICENSE_1_0.txt) 6 | 7 | // SPDX-License-Identifier: BSL-1.0 8 | /** \file 9 | * This is a convenience header for Catch2's Generator support. It includes 10 | * **all** of Catch2 headers related to generators. 11 | * 12 | * Generally the Catch2 users should use specific includes they need, 13 | * but this header can be used instead for ease-of-experimentation, or 14 | * just plain convenience, at the cost of (significantly) increased 15 | * compilation times. 16 | * 17 | * When a new header is added to either the `generators` folder, 18 | * or to the corresponding internal subfolder, it should be added here. 19 | */ 20 | 21 | #ifndef CATCH_GENERATORS_ALL_HPP_INCLUDED 22 | #define CATCH_GENERATORS_ALL_HPP_INCLUDED 23 | 24 | #include 25 | #include 26 | #include 27 | #include 28 | #include 29 | 30 | #endif // CATCH_GENERATORS_ALL_HPP_INCLUDED 31 | -------------------------------------------------------------------------------- /test/catch/src/catch2/interfaces/catch_interfaces_exception.hpp: -------------------------------------------------------------------------------- 1 | 2 | // Copyright Catch2 Authors 3 | // Distributed under the Boost Software License, Version 1.0. 4 | // (See accompanying file LICENSE.txt or copy at 5 | // https://www.boost.org/LICENSE_1_0.txt) 6 | 7 | // SPDX-License-Identifier: BSL-1.0 8 | #ifndef CATCH_INTERFACES_EXCEPTION_HPP_INCLUDED 9 | #define CATCH_INTERFACES_EXCEPTION_HPP_INCLUDED 10 | 11 | #include 12 | 13 | #include 14 | #include 15 | 16 | namespace Catch { 17 | using exceptionTranslateFunction = std::string(*)(); 18 | 19 | class IExceptionTranslator; 20 | using ExceptionTranslators = std::vector>; 21 | 22 | class IExceptionTranslator { 23 | public: 24 | virtual ~IExceptionTranslator(); // = default 25 | virtual std::string translate( ExceptionTranslators::const_iterator it, ExceptionTranslators::const_iterator itEnd ) const = 0; 26 | }; 27 | 28 | class IExceptionTranslatorRegistry { 29 | public: 30 | virtual ~IExceptionTranslatorRegistry(); // = default 31 | virtual std::string translateActiveException() const = 0; 32 | }; 33 | 34 | } // namespace Catch 35 | 36 | #endif // CATCH_INTERFACES_EXCEPTION_HPP_INCLUDED 37 | -------------------------------------------------------------------------------- /test/catch/src/catch2/internal/catch_enum_values_registry.hpp: -------------------------------------------------------------------------------- 1 | 2 | // Copyright Catch2 Authors 3 | // Distributed under the Boost Software License, Version 1.0. 4 | // (See accompanying file LICENSE.txt or copy at 5 | // https://www.boost.org/LICENSE_1_0.txt) 6 | 7 | // SPDX-License-Identifier: BSL-1.0 8 | #ifndef CATCH_ENUM_VALUES_REGISTRY_HPP_INCLUDED 9 | #define CATCH_ENUM_VALUES_REGISTRY_HPP_INCLUDED 10 | 11 | #include 12 | #include 13 | #include 14 | 15 | #include 16 | 17 | namespace Catch { 18 | 19 | namespace Detail { 20 | 21 | Catch::Detail::unique_ptr makeEnumInfo( StringRef enumName, StringRef allValueNames, std::vector const& values ); 22 | 23 | class EnumValuesRegistry : public IMutableEnumValuesRegistry { 24 | 25 | std::vector> m_enumInfos; 26 | 27 | EnumInfo const& registerEnum( StringRef enumName, StringRef allValueNames, std::vector const& values) override; 28 | }; 29 | 30 | std::vector parseEnums( StringRef enums ); 31 | 32 | } // Detail 33 | 34 | } // Catch 35 | 36 | #endif // CATCH_ENUM_VALUES_REGISTRY_HPP_INCLUDED 37 | -------------------------------------------------------------------------------- /test/catch/CMake/llvm-cov-wrapper: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | # This file is part of CMake-codecov. 4 | # 5 | # Copyright (c) 6 | # 2015-2017 RWTH Aachen University, Federal Republic of Germany 7 | # 8 | # See the LICENSE file in the package base directory for details 9 | # 10 | # Written by Alexander Haase, alexander.haase@rwth-aachen.de 11 | # 12 | 13 | if [ -z "$LLVM_COV_BIN" ] 14 | then 15 | echo "LLVM_COV_BIN not set!" >& 2 16 | exit 1 17 | fi 18 | 19 | 20 | # Get LLVM version to find out. 21 | LLVM_VERSION=$($LLVM_COV_BIN -version | grep -i "LLVM version" \ 22 | | sed "s/^\([A-Za-z ]*\)\([0-9]\).\([0-9]\).*$/\2.\3/g") 23 | 24 | if [ "$1" = "-v" ] 25 | then 26 | echo "llvm-cov-wrapper $LLVM_VERSION" 27 | exit 0 28 | fi 29 | 30 | 31 | if [ -n "$LLVM_VERSION" ] 32 | then 33 | MAJOR=$(echo $LLVM_VERSION | cut -d'.' -f1) 34 | MINOR=$(echo $LLVM_VERSION | cut -d'.' -f2) 35 | 36 | if [ $MAJOR -eq 3 ] && [ $MINOR -le 4 ] 37 | then 38 | if [ -f "$1" ] 39 | then 40 | filename=$(basename "$1") 41 | extension="${filename##*.}" 42 | 43 | case "$extension" in 44 | "gcno") exec $LLVM_COV_BIN --gcno="$1" ;; 45 | "gcda") exec $LLVM_COV_BIN --gcda="$1" ;; 46 | esac 47 | fi 48 | fi 49 | 50 | if [ $MAJOR -eq 3 ] && [ $MINOR -le 5 ] 51 | then 52 | exec $LLVM_COV_BIN $@ 53 | fi 54 | fi 55 | 56 | exec $LLVM_COV_BIN gcov $@ 57 | -------------------------------------------------------------------------------- /test/catch/src/catch2/internal/catch_leak_detector.cpp: -------------------------------------------------------------------------------- 1 | 2 | // Copyright Catch2 Authors 3 | // Distributed under the Boost Software License, Version 1.0. 4 | // (See accompanying file LICENSE.txt or copy at 5 | // https://www.boost.org/LICENSE_1_0.txt) 6 | 7 | // SPDX-License-Identifier: BSL-1.0 8 | 9 | #include 10 | #include 11 | #include 12 | 13 | #ifdef CATCH_CONFIG_WINDOWS_CRTDBG 14 | #include 15 | 16 | namespace Catch { 17 | 18 | LeakDetector::LeakDetector() { 19 | int flag = _CrtSetDbgFlag(_CRTDBG_REPORT_FLAG); 20 | flag |= _CRTDBG_LEAK_CHECK_DF; 21 | flag |= _CRTDBG_ALLOC_MEM_DF; 22 | _CrtSetDbgFlag(flag); 23 | _CrtSetReportMode(_CRT_WARN, _CRTDBG_MODE_FILE | _CRTDBG_MODE_DEBUG); 24 | _CrtSetReportFile(_CRT_WARN, _CRTDBG_FILE_STDERR); 25 | // Change this to leaking allocation's number to break there 26 | _CrtSetBreakAlloc(-1); 27 | } 28 | } 29 | 30 | #else // ^^ Windows crt debug heap enabled // Windows crt debug heap disabled vv 31 | 32 | Catch::LeakDetector::LeakDetector() = default; 33 | 34 | #endif // CATCH_CONFIG_WINDOWS_CRTDBG 35 | 36 | Catch::LeakDetector::~LeakDetector() { 37 | Catch::cleanUp(); 38 | } 39 | -------------------------------------------------------------------------------- /test/catch/.github/workflows/windows-simple-builds.yml: -------------------------------------------------------------------------------- 1 | name: Windows builds (basic) 2 | 3 | on: [push, pull_request] 4 | 5 | jobs: 6 | build: 7 | name: ${{matrix.os}}, ${{matrix.std}}, ${{matrix.build_type}}, ${{matrix.platform}} 8 | runs-on: ${{matrix.os}} 9 | strategy: 10 | matrix: 11 | os: [windows-2019, windows-2022] 12 | platform: [Win32, x64] 13 | build_type: [Debug, Release] 14 | std: [14, 17] 15 | steps: 16 | - uses: actions/checkout@v4 17 | 18 | - name: Configure build 19 | working-directory: ${{runner.workspace}} 20 | run: | 21 | cmake -S $Env:GITHUB_WORKSPACE ` 22 | -B ${{runner.workspace}}/build ` 23 | -DCMAKE_CXX_STANDARD=${{matrix.std}} ` 24 | -A ${{matrix.platform}} ` 25 | --preset all-tests 26 | 27 | - name: Build tests 28 | working-directory: ${{runner.workspace}} 29 | run: cmake --build build --config ${{matrix.build_type}} --parallel %NUMBER_OF_PROCESSORS% 30 | shell: cmd 31 | 32 | - name: Run tests 33 | working-directory: ${{runner.workspace}}/build 34 | env: 35 | CTEST_OUTPUT_ON_FAILURE: 1 36 | run: ctest -C ${{matrix.build_type}} -j %NUMBER_OF_PROCESSORS% 37 | shell: cmd 38 | -------------------------------------------------------------------------------- /test/catch/src/catch2/internal/catch_enforce.cpp: -------------------------------------------------------------------------------- 1 | 2 | // Copyright Catch2 Authors 3 | // Distributed under the Boost Software License, Version 1.0. 4 | // (See accompanying file LICENSE.txt or copy at 5 | // https://www.boost.org/LICENSE_1_0.txt) 6 | 7 | // SPDX-License-Identifier: BSL-1.0 8 | #include 9 | #include 10 | 11 | #include 12 | 13 | 14 | namespace Catch { 15 | #if defined(CATCH_CONFIG_DISABLE_EXCEPTIONS) && !defined(CATCH_CONFIG_DISABLE_EXCEPTIONS_CUSTOM_HANDLER) 16 | [[noreturn]] 17 | void throw_exception(std::exception const& e) { 18 | Catch::cerr() << "Catch will terminate because it needed to throw an exception.\n" 19 | << "The message was: " << e.what() << '\n'; 20 | std::terminate(); 21 | } 22 | #endif 23 | 24 | [[noreturn]] 25 | void throw_logic_error(std::string const& msg) { 26 | throw_exception(std::logic_error(msg)); 27 | } 28 | 29 | [[noreturn]] 30 | void throw_domain_error(std::string const& msg) { 31 | throw_exception(std::domain_error(msg)); 32 | } 33 | 34 | [[noreturn]] 35 | void throw_runtime_error(std::string const& msg) { 36 | throw_exception(std::runtime_error(msg)); 37 | } 38 | 39 | 40 | 41 | } // namespace Catch; 42 | -------------------------------------------------------------------------------- /test/catch/src/catch2/internal/catch_source_line_info.cpp: -------------------------------------------------------------------------------- 1 | 2 | // Copyright Catch2 Authors 3 | // Distributed under the Boost Software License, Version 1.0. 4 | // (See accompanying file LICENSE.txt or copy at 5 | // https://www.boost.org/LICENSE_1_0.txt) 6 | 7 | // SPDX-License-Identifier: BSL-1.0 8 | #include 9 | 10 | #include 11 | #include 12 | 13 | namespace Catch { 14 | 15 | bool SourceLineInfo::operator == ( SourceLineInfo const& other ) const noexcept { 16 | return line == other.line && (file == other.file || std::strcmp(file, other.file) == 0); 17 | } 18 | bool SourceLineInfo::operator < ( SourceLineInfo const& other ) const noexcept { 19 | // We can assume that the same file will usually have the same pointer. 20 | // Thus, if the pointers are the same, there is no point in calling the strcmp 21 | return line < other.line || ( line == other.line && file != other.file && (std::strcmp(file, other.file) < 0)); 22 | } 23 | 24 | std::ostream& operator << ( std::ostream& os, SourceLineInfo const& info ) { 25 | #ifndef __GNUG__ 26 | os << info.file << '(' << info.line << ')'; 27 | #else 28 | os << info.file << ':' << info.line; 29 | #endif 30 | return os; 31 | } 32 | 33 | } // end namespace Catch 34 | -------------------------------------------------------------------------------- /test/catch/src/catch2/internal/catch_case_insensitive_comparisons.cpp: -------------------------------------------------------------------------------- 1 | 2 | // Copyright Catch2 Authors 3 | // Distributed under the Boost Software License, Version 1.0. 4 | // (See accompanying file LICENSE.txt or copy at 5 | // https://www.boost.org/LICENSE_1_0.txt) 6 | 7 | // SPDX-License-Identifier: BSL-1.0 8 | 9 | #include 10 | #include 11 | 12 | #include 13 | 14 | namespace Catch { 15 | namespace Detail { 16 | 17 | bool CaseInsensitiveLess::operator()( StringRef lhs, 18 | StringRef rhs ) const { 19 | return std::lexicographical_compare( 20 | lhs.begin(), lhs.end(), 21 | rhs.begin(), rhs.end(), 22 | []( char l, char r ) { return toLower( l ) < toLower( r ); } ); 23 | } 24 | 25 | bool 26 | CaseInsensitiveEqualTo::operator()( StringRef lhs, 27 | StringRef rhs ) const { 28 | return std::equal( 29 | lhs.begin(), lhs.end(), 30 | rhs.begin(), rhs.end(), 31 | []( char l, char r ) { return toLower( l ) == toLower( r ); } ); 32 | } 33 | 34 | } // namespace Detail 35 | } // namespace Catch 36 | -------------------------------------------------------------------------------- /test/catch/src/catch2/internal/catch_lazy_expr.hpp: -------------------------------------------------------------------------------- 1 | 2 | // Copyright Catch2 Authors 3 | // Distributed under the Boost Software License, Version 1.0. 4 | // (See accompanying file LICENSE.txt or copy at 5 | // https://www.boost.org/LICENSE_1_0.txt) 6 | 7 | // SPDX-License-Identifier: BSL-1.0 8 | #ifndef CATCH_LAZY_EXPR_HPP_INCLUDED 9 | #define CATCH_LAZY_EXPR_HPP_INCLUDED 10 | 11 | #include 12 | 13 | namespace Catch { 14 | 15 | class ITransientExpression; 16 | 17 | class LazyExpression { 18 | friend class AssertionHandler; 19 | friend struct AssertionStats; 20 | friend class RunContext; 21 | 22 | ITransientExpression const* m_transientExpression = nullptr; 23 | bool m_isNegated; 24 | public: 25 | constexpr LazyExpression( bool isNegated ): 26 | m_isNegated(isNegated) 27 | {} 28 | constexpr LazyExpression(LazyExpression const& other) = default; 29 | LazyExpression& operator = ( LazyExpression const& ) = delete; 30 | 31 | constexpr explicit operator bool() const { 32 | return m_transientExpression != nullptr; 33 | } 34 | 35 | friend auto operator << ( std::ostream& os, LazyExpression const& lazyExpr ) -> std::ostream&; 36 | }; 37 | 38 | } // namespace Catch 39 | 40 | #endif // CATCH_LAZY_EXPR_HPP_INCLUDED 41 | -------------------------------------------------------------------------------- /test/catch/.github/workflows/linux-meson-builds.yml: -------------------------------------------------------------------------------- 1 | name: Linux builds (meson) 2 | 3 | on: [push, pull_request] 4 | 5 | jobs: 6 | build: 7 | name: meson ${{matrix.cxx}}, C++${{matrix.std}}, ${{matrix.build_type}} 8 | runs-on: ubuntu-22.04 9 | strategy: 10 | matrix: 11 | cxx: 12 | - g++-11 13 | - clang++-11 14 | build_type: [debug, release] 15 | std: [14, 17] 16 | include: 17 | - cxx: clang++-11 18 | other_pkgs: clang-11 19 | 20 | steps: 21 | - uses: actions/checkout@v4 22 | 23 | - name: Prepare environment 24 | run: | 25 | sudo apt-get update 26 | sudo apt-get install -y meson ninja-build ${{matrix.other_pkgs}} 27 | 28 | - name: Configure build 29 | env: 30 | CXX: ${{matrix.cxx}} 31 | CXXFLAGS: -std=c++${{matrix.std}} ${{matrix.cxxflags}} 32 | # Note: $GITHUB_WORKSPACE is distinct from ${{runner.workspace}}. 33 | # This is important 34 | run: | 35 | meson -Dbuildtype=${{matrix.build_type}} ${{runner.workspace}}/meson-build 36 | 37 | - name: Build tests + lib 38 | working-directory: ${{runner.workspace}}/meson-build 39 | run: ninja 40 | 41 | - name: Run tests 42 | working-directory: ${{runner.workspace}}/meson-build 43 | run: | 44 | meson test --verbose 45 | -------------------------------------------------------------------------------- /test/catch/src/catch2/catch_version.hpp: -------------------------------------------------------------------------------- 1 | 2 | // Copyright Catch2 Authors 3 | // Distributed under the Boost Software License, Version 1.0. 4 | // (See accompanying file LICENSE.txt or copy at 5 | // https://www.boost.org/LICENSE_1_0.txt) 6 | 7 | // SPDX-License-Identifier: BSL-1.0 8 | #ifndef CATCH_VERSION_HPP_INCLUDED 9 | #define CATCH_VERSION_HPP_INCLUDED 10 | 11 | #include 12 | 13 | namespace Catch { 14 | 15 | // Versioning information 16 | struct Version { 17 | Version( Version const& ) = delete; 18 | Version& operator=( Version const& ) = delete; 19 | Version( unsigned int _majorVersion, 20 | unsigned int _minorVersion, 21 | unsigned int _patchNumber, 22 | char const * const _branchName, 23 | unsigned int _buildNumber ); 24 | 25 | unsigned int const majorVersion; 26 | unsigned int const minorVersion; 27 | unsigned int const patchNumber; 28 | 29 | // buildNumber is only used if branchName is not null 30 | char const * const branchName; 31 | unsigned int const buildNumber; 32 | 33 | friend std::ostream& operator << ( std::ostream& os, Version const& version ); 34 | }; 35 | 36 | Version const& libraryVersion(); 37 | } 38 | 39 | #endif // CATCH_VERSION_HPP_INCLUDED 40 | -------------------------------------------------------------------------------- /test/catch/src/catch2/catch_timer.cpp: -------------------------------------------------------------------------------- 1 | 2 | // Copyright Catch2 Authors 3 | // Distributed under the Boost Software License, Version 1.0. 4 | // (See accompanying file LICENSE.txt or copy at 5 | // https://www.boost.org/LICENSE_1_0.txt) 6 | 7 | // SPDX-License-Identifier: BSL-1.0 8 | #include 9 | 10 | #include 11 | 12 | namespace Catch { 13 | 14 | namespace { 15 | static auto getCurrentNanosecondsSinceEpoch() -> uint64_t { 16 | return std::chrono::duration_cast(std::chrono::steady_clock::now().time_since_epoch()).count(); 17 | } 18 | } // end unnamed namespace 19 | 20 | void Timer::start() { 21 | m_nanoseconds = getCurrentNanosecondsSinceEpoch(); 22 | } 23 | auto Timer::getElapsedNanoseconds() const -> uint64_t { 24 | return getCurrentNanosecondsSinceEpoch() - m_nanoseconds; 25 | } 26 | auto Timer::getElapsedMicroseconds() const -> uint64_t { 27 | return getElapsedNanoseconds()/1000; 28 | } 29 | auto Timer::getElapsedMilliseconds() const -> unsigned int { 30 | return static_cast(getElapsedMicroseconds()/1000); 31 | } 32 | auto Timer::getElapsedSeconds() const -> double { 33 | return static_cast(getElapsedMicroseconds())/1000000.0; 34 | } 35 | 36 | 37 | } // namespace Catch 38 | -------------------------------------------------------------------------------- /test/catch/src/catch2/internal/catch_polyfills.cpp: -------------------------------------------------------------------------------- 1 | 2 | // Copyright Catch2 Authors 3 | // Distributed under the Boost Software License, Version 1.0. 4 | // (See accompanying file LICENSE.txt or copy at 5 | // https://www.boost.org/LICENSE_1_0.txt) 6 | 7 | // SPDX-License-Identifier: BSL-1.0 8 | 9 | #include 10 | #include 11 | #include 12 | 13 | #include 14 | 15 | namespace Catch { 16 | 17 | #if !defined(CATCH_CONFIG_POLYFILL_ISNAN) 18 | bool isnan(float f) { 19 | return std::isnan(f); 20 | } 21 | bool isnan(double d) { 22 | return std::isnan(d); 23 | } 24 | #else 25 | // For now we only use this for embarcadero 26 | bool isnan(float f) { 27 | return std::_isnan(f); 28 | } 29 | bool isnan(double d) { 30 | return std::_isnan(d); 31 | } 32 | #endif 33 | 34 | #if !defined( CATCH_CONFIG_GLOBAL_NEXTAFTER ) 35 | float nextafter( float x, float y ) { return std::nextafter( x, y ); } 36 | double nextafter( double x, double y ) { return std::nextafter( x, y ); } 37 | #else 38 | float nextafter( float x, float y ) { return ::nextafterf( x, y ); } 39 | double nextafter( double x, double y ) { return ::nextafter( x, y ); } 40 | #endif 41 | 42 | } // end namespace Catch 43 | -------------------------------------------------------------------------------- /test/catch/tools/misc/appveyorBuildConfigurationScript.bat: -------------------------------------------------------------------------------- 1 | SETLOCAL EnableDelayedExpansion 2 | 3 | @REM # Possibilities: 4 | @REM # Debug build + coverage 5 | @REM # Debug build + examples 6 | @REM # Debug build + --- 7 | @REM # Release build 8 | if "%CONFIGURATION%"=="Debug" ( 9 | if "%coverage%"=="1" ( 10 | @REM # coverage needs to build the special helper as well as the main 11 | cmake -Htools/misc -Bbuild-misc -A%PLATFORM% || exit /b !ERRORLEVEL! 12 | cmake --build build-misc || exit /b !ERRORLEVEL! 13 | cmake -H. -BBuild -A%PLATFORM% -DCATCH_TEST_USE_WMAIN=%wmain% -DMEMORYCHECK_COMMAND=build-misc\Debug\CoverageHelper.exe -DMEMORYCHECK_COMMAND_OPTIONS=--sep-- -DMEMORYCHECK_TYPE=Valgrind -DCATCH_BUILD_EXAMPLES=%examples% -DCATCH_BUILD_EXTRA_TESTS=%examples% -DCATCH_ENABLE_CONFIGURE_TESTS=%configure_tests% -DCATCH_DEVELOPMENT_BUILD=ON || exit /b !ERRORLEVEL! 14 | ) else ( 15 | @REM # We know that coverage is 0 16 | cmake -H. -BBuild -A%PLATFORM% -DCATCH_TEST_USE_WMAIN=%wmain% -DCATCH_BUILD_EXAMPLES=%examples% -DCATCH_BUILD_EXTRA_TESTS=%examples% -DCATCH_BUILD_SURROGATES=%surrogates% -DCATCH_DEVELOPMENT_BUILD=ON -DCATCH_ENABLE_CONFIGURE_TESTS=%configure_tests% || exit /b !ERRORLEVEL! 17 | ) 18 | ) 19 | if "%CONFIGURATION%"=="Release" ( 20 | cmake -H. -BBuild -A%PLATFORM% -DCATCH_TEST_USE_WMAIN=%wmain% -DCATCH_DEVELOPMENT_BUILD=ON || exit /b !ERRORLEVEL! 21 | ) 22 | -------------------------------------------------------------------------------- /doc/conf.py.in: -------------------------------------------------------------------------------- 1 | # Configuration file for the Sphinx documentation builder. 2 | # 3 | # For the full list of built-in configuration values, see the documentation: 4 | # https://www.sphinx-doc.org/en/master/usage/configuration.html 5 | 6 | # -- Project information ----------------------------------------------------- 7 | # https://www.sphinx-doc.org/en/master/usage/configuration.html#project-information 8 | 9 | project = 'tanuki' 10 | copyright = '2024, Francesco Biscani' 11 | author = 'Francesco Biscani' 12 | release = '@tanuki_VERSION@' 13 | 14 | # -- General configuration --------------------------------------------------- 15 | # https://www.sphinx-doc.org/en/master/usage/configuration.html#general-configuration 16 | 17 | extensions = [] 18 | 19 | templates_path = ['_templates'] 20 | exclude_patterns = ['_build', 'Thumbs.db', '.DS_Store'] 21 | 22 | 23 | 24 | # -- Options for HTML output ------------------------------------------------- 25 | # https://www.sphinx-doc.org/en/master/usage/configuration.html#options-for-html-output 26 | 27 | html_static_path = [] 28 | 29 | html_theme = "sphinx_book_theme" 30 | 31 | html_theme_options = { 32 | "repository_url": "https://github.com/bluescarni/tanuki", 33 | "use_repository_button": True, 34 | "use_issues_button": True, 35 | # See: https://github.com/pydata/pydata-sphinx-theme/issues/1492 36 | "navigation_with_keys": False, 37 | } 38 | -------------------------------------------------------------------------------- /test/catch/src/catch2/internal/catch_config_static_analysis_support.hpp: -------------------------------------------------------------------------------- 1 | 2 | // Copyright Catch2 Authors 3 | // Distributed under the Boost Software License, Version 1.0. 4 | // (See accompanying file LICENSE.txt or copy at 5 | // https://www.boost.org/LICENSE_1_0.txt) 6 | 7 | // SPDX-License-Identifier: BSL-1.0 8 | 9 | /** \file 10 | * Wrapper for the STATIC_ANALYSIS_SUPPORT configuration option 11 | * 12 | * Some of Catch2's macros can be defined differently to work better with 13 | * static analysis tools, like clang-tidy or coverity. 14 | * Currently the main use case is to show that `SECTION`s are executed 15 | * exclusively, and not all in one run of a `TEST_CASE`. 16 | */ 17 | 18 | #ifndef CATCH_CONFIG_STATIC_ANALYSIS_SUPPORT_HPP_INCLUDED 19 | #define CATCH_CONFIG_STATIC_ANALYSIS_SUPPORT_HPP_INCLUDED 20 | 21 | #include 22 | 23 | #if defined(__clang_analyzer__) || defined(__COVERITY__) 24 | #define CATCH_INTERNAL_CONFIG_STATIC_ANALYSIS_SUPPORT 25 | #endif 26 | 27 | #if defined( CATCH_INTERNAL_CONFIG_STATIC_ANALYSIS_SUPPORT ) && \ 28 | !defined( CATCH_CONFIG_NO_EXPERIMENTAL_STATIC_ANALYSIS_SUPPORT ) && \ 29 | !defined( CATCH_CONFIG_EXPERIMENTAL_STATIC_ANALYSIS_SUPPORT ) 30 | # define CATCH_CONFIG_EXPERIMENTAL_STATIC_ANALYSIS_SUPPORT 31 | #endif 32 | 33 | 34 | #endif // CATCH_CONFIG_STATIC_ANALYSIS_SUPPORT_HPP_INCLUDED 35 | -------------------------------------------------------------------------------- /test/catch/tests/ExtraTests/X23-CasingInReporterNames.cpp: -------------------------------------------------------------------------------- 1 | 2 | // Copyright Catch2 Authors 3 | // Distributed under the Boost Software License, Version 1.0. 4 | // (See accompanying file LICENSE.txt or copy at 5 | // https://www.boost.org/LICENSE_1_0.txt) 6 | 7 | // SPDX-License-Identifier: BSL-1.0 8 | 9 | /**\file 10 | * Test that reporter registration is case-preserving, selection is 11 | * case-insensitive. 12 | * 13 | * This is done by registering a custom reporter that prints out a marker 14 | * string upon construction and then invoking the binary with different 15 | * casings of the name. 16 | */ 17 | 18 | #include 19 | #include 20 | 21 | #include 22 | #include 23 | 24 | class TestReporter : public Catch::StreamingReporterBase { 25 | public: 26 | TestReporter(Catch::ReporterConfig&& _config): 27 | StreamingReporterBase(std::move(_config)) { 28 | std::cout << "TestReporter constructed\n"; 29 | } 30 | 31 | static std::string getDescription() { 32 | return "Reporter for testing casing handling in reporter registration/selection"; 33 | } 34 | 35 | ~TestReporter() override; 36 | }; 37 | 38 | TestReporter::~TestReporter() = default; 39 | 40 | CATCH_REGISTER_REPORTER("testReporterCASED", TestReporter) 41 | 42 | -------------------------------------------------------------------------------- /test/catch/tests/ExtraTests/X03-DisabledExceptions-DefaultHandler.cpp: -------------------------------------------------------------------------------- 1 | 2 | // Copyright Catch2 Authors 3 | // Distributed under the Boost Software License, Version 1.0. 4 | // (See accompanying file LICENSE.txt or copy at 5 | // https://www.boost.org/LICENSE_1_0.txt) 6 | 7 | // SPDX-License-Identifier: BSL-1.0 8 | 9 | #include 10 | #include 11 | #include 12 | #include 13 | 14 | TEST_CASE("Tests that run") { 15 | // All of these should be run and be reported 16 | CHECK(1 == 2); 17 | CHECK(1 == 1); 18 | CHECK(1 != 3); 19 | CHECK(1 == 4); 20 | } 21 | 22 | 23 | 24 | TEST_CASE("Tests that abort") { 25 | // Avoid abort and other exceptional exits -- there is no way 26 | // to tell CMake that abort is the desired outcome of a test. 27 | std::set_terminate([](){exit(1);}); 28 | REQUIRE(1 == 1); 29 | REQUIRE(1 != 2); 30 | REQUIRE(1 == 3); 31 | // We should not get here, because the test above aborts 32 | REQUIRE(1 != 4); 33 | } 34 | 35 | TEST_CASE( "Misc. macros to check that they compile without exceptions" ) { 36 | BENCHMARK( "simple benchmark" ) { return 1 * 2 + 3; }; 37 | REQUIRE_THAT( 1, 38 | Catch::Matchers::Predicate( []( int i ) { return i == 1; } ) ); 39 | } 40 | -------------------------------------------------------------------------------- /.github/workflows/static.yml: -------------------------------------------------------------------------------- 1 | name: Build and upload docs 2 | 3 | on: 4 | # Runs on pushes targeting the default branch 5 | push: 6 | branches: ["main"] 7 | 8 | # Allows you to run this workflow manually from the Actions tab 9 | workflow_dispatch: 10 | 11 | # Sets permissions of the GITHUB_TOKEN to allow deployment to GitHub Pages 12 | permissions: 13 | contents: read 14 | pages: write 15 | id-token: write 16 | 17 | # Allow only one concurrent deployment, skipping runs queued between the run in-progress and latest queued. 18 | # However, do NOT cancel in-progress runs as we want to allow these production deployments to complete. 19 | concurrency: 20 | group: "pages" 21 | cancel-in-progress: false 22 | 23 | jobs: 24 | # Single deploy job since we're just deploying 25 | deploy: 26 | environment: 27 | name: github-pages 28 | url: ${{ steps.deployment.outputs.page_url }} 29 | runs-on: ubuntu-latest 30 | steps: 31 | - name: Checkout 32 | uses: actions/checkout@v4 33 | - name: Setup Pages 34 | uses: actions/configure-pages@v4 35 | - name: Build docs 36 | run: bash tools/gha_conda_docs.sh 37 | - name: Upload docs 38 | uses: actions/upload-pages-artifact@v3 39 | with: 40 | path: './doc/_build/html' 41 | - name: Deploy to GitHub Pages 42 | id: deployment 43 | uses: actions/deploy-pages@v4 44 | -------------------------------------------------------------------------------- /test/catch/.github/workflows/mac-builds-m1.yml: -------------------------------------------------------------------------------- 1 | name: Arm Mac builds 2 | 3 | on: [push, pull_request] 4 | 5 | jobs: 6 | build: 7 | runs-on: macos-14 8 | strategy: 9 | matrix: 10 | cxx: 11 | - clang++ 12 | build_type: [Debug, Release] 13 | std: [14, 17] 14 | include: 15 | - build_type: Debug 16 | examples: ON 17 | extra_tests: ON 18 | 19 | steps: 20 | - uses: actions/checkout@v4 21 | 22 | - name: Configure build 23 | working-directory: ${{runner.workspace}} 24 | env: 25 | CXX: ${{matrix.cxx}} 26 | CXXFLAGS: ${{matrix.cxxflags}} 27 | run: | 28 | cmake -Bbuild -H$GITHUB_WORKSPACE \ 29 | -DCMAKE_BUILD_TYPE=${{matrix.build_type}} \ 30 | -DCMAKE_CXX_STANDARD=${{matrix.std}} \ 31 | -DCMAKE_CXX_STANDARD_REQUIRED=ON \ 32 | -DCATCH_DEVELOPMENT_BUILD=ON \ 33 | -DCATCH_BUILD_EXAMPLES=${{matrix.examples}} \ 34 | -DCATCH_BUILD_EXTRA_TESTS=${{matrix.examples}} 35 | 36 | - name: Build tests + lib 37 | working-directory: ${{runner.workspace}}/build 38 | run: make -j `sysctl -n hw.ncpu` 39 | 40 | - name: Run tests 41 | env: 42 | CTEST_OUTPUT_ON_FAILURE: 1 43 | working-directory: ${{runner.workspace}}/build 44 | run: ctest -C ${{matrix.build_type}} -j `sysctl -n hw.ncpu` 45 | -------------------------------------------------------------------------------- /test/catch/.clang-format: -------------------------------------------------------------------------------- 1 | --- 2 | Language: Cpp 3 | Standard: c++14 4 | 5 | # Note that we cannot use IncludeIsMainRegex functionality, because it 6 | # does not support includes in angle brackets (<>) 7 | SortIncludes: true 8 | IncludeBlocks: Regroup 9 | IncludeCategories: 10 | - Regex: 11 | Priority: 1 12 | - Regex: <.*/.*\.hpp> 13 | Priority: 2 14 | - Regex: <.*> 15 | Priority: 3 16 | 17 | AllowShortBlocksOnASingleLine: Always 18 | AllowShortEnumsOnASingleLine: false 19 | AllowShortFunctionsOnASingleLine: All 20 | AllowShortIfStatementsOnASingleLine: WithoutElse 21 | AllowShortLambdasOnASingleLine: Inline 22 | 23 | AccessModifierOffset: "-4" 24 | AlignEscapedNewlines: Left 25 | AllowAllConstructorInitializersOnNextLine: "true" 26 | BinPackArguments: "false" 27 | BinPackParameters: "false" 28 | BreakConstructorInitializers: AfterColon 29 | ConstructorInitializerAllOnOneLineOrOnePerLine: "true" 30 | DerivePointerAlignment: "false" 31 | FixNamespaceComments: "true" 32 | IndentCaseLabels: "false" 33 | IndentPPDirectives: AfterHash 34 | IndentWidth: "4" 35 | NamespaceIndentation: All 36 | PointerAlignment: Left 37 | SpaceBeforeCtorInitializerColon: "false" 38 | SpaceInEmptyParentheses: "false" 39 | SpacesInParentheses: "true" 40 | TabWidth: "4" 41 | UseTab: Never 42 | AlwaysBreakTemplateDeclarations: Yes 43 | SpaceAfterTemplateKeyword: true 44 | SortUsingDeclarations: true 45 | ReflowComments: true 46 | -------------------------------------------------------------------------------- /test/catch/src/catch2/internal/catch_message_info.hpp: -------------------------------------------------------------------------------- 1 | 2 | // Copyright Catch2 Authors 3 | // Distributed under the Boost Software License, Version 1.0. 4 | // (See accompanying file LICENSE.txt or copy at 5 | // https://www.boost.org/LICENSE_1_0.txt) 6 | 7 | // SPDX-License-Identifier: BSL-1.0 8 | #ifndef CATCH_MESSAGE_INFO_HPP_INCLUDED 9 | #define CATCH_MESSAGE_INFO_HPP_INCLUDED 10 | 11 | #include 12 | #include 13 | #include 14 | 15 | #include 16 | 17 | namespace Catch { 18 | 19 | struct MessageInfo { 20 | MessageInfo( StringRef _macroName, 21 | SourceLineInfo const& _lineInfo, 22 | ResultWas::OfType _type ); 23 | 24 | StringRef macroName; 25 | std::string message; 26 | SourceLineInfo lineInfo; 27 | ResultWas::OfType type; 28 | unsigned int sequence; 29 | 30 | bool operator == (MessageInfo const& other) const { 31 | return sequence == other.sequence; 32 | } 33 | bool operator < (MessageInfo const& other) const { 34 | return sequence < other.sequence; 35 | } 36 | private: 37 | static unsigned int globalCount; 38 | }; 39 | 40 | } // end namespace Catch 41 | 42 | #endif // CATCH_MESSAGE_INFO_HPP_INCLUDED 43 | -------------------------------------------------------------------------------- /test/catch/LICENSE.txt: -------------------------------------------------------------------------------- 1 | Boost Software License - Version 1.0 - August 17th, 2003 2 | 3 | Permission is hereby granted, free of charge, to any person or organization 4 | obtaining a copy of the software and accompanying documentation covered by 5 | this license (the "Software") to use, reproduce, display, distribute, 6 | execute, and transmit the Software, and to prepare derivative works of the 7 | Software, and to permit third-parties to whom the Software is furnished to 8 | do so, all subject to the following: 9 | 10 | The copyright notices in the Software and this entire statement, including 11 | the above license grant, this restriction and the following disclaimer, 12 | must be included in all copies of the Software, in whole or in part, and 13 | all derivative works of the Software, unless such copies or derivative 14 | works are solely in the form of machine-executable object code generated by 15 | a source language processor. 16 | 17 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 18 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 19 | FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT 20 | SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE 21 | FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE, 22 | ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER 23 | DEALINGS IN THE SOFTWARE. 24 | -------------------------------------------------------------------------------- /test/catch/src/catch2/reporters/catch_reporter_registrars.cpp: -------------------------------------------------------------------------------- 1 | 2 | // Copyright Catch2 Authors 3 | // Distributed under the Boost Software License, Version 1.0. 4 | // (See accompanying file LICENSE.txt or copy at 5 | // https://www.boost.org/LICENSE_1_0.txt) 6 | 7 | // SPDX-License-Identifier: BSL-1.0 8 | 9 | #include 10 | 11 | #include 12 | #include 13 | 14 | namespace Catch { 15 | namespace Detail { 16 | 17 | void registerReporterImpl( std::string const& name, 18 | IReporterFactoryPtr reporterPtr ) { 19 | CATCH_TRY { 20 | getMutableRegistryHub().registerReporter( 21 | name, CATCH_MOVE( reporterPtr ) ); 22 | } 23 | CATCH_CATCH_ALL { 24 | // Do not throw when constructing global objects, instead 25 | // register the exception to be processed later 26 | getMutableRegistryHub().registerStartupException(); 27 | } 28 | } 29 | 30 | void registerListenerImpl( Detail::unique_ptr listenerFactory ) { 31 | getMutableRegistryHub().registerListener( CATCH_MOVE(listenerFactory) ); 32 | } 33 | 34 | 35 | } // namespace Detail 36 | } // namespace Catch 37 | -------------------------------------------------------------------------------- /test/catch/examples/020-TestCase-1.cpp: -------------------------------------------------------------------------------- 1 | 2 | // Copyright Catch2 Authors 3 | // Distributed under the Boost Software License, Version 1.0. 4 | // (See accompanying file LICENSE.txt or copy at 5 | // https://www.boost.org/LICENSE_1_0.txt) 6 | 7 | // SPDX-License-Identifier: BSL-1.0 8 | 9 | // 020-TestCase-1.cpp 10 | 11 | #include 12 | 13 | TEST_CASE( "1: All test cases reside in other .cpp files (empty)", "[multi-file:1]" ) { 14 | } 15 | 16 | // ^^^ 17 | // Normally no TEST_CASEs in this file. 18 | // Here just to show there are two source files via option --list-tests. 19 | 20 | // Compile & run: 21 | // - g++ -std=c++14 -Wall -I$(CATCH_SINGLE_INCLUDE) -c 020-TestCase-1.cpp 22 | // - g++ -std=c++14 -Wall -I$(CATCH_SINGLE_INCLUDE) -o 020-TestCase TestCase-1.o 020-TestCase-2.cpp && 020-TestCase --success 23 | // 24 | // - cl -EHsc -I%CATCH_SINGLE_INCLUDE% -c 020-TestCase-1.cpp 25 | // - cl -EHsc -I%CATCH_SINGLE_INCLUDE% -Fe020-TestCase.exe 020-TestCase-1.obj 020-TestCase-2.cpp && 020-TestCase --success 26 | 27 | // Expected test case listing: 28 | // 29 | // prompt> 020-TestCase --list-tests * 30 | // Matching test cases: 31 | // 1: All test cases reside in other .cpp files (empty) 32 | // [multi-file:1] 33 | // 2: Factorial of 0 is computed (fail) 34 | // [multi-file:2] 35 | // 2: Factorials of 1 and higher are computed (pass) 36 | // [multi-file:2] 37 | // 3 matching test cases 38 | -------------------------------------------------------------------------------- /test/catch/src/catch2/catch_section_info.hpp: -------------------------------------------------------------------------------- 1 | 2 | // Copyright Catch2 Authors 3 | // Distributed under the Boost Software License, Version 1.0. 4 | // (See accompanying file LICENSE.txt or copy at 5 | // https://www.boost.org/LICENSE_1_0.txt) 6 | 7 | // SPDX-License-Identifier: BSL-1.0 8 | #ifndef CATCH_SECTION_INFO_HPP_INCLUDED 9 | #define CATCH_SECTION_INFO_HPP_INCLUDED 10 | 11 | #include 12 | #include 13 | #include 14 | #include 15 | 16 | #include 17 | 18 | namespace Catch { 19 | 20 | struct SectionInfo { 21 | // The last argument is ignored, so that people can write 22 | // SECTION("ShortName", "Proper description that is long") and 23 | // still use the `-c` flag comfortably. 24 | SectionInfo( SourceLineInfo const& _lineInfo, std::string _name, 25 | const char* const = nullptr ): 26 | name(CATCH_MOVE(_name)), 27 | lineInfo(_lineInfo) 28 | {} 29 | 30 | std::string name; 31 | SourceLineInfo lineInfo; 32 | }; 33 | 34 | struct SectionEndInfo { 35 | SectionInfo sectionInfo; 36 | Counts prevAssertions; 37 | double durationInSeconds; 38 | }; 39 | 40 | } // end namespace Catch 41 | 42 | #endif // CATCH_SECTION_INFO_HPP_INCLUDED 43 | -------------------------------------------------------------------------------- /test/catch/src/catch2/internal/catch_singletons.hpp: -------------------------------------------------------------------------------- 1 | 2 | // Copyright Catch2 Authors 3 | // Distributed under the Boost Software License, Version 1.0. 4 | // (See accompanying file LICENSE.txt or copy at 5 | // https://www.boost.org/LICENSE_1_0.txt) 6 | 7 | // SPDX-License-Identifier: BSL-1.0 8 | #ifndef CATCH_SINGLETONS_HPP_INCLUDED 9 | #define CATCH_SINGLETONS_HPP_INCLUDED 10 | 11 | namespace Catch { 12 | 13 | struct ISingleton { 14 | virtual ~ISingleton(); // = default 15 | }; 16 | 17 | 18 | void addSingleton( ISingleton* singleton ); 19 | void cleanupSingletons(); 20 | 21 | 22 | template 23 | class Singleton : SingletonImplT, public ISingleton { 24 | 25 | static auto getInternal() -> Singleton* { 26 | static Singleton* s_instance = nullptr; 27 | if( !s_instance ) { 28 | s_instance = new Singleton; 29 | addSingleton( s_instance ); 30 | } 31 | return s_instance; 32 | } 33 | 34 | public: 35 | static auto get() -> InterfaceT const& { 36 | return *getInternal(); 37 | } 38 | static auto getMutable() -> MutableInterfaceT& { 39 | return *getInternal(); 40 | } 41 | }; 42 | 43 | } // namespace Catch 44 | 45 | #endif // CATCH_SINGLETONS_HPP_INCLUDED 46 | -------------------------------------------------------------------------------- /tutorial/compose2.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | #include 4 | 5 | template 6 | struct foo_iface_impl : public Base { 7 | void foo() const final 8 | { 9 | getval(this).foo(); 10 | } 11 | }; 12 | 13 | // The foo() interface. 14 | struct foo_iface { 15 | virtual void foo() const = 0; 16 | 17 | template 18 | using impl = foo_iface_impl; 19 | }; 20 | 21 | template 22 | struct bar_iface_impl : foo_iface_impl { 23 | void bar() const final 24 | { 25 | getval(this).bar(); 26 | } 27 | }; 28 | 29 | // The bar() interface. 30 | struct bar_iface : foo_iface { 31 | virtual void bar() const = 0; 32 | 33 | template 34 | using impl = bar_iface_impl; 35 | }; 36 | 37 | struct foobar_model { 38 | void foo() const 39 | { 40 | std::cout << "Invoking foobar_model::foo()" << '\n'; 41 | }; 42 | void bar() const 43 | { 44 | std::cout << "Invoking foobar_model::bar()" << '\n'; 45 | }; 46 | }; 47 | 48 | int main() 49 | { 50 | // Define a wrap for the composite interface. 51 | using wrap_t = tanuki::wrap; 52 | 53 | // Wrap an object that satisfies the composite interface. 54 | wrap_t w1(foobar_model{}); 55 | 56 | // Invoke the member functions. 57 | w1->foo(); 58 | w1->bar(); 59 | } 60 | -------------------------------------------------------------------------------- /test/catch/src/catch2/internal/catch_debug_console.cpp: -------------------------------------------------------------------------------- 1 | 2 | // Copyright Catch2 Authors 3 | // Distributed under the Boost Software License, Version 1.0. 4 | // (See accompanying file LICENSE.txt or copy at 5 | // https://www.boost.org/LICENSE_1_0.txt) 6 | 7 | // SPDX-License-Identifier: BSL-1.0 8 | 9 | #include 10 | 11 | #include 12 | #include 13 | #include 14 | #include 15 | #include 16 | 17 | #include 18 | 19 | #if defined(CATCH_CONFIG_ANDROID_LOGWRITE) 20 | #include 21 | 22 | namespace Catch { 23 | void writeToDebugConsole( std::string const& text ) { 24 | __android_log_write( ANDROID_LOG_DEBUG, "Catch", text.c_str() ); 25 | } 26 | } 27 | 28 | #elif defined(CATCH_PLATFORM_WINDOWS) 29 | 30 | namespace Catch { 31 | void writeToDebugConsole( std::string const& text ) { 32 | ::OutputDebugStringA( text.c_str() ); 33 | } 34 | } 35 | 36 | #else 37 | 38 | namespace Catch { 39 | void writeToDebugConsole( std::string const& text ) { 40 | // !TBD: Need a version for Mac/ XCode and other IDEs 41 | Catch::cout() << text; 42 | } 43 | } 44 | 45 | #endif // Platform 46 | -------------------------------------------------------------------------------- /test/catch/src/catch2/reporters/catch_reporter_automake.hpp: -------------------------------------------------------------------------------- 1 | 2 | // Copyright Catch2 Authors 3 | // Distributed under the Boost Software License, Version 1.0. 4 | // (See accompanying file LICENSE.txt or copy at 5 | // https://www.boost.org/LICENSE_1_0.txt) 6 | 7 | // SPDX-License-Identifier: BSL-1.0 8 | #ifndef CATCH_REPORTER_AUTOMAKE_HPP_INCLUDED 9 | #define CATCH_REPORTER_AUTOMAKE_HPP_INCLUDED 10 | 11 | #include 12 | #include 13 | 14 | #include 15 | 16 | namespace Catch { 17 | 18 | class AutomakeReporter final : public StreamingReporterBase { 19 | public: 20 | // GCC5 compat: we cannot use inherited constructor, because it 21 | // doesn't implement backport of P0136 22 | AutomakeReporter(ReporterConfig&& _config): 23 | StreamingReporterBase(CATCH_MOVE(_config)) 24 | {} 25 | ~AutomakeReporter() override; 26 | 27 | static std::string getDescription() { 28 | using namespace std::string_literals; 29 | return "Reports test results in the format of Automake .trs files"s; 30 | } 31 | 32 | void testCaseEnded(TestCaseStats const& _testCaseStats) override; 33 | void skipTest(TestCaseInfo const& testInfo) override; 34 | }; 35 | 36 | } // end namespace Catch 37 | 38 | #endif // CATCH_REPORTER_AUTOMAKE_HPP_INCLUDED 39 | -------------------------------------------------------------------------------- /tutorial/custom_storage.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | #include 4 | 5 | template 6 | struct any_iface_impl : public Base { 7 | }; 8 | 9 | struct any_iface { 10 | template 11 | using impl = any_iface_impl; 12 | }; 13 | 14 | inline constexpr auto custom_config1 = tanuki::config<>{.static_size = tanuki::holder_size}; 15 | 16 | int main() 17 | { 18 | using wrap1_t = tanuki::wrap; 19 | 20 | wrap1_t w1(nullptr); 21 | 22 | std::cout << std::boolalpha; 23 | std::cout << "Is w1 using static storage? " << has_static_storage(w1) << '\n'; 24 | 25 | struct two_ptrs { 26 | void *p1 = nullptr; 27 | void *p2 = nullptr; 28 | }; 29 | 30 | wrap1_t w2(two_ptrs{}); 31 | 32 | std::cout << "Is w2 using static storage? " << has_static_storage(w2) << '\n'; 33 | 34 | constexpr auto custom_config2 = tanuki::config<>{.static_size = tanuki::holder_size, 35 | .static_align = tanuki::holder_align}; 36 | 37 | using wrap2_t = tanuki::wrap; 38 | 39 | wrap2_t w3(nullptr); 40 | 41 | std::cout << "Is w3 using static storage? " << has_static_storage(w3) << '\n'; 42 | 43 | std::cout << "sizeof(wrap1_t) is " << sizeof(wrap1_t) << ", sizeof(wrap2_t) is " << sizeof(wrap2_t) << '\n'; 44 | } 45 | -------------------------------------------------------------------------------- /test/catch/src/catch2/reporters/catch_reporter_automake.cpp: -------------------------------------------------------------------------------- 1 | 2 | // Copyright Catch2 Authors 3 | // Distributed under the Boost Software License, Version 1.0. 4 | // (See accompanying file LICENSE.txt or copy at 5 | // https://www.boost.org/LICENSE_1_0.txt) 6 | 7 | // SPDX-License-Identifier: BSL-1.0 8 | #include 9 | #include 10 | 11 | #include 12 | 13 | namespace Catch { 14 | 15 | AutomakeReporter::~AutomakeReporter() = default; 16 | 17 | void AutomakeReporter::testCaseEnded(TestCaseStats const& _testCaseStats) { 18 | // Possible values to emit are PASS, XFAIL, SKIP, FAIL, XPASS and ERROR. 19 | m_stream << ":test-result: "; 20 | if ( _testCaseStats.totals.testCases.skipped > 0 ) { 21 | m_stream << "SKIP"; 22 | } else if (_testCaseStats.totals.assertions.allPassed()) { 23 | m_stream << "PASS"; 24 | } else if (_testCaseStats.totals.assertions.allOk()) { 25 | m_stream << "XFAIL"; 26 | } else { 27 | m_stream << "FAIL"; 28 | } 29 | m_stream << ' ' << _testCaseStats.testInfo->name << '\n'; 30 | StreamingReporterBase::testCaseEnded(_testCaseStats); 31 | } 32 | 33 | void AutomakeReporter::skipTest(TestCaseInfo const& testInfo) { 34 | m_stream << ":test-result: SKIP " << testInfo.name << '\n'; 35 | } 36 | 37 | } // end namespace Catch 38 | -------------------------------------------------------------------------------- /test/catch/src/catch2/catch_version.cpp: -------------------------------------------------------------------------------- 1 | 2 | // Copyright Catch2 Authors 3 | // Distributed under the Boost Software License, Version 1.0. 4 | // (See accompanying file LICENSE.txt or copy at 5 | // https://www.boost.org/LICENSE_1_0.txt) 6 | 7 | // SPDX-License-Identifier: BSL-1.0 8 | #include 9 | #include 10 | 11 | namespace Catch { 12 | 13 | Version::Version 14 | ( unsigned int _majorVersion, 15 | unsigned int _minorVersion, 16 | unsigned int _patchNumber, 17 | char const * const _branchName, 18 | unsigned int _buildNumber ) 19 | : majorVersion( _majorVersion ), 20 | minorVersion( _minorVersion ), 21 | patchNumber( _patchNumber ), 22 | branchName( _branchName ), 23 | buildNumber( _buildNumber ) 24 | {} 25 | 26 | std::ostream& operator << ( std::ostream& os, Version const& version ) { 27 | os << version.majorVersion << '.' 28 | << version.minorVersion << '.' 29 | << version.patchNumber; 30 | // branchName is never null -> 0th char is \0 if it is empty 31 | if (version.branchName[0]) { 32 | os << '-' << version.branchName 33 | << '.' << version.buildNumber; 34 | } 35 | return os; 36 | } 37 | 38 | Version const& libraryVersion() { 39 | static Version version( 3, 8, 0, "", 0 ); 40 | return version; 41 | } 42 | 43 | } 44 | -------------------------------------------------------------------------------- /test/catch/src/catch2/internal/catch_platform.hpp: -------------------------------------------------------------------------------- 1 | 2 | // Copyright Catch2 Authors 3 | // Distributed under the Boost Software License, Version 1.0. 4 | // (See accompanying file LICENSE.txt or copy at 5 | // https://www.boost.org/LICENSE_1_0.txt) 6 | 7 | // SPDX-License-Identifier: BSL-1.0 8 | #ifndef CATCH_PLATFORM_HPP_INCLUDED 9 | #define CATCH_PLATFORM_HPP_INCLUDED 10 | 11 | // See e.g.: 12 | // https://opensource.apple.com/source/CarbonHeaders/CarbonHeaders-18.1/TargetConditionals.h.auto.html 13 | #ifdef __APPLE__ 14 | # ifndef __has_extension 15 | # define __has_extension(x) 0 16 | # endif 17 | # include 18 | # if (defined(TARGET_OS_OSX) && TARGET_OS_OSX == 1) || \ 19 | (defined(TARGET_OS_MAC) && TARGET_OS_MAC == 1) 20 | # define CATCH_PLATFORM_MAC 21 | # elif (defined(TARGET_OS_IPHONE) && TARGET_OS_IPHONE == 1) 22 | # define CATCH_PLATFORM_IPHONE 23 | # endif 24 | 25 | #elif defined(linux) || defined(__linux) || defined(__linux__) 26 | # define CATCH_PLATFORM_LINUX 27 | 28 | #elif defined(WIN32) || defined(__WIN32__) || defined(_WIN32) || defined(_MSC_VER) || defined(__MINGW32__) 29 | # define CATCH_PLATFORM_WINDOWS 30 | 31 | # if defined( WINAPI_FAMILY ) && ( WINAPI_FAMILY == WINAPI_FAMILY_APP ) 32 | # define CATCH_PLATFORM_WINDOWS_UWP 33 | # endif 34 | 35 | #elif defined(__ORBIS__) || defined(__PROSPERO__) 36 | # define CATCH_PLATFORM_PLAYSTATION 37 | 38 | #endif 39 | 40 | #endif // CATCH_PLATFORM_HPP_INCLUDED 41 | --------------------------------------------------------------------------------