diff --git a/dmff/dpnblist/CMakeLists.txt b/dmff/dpnblist/CMakeLists.txt new file mode 100644 index 00000000..be2934ba --- /dev/null +++ b/dmff/dpnblist/CMakeLists.txt @@ -0,0 +1,85 @@ +cmake_minimum_required(VERSION 3.15) +# project(dpnblist LANGUAGES CUDA CXX) +project(dpnblist LANGUAGES CXX) + +# Set C++ standard +set(CMAKE_CXX_STANDARD 17) +set(CMAKE_CXX_STANDARD_REQUIRED ON) + +# Find CUDA +find_package(CUDA QUIET) +if (CUDA_FOUND) + message(STATUS "CUDA found, compiling CUDA version") + enable_language(CUDA) + set(CUDA_NVCC_FLAGS 61) + set(SOURCES + src/pywrap.cpp + src/nbList.cpp + src/box.cpp + src/nbSchAlg.cpp + src/SchAlg/hashSchAlgGPU.cu + src/SchAlg/hashSchAlgCPU.cpp + src/SchAlg/octreeSchAlgCPU.cpp + src/SchAlg/octreeSchAlgGPU.cu + src/SchAlg/cellSchAlgCPU.cpp + src/SchAlg/cellSchAlgGPU.cu + ) +else() + set(SOURCES + src/pywrap_CPU.cpp + src/nbList_CPU.cpp + src/box.cpp + src/nbSchAlg.cpp + src/SchAlg/hashSchAlgCPU.cpp + src/SchAlg/octreeSchAlgCPU.cpp + src/SchAlg/cellSchAlgCPU.cpp + ) +endif() + +# Find pybind11 +find_package(pybind11 QUIET) +if (NOT pybind11_FOUND) + add_subdirectory(${CMAKE_SOURCE_DIR}/external/pybind11-2.11.1) +endif() + +# Add the pybind11 module +pybind11_add_module(dpnblist SHARED) +target_sources(dpnblist PRIVATE ${SOURCES}) + +# Include directories +target_include_directories(dpnblist PRIVATE + ${CMAKE_SOURCE_DIR}/src + ${CMAKE_SOURCE_DIR}/src/SchAlg +) + +# Find and link OpenMP +find_package(OpenMP REQUIRED) +if(OpenMP_CXX_FOUND) + target_link_libraries(dpnblist PUBLIC OpenMP::OpenMP_CXX) +endif() + +# Find and link Python3 +find_package(Python3 REQUIRED COMPONENTS Development) +if (Python3_FOUND) + target_link_libraries(dpnblist PUBLIC Python3::Python) +endif() + +# Add subdirectory for tests +if(CMAKE_BUILD_TYPE MATCHES Debug) + add_library(dpnblist ${SOURCES}) + target_include_directories(dpnblist PRIVATE + ${CMAKE_SOURCE_DIR}/src + ${CMAKE_SOURCE_DIR}/src/SchAlg + ) + target_link_libraries(dpnblist PUBLIC OpenMP::OpenMP_CXX Python3::Python) + add_subdirectory(tests) +endif() + +# Set position independent code +set_target_properties(dpnblist PROPERTIES POSITION_INDEPENDENT_CODE ON) + +# Set compiler flags +if (CUDA_FOUND) + set(CMAKE_CUDA_FLAGS "${CMAKE_CUDA_FLAGS} -Xcompiler -fopenmp -O3 -arch=sm_${CUDA_NVCC_FLAGS}") +endif() +set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fopenmp -O3") diff --git a/dmff/dpnblist/LICENSE b/dmff/dpnblist/LICENSE new file mode 100644 index 00000000..c03dde5b --- /dev/null +++ b/dmff/dpnblist/LICENSE @@ -0,0 +1,21 @@ +MIT License + +Copyright (c) 2024 Zhu Benhao + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. diff --git a/dmff/dpnblist/README.md b/dmff/dpnblist/README.md new file mode 100644 index 00000000..69a068b7 --- /dev/null +++ b/dmff/dpnblist/README.md @@ -0,0 +1,48 @@ +# dpnblist + Resable and Modular Neighborlist Lib + +### Installation +you can follow the below commands to build the project +``` +cmake -B build +cmake --build build +``` +then a .so lib will be generated, which can be used in python. + +### Usage +In our neighbor list library, we provide a full type of neighbor list and include three different types of algorithms: cell list, octree, and hash methods, and support CPU and GPU. + +1. First, it is necessary to define a simulation system through the `box` class, mainly including two parameters, the `length` and `angle` of the simulation system, as shown in the table below: + + |Box Parameter | Data Type | + |---|---| + |length | list | + |amgle | list | + +2. Then, specify different algorithms and platforms through the `NeighborList` class, with parameters as follows + + |Parameter| Data Type |Value| + |---|---|---| + |mode|string|"Linked_Cell-CPU" "Linked_Cell-GPU" "Octree-CPU" "Octree-GPU" "Hash-CPU" "Hash-GPU"| + +3. Finally, call the `build` method to generate the neighbor list, passing the `box`, `points`, and `cutoff` parameters. Then, use the `get_neighbor_pair` method to retrieve the neighbor list. + +Here's an example of usage: +```python +import nblist +import numpy as np + +nblist.set_num_threads(4) +print(nblist.get_max_threads()) +num_particle = 30000 +shape = (num_particle, 3) +points = np.random.random(shape) * domain_size +domain_size = [50.0, 50.0, 50.0] +angle = [90.0, 90.0, 90.0] +cutoff = 6.0 + +box = nblist.Box(domain_size, angle) +nb = nblist.NeighborList("Linked_Cell-GPU") # Linked_Cell-GPU Linked_Cell-CPU Octree-GPU Octree-CPU Hash-GPU Hash-CPU +nb.build(box, points, cutoff) +pairs = nb.get_neighbor_pair() +``` \ No newline at end of file diff --git a/dmff/dpnblist/examples/nblist_test.py b/dmff/dpnblist/examples/nblist_test.py new file mode 100644 index 00000000..bed85818 --- /dev/null +++ b/dmff/dpnblist/examples/nblist_test.py @@ -0,0 +1,22 @@ +import dpnblist +import numpy as np +import time +import freud + +dpnblist.set_num_threads(4) +print(dpnblist.get_max_threads()) + +num_particle = 3000 +domain_size = [50.0, 50.0, 50.0] +angle = [90.0, 90.0, 90.0] +shape = (num_particle, 3) +inputs = np.random.random(shape) * domain_size +cutoff = 6.0 + +box = dpnblist.Box(domain_size, angle) +nb = dpnblist.NeighborList("Octree-CPU") # Linked_Cell-GPU Linked_Cell-CPU Octree-GPU Octree-CPU Hash-GPU Hash-CPU +nb.build(box, inputs, cutoff) +pairs = nb.get_neighbor_pair() +lists = nb.get_neighbor_list() +print(pairs[0:9]) +print(lists[0:3]) diff --git a/dmff/dpnblist/external/doctest-2.4.11/.clang-format b/dmff/dpnblist/external/doctest-2.4.11/.clang-format new file mode 100644 index 00000000..cfdad2a2 --- /dev/null +++ b/dmff/dpnblist/external/doctest-2.4.11/.clang-format @@ -0,0 +1,82 @@ +# https://clang.llvm.org/docs/ClangFormatStyleOptions.html + +DisableFormat: false +Language: Cpp +Standard: Cpp11 +IndentWidth: 4 +TabWidth: 4 +UseTab: Never +ColumnLimit: 100 +ReflowComments: false +SortIncludes: false + +AlignConsecutiveAssignments: true +AlignConsecutiveDeclarations: true +AlignEscapedNewlinesLeft: false +AlignOperands: true +AlignTrailingComments: true +AlignAfterOpenBracket: true +DerivePointerAlignment: false +PointerAlignment: Left +IndentCaseLabels: true +ContinuationIndentWidth: 8 +NamespaceIndentation: Inner +CompactNamespaces: true +FixNamespaceComments: true +AccessModifierOffset: -4 + +SpaceAfterControlStatementKeyword: false +SpaceAfterCStyleCast: false +SpaceBeforeAssignmentOperators: true +SpaceBeforeParens: Never +SpaceInEmptyParentheses: false +SpacesBeforeTrailingComments: 1 +SpacesInAngles: false +SpacesInCStyleCastParentheses: false +SpacesInContainerLiterals: false +SpacesInParentheses: false +SpacesInSquareBrackets: false +Cpp11BracedListStyle: true + +KeepEmptyLinesAtTheStartOfBlocks: false +MaxEmptyLinesToKeep: 1 +BinPackArguments: true +BinPackParameters: true +AlwaysBreakAfterReturnType: None +AlwaysBreakAfterDefinitionReturnType: None +AlwaysBreakTemplateDeclarations: true +BreakConstructorInitializersBeforeComma: true +ConstructorInitializerAllOnOneLineOrOnePerLine: false +ConstructorInitializerIndentWidth: 8 + +AllowShortIfStatementsOnASingleLine: false +AllowShortLoopsOnASingleLine: false +AllowShortBlocksOnASingleLine: true +AllowShortCaseLabelsOnASingleLine: true +AllowAllParametersOfDeclarationOnNextLine: true +AllowShortFunctionsOnASingleLine: All + +BreakBeforeBinaryOperators: false +BreakBeforeTernaryOperators: false +BreakStringLiterals: true +BreakBeforeBraces: Custom +BraceWrapping: + AfterClass: true + AfterEnum: true + AfterNamespace: false + AfterStruct: true + AfterUnion: true + + BeforeCatch: false + BeforeElse: false + IndentBraces: false + AfterFunction: false + AfterControlStatement: false + +# penalties not thought of yet +PenaltyBreakBeforeFirstCallParameter: 19 +PenaltyBreakComment: 60 +PenaltyBreakString: 1000 +PenaltyBreakFirstLessLess: 120 +PenaltyExcessCharacter: 1000000 +PenaltyReturnTypeOnItsOwnLine: 1000 diff --git a/dmff/dpnblist/external/doctest-2.4.11/.clang-tidy b/dmff/dpnblist/external/doctest-2.4.11/.clang-tidy new file mode 100644 index 00000000..c563e502 --- /dev/null +++ b/dmff/dpnblist/external/doctest-2.4.11/.clang-tidy @@ -0,0 +1,62 @@ +Checks: '*, + -altera-id-dependent-backward-branch, + -altera-struct-pack-align, + -altera-unroll-loops, + -bugprone-easily-swappable-parameters, + -bugprone-macro-parentheses, + -bugprone-suspicious-include, + -cppcoreguidelines-avoid-magic-numbers, + -cppcoreguidelines-avoid-non-const-global-variables, + -cppcoreguidelines-macro-usage, + -cppcoreguidelines-non-private-member-variables-in-classes, + -cppcoreguidelines-owning-memory, + -cppcoreguidelines-pro-bounds-array-to-pointer-decay, + -cppcoreguidelines-pro-bounds-constant-array-index, + -cppcoreguidelines-pro-bounds-pointer-arithmetic, + -cppcoreguidelines-pro-type-member-init, + -cppcoreguidelines-pro-type-reinterpret-cast, + -cppcoreguidelines-pro-type-union-access, + -cppcoreguidelines-virtual-class-destructor, + -fuchsia-default-arguments-calls, + -fuchsia-default-arguments-declarations, + -fuchsia-overloaded-operator, + -google-build-using-namespace, + -google-explicit-constructor, + -google-readability-braces-around-statements, + -google-readability-function-size, + -google-readability-namespace-comments, + -google-readability-todo, + -google-runtime-int, + -google-runtime-references, + -hicpp-braces-around-statements, + -hicpp-explicit-conversions, + -hicpp-function-size, + -hicpp-member-init, + -hicpp-named-parameter, + -hicpp-no-array-decay, + -hicpp-no-assembler, + -hicpp-signed-bitwise, + -hicpp-uppercase-literal-suffix, + -llvm-header-guard, + -llvm-include-order, + -llvm-namespace-comment, + -llvmlibc-*, + -misc-no-recursion, + -misc-non-private-member-variables-in-classes, + -modernize-concat-nested-namespaces, + -modernize-use-default-member-init, + -modernize-use-nodiscard, + -modernize-use-trailing-return-type, + -readability-braces-around-statements, + -readability-function-cognitive-complexity, + -readability-function-size, + -readability-identifier-length, + -readability-implicit-bool-conversion, + -readability-magic-numbers, + -readability-named-parameter, + -readability-redundant-access-specifiers, + -readability-uppercase-literal-suffix' + +WarningsAsErrors: '*' + +HeaderFilterRegex: '.*h$' diff --git a/dmff/dpnblist/external/doctest-2.4.11/.editorconfig b/dmff/dpnblist/external/doctest-2.4.11/.editorconfig new file mode 100644 index 00000000..bdc3756f --- /dev/null +++ b/dmff/dpnblist/external/doctest-2.4.11/.editorconfig @@ -0,0 +1,12 @@ +root = true + +[*] +charset = utf-8 +trim_trailing_whitespace = true +end_of_line = lf +indent_style = space +indent_size = 4 +insert_final_newline = true + +[*.yml] +indent_size = 2 diff --git a/dmff/dpnblist/external/doctest-2.4.11/.gitattributes b/dmff/dpnblist/external/doctest-2.4.11/.gitattributes new file mode 100644 index 00000000..176a458f --- /dev/null +++ b/dmff/dpnblist/external/doctest-2.4.11/.gitattributes @@ -0,0 +1 @@ +* text=auto diff --git a/dmff/dpnblist/external/doctest-2.4.11/.github/FUNDING.yml b/dmff/dpnblist/external/doctest-2.4.11/.github/FUNDING.yml new file mode 100644 index 00000000..6615d84c --- /dev/null +++ b/dmff/dpnblist/external/doctest-2.4.11/.github/FUNDING.yml @@ -0,0 +1,4 @@ +github: onqtam +patreon: onqtam +custom: https://www.paypal.me/onqtam/10 + diff --git a/dmff/dpnblist/external/doctest-2.4.11/.github/issue_template.md b/dmff/dpnblist/external/doctest-2.4.11/.github/issue_template.md new file mode 100644 index 00000000..b4639880 --- /dev/null +++ b/dmff/dpnblist/external/doctest-2.4.11/.github/issue_template.md @@ -0,0 +1,29 @@ +## Description + + + +### Steps to reproduce + + + +### Extra information + +* doctest version: **v42.42.42** +* Operating System: **Joe's discount operating system** +* Compiler+version: **Hidden Dragon v1.2.3** diff --git a/dmff/dpnblist/external/doctest-2.4.11/.github/pull_request_template.md b/dmff/dpnblist/external/doctest-2.4.11/.github/pull_request_template.md new file mode 100644 index 00000000..9c667a54 --- /dev/null +++ b/dmff/dpnblist/external/doctest-2.4.11/.github/pull_request_template.md @@ -0,0 +1,26 @@ + + + +## Description + + +## GitHub Issues + diff --git a/dmff/dpnblist/external/doctest-2.4.11/.github/workflows/build_and_test.py b/dmff/dpnblist/external/doctest-2.4.11/.github/workflows/build_and_test.py new file mode 100644 index 00000000..e2de6cc4 --- /dev/null +++ b/dmff/dpnblist/external/doctest-2.4.11/.github/workflows/build_and_test.py @@ -0,0 +1,99 @@ +import os +import sys + +_os = sys.argv[1] +assert _os in ["Linux", "macOS", "Windows"] + +_arch = sys.argv[2] +assert _arch in ["x86", "x64"] + +_compiler = sys.argv[3] +assert _compiler in ["cl", "clang-cl", "clang", "gcc", "xcode"] + +_version = sys.argv[4] if len(sys.argv) >= 5 else "" + +print("Env: " + "; ".join([_os, _arch, _compiler, _version])) + +if _compiler == "gcc": + used_cxx = "g++" +elif _compiler == "clang" or _compiler == "xcode": + used_cxx = "clang++" +else: + used_cxx = _compiler + +if _os == "Linux": + used_cxx += "-" + _version + + +def log_and_call(command): + print(command) + return os.system(command) + + +def run_test(build_type, test_mode, flags, test = True): + print("Running: " + "; ".join([build_type, test_mode, flags, str(test)])) + if log_and_call("cmake -E remove_directory build"): + exit(1) + if log_and_call( + f"cmake -S . " + f"-B build " + f"-D CMAKE_BUILD_TYPE={build_type} " + f"-D DOCTEST_TEST_MODE={test_mode} " + + (flags and f'-D CMAKE_CXX_FLAGS="{flags}" ') + + f"-D CMAKE_CXX_COMPILER={used_cxx}" + ): + exit(2) + if log_and_call("cmake --build build"): + exit(3) + if test and log_and_call("ctest --test-dir build --no-tests=error"): + exit(4) + + +def version_tuple(v): + return tuple(map(int, (v.split(".")))) + + +flags = "-fsanitize=address,undefined -fno-omit-frame-pointer" +if _os == "Windows": + flags = "" +elif _os == "Linux": + if _compiler == "clang": + if version_tuple(_version) <= version_tuple("6.0"): + flags = "" + elif _compiler == "gcc": + if version_tuple(_version) <= version_tuple("5.0"): + flags = "" + +if _os == "Linux" and _compiler == "gcc": + flags += " -static-libasan" + +tsan_flags = "-fsanitize=thread -pie -fPIE" +if _os == "Windows": + tsan_flags = "" +elif _os == "Linux": + if _compiler == "clang": + if version_tuple(_version) <= version_tuple("3.9"): + tsan_flags = "" + elif _compiler == "gcc": + if version_tuple(_version) <= version_tuple("6.0"): + tsan_flags = "" + +if _os == "Linux" and _compiler == "gcc": + tsan_flags += " -static-libtsan" + +x86_flag = " -m32" if _arch == "x86" and _compiler != "cl" else "" + +for configuration in ["Debug", "Release"]: + run_test(configuration, "COMPARE", flags + x86_flag) + if tsan_flags != "": + run_test(configuration, "COMPARE", tsan_flags) + if _os != "Windows": + run_test( + configuration, + "COMPARE", + "-fno-exceptions -D DOCTEST_CONFIG_NO_EXCEPTIONS_BUT_WITH_ALL_ASSERTS", + test = False, + ) + run_test(configuration, "COMPARE", "-fno-rtti") + if _os == "Linux": + run_test(configuration, "VALGRIND", x86_flag) diff --git a/dmff/dpnblist/external/doctest-2.4.11/.github/workflows/codeql-analysis.yml b/dmff/dpnblist/external/doctest-2.4.11/.github/workflows/codeql-analysis.yml new file mode 100644 index 00000000..c25e11e4 --- /dev/null +++ b/dmff/dpnblist/external/doctest-2.4.11/.github/workflows/codeql-analysis.yml @@ -0,0 +1,67 @@ +# For most projects, this workflow file will not need changing; you simply need +# to commit it to your repository. +# +# You may wish to alter this file to override the set of languages analyzed, +# or to provide custom queries or build logic. +# +# ******** NOTE ******** +# We have attempted to detect the languages in your repository. Please check +# the `language` matrix defined below to confirm you have the correct set of +# supported CodeQL languages. +# +name: "CodeQL" + +on: + push: + branches: [ master ] + pull_request: + # The branches below must be a subset of the branches above + branches: [ master ] + schedule: + - cron: '38 1 * * *' + +jobs: + analyze: + name: Analyze + runs-on: ubuntu-latest + + strategy: + fail-fast: false + matrix: + language: [ 'cpp' ] + # CodeQL supports [ 'cpp', 'csharp', 'go', 'java', 'javascript', 'python' ] + # Learn more: + # https://docs.github.com/en/free-pro-team@latest/github/finding-security-vulnerabilities-and-errors-in-your-code/configuring-code-scanning#changing-the-languages-that-are-analyzed + + steps: + - name: Checkout repository + uses: actions/checkout@v2 + + # Initializes the CodeQL tools for scanning. + - name: Initialize CodeQL + uses: github/codeql-action/init@v1 + with: + languages: ${{ matrix.language }} + # If you wish to specify custom queries, you can do so here or in a config file. + # By default, queries listed here will override any specified in a config file. + # Prefix the list here with "+" to use these queries and those in the config file. + # queries: ./path/to/local/query, your-org/your-repo/queries@main + + # Autobuild attempts to build any compiled languages (C/C++, C#, or Java). + # If this step fails, then you should remove it and run the build manually (see below) + - name: Autobuild + uses: github/codeql-action/autobuild@v1 + + # ℹ️ Command-line programs to run using the OS shell. + # 📚 https://git.io/JvXDl + + # ✏️ If the Autobuild fails above, remove it and uncomment the following three lines + # and modify them (or add more) to build your code if your project + # uses a compiled language + + #- run: | + # make bootstrap + # make release + + - name: Perform CodeQL Analysis + uses: github/codeql-action/analyze@v1 diff --git a/dmff/dpnblist/external/doctest-2.4.11/.github/workflows/main.yml b/dmff/dpnblist/external/doctest-2.4.11/.github/workflows/main.yml new file mode 100644 index 00000000..31cebfaa --- /dev/null +++ b/dmff/dpnblist/external/doctest-2.4.11/.github/workflows/main.yml @@ -0,0 +1,375 @@ +name: CI + +on: + push: + paths-ignore: + - 'doc/**' + - 'scripts/**' + - 'LICENSE.txt' + - 'README.md' + pull_request: + paths-ignore: + - 'doc/**' + - 'scripts/**' + - 'LICENSE.txt' + - 'README.md' + +env: + CTEST_OUTPUT_ON_FAILURE: ON + CTEST_PARALLEL_LEVEL: 2 + +jobs: + coverage: + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v2 + + - name: Install + run: sudo apt-get install -y ninja-build lcov + + - name: Generate + run: cmake -B build -S . -G Ninja -D CMAKE_CXX_FLAGS="-fprofile-arcs -ftest-coverage" + + - name: Build + run: cmake --build build + + - name: Test + run: ctest --test-dir build --no-tests=error + + - name: LCOV + run: | + mkdir coverage + lcov -c -d build/ -o coverage/lcov.info --include "*doctest/parts*" + + - name: Codecov + uses: codecov/codecov-action@v2 + with: + files: ./coverage/lcov.info + fail_ci_if_error: true + + clang-tidy: + if: github.event_name == 'push' || github.event.pull_request.head.repo.full_name != github.repository + runs-on: ubuntu-22.04 + + steps: + - uses: actions/checkout@v2 + + - name: Install + run: sudo apt-get install -y ninja-build clang-tidy-14 + + - name: Generate + run: cmake -B build -S . -G Ninja -D CMAKE_CXX_COMPILER=clang++ -D CMAKE_EXPORT_COMPILE_COMMANDS=ON -D CMAKE_CXX_CLANG_TIDY="clang-tidy-14;-warnings-as-errors=*" + + - name: Build + run: cmake --build build + + sanitizers: + if: github.event_name == 'push' || github.event.pull_request.head.repo.full_name != github.repository + runs-on: ubuntu-22.04 + + strategy: + fail-fast: false + matrix: + sanitizers: ["address", "thread", "undefined", "integer", "implicit-conversion", "nullability", "safe-stack"] + + steps: + - uses: actions/checkout@v2 + + - name: Install + run: sudo apt-get install -y ninja-build + + - name: Generate + run: cmake -B build -S . -G Ninja -D CMAKE_CXX_COMPILER=clang++ -D CMAKE_EXPORT_COMPILE_COMMANDS=ON -D CMAKE_CXX_FLAGS="-fsanitize=${{ matrix.sanitizers }}" + + - name: Build + run: cmake --build build + + - name: Test + run: ctest --test-dir build --no-tests=error + + ci: + if: github.event_name == 'push' || github.event.pull_request.head.repo.full_name != github.repository + runs-on: ${{ matrix.os }} + + env: + CMAKE_GENERATOR: Ninja + ASAN_OPTIONS: strict_string_checks=true:detect_odr_violation=2:detect_stack_use_after_return=true:check_initialization_order=true:strict_init_order=true + TSAN_OPTIONS: force_seq_cst_atomics=1 + + strategy: + fail-fast: false + matrix: + os: ["windows-2019", "windows-2022"] + compiler: ["cl", "clang", "clang-cl"] + + include: + - os: ubuntu-18.04 + compiler: gcc + version: "4.8" + + - os: ubuntu-18.04 + compiler: gcc + version: "4.9" + + - os: ubuntu-18.04 + compiler: gcc + version: "5" + + - os: ubuntu-18.04 + compiler: gcc + version: "6" + + - os: ubuntu-18.04 + compiler: gcc + version: "7" + + - os: ubuntu-18.04 + compiler: gcc + version: "8" + + - os: ubuntu-latest + compiler: gcc + version: "9" + + - os: ubuntu-latest + compiler: gcc + version: "10" + + - os: ubuntu-latest + compiler: gcc + version: "11" + + - os: ubuntu-latest + compiler: gcc + version: "12" + + - os: ubuntu-18.04 + compiler: clang + version: "3.5" + + - os: ubuntu-18.04 + compiler: clang + version: "3.6" + + - os: ubuntu-18.04 + compiler: clang + version: "3.7" + + - os: ubuntu-18.04 + compiler: clang + version: "3.8" + + - os: ubuntu-18.04 + compiler: clang + version: "3.9" + + - os: ubuntu-18.04 + compiler: clang + version: "4.0" + + - os: ubuntu-18.04 + compiler: clang + version: "5.0" + + - os: ubuntu-18.04 + compiler: clang + version: "6.0" + + - os: ubuntu-18.04 + compiler: clang + version: "7" + + - os: ubuntu-18.04 + compiler: clang + version: "8" + + - os: ubuntu-20.04 + compiler: clang + version: "9" + + - os: ubuntu-20.04 + compiler: clang + version: "10" + + - os: ubuntu-20.04 + compiler: clang + version: "11" + + - os: ubuntu-20.04 + compiler: clang + version: "12" + + - os: ubuntu-latest + compiler: clang + version: "13" + + - os: ubuntu-latest + compiler: clang + version: "14" + + - os: ubuntu-latest + compiler: clang + version: "15" + + - os: macOS-10.15 + compiler: xcode + version: "10.3" + + - os: macOS-latest + compiler: xcode + version: "13.2.1" + + - os: macos-12 + compiler: xcode + version: "14.0.1" + + - os: macOS-latest + compiler: gcc + version: "11" + + steps: + - uses: actions/checkout@v2 + + - name: Install (Linux) + if: runner.os == 'Linux' + run: | + # Required for libc6-dbg:i386 and g++-multilib packages which are + # needed for x86 builds. + sudo dpkg --add-architecture i386 + + sudo apt-get update + + # libc6-dbg:i386 is required for running valgrind on x86. + sudo apt-get install -y ninja-build valgrind libc6-dbg:i386 wget gpg ca-certificates + + # clang-3.7 and earlier are not available in Bionic anymore so we get + # them from the Xenial repositories instead. + sudo gpg --keyserver keyserver.ubuntu.com --recv-keys 40976EAF437D05B5 + sudo gpg --keyserver keyserver.ubuntu.com --recv-keys 3B4FE6ACC0B21F32 + #sudo sh -c 'wget -q -O - "https://keyserver.ubuntu.com/pks/lookup?search=0x40976EAF437D05B5&fingerprint=on&op=get" | gpg -q --dearmor - | tee "/usr/share/keyrings/dk.gpg" > /dev/null' + sudo add-apt-repository "deb http://dk.archive.ubuntu.com/ubuntu/ xenial main" + sudo add-apt-repository "deb http://dk.archive.ubuntu.com/ubuntu/ xenial universe" + + # clang->=13 is not currently available by default + # causing compiler conflict for clang-14 as the below pulls from focal for 22.04 (ubuntu-latest) + #if [ "${{ matrix.compiler }}" = "clang" -a ${{ matrix.version }} -ge 13 ]; then + #wget -O - https://apt.llvm.org/llvm-snapshot.gpg.key | sudo apt-key add - + #sudo add-apt-repository "deb https://apt.llvm.org/focal/ llvm-toolchain-focal-${{ matrix.version }} main" + #fi + + if [ "${{ matrix.compiler }}" = "gcc" ]; then + sudo apt-get install -y g++-${{ matrix.version }} g++-${{ matrix.version }}-multilib + else + sudo apt-get install -y clang-${{ matrix.version }} libclang-${{ matrix.version }}-dev llvm-${{ matrix.version }}-dev g++-multilib + fi + + - name: Install (macOS) + if: runner.os == 'macOS' + run: | + brew install ninja + if [ "${{ matrix.compiler }}" = "xcode" ]; then + sudo xcode-select -switch /Applications/Xcode_${{ matrix.version }}.app + fi + + - name: Configure x64 + uses: ilammy/msvc-dev-cmd@v1 + + - name: Build & Test x64 + run: python3 .github/workflows/build_and_test.py ${{ runner.os }} x64 ${{ matrix.compiler }} ${{ matrix.version }} + + - name: Configure x86 + uses: ilammy/msvc-dev-cmd@v1 + with: + arch: x86 + + # MacOS doesn't support x86 from Xcode 10 onwards. + + - name: Build & Test x86 + if: runner.os == 'Linux' || runner.os == 'Windows' && matrix.compiler != 'clang-cl' + run: python3 .github/workflows/build_and_test.py ${{ runner.os }} x86 ${{ matrix.compiler }} ${{ matrix.version }} + + ci-min-gw: + if: github.event_name == 'push' || github.event.pull_request.head.repo.full_name != github.repository + runs-on: windows-latest + + strategy: + fail-fast: false + matrix: + configuration: ["Debug", "Release"] + + steps: + - uses: actions/checkout@v2 + + - name: Set up MinGW + uses: egor-tensin/setup-mingw@v2 + + - name: Generate + run: cmake -B build -S . -G "MinGW Makefiles" -D CMAKE_BUILD_TYPE=${{ matrix.configuration }} + + - name: Build + run: cmake --build build + + - name: Test + run: ctest --test-dir build --no-tests=error + + ci-msvs: + if: github.event_name == 'push' || github.event.pull_request.head.repo.full_name != github.repository + runs-on: ${{ matrix.toolset == 'v143' && 'windows-2022' || 'windows-2019' }} + + strategy: + fail-fast: false + matrix: + toolset: ["v140", "v141", "v142", "v143", "ClangCl"] + architecture: ["Win32", "x64"] + configuration: ["Debug", "Release"] + + steps: + - uses: actions/checkout@v2 + + - name: Generate + run: cmake -B build -S . -G "${{ matrix.toolset == 'v143' && 'Visual Studio 17 2022' || 'Visual Studio 16 2019' }}" \ + -A ${{ matrix.architecture }} -T ${{ matrix.toolset }} + + - name: Build + run: cmake --build build --config ${{ matrix.configuration }} + + - name: Test + run: ctest -C ${{ matrix.configuration }} --test-dir build --no-tests=error + + ci-icpc: + if: github.event_name == 'push' || github.event.pull_request.head.repo.full_name != github.repository + runs-on: ubuntu-latest + + strategy: + fail-fast: false + matrix: + configuration: ["Debug", "Release"] + + steps: + - uses: actions/checkout@v2 + + - name: Install + run: | + #wget -O - https://apt.repos.intel.com/intel-gpg-keys/GPG-PUB-KEY-INTEL-SW-PRODUCTS.PUB | sudo apt-key add - + #sudo add-apt-repository "deb [signed-by=/etc/apt/keyrings/icpc.gpg] https://apt.repos.intel.com/oneapi all main" + # apt-key is deprecated replace with below lines + wget -O - https://apt.repos.intel.com/intel-gpg-keys/GPG-PUB-KEY-INTEL-SW-PRODUCTS.PUB | sudo gpg --dearmor |sudo tee /etc/apt/keyrings/icpc.gpg > /dev/null + echo "deb [signed-by=/etc/apt/keyrings/icpc.gpg] https://apt.repos.intel.com/oneapi all main" | sudo tee /etc/apt/sources.list.d/icpc.list + sudo apt-get update + sudo apt-get install -y intel-oneapi-compiler-dpcpp-cpp-and-cpp-classic ninja-build + + - name: Generate + run: | + . /opt/intel/oneapi/setvars.sh + cmake -B build -S . -G Ninja -D CMAKE_CXX_COMPILER=icc -D CMAKE_C_COMPILER=icc -D CMAKE_CXX_COMPILER=icpc -D CMAKE_BUILD_TYPE=${{ matrix.configuration }} -D CMAKE_CXX_FLAGS="-w2 -Wcheck -Werror -diag-disable=10441 -D DOCTEST_CONFIG_NO_CONTRADICTING_INLINE" + + - name: Build + run: | + . /opt/intel/oneapi/setvars.sh + cmake --build build --config ${{ matrix.configuration }} + - name: Test + run: | + . /opt/intel/oneapi/setvars.sh + ctest -C ${{ matrix.configuration }} --test-dir build --no-tests=error + diff --git a/dmff/dpnblist/external/doctest-2.4.11/.gitignore b/dmff/dpnblist/external/doctest-2.4.11/.gitignore new file mode 100644 index 00000000..a8047cf9 --- /dev/null +++ b/dmff/dpnblist/external/doctest-2.4.11/.gitignore @@ -0,0 +1,75 @@ +# Compiled Object files +*.slo +*.lo +*.o +*.obj + +# Compiled Dynamic libraries +*.so +*.dylib +*.dll + +# Compiled Static libraries +*.lai +*.la +*.a +*.lib + +# Executables +*.exe +*.out +*.app + +# Text garbage +*.ii +*.s + +# My garbage :) +Win32/ +x64/ +doctest_with_main.dir/ +scripts/bench/project/* +scripts/bench/catch*.hpp +scripts/bench/results.txt +build/ +build-mingw/ +*.pyc +*vscode* +.idea/ +cmake-build-*/ +bazel-* + +# MacOS/Xcode +*.DS_Store +*.xcodeproj/ +XCBuildData/ + +# Visual Studio +*.vcxproj +*.vcxproj.filters +*.sln +*.lastbuildstate +*.recipe +*.tlog +*.exp +*.ilk +*.pdb + +# Ninja +build.ninja +.ninja_log +.ninja_deps + +# CMake generated +CMakeFiles/ +CMakeScripts/ +generated/ +cmake_install.cmake +CTestTestFile.cmake +CMakeCache.txt +*.FileListAbsolute.txt +CTestCostData.txt +*.Build.CppClean.log +LastTest.log +LastTestsFailed.log +temp diff --git a/dmff/dpnblist/external/doctest-2.4.11/CHANGELOG.md b/dmff/dpnblist/external/doctest-2.4.11/CHANGELOG.md new file mode 100644 index 00000000..4bf4433a --- /dev/null +++ b/dmff/dpnblist/external/doctest-2.4.11/CHANGELOG.md @@ -0,0 +1,903 @@ +# Change Log + +## [v2.4.11](https://github.com/doctest/doctest/tree/v2.4.11) (2023-03-15) + +[Full Changelog](https://github.com/doctest/doctest/compare/v2.4.10...v2.4.11) + +## [v2.4.10](https://github.com/doctest/doctest/tree/v2.4.10) (2023-02-27) + +[Full Changelog](https://github.com/doctest/doctest/compare/v2.4.9...v2.4.10) + +## [v2.4.9](https://github.com/doctest/doctest/tree/v2.4.9) (2022-06-18) +[Full Changelog](https://github.com/doctest/doctest/compare/v2.4.8...v2.4.9) + +**Closed issues:** +- Visual Studio's Test Explorer and Resharper C\+\+'s Unit Test Explorer don't see Doctest's tests \#661 ([KulaGGin](https://github.com/KulaGGin)) +- How to get detailed information about testcases failing due to thrown exceptions? \#660 ([NiklasKappel](https://github.com/NiklasKappel)) +- Add clang\-tidy integration and fix all warnings \#659 ([Saalvage](https://github.com/Saalvage)) +- Avoid static init problem in insufficient\_procs\(\) \(MPI\) \#657 ([starintheuniverse](https://github.com/starintheuniverse)) +- Use MPI\_Isend in MpiConsoleReporter to avoid deadlock \#656 ([starintheuniverse](https://github.com/starintheuniverse)) +- Deadlock in MpiConsoleReporter when root rank fails assert \#655 ([starintheuniverse](https://github.com/starintheuniverse)) +- Cleanup of DOCTEST\_DO\_BINARY\_EXPRESSION\_COMPARISON\. Fixes \#651 \#652 ([iboB](https://github.com/iboB)) +- Comparison with implicit cast from non\-const value can't be decomposed \#651 ([iboB](https://github.com/iboB)) +- Local structured bindings cannot be used in CHECK macros \(since 2\.4\.8\) \#647 ([pragmaxwell](https://github.com/pragmaxwell)) +- Add tests for DOCTEST\_CONFIG\_USE\_STD\_HEADERS \#643 ([Saalvage](https://github.com/Saalvage)) +- Stringification amendments \#642 ([Saalvage](https://github.com/Saalvage)) +- Clean up defines a bit; Implement \#439 \#641 ([Saalvage](https://github.com/Saalvage)) +- Fix \#508 \#640 ([Saalvage](https://github.com/Saalvage)) +- Fix \#508 \#639 ([Saalvage](https://github.com/Saalvage)) +- New doctest version gives me an error: reference to local binding '\.\.\.' declared in enclosing function 'DOCTEST\_ANON\_FUNC\_16' \#638 ([a4z](https://github.com/a4z)) +- The tutorial example does not work \(linker errors\) with clang 10 \#637 ([sixcy](https://github.com/sixcy)) +- Implementing \`DOCTEST\_ASSERT\_IMPLEMENT\_1\` as lambda prevents testing structured bindings \#636 ([ChrisThrasher](https://github.com/ChrisThrasher)) +- re\-re\-remove overly restrictive minimum version of meson \#635 ([eli-schwartz](https://github.com/eli-schwartz)) +- Fix move\-only types failing to decompose correctly \#634 ([Saalvage](https://github.com/Saalvage)) +- Weird compilation error when using CHECK\_THROWS/CHECK\_THROWS\_AS on Visual Studio 2019 with no exceptions \#633 ([yeputons](https://github.com/yeputons)) +- Error triggered by comparing typeid with new doctest 2\.4\.8 \#632 ([JazzSuite](https://github.com/JazzSuite)) +- Improve Mac PowerPC support \#631 ([ryandesign](https://github.com/ryandesign)) +- issue introduced in 2\.4\.7 \#630 ([onqtam](https://github.com/onqtam)) +- Decompose expressions containing the spaceship operator \#629 ([falbrechtskirchinger](https://github.com/falbrechtskirchinger)) +- added nolint for cert\-err58 \#628 ([serguei-k](https://github.com/serguei-k)) +- Fix properties not being passed in doctest\_discover\_tests \#626 ([quantumsteve](https://github.com/quantumsteve)) +- Config no multithreading \#625 ([Saalvage](https://github.com/Saalvage)) +- wasm\*\-support? \#624 ([FrozenSource](https://github.com/FrozenSource)) +- Fix MPI extension to work with no parallel tests \#623 ([BerengerBerthoul](https://github.com/BerengerBerthoul)) +- string comparison leads to gotting stuck \#622 ([laoshaw](https://github.com/laoshaw)) +- doctest\_discover\_tests no longer sets ENVIRONMENT variables for discovered tests\. \#621 ([quantumsteve](https://github.com/quantumsteve)) +- Add contains option to checks\. \#620 ([MFraters](https://github.com/MFraters)) +- Feature request: CHECK\_THROWS\_WITH with contains option \#619 ([MFraters](https://github.com/MFraters)) +- Add alias target for doctest\_with\_main \#617 ([jessestricker](https://github.com/jessestricker)) +- Allow escaping backslash with backslash in filters \(\#614\) \#616 ([yeputons](https://github.com/yeputons)) +- Fix operator<< \#615 ([Saalvage](https://github.com/Saalvage)) +- Correct minor typos \#613 ([utilForever](https://github.com/utilForever)) +- Fix MPI extension to work if launched without mpirun/mpiexec \#612 ([BerengerBerthoul](https://github.com/BerengerBerthoul)) +- Fix mpi subcase \#611 ([BerengerBerthoul](https://github.com/BerengerBerthoul)) +- compilation error with custom operator== defined in namespace \#610 ([zvyagin1](https://github.com/zvyagin1)) +- Regression: Clang\-Tidy warnings in 2\.4\.8 \#607 ([nlohmann](https://github.com/nlohmann)) +- Internal compiler error with GCC 7\.5 \#606 ([foonathan](https://github.com/foonathan)) +- tagging convension has changed? \#605 ([kloczek](https://github.com/kloczek)) +- Update Doctest in vcpkg to 2\.4\.8 \#604 ([gc435](https://github.com/gc435)) +- Add IsNaN operator\! \#603 ([Saalvage](https://github.com/Saalvage)) +- Ignored generated files from CMake, OSX, Xcode, and VS \#602 ([LeonBrands](https://github.com/LeonBrands)) +- Move roadmap and wipe it clean \#601 ([Saalvage](https://github.com/Saalvage)) +- removes a duplicate word 'most' in configuration\.md \#599 ([krishnakumarg1984](https://github.com/krishnakumarg1984)) +- Fix subcase reentry \#598 ([Saalvage](https://github.com/Saalvage)) +- Loop\-generated \`SUBCASE\`s are not run \#597 ([yeputons](https://github.com/yeputons)) +- Void \#596 ([Saalvage](https://github.com/Saalvage)) +- Add flag that forces custom stringification methods to be provided \#595 ([Saalvage](https://github.com/Saalvage)) +- Fix coverage \#594 ([Saalvage](https://github.com/Saalvage)) +- TEST CODECOV PR BEHAVIOR \#593 ([Saalvage](https://github.com/Saalvage)) +- Ignore CMake and MacOS generated files \#592 ([LeonBrands](https://github.com/LeonBrands)) +- Feature request: option to disable fallback "\{?\}" stringifier \#591 ([YarikTH](https://github.com/YarikTH)) +- Add tests for default stringification result of doctest \#590 ([YarikTH](https://github.com/YarikTH)) +- Feature config ret vals \#589 ([Saalvage](https://github.com/Saalvage)) +- DOCTEST\_CONFIG\_ASSERT\_RETURN\_VALUES \#588 ([Saalvage](https://github.com/Saalvage)) +- Support pretty printing of container based on heuristics \#587 ([YarikTH](https://github.com/YarikTH)) +- Refactor stringification \#585 ([Saalvage](https://github.com/Saalvage)) +- Feature: Better NaN \#584 ([Saalvage](https://github.com/Saalvage)) +- Nan check \#582 ([Saalvage](https://github.com/Saalvage)) +- Update roadmap following maintainer change \#581 ([eyalroz](https://github.com/eyalroz)) +- Regression between 2\.4\.6 and 2\.4\.7 \#571 ([YarikTH](https://github.com/YarikTH)) +- build failure with gcc\-11\.2 when using user declared operator<<\(ostream, vector\) \#551 ([nlitsme](https://github.com/nlitsme)) +- variable maximum is assigned 6206517616395625 instead of the actual return value which is 5\.0 \#530 ([kk723](https://github.com/kk723)) +- toString can call existing user\-defined toString through ADL incorrectly \#508 ([zeux](https://github.com/zeux)) +- \[Coverity\] Concurrent data access violations \(MISSING\_LOCK\) doctest\.h: 5838 in doctest::::ConsoleReporter::test\_case\_start\(const doctest::TestCaseData &\)\(\) \#486 ([jiridanek](https://github.com/jiridanek)) +- Provide an error message if REQUIRE \(or other disabled assertion macros\) are used when exceptions are disabled \#439 ([alexeyr](https://github.com/alexeyr)) +- Conflict with templated toString function \#420 ([TillHeinzel](https://github.com/TillHeinzel)) +- \-tc does not work with comma in names \#398 ([martinus](https://github.com/martinus)) +- Compile error on MSVC2019 with any macro which involves stringification of std::string \(asserts, INFO, etc\.\) when isn't included \#381 ([nyanpasu64](https://github.com/nyanpasu64)) +- the dll example doesn't run correctly on Windows with MinGW \#375 ([GregKon](https://github.com/GregKon)) +- add basic conan recipe \#354 ([trondhe](https://github.com/trondhe)) +- CHECK\_MESSAGE\(\) should accept temporaries \#337 ([eyalroz](https://github.com/eyalroz)) +- stringify of cstring literals doesn't work out of the box with separate test\_driver\.cpp \#329 ([teichert](https://github.com/teichert)) +- warning : function declared 'noreturn' should not return \[\-Winvalid\-noreturn\] \#307 ([Vexthil](https://github.com/Vexthil)) +- Test cases containing a comma cannot be run individually \#297 ([Tradias](https://github.com/Tradias)) +- \[bug\] Can't compile the tests because of mutex, that is declared in the doctest \#242 ([BrunaoW](https://github.com/BrunaoW)) +- The \`CHECK\` macro conflicts with Boost\.Beast \(and surely others\) \#234 ([reddwarf69](https://github.com/reddwarf69)) +- Feature request: check if a \`float\` or \`double\` is NaN \#105 ([iamthad](https://github.com/iamthad)) + +**Merged pull requests:** +- Add clang\-tidy integration and fix all warnings \#659 ([Saalvage](https://github.com/Saalvage)) +- Avoid static init problem in insufficient\_procs\(\) \(MPI\) \#657 ([starintheuniverse](https://github.com/starintheuniverse)) +- Use MPI\_Isend in MpiConsoleReporter to avoid deadlock \#656 ([starintheuniverse](https://github.com/starintheuniverse)) +- Cleanup of DOCTEST\_DO\_BINARY\_EXPRESSION\_COMPARISON\. Fixes \#651 \#652 ([iboB](https://github.com/iboB)) +- Add tests for DOCTEST\_CONFIG\_USE\_STD\_HEADERS \#643 ([Saalvage](https://github.com/Saalvage)) +- Stringification amendments \#642 ([Saalvage](https://github.com/Saalvage)) +- Clean up defines a bit; Implement \#439 \#641 ([Saalvage](https://github.com/Saalvage)) +- Fix \#508 \#640 ([Saalvage](https://github.com/Saalvage)) +- re\-re\-remove overly restrictive minimum version of meson \#635 ([eli-schwartz](https://github.com/eli-schwartz)) +- Fix move\-only types failing to decompose correctly \#634 ([Saalvage](https://github.com/Saalvage)) +- Improve Mac PowerPC support \#631 ([ryandesign](https://github.com/ryandesign)) +- added nolint for cert\-err58 \#628 ([serguei-k](https://github.com/serguei-k)) +- Fix properties not being passed in doctest\_discover\_tests \#626 ([quantumsteve](https://github.com/quantumsteve)) +- Config no multithreading \#625 ([Saalvage](https://github.com/Saalvage)) +- Fix MPI extension to work with no parallel tests \#623 ([BerengerBerthoul](https://github.com/BerengerBerthoul)) +- Add contains option to checks\. \#620 ([MFraters](https://github.com/MFraters)) +- Add alias target for doctest\_with\_main \#617 ([jessestricker](https://github.com/jessestricker)) +- Allow escaping backslash with backslash in filters \(\#614\) \#616 ([yeputons](https://github.com/yeputons)) +- Fix operator<< \#615 ([Saalvage](https://github.com/Saalvage)) +- Fix MPI extension to work if launched without mpirun/mpiexec \#612 ([BerengerBerthoul](https://github.com/BerengerBerthoul)) +- Fix mpi subcase \#611 ([BerengerBerthoul](https://github.com/BerengerBerthoul)) +- Add IsNaN operator\! \#603 ([Saalvage](https://github.com/Saalvage)) +- Move roadmap and wipe it clean \#601 ([Saalvage](https://github.com/Saalvage)) +- removes a duplicate word 'most' in configuration\.md \#599 ([krishnakumarg1984](https://github.com/krishnakumarg1984)) +- Fix subcase reentry \#598 ([Saalvage](https://github.com/Saalvage)) +- Add flag that forces custom stringification methods to be provided \#595 ([Saalvage](https://github.com/Saalvage)) +- Fix coverage \#594 ([Saalvage](https://github.com/Saalvage)) +- Ignore CMake and MacOS generated files \#592 ([LeonBrands](https://github.com/LeonBrands)) +- Feature config ret vals \#589 ([Saalvage](https://github.com/Saalvage)) +- Refactor stringification \#585 ([Saalvage](https://github.com/Saalvage)) +- Feature: Better NaN \#584 ([Saalvage](https://github.com/Saalvage)) +- Nan check \#582 ([Saalvage](https://github.com/Saalvage)) + +## [v2.4.8](https://github.com/doctest/doctest/tree/v2.4.8) (2022-01-10) +[Full Changelog](https://github.com/doctest/doctest/compare/2.4.7...v2.4.8) + +**Closed issues:** + +- \[meta\] Change git tagging pattern [\#579](https://github.com/doctest/doctest/issues/579) +- TEST\_CASE\_TEMPLATE causes "-Wunused-local-typedef" warning on Clang [\#577](https://github.com/doctest/doctest/issues/577) +- Regression between 2.4.6 and 2.4.7 with Visual Studio 2015 [\#573](https://github.com/doctest/doctest/issues/573) +- Regression between 2.4.6 and 2.4.7 [\#571](https://github.com/doctest/doctest/issues/571) +- Compilation error on MSVS2019 with ClangCL [\#570](https://github.com/doctest/doctest/issues/570) +- Compilation errors on MSVC 2015 after doctest update to 2.4.7 [\#568](https://github.com/doctest/doctest/issues/568) +- `g\_oss` is causing incorrect stringification results [\#567](https://github.com/doctest/doctest/issues/567) +- MSVC warnings leak through when using the library as a single header with /Wall [\#565](https://github.com/doctest/doctest/issues/565) +- \[PROJECT ANNOUNCEMENT\] Looking for maintainers for Doctest [\#554](https://github.com/doctest/doctest/issues/554) +- Is this still maintained? [\#537](https://github.com/doctest/doctest/issues/537) +- \[Feature request\] CHECK could return the value of expression [\#496](https://github.com/doctest/doctest/issues/496) +- Feature: check or return false [\#426](https://github.com/doctest/doctest/issues/426) +- Undefined reference of `operator\<\<\(ostream&, const string&\)` when compiling with clang 10 and libc++ 10 on Ubuntu 16.04.6 LTS [\#356](https://github.com/doctest/doctest/issues/356) +- Doctest is not able to compile on OSX [\#126](https://github.com/doctest/doctest/issues/126) + +**Merged pull requests:** + +- Continuous Integration Refactor [\#580](https://github.com/doctest/doctest/pull/580) ([Saalvage](https://github.com/Saalvage)) +- Fix semicolon enforcement [\#578](https://github.com/doctest/doctest/pull/578) ([Saalvage](https://github.com/Saalvage)) +- Fix unused variable 2 [\#576](https://github.com/doctest/doctest/pull/576) ([Saalvage](https://github.com/Saalvage)) +- Alternative approach to Windows color initialization [\#575](https://github.com/doctest/doctest/pull/575) ([Saalvage](https://github.com/Saalvage)) +- Assertions returning booleans [\#574](https://github.com/doctest/doctest/pull/574) ([Saalvage](https://github.com/Saalvage)) +- Fix the thread-local string-stream [\#569](https://github.com/doctest/doctest/pull/569) ([Saalvage](https://github.com/Saalvage)) +- Clean up warning suppression a bit; Fixes \#565 [\#566](https://github.com/doctest/doctest/pull/566) ([Saalvage](https://github.com/Saalvage)) +- Add Universal Windows Platform support [\#558](https://github.com/doctest/doctest/pull/558) ([isaevil](https://github.com/isaevil)) + +## [2.4.7](https://github.com/doctest/doctest/tree/2.4.7) (2021-12-10) +[Full Changelog](https://github.com/doctest/doctest/compare/2.4.6...2.4.7) + +**Implemented enhancements:** + +- Add a default Bazel BUILD file [\#433](https://github.com/doctest/doctest/issues/433) + +**Fixed bugs:** + +- Stack-buffer-overflow probably because char array is viewed as NULL terminated string [\#476](https://github.com/doctest/doctest/issues/476) + +**Closed issues:** + +- "C4834: discarding return value" with REQUIRE\_THROWS [\#549](https://github.com/doctest/doctest/issues/549) +- Xcode 11.3 is gone from macOS-latest \(=macOS-11\) [\#547](https://github.com/doctest/doctest/issues/547) +- is it possible to define dependency for CHECKs [\#545](https://github.com/doctest/doctest/issues/545) +- Output summary explanation [\#541](https://github.com/doctest/doctest/issues/541) +- compiler errors in doctest.h using cmake in CLion [\#540](https://github.com/doctest/doctest/issues/540) +- Fails to build in VS2013 because of constexpr [\#539](https://github.com/doctest/doctest/issues/539) +- -Wreserved-identifier warnings with Clang 13.0.0 [\#536](https://github.com/doctest/doctest/issues/536) +- Build fails with latest MSVC 2019 \(v16.11\) due to /WX [\#535](https://github.com/doctest/doctest/issues/535) +- VS 16.11 warning about unreferenced function with internal linkage [\#533](https://github.com/doctest/doctest/issues/533) +- Faq googletest mocking dead link [\#532](https://github.com/doctest/doctest/issues/532) +- FR: Documentation: FAQ: Add sectoin 'multiple files' [\#526](https://github.com/doctest/doctest/issues/526) +- CMAKE: doctest\_discover\_tests\(\) error when ADD\_LABELS is not specified [\#524](https://github.com/doctest/doctest/issues/524) +- Register tests based on test data available [\#521](https://github.com/doctest/doctest/issues/521) +- naming override in different testcase files [\#517](https://github.com/doctest/doctest/issues/517) +- Segmentation fault during the compilation without the copy elision optimization [\#515](https://github.com/doctest/doctest/issues/515) +- Compiler warnings on Xcode 12.5 [\#514](https://github.com/doctest/doctest/issues/514) +- Using filter `-sc` does not work properly? [\#513](https://github.com/doctest/doctest/issues/513) +- \[question\] Example of tests in production code & DLLs & shared libraries? [\#511](https://github.com/doctest/doctest/issues/511) +- Dumping fixture state to disk on error [\#509](https://github.com/doctest/doctest/issues/509) +- Macros construct reserved identifiers [\#507](https://github.com/doctest/doctest/issues/507) +- Running doctest on embedded ARM Cortex µCs [\#506](https://github.com/doctest/doctest/issues/506) +- Asserts Outside of Tests Example Does Not Link [\#504](https://github.com/doctest/doctest/issues/504) +- \[FEATURE REQUEST\] Quiet flag [\#503](https://github.com/doctest/doctest/issues/503) +- Compile error on Intel C++ Classic Compilers [\#502](https://github.com/doctest/doctest/issues/502) +- compiling doctest in 32-bit with \_\_stdcall calling convention fails [\#500](https://github.com/doctest/doctest/issues/500) +- Duplicate 'const' compilation error from TEST\_CASE\_CLASS macro [\#498](https://github.com/doctest/doctest/issues/498) +- Packed fields can't be accessed in 2.4.6 [\#495](https://github.com/doctest/doctest/issues/495) +- Dangling pointers with .str\(\).c\_str\(\) [\#494](https://github.com/doctest/doctest/issues/494) +- Automatic adding of TEST\_SUITE labels to discovered tests fails if ADD\_LABELS not set [\#489](https://github.com/doctest/doctest/issues/489) +- Adding a bunch of REQUIRE/CHECK utilities [\#487](https://github.com/doctest/doctest/issues/487) +- Warning C4114 in MSVC [\#485](https://github.com/doctest/doctest/issues/485) +- Own repository [\#410](https://github.com/doctest/doctest/issues/410) +- Linking problem with Clang 10 on Windows [\#362](https://github.com/doctest/doctest/issues/362) +- Add option not to print the intro text [\#342](https://github.com/doctest/doctest/issues/342) +- \[Feature\] Better integration with tools \(VS Code Test Adapter Extension\) [\#320](https://github.com/doctest/doctest/issues/320) +- vscode test explorer [\#303](https://github.com/doctest/doctest/issues/303) +- Want an option not to print any intro [\#245](https://github.com/doctest/doctest/issues/245) +- Add way to disable printing of intro [\#181](https://github.com/doctest/doctest/issues/181) + +**Merged pull requests:** + +- Make String::operator+ non-member [\#564](https://github.com/doctest/doctest/pull/564) ([Saalvage](https://github.com/Saalvage)) +- Add -minimal flag [\#562](https://github.com/doctest/doctest/pull/562) ([Saalvage](https://github.com/Saalvage)) +- Quiet flag [\#561](https://github.com/doctest/doctest/pull/561) ([Saalvage](https://github.com/Saalvage)) +- Fix redefinition error while using double time DOCTEST\_ANONYMOUS\(DOCTEST\_CAPTURE\_\) [\#557](https://github.com/doctest/doctest/pull/557) ([isaevil](https://github.com/isaevil)) +- Fix error: missing initializer for member doctest::detail::TestSuite [\#556](https://github.com/doctest/doctest/pull/556) ([isaevil](https://github.com/isaevil)) +- Xcode 11.3 with macos 10.15 [\#548](https://github.com/doctest/doctest/pull/548) ([jsoref](https://github.com/jsoref)) +- Spelling [\#546](https://github.com/doctest/doctest/pull/546) ([jsoref](https://github.com/jsoref)) +- Fix build with -Wunused-but-set-variable [\#543](https://github.com/doctest/doctest/pull/543) ([jktjkt](https://github.com/jktjkt)) +- build\(meson\): use `override\_dependency` if supported [\#538](https://github.com/doctest/doctest/pull/538) ([Tachi107](https://github.com/Tachi107)) +- Fix google death test URL [\#528](https://github.com/doctest/doctest/pull/528) ([emrecil](https://github.com/emrecil)) +- Fixing issue with doctestAddTests.cmake [\#527](https://github.com/doctest/doctest/pull/527) ([jharmer95](https://github.com/jharmer95)) +- Replace gendered pronouns [\#525](https://github.com/doctest/doctest/pull/525) ([mletterle](https://github.com/mletterle)) +- Fixed intel compiler parser bug. Should fix \#502 [\#523](https://github.com/doctest/doctest/pull/523) ([BerengerBerthoul](https://github.com/BerengerBerthoul)) +- specifying working directory for execute\_process in doctest\_discover\_tests [\#518](https://github.com/doctest/doctest/pull/518) ([philbucher](https://github.com/philbucher)) +- Fix the logic that depends on optional copy elision optimization [\#516](https://github.com/doctest/doctest/pull/516) ([ivankochin](https://github.com/ivankochin)) +- Fix reserved identifiers [\#510](https://github.com/doctest/doctest/pull/510) ([ts826848](https://github.com/ts826848)) +- Fix build with GCC 11 [\#505](https://github.com/doctest/doctest/pull/505) ([jktjkt](https://github.com/jktjkt)) +- minor fixes in MPI docs [\#499](https://github.com/doctest/doctest/pull/499) ([philbucher](https://github.com/philbucher)) +- Add a minimal bazel config [\#497](https://github.com/doctest/doctest/pull/497) ([elliottt](https://github.com/elliottt)) +- Handle escaped commas in parsed arguments [\#493](https://github.com/doctest/doctest/pull/493) ([friendlyanon](https://github.com/friendlyanon)) +- Fixes Issue 476 . When running executables with "-s" stringifyBinaryE… [\#491](https://github.com/doctest/doctest/pull/491) ([navinp0304](https://github.com/navinp0304)) +- Set variable to 0 if not set [\#490](https://github.com/doctest/doctest/pull/490) ([shivupa](https://github.com/shivupa)) + +## [2.4.6](https://github.com/doctest/doctest/tree/2.4.6) (2021-03-22) +[Full Changelog](https://github.com/doctest/doctest/compare/2.4.5...2.4.6) + +**Fixed bugs:** + +- REQUIRE does not compile when operator== in different namespace [\#443](https://github.com/doctest/doctest/issues/443) +- Using templated operator== inside TEST\_CASE changes deduced types of forwarding references [\#399](https://github.com/doctest/doctest/issues/399) + +**Closed issues:** + +- CMake doesn't link package [\#483](https://github.com/doctest/doctest/issues/483) +- Assertions are slow when running on Windows with a debugger attached [\#481](https://github.com/doctest/doctest/issues/481) +- Get list of registered test-case names [\#479](https://github.com/doctest/doctest/issues/479) +- Can't compile with glibc master \(future 2.34\): SIGSTKSZ is no longer a constant [\#473](https://github.com/doctest/doctest/issues/473) +- How to use Doctest with Github Actions [\#472](https://github.com/doctest/doctest/issues/472) +- Link error \(multiple definition...\) in simple project [\#470](https://github.com/doctest/doctest/issues/470) +- INFO does not compile when used like a function call [\#469](https://github.com/doctest/doctest/issues/469) +- std::uncaught\_exceptions is only available if compiling for macOS 10.12 or above [\#466](https://github.com/doctest/doctest/issues/466) +- Compile failure with WinRT on 2.4.5 [\#465](https://github.com/doctest/doctest/issues/465) + +**Merged pull requests:** + +- Improve speed with attached debugger \(Windows\) [\#482](https://github.com/doctest/doctest/pull/482) ([pgroke](https://github.com/pgroke)) +- Convert to bool by casting, rather than double negation [\#480](https://github.com/doctest/doctest/pull/480) ([kitegi](https://github.com/kitegi)) +- Fix compile error when targeting macOS version earlier and macOS 10.12 [\#478](https://github.com/doctest/doctest/pull/478) ([SamWindell](https://github.com/SamWindell)) +- Fix MSVC linter warning about uninitialized TestSuite variables [\#471](https://github.com/doctest/doctest/pull/471) ([Reedbeta](https://github.com/Reedbeta)) +- REQUIRE does not compile when operator== in different namespace \#443 . [\#468](https://github.com/doctest/doctest/pull/468) ([navinp0304](https://github.com/navinp0304)) +- Automatically add TEST\_SUITE labels to discovered tests [\#464](https://github.com/doctest/doctest/pull/464) ([shivupa](https://github.com/shivupa)) + +## [2.4.5](https://github.com/doctest/doctest/tree/2.4.5) (2021-02-02) +[Full Changelog](https://github.com/doctest/doctest/compare/2.4.4...2.4.5) + +**Closed issues:** + +- Stack buffer overflow in `String` constructor [\#460](https://github.com/doctest/doctest/issues/460) +- Suppress warnings from clang-tidy [\#459](https://github.com/doctest/doctest/issues/459) +- compilation issue in MSVC when defining DOCTEST\_THREAD\_LOCAL to static [\#458](https://github.com/doctest/doctest/issues/458) +- nvcc compiler warning; doctest.h\(4138\): warning : expression has no effect [\#454](https://github.com/doctest/doctest/issues/454) +- Use of std::atomic can slow down multithreaded tests [\#452](https://github.com/doctest/doctest/issues/452) + +**Merged pull requests:** + +- Fix compilation on case-sensitive filesystems [\#463](https://github.com/doctest/doctest/pull/463) ([jhasse](https://github.com/jhasse)) +- Use function-like macros for prefixless macro names [\#462](https://github.com/doctest/doctest/pull/462) ([tbleher](https://github.com/tbleher)) +- Implement a multi lane atomic for assertion counts [\#453](https://github.com/doctest/doctest/pull/453) ([martinus](https://github.com/martinus)) + +## [2.4.4](https://github.com/doctest/doctest/tree/2.4.4) (2020-12-25) +[Full Changelog](https://github.com/doctest/doctest/compare/2.4.3...2.4.4) + +**Closed issues:** + +- 2.4.2: build fails [\#450](https://github.com/doctest/doctest/issues/450) +- combine the same tests for different build configurations from multiple shared objects without having symbol clashes [\#436](https://github.com/doctest/doctest/issues/436) +- Issue with GitHub Security Scanning: gmtime [\#423](https://github.com/doctest/doctest/issues/423) + +## [2.4.3](https://github.com/doctest/doctest/tree/2.4.3) (2020-12-16) +[Full Changelog](https://github.com/doctest/doctest/compare/2.4.2...2.4.3) + +## [2.4.2](https://github.com/doctest/doctest/tree/2.4.2) (2020-12-15) +[Full Changelog](https://github.com/doctest/doctest/compare/2.4.1...2.4.2) + +**Closed issues:** + +- DOCTEST\_CHECK\_THROWS\_WITH\_AS fails to work with dependant exception type [\#447](https://github.com/doctest/doctest/issues/447) +- MSVC warnings: narrowing conversion, signed/unsigned mismatch [\#446](https://github.com/doctest/doctest/issues/446) +- log contexts for failures in JUnit reporter [\#441](https://github.com/doctest/doctest/issues/441) +- MinGW "'mutex' in namespace 'std' does not name a type" error. [\#438](https://github.com/doctest/doctest/issues/438) +- Test runner thread initialization [\#435](https://github.com/doctest/doctest/issues/435) +- PLATFORM is misdetected on MacOSX Big Sur [\#415](https://github.com/doctest/doctest/issues/415) +- CHECK\_EQ with enum values [\#276](https://github.com/doctest/doctest/issues/276) + +**Merged pull requests:** + +- Squash MSVC warnings when including ntstatus.h [\#449](https://github.com/doctest/doctest/pull/449) ([nickhutchinson](https://github.com/nickhutchinson)) +- Add MAIN\_PROJECT check for test option [\#445](https://github.com/doctest/doctest/pull/445) ([globberwops](https://github.com/globberwops)) +- Suppress clang-analyzer-cplusplus.NewDeleteLeaks [\#444](https://github.com/doctest/doctest/pull/444) ([ncihnegn](https://github.com/ncihnegn)) +- log contexts for failures in JUnit reporter [\#442](https://github.com/doctest/doctest/pull/442) ([runave](https://github.com/runave)) +- Fix 32bit support on macOS [\#440](https://github.com/doctest/doctest/pull/440) ([AlexanderLanin](https://github.com/AlexanderLanin)) + +## [2.4.1](https://github.com/doctest/doctest/tree/2.4.1) (2020-11-04) +[Full Changelog](https://github.com/doctest/doctest/compare/2.4.0...2.4.1) + +**Closed issues:** + +- Avoid old C-style casts [\#424](https://github.com/doctest/doctest/issues/424) +- Segfault in unwind [\#422](https://github.com/doctest/doctest/issues/422) +- Inspect exception with gdb [\#421](https://github.com/doctest/doctest/issues/421) +- use-of-uninitialized-value [\#414](https://github.com/doctest/doctest/issues/414) +- Support unit tests with MPI [\#413](https://github.com/doctest/doctest/issues/413) +- Break into debugger support is missing for Linux [\#411](https://github.com/doctest/doctest/issues/411) +- What if built doctest as static library instead of header-only [\#408](https://github.com/doctest/doctest/issues/408) +- \[Question\] How to get test case name [\#407](https://github.com/doctest/doctest/issues/407) +- create extensions header for optional features requiring more std includes or newer C++ features [\#405](https://github.com/doctest/doctest/issues/405) +- tests/asserts summary lines are misaligned when counts exceed 999999 [\#402](https://github.com/doctest/doctest/issues/402) +- Call to 'ne' is ambiguous -- with solution [\#395](https://github.com/doctest/doctest/issues/395) +- Intermittent Segfaults [\#391](https://github.com/doctest/doctest/issues/391) +- Junit classname [\#390](https://github.com/doctest/doctest/issues/390) +- Add default printers for enums [\#121](https://github.com/doctest/doctest/issues/121) + +**Merged pull requests:** + +- Enum support \(fix for Issue \#121\) [\#429](https://github.com/doctest/doctest/pull/429) ([jkriegshauser](https://github.com/jkriegshauser)) +- Support Clang 3.4 [\#428](https://github.com/doctest/doctest/pull/428) ([AlexanderLanin](https://github.com/AlexanderLanin)) +- Silence remarks on old C-style casts [\#425](https://github.com/doctest/doctest/pull/425) ([UnePierre](https://github.com/UnePierre)) +- Initial MPI unit tests implementation [\#418](https://github.com/doctest/doctest/pull/418) ([BerengerBerthoul](https://github.com/BerengerBerthoul)) +- Add JUNIT\_OUTPUT\_DIR option to doctest\_discover\_tests [\#417](https://github.com/doctest/doctest/pull/417) ([Tradias](https://github.com/Tradias)) +- Add option to build with std headers. [\#416](https://github.com/doctest/doctest/pull/416) ([avostrik](https://github.com/avostrik)) +- Port Catch2 break into debugger for Linux. closes \#411 [\#412](https://github.com/doctest/doctest/pull/412) ([mikezackles](https://github.com/mikezackles)) +- summary: align even large values \#402 [\#403](https://github.com/doctest/doctest/pull/403) ([dankamongmen](https://github.com/dankamongmen)) +- Add breakpoint inline assembly for the Apple Silicon macOS. [\#400](https://github.com/doctest/doctest/pull/400) ([bruvzg](https://github.com/bruvzg)) +- fix google's death test URI in roadmap [\#393](https://github.com/doctest/doctest/pull/393) ([ashutosh108](https://github.com/ashutosh108)) + +## [2.4.0](https://github.com/doctest/doctest/tree/2.4.0) (2020-06-27) +[Full Changelog](https://github.com/doctest/doctest/compare/2.3.8...2.4.0) + +**Closed issues:** + +- Count points based on the number of passed/failed cases? [\#386](https://github.com/doctest/doctest/issues/386) +- How to understand "\#data\_array" in std::string? [\#383](https://github.com/doctest/doctest/issues/383) +- crash: doctest with custom allocator [\#382](https://github.com/doctest/doctest/issues/382) +- Feature Request: format PRIVATE/PUBLIC/INTERFACE entries with constant indentation [\#378](https://github.com/doctest/doctest/issues/378) +- JUnit Reporter for Doctest [\#376](https://github.com/doctest/doctest/issues/376) +- Avoiding Feature Bloat [\#374](https://github.com/doctest/doctest/issues/374) +- StringMaker\ fail to compile with C++20 enabled \(GCC\) [\#357](https://github.com/doctest/doctest/issues/357) +- doctest\_discover\_tests and FetchContent\_Declare [\#351](https://github.com/doctest/doctest/issues/351) +- Junit reporter [\#318](https://github.com/doctest/doctest/issues/318) + +**Merged pull requests:** + +- Add a note that doctest can be installed through Homebrew [\#388](https://github.com/doctest/doctest/pull/388) ([cameronwhite](https://github.com/cameronwhite)) +- provide alternative implementation of has\_insertion\_operator for C++20 [\#387](https://github.com/doctest/doctest/pull/387) ([lukaszgemborowski](https://github.com/lukaszgemborowski)) +- Fix issue template to mention doctest [\#380](https://github.com/doctest/doctest/pull/380) ([nyanpasu64](https://github.com/nyanpasu64)) + +## [2.3.8](https://github.com/doctest/doctest/tree/2.3.8) (2020-05-17) +[Full Changelog](https://github.com/doctest/doctest/compare/2.3.7...2.3.8) + +**Closed issues:** + +- Scenario name can not be passed to -tc to execute single scenario [\#373](https://github.com/doctest/doctest/issues/373) +- Compile Error with CHECK\_NOTHROW when using 2 Template Arguments [\#372](https://github.com/doctest/doctest/issues/372) +- dll example won't compile [\#371](https://github.com/doctest/doctest/issues/371) +- Build error with MinGW \(Mingw-w64\) due to missing Windows.h \(with capital W\) [\#370](https://github.com/doctest/doctest/issues/370) +- How to override file\_line\_to\_stream? [\#369](https://github.com/doctest/doctest/issues/369) +- Memory sanitizer fails. [\#365](https://github.com/doctest/doctest/issues/365) +- Warning c6319 in Visual Studio [\#359](https://github.com/doctest/doctest/issues/359) +- Any option to show each test case's execute time? [\#358](https://github.com/doctest/doctest/issues/358) +- doctest in embedded [\#355](https://github.com/doctest/doctest/issues/355) +- Reloading a plugin with test cases leads to a segmentation fault [\#350](https://github.com/doctest/doctest/issues/350) +- Compiling with DOCTEST\_CONFIG\_COLORS\_ANSI fails on Windows [\#348](https://github.com/doctest/doctest/issues/348) +- Can I inherit ConsoleReporter? [\#344](https://github.com/doctest/doctest/issues/344) +- Noreturn and noexcept defines for Visual Studio 2013 support [\#327](https://github.com/doctest/doctest/issues/327) +- Data-driven testing -- print out the deepest DOCTEST\_SUBCASE [\#215](https://github.com/doctest/doctest/issues/215) +- Print the SUBCASE path when an assert fails in the TEST\_CASE body [\#125](https://github.com/doctest/doctest/issues/125) + +**Merged pull requests:** + +- fix: possible UB with nullptr increment [\#368](https://github.com/doctest/doctest/pull/368) ([oktonion](https://github.com/oktonion)) +- Use CMake's CMP0077 policy if available [\#363](https://github.com/doctest/doctest/pull/363) ([thelink2012](https://github.com/thelink2012)) +- Fix warning c6319 in Visual Studio 16.5 [\#361](https://github.com/doctest/doctest/pull/361) ([Cvelth](https://github.com/Cvelth)) + +## [2.3.7](https://github.com/doctest/doctest/tree/2.3.7) (2020-02-24) +[Full Changelog](https://github.com/doctest/doctest/compare/2.3.6...2.3.7) + +**Closed issues:** + +- Some of the GitHub CI builds are failing [\#334](https://github.com/doctest/doctest/issues/334) +- C++20 removed std::uncaught\_exception [\#333](https://github.com/doctest/doctest/issues/333) +- Doctest SEH handlers are called before \_\_except handlers [\#324](https://github.com/doctest/doctest/issues/324) + +**Merged pull requests:** + +- using std namespace where necessary and timer ticks fix [\#341](https://github.com/doctest/doctest/pull/341) ([oktonion](https://github.com/oktonion)) +- fix std::uncaught\_exceptions [\#340](https://github.com/doctest/doctest/pull/340) ([cyyever](https://github.com/cyyever)) +- Fix GitHub CI and add GitHub build badges [\#336](https://github.com/doctest/doctest/pull/336) ([claremacrae](https://github.com/claremacrae)) +- http -\> https [\#331](https://github.com/doctest/doctest/pull/331) ([Coeur](https://github.com/Coeur)) +- Switch to catching unhandled exceptions on Windows Closes \#324 [\#325](https://github.com/doctest/doctest/pull/325) ([jkriegshauser](https://github.com/jkriegshauser)) + +## [2.3.6](https://github.com/doctest/doctest/tree/2.3.6) (2019-12-16) +[Full Changelog](https://github.com/doctest/doctest/compare/2.3.5...2.3.6) + +**Closed issues:** + +- Link problem w/ BUILD=Release if MESSAGE\(\) with std::string/ostream-operator is used [\#316](https://github.com/doctest/doctest/issues/316) +- the FAQ about difference to Catch2 is missing tags [\#315](https://github.com/doctest/doctest/issues/315) +- include Windows.h in small caps to silence clang warnings [\#312](https://github.com/doctest/doctest/issues/312) +- Mistake in generator with lgtm error [\#311](https://github.com/doctest/doctest/issues/311) +- CMake: cannot install target doctest\_with\_main [\#310](https://github.com/doctest/doctest/issues/310) +- \[bug\] INFO\(\) and CAPTURE\(\) cannot compile using MSVC when used with DOCTEST\_CONFIG\_IMPLEMENTATION\_IN\_DLL [\#306](https://github.com/doctest/doctest/issues/306) +- Skip subcase [\#304](https://github.com/doctest/doctest/issues/304) +- Does some equivalent features from google test exist here? [\#300](https://github.com/doctest/doctest/issues/300) +- How to use doctest in dll only\(without main.cpp and .exe\) [\#299](https://github.com/doctest/doctest/issues/299) +- Warning: C26812: The enum type 'doctest::assertType::Enum' is unscoped. Prefer 'enum class' over 'enum' \(Enum.3\). [\#298](https://github.com/doctest/doctest/issues/298) +- test executable\_dll\_and\_plugin fails on Linux, GCC 8.1.0, -fsanitize=address [\#201](https://github.com/doctest/doctest/issues/201) + +**Merged pull requests:** + +- Fixed missing ostream include for MacOS when defining DOCTEST\_CONFIG\_… [\#314](https://github.com/doctest/doctest/pull/314) ([NKTomHaygarth](https://github.com/NKTomHaygarth)) +- include windows.h in cmall caps to silence clang nonportable warnings [\#313](https://github.com/doctest/doctest/pull/313) ([suoniq](https://github.com/suoniq)) +- Add .editorconfig file. [\#301](https://github.com/doctest/doctest/pull/301) ([DaanDeMeyer](https://github.com/DaanDeMeyer)) +- Add Github Actions CI [\#285](https://github.com/doctest/doctest/pull/285) ([DaanDeMeyer](https://github.com/DaanDeMeyer)) + +## [2.3.5](https://github.com/doctest/doctest/tree/2.3.5) (2019-09-22) +[Full Changelog](https://github.com/doctest/doctest/compare/2.3.4...2.3.5) + +**Closed issues:** + +- \[feature request\] Assertion macros for throwing exception of a specific type with message - \\_THROWS\_WITH\_AS\(expr, string, ex\_type\) [\#295](https://github.com/doctest/doctest/issues/295) +- CHECK\_THROWS\_AS of non-default constructor wants to call default constructor [\#293](https://github.com/doctest/doctest/issues/293) +- Typos and spelling errors in source, documentation and scripts [\#291](https://github.com/doctest/doctest/issues/291) +- Customize test names / variable substitution [\#284](https://github.com/doctest/doctest/issues/284) +- SUBCASE in function not behaving as expected [\#282](https://github.com/doctest/doctest/issues/282) +- SUPER\_FAST\_ASSERTS fails to compile CHECK\_MESSAGE [\#281](https://github.com/doctest/doctest/issues/281) +- CHECK\_MESSAGE no longer works with DOCTEST\_CONFIG\_SUPER\_FAST\_ASSERTS [\#280](https://github.com/doctest/doctest/issues/280) +- CAPTURE of structured binding element no longer works [\#279](https://github.com/doctest/doctest/issues/279) +- Reporter: `test\_case\_end` no longer fired after test case restart [\#278](https://github.com/doctest/doctest/issues/278) +- Add debug break override support [\#277](https://github.com/doctest/doctest/issues/277) +- Running tests from within Visual Studio in a static lib project [\#275](https://github.com/doctest/doctest/issues/275) +- Compile-time error when using a raw string literal inside of REQUIRE \(MSVC 2017\) [\#274](https://github.com/doctest/doctest/issues/274) +- Give example for having tests in production code [\#252](https://github.com/doctest/doctest/issues/252) +- Memory leaks just by including doctest.h [\#205](https://github.com/doctest/doctest/issues/205) +- Feature request: print subcase when an exception is thrown inside one [\#136](https://github.com/doctest/doctest/issues/136) + +**Merged pull requests:** + +- Fix typos and misspellings found by codespell. [\#292](https://github.com/doctest/doctest/pull/292) ([warmsocks](https://github.com/warmsocks)) +- Document order by issue correctly [\#290](https://github.com/doctest/doctest/pull/290) ([DaanDeMeyer](https://github.com/DaanDeMeyer)) +- Document that -order-by=file is compiler-dependent [\#289](https://github.com/doctest/doctest/pull/289) ([DaanDeMeyer](https://github.com/DaanDeMeyer)) +- Add -order-by=name to filter\_2 test [\#288](https://github.com/doctest/doctest/pull/288) ([DaanDeMeyer](https://github.com/DaanDeMeyer)) +- Add support for compiling with clang-cl [\#286](https://github.com/doctest/doctest/pull/286) ([DaanDeMeyer](https://github.com/DaanDeMeyer)) +- No minimum version limitation of Meson [\#283](https://github.com/doctest/doctest/pull/283) ([ydm](https://github.com/ydm)) + +## [2.3.4](https://github.com/doctest/doctest/tree/2.3.4) (2019-08-12) +[Full Changelog](https://github.com/doctest/doctest/compare/2.3.3...2.3.4) + +**Closed issues:** + +- Remove INFO\(\) limitation for using only lvalues and no rvalues [\#269](https://github.com/doctest/doctest/issues/269) +- Compile error on MAC OS with AppleClang 8.0.0.8000042 [\#266](https://github.com/doctest/doctest/issues/266) +- Throwing exception in a mocked method [\#265](https://github.com/doctest/doctest/issues/265) +- Illegal syntax for decorators compiles and runs without warning, but has no effect [\#264](https://github.com/doctest/doctest/issues/264) +- Support conditional expressions in REQUIRE [\#262](https://github.com/doctest/doctest/issues/262) +- Register a listener\(reporter\) that always listens [\#257](https://github.com/doctest/doctest/issues/257) +- Memory sanitizer complaint [\#255](https://github.com/doctest/doctest/issues/255) +- Windows Clang GNU command line warnings [\#253](https://github.com/doctest/doctest/issues/253) +- The build writes into the source directory [\#249](https://github.com/doctest/doctest/issues/249) +- How to enable tests inside another exe [\#246](https://github.com/doctest/doctest/issues/246) +- Testing multiple headers. [\#244](https://github.com/doctest/doctest/issues/244) +- CMakeLists.txt: Needs CMAKE\_CXX\_STANDARD=11 [\#243](https://github.com/doctest/doctest/issues/243) +- \[bug\] Can't compile the tests because of mutex, that is declared in the doctest [\#242](https://github.com/doctest/doctest/issues/242) + +**Merged pull requests:** + +- Improve Listener docs [\#273](https://github.com/doctest/doctest/pull/273) ([claremacrae](https://github.com/claremacrae)) +- Rework `INFO` lazy evaluation to use lambdas. [\#270](https://github.com/doctest/doctest/pull/270) ([DaanDeMeyer](https://github.com/DaanDeMeyer)) +- Prevent compile errors with AppleClang compiler [\#268](https://github.com/doctest/doctest/pull/268) ([ClausKlein](https://github.com/ClausKlein)) +- Revert "fix : including windows.h header cause error" [\#263](https://github.com/doctest/doctest/pull/263) ([onqtam](https://github.com/onqtam)) +- Fix static analyzer URLs [\#259](https://github.com/doctest/doctest/pull/259) ([godbyk](https://github.com/godbyk)) +- fix : including windows.h header cause error [\#258](https://github.com/doctest/doctest/pull/258) ([rinechran](https://github.com/rinechran)) +- only look for C++ compiler with CMake [\#256](https://github.com/doctest/doctest/pull/256) ([zhihaoy](https://github.com/zhihaoy)) +- Fix \#253 [\#254](https://github.com/doctest/doctest/pull/254) ([DaanDeMeyer](https://github.com/DaanDeMeyer)) +- add alias target for doctest for use in build tree [\#247](https://github.com/doctest/doctest/pull/247) ([trondhe](https://github.com/trondhe)) + +## [2.3.3](https://github.com/doctest/doctest/tree/2.3.3) (2019-06-02) +[Full Changelog](https://github.com/doctest/doctest/compare/2.3.2...2.3.3) + +**Closed issues:** + +- Build fails with gcc9 because of -Wstrict-overflow=5 which is too high [\#241](https://github.com/doctest/doctest/issues/241) +- doctest given defined with short macro name [\#239](https://github.com/doctest/doctest/issues/239) +- Splitting templated test across different translation units [\#238](https://github.com/doctest/doctest/issues/238) +- Compile errors with iosfwd.h and Visual Studio 2019 Preview [\#183](https://github.com/doctest/doctest/issues/183) +- Add CMake test support as catch\_discover\_tests\(\) in Catch2 [\#171](https://github.com/doctest/doctest/issues/171) + +**Merged pull requests:** + +- fix \#239 - use long macro name [\#240](https://github.com/doctest/doctest/pull/240) ([m-bd](https://github.com/m-bd)) +- Add doctest\_discover\_tests\(\) [\#236](https://github.com/doctest/doctest/pull/236) ([reddwarf69](https://github.com/reddwarf69)) +- Ignore redundant-decls warning on MinGW [\#235](https://github.com/doctest/doctest/pull/235) ([AMS21](https://github.com/AMS21)) +- Fixed meson build file dependency declaration [\#233](https://github.com/doctest/doctest/pull/233) ([jormundgand](https://github.com/jormundgand)) + +## [2.3.2](https://github.com/doctest/doctest/tree/2.3.2) (2019-05-06) +[Full Changelog](https://github.com/doctest/doctest/compare/2.3.1...2.3.2) + +**Closed issues:** + +- scripts/bench/run\_all.py : module 'urllib' has no attribute 'urlretrieve' [\#230](https://github.com/doctest/doctest/issues/230) +- wrong set of tests registered with TEST\_CASE\_TEMPLATE get executed [\#228](https://github.com/doctest/doctest/issues/228) +- Logging not Working for me [\#227](https://github.com/doctest/doctest/issues/227) +- Link test runner executable into dll? [\#226](https://github.com/doctest/doctest/issues/226) +- Linking issue for executables after including doctest in library [\#224](https://github.com/doctest/doctest/issues/224) +- Strange REQUIRE\_THROWS behaviour [\#223](https://github.com/doctest/doctest/issues/223) +- Windows clang-cl -Wunused-variable warning [\#221](https://github.com/doctest/doctest/issues/221) +- Update doctest 2.3.1 in bincrafters [\#220](https://github.com/doctest/doctest/issues/220) +- make install, on 64 bit, installs cmake files into lib instead of lib64 folder [\#218](https://github.com/doctest/doctest/issues/218) +- TSAN: data race related to hasLoggedCurrentTestStart [\#217](https://github.com/doctest/doctest/issues/217) +- REQUIRE\_THROWS\_AS does not support class constructors [\#216](https://github.com/doctest/doctest/issues/216) +- Build failure on clang 7.0.1 on Fedora 29 [\#214](https://github.com/doctest/doctest/issues/214) +- add example compatible with -\> https://github.com/report-ci/ [\#212](https://github.com/doctest/doctest/issues/212) +- No DOCTEST\_WITH\_TESTS? [\#211](https://github.com/doctest/doctest/issues/211) + +**Merged pull requests:** + +- Added meson file, to declare a dependency. [\#232](https://github.com/doctest/doctest/pull/232) ([jormundgand](https://github.com/jormundgand)) +- Explicitly specify the doctest\_with\_main C++ standard in CMake. [\#231](https://github.com/doctest/doctest/pull/231) ([DaanDeMeyer](https://github.com/DaanDeMeyer)) +- Remove architecture check from CMake package [\#225](https://github.com/doctest/doctest/pull/225) ([mmha](https://github.com/mmha)) +- add default install prefix [\#219](https://github.com/doctest/doctest/pull/219) ([a4z](https://github.com/a4z)) +- \[regression\] Workaround MSVC preprocessor issue triggered by REQUIRE\_THROWS [\#213](https://github.com/doctest/doctest/pull/213) ([zhihaoy](https://github.com/zhihaoy)) + +## [2.3.1](https://github.com/doctest/doctest/tree/2.3.1) (2019-03-24) +[Full Changelog](https://github.com/doctest/doctest/compare/2.3.0...2.3.1) + +**Merged pull requests:** + +- Add two very simple examples of using doctest with CMake [\#209](https://github.com/doctest/doctest/pull/209) ([pr0g](https://github.com/pr0g)) + +## [2.3.0](https://github.com/doctest/doctest/tree/2.3.0) (2019-03-23) +[Full Changelog](https://github.com/doctest/doctest/compare/2.2.3...2.3.0) + +**Closed issues:** + +- Compilation with emscripten fails by default because of signal handling [\#207](https://github.com/doctest/doctest/issues/207) +- Compilation fails with cl.exe /Zc:wchar\_t- [\#206](https://github.com/doctest/doctest/issues/206) +- Parallel invocation of doctest's own testsuite via CTest fails [\#202](https://github.com/doctest/doctest/issues/202) +- Get the number of passed/failed tests in the code [\#200](https://github.com/doctest/doctest/issues/200) +- Tests alongside code with multiple executables [\#199](https://github.com/doctest/doctest/issues/199) +- Cppcheck 1.86 warnings [\#198](https://github.com/doctest/doctest/issues/198) +- Compiling as Dll maybe is wrong [\#196](https://github.com/doctest/doctest/issues/196) +- Forward-declaring identifiers in std:: is UB - consider including some of the cheaper C/C++ stdlib headers [\#194](https://github.com/doctest/doctest/issues/194) +- QtCreator + clang warning about operator \<\< precedence [\#191](https://github.com/doctest/doctest/issues/191) +- run test fixture from cli [\#190](https://github.com/doctest/doctest/issues/190) +- Installing doctest using cmake and make fails on Ubuntu 16.04 \(C++11 is not used\) [\#189](https://github.com/doctest/doctest/issues/189) +- c++17 requirement for testing private members [\#188](https://github.com/doctest/doctest/issues/188) +- \[feature request\] implement a user-extendable reporter system [\#138](https://github.com/doctest/doctest/issues/138) +- Same test runs multiple times when written in a header and included with different unnormalized paths [\#45](https://github.com/doctest/doctest/issues/45) + +**Merged pull requests:** + +- Fix unmatched bracket in DOCTEST\_TEST\_CASE\_CLASS [\#204](https://github.com/doctest/doctest/pull/204) ([patstew](https://github.com/patstew)) +- Template apply [\#203](https://github.com/doctest/doctest/pull/203) ([zhihaoy](https://github.com/zhihaoy)) +- No undefined behavior per C++ standard in detecting endianness. [\#195](https://github.com/doctest/doctest/pull/195) ([dimztimz](https://github.com/dimztimz)) +- Fix propagating include directories of target doctest\_with\_main [\#193](https://github.com/doctest/doctest/pull/193) ([dimztimz](https://github.com/dimztimz)) +- Move single header to a separate folder [\#187](https://github.com/doctest/doctest/pull/187) ([dimztimz](https://github.com/dimztimz)) +- Fix Clang format to handle C++11 [\#186](https://github.com/doctest/doctest/pull/186) ([dimztimz](https://github.com/dimztimz)) +- Rename doctest\_impl.h to doctest.cpp for less confusion. [\#185](https://github.com/doctest/doctest/pull/185) ([dimztimz](https://github.com/dimztimz)) + +## [2.2.3](https://github.com/doctest/doctest/tree/2.2.3) (2019-02-10) +[Full Changelog](https://github.com/doctest/doctest/compare/2.2.2...2.2.3) + +**Closed issues:** + +- Calling convention needed on a few functions [\#182](https://github.com/doctest/doctest/issues/182) +- Terminal color is not reset when a test fails with some signal [\#122](https://github.com/doctest/doctest/issues/122) + +## [2.2.2](https://github.com/doctest/doctest/tree/2.2.2) (2019-01-28) +[Full Changelog](https://github.com/doctest/doctest/compare/2.2.1...2.2.2) + +**Closed issues:** + +- Add way to override getCurrentTicks\(\) implementation [\#178](https://github.com/doctest/doctest/issues/178) +- Wrap \ include with ifdef [\#177](https://github.com/doctest/doctest/issues/177) +- How to stop doctest hijack unhandled exceptions? [\#176](https://github.com/doctest/doctest/issues/176) +- Change the include path of the `doctest` CMake interface target so users need to specify the folder as well [\#175](https://github.com/doctest/doctest/issues/175) +- Reduce scope of DebugOutputWindowReporter instance [\#174](https://github.com/doctest/doctest/issues/174) +- Can logging \(INFO\) be used in helper class outside of TEST\_CASE? [\#169](https://github.com/doctest/doctest/issues/169) + +**Merged pull requests:** + +- Change the include path in examples as \#175 [\#180](https://github.com/doctest/doctest/pull/180) ([ncihnegn](https://github.com/ncihnegn)) +- Fix CMake include path \#175 [\#179](https://github.com/doctest/doctest/pull/179) ([ncihnegn](https://github.com/ncihnegn)) + +## [2.2.1](https://github.com/doctest/doctest/tree/2.2.1) (2019-01-15) +[Full Changelog](https://github.com/doctest/doctest/compare/2.2.0...2.2.1) + +**Closed issues:** + +- the `--no-throw` option shouldn't affect `\\_NOTHROW` asserts [\#173](https://github.com/doctest/doctest/issues/173) +- Make doctest work with XCode 6 and 7 \(no support for C++11 thread\_local\) [\#172](https://github.com/doctest/doctest/issues/172) +- Print vector content. [\#170](https://github.com/doctest/doctest/issues/170) +- Conan package [\#103](https://github.com/doctest/doctest/issues/103) +- \[feature request\] Thread-safety for asserts and logging facilities [\#4](https://github.com/doctest/doctest/issues/4) + +## [2.2.0](https://github.com/doctest/doctest/tree/2.2.0) (2018-12-05) +[Full Changelog](https://github.com/doctest/doctest/compare/2.1.0...2.2.0) + +**Closed issues:** + +- remove the FAST\_ versions of the binary asserts \(not a breaking change!\) [\#167](https://github.com/doctest/doctest/issues/167) +- \[compile times\] make the DOCTEST\_CONFIG\_SUPER\_FAST\_ASSERTS identifier affect normal asserts too [\#166](https://github.com/doctest/doctest/issues/166) + +## [2.1.0](https://github.com/doctest/doctest/tree/2.1.0) (2018-11-30) +[Full Changelog](https://github.com/doctest/doctest/compare/2.0.1...2.1.0) + +**Closed issues:** + +- doctest::String ctor with non-zero terminated string [\#165](https://github.com/doctest/doctest/issues/165) +- thread\_local is not supported on iOS 9.0 [\#164](https://github.com/doctest/doctest/issues/164) +- Compiler error on Android NDK r18 [\#163](https://github.com/doctest/doctest/issues/163) +- \[question\] One setup for multiple tests [\#160](https://github.com/doctest/doctest/issues/160) +- clang unwanted warning in user code [\#156](https://github.com/doctest/doctest/issues/156) +- Unsigned integer overflow in fileOrderComparator [\#151](https://github.com/doctest/doctest/issues/151) +- ThreadSanitizer: signal-unsafe call inside of a signal [\#147](https://github.com/doctest/doctest/issues/147) +- Feature request: check for exception string \(like Catch's CHECK\_THROWS\_WITH\) [\#97](https://github.com/doctest/doctest/issues/97) + +**Merged pull requests:** + +- Fixed build error under Android NDK [\#162](https://github.com/doctest/doctest/pull/162) ([tals](https://github.com/tals)) +- Added clang-7 to travis build [\#161](https://github.com/doctest/doctest/pull/161) ([AMS21](https://github.com/AMS21)) +- Remove clang-tidy warnings for static fields created by doctest [\#159](https://github.com/doctest/doctest/pull/159) ([rantasub](https://github.com/rantasub)) +- Make it possible to change the command line options prefix [\#158](https://github.com/doctest/doctest/pull/158) ([tbleher](https://github.com/tbleher)) + +## [2.0.1](https://github.com/doctest/doctest/tree/2.0.1) (2018-10-24) +[Full Changelog](https://github.com/doctest/doctest/compare/2.0.0...2.0.1) + +**Closed issues:** + +- macro name collision with google log [\#157](https://github.com/doctest/doctest/issues/157) +- Add \#define to not run tests by default [\#152](https://github.com/doctest/doctest/issues/152) +- REQUIRE\_THROWS\_MESSAGE not checking message correctly [\#150](https://github.com/doctest/doctest/issues/150) +- Test case passes even though subcase failed [\#149](https://github.com/doctest/doctest/issues/149) + +**Merged pull requests:** + +- Correctly document when a main\(\) entry point will be created [\#155](https://github.com/doctest/doctest/pull/155) ([tbleher](https://github.com/tbleher)) +- Correct format string for unsigned char [\#154](https://github.com/doctest/doctest/pull/154) ([tbleher](https://github.com/tbleher)) + +## [2.0.0](https://github.com/doctest/doctest/tree/2.0.0) (2018-08-23) +[Full Changelog](https://github.com/doctest/doctest/compare/1.2.9...2.0.0) + +**Closed issues:** + +- MSVC 2017 15.8.1, New Warnings as Errors [\#144](https://github.com/doctest/doctest/issues/144) +- Windows clang-cl -Wdeprecated-declarations warnings [\#143](https://github.com/doctest/doctest/issues/143) +- Logo Proposal for Doctest [\#141](https://github.com/doctest/doctest/issues/141) +- PCH Support [\#140](https://github.com/doctest/doctest/issues/140) +- improve compile times even further [\#139](https://github.com/doctest/doctest/issues/139) +- !!! BREAKING CHANGE !!! - Move to C++11 for next version of the library [\#137](https://github.com/doctest/doctest/issues/137) +- getCurrentTicks producing warning on MinGW [\#133](https://github.com/doctest/doctest/issues/133) +- \[enhancement\] Add support for "stand-alone assertions". [\#114](https://github.com/doctest/doctest/issues/114) + +**Merged pull requests:** + +- Suppress compiler warning on MinGW [\#134](https://github.com/doctest/doctest/pull/134) ([AMS21](https://github.com/AMS21)) + +## [1.2.9](https://github.com/doctest/doctest/tree/1.2.9) (2018-05-10) +[Full Changelog](https://github.com/doctest/doctest/compare/1.2.8...1.2.9) + +**Closed issues:** + +- GCC 8.0 std::uncaught\_exception\(\) is deprecated [\#130](https://github.com/doctest/doctest/issues/130) +- Signal stack size too small on Linux [\#129](https://github.com/doctest/doctest/issues/129) +- Support Intel Compiler [\#128](https://github.com/doctest/doctest/issues/128) +- Please add support for MSVC 2005 [\#127](https://github.com/doctest/doctest/issues/127) +- scan-build report "Dereference of null pointer" for function wildcmp [\#124](https://github.com/doctest/doctest/issues/124) +- !!! BREAKING CHANGE \(console output only\) !!! - Emulate the error/warning format emitted by native compiler gcc/clang/msvc when printing test failures in the log [\#123](https://github.com/doctest/doctest/issues/123) +- ARM builds: FTBFS on armhf - error: cast from 'const char\*' to 'const [\#118](https://github.com/doctest/doctest/issues/118) + +**Merged pull requests:** + +- Exclude Intel from GCC compiler check [\#132](https://github.com/doctest/doctest/pull/132) ([smcallis](https://github.com/smcallis)) +- Fix deprecated-declarations warning with GCC-8.0 [\#131](https://github.com/doctest/doctest/pull/131) ([AMS21](https://github.com/AMS21)) + +## [1.2.8](https://github.com/doctest/doctest/tree/1.2.8) (2018-03-10) +[Full Changelog](https://github.com/doctest/doctest/compare/1.2.7...1.2.8) + +**Closed issues:** + +- ARM64 builds: templated\_test\_cases.cpp test fails [\#119](https://github.com/doctest/doctest/issues/119) + +## [1.2.7](https://github.com/doctest/doctest/tree/1.2.7) (2018-02-06) +[Full Changelog](https://github.com/doctest/doctest/compare/1.2.6...1.2.7) + +**Closed issues:** + +- MSan has runtime error: unsigned integer overflow [\#116](https://github.com/doctest/doctest/issues/116) +- clang-tidy warning about cert-err58-cpp [\#115](https://github.com/doctest/doctest/issues/115) +- Linking errors [\#113](https://github.com/doctest/doctest/issues/113) +- inlining function defs [\#111](https://github.com/doctest/doctest/issues/111) +- Nullptr issue. [\#110](https://github.com/doctest/doctest/issues/110) +- MemorySanitizer: use-of-uninitialized-value [\#109](https://github.com/doctest/doctest/issues/109) +- Potential memory leak through scan-build [\#108](https://github.com/doctest/doctest/issues/108) +- Warnings raised to error with latest MSVC version [\#107](https://github.com/doctest/doctest/issues/107) +- New solution for tests in static libraries ! \(MSVC\) [\#106](https://github.com/doctest/doctest/issues/106) +- Command line flags do not work after code formatter/beautifier [\#104](https://github.com/doctest/doctest/issues/104) +- Cppcheck 1.81 warnings [\#102](https://github.com/doctest/doctest/issues/102) + +**Merged pull requests:** + +- Fix macros WIN32\_LEAN\_AND\_MEAN typo [\#112](https://github.com/doctest/doctest/pull/112) ([vladimirgamalyan](https://github.com/vladimirgamalyan)) +- Correct DOCTEST\_NO\_INSTALL logic; do install unless it is set \(\#99\) [\#100](https://github.com/doctest/doctest/pull/100) ([onqtam](https://github.com/onqtam)) +- Correct DOCTEST\_NO\_INSTALL logic; do install unless it is set [\#99](https://github.com/doctest/doctest/pull/99) ([OdyX](https://github.com/OdyX)) + +## [1.2.6](https://github.com/doctest/doctest/tree/1.2.6) (2017-10-29) +[Full Changelog](https://github.com/doctest/doctest/compare/1.2.5...1.2.6) + +**Closed issues:** + +- \[bug\] writing an exception translator in a header file results in it being registered multiple times which is suboptimal [\#98](https://github.com/doctest/doctest/issues/98) +- Warnings when using something more than /W4 for Visual Studio [\#95](https://github.com/doctest/doctest/issues/95) + +**Merged pull requests:** + +- Added an option to not install Doctest in the CMake scripts [\#96](https://github.com/doctest/doctest/pull/96) ([nm17](https://github.com/nm17)) +- Adding a defensive check against a null pointer for the current test suite [\#94](https://github.com/doctest/doctest/pull/94) ([Lectem](https://github.com/Lectem)) +- Remove incomplete copy ctor [\#93](https://github.com/doctest/doctest/pull/93) ([McMartin](https://github.com/McMartin)) + +## [1.2.5](https://github.com/doctest/doctest/tree/1.2.5) (2017-10-06) +[Full Changelog](https://github.com/doctest/doctest/compare/1.2.4...1.2.5) + +**Closed issues:** + +- Xcode 9 / clang - unknown warning group [\#92](https://github.com/doctest/doctest/issues/92) + +## [1.2.4](https://github.com/doctest/doctest/tree/1.2.4) (2017-09-20) +[Full Changelog](https://github.com/doctest/doctest/compare/1.2.3...1.2.4) + +**Closed issues:** + +- \[bug\] test cases can end up in the wrong test suite [\#91](https://github.com/doctest/doctest/issues/91) + +## [1.2.3](https://github.com/doctest/doctest/tree/1.2.3) (2017-09-11) +[Full Changelog](https://github.com/doctest/doctest/compare/1.2.2...1.2.3) + +**Closed issues:** + +- \[bug\] Defining a variable T inside a test with DOCTEST\_CONFIG\_DISABLE defined does not compile [\#90](https://github.com/doctest/doctest/issues/90) +- \[support\] Using `DOCTEST\_CONFIG\_NO\_SHORT\_MACRO\_NAMES` does not compile using g++ 6.3.0 [\#89](https://github.com/doctest/doctest/issues/89) +- \[question\] Why are SUBCASEs executed only once when within a function called multiple times? [\#88](https://github.com/doctest/doctest/issues/88) + +## [1.2.2](https://github.com/doctest/doctest/tree/1.2.2) (2017-09-05) +[Full Changelog](https://github.com/doctest/doctest/compare/1.2.1...1.2.2) + +**Closed issues:** + +- \[question\] Differences between doctest and googletest \(gtest\) for uninitialised local variables in test cases [\#86](https://github.com/doctest/doctest/issues/86) +- !!! BREAKING CHANGE !!! - remove the custom implementation of std::is\_constructible and optionally use the \ header because of infinite template recursion issues with GCC [\#85](https://github.com/doctest/doctest/issues/85) +- Static Analysis results of doctest [\#83](https://github.com/doctest/doctest/issues/83) +- !!! BREAKING CHANGE !!! - catch exceptions as const reference in \\_THROWS\_AS [\#81](https://github.com/doctest/doctest/issues/81) +- doctest implementation as static library [\#77](https://github.com/doctest/doctest/issues/77) +- Provide some easy way to compare structs containing float/doubles [\#73](https://github.com/doctest/doctest/issues/73) + +**Merged pull requests:** + +- Add support for templated scenarios [\#87](https://github.com/doctest/doctest/pull/87) ([Lectem](https://github.com/Lectem)) +- Prefer if\(MSVC\) in CMakeLists.txt. [\#84](https://github.com/doctest/doctest/pull/84) ([martinmoene](https://github.com/martinmoene)) +- catch throw\_as exception as const reference [\#82](https://github.com/doctest/doctest/pull/82) ([a4z](https://github.com/a4z)) +- Added doctest\_with\_main static lib [\#78](https://github.com/doctest/doctest/pull/78) ([ymadzhunkov](https://github.com/ymadzhunkov)) + +## [1.2.1](https://github.com/doctest/doctest/tree/1.2.1) (2017-05-24) +[Full Changelog](https://github.com/doctest/doctest/compare/1.2.0...1.2.1) + +**Closed issues:** + +- Compile error under MSVC 2015/2017 if \ included in same file as "doctest.h" [\#72](https://github.com/doctest/doctest/issues/72) + +**Merged pull requests:** + +- docs: TEST\_CASE\_METHOD -\> TEST\_CASE\_FIXTURE [\#71](https://github.com/doctest/doctest/pull/71) ([akrzemi1](https://github.com/akrzemi1)) + +## [1.2.0](https://github.com/doctest/doctest/tree/1.2.0) (2017-05-15) +[Full Changelog](https://github.com/doctest/doctest/compare/1.1.4...1.2.0) + +**Closed issues:** + +- Further improvements on compile time - disable inlining of functions used in asserts [\#70](https://github.com/doctest/doctest/issues/70) +- Improve runtime performance - lazy stringification, more inlining, no statics on the hot path, move semantics for classes such as doctest::String which are used by value, etc. [\#69](https://github.com/doctest/doctest/issues/69) +- Add option to show duration of test case execution and add a timeout\(seconds\) decorator - marking them as failed if they exceed it [\#68](https://github.com/doctest/doctest/issues/68) +- Add support for test case decorators - label, description, skip, may\_fail, should\_fail, expected\_failures, etc. [\#67](https://github.com/doctest/doctest/issues/67) +- Integrate static analysis into the CI builds [\#66](https://github.com/doctest/doctest/issues/66) +- Print the test suite name on test case failure [\#65](https://github.com/doctest/doctest/issues/65) +- Add signal handlers to handle crashes \(and use SEH under Windows\) - report which test case failed [\#63](https://github.com/doctest/doctest/issues/63) +- Add support to Approx for strong typedefs of double [\#62](https://github.com/doctest/doctest/issues/62) +- \[question\] Is there a way to always have 0 as the exit code regardless of test results? [\#59](https://github.com/doctest/doctest/issues/59) +- Add support for un-parenthesized expressions containing commas in asserts [\#58](https://github.com/doctest/doctest/issues/58) +- Add ability to filter subcases with filters [\#57](https://github.com/doctest/doctest/issues/57) +- Add option to query if code is being ran inside of a test - doctest::is\_running\_in\_test [\#56](https://github.com/doctest/doctest/issues/56) +- Ability for a binary \(executable / shared object\) to use the test runner implementation of another binary - with exported symbols - so tests end up in a single registry [\#55](https://github.com/doctest/doctest/issues/55) +- How to force the use of colors in the terminal? [\#54](https://github.com/doctest/doctest/issues/54) +- How can I mix production code with the Unit Tests? [\#53](https://github.com/doctest/doctest/issues/53) +- add \<= and \>= operators to Approx \(and also maybe \< and \>\) [\#52](https://github.com/doctest/doctest/issues/52) +- Add ability to capture variables from test scope [\#48](https://github.com/doctest/doctest/issues/48) +- !!! BREAKING CHANGE !!! - Make TEST\_SUITE work with blocks and add TEST\_SUITE\_BEGIN [\#41](https://github.com/doctest/doctest/issues/41) +- Add option to print which test suites/cases are run [\#39](https://github.com/doctest/doctest/issues/39) +- Add support for templated test cases - parameterized by type [\#38](https://github.com/doctest/doctest/issues/38) +- Add custom failure messages with lazy stringification [\#23](https://github.com/doctest/doctest/issues/23) +- Add an exception translation mechanism + the ability for users to extend it with custom exception types [\#12](https://github.com/doctest/doctest/issues/12) +- Add API for reporting failures [\#9](https://github.com/doctest/doctest/issues/9) + +**Merged pull requests:** + +- Update doctest to work with ARM DS5-compiler [\#64](https://github.com/doctest/doctest/pull/64) ([tomasnilefrost](https://github.com/tomasnilefrost)) + +## [1.1.4](https://github.com/doctest/doctest/tree/1.1.4) (2017-02-18) +[Full Changelog](https://github.com/doctest/doctest/compare/1.1.3...1.1.4) + +**Closed issues:** + +- Add option --force-colors - for when a tty is not detected for stdout [\#51](https://github.com/doctest/doctest/issues/51) +- Issue with using lambdas in tests in gcc [\#49](https://github.com/doctest/doctest/issues/49) +- Add the include file to releases [\#47](https://github.com/doctest/doctest/issues/47) + +**Merged pull requests:** + +- Add translation of std::exception for exceptions that terminate a test case [\#46](https://github.com/doctest/doctest/pull/46) ([eliaskosunen](https://github.com/eliaskosunen)) + +## [1.1.3](https://github.com/doctest/doctest/tree/1.1.3) (2016-11-15) +[Full Changelog](https://github.com/doctest/doctest/compare/1.1.2...1.1.3) + +**Closed issues:** + +- Exception handlers cause warnings when exceptions are disabled [\#44](https://github.com/doctest/doctest/issues/44) + +## [1.1.2](https://github.com/doctest/doctest/tree/1.1.2) (2016-10-10) +[Full Changelog](https://github.com/doctest/doctest/compare/1.1.1...1.1.2) + +**Closed issues:** + +- clang warnings when using C++11 or newer [\#42](https://github.com/doctest/doctest/issues/42) +- \[support\] identical names for test suites? [\#40](https://github.com/doctest/doctest/issues/40) + +## [1.1.1](https://github.com/doctest/doctest/tree/1.1.1) (2016-09-22) +[Full Changelog](https://github.com/doctest/doctest/compare/1.1.0...1.1.1) + +## [1.1.0](https://github.com/doctest/doctest/tree/1.1.0) (2016-09-21) +[Full Changelog](https://github.com/doctest/doctest/compare/1.0.0...1.1.0) + +**Closed issues:** + +- char\* comparison uses the contents, not the pointer [\#36](https://github.com/doctest/doctest/issues/36) +- add configuration preprocessor identifier for passing by value in assertions instead of by reference [\#35](https://github.com/doctest/doctest/issues/35) +- restrict expressions in assertion macros to binary comparisons at most with a static assert [\#34](https://github.com/doctest/doctest/issues/34) +- Add clearFilters\(\) to doctest::Context [\#33](https://github.com/doctest/doctest/issues/33) +- A way to refrain from polluting “\#define” space for users of tested code? [\#32](https://github.com/doctest/doctest/issues/32) +- drop VC++6 support [\#31](https://github.com/doctest/doctest/issues/31) +- False positive test [\#30](https://github.com/doctest/doctest/issues/30) +- Turn off coloring after tests are finished? [\#28](https://github.com/doctest/doctest/issues/28) +- C++11 nullptr [\#27](https://github.com/doctest/doctest/issues/27) +- Only one SUBCASE per line is executed [\#25](https://github.com/doctest/doctest/issues/25) +- creative formatting of chars [\#24](https://github.com/doctest/doctest/issues/24) +- DOCTEST\_BREAK\_INTO\_DEBUGGER undefined under OSX [\#22](https://github.com/doctest/doctest/issues/22) +- Tests inside a static library [\#21](https://github.com/doctest/doctest/issues/21) +- Add example how to remove doctest options from the command line for the program after the tests run [\#20](https://github.com/doctest/doctest/issues/20) +- Single-letter options active even without leading '-' \(dash\) [\#19](https://github.com/doctest/doctest/issues/19) +- pointer stringification not working for compilers different from MSVC [\#18](https://github.com/doctest/doctest/issues/18) +- Tests that accompany code run and produce output at default [\#17](https://github.com/doctest/doctest/issues/17) +- GCC 5.3.1 Compiler warning: sign compare [\#16](https://github.com/doctest/doctest/issues/16) +- Slower than Catch in realistic test cases [\#14](https://github.com/doctest/doctest/issues/14) +- Rename doctest::detail::Result res; in DOCTEST\_ASSERT\_IMPLEMENT [\#10](https://github.com/doctest/doctest/issues/10) +- No red when all tests pass [\#7](https://github.com/doctest/doctest/issues/7) +- UNIX line feedings on GitHub please [\#6](https://github.com/doctest/doctest/issues/6) + +**Merged pull requests:** + +- don't show green when tests fail [\#26](https://github.com/doctest/doctest/pull/26) ([ferkulat](https://github.com/ferkulat)) +- Include "program code" in example [\#15](https://github.com/doctest/doctest/pull/15) ([martinmoene](https://github.com/martinmoene)) + +## [1.0.0](https://github.com/doctest/doctest/tree/1.0.0) (2016-05-22) +**Merged pull requests:** + +- Reduce the header size for test users [\#3](https://github.com/doctest/doctest/pull/3) ([zah](https://github.com/zah)) +- Add a Gitter chat badge to README.md [\#1](https://github.com/doctest/doctest/pull/1) ([gitter-badger](https://github.com/gitter-badger)) + + + +\* *This Change Log was automatically generated by [github_changelog_generator](https://github.com/skywinder/Github-Changelog-Generator)* \ No newline at end of file diff --git a/dmff/dpnblist/external/doctest-2.4.11/CMakeLists.txt b/dmff/dpnblist/external/doctest-2.4.11/CMakeLists.txt new file mode 100644 index 00000000..6d384fa9 --- /dev/null +++ b/dmff/dpnblist/external/doctest-2.4.11/CMakeLists.txt @@ -0,0 +1,168 @@ +cmake_minimum_required(VERSION 3.0) + +if(POLICY CMP0077) + cmake_policy(SET CMP0077 NEW) +endif() + +################################################################################ +## DOCTEST +################################################################################ + +file(READ ${CMAKE_CURRENT_SOURCE_DIR}/scripts/version.txt ver) +project(doctest VERSION ${ver} LANGUAGES CXX) + +# Determine if doctest is built as a subproject (using add_subdirectory) or if it is the main project. +set(MAIN_PROJECT OFF) +if(CMAKE_CURRENT_SOURCE_DIR STREQUAL CMAKE_SOURCE_DIR) + set(MAIN_PROJECT ON) +endif() + +option(DOCTEST_WITH_TESTS "Build tests/examples" ${MAIN_PROJECT}) +option(DOCTEST_WITH_MAIN_IN_STATIC_LIB "Build a static lib (cmake target) with a default main entry point" ON) +option(DOCTEST_NO_INSTALL "Skip the installation process" OFF) +option(DOCTEST_USE_STD_HEADERS "Use std headers" OFF) + +add_library(${PROJECT_NAME} INTERFACE) +add_library(${PROJECT_NAME}::${PROJECT_NAME} ALIAS ${PROJECT_NAME}) + +if(NOT CMAKE_VERSION VERSION_LESS 3.8) + target_compile_features(${PROJECT_NAME} INTERFACE cxx_std_11) +endif() + +set(doctest_parts_folder "${CMAKE_CURRENT_SOURCE_DIR}/doctest/parts") +set(doctest_folder "${CMAKE_CURRENT_SOURCE_DIR}/") # in order to have the mpi extension files, not included into the doctest.h single header + +if(MAIN_PROJECT) + # use a special hidden version of the header which directly includes the 2 parts - proper reporting of file/line locations during dev + target_include_directories(${PROJECT_NAME} INTERFACE + $ + $ + $) + + # add a custom target that assembles the single header when any of the parts are touched + add_custom_command( + OUTPUT ${CMAKE_CURRENT_SOURCE_DIR}/doctest/doctest.h + DEPENDS + ${doctest_parts_folder}/doctest_fwd.h + ${doctest_parts_folder}/doctest.cpp + COMMAND ${CMAKE_COMMAND} -P ${CMAKE_CURRENT_SOURCE_DIR}/scripts/cmake/assemble_single_header.cmake + COMMENT "assembling the single header") + + add_custom_target(assemble_single_header ALL DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/doctest/doctest.h) +else() + target_include_directories(${PROJECT_NAME} INTERFACE $) +endif() + +if(CMAKE_BUILD_TYPE STREQUAL "Debug") + if (CMAKE_CXX_COMPILER_ID STREQUAL "Clang") + if (NOT WIN32) + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -gdwarf-4 ") + endif() + endif() +endif() + +# hack to support building on XCode 6 and 7 - propagate the definition to everything +if(DEFINED DOCTEST_THREAD_LOCAL) + target_compile_definitions(${PROJECT_NAME} INTERFACE + DOCTEST_THREAD_LOCAL=${DOCTEST_THREAD_LOCAL}) +endif() + +if(DOCTEST_USE_STD_HEADERS) + target_compile_definitions(${PROJECT_NAME} INTERFACE DOCTEST_CONFIG_USE_STD_HEADERS) +endif() + +################################################################################ +## TESTS/EXAMPLES/HELPERS +################################################################################ + +if(${DOCTEST_WITH_MAIN_IN_STATIC_LIB}) + add_library(${PROJECT_NAME}_with_main STATIC EXCLUDE_FROM_ALL ${doctest_parts_folder}/doctest.cpp) + add_library(${PROJECT_NAME}::${PROJECT_NAME}_with_main ALIAS ${PROJECT_NAME}_with_main) + target_compile_definitions(${PROJECT_NAME}_with_main PRIVATE + DOCTEST_CONFIG_IMPLEMENT_WITH_MAIN) + set_target_properties(${PROJECT_NAME}_with_main PROPERTIES CXX_STANDARD 11 CXX_STANDARD_REQUIRED ON) + target_link_libraries(${PROJECT_NAME}_with_main PUBLIC ${PROJECT_NAME}) +endif() + +if(MAIN_PROJECT AND DOCTEST_WITH_TESTS) + include(scripts/cmake/common.cmake) + + add_subdirectory(examples/all_features) + add_subdirectory(examples/exe_with_static_libs) + add_subdirectory(examples/executable_dll_and_plugin) + add_subdirectory(examples/combining_the_same_tests_built_differently_in_multiple_shared_objects) + add_subdirectory(scripts/playground) + add_subdirectory(examples/mpi) +endif() + +################################################################################ +## PACKAGE SUPPORT +################################################################################ + +set(generated_dir "${CMAKE_CURRENT_BINARY_DIR}/generated") + +if(CMAKE_SYSTEM_NAME STREQUAL Linux) + include(GNUInstallDirs) + set(include_install_dir ${CMAKE_INSTALL_INCLUDEDIR}) + set(config_install_dir "${CMAKE_INSTALL_LIBDIR}/cmake/${PROJECT_NAME}") +else() + set(include_install_dir "include") + set(config_install_dir "lib/cmake/${PROJECT_NAME}") +endif() + + +set(version_config "${generated_dir}/${PROJECT_NAME}ConfigVersion.cmake") +set(project_config "${generated_dir}/${PROJECT_NAME}Config.cmake") +set(targets_export_name "${PROJECT_NAME}Targets") +set(namespace "${PROJECT_NAME}::") + +include(CMakePackageConfigHelpers) + +# CMake automatically adds an architecture compatibility check to make sure +# 32 and 64 bit code is not accidentally mixed. For a header-only library this +# is not required. The check can be disabled by temporarily unsetting +# CMAKE_SIZEOF_VOID_P. In CMake 3.14 and later this can be achieved more cleanly +# with write_basic_package_version_file(ARCH_INDEPENDENT). +# TODO: Use this once a newer CMake can be required. +set(DOCTEST_SIZEOF_VOID_P ${CMAKE_SIZEOF_VOID_P}) +unset(CMAKE_SIZEOF_VOID_P) +write_basic_package_version_file( + "${version_config}" VERSION ${PROJECT_VERSION} COMPATIBILITY SameMajorVersion +) +set(CMAKE_SIZEOF_VOID_P ${DOCTEST_SIZEOF_VOID_P}) + +configure_file("scripts/cmake/Config.cmake.in" "${project_config}" @ONLY) + +if(NOT ${DOCTEST_NO_INSTALL}) + install( + TARGETS ${PROJECT_NAME} + EXPORT "${targets_export_name}" + INCLUDES DESTINATION "${include_install_dir}" + ) + + install( + FILES "doctest/doctest.h" + DESTINATION "${include_install_dir}/doctest" + ) + install( + DIRECTORY "doctest/extensions" + DESTINATION "${include_install_dir}/doctest" + FILES_MATCHING PATTERN "*.h" + ) + + install( + FILES "${project_config}" "${version_config}" + DESTINATION "${config_install_dir}" + ) + + install( + FILES "scripts/cmake/doctest.cmake" "scripts/cmake/doctestAddTests.cmake" + DESTINATION "${config_install_dir}" + ) + + install( + EXPORT "${targets_export_name}" + NAMESPACE "${namespace}" + DESTINATION "${config_install_dir}" + ) +endif() diff --git a/dmff/dpnblist/external/doctest-2.4.11/CONTRIBUTING.md b/dmff/dpnblist/external/doctest-2.4.11/CONTRIBUTING.md new file mode 100644 index 00000000..b955dffe --- /dev/null +++ b/dmff/dpnblist/external/doctest-2.4.11/CONTRIBUTING.md @@ -0,0 +1,30 @@ +## Contributing + +This library is free, and will stay free but needs your support to sustain its development. There are lots of [**new features**](https://github.com/doctest/doctest/issues/600) and maintenance to do. If you work for a company using **doctest** or have the means to do so, please consider financial support. + +[](https://www.patreon.com/onqtam) +[](https://www.paypal.me/onqtam/10) + +## Pull requests + +Consider opening an issue for a discussion before making a pull request to make sure the contribution goes smoothly. + +All pull requests should be made against the ```dev``` branch because the ```master``` is the stable one with the latest release. + +If you're going to change something in the library itself - make sure you don't modify ```doctest/doctest.h``` because it's generated from ```doctest/parts/doctest_fwd.h``` and ```doctest/parts/doctest.cpp``` - they get concatenated by CMake - so make sure you do a CMake build after you modify them so the ```assemble_single_header``` target gets built. Also take into consideration how the change affects the code coverage - based on the project in ```examples/all_features```. Also update any relevant examples in the ```examples``` folder. + +This framework has some design goals which must be kept. Make sure you have read the [**features and design goals**](doc/markdown/features.md) page. + +If your changes also change the output of the library - you should also update the reference output for the tests or otherwise the CI builds will fail when they compare the latest output to the outdated reference output (which is committed in the repository). To do this run CMake with the ```DOCTEST_TEST_MODE``` variable set to ```COLLECT``` (making the new reference output) and then run ```ctest``` and commit the changed (or newly created) ```.txt``` files in the ```test_output``` folders too. The default ```DOCTEST_TEST_MODE``` is ```COMPARE```. + +Example: ```cmake -DDOCTEST_TEST_MODE=COLLECT path/to/sources && cmake --build . && ctest``` + +Code should be formatted with a recent-enough ```clang-format``` using the config file in the root of the repo (or I will do it...) + +Testing with compilers different from GCC/Clang/MSVC (and more platforms) is something the project would benefit from. + +--------------- + +[Home](readme.md#reference) + +

diff --git a/dmff/dpnblist/external/doctest-2.4.11/LICENSE.txt b/dmff/dpnblist/external/doctest-2.4.11/LICENSE.txt new file mode 100644 index 00000000..5ae0eb10 --- /dev/null +++ b/dmff/dpnblist/external/doctest-2.4.11/LICENSE.txt @@ -0,0 +1,21 @@ +The MIT License (MIT) + +Copyright (c) 2016-2023 Viktor Kirilov + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. diff --git a/dmff/dpnblist/external/doctest-2.4.11/README.md b/dmff/dpnblist/external/doctest-2.4.11/README.md new file mode 100644 index 00000000..eb5a5906 --- /dev/null +++ b/dmff/dpnblist/external/doctest-2.4.11/README.md @@ -0,0 +1,137 @@ +

+ + + + + + + + + + + + + +
+ master branch + + + + +
+ dev branch + + + + +
+
+ +**doctest** is a new C++ testing framework but is by far the fastest both in compile times (by [**orders of magnitude**](doc/markdown/benchmarks.md)) and runtime compared to other feature-rich alternatives. It brings the ability of compiled languages such as [**D**](https://dlang.org/spec/unittest.html) / [**Rust**](https://doc.rust-lang.org/book/second-edition/ch11-00-testing.html) / [**Nim**](https://nim-lang.org/docs/unittest.html) to have tests written directly in the production code thanks to a fast, transparent and flexible test runner with a clean interface. + +[![Standard](https://img.shields.io/badge/c%2B%2B-11/14/17/20-blue.svg)](https://en.wikipedia.org/wiki/C%2B%2B#Standardization) +[![License](https://img.shields.io/badge/license-MIT-blue.svg)](https://opensource.org/licenses/MIT) +[![download](https://img.shields.io/badge/download%20%20-link-blue.svg)](https://raw.githubusercontent.com/doctest/doctest/master/doctest/doctest.h) +[![CII Best Practices](https://bestpractices.coreinfrastructure.org/projects/503/badge)](https://bestpractices.coreinfrastructure.org/projects/503) +[![Chat - Discord](https://img.shields.io/badge/chat-Discord-blue.svg)](https://discord.gg/PGXn9YmyF3) +[![Try it online](https://img.shields.io/badge/try%20it-online-orange.svg)](https://godbolt.org/z/4s389Kbfs) + + +[](https://www.patreon.com/onqtam) + +The framework is and will stay free but needs your support to sustain its development. There are lots of new features and maintenance to do. If you work for a company using **doctest** or have the means to do so, please consider financial support. Monthly donations via Patreon and one-offs via PayPal. + +[](https://www.paypal.me/onqtam/10) + +A complete example with a self-registering test that compiles to an executable looks like this: + +![cover-example](scripts/data/using_doctest_888px_wide.gif) + +There are many C++ testing frameworks - [Catch](https://github.com/catchorg/Catch2), [Boost.Test](http://www.boost.org/doc/libs/1_64_0/libs/test/doc/html/index.html), [UnitTest++](https://github.com/unittest-cpp/unittest-cpp), [cpputest](https://github.com/cpputest/cpputest), [googletest](https://github.com/google/googletest) and [others](https://en.wikipedia.org/wiki/List_of_unit_testing_frameworks#C.2B.2B). + +The **key** differences between it and other testing frameworks are that it is light and unintrusive: +- Ultra light on compile times both in terms of [**including the header**](doc/markdown/benchmarks.md#cost-of-including-the-header) and writing [**thousands of asserts**](doc/markdown/benchmarks.md#cost-of-an-assertion-macro) +- Doesn't produce any warnings even on the [**most aggressive**](scripts/cmake/common.cmake#L84) warning levels for **MSVC**/**GCC**/**Clang** +- Can remove **everything** testing-related from the binary with the [**```DOCTEST_CONFIG_DISABLE```**](doc/markdown/configuration.md#doctest_config_disable) identifier +- [**thread-safe**](doc/markdown/faq.md#is-doctest-thread-aware) - asserts can be used from multiple threads spawned from a single test case - [**example**](examples/all_features/concurrency.cpp) +- asserts can be used [**outside of a testing context**](doc/markdown/assertions.md#using-asserts-out-of-a-testing-context) - as a general purpose assert library - [**example**](examples/all_features/asserts_used_outside_of_tests.cpp) +- No global namespace pollution (everything is in ```doctest::```) & doesn't drag **any** headers with it +- [**Portable**](doc/markdown/features.md#extremely-portable) C++11 (use tag [**1.2.9**](https://github.com/doctest/doctest/tree/1.2.9) for C++98) with over 100 different CI builds (static analysis, sanitizers..) +- binaries (exe/dll) can use the test runner of another binary => tests in a single registry - [**example**](examples/executable_dll_and_plugin/) + +![cost-of-including-the-framework-header](scripts/data/benchmarks/header.png) + +This allows the framework to be used in more ways than any other - tests can be written directly in the production code! + +*Tests can be a form of documentation and should be able to reside near the production code which they test.* + +- This makes the barrier for writing tests **much lower** - you don't have to: **1)** make a separate source file **2)** include a bunch of stuff in it **3)** add it to the build system and **4)** add it to source control - You can just write the tests for a class or a piece of functionality at the bottom of its source file - or even header file! +- Tests in the production code can be thought of as documentation/up-to-date comments - showcasing the APIs +- Testing internals that are not exposed through the public API and headers is no longer a mind-bending exercise +- [**Test-driven development**](https://en.wikipedia.org/wiki/Test-driven_development) in C++ has never been easier! + +The framework can be used just like any other without mixing production code and tests - check out the [**features**](doc/markdown/features.md). + +**doctest** is modeled after [**Catch**](https://github.com/catchorg/Catch2) and some parts of the code have been taken directly - check out [**the differences**](doc/markdown/faq.md#how-is-doctest-different-from-catch). + +[This table](https://github.com/martinmoene/catch-lest-other-comparison) compares **doctest** / [**Catch**](https://github.com/catchorg/Catch2) / [**lest**](https://github.com/martinmoene/lest) which are all very similar. + +Checkout the [**CppCon 2017 talk**](https://cppcon2017.sched.com/event/BgsI/mix-tests-and-production-code-with-doctest-implementing-and-using-the-fastest-modern-c-testing-framework) on [**YouTube**](https://www.youtube.com/watch?v=eH1CxEC29l8) to get a better understanding of how the framework works and read about how to use it in [**the JetBrains article**](https://blog.jetbrains.com/rscpp/better-ways-testing-with-doctest/) - highlighting the unique aspects of the framework! On a short description on how to use the framework along production code you could refer to [**this GitHub issue**](https://github.com/doctest/doctest/issues/252). There is also an [**older article**](https://accu.org/var/uploads/journals/Overload137.pdf) in the february edition of ACCU Overload 2017. + +[![CppCon 2017 talk about doctest on youtube](scripts/data/youtube-cppcon-talk-thumbnail.png)](https://www.youtube.com/watch?v=eH1CxEC29l8) + +Documentation +------------- + +Project: + +- [Features and design goals](doc/markdown/features.md) - the complete list of features +- [Community driven roadmap](https://github.com/doctest/doctest/issues/600) - upcoming features +- [Benchmarks](doc/markdown/benchmarks.md) - compile-time and runtime supremacy +- [Contributing](CONTRIBUTING.md) - how to make a proper pull request +- [Changelog](CHANGELOG.md) - generated changelog based on closed issues/PRs + +Usage: + +- [Tutorial](doc/markdown/tutorial.md) - make sure you have read it before the other parts of the documentation +- [Assertion macros](doc/markdown/assertions.md) +- [Test cases, subcases and test fixtures](doc/markdown/testcases.md) +- [Parameterized test cases](doc/markdown/parameterized-tests.md) +- [Command line](doc/markdown/commandline.md) +- [Logging macros](doc/markdown/logging.md) +- [```main()``` entry point](doc/markdown/main.md) +- [Configuration](doc/markdown/configuration.md) +- [String conversions](doc/markdown/stringification.md) +- [Reporters](doc/markdown/reporters.md) +- [Extensions](doc/markdown/extensions.md) +- [FAQ](doc/markdown/faq.md) +- [Build systems](doc/markdown/build-systems.md) +- [Examples](examples) + +Contributing +------------ + +[](https://www.patreon.com/onqtam) + +Support the development of the project with donations! There is a list of planned features which are all important and big - see the [**roadmap**](https://github.com/doctest/doctest/issues/600). + +[](https://www.paypal.me/onqtam/10) + +If you work for a company using **doctest** or have the means to do so, please consider financial support. + +Contributions in the form of issues and pull requests are welcome as well - check out the [**Contributing**](CONTRIBUTING.md) page. + +Stargazers over time +------------ + +[![Stargazers over time](https://starchart.cc/doctest/doctest.svg)](https://starchart.cc/doctest/doctest) + +Logo +------------ + +The [logo](scripts/data/logo) is licensed under a Creative Commons Attribution 4.0 International License. Copyright © 2019 [area55git](https://github.com/area55git)   [![License: CC BY 4.0](https://licensebuttons.net/l/by/4.0/80x15.png)](https://creativecommons.org/licenses/by/4.0/) + +

diff --git a/dmff/dpnblist/external/doctest-2.4.11/WORKSPACE b/dmff/dpnblist/external/doctest-2.4.11/WORKSPACE new file mode 100644 index 00000000..e69de29b diff --git a/dmff/dpnblist/external/doctest-2.4.11/doc/markdown/assertions.md b/dmff/dpnblist/external/doctest-2.4.11/doc/markdown/assertions.md new file mode 100644 index 00000000..610c1a2d --- /dev/null +++ b/dmff/dpnblist/external/doctest-2.4.11/doc/markdown/assertions.md @@ -0,0 +1,192 @@ +## Assertion macros + +Most test frameworks have a large collection of assertion macros to capture all possible conditional forms (```_EQUALS```, ```_NOTEQUALS```, ```_GREATER_THAN``` etc). + +**doctest** is different (but it's like [**Catch**](https://github.com/catchorg/Catch2) in this regard). Because it decomposes comparison expressions most of these forms are reduced to one or two that you will use all the time. That said, there is a rich set of auxiliary macros as well. + +There are 3 levels of assert severity for all assertion macros: + +- ```REQUIRE``` - this level will immediately quit the test case if the assert fails and will mark the test case as failed. +- ```CHECK``` - this level will mark the test case as failed if the assert fails but will continue with the test case. +- ```WARN``` - this level will only print a message if the assert fails but will not mark the test case as failed. + +The ```CHECK``` level is mostly useful if you have a series of essentially orthogonal assertions and it is useful to see all the results rather than stopping at the first failure. + +All asserts evaluate the expressions only once and if they fail - the values are [**stringified**](stringification.md) properly. + +Since **doctest** is [**thread-safe**](faq.md#is-doctest-thread-aware) all asserts and [**logging**](logging.md) macros can be used in threads spawned from test cases. + +Note that the ```REQUIRE``` level of asserts uses exceptions to end the current test case. It might be dangerous to use this level of asserts inside destructors of user-defined classes - if a destructor is called during stack unwinding due to an exception and a ```REQUIRE``` assert fails then the program will terminate. Also since C++11 all destructors are by default ```noexcept(true)``` unless specified otherwise so such an assert will lead to ```std::terminate()``` being called. + +## Expression decomposing asserts + +These are of the form ```CHECK(expression)``` (Same for ```REQUIRE``` and ```WARN```). + +```expression``` can be a binary comparison like ```a == b``` or just a single thing like ```vec.isEmpty()```. + +If an exception is thrown it is caught, reported, and counted as a failure (unless the assert is of level ```WARN```). + +Examples: + +```c++ +CHECK(flags == state::alive | state::moving); +CHECK(thisReturnsTrue()); +REQUIRE(i < 42); +``` + +- Negating asserts - ```_FALSE(expression)``` - evaluates the expression and records the _logical NOT_ of the result. + +These forms exist as a workaround for the fact that ```!``` prefixed expressions cannot be decomposed properly. + +Example: + +```c++ +REQUIRE_FALSE(thisReturnsFalse()); +``` + +- Using the [**```DOCTEST_CONFIG_SUPER_FAST_ASSERTS```**](configuration.md#doctest_config_super_fast_asserts) config option can make compilation of asserts up to [**31-63%**](benchmarks.md#cost-of-an-assertion-macro) faster! +- These asserts also have a ```_MESSAGE``` form - like ```CHECK_MESSAGE(expression, message)``` which is basically a code block ```{}``` with a scoped [**```INFO()```**](logging.md#info) logging macro together with the ```CHECK``` macro - that way the message will be relevant only to that assert. The binary/unary asserts don't have this variation yet. + +Examples: + +```c++ +INFO("this is relevant to all asserts, and here is some var: ", local); + +CHECK_MESSAGE(a < b, "relevant only to this assert ", other_local, " more text!"); + +CHECK(b < c); // here only the first INFO() will be relevant +``` + +For more information about the ```INFO()``` macro visit the [logging page](logging.md). + +## Binary and unary asserts + +These asserts don't use templates to decompose the comparison expressions for the left and right parts. + +These have the same guarantees as the expression decomposing ones but [**57-68% faster**](benchmarks.md#cost-of-an-assertion-macro) for compilation. + +`````` is one of 3 possible: ```REQUIRE```/```CHECK```/```WARN```. + +- ```_EQ(left, right)``` - same as ```(left == right)``` +- ```_NE(left, right)``` - same as ```(left != right)``` +- ```_GT(left, right)``` - same as ```(left > right)``` +- ```_LT(left, right)``` - same as ```(left < right)``` +- ```_GE(left, right)``` - same as ```(left >= right)``` +- ```_LE(left, right)``` - same as ```(left <= right)``` +- ```_UNARY(expr)``` - same as ```(expr)``` +- ```_UNARY_FALSE(expr)``` - same as ```_FALSE(expr)``` + +Using the [**```DOCTEST_CONFIG_SUPER_FAST_ASSERTS```**](configuration.md#doctest_config_super_fast_asserts) config option can make the binary asserts to compile up to [**84-91%**](benchmarks.md#cost-of-an-assertion-macro) faster! + +## Exceptions + +`````` is one of 3 possible: ```REQUIRE```/```CHECK```/```WARN```. + +- ```_THROWS(expression)``` + +Expects that an exception (of any type) is thrown during evaluation of the expression. + +- ```_THROWS_AS(expression, exception_type)``` + +Expects that an exception of the _specified type_ is thrown during evaluation of the expression. + +Note that ```const``` and ```&``` are added to the exception type if missing (users shouldn't care) - the standard practice for exceptions in C++ is ```Throw by value, catch by (const) reference```. + +```c++ +CHECK_THROWS_AS(func(), const std::exception&); +CHECK_THROWS_AS(func(), std::exception); // same as above +``` + +- ```_THROWS_WITH(expression, c_string)``` + +Expects that an exception is thrown during evaluation of the expression and is successfully translated to the _specified c string_ (see [**translating exceptions**](stringification.md#translating-exceptions)). + +```c++ +CHECK_THROWS_WITH(func(), "invalid operation!"); +``` + +- ```_THROWS_WITH_AS(expression, c_string, exception_type)``` + +This is a combination of ```_THROWS_WITH``` and ```_THROWS_AS```. + +```c++ +CHECK_THROWS_WITH_AS(func(), "invalid operation!", std::runtime_error); +``` + +- ```_NOTHROW(expression)``` + +Expects that no exception is thrown during evaluation of the expression. + +Note that these asserts also have a ```_MESSAGE``` form - like ```CHECK_THROWS_MESSAGE(expression, message)``` - these work identically to the ```_MESSAGE``` form of the normal macros (```CHECK_MESSAGE(a < b, "this shouldn't fail")```) described earlier. + +Also note that a singular expression is expected, this means either a function call, an IIFE (immediately invoked function expressions) like `[&]() { throw 1; }()` (note the `()` at the end) or something comparable. Passing in a function or lambda by itself will **not** work. + +One may use the [**```DOCTEST_CONFIG_VOID_CAST_EXPRESSIONS```**](configuration.md#doctest_config_void_cast_expressions) config identifier to cast the expression in these asserts to void to avoid warnings or other issues - for example nodiscard statements whose result isn't checked. This will however limit the ability to write entire ```{}``` blocks of code as the expression (or multiple statements) but in that case a simple lambda can be used. This should have been the default behavior from day 1 of the framework... + +## Using asserts out of a testing context + +Asserts can be used outside of a testing context (in code not called from a ```TEST_CASE()```) instead of [```assert()```](https://en.cppreference.com/w/cpp/error/assert). + +A ```doctest::Context``` object still has to be created somewhere and set as the default one using the ```setAsDefaultForAssertsOutOfTestCases()``` method - and then asserts will work. A handler can be registered by calling the ```setAssertHandler()``` method on the context object. If no handler is set then ```std::abort()``` is called on failure. + +The results would be best when using the [**```DOCTEST_CONFIG_SUPER_FAST_ASSERTS```**](configuration.md#doctest_config_super_fast_asserts) config identifier. + +Checkout the [**example**](../../examples/all_features/asserts_used_outside_of_tests.cpp) showcasing how that is done. For more information see the [**issue for the feature request**](https://github.com/doctest/doctest/issues/114). + +Currently [**logging macros**](logging.md) cannot be used for extra context for asserts outside of a test run. That means that the ```_MESSAGE``` variants of asserts are also not usable - since they are just a packed ```INFO()``` with an assert right after it. + +## String containment + +```doctest::Contains``` can be used to check whether the string passed to its constructor is contained within the string it is compared with. Here's a simple example: + +```c++ +REQUIRE("foobar" == doctest::Contains("foo")); +``` + +It can also be used with the ```THROWS_WITH``` family of assertion macros to check whether the thrown exception [translated to a string](stringification.md#translating-exceptions) contains the provided string. Here's another example: +```c++ +REQUIRE_THROWS_WITH(func(), doctest::Contains("Oopsie")); +``` + +## Floating point comparisons + +When comparing floating point numbers - especially if at least one of them has been computed - great care must be taken to allow for rounding errors and inexact representations. + +**doctest** provides a way to perform tolerant comparisons of floating point values through the use of a wrapper class called ```doctest::Approx```. ```doctest::Approx``` can be used on either side of a comparison expression. It overloads the comparisons operators to take a relative tolerance into account. Here's a simple example: + +```c++ +REQUIRE(performComputation() == doctest::Approx(2.1)); +``` + +By default a small epsilon value (relative - in percentages) is used that covers many simple cases of rounding errors. When this is insufficient the epsilon value (the amount within which a difference either way is ignored) can be specified by calling the ```epsilon()``` method on the ```doctest::Approx``` instance. e.g.: + +```c++ +REQUIRE(22.0/7 == doctest::Approx(3.141).epsilon(0.01)); // allow for a 1% error +``` + +When dealing with very large or very small numbers it can be useful to specify a scale, which can be achieved by calling the ```scale()``` method on the ```doctest::Approx``` instance. + +## NaN checking + +Two NaN floating point numbers do not compare equal to each other. This makes it quite inconvenient to check for NaN while capturing the value. +```c++ +CHECK(std::isnan(performComputation()); // does not capture the result of the call +``` + +**doctest** provides `doctest::IsNaN` which can be used in assertions to check if a float (or any other floating point fundamental type) is indeed NaN, outputting the actual value if it is not. +```c++ +CHECK(doctest::IsNaN(performComputation()); // captures the result! +``` + +`IsNaN` is able to capture the value, even if negated via `!`. + +-------- + +- Check out the [**example**](../../examples/all_features/assertion_macros.cpp) which shows many of these macros +- Do not wrap assertion macros in ```try```/```catch``` - the REQUIRE macros throw exceptions to end the test case execution! + +--------------- + +[Home](readme.md#reference) + +

diff --git a/dmff/dpnblist/external/doctest-2.4.11/doc/markdown/benchmarks.md b/dmff/dpnblist/external/doctest-2.4.11/doc/markdown/benchmarks.md new file mode 100644 index 00000000..a28b370b --- /dev/null +++ b/dmff/dpnblist/external/doctest-2.4.11/doc/markdown/benchmarks.md @@ -0,0 +1,202 @@ +# Benchmarks + +The benchmarks are done with [**this**](../../scripts/bench/bench.py) script using CMake. There are 3 benchmarking scenarios: + +- [the cost of including the header](#cost-of-including-the-header) +- [the cost of an assertion macro](#cost-of-an-assertion-macro) +- [runtime speed of lots of asserts](#runtime-benchmarks) + +Compilers used: + +- WINDOWS: Microsoft Visual Studio Community 2017 - Version 15.8.1+28010.2003 +- WINDOWS: gcc 8.1.0 (x86_64-posix-seh-rev0, Built by MinGW-W64 project) +- LINUX: gcc 6.3.0 20170406 (Ubuntu 6.3.0-12ubuntu2) +- LINUX: clang 4.0.0-1 (tags/RELEASE_400/rc1) Target: x86_64-pc-linux-gnu + +Environment used (Intel i7 3770k, 16g RAM): + +- Windows 7 - on an SSD +- Ubuntu 17.04 in a VirtualBox VM - on a HDD + +**doctest** version: 2.2.0 (released on 2018.12.02) + +[**Catch**](https://github.com/catchorg/Catch2) version: 2.3.0 (released on 2018.07.22) + +# Compile time benchmarks + +## Cost of including the header + +This is a benchmark that is relevant only to single header and header only frameworks - like **doctest** and [**Catch**](https://github.com/catchorg/Catch2). + +The script generates 201 source files and in 200 of them makes a function in the form of ```int f135() { return 135; }``` and in ```main.cpp``` it forward declares all the 200 such dummy functions and accumulates their result to return from the ```main()``` function. This is done to ensure that all source files are built and that the linker doesn't remove/optimize anything. + +- **baseline** - how much time the source files need for a single threaded build with ```msbuild```/```make``` +- **+ implement** - only in ```main.cpp``` the header is included with a ```#define``` before it so the test runner gets implemented: + +```c++ +#define DOCTEST_CONFIG_IMPLEMENT_WITH_MAIN +#include "doctest.h" +``` +- **+ header everywhere** - the framework header is also included in all the other source files +- **+ disabled** - remove everything testing-related from the binary + +| doctest | baseline | + implement | + header everywhere | + disabled | +|---------------------|----------|-------------|---------------------|------------| +| MSVC Debug | 4.89 | 6.21 | 8.33 | 6.39 | +| MSVC Release | 4.38 | 6.39 | 8.71 | 6.02 | +| MinGW GCC Debug | 8.12 | 10.86 | 14.73 | 10.17 | +| MinGW GCC Release | 8.21 | 11.11 | 15.03 | 10.71 | +| Linux GCC Debug | 4.20 | 6.23 | 9.81 | 6.24 | +| Linux GCC Release | 4.29 | 6.93 | 11.05 | 6.76 | +| Linux Clang Debug | 8.70 | 10.02 | 14.43 | 11.13 | +| Linux Clang Release | 9.30 | 11.68 | 16.20 | 11.58 | + +| Catch | baseline | + implement | + header everywhere | + disabled | +|---------------------|----------|-------------|---------------------|------------| +| MSVC Debug | 4.82 | 7.83 | 88.85 | 88.72 | +| MSVC Release | 4.38 | 9.97 | 87.17 | 88.35 | +| MinGW GCC Debug | 8.00 | 57.28 | 137.28 | 132.73 | +| MinGW GCC Release | 8.38 | 22.94 | 97.17 | 97.22 | +| Linux GCC Debug | 4.42 | 15.57 | 97.94 | 97.18 | +| Linux GCC Release | 4.50 | 19.59 | 99.48 | 100.75 | +| Linux Clang Debug | 8.76 | 15.60 | 107.99 | 110.61 | +| Linux Clang Release | 9.32 | 25.75 | 118.67 | 117.11 | + + + + +### Conclusion + +#### doctest + +- instantiating the test runner in one source file costs ~1-3 seconds ```implement - baseline``` +- the inclusion of ```doctest.h``` in one source file costs between 11ms - 23ms ```(header_everywhere - implement) / 200``` +- including the library everywhere but everything disabled costs around 2 seconds ```disabled - baseline``` for 200 files + +#### [Catch](https://github.com/catchorg/Catch2) + +- instantiating the test runner in one source file costs ~3-50 seconds ```implement - baseline``` +- the inclusion of ```catch.hpp``` in one source file costs between 380ms - 470ms ```(header_everywhere - implement) / 200``` +- using the config option to disable the library (**```CATCH_CONFIG_DISABLE```**) has no effect on the header cost + +---------- + +So if ```doctest.h``` costs 11ms and ```catch.hpp``` costs 400ms on MSVC - then the **doctest** header is >> **36** << times lighter (for MSVC)! + +---------- + +The results are in seconds and are in **no way** intended to bash [**Catch**](https://github.com/catchorg/Catch2) - the **doctest** framework wouldn't exist without it. + +The reason the **doctest** header is so light on compile times is because it forward declares everything and doesn't drag any headers in the source files (except for the source file where the test runner gets implemented). This was a key design decision. + +## Cost of an assertion macro + +The script generates 11 ```.cpp``` files and in 10 of them makes 50 test cases with 100 asserts in them (of the form ```CHECK(a==b)``` where ```a``` and ```b``` are always the same ```int``` variables) - **50k** asserts! The testing framework gets implemented in ```main.cpp```. + +- **baseline** - how much time a single threaded build takes with the header included everywhere - no test cases or asserts! +- ```CHECK(a==b)``` - will add ```CHECK()``` asserts which decompose the expression with template machinery + +**doctest** specific: + +- **+fast 1** - will add [**```DOCTEST_CONFIG_SUPER_FAST_ASSERTS```**](configuration.md#doctest_config_super_fast_asserts) to speed up the compilation of the normal asserts ```CHECK(a==b)``` +- ```CHECK_EQ(a,b)``` - will use ```CHECK_EQ(a,b)``` instead of the expression decomposing ones +- **+fast 2** - will add [**```DOCTEST_CONFIG_SUPER_FAST_ASSERTS```**](configuration.md#doctest_config_super_fast_asserts) to speed up the compilation of the binary asserts ```CHECK_EQ(a,b)``` +- **+disabled** - all test case and assert macros will be disabled with [**```DOCTEST_CONFIG_DISABLE```**](configuration.md#doctest_config_disable) + +[**Catch**](https://github.com/catchorg/Catch2) specific: + +- **+fast** - will add [**```CATCH_CONFIG_FAST_COMPILE```**](https://github.com/catchorg/Catch2/blob/master/docs/configuration.md#catch_config_fast_compile) which speeds up the compilation of the normal asserts ```CHECK(a==b)``` +- **+disabled** - all test case and assert macros will be disabled with **```CATCH_CONFIG_DISABLE```** + +| doctest | baseline | ```CHECK(a==b)``` | +fast 1 | ```CHECK_EQ(a,b)``` | +fast 2 | +disabled | +|---------------------|----------|-------------------|---------|---------------------|---------|-----------| +| MSVC Debug | 2.69 | 27.37 | 10.37 | 17.17 | 4.82 | 1.91 | +| MSVC Release | 3.15 | 58.73 | 20.73 | 26.07 | 6.43 | 1.83 | +| MinGW GCC Debug | 3.78 | 97.29 | 43.05 | 59.86 | 11.88 | 1.67 | +| MinGW GCC Release | 4.09 | 286.70 | 95.42 | 156.73 | 18.16 | 2.03 | +| Linux GCC Debug | 2.39 | 91.36 | 41.92 | 52.26 | 10.16 | 1.32 | +| Linux GCC Release | 3.29 | 257.40 | 97.46 | 128.84 | 19.38 | 1.79 | +| Linux Clang Debug | 2.40 | 85.52 | 43.53 | 51.24 | 8.32 | 1.62 | +| Linux Clang Release | 3.40 | 160.65 | 79.34 | 81.52 | 11.90 | 1.82 | + +And here is [**Catch**](https://github.com/catchorg/Catch2) which only has normal ```CHECK(a==b)``` asserts: + +| Catch | baseline | ```CHECK(a==b)``` | +fast | +disabled | +|---------------------|----------|-------------------|-------|-----------| +| MSVC Debug | 8.20 | 31.22 | 25.54 | 8.22 | +| MSVC Release | 10.13 | 448.68 | 168.67 | 10.20 | +| MinGW GCC Debug | 53.54 | 152.38 | 131.85 | 49.07 | +| MinGW GCC Release | 19.26 | 590.16 | 466.69 | 18.99 | +| Linux GCC Debug | 15.05 | 117.30 | 95.33 | 14.79 | +| Linux GCC Release | 18.77 | 608.94 | 482.73 | 18.96 | +| Linux Clang Debug | 12.27 | 94.39 | 77.33 | 12.11 | +| Linux Clang Release | 20.75 | 545.84 | 506.02 | 20.15 | + + + +### Conclusion + +**doctest**: + +- is between 0 and 8 times faster than [**Catch**](https://github.com/catchorg/Catch2) when using normal expression decomposing ```CHECK(a==b)``` asserts +- asserts of the form ```CHECK_EQ(a,b)``` with no expression decomposition - around 31-63% faster than ```CHECK(a==b)``` +- the [**```DOCTEST_CONFIG_SUPER_FAST_ASSERTS```**](configuration.md#doctest_config_super_fast_asserts) identifier makes the normal asserts faster by 57-68% +- the [**```DOCTEST_CONFIG_SUPER_FAST_ASSERTS```**](configuration.md#doctest_config_super_fast_asserts) identifier makes the binary asserts even faster by another 84-91% +- using the [**```DOCTEST_CONFIG_DISABLE```**](configuration.md#doctest_config_disable) identifier the asserts just disappear as if they were never written - even lower than the baseline (because most of the implementation is also gone) + +[**Catch**](https://github.com/catchorg/Catch2): + +- using [**```CATCH_CONFIG_FAST_COMPILE```**](https://github.com/catchorg/Catch2/blob/master/docs/configuration.md#catch_config_fast_compile) results in 10-30% faster build times for asserts (and in one case 73%). +- using the **```CATCH_CONFIG_DISABLE```** identifier provides the same great benefits for assert macros as the doctest version ([**```DOCTEST_CONFIG_DISABLE```**](configuration.md#doctest_config_disable)) - but not for the header cost + +## Runtime benchmarks + +The runtime benchmarks consist of a single test case with a loop of 10 million iterations performing the task - a single normal assert (using expression decomposition) or the assert + the logging of the loop iterator ```i```: + +```c++ +for(int i = 0; i < 10000000; ++i) + CHECK(i == i); +``` + +or + +```c++ +for(int i = 0; i < 10000000; ++i) { + INFO(i); + CHECK(i == i); +} +``` + +Note that the assert always passes - the goal should be to optimize for the common case - lots of passing test cases and a few that maybe fail. + +| doctest | assert | + info |                                 | Catch | assert | + info | +|---------------------|---------|---------|-|---------------------|---------|---------| +| MSVC Debug | 4.00 | 11.41 | | MSVC Debug | 5.60 | 213.91 | +| MSVC Release | 0.40 | 1.47 | | MSVC Release | 0.76 | 7.60 | +| MinGW GCC Debug | 1.05 | 2.93 | | MinGW GCC Debug | 1.17 | 9.54 | +| MinGW GCC Release | 0.34 | 1.27 | | MinGW GCC Release | 0.36 | 4.28 | +| Linux GCC Debug | 1.24 | 2.34 | | Linux GCC Debug | 1.44 | 9.69 | +| Linux GCC Release | 0.29 | 0.52 | | Linux GCC Release | 0.29 | 3.60 | +| Linux Clang Debug | 1.15 | 2.38 | | Linux Clang Debug | 1.21 | 9.91 | +| Linux Clang Release | 0.28 | 0.50 | | Linux Clang Release | 0.32 | 3.27 | + + + + +### Conclusion + +**doctest** is around ~20% faster than catch for asserts but a few times faster when also logging variables and context (and in the case of one particular compiler over 18 times faster). + +---------- + +The bar charts were generated using [**this google spreadsheet**](https://docs.google.com/spreadsheets/d/1p3MAURUfPzKT7gtJOVuJU2_yVKSqkoD1nbypA1K3618) by pasting the data from the tables. + +If you want a benchmark that is not synthetic - check out [**this blog post**](http://baptiste-wicht.com/posts/2016/09/blazing-fast-unit-test-compilation-with-doctest-11.html) of [**Baptiste Wicht**](https://github.com/wichtounet) who tested the compile times of the asserts in the 1.1 release with his [**Expression Templates Library**](https://github.com/wichtounet/etl)! + +While reading the post - keep in mind that if a part of a process takes 50% of the time and is made 10000 times faster - the overall process would still be only roughly 50% faster. + +--------------- + +[Home](readme.md#reference) + +

diff --git a/dmff/dpnblist/external/doctest-2.4.11/doc/markdown/build-systems.md b/dmff/dpnblist/external/doctest-2.4.11/doc/markdown/build-systems.md new file mode 100644 index 00000000..c4f292fb --- /dev/null +++ b/dmff/dpnblist/external/doctest-2.4.11/doc/markdown/build-systems.md @@ -0,0 +1,93 @@ +## Build systems + +The latest released version of doctest can be obtained from here: https://raw.githubusercontent.com/doctest/doctest/master/doctest/doctest.h + +You can substitute ```master``` with ```dev``` or a tag like ```v1.4.8``` for a specific version in the URL above. + +### CMake + +- **doctest** is easiest to use as a single file inside your own repository. Then the following minimal example will work: + +```cmake +cmake_minimum_required(VERSION 3.0) +project(cmake_test VERSION 0.0.1 LANGUAGES CXX) + +# Prepare doctest for other targets to use +find_package(doctest REQUIRED) + +# Make test executable +add_executable(tests main.cpp) +target_compile_features(tests PRIVATE cxx_std_17) +target_link_libraries(tests PRIVATE doctest::doctest) +``` + +- You can also use the following CMake snippet to automatically fetch the entire **doctest** repository from github and configure it as an external project: + +```cmake +include(ExternalProject) +find_package(Git REQUIRED) + +ExternalProject_Add( + doctest + PREFIX ${CMAKE_BINARY_DIR}/doctest + GIT_REPOSITORY https://github.com/doctest/doctest.git + TIMEOUT 10 + UPDATE_COMMAND ${GIT_EXECUTABLE} pull + CONFIGURE_COMMAND "" + BUILD_COMMAND "" + INSTALL_COMMAND "" + LOG_DOWNLOAD ON +) + +# Expose required variable (DOCTEST_INCLUDE_DIR) to parent scope +ExternalProject_Get_Property(doctest source_dir) +set(DOCTEST_INCLUDE_DIR ${source_dir}/doctest CACHE INTERNAL "Path to include folder for doctest") +``` + +And later you'll be able to use the doctest include directory like this: + +```cmake +# add it globally +include_directories(${DOCTEST_INCLUDE_DIR}) + +# or per target +target_include_directories(my_target PUBLIC ${DOCTEST_INCLUDE_DIR}) +``` + +- If you have the entire doctest repository available (as a submodule or just as files) you could also include it in your CMake build by using ```add_subdirectory(path/to/doctest)``` and then you could use it like this: + +```cmake +add_executable(my_tests src_1.cpp src_2.cpp ...) +target_link_libraries(my_tests doctest) +``` + +- The ```CMakeLists.txt``` file of the doctest repository has ```install()``` commands so you could also use doctest as a package. + +- To discover tests from an executable and register them in ctest you could use [```doctest_discover_tests()``` from scripts/cmake/doctest.cmake](../../scripts/cmake/doctest.cmake) - read the comments in the file on how to use it. It works just like [the same functionality in Catch](https://github.com/catchorg/Catch2/blob/master/docs/cmake-integration.md#automatic-test-registration). + +### Package managers + +**doctest** is available through the following package managers: + +- vcpkg + - You can download and install doctest using the [vcpkg](https://github.com/Microsoft/vcpkg) dependency manager: + ```sh + git clone https://github.com/Microsoft/vcpkg.git + cd vcpkg + ./bootstrap-vcpkg.sh #.\bootstrap-vcpkg.bat(for windows) + ./vcpkg integrate install + ./vcpkg install doctest + ``` + The doctest port in vcpkg is kept up to date by Microsoft team members and community contributors. If the version is out of date, please create an issue or pull request on the [vcpkg repository](https://github.com/Microsoft/vcpkg). + +- hunter +- conan + - https://conan.io/center/doctest + - https://github.com/conan-io/conan-center-index/tree/master/recipes/doctest +- Homebrew (`brew install doctest`) + +--- + +[Home](readme.md#reference) + +

diff --git a/dmff/dpnblist/external/doctest-2.4.11/doc/markdown/commandline.md b/dmff/dpnblist/external/doctest-2.4.11/doc/markdown/commandline.md new file mode 100644 index 00000000..9a3f1a77 --- /dev/null +++ b/dmff/dpnblist/external/doctest-2.4.11/doc/markdown/commandline.md @@ -0,0 +1,135 @@ +## Command line + +**doctest** works quite nicely without any command line options at all - but for more control a bunch are available. + +**Query flags** - after the result is printed the program quits without executing any test cases (and if the framework is integrated into a client codebase which [**supplies its own ```main()``` entry point**](main.md) - the program should check the result of ```shouldExit()``` method after calling ```run()``` on a ```doctest::Context``` object and should exit - this is left up to the user). + +**Int/String options** - they require a value after the ```=``` sign - without spaces! For example: ```--order-by=rand```. + +**Bool options** - they expect ```1```/```yes```/```on```/```true``` or ```0```/```no```/```off```/```false``` after the ```=``` sign - but they can also be used like flags and the ```=value``` part can be skipped - then ```true``` is assumed. + +**Filters** - a comma-separated list of wildcards for matching values - where ```*``` means "match any sequence" and ```?``` means "match any one character". +To pass patterns with intervals use ```""``` like this: ```--test-case="*no sound*,vaguely named test number ?"```. Patterns that contain a comma or a backslash can be escaped with ```\``` (example: ```--test-case=this\,test\,has\,commas\,and\,a\\\,backslash\,followed\,by\,a\,comma```). +If a backslash is followed by neither ```\``` nor ```,``` it's left as is, e.g. ```--test-case="Test that \ works correctly"```. +Be careful: your shell may use ```\``` for escaping as well, so `\` may actually get consumed by the shell instead of doctest. + +All the options can also be set with code (defaults/overrides) if the user [**supplies the ```main()``` function**](main.md). + +| Query Flags | Description | +|:------------|-------------| +| ```-?```     ```--help``` ```-h``` | Prints a help message listing all these flags/options | +| ```-v```     ```--version``` | Prints the version of the **doctest** framework | +| ```-c```     ```--count``` | Prints the number of test cases matching the current filters (see below) | +| ```-ltc``` ```--list-test-cases``` | Lists all test cases by name which match the current filters (see below) | +| ```-lts``` ```--list-test-suites``` | Lists all test suites by name which have at least one test case matching the current filters (see below) | +| ```-lr``` ```--list-reporters``` | Lists all registered [**reporters**](reporters.md) | +| **Int/String Options** |
| +| ```-tc```   ```--test-case=``` | Filters test cases based on their name. By default all test cases match but if a value is given to this filter like ```--test-case=*math*,*sound*``` then only test cases who match at least one of the patterns in the comma-separated list with wildcards will get executed/counted/listed | +| ```-tce``` ```--test-case-exclude=``` | Same as the ```-test-case=``` option but if any of the patterns in the comma-separated list of values matches - then the test case is skipped | +| ```-sf```   ```--source-file=``` | Same as ```--test-case=``` but filters based on the file in which test cases are written | +| ```-sfe``` ```--source-file-exclude=``` | Same as ```--test-case-exclude=``` but filters based on the file in which test cases are written | +| ```-ts```   ```--test-suite=``` | Same as ```--test-case=``` but filters based on the test suite in which test cases are in | +| ```-tse``` ```--test-suite-exclude=``` | Same as ```--test-case-exclude=``` but filters based on the test suite in which test cases are in | +| ```-sc```   ```--subcase=``` | Same as ```--test-case=``` but filters subcases based on their names. Does not filter test cases (they have to be executed for subcases to be discovered) so you might want to use this together with ```--test-case=```. | +| ```-sce``` ```--subcase-exclude=``` | Same as ```--test-case-exclude=``` but filters based on subcase names | +| ```-r``` ```--reporters=``` | List of [**reporters**](reporters.md) to use (default is ```console```) | +| ```-o```   ```--out=``` | Output filename | +| ```-ob```   ```--order-by=``` | Test cases will be sorted before being executed either by **the file in which they are** / **the test suite they are in** / **their name** / **random**. The possible values of `````` are ```file```/```suite```/```name```/```rand```/```none```. The default is ```file```. **NOTE: the order produced by the ```file```, ```suite``` and ```name``` options is compiler-dependent and might differ depending on the compiler used.** | +| ```-rs```   ```--rand-seed=``` | The seed for random ordering | +| ```-f```     ```--first=``` | The **first** test case to execute which passes the current filters - for range-based execution - see [**the example python script**](../../examples/range_based_execution.py) | +| ```-l```     ```--last=``` | The **last** test case to execute which passes the current filters - for range-based execution - see [**the example python script**](../../examples/range_based_execution.py) | +| ```-aa```   ```--abort-after=``` | The testing framework will stop executing test cases/assertions after this many failed assertions. The default is 0 which means don't stop at all. Note that the framework uses an exception to stop the current test case regardless of the level of the assert (```CHECK```/```REQUIRE```) - so be careful with asserts in destructors... | +| ```-scfl``` ```--subcase-filter-levels=``` | Apply subcase filters only for the first `````` levels of nested subcases and just run the ones nested deeper. Default is a very high number which means *filter any subcase* | +| **Bool Options** |
| +| ```-s```     ```--success=``` | To include successful assertions in the output | +| ```-cs```   ```--case-sensitive=``` | Filters being treated as case sensitive | +| ```-e```     ```--exit=``` | Exits after the tests finish - this is meaningful only when the client has [**provided the ```main()``` entry point**](main.md) - the program should check the ```shouldExit()``` method after calling ```run()``` on a ```doctest::Context``` object and should exit - this is left up to the user. The idea is to be able to execute just the tests in a client program and to not continue with its execution | +| ```-d```   ```--duration=``` | Prints the time each test case took in seconds | +| ```-m```   ```--minimal=``` | Only prints failing tests | +| ```-q```   ```--quiet=``` | Does not print any output | +| ```-nt```   ```--no-throw=``` | Skips [**exceptions-related assertion**](assertions.md#exceptions) checks | +| ```-ne```   ```--no-exitcode=``` | Always returns a successful exit code - even if a test case has failed | +| ```-nr```   ```--no-run=``` | Skips all runtime **doctest** operations (except the test registering which happens before the program enters ```main()```). This is useful if the testing framework is integrated into a client codebase which has [**provided the ```main()``` entry point**](main.md) and the user wants to skip running the tests and just use the program | +| ```-ni```   ```--no-intro=``` | Omits the framework intro in the output | +| ```-nv```   ```--no-version=``` | Omits the framework version in the output | +| ```-nc```   ```--no-colors=``` | Disables colors in the output | +| ```-fc```   ```--force-colors=``` | Forces the use of colors even when a tty cannot be detected | +| ```-nb```   ```--no-breaks=``` | Disables breakpoints in debuggers when an assertion fails | +| ```-ns```   ```--no-skip=``` | Don't skip test cases marked as skip with a decorator | +| ```-gfl``` ```--gnu-file-line=``` | ```:n:``` vs ```(n):``` for line numbers in output (gnu mode is usually for linux tools/IDEs and is with the ```:``` separator) | +| ```-npf``` ```--no-path-filenames=``` | Paths are removed from the output when a filename is printed - useful if you want the same output from the testing framework on different environments | +| ```-nln``` ```--no-line-numbers=``` | Line numbers are replaced with ```0``` in the output when a source location is printed - useful if you want the same output from the testing framework even when test positions change within a source file | +| ```-ndo``` ```--no-debug-output=``` | Disables output in the debug console when a debugger is attached | +|                                                                  | | + +All the flags/options also come with a prefixed version (with ```--dt-``` at the front by default) - for example ```--version``` can be used also with ```--dt-version``` or ```--dt-v```. + +The default prefix is ```--dt-```, but this can be changed by setting the [**```DOCTEST_CONFIG_OPTIONS_PREFIX```**](configuration.md#doctest_config_options_prefix) define. + +All the unprefixed versions listed here can be disabled with the [**```DOCTEST_CONFIG_NO_UNPREFIXED_OPTIONS```**](configuration.md#doctest_config_no_unprefixed_options) define. + +This is done for easy interoperability with client command line option handling when the testing framework is integrated within a client codebase - all **doctest** related flags/options can be prefixed so there are no clashes and so that the user can exclude everything starting with ```--dt-``` from their option parsing. + +If there isn't an option to exclude those starting with ```--dt-``` then the ```dt_removed``` helper class might help to filter them out: + +```c++ +#define DOCTEST_CONFIG_NO_UNPREFIXED_OPTIONS +#define DOCTEST_CONFIG_IMPLEMENT +#include "doctest.h" + +class dt_removed { + std::vector vec; +public: + dt_removed(const char** argv_in) { + for(; *argv_in; ++argv_in) + if(strncmp(*argv_in, "--dt-", strlen("--dt-")) != 0) + vec.push_back(*argv_in); + vec.push_back(NULL); + } + + int argc() { return static_cast(vec.size()) - 1; } + const char** argv() { return &vec[0]; } // Note: non-const char **: +}; + +int program(int argc, const char** argv); + +int main(int argc, const char** argv) { + doctest::Context context(argc, argv); + int test_result = context.run(); // run queries, or run tests unless --no-run + + if(context.shouldExit()) // honor query flags and --exit + return test_result; + + dt_removed args(argv); + int app_result = program(args.argc(), args.argv()); + + return test_result + app_result; // combine the 2 results +} + +int program(int argc, const char** argv) { + printf("Program: %d arguments received:\n", argc - 1); + while(*++argv) + printf("'%s'\n", *argv); + return EXIT_SUCCESS; +} +``` + +When run like this: + +``` +program.exe --dt-test-case=math* --my-option -s --dt-no-breaks +``` + +Will output this: + +``` +Program: 2 arguments received: +'--my-option' +'-s' +``` + +--------------- + +[Home](readme.md#reference) + +

diff --git a/dmff/dpnblist/external/doctest-2.4.11/doc/markdown/configuration.md b/dmff/dpnblist/external/doctest-2.4.11/doc/markdown/configuration.md new file mode 100644 index 00000000..a8dd8f92 --- /dev/null +++ b/dmff/dpnblist/external/doctest-2.4.11/doc/markdown/configuration.md @@ -0,0 +1,321 @@ +## Configuration + +**doctest** is designed to "just work" as much as possible. It also allows configuring how it is built with a set of identifiers. + +The identifiers should be defined before the inclusion of the framework header. + +Defining something ```globally``` means for every source file of the binary (executable / shared object). + +- [**```DOCTEST_CONFIG_IMPLEMENT_WITH_MAIN```**](#doctest_config_implement_with_main) +- [**```DOCTEST_CONFIG_IMPLEMENT```**](#doctest_config_implement) +- [**```DOCTEST_CONFIG_DISABLE```**](#doctest_config_disable) +- [**```DOCTEST_CONFIG_IMPLEMENTATION_IN_DLL```**](#doctest_config_implementation_in_dll) +- [**```DOCTEST_CONFIG_NO_SHORT_MACRO_NAMES```**](#doctest_config_no_short_macro_names) +- [**```DOCTEST_CONFIG_TREAT_CHAR_STAR_AS_STRING```**](#doctest_config_treat_char_star_as_string) +- [**```DOCTEST_CONFIG_REQUIRE_STRINGIFICATION_FOR_ALL_USED_TYPES```**](#doctest_config_require_stringification_for_all_used_types) +- [**```DOCTEST_CONFIG_DOUBLE_STRINGIFY```**](#doctest_config_double_stringify) +- [**```DOCTEST_CONFIG_SUPER_FAST_ASSERTS```**](#doctest_config_super_fast_asserts) +- [**```DOCTEST_CONFIG_USE_STD_HEADERS```**](#doctest_config_use_std_headers) +- [**```DOCTEST_CONFIG_VOID_CAST_EXPRESSIONS```**](#doctest_config_void_cast_expressions) +- [**```DOCTEST_CONFIG_NO_COMPARISON_WARNING_SUPPRESSION```**](#doctest_config_no_comparison_warning_suppression) +- [**```DOCTEST_CONFIG_OPTIONS_PREFIX```**](#doctest_config_options_prefix) +- [**```DOCTEST_CONFIG_NO_UNPREFIXED_OPTIONS```**](#doctest_config_no_unprefixed_options) +- [**```DOCTEST_CONFIG_NO_TRY_CATCH_IN_ASSERTS```**](#doctest_config_no_try_catch_in_asserts) +- [**```DOCTEST_CONFIG_NO_EXCEPTIONS```**](#doctest_config_no_exceptions) +- [**```DOCTEST_CONFIG_NO_EXCEPTIONS_BUT_WITH_ALL_ASSERTS```**](#doctest_config_no_exceptions_but_with_all_asserts) +- [**```DOCTEST_CONFIG_ASSERTION_PARAMETERS_BY_VALUE```**](#doctest_config_assertion_parameters_by_value) +- [**```DOCTEST_CONFIG_COLORS_NONE```**](#doctest_config_colors_none) +- [**```DOCTEST_CONFIG_COLORS_WINDOWS```**](#doctest_config_colors_windows) +- [**```DOCTEST_CONFIG_COLORS_ANSI```**](#doctest_config_colors_ansi) +- [**```DOCTEST_CONFIG_WINDOWS_SEH```**](#doctest_config_windows_seh) +- [**```DOCTEST_CONFIG_NO_WINDOWS_SEH```**](#doctest_config_no_windows_seh) +- [**```DOCTEST_CONFIG_POSIX_SIGNALS```**](#doctest_config_posix_signals) +- [**```DOCTEST_CONFIG_NO_POSIX_SIGNALS```**](#doctest_config_no_posix_signals) +- [**```DOCTEST_CONFIG_INCLUDE_TYPE_TRAITS```**](#doctest_config_include_type_traits) +- [**```DOCTEST_CONFIG_NO_MULTITHREADING```**](#doctest_config_no_multithreading) +- [**```DOCTEST_CONFIG_NO_MULTI_LANE_ATOMICS```**](#doctest_config_no_multi_lane_atomics) +- [**```DOCTEST_CONFIG_ASSERTS_RETURN_VALUES```**](#doctest_config_asserts_return_values) +- [**```DOCTEST_CONFIG_EVALUATE_ASSERTS_EVEN_WHEN_DISABLED```**](#doctest_config_evaluate_asserts_even_when_disabled) +- [**```DOCTEST_CONFIG_NO_CONTRADICTING_INLINE```**](#doctest_config_no_contradicting_inline) +- [**```DOCTEST_CONFIG_NO_INCLUDE_IOSTREAM```**](#doctest_config_no_include_iostream) +- [**```DOCTEST_CONFIG_HANDLE_EXCEPTION```**](#doctest_config_handle_exception) + +For most people the only configuration needed is telling **doctest** which source file should host all the implementation code: + +### **```DOCTEST_CONFIG_IMPLEMENT_WITH_MAIN```** + +```c++ +#define DOCTEST_CONFIG_IMPLEMENT_WITH_MAIN +#include "doctest.h" +``` + +This should be defined only in the source file where the library is implemented. It also creates a ```main()``` entry point. + +### **```DOCTEST_CONFIG_IMPLEMENT```** + +If the client wants to [**supply the ```main()``` function**](main.md) (either to set an option with some value from the code or to integrate the framework into their existing project codebase) this identifier should be used. + +This should be defined only in the source file where the library is implemented. + +### **```DOCTEST_CONFIG_DISABLE```** + +One of the most important configuration options - everything testing-related is removed from the binary - including most of the framework implementation and every test case written anywhere! This is one of the most unique features of **doctest**. + +This should be defined globally. + +### **```DOCTEST_CONFIG_IMPLEMENTATION_IN_DLL```** + +This will affect the public interface of doctest - all necessary forward declarations for writing tests will be turned into imported symbols. That way the test runner doesn't have to be implemented in the binary (executable / shared object) and can be reused from another binary where it is built and exported. + +To export the test runner from a binary simply use [**```DOCTEST_CONFIG_IMPLEMENTATION_IN_DLL```**](#doctest_config_implementation_in_dll) together with [**```DOCTEST_CONFIG_IMPLEMENT```**](#doctest_config_implement) (or [**```DOCTEST_CONFIG_IMPLEMENT_WITH_MAIN```**](#doctest_config_implement_with_main) but then the other binaries will have to link to the executable) in whatever source file the test runner gets implemented into. Note that this identifier should not be defined in the other source files of the binary which exports the doctest test runner - or there will be linker conflicts - having the same symbols as both imported and exported within the same binary. + +Checkout the [**example**](../../examples/executable_dll_and_plugin/) - it shows how to have the test runner implemented in a dll (and there are even tests in a plugin which is dynamically loaded). + +This should be defined globally in binaries that import the symbols. + +This should be defined only in the source file where the library is implemented for binaries that export the test runner. + +### **```DOCTEST_CONFIG_NO_SHORT_MACRO_NAMES```** + +This will remove all macros from **doctest** that don't have the **```DOCTEST_```** prefix - like **```CHECK```**, **```TEST_CASE```** and **```SUBCASE```**. Then only the full macro names will be available - **```DOCTEST_CHECK```**, **```DOCTEST_TEST_CASE```** and **```DOCTEST_SUBCASE```**. The user is free to make their own short versions of these macros - [**example**](../../examples/all_features/alternative_macros.cpp). + +This can be defined both globally and in specific source files only. + +### **```DOCTEST_CONFIG_TREAT_CHAR_STAR_AS_STRING```** + +By default ```char*``` is being treated as a pointer. With this option comparing ```char*``` pointers will switch to using ```strcmp()``` for comparisons and when stringified the string will be printed instead of the pointer value. + +This should be defined globally. + +### **```DOCTEST_CONFIG_REQUIRE_STRINGIFICATION_FOR_ALL_USED_TYPES```** + +By default if stringification is not available for a type, it is simply printed as `{?}`. By enabling this flag, whenever a type is used in an assert that does not provide stringification, the compilation is stopped. + +This can be defined both globally and in specific source files only. + +### **```DOCTEST_CONFIG_DOUBLE_STRINGIFY```** + +If you define your own `toString` functions that return something, that's different from `doctest::String`, but still stringifiable, you can enable this flag to stringify the result of internal stringification calls again. + +You can also define `DOCTEST_STRINGIFY` yourself to override doctest's stringification behavior. + +This can be defined both globally and in specific source files only. + +### **```DOCTEST_CONFIG_SUPER_FAST_ASSERTS```** + +This config option makes the assert macros (except for those dealing with exceptions) compile [**much faster**](benchmarks.md#cost-of-an-assertion-macro)! (31-91% - depending on the type - [**normal**](assertions.md#expression-decomposing-asserts) or [**binary**](assertions.md#binary-and-unary-asserts)) + +Each assert is turned into a single function call - the only downside of this is: if an assert fails and a debugger is attached - when it breaks it will be in an internal function - the user will have to go 1 level up in the callstack to see the actual assert. + +It also implies [**```DOCTEST_CONFIG_NO_TRY_CATCH_IN_ASSERTS```**](#doctest_config_no_try_catch_in_asserts) (so exceptions thrown during the evaluation of an assert are not caught by the assert itself but by the testing framework - meaning that the test case is immediately aborted). + +This can be defined both globally and in specific source files only. + +### **```DOCTEST_CONFIG_USE_STD_HEADERS```** + +The library by default provides a forward declaration of ```std::ostream``` in order to support the ```operator<<``` [**stringification**](stringification.md) mechanism (also ```std::tuple<>``` and ```std::nullptr_t```). This is forbidden by the standard (even though it works everywhere on all tested compilers). However if the user wishes to be 100% standards compliant - then this configuration option can be used to force the inclusion of the relevant standard headers. + +Also it is possible that some STL implementation of a compiler with niche usage defines them differently - then there will be compilation errors in STL headers and using this option should fix the problem. + +This should be defined globally. + +### **```DOCTEST_CONFIG_VOID_CAST_EXPRESSIONS```** + +This affects the [asserts dealing with exceptions](assertions.md#exceptions) - the expression is cast to void to avoid problems such as when functions with the ```[[nodiscard]]``` attribute are used but their result isn't checked. + +This can be defined both globally and in specific source files only. + +### **```DOCTEST_CONFIG_NO_COMPARISON_WARNING_SUPPRESSION```** + +By default the library suppresses warnings about comparing signed and unsigned types, etc. + +- g++/clang ```-Wsign-conversion``` +- g++/clang ```-Wsign-compare``` +- msvc ```C4389``` 'operator' : signed/unsigned mismatch +- msvc ```C4018``` 'expression' : signed/unsigned mismatch + +You can checkout [**this**](https://github.com/doctest/doctest/issues/16#issuecomment-246803303) issue to better understand why I suppress these warnings by default. + +This can be defined both globally and in specific source files only. + +### **```DOCTEST_CONFIG_OPTIONS_PREFIX```** + +Defining this as a string will change the prefix of the [**command line**](commandline.md) options to use the given prefix instead of the default ```dt-``` prefix. This can be useful for integrating the testing framework into a client codebase, where a command option prefix like ```selftest-``` might be more clear to users. + +This should be defined only in the source file where the library is implemented (it's relevant only there). + +### **```DOCTEST_CONFIG_NO_UNPREFIXED_OPTIONS```** + +This will disable the short versions of the [**command line**](commandline.md) options and only the versions with ```--dt-``` prefix will be parsed by **doctest** - this is possible for easy interoperability with client command line option handling when the testing framework is integrated within a client codebase - so there are no clashes and so that the user can exclude everything starting with ```--dt-``` from their option parsing. + +This should be defined only in the source file where the library is implemented (it's relevant only there). + +### **```DOCTEST_CONFIG_NO_TRY_CATCH_IN_ASSERTS```** + +This will remove all ```try``` / ```catch``` sections from: + +- the [normal asserts](assertions.md#expression-decomposing-asserts) +- the [binary and unary asserts](assertions.md#binary-and-unary-asserts) + +so exceptions thrown while evaluating the expression in an assert will terminate the current test case. + +This can be used for some mild compile time savings but for greater impact look into [**```DOCTEST_CONFIG_SUPER_FAST_ASSERTS```**](configuration.md#doctest_config_super_fast_asserts). + +This can be defined both globally and in specific source files only. + +### **```DOCTEST_CONFIG_NO_EXCEPTIONS```** + +This will remove everything that uses exceptions from the framework - it is also auto detectable if exceptions are disabled for compilers (like with ```-fno-exceptions``` for GCC/Clang). + +What gets changed: + +- asserts that evaluate the expression in a ```try``` / ```catch``` section no longer evaluate in such a context +- ```REQUIRE``` macros are gone (undefined) +- [exception macros](assertions.md#exceptions) are gone (undefined) +- the ```abort-after``` option won't be fully working because an exception is used to terminate test cases + +The ```REQUIRE``` family of asserts uses exceptions to terminate the current test case when they fail. An exception is used instead of a simple ```return;``` because asserts can be used not only in a test case but also in functions called by a test case. + +Also some of the [**logging macros**](logging.md#messages-which-can-optionally-fail-test-cases) which act like a ```REQUIRE``` assert (terminating the test case) - like ```FAIL()``` - start to work differently - like a ```FAIL_CHECK()```. + +[**```DOCTEST_CONFIG_NO_EXCEPTIONS```**](#doctest_config_no_exceptions) implies [**```DOCTEST_CONFIG_NO_TRY_CATCH_IN_ASSERTS```**](#doctest_config_no_try_catch_in_asserts) + +If you wish to use asserts that deal with exceptions and only sometimes build without exceptions - check the [**```DOCTEST_CONFIG_NO_EXCEPTIONS_BUT_WITH_ALL_ASSERTS```**](#doctest_config_no_exceptions_but_with_all_asserts) config option. + +This should be defined globally. + +### **```DOCTEST_CONFIG_NO_EXCEPTIONS_BUT_WITH_ALL_ASSERTS```** + +When building with no exceptions (see [**```DOCTEST_CONFIG_NO_EXCEPTIONS```**](#doctest_config_no_exceptions)) ```REQUIRE``` asserts and the ones about dealing with exceptions are gone. + +If however you want your code to use these assertions and only sometimes build without exceptions - then using this config will be of help. The effects of using it are the following: + +- ```REQUIRE``` asserts are not gone - but they act like ```CHECK``` asserts - when one of them fails the whole test case will be marked as failed but will not be exited immediately +- the [asserts for dealing with exceptions](assertions.md#exceptions) are turned into a no-op (instead of being totally undefined) + +This can be defined both globally and in specific source files only. + +### **```DOCTEST_CONFIG_ASSERTION_PARAMETERS_BY_VALUE```** + +This option forces all doctest asserts to copy by value the expressions they are given instead of binding them to const references. This might be useful to avoid ODR-usage of static constants (which might lead to linker errors with g++/clang): + +```c++ +template struct type_traits { static const bool value = false; }; + +// unless DOCTEST_CONFIG_ASSERTION_PARAMETERS_BY_VALUE is defined the following assertion +// will lead to a linker error if type_traits::value isn't defined in a translation unit +CHECK(type_traits::value == false); +``` + +This can be defined both globally and in specific source files only. + +### **```DOCTEST_CONFIG_COLORS_NONE```** + +This will remove support for colors in the console output of the framework. + +This should be defined only in the source file where the library is implemented (it's relevant only there). + +### **```DOCTEST_CONFIG_COLORS_WINDOWS```** + +This will force the support for colors in the console output to use the Windows APIs and headers. + +This should be defined only in the source file where the library is implemented (it's relevant only there). + +### **```DOCTEST_CONFIG_COLORS_ANSI```** + +This will force the support for colors in the console output to use ANSI escape codes. + +This should be defined only in the source file where the library is implemented (it's relevant only there). + +### **```DOCTEST_CONFIG_WINDOWS_SEH```** + +This will enable SEH handling on Windows. Currently enabled only when compiled with MSVC, because some versions of MinGW do not have the necessary Win32 API support. The user may choose to enable this explicitly - it is known to work with the MinGW-w64 project. + +This should be defined only in the source file where the library is implemented (it's relevant only there). + +### **```DOCTEST_CONFIG_NO_WINDOWS_SEH```** + +This can be used to disable [**```DOCTEST_CONFIG_WINDOWS_SEH```**](#doctest_config_windows_seh) when it is auto-selected by the library. + +This should be defined only in the source file where the library is implemented (it's relevant only there). + +### **```DOCTEST_CONFIG_POSIX_SIGNALS```** + +This will enable the use of signals under UNIX for handling crashes. On by default. + +This should be defined only in the source file where the library is implemented (it's relevant only there). + +### **```DOCTEST_CONFIG_NO_POSIX_SIGNALS```** + +This can be used to disable **```DOCTEST_CONFIG_POSIX_SIGNALS```** when it is auto-selected by the library. + +This should be defined only in the source file where the library is implemented (it's relevant only there). + +### **```DOCTEST_CONFIG_INCLUDE_TYPE_TRAITS```** + +This can be used to include the `````` C++11 header. That in turn will enable the ability for the ```Approx``` helper to be used with strong typedefs of ```double``` - check [this](https://github.com/doctest/doctest/issues/62) or [this](https://github.com/doctest/doctest/issues/85) issue for more details on that. + +This can be defined both globally and in specific source files only. + +### **```DOCTEST_CONFIG_NO_MULTITHREADING```** + +This can be used to disable all multithreading support. + +Speeds up single threaded applications. + +Includes [**```DOCTEST_CONFIG_NO_MULTI_LANE_ATOMICS```**](#doctest_config_no_multi_lane_atomics). + +This should be defined only in the source file where the library is implemented (it's relevant only there). + +### **```DOCTEST_CONFIG_NO_MULTI_LANE_ATOMICS```** + +This can be used to disable multi lane atomics. Multi lane atomics can speed up highly parallel use of assert statements, but have a small overhead for single threaded applications. + +This should be defined only in the source file where the library is implemented (it's relevant only there). + +### **```DOCTEST_CONFIG_ASSERTS_RETURN_VALUES```** + +Makes all assertion macros return a boolean value, reporting whether the assertion succeeded. This can be used, for example, to have ```nullptr``` checks that don't terminate the test case on failure. + +Example: +```c++ +if (CHECK(somePtr != nullptr)) + CHECK(somePtr->someMethod() == 42); +``` + +This has a slight negative impact on performance as well as disabling some functionality inside assertions (e.g. ```co_return```). + +When [**```DOCTEST_CONFIG_DISABLE```**](#doctest_config_disable) is defined, all macros return ```false``` by default. + +This can be defined both globally and in specific source files only. + +### **```DOCTEST_CONFIG_EVALUATE_ASSERTS_EVEN_WHEN_DISABLED```** + +When [**```DOCTEST_CONFIG_ASSERTS_RETURN_VALUES```**](#doctest_config_asserts_return_values) and [**```DOCTEST_CONFIG_DISABLE```**](#doctest_config_disable) are defined, this macro will cause conditions from assertions to evaluate properly (instead of returning `false`), although all overhead and functionality from doctest is removed. This is useful when assertions are used in production code within if statements so that the condition continues to be evaluated. + +Since all ```THROWS_WITH``` assertions depend on doctest functionality which is not available when [**```DOCTEST_CONFIG_DISABLE```**](#doctest_config_disable) is defined (stringification), they will still unconditionally return ```false```. + +This can be defined both globally and in specific source files only. + +### **```DOCTEST_CONFIG_NO_CONTRADICTING_INLINE```** + +Some functions in doctest are marked with both `inline` and a compiler specific no-inline attribute. This is done because they need to be weak symbols (inline) so that they can be defined in multiple compilation units, but they should not actually be inlined as a compiler optimization as that would degrade compilation speed. + +However, this is known to cause some issues with a few compilers with hard to suppress warnings. This flag disables the use of the no-inline attribute in order to suppress the warning if your build requires that. + +### **```DOCTEST_CONFIG_NO_INCLUDE_IOSTREAM```** + +This option disables any inclusion of ``, `std::cout` and `std::cerr`. This implies that the `cout` context field must be supplied. If +```DOCTEST_CONFIG_NO_EXCEPTIONS``` is defined, then the unhandled exception is not printed to `std::cerr`. +[```DOCTEST_CONFIG_HANDLE_EXCEPTION```](#doctest_config_handle_exception) can be defined to handle this case. + +### **```DOCTEST_CONFIG_HANDLE_EXCEPTION```** + +This macro function can be defined to handle exceptions instead of just printing them +to `std::cerr`. + +--------------- + +[Home](readme.md#reference) + +

diff --git a/dmff/dpnblist/external/doctest-2.4.11/doc/markdown/extensions.md b/dmff/dpnblist/external/doctest-2.4.11/doc/markdown/extensions.md new file mode 100644 index 00000000..5c15456a --- /dev/null +++ b/dmff/dpnblist/external/doctest-2.4.11/doc/markdown/extensions.md @@ -0,0 +1,170 @@ +## Extensions + +The doctest header doesn't include any external or stdlib headers in its interface part in order to provide the most optimal build times but that means it is limited in what it can provide as functionality => that's when extensions come into play. They are located as header files in [`doctest/extensions`](../../doctest/extensions) and each of them is documented in a section here. + +# [Utils](../../doctest/extensions/doctest_util.h) + +nothing here yet... + +# [Distributed tests with MPI](../../doctest/extensions/doctest_mpi.h) + +[Bruno Maugars and Bérenger Berthoul, ONERA] + +Testing code over distributed processes requires support from the testing framework. **Doctest** support for MPI parallel communication is provided in the ```"doctest/extensions/doctest_mpi.h"``` header. + +## Example + +See [**the complete test**](../../examples/mpi/mpi.cpp) and [**the configuration of main()**](../../examples/mpi/main.cpp) + +### MPI_TEST_CASE + +```c++ +#include "doctest/extensions/doctest_mpi.h" + +int my_function_to_test(MPI_Comm comm) { + int rank; + MPI_Comm_rank(comm,&rank); + if (rank == 0) { + return 10; + } + return 11; +} + + +MPI_TEST_CASE("test over two processes",2) { // Parallel test on 2 processes + int x = my_function_to_test(test_comm); + + MPI_CHECK( 0, x==10 ); // CHECK for rank 0, that x==10 + MPI_CHECK( 1, x==11 ); // CHECK for rank 1, that x==11 +} +``` + +An ```MPI_TEST_CASE``` is like a regular ```TEST_CASE```, except it takes a second argument, which is the number of processes needed to run the test. If the number of processes is less than 2, the test will fail. If the number of processes is greater than or equal to 2, it will create a sub-communicator over 2 processes, called ```test_comm```, and execute the test over these processes. Three objects are provided by ```MPI_TEST_CASE```: + * ```test_comm```, of type ```MPI_Comm```: the mpi communicator on which the test is running, + * ```test_rank``` and ```test_nb_procs```, two ```int``` giving respectively the rank of the current process and the size of the communicator for ```test_comm```. These last two are just here for convenience and could be retrieved from ```test_comm```. + +We always have: + +```c++ +MPI_TEST_CASE("my_test",N) { + CHECK( test_nb_procs == N ); + MPI_CHECK( i, test_rank==i ); // for any i On rank [2] with 1 test failed +[doctest] Status: FAILURE! +``` + +If the test executable is launch with less processes than the number of processes required by one test, the test is skipped and marqued as such in the mpi console reporter: + + +```c++ +MPI_TEST_CASE("my_test",3) { + // ... +} +``` + +``` +mpirun -np 2 unit_test_executable.exe +``` + +``` +=============================================================================== +[doctest] test cases: 1 | 1 passed | 0 failed | 1 skipped +[doctest] assertions: 1 | 1 passed | 0 failed | +[doctest] Status: SUCCESS! +=============================================================================== +[doctest] assertions on all processes: 1 | 1 passed | 0 failed | +[doctest] WARNING: Skipped 1 test requiring more than 2 MPI processes to run +=============================================================================== +``` + +### MpiFileReporter +The ```MpiFileReporter``` will just print the result of each process in its own file, named ```doctest_[rank].log```. Only use this reporter as a debug facility if you want to know what is going on exactly when a parallel test case is failing. + +### Other reporters +Other reporters (jUnit, XML) are not supported directly, which mean that you can always print the result of each process to its own file, but there is (currently) no equivalent of the ```MpiConsoleReporter``` that will aggregate the results of all processes. + + +## Note + +This feature is provided to unit-test mpi-distributed code. It is **not** a way to parallelize many unit tests over several processes (for that, see [**the example python script**](../../examples/range_based_execution.py)). + +## TODO + + * Pass ```s``` member variable of ```ConsoleReporter``` as an argument to member functions so we can use them with another object (would help to factorize ```MPIConsoleReporter```) + * Only MPI_CHECK tested. MPI_REQUIRE, exception handling: nothing tested + * More testing, automatic testing + * Packaging: create a new target ```mpi_doctest```? (probably cleaner to depend explicitly on MPI for mpi/doctest.h) + * Later, maybe: have a general mechanism to represent assertions so we can separate the report format (console, xml, junit...) from the reporting strategy (sequential vs. MPI) + +--------------- + +[Home](readme.md#reference) + +

diff --git a/dmff/dpnblist/external/doctest-2.4.11/doc/markdown/faq.md b/dmff/dpnblist/external/doctest-2.4.11/doc/markdown/faq.md new file mode 100644 index 00000000..3aea7549 --- /dev/null +++ b/dmff/dpnblist/external/doctest-2.4.11/doc/markdown/faq.md @@ -0,0 +1,178 @@ +## FAQ + +- [**How is doctest different from Catch?**](#how-is-doctest-different-from-catch) +- [**How is doctest different from Google Test?**](#how-is-doctest-different-from-google-test) +- [**How to get the best compile-time performance with the framework?**](#how-to-get-the-best-compile-time-performance-with-the-framework) +- [**Is doctest thread-aware?**](#is-doctest-thread-aware) +- [**Is mocking supported?**](#is-mocking-supported) +- [**Why are my tests in a static library not getting registered?**](#why-are-my-tests-in-a-static-library-not-getting-registered) +- [**Why is comparing C strings (```char*```) actually comparing pointers?**](#why-is-comparing-c-strings-char-actually-comparing-pointers) +- [**How to write tests in header-only libraries?**](#how-to-write-tests-in-header-only-libraries) +- [**Does the framework use exceptions?**](#does-the-framework-use-exceptions) +- [**Why do I get compiler errors in STL headers when including the doctest header?**](#why-do-i-get-compiler-errors-in-stl-headers-when-including-the-doctest-header) +- [**Can different versions of the framework be used within the same binary (executable/dll)?**](#can-different-versions-of-the-framework-be-used-within-the-same-binary-executabledll) +- [**Why is doctest using macros?**](#why-is-doctest-using-macros) +- [**How to use with multiple files?**](#how-to-use-with-multiple-files) + +### How is **doctest** different from Catch? + +Pros of **doctest**: + +- **doctest** is [**thread-safe**](faq.md#is-doctest-thread-aware) +- asserts can be used [**outside of a testing context**](assertions.md#using-asserts-out-of-a-testing-context) +- including the **doctest** header is [**over 20 times lighter**](benchmarks.md#cost-of-including-the-header) on compile times than that of [**Catch**](https://github.com/catchorg/Catch2) +- the asserts in **doctest** can be [**many times lighter**](benchmarks.md#cost-of-an-assertion-macro) on compile times than those of [**Catch**](https://github.com/catchorg/Catch2) +- **doctest** executes tests [**many times faster**](benchmarks.md#runtime-benchmarks) than [**Catch**](https://github.com/catchorg/Catch2) +- everything testing-related can be removed from the binary by defining the [**```DOCTEST_CONFIG_DISABLE```**](configuration.md#doctest_config_disable) identifier +- doesn't drag any headers when included (except for in the translation unit where the library gets implemented) +- 0 warnings even on the [**most aggressive**](../../scripts/cmake/common.cmake#L84) warning levels for MSVC/GCC/Clang +- per commit tested with 180+ builds on [**much more compilers**](features.md#extremely-portable) - and through valgrind/sanitizers/analyzers +- test cases can be written in headers - the framework will still register the tests only once - no duplicates +- binaries (exe/dll) can use the test runner of another binary - so tests end up in a single registry - [**example**](../../examples/executable_dll_and_plugin/) + +Aside from everything mentioned so far doctest has some [**features**](features.md#other-features) (like [**test suites**](testcases.md#test-suites) and [**decorators**](testcases.md#decorators)) which [**Catch**](https://github.com/catchorg/Catch2) doesn't. + +Missing stuff: + +- matchers and generators +- micro benchmarking support - nonius is used in [**Catch**](https://github.com/catchorg/Catch2) +- other small stuff such as tags - can be easily emulated/migrated from - see below + +But these things (and more!) are planned in the [**roadmap**](https://github.com/doctest/doctest/issues/600)! + +**doctest** can be thought of as a very polished, light, stable and clean subset (or reimplementation) of [**Catch**](https://github.com/catchorg/Catch2) but this might change in the future as more features are added. + +Also checkout [this table](https://github.com/martinmoene/catch-lest-other-comparison) that compares **doctest** / [**Catch**](https://github.com/catchorg/Catch2) / [**lest**](https://github.com/martinmoene/lest). + +A quick and easy way to migrate most of your Catch tests to doctest is to change the ```TEST_CASE``` (if using tags) and ```SECTION``` macros as follows: + +```c++ +#include "path/to/doctest.h" + +#define SECTION(name) DOCTEST_SUBCASE(name) + +// only if tags are used: will concatenate them to the test name string literal +#undef TEST_CASE +#define TEST_CASE(name, tags) DOCTEST_TEST_CASE(tags " " name) + +// catch exposes this by default outside of its namespace +using doctest::Approx; +``` + +### How is **doctest** different from Google Test? + +Here are a couple of differences: + +- the main one is that only doctest from the C++ frameworks is usable next to your production code (speed of compilation, ability to remove the tests from the binary, ability to execute tests/code/both, ability to have tests in multiple shared objects and still a single registry for all of them) +- doctest is a single header - Google Test has to be built as a separate static library and linked against. +- doctest has the concept of [**Subcases**](https://github.com/doctest/doctest/blob/master/doc/markdown/tutorial.md#test-cases-and-subcases) which is a much cleaner way to share setup and teardown code between tests compared to fixtures and class inheritance - Google Test is quite verbose! +- doctest compiles faster and probably runs faster (although the runtime becomes an issue only when you have millions of asserts) +- doctest asserts are thread-safe even on Windows (Google Test uses pthreads so thread-safe asserts are available only on UNIX) +- doctest overall has a simpler API + +but there are also some areas in which doctest is lacking: + +- value-parameterized tests +- death tests (where you check if calling a certain function doesn’t simply throw but if it crashes the process) +- doctest has some integration with mocking libraries but Google Test works perfectly with Google Mock (although doctest should in theory work with it as well) + +The areas where doctest is behind are planned for improvement in the future. There are many other smaller differences - it would be impractical to cover them all. + +### How to get the best compile-time performance with the framework? + +The [**```DOCTEST_CONFIG_SUPER_FAST_ASSERTS```**](configuration.md#doctest_config_super_fast_asserts) config option yields the [**fastest possible**](benchmarks.md#cost-of-an-assertion-macro) compile times (up to 31-91%). Also the expression-decomposing template machinery can be skipped by using the [**binary**](assertions.md#binary-and-unary-asserts) asserts. + +There are only 2 tiny drawbacks of using this config option: + +- there is no ```try/catch``` block in each assert so if an expression is thrown the whole test case ends (but is still caught and reported). +- when an assert fails and a debugger is present - the framework will break inside a doctest function so the user will have to go 1 level up in the callstack to see where the actual assert is in the source code. + +These 2 things can be considered negligible and totally worth it if you are dealing mainly with expressions unlikely to throw exceptions and all the tests usually pass (you don't need to navigate often to a failing assert with a debugger attached). + +### Is doctest thread-aware? + +Most macros/functionality is safe to use in a multithreaded context: [**assertion**](assertions.md) and [**logging**](logging.md) macros can be safely used from multiple threads spawned from a single test case. This however does not mean that multiple test cases can be run in parallel - test cases are still run serially. [**Subcases**](tutorial.md#test-cases-and-subcases) should also be used only from the test runner thread and all threads spawned in a subcase ought to be joined before the end of that subcase and no new subcases should be entered while other threads with doctest assertions in them are still running - not following these instructions will lead to crashes (example in [**here**](../../examples/all_features/concurrency.cpp)). Also note that logged context in one thread will not be used/printed when asserts from another thread fail - logged context is thread-local. + +There is also an option to run a [**range**](commandline.md) of tests from an executable - so tests can be run in parallel by invoking the process multiple times with different ranges - see [**the example python script**](../../examples/range_based_execution.py). + +### Is mocking supported? + +**doctest** doesn't support mocking but should be easy to integrate with third-party libraries such as: + +- [trompeloeil](https://github.com/rollbear/trompeloeil) - integration shown [here](https://github.com/rollbear/trompeloeil/blob/master/docs/CookBook.md#adapt_doctest) +- [FakeIt](https://github.com/eranpeer/FakeIt) - integration might be similar to that of [catch](https://github.com/eranpeer/FakeIt/tree/master/config/catch) but this has not been looked into + +by using the [**logging**](logging.md#messages-which-can-optionally-fail-test-cases) macros such as ```ADD_FAIL_AT(file, line, message)``` + + + +### Why are my tests in a static library not getting registered? + +This is a [**common problem among libraries with self-registering code**](https://groups.google.com/forum/#!msg/catch-forum/FV0Qo62DvgY/jxEO6c9_q3kJ) and it affects all modern compilers on all platforms. + +The problem is that when a static library is being linked to a binary (executable or dll) - only object files from the static library that define a symbol being required from the binary will get pulled in (this is a linker/dependency optimization). + +A way to solve this in CMake is to use object libraries instead of static libraries - like this: + +```cmake +add_library(with_tests OBJECT src_1.cpp src_2.cpp src_3.cpp ...) + +add_library(dll SHARED $ dll_src_1.cpp ...) +add_executable(exe $ exe_src_1.cpp ...) +``` + +Thanks to [pthom](https://github.com/pthom) for suggesting this. + +As an alternative I have created a CMake function that forces every object file from a static library to be linked into a binary target - it is called [**```doctest_force_link_static_lib_in_target()```**](../../examples/exe_with_static_libs/doctest_force_link_static_lib_in_target.cmake). It is unintrusive - no source file gets changed - everything is done with compiler flags per source files. An example project using it can be found [**here**](../../examples/exe_with_static_libs) - the commented part of the CMakeLists.txt file. + +It doesn't work in 2 scenarios: + +- either the target or the library uses a precompiled header - see [**this**](https://github.com/doctest/doctest/issues/21#issuecomment-247001423) issue for details +- either the target or the library is an imported target (pre-built) and not built within the current cmake tree + +You can also checkout this repository for a different solution: [**pthom/doctest_registerlibrary**](https://github.com/pthom/doctest_registerlibrary). + +A compiler-specific solution for MSVC is to use the [```/OPT:NOREF```](https://msdn.microsoft.com/en-us/library/bxwfs976.aspx) linker flag (thanks to [lectem](https://github.com/Lectem) for [reporting](https://github.com/doctest/doctest/issues/106) it!). Another option is to look at [```/wholearchive```](https://docs.microsoft.com/en-us/cpp/build/reference/wholearchive-include-all-library-object-files?view=vs-2019) for MSVC. + +### Why is comparing C strings (```char*```) actually comparing pointers? + +**doctest** by default treats ```char*``` as normal pointers. Using the [**```DOCTEST_CONFIG_TREAT_CHAR_STAR_AS_STRING```**](configuration.md#doctest_config_treat_char_star_as_string) changes that. + +### How to write tests in header-only libraries? + +There are 2 options: + +- just include the doctest header in your headers and write the tests - the doctest header should be shipped with your headers and the user will have to implement the doctest runner in one of their source files. +- don't include the doctest header and guard your test cases with ```#ifdef DOCTEST_LIBRARY_INCLUDED``` and ```#endif``` - that way your tests will be compiled and registered if the user includes the doctest header before your headers (and they will also have to implement the test runner somewhere). + +Also note that it would be a good idea to add a tag in your test case names (like this: ```TEST_CASE("[the_lib] testing foo")```) so the user can easily filter them out with ```--test-case-exclude=*the_lib*``` if they wish to. + +### Does the framework use exceptions? + +Yes - but they can be disabled - see the [**```DOCTEST_CONFIG_NO_EXCEPTIONS```**](configuration.md#doctest_config_no_exceptions) config identifier. + +### Why do I get compiler errors in STL headers when including the doctest header? + +Try using the [**```DOCTEST_CONFIG_USE_STD_HEADERS```**](configuration.md#doctest_config_use_std_headers) configuration identifier. + +### Can different versions of the framework be used within the same binary (executable/dll)? + +Currently no. Single header libraries like [**stb**](https://github.com/nothings/stb) have this as an option (everything gets declared static - making it with internal linkage) but it isn't very logical for **doctest** - the main point is to write tests in any source file of the project and have the test runner implemented in only one source file. + +### Why is doctest using macros? + +Aren't they evil and not *modern*? - Check out the answer Phil Nash gives to this question [**here**](http://accu.org/index.php/journals/2064) (the creator of [**Catch**](https://github.com/catchorg/Catch2)). + +### How to use with multiple files? + +All you need to do is define either [**```DOCTEST_CONFIG_IMPLEMENT_WITH_MAIN```**](configuration.md#doctest_config_implement_with_main) or [**```DOCTEST_CONFIG_IMPLEMENT```**](configuration.md#doctest_config_implement) in only ONE of the source files just before including the doctest header - in all other source files you just include the header and use the framework. The difference between the two is that one of them provides a `main()` entry point - for more info on that please refer to [`The main() entry point`](main.md). + +--------------- + +[Home](readme.md#reference) + +

diff --git a/dmff/dpnblist/external/doctest-2.4.11/doc/markdown/features.md b/dmff/dpnblist/external/doctest-2.4.11/doc/markdown/features.md new file mode 100644 index 00000000..32d256d3 --- /dev/null +++ b/dmff/dpnblist/external/doctest-2.4.11/doc/markdown/features.md @@ -0,0 +1,84 @@ +## Features and design goals + +**doctest** has been designed from the start to be as **light** and **unintrusive** as possible. These key features should be kept. + +## Unintrusive (transparent): + +- everything testing-related can be removed from the binary executable by defining the [**```DOCTEST_CONFIG_DISABLE```**](configuration.md#doctest_config_disable) identifier +- very small and easy to integrate - single header +- **Extremely** low footprint on compile times - [**around 25ms**](benchmarks.md#cost-of-including-the-header) of compile time overhead for including the header in a file +- The [**fastest possible**](benchmarks.md#cost-of-an-assertion-macro) assertion macros - 50k asserts can compile for under 30 seconds (even under 10 sec) +- doesn't drag any headers when included (except for in the translation unit where the library gets implemented) +- everything is in the ```doctest``` namespace (and the implementation details are in a nested ```detail``` namespace) +- all macros have prefixes - some by default have unprefixed versions as well but that is optional - see [**configuration**](configuration.md) +- 0 warnings even with the most aggressive flags (on all tested compilers!!!) + - ```-Weverything -pedantic``` for **clang** + - ```-Wall -Wextra -pedantic``` and **>> over 35 <<** other warnings **not** covered by these flags for **GCC**!!! - see [**here**](../../scripts/cmake/common.cmake#L84) + - ```/Wall``` for **MSVC** +- doesn't error on unrecognized [**command line**](commandline.md) options and supports prefixes for interop with client command line parsing +- can set options [**procedurally**](main.md) and not deal with passing ```argc```/```argv``` from the command line +- doesn't leave warnings disabled after itself + +## Extremely portable: + +**SOME OF THIS IS OUTDATED** + +- Standards compliant **C++11** code - should work with any **C++11** capable compiler (use tag [**1.2.9**](https://github.com/doctest/doctest/tree/1.2.9) for C++98 and older compilers) +- tested with **GCC**: **4.8**, **4.9**, **5**, **6**, **7**, **8**, **9**, **10**, **11**, **12** +- tested with **Clang**: **3.5**, **3.6**, **3.7**, **3.8**, **3.9**, **4**, **5**, **6**, **7**, **8**, **9**, **10**, **11**, **12**, **13**, **14**, **15** (XCode 10+) +- tested with **MSVC**: **2015**, **2017**, **2019**, **2022** (also in 32 bit mode) +- per-commit tested on [**GitHub Actions**](https://github.com/doctest/doctest/actions) + - warnings as errors even on the most aggressive warning levels - see [**here**](../../scripts/cmake/common.cmake#L84) + - statically analyzed on the CI - [**Cppcheck**](http://cppcheck.sourceforge.net/) / [**Clang-Tidy**](https://clang.llvm.org/extra/clang-tidy/) / [**Coverity Scan**](https://scan.coverity.com/) / [**OCLint**](http://oclint.org/) / [**Visual Studio Analyzer**](https://docs.microsoft.com/en-us/visualstudio/code-quality/analyzing-c-cpp-code-quality-by-using-code-analysis) + - all tests have their output compared to reference output of a previous known good run + - all tests built and run in **Debug**/**Release** modes + - all tests ran through **valgrind** under **Linux** (sadly [not under OSX](https://github.com/doctest/doctest/issues/11)) + - all tests ran through **address**, **UB** and **thread** sanitizers under **Linux**/**OSX** + - tests are run in more than **300** different configurations on UNIX (Linux + OSX) & Windows + +## Other features: + +- really easy to get started - it's just 1 header file - see the [**tutorial**](tutorial.md) +- **very** light, unintrusive and portable - see the sections above - and also the [**benchmarks**](benchmarks.md) +- offers a way to remove **everything** testing-related from the binary with the [**```DOCTEST_CONFIG_DISABLE```**](configuration.md#doctest_config_disable) macro +- tests are registered automatically - no need to add them to a collection manually +- [**Subcases**](tutorial.md#test-cases-and-subcases) - an intuitive way to share common setup and teardown code for test cases (alternative to [**test fixtures**](testcases.md#test-fixtures) which are also supported) +- [**templated test cases**](parameterized-tests.md#templated-test-cases---parameterized-by-type) - parameterized by type +- supports [**logging macros**](logging.md) for capturing local variables and strings - as a message for when an assert fails - with lazy stringification and no allocations when possible! +- crash handling support - uses signals for UNIX and SEH for Windows +- [**thread-safe**](faq.md#is-doctest-thread-aware) - asserts (and logging) can be used from multiple threads spawned from a single test case - [**example**](../../examples/all_features/concurrency.cpp) +- an extensible [**reporter system**](reporters.md) (can be also used for implementing event listeners) +- output from all compilers on all platforms is the same - byte by byte +- binaries (exe/dll) can use the test runner of another binary - so tests end up in a single registry - [**example**](../../examples/executable_dll_and_plugin/) +- supports [**BDD style**](testcases.md) tests +- one core [**assertion macro**](assertions.md) for comparisons - standard C++ operators are used for the comparison (less than, equal, greater than...) - yet the full expression is decomposed and left and right values of the expression are logged +- asserts can be used [**outside of a testing context**](assertions.md#using-asserts-out-of-a-testing-context) - [**example**](../../examples/all_features/asserts_used_outside_of_tests.cpp) +- assertion macros for [**exceptions**](assertions.md#exceptions) - if something should or shouldn't throw +- floating point comparison support - see the [**```Approx()```**](assertions.md#floating-point-comparisons) helper +- powerful mechanism for [**stringification**](stringification.md) of user types - including [**exceptions**](stringification.md#translating-exceptions)! +- tests can be grouped in [**test suites**](testcases.md#test-suites) +- test case [**decorators**](testcases.md#decorators) such as ```description``` / ```skip``` / ```may_fail``` / ```should_fail``` / ```expected_failures``` / ```timeout``` +- can be used without exceptions and rtti - checkout [**```DOCTEST_CONFIG_NO_EXCEPTIONS```**](configuration.md#doctest_config_no_exceptions) +- powerful [**command line**](commandline.md) with lots of options +- can report the duration of test cases +- tests can be [**filtered**](commandline.md) based on their name/file/test suite using wildcards +- can [**filter**](commandline.md) subcases using wildcards and by specifying the nesting levels for which those filters should work +- failures can (optionally) break into the debugger on Windows and Mac +- integration with the output window of Visual Studio for failing tests +- a ```main()``` can be provided when implementing the library with the [**```DOCTEST_CONFIG_IMPLEMENT_WITH_MAIN```**](main.md#doctest_config_implement_with_main) identifier +- can write tests in headers - they will still be registered only once in the executable/shared object +- [**range-based**](commandline.md) execution of tests within a binary - see the [**example python script**](../../examples/range_based_execution.py) +- [**extension headers**](extensions.md) for extra functionality which doesn't need to go into the main `doctest.h` header +- colored output in the console +- controlling the order of test execution +- different ```doctest::Context```s can be created and run many times within a single execution of the program +- ability to query if code is currently being run in a test - ```doctest::is_running_in_test``` +- tests can be registered in CTest with the use of [```doctest_discover_tests()``` from scripts/cmake/doctest.cmake](../../scripts/cmake/doctest.cmake) + +There is a list of planned features which are all important and big - see the [**roadmap**](https://github.com/doctest/doctest/issues/600). + +--------------- + +[Home](readme.md#reference) + +

diff --git a/dmff/dpnblist/external/doctest-2.4.11/doc/markdown/logging.md b/dmff/dpnblist/external/doctest-2.4.11/doc/markdown/logging.md new file mode 100644 index 00000000..88ce44c0 --- /dev/null +++ b/dmff/dpnblist/external/doctest-2.4.11/doc/markdown/logging.md @@ -0,0 +1,70 @@ +## Logging macros + +Additional messages can be logged during a test case (safely even in [**concurrent threads**](faq.md#is-doctest-thread-aware)). + +## INFO() + +The ```INFO()``` macro allows heterogeneous sequences of expressions to be captured by listing them with commas. + +```c++ +INFO("The number is ", i); +``` + +This message will be relevant to all asserts after it in the current scope or in scopes nested in the current one and will be printed later only if an assert fails. + +The expression is **NOT** evaluated right away - instead it gets lazily evaluated only when needed. + +Some notes: + +- the lazy stringification means the expressions will be evaluated when an assert fails and not at the point of capture - so the value might have changed by then +- refer to the [**stringification**](stringification.md) page for information on how to teach doctest to stringify your types + +The lazy evaluation means that in the common case when no asserts fail the code runs super fast. This makes it suitable even in loops - perhaps to log the iteration. + +There is also the **```CAPTURE()```** macro which is a convenience wrapper of **```INFO()```**: + +```c++ +CAPTURE(some_variable) +``` + +This will handle the stringification of the variable name for you (actually it works with any expression, not just variables). + +This would log something like: + +```c++ + some_variable := 42 +``` + +## Messages which can optionally fail test cases + +There are a few other macros for logging information: + +- ```MESSAGE(message)``` +- ```FAIL_CHECK(message)``` +- ```FAIL(message)``` + +```FAIL()``` is like a ```REQUIRE``` assert - fails the test case and exits it. ```FAIL_CHECK()``` acts like a ```CHECK``` assert - fails the test case but continues with the execution. ```MESSAGE()``` just prints a message. + +```c++ +FAIL("This is not supposed to happen! some var: ", var); +``` + +Also there is no lazy stringification here - strings are always constructed and printed. + +There are also a few more intended for use by third party libraries such as mocking frameworks: + +- ```ADD_MESSAGE_AT(file, line, message)``` +- ```ADD_FAIL_CHECK_AT(file, line, message)``` +- ```ADD_FAIL_AT(file, line, message)``` + +They can be useful when integrating asserts from a different framework with doctest. + +------ + +- Check out the [**example**](../../examples/all_features/logging.cpp) which shows how all of these are used. + +--- + +[Home](readme.md#reference) + +

diff --git a/dmff/dpnblist/external/doctest-2.4.11/doc/markdown/main.md b/dmff/dpnblist/external/doctest-2.4.11/doc/markdown/main.md new file mode 100644 index 00000000..1df83c15 --- /dev/null +++ b/dmff/dpnblist/external/doctest-2.4.11/doc/markdown/main.md @@ -0,0 +1,62 @@ +## The ```main()``` entry point + +The usual way of writing tests in C++ has always been into separate source files from the code they test that form an executable containing only tests. In that scenario the default ```main()``` provided by **doctest** is usually sufficient: + +```c++ +#define DOCTEST_CONFIG_IMPLEMENT_WITH_MAIN +#include "doctest.h" +``` + +This should be done in exactly one source file and is even a good idea to do this in a separate file with nothing else in it. + +However if you need more control - want to set options with code to the execution context or want to integrate the framework in your production code - then the default ```main()``` just won't do the job. In that case use [**```DOCTEST_CONFIG_IMPLEMENT```**](configuration.md#doctest_config_implement). + +All the [**command line**](commandline.md) options can be set like this (flags cannot because it wouldn't make sense). Filters can only be appended or cleared with the ```addFilter()``` or ```clearFilters()``` method of a ```doctest::Context``` object - the user cannot remove a specific filter with code. + +```c++ +#define DOCTEST_CONFIG_IMPLEMENT +#include "doctest.h" + +int main(int argc, char** argv) { + doctest::Context context; + + // !!! THIS IS JUST AN EXAMPLE SHOWING HOW DEFAULTS/OVERRIDES ARE SET !!! + + // defaults + context.addFilter("test-case-exclude", "*math*"); // exclude test cases with "math" in their name + context.setOption("abort-after", 5); // stop test execution after 5 failed assertions + context.setOption("order-by", "name"); // sort the test cases by their name + + context.applyCommandLine(argc, argv); + + // overrides + context.setOption("no-breaks", true); // don't break in the debugger when assertions fail + + int res = context.run(); // run + + if(context.shouldExit()) // important - query flags (and --exit) rely on the user doing this + return res; // propagate the result of the tests + + int client_stuff_return_code = 0; + // your program - if the testing framework is integrated in your production code + + return res + client_stuff_return_code; // the result from doctest is propagated here as well +} + +``` + +Note the call to ```.shouldExit()``` on the context - that is very important - it will be set when a query flag has been used (or the ```--no-run``` option is set to ```true```) and it is the user's responsibility to exit the application in a normal way. + +### Dealing with shared objects (DLLs) + +The framework can be used separately in binaries (executables / shared objects) with each having its own test runner - this way even different versions of doctest can be used - but there will be no simple way to execute the tests from all loaded binaries and have the results aggregated and summarized. + +There is also an option to have the test runner (implementation) built in a binary and shared with others (so there is a single test registry) by exporting its public symbols (the ones needed for writing tests by the user - all the forward declarations of the framework). + +For more info on that checkout the [**```DOCTEST_CONFIG_IMPLEMENTATION_IN_DLL```**](configuration.md#doctest_config_implementation_in_dll) config identifier and [**this example**](../../examples/executable_dll_and_plugin/). + +--------------- + +[Home](readme.md#reference) + +

diff --git a/dmff/dpnblist/external/doctest-2.4.11/doc/markdown/parameterized-tests.md b/dmff/dpnblist/external/doctest-2.4.11/doc/markdown/parameterized-tests.md new file mode 100644 index 00000000..89286c06 --- /dev/null +++ b/dmff/dpnblist/external/doctest-2.4.11/doc/markdown/parameterized-tests.md @@ -0,0 +1,177 @@ +## Parameterized test cases + +Test cases can be parameterized easily by type and indirectly by value. + +## Value-parameterized test cases + +There will be proper support for this in the future. For now there are 2 ways of doing data-driven testing in doctest: + +- extracting the asserts in a helper function and calling it with a user-constructed array of data: + + ```c++ + void doChecks(int data) { + // do asserts with data + } + + TEST_CASE("test name") { + std::vector data {1, 2, 3, 4, 5, 6}; + + for(auto& i : data) { + CAPTURE(i); // log the current input data + doChecks(i); + } + } + ``` + + This has several drawbacks: + - in case of an exception (or a ```REQUIRE``` assert failing) the entire test case ends and the checks are not done for the rest of the input data + - the user has to manually log the data with calls to ```CAPTURE()``` ( or ```INFO()```) + - more boilerplate - doctest should supply primitives for generating data but currently doesn't - so the user has to write their own data generation + +- using subcases to initialize data differently: + + ```c++ + TEST_CASE("test name") { + int data; + SUBCASE("") { data = 1; } + SUBCASE("") { data = 2; } + + CAPTURE(data); + + // do asserts with data + } + ``` + + This has the following drawbacks: + - doesn't scale well - it is very impractical to write such code for more than a few different inputs + - the user has to manually log the data with calls to ```CAPTURE()``` (or ```INFO()```) + + -------------------------------- + + There is however an easy way to encapsulate this into a macro (written with C++14 for simplicity): + + ```c++ + #include + #include + + #define DOCTEST_VALUE_PARAMETERIZED_DATA(data, data_container) \ + static size_t _doctest_subcase_idx = 0; \ + std::for_each(data_container.begin(), data_container.end(), [&](const auto& in) { \ + DOCTEST_SUBCASE((std::string(#data_container "[") + \ + std::to_string(_doctest_subcase_idx++) + "]").c_str()) { data = in; } \ + }); \ + _doctest_subcase_idx = 0 + ``` + + and now this can be used as follows: + + ```c++ + TEST_CASE("test name") { + int data; + std::list data_container = {1, 2, 3, 4}; // must be iterable - std::vector<> would work as well + + DOCTEST_VALUE_PARAMETERIZED_DATA(data, data_container); + + printf("%d\n", data); + } + ``` + + and will print the 4 numbers by re-entering the test case 3 times (after the first entry) - just like subcases work: + + ``` + 1 + 2 + 3 + 4 + ``` + + The big limitation of this approach is that the macro cannot be used with other subcases at the same code block {} indentation level (will act weird) - it can only be used within a subcase. + +Stay tuned for proper value-parameterization in doctest! + +## Templated test cases - parameterized by type + +Suppose you have multiple implementations of the same interface and want to make sure that all of them satisfy some common requirements. Or, you may have defined several types that are supposed to conform to the same "concept" and you want to verify it. In both cases, you want the same test logic repeated for different types. + +While you can write one ```TEST_CASE``` for each type you want to test (and you may even factor the test logic into a function template that you invoke from the test case), it's tedious and doesn't scale: if you want ```M``` tests over ```N``` types, you'll end up writing ```M * N``` tests. + +Templated tests allow you to repeat the same test logic over a list of types. You only need to write the test logic once. + +There are 2 ways to do it: + +- directly pass the list of types to the templated test case + + ```c++ + TEST_CASE_TEMPLATE("signed integers stuff", T, char, short, int, long long int) { + T var = T(); + --var; + CHECK(var == -1); + } + ``` + +- define the templated test case with a specific unique name (identifier) for later instantiation + + ```c++ + TEST_CASE_TEMPLATE_DEFINE("signed integer stuff", T, test_id) { + T var = T(); + --var; + CHECK(var == -1); + } + + TEST_CASE_TEMPLATE_INVOKE(test_id, char, short, int, long long int); + + TEST_CASE_TEMPLATE_APPLY(test_id, std::tuple); + ``` + If you are designing an interface or concept, you can define a suite of type-parameterized tests to verify properties that any valid implementation of the interface/concept should have. Then, the author of each implementation can just instantiate the test suite with their type to verify that it conforms to the requirements, without having to write similar tests repeatedly. + + +A test case named ```signed integers stuff``` instantiated for type ```int``` will yield the following test case name: + +``` +signed integers stuff +``` + +By default all primitive types (fundamental - ```int```, ```bool```, ```float```...) have stringification provided by the library. For all other types the user will have to use the ```TYPE_TO_STRING(type)``` macro - like this: + +```c++ +TYPE_TO_STRING(std::vector); +``` + +The ```TYPE_TO_STRING``` macro has an effect only in the current source file and thus needs to be used in some header if the same type will be used in separate source files for templated test cases. + +Other testing frameworks use the header `````` in addition to demangling to get the string for types automatically but doctest cannot afford to include any header in its forward declaration part (the public one) of the header - so the user has to teach the framework for each type. This is done to achieve [maximal compile time performance](benchmarks.md). + +Some notes: + +- types are NOT filtered for uniqueness - the same templated test case can be instantiated multiple times for the same type - preventing that is left up to the user +- you don't need to provide stringification for every type as that plays a role only in the test case name - the default is ```<>``` - the tests will still work and be distinct +- if you need parameterization on more than 1 type you can package multiple types in a single one like this: + + ```c++ + template + struct TypePair + { + typedef first A; + typedef second B; + }; + + #define pairs \ + TypePair, \ + TypePair + + TEST_CASE_TEMPLATE("multiple types", T, pairs) { + typedef typename T::A T1; + typedef typename T::B T2; + // use T1 and T2 types + } + ``` + +------ + +- Check out the [**example**](../../examples/all_features/templated_test_cases.cpp) which shows how all of these are used. + +--- + +[Home](readme.md#reference) + +

diff --git a/dmff/dpnblist/external/doctest-2.4.11/doc/markdown/readme.md b/dmff/dpnblist/external/doctest-2.4.11/doc/markdown/readme.md new file mode 100644 index 00000000..1c02d8df --- /dev/null +++ b/dmff/dpnblist/external/doctest-2.4.11/doc/markdown/readme.md @@ -0,0 +1,36 @@ +Reference +======= + +Project: + +- [Features and design goals](features.md) - the complete list of features +- [Community driven roadmap](https://github.com/doctest/doctest/issues/600) - upcoming features +- [Benchmarks](benchmarks.md) - compile-time and runtime supremacy +- [Contributing](../../CONTRIBUTING.md) - how to make a proper pull request +- [Changelog](../../CHANGELOG.md) - generated changelog based on closed issues/PRs + +Usage: + +- [Tutorial](tutorial.md) - make sure you have read it before the other parts of the documentation +- [Assertion macros](assertions.md) +- [Test cases, subcases and test fixtures](testcases.md) +- [Parameterized test cases](parameterized-tests.md) +- [Logging macros](logging.md) +- [Command line](commandline.md) +- [```main()``` entry point](main.md) +- [Configuration](configuration.md) +- [String conversions](stringification.md) +- [Reporters](reporters.md) +- [Extensions](extensions.md) +- [FAQ](faq.md) +- [Build systems](build-systems.md) +- [Examples](../../examples) + +This library is free, and will stay free but needs your support to sustain its development. There are lots of [**new features**](https://github.com/doctest/doctest/issues/600) and maintenance to do. If you work for a company using **doctest** or have the means to do so, please consider financial support. + +[![Patreon](https://cloud.githubusercontent.com/assets/8225057/5990484/70413560-a9ab-11e4-8942-1a63607c0b00.png)](http://www.patreon.com/onqtam) +[![PayPal](https://www.paypalobjects.com/en_US/i/btn/btn_donate_LG.gif)](https://www.paypal.me/onqtam/10) + +------------ + +

diff --git a/dmff/dpnblist/external/doctest-2.4.11/doc/markdown/reporters.md b/dmff/dpnblist/external/doctest-2.4.11/doc/markdown/reporters.md new file mode 100644 index 00000000..8de75214 --- /dev/null +++ b/dmff/dpnblist/external/doctest-2.4.11/doc/markdown/reporters.md @@ -0,0 +1,106 @@ +## Reporters + +Doctest has a modular reporter/listener system with which users can write their own reporters and register them. The reporter interface can also be used for "listening" to events. + +You can list all registered reporters/listeners with ```--list-reporters```. There are a few implemented reporters in the framework: +- ```console``` - streaming - writes normal lines of text with coloring if a capable terminal is detected +- ```xml``` - streaming - writes in xml format tailored to doctest +- ```junit``` - buffering - writes in JUnit-compatible xml - for more information look [here](https://github.com/doctest/doctest/issues/318) and [here](https://github.com/doctest/doctest/issues/376). + +Streaming means that results are delivered progressively and not at the end of the test run. + +The output is by default written to ```stdout``` but can be redirected with the use of the ```--out=``` [**command line option**](commandline.md). + +Example how to define your own reporter: + +```c++ +#include + +#include + +using namespace doctest; + +struct MyXmlReporter : public IReporter +{ + // caching pointers/references to objects of these types - safe to do + std::ostream& stdout_stream; + const ContextOptions& opt; + const TestCaseData* tc; + std::mutex mutex; + + // constructor has to accept the ContextOptions by ref as a single argument + MyXmlReporter(const ContextOptions& in) + : stdout_stream(*in.cout) + , opt(in) {} + + void report_query(const QueryData& /*in*/) override {} + + void test_run_start() override {} + + void test_run_end(const TestRunStats& /*in*/) override {} + + void test_case_start(const TestCaseData& in) override { tc = ∈ } + + // called when a test case is reentered because of unfinished subcases + void test_case_reenter(const TestCaseData& /*in*/) override {} + + void test_case_end(const CurrentTestCaseStats& /*in*/) override {} + + void test_case_exception(const TestCaseException& /*in*/) override {} + + void subcase_start(const SubcaseSignature& /*in*/) override { + std::lock_guard lock(mutex); + } + + void subcase_end() override { + std::lock_guard lock(mutex); + } + + void log_assert(const AssertData& in) override { + // don't include successful asserts by default - this is done here + // instead of in the framework itself because doctest doesn't know + // if/when a reporter/listener cares about successful results + if(!in.m_failed && !opt.success) + return; + + // make sure there are no races - this is done here instead of in the + // framework itself because doctest doesn't know if reporters/listeners + // care about successful asserts and thus doesn't lock a mutex unnecessarily + std::lock_guard lock(mutex); + + // ... + } + + void log_message(const MessageData& /*in*/) override { + // messages too can be used in a multi-threaded context - like asserts + std::lock_guard lock(mutex); + + // ... + } + + void test_case_skipped(const TestCaseData& /*in*/) override {} +}; + +// "1" is the priority - used for ordering when multiple reporters are used +REGISTER_REPORTER("my_xml", 1, MyXmlReporter); + +// registering the same class as a reporter and as a listener is nonsense but it's possible +REGISTER_LISTENER("my_listener", 1, MyXmlReporter); +``` + +Custom `IReporter` implementations must be registered with one of: + +* `REGISTER_REPORTER`, for when the new reporter is an option that users may choose at run-time. +* `REGISTER_LISTENER`, for when the reporter is actually a listener and must always be executed, regardless of which reporters have been chosen at run-time. + +Multiple reporters can be used at the same time - just specify them through the ```--reporters=...``` [**command line filtering option**](commandline.md) using commas to separate them like this: ```--reporters=myReporter,xml``` and their order of execution will be based on their priority - that is the number "1" in the case of the example reporter above (lower means earlier - the default console/xml reporters from the framework have 0 as their priority and negative numbers are accepted as well). + +All registered listeners (```REGISTER_LISTENER```) will be executed before any reporter - they do not need to be specified and cannot be filtered through the command line. + +When implementing a reporter users are advised to follow the comments from the example above and look at the few implemented reporters in the framework itself. Also check out the [**example**](../../examples/all_features/reporters_and_listeners.cpp). + +--------------- + +[Home](readme.md#reference) + +

diff --git a/dmff/dpnblist/external/doctest-2.4.11/doc/markdown/stringification.md b/dmff/dpnblist/external/doctest-2.4.11/doc/markdown/stringification.md new file mode 100644 index 00000000..75d34339 --- /dev/null +++ b/dmff/dpnblist/external/doctest-2.4.11/doc/markdown/stringification.md @@ -0,0 +1,95 @@ +## String conversions + +**doctest** needs to be able to convert types you use in assertions and logging expressions into strings (for logging and reporting purposes). +Most built-in types are supported out of the box but there are three ways that you can tell **doctest** how to convert your own types (or other, third-party types) into strings. + +For stringifying enums checkout [this issue](https://github.com/doctest/doctest/issues/121). + +## ```operator<<``` overload for ```std::ostream``` + +This is the standard way of providing string conversions in C++ - and the chances are you may already provide this for your own purposes. If you're not familiar with this idiom it involves writing a free function of the form: + +```c++ +std::ostream& operator<< (std::ostream& os, const T& value) { + os << convertMyTypeToString(value); + return os; +} +``` + +(where ```T``` is your type and ```convertMyTypeToString``` is where you'll write whatever code is necessary to make your type printable - it doesn't have to be in another function). + +You should put this function in the same namespace as your type. + +Alternatively you may prefer to write it as a member function: + +```c++ +std::ostream& T::operator<<(std::ostream& os) const { + os << convertMyTypeToString(*this); + return os; +} +``` + +## ```doctest::toString``` overload + +If you don't want to provide an ```operator<<``` overload, or you want to convert your type differently for testing purposes, you can provide an overload for ```toString()``` for your type which returns ```doctest::String```. + +```c++ +namespace user { + struct udt {}; + + doctest::String toString(const udt& value) { + return convertMyTypeToString(value); + } +} +``` + +Note that the function must be in the same namespace as your type. If the type is not in any namespace - then the overload should be in the global namespace as well. ```convertMyTypeToString``` is where you'll write whatever code is necessary to make your type printable. + +## ```doctest::StringMaker``` specialisation + +There are some cases where overloading ```toString``` does not work as expected. Specialising ```StringMaker``` gives you more precise and reliable control - but at the cost of slightly more code and complexity: + +```c++ +namespace doctest { + template<> struct StringMaker { + static String convert(const T& value) { + return convertMyTypeToString(value); + } + }; +} +``` + +## Translating exceptions + +By default all exceptions deriving from ```std::exception``` will be translated to strings by calling the ```what()``` method (also C strings). For exception types that do not derive from ```std::exception``` - or if ```what()``` does not return a suitable string - use ```REGISTER_EXCEPTION_TRANSLATOR```. This defines a function that takes your exception type and returns a ```doctest::String```. It can appear anywhere in the code - it doesn't have to be in the same translation unit. For example: + +```c++ +REGISTER_EXCEPTION_TRANSLATOR(MyType& ex) { + return doctest::String(ex.message()); +} +``` + +Note that the exception may be accepted without a reference but it is considered bad practice in C++. + +An alternative way to register an exception translator is to do the following in some function - before executing any tests: + +```c++ + // adding a lambda - the signature required is `doctest::String(exception_type)` + doctest::registerExceptionTranslator([](int in){ return doctest::toString(in); }); +``` + +The order of registering exception translators can be controlled - simply call the explicit function in the required order or list the exception translators with the macro in a top-to-bottom fashion in a single translation unit - everything that auto-registers in doctest works in a top-to-bottom way for a single translation unit (source file). + +You could also [override the translation mechanism](https://github.com/catchorg/Catch2/issues/539#issuecomment-454549904) for exceptions deriving from ```std::exception```. + +------ + +- Check out the [**example**](../../examples/all_features/stringification.cpp) which shows how to stringify ```std::vector``` and other types/exceptions. +- Note that the type ```String``` is used when specializing ```StringMaker``` or overloading ```toString()``` - it is the string type **doctest** works with. ```std::string``` is not an option because doctest would have to include the `````` header. +- To support the ```operator<<(std::ostream&...``` stringification the library has to offer a forward declaration of ```std::ostream``` and that is what the library does - but it is forbidden by the standard. It currently works everywhere - on all tested compilers - but if the user wishes to be 100% standards compliant - then the [**```DOCTEST_CONFIG_USE_STD_HEADERS```**](configuration.md#doctest_config_use_std_headers) identifier can be used to force the inclusion of ``````. The reason the header is not included by default is that on MSVC (for example) it drags a whole bunch of stuff with it - and after the preprocessor is finished the translation unit has grown to 42k lines of C++ code - while Clang and the libc++ are so well implemented that including `````` there results in 400 lines of code. + +--- + +[Home](readme.md#reference) + +

diff --git a/dmff/dpnblist/external/doctest-2.4.11/doc/markdown/testcases.md b/dmff/dpnblist/external/doctest-2.4.11/doc/markdown/testcases.md new file mode 100644 index 00000000..ecb5b3a4 --- /dev/null +++ b/dmff/dpnblist/external/doctest-2.4.11/doc/markdown/testcases.md @@ -0,0 +1,172 @@ +## Test cases + +While **doctest** fully supports the traditional, xUnit, style of class-based fixtures containing test case methods this is not the preferred style. Instead **doctest** provides a powerful mechanism for nesting subcases within a test case. For a more detailed discussion and examples see the [**tutorial**](tutorial.md#test-cases-and-subcases). + +Test cases and subcases are very easy to use in practice: + +* **TEST_CASE(** _test name_ **)** +* **SUBCASE(** _subcase name_ **)** + +_test name_ and _subcase name_ are free form, quoted, strings. Test names don't have to be unique within the **doctest** executable. They should also be string literals. + +It is possible to write test cases inside of class bodies in C++17 with the help of ```TEST_CASE_CLASS()``` - used just like ```TEST_CASE()``` - making testing private parts of classes easier. + +Keep in mind that even though **doctest** is [**thread-safe**](faq.md#is-doctest-thread-aware) - using subcases has to be done only in the main test runner thread. + +Test cases can also be parameterized - see the [**documentation**](parameterized-tests.md) + +Test cases and subcases can be filtered through the use of the [**command line**](commandline.md) + +## BDD-style test cases + +In addition to **doctest**'s take on the classic style of test cases, **doctest** supports an alternative syntax that allow tests to be written as "executable specifications" (one of the early goals of [Behaviour Driven Development](http://dannorth.net/introducing-bdd/)). This set of macros map on to ```TEST_CASE```s and ```SUBCASE```s, with a little internal support to make them smoother to work with. + +* **SCENARIO(** _scenario name_ **)** + +This macro maps onto ```TEST_CASE``` and works in the same way, except that the test case name will be prefixed by "Scenario: " + +* **SCENARIO_TEMPLATE(** _scenario name_, _type_, _list of types_ **)** + +This macro maps onto ```TEST_CASE_TEMPLATE``` and works in the same way, except that the test case name will be prefixed by "Scenario: " + +* **SCENARIO_TEMPLATE_DEFINE(** _scenario name_, _type_, _id_ **)** + +This macro maps onto ```TEST_CASE_TEMPLATE_DEFINE``` and works in the same way, except that the test case name will be prefixed by "Scenario: " + +* **GIVEN(** _something_ **)** +* **WHEN(** _something_ **)** +* **THEN(** _something_ **)** + +These macros map onto ```SUBCASE```s except that the subcase names are the _something_s prefixed by "given: ", "when: " or "then: " respectively. + +* **AND_WHEN(** _something_ **)** +* **AND_THEN(** _something_ **)** + +Similar to ```WHEN``` and ```THEN``` except that the prefixes start with "and ". These are used to chain ```WHEN```s and ```THEN```s together. + +When any of these macros are used the console reporter recognises them and formats the test case header such that the Givens, Whens and Thens are aligned to aid readability. + +Other than the additional prefixes and the formatting in the console reporter these macros behave exactly as ```TEST_CASE```s and ```SUBCASE```s. As such there is nothing enforcing the correct sequencing of these macros - that's up to the programmer! + +Note that when using the [`--test-case=`](https://github.com/doctest/doctest/blob/master/doc/markdown/commandline.md) command line option (or `--subcase=`) you will have to pass the prefix `Scenario: ` as well. + +## Test fixtures + +Although **doctest** allows you to group tests together as subcases within a test case, it can still be convenient, sometimes, to group them using a more traditional test fixture. **doctest** fully supports this too. You define the test fixture as a simple structure: + +```c++ +class UniqueTestsFixture { +private: + static int uniqueID; +protected: + DBConnection conn; +public: + UniqueTestsFixture() : conn(DBConnection::createConnection("myDB")) {} +protected: + int getID() { + return ++uniqueID; + } +}; + +int UniqueTestsFixture::uniqueID = 0; + +TEST_CASE_FIXTURE(UniqueTestsFixture, "Create Employee/No Name") { + REQUIRE_THROWS(conn.executeSQL("INSERT INTO employee (id, name) VALUES (?, ?)", getID(), "")); +} +TEST_CASE_FIXTURE(UniqueTestsFixture, "Create Employee/Normal") { + REQUIRE(conn.executeSQL("INSERT INTO employee (id, name) VALUES (?, ?)", getID(), "Joe Bloggs")); +} +``` + +The two test cases here will create uniquely-named derived classes of UniqueTestsFixture and thus can access the `getID()` protected method and `conn` member variables. This ensures that both the test cases are able to create a DBConnection using the same method (DRY principle) and that any ID's created are unique such that the order that tests are executed does not matter. + +## Test suites + +Test cases can be grouped into test suites. This is done with ```TEST_SUITE()``` or ```TEST_SUITE_BEGIN()``` / ```TEST_SUITE_END()```. + +For example: + +```c++ +TEST_CASE("") {} // not part of any test suite + +TEST_SUITE("math") { + TEST_CASE("") {} // part of the math test suite + TEST_CASE("") {} // part of the math test suite +} + +TEST_SUITE_BEGIN("utils"); + +TEST_CASE("") {} // part of the utils test suite + +TEST_SUITE_END(); + +TEST_CASE("") {} // not part of any test suite +``` + +Then test cases from specific test suites can be executed with the help of filters - check out the [**command line**](commandline.md) + +## Decorators + +Test cases can be *decorated* with additional attributes like this: + +```c++ +TEST_CASE("name" + * doctest::description("shouldn't take more than 500ms") + * doctest::timeout(0.5)) { + // asserts +} +``` + +Multiple decorators can be used at the same time. These are the currently supported decorators: + +- **```skip(bool = true)```** - marks the test case to be skipped from execution - unless the ```--no-skip``` option is used +- **```no_breaks(bool = true)```** - no breaking into the debugger for asserts in the test case - useful in combination with `may_fail`/`should_fail`/`expected_failures` +- **```no_output(bool = true)```** - no output from asserts in the test case - useful in combination with `may_fail`/`should_fail`/`expected_failures` +- **```may_fail(bool = true)```** - doesn't fail the test if any given assertion fails (but still reports it) - this can be useful to flag a work-in-progress, or a known issue that you don't want to immediately fix but still want to track in your tests +- **```should_fail(bool = true)```** - like **```may_fail()```** but fails the test if it passes - this can be useful if you want to be notified of accidental, or third-party, fixes +- **```expected_failures(int)```** - defines the number of assertions that are expected to fail within the test case - reported as failure when the number of failed assertions is different than the declared expected number of failures +- **```timeout(double)```** - fails the test case if its execution exceeds this limit (in seconds) - but doesn't terminate it - that would require subprocess support +- **```test_suite("name")```** - can be used on test cases to override (or just set) the test suite they are in +- **```description("text")```** - a description of the test case + +The values that the decorators take are computed while registering the test cases (during global initialization) - before entering ```main()``` and not just before running them. + +Decorators can also be applied to test suite blocks and all test cases in that block inherit them: + +```c++ +TEST_SUITE("some TS" * doctest::description("all tests will have this")) { + TEST_CASE("has a description from the surrounding test suite") { + // asserts + } +} +TEST_SUITE("some TS") { + TEST_CASE("no description even though in the same test suite as the one above") { + // asserts + } +} +``` + +Test cases can override the decorators that they inherit from their surrounding test suite: + +```c++ +TEST_SUITE("not longer than 500ms" * doctest::timeout(0.5)) { + TEST_CASE("500ms limit") { + // asserts + } + TEST_CASE("200ms limit" * doctest::timeout(0.2)) { + // asserts + } +} +``` + +------ + +- Check out the [**subcases and BDD example**](../../examples/all_features/subcases.cpp) +- Check out the [**assertion macros example**](../../examples/all_features/assertion_macros.cpp) to see how test suites are used +- Tests are registered from top to bottom of each processed cpp after the headers have been preprocessed and included but there is no ordering between cpp files. + +--------------- + +[Home](readme.md#reference) + +

diff --git a/dmff/dpnblist/external/doctest-2.4.11/doc/markdown/tutorial.md b/dmff/dpnblist/external/doctest-2.4.11/doc/markdown/tutorial.md new file mode 100644 index 00000000..fd902bc1 --- /dev/null +++ b/dmff/dpnblist/external/doctest-2.4.11/doc/markdown/tutorial.md @@ -0,0 +1,205 @@ +## Tutorial + +To get started with **doctest** all you need is to download the [**latest version**](https://raw.githubusercontent.com/doctest/doctest/master/doctest/doctest.h) which is just a single header and include it in your source files (or add this repository as a git submodule). + +This tutorial assumes you can use the header directly: ```#include "doctest.h"``` - so it is either in the same folder with your test source files or you have set up the include paths to it in your build system properly. + +[TDD](https://en.wikipedia.org/wiki/Test-driven_development) is not discussed in this tutorial. + +## A simple example + +Suppose we have a ```factorial()``` function that we want to test: + +```c++ +int factorial(int number) { return number <= 1 ? number : factorial(number - 1) * number; } +``` + +A complete compiling example with a self-registering test looks like this: + +```c++ +#define DOCTEST_CONFIG_IMPLEMENT_WITH_MAIN +#include "doctest.h" + +int factorial(int number) { return number <= 1 ? number : factorial(number - 1) * number; } + +TEST_CASE("testing the factorial function") { + CHECK(factorial(1) == 1); + CHECK(factorial(2) == 2); + CHECK(factorial(3) == 6); + CHECK(factorial(10) == 3628800); +} +``` + +This will compile to a complete executable which responds to command line arguments. If you just run it with no arguments it will execute all test cases (in this case - just one), report any failures, report a summary of how many tests passed and failed and returns 0 on success and 1 if anything failed (useful if you just want a yes/no answer to: "did it work"). + +If you run this as written it will pass. Everything is good. Right? Well there is still a bug here. We missed to check if ```factorial(0) == 1``` so let's add that check as well: + +```c++ +TEST_CASE("testing the factorial function") { + CHECK(factorial(0) == 1); + CHECK(factorial(1) == 1); + CHECK(factorial(2) == 2); + CHECK(factorial(3) == 6); + CHECK(factorial(10) == 3628800); +} +``` + +Now we get a failure - something like: + +``` +test.cpp(7) FAILED! + CHECK( factorial(0) == 1 ) +with expansion: + CHECK( 0 == 1 ) +``` + +Note that we get the actual return value of ```factorial(0)``` printed for us (0) - even though we used a natural expression with the ```==``` operator. That lets us immediately see what the problem is. + +Let's change the factorial function to: + +```c++ +int factorial(int number) { return number > 1 ? factorial(number - 1) * number : 1; } +``` + +Now all the tests pass. + +Of course there are still more issues to do deal with. For example we'll hit problems when the return value starts to exceed the range of an int. With factorials that can happen quite quickly. You might want to add tests for such cases and decide how to handle them. We'll stop short of doing that here. + +## What did we do here? + +Although this was a simple test it's been enough to demonstrate a few things about how **doctest** is used. + +1. All we did was ```#define``` one identifier and ```#include``` one header and we got everything - even an implementation of ```main()``` that will respond to command line arguments. You can only use that ```#define``` in one source file for (hopefully) obvious reasons. Once you have more than one file with unit tests in you'll just ```#include "doctest.h"``` and go. Usually it's a good idea to have a dedicated implementation file that just has ```#define DOCTEST_CONFIG_IMPLEMENT_WITH_MAIN``` and ```#include "doctest.h"```. You can also provide your own implementation of main and drive **doctest** yourself - see [**supplying your own ```main()```**](main.md). +2. We introduce test cases with the ```TEST_CASE``` macro. It takes one argument - a free form test name (for more see [**Test cases and subcases**](testcases.md)). The test name doesn't have to be unique. You can run sets of tests by specifying a wildcarded test name or a tag expression. See the [**command line**](commandline.md) docs for more information on running tests. +3. The name is just a string. We haven't had to declare a function or method - or explicitly register the test case anywhere. Behind the scenes a function with a generated name is defined for you and automatically registered using static registry classes. By abstracting the function name away we can name our tests without the constraints of identifier names. +4. We write our individual test assertions using the ```CHECK()``` macro. Rather than a separate macro for each type of condition (equal, less than, greater than, etc.) we express the condition naturally using C++ syntax. Behind the scenes a simple expression template captures the left-hand-side and right-hand-side of the expression so we can display the values in our test report. There are other [**assertion macros**](assertions.md) not covered in this tutorial - but because of this technique the number of them is drastically reduced. + +## Test cases and subcases + +Most test frameworks have a class-based fixture mechanism - test cases map to methods on a class and common setup and teardown can be performed in ```setup()``` and ```teardown()``` methods (or constructor/ destructor in languages like C++ that support deterministic destruction). + +While **doctest** fully supports this way of working there are a few problems with the approach. In particular the way your code must be split up and the blunt granularity of it may cause problems. You can only have one setup/ teardown pair across a set of methods but sometimes you want slightly different setup in each method or you may even want several levels of setup (a concept which we will clarify later on in this tutorial). It was [**problems like these**](http://jamesnewkirk.typepad.com/posts/2007/09/why-you-should-.html) that led James Newkirk who led the team that built NUnit to start again from scratch and build [**xUnit**](http://jamesnewkirk.typepad.com/posts/2007/09/announcing-xuni.html)). + +**doctest** takes a different approach (to both NUnit and xUnit) that is a more natural fit for C++ and the C family of languages. + +This is best explained through an example: + +```c++ +TEST_CASE("vectors can be sized and resized") { + std::vector v(5); + + REQUIRE(v.size() == 5); + REQUIRE(v.capacity() >= 5); + + SUBCASE("adding to the vector increases its size") { + v.push_back(1); + + CHECK(v.size() == 6); + CHECK(v.capacity() >= 6); + } + SUBCASE("reserving increases just the capacity") { + v.reserve(6); + + CHECK(v.size() == 5); + CHECK(v.capacity() >= 6); + } +} +``` + +For each ```SUBCASE()``` the ```TEST_CASE()``` is executed from the start - so as we enter each subcase we know that the size is 5 and the capacity is at least 5. We enforce those requirements with the ```REQUIRE()``` macros at the top level so we can be confident in them. If a ```CHECK()``` fails - the test is marked as failed but the execution continues - but if a ```REQUIRE()``` fails - execution of the test stops. + +This works because the ```SUBCASE()``` macro contains an if statement that calls back into **doctest** to see if the subcase should be executed. One leaf subcase is executed on each run through a ```TEST_CASE()```. The other subcases are skipped. Next time the next subcase is executed and so on until no new subcases are encountered. + +So far so good - this is already an improvement on the setup/teardown approach because now we see our setup code inline and use the stack. The power of subcases really shows when we start nesting them like in the example below: + +
+Code + +Output +
+
+#define DOCTEST_CONFIG_IMPLEMENT_WITH_MAIN
+#include "doctest.h"
+
+#include <iostream> +using namespace std; +
+TEST_CASE("lots of nested subcases") { +    cout << endl << "root" << endl; +    SUBCASE("") { +        cout << "1" << endl; +        SUBCASE("") { cout << "1.1" << endl; } +    } +    SUBCASE("") { +        cout << "2" << endl; +        SUBCASE("") { cout << "2.1" << endl; } +        SUBCASE("") { +            cout << "2.2" << endl; +            SUBCASE("") { +                cout << "2.2.1" << endl; +                SUBCASE("") { cout << "2.2.1.1" << endl; } +                SUBCASE("") { cout << "2.2.1.2" << endl; } +            } +        } +        SUBCASE("") { cout << "2.3" << endl; } +        SUBCASE("") { cout << "2.4" << endl; } +    } +} +
+
+
+root
+1
+1.1
+root +2 +2.1
+root +2 +2.2 +2.2.1 +2.2.1.1
+root +2 +2.2 +2.2.1 +2.2.1.2
+root +2 +2.3
+root +2 +2.4 +
+
+ +Subcases can be nested to an arbitrary depth (limited only by your stack size). Each leaf subcase (a subcase that contains no nested subcases) will be executed exactly once on a separate path of execution from any other leaf subcase (so no leaf subcase can interfere with another). A fatal failure in a parent subcase will prevent nested subcases from running - but then that's the idea. + +Keep in mind that even though **doctest** is [**thread-safe**](faq.md#is-doctest-thread-aware) - using subcases has to be done only in the main test runner thread and all threads spawned in a subcase ought to be joined before the end of that subcase and no new subcases should be entered while other threads with doctest assertions in them are still running. + +## Scaling up + +To keep the tutorial simple we put all our code in a single file. This is fine to get started - and makes jumping into **doctest** even quicker and easier. This is not really the best approach when you start writing more real-world tests. + +The requirement is that the following block of code ([**or equivalent**](main.md)): + +```c++ +#define DOCTEST_CONFIG_IMPLEMENT_WITH_MAIN +#include "doctest.h" +``` + +appears in _exactly_ one translation unit (source file). Use as many additional source files as you need for your tests - partitioned however makes most sense for your way of working. Each additional file needs only to ```#include "doctest.h"``` - do not repeat the ```#define```! + +In fact it is usually a good idea to put the block with the ```#define``` in its own source file. + +## Next steps + +This has been a brief introduction to get you up and running with **doctest** and to point out some of the key differences between **doctest** and other frameworks you may already be familiar with. This will get you going quite far already and you are now in a position to dive in and write some tests. + +Of course there is more to learn - see the ever-growing [**reference**](readme.md#reference) section for what's available. + +--------------- + +[Home](readme.md#reference) + +

diff --git a/dmff/dpnblist/external/doctest-2.4.11/doctest/BUILD.bazel b/dmff/dpnblist/external/doctest-2.4.11/doctest/BUILD.bazel new file mode 100644 index 00000000..1c28c8f3 --- /dev/null +++ b/dmff/dpnblist/external/doctest-2.4.11/doctest/BUILD.bazel @@ -0,0 +1,32 @@ +cc_library( + name = "doctest", + hdrs = glob(["**/*.h"]), + defines = [ + "DOCTEST_CONFIG_IMPLEMENTATION_IN_DLL", + "DOCTEST_CONFIG_NO_UNPREFIXED_OPTIONS", + ], + visibility = ["//visibility:public"], +) + +genrule( + name = "dummy-main", + outs = ["dummy-main.cc"], + cmd = """ + echo '#include "doctest/doctest.h"' > $@ + """, +) + +cc_library( + name = "main", + srcs = glob(["**/*.h"]) + ["dummy-main.cc"], + local_defines = ["DOCTEST_CONFIG_IMPLEMENT_WITH_MAIN"], + visibility = ["//visibility:public"], +) + +cc_library( + name = "custom_main", + srcs = glob(["**/*.h"]) + ["dummy-main.cc"], + local_defines = ["DOCTEST_CONFIG_IMPLEMENT"], + visibility = ["//visibility:public"], +) + diff --git a/dmff/dpnblist/external/doctest-2.4.11/doctest/doctest.h b/dmff/dpnblist/external/doctest-2.4.11/doctest/doctest.h new file mode 100644 index 00000000..5c754cde --- /dev/null +++ b/dmff/dpnblist/external/doctest-2.4.11/doctest/doctest.h @@ -0,0 +1,7106 @@ +// ====================================================================== lgtm [cpp/missing-header-guard] +// == DO NOT MODIFY THIS FILE BY HAND - IT IS AUTO GENERATED BY CMAKE! == +// ====================================================================== +// +// doctest.h - the lightest feature-rich C++ single-header testing framework for unit tests and TDD +// +// Copyright (c) 2016-2023 Viktor Kirilov +// +// Distributed under the MIT Software License +// See accompanying file LICENSE.txt or copy at +// https://opensource.org/licenses/MIT +// +// The documentation can be found at the library's page: +// https://github.com/doctest/doctest/blob/master/doc/markdown/readme.md +// +// ================================================================================================= +// ================================================================================================= +// ================================================================================================= +// +// The library is heavily influenced by Catch - https://github.com/catchorg/Catch2 +// which uses the Boost Software License - Version 1.0 +// see here - https://github.com/catchorg/Catch2/blob/master/LICENSE.txt +// +// The concept of subcases (sections in Catch) and expression decomposition are from there. +// Some parts of the code are taken directly: +// - stringification - the detection of "ostream& operator<<(ostream&, const T&)" and StringMaker<> +// - the Approx() helper class for floating point comparison +// - colors in the console +// - breaking into a debugger +// - signal / SEH handling +// - timer +// - XmlWriter class - thanks to Phil Nash for allowing the direct reuse (AKA copy/paste) +// +// The expression decomposing templates are taken from lest - https://github.com/martinmoene/lest +// which uses the Boost Software License - Version 1.0 +// see here - https://github.com/martinmoene/lest/blob/master/LICENSE.txt +// +// ================================================================================================= +// ================================================================================================= +// ================================================================================================= + +#ifndef DOCTEST_LIBRARY_INCLUDED +#define DOCTEST_LIBRARY_INCLUDED + +// ================================================================================================= +// == VERSION ====================================================================================== +// ================================================================================================= + +#define DOCTEST_VERSION_MAJOR 2 +#define DOCTEST_VERSION_MINOR 4 +#define DOCTEST_VERSION_PATCH 11 + +// util we need here +#define DOCTEST_TOSTR_IMPL(x) #x +#define DOCTEST_TOSTR(x) DOCTEST_TOSTR_IMPL(x) + +#define DOCTEST_VERSION_STR \ + DOCTEST_TOSTR(DOCTEST_VERSION_MAJOR) "." \ + DOCTEST_TOSTR(DOCTEST_VERSION_MINOR) "." \ + DOCTEST_TOSTR(DOCTEST_VERSION_PATCH) + +#define DOCTEST_VERSION \ + (DOCTEST_VERSION_MAJOR * 10000 + DOCTEST_VERSION_MINOR * 100 + DOCTEST_VERSION_PATCH) + +// ================================================================================================= +// == COMPILER VERSION ============================================================================= +// ================================================================================================= + +// ideas for the version stuff are taken from here: https://github.com/cxxstuff/cxx_detect + +#ifdef _MSC_VER +#define DOCTEST_CPLUSPLUS _MSVC_LANG +#else +#define DOCTEST_CPLUSPLUS __cplusplus +#endif + +#define DOCTEST_COMPILER(MAJOR, MINOR, PATCH) ((MAJOR)*10000000 + (MINOR)*100000 + (PATCH)) + +// GCC/Clang and GCC/MSVC are mutually exclusive, but Clang/MSVC are not because of clang-cl... +#if defined(_MSC_VER) && defined(_MSC_FULL_VER) +#if _MSC_VER == _MSC_FULL_VER / 10000 +#define DOCTEST_MSVC DOCTEST_COMPILER(_MSC_VER / 100, _MSC_VER % 100, _MSC_FULL_VER % 10000) +#else // MSVC +#define DOCTEST_MSVC \ + DOCTEST_COMPILER(_MSC_VER / 100, (_MSC_FULL_VER / 100000) % 100, _MSC_FULL_VER % 100000) +#endif // MSVC +#endif // MSVC +#if defined(__clang__) && defined(__clang_minor__) && defined(__clang_patchlevel__) +#define DOCTEST_CLANG DOCTEST_COMPILER(__clang_major__, __clang_minor__, __clang_patchlevel__) +#elif defined(__GNUC__) && defined(__GNUC_MINOR__) && defined(__GNUC_PATCHLEVEL__) && \ + !defined(__INTEL_COMPILER) +#define DOCTEST_GCC DOCTEST_COMPILER(__GNUC__, __GNUC_MINOR__, __GNUC_PATCHLEVEL__) +#endif // GCC +#if defined(__INTEL_COMPILER) +#define DOCTEST_ICC DOCTEST_COMPILER(__INTEL_COMPILER / 100, __INTEL_COMPILER % 100, 0) +#endif // ICC + +#ifndef DOCTEST_MSVC +#define DOCTEST_MSVC 0 +#endif // DOCTEST_MSVC +#ifndef DOCTEST_CLANG +#define DOCTEST_CLANG 0 +#endif // DOCTEST_CLANG +#ifndef DOCTEST_GCC +#define DOCTEST_GCC 0 +#endif // DOCTEST_GCC +#ifndef DOCTEST_ICC +#define DOCTEST_ICC 0 +#endif // DOCTEST_ICC + +// ================================================================================================= +// == COMPILER WARNINGS HELPERS ==================================================================== +// ================================================================================================= + +#if DOCTEST_CLANG && !DOCTEST_ICC +#define DOCTEST_PRAGMA_TO_STR(x) _Pragma(#x) +#define DOCTEST_CLANG_SUPPRESS_WARNING_PUSH _Pragma("clang diagnostic push") +#define DOCTEST_CLANG_SUPPRESS_WARNING(w) DOCTEST_PRAGMA_TO_STR(clang diagnostic ignored w) +#define DOCTEST_CLANG_SUPPRESS_WARNING_POP _Pragma("clang diagnostic pop") +#define DOCTEST_CLANG_SUPPRESS_WARNING_WITH_PUSH(w) \ + DOCTEST_CLANG_SUPPRESS_WARNING_PUSH DOCTEST_CLANG_SUPPRESS_WARNING(w) +#else // DOCTEST_CLANG +#define DOCTEST_CLANG_SUPPRESS_WARNING_PUSH +#define DOCTEST_CLANG_SUPPRESS_WARNING(w) +#define DOCTEST_CLANG_SUPPRESS_WARNING_POP +#define DOCTEST_CLANG_SUPPRESS_WARNING_WITH_PUSH(w) +#endif // DOCTEST_CLANG + +#if DOCTEST_GCC +#define DOCTEST_PRAGMA_TO_STR(x) _Pragma(#x) +#define DOCTEST_GCC_SUPPRESS_WARNING_PUSH _Pragma("GCC diagnostic push") +#define DOCTEST_GCC_SUPPRESS_WARNING(w) DOCTEST_PRAGMA_TO_STR(GCC diagnostic ignored w) +#define DOCTEST_GCC_SUPPRESS_WARNING_POP _Pragma("GCC diagnostic pop") +#define DOCTEST_GCC_SUPPRESS_WARNING_WITH_PUSH(w) \ + DOCTEST_GCC_SUPPRESS_WARNING_PUSH DOCTEST_GCC_SUPPRESS_WARNING(w) +#else // DOCTEST_GCC +#define DOCTEST_GCC_SUPPRESS_WARNING_PUSH +#define DOCTEST_GCC_SUPPRESS_WARNING(w) +#define DOCTEST_GCC_SUPPRESS_WARNING_POP +#define DOCTEST_GCC_SUPPRESS_WARNING_WITH_PUSH(w) +#endif // DOCTEST_GCC + +#if DOCTEST_MSVC +#define DOCTEST_MSVC_SUPPRESS_WARNING_PUSH __pragma(warning(push)) +#define DOCTEST_MSVC_SUPPRESS_WARNING(w) __pragma(warning(disable : w)) +#define DOCTEST_MSVC_SUPPRESS_WARNING_POP __pragma(warning(pop)) +#define DOCTEST_MSVC_SUPPRESS_WARNING_WITH_PUSH(w) \ + DOCTEST_MSVC_SUPPRESS_WARNING_PUSH DOCTEST_MSVC_SUPPRESS_WARNING(w) +#else // DOCTEST_MSVC +#define DOCTEST_MSVC_SUPPRESS_WARNING_PUSH +#define DOCTEST_MSVC_SUPPRESS_WARNING(w) +#define DOCTEST_MSVC_SUPPRESS_WARNING_POP +#define DOCTEST_MSVC_SUPPRESS_WARNING_WITH_PUSH(w) +#endif // DOCTEST_MSVC + +// ================================================================================================= +// == COMPILER WARNINGS ============================================================================ +// ================================================================================================= + +// both the header and the implementation suppress all of these, +// so it only makes sense to aggregate them like so +#define DOCTEST_SUPPRESS_COMMON_WARNINGS_PUSH \ + DOCTEST_CLANG_SUPPRESS_WARNING_PUSH \ + DOCTEST_CLANG_SUPPRESS_WARNING("-Wunknown-pragmas") \ + DOCTEST_CLANG_SUPPRESS_WARNING("-Wweak-vtables") \ + DOCTEST_CLANG_SUPPRESS_WARNING("-Wpadded") \ + DOCTEST_CLANG_SUPPRESS_WARNING("-Wmissing-prototypes") \ + DOCTEST_CLANG_SUPPRESS_WARNING("-Wc++98-compat") \ + DOCTEST_CLANG_SUPPRESS_WARNING("-Wc++98-compat-pedantic") \ + \ + DOCTEST_GCC_SUPPRESS_WARNING_PUSH \ + DOCTEST_GCC_SUPPRESS_WARNING("-Wunknown-pragmas") \ + DOCTEST_GCC_SUPPRESS_WARNING("-Wpragmas") \ + DOCTEST_GCC_SUPPRESS_WARNING("-Weffc++") \ + DOCTEST_GCC_SUPPRESS_WARNING("-Wstrict-overflow") \ + DOCTEST_GCC_SUPPRESS_WARNING("-Wstrict-aliasing") \ + DOCTEST_GCC_SUPPRESS_WARNING("-Wmissing-declarations") \ + DOCTEST_GCC_SUPPRESS_WARNING("-Wuseless-cast") \ + DOCTEST_GCC_SUPPRESS_WARNING("-Wnoexcept") \ + \ + DOCTEST_MSVC_SUPPRESS_WARNING_PUSH \ + /* these 4 also disabled globally via cmake: */ \ + DOCTEST_MSVC_SUPPRESS_WARNING(4514) /* unreferenced inline function has been removed */ \ + DOCTEST_MSVC_SUPPRESS_WARNING(4571) /* SEH related */ \ + DOCTEST_MSVC_SUPPRESS_WARNING(4710) /* function not inlined */ \ + DOCTEST_MSVC_SUPPRESS_WARNING(4711) /* function selected for inline expansion*/ \ + /* common ones */ \ + DOCTEST_MSVC_SUPPRESS_WARNING(4616) /* invalid compiler warning */ \ + DOCTEST_MSVC_SUPPRESS_WARNING(4619) /* invalid compiler warning */ \ + DOCTEST_MSVC_SUPPRESS_WARNING(4996) /* The compiler encountered a deprecated declaration */ \ + DOCTEST_MSVC_SUPPRESS_WARNING(4706) /* assignment within conditional expression */ \ + DOCTEST_MSVC_SUPPRESS_WARNING(4512) /* 'class' : assignment operator could not be generated */ \ + DOCTEST_MSVC_SUPPRESS_WARNING(4127) /* conditional expression is constant */ \ + DOCTEST_MSVC_SUPPRESS_WARNING(4820) /* padding */ \ + DOCTEST_MSVC_SUPPRESS_WARNING(4625) /* copy constructor was implicitly deleted */ \ + DOCTEST_MSVC_SUPPRESS_WARNING(4626) /* assignment operator was implicitly deleted */ \ + DOCTEST_MSVC_SUPPRESS_WARNING(5027) /* move assignment operator implicitly deleted */ \ + DOCTEST_MSVC_SUPPRESS_WARNING(5026) /* move constructor was implicitly deleted */ \ + DOCTEST_MSVC_SUPPRESS_WARNING(4640) /* construction of local static object not thread-safe */ \ + DOCTEST_MSVC_SUPPRESS_WARNING(5045) /* Spectre mitigation for memory load */ \ + DOCTEST_MSVC_SUPPRESS_WARNING(5264) /* 'variable-name': 'const' variable is not used */ \ + /* static analysis */ \ + DOCTEST_MSVC_SUPPRESS_WARNING(26439) /* Function may not throw. Declare it 'noexcept' */ \ + DOCTEST_MSVC_SUPPRESS_WARNING(26495) /* Always initialize a member variable */ \ + DOCTEST_MSVC_SUPPRESS_WARNING(26451) /* Arithmetic overflow ... */ \ + DOCTEST_MSVC_SUPPRESS_WARNING(26444) /* Avoid unnamed objects with custom ctor and dtor... */ \ + DOCTEST_MSVC_SUPPRESS_WARNING(26812) /* Prefer 'enum class' over 'enum' */ + +#define DOCTEST_SUPPRESS_COMMON_WARNINGS_POP \ + DOCTEST_CLANG_SUPPRESS_WARNING_POP \ + DOCTEST_GCC_SUPPRESS_WARNING_POP \ + DOCTEST_MSVC_SUPPRESS_WARNING_POP + +DOCTEST_SUPPRESS_COMMON_WARNINGS_PUSH + +DOCTEST_CLANG_SUPPRESS_WARNING_PUSH +DOCTEST_CLANG_SUPPRESS_WARNING("-Wnon-virtual-dtor") +DOCTEST_CLANG_SUPPRESS_WARNING("-Wdeprecated") + +DOCTEST_GCC_SUPPRESS_WARNING_PUSH +DOCTEST_GCC_SUPPRESS_WARNING("-Wctor-dtor-privacy") +DOCTEST_GCC_SUPPRESS_WARNING("-Wnon-virtual-dtor") +DOCTEST_GCC_SUPPRESS_WARNING("-Wsign-promo") + +DOCTEST_MSVC_SUPPRESS_WARNING_PUSH +DOCTEST_MSVC_SUPPRESS_WARNING(4623) // default constructor was implicitly defined as deleted + +#define DOCTEST_MAKE_STD_HEADERS_CLEAN_FROM_WARNINGS_ON_WALL_BEGIN \ + DOCTEST_MSVC_SUPPRESS_WARNING_PUSH \ + DOCTEST_MSVC_SUPPRESS_WARNING(4548) /* before comma no effect; expected side - effect */ \ + DOCTEST_MSVC_SUPPRESS_WARNING(4265) /* virtual functions, but destructor is not virtual */ \ + DOCTEST_MSVC_SUPPRESS_WARNING(4986) /* exception specification does not match previous */ \ + DOCTEST_MSVC_SUPPRESS_WARNING(4350) /* 'member1' called instead of 'member2' */ \ + DOCTEST_MSVC_SUPPRESS_WARNING(4668) /* not defined as a preprocessor macro */ \ + DOCTEST_MSVC_SUPPRESS_WARNING(4365) /* signed/unsigned mismatch */ \ + DOCTEST_MSVC_SUPPRESS_WARNING(4774) /* format string not a string literal */ \ + DOCTEST_MSVC_SUPPRESS_WARNING(4820) /* padding */ \ + DOCTEST_MSVC_SUPPRESS_WARNING(4625) /* copy constructor was implicitly deleted */ \ + DOCTEST_MSVC_SUPPRESS_WARNING(4626) /* assignment operator was implicitly deleted */ \ + DOCTEST_MSVC_SUPPRESS_WARNING(5027) /* move assignment operator implicitly deleted */ \ + DOCTEST_MSVC_SUPPRESS_WARNING(5026) /* move constructor was implicitly deleted */ \ + DOCTEST_MSVC_SUPPRESS_WARNING(4623) /* default constructor was implicitly deleted */ \ + DOCTEST_MSVC_SUPPRESS_WARNING(5039) /* pointer to pot. throwing function passed to extern C */ \ + DOCTEST_MSVC_SUPPRESS_WARNING(5045) /* Spectre mitigation for memory load */ \ + DOCTEST_MSVC_SUPPRESS_WARNING(5105) /* macro producing 'defined' has undefined behavior */ \ + DOCTEST_MSVC_SUPPRESS_WARNING(4738) /* storing float result in memory, loss of performance */ \ + DOCTEST_MSVC_SUPPRESS_WARNING(5262) /* implicit fall-through */ + +#define DOCTEST_MAKE_STD_HEADERS_CLEAN_FROM_WARNINGS_ON_WALL_END DOCTEST_MSVC_SUPPRESS_WARNING_POP + +// ================================================================================================= +// == FEATURE DETECTION ============================================================================ +// ================================================================================================= + +// general compiler feature support table: https://en.cppreference.com/w/cpp/compiler_support +// MSVC C++11 feature support table: https://msdn.microsoft.com/en-us/library/hh567368.aspx +// GCC C++11 feature support table: https://gcc.gnu.org/projects/cxx-status.html +// MSVC version table: +// https://en.wikipedia.org/wiki/Microsoft_Visual_C%2B%2B#Internal_version_numbering +// MSVC++ 14.3 (17) _MSC_VER == 1930 (Visual Studio 2022) +// MSVC++ 14.2 (16) _MSC_VER == 1920 (Visual Studio 2019) +// MSVC++ 14.1 (15) _MSC_VER == 1910 (Visual Studio 2017) +// MSVC++ 14.0 _MSC_VER == 1900 (Visual Studio 2015) +// MSVC++ 12.0 _MSC_VER == 1800 (Visual Studio 2013) +// MSVC++ 11.0 _MSC_VER == 1700 (Visual Studio 2012) +// MSVC++ 10.0 _MSC_VER == 1600 (Visual Studio 2010) +// MSVC++ 9.0 _MSC_VER == 1500 (Visual Studio 2008) +// MSVC++ 8.0 _MSC_VER == 1400 (Visual Studio 2005) + +// Universal Windows Platform support +#if defined(WINAPI_FAMILY) && (WINAPI_FAMILY == WINAPI_FAMILY_APP) +#define DOCTEST_CONFIG_NO_WINDOWS_SEH +#endif // WINAPI_FAMILY +#if DOCTEST_MSVC && !defined(DOCTEST_CONFIG_WINDOWS_SEH) +#define DOCTEST_CONFIG_WINDOWS_SEH +#endif // MSVC +#if defined(DOCTEST_CONFIG_NO_WINDOWS_SEH) && defined(DOCTEST_CONFIG_WINDOWS_SEH) +#undef DOCTEST_CONFIG_WINDOWS_SEH +#endif // DOCTEST_CONFIG_NO_WINDOWS_SEH + +#if !defined(_WIN32) && !defined(__QNX__) && !defined(DOCTEST_CONFIG_POSIX_SIGNALS) && \ + !defined(__EMSCRIPTEN__) && !defined(__wasi__) +#define DOCTEST_CONFIG_POSIX_SIGNALS +#endif // _WIN32 +#if defined(DOCTEST_CONFIG_NO_POSIX_SIGNALS) && defined(DOCTEST_CONFIG_POSIX_SIGNALS) +#undef DOCTEST_CONFIG_POSIX_SIGNALS +#endif // DOCTEST_CONFIG_NO_POSIX_SIGNALS + +#ifndef DOCTEST_CONFIG_NO_EXCEPTIONS +#if !defined(__cpp_exceptions) && !defined(__EXCEPTIONS) && !defined(_CPPUNWIND) \ + || defined(__wasi__) +#define DOCTEST_CONFIG_NO_EXCEPTIONS +#endif // no exceptions +#endif // DOCTEST_CONFIG_NO_EXCEPTIONS + +#ifdef DOCTEST_CONFIG_NO_EXCEPTIONS_BUT_WITH_ALL_ASSERTS +#ifndef DOCTEST_CONFIG_NO_EXCEPTIONS +#define DOCTEST_CONFIG_NO_EXCEPTIONS +#endif // DOCTEST_CONFIG_NO_EXCEPTIONS +#endif // DOCTEST_CONFIG_NO_EXCEPTIONS_BUT_WITH_ALL_ASSERTS + +#if defined(DOCTEST_CONFIG_NO_EXCEPTIONS) && !defined(DOCTEST_CONFIG_NO_TRY_CATCH_IN_ASSERTS) +#define DOCTEST_CONFIG_NO_TRY_CATCH_IN_ASSERTS +#endif // DOCTEST_CONFIG_NO_EXCEPTIONS && !DOCTEST_CONFIG_NO_TRY_CATCH_IN_ASSERTS + +#ifdef __wasi__ +#define DOCTEST_CONFIG_NO_MULTITHREADING +#endif + +#if defined(DOCTEST_CONFIG_IMPLEMENT_WITH_MAIN) && !defined(DOCTEST_CONFIG_IMPLEMENT) +#define DOCTEST_CONFIG_IMPLEMENT +#endif // DOCTEST_CONFIG_IMPLEMENT_WITH_MAIN + +#if defined(_WIN32) || defined(__CYGWIN__) +#if DOCTEST_MSVC +#define DOCTEST_SYMBOL_EXPORT __declspec(dllexport) +#define DOCTEST_SYMBOL_IMPORT __declspec(dllimport) +#else // MSVC +#define DOCTEST_SYMBOL_EXPORT __attribute__((dllexport)) +#define DOCTEST_SYMBOL_IMPORT __attribute__((dllimport)) +#endif // MSVC +#else // _WIN32 +#define DOCTEST_SYMBOL_EXPORT __attribute__((visibility("default"))) +#define DOCTEST_SYMBOL_IMPORT +#endif // _WIN32 + +#ifdef DOCTEST_CONFIG_IMPLEMENTATION_IN_DLL +#ifdef DOCTEST_CONFIG_IMPLEMENT +#define DOCTEST_INTERFACE DOCTEST_SYMBOL_EXPORT +#else // DOCTEST_CONFIG_IMPLEMENT +#define DOCTEST_INTERFACE DOCTEST_SYMBOL_IMPORT +#endif // DOCTEST_CONFIG_IMPLEMENT +#else // DOCTEST_CONFIG_IMPLEMENTATION_IN_DLL +#define DOCTEST_INTERFACE +#endif // DOCTEST_CONFIG_IMPLEMENTATION_IN_DLL + +// needed for extern template instantiations +// see https://github.com/fmtlib/fmt/issues/2228 +#if DOCTEST_MSVC +#define DOCTEST_INTERFACE_DECL +#define DOCTEST_INTERFACE_DEF DOCTEST_INTERFACE +#else // DOCTEST_MSVC +#define DOCTEST_INTERFACE_DECL DOCTEST_INTERFACE +#define DOCTEST_INTERFACE_DEF +#endif // DOCTEST_MSVC + +#define DOCTEST_EMPTY + +#if DOCTEST_MSVC +#define DOCTEST_NOINLINE __declspec(noinline) +#define DOCTEST_UNUSED +#define DOCTEST_ALIGNMENT(x) +#elif DOCTEST_CLANG && DOCTEST_CLANG < DOCTEST_COMPILER(3, 5, 0) +#define DOCTEST_NOINLINE +#define DOCTEST_UNUSED +#define DOCTEST_ALIGNMENT(x) +#else +#define DOCTEST_NOINLINE __attribute__((noinline)) +#define DOCTEST_UNUSED __attribute__((unused)) +#define DOCTEST_ALIGNMENT(x) __attribute__((aligned(x))) +#endif + +#ifdef DOCTEST_CONFIG_NO_CONTRADICTING_INLINE +#define DOCTEST_INLINE_NOINLINE inline +#else +#define DOCTEST_INLINE_NOINLINE inline DOCTEST_NOINLINE +#endif + +#ifndef DOCTEST_NORETURN +#if DOCTEST_MSVC && (DOCTEST_MSVC < DOCTEST_COMPILER(19, 0, 0)) +#define DOCTEST_NORETURN +#else // DOCTEST_MSVC +#define DOCTEST_NORETURN [[noreturn]] +#endif // DOCTEST_MSVC +#endif // DOCTEST_NORETURN + +#ifndef DOCTEST_NOEXCEPT +#if DOCTEST_MSVC && (DOCTEST_MSVC < DOCTEST_COMPILER(19, 0, 0)) +#define DOCTEST_NOEXCEPT +#else // DOCTEST_MSVC +#define DOCTEST_NOEXCEPT noexcept +#endif // DOCTEST_MSVC +#endif // DOCTEST_NOEXCEPT + +#ifndef DOCTEST_CONSTEXPR +#if DOCTEST_MSVC && (DOCTEST_MSVC < DOCTEST_COMPILER(19, 0, 0)) +#define DOCTEST_CONSTEXPR const +#define DOCTEST_CONSTEXPR_FUNC inline +#else // DOCTEST_MSVC +#define DOCTEST_CONSTEXPR constexpr +#define DOCTEST_CONSTEXPR_FUNC constexpr +#endif // DOCTEST_MSVC +#endif // DOCTEST_CONSTEXPR + +#ifndef DOCTEST_NO_SANITIZE_INTEGER +#if DOCTEST_CLANG >= DOCTEST_COMPILER(3, 7, 0) +#define DOCTEST_NO_SANITIZE_INTEGER __attribute__((no_sanitize("integer"))) +#else +#define DOCTEST_NO_SANITIZE_INTEGER +#endif +#endif // DOCTEST_NO_SANITIZE_INTEGER + +// ================================================================================================= +// == FEATURE DETECTION END ======================================================================== +// ================================================================================================= + +#define DOCTEST_DECLARE_INTERFACE(name) \ + virtual ~name(); \ + name() = default; \ + name(const name&) = delete; \ + name(name&&) = delete; \ + name& operator=(const name&) = delete; \ + name& operator=(name&&) = delete; + +#define DOCTEST_DEFINE_INTERFACE(name) \ + name::~name() = default; + +// internal macros for string concatenation and anonymous variable name generation +#define DOCTEST_CAT_IMPL(s1, s2) s1##s2 +#define DOCTEST_CAT(s1, s2) DOCTEST_CAT_IMPL(s1, s2) +#ifdef __COUNTER__ // not standard and may be missing for some compilers +#define DOCTEST_ANONYMOUS(x) DOCTEST_CAT(x, __COUNTER__) +#else // __COUNTER__ +#define DOCTEST_ANONYMOUS(x) DOCTEST_CAT(x, __LINE__) +#endif // __COUNTER__ + +#ifndef DOCTEST_CONFIG_ASSERTION_PARAMETERS_BY_VALUE +#define DOCTEST_REF_WRAP(x) x& +#else // DOCTEST_CONFIG_ASSERTION_PARAMETERS_BY_VALUE +#define DOCTEST_REF_WRAP(x) x +#endif // DOCTEST_CONFIG_ASSERTION_PARAMETERS_BY_VALUE + +// not using __APPLE__ because... this is how Catch does it +#ifdef __MAC_OS_X_VERSION_MIN_REQUIRED +#define DOCTEST_PLATFORM_MAC +#elif defined(__IPHONE_OS_VERSION_MIN_REQUIRED) +#define DOCTEST_PLATFORM_IPHONE +#elif defined(_WIN32) +#define DOCTEST_PLATFORM_WINDOWS +#elif defined(__wasi__) +#define DOCTEST_PLATFORM_WASI +#else // DOCTEST_PLATFORM +#define DOCTEST_PLATFORM_LINUX +#endif // DOCTEST_PLATFORM + +namespace doctest { namespace detail { + static DOCTEST_CONSTEXPR int consume(const int*, int) noexcept { return 0; } +}} + +#define DOCTEST_GLOBAL_NO_WARNINGS(var, ...) \ + DOCTEST_CLANG_SUPPRESS_WARNING_WITH_PUSH("-Wglobal-constructors") \ + static const int var = doctest::detail::consume(&var, __VA_ARGS__); \ + DOCTEST_CLANG_SUPPRESS_WARNING_POP + +#ifndef DOCTEST_BREAK_INTO_DEBUGGER +// should probably take a look at https://github.com/scottt/debugbreak +#ifdef DOCTEST_PLATFORM_LINUX +#if defined(__GNUC__) && (defined(__i386) || defined(__x86_64)) +// Break at the location of the failing check if possible +#define DOCTEST_BREAK_INTO_DEBUGGER() __asm__("int $3\n" : :) // NOLINT(hicpp-no-assembler) +#else +#include +#define DOCTEST_BREAK_INTO_DEBUGGER() raise(SIGTRAP) +#endif +#elif defined(DOCTEST_PLATFORM_MAC) +#if defined(__x86_64) || defined(__x86_64__) || defined(__amd64__) || defined(__i386) +#define DOCTEST_BREAK_INTO_DEBUGGER() __asm__("int $3\n" : :) // NOLINT(hicpp-no-assembler) +#elif defined(__ppc__) || defined(__ppc64__) +// https://www.cocoawithlove.com/2008/03/break-into-debugger.html +#define DOCTEST_BREAK_INTO_DEBUGGER() __asm__("li r0, 20\nsc\nnop\nli r0, 37\nli r4, 2\nsc\nnop\n": : : "memory","r0","r3","r4") // NOLINT(hicpp-no-assembler) +#else +#define DOCTEST_BREAK_INTO_DEBUGGER() __asm__("brk #0"); // NOLINT(hicpp-no-assembler) +#endif +#elif DOCTEST_MSVC +#define DOCTEST_BREAK_INTO_DEBUGGER() __debugbreak() +#elif defined(__MINGW32__) +DOCTEST_GCC_SUPPRESS_WARNING_WITH_PUSH("-Wredundant-decls") +extern "C" __declspec(dllimport) void __stdcall DebugBreak(); +DOCTEST_GCC_SUPPRESS_WARNING_POP +#define DOCTEST_BREAK_INTO_DEBUGGER() ::DebugBreak() +#else // linux +#define DOCTEST_BREAK_INTO_DEBUGGER() (static_cast(0)) +#endif // linux +#endif // DOCTEST_BREAK_INTO_DEBUGGER + +// this is kept here for backwards compatibility since the config option was changed +#ifdef DOCTEST_CONFIG_USE_IOSFWD +#ifndef DOCTEST_CONFIG_USE_STD_HEADERS +#define DOCTEST_CONFIG_USE_STD_HEADERS +#endif +#endif // DOCTEST_CONFIG_USE_IOSFWD + +// for clang - always include ciso646 (which drags some std stuff) because +// we want to check if we are using libc++ with the _LIBCPP_VERSION macro in +// which case we don't want to forward declare stuff from std - for reference: +// https://github.com/doctest/doctest/issues/126 +// https://github.com/doctest/doctest/issues/356 +#if DOCTEST_CLANG +#include +#endif // clang + +#ifdef _LIBCPP_VERSION +#ifndef DOCTEST_CONFIG_USE_STD_HEADERS +#define DOCTEST_CONFIG_USE_STD_HEADERS +#endif +#endif // _LIBCPP_VERSION + +#ifdef DOCTEST_CONFIG_USE_STD_HEADERS +#ifndef DOCTEST_CONFIG_INCLUDE_TYPE_TRAITS +#define DOCTEST_CONFIG_INCLUDE_TYPE_TRAITS +#endif // DOCTEST_CONFIG_INCLUDE_TYPE_TRAITS +DOCTEST_MAKE_STD_HEADERS_CLEAN_FROM_WARNINGS_ON_WALL_BEGIN +#include +#include +#include +DOCTEST_MAKE_STD_HEADERS_CLEAN_FROM_WARNINGS_ON_WALL_END +#else // DOCTEST_CONFIG_USE_STD_HEADERS + +// Forward declaring 'X' in namespace std is not permitted by the C++ Standard. +DOCTEST_MSVC_SUPPRESS_WARNING_WITH_PUSH(4643) + +namespace std { // NOLINT(cert-dcl58-cpp) +typedef decltype(nullptr) nullptr_t; // NOLINT(modernize-use-using) +typedef decltype(sizeof(void*)) size_t; // NOLINT(modernize-use-using) +template +struct char_traits; +template <> +struct char_traits; +template +class basic_ostream; // NOLINT(fuchsia-virtual-inheritance) +typedef basic_ostream> ostream; // NOLINT(modernize-use-using) +template +// NOLINTNEXTLINE +basic_ostream& operator<<(basic_ostream&, const char*); +template +class basic_istream; +typedef basic_istream> istream; // NOLINT(modernize-use-using) +template +class tuple; +#if DOCTEST_MSVC >= DOCTEST_COMPILER(19, 20, 0) +// see this issue on why this is needed: https://github.com/doctest/doctest/issues/183 +template +class allocator; +template +class basic_string; +using string = basic_string, allocator>; +#endif // VS 2019 +} // namespace std + +DOCTEST_MSVC_SUPPRESS_WARNING_POP + +#endif // DOCTEST_CONFIG_USE_STD_HEADERS + +#ifdef DOCTEST_CONFIG_INCLUDE_TYPE_TRAITS +#include +#endif // DOCTEST_CONFIG_INCLUDE_TYPE_TRAITS + +namespace doctest { + +using std::size_t; + +DOCTEST_INTERFACE extern bool is_running_in_test; + +#ifndef DOCTEST_CONFIG_STRING_SIZE_TYPE +#define DOCTEST_CONFIG_STRING_SIZE_TYPE unsigned +#endif + +// A 24 byte string class (can be as small as 17 for x64 and 13 for x86) that can hold strings with length +// of up to 23 chars on the stack before going on the heap - the last byte of the buffer is used for: +// - "is small" bit - the highest bit - if "0" then it is small - otherwise its "1" (128) +// - if small - capacity left before going on the heap - using the lowest 5 bits +// - if small - 2 bits are left unused - the second and third highest ones +// - if small - acts as a null terminator if strlen() is 23 (24 including the null terminator) +// and the "is small" bit remains "0" ("as well as the capacity left") so its OK +// Idea taken from this lecture about the string implementation of facebook/folly - fbstring +// https://www.youtube.com/watch?v=kPR8h4-qZdk +// TODO: +// - optimizations - like not deleting memory unnecessarily in operator= and etc. +// - resize/reserve/clear +// - replace +// - back/front +// - iterator stuff +// - find & friends +// - push_back/pop_back +// - assign/insert/erase +// - relational operators as free functions - taking const char* as one of the params +class DOCTEST_INTERFACE String +{ +public: + using size_type = DOCTEST_CONFIG_STRING_SIZE_TYPE; + +private: + static DOCTEST_CONSTEXPR size_type len = 24; //!OCLINT avoid private static members + static DOCTEST_CONSTEXPR size_type last = len - 1; //!OCLINT avoid private static members + + struct view // len should be more than sizeof(view) - because of the final byte for flags + { + char* ptr; + size_type size; + size_type capacity; + }; + + union + { + char buf[len]; // NOLINT(*-avoid-c-arrays) + view data; + }; + + char* allocate(size_type sz); + + bool isOnStack() const noexcept { return (buf[last] & 128) == 0; } + void setOnHeap() noexcept; + void setLast(size_type in = last) noexcept; + void setSize(size_type sz) noexcept; + + void copy(const String& other); + +public: + static DOCTEST_CONSTEXPR size_type npos = static_cast(-1); + + String() noexcept; + ~String(); + + // cppcheck-suppress noExplicitConstructor + String(const char* in); + String(const char* in, size_type in_size); + + String(std::istream& in, size_type in_size); + + String(const String& other); + String& operator=(const String& other); + + String& operator+=(const String& other); + + String(String&& other) noexcept; + String& operator=(String&& other) noexcept; + + char operator[](size_type i) const; + char& operator[](size_type i); + + // the only functions I'm willing to leave in the interface - available for inlining + const char* c_str() const { return const_cast(this)->c_str(); } // NOLINT + char* c_str() { + if (isOnStack()) { + return reinterpret_cast(buf); + } + return data.ptr; + } + + size_type size() const; + size_type capacity() const; + + String substr(size_type pos, size_type cnt = npos) &&; + String substr(size_type pos, size_type cnt = npos) const &; + + size_type find(char ch, size_type pos = 0) const; + size_type rfind(char ch, size_type pos = npos) const; + + int compare(const char* other, bool no_case = false) const; + int compare(const String& other, bool no_case = false) const; + +friend DOCTEST_INTERFACE std::ostream& operator<<(std::ostream& s, const String& in); +}; + +DOCTEST_INTERFACE String operator+(const String& lhs, const String& rhs); + +DOCTEST_INTERFACE bool operator==(const String& lhs, const String& rhs); +DOCTEST_INTERFACE bool operator!=(const String& lhs, const String& rhs); +DOCTEST_INTERFACE bool operator<(const String& lhs, const String& rhs); +DOCTEST_INTERFACE bool operator>(const String& lhs, const String& rhs); +DOCTEST_INTERFACE bool operator<=(const String& lhs, const String& rhs); +DOCTEST_INTERFACE bool operator>=(const String& lhs, const String& rhs); + +class DOCTEST_INTERFACE Contains { +public: + explicit Contains(const String& string); + + bool checkWith(const String& other) const; + + String string; +}; + +DOCTEST_INTERFACE String toString(const Contains& in); + +DOCTEST_INTERFACE bool operator==(const String& lhs, const Contains& rhs); +DOCTEST_INTERFACE bool operator==(const Contains& lhs, const String& rhs); +DOCTEST_INTERFACE bool operator!=(const String& lhs, const Contains& rhs); +DOCTEST_INTERFACE bool operator!=(const Contains& lhs, const String& rhs); + +namespace Color { + enum Enum + { + None = 0, + White, + Red, + Green, + Blue, + Cyan, + Yellow, + Grey, + + Bright = 0x10, + + BrightRed = Bright | Red, + BrightGreen = Bright | Green, + LightGrey = Bright | Grey, + BrightWhite = Bright | White + }; + + DOCTEST_INTERFACE std::ostream& operator<<(std::ostream& s, Color::Enum code); +} // namespace Color + +namespace assertType { + enum Enum + { + // macro traits + + is_warn = 1, + is_check = 2 * is_warn, + is_require = 2 * is_check, + + is_normal = 2 * is_require, + is_throws = 2 * is_normal, + is_throws_as = 2 * is_throws, + is_throws_with = 2 * is_throws_as, + is_nothrow = 2 * is_throws_with, + + is_false = 2 * is_nothrow, + is_unary = 2 * is_false, // not checked anywhere - used just to distinguish the types + + is_eq = 2 * is_unary, + is_ne = 2 * is_eq, + + is_lt = 2 * is_ne, + is_gt = 2 * is_lt, + + is_ge = 2 * is_gt, + is_le = 2 * is_ge, + + // macro types + + DT_WARN = is_normal | is_warn, + DT_CHECK = is_normal | is_check, + DT_REQUIRE = is_normal | is_require, + + DT_WARN_FALSE = is_normal | is_false | is_warn, + DT_CHECK_FALSE = is_normal | is_false | is_check, + DT_REQUIRE_FALSE = is_normal | is_false | is_require, + + DT_WARN_THROWS = is_throws | is_warn, + DT_CHECK_THROWS = is_throws | is_check, + DT_REQUIRE_THROWS = is_throws | is_require, + + DT_WARN_THROWS_AS = is_throws_as | is_warn, + DT_CHECK_THROWS_AS = is_throws_as | is_check, + DT_REQUIRE_THROWS_AS = is_throws_as | is_require, + + DT_WARN_THROWS_WITH = is_throws_with | is_warn, + DT_CHECK_THROWS_WITH = is_throws_with | is_check, + DT_REQUIRE_THROWS_WITH = is_throws_with | is_require, + + DT_WARN_THROWS_WITH_AS = is_throws_with | is_throws_as | is_warn, + DT_CHECK_THROWS_WITH_AS = is_throws_with | is_throws_as | is_check, + DT_REQUIRE_THROWS_WITH_AS = is_throws_with | is_throws_as | is_require, + + DT_WARN_NOTHROW = is_nothrow | is_warn, + DT_CHECK_NOTHROW = is_nothrow | is_check, + DT_REQUIRE_NOTHROW = is_nothrow | is_require, + + DT_WARN_EQ = is_normal | is_eq | is_warn, + DT_CHECK_EQ = is_normal | is_eq | is_check, + DT_REQUIRE_EQ = is_normal | is_eq | is_require, + + DT_WARN_NE = is_normal | is_ne | is_warn, + DT_CHECK_NE = is_normal | is_ne | is_check, + DT_REQUIRE_NE = is_normal | is_ne | is_require, + + DT_WARN_GT = is_normal | is_gt | is_warn, + DT_CHECK_GT = is_normal | is_gt | is_check, + DT_REQUIRE_GT = is_normal | is_gt | is_require, + + DT_WARN_LT = is_normal | is_lt | is_warn, + DT_CHECK_LT = is_normal | is_lt | is_check, + DT_REQUIRE_LT = is_normal | is_lt | is_require, + + DT_WARN_GE = is_normal | is_ge | is_warn, + DT_CHECK_GE = is_normal | is_ge | is_check, + DT_REQUIRE_GE = is_normal | is_ge | is_require, + + DT_WARN_LE = is_normal | is_le | is_warn, + DT_CHECK_LE = is_normal | is_le | is_check, + DT_REQUIRE_LE = is_normal | is_le | is_require, + + DT_WARN_UNARY = is_normal | is_unary | is_warn, + DT_CHECK_UNARY = is_normal | is_unary | is_check, + DT_REQUIRE_UNARY = is_normal | is_unary | is_require, + + DT_WARN_UNARY_FALSE = is_normal | is_false | is_unary | is_warn, + DT_CHECK_UNARY_FALSE = is_normal | is_false | is_unary | is_check, + DT_REQUIRE_UNARY_FALSE = is_normal | is_false | is_unary | is_require, + }; +} // namespace assertType + +DOCTEST_INTERFACE const char* assertString(assertType::Enum at); +DOCTEST_INTERFACE const char* failureString(assertType::Enum at); +DOCTEST_INTERFACE const char* skipPathFromFilename(const char* file); + +struct DOCTEST_INTERFACE TestCaseData +{ + String m_file; // the file in which the test was registered (using String - see #350) + unsigned m_line; // the line where the test was registered + const char* m_name; // name of the test case + const char* m_test_suite; // the test suite in which the test was added + const char* m_description; + bool m_skip; + bool m_no_breaks; + bool m_no_output; + bool m_may_fail; + bool m_should_fail; + int m_expected_failures; + double m_timeout; +}; + +struct DOCTEST_INTERFACE AssertData +{ + // common - for all asserts + const TestCaseData* m_test_case; + assertType::Enum m_at; + const char* m_file; + int m_line; + const char* m_expr; + bool m_failed; + + // exception-related - for all asserts + bool m_threw; + String m_exception; + + // for normal asserts + String m_decomp; + + // for specific exception-related asserts + bool m_threw_as; + const char* m_exception_type; + + class DOCTEST_INTERFACE StringContains { + private: + Contains content; + bool isContains; + + public: + StringContains(const String& str) : content(str), isContains(false) { } + StringContains(Contains cntn) : content(static_cast(cntn)), isContains(true) { } + + bool check(const String& str) { return isContains ? (content == str) : (content.string == str); } + + operator const String&() const { return content.string; } + + const char* c_str() const { return content.string.c_str(); } + } m_exception_string; + + AssertData(assertType::Enum at, const char* file, int line, const char* expr, + const char* exception_type, const StringContains& exception_string); +}; + +struct DOCTEST_INTERFACE MessageData +{ + String m_string; + const char* m_file; + int m_line; + assertType::Enum m_severity; +}; + +struct DOCTEST_INTERFACE SubcaseSignature +{ + String m_name; + const char* m_file; + int m_line; + + bool operator==(const SubcaseSignature& other) const; + bool operator<(const SubcaseSignature& other) const; +}; + +struct DOCTEST_INTERFACE IContextScope +{ + DOCTEST_DECLARE_INTERFACE(IContextScope) + virtual void stringify(std::ostream*) const = 0; +}; + +namespace detail { + struct DOCTEST_INTERFACE TestCase; +} // namespace detail + +struct ContextOptions //!OCLINT too many fields +{ + std::ostream* cout = nullptr; // stdout stream + String binary_name; // the test binary name + + const detail::TestCase* currentTest = nullptr; + + // == parameters from the command line + String out; // output filename + String order_by; // how tests should be ordered + unsigned rand_seed; // the seed for rand ordering + + unsigned first; // the first (matching) test to be executed + unsigned last; // the last (matching) test to be executed + + int abort_after; // stop tests after this many failed assertions + int subcase_filter_levels; // apply the subcase filters for the first N levels + + bool success; // include successful assertions in output + bool case_sensitive; // if filtering should be case sensitive + bool exit; // if the program should be exited after the tests are ran/whatever + bool duration; // print the time duration of each test case + bool minimal; // minimal console output (only test failures) + bool quiet; // no console output + bool no_throw; // to skip exceptions-related assertion macros + bool no_exitcode; // if the framework should return 0 as the exitcode + bool no_run; // to not run the tests at all (can be done with an "*" exclude) + bool no_intro; // to not print the intro of the framework + bool no_version; // to not print the version of the framework + bool no_colors; // if output to the console should be colorized + bool force_colors; // forces the use of colors even when a tty cannot be detected + bool no_breaks; // to not break into the debugger + bool no_skip; // don't skip test cases which are marked to be skipped + bool gnu_file_line; // if line numbers should be surrounded with :x: and not (x): + bool no_path_in_filenames; // if the path to files should be removed from the output + bool no_line_numbers; // if source code line numbers should be omitted from the output + bool no_debug_output; // no output in the debug console when a debugger is attached + bool no_skipped_summary; // don't print "skipped" in the summary !!! UNDOCUMENTED !!! + bool no_time_in_output; // omit any time/timestamps from output !!! UNDOCUMENTED !!! + + bool help; // to print the help + bool version; // to print the version + bool count; // if only the count of matching tests is to be retrieved + bool list_test_cases; // to list all tests matching the filters + bool list_test_suites; // to list all suites matching the filters + bool list_reporters; // lists all registered reporters +}; + +namespace detail { + namespace types { +#ifdef DOCTEST_CONFIG_INCLUDE_TYPE_TRAITS + using namespace std; +#else + template + struct enable_if { }; + + template + struct enable_if { using type = T; }; + + struct true_type { static DOCTEST_CONSTEXPR bool value = true; }; + struct false_type { static DOCTEST_CONSTEXPR bool value = false; }; + + template struct remove_reference { using type = T; }; + template struct remove_reference { using type = T; }; + template struct remove_reference { using type = T; }; + + template struct is_rvalue_reference : false_type { }; + template struct is_rvalue_reference : true_type { }; + + template struct remove_const { using type = T; }; + template struct remove_const { using type = T; }; + + // Compiler intrinsics + template struct is_enum { static DOCTEST_CONSTEXPR bool value = __is_enum(T); }; + template struct underlying_type { using type = __underlying_type(T); }; + + template struct is_pointer : false_type { }; + template struct is_pointer : true_type { }; + + template struct is_array : false_type { }; + // NOLINTNEXTLINE(*-avoid-c-arrays) + template struct is_array : true_type { }; +#endif + } + + // + template + T&& declval(); + + template + DOCTEST_CONSTEXPR_FUNC T&& forward(typename types::remove_reference::type& t) DOCTEST_NOEXCEPT { + return static_cast(t); + } + + template + DOCTEST_CONSTEXPR_FUNC T&& forward(typename types::remove_reference::type&& t) DOCTEST_NOEXCEPT { + return static_cast(t); + } + + template + struct deferred_false : types::false_type { }; + +// MSVS 2015 :( +#if !DOCTEST_CLANG && defined(_MSC_VER) && _MSC_VER <= 1900 + template + struct has_global_insertion_operator : types::false_type { }; + + template + struct has_global_insertion_operator(), declval()), void())> : types::true_type { }; + + template + struct has_insertion_operator { static DOCTEST_CONSTEXPR bool value = has_global_insertion_operator::value; }; + + template + struct insert_hack; + + template + struct insert_hack { + static void insert(std::ostream& os, const T& t) { ::operator<<(os, t); } + }; + + template + struct insert_hack { + static void insert(std::ostream& os, const T& t) { operator<<(os, t); } + }; + + template + using insert_hack_t = insert_hack::value>; +#else + template + struct has_insertion_operator : types::false_type { }; +#endif + + template + struct has_insertion_operator(), declval()), void())> : types::true_type { }; + + template + struct should_stringify_as_underlying_type { + static DOCTEST_CONSTEXPR bool value = detail::types::is_enum::value && !doctest::detail::has_insertion_operator::value; + }; + + DOCTEST_INTERFACE std::ostream* tlssPush(); + DOCTEST_INTERFACE String tlssPop(); + + template + struct StringMakerBase { + template + static String convert(const DOCTEST_REF_WRAP(T)) { +#ifdef DOCTEST_CONFIG_REQUIRE_STRINGIFICATION_FOR_ALL_USED_TYPES + static_assert(deferred_false::value, "No stringification detected for type T. See string conversion manual"); +#endif + return "{?}"; + } + }; + + template + struct filldata; + + template + void filloss(std::ostream* stream, const T& in) { + filldata::fill(stream, in); + } + + template + void filloss(std::ostream* stream, const T (&in)[N]) { // NOLINT(*-avoid-c-arrays) + // T[N], T(&)[N], T(&&)[N] have same behaviour. + // Hence remove reference. + filloss::type>(stream, in); + } + + template + String toStream(const T& in) { + std::ostream* stream = tlssPush(); + filloss(stream, in); + return tlssPop(); + } + + template <> + struct StringMakerBase { + template + static String convert(const DOCTEST_REF_WRAP(T) in) { + return toStream(in); + } + }; +} // namespace detail + +template +struct StringMaker : public detail::StringMakerBase< + detail::has_insertion_operator::value || detail::types::is_pointer::value || detail::types::is_array::value> +{}; + +#ifndef DOCTEST_STRINGIFY +#ifdef DOCTEST_CONFIG_DOUBLE_STRINGIFY +#define DOCTEST_STRINGIFY(...) toString(toString(__VA_ARGS__)) +#else +#define DOCTEST_STRINGIFY(...) toString(__VA_ARGS__) +#endif +#endif + +template +String toString() { +#if DOCTEST_CLANG == 0 && DOCTEST_GCC == 0 && DOCTEST_ICC == 0 + String ret = __FUNCSIG__; // class doctest::String __cdecl doctest::toString(void) + String::size_type beginPos = ret.find('<'); + return ret.substr(beginPos + 1, ret.size() - beginPos - static_cast(sizeof(">(void)"))); +#else + String ret = __PRETTY_FUNCTION__; // doctest::String toString() [with T = TYPE] + String::size_type begin = ret.find('=') + 2; + return ret.substr(begin, ret.size() - begin - 1); +#endif +} + +template ::value, bool>::type = true> +String toString(const DOCTEST_REF_WRAP(T) value) { + return StringMaker::convert(value); +} + +#ifdef DOCTEST_CONFIG_TREAT_CHAR_STAR_AS_STRING +DOCTEST_INTERFACE String toString(const char* in); +#endif // DOCTEST_CONFIG_TREAT_CHAR_STAR_AS_STRING + +#if DOCTEST_MSVC >= DOCTEST_COMPILER(19, 20, 0) +// see this issue on why this is needed: https://github.com/doctest/doctest/issues/183 +DOCTEST_INTERFACE String toString(const std::string& in); +#endif // VS 2019 + +DOCTEST_INTERFACE String toString(String in); + +DOCTEST_INTERFACE String toString(std::nullptr_t); + +DOCTEST_INTERFACE String toString(bool in); + +DOCTEST_INTERFACE String toString(float in); +DOCTEST_INTERFACE String toString(double in); +DOCTEST_INTERFACE String toString(double long in); + +DOCTEST_INTERFACE String toString(char in); +DOCTEST_INTERFACE String toString(char signed in); +DOCTEST_INTERFACE String toString(char unsigned in); +DOCTEST_INTERFACE String toString(short in); +DOCTEST_INTERFACE String toString(short unsigned in); +DOCTEST_INTERFACE String toString(signed in); +DOCTEST_INTERFACE String toString(unsigned in); +DOCTEST_INTERFACE String toString(long in); +DOCTEST_INTERFACE String toString(long unsigned in); +DOCTEST_INTERFACE String toString(long long in); +DOCTEST_INTERFACE String toString(long long unsigned in); + +template ::value, bool>::type = true> +String toString(const DOCTEST_REF_WRAP(T) value) { + using UT = typename detail::types::underlying_type::type; + return (DOCTEST_STRINGIFY(static_cast(value))); +} + +namespace detail { + template + struct filldata + { + static void fill(std::ostream* stream, const T& in) { +#if defined(_MSC_VER) && _MSC_VER <= 1900 + insert_hack_t::insert(*stream, in); +#else + operator<<(*stream, in); +#endif + } + }; + +DOCTEST_MSVC_SUPPRESS_WARNING_WITH_PUSH(4866) +// NOLINTBEGIN(*-avoid-c-arrays) + template + struct filldata { + static void fill(std::ostream* stream, const T(&in)[N]) { + *stream << "["; + for (size_t i = 0; i < N; i++) { + if (i != 0) { *stream << ", "; } + *stream << (DOCTEST_STRINGIFY(in[i])); + } + *stream << "]"; + } + }; +// NOLINTEND(*-avoid-c-arrays) +DOCTEST_MSVC_SUPPRESS_WARNING_POP + + // Specialized since we don't want the terminating null byte! +// NOLINTBEGIN(*-avoid-c-arrays) + template + struct filldata { + static void fill(std::ostream* stream, const char (&in)[N]) { + *stream << String(in, in[N - 1] ? N : N - 1); + } // NOLINT(clang-analyzer-cplusplus.NewDeleteLeaks) + }; +// NOLINTEND(*-avoid-c-arrays) + + template <> + struct filldata { + static void fill(std::ostream* stream, const void* in); + }; + + template + struct filldata { +DOCTEST_MSVC_SUPPRESS_WARNING_WITH_PUSH(4180) + static void fill(std::ostream* stream, const T* in) { +DOCTEST_MSVC_SUPPRESS_WARNING_POP +DOCTEST_CLANG_SUPPRESS_WARNING_WITH_PUSH("-Wmicrosoft-cast") + filldata::fill(stream, +#if DOCTEST_GCC == 0 || DOCTEST_GCC >= DOCTEST_COMPILER(4, 9, 0) + reinterpret_cast(in) +#else + *reinterpret_cast(&in) +#endif + ); +DOCTEST_CLANG_SUPPRESS_WARNING_POP + } + }; +} + +struct DOCTEST_INTERFACE Approx +{ + Approx(double value); + + Approx operator()(double value) const; + +#ifdef DOCTEST_CONFIG_INCLUDE_TYPE_TRAITS + template + explicit Approx(const T& value, + typename detail::types::enable_if::value>::type* = + static_cast(nullptr)) { + *this = static_cast(value); + } +#endif // DOCTEST_CONFIG_INCLUDE_TYPE_TRAITS + + Approx& epsilon(double newEpsilon); + +#ifdef DOCTEST_CONFIG_INCLUDE_TYPE_TRAITS + template + typename std::enable_if::value, Approx&>::type epsilon( + const T& newEpsilon) { + m_epsilon = static_cast(newEpsilon); + return *this; + } +#endif // DOCTEST_CONFIG_INCLUDE_TYPE_TRAITS + + Approx& scale(double newScale); + +#ifdef DOCTEST_CONFIG_INCLUDE_TYPE_TRAITS + template + typename std::enable_if::value, Approx&>::type scale( + const T& newScale) { + m_scale = static_cast(newScale); + return *this; + } +#endif // DOCTEST_CONFIG_INCLUDE_TYPE_TRAITS + + // clang-format off + DOCTEST_INTERFACE friend bool operator==(double lhs, const Approx & rhs); + DOCTEST_INTERFACE friend bool operator==(const Approx & lhs, double rhs); + DOCTEST_INTERFACE friend bool operator!=(double lhs, const Approx & rhs); + DOCTEST_INTERFACE friend bool operator!=(const Approx & lhs, double rhs); + DOCTEST_INTERFACE friend bool operator<=(double lhs, const Approx & rhs); + DOCTEST_INTERFACE friend bool operator<=(const Approx & lhs, double rhs); + DOCTEST_INTERFACE friend bool operator>=(double lhs, const Approx & rhs); + DOCTEST_INTERFACE friend bool operator>=(const Approx & lhs, double rhs); + DOCTEST_INTERFACE friend bool operator< (double lhs, const Approx & rhs); + DOCTEST_INTERFACE friend bool operator< (const Approx & lhs, double rhs); + DOCTEST_INTERFACE friend bool operator> (double lhs, const Approx & rhs); + DOCTEST_INTERFACE friend bool operator> (const Approx & lhs, double rhs); + +#ifdef DOCTEST_CONFIG_INCLUDE_TYPE_TRAITS +#define DOCTEST_APPROX_PREFIX \ + template friend typename std::enable_if::value, bool>::type + + DOCTEST_APPROX_PREFIX operator==(const T& lhs, const Approx& rhs) { return operator==(static_cast(lhs), rhs); } + DOCTEST_APPROX_PREFIX operator==(const Approx& lhs, const T& rhs) { return operator==(rhs, lhs); } + DOCTEST_APPROX_PREFIX operator!=(const T& lhs, const Approx& rhs) { return !operator==(lhs, rhs); } + DOCTEST_APPROX_PREFIX operator!=(const Approx& lhs, const T& rhs) { return !operator==(rhs, lhs); } + DOCTEST_APPROX_PREFIX operator<=(const T& lhs, const Approx& rhs) { return static_cast(lhs) < rhs.m_value || lhs == rhs; } + DOCTEST_APPROX_PREFIX operator<=(const Approx& lhs, const T& rhs) { return lhs.m_value < static_cast(rhs) || lhs == rhs; } + DOCTEST_APPROX_PREFIX operator>=(const T& lhs, const Approx& rhs) { return static_cast(lhs) > rhs.m_value || lhs == rhs; } + DOCTEST_APPROX_PREFIX operator>=(const Approx& lhs, const T& rhs) { return lhs.m_value > static_cast(rhs) || lhs == rhs; } + DOCTEST_APPROX_PREFIX operator< (const T& lhs, const Approx& rhs) { return static_cast(lhs) < rhs.m_value && lhs != rhs; } + DOCTEST_APPROX_PREFIX operator< (const Approx& lhs, const T& rhs) { return lhs.m_value < static_cast(rhs) && lhs != rhs; } + DOCTEST_APPROX_PREFIX operator> (const T& lhs, const Approx& rhs) { return static_cast(lhs) > rhs.m_value && lhs != rhs; } + DOCTEST_APPROX_PREFIX operator> (const Approx& lhs, const T& rhs) { return lhs.m_value > static_cast(rhs) && lhs != rhs; } +#undef DOCTEST_APPROX_PREFIX +#endif // DOCTEST_CONFIG_INCLUDE_TYPE_TRAITS + + // clang-format on + + double m_epsilon; + double m_scale; + double m_value; +}; + +DOCTEST_INTERFACE String toString(const Approx& in); + +DOCTEST_INTERFACE const ContextOptions* getContextOptions(); + +template +struct DOCTEST_INTERFACE_DECL IsNaN +{ + F value; bool flipped; + IsNaN(F f, bool flip = false) : value(f), flipped(flip) { } + IsNaN operator!() const { return { value, !flipped }; } + operator bool() const; +}; +#ifndef __MINGW32__ +extern template struct DOCTEST_INTERFACE_DECL IsNaN; +extern template struct DOCTEST_INTERFACE_DECL IsNaN; +extern template struct DOCTEST_INTERFACE_DECL IsNaN; +#endif +DOCTEST_INTERFACE String toString(IsNaN in); +DOCTEST_INTERFACE String toString(IsNaN in); +DOCTEST_INTERFACE String toString(IsNaN in); + +#ifndef DOCTEST_CONFIG_DISABLE + +namespace detail { + // clang-format off +#ifdef DOCTEST_CONFIG_TREAT_CHAR_STAR_AS_STRING + template struct decay_array { using type = T; }; + template struct decay_array { using type = T*; }; + template struct decay_array { using type = T*; }; + + template struct not_char_pointer { static DOCTEST_CONSTEXPR int value = 1; }; + template<> struct not_char_pointer { static DOCTEST_CONSTEXPR int value = 0; }; + template<> struct not_char_pointer { static DOCTEST_CONSTEXPR int value = 0; }; + + template struct can_use_op : public not_char_pointer::type> {}; +#endif // DOCTEST_CONFIG_TREAT_CHAR_STAR_AS_STRING + // clang-format on + + struct DOCTEST_INTERFACE TestFailureException + { + }; + + DOCTEST_INTERFACE bool checkIfShouldThrow(assertType::Enum at); + +#ifndef DOCTEST_CONFIG_NO_EXCEPTIONS + DOCTEST_NORETURN +#endif // DOCTEST_CONFIG_NO_EXCEPTIONS + DOCTEST_INTERFACE void throwException(); + + struct DOCTEST_INTERFACE Subcase + { + SubcaseSignature m_signature; + bool m_entered = false; + + Subcase(const String& name, const char* file, int line); + Subcase(const Subcase&) = delete; + Subcase(Subcase&&) = delete; + Subcase& operator=(const Subcase&) = delete; + Subcase& operator=(Subcase&&) = delete; + ~Subcase(); + + operator bool() const; + + private: + bool checkFilters(); + }; + + template + String stringifyBinaryExpr(const DOCTEST_REF_WRAP(L) lhs, const char* op, + const DOCTEST_REF_WRAP(R) rhs) { + return (DOCTEST_STRINGIFY(lhs)) + op + (DOCTEST_STRINGIFY(rhs)); + } + +#if DOCTEST_CLANG && DOCTEST_CLANG < DOCTEST_COMPILER(3, 6, 0) +DOCTEST_CLANG_SUPPRESS_WARNING_WITH_PUSH("-Wunused-comparison") +#endif + +// This will check if there is any way it could find a operator like member or friend and uses it. +// If not it doesn't find the operator or if the operator at global scope is defined after +// this template, the template won't be instantiated due to SFINAE. Once the template is not +// instantiated it can look for global operator using normal conversions. +#ifdef __NVCC__ +#define SFINAE_OP(ret,op) ret +#else +#define SFINAE_OP(ret,op) decltype((void)(doctest::detail::declval() op doctest::detail::declval()),ret{}) +#endif + +#define DOCTEST_DO_BINARY_EXPRESSION_COMPARISON(op, op_str, op_macro) \ + template \ + DOCTEST_NOINLINE SFINAE_OP(Result,op) operator op(R&& rhs) { \ + bool res = op_macro(doctest::detail::forward(lhs), doctest::detail::forward(rhs)); \ + if(m_at & assertType::is_false) \ + res = !res; \ + if(!res || doctest::getContextOptions()->success) \ + return Result(res, stringifyBinaryExpr(lhs, op_str, rhs)); \ + return Result(res); \ + } + + // more checks could be added - like in Catch: + // https://github.com/catchorg/Catch2/pull/1480/files + // https://github.com/catchorg/Catch2/pull/1481/files +#define DOCTEST_FORBIT_EXPRESSION(rt, op) \ + template \ + rt& operator op(const R&) { \ + static_assert(deferred_false::value, \ + "Expression Too Complex Please Rewrite As Binary Comparison!"); \ + return *this; \ + } + + struct DOCTEST_INTERFACE Result // NOLINT(*-member-init) + { + bool m_passed; + String m_decomp; + + Result() = default; // TODO: Why do we need this? (To remove NOLINT) + Result(bool passed, const String& decomposition = String()); + + // forbidding some expressions based on this table: https://en.cppreference.com/w/cpp/language/operator_precedence + DOCTEST_FORBIT_EXPRESSION(Result, &) + DOCTEST_FORBIT_EXPRESSION(Result, ^) + DOCTEST_FORBIT_EXPRESSION(Result, |) + DOCTEST_FORBIT_EXPRESSION(Result, &&) + DOCTEST_FORBIT_EXPRESSION(Result, ||) + DOCTEST_FORBIT_EXPRESSION(Result, ==) + DOCTEST_FORBIT_EXPRESSION(Result, !=) + DOCTEST_FORBIT_EXPRESSION(Result, <) + DOCTEST_FORBIT_EXPRESSION(Result, >) + DOCTEST_FORBIT_EXPRESSION(Result, <=) + DOCTEST_FORBIT_EXPRESSION(Result, >=) + DOCTEST_FORBIT_EXPRESSION(Result, =) + DOCTEST_FORBIT_EXPRESSION(Result, +=) + DOCTEST_FORBIT_EXPRESSION(Result, -=) + DOCTEST_FORBIT_EXPRESSION(Result, *=) + DOCTEST_FORBIT_EXPRESSION(Result, /=) + DOCTEST_FORBIT_EXPRESSION(Result, %=) + DOCTEST_FORBIT_EXPRESSION(Result, <<=) + DOCTEST_FORBIT_EXPRESSION(Result, >>=) + DOCTEST_FORBIT_EXPRESSION(Result, &=) + DOCTEST_FORBIT_EXPRESSION(Result, ^=) + DOCTEST_FORBIT_EXPRESSION(Result, |=) + }; + +#ifndef DOCTEST_CONFIG_NO_COMPARISON_WARNING_SUPPRESSION + + DOCTEST_CLANG_SUPPRESS_WARNING_PUSH + DOCTEST_CLANG_SUPPRESS_WARNING("-Wsign-conversion") + DOCTEST_CLANG_SUPPRESS_WARNING("-Wsign-compare") + //DOCTEST_CLANG_SUPPRESS_WARNING("-Wdouble-promotion") + //DOCTEST_CLANG_SUPPRESS_WARNING("-Wconversion") + //DOCTEST_CLANG_SUPPRESS_WARNING("-Wfloat-equal") + + DOCTEST_GCC_SUPPRESS_WARNING_PUSH + DOCTEST_GCC_SUPPRESS_WARNING("-Wsign-conversion") + DOCTEST_GCC_SUPPRESS_WARNING("-Wsign-compare") + //DOCTEST_GCC_SUPPRESS_WARNING("-Wdouble-promotion") + //DOCTEST_GCC_SUPPRESS_WARNING("-Wconversion") + //DOCTEST_GCC_SUPPRESS_WARNING("-Wfloat-equal") + + DOCTEST_MSVC_SUPPRESS_WARNING_PUSH + // https://stackoverflow.com/questions/39479163 what's the difference between 4018 and 4389 + DOCTEST_MSVC_SUPPRESS_WARNING(4388) // signed/unsigned mismatch + DOCTEST_MSVC_SUPPRESS_WARNING(4389) // 'operator' : signed/unsigned mismatch + DOCTEST_MSVC_SUPPRESS_WARNING(4018) // 'expression' : signed/unsigned mismatch + //DOCTEST_MSVC_SUPPRESS_WARNING(4805) // 'operation' : unsafe mix of type 'type' and type 'type' in operation + +#endif // DOCTEST_CONFIG_NO_COMPARISON_WARNING_SUPPRESSION + + // clang-format off +#ifndef DOCTEST_CONFIG_TREAT_CHAR_STAR_AS_STRING +#define DOCTEST_COMPARISON_RETURN_TYPE bool +#else // DOCTEST_CONFIG_TREAT_CHAR_STAR_AS_STRING +#define DOCTEST_COMPARISON_RETURN_TYPE typename types::enable_if::value || can_use_op::value, bool>::type + inline bool eq(const char* lhs, const char* rhs) { return String(lhs) == String(rhs); } + inline bool ne(const char* lhs, const char* rhs) { return String(lhs) != String(rhs); } + inline bool lt(const char* lhs, const char* rhs) { return String(lhs) < String(rhs); } + inline bool gt(const char* lhs, const char* rhs) { return String(lhs) > String(rhs); } + inline bool le(const char* lhs, const char* rhs) { return String(lhs) <= String(rhs); } + inline bool ge(const char* lhs, const char* rhs) { return String(lhs) >= String(rhs); } +#endif // DOCTEST_CONFIG_TREAT_CHAR_STAR_AS_STRING + // clang-format on + +#define DOCTEST_RELATIONAL_OP(name, op) \ + template \ + DOCTEST_COMPARISON_RETURN_TYPE name(const DOCTEST_REF_WRAP(L) lhs, \ + const DOCTEST_REF_WRAP(R) rhs) { \ + return lhs op rhs; \ + } + + DOCTEST_RELATIONAL_OP(eq, ==) + DOCTEST_RELATIONAL_OP(ne, !=) + DOCTEST_RELATIONAL_OP(lt, <) + DOCTEST_RELATIONAL_OP(gt, >) + DOCTEST_RELATIONAL_OP(le, <=) + DOCTEST_RELATIONAL_OP(ge, >=) + +#ifndef DOCTEST_CONFIG_TREAT_CHAR_STAR_AS_STRING +#define DOCTEST_CMP_EQ(l, r) l == r +#define DOCTEST_CMP_NE(l, r) l != r +#define DOCTEST_CMP_GT(l, r) l > r +#define DOCTEST_CMP_LT(l, r) l < r +#define DOCTEST_CMP_GE(l, r) l >= r +#define DOCTEST_CMP_LE(l, r) l <= r +#else // DOCTEST_CONFIG_TREAT_CHAR_STAR_AS_STRING +#define DOCTEST_CMP_EQ(l, r) eq(l, r) +#define DOCTEST_CMP_NE(l, r) ne(l, r) +#define DOCTEST_CMP_GT(l, r) gt(l, r) +#define DOCTEST_CMP_LT(l, r) lt(l, r) +#define DOCTEST_CMP_GE(l, r) ge(l, r) +#define DOCTEST_CMP_LE(l, r) le(l, r) +#endif // DOCTEST_CONFIG_TREAT_CHAR_STAR_AS_STRING + + template + // cppcheck-suppress copyCtorAndEqOperator + struct Expression_lhs + { + L lhs; + assertType::Enum m_at; + + explicit Expression_lhs(L&& in, assertType::Enum at) + : lhs(static_cast(in)) + , m_at(at) {} + + DOCTEST_NOINLINE operator Result() { +// this is needed only for MSVC 2015 +DOCTEST_MSVC_SUPPRESS_WARNING_WITH_PUSH(4800) // 'int': forcing value to bool + bool res = static_cast(lhs); +DOCTEST_MSVC_SUPPRESS_WARNING_POP + if(m_at & assertType::is_false) { //!OCLINT bitwise operator in conditional + res = !res; + } + + if(!res || getContextOptions()->success) { + return { res, (DOCTEST_STRINGIFY(lhs)) }; + } + return { res }; + } + + /* This is required for user-defined conversions from Expression_lhs to L */ + operator L() const { return lhs; } + + // clang-format off + DOCTEST_DO_BINARY_EXPRESSION_COMPARISON(==, " == ", DOCTEST_CMP_EQ) //!OCLINT bitwise operator in conditional + DOCTEST_DO_BINARY_EXPRESSION_COMPARISON(!=, " != ", DOCTEST_CMP_NE) //!OCLINT bitwise operator in conditional + DOCTEST_DO_BINARY_EXPRESSION_COMPARISON(>, " > ", DOCTEST_CMP_GT) //!OCLINT bitwise operator in conditional + DOCTEST_DO_BINARY_EXPRESSION_COMPARISON(<, " < ", DOCTEST_CMP_LT) //!OCLINT bitwise operator in conditional + DOCTEST_DO_BINARY_EXPRESSION_COMPARISON(>=, " >= ", DOCTEST_CMP_GE) //!OCLINT bitwise operator in conditional + DOCTEST_DO_BINARY_EXPRESSION_COMPARISON(<=, " <= ", DOCTEST_CMP_LE) //!OCLINT bitwise operator in conditional + // clang-format on + + // forbidding some expressions based on this table: https://en.cppreference.com/w/cpp/language/operator_precedence + DOCTEST_FORBIT_EXPRESSION(Expression_lhs, &) + DOCTEST_FORBIT_EXPRESSION(Expression_lhs, ^) + DOCTEST_FORBIT_EXPRESSION(Expression_lhs, |) + DOCTEST_FORBIT_EXPRESSION(Expression_lhs, &&) + DOCTEST_FORBIT_EXPRESSION(Expression_lhs, ||) + DOCTEST_FORBIT_EXPRESSION(Expression_lhs, =) + DOCTEST_FORBIT_EXPRESSION(Expression_lhs, +=) + DOCTEST_FORBIT_EXPRESSION(Expression_lhs, -=) + DOCTEST_FORBIT_EXPRESSION(Expression_lhs, *=) + DOCTEST_FORBIT_EXPRESSION(Expression_lhs, /=) + DOCTEST_FORBIT_EXPRESSION(Expression_lhs, %=) + DOCTEST_FORBIT_EXPRESSION(Expression_lhs, <<=) + DOCTEST_FORBIT_EXPRESSION(Expression_lhs, >>=) + DOCTEST_FORBIT_EXPRESSION(Expression_lhs, &=) + DOCTEST_FORBIT_EXPRESSION(Expression_lhs, ^=) + DOCTEST_FORBIT_EXPRESSION(Expression_lhs, |=) + // these 2 are unfortunate because they should be allowed - they have higher precedence over the comparisons, but the + // ExpressionDecomposer class uses the left shift operator to capture the left operand of the binary expression... + DOCTEST_FORBIT_EXPRESSION(Expression_lhs, <<) + DOCTEST_FORBIT_EXPRESSION(Expression_lhs, >>) + }; + +#ifndef DOCTEST_CONFIG_NO_COMPARISON_WARNING_SUPPRESSION + + DOCTEST_CLANG_SUPPRESS_WARNING_POP + DOCTEST_MSVC_SUPPRESS_WARNING_POP + DOCTEST_GCC_SUPPRESS_WARNING_POP + +#endif // DOCTEST_CONFIG_NO_COMPARISON_WARNING_SUPPRESSION + +#if DOCTEST_CLANG && DOCTEST_CLANG < DOCTEST_COMPILER(3, 6, 0) +DOCTEST_CLANG_SUPPRESS_WARNING_POP +#endif + + struct DOCTEST_INTERFACE ExpressionDecomposer + { + assertType::Enum m_at; + + ExpressionDecomposer(assertType::Enum at); + + // The right operator for capturing expressions is "<=" instead of "<<" (based on the operator precedence table) + // but then there will be warnings from GCC about "-Wparentheses" and since "_Pragma()" is problematic this will stay for now... + // https://github.com/catchorg/Catch2/issues/870 + // https://github.com/catchorg/Catch2/issues/565 + template + Expression_lhs operator<<(L&& operand) { + return Expression_lhs(static_cast(operand), m_at); + } + + template ::value,void >::type* = nullptr> + Expression_lhs operator<<(const L &operand) { + return Expression_lhs(operand, m_at); + } + }; + + struct DOCTEST_INTERFACE TestSuite + { + const char* m_test_suite = nullptr; + const char* m_description = nullptr; + bool m_skip = false; + bool m_no_breaks = false; + bool m_no_output = false; + bool m_may_fail = false; + bool m_should_fail = false; + int m_expected_failures = 0; + double m_timeout = 0; + + TestSuite& operator*(const char* in); + + template + TestSuite& operator*(const T& in) { + in.fill(*this); + return *this; + } + }; + + using funcType = void (*)(); + + struct DOCTEST_INTERFACE TestCase : public TestCaseData + { + funcType m_test; // a function pointer to the test case + + String m_type; // for templated test cases - gets appended to the real name + int m_template_id; // an ID used to distinguish between the different versions of a templated test case + String m_full_name; // contains the name (only for templated test cases!) + the template type + + TestCase(funcType test, const char* file, unsigned line, const TestSuite& test_suite, + const String& type = String(), int template_id = -1); + + TestCase(const TestCase& other); + TestCase(TestCase&&) = delete; + + DOCTEST_MSVC_SUPPRESS_WARNING_WITH_PUSH(26434) // hides a non-virtual function + TestCase& operator=(const TestCase& other); + DOCTEST_MSVC_SUPPRESS_WARNING_POP + + TestCase& operator=(TestCase&&) = delete; + + TestCase& operator*(const char* in); + + template + TestCase& operator*(const T& in) { + in.fill(*this); + return *this; + } + + bool operator<(const TestCase& other) const; + + ~TestCase() = default; + }; + + // forward declarations of functions used by the macros + DOCTEST_INTERFACE int regTest(const TestCase& tc); + DOCTEST_INTERFACE int setTestSuite(const TestSuite& ts); + DOCTEST_INTERFACE bool isDebuggerActive(); + + template + int instantiationHelper(const T&) { return 0; } + + namespace binaryAssertComparison { + enum Enum + { + eq = 0, + ne, + gt, + lt, + ge, + le + }; + } // namespace binaryAssertComparison + + // clang-format off + template struct RelationalComparator { bool operator()(const DOCTEST_REF_WRAP(L), const DOCTEST_REF_WRAP(R) ) const { return false; } }; + +#define DOCTEST_BINARY_RELATIONAL_OP(n, op) \ + template struct RelationalComparator { bool operator()(const DOCTEST_REF_WRAP(L) lhs, const DOCTEST_REF_WRAP(R) rhs) const { return op(lhs, rhs); } }; + // clang-format on + + DOCTEST_BINARY_RELATIONAL_OP(0, doctest::detail::eq) + DOCTEST_BINARY_RELATIONAL_OP(1, doctest::detail::ne) + DOCTEST_BINARY_RELATIONAL_OP(2, doctest::detail::gt) + DOCTEST_BINARY_RELATIONAL_OP(3, doctest::detail::lt) + DOCTEST_BINARY_RELATIONAL_OP(4, doctest::detail::ge) + DOCTEST_BINARY_RELATIONAL_OP(5, doctest::detail::le) + + struct DOCTEST_INTERFACE ResultBuilder : public AssertData + { + ResultBuilder(assertType::Enum at, const char* file, int line, const char* expr, + const char* exception_type = "", const String& exception_string = ""); + + ResultBuilder(assertType::Enum at, const char* file, int line, const char* expr, + const char* exception_type, const Contains& exception_string); + + void setResult(const Result& res); + + template + DOCTEST_NOINLINE bool binary_assert(const DOCTEST_REF_WRAP(L) lhs, + const DOCTEST_REF_WRAP(R) rhs) { + m_failed = !RelationalComparator()(lhs, rhs); + if (m_failed || getContextOptions()->success) { + m_decomp = stringifyBinaryExpr(lhs, ", ", rhs); + } + return !m_failed; + } + + template + DOCTEST_NOINLINE bool unary_assert(const DOCTEST_REF_WRAP(L) val) { + m_failed = !val; + + if (m_at & assertType::is_false) { //!OCLINT bitwise operator in conditional + m_failed = !m_failed; + } + + if (m_failed || getContextOptions()->success) { + m_decomp = (DOCTEST_STRINGIFY(val)); + } + + return !m_failed; + } + + void translateException(); + + bool log(); + void react() const; + }; + + namespace assertAction { + enum Enum + { + nothing = 0, + dbgbreak = 1, + shouldthrow = 2 + }; + } // namespace assertAction + + DOCTEST_INTERFACE void failed_out_of_a_testing_context(const AssertData& ad); + + DOCTEST_INTERFACE bool decomp_assert(assertType::Enum at, const char* file, int line, + const char* expr, const Result& result); + +#define DOCTEST_ASSERT_OUT_OF_TESTS(decomp) \ + do { \ + if(!is_running_in_test) { \ + if(failed) { \ + ResultBuilder rb(at, file, line, expr); \ + rb.m_failed = failed; \ + rb.m_decomp = decomp; \ + failed_out_of_a_testing_context(rb); \ + if(isDebuggerActive() && !getContextOptions()->no_breaks) \ + DOCTEST_BREAK_INTO_DEBUGGER(); \ + if(checkIfShouldThrow(at)) \ + throwException(); \ + } \ + return !failed; \ + } \ + } while(false) + +#define DOCTEST_ASSERT_IN_TESTS(decomp) \ + ResultBuilder rb(at, file, line, expr); \ + rb.m_failed = failed; \ + if(rb.m_failed || getContextOptions()->success) \ + rb.m_decomp = decomp; \ + if(rb.log()) \ + DOCTEST_BREAK_INTO_DEBUGGER(); \ + if(rb.m_failed && checkIfShouldThrow(at)) \ + throwException() + + template + DOCTEST_NOINLINE bool binary_assert(assertType::Enum at, const char* file, int line, + const char* expr, const DOCTEST_REF_WRAP(L) lhs, + const DOCTEST_REF_WRAP(R) rhs) { + bool failed = !RelationalComparator()(lhs, rhs); + + // ################################################################################### + // IF THE DEBUGGER BREAKS HERE - GO 1 LEVEL UP IN THE CALLSTACK FOR THE FAILING ASSERT + // THIS IS THE EFFECT OF HAVING 'DOCTEST_CONFIG_SUPER_FAST_ASSERTS' DEFINED + // ################################################################################### + DOCTEST_ASSERT_OUT_OF_TESTS(stringifyBinaryExpr(lhs, ", ", rhs)); + DOCTEST_ASSERT_IN_TESTS(stringifyBinaryExpr(lhs, ", ", rhs)); + return !failed; + } + + template + DOCTEST_NOINLINE bool unary_assert(assertType::Enum at, const char* file, int line, + const char* expr, const DOCTEST_REF_WRAP(L) val) { + bool failed = !val; + + if(at & assertType::is_false) //!OCLINT bitwise operator in conditional + failed = !failed; + + // ################################################################################### + // IF THE DEBUGGER BREAKS HERE - GO 1 LEVEL UP IN THE CALLSTACK FOR THE FAILING ASSERT + // THIS IS THE EFFECT OF HAVING 'DOCTEST_CONFIG_SUPER_FAST_ASSERTS' DEFINED + // ################################################################################### + DOCTEST_ASSERT_OUT_OF_TESTS((DOCTEST_STRINGIFY(val))); + DOCTEST_ASSERT_IN_TESTS((DOCTEST_STRINGIFY(val))); + return !failed; + } + + struct DOCTEST_INTERFACE IExceptionTranslator + { + DOCTEST_DECLARE_INTERFACE(IExceptionTranslator) + virtual bool translate(String&) const = 0; + }; + + template + class ExceptionTranslator : public IExceptionTranslator //!OCLINT destructor of virtual class + { + public: + explicit ExceptionTranslator(String (*translateFunction)(T)) + : m_translateFunction(translateFunction) {} + + bool translate(String& res) const override { +#ifndef DOCTEST_CONFIG_NO_EXCEPTIONS + try { + throw; // lgtm [cpp/rethrow-no-exception] + // cppcheck-suppress catchExceptionByValue + } catch(const T& ex) { + res = m_translateFunction(ex); //!OCLINT parameter reassignment + return true; + } catch(...) {} //!OCLINT - empty catch statement +#endif // DOCTEST_CONFIG_NO_EXCEPTIONS + static_cast(res); // to silence -Wunused-parameter + return false; + } + + private: + String (*m_translateFunction)(T); + }; + + DOCTEST_INTERFACE void registerExceptionTranslatorImpl(const IExceptionTranslator* et); + + // ContextScope base class used to allow implementing methods of ContextScope + // that don't depend on the template parameter in doctest.cpp. + struct DOCTEST_INTERFACE ContextScopeBase : public IContextScope { + ContextScopeBase(const ContextScopeBase&) = delete; + + ContextScopeBase& operator=(const ContextScopeBase&) = delete; + ContextScopeBase& operator=(ContextScopeBase&&) = delete; + + ~ContextScopeBase() override = default; + + protected: + ContextScopeBase(); + ContextScopeBase(ContextScopeBase&& other) noexcept; + + void destroy(); + bool need_to_destroy{true}; + }; + + template class ContextScope : public ContextScopeBase + { + L lambda_; + + public: + explicit ContextScope(const L &lambda) : lambda_(lambda) {} + explicit ContextScope(L&& lambda) : lambda_(static_cast(lambda)) { } + + ContextScope(const ContextScope&) = delete; + ContextScope(ContextScope&&) noexcept = default; + + ContextScope& operator=(const ContextScope&) = delete; + ContextScope& operator=(ContextScope&&) = delete; + + void stringify(std::ostream* s) const override { lambda_(s); } + + ~ContextScope() override { + if (need_to_destroy) { + destroy(); + } + } + }; + + struct DOCTEST_INTERFACE MessageBuilder : public MessageData + { + std::ostream* m_stream; + bool logged = false; + + MessageBuilder(const char* file, int line, assertType::Enum severity); + + MessageBuilder(const MessageBuilder&) = delete; + MessageBuilder(MessageBuilder&&) = delete; + + MessageBuilder& operator=(const MessageBuilder&) = delete; + MessageBuilder& operator=(MessageBuilder&&) = delete; + + ~MessageBuilder(); + + // the preferred way of chaining parameters for stringification +DOCTEST_MSVC_SUPPRESS_WARNING_WITH_PUSH(4866) + template + MessageBuilder& operator,(const T& in) { + *m_stream << (DOCTEST_STRINGIFY(in)); + return *this; + } +DOCTEST_MSVC_SUPPRESS_WARNING_POP + + // kept here just for backwards-compatibility - the comma operator should be preferred now + template + MessageBuilder& operator<<(const T& in) { return this->operator,(in); } + + // the `,` operator has the lowest operator precedence - if `<<` is used by the user then + // the `,` operator will be called last which is not what we want and thus the `*` operator + // is used first (has higher operator precedence compared to `<<`) so that we guarantee that + // an operator of the MessageBuilder class is called first before the rest of the parameters + template + MessageBuilder& operator*(const T& in) { return this->operator,(in); } + + bool log(); + void react(); + }; + + template + ContextScope MakeContextScope(const L &lambda) { + return ContextScope(lambda); + } +} // namespace detail + +#define DOCTEST_DEFINE_DECORATOR(name, type, def) \ + struct name \ + { \ + type data; \ + name(type in = def) \ + : data(in) {} \ + void fill(detail::TestCase& state) const { state.DOCTEST_CAT(m_, name) = data; } \ + void fill(detail::TestSuite& state) const { state.DOCTEST_CAT(m_, name) = data; } \ + } + +DOCTEST_DEFINE_DECORATOR(test_suite, const char*, ""); +DOCTEST_DEFINE_DECORATOR(description, const char*, ""); +DOCTEST_DEFINE_DECORATOR(skip, bool, true); +DOCTEST_DEFINE_DECORATOR(no_breaks, bool, true); +DOCTEST_DEFINE_DECORATOR(no_output, bool, true); +DOCTEST_DEFINE_DECORATOR(timeout, double, 0); +DOCTEST_DEFINE_DECORATOR(may_fail, bool, true); +DOCTEST_DEFINE_DECORATOR(should_fail, bool, true); +DOCTEST_DEFINE_DECORATOR(expected_failures, int, 0); + +template +int registerExceptionTranslator(String (*translateFunction)(T)) { + DOCTEST_CLANG_SUPPRESS_WARNING_WITH_PUSH("-Wexit-time-destructors") + static detail::ExceptionTranslator exceptionTranslator(translateFunction); + DOCTEST_CLANG_SUPPRESS_WARNING_POP + detail::registerExceptionTranslatorImpl(&exceptionTranslator); + return 0; +} + +} // namespace doctest + +// in a separate namespace outside of doctest because the DOCTEST_TEST_SUITE macro +// introduces an anonymous namespace in which getCurrentTestSuite gets overridden +namespace doctest_detail_test_suite_ns { +DOCTEST_INTERFACE doctest::detail::TestSuite& getCurrentTestSuite(); +} // namespace doctest_detail_test_suite_ns + +namespace doctest { +#else // DOCTEST_CONFIG_DISABLE +template +int registerExceptionTranslator(String (*)(T)) { + return 0; +} +#endif // DOCTEST_CONFIG_DISABLE + +namespace detail { + using assert_handler = void (*)(const AssertData&); + struct ContextState; +} // namespace detail + +class DOCTEST_INTERFACE Context +{ + detail::ContextState* p; + + void parseArgs(int argc, const char* const* argv, bool withDefaults = false); + +public: + explicit Context(int argc = 0, const char* const* argv = nullptr); + + Context(const Context&) = delete; + Context(Context&&) = delete; + + Context& operator=(const Context&) = delete; + Context& operator=(Context&&) = delete; + + ~Context(); // NOLINT(performance-trivially-destructible) + + void applyCommandLine(int argc, const char* const* argv); + + void addFilter(const char* filter, const char* value); + void clearFilters(); + void setOption(const char* option, bool value); + void setOption(const char* option, int value); + void setOption(const char* option, const char* value); + + bool shouldExit(); + + void setAsDefaultForAssertsOutOfTestCases(); + + void setAssertHandler(detail::assert_handler ah); + + void setCout(std::ostream* out); + + int run(); +}; + +namespace TestCaseFailureReason { + enum Enum + { + None = 0, + AssertFailure = 1, // an assertion has failed in the test case + Exception = 2, // test case threw an exception + Crash = 4, // a crash... + TooManyFailedAsserts = 8, // the abort-after option + Timeout = 16, // see the timeout decorator + ShouldHaveFailedButDidnt = 32, // see the should_fail decorator + ShouldHaveFailedAndDid = 64, // see the should_fail decorator + DidntFailExactlyNumTimes = 128, // see the expected_failures decorator + FailedExactlyNumTimes = 256, // see the expected_failures decorator + CouldHaveFailedAndDid = 512 // see the may_fail decorator + }; +} // namespace TestCaseFailureReason + +struct DOCTEST_INTERFACE CurrentTestCaseStats +{ + int numAssertsCurrentTest; + int numAssertsFailedCurrentTest; + double seconds; + int failure_flags; // use TestCaseFailureReason::Enum + bool testCaseSuccess; +}; + +struct DOCTEST_INTERFACE TestCaseException +{ + String error_string; + bool is_crash; +}; + +struct DOCTEST_INTERFACE TestRunStats +{ + unsigned numTestCases; + unsigned numTestCasesPassingFilters; + unsigned numTestSuitesPassingFilters; + unsigned numTestCasesFailed; + int numAsserts; + int numAssertsFailed; +}; + +struct QueryData +{ + const TestRunStats* run_stats = nullptr; + const TestCaseData** data = nullptr; + unsigned num_data = 0; +}; + +struct DOCTEST_INTERFACE IReporter +{ + // The constructor has to accept "const ContextOptions&" as a single argument + // which has most of the options for the run + a pointer to the stdout stream + // Reporter(const ContextOptions& in) + + // called when a query should be reported (listing test cases, printing the version, etc.) + virtual void report_query(const QueryData&) = 0; + + // called when the whole test run starts + virtual void test_run_start() = 0; + // called when the whole test run ends (caching a pointer to the input doesn't make sense here) + virtual void test_run_end(const TestRunStats&) = 0; + + // called when a test case is started (safe to cache a pointer to the input) + virtual void test_case_start(const TestCaseData&) = 0; + // called when a test case is reentered because of unfinished subcases (safe to cache a pointer to the input) + virtual void test_case_reenter(const TestCaseData&) = 0; + // called when a test case has ended + virtual void test_case_end(const CurrentTestCaseStats&) = 0; + + // called when an exception is thrown from the test case (or it crashes) + virtual void test_case_exception(const TestCaseException&) = 0; + + // called whenever a subcase is entered (don't cache pointers to the input) + virtual void subcase_start(const SubcaseSignature&) = 0; + // called whenever a subcase is exited (don't cache pointers to the input) + virtual void subcase_end() = 0; + + // called for each assert (don't cache pointers to the input) + virtual void log_assert(const AssertData&) = 0; + // called for each message (don't cache pointers to the input) + virtual void log_message(const MessageData&) = 0; + + // called when a test case is skipped either because it doesn't pass the filters, has a skip decorator + // or isn't in the execution range (between first and last) (safe to cache a pointer to the input) + virtual void test_case_skipped(const TestCaseData&) = 0; + + DOCTEST_DECLARE_INTERFACE(IReporter) + + // can obtain all currently active contexts and stringify them if one wishes to do so + static int get_num_active_contexts(); + static const IContextScope* const* get_active_contexts(); + + // can iterate through contexts which have been stringified automatically in their destructors when an exception has been thrown + static int get_num_stringified_contexts(); + static const String* get_stringified_contexts(); +}; + +namespace detail { + using reporterCreatorFunc = IReporter* (*)(const ContextOptions&); + + DOCTEST_INTERFACE void registerReporterImpl(const char* name, int prio, reporterCreatorFunc c, bool isReporter); + + template + IReporter* reporterCreator(const ContextOptions& o) { + return new Reporter(o); + } +} // namespace detail + +template +int registerReporter(const char* name, int priority, bool isReporter) { + detail::registerReporterImpl(name, priority, detail::reporterCreator, isReporter); + return 0; +} +} // namespace doctest + +#ifdef DOCTEST_CONFIG_ASSERTS_RETURN_VALUES +#define DOCTEST_FUNC_EMPTY [] { return false; }() +#else +#define DOCTEST_FUNC_EMPTY (void)0 +#endif + +// if registering is not disabled +#ifndef DOCTEST_CONFIG_DISABLE + +#ifdef DOCTEST_CONFIG_ASSERTS_RETURN_VALUES +#define DOCTEST_FUNC_SCOPE_BEGIN [&] +#define DOCTEST_FUNC_SCOPE_END () +#define DOCTEST_FUNC_SCOPE_RET(v) return v +#else +#define DOCTEST_FUNC_SCOPE_BEGIN do +#define DOCTEST_FUNC_SCOPE_END while(false) +#define DOCTEST_FUNC_SCOPE_RET(v) (void)0 +#endif + +// common code in asserts - for convenience +#define DOCTEST_ASSERT_LOG_REACT_RETURN(b) \ + if(b.log()) DOCTEST_BREAK_INTO_DEBUGGER(); \ + b.react(); \ + DOCTEST_FUNC_SCOPE_RET(!b.m_failed) + +#ifdef DOCTEST_CONFIG_NO_TRY_CATCH_IN_ASSERTS +#define DOCTEST_WRAP_IN_TRY(x) x; +#else // DOCTEST_CONFIG_NO_TRY_CATCH_IN_ASSERTS +#define DOCTEST_WRAP_IN_TRY(x) \ + try { \ + x; \ + } catch(...) { DOCTEST_RB.translateException(); } +#endif // DOCTEST_CONFIG_NO_TRY_CATCH_IN_ASSERTS + +#ifdef DOCTEST_CONFIG_VOID_CAST_EXPRESSIONS +#define DOCTEST_CAST_TO_VOID(...) \ + DOCTEST_GCC_SUPPRESS_WARNING_WITH_PUSH("-Wuseless-cast") \ + static_cast(__VA_ARGS__); \ + DOCTEST_GCC_SUPPRESS_WARNING_POP +#else // DOCTEST_CONFIG_VOID_CAST_EXPRESSIONS +#define DOCTEST_CAST_TO_VOID(...) __VA_ARGS__; +#endif // DOCTEST_CONFIG_VOID_CAST_EXPRESSIONS + +// registers the test by initializing a dummy var with a function +#define DOCTEST_REGISTER_FUNCTION(global_prefix, f, decorators) \ + global_prefix DOCTEST_GLOBAL_NO_WARNINGS(DOCTEST_ANONYMOUS(DOCTEST_ANON_VAR_), /* NOLINT */ \ + doctest::detail::regTest( \ + doctest::detail::TestCase( \ + f, __FILE__, __LINE__, \ + doctest_detail_test_suite_ns::getCurrentTestSuite()) * \ + decorators)) + +#define DOCTEST_IMPLEMENT_FIXTURE(der, base, func, decorators) \ + namespace { /* NOLINT */ \ + struct der : public base \ + { \ + void f(); \ + }; \ + static DOCTEST_INLINE_NOINLINE void func() { \ + der v; \ + v.f(); \ + } \ + DOCTEST_REGISTER_FUNCTION(DOCTEST_EMPTY, func, decorators) \ + } \ + DOCTEST_INLINE_NOINLINE void der::f() // NOLINT(misc-definitions-in-headers) + +#define DOCTEST_CREATE_AND_REGISTER_FUNCTION(f, decorators) \ + static void f(); \ + DOCTEST_REGISTER_FUNCTION(DOCTEST_EMPTY, f, decorators) \ + static void f() + +#define DOCTEST_CREATE_AND_REGISTER_FUNCTION_IN_CLASS(f, proxy, decorators) \ + static doctest::detail::funcType proxy() { return f; } \ + DOCTEST_REGISTER_FUNCTION(inline, proxy(), decorators) \ + static void f() + +// for registering tests +#define DOCTEST_TEST_CASE(decorators) \ + DOCTEST_CREATE_AND_REGISTER_FUNCTION(DOCTEST_ANONYMOUS(DOCTEST_ANON_FUNC_), decorators) + +// for registering tests in classes - requires C++17 for inline variables! +#if DOCTEST_CPLUSPLUS >= 201703L +#define DOCTEST_TEST_CASE_CLASS(decorators) \ + DOCTEST_CREATE_AND_REGISTER_FUNCTION_IN_CLASS(DOCTEST_ANONYMOUS(DOCTEST_ANON_FUNC_), \ + DOCTEST_ANONYMOUS(DOCTEST_ANON_PROXY_), \ + decorators) +#else // DOCTEST_TEST_CASE_CLASS +#define DOCTEST_TEST_CASE_CLASS(...) \ + TEST_CASES_CAN_BE_REGISTERED_IN_CLASSES_ONLY_IN_CPP17_MODE_OR_WITH_VS_2017_OR_NEWER +#endif // DOCTEST_TEST_CASE_CLASS + +// for registering tests with a fixture +#define DOCTEST_TEST_CASE_FIXTURE(c, decorators) \ + DOCTEST_IMPLEMENT_FIXTURE(DOCTEST_ANONYMOUS(DOCTEST_ANON_CLASS_), c, \ + DOCTEST_ANONYMOUS(DOCTEST_ANON_FUNC_), decorators) + +// for converting types to strings without the header and demangling +#define DOCTEST_TYPE_TO_STRING_AS(str, ...) \ + namespace doctest { \ + template <> \ + inline String toString<__VA_ARGS__>() { \ + return str; \ + } \ + } \ + static_assert(true, "") + +#define DOCTEST_TYPE_TO_STRING(...) DOCTEST_TYPE_TO_STRING_AS(#__VA_ARGS__, __VA_ARGS__) + +#define DOCTEST_TEST_CASE_TEMPLATE_DEFINE_IMPL(dec, T, iter, func) \ + template \ + static void func(); \ + namespace { /* NOLINT */ \ + template \ + struct iter; \ + template \ + struct iter> \ + { \ + iter(const char* file, unsigned line, int index) { \ + doctest::detail::regTest(doctest::detail::TestCase(func, file, line, \ + doctest_detail_test_suite_ns::getCurrentTestSuite(), \ + doctest::toString(), \ + int(line) * 1000 + index) \ + * dec); \ + iter>(file, line, index + 1); \ + } \ + }; \ + template <> \ + struct iter> \ + { \ + iter(const char*, unsigned, int) {} \ + }; \ + } \ + template \ + static void func() + +#define DOCTEST_TEST_CASE_TEMPLATE_DEFINE(dec, T, id) \ + DOCTEST_TEST_CASE_TEMPLATE_DEFINE_IMPL(dec, T, DOCTEST_CAT(id, ITERATOR), \ + DOCTEST_ANONYMOUS(DOCTEST_ANON_TMP_)) + +#define DOCTEST_TEST_CASE_TEMPLATE_INSTANTIATE_IMPL(id, anon, ...) \ + DOCTEST_GLOBAL_NO_WARNINGS(DOCTEST_CAT(anon, DUMMY), /* NOLINT(cert-err58-cpp, fuchsia-statically-constructed-objects) */ \ + doctest::detail::instantiationHelper( \ + DOCTEST_CAT(id, ITERATOR)<__VA_ARGS__>(__FILE__, __LINE__, 0))) + +#define DOCTEST_TEST_CASE_TEMPLATE_INVOKE(id, ...) \ + DOCTEST_TEST_CASE_TEMPLATE_INSTANTIATE_IMPL(id, DOCTEST_ANONYMOUS(DOCTEST_ANON_TMP_), std::tuple<__VA_ARGS__>) \ + static_assert(true, "") + +#define DOCTEST_TEST_CASE_TEMPLATE_APPLY(id, ...) \ + DOCTEST_TEST_CASE_TEMPLATE_INSTANTIATE_IMPL(id, DOCTEST_ANONYMOUS(DOCTEST_ANON_TMP_), __VA_ARGS__) \ + static_assert(true, "") + +#define DOCTEST_TEST_CASE_TEMPLATE_IMPL(dec, T, anon, ...) \ + DOCTEST_TEST_CASE_TEMPLATE_DEFINE_IMPL(dec, T, DOCTEST_CAT(anon, ITERATOR), anon); \ + DOCTEST_TEST_CASE_TEMPLATE_INSTANTIATE_IMPL(anon, anon, std::tuple<__VA_ARGS__>) \ + template \ + static void anon() + +#define DOCTEST_TEST_CASE_TEMPLATE(dec, T, ...) \ + DOCTEST_TEST_CASE_TEMPLATE_IMPL(dec, T, DOCTEST_ANONYMOUS(DOCTEST_ANON_TMP_), __VA_ARGS__) + +// for subcases +#define DOCTEST_SUBCASE(name) \ + if(const doctest::detail::Subcase & DOCTEST_ANONYMOUS(DOCTEST_ANON_SUBCASE_) DOCTEST_UNUSED = \ + doctest::detail::Subcase(name, __FILE__, __LINE__)) + +// for grouping tests in test suites by using code blocks +#define DOCTEST_TEST_SUITE_IMPL(decorators, ns_name) \ + namespace ns_name { namespace doctest_detail_test_suite_ns { \ + static DOCTEST_NOINLINE doctest::detail::TestSuite& getCurrentTestSuite() noexcept { \ + DOCTEST_MSVC_SUPPRESS_WARNING_WITH_PUSH(4640) \ + DOCTEST_CLANG_SUPPRESS_WARNING_WITH_PUSH("-Wexit-time-destructors") \ + DOCTEST_GCC_SUPPRESS_WARNING_WITH_PUSH("-Wmissing-field-initializers") \ + static doctest::detail::TestSuite data{}; \ + static bool inited = false; \ + DOCTEST_MSVC_SUPPRESS_WARNING_POP \ + DOCTEST_CLANG_SUPPRESS_WARNING_POP \ + DOCTEST_GCC_SUPPRESS_WARNING_POP \ + if(!inited) { \ + data* decorators; \ + inited = true; \ + } \ + return data; \ + } \ + } \ + } \ + namespace ns_name + +#define DOCTEST_TEST_SUITE(decorators) \ + DOCTEST_TEST_SUITE_IMPL(decorators, DOCTEST_ANONYMOUS(DOCTEST_ANON_SUITE_)) + +// for starting a testsuite block +#define DOCTEST_TEST_SUITE_BEGIN(decorators) \ + DOCTEST_GLOBAL_NO_WARNINGS(DOCTEST_ANONYMOUS(DOCTEST_ANON_VAR_), /* NOLINT(cert-err58-cpp) */ \ + doctest::detail::setTestSuite(doctest::detail::TestSuite() * decorators)) \ + static_assert(true, "") + +// for ending a testsuite block +#define DOCTEST_TEST_SUITE_END \ + DOCTEST_GLOBAL_NO_WARNINGS(DOCTEST_ANONYMOUS(DOCTEST_ANON_VAR_), /* NOLINT(cert-err58-cpp) */ \ + doctest::detail::setTestSuite(doctest::detail::TestSuite() * "")) \ + using DOCTEST_ANONYMOUS(DOCTEST_ANON_FOR_SEMICOLON_) = int + +// for registering exception translators +#define DOCTEST_REGISTER_EXCEPTION_TRANSLATOR_IMPL(translatorName, signature) \ + inline doctest::String translatorName(signature); \ + DOCTEST_GLOBAL_NO_WARNINGS(DOCTEST_ANONYMOUS(DOCTEST_ANON_TRANSLATOR_), /* NOLINT(cert-err58-cpp) */ \ + doctest::registerExceptionTranslator(translatorName)) \ + doctest::String translatorName(signature) + +#define DOCTEST_REGISTER_EXCEPTION_TRANSLATOR(signature) \ + DOCTEST_REGISTER_EXCEPTION_TRANSLATOR_IMPL(DOCTEST_ANONYMOUS(DOCTEST_ANON_TRANSLATOR_), \ + signature) + +// for registering reporters +#define DOCTEST_REGISTER_REPORTER(name, priority, reporter) \ + DOCTEST_GLOBAL_NO_WARNINGS(DOCTEST_ANONYMOUS(DOCTEST_ANON_REPORTER_), /* NOLINT(cert-err58-cpp) */ \ + doctest::registerReporter(name, priority, true)) \ + static_assert(true, "") + +// for registering listeners +#define DOCTEST_REGISTER_LISTENER(name, priority, reporter) \ + DOCTEST_GLOBAL_NO_WARNINGS(DOCTEST_ANONYMOUS(DOCTEST_ANON_REPORTER_), /* NOLINT(cert-err58-cpp) */ \ + doctest::registerReporter(name, priority, false)) \ + static_assert(true, "") + +// clang-format off +// for logging - disabling formatting because it's important to have these on 2 separate lines - see PR #557 +#define DOCTEST_INFO(...) \ + DOCTEST_INFO_IMPL(DOCTEST_ANONYMOUS(DOCTEST_CAPTURE_), \ + DOCTEST_ANONYMOUS(DOCTEST_CAPTURE_OTHER_), \ + __VA_ARGS__) +// clang-format on + +#define DOCTEST_INFO_IMPL(mb_name, s_name, ...) \ + auto DOCTEST_ANONYMOUS(DOCTEST_CAPTURE_) = doctest::detail::MakeContextScope( \ + [&](std::ostream* s_name) { \ + doctest::detail::MessageBuilder mb_name(__FILE__, __LINE__, doctest::assertType::is_warn); \ + mb_name.m_stream = s_name; \ + mb_name * __VA_ARGS__; \ + }) + +#define DOCTEST_CAPTURE(x) DOCTEST_INFO(#x " := ", x) + +#define DOCTEST_ADD_AT_IMPL(type, file, line, mb, ...) \ + DOCTEST_FUNC_SCOPE_BEGIN { \ + doctest::detail::MessageBuilder mb(file, line, doctest::assertType::type); \ + mb * __VA_ARGS__; \ + if(mb.log()) \ + DOCTEST_BREAK_INTO_DEBUGGER(); \ + mb.react(); \ + } DOCTEST_FUNC_SCOPE_END + +// clang-format off +#define DOCTEST_ADD_MESSAGE_AT(file, line, ...) DOCTEST_ADD_AT_IMPL(is_warn, file, line, DOCTEST_ANONYMOUS(DOCTEST_MESSAGE_), __VA_ARGS__) +#define DOCTEST_ADD_FAIL_CHECK_AT(file, line, ...) DOCTEST_ADD_AT_IMPL(is_check, file, line, DOCTEST_ANONYMOUS(DOCTEST_MESSAGE_), __VA_ARGS__) +#define DOCTEST_ADD_FAIL_AT(file, line, ...) DOCTEST_ADD_AT_IMPL(is_require, file, line, DOCTEST_ANONYMOUS(DOCTEST_MESSAGE_), __VA_ARGS__) +// clang-format on + +#define DOCTEST_MESSAGE(...) DOCTEST_ADD_MESSAGE_AT(__FILE__, __LINE__, __VA_ARGS__) +#define DOCTEST_FAIL_CHECK(...) DOCTEST_ADD_FAIL_CHECK_AT(__FILE__, __LINE__, __VA_ARGS__) +#define DOCTEST_FAIL(...) DOCTEST_ADD_FAIL_AT(__FILE__, __LINE__, __VA_ARGS__) + +#define DOCTEST_TO_LVALUE(...) __VA_ARGS__ // Not removed to keep backwards compatibility. + +#ifndef DOCTEST_CONFIG_SUPER_FAST_ASSERTS + +#define DOCTEST_ASSERT_IMPLEMENT_2(assert_type, ...) \ + DOCTEST_CLANG_SUPPRESS_WARNING_WITH_PUSH("-Woverloaded-shift-op-parentheses") \ + /* NOLINTNEXTLINE(clang-analyzer-cplusplus.NewDeleteLeaks) */ \ + doctest::detail::ResultBuilder DOCTEST_RB(doctest::assertType::assert_type, __FILE__, \ + __LINE__, #__VA_ARGS__); \ + DOCTEST_WRAP_IN_TRY(DOCTEST_RB.setResult( \ + doctest::detail::ExpressionDecomposer(doctest::assertType::assert_type) \ + << __VA_ARGS__)) /* NOLINTNEXTLINE(clang-analyzer-cplusplus.NewDeleteLeaks) */ \ + DOCTEST_ASSERT_LOG_REACT_RETURN(DOCTEST_RB) \ + DOCTEST_CLANG_SUPPRESS_WARNING_POP + +#define DOCTEST_ASSERT_IMPLEMENT_1(assert_type, ...) \ + DOCTEST_FUNC_SCOPE_BEGIN { \ + DOCTEST_ASSERT_IMPLEMENT_2(assert_type, __VA_ARGS__); \ + } DOCTEST_FUNC_SCOPE_END // NOLINT(clang-analyzer-cplusplus.NewDeleteLeaks) + +#define DOCTEST_BINARY_ASSERT(assert_type, comp, ...) \ + DOCTEST_FUNC_SCOPE_BEGIN { \ + doctest::detail::ResultBuilder DOCTEST_RB(doctest::assertType::assert_type, __FILE__, \ + __LINE__, #__VA_ARGS__); \ + DOCTEST_WRAP_IN_TRY( \ + DOCTEST_RB.binary_assert( \ + __VA_ARGS__)) \ + DOCTEST_ASSERT_LOG_REACT_RETURN(DOCTEST_RB); \ + } DOCTEST_FUNC_SCOPE_END + +#define DOCTEST_UNARY_ASSERT(assert_type, ...) \ + DOCTEST_FUNC_SCOPE_BEGIN { \ + doctest::detail::ResultBuilder DOCTEST_RB(doctest::assertType::assert_type, __FILE__, \ + __LINE__, #__VA_ARGS__); \ + DOCTEST_WRAP_IN_TRY(DOCTEST_RB.unary_assert(__VA_ARGS__)) \ + DOCTEST_ASSERT_LOG_REACT_RETURN(DOCTEST_RB); \ + } DOCTEST_FUNC_SCOPE_END + +#else // DOCTEST_CONFIG_SUPER_FAST_ASSERTS + +// necessary for _MESSAGE +#define DOCTEST_ASSERT_IMPLEMENT_2 DOCTEST_ASSERT_IMPLEMENT_1 + +#define DOCTEST_ASSERT_IMPLEMENT_1(assert_type, ...) \ + DOCTEST_CLANG_SUPPRESS_WARNING_WITH_PUSH("-Woverloaded-shift-op-parentheses") \ + doctest::detail::decomp_assert( \ + doctest::assertType::assert_type, __FILE__, __LINE__, #__VA_ARGS__, \ + doctest::detail::ExpressionDecomposer(doctest::assertType::assert_type) \ + << __VA_ARGS__) DOCTEST_CLANG_SUPPRESS_WARNING_POP + +#define DOCTEST_BINARY_ASSERT(assert_type, comparison, ...) \ + doctest::detail::binary_assert( \ + doctest::assertType::assert_type, __FILE__, __LINE__, #__VA_ARGS__, __VA_ARGS__) + +#define DOCTEST_UNARY_ASSERT(assert_type, ...) \ + doctest::detail::unary_assert(doctest::assertType::assert_type, __FILE__, __LINE__, \ + #__VA_ARGS__, __VA_ARGS__) + +#endif // DOCTEST_CONFIG_SUPER_FAST_ASSERTS + +#define DOCTEST_WARN(...) DOCTEST_ASSERT_IMPLEMENT_1(DT_WARN, __VA_ARGS__) +#define DOCTEST_CHECK(...) DOCTEST_ASSERT_IMPLEMENT_1(DT_CHECK, __VA_ARGS__) +#define DOCTEST_REQUIRE(...) DOCTEST_ASSERT_IMPLEMENT_1(DT_REQUIRE, __VA_ARGS__) +#define DOCTEST_WARN_FALSE(...) DOCTEST_ASSERT_IMPLEMENT_1(DT_WARN_FALSE, __VA_ARGS__) +#define DOCTEST_CHECK_FALSE(...) DOCTEST_ASSERT_IMPLEMENT_1(DT_CHECK_FALSE, __VA_ARGS__) +#define DOCTEST_REQUIRE_FALSE(...) DOCTEST_ASSERT_IMPLEMENT_1(DT_REQUIRE_FALSE, __VA_ARGS__) + +// clang-format off +#define DOCTEST_WARN_MESSAGE(cond, ...) DOCTEST_FUNC_SCOPE_BEGIN { DOCTEST_INFO(__VA_ARGS__); DOCTEST_ASSERT_IMPLEMENT_2(DT_WARN, cond); } DOCTEST_FUNC_SCOPE_END +#define DOCTEST_CHECK_MESSAGE(cond, ...) DOCTEST_FUNC_SCOPE_BEGIN { DOCTEST_INFO(__VA_ARGS__); DOCTEST_ASSERT_IMPLEMENT_2(DT_CHECK, cond); } DOCTEST_FUNC_SCOPE_END +#define DOCTEST_REQUIRE_MESSAGE(cond, ...) DOCTEST_FUNC_SCOPE_BEGIN { DOCTEST_INFO(__VA_ARGS__); DOCTEST_ASSERT_IMPLEMENT_2(DT_REQUIRE, cond); } DOCTEST_FUNC_SCOPE_END +#define DOCTEST_WARN_FALSE_MESSAGE(cond, ...) DOCTEST_FUNC_SCOPE_BEGIN { DOCTEST_INFO(__VA_ARGS__); DOCTEST_ASSERT_IMPLEMENT_2(DT_WARN_FALSE, cond); } DOCTEST_FUNC_SCOPE_END +#define DOCTEST_CHECK_FALSE_MESSAGE(cond, ...) DOCTEST_FUNC_SCOPE_BEGIN { DOCTEST_INFO(__VA_ARGS__); DOCTEST_ASSERT_IMPLEMENT_2(DT_CHECK_FALSE, cond); } DOCTEST_FUNC_SCOPE_END +#define DOCTEST_REQUIRE_FALSE_MESSAGE(cond, ...) DOCTEST_FUNC_SCOPE_BEGIN { DOCTEST_INFO(__VA_ARGS__); DOCTEST_ASSERT_IMPLEMENT_2(DT_REQUIRE_FALSE, cond); } DOCTEST_FUNC_SCOPE_END +// clang-format on + +#define DOCTEST_WARN_EQ(...) DOCTEST_BINARY_ASSERT(DT_WARN_EQ, eq, __VA_ARGS__) +#define DOCTEST_CHECK_EQ(...) DOCTEST_BINARY_ASSERT(DT_CHECK_EQ, eq, __VA_ARGS__) +#define DOCTEST_REQUIRE_EQ(...) DOCTEST_BINARY_ASSERT(DT_REQUIRE_EQ, eq, __VA_ARGS__) +#define DOCTEST_WARN_NE(...) DOCTEST_BINARY_ASSERT(DT_WARN_NE, ne, __VA_ARGS__) +#define DOCTEST_CHECK_NE(...) DOCTEST_BINARY_ASSERT(DT_CHECK_NE, ne, __VA_ARGS__) +#define DOCTEST_REQUIRE_NE(...) DOCTEST_BINARY_ASSERT(DT_REQUIRE_NE, ne, __VA_ARGS__) +#define DOCTEST_WARN_GT(...) DOCTEST_BINARY_ASSERT(DT_WARN_GT, gt, __VA_ARGS__) +#define DOCTEST_CHECK_GT(...) DOCTEST_BINARY_ASSERT(DT_CHECK_GT, gt, __VA_ARGS__) +#define DOCTEST_REQUIRE_GT(...) DOCTEST_BINARY_ASSERT(DT_REQUIRE_GT, gt, __VA_ARGS__) +#define DOCTEST_WARN_LT(...) DOCTEST_BINARY_ASSERT(DT_WARN_LT, lt, __VA_ARGS__) +#define DOCTEST_CHECK_LT(...) DOCTEST_BINARY_ASSERT(DT_CHECK_LT, lt, __VA_ARGS__) +#define DOCTEST_REQUIRE_LT(...) DOCTEST_BINARY_ASSERT(DT_REQUIRE_LT, lt, __VA_ARGS__) +#define DOCTEST_WARN_GE(...) DOCTEST_BINARY_ASSERT(DT_WARN_GE, ge, __VA_ARGS__) +#define DOCTEST_CHECK_GE(...) DOCTEST_BINARY_ASSERT(DT_CHECK_GE, ge, __VA_ARGS__) +#define DOCTEST_REQUIRE_GE(...) DOCTEST_BINARY_ASSERT(DT_REQUIRE_GE, ge, __VA_ARGS__) +#define DOCTEST_WARN_LE(...) DOCTEST_BINARY_ASSERT(DT_WARN_LE, le, __VA_ARGS__) +#define DOCTEST_CHECK_LE(...) DOCTEST_BINARY_ASSERT(DT_CHECK_LE, le, __VA_ARGS__) +#define DOCTEST_REQUIRE_LE(...) DOCTEST_BINARY_ASSERT(DT_REQUIRE_LE, le, __VA_ARGS__) + +#define DOCTEST_WARN_UNARY(...) DOCTEST_UNARY_ASSERT(DT_WARN_UNARY, __VA_ARGS__) +#define DOCTEST_CHECK_UNARY(...) DOCTEST_UNARY_ASSERT(DT_CHECK_UNARY, __VA_ARGS__) +#define DOCTEST_REQUIRE_UNARY(...) DOCTEST_UNARY_ASSERT(DT_REQUIRE_UNARY, __VA_ARGS__) +#define DOCTEST_WARN_UNARY_FALSE(...) DOCTEST_UNARY_ASSERT(DT_WARN_UNARY_FALSE, __VA_ARGS__) +#define DOCTEST_CHECK_UNARY_FALSE(...) DOCTEST_UNARY_ASSERT(DT_CHECK_UNARY_FALSE, __VA_ARGS__) +#define DOCTEST_REQUIRE_UNARY_FALSE(...) DOCTEST_UNARY_ASSERT(DT_REQUIRE_UNARY_FALSE, __VA_ARGS__) + +#ifndef DOCTEST_CONFIG_NO_EXCEPTIONS + +#define DOCTEST_ASSERT_THROWS_AS(expr, assert_type, message, ...) \ + DOCTEST_FUNC_SCOPE_BEGIN { \ + if(!doctest::getContextOptions()->no_throw) { \ + doctest::detail::ResultBuilder DOCTEST_RB(doctest::assertType::assert_type, __FILE__, \ + __LINE__, #expr, #__VA_ARGS__, message); \ + try { \ + DOCTEST_CAST_TO_VOID(expr) \ + } catch(const typename doctest::detail::types::remove_const< \ + typename doctest::detail::types::remove_reference<__VA_ARGS__>::type>::type&) {\ + DOCTEST_RB.translateException(); \ + DOCTEST_RB.m_threw_as = true; \ + } catch(...) { DOCTEST_RB.translateException(); } \ + DOCTEST_ASSERT_LOG_REACT_RETURN(DOCTEST_RB); \ + } else { /* NOLINT(*-else-after-return) */ \ + DOCTEST_FUNC_SCOPE_RET(false); \ + } \ + } DOCTEST_FUNC_SCOPE_END + +#define DOCTEST_ASSERT_THROWS_WITH(expr, expr_str, assert_type, ...) \ + DOCTEST_FUNC_SCOPE_BEGIN { \ + if(!doctest::getContextOptions()->no_throw) { \ + doctest::detail::ResultBuilder DOCTEST_RB(doctest::assertType::assert_type, __FILE__, \ + __LINE__, expr_str, "", __VA_ARGS__); \ + try { \ + DOCTEST_CAST_TO_VOID(expr) \ + } catch(...) { DOCTEST_RB.translateException(); } \ + DOCTEST_ASSERT_LOG_REACT_RETURN(DOCTEST_RB); \ + } else { /* NOLINT(*-else-after-return) */ \ + DOCTEST_FUNC_SCOPE_RET(false); \ + } \ + } DOCTEST_FUNC_SCOPE_END + +#define DOCTEST_ASSERT_NOTHROW(assert_type, ...) \ + DOCTEST_FUNC_SCOPE_BEGIN { \ + doctest::detail::ResultBuilder DOCTEST_RB(doctest::assertType::assert_type, __FILE__, \ + __LINE__, #__VA_ARGS__); \ + try { \ + DOCTEST_CAST_TO_VOID(__VA_ARGS__) \ + } catch(...) { DOCTEST_RB.translateException(); } \ + DOCTEST_ASSERT_LOG_REACT_RETURN(DOCTEST_RB); \ + } DOCTEST_FUNC_SCOPE_END + +// clang-format off +#define DOCTEST_WARN_THROWS(...) DOCTEST_ASSERT_THROWS_WITH((__VA_ARGS__), #__VA_ARGS__, DT_WARN_THROWS, "") +#define DOCTEST_CHECK_THROWS(...) DOCTEST_ASSERT_THROWS_WITH((__VA_ARGS__), #__VA_ARGS__, DT_CHECK_THROWS, "") +#define DOCTEST_REQUIRE_THROWS(...) DOCTEST_ASSERT_THROWS_WITH((__VA_ARGS__), #__VA_ARGS__, DT_REQUIRE_THROWS, "") + +#define DOCTEST_WARN_THROWS_AS(expr, ...) DOCTEST_ASSERT_THROWS_AS(expr, DT_WARN_THROWS_AS, "", __VA_ARGS__) +#define DOCTEST_CHECK_THROWS_AS(expr, ...) DOCTEST_ASSERT_THROWS_AS(expr, DT_CHECK_THROWS_AS, "", __VA_ARGS__) +#define DOCTEST_REQUIRE_THROWS_AS(expr, ...) DOCTEST_ASSERT_THROWS_AS(expr, DT_REQUIRE_THROWS_AS, "", __VA_ARGS__) + +#define DOCTEST_WARN_THROWS_WITH(expr, ...) DOCTEST_ASSERT_THROWS_WITH(expr, #expr, DT_WARN_THROWS_WITH, __VA_ARGS__) +#define DOCTEST_CHECK_THROWS_WITH(expr, ...) DOCTEST_ASSERT_THROWS_WITH(expr, #expr, DT_CHECK_THROWS_WITH, __VA_ARGS__) +#define DOCTEST_REQUIRE_THROWS_WITH(expr, ...) DOCTEST_ASSERT_THROWS_WITH(expr, #expr, DT_REQUIRE_THROWS_WITH, __VA_ARGS__) + +#define DOCTEST_WARN_THROWS_WITH_AS(expr, message, ...) DOCTEST_ASSERT_THROWS_AS(expr, DT_WARN_THROWS_WITH_AS, message, __VA_ARGS__) +#define DOCTEST_CHECK_THROWS_WITH_AS(expr, message, ...) DOCTEST_ASSERT_THROWS_AS(expr, DT_CHECK_THROWS_WITH_AS, message, __VA_ARGS__) +#define DOCTEST_REQUIRE_THROWS_WITH_AS(expr, message, ...) DOCTEST_ASSERT_THROWS_AS(expr, DT_REQUIRE_THROWS_WITH_AS, message, __VA_ARGS__) + +#define DOCTEST_WARN_NOTHROW(...) DOCTEST_ASSERT_NOTHROW(DT_WARN_NOTHROW, __VA_ARGS__) +#define DOCTEST_CHECK_NOTHROW(...) DOCTEST_ASSERT_NOTHROW(DT_CHECK_NOTHROW, __VA_ARGS__) +#define DOCTEST_REQUIRE_NOTHROW(...) DOCTEST_ASSERT_NOTHROW(DT_REQUIRE_NOTHROW, __VA_ARGS__) + +#define DOCTEST_WARN_THROWS_MESSAGE(expr, ...) DOCTEST_FUNC_SCOPE_BEGIN { DOCTEST_INFO(__VA_ARGS__); DOCTEST_WARN_THROWS(expr); } DOCTEST_FUNC_SCOPE_END +#define DOCTEST_CHECK_THROWS_MESSAGE(expr, ...) DOCTEST_FUNC_SCOPE_BEGIN { DOCTEST_INFO(__VA_ARGS__); DOCTEST_CHECK_THROWS(expr); } DOCTEST_FUNC_SCOPE_END +#define DOCTEST_REQUIRE_THROWS_MESSAGE(expr, ...) DOCTEST_FUNC_SCOPE_BEGIN { DOCTEST_INFO(__VA_ARGS__); DOCTEST_REQUIRE_THROWS(expr); } DOCTEST_FUNC_SCOPE_END +#define DOCTEST_WARN_THROWS_AS_MESSAGE(expr, ex, ...) DOCTEST_FUNC_SCOPE_BEGIN { DOCTEST_INFO(__VA_ARGS__); DOCTEST_WARN_THROWS_AS(expr, ex); } DOCTEST_FUNC_SCOPE_END +#define DOCTEST_CHECK_THROWS_AS_MESSAGE(expr, ex, ...) DOCTEST_FUNC_SCOPE_BEGIN { DOCTEST_INFO(__VA_ARGS__); DOCTEST_CHECK_THROWS_AS(expr, ex); } DOCTEST_FUNC_SCOPE_END +#define DOCTEST_REQUIRE_THROWS_AS_MESSAGE(expr, ex, ...) DOCTEST_FUNC_SCOPE_BEGIN { DOCTEST_INFO(__VA_ARGS__); DOCTEST_REQUIRE_THROWS_AS(expr, ex); } DOCTEST_FUNC_SCOPE_END +#define DOCTEST_WARN_THROWS_WITH_MESSAGE(expr, with, ...) DOCTEST_FUNC_SCOPE_BEGIN { DOCTEST_INFO(__VA_ARGS__); DOCTEST_WARN_THROWS_WITH(expr, with); } DOCTEST_FUNC_SCOPE_END +#define DOCTEST_CHECK_THROWS_WITH_MESSAGE(expr, with, ...) DOCTEST_FUNC_SCOPE_BEGIN { DOCTEST_INFO(__VA_ARGS__); DOCTEST_CHECK_THROWS_WITH(expr, with); } DOCTEST_FUNC_SCOPE_END +#define DOCTEST_REQUIRE_THROWS_WITH_MESSAGE(expr, with, ...) DOCTEST_FUNC_SCOPE_BEGIN { DOCTEST_INFO(__VA_ARGS__); DOCTEST_REQUIRE_THROWS_WITH(expr, with); } DOCTEST_FUNC_SCOPE_END +#define DOCTEST_WARN_THROWS_WITH_AS_MESSAGE(expr, with, ex, ...) DOCTEST_FUNC_SCOPE_BEGIN { DOCTEST_INFO(__VA_ARGS__); DOCTEST_WARN_THROWS_WITH_AS(expr, with, ex); } DOCTEST_FUNC_SCOPE_END +#define DOCTEST_CHECK_THROWS_WITH_AS_MESSAGE(expr, with, ex, ...) DOCTEST_FUNC_SCOPE_BEGIN { DOCTEST_INFO(__VA_ARGS__); DOCTEST_CHECK_THROWS_WITH_AS(expr, with, ex); } DOCTEST_FUNC_SCOPE_END +#define DOCTEST_REQUIRE_THROWS_WITH_AS_MESSAGE(expr, with, ex, ...) DOCTEST_FUNC_SCOPE_BEGIN { DOCTEST_INFO(__VA_ARGS__); DOCTEST_REQUIRE_THROWS_WITH_AS(expr, with, ex); } DOCTEST_FUNC_SCOPE_END +#define DOCTEST_WARN_NOTHROW_MESSAGE(expr, ...) DOCTEST_FUNC_SCOPE_BEGIN { DOCTEST_INFO(__VA_ARGS__); DOCTEST_WARN_NOTHROW(expr); } DOCTEST_FUNC_SCOPE_END +#define DOCTEST_CHECK_NOTHROW_MESSAGE(expr, ...) DOCTEST_FUNC_SCOPE_BEGIN { DOCTEST_INFO(__VA_ARGS__); DOCTEST_CHECK_NOTHROW(expr); } DOCTEST_FUNC_SCOPE_END +#define DOCTEST_REQUIRE_NOTHROW_MESSAGE(expr, ...) DOCTEST_FUNC_SCOPE_BEGIN { DOCTEST_INFO(__VA_ARGS__); DOCTEST_REQUIRE_NOTHROW(expr); } DOCTEST_FUNC_SCOPE_END +// clang-format on + +#endif // DOCTEST_CONFIG_NO_EXCEPTIONS + +// ================================================================================================= +// == WHAT FOLLOWS IS VERSIONS OF THE MACROS THAT DO NOT DO ANY REGISTERING! == +// == THIS CAN BE ENABLED BY DEFINING DOCTEST_CONFIG_DISABLE GLOBALLY! == +// ================================================================================================= +#else // DOCTEST_CONFIG_DISABLE + +#define DOCTEST_IMPLEMENT_FIXTURE(der, base, func, name) \ + namespace /* NOLINT */ { \ + template \ + struct der : public base \ + { void f(); }; \ + } \ + template \ + inline void der::f() + +#define DOCTEST_CREATE_AND_REGISTER_FUNCTION(f, name) \ + template \ + static inline void f() + +// for registering tests +#define DOCTEST_TEST_CASE(name) \ + DOCTEST_CREATE_AND_REGISTER_FUNCTION(DOCTEST_ANONYMOUS(DOCTEST_ANON_FUNC_), name) + +// for registering tests in classes +#define DOCTEST_TEST_CASE_CLASS(name) \ + DOCTEST_CREATE_AND_REGISTER_FUNCTION(DOCTEST_ANONYMOUS(DOCTEST_ANON_FUNC_), name) + +// for registering tests with a fixture +#define DOCTEST_TEST_CASE_FIXTURE(x, name) \ + DOCTEST_IMPLEMENT_FIXTURE(DOCTEST_ANONYMOUS(DOCTEST_ANON_CLASS_), x, \ + DOCTEST_ANONYMOUS(DOCTEST_ANON_FUNC_), name) + +// for converting types to strings without the header and demangling +#define DOCTEST_TYPE_TO_STRING_AS(str, ...) static_assert(true, "") +#define DOCTEST_TYPE_TO_STRING(...) static_assert(true, "") + +// for typed tests +#define DOCTEST_TEST_CASE_TEMPLATE(name, type, ...) \ + template \ + inline void DOCTEST_ANONYMOUS(DOCTEST_ANON_TMP_)() + +#define DOCTEST_TEST_CASE_TEMPLATE_DEFINE(name, type, id) \ + template \ + inline void DOCTEST_ANONYMOUS(DOCTEST_ANON_TMP_)() + +#define DOCTEST_TEST_CASE_TEMPLATE_INVOKE(id, ...) static_assert(true, "") +#define DOCTEST_TEST_CASE_TEMPLATE_APPLY(id, ...) static_assert(true, "") + +// for subcases +#define DOCTEST_SUBCASE(name) + +// for a testsuite block +#define DOCTEST_TEST_SUITE(name) namespace // NOLINT + +// for starting a testsuite block +#define DOCTEST_TEST_SUITE_BEGIN(name) static_assert(true, "") + +// for ending a testsuite block +#define DOCTEST_TEST_SUITE_END using DOCTEST_ANONYMOUS(DOCTEST_ANON_FOR_SEMICOLON_) = int + +#define DOCTEST_REGISTER_EXCEPTION_TRANSLATOR(signature) \ + template \ + static inline doctest::String DOCTEST_ANONYMOUS(DOCTEST_ANON_TRANSLATOR_)(signature) + +#define DOCTEST_REGISTER_REPORTER(name, priority, reporter) +#define DOCTEST_REGISTER_LISTENER(name, priority, reporter) + +#define DOCTEST_INFO(...) (static_cast(0)) +#define DOCTEST_CAPTURE(x) (static_cast(0)) +#define DOCTEST_ADD_MESSAGE_AT(file, line, ...) (static_cast(0)) +#define DOCTEST_ADD_FAIL_CHECK_AT(file, line, ...) (static_cast(0)) +#define DOCTEST_ADD_FAIL_AT(file, line, ...) (static_cast(0)) +#define DOCTEST_MESSAGE(...) (static_cast(0)) +#define DOCTEST_FAIL_CHECK(...) (static_cast(0)) +#define DOCTEST_FAIL(...) (static_cast(0)) + +#if defined(DOCTEST_CONFIG_EVALUATE_ASSERTS_EVEN_WHEN_DISABLED) \ + && defined(DOCTEST_CONFIG_ASSERTS_RETURN_VALUES) + +#define DOCTEST_WARN(...) [&] { return __VA_ARGS__; }() +#define DOCTEST_CHECK(...) [&] { return __VA_ARGS__; }() +#define DOCTEST_REQUIRE(...) [&] { return __VA_ARGS__; }() +#define DOCTEST_WARN_FALSE(...) [&] { return !(__VA_ARGS__); }() +#define DOCTEST_CHECK_FALSE(...) [&] { return !(__VA_ARGS__); }() +#define DOCTEST_REQUIRE_FALSE(...) [&] { return !(__VA_ARGS__); }() + +#define DOCTEST_WARN_MESSAGE(cond, ...) [&] { return cond; }() +#define DOCTEST_CHECK_MESSAGE(cond, ...) [&] { return cond; }() +#define DOCTEST_REQUIRE_MESSAGE(cond, ...) [&] { return cond; }() +#define DOCTEST_WARN_FALSE_MESSAGE(cond, ...) [&] { return !(cond); }() +#define DOCTEST_CHECK_FALSE_MESSAGE(cond, ...) [&] { return !(cond); }() +#define DOCTEST_REQUIRE_FALSE_MESSAGE(cond, ...) [&] { return !(cond); }() + +namespace doctest { +namespace detail { +#define DOCTEST_RELATIONAL_OP(name, op) \ + template \ + bool name(const DOCTEST_REF_WRAP(L) lhs, const DOCTEST_REF_WRAP(R) rhs) { return lhs op rhs; } + + DOCTEST_RELATIONAL_OP(eq, ==) + DOCTEST_RELATIONAL_OP(ne, !=) + DOCTEST_RELATIONAL_OP(lt, <) + DOCTEST_RELATIONAL_OP(gt, >) + DOCTEST_RELATIONAL_OP(le, <=) + DOCTEST_RELATIONAL_OP(ge, >=) +} // namespace detail +} // namespace doctest + +#define DOCTEST_WARN_EQ(...) [&] { return doctest::detail::eq(__VA_ARGS__); }() +#define DOCTEST_CHECK_EQ(...) [&] { return doctest::detail::eq(__VA_ARGS__); }() +#define DOCTEST_REQUIRE_EQ(...) [&] { return doctest::detail::eq(__VA_ARGS__); }() +#define DOCTEST_WARN_NE(...) [&] { return doctest::detail::ne(__VA_ARGS__); }() +#define DOCTEST_CHECK_NE(...) [&] { return doctest::detail::ne(__VA_ARGS__); }() +#define DOCTEST_REQUIRE_NE(...) [&] { return doctest::detail::ne(__VA_ARGS__); }() +#define DOCTEST_WARN_LT(...) [&] { return doctest::detail::lt(__VA_ARGS__); }() +#define DOCTEST_CHECK_LT(...) [&] { return doctest::detail::lt(__VA_ARGS__); }() +#define DOCTEST_REQUIRE_LT(...) [&] { return doctest::detail::lt(__VA_ARGS__); }() +#define DOCTEST_WARN_GT(...) [&] { return doctest::detail::gt(__VA_ARGS__); }() +#define DOCTEST_CHECK_GT(...) [&] { return doctest::detail::gt(__VA_ARGS__); }() +#define DOCTEST_REQUIRE_GT(...) [&] { return doctest::detail::gt(__VA_ARGS__); }() +#define DOCTEST_WARN_LE(...) [&] { return doctest::detail::le(__VA_ARGS__); }() +#define DOCTEST_CHECK_LE(...) [&] { return doctest::detail::le(__VA_ARGS__); }() +#define DOCTEST_REQUIRE_LE(...) [&] { return doctest::detail::le(__VA_ARGS__); }() +#define DOCTEST_WARN_GE(...) [&] { return doctest::detail::ge(__VA_ARGS__); }() +#define DOCTEST_CHECK_GE(...) [&] { return doctest::detail::ge(__VA_ARGS__); }() +#define DOCTEST_REQUIRE_GE(...) [&] { return doctest::detail::ge(__VA_ARGS__); }() +#define DOCTEST_WARN_UNARY(...) [&] { return __VA_ARGS__; }() +#define DOCTEST_CHECK_UNARY(...) [&] { return __VA_ARGS__; }() +#define DOCTEST_REQUIRE_UNARY(...) [&] { return __VA_ARGS__; }() +#define DOCTEST_WARN_UNARY_FALSE(...) [&] { return !(__VA_ARGS__); }() +#define DOCTEST_CHECK_UNARY_FALSE(...) [&] { return !(__VA_ARGS__); }() +#define DOCTEST_REQUIRE_UNARY_FALSE(...) [&] { return !(__VA_ARGS__); }() + +#ifndef DOCTEST_CONFIG_NO_EXCEPTIONS + +#define DOCTEST_WARN_THROWS_WITH(expr, with, ...) [] { static_assert(false, "Exception translation is not available when doctest is disabled."); return false; }() +#define DOCTEST_CHECK_THROWS_WITH(expr, with, ...) DOCTEST_WARN_THROWS_WITH(,,) +#define DOCTEST_REQUIRE_THROWS_WITH(expr, with, ...) DOCTEST_WARN_THROWS_WITH(,,) +#define DOCTEST_WARN_THROWS_WITH_AS(expr, with, ex, ...) DOCTEST_WARN_THROWS_WITH(,,) +#define DOCTEST_CHECK_THROWS_WITH_AS(expr, with, ex, ...) DOCTEST_WARN_THROWS_WITH(,,) +#define DOCTEST_REQUIRE_THROWS_WITH_AS(expr, with, ex, ...) DOCTEST_WARN_THROWS_WITH(,,) + +#define DOCTEST_WARN_THROWS_WITH_MESSAGE(expr, with, ...) DOCTEST_WARN_THROWS_WITH(,,) +#define DOCTEST_CHECK_THROWS_WITH_MESSAGE(expr, with, ...) DOCTEST_WARN_THROWS_WITH(,,) +#define DOCTEST_REQUIRE_THROWS_WITH_MESSAGE(expr, with, ...) DOCTEST_WARN_THROWS_WITH(,,) +#define DOCTEST_WARN_THROWS_WITH_AS_MESSAGE(expr, with, ex, ...) DOCTEST_WARN_THROWS_WITH(,,) +#define DOCTEST_CHECK_THROWS_WITH_AS_MESSAGE(expr, with, ex, ...) DOCTEST_WARN_THROWS_WITH(,,) +#define DOCTEST_REQUIRE_THROWS_WITH_AS_MESSAGE(expr, with, ex, ...) DOCTEST_WARN_THROWS_WITH(,,) + +#define DOCTEST_WARN_THROWS(...) [&] { try { __VA_ARGS__; return false; } catch (...) { return true; } }() +#define DOCTEST_CHECK_THROWS(...) [&] { try { __VA_ARGS__; return false; } catch (...) { return true; } }() +#define DOCTEST_REQUIRE_THROWS(...) [&] { try { __VA_ARGS__; return false; } catch (...) { return true; } }() +#define DOCTEST_WARN_THROWS_AS(expr, ...) [&] { try { expr; } catch (__VA_ARGS__) { return true; } catch (...) { } return false; }() +#define DOCTEST_CHECK_THROWS_AS(expr, ...) [&] { try { expr; } catch (__VA_ARGS__) { return true; } catch (...) { } return false; }() +#define DOCTEST_REQUIRE_THROWS_AS(expr, ...) [&] { try { expr; } catch (__VA_ARGS__) { return true; } catch (...) { } return false; }() +#define DOCTEST_WARN_NOTHROW(...) [&] { try { __VA_ARGS__; return true; } catch (...) { return false; } }() +#define DOCTEST_CHECK_NOTHROW(...) [&] { try { __VA_ARGS__; return true; } catch (...) { return false; } }() +#define DOCTEST_REQUIRE_NOTHROW(...) [&] { try { __VA_ARGS__; return true; } catch (...) { return false; } }() + +#define DOCTEST_WARN_THROWS_MESSAGE(expr, ...) [&] { try { __VA_ARGS__; return false; } catch (...) { return true; } }() +#define DOCTEST_CHECK_THROWS_MESSAGE(expr, ...) [&] { try { __VA_ARGS__; return false; } catch (...) { return true; } }() +#define DOCTEST_REQUIRE_THROWS_MESSAGE(expr, ...) [&] { try { __VA_ARGS__; return false; } catch (...) { return true; } }() +#define DOCTEST_WARN_THROWS_AS_MESSAGE(expr, ex, ...) [&] { try { expr; } catch (__VA_ARGS__) { return true; } catch (...) { } return false; }() +#define DOCTEST_CHECK_THROWS_AS_MESSAGE(expr, ex, ...) [&] { try { expr; } catch (__VA_ARGS__) { return true; } catch (...) { } return false; }() +#define DOCTEST_REQUIRE_THROWS_AS_MESSAGE(expr, ex, ...) [&] { try { expr; } catch (__VA_ARGS__) { return true; } catch (...) { } return false; }() +#define DOCTEST_WARN_NOTHROW_MESSAGE(expr, ...) [&] { try { __VA_ARGS__; return true; } catch (...) { return false; } }() +#define DOCTEST_CHECK_NOTHROW_MESSAGE(expr, ...) [&] { try { __VA_ARGS__; return true; } catch (...) { return false; } }() +#define DOCTEST_REQUIRE_NOTHROW_MESSAGE(expr, ...) [&] { try { __VA_ARGS__; return true; } catch (...) { return false; } }() + +#endif // DOCTEST_CONFIG_NO_EXCEPTIONS + +#else // DOCTEST_CONFIG_EVALUATE_ASSERTS_EVEN_WHEN_DISABLED + +#define DOCTEST_WARN(...) DOCTEST_FUNC_EMPTY +#define DOCTEST_CHECK(...) DOCTEST_FUNC_EMPTY +#define DOCTEST_REQUIRE(...) DOCTEST_FUNC_EMPTY +#define DOCTEST_WARN_FALSE(...) DOCTEST_FUNC_EMPTY +#define DOCTEST_CHECK_FALSE(...) DOCTEST_FUNC_EMPTY +#define DOCTEST_REQUIRE_FALSE(...) DOCTEST_FUNC_EMPTY + +#define DOCTEST_WARN_MESSAGE(cond, ...) DOCTEST_FUNC_EMPTY +#define DOCTEST_CHECK_MESSAGE(cond, ...) DOCTEST_FUNC_EMPTY +#define DOCTEST_REQUIRE_MESSAGE(cond, ...) DOCTEST_FUNC_EMPTY +#define DOCTEST_WARN_FALSE_MESSAGE(cond, ...) DOCTEST_FUNC_EMPTY +#define DOCTEST_CHECK_FALSE_MESSAGE(cond, ...) DOCTEST_FUNC_EMPTY +#define DOCTEST_REQUIRE_FALSE_MESSAGE(cond, ...) DOCTEST_FUNC_EMPTY + +#define DOCTEST_WARN_EQ(...) DOCTEST_FUNC_EMPTY +#define DOCTEST_CHECK_EQ(...) DOCTEST_FUNC_EMPTY +#define DOCTEST_REQUIRE_EQ(...) DOCTEST_FUNC_EMPTY +#define DOCTEST_WARN_NE(...) DOCTEST_FUNC_EMPTY +#define DOCTEST_CHECK_NE(...) DOCTEST_FUNC_EMPTY +#define DOCTEST_REQUIRE_NE(...) DOCTEST_FUNC_EMPTY +#define DOCTEST_WARN_GT(...) DOCTEST_FUNC_EMPTY +#define DOCTEST_CHECK_GT(...) DOCTEST_FUNC_EMPTY +#define DOCTEST_REQUIRE_GT(...) DOCTEST_FUNC_EMPTY +#define DOCTEST_WARN_LT(...) DOCTEST_FUNC_EMPTY +#define DOCTEST_CHECK_LT(...) DOCTEST_FUNC_EMPTY +#define DOCTEST_REQUIRE_LT(...) DOCTEST_FUNC_EMPTY +#define DOCTEST_WARN_GE(...) DOCTEST_FUNC_EMPTY +#define DOCTEST_CHECK_GE(...) DOCTEST_FUNC_EMPTY +#define DOCTEST_REQUIRE_GE(...) DOCTEST_FUNC_EMPTY +#define DOCTEST_WARN_LE(...) DOCTEST_FUNC_EMPTY +#define DOCTEST_CHECK_LE(...) DOCTEST_FUNC_EMPTY +#define DOCTEST_REQUIRE_LE(...) DOCTEST_FUNC_EMPTY + +#define DOCTEST_WARN_UNARY(...) DOCTEST_FUNC_EMPTY +#define DOCTEST_CHECK_UNARY(...) DOCTEST_FUNC_EMPTY +#define DOCTEST_REQUIRE_UNARY(...) DOCTEST_FUNC_EMPTY +#define DOCTEST_WARN_UNARY_FALSE(...) DOCTEST_FUNC_EMPTY +#define DOCTEST_CHECK_UNARY_FALSE(...) DOCTEST_FUNC_EMPTY +#define DOCTEST_REQUIRE_UNARY_FALSE(...) DOCTEST_FUNC_EMPTY + +#ifndef DOCTEST_CONFIG_NO_EXCEPTIONS + +#define DOCTEST_WARN_THROWS(...) DOCTEST_FUNC_EMPTY +#define DOCTEST_CHECK_THROWS(...) DOCTEST_FUNC_EMPTY +#define DOCTEST_REQUIRE_THROWS(...) DOCTEST_FUNC_EMPTY +#define DOCTEST_WARN_THROWS_AS(expr, ...) DOCTEST_FUNC_EMPTY +#define DOCTEST_CHECK_THROWS_AS(expr, ...) DOCTEST_FUNC_EMPTY +#define DOCTEST_REQUIRE_THROWS_AS(expr, ...) DOCTEST_FUNC_EMPTY +#define DOCTEST_WARN_THROWS_WITH(expr, ...) DOCTEST_FUNC_EMPTY +#define DOCTEST_CHECK_THROWS_WITH(expr, ...) DOCTEST_FUNC_EMPTY +#define DOCTEST_REQUIRE_THROWS_WITH(expr, ...) DOCTEST_FUNC_EMPTY +#define DOCTEST_WARN_THROWS_WITH_AS(expr, with, ...) DOCTEST_FUNC_EMPTY +#define DOCTEST_CHECK_THROWS_WITH_AS(expr, with, ...) DOCTEST_FUNC_EMPTY +#define DOCTEST_REQUIRE_THROWS_WITH_AS(expr, with, ...) DOCTEST_FUNC_EMPTY +#define DOCTEST_WARN_NOTHROW(...) DOCTEST_FUNC_EMPTY +#define DOCTEST_CHECK_NOTHROW(...) DOCTEST_FUNC_EMPTY +#define DOCTEST_REQUIRE_NOTHROW(...) DOCTEST_FUNC_EMPTY + +#define DOCTEST_WARN_THROWS_MESSAGE(expr, ...) DOCTEST_FUNC_EMPTY +#define DOCTEST_CHECK_THROWS_MESSAGE(expr, ...) DOCTEST_FUNC_EMPTY +#define DOCTEST_REQUIRE_THROWS_MESSAGE(expr, ...) DOCTEST_FUNC_EMPTY +#define DOCTEST_WARN_THROWS_AS_MESSAGE(expr, ex, ...) DOCTEST_FUNC_EMPTY +#define DOCTEST_CHECK_THROWS_AS_MESSAGE(expr, ex, ...) DOCTEST_FUNC_EMPTY +#define DOCTEST_REQUIRE_THROWS_AS_MESSAGE(expr, ex, ...) DOCTEST_FUNC_EMPTY +#define DOCTEST_WARN_THROWS_WITH_MESSAGE(expr, with, ...) DOCTEST_FUNC_EMPTY +#define DOCTEST_CHECK_THROWS_WITH_MESSAGE(expr, with, ...) DOCTEST_FUNC_EMPTY +#define DOCTEST_REQUIRE_THROWS_WITH_MESSAGE(expr, with, ...) DOCTEST_FUNC_EMPTY +#define DOCTEST_WARN_THROWS_WITH_AS_MESSAGE(expr, with, ex, ...) DOCTEST_FUNC_EMPTY +#define DOCTEST_CHECK_THROWS_WITH_AS_MESSAGE(expr, with, ex, ...) DOCTEST_FUNC_EMPTY +#define DOCTEST_REQUIRE_THROWS_WITH_AS_MESSAGE(expr, with, ex, ...) DOCTEST_FUNC_EMPTY +#define DOCTEST_WARN_NOTHROW_MESSAGE(expr, ...) DOCTEST_FUNC_EMPTY +#define DOCTEST_CHECK_NOTHROW_MESSAGE(expr, ...) DOCTEST_FUNC_EMPTY +#define DOCTEST_REQUIRE_NOTHROW_MESSAGE(expr, ...) DOCTEST_FUNC_EMPTY + +#endif // DOCTEST_CONFIG_NO_EXCEPTIONS + +#endif // DOCTEST_CONFIG_EVALUATE_ASSERTS_EVEN_WHEN_DISABLED + +#endif // DOCTEST_CONFIG_DISABLE + +#ifdef DOCTEST_CONFIG_NO_EXCEPTIONS + +#ifdef DOCTEST_CONFIG_NO_EXCEPTIONS_BUT_WITH_ALL_ASSERTS +#define DOCTEST_EXCEPTION_EMPTY_FUNC DOCTEST_FUNC_EMPTY +#else // DOCTEST_CONFIG_NO_EXCEPTIONS_BUT_WITH_ALL_ASSERTS +#define DOCTEST_EXCEPTION_EMPTY_FUNC [] { static_assert(false, "Exceptions are disabled! " \ + "Use DOCTEST_CONFIG_NO_EXCEPTIONS_BUT_WITH_ALL_ASSERTS if you want to compile with exceptions disabled."); return false; }() + +#undef DOCTEST_REQUIRE +#undef DOCTEST_REQUIRE_FALSE +#undef DOCTEST_REQUIRE_MESSAGE +#undef DOCTEST_REQUIRE_FALSE_MESSAGE +#undef DOCTEST_REQUIRE_EQ +#undef DOCTEST_REQUIRE_NE +#undef DOCTEST_REQUIRE_GT +#undef DOCTEST_REQUIRE_LT +#undef DOCTEST_REQUIRE_GE +#undef DOCTEST_REQUIRE_LE +#undef DOCTEST_REQUIRE_UNARY +#undef DOCTEST_REQUIRE_UNARY_FALSE + +#define DOCTEST_REQUIRE DOCTEST_EXCEPTION_EMPTY_FUNC +#define DOCTEST_REQUIRE_FALSE DOCTEST_EXCEPTION_EMPTY_FUNC +#define DOCTEST_REQUIRE_MESSAGE DOCTEST_EXCEPTION_EMPTY_FUNC +#define DOCTEST_REQUIRE_FALSE_MESSAGE DOCTEST_EXCEPTION_EMPTY_FUNC +#define DOCTEST_REQUIRE_EQ DOCTEST_EXCEPTION_EMPTY_FUNC +#define DOCTEST_REQUIRE_NE DOCTEST_EXCEPTION_EMPTY_FUNC +#define DOCTEST_REQUIRE_GT DOCTEST_EXCEPTION_EMPTY_FUNC +#define DOCTEST_REQUIRE_LT DOCTEST_EXCEPTION_EMPTY_FUNC +#define DOCTEST_REQUIRE_GE DOCTEST_EXCEPTION_EMPTY_FUNC +#define DOCTEST_REQUIRE_LE DOCTEST_EXCEPTION_EMPTY_FUNC +#define DOCTEST_REQUIRE_UNARY DOCTEST_EXCEPTION_EMPTY_FUNC +#define DOCTEST_REQUIRE_UNARY_FALSE DOCTEST_EXCEPTION_EMPTY_FUNC + +#endif // DOCTEST_CONFIG_NO_EXCEPTIONS_BUT_WITH_ALL_ASSERTS + +#define DOCTEST_WARN_THROWS(...) DOCTEST_EXCEPTION_EMPTY_FUNC +#define DOCTEST_CHECK_THROWS(...) DOCTEST_EXCEPTION_EMPTY_FUNC +#define DOCTEST_REQUIRE_THROWS(...) DOCTEST_EXCEPTION_EMPTY_FUNC +#define DOCTEST_WARN_THROWS_AS(expr, ...) DOCTEST_EXCEPTION_EMPTY_FUNC +#define DOCTEST_CHECK_THROWS_AS(expr, ...) DOCTEST_EXCEPTION_EMPTY_FUNC +#define DOCTEST_REQUIRE_THROWS_AS(expr, ...) DOCTEST_EXCEPTION_EMPTY_FUNC +#define DOCTEST_WARN_THROWS_WITH(expr, ...) DOCTEST_EXCEPTION_EMPTY_FUNC +#define DOCTEST_CHECK_THROWS_WITH(expr, ...) DOCTEST_EXCEPTION_EMPTY_FUNC +#define DOCTEST_REQUIRE_THROWS_WITH(expr, ...) DOCTEST_EXCEPTION_EMPTY_FUNC +#define DOCTEST_WARN_THROWS_WITH_AS(expr, with, ...) DOCTEST_EXCEPTION_EMPTY_FUNC +#define DOCTEST_CHECK_THROWS_WITH_AS(expr, with, ...) DOCTEST_EXCEPTION_EMPTY_FUNC +#define DOCTEST_REQUIRE_THROWS_WITH_AS(expr, with, ...) DOCTEST_EXCEPTION_EMPTY_FUNC +#define DOCTEST_WARN_NOTHROW(...) DOCTEST_EXCEPTION_EMPTY_FUNC +#define DOCTEST_CHECK_NOTHROW(...) DOCTEST_EXCEPTION_EMPTY_FUNC +#define DOCTEST_REQUIRE_NOTHROW(...) DOCTEST_EXCEPTION_EMPTY_FUNC + +#define DOCTEST_WARN_THROWS_MESSAGE(expr, ...) DOCTEST_EXCEPTION_EMPTY_FUNC +#define DOCTEST_CHECK_THROWS_MESSAGE(expr, ...) DOCTEST_EXCEPTION_EMPTY_FUNC +#define DOCTEST_REQUIRE_THROWS_MESSAGE(expr, ...) DOCTEST_EXCEPTION_EMPTY_FUNC +#define DOCTEST_WARN_THROWS_AS_MESSAGE(expr, ex, ...) DOCTEST_EXCEPTION_EMPTY_FUNC +#define DOCTEST_CHECK_THROWS_AS_MESSAGE(expr, ex, ...) DOCTEST_EXCEPTION_EMPTY_FUNC +#define DOCTEST_REQUIRE_THROWS_AS_MESSAGE(expr, ex, ...) DOCTEST_EXCEPTION_EMPTY_FUNC +#define DOCTEST_WARN_THROWS_WITH_MESSAGE(expr, with, ...) DOCTEST_EXCEPTION_EMPTY_FUNC +#define DOCTEST_CHECK_THROWS_WITH_MESSAGE(expr, with, ...) DOCTEST_EXCEPTION_EMPTY_FUNC +#define DOCTEST_REQUIRE_THROWS_WITH_MESSAGE(expr, with, ...) DOCTEST_EXCEPTION_EMPTY_FUNC +#define DOCTEST_WARN_THROWS_WITH_AS_MESSAGE(expr, with, ex, ...) DOCTEST_EXCEPTION_EMPTY_FUNC +#define DOCTEST_CHECK_THROWS_WITH_AS_MESSAGE(expr, with, ex, ...) DOCTEST_EXCEPTION_EMPTY_FUNC +#define DOCTEST_REQUIRE_THROWS_WITH_AS_MESSAGE(expr, with, ex, ...) DOCTEST_EXCEPTION_EMPTY_FUNC +#define DOCTEST_WARN_NOTHROW_MESSAGE(expr, ...) DOCTEST_EXCEPTION_EMPTY_FUNC +#define DOCTEST_CHECK_NOTHROW_MESSAGE(expr, ...) DOCTEST_EXCEPTION_EMPTY_FUNC +#define DOCTEST_REQUIRE_NOTHROW_MESSAGE(expr, ...) DOCTEST_EXCEPTION_EMPTY_FUNC + +#endif // DOCTEST_CONFIG_NO_EXCEPTIONS + +// clang-format off +// KEPT FOR BACKWARDS COMPATIBILITY - FORWARDING TO THE RIGHT MACROS +#define DOCTEST_FAST_WARN_EQ DOCTEST_WARN_EQ +#define DOCTEST_FAST_CHECK_EQ DOCTEST_CHECK_EQ +#define DOCTEST_FAST_REQUIRE_EQ DOCTEST_REQUIRE_EQ +#define DOCTEST_FAST_WARN_NE DOCTEST_WARN_NE +#define DOCTEST_FAST_CHECK_NE DOCTEST_CHECK_NE +#define DOCTEST_FAST_REQUIRE_NE DOCTEST_REQUIRE_NE +#define DOCTEST_FAST_WARN_GT DOCTEST_WARN_GT +#define DOCTEST_FAST_CHECK_GT DOCTEST_CHECK_GT +#define DOCTEST_FAST_REQUIRE_GT DOCTEST_REQUIRE_GT +#define DOCTEST_FAST_WARN_LT DOCTEST_WARN_LT +#define DOCTEST_FAST_CHECK_LT DOCTEST_CHECK_LT +#define DOCTEST_FAST_REQUIRE_LT DOCTEST_REQUIRE_LT +#define DOCTEST_FAST_WARN_GE DOCTEST_WARN_GE +#define DOCTEST_FAST_CHECK_GE DOCTEST_CHECK_GE +#define DOCTEST_FAST_REQUIRE_GE DOCTEST_REQUIRE_GE +#define DOCTEST_FAST_WARN_LE DOCTEST_WARN_LE +#define DOCTEST_FAST_CHECK_LE DOCTEST_CHECK_LE +#define DOCTEST_FAST_REQUIRE_LE DOCTEST_REQUIRE_LE + +#define DOCTEST_FAST_WARN_UNARY DOCTEST_WARN_UNARY +#define DOCTEST_FAST_CHECK_UNARY DOCTEST_CHECK_UNARY +#define DOCTEST_FAST_REQUIRE_UNARY DOCTEST_REQUIRE_UNARY +#define DOCTEST_FAST_WARN_UNARY_FALSE DOCTEST_WARN_UNARY_FALSE +#define DOCTEST_FAST_CHECK_UNARY_FALSE DOCTEST_CHECK_UNARY_FALSE +#define DOCTEST_FAST_REQUIRE_UNARY_FALSE DOCTEST_REQUIRE_UNARY_FALSE + +#define DOCTEST_TEST_CASE_TEMPLATE_INSTANTIATE(id, ...) DOCTEST_TEST_CASE_TEMPLATE_INVOKE(id,__VA_ARGS__) +// clang-format on + +// BDD style macros +// clang-format off +#define DOCTEST_SCENARIO(name) DOCTEST_TEST_CASE(" Scenario: " name) +#define DOCTEST_SCENARIO_CLASS(name) DOCTEST_TEST_CASE_CLASS(" Scenario: " name) +#define DOCTEST_SCENARIO_TEMPLATE(name, T, ...) DOCTEST_TEST_CASE_TEMPLATE(" Scenario: " name, T, __VA_ARGS__) +#define DOCTEST_SCENARIO_TEMPLATE_DEFINE(name, T, id) DOCTEST_TEST_CASE_TEMPLATE_DEFINE(" Scenario: " name, T, id) + +#define DOCTEST_GIVEN(name) DOCTEST_SUBCASE(" Given: " name) +#define DOCTEST_WHEN(name) DOCTEST_SUBCASE(" When: " name) +#define DOCTEST_AND_WHEN(name) DOCTEST_SUBCASE("And when: " name) +#define DOCTEST_THEN(name) DOCTEST_SUBCASE(" Then: " name) +#define DOCTEST_AND_THEN(name) DOCTEST_SUBCASE(" And: " name) +// clang-format on + +// == SHORT VERSIONS OF THE MACROS +#ifndef DOCTEST_CONFIG_NO_SHORT_MACRO_NAMES + +#define TEST_CASE(name) DOCTEST_TEST_CASE(name) +#define TEST_CASE_CLASS(name) DOCTEST_TEST_CASE_CLASS(name) +#define TEST_CASE_FIXTURE(x, name) DOCTEST_TEST_CASE_FIXTURE(x, name) +#define TYPE_TO_STRING_AS(str, ...) DOCTEST_TYPE_TO_STRING_AS(str, __VA_ARGS__) +#define TYPE_TO_STRING(...) DOCTEST_TYPE_TO_STRING(__VA_ARGS__) +#define TEST_CASE_TEMPLATE(name, T, ...) DOCTEST_TEST_CASE_TEMPLATE(name, T, __VA_ARGS__) +#define TEST_CASE_TEMPLATE_DEFINE(name, T, id) DOCTEST_TEST_CASE_TEMPLATE_DEFINE(name, T, id) +#define TEST_CASE_TEMPLATE_INVOKE(id, ...) DOCTEST_TEST_CASE_TEMPLATE_INVOKE(id, __VA_ARGS__) +#define TEST_CASE_TEMPLATE_APPLY(id, ...) DOCTEST_TEST_CASE_TEMPLATE_APPLY(id, __VA_ARGS__) +#define SUBCASE(name) DOCTEST_SUBCASE(name) +#define TEST_SUITE(decorators) DOCTEST_TEST_SUITE(decorators) +#define TEST_SUITE_BEGIN(name) DOCTEST_TEST_SUITE_BEGIN(name) +#define TEST_SUITE_END DOCTEST_TEST_SUITE_END +#define REGISTER_EXCEPTION_TRANSLATOR(signature) DOCTEST_REGISTER_EXCEPTION_TRANSLATOR(signature) +#define REGISTER_REPORTER(name, priority, reporter) DOCTEST_REGISTER_REPORTER(name, priority, reporter) +#define REGISTER_LISTENER(name, priority, reporter) DOCTEST_REGISTER_LISTENER(name, priority, reporter) +#define INFO(...) DOCTEST_INFO(__VA_ARGS__) +#define CAPTURE(x) DOCTEST_CAPTURE(x) +#define ADD_MESSAGE_AT(file, line, ...) DOCTEST_ADD_MESSAGE_AT(file, line, __VA_ARGS__) +#define ADD_FAIL_CHECK_AT(file, line, ...) DOCTEST_ADD_FAIL_CHECK_AT(file, line, __VA_ARGS__) +#define ADD_FAIL_AT(file, line, ...) DOCTEST_ADD_FAIL_AT(file, line, __VA_ARGS__) +#define MESSAGE(...) DOCTEST_MESSAGE(__VA_ARGS__) +#define FAIL_CHECK(...) DOCTEST_FAIL_CHECK(__VA_ARGS__) +#define FAIL(...) DOCTEST_FAIL(__VA_ARGS__) +#define TO_LVALUE(...) DOCTEST_TO_LVALUE(__VA_ARGS__) + +#define WARN(...) DOCTEST_WARN(__VA_ARGS__) +#define WARN_FALSE(...) DOCTEST_WARN_FALSE(__VA_ARGS__) +#define WARN_THROWS(...) DOCTEST_WARN_THROWS(__VA_ARGS__) +#define WARN_THROWS_AS(expr, ...) DOCTEST_WARN_THROWS_AS(expr, __VA_ARGS__) +#define WARN_THROWS_WITH(expr, ...) DOCTEST_WARN_THROWS_WITH(expr, __VA_ARGS__) +#define WARN_THROWS_WITH_AS(expr, with, ...) DOCTEST_WARN_THROWS_WITH_AS(expr, with, __VA_ARGS__) +#define WARN_NOTHROW(...) DOCTEST_WARN_NOTHROW(__VA_ARGS__) +#define CHECK(...) DOCTEST_CHECK(__VA_ARGS__) +#define CHECK_FALSE(...) DOCTEST_CHECK_FALSE(__VA_ARGS__) +#define CHECK_THROWS(...) DOCTEST_CHECK_THROWS(__VA_ARGS__) +#define CHECK_THROWS_AS(expr, ...) DOCTEST_CHECK_THROWS_AS(expr, __VA_ARGS__) +#define CHECK_THROWS_WITH(expr, ...) DOCTEST_CHECK_THROWS_WITH(expr, __VA_ARGS__) +#define CHECK_THROWS_WITH_AS(expr, with, ...) DOCTEST_CHECK_THROWS_WITH_AS(expr, with, __VA_ARGS__) +#define CHECK_NOTHROW(...) DOCTEST_CHECK_NOTHROW(__VA_ARGS__) +#define REQUIRE(...) DOCTEST_REQUIRE(__VA_ARGS__) +#define REQUIRE_FALSE(...) DOCTEST_REQUIRE_FALSE(__VA_ARGS__) +#define REQUIRE_THROWS(...) DOCTEST_REQUIRE_THROWS(__VA_ARGS__) +#define REQUIRE_THROWS_AS(expr, ...) DOCTEST_REQUIRE_THROWS_AS(expr, __VA_ARGS__) +#define REQUIRE_THROWS_WITH(expr, ...) DOCTEST_REQUIRE_THROWS_WITH(expr, __VA_ARGS__) +#define REQUIRE_THROWS_WITH_AS(expr, with, ...) DOCTEST_REQUIRE_THROWS_WITH_AS(expr, with, __VA_ARGS__) +#define REQUIRE_NOTHROW(...) DOCTEST_REQUIRE_NOTHROW(__VA_ARGS__) + +#define WARN_MESSAGE(cond, ...) DOCTEST_WARN_MESSAGE(cond, __VA_ARGS__) +#define WARN_FALSE_MESSAGE(cond, ...) DOCTEST_WARN_FALSE_MESSAGE(cond, __VA_ARGS__) +#define WARN_THROWS_MESSAGE(expr, ...) DOCTEST_WARN_THROWS_MESSAGE(expr, __VA_ARGS__) +#define WARN_THROWS_AS_MESSAGE(expr, ex, ...) DOCTEST_WARN_THROWS_AS_MESSAGE(expr, ex, __VA_ARGS__) +#define WARN_THROWS_WITH_MESSAGE(expr, with, ...) DOCTEST_WARN_THROWS_WITH_MESSAGE(expr, with, __VA_ARGS__) +#define WARN_THROWS_WITH_AS_MESSAGE(expr, with, ex, ...) DOCTEST_WARN_THROWS_WITH_AS_MESSAGE(expr, with, ex, __VA_ARGS__) +#define WARN_NOTHROW_MESSAGE(expr, ...) DOCTEST_WARN_NOTHROW_MESSAGE(expr, __VA_ARGS__) +#define CHECK_MESSAGE(cond, ...) DOCTEST_CHECK_MESSAGE(cond, __VA_ARGS__) +#define CHECK_FALSE_MESSAGE(cond, ...) DOCTEST_CHECK_FALSE_MESSAGE(cond, __VA_ARGS__) +#define CHECK_THROWS_MESSAGE(expr, ...) DOCTEST_CHECK_THROWS_MESSAGE(expr, __VA_ARGS__) +#define CHECK_THROWS_AS_MESSAGE(expr, ex, ...) DOCTEST_CHECK_THROWS_AS_MESSAGE(expr, ex, __VA_ARGS__) +#define CHECK_THROWS_WITH_MESSAGE(expr, with, ...) DOCTEST_CHECK_THROWS_WITH_MESSAGE(expr, with, __VA_ARGS__) +#define CHECK_THROWS_WITH_AS_MESSAGE(expr, with, ex, ...) DOCTEST_CHECK_THROWS_WITH_AS_MESSAGE(expr, with, ex, __VA_ARGS__) +#define CHECK_NOTHROW_MESSAGE(expr, ...) DOCTEST_CHECK_NOTHROW_MESSAGE(expr, __VA_ARGS__) +#define REQUIRE_MESSAGE(cond, ...) DOCTEST_REQUIRE_MESSAGE(cond, __VA_ARGS__) +#define REQUIRE_FALSE_MESSAGE(cond, ...) DOCTEST_REQUIRE_FALSE_MESSAGE(cond, __VA_ARGS__) +#define REQUIRE_THROWS_MESSAGE(expr, ...) DOCTEST_REQUIRE_THROWS_MESSAGE(expr, __VA_ARGS__) +#define REQUIRE_THROWS_AS_MESSAGE(expr, ex, ...) DOCTEST_REQUIRE_THROWS_AS_MESSAGE(expr, ex, __VA_ARGS__) +#define REQUIRE_THROWS_WITH_MESSAGE(expr, with, ...) DOCTEST_REQUIRE_THROWS_WITH_MESSAGE(expr, with, __VA_ARGS__) +#define REQUIRE_THROWS_WITH_AS_MESSAGE(expr, with, ex, ...) DOCTEST_REQUIRE_THROWS_WITH_AS_MESSAGE(expr, with, ex, __VA_ARGS__) +#define REQUIRE_NOTHROW_MESSAGE(expr, ...) DOCTEST_REQUIRE_NOTHROW_MESSAGE(expr, __VA_ARGS__) + +#define SCENARIO(name) DOCTEST_SCENARIO(name) +#define SCENARIO_CLASS(name) DOCTEST_SCENARIO_CLASS(name) +#define SCENARIO_TEMPLATE(name, T, ...) DOCTEST_SCENARIO_TEMPLATE(name, T, __VA_ARGS__) +#define SCENARIO_TEMPLATE_DEFINE(name, T, id) DOCTEST_SCENARIO_TEMPLATE_DEFINE(name, T, id) +#define GIVEN(name) DOCTEST_GIVEN(name) +#define WHEN(name) DOCTEST_WHEN(name) +#define AND_WHEN(name) DOCTEST_AND_WHEN(name) +#define THEN(name) DOCTEST_THEN(name) +#define AND_THEN(name) DOCTEST_AND_THEN(name) + +#define WARN_EQ(...) DOCTEST_WARN_EQ(__VA_ARGS__) +#define CHECK_EQ(...) DOCTEST_CHECK_EQ(__VA_ARGS__) +#define REQUIRE_EQ(...) DOCTEST_REQUIRE_EQ(__VA_ARGS__) +#define WARN_NE(...) DOCTEST_WARN_NE(__VA_ARGS__) +#define CHECK_NE(...) DOCTEST_CHECK_NE(__VA_ARGS__) +#define REQUIRE_NE(...) DOCTEST_REQUIRE_NE(__VA_ARGS__) +#define WARN_GT(...) DOCTEST_WARN_GT(__VA_ARGS__) +#define CHECK_GT(...) DOCTEST_CHECK_GT(__VA_ARGS__) +#define REQUIRE_GT(...) DOCTEST_REQUIRE_GT(__VA_ARGS__) +#define WARN_LT(...) DOCTEST_WARN_LT(__VA_ARGS__) +#define CHECK_LT(...) DOCTEST_CHECK_LT(__VA_ARGS__) +#define REQUIRE_LT(...) DOCTEST_REQUIRE_LT(__VA_ARGS__) +#define WARN_GE(...) DOCTEST_WARN_GE(__VA_ARGS__) +#define CHECK_GE(...) DOCTEST_CHECK_GE(__VA_ARGS__) +#define REQUIRE_GE(...) DOCTEST_REQUIRE_GE(__VA_ARGS__) +#define WARN_LE(...) DOCTEST_WARN_LE(__VA_ARGS__) +#define CHECK_LE(...) DOCTEST_CHECK_LE(__VA_ARGS__) +#define REQUIRE_LE(...) DOCTEST_REQUIRE_LE(__VA_ARGS__) +#define WARN_UNARY(...) DOCTEST_WARN_UNARY(__VA_ARGS__) +#define CHECK_UNARY(...) DOCTEST_CHECK_UNARY(__VA_ARGS__) +#define REQUIRE_UNARY(...) DOCTEST_REQUIRE_UNARY(__VA_ARGS__) +#define WARN_UNARY_FALSE(...) DOCTEST_WARN_UNARY_FALSE(__VA_ARGS__) +#define CHECK_UNARY_FALSE(...) DOCTEST_CHECK_UNARY_FALSE(__VA_ARGS__) +#define REQUIRE_UNARY_FALSE(...) DOCTEST_REQUIRE_UNARY_FALSE(__VA_ARGS__) + +// KEPT FOR BACKWARDS COMPATIBILITY +#define FAST_WARN_EQ(...) DOCTEST_FAST_WARN_EQ(__VA_ARGS__) +#define FAST_CHECK_EQ(...) DOCTEST_FAST_CHECK_EQ(__VA_ARGS__) +#define FAST_REQUIRE_EQ(...) DOCTEST_FAST_REQUIRE_EQ(__VA_ARGS__) +#define FAST_WARN_NE(...) DOCTEST_FAST_WARN_NE(__VA_ARGS__) +#define FAST_CHECK_NE(...) DOCTEST_FAST_CHECK_NE(__VA_ARGS__) +#define FAST_REQUIRE_NE(...) DOCTEST_FAST_REQUIRE_NE(__VA_ARGS__) +#define FAST_WARN_GT(...) DOCTEST_FAST_WARN_GT(__VA_ARGS__) +#define FAST_CHECK_GT(...) DOCTEST_FAST_CHECK_GT(__VA_ARGS__) +#define FAST_REQUIRE_GT(...) DOCTEST_FAST_REQUIRE_GT(__VA_ARGS__) +#define FAST_WARN_LT(...) DOCTEST_FAST_WARN_LT(__VA_ARGS__) +#define FAST_CHECK_LT(...) DOCTEST_FAST_CHECK_LT(__VA_ARGS__) +#define FAST_REQUIRE_LT(...) DOCTEST_FAST_REQUIRE_LT(__VA_ARGS__) +#define FAST_WARN_GE(...) DOCTEST_FAST_WARN_GE(__VA_ARGS__) +#define FAST_CHECK_GE(...) DOCTEST_FAST_CHECK_GE(__VA_ARGS__) +#define FAST_REQUIRE_GE(...) DOCTEST_FAST_REQUIRE_GE(__VA_ARGS__) +#define FAST_WARN_LE(...) DOCTEST_FAST_WARN_LE(__VA_ARGS__) +#define FAST_CHECK_LE(...) DOCTEST_FAST_CHECK_LE(__VA_ARGS__) +#define FAST_REQUIRE_LE(...) DOCTEST_FAST_REQUIRE_LE(__VA_ARGS__) + +#define FAST_WARN_UNARY(...) DOCTEST_FAST_WARN_UNARY(__VA_ARGS__) +#define FAST_CHECK_UNARY(...) DOCTEST_FAST_CHECK_UNARY(__VA_ARGS__) +#define FAST_REQUIRE_UNARY(...) DOCTEST_FAST_REQUIRE_UNARY(__VA_ARGS__) +#define FAST_WARN_UNARY_FALSE(...) DOCTEST_FAST_WARN_UNARY_FALSE(__VA_ARGS__) +#define FAST_CHECK_UNARY_FALSE(...) DOCTEST_FAST_CHECK_UNARY_FALSE(__VA_ARGS__) +#define FAST_REQUIRE_UNARY_FALSE(...) DOCTEST_FAST_REQUIRE_UNARY_FALSE(__VA_ARGS__) + +#define TEST_CASE_TEMPLATE_INSTANTIATE(id, ...) DOCTEST_TEST_CASE_TEMPLATE_INSTANTIATE(id, __VA_ARGS__) + +#endif // DOCTEST_CONFIG_NO_SHORT_MACRO_NAMES + +#ifndef DOCTEST_CONFIG_DISABLE + +// this is here to clear the 'current test suite' for the current translation unit - at the top +DOCTEST_TEST_SUITE_END(); + +#endif // DOCTEST_CONFIG_DISABLE + +DOCTEST_CLANG_SUPPRESS_WARNING_POP +DOCTEST_MSVC_SUPPRESS_WARNING_POP +DOCTEST_GCC_SUPPRESS_WARNING_POP + +DOCTEST_SUPPRESS_COMMON_WARNINGS_POP + +#endif // DOCTEST_LIBRARY_INCLUDED + +#ifndef DOCTEST_SINGLE_HEADER +#define DOCTEST_SINGLE_HEADER +#endif // DOCTEST_SINGLE_HEADER + +#if defined(DOCTEST_CONFIG_IMPLEMENT) || !defined(DOCTEST_SINGLE_HEADER) + +#ifndef DOCTEST_SINGLE_HEADER +#include "doctest_fwd.h" +#endif // DOCTEST_SINGLE_HEADER + +DOCTEST_CLANG_SUPPRESS_WARNING_WITH_PUSH("-Wunused-macros") + +#ifndef DOCTEST_LIBRARY_IMPLEMENTATION +#define DOCTEST_LIBRARY_IMPLEMENTATION + +DOCTEST_CLANG_SUPPRESS_WARNING_POP + +DOCTEST_SUPPRESS_COMMON_WARNINGS_PUSH + +DOCTEST_CLANG_SUPPRESS_WARNING_PUSH +DOCTEST_CLANG_SUPPRESS_WARNING("-Wglobal-constructors") +DOCTEST_CLANG_SUPPRESS_WARNING("-Wexit-time-destructors") +DOCTEST_CLANG_SUPPRESS_WARNING("-Wsign-conversion") +DOCTEST_CLANG_SUPPRESS_WARNING("-Wshorten-64-to-32") +DOCTEST_CLANG_SUPPRESS_WARNING("-Wmissing-variable-declarations") +DOCTEST_CLANG_SUPPRESS_WARNING("-Wswitch") +DOCTEST_CLANG_SUPPRESS_WARNING("-Wswitch-enum") +DOCTEST_CLANG_SUPPRESS_WARNING("-Wcovered-switch-default") +DOCTEST_CLANG_SUPPRESS_WARNING("-Wmissing-noreturn") +DOCTEST_CLANG_SUPPRESS_WARNING("-Wdisabled-macro-expansion") +DOCTEST_CLANG_SUPPRESS_WARNING("-Wmissing-braces") +DOCTEST_CLANG_SUPPRESS_WARNING("-Wmissing-field-initializers") +DOCTEST_CLANG_SUPPRESS_WARNING("-Wunused-member-function") +DOCTEST_CLANG_SUPPRESS_WARNING("-Wnonportable-system-include-path") + +DOCTEST_GCC_SUPPRESS_WARNING_PUSH +DOCTEST_GCC_SUPPRESS_WARNING("-Wconversion") +DOCTEST_GCC_SUPPRESS_WARNING("-Wsign-conversion") +DOCTEST_GCC_SUPPRESS_WARNING("-Wmissing-field-initializers") +DOCTEST_GCC_SUPPRESS_WARNING("-Wmissing-braces") +DOCTEST_GCC_SUPPRESS_WARNING("-Wswitch") +DOCTEST_GCC_SUPPRESS_WARNING("-Wswitch-enum") +DOCTEST_GCC_SUPPRESS_WARNING("-Wswitch-default") +DOCTEST_GCC_SUPPRESS_WARNING("-Wunsafe-loop-optimizations") +DOCTEST_GCC_SUPPRESS_WARNING("-Wold-style-cast") +DOCTEST_GCC_SUPPRESS_WARNING("-Wunused-function") +DOCTEST_GCC_SUPPRESS_WARNING("-Wmultiple-inheritance") +DOCTEST_GCC_SUPPRESS_WARNING("-Wsuggest-attribute") + +DOCTEST_MSVC_SUPPRESS_WARNING_PUSH +DOCTEST_MSVC_SUPPRESS_WARNING(4267) // 'var' : conversion from 'x' to 'y', possible loss of data +DOCTEST_MSVC_SUPPRESS_WARNING(4530) // C++ exception handler used, but unwind semantics not enabled +DOCTEST_MSVC_SUPPRESS_WARNING(4577) // 'noexcept' used with no exception handling mode specified +DOCTEST_MSVC_SUPPRESS_WARNING(4774) // format string expected in argument is not a string literal +DOCTEST_MSVC_SUPPRESS_WARNING(4365) // conversion from 'int' to 'unsigned', signed/unsigned mismatch +DOCTEST_MSVC_SUPPRESS_WARNING(5039) // pointer to potentially throwing function passed to extern C +DOCTEST_MSVC_SUPPRESS_WARNING(4800) // forcing value to bool 'true' or 'false' (performance warning) +DOCTEST_MSVC_SUPPRESS_WARNING(5245) // unreferenced function with internal linkage has been removed + +DOCTEST_MAKE_STD_HEADERS_CLEAN_FROM_WARNINGS_ON_WALL_BEGIN + +// required includes - will go only in one translation unit! +#include +#include +#include +// borland (Embarcadero) compiler requires math.h and not cmath - https://github.com/doctest/doctest/pull/37 +#ifdef __BORLANDC__ +#include +#endif // __BORLANDC__ +#include +#include +#include +#include +#include +#include +#include +#include +#ifndef DOCTEST_CONFIG_NO_INCLUDE_IOSTREAM +#include +#endif // DOCTEST_CONFIG_NO_INCLUDE_IOSTREAM +#include +#include +#include +#ifndef DOCTEST_CONFIG_NO_MULTITHREADING +#include +#include +#define DOCTEST_DECLARE_MUTEX(name) std::mutex name; +#define DOCTEST_DECLARE_STATIC_MUTEX(name) static DOCTEST_DECLARE_MUTEX(name) +#define DOCTEST_LOCK_MUTEX(name) std::lock_guard DOCTEST_ANONYMOUS(DOCTEST_ANON_LOCK_)(name); +#else // DOCTEST_CONFIG_NO_MULTITHREADING +#define DOCTEST_DECLARE_MUTEX(name) +#define DOCTEST_DECLARE_STATIC_MUTEX(name) +#define DOCTEST_LOCK_MUTEX(name) +#endif // DOCTEST_CONFIG_NO_MULTITHREADING +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#ifdef DOCTEST_PLATFORM_MAC +#include +#include +#include +#endif // DOCTEST_PLATFORM_MAC + +#ifdef DOCTEST_PLATFORM_WINDOWS + +// defines for a leaner windows.h +#ifndef WIN32_LEAN_AND_MEAN +#define WIN32_LEAN_AND_MEAN +#define DOCTEST_UNDEF_WIN32_LEAN_AND_MEAN +#endif // WIN32_LEAN_AND_MEAN +#ifndef NOMINMAX +#define NOMINMAX +#define DOCTEST_UNDEF_NOMINMAX +#endif // NOMINMAX + +// not sure what AfxWin.h is for - here I do what Catch does +#ifdef __AFXDLL +#include +#else +#include +#endif +#include + +#else // DOCTEST_PLATFORM_WINDOWS + +#include +#include + +#endif // DOCTEST_PLATFORM_WINDOWS + +// this is a fix for https://github.com/doctest/doctest/issues/348 +// https://mail.gnome.org/archives/xml/2012-January/msg00000.html +#if !defined(HAVE_UNISTD_H) && !defined(STDOUT_FILENO) +#define STDOUT_FILENO fileno(stdout) +#endif // HAVE_UNISTD_H + +DOCTEST_MAKE_STD_HEADERS_CLEAN_FROM_WARNINGS_ON_WALL_END + +// counts the number of elements in a C array +#define DOCTEST_COUNTOF(x) (sizeof(x) / sizeof(x[0])) + +#ifdef DOCTEST_CONFIG_DISABLE +#define DOCTEST_BRANCH_ON_DISABLED(if_disabled, if_not_disabled) if_disabled +#else // DOCTEST_CONFIG_DISABLE +#define DOCTEST_BRANCH_ON_DISABLED(if_disabled, if_not_disabled) if_not_disabled +#endif // DOCTEST_CONFIG_DISABLE + +#ifndef DOCTEST_CONFIG_OPTIONS_PREFIX +#define DOCTEST_CONFIG_OPTIONS_PREFIX "dt-" +#endif + +#ifndef DOCTEST_THREAD_LOCAL +#if defined(DOCTEST_CONFIG_NO_MULTITHREADING) || DOCTEST_MSVC && (DOCTEST_MSVC < DOCTEST_COMPILER(19, 0, 0)) +#define DOCTEST_THREAD_LOCAL +#else // DOCTEST_MSVC +#define DOCTEST_THREAD_LOCAL thread_local +#endif // DOCTEST_MSVC +#endif // DOCTEST_THREAD_LOCAL + +#ifndef DOCTEST_MULTI_LANE_ATOMICS_THREAD_LANES +#define DOCTEST_MULTI_LANE_ATOMICS_THREAD_LANES 32 +#endif + +#ifndef DOCTEST_MULTI_LANE_ATOMICS_CACHE_LINE_SIZE +#define DOCTEST_MULTI_LANE_ATOMICS_CACHE_LINE_SIZE 64 +#endif + +#ifdef DOCTEST_CONFIG_NO_UNPREFIXED_OPTIONS +#define DOCTEST_OPTIONS_PREFIX_DISPLAY DOCTEST_CONFIG_OPTIONS_PREFIX +#else +#define DOCTEST_OPTIONS_PREFIX_DISPLAY "" +#endif + +#if defined(WINAPI_FAMILY) && (WINAPI_FAMILY == WINAPI_FAMILY_APP) +#define DOCTEST_CONFIG_NO_MULTI_LANE_ATOMICS +#endif + +#ifndef DOCTEST_CDECL +#define DOCTEST_CDECL __cdecl +#endif + +namespace doctest { + +bool is_running_in_test = false; + +namespace { + using namespace detail; + + template + DOCTEST_NORETURN void throw_exception(Ex const& e) { +#ifndef DOCTEST_CONFIG_NO_EXCEPTIONS + throw e; +#else // DOCTEST_CONFIG_NO_EXCEPTIONS +#ifdef DOCTEST_CONFIG_HANDLE_EXCEPTION + DOCTEST_CONFIG_HANDLE_EXCEPTION(e); +#else // DOCTEST_CONFIG_HANDLE_EXCEPTION +#ifndef DOCTEST_CONFIG_NO_INCLUDE_IOSTREAM + std::cerr << "doctest will terminate because it needed to throw an exception.\n" + << "The message was: " << e.what() << '\n'; +#endif // DOCTEST_CONFIG_NO_INCLUDE_IOSTREAM +#endif // DOCTEST_CONFIG_HANDLE_EXCEPTION + std::terminate(); +#endif // DOCTEST_CONFIG_NO_EXCEPTIONS + } + +#ifndef DOCTEST_INTERNAL_ERROR +#define DOCTEST_INTERNAL_ERROR(msg) \ + throw_exception(std::logic_error( \ + __FILE__ ":" DOCTEST_TOSTR(__LINE__) ": Internal doctest error: " msg)) +#endif // DOCTEST_INTERNAL_ERROR + + // case insensitive strcmp + int stricmp(const char* a, const char* b) { + for(;; a++, b++) { + const int d = tolower(*a) - tolower(*b); + if(d != 0 || !*a) + return d; + } + } + + struct Endianness + { + enum Arch + { + Big, + Little + }; + + static Arch which() { + int x = 1; + // casting any data pointer to char* is allowed + auto ptr = reinterpret_cast(&x); + if(*ptr) + return Little; + return Big; + } + }; +} // namespace + +namespace detail { + DOCTEST_THREAD_LOCAL class + { + std::vector stack; + std::stringstream ss; + + public: + std::ostream* push() { + stack.push_back(ss.tellp()); + return &ss; + } + + String pop() { + if (stack.empty()) + DOCTEST_INTERNAL_ERROR("TLSS was empty when trying to pop!"); + + std::streampos pos = stack.back(); + stack.pop_back(); + unsigned sz = static_cast(ss.tellp() - pos); + ss.rdbuf()->pubseekpos(pos, std::ios::in | std::ios::out); + return String(ss, sz); + } + } g_oss; + + std::ostream* tlssPush() { + return g_oss.push(); + } + + String tlssPop() { + return g_oss.pop(); + } + +#ifndef DOCTEST_CONFIG_DISABLE + +namespace timer_large_integer +{ + +#if defined(DOCTEST_PLATFORM_WINDOWS) + using type = ULONGLONG; +#else // DOCTEST_PLATFORM_WINDOWS + using type = std::uint64_t; +#endif // DOCTEST_PLATFORM_WINDOWS +} + +using ticks_t = timer_large_integer::type; + +#ifdef DOCTEST_CONFIG_GETCURRENTTICKS + ticks_t getCurrentTicks() { return DOCTEST_CONFIG_GETCURRENTTICKS(); } +#elif defined(DOCTEST_PLATFORM_WINDOWS) + ticks_t getCurrentTicks() { + static LARGE_INTEGER hz = { {0} }, hzo = { {0} }; + if(!hz.QuadPart) { + QueryPerformanceFrequency(&hz); + QueryPerformanceCounter(&hzo); + } + LARGE_INTEGER t; + QueryPerformanceCounter(&t); + return ((t.QuadPart - hzo.QuadPart) * LONGLONG(1000000)) / hz.QuadPart; + } +#else // DOCTEST_PLATFORM_WINDOWS + ticks_t getCurrentTicks() { + timeval t; + gettimeofday(&t, nullptr); + return static_cast(t.tv_sec) * 1000000 + static_cast(t.tv_usec); + } +#endif // DOCTEST_PLATFORM_WINDOWS + + struct Timer + { + void start() { m_ticks = getCurrentTicks(); } + unsigned int getElapsedMicroseconds() const { + return static_cast(getCurrentTicks() - m_ticks); + } + //unsigned int getElapsedMilliseconds() const { + // return static_cast(getElapsedMicroseconds() / 1000); + //} + double getElapsedSeconds() const { return static_cast(getCurrentTicks() - m_ticks) / 1000000.0; } + + private: + ticks_t m_ticks = 0; + }; + +#ifdef DOCTEST_CONFIG_NO_MULTITHREADING + template + using Atomic = T; +#else // DOCTEST_CONFIG_NO_MULTITHREADING + template + using Atomic = std::atomic; +#endif // DOCTEST_CONFIG_NO_MULTITHREADING + +#if defined(DOCTEST_CONFIG_NO_MULTI_LANE_ATOMICS) || defined(DOCTEST_CONFIG_NO_MULTITHREADING) + template + using MultiLaneAtomic = Atomic; +#else // DOCTEST_CONFIG_NO_MULTI_LANE_ATOMICS + // Provides a multilane implementation of an atomic variable that supports add, sub, load, + // store. Instead of using a single atomic variable, this splits up into multiple ones, + // each sitting on a separate cache line. The goal is to provide a speedup when most + // operations are modifying. It achieves this with two properties: + // + // * Multiple atomics are used, so chance of congestion from the same atomic is reduced. + // * Each atomic sits on a separate cache line, so false sharing is reduced. + // + // The disadvantage is that there is a small overhead due to the use of TLS, and load/store + // is slower because all atomics have to be accessed. + template + class MultiLaneAtomic + { + struct CacheLineAlignedAtomic + { + Atomic atomic{}; + char padding[DOCTEST_MULTI_LANE_ATOMICS_CACHE_LINE_SIZE - sizeof(Atomic)]; + }; + CacheLineAlignedAtomic m_atomics[DOCTEST_MULTI_LANE_ATOMICS_THREAD_LANES]; + + static_assert(sizeof(CacheLineAlignedAtomic) == DOCTEST_MULTI_LANE_ATOMICS_CACHE_LINE_SIZE, + "guarantee one atomic takes exactly one cache line"); + + public: + T operator++() DOCTEST_NOEXCEPT { return fetch_add(1) + 1; } + + T operator++(int) DOCTEST_NOEXCEPT { return fetch_add(1); } + + T fetch_add(T arg, std::memory_order order = std::memory_order_seq_cst) DOCTEST_NOEXCEPT { + return myAtomic().fetch_add(arg, order); + } + + T fetch_sub(T arg, std::memory_order order = std::memory_order_seq_cst) DOCTEST_NOEXCEPT { + return myAtomic().fetch_sub(arg, order); + } + + operator T() const DOCTEST_NOEXCEPT { return load(); } + + T load(std::memory_order order = std::memory_order_seq_cst) const DOCTEST_NOEXCEPT { + auto result = T(); + for(auto const& c : m_atomics) { + result += c.atomic.load(order); + } + return result; + } + + T operator=(T desired) DOCTEST_NOEXCEPT { // lgtm [cpp/assignment-does-not-return-this] + store(desired); + return desired; + } + + void store(T desired, std::memory_order order = std::memory_order_seq_cst) DOCTEST_NOEXCEPT { + // first value becomes desired", all others become 0. + for(auto& c : m_atomics) { + c.atomic.store(desired, order); + desired = {}; + } + } + + private: + // Each thread has a different atomic that it operates on. If more than NumLanes threads + // use this, some will use the same atomic. So performance will degrade a bit, but still + // everything will work. + // + // The logic here is a bit tricky. The call should be as fast as possible, so that there + // is minimal to no overhead in determining the correct atomic for the current thread. + // + // 1. A global static counter laneCounter counts continuously up. + // 2. Each successive thread will use modulo operation of that counter so it gets an atomic + // assigned in a round-robin fashion. + // 3. This tlsLaneIdx is stored in the thread local data, so it is directly available with + // little overhead. + Atomic& myAtomic() DOCTEST_NOEXCEPT { + static Atomic laneCounter; + DOCTEST_THREAD_LOCAL size_t tlsLaneIdx = + laneCounter++ % DOCTEST_MULTI_LANE_ATOMICS_THREAD_LANES; + + return m_atomics[tlsLaneIdx].atomic; + } + }; +#endif // DOCTEST_CONFIG_NO_MULTI_LANE_ATOMICS + + // this holds both parameters from the command line and runtime data for tests + struct ContextState : ContextOptions, TestRunStats, CurrentTestCaseStats + { + MultiLaneAtomic numAssertsCurrentTest_atomic; + MultiLaneAtomic numAssertsFailedCurrentTest_atomic; + + std::vector> filters = decltype(filters)(9); // 9 different filters + + std::vector reporters_currently_used; + + assert_handler ah = nullptr; + + Timer timer; + + std::vector stringifiedContexts; // logging from INFO() due to an exception + + // stuff for subcases + bool reachedLeaf; + std::vector subcaseStack; + std::vector nextSubcaseStack; + std::unordered_set fullyTraversedSubcases; + size_t currentSubcaseDepth; + Atomic shouldLogCurrentException; + + void resetRunData() { + numTestCases = 0; + numTestCasesPassingFilters = 0; + numTestSuitesPassingFilters = 0; + numTestCasesFailed = 0; + numAsserts = 0; + numAssertsFailed = 0; + numAssertsCurrentTest = 0; + numAssertsFailedCurrentTest = 0; + } + + void finalizeTestCaseData() { + seconds = timer.getElapsedSeconds(); + + // update the non-atomic counters + numAsserts += numAssertsCurrentTest_atomic; + numAssertsFailed += numAssertsFailedCurrentTest_atomic; + numAssertsCurrentTest = numAssertsCurrentTest_atomic; + numAssertsFailedCurrentTest = numAssertsFailedCurrentTest_atomic; + + if(numAssertsFailedCurrentTest) + failure_flags |= TestCaseFailureReason::AssertFailure; + + if(Approx(currentTest->m_timeout).epsilon(DBL_EPSILON) != 0 && + Approx(seconds).epsilon(DBL_EPSILON) > currentTest->m_timeout) + failure_flags |= TestCaseFailureReason::Timeout; + + if(currentTest->m_should_fail) { + if(failure_flags) { + failure_flags |= TestCaseFailureReason::ShouldHaveFailedAndDid; + } else { + failure_flags |= TestCaseFailureReason::ShouldHaveFailedButDidnt; + } + } else if(failure_flags && currentTest->m_may_fail) { + failure_flags |= TestCaseFailureReason::CouldHaveFailedAndDid; + } else if(currentTest->m_expected_failures > 0) { + if(numAssertsFailedCurrentTest == currentTest->m_expected_failures) { + failure_flags |= TestCaseFailureReason::FailedExactlyNumTimes; + } else { + failure_flags |= TestCaseFailureReason::DidntFailExactlyNumTimes; + } + } + + bool ok_to_fail = (TestCaseFailureReason::ShouldHaveFailedAndDid & failure_flags) || + (TestCaseFailureReason::CouldHaveFailedAndDid & failure_flags) || + (TestCaseFailureReason::FailedExactlyNumTimes & failure_flags); + + // if any subcase has failed - the whole test case has failed + testCaseSuccess = !(failure_flags && !ok_to_fail); + if(!testCaseSuccess) + numTestCasesFailed++; + } + }; + + ContextState* g_cs = nullptr; + + // used to avoid locks for the debug output + // TODO: figure out if this is indeed necessary/correct - seems like either there still + // could be a race or that there wouldn't be a race even if using the context directly + DOCTEST_THREAD_LOCAL bool g_no_colors; + +#endif // DOCTEST_CONFIG_DISABLE +} // namespace detail + +char* String::allocate(size_type sz) { + if (sz <= last) { + buf[sz] = '\0'; + setLast(last - sz); + return buf; + } else { + setOnHeap(); + data.size = sz; + data.capacity = data.size + 1; + data.ptr = new char[data.capacity]; + data.ptr[sz] = '\0'; + return data.ptr; + } +} + +void String::setOnHeap() noexcept { *reinterpret_cast(&buf[last]) = 128; } +void String::setLast(size_type in) noexcept { buf[last] = char(in); } +void String::setSize(size_type sz) noexcept { + if (isOnStack()) { buf[sz] = '\0'; setLast(last - sz); } + else { data.ptr[sz] = '\0'; data.size = sz; } +} + +void String::copy(const String& other) { + if(other.isOnStack()) { + memcpy(buf, other.buf, len); + } else { + memcpy(allocate(other.data.size), other.data.ptr, other.data.size); + } +} + +String::String() noexcept { + buf[0] = '\0'; + setLast(); +} + +String::~String() { + if(!isOnStack()) + delete[] data.ptr; +} // NOLINT(clang-analyzer-cplusplus.NewDeleteLeaks) + +String::String(const char* in) + : String(in, strlen(in)) {} + +String::String(const char* in, size_type in_size) { + memcpy(allocate(in_size), in, in_size); +} + +String::String(std::istream& in, size_type in_size) { + in.read(allocate(in_size), in_size); +} + +String::String(const String& other) { copy(other); } + +String& String::operator=(const String& other) { + if(this != &other) { + if(!isOnStack()) + delete[] data.ptr; + + copy(other); + } + + return *this; +} + +String& String::operator+=(const String& other) { + const size_type my_old_size = size(); + const size_type other_size = other.size(); + const size_type total_size = my_old_size + other_size; + if(isOnStack()) { + if(total_size < len) { + // append to the current stack space + memcpy(buf + my_old_size, other.c_str(), other_size + 1); + // NOLINTNEXTLINE(clang-analyzer-cplusplus.NewDeleteLeaks) + setLast(last - total_size); + } else { + // alloc new chunk + char* temp = new char[total_size + 1]; + // copy current data to new location before writing in the union + memcpy(temp, buf, my_old_size); // skip the +1 ('\0') for speed + // update data in union + setOnHeap(); + data.size = total_size; + data.capacity = data.size + 1; + data.ptr = temp; + // transfer the rest of the data + memcpy(data.ptr + my_old_size, other.c_str(), other_size + 1); + } + } else { + if(data.capacity > total_size) { + // append to the current heap block + data.size = total_size; + memcpy(data.ptr + my_old_size, other.c_str(), other_size + 1); + } else { + // resize + data.capacity *= 2; + if(data.capacity <= total_size) + data.capacity = total_size + 1; + // alloc new chunk + char* temp = new char[data.capacity]; + // copy current data to new location before releasing it + memcpy(temp, data.ptr, my_old_size); // skip the +1 ('\0') for speed + // release old chunk + delete[] data.ptr; + // update the rest of the union members + data.size = total_size; + data.ptr = temp; + // transfer the rest of the data + memcpy(data.ptr + my_old_size, other.c_str(), other_size + 1); + } + } + + return *this; +} + +String::String(String&& other) noexcept { + memcpy(buf, other.buf, len); + other.buf[0] = '\0'; + other.setLast(); +} + +String& String::operator=(String&& other) noexcept { + if(this != &other) { + if(!isOnStack()) + delete[] data.ptr; + memcpy(buf, other.buf, len); + other.buf[0] = '\0'; + other.setLast(); + } + return *this; +} + +char String::operator[](size_type i) const { + return const_cast(this)->operator[](i); +} + +char& String::operator[](size_type i) { + if(isOnStack()) + return reinterpret_cast(buf)[i]; + return data.ptr[i]; +} + +DOCTEST_GCC_SUPPRESS_WARNING_WITH_PUSH("-Wmaybe-uninitialized") +String::size_type String::size() const { + if(isOnStack()) + return last - (size_type(buf[last]) & 31); // using "last" would work only if "len" is 32 + return data.size; +} +DOCTEST_GCC_SUPPRESS_WARNING_POP + +String::size_type String::capacity() const { + if(isOnStack()) + return len; + return data.capacity; +} + +String String::substr(size_type pos, size_type cnt) && { + cnt = std::min(cnt, size() - 1 - pos); + char* cptr = c_str(); + memmove(cptr, cptr + pos, cnt); + setSize(cnt); + return std::move(*this); +} + +String String::substr(size_type pos, size_type cnt) const & { + cnt = std::min(cnt, size() - 1 - pos); + return String{ c_str() + pos, cnt }; +} + +String::size_type String::find(char ch, size_type pos) const { + const char* begin = c_str(); + const char* end = begin + size(); + const char* it = begin + pos; + for (; it < end && *it != ch; it++); + if (it < end) { return static_cast(it - begin); } + else { return npos; } +} + +String::size_type String::rfind(char ch, size_type pos) const { + const char* begin = c_str(); + const char* it = begin + std::min(pos, size() - 1); + for (; it >= begin && *it != ch; it--); + if (it >= begin) { return static_cast(it - begin); } + else { return npos; } +} + +int String::compare(const char* other, bool no_case) const { + if(no_case) + return doctest::stricmp(c_str(), other); + return std::strcmp(c_str(), other); +} + +int String::compare(const String& other, bool no_case) const { + return compare(other.c_str(), no_case); +} + +String operator+(const String& lhs, const String& rhs) { return String(lhs) += rhs; } + +bool operator==(const String& lhs, const String& rhs) { return lhs.compare(rhs) == 0; } +bool operator!=(const String& lhs, const String& rhs) { return lhs.compare(rhs) != 0; } +bool operator< (const String& lhs, const String& rhs) { return lhs.compare(rhs) < 0; } +bool operator> (const String& lhs, const String& rhs) { return lhs.compare(rhs) > 0; } +bool operator<=(const String& lhs, const String& rhs) { return (lhs != rhs) ? lhs.compare(rhs) < 0 : true; } +bool operator>=(const String& lhs, const String& rhs) { return (lhs != rhs) ? lhs.compare(rhs) > 0 : true; } + +std::ostream& operator<<(std::ostream& s, const String& in) { return s << in.c_str(); } + +Contains::Contains(const String& str) : string(str) { } + +bool Contains::checkWith(const String& other) const { + return strstr(other.c_str(), string.c_str()) != nullptr; +} + +String toString(const Contains& in) { + return "Contains( " + in.string + " )"; +} + +bool operator==(const String& lhs, const Contains& rhs) { return rhs.checkWith(lhs); } +bool operator==(const Contains& lhs, const String& rhs) { return lhs.checkWith(rhs); } +bool operator!=(const String& lhs, const Contains& rhs) { return !rhs.checkWith(lhs); } +bool operator!=(const Contains& lhs, const String& rhs) { return !lhs.checkWith(rhs); } + +namespace { + void color_to_stream(std::ostream&, Color::Enum) DOCTEST_BRANCH_ON_DISABLED({}, ;) +} // namespace + +namespace Color { + std::ostream& operator<<(std::ostream& s, Color::Enum code) { + color_to_stream(s, code); + return s; + } +} // namespace Color + +// clang-format off +const char* assertString(assertType::Enum at) { + DOCTEST_MSVC_SUPPRESS_WARNING_WITH_PUSH(4061) // enum 'x' in switch of enum 'y' is not explicitly handled + #define DOCTEST_GENERATE_ASSERT_TYPE_CASE(assert_type) case assertType::DT_ ## assert_type: return #assert_type + #define DOCTEST_GENERATE_ASSERT_TYPE_CASES(assert_type) \ + DOCTEST_GENERATE_ASSERT_TYPE_CASE(WARN_ ## assert_type); \ + DOCTEST_GENERATE_ASSERT_TYPE_CASE(CHECK_ ## assert_type); \ + DOCTEST_GENERATE_ASSERT_TYPE_CASE(REQUIRE_ ## assert_type) + switch(at) { + DOCTEST_GENERATE_ASSERT_TYPE_CASE(WARN); + DOCTEST_GENERATE_ASSERT_TYPE_CASE(CHECK); + DOCTEST_GENERATE_ASSERT_TYPE_CASE(REQUIRE); + + DOCTEST_GENERATE_ASSERT_TYPE_CASES(FALSE); + + DOCTEST_GENERATE_ASSERT_TYPE_CASES(THROWS); + + DOCTEST_GENERATE_ASSERT_TYPE_CASES(THROWS_AS); + + DOCTEST_GENERATE_ASSERT_TYPE_CASES(THROWS_WITH); + + DOCTEST_GENERATE_ASSERT_TYPE_CASES(THROWS_WITH_AS); + + DOCTEST_GENERATE_ASSERT_TYPE_CASES(NOTHROW); + + DOCTEST_GENERATE_ASSERT_TYPE_CASES(EQ); + DOCTEST_GENERATE_ASSERT_TYPE_CASES(NE); + DOCTEST_GENERATE_ASSERT_TYPE_CASES(GT); + DOCTEST_GENERATE_ASSERT_TYPE_CASES(LT); + DOCTEST_GENERATE_ASSERT_TYPE_CASES(GE); + DOCTEST_GENERATE_ASSERT_TYPE_CASES(LE); + + DOCTEST_GENERATE_ASSERT_TYPE_CASES(UNARY); + DOCTEST_GENERATE_ASSERT_TYPE_CASES(UNARY_FALSE); + + default: DOCTEST_INTERNAL_ERROR("Tried stringifying invalid assert type!"); + } + DOCTEST_MSVC_SUPPRESS_WARNING_POP +} +// clang-format on + +const char* failureString(assertType::Enum at) { + if(at & assertType::is_warn) //!OCLINT bitwise operator in conditional + return "WARNING"; + if(at & assertType::is_check) //!OCLINT bitwise operator in conditional + return "ERROR"; + if(at & assertType::is_require) //!OCLINT bitwise operator in conditional + return "FATAL ERROR"; + return ""; +} + +DOCTEST_CLANG_SUPPRESS_WARNING_WITH_PUSH("-Wnull-dereference") +DOCTEST_GCC_SUPPRESS_WARNING_WITH_PUSH("-Wnull-dereference") +// depending on the current options this will remove the path of filenames +const char* skipPathFromFilename(const char* file) { +#ifndef DOCTEST_CONFIG_DISABLE + if(getContextOptions()->no_path_in_filenames) { + auto back = std::strrchr(file, '\\'); + auto forward = std::strrchr(file, '/'); + if(back || forward) { + if(back > forward) + forward = back; + return forward + 1; + } + } +#endif // DOCTEST_CONFIG_DISABLE + return file; +} +DOCTEST_CLANG_SUPPRESS_WARNING_POP +DOCTEST_GCC_SUPPRESS_WARNING_POP + +bool SubcaseSignature::operator==(const SubcaseSignature& other) const { + return m_line == other.m_line + && std::strcmp(m_file, other.m_file) == 0 + && m_name == other.m_name; +} + +bool SubcaseSignature::operator<(const SubcaseSignature& other) const { + if(m_line != other.m_line) + return m_line < other.m_line; + if(std::strcmp(m_file, other.m_file) != 0) + return std::strcmp(m_file, other.m_file) < 0; + return m_name.compare(other.m_name) < 0; +} + +DOCTEST_DEFINE_INTERFACE(IContextScope) + +namespace detail { + void filldata::fill(std::ostream* stream, const void* in) { + if (in) { *stream << in; } + else { *stream << "nullptr"; } + } + + template + String toStreamLit(T t) { + std::ostream* os = tlssPush(); + os->operator<<(t); + return tlssPop(); + } +} + +#ifdef DOCTEST_CONFIG_TREAT_CHAR_STAR_AS_STRING +String toString(const char* in) { return String("\"") + (in ? in : "{null string}") + "\""; } +#endif // DOCTEST_CONFIG_TREAT_CHAR_STAR_AS_STRING + +#if DOCTEST_MSVC >= DOCTEST_COMPILER(19, 20, 0) +// see this issue on why this is needed: https://github.com/doctest/doctest/issues/183 +String toString(const std::string& in) { return in.c_str(); } +#endif // VS 2019 + +String toString(String in) { return in; } + +String toString(std::nullptr_t) { return "nullptr"; } + +String toString(bool in) { return in ? "true" : "false"; } + +String toString(float in) { return toStreamLit(in); } +String toString(double in) { return toStreamLit(in); } +String toString(double long in) { return toStreamLit(in); } + +String toString(char in) { return toStreamLit(static_cast(in)); } +String toString(char signed in) { return toStreamLit(static_cast(in)); } +String toString(char unsigned in) { return toStreamLit(static_cast(in)); } +String toString(short in) { return toStreamLit(in); } +String toString(short unsigned in) { return toStreamLit(in); } +String toString(signed in) { return toStreamLit(in); } +String toString(unsigned in) { return toStreamLit(in); } +String toString(long in) { return toStreamLit(in); } +String toString(long unsigned in) { return toStreamLit(in); } +String toString(long long in) { return toStreamLit(in); } +String toString(long long unsigned in) { return toStreamLit(in); } + +Approx::Approx(double value) + : m_epsilon(static_cast(std::numeric_limits::epsilon()) * 100) + , m_scale(1.0) + , m_value(value) {} + +Approx Approx::operator()(double value) const { + Approx approx(value); + approx.epsilon(m_epsilon); + approx.scale(m_scale); + return approx; +} + +Approx& Approx::epsilon(double newEpsilon) { + m_epsilon = newEpsilon; + return *this; +} +Approx& Approx::scale(double newScale) { + m_scale = newScale; + return *this; +} + +bool operator==(double lhs, const Approx& rhs) { + // Thanks to Richard Harris for his help refining this formula + return std::fabs(lhs - rhs.m_value) < + rhs.m_epsilon * (rhs.m_scale + std::max(std::fabs(lhs), std::fabs(rhs.m_value))); +} +bool operator==(const Approx& lhs, double rhs) { return operator==(rhs, lhs); } +bool operator!=(double lhs, const Approx& rhs) { return !operator==(lhs, rhs); } +bool operator!=(const Approx& lhs, double rhs) { return !operator==(rhs, lhs); } +bool operator<=(double lhs, const Approx& rhs) { return lhs < rhs.m_value || lhs == rhs; } +bool operator<=(const Approx& lhs, double rhs) { return lhs.m_value < rhs || lhs == rhs; } +bool operator>=(double lhs, const Approx& rhs) { return lhs > rhs.m_value || lhs == rhs; } +bool operator>=(const Approx& lhs, double rhs) { return lhs.m_value > rhs || lhs == rhs; } +bool operator<(double lhs, const Approx& rhs) { return lhs < rhs.m_value && lhs != rhs; } +bool operator<(const Approx& lhs, double rhs) { return lhs.m_value < rhs && lhs != rhs; } +bool operator>(double lhs, const Approx& rhs) { return lhs > rhs.m_value && lhs != rhs; } +bool operator>(const Approx& lhs, double rhs) { return lhs.m_value > rhs && lhs != rhs; } + +String toString(const Approx& in) { + return "Approx( " + doctest::toString(in.m_value) + " )"; +} +const ContextOptions* getContextOptions() { return DOCTEST_BRANCH_ON_DISABLED(nullptr, g_cs); } + +DOCTEST_MSVC_SUPPRESS_WARNING_WITH_PUSH(4738) +template +IsNaN::operator bool() const { + return std::isnan(value) ^ flipped; +} +DOCTEST_MSVC_SUPPRESS_WARNING_POP +template struct DOCTEST_INTERFACE_DEF IsNaN; +template struct DOCTEST_INTERFACE_DEF IsNaN; +template struct DOCTEST_INTERFACE_DEF IsNaN; +template +String toString(IsNaN in) { return String(in.flipped ? "! " : "") + "IsNaN( " + doctest::toString(in.value) + " )"; } +String toString(IsNaN in) { return toString(in); } +String toString(IsNaN in) { return toString(in); } +String toString(IsNaN in) { return toString(in); } + +} // namespace doctest + +#ifdef DOCTEST_CONFIG_DISABLE +namespace doctest { +Context::Context(int, const char* const*) {} +Context::~Context() = default; +void Context::applyCommandLine(int, const char* const*) {} +void Context::addFilter(const char*, const char*) {} +void Context::clearFilters() {} +void Context::setOption(const char*, bool) {} +void Context::setOption(const char*, int) {} +void Context::setOption(const char*, const char*) {} +bool Context::shouldExit() { return false; } +void Context::setAsDefaultForAssertsOutOfTestCases() {} +void Context::setAssertHandler(detail::assert_handler) {} +void Context::setCout(std::ostream*) {} +int Context::run() { return 0; } + +int IReporter::get_num_active_contexts() { return 0; } +const IContextScope* const* IReporter::get_active_contexts() { return nullptr; } +int IReporter::get_num_stringified_contexts() { return 0; } +const String* IReporter::get_stringified_contexts() { return nullptr; } + +int registerReporter(const char*, int, IReporter*) { return 0; } + +} // namespace doctest +#else // DOCTEST_CONFIG_DISABLE + +#if !defined(DOCTEST_CONFIG_COLORS_NONE) +#if !defined(DOCTEST_CONFIG_COLORS_WINDOWS) && !defined(DOCTEST_CONFIG_COLORS_ANSI) +#ifdef DOCTEST_PLATFORM_WINDOWS +#define DOCTEST_CONFIG_COLORS_WINDOWS +#else // linux +#define DOCTEST_CONFIG_COLORS_ANSI +#endif // platform +#endif // DOCTEST_CONFIG_COLORS_WINDOWS && DOCTEST_CONFIG_COLORS_ANSI +#endif // DOCTEST_CONFIG_COLORS_NONE + +namespace doctest_detail_test_suite_ns { +// holds the current test suite +doctest::detail::TestSuite& getCurrentTestSuite() { + static doctest::detail::TestSuite data{}; + return data; +} +} // namespace doctest_detail_test_suite_ns + +namespace doctest { +namespace { + // the int (priority) is part of the key for automatic sorting - sadly one can register a + // reporter with a duplicate name and a different priority but hopefully that won't happen often :| + using reporterMap = std::map, reporterCreatorFunc>; + + reporterMap& getReporters() { + static reporterMap data; + return data; + } + reporterMap& getListeners() { + static reporterMap data; + return data; + } +} // namespace +namespace detail { +#define DOCTEST_ITERATE_THROUGH_REPORTERS(function, ...) \ + for(auto& curr_rep : g_cs->reporters_currently_used) \ + curr_rep->function(__VA_ARGS__) + + bool checkIfShouldThrow(assertType::Enum at) { + if(at & assertType::is_require) //!OCLINT bitwise operator in conditional + return true; + + if((at & assertType::is_check) //!OCLINT bitwise operator in conditional + && getContextOptions()->abort_after > 0 && + (g_cs->numAssertsFailed + g_cs->numAssertsFailedCurrentTest_atomic) >= + getContextOptions()->abort_after) + return true; + + return false; + } + +#ifndef DOCTEST_CONFIG_NO_EXCEPTIONS + DOCTEST_NORETURN void throwException() { + g_cs->shouldLogCurrentException = false; + throw TestFailureException(); // NOLINT(hicpp-exception-baseclass) + } +#else // DOCTEST_CONFIG_NO_EXCEPTIONS + void throwException() {} +#endif // DOCTEST_CONFIG_NO_EXCEPTIONS +} // namespace detail + +namespace { + using namespace detail; + // matching of a string against a wildcard mask (case sensitivity configurable) taken from + // https://www.codeproject.com/Articles/1088/Wildcard-string-compare-globbing + int wildcmp(const char* str, const char* wild, bool caseSensitive) { + const char* cp = str; + const char* mp = wild; + + while((*str) && (*wild != '*')) { + if((caseSensitive ? (*wild != *str) : (tolower(*wild) != tolower(*str))) && + (*wild != '?')) { + return 0; + } + wild++; + str++; + } + + while(*str) { + if(*wild == '*') { + if(!*++wild) { + return 1; + } + mp = wild; + cp = str + 1; + } else if((caseSensitive ? (*wild == *str) : (tolower(*wild) == tolower(*str))) || + (*wild == '?')) { + wild++; + str++; + } else { + wild = mp; //!OCLINT parameter reassignment + str = cp++; //!OCLINT parameter reassignment + } + } + + while(*wild == '*') { + wild++; + } + return !*wild; + } + + // checks if the name matches any of the filters (and can be configured what to do when empty) + bool matchesAny(const char* name, const std::vector& filters, bool matchEmpty, + bool caseSensitive) { + if (filters.empty() && matchEmpty) + return true; + for (auto& curr : filters) + if (wildcmp(name, curr.c_str(), caseSensitive)) + return true; + return false; + } + + DOCTEST_NO_SANITIZE_INTEGER + unsigned long long hash(unsigned long long a, unsigned long long b) { + return (a << 5) + b; + } + + // C string hash function (djb2) - taken from http://www.cse.yorku.ca/~oz/hash.html + DOCTEST_NO_SANITIZE_INTEGER + unsigned long long hash(const char* str) { + unsigned long long hash = 5381; + char c; + while ((c = *str++)) + hash = ((hash << 5) + hash) + c; // hash * 33 + c + return hash; + } + + unsigned long long hash(const SubcaseSignature& sig) { + return hash(hash(hash(sig.m_file), hash(sig.m_name.c_str())), sig.m_line); + } + + unsigned long long hash(const std::vector& sigs, size_t count) { + unsigned long long running = 0; + auto end = sigs.begin() + count; + for (auto it = sigs.begin(); it != end; it++) { + running = hash(running, hash(*it)); + } + return running; + } + + unsigned long long hash(const std::vector& sigs) { + unsigned long long running = 0; + for (const SubcaseSignature& sig : sigs) { + running = hash(running, hash(sig)); + } + return running; + } +} // namespace +namespace detail { + bool Subcase::checkFilters() { + if (g_cs->subcaseStack.size() < size_t(g_cs->subcase_filter_levels)) { + if (!matchesAny(m_signature.m_name.c_str(), g_cs->filters[6], true, g_cs->case_sensitive)) + return true; + if (matchesAny(m_signature.m_name.c_str(), g_cs->filters[7], false, g_cs->case_sensitive)) + return true; + } + return false; + } + + Subcase::Subcase(const String& name, const char* file, int line) + : m_signature({name, file, line}) { + if (!g_cs->reachedLeaf) { + if (g_cs->nextSubcaseStack.size() <= g_cs->subcaseStack.size() + || g_cs->nextSubcaseStack[g_cs->subcaseStack.size()] == m_signature) { + // Going down. + if (checkFilters()) { return; } + + g_cs->subcaseStack.push_back(m_signature); + g_cs->currentSubcaseDepth++; + m_entered = true; + DOCTEST_ITERATE_THROUGH_REPORTERS(subcase_start, m_signature); + } + } else { + if (g_cs->subcaseStack[g_cs->currentSubcaseDepth] == m_signature) { + // This subcase is reentered via control flow. + g_cs->currentSubcaseDepth++; + m_entered = true; + DOCTEST_ITERATE_THROUGH_REPORTERS(subcase_start, m_signature); + } else if (g_cs->nextSubcaseStack.size() <= g_cs->currentSubcaseDepth + && g_cs->fullyTraversedSubcases.find(hash(hash(g_cs->subcaseStack, g_cs->currentSubcaseDepth), hash(m_signature))) + == g_cs->fullyTraversedSubcases.end()) { + if (checkFilters()) { return; } + // This subcase is part of the one to be executed next. + g_cs->nextSubcaseStack.clear(); + g_cs->nextSubcaseStack.insert(g_cs->nextSubcaseStack.end(), + g_cs->subcaseStack.begin(), g_cs->subcaseStack.begin() + g_cs->currentSubcaseDepth); + g_cs->nextSubcaseStack.push_back(m_signature); + } + } + } + + DOCTEST_MSVC_SUPPRESS_WARNING_WITH_PUSH(4996) // std::uncaught_exception is deprecated in C++17 + DOCTEST_GCC_SUPPRESS_WARNING_WITH_PUSH("-Wdeprecated-declarations") + DOCTEST_CLANG_SUPPRESS_WARNING_WITH_PUSH("-Wdeprecated-declarations") + + Subcase::~Subcase() { + if (m_entered) { + g_cs->currentSubcaseDepth--; + + if (!g_cs->reachedLeaf) { + // Leaf. + g_cs->fullyTraversedSubcases.insert(hash(g_cs->subcaseStack)); + g_cs->nextSubcaseStack.clear(); + g_cs->reachedLeaf = true; + } else if (g_cs->nextSubcaseStack.empty()) { + // All children are finished. + g_cs->fullyTraversedSubcases.insert(hash(g_cs->subcaseStack)); + } + +#if defined(__cpp_lib_uncaught_exceptions) && __cpp_lib_uncaught_exceptions >= 201411L && (!defined(__MAC_OS_X_VERSION_MIN_REQUIRED) || __MAC_OS_X_VERSION_MIN_REQUIRED >= 101200) + if(std::uncaught_exceptions() > 0 +#else + if(std::uncaught_exception() +#endif + && g_cs->shouldLogCurrentException) { + DOCTEST_ITERATE_THROUGH_REPORTERS( + test_case_exception, {"exception thrown in subcase - will translate later " + "when the whole test case has been exited (cannot " + "translate while there is an active exception)", + false}); + g_cs->shouldLogCurrentException = false; + } + + DOCTEST_ITERATE_THROUGH_REPORTERS(subcase_end, DOCTEST_EMPTY); + } + } + + DOCTEST_CLANG_SUPPRESS_WARNING_POP + DOCTEST_GCC_SUPPRESS_WARNING_POP + DOCTEST_MSVC_SUPPRESS_WARNING_POP + + Subcase::operator bool() const { return m_entered; } + + Result::Result(bool passed, const String& decomposition) + : m_passed(passed) + , m_decomp(decomposition) {} + + ExpressionDecomposer::ExpressionDecomposer(assertType::Enum at) + : m_at(at) {} + + TestSuite& TestSuite::operator*(const char* in) { + m_test_suite = in; + return *this; + } + + TestCase::TestCase(funcType test, const char* file, unsigned line, const TestSuite& test_suite, + const String& type, int template_id) { + m_file = file; + m_line = line; + m_name = nullptr; // will be later overridden in operator* + m_test_suite = test_suite.m_test_suite; + m_description = test_suite.m_description; + m_skip = test_suite.m_skip; + m_no_breaks = test_suite.m_no_breaks; + m_no_output = test_suite.m_no_output; + m_may_fail = test_suite.m_may_fail; + m_should_fail = test_suite.m_should_fail; + m_expected_failures = test_suite.m_expected_failures; + m_timeout = test_suite.m_timeout; + + m_test = test; + m_type = type; + m_template_id = template_id; + } + + TestCase::TestCase(const TestCase& other) + : TestCaseData() { + *this = other; + } + + DOCTEST_MSVC_SUPPRESS_WARNING_WITH_PUSH(26434) // hides a non-virtual function + TestCase& TestCase::operator=(const TestCase& other) { + TestCaseData::operator=(other); + m_test = other.m_test; + m_type = other.m_type; + m_template_id = other.m_template_id; + m_full_name = other.m_full_name; + + if(m_template_id != -1) + m_name = m_full_name.c_str(); + return *this; + } + DOCTEST_MSVC_SUPPRESS_WARNING_POP + + TestCase& TestCase::operator*(const char* in) { + m_name = in; + // make a new name with an appended type for templated test case + if(m_template_id != -1) { + m_full_name = String(m_name) + "<" + m_type + ">"; + // redirect the name to point to the newly constructed full name + m_name = m_full_name.c_str(); + } + return *this; + } + + bool TestCase::operator<(const TestCase& other) const { + // this will be used only to differentiate between test cases - not relevant for sorting + if(m_line != other.m_line) + return m_line < other.m_line; + const int name_cmp = strcmp(m_name, other.m_name); + if(name_cmp != 0) + return name_cmp < 0; + const int file_cmp = m_file.compare(other.m_file); + if(file_cmp != 0) + return file_cmp < 0; + return m_template_id < other.m_template_id; + } + + // all the registered tests + std::set& getRegisteredTests() { + static std::set data; + return data; + } +} // namespace detail +namespace { + using namespace detail; + // for sorting tests by file/line + bool fileOrderComparator(const TestCase* lhs, const TestCase* rhs) { + // this is needed because MSVC gives different case for drive letters + // for __FILE__ when evaluated in a header and a source file + const int res = lhs->m_file.compare(rhs->m_file, bool(DOCTEST_MSVC)); + if(res != 0) + return res < 0; + if(lhs->m_line != rhs->m_line) + return lhs->m_line < rhs->m_line; + return lhs->m_template_id < rhs->m_template_id; + } + + // for sorting tests by suite/file/line + bool suiteOrderComparator(const TestCase* lhs, const TestCase* rhs) { + const int res = std::strcmp(lhs->m_test_suite, rhs->m_test_suite); + if(res != 0) + return res < 0; + return fileOrderComparator(lhs, rhs); + } + + // for sorting tests by name/suite/file/line + bool nameOrderComparator(const TestCase* lhs, const TestCase* rhs) { + const int res = std::strcmp(lhs->m_name, rhs->m_name); + if(res != 0) + return res < 0; + return suiteOrderComparator(lhs, rhs); + } + + DOCTEST_CLANG_SUPPRESS_WARNING_WITH_PUSH("-Wdeprecated-declarations") + void color_to_stream(std::ostream& s, Color::Enum code) { + static_cast(s); // for DOCTEST_CONFIG_COLORS_NONE or DOCTEST_CONFIG_COLORS_WINDOWS + static_cast(code); // for DOCTEST_CONFIG_COLORS_NONE +#ifdef DOCTEST_CONFIG_COLORS_ANSI + if(g_no_colors || + (isatty(STDOUT_FILENO) == false && getContextOptions()->force_colors == false)) + return; + + auto col = ""; + // clang-format off + switch(code) { //!OCLINT missing break in switch statement / unnecessary default statement in covered switch statement + case Color::Red: col = "[0;31m"; break; + case Color::Green: col = "[0;32m"; break; + case Color::Blue: col = "[0;34m"; break; + case Color::Cyan: col = "[0;36m"; break; + case Color::Yellow: col = "[0;33m"; break; + case Color::Grey: col = "[1;30m"; break; + case Color::LightGrey: col = "[0;37m"; break; + case Color::BrightRed: col = "[1;31m"; break; + case Color::BrightGreen: col = "[1;32m"; break; + case Color::BrightWhite: col = "[1;37m"; break; + case Color::Bright: // invalid + case Color::None: + case Color::White: + default: col = "[0m"; + } + // clang-format on + s << "\033" << col; +#endif // DOCTEST_CONFIG_COLORS_ANSI + +#ifdef DOCTEST_CONFIG_COLORS_WINDOWS + if(g_no_colors || + (_isatty(_fileno(stdout)) == false && getContextOptions()->force_colors == false)) + return; + + static struct ConsoleHelper { + HANDLE stdoutHandle; + WORD origFgAttrs; + WORD origBgAttrs; + + ConsoleHelper() { + stdoutHandle = GetStdHandle(STD_OUTPUT_HANDLE); + CONSOLE_SCREEN_BUFFER_INFO csbiInfo; + GetConsoleScreenBufferInfo(stdoutHandle, &csbiInfo); + origFgAttrs = csbiInfo.wAttributes & ~(BACKGROUND_GREEN | BACKGROUND_RED | + BACKGROUND_BLUE | BACKGROUND_INTENSITY); + origBgAttrs = csbiInfo.wAttributes & ~(FOREGROUND_GREEN | FOREGROUND_RED | + FOREGROUND_BLUE | FOREGROUND_INTENSITY); + } + } ch; + +#define DOCTEST_SET_ATTR(x) SetConsoleTextAttribute(ch.stdoutHandle, x | ch.origBgAttrs) + + // clang-format off + switch (code) { + case Color::White: DOCTEST_SET_ATTR(FOREGROUND_GREEN | FOREGROUND_RED | FOREGROUND_BLUE); break; + case Color::Red: DOCTEST_SET_ATTR(FOREGROUND_RED); break; + case Color::Green: DOCTEST_SET_ATTR(FOREGROUND_GREEN); break; + case Color::Blue: DOCTEST_SET_ATTR(FOREGROUND_BLUE); break; + case Color::Cyan: DOCTEST_SET_ATTR(FOREGROUND_BLUE | FOREGROUND_GREEN); break; + case Color::Yellow: DOCTEST_SET_ATTR(FOREGROUND_RED | FOREGROUND_GREEN); break; + case Color::Grey: DOCTEST_SET_ATTR(0); break; + case Color::LightGrey: DOCTEST_SET_ATTR(FOREGROUND_INTENSITY); break; + case Color::BrightRed: DOCTEST_SET_ATTR(FOREGROUND_INTENSITY | FOREGROUND_RED); break; + case Color::BrightGreen: DOCTEST_SET_ATTR(FOREGROUND_INTENSITY | FOREGROUND_GREEN); break; + case Color::BrightWhite: DOCTEST_SET_ATTR(FOREGROUND_INTENSITY | FOREGROUND_GREEN | FOREGROUND_RED | FOREGROUND_BLUE); break; + case Color::None: + case Color::Bright: // invalid + default: DOCTEST_SET_ATTR(ch.origFgAttrs); + } + // clang-format on +#endif // DOCTEST_CONFIG_COLORS_WINDOWS + } + DOCTEST_CLANG_SUPPRESS_WARNING_POP + + std::vector& getExceptionTranslators() { + static std::vector data; + return data; + } + + String translateActiveException() { +#ifndef DOCTEST_CONFIG_NO_EXCEPTIONS + String res; + auto& translators = getExceptionTranslators(); + for(auto& curr : translators) + if(curr->translate(res)) + return res; + // clang-format off + DOCTEST_GCC_SUPPRESS_WARNING_WITH_PUSH("-Wcatch-value") + try { + throw; + } catch(std::exception& ex) { + return ex.what(); + } catch(std::string& msg) { + return msg.c_str(); + } catch(const char* msg) { + return msg; + } catch(...) { + return "unknown exception"; + } + DOCTEST_GCC_SUPPRESS_WARNING_POP +// clang-format on +#else // DOCTEST_CONFIG_NO_EXCEPTIONS + return ""; +#endif // DOCTEST_CONFIG_NO_EXCEPTIONS + } +} // namespace + +namespace detail { + // used by the macros for registering tests + int regTest(const TestCase& tc) { + getRegisteredTests().insert(tc); + return 0; + } + + // sets the current test suite + int setTestSuite(const TestSuite& ts) { + doctest_detail_test_suite_ns::getCurrentTestSuite() = ts; + return 0; + } + +#ifdef DOCTEST_IS_DEBUGGER_ACTIVE + bool isDebuggerActive() { return DOCTEST_IS_DEBUGGER_ACTIVE(); } +#else // DOCTEST_IS_DEBUGGER_ACTIVE +#ifdef DOCTEST_PLATFORM_LINUX + class ErrnoGuard { + public: + ErrnoGuard() : m_oldErrno(errno) {} + ~ErrnoGuard() { errno = m_oldErrno; } + private: + int m_oldErrno; + }; + // See the comments in Catch2 for the reasoning behind this implementation: + // https://github.com/catchorg/Catch2/blob/v2.13.1/include/internal/catch_debugger.cpp#L79-L102 + bool isDebuggerActive() { + ErrnoGuard guard; + std::ifstream in("/proc/self/status"); + for(std::string line; std::getline(in, line);) { + static const int PREFIX_LEN = 11; + if(line.compare(0, PREFIX_LEN, "TracerPid:\t") == 0) { + return line.length() > PREFIX_LEN && line[PREFIX_LEN] != '0'; + } + } + return false; + } +#elif defined(DOCTEST_PLATFORM_MAC) + // The following function is taken directly from the following technical note: + // https://developer.apple.com/library/archive/qa/qa1361/_index.html + // Returns true if the current process is being debugged (either + // running under the debugger or has a debugger attached post facto). + bool isDebuggerActive() { + int mib[4]; + kinfo_proc info; + size_t size; + // Initialize the flags so that, if sysctl fails for some bizarre + // reason, we get a predictable result. + info.kp_proc.p_flag = 0; + // Initialize mib, which tells sysctl the info we want, in this case + // we're looking for information about a specific process ID. + mib[0] = CTL_KERN; + mib[1] = KERN_PROC; + mib[2] = KERN_PROC_PID; + mib[3] = getpid(); + // Call sysctl. + size = sizeof(info); + if(sysctl(mib, DOCTEST_COUNTOF(mib), &info, &size, 0, 0) != 0) { + std::cerr << "\nCall to sysctl failed - unable to determine if debugger is active **\n"; + return false; + } + // We're being debugged if the P_TRACED flag is set. + return ((info.kp_proc.p_flag & P_TRACED) != 0); + } +#elif DOCTEST_MSVC || defined(__MINGW32__) || defined(__MINGW64__) + bool isDebuggerActive() { return ::IsDebuggerPresent() != 0; } +#else + bool isDebuggerActive() { return false; } +#endif // Platform +#endif // DOCTEST_IS_DEBUGGER_ACTIVE + + void registerExceptionTranslatorImpl(const IExceptionTranslator* et) { + if(std::find(getExceptionTranslators().begin(), getExceptionTranslators().end(), et) == + getExceptionTranslators().end()) + getExceptionTranslators().push_back(et); + } + + DOCTEST_THREAD_LOCAL std::vector g_infoContexts; // for logging with INFO() + + ContextScopeBase::ContextScopeBase() { + g_infoContexts.push_back(this); + } + + ContextScopeBase::ContextScopeBase(ContextScopeBase&& other) noexcept { + if (other.need_to_destroy) { + other.destroy(); + } + other.need_to_destroy = false; + g_infoContexts.push_back(this); + } + + DOCTEST_MSVC_SUPPRESS_WARNING_WITH_PUSH(4996) // std::uncaught_exception is deprecated in C++17 + DOCTEST_GCC_SUPPRESS_WARNING_WITH_PUSH("-Wdeprecated-declarations") + DOCTEST_CLANG_SUPPRESS_WARNING_WITH_PUSH("-Wdeprecated-declarations") + + // destroy cannot be inlined into the destructor because that would mean calling stringify after + // ContextScope has been destroyed (base class destructors run after derived class destructors). + // Instead, ContextScope calls this method directly from its destructor. + void ContextScopeBase::destroy() { +#if defined(__cpp_lib_uncaught_exceptions) && __cpp_lib_uncaught_exceptions >= 201411L && (!defined(__MAC_OS_X_VERSION_MIN_REQUIRED) || __MAC_OS_X_VERSION_MIN_REQUIRED >= 101200) + if(std::uncaught_exceptions() > 0) { +#else + if(std::uncaught_exception()) { +#endif + std::ostringstream s; + this->stringify(&s); + g_cs->stringifiedContexts.push_back(s.str().c_str()); + } + g_infoContexts.pop_back(); + } + + DOCTEST_CLANG_SUPPRESS_WARNING_POP + DOCTEST_GCC_SUPPRESS_WARNING_POP + DOCTEST_MSVC_SUPPRESS_WARNING_POP +} // namespace detail +namespace { + using namespace detail; + +#if !defined(DOCTEST_CONFIG_POSIX_SIGNALS) && !defined(DOCTEST_CONFIG_WINDOWS_SEH) + struct FatalConditionHandler + { + static void reset() {} + static void allocateAltStackMem() {} + static void freeAltStackMem() {} + }; +#else // DOCTEST_CONFIG_POSIX_SIGNALS || DOCTEST_CONFIG_WINDOWS_SEH + + void reportFatal(const std::string&); + +#ifdef DOCTEST_PLATFORM_WINDOWS + + struct SignalDefs + { + DWORD id; + const char* name; + }; + // There is no 1-1 mapping between signals and windows exceptions. + // Windows can easily distinguish between SO and SigSegV, + // but SigInt, SigTerm, etc are handled differently. + SignalDefs signalDefs[] = { + {static_cast(EXCEPTION_ILLEGAL_INSTRUCTION), + "SIGILL - Illegal instruction signal"}, + {static_cast(EXCEPTION_STACK_OVERFLOW), "SIGSEGV - Stack overflow"}, + {static_cast(EXCEPTION_ACCESS_VIOLATION), + "SIGSEGV - Segmentation violation signal"}, + {static_cast(EXCEPTION_INT_DIVIDE_BY_ZERO), "Divide by zero error"}, + }; + + struct FatalConditionHandler + { + static LONG CALLBACK handleException(PEXCEPTION_POINTERS ExceptionInfo) { + // Multiple threads may enter this filter/handler at once. We want the error message to be printed on the + // console just once no matter how many threads have crashed. + DOCTEST_DECLARE_STATIC_MUTEX(mutex) + static bool execute = true; + { + DOCTEST_LOCK_MUTEX(mutex) + if(execute) { + bool reported = false; + for(size_t i = 0; i < DOCTEST_COUNTOF(signalDefs); ++i) { + if(ExceptionInfo->ExceptionRecord->ExceptionCode == signalDefs[i].id) { + reportFatal(signalDefs[i].name); + reported = true; + break; + } + } + if(reported == false) + reportFatal("Unhandled SEH exception caught"); + if(isDebuggerActive() && !g_cs->no_breaks) + DOCTEST_BREAK_INTO_DEBUGGER(); + } + execute = false; + } + std::exit(EXIT_FAILURE); + } + + static void allocateAltStackMem() {} + static void freeAltStackMem() {} + + FatalConditionHandler() { + isSet = true; + // 32k seems enough for doctest to handle stack overflow, + // but the value was found experimentally, so there is no strong guarantee + guaranteeSize = 32 * 1024; + // Register an unhandled exception filter + previousTop = SetUnhandledExceptionFilter(handleException); + // Pass in guarantee size to be filled + SetThreadStackGuarantee(&guaranteeSize); + + // On Windows uncaught exceptions from another thread, exceptions from + // destructors, or calls to std::terminate are not a SEH exception + + // The terminal handler gets called when: + // - std::terminate is called FROM THE TEST RUNNER THREAD + // - an exception is thrown from a destructor FROM THE TEST RUNNER THREAD + original_terminate_handler = std::get_terminate(); + std::set_terminate([]() DOCTEST_NOEXCEPT { + reportFatal("Terminate handler called"); + if(isDebuggerActive() && !g_cs->no_breaks) + DOCTEST_BREAK_INTO_DEBUGGER(); + std::exit(EXIT_FAILURE); // explicitly exit - otherwise the SIGABRT handler may be called as well + }); + + // SIGABRT is raised when: + // - std::terminate is called FROM A DIFFERENT THREAD + // - an exception is thrown from a destructor FROM A DIFFERENT THREAD + // - an uncaught exception is thrown FROM A DIFFERENT THREAD + prev_sigabrt_handler = std::signal(SIGABRT, [](int signal) DOCTEST_NOEXCEPT { + if(signal == SIGABRT) { + reportFatal("SIGABRT - Abort (abnormal termination) signal"); + if(isDebuggerActive() && !g_cs->no_breaks) + DOCTEST_BREAK_INTO_DEBUGGER(); + std::exit(EXIT_FAILURE); + } + }); + + // The following settings are taken from google test, and more + // specifically from UnitTest::Run() inside of gtest.cc + + // the user does not want to see pop-up dialogs about crashes + prev_error_mode_1 = SetErrorMode(SEM_FAILCRITICALERRORS | SEM_NOALIGNMENTFAULTEXCEPT | + SEM_NOGPFAULTERRORBOX | SEM_NOOPENFILEERRORBOX); + // This forces the abort message to go to stderr in all circumstances. + prev_error_mode_2 = _set_error_mode(_OUT_TO_STDERR); + // In the debug version, Visual Studio pops up a separate dialog + // offering a choice to debug the aborted program - we want to disable that. + prev_abort_behavior = _set_abort_behavior(0x0, _WRITE_ABORT_MSG | _CALL_REPORTFAULT); + // In debug mode, the Windows CRT can crash with an assertion over invalid + // input (e.g. passing an invalid file descriptor). The default handling + // for these assertions is to pop up a dialog and wait for user input. + // Instead ask the CRT to dump such assertions to stderr non-interactively. + prev_report_mode = _CrtSetReportMode(_CRT_ASSERT, _CRTDBG_MODE_FILE | _CRTDBG_MODE_DEBUG); + prev_report_file = _CrtSetReportFile(_CRT_ASSERT, _CRTDBG_FILE_STDERR); + } + + static void reset() { + if(isSet) { + // Unregister handler and restore the old guarantee + SetUnhandledExceptionFilter(previousTop); + SetThreadStackGuarantee(&guaranteeSize); + std::set_terminate(original_terminate_handler); + std::signal(SIGABRT, prev_sigabrt_handler); + SetErrorMode(prev_error_mode_1); + _set_error_mode(prev_error_mode_2); + _set_abort_behavior(prev_abort_behavior, _WRITE_ABORT_MSG | _CALL_REPORTFAULT); + static_cast(_CrtSetReportMode(_CRT_ASSERT, prev_report_mode)); + static_cast(_CrtSetReportFile(_CRT_ASSERT, prev_report_file)); + isSet = false; + } + } + + ~FatalConditionHandler() { reset(); } + + private: + static UINT prev_error_mode_1; + static int prev_error_mode_2; + static unsigned int prev_abort_behavior; + static int prev_report_mode; + static _HFILE prev_report_file; + static void (DOCTEST_CDECL *prev_sigabrt_handler)(int); + static std::terminate_handler original_terminate_handler; + static bool isSet; + static ULONG guaranteeSize; + static LPTOP_LEVEL_EXCEPTION_FILTER previousTop; + }; + + UINT FatalConditionHandler::prev_error_mode_1; + int FatalConditionHandler::prev_error_mode_2; + unsigned int FatalConditionHandler::prev_abort_behavior; + int FatalConditionHandler::prev_report_mode; + _HFILE FatalConditionHandler::prev_report_file; + void (DOCTEST_CDECL *FatalConditionHandler::prev_sigabrt_handler)(int); + std::terminate_handler FatalConditionHandler::original_terminate_handler; + bool FatalConditionHandler::isSet = false; + ULONG FatalConditionHandler::guaranteeSize = 0; + LPTOP_LEVEL_EXCEPTION_FILTER FatalConditionHandler::previousTop = nullptr; + +#else // DOCTEST_PLATFORM_WINDOWS + + struct SignalDefs + { + int id; + const char* name; + }; + SignalDefs signalDefs[] = {{SIGINT, "SIGINT - Terminal interrupt signal"}, + {SIGILL, "SIGILL - Illegal instruction signal"}, + {SIGFPE, "SIGFPE - Floating point error signal"}, + {SIGSEGV, "SIGSEGV - Segmentation violation signal"}, + {SIGTERM, "SIGTERM - Termination request signal"}, + {SIGABRT, "SIGABRT - Abort (abnormal termination) signal"}}; + + struct FatalConditionHandler + { + static bool isSet; + static struct sigaction oldSigActions[DOCTEST_COUNTOF(signalDefs)]; + static stack_t oldSigStack; + static size_t altStackSize; + static char* altStackMem; + + static void handleSignal(int sig) { + const char* name = ""; + for(std::size_t i = 0; i < DOCTEST_COUNTOF(signalDefs); ++i) { + SignalDefs& def = signalDefs[i]; + if(sig == def.id) { + name = def.name; + break; + } + } + reset(); + reportFatal(name); + raise(sig); + } + + static void allocateAltStackMem() { + altStackMem = new char[altStackSize]; + } + + static void freeAltStackMem() { + delete[] altStackMem; + } + + FatalConditionHandler() { + isSet = true; + stack_t sigStack; + sigStack.ss_sp = altStackMem; + sigStack.ss_size = altStackSize; + sigStack.ss_flags = 0; + sigaltstack(&sigStack, &oldSigStack); + struct sigaction sa = {}; + sa.sa_handler = handleSignal; + sa.sa_flags = SA_ONSTACK; + for(std::size_t i = 0; i < DOCTEST_COUNTOF(signalDefs); ++i) { + sigaction(signalDefs[i].id, &sa, &oldSigActions[i]); + } + } + + ~FatalConditionHandler() { reset(); } + static void reset() { + if(isSet) { + // Set signals back to previous values -- hopefully nobody overwrote them in the meantime + for(std::size_t i = 0; i < DOCTEST_COUNTOF(signalDefs); ++i) { + sigaction(signalDefs[i].id, &oldSigActions[i], nullptr); + } + // Return the old stack + sigaltstack(&oldSigStack, nullptr); + isSet = false; + } + } + }; + + bool FatalConditionHandler::isSet = false; + struct sigaction FatalConditionHandler::oldSigActions[DOCTEST_COUNTOF(signalDefs)] = {}; + stack_t FatalConditionHandler::oldSigStack = {}; + size_t FatalConditionHandler::altStackSize = 4 * SIGSTKSZ; + char* FatalConditionHandler::altStackMem = nullptr; + +#endif // DOCTEST_PLATFORM_WINDOWS +#endif // DOCTEST_CONFIG_POSIX_SIGNALS || DOCTEST_CONFIG_WINDOWS_SEH + +} // namespace + +namespace { + using namespace detail; + +#ifdef DOCTEST_PLATFORM_WINDOWS +#define DOCTEST_OUTPUT_DEBUG_STRING(text) ::OutputDebugStringA(text) +#else + // TODO: integration with XCode and other IDEs +#define DOCTEST_OUTPUT_DEBUG_STRING(text) +#endif // Platform + + void addAssert(assertType::Enum at) { + if((at & assertType::is_warn) == 0) //!OCLINT bitwise operator in conditional + g_cs->numAssertsCurrentTest_atomic++; + } + + void addFailedAssert(assertType::Enum at) { + if((at & assertType::is_warn) == 0) //!OCLINT bitwise operator in conditional + g_cs->numAssertsFailedCurrentTest_atomic++; + } + +#if defined(DOCTEST_CONFIG_POSIX_SIGNALS) || defined(DOCTEST_CONFIG_WINDOWS_SEH) + void reportFatal(const std::string& message) { + g_cs->failure_flags |= TestCaseFailureReason::Crash; + + DOCTEST_ITERATE_THROUGH_REPORTERS(test_case_exception, {message.c_str(), true}); + + while (g_cs->subcaseStack.size()) { + g_cs->subcaseStack.pop_back(); + DOCTEST_ITERATE_THROUGH_REPORTERS(subcase_end, DOCTEST_EMPTY); + } + + g_cs->finalizeTestCaseData(); + + DOCTEST_ITERATE_THROUGH_REPORTERS(test_case_end, *g_cs); + + DOCTEST_ITERATE_THROUGH_REPORTERS(test_run_end, *g_cs); + } +#endif // DOCTEST_CONFIG_POSIX_SIGNALS || DOCTEST_CONFIG_WINDOWS_SEH +} // namespace + +AssertData::AssertData(assertType::Enum at, const char* file, int line, const char* expr, + const char* exception_type, const StringContains& exception_string) + : m_test_case(g_cs->currentTest), m_at(at), m_file(file), m_line(line), m_expr(expr), + m_failed(true), m_threw(false), m_threw_as(false), m_exception_type(exception_type), + m_exception_string(exception_string) { +#if DOCTEST_MSVC + if (m_expr[0] == ' ') // this happens when variadic macros are disabled under MSVC + ++m_expr; +#endif // MSVC +} + +namespace detail { + ResultBuilder::ResultBuilder(assertType::Enum at, const char* file, int line, const char* expr, + const char* exception_type, const String& exception_string) + : AssertData(at, file, line, expr, exception_type, exception_string) { } + + ResultBuilder::ResultBuilder(assertType::Enum at, const char* file, int line, const char* expr, + const char* exception_type, const Contains& exception_string) + : AssertData(at, file, line, expr, exception_type, exception_string) { } + + void ResultBuilder::setResult(const Result& res) { + m_decomp = res.m_decomp; + m_failed = !res.m_passed; + } + + void ResultBuilder::translateException() { + m_threw = true; + m_exception = translateActiveException(); + } + + bool ResultBuilder::log() { + if(m_at & assertType::is_throws) { //!OCLINT bitwise operator in conditional + m_failed = !m_threw; + } else if((m_at & assertType::is_throws_as) && (m_at & assertType::is_throws_with)) { //!OCLINT + m_failed = !m_threw_as || !m_exception_string.check(m_exception); + } else if(m_at & assertType::is_throws_as) { //!OCLINT bitwise operator in conditional + m_failed = !m_threw_as; + } else if(m_at & assertType::is_throws_with) { //!OCLINT bitwise operator in conditional + m_failed = !m_exception_string.check(m_exception); + } else if(m_at & assertType::is_nothrow) { //!OCLINT bitwise operator in conditional + m_failed = m_threw; + } + + if(m_exception.size()) + m_exception = "\"" + m_exception + "\""; + + if(is_running_in_test) { + addAssert(m_at); + DOCTEST_ITERATE_THROUGH_REPORTERS(log_assert, *this); + + if(m_failed) + addFailedAssert(m_at); + } else if(m_failed) { + failed_out_of_a_testing_context(*this); + } + + return m_failed && isDebuggerActive() && !getContextOptions()->no_breaks && + (g_cs->currentTest == nullptr || !g_cs->currentTest->m_no_breaks); // break into debugger + } + + void ResultBuilder::react() const { + if(m_failed && checkIfShouldThrow(m_at)) + throwException(); + } + + void failed_out_of_a_testing_context(const AssertData& ad) { + if(g_cs->ah) + g_cs->ah(ad); + else + std::abort(); + } + + bool decomp_assert(assertType::Enum at, const char* file, int line, const char* expr, + const Result& result) { + bool failed = !result.m_passed; + + // ################################################################################### + // IF THE DEBUGGER BREAKS HERE - GO 1 LEVEL UP IN THE CALLSTACK FOR THE FAILING ASSERT + // THIS IS THE EFFECT OF HAVING 'DOCTEST_CONFIG_SUPER_FAST_ASSERTS' DEFINED + // ################################################################################### + DOCTEST_ASSERT_OUT_OF_TESTS(result.m_decomp); + DOCTEST_ASSERT_IN_TESTS(result.m_decomp); + return !failed; + } + + MessageBuilder::MessageBuilder(const char* file, int line, assertType::Enum severity) { + m_stream = tlssPush(); + m_file = file; + m_line = line; + m_severity = severity; + } + + MessageBuilder::~MessageBuilder() { + if (!logged) + tlssPop(); + } + + DOCTEST_DEFINE_INTERFACE(IExceptionTranslator) + + bool MessageBuilder::log() { + if (!logged) { + m_string = tlssPop(); + logged = true; + } + + DOCTEST_ITERATE_THROUGH_REPORTERS(log_message, *this); + + const bool isWarn = m_severity & assertType::is_warn; + + // warn is just a message in this context so we don't treat it as an assert + if(!isWarn) { + addAssert(m_severity); + addFailedAssert(m_severity); + } + + return isDebuggerActive() && !getContextOptions()->no_breaks && !isWarn && + (g_cs->currentTest == nullptr || !g_cs->currentTest->m_no_breaks); // break into debugger + } + + void MessageBuilder::react() { + if(m_severity & assertType::is_require) //!OCLINT bitwise operator in conditional + throwException(); + } +} // namespace detail +namespace { + using namespace detail; + + // clang-format off + +// ================================================================================================= +// The following code has been taken verbatim from Catch2/include/internal/catch_xmlwriter.h/cpp +// This is done so cherry-picking bug fixes is trivial - even the style/formatting is untouched. +// ================================================================================================= + + class XmlEncode { + public: + enum ForWhat { ForTextNodes, ForAttributes }; + + XmlEncode( std::string const& str, ForWhat forWhat = ForTextNodes ); + + void encodeTo( std::ostream& os ) const; + + friend std::ostream& operator << ( std::ostream& os, XmlEncode const& xmlEncode ); + + private: + std::string m_str; + ForWhat m_forWhat; + }; + + class XmlWriter { + public: + + class ScopedElement { + public: + ScopedElement( XmlWriter* writer ); + + ScopedElement( ScopedElement&& other ) DOCTEST_NOEXCEPT; + ScopedElement& operator=( ScopedElement&& other ) DOCTEST_NOEXCEPT; + + ~ScopedElement(); + + ScopedElement& writeText( std::string const& text, bool indent = true ); + + template + ScopedElement& writeAttribute( std::string const& name, T const& attribute ) { + m_writer->writeAttribute( name, attribute ); + return *this; + } + + private: + mutable XmlWriter* m_writer = nullptr; + }; + +#ifndef DOCTEST_CONFIG_NO_INCLUDE_IOSTREAM + XmlWriter( std::ostream& os = std::cout ); +#else // DOCTEST_CONFIG_NO_INCLUDE_IOSTREAM + XmlWriter( std::ostream& os ); +#endif // DOCTEST_CONFIG_NO_INCLUDE_IOSTREAM + ~XmlWriter(); + + XmlWriter( XmlWriter const& ) = delete; + XmlWriter& operator=( XmlWriter const& ) = delete; + + XmlWriter& startElement( std::string const& name ); + + ScopedElement scopedElement( std::string const& name ); + + XmlWriter& endElement(); + + XmlWriter& writeAttribute( std::string const& name, std::string const& attribute ); + + XmlWriter& writeAttribute( std::string const& name, const char* attribute ); + + XmlWriter& writeAttribute( std::string const& name, bool attribute ); + + template + XmlWriter& writeAttribute( std::string const& name, T const& attribute ) { + std::stringstream rss; + rss << attribute; + return writeAttribute( name, rss.str() ); + } + + XmlWriter& writeText( std::string const& text, bool indent = true ); + + //XmlWriter& writeComment( std::string const& text ); + + //void writeStylesheetRef( std::string const& url ); + + //XmlWriter& writeBlankLine(); + + void ensureTagClosed(); + + void writeDeclaration(); + + private: + + void newlineIfNecessary(); + + bool m_tagIsOpen = false; + bool m_needsNewline = false; + std::vector m_tags; + std::string m_indent; + std::ostream& m_os; + }; + +// ================================================================================================= +// The following code has been taken verbatim from Catch2/include/internal/catch_xmlwriter.h/cpp +// This is done so cherry-picking bug fixes is trivial - even the style/formatting is untouched. +// ================================================================================================= + +using uchar = unsigned char; + +namespace { + + size_t trailingBytes(unsigned char c) { + if ((c & 0xE0) == 0xC0) { + return 2; + } + if ((c & 0xF0) == 0xE0) { + return 3; + } + if ((c & 0xF8) == 0xF0) { + return 4; + } + DOCTEST_INTERNAL_ERROR("Invalid multibyte utf-8 start byte encountered"); + } + + uint32_t headerValue(unsigned char c) { + if ((c & 0xE0) == 0xC0) { + return c & 0x1F; + } + if ((c & 0xF0) == 0xE0) { + return c & 0x0F; + } + if ((c & 0xF8) == 0xF0) { + return c & 0x07; + } + DOCTEST_INTERNAL_ERROR("Invalid multibyte utf-8 start byte encountered"); + } + + void hexEscapeChar(std::ostream& os, unsigned char c) { + std::ios_base::fmtflags f(os.flags()); + os << "\\x" + << std::uppercase << std::hex << std::setfill('0') << std::setw(2) + << static_cast(c); + os.flags(f); + } + +} // anonymous namespace + + XmlEncode::XmlEncode( std::string const& str, ForWhat forWhat ) + : m_str( str ), + m_forWhat( forWhat ) + {} + + void XmlEncode::encodeTo( std::ostream& os ) const { + // Apostrophe escaping not necessary if we always use " to write attributes + // (see: https://www.w3.org/TR/xml/#syntax) + + for( std::size_t idx = 0; idx < m_str.size(); ++ idx ) { + uchar c = m_str[idx]; + switch (c) { + case '<': os << "<"; break; + case '&': os << "&"; break; + + case '>': + // See: https://www.w3.org/TR/xml/#syntax + if (idx > 2 && m_str[idx - 1] == ']' && m_str[idx - 2] == ']') + os << ">"; + else + os << c; + break; + + case '\"': + if (m_forWhat == ForAttributes) + os << """; + else + os << c; + break; + + default: + // Check for control characters and invalid utf-8 + + // Escape control characters in standard ascii + // see https://stackoverflow.com/questions/404107/why-are-control-characters-illegal-in-xml-1-0 + if (c < 0x09 || (c > 0x0D && c < 0x20) || c == 0x7F) { + hexEscapeChar(os, c); + break; + } + + // Plain ASCII: Write it to stream + if (c < 0x7F) { + os << c; + break; + } + + // UTF-8 territory + // Check if the encoding is valid and if it is not, hex escape bytes. + // Important: We do not check the exact decoded values for validity, only the encoding format + // First check that this bytes is a valid lead byte: + // This means that it is not encoded as 1111 1XXX + // Or as 10XX XXXX + if (c < 0xC0 || + c >= 0xF8) { + hexEscapeChar(os, c); + break; + } + + auto encBytes = trailingBytes(c); + // Are there enough bytes left to avoid accessing out-of-bounds memory? + if (idx + encBytes - 1 >= m_str.size()) { + hexEscapeChar(os, c); + break; + } + // The header is valid, check data + // The next encBytes bytes must together be a valid utf-8 + // This means: bitpattern 10XX XXXX and the extracted value is sane (ish) + bool valid = true; + uint32_t value = headerValue(c); + for (std::size_t n = 1; n < encBytes; ++n) { + uchar nc = m_str[idx + n]; + valid &= ((nc & 0xC0) == 0x80); + value = (value << 6) | (nc & 0x3F); + } + + if ( + // Wrong bit pattern of following bytes + (!valid) || + // Overlong encodings + (value < 0x80) || + ( value < 0x800 && encBytes > 2) || // removed "0x80 <= value &&" because redundant + (0x800 < value && value < 0x10000 && encBytes > 3) || + // Encoded value out of range + (value >= 0x110000) + ) { + hexEscapeChar(os, c); + break; + } + + // If we got here, this is in fact a valid(ish) utf-8 sequence + for (std::size_t n = 0; n < encBytes; ++n) { + os << m_str[idx + n]; + } + idx += encBytes - 1; + break; + } + } + } + + std::ostream& operator << ( std::ostream& os, XmlEncode const& xmlEncode ) { + xmlEncode.encodeTo( os ); + return os; + } + + XmlWriter::ScopedElement::ScopedElement( XmlWriter* writer ) + : m_writer( writer ) + {} + + XmlWriter::ScopedElement::ScopedElement( ScopedElement&& other ) DOCTEST_NOEXCEPT + : m_writer( other.m_writer ){ + other.m_writer = nullptr; + } + XmlWriter::ScopedElement& XmlWriter::ScopedElement::operator=( ScopedElement&& other ) DOCTEST_NOEXCEPT { + if ( m_writer ) { + m_writer->endElement(); + } + m_writer = other.m_writer; + other.m_writer = nullptr; + return *this; + } + + + XmlWriter::ScopedElement::~ScopedElement() { + if( m_writer ) + m_writer->endElement(); + } + + XmlWriter::ScopedElement& XmlWriter::ScopedElement::writeText( std::string const& text, bool indent ) { + m_writer->writeText( text, indent ); + return *this; + } + + XmlWriter::XmlWriter( std::ostream& os ) : m_os( os ) + { + // writeDeclaration(); // called explicitly by the reporters that use the writer class - see issue #627 + } + + XmlWriter::~XmlWriter() { + while( !m_tags.empty() ) + endElement(); + } + + XmlWriter& XmlWriter::startElement( std::string const& name ) { + ensureTagClosed(); + newlineIfNecessary(); + m_os << m_indent << '<' << name; + m_tags.push_back( name ); + m_indent += " "; + m_tagIsOpen = true; + return *this; + } + + XmlWriter::ScopedElement XmlWriter::scopedElement( std::string const& name ) { + ScopedElement scoped( this ); + startElement( name ); + return scoped; + } + + XmlWriter& XmlWriter::endElement() { + newlineIfNecessary(); + m_indent = m_indent.substr( 0, m_indent.size()-2 ); + if( m_tagIsOpen ) { + m_os << "/>"; + m_tagIsOpen = false; + } + else { + m_os << m_indent << ""; + } + m_os << std::endl; + m_tags.pop_back(); + return *this; + } + + XmlWriter& XmlWriter::writeAttribute( std::string const& name, std::string const& attribute ) { + if( !name.empty() && !attribute.empty() ) + m_os << ' ' << name << "=\"" << XmlEncode( attribute, XmlEncode::ForAttributes ) << '"'; + return *this; + } + + XmlWriter& XmlWriter::writeAttribute( std::string const& name, const char* attribute ) { + if( !name.empty() && attribute && attribute[0] != '\0' ) + m_os << ' ' << name << "=\"" << XmlEncode( attribute, XmlEncode::ForAttributes ) << '"'; + return *this; + } + + XmlWriter& XmlWriter::writeAttribute( std::string const& name, bool attribute ) { + m_os << ' ' << name << "=\"" << ( attribute ? "true" : "false" ) << '"'; + return *this; + } + + XmlWriter& XmlWriter::writeText( std::string const& text, bool indent ) { + if( !text.empty() ){ + bool tagWasOpen = m_tagIsOpen; + ensureTagClosed(); + if( tagWasOpen && indent ) + m_os << m_indent; + m_os << XmlEncode( text ); + m_needsNewline = true; + } + return *this; + } + + //XmlWriter& XmlWriter::writeComment( std::string const& text ) { + // ensureTagClosed(); + // m_os << m_indent << ""; + // m_needsNewline = true; + // return *this; + //} + + //void XmlWriter::writeStylesheetRef( std::string const& url ) { + // m_os << "\n"; + //} + + //XmlWriter& XmlWriter::writeBlankLine() { + // ensureTagClosed(); + // m_os << '\n'; + // return *this; + //} + + void XmlWriter::ensureTagClosed() { + if( m_tagIsOpen ) { + m_os << ">" << std::endl; + m_tagIsOpen = false; + } + } + + void XmlWriter::writeDeclaration() { + m_os << "\n"; + } + + void XmlWriter::newlineIfNecessary() { + if( m_needsNewline ) { + m_os << std::endl; + m_needsNewline = false; + } + } + +// ================================================================================================= +// End of copy-pasted code from Catch +// ================================================================================================= + + // clang-format on + + struct XmlReporter : public IReporter + { + XmlWriter xml; + DOCTEST_DECLARE_MUTEX(mutex) + + // caching pointers/references to objects of these types - safe to do + const ContextOptions& opt; + const TestCaseData* tc = nullptr; + + XmlReporter(const ContextOptions& co) + : xml(*co.cout) + , opt(co) {} + + void log_contexts() { + int num_contexts = get_num_active_contexts(); + if(num_contexts) { + auto contexts = get_active_contexts(); + std::stringstream ss; + for(int i = 0; i < num_contexts; ++i) { + contexts[i]->stringify(&ss); + xml.scopedElement("Info").writeText(ss.str()); + ss.str(""); + } + } + } + + unsigned line(unsigned l) const { return opt.no_line_numbers ? 0 : l; } + + void test_case_start_impl(const TestCaseData& in) { + bool open_ts_tag = false; + if(tc != nullptr) { // we have already opened a test suite + if(std::strcmp(tc->m_test_suite, in.m_test_suite) != 0) { + xml.endElement(); + open_ts_tag = true; + } + } + else { + open_ts_tag = true; // first test case ==> first test suite + } + + if(open_ts_tag) { + xml.startElement("TestSuite"); + xml.writeAttribute("name", in.m_test_suite); + } + + tc = ∈ + xml.startElement("TestCase") + .writeAttribute("name", in.m_name) + .writeAttribute("filename", skipPathFromFilename(in.m_file.c_str())) + .writeAttribute("line", line(in.m_line)) + .writeAttribute("description", in.m_description); + + if(Approx(in.m_timeout) != 0) + xml.writeAttribute("timeout", in.m_timeout); + if(in.m_may_fail) + xml.writeAttribute("may_fail", true); + if(in.m_should_fail) + xml.writeAttribute("should_fail", true); + } + + // ========================================================================================= + // WHAT FOLLOWS ARE OVERRIDES OF THE VIRTUAL METHODS OF THE REPORTER INTERFACE + // ========================================================================================= + + void report_query(const QueryData& in) override { + test_run_start(); + if(opt.list_reporters) { + for(auto& curr : getListeners()) + xml.scopedElement("Listener") + .writeAttribute("priority", curr.first.first) + .writeAttribute("name", curr.first.second); + for(auto& curr : getReporters()) + xml.scopedElement("Reporter") + .writeAttribute("priority", curr.first.first) + .writeAttribute("name", curr.first.second); + } else if(opt.count || opt.list_test_cases) { + for(unsigned i = 0; i < in.num_data; ++i) { + xml.scopedElement("TestCase").writeAttribute("name", in.data[i]->m_name) + .writeAttribute("testsuite", in.data[i]->m_test_suite) + .writeAttribute("filename", skipPathFromFilename(in.data[i]->m_file.c_str())) + .writeAttribute("line", line(in.data[i]->m_line)) + .writeAttribute("skipped", in.data[i]->m_skip); + } + xml.scopedElement("OverallResultsTestCases") + .writeAttribute("unskipped", in.run_stats->numTestCasesPassingFilters); + } else if(opt.list_test_suites) { + for(unsigned i = 0; i < in.num_data; ++i) + xml.scopedElement("TestSuite").writeAttribute("name", in.data[i]->m_test_suite); + xml.scopedElement("OverallResultsTestCases") + .writeAttribute("unskipped", in.run_stats->numTestCasesPassingFilters); + xml.scopedElement("OverallResultsTestSuites") + .writeAttribute("unskipped", in.run_stats->numTestSuitesPassingFilters); + } + xml.endElement(); + } + + void test_run_start() override { + xml.writeDeclaration(); + + // remove .exe extension - mainly to have the same output on UNIX and Windows + std::string binary_name = skipPathFromFilename(opt.binary_name.c_str()); +#ifdef DOCTEST_PLATFORM_WINDOWS + if(binary_name.rfind(".exe") != std::string::npos) + binary_name = binary_name.substr(0, binary_name.length() - 4); +#endif // DOCTEST_PLATFORM_WINDOWS + + xml.startElement("doctest").writeAttribute("binary", binary_name); + if(opt.no_version == false) + xml.writeAttribute("version", DOCTEST_VERSION_STR); + + // only the consequential ones (TODO: filters) + xml.scopedElement("Options") + .writeAttribute("order_by", opt.order_by.c_str()) + .writeAttribute("rand_seed", opt.rand_seed) + .writeAttribute("first", opt.first) + .writeAttribute("last", opt.last) + .writeAttribute("abort_after", opt.abort_after) + .writeAttribute("subcase_filter_levels", opt.subcase_filter_levels) + .writeAttribute("case_sensitive", opt.case_sensitive) + .writeAttribute("no_throw", opt.no_throw) + .writeAttribute("no_skip", opt.no_skip); + } + + void test_run_end(const TestRunStats& p) override { + if(tc) // the TestSuite tag - only if there has been at least 1 test case + xml.endElement(); + + xml.scopedElement("OverallResultsAsserts") + .writeAttribute("successes", p.numAsserts - p.numAssertsFailed) + .writeAttribute("failures", p.numAssertsFailed); + + xml.startElement("OverallResultsTestCases") + .writeAttribute("successes", + p.numTestCasesPassingFilters - p.numTestCasesFailed) + .writeAttribute("failures", p.numTestCasesFailed); + if(opt.no_skipped_summary == false) + xml.writeAttribute("skipped", p.numTestCases - p.numTestCasesPassingFilters); + xml.endElement(); + + xml.endElement(); + } + + void test_case_start(const TestCaseData& in) override { + test_case_start_impl(in); + xml.ensureTagClosed(); + } + + void test_case_reenter(const TestCaseData&) override {} + + void test_case_end(const CurrentTestCaseStats& st) override { + xml.startElement("OverallResultsAsserts") + .writeAttribute("successes", + st.numAssertsCurrentTest - st.numAssertsFailedCurrentTest) + .writeAttribute("failures", st.numAssertsFailedCurrentTest) + .writeAttribute("test_case_success", st.testCaseSuccess); + if(opt.duration) + xml.writeAttribute("duration", st.seconds); + if(tc->m_expected_failures) + xml.writeAttribute("expected_failures", tc->m_expected_failures); + xml.endElement(); + + xml.endElement(); + } + + void test_case_exception(const TestCaseException& e) override { + DOCTEST_LOCK_MUTEX(mutex) + + xml.scopedElement("Exception") + .writeAttribute("crash", e.is_crash) + .writeText(e.error_string.c_str()); + } + + void subcase_start(const SubcaseSignature& in) override { + xml.startElement("SubCase") + .writeAttribute("name", in.m_name) + .writeAttribute("filename", skipPathFromFilename(in.m_file)) + .writeAttribute("line", line(in.m_line)); + xml.ensureTagClosed(); + } + + void subcase_end() override { xml.endElement(); } + + void log_assert(const AssertData& rb) override { + if(!rb.m_failed && !opt.success) + return; + + DOCTEST_LOCK_MUTEX(mutex) + + xml.startElement("Expression") + .writeAttribute("success", !rb.m_failed) + .writeAttribute("type", assertString(rb.m_at)) + .writeAttribute("filename", skipPathFromFilename(rb.m_file)) + .writeAttribute("line", line(rb.m_line)); + + xml.scopedElement("Original").writeText(rb.m_expr); + + if(rb.m_threw) + xml.scopedElement("Exception").writeText(rb.m_exception.c_str()); + + if(rb.m_at & assertType::is_throws_as) + xml.scopedElement("ExpectedException").writeText(rb.m_exception_type); + if(rb.m_at & assertType::is_throws_with) + xml.scopedElement("ExpectedExceptionString").writeText(rb.m_exception_string.c_str()); + if((rb.m_at & assertType::is_normal) && !rb.m_threw) + xml.scopedElement("Expanded").writeText(rb.m_decomp.c_str()); + + log_contexts(); + + xml.endElement(); + } + + void log_message(const MessageData& mb) override { + DOCTEST_LOCK_MUTEX(mutex) + + xml.startElement("Message") + .writeAttribute("type", failureString(mb.m_severity)) + .writeAttribute("filename", skipPathFromFilename(mb.m_file)) + .writeAttribute("line", line(mb.m_line)); + + xml.scopedElement("Text").writeText(mb.m_string.c_str()); + + log_contexts(); + + xml.endElement(); + } + + void test_case_skipped(const TestCaseData& in) override { + if(opt.no_skipped_summary == false) { + test_case_start_impl(in); + xml.writeAttribute("skipped", "true"); + xml.endElement(); + } + } + }; + + DOCTEST_REGISTER_REPORTER("xml", 0, XmlReporter); + + void fulltext_log_assert_to_stream(std::ostream& s, const AssertData& rb) { + if((rb.m_at & (assertType::is_throws_as | assertType::is_throws_with)) == + 0) //!OCLINT bitwise operator in conditional + s << Color::Cyan << assertString(rb.m_at) << "( " << rb.m_expr << " ) " + << Color::None; + + if(rb.m_at & assertType::is_throws) { //!OCLINT bitwise operator in conditional + s << (rb.m_threw ? "threw as expected!" : "did NOT throw at all!") << "\n"; + } else if((rb.m_at & assertType::is_throws_as) && + (rb.m_at & assertType::is_throws_with)) { //!OCLINT + s << Color::Cyan << assertString(rb.m_at) << "( " << rb.m_expr << ", \"" + << rb.m_exception_string.c_str() + << "\", " << rb.m_exception_type << " ) " << Color::None; + if(rb.m_threw) { + if(!rb.m_failed) { + s << "threw as expected!\n"; + } else { + s << "threw a DIFFERENT exception! (contents: " << rb.m_exception << ")\n"; + } + } else { + s << "did NOT throw at all!\n"; + } + } else if(rb.m_at & + assertType::is_throws_as) { //!OCLINT bitwise operator in conditional + s << Color::Cyan << assertString(rb.m_at) << "( " << rb.m_expr << ", " + << rb.m_exception_type << " ) " << Color::None + << (rb.m_threw ? (rb.m_threw_as ? "threw as expected!" : + "threw a DIFFERENT exception: ") : + "did NOT throw at all!") + << Color::Cyan << rb.m_exception << "\n"; + } else if(rb.m_at & + assertType::is_throws_with) { //!OCLINT bitwise operator in conditional + s << Color::Cyan << assertString(rb.m_at) << "( " << rb.m_expr << ", \"" + << rb.m_exception_string.c_str() + << "\" ) " << Color::None + << (rb.m_threw ? (!rb.m_failed ? "threw as expected!" : + "threw a DIFFERENT exception: ") : + "did NOT throw at all!") + << Color::Cyan << rb.m_exception << "\n"; + } else if(rb.m_at & assertType::is_nothrow) { //!OCLINT bitwise operator in conditional + s << (rb.m_threw ? "THREW exception: " : "didn't throw!") << Color::Cyan + << rb.m_exception << "\n"; + } else { + s << (rb.m_threw ? "THREW exception: " : + (!rb.m_failed ? "is correct!\n" : "is NOT correct!\n")); + if(rb.m_threw) + s << rb.m_exception << "\n"; + else + s << " values: " << assertString(rb.m_at) << "( " << rb.m_decomp << " )\n"; + } + } + + // TODO: + // - log_message() + // - respond to queries + // - honor remaining options + // - more attributes in tags + struct JUnitReporter : public IReporter + { + XmlWriter xml; + DOCTEST_DECLARE_MUTEX(mutex) + Timer timer; + std::vector deepestSubcaseStackNames; + + struct JUnitTestCaseData + { + static std::string getCurrentTimestamp() { + // Beware, this is not reentrant because of backward compatibility issues + // Also, UTC only, again because of backward compatibility (%z is C++11) + time_t rawtime; + std::time(&rawtime); + auto const timeStampSize = sizeof("2017-01-16T17:06:45Z"); + + std::tm timeInfo; +#ifdef DOCTEST_PLATFORM_WINDOWS + gmtime_s(&timeInfo, &rawtime); +#else // DOCTEST_PLATFORM_WINDOWS + gmtime_r(&rawtime, &timeInfo); +#endif // DOCTEST_PLATFORM_WINDOWS + + char timeStamp[timeStampSize]; + const char* const fmt = "%Y-%m-%dT%H:%M:%SZ"; + + std::strftime(timeStamp, timeStampSize, fmt, &timeInfo); + return std::string(timeStamp); + } + + struct JUnitTestMessage + { + JUnitTestMessage(const std::string& _message, const std::string& _type, const std::string& _details) + : message(_message), type(_type), details(_details) {} + + JUnitTestMessage(const std::string& _message, const std::string& _details) + : message(_message), type(), details(_details) {} + + std::string message, type, details; + }; + + struct JUnitTestCase + { + JUnitTestCase(const std::string& _classname, const std::string& _name) + : classname(_classname), name(_name), time(0), failures() {} + + std::string classname, name; + double time; + std::vector failures, errors; + }; + + void add(const std::string& classname, const std::string& name) { + testcases.emplace_back(classname, name); + } + + void appendSubcaseNamesToLastTestcase(std::vector nameStack) { + for(auto& curr: nameStack) + if(curr.size()) + testcases.back().name += std::string("/") + curr.c_str(); + } + + void addTime(double time) { + if(time < 1e-4) + time = 0; + testcases.back().time = time; + totalSeconds += time; + } + + void addFailure(const std::string& message, const std::string& type, const std::string& details) { + testcases.back().failures.emplace_back(message, type, details); + ++totalFailures; + } + + void addError(const std::string& message, const std::string& details) { + testcases.back().errors.emplace_back(message, details); + ++totalErrors; + } + + std::vector testcases; + double totalSeconds = 0; + int totalErrors = 0, totalFailures = 0; + }; + + JUnitTestCaseData testCaseData; + + // caching pointers/references to objects of these types - safe to do + const ContextOptions& opt; + const TestCaseData* tc = nullptr; + + JUnitReporter(const ContextOptions& co) + : xml(*co.cout) + , opt(co) {} + + unsigned line(unsigned l) const { return opt.no_line_numbers ? 0 : l; } + + // ========================================================================================= + // WHAT FOLLOWS ARE OVERRIDES OF THE VIRTUAL METHODS OF THE REPORTER INTERFACE + // ========================================================================================= + + void report_query(const QueryData&) override { + xml.writeDeclaration(); + } + + void test_run_start() override { + xml.writeDeclaration(); + } + + void test_run_end(const TestRunStats& p) override { + // remove .exe extension - mainly to have the same output on UNIX and Windows + std::string binary_name = skipPathFromFilename(opt.binary_name.c_str()); +#ifdef DOCTEST_PLATFORM_WINDOWS + if(binary_name.rfind(".exe") != std::string::npos) + binary_name = binary_name.substr(0, binary_name.length() - 4); +#endif // DOCTEST_PLATFORM_WINDOWS + xml.startElement("testsuites"); + xml.startElement("testsuite").writeAttribute("name", binary_name) + .writeAttribute("errors", testCaseData.totalErrors) + .writeAttribute("failures", testCaseData.totalFailures) + .writeAttribute("tests", p.numAsserts); + if(opt.no_time_in_output == false) { + xml.writeAttribute("time", testCaseData.totalSeconds); + xml.writeAttribute("timestamp", JUnitTestCaseData::getCurrentTimestamp()); + } + if(opt.no_version == false) + xml.writeAttribute("doctest_version", DOCTEST_VERSION_STR); + + for(const auto& testCase : testCaseData.testcases) { + xml.startElement("testcase") + .writeAttribute("classname", testCase.classname) + .writeAttribute("name", testCase.name); + if(opt.no_time_in_output == false) + xml.writeAttribute("time", testCase.time); + // This is not ideal, but it should be enough to mimic gtest's junit output. + xml.writeAttribute("status", "run"); + + for(const auto& failure : testCase.failures) { + xml.scopedElement("failure") + .writeAttribute("message", failure.message) + .writeAttribute("type", failure.type) + .writeText(failure.details, false); + } + + for(const auto& error : testCase.errors) { + xml.scopedElement("error") + .writeAttribute("message", error.message) + .writeText(error.details); + } + + xml.endElement(); + } + xml.endElement(); + xml.endElement(); + } + + void test_case_start(const TestCaseData& in) override { + testCaseData.add(skipPathFromFilename(in.m_file.c_str()), in.m_name); + timer.start(); + } + + void test_case_reenter(const TestCaseData& in) override { + testCaseData.addTime(timer.getElapsedSeconds()); + testCaseData.appendSubcaseNamesToLastTestcase(deepestSubcaseStackNames); + deepestSubcaseStackNames.clear(); + + timer.start(); + testCaseData.add(skipPathFromFilename(in.m_file.c_str()), in.m_name); + } + + void test_case_end(const CurrentTestCaseStats&) override { + testCaseData.addTime(timer.getElapsedSeconds()); + testCaseData.appendSubcaseNamesToLastTestcase(deepestSubcaseStackNames); + deepestSubcaseStackNames.clear(); + } + + void test_case_exception(const TestCaseException& e) override { + DOCTEST_LOCK_MUTEX(mutex) + testCaseData.addError("exception", e.error_string.c_str()); + } + + void subcase_start(const SubcaseSignature& in) override { + deepestSubcaseStackNames.push_back(in.m_name); + } + + void subcase_end() override {} + + void log_assert(const AssertData& rb) override { + if(!rb.m_failed) // report only failures & ignore the `success` option + return; + + DOCTEST_LOCK_MUTEX(mutex) + + std::ostringstream os; + os << skipPathFromFilename(rb.m_file) << (opt.gnu_file_line ? ":" : "(") + << line(rb.m_line) << (opt.gnu_file_line ? ":" : "):") << std::endl; + + fulltext_log_assert_to_stream(os, rb); + log_contexts(os); + testCaseData.addFailure(rb.m_decomp.c_str(), assertString(rb.m_at), os.str()); + } + + void log_message(const MessageData& mb) override { + if(mb.m_severity & assertType::is_warn) // report only failures + return; + + DOCTEST_LOCK_MUTEX(mutex) + + std::ostringstream os; + os << skipPathFromFilename(mb.m_file) << (opt.gnu_file_line ? ":" : "(") + << line(mb.m_line) << (opt.gnu_file_line ? ":" : "):") << std::endl; + + os << mb.m_string.c_str() << "\n"; + log_contexts(os); + + testCaseData.addFailure(mb.m_string.c_str(), + mb.m_severity & assertType::is_check ? "FAIL_CHECK" : "FAIL", os.str()); + } + + void test_case_skipped(const TestCaseData&) override {} + + void log_contexts(std::ostringstream& s) { + int num_contexts = get_num_active_contexts(); + if(num_contexts) { + auto contexts = get_active_contexts(); + + s << " logged: "; + for(int i = 0; i < num_contexts; ++i) { + s << (i == 0 ? "" : " "); + contexts[i]->stringify(&s); + s << std::endl; + } + } + } + }; + + DOCTEST_REGISTER_REPORTER("junit", 0, JUnitReporter); + + struct Whitespace + { + int nrSpaces; + explicit Whitespace(int nr) + : nrSpaces(nr) {} + }; + + std::ostream& operator<<(std::ostream& out, const Whitespace& ws) { + if(ws.nrSpaces != 0) + out << std::setw(ws.nrSpaces) << ' '; + return out; + } + + struct ConsoleReporter : public IReporter + { + std::ostream& s; + bool hasLoggedCurrentTestStart; + std::vector subcasesStack; + size_t currentSubcaseLevel; + DOCTEST_DECLARE_MUTEX(mutex) + + // caching pointers/references to objects of these types - safe to do + const ContextOptions& opt; + const TestCaseData* tc; + + ConsoleReporter(const ContextOptions& co) + : s(*co.cout) + , opt(co) {} + + ConsoleReporter(const ContextOptions& co, std::ostream& ostr) + : s(ostr) + , opt(co) {} + + // ========================================================================================= + // WHAT FOLLOWS ARE HELPERS USED BY THE OVERRIDES OF THE VIRTUAL METHODS OF THE INTERFACE + // ========================================================================================= + + void separator_to_stream() { + s << Color::Yellow + << "===============================================================================" + "\n"; + } + + const char* getSuccessOrFailString(bool success, assertType::Enum at, + const char* success_str) { + if(success) + return success_str; + return failureString(at); + } + + Color::Enum getSuccessOrFailColor(bool success, assertType::Enum at) { + return success ? Color::BrightGreen : + (at & assertType::is_warn) ? Color::Yellow : Color::Red; + } + + void successOrFailColoredStringToStream(bool success, assertType::Enum at, + const char* success_str = "SUCCESS") { + s << getSuccessOrFailColor(success, at) + << getSuccessOrFailString(success, at, success_str) << ": "; + } + + void log_contexts() { + int num_contexts = get_num_active_contexts(); + if(num_contexts) { + auto contexts = get_active_contexts(); + + s << Color::None << " logged: "; + for(int i = 0; i < num_contexts; ++i) { + s << (i == 0 ? "" : " "); + contexts[i]->stringify(&s); + s << "\n"; + } + } + + s << "\n"; + } + + // this was requested to be made virtual so users could override it + virtual void file_line_to_stream(const char* file, int line, + const char* tail = "") { + s << Color::LightGrey << skipPathFromFilename(file) << (opt.gnu_file_line ? ":" : "(") + << (opt.no_line_numbers ? 0 : line) // 0 or the real num depending on the option + << (opt.gnu_file_line ? ":" : "):") << tail; + } + + void logTestStart() { + if(hasLoggedCurrentTestStart) + return; + + separator_to_stream(); + file_line_to_stream(tc->m_file.c_str(), tc->m_line, "\n"); + if(tc->m_description) + s << Color::Yellow << "DESCRIPTION: " << Color::None << tc->m_description << "\n"; + if(tc->m_test_suite && tc->m_test_suite[0] != '\0') + s << Color::Yellow << "TEST SUITE: " << Color::None << tc->m_test_suite << "\n"; + if(strncmp(tc->m_name, " Scenario:", 11) != 0) + s << Color::Yellow << "TEST CASE: "; + s << Color::None << tc->m_name << "\n"; + + for(size_t i = 0; i < currentSubcaseLevel; ++i) { + if(subcasesStack[i].m_name[0] != '\0') + s << " " << subcasesStack[i].m_name << "\n"; + } + + if(currentSubcaseLevel != subcasesStack.size()) { + s << Color::Yellow << "\nDEEPEST SUBCASE STACK REACHED (DIFFERENT FROM THE CURRENT ONE):\n" << Color::None; + for(size_t i = 0; i < subcasesStack.size(); ++i) { + if(subcasesStack[i].m_name[0] != '\0') + s << " " << subcasesStack[i].m_name << "\n"; + } + } + + s << "\n"; + + hasLoggedCurrentTestStart = true; + } + + void printVersion() { + if(opt.no_version == false) + s << Color::Cyan << "[doctest] " << Color::None << "doctest version is \"" + << DOCTEST_VERSION_STR << "\"\n"; + } + + void printIntro() { + if(opt.no_intro == false) { + printVersion(); + s << Color::Cyan << "[doctest] " << Color::None + << "run with \"--" DOCTEST_OPTIONS_PREFIX_DISPLAY "help\" for options\n"; + } + } + + void printHelp() { + int sizePrefixDisplay = static_cast(strlen(DOCTEST_OPTIONS_PREFIX_DISPLAY)); + printVersion(); + // clang-format off + s << Color::Cyan << "[doctest]\n" << Color::None; + s << Color::Cyan << "[doctest] " << Color::None; + s << "boolean values: \"1/on/yes/true\" or \"0/off/no/false\"\n"; + s << Color::Cyan << "[doctest] " << Color::None; + s << "filter values: \"str1,str2,str3\" (comma separated strings)\n"; + s << Color::Cyan << "[doctest]\n" << Color::None; + s << Color::Cyan << "[doctest] " << Color::None; + s << "filters use wildcards for matching strings\n"; + s << Color::Cyan << "[doctest] " << Color::None; + s << "something passes a filter if any of the strings in a filter matches\n"; +#ifndef DOCTEST_CONFIG_NO_UNPREFIXED_OPTIONS + s << Color::Cyan << "[doctest]\n" << Color::None; + s << Color::Cyan << "[doctest] " << Color::None; + s << "ALL FLAGS, OPTIONS AND FILTERS ALSO AVAILABLE WITH A \"" DOCTEST_CONFIG_OPTIONS_PREFIX "\" PREFIX!!!\n"; +#endif + s << Color::Cyan << "[doctest]\n" << Color::None; + s << Color::Cyan << "[doctest] " << Color::None; + s << "Query flags - the program quits after them. Available:\n\n"; + s << " -" DOCTEST_OPTIONS_PREFIX_DISPLAY "?, --" DOCTEST_OPTIONS_PREFIX_DISPLAY "help, -" DOCTEST_OPTIONS_PREFIX_DISPLAY "h " + << Whitespace(sizePrefixDisplay*0) << "prints this message\n"; + s << " -" DOCTEST_OPTIONS_PREFIX_DISPLAY "v, --" DOCTEST_OPTIONS_PREFIX_DISPLAY "version " + << Whitespace(sizePrefixDisplay*1) << "prints the version\n"; + s << " -" DOCTEST_OPTIONS_PREFIX_DISPLAY "c, --" DOCTEST_OPTIONS_PREFIX_DISPLAY "count " + << Whitespace(sizePrefixDisplay*1) << "prints the number of matching tests\n"; + s << " -" DOCTEST_OPTIONS_PREFIX_DISPLAY "ltc, --" DOCTEST_OPTIONS_PREFIX_DISPLAY "list-test-cases " + << Whitespace(sizePrefixDisplay*1) << "lists all matching tests by name\n"; + s << " -" DOCTEST_OPTIONS_PREFIX_DISPLAY "lts, --" DOCTEST_OPTIONS_PREFIX_DISPLAY "list-test-suites " + << Whitespace(sizePrefixDisplay*1) << "lists all matching test suites\n"; + s << " -" DOCTEST_OPTIONS_PREFIX_DISPLAY "lr, --" DOCTEST_OPTIONS_PREFIX_DISPLAY "list-reporters " + << Whitespace(sizePrefixDisplay*1) << "lists all registered reporters\n\n"; + // ================================================================================== << 79 + s << Color::Cyan << "[doctest] " << Color::None; + s << "The available / options/filters are:\n\n"; + s << " -" DOCTEST_OPTIONS_PREFIX_DISPLAY "tc, --" DOCTEST_OPTIONS_PREFIX_DISPLAY "test-case= " + << Whitespace(sizePrefixDisplay*1) << "filters tests by their name\n"; + s << " -" DOCTEST_OPTIONS_PREFIX_DISPLAY "tce, --" DOCTEST_OPTIONS_PREFIX_DISPLAY "test-case-exclude= " + << Whitespace(sizePrefixDisplay*1) << "filters OUT tests by their name\n"; + s << " -" DOCTEST_OPTIONS_PREFIX_DISPLAY "sf, --" DOCTEST_OPTIONS_PREFIX_DISPLAY "source-file= " + << Whitespace(sizePrefixDisplay*1) << "filters tests by their file\n"; + s << " -" DOCTEST_OPTIONS_PREFIX_DISPLAY "sfe, --" DOCTEST_OPTIONS_PREFIX_DISPLAY "source-file-exclude= " + << Whitespace(sizePrefixDisplay*1) << "filters OUT tests by their file\n"; + s << " -" DOCTEST_OPTIONS_PREFIX_DISPLAY "ts, --" DOCTEST_OPTIONS_PREFIX_DISPLAY "test-suite= " + << Whitespace(sizePrefixDisplay*1) << "filters tests by their test suite\n"; + s << " -" DOCTEST_OPTIONS_PREFIX_DISPLAY "tse, --" DOCTEST_OPTIONS_PREFIX_DISPLAY "test-suite-exclude= " + << Whitespace(sizePrefixDisplay*1) << "filters OUT tests by their test suite\n"; + s << " -" DOCTEST_OPTIONS_PREFIX_DISPLAY "sc, --" DOCTEST_OPTIONS_PREFIX_DISPLAY "subcase= " + << Whitespace(sizePrefixDisplay*1) << "filters subcases by their name\n"; + s << " -" DOCTEST_OPTIONS_PREFIX_DISPLAY "sce, --" DOCTEST_OPTIONS_PREFIX_DISPLAY "subcase-exclude= " + << Whitespace(sizePrefixDisplay*1) << "filters OUT subcases by their name\n"; + s << " -" DOCTEST_OPTIONS_PREFIX_DISPLAY "r, --" DOCTEST_OPTIONS_PREFIX_DISPLAY "reporters= " + << Whitespace(sizePrefixDisplay*1) << "reporters to use (console is default)\n"; + s << " -" DOCTEST_OPTIONS_PREFIX_DISPLAY "o, --" DOCTEST_OPTIONS_PREFIX_DISPLAY "out= " + << Whitespace(sizePrefixDisplay*1) << "output filename\n"; + s << " -" DOCTEST_OPTIONS_PREFIX_DISPLAY "ob, --" DOCTEST_OPTIONS_PREFIX_DISPLAY "order-by= " + << Whitespace(sizePrefixDisplay*1) << "how the tests should be ordered\n"; + s << Whitespace(sizePrefixDisplay*3) << " - [file/suite/name/rand/none]\n"; + s << " -" DOCTEST_OPTIONS_PREFIX_DISPLAY "rs, --" DOCTEST_OPTIONS_PREFIX_DISPLAY "rand-seed= " + << Whitespace(sizePrefixDisplay*1) << "seed for random ordering\n"; + s << " -" DOCTEST_OPTIONS_PREFIX_DISPLAY "f, --" DOCTEST_OPTIONS_PREFIX_DISPLAY "first= " + << Whitespace(sizePrefixDisplay*1) << "the first test passing the filters to\n"; + s << Whitespace(sizePrefixDisplay*3) << " execute - for range-based execution\n"; + s << " -" DOCTEST_OPTIONS_PREFIX_DISPLAY "l, --" DOCTEST_OPTIONS_PREFIX_DISPLAY "last= " + << Whitespace(sizePrefixDisplay*1) << "the last test passing the filters to\n"; + s << Whitespace(sizePrefixDisplay*3) << " execute - for range-based execution\n"; + s << " -" DOCTEST_OPTIONS_PREFIX_DISPLAY "aa, --" DOCTEST_OPTIONS_PREFIX_DISPLAY "abort-after= " + << Whitespace(sizePrefixDisplay*1) << "stop after failed assertions\n"; + s << " -" DOCTEST_OPTIONS_PREFIX_DISPLAY "scfl,--" DOCTEST_OPTIONS_PREFIX_DISPLAY "subcase-filter-levels= " + << Whitespace(sizePrefixDisplay*1) << "apply filters for the first levels\n"; + s << Color::Cyan << "\n[doctest] " << Color::None; + s << "Bool options - can be used like flags and true is assumed. Available:\n\n"; + s << " -" DOCTEST_OPTIONS_PREFIX_DISPLAY "s, --" DOCTEST_OPTIONS_PREFIX_DISPLAY "success= " + << Whitespace(sizePrefixDisplay*1) << "include successful assertions in output\n"; + s << " -" DOCTEST_OPTIONS_PREFIX_DISPLAY "cs, --" DOCTEST_OPTIONS_PREFIX_DISPLAY "case-sensitive= " + << Whitespace(sizePrefixDisplay*1) << "filters being treated as case sensitive\n"; + s << " -" DOCTEST_OPTIONS_PREFIX_DISPLAY "e, --" DOCTEST_OPTIONS_PREFIX_DISPLAY "exit= " + << Whitespace(sizePrefixDisplay*1) << "exits after the tests finish\n"; + s << " -" DOCTEST_OPTIONS_PREFIX_DISPLAY "d, --" DOCTEST_OPTIONS_PREFIX_DISPLAY "duration= " + << Whitespace(sizePrefixDisplay*1) << "prints the time duration of each test\n"; + s << " -" DOCTEST_OPTIONS_PREFIX_DISPLAY "m, --" DOCTEST_OPTIONS_PREFIX_DISPLAY "minimal= " + << Whitespace(sizePrefixDisplay*1) << "minimal console output (only failures)\n"; + s << " -" DOCTEST_OPTIONS_PREFIX_DISPLAY "q, --" DOCTEST_OPTIONS_PREFIX_DISPLAY "quiet= " + << Whitespace(sizePrefixDisplay*1) << "no console output\n"; + s << " -" DOCTEST_OPTIONS_PREFIX_DISPLAY "nt, --" DOCTEST_OPTIONS_PREFIX_DISPLAY "no-throw= " + << Whitespace(sizePrefixDisplay*1) << "skips exceptions-related assert checks\n"; + s << " -" DOCTEST_OPTIONS_PREFIX_DISPLAY "ne, --" DOCTEST_OPTIONS_PREFIX_DISPLAY "no-exitcode= " + << Whitespace(sizePrefixDisplay*1) << "returns (or exits) always with success\n"; + s << " -" DOCTEST_OPTIONS_PREFIX_DISPLAY "nr, --" DOCTEST_OPTIONS_PREFIX_DISPLAY "no-run= " + << Whitespace(sizePrefixDisplay*1) << "skips all runtime doctest operations\n"; + s << " -" DOCTEST_OPTIONS_PREFIX_DISPLAY "ni, --" DOCTEST_OPTIONS_PREFIX_DISPLAY "no-intro= " + << Whitespace(sizePrefixDisplay*1) << "omit the framework intro in the output\n"; + s << " -" DOCTEST_OPTIONS_PREFIX_DISPLAY "nv, --" DOCTEST_OPTIONS_PREFIX_DISPLAY "no-version= " + << Whitespace(sizePrefixDisplay*1) << "omit the framework version in the output\n"; + s << " -" DOCTEST_OPTIONS_PREFIX_DISPLAY "nc, --" DOCTEST_OPTIONS_PREFIX_DISPLAY "no-colors= " + << Whitespace(sizePrefixDisplay*1) << "disables colors in output\n"; + s << " -" DOCTEST_OPTIONS_PREFIX_DISPLAY "fc, --" DOCTEST_OPTIONS_PREFIX_DISPLAY "force-colors= " + << Whitespace(sizePrefixDisplay*1) << "use colors even when not in a tty\n"; + s << " -" DOCTEST_OPTIONS_PREFIX_DISPLAY "nb, --" DOCTEST_OPTIONS_PREFIX_DISPLAY "no-breaks= " + << Whitespace(sizePrefixDisplay*1) << "disables breakpoints in debuggers\n"; + s << " -" DOCTEST_OPTIONS_PREFIX_DISPLAY "ns, --" DOCTEST_OPTIONS_PREFIX_DISPLAY "no-skip= " + << Whitespace(sizePrefixDisplay*1) << "don't skip test cases marked as skip\n"; + s << " -" DOCTEST_OPTIONS_PREFIX_DISPLAY "gfl, --" DOCTEST_OPTIONS_PREFIX_DISPLAY "gnu-file-line= " + << Whitespace(sizePrefixDisplay*1) << ":n: vs (n): for line numbers in output\n"; + s << " -" DOCTEST_OPTIONS_PREFIX_DISPLAY "npf, --" DOCTEST_OPTIONS_PREFIX_DISPLAY "no-path-filenames= " + << Whitespace(sizePrefixDisplay*1) << "only filenames and no paths in output\n"; + s << " -" DOCTEST_OPTIONS_PREFIX_DISPLAY "nln, --" DOCTEST_OPTIONS_PREFIX_DISPLAY "no-line-numbers= " + << Whitespace(sizePrefixDisplay*1) << "0 instead of real line numbers in output\n"; + // ================================================================================== << 79 + // clang-format on + + s << Color::Cyan << "\n[doctest] " << Color::None; + s << "for more information visit the project documentation\n\n"; + } + + void printRegisteredReporters() { + printVersion(); + auto printReporters = [this] (const reporterMap& reporters, const char* type) { + if(reporters.size()) { + s << Color::Cyan << "[doctest] " << Color::None << "listing all registered " << type << "\n"; + for(auto& curr : reporters) + s << "priority: " << std::setw(5) << curr.first.first + << " name: " << curr.first.second << "\n"; + } + }; + printReporters(getListeners(), "listeners"); + printReporters(getReporters(), "reporters"); + } + + // ========================================================================================= + // WHAT FOLLOWS ARE OVERRIDES OF THE VIRTUAL METHODS OF THE REPORTER INTERFACE + // ========================================================================================= + + void report_query(const QueryData& in) override { + if(opt.version) { + printVersion(); + } else if(opt.help) { + printHelp(); + } else if(opt.list_reporters) { + printRegisteredReporters(); + } else if(opt.count || opt.list_test_cases) { + if(opt.list_test_cases) { + s << Color::Cyan << "[doctest] " << Color::None + << "listing all test case names\n"; + separator_to_stream(); + } + + for(unsigned i = 0; i < in.num_data; ++i) + s << Color::None << in.data[i]->m_name << "\n"; + + separator_to_stream(); + + s << Color::Cyan << "[doctest] " << Color::None + << "unskipped test cases passing the current filters: " + << g_cs->numTestCasesPassingFilters << "\n"; + + } else if(opt.list_test_suites) { + s << Color::Cyan << "[doctest] " << Color::None << "listing all test suites\n"; + separator_to_stream(); + + for(unsigned i = 0; i < in.num_data; ++i) + s << Color::None << in.data[i]->m_test_suite << "\n"; + + separator_to_stream(); + + s << Color::Cyan << "[doctest] " << Color::None + << "unskipped test cases passing the current filters: " + << g_cs->numTestCasesPassingFilters << "\n"; + s << Color::Cyan << "[doctest] " << Color::None + << "test suites with unskipped test cases passing the current filters: " + << g_cs->numTestSuitesPassingFilters << "\n"; + } + } + + void test_run_start() override { + if(!opt.minimal) + printIntro(); + } + + void test_run_end(const TestRunStats& p) override { + if(opt.minimal && p.numTestCasesFailed == 0) + return; + + separator_to_stream(); + s << std::dec; + + auto totwidth = int(std::ceil(log10(static_cast(std::max(p.numTestCasesPassingFilters, static_cast(p.numAsserts))) + 1))); + auto passwidth = int(std::ceil(log10(static_cast(std::max(p.numTestCasesPassingFilters - p.numTestCasesFailed, static_cast(p.numAsserts - p.numAssertsFailed))) + 1))); + auto failwidth = int(std::ceil(log10(static_cast(std::max(p.numTestCasesFailed, static_cast(p.numAssertsFailed))) + 1))); + const bool anythingFailed = p.numTestCasesFailed > 0 || p.numAssertsFailed > 0; + s << Color::Cyan << "[doctest] " << Color::None << "test cases: " << std::setw(totwidth) + << p.numTestCasesPassingFilters << " | " + << ((p.numTestCasesPassingFilters == 0 || anythingFailed) ? Color::None : + Color::Green) + << std::setw(passwidth) << p.numTestCasesPassingFilters - p.numTestCasesFailed << " passed" + << Color::None << " | " << (p.numTestCasesFailed > 0 ? Color::Red : Color::None) + << std::setw(failwidth) << p.numTestCasesFailed << " failed" << Color::None << " |"; + if(opt.no_skipped_summary == false) { + const int numSkipped = p.numTestCases - p.numTestCasesPassingFilters; + s << " " << (numSkipped == 0 ? Color::None : Color::Yellow) << numSkipped + << " skipped" << Color::None; + } + s << "\n"; + s << Color::Cyan << "[doctest] " << Color::None << "assertions: " << std::setw(totwidth) + << p.numAsserts << " | " + << ((p.numAsserts == 0 || anythingFailed) ? Color::None : Color::Green) + << std::setw(passwidth) << (p.numAsserts - p.numAssertsFailed) << " passed" << Color::None + << " | " << (p.numAssertsFailed > 0 ? Color::Red : Color::None) << std::setw(failwidth) + << p.numAssertsFailed << " failed" << Color::None << " |\n"; + s << Color::Cyan << "[doctest] " << Color::None + << "Status: " << (p.numTestCasesFailed > 0 ? Color::Red : Color::Green) + << ((p.numTestCasesFailed > 0) ? "FAILURE!" : "SUCCESS!") << Color::None << std::endl; + } + + void test_case_start(const TestCaseData& in) override { + hasLoggedCurrentTestStart = false; + tc = ∈ + subcasesStack.clear(); + currentSubcaseLevel = 0; + } + + void test_case_reenter(const TestCaseData&) override { + subcasesStack.clear(); + } + + void test_case_end(const CurrentTestCaseStats& st) override { + if(tc->m_no_output) + return; + + // log the preamble of the test case only if there is something + // else to print - something other than that an assert has failed + if(opt.duration || + (st.failure_flags && st.failure_flags != static_cast(TestCaseFailureReason::AssertFailure))) + logTestStart(); + + if(opt.duration) + s << Color::None << std::setprecision(6) << std::fixed << st.seconds + << " s: " << tc->m_name << "\n"; + + if(st.failure_flags & TestCaseFailureReason::Timeout) + s << Color::Red << "Test case exceeded time limit of " << std::setprecision(6) + << std::fixed << tc->m_timeout << "!\n"; + + if(st.failure_flags & TestCaseFailureReason::ShouldHaveFailedButDidnt) { + s << Color::Red << "Should have failed but didn't! Marking it as failed!\n"; + } else if(st.failure_flags & TestCaseFailureReason::ShouldHaveFailedAndDid) { + s << Color::Yellow << "Failed as expected so marking it as not failed\n"; + } else if(st.failure_flags & TestCaseFailureReason::CouldHaveFailedAndDid) { + s << Color::Yellow << "Allowed to fail so marking it as not failed\n"; + } else if(st.failure_flags & TestCaseFailureReason::DidntFailExactlyNumTimes) { + s << Color::Red << "Didn't fail exactly " << tc->m_expected_failures + << " times so marking it as failed!\n"; + } else if(st.failure_flags & TestCaseFailureReason::FailedExactlyNumTimes) { + s << Color::Yellow << "Failed exactly " << tc->m_expected_failures + << " times as expected so marking it as not failed!\n"; + } + if(st.failure_flags & TestCaseFailureReason::TooManyFailedAsserts) { + s << Color::Red << "Aborting - too many failed asserts!\n"; + } + s << Color::None; // lgtm [cpp/useless-expression] + } + + void test_case_exception(const TestCaseException& e) override { + DOCTEST_LOCK_MUTEX(mutex) + if(tc->m_no_output) + return; + + logTestStart(); + + file_line_to_stream(tc->m_file.c_str(), tc->m_line, " "); + successOrFailColoredStringToStream(false, e.is_crash ? assertType::is_require : + assertType::is_check); + s << Color::Red << (e.is_crash ? "test case CRASHED: " : "test case THREW exception: ") + << Color::Cyan << e.error_string << "\n"; + + int num_stringified_contexts = get_num_stringified_contexts(); + if(num_stringified_contexts) { + auto stringified_contexts = get_stringified_contexts(); + s << Color::None << " logged: "; + for(int i = num_stringified_contexts; i > 0; --i) { + s << (i == num_stringified_contexts ? "" : " ") + << stringified_contexts[i - 1] << "\n"; + } + } + s << "\n" << Color::None; + } + + void subcase_start(const SubcaseSignature& subc) override { + subcasesStack.push_back(subc); + ++currentSubcaseLevel; + hasLoggedCurrentTestStart = false; + } + + void subcase_end() override { + --currentSubcaseLevel; + hasLoggedCurrentTestStart = false; + } + + void log_assert(const AssertData& rb) override { + if((!rb.m_failed && !opt.success) || tc->m_no_output) + return; + + DOCTEST_LOCK_MUTEX(mutex) + + logTestStart(); + + file_line_to_stream(rb.m_file, rb.m_line, " "); + successOrFailColoredStringToStream(!rb.m_failed, rb.m_at); + + fulltext_log_assert_to_stream(s, rb); + + log_contexts(); + } + + void log_message(const MessageData& mb) override { + if(tc->m_no_output) + return; + + DOCTEST_LOCK_MUTEX(mutex) + + logTestStart(); + + file_line_to_stream(mb.m_file, mb.m_line, " "); + s << getSuccessOrFailColor(false, mb.m_severity) + << getSuccessOrFailString(mb.m_severity & assertType::is_warn, mb.m_severity, + "MESSAGE") << ": "; + s << Color::None << mb.m_string << "\n"; + log_contexts(); + } + + void test_case_skipped(const TestCaseData&) override {} + }; + + DOCTEST_REGISTER_REPORTER("console", 0, ConsoleReporter); + +#ifdef DOCTEST_PLATFORM_WINDOWS + struct DebugOutputWindowReporter : public ConsoleReporter + { + DOCTEST_THREAD_LOCAL static std::ostringstream oss; + + DebugOutputWindowReporter(const ContextOptions& co) + : ConsoleReporter(co, oss) {} + +#define DOCTEST_DEBUG_OUTPUT_REPORTER_OVERRIDE(func, type, arg) \ + void func(type arg) override { \ + bool with_col = g_no_colors; \ + g_no_colors = false; \ + ConsoleReporter::func(arg); \ + if(oss.tellp() != std::streampos{}) { \ + DOCTEST_OUTPUT_DEBUG_STRING(oss.str().c_str()); \ + oss.str(""); \ + } \ + g_no_colors = with_col; \ + } + + DOCTEST_DEBUG_OUTPUT_REPORTER_OVERRIDE(test_run_start, DOCTEST_EMPTY, DOCTEST_EMPTY) + DOCTEST_DEBUG_OUTPUT_REPORTER_OVERRIDE(test_run_end, const TestRunStats&, in) + DOCTEST_DEBUG_OUTPUT_REPORTER_OVERRIDE(test_case_start, const TestCaseData&, in) + DOCTEST_DEBUG_OUTPUT_REPORTER_OVERRIDE(test_case_reenter, const TestCaseData&, in) + DOCTEST_DEBUG_OUTPUT_REPORTER_OVERRIDE(test_case_end, const CurrentTestCaseStats&, in) + DOCTEST_DEBUG_OUTPUT_REPORTER_OVERRIDE(test_case_exception, const TestCaseException&, in) + DOCTEST_DEBUG_OUTPUT_REPORTER_OVERRIDE(subcase_start, const SubcaseSignature&, in) + DOCTEST_DEBUG_OUTPUT_REPORTER_OVERRIDE(subcase_end, DOCTEST_EMPTY, DOCTEST_EMPTY) + DOCTEST_DEBUG_OUTPUT_REPORTER_OVERRIDE(log_assert, const AssertData&, in) + DOCTEST_DEBUG_OUTPUT_REPORTER_OVERRIDE(log_message, const MessageData&, in) + DOCTEST_DEBUG_OUTPUT_REPORTER_OVERRIDE(test_case_skipped, const TestCaseData&, in) + }; + + DOCTEST_THREAD_LOCAL std::ostringstream DebugOutputWindowReporter::oss; +#endif // DOCTEST_PLATFORM_WINDOWS + + // the implementation of parseOption() + bool parseOptionImpl(int argc, const char* const* argv, const char* pattern, String* value) { + // going from the end to the beginning and stopping on the first occurrence from the end + for(int i = argc; i > 0; --i) { + auto index = i - 1; + auto temp = std::strstr(argv[index], pattern); + if(temp && (value || strlen(temp) == strlen(pattern))) { //!OCLINT prefer early exits and continue + // eliminate matches in which the chars before the option are not '-' + bool noBadCharsFound = true; + auto curr = argv[index]; + while(curr != temp) { + if(*curr++ != '-') { + noBadCharsFound = false; + break; + } + } + if(noBadCharsFound && argv[index][0] == '-') { + if(value) { + // parsing the value of an option + temp += strlen(pattern); + const unsigned len = strlen(temp); + if(len) { + *value = temp; + return true; + } + } else { + // just a flag - no value + return true; + } + } + } + } + return false; + } + + // parses an option and returns the string after the '=' character + bool parseOption(int argc, const char* const* argv, const char* pattern, String* value = nullptr, + const String& defaultVal = String()) { + if(value) + *value = defaultVal; +#ifndef DOCTEST_CONFIG_NO_UNPREFIXED_OPTIONS + // offset (normally 3 for "dt-") to skip prefix + if(parseOptionImpl(argc, argv, pattern + strlen(DOCTEST_CONFIG_OPTIONS_PREFIX), value)) + return true; +#endif // DOCTEST_CONFIG_NO_UNPREFIXED_OPTIONS + return parseOptionImpl(argc, argv, pattern, value); + } + + // locates a flag on the command line + bool parseFlag(int argc, const char* const* argv, const char* pattern) { + return parseOption(argc, argv, pattern); + } + + // parses a comma separated list of words after a pattern in one of the arguments in argv + bool parseCommaSepArgs(int argc, const char* const* argv, const char* pattern, + std::vector& res) { + String filtersString; + if(parseOption(argc, argv, pattern, &filtersString)) { + // tokenize with "," as a separator, unless escaped with backslash + std::ostringstream s; + auto flush = [&s, &res]() { + auto string = s.str(); + if(string.size() > 0) { + res.push_back(string.c_str()); + } + s.str(""); + }; + + bool seenBackslash = false; + const char* current = filtersString.c_str(); + const char* end = current + strlen(current); + while(current != end) { + char character = *current++; + if(seenBackslash) { + seenBackslash = false; + if(character == ',' || character == '\\') { + s.put(character); + continue; + } + s.put('\\'); + } + if(character == '\\') { + seenBackslash = true; + } else if(character == ',') { + flush(); + } else { + s.put(character); + } + } + + if(seenBackslash) { + s.put('\\'); + } + flush(); + return true; + } + return false; + } + + enum optionType + { + option_bool, + option_int + }; + + // parses an int/bool option from the command line + bool parseIntOption(int argc, const char* const* argv, const char* pattern, optionType type, + int& res) { + String parsedValue; + if(!parseOption(argc, argv, pattern, &parsedValue)) + return false; + + if(type) { + // integer + // TODO: change this to use std::stoi or something else! currently it uses undefined behavior - assumes '0' on failed parse... + int theInt = std::atoi(parsedValue.c_str()); + if (theInt != 0) { + res = theInt; //!OCLINT parameter reassignment + return true; + } + } else { + // boolean + const char positive[][5] = { "1", "true", "on", "yes" }; // 5 - strlen("true") + 1 + const char negative[][6] = { "0", "false", "off", "no" }; // 6 - strlen("false") + 1 + + // if the value matches any of the positive/negative possibilities + for (unsigned i = 0; i < 4; i++) { + if (parsedValue.compare(positive[i], true) == 0) { + res = 1; //!OCLINT parameter reassignment + return true; + } + if (parsedValue.compare(negative[i], true) == 0) { + res = 0; //!OCLINT parameter reassignment + return true; + } + } + } + return false; + } +} // namespace + +Context::Context(int argc, const char* const* argv) + : p(new detail::ContextState) { + parseArgs(argc, argv, true); + if(argc) + p->binary_name = argv[0]; +} + +Context::~Context() { + if(g_cs == p) + g_cs = nullptr; + delete p; +} + +void Context::applyCommandLine(int argc, const char* const* argv) { + parseArgs(argc, argv); + if(argc) + p->binary_name = argv[0]; +} + +// parses args +void Context::parseArgs(int argc, const char* const* argv, bool withDefaults) { + using namespace detail; + + // clang-format off + parseCommaSepArgs(argc, argv, DOCTEST_CONFIG_OPTIONS_PREFIX "source-file=", p->filters[0]); + parseCommaSepArgs(argc, argv, DOCTEST_CONFIG_OPTIONS_PREFIX "sf=", p->filters[0]); + parseCommaSepArgs(argc, argv, DOCTEST_CONFIG_OPTIONS_PREFIX "source-file-exclude=",p->filters[1]); + parseCommaSepArgs(argc, argv, DOCTEST_CONFIG_OPTIONS_PREFIX "sfe=", p->filters[1]); + parseCommaSepArgs(argc, argv, DOCTEST_CONFIG_OPTIONS_PREFIX "test-suite=", p->filters[2]); + parseCommaSepArgs(argc, argv, DOCTEST_CONFIG_OPTIONS_PREFIX "ts=", p->filters[2]); + parseCommaSepArgs(argc, argv, DOCTEST_CONFIG_OPTIONS_PREFIX "test-suite-exclude=", p->filters[3]); + parseCommaSepArgs(argc, argv, DOCTEST_CONFIG_OPTIONS_PREFIX "tse=", p->filters[3]); + parseCommaSepArgs(argc, argv, DOCTEST_CONFIG_OPTIONS_PREFIX "test-case=", p->filters[4]); + parseCommaSepArgs(argc, argv, DOCTEST_CONFIG_OPTIONS_PREFIX "tc=", p->filters[4]); + parseCommaSepArgs(argc, argv, DOCTEST_CONFIG_OPTIONS_PREFIX "test-case-exclude=", p->filters[5]); + parseCommaSepArgs(argc, argv, DOCTEST_CONFIG_OPTIONS_PREFIX "tce=", p->filters[5]); + parseCommaSepArgs(argc, argv, DOCTEST_CONFIG_OPTIONS_PREFIX "subcase=", p->filters[6]); + parseCommaSepArgs(argc, argv, DOCTEST_CONFIG_OPTIONS_PREFIX "sc=", p->filters[6]); + parseCommaSepArgs(argc, argv, DOCTEST_CONFIG_OPTIONS_PREFIX "subcase-exclude=", p->filters[7]); + parseCommaSepArgs(argc, argv, DOCTEST_CONFIG_OPTIONS_PREFIX "sce=", p->filters[7]); + parseCommaSepArgs(argc, argv, DOCTEST_CONFIG_OPTIONS_PREFIX "reporters=", p->filters[8]); + parseCommaSepArgs(argc, argv, DOCTEST_CONFIG_OPTIONS_PREFIX "r=", p->filters[8]); + // clang-format on + + int intRes = 0; + String strRes; + +#define DOCTEST_PARSE_AS_BOOL_OR_FLAG(name, sname, var, default) \ + if(parseIntOption(argc, argv, DOCTEST_CONFIG_OPTIONS_PREFIX name "=", option_bool, intRes) || \ + parseIntOption(argc, argv, DOCTEST_CONFIG_OPTIONS_PREFIX sname "=", option_bool, intRes)) \ + p->var = static_cast(intRes); \ + else if(parseFlag(argc, argv, DOCTEST_CONFIG_OPTIONS_PREFIX name) || \ + parseFlag(argc, argv, DOCTEST_CONFIG_OPTIONS_PREFIX sname)) \ + p->var = true; \ + else if(withDefaults) \ + p->var = default + +#define DOCTEST_PARSE_INT_OPTION(name, sname, var, default) \ + if(parseIntOption(argc, argv, DOCTEST_CONFIG_OPTIONS_PREFIX name "=", option_int, intRes) || \ + parseIntOption(argc, argv, DOCTEST_CONFIG_OPTIONS_PREFIX sname "=", option_int, intRes)) \ + p->var = intRes; \ + else if(withDefaults) \ + p->var = default + +#define DOCTEST_PARSE_STR_OPTION(name, sname, var, default) \ + if(parseOption(argc, argv, DOCTEST_CONFIG_OPTIONS_PREFIX name "=", &strRes, default) || \ + parseOption(argc, argv, DOCTEST_CONFIG_OPTIONS_PREFIX sname "=", &strRes, default) || \ + withDefaults) \ + p->var = strRes + + // clang-format off + DOCTEST_PARSE_STR_OPTION("out", "o", out, ""); + DOCTEST_PARSE_STR_OPTION("order-by", "ob", order_by, "file"); + DOCTEST_PARSE_INT_OPTION("rand-seed", "rs", rand_seed, 0); + + DOCTEST_PARSE_INT_OPTION("first", "f", first, 0); + DOCTEST_PARSE_INT_OPTION("last", "l", last, UINT_MAX); + + DOCTEST_PARSE_INT_OPTION("abort-after", "aa", abort_after, 0); + DOCTEST_PARSE_INT_OPTION("subcase-filter-levels", "scfl", subcase_filter_levels, INT_MAX); + + DOCTEST_PARSE_AS_BOOL_OR_FLAG("success", "s", success, false); + DOCTEST_PARSE_AS_BOOL_OR_FLAG("case-sensitive", "cs", case_sensitive, false); + DOCTEST_PARSE_AS_BOOL_OR_FLAG("exit", "e", exit, false); + DOCTEST_PARSE_AS_BOOL_OR_FLAG("duration", "d", duration, false); + DOCTEST_PARSE_AS_BOOL_OR_FLAG("minimal", "m", minimal, false); + DOCTEST_PARSE_AS_BOOL_OR_FLAG("quiet", "q", quiet, false); + DOCTEST_PARSE_AS_BOOL_OR_FLAG("no-throw", "nt", no_throw, false); + DOCTEST_PARSE_AS_BOOL_OR_FLAG("no-exitcode", "ne", no_exitcode, false); + DOCTEST_PARSE_AS_BOOL_OR_FLAG("no-run", "nr", no_run, false); + DOCTEST_PARSE_AS_BOOL_OR_FLAG("no-intro", "ni", no_intro, false); + DOCTEST_PARSE_AS_BOOL_OR_FLAG("no-version", "nv", no_version, false); + DOCTEST_PARSE_AS_BOOL_OR_FLAG("no-colors", "nc", no_colors, false); + DOCTEST_PARSE_AS_BOOL_OR_FLAG("force-colors", "fc", force_colors, false); + DOCTEST_PARSE_AS_BOOL_OR_FLAG("no-breaks", "nb", no_breaks, false); + DOCTEST_PARSE_AS_BOOL_OR_FLAG("no-skip", "ns", no_skip, false); + DOCTEST_PARSE_AS_BOOL_OR_FLAG("gnu-file-line", "gfl", gnu_file_line, !bool(DOCTEST_MSVC)); + DOCTEST_PARSE_AS_BOOL_OR_FLAG("no-path-filenames", "npf", no_path_in_filenames, false); + DOCTEST_PARSE_AS_BOOL_OR_FLAG("no-line-numbers", "nln", no_line_numbers, false); + DOCTEST_PARSE_AS_BOOL_OR_FLAG("no-debug-output", "ndo", no_debug_output, false); + DOCTEST_PARSE_AS_BOOL_OR_FLAG("no-skipped-summary", "nss", no_skipped_summary, false); + DOCTEST_PARSE_AS_BOOL_OR_FLAG("no-time-in-output", "ntio", no_time_in_output, false); + // clang-format on + + if(withDefaults) { + p->help = false; + p->version = false; + p->count = false; + p->list_test_cases = false; + p->list_test_suites = false; + p->list_reporters = false; + } + if(parseFlag(argc, argv, DOCTEST_CONFIG_OPTIONS_PREFIX "help") || + parseFlag(argc, argv, DOCTEST_CONFIG_OPTIONS_PREFIX "h") || + parseFlag(argc, argv, DOCTEST_CONFIG_OPTIONS_PREFIX "?")) { + p->help = true; + p->exit = true; + } + if(parseFlag(argc, argv, DOCTEST_CONFIG_OPTIONS_PREFIX "version") || + parseFlag(argc, argv, DOCTEST_CONFIG_OPTIONS_PREFIX "v")) { + p->version = true; + p->exit = true; + } + if(parseFlag(argc, argv, DOCTEST_CONFIG_OPTIONS_PREFIX "count") || + parseFlag(argc, argv, DOCTEST_CONFIG_OPTIONS_PREFIX "c")) { + p->count = true; + p->exit = true; + } + if(parseFlag(argc, argv, DOCTEST_CONFIG_OPTIONS_PREFIX "list-test-cases") || + parseFlag(argc, argv, DOCTEST_CONFIG_OPTIONS_PREFIX "ltc")) { + p->list_test_cases = true; + p->exit = true; + } + if(parseFlag(argc, argv, DOCTEST_CONFIG_OPTIONS_PREFIX "list-test-suites") || + parseFlag(argc, argv, DOCTEST_CONFIG_OPTIONS_PREFIX "lts")) { + p->list_test_suites = true; + p->exit = true; + } + if(parseFlag(argc, argv, DOCTEST_CONFIG_OPTIONS_PREFIX "list-reporters") || + parseFlag(argc, argv, DOCTEST_CONFIG_OPTIONS_PREFIX "lr")) { + p->list_reporters = true; + p->exit = true; + } +} + +// allows the user to add procedurally to the filters from the command line +void Context::addFilter(const char* filter, const char* value) { setOption(filter, value); } + +// allows the user to clear all filters from the command line +void Context::clearFilters() { + for(auto& curr : p->filters) + curr.clear(); +} + +// allows the user to override procedurally the bool options from the command line +void Context::setOption(const char* option, bool value) { + setOption(option, value ? "true" : "false"); +} + +// allows the user to override procedurally the int options from the command line +void Context::setOption(const char* option, int value) { + setOption(option, toString(value).c_str()); +} + +// allows the user to override procedurally the string options from the command line +void Context::setOption(const char* option, const char* value) { + auto argv = String("-") + option + "=" + value; + auto lvalue = argv.c_str(); + parseArgs(1, &lvalue); +} + +// users should query this in their main() and exit the program if true +bool Context::shouldExit() { return p->exit; } + +void Context::setAsDefaultForAssertsOutOfTestCases() { g_cs = p; } + +void Context::setAssertHandler(detail::assert_handler ah) { p->ah = ah; } + +void Context::setCout(std::ostream* out) { p->cout = out; } + +static class DiscardOStream : public std::ostream +{ +private: + class : public std::streambuf + { + private: + // allowing some buffering decreases the amount of calls to overflow + char buf[1024]; + + protected: + std::streamsize xsputn(const char_type*, std::streamsize count) override { return count; } + + int_type overflow(int_type ch) override { + setp(std::begin(buf), std::end(buf)); + return traits_type::not_eof(ch); + } + } discardBuf; + +public: + DiscardOStream() + : std::ostream(&discardBuf) {} +} discardOut; + +// the main function that does all the filtering and test running +int Context::run() { + using namespace detail; + + // save the old context state in case such was setup - for using asserts out of a testing context + auto old_cs = g_cs; + // this is the current contest + g_cs = p; + is_running_in_test = true; + + g_no_colors = p->no_colors; + p->resetRunData(); + + std::fstream fstr; + if(p->cout == nullptr) { + if(p->quiet) { + p->cout = &discardOut; + } else if(p->out.size()) { + // to a file if specified + fstr.open(p->out.c_str(), std::fstream::out); + p->cout = &fstr; + } else { +#ifndef DOCTEST_CONFIG_NO_INCLUDE_IOSTREAM + // stdout by default + p->cout = &std::cout; +#else // DOCTEST_CONFIG_NO_INCLUDE_IOSTREAM + return EXIT_FAILURE; +#endif // DOCTEST_CONFIG_NO_INCLUDE_IOSTREAM + } + } + + FatalConditionHandler::allocateAltStackMem(); + + auto cleanup_and_return = [&]() { + FatalConditionHandler::freeAltStackMem(); + + if(fstr.is_open()) + fstr.close(); + + // restore context + g_cs = old_cs; + is_running_in_test = false; + + // we have to free the reporters which were allocated when the run started + for(auto& curr : p->reporters_currently_used) + delete curr; + p->reporters_currently_used.clear(); + + if(p->numTestCasesFailed && !p->no_exitcode) + return EXIT_FAILURE; + return EXIT_SUCCESS; + }; + + // setup default reporter if none is given through the command line + if(p->filters[8].empty()) + p->filters[8].push_back("console"); + + // check to see if any of the registered reporters has been selected + for(auto& curr : getReporters()) { + if(matchesAny(curr.first.second.c_str(), p->filters[8], false, p->case_sensitive)) + p->reporters_currently_used.push_back(curr.second(*g_cs)); + } + + // TODO: check if there is nothing in reporters_currently_used + + // prepend all listeners + for(auto& curr : getListeners()) + p->reporters_currently_used.insert(p->reporters_currently_used.begin(), curr.second(*g_cs)); + +#ifdef DOCTEST_PLATFORM_WINDOWS + if(isDebuggerActive() && p->no_debug_output == false) + p->reporters_currently_used.push_back(new DebugOutputWindowReporter(*g_cs)); +#endif // DOCTEST_PLATFORM_WINDOWS + + // handle version, help and no_run + if(p->no_run || p->version || p->help || p->list_reporters) { + DOCTEST_ITERATE_THROUGH_REPORTERS(report_query, QueryData()); + + return cleanup_and_return(); + } + + std::vector testArray; + for(auto& curr : getRegisteredTests()) + testArray.push_back(&curr); + p->numTestCases = testArray.size(); + + // sort the collected records + if(!testArray.empty()) { + if(p->order_by.compare("file", true) == 0) { + std::sort(testArray.begin(), testArray.end(), fileOrderComparator); + } else if(p->order_by.compare("suite", true) == 0) { + std::sort(testArray.begin(), testArray.end(), suiteOrderComparator); + } else if(p->order_by.compare("name", true) == 0) { + std::sort(testArray.begin(), testArray.end(), nameOrderComparator); + } else if(p->order_by.compare("rand", true) == 0) { + std::srand(p->rand_seed); + + // random_shuffle implementation + const auto first = &testArray[0]; + for(size_t i = testArray.size() - 1; i > 0; --i) { + int idxToSwap = std::rand() % (i + 1); + + const auto temp = first[i]; + + first[i] = first[idxToSwap]; + first[idxToSwap] = temp; + } + } else if(p->order_by.compare("none", true) == 0) { + // means no sorting - beneficial for death tests which call into the executable + // with a specific test case in mind - we don't want to slow down the startup times + } + } + + std::set testSuitesPassingFilt; + + bool query_mode = p->count || p->list_test_cases || p->list_test_suites; + std::vector queryResults; + + if(!query_mode) + DOCTEST_ITERATE_THROUGH_REPORTERS(test_run_start, DOCTEST_EMPTY); + + // invoke the registered functions if they match the filter criteria (or just count them) + for(auto& curr : testArray) { + const auto& tc = *curr; + + bool skip_me = false; + if(tc.m_skip && !p->no_skip) + skip_me = true; + + if(!matchesAny(tc.m_file.c_str(), p->filters[0], true, p->case_sensitive)) + skip_me = true; + if(matchesAny(tc.m_file.c_str(), p->filters[1], false, p->case_sensitive)) + skip_me = true; + if(!matchesAny(tc.m_test_suite, p->filters[2], true, p->case_sensitive)) + skip_me = true; + if(matchesAny(tc.m_test_suite, p->filters[3], false, p->case_sensitive)) + skip_me = true; + if(!matchesAny(tc.m_name, p->filters[4], true, p->case_sensitive)) + skip_me = true; + if(matchesAny(tc.m_name, p->filters[5], false, p->case_sensitive)) + skip_me = true; + + if(!skip_me) + p->numTestCasesPassingFilters++; + + // skip the test if it is not in the execution range + if((p->last < p->numTestCasesPassingFilters && p->first <= p->last) || + (p->first > p->numTestCasesPassingFilters)) + skip_me = true; + + if(skip_me) { + if(!query_mode) + DOCTEST_ITERATE_THROUGH_REPORTERS(test_case_skipped, tc); + continue; + } + + // do not execute the test if we are to only count the number of filter passing tests + if(p->count) + continue; + + // print the name of the test and don't execute it + if(p->list_test_cases) { + queryResults.push_back(&tc); + continue; + } + + // print the name of the test suite if not done already and don't execute it + if(p->list_test_suites) { + if((testSuitesPassingFilt.count(tc.m_test_suite) == 0) && tc.m_test_suite[0] != '\0') { + queryResults.push_back(&tc); + testSuitesPassingFilt.insert(tc.m_test_suite); + p->numTestSuitesPassingFilters++; + } + continue; + } + + // execute the test if it passes all the filtering + { + p->currentTest = &tc; + + p->failure_flags = TestCaseFailureReason::None; + p->seconds = 0; + + // reset atomic counters + p->numAssertsFailedCurrentTest_atomic = 0; + p->numAssertsCurrentTest_atomic = 0; + + p->fullyTraversedSubcases.clear(); + + DOCTEST_ITERATE_THROUGH_REPORTERS(test_case_start, tc); + + p->timer.start(); + + bool run_test = true; + + do { + // reset some of the fields for subcases (except for the set of fully passed ones) + p->reachedLeaf = false; + // May not be empty if previous subcase exited via exception. + p->subcaseStack.clear(); + p->currentSubcaseDepth = 0; + + p->shouldLogCurrentException = true; + + // reset stuff for logging with INFO() + p->stringifiedContexts.clear(); + +#ifndef DOCTEST_CONFIG_NO_EXCEPTIONS + try { +#endif // DOCTEST_CONFIG_NO_EXCEPTIONS +// MSVC 2015 diagnoses fatalConditionHandler as unused (because reset() is a static method) +DOCTEST_MSVC_SUPPRESS_WARNING_WITH_PUSH(4101) // unreferenced local variable + FatalConditionHandler fatalConditionHandler; // Handle signals + // execute the test + tc.m_test(); + fatalConditionHandler.reset(); +DOCTEST_MSVC_SUPPRESS_WARNING_POP +#ifndef DOCTEST_CONFIG_NO_EXCEPTIONS + } catch(const TestFailureException&) { + p->failure_flags |= TestCaseFailureReason::AssertFailure; + } catch(...) { + DOCTEST_ITERATE_THROUGH_REPORTERS(test_case_exception, + {translateActiveException(), false}); + p->failure_flags |= TestCaseFailureReason::Exception; + } +#endif // DOCTEST_CONFIG_NO_EXCEPTIONS + + // exit this loop if enough assertions have failed - even if there are more subcases + if(p->abort_after > 0 && + p->numAssertsFailed + p->numAssertsFailedCurrentTest_atomic >= p->abort_after) { + run_test = false; + p->failure_flags |= TestCaseFailureReason::TooManyFailedAsserts; + } + + if(!p->nextSubcaseStack.empty() && run_test) + DOCTEST_ITERATE_THROUGH_REPORTERS(test_case_reenter, tc); + if(p->nextSubcaseStack.empty()) + run_test = false; + } while(run_test); + + p->finalizeTestCaseData(); + + DOCTEST_ITERATE_THROUGH_REPORTERS(test_case_end, *g_cs); + + p->currentTest = nullptr; + + // stop executing tests if enough assertions have failed + if(p->abort_after > 0 && p->numAssertsFailed >= p->abort_after) + break; + } + } + + if(!query_mode) { + DOCTEST_ITERATE_THROUGH_REPORTERS(test_run_end, *g_cs); + } else { + QueryData qdata; + qdata.run_stats = g_cs; + qdata.data = queryResults.data(); + qdata.num_data = unsigned(queryResults.size()); + DOCTEST_ITERATE_THROUGH_REPORTERS(report_query, qdata); + } + + return cleanup_and_return(); +} + +DOCTEST_DEFINE_INTERFACE(IReporter) + +int IReporter::get_num_active_contexts() { return detail::g_infoContexts.size(); } +const IContextScope* const* IReporter::get_active_contexts() { + return get_num_active_contexts() ? &detail::g_infoContexts[0] : nullptr; +} + +int IReporter::get_num_stringified_contexts() { return detail::g_cs->stringifiedContexts.size(); } +const String* IReporter::get_stringified_contexts() { + return get_num_stringified_contexts() ? &detail::g_cs->stringifiedContexts[0] : nullptr; +} + +namespace detail { + void registerReporterImpl(const char* name, int priority, reporterCreatorFunc c, bool isReporter) { + if(isReporter) + getReporters().insert(reporterMap::value_type(reporterMap::key_type(priority, name), c)); + else + getListeners().insert(reporterMap::value_type(reporterMap::key_type(priority, name), c)); + } +} // namespace detail + +} // namespace doctest + +#endif // DOCTEST_CONFIG_DISABLE + +#ifdef DOCTEST_CONFIG_IMPLEMENT_WITH_MAIN +DOCTEST_MSVC_SUPPRESS_WARNING_WITH_PUSH(4007) // 'function' : must be 'attribute' - see issue #182 +int main(int argc, char** argv) { return doctest::Context(argc, argv).run(); } +DOCTEST_MSVC_SUPPRESS_WARNING_POP +#endif // DOCTEST_CONFIG_IMPLEMENT_WITH_MAIN + +DOCTEST_CLANG_SUPPRESS_WARNING_POP +DOCTEST_MSVC_SUPPRESS_WARNING_POP +DOCTEST_GCC_SUPPRESS_WARNING_POP + +DOCTEST_SUPPRESS_COMMON_WARNINGS_POP + +#endif // DOCTEST_LIBRARY_IMPLEMENTATION +#endif // DOCTEST_CONFIG_IMPLEMENT + +#ifdef DOCTEST_UNDEF_WIN32_LEAN_AND_MEAN +#undef WIN32_LEAN_AND_MEAN +#undef DOCTEST_UNDEF_WIN32_LEAN_AND_MEAN +#endif // DOCTEST_UNDEF_WIN32_LEAN_AND_MEAN + +#ifdef DOCTEST_UNDEF_NOMINMAX +#undef NOMINMAX +#undef DOCTEST_UNDEF_NOMINMAX +#endif // DOCTEST_UNDEF_NOMINMAX diff --git a/dmff/dpnblist/external/doctest-2.4.11/doctest/extensions/doctest_mpi.h b/dmff/dpnblist/external/doctest-2.4.11/doctest/extensions/doctest_mpi.h new file mode 100644 index 00000000..ce969526 --- /dev/null +++ b/dmff/dpnblist/external/doctest-2.4.11/doctest/extensions/doctest_mpi.h @@ -0,0 +1,169 @@ +#ifndef DOCTEST_MPI_H +#define DOCTEST_MPI_H + +#ifdef DOCTEST_CONFIG_IMPLEMENT + +#include "doctest/extensions/mpi_sub_comm.h" +#include "mpi_reporter.h" +#include + +namespace doctest { + +// Each time a MPI_TEST_CASE is executed on N procs, +// we need a sub-communicator of N procs to execute it. +// It is then registered here and can be re-used +// by other tests that requires a sub-comm of the same size +std::unordered_map sub_comms_by_size; + +// Record if at least one MPI_TEST_CASE was registered "skipped" +// because there is not enought procs to execute it +int nb_test_cases_skipped_insufficient_procs = 0; + + +std::string thread_level_to_string(int thread_lvl); +int mpi_init_thread(int argc, char *argv[], int required_thread_support); +void mpi_finalize(); + + +// Can be safely called before MPI_Init() +// This is needed for MPI_TEST_CASE because we use doctest::skip() +// to prevent execution of tests where there is not enough procs, +// but doctest::skip() is called during test registration, that is, before main(), and hence before MPI_Init() +int mpi_comm_world_size() { + #if defined(OPEN_MPI) + const char* size_str = std::getenv("OMPI_COMM_WORLD_SIZE"); + #elif defined(I_MPI_VERSION) || defined(MPI_VERSION) // Intel MPI + MPICH (at least) + const char* size_str = std::getenv("PMI_SIZE"); // see https://community.intel.com/t5/Intel-oneAPI-HPC-Toolkit/Environment-variables-defined-by-intel-mpirun/td-p/1096703 + #else + #error "Unknown MPI implementation: please submit an issue or a PR to doctest. Meanwhile, you can look at the output of e.g. `mpirun -np 3 env` to search for an environnement variable that contains the size of MPI_COMM_WORLD and extend this code accordingly" + #endif + if (size_str==nullptr) return 1; // not launched with mpirun/mpiexec, so assume only one process + return std::stoi(size_str); +} + +// Record size of MPI_COMM_WORLD with mpi_comm_world_size() +int world_size_before_init = mpi_comm_world_size(); + + +std::string thread_level_to_string(int thread_lvl) { + switch (thread_lvl) { + case MPI_THREAD_SINGLE: return "MPI_THREAD_SINGLE"; + case MPI_THREAD_FUNNELED: return "MPI_THREAD_FUNNELED"; + case MPI_THREAD_SERIALIZED: return "MPI_THREAD_SERIALIZED"; + case MPI_THREAD_MULTIPLE: return "MPI_THREAD_MULTIPLE"; + default: return "Invalid MPI thread level"; + } +} +int mpi_init_thread(int argc, char *argv[], int required_thread_support) { + int provided_thread_support; + MPI_Init_thread(&argc, &argv, required_thread_support, &provided_thread_support); + + int world_size; + MPI_Comm_size(MPI_COMM_WORLD,&world_size); + if (world_size_before_init != world_size) { + DOCTEST_INTERNAL_ERROR( + "doctest found "+std::to_string(world_size_before_init)+" MPI processes before `MPI_Init_thread`," + " but MPI_COMM_WORLD is actually of size "+std::to_string(world_size)+".\n" + "This is most likely due to your MPI implementation not being well supported by doctest. Please report this issue on GitHub" + ); + } + + if (provided_thread_support!=required_thread_support) { + std::cout << + "WARNING: " + thread_level_to_string(required_thread_support) + " was asked, " + + "but only " + thread_level_to_string(provided_thread_support) + " is provided by the MPI library\n"; + } + return provided_thread_support; +} +void mpi_finalize() { + // We need to destroy all created sub-communicators before calling MPI_Finalize() + doctest::sub_comms_by_size.clear(); + MPI_Finalize(); +} + +} // doctest + +#else // DOCTEST_CONFIG_IMPLEMENT + +#include "doctest/extensions/mpi_sub_comm.h" +#include +#include + +namespace doctest { + +extern std::unordered_map sub_comms_by_size; +extern int nb_test_cases_skipped_insufficient_procs; +extern int world_size_before_init; +int mpi_comm_world_size(); + +int mpi_init_thread(int argc, char *argv[], int required_thread_support); +void mpi_finalize(); + +template +void execute_mpi_test_case(F func) { + auto it = sub_comms_by_size.find(nb_procs); + if (it==end(sub_comms_by_size)) { + bool was_emplaced = false; + std::tie(it,was_emplaced) = sub_comms_by_size.emplace(std::make_pair(nb_procs,mpi_sub_comm(nb_procs))); + assert(was_emplaced); + } + const mpi_sub_comm& sub = it->second; + if (sub.comm != MPI_COMM_NULL) { + func(sub.rank,nb_procs,sub.comm,std::integral_constant{}); + }; +} + +inline bool +insufficient_procs(int test_nb_procs) { + static const int world_size = mpi_comm_world_size(); + bool insufficient = test_nb_procs>world_size; + if (insufficient) { + ++nb_test_cases_skipped_insufficient_procs; + } + return insufficient; +} + +} // doctest + + +#define DOCTEST_MPI_GEN_ASSERTION(rank_to_test, assertion, ...) \ + static_assert(rank_to_test); \ + TEST_CASE(name * doctest::description("MPI_TEST_CASE") * doctest::skip(doctest::insufficient_procs(nb_procs))) { \ + doctest::execute_mpi_test_case(func); \ + } \ + static void func(DOCTEST_UNUSED int test_rank, DOCTEST_UNUSED int test_nb_procs, DOCTEST_UNUSED MPI_Comm test_comm, DOCTEST_UNUSED std::integral_constant test_nb_procs_as_int_constant) + // DOC: test_rank, test_nb_procs, and test_comm are available UNDER THESE SPECIFIC NAMES in the body of the unit test + // DOC: test_nb_procs_as_int_constant is equal to test_nb_procs, but as a compile time value + // (used in CHECK-like macros to assert the checked rank exists) + +#define DOCTEST_MPI_TEST_CASE(name,nb_procs) \ + DOCTEST_CREATE_MPI_TEST_CASE(name,nb_procs,DOCTEST_ANONYMOUS(DOCTEST_MPI_FUNC)) + + +// == SHORT VERSIONS OF THE MACROS +#if !defined(DOCTEST_CONFIG_NO_SHORT_MACRO_NAMES) +#define MPI_WARN DOCTEST_MPI_WARN +#define MPI_CHECK DOCTEST_MPI_CHECK +#define MPI_REQUIRE DOCTEST_MPI_REQUIRE +#define MPI_WARN_FALSE DOCTEST_MPI_WARN_FALSE +#define MPI_CHECK_FALSE DOCTEST_MPI_CHECK_FALSE +#define MPI_REQUIRE_FALSE DOCTEST_MPI_REQUIRE_FALSE + +#define MPI_TEST_CASE DOCTEST_MPI_TEST_CASE +#endif // DOCTEST_CONFIG_NO_SHORT_MACRO_NAMES + + +#endif // DOCTEST_CONFIG_IMPLEMENT + +#endif // DOCTEST_MPI_H diff --git a/dmff/dpnblist/external/doctest-2.4.11/doctest/extensions/doctest_util.h b/dmff/dpnblist/external/doctest-2.4.11/doctest/extensions/doctest_util.h new file mode 100644 index 00000000..3e63ebc9 --- /dev/null +++ b/dmff/dpnblist/external/doctest-2.4.11/doctest/extensions/doctest_util.h @@ -0,0 +1,37 @@ +// +// doctest_util.h - an accompanying extensions header to the main doctest.h header +// +// Copyright (c) 2016-2023 Viktor Kirilov +// +// Distributed under the MIT Software License +// See accompanying file LICENSE.txt or copy at +// https://opensource.org/licenses/MIT +// +// The documentation can be found at the library's page: +// https://github.com/doctest/doctest/blob/master/doc/markdown/readme.md +// + +#ifndef DOCTEST_UTIL_H +#define DOCTEST_UTIL_H + +#ifndef DOCTEST_LIBRARY_INCLUDED +#include "../doctest.h" +#endif + +#include +#include +#include + +namespace doctest { + + inline void applyCommandLine(doctest::Context& ctx, const std::vector& args) { + auto doctest_args = std::make_unique(args.size()); + for (size_t i = 0; i < args.size(); ++i) { + doctest_args[i] = args[i].c_str(); + } + ctx.applyCommandLine(args.size(), doctest_args.get()); + } + +} // namespace doctest + +#endif // DOCTEST_UTIL_H diff --git a/dmff/dpnblist/external/doctest-2.4.11/doctest/extensions/mpi_reporter.h b/dmff/dpnblist/external/doctest-2.4.11/doctest/extensions/mpi_reporter.h new file mode 100644 index 00000000..19a43e00 --- /dev/null +++ b/dmff/dpnblist/external/doctest-2.4.11/doctest/extensions/mpi_reporter.h @@ -0,0 +1,271 @@ +#ifndef DOCTEST_MPI_REPORTER_H +#define DOCTEST_MPI_REPORTER_H + +// #include +#include +#include +#include "mpi.h" + + +#include +#include + +namespace doctest { + +extern int nb_test_cases_skipped_insufficient_procs; +int mpi_comm_world_size(); + +namespace { + +// https://stackoverflow.com/a/11826666/1583122 +struct NullBuffer : std::streambuf { + int overflow(int c) { return c; } +}; +class NullStream : public std::ostream { + public: + NullStream() + : std::ostream(&nullBuff) + {} + private: + NullBuffer nullBuff = {}; +}; +static NullStream nullStream; + + +/* \brief Extends the ConsoleReporter of doctest + * Each process writes its results to its own file + * Intended to be used when a test assertion fails and the user wants to know exactly what happens on which process + */ +struct MpiFileReporter : public ConsoleReporter { + std::ofstream logfile_stream = {}; + + MpiFileReporter(const ContextOptions& co) + : ConsoleReporter(co,logfile_stream) + { + int rank = 0; + MPI_Comm_rank(MPI_COMM_WORLD, &rank); + + std::string logfile_name = "doctest_" + std::to_string(rank) + ".log"; + + logfile_stream = std::ofstream(logfile_name.c_str(), std::fstream::out); + } +}; + + +/* \brief Extends the ConsoleReporter of doctest + * Allows to manage the execution of tests in a parallel framework + * All results are collected on rank 0 + */ +struct MpiConsoleReporter : public ConsoleReporter { +private: + static std::ostream& replace_by_null_if_not_rank_0(std::ostream* os) { + int rank = 0; + MPI_Comm_rank(MPI_COMM_WORLD, &rank); + if (rank==0) { + return *os; + } else { + return nullStream; + } + } + std::vector> m_failure_str_queue = {}; +public: + MpiConsoleReporter(const ContextOptions& co) + : ConsoleReporter(co,replace_by_null_if_not_rank_0(co.cout)) + {} + + std::string file_line_to_string(const char* file, int line, + const char* tail = ""){ + std::stringstream ss; + ss << skipPathFromFilename(file) + << (opt.gnu_file_line ? ":" : "(") + << (opt.no_line_numbers ? 0 : line) // 0 or the real num depending on the option + << (opt.gnu_file_line ? ":" : "):") << tail; + return ss.str(); + } + + void test_run_end(const TestRunStats& p) override { + ConsoleReporter::test_run_end(p); + + const bool anythingFailed = p.numTestCasesFailed > 0 || p.numAssertsFailed > 0; + + // ----------------------------------------------------- + // > Gather information in rank 0 + int n_rank, rank; + MPI_Comm_rank(MPI_COMM_WORLD, &rank); + MPI_Comm_size(MPI_COMM_WORLD, &n_rank); + + int g_numAsserts = 0; + int g_numAssertsFailed = 0; + int g_numTestCasesFailed = 0; + + MPI_Reduce(&p.numAsserts , &g_numAsserts , 1, MPI_INT, MPI_SUM, 0, MPI_COMM_WORLD); + MPI_Reduce(&p.numAssertsFailed , &g_numAssertsFailed , 1, MPI_INT, MPI_SUM, 0, MPI_COMM_WORLD); + MPI_Reduce(&p.numTestCasesFailed, &g_numTestCasesFailed, 1, MPI_INT, MPI_SUM, 0, MPI_COMM_WORLD); + + std::vector numAssertsFailedByRank; + if(rank == 0){ + numAssertsFailedByRank.resize(static_cast(n_rank)); + } + + MPI_Gather(&p.numAssertsFailed, 1, MPI_INT, numAssertsFailedByRank.data(), 1, MPI_INT, 0, MPI_COMM_WORLD); + + if(rank == 0) { + separator_to_stream(); + s << Color::Cyan << "[doctest] " << Color::None << "assertions on all processes: " << std::setw(6) + << g_numAsserts << " | " + << ((g_numAsserts == 0 || anythingFailed) ? Color::None : Color::Green) + << std::setw(6) << (g_numAsserts - g_numAssertsFailed) << " passed" << Color::None + << " | " << (g_numAssertsFailed > 0 ? Color::Red : Color::None) << std::setw(6) + << g_numAssertsFailed << " failed" << Color::None << " |\n"; + if (nb_test_cases_skipped_insufficient_procs>0) { + s << Color::Cyan << "[doctest] " << Color::Yellow << "WARNING: Skipped "; + if (nb_test_cases_skipped_insufficient_procs>1) { + s << nb_test_cases_skipped_insufficient_procs << " tests requiring more than "; + } else { + s << nb_test_cases_skipped_insufficient_procs << " test requiring more than "; + } + if (mpi_comm_world_size()>1) { + s << mpi_comm_world_size() << " MPI processes to run\n"; + } else { + s << mpi_comm_world_size() << " MPI process to run\n"; + } + } + + separator_to_stream(); + if(g_numAssertsFailed > 0){ + + s << Color::Cyan << "[doctest] " << Color::None << "fail on rank:" << std::setw(6) << "\n"; + for(std::size_t i = 0; i < numAssertsFailedByRank.size(); ++i){ + if( numAssertsFailedByRank[i] > 0 ){ + s << std::setw(16) << " -> On rank [" << i << "] with " << numAssertsFailedByRank[i] << " test failed" << std::endl; + } + } + } + s << Color::Cyan << "[doctest] " << Color::None + << "Status: " << (g_numTestCasesFailed > 0 ? Color::Red : Color::Green) + << ((g_numTestCasesFailed > 0) ? "FAILURE!" : "SUCCESS!") << Color::None << std::endl; + } + } + + void test_case_end(const CurrentTestCaseStats& st) override { + if (is_mpi_test_case()) { + // function called by every rank at the end of a test + // if failed assertions happened, they have been sent to rank 0 + // here rank zero gathers them and prints them all + + int rank; + MPI_Comm_rank(MPI_COMM_WORLD, &rank); + + std::vector requests; + requests.reserve(m_failure_str_queue.size()); // avoid realloc & copy of MPI_Request + for (const std::pair &failure : m_failure_str_queue) + { + const std::string & failure_str = failure.first; + const int failure_line = failure.second; + + int failure_msg_size = static_cast(failure_str.size()); + + requests.push_back(MPI_REQUEST_NULL); + MPI_Isend(failure_str.c_str(), failure_msg_size, MPI_BYTE, + 0, failure_line, MPI_COMM_WORLD, &requests.back()); // Tag = file line + } + + + // Compute the number of assert with fail among all procs + const int nb_fail_asserts = static_cast(m_failure_str_queue.size()); + int nb_fail_asserts_glob = 0; + MPI_Reduce(&nb_fail_asserts, &nb_fail_asserts_glob, 1, MPI_INT, MPI_SUM, 0, MPI_COMM_WORLD); + + if(rank == 0) { + MPI_Status status; + MPI_Status status_recv; + + using id_string = std::pair; + std::vector msgs(static_cast(nb_fail_asserts_glob)); + + for (std::size_t i=0; i(nb_fail_asserts_glob); ++i) { + MPI_Probe(MPI_ANY_SOURCE, MPI_ANY_TAG, MPI_COMM_WORLD, &status); + + int count; + MPI_Get_count(&status, MPI_BYTE, &count); + + std::string recv_msg(static_cast(count),'\0'); + void* recv_msg_data = const_cast(recv_msg.data()); // const_cast needed. Non-const .data() exists in C++11 though... + MPI_Recv(recv_msg_data, count, MPI_BYTE, status.MPI_SOURCE, + status.MPI_TAG, MPI_COMM_WORLD, &status_recv); + + msgs[i] = {status.MPI_SOURCE,recv_msg}; + } + + std::sort(begin(msgs),end(msgs),[](const id_string& x, const id_string& y){ return x.first < y.first; }); + + // print + if (nb_fail_asserts_glob>0) { + separator_to_stream(); + file_line_to_stream(tc->m_file.c_str(), static_cast(tc->m_line), "\n"); + if(tc->m_test_suite && tc->m_test_suite[0] != '\0') + s << Color::Yellow << "TEST SUITE: " << Color::None << tc->m_test_suite << "\n"; + if(strncmp(tc->m_name, " Scenario:", 11) != 0) + s << Color::Yellow << "TEST CASE: "; + s << Color::None << tc->m_name << "\n\n"; + for(const auto& msg : msgs) { + s << msg.second; + } + s << "\n"; + } + } + + MPI_Waitall(static_cast(requests.size()), requests.data(), MPI_STATUSES_IGNORE); + m_failure_str_queue.clear(); + } + + ConsoleReporter::test_case_end(st); + } + + bool is_mpi_test_case() const { + return tc->m_description != nullptr + && std::string(tc->m_description) == std::string("MPI_TEST_CASE"); + } + + void log_assert(const AssertData& rb) override { + if (!is_mpi_test_case()) { + ConsoleReporter::log_assert(rb); + } else { + int rank; + MPI_Comm_rank(MPI_COMM_WORLD, &rank); + + + if(!rb.m_failed && !opt.success) + return; + + std::lock_guard lock(mutex); + + std::stringstream failure_msg; + failure_msg << Color::Red << "On rank [" << rank << "] : " << Color::None; + failure_msg << file_line_to_string(rb.m_file, rb.m_line, " "); + + if((rb.m_at & (assertType::is_throws_as | assertType::is_throws_with)) ==0){ + failure_msg << Color::Cyan + << assertString(rb.m_at) + << "( " << rb.m_expr << " ) " + << Color::None + + << (!rb.m_failed ? "is correct!\n" : "is NOT correct!\n") + << " values: " + << assertString(rb.m_at) + << "( " << rb.m_decomp.c_str() << " )\n"; + } + + m_failure_str_queue.push_back({failure_msg.str(), rb.m_line}); + } + } +}; // MpiConsoleReporter + +// "1" is the priority - used for ordering when multiple reporters/listeners are used +REGISTER_REPORTER("MpiConsoleReporter", 1, MpiConsoleReporter); +REGISTER_REPORTER("MpiFileReporter", 1, MpiFileReporter); + +} // anonymous +} // doctest + +#endif // DOCTEST_REPORTER_H diff --git a/dmff/dpnblist/external/doctest-2.4.11/doctest/extensions/mpi_sub_comm.h b/dmff/dpnblist/external/doctest-2.4.11/doctest/extensions/mpi_sub_comm.h new file mode 100644 index 00000000..c030d74a --- /dev/null +++ b/dmff/dpnblist/external/doctest-2.4.11/doctest/extensions/mpi_sub_comm.h @@ -0,0 +1,84 @@ +#ifndef DOCTEST_MPI_SUB_COMM_H +#define DOCTEST_MPI_SUB_COMM_H + +#include "mpi.h" +#include "doctest/doctest.h" +#include +#include + +namespace doctest { + +inline +int mpi_world_nb_procs() { + int n; + MPI_Comm_size(MPI_COMM_WORLD, &n); + return n; +} + +struct mpi_sub_comm { + int nb_procs; + int rank; + MPI_Comm comm; + + mpi_sub_comm( mpi_sub_comm const& ) = delete; + mpi_sub_comm& operator=( mpi_sub_comm const& ) = delete; + + mpi_sub_comm(int nb_prcs) noexcept + : nb_procs(nb_prcs) + , rank(-1) + , comm(MPI_COMM_NULL) + { + int comm_world_rank; + MPI_Comm_rank(MPI_COMM_WORLD, &comm_world_rank); + if (nb_procs>mpi_world_nb_procs()) { + if (comm_world_rank==0) { + MESSAGE( + "Unable to run test: need ", std::to_string(nb_procs), " procs", + " but program launched with only ", std::to_string(doctest::mpi_world_nb_procs()), "." + ); + CHECK(nb_procs<=mpi_world_nb_procs()); + } + } else { + int color = MPI_UNDEFINED; + if(comm_world_rank < nb_procs){ + color = 0; + } + MPI_Comm_split(MPI_COMM_WORLD, color, comm_world_rank, &comm); + + if(comm != MPI_COMM_NULL){ + MPI_Comm_rank(comm, &rank); + assert(rank==comm_world_rank); + } + } + } + + void destroy_comm() { + if(comm != MPI_COMM_NULL){ + MPI_Comm_free(&comm); + } + } + + mpi_sub_comm(mpi_sub_comm&& x) + : nb_procs(x.nb_procs) + , rank(x.rank) + , comm(x.comm) + { + x.comm = MPI_COMM_NULL; + } + mpi_sub_comm& operator=(mpi_sub_comm&& x) { + destroy_comm(); + nb_procs = x.nb_procs; + rank = x.rank; + comm = x.comm; + x.comm = MPI_COMM_NULL; + return *this; + } + + ~mpi_sub_comm() { + destroy_comm(); + } +}; + +} // doctest + +#endif // DOCTEST_SUB_COMM_H diff --git a/dmff/dpnblist/external/doctest-2.4.11/examples/all_features/CMakeLists.txt b/dmff/dpnblist/external/doctest-2.4.11/examples/all_features/CMakeLists.txt new file mode 100644 index 00000000..ebc75c25 --- /dev/null +++ b/dmff/dpnblist/external/doctest-2.4.11/examples/all_features/CMakeLists.txt @@ -0,0 +1,154 @@ +################################################################################ +## BUILD ALL EXAMPLE SOURCES INTO A SINGLE BINARY AND EXECUTE TESTS ON EACH FILE +################################################################################ + +set(files_with_output + main.cpp + doctest_proxy.h + header.h + alternative_macros.cpp + assertion_macros.cpp + stringification.cpp + double_stringification.cpp + reporters_and_listeners.cpp + subcases.cpp + logging.cpp + templated_test_cases.cpp + test_cases_and_suites.cpp + asserts_used_outside_of_tests.cpp + enums.cpp + decomposition.cpp +) + +set(files_all + ${files_with_output} + concurrency.cpp + coverage_maxout.cpp + namespace1.cpp + namespace2.cpp + namespace3.cpp + namespace4.cpp + namespace5.cpp + namespace6.cpp + namespace7.cpp + namespace8.cpp + namespace9.cpp + no_failures.cpp +) + +# add the executable +add_executable(all_features ${files_all}) +target_link_libraries(all_features doctest ${CMAKE_THREAD_LIBS_INIT}) + +# easy way to fix test coverage - disable colors and crash handling +target_compile_definitions(all_features PRIVATE + DOCTEST_CONFIG_COLORS_NONE + DOCTEST_CONFIG_NO_POSIX_SIGNALS + DOCTEST_CONFIG_NO_WINDOWS_SEH) + +# omit the version and the num test cases skipped from the summary - this way the output will change less often +set(common_args COMMAND $ --no-skipped-summary --no-version) + +# add per-file tests +foreach(f ${files_with_output}) + doctest_add_test(NAME ${f} ${common_args} -sf=*${f}) +endforeach() + +# add this separately since it shouldn't have output compared to reference output - due to concurrency +# not adding it for MinGW since it crashes when using mingw-w64-x86_64-8.1.0-release-posix-seh-rt_v6-rev0 +# (also disabled for old XCode builds where there is no thread_local support and this is defined in the build matrix) +if(NOT MINGW AND NOT DEFINED DOCTEST_THREAD_LOCAL) + doctest_add_test(NO_OUTPUT NAME concurrency.cpp ${common_args} -sf=*concurrency.cpp -d) # duration: there is no output anyway +endif() + +doctest_add_test(NO_OUTPUT NAME namespace1.cpp ${common_args} -sf=*namespace1.cpp ) +doctest_add_test(NO_OUTPUT NAME namespace2.cpp ${common_args} -sf=*namespace2.cpp ) +doctest_add_test(NO_OUTPUT NAME namespace3.cpp ${common_args} -sf=*namespace3.cpp ) +doctest_add_test(NO_OUTPUT NAME namespace4.cpp ${common_args} -sf=*namespace4.cpp ) +doctest_add_test(NO_OUTPUT NAME namespace5.cpp ${common_args} -sf=*namespace5.cpp ) +doctest_add_test(NO_OUTPUT NAME namespace6.cpp ${common_args} -sf=*namespace6.cpp ) +doctest_add_test(NO_OUTPUT NAME namespace7.cpp ${common_args} -sf=*namespace7.cpp ) +doctest_add_test(NO_OUTPUT NAME namespace8.cpp ${common_args} -sf=*namespace8.cpp ) +doctest_add_test(NO_OUTPUT NAME namespace9.cpp ${common_args} -sf=*namespace9.cpp ) + +# add this separately since the file has a non-straightforward path +doctest_add_test(NAME coverage_maxout.cpp ${common_args} -sf=*coverage_maxout.cpp) + +# queries +doctest_add_test(NAME version COMMAND $ -v) +doctest_add_test(NAME help ${common_args} -h) +doctest_add_test(NO_OUTPUT NAME outfile ${common_args} -c -out=temp) # just to exercise the output option +doctest_add_test(NAME count ${common_args} -c -sf=*coverage*) +doctest_add_test(NAME list_test_cases ${common_args} -ltc -sf=*coverage*) +doctest_add_test(NAME list_test_suites ${common_args} -lts -sf=*coverage*) +doctest_add_test(NAME list_reporters ${common_args} -lr -sf=*coverage*) + +# options +doctest_add_test(NAME all_binary ${common_args} -tc=all?binary* -s) # print all binary asserts - for getAssertString() +doctest_add_test(NAME abort_after ${common_args} -aa=2 -e=off -sf=*coverage*) # abort after 2 assert fails and parse a negative +doctest_add_test(NAME first_last ${common_args} -f=2 -l=4 -sf=*coverage*) # run a range +doctest_add_test(NAME filter_1 ${common_args} -ts=none) # should filter out all +# -order-by=name to avoid different output depending on the compiler used. See https://github.com/doctest/doctest/issues/287 +doctest_add_test(NAME filter_2 COMMAND $ -tse=* -nv -order-by=name) # should filter out all + print skipped +doctest_add_test(NAME filter_3 ${common_args} -sc=from*,sc* -sce=sc2 -sf=*subcases*) # enter a specific subcase - sc1 +doctest_add_test(NAME filter_4 ${common_args} -ts=*\\, -tc=*\\: -sc=*\\\\\\,,*:) # escape stuff +doctest_add_test(NAME order_1 ${common_args} -ob=suite -ns -sf=*test_cases_and_suites*) +doctest_add_test(NAME order_2 ${common_args} -ob=name -sf=*test_cases_and_suites*) +doctest_add_test(NAME order_3 ${common_args} -ob=rand -sfe=*) # exclude everything for no output +doctest_add_test(NO_OUTPUT NAME quiet ${common_args} -q -sf=*test_cases_and_suites*) # quiet +doctest_add_test(NAME minimal ${common_args} -m -sf=*test_cases_and_suites*) # minimal with summary +doctest_add_test(NAME minimal_no_fail ${common_args} -m -sf=*no_failures.cpp) # minimal + +add_executable(disabled_but_evaluated assert_returns_disabled.cpp assert_returns_disabled_evaluate.cpp) +target_compile_definitions(disabled_but_evaluated PRIVATE DOCTEST_CONFIG_DISABLE) +target_link_libraries(disabled_but_evaluated doctest ${CMAKE_THREAD_LIBS_INIT}) + +doctest_add_test_impl(NO_OUTPUT NAME disabled_but_evaluated COMMAND $) + +if(MSVC) + target_compile_options(disabled_but_evaluated PRIVATE /wd4702) # unreachable code +endif() + +if(CMAKE_CXX_COMPILER_ID MATCHES "Clang") + target_compile_options(disabled_but_evaluated PRIVATE -Wno-global-constructors) + target_compile_options(disabled_but_evaluated PRIVATE -Wno-unused-variable) +elseif(CMAKE_CXX_COMPILER_ID MATCHES "GNU") + target_compile_options(disabled_but_evaluated PRIVATE -Wno-unused-variable) +endif() + +################################################################################ +## CONFIG TESTS - TESTS WITH VARIOUS CONFIGURATION OPTIONS +################################################################################ + +function(add_test_all_features test_name flags) + add_executable(${test_name} ${files_with_output}) + target_compile_definitions(${test_name} PRIVATE ${flags}) + target_link_libraries(${test_name} doctest ${CMAKE_THREAD_LIBS_INIT}) + + doctest_add_test_impl(NAME ${test_name} COMMAND $ --no-skipped-summary --no-version -ob=name) +endfunction() + +add_test_all_features(no_multithreading DOCTEST_CONFIG_NO_MULTITHREADING) +add_test_all_features(no_multi_lane_atomics DOCTEST_CONFIG_NO_MULTI_LANE_ATOMICS) +add_test_all_features(disabled DOCTEST_CONFIG_DISABLE) +add_test_all_features(std_headers DOCTEST_CONFIG_USE_STD_HEADERS) + +# TODO: think about fixing these in a different way! - see issue #61 or commit 6b61e8aa3818c5ea100cedc1bb48a60ea10df6e8 +if(MSVC) + target_compile_options(disabled PRIVATE /wd4505) # unreferenced local function has been removed + target_compile_options(disabled PRIVATE /wd4100) # unreferenced formal parameter + target_compile_options(disabled PRIVATE /wd4189) # local variable is initialized but not referenced +endif() + +if(CMAKE_CXX_COMPILER_ID MATCHES "Clang") + target_compile_options(disabled PRIVATE -Wno-unknown-warning-option) + target_compile_options(disabled PRIVATE -Wno-unneeded-internal-declaration) + target_compile_options(disabled PRIVATE -Wno-unused-function) + target_compile_options(disabled PRIVATE -Wno-unused-parameter) + target_compile_options(disabled PRIVATE -Wno-unused-variable) + target_compile_options(disabled PRIVATE -Wno-unused-template) +elseif(CMAKE_CXX_COMPILER_ID MATCHES "GNU") + target_compile_options(disabled PRIVATE -Wno-unused-function) + target_compile_options(disabled PRIVATE -Wno-unused-parameter) + target_compile_options(disabled PRIVATE -Wno-unused-variable) +endif() diff --git a/dmff/dpnblist/external/doctest-2.4.11/examples/all_features/alternative_macros.cpp b/dmff/dpnblist/external/doctest-2.4.11/examples/all_features/alternative_macros.cpp new file mode 100644 index 00000000..30231966 --- /dev/null +++ b/dmff/dpnblist/external/doctest-2.4.11/examples/all_features/alternative_macros.cpp @@ -0,0 +1,15 @@ +#include "doctest_proxy.h" + +my_testcase("custom macros") { + my_check(1 == 1); + + my_check_eq(1, 1); + + my_subcase("bar") { + my_subcase("foo") { /* code code code */ } + my_subcase("baz") { /* code code code */ } + + my_require(5 > 3); + } + // CHECK(1 == 1); <== ERROR - the default short macros are disabled from the proxy header +} diff --git a/dmff/dpnblist/external/doctest-2.4.11/examples/all_features/assert_returns_disabled.cpp b/dmff/dpnblist/external/doctest-2.4.11/examples/all_features/assert_returns_disabled.cpp new file mode 100644 index 00000000..da5a7018 --- /dev/null +++ b/dmff/dpnblist/external/doctest-2.4.11/examples/all_features/assert_returns_disabled.cpp @@ -0,0 +1,30 @@ +#define DOCTEST_CONFIG_ASSERTS_RETURN_VALUES +#include + +DOCTEST_MAKE_STD_HEADERS_CLEAN_FROM_WARNINGS_ON_WALL_BEGIN +#include +DOCTEST_MAKE_STD_HEADERS_CLEAN_FROM_WARNINGS_ON_WALL_END + +#ifndef TEST_FLIP +#define TEST_FLIP 0 +#endif + +#define TEST_FAIL() std::cout << "FAILED ON: " << __LINE__ \ + << "(" << (TEST_FLIP ? "EVALUATED" : "DISABLED") << ")" << std::endl + +static int test_disabled_var_ = [] { // NOLINT + // none may return true + if (TEST_FLIP ^ CHECK(0 == 0)) { TEST_FAIL(); } + if (TEST_FLIP ^ CHECK_FALSE(0 != 0)) { TEST_FAIL(); } + if (TEST_FLIP ^ CHECK_EQ(0, 0)) { TEST_FAIL(); } + if (TEST_FLIP ^ CHECK_UNARY(true)) { TEST_FAIL(); } + if (TEST_FLIP ^ CHECK_UNARY_FALSE(false)) { TEST_FAIL(); } +#ifndef DOCTEST_CONFIG_NO_EXCEPTIONS_BUT_WITH_ALL_ASSERTS + int i = 2; (void)i; + if (TEST_FLIP ^ CHECK_THROWS([=] { throw i; }())) { TEST_FAIL(); } + if (TEST_FLIP ^ CHECK_THROWS_AS([=] { throw i; }(), int)) { TEST_FAIL(); } + if (TEST_FLIP ^ CHECK_NOTHROW([=]{ }())) { TEST_FAIL(); } +#endif + + return 0; +}(); diff --git a/dmff/dpnblist/external/doctest-2.4.11/examples/all_features/assert_returns_disabled_evaluate.cpp b/dmff/dpnblist/external/doctest-2.4.11/examples/all_features/assert_returns_disabled_evaluate.cpp new file mode 100644 index 00000000..722e9b43 --- /dev/null +++ b/dmff/dpnblist/external/doctest-2.4.11/examples/all_features/assert_returns_disabled_evaluate.cpp @@ -0,0 +1,4 @@ +#define DOCTEST_CONFIG_EVALUATE_ASSERTS_EVEN_WHEN_DISABLED +#define DOCTEST_CONFIG_IMPLEMENT_WITH_MAIN +#define TEST_FLIP 1 +#include "assert_returns_disabled.cpp" diff --git a/dmff/dpnblist/external/doctest-2.4.11/examples/all_features/assertion_macros.cpp b/dmff/dpnblist/external/doctest-2.4.11/examples/all_features/assertion_macros.cpp new file mode 100644 index 00000000..42ad86bf --- /dev/null +++ b/dmff/dpnblist/external/doctest-2.4.11/examples/all_features/assertion_macros.cpp @@ -0,0 +1,235 @@ +#define DOCTEST_CONFIG_ASSERTS_RETURN_VALUES +#include + +#include "header.h" + +DOCTEST_MAKE_STD_HEADERS_CLEAN_FROM_WARNINGS_ON_WALL_BEGIN +#include +#include +DOCTEST_MAKE_STD_HEADERS_CLEAN_FROM_WARNINGS_ON_WALL_END + +TEST_CASE("normal macros") { + int a = 5; + int b = 5; + + CHECK(throw_if(true, std::runtime_error("whops!")) == 42); + + CHECK_FALSE(!(a == b)); + + REQUIRE(a == b); + + CHECK_EQ(a, b); + + CHECK(doctest::Approx(0.1000001) == 0.1000002); + CHECK(doctest::Approx(0.502) == 0.501); +} + +TEST_CASE("expressions should be evaluated only once") { + int a = 5; + REQUIRE(++a == 6); + REQUIRE_EQ(++a, 7); +} + +TEST_CASE("exceptions-related macros") { + CHECK_THROWS(throw_if(true, 0)); + CHECK_THROWS(throw_if(false, 0)); // fails + CHECK_THROWS_AS(throw_if(true, 0), int); + CHECK_THROWS_AS(throw_if(true, 0), char); // fails + CHECK_THROWS_AS(throw_if(false, 0), int); // fails + + CHECK_THROWS_WITH(throw_if(true, "whops!"), "whops! no match!"); // fails + CHECK_THROWS_WITH(throw_if(true, "whops! does it match?"), doctest::Contains("whops!")); + CHECK_THROWS_WITH(throw_if(true, "whops! does it match?"), doctest::Contains("whops! no match!")); // fails + CHECK_THROWS_WITH_AS(throw_if(true, "whops!"), "whops! no match!", bool); // fails + CHECK_THROWS_WITH_AS(throw_if(true, "whops!"), "whops!", int); // fails + CHECK_THROWS_WITH_AS(throw_if(true, "whops! does it match?"), doctest::Contains("whops! no match!"), int); // fails + + CHECK_NOTHROW(throw_if(true, 0)); // fails + CHECK_NOTHROW(throw_if(false, 0)); +} + +TEST_CASE("exceptions-related macros for std::exception") { + CHECK_THROWS(throw_if(false, 0)); + CHECK_THROWS_AS(throw_if(false, std::runtime_error("whops!")), std::exception); + CHECK_THROWS_AS(throw_if(true, std::runtime_error("whops!")), const std::exception&); + CHECK_THROWS_AS(throw_if(true, std::runtime_error("whops!")), int); + + CHECK_THROWS_WITH(throw_if(false, ""), "whops!"); + + REQUIRE_NOTHROW(throw_if(true, std::runtime_error("whops!"))); +} + +// ================================================================================================= +// == TESTING (ALMOST) ALL ASSERTS THAT THEY ACT ACCORDINGLY - not interesting examples... +// ================================================================================================= + +TEST_CASE("WARN level of asserts don't fail the test case") { + WARN(0); + WARN_FALSE(1); + WARN_THROWS(throw_if(false, 0)); + WARN_THROWS_WITH(throw_if(true, ""), "whops!"); + WARN_THROWS_WITH(throw_if(false, ""), "whops!"); + WARN_THROWS_AS(throw_if(false, 0), bool); + WARN_THROWS_AS(throw_if(true, 0), bool); + WARN_THROWS_WITH_AS(throw_if(false, ""), "whops!", int); + WARN_THROWS_WITH_AS(throw_if(true, ""), "whops!", int); + WARN_NOTHROW(throw_if(true, 0)); + + WARN_EQ(1, 0); + doctest::String myStr = doctest::String("Hello world, how are you doing? Well, nice to meet you, Goodbye!"); + WARN_EQ(myStr, doctest::Contains("Hello")); + WARN(myStr == doctest::Contains("Goodbye")); + WARN(myStr != doctest::Contains("goodbye")); + WARN_UNARY(0); + WARN_UNARY_FALSE(1); +} + +TEST_CASE("CHECK level of asserts fail the test case but don't abort it") { + CHECK(0); + CHECK_FALSE(1); + CHECK_THROWS(throw_if(false, 0)); + CHECK_THROWS_AS(throw_if(false, 0), bool); + CHECK_THROWS_AS(throw_if(true, 0), bool); + CHECK_THROWS_WITH(throw_if(true, 0), "unrecognized"); + CHECK_THROWS_WITH_AS(throw_if(true, 0), "unrecognized", int); + CHECK_NOTHROW(throw_if(true, 0)); + + CHECK_EQ(1, 0); + doctest::String myStr = doctest::String("Hello world, how are you doing? Well, nice to meet you, Goodbye!"); + CHECK_EQ(myStr, doctest::Contains("Hello")); + CHECK(myStr == doctest::Contains("Goodbye")); + CHECK(myStr != doctest::Contains("goodbye")); + CHECK_UNARY(0); + CHECK_UNARY_FALSE(1); + + MESSAGE("reached!"); +} + +TEST_CASE("REQUIRE level of asserts fail and abort the test case - 1") { + REQUIRE(0); + MESSAGE("should not be reached!"); +} +TEST_CASE("REQUIRE level of asserts fail and abort the test case - 2") { + REQUIRE_FALSE(1); + MESSAGE("should not be reached!"); +} +TEST_CASE("REQUIRE level of asserts fail and abort the test case - 3") { + REQUIRE_THROWS(throw_if(false, 0)); + MESSAGE("should not be reached!"); +} +TEST_CASE("REQUIRE level of asserts fail and abort the test case - 4") { + REQUIRE_THROWS_AS(throw_if(false, 0), bool); + MESSAGE("should not be reached!"); +} +TEST_CASE("REQUIRE level of asserts fail and abort the test case - 5") { + REQUIRE_THROWS_AS(throw_if(true, 0), bool); + MESSAGE("should not be reached!"); +} +TEST_CASE("REQUIRE level of asserts fail and abort the test case - 6") { + REQUIRE_THROWS_WITH(throw_if(false, ""), "whops!"); + MESSAGE("should not be reached!"); +} +TEST_CASE("REQUIRE level of asserts fail and abort the test case - 7") { + REQUIRE_THROWS_WITH(throw_if(true, ""), "whops!"); + MESSAGE("should not be reached!"); +} +TEST_CASE("REQUIRE level of asserts fail and abort the test case - 8") { + REQUIRE_THROWS_WITH_AS(throw_if(false, ""), "whops!", bool); + MESSAGE("should not be reached!"); +} +TEST_CASE("REQUIRE level of asserts fail and abort the test case - 9") { + REQUIRE_THROWS_WITH_AS(throw_if(true, ""), "whops!", bool); + MESSAGE("should not be reached!"); +} +TEST_CASE("REQUIRE level of asserts fail and abort the test case - 10") { + REQUIRE_NOTHROW(throw_if(true, 0)); + MESSAGE("should not be reached!"); +} +TEST_CASE("REQUIRE level of asserts fail and abort the test case - 11") { + REQUIRE_EQ(1, 0); + MESSAGE("should not be reached!"); +} +TEST_CASE("REQUIRE level of asserts fail and abort the test case - 12") { + REQUIRE_UNARY(0); + MESSAGE("should not be reached!"); +} +TEST_CASE("REQUIRE level of asserts fail and abort the test case - 13") { + REQUIRE_UNARY_FALSE(1); + MESSAGE("should not be reached!"); +} + +TEST_CASE("all binary assertions") { + WARN_EQ(1, 1); + CHECK_EQ(1, 1); + REQUIRE_EQ(1, 1); + WARN_NE(1, 0); + CHECK_NE(1, 0); + REQUIRE_NE(1, 0); + WARN_GT(1, 0); + CHECK_GT(1, 0); + REQUIRE_GT(1, 0); + WARN_LT(0, 1); + CHECK_LT(0, 1); + REQUIRE_LT(0, 1); + WARN_GE(1, 1); + CHECK_GE(1, 1); + REQUIRE_GE(1, 1); + WARN_LE(1, 1); + CHECK_LE(1, 1); + REQUIRE_LE(1, 1); + WARN_UNARY(1); + CHECK_UNARY(1); + REQUIRE_UNARY(1); + WARN_UNARY_FALSE(0); + CHECK_UNARY_FALSE(0); + REQUIRE_UNARY_FALSE(0); +} + +static void someAssertsInFunction() { + int a = 5; + int b = 5; + CHECK(a == b); + CHECK_FALSE(a != b); + CHECK_THROWS(throw_if(true, 0)); + CHECK_THROWS_AS(throw_if(true, 0), int); + CHECK_THROWS_WITH(throw_if(true, false), "unknown exception"); + CHECK_THROWS_WITH_AS(throw_if(true, false), "unknown exception", int); + CHECK_NOTHROW(throw_if(false, 0)); + + CHECK_EQ(a, b); + CHECK_UNARY(a == b); + CHECK_UNARY_FALSE(a != b); +} + +TEST_CASE("some asserts used in a function called by a test case") { + someAssertsInFunction(); +} + +// TODO: Remove NOLINT (if (false && (__VA_ARGS__));)? +DOCTEST_INLINE_NOINLINE void comp(int a, int b) { // NOLINT(misc-unused-parameters) + if (CHECK(a == b)) { MESSAGE(":D"); } + if (CHECK_FALSE(a != b)) { MESSAGE(":D"); } + if (CHECK_EQ(a, b)) { MESSAGE(":D"); } + if (CHECK_UNARY(a == b)) { MESSAGE(":D"); } + if (CHECK_UNARY_FALSE(a != b)) { MESSAGE(":D"); } +} + +DOCTEST_MSVC_SUPPRESS_WARNING_WITH_PUSH(4702) +TEST_CASE("check return values") { + comp(0, 0); + + if (CHECK_THROWS(throw_if(true, true))) { MESSAGE(":D"); } + if (CHECK_THROWS_AS(throw_if(true, 2), int)) { MESSAGE(":D"); } + if (CHECK_NOTHROW(throw_if(false, 2))) { MESSAGE(":D"); } + if (CHECK_THROWS_WITH(throw_if(true, 2), "2")) { MESSAGE(":D"); } +} + +TEST_CASE("check return values no print") { + comp(4, 2); + + if (CHECK_THROWS(throw_if(false, false))) { MESSAGE(":D"); } + if (CHECK_THROWS_AS(throw_if(true, 2), doctest::Approx)) { MESSAGE(":D"); } + if (CHECK_NOTHROW(throw_if(true, 2))) { MESSAGE(":D"); } + if (CHECK_THROWS_WITH(throw_if(true, 2), "1")) { MESSAGE(":D"); } +} +DOCTEST_MSVC_SUPPRESS_WARNING_POP diff --git a/dmff/dpnblist/external/doctest-2.4.11/examples/all_features/asserts_used_outside_of_tests.cpp b/dmff/dpnblist/external/doctest-2.4.11/examples/all_features/asserts_used_outside_of_tests.cpp new file mode 100644 index 00000000..289c2666 --- /dev/null +++ b/dmff/dpnblist/external/doctest-2.4.11/examples/all_features/asserts_used_outside_of_tests.cpp @@ -0,0 +1,74 @@ +#ifndef DOCTEST_CONFIG_DISABLE +#define DOCTEST_CONFIG_SUPER_FAST_ASSERTS // defined so the asserts are crazy fast - both for compilation and execution +#endif + +#include + +#include "header.h" + +DOCTEST_MAKE_STD_HEADERS_CLEAN_FROM_WARNINGS_ON_WALL_BEGIN +#include +#include +#include +DOCTEST_MAKE_STD_HEADERS_CLEAN_FROM_WARNINGS_ON_WALL_END +DOCTEST_GCC_SUPPRESS_WARNING("-Wmissing-declarations") +DOCTEST_CLANG_SUPPRESS_WARNING("-Wmissing-prototypes") + +// some function which uses asserts not just for unit testing but also for ensuring contracts in production code +static void some_func() { + CHECK_EQ(true, false); + CHECK_UNARY(false); + CHECK_UNARY_FALSE(true); + + CHECK(false); + CHECK_THROWS(std::cout << "hello! \n"); +} + +// std::mutex g_mut; + +static void handler(const doctest::AssertData& ad) { + using namespace doctest; + + // uncomment if asserts will be used in a multi-threaded context + // std::lock_guard lock(g_mut); + + // here we can choose what to do: + // - log the failed assert + // - throw an exception + // - call std::abort() or std::terminate() + + std::cout << Color::LightGrey << skipPathFromFilename(ad.m_file) << "(" << ad.m_line << "): "; + std::cout << Color::Red << failureString(ad.m_at) << ": "; + + // handling only normal (comparison and unary) asserts - exceptions-related asserts have been skipped + if(ad.m_at & assertType::is_normal) { + std::cout << Color::Cyan << assertString(ad.m_at) << "( " << ad.m_expr << " ) "; + std::cout << Color::None << (ad.m_threw ? "THREW exception: " : "is NOT correct!\n"); + if(ad.m_threw) + std::cout << ad.m_exception; + else + std::cout << " values: " << assertString(ad.m_at) << "( " << ad.m_decomp << " )"; + } else { + std::cout << Color::None << "an assert dealing with exceptions has failed!"; + } + + std::cout << std::endl; +} + +void some_program_code(int argc, char** argv) { + // IGNORE THIS: return if the current test from the doctest CMake tests is not for this file + if(std::find_if(argv, argv + argc, [](const char* str) { return strcmp(str, "-sf=*asserts_used_outside_of_tests.cpp") == 0; }) == argv + argc) return; + + // construct a context + doctest::Context context(argc, argv); + + // sets the context as the default one - so asserts used outside of a testing context do not crash + context.setAsDefaultForAssertsOutOfTestCases(); + + // set a handler with a signature: void(const doctest::AssertData&) + // without setting a handler we would get std::abort() called when an assert fails + context.setAssertHandler(handler); + + // call the function with asserts out of a testing context - the above handler will be called on failure + some_func(); +} diff --git a/dmff/dpnblist/external/doctest-2.4.11/examples/all_features/concurrency.cpp b/dmff/dpnblist/external/doctest-2.4.11/examples/all_features/concurrency.cpp new file mode 100644 index 00000000..844ebaa3 --- /dev/null +++ b/dmff/dpnblist/external/doctest-2.4.11/examples/all_features/concurrency.cpp @@ -0,0 +1,71 @@ +#include + +#ifndef DOCTEST_CONFIG_NO_EXCEPTIONS + +DOCTEST_MAKE_STD_HEADERS_CLEAN_FROM_WARNINGS_ON_WALL_BEGIN +#include +#include +#include +#include +DOCTEST_MAKE_STD_HEADERS_CLEAN_FROM_WARNINGS_ON_WALL_END + +DOCTEST_MSVC_SUPPRESS_WARNING(4626) // assignment operator was implicitly defined as deleted + +TEST_CASE("threads...") { + auto call_from_thread = [](int value) { + INFO("print me!"); + // one of these has to fail + CHECK(value == 1); + CHECK(value == 2); + }; + + int data_1 = 1; + int data_2 = 2; + CAPTURE(data_1); // will not be used for assertions in other threads + + // subcases have to be used only in the main thread (where the test runner is) + SUBCASE("test runner thread") { + call_from_thread(data_1); + } + + // normal threads which are assumed not to throw + SUBCASE("spawned threads") { + std::thread t1(call_from_thread, data_1); + std::thread t2(call_from_thread, data_2); + + t1.join(); + t2.join(); + } + + // exceptions from threads (that includes failing REQUIRE asserts) have to be handled explicitly + SUBCASE("spawned threads with exception propagation") { + std::exception_ptr exception_ptr = nullptr; + std::mutex mutex; + + auto might_throw = [&]() { + try { + REQUIRE(1 == 1); + REQUIRE(1 == 2); // will fail and throw an exception + MESSAGE("not reached!"); + } catch(...) { + // make sure there are no races when dealing with the exception ptr + std::lock_guard lock(mutex); + + // set the exception pointer in case of an exception - might overwrite + // another exception but here we care about propagating any exception - not all + exception_ptr = std::current_exception(); + } + }; + std::thread t1(might_throw); + std::thread t2(might_throw); + + t1.join(); + t2.join(); + + // if any thread has thrown an exception - rethrow it + if(exception_ptr) + std::rethrow_exception(exception_ptr); + } +} + +#endif // DOCTEST_CONFIG_NO_EXCEPTIONS diff --git a/dmff/dpnblist/external/doctest-2.4.11/examples/all_features/coverage_maxout.cpp b/dmff/dpnblist/external/doctest-2.4.11/examples/all_features/coverage_maxout.cpp new file mode 100644 index 00000000..34489da5 --- /dev/null +++ b/dmff/dpnblist/external/doctest-2.4.11/examples/all_features/coverage_maxout.cpp @@ -0,0 +1,127 @@ +#include + +#include "header.h" + +DOCTEST_MAKE_STD_HEADERS_CLEAN_FROM_WARNINGS_ON_WALL_BEGIN +#include +#include +#include +DOCTEST_MAKE_STD_HEADERS_CLEAN_FROM_WARNINGS_ON_WALL_END + +#ifndef DOCTEST_CONFIG_DISABLE + +// ================================================================================================= +// !!! THESE ARE NOT PROPER EXAMPLES OF LIBRARY USAGE !!! THESE ARE MEANT FOR CODE COVERAGE ONLY !!! +// ================================================================================================= + +TEST_CASE("exercising tricky code paths of doctest") { + using namespace doctest; + + // trigger code path for comparing the file in "operator<" of SubcaseSignature + CHECK(SubcaseSignature{"", "a.cpp", 0} < SubcaseSignature{"", "b.cpp", 0}); + // same for String + CHECK(String("a.cpp") < String("b.cpp")); + + // trigger code path for string with nullptr + String str; + const String const_str("omgomgomg"); + str = const_str.c_str(); + CHECK(const_str[0] == 'o'); + CHECK(str.capacity() == 24); + CHECK(str.size() == const_str.size()); + CHECK_MESSAGE(str.compare(const_str, true) != 0, "should fail"); + CHECK_MESSAGE(str.compare("omgomgomg", false) != 0, "should fail"); + + String heap_str("012345678901234567890123456789"); + CHECK(heap_str.capacity() == heap_str.size() + 1); // on heap with maxed capacity + heap_str += "0123456789"; + CHECK(heap_str.capacity() > heap_str.size() + 1); + heap_str += "0123456789"; // triggers path in += + CHECK(heap_str[heap_str.size() - 1] == '9'); + heap_str = ""; + + CHECK(String("abc") == "abc"); + CHECK(String("abc") > "aaa"); + CHECK(String("abc") >= "aaa"); + CHECK(String("abc") < "bbb"); + CHECK(String("abc") <= "bbb"); + CHECK(String("abc")[0] == 'a'); + + // toString + str += toString("aaa") // + + toString(nullptr) // + + toString(true) // + + toString(0u) // + + toString('c') // + + toString(static_cast('c')) // + + toString(static_cast(1)) // + + toString(static_cast(1)) // + + toString(1L) // + + toString(1UL) // + + toString(static_cast(1)) // + + toString(1LL) // + + toString(1ULL); + + std::ostringstream oss; + + // trigger code path for String to ostream through operator<< + oss << str; + // trigger code path for assert string of a non-existent assert type +#ifndef DOCTEST_CONFIG_NO_EXCEPTIONS + try { + assertString(static_cast(3)); + } catch (const std::logic_error&) { } +#endif + str += oss.str().c_str(); + str += failureString(assertType::is_normal); + CHECK(str == "omgomgomgaaanullptrtrue099991111111" + "omgomgomgaaanullptrtrue099991111111"); + // trigger code path for rawMemoryToString + bool isThereAnything = str.size() > 0u; + String unknown = toString(skip()); // trigger code path for "{?}" + str = unknown; // trigger code path for deleting memory in operator= + CHECK_FALSE_MESSAGE(isThereAnything, "should fail"); + + Approx a(5); + a.scale(4); + Approx b = a(7); + + CHECK(b == 7); + CHECK(b != 6); + CHECK(b > 6); + CHECK(b < 8); + CHECK(b >= 7); + CHECK(b <= 7); + + CHECK(5 == a); + CHECK(6 != a); + CHECK(6 > a); + CHECK(4 < a); + CHECK(5 >= a); + CHECK(5 <= a); + + // trigger another single line of code... lol + // NOLINTBEGIN(cppcoreguidelines-pro-type-const-cast) + auto oldVal = const_cast(getContextOptions())->no_path_in_filenames; + const_cast(getContextOptions())->no_path_in_filenames = false; + CHECK(String(skipPathFromFilename("")) == ""); + const_cast(getContextOptions())->no_path_in_filenames = oldVal; + // NOLINTEND(cppcoreguidelines-pro-type-const-cast) + + // a hack to trigger a bug in doctest: currently a 0 cannot be successfully parsed for an int option! + Context().setOption("last", 0); +} + +TEST_SUITE("will be overridden by a decorator" * doctest::test_suite("exception related")) { + TEST_CASE("will end from a std::string exception") { + throw_if(true, std::string("std::string!")); + } + + TEST_CASE("will end from a const char* exception") { throw_if(true, "const char*!"); } + + TEST_CASE("will end from an unknown exception") { + throw_if(true, doctest::String("unknown :(")); + } +} + +#endif // DOCTEST_CONFIG_DISABLE diff --git a/dmff/dpnblist/external/doctest-2.4.11/examples/all_features/decomposition.cpp b/dmff/dpnblist/external/doctest-2.4.11/examples/all_features/decomposition.cpp new file mode 100644 index 00000000..2713971b --- /dev/null +++ b/dmff/dpnblist/external/doctest-2.4.11/examples/all_features/decomposition.cpp @@ -0,0 +1,63 @@ +#include + +class MoveOnly { + public: + MoveOnly(int iIn) : i(iIn) { } + MoveOnly(MoveOnly&&) = default; + MoveOnly(const MoveOnly&) = delete; + MoveOnly& operator=(MoveOnly&&) = default; + MoveOnly& operator=(const MoveOnly&) = default; + ~MoveOnly() = default; + // NOLINTNEXTLINE(readability-make-member-function-const) + operator bool() { // NOT const! + return i == 42; + } + + private: + int i; +}; + +static MoveOnly genType(bool b) { + return { b ? 42 : 0 }; +} + +TEST_CASE("Move Only Type") { + CHECK(genType(true)); + CHECK(genType(false)); + + MoveOnly a{ 0 }; + CHECK(a); +} + + +struct int_pointer { + int* p = nullptr; + int_pointer() = default; + + // non-const ref used in constructor + // we don't want to accidentally construct a dangling pointer from a temporary + int_pointer(int& i) : p(&i) { } + + // NOLINTNEXTLINE(readability-make-member-function-const) + explicit operator bool() { return !!p; } + int val() const { return *p; } +}; + +struct int_holder { + int i; + bool operator==(int_pointer p) const { + if (!p) return false; + return i == p.val(); + } +}; + +DOCTEST_MSVC_SUPPRESS_WARNING_WITH_PUSH(4866) // eval order +TEST_CASE("Impl cast from non-const value") { + int_holder h{ 8 }; + int i = 8; + + // this comparison is safe + // int_pointer can be implicitly constructed from this int here + CHECK(h == i); +} +DOCTEST_MSVC_SUPPRESS_WARNING_POP diff --git a/dmff/dpnblist/external/doctest-2.4.11/examples/all_features/doctest_proxy.h b/dmff/dpnblist/external/doctest-2.4.11/examples/all_features/doctest_proxy.h new file mode 100644 index 00000000..396d673d --- /dev/null +++ b/dmff/dpnblist/external/doctest-2.4.11/examples/all_features/doctest_proxy.h @@ -0,0 +1,71 @@ +#ifndef DOCTEST_CONFIG_NO_SHORT_MACRO_NAMES +#define DOCTEST_CONFIG_NO_SHORT_MACRO_NAMES +#endif // DOCTEST_CONFIG_NO_SHORT_MACRO_NAMES + +// no guard for including the doctest header itself because it should support multiple inclusion +#include + +#ifndef MY_PROXY_MACROS +#define MY_PROXY_MACROS + +#define my_testcase DOCTEST_TEST_CASE +#define my_testcase_class DOCTEST_TEST_CASE_CLASS +#define my_testcase_fixture DOCTEST_TEST_CASE_FIXTURE +#define my_subcase DOCTEST_SUBCASE +#define my_testsuite DOCTEST_TEST_SUITE +#define my_testsuite_begin DOCTEST_TEST_SUITE_BEGIN +#define my_testsuite_end DOCTEST_TEST_SUITE_END +#define my_warn DOCTEST_WARN +#define my_warn_false DOCTEST_WARN_FALSE +#define my_warn_throws DOCTEST_WARN_THROWS +#define my_warn_throws_as DOCTEST_WARN_THROWS_AS +#define my_warn_throws_with DOCTEST_WARN_THROWS_WITH +#define my_warn_throws_with_as DOCTEST_WARN_THROWS_WITH_AS +#define my_warn_nothrow DOCTEST_WARN_NOTHROW +#define my_check DOCTEST_CHECK +#define my_check_false DOCTEST_CHECK_FALSE +#define my_check_throws DOCTEST_CHECK_THROWS +#define my_check_throws_as DOCTEST_CHECK_THROWS_AS +#define my_check_throws_with DOCTEST_CHECK_THROWS_WITH +#define my_check_throws_with_as DOCTEST_CHECK_THROWS_WITH_AS +#define my_check_nothrow DOCTEST_CHECK_NOTHROW +#define my_require DOCTEST_REQUIRE +#define my_require_false DOCTEST_REQUIRE_FALSE +#define my_require_throws DOCTEST_REQUIRE_THROWS +#define my_require_throws_as DOCTEST_REQUIRE_THROWS_AS +#define my_require_throws_with_as DOCTEST_REQUIRE_THROWS_WITH_AS +#define my_require_nothrow DOCTEST_REQUIRE_NOTHROW + +#define my_scenario DOCTEST_SCENARIO +#define my_given DOCTEST_GIVEN +#define my_when DOCTEST_WHEN +#define my_and_when DOCTEST_AND_WHEN +#define my_then DOCTEST_THEN +#define my_and_then DOCTEST_AND_THEN + +#define my_warn_eq DOCTEST_WARN_EQ +#define my_check_eq DOCTEST_CHECK_EQ +#define my_require_eq DOCTEST_REQUIRE_EQ +#define my_warn_ne DOCTEST_WARN_NE +#define my_check_ne DOCTEST_CHECK_NE +#define my_require_ne DOCTEST_REQUIRE_NE +#define my_warn_gt DOCTEST_WARN_GT +#define my_check_gt DOCTEST_CHECK_GT +#define my_require_gt DOCTEST_REQUIRE_GT +#define my_warn_lt DOCTEST_WARN_LT +#define my_check_lt DOCTEST_CHECK_LT +#define my_require_lt DOCTEST_REQUIRE_LT +#define my_warn_ge DOCTEST_WARN_GE +#define my_check_ge DOCTEST_CHECK_GE +#define my_require_ge DOCTEST_REQUIRE_GE +#define my_warn_le DOCTEST_WARN_LE +#define my_check_le DOCTEST_CHECK_LE +#define my_require_le DOCTEST_REQUIRE_LE +#define my_warn_unary DOCTEST_WARN_UNARY +#define my_check_unary DOCTEST_CHECK_UNARY +#define my_require_unary DOCTEST_REQUIRE_UNARY +#define my_warn_unary_false DOCTEST_WARN_UNARY_FALSE +#define my_check_unary_false DOCTEST_CHECK_UNARY_FALSE +#define my_require_unary_false DOCTEST_REQUIRE_UNARY_FALSE + +#endif // MY_PROXY_MACROS diff --git a/dmff/dpnblist/external/doctest-2.4.11/examples/all_features/double_stringification.cpp b/dmff/dpnblist/external/doctest-2.4.11/examples/all_features/double_stringification.cpp new file mode 100644 index 00000000..5a1ebb53 --- /dev/null +++ b/dmff/dpnblist/external/doctest-2.4.11/examples/all_features/double_stringification.cpp @@ -0,0 +1,18 @@ +#define DOCTEST_CONFIG_DOUBLE_STRINGIFY +#include + +DOCTEST_MAKE_STD_HEADERS_CLEAN_FROM_WARNINGS_ON_WALL_BEGIN +#include +DOCTEST_MAKE_STD_HEADERS_CLEAN_FROM_WARNINGS_ON_WALL_END + +namespace App { + struct Foo { }; + static std::string toString(Foo*) { return "Foo"; } +} + +TEST_CASE("toString std::string ret type") { + App::Foo foo; + CHECK(&foo != nullptr); + CHECK_NE(&foo, nullptr); + CHECK(&foo); +} diff --git a/dmff/dpnblist/external/doctest-2.4.11/examples/all_features/enums.cpp b/dmff/dpnblist/external/doctest-2.4.11/examples/all_features/enums.cpp new file mode 100644 index 00000000..d92127d0 --- /dev/null +++ b/dmff/dpnblist/external/doctest-2.4.11/examples/all_features/enums.cpp @@ -0,0 +1,121 @@ +#include + +// GCC < 5 breaks when trying to compare enums to integers when using std headers. +#if !defined(DOCTEST_CONFIG_USE_STD_HEADERS) || DOCTEST_GCC == 0 || DOCTEST_GCC >= DOCTEST_COMPILER(5, 0, 0) +#define RET_TYPE(x) x +#else +#define RET_TYPE(x) typename doctest::detail::types::underlying_type::type +#endif + +template +static RET_TYPE(S) castToUnderlying(S in) { + return in; +} + +#include "header.h" + +DOCTEST_MAKE_STD_HEADERS_CLEAN_FROM_WARNINGS_ON_WALL_BEGIN +#include +#include +DOCTEST_MAKE_STD_HEADERS_CLEAN_FROM_WARNINGS_ON_WALL_END + +namespace +{ + +enum StandardEnum +{ + Zero, + One, + Two, +}; + +enum TypedEnum : int64_t +{ + TypedZero, + TypedOne, + TypedTwo, +}; + +enum class EnumClassC : char +{ + Zero = '0', + One = '1', + Two = '2', +}; + +enum class EnumClassSC : signed char +{ + Zero = '0', + One = '1', + Two = '2', +}; + +enum class EnumClassUC : unsigned char +{ + Zero = '0', + One = '1', + Two = '2', +}; + +enum class EnumClassU8 : uint8_t +{ + Zero, + One, + Two, +}; + +template::type> +T printable(E val) +{ + return static_cast(val); +} + +} + +TEST_CASE("enum 1") +{ + std::ostringstream ostr; + ostr << Zero << One << Two; + ostr << TypedZero << TypedOne << TypedTwo; + static_assert(std::is_enum::value, ""); + ostr << printable(EnumClassSC::Zero) << printable(EnumClassSC::One) << printable(EnumClassSC::Two); + + CHECK_EQ(castToUnderlying(Zero), 0); + CHECK_EQ(castToUnderlying(One), 1); + CHECK_EQ(castToUnderlying(Two), 2); + + CHECK_EQ(castToUnderlying(TypedZero), 0); + CHECK_EQ(castToUnderlying(TypedOne), 1); + CHECK_EQ(castToUnderlying(TypedTwo), 2); + + CHECK_EQ(EnumClassSC::Zero, EnumClassSC::Zero); + CHECK_EQ(EnumClassSC::One, EnumClassSC::One); + CHECK_EQ(EnumClassSC::Two, EnumClassSC::Two); +} + +TEST_CASE("enum 2" * doctest::should_fail()) +{ + CHECK_EQ(castToUnderlying(Zero), 1); + CHECK_EQ(castToUnderlying(One), 2); + CHECK_EQ(castToUnderlying(Two), 3); + + CHECK_EQ(castToUnderlying(TypedZero), 1); + CHECK_EQ(castToUnderlying(TypedOne), 2); + CHECK_EQ(castToUnderlying(TypedTwo), 3); + + CHECK_EQ(EnumClassC::Zero, EnumClassC::One); + CHECK_EQ(EnumClassC::One, EnumClassC::Two); + CHECK_EQ(EnumClassC::Two, EnumClassC::Zero); + + CHECK_EQ(EnumClassSC::Zero, EnumClassSC::One); + CHECK_EQ(EnumClassSC::One, EnumClassSC::Two); + CHECK_EQ(EnumClassSC::Two, EnumClassSC::Zero); + + CHECK_EQ(EnumClassUC::Zero, EnumClassUC::One); + CHECK_EQ(EnumClassUC::One, EnumClassUC::Two); + CHECK_EQ(EnumClassUC::Two, EnumClassUC::Zero); + + CHECK_EQ(EnumClassU8::Zero, EnumClassU8::One); + CHECK_EQ(EnumClassU8::One, EnumClassU8::Two); + CHECK_EQ(EnumClassU8::Two, EnumClassU8::Zero); +} diff --git a/dmff/dpnblist/external/doctest-2.4.11/examples/all_features/header.h b/dmff/dpnblist/external/doctest-2.4.11/examples/all_features/header.h new file mode 100644 index 00000000..5c5fed47 --- /dev/null +++ b/dmff/dpnblist/external/doctest-2.4.11/examples/all_features/header.h @@ -0,0 +1,68 @@ +#pragma once + +#include + +// helper for throwing exceptions +template +int throw_if(bool in, const T& ex) { + if(in) +#ifndef DOCTEST_CONFIG_NO_EXCEPTIONS + throw ex; // NOLINT +#else // DOCTEST_CONFIG_NO_EXCEPTIONS + ((void)ex); +#endif // DOCTEST_CONFIG_NO_EXCEPTIONS + return 42; +} + +// stuff that should be fine when used in a header - test cases for example should be registered only once + +TEST_SUITE("some TS") { + TEST_CASE("in TS") { + FAIL(""); + } +} + +REGISTER_EXCEPTION_TRANSLATOR(int& in) { + return doctest::toString(in); +} + +// Removes class on MSVC +TYPE_TO_STRING(doctest::String); + +TEST_CASE_TEMPLATE("template 1", T, char) { + FAIL(""); +} + +TEST_CASE_TEMPLATE_DEFINE("template 2", T, header_test) { + FAIL(""); +} + +TEST_CASE_TEMPLATE_INVOKE(header_test, doctest::String); + +// to silence GCC warnings when inheriting from some class which has no virtual destructor - happens only on gcc 4.7/4.8 +#if DOCTEST_GCC >= DOCTEST_COMPILER(4, 7, 0) && DOCTEST_GCC < DOCTEST_COMPILER(4, 9, 0) +DOCTEST_GCC_SUPPRESS_WARNING("-Weffc++") +#endif // gcc 4.7 / 4.8 +#if DOCTEST_GCC >= DOCTEST_COMPILER(5, 0, 0) && DOCTEST_GCC < DOCTEST_COMPILER(6, 0, 0) +DOCTEST_GCC_SUPPRESS_WARNING("-Wstrict-overflow") +#endif // gcc 5 + +// NOLINTBEGIN +struct SomeFixture +{ + int data; + SomeFixture() noexcept + : data(42) { + // setup here + } + + ~SomeFixture() { + // teardown here + } +}; +// NOLINTEND + +TEST_CASE_FIXTURE(SomeFixture, "fixtured test") { + data /= 2; + CHECK(data == 21); +} diff --git a/dmff/dpnblist/external/doctest-2.4.11/examples/all_features/logging.cpp b/dmff/dpnblist/external/doctest-2.4.11/examples/all_features/logging.cpp new file mode 100644 index 00000000..5182b165 --- /dev/null +++ b/dmff/dpnblist/external/doctest-2.4.11/examples/all_features/logging.cpp @@ -0,0 +1,81 @@ +#include + +#include "header.h" + +DOCTEST_MAKE_STD_HEADERS_CLEAN_FROM_WARNINGS_ON_WALL_BEGIN +#include +DOCTEST_MAKE_STD_HEADERS_CLEAN_FROM_WARNINGS_ON_WALL_END + +TEST_CASE("logging the counter of a loop") { + std::vector vec; + vec.push_back(1); + vec.push_back(2); + vec.push_back(4); + vec.push_back(8); + vec.push_back(16); + + INFO("current iteration of loop:"); + for(unsigned i = 0; i < vec.size(); ++i) { + CAPTURE(i); + CHECK(vec[i] != (1 << i)); + } +} + +static int someTests() { + int some_var = 42; + INFO("lots of captures: ", some_var, " ", some_var, " ", some_var, ";"); + INFO("old way of capturing - using the streaming operator: " << some_var << " " << some_var); + FAIL_CHECK("forcing the many captures to be stringified"); + return some_var; +} + +TEST_CASE("a test case that will end from an exception") { + int some_var = someTests(); + INFO("someTests() returned: ", some_var); // note that we have to use a local variable - cannot pass a temporary + INFO("this should be printed if an exception is thrown even if no assert has failed: ", some_var); + { + INFO("in a nested scope this should be printed as well: ", some_var); + { + INFO("this should not be printed"); + CAPTURE(some_var); + } + + CHECK_MESSAGE(some_var == 666, "why is this not 666 ?!"); + + throw_if(true, 0); + } +} + +TEST_CASE("a test case that will end from an exception and should print the unprinted context") { + INFO("should be printed even if an exception is thrown and no assert fails before that"); + throw_if(true, 0); +} + +// TODO: Also remove +// NOLINTNEXTLINE(misc-unused-parameters) +static void thirdPartyAssert(bool result, bool is_fatal, const char* file, int line) { + if(!result) { + if(is_fatal) // NOLINT(bugprone-branch-clone) + ADD_FAIL_AT(file, line, "MY_ASSERT_FATAL(" << result << ")"); + else + ADD_FAIL_CHECK_AT(file, line, "MY_ASSERT(" << result << ")"); + } +} + +#define MY_ASSERT(x) thirdPartyAssert(x, false, __FILE__, __LINE__) +#define MY_ASSERT_FATAL(x) thirdPartyAssert(x, true, __FILE__, __LINE__) + +TEST_CASE("third party asserts can report failures to doctest") { + MY_ASSERT(1 == 2); + MY_ASSERT_FATAL(1 == 2); +} + +TEST_CASE("explicit failures 1") { + FAIL_CHECK("this should not end the test case, but mark it as failing"); + MESSAGE("reached!"); +} + +TEST_CASE("explicit failures 2") { + FAIL("fail the test case and also end it"); + MESSAGE("never reached..."); +} diff --git a/dmff/dpnblist/external/doctest-2.4.11/examples/all_features/main.cpp b/dmff/dpnblist/external/doctest-2.4.11/examples/all_features/main.cpp new file mode 100644 index 00000000..e51542b4 --- /dev/null +++ b/dmff/dpnblist/external/doctest-2.4.11/examples/all_features/main.cpp @@ -0,0 +1,51 @@ +#define DOCTEST_CONFIG_IMPLEMENT +#include + +#include "header.h" + +int program(); +void some_program_code(int argc, char** argv); + +int main(int argc, char** argv) { + doctest::Context context; + + // !!! THIS IS JUST AN EXAMPLE SHOWING HOW DEFAULTS/OVERRIDES ARE SET !!! + + // defaults + context.addFilter("test-case-exclude", "*math*"); // exclude test cases with "math" in the name + context.setOption("rand-seed", 324); // if order-by is set to "rand" use this seed + context.setOption("order-by", "file"); // sort the test cases by file and line + + context.applyCommandLine(argc, argv); + + // overrides + context.setOption("no-breaks", true); // don't break in the debugger when assertions fail + + int res = context.run(); // run queries, or run tests unless --no-run is specified + + if(context.shouldExit()) // important - query flags (and --exit) rely on the user doing this + return res; // propagate the result of the tests + + context.clearFilters(); // removes all filters added up to this point + + int client_stuff_return_code = program(); + some_program_code(argc, argv); + // your program - if the testing framework is integrated in your production code + + return res + client_stuff_return_code; // the result from doctest is propagated here as well +} + +TEST_CASE("[string] testing std::string") { + std::string a("omg"); + CHECK(a == "omg"); +} + +TEST_CASE("[math] basic stuff") { + CHECK(6 > 5); + CHECK(6 > 7); +} + +int program() { + std::cout << "Program code." << std::endl; + return EXIT_SUCCESS; +} diff --git a/dmff/dpnblist/external/doctest-2.4.11/examples/all_features/namespace1.cpp b/dmff/dpnblist/external/doctest-2.4.11/examples/all_features/namespace1.cpp new file mode 100644 index 00000000..4014ab54 --- /dev/null +++ b/dmff/dpnblist/external/doctest-2.4.11/examples/all_features/namespace1.cpp @@ -0,0 +1,27 @@ +#include + +DOCTEST_MAKE_STD_HEADERS_CLEAN_FROM_WARNINGS_ON_WALL_BEGIN +#include +#include +DOCTEST_MAKE_STD_HEADERS_CLEAN_FROM_WARNINGS_ON_WALL_END + +namespace user1 { +struct label +{ + label() + : i(0) {} + int i; +}; +} // namespace user1 + +DOCTEST_GCC_SUPPRESS_WARNING("-Wmissing-declarations") +DOCTEST_CLANG_SUPPRESS_WARNING("-Wmissing-prototypes") + +bool operator==(const user1::label& lhs, const user1::label& rhs) { return lhs.i == rhs.i; } + + +TEST_CASE("namespace 1 global operator") { + user1::label a; + user1::label b; + CHECK(a == b); +} diff --git a/dmff/dpnblist/external/doctest-2.4.11/examples/all_features/namespace2.cpp b/dmff/dpnblist/external/doctest-2.4.11/examples/all_features/namespace2.cpp new file mode 100644 index 00000000..3dc1d556 --- /dev/null +++ b/dmff/dpnblist/external/doctest-2.4.11/examples/all_features/namespace2.cpp @@ -0,0 +1,24 @@ +#include + +DOCTEST_MAKE_STD_HEADERS_CLEAN_FROM_WARNINGS_ON_WALL_BEGIN +#include +#include +DOCTEST_MAKE_STD_HEADERS_CLEAN_FROM_WARNINGS_ON_WALL_END + +namespace user2 { +struct label +{ + label() + : i(0) {} + int i; + friend bool operator==(const user2::label& lhs, const user2::label& rhs) { + return lhs.i == rhs.i; + } +}; +} // namespace user2 + +TEST_CASE("namespace 2 friend operator") { + user2::label a; + user2::label b; + REQUIRE(a == b); +} diff --git a/dmff/dpnblist/external/doctest-2.4.11/examples/all_features/namespace3.cpp b/dmff/dpnblist/external/doctest-2.4.11/examples/all_features/namespace3.cpp new file mode 100644 index 00000000..a1015aa0 --- /dev/null +++ b/dmff/dpnblist/external/doctest-2.4.11/examples/all_features/namespace3.cpp @@ -0,0 +1,22 @@ +#include + +DOCTEST_MAKE_STD_HEADERS_CLEAN_FROM_WARNINGS_ON_WALL_BEGIN +#include +#include +DOCTEST_MAKE_STD_HEADERS_CLEAN_FROM_WARNINGS_ON_WALL_END + +namespace user3 { +struct label +{ + label() + : i(0) {} + int i; + bool operator==(const user3::label& rhs) const { return i == rhs.i; } +}; +} // namespace user3 + +TEST_CASE("namespace 3 member operator") { + user3::label a; + user3::label b; + REQUIRE(a == b); +} diff --git a/dmff/dpnblist/external/doctest-2.4.11/examples/all_features/namespace4.cpp b/dmff/dpnblist/external/doctest-2.4.11/examples/all_features/namespace4.cpp new file mode 100644 index 00000000..88d74628 --- /dev/null +++ b/dmff/dpnblist/external/doctest-2.4.11/examples/all_features/namespace4.cpp @@ -0,0 +1,37 @@ +#include + +DOCTEST_MAKE_STD_HEADERS_CLEAN_FROM_WARNINGS_ON_WALL_BEGIN +#include +#include +DOCTEST_MAKE_STD_HEADERS_CLEAN_FROM_WARNINGS_ON_WALL_END + +namespace user4 { +struct label +{ + label() + : i(0) {} + int i; + bool operator==(const user4::label& rhs) const { return i == rhs.i; } +}; +} // namespace user4 + +namespace user5 { +struct label +{ + label() + : i(0) {} + int i; + bool operator==(const user5::label& rhs) const { return i == rhs.i; } +}; +} // namespace user5 + +TEST_CASE("namespace 4 member vs member") { + user4::label a4; + user4::label b4; + + user5::label a5; + user5::label b5; + + REQUIRE(a4 == b4); + REQUIRE(a5 == b5); +} diff --git a/dmff/dpnblist/external/doctest-2.4.11/examples/all_features/namespace5.cpp b/dmff/dpnblist/external/doctest-2.4.11/examples/all_features/namespace5.cpp new file mode 100644 index 00000000..20fb0d77 --- /dev/null +++ b/dmff/dpnblist/external/doctest-2.4.11/examples/all_features/namespace5.cpp @@ -0,0 +1,39 @@ +#include + +DOCTEST_MAKE_STD_HEADERS_CLEAN_FROM_WARNINGS_ON_WALL_BEGIN +#include +#include +DOCTEST_MAKE_STD_HEADERS_CLEAN_FROM_WARNINGS_ON_WALL_END + +namespace user6 { +struct label +{ + label() + : i(0) {} + int i; + bool operator==(const user6::label& rhs) const { return i == rhs.i; } +}; +} // namespace user6 + +namespace user7 { +struct label +{ + label() + : i(0) {} + int i; + friend bool operator==(const user7::label& lhs, const user7::label& rhs) { + return lhs.i == rhs.i; + } +}; +} // namespace user7 + +TEST_CASE("namespace 5 member vs friend") { + user6::label a6; + user6::label b6; + + user7::label a7; + user7::label b7; + + REQUIRE(a6 == b6); + REQUIRE(a7 == b7); +} diff --git a/dmff/dpnblist/external/doctest-2.4.11/examples/all_features/namespace6.cpp b/dmff/dpnblist/external/doctest-2.4.11/examples/all_features/namespace6.cpp new file mode 100644 index 00000000..e8c66e2a --- /dev/null +++ b/dmff/dpnblist/external/doctest-2.4.11/examples/all_features/namespace6.cpp @@ -0,0 +1,41 @@ +#include + +DOCTEST_MAKE_STD_HEADERS_CLEAN_FROM_WARNINGS_ON_WALL_BEGIN +#include +#include +DOCTEST_MAKE_STD_HEADERS_CLEAN_FROM_WARNINGS_ON_WALL_END + +namespace user6 { +struct label +{ + label() + : i(0) {} + int i; + friend bool operator==(const user6::label& lhs, const user6::label& rhs) { + return lhs.i == rhs.i; + } +}; +} // namespace user6 + +namespace user7 { +struct label +{ + label() + : i(0) {} + int i; + friend bool operator==(const user7::label& lhs, const user7::label& rhs) { + return lhs.i == rhs.i; + } +}; +} // namespace user7 + +TEST_CASE("namespace 6 friend vs friend") { + user6::label a6; + user6::label b6; + + user7::label a7; + user7::label b7; + + REQUIRE(a6 == b6); + REQUIRE(a7 == b7); +} diff --git a/dmff/dpnblist/external/doctest-2.4.11/examples/all_features/namespace7.cpp b/dmff/dpnblist/external/doctest-2.4.11/examples/all_features/namespace7.cpp new file mode 100644 index 00000000..c2c27322 --- /dev/null +++ b/dmff/dpnblist/external/doctest-2.4.11/examples/all_features/namespace7.cpp @@ -0,0 +1,41 @@ +#include + +DOCTEST_MAKE_STD_HEADERS_CLEAN_FROM_WARNINGS_ON_WALL_BEGIN +#include +#include +DOCTEST_MAKE_STD_HEADERS_CLEAN_FROM_WARNINGS_ON_WALL_END + +namespace user6 { +struct label +{ + label() + : i(0) {} + int i; + bool operator==(const user6::label& rhs) const { return i == rhs.i; } +}; +} // namespace user6 + +namespace user7 { +struct label +{ + label() + : i(0) {} + int i; +}; +} // namespace user7 + +DOCTEST_GCC_SUPPRESS_WARNING("-Wmissing-declarations") +DOCTEST_CLANG_SUPPRESS_WARNING("-Wmissing-prototypes") + +bool operator==(const user7::label& lhs, const user7::label& rhs) { return lhs.i == rhs.i; } + +TEST_CASE("namespace 7 member vs global") { + user6::label a6; + user6::label b6; + + user7::label a7; + user7::label b7; + + REQUIRE(a6 == b6); + REQUIRE(a7 == b7); +} diff --git a/dmff/dpnblist/external/doctest-2.4.11/examples/all_features/namespace8.cpp b/dmff/dpnblist/external/doctest-2.4.11/examples/all_features/namespace8.cpp new file mode 100644 index 00000000..cfc2131b --- /dev/null +++ b/dmff/dpnblist/external/doctest-2.4.11/examples/all_features/namespace8.cpp @@ -0,0 +1,45 @@ +#include + +DOCTEST_MAKE_STD_HEADERS_CLEAN_FROM_WARNINGS_ON_WALL_BEGIN +#include +#include +DOCTEST_MAKE_STD_HEADERS_CLEAN_FROM_WARNINGS_ON_WALL_END + +namespace user6 { +struct label +{ + label() + : i(0) {} + int i; + friend bool operator==(const user6::label& lhs, const user6::label& rhs) { + return lhs.i == rhs.i; + } +}; +} // namespace user6 + +namespace user8 { +struct label +{ + label() + : i(0) {} + int i; +}; +} // namespace user8 + + +DOCTEST_GCC_SUPPRESS_WARNING("-Wmissing-declarations") +DOCTEST_CLANG_SUPPRESS_WARNING("-Wmissing-prototypes") + +bool operator==(const user8::label& lhs, const user8::label& rhs) { return lhs.i == rhs.i; } + + +TEST_CASE("namespace 8 friend vs global") { + user6::label a6; + user6::label b6; + + user8::label a8; + user8::label b8; + + REQUIRE(a6 == b6); + REQUIRE(a8 == b8); +} diff --git a/dmff/dpnblist/external/doctest-2.4.11/examples/all_features/namespace9.cpp b/dmff/dpnblist/external/doctest-2.4.11/examples/all_features/namespace9.cpp new file mode 100644 index 00000000..078e6235 --- /dev/null +++ b/dmff/dpnblist/external/doctest-2.4.11/examples/all_features/namespace9.cpp @@ -0,0 +1,44 @@ +#include + +DOCTEST_MAKE_STD_HEADERS_CLEAN_FROM_WARNINGS_ON_WALL_BEGIN +#include +#include +DOCTEST_MAKE_STD_HEADERS_CLEAN_FROM_WARNINGS_ON_WALL_END + +namespace user9a { +struct label +{ + label() + : i(0) {} + int i; +}; +} // namespace user9a + +DOCTEST_GCC_SUPPRESS_WARNING("-Wmissing-declarations") +DOCTEST_CLANG_SUPPRESS_WARNING("-Wmissing-prototypes") +bool operator==(const user9a::label& lhs, const user9a::label& rhs) { return lhs.i == rhs.i; } + +namespace user9b { +struct label +{ + label() + : i(0) {} + int i; +}; +} // namespace user9b + +DOCTEST_GCC_SUPPRESS_WARNING("-Wmissing-declarations") +DOCTEST_CLANG_SUPPRESS_WARNING("-Wmissing-prototypes") + +bool operator==(const user9b::label& lhs, const user9b::label& rhs) { return lhs.i == rhs.i; } + +TEST_CASE("namespace 9 both global") { + user9a::label a1; + user9a::label a2; + + user9b::label b1; + user9b::label b2; + + REQUIRE(a1 == a2); + REQUIRE(b1 == b2); +} diff --git a/dmff/dpnblist/external/doctest-2.4.11/examples/all_features/no_failures.cpp b/dmff/dpnblist/external/doctest-2.4.11/examples/all_features/no_failures.cpp new file mode 100644 index 00000000..ae74047e --- /dev/null +++ b/dmff/dpnblist/external/doctest-2.4.11/examples/all_features/no_failures.cpp @@ -0,0 +1,13 @@ +#include + +TEST_CASE("no checks") {} + +TEST_CASE("simple check") { + CHECK(1 == 1); +} + +TEST_SUITE("some suite") { + TEST_CASE("fails - and its allowed" * doctest::may_fail()) { FAIL(""); } +} + +TEST_CASE("should fail and no output" * doctest::should_fail() * doctest::no_breaks() * doctest::no_output()) { FAIL(""); } diff --git a/dmff/dpnblist/external/doctest-2.4.11/examples/all_features/reporters_and_listeners.cpp b/dmff/dpnblist/external/doctest-2.4.11/examples/all_features/reporters_and_listeners.cpp new file mode 100644 index 00000000..49569232 --- /dev/null +++ b/dmff/dpnblist/external/doctest-2.4.11/examples/all_features/reporters_and_listeners.cpp @@ -0,0 +1,85 @@ +#include + +DOCTEST_MAKE_STD_HEADERS_CLEAN_FROM_WARNINGS_ON_WALL_BEGIN +#include +#include +DOCTEST_MAKE_STD_HEADERS_CLEAN_FROM_WARNINGS_ON_WALL_END + +DOCTEST_CLANG_SUPPRESS_WARNING("-Wweak-vtables") + +DOCTEST_GCC_SUPPRESS_WARNING("-Weffc++") +DOCTEST_GCC_SUPPRESS_WARNING("-Wpedantic") + +DOCTEST_MSVC_SUPPRESS_WARNING(5026) // move constructor was implicitly defined as deleted +DOCTEST_MSVC_SUPPRESS_WARNING(4625) // copy constructor was implicitly defined as deleted +DOCTEST_MSVC_SUPPRESS_WARNING(4626) // assignment operator was implicitly defined as deleted +DOCTEST_MSVC_SUPPRESS_WARNING(5027) // move assignment operator was implicitly defined as deleted + +using namespace doctest; + +struct MyXmlReporter : public IReporter +{ + // caching pointers/references to objects of these types - safe to do + std::ostream& stdout_stream; + const ContextOptions& opt; + const TestCaseData* tc; + std::mutex mutex; + + // constructor has to accept the ContextOptions by ref as a single argument + MyXmlReporter(const ContextOptions& in) + : stdout_stream(*in.cout) + , opt(in) + , tc(nullptr) {} + + void report_query(const QueryData& /*in*/) override {} + + void test_run_start() override {} + + void test_run_end(const TestRunStats& /*in*/) override {} + + void test_case_start(const TestCaseData& in) override { tc = ∈ } + + void test_case_reenter(const TestCaseData& /*in*/) override {} + + void test_case_end(const CurrentTestCaseStats& /*in*/) override {} + + void test_case_exception(const TestCaseException& /*in*/) override {} + + void subcase_start(const SubcaseSignature& /*in*/) override { + std::lock_guard lock(mutex); + } + + void subcase_end() override { + std::lock_guard lock(mutex); + } + + void log_assert(const AssertData& in) override { + // don't include successful asserts by default - this is done here + // instead of in the framework itself because doctest doesn't know + // if/when a reporter/listener cares about successful results + if(!in.m_failed && !opt.success) + return; + + // make sure there are no races - this is done here instead of in the + // framework itself because doctest doesn't know if reporters/listeners + // care about successful asserts and thus doesn't lock a mutex unnecessarily + std::lock_guard lock(mutex); + + // ... + } + + void log_message(const MessageData& /*in*/) override { + // messages too can be used in a multi-threaded context - like asserts + std::lock_guard lock(mutex); + + // ... + } + + void test_case_skipped(const TestCaseData& /*in*/) override {} +}; + +// "1" is the priority - used for ordering when multiple reporters/listeners are used +REGISTER_REPORTER("my_xml", 1, MyXmlReporter); + +// registering the same class as a reporter and as a listener is nonsense but it's possible +REGISTER_LISTENER("my_listener", 1, MyXmlReporter); diff --git a/dmff/dpnblist/external/doctest-2.4.11/examples/all_features/stringification.cpp b/dmff/dpnblist/external/doctest-2.4.11/examples/all_features/stringification.cpp new file mode 100644 index 00000000..d36d3728 --- /dev/null +++ b/dmff/dpnblist/external/doctest-2.4.11/examples/all_features/stringification.cpp @@ -0,0 +1,276 @@ +#ifdef _MSC_VER +__pragma(warning(push)) +__pragma(warning(disable : 4643)) +namespace std { + template struct char_traits; + template class basic_ostream; + typedef basic_ostream> ostream; // NOLINT(modernize-use-using) + template + basic_ostream& operator<<(basic_ostream&, const char*); +} +__pragma(warning(pop)) +#else +#include +#endif + +namespace N { + struct A { }; + struct B { + friend std::ostream& operator<<(std::ostream& os, const B&) { return os << "B"; } + }; + struct C { }; + static std::ostream& operator<<(std::ostream& os, const C&) { return os << "C"; } +} + +static std::ostream& operator<<(std::ostream& os, const N::A&) { return os << "A"; } + +#include + +#include + +TEST_CASE("operator<<") { + MESSAGE(N::A{ }); + MESSAGE(N::B{ }); + MESSAGE(N::C{ }); +} + +#include "header.h" + +// std::move is broken with VS <= 15 +#if defined(_MSC_VER) && _MSC_VER <= 1900 +#define MOVE(...) __VA_ARGS__ +#else +#define MOVE std::move +#endif + +TEST_CASE("no headers") { + char chs[] = { '1', 'a', 's' }; // NOLINT(*-avoid-c-arrays) + MESSAGE(chs); CHECK(chs == nullptr); + MESSAGE("1as"); CHECK("1as" == nullptr); + + int ints[] = { 0, 1, 1, 2, 3, 5, 8, 13 }; // NOLINT(*-avoid-c-arrays) + MESSAGE(ints); CHECK(ints == nullptr); + MESSAGE(MOVE(ints)); // NOLINT(*-move-const-arg) + + char* cptr = reinterpret_cast(ints + 4); // NOLINT + const char* ccptr = cptr; + void* vptr = reinterpret_cast(cptr); + CHECK(doctest::toString(cptr) == doctest::toString(ccptr)); + CHECK(doctest::toString(ccptr) == doctest::toString(vptr)); + + char* cnptr = nullptr; + MESSAGE(cnptr); CHECK(cnptr != nullptr); + + enum Test { + A = 0, B, C = 100, + }; + MESSAGE(A); CHECK(A == C); + + MESSAGE(doctest::toString()); +} + +DOCTEST_MAKE_STD_HEADERS_CLEAN_FROM_WARNINGS_ON_WALL_BEGIN +#include +#include +#include +#include +#include +DOCTEST_MAKE_STD_HEADERS_CLEAN_FROM_WARNINGS_ON_WALL_END + +DOCTEST_MSVC_SUPPRESS_WARNING(5045) // Spectre mitigation diagnostics + +// the standard forbids writing in the std namespace but it works on all compilers +namespace std // NOLINT(cert-dcl58-cpp) +{ +template +ostream& operator<<(ostream& stream, const vector& in) { + stream << "["; + for (size_t i = 0; i < in.size(); ++i) { + if (i != 0) { stream << ", "; } + stream << in[i]; + } + stream << "]"; + return stream; +} +} + +// as an alternative you may write a specialization of doctest::StringMaker +namespace doctest +{ +template +struct StringMaker> +{ + static String convert(const std::list& in) { + std::ostringstream oss; + + oss << "["; + // NOLINTNEXTLINE(*-use-auto) + for (typename std::list::const_iterator it = in.begin(); it != in.end();) { + oss << *it; + if (++it != in.end()) { oss << ", "; } + } + oss << "]"; + return oss.str().c_str(); + } +}; +} + +template +struct MyType +{ + T one; + K two; +}; + +template +struct MyTypeInherited : MyType +{}; + +template +bool operator==(const MyType& lhs, const MyType& rhs) { + return lhs.one == rhs.one && lhs.two == rhs.two; +} + +template +std::ostream& operator<<(std::ostream& stream, const MyType& in) { + stream << "[" << in.one << ", " << in.two << "]"; + return stream; +} + +namespace Bar +{ +struct Foo +{ + friend bool operator==(const Foo&, const Foo&) { return false; } +}; + +// as a third option you may provide an overload of toString() +inline doctest::String toString(const Foo&) { return "Foo{}"; } + +struct MyOtherType +{ + int data; + friend bool operator==(const MyOtherType& l, const MyOtherType& r) { return l.data == r.data; } +}; + +// you also can use a template operator<< if your code does not use std::ostream +template +OStream& operator<<(OStream& stream, const MyOtherType& in) { + stream << "MyOtherType: " << in.data; + return stream; +} + +} // namespace Bar + +// set an exception translator for MyTypeInherited +REGISTER_EXCEPTION_TRANSLATOR(MyTypeInherited& ex) { + return doctest::String("MyTypeInherited(") + doctest::toString(ex.one) + ", " + + doctest::toString(ex.two) + ")"; +} + +#define CHECK_NOT_DEFAULT_STR(var) CHECK(toString(var) != "{?}") + +TEST_CASE("all asserts should fail and show how the objects get stringified") { + MyTypeInherited bla1; + bla1.one = 5; + bla1.two = 4u; + + Bar::Foo f1; + MESSAGE(f1); + Bar::Foo f2; + CHECK(f1 == f2); + + doctest::String str; + CHECK(str == doctest::toString(str)); + + // std::string already has an operator<< working with std::ostream + std::string dummy = "omg"; + + MESSAGE(dummy); + + CHECK(dummy == "tralala"); // should fail + CHECK("tralala" == dummy); // should fail + + std::vector vec1; + vec1.push_back(1); + vec1.push_back(2); + vec1.push_back(3); + + MESSAGE(vec1); + + std::vector vec2; + vec2.push_back(1); + vec2.push_back(2); + vec2.push_back(4); + + CHECK(vec1 == vec2); + + std::list lst_1; + lst_1.push_back(1); + lst_1.push_back(42); + lst_1.push_back(3); + + MESSAGE(lst_1); + + std::list lst_2; + lst_2.push_back(1); + lst_2.push_back(2); + lst_2.push_back(666); + + CHECK(lst_1 == lst_2); + + { + Bar::MyOtherType s1 {42}; + Bar::MyOtherType s2 {666}; + INFO("s1=", s1, " s2=", s2); + CHECK(s1 == s2); + CHECK_MESSAGE(s1 == s2, s1, " is not really ", s2); + } + + CHECK_NOT_DEFAULT_STR(doctest::IsNaN(0.5)); + CHECK_NOT_DEFAULT_STR(!doctest::IsNaN(std::numeric_limits::infinity())); + CHECK_NOT_DEFAULT_STR(doctest::IsNaN(std::numeric_limits::quiet_NaN())); + + CHECK("a" == doctest::Contains("aaa")); + + // lets see if this exception gets translated + throw_if(true, bla1); +} + +static doctest::String intTranslator(int ex) { + return doctest::String("int: ") + doctest::toString(ex); +} + +TEST_CASE("a test case that registers an exception translator for int and then throws one") { + // set an exception translator for int - note that this shouldn't be done in a test case but + // in main() or somewhere before executing the tests - but here I'm just lazy... + doctest::registerExceptionTranslator(intTranslator); + + throw_if(true, 5); +} + +static void function() { } +static int*** function2() { return nullptr; } + +TEST_CASE("pointer comparisons") { + int i = 42; + int* a = &i; + int* b = a; + + CHECK(a == b); + CHECK_EQ(a, b); + + void (*functionPointer)() = &function; + CHECK(&function == functionPointer); + CHECK(&function2 == &function2); +} + +enum class Foo { }; + +static std::ostream& operator<<(std::ostream& os, Foo) { + return os << "Foo"; +} + +TEST_CASE("enum with operator<<") { + CHECK(doctest::toString(Foo()) == "Foo"); +} diff --git a/dmff/dpnblist/external/doctest-2.4.11/examples/all_features/subcases.cpp b/dmff/dpnblist/external/doctest-2.4.11/examples/all_features/subcases.cpp new file mode 100644 index 00000000..558baa0d --- /dev/null +++ b/dmff/dpnblist/external/doctest-2.4.11/examples/all_features/subcases.cpp @@ -0,0 +1,198 @@ +#include + +#include "header.h" + +DOCTEST_MAKE_STD_HEADERS_CLEAN_FROM_WARNINGS_ON_WALL_BEGIN +#include +#include +#include +using namespace std; +DOCTEST_MAKE_STD_HEADERS_CLEAN_FROM_WARNINGS_ON_WALL_END + +TEST_CASE("lots of nested subcases") { + cout << endl << "root" << endl; + SUBCASE("") { + cout << "1" << endl; + SUBCASE("") { cout << "1.1" << endl; } + } + SUBCASE("") { + cout << "2" << endl; + SUBCASE("") { cout << "2.1" << endl; } + SUBCASE("") { + // whops! all the subcases below shouldn't be discovered and executed! + FAIL(""); + + cout << "2.2" << endl; + SUBCASE("") { + cout << "2.2.1" << endl; + SUBCASE("") { cout << "2.2.1.1" << endl; } + SUBCASE("") { cout << "2.2.1.2" << endl; } + } + } + SUBCASE("") { cout << "2.3" << endl; } + SUBCASE("") { cout << "2.4" << endl; } + } +} + +TEST_CASE("reentering subcase via regular control flow") { + cout << endl << "root" << endl; + for (int i : { 0, 1, 2 }) { + cout << "outside of subcase" << endl; + SUBCASE("") { cout << "inside subcase " << i << endl; } + SUBCASE("") { cout << "also inside " << i << endl; } + SUBCASE("") { + if (i != 0) { FAIL(i); } + cout << "fail inside " << i << endl; + } + SUBCASE("") { + cout << "inside outside" << endl; + for (int j : { 0, 1, 2 }) { + SUBCASE("") { cout << "nested twice " << i << ", " << j << endl; } + SUBCASE("") { cout << "also twice " << i << ", " << j << endl; } + } + } + } +} + +static void call_func() { + SUBCASE("from function...") { + MESSAGE("print me twice"); + SUBCASE("sc1") { + MESSAGE("hello! from sc1"); + } + SUBCASE("sc2") { + MESSAGE("hello! from sc2"); + } + } +} + +TEST_CASE("subcases can be used in a separate function as well") { + call_func(); + MESSAGE("lala"); +} + +SCENARIO("vectors can be sized and resized") { + GIVEN("A vector with some items") { + std::vector v(5); + + REQUIRE(v.size() == 5); + REQUIRE(v.capacity() >= 5); + + WHEN("the size is increased") { + v.resize(10); + + THEN("the size and capacity change") { + CHECK(v.size() == 20); + CHECK(v.capacity() >= 10); + } + } + WHEN("the size is reduced") { + v.resize(0); + + THEN("the size changes but not capacity") { + CHECK(v.size() == 0); + CHECK(v.capacity() >= 5); + } + } + WHEN("more capacity is reserved") { + v.reserve(10); + + THEN("the capacity changes but not the size") { + CHECK(v.size() == 5); + CHECK(v.capacity() >= 10); + } + } + WHEN("less capacity is reserved") { + v.reserve(0); + + THEN("neither size nor capacity are changed") { + CHECK(v.size() == 10); + CHECK(v.capacity() >= 5); + } + } + } +} + +TEST_CASE("test case should fail even though the last subcase passes") { + SUBCASE("one") { + CHECK(false); + } + SUBCASE("two") { + CHECK(true); + } +} + +TEST_CASE("fails from an exception but gets re-entered to traverse all subcases") { + SUBCASE("level zero") { + SUBCASE("one") { + CHECK(false); + } + SUBCASE("two") { + CHECK(false); + } + + throw_if(true, "failure... but the show must go on!"); + } +} + +static void checks(int data) // NOLINT(misc-unused-parameters) +{ + DOCTEST_SUBCASE("check data 1") { REQUIRE(data % 2 == 0); } + DOCTEST_SUBCASE("check data 2") { REQUIRE(data % 4 == 0); } +} + +TEST_CASE("Nested - related to https://github.com/doctest/doctest/issues/282") +{ + DOCTEST_SUBCASE("generate data variant 1") + { + int data(44); + + // checks + checks(data); + } + DOCTEST_SUBCASE("generate data variant 1") + { + int data(80); + + // checks (identical in both variants) + checks(data); + } +} + +DOCTEST_MSVC_SUPPRESS_WARNING(5045) // Spectre mitigation stuff +DOCTEST_GCC_SUPPRESS_WARNING("-Wuseless-cast") // for the std::string() cast +#undef SUBCASE +#define SUBCASE(...) DOCTEST_SUBCASE(std::string(__VA_ARGS__).c_str()) + +TEST_CASE("subcases with changing names") { + for(int i = 0; i < 2; ++i) { + SUBCASE("outer " + std::to_string(i)) { + for(int k = 0; k < 2; ++k) { + SUBCASE("inner " + std::to_string(k)) { + MESSAGE("msg!"); + } + } + } + } + SUBCASE("separate") { + MESSAGE("separate msg!"); + } +} + +TEST_SUITE("with a funny name,") { + TEST_CASE("with a funnier name\\:") { + SUBCASE("with the funniest name\\,") { + MESSAGE("Yes!"); + } + SUBCASE("with a slightly funny name :") { + MESSAGE("Yep!"); + } + SUBCASE("without a funny name") { + MESSAGE("NO!"); + } + } + + TEST_CASE("without a funny name:") { + MESSAGE("Nooo"); + } +} diff --git a/dmff/dpnblist/external/doctest-2.4.11/examples/all_features/templated_test_cases.cpp b/dmff/dpnblist/external/doctest-2.4.11/examples/all_features/templated_test_cases.cpp new file mode 100644 index 00000000..dafb32e9 --- /dev/null +++ b/dmff/dpnblist/external/doctest-2.4.11/examples/all_features/templated_test_cases.cpp @@ -0,0 +1,78 @@ +#include + +DOCTEST_MAKE_STD_HEADERS_CLEAN_FROM_WARNINGS_ON_WALL_BEGIN +#include +DOCTEST_MAKE_STD_HEADERS_CLEAN_FROM_WARNINGS_ON_WALL_END + +// ================================================================================================= +// NORMAL TEMPLATED TEST CASES +// ================================================================================================= + +TYPE_TO_STRING_AS("SHORT!!!", short); + +TEST_CASE_TEMPLATE("signed integers stuff", T, signed char, short, int) { + T var = T(); + --var; + CHECK(var == -1); +} + +// teach the library how to stringify this type - otherwise <> will be used +TYPE_TO_STRING(std::vector); + +TEST_CASE_TEMPLATE("vector stuff", T, std::vector) { + T vec(10); + CHECK(vec.size() == 20); // will fail +} + +// ================================================================================================= +// NAMED TEMPLATED TEST CASES WITH DEFERRED INSTANTIATION +// ================================================================================================= + +TEST_CASE_TEMPLATE_DEFINE("default construction", T, test_id) { + T var = T(); + CHECK(doctest::Approx(var) == T()); +} + +TEST_CASE_TEMPLATE_INVOKE(test_id, signed char, short, int); +TEST_CASE_TEMPLATE_INVOKE(test_id, double, double); // note that types won't be filtered for uniqueness + +TEST_CASE_TEMPLATE_APPLY(test_id, std::tuple); + +// ================================================================================================= +// MULTIPLE TYPES AS PARAMETERS +// ================================================================================================= + +template +struct TypePair +{ + using A = first; + using B = second; +}; + +TYPE_TO_STRING_AS("Custom name test", TypePair); +TYPE_TO_STRING_AS("Other custom name", TypePair); +TYPE_TO_STRING(TypePair); + +TEST_CASE_TEMPLATE("multiple types", T, TypePair, TypePair, TypePair) { + using T1 = typename T::A; + using T2 = typename T::B; + T1 t1 = T1(); + T2 t2 = T2(); + // use T1 and T2 types + CHECK(t1 == T1()); + CHECK(t2 != T2()); +} + +// currently the string result will be "int_pair" instead of "TypePair" because of the way the type stringification works +using int_pair = TypePair; +TYPE_TO_STRING(int_pair); + +TEST_CASE_TEMPLATE("bad stringification of type pair", T, int_pair) { + using T1 = typename T::A; + using T2 = typename T::B; + T1 t1 = T1(); + T2 t2 = T2(); + // use T1 and T2 types + CHECK(t1 == T1()); + CHECK(t2 != T2()); +} diff --git a/dmff/dpnblist/external/doctest-2.4.11/examples/all_features/test_cases_and_suites.cpp b/dmff/dpnblist/external/doctest-2.4.11/examples/all_features/test_cases_and_suites.cpp new file mode 100644 index 00000000..13b316de --- /dev/null +++ b/dmff/dpnblist/external/doctest-2.4.11/examples/all_features/test_cases_and_suites.cpp @@ -0,0 +1,76 @@ +#include + +#include "header.h" + +static int doStuff() { + int a = 5; + a += 2; + // asserts and other doctest functionality can be used in user code if checked for a testing context + // AND they can also be used without such checks - see "asserts_used_outside_of_tests.cpp" + if(doctest::is_running_in_test) + CHECK(a == 7); + + return a; +} + +TEST_CASE("an empty test that will succeed - not part of a test suite") {} + +TEST_CASE("should fail because of an exception") { + doStuff(); + + throw_if(true, 0); +} + +TEST_SUITE("scoped test suite") { + TEST_CASE("part of scoped") { + FAIL(""); + } + + TEST_CASE("part of scoped 2") { + FAIL(""); + } +} + +TEST_SUITE_BEGIN("some TS"); // begin "some TS" + +TEST_CASE("part of some TS") { + FAIL(""); +} + +TEST_SUITE_END(); // ends "some TS" + +TEST_CASE_FIXTURE(SomeFixture, "fixtured test - not part of a test suite") { + data /= 2; + CHECK(data == 85); +} + +TEST_CASE("normal test in a test suite from a decorator" * doctest::test_suite("ts1") * + doctest::timeout(0.000001)) { + MESSAGE("failing because of the timeout decorator!"); +} + +static bool shouldSkip() { return false; } + +TEST_SUITE("skipped test cases" * doctest::skip()) { + TEST_CASE("unskipped" * doctest::skip(shouldSkip()) * + doctest::description("this test has overridden its skip decorator")) { + FAIL(""); + } + TEST_CASE("skipped - inherited from the test suite") { FAIL(""); } +} + +TEST_SUITE("test suite with a description" * doctest::description("regarding failures")) { + TEST_CASE("fails - and its allowed" * doctest::may_fail()) { FAIL(""); } + TEST_CASE("doesn't fail which is fine" * doctest::may_fail()) {} + + TEST_CASE("fails as it should" * doctest::should_fail()) { FAIL(""); } + TEST_CASE("doesn't fail but it should have" * doctest::should_fail()) {} + + TEST_CASE("fails 1 time as it should" * doctest::expected_failures(1)) { FAIL(""); } + TEST_CASE("fails more times than it should" * doctest::expected_failures(1)) { + FAIL_CHECK(""); + FAIL_CHECK(""); + } +} + +TEST_CASE("should fail and no output" * doctest::should_fail() * doctest::no_breaks() * doctest::no_output()) { FAIL(""); } diff --git a/dmff/dpnblist/external/doctest-2.4.11/examples/all_features/test_output/abort_after.txt b/dmff/dpnblist/external/doctest-2.4.11/examples/all_features/test_output/abort_after.txt new file mode 100644 index 00000000..717ce2e6 --- /dev/null +++ b/dmff/dpnblist/external/doctest-2.4.11/examples/all_features/test_output/abort_after.txt @@ -0,0 +1,19 @@ +[doctest] run with "--help" for options +=============================================================================== +coverage_maxout.cpp(0): +TEST CASE: exercising tricky code paths of doctest + +coverage_maxout.cpp(0): ERROR: CHECK( str.compare(const_str, true) != 0 ) is NOT correct! + values: CHECK( 0 != 0 ) + logged: should fail + +coverage_maxout.cpp(0): ERROR: CHECK( str.compare("omgomgomg", false) != 0 ) is NOT correct! + values: CHECK( 0 != 0 ) + logged: should fail + +Aborting - too many failed asserts! +=============================================================================== +[doctest] test cases: 1 | 0 passed | 1 failed | +[doctest] assertions: 7 | 5 passed | 2 failed | +[doctest] Status: FAILURE! +Program code. diff --git a/dmff/dpnblist/external/doctest-2.4.11/examples/all_features/test_output/abort_after_junit.txt b/dmff/dpnblist/external/doctest-2.4.11/examples/all_features/test_output/abort_after_junit.txt new file mode 100644 index 00000000..95cefeb6 --- /dev/null +++ b/dmff/dpnblist/external/doctest-2.4.11/examples/all_features/test_output/abort_after_junit.txt @@ -0,0 +1,22 @@ + + + + + +coverage_maxout.cpp(0): +CHECK( str.compare(const_str, true) != 0 ) is NOT correct! + values: CHECK( 0 != 0 ) + logged: should fail + + + +coverage_maxout.cpp(0): +CHECK( str.compare("omgomgomg", false) != 0 ) is NOT correct! + values: CHECK( 0 != 0 ) + logged: should fail + + + + + +Program code. diff --git a/dmff/dpnblist/external/doctest-2.4.11/examples/all_features/test_output/abort_after_xml.txt b/dmff/dpnblist/external/doctest-2.4.11/examples/all_features/test_output/abort_after_xml.txt new file mode 100644 index 00000000..db74df97 --- /dev/null +++ b/dmff/dpnblist/external/doctest-2.4.11/examples/all_features/test_output/abort_after_xml.txt @@ -0,0 +1,34 @@ + + + + + + + + str.compare(const_str, true) != 0 + + + 0 != 0 + + + should fail + + + + + str.compare("omgomgomg", false) != 0 + + + 0 != 0 + + + should fail + + + + + + + + +Program code. diff --git a/dmff/dpnblist/external/doctest-2.4.11/examples/all_features/test_output/all_binary.txt b/dmff/dpnblist/external/doctest-2.4.11/examples/all_features/test_output/all_binary.txt new file mode 100644 index 00000000..2eaac524 --- /dev/null +++ b/dmff/dpnblist/external/doctest-2.4.11/examples/all_features/test_output/all_binary.txt @@ -0,0 +1,82 @@ +[doctest] run with "--help" for options +=============================================================================== +assertion_macros.cpp(0): +TEST CASE: all binary assertions + +assertion_macros.cpp(0): SUCCESS: WARN_EQ( 1, 1 ) is correct! + values: WARN_EQ( 1, 1 ) + +assertion_macros.cpp(0): SUCCESS: CHECK_EQ( 1, 1 ) is correct! + values: CHECK_EQ( 1, 1 ) + +assertion_macros.cpp(0): SUCCESS: REQUIRE_EQ( 1, 1 ) is correct! + values: REQUIRE_EQ( 1, 1 ) + +assertion_macros.cpp(0): SUCCESS: WARN_NE( 1, 0 ) is correct! + values: WARN_NE( 1, 0 ) + +assertion_macros.cpp(0): SUCCESS: CHECK_NE( 1, 0 ) is correct! + values: CHECK_NE( 1, 0 ) + +assertion_macros.cpp(0): SUCCESS: REQUIRE_NE( 1, 0 ) is correct! + values: REQUIRE_NE( 1, 0 ) + +assertion_macros.cpp(0): SUCCESS: WARN_GT( 1, 0 ) is correct! + values: WARN_GT( 1, 0 ) + +assertion_macros.cpp(0): SUCCESS: CHECK_GT( 1, 0 ) is correct! + values: CHECK_GT( 1, 0 ) + +assertion_macros.cpp(0): SUCCESS: REQUIRE_GT( 1, 0 ) is correct! + values: REQUIRE_GT( 1, 0 ) + +assertion_macros.cpp(0): SUCCESS: WARN_LT( 0, 1 ) is correct! + values: WARN_LT( 0, 1 ) + +assertion_macros.cpp(0): SUCCESS: CHECK_LT( 0, 1 ) is correct! + values: CHECK_LT( 0, 1 ) + +assertion_macros.cpp(0): SUCCESS: REQUIRE_LT( 0, 1 ) is correct! + values: REQUIRE_LT( 0, 1 ) + +assertion_macros.cpp(0): SUCCESS: WARN_GE( 1, 1 ) is correct! + values: WARN_GE( 1, 1 ) + +assertion_macros.cpp(0): SUCCESS: CHECK_GE( 1, 1 ) is correct! + values: CHECK_GE( 1, 1 ) + +assertion_macros.cpp(0): SUCCESS: REQUIRE_GE( 1, 1 ) is correct! + values: REQUIRE_GE( 1, 1 ) + +assertion_macros.cpp(0): SUCCESS: WARN_LE( 1, 1 ) is correct! + values: WARN_LE( 1, 1 ) + +assertion_macros.cpp(0): SUCCESS: CHECK_LE( 1, 1 ) is correct! + values: CHECK_LE( 1, 1 ) + +assertion_macros.cpp(0): SUCCESS: REQUIRE_LE( 1, 1 ) is correct! + values: REQUIRE_LE( 1, 1 ) + +assertion_macros.cpp(0): SUCCESS: WARN_UNARY( 1 ) is correct! + values: WARN_UNARY( 1 ) + +assertion_macros.cpp(0): SUCCESS: CHECK_UNARY( 1 ) is correct! + values: CHECK_UNARY( 1 ) + +assertion_macros.cpp(0): SUCCESS: REQUIRE_UNARY( 1 ) is correct! + values: REQUIRE_UNARY( 1 ) + +assertion_macros.cpp(0): SUCCESS: WARN_UNARY_FALSE( 0 ) is correct! + values: WARN_UNARY_FALSE( 0 ) + +assertion_macros.cpp(0): SUCCESS: CHECK_UNARY_FALSE( 0 ) is correct! + values: CHECK_UNARY_FALSE( 0 ) + +assertion_macros.cpp(0): SUCCESS: REQUIRE_UNARY_FALSE( 0 ) is correct! + values: REQUIRE_UNARY_FALSE( 0 ) + +=============================================================================== +[doctest] test cases: 1 | 1 passed | 0 failed | +[doctest] assertions: 16 | 16 passed | 0 failed | +[doctest] Status: SUCCESS! +Program code. diff --git a/dmff/dpnblist/external/doctest-2.4.11/examples/all_features/test_output/all_binary_junit.txt b/dmff/dpnblist/external/doctest-2.4.11/examples/all_features/test_output/all_binary_junit.txt new file mode 100644 index 00000000..84ee370e --- /dev/null +++ b/dmff/dpnblist/external/doctest-2.4.11/examples/all_features/test_output/all_binary_junit.txt @@ -0,0 +1,7 @@ + + + + + + +Program code. diff --git a/dmff/dpnblist/external/doctest-2.4.11/examples/all_features/test_output/all_binary_xml.txt b/dmff/dpnblist/external/doctest-2.4.11/examples/all_features/test_output/all_binary_xml.txt new file mode 100644 index 00000000..519c8814 --- /dev/null +++ b/dmff/dpnblist/external/doctest-2.4.11/examples/all_features/test_output/all_binary_xml.txt @@ -0,0 +1,204 @@ + + + + + + + + 1, 1 + + + 1, 1 + + + + + 1, 1 + + + 1, 1 + + + + + 1, 1 + + + 1, 1 + + + + + 1, 0 + + + 1, 0 + + + + + 1, 0 + + + 1, 0 + + + + + 1, 0 + + + 1, 0 + + + + + 1, 0 + + + 1, 0 + + + + + 1, 0 + + + 1, 0 + + + + + 1, 0 + + + 1, 0 + + + + + 0, 1 + + + 0, 1 + + + + + 0, 1 + + + 0, 1 + + + + + 0, 1 + + + 0, 1 + + + + + 1, 1 + + + 1, 1 + + + + + 1, 1 + + + 1, 1 + + + + + 1, 1 + + + 1, 1 + + + + + 1, 1 + + + 1, 1 + + + + + 1, 1 + + + 1, 1 + + + + + 1, 1 + + + 1, 1 + + + + + 1 + + + 1 + + + + + 1 + + + 1 + + + + + 1 + + + 1 + + + + + 0 + + + 0 + + + + + 0 + + + 0 + + + + + 0 + + + 0 + + + + + + + + +Program code. diff --git a/dmff/dpnblist/external/doctest-2.4.11/examples/all_features/test_output/alternative_macros.cpp.txt b/dmff/dpnblist/external/doctest-2.4.11/examples/all_features/test_output/alternative_macros.cpp.txt new file mode 100644 index 00000000..de7784c8 --- /dev/null +++ b/dmff/dpnblist/external/doctest-2.4.11/examples/all_features/test_output/alternative_macros.cpp.txt @@ -0,0 +1,6 @@ +[doctest] run with "--help" for options +=============================================================================== +[doctest] test cases: 1 | 1 passed | 0 failed | +[doctest] assertions: 6 | 6 passed | 0 failed | +[doctest] Status: SUCCESS! +Program code. diff --git a/dmff/dpnblist/external/doctest-2.4.11/examples/all_features/test_output/alternative_macros.cpp_junit.txt b/dmff/dpnblist/external/doctest-2.4.11/examples/all_features/test_output/alternative_macros.cpp_junit.txt new file mode 100644 index 00000000..9f5a4865 --- /dev/null +++ b/dmff/dpnblist/external/doctest-2.4.11/examples/all_features/test_output/alternative_macros.cpp_junit.txt @@ -0,0 +1,8 @@ + + + + + + + +Program code. diff --git a/dmff/dpnblist/external/doctest-2.4.11/examples/all_features/test_output/alternative_macros.cpp_xml.txt b/dmff/dpnblist/external/doctest-2.4.11/examples/all_features/test_output/alternative_macros.cpp_xml.txt new file mode 100644 index 00000000..8c7fd67f --- /dev/null +++ b/dmff/dpnblist/external/doctest-2.4.11/examples/all_features/test_output/alternative_macros.cpp_xml.txt @@ -0,0 +1,20 @@ + + + + + + + + + + + + + + + + + + + +Program code. diff --git a/dmff/dpnblist/external/doctest-2.4.11/examples/all_features/test_output/assertion_macros.cpp.txt b/dmff/dpnblist/external/doctest-2.4.11/examples/all_features/test_output/assertion_macros.cpp.txt new file mode 100644 index 00000000..fc4cc946 --- /dev/null +++ b/dmff/dpnblist/external/doctest-2.4.11/examples/all_features/test_output/assertion_macros.cpp.txt @@ -0,0 +1,257 @@ +[doctest] run with "--help" for options +=============================================================================== +assertion_macros.cpp(0): +TEST CASE: normal macros + +assertion_macros.cpp(0): ERROR: CHECK( throw_if(true, std::runtime_error("whops!")) == 42 ) THREW exception: "whops!" + +assertion_macros.cpp(0): ERROR: CHECK( doctest::Approx(0.502) == 0.501 ) is NOT correct! + values: CHECK( Approx( 0.502 ) == 0.501 ) + +=============================================================================== +assertion_macros.cpp(0): +TEST CASE: exceptions-related macros + +assertion_macros.cpp(0): ERROR: CHECK_THROWS( throw_if(false, 0) ) did NOT throw at all! + +assertion_macros.cpp(0): ERROR: CHECK_THROWS_AS( throw_if(true, 0), char ) threw a DIFFERENT exception: "0" + +assertion_macros.cpp(0): ERROR: CHECK_THROWS_AS( throw_if(false, 0), int ) did NOT throw at all! + +assertion_macros.cpp(0): ERROR: CHECK_THROWS_WITH( throw_if(true, "whops!"), "whops! no match!" ) threw a DIFFERENT exception: "whops!" + +assertion_macros.cpp(0): ERROR: CHECK_THROWS_WITH( throw_if(true, "whops! does it match?"), "whops! no match!" ) threw a DIFFERENT exception: "whops! does it match?" + +assertion_macros.cpp(0): ERROR: CHECK_THROWS_WITH_AS( throw_if(true, "whops!"), "whops! no match!", bool ) threw a DIFFERENT exception! (contents: "whops!") + +assertion_macros.cpp(0): ERROR: CHECK_THROWS_WITH_AS( throw_if(true, "whops!"), "whops!", int ) threw a DIFFERENT exception! (contents: "whops!") + +assertion_macros.cpp(0): ERROR: CHECK_THROWS_WITH_AS( throw_if(true, "whops! does it match?"), "whops! no match!", int ) threw a DIFFERENT exception! (contents: "whops! does it match?") + +assertion_macros.cpp(0): ERROR: CHECK_NOTHROW( throw_if(true, 0) ) THREW exception: "0" + +=============================================================================== +assertion_macros.cpp(0): +TEST CASE: exceptions-related macros for std::exception + +assertion_macros.cpp(0): ERROR: CHECK_THROWS( throw_if(false, 0) ) did NOT throw at all! + +assertion_macros.cpp(0): ERROR: CHECK_THROWS_AS( throw_if(false, std::runtime_error("whops!")), std::exception ) did NOT throw at all! + +assertion_macros.cpp(0): ERROR: CHECK_THROWS_AS( throw_if(true, std::runtime_error("whops!")), int ) threw a DIFFERENT exception: "whops!" + +assertion_macros.cpp(0): ERROR: CHECK_THROWS_WITH( throw_if(false, ""), "whops!" ) did NOT throw at all! + +assertion_macros.cpp(0): FATAL ERROR: REQUIRE_NOTHROW( throw_if(true, std::runtime_error("whops!")) ) THREW exception: "whops!" + +=============================================================================== +assertion_macros.cpp(0): +TEST CASE: WARN level of asserts don't fail the test case + +assertion_macros.cpp(0): WARNING: WARN( 0 ) is NOT correct! + values: WARN( 0 ) + +assertion_macros.cpp(0): WARNING: WARN_FALSE( 1 ) is NOT correct! + values: WARN_FALSE( 1 ) + +assertion_macros.cpp(0): WARNING: WARN_THROWS( throw_if(false, 0) ) did NOT throw at all! + +assertion_macros.cpp(0): WARNING: WARN_THROWS_WITH( throw_if(true, ""), "whops!" ) threw a DIFFERENT exception: + +assertion_macros.cpp(0): WARNING: WARN_THROWS_WITH( throw_if(false, ""), "whops!" ) did NOT throw at all! + +assertion_macros.cpp(0): WARNING: WARN_THROWS_AS( throw_if(false, 0), bool ) did NOT throw at all! + +assertion_macros.cpp(0): WARNING: WARN_THROWS_AS( throw_if(true, 0), bool ) threw a DIFFERENT exception: "0" + +assertion_macros.cpp(0): WARNING: WARN_THROWS_WITH_AS( throw_if(false, ""), "whops!", int ) did NOT throw at all! + +assertion_macros.cpp(0): WARNING: WARN_THROWS_WITH_AS( throw_if(true, ""), "whops!", int ) threw a DIFFERENT exception! (contents: ) + +assertion_macros.cpp(0): WARNING: WARN_NOTHROW( throw_if(true, 0) ) THREW exception: "0" + +assertion_macros.cpp(0): WARNING: WARN_EQ( 1, 0 ) is NOT correct! + values: WARN_EQ( 1, 0 ) + +assertion_macros.cpp(0): WARNING: WARN_UNARY( 0 ) is NOT correct! + values: WARN_UNARY( 0 ) + +assertion_macros.cpp(0): WARNING: WARN_UNARY_FALSE( 1 ) is NOT correct! + values: WARN_UNARY_FALSE( 1 ) + +=============================================================================== +assertion_macros.cpp(0): +TEST CASE: CHECK level of asserts fail the test case but don't abort it + +assertion_macros.cpp(0): ERROR: CHECK( 0 ) is NOT correct! + values: CHECK( 0 ) + +assertion_macros.cpp(0): ERROR: CHECK_FALSE( 1 ) is NOT correct! + values: CHECK_FALSE( 1 ) + +assertion_macros.cpp(0): ERROR: CHECK_THROWS( throw_if(false, 0) ) did NOT throw at all! + +assertion_macros.cpp(0): ERROR: CHECK_THROWS_AS( throw_if(false, 0), bool ) did NOT throw at all! + +assertion_macros.cpp(0): ERROR: CHECK_THROWS_AS( throw_if(true, 0), bool ) threw a DIFFERENT exception: "0" + +assertion_macros.cpp(0): ERROR: CHECK_THROWS_WITH( throw_if(true, 0), "unrecognized" ) threw a DIFFERENT exception: "0" + +assertion_macros.cpp(0): ERROR: CHECK_THROWS_WITH_AS( throw_if(true, 0), "unrecognized", int ) threw a DIFFERENT exception! (contents: "0") + +assertion_macros.cpp(0): ERROR: CHECK_NOTHROW( throw_if(true, 0) ) THREW exception: "0" + +assertion_macros.cpp(0): ERROR: CHECK_EQ( 1, 0 ) is NOT correct! + values: CHECK_EQ( 1, 0 ) + +assertion_macros.cpp(0): ERROR: CHECK_UNARY( 0 ) is NOT correct! + values: CHECK_UNARY( 0 ) + +assertion_macros.cpp(0): ERROR: CHECK_UNARY_FALSE( 1 ) is NOT correct! + values: CHECK_UNARY_FALSE( 1 ) + +assertion_macros.cpp(0): MESSAGE: reached! + +=============================================================================== +assertion_macros.cpp(0): +TEST CASE: REQUIRE level of asserts fail and abort the test case - 1 + +assertion_macros.cpp(0): FATAL ERROR: REQUIRE( 0 ) is NOT correct! + values: REQUIRE( 0 ) + +=============================================================================== +assertion_macros.cpp(0): +TEST CASE: REQUIRE level of asserts fail and abort the test case - 2 + +assertion_macros.cpp(0): FATAL ERROR: REQUIRE_FALSE( 1 ) is NOT correct! + values: REQUIRE_FALSE( 1 ) + +=============================================================================== +assertion_macros.cpp(0): +TEST CASE: REQUIRE level of asserts fail and abort the test case - 3 + +assertion_macros.cpp(0): FATAL ERROR: REQUIRE_THROWS( throw_if(false, 0) ) did NOT throw at all! + +=============================================================================== +assertion_macros.cpp(0): +TEST CASE: REQUIRE level of asserts fail and abort the test case - 4 + +assertion_macros.cpp(0): FATAL ERROR: REQUIRE_THROWS_AS( throw_if(false, 0), bool ) did NOT throw at all! + +=============================================================================== +assertion_macros.cpp(0): +TEST CASE: REQUIRE level of asserts fail and abort the test case - 5 + +assertion_macros.cpp(0): FATAL ERROR: REQUIRE_THROWS_AS( throw_if(true, 0), bool ) threw a DIFFERENT exception: "0" + +=============================================================================== +assertion_macros.cpp(0): +TEST CASE: REQUIRE level of asserts fail and abort the test case - 6 + +assertion_macros.cpp(0): FATAL ERROR: REQUIRE_THROWS_WITH( throw_if(false, ""), "whops!" ) did NOT throw at all! + +=============================================================================== +assertion_macros.cpp(0): +TEST CASE: REQUIRE level of asserts fail and abort the test case - 7 + +assertion_macros.cpp(0): FATAL ERROR: REQUIRE_THROWS_WITH( throw_if(true, ""), "whops!" ) threw a DIFFERENT exception: + +=============================================================================== +assertion_macros.cpp(0): +TEST CASE: REQUIRE level of asserts fail and abort the test case - 8 + +assertion_macros.cpp(0): FATAL ERROR: REQUIRE_THROWS_WITH_AS( throw_if(false, ""), "whops!", bool ) did NOT throw at all! + +=============================================================================== +assertion_macros.cpp(0): +TEST CASE: REQUIRE level of asserts fail and abort the test case - 9 + +assertion_macros.cpp(0): FATAL ERROR: REQUIRE_THROWS_WITH_AS( throw_if(true, ""), "whops!", bool ) threw a DIFFERENT exception! (contents: ) + +=============================================================================== +assertion_macros.cpp(0): +TEST CASE: REQUIRE level of asserts fail and abort the test case - 10 + +assertion_macros.cpp(0): FATAL ERROR: REQUIRE_NOTHROW( throw_if(true, 0) ) THREW exception: "0" + +=============================================================================== +assertion_macros.cpp(0): +TEST CASE: REQUIRE level of asserts fail and abort the test case - 11 + +assertion_macros.cpp(0): FATAL ERROR: REQUIRE_EQ( 1, 0 ) is NOT correct! + values: REQUIRE_EQ( 1, 0 ) + +=============================================================================== +assertion_macros.cpp(0): +TEST CASE: REQUIRE level of asserts fail and abort the test case - 12 + +assertion_macros.cpp(0): FATAL ERROR: REQUIRE_UNARY( 0 ) is NOT correct! + values: REQUIRE_UNARY( 0 ) + +=============================================================================== +assertion_macros.cpp(0): +TEST CASE: REQUIRE level of asserts fail and abort the test case - 13 + +assertion_macros.cpp(0): FATAL ERROR: REQUIRE_UNARY_FALSE( 1 ) is NOT correct! + values: REQUIRE_UNARY_FALSE( 1 ) + +=============================================================================== +assertion_macros.cpp(0): +TEST CASE: some asserts used in a function called by a test case + +assertion_macros.cpp(0): ERROR: CHECK_THROWS_WITH_AS( throw_if(true, false), "unknown exception", int ) threw a DIFFERENT exception! (contents: "unknown exception") + +=============================================================================== +assertion_macros.cpp(0): +TEST CASE: check return values + +assertion_macros.cpp(0): MESSAGE: :D + +assertion_macros.cpp(0): MESSAGE: :D + +assertion_macros.cpp(0): MESSAGE: :D + +assertion_macros.cpp(0): MESSAGE: :D + +assertion_macros.cpp(0): MESSAGE: :D + +assertion_macros.cpp(0): MESSAGE: :D + +assertion_macros.cpp(0): MESSAGE: :D + +assertion_macros.cpp(0): MESSAGE: :D + +assertion_macros.cpp(0): MESSAGE: :D + +=============================================================================== +assertion_macros.cpp(0): +TEST CASE: check return values no print + +assertion_macros.cpp(0): ERROR: CHECK( a == b ) is NOT correct! + values: CHECK( 4 == 2 ) + +assertion_macros.cpp(0): ERROR: CHECK_FALSE( a != b ) is NOT correct! + values: CHECK_FALSE( 4 != 2 ) + +assertion_macros.cpp(0): ERROR: CHECK_EQ( a, b ) is NOT correct! + values: CHECK_EQ( 4, 2 ) + +assertion_macros.cpp(0): ERROR: CHECK_UNARY( a == b ) is NOT correct! + values: CHECK_UNARY( false ) + +assertion_macros.cpp(0): ERROR: CHECK_UNARY_FALSE( a != b ) is NOT correct! + values: CHECK_UNARY_FALSE( true ) + +assertion_macros.cpp(0): ERROR: CHECK_THROWS( throw_if(false, false) ) did NOT throw at all! + +assertion_macros.cpp(0): ERROR: CHECK_THROWS_AS( throw_if(true, 2), doctest::Approx ) threw a DIFFERENT exception: "2" + +assertion_macros.cpp(0): ERROR: CHECK_NOTHROW( throw_if(true, 2) ) THREW exception: "2" + +assertion_macros.cpp(0): ERROR: CHECK_THROWS_WITH( throw_if(true, 2), "1" ) threw a DIFFERENT exception: "2" + +=============================================================================== +[doctest] test cases: 23 | 4 passed | 19 failed | +[doctest] assertions: 98 | 48 passed | 50 failed | +[doctest] Status: FAILURE! +Program code. diff --git a/dmff/dpnblist/external/doctest-2.4.11/examples/all_features/test_output/assertion_macros.cpp_junit.txt b/dmff/dpnblist/external/doctest-2.4.11/examples/all_features/test_output/assertion_macros.cpp_junit.txt new file mode 100644 index 00000000..3802a4e6 --- /dev/null +++ b/dmff/dpnblist/external/doctest-2.4.11/examples/all_features/test_output/assertion_macros.cpp_junit.txt @@ -0,0 +1,385 @@ + + + + + +assertion_macros.cpp(0): +CHECK( throw_if(true, std::runtime_error("whops!")) == 42 ) THREW exception: "whops!" + + + +assertion_macros.cpp(0): +CHECK( doctest::Approx(0.502) == 0.501 ) is NOT correct! + values: CHECK( Approx( 0.502 ) == 0.501 ) + + + + + + +assertion_macros.cpp(0): +CHECK_THROWS( throw_if(false, 0) ) did NOT throw at all! + + + +assertion_macros.cpp(0): +CHECK_THROWS_AS( throw_if(true, 0), char ) threw a DIFFERENT exception: "0" + + + +assertion_macros.cpp(0): +CHECK_THROWS_AS( throw_if(false, 0), int ) did NOT throw at all! + + + +assertion_macros.cpp(0): +CHECK_THROWS_WITH( throw_if(true, "whops!"), "whops! no match!" ) threw a DIFFERENT exception: "whops!" + + + +assertion_macros.cpp(0): +CHECK_THROWS_WITH( throw_if(true, "whops! does it match?"), "whops! no match!" ) threw a DIFFERENT exception: "whops! does it match?" + + + +assertion_macros.cpp(0): +CHECK_THROWS_WITH_AS( throw_if(true, "whops!"), "whops! no match!", bool ) threw a DIFFERENT exception! (contents: "whops!") + + + +assertion_macros.cpp(0): +CHECK_THROWS_WITH_AS( throw_if(true, "whops!"), "whops!", int ) threw a DIFFERENT exception! (contents: "whops!") + + + +assertion_macros.cpp(0): +CHECK_THROWS_WITH_AS( throw_if(true, "whops! does it match?"), "whops! no match!", int ) threw a DIFFERENT exception! (contents: "whops! does it match?") + + + +assertion_macros.cpp(0): +CHECK_NOTHROW( throw_if(true, 0) ) THREW exception: "0" + + + + + +assertion_macros.cpp(0): +CHECK_THROWS( throw_if(false, 0) ) did NOT throw at all! + + + +assertion_macros.cpp(0): +CHECK_THROWS_AS( throw_if(false, std::runtime_error("whops!")), std::exception ) did NOT throw at all! + + + +assertion_macros.cpp(0): +CHECK_THROWS_AS( throw_if(true, std::runtime_error("whops!")), int ) threw a DIFFERENT exception: "whops!" + + + +assertion_macros.cpp(0): +CHECK_THROWS_WITH( throw_if(false, ""), "whops!" ) did NOT throw at all! + + + +assertion_macros.cpp(0): +REQUIRE_NOTHROW( throw_if(true, std::runtime_error("whops!")) ) THREW exception: "whops!" + + + + + +assertion_macros.cpp(0): +WARN( 0 ) is NOT correct! + values: WARN( 0 ) + + + +assertion_macros.cpp(0): +WARN_FALSE( 1 ) is NOT correct! + values: WARN_FALSE( 1 ) + + + +assertion_macros.cpp(0): +WARN_THROWS( throw_if(false, 0) ) did NOT throw at all! + + + +assertion_macros.cpp(0): +WARN_THROWS_WITH( throw_if(true, ""), "whops!" ) threw a DIFFERENT exception: + + + +assertion_macros.cpp(0): +WARN_THROWS_WITH( throw_if(false, ""), "whops!" ) did NOT throw at all! + + + +assertion_macros.cpp(0): +WARN_THROWS_AS( throw_if(false, 0), bool ) did NOT throw at all! + + + +assertion_macros.cpp(0): +WARN_THROWS_AS( throw_if(true, 0), bool ) threw a DIFFERENT exception: "0" + + + +assertion_macros.cpp(0): +WARN_THROWS_WITH_AS( throw_if(false, ""), "whops!", int ) did NOT throw at all! + + + +assertion_macros.cpp(0): +WARN_THROWS_WITH_AS( throw_if(true, ""), "whops!", int ) threw a DIFFERENT exception! (contents: ) + + + +assertion_macros.cpp(0): +WARN_NOTHROW( throw_if(true, 0) ) THREW exception: "0" + + + +assertion_macros.cpp(0): +WARN_EQ( 1, 0 ) is NOT correct! + values: WARN_EQ( 1, 0 ) + + + +assertion_macros.cpp(0): +WARN_UNARY( 0 ) is NOT correct! + values: WARN_UNARY( 0 ) + + + +assertion_macros.cpp(0): +WARN_UNARY_FALSE( 1 ) is NOT correct! + values: WARN_UNARY_FALSE( 1 ) + + + + + +assertion_macros.cpp(0): +CHECK( 0 ) is NOT correct! + values: CHECK( 0 ) + + + +assertion_macros.cpp(0): +CHECK_FALSE( 1 ) is NOT correct! + values: CHECK_FALSE( 1 ) + + + +assertion_macros.cpp(0): +CHECK_THROWS( throw_if(false, 0) ) did NOT throw at all! + + + +assertion_macros.cpp(0): +CHECK_THROWS_AS( throw_if(false, 0), bool ) did NOT throw at all! + + + +assertion_macros.cpp(0): +CHECK_THROWS_AS( throw_if(true, 0), bool ) threw a DIFFERENT exception: "0" + + + +assertion_macros.cpp(0): +CHECK_THROWS_WITH( throw_if(true, 0), "unrecognized" ) threw a DIFFERENT exception: "0" + + + +assertion_macros.cpp(0): +CHECK_THROWS_WITH_AS( throw_if(true, 0), "unrecognized", int ) threw a DIFFERENT exception! (contents: "0") + + + +assertion_macros.cpp(0): +CHECK_NOTHROW( throw_if(true, 0) ) THREW exception: "0" + + + +assertion_macros.cpp(0): +CHECK_EQ( 1, 0 ) is NOT correct! + values: CHECK_EQ( 1, 0 ) + + + +assertion_macros.cpp(0): +CHECK_UNARY( 0 ) is NOT correct! + values: CHECK_UNARY( 0 ) + + + +assertion_macros.cpp(0): +CHECK_UNARY_FALSE( 1 ) is NOT correct! + values: CHECK_UNARY_FALSE( 1 ) + + + + + +assertion_macros.cpp(0): +REQUIRE( 0 ) is NOT correct! + values: REQUIRE( 0 ) + + + + + +assertion_macros.cpp(0): +REQUIRE_FALSE( 1 ) is NOT correct! + values: REQUIRE_FALSE( 1 ) + + + + + +assertion_macros.cpp(0): +REQUIRE_THROWS( throw_if(false, 0) ) did NOT throw at all! + + + + + +assertion_macros.cpp(0): +REQUIRE_THROWS_AS( throw_if(false, 0), bool ) did NOT throw at all! + + + + + +assertion_macros.cpp(0): +REQUIRE_THROWS_AS( throw_if(true, 0), bool ) threw a DIFFERENT exception: "0" + + + + + +assertion_macros.cpp(0): +REQUIRE_THROWS_WITH( throw_if(false, ""), "whops!" ) did NOT throw at all! + + + + + +assertion_macros.cpp(0): +REQUIRE_THROWS_WITH( throw_if(true, ""), "whops!" ) threw a DIFFERENT exception: + + + + + +assertion_macros.cpp(0): +REQUIRE_THROWS_WITH_AS( throw_if(false, ""), "whops!", bool ) did NOT throw at all! + + + + + +assertion_macros.cpp(0): +REQUIRE_THROWS_WITH_AS( throw_if(true, ""), "whops!", bool ) threw a DIFFERENT exception! (contents: ) + + + + + +assertion_macros.cpp(0): +REQUIRE_NOTHROW( throw_if(true, 0) ) THREW exception: "0" + + + + + +assertion_macros.cpp(0): +REQUIRE_EQ( 1, 0 ) is NOT correct! + values: REQUIRE_EQ( 1, 0 ) + + + + + +assertion_macros.cpp(0): +REQUIRE_UNARY( 0 ) is NOT correct! + values: REQUIRE_UNARY( 0 ) + + + + + +assertion_macros.cpp(0): +REQUIRE_UNARY_FALSE( 1 ) is NOT correct! + values: REQUIRE_UNARY_FALSE( 1 ) + + + + + + +assertion_macros.cpp(0): +CHECK_THROWS_WITH_AS( throw_if(true, false), "unknown exception", int ) threw a DIFFERENT exception! (contents: "unknown exception") + + + + + + +assertion_macros.cpp(0): +CHECK( a == b ) is NOT correct! + values: CHECK( 4 == 2 ) + + + +assertion_macros.cpp(0): +CHECK_FALSE( a != b ) is NOT correct! + values: CHECK_FALSE( 4 != 2 ) + + + +assertion_macros.cpp(0): +CHECK_EQ( a, b ) is NOT correct! + values: CHECK_EQ( 4, 2 ) + + + +assertion_macros.cpp(0): +CHECK_UNARY( a == b ) is NOT correct! + values: CHECK_UNARY( false ) + + + +assertion_macros.cpp(0): +CHECK_UNARY_FALSE( a != b ) is NOT correct! + values: CHECK_UNARY_FALSE( true ) + + + +assertion_macros.cpp(0): +CHECK_THROWS( throw_if(false, false) ) did NOT throw at all! + + + +assertion_macros.cpp(0): +CHECK_THROWS_AS( throw_if(true, 2), doctest::Approx ) threw a DIFFERENT exception: "2" + + + +assertion_macros.cpp(0): +CHECK_NOTHROW( throw_if(true, 2) ) THREW exception: "2" + + + +assertion_macros.cpp(0): +CHECK_THROWS_WITH( throw_if(true, 2), "1" ) threw a DIFFERENT exception: "2" + + + + + +Program code. diff --git a/dmff/dpnblist/external/doctest-2.4.11/examples/all_features/test_output/assertion_macros.cpp_xml.txt b/dmff/dpnblist/external/doctest-2.4.11/examples/all_features/test_output/assertion_macros.cpp_xml.txt new file mode 100644 index 00000000..b67c33aa --- /dev/null +++ b/dmff/dpnblist/external/doctest-2.4.11/examples/all_features/test_output/assertion_macros.cpp_xml.txt @@ -0,0 +1,690 @@ + + + + + + + + throw_if(true, std::runtime_error("whops!")) == 42 + + + "whops!" + + + + + doctest::Approx(0.502) == 0.501 + + + Approx( 0.502 ) == 0.501 + + + + + + + + + + + throw_if(false, 0) + + + + + throw_if(true, 0) + + + "0" + + + char + + + + + throw_if(false, 0) + + + int + + + + + throw_if(true, "whops!") + + + "whops!" + + + whops! no match! + + + + + throw_if(true, "whops! does it match?") + + + "whops! does it match?" + + + whops! no match! + + + + + throw_if(true, "whops!") + + + "whops!" + + + bool + + + whops! no match! + + + + + throw_if(true, "whops!") + + + "whops!" + + + int + + + whops! + + + + + throw_if(true, "whops! does it match?") + + + "whops! does it match?" + + + int + + + whops! no match! + + + + + throw_if(true, 0) + + + "0" + + + + + + + + throw_if(false, 0) + + + + + throw_if(false, std::runtime_error("whops!")) + + + std::exception + + + + + throw_if(true, std::runtime_error("whops!")) + + + "whops!" + + + int + + + + + throw_if(false, "") + + + whops! + + + + + throw_if(true, std::runtime_error("whops!")) + + + "whops!" + + + + + + + + 0 + + + 0 + + + + + 1 + + + 1 + + + + + throw_if(false, 0) + + + + + throw_if(true, "") + + + + whops! + + + + + throw_if(false, "") + + + whops! + + + + + throw_if(false, 0) + + + bool + + + + + throw_if(true, 0) + + + "0" + + + bool + + + + + throw_if(false, "") + + + int + + + whops! + + + + + throw_if(true, "") + + + + int + + + whops! + + + + + throw_if(true, 0) + + + "0" + + + + + 1, 0 + + + 1, 0 + + + + + 0 + + + 0 + + + + + 1 + + + 1 + + + + + + + + 0 + + + 0 + + + + + 1 + + + 1 + + + + + throw_if(false, 0) + + + + + throw_if(false, 0) + + + bool + + + + + throw_if(true, 0) + + + "0" + + + bool + + + + + throw_if(true, 0) + + + "0" + + + unrecognized + + + + + throw_if(true, 0) + + + "0" + + + int + + + unrecognized + + + + + throw_if(true, 0) + + + "0" + + + + + 1, 0 + + + 1, 0 + + + + + 0 + + + 0 + + + + + 1 + + + 1 + + + + + reached! + + + + + + + + 0 + + + 0 + + + + + + + + 1 + + + 1 + + + + + + + + throw_if(false, 0) + + + + + + + + throw_if(false, 0) + + + bool + + + + + + + + throw_if(true, 0) + + + "0" + + + bool + + + + + + + + throw_if(false, "") + + + whops! + + + + + + + + throw_if(true, "") + + + + whops! + + + + + + + + throw_if(false, "") + + + bool + + + whops! + + + + + + + + throw_if(true, "") + + + + bool + + + whops! + + + + + + + + throw_if(true, 0) + + + "0" + + + + + + + + 1, 0 + + + 1, 0 + + + + + + + + 0 + + + 0 + + + + + + + + 1 + + + 1 + + + + + + + + + + + throw_if(true, false) + + + "unknown exception" + + + int + + + unknown exception + + + + + + + + :D + + + + + :D + + + + + :D + + + + + :D + + + + + :D + + + + + :D + + + + + :D + + + + + :D + + + + + :D + + + + + + + + a == b + + + 4 == 2 + + + + + a != b + + + 4 != 2 + + + + + a, b + + + 4, 2 + + + + + a == b + + + false + + + + + a != b + + + true + + + + + throw_if(false, false) + + + + + throw_if(true, 2) + + + "2" + + + doctest::Approx + + + + + throw_if(true, 2) + + + "2" + + + + + throw_if(true, 2) + + + "2" + + + 1 + + + + + + + + +Program code. diff --git a/dmff/dpnblist/external/doctest-2.4.11/examples/all_features/test_output/asserts_used_outside_of_tests.cpp.txt b/dmff/dpnblist/external/doctest-2.4.11/examples/all_features/test_output/asserts_used_outside_of_tests.cpp.txt new file mode 100644 index 00000000..9c090606 --- /dev/null +++ b/dmff/dpnblist/external/doctest-2.4.11/examples/all_features/test_output/asserts_used_outside_of_tests.cpp.txt @@ -0,0 +1,16 @@ +[doctest] run with "--help" for options +=============================================================================== +[doctest] test cases: 0 | 0 passed | 0 failed | +[doctest] assertions: 0 | 0 passed | 0 failed | +[doctest] Status: SUCCESS! +Program code. +asserts_used_outside_of_tests.cpp(19): ERROR: CHECK_EQ( true, false ) is NOT correct! + values: CHECK_EQ( true, false ) +asserts_used_outside_of_tests.cpp(20): ERROR: CHECK_UNARY( false ) is NOT correct! + values: CHECK_UNARY( false ) +asserts_used_outside_of_tests.cpp(21): ERROR: CHECK_UNARY_FALSE( true ) is NOT correct! + values: CHECK_UNARY_FALSE( true ) +asserts_used_outside_of_tests.cpp(23): ERROR: CHECK( false ) is NOT correct! + values: CHECK( false ) +hello! +asserts_used_outside_of_tests.cpp(24): ERROR: an assert dealing with exceptions has failed! diff --git a/dmff/dpnblist/external/doctest-2.4.11/examples/all_features/test_output/asserts_used_outside_of_tests.cpp_junit.txt b/dmff/dpnblist/external/doctest-2.4.11/examples/all_features/test_output/asserts_used_outside_of_tests.cpp_junit.txt new file mode 100644 index 00000000..5727760e --- /dev/null +++ b/dmff/dpnblist/external/doctest-2.4.11/examples/all_features/test_output/asserts_used_outside_of_tests.cpp_junit.txt @@ -0,0 +1,15 @@ + + + + +Program code. +asserts_used_outside_of_tests.cpp(19): ERROR: CHECK_EQ( true, false ) is NOT correct! + values: CHECK_EQ( true, false ) +asserts_used_outside_of_tests.cpp(20): ERROR: CHECK_UNARY( false ) is NOT correct! + values: CHECK_UNARY( false ) +asserts_used_outside_of_tests.cpp(21): ERROR: CHECK_UNARY_FALSE( true ) is NOT correct! + values: CHECK_UNARY_FALSE( true ) +asserts_used_outside_of_tests.cpp(23): ERROR: CHECK( false ) is NOT correct! + values: CHECK( false ) +hello! +asserts_used_outside_of_tests.cpp(24): ERROR: an assert dealing with exceptions has failed! diff --git a/dmff/dpnblist/external/doctest-2.4.11/examples/all_features/test_output/asserts_used_outside_of_tests.cpp_xml.txt b/dmff/dpnblist/external/doctest-2.4.11/examples/all_features/test_output/asserts_used_outside_of_tests.cpp_xml.txt new file mode 100644 index 00000000..6490fb18 --- /dev/null +++ b/dmff/dpnblist/external/doctest-2.4.11/examples/all_features/test_output/asserts_used_outside_of_tests.cpp_xml.txt @@ -0,0 +1,17 @@ + + + + + + +Program code. +asserts_used_outside_of_tests.cpp(19): ERROR: CHECK_EQ( true, false ) is NOT correct! + values: CHECK_EQ( true, false ) +asserts_used_outside_of_tests.cpp(20): ERROR: CHECK_UNARY( false ) is NOT correct! + values: CHECK_UNARY( false ) +asserts_used_outside_of_tests.cpp(21): ERROR: CHECK_UNARY_FALSE( true ) is NOT correct! + values: CHECK_UNARY_FALSE( true ) +asserts_used_outside_of_tests.cpp(23): ERROR: CHECK( false ) is NOT correct! + values: CHECK( false ) +hello! +asserts_used_outside_of_tests.cpp(24): ERROR: an assert dealing with exceptions has failed! diff --git a/dmff/dpnblist/external/doctest-2.4.11/examples/all_features/test_output/count.txt b/dmff/dpnblist/external/doctest-2.4.11/examples/all_features/test_output/count.txt new file mode 100644 index 00000000..f7427164 --- /dev/null +++ b/dmff/dpnblist/external/doctest-2.4.11/examples/all_features/test_output/count.txt @@ -0,0 +1,2 @@ +=============================================================================== +[doctest] unskipped test cases passing the current filters: 4 diff --git a/dmff/dpnblist/external/doctest-2.4.11/examples/all_features/test_output/count_junit.txt b/dmff/dpnblist/external/doctest-2.4.11/examples/all_features/test_output/count_junit.txt new file mode 100644 index 00000000..12bbf745 --- /dev/null +++ b/dmff/dpnblist/external/doctest-2.4.11/examples/all_features/test_output/count_junit.txt @@ -0,0 +1 @@ + diff --git a/dmff/dpnblist/external/doctest-2.4.11/examples/all_features/test_output/count_xml.txt b/dmff/dpnblist/external/doctest-2.4.11/examples/all_features/test_output/count_xml.txt new file mode 100644 index 00000000..82064e68 --- /dev/null +++ b/dmff/dpnblist/external/doctest-2.4.11/examples/all_features/test_output/count_xml.txt @@ -0,0 +1,5 @@ + + + + + diff --git a/dmff/dpnblist/external/doctest-2.4.11/examples/all_features/test_output/coverage_maxout.cpp.txt b/dmff/dpnblist/external/doctest-2.4.11/examples/all_features/test_output/coverage_maxout.cpp.txt new file mode 100644 index 00000000..e0c193dd --- /dev/null +++ b/dmff/dpnblist/external/doctest-2.4.11/examples/all_features/test_output/coverage_maxout.cpp.txt @@ -0,0 +1,43 @@ +[doctest] run with "--help" for options +=============================================================================== +coverage_maxout.cpp(0): +TEST CASE: exercising tricky code paths of doctest + +coverage_maxout.cpp(0): ERROR: CHECK( str.compare(const_str, true) != 0 ) is NOT correct! + values: CHECK( 0 != 0 ) + logged: should fail + +coverage_maxout.cpp(0): ERROR: CHECK( str.compare("omgomgomg", false) != 0 ) is NOT correct! + values: CHECK( 0 != 0 ) + logged: should fail + +coverage_maxout.cpp(0): ERROR: CHECK_FALSE( isThereAnything ) is NOT correct! + values: CHECK_FALSE( true ) + logged: should fail + +=============================================================================== +coverage_maxout.cpp(0): +TEST SUITE: exception related +TEST CASE: will end from a std::string exception + +coverage_maxout.cpp(0): ERROR: test case THREW exception: std::string! + +=============================================================================== +coverage_maxout.cpp(0): +TEST SUITE: exception related +TEST CASE: will end from a const char* exception + +coverage_maxout.cpp(0): ERROR: test case THREW exception: const char*! + +=============================================================================== +coverage_maxout.cpp(0): +TEST SUITE: exception related +TEST CASE: will end from an unknown exception + +coverage_maxout.cpp(0): ERROR: test case THREW exception: unknown exception + +=============================================================================== +[doctest] test cases: 4 | 0 passed | 4 failed | +[doctest] assertions: 31 | 28 passed | 3 failed | +[doctest] Status: FAILURE! +Program code. diff --git a/dmff/dpnblist/external/doctest-2.4.11/examples/all_features/test_output/coverage_maxout.cpp_junit.txt b/dmff/dpnblist/external/doctest-2.4.11/examples/all_features/test_output/coverage_maxout.cpp_junit.txt new file mode 100644 index 00000000..8f1e9920 --- /dev/null +++ b/dmff/dpnblist/external/doctest-2.4.11/examples/all_features/test_output/coverage_maxout.cpp_junit.txt @@ -0,0 +1,44 @@ + + + + + +coverage_maxout.cpp(0): +CHECK( str.compare(const_str, true) != 0 ) is NOT correct! + values: CHECK( 0 != 0 ) + logged: should fail + + + +coverage_maxout.cpp(0): +CHECK( str.compare("omgomgomg", false) != 0 ) is NOT correct! + values: CHECK( 0 != 0 ) + logged: should fail + + + +coverage_maxout.cpp(0): +CHECK_FALSE( isThereAnything ) is NOT correct! + values: CHECK_FALSE( true ) + logged: should fail + + + + + + std::string! + + + + + const char*! + + + + + unknown exception + + + + +Program code. diff --git a/dmff/dpnblist/external/doctest-2.4.11/examples/all_features/test_output/coverage_maxout.cpp_xml.txt b/dmff/dpnblist/external/doctest-2.4.11/examples/all_features/test_output/coverage_maxout.cpp_xml.txt new file mode 100644 index 00000000..9a9bf100 --- /dev/null +++ b/dmff/dpnblist/external/doctest-2.4.11/examples/all_features/test_output/coverage_maxout.cpp_xml.txt @@ -0,0 +1,65 @@ + + + + + + + + str.compare(const_str, true) != 0 + + + 0 != 0 + + + should fail + + + + + str.compare("omgomgomg", false) != 0 + + + 0 != 0 + + + should fail + + + + + isThereAnything + + + true + + + should fail + + + + + + + + + std::string! + + + + + + const char*! + + + + + + unknown exception + + + + + + + +Program code. diff --git a/dmff/dpnblist/external/doctest-2.4.11/examples/all_features/test_output/decomposition.cpp.txt b/dmff/dpnblist/external/doctest-2.4.11/examples/all_features/test_output/decomposition.cpp.txt new file mode 100644 index 00000000..5772c4ee --- /dev/null +++ b/dmff/dpnblist/external/doctest-2.4.11/examples/all_features/test_output/decomposition.cpp.txt @@ -0,0 +1,16 @@ +[doctest] run with "--help" for options +=============================================================================== +decomposition.cpp(0): +TEST CASE: Move Only Type + +decomposition.cpp(0): ERROR: CHECK( genType(false) ) is NOT correct! + values: CHECK( {?} ) + +decomposition.cpp(0): ERROR: CHECK( a ) is NOT correct! + values: CHECK( {?} ) + +=============================================================================== +[doctest] test cases: 2 | 1 passed | 1 failed | +[doctest] assertions: 4 | 2 passed | 2 failed | +[doctest] Status: FAILURE! +Program code. diff --git a/dmff/dpnblist/external/doctest-2.4.11/examples/all_features/test_output/decomposition.cpp_junit.txt b/dmff/dpnblist/external/doctest-2.4.11/examples/all_features/test_output/decomposition.cpp_junit.txt new file mode 100644 index 00000000..4c51610d --- /dev/null +++ b/dmff/dpnblist/external/doctest-2.4.11/examples/all_features/test_output/decomposition.cpp_junit.txt @@ -0,0 +1,21 @@ + + + + + +decomposition.cpp(0): +CHECK( genType(false) ) is NOT correct! + values: CHECK( {?} ) + + + +decomposition.cpp(0): +CHECK( a ) is NOT correct! + values: CHECK( {?} ) + + + + + + +Program code. diff --git a/dmff/dpnblist/external/doctest-2.4.11/examples/all_features/test_output/decomposition.cpp_xml.txt b/dmff/dpnblist/external/doctest-2.4.11/examples/all_features/test_output/decomposition.cpp_xml.txt new file mode 100644 index 00000000..e668a0f0 --- /dev/null +++ b/dmff/dpnblist/external/doctest-2.4.11/examples/all_features/test_output/decomposition.cpp_xml.txt @@ -0,0 +1,31 @@ + + + + + + + + genType(false) + + + {?} + + + + + a + + + {?} + + + + + + + + + + + +Program code. diff --git a/dmff/dpnblist/external/doctest-2.4.11/examples/all_features/test_output/disabled.txt b/dmff/dpnblist/external/doctest-2.4.11/examples/all_features/test_output/disabled.txt new file mode 100644 index 00000000..fd6c04e6 --- /dev/null +++ b/dmff/dpnblist/external/doctest-2.4.11/examples/all_features/test_output/disabled.txt @@ -0,0 +1 @@ +Program code. diff --git a/dmff/dpnblist/external/doctest-2.4.11/examples/all_features/test_output/disabled_but_evaluated.txt b/dmff/dpnblist/external/doctest-2.4.11/examples/all_features/test_output/disabled_but_evaluated.txt new file mode 100644 index 00000000..e69de29b diff --git a/dmff/dpnblist/external/doctest-2.4.11/examples/all_features/test_output/doctest_proxy.h.txt b/dmff/dpnblist/external/doctest-2.4.11/examples/all_features/test_output/doctest_proxy.h.txt new file mode 100644 index 00000000..668d9dd1 --- /dev/null +++ b/dmff/dpnblist/external/doctest-2.4.11/examples/all_features/test_output/doctest_proxy.h.txt @@ -0,0 +1,6 @@ +[doctest] run with "--help" for options +=============================================================================== +[doctest] test cases: 0 | 0 passed | 0 failed | +[doctest] assertions: 0 | 0 passed | 0 failed | +[doctest] Status: SUCCESS! +Program code. diff --git a/dmff/dpnblist/external/doctest-2.4.11/examples/all_features/test_output/doctest_proxy.h_junit.txt b/dmff/dpnblist/external/doctest-2.4.11/examples/all_features/test_output/doctest_proxy.h_junit.txt new file mode 100644 index 00000000..04b87701 --- /dev/null +++ b/dmff/dpnblist/external/doctest-2.4.11/examples/all_features/test_output/doctest_proxy.h_junit.txt @@ -0,0 +1,5 @@ + + + + +Program code. diff --git a/dmff/dpnblist/external/doctest-2.4.11/examples/all_features/test_output/doctest_proxy.h_xml.txt b/dmff/dpnblist/external/doctest-2.4.11/examples/all_features/test_output/doctest_proxy.h_xml.txt new file mode 100644 index 00000000..1ea28b6c --- /dev/null +++ b/dmff/dpnblist/external/doctest-2.4.11/examples/all_features/test_output/doctest_proxy.h_xml.txt @@ -0,0 +1,7 @@ + + + + + + +Program code. diff --git a/dmff/dpnblist/external/doctest-2.4.11/examples/all_features/test_output/double_stringification.cpp.txt b/dmff/dpnblist/external/doctest-2.4.11/examples/all_features/test_output/double_stringification.cpp.txt new file mode 100644 index 00000000..75be56a8 --- /dev/null +++ b/dmff/dpnblist/external/doctest-2.4.11/examples/all_features/test_output/double_stringification.cpp.txt @@ -0,0 +1,6 @@ +[doctest] run with "--help" for options +=============================================================================== +[doctest] test cases: 1 | 1 passed | 0 failed | +[doctest] assertions: 3 | 3 passed | 0 failed | +[doctest] Status: SUCCESS! +Program code. diff --git a/dmff/dpnblist/external/doctest-2.4.11/examples/all_features/test_output/double_stringification.cpp_junit.txt b/dmff/dpnblist/external/doctest-2.4.11/examples/all_features/test_output/double_stringification.cpp_junit.txt new file mode 100644 index 00000000..982ca2e8 --- /dev/null +++ b/dmff/dpnblist/external/doctest-2.4.11/examples/all_features/test_output/double_stringification.cpp_junit.txt @@ -0,0 +1,7 @@ + + + + + + +Program code. diff --git a/dmff/dpnblist/external/doctest-2.4.11/examples/all_features/test_output/double_stringification.cpp_xml.txt b/dmff/dpnblist/external/doctest-2.4.11/examples/all_features/test_output/double_stringification.cpp_xml.txt new file mode 100644 index 00000000..9403b1c1 --- /dev/null +++ b/dmff/dpnblist/external/doctest-2.4.11/examples/all_features/test_output/double_stringification.cpp_xml.txt @@ -0,0 +1,12 @@ + + + + + + + + + + + +Program code. diff --git a/dmff/dpnblist/external/doctest-2.4.11/examples/all_features/test_output/enums.cpp.txt b/dmff/dpnblist/external/doctest-2.4.11/examples/all_features/test_output/enums.cpp.txt new file mode 100644 index 00000000..bb739e68 --- /dev/null +++ b/dmff/dpnblist/external/doctest-2.4.11/examples/all_features/test_output/enums.cpp.txt @@ -0,0 +1,65 @@ +[doctest] run with "--help" for options +=============================================================================== +enums.cpp(0): +TEST CASE: enum 2 + +enums.cpp(0): ERROR: CHECK_EQ( castToUnderlying(Zero), 1 ) is NOT correct! + values: CHECK_EQ( 0, 1 ) + +enums.cpp(0): ERROR: CHECK_EQ( castToUnderlying(One), 2 ) is NOT correct! + values: CHECK_EQ( 1, 2 ) + +enums.cpp(0): ERROR: CHECK_EQ( castToUnderlying(Two), 3 ) is NOT correct! + values: CHECK_EQ( 2, 3 ) + +enums.cpp(0): ERROR: CHECK_EQ( castToUnderlying(TypedZero), 1 ) is NOT correct! + values: CHECK_EQ( 0, 1 ) + +enums.cpp(0): ERROR: CHECK_EQ( castToUnderlying(TypedOne), 2 ) is NOT correct! + values: CHECK_EQ( 1, 2 ) + +enums.cpp(0): ERROR: CHECK_EQ( castToUnderlying(TypedTwo), 3 ) is NOT correct! + values: CHECK_EQ( 2, 3 ) + +enums.cpp(0): ERROR: CHECK_EQ( EnumClassC::Zero, EnumClassC::One ) is NOT correct! + values: CHECK_EQ( 48, 49 ) + +enums.cpp(0): ERROR: CHECK_EQ( EnumClassC::One, EnumClassC::Two ) is NOT correct! + values: CHECK_EQ( 49, 50 ) + +enums.cpp(0): ERROR: CHECK_EQ( EnumClassC::Two, EnumClassC::Zero ) is NOT correct! + values: CHECK_EQ( 50, 48 ) + +enums.cpp(0): ERROR: CHECK_EQ( EnumClassSC::Zero, EnumClassSC::One ) is NOT correct! + values: CHECK_EQ( 48, 49 ) + +enums.cpp(0): ERROR: CHECK_EQ( EnumClassSC::One, EnumClassSC::Two ) is NOT correct! + values: CHECK_EQ( 49, 50 ) + +enums.cpp(0): ERROR: CHECK_EQ( EnumClassSC::Two, EnumClassSC::Zero ) is NOT correct! + values: CHECK_EQ( 50, 48 ) + +enums.cpp(0): ERROR: CHECK_EQ( EnumClassUC::Zero, EnumClassUC::One ) is NOT correct! + values: CHECK_EQ( 48, 49 ) + +enums.cpp(0): ERROR: CHECK_EQ( EnumClassUC::One, EnumClassUC::Two ) is NOT correct! + values: CHECK_EQ( 49, 50 ) + +enums.cpp(0): ERROR: CHECK_EQ( EnumClassUC::Two, EnumClassUC::Zero ) is NOT correct! + values: CHECK_EQ( 50, 48 ) + +enums.cpp(0): ERROR: CHECK_EQ( EnumClassU8::Zero, EnumClassU8::One ) is NOT correct! + values: CHECK_EQ( 0, 1 ) + +enums.cpp(0): ERROR: CHECK_EQ( EnumClassU8::One, EnumClassU8::Two ) is NOT correct! + values: CHECK_EQ( 1, 2 ) + +enums.cpp(0): ERROR: CHECK_EQ( EnumClassU8::Two, EnumClassU8::Zero ) is NOT correct! + values: CHECK_EQ( 2, 0 ) + +Failed as expected so marking it as not failed +=============================================================================== +[doctest] test cases: 2 | 2 passed | 0 failed | +[doctest] assertions: 27 | 9 passed | 18 failed | +[doctest] Status: SUCCESS! +Program code. diff --git a/dmff/dpnblist/external/doctest-2.4.11/examples/all_features/test_output/enums.cpp_junit.txt b/dmff/dpnblist/external/doctest-2.4.11/examples/all_features/test_output/enums.cpp_junit.txt new file mode 100644 index 00000000..325c31e6 --- /dev/null +++ b/dmff/dpnblist/external/doctest-2.4.11/examples/all_features/test_output/enums.cpp_junit.txt @@ -0,0 +1,117 @@ + + + + + + +enums.cpp(0): +CHECK_EQ( castToUnderlying(Zero), 1 ) is NOT correct! + values: CHECK_EQ( 0, 1 ) + + + +enums.cpp(0): +CHECK_EQ( castToUnderlying(One), 2 ) is NOT correct! + values: CHECK_EQ( 1, 2 ) + + + +enums.cpp(0): +CHECK_EQ( castToUnderlying(Two), 3 ) is NOT correct! + values: CHECK_EQ( 2, 3 ) + + + +enums.cpp(0): +CHECK_EQ( castToUnderlying(TypedZero), 1 ) is NOT correct! + values: CHECK_EQ( 0, 1 ) + + + +enums.cpp(0): +CHECK_EQ( castToUnderlying(TypedOne), 2 ) is NOT correct! + values: CHECK_EQ( 1, 2 ) + + + +enums.cpp(0): +CHECK_EQ( castToUnderlying(TypedTwo), 3 ) is NOT correct! + values: CHECK_EQ( 2, 3 ) + + + +enums.cpp(0): +CHECK_EQ( EnumClassC::Zero, EnumClassC::One ) is NOT correct! + values: CHECK_EQ( 48, 49 ) + + + +enums.cpp(0): +CHECK_EQ( EnumClassC::One, EnumClassC::Two ) is NOT correct! + values: CHECK_EQ( 49, 50 ) + + + +enums.cpp(0): +CHECK_EQ( EnumClassC::Two, EnumClassC::Zero ) is NOT correct! + values: CHECK_EQ( 50, 48 ) + + + +enums.cpp(0): +CHECK_EQ( EnumClassSC::Zero, EnumClassSC::One ) is NOT correct! + values: CHECK_EQ( 48, 49 ) + + + +enums.cpp(0): +CHECK_EQ( EnumClassSC::One, EnumClassSC::Two ) is NOT correct! + values: CHECK_EQ( 49, 50 ) + + + +enums.cpp(0): +CHECK_EQ( EnumClassSC::Two, EnumClassSC::Zero ) is NOT correct! + values: CHECK_EQ( 50, 48 ) + + + +enums.cpp(0): +CHECK_EQ( EnumClassUC::Zero, EnumClassUC::One ) is NOT correct! + values: CHECK_EQ( 48, 49 ) + + + +enums.cpp(0): +CHECK_EQ( EnumClassUC::One, EnumClassUC::Two ) is NOT correct! + values: CHECK_EQ( 49, 50 ) + + + +enums.cpp(0): +CHECK_EQ( EnumClassUC::Two, EnumClassUC::Zero ) is NOT correct! + values: CHECK_EQ( 50, 48 ) + + + +enums.cpp(0): +CHECK_EQ( EnumClassU8::Zero, EnumClassU8::One ) is NOT correct! + values: CHECK_EQ( 0, 1 ) + + + +enums.cpp(0): +CHECK_EQ( EnumClassU8::One, EnumClassU8::Two ) is NOT correct! + values: CHECK_EQ( 1, 2 ) + + + +enums.cpp(0): +CHECK_EQ( EnumClassU8::Two, EnumClassU8::Zero ) is NOT correct! + values: CHECK_EQ( 2, 0 ) + + + + + +Program code. diff --git a/dmff/dpnblist/external/doctest-2.4.11/examples/all_features/test_output/enums.cpp_xml.txt b/dmff/dpnblist/external/doctest-2.4.11/examples/all_features/test_output/enums.cpp_xml.txt new file mode 100644 index 00000000..1f74d517 --- /dev/null +++ b/dmff/dpnblist/external/doctest-2.4.11/examples/all_features/test_output/enums.cpp_xml.txt @@ -0,0 +1,159 @@ + + + + + + + + + + + castToUnderlying(Zero), 1 + + + 0, 1 + + + + + castToUnderlying(One), 2 + + + 1, 2 + + + + + castToUnderlying(Two), 3 + + + 2, 3 + + + + + castToUnderlying(TypedZero), 1 + + + 0, 1 + + + + + castToUnderlying(TypedOne), 2 + + + 1, 2 + + + + + castToUnderlying(TypedTwo), 3 + + + 2, 3 + + + + + EnumClassC::Zero, EnumClassC::One + + + 48, 49 + + + + + EnumClassC::One, EnumClassC::Two + + + 49, 50 + + + + + EnumClassC::Two, EnumClassC::Zero + + + 50, 48 + + + + + EnumClassSC::Zero, EnumClassSC::One + + + 48, 49 + + + + + EnumClassSC::One, EnumClassSC::Two + + + 49, 50 + + + + + EnumClassSC::Two, EnumClassSC::Zero + + + 50, 48 + + + + + EnumClassUC::Zero, EnumClassUC::One + + + 48, 49 + + + + + EnumClassUC::One, EnumClassUC::Two + + + 49, 50 + + + + + EnumClassUC::Two, EnumClassUC::Zero + + + 50, 48 + + + + + EnumClassU8::Zero, EnumClassU8::One + + + 0, 1 + + + + + EnumClassU8::One, EnumClassU8::Two + + + 1, 2 + + + + + EnumClassU8::Two, EnumClassU8::Zero + + + 2, 0 + + + + + + + + +Program code. diff --git a/dmff/dpnblist/external/doctest-2.4.11/examples/all_features/test_output/filter_1.txt b/dmff/dpnblist/external/doctest-2.4.11/examples/all_features/test_output/filter_1.txt new file mode 100644 index 00000000..668d9dd1 --- /dev/null +++ b/dmff/dpnblist/external/doctest-2.4.11/examples/all_features/test_output/filter_1.txt @@ -0,0 +1,6 @@ +[doctest] run with "--help" for options +=============================================================================== +[doctest] test cases: 0 | 0 passed | 0 failed | +[doctest] assertions: 0 | 0 passed | 0 failed | +[doctest] Status: SUCCESS! +Program code. diff --git a/dmff/dpnblist/external/doctest-2.4.11/examples/all_features/test_output/filter_1_junit.txt b/dmff/dpnblist/external/doctest-2.4.11/examples/all_features/test_output/filter_1_junit.txt new file mode 100644 index 00000000..04b87701 --- /dev/null +++ b/dmff/dpnblist/external/doctest-2.4.11/examples/all_features/test_output/filter_1_junit.txt @@ -0,0 +1,5 @@ + + + + +Program code. diff --git a/dmff/dpnblist/external/doctest-2.4.11/examples/all_features/test_output/filter_1_xml.txt b/dmff/dpnblist/external/doctest-2.4.11/examples/all_features/test_output/filter_1_xml.txt new file mode 100644 index 00000000..1ea28b6c --- /dev/null +++ b/dmff/dpnblist/external/doctest-2.4.11/examples/all_features/test_output/filter_1_xml.txt @@ -0,0 +1,7 @@ + + + + + + +Program code. diff --git a/dmff/dpnblist/external/doctest-2.4.11/examples/all_features/test_output/filter_2.txt b/dmff/dpnblist/external/doctest-2.4.11/examples/all_features/test_output/filter_2.txt new file mode 100644 index 00000000..1f3c3ea8 --- /dev/null +++ b/dmff/dpnblist/external/doctest-2.4.11/examples/all_features/test_output/filter_2.txt @@ -0,0 +1,6 @@ +[doctest] run with "--help" for options +=============================================================================== +[doctest] test cases: 0 | 0 passed | 0 failed | 106 skipped +[doctest] assertions: 0 | 0 passed | 0 failed | +[doctest] Status: SUCCESS! +Program code. diff --git a/dmff/dpnblist/external/doctest-2.4.11/examples/all_features/test_output/filter_2_junit.txt b/dmff/dpnblist/external/doctest-2.4.11/examples/all_features/test_output/filter_2_junit.txt new file mode 100644 index 00000000..04b87701 --- /dev/null +++ b/dmff/dpnblist/external/doctest-2.4.11/examples/all_features/test_output/filter_2_junit.txt @@ -0,0 +1,5 @@ + + + + +Program code. diff --git a/dmff/dpnblist/external/doctest-2.4.11/examples/all_features/test_output/filter_2_xml.txt b/dmff/dpnblist/external/doctest-2.4.11/examples/all_features/test_output/filter_2_xml.txt new file mode 100644 index 00000000..16fe2539 --- /dev/null +++ b/dmff/dpnblist/external/doctest-2.4.11/examples/all_features/test_output/filter_2_xml.txt @@ -0,0 +1,155 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +Program code. diff --git a/dmff/dpnblist/external/doctest-2.4.11/examples/all_features/test_output/filter_3.txt b/dmff/dpnblist/external/doctest-2.4.11/examples/all_features/test_output/filter_3.txt new file mode 100644 index 00000000..7da4b5c4 --- /dev/null +++ b/dmff/dpnblist/external/doctest-2.4.11/examples/all_features/test_output/filter_3.txt @@ -0,0 +1,45 @@ +[doctest] run with "--help" for options + +root + +root +outside of subcase +outside of subcase +outside of subcase +=============================================================================== +subcases.cpp(0): +TEST CASE: subcases can be used in a separate function as well + from function... + +subcases.cpp(0): MESSAGE: print me twice + +=============================================================================== +subcases.cpp(0): +TEST CASE: subcases can be used in a separate function as well + from function... + sc1 + +subcases.cpp(0): MESSAGE: hello! from sc1 + +=============================================================================== +subcases.cpp(0): +TEST CASE: subcases can be used in a separate function as well + +DEEPEST SUBCASE STACK REACHED (DIFFERENT FROM THE CURRENT ONE): + from function... + sc1 + +subcases.cpp(0): MESSAGE: lala + +=============================================================================== +subcases.cpp(0): +TEST SUITE: with a funny name, +TEST CASE: without a funny name: + +subcases.cpp(0): MESSAGE: Nooo + +=============================================================================== +[doctest] test cases: 10 | 10 passed | 0 failed | +[doctest] assertions: 0 | 0 passed | 0 failed | +[doctest] Status: SUCCESS! +Program code. diff --git a/dmff/dpnblist/external/doctest-2.4.11/examples/all_features/test_output/filter_3_junit.txt b/dmff/dpnblist/external/doctest-2.4.11/examples/all_features/test_output/filter_3_junit.txt new file mode 100644 index 00000000..6ea54f98 --- /dev/null +++ b/dmff/dpnblist/external/doctest-2.4.11/examples/all_features/test_output/filter_3_junit.txt @@ -0,0 +1,23 @@ + + +root + +root +outside of subcase +outside of subcase +outside of subcase + + + + + + + + + + + + + + +Program code. diff --git a/dmff/dpnblist/external/doctest-2.4.11/examples/all_features/test_output/filter_3_xml.txt b/dmff/dpnblist/external/doctest-2.4.11/examples/all_features/test_output/filter_3_xml.txt new file mode 100644 index 00000000..f662506c --- /dev/null +++ b/dmff/dpnblist/external/doctest-2.4.11/examples/all_features/test_output/filter_3_xml.txt @@ -0,0 +1,72 @@ + + + + + + +root + + + + +root +outside of subcase +outside of subcase +outside of subcase + + + + + + + print me twice + + + + + + hello! from sc1 + + + + + + + lala + + + + + + + + + + + + + + + + + + + + + + + + + + + + Nooo + + + + + + + + +Program code. diff --git a/dmff/dpnblist/external/doctest-2.4.11/examples/all_features/test_output/filter_4.txt b/dmff/dpnblist/external/doctest-2.4.11/examples/all_features/test_output/filter_4.txt new file mode 100644 index 00000000..5262e441 --- /dev/null +++ b/dmff/dpnblist/external/doctest-2.4.11/examples/all_features/test_output/filter_4.txt @@ -0,0 +1,22 @@ +[doctest] run with "--help" for options +=============================================================================== +subcases.cpp(0): +TEST SUITE: with a funny name, +TEST CASE: with a funnier name\: + with the funniest name\, + +subcases.cpp(0): MESSAGE: Yes! + +=============================================================================== +subcases.cpp(0): +TEST SUITE: with a funny name, +TEST CASE: with a funnier name\: + with a slightly funny name : + +subcases.cpp(0): MESSAGE: Yep! + +=============================================================================== +[doctest] test cases: 1 | 1 passed | 0 failed | +[doctest] assertions: 0 | 0 passed | 0 failed | +[doctest] Status: SUCCESS! +Program code. diff --git a/dmff/dpnblist/external/doctest-2.4.11/examples/all_features/test_output/filter_4_junit.txt b/dmff/dpnblist/external/doctest-2.4.11/examples/all_features/test_output/filter_4_junit.txt new file mode 100644 index 00000000..e62f6c2a --- /dev/null +++ b/dmff/dpnblist/external/doctest-2.4.11/examples/all_features/test_output/filter_4_junit.txt @@ -0,0 +1,8 @@ + + + + + + + +Program code. diff --git a/dmff/dpnblist/external/doctest-2.4.11/examples/all_features/test_output/filter_4_xml.txt b/dmff/dpnblist/external/doctest-2.4.11/examples/all_features/test_output/filter_4_xml.txt new file mode 100644 index 00000000..5815b5ed --- /dev/null +++ b/dmff/dpnblist/external/doctest-2.4.11/examples/all_features/test_output/filter_4_xml.txt @@ -0,0 +1,26 @@ + + + + + + + + + Yes! + + + + + + + Yep! + + + + + + + + + +Program code. diff --git a/dmff/dpnblist/external/doctest-2.4.11/examples/all_features/test_output/first_last.txt b/dmff/dpnblist/external/doctest-2.4.11/examples/all_features/test_output/first_last.txt new file mode 100644 index 00000000..385376fc --- /dev/null +++ b/dmff/dpnblist/external/doctest-2.4.11/examples/all_features/test_output/first_last.txt @@ -0,0 +1,27 @@ +[doctest] run with "--help" for options +=============================================================================== +coverage_maxout.cpp(0): +TEST SUITE: exception related +TEST CASE: will end from a std::string exception + +coverage_maxout.cpp(0): ERROR: test case THREW exception: std::string! + +=============================================================================== +coverage_maxout.cpp(0): +TEST SUITE: exception related +TEST CASE: will end from a const char* exception + +coverage_maxout.cpp(0): ERROR: test case THREW exception: const char*! + +=============================================================================== +coverage_maxout.cpp(0): +TEST SUITE: exception related +TEST CASE: will end from an unknown exception + +coverage_maxout.cpp(0): ERROR: test case THREW exception: unknown exception + +=============================================================================== +[doctest] test cases: 4 | 1 passed | 3 failed | +[doctest] assertions: 0 | 0 passed | 0 failed | +[doctest] Status: FAILURE! +Program code. diff --git a/dmff/dpnblist/external/doctest-2.4.11/examples/all_features/test_output/first_last_junit.txt b/dmff/dpnblist/external/doctest-2.4.11/examples/all_features/test_output/first_last_junit.txt new file mode 100644 index 00000000..f08b9110 --- /dev/null +++ b/dmff/dpnblist/external/doctest-2.4.11/examples/all_features/test_output/first_last_junit.txt @@ -0,0 +1,21 @@ + + + + + + std::string! + + + + + const char*! + + + + + unknown exception + + + + +Program code. diff --git a/dmff/dpnblist/external/doctest-2.4.11/examples/all_features/test_output/first_last_xml.txt b/dmff/dpnblist/external/doctest-2.4.11/examples/all_features/test_output/first_last_xml.txt new file mode 100644 index 00000000..b097b077 --- /dev/null +++ b/dmff/dpnblist/external/doctest-2.4.11/examples/all_features/test_output/first_last_xml.txt @@ -0,0 +1,27 @@ + + + + + + + std::string! + + + + + + const char*! + + + + + + unknown exception + + + + + + + +Program code. diff --git a/dmff/dpnblist/external/doctest-2.4.11/examples/all_features/test_output/header.h.txt b/dmff/dpnblist/external/doctest-2.4.11/examples/all_features/test_output/header.h.txt new file mode 100644 index 00000000..411c975b --- /dev/null +++ b/dmff/dpnblist/external/doctest-2.4.11/examples/all_features/test_output/header.h.txt @@ -0,0 +1,25 @@ +[doctest] run with "--help" for options +=============================================================================== +header.h(0): +TEST SUITE: some TS +TEST CASE: in TS + +header.h(0): FATAL ERROR: + +=============================================================================== +header.h(0): +TEST CASE: template 1 + +header.h(0): FATAL ERROR: + +=============================================================================== +header.h(0): +TEST CASE: template 2 + +header.h(0): FATAL ERROR: + +=============================================================================== +[doctest] test cases: 4 | 1 passed | 3 failed | +[doctest] assertions: 4 | 1 passed | 3 failed | +[doctest] Status: FAILURE! +Program code. diff --git a/dmff/dpnblist/external/doctest-2.4.11/examples/all_features/test_output/header.h_junit.txt b/dmff/dpnblist/external/doctest-2.4.11/examples/all_features/test_output/header.h_junit.txt new file mode 100644 index 00000000..6ef648c3 --- /dev/null +++ b/dmff/dpnblist/external/doctest-2.4.11/examples/all_features/test_output/header.h_junit.txt @@ -0,0 +1,28 @@ + + + + + +header.h(0): + + + + + + +header.h(0): + + + + + + +header.h(0): + + + + + + + +Program code. diff --git a/dmff/dpnblist/external/doctest-2.4.11/examples/all_features/test_output/header.h_xml.txt b/dmff/dpnblist/external/doctest-2.4.11/examples/all_features/test_output/header.h_xml.txt new file mode 100644 index 00000000..840fe80c --- /dev/null +++ b/dmff/dpnblist/external/doctest-2.4.11/examples/all_features/test_output/header.h_xml.txt @@ -0,0 +1,32 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +Program code. diff --git a/dmff/dpnblist/external/doctest-2.4.11/examples/all_features/test_output/help.txt b/dmff/dpnblist/external/doctest-2.4.11/examples/all_features/test_output/help.txt new file mode 100644 index 00000000..995c827f --- /dev/null +++ b/dmff/dpnblist/external/doctest-2.4.11/examples/all_features/test_output/help.txt @@ -0,0 +1,63 @@ +[doctest] +[doctest] boolean values: "1/on/yes/true" or "0/off/no/false" +[doctest] filter values: "str1,str2,str3" (comma separated strings) +[doctest] +[doctest] filters use wildcards for matching strings +[doctest] something passes a filter if any of the strings in a filter matches +[doctest] +[doctest] ALL FLAGS, OPTIONS AND FILTERS ALSO AVAILABLE WITH A "dt-" PREFIX!!! +[doctest] +[doctest] Query flags - the program quits after them. Available: + + -?, --help, -h prints this message + -v, --version prints the version + -c, --count prints the number of matching tests + -ltc, --list-test-cases lists all matching tests by name + -lts, --list-test-suites lists all matching test suites + -lr, --list-reporters lists all registered reporters + +[doctest] The available / options/filters are: + + -tc, --test-case= filters tests by their name + -tce, --test-case-exclude= filters OUT tests by their name + -sf, --source-file= filters tests by their file + -sfe, --source-file-exclude= filters OUT tests by their file + -ts, --test-suite= filters tests by their test suite + -tse, --test-suite-exclude= filters OUT tests by their test suite + -sc, --subcase= filters subcases by their name + -sce, --subcase-exclude= filters OUT subcases by their name + -r, --reporters= reporters to use (console is default) + -o, --out= output filename + -ob, --order-by= how the tests should be ordered + - [file/suite/name/rand/none] + -rs, --rand-seed= seed for random ordering + -f, --first= the first test passing the filters to + execute - for range-based execution + -l, --last= the last test passing the filters to + execute - for range-based execution + -aa, --abort-after= stop after failed assertions + -scfl,--subcase-filter-levels= apply filters for the first levels + +[doctest] Bool options - can be used like flags and true is assumed. Available: + + -s, --success= include successful assertions in output + -cs, --case-sensitive= filters being treated as case sensitive + -e, --exit= exits after the tests finish + -d, --duration= prints the time duration of each test + -m, --minimal= minimal console output (only failures) + -q, --quiet= no console output + -nt, --no-throw= skips exceptions-related assert checks + -ne, --no-exitcode= returns (or exits) always with success + -nr, --no-run= skips all runtime doctest operations + -ni, --no-intro= omit the framework intro in the output + -nv, --no-version= omit the framework version in the output + -nc, --no-colors= disables colors in output + -fc, --force-colors= use colors even when not in a tty + -nb, --no-breaks= disables breakpoints in debuggers + -ns, --no-skip= don't skip test cases marked as skip + -gfl, --gnu-file-line= :n: vs (n): for line numbers in output + -npf, --no-path-filenames= only filenames and no paths in output + -nln, --no-line-numbers= 0 instead of real line numbers in output + +[doctest] for more information visit the project documentation + diff --git a/dmff/dpnblist/external/doctest-2.4.11/examples/all_features/test_output/help_junit.txt b/dmff/dpnblist/external/doctest-2.4.11/examples/all_features/test_output/help_junit.txt new file mode 100644 index 00000000..12bbf745 --- /dev/null +++ b/dmff/dpnblist/external/doctest-2.4.11/examples/all_features/test_output/help_junit.txt @@ -0,0 +1 @@ + diff --git a/dmff/dpnblist/external/doctest-2.4.11/examples/all_features/test_output/help_xml.txt b/dmff/dpnblist/external/doctest-2.4.11/examples/all_features/test_output/help_xml.txt new file mode 100644 index 00000000..4cc3ba89 --- /dev/null +++ b/dmff/dpnblist/external/doctest-2.4.11/examples/all_features/test_output/help_xml.txt @@ -0,0 +1,4 @@ + + + + diff --git a/dmff/dpnblist/external/doctest-2.4.11/examples/all_features/test_output/list_reporters.txt b/dmff/dpnblist/external/doctest-2.4.11/examples/all_features/test_output/list_reporters.txt new file mode 100644 index 00000000..2af24bef --- /dev/null +++ b/dmff/dpnblist/external/doctest-2.4.11/examples/all_features/test_output/list_reporters.txt @@ -0,0 +1,7 @@ +[doctest] listing all registered listeners +priority: 1 name: my_listener +[doctest] listing all registered reporters +priority: 0 name: console +priority: 0 name: junit +priority: 0 name: xml +priority: 1 name: my_xml diff --git a/dmff/dpnblist/external/doctest-2.4.11/examples/all_features/test_output/list_reporters_junit.txt b/dmff/dpnblist/external/doctest-2.4.11/examples/all_features/test_output/list_reporters_junit.txt new file mode 100644 index 00000000..12bbf745 --- /dev/null +++ b/dmff/dpnblist/external/doctest-2.4.11/examples/all_features/test_output/list_reporters_junit.txt @@ -0,0 +1 @@ + diff --git a/dmff/dpnblist/external/doctest-2.4.11/examples/all_features/test_output/list_reporters_xml.txt b/dmff/dpnblist/external/doctest-2.4.11/examples/all_features/test_output/list_reporters_xml.txt new file mode 100644 index 00000000..9bf895cf --- /dev/null +++ b/dmff/dpnblist/external/doctest-2.4.11/examples/all_features/test_output/list_reporters_xml.txt @@ -0,0 +1,9 @@ + + + + + + + + + diff --git a/dmff/dpnblist/external/doctest-2.4.11/examples/all_features/test_output/list_test_cases.txt b/dmff/dpnblist/external/doctest-2.4.11/examples/all_features/test_output/list_test_cases.txt new file mode 100644 index 00000000..ec5bbd52 --- /dev/null +++ b/dmff/dpnblist/external/doctest-2.4.11/examples/all_features/test_output/list_test_cases.txt @@ -0,0 +1,8 @@ +[doctest] listing all test case names +=============================================================================== +exercising tricky code paths of doctest +will end from a std::string exception +will end from a const char* exception +will end from an unknown exception +=============================================================================== +[doctest] unskipped test cases passing the current filters: 4 diff --git a/dmff/dpnblist/external/doctest-2.4.11/examples/all_features/test_output/list_test_cases_junit.txt b/dmff/dpnblist/external/doctest-2.4.11/examples/all_features/test_output/list_test_cases_junit.txt new file mode 100644 index 00000000..12bbf745 --- /dev/null +++ b/dmff/dpnblist/external/doctest-2.4.11/examples/all_features/test_output/list_test_cases_junit.txt @@ -0,0 +1 @@ + diff --git a/dmff/dpnblist/external/doctest-2.4.11/examples/all_features/test_output/list_test_cases_xml.txt b/dmff/dpnblist/external/doctest-2.4.11/examples/all_features/test_output/list_test_cases_xml.txt new file mode 100644 index 00000000..3419c1d9 --- /dev/null +++ b/dmff/dpnblist/external/doctest-2.4.11/examples/all_features/test_output/list_test_cases_xml.txt @@ -0,0 +1,9 @@ + + + + + + + + + diff --git a/dmff/dpnblist/external/doctest-2.4.11/examples/all_features/test_output/list_test_suites.txt b/dmff/dpnblist/external/doctest-2.4.11/examples/all_features/test_output/list_test_suites.txt new file mode 100644 index 00000000..861bf21b --- /dev/null +++ b/dmff/dpnblist/external/doctest-2.4.11/examples/all_features/test_output/list_test_suites.txt @@ -0,0 +1,6 @@ +[doctest] listing all test suites +=============================================================================== +exception related +=============================================================================== +[doctest] unskipped test cases passing the current filters: 4 +[doctest] test suites with unskipped test cases passing the current filters: 1 diff --git a/dmff/dpnblist/external/doctest-2.4.11/examples/all_features/test_output/list_test_suites_junit.txt b/dmff/dpnblist/external/doctest-2.4.11/examples/all_features/test_output/list_test_suites_junit.txt new file mode 100644 index 00000000..12bbf745 --- /dev/null +++ b/dmff/dpnblist/external/doctest-2.4.11/examples/all_features/test_output/list_test_suites_junit.txt @@ -0,0 +1 @@ + diff --git a/dmff/dpnblist/external/doctest-2.4.11/examples/all_features/test_output/list_test_suites_xml.txt b/dmff/dpnblist/external/doctest-2.4.11/examples/all_features/test_output/list_test_suites_xml.txt new file mode 100644 index 00000000..6a7a6e91 --- /dev/null +++ b/dmff/dpnblist/external/doctest-2.4.11/examples/all_features/test_output/list_test_suites_xml.txt @@ -0,0 +1,7 @@ + + + + + + + diff --git a/dmff/dpnblist/external/doctest-2.4.11/examples/all_features/test_output/logging.cpp.txt b/dmff/dpnblist/external/doctest-2.4.11/examples/all_features/test_output/logging.cpp.txt new file mode 100644 index 00000000..5c362940 --- /dev/null +++ b/dmff/dpnblist/external/doctest-2.4.11/examples/all_features/test_output/logging.cpp.txt @@ -0,0 +1,84 @@ +[doctest] run with "--help" for options +=============================================================================== +logging.cpp(0): +TEST CASE: logging the counter of a loop + +logging.cpp(0): ERROR: CHECK( vec[i] != (1 << i) ) is NOT correct! + values: CHECK( 1 != 1 ) + logged: current iteration of loop: + i := 0 + +logging.cpp(0): ERROR: CHECK( vec[i] != (1 << i) ) is NOT correct! + values: CHECK( 2 != 2 ) + logged: current iteration of loop: + i := 1 + +logging.cpp(0): ERROR: CHECK( vec[i] != (1 << i) ) is NOT correct! + values: CHECK( 4 != 4 ) + logged: current iteration of loop: + i := 2 + +logging.cpp(0): ERROR: CHECK( vec[i] != (1 << i) ) is NOT correct! + values: CHECK( 8 != 8 ) + logged: current iteration of loop: + i := 3 + +logging.cpp(0): ERROR: CHECK( vec[i] != (1 << i) ) is NOT correct! + values: CHECK( 16 != 16 ) + logged: current iteration of loop: + i := 4 + +=============================================================================== +logging.cpp(0): +TEST CASE: a test case that will end from an exception + +logging.cpp(0): ERROR: forcing the many captures to be stringified + logged: lots of captures: 42 42 42; + old way of capturing - using the streaming operator: 42 42 + +logging.cpp(0): ERROR: CHECK( some_var == 666 ) is NOT correct! + values: CHECK( 42 == 666 ) + logged: someTests() returned: 42 + this should be printed if an exception is thrown even if no assert has failed: 42 + in a nested scope this should be printed as well: 42 + why is this not 666 ?! + +logging.cpp(0): ERROR: test case THREW exception: 0 + logged: someTests() returned: 42 + this should be printed if an exception is thrown even if no assert has failed: 42 + in a nested scope this should be printed as well: 42 + +=============================================================================== +logging.cpp(0): +TEST CASE: a test case that will end from an exception and should print the unprinted context + +logging.cpp(0): ERROR: test case THREW exception: 0 + logged: should be printed even if an exception is thrown and no assert fails before that + +=============================================================================== +logging.cpp(0): +TEST CASE: third party asserts can report failures to doctest + +logging.cpp(0): ERROR: MY_ASSERT(false) + +logging.cpp(0): FATAL ERROR: MY_ASSERT_FATAL(false) + +=============================================================================== +logging.cpp(0): +TEST CASE: explicit failures 1 + +logging.cpp(0): ERROR: this should not end the test case, but mark it as failing + +logging.cpp(0): MESSAGE: reached! + +=============================================================================== +logging.cpp(0): +TEST CASE: explicit failures 2 + +logging.cpp(0): FATAL ERROR: fail the test case and also end it + +=============================================================================== +[doctest] test cases: 6 | 0 passed | 6 failed | +[doctest] assertions: 11 | 0 passed | 11 failed | +[doctest] Status: FAILURE! +Program code. diff --git a/dmff/dpnblist/external/doctest-2.4.11/examples/all_features/test_output/logging.cpp_junit.txt b/dmff/dpnblist/external/doctest-2.4.11/examples/all_features/test_output/logging.cpp_junit.txt new file mode 100644 index 00000000..5ec44f7d --- /dev/null +++ b/dmff/dpnblist/external/doctest-2.4.11/examples/all_features/test_output/logging.cpp_junit.txt @@ -0,0 +1,101 @@ + + + + + +logging.cpp(0): +CHECK( vec[i] != (1 << i) ) is NOT correct! + values: CHECK( 1 != 1 ) + logged: current iteration of loop: + i := 0 + + + +logging.cpp(0): +CHECK( vec[i] != (1 << i) ) is NOT correct! + values: CHECK( 2 != 2 ) + logged: current iteration of loop: + i := 1 + + + +logging.cpp(0): +CHECK( vec[i] != (1 << i) ) is NOT correct! + values: CHECK( 4 != 4 ) + logged: current iteration of loop: + i := 2 + + + +logging.cpp(0): +CHECK( vec[i] != (1 << i) ) is NOT correct! + values: CHECK( 8 != 8 ) + logged: current iteration of loop: + i := 3 + + + +logging.cpp(0): +CHECK( vec[i] != (1 << i) ) is NOT correct! + values: CHECK( 16 != 16 ) + logged: current iteration of loop: + i := 4 + + + + + +logging.cpp(0): +forcing the many captures to be stringified + logged: lots of captures: 42 42 42; + old way of capturing - using the streaming operator: 42 42 + + + +logging.cpp(0): +CHECK( some_var == 666 ) is NOT correct! + values: CHECK( 42 == 666 ) + logged: someTests() returned: 42 + this should be printed if an exception is thrown even if no assert has failed: 42 + in a nested scope this should be printed as well: 42 + why is this not 666 ?! + + + + 0 + + + + + 0 + + + + +logging.cpp(0): +MY_ASSERT(false) + + + +logging.cpp(0): +MY_ASSERT_FATAL(false) + + + + + +logging.cpp(0): +this should not end the test case, but mark it as failing + + + + + +logging.cpp(0): +fail the test case and also end it + + + + + +Program code. diff --git a/dmff/dpnblist/external/doctest-2.4.11/examples/all_features/test_output/logging.cpp_xml.txt b/dmff/dpnblist/external/doctest-2.4.11/examples/all_features/test_output/logging.cpp_xml.txt new file mode 100644 index 00000000..27207f98 --- /dev/null +++ b/dmff/dpnblist/external/doctest-2.4.11/examples/all_features/test_output/logging.cpp_xml.txt @@ -0,0 +1,159 @@ + + + + + + + + vec[i] != (1 << i) + + + 1 != 1 + + + current iteration of loop: + + + i := 0 + + + + + vec[i] != (1 << i) + + + 2 != 2 + + + current iteration of loop: + + + i := 1 + + + + + vec[i] != (1 << i) + + + 4 != 4 + + + current iteration of loop: + + + i := 2 + + + + + vec[i] != (1 << i) + + + 8 != 8 + + + current iteration of loop: + + + i := 3 + + + + + vec[i] != (1 << i) + + + 16 != 16 + + + current iteration of loop: + + + i := 4 + + + + + + + + forcing the many captures to be stringified + + + lots of captures: 42 42 42; + + + old way of capturing - using the streaming operator: 42 42 + + + + + some_var == 666 + + + 42 == 666 + + + someTests() returned: 42 + + + this should be printed if an exception is thrown even if no assert has failed: 42 + + + in a nested scope this should be printed as well: 42 + + + why is this not 666 ?! + + + + 0 + + + + + + 0 + + + + + + + MY_ASSERT(false) + + + + + MY_ASSERT_FATAL(false) + + + + + + + + this should not end the test case, but mark it as failing + + + + + reached! + + + + + + + + fail the test case and also end it + + + + + + + + +Program code. diff --git a/dmff/dpnblist/external/doctest-2.4.11/examples/all_features/test_output/main.cpp.txt b/dmff/dpnblist/external/doctest-2.4.11/examples/all_features/test_output/main.cpp.txt new file mode 100644 index 00000000..8a145de4 --- /dev/null +++ b/dmff/dpnblist/external/doctest-2.4.11/examples/all_features/test_output/main.cpp.txt @@ -0,0 +1,6 @@ +[doctest] run with "--help" for options +=============================================================================== +[doctest] test cases: 1 | 1 passed | 0 failed | +[doctest] assertions: 1 | 1 passed | 0 failed | +[doctest] Status: SUCCESS! +Program code. diff --git a/dmff/dpnblist/external/doctest-2.4.11/examples/all_features/test_output/main.cpp_junit.txt b/dmff/dpnblist/external/doctest-2.4.11/examples/all_features/test_output/main.cpp_junit.txt new file mode 100644 index 00000000..bd3830b3 --- /dev/null +++ b/dmff/dpnblist/external/doctest-2.4.11/examples/all_features/test_output/main.cpp_junit.txt @@ -0,0 +1,7 @@ + + + + + + +Program code. diff --git a/dmff/dpnblist/external/doctest-2.4.11/examples/all_features/test_output/main.cpp_xml.txt b/dmff/dpnblist/external/doctest-2.4.11/examples/all_features/test_output/main.cpp_xml.txt new file mode 100644 index 00000000..90e2ef0a --- /dev/null +++ b/dmff/dpnblist/external/doctest-2.4.11/examples/all_features/test_output/main.cpp_xml.txt @@ -0,0 +1,12 @@ + + + + + + + + + + + +Program code. diff --git a/dmff/dpnblist/external/doctest-2.4.11/examples/all_features/test_output/minimal.txt b/dmff/dpnblist/external/doctest-2.4.11/examples/all_features/test_output/minimal.txt new file mode 100644 index 00000000..369c3684 --- /dev/null +++ b/dmff/dpnblist/external/doctest-2.4.11/examples/all_features/test_output/minimal.txt @@ -0,0 +1,100 @@ +=============================================================================== +test_cases_and_suites.cpp(0): +TEST CASE: should fail because of an exception + +test_cases_and_suites.cpp(0): ERROR: test case THREW exception: 0 + +=============================================================================== +test_cases_and_suites.cpp(0): +TEST SUITE: scoped test suite +TEST CASE: part of scoped + +test_cases_and_suites.cpp(0): FATAL ERROR: + +=============================================================================== +test_cases_and_suites.cpp(0): +TEST SUITE: scoped test suite +TEST CASE: part of scoped 2 + +test_cases_and_suites.cpp(0): FATAL ERROR: + +=============================================================================== +test_cases_and_suites.cpp(0): +TEST SUITE: some TS +TEST CASE: part of some TS + +test_cases_and_suites.cpp(0): FATAL ERROR: + +=============================================================================== +test_cases_and_suites.cpp(0): +TEST CASE: fixtured test - not part of a test suite + +test_cases_and_suites.cpp(0): ERROR: CHECK( data == 85 ) is NOT correct! + values: CHECK( 21 == 85 ) + +=============================================================================== +test_cases_and_suites.cpp(0): +TEST SUITE: ts1 +TEST CASE: normal test in a test suite from a decorator + +test_cases_and_suites.cpp(0): MESSAGE: failing because of the timeout decorator! + +Test case exceeded time limit of 0.000001! +=============================================================================== +test_cases_and_suites.cpp(0): +DESCRIPTION: this test has overridden its skip decorator +TEST SUITE: skipped test cases +TEST CASE: unskipped + +test_cases_and_suites.cpp(0): FATAL ERROR: + +=============================================================================== +test_cases_and_suites.cpp(0): +DESCRIPTION: regarding failures +TEST SUITE: test suite with a description +TEST CASE: fails - and its allowed + +test_cases_and_suites.cpp(0): FATAL ERROR: + +Allowed to fail so marking it as not failed +=============================================================================== +test_cases_and_suites.cpp(0): +DESCRIPTION: regarding failures +TEST SUITE: test suite with a description +TEST CASE: fails as it should + +test_cases_and_suites.cpp(0): FATAL ERROR: + +Failed as expected so marking it as not failed +=============================================================================== +test_cases_and_suites.cpp(0): +DESCRIPTION: regarding failures +TEST SUITE: test suite with a description +TEST CASE: doesn't fail but it should have + +Should have failed but didn't! Marking it as failed! +=============================================================================== +test_cases_and_suites.cpp(0): +DESCRIPTION: regarding failures +TEST SUITE: test suite with a description +TEST CASE: fails 1 time as it should + +test_cases_and_suites.cpp(0): FATAL ERROR: + +Failed exactly 1 times as expected so marking it as not failed! +=============================================================================== +test_cases_and_suites.cpp(0): +DESCRIPTION: regarding failures +TEST SUITE: test suite with a description +TEST CASE: fails more times than it should + +test_cases_and_suites.cpp(0): ERROR: + +test_cases_and_suites.cpp(0): ERROR: + +Didn't fail exactly 1 times so marking it as failed! +=============================================================================== +[doctest] test cases: 15 | 6 passed | 9 failed | +[doctest] assertions: 12 | 1 passed | 11 failed | +[doctest] Status: FAILURE! +Program code. diff --git a/dmff/dpnblist/external/doctest-2.4.11/examples/all_features/test_output/minimal_junit.txt b/dmff/dpnblist/external/doctest-2.4.11/examples/all_features/test_output/minimal_junit.txt new file mode 100644 index 00000000..14733b6a --- /dev/null +++ b/dmff/dpnblist/external/doctest-2.4.11/examples/all_features/test_output/minimal_junit.txt @@ -0,0 +1,91 @@ + + + + + + + 0 + + + + +test_cases_and_suites.cpp(0): + + + + + + +test_cases_and_suites.cpp(0): + + + + + + +test_cases_and_suites.cpp(0): + + + + + + +test_cases_and_suites.cpp(0): +CHECK( data == 85 ) is NOT correct! + values: CHECK( 21 == 85 ) + + + + + + +test_cases_and_suites.cpp(0): + + + + + + +test_cases_and_suites.cpp(0): + + + + + + + +test_cases_and_suites.cpp(0): + + + + + + + +test_cases_and_suites.cpp(0): + + + + + + +test_cases_and_suites.cpp(0): + + + + +test_cases_and_suites.cpp(0): + + + + + + +test_cases_and_suites.cpp(0): + + + + + + +Program code. diff --git a/dmff/dpnblist/external/doctest-2.4.11/examples/all_features/test_output/minimal_no_fail.txt b/dmff/dpnblist/external/doctest-2.4.11/examples/all_features/test_output/minimal_no_fail.txt new file mode 100644 index 00000000..afcd6d92 --- /dev/null +++ b/dmff/dpnblist/external/doctest-2.4.11/examples/all_features/test_output/minimal_no_fail.txt @@ -0,0 +1,9 @@ +=============================================================================== +no_failures.cpp(0): +TEST SUITE: some suite +TEST CASE: fails - and its allowed + +no_failures.cpp(0): FATAL ERROR: + +Allowed to fail so marking it as not failed +Program code. diff --git a/dmff/dpnblist/external/doctest-2.4.11/examples/all_features/test_output/minimal_no_fail_junit.txt b/dmff/dpnblist/external/doctest-2.4.11/examples/all_features/test_output/minimal_no_fail_junit.txt new file mode 100644 index 00000000..f53ebeaf --- /dev/null +++ b/dmff/dpnblist/external/doctest-2.4.11/examples/all_features/test_output/minimal_no_fail_junit.txt @@ -0,0 +1,22 @@ + + + + + + + +no_failures.cpp(0): + + + + + + +no_failures.cpp(0): + + + + + + +Program code. diff --git a/dmff/dpnblist/external/doctest-2.4.11/examples/all_features/test_output/minimal_no_fail_xml.txt b/dmff/dpnblist/external/doctest-2.4.11/examples/all_features/test_output/minimal_no_fail_xml.txt new file mode 100644 index 00000000..67ff229a --- /dev/null +++ b/dmff/dpnblist/external/doctest-2.4.11/examples/all_features/test_output/minimal_no_fail_xml.txt @@ -0,0 +1,31 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +Program code. diff --git a/dmff/dpnblist/external/doctest-2.4.11/examples/all_features/test_output/minimal_xml.txt b/dmff/dpnblist/external/doctest-2.4.11/examples/all_features/test_output/minimal_xml.txt new file mode 100644 index 00000000..6fc245aa --- /dev/null +++ b/dmff/dpnblist/external/doctest-2.4.11/examples/all_features/test_output/minimal_xml.txt @@ -0,0 +1,114 @@ + + + + + + + + + + 0 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + data == 85 + + + 21 == 85 + + + + + + + + + + failing because of the timeout decorator! + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +Program code. diff --git a/dmff/dpnblist/external/doctest-2.4.11/examples/all_features/test_output/no_multi_lane_atomics.txt b/dmff/dpnblist/external/doctest-2.4.11/examples/all_features/test_output/no_multi_lane_atomics.txt new file mode 100644 index 00000000..4469b915 --- /dev/null +++ b/dmff/dpnblist/external/doctest-2.4.11/examples/all_features/test_output/no_multi_lane_atomics.txt @@ -0,0 +1,931 @@ +[doctest] run with "--help" for options +=============================================================================== +subcases.cpp(0): + Scenario: vectors can be sized and resized + Given: A vector with some items + When: the size is increased + Then: the size and capacity change + +subcases.cpp(0): ERROR: CHECK( v.size() == 20 ) is NOT correct! + values: CHECK( 10 == 20 ) + +=============================================================================== +subcases.cpp(0): + Scenario: vectors can be sized and resized + Given: A vector with some items + When: less capacity is reserved + Then: neither size nor capacity are changed + +subcases.cpp(0): ERROR: CHECK( v.size() == 10 ) is NOT correct! + values: CHECK( 5 == 10 ) + +=============================================================================== +assertion_macros.cpp(0): +TEST CASE: CHECK level of asserts fail the test case but don't abort it + +assertion_macros.cpp(0): ERROR: CHECK( 0 ) is NOT correct! + values: CHECK( 0 ) + +assertion_macros.cpp(0): ERROR: CHECK_FALSE( 1 ) is NOT correct! + values: CHECK_FALSE( 1 ) + +assertion_macros.cpp(0): ERROR: CHECK_THROWS( throw_if(false, 0) ) did NOT throw at all! + +assertion_macros.cpp(0): ERROR: CHECK_THROWS_AS( throw_if(false, 0), bool ) did NOT throw at all! + +assertion_macros.cpp(0): ERROR: CHECK_THROWS_AS( throw_if(true, 0), bool ) threw a DIFFERENT exception: "0" + +assertion_macros.cpp(0): ERROR: CHECK_THROWS_WITH( throw_if(true, 0), "unrecognized" ) threw a DIFFERENT exception: "0" + +assertion_macros.cpp(0): ERROR: CHECK_THROWS_WITH_AS( throw_if(true, 0), "unrecognized", int ) threw a DIFFERENT exception! (contents: "0") + +assertion_macros.cpp(0): ERROR: CHECK_NOTHROW( throw_if(true, 0) ) THREW exception: "0" + +assertion_macros.cpp(0): ERROR: CHECK_EQ( 1, 0 ) is NOT correct! + values: CHECK_EQ( 1, 0 ) + +assertion_macros.cpp(0): ERROR: CHECK_UNARY( 0 ) is NOT correct! + values: CHECK_UNARY( 0 ) + +assertion_macros.cpp(0): ERROR: CHECK_UNARY_FALSE( 1 ) is NOT correct! + values: CHECK_UNARY_FALSE( 1 ) + +assertion_macros.cpp(0): MESSAGE: reached! + +=============================================================================== +decomposition.cpp(0): +TEST CASE: Move Only Type + +decomposition.cpp(0): ERROR: CHECK( genType(false) ) is NOT correct! + values: CHECK( {?} ) + +decomposition.cpp(0): ERROR: CHECK( a ) is NOT correct! + values: CHECK( {?} ) + +=============================================================================== +assertion_macros.cpp(0): +TEST CASE: REQUIRE level of asserts fail and abort the test case - 1 + +assertion_macros.cpp(0): FATAL ERROR: REQUIRE( 0 ) is NOT correct! + values: REQUIRE( 0 ) + +=============================================================================== +assertion_macros.cpp(0): +TEST CASE: REQUIRE level of asserts fail and abort the test case - 10 + +assertion_macros.cpp(0): FATAL ERROR: REQUIRE_NOTHROW( throw_if(true, 0) ) THREW exception: "0" + +=============================================================================== +assertion_macros.cpp(0): +TEST CASE: REQUIRE level of asserts fail and abort the test case - 11 + +assertion_macros.cpp(0): FATAL ERROR: REQUIRE_EQ( 1, 0 ) is NOT correct! + values: REQUIRE_EQ( 1, 0 ) + +=============================================================================== +assertion_macros.cpp(0): +TEST CASE: REQUIRE level of asserts fail and abort the test case - 12 + +assertion_macros.cpp(0): FATAL ERROR: REQUIRE_UNARY( 0 ) is NOT correct! + values: REQUIRE_UNARY( 0 ) + +=============================================================================== +assertion_macros.cpp(0): +TEST CASE: REQUIRE level of asserts fail and abort the test case - 13 + +assertion_macros.cpp(0): FATAL ERROR: REQUIRE_UNARY_FALSE( 1 ) is NOT correct! + values: REQUIRE_UNARY_FALSE( 1 ) + +=============================================================================== +assertion_macros.cpp(0): +TEST CASE: REQUIRE level of asserts fail and abort the test case - 2 + +assertion_macros.cpp(0): FATAL ERROR: REQUIRE_FALSE( 1 ) is NOT correct! + values: REQUIRE_FALSE( 1 ) + +=============================================================================== +assertion_macros.cpp(0): +TEST CASE: REQUIRE level of asserts fail and abort the test case - 3 + +assertion_macros.cpp(0): FATAL ERROR: REQUIRE_THROWS( throw_if(false, 0) ) did NOT throw at all! + +=============================================================================== +assertion_macros.cpp(0): +TEST CASE: REQUIRE level of asserts fail and abort the test case - 4 + +assertion_macros.cpp(0): FATAL ERROR: REQUIRE_THROWS_AS( throw_if(false, 0), bool ) did NOT throw at all! + +=============================================================================== +assertion_macros.cpp(0): +TEST CASE: REQUIRE level of asserts fail and abort the test case - 5 + +assertion_macros.cpp(0): FATAL ERROR: REQUIRE_THROWS_AS( throw_if(true, 0), bool ) threw a DIFFERENT exception: "0" + +=============================================================================== +assertion_macros.cpp(0): +TEST CASE: REQUIRE level of asserts fail and abort the test case - 6 + +assertion_macros.cpp(0): FATAL ERROR: REQUIRE_THROWS_WITH( throw_if(false, ""), "whops!" ) did NOT throw at all! + +=============================================================================== +assertion_macros.cpp(0): +TEST CASE: REQUIRE level of asserts fail and abort the test case - 7 + +assertion_macros.cpp(0): FATAL ERROR: REQUIRE_THROWS_WITH( throw_if(true, ""), "whops!" ) threw a DIFFERENT exception: + +=============================================================================== +assertion_macros.cpp(0): +TEST CASE: REQUIRE level of asserts fail and abort the test case - 8 + +assertion_macros.cpp(0): FATAL ERROR: REQUIRE_THROWS_WITH_AS( throw_if(false, ""), "whops!", bool ) did NOT throw at all! + +=============================================================================== +assertion_macros.cpp(0): +TEST CASE: REQUIRE level of asserts fail and abort the test case - 9 + +assertion_macros.cpp(0): FATAL ERROR: REQUIRE_THROWS_WITH_AS( throw_if(true, ""), "whops!", bool ) threw a DIFFERENT exception! (contents: ) + +=============================================================================== +assertion_macros.cpp(0): +TEST CASE: WARN level of asserts don't fail the test case + +assertion_macros.cpp(0): WARNING: WARN( 0 ) is NOT correct! + values: WARN( 0 ) + +assertion_macros.cpp(0): WARNING: WARN_FALSE( 1 ) is NOT correct! + values: WARN_FALSE( 1 ) + +assertion_macros.cpp(0): WARNING: WARN_THROWS( throw_if(false, 0) ) did NOT throw at all! + +assertion_macros.cpp(0): WARNING: WARN_THROWS_WITH( throw_if(true, ""), "whops!" ) threw a DIFFERENT exception: + +assertion_macros.cpp(0): WARNING: WARN_THROWS_WITH( throw_if(false, ""), "whops!" ) did NOT throw at all! + +assertion_macros.cpp(0): WARNING: WARN_THROWS_AS( throw_if(false, 0), bool ) did NOT throw at all! + +assertion_macros.cpp(0): WARNING: WARN_THROWS_AS( throw_if(true, 0), bool ) threw a DIFFERENT exception: "0" + +assertion_macros.cpp(0): WARNING: WARN_THROWS_WITH_AS( throw_if(false, ""), "whops!", int ) did NOT throw at all! + +assertion_macros.cpp(0): WARNING: WARN_THROWS_WITH_AS( throw_if(true, ""), "whops!", int ) threw a DIFFERENT exception! (contents: ) + +assertion_macros.cpp(0): WARNING: WARN_NOTHROW( throw_if(true, 0) ) THREW exception: "0" + +assertion_macros.cpp(0): WARNING: WARN_EQ( 1, 0 ) is NOT correct! + values: WARN_EQ( 1, 0 ) + +assertion_macros.cpp(0): WARNING: WARN_UNARY( 0 ) is NOT correct! + values: WARN_UNARY( 0 ) + +assertion_macros.cpp(0): WARNING: WARN_UNARY_FALSE( 1 ) is NOT correct! + values: WARN_UNARY_FALSE( 1 ) + +=============================================================================== +stringification.cpp(0): +TEST CASE: a test case that registers an exception translator for int and then throws one + +stringification.cpp(0): ERROR: test case THREW exception: 5 + +=============================================================================== +logging.cpp(0): +TEST CASE: a test case that will end from an exception + +logging.cpp(0): ERROR: forcing the many captures to be stringified + logged: lots of captures: 42 42 42; + old way of capturing - using the streaming operator: 42 42 + +logging.cpp(0): ERROR: CHECK( some_var == 666 ) is NOT correct! + values: CHECK( 42 == 666 ) + logged: someTests() returned: 42 + this should be printed if an exception is thrown even if no assert has failed: 42 + in a nested scope this should be printed as well: 42 + why is this not 666 ?! + +logging.cpp(0): ERROR: test case THREW exception: 0 + logged: someTests() returned: 42 + this should be printed if an exception is thrown even if no assert has failed: 42 + in a nested scope this should be printed as well: 42 + +=============================================================================== +logging.cpp(0): +TEST CASE: a test case that will end from an exception and should print the unprinted context + +logging.cpp(0): ERROR: test case THREW exception: 0 + logged: should be printed even if an exception is thrown and no assert fails before that + +=============================================================================== +stringification.cpp(0): +TEST CASE: all asserts should fail and show how the objects get stringified + +stringification.cpp(0): MESSAGE: Foo{} + +stringification.cpp(0): ERROR: CHECK( f1 == f2 ) is NOT correct! + values: CHECK( Foo{} == Foo{} ) + +stringification.cpp(0): MESSAGE: omg + +stringification.cpp(0): ERROR: CHECK( dummy == "tralala" ) is NOT correct! + values: CHECK( omg == tralala ) + +stringification.cpp(0): ERROR: CHECK( "tralala" == dummy ) is NOT correct! + values: CHECK( tralala == omg ) + +stringification.cpp(0): MESSAGE: [1, 2, 3] + +stringification.cpp(0): ERROR: CHECK( vec1 == vec2 ) is NOT correct! + values: CHECK( [1, 2, 3] == [1, 2, 4] ) + +stringification.cpp(0): MESSAGE: [1, 42, 3] + +stringification.cpp(0): ERROR: CHECK( lst_1 == lst_2 ) is NOT correct! + values: CHECK( [1, 42, 3] == [1, 2, 666] ) + +stringification.cpp(0): ERROR: CHECK( s1 == s2 ) is NOT correct! + values: CHECK( MyOtherType: 42 == MyOtherType: 666 ) + logged: s1=MyOtherType: 42 s2=MyOtherType: 666 + +stringification.cpp(0): ERROR: CHECK( s1 == s2 ) is NOT correct! + values: CHECK( MyOtherType: 42 == MyOtherType: 666 ) + logged: s1=MyOtherType: 42 s2=MyOtherType: 666 + MyOtherType: 42 is not really MyOtherType: 666 + +stringification.cpp(0): ERROR: CHECK( "a" == doctest::Contains("aaa") ) is NOT correct! + values: CHECK( a == Contains( aaa ) ) + +stringification.cpp(0): ERROR: test case THREW exception: MyTypeInherited(5, 4) + +=============================================================================== +templated_test_cases.cpp(0): +TEST CASE: bad stringification of type pair + +templated_test_cases.cpp(0): ERROR: CHECK( t2 != T2() ) is NOT correct! + values: CHECK( 0 != 0 ) + +=============================================================================== +assertion_macros.cpp(0): +TEST CASE: check return values + +assertion_macros.cpp(0): MESSAGE: :D + +assertion_macros.cpp(0): MESSAGE: :D + +assertion_macros.cpp(0): MESSAGE: :D + +assertion_macros.cpp(0): MESSAGE: :D + +assertion_macros.cpp(0): MESSAGE: :D + +assertion_macros.cpp(0): MESSAGE: :D + +assertion_macros.cpp(0): MESSAGE: :D + +assertion_macros.cpp(0): MESSAGE: :D + +assertion_macros.cpp(0): MESSAGE: :D + +=============================================================================== +assertion_macros.cpp(0): +TEST CASE: check return values no print + +assertion_macros.cpp(0): ERROR: CHECK( a == b ) is NOT correct! + values: CHECK( 4 == 2 ) + +assertion_macros.cpp(0): ERROR: CHECK_FALSE( a != b ) is NOT correct! + values: CHECK_FALSE( 4 != 2 ) + +assertion_macros.cpp(0): ERROR: CHECK_EQ( a, b ) is NOT correct! + values: CHECK_EQ( 4, 2 ) + +assertion_macros.cpp(0): ERROR: CHECK_UNARY( a == b ) is NOT correct! + values: CHECK_UNARY( false ) + +assertion_macros.cpp(0): ERROR: CHECK_UNARY_FALSE( a != b ) is NOT correct! + values: CHECK_UNARY_FALSE( true ) + +assertion_macros.cpp(0): ERROR: CHECK_THROWS( throw_if(false, false) ) did NOT throw at all! + +assertion_macros.cpp(0): ERROR: CHECK_THROWS_AS( throw_if(true, 2), doctest::Approx ) threw a DIFFERENT exception: "2" + +assertion_macros.cpp(0): ERROR: CHECK_NOTHROW( throw_if(true, 2) ) THREW exception: "2" + +assertion_macros.cpp(0): ERROR: CHECK_THROWS_WITH( throw_if(true, 2), "1" ) threw a DIFFERENT exception: "2" + +=============================================================================== +test_cases_and_suites.cpp(0): +DESCRIPTION: regarding failures +TEST SUITE: test suite with a description +TEST CASE: doesn't fail but it should have + +Should have failed but didn't! Marking it as failed! +=============================================================================== +enums.cpp(0): +TEST CASE: enum 2 + +enums.cpp(0): ERROR: CHECK_EQ( castToUnderlying(Zero), 1 ) is NOT correct! + values: CHECK_EQ( 0, 1 ) + +enums.cpp(0): ERROR: CHECK_EQ( castToUnderlying(One), 2 ) is NOT correct! + values: CHECK_EQ( 1, 2 ) + +enums.cpp(0): ERROR: CHECK_EQ( castToUnderlying(Two), 3 ) is NOT correct! + values: CHECK_EQ( 2, 3 ) + +enums.cpp(0): ERROR: CHECK_EQ( castToUnderlying(TypedZero), 1 ) is NOT correct! + values: CHECK_EQ( 0, 1 ) + +enums.cpp(0): ERROR: CHECK_EQ( castToUnderlying(TypedOne), 2 ) is NOT correct! + values: CHECK_EQ( 1, 2 ) + +enums.cpp(0): ERROR: CHECK_EQ( castToUnderlying(TypedTwo), 3 ) is NOT correct! + values: CHECK_EQ( 2, 3 ) + +enums.cpp(0): ERROR: CHECK_EQ( EnumClassC::Zero, EnumClassC::One ) is NOT correct! + values: CHECK_EQ( 48, 49 ) + +enums.cpp(0): ERROR: CHECK_EQ( EnumClassC::One, EnumClassC::Two ) is NOT correct! + values: CHECK_EQ( 49, 50 ) + +enums.cpp(0): ERROR: CHECK_EQ( EnumClassC::Two, EnumClassC::Zero ) is NOT correct! + values: CHECK_EQ( 50, 48 ) + +enums.cpp(0): ERROR: CHECK_EQ( EnumClassSC::Zero, EnumClassSC::One ) is NOT correct! + values: CHECK_EQ( 48, 49 ) + +enums.cpp(0): ERROR: CHECK_EQ( EnumClassSC::One, EnumClassSC::Two ) is NOT correct! + values: CHECK_EQ( 49, 50 ) + +enums.cpp(0): ERROR: CHECK_EQ( EnumClassSC::Two, EnumClassSC::Zero ) is NOT correct! + values: CHECK_EQ( 50, 48 ) + +enums.cpp(0): ERROR: CHECK_EQ( EnumClassUC::Zero, EnumClassUC::One ) is NOT correct! + values: CHECK_EQ( 48, 49 ) + +enums.cpp(0): ERROR: CHECK_EQ( EnumClassUC::One, EnumClassUC::Two ) is NOT correct! + values: CHECK_EQ( 49, 50 ) + +enums.cpp(0): ERROR: CHECK_EQ( EnumClassUC::Two, EnumClassUC::Zero ) is NOT correct! + values: CHECK_EQ( 50, 48 ) + +enums.cpp(0): ERROR: CHECK_EQ( EnumClassU8::Zero, EnumClassU8::One ) is NOT correct! + values: CHECK_EQ( 0, 1 ) + +enums.cpp(0): ERROR: CHECK_EQ( EnumClassU8::One, EnumClassU8::Two ) is NOT correct! + values: CHECK_EQ( 1, 2 ) + +enums.cpp(0): ERROR: CHECK_EQ( EnumClassU8::Two, EnumClassU8::Zero ) is NOT correct! + values: CHECK_EQ( 2, 0 ) + +Failed as expected so marking it as not failed +=============================================================================== +assertion_macros.cpp(0): +TEST CASE: exceptions-related macros + +assertion_macros.cpp(0): ERROR: CHECK_THROWS( throw_if(false, 0) ) did NOT throw at all! + +assertion_macros.cpp(0): ERROR: CHECK_THROWS_AS( throw_if(true, 0), char ) threw a DIFFERENT exception: "0" + +assertion_macros.cpp(0): ERROR: CHECK_THROWS_AS( throw_if(false, 0), int ) did NOT throw at all! + +assertion_macros.cpp(0): ERROR: CHECK_THROWS_WITH( throw_if(true, "whops!"), "whops! no match!" ) threw a DIFFERENT exception: "whops!" + +assertion_macros.cpp(0): ERROR: CHECK_THROWS_WITH( throw_if(true, "whops! does it match?"), "whops! no match!" ) threw a DIFFERENT exception: "whops! does it match?" + +assertion_macros.cpp(0): ERROR: CHECK_THROWS_WITH_AS( throw_if(true, "whops!"), "whops! no match!", bool ) threw a DIFFERENT exception! (contents: "whops!") + +assertion_macros.cpp(0): ERROR: CHECK_THROWS_WITH_AS( throw_if(true, "whops!"), "whops!", int ) threw a DIFFERENT exception! (contents: "whops!") + +assertion_macros.cpp(0): ERROR: CHECK_THROWS_WITH_AS( throw_if(true, "whops! does it match?"), "whops! no match!", int ) threw a DIFFERENT exception! (contents: "whops! does it match?") + +assertion_macros.cpp(0): ERROR: CHECK_NOTHROW( throw_if(true, 0) ) THREW exception: "0" + +=============================================================================== +assertion_macros.cpp(0): +TEST CASE: exceptions-related macros for std::exception + +assertion_macros.cpp(0): ERROR: CHECK_THROWS( throw_if(false, 0) ) did NOT throw at all! + +assertion_macros.cpp(0): ERROR: CHECK_THROWS_AS( throw_if(false, std::runtime_error("whops!")), std::exception ) did NOT throw at all! + +assertion_macros.cpp(0): ERROR: CHECK_THROWS_AS( throw_if(true, std::runtime_error("whops!")), int ) threw a DIFFERENT exception: "whops!" + +assertion_macros.cpp(0): ERROR: CHECK_THROWS_WITH( throw_if(false, ""), "whops!" ) did NOT throw at all! + +assertion_macros.cpp(0): FATAL ERROR: REQUIRE_NOTHROW( throw_if(true, std::runtime_error("whops!")) ) THREW exception: "whops!" + +=============================================================================== +logging.cpp(0): +TEST CASE: explicit failures 1 + +logging.cpp(0): ERROR: this should not end the test case, but mark it as failing + +logging.cpp(0): MESSAGE: reached! + +=============================================================================== +logging.cpp(0): +TEST CASE: explicit failures 2 + +logging.cpp(0): FATAL ERROR: fail the test case and also end it + +=============================================================================== +test_cases_and_suites.cpp(0): +DESCRIPTION: regarding failures +TEST SUITE: test suite with a description +TEST CASE: fails - and its allowed + +test_cases_and_suites.cpp(0): FATAL ERROR: + +Allowed to fail so marking it as not failed +=============================================================================== +test_cases_and_suites.cpp(0): +DESCRIPTION: regarding failures +TEST SUITE: test suite with a description +TEST CASE: fails 1 time as it should + +test_cases_and_suites.cpp(0): FATAL ERROR: + +Failed exactly 1 times as expected so marking it as not failed! +=============================================================================== +test_cases_and_suites.cpp(0): +DESCRIPTION: regarding failures +TEST SUITE: test suite with a description +TEST CASE: fails as it should + +test_cases_and_suites.cpp(0): FATAL ERROR: + +Failed as expected so marking it as not failed +=============================================================================== +subcases.cpp(0): +TEST CASE: fails from an exception but gets re-entered to traverse all subcases + level zero + one + +subcases.cpp(0): ERROR: CHECK( false ) is NOT correct! + values: CHECK( false ) + +=============================================================================== +subcases.cpp(0): +TEST CASE: fails from an exception but gets re-entered to traverse all subcases + level zero + +DEEPEST SUBCASE STACK REACHED (DIFFERENT FROM THE CURRENT ONE): + level zero + one + +subcases.cpp(0): ERROR: test case THREW exception: exception thrown in subcase - will translate later when the whole test case has been exited (cannot translate while there is an active exception) + +=============================================================================== +subcases.cpp(0): +TEST CASE: fails from an exception but gets re-entered to traverse all subcases + +DEEPEST SUBCASE STACK REACHED (DIFFERENT FROM THE CURRENT ONE): + level zero + one + +subcases.cpp(0): ERROR: test case THREW exception: failure... but the show must go on! + +=============================================================================== +subcases.cpp(0): +TEST CASE: fails from an exception but gets re-entered to traverse all subcases + level zero + two + +subcases.cpp(0): ERROR: CHECK( false ) is NOT correct! + values: CHECK( false ) + +=============================================================================== +subcases.cpp(0): +TEST CASE: fails from an exception but gets re-entered to traverse all subcases + level zero + +DEEPEST SUBCASE STACK REACHED (DIFFERENT FROM THE CURRENT ONE): + level zero + two + +subcases.cpp(0): ERROR: test case THREW exception: exception thrown in subcase - will translate later when the whole test case has been exited (cannot translate while there is an active exception) + +=============================================================================== +subcases.cpp(0): +TEST CASE: fails from an exception but gets re-entered to traverse all subcases + +DEEPEST SUBCASE STACK REACHED (DIFFERENT FROM THE CURRENT ONE): + level zero + two + +subcases.cpp(0): ERROR: test case THREW exception: failure... but the show must go on! + +=============================================================================== +test_cases_and_suites.cpp(0): +DESCRIPTION: regarding failures +TEST SUITE: test suite with a description +TEST CASE: fails more times than it should + +test_cases_and_suites.cpp(0): ERROR: + +test_cases_and_suites.cpp(0): ERROR: + +Didn't fail exactly 1 times so marking it as failed! +=============================================================================== +test_cases_and_suites.cpp(0): +TEST CASE: fixtured test - not part of a test suite + +test_cases_and_suites.cpp(0): ERROR: CHECK( data == 85 ) is NOT correct! + values: CHECK( 21 == 85 ) + +=============================================================================== +header.h(0): +TEST SUITE: some TS +TEST CASE: in TS + +header.h(0): FATAL ERROR: + +=============================================================================== +logging.cpp(0): +TEST CASE: logging the counter of a loop + +logging.cpp(0): ERROR: CHECK( vec[i] != (1 << i) ) is NOT correct! + values: CHECK( 1 != 1 ) + logged: current iteration of loop: + i := 0 + +logging.cpp(0): ERROR: CHECK( vec[i] != (1 << i) ) is NOT correct! + values: CHECK( 2 != 2 ) + logged: current iteration of loop: + i := 1 + +logging.cpp(0): ERROR: CHECK( vec[i] != (1 << i) ) is NOT correct! + values: CHECK( 4 != 4 ) + logged: current iteration of loop: + i := 2 + +logging.cpp(0): ERROR: CHECK( vec[i] != (1 << i) ) is NOT correct! + values: CHECK( 8 != 8 ) + logged: current iteration of loop: + i := 3 + +logging.cpp(0): ERROR: CHECK( vec[i] != (1 << i) ) is NOT correct! + values: CHECK( 16 != 16 ) + logged: current iteration of loop: + i := 4 + + +root +1 +1.1 + +root +2 +2.1 + +root +2 +=============================================================================== +subcases.cpp(0): +TEST CASE: lots of nested subcases + +subcases.cpp(0): FATAL ERROR: + +=============================================================================== +templated_test_cases.cpp(0): +TEST CASE: multiple types + +templated_test_cases.cpp(0): ERROR: CHECK( t2 != T2() ) is NOT correct! + values: CHECK( 0 != 0 ) + +=============================================================================== +templated_test_cases.cpp(0): +TEST CASE: multiple types + +templated_test_cases.cpp(0): ERROR: CHECK( t2 != T2() ) is NOT correct! + values: CHECK( 0 != 0 ) + +=============================================================================== +templated_test_cases.cpp(0): +TEST CASE: multiple types> + +templated_test_cases.cpp(0): ERROR: CHECK( t2 != T2() ) is NOT correct! + values: CHECK( 0 != 0 ) + +=============================================================================== +stringification.cpp(0): +TEST CASE: no headers + +stringification.cpp(0): MESSAGE: 1as + +stringification.cpp(0): ERROR: CHECK( chs == nullptr ) is NOT correct! + values: CHECK( 1as == nullptr ) + +stringification.cpp(0): MESSAGE: 1as + +stringification.cpp(0): ERROR: CHECK( "1as" == nullptr ) is NOT correct! + values: CHECK( 1as == nullptr ) + +stringification.cpp(0): MESSAGE: [0, 1, 1, 2, 3, 5, 8, 13] + +stringification.cpp(0): ERROR: CHECK( ints == nullptr ) is NOT correct! + values: CHECK( [0, 1, 1, 2, 3, 5, 8, 13] == nullptr ) + +stringification.cpp(0): MESSAGE: [0, 1, 1, 2, 3, 5, 8, 13] + +stringification.cpp(0): MESSAGE: nullptr + +stringification.cpp(0): ERROR: CHECK( cnptr != nullptr ) is NOT correct! + values: CHECK( nullptr != nullptr ) + +stringification.cpp(0): MESSAGE: 0 + +stringification.cpp(0): ERROR: CHECK( A == C ) is NOT correct! + values: CHECK( 0 == 100 ) + +stringification.cpp(0): MESSAGE: int + +=============================================================================== +assertion_macros.cpp(0): +TEST CASE: normal macros + +assertion_macros.cpp(0): ERROR: CHECK( throw_if(true, std::runtime_error("whops!")) == 42 ) THREW exception: "whops!" + +assertion_macros.cpp(0): ERROR: CHECK( doctest::Approx(0.502) == 0.501 ) is NOT correct! + values: CHECK( Approx( 0.502 ) == 0.501 ) + +=============================================================================== +test_cases_and_suites.cpp(0): +TEST SUITE: ts1 +TEST CASE: normal test in a test suite from a decorator + +test_cases_and_suites.cpp(0): MESSAGE: failing because of the timeout decorator! + +Test case exceeded time limit of 0.000001! +=============================================================================== +stringification.cpp(0): +TEST CASE: operator<< + +stringification.cpp(0): MESSAGE: A + +stringification.cpp(0): MESSAGE: B + +stringification.cpp(0): MESSAGE: C + +=============================================================================== +test_cases_and_suites.cpp(0): +TEST SUITE: scoped test suite +TEST CASE: part of scoped + +test_cases_and_suites.cpp(0): FATAL ERROR: + +=============================================================================== +test_cases_and_suites.cpp(0): +TEST SUITE: scoped test suite +TEST CASE: part of scoped 2 + +test_cases_and_suites.cpp(0): FATAL ERROR: + +=============================================================================== +test_cases_and_suites.cpp(0): +TEST SUITE: some TS +TEST CASE: part of some TS + +test_cases_and_suites.cpp(0): FATAL ERROR: + + +root +outside of subcase +inside subcase 0 +outside of subcase +inside subcase 1 +outside of subcase +inside subcase 2 + +root +outside of subcase +also inside 0 +outside of subcase +also inside 1 +outside of subcase +also inside 2 + +root +outside of subcase +fail inside 0 +outside of subcase +=============================================================================== +subcases.cpp(0): +TEST CASE: reentering subcase via regular control flow + +DEEPEST SUBCASE STACK REACHED (DIFFERENT FROM THE CURRENT ONE): + +subcases.cpp(0): FATAL ERROR: 1 + + +root +outside of subcase +inside outside +nested twice 0, 0 +nested twice 0, 1 +nested twice 0, 2 +outside of subcase +inside outside +nested twice 1, 0 +nested twice 1, 1 +nested twice 1, 2 +outside of subcase +inside outside +nested twice 2, 0 +nested twice 2, 1 +nested twice 2, 2 + +root +outside of subcase +inside outside +also twice 0, 0 +also twice 0, 1 +also twice 0, 2 +outside of subcase +inside outside +also twice 1, 0 +also twice 1, 1 +also twice 1, 2 +outside of subcase +inside outside +also twice 2, 0 +also twice 2, 1 +also twice 2, 2 +=============================================================================== +test_cases_and_suites.cpp(0): +TEST CASE: should fail because of an exception + +test_cases_and_suites.cpp(0): ERROR: test case THREW exception: 0 + +=============================================================================== +assertion_macros.cpp(0): +TEST CASE: some asserts used in a function called by a test case + +assertion_macros.cpp(0): ERROR: CHECK_THROWS_WITH_AS( throw_if(true, false), "unknown exception", int ) threw a DIFFERENT exception! (contents: "unknown exception") + +=============================================================================== +subcases.cpp(0): +TEST CASE: subcases can be used in a separate function as well + from function... + +subcases.cpp(0): MESSAGE: print me twice + +=============================================================================== +subcases.cpp(0): +TEST CASE: subcases can be used in a separate function as well + from function... + sc1 + +subcases.cpp(0): MESSAGE: hello! from sc1 + +=============================================================================== +subcases.cpp(0): +TEST CASE: subcases can be used in a separate function as well + +DEEPEST SUBCASE STACK REACHED (DIFFERENT FROM THE CURRENT ONE): + from function... + sc1 + +subcases.cpp(0): MESSAGE: lala + +=============================================================================== +subcases.cpp(0): +TEST CASE: subcases can be used in a separate function as well + from function... + +subcases.cpp(0): MESSAGE: print me twice + +=============================================================================== +subcases.cpp(0): +TEST CASE: subcases can be used in a separate function as well + from function... + sc2 + +subcases.cpp(0): MESSAGE: hello! from sc2 + +=============================================================================== +subcases.cpp(0): +TEST CASE: subcases can be used in a separate function as well + +DEEPEST SUBCASE STACK REACHED (DIFFERENT FROM THE CURRENT ONE): + from function... + sc2 + +subcases.cpp(0): MESSAGE: lala + +=============================================================================== +subcases.cpp(0): +TEST CASE: subcases with changing names + outer 0 + inner 0 + +subcases.cpp(0): MESSAGE: msg! + +=============================================================================== +subcases.cpp(0): +TEST CASE: subcases with changing names + outer 0 + inner 1 + +subcases.cpp(0): MESSAGE: msg! + +=============================================================================== +subcases.cpp(0): +TEST CASE: subcases with changing names + outer 1 + inner 0 + +subcases.cpp(0): MESSAGE: msg! + +=============================================================================== +subcases.cpp(0): +TEST CASE: subcases with changing names + outer 1 + inner 1 + +subcases.cpp(0): MESSAGE: msg! + +=============================================================================== +subcases.cpp(0): +TEST CASE: subcases with changing names + separate + +subcases.cpp(0): MESSAGE: separate msg! + +=============================================================================== +header.h(0): +TEST CASE: template 1 + +header.h(0): FATAL ERROR: + +=============================================================================== +header.h(0): +TEST CASE: template 2 + +header.h(0): FATAL ERROR: + +=============================================================================== +subcases.cpp(0): +TEST CASE: test case should fail even though the last subcase passes + one + +subcases.cpp(0): ERROR: CHECK( false ) is NOT correct! + values: CHECK( false ) + +=============================================================================== +logging.cpp(0): +TEST CASE: third party asserts can report failures to doctest + +logging.cpp(0): ERROR: MY_ASSERT(false) + +logging.cpp(0): FATAL ERROR: MY_ASSERT_FATAL(false) + +=============================================================================== +test_cases_and_suites.cpp(0): +DESCRIPTION: this test has overridden its skip decorator +TEST SUITE: skipped test cases +TEST CASE: unskipped + +test_cases_and_suites.cpp(0): FATAL ERROR: + +=============================================================================== +templated_test_cases.cpp(0): +TEST CASE: vector stuff> + +templated_test_cases.cpp(0): ERROR: CHECK( vec.size() == 20 ) is NOT correct! + values: CHECK( 10 == 20 ) + +=============================================================================== +subcases.cpp(0): +TEST SUITE: with a funny name, +TEST CASE: with a funnier name\: + with the funniest name\, + +subcases.cpp(0): MESSAGE: Yes! + +=============================================================================== +subcases.cpp(0): +TEST SUITE: with a funny name, +TEST CASE: with a funnier name\: + with a slightly funny name : + +subcases.cpp(0): MESSAGE: Yep! + +=============================================================================== +subcases.cpp(0): +TEST SUITE: with a funny name, +TEST CASE: with a funnier name\: + without a funny name + +subcases.cpp(0): MESSAGE: NO! + +=============================================================================== +subcases.cpp(0): +TEST SUITE: with a funny name, +TEST CASE: without a funny name: + +subcases.cpp(0): MESSAGE: Nooo + +=============================================================================== +[doctest] test cases: 86 | 35 passed | 51 failed | +[doctest] assertions: 235 | 115 passed | 120 failed | +[doctest] Status: FAILURE! +Program code. diff --git a/dmff/dpnblist/external/doctest-2.4.11/examples/all_features/test_output/no_multithreading.txt b/dmff/dpnblist/external/doctest-2.4.11/examples/all_features/test_output/no_multithreading.txt new file mode 100644 index 00000000..4469b915 --- /dev/null +++ b/dmff/dpnblist/external/doctest-2.4.11/examples/all_features/test_output/no_multithreading.txt @@ -0,0 +1,931 @@ +[doctest] run with "--help" for options +=============================================================================== +subcases.cpp(0): + Scenario: vectors can be sized and resized + Given: A vector with some items + When: the size is increased + Then: the size and capacity change + +subcases.cpp(0): ERROR: CHECK( v.size() == 20 ) is NOT correct! + values: CHECK( 10 == 20 ) + +=============================================================================== +subcases.cpp(0): + Scenario: vectors can be sized and resized + Given: A vector with some items + When: less capacity is reserved + Then: neither size nor capacity are changed + +subcases.cpp(0): ERROR: CHECK( v.size() == 10 ) is NOT correct! + values: CHECK( 5 == 10 ) + +=============================================================================== +assertion_macros.cpp(0): +TEST CASE: CHECK level of asserts fail the test case but don't abort it + +assertion_macros.cpp(0): ERROR: CHECK( 0 ) is NOT correct! + values: CHECK( 0 ) + +assertion_macros.cpp(0): ERROR: CHECK_FALSE( 1 ) is NOT correct! + values: CHECK_FALSE( 1 ) + +assertion_macros.cpp(0): ERROR: CHECK_THROWS( throw_if(false, 0) ) did NOT throw at all! + +assertion_macros.cpp(0): ERROR: CHECK_THROWS_AS( throw_if(false, 0), bool ) did NOT throw at all! + +assertion_macros.cpp(0): ERROR: CHECK_THROWS_AS( throw_if(true, 0), bool ) threw a DIFFERENT exception: "0" + +assertion_macros.cpp(0): ERROR: CHECK_THROWS_WITH( throw_if(true, 0), "unrecognized" ) threw a DIFFERENT exception: "0" + +assertion_macros.cpp(0): ERROR: CHECK_THROWS_WITH_AS( throw_if(true, 0), "unrecognized", int ) threw a DIFFERENT exception! (contents: "0") + +assertion_macros.cpp(0): ERROR: CHECK_NOTHROW( throw_if(true, 0) ) THREW exception: "0" + +assertion_macros.cpp(0): ERROR: CHECK_EQ( 1, 0 ) is NOT correct! + values: CHECK_EQ( 1, 0 ) + +assertion_macros.cpp(0): ERROR: CHECK_UNARY( 0 ) is NOT correct! + values: CHECK_UNARY( 0 ) + +assertion_macros.cpp(0): ERROR: CHECK_UNARY_FALSE( 1 ) is NOT correct! + values: CHECK_UNARY_FALSE( 1 ) + +assertion_macros.cpp(0): MESSAGE: reached! + +=============================================================================== +decomposition.cpp(0): +TEST CASE: Move Only Type + +decomposition.cpp(0): ERROR: CHECK( genType(false) ) is NOT correct! + values: CHECK( {?} ) + +decomposition.cpp(0): ERROR: CHECK( a ) is NOT correct! + values: CHECK( {?} ) + +=============================================================================== +assertion_macros.cpp(0): +TEST CASE: REQUIRE level of asserts fail and abort the test case - 1 + +assertion_macros.cpp(0): FATAL ERROR: REQUIRE( 0 ) is NOT correct! + values: REQUIRE( 0 ) + +=============================================================================== +assertion_macros.cpp(0): +TEST CASE: REQUIRE level of asserts fail and abort the test case - 10 + +assertion_macros.cpp(0): FATAL ERROR: REQUIRE_NOTHROW( throw_if(true, 0) ) THREW exception: "0" + +=============================================================================== +assertion_macros.cpp(0): +TEST CASE: REQUIRE level of asserts fail and abort the test case - 11 + +assertion_macros.cpp(0): FATAL ERROR: REQUIRE_EQ( 1, 0 ) is NOT correct! + values: REQUIRE_EQ( 1, 0 ) + +=============================================================================== +assertion_macros.cpp(0): +TEST CASE: REQUIRE level of asserts fail and abort the test case - 12 + +assertion_macros.cpp(0): FATAL ERROR: REQUIRE_UNARY( 0 ) is NOT correct! + values: REQUIRE_UNARY( 0 ) + +=============================================================================== +assertion_macros.cpp(0): +TEST CASE: REQUIRE level of asserts fail and abort the test case - 13 + +assertion_macros.cpp(0): FATAL ERROR: REQUIRE_UNARY_FALSE( 1 ) is NOT correct! + values: REQUIRE_UNARY_FALSE( 1 ) + +=============================================================================== +assertion_macros.cpp(0): +TEST CASE: REQUIRE level of asserts fail and abort the test case - 2 + +assertion_macros.cpp(0): FATAL ERROR: REQUIRE_FALSE( 1 ) is NOT correct! + values: REQUIRE_FALSE( 1 ) + +=============================================================================== +assertion_macros.cpp(0): +TEST CASE: REQUIRE level of asserts fail and abort the test case - 3 + +assertion_macros.cpp(0): FATAL ERROR: REQUIRE_THROWS( throw_if(false, 0) ) did NOT throw at all! + +=============================================================================== +assertion_macros.cpp(0): +TEST CASE: REQUIRE level of asserts fail and abort the test case - 4 + +assertion_macros.cpp(0): FATAL ERROR: REQUIRE_THROWS_AS( throw_if(false, 0), bool ) did NOT throw at all! + +=============================================================================== +assertion_macros.cpp(0): +TEST CASE: REQUIRE level of asserts fail and abort the test case - 5 + +assertion_macros.cpp(0): FATAL ERROR: REQUIRE_THROWS_AS( throw_if(true, 0), bool ) threw a DIFFERENT exception: "0" + +=============================================================================== +assertion_macros.cpp(0): +TEST CASE: REQUIRE level of asserts fail and abort the test case - 6 + +assertion_macros.cpp(0): FATAL ERROR: REQUIRE_THROWS_WITH( throw_if(false, ""), "whops!" ) did NOT throw at all! + +=============================================================================== +assertion_macros.cpp(0): +TEST CASE: REQUIRE level of asserts fail and abort the test case - 7 + +assertion_macros.cpp(0): FATAL ERROR: REQUIRE_THROWS_WITH( throw_if(true, ""), "whops!" ) threw a DIFFERENT exception: + +=============================================================================== +assertion_macros.cpp(0): +TEST CASE: REQUIRE level of asserts fail and abort the test case - 8 + +assertion_macros.cpp(0): FATAL ERROR: REQUIRE_THROWS_WITH_AS( throw_if(false, ""), "whops!", bool ) did NOT throw at all! + +=============================================================================== +assertion_macros.cpp(0): +TEST CASE: REQUIRE level of asserts fail and abort the test case - 9 + +assertion_macros.cpp(0): FATAL ERROR: REQUIRE_THROWS_WITH_AS( throw_if(true, ""), "whops!", bool ) threw a DIFFERENT exception! (contents: ) + +=============================================================================== +assertion_macros.cpp(0): +TEST CASE: WARN level of asserts don't fail the test case + +assertion_macros.cpp(0): WARNING: WARN( 0 ) is NOT correct! + values: WARN( 0 ) + +assertion_macros.cpp(0): WARNING: WARN_FALSE( 1 ) is NOT correct! + values: WARN_FALSE( 1 ) + +assertion_macros.cpp(0): WARNING: WARN_THROWS( throw_if(false, 0) ) did NOT throw at all! + +assertion_macros.cpp(0): WARNING: WARN_THROWS_WITH( throw_if(true, ""), "whops!" ) threw a DIFFERENT exception: + +assertion_macros.cpp(0): WARNING: WARN_THROWS_WITH( throw_if(false, ""), "whops!" ) did NOT throw at all! + +assertion_macros.cpp(0): WARNING: WARN_THROWS_AS( throw_if(false, 0), bool ) did NOT throw at all! + +assertion_macros.cpp(0): WARNING: WARN_THROWS_AS( throw_if(true, 0), bool ) threw a DIFFERENT exception: "0" + +assertion_macros.cpp(0): WARNING: WARN_THROWS_WITH_AS( throw_if(false, ""), "whops!", int ) did NOT throw at all! + +assertion_macros.cpp(0): WARNING: WARN_THROWS_WITH_AS( throw_if(true, ""), "whops!", int ) threw a DIFFERENT exception! (contents: ) + +assertion_macros.cpp(0): WARNING: WARN_NOTHROW( throw_if(true, 0) ) THREW exception: "0" + +assertion_macros.cpp(0): WARNING: WARN_EQ( 1, 0 ) is NOT correct! + values: WARN_EQ( 1, 0 ) + +assertion_macros.cpp(0): WARNING: WARN_UNARY( 0 ) is NOT correct! + values: WARN_UNARY( 0 ) + +assertion_macros.cpp(0): WARNING: WARN_UNARY_FALSE( 1 ) is NOT correct! + values: WARN_UNARY_FALSE( 1 ) + +=============================================================================== +stringification.cpp(0): +TEST CASE: a test case that registers an exception translator for int and then throws one + +stringification.cpp(0): ERROR: test case THREW exception: 5 + +=============================================================================== +logging.cpp(0): +TEST CASE: a test case that will end from an exception + +logging.cpp(0): ERROR: forcing the many captures to be stringified + logged: lots of captures: 42 42 42; + old way of capturing - using the streaming operator: 42 42 + +logging.cpp(0): ERROR: CHECK( some_var == 666 ) is NOT correct! + values: CHECK( 42 == 666 ) + logged: someTests() returned: 42 + this should be printed if an exception is thrown even if no assert has failed: 42 + in a nested scope this should be printed as well: 42 + why is this not 666 ?! + +logging.cpp(0): ERROR: test case THREW exception: 0 + logged: someTests() returned: 42 + this should be printed if an exception is thrown even if no assert has failed: 42 + in a nested scope this should be printed as well: 42 + +=============================================================================== +logging.cpp(0): +TEST CASE: a test case that will end from an exception and should print the unprinted context + +logging.cpp(0): ERROR: test case THREW exception: 0 + logged: should be printed even if an exception is thrown and no assert fails before that + +=============================================================================== +stringification.cpp(0): +TEST CASE: all asserts should fail and show how the objects get stringified + +stringification.cpp(0): MESSAGE: Foo{} + +stringification.cpp(0): ERROR: CHECK( f1 == f2 ) is NOT correct! + values: CHECK( Foo{} == Foo{} ) + +stringification.cpp(0): MESSAGE: omg + +stringification.cpp(0): ERROR: CHECK( dummy == "tralala" ) is NOT correct! + values: CHECK( omg == tralala ) + +stringification.cpp(0): ERROR: CHECK( "tralala" == dummy ) is NOT correct! + values: CHECK( tralala == omg ) + +stringification.cpp(0): MESSAGE: [1, 2, 3] + +stringification.cpp(0): ERROR: CHECK( vec1 == vec2 ) is NOT correct! + values: CHECK( [1, 2, 3] == [1, 2, 4] ) + +stringification.cpp(0): MESSAGE: [1, 42, 3] + +stringification.cpp(0): ERROR: CHECK( lst_1 == lst_2 ) is NOT correct! + values: CHECK( [1, 42, 3] == [1, 2, 666] ) + +stringification.cpp(0): ERROR: CHECK( s1 == s2 ) is NOT correct! + values: CHECK( MyOtherType: 42 == MyOtherType: 666 ) + logged: s1=MyOtherType: 42 s2=MyOtherType: 666 + +stringification.cpp(0): ERROR: CHECK( s1 == s2 ) is NOT correct! + values: CHECK( MyOtherType: 42 == MyOtherType: 666 ) + logged: s1=MyOtherType: 42 s2=MyOtherType: 666 + MyOtherType: 42 is not really MyOtherType: 666 + +stringification.cpp(0): ERROR: CHECK( "a" == doctest::Contains("aaa") ) is NOT correct! + values: CHECK( a == Contains( aaa ) ) + +stringification.cpp(0): ERROR: test case THREW exception: MyTypeInherited(5, 4) + +=============================================================================== +templated_test_cases.cpp(0): +TEST CASE: bad stringification of type pair + +templated_test_cases.cpp(0): ERROR: CHECK( t2 != T2() ) is NOT correct! + values: CHECK( 0 != 0 ) + +=============================================================================== +assertion_macros.cpp(0): +TEST CASE: check return values + +assertion_macros.cpp(0): MESSAGE: :D + +assertion_macros.cpp(0): MESSAGE: :D + +assertion_macros.cpp(0): MESSAGE: :D + +assertion_macros.cpp(0): MESSAGE: :D + +assertion_macros.cpp(0): MESSAGE: :D + +assertion_macros.cpp(0): MESSAGE: :D + +assertion_macros.cpp(0): MESSAGE: :D + +assertion_macros.cpp(0): MESSAGE: :D + +assertion_macros.cpp(0): MESSAGE: :D + +=============================================================================== +assertion_macros.cpp(0): +TEST CASE: check return values no print + +assertion_macros.cpp(0): ERROR: CHECK( a == b ) is NOT correct! + values: CHECK( 4 == 2 ) + +assertion_macros.cpp(0): ERROR: CHECK_FALSE( a != b ) is NOT correct! + values: CHECK_FALSE( 4 != 2 ) + +assertion_macros.cpp(0): ERROR: CHECK_EQ( a, b ) is NOT correct! + values: CHECK_EQ( 4, 2 ) + +assertion_macros.cpp(0): ERROR: CHECK_UNARY( a == b ) is NOT correct! + values: CHECK_UNARY( false ) + +assertion_macros.cpp(0): ERROR: CHECK_UNARY_FALSE( a != b ) is NOT correct! + values: CHECK_UNARY_FALSE( true ) + +assertion_macros.cpp(0): ERROR: CHECK_THROWS( throw_if(false, false) ) did NOT throw at all! + +assertion_macros.cpp(0): ERROR: CHECK_THROWS_AS( throw_if(true, 2), doctest::Approx ) threw a DIFFERENT exception: "2" + +assertion_macros.cpp(0): ERROR: CHECK_NOTHROW( throw_if(true, 2) ) THREW exception: "2" + +assertion_macros.cpp(0): ERROR: CHECK_THROWS_WITH( throw_if(true, 2), "1" ) threw a DIFFERENT exception: "2" + +=============================================================================== +test_cases_and_suites.cpp(0): +DESCRIPTION: regarding failures +TEST SUITE: test suite with a description +TEST CASE: doesn't fail but it should have + +Should have failed but didn't! Marking it as failed! +=============================================================================== +enums.cpp(0): +TEST CASE: enum 2 + +enums.cpp(0): ERROR: CHECK_EQ( castToUnderlying(Zero), 1 ) is NOT correct! + values: CHECK_EQ( 0, 1 ) + +enums.cpp(0): ERROR: CHECK_EQ( castToUnderlying(One), 2 ) is NOT correct! + values: CHECK_EQ( 1, 2 ) + +enums.cpp(0): ERROR: CHECK_EQ( castToUnderlying(Two), 3 ) is NOT correct! + values: CHECK_EQ( 2, 3 ) + +enums.cpp(0): ERROR: CHECK_EQ( castToUnderlying(TypedZero), 1 ) is NOT correct! + values: CHECK_EQ( 0, 1 ) + +enums.cpp(0): ERROR: CHECK_EQ( castToUnderlying(TypedOne), 2 ) is NOT correct! + values: CHECK_EQ( 1, 2 ) + +enums.cpp(0): ERROR: CHECK_EQ( castToUnderlying(TypedTwo), 3 ) is NOT correct! + values: CHECK_EQ( 2, 3 ) + +enums.cpp(0): ERROR: CHECK_EQ( EnumClassC::Zero, EnumClassC::One ) is NOT correct! + values: CHECK_EQ( 48, 49 ) + +enums.cpp(0): ERROR: CHECK_EQ( EnumClassC::One, EnumClassC::Two ) is NOT correct! + values: CHECK_EQ( 49, 50 ) + +enums.cpp(0): ERROR: CHECK_EQ( EnumClassC::Two, EnumClassC::Zero ) is NOT correct! + values: CHECK_EQ( 50, 48 ) + +enums.cpp(0): ERROR: CHECK_EQ( EnumClassSC::Zero, EnumClassSC::One ) is NOT correct! + values: CHECK_EQ( 48, 49 ) + +enums.cpp(0): ERROR: CHECK_EQ( EnumClassSC::One, EnumClassSC::Two ) is NOT correct! + values: CHECK_EQ( 49, 50 ) + +enums.cpp(0): ERROR: CHECK_EQ( EnumClassSC::Two, EnumClassSC::Zero ) is NOT correct! + values: CHECK_EQ( 50, 48 ) + +enums.cpp(0): ERROR: CHECK_EQ( EnumClassUC::Zero, EnumClassUC::One ) is NOT correct! + values: CHECK_EQ( 48, 49 ) + +enums.cpp(0): ERROR: CHECK_EQ( EnumClassUC::One, EnumClassUC::Two ) is NOT correct! + values: CHECK_EQ( 49, 50 ) + +enums.cpp(0): ERROR: CHECK_EQ( EnumClassUC::Two, EnumClassUC::Zero ) is NOT correct! + values: CHECK_EQ( 50, 48 ) + +enums.cpp(0): ERROR: CHECK_EQ( EnumClassU8::Zero, EnumClassU8::One ) is NOT correct! + values: CHECK_EQ( 0, 1 ) + +enums.cpp(0): ERROR: CHECK_EQ( EnumClassU8::One, EnumClassU8::Two ) is NOT correct! + values: CHECK_EQ( 1, 2 ) + +enums.cpp(0): ERROR: CHECK_EQ( EnumClassU8::Two, EnumClassU8::Zero ) is NOT correct! + values: CHECK_EQ( 2, 0 ) + +Failed as expected so marking it as not failed +=============================================================================== +assertion_macros.cpp(0): +TEST CASE: exceptions-related macros + +assertion_macros.cpp(0): ERROR: CHECK_THROWS( throw_if(false, 0) ) did NOT throw at all! + +assertion_macros.cpp(0): ERROR: CHECK_THROWS_AS( throw_if(true, 0), char ) threw a DIFFERENT exception: "0" + +assertion_macros.cpp(0): ERROR: CHECK_THROWS_AS( throw_if(false, 0), int ) did NOT throw at all! + +assertion_macros.cpp(0): ERROR: CHECK_THROWS_WITH( throw_if(true, "whops!"), "whops! no match!" ) threw a DIFFERENT exception: "whops!" + +assertion_macros.cpp(0): ERROR: CHECK_THROWS_WITH( throw_if(true, "whops! does it match?"), "whops! no match!" ) threw a DIFFERENT exception: "whops! does it match?" + +assertion_macros.cpp(0): ERROR: CHECK_THROWS_WITH_AS( throw_if(true, "whops!"), "whops! no match!", bool ) threw a DIFFERENT exception! (contents: "whops!") + +assertion_macros.cpp(0): ERROR: CHECK_THROWS_WITH_AS( throw_if(true, "whops!"), "whops!", int ) threw a DIFFERENT exception! (contents: "whops!") + +assertion_macros.cpp(0): ERROR: CHECK_THROWS_WITH_AS( throw_if(true, "whops! does it match?"), "whops! no match!", int ) threw a DIFFERENT exception! (contents: "whops! does it match?") + +assertion_macros.cpp(0): ERROR: CHECK_NOTHROW( throw_if(true, 0) ) THREW exception: "0" + +=============================================================================== +assertion_macros.cpp(0): +TEST CASE: exceptions-related macros for std::exception + +assertion_macros.cpp(0): ERROR: CHECK_THROWS( throw_if(false, 0) ) did NOT throw at all! + +assertion_macros.cpp(0): ERROR: CHECK_THROWS_AS( throw_if(false, std::runtime_error("whops!")), std::exception ) did NOT throw at all! + +assertion_macros.cpp(0): ERROR: CHECK_THROWS_AS( throw_if(true, std::runtime_error("whops!")), int ) threw a DIFFERENT exception: "whops!" + +assertion_macros.cpp(0): ERROR: CHECK_THROWS_WITH( throw_if(false, ""), "whops!" ) did NOT throw at all! + +assertion_macros.cpp(0): FATAL ERROR: REQUIRE_NOTHROW( throw_if(true, std::runtime_error("whops!")) ) THREW exception: "whops!" + +=============================================================================== +logging.cpp(0): +TEST CASE: explicit failures 1 + +logging.cpp(0): ERROR: this should not end the test case, but mark it as failing + +logging.cpp(0): MESSAGE: reached! + +=============================================================================== +logging.cpp(0): +TEST CASE: explicit failures 2 + +logging.cpp(0): FATAL ERROR: fail the test case and also end it + +=============================================================================== +test_cases_and_suites.cpp(0): +DESCRIPTION: regarding failures +TEST SUITE: test suite with a description +TEST CASE: fails - and its allowed + +test_cases_and_suites.cpp(0): FATAL ERROR: + +Allowed to fail so marking it as not failed +=============================================================================== +test_cases_and_suites.cpp(0): +DESCRIPTION: regarding failures +TEST SUITE: test suite with a description +TEST CASE: fails 1 time as it should + +test_cases_and_suites.cpp(0): FATAL ERROR: + +Failed exactly 1 times as expected so marking it as not failed! +=============================================================================== +test_cases_and_suites.cpp(0): +DESCRIPTION: regarding failures +TEST SUITE: test suite with a description +TEST CASE: fails as it should + +test_cases_and_suites.cpp(0): FATAL ERROR: + +Failed as expected so marking it as not failed +=============================================================================== +subcases.cpp(0): +TEST CASE: fails from an exception but gets re-entered to traverse all subcases + level zero + one + +subcases.cpp(0): ERROR: CHECK( false ) is NOT correct! + values: CHECK( false ) + +=============================================================================== +subcases.cpp(0): +TEST CASE: fails from an exception but gets re-entered to traverse all subcases + level zero + +DEEPEST SUBCASE STACK REACHED (DIFFERENT FROM THE CURRENT ONE): + level zero + one + +subcases.cpp(0): ERROR: test case THREW exception: exception thrown in subcase - will translate later when the whole test case has been exited (cannot translate while there is an active exception) + +=============================================================================== +subcases.cpp(0): +TEST CASE: fails from an exception but gets re-entered to traverse all subcases + +DEEPEST SUBCASE STACK REACHED (DIFFERENT FROM THE CURRENT ONE): + level zero + one + +subcases.cpp(0): ERROR: test case THREW exception: failure... but the show must go on! + +=============================================================================== +subcases.cpp(0): +TEST CASE: fails from an exception but gets re-entered to traverse all subcases + level zero + two + +subcases.cpp(0): ERROR: CHECK( false ) is NOT correct! + values: CHECK( false ) + +=============================================================================== +subcases.cpp(0): +TEST CASE: fails from an exception but gets re-entered to traverse all subcases + level zero + +DEEPEST SUBCASE STACK REACHED (DIFFERENT FROM THE CURRENT ONE): + level zero + two + +subcases.cpp(0): ERROR: test case THREW exception: exception thrown in subcase - will translate later when the whole test case has been exited (cannot translate while there is an active exception) + +=============================================================================== +subcases.cpp(0): +TEST CASE: fails from an exception but gets re-entered to traverse all subcases + +DEEPEST SUBCASE STACK REACHED (DIFFERENT FROM THE CURRENT ONE): + level zero + two + +subcases.cpp(0): ERROR: test case THREW exception: failure... but the show must go on! + +=============================================================================== +test_cases_and_suites.cpp(0): +DESCRIPTION: regarding failures +TEST SUITE: test suite with a description +TEST CASE: fails more times than it should + +test_cases_and_suites.cpp(0): ERROR: + +test_cases_and_suites.cpp(0): ERROR: + +Didn't fail exactly 1 times so marking it as failed! +=============================================================================== +test_cases_and_suites.cpp(0): +TEST CASE: fixtured test - not part of a test suite + +test_cases_and_suites.cpp(0): ERROR: CHECK( data == 85 ) is NOT correct! + values: CHECK( 21 == 85 ) + +=============================================================================== +header.h(0): +TEST SUITE: some TS +TEST CASE: in TS + +header.h(0): FATAL ERROR: + +=============================================================================== +logging.cpp(0): +TEST CASE: logging the counter of a loop + +logging.cpp(0): ERROR: CHECK( vec[i] != (1 << i) ) is NOT correct! + values: CHECK( 1 != 1 ) + logged: current iteration of loop: + i := 0 + +logging.cpp(0): ERROR: CHECK( vec[i] != (1 << i) ) is NOT correct! + values: CHECK( 2 != 2 ) + logged: current iteration of loop: + i := 1 + +logging.cpp(0): ERROR: CHECK( vec[i] != (1 << i) ) is NOT correct! + values: CHECK( 4 != 4 ) + logged: current iteration of loop: + i := 2 + +logging.cpp(0): ERROR: CHECK( vec[i] != (1 << i) ) is NOT correct! + values: CHECK( 8 != 8 ) + logged: current iteration of loop: + i := 3 + +logging.cpp(0): ERROR: CHECK( vec[i] != (1 << i) ) is NOT correct! + values: CHECK( 16 != 16 ) + logged: current iteration of loop: + i := 4 + + +root +1 +1.1 + +root +2 +2.1 + +root +2 +=============================================================================== +subcases.cpp(0): +TEST CASE: lots of nested subcases + +subcases.cpp(0): FATAL ERROR: + +=============================================================================== +templated_test_cases.cpp(0): +TEST CASE: multiple types + +templated_test_cases.cpp(0): ERROR: CHECK( t2 != T2() ) is NOT correct! + values: CHECK( 0 != 0 ) + +=============================================================================== +templated_test_cases.cpp(0): +TEST CASE: multiple types + +templated_test_cases.cpp(0): ERROR: CHECK( t2 != T2() ) is NOT correct! + values: CHECK( 0 != 0 ) + +=============================================================================== +templated_test_cases.cpp(0): +TEST CASE: multiple types> + +templated_test_cases.cpp(0): ERROR: CHECK( t2 != T2() ) is NOT correct! + values: CHECK( 0 != 0 ) + +=============================================================================== +stringification.cpp(0): +TEST CASE: no headers + +stringification.cpp(0): MESSAGE: 1as + +stringification.cpp(0): ERROR: CHECK( chs == nullptr ) is NOT correct! + values: CHECK( 1as == nullptr ) + +stringification.cpp(0): MESSAGE: 1as + +stringification.cpp(0): ERROR: CHECK( "1as" == nullptr ) is NOT correct! + values: CHECK( 1as == nullptr ) + +stringification.cpp(0): MESSAGE: [0, 1, 1, 2, 3, 5, 8, 13] + +stringification.cpp(0): ERROR: CHECK( ints == nullptr ) is NOT correct! + values: CHECK( [0, 1, 1, 2, 3, 5, 8, 13] == nullptr ) + +stringification.cpp(0): MESSAGE: [0, 1, 1, 2, 3, 5, 8, 13] + +stringification.cpp(0): MESSAGE: nullptr + +stringification.cpp(0): ERROR: CHECK( cnptr != nullptr ) is NOT correct! + values: CHECK( nullptr != nullptr ) + +stringification.cpp(0): MESSAGE: 0 + +stringification.cpp(0): ERROR: CHECK( A == C ) is NOT correct! + values: CHECK( 0 == 100 ) + +stringification.cpp(0): MESSAGE: int + +=============================================================================== +assertion_macros.cpp(0): +TEST CASE: normal macros + +assertion_macros.cpp(0): ERROR: CHECK( throw_if(true, std::runtime_error("whops!")) == 42 ) THREW exception: "whops!" + +assertion_macros.cpp(0): ERROR: CHECK( doctest::Approx(0.502) == 0.501 ) is NOT correct! + values: CHECK( Approx( 0.502 ) == 0.501 ) + +=============================================================================== +test_cases_and_suites.cpp(0): +TEST SUITE: ts1 +TEST CASE: normal test in a test suite from a decorator + +test_cases_and_suites.cpp(0): MESSAGE: failing because of the timeout decorator! + +Test case exceeded time limit of 0.000001! +=============================================================================== +stringification.cpp(0): +TEST CASE: operator<< + +stringification.cpp(0): MESSAGE: A + +stringification.cpp(0): MESSAGE: B + +stringification.cpp(0): MESSAGE: C + +=============================================================================== +test_cases_and_suites.cpp(0): +TEST SUITE: scoped test suite +TEST CASE: part of scoped + +test_cases_and_suites.cpp(0): FATAL ERROR: + +=============================================================================== +test_cases_and_suites.cpp(0): +TEST SUITE: scoped test suite +TEST CASE: part of scoped 2 + +test_cases_and_suites.cpp(0): FATAL ERROR: + +=============================================================================== +test_cases_and_suites.cpp(0): +TEST SUITE: some TS +TEST CASE: part of some TS + +test_cases_and_suites.cpp(0): FATAL ERROR: + + +root +outside of subcase +inside subcase 0 +outside of subcase +inside subcase 1 +outside of subcase +inside subcase 2 + +root +outside of subcase +also inside 0 +outside of subcase +also inside 1 +outside of subcase +also inside 2 + +root +outside of subcase +fail inside 0 +outside of subcase +=============================================================================== +subcases.cpp(0): +TEST CASE: reentering subcase via regular control flow + +DEEPEST SUBCASE STACK REACHED (DIFFERENT FROM THE CURRENT ONE): + +subcases.cpp(0): FATAL ERROR: 1 + + +root +outside of subcase +inside outside +nested twice 0, 0 +nested twice 0, 1 +nested twice 0, 2 +outside of subcase +inside outside +nested twice 1, 0 +nested twice 1, 1 +nested twice 1, 2 +outside of subcase +inside outside +nested twice 2, 0 +nested twice 2, 1 +nested twice 2, 2 + +root +outside of subcase +inside outside +also twice 0, 0 +also twice 0, 1 +also twice 0, 2 +outside of subcase +inside outside +also twice 1, 0 +also twice 1, 1 +also twice 1, 2 +outside of subcase +inside outside +also twice 2, 0 +also twice 2, 1 +also twice 2, 2 +=============================================================================== +test_cases_and_suites.cpp(0): +TEST CASE: should fail because of an exception + +test_cases_and_suites.cpp(0): ERROR: test case THREW exception: 0 + +=============================================================================== +assertion_macros.cpp(0): +TEST CASE: some asserts used in a function called by a test case + +assertion_macros.cpp(0): ERROR: CHECK_THROWS_WITH_AS( throw_if(true, false), "unknown exception", int ) threw a DIFFERENT exception! (contents: "unknown exception") + +=============================================================================== +subcases.cpp(0): +TEST CASE: subcases can be used in a separate function as well + from function... + +subcases.cpp(0): MESSAGE: print me twice + +=============================================================================== +subcases.cpp(0): +TEST CASE: subcases can be used in a separate function as well + from function... + sc1 + +subcases.cpp(0): MESSAGE: hello! from sc1 + +=============================================================================== +subcases.cpp(0): +TEST CASE: subcases can be used in a separate function as well + +DEEPEST SUBCASE STACK REACHED (DIFFERENT FROM THE CURRENT ONE): + from function... + sc1 + +subcases.cpp(0): MESSAGE: lala + +=============================================================================== +subcases.cpp(0): +TEST CASE: subcases can be used in a separate function as well + from function... + +subcases.cpp(0): MESSAGE: print me twice + +=============================================================================== +subcases.cpp(0): +TEST CASE: subcases can be used in a separate function as well + from function... + sc2 + +subcases.cpp(0): MESSAGE: hello! from sc2 + +=============================================================================== +subcases.cpp(0): +TEST CASE: subcases can be used in a separate function as well + +DEEPEST SUBCASE STACK REACHED (DIFFERENT FROM THE CURRENT ONE): + from function... + sc2 + +subcases.cpp(0): MESSAGE: lala + +=============================================================================== +subcases.cpp(0): +TEST CASE: subcases with changing names + outer 0 + inner 0 + +subcases.cpp(0): MESSAGE: msg! + +=============================================================================== +subcases.cpp(0): +TEST CASE: subcases with changing names + outer 0 + inner 1 + +subcases.cpp(0): MESSAGE: msg! + +=============================================================================== +subcases.cpp(0): +TEST CASE: subcases with changing names + outer 1 + inner 0 + +subcases.cpp(0): MESSAGE: msg! + +=============================================================================== +subcases.cpp(0): +TEST CASE: subcases with changing names + outer 1 + inner 1 + +subcases.cpp(0): MESSAGE: msg! + +=============================================================================== +subcases.cpp(0): +TEST CASE: subcases with changing names + separate + +subcases.cpp(0): MESSAGE: separate msg! + +=============================================================================== +header.h(0): +TEST CASE: template 1 + +header.h(0): FATAL ERROR: + +=============================================================================== +header.h(0): +TEST CASE: template 2 + +header.h(0): FATAL ERROR: + +=============================================================================== +subcases.cpp(0): +TEST CASE: test case should fail even though the last subcase passes + one + +subcases.cpp(0): ERROR: CHECK( false ) is NOT correct! + values: CHECK( false ) + +=============================================================================== +logging.cpp(0): +TEST CASE: third party asserts can report failures to doctest + +logging.cpp(0): ERROR: MY_ASSERT(false) + +logging.cpp(0): FATAL ERROR: MY_ASSERT_FATAL(false) + +=============================================================================== +test_cases_and_suites.cpp(0): +DESCRIPTION: this test has overridden its skip decorator +TEST SUITE: skipped test cases +TEST CASE: unskipped + +test_cases_and_suites.cpp(0): FATAL ERROR: + +=============================================================================== +templated_test_cases.cpp(0): +TEST CASE: vector stuff> + +templated_test_cases.cpp(0): ERROR: CHECK( vec.size() == 20 ) is NOT correct! + values: CHECK( 10 == 20 ) + +=============================================================================== +subcases.cpp(0): +TEST SUITE: with a funny name, +TEST CASE: with a funnier name\: + with the funniest name\, + +subcases.cpp(0): MESSAGE: Yes! + +=============================================================================== +subcases.cpp(0): +TEST SUITE: with a funny name, +TEST CASE: with a funnier name\: + with a slightly funny name : + +subcases.cpp(0): MESSAGE: Yep! + +=============================================================================== +subcases.cpp(0): +TEST SUITE: with a funny name, +TEST CASE: with a funnier name\: + without a funny name + +subcases.cpp(0): MESSAGE: NO! + +=============================================================================== +subcases.cpp(0): +TEST SUITE: with a funny name, +TEST CASE: without a funny name: + +subcases.cpp(0): MESSAGE: Nooo + +=============================================================================== +[doctest] test cases: 86 | 35 passed | 51 failed | +[doctest] assertions: 235 | 115 passed | 120 failed | +[doctest] Status: FAILURE! +Program code. diff --git a/dmff/dpnblist/external/doctest-2.4.11/examples/all_features/test_output/order_1.txt b/dmff/dpnblist/external/doctest-2.4.11/examples/all_features/test_output/order_1.txt new file mode 100644 index 00000000..22637c39 --- /dev/null +++ b/dmff/dpnblist/external/doctest-2.4.11/examples/all_features/test_output/order_1.txt @@ -0,0 +1,108 @@ +[doctest] run with "--help" for options +=============================================================================== +test_cases_and_suites.cpp(0): +TEST CASE: should fail because of an exception + +test_cases_and_suites.cpp(0): ERROR: test case THREW exception: 0 + +=============================================================================== +test_cases_and_suites.cpp(0): +TEST CASE: fixtured test - not part of a test suite + +test_cases_and_suites.cpp(0): ERROR: CHECK( data == 85 ) is NOT correct! + values: CHECK( 21 == 85 ) + +=============================================================================== +test_cases_and_suites.cpp(0): +TEST SUITE: scoped test suite +TEST CASE: part of scoped + +test_cases_and_suites.cpp(0): FATAL ERROR: + +=============================================================================== +test_cases_and_suites.cpp(0): +TEST SUITE: scoped test suite +TEST CASE: part of scoped 2 + +test_cases_and_suites.cpp(0): FATAL ERROR: + +=============================================================================== +test_cases_and_suites.cpp(0): +DESCRIPTION: this test has overridden its skip decorator +TEST SUITE: skipped test cases +TEST CASE: unskipped + +test_cases_and_suites.cpp(0): FATAL ERROR: + +=============================================================================== +test_cases_and_suites.cpp(0): +TEST SUITE: skipped test cases +TEST CASE: skipped - inherited from the test suite + +test_cases_and_suites.cpp(0): FATAL ERROR: + +=============================================================================== +test_cases_and_suites.cpp(0): +TEST SUITE: some TS +TEST CASE: part of some TS + +test_cases_and_suites.cpp(0): FATAL ERROR: + +=============================================================================== +test_cases_and_suites.cpp(0): +DESCRIPTION: regarding failures +TEST SUITE: test suite with a description +TEST CASE: fails - and its allowed + +test_cases_and_suites.cpp(0): FATAL ERROR: + +Allowed to fail so marking it as not failed +=============================================================================== +test_cases_and_suites.cpp(0): +DESCRIPTION: regarding failures +TEST SUITE: test suite with a description +TEST CASE: fails as it should + +test_cases_and_suites.cpp(0): FATAL ERROR: + +Failed as expected so marking it as not failed +=============================================================================== +test_cases_and_suites.cpp(0): +DESCRIPTION: regarding failures +TEST SUITE: test suite with a description +TEST CASE: doesn't fail but it should have + +Should have failed but didn't! Marking it as failed! +=============================================================================== +test_cases_and_suites.cpp(0): +DESCRIPTION: regarding failures +TEST SUITE: test suite with a description +TEST CASE: fails 1 time as it should + +test_cases_and_suites.cpp(0): FATAL ERROR: + +Failed exactly 1 times as expected so marking it as not failed! +=============================================================================== +test_cases_and_suites.cpp(0): +DESCRIPTION: regarding failures +TEST SUITE: test suite with a description +TEST CASE: fails more times than it should + +test_cases_and_suites.cpp(0): ERROR: + +test_cases_and_suites.cpp(0): ERROR: + +Didn't fail exactly 1 times so marking it as failed! +=============================================================================== +test_cases_and_suites.cpp(0): +TEST SUITE: ts1 +TEST CASE: normal test in a test suite from a decorator + +test_cases_and_suites.cpp(0): MESSAGE: failing because of the timeout decorator! + +Test case exceeded time limit of 0.000001! +=============================================================================== +[doctest] test cases: 16 | 6 passed | 10 failed | +[doctest] assertions: 13 | 1 passed | 12 failed | +[doctest] Status: FAILURE! +Program code. diff --git a/dmff/dpnblist/external/doctest-2.4.11/examples/all_features/test_output/order_1_junit.txt b/dmff/dpnblist/external/doctest-2.4.11/examples/all_features/test_output/order_1_junit.txt new file mode 100644 index 00000000..5c369f32 --- /dev/null +++ b/dmff/dpnblist/external/doctest-2.4.11/examples/all_features/test_output/order_1_junit.txt @@ -0,0 +1,98 @@ + + + + + + + 0 + + + + +test_cases_and_suites.cpp(0): +CHECK( data == 85 ) is NOT correct! + values: CHECK( 21 == 85 ) + + + + + +test_cases_and_suites.cpp(0): + + + + + + +test_cases_and_suites.cpp(0): + + + + + + +test_cases_and_suites.cpp(0): + + + + + + +test_cases_and_suites.cpp(0): + + + + + + +test_cases_and_suites.cpp(0): + + + + + + +test_cases_and_suites.cpp(0): + + + + + + +test_cases_and_suites.cpp(0): + + + + + + + +test_cases_and_suites.cpp(0): + + + + + + + +test_cases_and_suites.cpp(0): + + + + + + +test_cases_and_suites.cpp(0): + + + + +test_cases_and_suites.cpp(0): + + + + + + + +Program code. diff --git a/dmff/dpnblist/external/doctest-2.4.11/examples/all_features/test_output/order_1_xml.txt b/dmff/dpnblist/external/doctest-2.4.11/examples/all_features/test_output/order_1_xml.txt new file mode 100644 index 00000000..257e5c04 --- /dev/null +++ b/dmff/dpnblist/external/doctest-2.4.11/examples/all_features/test_output/order_1_xml.txt @@ -0,0 +1,116 @@ + + + + + + + + + + 0 + + + + + + + data == 85 + + + 21 == 85 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + failing because of the timeout decorator! + + + + + + + + +Program code. diff --git a/dmff/dpnblist/external/doctest-2.4.11/examples/all_features/test_output/order_2.txt b/dmff/dpnblist/external/doctest-2.4.11/examples/all_features/test_output/order_2.txt new file mode 100644 index 00000000..8f00f52f --- /dev/null +++ b/dmff/dpnblist/external/doctest-2.4.11/examples/all_features/test_output/order_2.txt @@ -0,0 +1,101 @@ +[doctest] run with "--help" for options +=============================================================================== +test_cases_and_suites.cpp(0): +DESCRIPTION: regarding failures +TEST SUITE: test suite with a description +TEST CASE: doesn't fail but it should have + +Should have failed but didn't! Marking it as failed! +=============================================================================== +test_cases_and_suites.cpp(0): +DESCRIPTION: regarding failures +TEST SUITE: test suite with a description +TEST CASE: fails - and its allowed + +test_cases_and_suites.cpp(0): FATAL ERROR: + +Allowed to fail so marking it as not failed +=============================================================================== +test_cases_and_suites.cpp(0): +DESCRIPTION: regarding failures +TEST SUITE: test suite with a description +TEST CASE: fails 1 time as it should + +test_cases_and_suites.cpp(0): FATAL ERROR: + +Failed exactly 1 times as expected so marking it as not failed! +=============================================================================== +test_cases_and_suites.cpp(0): +DESCRIPTION: regarding failures +TEST SUITE: test suite with a description +TEST CASE: fails as it should + +test_cases_and_suites.cpp(0): FATAL ERROR: + +Failed as expected so marking it as not failed +=============================================================================== +test_cases_and_suites.cpp(0): +DESCRIPTION: regarding failures +TEST SUITE: test suite with a description +TEST CASE: fails more times than it should + +test_cases_and_suites.cpp(0): ERROR: + +test_cases_and_suites.cpp(0): ERROR: + +Didn't fail exactly 1 times so marking it as failed! +=============================================================================== +test_cases_and_suites.cpp(0): +TEST CASE: fixtured test - not part of a test suite + +test_cases_and_suites.cpp(0): ERROR: CHECK( data == 85 ) is NOT correct! + values: CHECK( 21 == 85 ) + +=============================================================================== +test_cases_and_suites.cpp(0): +TEST SUITE: ts1 +TEST CASE: normal test in a test suite from a decorator + +test_cases_and_suites.cpp(0): MESSAGE: failing because of the timeout decorator! + +Test case exceeded time limit of 0.000001! +=============================================================================== +test_cases_and_suites.cpp(0): +TEST SUITE: scoped test suite +TEST CASE: part of scoped + +test_cases_and_suites.cpp(0): FATAL ERROR: + +=============================================================================== +test_cases_and_suites.cpp(0): +TEST SUITE: scoped test suite +TEST CASE: part of scoped 2 + +test_cases_and_suites.cpp(0): FATAL ERROR: + +=============================================================================== +test_cases_and_suites.cpp(0): +TEST SUITE: some TS +TEST CASE: part of some TS + +test_cases_and_suites.cpp(0): FATAL ERROR: + +=============================================================================== +test_cases_and_suites.cpp(0): +TEST CASE: should fail because of an exception + +test_cases_and_suites.cpp(0): ERROR: test case THREW exception: 0 + +=============================================================================== +test_cases_and_suites.cpp(0): +DESCRIPTION: this test has overridden its skip decorator +TEST SUITE: skipped test cases +TEST CASE: unskipped + +test_cases_and_suites.cpp(0): FATAL ERROR: + +=============================================================================== +[doctest] test cases: 15 | 6 passed | 9 failed | +[doctest] assertions: 12 | 1 passed | 11 failed | +[doctest] Status: FAILURE! +Program code. diff --git a/dmff/dpnblist/external/doctest-2.4.11/examples/all_features/test_output/order_2_junit.txt b/dmff/dpnblist/external/doctest-2.4.11/examples/all_features/test_output/order_2_junit.txt new file mode 100644 index 00000000..6f3c7b2a --- /dev/null +++ b/dmff/dpnblist/external/doctest-2.4.11/examples/all_features/test_output/order_2_junit.txt @@ -0,0 +1,91 @@ + + + + + + + + +test_cases_and_suites.cpp(0): + + + + + + +test_cases_and_suites.cpp(0): + + + + + + +test_cases_and_suites.cpp(0): + + + + + + +test_cases_and_suites.cpp(0): + + + + +test_cases_and_suites.cpp(0): + + + + + + +test_cases_and_suites.cpp(0): +CHECK( data == 85 ) is NOT correct! + values: CHECK( 21 == 85 ) + + + + + + +test_cases_and_suites.cpp(0): + + + + + + +test_cases_and_suites.cpp(0): + + + + + + +test_cases_and_suites.cpp(0): + + + + + + +test_cases_and_suites.cpp(0): + + + + + + + 0 + + + + +test_cases_and_suites.cpp(0): + + + + + + +Program code. diff --git a/dmff/dpnblist/external/doctest-2.4.11/examples/all_features/test_output/order_2_xml.txt b/dmff/dpnblist/external/doctest-2.4.11/examples/all_features/test_output/order_2_xml.txt new file mode 100644 index 00000000..6e8fac30 --- /dev/null +++ b/dmff/dpnblist/external/doctest-2.4.11/examples/all_features/test_output/order_2_xml.txt @@ -0,0 +1,114 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + data == 85 + + + 21 == 85 + + + + + + + + + + failing because of the timeout decorator! + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 0 + + + + + + + + + + + + + + + +Program code. diff --git a/dmff/dpnblist/external/doctest-2.4.11/examples/all_features/test_output/order_3.txt b/dmff/dpnblist/external/doctest-2.4.11/examples/all_features/test_output/order_3.txt new file mode 100644 index 00000000..668d9dd1 --- /dev/null +++ b/dmff/dpnblist/external/doctest-2.4.11/examples/all_features/test_output/order_3.txt @@ -0,0 +1,6 @@ +[doctest] run with "--help" for options +=============================================================================== +[doctest] test cases: 0 | 0 passed | 0 failed | +[doctest] assertions: 0 | 0 passed | 0 failed | +[doctest] Status: SUCCESS! +Program code. diff --git a/dmff/dpnblist/external/doctest-2.4.11/examples/all_features/test_output/order_3_junit.txt b/dmff/dpnblist/external/doctest-2.4.11/examples/all_features/test_output/order_3_junit.txt new file mode 100644 index 00000000..04b87701 --- /dev/null +++ b/dmff/dpnblist/external/doctest-2.4.11/examples/all_features/test_output/order_3_junit.txt @@ -0,0 +1,5 @@ + + + + +Program code. diff --git a/dmff/dpnblist/external/doctest-2.4.11/examples/all_features/test_output/order_3_xml.txt b/dmff/dpnblist/external/doctest-2.4.11/examples/all_features/test_output/order_3_xml.txt new file mode 100644 index 00000000..be84c82c --- /dev/null +++ b/dmff/dpnblist/external/doctest-2.4.11/examples/all_features/test_output/order_3_xml.txt @@ -0,0 +1,7 @@ + + + + + + +Program code. diff --git a/dmff/dpnblist/external/doctest-2.4.11/examples/all_features/test_output/reporters_and_listeners.cpp.txt b/dmff/dpnblist/external/doctest-2.4.11/examples/all_features/test_output/reporters_and_listeners.cpp.txt new file mode 100644 index 00000000..668d9dd1 --- /dev/null +++ b/dmff/dpnblist/external/doctest-2.4.11/examples/all_features/test_output/reporters_and_listeners.cpp.txt @@ -0,0 +1,6 @@ +[doctest] run with "--help" for options +=============================================================================== +[doctest] test cases: 0 | 0 passed | 0 failed | +[doctest] assertions: 0 | 0 passed | 0 failed | +[doctest] Status: SUCCESS! +Program code. diff --git a/dmff/dpnblist/external/doctest-2.4.11/examples/all_features/test_output/reporters_and_listeners.cpp_junit.txt b/dmff/dpnblist/external/doctest-2.4.11/examples/all_features/test_output/reporters_and_listeners.cpp_junit.txt new file mode 100644 index 00000000..04b87701 --- /dev/null +++ b/dmff/dpnblist/external/doctest-2.4.11/examples/all_features/test_output/reporters_and_listeners.cpp_junit.txt @@ -0,0 +1,5 @@ + + + + +Program code. diff --git a/dmff/dpnblist/external/doctest-2.4.11/examples/all_features/test_output/reporters_and_listeners.cpp_xml.txt b/dmff/dpnblist/external/doctest-2.4.11/examples/all_features/test_output/reporters_and_listeners.cpp_xml.txt new file mode 100644 index 00000000..1ea28b6c --- /dev/null +++ b/dmff/dpnblist/external/doctest-2.4.11/examples/all_features/test_output/reporters_and_listeners.cpp_xml.txt @@ -0,0 +1,7 @@ + + + + + + +Program code. diff --git a/dmff/dpnblist/external/doctest-2.4.11/examples/all_features/test_output/std_headers.txt b/dmff/dpnblist/external/doctest-2.4.11/examples/all_features/test_output/std_headers.txt new file mode 100644 index 00000000..4469b915 --- /dev/null +++ b/dmff/dpnblist/external/doctest-2.4.11/examples/all_features/test_output/std_headers.txt @@ -0,0 +1,931 @@ +[doctest] run with "--help" for options +=============================================================================== +subcases.cpp(0): + Scenario: vectors can be sized and resized + Given: A vector with some items + When: the size is increased + Then: the size and capacity change + +subcases.cpp(0): ERROR: CHECK( v.size() == 20 ) is NOT correct! + values: CHECK( 10 == 20 ) + +=============================================================================== +subcases.cpp(0): + Scenario: vectors can be sized and resized + Given: A vector with some items + When: less capacity is reserved + Then: neither size nor capacity are changed + +subcases.cpp(0): ERROR: CHECK( v.size() == 10 ) is NOT correct! + values: CHECK( 5 == 10 ) + +=============================================================================== +assertion_macros.cpp(0): +TEST CASE: CHECK level of asserts fail the test case but don't abort it + +assertion_macros.cpp(0): ERROR: CHECK( 0 ) is NOT correct! + values: CHECK( 0 ) + +assertion_macros.cpp(0): ERROR: CHECK_FALSE( 1 ) is NOT correct! + values: CHECK_FALSE( 1 ) + +assertion_macros.cpp(0): ERROR: CHECK_THROWS( throw_if(false, 0) ) did NOT throw at all! + +assertion_macros.cpp(0): ERROR: CHECK_THROWS_AS( throw_if(false, 0), bool ) did NOT throw at all! + +assertion_macros.cpp(0): ERROR: CHECK_THROWS_AS( throw_if(true, 0), bool ) threw a DIFFERENT exception: "0" + +assertion_macros.cpp(0): ERROR: CHECK_THROWS_WITH( throw_if(true, 0), "unrecognized" ) threw a DIFFERENT exception: "0" + +assertion_macros.cpp(0): ERROR: CHECK_THROWS_WITH_AS( throw_if(true, 0), "unrecognized", int ) threw a DIFFERENT exception! (contents: "0") + +assertion_macros.cpp(0): ERROR: CHECK_NOTHROW( throw_if(true, 0) ) THREW exception: "0" + +assertion_macros.cpp(0): ERROR: CHECK_EQ( 1, 0 ) is NOT correct! + values: CHECK_EQ( 1, 0 ) + +assertion_macros.cpp(0): ERROR: CHECK_UNARY( 0 ) is NOT correct! + values: CHECK_UNARY( 0 ) + +assertion_macros.cpp(0): ERROR: CHECK_UNARY_FALSE( 1 ) is NOT correct! + values: CHECK_UNARY_FALSE( 1 ) + +assertion_macros.cpp(0): MESSAGE: reached! + +=============================================================================== +decomposition.cpp(0): +TEST CASE: Move Only Type + +decomposition.cpp(0): ERROR: CHECK( genType(false) ) is NOT correct! + values: CHECK( {?} ) + +decomposition.cpp(0): ERROR: CHECK( a ) is NOT correct! + values: CHECK( {?} ) + +=============================================================================== +assertion_macros.cpp(0): +TEST CASE: REQUIRE level of asserts fail and abort the test case - 1 + +assertion_macros.cpp(0): FATAL ERROR: REQUIRE( 0 ) is NOT correct! + values: REQUIRE( 0 ) + +=============================================================================== +assertion_macros.cpp(0): +TEST CASE: REQUIRE level of asserts fail and abort the test case - 10 + +assertion_macros.cpp(0): FATAL ERROR: REQUIRE_NOTHROW( throw_if(true, 0) ) THREW exception: "0" + +=============================================================================== +assertion_macros.cpp(0): +TEST CASE: REQUIRE level of asserts fail and abort the test case - 11 + +assertion_macros.cpp(0): FATAL ERROR: REQUIRE_EQ( 1, 0 ) is NOT correct! + values: REQUIRE_EQ( 1, 0 ) + +=============================================================================== +assertion_macros.cpp(0): +TEST CASE: REQUIRE level of asserts fail and abort the test case - 12 + +assertion_macros.cpp(0): FATAL ERROR: REQUIRE_UNARY( 0 ) is NOT correct! + values: REQUIRE_UNARY( 0 ) + +=============================================================================== +assertion_macros.cpp(0): +TEST CASE: REQUIRE level of asserts fail and abort the test case - 13 + +assertion_macros.cpp(0): FATAL ERROR: REQUIRE_UNARY_FALSE( 1 ) is NOT correct! + values: REQUIRE_UNARY_FALSE( 1 ) + +=============================================================================== +assertion_macros.cpp(0): +TEST CASE: REQUIRE level of asserts fail and abort the test case - 2 + +assertion_macros.cpp(0): FATAL ERROR: REQUIRE_FALSE( 1 ) is NOT correct! + values: REQUIRE_FALSE( 1 ) + +=============================================================================== +assertion_macros.cpp(0): +TEST CASE: REQUIRE level of asserts fail and abort the test case - 3 + +assertion_macros.cpp(0): FATAL ERROR: REQUIRE_THROWS( throw_if(false, 0) ) did NOT throw at all! + +=============================================================================== +assertion_macros.cpp(0): +TEST CASE: REQUIRE level of asserts fail and abort the test case - 4 + +assertion_macros.cpp(0): FATAL ERROR: REQUIRE_THROWS_AS( throw_if(false, 0), bool ) did NOT throw at all! + +=============================================================================== +assertion_macros.cpp(0): +TEST CASE: REQUIRE level of asserts fail and abort the test case - 5 + +assertion_macros.cpp(0): FATAL ERROR: REQUIRE_THROWS_AS( throw_if(true, 0), bool ) threw a DIFFERENT exception: "0" + +=============================================================================== +assertion_macros.cpp(0): +TEST CASE: REQUIRE level of asserts fail and abort the test case - 6 + +assertion_macros.cpp(0): FATAL ERROR: REQUIRE_THROWS_WITH( throw_if(false, ""), "whops!" ) did NOT throw at all! + +=============================================================================== +assertion_macros.cpp(0): +TEST CASE: REQUIRE level of asserts fail and abort the test case - 7 + +assertion_macros.cpp(0): FATAL ERROR: REQUIRE_THROWS_WITH( throw_if(true, ""), "whops!" ) threw a DIFFERENT exception: + +=============================================================================== +assertion_macros.cpp(0): +TEST CASE: REQUIRE level of asserts fail and abort the test case - 8 + +assertion_macros.cpp(0): FATAL ERROR: REQUIRE_THROWS_WITH_AS( throw_if(false, ""), "whops!", bool ) did NOT throw at all! + +=============================================================================== +assertion_macros.cpp(0): +TEST CASE: REQUIRE level of asserts fail and abort the test case - 9 + +assertion_macros.cpp(0): FATAL ERROR: REQUIRE_THROWS_WITH_AS( throw_if(true, ""), "whops!", bool ) threw a DIFFERENT exception! (contents: ) + +=============================================================================== +assertion_macros.cpp(0): +TEST CASE: WARN level of asserts don't fail the test case + +assertion_macros.cpp(0): WARNING: WARN( 0 ) is NOT correct! + values: WARN( 0 ) + +assertion_macros.cpp(0): WARNING: WARN_FALSE( 1 ) is NOT correct! + values: WARN_FALSE( 1 ) + +assertion_macros.cpp(0): WARNING: WARN_THROWS( throw_if(false, 0) ) did NOT throw at all! + +assertion_macros.cpp(0): WARNING: WARN_THROWS_WITH( throw_if(true, ""), "whops!" ) threw a DIFFERENT exception: + +assertion_macros.cpp(0): WARNING: WARN_THROWS_WITH( throw_if(false, ""), "whops!" ) did NOT throw at all! + +assertion_macros.cpp(0): WARNING: WARN_THROWS_AS( throw_if(false, 0), bool ) did NOT throw at all! + +assertion_macros.cpp(0): WARNING: WARN_THROWS_AS( throw_if(true, 0), bool ) threw a DIFFERENT exception: "0" + +assertion_macros.cpp(0): WARNING: WARN_THROWS_WITH_AS( throw_if(false, ""), "whops!", int ) did NOT throw at all! + +assertion_macros.cpp(0): WARNING: WARN_THROWS_WITH_AS( throw_if(true, ""), "whops!", int ) threw a DIFFERENT exception! (contents: ) + +assertion_macros.cpp(0): WARNING: WARN_NOTHROW( throw_if(true, 0) ) THREW exception: "0" + +assertion_macros.cpp(0): WARNING: WARN_EQ( 1, 0 ) is NOT correct! + values: WARN_EQ( 1, 0 ) + +assertion_macros.cpp(0): WARNING: WARN_UNARY( 0 ) is NOT correct! + values: WARN_UNARY( 0 ) + +assertion_macros.cpp(0): WARNING: WARN_UNARY_FALSE( 1 ) is NOT correct! + values: WARN_UNARY_FALSE( 1 ) + +=============================================================================== +stringification.cpp(0): +TEST CASE: a test case that registers an exception translator for int and then throws one + +stringification.cpp(0): ERROR: test case THREW exception: 5 + +=============================================================================== +logging.cpp(0): +TEST CASE: a test case that will end from an exception + +logging.cpp(0): ERROR: forcing the many captures to be stringified + logged: lots of captures: 42 42 42; + old way of capturing - using the streaming operator: 42 42 + +logging.cpp(0): ERROR: CHECK( some_var == 666 ) is NOT correct! + values: CHECK( 42 == 666 ) + logged: someTests() returned: 42 + this should be printed if an exception is thrown even if no assert has failed: 42 + in a nested scope this should be printed as well: 42 + why is this not 666 ?! + +logging.cpp(0): ERROR: test case THREW exception: 0 + logged: someTests() returned: 42 + this should be printed if an exception is thrown even if no assert has failed: 42 + in a nested scope this should be printed as well: 42 + +=============================================================================== +logging.cpp(0): +TEST CASE: a test case that will end from an exception and should print the unprinted context + +logging.cpp(0): ERROR: test case THREW exception: 0 + logged: should be printed even if an exception is thrown and no assert fails before that + +=============================================================================== +stringification.cpp(0): +TEST CASE: all asserts should fail and show how the objects get stringified + +stringification.cpp(0): MESSAGE: Foo{} + +stringification.cpp(0): ERROR: CHECK( f1 == f2 ) is NOT correct! + values: CHECK( Foo{} == Foo{} ) + +stringification.cpp(0): MESSAGE: omg + +stringification.cpp(0): ERROR: CHECK( dummy == "tralala" ) is NOT correct! + values: CHECK( omg == tralala ) + +stringification.cpp(0): ERROR: CHECK( "tralala" == dummy ) is NOT correct! + values: CHECK( tralala == omg ) + +stringification.cpp(0): MESSAGE: [1, 2, 3] + +stringification.cpp(0): ERROR: CHECK( vec1 == vec2 ) is NOT correct! + values: CHECK( [1, 2, 3] == [1, 2, 4] ) + +stringification.cpp(0): MESSAGE: [1, 42, 3] + +stringification.cpp(0): ERROR: CHECK( lst_1 == lst_2 ) is NOT correct! + values: CHECK( [1, 42, 3] == [1, 2, 666] ) + +stringification.cpp(0): ERROR: CHECK( s1 == s2 ) is NOT correct! + values: CHECK( MyOtherType: 42 == MyOtherType: 666 ) + logged: s1=MyOtherType: 42 s2=MyOtherType: 666 + +stringification.cpp(0): ERROR: CHECK( s1 == s2 ) is NOT correct! + values: CHECK( MyOtherType: 42 == MyOtherType: 666 ) + logged: s1=MyOtherType: 42 s2=MyOtherType: 666 + MyOtherType: 42 is not really MyOtherType: 666 + +stringification.cpp(0): ERROR: CHECK( "a" == doctest::Contains("aaa") ) is NOT correct! + values: CHECK( a == Contains( aaa ) ) + +stringification.cpp(0): ERROR: test case THREW exception: MyTypeInherited(5, 4) + +=============================================================================== +templated_test_cases.cpp(0): +TEST CASE: bad stringification of type pair + +templated_test_cases.cpp(0): ERROR: CHECK( t2 != T2() ) is NOT correct! + values: CHECK( 0 != 0 ) + +=============================================================================== +assertion_macros.cpp(0): +TEST CASE: check return values + +assertion_macros.cpp(0): MESSAGE: :D + +assertion_macros.cpp(0): MESSAGE: :D + +assertion_macros.cpp(0): MESSAGE: :D + +assertion_macros.cpp(0): MESSAGE: :D + +assertion_macros.cpp(0): MESSAGE: :D + +assertion_macros.cpp(0): MESSAGE: :D + +assertion_macros.cpp(0): MESSAGE: :D + +assertion_macros.cpp(0): MESSAGE: :D + +assertion_macros.cpp(0): MESSAGE: :D + +=============================================================================== +assertion_macros.cpp(0): +TEST CASE: check return values no print + +assertion_macros.cpp(0): ERROR: CHECK( a == b ) is NOT correct! + values: CHECK( 4 == 2 ) + +assertion_macros.cpp(0): ERROR: CHECK_FALSE( a != b ) is NOT correct! + values: CHECK_FALSE( 4 != 2 ) + +assertion_macros.cpp(0): ERROR: CHECK_EQ( a, b ) is NOT correct! + values: CHECK_EQ( 4, 2 ) + +assertion_macros.cpp(0): ERROR: CHECK_UNARY( a == b ) is NOT correct! + values: CHECK_UNARY( false ) + +assertion_macros.cpp(0): ERROR: CHECK_UNARY_FALSE( a != b ) is NOT correct! + values: CHECK_UNARY_FALSE( true ) + +assertion_macros.cpp(0): ERROR: CHECK_THROWS( throw_if(false, false) ) did NOT throw at all! + +assertion_macros.cpp(0): ERROR: CHECK_THROWS_AS( throw_if(true, 2), doctest::Approx ) threw a DIFFERENT exception: "2" + +assertion_macros.cpp(0): ERROR: CHECK_NOTHROW( throw_if(true, 2) ) THREW exception: "2" + +assertion_macros.cpp(0): ERROR: CHECK_THROWS_WITH( throw_if(true, 2), "1" ) threw a DIFFERENT exception: "2" + +=============================================================================== +test_cases_and_suites.cpp(0): +DESCRIPTION: regarding failures +TEST SUITE: test suite with a description +TEST CASE: doesn't fail but it should have + +Should have failed but didn't! Marking it as failed! +=============================================================================== +enums.cpp(0): +TEST CASE: enum 2 + +enums.cpp(0): ERROR: CHECK_EQ( castToUnderlying(Zero), 1 ) is NOT correct! + values: CHECK_EQ( 0, 1 ) + +enums.cpp(0): ERROR: CHECK_EQ( castToUnderlying(One), 2 ) is NOT correct! + values: CHECK_EQ( 1, 2 ) + +enums.cpp(0): ERROR: CHECK_EQ( castToUnderlying(Two), 3 ) is NOT correct! + values: CHECK_EQ( 2, 3 ) + +enums.cpp(0): ERROR: CHECK_EQ( castToUnderlying(TypedZero), 1 ) is NOT correct! + values: CHECK_EQ( 0, 1 ) + +enums.cpp(0): ERROR: CHECK_EQ( castToUnderlying(TypedOne), 2 ) is NOT correct! + values: CHECK_EQ( 1, 2 ) + +enums.cpp(0): ERROR: CHECK_EQ( castToUnderlying(TypedTwo), 3 ) is NOT correct! + values: CHECK_EQ( 2, 3 ) + +enums.cpp(0): ERROR: CHECK_EQ( EnumClassC::Zero, EnumClassC::One ) is NOT correct! + values: CHECK_EQ( 48, 49 ) + +enums.cpp(0): ERROR: CHECK_EQ( EnumClassC::One, EnumClassC::Two ) is NOT correct! + values: CHECK_EQ( 49, 50 ) + +enums.cpp(0): ERROR: CHECK_EQ( EnumClassC::Two, EnumClassC::Zero ) is NOT correct! + values: CHECK_EQ( 50, 48 ) + +enums.cpp(0): ERROR: CHECK_EQ( EnumClassSC::Zero, EnumClassSC::One ) is NOT correct! + values: CHECK_EQ( 48, 49 ) + +enums.cpp(0): ERROR: CHECK_EQ( EnumClassSC::One, EnumClassSC::Two ) is NOT correct! + values: CHECK_EQ( 49, 50 ) + +enums.cpp(0): ERROR: CHECK_EQ( EnumClassSC::Two, EnumClassSC::Zero ) is NOT correct! + values: CHECK_EQ( 50, 48 ) + +enums.cpp(0): ERROR: CHECK_EQ( EnumClassUC::Zero, EnumClassUC::One ) is NOT correct! + values: CHECK_EQ( 48, 49 ) + +enums.cpp(0): ERROR: CHECK_EQ( EnumClassUC::One, EnumClassUC::Two ) is NOT correct! + values: CHECK_EQ( 49, 50 ) + +enums.cpp(0): ERROR: CHECK_EQ( EnumClassUC::Two, EnumClassUC::Zero ) is NOT correct! + values: CHECK_EQ( 50, 48 ) + +enums.cpp(0): ERROR: CHECK_EQ( EnumClassU8::Zero, EnumClassU8::One ) is NOT correct! + values: CHECK_EQ( 0, 1 ) + +enums.cpp(0): ERROR: CHECK_EQ( EnumClassU8::One, EnumClassU8::Two ) is NOT correct! + values: CHECK_EQ( 1, 2 ) + +enums.cpp(0): ERROR: CHECK_EQ( EnumClassU8::Two, EnumClassU8::Zero ) is NOT correct! + values: CHECK_EQ( 2, 0 ) + +Failed as expected so marking it as not failed +=============================================================================== +assertion_macros.cpp(0): +TEST CASE: exceptions-related macros + +assertion_macros.cpp(0): ERROR: CHECK_THROWS( throw_if(false, 0) ) did NOT throw at all! + +assertion_macros.cpp(0): ERROR: CHECK_THROWS_AS( throw_if(true, 0), char ) threw a DIFFERENT exception: "0" + +assertion_macros.cpp(0): ERROR: CHECK_THROWS_AS( throw_if(false, 0), int ) did NOT throw at all! + +assertion_macros.cpp(0): ERROR: CHECK_THROWS_WITH( throw_if(true, "whops!"), "whops! no match!" ) threw a DIFFERENT exception: "whops!" + +assertion_macros.cpp(0): ERROR: CHECK_THROWS_WITH( throw_if(true, "whops! does it match?"), "whops! no match!" ) threw a DIFFERENT exception: "whops! does it match?" + +assertion_macros.cpp(0): ERROR: CHECK_THROWS_WITH_AS( throw_if(true, "whops!"), "whops! no match!", bool ) threw a DIFFERENT exception! (contents: "whops!") + +assertion_macros.cpp(0): ERROR: CHECK_THROWS_WITH_AS( throw_if(true, "whops!"), "whops!", int ) threw a DIFFERENT exception! (contents: "whops!") + +assertion_macros.cpp(0): ERROR: CHECK_THROWS_WITH_AS( throw_if(true, "whops! does it match?"), "whops! no match!", int ) threw a DIFFERENT exception! (contents: "whops! does it match?") + +assertion_macros.cpp(0): ERROR: CHECK_NOTHROW( throw_if(true, 0) ) THREW exception: "0" + +=============================================================================== +assertion_macros.cpp(0): +TEST CASE: exceptions-related macros for std::exception + +assertion_macros.cpp(0): ERROR: CHECK_THROWS( throw_if(false, 0) ) did NOT throw at all! + +assertion_macros.cpp(0): ERROR: CHECK_THROWS_AS( throw_if(false, std::runtime_error("whops!")), std::exception ) did NOT throw at all! + +assertion_macros.cpp(0): ERROR: CHECK_THROWS_AS( throw_if(true, std::runtime_error("whops!")), int ) threw a DIFFERENT exception: "whops!" + +assertion_macros.cpp(0): ERROR: CHECK_THROWS_WITH( throw_if(false, ""), "whops!" ) did NOT throw at all! + +assertion_macros.cpp(0): FATAL ERROR: REQUIRE_NOTHROW( throw_if(true, std::runtime_error("whops!")) ) THREW exception: "whops!" + +=============================================================================== +logging.cpp(0): +TEST CASE: explicit failures 1 + +logging.cpp(0): ERROR: this should not end the test case, but mark it as failing + +logging.cpp(0): MESSAGE: reached! + +=============================================================================== +logging.cpp(0): +TEST CASE: explicit failures 2 + +logging.cpp(0): FATAL ERROR: fail the test case and also end it + +=============================================================================== +test_cases_and_suites.cpp(0): +DESCRIPTION: regarding failures +TEST SUITE: test suite with a description +TEST CASE: fails - and its allowed + +test_cases_and_suites.cpp(0): FATAL ERROR: + +Allowed to fail so marking it as not failed +=============================================================================== +test_cases_and_suites.cpp(0): +DESCRIPTION: regarding failures +TEST SUITE: test suite with a description +TEST CASE: fails 1 time as it should + +test_cases_and_suites.cpp(0): FATAL ERROR: + +Failed exactly 1 times as expected so marking it as not failed! +=============================================================================== +test_cases_and_suites.cpp(0): +DESCRIPTION: regarding failures +TEST SUITE: test suite with a description +TEST CASE: fails as it should + +test_cases_and_suites.cpp(0): FATAL ERROR: + +Failed as expected so marking it as not failed +=============================================================================== +subcases.cpp(0): +TEST CASE: fails from an exception but gets re-entered to traverse all subcases + level zero + one + +subcases.cpp(0): ERROR: CHECK( false ) is NOT correct! + values: CHECK( false ) + +=============================================================================== +subcases.cpp(0): +TEST CASE: fails from an exception but gets re-entered to traverse all subcases + level zero + +DEEPEST SUBCASE STACK REACHED (DIFFERENT FROM THE CURRENT ONE): + level zero + one + +subcases.cpp(0): ERROR: test case THREW exception: exception thrown in subcase - will translate later when the whole test case has been exited (cannot translate while there is an active exception) + +=============================================================================== +subcases.cpp(0): +TEST CASE: fails from an exception but gets re-entered to traverse all subcases + +DEEPEST SUBCASE STACK REACHED (DIFFERENT FROM THE CURRENT ONE): + level zero + one + +subcases.cpp(0): ERROR: test case THREW exception: failure... but the show must go on! + +=============================================================================== +subcases.cpp(0): +TEST CASE: fails from an exception but gets re-entered to traverse all subcases + level zero + two + +subcases.cpp(0): ERROR: CHECK( false ) is NOT correct! + values: CHECK( false ) + +=============================================================================== +subcases.cpp(0): +TEST CASE: fails from an exception but gets re-entered to traverse all subcases + level zero + +DEEPEST SUBCASE STACK REACHED (DIFFERENT FROM THE CURRENT ONE): + level zero + two + +subcases.cpp(0): ERROR: test case THREW exception: exception thrown in subcase - will translate later when the whole test case has been exited (cannot translate while there is an active exception) + +=============================================================================== +subcases.cpp(0): +TEST CASE: fails from an exception but gets re-entered to traverse all subcases + +DEEPEST SUBCASE STACK REACHED (DIFFERENT FROM THE CURRENT ONE): + level zero + two + +subcases.cpp(0): ERROR: test case THREW exception: failure... but the show must go on! + +=============================================================================== +test_cases_and_suites.cpp(0): +DESCRIPTION: regarding failures +TEST SUITE: test suite with a description +TEST CASE: fails more times than it should + +test_cases_and_suites.cpp(0): ERROR: + +test_cases_and_suites.cpp(0): ERROR: + +Didn't fail exactly 1 times so marking it as failed! +=============================================================================== +test_cases_and_suites.cpp(0): +TEST CASE: fixtured test - not part of a test suite + +test_cases_and_suites.cpp(0): ERROR: CHECK( data == 85 ) is NOT correct! + values: CHECK( 21 == 85 ) + +=============================================================================== +header.h(0): +TEST SUITE: some TS +TEST CASE: in TS + +header.h(0): FATAL ERROR: + +=============================================================================== +logging.cpp(0): +TEST CASE: logging the counter of a loop + +logging.cpp(0): ERROR: CHECK( vec[i] != (1 << i) ) is NOT correct! + values: CHECK( 1 != 1 ) + logged: current iteration of loop: + i := 0 + +logging.cpp(0): ERROR: CHECK( vec[i] != (1 << i) ) is NOT correct! + values: CHECK( 2 != 2 ) + logged: current iteration of loop: + i := 1 + +logging.cpp(0): ERROR: CHECK( vec[i] != (1 << i) ) is NOT correct! + values: CHECK( 4 != 4 ) + logged: current iteration of loop: + i := 2 + +logging.cpp(0): ERROR: CHECK( vec[i] != (1 << i) ) is NOT correct! + values: CHECK( 8 != 8 ) + logged: current iteration of loop: + i := 3 + +logging.cpp(0): ERROR: CHECK( vec[i] != (1 << i) ) is NOT correct! + values: CHECK( 16 != 16 ) + logged: current iteration of loop: + i := 4 + + +root +1 +1.1 + +root +2 +2.1 + +root +2 +=============================================================================== +subcases.cpp(0): +TEST CASE: lots of nested subcases + +subcases.cpp(0): FATAL ERROR: + +=============================================================================== +templated_test_cases.cpp(0): +TEST CASE: multiple types + +templated_test_cases.cpp(0): ERROR: CHECK( t2 != T2() ) is NOT correct! + values: CHECK( 0 != 0 ) + +=============================================================================== +templated_test_cases.cpp(0): +TEST CASE: multiple types + +templated_test_cases.cpp(0): ERROR: CHECK( t2 != T2() ) is NOT correct! + values: CHECK( 0 != 0 ) + +=============================================================================== +templated_test_cases.cpp(0): +TEST CASE: multiple types> + +templated_test_cases.cpp(0): ERROR: CHECK( t2 != T2() ) is NOT correct! + values: CHECK( 0 != 0 ) + +=============================================================================== +stringification.cpp(0): +TEST CASE: no headers + +stringification.cpp(0): MESSAGE: 1as + +stringification.cpp(0): ERROR: CHECK( chs == nullptr ) is NOT correct! + values: CHECK( 1as == nullptr ) + +stringification.cpp(0): MESSAGE: 1as + +stringification.cpp(0): ERROR: CHECK( "1as" == nullptr ) is NOT correct! + values: CHECK( 1as == nullptr ) + +stringification.cpp(0): MESSAGE: [0, 1, 1, 2, 3, 5, 8, 13] + +stringification.cpp(0): ERROR: CHECK( ints == nullptr ) is NOT correct! + values: CHECK( [0, 1, 1, 2, 3, 5, 8, 13] == nullptr ) + +stringification.cpp(0): MESSAGE: [0, 1, 1, 2, 3, 5, 8, 13] + +stringification.cpp(0): MESSAGE: nullptr + +stringification.cpp(0): ERROR: CHECK( cnptr != nullptr ) is NOT correct! + values: CHECK( nullptr != nullptr ) + +stringification.cpp(0): MESSAGE: 0 + +stringification.cpp(0): ERROR: CHECK( A == C ) is NOT correct! + values: CHECK( 0 == 100 ) + +stringification.cpp(0): MESSAGE: int + +=============================================================================== +assertion_macros.cpp(0): +TEST CASE: normal macros + +assertion_macros.cpp(0): ERROR: CHECK( throw_if(true, std::runtime_error("whops!")) == 42 ) THREW exception: "whops!" + +assertion_macros.cpp(0): ERROR: CHECK( doctest::Approx(0.502) == 0.501 ) is NOT correct! + values: CHECK( Approx( 0.502 ) == 0.501 ) + +=============================================================================== +test_cases_and_suites.cpp(0): +TEST SUITE: ts1 +TEST CASE: normal test in a test suite from a decorator + +test_cases_and_suites.cpp(0): MESSAGE: failing because of the timeout decorator! + +Test case exceeded time limit of 0.000001! +=============================================================================== +stringification.cpp(0): +TEST CASE: operator<< + +stringification.cpp(0): MESSAGE: A + +stringification.cpp(0): MESSAGE: B + +stringification.cpp(0): MESSAGE: C + +=============================================================================== +test_cases_and_suites.cpp(0): +TEST SUITE: scoped test suite +TEST CASE: part of scoped + +test_cases_and_suites.cpp(0): FATAL ERROR: + +=============================================================================== +test_cases_and_suites.cpp(0): +TEST SUITE: scoped test suite +TEST CASE: part of scoped 2 + +test_cases_and_suites.cpp(0): FATAL ERROR: + +=============================================================================== +test_cases_and_suites.cpp(0): +TEST SUITE: some TS +TEST CASE: part of some TS + +test_cases_and_suites.cpp(0): FATAL ERROR: + + +root +outside of subcase +inside subcase 0 +outside of subcase +inside subcase 1 +outside of subcase +inside subcase 2 + +root +outside of subcase +also inside 0 +outside of subcase +also inside 1 +outside of subcase +also inside 2 + +root +outside of subcase +fail inside 0 +outside of subcase +=============================================================================== +subcases.cpp(0): +TEST CASE: reentering subcase via regular control flow + +DEEPEST SUBCASE STACK REACHED (DIFFERENT FROM THE CURRENT ONE): + +subcases.cpp(0): FATAL ERROR: 1 + + +root +outside of subcase +inside outside +nested twice 0, 0 +nested twice 0, 1 +nested twice 0, 2 +outside of subcase +inside outside +nested twice 1, 0 +nested twice 1, 1 +nested twice 1, 2 +outside of subcase +inside outside +nested twice 2, 0 +nested twice 2, 1 +nested twice 2, 2 + +root +outside of subcase +inside outside +also twice 0, 0 +also twice 0, 1 +also twice 0, 2 +outside of subcase +inside outside +also twice 1, 0 +also twice 1, 1 +also twice 1, 2 +outside of subcase +inside outside +also twice 2, 0 +also twice 2, 1 +also twice 2, 2 +=============================================================================== +test_cases_and_suites.cpp(0): +TEST CASE: should fail because of an exception + +test_cases_and_suites.cpp(0): ERROR: test case THREW exception: 0 + +=============================================================================== +assertion_macros.cpp(0): +TEST CASE: some asserts used in a function called by a test case + +assertion_macros.cpp(0): ERROR: CHECK_THROWS_WITH_AS( throw_if(true, false), "unknown exception", int ) threw a DIFFERENT exception! (contents: "unknown exception") + +=============================================================================== +subcases.cpp(0): +TEST CASE: subcases can be used in a separate function as well + from function... + +subcases.cpp(0): MESSAGE: print me twice + +=============================================================================== +subcases.cpp(0): +TEST CASE: subcases can be used in a separate function as well + from function... + sc1 + +subcases.cpp(0): MESSAGE: hello! from sc1 + +=============================================================================== +subcases.cpp(0): +TEST CASE: subcases can be used in a separate function as well + +DEEPEST SUBCASE STACK REACHED (DIFFERENT FROM THE CURRENT ONE): + from function... + sc1 + +subcases.cpp(0): MESSAGE: lala + +=============================================================================== +subcases.cpp(0): +TEST CASE: subcases can be used in a separate function as well + from function... + +subcases.cpp(0): MESSAGE: print me twice + +=============================================================================== +subcases.cpp(0): +TEST CASE: subcases can be used in a separate function as well + from function... + sc2 + +subcases.cpp(0): MESSAGE: hello! from sc2 + +=============================================================================== +subcases.cpp(0): +TEST CASE: subcases can be used in a separate function as well + +DEEPEST SUBCASE STACK REACHED (DIFFERENT FROM THE CURRENT ONE): + from function... + sc2 + +subcases.cpp(0): MESSAGE: lala + +=============================================================================== +subcases.cpp(0): +TEST CASE: subcases with changing names + outer 0 + inner 0 + +subcases.cpp(0): MESSAGE: msg! + +=============================================================================== +subcases.cpp(0): +TEST CASE: subcases with changing names + outer 0 + inner 1 + +subcases.cpp(0): MESSAGE: msg! + +=============================================================================== +subcases.cpp(0): +TEST CASE: subcases with changing names + outer 1 + inner 0 + +subcases.cpp(0): MESSAGE: msg! + +=============================================================================== +subcases.cpp(0): +TEST CASE: subcases with changing names + outer 1 + inner 1 + +subcases.cpp(0): MESSAGE: msg! + +=============================================================================== +subcases.cpp(0): +TEST CASE: subcases with changing names + separate + +subcases.cpp(0): MESSAGE: separate msg! + +=============================================================================== +header.h(0): +TEST CASE: template 1 + +header.h(0): FATAL ERROR: + +=============================================================================== +header.h(0): +TEST CASE: template 2 + +header.h(0): FATAL ERROR: + +=============================================================================== +subcases.cpp(0): +TEST CASE: test case should fail even though the last subcase passes + one + +subcases.cpp(0): ERROR: CHECK( false ) is NOT correct! + values: CHECK( false ) + +=============================================================================== +logging.cpp(0): +TEST CASE: third party asserts can report failures to doctest + +logging.cpp(0): ERROR: MY_ASSERT(false) + +logging.cpp(0): FATAL ERROR: MY_ASSERT_FATAL(false) + +=============================================================================== +test_cases_and_suites.cpp(0): +DESCRIPTION: this test has overridden its skip decorator +TEST SUITE: skipped test cases +TEST CASE: unskipped + +test_cases_and_suites.cpp(0): FATAL ERROR: + +=============================================================================== +templated_test_cases.cpp(0): +TEST CASE: vector stuff> + +templated_test_cases.cpp(0): ERROR: CHECK( vec.size() == 20 ) is NOT correct! + values: CHECK( 10 == 20 ) + +=============================================================================== +subcases.cpp(0): +TEST SUITE: with a funny name, +TEST CASE: with a funnier name\: + with the funniest name\, + +subcases.cpp(0): MESSAGE: Yes! + +=============================================================================== +subcases.cpp(0): +TEST SUITE: with a funny name, +TEST CASE: with a funnier name\: + with a slightly funny name : + +subcases.cpp(0): MESSAGE: Yep! + +=============================================================================== +subcases.cpp(0): +TEST SUITE: with a funny name, +TEST CASE: with a funnier name\: + without a funny name + +subcases.cpp(0): MESSAGE: NO! + +=============================================================================== +subcases.cpp(0): +TEST SUITE: with a funny name, +TEST CASE: without a funny name: + +subcases.cpp(0): MESSAGE: Nooo + +=============================================================================== +[doctest] test cases: 86 | 35 passed | 51 failed | +[doctest] assertions: 235 | 115 passed | 120 failed | +[doctest] Status: FAILURE! +Program code. diff --git a/dmff/dpnblist/external/doctest-2.4.11/examples/all_features/test_output/stringification.cpp.txt b/dmff/dpnblist/external/doctest-2.4.11/examples/all_features/test_output/stringification.cpp.txt new file mode 100644 index 00000000..1dc49288 --- /dev/null +++ b/dmff/dpnblist/external/doctest-2.4.11/examples/all_features/test_output/stringification.cpp.txt @@ -0,0 +1,96 @@ +[doctest] run with "--help" for options +=============================================================================== +stringification.cpp(0): +TEST CASE: operator<< + +stringification.cpp(0): MESSAGE: A + +stringification.cpp(0): MESSAGE: B + +stringification.cpp(0): MESSAGE: C + +=============================================================================== +stringification.cpp(0): +TEST CASE: no headers + +stringification.cpp(0): MESSAGE: 1as + +stringification.cpp(0): ERROR: CHECK( chs == nullptr ) is NOT correct! + values: CHECK( 1as == nullptr ) + +stringification.cpp(0): MESSAGE: 1as + +stringification.cpp(0): ERROR: CHECK( "1as" == nullptr ) is NOT correct! + values: CHECK( 1as == nullptr ) + +stringification.cpp(0): MESSAGE: [0, 1, 1, 2, 3, 5, 8, 13] + +stringification.cpp(0): ERROR: CHECK( ints == nullptr ) is NOT correct! + values: CHECK( [0, 1, 1, 2, 3, 5, 8, 13] == nullptr ) + +stringification.cpp(0): MESSAGE: [0, 1, 1, 2, 3, 5, 8, 13] + +stringification.cpp(0): MESSAGE: nullptr + +stringification.cpp(0): ERROR: CHECK( cnptr != nullptr ) is NOT correct! + values: CHECK( nullptr != nullptr ) + +stringification.cpp(0): MESSAGE: 0 + +stringification.cpp(0): ERROR: CHECK( A == C ) is NOT correct! + values: CHECK( 0 == 100 ) + +stringification.cpp(0): MESSAGE: int + +=============================================================================== +stringification.cpp(0): +TEST CASE: all asserts should fail and show how the objects get stringified + +stringification.cpp(0): MESSAGE: Foo{} + +stringification.cpp(0): ERROR: CHECK( f1 == f2 ) is NOT correct! + values: CHECK( Foo{} == Foo{} ) + +stringification.cpp(0): MESSAGE: omg + +stringification.cpp(0): ERROR: CHECK( dummy == "tralala" ) is NOT correct! + values: CHECK( omg == tralala ) + +stringification.cpp(0): ERROR: CHECK( "tralala" == dummy ) is NOT correct! + values: CHECK( tralala == omg ) + +stringification.cpp(0): MESSAGE: [1, 2, 3] + +stringification.cpp(0): ERROR: CHECK( vec1 == vec2 ) is NOT correct! + values: CHECK( [1, 2, 3] == [1, 2, 4] ) + +stringification.cpp(0): MESSAGE: [1, 42, 3] + +stringification.cpp(0): ERROR: CHECK( lst_1 == lst_2 ) is NOT correct! + values: CHECK( [1, 42, 3] == [1, 2, 666] ) + +stringification.cpp(0): ERROR: CHECK( s1 == s2 ) is NOT correct! + values: CHECK( MyOtherType: 42 == MyOtherType: 666 ) + logged: s1=MyOtherType: 42 s2=MyOtherType: 666 + +stringification.cpp(0): ERROR: CHECK( s1 == s2 ) is NOT correct! + values: CHECK( MyOtherType: 42 == MyOtherType: 666 ) + logged: s1=MyOtherType: 42 s2=MyOtherType: 666 + MyOtherType: 42 is not really MyOtherType: 666 + +stringification.cpp(0): ERROR: CHECK( "a" == doctest::Contains("aaa") ) is NOT correct! + values: CHECK( a == Contains( aaa ) ) + +stringification.cpp(0): ERROR: test case THREW exception: MyTypeInherited(5, 4) + +=============================================================================== +stringification.cpp(0): +TEST CASE: a test case that registers an exception translator for int and then throws one + +stringification.cpp(0): ERROR: test case THREW exception: 5 + +=============================================================================== +[doctest] test cases: 7 | 4 passed | 3 failed | +[doctest] assertions: 27 | 14 passed | 13 failed | +[doctest] Status: FAILURE! +Program code. diff --git a/dmff/dpnblist/external/doctest-2.4.11/examples/all_features/test_output/stringification.cpp_junit.txt b/dmff/dpnblist/external/doctest-2.4.11/examples/all_features/test_output/stringification.cpp_junit.txt new file mode 100644 index 00000000..dfa54312 --- /dev/null +++ b/dmff/dpnblist/external/doctest-2.4.11/examples/all_features/test_output/stringification.cpp_junit.txt @@ -0,0 +1,103 @@ + + + + + + + +stringification.cpp(0): +CHECK( chs == nullptr ) is NOT correct! + values: CHECK( 1as == nullptr ) + + + +stringification.cpp(0): +CHECK( "1as" == nullptr ) is NOT correct! + values: CHECK( 1as == nullptr ) + + + +stringification.cpp(0): +CHECK( ints == nullptr ) is NOT correct! + values: CHECK( [0, 1, 1, 2, 3, 5, 8, 13] == nullptr ) + + + +stringification.cpp(0): +CHECK( cnptr != nullptr ) is NOT correct! + values: CHECK( nullptr != nullptr ) + + + +stringification.cpp(0): +CHECK( A == C ) is NOT correct! + values: CHECK( 0 == 100 ) + + + + + +stringification.cpp(0): +CHECK( f1 == f2 ) is NOT correct! + values: CHECK( Foo{} == Foo{} ) + + + +stringification.cpp(0): +CHECK( dummy == "tralala" ) is NOT correct! + values: CHECK( omg == tralala ) + + + +stringification.cpp(0): +CHECK( "tralala" == dummy ) is NOT correct! + values: CHECK( tralala == omg ) + + + +stringification.cpp(0): +CHECK( vec1 == vec2 ) is NOT correct! + values: CHECK( [1, 2, 3] == [1, 2, 4] ) + + + +stringification.cpp(0): +CHECK( lst_1 == lst_2 ) is NOT correct! + values: CHECK( [1, 42, 3] == [1, 2, 666] ) + + + +stringification.cpp(0): +CHECK( s1 == s2 ) is NOT correct! + values: CHECK( MyOtherType: 42 == MyOtherType: 666 ) + logged: s1=MyOtherType: 42 s2=MyOtherType: 666 + + + +stringification.cpp(0): +CHECK( s1 == s2 ) is NOT correct! + values: CHECK( MyOtherType: 42 == MyOtherType: 666 ) + logged: s1=MyOtherType: 42 s2=MyOtherType: 666 + MyOtherType: 42 is not really MyOtherType: 666 + + + +stringification.cpp(0): +CHECK( "a" == doctest::Contains("aaa") ) is NOT correct! + values: CHECK( a == Contains( aaa ) ) + + + + MyTypeInherited<int>(5, 4) + + + + + 5 + + + + + + +Program code. diff --git a/dmff/dpnblist/external/doctest-2.4.11/examples/all_features/test_output/stringification.cpp_xml.txt b/dmff/dpnblist/external/doctest-2.4.11/examples/all_features/test_output/stringification.cpp_xml.txt new file mode 100644 index 00000000..c90acf53 --- /dev/null +++ b/dmff/dpnblist/external/doctest-2.4.11/examples/all_features/test_output/stringification.cpp_xml.txt @@ -0,0 +1,219 @@ + + + + + + + + + + + A + + + + + B + + + + + C + + + + + + + + 1as + + + + + chs == nullptr + + + 1as == nullptr + + + + + 1as + + + + + "1as" == nullptr + + + 1as == nullptr + + + + + [0, 1, 1, 2, 3, 5, 8, 13] + + + + + ints == nullptr + + + [0, 1, 1, 2, 3, 5, 8, 13] == nullptr + + + + + [0, 1, 1, 2, 3, 5, 8, 13] + + + + + nullptr + + + + + cnptr != nullptr + + + nullptr != nullptr + + + + + 0 + + + + + A == C + + + 0 == 100 + + + + + int + + + + + + + + Foo{} + + + + + f1 == f2 + + + Foo{} == Foo{} + + + + + omg + + + + + dummy == "tralala" + + + omg == tralala + + + + + "tralala" == dummy + + + tralala == omg + + + + + [1, 2, 3] + + + + + vec1 == vec2 + + + [1, 2, 3] == [1, 2, 4] + + + + + [1, 42, 3] + + + + + lst_1 == lst_2 + + + [1, 42, 3] == [1, 2, 666] + + + + + s1 == s2 + + + MyOtherType: 42 == MyOtherType: 666 + + + s1=MyOtherType: 42 s2=MyOtherType: 666 + + + + + s1 == s2 + + + MyOtherType: 42 == MyOtherType: 666 + + + s1=MyOtherType: 42 s2=MyOtherType: 666 + + + MyOtherType: 42 is not really MyOtherType: 666 + + + + + "a" == doctest::Contains("aaa") + + + a == Contains( aaa ) + + + + MyTypeInherited<int>(5, 4) + + + + + + 5 + + + + + + + + + + + + + +Program code. diff --git a/dmff/dpnblist/external/doctest-2.4.11/examples/all_features/test_output/subcases.cpp.txt b/dmff/dpnblist/external/doctest-2.4.11/examples/all_features/test_output/subcases.cpp.txt new file mode 100644 index 00000000..8ce6f4e7 --- /dev/null +++ b/dmff/dpnblist/external/doctest-2.4.11/examples/all_features/test_output/subcases.cpp.txt @@ -0,0 +1,294 @@ +[doctest] run with "--help" for options + +root +1 +1.1 + +root +2 +2.1 + +root +2 +=============================================================================== +subcases.cpp(0): +TEST CASE: lots of nested subcases + +subcases.cpp(0): FATAL ERROR: + + +root +outside of subcase +inside subcase 0 +outside of subcase +inside subcase 1 +outside of subcase +inside subcase 2 + +root +outside of subcase +also inside 0 +outside of subcase +also inside 1 +outside of subcase +also inside 2 + +root +outside of subcase +fail inside 0 +outside of subcase +=============================================================================== +subcases.cpp(0): +TEST CASE: reentering subcase via regular control flow + +DEEPEST SUBCASE STACK REACHED (DIFFERENT FROM THE CURRENT ONE): + +subcases.cpp(0): FATAL ERROR: 1 + + +root +outside of subcase +inside outside +nested twice 0, 0 +nested twice 0, 1 +nested twice 0, 2 +outside of subcase +inside outside +nested twice 1, 0 +nested twice 1, 1 +nested twice 1, 2 +outside of subcase +inside outside +nested twice 2, 0 +nested twice 2, 1 +nested twice 2, 2 + +root +outside of subcase +inside outside +also twice 0, 0 +also twice 0, 1 +also twice 0, 2 +outside of subcase +inside outside +also twice 1, 0 +also twice 1, 1 +also twice 1, 2 +outside of subcase +inside outside +also twice 2, 0 +also twice 2, 1 +also twice 2, 2 +=============================================================================== +subcases.cpp(0): +TEST CASE: subcases can be used in a separate function as well + from function... + +subcases.cpp(0): MESSAGE: print me twice + +=============================================================================== +subcases.cpp(0): +TEST CASE: subcases can be used in a separate function as well + from function... + sc1 + +subcases.cpp(0): MESSAGE: hello! from sc1 + +=============================================================================== +subcases.cpp(0): +TEST CASE: subcases can be used in a separate function as well + +DEEPEST SUBCASE STACK REACHED (DIFFERENT FROM THE CURRENT ONE): + from function... + sc1 + +subcases.cpp(0): MESSAGE: lala + +=============================================================================== +subcases.cpp(0): +TEST CASE: subcases can be used in a separate function as well + from function... + +subcases.cpp(0): MESSAGE: print me twice + +=============================================================================== +subcases.cpp(0): +TEST CASE: subcases can be used in a separate function as well + from function... + sc2 + +subcases.cpp(0): MESSAGE: hello! from sc2 + +=============================================================================== +subcases.cpp(0): +TEST CASE: subcases can be used in a separate function as well + +DEEPEST SUBCASE STACK REACHED (DIFFERENT FROM THE CURRENT ONE): + from function... + sc2 + +subcases.cpp(0): MESSAGE: lala + +=============================================================================== +subcases.cpp(0): + Scenario: vectors can be sized and resized + Given: A vector with some items + When: the size is increased + Then: the size and capacity change + +subcases.cpp(0): ERROR: CHECK( v.size() == 20 ) is NOT correct! + values: CHECK( 10 == 20 ) + +=============================================================================== +subcases.cpp(0): + Scenario: vectors can be sized and resized + Given: A vector with some items + When: less capacity is reserved + Then: neither size nor capacity are changed + +subcases.cpp(0): ERROR: CHECK( v.size() == 10 ) is NOT correct! + values: CHECK( 5 == 10 ) + +=============================================================================== +subcases.cpp(0): +TEST CASE: test case should fail even though the last subcase passes + one + +subcases.cpp(0): ERROR: CHECK( false ) is NOT correct! + values: CHECK( false ) + +=============================================================================== +subcases.cpp(0): +TEST CASE: fails from an exception but gets re-entered to traverse all subcases + level zero + one + +subcases.cpp(0): ERROR: CHECK( false ) is NOT correct! + values: CHECK( false ) + +=============================================================================== +subcases.cpp(0): +TEST CASE: fails from an exception but gets re-entered to traverse all subcases + level zero + +DEEPEST SUBCASE STACK REACHED (DIFFERENT FROM THE CURRENT ONE): + level zero + one + +subcases.cpp(0): ERROR: test case THREW exception: exception thrown in subcase - will translate later when the whole test case has been exited (cannot translate while there is an active exception) + +=============================================================================== +subcases.cpp(0): +TEST CASE: fails from an exception but gets re-entered to traverse all subcases + +DEEPEST SUBCASE STACK REACHED (DIFFERENT FROM THE CURRENT ONE): + level zero + one + +subcases.cpp(0): ERROR: test case THREW exception: failure... but the show must go on! + +=============================================================================== +subcases.cpp(0): +TEST CASE: fails from an exception but gets re-entered to traverse all subcases + level zero + two + +subcases.cpp(0): ERROR: CHECK( false ) is NOT correct! + values: CHECK( false ) + +=============================================================================== +subcases.cpp(0): +TEST CASE: fails from an exception but gets re-entered to traverse all subcases + level zero + +DEEPEST SUBCASE STACK REACHED (DIFFERENT FROM THE CURRENT ONE): + level zero + two + +subcases.cpp(0): ERROR: test case THREW exception: exception thrown in subcase - will translate later when the whole test case has been exited (cannot translate while there is an active exception) + +=============================================================================== +subcases.cpp(0): +TEST CASE: fails from an exception but gets re-entered to traverse all subcases + +DEEPEST SUBCASE STACK REACHED (DIFFERENT FROM THE CURRENT ONE): + level zero + two + +subcases.cpp(0): ERROR: test case THREW exception: failure... but the show must go on! + +=============================================================================== +subcases.cpp(0): +TEST CASE: subcases with changing names + outer 0 + inner 0 + +subcases.cpp(0): MESSAGE: msg! + +=============================================================================== +subcases.cpp(0): +TEST CASE: subcases with changing names + outer 0 + inner 1 + +subcases.cpp(0): MESSAGE: msg! + +=============================================================================== +subcases.cpp(0): +TEST CASE: subcases with changing names + outer 1 + inner 0 + +subcases.cpp(0): MESSAGE: msg! + +=============================================================================== +subcases.cpp(0): +TEST CASE: subcases with changing names + outer 1 + inner 1 + +subcases.cpp(0): MESSAGE: msg! + +=============================================================================== +subcases.cpp(0): +TEST CASE: subcases with changing names + separate + +subcases.cpp(0): MESSAGE: separate msg! + +=============================================================================== +subcases.cpp(0): +TEST SUITE: with a funny name, +TEST CASE: with a funnier name\: + with the funniest name\, + +subcases.cpp(0): MESSAGE: Yes! + +=============================================================================== +subcases.cpp(0): +TEST SUITE: with a funny name, +TEST CASE: with a funnier name\: + with a slightly funny name : + +subcases.cpp(0): MESSAGE: Yep! + +=============================================================================== +subcases.cpp(0): +TEST SUITE: with a funny name, +TEST CASE: with a funnier name\: + without a funny name + +subcases.cpp(0): MESSAGE: NO! + +=============================================================================== +subcases.cpp(0): +TEST SUITE: with a funny name, +TEST CASE: without a funny name: + +subcases.cpp(0): MESSAGE: Nooo + +=============================================================================== +[doctest] test cases: 10 | 5 passed | 5 failed | +[doctest] assertions: 26 | 19 passed | 7 failed | +[doctest] Status: FAILURE! +Program code. diff --git a/dmff/dpnblist/external/doctest-2.4.11/examples/all_features/test_output/subcases.cpp_junit.txt b/dmff/dpnblist/external/doctest-2.4.11/examples/all_features/test_output/subcases.cpp_junit.txt new file mode 100644 index 00000000..5fd733e8 --- /dev/null +++ b/dmff/dpnblist/external/doctest-2.4.11/examples/all_features/test_output/subcases.cpp_junit.txt @@ -0,0 +1,162 @@ + + +root +1 +1.1 + +root +2 +2.1 + +root +2 + +root +outside of subcase +inside subcase 0 +outside of subcase +inside subcase 1 +outside of subcase +inside subcase 2 + +root +outside of subcase +also inside 0 +outside of subcase +also inside 1 +outside of subcase +also inside 2 + +root +outside of subcase +fail inside 0 +outside of subcase + +root +outside of subcase +inside outside +nested twice 0, 0 +nested twice 0, 1 +nested twice 0, 2 +outside of subcase +inside outside +nested twice 1, 0 +nested twice 1, 1 +nested twice 1, 2 +outside of subcase +inside outside +nested twice 2, 0 +nested twice 2, 1 +nested twice 2, 2 + +root +outside of subcase +inside outside +also twice 0, 0 +also twice 0, 1 +also twice 0, 2 +outside of subcase +inside outside +also twice 1, 0 +also twice 1, 1 +also twice 1, 2 +outside of subcase +inside outside +also twice 2, 0 +also twice 2, 1 +also twice 2, 2 + + + + + + +subcases.cpp(0): + + + + + + + + +subcases.cpp(0): +1 + + + + + + + + + +subcases.cpp(0): +CHECK( v.size() == 20 ) is NOT correct! + values: CHECK( 10 == 20 ) + + + + + + + +subcases.cpp(0): +CHECK( v.size() == 10 ) is NOT correct! + values: CHECK( 5 == 10 ) + + + + + +subcases.cpp(0): +CHECK( false ) is NOT correct! + values: CHECK( false ) + + + + + + +subcases.cpp(0): +CHECK( false ) is NOT correct! + values: CHECK( false ) + + + + exception thrown in subcase - will translate later when the whole test case has been exited (cannot translate while there is an active exception) + + + failure... but the show must go on! + + + + +subcases.cpp(0): +CHECK( false ) is NOT correct! + values: CHECK( false ) + + + + exception thrown in subcase - will translate later when the whole test case has been exited (cannot translate while there is an active exception) + + + failure... but the show must go on! + + + + + + + + + + + + + + + + + +Program code. diff --git a/dmff/dpnblist/external/doctest-2.4.11/examples/all_features/test_output/subcases.cpp_xml.txt b/dmff/dpnblist/external/doctest-2.4.11/examples/all_features/test_output/subcases.cpp_xml.txt new file mode 100644 index 00000000..465fcd0f --- /dev/null +++ b/dmff/dpnblist/external/doctest-2.4.11/examples/all_features/test_output/subcases.cpp_xml.txt @@ -0,0 +1,402 @@ + + + + + + +root + +1 + +1.1 + + + +root + +2 + +2.1 + + + +root + +2 + + + + + + + + + + +root +outside of subcase + +inside subcase 0 + +outside of subcase + +inside subcase 1 + +outside of subcase + +inside subcase 2 + + +root +outside of subcase + +also inside 0 + +outside of subcase + +also inside 1 + +outside of subcase + +also inside 2 + + +root +outside of subcase + +fail inside 0 + +outside of subcase + + + + 1 + + + + +root +outside of subcase + +inside outside + +nested twice 0, 0 + + +nested twice 0, 1 + + +nested twice 0, 2 + + +outside of subcase + +inside outside + +nested twice 1, 0 + + +nested twice 1, 1 + + +nested twice 1, 2 + + +outside of subcase + +inside outside + +nested twice 2, 0 + + +nested twice 2, 1 + + +nested twice 2, 2 + + + +root +outside of subcase + +inside outside + +also twice 0, 0 + + +also twice 0, 1 + + +also twice 0, 2 + + +outside of subcase + +inside outside + +also twice 1, 0 + + +also twice 1, 1 + + +also twice 1, 2 + + +outside of subcase + +inside outside + +also twice 2, 0 + + +also twice 2, 1 + + +also twice 2, 2 + + + + + + + + + print me twice + + + + + + hello! from sc1 + + + + + + + lala + + + + + + print me twice + + + + + + hello! from sc2 + + + + + + + lala + + + + + + + + + + + v.size() == 20 + + + 10 == 20 + + + + + + + + + + + + + + + + + + + + + + + v.size() == 10 + + + 5 == 10 + + + + + + + + + + + + false + + + false + + + + + + + + + + + + + false + + + false + + + + + exception thrown in subcase - will translate later when the whole test case has been exited (cannot translate while there is an active exception) + + + + failure... but the show must go on! + + + + + + false + + + false + + + + + exception thrown in subcase - will translate later when the whole test case has been exited (cannot translate while there is an active exception) + + + + failure... but the show must go on! + + + + + + + + + + + + + + + + + + + + + + + + + + + + msg! + + + + + + + + + msg! + + + + + + + + + msg! + + + + + + + + + msg! + + + + + + + + separate msg! + + + + + + + + + + + + Yes! + + + + + + + Yep! + + + + + + + NO! + + + + + + + + + Nooo + + + + + + + + +Program code. diff --git a/dmff/dpnblist/external/doctest-2.4.11/examples/all_features/test_output/templated_test_cases.cpp.txt b/dmff/dpnblist/external/doctest-2.4.11/examples/all_features/test_output/templated_test_cases.cpp.txt new file mode 100644 index 00000000..d4296938 --- /dev/null +++ b/dmff/dpnblist/external/doctest-2.4.11/examples/all_features/test_output/templated_test_cases.cpp.txt @@ -0,0 +1,41 @@ +[doctest] run with "--help" for options +=============================================================================== +templated_test_cases.cpp(0): +TEST CASE: vector stuff> + +templated_test_cases.cpp(0): ERROR: CHECK( vec.size() == 20 ) is NOT correct! + values: CHECK( 10 == 20 ) + +=============================================================================== +templated_test_cases.cpp(0): +TEST CASE: multiple types + +templated_test_cases.cpp(0): ERROR: CHECK( t2 != T2() ) is NOT correct! + values: CHECK( 0 != 0 ) + +=============================================================================== +templated_test_cases.cpp(0): +TEST CASE: multiple types + +templated_test_cases.cpp(0): ERROR: CHECK( t2 != T2() ) is NOT correct! + values: CHECK( 0 != 0 ) + +=============================================================================== +templated_test_cases.cpp(0): +TEST CASE: multiple types> + +templated_test_cases.cpp(0): ERROR: CHECK( t2 != T2() ) is NOT correct! + values: CHECK( 0 != 0 ) + +=============================================================================== +templated_test_cases.cpp(0): +TEST CASE: bad stringification of type pair + +templated_test_cases.cpp(0): ERROR: CHECK( t2 != T2() ) is NOT correct! + values: CHECK( 0 != 0 ) + +=============================================================================== +[doctest] test cases: 15 | 10 passed | 5 failed | +[doctest] assertions: 19 | 14 passed | 5 failed | +[doctest] Status: FAILURE! +Program code. diff --git a/dmff/dpnblist/external/doctest-2.4.11/examples/all_features/test_output/templated_test_cases.cpp_junit.txt b/dmff/dpnblist/external/doctest-2.4.11/examples/all_features/test_output/templated_test_cases.cpp_junit.txt new file mode 100644 index 00000000..2c9d17de --- /dev/null +++ b/dmff/dpnblist/external/doctest-2.4.11/examples/all_features/test_output/templated_test_cases.cpp_junit.txt @@ -0,0 +1,56 @@ + + + + + + + + +templated_test_cases.cpp(0): +CHECK( vec.size() == 20 ) is NOT correct! + values: CHECK( 10 == 20 ) + + + + + + + + + + + + +templated_test_cases.cpp(0): +CHECK( t2 != T2() ) is NOT correct! + values: CHECK( 0 != 0 ) + + + + + +templated_test_cases.cpp(0): +CHECK( t2 != T2() ) is NOT correct! + values: CHECK( 0 != 0 ) + + + + + +templated_test_cases.cpp(0): +CHECK( t2 != T2() ) is NOT correct! + values: CHECK( 0 != 0 ) + + + + + +templated_test_cases.cpp(0): +CHECK( t2 != T2() ) is NOT correct! + values: CHECK( 0 != 0 ) + + + + + +Program code. diff --git a/dmff/dpnblist/external/doctest-2.4.11/examples/all_features/test_output/templated_test_cases.cpp_xml.txt b/dmff/dpnblist/external/doctest-2.4.11/examples/all_features/test_output/templated_test_cases.cpp_xml.txt new file mode 100644 index 00000000..2b43e30e --- /dev/null +++ b/dmff/dpnblist/external/doctest-2.4.11/examples/all_features/test_output/templated_test_cases.cpp_xml.txt @@ -0,0 +1,94 @@ + + + + + + + + + + + + + + + + + vec.size() == 20 + + + 10 == 20 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + t2 != T2() + + + 0 != 0 + + + + + + + + t2 != T2() + + + 0 != 0 + + + + + + + + t2 != T2() + + + 0 != 0 + + + + + + + + t2 != T2() + + + 0 != 0 + + + + + + + + +Program code. diff --git a/dmff/dpnblist/external/doctest-2.4.11/examples/all_features/test_output/test_cases_and_suites.cpp.txt b/dmff/dpnblist/external/doctest-2.4.11/examples/all_features/test_output/test_cases_and_suites.cpp.txt new file mode 100644 index 00000000..64815f66 --- /dev/null +++ b/dmff/dpnblist/external/doctest-2.4.11/examples/all_features/test_output/test_cases_and_suites.cpp.txt @@ -0,0 +1,101 @@ +[doctest] run with "--help" for options +=============================================================================== +test_cases_and_suites.cpp(0): +TEST CASE: should fail because of an exception + +test_cases_and_suites.cpp(0): ERROR: test case THREW exception: 0 + +=============================================================================== +test_cases_and_suites.cpp(0): +TEST SUITE: scoped test suite +TEST CASE: part of scoped + +test_cases_and_suites.cpp(0): FATAL ERROR: + +=============================================================================== +test_cases_and_suites.cpp(0): +TEST SUITE: scoped test suite +TEST CASE: part of scoped 2 + +test_cases_and_suites.cpp(0): FATAL ERROR: + +=============================================================================== +test_cases_and_suites.cpp(0): +TEST SUITE: some TS +TEST CASE: part of some TS + +test_cases_and_suites.cpp(0): FATAL ERROR: + +=============================================================================== +test_cases_and_suites.cpp(0): +TEST CASE: fixtured test - not part of a test suite + +test_cases_and_suites.cpp(0): ERROR: CHECK( data == 85 ) is NOT correct! + values: CHECK( 21 == 85 ) + +=============================================================================== +test_cases_and_suites.cpp(0): +TEST SUITE: ts1 +TEST CASE: normal test in a test suite from a decorator + +test_cases_and_suites.cpp(0): MESSAGE: failing because of the timeout decorator! + +Test case exceeded time limit of 0.000001! +=============================================================================== +test_cases_and_suites.cpp(0): +DESCRIPTION: this test has overridden its skip decorator +TEST SUITE: skipped test cases +TEST CASE: unskipped + +test_cases_and_suites.cpp(0): FATAL ERROR: + +=============================================================================== +test_cases_and_suites.cpp(0): +DESCRIPTION: regarding failures +TEST SUITE: test suite with a description +TEST CASE: fails - and its allowed + +test_cases_and_suites.cpp(0): FATAL ERROR: + +Allowed to fail so marking it as not failed +=============================================================================== +test_cases_and_suites.cpp(0): +DESCRIPTION: regarding failures +TEST SUITE: test suite with a description +TEST CASE: fails as it should + +test_cases_and_suites.cpp(0): FATAL ERROR: + +Failed as expected so marking it as not failed +=============================================================================== +test_cases_and_suites.cpp(0): +DESCRIPTION: regarding failures +TEST SUITE: test suite with a description +TEST CASE: doesn't fail but it should have + +Should have failed but didn't! Marking it as failed! +=============================================================================== +test_cases_and_suites.cpp(0): +DESCRIPTION: regarding failures +TEST SUITE: test suite with a description +TEST CASE: fails 1 time as it should + +test_cases_and_suites.cpp(0): FATAL ERROR: + +Failed exactly 1 times as expected so marking it as not failed! +=============================================================================== +test_cases_and_suites.cpp(0): +DESCRIPTION: regarding failures +TEST SUITE: test suite with a description +TEST CASE: fails more times than it should + +test_cases_and_suites.cpp(0): ERROR: + +test_cases_and_suites.cpp(0): ERROR: + +Didn't fail exactly 1 times so marking it as failed! +=============================================================================== +[doctest] test cases: 15 | 6 passed | 9 failed | +[doctest] assertions: 12 | 1 passed | 11 failed | +[doctest] Status: FAILURE! +Program code. diff --git a/dmff/dpnblist/external/doctest-2.4.11/examples/all_features/test_output/test_cases_and_suites.cpp_junit.txt b/dmff/dpnblist/external/doctest-2.4.11/examples/all_features/test_output/test_cases_and_suites.cpp_junit.txt new file mode 100644 index 00000000..14733b6a --- /dev/null +++ b/dmff/dpnblist/external/doctest-2.4.11/examples/all_features/test_output/test_cases_and_suites.cpp_junit.txt @@ -0,0 +1,91 @@ + + + + + + + 0 + + + + +test_cases_and_suites.cpp(0): + + + + + + +test_cases_and_suites.cpp(0): + + + + + + +test_cases_and_suites.cpp(0): + + + + + + +test_cases_and_suites.cpp(0): +CHECK( data == 85 ) is NOT correct! + values: CHECK( 21 == 85 ) + + + + + + +test_cases_and_suites.cpp(0): + + + + + + +test_cases_and_suites.cpp(0): + + + + + + + +test_cases_and_suites.cpp(0): + + + + + + + +test_cases_and_suites.cpp(0): + + + + + + +test_cases_and_suites.cpp(0): + + + + +test_cases_and_suites.cpp(0): + + + + + + +test_cases_and_suites.cpp(0): + + + + + + +Program code. diff --git a/dmff/dpnblist/external/doctest-2.4.11/examples/all_features/test_output/test_cases_and_suites.cpp_xml.txt b/dmff/dpnblist/external/doctest-2.4.11/examples/all_features/test_output/test_cases_and_suites.cpp_xml.txt new file mode 100644 index 00000000..6fc245aa --- /dev/null +++ b/dmff/dpnblist/external/doctest-2.4.11/examples/all_features/test_output/test_cases_and_suites.cpp_xml.txt @@ -0,0 +1,114 @@ + + + + + + + + + + 0 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + data == 85 + + + 21 == 85 + + + + + + + + + + failing because of the timeout decorator! + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +Program code. diff --git a/dmff/dpnblist/external/doctest-2.4.11/examples/all_features/test_output/version.txt b/dmff/dpnblist/external/doctest-2.4.11/examples/all_features/test_output/version.txt new file mode 100644 index 00000000..df227f98 --- /dev/null +++ b/dmff/dpnblist/external/doctest-2.4.11/examples/all_features/test_output/version.txt @@ -0,0 +1 @@ +[doctest] doctest version is "2.4.11" diff --git a/dmff/dpnblist/external/doctest-2.4.11/examples/all_features/test_output/version_junit.txt b/dmff/dpnblist/external/doctest-2.4.11/examples/all_features/test_output/version_junit.txt new file mode 100644 index 00000000..12bbf745 --- /dev/null +++ b/dmff/dpnblist/external/doctest-2.4.11/examples/all_features/test_output/version_junit.txt @@ -0,0 +1 @@ + diff --git a/dmff/dpnblist/external/doctest-2.4.11/examples/all_features/test_output/version_xml.txt b/dmff/dpnblist/external/doctest-2.4.11/examples/all_features/test_output/version_xml.txt new file mode 100644 index 00000000..28598e93 --- /dev/null +++ b/dmff/dpnblist/external/doctest-2.4.11/examples/all_features/test_output/version_xml.txt @@ -0,0 +1,4 @@ + + + + diff --git a/dmff/dpnblist/external/doctest-2.4.11/examples/combining_the_same_tests_built_differently_in_multiple_shared_objects/CMakeLists.txt b/dmff/dpnblist/external/doctest-2.4.11/examples/combining_the_same_tests_built_differently_in_multiple_shared_objects/CMakeLists.txt new file mode 100644 index 00000000..45014fa6 --- /dev/null +++ b/dmff/dpnblist/external/doctest-2.4.11/examples/combining_the_same_tests_built_differently_in_multiple_shared_objects/CMakeLists.txt @@ -0,0 +1,63 @@ +# for more information about this example refer to the GitHub issue: https://github.com/doctest/doctest/issues/436 + +# create the test runner, to which all other targets will link to +add_library(test_runner SHARED test_runner.cpp) +target_link_libraries(test_runner PUBLIC doctest) + +add_library(default SHARED default.cpp) +target_link_libraries(default PUBLIC doctest test_runner) +set_target_properties(default PROPERTIES CXX_VISIBILITY_PRESET hidden) + +add_library(return42 SHARED return42.cpp) +target_link_libraries(return42 PUBLIC doctest test_runner) +set_target_properties(return42 PROPERTIES CXX_VISIBILITY_PRESET hidden) + +add_executable(same_tests_multiple_configurations main.cpp) +target_link_libraries(same_tests_multiple_configurations PUBLIC default return42 doctest test_runner) + +# the output on a GitHub Actions Windows build with cl.exe when printing __FILE__ in the fileOrderComparator is the following: +# +# ..\examples\combining_the_same_tests_built_differently_in_multiple_shared_objects\test_runner.cpp +# ..\examples\combining_the_same_tests_built_differently_in_multiple_shared_objects\main.cpp +# ..\examples\combining_the_same_tests_built_differently_in_multiple_shared_objects\main.cpp +# ..\examples\combining_the_same_tests_built_differently_in_multiple_shared_objects\test_runner.cpp +# ..\examples\combining_the_same_tests_built_differently_in_multiple_shared_objects\main.cpp +# d:\a\doctest\doctest\examples\combining_the_same_tests_built_differently_in_multiple_shared_objects\foo.h +# ..\examples\combining_the_same_tests_built_differently_in_multiple_shared_objects\main.cpp +# d:\a\doctest\doctest\examples\combining_the_same_tests_built_differently_in_multiple_shared_objects\foo.h +# ..\examples\combining_the_same_tests_built_differently_in_multiple_shared_objects\main.cpp +# d:\a\doctest\doctest\examples\combining_the_same_tests_built_differently_in_multiple_shared_objects\foo.h +# +# and the output from cl.exe on AppVeyor or on my local Windows setup is the following: +# +# C:\projects\doctest\examples\combining_the_same_tests_built_differently_in_multiple_shared_objects\test_runner.cpp +# C:\projects\doctest\examples\combining_the_same_tests_built_differently_in_multiple_shared_objects\main.cpp +# C:\projects\doctest\examples\combining_the_same_tests_built_differently_in_multiple_shared_objects\main.cpp +# c:\projects\doctest\examples\combining_the_same_tests_built_differently_in_multiple_shared_objects\foo.h +# c:\projects\doctest\examples\combining_the_same_tests_built_differently_in_multiple_shared_objects\foo.h +# C:\projects\doctest\examples\combining_the_same_tests_built_differently_in_multiple_shared_objects\test_runner.cpp +# c:\projects\doctest\examples\combining_the_same_tests_built_differently_in_multiple_shared_objects\foo.h +# C:\projects\doctest\examples\combining_the_same_tests_built_differently_in_multiple_shared_objects\main.cpp +# c:\projects\doctest\examples\combining_the_same_tests_built_differently_in_multiple_shared_objects\foo.h +# c:\projects\doctest\examples\combining_the_same_tests_built_differently_in_multiple_shared_objects\foo.h +# c:\projects\doctest\examples\combining_the_same_tests_built_differently_in_multiple_shared_objects\foo.h +# C:\projects\doctest\examples\combining_the_same_tests_built_differently_in_multiple_shared_objects\test_runner.cpp +# c:\projects\doctest\examples\combining_the_same_tests_built_differently_in_multiple_shared_objects\foo.h +# C:\projects\doctest\examples\combining_the_same_tests_built_differently_in_multiple_shared_objects\main.cpp +# c:\projects\doctest\examples\combining_the_same_tests_built_differently_in_multiple_shared_objects\foo.h +# c:\projects\doctest\examples\combining_the_same_tests_built_differently_in_multiple_shared_objects\foo.h +# c:\projects\doctest\examples\combining_the_same_tests_built_differently_in_multiple_shared_objects\foo.h +# C:\projects\doctest\examples\combining_the_same_tests_built_differently_in_multiple_shared_objects\test_runner.cpp +# c:\projects\doctest\examples\combining_the_same_tests_built_differently_in_multiple_shared_objects\foo.h +# C:\projects\doctest\examples\combining_the_same_tests_built_differently_in_multiple_shared_objects\main.cpp +# c:\projects\doctest\examples\combining_the_same_tests_built_differently_in_multiple_shared_objects\foo.h +# c:\projects\doctest\examples\combining_the_same_tests_built_differently_in_multiple_shared_objects\foo.h +# +# as you can see on GitHub Actions we get a full path for the header and a relative for the sources and +# regardless of case sensitivity (for which there is a difference in fileOrderComparator) we will always +# get a different sorting of the test cases and thus we need NO_OUTPUT on this test so that the CI passes +# +# otherwise the output from test_runner.cpp and main.cpp gets reordered before/after the output from the header +# TODO: maybe we should simply remove the output from those 2 .cpp files? then there won't be a problem... +# +doctest_add_test(NO_OUTPUT NAME same_tests_multiple_configurations COMMAND $ --no-version) diff --git a/dmff/dpnblist/external/doctest-2.4.11/examples/combining_the_same_tests_built_differently_in_multiple_shared_objects/default.cpp b/dmff/dpnblist/external/doctest-2.4.11/examples/combining_the_same_tests_built_differently_in_multiple_shared_objects/default.cpp new file mode 100644 index 00000000..44641198 --- /dev/null +++ b/dmff/dpnblist/external/doctest-2.4.11/examples/combining_the_same_tests_built_differently_in_multiple_shared_objects/default.cpp @@ -0,0 +1,6 @@ +#define DOCTEST_CONFIG_IMPLEMENTATION_IN_DLL +#include "doctest/doctest.h" + +#include "foo.h" + +DOCTEST_SYMBOL_EXPORT void default_cpp_force_link() {} diff --git a/dmff/dpnblist/external/doctest-2.4.11/examples/combining_the_same_tests_built_differently_in_multiple_shared_objects/foo.h b/dmff/dpnblist/external/doctest-2.4.11/examples/combining_the_same_tests_built_differently_in_multiple_shared_objects/foo.h new file mode 100644 index 00000000..3a5c40c5 --- /dev/null +++ b/dmff/dpnblist/external/doctest-2.4.11/examples/combining_the_same_tests_built_differently_in_multiple_shared_objects/foo.h @@ -0,0 +1,41 @@ +#pragma once +#include "doctest/doctest.h" +#include + +DOCTEST_CLANG_SUPPRESS_WARNING("-Wmissing-prototypes") +DOCTEST_GCC_SUPPRESS_WARNING("-Wmissing-declarations") + +#ifdef RETURN_42 +#define TEST_LABEL "[return42] " +#else +#define TEST_LABEL "[default] " +#endif + +inline int bar() { +#ifdef RETURN_42 + return 42; +#else + return 11; +#endif +} + +#ifdef DOCTEST_LIBRARY_INCLUDED + +#ifdef RETURN_42 +TEST_CASE(TEST_LABEL "bartest"){ + INFO("Running " TEST_LABEL "bartest"); MESSAGE(""); + CHECK_EQ(42, bar()); +} +#endif + +#ifndef RETURN_42 +TEST_CASE(TEST_LABEL "bartest"){ + INFO("Running " TEST_LABEL "bartest"); MESSAGE(""); + CHECK_EQ(11, bar()); +} +#endif + +TEST_CASE(TEST_LABEL "commontest"){ + INFO("Running " TEST_LABEL "commontest"); MESSAGE(""); +} +#endif // DOCTEST_LIBRARY_INCLUDED diff --git a/dmff/dpnblist/external/doctest-2.4.11/examples/combining_the_same_tests_built_differently_in_multiple_shared_objects/main.cpp b/dmff/dpnblist/external/doctest-2.4.11/examples/combining_the_same_tests_built_differently_in_multiple_shared_objects/main.cpp new file mode 100644 index 00000000..948a981b --- /dev/null +++ b/dmff/dpnblist/external/doctest-2.4.11/examples/combining_the_same_tests_built_differently_in_multiple_shared_objects/main.cpp @@ -0,0 +1,24 @@ +#define DOCTEST_CONFIG_IMPLEMENTATION_IN_DLL +#include "doctest/doctest.h" + +DOCTEST_SYMBOL_IMPORT void default_cpp_force_link(); +DOCTEST_SYMBOL_IMPORT void return42_cpp_force_link(); + +TEST_CASE("main") { MESSAGE("hello from "); } + +int main(int argc, char** argv) { + + default_cpp_force_link(); + return42_cpp_force_link(); + + doctest::Context context(argc, argv); + int res = context.run(); + + if(context.shouldExit()) // important - query flags (and --exit) rely on the user doing this + return res; // propagate the result of the tests + + int client_stuff_return_code = 0; + // your program - if the testing framework is integrated in your production code + + return res + client_stuff_return_code; // the result from doctest is propagated here as well +} diff --git a/dmff/dpnblist/external/doctest-2.4.11/examples/combining_the_same_tests_built_differently_in_multiple_shared_objects/return42.cpp b/dmff/dpnblist/external/doctest-2.4.11/examples/combining_the_same_tests_built_differently_in_multiple_shared_objects/return42.cpp new file mode 100644 index 00000000..63dfb876 --- /dev/null +++ b/dmff/dpnblist/external/doctest-2.4.11/examples/combining_the_same_tests_built_differently_in_multiple_shared_objects/return42.cpp @@ -0,0 +1,7 @@ +#define DOCTEST_CONFIG_IMPLEMENTATION_IN_DLL +#include "doctest/doctest.h" + +#define RETURN_42 +#include "foo.h" + +DOCTEST_SYMBOL_EXPORT void return42_cpp_force_link() {} diff --git a/dmff/dpnblist/external/doctest-2.4.11/examples/combining_the_same_tests_built_differently_in_multiple_shared_objects/test_output/same_tests_multiple_configurations.txt b/dmff/dpnblist/external/doctest-2.4.11/examples/combining_the_same_tests_built_differently_in_multiple_shared_objects/test_output/same_tests_multiple_configurations.txt new file mode 100644 index 00000000..34099eda --- /dev/null +++ b/dmff/dpnblist/external/doctest-2.4.11/examples/combining_the_same_tests_built_differently_in_multiple_shared_objects/test_output/same_tests_multiple_configurations.txt @@ -0,0 +1,45 @@ +[doctest] run with "--help" for options +=============================================================================== +foo.h(0): +TEST CASE: [return42] bartest + +foo.h(0): MESSAGE: + logged: Running [return42] bartest + +=============================================================================== +foo.h(0): +TEST CASE: [default] bartest + +foo.h(0): MESSAGE: + logged: Running [default] bartest + +=============================================================================== +foo.h(0): +TEST CASE: [default] commontest + +foo.h(0): MESSAGE: + logged: Running [default] commontest + +=============================================================================== +foo.h(0): +TEST CASE: [return42] commontest + +foo.h(0): MESSAGE: + logged: Running [return42] commontest + +=============================================================================== +main.cpp(0): +TEST CASE: main + +main.cpp(0): MESSAGE: hello from + +=============================================================================== +test_runner.cpp(0): +TEST CASE: test_runner + +test_runner.cpp(0): MESSAGE: hello from + +=============================================================================== +[doctest] test cases: 6 | 6 passed | 0 failed | 0 skipped +[doctest] assertions: 2 | 2 passed | 0 failed | +[doctest] Status: SUCCESS! diff --git a/dmff/dpnblist/external/doctest-2.4.11/examples/combining_the_same_tests_built_differently_in_multiple_shared_objects/test_output/same_tests_multiple_configurations_junit.txt b/dmff/dpnblist/external/doctest-2.4.11/examples/combining_the_same_tests_built_differently_in_multiple_shared_objects/test_output/same_tests_multiple_configurations_junit.txt new file mode 100644 index 00000000..55f969a2 --- /dev/null +++ b/dmff/dpnblist/external/doctest-2.4.11/examples/combining_the_same_tests_built_differently_in_multiple_shared_objects/test_output/same_tests_multiple_configurations_junit.txt @@ -0,0 +1,11 @@ + + + + + + + + + + + diff --git a/dmff/dpnblist/external/doctest-2.4.11/examples/combining_the_same_tests_built_differently_in_multiple_shared_objects/test_output/same_tests_multiple_configurations_xml.txt b/dmff/dpnblist/external/doctest-2.4.11/examples/combining_the_same_tests_built_differently_in_multiple_shared_objects/test_output/same_tests_multiple_configurations_xml.txt new file mode 100644 index 00000000..3e4e90d1 --- /dev/null +++ b/dmff/dpnblist/external/doctest-2.4.11/examples/combining_the_same_tests_built_differently_in_multiple_shared_objects/test_output/same_tests_multiple_configurations_xml.txt @@ -0,0 +1,60 @@ + + + + + + + + + Running [return42] bartest + + + + + + + + + Running [default] bartest + + + + + + + + + Running [default] commontest + + + + + + + + + Running [return42] commontest + + + + + + + + hello from <main.cpp> + + + + + + + + hello from <test_runner.cpp> + + + + + + + + diff --git a/dmff/dpnblist/external/doctest-2.4.11/examples/combining_the_same_tests_built_differently_in_multiple_shared_objects/test_runner.cpp b/dmff/dpnblist/external/doctest-2.4.11/examples/combining_the_same_tests_built_differently_in_multiple_shared_objects/test_runner.cpp new file mode 100644 index 00000000..8d9be99e --- /dev/null +++ b/dmff/dpnblist/external/doctest-2.4.11/examples/combining_the_same_tests_built_differently_in_multiple_shared_objects/test_runner.cpp @@ -0,0 +1,5 @@ +#define DOCTEST_CONFIG_IMPLEMENTATION_IN_DLL +#define DOCTEST_CONFIG_IMPLEMENT +#include "doctest/doctest.h" + +TEST_CASE("test_runner") { MESSAGE("hello from "); } diff --git a/dmff/dpnblist/external/doctest-2.4.11/examples/exe_with_static_libs/CMakeLists.txt b/dmff/dpnblist/external/doctest-2.4.11/examples/exe_with_static_libs/CMakeLists.txt new file mode 100644 index 00000000..c89621de --- /dev/null +++ b/dmff/dpnblist/external/doctest-2.4.11/examples/exe_with_static_libs/CMakeLists.txt @@ -0,0 +1,27 @@ +# create object libraries instead of static libraries +add_library(lib_1 OBJECT lib_1_src1.cpp lib_1_src2.cpp) +add_library(lib_2 OBJECT lib_2_src.cpp) +add_executable(exe_with_static_libs main.cpp $ $) +target_link_libraries(exe_with_static_libs doctest) + +# object libraries cannot "link" to any target so this is how we get the INTERFACE include directories of the doctest target +get_property(doctest_include_dir TARGET doctest PROPERTY INTERFACE_INCLUDE_DIRECTORIES) +target_include_directories(lib_1 PRIVATE ${doctest_include_dir}) +target_include_directories(lib_2 PRIVATE ${doctest_include_dir}) + +# alternatively we could create static libraries and use "doctest_force_link_static_lib_in_target" +#add_library(lib_1 STATIC lib_1_src1.cpp lib_1_src2.cpp) +#add_library(lib_2 STATIC lib_2_src.cpp) +#add_executable(exe_with_static_libs main.cpp) +#target_link_libraries(exe_with_static_libs lib_1) +#target_link_libraries(exe_with_static_libs lib_2) +#include(doctest_force_link_static_lib_in_target.cmake) +#doctest_force_link_static_lib_in_target(exe_with_static_libs lib_1) +#doctest_force_link_static_lib_in_target(exe_with_static_libs lib_2) + +# group them together in a single folder inside IDEs +set_target_properties(lib_1 PROPERTIES FOLDER exe_with_static_libs) +set_target_properties(lib_2 PROPERTIES FOLDER exe_with_static_libs) +set_target_properties(exe_with_static_libs PROPERTIES FOLDER exe_with_static_libs) + +doctest_add_test(NAME exe_with_static_libs COMMAND $ --no-version) diff --git a/dmff/dpnblist/external/doctest-2.4.11/examples/exe_with_static_libs/doctest_force_link_static_lib_in_target.cmake b/dmff/dpnblist/external/doctest-2.4.11/examples/exe_with_static_libs/doctest_force_link_static_lib_in_target.cmake new file mode 100644 index 00000000..8b696e36 --- /dev/null +++ b/dmff/dpnblist/external/doctest-2.4.11/examples/exe_with_static_libs/doctest_force_link_static_lib_in_target.cmake @@ -0,0 +1,131 @@ +if(doctest_force_link_static_lib_in_target_included) + return() +endif() +set(doctest_force_link_static_lib_in_target_included true) + +cmake_minimum_required(VERSION 3.0) + +# includes the file to the source with compiler flags +function(doctest_include_file_in_sources header sources) + foreach(src ${sources}) + if(${src} MATCHES \\.\(cc|cp|cpp|CPP|c\\+\\+|cxx\)$) + # get old flags + get_source_file_property(old_compile_flags ${src} COMPILE_FLAGS) + if(old_compile_flags STREQUAL "NOTFOUND") + set(old_compile_flags "") + endif() + + # update flags + if(MSVC) + set_source_files_properties(${src} PROPERTIES COMPILE_FLAGS + "${old_compile_flags} /FI\"${header}\"") + else() + set_source_files_properties(${src} PROPERTIES COMPILE_FLAGS + "${old_compile_flags} -include \"${header}\"") + endif() + endif() + endforeach() +endfunction() + +# this is the magic function - forces every object file from the library to be linked into the target (dll or executable) +# it doesn't work in 2 scenarios: +# - either the target or the library uses a precompiled header - see the end of this issue for details: https://github.com/doctest/doctest/issues/21 +# - either the target or the library is an imported target (pre-built) and not built within the current cmake tree +# Alternatives: +# - use CMake object libraries instead of static libraries - >> THIS IS ACTUALLY PREFERRED << to all this CMake trickery +# - checkout these 2 repositories: +# - https://github.com/pthom/cmake_registertest +# - https://github.com/pthom/doctest_registerlibrary +function(doctest_force_link_static_lib_in_target target lib) + # check if the library has generated dummy headers + get_target_property(DDH ${lib} DOCTEST_DUMMY_HEADER) + get_target_property(LIB_NAME ${lib} NAME) + if(${DDH} STREQUAL "DDH-NOTFOUND") + # figure out the paths and names of the dummy headers - should be in the build folder for the target + set(BD ${CMAKE_CURRENT_BINARY_DIR}) + if(NOT CMAKE_VERSION VERSION_LESS 3.4) + get_target_property(BD ${lib} BINARY_DIR) # 'BINARY_DIR' target property unsupported before CMake 3.4 ... + endif() + set(dummy_dir ${BD}/${LIB_NAME}_DOCTEST_STATIC_LIB_FORCE_LINK_DUMMIES/) + set(dummy_header ${dummy_dir}/all_dummies.h) + file(MAKE_DIRECTORY ${dummy_dir}) + + # create a dummy header for each source file, include a dummy function in it and include it in the source file + set(curr_dummy "0") + set(DLL_PRIVATE "#ifndef _WIN32\n#define DLL_PRIVATE __attribute__ ((visibility (\"hidden\")))\n#else\n#define DLL_PRIVATE\n#endif\n\n") + get_target_property(lib_sources ${lib} SOURCES) + foreach(src ${lib_sources}) + if(${src} MATCHES \\.\(cc|cp|cpp|CPP|c\\+\\+|cxx\)$) + math(EXPR curr_dummy "${curr_dummy} + 1") + + set(curr_dummy_header ${dummy_dir}/dummy_${curr_dummy}.h) + file(WRITE ${curr_dummy_header} "${DLL_PRIVATE}namespace doctest { namespace detail { DLL_PRIVATE int dummy_for_${LIB_NAME}_${curr_dummy}(); DLL_PRIVATE int dummy_for_${LIB_NAME}_${curr_dummy}() { return ${curr_dummy}; } } }\n") + doctest_include_file_in_sources(${curr_dummy_header} ${src}) + endif() + endforeach() + set(total_dummies ${curr_dummy}) + + # create the master dummy header + file(WRITE ${dummy_header} "${DLL_PRIVATE}namespace doctest { namespace detail {\n\n") + + # forward declare the dummy functions in the master dummy header + foreach(curr_dummy RANGE 1 ${total_dummies}) + file(APPEND ${dummy_header} "DLL_PRIVATE int dummy_for_${LIB_NAME}_${curr_dummy}();\n") + endforeach() + + # call the dummy functions in the master dummy header + file(APPEND ${dummy_header} "\nDLL_PRIVATE int dummies_for_${LIB_NAME}();\nDLL_PRIVATE int dummies_for_${LIB_NAME}() {\n int res = 0;\n") + foreach(curr_dummy RANGE 1 ${total_dummies}) + file(APPEND ${dummy_header} " res += dummy_for_${LIB_NAME}_${curr_dummy}();\n") + endforeach() + file(APPEND ${dummy_header} " return res;\n}\n\n} } // namespaces\n") + + # set the dummy header property so we don't recreate the dummy headers the next time this macro is called for this library + set_target_properties(${lib} PROPERTIES DOCTEST_DUMMY_HEADER ${dummy_header}) + set(DDH ${dummy_header}) + endif() + + get_target_property(DFLLTD ${target} DOCTEST_FORCE_LINKED_LIBRARIES_THROUGH_DUMMIES) + get_target_property(target_sources ${target} SOURCES) + + if("${DFLLTD}" STREQUAL "DFLLTD-NOTFOUND") + # if no library has been force linked to this target + foreach(src ${target_sources}) + if(${src} MATCHES \\.\(cc|cp|cpp|CPP|c\\+\\+|cxx\)$) + doctest_include_file_in_sources(${DDH} ${src}) + break() + endif() + endforeach() + + # add the library as force linked to this target + set_target_properties(${target} PROPERTIES DOCTEST_FORCE_LINKED_LIBRARIES_THROUGH_DUMMIES ${LIB_NAME}) + else() + # if this particular library hasn't been force linked to this target + list(FIND DFLLTD ${LIB_NAME} lib_forced_in_target) + if(${lib_forced_in_target} EQUAL -1) + foreach(src ${target_sources}) + if(${src} MATCHES \\.\(cc|cp|cpp|CPP|c\\+\\+|cxx\)$) + doctest_include_file_in_sources(${DDH} ${src}) + break() + endif() + endforeach() + + # add this library to the list of force linked libraries for this target + list(APPEND DFLLTD ${LIB_NAME}) + set_target_properties(${target} PROPERTIES DOCTEST_FORCE_LINKED_LIBRARIES_THROUGH_DUMMIES "${DFLLTD}") + else() + message(AUTHOR_WARNING "LIBRARY \"${lib}\" ALREADY FORCE-LINKED TO TARGET \"${target}\"!") + endif() + endif() +endfunction() + +# a utility function to create an executable for a static library with tests - as requested by https://github.com/pthom +function(doctest_make_exe_for_static_lib exe_name lib_name) + set(exe_dir ${CMAKE_CURRENT_BINARY_DIR}/${exe_name}_generated_sources) + file(MAKE_DIRECTORY ${exe_dir}) + file(WRITE ${exe_dir}/main.cpp "#define DOCTEST_CONFIG_IMPLEMENT_WITH_MAIN\n#include \"doctest.h\"\n") + add_executable(${exe_name} ${exe_dir}/main.cpp) + target_link_libraries(${exe_name} ${lib_name}) + doctest_force_link_static_lib_in_target(${exe_name} ${lib_name}) + add_test(NAME ${exe_name} COMMAND $) +endfunction() diff --git a/dmff/dpnblist/external/doctest-2.4.11/examples/exe_with_static_libs/lib_1_src1.cpp b/dmff/dpnblist/external/doctest-2.4.11/examples/exe_with_static_libs/lib_1_src1.cpp new file mode 100644 index 00000000..125496cb --- /dev/null +++ b/dmff/dpnblist/external/doctest-2.4.11/examples/exe_with_static_libs/lib_1_src1.cpp @@ -0,0 +1,6 @@ +#include +DOCTEST_MAKE_STD_HEADERS_CLEAN_FROM_WARNINGS_ON_WALL_BEGIN +#include +DOCTEST_MAKE_STD_HEADERS_CLEAN_FROM_WARNINGS_ON_WALL_END + +TEST_CASE("asd") { std::cout << "hello from " << std::endl; } diff --git a/dmff/dpnblist/external/doctest-2.4.11/examples/exe_with_static_libs/lib_1_src2.cpp b/dmff/dpnblist/external/doctest-2.4.11/examples/exe_with_static_libs/lib_1_src2.cpp new file mode 100644 index 00000000..d0fc3904 --- /dev/null +++ b/dmff/dpnblist/external/doctest-2.4.11/examples/exe_with_static_libs/lib_1_src2.cpp @@ -0,0 +1,6 @@ +#include +DOCTEST_MAKE_STD_HEADERS_CLEAN_FROM_WARNINGS_ON_WALL_BEGIN +#include +DOCTEST_MAKE_STD_HEADERS_CLEAN_FROM_WARNINGS_ON_WALL_END + +TEST_CASE("asd") { std::cout << "hello from " << std::endl; } diff --git a/dmff/dpnblist/external/doctest-2.4.11/examples/exe_with_static_libs/lib_2_src.cpp b/dmff/dpnblist/external/doctest-2.4.11/examples/exe_with_static_libs/lib_2_src.cpp new file mode 100644 index 00000000..3a842f94 --- /dev/null +++ b/dmff/dpnblist/external/doctest-2.4.11/examples/exe_with_static_libs/lib_2_src.cpp @@ -0,0 +1,6 @@ +#include +DOCTEST_MAKE_STD_HEADERS_CLEAN_FROM_WARNINGS_ON_WALL_BEGIN +#include +DOCTEST_MAKE_STD_HEADERS_CLEAN_FROM_WARNINGS_ON_WALL_END + +TEST_CASE("asd") { std::cout << "hello from " << std::endl; } diff --git a/dmff/dpnblist/external/doctest-2.4.11/examples/exe_with_static_libs/main.cpp b/dmff/dpnblist/external/doctest-2.4.11/examples/exe_with_static_libs/main.cpp new file mode 100644 index 00000000..5542f57d --- /dev/null +++ b/dmff/dpnblist/external/doctest-2.4.11/examples/exe_with_static_libs/main.cpp @@ -0,0 +1,4 @@ +#define DOCTEST_CONFIG_IMPLEMENT_WITH_MAIN +#include + +TEST_CASE("main") { std::cout << "hello from " << std::endl; } diff --git a/dmff/dpnblist/external/doctest-2.4.11/examples/exe_with_static_libs/test_output/exe_with_static_libs.txt b/dmff/dpnblist/external/doctest-2.4.11/examples/exe_with_static_libs/test_output/exe_with_static_libs.txt new file mode 100644 index 00000000..5167ef05 --- /dev/null +++ b/dmff/dpnblist/external/doctest-2.4.11/examples/exe_with_static_libs/test_output/exe_with_static_libs.txt @@ -0,0 +1,9 @@ +[doctest] run with "--help" for options +hello from +hello from +hello from +hello from +=============================================================================== +[doctest] test cases: 4 | 4 passed | 0 failed | 0 skipped +[doctest] assertions: 0 | 0 passed | 0 failed | +[doctest] Status: SUCCESS! diff --git a/dmff/dpnblist/external/doctest-2.4.11/examples/exe_with_static_libs/test_output/exe_with_static_libs_junit.txt b/dmff/dpnblist/external/doctest-2.4.11/examples/exe_with_static_libs/test_output/exe_with_static_libs_junit.txt new file mode 100644 index 00000000..bfc12388 --- /dev/null +++ b/dmff/dpnblist/external/doctest-2.4.11/examples/exe_with_static_libs/test_output/exe_with_static_libs_junit.txt @@ -0,0 +1,13 @@ + +hello from +hello from +hello from +hello from + + + + + + + + diff --git a/dmff/dpnblist/external/doctest-2.4.11/examples/exe_with_static_libs/test_output/exe_with_static_libs_xml.txt b/dmff/dpnblist/external/doctest-2.4.11/examples/exe_with_static_libs/test_output/exe_with_static_libs_xml.txt new file mode 100644 index 00000000..7a4e53e6 --- /dev/null +++ b/dmff/dpnblist/external/doctest-2.4.11/examples/exe_with_static_libs/test_output/exe_with_static_libs_xml.txt @@ -0,0 +1,24 @@ + + + + + +hello from + + + +hello from + + + +hello from + + + +hello from + + + + + + diff --git a/dmff/dpnblist/external/doctest-2.4.11/examples/executable_dll_and_plugin/CMakeLists.txt b/dmff/dpnblist/external/doctest-2.4.11/examples/executable_dll_and_plugin/CMakeLists.txt new file mode 100644 index 00000000..31b5ed2f --- /dev/null +++ b/dmff/dpnblist/external/doctest-2.4.11/examples/executable_dll_and_plugin/CMakeLists.txt @@ -0,0 +1,27 @@ +add_library(implementation SHARED implementation.cpp implementation_2.cpp) +target_link_libraries(implementation PUBLIC doctest) + +add_library(dll SHARED dll.cpp) +target_link_libraries(dll implementation) + +add_library(plugin SHARED plugin.cpp) +target_link_libraries(plugin implementation) + +add_executable(executable_dll_and_plugin main.cpp) +target_link_libraries(executable_dll_and_plugin dll) +target_link_libraries(executable_dll_and_plugin implementation) + +if(NOT WIN32) + target_link_libraries(executable_dll_and_plugin dl) +endif() + +# have the executable depend on the plugin so it gets built as well when building/starting only the executable +add_dependencies(executable_dll_and_plugin plugin) + +# group them together in a single folder inside IDEs +set_target_properties(implementation PROPERTIES FOLDER executable_dll_and_plugin) +set_target_properties(dll PROPERTIES FOLDER executable_dll_and_plugin) +set_target_properties(plugin PROPERTIES FOLDER executable_dll_and_plugin) +set_target_properties(executable_dll_and_plugin PROPERTIES FOLDER executable_dll_and_plugin) + +doctest_add_test(NAME executable_dll_and_plugin COMMAND $ --no-version) diff --git a/dmff/dpnblist/external/doctest-2.4.11/examples/executable_dll_and_plugin/dll.cpp b/dmff/dpnblist/external/doctest-2.4.11/examples/executable_dll_and_plugin/dll.cpp new file mode 100644 index 00000000..b436e8fa --- /dev/null +++ b/dmff/dpnblist/external/doctest-2.4.11/examples/executable_dll_and_plugin/dll.cpp @@ -0,0 +1,14 @@ +#define DOCTEST_CONFIG_IMPLEMENTATION_IN_DLL +#include + +DOCTEST_MAKE_STD_HEADERS_CLEAN_FROM_WARNINGS_ON_WALL_BEGIN +#include +DOCTEST_MAKE_STD_HEADERS_CLEAN_FROM_WARNINGS_ON_WALL_END + +TEST_CASE("dll") { + std::cout << "I am a test from the dll!\n"; + CHECK(true); +} + +DOCTEST_SYMBOL_EXPORT void from_dll(); // to silence "-Wmissing-declarations" with GCC +DOCTEST_SYMBOL_EXPORT void from_dll() {} // force the creation of a .lib file with MSVC diff --git a/dmff/dpnblist/external/doctest-2.4.11/examples/executable_dll_and_plugin/implementation.cpp b/dmff/dpnblist/external/doctest-2.4.11/examples/executable_dll_and_plugin/implementation.cpp new file mode 100644 index 00000000..07ba854a --- /dev/null +++ b/dmff/dpnblist/external/doctest-2.4.11/examples/executable_dll_and_plugin/implementation.cpp @@ -0,0 +1,11 @@ +#define DOCTEST_CONFIG_IMPLEMENTATION_IN_DLL +#define DOCTEST_CONFIG_IMPLEMENT +#include + +DOCTEST_MAKE_STD_HEADERS_CLEAN_FROM_WARNINGS_ON_WALL_BEGIN +#include +DOCTEST_MAKE_STD_HEADERS_CLEAN_FROM_WARNINGS_ON_WALL_END + +TEST_CASE("implementation") { + std::cout << "I am a test from the implementation!" << std::endl; +} diff --git a/dmff/dpnblist/external/doctest-2.4.11/examples/executable_dll_and_plugin/implementation_2.cpp b/dmff/dpnblist/external/doctest-2.4.11/examples/executable_dll_and_plugin/implementation_2.cpp new file mode 100644 index 00000000..ddd45c80 --- /dev/null +++ b/dmff/dpnblist/external/doctest-2.4.11/examples/executable_dll_and_plugin/implementation_2.cpp @@ -0,0 +1,10 @@ +// note that DOCTEST_CONFIG_IMPLEMENTATION_IN_DLL should not be defined here +#include + +DOCTEST_MAKE_STD_HEADERS_CLEAN_FROM_WARNINGS_ON_WALL_BEGIN +#include +DOCTEST_MAKE_STD_HEADERS_CLEAN_FROM_WARNINGS_ON_WALL_END + +TEST_CASE("implementation_2") { + std::cout << "I am a test from the implementation_2!" << std::endl; +} diff --git a/dmff/dpnblist/external/doctest-2.4.11/examples/executable_dll_and_plugin/main.cpp b/dmff/dpnblist/external/doctest-2.4.11/examples/executable_dll_and_plugin/main.cpp new file mode 100644 index 00000000..cd2e2d7e --- /dev/null +++ b/dmff/dpnblist/external/doctest-2.4.11/examples/executable_dll_and_plugin/main.cpp @@ -0,0 +1,67 @@ +#define DOCTEST_CONFIG_IMPLEMENTATION_IN_DLL +#include + +DOCTEST_MAKE_STD_HEADERS_CLEAN_FROM_WARNINGS_ON_WALL_BEGIN +#include +DOCTEST_MAKE_STD_HEADERS_CLEAN_FROM_WARNINGS_ON_WALL_END + +template +static int conditional_throw(bool in, const T& ex) { + if(in) +#ifndef DOCTEST_CONFIG_NO_EXCEPTIONS + throw ex; // NOLINT +#else // DOCTEST_CONFIG_NO_EXCEPTIONS + ((void)ex); +#endif // DOCTEST_CONFIG_NO_EXCEPTIONS + return 42; +} + +TEST_CASE("executable") { + std::cout << "I am a test from the executable!" << std::endl; + conditional_throw(true, 'a'); +} + +#ifdef _WIN32 +#define WIN32_LEAN_AND_MEAN +DOCTEST_MAKE_STD_HEADERS_CLEAN_FROM_WARNINGS_ON_WALL_BEGIN +DOCTEST_CLANG_SUPPRESS_WARNING("-Wnonportable-system-include-path") +#include +DOCTEST_MAKE_STD_HEADERS_CLEAN_FROM_WARNINGS_ON_WALL_END +#ifdef _MSC_VER +#define LoadDynamicLib(lib) LoadLibrary(lib ".dll") +#else // _MSC_VER +#define LoadDynamicLib(lib) LoadLibrary("lib" lib ".dll") +#endif // _MSC_VER +#else // _WIN32 +#include +#ifdef __APPLE__ +#define LoadDynamicLib(lib) dlopen("lib" lib ".dylib", RTLD_NOW) +#else // __APPLE__ +#define LoadDynamicLib(lib) dlopen("lib" lib ".so", RTLD_NOW) +#endif // __APPLE__ +#endif // _WIN32 + +// set an exception translator for double +REGISTER_EXCEPTION_TRANSLATOR(double& e) { + return doctest::String("double: ") + doctest::toString(e); +} + +DOCTEST_SYMBOL_IMPORT void from_dll(); + +int main(int argc, char** argv) { + // force the use of a symbol from the dll so tests from it get registered + from_dll(); + + LoadDynamicLib("plugin"); // load the plugin so tests from it get registered + + doctest::Context context(argc, argv); + int res = context.run(); + + if(context.shouldExit()) // important - query flags (and --exit) rely on the user doing this + return res; // propagate the result of the tests + + int client_stuff_return_code = 0; + // your program - if the testing framework is integrated in your production code + + return res + client_stuff_return_code; // the result from doctest is propagated here as well +} diff --git a/dmff/dpnblist/external/doctest-2.4.11/examples/executable_dll_and_plugin/plugin.cpp b/dmff/dpnblist/external/doctest-2.4.11/examples/executable_dll_and_plugin/plugin.cpp new file mode 100644 index 00000000..dba953f6 --- /dev/null +++ b/dmff/dpnblist/external/doctest-2.4.11/examples/executable_dll_and_plugin/plugin.cpp @@ -0,0 +1,23 @@ +#define DOCTEST_CONFIG_IMPLEMENTATION_IN_DLL +#include + +DOCTEST_MAKE_STD_HEADERS_CLEAN_FROM_WARNINGS_ON_WALL_BEGIN +#include +DOCTEST_MAKE_STD_HEADERS_CLEAN_FROM_WARNINGS_ON_WALL_END + +// most of these are used here just to test that they compile successfully from within a plugin +TEST_SUITE("some test suite") { + TEST_CASE("test case in a plugin") { + SUBCASE("some subcase") { + INFO("some info"); + MESSAGE("triggering the INFO above to be printed"); + CHECK(1 == 2); + FAIL("certain death!"); + } + } +} + +// set an exception translator for char +REGISTER_EXCEPTION_TRANSLATOR(char& e) { + return doctest::String("char: ") + doctest::toString(e); +} diff --git a/dmff/dpnblist/external/doctest-2.4.11/examples/executable_dll_and_plugin/test_output/executable_dll_and_plugin.txt b/dmff/dpnblist/external/doctest-2.4.11/examples/executable_dll_and_plugin/test_output/executable_dll_and_plugin.txt new file mode 100644 index 00000000..bc674380 --- /dev/null +++ b/dmff/dpnblist/external/doctest-2.4.11/examples/executable_dll_and_plugin/test_output/executable_dll_and_plugin.txt @@ -0,0 +1,31 @@ +[doctest] run with "--help" for options +I am a test from the dll! +I am a test from the implementation! +I am a test from the implementation_2! +I am a test from the executable! +=============================================================================== +main.cpp(0): +TEST CASE: executable + +main.cpp(0): ERROR: test case THREW exception: char: 97 + +=============================================================================== +plugin.cpp(0): +TEST SUITE: some test suite +TEST CASE: test case in a plugin + some subcase + +plugin.cpp(0): MESSAGE: triggering the INFO above to be printed + logged: some info + +plugin.cpp(0): ERROR: CHECK( 1 == 2 ) is NOT correct! + values: CHECK( 1 == 2 ) + logged: some info + +plugin.cpp(0): FATAL ERROR: certain death! + logged: some info + +=============================================================================== +[doctest] test cases: 5 | 3 passed | 2 failed | 0 skipped +[doctest] assertions: 3 | 1 passed | 2 failed | +[doctest] Status: FAILURE! diff --git a/dmff/dpnblist/external/doctest-2.4.11/examples/executable_dll_and_plugin/test_output/executable_dll_and_plugin_junit.txt b/dmff/dpnblist/external/doctest-2.4.11/examples/executable_dll_and_plugin/test_output/executable_dll_and_plugin_junit.txt new file mode 100644 index 00000000..ed43dca0 --- /dev/null +++ b/dmff/dpnblist/external/doctest-2.4.11/examples/executable_dll_and_plugin/test_output/executable_dll_and_plugin_junit.txt @@ -0,0 +1,32 @@ + +I am a test from the dll! +I am a test from the implementation! +I am a test from the implementation_2! +I am a test from the executable! + + + + + + + + char: 97 + + + + +plugin.cpp(0): +CHECK( 1 == 2 ) is NOT correct! + values: CHECK( 1 == 2 ) + logged: some info + + + +plugin.cpp(0): +certain death! + logged: some info + + + + + diff --git a/dmff/dpnblist/external/doctest-2.4.11/examples/executable_dll_and_plugin/test_output/executable_dll_and_plugin_xml.txt b/dmff/dpnblist/external/doctest-2.4.11/examples/executable_dll_and_plugin/test_output/executable_dll_and_plugin_xml.txt new file mode 100644 index 00000000..b300e78c --- /dev/null +++ b/dmff/dpnblist/external/doctest-2.4.11/examples/executable_dll_and_plugin/test_output/executable_dll_and_plugin_xml.txt @@ -0,0 +1,61 @@ + + + + + +I am a test from the dll! + + + +I am a test from the implementation! + + + +I am a test from the implementation_2! + + + +I am a test from the executable! + + char: 97 + + + + + + + + + + triggering the INFO above to be printed + + + some info + + + + + 1 == 2 + + + 1 == 2 + + + some info + + + + + certain death! + + + some info + + + + + + + + + diff --git a/dmff/dpnblist/external/doctest-2.4.11/examples/installed_doctest_cmake/dll/CMakeLists.txt b/dmff/dpnblist/external/doctest-2.4.11/examples/installed_doctest_cmake/dll/CMakeLists.txt new file mode 100644 index 00000000..3fd9325c --- /dev/null +++ b/dmff/dpnblist/external/doctest-2.4.11/examples/installed_doctest_cmake/dll/CMakeLists.txt @@ -0,0 +1,14 @@ +cmake_minimum_required(VERSION 3.0) + +project(example_dll VERSION 0.0.1 LANGUAGES CXX) + +find_package(doctest REQUIRED) + +add_library("dll" SHARED dll.cpp) +target_compile_features("dll" PRIVATE cxx_std_17) +target_compile_definitions("dll" PUBLIC -D_EXPORT) +target_link_libraries("dll" doctest::doctest) + +add_executable(${PROJECT_NAME} main.cpp) +target_compile_features(${PROJECT_NAME} PRIVATE cxx_std_17) +target_link_libraries(${PROJECT_NAME} dll) \ No newline at end of file diff --git a/dmff/dpnblist/external/doctest-2.4.11/examples/installed_doctest_cmake/dll/dll.cpp b/dmff/dpnblist/external/doctest-2.4.11/examples/installed_doctest_cmake/dll/dll.cpp new file mode 100644 index 00000000..83b79a0f --- /dev/null +++ b/dmff/dpnblist/external/doctest-2.4.11/examples/installed_doctest_cmake/dll/dll.cpp @@ -0,0 +1,22 @@ +#define DOCTEST_CONFIG_IMPLEMENTATION_IN_DLL +#define DOCTEST_CONFIG_IMPLEMENT +#include + +#include "dll.h" +#include + +extern "C" { + void say_hello_dll() { printf("%s", "Hello, World!\n"); } +} + +int factorial(int number) { + return number < 1 ? 1 : number <= 1 ? number : factorial(number - 1) * number; +} + +TEST_CASE("testing the factorial function") { + CHECK(factorial(0) == 1); + CHECK(factorial(1) == 1); + CHECK(factorial(2) == 2); + CHECK(factorial(3) == 6); + CHECK(factorial(10) == 3628800); +} \ No newline at end of file diff --git a/dmff/dpnblist/external/doctest-2.4.11/examples/installed_doctest_cmake/dll/dll.h b/dmff/dpnblist/external/doctest-2.4.11/examples/installed_doctest_cmake/dll/dll.h new file mode 100644 index 00000000..4d089853 --- /dev/null +++ b/dmff/dpnblist/external/doctest-2.4.11/examples/installed_doctest_cmake/dll/dll.h @@ -0,0 +1,7 @@ +#pragma once + +#include "exporting.h" + +extern "C" { + DLL_API void say_hello_dll(); +} \ No newline at end of file diff --git a/dmff/dpnblist/external/doctest-2.4.11/examples/installed_doctest_cmake/dll/exporting.h b/dmff/dpnblist/external/doctest-2.4.11/examples/installed_doctest_cmake/dll/exporting.h new file mode 100644 index 00000000..a0f624be --- /dev/null +++ b/dmff/dpnblist/external/doctest-2.4.11/examples/installed_doctest_cmake/dll/exporting.h @@ -0,0 +1,15 @@ +#pragma once + +#ifdef _EXPORT +#ifdef _MSC_VER +#define DLL_API __declspec(dllexport) +#elif defined __GNUC__ +#define DLL_API __attribute__((visibility("default"))) +#endif +#else +#ifdef _MSC_VER +#define DLL_API __declspec(dllimport) +#elif defined __GNUC__ +#define DLL_API __attribute__((visibility("hidden"))) +#endif +#endif \ No newline at end of file diff --git a/dmff/dpnblist/external/doctest-2.4.11/examples/installed_doctest_cmake/dll/main.cpp b/dmff/dpnblist/external/doctest-2.4.11/examples/installed_doctest_cmake/dll/main.cpp new file mode 100644 index 00000000..7c6d0f91 --- /dev/null +++ b/dmff/dpnblist/external/doctest-2.4.11/examples/installed_doctest_cmake/dll/main.cpp @@ -0,0 +1,34 @@ +#define DOCTEST_CONFIG_IMPLEMENTATION_IN_DLL +#include + +#include "dll.h" + +int main(int argc, char **argv) { + doctest::Context context; + context.applyCommandLine(argc, argv); + + int res = context.run(); // run doctest + + // important - query flags (and --exit) rely on the user doing this + if (context.shouldExit()) { + // propagate the result of the tests + return res; + } + + say_hello_dll(); // test dll func +} + +int square(const int number) { return number * number; } + +TEST_CASE("testing the square function") { + CHECK(square(2) == 4); + CHECK(square(4) == 16); + CHECK(square(5) == 25); + CHECK(square(8) == 64); +} + +// running notes +// ./example_dll --no-run (run normal program) +// ./example_dll --exit (run tests then exit) +// ./example_dll (run tests then run program) +// ./example_dll --success (print successful test casts) \ No newline at end of file diff --git a/dmff/dpnblist/external/doctest-2.4.11/examples/installed_doctest_cmake/executable/CMakeLists.txt b/dmff/dpnblist/external/doctest-2.4.11/examples/installed_doctest_cmake/executable/CMakeLists.txt new file mode 100644 index 00000000..a3c6d8da --- /dev/null +++ b/dmff/dpnblist/external/doctest-2.4.11/examples/installed_doctest_cmake/executable/CMakeLists.txt @@ -0,0 +1,9 @@ +cmake_minimum_required(VERSION 3.0) + +project(example_exe VERSION 0.0.1 LANGUAGES CXX) + +find_package(doctest REQUIRED) + +add_executable(${PROJECT_NAME} main.cpp) +target_compile_features(${PROJECT_NAME} PRIVATE cxx_std_17) +target_link_libraries(${PROJECT_NAME} PRIVATE doctest::doctest) diff --git a/dmff/dpnblist/external/doctest-2.4.11/examples/installed_doctest_cmake/executable/main.cpp b/dmff/dpnblist/external/doctest-2.4.11/examples/installed_doctest_cmake/executable/main.cpp new file mode 100644 index 00000000..2c9e856f --- /dev/null +++ b/dmff/dpnblist/external/doctest-2.4.11/examples/installed_doctest_cmake/executable/main.cpp @@ -0,0 +1,35 @@ +#define DOCTEST_CONFIG_IMPLEMENT +#include + +int main(int argc, char **argv) { + doctest::Context context; + context.applyCommandLine(argc, argv); + + int res = context.run(); // run doctest + + // important - query flags (and --exit) rely on the user doing this + if (context.shouldExit()) { + // propagate the result of the tests + return res; + } + + printf("%s\n", "Hello, World!"); +} + +int factorial(const int number) { + return number < 1 ? 1 : number <= 1 ? number : factorial(number - 1) * number; +} + +TEST_CASE("testing the factorial function") { + CHECK(factorial(0) == 1); + CHECK(factorial(1) == 1); + CHECK(factorial(2) == 2); + CHECK(factorial(3) == 6); + CHECK(factorial(10) == 3628800); +} + +// running notes +// ./example_exe --no-run (run normal program) +// ./example_exe --exit (run tests then exit) +// ./example_exe (run tests then run program) +// ./example_exe --success (print successful test casts) diff --git a/dmff/dpnblist/external/doctest-2.4.11/examples/mpi/CMakeLists.txt b/dmff/dpnblist/external/doctest-2.4.11/examples/mpi/CMakeLists.txt new file mode 100644 index 00000000..2d929f5f --- /dev/null +++ b/dmff/dpnblist/external/doctest-2.4.11/examples/mpi/CMakeLists.txt @@ -0,0 +1,7 @@ +find_package(MPI COMPONENTS CXX) +if(MPI_FOUND) + add_executable(test_mpi main.cpp mpi.cpp) + target_link_libraries(test_mpi doctest ${CMAKE_THREAD_LIBS_INIT} MPI::MPI_CXX) + + doctest_add_test(NO_OUTPUT NAME test_mpi COMMAND ${MPIEXEC_EXECUTABLE} ${MPIEXEC_NUMPROC_FLAG} 3 $) +endif() diff --git a/dmff/dpnblist/external/doctest-2.4.11/examples/mpi/main.cpp b/dmff/dpnblist/external/doctest-2.4.11/examples/mpi/main.cpp new file mode 100644 index 00000000..6d080b76 --- /dev/null +++ b/dmff/dpnblist/external/doctest-2.4.11/examples/mpi/main.cpp @@ -0,0 +1,19 @@ +#define DOCTEST_CONFIG_IMPLEMENT + +#include + +int main(int argc, char** argv) { + doctest::mpi_init_thread(argc,argv,MPI_THREAD_MULTIPLE); + + doctest::Context ctx; + ctx.setOption("reporters", "MpiConsoleReporter"); + ctx.setOption("reporters", "MpiFileReporter"); + ctx.setOption("force-colors", true); + ctx.applyCommandLine(argc, argv); + + int test_result = ctx.run(); + + doctest::mpi_finalize(); + + return test_result; +} diff --git a/dmff/dpnblist/external/doctest-2.4.11/examples/mpi/mpi.cpp b/dmff/dpnblist/external/doctest-2.4.11/examples/mpi/mpi.cpp new file mode 100644 index 00000000..54c7d458 --- /dev/null +++ b/dmff/dpnblist/external/doctest-2.4.11/examples/mpi/mpi.cpp @@ -0,0 +1,46 @@ +#include + +int f_for_test(int rank); + +int f_for_test(int rank) { + if (rank == 0) { + return 10; + } + else if (rank == 1) { + return 11; + } + return 0; +} + + + +MPI_TEST_CASE("Parallel test on 2 processes",2) { // if MPI_SIZE < 2, report test can't be run + // 3 objects accessible in the test: + // test_comm: MPI_Comm of size 2 + // test_rank: integer of value the rank of the process in test_comm + // test_nb_procs: integer of value the size of the process (here: 2) + + int x = f_for_test(test_rank); + + MPI_CHECK( 0, x==10 ); // CHECK for rank 0, that x==10 + MPI_CHECK( 1, x==11 ); // CHECK for rank 1, that x==11 + //MPI_CHECK( 2, x==0 ); // will trigger a static assert because non-existing rank +} + +MPI_TEST_CASE("Parallel test on 3 processes (failing)",3) { + int x = f_for_test(test_rank); + + MPI_CHECK( 0, x==10 ); // CHECK for rank 0, that x==10 + MPI_CHECK( 1, x==11 ); // CHECK for rank 1, that x==11 + MPI_CHECK( 2, x==-1 ); // CHECK for rank 2, that x==-1 (which is not the case -> will trigger a failure report) +} + +MPI_TEST_CASE("Parallel tests with subcases",2) { + + SUBCASE("sub_case 0") { + CHECK( test_nb_procs == 2 ); + } + SUBCASE("sub_case 1") { + CHECK( test_rank == 0 ); // should fail on proc 1 + } +} diff --git a/dmff/dpnblist/external/doctest-2.4.11/examples/range_based_execution.py b/dmff/dpnblist/external/doctest-2.4.11/examples/range_based_execution.py new file mode 100644 index 00000000..1c14ba7d --- /dev/null +++ b/dmff/dpnblist/external/doctest-2.4.11/examples/range_based_execution.py @@ -0,0 +1,43 @@ +#!/usr/bin/python + +import sys +import math +import multiprocessing +import subprocess + +if len(sys.argv) < 2: + print("supply the path to the doctest executable as the first argument!") + sys.exit(1) + +# get the number of tests in the doctest executable +num_tests = 0 + +program_with_args = [sys.argv[1], "--dt-count=1"] +for i in range(2, len(sys.argv)): + program_with_args.append(sys.argv[i]) + +result = subprocess.Popen(program_with_args, stdout = subprocess.PIPE).communicate()[0] +result = result.splitlines(True) +for line in result: + if line.startswith("[doctest] unskipped test cases passing the current filters:"): + num_tests = int(line.rsplit(' ', 1)[-1]) + +# calculate the ranges +cores = multiprocessing.cpu_count() +l = range(num_tests + 1) +n = int(math.ceil(float(len( l )) / cores)) +data = [l[i : i + n] for i in range(1, len( l ), n)] +data = tuple([[x[0], x[-1]] for x in data]) + +# for 8 cores and 100 tests the ranges will look like this +# ([1, 13], [14, 26], [27, 39], [40, 52], [53, 65], [66, 78], [79, 91], [92, 100]) + +# the worker callback that runs the executable for the given range of tests +def worker((first, last)): + program_with_args = [sys.argv[1], "--dt-first=" + str(first), "--dt-last=" + str(last)] + subprocess.Popen(program_with_args) + +# run the tasks on a pool +if __name__ == '__main__': + p = multiprocessing.Pool(cores) + p.map(worker, data) diff --git a/dmff/dpnblist/external/doctest-2.4.11/meson.build b/dmff/dpnblist/external/doctest-2.4.11/meson.build new file mode 100644 index 00000000..585dd555 --- /dev/null +++ b/dmff/dpnblist/external/doctest-2.4.11/meson.build @@ -0,0 +1,7 @@ +project('doctest', ['cpp'], version: '2.4.11') + +doctest_dep = declare_dependency(include_directories: include_directories('doctest')) + +if meson.version().version_compare('>=0.54.0') + meson.override_dependency('doctest', doctest_dep) +endif diff --git a/dmff/dpnblist/external/doctest-2.4.11/scripts/bench/bench.py b/dmff/dpnblist/external/doctest-2.4.11/scripts/bench/bench.py new file mode 100644 index 00000000..0aaa981a --- /dev/null +++ b/dmff/dpnblist/external/doctest-2.4.11/scripts/bench/bench.py @@ -0,0 +1,237 @@ +#!/usr/bin/python3 + +import os +import sys +if sys.version_info[0] < 3: raise Exception("Python 3 or a more recent version is required.") +import pprint +import argparse +import urllib.request +from datetime import datetime +import shutil +from time import sleep + +# ============================================================================== +# == ARGUMENTS ================================================================= +# ============================================================================== + +def addCommonFlags(parser): + parser.add_argument("compiler", choices=['msvc', 'gcc', 'clang'], default='msvc', help = "compiler to use") + parser.add_argument("--debug", action = "store_true", help = "build in debug") + parser.add_argument("--catch", action = "store_true", help = "use Catch instead of doctest") + parser.add_argument("--disabled", action = "store_true", help = "DOCTEST_CONFIG_DISABLE / CATCH_CONFIG_DISABLE") + parser.add_argument("--fast", action = "store_true", help = "define the doctest/Catch fast config identifier") + parser.add_argument("--files", type=int, default=1, help = "number of source files (besides the implementation)") + parser.add_argument("--tests", type=int, default=1, help = "number of test cases per source file") + parser.add_argument("--checks", type=int, default=1, help = "number of asserts per test case") + parser.add_argument("--asserts", choices=['normal', 'binary'], default="normal", + help = " type of assert used - Catch: only normal") + +parser = argparse.ArgumentParser() +subparsers = parser.add_subparsers() +parser_c = subparsers.add_parser('compile', help='benchmark compile times') +addCommonFlags(parser_c) +parser_c.add_argument("--implement", action = "store_true", help = "implement the framework test runner") +parser_c.add_argument("--header", action = "store_true", help = "include the framework header everywhere") +parser_r = subparsers.add_parser('runtime', help='benchmark runtime') +addCommonFlags(parser_r) +parser_r.add_argument("--loop-iters", type=int, default=1000, help = "loop N times all asserts in each test case") +parser_r.add_argument("--info", action = "store_true", help = "log the loop variable with INFO()") + +def compile(args): args.compile = True; args.runtime = False +def runtime(args): args.compile = False; args.runtime = True +parser_c.set_defaults(func=compile) +parser_r.set_defaults(func=runtime) +args = parser.parse_args() +args.func(args) + +print("== PASSED OPTIONS TO BENCHMARK SCRIPT:") +pprint.pprint(vars(args), width = 1) + +# ============================================================================== +# == SETUP ENVIRONMENT ========================================================= +# ============================================================================== + +# catch version +catch_ver = "2.3.0" +catch_header = "catch." + catch_ver + ".hpp" + +# get the catch header +if not os.path.exists("catch." + catch_ver + ".hpp"): + urllib.request.urlretrieve("https://github.com/catchorg/Catch2/releases/download/v" + catch_ver + "/catch.hpp", catch_header) + +# folder with generated code +the_folder = 'project' + +# delete the folder +if os.path.exists(the_folder): + shutil.rmtree(the_folder) + +# wait a bit or the script might fail... +sleep(2) + +# create the folder +if not os.path.exists(the_folder): + os.makedirs(the_folder) + +# enter folder +os.chdir(the_folder); + +# ============================================================================== +# == DO STUFF ================================================================== +# ============================================================================== + +# setup defines used +defines = "" +if args.catch and args.disabled: + defines += "#define CATCH_CONFIG_DISABLE\n" +if not args.catch and args.disabled: + defines += "#define DOCTEST_CONFIG_DISABLE\n" +if args.catch and args.fast: + defines += "#define CATCH_CONFIG_FAST_COMPILE\n" +if not args.catch and args.fast: + defines += "#define DOCTEST_CONFIG_SUPER_FAST_ASSERTS\n" + +define_implement = "#define DOCTEST_CONFIG_IMPLEMENT\n" +if args.catch: + define_implement = "#define CATCH_CONFIG_RUNNER\n" + +# setup the macros used +macro = " CHECK(a == b);\n" +if args.runtime: + macro = " CHECK(i == i);\n" +if not args.catch and args.asserts == "binary": + macro = " CHECK_EQ(a, b);\n" + +# setup the header used +include = '#include "doctest.h"\n' +if args.catch: + include = '#include "' + catch_header + '"\n' + +# ============================================================================== +# == GENERATE SOURCE CODE ====================================================== +# ============================================================================== + +# make the source files +for i in range(0, args.files): + f = open(str(i) + '.cpp', 'w') + if args.runtime or args.header: + f.write(defines) + f.write(include) + for t in range(0, args.tests): + f.write('TEST_CASE("") {\n') + f.write(' int a = 5;\n') + f.write(' int b = 5;\n') + if args.runtime and args.loop_iters > 0: + f.write(' for(int i = 0; i < ' + str(args.loop_iters) + '; ++i) {\n') + if args.runtime and args.info: + f.write(' INFO(i);\n') + for a in range(0, args.checks): + if args.runtime and args.loop_iters > 0: + f.write(' ') + f.write(macro) + if args.runtime and args.loop_iters > 0: + f.write(' }\n') + f.write('}\n\n') + f.write('int f' + str(i) + '() { return ' + str(i) + '; }\n\n') + f.close() + +# the main file +f = open('main.cpp', 'w') +if args.runtime or args.implement or args.header: + f.write(defines) + f.write(define_implement) + f.write(include) +f.write('int main(int argc, char** argv) {\n') +if args.runtime or args.implement or args.header: + if not args.catch: f.write(' int res = doctest::Context(argc, argv).run();\n') + else: f.write(' int res = Catch::Session().run(argc, argv);\n') +else: + f.write(' int res = 0;\n') +for i in range(0, args.files): + f.write(' int f' + str(i) + '(); res += f' + str(i) + '();\n') +f.write(' return res;\n}\n') +f.close() + +# the cmake file +f = open('CMakeLists.txt', 'w') +f.write('cmake_minimum_required(VERSION 2.8)\n\n') +f.write('project(bench)\n\n') +f.write('if(NOT MSVC)\n') +f.write('set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11")\n') +f.write('endif()\n\n') +if not args.catch: f.write('include_directories("../../../doctest/")\n\n') +else: f.write('include_directories("../")\n\n') +f.write('add_executable(bench main.cpp\n') +for i in range(0, args.files): + f.write(' ' + str(i) + '.cpp\n') +f.write(')\n') +f.close() + +# ============================================================================== +# == INVOKE CMAKE ============================================================== +# ============================================================================== + +compiler = "" +if args.compiler == 'clang': + compiler = " -DCMAKE_CXX_COMPILER=clang++ -DCMAKE_CXX_FLAGS=-w" +if args.compiler == 'gcc': + compiler = " -DCMAKE_CXX_COMPILER=g++ -DCMAKE_CXX_FLAGS=-w" + +# setup cmake command +cmake_command = 'cmake . -G "Visual Studio 15 Win64"' # MSVC 2017 +if args.compiler != 'msvc': + cmake_command = 'cmake . -G "MinGW Makefiles" -DCMAKE_BUILD_TYPE=' + ('Debug' if args.debug else 'Release') +if os.name != "nt": + cmake_command = 'cmake . -DCMAKE_BUILD_TYPE=' + ('Debug' if args.debug else 'Release') + +os.system(cmake_command + compiler) + +# ============================================================================== +# == BUILD PROJECT ============================================================= +# ============================================================================== + +the_config = '' +if args.compiler == 'msvc': + if args.debug: the_config = ' --config Debug' + else: the_config = ' --config Release' + +# build it +start = datetime.now() +os.system('cmake --build .' + the_config) +end = datetime.now() + +if not args.runtime: + print("Time running compiler (+ linker) in seconds: " + str((end - start).total_seconds())) + +# ============================================================================== +# == RUN PROJECT =============================================================== +# ============================================================================== + +if args.runtime: + start = datetime.now() + if args.compiler == 'msvc': + os.system(('Debug' if args.debug else 'Release') + '\\bench.exe') + elif os.name == "nt": + os.system('bench.exe') + else: + os.system('./bench') + end = datetime.now() + + print("Time running the tests in seconds: " + str((end - start).total_seconds())) + +# leave folder +os.chdir("../"); + + + + + + + + + + + + + + diff --git a/dmff/dpnblist/external/doctest-2.4.11/scripts/bench/run_all.py b/dmff/dpnblist/external/doctest-2.4.11/scripts/bench/run_all.py new file mode 100644 index 00000000..7dfd78aa --- /dev/null +++ b/dmff/dpnblist/external/doctest-2.4.11/scripts/bench/run_all.py @@ -0,0 +1,65 @@ +#!/usr/bin/python3 + +import os +import sys +if sys.version_info[0] < 3: raise Exception("Python 3 or a more recent version is required.") +import json +import subprocess + +average_num_times = 3 +max_accum_time = 60 # don't take too long on a test - stop averaging if time exceeds some amount of seconds + +with open('tests.json') as data_file: + data = json.load(data_file) + +def runBench(prog): + result = subprocess.Popen(prog.split(), stdout = subprocess.PIPE).communicate()[0] + result = result.splitlines() + for line in result: + line = line.decode("utf-8") + if line.startswith("Time running "): + return str(line.rsplit(' ', 1)[-1]) + return "" + +call = 'python ./bench.py' +the_os = 'linux' +if os.name == "nt": + call = 'python bench.py' + the_os = 'windows' + +f = open('results.txt', 'w') +for test in ['header', 'asserts', 'runtime']: + print( '\n************** ' + test + '\n') + f.write('\n************** ' + test + '\n') + f.flush() + for framework in ['doctest', 'catch']: + print( '== ' + framework + '\n') + f.write('== ' + framework + '\n') + f.flush() + for config in data['compilers'][the_os]: + for curr in data[test][1]: + if curr[0] == framework or curr[0] == "any": + command = call + data[test][0] + config + curr[1] + (' --catch' if framework == 'catch' else '') + print(command) + + accum = float(0) + num_times = 0 + for i in range(0, average_num_times): + res = float(runBench(command)) + print(res) + accum += res + num_times += 1 + + if accum > max_accum_time: + break + + average = "{:7.2f}".format(round(accum / num_times, 2)) + print("AVERAGE: " + average) + f.write(average + " | ") + f.flush() + f.write("\n") + f.flush() + +f.close() + + diff --git a/dmff/dpnblist/external/doctest-2.4.11/scripts/bench/tests.json b/dmff/dpnblist/external/doctest-2.4.11/scripts/bench/tests.json new file mode 100644 index 00000000..5d7d5515 --- /dev/null +++ b/dmff/dpnblist/external/doctest-2.4.11/scripts/bench/tests.json @@ -0,0 +1,43 @@ +{ + "compilers": { + "windows": [ + " msvc --debug", + " msvc", + " gcc --debug", + " gcc" + ], + "linux": [ + " gcc --debug", + " gcc", + " clang --debug", + " clang" + ] + }, + "header": [ + " compile", + [ + ["any", " --files 200 --tests 0"], + ["any", " --files 200 --tests 0 --implement"], + ["any", " --files 200 --tests 0 --implement --header"], + ["any", " --files 200 --tests 0 --implement --header --disabled"] + ] + ], + "asserts": [ + " compile", + [ + ["any", " --header --files 10 --tests 0 --checks 0"], + ["any", " --header --files 10 --tests 50 --checks 100 --asserts normal"], + ["any", " --header --files 10 --tests 50 --checks 100 --asserts normal --fast"], + ["doctest", " --header --files 10 --tests 50 --checks 100 --asserts binary"], + ["doctest", " --header --files 10 --tests 50 --checks 100 --asserts binary --fast"], + ["any", " --header --files 10 --tests 50 --checks 100 --asserts normal --disabled"] + ] + ], + "runtime": [ + " runtime", + [ + ["any", " --files 1 --tests 1 --checks 1 --loop-iters 10000000"], + ["any", " --files 1 --tests 1 --checks 1 --loop-iters 10000000 --info"] + ] + ] +} diff --git a/dmff/dpnblist/external/doctest-2.4.11/scripts/cmake/Config.cmake.in b/dmff/dpnblist/external/doctest-2.4.11/scripts/cmake/Config.cmake.in new file mode 100644 index 00000000..44ddb07d --- /dev/null +++ b/dmff/dpnblist/external/doctest-2.4.11/scripts/cmake/Config.cmake.in @@ -0,0 +1,6 @@ +if(NOT TARGET doctest::doctest) + # Provide path for scripts + list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_LIST_DIR}") + + include("${CMAKE_CURRENT_LIST_DIR}/@targets_export_name@.cmake") +endif() diff --git a/dmff/dpnblist/external/doctest-2.4.11/scripts/cmake/assemble_single_header.cmake b/dmff/dpnblist/external/doctest-2.4.11/scripts/cmake/assemble_single_header.cmake new file mode 100644 index 00000000..98097549 --- /dev/null +++ b/dmff/dpnblist/external/doctest-2.4.11/scripts/cmake/assemble_single_header.cmake @@ -0,0 +1,13 @@ +set(doctest_include_folder "${CMAKE_CURRENT_LIST_DIR}/../../doctest/") + +file(READ ${doctest_include_folder}/parts/doctest_fwd.h fwd) +file(READ ${doctest_include_folder}/parts/doctest.cpp impl) + +file(WRITE ${doctest_include_folder}/doctest.h "// ====================================================================== lgtm [cpp/missing-header-guard]\n") +file(APPEND ${doctest_include_folder}/doctest.h "// == DO NOT MODIFY THIS FILE BY HAND - IT IS AUTO GENERATED BY CMAKE! ==\n") +file(APPEND ${doctest_include_folder}/doctest.h "// ======================================================================\n") +file(APPEND ${doctest_include_folder}/doctest.h "${fwd}\n") +file(APPEND ${doctest_include_folder}/doctest.h "#ifndef DOCTEST_SINGLE_HEADER\n") +file(APPEND ${doctest_include_folder}/doctest.h "#define DOCTEST_SINGLE_HEADER\n") +file(APPEND ${doctest_include_folder}/doctest.h "#endif // DOCTEST_SINGLE_HEADER\n") +file(APPEND ${doctest_include_folder}/doctest.h "\n${impl}") diff --git a/dmff/dpnblist/external/doctest-2.4.11/scripts/cmake/common.cmake b/dmff/dpnblist/external/doctest-2.4.11/scripts/cmake/common.cmake new file mode 100644 index 00000000..b90f5dd7 --- /dev/null +++ b/dmff/dpnblist/external/doctest-2.4.11/scripts/cmake/common.cmake @@ -0,0 +1,212 @@ +include(CMakeParseArguments) + +# cache this for use inside of the function +set(CURRENT_LIST_DIR_CACHED ${CMAKE_CURRENT_LIST_DIR}) + +set_property(GLOBAL PROPERTY USE_FOLDERS ON) + +enable_testing() + +find_package(Threads) + +set(DOCTEST_TEST_MODE "COMPARE" CACHE STRING "Test mode - normal/run through valgrind/collect output/compare with output") +set_property(CACHE DOCTEST_TEST_MODE PROPERTY STRINGS "NORMAL;VALGRIND;COLLECT;COMPARE") + +function(doctest_add_test_impl) + cmake_parse_arguments(ARG "NO_VALGRIND;NO_OUTPUT;XML_OUTPUT;JUNIT_OUTPUT" "NAME" "COMMAND" ${ARGN}) + if(NOT "${ARG_UNPARSED_ARGUMENTS}" STREQUAL "" OR "${ARG_NAME}" STREQUAL "" OR "${ARG_COMMAND}" STREQUAL "") + message(FATAL_ERROR "doctest_add_test() called with wrong options!") + endif() + + set(the_test_mode NORMAL) + + # construct the command that will be called by the exec_test.cmake script + set(the_command "") + if(${DOCTEST_TEST_MODE} STREQUAL "VALGRIND" AND NOT ARG_NO_VALGRIND) + set(the_test_mode VALGRIND) + set(the_command "valgrind -v --leak-check=full --track-origins=yes --error-exitcode=1") + endif() + foreach(cur ${ARG_COMMAND}) + set(the_command "${the_command} ${cur}") + endforeach() + if(ARG_XML_OUTPUT) + set(the_command "${the_command} --reporters=xml") + set(ARG_NAME ${ARG_NAME}_xml) + endif() + if(ARG_JUNIT_OUTPUT) + set(the_command "${the_command} --reporters=junit") + set(ARG_NAME ${ARG_NAME}_junit) + endif() + + # append the argument for removing paths from filenames in the output so tests give the same output everywhere + set(the_command "${the_command} --dt-no-path-filenames=1") + # append the argument for substituting source line numbers with 0 in the output so tests give the same output when lines change a bit + set(the_command "${the_command} --dt-no-line-numbers=1") + # append the argument for ignoring the exit code of the test programs because some are intended to have failing tests + set(the_command "${the_command} --dt-no-exitcode=1") + # append the argument for using the same line format in the output - so gcc/non-gcc builds have the same output + set(the_command "${the_command} --dt-gnu-file-line=0") + # append the argument for skipping any time-related output so that the reference output from reporters is stable on CI + set(the_command "${the_command} --dt-no-time-in-output=1") + + string(STRIP ${the_command} the_command) + + if(${DOCTEST_TEST_MODE} STREQUAL "COLLECT" OR ${DOCTEST_TEST_MODE} STREQUAL "COMPARE") + if(NOT ARG_NO_OUTPUT) + file(MAKE_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/test_output/) + set(the_test_mode ${DOCTEST_TEST_MODE}) + list(APPEND ADDITIONAL_FLAGS -DTEST_OUTPUT_FILE=${CMAKE_CURRENT_SOURCE_DIR}/test_output/${ARG_NAME}.txt) + list(APPEND ADDITIONAL_FLAGS -DTEST_TEMP_FILE=${CMAKE_CURRENT_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/temp_test_output_${ARG_NAME}.txt) + endif() + endif() + + list(APPEND ADDITIONAL_FLAGS -DTEST_MODE=${the_test_mode}) + + add_test(NAME ${ARG_NAME} COMMAND ${CMAKE_COMMAND} -DCOMMAND=${the_command} ${ADDITIONAL_FLAGS} -P ${CURRENT_LIST_DIR_CACHED}/exec_test.cmake) +endfunction() + +# a custom version of add_test() to suite my needs +function(doctest_add_test) + doctest_add_test_impl(${ARGN}) + doctest_add_test_impl(${ARGN} XML_OUTPUT) + doctest_add_test_impl(${ARGN} JUNIT_OUTPUT) +endfunction() + +macro(add_compiler_flags) + foreach(flag ${ARGV}) + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${flag}") + endforeach() +endmacro() + +if(CMAKE_CXX_COMPILER_ID MATCHES "GNU|Clang") + add_compiler_flags(-Werror) + add_compiler_flags(-fstrict-aliasing) + + # The following options are not valid when clang-cl is used. + if(NOT MSVC) + add_compiler_flags(-pedantic) + add_compiler_flags(-pedantic-errors) + add_compiler_flags(-fvisibility=hidden) + endif() +endif() + +if(CMAKE_CXX_COMPILER_ID MATCHES "GNU") + #add_compiler_flags(-Wno-unknown-pragmas) + add_compiler_flags(-Wall) + add_compiler_flags(-Wextra) + add_compiler_flags(-fdiagnostics-show-option) + add_compiler_flags(-Wconversion) + add_compiler_flags(-Wold-style-cast) + add_compiler_flags(-Wfloat-equal) + add_compiler_flags(-Wlogical-op) + add_compiler_flags(-Wundef) + add_compiler_flags(-Wredundant-decls) + add_compiler_flags(-Wshadow) + add_compiler_flags(-Wstrict-overflow=5) + add_compiler_flags(-Wwrite-strings) + add_compiler_flags(-Wpointer-arith) + add_compiler_flags(-Wcast-qual) + add_compiler_flags(-Wformat=2) + add_compiler_flags(-Wswitch-default) + add_compiler_flags(-Wmissing-include-dirs) + add_compiler_flags(-Wcast-align) + add_compiler_flags(-Wswitch-enum) + add_compiler_flags(-Wnon-virtual-dtor) + add_compiler_flags(-Wctor-dtor-privacy) + add_compiler_flags(-Wsign-conversion) + add_compiler_flags(-Wdisabled-optimization) + add_compiler_flags(-Weffc++) + add_compiler_flags(-Winvalid-pch) + add_compiler_flags(-Wmissing-declarations) + add_compiler_flags(-Woverloaded-virtual) + add_compiler_flags(-Wunused-but-set-variable) + add_compiler_flags(-Wunused-result) + + # add_compiler_flags(-Wsuggest-override) + # add_compiler_flags(-Wmultiple-inheritance) + # add_compiler_flags(-Wcatch-value) + # add_compiler_flags(-Wsuggest-attribute=cold) + # add_compiler_flags(-Wsuggest-attribute=const) + # add_compiler_flags(-Wsuggest-attribute=format) + # add_compiler_flags(-Wsuggest-attribute=malloc) + # add_compiler_flags(-Wsuggest-attribute=noreturn) + # add_compiler_flags(-Wsuggest-attribute=pure) + # add_compiler_flags(-Wsuggest-final-methods) + # add_compiler_flags(-Wsuggest-final-types) + + if(NOT CMAKE_CXX_COMPILER_VERSION VERSION_LESS 4.6) + add_compiler_flags(-Wnoexcept) + endif() + + if(CMAKE_CXX_COMPILER_VERSION VERSION_LESS 5.0) + add_compiler_flags(-Wno-missing-field-initializers) + endif() + + # no way to silence it in the expression decomposition macros: _Pragma() in macros doesn't work for the c++ front-end of g++ + # https://gcc.gnu.org/bugzilla/show_bug.cgi?id=55578 + # https://gcc.gnu.org/bugzilla/show_bug.cgi?id=69543 + # Also the warning is completely worthless nowadays - https://stackoverflow.com/questions/14016993 + #add_compiler_flags(-Waggregate-return) + + if(NOT CMAKE_CXX_COMPILER_VERSION VERSION_LESS 5.0) + add_compiler_flags(-Wdouble-promotion) + add_compiler_flags(-Wtrampolines) + add_compiler_flags(-Wzero-as-null-pointer-constant) + add_compiler_flags(-Wuseless-cast) + add_compiler_flags(-Wvector-operation-performance) + endif() + + if(NOT CMAKE_CXX_COMPILER_VERSION VERSION_LESS 6.0) + add_compiler_flags(-Wshift-overflow=2) + add_compiler_flags(-Wnull-dereference) + add_compiler_flags(-Wduplicated-cond) + endif() + + if(NOT CMAKE_CXX_COMPILER_VERSION VERSION_LESS 7.0) + add_compiler_flags(-Walloc-zero) + add_compiler_flags(-Walloca) + add_compiler_flags(-Wduplicated-branches) + endif() + + if(NOT CMAKE_CXX_COMPILER_VERSION VERSION_LESS 8.0) + add_compiler_flags(-Wcast-align=strict) + endif() +endif() + +# necessary for some older compilers which don't default to C++11 +set(CMAKE_CXX_STANDARD 11) +set(CMAKE_CXX_STANDARD_REQUIRED ON) + +if(CMAKE_CXX_COMPILER_ID MATCHES "Clang") + add_compiler_flags(-Weverything) + add_compiler_flags(-Wno-c++98-compat) + add_compiler_flags(-Wno-c++98-compat-pedantic) + add_compiler_flags(-Wno-c++98-compat-bind-to-temporary-copy) + add_compiler_flags(-Wno-c++98-compat-local-type-template-args) + add_compiler_flags(-Qunused-arguments -fcolor-diagnostics) # needed for ccache integration +endif() + +if(MSVC) + add_compiler_flags(/std:c++latest) # for post c++14 updates in MSVC + add_compiler_flags(/permissive-) # force standard conformance - this is the better flag than /Za + add_compiler_flags(/WX) + add_compiler_flags(/Wall) # turns on warnings from levels 1 through 4 which are off by default - https://msdn.microsoft.com/en-us/library/23k5d385.aspx + + add_compiler_flags( + /wd4514 # unreferenced inline function has been removed + /wd4571 # SEH related + /wd5264 # const variable is not used + /wd4710 # function not inlined + /wd4711 # function 'x' selected for automatic inline expansion + + /wd4616 # invalid compiler warnings - https://msdn.microsoft.com/en-us/library/t7ab6xtd.aspx + /wd4619 # invalid compiler warnings - https://msdn.microsoft.com/en-us/library/tacee08d.aspx + + #/wd4820 # padding in structs + #/wd4625 # copy constructor was implicitly defined as deleted + #/wd4626 # assignment operator was implicitly defined as deleted + #/wd5027 # move assignment operator was implicitly defined as deleted + #/wd5026 # move constructor was implicitly defined as deleted + #/wd4623 # default constructor was implicitly defined as deleted + ) +endif() diff --git a/dmff/dpnblist/external/doctest-2.4.11/scripts/cmake/doctest.cmake b/dmff/dpnblist/external/doctest-2.4.11/scripts/cmake/doctest.cmake new file mode 100644 index 00000000..3c4929f2 --- /dev/null +++ b/dmff/dpnblist/external/doctest-2.4.11/scripts/cmake/doctest.cmake @@ -0,0 +1,189 @@ +# Distributed under the OSI-approved BSD 3-Clause License. See accompanying +# file Copyright.txt or https://cmake.org/licensing for details. + +#[=======================================================================[.rst: +doctest +----- + +This module defines a function to help use the doctest test framework. + +The :command:`doctest_discover_tests` discovers tests by asking the compiled test +executable to enumerate its tests. This does not require CMake to be re-run +when tests change. However, it may not work in a cross-compiling environment, +and setting test properties is less convenient. + +This command is intended to replace use of :command:`add_test` to register +tests, and will create a separate CTest test for each doctest test case. Note +that this is in some cases less efficient, as common set-up and tear-down logic +cannot be shared by multiple test cases executing in the same instance. +However, it provides more fine-grained pass/fail information to CTest, which is +usually considered as more beneficial. By default, the CTest test name is the +same as the doctest name; see also ``TEST_PREFIX`` and ``TEST_SUFFIX``. + +.. command:: doctest_discover_tests + + Automatically add tests with CTest by querying the compiled test executable + for available tests:: + + doctest_discover_tests(target + [TEST_SPEC arg1...] + [EXTRA_ARGS arg1...] + [WORKING_DIRECTORY dir] + [TEST_PREFIX prefix] + [TEST_SUFFIX suffix] + [PROPERTIES name1 value1...] + [ADD_LABELS value] + [TEST_LIST var] + [JUNIT_OUTPUT_DIR dir] + ) + + ``doctest_discover_tests`` sets up a post-build command on the test executable + that generates the list of tests by parsing the output from running the test + with the ``--list-test-cases`` argument. This ensures that the full + list of tests is obtained. Since test discovery occurs at build time, it is + not necessary to re-run CMake when the list of tests changes. + However, it requires that :prop_tgt:`CROSSCOMPILING_EMULATOR` is properly set + in order to function in a cross-compiling environment. + + Additionally, setting properties on tests is somewhat less convenient, since + the tests are not available at CMake time. Additional test properties may be + assigned to the set of tests as a whole using the ``PROPERTIES`` option. If + more fine-grained test control is needed, custom content may be provided + through an external CTest script using the :prop_dir:`TEST_INCLUDE_FILES` + directory property. The set of discovered tests is made accessible to such a + script via the ``_TESTS`` variable. + + The options are: + + ``target`` + Specifies the doctest executable, which must be a known CMake executable + target. CMake will substitute the location of the built executable when + running the test. + + ``TEST_SPEC arg1...`` + Specifies test cases, wildcarded test cases, tags and tag expressions to + pass to the doctest executable with the ``--list-test-cases`` argument. + + ``EXTRA_ARGS arg1...`` + Any extra arguments to pass on the command line to each test case. + + ``WORKING_DIRECTORY dir`` + Specifies the directory in which to run the discovered test cases. If this + option is not provided, the current binary directory is used. + + ``TEST_PREFIX prefix`` + Specifies a ``prefix`` to be prepended to the name of each discovered test + case. This can be useful when the same test executable is being used in + multiple calls to ``doctest_discover_tests()`` but with different + ``TEST_SPEC`` or ``EXTRA_ARGS``. + + ``TEST_SUFFIX suffix`` + Similar to ``TEST_PREFIX`` except the ``suffix`` is appended to the name of + every discovered test case. Both ``TEST_PREFIX`` and ``TEST_SUFFIX`` may + be specified. + + ``PROPERTIES name1 value1...`` + Specifies additional properties to be set on all tests discovered by this + invocation of ``doctest_discover_tests``. + + ``ADD_LABELS value`` + Specifies if the test labels should be set automatically. + + ``TEST_LIST var`` + Make the list of tests available in the variable ``var``, rather than the + default ``_TESTS``. This can be useful when the same test + executable is being used in multiple calls to ``doctest_discover_tests()``. + Note that this variable is only available in CTest. + + ``JUNIT_OUTPUT_DIR dir`` + If specified, the parameter is passed along with ``--reporters=junit`` + and ``--out=`` to the test executable. The actual file name is the same + as the test target, including prefix and suffix. This should be used + instead of EXTRA_ARGS to avoid race conditions writing the XML result + output when using parallel test execution. + +#]=======================================================================] + +#------------------------------------------------------------------------------ +function(doctest_discover_tests TARGET) + cmake_parse_arguments( + "" + "" + "TEST_PREFIX;TEST_SUFFIX;WORKING_DIRECTORY;TEST_LIST;JUNIT_OUTPUT_DIR" + "TEST_SPEC;EXTRA_ARGS;PROPERTIES;ADD_LABELS" + ${ARGN} + ) + + if(NOT _WORKING_DIRECTORY) + set(_WORKING_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}") + endif() + if(NOT _TEST_LIST) + set(_TEST_LIST ${TARGET}_TESTS) + endif() + + ## Generate a unique name based on the extra arguments + string(SHA1 args_hash "${_TEST_SPEC} ${_EXTRA_ARGS}") + string(SUBSTRING ${args_hash} 0 7 args_hash) + + # Define rule to generate test list for aforementioned test executable + set(ctest_include_file "${CMAKE_CURRENT_BINARY_DIR}/${TARGET}_include-${args_hash}.cmake") + set(ctest_tests_file "${CMAKE_CURRENT_BINARY_DIR}/${TARGET}_tests-${args_hash}.cmake") + get_property(crosscompiling_emulator + TARGET ${TARGET} + PROPERTY CROSSCOMPILING_EMULATOR + ) + add_custom_command( + TARGET ${TARGET} POST_BUILD + BYPRODUCTS "${ctest_tests_file}" + COMMAND "${CMAKE_COMMAND}" + -D "TEST_TARGET=${TARGET}" + -D "TEST_EXECUTABLE=$" + -D "TEST_EXECUTOR=${crosscompiling_emulator}" + -D "TEST_WORKING_DIR=${_WORKING_DIRECTORY}" + -D "TEST_SPEC=${_TEST_SPEC}" + -D "TEST_EXTRA_ARGS=${_EXTRA_ARGS}" + -D "TEST_PROPERTIES=${_PROPERTIES}" + -D "TEST_ADD_LABELS=${_ADD_LABELS}" + -D "TEST_PREFIX=${_TEST_PREFIX}" + -D "TEST_SUFFIX=${_TEST_SUFFIX}" + -D "TEST_LIST=${_TEST_LIST}" + -D "TEST_JUNIT_OUTPUT_DIR=${_JUNIT_OUTPUT_DIR}" + -D "CTEST_FILE=${ctest_tests_file}" + -P "${_DOCTEST_DISCOVER_TESTS_SCRIPT}" + VERBATIM + ) + + file(WRITE "${ctest_include_file}" + "if(EXISTS \"${ctest_tests_file}\")\n" + " include(\"${ctest_tests_file}\")\n" + "else()\n" + " add_test(${TARGET}_NOT_BUILT-${args_hash} ${TARGET}_NOT_BUILT-${args_hash})\n" + "endif()\n" + ) + + if(NOT CMAKE_VERSION VERSION_LESS 3.10) + # Add discovered tests to directory TEST_INCLUDE_FILES + set_property(DIRECTORY + APPEND PROPERTY TEST_INCLUDE_FILES "${ctest_include_file}" + ) + else() + # Add discovered tests as directory TEST_INCLUDE_FILE if possible + get_property(test_include_file_set DIRECTORY PROPERTY TEST_INCLUDE_FILE SET) + if(NOT ${test_include_file_set}) + set_property(DIRECTORY + PROPERTY TEST_INCLUDE_FILE "${ctest_include_file}" + ) + else() + message(FATAL_ERROR + "Cannot set more than one TEST_INCLUDE_FILE" + ) + endif() + endif() + +endfunction() + +############################################################################### + +set(_DOCTEST_DISCOVER_TESTS_SCRIPT + ${CMAKE_CURRENT_LIST_DIR}/doctestAddTests.cmake +) diff --git a/dmff/dpnblist/external/doctest-2.4.11/scripts/cmake/doctestAddTests.cmake b/dmff/dpnblist/external/doctest-2.4.11/scripts/cmake/doctestAddTests.cmake new file mode 100644 index 00000000..3b254850 --- /dev/null +++ b/dmff/dpnblist/external/doctest-2.4.11/scripts/cmake/doctestAddTests.cmake @@ -0,0 +1,120 @@ +# Distributed under the OSI-approved BSD 3-Clause License. See accompanying +# file Copyright.txt or https://cmake.org/licensing for details. + +set(prefix "${TEST_PREFIX}") +set(suffix "${TEST_SUFFIX}") +set(spec ${TEST_SPEC}) +set(extra_args ${TEST_EXTRA_ARGS}) +set(properties ${TEST_PROPERTIES}) +set(add_labels ${TEST_ADD_LABELS}) +set(junit_output_dir "${TEST_JUNIT_OUTPUT_DIR}") +set(script) +set(suite) +set(tests) + +function(add_command NAME) + set(_args "") + foreach(_arg ${ARGN}) + if(_arg MATCHES "[^-./:a-zA-Z0-9_]") + set(_args "${_args} [==[${_arg}]==]") # form a bracket_argument + else() + set(_args "${_args} ${_arg}") + endif() + endforeach() + set(script "${script}${NAME}(${_args})\n" PARENT_SCOPE) +endfunction() + +# Run test executable to get list of available tests +if(NOT EXISTS "${TEST_EXECUTABLE}") + message(FATAL_ERROR + "Specified test executable '${TEST_EXECUTABLE}' does not exist" + ) +endif() + +if("${spec}" MATCHES .) + set(spec "--test-case=${spec}") +endif() + +execute_process( + COMMAND ${TEST_EXECUTOR} "${TEST_EXECUTABLE}" ${spec} --list-test-cases + OUTPUT_VARIABLE output + RESULT_VARIABLE result + WORKING_DIRECTORY "${TEST_WORKING_DIR}" +) +if(NOT ${result} EQUAL 0) + message(FATAL_ERROR + "Error running test executable '${TEST_EXECUTABLE}':\n" + " Result: ${result}\n" + " Output: ${output}\n" + ) +endif() + +string(REPLACE "\n" ";" output "${output}") + +# Parse output +foreach(line ${output}) + if("${line}" STREQUAL "===============================================================================" OR "${line}" MATCHES [==[^\[doctest\] ]==]) + continue() + endif() + set(test ${line}) + set(labels "") + if(${add_labels}) + # get test suite that test belongs to + execute_process( + COMMAND ${TEST_EXECUTOR} "${TEST_EXECUTABLE}" --test-case=${test} --list-test-suites + OUTPUT_VARIABLE labeloutput + RESULT_VARIABLE labelresult + WORKING_DIRECTORY "${TEST_WORKING_DIR}" + ) + if(NOT ${labelresult} EQUAL 0) + message(FATAL_ERROR + "Error running test executable '${TEST_EXECUTABLE}':\n" + " Result: ${labelresult}\n" + " Output: ${labeloutput}\n" + ) + endif() + + string(REPLACE "\n" ";" labeloutput "${labeloutput}") + foreach(labelline ${labeloutput}) + if("${labelline}" STREQUAL "===============================================================================" OR "${labelline}" MATCHES [==[^\[doctest\] ]==]) + continue() + endif() + list(APPEND labels ${labelline}) + endforeach() + endif() + + if(NOT "${junit_output_dir}" STREQUAL "") + # turn testname into a valid filename by replacing all special characters with "-" + string(REGEX REPLACE "[/\\:\"|<>]" "-" test_filename "${test}") + set(TEST_JUNIT_OUTPUT_PARAM "--reporters=junit" "--out=${junit_output_dir}/${prefix}${test_filename}${suffix}.xml") + else() + unset(TEST_JUNIT_OUTPUT_PARAM) + endif() + # use escape commas to handle properly test cases with commas inside the name + string(REPLACE "," "\\," test_name ${test}) + # ...and add to script + add_command(add_test + "${prefix}${test}${suffix}" + ${TEST_EXECUTOR} + "${TEST_EXECUTABLE}" + "--test-case=${test_name}" + "${TEST_JUNIT_OUTPUT_PARAM}" + ${extra_args} + ) + add_command(set_tests_properties + "${prefix}${test}${suffix}" + PROPERTIES + WORKING_DIRECTORY "${TEST_WORKING_DIR}" + ${properties} + LABELS ${labels} + ) + unset(labels) + list(APPEND tests "${prefix}${test}${suffix}") +endforeach() + +# Create a list of all discovered tests, which users may use to e.g. set +# properties on the tests +add_command(set ${TEST_LIST} ${tests}) + +# Write CTest script +file(WRITE "${CTEST_FILE}" "${script}") diff --git a/dmff/dpnblist/external/doctest-2.4.11/scripts/cmake/exec_test.cmake b/dmff/dpnblist/external/doctest-2.4.11/scripts/cmake/exec_test.cmake new file mode 100644 index 00000000..ab51a015 --- /dev/null +++ b/dmff/dpnblist/external/doctest-2.4.11/scripts/cmake/exec_test.cmake @@ -0,0 +1,70 @@ +# Arguments: +# - COMMAND: the command to run with all it's arguments +# - TEST_MODE: NORMAL/VALGRIND/COLLECT/COMPARE +# - TEST_OUTPUT_FILE: the file to/from which to write/read the output of the test +# - TEST_TEMP_FILE: the temp file for the current test output used in COMPARE mode +# To run something through this script use cmake like this: +# cmake -DCOMMAND=path/to/my.exe -arg1 -arg2 -DTEST_MODE=VALGRIND -P path/to/exec_test.cmake + +#message("COMMAND: ${COMMAND}") +#message("TEST_MODE: ${TEST_MODE}") +#message("TEST_OUTPUT_FILE: ${TEST_OUTPUT_FILE}") +#message("TEST_TEMP_FILE: ${TEST_TEMP_FILE}") + +string(REPLACE " " ";" COMMAND_LIST ${COMMAND}) +set(cmd COMMAND ${COMMAND_LIST} RESULT_VARIABLE CMD_RESULT) +if("${TEST_MODE}" STREQUAL "COLLECT") + list(APPEND cmd OUTPUT_FILE ${TEST_OUTPUT_FILE} ERROR_FILE ${TEST_OUTPUT_FILE}) +elseif("${TEST_MODE}" STREQUAL "COMPARE") + list(APPEND cmd OUTPUT_FILE ${TEST_TEMP_FILE} ERROR_FILE ${TEST_TEMP_FILE}) +endif() + +execute_process(${cmd}) + +# fix line endings +if("${TEST_MODE}" STREQUAL "COLLECT" AND NOT CMAKE_HOST_UNIX) + execute_process(COMMAND dos2unix ${TEST_OUTPUT_FILE}) +endif() + +if("${TEST_MODE}" STREQUAL "COMPARE") + # fix line endings + if(NOT CMAKE_HOST_UNIX) + execute_process(COMMAND dos2unix ${TEST_TEMP_FILE}) + endif() + + if(CMAKE_VERSION VERSION_GREATER_EQUAL "3.14.0") + set(IGNORE_EOL --ignore-eol) + endif() + + execute_process(COMMAND ${CMAKE_COMMAND} -E compare_files ${IGNORE_EOL} ${TEST_OUTPUT_FILE} ${TEST_TEMP_FILE} RESULT_VARIABLE cmp_result) + + if(cmp_result) + find_package(Git) + if(GIT_FOUND) + set(cmd ${GIT_EXECUTABLE} diff --no-index ${TEST_OUTPUT_FILE} ${TEST_TEMP_FILE}) + execute_process(COMMAND ${GIT_EXECUTABLE} diff --no-index ${TEST_OUTPUT_FILE} ${TEST_TEMP_FILE} OUTPUT_VARIABLE DIFF) + message("${DIFF}") + endif() + + # file(READ ${TEST_OUTPUT_FILE} orig) + # file(READ ${TEST_TEMP_FILE} temp) + + # message("==========================================================================") + # message("== CONTENTS OF ${TEST_OUTPUT_FILE}") + # message("==========================================================================") + # message("${orig}") + # message("==========================================================================") + # message("== CONTENTS OF ${TEST_TEMP_FILE}") + # message("==========================================================================") + # message("${temp}") + # message("==========================================================================") + # message("== CONTENTS END") + # message("==========================================================================") + + set(CMD_RESULT "Output is different from reference file!") + endif() +endif() + +if(CMD_RESULT) + message(FATAL_ERROR "Running '${COMMAND}' ended with code '${CMD_RESULT}'") +endif() diff --git a/dmff/dpnblist/external/doctest-2.4.11/scripts/data/article.txt b/dmff/dpnblist/external/doctest-2.4.11/scripts/data/article.txt new file mode 100644 index 00000000..caeae678 --- /dev/null +++ b/dmff/dpnblist/external/doctest-2.4.11/scripts/data/article.txt @@ -0,0 +1,257 @@ +== doctest - the lightest C++ unit testing framework + +doctest is a fully open source light and feature-rich C++11 single-header testing framework for unit tests and TDD. + +Web Site: https://github.com/doctest/doctest +Version tested: 2.0.0 +System requirements: C++11 or newer +License & Pricing: MIT, free +Support: through the GitHub project page + +== Introduction + +A complete example with a self-registering test that compiles to an executable looks like this: + +#define DOCTEST_CONFIG_IMPLEMENT_WITH_MAIN +#include "doctest.h" + +int fact(int n) { return n <= 1 ? n : fact(n - 1) * n; } + +TEST_CASE("testing the factorial function") { + CHECK(fact(0) == 1); // will fail + CHECK(fact(1) == 1); + CHECK(fact(2) == 2); + CHECK(fact(10) == 3628800); +} + +And the output from that program is the following: + +[doctest] doctest version is "1.1.3" +[doctest] run with "--help" for options +======================================================== +main.cpp(6) +testing the factorial function + +main.cpp(7) FAILED! + CHECK( fact(0) == 1 ) +with expansion: + CHECK( 0 == 1 ) + +======================================================== +[doctest] test cases: 1 | 0 passed | 1 failed | +[doctest] assertions: 4 | 3 passed | 1 failed | + +Note how a standard C++ operator for equality comparison is used - doctest has one core assertion macro (it also has macros for less than, equals, greater than...) - yet the full expression is decomposed and the left and right values are logged. This is done with expression templates and C++ trickery. Also the test case is automatically registered - you don't need to manually insert it to a list. + +Doctest is modeled after Catch [1] which is currently the most popular alternative for testing in C++ (along with googletest [5]) - check out the differences in the FAQ [7]. Currently a few things which Catch has are missing but doctest aims to eventually become a superset of Catch. + +== Motivation behind the framework - how is it different + +doctest is inspired by the unittest {} functionality of the D programming language and Python's docstrings - tests can be considered a form of documentation and should be able to reside near the production code which they test (for example in the same source file a class is implemented). + +A few reasons you might want to do that: + +- Testing internals that are not exposed through the public API and headers of a module becomes easier. +- Lower barrier for writing tests - you don't have to: + 1. make a separate source file + 2. include a bunch of stuff in it + 3. add it to the build system + 4. add it to source control + You can just write the tests for a class or a piece of functionality at the bottom of its source file - or even header file! +- Faster iteration times - TDD becomes a lot easier. +- Tests in the production code stay in sync and can be thought of as active documentation or up-to-date comments - showing how an API is used. + +The framework can still be used like any other even if the idea of writing tests in the production code doesn't appeal to you - but this is the biggest power of the framework - and nothing else comes close to being so practical in achieving this - details below. + +There are many other features [8] and a lot more are planned in the roadmap [9]. + +This isn't possible (or at least practical) with any other testing framework for C++ - Catch [1], Boost.Test [2], UnitTest++ [3], cpputest [4], googletest [5] and many others [6]. + +What makes doctest different is that it is ultra light on compile times (by orders of magnitude - further details are in the "Compile time benchmarks" section) and is unintrusive. + +The key differences between it and the others are: + +- Ultra light - below 10ms of compile time overhead for including the header in a source file (compared to 250-460 ms for Catch) - see the "Compile time benchmarks" section +- The fastest possible assertion macros - 50 000 asserts can compile for under 30 seconds (even under 10 sec) +- Offers a way to remove everything testing-related from the binary with the DOCTEST_CONFIG_DISABLE identifier +- Doesn't pollute the global namespace (everything is in the doctest namespace) and doesn't drag any headers with it +- Doesn't produce any warnings even on the most aggressive warning levels for MSVC / GCC / Clang + * -Weverything for Clang + * /W4 for MSVC + * -Wall -Wextra -pedantic and over 35 other flags not included in these! +- Very portable and well tested C++11 - per commit tested on CI with over 300 different builds with different compilers and configurations (gcc 4.7-8.0 / clang 3.5-6.0 / MSVC 2013-2017, debug / release, x86/x64, linux / windows / osx, valgrind, sanitizers...) +- Just one header and no external dependencies apart from the C / C++ standard library (which are used only in the test runner) + +So if doctest is included in 1000 source files (globally in a big project) the overall build slowdown will be only ~10 seconds. If Catch is used - this would mean 350+ seconds just for including the header everywhere. + +If you have 50 000 asserts spread across your project (which is quite a lot) you should expect to see roughly 60-100 seconds of increased build time if using the normal expression-decomposing asserts or 10-40 seconds if you have used the fast form [11] of the asserts. + +These numbers pale in comparison to the build times of a 1000 source file project. Further details are in the "Compile time benchmarks" section. + +You also won't see any warnings or unnecessarily imported symbols from doctest - nor will you see a valgrind or a sanitizer error caused by the framework - it is truly transparent. + +== The main() entry point + +As we saw in the example above - a main() entry point for the program can be provided by the framework. If however you are writing the tests in your production code you probably already have a main() function. The following code example shows how doctest is used from a user main(): + +#define DOCTEST_CONFIG_IMPLEMENT +#include "doctest.h" +int main(int argc, char** argv) { + doctest::Context ctx; + // !!! THIS IS JUST AN EXAMPLE SHOWING HOW DEFAULTS/OVERRIDES ARE SET !!! + ctx.setOption("abort-after", 5); // default - stop after 5 failed asserts + ctx.applyCommandLine(argc, argv); // apply command line - argc / argv + ctx.setOption("no-breaks", true); // override - don't break in the debugger + int res = ctx.run(); // run test cases unless with --no-run + if(ctx.shouldExit()) // query flags (and --exit) rely on this + return res; // propagate the result of the tests + // your code goes here + return res; // + your_program_res +} + +With this setup the following 3 scenarios are possible: +- running only the tests (with the --exit option) +- running only the user code (with the --no-run option) +- running both the tests and the user code + +This must be possible if you are going to write the tests directly in the production code. + +Also this example shows how defaults and overrides can be set for command line options. + +Note that the DOCTEST_CONFIG_IMPLEMENT or DOCTEST_CONFIG_IMPLEMENT_WITH_MAIN identifiers should be defined before including the framework header - but only in one source file - where the test runner will get implemented. Everywhere else just include the header and write some tests. This is a common practice for single-header libraries that need a part of them to be compiled in one source file (in this case the test runner). + +== Removing everything testing-related from the binary + +You might want to remove the tests from your production code when building the release build that will be shipped to customers. The way this is done using doctest is by defining the DOCTEST_CONFIG_DISABLE preprocessor identifier in your whole project. + +The effect that identifier has on the TEST_CASE macro for example is the following - it gets turned into an anonymous template that never gets instantiated: + +#define TEST_CASE(name) \ + template \ + static inline void ANONYMOUS(ANON_FUNC_)() + +This means that all test cases are trimmed out of the resulting binary - even in Debug mode! The linker doesn't ever see the anonymous test case functions because they are never instantiated. + +The ANONYMOUS() macro is used to get unique identifiers each time it's called - it uses the __COUNTER__ preprocessor macro which returns an integer with 1 greater than the last time each time it gets used. For example: + +int ANONYMOUS(ANON_VAR_); // int ANON_VAR_5; +int ANONYMOUS(ANON_VAR_); // int ANON_VAR_6; + +== Subcases - the easiest way to share setup / teardown code between test cases + +Suppose you want to open a file in a few test cases and read from it. If you don't want to copy / paste the same setup code a few times you might use the Subcases mechanism of doctest. + +TEST_CASE("testing file stuff") { + printf("opening the file\n"); + std::ifstream is ("test.txt", std::ifstream::binary); + + SUBCASE("seeking in file") { + printf("seeking\n"); + // is.seekg() + } + SUBCASE("reading from file") { + printf("reading\n"); + // is.read() + } + printf("closing... (by the destructor)\n"); +} + +The following text will be printed: + +opening the file +seeking +closing... (by the destructor) +opening the file +reading +closing... (by the destructor) + +As you can see the test case was entered twice - and each time a different subcase was entered. Subcases can also be infinitely nested. The execution model resembles a DFS traversal - each time starting from the start of the test case and traversing the "tree" until a leaf node is reached (one that hasn't been traversed yet) - then the test case is exited by popping the stack of entered nested subcases. + +== Examples of how to embed tests in production code + +If shipping libraries with tests - it is a good idea to add a tag in your test case names (like this: TEST_CASE("[the_lib] testing foo")) so the user can easily filter them out with --test-case-exclude=*[the_lib]* if he wishes to. + +- If you are shipping a header-only library there are mainly 2 options: + +1. You could surround your tests with an ifdef to check if doctest is included before your headers - like this: + +// fact.h +#pragma once + +inline int fact(int n) { return n <= 1 ? n : fact(n - 1) * n; } + +#ifdef DOCTEST_LIBRARY_INCLUDED +TEST_CASE("[fact] testing the factorial function") { + CHECK(fact(0) == 1); // will fail + CHECK(fact(1) == 1); + CHECK(fact(2) == 2); + CHECK(fact(10) == 3628800); +} +#endif // DOCTEST_LIBRARY_INCLUDED + +2. You could use a preprocessor identifier (like FACT_WITH_TESTS) to conditionally use the tests - like this: + +// fact.h +#pragma once + +inline int fact(int n) { return n <= 1 ? n : fact(n - 1) * n; } + +#ifdef FACT_WITH_TESTS + +#ifndef DOCTEST_LIBRARY_INCLUDED +#include "doctest.h" +#endif // DOCTEST_LIBRARY_INCLUDED + +TEST_CASE("[fact] testing the factorial function") { + CHECK(fact(0) == 1); // will fail + CHECK(fact(1) == 1); + CHECK(fact(2) == 2); + CHECK(fact(10) == 3628800); +} +#endif // FACT_WITH_TESTS + +In both of these cases the user of the header-only library will have to implement the test runner of the framework somewhere in his executable/shared object. + +- If you are developing an end product and not a library for developers - then you can just mix code and tests and implement the test runner like described in the section "The main() entry point". + +- If you are developing a library which is not header-only - you could again write tests in your headers like shown above, and you could also make use of the DOCTEST_CONFIG_DISABLE identifier to optionally remove the tests from the source files when shipping it - or figure out a custom scheme like the use of a preprocessor identifier to optionally ship the tests - MY_LIB_WITH_TESTS. + +== Compile time benchmarks + +So there are 3 types of compile time benchmarks that are relevant for doctest: +- cost of including the header +- cost of assertion macros +- how much the build times drop when all tests are removed with the DOCTEST_CONFIG_DISABLE identifier + +In summary: +- Including the doctest header costs under 10ms compared to 250-460 ms of Catch - so doctest is 25-50 times lighter +- 50 000 asserts compile for roughly 60 seconds which is around 25% faster than Catch +- 50 000 asserts can compile for as low as 30 seconds (or even 10) if alternative assert macros [11] are used (for power users) +- 50 000 asserts spread in 500 test cases just vanish when disabled with DOCTEST_CONFIG_DISABLE - all of it takes less than 2 seconds! + +The lightness of the header was achieved by forward declaring everything and not including anything in the main part of the header. There are includes in the test runner implementation part of the header but that resides in only one translation unit - where the library gets implemented (by defining the DOCTEST_CONFIG_IMPLEMENT preprocessor identifier before including it). + +Regarding the cost of asserts - note that this is for trivial asserts comparing 2 integers - if you need to construct more complex objects and have more setup code for your test cases then there will be an additional amount of time spent compiling - this depends very much on what is being tested. A user of doctest provides a real world example of this in his article [12]. + +In the benchmarks page [10] of the project documentation you can see the setup and more details for the benchmarks. + +== Conclusion + +The doctest framework is really easy to get started with and is fully transparent and unintrusive - including it and writing tests will be unnoticeable both in terms of compile times and integration (warnings, build system, etc). Using it will speed up your development process as much as possible - no other framework is so easy to use! + +Note that Catch 2 is on it's way (not public yet) and when it is released there will be a new set of benchmarks. + +The development of doctest is supported with donations. + +[1] https://github.com/catchorg/Catch2 +[2] http://www.boost.org/doc/libs/1_60_0/libs/test/doc/html/index.html +[3] https://github.com/unittest-cpp/unittest-cpp +[4] https://github.com/cpputest/cpputest +[5] https://github.com/google/googletest +[6] https://en.wikipedia.org/wiki/List_of_unit_testing_frameworks#C.2B.2B +[7] https://github.com/doctest/doctest/blob/master/doc/markdown/faq.md#how-is-doctest-different-from-catch +[8] https://github.com/doctest/doctest/blob/master/doc/markdown/features.md +[9] https://github.com/doctest/doctest/issues/600 +[10] https://github.com/doctest/doctest/blob/master/doc/markdown/benchmarks.md +[11] https://github.com/doctest/doctest/blob/master/doc/markdown/assertions.md#fast-asserts +[12] http://baptiste-wicht.com/posts/2016/09/blazing-fast-unit-test-compilation-with-doctest-11.html diff --git a/dmff/dpnblist/external/doctest-2.4.11/scripts/data/article2.txt b/dmff/dpnblist/external/doctest-2.4.11/scripts/data/article2.txt new file mode 100644 index 00000000..4be1d814 --- /dev/null +++ b/dmff/dpnblist/external/doctest-2.4.11/scripts/data/article2.txt @@ -0,0 +1,153 @@ +== TITLE: Better ways of testing with doctest - the fastest C++ unit testing framework + +doctest [0] is a relatively new C++ testing framework but is by far the fastest both in terms of compile times (by orders of magnitude [1]) and runtime compared to other feature-rich alternatives. It was released in 2016 and has been picking up in popularity [2] ever since. + +A complete example with a self-registering test that compiles to an executable looks like this: + +#define DOCTEST_CONFIG_IMPLEMENT_WITH_MAIN +#include "doctest.h" + +int fact(int n) { + return n <= 1 ? n : fact(n - 1) * n; +} + +TEST_CASE("testing the factorial function") { + CHECK(fact(0) == 1); // should fail + CHECK(fact(1) == 1); + CHECK(fact(2) == 2); + CHECK(fact(3) == 6); + CHECK(fact(10) == 3628800); +} + +There is no need to link to anything - the library is just a single header which depends only on the C++ standard library. The output from that program is the following: + +[doctest] doctest version is "2.3.3" +[doctest] run with "--help" for options +=============================================================================== +hello_world.cpp:8: +TEST CASE: testing the factorial function + +hello_world.cpp:9: ERROR: CHECK( fact(0) == 1 ) is NOT correct! + values: CHECK( 0 == 1 ) + +=============================================================================== +[doctest] test cases: 1 | 0 passed | 1 failed | 0 skipped +[doctest] assertions: 5 | 4 passed | 1 failed | +[doctest] Status: FAILURE! + +A list of some of the important features can be summarized as follows: + +- expression decomposition [3] - use standard comparison operators in asserts instead of having to explicitly say if the assert is for equality, less than, etc. +- thread-safe asserts which can be used in a multi-threaded context [4] +- can be used without exceptions and RTTI [5] +- Subcases [6] - an intuitive way to share common setup and teardown code for test cases (inspired by sections in Catch2) +- crash handling, logging [7], an extensible reporter system [8] (xml, custom), templated test cases [9], test suites [10], decorators [11], a rich command line [12] and many more [13]. + +# What makes doctest interesting + +So far doctest sounds like just another framework with some set of features. What truly sets it apart is the ability to use it alongside your production code. This might seem strange at first but writing your tests right next to the code they are testing is an actual pattern in other languages such as Rust, D, Nim, Python, etc - their unit testing modules let you do exactly that. + +But why is doctest the most suitable C++ framework for this? A few key reasons: + +- Ultra light - less than 20ms of compile time overhead for including the header in a source file [14] +- The fastest possible assertion macros [15] - 50 000 asserts can compile for under 20 seconds (even under 10 sec) +- Offers a way to remove everything testing-related from the binary with the DOCTEST_CONFIG_DISABLE [16] identifier (for the final release builds) +- Doesn't produce any warnings [17] even on the most aggressive levels for MSVC / GCC / Clang +- Very portable [18] and well tested C++11 - per commit tested on CI with over 180 different builds with different compilers and configurations (gcc 4.8-9.1 / clang 3.5-8.0 / MSVC 2015-2019, debug / release, x86/x64, linux / windows / osx, valgrind, sanitizers, static analysis...) + +The idea is that you shouldn't even notice if there are tests in the production code - the compile time penalty is negligible and there aren't any traces of the testing framework (no warnings, no namespace pollution, macros and command line options can be prefixed). The framework can still be used like any other even if the idea of writing tests in the production code doesn't appeal to you - but this is the biggest power of the framework and nothing else comes even close to being so practical in achieving this. Think of the improved workflow: + +- The barrier for writing tests becomes much lower - you won't have to: 1) make a separate source file 2) include a bunch of headers in it 3) add it to the build system 4) add it to source control 5) wait for excessive compile + link times (because your heavy headers would need to be parsed an extra time and the static libraries you link against are a few hundred megabytes...) - You can just write the tests for a class or a piece of functionality at the bottom of its source file (or even header file)! +- Tests in the production code can be thought of as inline documentation - showing how an API is used (correctness enforced by the compiler - always up-to-date). +- Testing internals that are not exposed through the public API and headers becomes easier. + +# Integration within programs + +Having tests next to your production code requires a few things: + +- everything testing-related should be optionally removable from builds +- code and tests should be executable in 3 different scenarios: only the tests, only the program, and both +- programs consisting of an executable + multiple shared objects (.dll/.so/.dylib) should have a single test registry + +The effect of the DOCTEST_CONFIG_DISABLE [16] identifier when defined globally in the entire project is that the TEST_CASE() macro becomes the following: + +#define TEST_CASE(name) template \ + static inline void ANONYMOUS(ANON_FUNC_)() + +There is no instantiation of the anonymous template and there is no test self-registration - the test code will not be present in the final binaries even in Debug. The other effects of this identifier are that asserts within the test case body are turned into noops so even less code is parsed/compiled within these uninstantiated templates, and the test runner is almost entirely removed. Using this identifier is equivalent to not having written any tests - they simply no longer exist. + +And here is an example main() function [19] showing how to foster the 3 execution scenarios when tests are present (also showing how defaults and overrides can be set for command line options [12]): + +#define DOCTEST_CONFIG_IMPLEMENT +#include "doctest.h" + +int main(int argc, char** argv) { + doctest::Context ctx; + + ctx.setOption("abort-after", 5); // default - stop after 5 failed asserts + + ctx.applyCommandLine(argc, argv); // apply command line - argc / argv + + ctx.setOption("no-breaks", true); // override - don't break in the debugger + + int res = ctx.run(); // run test cases unless with --no-run + + if(ctx.shouldExit()) // query flags (and --exit) rely on this + return res; // propagate the result of the tests + + // your actual program execution goes here - only if we haven't exited + + return res; // + your_program_res +} + +With this setup the following 3 scenarios are possible: + +- running only the tests (with the --exit option or just doing a query like listing all test cases) +- running only the user code (with the --no-run option to the test runner) +- running both the tests and the user code + +In the case of programs comprised of multiple binaries (shared objects) the DOCTEST_CONFIG_IMPLEMENTATION_IN_DLL [20] identifier can be used - then only a single binary should provide the test runner implementation. Even plugins which are loaded by the program after it has started will properly register their tests into the registry which should be separated into a common shared library to which every other binary links against (example [21]). + +# Going a step further - using doctest as a general purpose assert library + +Perhaps you use some custom assert for checking preconditions in the actual code. That assert won't play nicely within a testing context (failures won't be handled uniformly) - wouldn't it be nice if we could just use doctest asserts instead? Turns out that's possible [22] - this way a project could have a unified way of asserting invariants both in production code and in test scenarios - with the use of a single set of macros and a single point of configuration! + +All the user has to do is set a doctest::Context object somewhere as the default for asserts outside of a testing context. Asserts will call std::abort on failure but this behavior can be overridden by setting an assert handler - with a call to setAssertHandler() on the context. The handler is a function with the following signature: "void handler(const doctest::AssertData&)" and everything important for the assert can be extracted through the AssertData input. It can choose to abort, throw or even just to log an entry for the failure somewhere - the choice is yours! An example of what that would look like can be seen here [23]. Thankfully doctest is thread-safe [4] - there is nothing stopping us from using the same set of asserts in any context! + +This would be best combined with the use of the binary asserts [24] which are faster for compilation than the normal expression-decomposing ones (less template instantiations). And why not use the DOCTEST_CONFIG_SUPER_FAST_ASSERTS [25] identifier to reach the best possible [26] compile time - turning each assert into a single function call? + +# Conclusion + +Testing is a fundamental aspect of software engineering and the stakes are getting only higher - the world runs entirely on software and the responsibility is placed upon us to develop and enforce standards and procedures in the fastest changing and least mature industry. Using better tools that remove friction in the development process is the best approach towards a more robust and secure future - human nature should never be left out of the equation. + +doctest [0] stands out with its ability to write tests in a new and easier way - unlocking the potential for more thorough, up-to-date and uniform testing. Locality is king not only in CPU caches. There is quite a lot of work left which can be seen in the roadmap [27] - exciting times ahead! If you are curious about implementation details of the framework make sure to checkout the CppCon [28] presentation! + +[0] https://github.com/doctest/doctest +[1] https://github.com/doctest/doctest/blob/master/doc/markdown/benchmarks.md +[2] https://starcharts.herokuapp.com/doctest/doctest +[3] https://github.com/doctest/doctest/blob/master/doc/markdown/assertions.md#expression-decomposing-asserts +[4] https://github.com/doctest/doctest/blob/master/doc/markdown/faq.md#is-doctest-thread-aware +[5] https://github.com/doctest/doctest/blob/master/doc/markdown/configuration.md#doctest_config_no_exceptions +[6] https://github.com/doctest/doctest/blob/master/doc/markdown/tutorial.md#test-cases-and-subcases +[7] https://github.com/doctest/doctest/blob/master/doc/markdown/logging.md +[8] https://github.com/doctest/doctest/blob/master/doc/markdown/reporters.md +[9] https://github.com/doctest/doctest/blob/master/doc/markdown/parameterized-tests.md#templated-test-cases---parameterized-by-type +[10] https://github.com/doctest/doctest/blob/master/doc/markdown/testcases.md#test-suites +[11] https://github.com/doctest/doctest/blob/master/doc/markdown/testcases.md#decorators +[12] https://github.com/doctest/doctest/blob/master/doc/markdown/commandline.md +[13] https://github.com/doctest/doctest/blob/master/doc/markdown/features.md#other-features +[14] https://github.com/doctest/doctest/blob/master/doc/markdown/benchmarks.md#cost-of-including-the-header +[15] https://github.com/doctest/doctest/blob/master/doc/markdown/benchmarks.md#cost-of-an-assertion-macro +[16] https://github.com/doctest/doctest/blob/master/doc/markdown/configuration.md#doctest_config_disable +[17] https://github.com/doctest/doctest/blob/master/doc/markdown/features.md#unintrusive-transparent +[18] https://github.com/doctest/doctest/blob/master/doc/markdown/features.md#extremely-portable +[19] https://github.com/doctest/doctest/blob/master/doc/markdown/main.md +[20] https://github.com/doctest/doctest/blob/master/doc/markdown/configuration.md#doctest_config_implementation_in_dll +[21] https://github.com/doctest/doctest/tree/master/examples/executable_dll_and_plugin +[22] https://github.com/doctest/doctest/blob/master/doc/markdown/assertions.md#using-asserts-out-of-a-testing-context +[23] https://github.com/doctest/doctest/blob/master/examples/all_features/asserts_used_outside_of_tests.cpp#L18 +[24] https://github.com/doctest/doctest/blob/master/doc/markdown/assertions.md#binary-and-unary-asserts +[25] https://github.com/doctest/doctest/blob/master/doc/markdown/configuration.md#doctest_config_super_fast_asserts +[26] https://github.com/doctest/doctest/blob/master/doc/markdown/faq.md#how-to-get-the-best-compile-time-performance-with-the-framework +[27] https://github.com/doctest/doctest/issues/600 +[28] https://www.youtube.com/watch?v=eH1CxEC29l8 diff --git a/dmff/dpnblist/external/doctest-2.4.11/scripts/data/benchmarks/asserts.png b/dmff/dpnblist/external/doctest-2.4.11/scripts/data/benchmarks/asserts.png new file mode 100644 index 00000000..a19bb22b Binary files /dev/null and b/dmff/dpnblist/external/doctest-2.4.11/scripts/data/benchmarks/asserts.png differ diff --git a/dmff/dpnblist/external/doctest-2.4.11/scripts/data/benchmarks/header.png b/dmff/dpnblist/external/doctest-2.4.11/scripts/data/benchmarks/header.png new file mode 100644 index 00000000..2da4465d Binary files /dev/null and b/dmff/dpnblist/external/doctest-2.4.11/scripts/data/benchmarks/header.png differ diff --git a/dmff/dpnblist/external/doctest-2.4.11/scripts/data/benchmarks/implement.png b/dmff/dpnblist/external/doctest-2.4.11/scripts/data/benchmarks/implement.png new file mode 100644 index 00000000..ab2f9845 Binary files /dev/null and b/dmff/dpnblist/external/doctest-2.4.11/scripts/data/benchmarks/implement.png differ diff --git a/dmff/dpnblist/external/doctest-2.4.11/scripts/data/benchmarks/runtime_assert.png b/dmff/dpnblist/external/doctest-2.4.11/scripts/data/benchmarks/runtime_assert.png new file mode 100644 index 00000000..7086429d Binary files /dev/null and b/dmff/dpnblist/external/doctest-2.4.11/scripts/data/benchmarks/runtime_assert.png differ diff --git a/dmff/dpnblist/external/doctest-2.4.11/scripts/data/benchmarks/runtime_info.png b/dmff/dpnblist/external/doctest-2.4.11/scripts/data/benchmarks/runtime_info.png new file mode 100644 index 00000000..78fb911e Binary files /dev/null and b/dmff/dpnblist/external/doctest-2.4.11/scripts/data/benchmarks/runtime_info.png differ diff --git a/dmff/dpnblist/external/doctest-2.4.11/scripts/data/cover.png b/dmff/dpnblist/external/doctest-2.4.11/scripts/data/cover.png new file mode 100644 index 00000000..98a0ed0e Binary files /dev/null and b/dmff/dpnblist/external/doctest-2.4.11/scripts/data/cover.png differ diff --git a/dmff/dpnblist/external/doctest-2.4.11/scripts/data/cover_888px_wide.png b/dmff/dpnblist/external/doctest-2.4.11/scripts/data/cover_888px_wide.png new file mode 100644 index 00000000..8e7427a0 Binary files /dev/null and b/dmff/dpnblist/external/doctest-2.4.11/scripts/data/cover_888px_wide.png differ diff --git a/dmff/dpnblist/external/doctest-2.4.11/scripts/data/initial_release_traffic.png b/dmff/dpnblist/external/doctest-2.4.11/scripts/data/initial_release_traffic.png new file mode 100644 index 00000000..50872111 Binary files /dev/null and b/dmff/dpnblist/external/doctest-2.4.11/scripts/data/initial_release_traffic.png differ diff --git a/dmff/dpnblist/external/doctest-2.4.11/scripts/data/logo/icon_1.svg b/dmff/dpnblist/external/doctest-2.4.11/scripts/data/logo/icon_1.svg new file mode 100644 index 00000000..79f68afb --- /dev/null +++ b/dmff/dpnblist/external/doctest-2.4.11/scripts/data/logo/icon_1.svg @@ -0,0 +1,27 @@ + + + + + + + + + + + + + + + + + diff --git a/dmff/dpnblist/external/doctest-2.4.11/scripts/data/logo/icon_2.svg b/dmff/dpnblist/external/doctest-2.4.11/scripts/data/logo/icon_2.svg new file mode 100644 index 00000000..43561c94 --- /dev/null +++ b/dmff/dpnblist/external/doctest-2.4.11/scripts/data/logo/icon_2.svg @@ -0,0 +1,32 @@ + + + + + + + + + + + + + + + + + + + + + + diff --git a/dmff/dpnblist/external/doctest-2.4.11/scripts/data/logo/icon_3.svg b/dmff/dpnblist/external/doctest-2.4.11/scripts/data/logo/icon_3.svg new file mode 100644 index 00000000..5ae39122 --- /dev/null +++ b/dmff/dpnblist/external/doctest-2.4.11/scripts/data/logo/icon_3.svg @@ -0,0 +1,37 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/dmff/dpnblist/external/doctest-2.4.11/scripts/data/logo/icon_4.svg b/dmff/dpnblist/external/doctest-2.4.11/scripts/data/logo/icon_4.svg new file mode 100644 index 00000000..b265415b --- /dev/null +++ b/dmff/dpnblist/external/doctest-2.4.11/scripts/data/logo/icon_4.svg @@ -0,0 +1,25 @@ + + + + + + + + + + + + + + + + diff --git a/dmff/dpnblist/external/doctest-2.4.11/scripts/data/logo/icon_5.svg b/dmff/dpnblist/external/doctest-2.4.11/scripts/data/logo/icon_5.svg new file mode 100644 index 00000000..895d8492 --- /dev/null +++ b/dmff/dpnblist/external/doctest-2.4.11/scripts/data/logo/icon_5.svg @@ -0,0 +1,32 @@ + + + + + + + + + + + + + + + + + + + + + diff --git a/dmff/dpnblist/external/doctest-2.4.11/scripts/data/logo/icon_6.svg b/dmff/dpnblist/external/doctest-2.4.11/scripts/data/logo/icon_6.svg new file mode 100644 index 00000000..6727eecf --- /dev/null +++ b/dmff/dpnblist/external/doctest-2.4.11/scripts/data/logo/icon_6.svg @@ -0,0 +1,32 @@ + + + + + + + + + + + + + + + + + + + + + diff --git a/dmff/dpnblist/external/doctest-2.4.11/scripts/data/logo/logo_1.svg b/dmff/dpnblist/external/doctest-2.4.11/scripts/data/logo/logo_1.svg new file mode 100644 index 00000000..9fe13b85 --- /dev/null +++ b/dmff/dpnblist/external/doctest-2.4.11/scripts/data/logo/logo_1.svg @@ -0,0 +1,35 @@ + + + + + + + + + + + + + + + + + + + + + + + diff --git a/dmff/dpnblist/external/doctest-2.4.11/scripts/data/logo/logo_2.svg b/dmff/dpnblist/external/doctest-2.4.11/scripts/data/logo/logo_2.svg new file mode 100644 index 00000000..f79d9660 --- /dev/null +++ b/dmff/dpnblist/external/doctest-2.4.11/scripts/data/logo/logo_2.svg @@ -0,0 +1,33 @@ + + + + + + + + + + + + + + + + + + + + + + diff --git a/dmff/dpnblist/external/doctest-2.4.11/scripts/data/logo/logo_3.svg b/dmff/dpnblist/external/doctest-2.4.11/scripts/data/logo/logo_3.svg new file mode 100644 index 00000000..2352abe4 --- /dev/null +++ b/dmff/dpnblist/external/doctest-2.4.11/scripts/data/logo/logo_3.svg @@ -0,0 +1,33 @@ + + + + + + + + + + + + + + + + + + + + + + + diff --git a/dmff/dpnblist/external/doctest-2.4.11/scripts/data/logo/logo_4.svg b/dmff/dpnblist/external/doctest-2.4.11/scripts/data/logo/logo_4.svg new file mode 100644 index 00000000..a03ac16c --- /dev/null +++ b/dmff/dpnblist/external/doctest-2.4.11/scripts/data/logo/logo_4.svg @@ -0,0 +1,33 @@ + + + + + + + + + + + + + + + + + + + + + + + diff --git a/dmff/dpnblist/external/doctest-2.4.11/scripts/data/logo/logo_5.svg b/dmff/dpnblist/external/doctest-2.4.11/scripts/data/logo/logo_5.svg new file mode 100644 index 00000000..4cebe477 --- /dev/null +++ b/dmff/dpnblist/external/doctest-2.4.11/scripts/data/logo/logo_5.svg @@ -0,0 +1,34 @@ + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/dmff/dpnblist/external/doctest-2.4.11/scripts/data/logo/logo_6.svg b/dmff/dpnblist/external/doctest-2.4.11/scripts/data/logo/logo_6.svg new file mode 100644 index 00000000..684c01ae --- /dev/null +++ b/dmff/dpnblist/external/doctest-2.4.11/scripts/data/logo/logo_6.svg @@ -0,0 +1,34 @@ + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/dmff/dpnblist/external/doctest-2.4.11/scripts/data/logo/logo_7.svg b/dmff/dpnblist/external/doctest-2.4.11/scripts/data/logo/logo_7.svg new file mode 100644 index 00000000..3c47e57f --- /dev/null +++ b/dmff/dpnblist/external/doctest-2.4.11/scripts/data/logo/logo_7.svg @@ -0,0 +1,38 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/dmff/dpnblist/external/doctest-2.4.11/scripts/data/using_doctest_888px_wide.gif b/dmff/dpnblist/external/doctest-2.4.11/scripts/data/using_doctest_888px_wide.gif new file mode 100644 index 00000000..7ee9b2cc Binary files /dev/null and b/dmff/dpnblist/external/doctest-2.4.11/scripts/data/using_doctest_888px_wide.gif differ diff --git a/dmff/dpnblist/external/doctest-2.4.11/scripts/data/youtube-cppcon-talk-thumbnail.png b/dmff/dpnblist/external/doctest-2.4.11/scripts/data/youtube-cppcon-talk-thumbnail.png new file mode 100644 index 00000000..b2f0d8da Binary files /dev/null and b/dmff/dpnblist/external/doctest-2.4.11/scripts/data/youtube-cppcon-talk-thumbnail.png differ diff --git a/dmff/dpnblist/external/doctest-2.4.11/scripts/development_only/doctest/doctest.h b/dmff/dpnblist/external/doctest-2.4.11/scripts/development_only/doctest/doctest.h new file mode 100644 index 00000000..9fbd512e --- /dev/null +++ b/dmff/dpnblist/external/doctest-2.4.11/scripts/development_only/doctest/doctest.h @@ -0,0 +1,5 @@ +#include "doctest_fwd.h" +#ifndef DOCTEST_SINGLE_HEADER +#define DOCTEST_SINGLE_HEADER +#endif +#include "doctest.cpp" diff --git a/dmff/dpnblist/external/doctest-2.4.11/scripts/hello_world.cpp b/dmff/dpnblist/external/doctest-2.4.11/scripts/hello_world.cpp new file mode 100644 index 00000000..61d2889c --- /dev/null +++ b/dmff/dpnblist/external/doctest-2.4.11/scripts/hello_world.cpp @@ -0,0 +1,14 @@ +#define DOCTEST_CONFIG_IMPLEMENT_WITH_MAIN +#include "doctest.h" + +int fact(int n) { + return n <= 1 ? n : fact(n - 1) * n; +} + +TEST_CASE("testing the factorial function") { + CHECK(fact(0) == 1); // should fail + CHECK(fact(1) == 1); + CHECK(fact(2) == 2); + CHECK(fact(3) == 6); + CHECK(fact(10) == 3628800); +} diff --git a/dmff/dpnblist/external/doctest-2.4.11/scripts/how_stuff_works/CMakeLists.txt b/dmff/dpnblist/external/doctest-2.4.11/scripts/how_stuff_works/CMakeLists.txt new file mode 100644 index 00000000..ca675c68 --- /dev/null +++ b/dmff/dpnblist/external/doctest-2.4.11/scripts/how_stuff_works/CMakeLists.txt @@ -0,0 +1,6 @@ +cmake_minimum_required(VERSION 3.0) + +project(how_stuff_works) + +add_executable(how_exception_translators_work how_exception_translators_work.cpp) +add_executable(how_subcases_work how_subcases_work.cpp) diff --git a/dmff/dpnblist/external/doctest-2.4.11/scripts/how_stuff_works/how_exception_translators_work.cpp b/dmff/dpnblist/external/doctest-2.4.11/scripts/how_stuff_works/how_exception_translators_work.cpp new file mode 100644 index 00000000..faf5e294 --- /dev/null +++ b/dmff/dpnblist/external/doctest-2.4.11/scripts/how_stuff_works/how_exception_translators_work.cpp @@ -0,0 +1,90 @@ +#include +#include +#include +using namespace std; + +#define CAT_IMPL(s1, s2) s1##s2 +#define CAT(s1, s2) CAT_IMPL(s1, s2) +#define ANONYMOUS(x) CAT(x, __COUNTER__) + +struct ITranslator { + virtual bool translate(string&) = 0; +}; + +template +struct Translator : ITranslator { + Translator(string(*func)(T)) : m_func(func) {} + + bool translate(string& res) { + try { + throw; + } catch(T ex) { + res = m_func(ex); + return true; + } catch(...) { + return false; + } + } + + string(*m_func)(T); +}; + +void regTranslatorImpl(ITranslator* t); // fwd decl + +template +int regTranslator(string(*func)(T)) { + static Translator t(func); + regTranslatorImpl(&t); + return 0; +} + +#define REG_TRANSLATOR_2(name, type) \ + static string name(type); \ + static int ANONYMOUS(TRANS_) = regTranslator(&name); \ + static string name(type) + +#define REG_TRANSLATOR(type) REG_TRANSLATOR_2(ANONYMOUS(TRANS_), type) + +// impl + +vector translators; + +void regTranslatorImpl(ITranslator* t) { + translators.push_back(t); +} + +string translate() { + // try translators + string res; + for(size_t i = 0; i < translators.size(); ++i) + if(translators[i]->translate(res)) + return res; + // proceed with default translation + try { + throw; + } catch(exception& ex) { + return ex.what(); + } catch(string& msg) { + return msg; + } catch(const char* msg) { + return msg; + } catch(...) { + return "Unknown exception!"; + } +} + +// usage + +REG_TRANSLATOR(double& e) { + return string("double: ") + to_string(e); +} + +int main() { + try { + //throw 42; + throw 5.0; + //throw runtime_error("whops!"); + } catch(...) { + cout << translate() << endl; + } +} diff --git a/dmff/dpnblist/external/doctest-2.4.11/scripts/how_stuff_works/how_subcases_work.cpp b/dmff/dpnblist/external/doctest-2.4.11/scripts/how_stuff_works/how_subcases_work.cpp new file mode 100644 index 00000000..06541763 --- /dev/null +++ b/dmff/dpnblist/external/doctest-2.4.11/scripts/how_stuff_works/how_subcases_work.cpp @@ -0,0 +1,116 @@ +/* THE OUTPUT IS: + +creating empty vector ++ 2 +== size: 2 ++ 2 +== size: 4 + +creating empty vector ++ 2 +== size: 2 ++ 1 +== size: 3 + +creating empty vector ++ 1 +== size: 1 + +*/ + +#include +#include +#include + +using namespace std; + +set > passed_subcases; +set entered_levels; +int current_level; +bool has_skipped; + +struct Subcase { + Subcase(const char* file, int line) + : m_entered(false) + , m_file(file) + , m_line(line) + { + m_entered = false; + + // if we have already completed it + if(passed_subcases.count(pair(file, line)) != 0) + return; + + // if a Subcase on the same level has already been entered + if(entered_levels.count(current_level) != 0) { + has_skipped = true; + return; + } + + entered_levels.insert(current_level++); + + m_entered = true; + } + + ~Subcase() { + if(m_entered) { + current_level--; + // only mark the subcase as passed if no subcases have been skipped + if(has_skipped == false) + passed_subcases.insert(pair(m_file, m_line)); + } + } + + operator bool() const { return m_entered; } + + bool m_entered; + const char* m_file; + int m_line; +}; + +#define STR_CONCAT_IMPL(s1, s2) s1##s2 +#define STR_CONCAT(s1, s2) STR_CONCAT_IMPL(s1, s2) +#define ANON_VAR STR_CONCAT(anon, __LINE__) + +#define subcase(title) if(const Subcase& ANON_VAR = Subcase(__FILE__, __LINE__)) + +void test() { + cout << endl << "creating empty vector" << endl; + vector data; + + subcase("size should grow to 2") { + cout << "+ 2" << endl; + data.push_back(42); + data.push_back(10); + cout << "== size: " << data.size() << endl; + + subcase("size should grow to 4") { + cout << "+ 2" << endl; + data.push_back(666); + data.push_back(100); + cout << "== size: " << data.size() << endl; + } + subcase("size should grow to 3") { + cout << "+ 1" << endl; + data.push_back(666); + cout << "== size: " << data.size() << endl; + } + } + subcase("size should grow to 1") { + cout << "+ 1" << endl; + data.push_back(42); + cout << "== size: " << data.size() << endl; + } +} + +int main() { + passed_subcases.clear(); + do { + has_skipped = false; + current_level = 0; + entered_levels.clear(); + test(); + } while(has_skipped == true); + + return 0; +} diff --git a/dmff/dpnblist/external/doctest-2.4.11/scripts/how_stuff_works/testing_crash_scenarios.cpp b/dmff/dpnblist/external/doctest-2.4.11/scripts/how_stuff_works/testing_crash_scenarios.cpp new file mode 100644 index 00000000..407a7d99 --- /dev/null +++ b/dmff/dpnblist/external/doctest-2.4.11/scripts/how_stuff_works/testing_crash_scenarios.cpp @@ -0,0 +1,71 @@ +#define DOCTEST_CONFIG_IMPLEMENT_WITH_MAIN +#include "doctest.h" + +DOCTEST_MAKE_STD_HEADERS_CLEAN_FROM_WARNINGS_ON_WALL_BEGIN +#include +#include +#include +#include +#include +#include +using namespace std; +DOCTEST_MAKE_STD_HEADERS_CLEAN_FROM_WARNINGS_ON_WALL_END + +DOCTEST_GCC_SUPPRESS_WARNING("-Wterminate") +DOCTEST_GCC_SUPPRESS_WARNING("-Wdiv-by-zero") + +DOCTEST_MSVC_SUPPRESS_WARNING(4722) +DOCTEST_MSVC_SUPPRESS_WARNING(4297) +DOCTEST_MSVC_SUPPRESS_WARNING(4723) +DOCTEST_MSVC_SUPPRESS_WARNING(4702) + +// echo %errorlevel% + +#define FROM_A_SEPARATE_THREAD 1 + +TEST_CASE("uncomment to test these out") { + std::function f; + + //for(;;); // infinite loop - to test SIGTERM for CTRL+C ==> doesn't work! + + //SUBCASE("null pointer access") { + // f = []() { std::cout << *static_cast(nullptr); }; + //} + + //SUBCASE("div by zero") { + // f = []() { + // int a = 1; + // --a; + // std::cout << 5 / a; + // }; + //} + + //SUBCASE("call terminate") { + // f = []() { std::terminate(); }; + //} + + //SUBCASE("throw from destructor`") { + // f = []() { + // struct dtor + // { + // ~dtor() { + // //REQUIRE(1 == 2); + // throw 42; + // } + // }; + + // dtor(); + // }; + //} + + //SUBCASE("escaping exception") { + // f = []() { throw 42; }; + //} + +#if FROM_A_SEPARATE_THREAD + std::thread t(f); + t.join(); +#else + f(); +#endif +} diff --git a/dmff/dpnblist/external/doctest-2.4.11/scripts/playground/CMakeLists.txt b/dmff/dpnblist/external/doctest-2.4.11/scripts/playground/CMakeLists.txt new file mode 100644 index 00000000..38a258d0 --- /dev/null +++ b/dmff/dpnblist/external/doctest-2.4.11/scripts/playground/CMakeLists.txt @@ -0,0 +1,7 @@ +add_executable(playground main.cpp test.cpp) +target_link_libraries(playground doctest) + +doctest_add_test(NAME playground NO_OUTPUT COMMAND $ -nv) + +#add_custom_command(TARGET playground POST_BUILD COMMAND $) +#add_custom_command(TARGET playground POST_BUILD COMMAND ctest -C $ --output-on-failure) diff --git a/dmff/dpnblist/external/doctest-2.4.11/scripts/playground/main.cpp b/dmff/dpnblist/external/doctest-2.4.11/scripts/playground/main.cpp new file mode 100644 index 00000000..ae76d3e7 --- /dev/null +++ b/dmff/dpnblist/external/doctest-2.4.11/scripts/playground/main.cpp @@ -0,0 +1,26 @@ +#include "doctest.cpp" + +int main(int argc, char** argv) { + doctest::Context context; + + // !!! THIS IS JUST AN EXAMPLE SHOWING HOW DEFAULTS/OVERRIDES ARE SET !!! + + // defaults + context.addFilter("test-case-exclude", "*math*"); // exclude test cases with "math" in the name + context.setOption("no-breaks", true); // don't break in the debugger when assertions fail + + context.applyCommandLine(argc, argv); + + // overrides + context.setOption("order-by", "file"); // sort the test cases by their name + + int res = context.run(); // run + + if(context.shouldExit()) // important - query flags (and --exit) rely on the user doing this + return res; // propagate the result of the tests + + int client_stuff_return_code = 0; + // your program - if the testing framework is integrated in your production code + + return res + client_stuff_return_code; // the result from doctest is propagated here as well +} diff --git a/dmff/dpnblist/external/doctest-2.4.11/scripts/playground/test.cpp b/dmff/dpnblist/external/doctest-2.4.11/scripts/playground/test.cpp new file mode 100644 index 00000000..7c724268 --- /dev/null +++ b/dmff/dpnblist/external/doctest-2.4.11/scripts/playground/test.cpp @@ -0,0 +1,6 @@ +#include "doctest_fwd.h" + +DOCTEST_MAKE_STD_HEADERS_CLEAN_FROM_WARNINGS_ON_WALL_BEGIN +#include +using namespace std; +DOCTEST_MAKE_STD_HEADERS_CLEAN_FROM_WARNINGS_ON_WALL_END diff --git a/dmff/dpnblist/external/doctest-2.4.11/scripts/random_dev_notes.md b/dmff/dpnblist/external/doctest-2.4.11/scripts/random_dev_notes.md new file mode 100644 index 00000000..85a87c49 --- /dev/null +++ b/dmff/dpnblist/external/doctest-2.4.11/scripts/random_dev_notes.md @@ -0,0 +1,64 @@ + +figure out how to get the filters to the reporter interface so users can access them in any .cpp file (also the list of reporters) + +move down from /Wall to /W4 for Visual Studio... /Wall is absolutely unnecessary and handling it clutters the repository + +https://github.com/catchorg/Catch2/blob/master/docs/tostring.md#catchis_range-specialisation + +add in the faq about the compile errors with stream<<"array" - nikola goranov, also moving to catch undef/define stuffs - use vararg macro, also make the "moving from catch to doctest" easier to find, also this: https://stackoverflow.com/questions/35530850/how-to-require-a-semicolon-after-a-macro/52122660#52122660 + + + +fix discoverability of subcases + look at the subcase filtering and the filter_3 example - the test case is re-entered when in fact it shouldn't have + convoluted to solve - not really important + +https://github.com/catchorg/Catch2/commit/de36b2ada6e4593a9a32c4c86cd47d4bc002b148 + +try to forward declare std::string and specialize the string maker for it or something like that + +UDL literal for approx: Approx operator "" _a(long double val) + +https://github.com/catchorg/Catch2/issues/980 +https://github.com/catchorg/Catch2/commit/00af677577973758b3b35e1c94ab4142c45c3f67 +https://github.com/catchorg/Catch2/commit/11f716f28d6621d1e54cf13374f8b5dd1a7489f5 +https://github.com/catchorg/Catch2/commit/22ac9d2184b3868cccfd635eb631d0eee1529121 +https://github.com/catchorg/Catch2/commit/0b1f1b10030942c38ca8c1b95140b0c65efc903e + +== when making a new release: + +news.ycombinator.com +isocpp.org +reddit.com/r/cpp +reddit.com/r/programming +reddit.com/r/gamedev +reddit.com/r/cplusplus +https://www.linkedin.com/groups/86782/profile +twitter +https://www.linkedin.com/groups/86998/ +https://www.linkedin.com/groups/100895/ +https://www.linkedin.com/groups/1917190/ +https://www.linkedin.com/groups/2771729/ +https://www.linkedin.com/groups/133720/ +https://www.linkedin.com/groups/2526482/ +https://www.viva64.com/en/b/0604/ + +on big releases: update benchmarks, number of CI builds, differences with Catch, docs, etc. + +also check if anything should be added here: +https://github.com/martinmoene/catch-lest-other-comparison + +== how to deal with pull requests for the main branch instead of the dev branch +- https://stackoverflow.com/questions/9135913/merge-pull-request-to-a-different-branch-than-default-in-github +- git fetch origin pull/ID/head:BRANCHNAME << BRANCHNAME should be a new local branch! and then rebase it + +== other +- operator<< trouble + - see how Catch is implementing their IsStreamInsertable trait for C++11 + - https://github.com/catchorg/Catch2/issues/757 + - https://github.com/catchorg/Catch2/issues/872 + - https://github.com/catchorg/Catch2/pull/877 + - https://github.com/catchorg/Catch2/issues/880 + - https://github.com/catchorg/Catch2/pull/1405 +- toString trouble - https://github.com/catchorg/Catch2/issues/741 +- https://github.com/catchorg/Catch2/commit/33ed1773f40b406dbf3b7201bf52694bd86b1503 diff --git a/dmff/dpnblist/external/doctest-2.4.11/scripts/release_process.md b/dmff/dpnblist/external/doctest-2.4.11/scripts/release_process.md new file mode 100644 index 00000000..75274ad4 --- /dev/null +++ b/dmff/dpnblist/external/doctest-2.4.11/scripts/release_process.md @@ -0,0 +1,18 @@ +- update version in version.txt (following semver) +- run update_stuff.py from the scripts folder +- regenerate test output (actually only the `version` test's output changes and that was done to maximize code coverage - might remove it to simplify the release process) + - first run cmake with -DDOCTEST_TEST_MODE=COLLECT + - then run ctest & git add the changed and/or new .txt files +- run changelog generator (WIP) +- commit in dev +- rebase dev onto master (linear history instead of merge commits) +- push all branches (git push --all) +- create github release with the same semver tag as the changelog + - copy the text from a previous release and update the version numbers & dates +- OPTIONAL: update packages (I've never done it) + - vcpkg https://github.com/Microsoft/vcpkg/tree/master/ports/doctest + - hunter + - https://github.com/ruslo/hunter/blob/master/cmake/configs/default.cmake + - https://github.com/ruslo/hunter/blob/master/cmake/projects/doctest/hunter.cmake + - conan + - https://github.com/bincrafters/conan-doctest diff --git a/dmff/dpnblist/external/doctest-2.4.11/scripts/update_stuff.py b/dmff/dpnblist/external/doctest-2.4.11/scripts/update_stuff.py new file mode 100644 index 00000000..1ac36f2b --- /dev/null +++ b/dmff/dpnblist/external/doctest-2.4.11/scripts/update_stuff.py @@ -0,0 +1,44 @@ +#!/usr/bin/python2.7 + +import os +import fileinput + +# the version of the release +with open("version.txt") as f: version = f.read() + +def getVersionTuple(v): + return tuple(map(int, (v.split(".")))) + +version_major = str(getVersionTuple(version)[0]) +version_minor = str(getVersionTuple(version)[1]) +version_patch = str(getVersionTuple(version)[2]) + +# update version in the header file +print("updating the version in the header file") +doctest_contents = "" +for line in fileinput.input(["../doctest/parts/doctest_fwd.h"]): + if line.startswith("#define DOCTEST_VERSION_MAJOR "): + doctest_contents += "#define DOCTEST_VERSION_MAJOR " + version_major + "\n" + elif line.startswith("#define DOCTEST_VERSION_MINOR "): + doctest_contents += "#define DOCTEST_VERSION_MINOR " + version_minor + "\n" + elif line.startswith("#define DOCTEST_VERSION_PATCH "): + doctest_contents += "#define DOCTEST_VERSION_PATCH " + version_patch + "\n" + else: + doctest_contents += line + +readme = open("../doctest/parts/doctest_fwd.h", "w") +readme.write(doctest_contents) +readme.close() + +# update meson file with version +print("updating the meson file") +meson_contents = "" +for line in fileinput.input(["../meson.build"]): + if line.startswith("project('doctest'"): + meson_contents += "project('doctest', ['cpp'], version: '" + version + "')\n" + else: + meson_contents += line + +meson = open("../meson.build", "w") +meson.write(meson_contents) +meson.close() diff --git a/dmff/dpnblist/external/doctest-2.4.11/scripts/version.txt b/dmff/dpnblist/external/doctest-2.4.11/scripts/version.txt new file mode 100644 index 00000000..e393c3c5 --- /dev/null +++ b/dmff/dpnblist/external/doctest-2.4.11/scripts/version.txt @@ -0,0 +1 @@ +2.4.11 \ No newline at end of file diff --git a/dmff/dpnblist/external/pybind11-2.11.1/.appveyor.yml b/dmff/dpnblist/external/pybind11-2.11.1/.appveyor.yml new file mode 100644 index 00000000..360760ac --- /dev/null +++ b/dmff/dpnblist/external/pybind11-2.11.1/.appveyor.yml @@ -0,0 +1,35 @@ +version: 1.0.{build} +image: +- Visual Studio 2017 +test: off +skip_branch_with_pr: true +build: + parallel: true +platform: +- x86 +environment: + matrix: + - PYTHON: 36 + CONFIG: Debug +install: +- ps: | + $env:CMAKE_GENERATOR = "Visual Studio 15 2017" + if ($env:PLATFORM -eq "x64") { $env:PYTHON = "$env:PYTHON-x64" } + $env:PATH = "C:\Python$env:PYTHON\;C:\Python$env:PYTHON\Scripts\;$env:PATH" + python -W ignore -m pip install --upgrade pip wheel + python -W ignore -m pip install pytest numpy --no-warn-script-location pytest-timeout +- ps: | + Start-FileDownload 'https://gitlab.com/libeigen/eigen/-/archive/3.3.7/eigen-3.3.7.zip' + 7z x eigen-3.3.7.zip -y > $null + $env:CMAKE_INCLUDE_PATH = "eigen-3.3.7;$env:CMAKE_INCLUDE_PATH" +build_script: +- cmake -G "%CMAKE_GENERATOR%" -A "%CMAKE_ARCH%" + -DCMAKE_CXX_STANDARD=14 + -DPYBIND11_WERROR=ON + -DDOWNLOAD_CATCH=ON + -DCMAKE_SUPPRESS_REGENERATION=1 + . +- set MSBuildLogger="C:\Program Files\AppVeyor\BuildAgent\Appveyor.MSBuildLogger.dll" +- cmake --build . --config %CONFIG% --target pytest -- /m /v:m /logger:%MSBuildLogger% +- cmake --build . --config %CONFIG% --target cpptest -- /m /v:m /logger:%MSBuildLogger% +on_failure: if exist "tests\test_cmake_build" type tests\test_cmake_build\*.log* diff --git a/dmff/dpnblist/external/pybind11-2.11.1/.clang-format b/dmff/dpnblist/external/pybind11-2.11.1/.clang-format new file mode 100644 index 00000000..b477a160 --- /dev/null +++ b/dmff/dpnblist/external/pybind11-2.11.1/.clang-format @@ -0,0 +1,38 @@ +--- +# See all possible options and defaults with: +# clang-format --style=llvm --dump-config +BasedOnStyle: LLVM +AccessModifierOffset: -4 +AllowShortLambdasOnASingleLine: true +AlwaysBreakTemplateDeclarations: Yes +BinPackArguments: false +BinPackParameters: false +BreakBeforeBinaryOperators: All +BreakConstructorInitializers: BeforeColon +ColumnLimit: 99 +CommentPragmas: 'NOLINT:.*|^ IWYU pragma:' +IncludeBlocks: Regroup +IndentCaseLabels: true +IndentPPDirectives: AfterHash +IndentWidth: 4 +Language: Cpp +SpaceAfterCStyleCast: true +Standard: Cpp11 +StatementMacros: ['PyObject_HEAD'] +TabWidth: 4 +IncludeCategories: + - Regex: '' + Priority: 4 + - Regex: '.*' + Priority: 5 +... diff --git a/dmff/dpnblist/external/pybind11-2.11.1/.clang-tidy b/dmff/dpnblist/external/pybind11-2.11.1/.clang-tidy new file mode 100644 index 00000000..23018386 --- /dev/null +++ b/dmff/dpnblist/external/pybind11-2.11.1/.clang-tidy @@ -0,0 +1,77 @@ +FormatStyle: file + +Checks: | + *bugprone*, + *performance*, + clang-analyzer-optin.cplusplus.VirtualCall, + clang-analyzer-optin.performance.Padding, + cppcoreguidelines-init-variables, + cppcoreguidelines-prefer-member-initializer, + cppcoreguidelines-pro-type-static-cast-downcast, + cppcoreguidelines-slicing, + google-explicit-constructor, + llvm-namespace-comment, + misc-definitions-in-headers, + misc-misplaced-const, + misc-non-copyable-objects, + misc-static-assert, + misc-throw-by-value-catch-by-reference, + misc-uniqueptr-reset-release, + misc-unused-parameters, + modernize-avoid-bind, + modernize-loop-convert, + modernize-make-shared, + modernize-redundant-void-arg, + modernize-replace-auto-ptr, + modernize-replace-disallow-copy-and-assign-macro, + modernize-replace-random-shuffle, + modernize-shrink-to-fit, + modernize-use-auto, + modernize-use-bool-literals, + modernize-use-default-member-init, + modernize-use-emplace, + modernize-use-equals-default, + modernize-use-equals-delete, + modernize-use-noexcept, + modernize-use-nullptr, + modernize-use-override, + modernize-use-using, + readability-avoid-const-params-in-decls, + readability-braces-around-statements, + readability-const-return-type, + readability-container-size-empty, + readability-delete-null-pointer, + readability-else-after-return, + readability-implicit-bool-conversion, + readability-inconsistent-declaration-parameter-name, + readability-make-member-function-const, + readability-misplaced-array-index, + readability-non-const-parameter, + readability-qualified-auto, + readability-redundant-function-ptr-dereference, + readability-redundant-smartptr-get, + readability-redundant-string-cstr, + readability-simplify-subscript-expr, + readability-static-accessed-through-instance, + readability-static-definition-in-anonymous-namespace, + readability-string-compare, + readability-suspicious-call-argument, + readability-uniqueptr-delete-release, + -bugprone-easily-swappable-parameters, + -bugprone-exception-escape, + -bugprone-reserved-identifier, + -bugprone-unused-raii, + +CheckOptions: +- key: modernize-use-equals-default.IgnoreMacros + value: false +- key: performance-for-range-copy.WarnOnAllAutoCopies + value: true +- key: performance-inefficient-string-concatenation.StrictMode + value: true +- key: performance-unnecessary-value-param.AllowedTypes + value: 'exception_ptr$;' +- key: readability-implicit-bool-conversion.AllowPointerConditions + value: true + +HeaderFilterRegex: 'pybind11/.*h' diff --git a/dmff/dpnblist/external/pybind11-2.11.1/.cmake-format.yaml b/dmff/dpnblist/external/pybind11-2.11.1/.cmake-format.yaml new file mode 100644 index 00000000..a2a69f3f --- /dev/null +++ b/dmff/dpnblist/external/pybind11-2.11.1/.cmake-format.yaml @@ -0,0 +1,73 @@ +parse: + additional_commands: + pybind11_add_module: + flags: + - THIN_LTO + - MODULE + - SHARED + - NO_EXTRAS + - EXCLUDE_FROM_ALL + - SYSTEM + +format: + line_width: 99 + tab_size: 2 + + # If an argument group contains more than this many sub-groups + # (parg or kwarg groups) then force it to a vertical layout. + max_subgroups_hwrap: 2 + + # If a positional argument group contains more than this many + # arguments, then force it to a vertical layout. + max_pargs_hwrap: 6 + + # If a cmdline positional group consumes more than this many + # lines without nesting, then invalidate the layout (and nest) + max_rows_cmdline: 2 + separate_ctrl_name_with_space: false + separate_fn_name_with_space: false + dangle_parens: false + + # If the trailing parenthesis must be 'dangled' on its on + # 'line, then align it to this reference: `prefix`: the start' + # 'of the statement, `prefix-indent`: the start of the' + # 'statement, plus one indentation level, `child`: align to' + # the column of the arguments + dangle_align: prefix + # If the statement spelling length (including space and + # parenthesis) is smaller than this amount, then force reject + # nested layouts. + min_prefix_chars: 4 + + # If the statement spelling length (including space and + # parenthesis) is larger than the tab width by more than this + # amount, then force reject un-nested layouts. + max_prefix_chars: 10 + + # If a candidate layout is wrapped horizontally but it exceeds + # this many lines, then reject the layout. + max_lines_hwrap: 2 + + line_ending: unix + + # Format command names consistently as 'lower' or 'upper' case + command_case: canonical + + # Format keywords consistently as 'lower' or 'upper' case + # unchanged is valid too + keyword_case: 'upper' + + # A list of command names which should always be wrapped + always_wrap: [] + + # If true, the argument lists which are known to be sortable + # will be sorted lexicographically + enable_sort: true + + # If true, the parsers may infer whether or not an argument + # list is sortable (without annotation). + autosort: false + +# Causes a few issues - can be solved later, possibly. +markup: + enable_markup: false diff --git a/dmff/dpnblist/external/pybind11-2.11.1/.codespell-ignore-lines b/dmff/dpnblist/external/pybind11-2.11.1/.codespell-ignore-lines new file mode 100644 index 00000000..2a01d63e --- /dev/null +++ b/dmff/dpnblist/external/pybind11-2.11.1/.codespell-ignore-lines @@ -0,0 +1,24 @@ +template + template + auto &this_ = static_cast(*this); + if (load_impl(temp, false)) { + ssize_t nd = 0; + auto trivial = broadcast(buffers, nd, shape); + auto ndim = (size_t) nd; + int nd; + ssize_t ndim() const { return detail::array_proxy(m_ptr)->nd; } + using op = op_impl; +template + template + class_ &def(const detail::op_ &op, const Extra &...extra) { + class_ &def_cast(const detail::op_ &op, const Extra &...extra) { +@pytest.mark.parametrize("access", ["ro", "rw", "static_ro", "static_rw"]) +struct IntStruct { + explicit IntStruct(int v) : value(v){}; + ~IntStruct() { value = -value; } + IntStruct(const IntStruct &) = default; + IntStruct &operator=(const IntStruct &) = default; + py::class_(m, "IntStruct").def(py::init([](const int i) { return IntStruct(i); })); + py::implicitly_convertible(); + m.def("test", [](int expected, const IntStruct &in) { + [](int expected, const IntStruct &in) { diff --git a/dmff/dpnblist/external/pybind11-2.11.1/.gitattributes b/dmff/dpnblist/external/pybind11-2.11.1/.gitattributes new file mode 100644 index 00000000..d611e149 --- /dev/null +++ b/dmff/dpnblist/external/pybind11-2.11.1/.gitattributes @@ -0,0 +1 @@ +docs/*.svg binary diff --git a/dmff/dpnblist/external/pybind11-2.11.1/.github/CODEOWNERS b/dmff/dpnblist/external/pybind11-2.11.1/.github/CODEOWNERS new file mode 100644 index 00000000..4e2c6690 --- /dev/null +++ b/dmff/dpnblist/external/pybind11-2.11.1/.github/CODEOWNERS @@ -0,0 +1,9 @@ +*.cmake @henryiii +CMakeLists.txt @henryiii +*.yml @henryiii +*.yaml @henryiii +/tools/ @henryiii +/pybind11/ @henryiii +noxfile.py @henryiii +.clang-format @henryiii +.clang-tidy @henryiii diff --git a/dmff/dpnblist/external/pybind11-2.11.1/.github/CONTRIBUTING.md b/dmff/dpnblist/external/pybind11-2.11.1/.github/CONTRIBUTING.md new file mode 100644 index 00000000..ad797439 --- /dev/null +++ b/dmff/dpnblist/external/pybind11-2.11.1/.github/CONTRIBUTING.md @@ -0,0 +1,388 @@ +Thank you for your interest in this project! Please refer to the following +sections on how to contribute code and bug reports. + +### Reporting bugs + +Before submitting a question or bug report, please take a moment of your time +and ensure that your issue isn't already discussed in the project documentation +provided at [pybind11.readthedocs.org][] or in the [issue tracker][]. You can +also check [gitter][] to see if it came up before. + +Assuming that you have identified a previously unknown problem or an important +question, it's essential that you submit a self-contained and minimal piece of +code that reproduces the problem. In other words: no external dependencies, +isolate the function(s) that cause breakage, submit matched and complete C++ +and Python snippets that can be easily compiled and run in isolation; or +ideally make a small PR with a failing test case that can be used as a starting +point. + +## Pull requests + +Contributions are submitted, reviewed, and accepted using GitHub pull requests. +Please refer to [this article][using pull requests] for details and adhere to +the following rules to make the process as smooth as possible: + +* Make a new branch for every feature you're working on. +* Make small and clean pull requests that are easy to review but make sure they + do add value by themselves. +* Add tests for any new functionality and run the test suite (`cmake --build + build --target pytest`) to ensure that no existing features break. +* Please run [`pre-commit`][pre-commit] to check your code matches the + project style. (Note that `gawk` is required.) Use `pre-commit run + --all-files` before committing (or use installed-mode, check pre-commit docs) + to verify your code passes before pushing to save time. +* This project has a strong focus on providing general solutions using a + minimal amount of code, thus small pull requests are greatly preferred. + +### Licensing of contributions + +pybind11 is provided under a BSD-style license that can be found in the +``LICENSE`` file. By using, distributing, or contributing to this project, you +agree to the terms and conditions of this license. + +You are under no obligation whatsoever to provide any bug fixes, patches, or +upgrades to the features, functionality or performance of the source code +("Enhancements") to anyone; however, if you choose to make your Enhancements +available either publicly, or directly to the author of this software, without +imposing a separate written license agreement for such Enhancements, then you +hereby grant the following license: a non-exclusive, royalty-free perpetual +license to install, use, modify, prepare derivative works, incorporate into +other computer software, distribute, and sublicense such enhancements or +derivative works thereof, in binary and source code form. + + +## Development of pybind11 + +### Quick setup + +To setup a quick development environment, use [`nox`](https://nox.thea.codes). +This will allow you to do some common tasks with minimal setup effort, but will +take more time to run and be less flexible than a full development environment. +If you use [`pipx run nox`](https://pipx.pypa.io), you don't even need to +install `nox`. Examples: + +```bash +# List all available sessions +nox -l + +# Run linters +nox -s lint + +# Run tests on Python 3.9 +nox -s tests-3.9 + +# Build and preview docs +nox -s docs -- serve + +# Build SDists and wheels +nox -s build +``` + +### Full setup + +To setup an ideal development environment, run the following commands on a +system with CMake 3.14+: + +```bash +python3 -m venv venv +source venv/bin/activate +pip install -r tests/requirements.txt +cmake -S . -B build -DDOWNLOAD_CATCH=ON -DDOWNLOAD_EIGEN=ON +cmake --build build -j4 +``` + +Tips: + +* You can use `virtualenv` (faster, from PyPI) instead of `venv`. +* You can select any name for your environment folder; if it contains "env" it + will be ignored by git. +* If you don't have CMake 3.14+, just add "cmake" to the pip install command. +* You can use `-DPYBIND11_FINDPYTHON=ON` to use FindPython on CMake 3.12+ +* In classic mode, you may need to set `-DPYTHON_EXECUTABLE=/path/to/python`. + FindPython uses `-DPython_ROOT_DIR=/path/to` or + `-DPython_EXECUTABLE=/path/to/python`. + +### Configuration options + +In CMake, configuration options are given with "-D". Options are stored in the +build directory, in the `CMakeCache.txt` file, so they are remembered for each +build directory. Two selections are special - the generator, given with `-G`, +and the compiler, which is selected based on environment variables `CXX` and +similar, or `-DCMAKE_CXX_COMPILER=`. Unlike the others, these cannot be changed +after the initial run. + +The valid options are: + +* `-DCMAKE_BUILD_TYPE`: Release, Debug, MinSizeRel, RelWithDebInfo +* `-DPYBIND11_FINDPYTHON=ON`: Use CMake 3.12+'s FindPython instead of the + classic, deprecated, custom FindPythonLibs +* `-DPYBIND11_NOPYTHON=ON`: Disable all Python searching (disables tests) +* `-DBUILD_TESTING=ON`: Enable the tests +* `-DDOWNLOAD_CATCH=ON`: Download catch to build the C++ tests +* `-DDOWNLOAD_EIGEN=ON`: Download Eigen for the NumPy tests +* `-DPYBIND11_INSTALL=ON/OFF`: Enable the install target (on by default for the + master project) +* `-DUSE_PYTHON_INSTALL_DIR=ON`: Try to install into the python dir + + +
A few standard CMake tricks: (click to expand)

+ +* Use `cmake --build build -v` to see the commands used to build the files. +* Use `cmake build -LH` to list the CMake options with help. +* Use `ccmake` if available to see a curses (terminal) gui, or `cmake-gui` for + a completely graphical interface (not present in the PyPI package). +* Use `cmake --build build -j12` to build with 12 cores (for example). +* Use `-G` and the name of a generator to use something different. `cmake + --help` lists the generators available. + - On Unix, setting `CMAKE_GENERATER=Ninja` in your environment will give + you automatic mulithreading on all your CMake projects! +* Open the `CMakeLists.txt` with QtCreator to generate for that IDE. +* You can use `-DCMAKE_EXPORT_COMPILE_COMMANDS=ON` to generate the `.json` file + that some tools expect. + +

+ + +To run the tests, you can "build" the check target: + +```bash +cmake --build build --target check +``` + +`--target` can be spelled `-t` in CMake 3.15+. You can also run individual +tests with these targets: + +* `pytest`: Python tests only, using the +[pytest](https://docs.pytest.org/en/stable/) framework +* `cpptest`: C++ tests only +* `test_cmake_build`: Install / subdirectory tests + +If you want to build just a subset of tests, use +`-DPYBIND11_TEST_OVERRIDE="test_callbacks;test_pickling"`. If this is +empty, all tests will be built. Tests are specified without an extension if they need both a .py and +.cpp file. + +You may also pass flags to the `pytest` target by editing `tests/pytest.ini` or +by using the `PYTEST_ADDOPTS` environment variable +(see [`pytest` docs](https://docs.pytest.org/en/2.7.3/customize.html#adding-default-options)). As an example: + +```bash +env PYTEST_ADDOPTS="--capture=no --exitfirst" \ + cmake --build build --target pytest +# Or using abbreviated flags +env PYTEST_ADDOPTS="-s -x" cmake --build build --target pytest +``` + +### Formatting + +All formatting is handled by pre-commit. + +Install with brew (macOS) or pip (any OS): + +```bash +# Any OS +python3 -m pip install pre-commit + +# OR macOS with homebrew: +brew install pre-commit +``` + +Then, you can run it on the items you've added to your staging area, or all +files: + +```bash +pre-commit run +# OR +pre-commit run --all-files +``` + +And, if you want to always use it, you can install it as a git hook (hence the +name, pre-commit): + +```bash +pre-commit install +``` + +### Clang-Format + +As of v2.6.2, pybind11 ships with a [`clang-format`][clang-format] +configuration file at the top level of the repo (the filename is +`.clang-format`). Currently, formatting is NOT applied automatically, but +manually using `clang-format` for newly developed files is highly encouraged. +To check if a file needs formatting: + +```bash +clang-format -style=file --dry-run some.cpp +``` + +The output will show things to be fixed, if any. To actually format the file: + +```bash +clang-format -style=file -i some.cpp +``` + +Note that the `-style-file` option searches the parent directories for the +`.clang-format` file, i.e. the commands above can be run in any subdirectory +of the pybind11 repo. + +### Clang-Tidy + +[`clang-tidy`][clang-tidy] performs deeper static code analyses and is +more complex to run, compared to `clang-format`, but support for `clang-tidy` +is built into the pybind11 CMake configuration. To run `clang-tidy`, the +following recipe should work. Run the `docker` command from the top-level +directory inside your pybind11 git clone. Files will be modified in place, +so you can use git to monitor the changes. + +```bash +docker run --rm -v $PWD:/mounted_pybind11 -it silkeh/clang:15-bullseye +apt-get update && apt-get install -y git python3-dev python3-pytest +cmake -S /mounted_pybind11/ -B build -DCMAKE_CXX_CLANG_TIDY="$(which clang-tidy);--use-color" -DDOWNLOAD_EIGEN=ON -DDOWNLOAD_CATCH=ON -DCMAKE_CXX_STANDARD=17 +cmake --build build -j 2 +``` + +You can add `--fix` to the options list if you want. + +### Include what you use + +To run include what you use, install (`brew install include-what-you-use` on +macOS), then run: + +```bash +cmake -S . -B build-iwyu -DCMAKE_CXX_INCLUDE_WHAT_YOU_USE=$(which include-what-you-use) +cmake --build build +``` + +The report is sent to stderr; you can pipe it into a file if you wish. + +### Build recipes + +This builds with the Intel compiler (assuming it is in your path, along with a +recent CMake and Python): + +```bash +python3 -m venv venv +. venv/bin/activate +pip install pytest +cmake -S . -B build-intel -DCMAKE_CXX_COMPILER=$(which icpc) -DDOWNLOAD_CATCH=ON -DDOWNLOAD_EIGEN=ON -DPYBIND11_WERROR=ON +``` + +This will test the PGI compilers: + +```bash +docker run --rm -it -v $PWD:/pybind11 nvcr.io/hpc/pgi-compilers:ce +apt-get update && apt-get install -y python3-dev python3-pip python3-pytest +wget -qO- "https://cmake.org/files/v3.18/cmake-3.18.2-Linux-x86_64.tar.gz" | tar --strip-components=1 -xz -C /usr/local +cmake -S pybind11/ -B build +cmake --build build +``` + +### Explanation of the SDist/wheel building design + +> These details below are _only_ for packaging the Python sources from git. The +> SDists and wheels created do not have any extra requirements at all and are +> completely normal. + +The main objective of the packaging system is to create SDists (Python's source +distribution packages) and wheels (Python's binary distribution packages) that +include everything that is needed to work with pybind11, and which can be +installed without any additional dependencies. This is more complex than it +appears: in order to support CMake as a first class language even when using +the PyPI package, they must include the _generated_ CMake files (so as not to +require CMake when installing the `pybind11` package itself). They should also +provide the option to install to the "standard" location +(`/include/pybind11` and `/share/cmake/pybind11`) so they are +easy to find with CMake, but this can cause problems if you are not an +environment or using ``pyproject.toml`` requirements. This was solved by having +two packages; the "nice" pybind11 package that stores the includes and CMake +files inside the package, that you get access to via functions in the package, +and a `pybind11-global` package that can be included via `pybind11[global]` if +you want the more invasive but discoverable file locations. + +If you want to install or package the GitHub source, it is best to have Pip 10 +or newer on Windows, macOS, or Linux (manylinux1 compatible, includes most +distributions). You can then build the SDists, or run any procedure that makes +SDists internally, like making wheels or installing. + + +```bash +# Editable development install example +python3 -m pip install -e . +``` + +Since Pip itself does not have an `sdist` command (it does have `wheel` and +`install`), you may want to use the upcoming `build` package: + +```bash +python3 -m pip install build + +# Normal package +python3 -m build -s . + +# Global extra +PYBIND11_GLOBAL_SDIST=1 python3 -m build -s . +``` + +If you want to use the classic "direct" usage of `python setup.py`, you will +need CMake 3.15+ and either `make` or `ninja` preinstalled (possibly via `pip +install cmake ninja`), since directly running Python on `setup.py` cannot pick +up and install `pyproject.toml` requirements. As long as you have those two +things, though, everything works the way you would expect: + +```bash +# Normal package +python3 setup.py sdist + +# Global extra +PYBIND11_GLOBAL_SDIST=1 python3 setup.py sdist +``` + +A detailed explanation of the build procedure design for developers wanting to +work on or maintain the packaging system is as follows: + +#### 1. Building from the source directory + +When you invoke any `setup.py` command from the source directory, including +`pip wheel .` and `pip install .`, you will activate a full source build. This +is made of the following steps: + +1. If the tool is PEP 518 compliant, like Pip 10+, it will create a temporary + virtual environment and install the build requirements (mostly CMake) into + it. (if you are not on Windows, macOS, or a manylinux compliant system, you + can disable this with `--no-build-isolation` as long as you have CMake 3.15+ + installed) +2. The environment variable `PYBIND11_GLOBAL_SDIST` is checked - if it is set + and truthy, this will be make the accessory `pybind11-global` package, + instead of the normal `pybind11` package. This package is used for + installing the files directly to your environment root directory, using + `pybind11[global]`. +2. `setup.py` reads the version from `pybind11/_version.py` and verifies it + matches `includes/pybind11/detail/common.h`. +3. CMake is run with `-DCMAKE_INSTALL_PREIFX=pybind11`. Since the CMake install + procedure uses only relative paths and is identical on all platforms, these + files are valid as long as they stay in the correct relative position to the + includes. `pybind11/share/cmake/pybind11` has the CMake files, and + `pybind11/include` has the includes. The build directory is discarded. +4. Simpler files are placed in the SDist: `tools/setup_*.py.in`, + `tools/pyproject.toml` (`main` or `global`) +5. The package is created by running the setup function in the + `tools/setup_*.py`. `setup_main.py` fills in Python packages, and + `setup_global.py` fills in only the data/header slots. +6. A context manager cleans up the temporary CMake install directory (even if + an error is thrown). + +### 2. Building from SDist + +Since the SDist has the rendered template files in `tools` along with the +includes and CMake files in the correct locations, the builds are completely +trivial and simple. No extra requirements are required. You can even use Pip 9 +if you really want to. + + +[pre-commit]: https://pre-commit.com +[clang-format]: https://clang.llvm.org/docs/ClangFormat.html +[clang-tidy]: https://clang.llvm.org/extra/clang-tidy/ +[pybind11.readthedocs.org]: http://pybind11.readthedocs.org/en/latest +[issue tracker]: https://github.com/pybind/pybind11/issues +[gitter]: https://gitter.im/pybind/Lobby +[using pull requests]: https://help.github.com/articles/using-pull-requests diff --git a/dmff/dpnblist/external/pybind11-2.11.1/.github/ISSUE_TEMPLATE/bug-report.yml b/dmff/dpnblist/external/pybind11-2.11.1/.github/ISSUE_TEMPLATE/bug-report.yml new file mode 100644 index 00000000..4f1e78f3 --- /dev/null +++ b/dmff/dpnblist/external/pybind11-2.11.1/.github/ISSUE_TEMPLATE/bug-report.yml @@ -0,0 +1,61 @@ +name: Bug Report +description: File an issue about a bug +title: "[BUG]: " +labels: [triage] +body: + - type: markdown + attributes: + value: | + Please do your best to make the issue as easy to act on as possible, and only submit here if there is clearly a problem with pybind11 (ask first if unsure). **Note that a reproducer in a PR is much more likely to get immediate attention.** + + - type: checkboxes + id: steps + attributes: + label: Required prerequisites + description: Make sure you've completed the following steps before submitting your issue -- thank you! + options: + - label: Make sure you've read the [documentation](https://pybind11.readthedocs.io). Your issue may be addressed there. + required: true + - label: Search the [issue tracker](https://github.com/pybind/pybind11/issues) and [Discussions](https:/pybind/pybind11/discussions) to verify that this hasn't already been reported. +1 or comment there if it has. + required: true + - label: Consider asking first in the [Gitter chat room](https://gitter.im/pybind/Lobby) or in a [Discussion](https:/pybind/pybind11/discussions/new). + required: false + + - type: input + id: version + attributes: + label: What version (or hash if on master) of pybind11 are you using? + validations: + required: true + + - type: textarea + id: description + attributes: + label: Problem description + placeholder: >- + Provide a short description, state the expected behavior and what + actually happens. Include relevant information like what version of + pybind11 you are using, what system you are on, and any useful commands + / output. + validations: + required: true + + - type: textarea + id: code + attributes: + label: Reproducible example code + placeholder: >- + The code should be minimal, have no external dependencies, isolate the + function(s) that cause breakage. Submit matched and complete C++ and + Python snippets that can be easily compiled and run to diagnose the + issue. — Note that a reproducer in a PR is much more likely to get + immediate attention: failing tests in the pybind11 CI are the best + starting point for working out fixes. + render: text + + - type: input + id: regression + attributes: + label: Is this a regression? Put the last known working version here if it is. + description: Put the last known working version here if this is a regression. + value: Not a regression diff --git a/dmff/dpnblist/external/pybind11-2.11.1/.github/ISSUE_TEMPLATE/config.yml b/dmff/dpnblist/external/pybind11-2.11.1/.github/ISSUE_TEMPLATE/config.yml new file mode 100644 index 00000000..27f9a804 --- /dev/null +++ b/dmff/dpnblist/external/pybind11-2.11.1/.github/ISSUE_TEMPLATE/config.yml @@ -0,0 +1,8 @@ +blank_issues_enabled: false +contact_links: + - name: Ask a question + url: https://github.com/pybind/pybind11/discussions/new + about: Please ask and answer questions here, or propose new ideas. + - name: Gitter room + url: https://gitter.im/pybind/Lobby + about: A room for discussing pybind11 with an active community diff --git a/dmff/dpnblist/external/pybind11-2.11.1/.github/dependabot.yml b/dmff/dpnblist/external/pybind11-2.11.1/.github/dependabot.yml new file mode 100644 index 00000000..2c7d1708 --- /dev/null +++ b/dmff/dpnblist/external/pybind11-2.11.1/.github/dependabot.yml @@ -0,0 +1,7 @@ +version: 2 +updates: + # Maintain dependencies for GitHub Actions + - package-ecosystem: "github-actions" + directory: "/" + schedule: + interval: "daily" diff --git a/dmff/dpnblist/external/pybind11-2.11.1/.github/labeler.yml b/dmff/dpnblist/external/pybind11-2.11.1/.github/labeler.yml new file mode 100644 index 00000000..abb0d05a --- /dev/null +++ b/dmff/dpnblist/external/pybind11-2.11.1/.github/labeler.yml @@ -0,0 +1,8 @@ +docs: +- any: + - 'docs/**/*.rst' + - '!docs/changelog.rst' + - '!docs/upgrade.rst' + +ci: +- '.github/workflows/*.yml' diff --git a/dmff/dpnblist/external/pybind11-2.11.1/.github/labeler_merged.yml b/dmff/dpnblist/external/pybind11-2.11.1/.github/labeler_merged.yml new file mode 100644 index 00000000..2374ad42 --- /dev/null +++ b/dmff/dpnblist/external/pybind11-2.11.1/.github/labeler_merged.yml @@ -0,0 +1,3 @@ +needs changelog: +- all: + - '!docs/changelog.rst' diff --git a/dmff/dpnblist/external/pybind11-2.11.1/.github/matchers/pylint.json b/dmff/dpnblist/external/pybind11-2.11.1/.github/matchers/pylint.json new file mode 100644 index 00000000..e3a6bd16 --- /dev/null +++ b/dmff/dpnblist/external/pybind11-2.11.1/.github/matchers/pylint.json @@ -0,0 +1,32 @@ +{ + "problemMatcher": [ + { + "severity": "warning", + "pattern": [ + { + "regexp": "^([^:]+):(\\d+):(\\d+): ([A-DF-Z]\\d+): \\033\\[[\\d;]+m([^\\033]+).*$", + "file": 1, + "line": 2, + "column": 3, + "code": 4, + "message": 5 + } + ], + "owner": "pylint-warning" + }, + { + "severity": "error", + "pattern": [ + { + "regexp": "^([^:]+):(\\d+):(\\d+): (E\\d+): \\033\\[[\\d;]+m([^\\033]+).*$", + "file": 1, + "line": 2, + "column": 3, + "code": 4, + "message": 5 + } + ], + "owner": "pylint-error" + } + ] +} diff --git a/dmff/dpnblist/external/pybind11-2.11.1/.github/pull_request_template.md b/dmff/dpnblist/external/pybind11-2.11.1/.github/pull_request_template.md new file mode 100644 index 00000000..54b7f510 --- /dev/null +++ b/dmff/dpnblist/external/pybind11-2.11.1/.github/pull_request_template.md @@ -0,0 +1,19 @@ + +## Description + + + + +## Suggested changelog entry: + + + +```rst + +``` + + diff --git a/dmff/dpnblist/external/pybind11-2.11.1/.github/workflows/ci.yml b/dmff/dpnblist/external/pybind11-2.11.1/.github/workflows/ci.yml new file mode 100644 index 00000000..48f7c5e9 --- /dev/null +++ b/dmff/dpnblist/external/pybind11-2.11.1/.github/workflows/ci.yml @@ -0,0 +1,1165 @@ +name: CI + +on: + workflow_dispatch: + pull_request: + push: + branches: + - master + - stable + - v* + +permissions: read-all + +concurrency: + group: test-${{ github.ref }} + cancel-in-progress: true + +env: + PIP_BREAK_SYSTEM_PACKAGES: 1 + PIP_ONLY_BINARY: numpy + FORCE_COLOR: 3 + PYTEST_TIMEOUT: 300 + # For cmake: + VERBOSE: 1 + +jobs: + # This is the "main" test suite, which tests a large number of different + # versions of default compilers and Python versions in GitHub Actions. + standard: + strategy: + fail-fast: false + matrix: + runs-on: [ubuntu-20.04, windows-2022, macos-latest] + python: + - '3.6' + - '3.9' + - '3.10' + - '3.11' + - '3.12' + - 'pypy-3.8' + - 'pypy-3.9' + - 'pypy-3.10' + + # Items in here will either be added to the build matrix (if not + # present), or add new keys to an existing matrix element if all the + # existing keys match. + # + # We support an optional key: args, for cmake args + include: + # Just add a key + - runs-on: ubuntu-20.04 + python: '3.6' + args: > + -DPYBIND11_FINDPYTHON=ON + -DCMAKE_CXX_FLAGS="-D_=1" + - runs-on: ubuntu-20.04 + python: 'pypy-3.8' + args: > + -DPYBIND11_FINDPYTHON=ON + - runs-on: windows-2019 + python: '3.6' + args: > + -DPYBIND11_FINDPYTHON=ON + # Inject a couple Windows 2019 runs + - runs-on: windows-2019 + python: '3.9' + + name: "🐍 ${{ matrix.python }} • ${{ matrix.runs-on }} • x64 ${{ matrix.args }}" + runs-on: ${{ matrix.runs-on }} + + steps: + - uses: actions/checkout@v3 + + - name: Setup Python ${{ matrix.python }} + uses: actions/setup-python@v4 + with: + python-version: ${{ matrix.python }} + allow-prereleases: true + + - name: Setup Boost (Linux) + # Can't use boost + define _ + if: runner.os == 'Linux' && matrix.python != '3.6' + run: sudo apt-get install libboost-dev + + - name: Setup Boost (macOS) + if: runner.os == 'macOS' + run: brew install boost + + - name: Update CMake + uses: jwlawson/actions-setup-cmake@v1.14 + + - name: Cache wheels + if: runner.os == 'macOS' + uses: actions/cache@v3 + with: + # This path is specific to macOS - we really only need it for PyPy NumPy wheels + # See https://github.com/actions/cache/blob/master/examples.md#python---pip + # for ways to do this more generally + path: ~/Library/Caches/pip + # Look to see if there is a cache hit for the corresponding requirements file + key: ${{ runner.os }}-pip-${{ matrix.python }}-x64-${{ hashFiles('tests/requirements.txt') }} + + - name: Prepare env + run: | + python -m pip install -r tests/requirements.txt + + - name: Setup annotations on Linux + if: runner.os == 'Linux' + run: python -m pip install pytest-github-actions-annotate-failures + + # First build - C++11 mode and inplace + # More-or-less randomly adding -DPYBIND11_SIMPLE_GIL_MANAGEMENT=ON here. + - name: Configure C++11 ${{ matrix.args }} + run: > + cmake -S . -B . + -DPYBIND11_WERROR=ON + -DPYBIND11_SIMPLE_GIL_MANAGEMENT=ON + -DDOWNLOAD_CATCH=ON + -DDOWNLOAD_EIGEN=ON + -DCMAKE_CXX_STANDARD=11 + ${{ matrix.args }} + + - name: Build C++11 + run: cmake --build . -j 2 + + - name: Python tests C++11 + run: cmake --build . --target pytest -j 2 + + - name: C++11 tests + # TODO: Figure out how to load the DLL on Python 3.8+ + if: "!(runner.os == 'Windows' && (matrix.python == 3.8 || matrix.python == 3.9 || matrix.python == '3.10' || matrix.python == '3.11' || matrix.python == 'pypy-3.8'))" + run: cmake --build . --target cpptest -j 2 + + - name: Interface test C++11 + run: cmake --build . --target test_cmake_build + + - name: Clean directory + run: git clean -fdx + + # Second build - C++17 mode and in a build directory + # More-or-less randomly adding -DPYBIND11_SIMPLE_GIL_MANAGEMENT=OFF here. + - name: Configure C++17 + run: > + cmake -S . -B build2 + -DPYBIND11_WERROR=ON + -DPYBIND11_SIMPLE_GIL_MANAGEMENT=OFF + -DDOWNLOAD_CATCH=ON + -DDOWNLOAD_EIGEN=ON + -DCMAKE_CXX_STANDARD=17 + ${{ matrix.args }} + + - name: Build + run: cmake --build build2 -j 2 + + - name: Python tests + run: cmake --build build2 --target pytest + + - name: C++ tests + # TODO: Figure out how to load the DLL on Python 3.8+ + if: "!(runner.os == 'Windows' && (matrix.python == 3.8 || matrix.python == 3.9 || matrix.python == '3.10' || matrix.python == '3.11' || matrix.python == 'pypy-3.8'))" + run: cmake --build build2 --target cpptest + + # Third build - C++17 mode with unstable ABI + - name: Configure (unstable ABI) + run: > + cmake -S . -B build3 + -DPYBIND11_WERROR=ON + -DDOWNLOAD_CATCH=ON + -DDOWNLOAD_EIGEN=ON + -DCMAKE_CXX_STANDARD=17 + -DPYBIND11_INTERNALS_VERSION=10000000 + ${{ matrix.args }} + + - name: Build (unstable ABI) + run: cmake --build build3 -j 2 + + - name: Python tests (unstable ABI) + run: cmake --build build3 --target pytest + + - name: Interface test + run: cmake --build build2 --target test_cmake_build + + # This makes sure the setup_helpers module can build packages using + # setuptools + - name: Setuptools helpers test + run: | + pip install setuptools + pytest tests/extra_setuptools + if: "!(matrix.runs-on == 'windows-2022')" + + + deadsnakes: + strategy: + fail-fast: false + matrix: + include: + # TODO: Fails on 3.10, investigate + - python-version: "3.9" + python-debug: true + valgrind: true + - python-version: "3.11" + python-debug: false + + name: "🐍 ${{ matrix.python-version }}${{ matrix.python-debug && '-dbg' || '' }} (deadsnakes)${{ matrix.valgrind && ' • Valgrind' || '' }} • x64" + runs-on: ubuntu-20.04 + + steps: + - uses: actions/checkout@v3 + + - name: Setup Python ${{ matrix.python-version }} (deadsnakes) + uses: deadsnakes/action@v3.0.1 + with: + python-version: ${{ matrix.python-version }} + debug: ${{ matrix.python-debug }} + + - name: Update CMake + uses: jwlawson/actions-setup-cmake@v1.14 + + - name: Valgrind cache + if: matrix.valgrind + uses: actions/cache@v3 + id: cache-valgrind + with: + path: valgrind + key: 3.16.1 # Valgrind version + + - name: Compile Valgrind + if: matrix.valgrind && steps.cache-valgrind.outputs.cache-hit != 'true' + run: | + VALGRIND_VERSION=3.16.1 + curl https://sourceware.org/pub/valgrind/valgrind-$VALGRIND_VERSION.tar.bz2 -o - | tar xj + mv valgrind-$VALGRIND_VERSION valgrind + cd valgrind + ./configure + make -j 2 > /dev/null + + - name: Install Valgrind + if: matrix.valgrind + working-directory: valgrind + run: | + sudo make install + sudo apt-get update + sudo apt-get install libc6-dbg # Needed by Valgrind + + - name: Prepare env + run: | + python -m pip install -r tests/requirements.txt + + - name: Configure + run: > + cmake -S . -B build + -DCMAKE_BUILD_TYPE=Debug + -DPYBIND11_WERROR=ON + -DDOWNLOAD_CATCH=ON + -DDOWNLOAD_EIGEN=ON + -DCMAKE_CXX_STANDARD=17 + + - name: Build + run: cmake --build build -j 2 + + - name: Python tests + run: cmake --build build --target pytest + + - name: C++ tests + run: cmake --build build --target cpptest + + - name: Run Valgrind on Python tests + if: matrix.valgrind + run: cmake --build build --target memcheck + + + # Testing on clang using the excellent silkeh clang docker images + clang: + runs-on: ubuntu-latest + strategy: + fail-fast: false + matrix: + clang: + - 3.6 + - 3.7 + - 3.9 + - 7 + - 9 + - dev + std: + - 11 + container_suffix: + - "" + include: + - clang: 5 + std: 14 + - clang: 10 + std: 17 + - clang: 11 + std: 20 + - clang: 12 + std: 20 + - clang: 13 + std: 20 + - clang: 14 + std: 20 + - clang: 15 + std: 20 + container_suffix: "-bullseye" + + name: "🐍 3 • Clang ${{ matrix.clang }} • C++${{ matrix.std }} • x64" + container: "silkeh/clang:${{ matrix.clang }}${{ matrix.container_suffix }}" + + steps: + - uses: actions/checkout@v3 + + - name: Add wget and python3 + run: apt-get update && apt-get install -y python3-dev python3-numpy python3-pytest libeigen3-dev + + - name: Configure + shell: bash + run: > + cmake -S . -B build + -DPYBIND11_WERROR=ON + -DDOWNLOAD_CATCH=ON + -DCMAKE_CXX_STANDARD=${{ matrix.std }} + -DPYTHON_EXECUTABLE=$(python3 -c "import sys; print(sys.executable)") + + - name: Build + run: cmake --build build -j 2 + + - name: Python tests + run: cmake --build build --target pytest + + - name: C++ tests + run: cmake --build build --target cpptest + + - name: Interface test + run: cmake --build build --target test_cmake_build + + + # Testing NVCC; forces sources to behave like .cu files + cuda: + runs-on: ubuntu-latest + name: "🐍 3.10 • CUDA 12.2 • Ubuntu 22.04" + container: nvidia/cuda:12.2.0-devel-ubuntu22.04 + + steps: + - uses: actions/checkout@v3 + + # tzdata will try to ask for the timezone, so set the DEBIAN_FRONTEND + - name: Install 🐍 3 + run: apt-get update && DEBIAN_FRONTEND="noninteractive" apt-get install -y cmake git python3-dev python3-pytest python3-numpy + + - name: Configure + run: cmake -S . -B build -DPYBIND11_CUDA_TESTS=ON -DPYBIND11_WERROR=ON -DDOWNLOAD_CATCH=ON + + - name: Build + run: cmake --build build -j2 --verbose + + - name: Python tests + run: cmake --build build --target pytest + + +# TODO: Internal compiler error - report to NVidia +# # Testing CentOS 8 + PGI compilers +# centos-nvhpc8: +# runs-on: ubuntu-latest +# name: "🐍 3 • CentOS8 / PGI 20.11 • x64" +# container: centos:8 +# +# steps: +# - uses: actions/checkout@v3 +# +# - name: Add Python 3 and a few requirements +# run: yum update -y && yum install -y git python3-devel python3-numpy python3-pytest make environment-modules +# +# - name: Install CMake with pip +# run: | +# python3 -m pip install --upgrade pip +# python3 -m pip install cmake --prefer-binary +# +# - name: Install NVidia HPC SDK +# run: > +# yum -y install +# https://developer.download.nvidia.com/hpc-sdk/20.11/nvhpc-20-11-20.11-1.x86_64.rpm +# https://developer.download.nvidia.com/hpc-sdk/20.11/nvhpc-2020-20.11-1.x86_64.rpm +# +# - name: Configure +# shell: bash +# run: | +# source /etc/profile.d/modules.sh +# module load /opt/nvidia/hpc_sdk/modulefiles/nvhpc/20.11 +# cmake -S . -B build -DDOWNLOAD_CATCH=ON -DCMAKE_CXX_STANDARD=14 -DPYTHON_EXECUTABLE=$(python3 -c "import sys; print(sys.executable)") +# +# - name: Build +# run: cmake --build build -j 2 --verbose +# +# - name: Python tests +# run: cmake --build build --target pytest +# +# - name: C++ tests +# run: cmake --build build --target cpptest +# +# - name: Interface test +# run: cmake --build build --target test_cmake_build + + + # Testing on CentOS 7 + PGI compilers, which seems to require more workarounds + centos-nvhpc7: + if: ${{ false }} # JOB DISABLED (NEEDS WORK): https://github.com/pybind/pybind11/issues/4690 + runs-on: ubuntu-latest + name: "🐍 3 • CentOS7 / PGI 22.9 • x64" + container: centos:7 + + steps: + - uses: actions/checkout@v3 + + - name: Add Python 3 and a few requirements + run: yum update -y && yum install -y epel-release && yum install -y git python3-devel make environment-modules cmake3 yum-utils + + - name: Install NVidia HPC SDK + run: yum-config-manager --add-repo https://developer.download.nvidia.com/hpc-sdk/rhel/nvhpc.repo && yum -y install nvhpc-22.9 + + # On CentOS 7, we have to filter a few tests (compiler internal error) + # and allow deeper template recursion (not needed on CentOS 8 with a newer + # standard library). On some systems, you many need further workarounds: + # https://github.com/pybind/pybind11/pull/2475 + - name: Configure + shell: bash + run: | + source /etc/profile.d/modules.sh + module load /opt/nvidia/hpc_sdk/modulefiles/nvhpc/22.9 + cmake3 -S . -B build -DDOWNLOAD_CATCH=ON \ + -DCMAKE_CXX_STANDARD=11 \ + -DPYTHON_EXECUTABLE=$(python3 -c "import sys; print(sys.executable)") \ + -DCMAKE_CXX_FLAGS="-Wc,--pending_instantiations=0" \ + -DPYBIND11_TEST_FILTER="test_smart_ptr.cpp" + + # Building before installing Pip should produce a warning but not an error + - name: Build + run: cmake3 --build build -j 2 --verbose + + - name: Install CMake with pip + run: | + python3 -m pip install --upgrade pip + python3 -m pip install pytest + + - name: Python tests + run: cmake3 --build build --target pytest + + - name: C++ tests + run: cmake3 --build build --target cpptest + + - name: Interface test + run: cmake3 --build build --target test_cmake_build + + + # Testing on GCC using the GCC docker images (only recent images supported) + gcc: + runs-on: ubuntu-latest + strategy: + fail-fast: false + matrix: + include: + - { gcc: 7, std: 11 } + - { gcc: 7, std: 17 } + - { gcc: 8, std: 14 } + - { gcc: 8, std: 17 } + - { gcc: 10, std: 17 } + - { gcc: 11, std: 20 } + - { gcc: 12, std: 20 } + + name: "🐍 3 • GCC ${{ matrix.gcc }} • C++${{ matrix.std }}• x64" + container: "gcc:${{ matrix.gcc }}" + + steps: + - uses: actions/checkout@v3 + + - name: Add Python 3 + run: apt-get update; apt-get install -y python3-dev python3-numpy python3-pytest python3-pip libeigen3-dev + + - name: Update pip + run: python3 -m pip install --upgrade pip + + - name: Update CMake + uses: jwlawson/actions-setup-cmake@v1.14 + + - name: Configure + shell: bash + run: > + cmake -S . -B build + -DPYBIND11_WERROR=ON + -DDOWNLOAD_CATCH=ON + -DCMAKE_CXX_STANDARD=${{ matrix.std }} + -DPYTHON_EXECUTABLE=$(python3 -c "import sys; print(sys.executable)") + + - name: Build + run: cmake --build build -j 2 + + - name: Python tests + run: cmake --build build --target pytest + + - name: C++ tests + run: cmake --build build --target cpptest + + - name: Interface test + run: cmake --build build --target test_cmake_build + + - name: Configure - Exercise cmake -DPYBIND11_TEST_OVERRIDE + if: matrix.gcc == '12' + shell: bash + run: > + cmake -S . -B build_partial + -DPYBIND11_WERROR=ON + -DDOWNLOAD_CATCH=ON + -DCMAKE_CXX_STANDARD=${{ matrix.std }} + -DPYTHON_EXECUTABLE=$(python3 -c "import sys; print(sys.executable)") + "-DPYBIND11_TEST_OVERRIDE=test_call_policies.cpp;test_gil_scoped.cpp;test_thread.cpp" + + - name: Build - Exercise cmake -DPYBIND11_TEST_OVERRIDE + if: matrix.gcc == '12' + run: cmake --build build_partial -j 2 + + - name: Python tests - Exercise cmake -DPYBIND11_TEST_OVERRIDE + if: matrix.gcc == '12' + run: cmake --build build_partial --target pytest + + # Testing on ICC using the oneAPI apt repo + icc: + runs-on: ubuntu-20.04 + strategy: + fail-fast: false + + name: "🐍 3 • ICC latest • x64" + + steps: + - uses: actions/checkout@v3 + + - name: Add apt repo + run: | + sudo apt-get update + sudo apt-get install -y wget build-essential pkg-config cmake ca-certificates gnupg + wget https://apt.repos.intel.com/intel-gpg-keys/GPG-PUB-KEY-INTEL-SW-PRODUCTS-2023.PUB + sudo apt-key add GPG-PUB-KEY-INTEL-SW-PRODUCTS-2023.PUB + echo "deb https://apt.repos.intel.com/oneapi all main" | sudo tee /etc/apt/sources.list.d/oneAPI.list + + - name: Add ICC & Python 3 + run: sudo apt-get update; sudo apt-get install -y intel-oneapi-compiler-dpcpp-cpp-and-cpp-classic cmake python3-dev python3-numpy python3-pytest python3-pip + + - name: Update pip + run: | + set +e; source /opt/intel/oneapi/setvars.sh; set -e + python3 -m pip install --upgrade pip + + - name: Install dependencies + run: | + set +e; source /opt/intel/oneapi/setvars.sh; set -e + python3 -m pip install -r tests/requirements.txt + + - name: Configure C++11 + run: | + set +e; source /opt/intel/oneapi/setvars.sh; set -e + cmake -S . -B build-11 \ + -DPYBIND11_WERROR=ON \ + -DDOWNLOAD_CATCH=ON \ + -DDOWNLOAD_EIGEN=OFF \ + -DCMAKE_CXX_STANDARD=11 \ + -DCMAKE_CXX_COMPILER=$(which icpc) \ + -DPYTHON_EXECUTABLE=$(python3 -c "import sys; print(sys.executable)") + + - name: Build C++11 + run: | + set +e; source /opt/intel/oneapi/setvars.sh; set -e + cmake --build build-11 -j 2 -v + + - name: Python tests C++11 + run: | + set +e; source /opt/intel/oneapi/setvars.sh; set -e + sudo service apport stop + cmake --build build-11 --target check + + - name: C++ tests C++11 + run: | + set +e; source /opt/intel/oneapi/setvars.sh; set -e + cmake --build build-11 --target cpptest + + - name: Interface test C++11 + run: | + set +e; source /opt/intel/oneapi/setvars.sh; set -e + cmake --build build-11 --target test_cmake_build + + - name: Configure C++17 + run: | + set +e; source /opt/intel/oneapi/setvars.sh; set -e + cmake -S . -B build-17 \ + -DPYBIND11_WERROR=ON \ + -DDOWNLOAD_CATCH=ON \ + -DDOWNLOAD_EIGEN=OFF \ + -DCMAKE_CXX_STANDARD=17 \ + -DCMAKE_CXX_COMPILER=$(which icpc) \ + -DPYTHON_EXECUTABLE=$(python3 -c "import sys; print(sys.executable)") + + - name: Build C++17 + run: | + set +e; source /opt/intel/oneapi/setvars.sh; set -e + cmake --build build-17 -j 2 -v + + - name: Python tests C++17 + run: | + set +e; source /opt/intel/oneapi/setvars.sh; set -e + sudo service apport stop + cmake --build build-17 --target check + + - name: C++ tests C++17 + run: | + set +e; source /opt/intel/oneapi/setvars.sh; set -e + cmake --build build-17 --target cpptest + + - name: Interface test C++17 + run: | + set +e; source /opt/intel/oneapi/setvars.sh; set -e + cmake --build build-17 --target test_cmake_build + + + # Testing on CentOS (manylinux uses a centos base, and this is an easy way + # to get GCC 4.8, which is the manylinux1 compiler). + centos: + runs-on: ubuntu-latest + strategy: + fail-fast: false + matrix: + container: + - "centos:7" # GCC 4.8 + - "almalinux:8" + - "almalinux:9" + + name: "🐍 3 • ${{ matrix.container }} • x64" + container: "${{ matrix.container }}" + + steps: + - uses: actions/checkout@v3 + + - name: Add Python 3 (RHEL 7) + if: matrix.container == 'centos:7' + run: yum update -y && yum install -y python3-devel gcc-c++ make git + + - name: Add Python 3 (RHEL 8+) + if: matrix.container != 'centos:7' + run: dnf update -y && dnf install -y python3-devel gcc-c++ make git + + - name: Update pip + run: python3 -m pip install --upgrade pip + + - name: Install dependencies + run: | + python3 -m pip install cmake -r tests/requirements.txt + + - name: Configure + shell: bash + run: > + cmake -S . -B build + -DCMAKE_BUILD_TYPE=MinSizeRel + -DPYBIND11_WERROR=ON + -DDOWNLOAD_CATCH=ON + -DDOWNLOAD_EIGEN=ON + -DCMAKE_CXX_STANDARD=11 + -DPYTHON_EXECUTABLE=$(python3 -c "import sys; print(sys.executable)") + + - name: Build + run: cmake --build build -j 2 + + - name: Python tests + run: cmake --build build --target pytest + + - name: C++ tests + run: cmake --build build --target cpptest + + - name: Interface test + run: cmake --build build --target test_cmake_build + + + # This tests an "install" with the CMake tools + install-classic: + name: "🐍 3.7 • Debian • x86 • Install" + runs-on: ubuntu-latest + container: i386/debian:buster + + steps: + - uses: actions/checkout@v1 # Required to run inside docker + + - name: Install requirements + run: | + apt-get update + apt-get install -y git make cmake g++ libeigen3-dev python3-dev python3-pip + pip3 install "pytest==6.*" + + - name: Configure for install + run: > + cmake . + -DPYBIND11_INSTALL=1 -DPYBIND11_TEST=0 + -DPYTHON_EXECUTABLE=$(python3 -c "import sys; print(sys.executable)") + + - name: Make and install + run: make install + + - name: Copy tests to new directory + run: cp -a tests /pybind11-tests + + - name: Make a new test directory + run: mkdir /build-tests + + - name: Configure tests + run: > + cmake ../pybind11-tests + -DDOWNLOAD_CATCH=ON + -DPYBIND11_WERROR=ON + -DPYTHON_EXECUTABLE=$(python3 -c "import sys; print(sys.executable)") + working-directory: /build-tests + + - name: Python tests + run: make pytest -j 2 + working-directory: /build-tests + + + # This verifies that the documentation is not horribly broken, and does a + # basic validation check on the SDist. + doxygen: + name: "Documentation build test" + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v3 + + - uses: actions/setup-python@v4 + with: + python-version: "3.x" + + - name: Install Doxygen + run: sudo apt-get install -y doxygen librsvg2-bin # Changed to rsvg-convert in 20.04 + + - name: Build docs + run: pipx run nox -s docs + + - name: Make SDist + run: pipx run nox -s build -- --sdist + + - run: git status --ignored + + - name: Check local include dir + run: > + ls pybind11; + python3 -c "import pybind11, pathlib; assert (a := pybind11.get_include()) == (b := str(pathlib.Path('include').resolve())), f'{a} != {b}'" + + - name: Compare Dists (headers only) + working-directory: include + run: | + python3 -m pip install --user -U ../dist/*.tar.gz + installed=$(python3 -c "import pybind11; print(pybind11.get_include() + '/pybind11')") + diff -rq $installed ./pybind11 + + win32: + strategy: + fail-fast: false + matrix: + python: + - 3.6 + - 3.7 + - 3.8 + - 3.9 + + include: + - python: 3.9 + args: -DCMAKE_CXX_STANDARD=20 + - python: 3.8 + args: -DCMAKE_CXX_STANDARD=17 + - python: 3.7 + args: -DCMAKE_CXX_STANDARD=14 + + + name: "🐍 ${{ matrix.python }} • MSVC 2019 • x86 ${{ matrix.args }}" + runs-on: windows-2019 + + steps: + - uses: actions/checkout@v3 + + - name: Setup Python ${{ matrix.python }} + uses: actions/setup-python@v4 + with: + python-version: ${{ matrix.python }} + architecture: x86 + + - name: Update CMake + uses: jwlawson/actions-setup-cmake@v1.14 + + - name: Prepare MSVC + uses: ilammy/msvc-dev-cmd@v1.12.1 + with: + arch: x86 + + - name: Prepare env + run: | + python -m pip install -r tests/requirements.txt + + # First build - C++11 mode and inplace + - name: Configure ${{ matrix.args }} + run: > + cmake -S . -B build + -G "Visual Studio 16 2019" -A Win32 + -DPYBIND11_WERROR=ON + -DDOWNLOAD_CATCH=ON + -DDOWNLOAD_EIGEN=ON + ${{ matrix.args }} + - name: Build C++11 + run: cmake --build build -j 2 + + - name: Python tests + run: cmake --build build -t pytest + + win32-debug: + strategy: + fail-fast: false + matrix: + python: + - 3.8 + - 3.9 + + include: + - python: 3.9 + args: -DCMAKE_CXX_STANDARD=20 + - python: 3.8 + args: -DCMAKE_CXX_STANDARD=17 + + name: "🐍 ${{ matrix.python }} • MSVC 2019 (Debug) • x86 ${{ matrix.args }}" + runs-on: windows-2019 + + steps: + - uses: actions/checkout@v3 + + - name: Setup Python ${{ matrix.python }} + uses: actions/setup-python@v4 + with: + python-version: ${{ matrix.python }} + architecture: x86 + + - name: Update CMake + uses: jwlawson/actions-setup-cmake@v1.14 + + - name: Prepare MSVC + uses: ilammy/msvc-dev-cmd@v1.12.1 + with: + arch: x86 + + - name: Prepare env + run: | + python -m pip install -r tests/requirements.txt + + # First build - C++11 mode and inplace + - name: Configure ${{ matrix.args }} + run: > + cmake -S . -B build + -G "Visual Studio 16 2019" -A Win32 + -DCMAKE_BUILD_TYPE=Debug + -DPYBIND11_WERROR=ON + -DDOWNLOAD_CATCH=ON + -DDOWNLOAD_EIGEN=ON + ${{ matrix.args }} + - name: Build C++11 + run: cmake --build build --config Debug -j 2 + + - name: Python tests + run: cmake --build build --config Debug -t pytest + + + windows-2022: + strategy: + fail-fast: false + matrix: + python: + - 3.9 + + name: "🐍 ${{ matrix.python }} • MSVC 2022 C++20 • x64" + runs-on: windows-2022 + + steps: + - uses: actions/checkout@v3 + + - name: Setup Python ${{ matrix.python }} + uses: actions/setup-python@v4 + with: + python-version: ${{ matrix.python }} + + - name: Prepare env + run: | + python3 -m pip install -r tests/requirements.txt + + - name: Update CMake + uses: jwlawson/actions-setup-cmake@v1.14 + + - name: Configure C++20 + run: > + cmake -S . -B build + -DPYBIND11_WERROR=ON + -DDOWNLOAD_CATCH=ON + -DDOWNLOAD_EIGEN=ON + -DCMAKE_CXX_STANDARD=20 + + - name: Build C++20 + run: cmake --build build -j 2 + + - name: Python tests + run: cmake --build build --target pytest + + - name: C++20 tests + run: cmake --build build --target cpptest -j 2 + + - name: Interface test C++20 + run: cmake --build build --target test_cmake_build + + - name: Configure C++20 - Exercise cmake -DPYBIND11_TEST_OVERRIDE + run: > + cmake -S . -B build_partial + -DPYBIND11_WERROR=ON + -DDOWNLOAD_CATCH=ON + -DDOWNLOAD_EIGEN=ON + -DCMAKE_CXX_STANDARD=20 + "-DPYBIND11_TEST_OVERRIDE=test_call_policies.cpp;test_gil_scoped.cpp;test_thread.cpp" + + - name: Build C++20 - Exercise cmake -DPYBIND11_TEST_OVERRIDE + run: cmake --build build_partial -j 2 + + - name: Python tests - Exercise cmake -DPYBIND11_TEST_OVERRIDE + run: cmake --build build_partial --target pytest + + mingw: + name: "🐍 3 • windows-latest • ${{ matrix.sys }}" + runs-on: windows-latest + defaults: + run: + shell: msys2 {0} + strategy: + fail-fast: false + matrix: + include: + - { sys: mingw64, env: x86_64 } + - { sys: mingw32, env: i686 } + steps: + - uses: msys2/setup-msys2@v2 + with: + msystem: ${{matrix.sys}} + install: >- + git + mingw-w64-${{matrix.env}}-gcc + mingw-w64-${{matrix.env}}-python-pip + mingw-w64-${{matrix.env}}-python-numpy + mingw-w64-${{matrix.env}}-python-scipy + mingw-w64-${{matrix.env}}-cmake + mingw-w64-${{matrix.env}}-make + mingw-w64-${{matrix.env}}-python-pytest + mingw-w64-${{matrix.env}}-eigen3 + mingw-w64-${{matrix.env}}-boost + mingw-w64-${{matrix.env}}-catch + + - uses: actions/checkout@v3 + + - name: Configure C++11 + # LTO leads to many undefined reference like + # `pybind11::detail::function_call::function_call(pybind11::detail::function_call&&) + run: cmake -G "MinGW Makefiles" -DCMAKE_CXX_STANDARD=11 -DPYBIND11_WERROR=ON -DDOWNLOAD_CATCH=ON -S . -B build + + - name: Build C++11 + run: cmake --build build -j 2 + + - name: Python tests C++11 + run: cmake --build build --target pytest -j 2 + + - name: C++11 tests + run: PYTHONHOME=/${{matrix.sys}} PYTHONPATH=/${{matrix.sys}} cmake --build build --target cpptest -j 2 + + - name: Interface test C++11 + run: PYTHONHOME=/${{matrix.sys}} PYTHONPATH=/${{matrix.sys}} cmake --build build --target test_cmake_build + + - name: Clean directory + run: git clean -fdx + + - name: Configure C++14 + run: cmake -G "MinGW Makefiles" -DCMAKE_CXX_STANDARD=14 -DPYBIND11_WERROR=ON -DDOWNLOAD_CATCH=ON -S . -B build2 + + - name: Build C++14 + run: cmake --build build2 -j 2 + + - name: Python tests C++14 + run: cmake --build build2 --target pytest -j 2 + + - name: C++14 tests + run: PYTHONHOME=/${{matrix.sys}} PYTHONPATH=/${{matrix.sys}} cmake --build build2 --target cpptest -j 2 + + - name: Interface test C++14 + run: PYTHONHOME=/${{matrix.sys}} PYTHONPATH=/${{matrix.sys}} cmake --build build2 --target test_cmake_build + + - name: Clean directory + run: git clean -fdx + + - name: Configure C++17 + run: cmake -G "MinGW Makefiles" -DCMAKE_CXX_STANDARD=17 -DPYBIND11_WERROR=ON -DDOWNLOAD_CATCH=ON -S . -B build3 + + - name: Build C++17 + run: cmake --build build3 -j 2 + + - name: Python tests C++17 + run: cmake --build build3 --target pytest -j 2 + + - name: C++17 tests + run: PYTHONHOME=/${{matrix.sys}} PYTHONPATH=/${{matrix.sys}} cmake --build build3 --target cpptest -j 2 + + - name: Interface test C++17 + run: PYTHONHOME=/${{matrix.sys}} PYTHONPATH=/${{matrix.sys}} cmake --build build3 --target test_cmake_build + + windows_clang: + + strategy: + matrix: + os: [windows-latest] + python: ['3.10'] + + runs-on: "${{ matrix.os }}" + + name: "🐍 ${{ matrix.python }} • ${{ matrix.os }} • clang-latest" + + steps: + - name: Show env + run: env + + - name: Checkout + uses: actions/checkout@v3 + + - name: Set up Clang + uses: egor-tensin/setup-clang@v1 + + - name: Setup Python ${{ matrix.python }} + uses: actions/setup-python@v4 + with: + python-version: ${{ matrix.python }} + + - name: Update CMake + uses: jwlawson/actions-setup-cmake@v1.14 + + - name: Install ninja-build tool + uses: seanmiddleditch/gha-setup-ninja@v3 + + - name: Run pip installs + run: | + python -m pip install --upgrade pip + python -m pip install -r tests/requirements.txt + + - name: Show Clang++ version + run: clang++ --version + + - name: Show CMake version + run: cmake --version + + # TODO: WERROR=ON + - name: Configure Clang + run: > + cmake -G Ninja -S . -B . + -DPYBIND11_WERROR=OFF + -DPYBIND11_SIMPLE_GIL_MANAGEMENT=OFF + -DDOWNLOAD_CATCH=ON + -DDOWNLOAD_EIGEN=ON + -DCMAKE_CXX_COMPILER=clang++ + -DCMAKE_CXX_STANDARD=17 + + - name: Build + run: cmake --build . -j 2 + + - name: Python tests + run: cmake --build . --target pytest -j 2 + + - name: C++ tests + run: cmake --build . --target cpptest -j 2 + + - name: Interface test + run: cmake --build . --target test_cmake_build -j 2 + + - name: Clean directory + run: git clean -fdx + + macos_brew_install_llvm: + name: "macos-latest • brew install llvm" + runs-on: macos-latest + + env: + # https://apple.stackexchange.com/questions/227026/how-to-install-recent-clang-with-homebrew + LDFLAGS: '-L/usr/local/opt/llvm/lib -Wl,-rpath,/usr/local/opt/llvm/lib' + + steps: + - name: Update PATH + run: echo "/usr/local/opt/llvm/bin" >> $GITHUB_PATH + + - name: Show env + run: env + + - name: Checkout + uses: actions/checkout@v3 + + - name: Show Clang++ version before brew install llvm + run: clang++ --version + + - name: brew install llvm + run: brew install llvm + + - name: Show Clang++ version after brew install llvm + run: clang++ --version + + - name: Update CMake + uses: jwlawson/actions-setup-cmake@v1.14 + + - name: Run pip installs + run: | + python3 -m pip install --upgrade pip + python3 -m pip install -r tests/requirements.txt + python3 -m pip install numpy + python3 -m pip install scipy + + - name: Show CMake version + run: cmake --version + + - name: CMake Configure + run: > + cmake -S . -B . + -DPYBIND11_WERROR=ON + -DPYBIND11_SIMPLE_GIL_MANAGEMENT=OFF + -DDOWNLOAD_CATCH=ON + -DDOWNLOAD_EIGEN=ON + -DCMAKE_CXX_COMPILER=clang++ + -DCMAKE_CXX_STANDARD=17 + -DPYTHON_EXECUTABLE=$(python3 -c "import sys; print(sys.executable)") + + - name: Build + run: cmake --build . -j 2 + + - name: Python tests + run: cmake --build . --target pytest -j 2 + + - name: C++ tests + run: cmake --build . --target cpptest -j 2 + + - name: Interface test + run: cmake --build . --target test_cmake_build -j 2 + + - name: CMake Configure - Exercise cmake -DPYBIND11_TEST_OVERRIDE + run: > + cmake -S . -B build_partial + -DPYBIND11_WERROR=ON + -DPYBIND11_SIMPLE_GIL_MANAGEMENT=OFF + -DDOWNLOAD_CATCH=ON + -DDOWNLOAD_EIGEN=ON + -DCMAKE_CXX_COMPILER=clang++ + -DCMAKE_CXX_STANDARD=17 + -DPYTHON_EXECUTABLE=$(python3 -c "import sys; print(sys.executable)") + "-DPYBIND11_TEST_OVERRIDE=test_call_policies.cpp;test_gil_scoped.cpp;test_thread.cpp" + + - name: Build - Exercise cmake -DPYBIND11_TEST_OVERRIDE + run: cmake --build build_partial -j 2 + + - name: Python tests - Exercise cmake -DPYBIND11_TEST_OVERRIDE + run: cmake --build build_partial --target pytest -j 2 + + - name: Clean directory + run: git clean -fdx diff --git a/dmff/dpnblist/external/pybind11-2.11.1/.github/workflows/configure.yml b/dmff/dpnblist/external/pybind11-2.11.1/.github/workflows/configure.yml new file mode 100644 index 00000000..ec7cd612 --- /dev/null +++ b/dmff/dpnblist/external/pybind11-2.11.1/.github/workflows/configure.yml @@ -0,0 +1,92 @@ +name: Config + +on: + workflow_dispatch: + pull_request: + push: + branches: + - master + - stable + - v* + +permissions: + contents: read + +env: + PIP_BREAK_SYSTEM_PACKAGES: 1 + # For cmake: + VERBOSE: 1 + +jobs: + # This tests various versions of CMake in various combinations, to make sure + # the configure step passes. + cmake: + strategy: + fail-fast: false + matrix: + runs-on: [ubuntu-20.04, macos-latest, windows-latest] + arch: [x64] + cmake: ["3.26"] + + include: + - runs-on: ubuntu-20.04 + arch: x64 + cmake: "3.5" + + - runs-on: ubuntu-20.04 + arch: x64 + cmake: "3.27" + + - runs-on: macos-latest + arch: x64 + cmake: "3.7" + + - runs-on: windows-2019 + arch: x64 # x86 compilers seem to be missing on 2019 image + cmake: "3.18" + + name: 🐍 3.7 • CMake ${{ matrix.cmake }} • ${{ matrix.runs-on }} + runs-on: ${{ matrix.runs-on }} + + steps: + - uses: actions/checkout@v3 + + - name: Setup Python 3.7 + uses: actions/setup-python@v4 + with: + python-version: 3.7 + architecture: ${{ matrix.arch }} + + - name: Prepare env + run: python -m pip install -r tests/requirements.txt + + # An action for adding a specific version of CMake: + # https://github.com/jwlawson/actions-setup-cmake + - name: Setup CMake ${{ matrix.cmake }} + uses: jwlawson/actions-setup-cmake@v1.14 + with: + cmake-version: ${{ matrix.cmake }} + + # These steps use a directory with a space in it intentionally + - name: Make build directories + run: mkdir "build dir" + + - name: Configure + working-directory: build dir + shell: bash + run: > + cmake .. + -DPYBIND11_WERROR=ON + -DDOWNLOAD_CATCH=ON + -DPYTHON_EXECUTABLE=$(python -c "import sys; print(sys.executable)") + + # Only build and test if this was manually triggered in the GitHub UI + - name: Build + working-directory: build dir + if: github.event_name == 'workflow_dispatch' + run: cmake --build . --config Release + + - name: Test + working-directory: build dir + if: github.event_name == 'workflow_dispatch' + run: cmake --build . --config Release --target check diff --git a/dmff/dpnblist/external/pybind11-2.11.1/.github/workflows/format.yml b/dmff/dpnblist/external/pybind11-2.11.1/.github/workflows/format.yml new file mode 100644 index 00000000..b8242ee5 --- /dev/null +++ b/dmff/dpnblist/external/pybind11-2.11.1/.github/workflows/format.yml @@ -0,0 +1,60 @@ +# This is a format job. Pre-commit has a first-party GitHub action, so we use +# that: https://github.com/pre-commit/action + +name: Format + +on: + workflow_dispatch: + pull_request: + push: + branches: + - master + - stable + - "v*" + +permissions: + contents: read + +env: + FORCE_COLOR: 3 + # For cmake: + VERBOSE: 1 + +jobs: + pre-commit: + name: Format + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + - uses: actions/setup-python@v4 + with: + python-version: "3.x" + - name: Add matchers + run: echo "::add-matcher::$GITHUB_WORKSPACE/.github/matchers/pylint.json" + - uses: pre-commit/action@v3.0.0 + with: + # Slow hooks are marked with manual - slow is okay here, run them too + extra_args: --hook-stage manual --all-files + + clang-tidy: + # When making changes here, please also review the "Clang-Tidy" section + # in .github/CONTRIBUTING.md and update as needed. + name: Clang-Tidy + runs-on: ubuntu-latest + container: silkeh/clang:15-bullseye + steps: + - uses: actions/checkout@v3 + + - name: Install requirements + run: apt-get update && apt-get install -y git python3-dev python3-pytest + + - name: Configure + run: > + cmake -S . -B build + -DCMAKE_CXX_CLANG_TIDY="$(which clang-tidy);--use-color;--warnings-as-errors=*" + -DDOWNLOAD_EIGEN=ON + -DDOWNLOAD_CATCH=ON + -DCMAKE_CXX_STANDARD=17 + + - name: Build + run: cmake --build build -j 2 -- --keep-going diff --git a/dmff/dpnblist/external/pybind11-2.11.1/.github/workflows/labeler.yml b/dmff/dpnblist/external/pybind11-2.11.1/.github/workflows/labeler.yml new file mode 100644 index 00000000..858a4a0e --- /dev/null +++ b/dmff/dpnblist/external/pybind11-2.11.1/.github/workflows/labeler.yml @@ -0,0 +1,25 @@ +name: Labeler +on: + pull_request_target: + types: [closed] + +permissions: {} + +jobs: + label: + name: Labeler + runs-on: ubuntu-latest + permissions: + contents: read + pull-requests: write + steps: + + - uses: actions/labeler@main + if: > + github.event.pull_request.merged == true && + !startsWith(github.event.pull_request.title, 'chore(deps):') && + !startsWith(github.event.pull_request.title, 'ci(fix):') && + !startsWith(github.event.pull_request.title, 'docs(changelog):') + with: + repo-token: ${{ secrets.GITHUB_TOKEN }} + configuration-path: .github/labeler_merged.yml diff --git a/dmff/dpnblist/external/pybind11-2.11.1/.github/workflows/pip.yml b/dmff/dpnblist/external/pybind11-2.11.1/.github/workflows/pip.yml new file mode 100644 index 00000000..d6687b44 --- /dev/null +++ b/dmff/dpnblist/external/pybind11-2.11.1/.github/workflows/pip.yml @@ -0,0 +1,114 @@ +name: Pip + +on: + workflow_dispatch: + pull_request: + push: + branches: + - master + - stable + - v* + release: + types: + - published + +permissions: + contents: read + +env: + PIP_BREAK_SYSTEM_PACKAGES: 1 + PIP_ONLY_BINARY: numpy + +jobs: + # This builds the sdists and wheels and makes sure the files are exactly as + # expected. Using Windows and Python 3.6, since that is often the most + # challenging matrix element. + test-packaging: + name: 🐍 3.6 • 📦 tests • windows-latest + runs-on: windows-latest + + steps: + - uses: actions/checkout@v3 + + - name: Setup 🐍 3.6 + uses: actions/setup-python@v4 + with: + python-version: 3.6 + + - name: Prepare env + run: | + python -m pip install -r tests/requirements.txt + + - name: Python Packaging tests + run: pytest tests/extra_python_package/ + + + # This runs the packaging tests and also builds and saves the packages as + # artifacts. + packaging: + name: 🐍 3.8 • 📦 & 📦 tests • ubuntu-latest + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v3 + + - name: Setup 🐍 3.8 + uses: actions/setup-python@v4 + with: + python-version: 3.8 + + - name: Prepare env + run: | + python -m pip install -r tests/requirements.txt build twine + + - name: Python Packaging tests + run: pytest tests/extra_python_package/ + + - name: Build SDist and wheels + run: | + python -m build + PYBIND11_GLOBAL_SDIST=1 python -m build + + - name: Check metadata + run: twine check dist/* + + - name: Save standard package + uses: actions/upload-artifact@v3 + with: + name: standard + path: dist/pybind11-* + + - name: Save global package + uses: actions/upload-artifact@v3 + with: + name: global + path: dist/pybind11_global-* + + + + # When a GitHub release is made, upload the artifacts to PyPI + upload: + name: Upload to PyPI + runs-on: ubuntu-latest + if: github.event_name == 'release' && github.event.action == 'published' + needs: [packaging] + + steps: + - uses: actions/setup-python@v4 + with: + python-version: "3.x" + + # Downloads all to directories matching the artifact names + - uses: actions/download-artifact@v3 + + - name: Publish standard package + uses: pypa/gh-action-pypi-publish@release/v1 + with: + password: ${{ secrets.pypi_password }} + packages-dir: standard/ + + - name: Publish global package + uses: pypa/gh-action-pypi-publish@release/v1 + with: + password: ${{ secrets.pypi_password_global }} + packages-dir: global/ diff --git a/dmff/dpnblist/external/pybind11-2.11.1/.github/workflows/upstream.yml b/dmff/dpnblist/external/pybind11-2.11.1/.github/workflows/upstream.yml new file mode 100644 index 00000000..dd8a1c96 --- /dev/null +++ b/dmff/dpnblist/external/pybind11-2.11.1/.github/workflows/upstream.yml @@ -0,0 +1,116 @@ +name: Upstream + +on: + workflow_dispatch: + pull_request: + +permissions: + contents: read + +concurrency: + group: upstream-${{ github.ref }} + cancel-in-progress: true + +env: + PIP_BREAK_SYSTEM_PACKAGES: 1 + PIP_ONLY_BINARY: ":all:" + # For cmake: + VERBOSE: 1 + +jobs: + standard: + name: "🐍 3.12 latest • ubuntu-latest • x64" + runs-on: ubuntu-latest + # Only runs when the 'python dev' label is selected + if: "contains(github.event.pull_request.labels.*.name, 'python dev')" + + steps: + - uses: actions/checkout@v3 + + - name: Setup Python 3.12 + uses: actions/setup-python@v4 + with: + python-version: "3.12-dev" + + - name: Setup Boost + run: sudo apt-get install libboost-dev + + - name: Update CMake + uses: jwlawson/actions-setup-cmake@v1.14 + + - name: Run pip installs + run: | + python -m pip install --upgrade pip + python -m pip install -r tests/requirements.txt + + - name: Show platform info + run: | + python -m platform + cmake --version + pip list + + # First build - C++11 mode and inplace + - name: Configure C++11 + run: > + cmake -S . -B build11 + -DPYBIND11_WERROR=ON + -DDOWNLOAD_CATCH=ON + -DDOWNLOAD_EIGEN=ON + -DCMAKE_CXX_STANDARD=11 + -DCMAKE_BUILD_TYPE=Debug + + - name: Build C++11 + run: cmake --build build11 -j 2 + + - name: Python tests C++11 + run: cmake --build build11 --target pytest -j 2 + + - name: C++11 tests + run: cmake --build build11 --target cpptest -j 2 + + - name: Interface test C++11 + run: cmake --build build11 --target test_cmake_build + + # Second build - C++17 mode and in a build directory + - name: Configure C++17 + run: > + cmake -S . -B build17 + -DPYBIND11_WERROR=ON + -DDOWNLOAD_CATCH=ON + -DDOWNLOAD_EIGEN=ON + -DCMAKE_CXX_STANDARD=17 + + - name: Build C++17 + run: cmake --build build17 -j 2 + + - name: Python tests C++17 + run: cmake --build build17 --target pytest + + - name: C++17 tests + run: cmake --build build17 --target cpptest + + # Third build - C++17 mode with unstable ABI + - name: Configure (unstable ABI) + run: > + cmake -S . -B build17max + -DPYBIND11_WERROR=ON + -DDOWNLOAD_CATCH=ON + -DDOWNLOAD_EIGEN=ON + -DCMAKE_CXX_STANDARD=17 + -DPYBIND11_INTERNALS_VERSION=10000000 + + - name: Build (unstable ABI) + run: cmake --build build17max -j 2 + + - name: Python tests (unstable ABI) + run: cmake --build build17max --target pytest + + - name: Interface test (unstable ABI) + run: cmake --build build17max --target test_cmake_build + + # This makes sure the setup_helpers module can build packages using + # setuptools + - name: Setuptools helpers test + run: | + pip install setuptools + pytest tests/extra_setuptools diff --git a/dmff/dpnblist/external/pybind11-2.11.1/.gitignore b/dmff/dpnblist/external/pybind11-2.11.1/.gitignore new file mode 100644 index 00000000..43d5094c --- /dev/null +++ b/dmff/dpnblist/external/pybind11-2.11.1/.gitignore @@ -0,0 +1,46 @@ +CMakeCache.txt +CMakeFiles +Makefile +cmake_install.cmake +cmake_uninstall.cmake +.DS_Store +*.so +*.pyd +*.dll +*.sln +*.sdf +*.opensdf +*.vcxproj +*.vcxproj.user +*.filters +example.dir +Win32 +x64 +Release +Debug +.vs +CTestTestfile.cmake +Testing +autogen +MANIFEST +/.ninja_* +/*.ninja +/docs/.build +*.py[co] +*.egg-info +*~ +.*.swp +.DS_Store +/dist +/*build* +.cache/ +sosize-*.txt +pybind11Config*.cmake +pybind11Targets.cmake +/*env* +/.vscode +/pybind11/include/* +/pybind11/share/* +/docs/_build/* +.ipynb_checkpoints/ +tests/main.cpp diff --git a/dmff/dpnblist/external/pybind11-2.11.1/.pre-commit-config.yaml b/dmff/dpnblist/external/pybind11-2.11.1/.pre-commit-config.yaml new file mode 100644 index 00000000..86ac965d --- /dev/null +++ b/dmff/dpnblist/external/pybind11-2.11.1/.pre-commit-config.yaml @@ -0,0 +1,153 @@ +# To use: +# +# pre-commit run -a +# +# Or: +# +# pre-commit install # (runs every time you commit in git) +# +# To update this file: +# +# pre-commit autoupdate +# +# See https://github.com/pre-commit/pre-commit + + +ci: + autoupdate_commit_msg: "chore(deps): update pre-commit hooks" + autofix_commit_msg: "style: pre-commit fixes" + autoupdate_schedule: monthly + +# third-party content +exclude: ^tools/JoinPaths.cmake$ + +repos: + +# Clang format the codebase automatically +- repo: https://github.com/pre-commit/mirrors-clang-format + rev: "v16.0.6" + hooks: + - id: clang-format + types_or: [c++, c, cuda] + +# Black, the code formatter, natively supports pre-commit +- repo: https://github.com/psf/black + rev: "23.3.0" # Keep in sync with blacken-docs + hooks: + - id: black + +# Ruff, the Python auto-correcting linter written in Rust +- repo: https://github.com/astral-sh/ruff-pre-commit + rev: v0.0.276 + hooks: + - id: ruff + args: ["--fix", "--show-fixes"] + +# Check static types with mypy +- repo: https://github.com/pre-commit/mirrors-mypy + rev: "v1.4.1" + hooks: + - id: mypy + args: [] + exclude: ^(tests|docs)/ + additional_dependencies: + - markdown-it-py<3 # Drop this together with dropping Python 3.7 support. + - nox + - rich + - types-setuptools + +# CMake formatting +- repo: https://github.com/cheshirekow/cmake-format-precommit + rev: "v0.6.13" + hooks: + - id: cmake-format + additional_dependencies: [pyyaml] + types: [file] + files: (\.cmake|CMakeLists.txt)(.in)?$ + +# Standard hooks +- repo: https://github.com/pre-commit/pre-commit-hooks + rev: "v4.4.0" + hooks: + - id: check-added-large-files + - id: check-case-conflict + - id: check-docstring-first + - id: check-merge-conflict + - id: check-symlinks + - id: check-toml + - id: check-yaml + - id: debug-statements + - id: end-of-file-fixer + - id: mixed-line-ending + - id: requirements-txt-fixer + - id: trailing-whitespace + +# Also code format the docs +- repo: https://github.com/asottile/blacken-docs + rev: "1.14.0" + hooks: + - id: blacken-docs + additional_dependencies: + - black==23.3.0 # keep in sync with black hook + +# Changes tabs to spaces +- repo: https://github.com/Lucas-C/pre-commit-hooks + rev: "v1.5.1" + hooks: + - id: remove-tabs + +# Avoid directional quotes +- repo: https://github.com/sirosen/texthooks + rev: "0.5.0" + hooks: + - id: fix-ligatures + - id: fix-smartquotes + +# Checking for common mistakes +- repo: https://github.com/pre-commit/pygrep-hooks + rev: "v1.10.0" + hooks: + - id: rst-backticks + - id: rst-directive-colons + - id: rst-inline-touching-normal + +# Checks the manifest for missing files (native support) +- repo: https://github.com/mgedmin/check-manifest + rev: "0.49" + hooks: + - id: check-manifest + # This is a slow hook, so only run this if --hook-stage manual is passed + stages: [manual] + additional_dependencies: [cmake, ninja] + +# Check for spelling +# Use tools/codespell_ignore_lines_from_errors.py +# to rebuild .codespell-ignore-lines +- repo: https://github.com/codespell-project/codespell + rev: "v2.2.5" + hooks: + - id: codespell + exclude: ".supp$" + args: ["-x.codespell-ignore-lines", "-Lccompiler"] + +# Check for common shell mistakes +- repo: https://github.com/shellcheck-py/shellcheck-py + rev: "v0.9.0.5" + hooks: + - id: shellcheck + +# Disallow some common capitalization mistakes +- repo: local + hooks: + - id: disallow-caps + name: Disallow improper capitalization + language: pygrep + entry: PyBind|Numpy|Cmake|CCache|PyTest + exclude: ^\.pre-commit-config.yaml$ + +# PyLint has native support - not always usable, but works for us +- repo: https://github.com/PyCQA/pylint + rev: "v3.0.0a6" + hooks: + - id: pylint + files: ^pybind11 diff --git a/dmff/dpnblist/external/pybind11-2.11.1/.readthedocs.yml b/dmff/dpnblist/external/pybind11-2.11.1/.readthedocs.yml new file mode 100644 index 00000000..c9c61617 --- /dev/null +++ b/dmff/dpnblist/external/pybind11-2.11.1/.readthedocs.yml @@ -0,0 +1,3 @@ +python: + version: 3 +requirements_file: docs/requirements.txt diff --git a/dmff/dpnblist/external/pybind11-2.11.1/CMakeLists.txt b/dmff/dpnblist/external/pybind11-2.11.1/CMakeLists.txt new file mode 100644 index 00000000..87ec1034 --- /dev/null +++ b/dmff/dpnblist/external/pybind11-2.11.1/CMakeLists.txt @@ -0,0 +1,322 @@ +# CMakeLists.txt -- Build system for the pybind11 modules +# +# Copyright (c) 2015 Wenzel Jakob +# +# All rights reserved. Use of this source code is governed by a +# BSD-style license that can be found in the LICENSE file. + +cmake_minimum_required(VERSION 3.5) + +# The `cmake_minimum_required(VERSION 3.5...3.26)` syntax does not work with +# some versions of VS that have a patched CMake 3.11. This forces us to emulate +# the behavior using the following workaround: +if(${CMAKE_VERSION} VERSION_LESS 3.26) + cmake_policy(VERSION ${CMAKE_MAJOR_VERSION}.${CMAKE_MINOR_VERSION}) +else() + cmake_policy(VERSION 3.26) +endif() + +# Avoid infinite recursion if tests include this as a subdirectory +if(DEFINED PYBIND11_MASTER_PROJECT) + return() +endif() + +# Extract project version from source +file(STRINGS "${CMAKE_CURRENT_SOURCE_DIR}/include/pybind11/detail/common.h" + pybind11_version_defines REGEX "#define PYBIND11_VERSION_(MAJOR|MINOR|PATCH) ") + +foreach(ver ${pybind11_version_defines}) + if(ver MATCHES [[#define PYBIND11_VERSION_(MAJOR|MINOR|PATCH) +([^ ]+)$]]) + set(PYBIND11_VERSION_${CMAKE_MATCH_1} "${CMAKE_MATCH_2}") + endif() +endforeach() + +if(PYBIND11_VERSION_PATCH MATCHES [[\.([a-zA-Z0-9]+)$]]) + set(pybind11_VERSION_TYPE "${CMAKE_MATCH_1}") +endif() +string(REGEX MATCH "^[0-9]+" PYBIND11_VERSION_PATCH "${PYBIND11_VERSION_PATCH}") + +project( + pybind11 + LANGUAGES CXX + VERSION "${PYBIND11_VERSION_MAJOR}.${PYBIND11_VERSION_MINOR}.${PYBIND11_VERSION_PATCH}") + +# Standard includes +include(GNUInstallDirs) +include(CMakePackageConfigHelpers) +include(CMakeDependentOption) + +if(NOT pybind11_FIND_QUIETLY) + message(STATUS "pybind11 v${pybind11_VERSION} ${pybind11_VERSION_TYPE}") +endif() + +# Check if pybind11 is being used directly or via add_subdirectory +if(CMAKE_SOURCE_DIR STREQUAL PROJECT_SOURCE_DIR) + ### Warn if not an out-of-source builds + if(CMAKE_CURRENT_SOURCE_DIR STREQUAL CMAKE_CURRENT_BINARY_DIR) + set(lines + "You are building in-place. If that is not what you intended to " + "do, you can clean the source directory with:\n" + "rm -r CMakeCache.txt CMakeFiles/ cmake_uninstall.cmake pybind11Config.cmake " + "pybind11ConfigVersion.cmake tests/CMakeFiles/\n") + message(AUTHOR_WARNING ${lines}) + endif() + + set(PYBIND11_MASTER_PROJECT ON) + + if(OSX AND CMAKE_VERSION VERSION_LESS 3.7) + # Bug in macOS CMake < 3.7 is unable to download catch + message(WARNING "CMAKE 3.7+ needed on macOS to download catch, and newer HIGHLY recommended") + elseif(WINDOWS AND CMAKE_VERSION VERSION_LESS 3.8) + # Only tested with 3.8+ in CI. + message(WARNING "CMAKE 3.8+ tested on Windows, previous versions untested") + endif() + + message(STATUS "CMake ${CMAKE_VERSION}") + + if(CMAKE_CXX_STANDARD) + set(CMAKE_CXX_EXTENSIONS OFF) + set(CMAKE_CXX_STANDARD_REQUIRED ON) + endif() + + set(pybind11_system "") + + set_property(GLOBAL PROPERTY USE_FOLDERS ON) +else() + set(PYBIND11_MASTER_PROJECT OFF) + set(pybind11_system SYSTEM) +endif() + +# Options +option(PYBIND11_INSTALL "Install pybind11 header files?" ${PYBIND11_MASTER_PROJECT}) +option(PYBIND11_TEST "Build pybind11 test suite?" ${PYBIND11_MASTER_PROJECT}) +option(PYBIND11_NOPYTHON "Disable search for Python" OFF) +option(PYBIND11_SIMPLE_GIL_MANAGEMENT + "Use simpler GIL management logic that does not support disassociation" OFF) +set(PYBIND11_INTERNALS_VERSION + "" + CACHE STRING "Override the ABI version, may be used to enable the unstable ABI.") + +if(PYBIND11_SIMPLE_GIL_MANAGEMENT) + add_compile_definitions(PYBIND11_SIMPLE_GIL_MANAGEMENT) +endif() + +cmake_dependent_option( + USE_PYTHON_INCLUDE_DIR + "Install pybind11 headers in Python include directory instead of default installation prefix" + OFF "PYBIND11_INSTALL" OFF) + +cmake_dependent_option(PYBIND11_FINDPYTHON "Force new FindPython" OFF + "NOT CMAKE_VERSION VERSION_LESS 3.12" OFF) + +# NB: when adding a header don't forget to also add it to setup.py +set(PYBIND11_HEADERS + include/pybind11/detail/class.h + include/pybind11/detail/common.h + include/pybind11/detail/descr.h + include/pybind11/detail/init.h + include/pybind11/detail/internals.h + include/pybind11/detail/type_caster_base.h + include/pybind11/detail/typeid.h + include/pybind11/attr.h + include/pybind11/buffer_info.h + include/pybind11/cast.h + include/pybind11/chrono.h + include/pybind11/common.h + include/pybind11/complex.h + include/pybind11/options.h + include/pybind11/eigen.h + include/pybind11/eigen/common.h + include/pybind11/eigen/matrix.h + include/pybind11/eigen/tensor.h + include/pybind11/embed.h + include/pybind11/eval.h + include/pybind11/gil.h + include/pybind11/iostream.h + include/pybind11/functional.h + include/pybind11/numpy.h + include/pybind11/operators.h + include/pybind11/pybind11.h + include/pybind11/pytypes.h + include/pybind11/stl.h + include/pybind11/stl_bind.h + include/pybind11/stl/filesystem.h + include/pybind11/type_caster_pyobject_ptr.h) + +# Compare with grep and warn if mismatched +if(PYBIND11_MASTER_PROJECT AND NOT CMAKE_VERSION VERSION_LESS 3.12) + file( + GLOB_RECURSE _pybind11_header_check + LIST_DIRECTORIES false + RELATIVE "${CMAKE_CURRENT_SOURCE_DIR}" + CONFIGURE_DEPENDS "include/pybind11/*.h") + set(_pybind11_here_only ${PYBIND11_HEADERS}) + set(_pybind11_disk_only ${_pybind11_header_check}) + list(REMOVE_ITEM _pybind11_here_only ${_pybind11_header_check}) + list(REMOVE_ITEM _pybind11_disk_only ${PYBIND11_HEADERS}) + if(_pybind11_here_only) + message(AUTHOR_WARNING "PYBIND11_HEADERS has extra files:" ${_pybind11_here_only}) + endif() + if(_pybind11_disk_only) + message(AUTHOR_WARNING "PYBIND11_HEADERS is missing files:" ${_pybind11_disk_only}) + endif() +endif() + +# CMake 3.12 added list(TRANSFORM PREPEND +# But we can't use it yet +string(REPLACE "include/" "${CMAKE_CURRENT_SOURCE_DIR}/include/" PYBIND11_HEADERS + "${PYBIND11_HEADERS}") + +# Cache variable so this can be used in parent projects +set(pybind11_INCLUDE_DIR + "${CMAKE_CURRENT_LIST_DIR}/include" + CACHE INTERNAL "Directory where pybind11 headers are located") + +# Backward compatible variable for add_subdirectory mode +if(NOT PYBIND11_MASTER_PROJECT) + set(PYBIND11_INCLUDE_DIR + "${pybind11_INCLUDE_DIR}" + CACHE INTERNAL "") +endif() + +# Note: when creating targets, you cannot use if statements at configure time - +# you need generator expressions, because those will be placed in the target file. +# You can also place ifs *in* the Config.in, but not here. + +# This section builds targets, but does *not* touch Python +# Non-IMPORT targets cannot be defined twice +if(NOT TARGET pybind11_headers) + # Build the headers-only target (no Python included): + # (long name used here to keep this from clashing in subdirectory mode) + add_library(pybind11_headers INTERFACE) + add_library(pybind11::pybind11_headers ALIAS pybind11_headers) # to match exported target + add_library(pybind11::headers ALIAS pybind11_headers) # easier to use/remember + + target_include_directories( + pybind11_headers ${pybind11_system} INTERFACE $ + $) + + target_compile_features(pybind11_headers INTERFACE cxx_inheriting_constructors cxx_user_literals + cxx_right_angle_brackets) + if(NOT "${PYBIND11_INTERNALS_VERSION}" STREQUAL "") + target_compile_definitions( + pybind11_headers INTERFACE "PYBIND11_INTERNALS_VERSION=${PYBIND11_INTERNALS_VERSION}") + endif() +else() + # It is invalid to install a target twice, too. + set(PYBIND11_INSTALL OFF) +endif() + +include("${CMAKE_CURRENT_SOURCE_DIR}/tools/pybind11Common.cmake") +# https://github.com/jtojnar/cmake-snips/#concatenating-paths-when-building-pkg-config-files +# TODO: cmake 3.20 adds the cmake_path() function, which obsoletes this snippet +include("${CMAKE_CURRENT_SOURCE_DIR}/tools/JoinPaths.cmake") + +# Relative directory setting +if(USE_PYTHON_INCLUDE_DIR AND DEFINED Python_INCLUDE_DIRS) + file(RELATIVE_PATH CMAKE_INSTALL_INCLUDEDIR ${CMAKE_INSTALL_PREFIX} ${Python_INCLUDE_DIRS}) +elseif(USE_PYTHON_INCLUDE_DIR AND DEFINED PYTHON_INCLUDE_DIR) + file(RELATIVE_PATH CMAKE_INSTALL_INCLUDEDIR ${CMAKE_INSTALL_PREFIX} ${PYTHON_INCLUDE_DIRS}) +endif() + +if(PYBIND11_INSTALL) + install(DIRECTORY ${pybind11_INCLUDE_DIR}/pybind11 DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}) + set(PYBIND11_CMAKECONFIG_INSTALL_DIR + "${CMAKE_INSTALL_DATAROOTDIR}/cmake/${PROJECT_NAME}" + CACHE STRING "install path for pybind11Config.cmake") + + if(IS_ABSOLUTE "${CMAKE_INSTALL_INCLUDEDIR}") + set(pybind11_INCLUDEDIR "${CMAKE_INSTALL_FULL_INCLUDEDIR}") + else() + set(pybind11_INCLUDEDIR "\$\{PACKAGE_PREFIX_DIR\}/${CMAKE_INSTALL_INCLUDEDIR}") + endif() + + configure_package_config_file( + tools/${PROJECT_NAME}Config.cmake.in "${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}Config.cmake" + INSTALL_DESTINATION ${PYBIND11_CMAKECONFIG_INSTALL_DIR}) + + if(CMAKE_VERSION VERSION_LESS 3.14) + # Remove CMAKE_SIZEOF_VOID_P from ConfigVersion.cmake since the library does + # not depend on architecture specific settings or libraries. + set(_PYBIND11_CMAKE_SIZEOF_VOID_P ${CMAKE_SIZEOF_VOID_P}) + unset(CMAKE_SIZEOF_VOID_P) + + write_basic_package_version_file( + ${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}ConfigVersion.cmake + VERSION ${PROJECT_VERSION} + COMPATIBILITY AnyNewerVersion) + + set(CMAKE_SIZEOF_VOID_P ${_PYBIND11_CMAKE_SIZEOF_VOID_P}) + else() + # CMake 3.14+ natively supports header-only libraries + write_basic_package_version_file( + ${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}ConfigVersion.cmake + VERSION ${PROJECT_VERSION} + COMPATIBILITY AnyNewerVersion ARCH_INDEPENDENT) + endif() + + install( + FILES ${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}Config.cmake + ${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}ConfigVersion.cmake + tools/FindPythonLibsNew.cmake + tools/pybind11Common.cmake + tools/pybind11Tools.cmake + tools/pybind11NewTools.cmake + DESTINATION ${PYBIND11_CMAKECONFIG_INSTALL_DIR}) + + if(NOT PYBIND11_EXPORT_NAME) + set(PYBIND11_EXPORT_NAME "${PROJECT_NAME}Targets") + endif() + + install(TARGETS pybind11_headers EXPORT "${PYBIND11_EXPORT_NAME}") + + install( + EXPORT "${PYBIND11_EXPORT_NAME}" + NAMESPACE "pybind11::" + DESTINATION ${PYBIND11_CMAKECONFIG_INSTALL_DIR}) + + # pkg-config support + if(NOT prefix_for_pc_file) + set(prefix_for_pc_file "${CMAKE_INSTALL_PREFIX}") + endif() + join_paths(includedir_for_pc_file "\${prefix}" "${CMAKE_INSTALL_INCLUDEDIR}") + configure_file("${CMAKE_CURRENT_SOURCE_DIR}/tools/pybind11.pc.in" + "${CMAKE_CURRENT_BINARY_DIR}/pybind11.pc" @ONLY) + install(FILES "${CMAKE_CURRENT_BINARY_DIR}/pybind11.pc" + DESTINATION "${CMAKE_INSTALL_DATAROOTDIR}/pkgconfig/") + + # Uninstall target + if(PYBIND11_MASTER_PROJECT) + configure_file("${CMAKE_CURRENT_SOURCE_DIR}/tools/cmake_uninstall.cmake.in" + "${CMAKE_CURRENT_BINARY_DIR}/cmake_uninstall.cmake" IMMEDIATE @ONLY) + + add_custom_target(uninstall COMMAND ${CMAKE_COMMAND} -P + ${CMAKE_CURRENT_BINARY_DIR}/cmake_uninstall.cmake) + endif() +endif() + +# BUILD_TESTING takes priority, but only if this is the master project +if(PYBIND11_MASTER_PROJECT AND DEFINED BUILD_TESTING) + if(BUILD_TESTING) + if(_pybind11_nopython) + message(FATAL_ERROR "Cannot activate tests in NOPYTHON mode") + else() + add_subdirectory(tests) + endif() + endif() +else() + if(PYBIND11_TEST) + if(_pybind11_nopython) + message(FATAL_ERROR "Cannot activate tests in NOPYTHON mode") + else() + add_subdirectory(tests) + endif() + endif() +endif() + +# Better symmetry with find_package(pybind11 CONFIG) mode. +if(NOT PYBIND11_MASTER_PROJECT) + set(pybind11_FOUND + TRUE + CACHE INTERNAL "True if pybind11 and all required components found on the system") +endif() diff --git a/dmff/dpnblist/external/pybind11-2.11.1/LICENSE b/dmff/dpnblist/external/pybind11-2.11.1/LICENSE new file mode 100644 index 00000000..e466b0df --- /dev/null +++ b/dmff/dpnblist/external/pybind11-2.11.1/LICENSE @@ -0,0 +1,29 @@ +Copyright (c) 2016 Wenzel Jakob , All rights reserved. + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are met: + +1. Redistributions of source code must retain the above copyright notice, this + list of conditions and the following disclaimer. + +2. Redistributions in binary form must reproduce the above copyright notice, + this list of conditions and the following disclaimer in the documentation + and/or other materials provided with the distribution. + +3. Neither the name of the copyright holder nor the names of its contributors + may be used to endorse or promote products derived from this software + without specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND +ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE +FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR +SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER +CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, +OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +Please also refer to the file .github/CONTRIBUTING.md, which clarifies licensing of +external contributions to this project including patches, pull requests, etc. diff --git a/dmff/dpnblist/external/pybind11-2.11.1/MANIFEST.in b/dmff/dpnblist/external/pybind11-2.11.1/MANIFEST.in new file mode 100644 index 00000000..7ce83c55 --- /dev/null +++ b/dmff/dpnblist/external/pybind11-2.11.1/MANIFEST.in @@ -0,0 +1,6 @@ +prune tests +recursive-include pybind11/include/pybind11 *.h +recursive-include pybind11 *.py +recursive-include pybind11 py.typed +include pybind11/share/cmake/pybind11/*.cmake +include LICENSE README.rst SECURITY.md pyproject.toml setup.py setup.cfg diff --git a/dmff/dpnblist/external/pybind11-2.11.1/README.rst b/dmff/dpnblist/external/pybind11-2.11.1/README.rst new file mode 100644 index 00000000..80213a40 --- /dev/null +++ b/dmff/dpnblist/external/pybind11-2.11.1/README.rst @@ -0,0 +1,180 @@ +.. figure:: https://github.com/pybind/pybind11/raw/master/docs/pybind11-logo.png + :alt: pybind11 logo + +**pybind11 — Seamless operability between C++11 and Python** + +|Latest Documentation Status| |Stable Documentation Status| |Gitter chat| |GitHub Discussions| |CI| |Build status| + +|Repology| |PyPI package| |Conda-forge| |Python Versions| + +`Setuptools example `_ +• `Scikit-build example `_ +• `CMake example `_ + +.. start + + +**pybind11** is a lightweight header-only library that exposes C++ types +in Python and vice versa, mainly to create Python bindings of existing +C++ code. Its goals and syntax are similar to the excellent +`Boost.Python `_ +library by David Abrahams: to minimize boilerplate code in traditional +extension modules by inferring type information using compile-time +introspection. + +The main issue with Boost.Python—and the reason for creating such a +similar project—is Boost. Boost is an enormously large and complex suite +of utility libraries that works with almost every C++ compiler in +existence. This compatibility has its cost: arcane template tricks and +workarounds are necessary to support the oldest and buggiest of compiler +specimens. Now that C++11-compatible compilers are widely available, +this heavy machinery has become an excessively large and unnecessary +dependency. + +Think of this library as a tiny self-contained version of Boost.Python +with everything stripped away that isn't relevant for binding +generation. Without comments, the core header files only require ~4K +lines of code and depend on Python (3.6+, or PyPy) and the C++ +standard library. This compact implementation was possible thanks to +some of the new C++11 language features (specifically: tuples, lambda +functions and variadic templates). Since its creation, this library has +grown beyond Boost.Python in many ways, leading to dramatically simpler +binding code in many common situations. + +Tutorial and reference documentation is provided at +`pybind11.readthedocs.io `_. +A PDF version of the manual is available +`here `_. +And the source code is always available at +`github.com/pybind/pybind11 `_. + + +Core features +------------- + + +pybind11 can map the following core C++ features to Python: + +- Functions accepting and returning custom data structures per value, + reference, or pointer +- Instance methods and static methods +- Overloaded functions +- Instance attributes and static attributes +- Arbitrary exception types +- Enumerations +- Callbacks +- Iterators and ranges +- Custom operators +- Single and multiple inheritance +- STL data structures +- Smart pointers with reference counting like ``std::shared_ptr`` +- Internal references with correct reference counting +- C++ classes with virtual (and pure virtual) methods can be extended + in Python + +Goodies +------- + +In addition to the core functionality, pybind11 provides some extra +goodies: + +- Python 3.6+, and PyPy3 7.3 are supported with an implementation-agnostic + interface (pybind11 2.9 was the last version to support Python 2 and 3.5). + +- It is possible to bind C++11 lambda functions with captured + variables. The lambda capture data is stored inside the resulting + Python function object. + +- pybind11 uses C++11 move constructors and move assignment operators + whenever possible to efficiently transfer custom data types. + +- It's easy to expose the internal storage of custom data types through + Pythons' buffer protocols. This is handy e.g. for fast conversion + between C++ matrix classes like Eigen and NumPy without expensive + copy operations. + +- pybind11 can automatically vectorize functions so that they are + transparently applied to all entries of one or more NumPy array + arguments. + +- Python's slice-based access and assignment operations can be + supported with just a few lines of code. + +- Everything is contained in just a few header files; there is no need + to link against any additional libraries. + +- Binaries are generally smaller by a factor of at least 2 compared to + equivalent bindings generated by Boost.Python. A recent pybind11 + conversion of PyRosetta, an enormous Boost.Python binding project, + `reported `_ + a binary size reduction of **5.4x** and compile time reduction by + **5.8x**. + +- Function signatures are precomputed at compile time (using + ``constexpr``), leading to smaller binaries. + +- With little extra effort, C++ types can be pickled and unpickled + similar to regular Python objects. + +Supported compilers +------------------- + +1. Clang/LLVM 3.3 or newer (for Apple Xcode's clang, this is 5.0.0 or + newer) +2. GCC 4.8 or newer +3. Microsoft Visual Studio 2017 or newer +4. Intel classic C++ compiler 18 or newer (ICC 20.2 tested in CI) +5. Cygwin/GCC (previously tested on 2.5.1) +6. NVCC (CUDA 11.0 tested in CI) +7. NVIDIA PGI (20.9 tested in CI) + +About +----- + +This project was created by `Wenzel +Jakob `_. Significant features and/or +improvements to the code were contributed by Jonas Adler, Lori A. Burns, +Sylvain Corlay, Eric Cousineau, Aaron Gokaslan, Ralf Grosse-Kunstleve, Trent Houliston, Axel +Huebl, @hulucc, Yannick Jadoul, Sergey Lyskov, Johan Mabille, Tomasz Miąsko, +Dean Moldovan, Ben Pritchard, Jason Rhinelander, Boris Schäling, Pim +Schellart, Henry Schreiner, Ivan Smirnov, Boris Staletic, and Patrick Stewart. + +We thank Google for a generous financial contribution to the continuous +integration infrastructure used by this project. + + +Contributing +~~~~~~~~~~~~ + +See the `contributing +guide `_ +for information on building and contributing to pybind11. + +License +~~~~~~~ + +pybind11 is provided under a BSD-style license that can be found in the +`LICENSE `_ +file. By using, distributing, or contributing to this project, you agree +to the terms and conditions of this license. + +.. |Latest Documentation Status| image:: https://readthedocs.org/projects/pybind11/badge?version=latest + :target: http://pybind11.readthedocs.org/en/latest +.. |Stable Documentation Status| image:: https://img.shields.io/badge/docs-stable-blue.svg + :target: http://pybind11.readthedocs.org/en/stable +.. |Gitter chat| image:: https://img.shields.io/gitter/room/gitterHQ/gitter.svg + :target: https://gitter.im/pybind/Lobby +.. |CI| image:: https://github.com/pybind/pybind11/workflows/CI/badge.svg + :target: https://github.com/pybind/pybind11/actions +.. |Build status| image:: https://ci.appveyor.com/api/projects/status/riaj54pn4h08xy40?svg=true + :target: https://ci.appveyor.com/project/wjakob/pybind11 +.. |PyPI package| image:: https://img.shields.io/pypi/v/pybind11.svg + :target: https://pypi.org/project/pybind11/ +.. |Conda-forge| image:: https://img.shields.io/conda/vn/conda-forge/pybind11.svg + :target: https://github.com/conda-forge/pybind11-feedstock +.. |Repology| image:: https://repology.org/badge/latest-versions/python:pybind11.svg + :target: https://repology.org/project/python:pybind11/versions +.. |Python Versions| image:: https://img.shields.io/pypi/pyversions/pybind11.svg + :target: https://pypi.org/project/pybind11/ +.. |GitHub Discussions| image:: https://img.shields.io/static/v1?label=Discussions&message=Ask&color=blue&logo=github + :target: https://github.com/pybind/pybind11/discussions diff --git a/dmff/dpnblist/external/pybind11-2.11.1/SECURITY.md b/dmff/dpnblist/external/pybind11-2.11.1/SECURITY.md new file mode 100644 index 00000000..3d74611f --- /dev/null +++ b/dmff/dpnblist/external/pybind11-2.11.1/SECURITY.md @@ -0,0 +1,13 @@ +# Security Policy + +## Supported Versions + +Security updates are applied only to the latest release. + +## Reporting a Vulnerability + +If you have discovered a security vulnerability in this project, please report it privately. **Do not disclose it as a public issue.** This gives us time to work with you to fix the issue before public exposure, reducing the chance that the exploit will be used before a patch is released. + +Please disclose it at [security advisory](https://github.com/pybind/pybind11/security/advisories/new). + +This project is maintained by a team of volunteers on a reasonable-effort basis. As such, please give us at least 90 days to work on a fix before public exposure. diff --git a/dmff/dpnblist/external/pybind11-2.11.1/docs/Doxyfile b/dmff/dpnblist/external/pybind11-2.11.1/docs/Doxyfile new file mode 100644 index 00000000..09138db3 --- /dev/null +++ b/dmff/dpnblist/external/pybind11-2.11.1/docs/Doxyfile @@ -0,0 +1,21 @@ +PROJECT_NAME = pybind11 +INPUT = ../include/pybind11/ +RECURSIVE = YES + +GENERATE_HTML = NO +GENERATE_LATEX = NO +GENERATE_XML = YES +XML_OUTPUT = .build/doxygenxml +XML_PROGRAMLISTING = YES + +MACRO_EXPANSION = YES +EXPAND_ONLY_PREDEF = YES +EXPAND_AS_DEFINED = PYBIND11_RUNTIME_EXCEPTION + +ALIASES = "rst=\verbatim embed:rst" +ALIASES += "endrst=\endverbatim" + +QUIET = YES +WARNINGS = YES +WARN_IF_UNDOCUMENTED = NO +PREDEFINED = PYBIND11_NOINLINE diff --git a/dmff/dpnblist/external/pybind11-2.11.1/docs/_static/css/custom.css b/dmff/dpnblist/external/pybind11-2.11.1/docs/_static/css/custom.css new file mode 100644 index 00000000..7a49a6ac --- /dev/null +++ b/dmff/dpnblist/external/pybind11-2.11.1/docs/_static/css/custom.css @@ -0,0 +1,3 @@ +.highlight .go { + color: #707070; +} diff --git a/dmff/dpnblist/external/pybind11-2.11.1/docs/advanced/cast/chrono.rst b/dmff/dpnblist/external/pybind11-2.11.1/docs/advanced/cast/chrono.rst new file mode 100644 index 00000000..fbd46057 --- /dev/null +++ b/dmff/dpnblist/external/pybind11-2.11.1/docs/advanced/cast/chrono.rst @@ -0,0 +1,81 @@ +Chrono +====== + +When including the additional header file :file:`pybind11/chrono.h` conversions +from C++11 chrono datatypes to python datetime objects are automatically enabled. +This header also enables conversions of python floats (often from sources such +as ``time.monotonic()``, ``time.perf_counter()`` and ``time.process_time()``) +into durations. + +An overview of clocks in C++11 +------------------------------ + +A point of confusion when using these conversions is the differences between +clocks provided in C++11. There are three clock types defined by the C++11 +standard and users can define their own if needed. Each of these clocks have +different properties and when converting to and from python will give different +results. + +The first clock defined by the standard is ``std::chrono::system_clock``. This +clock measures the current date and time. However, this clock changes with to +updates to the operating system time. For example, if your time is synchronised +with a time server this clock will change. This makes this clock a poor choice +for timing purposes but good for measuring the wall time. + +The second clock defined in the standard is ``std::chrono::steady_clock``. +This clock ticks at a steady rate and is never adjusted. This makes it excellent +for timing purposes, however the value in this clock does not correspond to the +current date and time. Often this clock will be the amount of time your system +has been on, although it does not have to be. This clock will never be the same +clock as the system clock as the system clock can change but steady clocks +cannot. + +The third clock defined in the standard is ``std::chrono::high_resolution_clock``. +This clock is the clock that has the highest resolution out of the clocks in the +system. It is normally a typedef to either the system clock or the steady clock +but can be its own independent clock. This is important as when using these +conversions as the types you get in python for this clock might be different +depending on the system. +If it is a typedef of the system clock, python will get datetime objects, but if +it is a different clock they will be timedelta objects. + +Provided conversions +-------------------- + +.. rubric:: C++ to Python + +- ``std::chrono::system_clock::time_point`` → ``datetime.datetime`` + System clock times are converted to python datetime instances. They are + in the local timezone, but do not have any timezone information attached + to them (they are naive datetime objects). + +- ``std::chrono::duration`` → ``datetime.timedelta`` + Durations are converted to timedeltas, any precision in the duration + greater than microseconds is lost by rounding towards zero. + +- ``std::chrono::[other_clocks]::time_point`` → ``datetime.timedelta`` + Any clock time that is not the system clock is converted to a time delta. + This timedelta measures the time from the clocks epoch to now. + +.. rubric:: Python to C++ + +- ``datetime.datetime`` or ``datetime.date`` or ``datetime.time`` → ``std::chrono::system_clock::time_point`` + Date/time objects are converted into system clock timepoints. Any + timezone information is ignored and the type is treated as a naive + object. + +- ``datetime.timedelta`` → ``std::chrono::duration`` + Time delta are converted into durations with microsecond precision. + +- ``datetime.timedelta`` → ``std::chrono::[other_clocks]::time_point`` + Time deltas that are converted into clock timepoints are treated as + the amount of time from the start of the clocks epoch. + +- ``float`` → ``std::chrono::duration`` + Floats that are passed to C++ as durations be interpreted as a number of + seconds. These will be converted to the duration using ``duration_cast`` + from the float. + +- ``float`` → ``std::chrono::[other_clocks]::time_point`` + Floats that are passed to C++ as time points will be interpreted as the + number of seconds from the start of the clocks epoch. diff --git a/dmff/dpnblist/external/pybind11-2.11.1/docs/advanced/cast/custom.rst b/dmff/dpnblist/external/pybind11-2.11.1/docs/advanced/cast/custom.rst new file mode 100644 index 00000000..8138cac6 --- /dev/null +++ b/dmff/dpnblist/external/pybind11-2.11.1/docs/advanced/cast/custom.rst @@ -0,0 +1,93 @@ +Custom type casters +=================== + +In very rare cases, applications may require custom type casters that cannot be +expressed using the abstractions provided by pybind11, thus requiring raw +Python C API calls. This is fairly advanced usage and should only be pursued by +experts who are familiar with the intricacies of Python reference counting. + +The following snippets demonstrate how this works for a very simple ``inty`` +type that that should be convertible from Python types that provide a +``__int__(self)`` method. + +.. code-block:: cpp + + struct inty { long long_value; }; + + void print(inty s) { + std::cout << s.long_value << std::endl; + } + +The following Python snippet demonstrates the intended usage from the Python side: + +.. code-block:: python + + class A: + def __int__(self): + return 123 + + + from example import print + + print(A()) + +To register the necessary conversion routines, it is necessary to add an +instantiation of the ``pybind11::detail::type_caster`` template. +Although this is an implementation detail, adding an instantiation of this +type is explicitly allowed. + +.. code-block:: cpp + + namespace PYBIND11_NAMESPACE { namespace detail { + template <> struct type_caster { + public: + /** + * This macro establishes the name 'inty' in + * function signatures and declares a local variable + * 'value' of type inty + */ + PYBIND11_TYPE_CASTER(inty, const_name("inty")); + + /** + * Conversion part 1 (Python->C++): convert a PyObject into a inty + * instance or return false upon failure. The second argument + * indicates whether implicit conversions should be applied. + */ + bool load(handle src, bool) { + /* Extract PyObject from handle */ + PyObject *source = src.ptr(); + /* Try converting into a Python integer value */ + PyObject *tmp = PyNumber_Long(source); + if (!tmp) + return false; + /* Now try to convert into a C++ int */ + value.long_value = PyLong_AsLong(tmp); + Py_DECREF(tmp); + /* Ensure return code was OK (to avoid out-of-range errors etc) */ + return !(value.long_value == -1 && !PyErr_Occurred()); + } + + /** + * Conversion part 2 (C++ -> Python): convert an inty instance into + * a Python object. The second and third arguments are used to + * indicate the return value policy and parent object (for + * ``return_value_policy::reference_internal``) and are generally + * ignored by implicit casters. + */ + static handle cast(inty src, return_value_policy /* policy */, handle /* parent */) { + return PyLong_FromLong(src.long_value); + } + }; + }} // namespace PYBIND11_NAMESPACE::detail + +.. note:: + + A ``type_caster`` defined with ``PYBIND11_TYPE_CASTER(T, ...)`` requires + that ``T`` is default-constructible (``value`` is first default constructed + and then ``load()`` assigns to it). + +.. warning:: + + When using custom type casters, it's important to declare them consistently + in every compilation unit of the Python extension module. Otherwise, + undefined behavior can ensue. diff --git a/dmff/dpnblist/external/pybind11-2.11.1/docs/advanced/cast/eigen.rst b/dmff/dpnblist/external/pybind11-2.11.1/docs/advanced/cast/eigen.rst new file mode 100644 index 00000000..a5c11a3f --- /dev/null +++ b/dmff/dpnblist/external/pybind11-2.11.1/docs/advanced/cast/eigen.rst @@ -0,0 +1,310 @@ +Eigen +##### + +`Eigen `_ is C++ header-based library for dense and +sparse linear algebra. Due to its popularity and widespread adoption, pybind11 +provides transparent conversion and limited mapping support between Eigen and +Scientific Python linear algebra data types. + +To enable the built-in Eigen support you must include the optional header file +:file:`pybind11/eigen.h`. + +Pass-by-value +============= + +When binding a function with ordinary Eigen dense object arguments (for +example, ``Eigen::MatrixXd``), pybind11 will accept any input value that is +already (or convertible to) a ``numpy.ndarray`` with dimensions compatible with +the Eigen type, copy its values into a temporary Eigen variable of the +appropriate type, then call the function with this temporary variable. + +Sparse matrices are similarly copied to or from +``scipy.sparse.csr_matrix``/``scipy.sparse.csc_matrix`` objects. + +Pass-by-reference +================= + +One major limitation of the above is that every data conversion implicitly +involves a copy, which can be both expensive (for large matrices) and disallows +binding functions that change their (Matrix) arguments. Pybind11 allows you to +work around this by using Eigen's ``Eigen::Ref`` class much as you +would when writing a function taking a generic type in Eigen itself (subject to +some limitations discussed below). + +When calling a bound function accepting a ``Eigen::Ref`` +type, pybind11 will attempt to avoid copying by using an ``Eigen::Map`` object +that maps into the source ``numpy.ndarray`` data: this requires both that the +data types are the same (e.g. ``dtype='float64'`` and ``MatrixType::Scalar`` is +``double``); and that the storage is layout compatible. The latter limitation +is discussed in detail in the section below, and requires careful +consideration: by default, numpy matrices and Eigen matrices are *not* storage +compatible. + +If the numpy matrix cannot be used as is (either because its types differ, e.g. +passing an array of integers to an Eigen parameter requiring doubles, or +because the storage is incompatible), pybind11 makes a temporary copy and +passes the copy instead. + +When a bound function parameter is instead ``Eigen::Ref`` (note the +lack of ``const``), pybind11 will only allow the function to be called if it +can be mapped *and* if the numpy array is writeable (that is +``a.flags.writeable`` is true). Any access (including modification) made to +the passed variable will be transparently carried out directly on the +``numpy.ndarray``. + +This means you can write code such as the following and have it work as +expected: + +.. code-block:: cpp + + void scale_by_2(Eigen::Ref v) { + v *= 2; + } + +Note, however, that you will likely run into limitations due to numpy and +Eigen's difference default storage order for data; see the below section on +:ref:`storage_orders` for details on how to bind code that won't run into such +limitations. + +.. note:: + + Passing by reference is not supported for sparse types. + +Returning values to Python +========================== + +When returning an ordinary dense Eigen matrix type to numpy (e.g. +``Eigen::MatrixXd`` or ``Eigen::RowVectorXf``) pybind11 keeps the matrix and +returns a numpy array that directly references the Eigen matrix: no copy of the +data is performed. The numpy array will have ``array.flags.owndata`` set to +``False`` to indicate that it does not own the data, and the lifetime of the +stored Eigen matrix will be tied to the returned ``array``. + +If you bind a function with a non-reference, ``const`` return type (e.g. +``const Eigen::MatrixXd``), the same thing happens except that pybind11 also +sets the numpy array's ``writeable`` flag to false. + +If you return an lvalue reference or pointer, the usual pybind11 rules apply, +as dictated by the binding function's return value policy (see the +documentation on :ref:`return_value_policies` for full details). That means, +without an explicit return value policy, lvalue references will be copied and +pointers will be managed by pybind11. In order to avoid copying, you should +explicitly specify an appropriate return value policy, as in the following +example: + +.. code-block:: cpp + + class MyClass { + Eigen::MatrixXd big_mat = Eigen::MatrixXd::Zero(10000, 10000); + public: + Eigen::MatrixXd &getMatrix() { return big_mat; } + const Eigen::MatrixXd &viewMatrix() { return big_mat; } + }; + + // Later, in binding code: + py::class_(m, "MyClass") + .def(py::init<>()) + .def("copy_matrix", &MyClass::getMatrix) // Makes a copy! + .def("get_matrix", &MyClass::getMatrix, py::return_value_policy::reference_internal) + .def("view_matrix", &MyClass::viewMatrix, py::return_value_policy::reference_internal) + ; + +.. code-block:: python + + a = MyClass() + m = a.get_matrix() # flags.writeable = True, flags.owndata = False + v = a.view_matrix() # flags.writeable = False, flags.owndata = False + c = a.copy_matrix() # flags.writeable = True, flags.owndata = True + # m[5,6] and v[5,6] refer to the same element, c[5,6] does not. + +Note in this example that ``py::return_value_policy::reference_internal`` is +used to tie the life of the MyClass object to the life of the returned arrays. + +You may also return an ``Eigen::Ref``, ``Eigen::Map`` or other map-like Eigen +object (for example, the return value of ``matrix.block()`` and related +methods) that map into a dense Eigen type. When doing so, the default +behaviour of pybind11 is to simply reference the returned data: you must take +care to ensure that this data remains valid! You may ask pybind11 to +explicitly *copy* such a return value by using the +``py::return_value_policy::copy`` policy when binding the function. You may +also use ``py::return_value_policy::reference_internal`` or a +``py::keep_alive`` to ensure the data stays valid as long as the returned numpy +array does. + +When returning such a reference of map, pybind11 additionally respects the +readonly-status of the returned value, marking the numpy array as non-writeable +if the reference or map was itself read-only. + +.. note:: + + Sparse types are always copied when returned. + +.. _storage_orders: + +Storage orders +============== + +Passing arguments via ``Eigen::Ref`` has some limitations that you must be +aware of in order to effectively pass matrices by reference. First and +foremost is that the default ``Eigen::Ref`` class requires +contiguous storage along columns (for column-major types, the default in Eigen) +or rows if ``MatrixType`` is specifically an ``Eigen::RowMajor`` storage type. +The former, Eigen's default, is incompatible with ``numpy``'s default row-major +storage, and so you will not be able to pass numpy arrays to Eigen by reference +without making one of two changes. + +(Note that this does not apply to vectors (or column or row matrices): for such +types the "row-major" and "column-major" distinction is meaningless). + +The first approach is to change the use of ``Eigen::Ref`` to the +more general ``Eigen::Ref>`` (or similar type with a fully dynamic stride type in the +third template argument). Since this is a rather cumbersome type, pybind11 +provides a ``py::EigenDRef`` type alias for your convenience (along +with EigenDMap for the equivalent Map, and EigenDStride for just the stride +type). + +This type allows Eigen to map into any arbitrary storage order. This is not +the default in Eigen for performance reasons: contiguous storage allows +vectorization that cannot be done when storage is not known to be contiguous at +compile time. The default ``Eigen::Ref`` stride type allows non-contiguous +storage along the outer dimension (that is, the rows of a column-major matrix +or columns of a row-major matrix), but not along the inner dimension. + +This type, however, has the added benefit of also being able to map numpy array +slices. For example, the following (contrived) example uses Eigen with a numpy +slice to multiply by 2 all coefficients that are both on even rows (0, 2, 4, +...) and in columns 2, 5, or 8: + +.. code-block:: cpp + + m.def("scale", [](py::EigenDRef m, double c) { m *= c; }); + +.. code-block:: python + + # a = np.array(...) + scale_by_2(myarray[0::2, 2:9:3]) + +The second approach to avoid copying is more intrusive: rearranging the +underlying data types to not run into the non-contiguous storage problem in the +first place. In particular, that means using matrices with ``Eigen::RowMajor`` +storage, where appropriate, such as: + +.. code-block:: cpp + + using RowMatrixXd = Eigen::Matrix; + // Use RowMatrixXd instead of MatrixXd + +Now bound functions accepting ``Eigen::Ref`` arguments will be +callable with numpy's (default) arrays without involving a copying. + +You can, alternatively, change the storage order that numpy arrays use by +adding the ``order='F'`` option when creating an array: + +.. code-block:: python + + myarray = np.array(source, order="F") + +Such an object will be passable to a bound function accepting an +``Eigen::Ref`` (or similar column-major Eigen type). + +One major caveat with this approach, however, is that it is not entirely as +easy as simply flipping all Eigen or numpy usage from one to the other: some +operations may alter the storage order of a numpy array. For example, ``a2 = +array.transpose()`` results in ``a2`` being a view of ``array`` that references +the same data, but in the opposite storage order! + +While this approach allows fully optimized vectorized calculations in Eigen, it +cannot be used with array slices, unlike the first approach. + +When *returning* a matrix to Python (either a regular matrix, a reference via +``Eigen::Ref<>``, or a map/block into a matrix), no special storage +consideration is required: the created numpy array will have the required +stride that allows numpy to properly interpret the array, whatever its storage +order. + +Failing rather than copying +=========================== + +The default behaviour when binding ``Eigen::Ref`` Eigen +references is to copy matrix values when passed a numpy array that does not +conform to the element type of ``MatrixType`` or does not have a compatible +stride layout. If you want to explicitly avoid copying in such a case, you +should bind arguments using the ``py::arg().noconvert()`` annotation (as +described in the :ref:`nonconverting_arguments` documentation). + +The following example shows an example of arguments that don't allow data +copying to take place: + +.. code-block:: cpp + + // The method and function to be bound: + class MyClass { + // ... + double some_method(const Eigen::Ref &matrix) { /* ... */ } + }; + float some_function(const Eigen::Ref &big, + const Eigen::Ref &small) { + // ... + } + + // The associated binding code: + using namespace pybind11::literals; // for "arg"_a + py::class_(m, "MyClass") + // ... other class definitions + .def("some_method", &MyClass::some_method, py::arg().noconvert()); + + m.def("some_function", &some_function, + "big"_a.noconvert(), // <- Don't allow copying for this arg + "small"_a // <- This one can be copied if needed + ); + +With the above binding code, attempting to call the the ``some_method(m)`` +method on a ``MyClass`` object, or attempting to call ``some_function(m, m2)`` +will raise a ``RuntimeError`` rather than making a temporary copy of the array. +It will, however, allow the ``m2`` argument to be copied into a temporary if +necessary. + +Note that explicitly specifying ``.noconvert()`` is not required for *mutable* +Eigen references (e.g. ``Eigen::Ref`` without ``const`` on the +``MatrixXd``): mutable references will never be called with a temporary copy. + +Vectors versus column/row matrices +================================== + +Eigen and numpy have fundamentally different notions of a vector. In Eigen, a +vector is simply a matrix with the number of columns or rows set to 1 at +compile time (for a column vector or row vector, respectively). NumPy, in +contrast, has comparable 2-dimensional 1xN and Nx1 arrays, but *also* has +1-dimensional arrays of size N. + +When passing a 2-dimensional 1xN or Nx1 array to Eigen, the Eigen type must +have matching dimensions: That is, you cannot pass a 2-dimensional Nx1 numpy +array to an Eigen value expecting a row vector, or a 1xN numpy array as a +column vector argument. + +On the other hand, pybind11 allows you to pass 1-dimensional arrays of length N +as Eigen parameters. If the Eigen type can hold a column vector of length N it +will be passed as such a column vector. If not, but the Eigen type constraints +will accept a row vector, it will be passed as a row vector. (The column +vector takes precedence when both are supported, for example, when passing a +1D numpy array to a MatrixXd argument). Note that the type need not be +explicitly a vector: it is permitted to pass a 1D numpy array of size 5 to an +Eigen ``Matrix``: you would end up with a 1x5 Eigen matrix. +Passing the same to an ``Eigen::MatrixXd`` would result in a 5x1 Eigen matrix. + +When returning an Eigen vector to numpy, the conversion is ambiguous: a row +vector of length 4 could be returned as either a 1D array of length 4, or as a +2D array of size 1x4. When encountering such a situation, pybind11 compromises +by considering the returned Eigen type: if it is a compile-time vector--that +is, the type has either the number of rows or columns set to 1 at compile +time--pybind11 converts to a 1D numpy array when returning the value. For +instances that are a vector only at run-time (e.g. ``MatrixXd``, +``Matrix``), pybind11 returns the vector as a 2D array to +numpy. If this isn't want you want, you can use ``array.reshape(...)`` to get +a view of the same data in the desired dimensions. + +.. seealso:: + + The file :file:`tests/test_eigen.cpp` contains a complete example that + shows how to pass Eigen sparse and dense data types in more detail. diff --git a/dmff/dpnblist/external/pybind11-2.11.1/docs/advanced/cast/functional.rst b/dmff/dpnblist/external/pybind11-2.11.1/docs/advanced/cast/functional.rst new file mode 100644 index 00000000..d9b46057 --- /dev/null +++ b/dmff/dpnblist/external/pybind11-2.11.1/docs/advanced/cast/functional.rst @@ -0,0 +1,109 @@ +Functional +########## + +The following features must be enabled by including :file:`pybind11/functional.h`. + + +Callbacks and passing anonymous functions +========================================= + +The C++11 standard brought lambda functions and the generic polymorphic +function wrapper ``std::function<>`` to the C++ programming language, which +enable powerful new ways of working with functions. Lambda functions come in +two flavors: stateless lambda function resemble classic function pointers that +link to an anonymous piece of code, while stateful lambda functions +additionally depend on captured variables that are stored in an anonymous +*lambda closure object*. + +Here is a simple example of a C++ function that takes an arbitrary function +(stateful or stateless) with signature ``int -> int`` as an argument and runs +it with the value 10. + +.. code-block:: cpp + + int func_arg(const std::function &f) { + return f(10); + } + +The example below is more involved: it takes a function of signature ``int -> int`` +and returns another function of the same kind. The return value is a stateful +lambda function, which stores the value ``f`` in the capture object and adds 1 to +its return value upon execution. + +.. code-block:: cpp + + std::function func_ret(const std::function &f) { + return [f](int i) { + return f(i) + 1; + }; + } + +This example demonstrates using python named parameters in C++ callbacks which +requires using ``py::cpp_function`` as a wrapper. Usage is similar to defining +methods of classes: + +.. code-block:: cpp + + py::cpp_function func_cpp() { + return py::cpp_function([](int i) { return i+1; }, + py::arg("number")); + } + +After including the extra header file :file:`pybind11/functional.h`, it is almost +trivial to generate binding code for all of these functions. + +.. code-block:: cpp + + #include + + PYBIND11_MODULE(example, m) { + m.def("func_arg", &func_arg); + m.def("func_ret", &func_ret); + m.def("func_cpp", &func_cpp); + } + +The following interactive session shows how to call them from Python. + +.. code-block:: pycon + + $ python + >>> import example + >>> def square(i): + ... return i * i + ... + >>> example.func_arg(square) + 100L + >>> square_plus_1 = example.func_ret(square) + >>> square_plus_1(4) + 17L + >>> plus_1 = func_cpp() + >>> plus_1(number=43) + 44L + +.. warning:: + + Keep in mind that passing a function from C++ to Python (or vice versa) + will instantiate a piece of wrapper code that translates function + invocations between the two languages. Naturally, this translation + increases the computational cost of each function call somewhat. A + problematic situation can arise when a function is copied back and forth + between Python and C++ many times in a row, in which case the underlying + wrappers will accumulate correspondingly. The resulting long sequence of + C++ -> Python -> C++ -> ... roundtrips can significantly decrease + performance. + + There is one exception: pybind11 detects case where a stateless function + (i.e. a function pointer or a lambda function without captured variables) + is passed as an argument to another C++ function exposed in Python. In this + case, there is no overhead. Pybind11 will extract the underlying C++ + function pointer from the wrapped function to sidestep a potential C++ -> + Python -> C++ roundtrip. This is demonstrated in :file:`tests/test_callbacks.cpp`. + +.. note:: + + This functionality is very useful when generating bindings for callbacks in + C++ libraries (e.g. GUI libraries, asynchronous networking libraries, etc.). + + The file :file:`tests/test_callbacks.cpp` contains a complete example + that demonstrates how to work with callbacks and anonymous functions in + more detail. diff --git a/dmff/dpnblist/external/pybind11-2.11.1/docs/advanced/cast/index.rst b/dmff/dpnblist/external/pybind11-2.11.1/docs/advanced/cast/index.rst new file mode 100644 index 00000000..3ce9ea02 --- /dev/null +++ b/dmff/dpnblist/external/pybind11-2.11.1/docs/advanced/cast/index.rst @@ -0,0 +1,43 @@ +.. _type-conversions: + +Type conversions +################ + +Apart from enabling cross-language function calls, a fundamental problem +that a binding tool like pybind11 must address is to provide access to +native Python types in C++ and vice versa. There are three fundamentally +different ways to do this—which approach is preferable for a particular type +depends on the situation at hand. + +1. Use a native C++ type everywhere. In this case, the type must be wrapped + using pybind11-generated bindings so that Python can interact with it. + +2. Use a native Python type everywhere. It will need to be wrapped so that + C++ functions can interact with it. + +3. Use a native C++ type on the C++ side and a native Python type on the + Python side. pybind11 refers to this as a *type conversion*. + + Type conversions are the most "natural" option in the sense that native + (non-wrapped) types are used everywhere. The main downside is that a copy + of the data must be made on every Python ↔ C++ transition: this is + needed since the C++ and Python versions of the same type generally won't + have the same memory layout. + + pybind11 can perform many kinds of conversions automatically. An overview + is provided in the table ":ref:`conversion_table`". + +The following subsections discuss the differences between these options in more +detail. The main focus in this section is on type conversions, which represent +the last case of the above list. + +.. toctree:: + :maxdepth: 1 + + overview + strings + stl + functional + chrono + eigen + custom diff --git a/dmff/dpnblist/external/pybind11-2.11.1/docs/advanced/cast/overview.rst b/dmff/dpnblist/external/pybind11-2.11.1/docs/advanced/cast/overview.rst new file mode 100644 index 00000000..011bd4c7 --- /dev/null +++ b/dmff/dpnblist/external/pybind11-2.11.1/docs/advanced/cast/overview.rst @@ -0,0 +1,170 @@ +Overview +######## + +.. rubric:: 1. Native type in C++, wrapper in Python + +Exposing a custom C++ type using :class:`py::class_` was covered in detail +in the :doc:`/classes` section. There, the underlying data structure is +always the original C++ class while the :class:`py::class_` wrapper provides +a Python interface. Internally, when an object like this is sent from C++ to +Python, pybind11 will just add the outer wrapper layer over the native C++ +object. Getting it back from Python is just a matter of peeling off the +wrapper. + +.. rubric:: 2. Wrapper in C++, native type in Python + +This is the exact opposite situation. Now, we have a type which is native to +Python, like a ``tuple`` or a ``list``. One way to get this data into C++ is +with the :class:`py::object` family of wrappers. These are explained in more +detail in the :doc:`/advanced/pycpp/object` section. We'll just give a quick +example here: + +.. code-block:: cpp + + void print_list(py::list my_list) { + for (auto item : my_list) + std::cout << item << " "; + } + +.. code-block:: pycon + + >>> print_list([1, 2, 3]) + 1 2 3 + +The Python ``list`` is not converted in any way -- it's just wrapped in a C++ +:class:`py::list` class. At its core it's still a Python object. Copying a +:class:`py::list` will do the usual reference-counting like in Python. +Returning the object to Python will just remove the thin wrapper. + +.. rubric:: 3. Converting between native C++ and Python types + +In the previous two cases we had a native type in one language and a wrapper in +the other. Now, we have native types on both sides and we convert between them. + +.. code-block:: cpp + + void print_vector(const std::vector &v) { + for (auto item : v) + std::cout << item << "\n"; + } + +.. code-block:: pycon + + >>> print_vector([1, 2, 3]) + 1 2 3 + +In this case, pybind11 will construct a new ``std::vector`` and copy each +element from the Python ``list``. The newly constructed object will be passed +to ``print_vector``. The same thing happens in the other direction: a new +``list`` is made to match the value returned from C++. + +Lots of these conversions are supported out of the box, as shown in the table +below. They are very convenient, but keep in mind that these conversions are +fundamentally based on copying data. This is perfectly fine for small immutable +types but it may become quite expensive for large data structures. This can be +avoided by overriding the automatic conversion with a custom wrapper (i.e. the +above-mentioned approach 1). This requires some manual effort and more details +are available in the :ref:`opaque` section. + +.. _conversion_table: + +List of all builtin conversions +------------------------------- + +The following basic data types are supported out of the box (some may require +an additional extension header to be included). To pass other data structures +as arguments and return values, refer to the section on binding :ref:`classes`. + ++------------------------------------+---------------------------+-----------------------------------+ +| Data type | Description | Header file | ++====================================+===========================+===================================+ +| ``int8_t``, ``uint8_t`` | 8-bit integers | :file:`pybind11/pybind11.h` | ++------------------------------------+---------------------------+-----------------------------------+ +| ``int16_t``, ``uint16_t`` | 16-bit integers | :file:`pybind11/pybind11.h` | ++------------------------------------+---------------------------+-----------------------------------+ +| ``int32_t``, ``uint32_t`` | 32-bit integers | :file:`pybind11/pybind11.h` | ++------------------------------------+---------------------------+-----------------------------------+ +| ``int64_t``, ``uint64_t`` | 64-bit integers | :file:`pybind11/pybind11.h` | ++------------------------------------+---------------------------+-----------------------------------+ +| ``ssize_t``, ``size_t`` | Platform-dependent size | :file:`pybind11/pybind11.h` | ++------------------------------------+---------------------------+-----------------------------------+ +| ``float``, ``double`` | Floating point types | :file:`pybind11/pybind11.h` | ++------------------------------------+---------------------------+-----------------------------------+ +| ``bool`` | Two-state Boolean type | :file:`pybind11/pybind11.h` | ++------------------------------------+---------------------------+-----------------------------------+ +| ``char`` | Character literal | :file:`pybind11/pybind11.h` | ++------------------------------------+---------------------------+-----------------------------------+ +| ``char16_t`` | UTF-16 character literal | :file:`pybind11/pybind11.h` | ++------------------------------------+---------------------------+-----------------------------------+ +| ``char32_t`` | UTF-32 character literal | :file:`pybind11/pybind11.h` | ++------------------------------------+---------------------------+-----------------------------------+ +| ``wchar_t`` | Wide character literal | :file:`pybind11/pybind11.h` | ++------------------------------------+---------------------------+-----------------------------------+ +| ``const char *`` | UTF-8 string literal | :file:`pybind11/pybind11.h` | ++------------------------------------+---------------------------+-----------------------------------+ +| ``const char16_t *`` | UTF-16 string literal | :file:`pybind11/pybind11.h` | ++------------------------------------+---------------------------+-----------------------------------+ +| ``const char32_t *`` | UTF-32 string literal | :file:`pybind11/pybind11.h` | ++------------------------------------+---------------------------+-----------------------------------+ +| ``const wchar_t *`` | Wide string literal | :file:`pybind11/pybind11.h` | ++------------------------------------+---------------------------+-----------------------------------+ +| ``std::string`` | STL dynamic UTF-8 string | :file:`pybind11/pybind11.h` | ++------------------------------------+---------------------------+-----------------------------------+ +| ``std::u16string`` | STL dynamic UTF-16 string | :file:`pybind11/pybind11.h` | ++------------------------------------+---------------------------+-----------------------------------+ +| ``std::u32string`` | STL dynamic UTF-32 string | :file:`pybind11/pybind11.h` | ++------------------------------------+---------------------------+-----------------------------------+ +| ``std::wstring`` | STL dynamic wide string | :file:`pybind11/pybind11.h` | ++------------------------------------+---------------------------+-----------------------------------+ +| ``std::string_view``, | STL C++17 string views | :file:`pybind11/pybind11.h` | +| ``std::u16string_view``, etc. | | | ++------------------------------------+---------------------------+-----------------------------------+ +| ``std::pair`` | Pair of two custom types | :file:`pybind11/pybind11.h` | ++------------------------------------+---------------------------+-----------------------------------+ +| ``std::tuple<...>`` | Arbitrary tuple of types | :file:`pybind11/pybind11.h` | ++------------------------------------+---------------------------+-----------------------------------+ +| ``std::reference_wrapper<...>`` | Reference type wrapper | :file:`pybind11/pybind11.h` | ++------------------------------------+---------------------------+-----------------------------------+ +| ``std::complex`` | Complex numbers | :file:`pybind11/complex.h` | ++------------------------------------+---------------------------+-----------------------------------+ +| ``std::array`` | STL static array | :file:`pybind11/stl.h` | ++------------------------------------+---------------------------+-----------------------------------+ +| ``std::vector`` | STL dynamic array | :file:`pybind11/stl.h` | ++------------------------------------+---------------------------+-----------------------------------+ +| ``std::deque`` | STL double-ended queue | :file:`pybind11/stl.h` | ++------------------------------------+---------------------------+-----------------------------------+ +| ``std::valarray`` | STL value array | :file:`pybind11/stl.h` | ++------------------------------------+---------------------------+-----------------------------------+ +| ``std::list`` | STL linked list | :file:`pybind11/stl.h` | ++------------------------------------+---------------------------+-----------------------------------+ +| ``std::map`` | STL ordered map | :file:`pybind11/stl.h` | ++------------------------------------+---------------------------+-----------------------------------+ +| ``std::unordered_map`` | STL unordered map | :file:`pybind11/stl.h` | ++------------------------------------+---------------------------+-----------------------------------+ +| ``std::set`` | STL ordered set | :file:`pybind11/stl.h` | ++------------------------------------+---------------------------+-----------------------------------+ +| ``std::unordered_set`` | STL unordered set | :file:`pybind11/stl.h` | ++------------------------------------+---------------------------+-----------------------------------+ +| ``std::optional`` | STL optional type (C++17) | :file:`pybind11/stl.h` | ++------------------------------------+---------------------------+-----------------------------------+ +| ``std::experimental::optional`` | STL optional type (exp.) | :file:`pybind11/stl.h` | ++------------------------------------+---------------------------+-----------------------------------+ +| ``std::variant<...>`` | Type-safe union (C++17) | :file:`pybind11/stl.h` | ++------------------------------------+---------------------------+-----------------------------------+ +| ``std::filesystem::path`` | STL path (C++17) [#]_ | :file:`pybind11/stl/filesystem.h` | ++------------------------------------+---------------------------+-----------------------------------+ +| ``std::function<...>`` | STL polymorphic function | :file:`pybind11/functional.h` | ++------------------------------------+---------------------------+-----------------------------------+ +| ``std::chrono::duration<...>`` | STL time duration | :file:`pybind11/chrono.h` | ++------------------------------------+---------------------------+-----------------------------------+ +| ``std::chrono::time_point<...>`` | STL date/time | :file:`pybind11/chrono.h` | ++------------------------------------+---------------------------+-----------------------------------+ +| ``Eigen::Matrix<...>`` | Eigen: dense matrix | :file:`pybind11/eigen.h` | ++------------------------------------+---------------------------+-----------------------------------+ +| ``Eigen::Map<...>`` | Eigen: mapped memory | :file:`pybind11/eigen.h` | ++------------------------------------+---------------------------+-----------------------------------+ +| ``Eigen::SparseMatrix<...>`` | Eigen: sparse matrix | :file:`pybind11/eigen.h` | ++------------------------------------+---------------------------+-----------------------------------+ + +.. [#] ``std::filesystem::path`` is converted to ``pathlib.Path`` and + ``os.PathLike`` is converted to ``std::filesystem::path``. diff --git a/dmff/dpnblist/external/pybind11-2.11.1/docs/advanced/cast/stl.rst b/dmff/dpnblist/external/pybind11-2.11.1/docs/advanced/cast/stl.rst new file mode 100644 index 00000000..03d49b29 --- /dev/null +++ b/dmff/dpnblist/external/pybind11-2.11.1/docs/advanced/cast/stl.rst @@ -0,0 +1,249 @@ +STL containers +############## + +Automatic conversion +==================== + +When including the additional header file :file:`pybind11/stl.h`, conversions +between ``std::vector<>``/``std::deque<>``/``std::list<>``/``std::array<>``/``std::valarray<>``, +``std::set<>``/``std::unordered_set<>``, and +``std::map<>``/``std::unordered_map<>`` and the Python ``list``, ``set`` and +``dict`` data structures are automatically enabled. The types ``std::pair<>`` +and ``std::tuple<>`` are already supported out of the box with just the core +:file:`pybind11/pybind11.h` header. + +The major downside of these implicit conversions is that containers must be +converted (i.e. copied) on every Python->C++ and C++->Python transition, which +can have implications on the program semantics and performance. Please read the +next sections for more details and alternative approaches that avoid this. + +.. note:: + + Arbitrary nesting of any of these types is possible. + +.. seealso:: + + The file :file:`tests/test_stl.cpp` contains a complete + example that demonstrates how to pass STL data types in more detail. + +.. _cpp17_container_casters: + +C++17 library containers +======================== + +The :file:`pybind11/stl.h` header also includes support for ``std::optional<>`` +and ``std::variant<>``. These require a C++17 compiler and standard library. +In C++14 mode, ``std::experimental::optional<>`` is supported if available. + +Various versions of these containers also exist for C++11 (e.g. in Boost). +pybind11 provides an easy way to specialize the ``type_caster`` for such +types: + +.. code-block:: cpp + + // `boost::optional` as an example -- can be any `std::optional`-like container + namespace PYBIND11_NAMESPACE { namespace detail { + template + struct type_caster> : optional_caster> {}; + }} + +The above should be placed in a header file and included in all translation units +where automatic conversion is needed. Similarly, a specialization can be provided +for custom variant types: + +.. code-block:: cpp + + // `boost::variant` as an example -- can be any `std::variant`-like container + namespace PYBIND11_NAMESPACE { namespace detail { + template + struct type_caster> : variant_caster> {}; + + // Specifies the function used to visit the variant -- `apply_visitor` instead of `visit` + template <> + struct visit_helper { + template + static auto call(Args &&...args) -> decltype(boost::apply_visitor(args...)) { + return boost::apply_visitor(args...); + } + }; + }} // namespace PYBIND11_NAMESPACE::detail + +The ``visit_helper`` specialization is not required if your ``name::variant`` provides +a ``name::visit()`` function. For any other function name, the specialization must be +included to tell pybind11 how to visit the variant. + +.. warning:: + + When converting a ``variant`` type, pybind11 follows the same rules as when + determining which function overload to call (:ref:`overload_resolution`), and + so the same caveats hold. In particular, the order in which the ``variant``'s + alternatives are listed is important, since pybind11 will try conversions in + this order. This means that, for example, when converting ``variant``, + the ``bool`` variant will never be selected, as any Python ``bool`` is already + an ``int`` and is convertible to a C++ ``int``. Changing the order of alternatives + (and using ``variant``, in this example) provides a solution. + +.. note:: + + pybind11 only supports the modern implementation of ``boost::variant`` + which makes use of variadic templates. This requires Boost 1.56 or newer. + +.. _opaque: + +Making opaque types +=================== + +pybind11 heavily relies on a template matching mechanism to convert parameters +and return values that are constructed from STL data types such as vectors, +linked lists, hash tables, etc. This even works in a recursive manner, for +instance to deal with lists of hash maps of pairs of elementary and custom +types, etc. + +However, a fundamental limitation of this approach is that internal conversions +between Python and C++ types involve a copy operation that prevents +pass-by-reference semantics. What does this mean? + +Suppose we bind the following function + +.. code-block:: cpp + + void append_1(std::vector &v) { + v.push_back(1); + } + +and call it from Python, the following happens: + +.. code-block:: pycon + + >>> v = [5, 6] + >>> append_1(v) + >>> print(v) + [5, 6] + +As you can see, when passing STL data structures by reference, modifications +are not propagated back the Python side. A similar situation arises when +exposing STL data structures using the ``def_readwrite`` or ``def_readonly`` +functions: + +.. code-block:: cpp + + /* ... definition ... */ + + class MyClass { + std::vector contents; + }; + + /* ... binding code ... */ + + py::class_(m, "MyClass") + .def(py::init<>()) + .def_readwrite("contents", &MyClass::contents); + +In this case, properties can be read and written in their entirety. However, an +``append`` operation involving such a list type has no effect: + +.. code-block:: pycon + + >>> m = MyClass() + >>> m.contents = [5, 6] + >>> print(m.contents) + [5, 6] + >>> m.contents.append(7) + >>> print(m.contents) + [5, 6] + +Finally, the involved copy operations can be costly when dealing with very +large lists. To deal with all of the above situations, pybind11 provides a +macro named ``PYBIND11_MAKE_OPAQUE(T)`` that disables the template-based +conversion machinery of types, thus rendering them *opaque*. The contents of +opaque objects are never inspected or extracted, hence they *can* be passed by +reference. For instance, to turn ``std::vector`` into an opaque type, add +the declaration + +.. code-block:: cpp + + PYBIND11_MAKE_OPAQUE(std::vector); + +before any binding code (e.g. invocations to ``class_::def()``, etc.). This +macro must be specified at the top level (and outside of any namespaces), since +it adds a template instantiation of ``type_caster``. If your binding code consists of +multiple compilation units, it must be present in every file (typically via a +common header) preceding any usage of ``std::vector``. Opaque types must +also have a corresponding ``class_`` declaration to associate them with a name +in Python, and to define a set of available operations, e.g.: + +.. code-block:: cpp + + py::class_>(m, "IntVector") + .def(py::init<>()) + .def("clear", &std::vector::clear) + .def("pop_back", &std::vector::pop_back) + .def("__len__", [](const std::vector &v) { return v.size(); }) + .def("__iter__", [](std::vector &v) { + return py::make_iterator(v.begin(), v.end()); + }, py::keep_alive<0, 1>()) /* Keep vector alive while iterator is used */ + // .... + +.. seealso:: + + The file :file:`tests/test_opaque_types.cpp` contains a complete + example that demonstrates how to create and expose opaque types using + pybind11 in more detail. + +.. _stl_bind: + +Binding STL containers +====================== + +The ability to expose STL containers as native Python objects is a fairly +common request, hence pybind11 also provides an optional header file named +:file:`pybind11/stl_bind.h` that does exactly this. The mapped containers try +to match the behavior of their native Python counterparts as much as possible. + +The following example showcases usage of :file:`pybind11/stl_bind.h`: + +.. code-block:: cpp + + // Don't forget this + #include + + PYBIND11_MAKE_OPAQUE(std::vector); + PYBIND11_MAKE_OPAQUE(std::map); + + // ... + + // later in binding code: + py::bind_vector>(m, "VectorInt"); + py::bind_map>(m, "MapStringDouble"); + +When binding STL containers pybind11 considers the types of the container's +elements to decide whether the container should be confined to the local module +(via the :ref:`module_local` feature). If the container element types are +anything other than already-bound custom types bound without +``py::module_local()`` the container binding will have ``py::module_local()`` +applied. This includes converting types such as numeric types, strings, Eigen +types; and types that have not yet been bound at the time of the stl container +binding. This module-local binding is designed to avoid potential conflicts +between module bindings (for example, from two separate modules each attempting +to bind ``std::vector`` as a python type). + +It is possible to override this behavior to force a definition to be either +module-local or global. To do so, you can pass the attributes +``py::module_local()`` (to make the binding module-local) or +``py::module_local(false)`` (to make the binding global) into the +``py::bind_vector`` or ``py::bind_map`` arguments: + +.. code-block:: cpp + + py::bind_vector>(m, "VectorInt", py::module_local(false)); + +Note, however, that such a global binding would make it impossible to load this +module at the same time as any other pybind module that also attempts to bind +the same container type (``std::vector`` in the above example). + +See :ref:`module_local` for more details on module-local bindings. + +.. seealso:: + + The file :file:`tests/test_stl_binders.cpp` shows how to use the + convenience STL container wrappers. diff --git a/dmff/dpnblist/external/pybind11-2.11.1/docs/advanced/cast/strings.rst b/dmff/dpnblist/external/pybind11-2.11.1/docs/advanced/cast/strings.rst new file mode 100644 index 00000000..271716b4 --- /dev/null +++ b/dmff/dpnblist/external/pybind11-2.11.1/docs/advanced/cast/strings.rst @@ -0,0 +1,296 @@ +Strings, bytes and Unicode conversions +###################################### + +Passing Python strings to C++ +============================= + +When a Python ``str`` is passed from Python to a C++ function that accepts +``std::string`` or ``char *`` as arguments, pybind11 will encode the Python +string to UTF-8. All Python ``str`` can be encoded in UTF-8, so this operation +does not fail. + +The C++ language is encoding agnostic. It is the responsibility of the +programmer to track encodings. It's often easiest to simply `use UTF-8 +everywhere `_. + +.. code-block:: c++ + + m.def("utf8_test", + [](const std::string &s) { + cout << "utf-8 is icing on the cake.\n"; + cout << s; + } + ); + m.def("utf8_charptr", + [](const char *s) { + cout << "My favorite food is\n"; + cout << s; + } + ); + +.. code-block:: pycon + + >>> utf8_test("🎂") + utf-8 is icing on the cake. + 🎂 + + >>> utf8_charptr("🍕") + My favorite food is + 🍕 + +.. note:: + + Some terminal emulators do not support UTF-8 or emoji fonts and may not + display the example above correctly. + +The results are the same whether the C++ function accepts arguments by value or +reference, and whether or not ``const`` is used. + +Passing bytes to C++ +-------------------- + +A Python ``bytes`` object will be passed to C++ functions that accept +``std::string`` or ``char*`` *without* conversion. In order to make a function +*only* accept ``bytes`` (and not ``str``), declare it as taking a ``py::bytes`` +argument. + + +Returning C++ strings to Python +=============================== + +When a C++ function returns a ``std::string`` or ``char*`` to a Python caller, +**pybind11 will assume that the string is valid UTF-8** and will decode it to a +native Python ``str``, using the same API as Python uses to perform +``bytes.decode('utf-8')``. If this implicit conversion fails, pybind11 will +raise a ``UnicodeDecodeError``. + +.. code-block:: c++ + + m.def("std_string_return", + []() { + return std::string("This string needs to be UTF-8 encoded"); + } + ); + +.. code-block:: pycon + + >>> isinstance(example.std_string_return(), str) + True + + +Because UTF-8 is inclusive of pure ASCII, there is never any issue with +returning a pure ASCII string to Python. If there is any possibility that the +string is not pure ASCII, it is necessary to ensure the encoding is valid +UTF-8. + +.. warning:: + + Implicit conversion assumes that a returned ``char *`` is null-terminated. + If there is no null terminator a buffer overrun will occur. + +Explicit conversions +-------------------- + +If some C++ code constructs a ``std::string`` that is not a UTF-8 string, one +can perform a explicit conversion and return a ``py::str`` object. Explicit +conversion has the same overhead as implicit conversion. + +.. code-block:: c++ + + // This uses the Python C API to convert Latin-1 to Unicode + m.def("str_output", + []() { + std::string s = "Send your r\xe9sum\xe9 to Alice in HR"; // Latin-1 + py::handle py_s = PyUnicode_DecodeLatin1(s.data(), s.length(), nullptr); + if (!py_s) { + throw py::error_already_set(); + } + return py::reinterpret_steal(py_s); + } + ); + +.. code-block:: pycon + + >>> str_output() + 'Send your résumé to Alice in HR' + +The `Python C API +`_ provides +several built-in codecs. Note that these all return *new* references, so +use :cpp:func:`reinterpret_steal` when converting them to a :cpp:class:`str`. + + +One could also use a third party encoding library such as libiconv to transcode +to UTF-8. + +Return C++ strings without conversion +------------------------------------- + +If the data in a C++ ``std::string`` does not represent text and should be +returned to Python as ``bytes``, then one can return the data as a +``py::bytes`` object. + +.. code-block:: c++ + + m.def("return_bytes", + []() { + std::string s("\xba\xd0\xba\xd0"); // Not valid UTF-8 + return py::bytes(s); // Return the data without transcoding + } + ); + +.. code-block:: pycon + + >>> example.return_bytes() + b'\xba\xd0\xba\xd0' + + +Note the asymmetry: pybind11 will convert ``bytes`` to ``std::string`` without +encoding, but cannot convert ``std::string`` back to ``bytes`` implicitly. + +.. code-block:: c++ + + m.def("asymmetry", + [](std::string s) { // Accepts str or bytes from Python + return s; // Looks harmless, but implicitly converts to str + } + ); + +.. code-block:: pycon + + >>> isinstance(example.asymmetry(b"have some bytes"), str) + True + + >>> example.asymmetry(b"\xba\xd0\xba\xd0") # invalid utf-8 as bytes + UnicodeDecodeError: 'utf-8' codec can't decode byte 0xba in position 0: invalid start byte + + +Wide character strings +====================== + +When a Python ``str`` is passed to a C++ function expecting ``std::wstring``, +``wchar_t*``, ``std::u16string`` or ``std::u32string``, the ``str`` will be +encoded to UTF-16 or UTF-32 depending on how the C++ compiler implements each +type, in the platform's native endianness. When strings of these types are +returned, they are assumed to contain valid UTF-16 or UTF-32, and will be +decoded to Python ``str``. + +.. code-block:: c++ + + #define UNICODE + #include + + m.def("set_window_text", + [](HWND hwnd, std::wstring s) { + // Call SetWindowText with null-terminated UTF-16 string + ::SetWindowText(hwnd, s.c_str()); + } + ); + m.def("get_window_text", + [](HWND hwnd) { + const int buffer_size = ::GetWindowTextLength(hwnd) + 1; + auto buffer = std::make_unique< wchar_t[] >(buffer_size); + + ::GetWindowText(hwnd, buffer.data(), buffer_size); + + std::wstring text(buffer.get()); + + // wstring will be converted to Python str + return text; + } + ); + +Strings in multibyte encodings such as Shift-JIS must transcoded to a +UTF-8/16/32 before being returned to Python. + + +Character literals +================== + +C++ functions that accept character literals as input will receive the first +character of a Python ``str`` as their input. If the string is longer than one +Unicode character, trailing characters will be ignored. + +When a character literal is returned from C++ (such as a ``char`` or a +``wchar_t``), it will be converted to a ``str`` that represents the single +character. + +.. code-block:: c++ + + m.def("pass_char", [](char c) { return c; }); + m.def("pass_wchar", [](wchar_t w) { return w; }); + +.. code-block:: pycon + + >>> example.pass_char("A") + 'A' + +While C++ will cast integers to character types (``char c = 0x65;``), pybind11 +does not convert Python integers to characters implicitly. The Python function +``chr()`` can be used to convert integers to characters. + +.. code-block:: pycon + + >>> example.pass_char(0x65) + TypeError + + >>> example.pass_char(chr(0x65)) + 'A' + +If the desire is to work with an 8-bit integer, use ``int8_t`` or ``uint8_t`` +as the argument type. + +Grapheme clusters +----------------- + +A single grapheme may be represented by two or more Unicode characters. For +example 'é' is usually represented as U+00E9 but can also be expressed as the +combining character sequence U+0065 U+0301 (that is, the letter 'e' followed by +a combining acute accent). The combining character will be lost if the +two-character sequence is passed as an argument, even though it renders as a +single grapheme. + +.. code-block:: pycon + + >>> example.pass_wchar("é") + 'é' + + >>> combining_e_acute = "e" + "\u0301" + + >>> combining_e_acute + 'é' + + >>> combining_e_acute == "é" + False + + >>> example.pass_wchar(combining_e_acute) + 'e' + +Normalizing combining characters before passing the character literal to C++ +may resolve *some* of these issues: + +.. code-block:: pycon + + >>> example.pass_wchar(unicodedata.normalize("NFC", combining_e_acute)) + 'é' + +In some languages (Thai for example), there are `graphemes that cannot be +expressed as a single Unicode code point +`_, so there is +no way to capture them in a C++ character type. + + +C++17 string views +================== + +C++17 string views are automatically supported when compiling in C++17 mode. +They follow the same rules for encoding and decoding as the corresponding STL +string type (for example, a ``std::u16string_view`` argument will be passed +UTF-16-encoded data, and a returned ``std::string_view`` will be decoded as +UTF-8). + +References +========== + +* `The Absolute Minimum Every Software Developer Absolutely, Positively Must Know About Unicode and Character Sets (No Excuses!) `_ +* `C++ - Using STL Strings at Win32 API Boundaries `_ diff --git a/dmff/dpnblist/external/pybind11-2.11.1/docs/advanced/classes.rst b/dmff/dpnblist/external/pybind11-2.11.1/docs/advanced/classes.rst new file mode 100644 index 00000000..01a490b7 --- /dev/null +++ b/dmff/dpnblist/external/pybind11-2.11.1/docs/advanced/classes.rst @@ -0,0 +1,1335 @@ +Classes +####### + +This section presents advanced binding code for classes and it is assumed +that you are already familiar with the basics from :doc:`/classes`. + +.. _overriding_virtuals: + +Overriding virtual functions in Python +====================================== + +Suppose that a C++ class or interface has a virtual function that we'd like +to override from within Python (we'll focus on the class ``Animal``; ``Dog`` is +given as a specific example of how one would do this with traditional C++ +code). + +.. code-block:: cpp + + class Animal { + public: + virtual ~Animal() { } + virtual std::string go(int n_times) = 0; + }; + + class Dog : public Animal { + public: + std::string go(int n_times) override { + std::string result; + for (int i=0; igo(3); + } + +Normally, the binding code for these classes would look as follows: + +.. code-block:: cpp + + PYBIND11_MODULE(example, m) { + py::class_(m, "Animal") + .def("go", &Animal::go); + + py::class_(m, "Dog") + .def(py::init<>()); + + m.def("call_go", &call_go); + } + +However, these bindings are impossible to extend: ``Animal`` is not +constructible, and we clearly require some kind of "trampoline" that +redirects virtual calls back to Python. + +Defining a new type of ``Animal`` from within Python is possible but requires a +helper class that is defined as follows: + +.. code-block:: cpp + + class PyAnimal : public Animal { + public: + /* Inherit the constructors */ + using Animal::Animal; + + /* Trampoline (need one for each virtual function) */ + std::string go(int n_times) override { + PYBIND11_OVERRIDE_PURE( + std::string, /* Return type */ + Animal, /* Parent class */ + go, /* Name of function in C++ (must match Python name) */ + n_times /* Argument(s) */ + ); + } + }; + +The macro :c:macro:`PYBIND11_OVERRIDE_PURE` should be used for pure virtual +functions, and :c:macro:`PYBIND11_OVERRIDE` should be used for functions which have +a default implementation. There are also two alternate macros +:c:macro:`PYBIND11_OVERRIDE_PURE_NAME` and :c:macro:`PYBIND11_OVERRIDE_NAME` which +take a string-valued name argument between the *Parent class* and *Name of the +function* slots, which defines the name of function in Python. This is required +when the C++ and Python versions of the +function have different names, e.g. ``operator()`` vs ``__call__``. + +The binding code also needs a few minor adaptations (highlighted): + +.. code-block:: cpp + :emphasize-lines: 2,3 + + PYBIND11_MODULE(example, m) { + py::class_(m, "Animal") + .def(py::init<>()) + .def("go", &Animal::go); + + py::class_(m, "Dog") + .def(py::init<>()); + + m.def("call_go", &call_go); + } + +Importantly, pybind11 is made aware of the trampoline helper class by +specifying it as an extra template argument to :class:`class_`. (This can also +be combined with other template arguments such as a custom holder type; the +order of template types does not matter). Following this, we are able to +define a constructor as usual. + +Bindings should be made against the actual class, not the trampoline helper class. + +.. code-block:: cpp + :emphasize-lines: 3 + + py::class_(m, "Animal"); + .def(py::init<>()) + .def("go", &PyAnimal::go); /* <--- THIS IS WRONG, use &Animal::go */ + +Note, however, that the above is sufficient for allowing python classes to +extend ``Animal``, but not ``Dog``: see :ref:`virtual_and_inheritance` for the +necessary steps required to providing proper overriding support for inherited +classes. + +The Python session below shows how to override ``Animal::go`` and invoke it via +a virtual method call. + +.. code-block:: pycon + + >>> from example import * + >>> d = Dog() + >>> call_go(d) + 'woof! woof! woof! ' + >>> class Cat(Animal): + ... def go(self, n_times): + ... return "meow! " * n_times + ... + >>> c = Cat() + >>> call_go(c) + 'meow! meow! meow! ' + +If you are defining a custom constructor in a derived Python class, you *must* +ensure that you explicitly call the bound C++ constructor using ``__init__``, +*regardless* of whether it is a default constructor or not. Otherwise, the +memory for the C++ portion of the instance will be left uninitialized, which +will generally leave the C++ instance in an invalid state and cause undefined +behavior if the C++ instance is subsequently used. + +.. versionchanged:: 2.6 + The default pybind11 metaclass will throw a ``TypeError`` when it detects + that ``__init__`` was not called by a derived class. + +Here is an example: + +.. code-block:: python + + class Dachshund(Dog): + def __init__(self, name): + Dog.__init__(self) # Without this, a TypeError is raised. + self.name = name + + def bark(self): + return "yap!" + +Note that a direct ``__init__`` constructor *should be called*, and ``super()`` +should not be used. For simple cases of linear inheritance, ``super()`` +may work, but once you begin mixing Python and C++ multiple inheritance, +things will fall apart due to differences between Python's MRO and C++'s +mechanisms. + +Please take a look at the :ref:`macro_notes` before using this feature. + +.. note:: + + When the overridden type returns a reference or pointer to a type that + pybind11 converts from Python (for example, numeric values, std::string, + and other built-in value-converting types), there are some limitations to + be aware of: + + - because in these cases there is no C++ variable to reference (the value + is stored in the referenced Python variable), pybind11 provides one in + the PYBIND11_OVERRIDE macros (when needed) with static storage duration. + Note that this means that invoking the overridden method on *any* + instance will change the referenced value stored in *all* instances of + that type. + + - Attempts to modify a non-const reference will not have the desired + effect: it will change only the static cache variable, but this change + will not propagate to underlying Python instance, and the change will be + replaced the next time the override is invoked. + +.. warning:: + + The :c:macro:`PYBIND11_OVERRIDE` and accompanying macros used to be called + ``PYBIND11_OVERLOAD`` up until pybind11 v2.5.0, and :func:`get_override` + used to be called ``get_overload``. This naming was corrected and the older + macro and function names may soon be deprecated, in order to reduce + confusion with overloaded functions and methods and ``py::overload_cast`` + (see :ref:`classes`). + +.. seealso:: + + The file :file:`tests/test_virtual_functions.cpp` contains a complete + example that demonstrates how to override virtual functions using pybind11 + in more detail. + +.. _virtual_and_inheritance: + +Combining virtual functions and inheritance +=========================================== + +When combining virtual methods with inheritance, you need to be sure to provide +an override for each method for which you want to allow overrides from derived +python classes. For example, suppose we extend the above ``Animal``/``Dog`` +example as follows: + +.. code-block:: cpp + + class Animal { + public: + virtual std::string go(int n_times) = 0; + virtual std::string name() { return "unknown"; } + }; + class Dog : public Animal { + public: + std::string go(int n_times) override { + std::string result; + for (int i=0; i class PyAnimal : public AnimalBase { + public: + using AnimalBase::AnimalBase; // Inherit constructors + std::string go(int n_times) override { PYBIND11_OVERRIDE_PURE(std::string, AnimalBase, go, n_times); } + std::string name() override { PYBIND11_OVERRIDE(std::string, AnimalBase, name, ); } + }; + template class PyDog : public PyAnimal { + public: + using PyAnimal::PyAnimal; // Inherit constructors + // Override PyAnimal's pure virtual go() with a non-pure one: + std::string go(int n_times) override { PYBIND11_OVERRIDE(std::string, DogBase, go, n_times); } + std::string bark() override { PYBIND11_OVERRIDE(std::string, DogBase, bark, ); } + }; + +This technique has the advantage of requiring just one trampoline method to be +declared per virtual method and pure virtual method override. It does, +however, require the compiler to generate at least as many methods (and +possibly more, if both pure virtual and overridden pure virtual methods are +exposed, as above). + +The classes are then registered with pybind11 using: + +.. code-block:: cpp + + py::class_> animal(m, "Animal"); + py::class_> dog(m, "Dog"); + py::class_> husky(m, "Husky"); + // ... add animal, dog, husky definitions + +Note that ``Husky`` did not require a dedicated trampoline template class at +all, since it neither declares any new virtual methods nor provides any pure +virtual method implementations. + +With either the repeated-virtuals or templated trampoline methods in place, you +can now create a python class that inherits from ``Dog``: + +.. code-block:: python + + class ShihTzu(Dog): + def bark(self): + return "yip!" + +.. seealso:: + + See the file :file:`tests/test_virtual_functions.cpp` for complete examples + using both the duplication and templated trampoline approaches. + +.. _extended_aliases: + +Extended trampoline class functionality +======================================= + +.. _extended_class_functionality_forced_trampoline: + +Forced trampoline class initialisation +-------------------------------------- +The trampoline classes described in the previous sections are, by default, only +initialized when needed. More specifically, they are initialized when a python +class actually inherits from a registered type (instead of merely creating an +instance of the registered type), or when a registered constructor is only +valid for the trampoline class but not the registered class. This is primarily +for performance reasons: when the trampoline class is not needed for anything +except virtual method dispatching, not initializing the trampoline class +improves performance by avoiding needing to do a run-time check to see if the +inheriting python instance has an overridden method. + +Sometimes, however, it is useful to always initialize a trampoline class as an +intermediate class that does more than just handle virtual method dispatching. +For example, such a class might perform extra class initialization, extra +destruction operations, and might define new members and methods to enable a +more python-like interface to a class. + +In order to tell pybind11 that it should *always* initialize the trampoline +class when creating new instances of a type, the class constructors should be +declared using ``py::init_alias()`` instead of the usual +``py::init()``. This forces construction via the trampoline class, +ensuring member initialization and (eventual) destruction. + +.. seealso:: + + See the file :file:`tests/test_virtual_functions.cpp` for complete examples + showing both normal and forced trampoline instantiation. + +Different method signatures +--------------------------- +The macro's introduced in :ref:`overriding_virtuals` cover most of the standard +use cases when exposing C++ classes to Python. Sometimes it is hard or unwieldy +to create a direct one-on-one mapping between the arguments and method return +type. + +An example would be when the C++ signature contains output arguments using +references (See also :ref:`faq_reference_arguments`). Another way of solving +this is to use the method body of the trampoline class to do conversions to the +input and return of the Python method. + +The main building block to do so is the :func:`get_override`, this function +allows retrieving a method implemented in Python from within the trampoline's +methods. Consider for example a C++ method which has the signature +``bool myMethod(int32_t& value)``, where the return indicates whether +something should be done with the ``value``. This can be made convenient on the +Python side by allowing the Python function to return ``None`` or an ``int``: + +.. code-block:: cpp + + bool MyClass::myMethod(int32_t& value) + { + pybind11::gil_scoped_acquire gil; // Acquire the GIL while in this scope. + // Try to look up the overridden method on the Python side. + pybind11::function override = pybind11::get_override(this, "myMethod"); + if (override) { // method is found + auto obj = override(value); // Call the Python function. + if (py::isinstance(obj)) { // check if it returned a Python integer type + value = obj.cast(); // Cast it and assign it to the value. + return true; // Return true; value should be used. + } else { + return false; // Python returned none, return false. + } + } + return false; // Alternatively return MyClass::myMethod(value); + } + + +.. _custom_constructors: + +Custom constructors +=================== + +The syntax for binding constructors was previously introduced, but it only +works when a constructor of the appropriate arguments actually exists on the +C++ side. To extend this to more general cases, pybind11 makes it possible +to bind factory functions as constructors. For example, suppose you have a +class like this: + +.. code-block:: cpp + + class Example { + private: + Example(int); // private constructor + public: + // Factory function: + static Example create(int a) { return Example(a); } + }; + + py::class_(m, "Example") + .def(py::init(&Example::create)); + +While it is possible to create a straightforward binding of the static +``create`` method, it may sometimes be preferable to expose it as a constructor +on the Python side. This can be accomplished by calling ``.def(py::init(...))`` +with the function reference returning the new instance passed as an argument. +It is also possible to use this approach to bind a function returning a new +instance by raw pointer or by the holder (e.g. ``std::unique_ptr``). + +The following example shows the different approaches: + +.. code-block:: cpp + + class Example { + private: + Example(int); // private constructor + public: + // Factory function - returned by value: + static Example create(int a) { return Example(a); } + + // These constructors are publicly callable: + Example(double); + Example(int, int); + Example(std::string); + }; + + py::class_(m, "Example") + // Bind the factory function as a constructor: + .def(py::init(&Example::create)) + // Bind a lambda function returning a pointer wrapped in a holder: + .def(py::init([](std::string arg) { + return std::unique_ptr(new Example(arg)); + })) + // Return a raw pointer: + .def(py::init([](int a, int b) { return new Example(a, b); })) + // You can mix the above with regular C++ constructor bindings as well: + .def(py::init()) + ; + +When the constructor is invoked from Python, pybind11 will call the factory +function and store the resulting C++ instance in the Python instance. + +When combining factory functions constructors with :ref:`virtual function +trampolines ` there are two approaches. The first is to +add a constructor to the alias class that takes a base value by +rvalue-reference. If such a constructor is available, it will be used to +construct an alias instance from the value returned by the factory function. +The second option is to provide two factory functions to ``py::init()``: the +first will be invoked when no alias class is required (i.e. when the class is +being used but not inherited from in Python), and the second will be invoked +when an alias is required. + +You can also specify a single factory function that always returns an alias +instance: this will result in behaviour similar to ``py::init_alias<...>()``, +as described in the :ref:`extended trampoline class documentation +`. + +The following example shows the different factory approaches for a class with +an alias: + +.. code-block:: cpp + + #include + class Example { + public: + // ... + virtual ~Example() = default; + }; + class PyExample : public Example { + public: + using Example::Example; + PyExample(Example &&base) : Example(std::move(base)) {} + }; + py::class_(m, "Example") + // Returns an Example pointer. If a PyExample is needed, the Example + // instance will be moved via the extra constructor in PyExample, above. + .def(py::init([]() { return new Example(); })) + // Two callbacks: + .def(py::init([]() { return new Example(); } /* no alias needed */, + []() { return new PyExample(); } /* alias needed */)) + // *Always* returns an alias instance (like py::init_alias<>()) + .def(py::init([]() { return new PyExample(); })) + ; + +Brace initialization +-------------------- + +``pybind11::init<>`` internally uses C++11 brace initialization to call the +constructor of the target class. This means that it can be used to bind +*implicit* constructors as well: + +.. code-block:: cpp + + struct Aggregate { + int a; + std::string b; + }; + + py::class_(m, "Aggregate") + .def(py::init()); + +.. note:: + + Note that brace initialization preferentially invokes constructor overloads + taking a ``std::initializer_list``. In the rare event that this causes an + issue, you can work around it by using ``py::init(...)`` with a lambda + function that constructs the new object as desired. + +.. _classes_with_non_public_destructors: + +Non-public destructors +====================== + +If a class has a private or protected destructor (as might e.g. be the case in +a singleton pattern), a compile error will occur when creating bindings via +pybind11. The underlying issue is that the ``std::unique_ptr`` holder type that +is responsible for managing the lifetime of instances will reference the +destructor even if no deallocations ever take place. In order to expose classes +with private or protected destructors, it is possible to override the holder +type via a holder type argument to ``class_``. Pybind11 provides a helper class +``py::nodelete`` that disables any destructor invocations. In this case, it is +crucial that instances are deallocated on the C++ side to avoid memory leaks. + +.. code-block:: cpp + + /* ... definition ... */ + + class MyClass { + private: + ~MyClass() { } + }; + + /* ... binding code ... */ + + py::class_>(m, "MyClass") + .def(py::init<>()) + +.. _destructors_that_call_python: + +Destructors that call Python +============================ + +If a Python function is invoked from a C++ destructor, an exception may be thrown +of type :class:`error_already_set`. If this error is thrown out of a class destructor, +``std::terminate()`` will be called, terminating the process. Class destructors +must catch all exceptions of type :class:`error_already_set` to discard the Python +exception using :func:`error_already_set::discard_as_unraisable`. + +Every Python function should be treated as *possibly throwing*. When a Python generator +stops yielding items, Python will throw a ``StopIteration`` exception, which can pass +though C++ destructors if the generator's stack frame holds the last reference to C++ +objects. + +For more information, see :ref:`the documentation on exceptions `. + +.. code-block:: cpp + + class MyClass { + public: + ~MyClass() { + try { + py::print("Even printing is dangerous in a destructor"); + py::exec("raise ValueError('This is an unraisable exception')"); + } catch (py::error_already_set &e) { + // error_context should be information about where/why the occurred, + // e.g. use __func__ to get the name of the current function + e.discard_as_unraisable(__func__); + } + } + }; + +.. note:: + + pybind11 does not support C++ destructors marked ``noexcept(false)``. + +.. versionadded:: 2.6 + +.. _implicit_conversions: + +Implicit conversions +==================== + +Suppose that instances of two types ``A`` and ``B`` are used in a project, and +that an ``A`` can easily be converted into an instance of type ``B`` (examples of this +could be a fixed and an arbitrary precision number type). + +.. code-block:: cpp + + py::class_(m, "A") + /// ... members ... + + py::class_(m, "B") + .def(py::init()) + /// ... members ... + + m.def("func", + [](const B &) { /* .... */ } + ); + +To invoke the function ``func`` using a variable ``a`` containing an ``A`` +instance, we'd have to write ``func(B(a))`` in Python. On the other hand, C++ +will automatically apply an implicit type conversion, which makes it possible +to directly write ``func(a)``. + +In this situation (i.e. where ``B`` has a constructor that converts from +``A``), the following statement enables similar implicit conversions on the +Python side: + +.. code-block:: cpp + + py::implicitly_convertible(); + +.. note:: + + Implicit conversions from ``A`` to ``B`` only work when ``B`` is a custom + data type that is exposed to Python via pybind11. + + To prevent runaway recursion, implicit conversions are non-reentrant: an + implicit conversion invoked as part of another implicit conversion of the + same type (i.e. from ``A`` to ``B``) will fail. + +.. _static_properties: + +Static properties +================= + +The section on :ref:`properties` discussed the creation of instance properties +that are implemented in terms of C++ getters and setters. + +Static properties can also be created in a similar way to expose getters and +setters of static class attributes. Note that the implicit ``self`` argument +also exists in this case and is used to pass the Python ``type`` subclass +instance. This parameter will often not be needed by the C++ side, and the +following example illustrates how to instantiate a lambda getter function +that ignores it: + +.. code-block:: cpp + + py::class_(m, "Foo") + .def_property_readonly_static("foo", [](py::object /* self */) { return Foo(); }); + +Operator overloading +==================== + +Suppose that we're given the following ``Vector2`` class with a vector addition +and scalar multiplication operation, all implemented using overloaded operators +in C++. + +.. code-block:: cpp + + class Vector2 { + public: + Vector2(float x, float y) : x(x), y(y) { } + + Vector2 operator+(const Vector2 &v) const { return Vector2(x + v.x, y + v.y); } + Vector2 operator*(float value) const { return Vector2(x * value, y * value); } + Vector2& operator+=(const Vector2 &v) { x += v.x; y += v.y; return *this; } + Vector2& operator*=(float v) { x *= v; y *= v; return *this; } + + friend Vector2 operator*(float f, const Vector2 &v) { + return Vector2(f * v.x, f * v.y); + } + + std::string toString() const { + return "[" + std::to_string(x) + ", " + std::to_string(y) + "]"; + } + private: + float x, y; + }; + +The following snippet shows how the above operators can be conveniently exposed +to Python. + +.. code-block:: cpp + + #include + + PYBIND11_MODULE(example, m) { + py::class_(m, "Vector2") + .def(py::init()) + .def(py::self + py::self) + .def(py::self += py::self) + .def(py::self *= float()) + .def(float() * py::self) + .def(py::self * float()) + .def(-py::self) + .def("__repr__", &Vector2::toString); + } + +Note that a line like + +.. code-block:: cpp + + .def(py::self * float()) + +is really just short hand notation for + +.. code-block:: cpp + + .def("__mul__", [](const Vector2 &a, float b) { + return a * b; + }, py::is_operator()) + +This can be useful for exposing additional operators that don't exist on the +C++ side, or to perform other types of customization. The ``py::is_operator`` +flag marker is needed to inform pybind11 that this is an operator, which +returns ``NotImplemented`` when invoked with incompatible arguments rather than +throwing a type error. + +.. note:: + + To use the more convenient ``py::self`` notation, the additional + header file :file:`pybind11/operators.h` must be included. + +.. seealso:: + + The file :file:`tests/test_operator_overloading.cpp` contains a + complete example that demonstrates how to work with overloaded operators in + more detail. + +.. _pickling: + +Pickling support +================ + +Python's ``pickle`` module provides a powerful facility to serialize and +de-serialize a Python object graph into a binary data stream. To pickle and +unpickle C++ classes using pybind11, a ``py::pickle()`` definition must be +provided. Suppose the class in question has the following signature: + +.. code-block:: cpp + + class Pickleable { + public: + Pickleable(const std::string &value) : m_value(value) { } + const std::string &value() const { return m_value; } + + void setExtra(int extra) { m_extra = extra; } + int extra() const { return m_extra; } + private: + std::string m_value; + int m_extra = 0; + }; + +Pickling support in Python is enabled by defining the ``__setstate__`` and +``__getstate__`` methods [#f3]_. For pybind11 classes, use ``py::pickle()`` +to bind these two functions: + +.. code-block:: cpp + + py::class_(m, "Pickleable") + .def(py::init()) + .def("value", &Pickleable::value) + .def("extra", &Pickleable::extra) + .def("setExtra", &Pickleable::setExtra) + .def(py::pickle( + [](const Pickleable &p) { // __getstate__ + /* Return a tuple that fully encodes the state of the object */ + return py::make_tuple(p.value(), p.extra()); + }, + [](py::tuple t) { // __setstate__ + if (t.size() != 2) + throw std::runtime_error("Invalid state!"); + + /* Create a new C++ instance */ + Pickleable p(t[0].cast()); + + /* Assign any additional state */ + p.setExtra(t[1].cast()); + + return p; + } + )); + +The ``__setstate__`` part of the ``py::pickle()`` definition follows the same +rules as the single-argument version of ``py::init()``. The return type can be +a value, pointer or holder type. See :ref:`custom_constructors` for details. + +An instance can now be pickled as follows: + +.. code-block:: python + + import pickle + + p = Pickleable("test_value") + p.setExtra(15) + data = pickle.dumps(p) + + +.. note:: + If given, the second argument to ``dumps`` must be 2 or larger - 0 and 1 are + not supported. Newer versions are also fine; for instance, specify ``-1`` to + always use the latest available version. Beware: failure to follow these + instructions will cause important pybind11 memory allocation routines to be + skipped during unpickling, which will likely lead to memory corruption + and/or segmentation faults. Python defaults to version 3 (Python 3-3.7) and + version 4 for Python 3.8+. + +.. seealso:: + + The file :file:`tests/test_pickling.cpp` contains a complete example + that demonstrates how to pickle and unpickle types using pybind11 in more + detail. + +.. [#f3] http://docs.python.org/3/library/pickle.html#pickling-class-instances + +Deepcopy support +================ + +Python normally uses references in assignments. Sometimes a real copy is needed +to prevent changing all copies. The ``copy`` module [#f5]_ provides these +capabilities. + +A class with pickle support is automatically also (deep)copy +compatible. However, performance can be improved by adding custom +``__copy__`` and ``__deepcopy__`` methods. + +For simple classes (deep)copy can be enabled by using the copy constructor, +which should look as follows: + +.. code-block:: cpp + + py::class_(m, "Copyable") + .def("__copy__", [](const Copyable &self) { + return Copyable(self); + }) + .def("__deepcopy__", [](const Copyable &self, py::dict) { + return Copyable(self); + }, "memo"_a); + +.. note:: + + Dynamic attributes will not be copied in this example. + +.. [#f5] https://docs.python.org/3/library/copy.html + +Multiple Inheritance +==================== + +pybind11 can create bindings for types that derive from multiple base types +(aka. *multiple inheritance*). To do so, specify all bases in the template +arguments of the ``class_`` declaration: + +.. code-block:: cpp + + py::class_(m, "MyType") + ... + +The base types can be specified in arbitrary order, and they can even be +interspersed with alias types and holder types (discussed earlier in this +document)---pybind11 will automatically find out which is which. The only +requirement is that the first template argument is the type to be declared. + +It is also permitted to inherit multiply from exported C++ classes in Python, +as well as inheriting from multiple Python and/or pybind11-exported classes. + +There is one caveat regarding the implementation of this feature: + +When only one base type is specified for a C++ type that actually has multiple +bases, pybind11 will assume that it does not participate in multiple +inheritance, which can lead to undefined behavior. In such cases, add the tag +``multiple_inheritance`` to the class constructor: + +.. code-block:: cpp + + py::class_(m, "MyType", py::multiple_inheritance()); + +The tag is redundant and does not need to be specified when multiple base types +are listed. + +.. _module_local: + +Module-local class bindings +=========================== + +When creating a binding for a class, pybind11 by default makes that binding +"global" across modules. What this means is that a type defined in one module +can be returned from any module resulting in the same Python type. For +example, this allows the following: + +.. code-block:: cpp + + // In the module1.cpp binding code for module1: + py::class_(m, "Pet") + .def(py::init()) + .def_readonly("name", &Pet::name); + +.. code-block:: cpp + + // In the module2.cpp binding code for module2: + m.def("create_pet", [](std::string name) { return new Pet(name); }); + +.. code-block:: pycon + + >>> from module1 import Pet + >>> from module2 import create_pet + >>> pet1 = Pet("Kitty") + >>> pet2 = create_pet("Doggy") + >>> pet2.name() + 'Doggy' + +When writing binding code for a library, this is usually desirable: this +allows, for example, splitting up a complex library into multiple Python +modules. + +In some cases, however, this can cause conflicts. For example, suppose two +unrelated modules make use of an external C++ library and each provide custom +bindings for one of that library's classes. This will result in an error when +a Python program attempts to import both modules (directly or indirectly) +because of conflicting definitions on the external type: + +.. code-block:: cpp + + // dogs.cpp + + // Binding for external library class: + py::class(m, "Pet") + .def("name", &pets::Pet::name); + + // Binding for local extension class: + py::class(m, "Dog") + .def(py::init()); + +.. code-block:: cpp + + // cats.cpp, in a completely separate project from the above dogs.cpp. + + // Binding for external library class: + py::class(m, "Pet") + .def("get_name", &pets::Pet::name); + + // Binding for local extending class: + py::class(m, "Cat") + .def(py::init()); + +.. code-block:: pycon + + >>> import cats + >>> import dogs + Traceback (most recent call last): + File "", line 1, in + ImportError: generic_type: type "Pet" is already registered! + +To get around this, you can tell pybind11 to keep the external class binding +localized to the module by passing the ``py::module_local()`` attribute into +the ``py::class_`` constructor: + +.. code-block:: cpp + + // Pet binding in dogs.cpp: + py::class(m, "Pet", py::module_local()) + .def("name", &pets::Pet::name); + +.. code-block:: cpp + + // Pet binding in cats.cpp: + py::class(m, "Pet", py::module_local()) + .def("get_name", &pets::Pet::name); + +This makes the Python-side ``dogs.Pet`` and ``cats.Pet`` into distinct classes, +avoiding the conflict and allowing both modules to be loaded. C++ code in the +``dogs`` module that casts or returns a ``Pet`` instance will result in a +``dogs.Pet`` Python instance, while C++ code in the ``cats`` module will result +in a ``cats.Pet`` Python instance. + +This does come with two caveats, however: First, external modules cannot return +or cast a ``Pet`` instance to Python (unless they also provide their own local +bindings). Second, from the Python point of view they are two distinct classes. + +Note that the locality only applies in the C++ -> Python direction. When +passing such a ``py::module_local`` type into a C++ function, the module-local +classes are still considered. This means that if the following function is +added to any module (including but not limited to the ``cats`` and ``dogs`` +modules above) it will be callable with either a ``dogs.Pet`` or ``cats.Pet`` +argument: + +.. code-block:: cpp + + m.def("pet_name", [](const pets::Pet &pet) { return pet.name(); }); + +For example, suppose the above function is added to each of ``cats.cpp``, +``dogs.cpp`` and ``frogs.cpp`` (where ``frogs.cpp`` is some other module that +does *not* bind ``Pets`` at all). + +.. code-block:: pycon + + >>> import cats, dogs, frogs # No error because of the added py::module_local() + >>> mycat, mydog = cats.Cat("Fluffy"), dogs.Dog("Rover") + >>> (cats.pet_name(mycat), dogs.pet_name(mydog)) + ('Fluffy', 'Rover') + >>> (cats.pet_name(mydog), dogs.pet_name(mycat), frogs.pet_name(mycat)) + ('Rover', 'Fluffy', 'Fluffy') + +It is possible to use ``py::module_local()`` registrations in one module even +if another module registers the same type globally: within the module with the +module-local definition, all C++ instances will be cast to the associated bound +Python type. In other modules any such values are converted to the global +Python type created elsewhere. + +.. note:: + + STL bindings (as provided via the optional :file:`pybind11/stl_bind.h` + header) apply ``py::module_local`` by default when the bound type might + conflict with other modules; see :ref:`stl_bind` for details. + +.. note:: + + The localization of the bound types is actually tied to the shared object + or binary generated by the compiler/linker. For typical modules created + with ``PYBIND11_MODULE()``, this distinction is not significant. It is + possible, however, when :ref:`embedding` to embed multiple modules in the + same binary (see :ref:`embedding_modules`). In such a case, the + localization will apply across all embedded modules within the same binary. + +.. seealso:: + + The file :file:`tests/test_local_bindings.cpp` contains additional examples + that demonstrate how ``py::module_local()`` works. + +Binding protected member functions +================================== + +It's normally not possible to expose ``protected`` member functions to Python: + +.. code-block:: cpp + + class A { + protected: + int foo() const { return 42; } + }; + + py::class_(m, "A") + .def("foo", &A::foo); // error: 'foo' is a protected member of 'A' + +On one hand, this is good because non-``public`` members aren't meant to be +accessed from the outside. But we may want to make use of ``protected`` +functions in derived Python classes. + +The following pattern makes this possible: + +.. code-block:: cpp + + class A { + protected: + int foo() const { return 42; } + }; + + class Publicist : public A { // helper type for exposing protected functions + public: + using A::foo; // inherited with different access modifier + }; + + py::class_(m, "A") // bind the primary class + .def("foo", &Publicist::foo); // expose protected methods via the publicist + +This works because ``&Publicist::foo`` is exactly the same function as +``&A::foo`` (same signature and address), just with a different access +modifier. The only purpose of the ``Publicist`` helper class is to make +the function name ``public``. + +If the intent is to expose ``protected`` ``virtual`` functions which can be +overridden in Python, the publicist pattern can be combined with the previously +described trampoline: + +.. code-block:: cpp + + class A { + public: + virtual ~A() = default; + + protected: + virtual int foo() const { return 42; } + }; + + class Trampoline : public A { + public: + int foo() const override { PYBIND11_OVERRIDE(int, A, foo, ); } + }; + + class Publicist : public A { + public: + using A::foo; + }; + + py::class_(m, "A") // <-- `Trampoline` here + .def("foo", &Publicist::foo); // <-- `Publicist` here, not `Trampoline`! + +Binding final classes +===================== + +Some classes may not be appropriate to inherit from. In C++11, classes can +use the ``final`` specifier to ensure that a class cannot be inherited from. +The ``py::is_final`` attribute can be used to ensure that Python classes +cannot inherit from a specified type. The underlying C++ type does not need +to be declared final. + +.. code-block:: cpp + + class IsFinal final {}; + + py::class_(m, "IsFinal", py::is_final()); + +When you try to inherit from such a class in Python, you will now get this +error: + +.. code-block:: pycon + + >>> class PyFinalChild(IsFinal): + ... pass + ... + TypeError: type 'IsFinal' is not an acceptable base type + +.. note:: This attribute is currently ignored on PyPy + +.. versionadded:: 2.6 + +Binding classes with template parameters +======================================== + +pybind11 can also wrap classes that have template parameters. Consider these classes: + +.. code-block:: cpp + + struct Cat {}; + struct Dog {}; + + template + struct Cage { + Cage(PetType& pet); + PetType& get(); + }; + +C++ templates may only be instantiated at compile time, so pybind11 can only +wrap instantiated templated classes. You cannot wrap a non-instantiated template: + +.. code-block:: cpp + + // BROKEN (this will not compile) + py::class_(m, "Cage"); + .def("get", &Cage::get); + +You must explicitly specify each template/type combination that you want to +wrap separately. + +.. code-block:: cpp + + // ok + py::class_>(m, "CatCage") + .def("get", &Cage::get); + + // ok + py::class_>(m, "DogCage") + .def("get", &Cage::get); + +If your class methods have template parameters you can wrap those as well, +but once again each instantiation must be explicitly specified: + +.. code-block:: cpp + + typename + struct MyClass { + template + T fn(V v); + }; + + py::class>(m, "MyClassT") + .def("fn", &MyClass::fn); + +Custom automatic downcasters +============================ + +As explained in :ref:`inheritance`, pybind11 comes with built-in +understanding of the dynamic type of polymorphic objects in C++; that +is, returning a Pet to Python produces a Python object that knows it's +wrapping a Dog, if Pet has virtual methods and pybind11 knows about +Dog and this Pet is in fact a Dog. Sometimes, you might want to +provide this automatic downcasting behavior when creating bindings for +a class hierarchy that does not use standard C++ polymorphism, such as +LLVM [#f4]_. As long as there's some way to determine at runtime +whether a downcast is safe, you can proceed by specializing the +``pybind11::polymorphic_type_hook`` template: + +.. code-block:: cpp + + enum class PetKind { Cat, Dog, Zebra }; + struct Pet { // Not polymorphic: has no virtual methods + const PetKind kind; + int age = 0; + protected: + Pet(PetKind _kind) : kind(_kind) {} + }; + struct Dog : Pet { + Dog() : Pet(PetKind::Dog) {} + std::string sound = "woof!"; + std::string bark() const { return sound; } + }; + + namespace PYBIND11_NAMESPACE { + template<> struct polymorphic_type_hook { + static const void *get(const Pet *src, const std::type_info*& type) { + // note that src may be nullptr + if (src && src->kind == PetKind::Dog) { + type = &typeid(Dog); + return static_cast(src); + } + return src; + } + }; + } // namespace PYBIND11_NAMESPACE + +When pybind11 wants to convert a C++ pointer of type ``Base*`` to a +Python object, it calls ``polymorphic_type_hook::get()`` to +determine if a downcast is possible. The ``get()`` function should use +whatever runtime information is available to determine if its ``src`` +parameter is in fact an instance of some class ``Derived`` that +inherits from ``Base``. If it finds such a ``Derived``, it sets ``type += &typeid(Derived)`` and returns a pointer to the ``Derived`` object +that contains ``src``. Otherwise, it just returns ``src``, leaving +``type`` at its default value of nullptr. If you set ``type`` to a +type that pybind11 doesn't know about, no downcasting will occur, and +the original ``src`` pointer will be used with its static type +``Base*``. + +It is critical that the returned pointer and ``type`` argument of +``get()`` agree with each other: if ``type`` is set to something +non-null, the returned pointer must point to the start of an object +whose type is ``type``. If the hierarchy being exposed uses only +single inheritance, a simple ``return src;`` will achieve this just +fine, but in the general case, you must cast ``src`` to the +appropriate derived-class pointer (e.g. using +``static_cast(src)``) before allowing it to be returned as a +``void*``. + +.. [#f4] https://llvm.org/docs/HowToSetUpLLVMStyleRTTI.html + +.. note:: + + pybind11's standard support for downcasting objects whose types + have virtual methods is implemented using + ``polymorphic_type_hook`` too, using the standard C++ ability to + determine the most-derived type of a polymorphic object using + ``typeid()`` and to cast a base pointer to that most-derived type + (even if you don't know what it is) using ``dynamic_cast``. + +.. seealso:: + + The file :file:`tests/test_tagbased_polymorphic.cpp` contains a + more complete example, including a demonstration of how to provide + automatic downcasting for an entire class hierarchy without + writing one get() function for each class. + +Accessing the type object +========================= + +You can get the type object from a C++ class that has already been registered using: + +.. code-block:: cpp + + py::type T_py = py::type::of(); + +You can directly use ``py::type::of(ob)`` to get the type object from any python +object, just like ``type(ob)`` in Python. + +.. note:: + + Other types, like ``py::type::of()``, do not work, see :ref:`type-conversions`. + +.. versionadded:: 2.6 + +Custom type setup +================= + +For advanced use cases, such as enabling garbage collection support, you may +wish to directly manipulate the ``PyHeapTypeObject`` corresponding to a +``py::class_`` definition. + +You can do that using ``py::custom_type_setup``: + +.. code-block:: cpp + + struct OwnsPythonObjects { + py::object value = py::none(); + }; + py::class_ cls( + m, "OwnsPythonObjects", py::custom_type_setup([](PyHeapTypeObject *heap_type) { + auto *type = &heap_type->ht_type; + type->tp_flags |= Py_TPFLAGS_HAVE_GC; + type->tp_traverse = [](PyObject *self_base, visitproc visit, void *arg) { + auto &self = py::cast(py::handle(self_base)); + Py_VISIT(self.value.ptr()); + return 0; + }; + type->tp_clear = [](PyObject *self_base) { + auto &self = py::cast(py::handle(self_base)); + self.value = py::none(); + return 0; + }; + })); + cls.def(py::init<>()); + cls.def_readwrite("value", &OwnsPythonObjects::value); + +.. versionadded:: 2.8 diff --git a/dmff/dpnblist/external/pybind11-2.11.1/docs/advanced/embedding.rst b/dmff/dpnblist/external/pybind11-2.11.1/docs/advanced/embedding.rst new file mode 100644 index 00000000..e6a1686f --- /dev/null +++ b/dmff/dpnblist/external/pybind11-2.11.1/docs/advanced/embedding.rst @@ -0,0 +1,262 @@ +.. _embedding: + +Embedding the interpreter +######################### + +While pybind11 is mainly focused on extending Python using C++, it's also +possible to do the reverse: embed the Python interpreter into a C++ program. +All of the other documentation pages still apply here, so refer to them for +general pybind11 usage. This section will cover a few extra things required +for embedding. + +Getting started +=============== + +A basic executable with an embedded interpreter can be created with just a few +lines of CMake and the ``pybind11::embed`` target, as shown below. For more +information, see :doc:`/compiling`. + +.. code-block:: cmake + + cmake_minimum_required(VERSION 3.5...3.26) + project(example) + + find_package(pybind11 REQUIRED) # or `add_subdirectory(pybind11)` + + add_executable(example main.cpp) + target_link_libraries(example PRIVATE pybind11::embed) + +The essential structure of the ``main.cpp`` file looks like this: + +.. code-block:: cpp + + #include // everything needed for embedding + namespace py = pybind11; + + int main() { + py::scoped_interpreter guard{}; // start the interpreter and keep it alive + + py::print("Hello, World!"); // use the Python API + } + +The interpreter must be initialized before using any Python API, which includes +all the functions and classes in pybind11. The RAII guard class ``scoped_interpreter`` +takes care of the interpreter lifetime. After the guard is destroyed, the interpreter +shuts down and clears its memory. No Python functions can be called after this. + +Executing Python code +===================== + +There are a few different ways to run Python code. One option is to use ``eval``, +``exec`` or ``eval_file``, as explained in :ref:`eval`. Here is a quick example in +the context of an executable with an embedded interpreter: + +.. code-block:: cpp + + #include + namespace py = pybind11; + + int main() { + py::scoped_interpreter guard{}; + + py::exec(R"( + kwargs = dict(name="World", number=42) + message = "Hello, {name}! The answer is {number}".format(**kwargs) + print(message) + )"); + } + +Alternatively, similar results can be achieved using pybind11's API (see +:doc:`/advanced/pycpp/index` for more details). + +.. code-block:: cpp + + #include + namespace py = pybind11; + using namespace py::literals; + + int main() { + py::scoped_interpreter guard{}; + + auto kwargs = py::dict("name"_a="World", "number"_a=42); + auto message = "Hello, {name}! The answer is {number}"_s.format(**kwargs); + py::print(message); + } + +The two approaches can also be combined: + +.. code-block:: cpp + + #include + #include + + namespace py = pybind11; + using namespace py::literals; + + int main() { + py::scoped_interpreter guard{}; + + auto locals = py::dict("name"_a="World", "number"_a=42); + py::exec(R"( + message = "Hello, {name}! The answer is {number}".format(**locals()) + )", py::globals(), locals); + + auto message = locals["message"].cast(); + std::cout << message; + } + +Importing modules +================= + +Python modules can be imported using ``module_::import()``: + +.. code-block:: cpp + + py::module_ sys = py::module_::import("sys"); + py::print(sys.attr("path")); + +For convenience, the current working directory is included in ``sys.path`` when +embedding the interpreter. This makes it easy to import local Python files: + +.. code-block:: python + + """calc.py located in the working directory""" + + + def add(i, j): + return i + j + + +.. code-block:: cpp + + py::module_ calc = py::module_::import("calc"); + py::object result = calc.attr("add")(1, 2); + int n = result.cast(); + assert(n == 3); + +Modules can be reloaded using ``module_::reload()`` if the source is modified e.g. +by an external process. This can be useful in scenarios where the application +imports a user defined data processing script which needs to be updated after +changes by the user. Note that this function does not reload modules recursively. + +.. _embedding_modules: + +Adding embedded modules +======================= + +Embedded binary modules can be added using the ``PYBIND11_EMBEDDED_MODULE`` macro. +Note that the definition must be placed at global scope. They can be imported +like any other module. + +.. code-block:: cpp + + #include + namespace py = pybind11; + + PYBIND11_EMBEDDED_MODULE(fast_calc, m) { + // `m` is a `py::module_` which is used to bind functions and classes + m.def("add", [](int i, int j) { + return i + j; + }); + } + + int main() { + py::scoped_interpreter guard{}; + + auto fast_calc = py::module_::import("fast_calc"); + auto result = fast_calc.attr("add")(1, 2).cast(); + assert(result == 3); + } + +Unlike extension modules where only a single binary module can be created, on +the embedded side an unlimited number of modules can be added using multiple +``PYBIND11_EMBEDDED_MODULE`` definitions (as long as they have unique names). + +These modules are added to Python's list of builtins, so they can also be +imported in pure Python files loaded by the interpreter. Everything interacts +naturally: + +.. code-block:: python + + """py_module.py located in the working directory""" + import cpp_module + + a = cpp_module.a + b = a + 1 + + +.. code-block:: cpp + + #include + namespace py = pybind11; + + PYBIND11_EMBEDDED_MODULE(cpp_module, m) { + m.attr("a") = 1; + } + + int main() { + py::scoped_interpreter guard{}; + + auto py_module = py::module_::import("py_module"); + + auto locals = py::dict("fmt"_a="{} + {} = {}", **py_module.attr("__dict__")); + assert(locals["a"].cast() == 1); + assert(locals["b"].cast() == 2); + + py::exec(R"( + c = a + b + message = fmt.format(a, b, c) + )", py::globals(), locals); + + assert(locals["c"].cast() == 3); + assert(locals["message"].cast() == "1 + 2 = 3"); + } + + +Interpreter lifetime +==================== + +The Python interpreter shuts down when ``scoped_interpreter`` is destroyed. After +this, creating a new instance will restart the interpreter. Alternatively, the +``initialize_interpreter`` / ``finalize_interpreter`` pair of functions can be used +to directly set the state at any time. + +Modules created with pybind11 can be safely re-initialized after the interpreter +has been restarted. However, this may not apply to third-party extension modules. +The issue is that Python itself cannot completely unload extension modules and +there are several caveats with regard to interpreter restarting. In short, not +all memory may be freed, either due to Python reference cycles or user-created +global data. All the details can be found in the CPython documentation. + +.. warning:: + + Creating two concurrent ``scoped_interpreter`` guards is a fatal error. So is + calling ``initialize_interpreter`` for a second time after the interpreter + has already been initialized. + + Do not use the raw CPython API functions ``Py_Initialize`` and + ``Py_Finalize`` as these do not properly handle the lifetime of + pybind11's internal data. + + +Sub-interpreter support +======================= + +Creating multiple copies of ``scoped_interpreter`` is not possible because it +represents the main Python interpreter. Sub-interpreters are something different +and they do permit the existence of multiple interpreters. This is an advanced +feature of the CPython API and should be handled with care. pybind11 does not +currently offer a C++ interface for sub-interpreters, so refer to the CPython +documentation for all the details regarding this feature. + +We'll just mention a couple of caveats the sub-interpreters support in pybind11: + + 1. Sub-interpreters will not receive independent copies of embedded modules. + Instead, these are shared and modifications in one interpreter may be + reflected in another. + + 2. Managing multiple threads, multiple interpreters and the GIL can be + challenging and there are several caveats here, even within the pure + CPython API (please refer to the Python docs for details). As for + pybind11, keep in mind that ``gil_scoped_release`` and ``gil_scoped_acquire`` + do not take sub-interpreters into account. diff --git a/dmff/dpnblist/external/pybind11-2.11.1/docs/advanced/exceptions.rst b/dmff/dpnblist/external/pybind11-2.11.1/docs/advanced/exceptions.rst new file mode 100644 index 00000000..53981dc0 --- /dev/null +++ b/dmff/dpnblist/external/pybind11-2.11.1/docs/advanced/exceptions.rst @@ -0,0 +1,401 @@ +Exceptions +########## + +Built-in C++ to Python exception translation +============================================ + +When Python calls C++ code through pybind11, pybind11 provides a C++ exception handler +that will trap C++ exceptions, translate them to the corresponding Python exception, +and raise them so that Python code can handle them. + +pybind11 defines translations for ``std::exception`` and its standard +subclasses, and several special exception classes that translate to specific +Python exceptions. Note that these are not actually Python exceptions, so they +cannot be examined using the Python C API. Instead, they are pure C++ objects +that pybind11 will translate the corresponding Python exception when they arrive +at its exception handler. + +.. tabularcolumns:: |p{0.5\textwidth}|p{0.45\textwidth}| + ++--------------------------------------+--------------------------------------+ +| Exception thrown by C++ | Translated to Python exception type | ++======================================+======================================+ +| :class:`std::exception` | ``RuntimeError`` | ++--------------------------------------+--------------------------------------+ +| :class:`std::bad_alloc` | ``MemoryError`` | ++--------------------------------------+--------------------------------------+ +| :class:`std::domain_error` | ``ValueError`` | ++--------------------------------------+--------------------------------------+ +| :class:`std::invalid_argument` | ``ValueError`` | ++--------------------------------------+--------------------------------------+ +| :class:`std::length_error` | ``ValueError`` | ++--------------------------------------+--------------------------------------+ +| :class:`std::out_of_range` | ``IndexError`` | ++--------------------------------------+--------------------------------------+ +| :class:`std::range_error` | ``ValueError`` | ++--------------------------------------+--------------------------------------+ +| :class:`std::overflow_error` | ``OverflowError`` | ++--------------------------------------+--------------------------------------+ +| :class:`pybind11::stop_iteration` | ``StopIteration`` (used to implement | +| | custom iterators) | ++--------------------------------------+--------------------------------------+ +| :class:`pybind11::index_error` | ``IndexError`` (used to indicate out | +| | of bounds access in ``__getitem__``, | +| | ``__setitem__``, etc.) | ++--------------------------------------+--------------------------------------+ +| :class:`pybind11::key_error` | ``KeyError`` (used to indicate out | +| | of bounds access in ``__getitem__``, | +| | ``__setitem__`` in dict-like | +| | objects, etc.) | ++--------------------------------------+--------------------------------------+ +| :class:`pybind11::value_error` | ``ValueError`` (used to indicate | +| | wrong value passed in | +| | ``container.remove(...)``) | ++--------------------------------------+--------------------------------------+ +| :class:`pybind11::type_error` | ``TypeError`` | ++--------------------------------------+--------------------------------------+ +| :class:`pybind11::buffer_error` | ``BufferError`` | ++--------------------------------------+--------------------------------------+ +| :class:`pybind11::import_error` | ``ImportError`` | ++--------------------------------------+--------------------------------------+ +| :class:`pybind11::attribute_error` | ``AttributeError`` | ++--------------------------------------+--------------------------------------+ +| Any other exception | ``RuntimeError`` | ++--------------------------------------+--------------------------------------+ + +Exception translation is not bidirectional. That is, *catching* the C++ +exceptions defined above will not trap exceptions that originate from +Python. For that, catch :class:`pybind11::error_already_set`. See :ref:`below +` for further details. + +There is also a special exception :class:`cast_error` that is thrown by +:func:`handle::call` when the input arguments cannot be converted to Python +objects. + +Registering custom translators +============================== + +If the default exception conversion policy described above is insufficient, +pybind11 also provides support for registering custom exception translators. +Similar to pybind11 classes, exception translators can be local to the module +they are defined in or global to the entire python session. To register a simple +exception conversion that translates a C++ exception into a new Python exception +using the C++ exception's ``what()`` method, a helper function is available: + +.. code-block:: cpp + + py::register_exception(module, "PyExp"); + +This call creates a Python exception class with the name ``PyExp`` in the given +module and automatically converts any encountered exceptions of type ``CppExp`` +into Python exceptions of type ``PyExp``. + +A matching function is available for registering a local exception translator: + +.. code-block:: cpp + + py::register_local_exception(module, "PyExp"); + + +It is possible to specify base class for the exception using the third +parameter, a ``handle``: + +.. code-block:: cpp + + py::register_exception(module, "PyExp", PyExc_RuntimeError); + py::register_local_exception(module, "PyExp", PyExc_RuntimeError); + +Then ``PyExp`` can be caught both as ``PyExp`` and ``RuntimeError``. + +The class objects of the built-in Python exceptions are listed in the Python +documentation on `Standard Exceptions `_. +The default base class is ``PyExc_Exception``. + +When more advanced exception translation is needed, the functions +``py::register_exception_translator(translator)`` and +``py::register_local_exception_translator(translator)`` can be used to register +functions that can translate arbitrary exception types (and which may include +additional logic to do so). The functions takes a stateless callable (e.g. a +function pointer or a lambda function without captured variables) with the call +signature ``void(std::exception_ptr)``. + +When a C++ exception is thrown, the registered exception translators are tried +in reverse order of registration (i.e. the last registered translator gets the +first shot at handling the exception). All local translators will be tried +before a global translator is tried. + +Inside the translator, ``std::rethrow_exception`` should be used within +a try block to re-throw the exception. One or more catch clauses to catch +the appropriate exceptions should then be used with each clause using +``PyErr_SetString`` to set a Python exception or ``ex(string)`` to set +the python exception to a custom exception type (see below). + +To declare a custom Python exception type, declare a ``py::exception`` variable +and use this in the associated exception translator (note: it is often useful +to make this a static declaration when using it inside a lambda expression +without requiring capturing). + +The following example demonstrates this for a hypothetical exception classes +``MyCustomException`` and ``OtherException``: the first is translated to a +custom python exception ``MyCustomError``, while the second is translated to a +standard python RuntimeError: + +.. code-block:: cpp + + static py::exception exc(m, "MyCustomError"); + py::register_exception_translator([](std::exception_ptr p) { + try { + if (p) std::rethrow_exception(p); + } catch (const MyCustomException &e) { + exc(e.what()); + } catch (const OtherException &e) { + PyErr_SetString(PyExc_RuntimeError, e.what()); + } + }); + +Multiple exceptions can be handled by a single translator, as shown in the +example above. If the exception is not caught by the current translator, the +previously registered one gets a chance. + +If none of the registered exception translators is able to handle the +exception, it is handled by the default converter as described in the previous +section. + +.. seealso:: + + The file :file:`tests/test_exceptions.cpp` contains examples + of various custom exception translators and custom exception types. + +.. note:: + + Call either ``PyErr_SetString`` or a custom exception's call + operator (``exc(string)``) for every exception caught in a custom exception + translator. Failure to do so will cause Python to crash with ``SystemError: + error return without exception set``. + + Exceptions that you do not plan to handle should simply not be caught, or + may be explicitly (re-)thrown to delegate it to the other, + previously-declared existing exception translators. + + Note that ``libc++`` and ``libstdc++`` `behave differently under macOS + `_ + with ``-fvisibility=hidden``. Therefore exceptions that are used across ABI + boundaries need to be explicitly exported, as exercised in + ``tests/test_exceptions.h``. See also: + "Problems with C++ exceptions" under `GCC Wiki `_. + + +Local vs Global Exception Translators +===================================== + +When a global exception translator is registered, it will be applied across all +modules in the reverse order of registration. This can create behavior where the +order of module import influences how exceptions are translated. + +If module1 has the following translator: + +.. code-block:: cpp + + py::register_exception_translator([](std::exception_ptr p) { + try { + if (p) std::rethrow_exception(p); + } catch (const std::invalid_argument &e) { + PyErr_SetString("module1 handled this") + } + } + +and module2 has the following similar translator: + +.. code-block:: cpp + + py::register_exception_translator([](std::exception_ptr p) { + try { + if (p) std::rethrow_exception(p); + } catch (const std::invalid_argument &e) { + PyErr_SetString("module2 handled this") + } + } + +then which translator handles the invalid_argument will be determined by the +order that module1 and module2 are imported. Since exception translators are +applied in the reverse order of registration, which ever module was imported +last will "win" and that translator will be applied. + +If there are multiple pybind11 modules that share exception types (either +standard built-in or custom) loaded into a single python instance and +consistent error handling behavior is needed, then local translators should be +used. + +Changing the previous example to use ``register_local_exception_translator`` +would mean that when invalid_argument is thrown in the module2 code, the +module2 translator will always handle it, while in module1, the module1 +translator will do the same. + +.. _handling_python_exceptions_cpp: + +Handling exceptions from Python in C++ +====================================== + +When C++ calls Python functions, such as in a callback function or when +manipulating Python objects, and Python raises an ``Exception``, pybind11 +converts the Python exception into a C++ exception of type +:class:`pybind11::error_already_set` whose payload contains a C++ string textual +summary and the actual Python exception. ``error_already_set`` is used to +propagate Python exception back to Python (or possibly, handle them in C++). + +.. tabularcolumns:: |p{0.5\textwidth}|p{0.45\textwidth}| + ++--------------------------------------+--------------------------------------+ +| Exception raised in Python | Thrown as C++ exception type | ++======================================+======================================+ +| Any Python ``Exception`` | :class:`pybind11::error_already_set` | ++--------------------------------------+--------------------------------------+ + +For example: + +.. code-block:: cpp + + try { + // open("missing.txt", "r") + auto file = py::module_::import("io").attr("open")("missing.txt", "r"); + auto text = file.attr("read")(); + file.attr("close")(); + } catch (py::error_already_set &e) { + if (e.matches(PyExc_FileNotFoundError)) { + py::print("missing.txt not found"); + } else if (e.matches(PyExc_PermissionError)) { + py::print("missing.txt found but not accessible"); + } else { + throw; + } + } + +Note that C++ to Python exception translation does not apply here, since that is +a method for translating C++ exceptions to Python, not vice versa. The error raised +from Python is always ``error_already_set``. + +This example illustrates this behavior: + +.. code-block:: cpp + + try { + py::eval("raise ValueError('The Ring')"); + } catch (py::value_error &boromir) { + // Boromir never gets the ring + assert(false); + } catch (py::error_already_set &frodo) { + // Frodo gets the ring + py::print("I will take the ring"); + } + + try { + // py::value_error is a request for pybind11 to raise a Python exception + throw py::value_error("The ball"); + } catch (py::error_already_set &cat) { + // cat won't catch the ball since + // py::value_error is not a Python exception + assert(false); + } catch (py::value_error &dog) { + // dog will catch the ball + py::print("Run Spot run"); + throw; // Throw it again (pybind11 will raise ValueError) + } + +Handling errors from the Python C API +===================================== + +Where possible, use :ref:`pybind11 wrappers ` instead of calling +the Python C API directly. When calling the Python C API directly, in +addition to manually managing reference counts, one must follow the pybind11 +error protocol, which is outlined here. + +After calling the Python C API, if Python returns an error, +``throw py::error_already_set();``, which allows pybind11 to deal with the +exception and pass it back to the Python interpreter. This includes calls to +the error setting functions such as ``PyErr_SetString``. + +.. code-block:: cpp + + PyErr_SetString(PyExc_TypeError, "C API type error demo"); + throw py::error_already_set(); + + // But it would be easier to simply... + throw py::type_error("pybind11 wrapper type error"); + +Alternately, to ignore the error, call `PyErr_Clear +`_. + +Any Python error must be thrown or cleared, or Python/pybind11 will be left in +an invalid state. + +Chaining exceptions ('raise from') +================================== + +Python has a mechanism for indicating that exceptions were caused by other +exceptions: + +.. code-block:: py + + try: + print(1 / 0) + except Exception as exc: + raise RuntimeError("could not divide by zero") from exc + +To do a similar thing in pybind11, you can use the ``py::raise_from`` function. It +sets the current python error indicator, so to continue propagating the exception +you should ``throw py::error_already_set()``. + +.. code-block:: cpp + + try { + py::eval("print(1 / 0")); + } catch (py::error_already_set &e) { + py::raise_from(e, PyExc_RuntimeError, "could not divide by zero"); + throw py::error_already_set(); + } + +.. versionadded:: 2.8 + +.. _unraisable_exceptions: + +Handling unraisable exceptions +============================== + +If a Python function invoked from a C++ destructor or any function marked +``noexcept(true)`` (collectively, "noexcept functions") throws an exception, there +is no way to propagate the exception, as such functions may not throw. +Should they throw or fail to catch any exceptions in their call graph, +the C++ runtime calls ``std::terminate()`` to abort immediately. + +Similarly, Python exceptions raised in a class's ``__del__`` method do not +propagate, but are logged by Python as an unraisable error. In Python 3.8+, a +`system hook is triggered +`_ +and an auditing event is logged. + +Any noexcept function should have a try-catch block that traps +class:`error_already_set` (or any other exception that can occur). Note that +pybind11 wrappers around Python exceptions such as +:class:`pybind11::value_error` are *not* Python exceptions; they are C++ +exceptions that pybind11 catches and converts to Python exceptions. Noexcept +functions cannot propagate these exceptions either. A useful approach is to +convert them to Python exceptions and then ``discard_as_unraisable`` as shown +below. + +.. code-block:: cpp + + void nonthrowing_func() noexcept(true) { + try { + // ... + } catch (py::error_already_set &eas) { + // Discard the Python error using Python APIs, using the C++ magic + // variable __func__. Python already knows the type and value and of the + // exception object. + eas.discard_as_unraisable(__func__); + } catch (const std::exception &e) { + // Log and discard C++ exceptions. + third_party::log(e); + } + } + +.. versionadded:: 2.6 diff --git a/dmff/dpnblist/external/pybind11-2.11.1/docs/advanced/functions.rst b/dmff/dpnblist/external/pybind11-2.11.1/docs/advanced/functions.rst new file mode 100644 index 00000000..69e3d8a1 --- /dev/null +++ b/dmff/dpnblist/external/pybind11-2.11.1/docs/advanced/functions.rst @@ -0,0 +1,614 @@ +Functions +######### + +Before proceeding with this section, make sure that you are already familiar +with the basics of binding functions and classes, as explained in :doc:`/basics` +and :doc:`/classes`. The following guide is applicable to both free and member +functions, i.e. *methods* in Python. + +.. _return_value_policies: + +Return value policies +===================== + +Python and C++ use fundamentally different ways of managing the memory and +lifetime of objects managed by them. This can lead to issues when creating +bindings for functions that return a non-trivial type. Just by looking at the +type information, it is not clear whether Python should take charge of the +returned value and eventually free its resources, or if this is handled on the +C++ side. For this reason, pybind11 provides a several *return value policy* +annotations that can be passed to the :func:`module_::def` and +:func:`class_::def` functions. The default policy is +:enum:`return_value_policy::automatic`. + +Return value policies are tricky, and it's very important to get them right. +Just to illustrate what can go wrong, consider the following simple example: + +.. code-block:: cpp + + /* Function declaration */ + Data *get_data() { return _data; /* (pointer to a static data structure) */ } + ... + + /* Binding code */ + m.def("get_data", &get_data); // <-- KABOOM, will cause crash when called from Python + +What's going on here? When ``get_data()`` is called from Python, the return +value (a native C++ type) must be wrapped to turn it into a usable Python type. +In this case, the default return value policy (:enum:`return_value_policy::automatic`) +causes pybind11 to assume ownership of the static ``_data`` instance. + +When Python's garbage collector eventually deletes the Python +wrapper, pybind11 will also attempt to delete the C++ instance (via ``operator +delete()``) due to the implied ownership. At this point, the entire application +will come crashing down, though errors could also be more subtle and involve +silent data corruption. + +In the above example, the policy :enum:`return_value_policy::reference` should have +been specified so that the global data instance is only *referenced* without any +implied transfer of ownership, i.e.: + +.. code-block:: cpp + + m.def("get_data", &get_data, py::return_value_policy::reference); + +On the other hand, this is not the right policy for many other situations, +where ignoring ownership could lead to resource leaks. +As a developer using pybind11, it's important to be familiar with the different +return value policies, including which situation calls for which one of them. +The following table provides an overview of available policies: + +.. tabularcolumns:: |p{0.5\textwidth}|p{0.45\textwidth}| + ++--------------------------------------------------+----------------------------------------------------------------------------+ +| Return value policy | Description | ++==================================================+============================================================================+ +| :enum:`return_value_policy::take_ownership` | Reference an existing object (i.e. do not create a new copy) and take | +| | ownership. Python will call the destructor and delete operator when the | +| | object's reference count reaches zero. Undefined behavior ensues when the | +| | C++ side does the same, or when the data was not dynamically allocated. | ++--------------------------------------------------+----------------------------------------------------------------------------+ +| :enum:`return_value_policy::copy` | Create a new copy of the returned object, which will be owned by Python. | +| | This policy is comparably safe because the lifetimes of the two instances | +| | are decoupled. | ++--------------------------------------------------+----------------------------------------------------------------------------+ +| :enum:`return_value_policy::move` | Use ``std::move`` to move the return value contents into a new instance | +| | that will be owned by Python. This policy is comparably safe because the | +| | lifetimes of the two instances (move source and destination) are decoupled.| ++--------------------------------------------------+----------------------------------------------------------------------------+ +| :enum:`return_value_policy::reference` | Reference an existing object, but do not take ownership. The C++ side is | +| | responsible for managing the object's lifetime and deallocating it when | +| | it is no longer used. Warning: undefined behavior will ensue when the C++ | +| | side deletes an object that is still referenced and used by Python. | ++--------------------------------------------------+----------------------------------------------------------------------------+ +| :enum:`return_value_policy::reference_internal` | Indicates that the lifetime of the return value is tied to the lifetime | +| | of a parent object, namely the implicit ``this``, or ``self`` argument of | +| | the called method or property. Internally, this policy works just like | +| | :enum:`return_value_policy::reference` but additionally applies a | +| | ``keep_alive<0, 1>`` *call policy* (described in the next section) that | +| | prevents the parent object from being garbage collected as long as the | +| | return value is referenced by Python. This is the default policy for | +| | property getters created via ``def_property``, ``def_readwrite``, etc. | ++--------------------------------------------------+----------------------------------------------------------------------------+ +| :enum:`return_value_policy::automatic` | This policy falls back to the policy | +| | :enum:`return_value_policy::take_ownership` when the return value is a | +| | pointer. Otherwise, it uses :enum:`return_value_policy::move` or | +| | :enum:`return_value_policy::copy` for rvalue and lvalue references, | +| | respectively. See above for a description of what all of these different | +| | policies do. This is the default policy for ``py::class_``-wrapped types. | ++--------------------------------------------------+----------------------------------------------------------------------------+ +| :enum:`return_value_policy::automatic_reference` | As above, but use policy :enum:`return_value_policy::reference` when the | +| | return value is a pointer. This is the default conversion policy for | +| | function arguments when calling Python functions manually from C++ code | +| | (i.e. via ``handle::operator()``) and the casters in ``pybind11/stl.h``. | +| | You probably won't need to use this explicitly. | ++--------------------------------------------------+----------------------------------------------------------------------------+ + +Return value policies can also be applied to properties: + +.. code-block:: cpp + + class_(m, "MyClass") + .def_property("data", &MyClass::getData, &MyClass::setData, + py::return_value_policy::copy); + +Technically, the code above applies the policy to both the getter and the +setter function, however, the setter doesn't really care about *return* +value policies which makes this a convenient terse syntax. Alternatively, +targeted arguments can be passed through the :class:`cpp_function` constructor: + +.. code-block:: cpp + + class_(m, "MyClass") + .def_property("data", + py::cpp_function(&MyClass::getData, py::return_value_policy::copy), + py::cpp_function(&MyClass::setData) + ); + +.. warning:: + + Code with invalid return value policies might access uninitialized memory or + free data structures multiple times, which can lead to hard-to-debug + non-determinism and segmentation faults, hence it is worth spending the + time to understand all the different options in the table above. + +.. note:: + + One important aspect of the above policies is that they only apply to + instances which pybind11 has *not* seen before, in which case the policy + clarifies essential questions about the return value's lifetime and + ownership. When pybind11 knows the instance already (as identified by its + type and address in memory), it will return the existing Python object + wrapper rather than creating a new copy. + +.. note:: + + The next section on :ref:`call_policies` discusses *call policies* that can be + specified *in addition* to a return value policy from the list above. Call + policies indicate reference relationships that can involve both return values + and parameters of functions. + +.. note:: + + As an alternative to elaborate call policies and lifetime management logic, + consider using smart pointers (see the section on :ref:`smart_pointers` for + details). Smart pointers can tell whether an object is still referenced from + C++ or Python, which generally eliminates the kinds of inconsistencies that + can lead to crashes or undefined behavior. For functions returning smart + pointers, it is not necessary to specify a return value policy. + +.. _call_policies: + +Additional call policies +======================== + +In addition to the above return value policies, further *call policies* can be +specified to indicate dependencies between parameters or ensure a certain state +for the function call. + +Keep alive +---------- + +In general, this policy is required when the C++ object is any kind of container +and another object is being added to the container. ``keep_alive`` +indicates that the argument with index ``Patient`` should be kept alive at least +until the argument with index ``Nurse`` is freed by the garbage collector. Argument +indices start at one, while zero refers to the return value. For methods, index +``1`` refers to the implicit ``this`` pointer, while regular arguments begin at +index ``2``. Arbitrarily many call policies can be specified. When a ``Nurse`` +with value ``None`` is detected at runtime, the call policy does nothing. + +When the nurse is not a pybind11-registered type, the implementation internally +relies on the ability to create a *weak reference* to the nurse object. When +the nurse object is not a pybind11-registered type and does not support weak +references, an exception will be thrown. + +If you use an incorrect argument index, you will get a ``RuntimeError`` saying +``Could not activate keep_alive!``. You should review the indices you're using. + +Consider the following example: here, the binding code for a list append +operation ties the lifetime of the newly added element to the underlying +container: + +.. code-block:: cpp + + py::class_(m, "List") + .def("append", &List::append, py::keep_alive<1, 2>()); + +For consistency, the argument indexing is identical for constructors. Index +``1`` still refers to the implicit ``this`` pointer, i.e. the object which is +being constructed. Index ``0`` refers to the return type which is presumed to +be ``void`` when a constructor is viewed like a function. The following example +ties the lifetime of the constructor element to the constructed object: + +.. code-block:: cpp + + py::class_(m, "Nurse") + .def(py::init(), py::keep_alive<1, 2>()); + +.. note:: + + ``keep_alive`` is analogous to the ``with_custodian_and_ward`` (if Nurse, + Patient != 0) and ``with_custodian_and_ward_postcall`` (if Nurse/Patient == + 0) policies from Boost.Python. + +Call guard +---------- + +The ``call_guard`` policy allows any scope guard type ``T`` to be placed +around the function call. For example, this definition: + +.. code-block:: cpp + + m.def("foo", foo, py::call_guard()); + +is equivalent to the following pseudocode: + +.. code-block:: cpp + + m.def("foo", [](args...) { + T scope_guard; + return foo(args...); // forwarded arguments + }); + +The only requirement is that ``T`` is default-constructible, but otherwise any +scope guard will work. This is very useful in combination with ``gil_scoped_release``. +See :ref:`gil`. + +Multiple guards can also be specified as ``py::call_guard``. The +constructor order is left to right and destruction happens in reverse. + +.. seealso:: + + The file :file:`tests/test_call_policies.cpp` contains a complete example + that demonstrates using `keep_alive` and `call_guard` in more detail. + +.. _python_objects_as_args: + +Python objects as arguments +=========================== + +pybind11 exposes all major Python types using thin C++ wrapper classes. These +wrapper classes can also be used as parameters of functions in bindings, which +makes it possible to directly work with native Python types on the C++ side. +For instance, the following statement iterates over a Python ``dict``: + +.. code-block:: cpp + + void print_dict(const py::dict& dict) { + /* Easily interact with Python types */ + for (auto item : dict) + std::cout << "key=" << std::string(py::str(item.first)) << ", " + << "value=" << std::string(py::str(item.second)) << std::endl; + } + +It can be exported: + +.. code-block:: cpp + + m.def("print_dict", &print_dict); + +And used in Python as usual: + +.. code-block:: pycon + + >>> print_dict({"foo": 123, "bar": "hello"}) + key=foo, value=123 + key=bar, value=hello + +For more information on using Python objects in C++, see :doc:`/advanced/pycpp/index`. + +Accepting \*args and \*\*kwargs +=============================== + +Python provides a useful mechanism to define functions that accept arbitrary +numbers of arguments and keyword arguments: + +.. code-block:: python + + def generic(*args, **kwargs): + ... # do something with args and kwargs + +Such functions can also be created using pybind11: + +.. code-block:: cpp + + void generic(py::args args, const py::kwargs& kwargs) { + /// .. do something with args + if (kwargs) + /// .. do something with kwargs + } + + /// Binding code + m.def("generic", &generic); + +The class ``py::args`` derives from ``py::tuple`` and ``py::kwargs`` derives +from ``py::dict``. + +You may also use just one or the other, and may combine these with other +arguments. Note, however, that ``py::kwargs`` must always be the last argument +of the function, and ``py::args`` implies that any further arguments are +keyword-only (see :ref:`keyword_only_arguments`). + +Please refer to the other examples for details on how to iterate over these, +and on how to cast their entries into C++ objects. A demonstration is also +available in ``tests/test_kwargs_and_defaults.cpp``. + +.. note:: + + When combining \*args or \*\*kwargs with :ref:`keyword_args` you should + *not* include ``py::arg`` tags for the ``py::args`` and ``py::kwargs`` + arguments. + +Default arguments revisited +=========================== + +The section on :ref:`default_args` previously discussed basic usage of default +arguments using pybind11. One noteworthy aspect of their implementation is that +default arguments are converted to Python objects right at declaration time. +Consider the following example: + +.. code-block:: cpp + + py::class_("MyClass") + .def("myFunction", py::arg("arg") = SomeType(123)); + +In this case, pybind11 must already be set up to deal with values of the type +``SomeType`` (via a prior instantiation of ``py::class_``), or an +exception will be thrown. + +Another aspect worth highlighting is that the "preview" of the default argument +in the function signature is generated using the object's ``__repr__`` method. +If not available, the signature may not be very helpful, e.g.: + +.. code-block:: pycon + + FUNCTIONS + ... + | myFunction(...) + | Signature : (MyClass, arg : SomeType = ) -> NoneType + ... + +The first way of addressing this is by defining ``SomeType.__repr__``. +Alternatively, it is possible to specify the human-readable preview of the +default argument manually using the ``arg_v`` notation: + +.. code-block:: cpp + + py::class_("MyClass") + .def("myFunction", py::arg_v("arg", SomeType(123), "SomeType(123)")); + +Sometimes it may be necessary to pass a null pointer value as a default +argument. In this case, remember to cast it to the underlying type in question, +like so: + +.. code-block:: cpp + + py::class_("MyClass") + .def("myFunction", py::arg("arg") = static_cast(nullptr)); + +.. _keyword_only_arguments: + +Keyword-only arguments +====================== + +Python implements keyword-only arguments by specifying an unnamed ``*`` +argument in a function definition: + +.. code-block:: python + + def f(a, *, b): # a can be positional or via keyword; b must be via keyword + pass + + + f(a=1, b=2) # good + f(b=2, a=1) # good + f(1, b=2) # good + f(1, 2) # TypeError: f() takes 1 positional argument but 2 were given + +Pybind11 provides a ``py::kw_only`` object that allows you to implement +the same behaviour by specifying the object between positional and keyword-only +argument annotations when registering the function: + +.. code-block:: cpp + + m.def("f", [](int a, int b) { /* ... */ }, + py::arg("a"), py::kw_only(), py::arg("b")); + +.. versionadded:: 2.6 + +A ``py::args`` argument implies that any following arguments are keyword-only, +as if ``py::kw_only()`` had been specified in the same relative location of the +argument list as the ``py::args`` argument. The ``py::kw_only()`` may be +included to be explicit about this, but is not required. + +.. versionchanged:: 2.9 + This can now be combined with ``py::args``. Before, ``py::args`` could only + occur at the end of the argument list, or immediately before a ``py::kwargs`` + argument at the end. + + +Positional-only arguments +========================= + +Python 3.8 introduced a new positional-only argument syntax, using ``/`` in the +function definition (note that this has been a convention for CPython +positional arguments, such as in ``pow()``, since Python 2). You can +do the same thing in any version of Python using ``py::pos_only()``: + +.. code-block:: cpp + + m.def("f", [](int a, int b) { /* ... */ }, + py::arg("a"), py::pos_only(), py::arg("b")); + +You now cannot give argument ``a`` by keyword. This can be combined with +keyword-only arguments, as well. + +.. versionadded:: 2.6 + +.. _nonconverting_arguments: + +Non-converting arguments +======================== + +Certain argument types may support conversion from one type to another. Some +examples of conversions are: + +* :ref:`implicit_conversions` declared using ``py::implicitly_convertible()`` +* Calling a method accepting a double with an integer argument +* Calling a ``std::complex`` argument with a non-complex python type + (for example, with a float). (Requires the optional ``pybind11/complex.h`` + header). +* Calling a function taking an Eigen matrix reference with a numpy array of the + wrong type or of an incompatible data layout. (Requires the optional + ``pybind11/eigen.h`` header). + +This behaviour is sometimes undesirable: the binding code may prefer to raise +an error rather than convert the argument. This behaviour can be obtained +through ``py::arg`` by calling the ``.noconvert()`` method of the ``py::arg`` +object, such as: + +.. code-block:: cpp + + m.def("floats_only", [](double f) { return 0.5 * f; }, py::arg("f").noconvert()); + m.def("floats_preferred", [](double f) { return 0.5 * f; }, py::arg("f")); + +Attempting the call the second function (the one without ``.noconvert()``) with +an integer will succeed, but attempting to call the ``.noconvert()`` version +will fail with a ``TypeError``: + +.. code-block:: pycon + + >>> floats_preferred(4) + 2.0 + >>> floats_only(4) + Traceback (most recent call last): + File "", line 1, in + TypeError: floats_only(): incompatible function arguments. The following argument types are supported: + 1. (f: float) -> float + + Invoked with: 4 + +You may, of course, combine this with the :var:`_a` shorthand notation (see +:ref:`keyword_args`) and/or :ref:`default_args`. It is also permitted to omit +the argument name by using the ``py::arg()`` constructor without an argument +name, i.e. by specifying ``py::arg().noconvert()``. + +.. note:: + + When specifying ``py::arg`` options it is necessary to provide the same + number of options as the bound function has arguments. Thus if you want to + enable no-convert behaviour for just one of several arguments, you will + need to specify a ``py::arg()`` annotation for each argument with the + no-convert argument modified to ``py::arg().noconvert()``. + +.. _none_arguments: + +Allow/Prohibiting None arguments +================================ + +When a C++ type registered with :class:`py::class_` is passed as an argument to +a function taking the instance as pointer or shared holder (e.g. ``shared_ptr`` +or a custom, copyable holder as described in :ref:`smart_pointers`), pybind +allows ``None`` to be passed from Python which results in calling the C++ +function with ``nullptr`` (or an empty holder) for the argument. + +To explicitly enable or disable this behaviour, using the +``.none`` method of the :class:`py::arg` object: + +.. code-block:: cpp + + py::class_(m, "Dog").def(py::init<>()); + py::class_(m, "Cat").def(py::init<>()); + m.def("bark", [](Dog *dog) -> std::string { + if (dog) return "woof!"; /* Called with a Dog instance */ + else return "(no dog)"; /* Called with None, dog == nullptr */ + }, py::arg("dog").none(true)); + m.def("meow", [](Cat *cat) -> std::string { + // Can't be called with None argument + return "meow"; + }, py::arg("cat").none(false)); + +With the above, the Python call ``bark(None)`` will return the string ``"(no +dog)"``, while attempting to call ``meow(None)`` will raise a ``TypeError``: + +.. code-block:: pycon + + >>> from animals import Dog, Cat, bark, meow + >>> bark(Dog()) + 'woof!' + >>> meow(Cat()) + 'meow' + >>> bark(None) + '(no dog)' + >>> meow(None) + Traceback (most recent call last): + File "", line 1, in + TypeError: meow(): incompatible function arguments. The following argument types are supported: + 1. (cat: animals.Cat) -> str + + Invoked with: None + +The default behaviour when the tag is unspecified is to allow ``None``. + +.. note:: + + Even when ``.none(true)`` is specified for an argument, ``None`` will be converted to a + ``nullptr`` *only* for custom and :ref:`opaque ` types. Pointers to built-in types + (``double *``, ``int *``, ...) and STL types (``std::vector *``, ...; if ``pybind11/stl.h`` + is included) are copied when converted to C++ (see :doc:`/advanced/cast/overview`) and will + not allow ``None`` as argument. To pass optional argument of these copied types consider + using ``std::optional`` + +.. _overload_resolution: + +Overload resolution order +========================= + +When a function or method with multiple overloads is called from Python, +pybind11 determines which overload to call in two passes. The first pass +attempts to call each overload without allowing argument conversion (as if +every argument had been specified as ``py::arg().noconvert()`` as described +above). + +If no overload succeeds in the no-conversion first pass, a second pass is +attempted in which argument conversion is allowed (except where prohibited via +an explicit ``py::arg().noconvert()`` attribute in the function definition). + +If the second pass also fails a ``TypeError`` is raised. + +Within each pass, overloads are tried in the order they were registered with +pybind11. If the ``py::prepend()`` tag is added to the definition, a function +can be placed at the beginning of the overload sequence instead, allowing user +overloads to proceed built in functions. + +What this means in practice is that pybind11 will prefer any overload that does +not require conversion of arguments to an overload that does, but otherwise +prefers earlier-defined overloads to later-defined ones. + +.. note:: + + pybind11 does *not* further prioritize based on the number/pattern of + overloaded arguments. That is, pybind11 does not prioritize a function + requiring one conversion over one requiring three, but only prioritizes + overloads requiring no conversion at all to overloads that require + conversion of at least one argument. + +.. versionadded:: 2.6 + + The ``py::prepend()`` tag. + +Binding functions with template parameters +========================================== + +You can bind functions that have template parameters. Here's a function: + +.. code-block:: cpp + + template + void set(T t); + +C++ templates cannot be instantiated at runtime, so you cannot bind the +non-instantiated function: + +.. code-block:: cpp + + // BROKEN (this will not compile) + m.def("set", &set); + +You must bind each instantiated function template separately. You may bind +each instantiation with the same name, which will be treated the same as +an overloaded function: + +.. code-block:: cpp + + m.def("set", &set); + m.def("set", &set); + +Sometimes it's more clear to bind them with separate names, which is also +an option: + +.. code-block:: cpp + + m.def("setInt", &set); + m.def("setString", &set); diff --git a/dmff/dpnblist/external/pybind11-2.11.1/docs/advanced/misc.rst b/dmff/dpnblist/external/pybind11-2.11.1/docs/advanced/misc.rst new file mode 100644 index 00000000..805ec838 --- /dev/null +++ b/dmff/dpnblist/external/pybind11-2.11.1/docs/advanced/misc.rst @@ -0,0 +1,400 @@ +Miscellaneous +############# + +.. _macro_notes: + +General notes regarding convenience macros +========================================== + +pybind11 provides a few convenience macros such as +:func:`PYBIND11_DECLARE_HOLDER_TYPE` and ``PYBIND11_OVERRIDE_*``. Since these +are "just" macros that are evaluated in the preprocessor (which has no concept +of types), they *will* get confused by commas in a template argument; for +example, consider: + +.. code-block:: cpp + + PYBIND11_OVERRIDE(MyReturnType, Class, func) + +The limitation of the C preprocessor interprets this as five arguments (with new +arguments beginning after each comma) rather than three. To get around this, +there are two alternatives: you can use a type alias, or you can wrap the type +using the ``PYBIND11_TYPE`` macro: + +.. code-block:: cpp + + // Version 1: using a type alias + using ReturnType = MyReturnType; + using ClassType = Class; + PYBIND11_OVERRIDE(ReturnType, ClassType, func); + + // Version 2: using the PYBIND11_TYPE macro: + PYBIND11_OVERRIDE(PYBIND11_TYPE(MyReturnType), + PYBIND11_TYPE(Class), func) + +The ``PYBIND11_MAKE_OPAQUE`` macro does *not* require the above workarounds. + +.. _gil: + +Global Interpreter Lock (GIL) +============================= + +The Python C API dictates that the Global Interpreter Lock (GIL) must always +be held by the current thread to safely access Python objects. As a result, +when Python calls into C++ via pybind11 the GIL must be held, and pybind11 +will never implicitly release the GIL. + +.. code-block:: cpp + + void my_function() { + /* GIL is held when this function is called from Python */ + } + + PYBIND11_MODULE(example, m) { + m.def("my_function", &my_function); + } + +pybind11 will ensure that the GIL is held when it knows that it is calling +Python code. For example, if a Python callback is passed to C++ code via +``std::function``, when C++ code calls the function the built-in wrapper +will acquire the GIL before calling the Python callback. Similarly, the +``PYBIND11_OVERRIDE`` family of macros will acquire the GIL before calling +back into Python. + +When writing C++ code that is called from other C++ code, if that code accesses +Python state, it must explicitly acquire and release the GIL. + +The classes :class:`gil_scoped_release` and :class:`gil_scoped_acquire` can be +used to acquire and release the global interpreter lock in the body of a C++ +function call. In this way, long-running C++ code can be parallelized using +multiple Python threads, **but great care must be taken** when any +:class:`gil_scoped_release` appear: if there is any way that the C++ code +can access Python objects, :class:`gil_scoped_acquire` should be used to +reacquire the GIL. Taking :ref:`overriding_virtuals` as an example, this +could be realized as follows (important changes highlighted): + +.. code-block:: cpp + :emphasize-lines: 8,30,31 + + class PyAnimal : public Animal { + public: + /* Inherit the constructors */ + using Animal::Animal; + + /* Trampoline (need one for each virtual function) */ + std::string go(int n_times) { + /* PYBIND11_OVERRIDE_PURE will acquire the GIL before accessing Python state */ + PYBIND11_OVERRIDE_PURE( + std::string, /* Return type */ + Animal, /* Parent class */ + go, /* Name of function */ + n_times /* Argument(s) */ + ); + } + }; + + PYBIND11_MODULE(example, m) { + py::class_ animal(m, "Animal"); + animal + .def(py::init<>()) + .def("go", &Animal::go); + + py::class_(m, "Dog", animal) + .def(py::init<>()); + + m.def("call_go", [](Animal *animal) -> std::string { + // GIL is held when called from Python code. Release GIL before + // calling into (potentially long-running) C++ code + py::gil_scoped_release release; + return call_go(animal); + }); + } + +The ``call_go`` wrapper can also be simplified using the ``call_guard`` policy +(see :ref:`call_policies`) which yields the same result: + +.. code-block:: cpp + + m.def("call_go", &call_go, py::call_guard()); + + +Common Sources Of Global Interpreter Lock Errors +================================================================== + +Failing to properly hold the Global Interpreter Lock (GIL) is one of the +more common sources of bugs within code that uses pybind11. If you are +running into GIL related errors, we highly recommend you consult the +following checklist. + +- Do you have any global variables that are pybind11 objects or invoke + pybind11 functions in either their constructor or destructor? You are generally + not allowed to invoke any Python function in a global static context. We recommend + using lazy initialization and then intentionally leaking at the end of the program. + +- Do you have any pybind11 objects that are members of other C++ structures? One + commonly overlooked requirement is that pybind11 objects have to increase their reference count + whenever their copy constructor is called. Thus, you need to be holding the GIL to invoke + the copy constructor of any C++ class that has a pybind11 member. This can sometimes be very + tricky to track for complicated programs Think carefully when you make a pybind11 object + a member in another struct. + +- C++ destructors that invoke Python functions can be particularly troublesome as + destructors can sometimes get invoked in weird and unexpected circumstances as a result + of exceptions. + +- You should try running your code in a debug build. That will enable additional assertions + within pybind11 that will throw exceptions on certain GIL handling errors + (reference counting operations). + +Binding sequence data types, iterators, the slicing protocol, etc. +================================================================== + +Please refer to the supplemental example for details. + +.. seealso:: + + The file :file:`tests/test_sequences_and_iterators.cpp` contains a + complete example that shows how to bind a sequence data type, including + length queries (``__len__``), iterators (``__iter__``), the slicing + protocol and other kinds of useful operations. + + +Partitioning code over multiple extension modules +================================================= + +It's straightforward to split binding code over multiple extension modules, +while referencing types that are declared elsewhere. Everything "just" works +without any special precautions. One exception to this rule occurs when +extending a type declared in another extension module. Recall the basic example +from Section :ref:`inheritance`. + +.. code-block:: cpp + + py::class_ pet(m, "Pet"); + pet.def(py::init()) + .def_readwrite("name", &Pet::name); + + py::class_(m, "Dog", pet /* <- specify parent */) + .def(py::init()) + .def("bark", &Dog::bark); + +Suppose now that ``Pet`` bindings are defined in a module named ``basic``, +whereas the ``Dog`` bindings are defined somewhere else. The challenge is of +course that the variable ``pet`` is not available anymore though it is needed +to indicate the inheritance relationship to the constructor of ``class_``. +However, it can be acquired as follows: + +.. code-block:: cpp + + py::object pet = (py::object) py::module_::import("basic").attr("Pet"); + + py::class_(m, "Dog", pet) + .def(py::init()) + .def("bark", &Dog::bark); + +Alternatively, you can specify the base class as a template parameter option to +``class_``, which performs an automated lookup of the corresponding Python +type. Like the above code, however, this also requires invoking the ``import`` +function once to ensure that the pybind11 binding code of the module ``basic`` +has been executed: + +.. code-block:: cpp + + py::module_::import("basic"); + + py::class_(m, "Dog") + .def(py::init()) + .def("bark", &Dog::bark); + +Naturally, both methods will fail when there are cyclic dependencies. + +Note that pybind11 code compiled with hidden-by-default symbol visibility (e.g. +via the command line flag ``-fvisibility=hidden`` on GCC/Clang), which is +required for proper pybind11 functionality, can interfere with the ability to +access types defined in another extension module. Working around this requires +manually exporting types that are accessed by multiple extension modules; +pybind11 provides a macro to do just this: + +.. code-block:: cpp + + class PYBIND11_EXPORT Dog : public Animal { + ... + }; + +Note also that it is possible (although would rarely be required) to share arbitrary +C++ objects between extension modules at runtime. Internal library data is shared +between modules using capsule machinery [#f6]_ which can be also utilized for +storing, modifying and accessing user-defined data. Note that an extension module +will "see" other extensions' data if and only if they were built with the same +pybind11 version. Consider the following example: + +.. code-block:: cpp + + auto data = reinterpret_cast(py::get_shared_data("mydata")); + if (!data) + data = static_cast(py::set_shared_data("mydata", new MyData(42))); + +If the above snippet was used in several separately compiled extension modules, +the first one to be imported would create a ``MyData`` instance and associate +a ``"mydata"`` key with a pointer to it. Extensions that are imported later +would be then able to access the data behind the same pointer. + +.. [#f6] https://docs.python.org/3/extending/extending.html#using-capsules + +Module Destructors +================== + +pybind11 does not provide an explicit mechanism to invoke cleanup code at +module destruction time. In rare cases where such functionality is required, it +is possible to emulate it using Python capsules or weak references with a +destruction callback. + +.. code-block:: cpp + + auto cleanup_callback = []() { + // perform cleanup here -- this function is called with the GIL held + }; + + m.add_object("_cleanup", py::capsule(cleanup_callback)); + +This approach has the potential downside that instances of classes exposed +within the module may still be alive when the cleanup callback is invoked +(whether this is acceptable will generally depend on the application). + +Alternatively, the capsule may also be stashed within a type object, which +ensures that it not called before all instances of that type have been +collected: + +.. code-block:: cpp + + auto cleanup_callback = []() { /* ... */ }; + m.attr("BaseClass").attr("_cleanup") = py::capsule(cleanup_callback); + +Both approaches also expose a potentially dangerous ``_cleanup`` attribute in +Python, which may be undesirable from an API standpoint (a premature explicit +call from Python might lead to undefined behavior). Yet another approach that +avoids this issue involves weak reference with a cleanup callback: + +.. code-block:: cpp + + // Register a callback function that is invoked when the BaseClass object is collected + py::cpp_function cleanup_callback( + [](py::handle weakref) { + // perform cleanup here -- this function is called with the GIL held + + weakref.dec_ref(); // release weak reference + } + ); + + // Create a weak reference with a cleanup callback and initially leak it + (void) py::weakref(m.attr("BaseClass"), cleanup_callback).release(); + +.. note:: + + PyPy does not garbage collect objects when the interpreter exits. An alternative + approach (which also works on CPython) is to use the :py:mod:`atexit` module [#f7]_, + for example: + + .. code-block:: cpp + + auto atexit = py::module_::import("atexit"); + atexit.attr("register")(py::cpp_function([]() { + // perform cleanup here -- this function is called with the GIL held + })); + + .. [#f7] https://docs.python.org/3/library/atexit.html + + +Generating documentation using Sphinx +===================================== + +Sphinx [#f4]_ has the ability to inspect the signatures and documentation +strings in pybind11-based extension modules to automatically generate beautiful +documentation in a variety formats. The python_example repository [#f5]_ contains a +simple example repository which uses this approach. + +There are two potential gotchas when using this approach: first, make sure that +the resulting strings do not contain any :kbd:`TAB` characters, which break the +docstring parsing routines. You may want to use C++11 raw string literals, +which are convenient for multi-line comments. Conveniently, any excess +indentation will be automatically be removed by Sphinx. However, for this to +work, it is important that all lines are indented consistently, i.e.: + +.. code-block:: cpp + + // ok + m.def("foo", &foo, R"mydelimiter( + The foo function + + Parameters + ---------- + )mydelimiter"); + + // *not ok* + m.def("foo", &foo, R"mydelimiter(The foo function + + Parameters + ---------- + )mydelimiter"); + +By default, pybind11 automatically generates and prepends a signature to the docstring of a function +registered with ``module_::def()`` and ``class_::def()``. Sometimes this +behavior is not desirable, because you want to provide your own signature or remove +the docstring completely to exclude the function from the Sphinx documentation. +The class ``options`` allows you to selectively suppress auto-generated signatures: + +.. code-block:: cpp + + PYBIND11_MODULE(example, m) { + py::options options; + options.disable_function_signatures(); + + m.def("add", [](int a, int b) { return a + b; }, "A function which adds two numbers"); + } + +pybind11 also appends all members of an enum to the resulting enum docstring. +This default behavior can be disabled by using the ``disable_enum_members_docstring()`` +function of the ``options`` class. + +With ``disable_user_defined_docstrings()`` all user defined docstrings of +``module_::def()``, ``class_::def()`` and ``enum_()`` are disabled, but the +function signatures and enum members are included in the docstring, unless they +are disabled separately. + +Note that changes to the settings affect only function bindings created during the +lifetime of the ``options`` instance. When it goes out of scope at the end of the module's init function, +the default settings are restored to prevent unwanted side effects. + +.. [#f4] http://www.sphinx-doc.org +.. [#f5] http://github.com/pybind/python_example + +.. _avoiding-cpp-types-in-docstrings: + +Avoiding C++ types in docstrings +================================ + +Docstrings are generated at the time of the declaration, e.g. when ``.def(...)`` is called. +At this point parameter and return types should be known to pybind11. +If a custom type is not exposed yet through a ``py::class_`` constructor or a custom type caster, +its C++ type name will be used instead to generate the signature in the docstring: + +.. code-block:: text + + | __init__(...) + | __init__(self: example.Foo, arg0: ns::Bar) -> None + ^^^^^^^ + + +This limitation can be circumvented by ensuring that C++ classes are registered with pybind11 +before they are used as a parameter or return type of a function: + +.. code-block:: cpp + + PYBIND11_MODULE(example, m) { + + auto pyFoo = py::class_(m, "Foo"); + auto pyBar = py::class_(m, "Bar"); + + pyFoo.def(py::init()); + pyBar.def(py::init()); + } diff --git a/dmff/dpnblist/external/pybind11-2.11.1/docs/advanced/pycpp/index.rst b/dmff/dpnblist/external/pybind11-2.11.1/docs/advanced/pycpp/index.rst new file mode 100644 index 00000000..6885bdcf --- /dev/null +++ b/dmff/dpnblist/external/pybind11-2.11.1/docs/advanced/pycpp/index.rst @@ -0,0 +1,13 @@ +Python C++ interface +#################### + +pybind11 exposes Python types and functions using thin C++ wrappers, which +makes it possible to conveniently call Python code from C++ without resorting +to Python's C API. + +.. toctree:: + :maxdepth: 2 + + object + numpy + utilities diff --git a/dmff/dpnblist/external/pybind11-2.11.1/docs/advanced/pycpp/numpy.rst b/dmff/dpnblist/external/pybind11-2.11.1/docs/advanced/pycpp/numpy.rst new file mode 100644 index 00000000..07c96930 --- /dev/null +++ b/dmff/dpnblist/external/pybind11-2.11.1/docs/advanced/pycpp/numpy.rst @@ -0,0 +1,455 @@ +.. _numpy: + +NumPy +##### + +Buffer protocol +=============== + +Python supports an extremely general and convenient approach for exchanging +data between plugin libraries. Types can expose a buffer view [#f2]_, which +provides fast direct access to the raw internal data representation. Suppose we +want to bind the following simplistic Matrix class: + +.. code-block:: cpp + + class Matrix { + public: + Matrix(size_t rows, size_t cols) : m_rows(rows), m_cols(cols) { + m_data = new float[rows*cols]; + } + float *data() { return m_data; } + size_t rows() const { return m_rows; } + size_t cols() const { return m_cols; } + private: + size_t m_rows, m_cols; + float *m_data; + }; + +The following binding code exposes the ``Matrix`` contents as a buffer object, +making it possible to cast Matrices into NumPy arrays. It is even possible to +completely avoid copy operations with Python expressions like +``np.array(matrix_instance, copy = False)``. + +.. code-block:: cpp + + py::class_(m, "Matrix", py::buffer_protocol()) + .def_buffer([](Matrix &m) -> py::buffer_info { + return py::buffer_info( + m.data(), /* Pointer to buffer */ + sizeof(float), /* Size of one scalar */ + py::format_descriptor::format(), /* Python struct-style format descriptor */ + 2, /* Number of dimensions */ + { m.rows(), m.cols() }, /* Buffer dimensions */ + { sizeof(float) * m.cols(), /* Strides (in bytes) for each index */ + sizeof(float) } + ); + }); + +Supporting the buffer protocol in a new type involves specifying the special +``py::buffer_protocol()`` tag in the ``py::class_`` constructor and calling the +``def_buffer()`` method with a lambda function that creates a +``py::buffer_info`` description record on demand describing a given matrix +instance. The contents of ``py::buffer_info`` mirror the Python buffer protocol +specification. + +.. code-block:: cpp + + struct buffer_info { + void *ptr; + py::ssize_t itemsize; + std::string format; + py::ssize_t ndim; + std::vector shape; + std::vector strides; + }; + +To create a C++ function that can take a Python buffer object as an argument, +simply use the type ``py::buffer`` as one of its arguments. Buffers can exist +in a great variety of configurations, hence some safety checks are usually +necessary in the function body. Below, you can see a basic example on how to +define a custom constructor for the Eigen double precision matrix +(``Eigen::MatrixXd``) type, which supports initialization from compatible +buffer objects (e.g. a NumPy matrix). + +.. code-block:: cpp + + /* Bind MatrixXd (or some other Eigen type) to Python */ + typedef Eigen::MatrixXd Matrix; + + typedef Matrix::Scalar Scalar; + constexpr bool rowMajor = Matrix::Flags & Eigen::RowMajorBit; + + py::class_(m, "Matrix", py::buffer_protocol()) + .def(py::init([](py::buffer b) { + typedef Eigen::Stride Strides; + + /* Request a buffer descriptor from Python */ + py::buffer_info info = b.request(); + + /* Some basic validation checks ... */ + if (info.format != py::format_descriptor::format()) + throw std::runtime_error("Incompatible format: expected a double array!"); + + if (info.ndim != 2) + throw std::runtime_error("Incompatible buffer dimension!"); + + auto strides = Strides( + info.strides[rowMajor ? 0 : 1] / (py::ssize_t)sizeof(Scalar), + info.strides[rowMajor ? 1 : 0] / (py::ssize_t)sizeof(Scalar)); + + auto map = Eigen::Map( + static_cast(info.ptr), info.shape[0], info.shape[1], strides); + + return Matrix(map); + })); + +For reference, the ``def_buffer()`` call for this Eigen data type should look +as follows: + +.. code-block:: cpp + + .def_buffer([](Matrix &m) -> py::buffer_info { + return py::buffer_info( + m.data(), /* Pointer to buffer */ + sizeof(Scalar), /* Size of one scalar */ + py::format_descriptor::format(), /* Python struct-style format descriptor */ + 2, /* Number of dimensions */ + { m.rows(), m.cols() }, /* Buffer dimensions */ + { sizeof(Scalar) * (rowMajor ? m.cols() : 1), + sizeof(Scalar) * (rowMajor ? 1 : m.rows()) } + /* Strides (in bytes) for each index */ + ); + }) + +For a much easier approach of binding Eigen types (although with some +limitations), refer to the section on :doc:`/advanced/cast/eigen`. + +.. seealso:: + + The file :file:`tests/test_buffers.cpp` contains a complete example + that demonstrates using the buffer protocol with pybind11 in more detail. + +.. [#f2] http://docs.python.org/3/c-api/buffer.html + +Arrays +====== + +By exchanging ``py::buffer`` with ``py::array`` in the above snippet, we can +restrict the function so that it only accepts NumPy arrays (rather than any +type of Python object satisfying the buffer protocol). + +In many situations, we want to define a function which only accepts a NumPy +array of a certain data type. This is possible via the ``py::array_t`` +template. For instance, the following function requires the argument to be a +NumPy array containing double precision values. + +.. code-block:: cpp + + void f(py::array_t array); + +When it is invoked with a different type (e.g. an integer or a list of +integers), the binding code will attempt to cast the input into a NumPy array +of the requested type. This feature requires the :file:`pybind11/numpy.h` +header to be included. Note that :file:`pybind11/numpy.h` does not depend on +the NumPy headers, and thus can be used without declaring a build-time +dependency on NumPy; NumPy>=1.7.0 is a runtime dependency. + +Data in NumPy arrays is not guaranteed to packed in a dense manner; +furthermore, entries can be separated by arbitrary column and row strides. +Sometimes, it can be useful to require a function to only accept dense arrays +using either the C (row-major) or Fortran (column-major) ordering. This can be +accomplished via a second template argument with values ``py::array::c_style`` +or ``py::array::f_style``. + +.. code-block:: cpp + + void f(py::array_t array); + +The ``py::array::forcecast`` argument is the default value of the second +template parameter, and it ensures that non-conforming arguments are converted +into an array satisfying the specified requirements instead of trying the next +function overload. + +There are several methods on arrays; the methods listed below under references +work, as well as the following functions based on the NumPy API: + +- ``.dtype()`` returns the type of the contained values. + +- ``.strides()`` returns a pointer to the strides of the array (optionally pass + an integer axis to get a number). + +- ``.flags()`` returns the flag settings. ``.writable()`` and ``.owndata()`` + are directly available. + +- ``.offset_at()`` returns the offset (optionally pass indices). + +- ``.squeeze()`` returns a view with length-1 axes removed. + +- ``.view(dtype)`` returns a view of the array with a different dtype. + +- ``.reshape({i, j, ...})`` returns a view of the array with a different shape. + ``.resize({...})`` is also available. + +- ``.index_at(i, j, ...)`` gets the count from the beginning to a given index. + + +There are also several methods for getting references (described below). + +Structured types +================ + +In order for ``py::array_t`` to work with structured (record) types, we first +need to register the memory layout of the type. This can be done via +``PYBIND11_NUMPY_DTYPE`` macro, called in the plugin definition code, which +expects the type followed by field names: + +.. code-block:: cpp + + struct A { + int x; + double y; + }; + + struct B { + int z; + A a; + }; + + // ... + PYBIND11_MODULE(test, m) { + // ... + + PYBIND11_NUMPY_DTYPE(A, x, y); + PYBIND11_NUMPY_DTYPE(B, z, a); + /* now both A and B can be used as template arguments to py::array_t */ + } + +The structure should consist of fundamental arithmetic types, ``std::complex``, +previously registered substructures, and arrays of any of the above. Both C++ +arrays and ``std::array`` are supported. While there is a static assertion to +prevent many types of unsupported structures, it is still the user's +responsibility to use only "plain" structures that can be safely manipulated as +raw memory without violating invariants. + +Vectorizing functions +===================== + +Suppose we want to bind a function with the following signature to Python so +that it can process arbitrary NumPy array arguments (vectors, matrices, general +N-D arrays) in addition to its normal arguments: + +.. code-block:: cpp + + double my_func(int x, float y, double z); + +After including the ``pybind11/numpy.h`` header, this is extremely simple: + +.. code-block:: cpp + + m.def("vectorized_func", py::vectorize(my_func)); + +Invoking the function like below causes 4 calls to be made to ``my_func`` with +each of the array elements. The significant advantage of this compared to +solutions like ``numpy.vectorize()`` is that the loop over the elements runs +entirely on the C++ side and can be crunched down into a tight, optimized loop +by the compiler. The result is returned as a NumPy array of type +``numpy.dtype.float64``. + +.. code-block:: pycon + + >>> x = np.array([[1, 3], [5, 7]]) + >>> y = np.array([[2, 4], [6, 8]]) + >>> z = 3 + >>> result = vectorized_func(x, y, z) + +The scalar argument ``z`` is transparently replicated 4 times. The input +arrays ``x`` and ``y`` are automatically converted into the right types (they +are of type ``numpy.dtype.int64`` but need to be ``numpy.dtype.int32`` and +``numpy.dtype.float32``, respectively). + +.. note:: + + Only arithmetic, complex, and POD types passed by value or by ``const &`` + reference are vectorized; all other arguments are passed through as-is. + Functions taking rvalue reference arguments cannot be vectorized. + +In cases where the computation is too complicated to be reduced to +``vectorize``, it will be necessary to create and access the buffer contents +manually. The following snippet contains a complete example that shows how this +works (the code is somewhat contrived, since it could have been done more +simply using ``vectorize``). + +.. code-block:: cpp + + #include + #include + + namespace py = pybind11; + + py::array_t add_arrays(py::array_t input1, py::array_t input2) { + py::buffer_info buf1 = input1.request(), buf2 = input2.request(); + + if (buf1.ndim != 1 || buf2.ndim != 1) + throw std::runtime_error("Number of dimensions must be one"); + + if (buf1.size != buf2.size) + throw std::runtime_error("Input shapes must match"); + + /* No pointer is passed, so NumPy will allocate the buffer */ + auto result = py::array_t(buf1.size); + + py::buffer_info buf3 = result.request(); + + double *ptr1 = static_cast(buf1.ptr); + double *ptr2 = static_cast(buf2.ptr); + double *ptr3 = static_cast(buf3.ptr); + + for (size_t idx = 0; idx < buf1.shape[0]; idx++) + ptr3[idx] = ptr1[idx] + ptr2[idx]; + + return result; + } + + PYBIND11_MODULE(test, m) { + m.def("add_arrays", &add_arrays, "Add two NumPy arrays"); + } + +.. seealso:: + + The file :file:`tests/test_numpy_vectorize.cpp` contains a complete + example that demonstrates using :func:`vectorize` in more detail. + +Direct access +============= + +For performance reasons, particularly when dealing with very large arrays, it +is often desirable to directly access array elements without internal checking +of dimensions and bounds on every access when indices are known to be already +valid. To avoid such checks, the ``array`` class and ``array_t`` template +class offer an unchecked proxy object that can be used for this unchecked +access through the ``unchecked`` and ``mutable_unchecked`` methods, +where ``N`` gives the required dimensionality of the array: + +.. code-block:: cpp + + m.def("sum_3d", [](py::array_t x) { + auto r = x.unchecked<3>(); // x must have ndim = 3; can be non-writeable + double sum = 0; + for (py::ssize_t i = 0; i < r.shape(0); i++) + for (py::ssize_t j = 0; j < r.shape(1); j++) + for (py::ssize_t k = 0; k < r.shape(2); k++) + sum += r(i, j, k); + return sum; + }); + m.def("increment_3d", [](py::array_t x) { + auto r = x.mutable_unchecked<3>(); // Will throw if ndim != 3 or flags.writeable is false + for (py::ssize_t i = 0; i < r.shape(0); i++) + for (py::ssize_t j = 0; j < r.shape(1); j++) + for (py::ssize_t k = 0; k < r.shape(2); k++) + r(i, j, k) += 1.0; + }, py::arg().noconvert()); + +To obtain the proxy from an ``array`` object, you must specify both the data +type and number of dimensions as template arguments, such as ``auto r = +myarray.mutable_unchecked()``. + +If the number of dimensions is not known at compile time, you can omit the +dimensions template parameter (i.e. calling ``arr_t.unchecked()`` or +``arr.unchecked()``. This will give you a proxy object that works in the +same way, but results in less optimizable code and thus a small efficiency +loss in tight loops. + +Note that the returned proxy object directly references the array's data, and +only reads its shape, strides, and writeable flag when constructed. You must +take care to ensure that the referenced array is not destroyed or reshaped for +the duration of the returned object, typically by limiting the scope of the +returned instance. + +The returned proxy object supports some of the same methods as ``py::array`` so +that it can be used as a drop-in replacement for some existing, index-checked +uses of ``py::array``: + +- ``.ndim()`` returns the number of dimensions + +- ``.data(1, 2, ...)`` and ``r.mutable_data(1, 2, ...)``` returns a pointer to + the ``const T`` or ``T`` data, respectively, at the given indices. The + latter is only available to proxies obtained via ``a.mutable_unchecked()``. + +- ``.itemsize()`` returns the size of an item in bytes, i.e. ``sizeof(T)``. + +- ``.ndim()`` returns the number of dimensions. + +- ``.shape(n)`` returns the size of dimension ``n`` + +- ``.size()`` returns the total number of elements (i.e. the product of the shapes). + +- ``.nbytes()`` returns the number of bytes used by the referenced elements + (i.e. ``itemsize()`` times ``size()``). + +.. seealso:: + + The file :file:`tests/test_numpy_array.cpp` contains additional examples + demonstrating the use of this feature. + +Ellipsis +======== + +Python provides a convenient ``...`` ellipsis notation that is often used to +slice multidimensional arrays. For instance, the following snippet extracts the +middle dimensions of a tensor with the first and last index set to zero. + +.. code-block:: python + + a = ... # a NumPy array + b = a[0, ..., 0] + +The function ``py::ellipsis()`` function can be used to perform the same +operation on the C++ side: + +.. code-block:: cpp + + py::array a = /* A NumPy array */; + py::array b = a[py::make_tuple(0, py::ellipsis(), 0)]; + + +Memory view +=========== + +For a case when we simply want to provide a direct accessor to C/C++ buffer +without a concrete class object, we can return a ``memoryview`` object. Suppose +we wish to expose a ``memoryview`` for 2x4 uint8_t array, we can do the +following: + +.. code-block:: cpp + + const uint8_t buffer[] = { + 0, 1, 2, 3, + 4, 5, 6, 7 + }; + m.def("get_memoryview2d", []() { + return py::memoryview::from_buffer( + buffer, // buffer pointer + { 2, 4 }, // shape (rows, cols) + { sizeof(uint8_t) * 4, sizeof(uint8_t) } // strides in bytes + ); + }); + +This approach is meant for providing a ``memoryview`` for a C/C++ buffer not +managed by Python. The user is responsible for managing the lifetime of the +buffer. Using a ``memoryview`` created in this way after deleting the buffer in +C++ side results in undefined behavior. + +We can also use ``memoryview::from_memory`` for a simple 1D contiguous buffer: + +.. code-block:: cpp + + m.def("get_memoryview1d", []() { + return py::memoryview::from_memory( + buffer, // buffer pointer + sizeof(uint8_t) * 8 // buffer size + ); + }); + +.. versionchanged:: 2.6 + ``memoryview::from_memory`` added. diff --git a/dmff/dpnblist/external/pybind11-2.11.1/docs/advanced/pycpp/object.rst b/dmff/dpnblist/external/pybind11-2.11.1/docs/advanced/pycpp/object.rst new file mode 100644 index 00000000..93e1a94d --- /dev/null +++ b/dmff/dpnblist/external/pybind11-2.11.1/docs/advanced/pycpp/object.rst @@ -0,0 +1,286 @@ +Python types +############ + +.. _wrappers: + +Available wrappers +================== + +All major Python types are available as thin C++ wrapper classes. These +can also be used as function parameters -- see :ref:`python_objects_as_args`. + +Available types include :class:`handle`, :class:`object`, :class:`bool_`, +:class:`int_`, :class:`float_`, :class:`str`, :class:`bytes`, :class:`tuple`, +:class:`list`, :class:`dict`, :class:`slice`, :class:`none`, :class:`capsule`, +:class:`iterable`, :class:`iterator`, :class:`function`, :class:`buffer`, +:class:`array`, and :class:`array_t`. + +.. warning:: + + Be sure to review the :ref:`pytypes_gotchas` before using this heavily in + your C++ API. + +.. _instantiating_compound_types: + +Instantiating compound Python types from C++ +============================================ + +Dictionaries can be initialized in the :class:`dict` constructor: + +.. code-block:: cpp + + using namespace pybind11::literals; // to bring in the `_a` literal + py::dict d("spam"_a=py::none(), "eggs"_a=42); + +A tuple of python objects can be instantiated using :func:`py::make_tuple`: + +.. code-block:: cpp + + py::tuple tup = py::make_tuple(42, py::none(), "spam"); + +Each element is converted to a supported Python type. + +A `simple namespace`_ can be instantiated using + +.. code-block:: cpp + + using namespace pybind11::literals; // to bring in the `_a` literal + py::object SimpleNamespace = py::module_::import("types").attr("SimpleNamespace"); + py::object ns = SimpleNamespace("spam"_a=py::none(), "eggs"_a=42); + +Attributes on a namespace can be modified with the :func:`py::delattr`, +:func:`py::getattr`, and :func:`py::setattr` functions. Simple namespaces can +be useful as lightweight stand-ins for class instances. + +.. _simple namespace: https://docs.python.org/3/library/types.html#types.SimpleNamespace + +.. _casting_back_and_forth: + +Casting back and forth +====================== + +In this kind of mixed code, it is often necessary to convert arbitrary C++ +types to Python, which can be done using :func:`py::cast`: + +.. code-block:: cpp + + MyClass *cls = ...; + py::object obj = py::cast(cls); + +The reverse direction uses the following syntax: + +.. code-block:: cpp + + py::object obj = ...; + MyClass *cls = obj.cast(); + +When conversion fails, both directions throw the exception :class:`cast_error`. + +.. _python_libs: + +Accessing Python libraries from C++ +=================================== + +It is also possible to import objects defined in the Python standard +library or available in the current Python environment (``sys.path``) and work +with these in C++. + +This example obtains a reference to the Python ``Decimal`` class. + +.. code-block:: cpp + + // Equivalent to "from decimal import Decimal" + py::object Decimal = py::module_::import("decimal").attr("Decimal"); + +.. code-block:: cpp + + // Try to import scipy + py::object scipy = py::module_::import("scipy"); + return scipy.attr("__version__"); + + +.. _calling_python_functions: + +Calling Python functions +======================== + +It is also possible to call Python classes, functions and methods +via ``operator()``. + +.. code-block:: cpp + + // Construct a Python object of class Decimal + py::object pi = Decimal("3.14159"); + +.. code-block:: cpp + + // Use Python to make our directories + py::object os = py::module_::import("os"); + py::object makedirs = os.attr("makedirs"); + makedirs("/tmp/path/to/somewhere"); + +One can convert the result obtained from Python to a pure C++ version +if a ``py::class_`` or type conversion is defined. + +.. code-block:: cpp + + py::function f = <...>; + py::object result_py = f(1234, "hello", some_instance); + MyClass &result = result_py.cast(); + +.. _calling_python_methods: + +Calling Python methods +======================== + +To call an object's method, one can again use ``.attr`` to obtain access to the +Python method. + +.. code-block:: cpp + + // Calculate e^π in decimal + py::object exp_pi = pi.attr("exp")(); + py::print(py::str(exp_pi)); + +In the example above ``pi.attr("exp")`` is a *bound method*: it will always call +the method for that same instance of the class. Alternately one can create an +*unbound method* via the Python class (instead of instance) and pass the ``self`` +object explicitly, followed by other arguments. + +.. code-block:: cpp + + py::object decimal_exp = Decimal.attr("exp"); + + // Compute the e^n for n=0..4 + for (int n = 0; n < 5; n++) { + py::print(decimal_exp(Decimal(n)); + } + +Keyword arguments +================= + +Keyword arguments are also supported. In Python, there is the usual call syntax: + +.. code-block:: python + + def f(number, say, to): + ... # function code + + + f(1234, say="hello", to=some_instance) # keyword call in Python + +In C++, the same call can be made using: + +.. code-block:: cpp + + using namespace pybind11::literals; // to bring in the `_a` literal + f(1234, "say"_a="hello", "to"_a=some_instance); // keyword call in C++ + +Unpacking arguments +=================== + +Unpacking of ``*args`` and ``**kwargs`` is also possible and can be mixed with +other arguments: + +.. code-block:: cpp + + // * unpacking + py::tuple args = py::make_tuple(1234, "hello", some_instance); + f(*args); + + // ** unpacking + py::dict kwargs = py::dict("number"_a=1234, "say"_a="hello", "to"_a=some_instance); + f(**kwargs); + + // mixed keywords, * and ** unpacking + py::tuple args = py::make_tuple(1234); + py::dict kwargs = py::dict("to"_a=some_instance); + f(*args, "say"_a="hello", **kwargs); + +Generalized unpacking according to PEP448_ is also supported: + +.. code-block:: cpp + + py::dict kwargs1 = py::dict("number"_a=1234); + py::dict kwargs2 = py::dict("to"_a=some_instance); + f(**kwargs1, "say"_a="hello", **kwargs2); + +.. seealso:: + + The file :file:`tests/test_pytypes.cpp` contains a complete + example that demonstrates passing native Python types in more detail. The + file :file:`tests/test_callbacks.cpp` presents a few examples of calling + Python functions from C++, including keywords arguments and unpacking. + +.. _PEP448: https://www.python.org/dev/peps/pep-0448/ + +.. _implicit_casting: + +Implicit casting +================ + +When using the C++ interface for Python types, or calling Python functions, +objects of type :class:`object` are returned. It is possible to invoke implicit +conversions to subclasses like :class:`dict`. The same holds for the proxy objects +returned by ``operator[]`` or ``obj.attr()``. +Casting to subtypes improves code readability and allows values to be passed to +C++ functions that require a specific subtype rather than a generic :class:`object`. + +.. code-block:: cpp + + #include + using namespace pybind11::literals; + + py::module_ os = py::module_::import("os"); + py::module_ path = py::module_::import("os.path"); // like 'import os.path as path' + py::module_ np = py::module_::import("numpy"); // like 'import numpy as np' + + py::str curdir_abs = path.attr("abspath")(path.attr("curdir")); + py::print(py::str("Current directory: ") + curdir_abs); + py::dict environ = os.attr("environ"); + py::print(environ["HOME"]); + py::array_t arr = np.attr("ones")(3, "dtype"_a="float32"); + py::print(py::repr(arr + py::int_(1))); + +These implicit conversions are available for subclasses of :class:`object`; there +is no need to call ``obj.cast()`` explicitly as for custom classes, see +:ref:`casting_back_and_forth`. + +.. note:: + If a trivial conversion via move constructor is not possible, both implicit and + explicit casting (calling ``obj.cast()``) will attempt a "rich" conversion. + For instance, ``py::list env = os.attr("environ");`` will succeed and is + equivalent to the Python code ``env = list(os.environ)`` that produces a + list of the dict keys. + +.. TODO: Adapt text once PR #2349 has landed + +Handling exceptions +=================== + +Python exceptions from wrapper classes will be thrown as a ``py::error_already_set``. +See :ref:`Handling exceptions from Python in C++ +` for more information on handling exceptions +raised when calling C++ wrapper classes. + +.. _pytypes_gotchas: + +Gotchas +======= + +Default-Constructed Wrappers +---------------------------- + +When a wrapper type is default-constructed, it is **not** a valid Python object (i.e. it is not ``py::none()``). It is simply the same as +``PyObject*`` null pointer. To check for this, use +``static_cast(my_wrapper)``. + +Assigning py::none() to wrappers +-------------------------------- + +You may be tempted to use types like ``py::str`` and ``py::dict`` in C++ +signatures (either pure C++, or in bound signatures), and assign them default +values of ``py::none()``. However, in a best case scenario, it will fail fast +because ``None`` is not convertible to that type (e.g. ``py::dict``), or in a +worse case scenario, it will silently work but corrupt the types you want to +work with (e.g. ``py::str(py::none())`` will yield ``"None"`` in Python). diff --git a/dmff/dpnblist/external/pybind11-2.11.1/docs/advanced/pycpp/utilities.rst b/dmff/dpnblist/external/pybind11-2.11.1/docs/advanced/pycpp/utilities.rst new file mode 100644 index 00000000..af0f9cb2 --- /dev/null +++ b/dmff/dpnblist/external/pybind11-2.11.1/docs/advanced/pycpp/utilities.rst @@ -0,0 +1,155 @@ +Utilities +######### + +Using Python's print function in C++ +==================================== + +The usual way to write output in C++ is using ``std::cout`` while in Python one +would use ``print``. Since these methods use different buffers, mixing them can +lead to output order issues. To resolve this, pybind11 modules can use the +:func:`py::print` function which writes to Python's ``sys.stdout`` for consistency. + +Python's ``print`` function is replicated in the C++ API including optional +keyword arguments ``sep``, ``end``, ``file``, ``flush``. Everything works as +expected in Python: + +.. code-block:: cpp + + py::print(1, 2.0, "three"); // 1 2.0 three + py::print(1, 2.0, "three", "sep"_a="-"); // 1-2.0-three + + auto args = py::make_tuple("unpacked", true); + py::print("->", *args, "end"_a="<-"); // -> unpacked True <- + +.. _ostream_redirect: + +Capturing standard output from ostream +====================================== + +Often, a library will use the streams ``std::cout`` and ``std::cerr`` to print, +but this does not play well with Python's standard ``sys.stdout`` and ``sys.stderr`` +redirection. Replacing a library's printing with ``py::print `` may not +be feasible. This can be fixed using a guard around the library function that +redirects output to the corresponding Python streams: + +.. code-block:: cpp + + #include + + ... + + // Add a scoped redirect for your noisy code + m.def("noisy_func", []() { + py::scoped_ostream_redirect stream( + std::cout, // std::ostream& + py::module_::import("sys").attr("stdout") // Python output + ); + call_noisy_func(); + }); + +.. warning:: + + The implementation in ``pybind11/iostream.h`` is NOT thread safe. Multiple + threads writing to a redirected ostream concurrently cause data races + and potentially buffer overflows. Therefore it is currently a requirement + that all (possibly) concurrent redirected ostream writes are protected by + a mutex. #HelpAppreciated: Work on iostream.h thread safety. For more + background see the discussions under + `PR #2982 `_ and + `PR #2995 `_. + +This method respects flushes on the output streams and will flush if needed +when the scoped guard is destroyed. This allows the output to be redirected in +real time, such as to a Jupyter notebook. The two arguments, the C++ stream and +the Python output, are optional, and default to standard output if not given. An +extra type, ``py::scoped_estream_redirect ``, is identical +except for defaulting to ``std::cerr`` and ``sys.stderr``; this can be useful with +``py::call_guard``, which allows multiple items, but uses the default constructor: + +.. code-block:: cpp + + // Alternative: Call single function using call guard + m.def("noisy_func", &call_noisy_function, + py::call_guard()); + +The redirection can also be done in Python with the addition of a context +manager, using the ``py::add_ostream_redirect() `` function: + +.. code-block:: cpp + + py::add_ostream_redirect(m, "ostream_redirect"); + +The name in Python defaults to ``ostream_redirect`` if no name is passed. This +creates the following context manager in Python: + +.. code-block:: python + + with ostream_redirect(stdout=True, stderr=True): + noisy_function() + +It defaults to redirecting both streams, though you can use the keyword +arguments to disable one of the streams if needed. + +.. note:: + + The above methods will not redirect C-level output to file descriptors, such + as ``fprintf``. For those cases, you'll need to redirect the file + descriptors either directly in C or with Python's ``os.dup2`` function + in an operating-system dependent way. + +.. _eval: + +Evaluating Python expressions from strings and files +==================================================== + +pybind11 provides the ``eval``, ``exec`` and ``eval_file`` functions to evaluate +Python expressions and statements. The following example illustrates how they +can be used. + +.. code-block:: cpp + + // At beginning of file + #include + + ... + + // Evaluate in scope of main module + py::object scope = py::module_::import("__main__").attr("__dict__"); + + // Evaluate an isolated expression + int result = py::eval("my_variable + 10", scope).cast(); + + // Evaluate a sequence of statements + py::exec( + "print('Hello')\n" + "print('world!');", + scope); + + // Evaluate the statements in an separate Python file on disk + py::eval_file("script.py", scope); + +C++11 raw string literals are also supported and quite handy for this purpose. +The only requirement is that the first statement must be on a new line following +the raw string delimiter ``R"(``, ensuring all lines have common leading indent: + +.. code-block:: cpp + + py::exec(R"( + x = get_answer() + if x == 42: + print('Hello World!') + else: + print('Bye!') + )", scope + ); + +.. note:: + + `eval` and `eval_file` accept a template parameter that describes how the + string/file should be interpreted. Possible choices include ``eval_expr`` + (isolated expression), ``eval_single_statement`` (a single statement, return + value is always ``none``), and ``eval_statements`` (sequence of statements, + return value is always ``none``). `eval` defaults to ``eval_expr``, + `eval_file` defaults to ``eval_statements`` and `exec` is just a shortcut + for ``eval``. diff --git a/dmff/dpnblist/external/pybind11-2.11.1/docs/advanced/smart_ptrs.rst b/dmff/dpnblist/external/pybind11-2.11.1/docs/advanced/smart_ptrs.rst new file mode 100644 index 00000000..3c40ce12 --- /dev/null +++ b/dmff/dpnblist/external/pybind11-2.11.1/docs/advanced/smart_ptrs.rst @@ -0,0 +1,174 @@ +Smart pointers +############## + +std::unique_ptr +=============== + +Given a class ``Example`` with Python bindings, it's possible to return +instances wrapped in C++11 unique pointers, like so + +.. code-block:: cpp + + std::unique_ptr create_example() { return std::unique_ptr(new Example()); } + +.. code-block:: cpp + + m.def("create_example", &create_example); + +In other words, there is nothing special that needs to be done. While returning +unique pointers in this way is allowed, it is *illegal* to use them as function +arguments. For instance, the following function signature cannot be processed +by pybind11. + +.. code-block:: cpp + + void do_something_with_example(std::unique_ptr ex) { ... } + +The above signature would imply that Python needs to give up ownership of an +object that is passed to this function, which is generally not possible (for +instance, the object might be referenced elsewhere). + +std::shared_ptr +=============== + +The binding generator for classes, :class:`class_`, can be passed a template +type that denotes a special *holder* type that is used to manage references to +the object. If no such holder type template argument is given, the default for +a type named ``Type`` is ``std::unique_ptr``, which means that the object +is deallocated when Python's reference count goes to zero. + +It is possible to switch to other types of reference counting wrappers or smart +pointers, which is useful in codebases that rely on them. For instance, the +following snippet causes ``std::shared_ptr`` to be used instead. + +.. code-block:: cpp + + py::class_ /* <- holder type */> obj(m, "Example"); + +Note that any particular class can only be associated with a single holder type. + +One potential stumbling block when using holder types is that they need to be +applied consistently. Can you guess what's broken about the following binding +code? + +.. code-block:: cpp + + class Child { }; + + class Parent { + public: + Parent() : child(std::make_shared()) { } + Child *get_child() { return child.get(); } /* Hint: ** DON'T DO THIS ** */ + private: + std::shared_ptr child; + }; + + PYBIND11_MODULE(example, m) { + py::class_>(m, "Child"); + + py::class_>(m, "Parent") + .def(py::init<>()) + .def("get_child", &Parent::get_child); + } + +The following Python code will cause undefined behavior (and likely a +segmentation fault). + +.. code-block:: python + + from example import Parent + + print(Parent().get_child()) + +The problem is that ``Parent::get_child()`` returns a pointer to an instance of +``Child``, but the fact that this instance is already managed by +``std::shared_ptr<...>`` is lost when passing raw pointers. In this case, +pybind11 will create a second independent ``std::shared_ptr<...>`` that also +claims ownership of the pointer. In the end, the object will be freed **twice** +since these shared pointers have no way of knowing about each other. + +There are two ways to resolve this issue: + +1. For types that are managed by a smart pointer class, never use raw pointers + in function arguments or return values. In other words: always consistently + wrap pointers into their designated holder types (such as + ``std::shared_ptr<...>``). In this case, the signature of ``get_child()`` + should be modified as follows: + +.. code-block:: cpp + + std::shared_ptr get_child() { return child; } + +2. Adjust the definition of ``Child`` by specifying + ``std::enable_shared_from_this`` (see cppreference_ for details) as a + base class. This adds a small bit of information to ``Child`` that allows + pybind11 to realize that there is already an existing + ``std::shared_ptr<...>`` and communicate with it. In this case, the + declaration of ``Child`` should look as follows: + +.. _cppreference: http://en.cppreference.com/w/cpp/memory/enable_shared_from_this + +.. code-block:: cpp + + class Child : public std::enable_shared_from_this { }; + +.. _smart_pointers: + +Custom smart pointers +===================== + +pybind11 supports ``std::unique_ptr`` and ``std::shared_ptr`` right out of the +box. For any other custom smart pointer, transparent conversions can be enabled +using a macro invocation similar to the following. It must be declared at the +top namespace level before any binding code: + +.. code-block:: cpp + + PYBIND11_DECLARE_HOLDER_TYPE(T, SmartPtr); + +The first argument of :func:`PYBIND11_DECLARE_HOLDER_TYPE` should be a +placeholder name that is used as a template parameter of the second argument. +Thus, feel free to use any identifier, but use it consistently on both sides; +also, don't use the name of a type that already exists in your codebase. + +The macro also accepts a third optional boolean parameter that is set to false +by default. Specify + +.. code-block:: cpp + + PYBIND11_DECLARE_HOLDER_TYPE(T, SmartPtr, true); + +if ``SmartPtr`` can always be initialized from a ``T*`` pointer without the +risk of inconsistencies (such as multiple independent ``SmartPtr`` instances +believing that they are the sole owner of the ``T*`` pointer). A common +situation where ``true`` should be passed is when the ``T`` instances use +*intrusive* reference counting. + +Please take a look at the :ref:`macro_notes` before using this feature. + +By default, pybind11 assumes that your custom smart pointer has a standard +interface, i.e. provides a ``.get()`` member function to access the underlying +raw pointer. If this is not the case, pybind11's ``holder_helper`` must be +specialized: + +.. code-block:: cpp + + // Always needed for custom holder types + PYBIND11_DECLARE_HOLDER_TYPE(T, SmartPtr); + + // Only needed if the type's `.get()` goes by another name + namespace PYBIND11_NAMESPACE { namespace detail { + template + struct holder_helper> { // <-- specialization + static const T *get(const SmartPtr &p) { return p.getPointer(); } + }; + }} + +The above specialization informs pybind11 that the custom ``SmartPtr`` class +provides ``.get()`` functionality via ``.getPointer()``. + +.. seealso:: + + The file :file:`tests/test_smart_ptr.cpp` contains a complete example + that demonstrates how to work with custom reference-counting holder types + in more detail. diff --git a/dmff/dpnblist/external/pybind11-2.11.1/docs/basics.rst b/dmff/dpnblist/external/pybind11-2.11.1/docs/basics.rst new file mode 100644 index 00000000..e9b24c7f --- /dev/null +++ b/dmff/dpnblist/external/pybind11-2.11.1/docs/basics.rst @@ -0,0 +1,307 @@ +.. _basics: + +First steps +########### + +This sections demonstrates the basic features of pybind11. Before getting +started, make sure that development environment is set up to compile the +included set of test cases. + + +Compiling the test cases +======================== + +Linux/macOS +----------- + +On Linux you'll need to install the **python-dev** or **python3-dev** packages as +well as **cmake**. On macOS, the included python version works out of the box, +but **cmake** must still be installed. + +After installing the prerequisites, run + +.. code-block:: bash + + mkdir build + cd build + cmake .. + make check -j 4 + +The last line will both compile and run the tests. + +Windows +------- + +On Windows, only **Visual Studio 2017** and newer are supported. + +.. Note:: + + To use the C++17 in Visual Studio 2017 (MSVC 14.1), pybind11 requires the flag + ``/permissive-`` to be passed to the compiler `to enforce standard conformance`_. When + building with Visual Studio 2019, this is not strictly necessary, but still advised. + +.. _`to enforce standard conformance`: https://docs.microsoft.com/en-us/cpp/build/reference/permissive-standards-conformance?view=vs-2017 + +To compile and run the tests: + +.. code-block:: batch + + mkdir build + cd build + cmake .. + cmake --build . --config Release --target check + +This will create a Visual Studio project, compile and run the target, all from the +command line. + +.. Note:: + + If all tests fail, make sure that the Python binary and the testcases are compiled + for the same processor type and bitness (i.e. either **i386** or **x86_64**). You + can specify **x86_64** as the target architecture for the generated Visual Studio + project using ``cmake -A x64 ..``. + +.. seealso:: + + Advanced users who are already familiar with Boost.Python may want to skip + the tutorial and look at the test cases in the :file:`tests` directory, + which exercise all features of pybind11. + +Header and namespace conventions +================================ + +For brevity, all code examples assume that the following two lines are present: + +.. code-block:: cpp + + #include + + namespace py = pybind11; + +Some features may require additional headers, but those will be specified as needed. + +.. _simple_example: + +Creating bindings for a simple function +======================================= + +Let's start by creating Python bindings for an extremely simple function, which +adds two numbers and returns their result: + +.. code-block:: cpp + + int add(int i, int j) { + return i + j; + } + +For simplicity [#f1]_, we'll put both this function and the binding code into +a file named :file:`example.cpp` with the following contents: + +.. code-block:: cpp + + #include + + int add(int i, int j) { + return i + j; + } + + PYBIND11_MODULE(example, m) { + m.doc() = "pybind11 example plugin"; // optional module docstring + + m.def("add", &add, "A function that adds two numbers"); + } + +.. [#f1] In practice, implementation and binding code will generally be located + in separate files. + +The :func:`PYBIND11_MODULE` macro creates a function that will be called when an +``import`` statement is issued from within Python. The module name (``example``) +is given as the first macro argument (it should not be in quotes). The second +argument (``m``) defines a variable of type :class:`py::module_ ` which +is the main interface for creating bindings. The method :func:`module_::def` +generates binding code that exposes the ``add()`` function to Python. + +.. note:: + + Notice how little code was needed to expose our function to Python: all + details regarding the function's parameters and return value were + automatically inferred using template metaprogramming. This overall + approach and the used syntax are borrowed from Boost.Python, though the + underlying implementation is very different. + +pybind11 is a header-only library, hence it is not necessary to link against +any special libraries and there are no intermediate (magic) translation steps. +On Linux, the above example can be compiled using the following command: + +.. code-block:: bash + + $ c++ -O3 -Wall -shared -std=c++11 -fPIC $(python3 -m pybind11 --includes) example.cpp -o example$(python3-config --extension-suffix) + +.. note:: + + If you used :ref:`include_as_a_submodule` to get the pybind11 source, then + use ``$(python3-config --includes) -Iextern/pybind11/include`` instead of + ``$(python3 -m pybind11 --includes)`` in the above compilation, as + explained in :ref:`building_manually`. + +For more details on the required compiler flags on Linux and macOS, see +:ref:`building_manually`. For complete cross-platform compilation instructions, +refer to the :ref:`compiling` page. + +The `python_example`_ and `cmake_example`_ repositories are also a good place +to start. They are both complete project examples with cross-platform build +systems. The only difference between the two is that `python_example`_ uses +Python's ``setuptools`` to build the module, while `cmake_example`_ uses CMake +(which may be preferable for existing C++ projects). + +.. _python_example: https://github.com/pybind/python_example +.. _cmake_example: https://github.com/pybind/cmake_example + +Building the above C++ code will produce a binary module file that can be +imported to Python. Assuming that the compiled module is located in the +current directory, the following interactive Python session shows how to +load and execute the example: + +.. code-block:: pycon + + $ python + Python 3.9.10 (main, Jan 15 2022, 11:48:04) + [Clang 13.0.0 (clang-1300.0.29.3)] on darwin + Type "help", "copyright", "credits" or "license" for more information. + >>> import example + >>> example.add(1, 2) + 3 + >>> + +.. _keyword_args: + +Keyword arguments +================= + +With a simple code modification, it is possible to inform Python about the +names of the arguments ("i" and "j" in this case). + +.. code-block:: cpp + + m.def("add", &add, "A function which adds two numbers", + py::arg("i"), py::arg("j")); + +:class:`arg` is one of several special tag classes which can be used to pass +metadata into :func:`module_::def`. With this modified binding code, we can now +call the function using keyword arguments, which is a more readable alternative +particularly for functions taking many parameters: + +.. code-block:: pycon + + >>> import example + >>> example.add(i=1, j=2) + 3L + +The keyword names also appear in the function signatures within the documentation. + +.. code-block:: pycon + + >>> help(example) + + .... + + FUNCTIONS + add(...) + Signature : (i: int, j: int) -> int + + A function which adds two numbers + +A shorter notation for named arguments is also available: + +.. code-block:: cpp + + // regular notation + m.def("add1", &add, py::arg("i"), py::arg("j")); + // shorthand + using namespace pybind11::literals; + m.def("add2", &add, "i"_a, "j"_a); + +The :var:`_a` suffix forms a C++11 literal which is equivalent to :class:`arg`. +Note that the literal operator must first be made visible with the directive +``using namespace pybind11::literals``. This does not bring in anything else +from the ``pybind11`` namespace except for literals. + +.. _default_args: + +Default arguments +================= + +Suppose now that the function to be bound has default arguments, e.g.: + +.. code-block:: cpp + + int add(int i = 1, int j = 2) { + return i + j; + } + +Unfortunately, pybind11 cannot automatically extract these parameters, since they +are not part of the function's type information. However, they are simple to specify +using an extension of :class:`arg`: + +.. code-block:: cpp + + m.def("add", &add, "A function which adds two numbers", + py::arg("i") = 1, py::arg("j") = 2); + +The default values also appear within the documentation. + +.. code-block:: pycon + + >>> help(example) + + .... + + FUNCTIONS + add(...) + Signature : (i: int = 1, j: int = 2) -> int + + A function which adds two numbers + +The shorthand notation is also available for default arguments: + +.. code-block:: cpp + + // regular notation + m.def("add1", &add, py::arg("i") = 1, py::arg("j") = 2); + // shorthand + m.def("add2", &add, "i"_a=1, "j"_a=2); + +Exporting variables +=================== + +To expose a value from C++, use the ``attr`` function to register it in a +module as shown below. Built-in types and general objects (more on that later) +are automatically converted when assigned as attributes, and can be explicitly +converted using the function ``py::cast``. + +.. code-block:: cpp + + PYBIND11_MODULE(example, m) { + m.attr("the_answer") = 42; + py::object world = py::cast("World"); + m.attr("what") = world; + } + +These are then accessible from Python: + +.. code-block:: pycon + + >>> import example + >>> example.the_answer + 42 + >>> example.what + 'World' + +.. _supported_types: + +Supported data types +==================== + +A large number of data types are supported out of the box and can be used +seamlessly as functions arguments, return values or with ``py::cast`` in general. +For a full overview, see the :doc:`advanced/cast/index` section. diff --git a/dmff/dpnblist/external/pybind11-2.11.1/docs/benchmark.py b/dmff/dpnblist/external/pybind11-2.11.1/docs/benchmark.py new file mode 100644 index 00000000..2150b6ca --- /dev/null +++ b/dmff/dpnblist/external/pybind11-2.11.1/docs/benchmark.py @@ -0,0 +1,87 @@ +import datetime as dt +import os +import random + +nfns = 4 # Functions per class +nargs = 4 # Arguments per function + + +def generate_dummy_code_pybind11(nclasses=10): + decl = "" + bindings = "" + + for cl in range(nclasses): + decl += f"class cl{cl:03};\n" + decl += "\n" + + for cl in range(nclasses): + decl += f"class {cl:03} {{\n" + decl += "public:\n" + bindings += f' py::class_(m, "cl{cl:03}")\n' + for fn in range(nfns): + ret = random.randint(0, nclasses - 1) + params = [random.randint(0, nclasses - 1) for i in range(nargs)] + decl += f" cl{ret:03} *fn_{fn:03}(" + decl += ", ".join(f"cl{p:03} *" for p in params) + decl += ");\n" + bindings += f' .def("fn_{fn:03}", &cl{cl:03}::fn_{fn:03})\n' + decl += "};\n\n" + bindings += " ;\n" + + result = "#include \n\n" + result += "namespace py = pybind11;\n\n" + result += decl + "\n" + result += "PYBIND11_MODULE(example, m) {\n" + result += bindings + result += "}" + return result + + +def generate_dummy_code_boost(nclasses=10): + decl = "" + bindings = "" + + for cl in range(nclasses): + decl += f"class cl{cl:03};\n" + decl += "\n" + + for cl in range(nclasses): + decl += "class cl%03i {\n" % cl + decl += "public:\n" + bindings += f' py::class_("cl{cl:03}")\n' + for fn in range(nfns): + ret = random.randint(0, nclasses - 1) + params = [random.randint(0, nclasses - 1) for i in range(nargs)] + decl += f" cl{ret:03} *fn_{fn:03}(" + decl += ", ".join(f"cl{p:03} *" for p in params) + decl += ");\n" + bindings += f' .def("fn_{fn:03}", &cl{cl:03}::fn_{fn:03}, py::return_value_policy())\n' + decl += "};\n\n" + bindings += " ;\n" + + result = "#include \n\n" + result += "namespace py = boost::python;\n\n" + result += decl + "\n" + result += "BOOST_PYTHON_MODULE(example) {\n" + result += bindings + result += "}" + return result + + +for codegen in [generate_dummy_code_pybind11, generate_dummy_code_boost]: + print("{") + for i in range(0, 10): + nclasses = 2**i + with open("test.cpp", "w") as f: + f.write(codegen(nclasses)) + n1 = dt.datetime.now() + os.system( + "g++ -Os -shared -rdynamic -undefined dynamic_lookup " + "-fvisibility=hidden -std=c++14 test.cpp -I include " + "-I /System/Library/Frameworks/Python.framework/Headers -o test.so" + ) + n2 = dt.datetime.now() + elapsed = (n2 - n1).total_seconds() + size = os.stat("test.so").st_size + print(" {%i, %f, %i}," % (nclasses * nfns, elapsed, size)) + print("}") diff --git a/dmff/dpnblist/external/pybind11-2.11.1/docs/benchmark.rst b/dmff/dpnblist/external/pybind11-2.11.1/docs/benchmark.rst new file mode 100644 index 00000000..02c2ccde --- /dev/null +++ b/dmff/dpnblist/external/pybind11-2.11.1/docs/benchmark.rst @@ -0,0 +1,95 @@ +Benchmark +========= + +The following is the result of a synthetic benchmark comparing both compilation +time and module size of pybind11 against Boost.Python. A detailed report about a +Boost.Python to pybind11 conversion of a real project is available here: [#f1]_. + +.. [#f1] http://graylab.jhu.edu/RosettaCon2016/PyRosetta-4.pdf + +Setup +----- + +A python script (see the ``docs/benchmark.py`` file) was used to generate a set +of files with dummy classes whose count increases for each successive benchmark +(between 1 and 2048 classes in powers of two). Each class has four methods with +a randomly generated signature with a return value and four arguments. (There +was no particular reason for this setup other than the desire to generate many +unique function signatures whose count could be controlled in a simple way.) + +Here is an example of the binding code for one class: + +.. code-block:: cpp + + ... + class cl034 { + public: + cl279 *fn_000(cl084 *, cl057 *, cl065 *, cl042 *); + cl025 *fn_001(cl098 *, cl262 *, cl414 *, cl121 *); + cl085 *fn_002(cl445 *, cl297 *, cl145 *, cl421 *); + cl470 *fn_003(cl200 *, cl323 *, cl332 *, cl492 *); + }; + ... + + PYBIND11_MODULE(example, m) { + ... + py::class_(m, "cl034") + .def("fn_000", &cl034::fn_000) + .def("fn_001", &cl034::fn_001) + .def("fn_002", &cl034::fn_002) + .def("fn_003", &cl034::fn_003) + ... + } + +The Boost.Python version looks almost identical except that a return value +policy had to be specified as an argument to ``def()``. For both libraries, +compilation was done with + +.. code-block:: bash + + Apple LLVM version 7.0.2 (clang-700.1.81) + +and the following compilation flags + +.. code-block:: bash + + g++ -Os -shared -rdynamic -undefined dynamic_lookup -fvisibility=hidden -std=c++14 + +Compilation time +---------------- + +The following log-log plot shows how the compilation time grows for an +increasing number of class and function declarations. pybind11 includes many +fewer headers, which initially leads to shorter compilation times, but the +performance is ultimately fairly similar (pybind11 is 19.8 seconds faster for +the largest largest file with 2048 classes and a total of 8192 methods -- a +modest **1.2x** speedup relative to Boost.Python, which required 116.35 +seconds). + +.. only:: not latex + + .. image:: pybind11_vs_boost_python1.svg + +.. only:: latex + + .. image:: pybind11_vs_boost_python1.png + +Module size +----------- + +Differences between the two libraries become much more pronounced when +considering the file size of the generated Python plugin: for the largest file, +the binary generated by Boost.Python required 16.8 MiB, which was **2.17 +times** / **9.1 megabytes** larger than the output generated by pybind11. For +very small inputs, Boost.Python has an edge in the plot below -- however, note +that it stores many definitions in an external library, whose size was not +included here, hence the comparison is slightly shifted in Boost.Python's +favor. + +.. only:: not latex + + .. image:: pybind11_vs_boost_python2.svg + +.. only:: latex + + .. image:: pybind11_vs_boost_python2.png diff --git a/dmff/dpnblist/external/pybind11-2.11.1/docs/changelog.rst b/dmff/dpnblist/external/pybind11-2.11.1/docs/changelog.rst new file mode 100644 index 00000000..add3fd66 --- /dev/null +++ b/dmff/dpnblist/external/pybind11-2.11.1/docs/changelog.rst @@ -0,0 +1,2826 @@ +.. _changelog: + +Changelog +######### + +Starting with version 1.8.0, pybind11 releases use a `semantic versioning +`_ policy. + +Changes will be added here periodically from the "Suggested changelog entry" +block in pull request descriptions. + + +Version 2.11.1 (July 17, 2023) +----------------------------- + +Changes: + +* ``PYBIND11_NO_ASSERT_GIL_HELD_INCREF_DECREF`` is now provided as an option + for disabling the default-on ``PyGILState_Check()``'s in + ``pybind11::handle``'s ``inc_ref()`` & ``dec_ref()``. + `#4753 `_ + +* ``PYBIND11_ASSERT_GIL_HELD_INCREF_DECREF`` was disabled for PyPy in general + (not just PyPy Windows). + `#4751 `_ + + +Version 2.11.0 (July 14, 2023) +----------------------------- + +New features: + +* The newly added ``pybind11::detail::is_move_constructible`` trait can be + specialized for cases in which ``std::is_move_constructible`` does not work + as needed. This is very similar to the long-established + ``pybind11::detail::is_copy_constructible``. + `#4631 `_ + +* Introduce ``recursive_container_traits``. + `#4623 `_ + +* ``pybind11/type_caster_pyobject_ptr.h`` was added to support automatic + wrapping of APIs that make use of ``PyObject *``. This header needs to + included explicitly (i.e. it is not included implicitly + with ``pybind/pybind11.h``). + `#4601 `_ + +* ``format_descriptor<>`` & ``npy_format_descriptor<>`` ``PyObject *`` + specializations were added. The latter enables ``py::array_t`` + to/from-python conversions. + `#4674 `_ + +* ``buffer_info`` gained an ``item_type_is_equivalent_to()`` member + function. + `#4674 `_ + +* The ``capsule`` API gained a user-friendly constructor + (``py::capsule(ptr, "name", dtor)``). + `#4720 `_ + +Changes: + +* ``PyGILState_Check()``'s in ``pybind11::handle``'s ``inc_ref()`` & + ``dec_ref()`` are now enabled by default again. + `#4246 `_ + +* ``py::initialize_interpreter()`` using ``PyConfig_InitPythonConfig()`` + instead of ``PyConfig_InitIsolatedConfig()``, to obtain complete + ``sys.path``. + `#4473 `_ + +* Cast errors now always include Python type information, even if + ``PYBIND11_DETAILED_ERROR_MESSAGES`` is not defined. This increases binary + sizes slightly (~1.5%) but the error messages are much more informative. + `#4463 `_ + +* The docstring generation for the ``std::array``-list caster was fixed. + Previously, signatures included the size of the list in a non-standard, + non-spec compliant way. The new format conforms to PEP 593. + **Tooling for processing the docstrings may need to be updated accordingly.** + `#4679 `_ + +* Setter return values (which are inaccessible for all practical purposes) are + no longer converted to Python (only to be discarded). + `#4621 `_ + +* Allow lambda specified to function definition to be ``noexcept(true)`` + in C++17. + `#4593 `_ + +* Get rid of recursive template instantiations for concatenating type + signatures on C++17 and higher. + `#4587 `_ + +* Compatibility with Python 3.12 (beta). Note that the minimum pybind11 + ABI version for Python 3.12 is version 5. (The default ABI version + for Python versions up to and including 3.11 is still version 4.). + `#4570 `_ + +* With ``PYBIND11_INTERNALS_VERSION 5`` (default for Python 3.12+), MSVC builds + use ``std::hash`` and ``std::equal_to`` + instead of string-based type comparisons. This resolves issues when binding + types defined in the unnamed namespace. + `#4319 `_ + +* Python exception ``__notes__`` (introduced with Python 3.11) are now added to + the ``error_already_set::what()`` output. + `#4678 `_ + +Build system improvements: + +* CMake 3.27 support was added, CMake 3.4 support was dropped. + FindPython will be used if ``FindPythonInterp`` is not present. + `#4719 `_ + +* Update clang-tidy to 15 in CI. + `#4387 `_ + +* Moved the linting framework over to Ruff. + `#4483 `_ + +* Skip ``lto`` checks and target generation when + ``CMAKE_INTERPROCEDURAL_OPTIMIZATION`` is defined. + `#4643 `_ + +* No longer inject ``-stdlib=libc++``, not needed for modern Pythons + (macOS 10.9+). + `#4639 `_ + +* PyPy 3.10 support was added, PyPy 3.7 support was dropped. + `#4728 `_ + +* Testing with Python 3.12 beta releases was added. + `#4713 `_ + + +Version 2.10.4 (Mar 16, 2023) +----------------------------- + +Changes: + +* ``python3 -m pybind11`` gained a ``--version`` option (prints the version and + exits). + `#4526 `_ + +Bug Fixes: + +* Fix a warning when pydebug is enabled on Python 3.11. + `#4461 `_ + +* Ensure ``gil_scoped_release`` RAII is non-copyable. + `#4490 `_ + +* Ensure the tests dir does not show up with new versions of setuptools. + `#4510 `_ + +* Better stacklevel for a warning in setuptools helpers. + `#4516 `_ + +Version 2.10.3 (Jan 3, 2023) +---------------------------- + +Changes: + +* Temporarily made our GIL status assertions (added in 2.10.2) disabled by + default (re-enable manually by defining + ``PYBIND11_ASSERT_GIL_HELD_INCREF_DECREF``, will be enabled in 2.11). + `#4432 `_ + +* Improved error messages when ``inc_ref``/``dec_ref`` are called with an + invalid GIL state. + `#4427 `_ + `#4436 `_ + +Bug Fixes: + +* Some minor touchups found by static analyzers. + `#4440 `_ + + +Version 2.10.2 (Dec 20, 2022) +----------------------------- + +Changes: + +* ``scoped_interpreter`` constructor taking ``PyConfig``. + `#4330 `_ + +* ``pybind11/eigen/tensor.h`` adds converters to and from ``Eigen::Tensor`` and + ``Eigen::TensorMap``. + `#4201 `_ + +* ``PyGILState_Check()``'s were integrated to ``pybind11::handle`` + ``inc_ref()`` & ``dec_ref()``. The added GIL checks are guarded by + ``PYBIND11_ASSERT_GIL_HELD_INCREF_DECREF``, which is the default only if + ``NDEBUG`` is not defined. (Made non-default in 2.10.3, will be active in 2.11) + `#4246 `_ + +* Add option for enable/disable enum members in docstring. + `#2768 `_ + +* Fixed typing of ``KeysView``, ``ValuesView`` and ``ItemsView`` in ``bind_map``. + `#4353 `_ + +Bug fixes: + +* Bug fix affecting only Python 3.6 under very specific, uncommon conditions: + move ``PyEval_InitThreads()`` call to the correct location. + `#4350 `_ + +* Fix segfault bug when passing foreign native functions to functional.h. + `#4254 `_ + +Build system improvements: + +* Support setting PYTHON_LIBRARIES manually for Windows ARM cross-compilation + (classic mode). + `#4406 `_ + +* Extend IPO/LTO detection for ICX (a.k.a IntelLLVM) compiler. + `#4402 `_ + +* Allow calling ``find_package(pybind11 CONFIG)`` multiple times from separate + directories in the same CMake project and properly link Python (new mode). + `#4401 `_ + +* ``multiprocessing_set_spawn`` in pytest fixture for added safety. + `#4377 `_ + +* Fixed a bug in two pybind11/tools cmake scripts causing "Unknown arguments specified" errors. + `#4327 `_ + + + +Version 2.10.1 (Oct 31, 2022) +----------------------------- + +This is the first version to fully support embedding the newly released Python 3.11. + +Changes: + +* Allow ``pybind11::capsule`` constructor to take null destructor pointers. + `#4221 `_ + +* ``embed.h`` was changed so that ``PYTHONPATH`` is used also with Python 3.11 + (established behavior). + `#4119 `_ + +* A ``PYBIND11_SIMPLE_GIL_MANAGEMENT`` option was added (cmake, C++ define), + along with many additional tests in ``test_gil_scoped.py``. The option may be + useful to try when debugging GIL-related issues, to determine if the more + complex default implementation is or is not to blame. See #4216 for + background. WARNING: Please be careful to not create ODR violations when + using the option: everything that is linked together with mutual symbol + visibility needs to be rebuilt. + `#4216 `_ + +* ``PYBIND11_EXPORT_EXCEPTION`` was made non-empty only under macOS. This makes + Linux builds safer, and enables the removal of warning suppression pragmas for + Windows. + `#4298 `_ + +Bug fixes: + +* Fixed a bug where ``UnicodeDecodeError`` was not propagated from various + ``py::str`` ctors when decoding surrogate utf characters. + `#4294 `_ + +* Revert perfect forwarding for ``make_iterator``. This broke at least one + valid use case. May revisit later. + `#4234 `_ + +* Fix support for safe casts to ``void*`` (regression in 2.10.0). + `#4275 `_ + +* Fix ``char8_t`` support (regression in 2.9). + `#4278 `_ + +* Unicode surrogate character in Python exception message leads to process + termination in ``error_already_set::what()``. + `#4297 `_ + +* Fix MSVC 2019 v.1924 & C++14 mode error for ``overload_cast``. + `#4188 `_ + +* Make augmented assignment operators non-const for the object-api. Behavior + was previously broken for augmented assignment operators. + `#4065 `_ + +* Add proper error checking to C++ bindings for Python list append and insert. + `#4208 `_ + +* Work-around for Nvidia's CUDA nvcc compiler in versions 11.4.0 - 11.8.0. + `#4220 `_ + +* A workaround for PyPy was added in the ``py::error_already_set`` + implementation, related to PR `#1895 `_ + released with v2.10.0. + `#4079 `_ + +* Fixed compiler errors when C++23 ``std::forward_like`` is available. + `#4136 `_ + +* Properly raise exceptions in contains methods (like when an object in unhashable). + `#4209 `_ + +* Further improve another error in exception handling. + `#4232 `_ + +* ``get_local_internals()`` was made compatible with + ``finalize_interpreter()``, fixing potential freezes during interpreter + finalization. + `#4192 `_ + +Performance and style: + +* Reserve space in set and STL map casters if possible. This will prevent + unnecessary rehashing / resizing by knowing the number of keys ahead of time + for Python to C++ casting. This improvement will greatly speed up the casting + of large unordered maps and sets. + `#4194 `_ + +* GIL RAII scopes are non-copyable to avoid potential bugs. + `#4183 `_ + +* Explicitly default all relevant ctors for pytypes in the ``PYBIND11_OBJECT`` + macros and enforce the clang-tidy checks ``modernize-use-equals-default`` in + macros as well. + `#4017 `_ + +* Optimize iterator advancement in C++ bindings. + `#4237 `_ + +* Use the modern ``PyObject_GenericGetDict`` and ``PyObject_GenericSetDict`` + for handling dynamic attribute dictionaries. + `#4106 `_ + +* Document that users should use ``PYBIND11_NAMESPACE`` instead of using ``pybind11`` when + opening namespaces. Using namespace declarations and namespace qualification + remain the same as ``pybind11``. This is done to ensure consistent symbol + visibility. + `#4098 `_ + +* Mark ``detail::forward_like`` as constexpr. + `#4147 `_ + +* Optimize unpacking_collector when processing ``arg_v`` arguments. + `#4219 `_ + +* Optimize casting C++ object to ``None``. + `#4269 `_ + + +Build system improvements: + +* CMake: revert overwrite behavior, now opt-in with ``PYBIND11_PYTHONLIBS_OVERRWRITE OFF``. + `#4195 `_ + +* Include a pkg-config file when installing pybind11, such as in the Python + package. + `#4077 `_ + +* Avoid stripping debug symbols when ``CMAKE_BUILD_TYPE`` is set to ``DEBUG`` + instead of ``Debug``. + `#4078 `_ + +* Followup to `#3948 `_, fixing vcpkg again. + `#4123 `_ + +Version 2.10.0 (Jul 15, 2022) +----------------------------- + +Removed support for Python 2.7, Python 3.5, and MSVC 2015. Support for MSVC +2017 is limited due to availability of CI runners; we highly recommend MSVC +2019 or 2022 be used. Initial support added for Python 3.11. + +New features: + +* ``py::anyset`` & ``py::frozenset`` were added, with copying (cast) to + ``std::set`` (similar to ``set``). + `#3901 `_ + +* Support bytearray casting to string. + `#3707 `_ + +* ``type_caster`` was added. ``std::monostate`` is a tag type + that allows ``std::variant`` to act as an optional, or allows default + construction of a ``std::variant`` holding a non-default constructible type. + `#3818 `_ + +* ``pybind11::capsule::set_name`` added to mutate the name of the capsule instance. + `#3866 `_ + +* NumPy: dtype constructor from type number added, accessors corresponding to + Python API ``dtype.num``, ``dtype.byteorder``, ``dtype.flags`` and + ``dtype.alignment`` added. + `#3868 `_ + + +Changes: + +* Python 3.6 is now the minimum supported version. + `#3688 `_ + `#3719 `_ + +* The minimum version for MSVC is now 2017. + `#3722 `_ + +* Fix issues with CPython 3.11 betas and add to supported test matrix. + `#3923 `_ + +* ``error_already_set`` is now safer and more performant, especially for + exceptions with long tracebacks, by delaying computation. + `#1895 `_ + +* Improve exception handling in python ``str`` bindings. + `#3826 `_ + +* The bindings for capsules now have more consistent exception handling. + `#3825 `_ + +* ``PYBIND11_OBJECT_CVT`` and ``PYBIND11_OBJECT_CVT_DEFAULT`` macro can now be + used to define classes in namespaces other than pybind11. + `#3797 `_ + +* Error printing code now uses ``PYBIND11_DETAILED_ERROR_MESSAGES`` instead of + requiring ``NDEBUG``, allowing use with release builds if desired. + `#3913 `_ + +* Implicit conversion of the literal ``0`` to ``pybind11::handle`` is now disabled. + `#4008 `_ + + +Bug fixes: + +* Fix exception handling when ``pybind11::weakref()`` fails. + `#3739 `_ + +* ``module_::def_submodule`` was missing proper error handling. This is fixed now. + `#3973 `_ + +* The behavior or ``error_already_set`` was made safer and the highly opaque + "Unknown internal error occurred" message was replaced with a more helpful + message. + `#3982 `_ + +* ``error_already_set::what()`` now handles non-normalized exceptions correctly. + `#3971 `_ + +* Support older C++ compilers where filesystem is not yet part of the standard + library and is instead included in ``std::experimental::filesystem``. + `#3840 `_ + +* Fix ``-Wfree-nonheap-object`` warnings produced by GCC by avoiding returning + pointers to static objects with ``return_value_policy::take_ownership``. + `#3946 `_ + +* Fix cast from pytype rvalue to another pytype. + `#3949 `_ + +* Ensure proper behavior when garbage collecting classes with dynamic attributes in Python >=3.9. + `#4051 `_ + +* A couple long-standing ``PYBIND11_NAMESPACE`` + ``__attribute__((visibility("hidden")))`` inconsistencies are now fixed + (affects only unusual environments). + `#4043 `_ + +* ``pybind11::detail::get_internals()`` is now resilient to in-flight Python + exceptions. + `#3981 `_ + +* Arrays with a dimension of size 0 are now properly converted to dynamic Eigen + matrices (more common in NumPy 1.23). + `#4038 `_ + +* Avoid catching unrelated errors when importing NumPy. + `#3974 `_ + +Performance and style: + +* Added an accessor overload of ``(object &&key)`` to reference steal the + object when using python types as keys. This prevents unnecessary reference + count overhead for attr, dictionary, tuple, and sequence look ups. Added + additional regression tests. Fixed a performance bug the caused accessor + assignments to potentially perform unnecessary copies. + `#3970 `_ + +* Perfect forward all args of ``make_iterator``. + `#3980 `_ + +* Avoid potential bug in pycapsule destructor by adding an ``error_guard`` to + one of the dtors. + `#3958 `_ + +* Optimize dictionary access in ``strip_padding`` for numpy. + `#3994 `_ + +* ``stl_bind.h`` bindings now take slice args as a const-ref. + `#3852 `_ + +* Made slice constructor more consistent, and improve performance of some + casters by allowing reference stealing. + `#3845 `_ + +* Change numpy dtype from_args method to use const ref. + `#3878 `_ + +* Follow rule of three to ensure ``PyErr_Restore`` is called only once. + `#3872 `_ + +* Added missing perfect forwarding for ``make_iterator`` functions. + `#3860 `_ + +* Optimize c++ to python function casting by using the rvalue caster. + `#3966 `_ + +* Optimize Eigen sparse matrix casting by removing unnecessary temporary. + `#4064 `_ + +* Avoid potential implicit copy/assignment constructors causing double free in + ``strdup_gaurd``. + `#3905 `_ + +* Enable clang-tidy checks ``misc-definitions-in-headers``, + ``modernize-loop-convert``, and ``modernize-use-nullptr``. + `#3881 `_ + `#3988 `_ + + +Build system improvements: + +* CMake: Fix file extension on Windows with cp36 and cp37 using FindPython. + `#3919 `_ + +* CMake: Support multiple Python targets (such as on vcpkg). + `#3948 `_ + +* CMake: Fix issue with NVCC on Windows. + `#3947 `_ + +* CMake: Drop the bitness check on cross compiles (like targeting WebAssembly + via Emscripten). + `#3959 `_ + +* Add MSVC builds in debug mode to CI. + `#3784 `_ + +* MSVC 2022 C++20 coverage was added to GitHub Actions, including Eigen. + `#3732 `_, + `#3741 `_ + + +Backend and tidying up: + +* New theme for the documentation. + `#3109 `_ + +* Remove idioms in code comments. Use more inclusive language. + `#3809 `_ + +* ``#include `` was removed from the ``pybind11/stl.h`` header. Your + project may break if it has a transitive dependency on this include. The fix + is to "Include What You Use". + `#3928 `_ + +* Avoid ``setup.py `` usage in internal tests. + `#3734 `_ + + +Version 2.9.2 (Mar 29, 2022) +---------------------------- + +Changes: + +* Enum now has an ``__index__`` method on Python <3.8 too. + `#3700 `_ + +* Local internals are now cleared after finalizing the interpreter. + `#3744 `_ + +Bug fixes: + +* Better support for Python 3.11 alphas. + `#3694 `_ + +* ``PYBIND11_TYPE_CASTER`` now uses fully qualified symbols, so it can be used + outside of ``pybind11::detail``. + `#3758 `_ + +* Some fixes for PyPy 3.9. + `#3768 `_ + +* Fixed a potential memleak in PyPy in ``get_type_override``. + `#3774 `_ + +* Fix usage of ``VISIBILITY_INLINES_HIDDEN``. + `#3721 `_ + + +Build system improvements: + +* Uses ``sysconfig`` module to determine installation locations on Python >= + 3.10, instead of ``distutils`` which has been deprecated. + `#3764 `_ + +* Support Catch 2.13.5+ (supporting GLIBC 2.34+). + `#3679 `_ + +* Fix test failures with numpy 1.22 by ignoring whitespace when comparing + ``str()`` of dtypes. + `#3682 `_ + + +Backend and tidying up: + +* clang-tidy: added ``readability-qualified-auto``, + ``readability-braces-around-statements``, + ``cppcoreguidelines-prefer-member-initializer``, + ``clang-analyzer-optin.performance.Padding``, + ``cppcoreguidelines-pro-type-static-cast-downcast``, and + ``readability-inconsistent-declaration-parameter-name``. + `#3702 `_, + `#3699 `_, + `#3716 `_, + `#3709 `_ + +* clang-format was added to the pre-commit actions, and the entire code base + automatically reformatted (after several iterations preparing for this leap). + `#3713 `_ + + +Version 2.9.1 (Feb 2, 2022) +--------------------------- + +Changes: + +* If possible, attach Python exception with ``py::raise_from`` to ``TypeError`` + when casting from C++ to Python. This will give additional info if Python + exceptions occur in the caster. Adds a test case of trying to convert a set + from C++ to Python when the hash function is not defined in Python. + `#3605 `_ + +* Add a mapping of C++11 nested exceptions to their Python exception + equivalent using ``py::raise_from``. This attaches the nested exceptions in + Python using the ``__cause__`` field. + `#3608 `_ + +* Propagate Python exception traceback using ``raise_from`` if a pybind11 + function runs out of overloads. + `#3671 `_ + +* ``py::multiple_inheritance`` is now only needed when C++ bases are hidden + from pybind11. + `#3650 `_ and + `#3659 `_ + + +Bug fixes: + +* Remove a boolean cast in ``numpy.h`` that causes MSVC C4800 warnings when + compiling against Python 3.10 or newer. + `#3669 `_ + +* Render ``py::bool_`` and ``py::float_`` as ``bool`` and ``float`` + respectively. + `#3622 `_ + +Build system improvements: + +* Fix CMake extension suffix computation on Python 3.10+. + `#3663 `_ + +* Allow ``CMAKE_ARGS`` to override CMake args in pybind11's own ``setup.py``. + `#3577 `_ + +* Remove a few deprecated c-headers. + `#3610 `_ + +* More uniform handling of test targets. + `#3590 `_ + +* Add clang-tidy readability check to catch potentially swapped function args. + `#3611 `_ + + +Version 2.9.0 (Dec 28, 2021) +---------------------------- + +This is the last version to support Python 2.7 and 3.5. + +New Features: + +* Allow ``py::args`` to be followed by other arguments; the remaining arguments + are implicitly keyword-only, as if a ``py::kw_only{}`` annotation had been + used. + `#3402 `_ + +Changes: + +* Make str/bytes/memoryview more interoperable with ``std::string_view``. + `#3521 `_ + +* Replace ``_`` with ``const_name`` in internals, avoid defining ``pybind::_`` + if ``_`` defined as macro (common gettext usage) + `#3423 `_ + + +Bug fixes: + +* Fix a rare warning about extra copy in an Eigen constructor. + `#3486 `_ + +* Fix caching of the C++ overrides. + `#3465 `_ + +* Add missing ``std::forward`` calls to some ``cpp_function`` overloads. + `#3443 `_ + +* Support PyPy 7.3.7 and the PyPy3.8 beta. Test python-3.11 on PRs with the + ``python dev`` label. + `#3419 `_ + +* Replace usage of deprecated ``Eigen::MappedSparseMatrix`` with + ``Eigen::Map>`` for Eigen 3.3+. + `#3499 `_ + +* Tweaks to support Microsoft Visual Studio 2022. + `#3497 `_ + +Build system improvements: + +* Nicer CMake printout and IDE organisation for pybind11's own tests. + `#3479 `_ + +* CMake: report version type as part of the version string to avoid a spurious + space in the package status message. + `#3472 `_ + +* Flags starting with ``-g`` in ``$CFLAGS`` and ``$CPPFLAGS`` are no longer + overridden by ``.Pybind11Extension``. + `#3436 `_ + +* Ensure ThreadPool is closed in ``setup_helpers``. + `#3548 `_ + +* Avoid LTS on ``mips64`` and ``ppc64le`` (reported broken). + `#3557 `_ + + +v2.8.1 (Oct 27, 2021) +--------------------- + +Changes and additions: + +* The simple namespace creation shortcut added in 2.8.0 was deprecated due to + usage of CPython internal API, and will be removed soon. Use + ``py::module_::import("types").attr("SimpleNamespace")``. + `#3374 `_ + +* Add C++ Exception type to throw and catch ``AttributeError``. Useful for + defining custom ``__setattr__`` and ``__getattr__`` methods. + `#3387 `_ + +Fixes: + +* Fixed the potential for dangling references when using properties with + ``std::optional`` types. + `#3376 `_ + +* Modernize usage of ``PyCodeObject`` on Python 3.9+ (moving toward support for + Python 3.11a1) + `#3368 `_ + +* A long-standing bug in ``eigen.h`` was fixed (originally PR #3343). The bug + was unmasked by newly added ``static_assert``'s in the Eigen 3.4.0 release. + `#3352 `_ + +* Support multiple raw inclusion of CMake helper files (Conan.io does this for + multi-config generators). + `#3420 `_ + +* Fix harmless warning on upcoming CMake 3.22. + `#3368 `_ + +* Fix 2.8.0 regression with MSVC 2017 + C++17 mode + Python 3. + `#3407 `_ + +* Fix 2.8.0 regression that caused undefined behavior (typically + segfaults) in ``make_key_iterator``/``make_value_iterator`` if dereferencing + the iterator returned a temporary value instead of a reference. + `#3348 `_ + + +v2.8.0 (Oct 4, 2021) +-------------------- + +New features: + +* Added ``py::raise_from`` to enable chaining exceptions. + `#3215 `_ + +* Allow exception translators to be optionally registered local to a module + instead of applying globally across all pybind11 modules. Use + ``register_local_exception_translator(ExceptionTranslator&& translator)`` + instead of ``register_exception_translator(ExceptionTranslator&& + translator)`` to keep your exception remapping code local to the module. + `#2650 `_ + +* Add ``make_simple_namespace`` function for instantiating Python + ``SimpleNamespace`` objects. **Deprecated in 2.8.1.** + `#2840 `_ + +* ``pybind11::scoped_interpreter`` and ``initialize_interpreter`` have new + arguments to allow ``sys.argv`` initialization. + `#2341 `_ + +* Allow Python builtins to be used as callbacks in CPython. + `#1413 `_ + +* Added ``view`` to view arrays with a different datatype. + `#987 `_ + +* Implemented ``reshape`` on arrays. + `#984 `_ + +* Enable defining custom ``__new__`` methods on classes by fixing bug + preventing overriding methods if they have non-pybind11 siblings. + `#3265 `_ + +* Add ``make_value_iterator()``, and fix ``make_key_iterator()`` to return + references instead of copies. + `#3293 `_ + +* Improve the classes generated by ``bind_map``: `#3310 `_ + + * Change ``.items`` from an iterator to a dictionary view. + * Add ``.keys`` and ``.values`` (both dictionary views). + * Allow ``__contains__`` to take any object. + +* ``pybind11::custom_type_setup`` was added, for customizing the + ``PyHeapTypeObject`` corresponding to a class, which may be useful for + enabling garbage collection support, among other things. + `#3287 `_ + + +Changes: + +* Set ``__file__`` constant when running ``eval_file`` in an embedded interpreter. + `#3233 `_ + +* Python objects and (C++17) ``std::optional`` now accepted in ``py::slice`` + constructor. + `#1101 `_ + +* The pybind11 proxy types ``str``, ``bytes``, ``bytearray``, ``tuple``, + ``list`` now consistently support passing ``ssize_t`` values for sizes and + indexes. Previously, only ``size_t`` was accepted in several interfaces. + `#3219 `_ + +* Avoid evaluating ``PYBIND11_TLS_REPLACE_VALUE`` arguments more than once. + `#3290 `_ + +Fixes: + +* Bug fix: enum value's ``__int__`` returning non-int when underlying type is + bool or of char type. + `#1334 `_ + +* Fixes bug in setting error state in Capsule's pointer methods. + `#3261 `_ + +* A long-standing memory leak in ``py::cpp_function::initialize`` was fixed. + `#3229 `_ + +* Fixes thread safety for some ``pybind11::type_caster`` which require lifetime + extension, such as for ``std::string_view``. + `#3237 `_ + +* Restore compatibility with gcc 4.8.4 as distributed by ubuntu-trusty, linuxmint-17. + `#3270 `_ + + +Build system improvements: + +* Fix regression in CMake Python package config: improper use of absolute path. + `#3144 `_ + +* Cached Python version information could become stale when CMake was re-run + with a different Python version. The build system now detects this and + updates this information. + `#3299 `_ + +* Specified UTF8-encoding in setup.py calls of open(). + `#3137 `_ + +* Fix a harmless warning from CMake 3.21 with the classic Python discovery. + `#3220 `_ + +* Eigen repo and version can now be specified as cmake options. + `#3324 `_ + + +Backend and tidying up: + +* Reduced thread-local storage required for keeping alive temporary data for + type conversion to one key per ABI version, rather than one key per extension + module. This makes the total thread-local storage required by pybind11 2 + keys per ABI version. + `#3275 `_ + +* Optimize NumPy array construction with additional moves. + `#3183 `_ + +* Conversion to ``std::string`` and ``std::string_view`` now avoids making an + extra copy of the data on Python >= 3.3. + `#3257 `_ + +* Remove const modifier from certain C++ methods on Python collections + (``list``, ``set``, ``dict``) such as (``clear()``, ``append()``, + ``insert()``, etc...) and annotated them with ``py-non-const``. + +* Enable readability ``clang-tidy-const-return`` and remove useless consts. + `#3254 `_ + `#3194 `_ + +* The clang-tidy ``google-explicit-constructor`` option was enabled. + `#3250 `_ + +* Mark a pytype move constructor as noexcept (perf). + `#3236 `_ + +* Enable clang-tidy check to guard against inheritance slicing. + `#3210 `_ + +* Legacy warning suppression pragma were removed from eigen.h. On Unix + platforms, please use -isystem for Eigen include directories, to suppress + compiler warnings originating from Eigen headers. Note that CMake does this + by default. No adjustments are needed for Windows. + `#3198 `_ + +* Format pybind11 with isort consistent ordering of imports + `#3195 `_ + +* The warnings-suppression "pragma clamp" at the top/bottom of pybind11 was + removed, clearing the path to refactoring and IWYU cleanup. + `#3186 `_ + +* Enable most bugprone checks in clang-tidy and fix the found potential bugs + and poor coding styles. + `#3166 `_ + +* Add ``clang-tidy-readability`` rules to make boolean casts explicit improving + code readability. Also enabled other misc and readability clang-tidy checks. + `#3148 `_ + +* Move object in ``.pop()`` for list. + `#3116 `_ + + + + +v2.7.1 (Aug 3, 2021) +--------------------- + +Minor missing functionality added: + +* Allow Python builtins to be used as callbacks in CPython. + `#1413 `_ + +Bug fixes: + +* Fix regression in CMake Python package config: improper use of absolute path. + `#3144 `_ + +* Fix Mingw64 and add to the CI testing matrix. + `#3132 `_ + +* Specified UTF8-encoding in setup.py calls of open(). + `#3137 `_ + +* Add clang-tidy-readability rules to make boolean casts explicit improving + code readability. Also enabled other misc and readability clang-tidy checks. + `#3148 `_ + +* Move object in ``.pop()`` for list. + `#3116 `_ + +Backend and tidying up: + +* Removed and fixed warning suppressions. + `#3127 `_ + `#3129 `_ + `#3135 `_ + `#3141 `_ + `#3142 `_ + `#3150 `_ + `#3152 `_ + `#3160 `_ + `#3161 `_ + + +v2.7.0 (Jul 16, 2021) +--------------------- + +New features: + +* Enable ``py::implicitly_convertible`` for + ``py::class_``-wrapped types. + `#3059 `_ + +* Allow function pointer extraction from overloaded functions. + `#2944 `_ + +* NumPy: added ``.char_()`` to type which gives the NumPy public ``char`` + result, which also distinguishes types by bit length (unlike ``.kind()``). + `#2864 `_ + +* Add ``pybind11::bytearray`` to manipulate ``bytearray`` similar to ``bytes``. + `#2799 `_ + +* ``pybind11/stl/filesystem.h`` registers a type caster that, on C++17/Python + 3.6+, converts ``std::filesystem::path`` to ``pathlib.Path`` and any + ``os.PathLike`` to ``std::filesystem::path``. + `#2730 `_ + +* A ``PYBIND11_VERSION_HEX`` define was added, similar to ``PY_VERSION_HEX``. + `#3120 `_ + + + +Changes: + +* ``py::str`` changed to exclusively hold ``PyUnicodeObject``. Previously + ``py::str`` could also hold ``bytes``, which is probably surprising, was + never documented, and can mask bugs (e.g. accidental use of ``py::str`` + instead of ``py::bytes``). + `#2409 `_ + +* Add a safety guard to ensure that the Python GIL is held when C++ calls back + into Python via ``object_api<>::operator()`` (e.g. ``py::function`` + ``__call__``). (This feature is available for Python 3.6+ only.) + `#2919 `_ + +* Catch a missing ``self`` argument in calls to ``__init__()``. + `#2914 `_ + +* Use ``std::string_view`` if available to avoid a copy when passing an object + to a ``std::ostream``. + `#3042 `_ + +* An important warning about thread safety was added to the ``iostream.h`` + documentation; attempts to make ``py::scoped_ostream_redirect`` thread safe + have been removed, as it was only partially effective. + `#2995 `_ + + +Fixes: + +* Performance: avoid unnecessary strlen calls. + `#3058 `_ + +* Fix auto-generated documentation string when using ``const T`` in + ``pyarray_t``. + `#3020 `_ + +* Unify error messages thrown by ``simple_collector``/``unpacking_collector``. + `#3013 `_ + +* ``pybind11::builtin_exception`` is now explicitly exported, which means the + types included/defined in different modules are identical, and exceptions + raised in different modules can be caught correctly. The documentation was + updated to explain that custom exceptions that are used across module + boundaries need to be explicitly exported as well. + `#2999 `_ + +* Fixed exception when printing UTF-8 to a ``scoped_ostream_redirect``. + `#2982 `_ + +* Pickle support enhancement: ``setstate`` implementation will attempt to + ``setattr`` ``__dict__`` only if the unpickled ``dict`` object is not empty, + to not force use of ``py::dynamic_attr()`` unnecessarily. + `#2972 `_ + +* Allow negative timedelta values to roundtrip. + `#2870 `_ + +* Fix unchecked errors could potentially swallow signals/other exceptions. + `#2863 `_ + +* Add null pointer check with ``std::localtime``. + `#2846 `_ + +* Fix the ``weakref`` constructor from ``py::object`` to create a new + ``weakref`` on conversion. + `#2832 `_ + +* Avoid relying on exceptions in C++17 when getting a ``shared_ptr`` holder + from a ``shared_from_this`` class. + `#2819 `_ + +* Allow the codec's exception to be raised instead of :code:`RuntimeError` when + casting from :code:`py::str` to :code:`std::string`. + `#2903 `_ + + +Build system improvements: + +* In ``setup_helpers.py``, test for platforms that have some multiprocessing + features but lack semaphores, which ``ParallelCompile`` requires. + `#3043 `_ + +* Fix ``pybind11_INCLUDE_DIR`` in case ``CMAKE_INSTALL_INCLUDEDIR`` is + absolute. + `#3005 `_ + +* Fix bug not respecting ``WITH_SOABI`` or ``WITHOUT_SOABI`` to CMake. + `#2938 `_ + +* Fix the default ``Pybind11Extension`` compilation flags with a Mingw64 python. + `#2921 `_ + +* Clang on Windows: do not pass ``/MP`` (ignored flag). + `#2824 `_ + +* ``pybind11.setup_helpers.intree_extensions`` can be used to generate + ``Pybind11Extension`` instances from cpp files placed in the Python package + source tree. + `#2831 `_ + +Backend and tidying up: + +* Enable clang-tidy performance, readability, and modernization checks + throughout the codebase to enforce best coding practices. + `#3046 `_, + `#3049 `_, + `#3051 `_, + `#3052 `_, + `#3080 `_, and + `#3094 `_ + + +* Checks for common misspellings were added to the pre-commit hooks. + `#3076 `_ + +* Changed ``Werror`` to stricter ``Werror-all`` for Intel compiler and fixed + minor issues. + `#2948 `_ + +* Fixed compilation with GCC < 5 when the user defines ``_GLIBCXX_USE_CXX11_ABI``. + `#2956 `_ + +* Added nox support for easier local testing and linting of contributions. + `#3101 `_ and + `#3121 `_ + +* Avoid RTD style issue with docutils 0.17+. + `#3119 `_ + +* Support pipx run, such as ``pipx run pybind11 --include`` for a quick compile. + `#3117 `_ + + + +v2.6.2 (Jan 26, 2021) +--------------------- + +Minor missing functionality added: + +* enum: add missing Enum.value property. + `#2739 `_ + +* Allow thread termination to be avoided during shutdown for CPython 3.7+ via + ``.disarm`` for ``gil_scoped_acquire``/``gil_scoped_release``. + `#2657 `_ + +Fixed or improved behavior in a few special cases: + +* Fix bug where the constructor of ``object`` subclasses would not throw on + being passed a Python object of the wrong type. + `#2701 `_ + +* The ``type_caster`` for integers does not convert Python objects with + ``__int__`` anymore with ``noconvert`` or during the first round of trying + overloads. + `#2698 `_ + +* When casting to a C++ integer, ``__index__`` is always called and not + considered as conversion, consistent with Python 3.8+. + `#2801 `_ + +Build improvements: + +* Setup helpers: ``extra_compile_args`` and ``extra_link_args`` automatically set by + Pybind11Extension are now prepended, which allows them to be overridden + by user-set ``extra_compile_args`` and ``extra_link_args``. + `#2808 `_ + +* Setup helpers: Don't trigger unused parameter warning. + `#2735 `_ + +* CMake: Support running with ``--warn-uninitialized`` active. + `#2806 `_ + +* CMake: Avoid error if included from two submodule directories. + `#2804 `_ + +* CMake: Fix ``STATIC`` / ``SHARED`` being ignored in FindPython mode. + `#2796 `_ + +* CMake: Respect the setting for ``CMAKE_CXX_VISIBILITY_PRESET`` if defined. + `#2793 `_ + +* CMake: Fix issue with FindPython2/FindPython3 not working with ``pybind11::embed``. + `#2662 `_ + +* CMake: mixing local and installed pybind11's would prioritize the installed + one over the local one (regression in 2.6.0). + `#2716 `_ + + +Bug fixes: + +* Fixed segfault in multithreaded environments when using + ``scoped_ostream_redirect``. + `#2675 `_ + +* Leave docstring unset when all docstring-related options are disabled, rather + than set an empty string. + `#2745 `_ + +* The module key in builtins that pybind11 uses to store its internals changed + from std::string to a python str type (more natural on Python 2, no change on + Python 3). + `#2814 `_ + +* Fixed assertion error related to unhandled (later overwritten) exception in + CPython 3.8 and 3.9 debug builds. + `#2685 `_ + +* Fix ``py::gil_scoped_acquire`` assert with CPython 3.9 debug build. + `#2683 `_ + +* Fix issue with a test failing on pytest 6.2. + `#2741 `_ + +Warning fixes: + +* Fix warning modifying constructor parameter 'flag' that shadows a field of + 'set_flag' ``[-Wshadow-field-in-constructor-modified]``. + `#2780 `_ + +* Suppressed some deprecation warnings about old-style + ``__init__``/``__setstate__`` in the tests. + `#2759 `_ + +Valgrind work: + +* Fix invalid access when calling a pybind11 ``__init__`` on a non-pybind11 + class instance. + `#2755 `_ + +* Fixed various minor memory leaks in pybind11's test suite. + `#2758 `_ + +* Resolved memory leak in cpp_function initialization when exceptions occurred. + `#2756 `_ + +* Added a Valgrind build, checking for leaks and memory-related UB, to CI. + `#2746 `_ + +Compiler support: + +* Intel compiler was not activating C++14 support due to a broken define. + `#2679 `_ + +* Support ICC and NVIDIA HPC SDK in C++17 mode. + `#2729 `_ + +* Support Intel OneAPI compiler (ICC 20.2) and add to CI. + `#2573 `_ + + + +v2.6.1 (Nov 11, 2020) +--------------------- + +* ``py::exec``, ``py::eval``, and ``py::eval_file`` now add the builtins module + as ``"__builtins__"`` to their ``globals`` argument, better matching ``exec`` + and ``eval`` in pure Python. + `#2616 `_ + +* ``setup_helpers`` will no longer set a minimum macOS version higher than the + current version. + `#2622 `_ + +* Allow deleting static properties. + `#2629 `_ + +* Seal a leak in ``def_buffer``, cleaning up the ``capture`` object after the + ``class_`` object goes out of scope. + `#2634 `_ + +* ``pybind11_INCLUDE_DIRS`` was incorrect, potentially causing a regression if + it was expected to include ``PYTHON_INCLUDE_DIRS`` (please use targets + instead). + `#2636 `_ + +* Added parameter names to the ``py::enum_`` constructor and methods, avoiding + ``arg0`` in the generated docstrings. + `#2637 `_ + +* Added ``needs_recompile`` optional function to the ``ParallelCompiler`` + helper, to allow a recompile to be skipped based on a user-defined function. + `#2643 `_ + + +v2.6.0 (Oct 21, 2020) +--------------------- + +See :ref:`upgrade-guide-2.6` for help upgrading to the new version. + +New features: + +* Keyword-only arguments supported in Python 2 or 3 with ``py::kw_only()``. + `#2100 `_ + +* Positional-only arguments supported in Python 2 or 3 with ``py::pos_only()``. + `#2459 `_ + +* ``py::is_final()`` class modifier to block subclassing (CPython only). + `#2151 `_ + +* Added ``py::prepend()``, allowing a function to be placed at the beginning of + the overload chain. + `#1131 `_ + +* Access to the type object now provided with ``py::type::of()`` and + ``py::type::of(h)``. + `#2364 `_ + +* Perfect forwarding support for methods. + `#2048 `_ + +* Added ``py::error_already_set::discard_as_unraisable()``. + `#2372 `_ + +* ``py::hash`` is now public. + `#2217 `_ + +* ``py::class_`` is now supported. Note that writing to one data + member of the union and reading another (type punning) is UB in C++. Thus + pybind11-bound enums should never be used for such conversions. + `#2320 `_. + +* Classes now check local scope when registering members, allowing a subclass + to have a member with the same name as a parent (such as an enum). + `#2335 `_ + +Code correctness features: + +* Error now thrown when ``__init__`` is forgotten on subclasses. + `#2152 `_ + +* Throw error if conversion to a pybind11 type if the Python object isn't a + valid instance of that type, such as ``py::bytes(o)`` when ``py::object o`` + isn't a bytes instance. + `#2349 `_ + +* Throw if conversion to ``str`` fails. + `#2477 `_ + + +API changes: + +* ``py::module`` was renamed ``py::module_`` to avoid issues with C++20 when + used unqualified, but an alias ``py::module`` is provided for backward + compatibility. + `#2489 `_ + +* Public constructors for ``py::module_`` have been deprecated; please use + ``pybind11::module_::create_extension_module`` if you were using the public + constructor (fairly rare after ``PYBIND11_MODULE`` was introduced). + `#2552 `_ + +* ``PYBIND11_OVERLOAD*`` macros and ``get_overload`` function replaced by + correctly-named ``PYBIND11_OVERRIDE*`` and ``get_override``, fixing + inconsistencies in the presence of a closing ``;`` in these macros. + ``get_type_overload`` is deprecated. + `#2325 `_ + +Packaging / building improvements: + +* The Python package was reworked to be more powerful and useful. + `#2433 `_ + + * :ref:`build-setuptools` is easier thanks to a new + ``pybind11.setup_helpers`` module, which provides utilities to use + setuptools with pybind11. It can be used via PEP 518, ``setup_requires``, + or by directly importing or copying ``setup_helpers.py`` into your project. + + * CMake configuration files are now included in the Python package. Use + ``pybind11.get_cmake_dir()`` or ``python -m pybind11 --cmakedir`` to get + the directory with the CMake configuration files, or include the + site-packages location in your ``CMAKE_MODULE_PATH``. Or you can use the + new ``pybind11[global]`` extra when you install ``pybind11``, which + installs the CMake files and headers into your base environment in the + standard location. + + * ``pybind11-config`` is another way to write ``python -m pybind11`` if you + have your PATH set up. + + * Added external typing support to the helper module, code from + ``import pybind11`` can now be type checked. + `#2588 `_ + +* Minimum CMake required increased to 3.4. + `#2338 `_ and + `#2370 `_ + + * Full integration with CMake's C++ standard system and compile features + replaces ``PYBIND11_CPP_STANDARD``. + + * Generated config file is now portable to different Python/compiler/CMake + versions. + + * Virtual environments prioritized if ``PYTHON_EXECUTABLE`` is not set + (``venv``, ``virtualenv``, and ``conda``) (similar to the new FindPython + mode). + + * Other CMake features now natively supported, like + ``CMAKE_INTERPROCEDURAL_OPTIMIZATION``, ``set(CMAKE_CXX_VISIBILITY_PRESET + hidden)``. + + * ``CUDA`` as a language is now supported. + + * Helper functions ``pybind11_strip``, ``pybind11_extension``, + ``pybind11_find_import`` added, see :doc:`cmake/index`. + + * Optional :ref:`find-python-mode` and :ref:`nopython-mode` with CMake. + `#2370 `_ + +* Uninstall target added. + `#2265 `_ and + `#2346 `_ + +* ``pybind11_add_module()`` now accepts an optional ``OPT_SIZE`` flag that + switches the binding target to size-based optimization if the global build + type can not always be fixed to ``MinSizeRel`` (except in debug mode, where + optimizations remain disabled). ``MinSizeRel`` or this flag reduces binary + size quite substantially (~25% on some platforms). + `#2463 `_ + +Smaller or developer focused features and fixes: + +* Moved ``mkdoc.py`` to a new repo, `pybind11-mkdoc`_. There are no longer + submodules in the main repo. + +* ``py::memoryview`` segfault fix and update, with new + ``py::memoryview::from_memory`` in Python 3, and documentation. + `#2223 `_ + +* Fix for ``buffer_info`` on Python 2. + `#2503 `_ + +* If ``__eq__`` defined but not ``__hash__``, ``__hash__`` is now set to + ``None``. + `#2291 `_ + +* ``py::ellipsis`` now also works on Python 2. + `#2360 `_ + +* Pointer to ``std::tuple`` & ``std::pair`` supported in cast. + `#2334 `_ + +* Small fixes in NumPy support. ``py::array`` now uses ``py::ssize_t`` as first + argument type. + `#2293 `_ + +* Added missing signature for ``py::array``. + `#2363 `_ + +* ``unchecked_mutable_reference`` has access to operator ``()`` and ``[]`` when + const. + `#2514 `_ + +* ``py::vectorize`` is now supported on functions that return void. + `#1969 `_ + +* ``py::capsule`` supports ``get_pointer`` and ``set_pointer``. + `#1131 `_ + +* Fix crash when different instances share the same pointer of the same type. + `#2252 `_ + +* Fix for ``py::len`` not clearing Python's error state when it fails and throws. + `#2575 `_ + +* Bugfixes related to more extensive testing, new GitHub Actions CI. + `#2321 `_ + +* Bug in timezone issue in Eastern hemisphere midnight fixed. + `#2438 `_ + +* ``std::chrono::time_point`` now works when the resolution is not the same as + the system. + `#2481 `_ + +* Bug fixed where ``py::array_t`` could accept arrays that did not match the + requested ordering. + `#2484 `_ + +* Avoid a segfault on some compilers when types are removed in Python. + `#2564 `_ + +* ``py::arg::none()`` is now also respected when passing keyword arguments. + `#2611 `_ + +* PyPy fixes, PyPy 7.3.x now supported, including PyPy3. (Known issue with + PyPy2 and Windows `#2596 `_). + `#2146 `_ + +* CPython 3.9.0 workaround for undefined behavior (macOS segfault). + `#2576 `_ + +* CPython 3.9 warning fixes. + `#2253 `_ + +* Improved C++20 support, now tested in CI. + `#2489 `_ + `#2599 `_ + +* Improved but still incomplete debug Python interpreter support. + `#2025 `_ + +* NVCC (CUDA 11) now supported and tested in CI. + `#2461 `_ + +* NVIDIA PGI compilers now supported and tested in CI. + `#2475 `_ + +* At least Intel 18 now explicitly required when compiling with Intel. + `#2577 `_ + +* Extensive style checking in CI, with `pre-commit`_ support. Code + modernization, checked by clang-tidy. + +* Expanded docs, including new main page, new installing section, and CMake + helpers page, along with over a dozen new sections on existing pages. + +* In GitHub, new docs for contributing and new issue templates. + +.. _pre-commit: https://pre-commit.com + +.. _pybind11-mkdoc: https://github.com/pybind/pybind11-mkdoc + +v2.5.0 (Mar 31, 2020) +----------------------------------------------------- + +* Use C++17 fold expressions in type casters, if available. This can + improve performance during overload resolution when functions have + multiple arguments. + `#2043 `_. + +* Changed include directory resolution in ``pybind11/__init__.py`` + and installation in ``setup.py``. This fixes a number of open issues + where pybind11 headers could not be found in certain environments. + `#1995 `_. + +* C++20 ``char8_t`` and ``u8string`` support. `#2026 + `_. + +* CMake: search for Python 3.9. `bb9c91 + `_. + +* Fixes for MSYS-based build environments. + `#2087 `_, + `#2053 `_. + +* STL bindings for ``std::vector<...>::clear``. `#2074 + `_. + +* Read-only flag for ``py::buffer``. `#1466 + `_. + +* Exception handling during module initialization. + `bf2b031 `_. + +* Support linking against a CPython debug build. + `#2025 `_. + +* Fixed issues involving the availability and use of aligned ``new`` and + ``delete``. `#1988 `_, + `759221 `_. + +* Fixed a resource leak upon interpreter shutdown. + `#2020 `_. + +* Fixed error handling in the boolean caster. + `#1976 `_. + +v2.4.3 (Oct 15, 2019) +----------------------------------------------------- + +* Adapt pybind11 to a C API convention change in Python 3.8. `#1950 + `_. + +v2.4.2 (Sep 21, 2019) +----------------------------------------------------- + +* Replaced usage of a C++14 only construct. `#1929 + `_. + +* Made an ifdef future-proof for Python >= 4. `f3109d + `_. + +v2.4.1 (Sep 20, 2019) +----------------------------------------------------- + +* Fixed a problem involving implicit conversion from enumerations to integers + on Python 3.8. `#1780 `_. + +v2.4.0 (Sep 19, 2019) +----------------------------------------------------- + +* Try harder to keep pybind11-internal data structures separate when there + are potential ABI incompatibilities. Fixes crashes that occurred when loading + multiple pybind11 extensions that were e.g. compiled by GCC (libstdc++) + and Clang (libc++). + `#1588 `_ and + `c9f5a `_. + +* Added support for ``__await__``, ``__aiter__``, and ``__anext__`` protocols. + `#1842 `_. + +* ``pybind11_add_module()``: don't strip symbols when compiling in + ``RelWithDebInfo`` mode. `#1980 + `_. + +* ``enum_``: Reproduce Python behavior when comparing against invalid values + (e.g. ``None``, strings, etc.). Add back support for ``__invert__()``. + `#1912 `_, + `#1907 `_. + +* List insertion operation for ``py::list``. + Added ``.empty()`` to all collection types. + Added ``py::set::contains()`` and ``py::dict::contains()``. + `#1887 `_, + `#1884 `_, + `#1888 `_. + +* ``py::details::overload_cast_impl`` is available in C++11 mode, can be used + like ``overload_cast`` with an additional set of parentheses. + `#1581 `_. + +* Fixed ``get_include()`` on Conda. + `#1877 `_. + +* ``stl_bind.h``: negative indexing support. + `#1882 `_. + +* Minor CMake fix to add MinGW compatibility. + `#1851 `_. + +* GIL-related fixes. + `#1836 `_, + `8b90b `_. + +* Other very minor/subtle fixes and improvements. + `#1329 `_, + `#1910 `_, + `#1863 `_, + `#1847 `_, + `#1890 `_, + `#1860 `_, + `#1848 `_, + `#1821 `_, + `#1837 `_, + `#1833 `_, + `#1748 `_, + `#1852 `_. + +v2.3.0 (June 11, 2019) +----------------------------------------------------- + +* Significantly reduced module binary size (10-20%) when compiled in C++11 mode + with GCC/Clang, or in any mode with MSVC. Function signatures are now always + precomputed at compile time (this was previously only available in C++14 mode + for non-MSVC compilers). + `#934 `_. + +* Add basic support for tag-based static polymorphism, where classes + provide a method to returns the desired type of an instance. + `#1326 `_. + +* Python type wrappers (``py::handle``, ``py::object``, etc.) + now support map Python's number protocol onto C++ arithmetic + operators such as ``operator+``, ``operator/=``, etc. + `#1511 `_. + +* A number of improvements related to enumerations: + + 1. The ``enum_`` implementation was rewritten from scratch to reduce + code bloat. Rather than instantiating a full implementation for each + enumeration, most code is now contained in a generic base class. + `#1511 `_. + + 2. The ``value()`` method of ``py::enum_`` now accepts an optional + docstring that will be shown in the documentation of the associated + enumeration. `#1160 `_. + + 3. check for already existing enum value and throw an error if present. + `#1453 `_. + +* Support for over-aligned type allocation via C++17's aligned ``new`` + statement. `#1582 `_. + +* Added ``py::ellipsis()`` method for slicing of multidimensional NumPy arrays + `#1502 `_. + +* Numerous Improvements to the ``mkdoc.py`` script for extracting documentation + from C++ header files. + `#1788 `_. + +* ``pybind11_add_module()``: allow including Python as a ``SYSTEM`` include path. + `#1416 `_. + +* ``pybind11/stl.h`` does not convert strings to ``vector`` anymore. + `#1258 `_. + +* Mark static methods as such to fix auto-generated Sphinx documentation. + `#1732 `_. + +* Re-throw forced unwind exceptions (e.g. during pthread termination). + `#1208 `_. + +* Added ``__contains__`` method to the bindings of maps (``std::map``, + ``std::unordered_map``). + `#1767 `_. + +* Improvements to ``gil_scoped_acquire``. + `#1211 `_. + +* Type caster support for ``std::deque``. + `#1609 `_. + +* Support for ``std::unique_ptr`` holders, whose deleters differ between a base and derived + class. `#1353 `_. + +* Construction of STL array/vector-like data structures from + iterators. Added an ``extend()`` operation. + `#1709 `_, + +* CMake build system improvements for projects that include non-C++ + files (e.g. plain C, CUDA) in ``pybind11_add_module`` et al. + `#1678 `_. + +* Fixed asynchronous invocation and deallocation of Python functions + wrapped in ``std::function``. + `#1595 `_. + +* Fixes regarding return value policy propagation in STL type casters. + `#1603 `_. + +* Fixed scoped enum comparisons. + `#1571 `_. + +* Fixed iostream redirection for code that releases the GIL. + `#1368 `_, + +* A number of CI-related fixes. + `#1757 `_, + `#1744 `_, + `#1670 `_. + +v2.2.4 (September 11, 2018) +----------------------------------------------------- + +* Use new Python 3.7 Thread Specific Storage (TSS) implementation if available. + `#1454 `_, + `#1517 `_. + +* Fixes for newer MSVC versions and C++17 mode. + `#1347 `_, + `#1462 `_. + +* Propagate return value policies to type-specific casters + when casting STL containers. + `#1455 `_. + +* Allow ostream-redirection of more than 1024 characters. + `#1479 `_. + +* Set ``Py_DEBUG`` define when compiling against a debug Python build. + `#1438 `_. + +* Untangle integer logic in number type caster to work for custom + types that may only be castable to a restricted set of builtin types. + `#1442 `_. + +* CMake build system: Remember Python version in cache file. + `#1434 `_. + +* Fix for custom smart pointers: use ``std::addressof`` to obtain holder + address instead of ``operator&``. + `#1435 `_. + +* Properly report exceptions thrown during module initialization. + `#1362 `_. + +* Fixed a segmentation fault when creating empty-shaped NumPy array. + `#1371 `_. + +* The version of Intel C++ compiler must be >= 2017, and this is now checked by + the header files. `#1363 `_. + +* A few minor typo fixes and improvements to the test suite, and + patches that silence compiler warnings. + +* Vectors now support construction from generators, as well as ``extend()`` from a + list or generator. + `#1496 `_. + + +v2.2.3 (April 29, 2018) +----------------------------------------------------- + +* The pybind11 header location detection was replaced by a new implementation + that no longer depends on ``pip`` internals (the recently released ``pip`` + 10 has restricted access to this API). + `#1190 `_. + +* Small adjustment to an implementation detail to work around a compiler segmentation fault in Clang 3.3/3.4. + `#1350 `_. + +* The minimal supported version of the Intel compiler was >= 17.0 since + pybind11 v2.1. This check is now explicit, and a compile-time error is raised + if the compiler meet the requirement. + `#1363 `_. + +* Fixed an endianness-related fault in the test suite. + `#1287 `_. + +v2.2.2 (February 7, 2018) +----------------------------------------------------- + +* Fixed a segfault when combining embedded interpreter + shutdown/reinitialization with external loaded pybind11 modules. + `#1092 `_. + +* Eigen support: fixed a bug where Nx1/1xN numpy inputs couldn't be passed as + arguments to Eigen vectors (which for Eigen are simply compile-time fixed + Nx1/1xN matrices). + `#1106 `_. + +* Clarified to license by moving the licensing of contributions from + ``LICENSE`` into ``CONTRIBUTING.md``: the licensing of contributions is not + actually part of the software license as distributed. This isn't meant to be + a substantial change in the licensing of the project, but addresses concerns + that the clause made the license non-standard. + `#1109 `_. + +* Fixed a regression introduced in 2.1 that broke binding functions with lvalue + character literal arguments. + `#1128 `_. + +* MSVC: fix for compilation failures under /permissive-, and added the flag to + the appveyor test suite. + `#1155 `_. + +* Fixed ``__qualname__`` generation, and in turn, fixes how class names + (especially nested class names) are shown in generated docstrings. + `#1171 `_. + +* Updated the FAQ with a suggested project citation reference. + `#1189 `_. + +* Added fixes for deprecation warnings when compiled under C++17 with + ``-Wdeprecated`` turned on, and add ``-Wdeprecated`` to the test suite + compilation flags. + `#1191 `_. + +* Fixed outdated PyPI URLs in ``setup.py``. + `#1213 `_. + +* Fixed a refcount leak for arguments that end up in a ``py::args`` argument + for functions with both fixed positional and ``py::args`` arguments. + `#1216 `_. + +* Fixed a potential segfault resulting from possible premature destruction of + ``py::args``/``py::kwargs`` arguments with overloaded functions. + `#1223 `_. + +* Fixed ``del map[item]`` for a ``stl_bind.h`` bound stl map. + `#1229 `_. + +* Fixed a regression from v2.1.x where the aggregate initialization could + unintentionally end up at a constructor taking a templated + ``std::initializer_list`` argument. + `#1249 `_. + +* Fixed an issue where calling a function with a keep_alive policy on the same + nurse/patient pair would cause the internal patient storage to needlessly + grow (unboundedly, if the nurse is long-lived). + `#1251 `_. + +* Various other minor fixes. + +v2.2.1 (September 14, 2017) +----------------------------------------------------- + +* Added ``py::module_::reload()`` member function for reloading a module. + `#1040 `_. + +* Fixed a reference leak in the number converter. + `#1078 `_. + +* Fixed compilation with Clang on host GCC < 5 (old libstdc++ which isn't fully + C++11 compliant). `#1062 `_. + +* Fixed a regression where the automatic ``std::vector`` caster would + fail to compile. The same fix also applies to any container which returns + element proxies instead of references. + `#1053 `_. + +* Fixed a regression where the ``py::keep_alive`` policy could not be applied + to constructors. `#1065 `_. + +* Fixed a nullptr dereference when loading a ``py::module_local`` type + that's only registered in an external module. + `#1058 `_. + +* Fixed implicit conversion of accessors to types derived from ``py::object``. + `#1076 `_. + +* The ``name`` in ``PYBIND11_MODULE(name, variable)`` can now be a macro. + `#1082 `_. + +* Relaxed overly strict ``py::pickle()`` check for matching get and set types. + `#1064 `_. + +* Conversion errors now try to be more informative when it's likely that + a missing header is the cause (e.g. forgetting ````). + `#1077 `_. + +v2.2.0 (August 31, 2017) +----------------------------------------------------- + +* Support for embedding the Python interpreter. See the + :doc:`documentation page ` for a + full overview of the new features. + `#774 `_, + `#889 `_, + `#892 `_, + `#920 `_. + + .. code-block:: cpp + + #include + namespace py = pybind11; + + int main() { + py::scoped_interpreter guard{}; // start the interpreter and keep it alive + + py::print("Hello, World!"); // use the Python API + } + +* Support for inheriting from multiple C++ bases in Python. + `#693 `_. + + .. code-block:: python + + from cpp_module import CppBase1, CppBase2 + + + class PyDerived(CppBase1, CppBase2): + def __init__(self): + CppBase1.__init__(self) # C++ bases must be initialized explicitly + CppBase2.__init__(self) + +* ``PYBIND11_MODULE`` is now the preferred way to create module entry points. + ``PYBIND11_PLUGIN`` is deprecated. See :ref:`macros` for details. + `#879 `_. + + .. code-block:: cpp + + // new + PYBIND11_MODULE(example, m) { + m.def("add", [](int a, int b) { return a + b; }); + } + + // old + PYBIND11_PLUGIN(example) { + py::module m("example"); + m.def("add", [](int a, int b) { return a + b; }); + return m.ptr(); + } + +* pybind11's headers and build system now more strictly enforce hidden symbol + visibility for extension modules. This should be seamless for most users, + but see the :doc:`upgrade` if you use a custom build system. + `#995 `_. + +* Support for ``py::module_local`` types which allow multiple modules to + export the same C++ types without conflicts. This is useful for opaque + types like ``std::vector``. ``py::bind_vector`` and ``py::bind_map`` + now default to ``py::module_local`` if their elements are builtins or + local types. See :ref:`module_local` for details. + `#949 `_, + `#981 `_, + `#995 `_, + `#997 `_. + +* Custom constructors can now be added very easily using lambdas or factory + functions which return a class instance by value, pointer or holder. This + supersedes the old placement-new ``__init__`` technique. + See :ref:`custom_constructors` for details. + `#805 `_, + `#1014 `_. + + .. code-block:: cpp + + struct Example { + Example(std::string); + }; + + py::class_(m, "Example") + .def(py::init()) // existing constructor + .def(py::init([](int n) { // custom constructor + return std::make_unique(std::to_string(n)); + })); + +* Similarly to custom constructors, pickling support functions are now bound + using the ``py::pickle()`` adaptor which improves type safety. See the + :doc:`upgrade` and :ref:`pickling` for details. + `#1038 `_. + +* Builtin support for converting C++17 standard library types and general + conversion improvements: + + 1. C++17 ``std::variant`` is supported right out of the box. C++11/14 + equivalents (e.g. ``boost::variant``) can also be added with a simple + user-defined specialization. See :ref:`cpp17_container_casters` for details. + `#811 `_, + `#845 `_, + `#989 `_. + + 2. Out-of-the-box support for C++17 ``std::string_view``. + `#906 `_. + + 3. Improved compatibility of the builtin ``optional`` converter. + `#874 `_. + + 4. The ``bool`` converter now accepts ``numpy.bool_`` and types which + define ``__bool__`` (Python 3.x) or ``__nonzero__`` (Python 2.7). + `#925 `_. + + 5. C++-to-Python casters are now more efficient and move elements out + of rvalue containers whenever possible. + `#851 `_, + `#936 `_, + `#938 `_. + + 6. Fixed ``bytes`` to ``std::string/char*`` conversion on Python 3. + `#817 `_. + + 7. Fixed lifetime of temporary C++ objects created in Python-to-C++ conversions. + `#924 `_. + +* Scope guard call policy for RAII types, e.g. ``py::call_guard()``, + ``py::call_guard()``. See :ref:`call_policies` for details. + `#740 `_. + +* Utility for redirecting C++ streams to Python (e.g. ``std::cout`` -> + ``sys.stdout``). Scope guard ``py::scoped_ostream_redirect`` in C++ and + a context manager in Python. See :ref:`ostream_redirect`. + `#1009 `_. + +* Improved handling of types and exceptions across module boundaries. + `#915 `_, + `#951 `_, + `#995 `_. + +* Fixed destruction order of ``py::keep_alive`` nurse/patient objects + in reference cycles. + `#856 `_. + +* NumPy and buffer protocol related improvements: + + 1. Support for negative strides in Python buffer objects/numpy arrays. This + required changing integers from unsigned to signed for the related C++ APIs. + Note: If you have compiler warnings enabled, you may notice some new conversion + warnings after upgrading. These can be resolved with ``static_cast``. + `#782 `_. + + 2. Support ``std::complex`` and arrays inside ``PYBIND11_NUMPY_DTYPE``. + `#831 `_, + `#832 `_. + + 3. Support for constructing ``py::buffer_info`` and ``py::arrays`` using + arbitrary containers or iterators instead of requiring a ``std::vector``. + `#788 `_, + `#822 `_, + `#860 `_. + + 4. Explicitly check numpy version and require >= 1.7.0. + `#819 `_. + +* Support for allowing/prohibiting ``None`` for specific arguments and improved + ``None`` overload resolution order. See :ref:`none_arguments` for details. + `#843 `_. + `#859 `_. + +* Added ``py::exec()`` as a shortcut for ``py::eval()`` + and support for C++11 raw string literals as input. See :ref:`eval`. + `#766 `_, + `#827 `_. + +* ``py::vectorize()`` ignores non-vectorizable arguments and supports + member functions. + `#762 `_. + +* Support for bound methods as callbacks (``pybind11/functional.h``). + `#815 `_. + +* Allow aliasing pybind11 methods: ``cls.attr("foo") = cls.attr("bar")``. + `#802 `_. + +* Don't allow mixed static/non-static overloads. + `#804 `_. + +* Fixed overriding static properties in derived classes. + `#784 `_. + +* Added support for write only properties. + `#1144 `_. + +* Improved deduction of member functions of a derived class when its bases + aren't registered with pybind11. + `#855 `_. + + .. code-block:: cpp + + struct Base { + int foo() { return 42; } + } + + struct Derived : Base {} + + // Now works, but previously required also binding `Base` + py::class_(m, "Derived") + .def("foo", &Derived::foo); // function is actually from `Base` + +* The implementation of ``py::init<>`` now uses C++11 brace initialization + syntax to construct instances, which permits binding implicit constructors of + aggregate types. `#1015 `_. + + .. code-block:: cpp + + struct Aggregate { + int a; + std::string b; + }; + + py::class_(m, "Aggregate") + .def(py::init()); + +* Fixed issues with multiple inheritance with offset base/derived pointers. + `#812 `_, + `#866 `_, + `#960 `_. + +* Fixed reference leak of type objects. + `#1030 `_. + +* Improved support for the ``/std:c++14`` and ``/std:c++latest`` modes + on MSVC 2017. + `#841 `_, + `#999 `_. + +* Fixed detection of private operator new on MSVC. + `#893 `_, + `#918 `_. + +* Intel C++ compiler compatibility fixes. + `#937 `_. + +* Fixed implicit conversion of ``py::enum_`` to integer types on Python 2.7. + `#821 `_. + +* Added ``py::hash`` to fetch the hash value of Python objects, and + ``.def(hash(py::self))`` to provide the C++ ``std::hash`` as the Python + ``__hash__`` method. + `#1034 `_. + +* Fixed ``__truediv__`` on Python 2 and ``__itruediv__`` on Python 3. + `#867 `_. + +* ``py::capsule`` objects now support the ``name`` attribute. This is useful + for interfacing with ``scipy.LowLevelCallable``. + `#902 `_. + +* Fixed ``py::make_iterator``'s ``__next__()`` for past-the-end calls. + `#897 `_. + +* Added ``error_already_set::matches()`` for checking Python exceptions. + `#772 `_. + +* Deprecated ``py::error_already_set::clear()``. It's no longer needed + following a simplification of the ``py::error_already_set`` class. + `#954 `_. + +* Deprecated ``py::handle::operator==()`` in favor of ``py::handle::is()`` + `#825 `_. + +* Deprecated ``py::object::borrowed``/``py::object::stolen``. + Use ``py::object::borrowed_t{}``/``py::object::stolen_t{}`` instead. + `#771 `_. + +* Changed internal data structure versioning to avoid conflicts between + modules compiled with different revisions of pybind11. + `#1012 `_. + +* Additional compile-time and run-time error checking and more informative messages. + `#786 `_, + `#794 `_, + `#803 `_. + +* Various minor improvements and fixes. + `#764 `_, + `#791 `_, + `#795 `_, + `#840 `_, + `#844 `_, + `#846 `_, + `#849 `_, + `#858 `_, + `#862 `_, + `#871 `_, + `#872 `_, + `#881 `_, + `#888 `_, + `#899 `_, + `#928 `_, + `#931 `_, + `#944 `_, + `#950 `_, + `#952 `_, + `#962 `_, + `#965 `_, + `#970 `_, + `#978 `_, + `#979 `_, + `#986 `_, + `#1020 `_, + `#1027 `_, + `#1037 `_. + +* Testing improvements. + `#798 `_, + `#882 `_, + `#898 `_, + `#900 `_, + `#921 `_, + `#923 `_, + `#963 `_. + +v2.1.1 (April 7, 2017) +----------------------------------------------------- + +* Fixed minimum version requirement for MSVC 2015u3 + `#773 `_. + +v2.1.0 (March 22, 2017) +----------------------------------------------------- + +* pybind11 now performs function overload resolution in two phases. The first + phase only considers exact type matches, while the second allows for implicit + conversions to take place. A special ``noconvert()`` syntax can be used to + completely disable implicit conversions for specific arguments. + `#643 `_, + `#634 `_, + `#650 `_. + +* Fixed a regression where static properties no longer worked with classes + using multiple inheritance. The ``py::metaclass`` attribute is no longer + necessary (and deprecated as of this release) when binding classes with + static properties. + `#679 `_, + +* Classes bound using ``pybind11`` can now use custom metaclasses. + `#679 `_, + +* ``py::args`` and ``py::kwargs`` can now be mixed with other positional + arguments when binding functions using pybind11. + `#611 `_. + +* Improved support for C++11 unicode string and character types; added + extensive documentation regarding pybind11's string conversion behavior. + `#624 `_, + `#636 `_, + `#715 `_. + +* pybind11 can now avoid expensive copies when converting Eigen arrays to NumPy + arrays (and vice versa). `#610 `_. + +* The "fast path" in ``py::vectorize`` now works for any full-size group of C or + F-contiguous arrays. The non-fast path is also faster since it no longer performs + copies of the input arguments (except when type conversions are necessary). + `#610 `_. + +* Added fast, unchecked access to NumPy arrays via a proxy object. + `#746 `_. + +* Transparent support for class-specific ``operator new`` and + ``operator delete`` implementations. + `#755 `_. + +* Slimmer and more efficient STL-compatible iterator interface for sequence types. + `#662 `_. + +* Improved custom holder type support. + `#607 `_. + +* ``nullptr`` to ``None`` conversion fixed in various builtin type casters. + `#732 `_. + +* ``enum_`` now exposes its members via a special ``__members__`` attribute. + `#666 `_. + +* ``std::vector`` bindings created using ``stl_bind.h`` can now optionally + implement the buffer protocol. `#488 `_. + +* Automated C++ reference documentation using doxygen and breathe. + `#598 `_. + +* Added minimum compiler version assertions. + `#727 `_. + +* Improved compatibility with C++1z. + `#677 `_. + +* Improved ``py::capsule`` API. Can be used to implement cleanup + callbacks that are involved at module destruction time. + `#752 `_. + +* Various minor improvements and fixes. + `#595 `_, + `#588 `_, + `#589 `_, + `#603 `_, + `#619 `_, + `#648 `_, + `#695 `_, + `#720 `_, + `#723 `_, + `#729 `_, + `#724 `_, + `#742 `_, + `#753 `_. + +v2.0.1 (Jan 4, 2017) +----------------------------------------------------- + +* Fix pointer to reference error in type_caster on MSVC + `#583 `_. + +* Fixed a segmentation in the test suite due to a typo + `cd7eac `_. + +v2.0.0 (Jan 1, 2017) +----------------------------------------------------- + +* Fixed a reference counting regression affecting types with custom metaclasses + (introduced in v2.0.0-rc1). + `#571 `_. + +* Quenched a CMake policy warning. + `#570 `_. + +v2.0.0-rc1 (Dec 23, 2016) +----------------------------------------------------- + +The pybind11 developers are excited to issue a release candidate of pybind11 +with a subsequent v2.0.0 release planned in early January next year. + +An incredible amount of effort by went into pybind11 over the last ~5 months, +leading to a release that is jam-packed with exciting new features and numerous +usability improvements. The following list links PRs or individual commits +whenever applicable. + +Happy Christmas! + +* Support for binding C++ class hierarchies that make use of multiple + inheritance. `#410 `_. + +* PyPy support: pybind11 now supports nightly builds of PyPy and will + interoperate with the future 5.7 release. No code changes are necessary, + everything "just" works as usual. Note that we only target the Python 2.7 + branch for now; support for 3.x will be added once its ``cpyext`` extension + support catches up. A few minor features remain unsupported for the time + being (notably dynamic attributes in custom types). + `#527 `_. + +* Significant work on the documentation -- in particular, the monolithic + ``advanced.rst`` file was restructured into a easier to read hierarchical + organization. `#448 `_. + +* Many NumPy-related improvements: + + 1. Object-oriented API to access and modify NumPy ``ndarray`` instances, + replicating much of the corresponding NumPy C API functionality. + `#402 `_. + + 2. NumPy array ``dtype`` array descriptors are now first-class citizens and + are exposed via a new class ``py::dtype``. + + 3. Structured dtypes can be registered using the ``PYBIND11_NUMPY_DTYPE()`` + macro. Special ``array`` constructors accepting dtype objects were also + added. + + One potential caveat involving this change: format descriptor strings + should now be accessed via ``format_descriptor::format()`` (however, for + compatibility purposes, the old syntax ``format_descriptor::value`` will + still work for non-structured data types). `#308 + `_. + + 4. Further improvements to support structured dtypes throughout the system. + `#472 `_, + `#474 `_, + `#459 `_, + `#453 `_, + `#452 `_, and + `#505 `_. + + 5. Fast access operators. `#497 `_. + + 6. Constructors for arrays whose storage is owned by another object. + `#440 `_. + + 7. Added constructors for ``array`` and ``array_t`` explicitly accepting shape + and strides; if strides are not provided, they are deduced assuming + C-contiguity. Also added simplified constructors for 1-dimensional case. + + 8. Added buffer/NumPy support for ``char[N]`` and ``std::array`` types. + + 9. Added ``memoryview`` wrapper type which is constructible from ``buffer_info``. + +* Eigen: many additional conversions and support for non-contiguous + arrays/slices. + `#427 `_, + `#315 `_, + `#316 `_, + `#312 `_, and + `#267 `_ + +* Incompatible changes in ``class_<...>::class_()``: + + 1. Declarations of types that provide access via the buffer protocol must + now include the ``py::buffer_protocol()`` annotation as an argument to + the ``class_`` constructor. + + 2. Declarations of types that require a custom metaclass (i.e. all classes + which include static properties via commands such as + ``def_readwrite_static()``) must now include the ``py::metaclass()`` + annotation as an argument to the ``class_`` constructor. + + These two changes were necessary to make type definitions in pybind11 + future-proof, and to support PyPy via its cpyext mechanism. `#527 + `_. + + + 3. This version of pybind11 uses a redesigned mechanism for instantiating + trampoline classes that are used to override virtual methods from within + Python. This led to the following user-visible syntax change: instead of + + .. code-block:: cpp + + py::class_("MyClass") + .alias() + .... + + write + + .. code-block:: cpp + + py::class_("MyClass") + .... + + Importantly, both the original and the trampoline class are now + specified as an arguments (in arbitrary order) to the ``py::class_`` + template, and the ``alias<..>()`` call is gone. The new scheme has zero + overhead in cases when Python doesn't override any functions of the + underlying C++ class. `rev. 86d825 + `_. + +* Added ``eval`` and ``eval_file`` functions for evaluating expressions and + statements from a string or file. `rev. 0d3fc3 + `_. + +* pybind11 can now create types with a modifiable dictionary. + `#437 `_ and + `#444 `_. + +* Support for translation of arbitrary C++ exceptions to Python counterparts. + `#296 `_ and + `#273 `_. + +* Report full backtraces through mixed C++/Python code, better reporting for + import errors, fixed GIL management in exception processing. + `#537 `_, + `#494 `_, + `rev. e72d95 `_, and + `rev. 099d6e `_. + +* Support for bit-level operations, comparisons, and serialization of C++ + enumerations. `#503 `_, + `#508 `_, + `#380 `_, + `#309 `_. + `#311 `_. + +* The ``class_`` constructor now accepts its template arguments in any order. + `#385 `_. + +* Attribute and item accessors now have a more complete interface which makes + it possible to chain attributes as in + ``obj.attr("a")[key].attr("b").attr("method")(1, 2, 3)``. `#425 + `_. + +* Major redesign of the default and conversion constructors in ``pytypes.h``. + `#464 `_. + +* Added built-in support for ``std::shared_ptr`` holder type. It is no longer + necessary to to include a declaration of the form + ``PYBIND11_DECLARE_HOLDER_TYPE(T, std::shared_ptr)`` (though continuing to + do so won't cause an error). + `#454 `_. + +* New ``py::overload_cast`` casting operator to select among multiple possible + overloads of a function. An example: + + .. code-block:: cpp + + py::class_(m, "Pet") + .def("set", py::overload_cast(&Pet::set), "Set the pet's age") + .def("set", py::overload_cast(&Pet::set), "Set the pet's name"); + + This feature only works on C++14-capable compilers. + `#541 `_. + +* C++ types are automatically cast to Python types, e.g. when assigning + them as an attribute. For instance, the following is now legal: + + .. code-block:: cpp + + py::module m = /* ... */ + m.attr("constant") = 123; + + (Previously, a ``py::cast`` call was necessary to avoid a compilation error.) + `#551 `_. + +* Redesigned ``pytest``-based test suite. `#321 `_. + +* Instance tracking to detect reference leaks in test suite. `#324 `_ + +* pybind11 can now distinguish between multiple different instances that are + located at the same memory address, but which have different types. + `#329 `_. + +* Improved logic in ``move`` return value policy. + `#510 `_, + `#297 `_. + +* Generalized unpacking API to permit calling Python functions from C++ using + notation such as ``foo(a1, a2, *args, "ka"_a=1, "kb"_a=2, **kwargs)``. `#372 `_. + +* ``py::print()`` function whose behavior matches that of the native Python + ``print()`` function. `#372 `_. + +* Added ``py::dict`` keyword constructor:``auto d = dict("number"_a=42, + "name"_a="World");``. `#372 `_. + +* Added ``py::str::format()`` method and ``_s`` literal: ``py::str s = "1 + 2 + = {}"_s.format(3);``. `#372 `_. + +* Added ``py::repr()`` function which is equivalent to Python's builtin + ``repr()``. `#333 `_. + +* Improved construction and destruction logic for holder types. It is now + possible to reference instances with smart pointer holder types without + constructing the holder if desired. The ``PYBIND11_DECLARE_HOLDER_TYPE`` + macro now accepts an optional second parameter to indicate whether the holder + type uses intrusive reference counting. + `#533 `_ and + `#561 `_. + +* Mapping a stateless C++ function to Python and back is now "for free" (i.e. + no extra indirections or argument conversion overheads). `rev. 954b79 + `_. + +* Bindings for ``std::valarray``. + `#545 `_. + +* Improved support for C++17 capable compilers. + `#562 `_. + +* Bindings for ``std::optional``. + `#475 `_, + `#476 `_, + `#479 `_, + `#499 `_, and + `#501 `_. + +* ``stl_bind.h``: general improvements and support for ``std::map`` and + ``std::unordered_map``. + `#490 `_, + `#282 `_, + `#235 `_. + +* The ``std::tuple``, ``std::pair``, ``std::list``, and ``std::vector`` type + casters now accept any Python sequence type as input. `rev. 107285 + `_. + +* Improved CMake Python detection on multi-architecture Linux. + `#532 `_. + +* Infrastructure to selectively disable or enable parts of the automatically + generated docstrings. `#486 `_. + +* ``reference`` and ``reference_internal`` are now the default return value + properties for static and non-static properties, respectively. `#473 + `_. (the previous defaults + were ``automatic``). `#473 `_. + +* Support for ``std::unique_ptr`` with non-default deleters or no deleter at + all (``py::nodelete``). `#384 `_. + +* Deprecated ``handle::call()`` method. The new syntax to call Python + functions is simply ``handle()``. It can also be invoked explicitly via + ``handle::operator()``, where ``X`` is an optional return value policy. + +* Print more informative error messages when ``make_tuple()`` or ``cast()`` + fail. `#262 `_. + +* Creation of holder types for classes deriving from + ``std::enable_shared_from_this<>`` now also works for ``const`` values. + `#260 `_. + +* ``make_iterator()`` improvements for better compatibility with various + types (now uses prefix increment operator); it now also accepts iterators + with different begin/end types as long as they are equality comparable. + `#247 `_. + +* ``arg()`` now accepts a wider range of argument types for default values. + `#244 `_. + +* Support ``keep_alive`` where the nurse object may be ``None``. `#341 + `_. + +* Added constructors for ``str`` and ``bytes`` from zero-terminated char + pointers, and from char pointers and length. Added constructors for ``str`` + from ``bytes`` and for ``bytes`` from ``str``, which will perform UTF-8 + decoding/encoding as required. + +* Many other improvements of library internals without user-visible changes + + +1.8.1 (July 12, 2016) +---------------------- +* Fixed a rare but potentially very severe issue when the garbage collector ran + during pybind11 type creation. + +1.8.0 (June 14, 2016) +---------------------- +* Redesigned CMake build system which exports a convenient + ``pybind11_add_module`` function to parent projects. +* ``std::vector<>`` type bindings analogous to Boost.Python's ``indexing_suite`` +* Transparent conversion of sparse and dense Eigen matrices and vectors (``eigen.h``) +* Added an ``ExtraFlags`` template argument to the NumPy ``array_t<>`` wrapper + to disable an enforced cast that may lose precision, e.g. to create overloads + for different precisions and complex vs real-valued matrices. +* Prevent implicit conversion of floating point values to integral types in + function arguments +* Fixed incorrect default return value policy for functions returning a shared + pointer +* Don't allow registering a type via ``class_`` twice +* Don't allow casting a ``None`` value into a C++ lvalue reference +* Fixed a crash in ``enum_::operator==`` that was triggered by the ``help()`` command +* Improved detection of whether or not custom C++ types can be copy/move-constructed +* Extended ``str`` type to also work with ``bytes`` instances +* Added a ``"name"_a`` user defined string literal that is equivalent to ``py::arg("name")``. +* When specifying function arguments via ``py::arg``, the test that verifies + the number of arguments now runs at compile time. +* Added ``[[noreturn]]`` attribute to ``pybind11_fail()`` to quench some + compiler warnings +* List function arguments in exception text when the dispatch code cannot find + a matching overload +* Added ``PYBIND11_OVERLOAD_NAME`` and ``PYBIND11_OVERLOAD_PURE_NAME`` macros which + can be used to override virtual methods whose name differs in C++ and Python + (e.g. ``__call__`` and ``operator()``) +* Various minor ``iterator`` and ``make_iterator()`` improvements +* Transparently support ``__bool__`` on Python 2.x and Python 3.x +* Fixed issue with destructor of unpickled object not being called +* Minor CMake build system improvements on Windows +* New ``pybind11::args`` and ``pybind11::kwargs`` types to create functions which + take an arbitrary number of arguments and keyword arguments +* New syntax to call a Python function from C++ using ``*args`` and ``*kwargs`` +* The functions ``def_property_*`` now correctly process docstring arguments (these + formerly caused a segmentation fault) +* Many ``mkdoc.py`` improvements (enumerations, template arguments, ``DOC()`` + macro accepts more arguments) +* Cygwin support +* Documentation improvements (pickling support, ``keep_alive``, macro usage) + +1.7 (April 30, 2016) +---------------------- +* Added a new ``move`` return value policy that triggers C++11 move semantics. + The automatic return value policy falls back to this case whenever a rvalue + reference is encountered +* Significantly more general GIL state routines that are used instead of + Python's troublesome ``PyGILState_Ensure`` and ``PyGILState_Release`` API +* Redesign of opaque types that drastically simplifies their usage +* Extended ability to pass values of type ``[const] void *`` +* ``keep_alive`` fix: don't fail when there is no patient +* ``functional.h``: acquire the GIL before calling a Python function +* Added Python RAII type wrappers ``none`` and ``iterable`` +* Added ``*args`` and ``*kwargs`` pass-through parameters to + ``pybind11.get_include()`` function +* Iterator improvements and fixes +* Documentation on return value policies and opaque types improved + +1.6 (April 30, 2016) +---------------------- +* Skipped due to upload to PyPI gone wrong and inability to recover + (https://github.com/pypa/packaging-problems/issues/74) + +1.5 (April 21, 2016) +---------------------- +* For polymorphic types, use RTTI to try to return the closest type registered with pybind11 +* Pickling support for serializing and unserializing C++ instances to a byte stream in Python +* Added a convenience routine ``make_iterator()`` which turns a range indicated + by a pair of C++ iterators into a iterable Python object +* Added ``len()`` and a variadic ``make_tuple()`` function +* Addressed a rare issue that could confuse the current virtual function + dispatcher and another that could lead to crashes in multi-threaded + applications +* Added a ``get_include()`` function to the Python module that returns the path + of the directory containing the installed pybind11 header files +* Documentation improvements: import issues, symbol visibility, pickling, limitations +* Added casting support for ``std::reference_wrapper<>`` + +1.4 (April 7, 2016) +-------------------------- +* Transparent type conversion for ``std::wstring`` and ``wchar_t`` +* Allow passing ``nullptr``-valued strings +* Transparent passing of ``void *`` pointers using capsules +* Transparent support for returning values wrapped in ``std::unique_ptr<>`` +* Improved docstring generation for compatibility with Sphinx +* Nicer debug error message when default parameter construction fails +* Support for "opaque" types that bypass the transparent conversion layer for STL containers +* Redesigned type casting interface to avoid ambiguities that could occasionally cause compiler errors +* Redesigned property implementation; fixes crashes due to an unfortunate default return value policy +* Anaconda package generation support + +1.3 (March 8, 2016) +-------------------------- + +* Added support for the Intel C++ compiler (v15+) +* Added support for the STL unordered set/map data structures +* Added support for the STL linked list data structure +* NumPy-style broadcasting support in ``pybind11::vectorize`` +* pybind11 now displays more verbose error messages when ``arg::operator=()`` fails +* pybind11 internal data structures now live in a version-dependent namespace to avoid ABI issues +* Many, many bugfixes involving corner cases and advanced usage + +1.2 (February 7, 2016) +-------------------------- + +* Optional: efficient generation of function signatures at compile time using C++14 +* Switched to a simpler and more general way of dealing with function default + arguments. Unused keyword arguments in function calls are now detected and + cause errors as expected +* New ``keep_alive`` call policy analogous to Boost.Python's ``with_custodian_and_ward`` +* New ``pybind11::base<>`` attribute to indicate a subclass relationship +* Improved interface for RAII type wrappers in ``pytypes.h`` +* Use RAII type wrappers consistently within pybind11 itself. This + fixes various potential refcount leaks when exceptions occur +* Added new ``bytes`` RAII type wrapper (maps to ``string`` in Python 2.7) +* Made handle and related RAII classes const correct, using them more + consistently everywhere now +* Got rid of the ugly ``__pybind11__`` attributes on the Python side---they are + now stored in a C++ hash table that is not visible in Python +* Fixed refcount leaks involving NumPy arrays and bound functions +* Vastly improved handling of shared/smart pointers +* Removed an unnecessary copy operation in ``pybind11::vectorize`` +* Fixed naming clashes when both pybind11 and NumPy headers are included +* Added conversions for additional exception types +* Documentation improvements (using multiple extension modules, smart pointers, + other minor clarifications) +* unified infrastructure for parsing variadic arguments in ``class_`` and cpp_function +* Fixed license text (was: ZLIB, should have been: 3-clause BSD) +* Python 3.2 compatibility +* Fixed remaining issues when accessing types in another plugin module +* Added enum comparison and casting methods +* Improved SFINAE-based detection of whether types are copy-constructible +* Eliminated many warnings about unused variables and the use of ``offsetof()`` +* Support for ``std::array<>`` conversions + +1.1 (December 7, 2015) +-------------------------- + +* Documentation improvements (GIL, wrapping functions, casting, fixed many typos) +* Generalized conversion of integer types +* Improved support for casting function objects +* Improved support for ``std::shared_ptr<>`` conversions +* Initial support for ``std::set<>`` conversions +* Fixed type resolution issue for types defined in a separate plugin module +* CMake build system improvements +* Factored out generic functionality to non-templated code (smaller code size) +* Added a code size / compile time benchmark vs Boost.Python +* Added an appveyor CI script + +1.0 (October 15, 2015) +------------------------ +* Initial release diff --git a/dmff/dpnblist/external/pybind11-2.11.1/docs/classes.rst b/dmff/dpnblist/external/pybind11-2.11.1/docs/classes.rst new file mode 100644 index 00000000..4f2167da --- /dev/null +++ b/dmff/dpnblist/external/pybind11-2.11.1/docs/classes.rst @@ -0,0 +1,555 @@ +.. _classes: + +Object-oriented code +#################### + +Creating bindings for a custom type +=================================== + +Let's now look at a more complex example where we'll create bindings for a +custom C++ data structure named ``Pet``. Its definition is given below: + +.. code-block:: cpp + + struct Pet { + Pet(const std::string &name) : name(name) { } + void setName(const std::string &name_) { name = name_; } + const std::string &getName() const { return name; } + + std::string name; + }; + +The binding code for ``Pet`` looks as follows: + +.. code-block:: cpp + + #include + + namespace py = pybind11; + + PYBIND11_MODULE(example, m) { + py::class_(m, "Pet") + .def(py::init()) + .def("setName", &Pet::setName) + .def("getName", &Pet::getName); + } + +:class:`class_` creates bindings for a C++ *class* or *struct*-style data +structure. :func:`init` is a convenience function that takes the types of a +constructor's parameters as template arguments and wraps the corresponding +constructor (see the :ref:`custom_constructors` section for details). An +interactive Python session demonstrating this example is shown below: + +.. code-block:: pycon + + % python + >>> import example + >>> p = example.Pet("Molly") + >>> print(p) + + >>> p.getName() + 'Molly' + >>> p.setName("Charly") + >>> p.getName() + 'Charly' + +.. seealso:: + + Static member functions can be bound in the same way using + :func:`class_::def_static`. + +.. note:: + + Binding C++ types in unnamed namespaces (also known as anonymous namespaces) + works reliably on many platforms, but not all. The `XFAIL_CONDITION` in + tests/test_unnamed_namespace_a.py encodes the currently known conditions. + For background see `#4319 `_. + If portability is a concern, it is therefore not recommended to bind C++ + types in unnamed namespaces. It will be safest to manually pick unique + namespace names. + +Keyword and default arguments +============================= +It is possible to specify keyword and default arguments using the syntax +discussed in the previous chapter. Refer to the sections :ref:`keyword_args` +and :ref:`default_args` for details. + +Binding lambda functions +======================== + +Note how ``print(p)`` produced a rather useless summary of our data structure in the example above: + +.. code-block:: pycon + + >>> print(p) + + +To address this, we could bind a utility function that returns a human-readable +summary to the special method slot named ``__repr__``. Unfortunately, there is no +suitable functionality in the ``Pet`` data structure, and it would be nice if +we did not have to change it. This can easily be accomplished by binding a +Lambda function instead: + +.. code-block:: cpp + + py::class_(m, "Pet") + .def(py::init()) + .def("setName", &Pet::setName) + .def("getName", &Pet::getName) + .def("__repr__", + [](const Pet &a) { + return ""; + } + ); + +Both stateless [#f1]_ and stateful lambda closures are supported by pybind11. +With the above change, the same Python code now produces the following output: + +.. code-block:: pycon + + >>> print(p) + + +.. [#f1] Stateless closures are those with an empty pair of brackets ``[]`` as the capture object. + +.. _properties: + +Instance and static fields +========================== + +We can also directly expose the ``name`` field using the +:func:`class_::def_readwrite` method. A similar :func:`class_::def_readonly` +method also exists for ``const`` fields. + +.. code-block:: cpp + + py::class_(m, "Pet") + .def(py::init()) + .def_readwrite("name", &Pet::name) + // ... remainder ... + +This makes it possible to write + +.. code-block:: pycon + + >>> p = example.Pet("Molly") + >>> p.name + 'Molly' + >>> p.name = "Charly" + >>> p.name + 'Charly' + +Now suppose that ``Pet::name`` was a private internal variable +that can only be accessed via setters and getters. + +.. code-block:: cpp + + class Pet { + public: + Pet(const std::string &name) : name(name) { } + void setName(const std::string &name_) { name = name_; } + const std::string &getName() const { return name; } + private: + std::string name; + }; + +In this case, the method :func:`class_::def_property` +(:func:`class_::def_property_readonly` for read-only data) can be used to +provide a field-like interface within Python that will transparently call +the setter and getter functions: + +.. code-block:: cpp + + py::class_(m, "Pet") + .def(py::init()) + .def_property("name", &Pet::getName, &Pet::setName) + // ... remainder ... + +Write only properties can be defined by passing ``nullptr`` as the +input for the read function. + +.. seealso:: + + Similar functions :func:`class_::def_readwrite_static`, + :func:`class_::def_readonly_static` :func:`class_::def_property_static`, + and :func:`class_::def_property_readonly_static` are provided for binding + static variables and properties. Please also see the section on + :ref:`static_properties` in the advanced part of the documentation. + +Dynamic attributes +================== + +Native Python classes can pick up new attributes dynamically: + +.. code-block:: pycon + + >>> class Pet: + ... name = "Molly" + ... + >>> p = Pet() + >>> p.name = "Charly" # overwrite existing + >>> p.age = 2 # dynamically add a new attribute + +By default, classes exported from C++ do not support this and the only writable +attributes are the ones explicitly defined using :func:`class_::def_readwrite` +or :func:`class_::def_property`. + +.. code-block:: cpp + + py::class_(m, "Pet") + .def(py::init<>()) + .def_readwrite("name", &Pet::name); + +Trying to set any other attribute results in an error: + +.. code-block:: pycon + + >>> p = example.Pet() + >>> p.name = "Charly" # OK, attribute defined in C++ + >>> p.age = 2 # fail + AttributeError: 'Pet' object has no attribute 'age' + +To enable dynamic attributes for C++ classes, the :class:`py::dynamic_attr` tag +must be added to the :class:`py::class_` constructor: + +.. code-block:: cpp + + py::class_(m, "Pet", py::dynamic_attr()) + .def(py::init<>()) + .def_readwrite("name", &Pet::name); + +Now everything works as expected: + +.. code-block:: pycon + + >>> p = example.Pet() + >>> p.name = "Charly" # OK, overwrite value in C++ + >>> p.age = 2 # OK, dynamically add a new attribute + >>> p.__dict__ # just like a native Python class + {'age': 2} + +Note that there is a small runtime cost for a class with dynamic attributes. +Not only because of the addition of a ``__dict__``, but also because of more +expensive garbage collection tracking which must be activated to resolve +possible circular references. Native Python classes incur this same cost by +default, so this is not anything to worry about. By default, pybind11 classes +are more efficient than native Python classes. Enabling dynamic attributes +just brings them on par. + +.. _inheritance: + +Inheritance and automatic downcasting +===================================== + +Suppose now that the example consists of two data structures with an +inheritance relationship: + +.. code-block:: cpp + + struct Pet { + Pet(const std::string &name) : name(name) { } + std::string name; + }; + + struct Dog : Pet { + Dog(const std::string &name) : Pet(name) { } + std::string bark() const { return "woof!"; } + }; + +There are two different ways of indicating a hierarchical relationship to +pybind11: the first specifies the C++ base class as an extra template +parameter of the :class:`class_`: + +.. code-block:: cpp + + py::class_(m, "Pet") + .def(py::init()) + .def_readwrite("name", &Pet::name); + + // Method 1: template parameter: + py::class_(m, "Dog") + .def(py::init()) + .def("bark", &Dog::bark); + +Alternatively, we can also assign a name to the previously bound ``Pet`` +:class:`class_` object and reference it when binding the ``Dog`` class: + +.. code-block:: cpp + + py::class_ pet(m, "Pet"); + pet.def(py::init()) + .def_readwrite("name", &Pet::name); + + // Method 2: pass parent class_ object: + py::class_(m, "Dog", pet /* <- specify Python parent type */) + .def(py::init()) + .def("bark", &Dog::bark); + +Functionality-wise, both approaches are equivalent. Afterwards, instances will +expose fields and methods of both types: + +.. code-block:: pycon + + >>> p = example.Dog("Molly") + >>> p.name + 'Molly' + >>> p.bark() + 'woof!' + +The C++ classes defined above are regular non-polymorphic types with an +inheritance relationship. This is reflected in Python: + +.. code-block:: cpp + + // Return a base pointer to a derived instance + m.def("pet_store", []() { return std::unique_ptr(new Dog("Molly")); }); + +.. code-block:: pycon + + >>> p = example.pet_store() + >>> type(p) # `Dog` instance behind `Pet` pointer + Pet # no pointer downcasting for regular non-polymorphic types + >>> p.bark() + AttributeError: 'Pet' object has no attribute 'bark' + +The function returned a ``Dog`` instance, but because it's a non-polymorphic +type behind a base pointer, Python only sees a ``Pet``. In C++, a type is only +considered polymorphic if it has at least one virtual function and pybind11 +will automatically recognize this: + +.. code-block:: cpp + + struct PolymorphicPet { + virtual ~PolymorphicPet() = default; + }; + + struct PolymorphicDog : PolymorphicPet { + std::string bark() const { return "woof!"; } + }; + + // Same binding code + py::class_(m, "PolymorphicPet"); + py::class_(m, "PolymorphicDog") + .def(py::init<>()) + .def("bark", &PolymorphicDog::bark); + + // Again, return a base pointer to a derived instance + m.def("pet_store2", []() { return std::unique_ptr(new PolymorphicDog); }); + +.. code-block:: pycon + + >>> p = example.pet_store2() + >>> type(p) + PolymorphicDog # automatically downcast + >>> p.bark() + 'woof!' + +Given a pointer to a polymorphic base, pybind11 performs automatic downcasting +to the actual derived type. Note that this goes beyond the usual situation in +C++: we don't just get access to the virtual functions of the base, we get the +concrete derived type including functions and attributes that the base type may +not even be aware of. + +.. seealso:: + + For more information about polymorphic behavior see :ref:`overriding_virtuals`. + + +Overloaded methods +================== + +Sometimes there are several overloaded C++ methods with the same name taking +different kinds of input arguments: + +.. code-block:: cpp + + struct Pet { + Pet(const std::string &name, int age) : name(name), age(age) { } + + void set(int age_) { age = age_; } + void set(const std::string &name_) { name = name_; } + + std::string name; + int age; + }; + +Attempting to bind ``Pet::set`` will cause an error since the compiler does not +know which method the user intended to select. We can disambiguate by casting +them to function pointers. Binding multiple functions to the same Python name +automatically creates a chain of function overloads that will be tried in +sequence. + +.. code-block:: cpp + + py::class_(m, "Pet") + .def(py::init()) + .def("set", static_cast(&Pet::set), "Set the pet's age") + .def("set", static_cast(&Pet::set), "Set the pet's name"); + +The overload signatures are also visible in the method's docstring: + +.. code-block:: pycon + + >>> help(example.Pet) + + class Pet(__builtin__.object) + | Methods defined here: + | + | __init__(...) + | Signature : (Pet, str, int) -> NoneType + | + | set(...) + | 1. Signature : (Pet, int) -> NoneType + | + | Set the pet's age + | + | 2. Signature : (Pet, str) -> NoneType + | + | Set the pet's name + +If you have a C++14 compatible compiler [#cpp14]_, you can use an alternative +syntax to cast the overloaded function: + +.. code-block:: cpp + + py::class_(m, "Pet") + .def("set", py::overload_cast(&Pet::set), "Set the pet's age") + .def("set", py::overload_cast(&Pet::set), "Set the pet's name"); + +Here, ``py::overload_cast`` only requires the parameter types to be specified. +The return type and class are deduced. This avoids the additional noise of +``void (Pet::*)()`` as seen in the raw cast. If a function is overloaded based +on constness, the ``py::const_`` tag should be used: + +.. code-block:: cpp + + struct Widget { + int foo(int x, float y); + int foo(int x, float y) const; + }; + + py::class_(m, "Widget") + .def("foo_mutable", py::overload_cast(&Widget::foo)) + .def("foo_const", py::overload_cast(&Widget::foo, py::const_)); + +If you prefer the ``py::overload_cast`` syntax but have a C++11 compatible compiler only, +you can use ``py::detail::overload_cast_impl`` with an additional set of parentheses: + +.. code-block:: cpp + + template + using overload_cast_ = pybind11::detail::overload_cast_impl; + + py::class_(m, "Pet") + .def("set", overload_cast_()(&Pet::set), "Set the pet's age") + .def("set", overload_cast_()(&Pet::set), "Set the pet's name"); + +.. [#cpp14] A compiler which supports the ``-std=c++14`` flag. + +.. note:: + + To define multiple overloaded constructors, simply declare one after the + other using the ``.def(py::init<...>())`` syntax. The existing machinery + for specifying keyword and default arguments also works. + +Enumerations and internal types +=============================== + +Let's now suppose that the example class contains internal types like enumerations, e.g.: + +.. code-block:: cpp + + struct Pet { + enum Kind { + Dog = 0, + Cat + }; + + struct Attributes { + float age = 0; + }; + + Pet(const std::string &name, Kind type) : name(name), type(type) { } + + std::string name; + Kind type; + Attributes attr; + }; + +The binding code for this example looks as follows: + +.. code-block:: cpp + + py::class_ pet(m, "Pet"); + + pet.def(py::init()) + .def_readwrite("name", &Pet::name) + .def_readwrite("type", &Pet::type) + .def_readwrite("attr", &Pet::attr); + + py::enum_(pet, "Kind") + .value("Dog", Pet::Kind::Dog) + .value("Cat", Pet::Kind::Cat) + .export_values(); + + py::class_(pet, "Attributes") + .def(py::init<>()) + .def_readwrite("age", &Pet::Attributes::age); + + +To ensure that the nested types ``Kind`` and ``Attributes`` are created within the scope of ``Pet``, the +``pet`` :class:`class_` instance must be supplied to the :class:`enum_` and :class:`class_` +constructor. The :func:`enum_::export_values` function exports the enum entries +into the parent scope, which should be skipped for newer C++11-style strongly +typed enums. + +.. code-block:: pycon + + >>> p = Pet("Lucy", Pet.Cat) + >>> p.type + Kind.Cat + >>> int(p.type) + 1L + +The entries defined by the enumeration type are exposed in the ``__members__`` property: + +.. code-block:: pycon + + >>> Pet.Kind.__members__ + {'Dog': Kind.Dog, 'Cat': Kind.Cat} + +The ``name`` property returns the name of the enum value as a unicode string. + +.. note:: + + It is also possible to use ``str(enum)``, however these accomplish different + goals. The following shows how these two approaches differ. + + .. code-block:: pycon + + >>> p = Pet("Lucy", Pet.Cat) + >>> pet_type = p.type + >>> pet_type + Pet.Cat + >>> str(pet_type) + 'Pet.Cat' + >>> pet_type.name + 'Cat' + +.. note:: + + When the special tag ``py::arithmetic()`` is specified to the ``enum_`` + constructor, pybind11 creates an enumeration that also supports rudimentary + arithmetic and bit-level operations like comparisons, and, or, xor, negation, + etc. + + .. code-block:: cpp + + py::enum_(pet, "Kind", py::arithmetic()) + ... + + By default, these are omitted to conserve space. + +.. warning:: + + Contrary to Python customs, enum values from the wrappers should not be compared using ``is``, but with ``==`` (see `#1177 `_ for background). diff --git a/dmff/dpnblist/external/pybind11-2.11.1/docs/cmake/index.rst b/dmff/dpnblist/external/pybind11-2.11.1/docs/cmake/index.rst new file mode 100644 index 00000000..eaf66d70 --- /dev/null +++ b/dmff/dpnblist/external/pybind11-2.11.1/docs/cmake/index.rst @@ -0,0 +1,8 @@ +CMake helpers +------------- + +Pybind11 can be used with ``add_subdirectory(extern/pybind11)``, or from an +install with ``find_package(pybind11 CONFIG)``. The interface provided in +either case is functionally identical. + +.. cmake-module:: ../../tools/pybind11Config.cmake.in diff --git a/dmff/dpnblist/external/pybind11-2.11.1/docs/compiling.rst b/dmff/dpnblist/external/pybind11-2.11.1/docs/compiling.rst new file mode 100644 index 00000000..1fd098be --- /dev/null +++ b/dmff/dpnblist/external/pybind11-2.11.1/docs/compiling.rst @@ -0,0 +1,641 @@ +.. _compiling: + +Build systems +############# + +.. _build-setuptools: + +Building with setuptools +======================== + +For projects on PyPI, building with setuptools is the way to go. Sylvain Corlay +has kindly provided an example project which shows how to set up everything, +including automatic generation of documentation using Sphinx. Please refer to +the [python_example]_ repository. + +.. [python_example] https://github.com/pybind/python_example + +A helper file is provided with pybind11 that can simplify usage with setuptools. + +To use pybind11 inside your ``setup.py``, you have to have some system to +ensure that ``pybind11`` is installed when you build your package. There are +four possible ways to do this, and pybind11 supports all four: You can ask all +users to install pybind11 beforehand (bad), you can use +:ref:`setup_helpers-pep518` (good, but very new and requires Pip 10), +:ref:`setup_helpers-setup_requires` (discouraged by Python packagers now that +PEP 518 is available, but it still works everywhere), or you can +:ref:`setup_helpers-copy-manually` (always works but you have to manually sync +your copy to get updates). + +An example of a ``setup.py`` using pybind11's helpers: + +.. code-block:: python + + from glob import glob + from setuptools import setup + from pybind11.setup_helpers import Pybind11Extension + + ext_modules = [ + Pybind11Extension( + "python_example", + sorted(glob("src/*.cpp")), # Sort source files for reproducibility + ), + ] + + setup(..., ext_modules=ext_modules) + +If you want to do an automatic search for the highest supported C++ standard, +that is supported via a ``build_ext`` command override; it will only affect +``Pybind11Extensions``: + +.. code-block:: python + + from glob import glob + from setuptools import setup + from pybind11.setup_helpers import Pybind11Extension, build_ext + + ext_modules = [ + Pybind11Extension( + "python_example", + sorted(glob("src/*.cpp")), + ), + ] + + setup(..., cmdclass={"build_ext": build_ext}, ext_modules=ext_modules) + +If you have single-file extension modules that are directly stored in the +Python source tree (``foo.cpp`` in the same directory as where a ``foo.py`` +would be located), you can also generate ``Pybind11Extensions`` using +``setup_helpers.intree_extensions``: ``intree_extensions(["path/to/foo.cpp", +...])`` returns a list of ``Pybind11Extensions`` which can be passed to +``ext_modules``, possibly after further customizing their attributes +(``libraries``, ``include_dirs``, etc.). By doing so, a ``foo.*.so`` extension +module will be generated and made available upon installation. + +``intree_extension`` will automatically detect if you are using a ``src``-style +layout (as long as no namespace packages are involved), but you can also +explicitly pass ``package_dir`` to it (as in ``setuptools.setup``). + +Since pybind11 does not require NumPy when building, a light-weight replacement +for NumPy's parallel compilation distutils tool is included. Use it like this: + +.. code-block:: python + + from pybind11.setup_helpers import ParallelCompile + + # Optional multithreaded build + ParallelCompile("NPY_NUM_BUILD_JOBS").install() + + setup(...) + +The argument is the name of an environment variable to control the number of +threads, such as ``NPY_NUM_BUILD_JOBS`` (as used by NumPy), though you can set +something different if you want; ``CMAKE_BUILD_PARALLEL_LEVEL`` is another choice +a user might expect. You can also pass ``default=N`` to set the default number +of threads (0 will take the number of threads available) and ``max=N``, the +maximum number of threads; if you have a large extension you may want set this +to a memory dependent number. + +If you are developing rapidly and have a lot of C++ files, you may want to +avoid rebuilding files that have not changed. For simple cases were you are +using ``pip install -e .`` and do not have local headers, you can skip the +rebuild if an object file is newer than its source (headers are not checked!) +with the following: + +.. code-block:: python + + from pybind11.setup_helpers import ParallelCompile, naive_recompile + + ParallelCompile("NPY_NUM_BUILD_JOBS", needs_recompile=naive_recompile).install() + + +If you have a more complex build, you can implement a smarter function and pass +it to ``needs_recompile``, or you can use [Ccache]_ instead. ``CXX="cache g++" +pip install -e .`` would be the way to use it with GCC, for example. Unlike the +simple solution, this even works even when not compiling in editable mode, but +it does require Ccache to be installed. + +Keep in mind that Pip will not even attempt to rebuild if it thinks it has +already built a copy of your code, which it deduces from the version number. +One way to avoid this is to use [setuptools_scm]_, which will generate a +version number that includes the number of commits since your last tag and a +hash for a dirty directory. Another way to force a rebuild is purge your cache +or use Pip's ``--no-cache-dir`` option. + +.. [Ccache] https://ccache.dev + +.. [setuptools_scm] https://github.com/pypa/setuptools_scm + +.. _setup_helpers-pep518: + +PEP 518 requirements (Pip 10+ required) +--------------------------------------- + +If you use `PEP 518's `_ +``pyproject.toml`` file, you can ensure that ``pybind11`` is available during +the compilation of your project. When this file exists, Pip will make a new +virtual environment, download just the packages listed here in ``requires=``, +and build a wheel (binary Python package). It will then throw away the +environment, and install your wheel. + +Your ``pyproject.toml`` file will likely look something like this: + +.. code-block:: toml + + [build-system] + requires = ["setuptools>=42", "wheel", "pybind11~=2.6.1"] + build-backend = "setuptools.build_meta" + +.. note:: + + The main drawback to this method is that a `PEP 517`_ compliant build tool, + such as Pip 10+, is required for this approach to work; older versions of + Pip completely ignore this file. If you distribute binaries (called wheels + in Python) using something like `cibuildwheel`_, remember that ``setup.py`` + and ``pyproject.toml`` are not even contained in the wheel, so this high + Pip requirement is only for source builds, and will not affect users of + your binary wheels. If you are building SDists and wheels, then + `pypa-build`_ is the recommended official tool. + +.. _PEP 517: https://www.python.org/dev/peps/pep-0517/ +.. _cibuildwheel: https://cibuildwheel.readthedocs.io +.. _pypa-build: https://pypa-build.readthedocs.io/en/latest/ + +.. _setup_helpers-setup_requires: + +Classic ``setup_requires`` +-------------------------- + +If you want to support old versions of Pip with the classic +``setup_requires=["pybind11"]`` keyword argument to setup, which triggers a +two-phase ``setup.py`` run, then you will need to use something like this to +ensure the first pass works (which has not yet installed the ``setup_requires`` +packages, since it can't install something it does not know about): + +.. code-block:: python + + try: + from pybind11.setup_helpers import Pybind11Extension + except ImportError: + from setuptools import Extension as Pybind11Extension + + +It doesn't matter that the Extension class is not the enhanced subclass for the +first pass run; and the second pass will have the ``setup_requires`` +requirements. + +This is obviously more of a hack than the PEP 518 method, but it supports +ancient versions of Pip. + +.. _setup_helpers-copy-manually: + +Copy manually +------------- + +You can also copy ``setup_helpers.py`` directly to your project; it was +designed to be usable standalone, like the old example ``setup.py``. You can +set ``include_pybind11=False`` to skip including the pybind11 package headers, +so you can use it with git submodules and a specific git version. If you use +this, you will need to import from a local file in ``setup.py`` and ensure the +helper file is part of your MANIFEST. + + +Closely related, if you include pybind11 as a subproject, you can run the +``setup_helpers.py`` inplace. If loaded correctly, this should even pick up +the correct include for pybind11, though you can turn it off as shown above if +you want to input it manually. + +Suggested usage if you have pybind11 as a submodule in ``extern/pybind11``: + +.. code-block:: python + + DIR = os.path.abspath(os.path.dirname(__file__)) + + sys.path.append(os.path.join(DIR, "extern", "pybind11")) + from pybind11.setup_helpers import Pybind11Extension # noqa: E402 + + del sys.path[-1] + + +.. versionchanged:: 2.6 + + Added ``setup_helpers`` file. + +Building with cppimport +======================== + +[cppimport]_ is a small Python import hook that determines whether there is a C++ +source file whose name matches the requested module. If there is, the file is +compiled as a Python extension using pybind11 and placed in the same folder as +the C++ source file. Python is then able to find the module and load it. + +.. [cppimport] https://github.com/tbenthompson/cppimport + +.. _cmake: + +Building with CMake +=================== + +For C++ codebases that have an existing CMake-based build system, a Python +extension module can be created with just a few lines of code: + +.. code-block:: cmake + + cmake_minimum_required(VERSION 3.5...3.26) + project(example LANGUAGES CXX) + + add_subdirectory(pybind11) + pybind11_add_module(example example.cpp) + +This assumes that the pybind11 repository is located in a subdirectory named +:file:`pybind11` and that the code is located in a file named :file:`example.cpp`. +The CMake command ``add_subdirectory`` will import the pybind11 project which +provides the ``pybind11_add_module`` function. It will take care of all the +details needed to build a Python extension module on any platform. + +A working sample project, including a way to invoke CMake from :file:`setup.py` for +PyPI integration, can be found in the [cmake_example]_ repository. + +.. [cmake_example] https://github.com/pybind/cmake_example + +.. versionchanged:: 2.6 + CMake 3.4+ is required. + +.. versionchanged:: 2.11 + CMake 3.5+ is required. + +Further information can be found at :doc:`cmake/index`. + +pybind11_add_module +------------------- + +To ease the creation of Python extension modules, pybind11 provides a CMake +function with the following signature: + +.. code-block:: cmake + + pybind11_add_module( [MODULE | SHARED] [EXCLUDE_FROM_ALL] + [NO_EXTRAS] [THIN_LTO] [OPT_SIZE] source1 [source2 ...]) + +This function behaves very much like CMake's builtin ``add_library`` (in fact, +it's a wrapper function around that command). It will add a library target +called ```` to be built from the listed source files. In addition, it +will take care of all the Python-specific compiler and linker flags as well +as the OS- and Python-version-specific file extension. The produced target +```` can be further manipulated with regular CMake commands. + +``MODULE`` or ``SHARED`` may be given to specify the type of library. If no +type is given, ``MODULE`` is used by default which ensures the creation of a +Python-exclusive module. Specifying ``SHARED`` will create a more traditional +dynamic library which can also be linked from elsewhere. ``EXCLUDE_FROM_ALL`` +removes this target from the default build (see CMake docs for details). + +Since pybind11 is a template library, ``pybind11_add_module`` adds compiler +flags to ensure high quality code generation without bloat arising from long +symbol names and duplication of code in different translation units. It +sets default visibility to *hidden*, which is required for some pybind11 +features and functionality when attempting to load multiple pybind11 modules +compiled under different pybind11 versions. It also adds additional flags +enabling LTO (Link Time Optimization) and strip unneeded symbols. See the +:ref:`FAQ entry ` for a more detailed explanation. These +latter optimizations are never applied in ``Debug`` mode. If ``NO_EXTRAS`` is +given, they will always be disabled, even in ``Release`` mode. However, this +will result in code bloat and is generally not recommended. + +As stated above, LTO is enabled by default. Some newer compilers also support +different flavors of LTO such as `ThinLTO`_. Setting ``THIN_LTO`` will cause +the function to prefer this flavor if available. The function falls back to +regular LTO if ``-flto=thin`` is not available. If +``CMAKE_INTERPROCEDURAL_OPTIMIZATION`` is set (either ``ON`` or ``OFF``), then +that will be respected instead of the built-in flag search. + +.. note:: + + If you want to set the property form on targets or the + ``CMAKE_INTERPROCEDURAL_OPTIMIZATION_`` versions of this, you should + still use ``set(CMAKE_INTERPROCEDURAL_OPTIMIZATION OFF)`` (otherwise a + no-op) to disable pybind11's ipo flags. + +The ``OPT_SIZE`` flag enables size-based optimization equivalent to the +standard ``/Os`` or ``-Os`` compiler flags and the ``MinSizeRel`` build type, +which avoid optimizations that that can substantially increase the size of the +resulting binary. This flag is particularly useful in projects that are split +into performance-critical parts and associated bindings. In this case, we can +compile the project in release mode (and hence, optimize performance globally), +and specify ``OPT_SIZE`` for the binding target, where size might be the main +concern as performance is often less critical here. A ~25% size reduction has +been observed in practice. This flag only changes the optimization behavior at +a per-target level and takes precedence over the global CMake build type +(``Release``, ``RelWithDebInfo``) except for ``Debug`` builds, where +optimizations remain disabled. + +.. _ThinLTO: http://clang.llvm.org/docs/ThinLTO.html + +Configuration variables +----------------------- + +By default, pybind11 will compile modules with the compiler default or the +minimum standard required by pybind11, whichever is higher. You can set the +standard explicitly with +`CMAKE_CXX_STANDARD `_: + +.. code-block:: cmake + + set(CMAKE_CXX_STANDARD 14 CACHE STRING "C++ version selection") # or 11, 14, 17, 20 + set(CMAKE_CXX_STANDARD_REQUIRED ON) # optional, ensure standard is supported + set(CMAKE_CXX_EXTENSIONS OFF) # optional, keep compiler extensions off + +The variables can also be set when calling CMake from the command line using +the ``-D=`` flag. You can also manually set ``CXX_STANDARD`` +on a target or use ``target_compile_features`` on your targets - anything that +CMake supports. + +Classic Python support: The target Python version can be selected by setting +``PYBIND11_PYTHON_VERSION`` or an exact Python installation can be specified +with ``PYTHON_EXECUTABLE``. For example: + +.. code-block:: bash + + cmake -DPYBIND11_PYTHON_VERSION=3.6 .. + + # Another method: + cmake -DPYTHON_EXECUTABLE=/path/to/python .. + + # This often is a good way to get the current Python, works in environments: + cmake -DPYTHON_EXECUTABLE=$(python3 -c "import sys; print(sys.executable)") .. + + +find_package vs. add_subdirectory +--------------------------------- + +For CMake-based projects that don't include the pybind11 repository internally, +an external installation can be detected through ``find_package(pybind11)``. +See the `Config file`_ docstring for details of relevant CMake variables. + +.. code-block:: cmake + + cmake_minimum_required(VERSION 3.4...3.18) + project(example LANGUAGES CXX) + + find_package(pybind11 REQUIRED) + pybind11_add_module(example example.cpp) + +Note that ``find_package(pybind11)`` will only work correctly if pybind11 +has been correctly installed on the system, e. g. after downloading or cloning +the pybind11 repository : + +.. code-block:: bash + + # Classic CMake + cd pybind11 + mkdir build + cd build + cmake .. + make install + + # CMake 3.15+ + cd pybind11 + cmake -S . -B build + cmake --build build -j 2 # Build on 2 cores + cmake --install build + +Once detected, the aforementioned ``pybind11_add_module`` can be employed as +before. The function usage and configuration variables are identical no matter +if pybind11 is added as a subdirectory or found as an installed package. You +can refer to the same [cmake_example]_ repository for a full sample project +-- just swap out ``add_subdirectory`` for ``find_package``. + +.. _Config file: https://github.com/pybind/pybind11/blob/master/tools/pybind11Config.cmake.in + + +.. _find-python-mode: + +FindPython mode +--------------- + +CMake 3.12+ (3.15+ recommended, 3.18.2+ ideal) added a new module called +FindPython that had a highly improved search algorithm and modern targets +and tools. If you use FindPython, pybind11 will detect this and use the +existing targets instead: + +.. code-block:: cmake + + cmake_minimum_required(VERSION 3.15...3.22) + project(example LANGUAGES CXX) + + find_package(Python 3.6 COMPONENTS Interpreter Development REQUIRED) + find_package(pybind11 CONFIG REQUIRED) + # or add_subdirectory(pybind11) + + pybind11_add_module(example example.cpp) + +You can also use the targets (as listed below) with FindPython. If you define +``PYBIND11_FINDPYTHON``, pybind11 will perform the FindPython step for you +(mostly useful when building pybind11's own tests, or as a way to change search +algorithms from the CMake invocation, with ``-DPYBIND11_FINDPYTHON=ON``. + +.. warning:: + + If you use FindPython to multi-target Python versions, use the individual + targets listed below, and avoid targets that directly include Python parts. + +There are `many ways to hint or force a discovery of a specific Python +installation `_), +setting ``Python_ROOT_DIR`` may be the most common one (though with +virtualenv/venv support, and Conda support, this tends to find the correct +Python version more often than the old system did). + +.. warning:: + + When the Python libraries (i.e. ``libpythonXX.a`` and ``libpythonXX.so`` + on Unix) are not available, as is the case on a manylinux image, the + ``Development`` component will not be resolved by ``FindPython``. When not + using the embedding functionality, CMake 3.18+ allows you to specify + ``Development.Module`` instead of ``Development`` to resolve this issue. + +.. versionadded:: 2.6 + +Advanced: interface library targets +----------------------------------- + +Pybind11 supports modern CMake usage patterns with a set of interface targets, +available in all modes. The targets provided are: + + ``pybind11::headers`` + Just the pybind11 headers and minimum compile requirements + + ``pybind11::pybind11`` + Python headers + ``pybind11::headers`` + + ``pybind11::python_link_helper`` + Just the "linking" part of pybind11:module + + ``pybind11::module`` + Everything for extension modules - ``pybind11::pybind11`` + ``Python::Module`` (FindPython CMake 3.15+) or ``pybind11::python_link_helper`` + + ``pybind11::embed`` + Everything for embedding the Python interpreter - ``pybind11::pybind11`` + ``Python::Python`` (FindPython) or Python libs + + ``pybind11::lto`` / ``pybind11::thin_lto`` + An alternative to `INTERPROCEDURAL_OPTIMIZATION` for adding link-time optimization. + + ``pybind11::windows_extras`` + ``/bigobj`` and ``/mp`` for MSVC. + + ``pybind11::opt_size`` + ``/Os`` for MSVC, ``-Os`` for other compilers. Does nothing for debug builds. + +Two helper functions are also provided: + + ``pybind11_strip(target)`` + Strips a target (uses ``CMAKE_STRIP`` after the target is built) + + ``pybind11_extension(target)`` + Sets the correct extension (with SOABI) for a target. + +You can use these targets to build complex applications. For example, the +``add_python_module`` function is identical to: + +.. code-block:: cmake + + cmake_minimum_required(VERSION 3.5...3.26) + project(example LANGUAGES CXX) + + find_package(pybind11 REQUIRED) # or add_subdirectory(pybind11) + + add_library(example MODULE main.cpp) + + target_link_libraries(example PRIVATE pybind11::module pybind11::lto pybind11::windows_extras) + + pybind11_extension(example) + if(NOT MSVC AND NOT ${CMAKE_BUILD_TYPE} MATCHES Debug|RelWithDebInfo) + # Strip unnecessary sections of the binary on Linux/macOS + pybind11_strip(example) + endif() + + set_target_properties(example PROPERTIES CXX_VISIBILITY_PRESET "hidden" + CUDA_VISIBILITY_PRESET "hidden") + +Instead of setting properties, you can set ``CMAKE_*`` variables to initialize these correctly. + +.. warning:: + + Since pybind11 is a metatemplate library, it is crucial that certain + compiler flags are provided to ensure high quality code generation. In + contrast to the ``pybind11_add_module()`` command, the CMake interface + provides a *composable* set of targets to ensure that you retain flexibility. + It can be especially important to provide or set these properties; the + :ref:`FAQ ` contains an explanation on why these are needed. + +.. versionadded:: 2.6 + +.. _nopython-mode: + +Advanced: NOPYTHON mode +----------------------- + +If you want complete control, you can set ``PYBIND11_NOPYTHON`` to completely +disable Python integration (this also happens if you run ``FindPython2`` and +``FindPython3`` without running ``FindPython``). This gives you complete +freedom to integrate into an existing system (like `Scikit-Build's +`_ ``PythonExtensions``). +``pybind11_add_module`` and ``pybind11_extension`` will be unavailable, and the +targets will be missing any Python specific behavior. + +.. versionadded:: 2.6 + +Embedding the Python interpreter +-------------------------------- + +In addition to extension modules, pybind11 also supports embedding Python into +a C++ executable or library. In CMake, simply link with the ``pybind11::embed`` +target. It provides everything needed to get the interpreter running. The Python +headers and libraries are attached to the target. Unlike ``pybind11::module``, +there is no need to manually set any additional properties here. For more +information about usage in C++, see :doc:`/advanced/embedding`. + +.. code-block:: cmake + + cmake_minimum_required(VERSION 3.5...3.26) + project(example LANGUAGES CXX) + + find_package(pybind11 REQUIRED) # or add_subdirectory(pybind11) + + add_executable(example main.cpp) + target_link_libraries(example PRIVATE pybind11::embed) + +.. _building_manually: + +Building manually +================= + +pybind11 is a header-only library, hence it is not necessary to link against +any special libraries and there are no intermediate (magic) translation steps. + +On Linux, you can compile an example such as the one given in +:ref:`simple_example` using the following command: + +.. code-block:: bash + + $ c++ -O3 -Wall -shared -std=c++11 -fPIC $(python3 -m pybind11 --includes) example.cpp -o example$(python3-config --extension-suffix) + +The ``python3 -m pybind11 --includes`` command fetches the include paths for +both pybind11 and Python headers. This assumes that pybind11 has been installed +using ``pip`` or ``conda``. If it hasn't, you can also manually specify +``-I /include`` together with the Python includes path +``python3-config --includes``. + +On macOS: the build command is almost the same but it also requires passing +the ``-undefined dynamic_lookup`` flag so as to ignore missing symbols when +building the module: + +.. code-block:: bash + + $ c++ -O3 -Wall -shared -std=c++11 -undefined dynamic_lookup $(python3 -m pybind11 --includes) example.cpp -o example$(python3-config --extension-suffix) + +In general, it is advisable to include several additional build parameters +that can considerably reduce the size of the created binary. Refer to section +:ref:`cmake` for a detailed example of a suitable cross-platform CMake-based +build system that works on all platforms including Windows. + +.. note:: + + On Linux and macOS, it's better to (intentionally) not link against + ``libpython``. The symbols will be resolved when the extension library + is loaded into a Python binary. This is preferable because you might + have several different installations of a given Python version (e.g. the + system-provided Python, and one that ships with a piece of commercial + software). In this way, the plugin will work with both versions, instead + of possibly importing a second Python library into a process that already + contains one (which will lead to a segfault). + + +Building with Bazel +=================== + +You can build with the Bazel build system using the `pybind11_bazel +`_ repository. + +Generating binding code automatically +===================================== + +The ``Binder`` project is a tool for automatic generation of pybind11 binding +code by introspecting existing C++ codebases using LLVM/Clang. See the +[binder]_ documentation for details. + +.. [binder] http://cppbinder.readthedocs.io/en/latest/about.html + +[AutoWIG]_ is a Python library that wraps automatically compiled libraries into +high-level languages. It parses C++ code using LLVM/Clang technologies and +generates the wrappers using the Mako templating engine. The approach is automatic, +extensible, and applies to very complex C++ libraries, composed of thousands of +classes or incorporating modern meta-programming constructs. + +.. [AutoWIG] https://github.com/StatisKit/AutoWIG + +[robotpy-build]_ is a is a pure python, cross platform build tool that aims to +simplify creation of python wheels for pybind11 projects, and provide +cross-project dependency management. Additionally, it is able to autogenerate +customizable pybind11-based wrappers by parsing C++ header files. + +.. [robotpy-build] https://robotpy-build.readthedocs.io diff --git a/dmff/dpnblist/external/pybind11-2.11.1/docs/conf.py b/dmff/dpnblist/external/pybind11-2.11.1/docs/conf.py new file mode 100644 index 00000000..6e24751e --- /dev/null +++ b/dmff/dpnblist/external/pybind11-2.11.1/docs/conf.py @@ -0,0 +1,368 @@ +#!/usr/bin/env python3 +# +# pybind11 documentation build configuration file, created by +# sphinx-quickstart on Sun Oct 11 19:23:48 2015. +# +# This file is execfile()d with the current directory set to its +# containing dir. +# +# Note that not all possible configuration values are present in this +# autogenerated file. +# +# All configuration values have a default; values that are commented out +# serve to show the default. + +import os +import re +import subprocess +import sys +from pathlib import Path + +DIR = Path(__file__).parent.resolve() + +# If extensions (or modules to document with autodoc) are in another directory, +# add these directories to sys.path here. If the directory is relative to the +# documentation root, use os.path.abspath to make it absolute, like shown here. +# sys.path.insert(0, os.path.abspath('.')) + +# -- General configuration ------------------------------------------------ + +# If your documentation needs a minimal Sphinx version, state it here. +# needs_sphinx = '1.0' + +# Add any Sphinx extension module names here, as strings. They can be +# extensions coming with Sphinx (named 'sphinx.ext.*') or your custom +# ones. +extensions = [ + "breathe", + "sphinx_copybutton", + "sphinxcontrib.rsvgconverter", + "sphinxcontrib.moderncmakedomain", +] + +breathe_projects = {"pybind11": ".build/doxygenxml/"} +breathe_default_project = "pybind11" +breathe_domain_by_extension = {"h": "cpp"} + +# Add any paths that contain templates here, relative to this directory. +templates_path = [".templates"] + +# The suffix(es) of source filenames. +# You can specify multiple suffix as a list of string: +# source_suffix = ['.rst', '.md'] +source_suffix = ".rst" + +# The encoding of source files. +# source_encoding = 'utf-8-sig' + +# The master toctree document. +master_doc = "index" + +# General information about the project. +project = "pybind11" +copyright = "2017, Wenzel Jakob" +author = "Wenzel Jakob" + +# The version info for the project you're documenting, acts as replacement for +# |version| and |release|, also used in various other places throughout the +# built documents. + +# Read the listed version +with open("../pybind11/_version.py") as f: + code = compile(f.read(), "../pybind11/_version.py", "exec") +loc = {} +exec(code, loc) + +# The full version, including alpha/beta/rc tags. +version = loc["__version__"] + +# The language for content autogenerated by Sphinx. Refer to documentation +# for a list of supported languages. +# +# This is also used if you do content translation via gettext catalogs. +# Usually you set "language" from the command line for these cases. +language = None + +# There are two options for replacing |today|: either, you set today to some +# non-false value, then it is used: +# today = '' +# Else, today_fmt is used as the format for a strftime call. +# today_fmt = '%B %d, %Y' + +# List of patterns, relative to source directory, that match files and +# directories to ignore when looking for source files. +exclude_patterns = [".build", "release.rst"] + +# The reST default role (used for this markup: `text`) to use for all +# documents. +default_role = "any" + +# If true, '()' will be appended to :func: etc. cross-reference text. +# add_function_parentheses = True + +# If true, the current module name will be prepended to all description +# unit titles (such as .. function::). +# add_module_names = True + +# If true, sectionauthor and moduleauthor directives will be shown in the +# output. They are ignored by default. +# show_authors = False + +# The name of the Pygments (syntax highlighting) style to use. +# pygments_style = 'monokai' + +# A list of ignored prefixes for module index sorting. +# modindex_common_prefix = [] + +# If true, keep warnings as "system message" paragraphs in the built documents. +# keep_warnings = False + +# If true, `todo` and `todoList` produce output, else they produce nothing. +todo_include_todos = False + + +# -- Options for HTML output ---------------------------------------------- + +# The theme to use for HTML and HTML Help pages. See the documentation for +# a list of builtin themes. + +html_theme = "furo" + +# Theme options are theme-specific and customize the look and feel of a theme +# further. For a list of options available for each theme, see the +# documentation. +# html_theme_options = {} + +# Add any paths that contain custom themes here, relative to this directory. +# html_theme_path = [] + +# The name for this set of Sphinx documents. If None, it defaults to +# " v documentation". +# html_title = None + +# A shorter title for the navigation bar. Default is the same as html_title. +# html_short_title = None + +# The name of an image file (relative to this directory) to place at the top +# of the sidebar. +# html_logo = None + +# The name of an image file (within the static path) to use as favicon of the +# docs. This file should be a Windows icon file (.ico) being 16x16 or 32x32 +# pixels large. +# html_favicon = None + +# Add any paths that contain custom static files (such as style sheets) here, +# relative to this directory. They are copied after the builtin static files, +# so a file named "default.css" will overwrite the builtin "default.css". +html_static_path = ["_static"] + +html_css_files = [ + "css/custom.css", +] + +# Add any extra paths that contain custom files (such as robots.txt or +# .htaccess) here, relative to this directory. These files are copied +# directly to the root of the documentation. +# html_extra_path = [] + +# If not '', a 'Last updated on:' timestamp is inserted at every page bottom, +# using the given strftime format. +# html_last_updated_fmt = '%b %d, %Y' + +# If true, SmartyPants will be used to convert quotes and dashes to +# typographically correct entities. +# html_use_smartypants = True + +# Custom sidebar templates, maps document names to template names. +# html_sidebars = {} + +# Additional templates that should be rendered to pages, maps page names to +# template names. +# html_additional_pages = {} + +# If false, no module index is generated. +# html_domain_indices = True + +# If false, no index is generated. +# html_use_index = True + +# If true, the index is split into individual pages for each letter. +# html_split_index = False + +# If true, links to the reST sources are added to the pages. +# html_show_sourcelink = True + +# If true, "Created using Sphinx" is shown in the HTML footer. Default is True. +# html_show_sphinx = True + +# If true, "(C) Copyright ..." is shown in the HTML footer. Default is True. +# html_show_copyright = True + +# If true, an OpenSearch description file will be output, and all pages will +# contain a tag referring to it. The value of this option must be the +# base URL from which the finished HTML is served. +# html_use_opensearch = '' + +# This is the file name suffix for HTML files (e.g. ".xhtml"). +# html_file_suffix = None + +# Language to be used for generating the HTML full-text search index. +# Sphinx supports the following languages: +# 'da', 'de', 'en', 'es', 'fi', 'fr', 'h', 'it', 'ja' +# 'nl', 'no', 'pt', 'ro', 'r', 'sv', 'tr' +# html_search_language = 'en' + +# A dictionary with options for the search language support, empty by default. +# Now only 'ja' uses this config value +# html_search_options = {'type': 'default'} + +# The name of a javascript file (relative to the configuration directory) that +# implements a search results scorer. If empty, the default will be used. +# html_search_scorer = 'scorer.js' + +# Output file base name for HTML help builder. +htmlhelp_basename = "pybind11doc" + +# -- Options for LaTeX output --------------------------------------------- + +latex_engine = "pdflatex" + +latex_elements = { + # The paper size ('letterpaper' or 'a4paper'). + # 'papersize': 'letterpaper', + # + # The font size ('10pt', '11pt' or '12pt'). + # 'pointsize': '10pt', + # + # Additional stuff for the LaTeX preamble. + # remove blank pages (between the title page and the TOC, etc.) + "classoptions": ",openany,oneside", + "preamble": r""" +\usepackage{fontawesome} +\usepackage{textgreek} +\DeclareUnicodeCharacter{00A0}{} +\DeclareUnicodeCharacter{2194}{\faArrowsH} +\DeclareUnicodeCharacter{1F382}{\faBirthdayCake} +\DeclareUnicodeCharacter{1F355}{\faAdjust} +\DeclareUnicodeCharacter{0301}{'} +\DeclareUnicodeCharacter{03C0}{\textpi} + +""", + # Latex figure (float) alignment + # 'figure_align': 'htbp', +} + +# Grouping the document tree into LaTeX files. List of tuples +# (source start file, target name, title, +# author, documentclass [howto, manual, or own class]). +latex_documents = [ + (master_doc, "pybind11.tex", "pybind11 Documentation", "Wenzel Jakob", "manual"), +] + +# The name of an image file (relative to this directory) to place at the top of +# the title page. +# latex_logo = 'pybind11-logo.png' + +# For "manual" documents, if this is true, then toplevel headings are parts, +# not chapters. +# latex_use_parts = False + +# If true, show page references after internal links. +# latex_show_pagerefs = False + +# If true, show URL addresses after external links. +# latex_show_urls = False + +# Documents to append as an appendix to all manuals. +# latex_appendices = [] + +# If false, no module index is generated. +# latex_domain_indices = True + + +# -- Options for manual page output --------------------------------------- + +# One entry per manual page. List of tuples +# (source start file, name, description, authors, manual section). +man_pages = [(master_doc, "pybind11", "pybind11 Documentation", [author], 1)] + +# If true, show URL addresses after external links. +# man_show_urls = False + + +# -- Options for Texinfo output ------------------------------------------- + +# Grouping the document tree into Texinfo files. List of tuples +# (source start file, target name, title, author, +# dir menu entry, description, category) +texinfo_documents = [ + ( + master_doc, + "pybind11", + "pybind11 Documentation", + author, + "pybind11", + "One line description of project.", + "Miscellaneous", + ), +] + +# Documents to append as an appendix to all manuals. +# texinfo_appendices = [] + +# If false, no module index is generated. +# texinfo_domain_indices = True + +# How to display URL addresses: 'footnote', 'no', or 'inline'. +# texinfo_show_urls = 'footnote' + +# If true, do not generate a @detailmenu in the "Top" node's menu. +# texinfo_no_detailmenu = False + +primary_domain = "cpp" +highlight_language = "cpp" + + +def generate_doxygen_xml(app): + build_dir = os.path.join(app.confdir, ".build") + if not os.path.exists(build_dir): + os.mkdir(build_dir) + + try: + subprocess.call(["doxygen", "--version"]) + retcode = subprocess.call(["doxygen"], cwd=app.confdir) + if retcode < 0: + sys.stderr.write(f"doxygen error code: {-retcode}\n") + except OSError as e: + sys.stderr.write(f"doxygen execution failed: {e}\n") + + +def prepare(app): + with open(DIR.parent / "README.rst") as f: + contents = f.read() + + if app.builder.name == "latex": + # Remove badges and stuff from start + contents = contents[contents.find(r".. start") :] + + # Filter out section titles for index.rst for LaTeX + contents = re.sub(r"^(.*)\n[-~]{3,}$", r"**\1**", contents, flags=re.MULTILINE) + + with open(DIR / "readme.rst", "w") as f: + f.write(contents) + + +def clean_up(app, exception): # noqa: ARG001 + (DIR / "readme.rst").unlink() + + +def setup(app): + # Add hook for building doxygen xml when needed + app.connect("builder-inited", generate_doxygen_xml) + + # Copy the readme in + app.connect("builder-inited", prepare) + + # Clean up the generated readme + app.connect("build-finished", clean_up) diff --git a/dmff/dpnblist/external/pybind11-2.11.1/docs/faq.rst b/dmff/dpnblist/external/pybind11-2.11.1/docs/faq.rst new file mode 100644 index 00000000..1eb00efa --- /dev/null +++ b/dmff/dpnblist/external/pybind11-2.11.1/docs/faq.rst @@ -0,0 +1,308 @@ +Frequently asked questions +########################## + +"ImportError: dynamic module does not define init function" +=========================================================== + +1. Make sure that the name specified in PYBIND11_MODULE is identical to the +filename of the extension library (without suffixes such as ``.so``). + +2. If the above did not fix the issue, you are likely using an incompatible +version of Python that does not match what you compiled with. + +"Symbol not found: ``__Py_ZeroStruct`` / ``_PyInstanceMethod_Type``" +======================================================================== + +See the first answer. + +"SystemError: dynamic module not initialized properly" +====================================================== + +See the first answer. + +The Python interpreter immediately crashes when importing my module +=================================================================== + +See the first answer. + +.. _faq_reference_arguments: + +Limitations involving reference arguments +========================================= + +In C++, it's fairly common to pass arguments using mutable references or +mutable pointers, which allows both read and write access to the value +supplied by the caller. This is sometimes done for efficiency reasons, or to +realize functions that have multiple return values. Here are two very basic +examples: + +.. code-block:: cpp + + void increment(int &i) { i++; } + void increment_ptr(int *i) { (*i)++; } + +In Python, all arguments are passed by reference, so there is no general +issue in binding such code from Python. + +However, certain basic Python types (like ``str``, ``int``, ``bool``, +``float``, etc.) are **immutable**. This means that the following attempt +to port the function to Python doesn't have the same effect on the value +provided by the caller -- in fact, it does nothing at all. + +.. code-block:: python + + def increment(i): + i += 1 # nope.. + +pybind11 is also affected by such language-level conventions, which means that +binding ``increment`` or ``increment_ptr`` will also create Python functions +that don't modify their arguments. + +Although inconvenient, one workaround is to encapsulate the immutable types in +a custom type that does allow modifications. + +An other alternative involves binding a small wrapper lambda function that +returns a tuple with all output arguments (see the remainder of the +documentation for examples on binding lambda functions). An example: + +.. code-block:: cpp + + int foo(int &i) { i++; return 123; } + +and the binding code + +.. code-block:: cpp + + m.def("foo", [](int i) { int rv = foo(i); return std::make_tuple(rv, i); }); + + +How can I reduce the build time? +================================ + +It's good practice to split binding code over multiple files, as in the +following example: + +:file:`example.cpp`: + +.. code-block:: cpp + + void init_ex1(py::module_ &); + void init_ex2(py::module_ &); + /* ... */ + + PYBIND11_MODULE(example, m) { + init_ex1(m); + init_ex2(m); + /* ... */ + } + +:file:`ex1.cpp`: + +.. code-block:: cpp + + void init_ex1(py::module_ &m) { + m.def("add", [](int a, int b) { return a + b; }); + } + +:file:`ex2.cpp`: + +.. code-block:: cpp + + void init_ex2(py::module_ &m) { + m.def("sub", [](int a, int b) { return a - b; }); + } + +:command:`python`: + +.. code-block:: pycon + + >>> import example + >>> example.add(1, 2) + 3 + >>> example.sub(1, 1) + 0 + +As shown above, the various ``init_ex`` functions should be contained in +separate files that can be compiled independently from one another, and then +linked together into the same final shared object. Following this approach +will: + +1. reduce memory requirements per compilation unit. + +2. enable parallel builds (if desired). + +3. allow for faster incremental builds. For instance, when a single class + definition is changed, only a subset of the binding code will generally need + to be recompiled. + +"recursive template instantiation exceeded maximum depth of 256" +================================================================ + +If you receive an error about excessive recursive template evaluation, try +specifying a larger value, e.g. ``-ftemplate-depth=1024`` on GCC/Clang. The +culprit is generally the generation of function signatures at compile time +using C++14 template metaprogramming. + +.. _`faq:hidden_visibility`: + +"'SomeClass' declared with greater visibility than the type of its field 'SomeClass::member' [-Wattributes]" +============================================================================================================ + +This error typically indicates that you are compiling without the required +``-fvisibility`` flag. pybind11 code internally forces hidden visibility on +all internal code, but if non-hidden (and thus *exported*) code attempts to +include a pybind type (for example, ``py::object`` or ``py::list``) you can run +into this warning. + +To avoid it, make sure you are specifying ``-fvisibility=hidden`` when +compiling pybind code. + +As to why ``-fvisibility=hidden`` is necessary, because pybind modules could +have been compiled under different versions of pybind itself, it is also +important that the symbols defined in one module do not clash with the +potentially-incompatible symbols defined in another. While Python extension +modules are usually loaded with localized symbols (under POSIX systems +typically using ``dlopen`` with the ``RTLD_LOCAL`` flag), this Python default +can be changed, but even if it isn't it is not always enough to guarantee +complete independence of the symbols involved when not using +``-fvisibility=hidden``. + +Additionally, ``-fvisibility=hidden`` can deliver considerably binary size +savings. (See the following section for more details.) + + +.. _`faq:symhidden`: + +How can I create smaller binaries? +================================== + +To do its job, pybind11 extensively relies on a programming technique known as +*template metaprogramming*, which is a way of performing computation at compile +time using type information. Template metaprogramming usually instantiates code +involving significant numbers of deeply nested types that are either completely +removed or reduced to just a few instructions during the compiler's optimization +phase. However, due to the nested nature of these types, the resulting symbol +names in the compiled extension library can be extremely long. For instance, +the included test suite contains the following symbol: + +.. only:: html + + .. code-block:: none + + _​_​Z​N​8​p​y​b​i​n​d​1​1​1​2​c​p​p​_​f​u​n​c​t​i​o​n​C​1​I​v​8​E​x​a​m​p​l​e​2​J​R​N​S​t​3​_​_​1​6​v​e​c​t​o​r​I​N​S​3​_​1​2​b​a​s​i​c​_​s​t​r​i​n​g​I​w​N​S​3​_​1​1​c​h​a​r​_​t​r​a​i​t​s​I​w​E​E​N​S​3​_​9​a​l​l​o​c​a​t​o​r​I​w​E​E​E​E​N​S​8​_​I​S​A​_​E​E​E​E​E​J​N​S​_​4​n​a​m​e​E​N​S​_​7​s​i​b​l​i​n​g​E​N​S​_​9​i​s​_​m​e​t​h​o​d​E​A​2​8​_​c​E​E​E​M​T​0​_​F​T​_​D​p​T​1​_​E​D​p​R​K​T​2​_ + +.. only:: not html + + .. code-block:: cpp + + __ZN8pybind1112cpp_functionC1Iv8Example2JRNSt3__16vectorINS3_12basic_stringIwNS3_11char_traitsIwEENS3_9allocatorIwEEEENS8_ISA_EEEEEJNS_4nameENS_7siblingENS_9is_methodEA28_cEEEMT0_FT_DpT1_EDpRKT2_ + +which is the mangled form of the following function type: + +.. code-block:: cpp + + pybind11::cpp_function::cpp_function, std::__1::allocator >, std::__1::allocator, std::__1::allocator > > >&, pybind11::name, pybind11::sibling, pybind11::is_method, char [28]>(void (Example2::*)(std::__1::vector, std::__1::allocator >, std::__1::allocator, std::__1::allocator > > >&), pybind11::name const&, pybind11::sibling const&, pybind11::is_method const&, char const (&) [28]) + +The memory needed to store just the mangled name of this function (196 bytes) +is larger than the actual piece of code (111 bytes) it represents! On the other +hand, it's silly to even give this function a name -- after all, it's just a +tiny cog in a bigger piece of machinery that is not exposed to the outside +world. So we'll generally only want to export symbols for those functions which +are actually called from the outside. + +This can be achieved by specifying the parameter ``-fvisibility=hidden`` to GCC +and Clang, which sets the default symbol visibility to *hidden*, which has a +tremendous impact on the final binary size of the resulting extension library. +(On Visual Studio, symbols are already hidden by default, so nothing needs to +be done there.) + +In addition to decreasing binary size, ``-fvisibility=hidden`` also avoids +potential serious issues when loading multiple modules and is required for +proper pybind operation. See the previous FAQ entry for more details. + +How can I properly handle Ctrl-C in long-running functions? +=========================================================== + +Ctrl-C is received by the Python interpreter, and holds it until the GIL +is released, so a long-running function won't be interrupted. + +To interrupt from inside your function, you can use the ``PyErr_CheckSignals()`` +function, that will tell if a signal has been raised on the Python side. This +function merely checks a flag, so its impact is negligible. When a signal has +been received, you must either explicitly interrupt execution by throwing +``py::error_already_set`` (which will propagate the existing +``KeyboardInterrupt``), or clear the error (which you usually will not want): + +.. code-block:: cpp + + PYBIND11_MODULE(example, m) + { + m.def("long running_func", []() + { + for (;;) { + if (PyErr_CheckSignals() != 0) + throw py::error_already_set(); + // Long running iteration + } + }); + } + +CMake doesn't detect the right Python version +============================================= + +The CMake-based build system will try to automatically detect the installed +version of Python and link against that. When this fails, or when there are +multiple versions of Python and it finds the wrong one, delete +``CMakeCache.txt`` and then add ``-DPYTHON_EXECUTABLE=$(which python)`` to your +CMake configure line. (Replace ``$(which python)`` with a path to python if +your prefer.) + +You can alternatively try ``-DPYBIND11_FINDPYTHON=ON``, which will activate the +new CMake FindPython support instead of pybind11's custom search. Requires +CMake 3.12+, and 3.15+ or 3.18.2+ are even better. You can set this in your +``CMakeLists.txt`` before adding or finding pybind11, as well. + +Inconsistent detection of Python version in CMake and pybind11 +============================================================== + +The functions ``find_package(PythonInterp)`` and ``find_package(PythonLibs)`` +provided by CMake for Python version detection are modified by pybind11 due to +unreliability and limitations that make them unsuitable for pybind11's needs. +Instead pybind11 provides its own, more reliable Python detection CMake code. +Conflicts can arise, however, when using pybind11 in a project that *also* uses +the CMake Python detection in a system with several Python versions installed. + +This difference may cause inconsistencies and errors if *both* mechanisms are +used in the same project. + +There are three possible solutions: + +1. Avoid using ``find_package(PythonInterp)`` and ``find_package(PythonLibs)`` + from CMake and rely on pybind11 in detecting Python version. If this is not + possible, the CMake machinery should be called *before* including pybind11. +2. Set ``PYBIND11_FINDPYTHON`` to ``True`` or use ``find_package(Python + COMPONENTS Interpreter Development)`` on modern CMake (3.12+, 3.15+ better, + 3.18.2+ best). Pybind11 in these cases uses the new CMake FindPython instead + of the old, deprecated search tools, and these modules are much better at + finding the correct Python. If FindPythonLibs/Interp are not available + (CMake 3.27+), then this will be ignored and FindPython will be used. +3. Set ``PYBIND11_NOPYTHON`` to ``TRUE``. Pybind11 will not search for Python. + However, you will have to use the target-based system, and do more setup + yourself, because it does not know about or include things that depend on + Python, like ``pybind11_add_module``. This might be ideal for integrating + into an existing system, like scikit-build's Python helpers. + +How to cite this project? +========================= + +We suggest the following BibTeX template to cite pybind11 in scientific +discourse: + +.. code-block:: bash + + @misc{pybind11, + author = {Wenzel Jakob and Jason Rhinelander and Dean Moldovan}, + year = {2017}, + note = {https://github.com/pybind/pybind11}, + title = {pybind11 -- Seamless operability between C++11 and Python} + } diff --git a/dmff/dpnblist/external/pybind11-2.11.1/docs/index.rst b/dmff/dpnblist/external/pybind11-2.11.1/docs/index.rst new file mode 100644 index 00000000..4e2e8ca3 --- /dev/null +++ b/dmff/dpnblist/external/pybind11-2.11.1/docs/index.rst @@ -0,0 +1,48 @@ +.. only:: latex + + Intro + ===== + +.. include:: readme.rst + +.. only:: not latex + + Contents: + +.. toctree:: + :maxdepth: 1 + + changelog + upgrade + +.. toctree:: + :caption: The Basics + :maxdepth: 2 + + installing + basics + classes + compiling + +.. toctree:: + :caption: Advanced Topics + :maxdepth: 2 + + advanced/functions + advanced/classes + advanced/exceptions + advanced/smart_ptrs + advanced/cast/index + advanced/pycpp/index + advanced/embedding + advanced/misc + +.. toctree:: + :caption: Extra Information + :maxdepth: 1 + + faq + benchmark + limitations + reference + cmake/index diff --git a/dmff/dpnblist/external/pybind11-2.11.1/docs/installing.rst b/dmff/dpnblist/external/pybind11-2.11.1/docs/installing.rst new file mode 100644 index 00000000..30b9f185 --- /dev/null +++ b/dmff/dpnblist/external/pybind11-2.11.1/docs/installing.rst @@ -0,0 +1,105 @@ +.. _installing: + +Installing the library +###################### + +There are several ways to get the pybind11 source, which lives at +`pybind/pybind11 on GitHub `_. The pybind11 +developers recommend one of the first three ways listed here, submodule, PyPI, +or conda-forge, for obtaining pybind11. + +.. _include_as_a_submodule: + +Include as a submodule +====================== + +When you are working on a project in Git, you can use the pybind11 repository +as a submodule. From your git repository, use: + +.. code-block:: bash + + git submodule add -b stable ../../pybind/pybind11 extern/pybind11 + git submodule update --init + +This assumes you are placing your dependencies in ``extern/``, and that you are +using GitHub; if you are not using GitHub, use the full https or ssh URL +instead of the relative URL ``../../pybind/pybind11`` above. Some other servers +also require the ``.git`` extension (GitHub does not). + +From here, you can now include ``extern/pybind11/include``, or you can use +the various integration tools (see :ref:`compiling`) pybind11 provides directly +from the local folder. + +Include with PyPI +================= + +You can download the sources and CMake files as a Python package from PyPI +using Pip. Just use: + +.. code-block:: bash + + pip install pybind11 + +This will provide pybind11 in a standard Python package format. If you want +pybind11 available directly in your environment root, you can use: + +.. code-block:: bash + + pip install "pybind11[global]" + +This is not recommended if you are installing with your system Python, as it +will add files to ``/usr/local/include/pybind11`` and +``/usr/local/share/cmake/pybind11``, so unless that is what you want, it is +recommended only for use in virtual environments or your ``pyproject.toml`` +file (see :ref:`compiling`). + +Include with conda-forge +======================== + +You can use pybind11 with conda packaging via `conda-forge +`_: + +.. code-block:: bash + + conda install -c conda-forge pybind11 + + +Include with vcpkg +================== +You can download and install pybind11 using the Microsoft `vcpkg +`_ dependency manager: + +.. code-block:: bash + + git clone https://github.com/Microsoft/vcpkg.git + cd vcpkg + ./bootstrap-vcpkg.sh + ./vcpkg integrate install + vcpkg install pybind11 + +The pybind11 port in vcpkg is kept up to date by Microsoft team members and +community contributors. If the version is out of date, please `create an issue +or pull request `_ on the vcpkg +repository. + +Global install with brew +======================== + +The brew package manager (Homebrew on macOS, or Linuxbrew on Linux) has a +`pybind11 package +`_. +To install: + +.. code-block:: bash + + brew install pybind11 + +.. We should list Conan, and possibly a few other C++ package managers (hunter, +.. perhaps). Conan has a very clean CMake integration that would be good to show. + +Other options +============= + +Other locations you can find pybind11 are `listed here +`_; these are maintained +by various packagers and the community. diff --git a/dmff/dpnblist/external/pybind11-2.11.1/docs/limitations.rst b/dmff/dpnblist/external/pybind11-2.11.1/docs/limitations.rst new file mode 100644 index 00000000..def5ad65 --- /dev/null +++ b/dmff/dpnblist/external/pybind11-2.11.1/docs/limitations.rst @@ -0,0 +1,72 @@ +Limitations +########### + +Design choices +^^^^^^^^^^^^^^ + +pybind11 strives to be a general solution to binding generation, but it also has +certain limitations: + +- pybind11 casts away ``const``-ness in function arguments and return values. + This is in line with the Python language, which has no concept of ``const`` + values. This means that some additional care is needed to avoid bugs that + would be caught by the type checker in a traditional C++ program. + +- The NumPy interface ``pybind11::array`` greatly simplifies accessing + numerical data from C++ (and vice versa), but it's not a full-blown array + class like ``Eigen::Array`` or ``boost.multi_array``. ``Eigen`` objects are + directly supported, however, with ``pybind11/eigen.h``. + +Large but useful features could be implemented in pybind11 but would lead to a +significant increase in complexity. Pybind11 strives to be simple and compact. +Users who require large new features are encouraged to write an extension to +pybind11; see `pybind11_json `_ for an +example. + + +Known bugs +^^^^^^^^^^ + +These are issues that hopefully will one day be fixed, but currently are +unsolved. If you know how to help with one of these issues, contributions +are welcome! + +- Intel 20.2 is currently having an issue with the test suite. + `#2573 `_ + +- Debug mode Python does not support 1-5 tests in the test suite currently. + `#2422 `_ + +- PyPy3 7.3.1 and 7.3.2 have issues with several tests on 32-bit Windows. + +Known limitations +^^^^^^^^^^^^^^^^^ + +These are issues that are probably solvable, but have not been fixed yet. A +clean, well written patch would likely be accepted to solve them. + +- Type casters are not kept alive recursively. + `#2527 `_ + One consequence is that containers of ``char *`` are currently not supported. + `#2245 `_ + +- The ``cpptest`` does not run on Windows with Python 3.8 or newer, due to DLL + loader changes. User code that is correctly installed should not be affected. + `#2560 `_ + +Python 3.9.0 warning +^^^^^^^^^^^^^^^^^^^^ + +Combining older versions of pybind11 (< 2.6.0) with Python on exactly 3.9.0 +will trigger undefined behavior that typically manifests as crashes during +interpreter shutdown (but could also destroy your data. **You have been +warned**). + +This issue was `fixed in Python `_. +As a mitigation for this bug, pybind11 2.6.0 or newer includes a workaround +specifically when Python 3.9.0 is detected at runtime, leaking about 50 bytes +of memory when a callback function is garbage collected. For reference, the +pybind11 test suite has about 2,000 such callbacks, but only 49 are garbage +collected before the end-of-process. Wheels (even if built with Python 3.9.0) +will correctly avoid the leak when run in Python 3.9.1, and this does not +affect other 3.X versions. diff --git a/dmff/dpnblist/external/pybind11-2.11.1/docs/pybind11-logo.png b/dmff/dpnblist/external/pybind11-2.11.1/docs/pybind11-logo.png new file mode 100644 index 00000000..2d633a4d Binary files /dev/null and b/dmff/dpnblist/external/pybind11-2.11.1/docs/pybind11-logo.png differ diff --git a/dmff/dpnblist/external/pybind11-2.11.1/docs/pybind11_vs_boost_python1.png b/dmff/dpnblist/external/pybind11-2.11.1/docs/pybind11_vs_boost_python1.png new file mode 100644 index 00000000..833231f2 Binary files /dev/null and b/dmff/dpnblist/external/pybind11-2.11.1/docs/pybind11_vs_boost_python1.png differ diff --git a/dmff/dpnblist/external/pybind11-2.11.1/docs/pybind11_vs_boost_python1.svg b/dmff/dpnblist/external/pybind11-2.11.1/docs/pybind11_vs_boost_python1.svg new file mode 100644 index 00000000..5bf950e6 --- /dev/null +++ b/dmff/dpnblist/external/pybind11-2.11.1/docs/pybind11_vs_boost_python1.svg @@ -0,0 +1,427 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/dmff/dpnblist/external/pybind11-2.11.1/docs/pybind11_vs_boost_python2.png b/dmff/dpnblist/external/pybind11-2.11.1/docs/pybind11_vs_boost_python2.png new file mode 100644 index 00000000..9f17272c Binary files /dev/null and b/dmff/dpnblist/external/pybind11-2.11.1/docs/pybind11_vs_boost_python2.png differ diff --git a/dmff/dpnblist/external/pybind11-2.11.1/docs/pybind11_vs_boost_python2.svg b/dmff/dpnblist/external/pybind11-2.11.1/docs/pybind11_vs_boost_python2.svg new file mode 100644 index 00000000..5ed6530c --- /dev/null +++ b/dmff/dpnblist/external/pybind11-2.11.1/docs/pybind11_vs_boost_python2.svg @@ -0,0 +1,427 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/dmff/dpnblist/external/pybind11-2.11.1/docs/reference.rst b/dmff/dpnblist/external/pybind11-2.11.1/docs/reference.rst new file mode 100644 index 00000000..e64a0351 --- /dev/null +++ b/dmff/dpnblist/external/pybind11-2.11.1/docs/reference.rst @@ -0,0 +1,130 @@ +.. _reference: + +.. warning:: + + Please be advised that the reference documentation discussing pybind11 + internals is currently incomplete. Please refer to the previous sections + and the pybind11 header files for the nitty gritty details. + +Reference +######### + +.. _macros: + +Macros +====== + +.. doxygendefine:: PYBIND11_MODULE + +.. _core_types: + +Convenience classes for arbitrary Python types +============================================== + +Common member functions +----------------------- + +.. doxygenclass:: object_api + :members: + +Without reference counting +-------------------------- + +.. doxygenclass:: handle + :members: + +With reference counting +----------------------- + +.. doxygenclass:: object + :members: + +.. doxygenfunction:: reinterpret_borrow + +.. doxygenfunction:: reinterpret_steal + +Convenience classes for specific Python types +============================================= + +.. doxygenclass:: module_ + :members: + +.. doxygengroup:: pytypes + :members: + +Convenience functions converting to Python types +================================================ + +.. doxygenfunction:: make_tuple(Args&&...) + +.. doxygenfunction:: make_iterator(Iterator, Sentinel, Extra &&...) +.. doxygenfunction:: make_iterator(Type &, Extra&&...) + +.. doxygenfunction:: make_key_iterator(Iterator, Sentinel, Extra &&...) +.. doxygenfunction:: make_key_iterator(Type &, Extra&&...) + +.. doxygenfunction:: make_value_iterator(Iterator, Sentinel, Extra &&...) +.. doxygenfunction:: make_value_iterator(Type &, Extra&&...) + +.. _extras: + +Passing extra arguments to ``def`` or ``class_`` +================================================ + +.. doxygengroup:: annotations + :members: + +Embedding the interpreter +========================= + +.. doxygendefine:: PYBIND11_EMBEDDED_MODULE + +.. doxygenfunction:: initialize_interpreter + +.. doxygenfunction:: finalize_interpreter + +.. doxygenclass:: scoped_interpreter + +Redirecting C++ streams +======================= + +.. doxygenclass:: scoped_ostream_redirect + +.. doxygenclass:: scoped_estream_redirect + +.. doxygenfunction:: add_ostream_redirect + +Python built-in functions +========================= + +.. doxygengroup:: python_builtins + :members: + +Inheritance +=========== + +See :doc:`/classes` and :doc:`/advanced/classes` for more detail. + +.. doxygendefine:: PYBIND11_OVERRIDE + +.. doxygendefine:: PYBIND11_OVERRIDE_PURE + +.. doxygendefine:: PYBIND11_OVERRIDE_NAME + +.. doxygendefine:: PYBIND11_OVERRIDE_PURE_NAME + +.. doxygenfunction:: get_override + +Exceptions +========== + +.. doxygenclass:: error_already_set + :members: + +.. doxygenclass:: builtin_exception + :members: + +Literals +======== + +.. doxygennamespace:: literals diff --git a/dmff/dpnblist/external/pybind11-2.11.1/docs/release.rst b/dmff/dpnblist/external/pybind11-2.11.1/docs/release.rst new file mode 100644 index 00000000..4950c3b8 --- /dev/null +++ b/dmff/dpnblist/external/pybind11-2.11.1/docs/release.rst @@ -0,0 +1,99 @@ +On version numbers +^^^^^^^^^^^^^^^^^^ + +The two version numbers (C++ and Python) must match when combined (checked when +you build the PyPI package), and must be a valid `PEP 440 +`_ version when combined. + +For example: + +.. code-block:: C++ + + #define PYBIND11_VERSION_MAJOR X + #define PYBIND11_VERSION_MINOR Y + #define PYBIND11_VERSION_PATCH Z.dev1 + +For beta, ``PYBIND11_VERSION_PATCH`` should be ``Z.b1``. RC's can be ``Z.rc1``. +Always include the dot (even though PEP 440 allows it to be dropped). For a +final release, this must be a simple integer. There is also a HEX version of +the version just below. + + +To release a new version of pybind11: +^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +If you don't have nox, you should either use ``pipx run nox`` instead, or use +``pipx install nox`` or ``brew install nox`` (Unix). + +- Update the version number + - Update ``PYBIND11_VERSION_MAJOR`` etc. in + ``include/pybind11/detail/common.h``. PATCH should be a simple integer. + - Update the version HEX just below, as well. + - Update ``pybind11/_version.py`` (match above) + - Run ``nox -s tests_packaging`` to ensure this was done correctly. + - Ensure that all the information in ``setup.cfg`` is up-to-date, like + supported Python versions. + - Add release date in ``docs/changelog.rst`` and integrate the output of + ``nox -s make_changelog``. + - Note that the ``make_changelog`` command inspects + `needs changelog `_. + - Manually clear the ``needs changelog`` labels using the GitHub web + interface (very easy: start by clicking the link above). + - ``git add`` and ``git commit``, ``git push``. **Ensure CI passes**. (If it + fails due to a known flake issue, either ignore or restart CI.) +- Add a release branch if this is a new minor version, or update the existing release branch if it is a patch version + - New branch: ``git checkout -b vX.Y``, ``git push -u origin vX.Y`` + - Update branch: ``git checkout vX.Y``, ``git merge ``, ``git push`` +- Update tags (optional; if you skip this, the GitHub release makes a + non-annotated tag for you) + - ``git tag -a vX.Y.Z -m 'vX.Y.Z release'``. + - ``git push --tags``. +- Update stable + - ``git checkout stable`` + - ``git merge master`` + - ``git push`` +- Make a GitHub release (this shows up in the UI, sends new release + notifications to users watching releases, and also uploads PyPI packages). + (Note: if you do not use an existing tag, this creates a new lightweight tag + for you, so you could skip the above step.) + - GUI method: Under `releases `_ + click "Draft a new release" on the far right, fill in the tag name + (if you didn't tag above, it will be made here), fill in a release name + like "Version X.Y.Z", and copy-and-paste the markdown-formatted (!) changelog + into the description (usually ``cat docs/changelog.rst | pandoc -f rst -t gfm``). + Check "pre-release" if this is a beta/RC. + - CLI method: with ``gh`` installed, run ``gh release create vX.Y.Z -t "Version X.Y.Z"`` + If this is a pre-release, add ``-p``. + +- Get back to work + - Make sure you are on master, not somewhere else: ``git checkout master`` + - Update version macros in ``include/pybind11/detail/common.h`` (set PATCH to + ``0.dev1`` and increment MINOR). + - Update ``_version.py`` to match + - Run ``nox -s tests_packaging`` to ensure this was done correctly. + - Add a spot for in-development updates in ``docs/changelog.rst``. + - ``git add``, ``git commit``, ``git push`` + +If a version branch is updated, remember to set PATCH to ``1.dev1``. + +If you'd like to bump homebrew, run: + +.. code-block:: console + + brew bump-formula-pr --url https://github.com/pybind/pybind11/archive/vX.Y.Z.tar.gz + +Conda-forge should automatically make a PR in a few hours, and automatically +merge it if there are no issues. + + +Manual packaging +^^^^^^^^^^^^^^^^ + +If you need to manually upload releases, you can download the releases from the job artifacts and upload them with twine. You can also make the files locally (not recommended in general, as your local directory is more likely to be "dirty" and SDists love picking up random unrelated/hidden files); this is the procedure: + +.. code-block:: bash + + nox -s build + twine upload dist/* + +This makes SDists and wheels, and the final line uploads them. diff --git a/dmff/dpnblist/external/pybind11-2.11.1/docs/requirements.txt b/dmff/dpnblist/external/pybind11-2.11.1/docs/requirements.txt new file mode 100644 index 00000000..d2a9ae16 --- /dev/null +++ b/dmff/dpnblist/external/pybind11-2.11.1/docs/requirements.txt @@ -0,0 +1,6 @@ +breathe==4.34.0 +furo==2022.6.21 +sphinx==5.0.2 +sphinx-copybutton==0.5.0 +sphinxcontrib-moderncmakedomain==3.21.4 +sphinxcontrib-svg2pdfconverter==1.2.0 diff --git a/dmff/dpnblist/external/pybind11-2.11.1/docs/upgrade.rst b/dmff/dpnblist/external/pybind11-2.11.1/docs/upgrade.rst new file mode 100644 index 00000000..b13d21f5 --- /dev/null +++ b/dmff/dpnblist/external/pybind11-2.11.1/docs/upgrade.rst @@ -0,0 +1,566 @@ +Upgrade guide +############# + +This is a companion guide to the :doc:`changelog`. While the changelog briefly +lists all of the new features, improvements and bug fixes, this upgrade guide +focuses only the subset which directly impacts your experience when upgrading +to a new version. But it goes into more detail. This includes things like +deprecated APIs and their replacements, build system changes, general code +modernization and other useful information. + +.. _upgrade-guide-2.11: + +v2.11 +===== + +* The minimum version of CMake is now 3.5. A future version will likely move to + requiring something like CMake 3.15. Note that CMake 3.27 is removing the + long-deprecated support for ``FindPythonInterp`` if you set 3.27 as the + minimum or maximum supported version. To prepare for that future, CMake 3.15+ + using ``FindPython`` or setting ``PYBIND11_FINDPYTHON`` is highly recommended, + otherwise pybind11 will automatically switch to using ``FindPython`` if + ``FindPythonInterp`` is not available. + + +.. _upgrade-guide-2.9: + +v2.9 +==== + +* Any usage of the recently added ``py::make_simple_namespace`` should be + converted to using ``py::module_::import("types").attr("SimpleNamespace")`` + instead. + +* The use of ``_`` in custom type casters can now be replaced with the more + readable ``const_name`` instead. The old ``_`` shortcut has been retained + unless it is being used as a macro (like for gettext). + + +.. _upgrade-guide-2.7: + +v2.7 +==== + +*Before* v2.7, ``py::str`` can hold ``PyUnicodeObject`` or ``PyBytesObject``, +and ``py::isinstance()`` is ``true`` for both ``py::str`` and +``py::bytes``. Starting with v2.7, ``py::str`` exclusively holds +``PyUnicodeObject`` (`#2409 `_), +and ``py::isinstance()`` is ``true`` only for ``py::str``. To help in +the transition of user code, the ``PYBIND11_STR_LEGACY_PERMISSIVE`` macro +is provided as an escape hatch to go back to the legacy behavior. This macro +will be removed in future releases. Two types of required fixes are expected +to be common: + +* Accidental use of ``py::str`` instead of ``py::bytes``, masked by the legacy + behavior. These are probably very easy to fix, by changing from + ``py::str`` to ``py::bytes``. + +* Reliance on py::isinstance(obj) being ``true`` for + ``py::bytes``. This is likely to be easy to fix in most cases by adding + ``|| py::isinstance(obj)``, but a fix may be more involved, e.g. if + ``py::isinstance`` appears in a template. Such situations will require + careful review and custom fixes. + + +.. _upgrade-guide-2.6: + +v2.6 +==== + +Usage of the ``PYBIND11_OVERLOAD*`` macros and ``get_overload`` function should +be replaced by ``PYBIND11_OVERRIDE*`` and ``get_override``. In the future, the +old macros may be deprecated and removed. + +``py::module`` has been renamed ``py::module_``, but a backward compatible +typedef has been included. This change was to avoid a language change in C++20 +that requires unqualified ``module`` not be placed at the start of a logical +line. Qualified usage is unaffected and the typedef will remain unless the +C++ language rules change again. + +The public constructors of ``py::module_`` have been deprecated. Use +``PYBIND11_MODULE`` or ``module_::create_extension_module`` instead. + +An error is now thrown when ``__init__`` is forgotten on subclasses. This was +incorrect before, but was not checked. Add a call to ``__init__`` if it is +missing. + +A ``py::type_error`` is now thrown when casting to a subclass (like +``py::bytes`` from ``py::object``) if the conversion is not valid. Make a valid +conversion instead. + +The undocumented ``h.get_type()`` method has been deprecated and replaced by +``py::type::of(h)``. + +Enums now have a ``__str__`` method pre-defined; if you want to override it, +the simplest fix is to add the new ``py::prepend()`` tag when defining +``"__str__"``. + +If ``__eq__`` defined but not ``__hash__``, ``__hash__`` is now set to +``None``, as in normal CPython. You should add ``__hash__`` if you intended the +class to be hashable, possibly using the new ``py::hash`` shortcut. + +The constructors for ``py::array`` now always take signed integers for size, +for consistency. This may lead to compiler warnings on some systems. Cast to +``py::ssize_t`` instead of ``std::size_t``. + +The ``tools/clang`` submodule and ``tools/mkdoc.py`` have been moved to a +standalone package, `pybind11-mkdoc`_. If you were using those tools, please +use them via a pip install from the new location. + +The ``pybind11`` package on PyPI no longer fills the wheel "headers" slot - if +you were using the headers from this slot, they are available by requesting the +``global`` extra, that is, ``pip install "pybind11[global]"``. (Most users will +be unaffected, as the ``pybind11/include`` location is reported by ``python -m +pybind11 --includes`` and ``pybind11.get_include()`` is still correct and has +not changed since 2.5). + +.. _pybind11-mkdoc: https://github.com/pybind/pybind11-mkdoc + +CMake support: +-------------- + +The minimum required version of CMake is now 3.4. Several details of the CMake +support have been deprecated; warnings will be shown if you need to change +something. The changes are: + +* ``PYBIND11_CPP_STANDARD=`` is deprecated, please use + ``CMAKE_CXX_STANDARD=`` instead, or any other valid CMake CXX or CUDA + standard selection method, like ``target_compile_features``. + +* If you do not request a standard, pybind11 targets will compile with the + compiler default, but not less than C++11, instead of forcing C++14 always. + If you depend on the old behavior, please use ``set(CMAKE_CXX_STANDARD 14 CACHE STRING "")`` + instead. + +* Direct ``pybind11::module`` usage should always be accompanied by at least + ``set(CMAKE_CXX_VISIBILITY_PRESET hidden)`` or similar - it used to try to + manually force this compiler flag (but not correctly on all compilers or with + CUDA). + +* ``pybind11_add_module``'s ``SYSTEM`` argument is deprecated and does nothing; + linking now behaves like other imported libraries consistently in both + config and submodule mode, and behaves like a ``SYSTEM`` library by + default. + +* If ``PYTHON_EXECUTABLE`` is not set, virtual environments (``venv``, + ``virtualenv``, and ``conda``) are prioritized over the standard search + (similar to the new FindPython mode). + +In addition, the following changes may be of interest: + +* ``CMAKE_INTERPROCEDURAL_OPTIMIZATION`` will be respected by + ``pybind11_add_module`` if set instead of linking to ``pybind11::lto`` or + ``pybind11::thin_lto``. + +* Using ``find_package(Python COMPONENTS Interpreter Development)`` before + pybind11 will cause pybind11 to use the new Python mechanisms instead of its + own custom search, based on a patched version of classic ``FindPythonInterp`` + / ``FindPythonLibs``. In the future, this may become the default. A recent + (3.15+ or 3.18.2+) version of CMake is recommended. + + + +v2.5 +==== + +The Python package now includes the headers as data in the package itself, as +well as in the "headers" wheel slot. ``pybind11 --includes`` and +``pybind11.get_include()`` report the new location, which is always correct +regardless of how pybind11 was installed, making the old ``user=`` argument +meaningless. If you are not using the function to get the location already, you +are encouraged to switch to the package location. + + +v2.2 +==== + +Deprecation of the ``PYBIND11_PLUGIN`` macro +-------------------------------------------- + +``PYBIND11_MODULE`` is now the preferred way to create module entry points. +The old macro emits a compile-time deprecation warning. + +.. code-block:: cpp + + // old + PYBIND11_PLUGIN(example) { + py::module m("example", "documentation string"); + + m.def("add", [](int a, int b) { return a + b; }); + + return m.ptr(); + } + + // new + PYBIND11_MODULE(example, m) { + m.doc() = "documentation string"; // optional + + m.def("add", [](int a, int b) { return a + b; }); + } + + +New API for defining custom constructors and pickling functions +--------------------------------------------------------------- + +The old placement-new custom constructors have been deprecated. The new approach +uses ``py::init()`` and factory functions to greatly improve type safety. + +Placement-new can be called accidentally with an incompatible type (without any +compiler errors or warnings), or it can initialize the same object multiple times +if not careful with the Python-side ``__init__`` calls. The new-style custom +constructors prevent such mistakes. See :ref:`custom_constructors` for details. + +.. code-block:: cpp + + // old -- deprecated (runtime warning shown only in debug mode) + py::class(m, "Foo") + .def("__init__", [](Foo &self, ...) { + new (&self) Foo(...); // uses placement-new + }); + + // new + py::class(m, "Foo") + .def(py::init([](...) { // Note: no `self` argument + return new Foo(...); // return by raw pointer + // or: return std::make_unique(...); // return by holder + // or: return Foo(...); // return by value (move constructor) + })); + +Mirroring the custom constructor changes, ``py::pickle()`` is now the preferred +way to get and set object state. See :ref:`pickling` for details. + +.. code-block:: cpp + + // old -- deprecated (runtime warning shown only in debug mode) + py::class(m, "Foo") + ... + .def("__getstate__", [](const Foo &self) { + return py::make_tuple(self.value1(), self.value2(), ...); + }) + .def("__setstate__", [](Foo &self, py::tuple t) { + new (&self) Foo(t[0].cast(), ...); + }); + + // new + py::class(m, "Foo") + ... + .def(py::pickle( + [](const Foo &self) { // __getstate__ + return py::make_tuple(self.value1(), self.value2(), ...); // unchanged + }, + [](py::tuple t) { // __setstate__, note: no `self` argument + return new Foo(t[0].cast(), ...); + // or: return std::make_unique(...); // return by holder + // or: return Foo(...); // return by value (move constructor) + } + )); + +For both the constructors and pickling, warnings are shown at module +initialization time (on import, not when the functions are called). +They're only visible when compiled in debug mode. Sample warning: + +.. code-block:: none + + pybind11-bound class 'mymodule.Foo' is using an old-style placement-new '__init__' + which has been deprecated. See the upgrade guide in pybind11's docs. + + +Stricter enforcement of hidden symbol visibility for pybind11 modules +--------------------------------------------------------------------- + +pybind11 now tries to actively enforce hidden symbol visibility for modules. +If you're using either one of pybind11's :doc:`CMake or Python build systems +` (the two example repositories) and you haven't been exporting any +symbols, there's nothing to be concerned about. All the changes have been done +transparently in the background. If you were building manually or relied on +specific default visibility, read on. + +Setting default symbol visibility to *hidden* has always been recommended for +pybind11 (see :ref:`faq:symhidden`). On Linux and macOS, hidden symbol +visibility (in conjunction with the ``strip`` utility) yields much smaller +module binaries. `CPython's extension docs`_ also recommend hiding symbols +by default, with the goal of avoiding symbol name clashes between modules. +Starting with v2.2, pybind11 enforces this more strictly: (1) by declaring +all symbols inside the ``pybind11`` namespace as hidden and (2) by including +the ``-fvisibility=hidden`` flag on Linux and macOS (only for extension +modules, not for embedding the interpreter). + +.. _CPython's extension docs: https://docs.python.org/3/extending/extending.html#providing-a-c-api-for-an-extension-module + +The namespace-scope hidden visibility is done automatically in pybind11's +headers and it's generally transparent to users. It ensures that: + +* Modules compiled with different pybind11 versions don't clash with each other. + +* Some new features, like ``py::module_local`` bindings, can work as intended. + +The ``-fvisibility=hidden`` flag applies the same visibility to user bindings +outside of the ``pybind11`` namespace. It's now set automatic by pybind11's +CMake and Python build systems, but this needs to be done manually by users +of other build systems. Adding this flag: + +* Minimizes the chances of symbol conflicts between modules. E.g. if two + unrelated modules were statically linked to different (ABI-incompatible) + versions of the same third-party library, a symbol clash would be likely + (and would end with unpredictable results). + +* Produces smaller binaries on Linux and macOS, as pointed out previously. + +Within pybind11's CMake build system, ``pybind11_add_module`` has always been +setting the ``-fvisibility=hidden`` flag in release mode. From now on, it's +being applied unconditionally, even in debug mode and it can no longer be opted +out of with the ``NO_EXTRAS`` option. The ``pybind11::module`` target now also +adds this flag to its interface. The ``pybind11::embed`` target is unchanged. + +The most significant change here is for the ``pybind11::module`` target. If you +were previously relying on default visibility, i.e. if your Python module was +doubling as a shared library with dependents, you'll need to either export +symbols manually (recommended for cross-platform libraries) or factor out the +shared library (and have the Python module link to it like the other +dependents). As a temporary workaround, you can also restore default visibility +using the CMake code below, but this is not recommended in the long run: + +.. code-block:: cmake + + target_link_libraries(mymodule PRIVATE pybind11::module) + + add_library(restore_default_visibility INTERFACE) + target_compile_options(restore_default_visibility INTERFACE -fvisibility=default) + target_link_libraries(mymodule PRIVATE restore_default_visibility) + + +Local STL container bindings +---------------------------- + +Previous pybind11 versions could only bind types globally -- all pybind11 +modules, even unrelated ones, would have access to the same exported types. +However, this would also result in a conflict if two modules exported the +same C++ type, which is especially problematic for very common types, e.g. +``std::vector``. :ref:`module_local` were added to resolve this (see +that section for a complete usage guide). + +``py::class_`` still defaults to global bindings (because these types are +usually unique across modules), however in order to avoid clashes of opaque +types, ``py::bind_vector`` and ``py::bind_map`` will now bind STL containers +as ``py::module_local`` if their elements are: builtins (``int``, ``float``, +etc.), not bound using ``py::class_``, or bound as ``py::module_local``. For +example, this change allows multiple modules to bind ``std::vector`` +without causing conflicts. See :ref:`stl_bind` for more details. + +When upgrading to this version, if you have multiple modules which depend on +a single global binding of an STL container, note that all modules can still +accept foreign ``py::module_local`` types in the direction of Python-to-C++. +The locality only affects the C++-to-Python direction. If this is needed in +multiple modules, you'll need to either: + +* Add a copy of the same STL binding to all of the modules which need it. + +* Restore the global status of that single binding by marking it + ``py::module_local(false)``. + +The latter is an easy workaround, but in the long run it would be best to +localize all common type bindings in order to avoid conflicts with +third-party modules. + + +Negative strides for Python buffer objects and numpy arrays +----------------------------------------------------------- + +Support for negative strides required changing the integer type from unsigned +to signed in the interfaces of ``py::buffer_info`` and ``py::array``. If you +have compiler warnings enabled, you may notice some new conversion warnings +after upgrading. These can be resolved using ``static_cast``. + + +Deprecation of some ``py::object`` APIs +--------------------------------------- + +To compare ``py::object`` instances by pointer, you should now use +``obj1.is(obj2)`` which is equivalent to ``obj1 is obj2`` in Python. +Previously, pybind11 used ``operator==`` for this (``obj1 == obj2``), but +that could be confusing and is now deprecated (so that it can eventually +be replaced with proper rich object comparison in a future release). + +For classes which inherit from ``py::object``, ``borrowed`` and ``stolen`` +were previously available as protected constructor tags. Now the types +should be used directly instead: ``borrowed_t{}`` and ``stolen_t{}`` +(`#771 `_). + + +Stricter compile-time error checking +------------------------------------ + +Some error checks have been moved from run time to compile time. Notably, +automatic conversion of ``std::shared_ptr`` is not possible when ``T`` is +not directly registered with ``py::class_`` (e.g. ``std::shared_ptr`` +or ``std::shared_ptr>`` are not automatically convertible). +Attempting to bind a function with such arguments now results in a compile-time +error instead of waiting to fail at run time. + +``py::init<...>()`` constructor definitions are also stricter and now prevent +bindings which could cause unexpected behavior: + +.. code-block:: cpp + + struct Example { + Example(int &); + }; + + py::class_(m, "Example") + .def(py::init()); // OK, exact match + // .def(py::init()); // compile-time error, mismatch + +A non-``const`` lvalue reference is not allowed to bind to an rvalue. However, +note that a constructor taking ``const T &`` can still be registered using +``py::init()`` because a ``const`` lvalue reference can bind to an rvalue. + +v2.1 +==== + +Minimum compiler versions are enforced at compile time +------------------------------------------------------ + +The minimums also apply to v2.0 but the check is now explicit and a compile-time +error is raised if the compiler does not meet the requirements: + +* GCC >= 4.8 +* clang >= 3.3 (appleclang >= 5.0) +* MSVC >= 2015u3 +* Intel C++ >= 15.0 + + +The ``py::metaclass`` attribute is not required for static properties +--------------------------------------------------------------------- + +Binding classes with static properties is now possible by default. The +zero-parameter version of ``py::metaclass()`` is deprecated. However, a new +one-parameter ``py::metaclass(python_type)`` version was added for rare +cases when a custom metaclass is needed to override pybind11's default. + +.. code-block:: cpp + + // old -- emits a deprecation warning + py::class_(m, "Foo", py::metaclass()) + .def_property_readonly_static("foo", ...); + + // new -- static properties work without the attribute + py::class_(m, "Foo") + .def_property_readonly_static("foo", ...); + + // new -- advanced feature, override pybind11's default metaclass + py::class_(m, "Bar", py::metaclass(custom_python_type)) + ... + + +v2.0 +==== + +Breaking changes in ``py::class_`` +---------------------------------- + +These changes were necessary to make type definitions in pybind11 +future-proof, to support PyPy via its ``cpyext`` mechanism (`#527 +`_), and to improve efficiency +(`rev. 86d825 `_). + +1. Declarations of types that provide access via the buffer protocol must + now include the ``py::buffer_protocol()`` annotation as an argument to + the ``py::class_`` constructor. + + .. code-block:: cpp + + py::class_("Matrix", py::buffer_protocol()) + .def(py::init<...>()) + .def_buffer(...); + +2. Classes which include static properties (e.g. ``def_readwrite_static()``) + must now include the ``py::metaclass()`` attribute. Note: this requirement + has since been removed in v2.1. If you're upgrading from 1.x, it's + recommended to skip directly to v2.1 or newer. + +3. This version of pybind11 uses a redesigned mechanism for instantiating + trampoline classes that are used to override virtual methods from within + Python. This led to the following user-visible syntax change: + + .. code-block:: cpp + + // old v1.x syntax + py::class_("MyClass") + .alias() + ... + + // new v2.x syntax + py::class_("MyClass") + ... + + Importantly, both the original and the trampoline class are now specified + as arguments to the ``py::class_`` template, and the ``alias<..>()`` call + is gone. The new scheme has zero overhead in cases when Python doesn't + override any functions of the underlying C++ class. + `rev. 86d825 `_. + + The class type must be the first template argument given to ``py::class_`` + while the trampoline can be mixed in arbitrary order with other arguments + (see the following section). + + +Deprecation of the ``py::base()`` attribute +---------------------------------------------- + +``py::base()`` was deprecated in favor of specifying ``T`` as a template +argument to ``py::class_``. This new syntax also supports multiple inheritance. +Note that, while the type being exported must be the first argument in the +``py::class_`` template, the order of the following types (bases, +holder and/or trampoline) is not important. + +.. code-block:: cpp + + // old v1.x + py::class_("Derived", py::base()); + + // new v2.x + py::class_("Derived"); + + // new -- multiple inheritance + py::class_("Derived"); + + // new -- apart from `Derived` the argument order can be arbitrary + py::class_("Derived"); + + +Out-of-the-box support for ``std::shared_ptr`` +---------------------------------------------- + +The relevant type caster is now built in, so it's no longer necessary to +include a declaration of the form: + +.. code-block:: cpp + + PYBIND11_DECLARE_HOLDER_TYPE(T, std::shared_ptr) + +Continuing to do so won't cause an error or even a deprecation warning, +but it's completely redundant. + + +Deprecation of a few ``py::object`` APIs +---------------------------------------- + +All of the old-style calls emit deprecation warnings. + ++---------------------------------------+---------------------------------------------+ +| Old syntax | New syntax | ++=======================================+=============================================+ +| ``obj.call(args...)`` | ``obj(args...)`` | ++---------------------------------------+---------------------------------------------+ +| ``obj.str()`` | ``py::str(obj)`` | ++---------------------------------------+---------------------------------------------+ +| ``auto l = py::list(obj); l.check()`` | ``py::isinstance(obj)`` | ++---------------------------------------+---------------------------------------------+ +| ``py::object(ptr, true)`` | ``py::reinterpret_borrow(ptr)`` | ++---------------------------------------+---------------------------------------------+ +| ``py::object(ptr, false)`` | ``py::reinterpret_steal(ptr)`` | ++---------------------------------------+---------------------------------------------+ +| ``if (obj.attr("foo"))`` | ``if (py::hasattr(obj, "foo"))`` | ++---------------------------------------+---------------------------------------------+ +| ``if (obj["bar"])`` | ``if (obj.contains("bar"))`` | ++---------------------------------------+---------------------------------------------+ diff --git a/dmff/dpnblist/external/pybind11-2.11.1/include/pybind11/attr.h b/dmff/dpnblist/external/pybind11-2.11.1/include/pybind11/attr.h new file mode 100644 index 00000000..1044db94 --- /dev/null +++ b/dmff/dpnblist/external/pybind11-2.11.1/include/pybind11/attr.h @@ -0,0 +1,690 @@ +/* + pybind11/attr.h: Infrastructure for processing custom + type and function attributes + + Copyright (c) 2016 Wenzel Jakob + + All rights reserved. Use of this source code is governed by a + BSD-style license that can be found in the LICENSE file. +*/ + +#pragma once + +#include "detail/common.h" +#include "cast.h" + +#include + +PYBIND11_NAMESPACE_BEGIN(PYBIND11_NAMESPACE) + +/// \addtogroup annotations +/// @{ + +/// Annotation for methods +struct is_method { + handle class_; + explicit is_method(const handle &c) : class_(c) {} +}; + +/// Annotation for setters +struct is_setter {}; + +/// Annotation for operators +struct is_operator {}; + +/// Annotation for classes that cannot be subclassed +struct is_final {}; + +/// Annotation for parent scope +struct scope { + handle value; + explicit scope(const handle &s) : value(s) {} +}; + +/// Annotation for documentation +struct doc { + const char *value; + explicit doc(const char *value) : value(value) {} +}; + +/// Annotation for function names +struct name { + const char *value; + explicit name(const char *value) : value(value) {} +}; + +/// Annotation indicating that a function is an overload associated with a given "sibling" +struct sibling { + handle value; + explicit sibling(const handle &value) : value(value.ptr()) {} +}; + +/// Annotation indicating that a class derives from another given type +template +struct base { + + PYBIND11_DEPRECATED( + "base() was deprecated in favor of specifying 'T' as a template argument to class_") + base() = default; +}; + +/// Keep patient alive while nurse lives +template +struct keep_alive {}; + +/// Annotation indicating that a class is involved in a multiple inheritance relationship +struct multiple_inheritance {}; + +/// Annotation which enables dynamic attributes, i.e. adds `__dict__` to a class +struct dynamic_attr {}; + +/// Annotation which enables the buffer protocol for a type +struct buffer_protocol {}; + +/// Annotation which requests that a special metaclass is created for a type +struct metaclass { + handle value; + + PYBIND11_DEPRECATED("py::metaclass() is no longer required. It's turned on by default now.") + metaclass() = default; + + /// Override pybind11's default metaclass + explicit metaclass(handle value) : value(value) {} +}; + +/// Specifies a custom callback with signature `void (PyHeapTypeObject*)` that +/// may be used to customize the Python type. +/// +/// The callback is invoked immediately before `PyType_Ready`. +/// +/// Note: This is an advanced interface, and uses of it may require changes to +/// work with later versions of pybind11. You may wish to consult the +/// implementation of `make_new_python_type` in `detail/classes.h` to understand +/// the context in which the callback will be run. +struct custom_type_setup { + using callback = std::function; + + explicit custom_type_setup(callback value) : value(std::move(value)) {} + + callback value; +}; + +/// Annotation that marks a class as local to the module: +struct module_local { + const bool value; + constexpr explicit module_local(bool v = true) : value(v) {} +}; + +/// Annotation to mark enums as an arithmetic type +struct arithmetic {}; + +/// Mark a function for addition at the beginning of the existing overload chain instead of the end +struct prepend {}; + +/** \rst + A call policy which places one or more guard variables (``Ts...``) around the function call. + + For example, this definition: + + .. code-block:: cpp + + m.def("foo", foo, py::call_guard()); + + is equivalent to the following pseudocode: + + .. code-block:: cpp + + m.def("foo", [](args...) { + T scope_guard; + return foo(args...); // forwarded arguments + }); + \endrst */ +template +struct call_guard; + +template <> +struct call_guard<> { + using type = detail::void_type; +}; + +template +struct call_guard { + static_assert(std::is_default_constructible::value, + "The guard type must be default constructible"); + + using type = T; +}; + +template +struct call_guard { + struct type { + T guard{}; // Compose multiple guard types with left-to-right default-constructor order + typename call_guard::type next{}; + }; +}; + +/// @} annotations + +PYBIND11_NAMESPACE_BEGIN(detail) +/* Forward declarations */ +enum op_id : int; +enum op_type : int; +struct undefined_t; +template +struct op_; +void keep_alive_impl(size_t Nurse, size_t Patient, function_call &call, handle ret); + +/// Internal data structure which holds metadata about a keyword argument +struct argument_record { + const char *name; ///< Argument name + const char *descr; ///< Human-readable version of the argument value + handle value; ///< Associated Python object + bool convert : 1; ///< True if the argument is allowed to convert when loading + bool none : 1; ///< True if None is allowed when loading + + argument_record(const char *name, const char *descr, handle value, bool convert, bool none) + : name(name), descr(descr), value(value), convert(convert), none(none) {} +}; + +/// Internal data structure which holds metadata about a bound function (signature, overloads, +/// etc.) +struct function_record { + function_record() + : is_constructor(false), is_new_style_constructor(false), is_stateless(false), + is_operator(false), is_method(false), is_setter(false), has_args(false), + has_kwargs(false), prepend(false) {} + + /// Function name + char *name = nullptr; /* why no C++ strings? They generate heavier code.. */ + + // User-specified documentation string + char *doc = nullptr; + + /// Human-readable version of the function signature + char *signature = nullptr; + + /// List of registered keyword arguments + std::vector args; + + /// Pointer to lambda function which converts arguments and performs the actual call + handle (*impl)(function_call &) = nullptr; + + /// Storage for the wrapped function pointer and captured data, if any + void *data[3] = {}; + + /// Pointer to custom destructor for 'data' (if needed) + void (*free_data)(function_record *ptr) = nullptr; + + /// Return value policy associated with this function + return_value_policy policy = return_value_policy::automatic; + + /// True if name == '__init__' + bool is_constructor : 1; + + /// True if this is a new-style `__init__` defined in `detail/init.h` + bool is_new_style_constructor : 1; + + /// True if this is a stateless function pointer + bool is_stateless : 1; + + /// True if this is an operator (__add__), etc. + bool is_operator : 1; + + /// True if this is a method + bool is_method : 1; + + /// True if this is a setter + bool is_setter : 1; + + /// True if the function has a '*args' argument + bool has_args : 1; + + /// True if the function has a '**kwargs' argument + bool has_kwargs : 1; + + /// True if this function is to be inserted at the beginning of the overload resolution chain + bool prepend : 1; + + /// Number of arguments (including py::args and/or py::kwargs, if present) + std::uint16_t nargs; + + /// Number of leading positional arguments, which are terminated by a py::args or py::kwargs + /// argument or by a py::kw_only annotation. + std::uint16_t nargs_pos = 0; + + /// Number of leading arguments (counted in `nargs`) that are positional-only + std::uint16_t nargs_pos_only = 0; + + /// Python method object + PyMethodDef *def = nullptr; + + /// Python handle to the parent scope (a class or a module) + handle scope; + + /// Python handle to the sibling function representing an overload chain + handle sibling; + + /// Pointer to next overload + function_record *next = nullptr; +}; + +/// Special data structure which (temporarily) holds metadata about a bound class +struct type_record { + PYBIND11_NOINLINE type_record() + : multiple_inheritance(false), dynamic_attr(false), buffer_protocol(false), + default_holder(true), module_local(false), is_final(false) {} + + /// Handle to the parent scope + handle scope; + + /// Name of the class + const char *name = nullptr; + + // Pointer to RTTI type_info data structure + const std::type_info *type = nullptr; + + /// How large is the underlying C++ type? + size_t type_size = 0; + + /// What is the alignment of the underlying C++ type? + size_t type_align = 0; + + /// How large is the type's holder? + size_t holder_size = 0; + + /// The global operator new can be overridden with a class-specific variant + void *(*operator_new)(size_t) = nullptr; + + /// Function pointer to class_<..>::init_instance + void (*init_instance)(instance *, const void *) = nullptr; + + /// Function pointer to class_<..>::dealloc + void (*dealloc)(detail::value_and_holder &) = nullptr; + + /// List of base classes of the newly created type + list bases; + + /// Optional docstring + const char *doc = nullptr; + + /// Custom metaclass (optional) + handle metaclass; + + /// Custom type setup. + custom_type_setup::callback custom_type_setup_callback; + + /// Multiple inheritance marker + bool multiple_inheritance : 1; + + /// Does the class manage a __dict__? + bool dynamic_attr : 1; + + /// Does the class implement the buffer protocol? + bool buffer_protocol : 1; + + /// Is the default (unique_ptr) holder type used? + bool default_holder : 1; + + /// Is the class definition local to the module shared object? + bool module_local : 1; + + /// Is the class inheritable from python classes? + bool is_final : 1; + + PYBIND11_NOINLINE void add_base(const std::type_info &base, void *(*caster)(void *) ) { + auto *base_info = detail::get_type_info(base, false); + if (!base_info) { + std::string tname(base.name()); + detail::clean_type_id(tname); + pybind11_fail("generic_type: type \"" + std::string(name) + + "\" referenced unknown base type \"" + tname + "\""); + } + + if (default_holder != base_info->default_holder) { + std::string tname(base.name()); + detail::clean_type_id(tname); + pybind11_fail("generic_type: type \"" + std::string(name) + "\" " + + (default_holder ? "does not have" : "has") + + " a non-default holder type while its base \"" + tname + "\" " + + (base_info->default_holder ? "does not" : "does")); + } + + bases.append((PyObject *) base_info->type); + +#if PY_VERSION_HEX < 0x030B0000 + dynamic_attr |= base_info->type->tp_dictoffset != 0; +#else + dynamic_attr |= (base_info->type->tp_flags & Py_TPFLAGS_MANAGED_DICT) != 0; +#endif + + if (caster) { + base_info->implicit_casts.emplace_back(type, caster); + } + } +}; + +inline function_call::function_call(const function_record &f, handle p) : func(f), parent(p) { + args.reserve(f.nargs); + args_convert.reserve(f.nargs); +} + +/// Tag for a new-style `__init__` defined in `detail/init.h` +struct is_new_style_constructor {}; + +/** + * Partial template specializations to process custom attributes provided to + * cpp_function_ and class_. These are either used to initialize the respective + * fields in the type_record and function_record data structures or executed at + * runtime to deal with custom call policies (e.g. keep_alive). + */ +template +struct process_attribute; + +template +struct process_attribute_default { + /// Default implementation: do nothing + static void init(const T &, function_record *) {} + static void init(const T &, type_record *) {} + static void precall(function_call &) {} + static void postcall(function_call &, handle) {} +}; + +/// Process an attribute specifying the function's name +template <> +struct process_attribute : process_attribute_default { + static void init(const name &n, function_record *r) { r->name = const_cast(n.value); } +}; + +/// Process an attribute specifying the function's docstring +template <> +struct process_attribute : process_attribute_default { + static void init(const doc &n, function_record *r) { r->doc = const_cast(n.value); } +}; + +/// Process an attribute specifying the function's docstring (provided as a C-style string) +template <> +struct process_attribute : process_attribute_default { + static void init(const char *d, function_record *r) { r->doc = const_cast(d); } + static void init(const char *d, type_record *r) { r->doc = d; } +}; +template <> +struct process_attribute : process_attribute {}; + +/// Process an attribute indicating the function's return value policy +template <> +struct process_attribute : process_attribute_default { + static void init(const return_value_policy &p, function_record *r) { r->policy = p; } +}; + +/// Process an attribute which indicates that this is an overloaded function associated with a +/// given sibling +template <> +struct process_attribute : process_attribute_default { + static void init(const sibling &s, function_record *r) { r->sibling = s.value; } +}; + +/// Process an attribute which indicates that this function is a method +template <> +struct process_attribute : process_attribute_default { + static void init(const is_method &s, function_record *r) { + r->is_method = true; + r->scope = s.class_; + } +}; + +/// Process an attribute which indicates that this function is a setter +template <> +struct process_attribute : process_attribute_default { + static void init(const is_setter &, function_record *r) { r->is_setter = true; } +}; + +/// Process an attribute which indicates the parent scope of a method +template <> +struct process_attribute : process_attribute_default { + static void init(const scope &s, function_record *r) { r->scope = s.value; } +}; + +/// Process an attribute which indicates that this function is an operator +template <> +struct process_attribute : process_attribute_default { + static void init(const is_operator &, function_record *r) { r->is_operator = true; } +}; + +template <> +struct process_attribute + : process_attribute_default { + static void init(const is_new_style_constructor &, function_record *r) { + r->is_new_style_constructor = true; + } +}; + +inline void check_kw_only_arg(const arg &a, function_record *r) { + if (r->args.size() > r->nargs_pos && (!a.name || a.name[0] == '\0')) { + pybind11_fail("arg(): cannot specify an unnamed argument after a kw_only() annotation or " + "args() argument"); + } +} + +inline void append_self_arg_if_needed(function_record *r) { + if (r->is_method && r->args.empty()) { + r->args.emplace_back("self", nullptr, handle(), /*convert=*/true, /*none=*/false); + } +} + +/// Process a keyword argument attribute (*without* a default value) +template <> +struct process_attribute : process_attribute_default { + static void init(const arg &a, function_record *r) { + append_self_arg_if_needed(r); + r->args.emplace_back(a.name, nullptr, handle(), !a.flag_noconvert, a.flag_none); + + check_kw_only_arg(a, r); + } +}; + +/// Process a keyword argument attribute (*with* a default value) +template <> +struct process_attribute : process_attribute_default { + static void init(const arg_v &a, function_record *r) { + if (r->is_method && r->args.empty()) { + r->args.emplace_back( + "self", /*descr=*/nullptr, /*parent=*/handle(), /*convert=*/true, /*none=*/false); + } + + if (!a.value) { +#if defined(PYBIND11_DETAILED_ERROR_MESSAGES) + std::string descr("'"); + if (a.name) { + descr += std::string(a.name) + ": "; + } + descr += a.type + "'"; + if (r->is_method) { + if (r->name) { + descr += " in method '" + (std::string) str(r->scope) + "." + + (std::string) r->name + "'"; + } else { + descr += " in method of '" + (std::string) str(r->scope) + "'"; + } + } else if (r->name) { + descr += " in function '" + (std::string) r->name + "'"; + } + pybind11_fail("arg(): could not convert default argument " + descr + + " into a Python object (type not registered yet?)"); +#else + pybind11_fail("arg(): could not convert default argument " + "into a Python object (type not registered yet?). " + "#define PYBIND11_DETAILED_ERROR_MESSAGES or compile in debug mode for " + "more information."); +#endif + } + r->args.emplace_back(a.name, a.descr, a.value.inc_ref(), !a.flag_noconvert, a.flag_none); + + check_kw_only_arg(a, r); + } +}; + +/// Process a keyword-only-arguments-follow pseudo argument +template <> +struct process_attribute : process_attribute_default { + static void init(const kw_only &, function_record *r) { + append_self_arg_if_needed(r); + if (r->has_args && r->nargs_pos != static_cast(r->args.size())) { + pybind11_fail("Mismatched args() and kw_only(): they must occur at the same relative " + "argument location (or omit kw_only() entirely)"); + } + r->nargs_pos = static_cast(r->args.size()); + } +}; + +/// Process a positional-only-argument maker +template <> +struct process_attribute : process_attribute_default { + static void init(const pos_only &, function_record *r) { + append_self_arg_if_needed(r); + r->nargs_pos_only = static_cast(r->args.size()); + if (r->nargs_pos_only > r->nargs_pos) { + pybind11_fail("pos_only(): cannot follow a py::args() argument"); + } + // It also can't follow a kw_only, but a static_assert in pybind11.h checks that + } +}; + +/// Process a parent class attribute. Single inheritance only (class_ itself already guarantees +/// that) +template +struct process_attribute::value>> + : process_attribute_default { + static void init(const handle &h, type_record *r) { r->bases.append(h); } +}; + +/// Process a parent class attribute (deprecated, does not support multiple inheritance) +template +struct process_attribute> : process_attribute_default> { + static void init(const base &, type_record *r) { r->add_base(typeid(T), nullptr); } +}; + +/// Process a multiple inheritance attribute +template <> +struct process_attribute : process_attribute_default { + static void init(const multiple_inheritance &, type_record *r) { + r->multiple_inheritance = true; + } +}; + +template <> +struct process_attribute : process_attribute_default { + static void init(const dynamic_attr &, type_record *r) { r->dynamic_attr = true; } +}; + +template <> +struct process_attribute { + static void init(const custom_type_setup &value, type_record *r) { + r->custom_type_setup_callback = value.value; + } +}; + +template <> +struct process_attribute : process_attribute_default { + static void init(const is_final &, type_record *r) { r->is_final = true; } +}; + +template <> +struct process_attribute : process_attribute_default { + static void init(const buffer_protocol &, type_record *r) { r->buffer_protocol = true; } +}; + +template <> +struct process_attribute : process_attribute_default { + static void init(const metaclass &m, type_record *r) { r->metaclass = m.value; } +}; + +template <> +struct process_attribute : process_attribute_default { + static void init(const module_local &l, type_record *r) { r->module_local = l.value; } +}; + +/// Process a 'prepend' attribute, putting this at the beginning of the overload chain +template <> +struct process_attribute : process_attribute_default { + static void init(const prepend &, function_record *r) { r->prepend = true; } +}; + +/// Process an 'arithmetic' attribute for enums (does nothing here) +template <> +struct process_attribute : process_attribute_default {}; + +template +struct process_attribute> : process_attribute_default> {}; + +/** + * Process a keep_alive call policy -- invokes keep_alive_impl during the + * pre-call handler if both Nurse, Patient != 0 and use the post-call handler + * otherwise + */ +template +struct process_attribute> + : public process_attribute_default> { + template = 0> + static void precall(function_call &call) { + keep_alive_impl(Nurse, Patient, call, handle()); + } + template = 0> + static void postcall(function_call &, handle) {} + template = 0> + static void precall(function_call &) {} + template = 0> + static void postcall(function_call &call, handle ret) { + keep_alive_impl(Nurse, Patient, call, ret); + } +}; + +/// Recursively iterate over variadic template arguments +template +struct process_attributes { + static void init(const Args &...args, function_record *r) { + PYBIND11_WORKAROUND_INCORRECT_MSVC_C4100(r); + PYBIND11_WORKAROUND_INCORRECT_GCC_UNUSED_BUT_SET_PARAMETER(r); + using expander = int[]; + (void) expander{ + 0, ((void) process_attribute::type>::init(args, r), 0)...}; + } + static void init(const Args &...args, type_record *r) { + PYBIND11_WORKAROUND_INCORRECT_MSVC_C4100(r); + PYBIND11_WORKAROUND_INCORRECT_GCC_UNUSED_BUT_SET_PARAMETER(r); + using expander = int[]; + (void) expander{0, + (process_attribute::type>::init(args, r), 0)...}; + } + static void precall(function_call &call) { + PYBIND11_WORKAROUND_INCORRECT_MSVC_C4100(call); + using expander = int[]; + (void) expander{0, + (process_attribute::type>::precall(call), 0)...}; + } + static void postcall(function_call &call, handle fn_ret) { + PYBIND11_WORKAROUND_INCORRECT_MSVC_C4100(call, fn_ret); + PYBIND11_WORKAROUND_INCORRECT_GCC_UNUSED_BUT_SET_PARAMETER(fn_ret); + using expander = int[]; + (void) expander{ + 0, (process_attribute::type>::postcall(call, fn_ret), 0)...}; + } +}; + +template +using is_call_guard = is_instantiation; + +/// Extract the ``type`` from the first `call_guard` in `Extras...` (or `void_type` if none found) +template +using extract_guard_t = typename exactly_one_t, Extra...>::type; + +/// Check the number of named arguments at compile time +template ::value...), + size_t self = constexpr_sum(std::is_same::value...)> +constexpr bool expected_num_args(size_t nargs, bool has_args, bool has_kwargs) { + PYBIND11_WORKAROUND_INCORRECT_MSVC_C4100(nargs, has_args, has_kwargs); + return named == 0 || (self + named + size_t(has_args) + size_t(has_kwargs)) == nargs; +} + +PYBIND11_NAMESPACE_END(detail) +PYBIND11_NAMESPACE_END(PYBIND11_NAMESPACE) diff --git a/dmff/dpnblist/external/pybind11-2.11.1/include/pybind11/buffer_info.h b/dmff/dpnblist/external/pybind11-2.11.1/include/pybind11/buffer_info.h new file mode 100644 index 00000000..b99ee8be --- /dev/null +++ b/dmff/dpnblist/external/pybind11-2.11.1/include/pybind11/buffer_info.h @@ -0,0 +1,208 @@ +/* + pybind11/buffer_info.h: Python buffer object interface + + Copyright (c) 2016 Wenzel Jakob + + All rights reserved. Use of this source code is governed by a + BSD-style license that can be found in the LICENSE file. +*/ + +#pragma once + +#include "detail/common.h" + +PYBIND11_NAMESPACE_BEGIN(PYBIND11_NAMESPACE) + +PYBIND11_NAMESPACE_BEGIN(detail) + +// Default, C-style strides +inline std::vector c_strides(const std::vector &shape, ssize_t itemsize) { + auto ndim = shape.size(); + std::vector strides(ndim, itemsize); + if (ndim > 0) { + for (size_t i = ndim - 1; i > 0; --i) { + strides[i - 1] = strides[i] * shape[i]; + } + } + return strides; +} + +// F-style strides; default when constructing an array_t with `ExtraFlags & f_style` +inline std::vector f_strides(const std::vector &shape, ssize_t itemsize) { + auto ndim = shape.size(); + std::vector strides(ndim, itemsize); + for (size_t i = 1; i < ndim; ++i) { + strides[i] = strides[i - 1] * shape[i - 1]; + } + return strides; +} + +template +struct compare_buffer_info; + +PYBIND11_NAMESPACE_END(detail) + +/// Information record describing a Python buffer object +struct buffer_info { + void *ptr = nullptr; // Pointer to the underlying storage + ssize_t itemsize = 0; // Size of individual items in bytes + ssize_t size = 0; // Total number of entries + std::string format; // For homogeneous buffers, this should be set to + // format_descriptor::format() + ssize_t ndim = 0; // Number of dimensions + std::vector shape; // Shape of the tensor (1 entry per dimension) + std::vector strides; // Number of bytes between adjacent entries + // (for each per dimension) + bool readonly = false; // flag to indicate if the underlying storage may be written to + + buffer_info() = default; + + buffer_info(void *ptr, + ssize_t itemsize, + const std::string &format, + ssize_t ndim, + detail::any_container shape_in, + detail::any_container strides_in, + bool readonly = false) + : ptr(ptr), itemsize(itemsize), size(1), format(format), ndim(ndim), + shape(std::move(shape_in)), strides(std::move(strides_in)), readonly(readonly) { + if (ndim != (ssize_t) shape.size() || ndim != (ssize_t) strides.size()) { + pybind11_fail("buffer_info: ndim doesn't match shape and/or strides length"); + } + for (size_t i = 0; i < (size_t) ndim; ++i) { + size *= shape[i]; + } + } + + template + buffer_info(T *ptr, + detail::any_container shape_in, + detail::any_container strides_in, + bool readonly = false) + : buffer_info(private_ctr_tag(), + ptr, + sizeof(T), + format_descriptor::format(), + static_cast(shape_in->size()), + std::move(shape_in), + std::move(strides_in), + readonly) {} + + buffer_info(void *ptr, + ssize_t itemsize, + const std::string &format, + ssize_t size, + bool readonly = false) + : buffer_info(ptr, itemsize, format, 1, {size}, {itemsize}, readonly) {} + + template + buffer_info(T *ptr, ssize_t size, bool readonly = false) + : buffer_info(ptr, sizeof(T), format_descriptor::format(), size, readonly) {} + + template + buffer_info(const T *ptr, ssize_t size, bool readonly = true) + : buffer_info( + const_cast(ptr), sizeof(T), format_descriptor::format(), size, readonly) {} + + explicit buffer_info(Py_buffer *view, bool ownview = true) + : buffer_info( + view->buf, + view->itemsize, + view->format, + view->ndim, + {view->shape, view->shape + view->ndim}, + /* Though buffer::request() requests PyBUF_STRIDES, ctypes objects + * ignore this flag and return a view with NULL strides. + * When strides are NULL, build them manually. */ + view->strides + ? std::vector(view->strides, view->strides + view->ndim) + : detail::c_strides({view->shape, view->shape + view->ndim}, view->itemsize), + (view->readonly != 0)) { + // NOLINTNEXTLINE(cppcoreguidelines-prefer-member-initializer) + this->m_view = view; + // NOLINTNEXTLINE(cppcoreguidelines-prefer-member-initializer) + this->ownview = ownview; + } + + buffer_info(const buffer_info &) = delete; + buffer_info &operator=(const buffer_info &) = delete; + + buffer_info(buffer_info &&other) noexcept { (*this) = std::move(other); } + + buffer_info &operator=(buffer_info &&rhs) noexcept { + ptr = rhs.ptr; + itemsize = rhs.itemsize; + size = rhs.size; + format = std::move(rhs.format); + ndim = rhs.ndim; + shape = std::move(rhs.shape); + strides = std::move(rhs.strides); + std::swap(m_view, rhs.m_view); + std::swap(ownview, rhs.ownview); + readonly = rhs.readonly; + return *this; + } + + ~buffer_info() { + if (m_view && ownview) { + PyBuffer_Release(m_view); + delete m_view; + } + } + + Py_buffer *view() const { return m_view; } + Py_buffer *&view() { return m_view; } + + /* True if the buffer item type is equivalent to `T`. */ + // To define "equivalent" by example: + // `buffer_info::item_type_is_equivalent_to(b)` and + // `buffer_info::item_type_is_equivalent_to(b)` may both be true + // on some platforms, but `int` and `unsigned` will never be equivalent. + // For the ground truth, please inspect `detail::compare_buffer_info<>`. + template + bool item_type_is_equivalent_to() const { + return detail::compare_buffer_info::compare(*this); + } + +private: + struct private_ctr_tag {}; + + buffer_info(private_ctr_tag, + void *ptr, + ssize_t itemsize, + const std::string &format, + ssize_t ndim, + detail::any_container &&shape_in, + detail::any_container &&strides_in, + bool readonly) + : buffer_info( + ptr, itemsize, format, ndim, std::move(shape_in), std::move(strides_in), readonly) {} + + Py_buffer *m_view = nullptr; + bool ownview = false; +}; + +PYBIND11_NAMESPACE_BEGIN(detail) + +template +struct compare_buffer_info { + static bool compare(const buffer_info &b) { + // NOLINTNEXTLINE(bugprone-sizeof-expression) Needed for `PyObject *` + return b.format == format_descriptor::format() && b.itemsize == (ssize_t) sizeof(T); + } +}; + +template +struct compare_buffer_info::value>> { + static bool compare(const buffer_info &b) { + return (size_t) b.itemsize == sizeof(T) + && (b.format == format_descriptor::value + || ((sizeof(T) == sizeof(long)) + && b.format == (std::is_unsigned::value ? "L" : "l")) + || ((sizeof(T) == sizeof(size_t)) + && b.format == (std::is_unsigned::value ? "N" : "n"))); + } +}; + +PYBIND11_NAMESPACE_END(detail) +PYBIND11_NAMESPACE_END(PYBIND11_NAMESPACE) diff --git a/dmff/dpnblist/external/pybind11-2.11.1/include/pybind11/cast.h b/dmff/dpnblist/external/pybind11-2.11.1/include/pybind11/cast.h new file mode 100644 index 00000000..db393411 --- /dev/null +++ b/dmff/dpnblist/external/pybind11-2.11.1/include/pybind11/cast.h @@ -0,0 +1,1704 @@ +/* + pybind11/cast.h: Partial template specializations to cast between + C++ and Python types + + Copyright (c) 2016 Wenzel Jakob + + All rights reserved. Use of this source code is governed by a + BSD-style license that can be found in the LICENSE file. +*/ + +#pragma once + +#include "detail/common.h" +#include "detail/descr.h" +#include "detail/type_caster_base.h" +#include "detail/typeid.h" +#include "pytypes.h" + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +PYBIND11_NAMESPACE_BEGIN(PYBIND11_NAMESPACE) + +PYBIND11_WARNING_DISABLE_MSVC(4127) + +PYBIND11_NAMESPACE_BEGIN(detail) + +template +class type_caster : public type_caster_base {}; +template +using make_caster = type_caster>; + +// Shortcut for calling a caster's `cast_op_type` cast operator for casting a type_caster to a T +template +typename make_caster::template cast_op_type cast_op(make_caster &caster) { + return caster.operator typename make_caster::template cast_op_type(); +} +template +typename make_caster::template cast_op_type::type> +cast_op(make_caster &&caster) { + return std::move(caster).operator typename make_caster:: + template cast_op_type::type>(); +} + +template +class type_caster> { +private: + using caster_t = make_caster; + caster_t subcaster; + using reference_t = type &; + using subcaster_cast_op_type = typename caster_t::template cast_op_type; + + static_assert( + std::is_same::type &, subcaster_cast_op_type>::value + || std::is_same::value, + "std::reference_wrapper caster requires T to have a caster with an " + "`operator T &()` or `operator const T &()`"); + +public: + bool load(handle src, bool convert) { return subcaster.load(src, convert); } + static constexpr auto name = caster_t::name; + static handle + cast(const std::reference_wrapper &src, return_value_policy policy, handle parent) { + // It is definitely wrong to take ownership of this pointer, so mask that rvp + if (policy == return_value_policy::take_ownership + || policy == return_value_policy::automatic) { + policy = return_value_policy::automatic_reference; + } + return caster_t::cast(&src.get(), policy, parent); + } + template + using cast_op_type = std::reference_wrapper; + explicit operator std::reference_wrapper() { return cast_op(subcaster); } +}; + +#define PYBIND11_TYPE_CASTER(type, py_name) \ +protected: \ + type value; \ + \ +public: \ + static constexpr auto name = py_name; \ + template >::value, \ + int> \ + = 0> \ + static ::pybind11::handle cast( \ + T_ *src, ::pybind11::return_value_policy policy, ::pybind11::handle parent) { \ + if (!src) \ + return ::pybind11::none().release(); \ + if (policy == ::pybind11::return_value_policy::take_ownership) { \ + auto h = cast(std::move(*src), policy, parent); \ + delete src; \ + return h; \ + } \ + return cast(*src, policy, parent); \ + } \ + operator type *() { return &value; } /* NOLINT(bugprone-macro-parentheses) */ \ + operator type &() { return value; } /* NOLINT(bugprone-macro-parentheses) */ \ + operator type &&() && { return std::move(value); } /* NOLINT(bugprone-macro-parentheses) */ \ + template \ + using cast_op_type = ::pybind11::detail::movable_cast_op_type + +template +using is_std_char_type = any_of, /* std::string */ +#if defined(PYBIND11_HAS_U8STRING) + std::is_same, /* std::u8string */ +#endif + std::is_same, /* std::u16string */ + std::is_same, /* std::u32string */ + std::is_same /* std::wstring */ + >; + +template +struct type_caster::value && !is_std_char_type::value>> { + using _py_type_0 = conditional_t; + using _py_type_1 = conditional_t::value, + _py_type_0, + typename std::make_unsigned<_py_type_0>::type>; + using py_type = conditional_t::value, double, _py_type_1>; + +public: + bool load(handle src, bool convert) { + py_type py_value; + + if (!src) { + return false; + } + +#if !defined(PYPY_VERSION) + auto index_check = [](PyObject *o) { return PyIndex_Check(o); }; +#else + // In PyPy 7.3.3, `PyIndex_Check` is implemented by calling `__index__`, + // while CPython only considers the existence of `nb_index`/`__index__`. + auto index_check = [](PyObject *o) { return hasattr(o, "__index__"); }; +#endif + + if (std::is_floating_point::value) { + if (convert || PyFloat_Check(src.ptr())) { + py_value = (py_type) PyFloat_AsDouble(src.ptr()); + } else { + return false; + } + } else if (PyFloat_Check(src.ptr()) + || (!convert && !PYBIND11_LONG_CHECK(src.ptr()) && !index_check(src.ptr()))) { + return false; + } else { + handle src_or_index = src; + // PyPy: 7.3.7's 3.8 does not implement PyLong_*'s __index__ calls. +#if PY_VERSION_HEX < 0x03080000 || defined(PYPY_VERSION) + object index; + if (!PYBIND11_LONG_CHECK(src.ptr())) { // So: index_check(src.ptr()) + index = reinterpret_steal(PyNumber_Index(src.ptr())); + if (!index) { + PyErr_Clear(); + if (!convert) + return false; + } else { + src_or_index = index; + } + } +#endif + if (std::is_unsigned::value) { + py_value = as_unsigned(src_or_index.ptr()); + } else { // signed integer: + py_value = sizeof(T) <= sizeof(long) + ? (py_type) PyLong_AsLong(src_or_index.ptr()) + : (py_type) PYBIND11_LONG_AS_LONGLONG(src_or_index.ptr()); + } + } + + // Python API reported an error + bool py_err = py_value == (py_type) -1 && PyErr_Occurred(); + + // Check to see if the conversion is valid (integers should match exactly) + // Signed/unsigned checks happen elsewhere + if (py_err + || (std::is_integral::value && sizeof(py_type) != sizeof(T) + && py_value != (py_type) (T) py_value)) { + PyErr_Clear(); + if (py_err && convert && (PyNumber_Check(src.ptr()) != 0)) { + auto tmp = reinterpret_steal(std::is_floating_point::value + ? PyNumber_Float(src.ptr()) + : PyNumber_Long(src.ptr())); + PyErr_Clear(); + return load(tmp, false); + } + return false; + } + + value = (T) py_value; + return true; + } + + template + static typename std::enable_if::value, handle>::type + cast(U src, return_value_policy /* policy */, handle /* parent */) { + return PyFloat_FromDouble((double) src); + } + + template + static typename std::enable_if::value && std::is_signed::value + && (sizeof(U) <= sizeof(long)), + handle>::type + cast(U src, return_value_policy /* policy */, handle /* parent */) { + return PYBIND11_LONG_FROM_SIGNED((long) src); + } + + template + static typename std::enable_if::value && std::is_unsigned::value + && (sizeof(U) <= sizeof(unsigned long)), + handle>::type + cast(U src, return_value_policy /* policy */, handle /* parent */) { + return PYBIND11_LONG_FROM_UNSIGNED((unsigned long) src); + } + + template + static typename std::enable_if::value && std::is_signed::value + && (sizeof(U) > sizeof(long)), + handle>::type + cast(U src, return_value_policy /* policy */, handle /* parent */) { + return PyLong_FromLongLong((long long) src); + } + + template + static typename std::enable_if::value && std::is_unsigned::value + && (sizeof(U) > sizeof(unsigned long)), + handle>::type + cast(U src, return_value_policy /* policy */, handle /* parent */) { + return PyLong_FromUnsignedLongLong((unsigned long long) src); + } + + PYBIND11_TYPE_CASTER(T, const_name::value>("int", "float")); +}; + +template +struct void_caster { +public: + bool load(handle src, bool) { + if (src && src.is_none()) { + return true; + } + return false; + } + static handle cast(T, return_value_policy /* policy */, handle /* parent */) { + return none().release(); + } + PYBIND11_TYPE_CASTER(T, const_name("None")); +}; + +template <> +class type_caster : public void_caster {}; + +template <> +class type_caster : public type_caster { +public: + using type_caster::cast; + + bool load(handle h, bool) { + if (!h) { + return false; + } + if (h.is_none()) { + value = nullptr; + return true; + } + + /* Check if this is a capsule */ + if (isinstance(h)) { + value = reinterpret_borrow(h); + return true; + } + + /* Check if this is a C++ type */ + const auto &bases = all_type_info((PyTypeObject *) type::handle_of(h).ptr()); + if (bases.size() == 1) { // Only allowing loading from a single-value type + value = values_and_holders(reinterpret_cast(h.ptr())).begin()->value_ptr(); + return true; + } + + /* Fail */ + return false; + } + + static handle cast(const void *ptr, return_value_policy /* policy */, handle /* parent */) { + if (ptr) { + return capsule(ptr).release(); + } + return none().release(); + } + + template + using cast_op_type = void *&; + explicit operator void *&() { return value; } + static constexpr auto name = const_name("capsule"); + +private: + void *value = nullptr; +}; + +template <> +class type_caster : public void_caster {}; + +template <> +class type_caster { +public: + bool load(handle src, bool convert) { + if (!src) { + return false; + } + if (src.ptr() == Py_True) { + value = true; + return true; + } + if (src.ptr() == Py_False) { + value = false; + return true; + } + if (convert || (std::strcmp("numpy.bool_", Py_TYPE(src.ptr())->tp_name) == 0)) { + // (allow non-implicit conversion for numpy booleans) + + Py_ssize_t res = -1; + if (src.is_none()) { + res = 0; // None is implicitly converted to False + } +#if defined(PYPY_VERSION) + // On PyPy, check that "__bool__" attr exists + else if (hasattr(src, PYBIND11_BOOL_ATTR)) { + res = PyObject_IsTrue(src.ptr()); + } +#else + // Alternate approach for CPython: this does the same as the above, but optimized + // using the CPython API so as to avoid an unneeded attribute lookup. + else if (auto *tp_as_number = src.ptr()->ob_type->tp_as_number) { + if (PYBIND11_NB_BOOL(tp_as_number)) { + res = (*PYBIND11_NB_BOOL(tp_as_number))(src.ptr()); + } + } +#endif + if (res == 0 || res == 1) { + value = (res != 0); + return true; + } + PyErr_Clear(); + } + return false; + } + static handle cast(bool src, return_value_policy /* policy */, handle /* parent */) { + return handle(src ? Py_True : Py_False).inc_ref(); + } + PYBIND11_TYPE_CASTER(bool, const_name("bool")); +}; + +// Helper class for UTF-{8,16,32} C++ stl strings: +template +struct string_caster { + using CharT = typename StringType::value_type; + + // Simplify life by being able to assume standard char sizes (the standard only guarantees + // minimums, but Python requires exact sizes) + static_assert(!std::is_same::value || sizeof(CharT) == 1, + "Unsupported char size != 1"); +#if defined(PYBIND11_HAS_U8STRING) + static_assert(!std::is_same::value || sizeof(CharT) == 1, + "Unsupported char8_t size != 1"); +#endif + static_assert(!std::is_same::value || sizeof(CharT) == 2, + "Unsupported char16_t size != 2"); + static_assert(!std::is_same::value || sizeof(CharT) == 4, + "Unsupported char32_t size != 4"); + // wchar_t can be either 16 bits (Windows) or 32 (everywhere else) + static_assert(!std::is_same::value || sizeof(CharT) == 2 || sizeof(CharT) == 4, + "Unsupported wchar_t size != 2/4"); + static constexpr size_t UTF_N = 8 * sizeof(CharT); + + bool load(handle src, bool) { + handle load_src = src; + if (!src) { + return false; + } + if (!PyUnicode_Check(load_src.ptr())) { + return load_raw(load_src); + } + + // For UTF-8 we avoid the need for a temporary `bytes` object by using + // `PyUnicode_AsUTF8AndSize`. + if (UTF_N == 8) { + Py_ssize_t size = -1; + const auto *buffer + = reinterpret_cast(PyUnicode_AsUTF8AndSize(load_src.ptr(), &size)); + if (!buffer) { + PyErr_Clear(); + return false; + } + value = StringType(buffer, static_cast(size)); + return true; + } + + auto utfNbytes + = reinterpret_steal(PyUnicode_AsEncodedString(load_src.ptr(), + UTF_N == 8 ? "utf-8" + : UTF_N == 16 ? "utf-16" + : "utf-32", + nullptr)); + if (!utfNbytes) { + PyErr_Clear(); + return false; + } + + const auto *buffer + = reinterpret_cast(PYBIND11_BYTES_AS_STRING(utfNbytes.ptr())); + size_t length = (size_t) PYBIND11_BYTES_SIZE(utfNbytes.ptr()) / sizeof(CharT); + // Skip BOM for UTF-16/32 + if (UTF_N > 8) { + buffer++; + length--; + } + value = StringType(buffer, length); + + // If we're loading a string_view we need to keep the encoded Python object alive: + if (IsView) { + loader_life_support::add_patient(utfNbytes); + } + + return true; + } + + static handle + cast(const StringType &src, return_value_policy /* policy */, handle /* parent */) { + const char *buffer = reinterpret_cast(src.data()); + auto nbytes = ssize_t(src.size() * sizeof(CharT)); + handle s = decode_utfN(buffer, nbytes); + if (!s) { + throw error_already_set(); + } + return s; + } + + PYBIND11_TYPE_CASTER(StringType, const_name(PYBIND11_STRING_NAME)); + +private: + static handle decode_utfN(const char *buffer, ssize_t nbytes) { +#if !defined(PYPY_VERSION) + return UTF_N == 8 ? PyUnicode_DecodeUTF8(buffer, nbytes, nullptr) + : UTF_N == 16 ? PyUnicode_DecodeUTF16(buffer, nbytes, nullptr, nullptr) + : PyUnicode_DecodeUTF32(buffer, nbytes, nullptr, nullptr); +#else + // PyPy segfaults when on PyUnicode_DecodeUTF16 (and possibly on PyUnicode_DecodeUTF32 as + // well), so bypass the whole thing by just passing the encoding as a string value, which + // works properly: + return PyUnicode_Decode(buffer, + nbytes, + UTF_N == 8 ? "utf-8" + : UTF_N == 16 ? "utf-16" + : "utf-32", + nullptr); +#endif + } + + // When loading into a std::string or char*, accept a bytes/bytearray object as-is (i.e. + // without any encoding/decoding attempt). For other C++ char sizes this is a no-op. + // which supports loading a unicode from a str, doesn't take this path. + template + bool load_raw(enable_if_t::value, handle> src) { + if (PYBIND11_BYTES_CHECK(src.ptr())) { + // We were passed raw bytes; accept it into a std::string or char* + // without any encoding attempt. + const char *bytes = PYBIND11_BYTES_AS_STRING(src.ptr()); + if (!bytes) { + pybind11_fail("Unexpected PYBIND11_BYTES_AS_STRING() failure."); + } + value = StringType(bytes, (size_t) PYBIND11_BYTES_SIZE(src.ptr())); + return true; + } + if (PyByteArray_Check(src.ptr())) { + // We were passed a bytearray; accept it into a std::string or char* + // without any encoding attempt. + const char *bytearray = PyByteArray_AsString(src.ptr()); + if (!bytearray) { + pybind11_fail("Unexpected PyByteArray_AsString() failure."); + } + value = StringType(bytearray, (size_t) PyByteArray_Size(src.ptr())); + return true; + } + + return false; + } + + template + bool load_raw(enable_if_t::value, handle>) { + return false; + } +}; + +template +struct type_caster, + enable_if_t::value>> + : string_caster> {}; + +#ifdef PYBIND11_HAS_STRING_VIEW +template +struct type_caster, + enable_if_t::value>> + : string_caster, true> {}; +#endif + +// Type caster for C-style strings. We basically use a std::string type caster, but also add the +// ability to use None as a nullptr char* (which the string caster doesn't allow). +template +struct type_caster::value>> { + using StringType = std::basic_string; + using StringCaster = make_caster; + StringCaster str_caster; + bool none = false; + CharT one_char = 0; + +public: + bool load(handle src, bool convert) { + if (!src) { + return false; + } + if (src.is_none()) { + // Defer accepting None to other overloads (if we aren't in convert mode): + if (!convert) { + return false; + } + none = true; + return true; + } + return str_caster.load(src, convert); + } + + static handle cast(const CharT *src, return_value_policy policy, handle parent) { + if (src == nullptr) { + return pybind11::none().release(); + } + return StringCaster::cast(StringType(src), policy, parent); + } + + static handle cast(CharT src, return_value_policy policy, handle parent) { + if (std::is_same::value) { + handle s = PyUnicode_DecodeLatin1((const char *) &src, 1, nullptr); + if (!s) { + throw error_already_set(); + } + return s; + } + return StringCaster::cast(StringType(1, src), policy, parent); + } + + explicit operator CharT *() { + return none ? nullptr : const_cast(static_cast(str_caster).c_str()); + } + explicit operator CharT &() { + if (none) { + throw value_error("Cannot convert None to a character"); + } + + auto &value = static_cast(str_caster); + size_t str_len = value.size(); + if (str_len == 0) { + throw value_error("Cannot convert empty string to a character"); + } + + // If we're in UTF-8 mode, we have two possible failures: one for a unicode character that + // is too high, and one for multiple unicode characters (caught later), so we need to + // figure out how long the first encoded character is in bytes to distinguish between these + // two errors. We also allow want to allow unicode characters U+0080 through U+00FF, as + // those can fit into a single char value. + if (StringCaster::UTF_N == 8 && str_len > 1 && str_len <= 4) { + auto v0 = static_cast(value[0]); + // low bits only: 0-127 + // 0b110xxxxx - start of 2-byte sequence + // 0b1110xxxx - start of 3-byte sequence + // 0b11110xxx - start of 4-byte sequence + size_t char0_bytes = (v0 & 0x80) == 0 ? 1 + : (v0 & 0xE0) == 0xC0 ? 2 + : (v0 & 0xF0) == 0xE0 ? 3 + : 4; + + if (char0_bytes == str_len) { + // If we have a 128-255 value, we can decode it into a single char: + if (char0_bytes == 2 && (v0 & 0xFC) == 0xC0) { // 0x110000xx 0x10xxxxxx + one_char = static_cast(((v0 & 3) << 6) + + (static_cast(value[1]) & 0x3F)); + return one_char; + } + // Otherwise we have a single character, but it's > U+00FF + throw value_error("Character code point not in range(0x100)"); + } + } + + // UTF-16 is much easier: we can only have a surrogate pair for values above U+FFFF, thus a + // surrogate pair with total length 2 instantly indicates a range error (but not a "your + // string was too long" error). + else if (StringCaster::UTF_N == 16 && str_len == 2) { + one_char = static_cast(value[0]); + if (one_char >= 0xD800 && one_char < 0xE000) { + throw value_error("Character code point not in range(0x10000)"); + } + } + + if (str_len != 1) { + throw value_error("Expected a character, but multi-character string found"); + } + + one_char = value[0]; + return one_char; + } + + static constexpr auto name = const_name(PYBIND11_STRING_NAME); + template + using cast_op_type = pybind11::detail::cast_op_type<_T>; +}; + +// Base implementation for std::tuple and std::pair +template