diff --git a/.bazelrc b/.bazelrc index c01cb39f1d..9cb0aa1b8d 100644 --- a/.bazelrc +++ b/.bazelrc @@ -8,3 +8,4 @@ build:vs2022 --cxxopt=/std:c++17 build:windows --config=vs2022 build:linux --config=gcc11 +build:macos --cxxopt=-std=c++2b diff --git a/.clang-tidy b/.clang-tidy new file mode 100644 index 0000000000..539010d95e --- /dev/null +++ b/.clang-tidy @@ -0,0 +1,81 @@ +--- +# Note: Alas, `Checks` is a string, not an array. +# Comments in the block string are not parsed and are passed in the value. +# They must thus be delimited by ',' from either side - then they are +# harmless. It's terrible, but it works. +Checks: >- + clang-diagnostic-*, + clang-analyzer-*, + -clang-analyzer-optin.core.EnumCastOutOfRange, + + bugprone-*, + -bugprone-unchecked-optional-access, + ,# This is ridiculous, as it triggers on constants, + -bugprone-implicit-widening-of-multiplication-result, + -bugprone-easily-swappable-parameters, + ,# Is not really useful, has false positives, triggers for no-noexcept move constructors ..., + -bugprone-exception-escape, + -bugprone-narrowing-conversions, + -bugprone-chained-comparison,# RIP decomposers, + + modernize-*, + -modernize-avoid-c-arrays, + -modernize-use-auto, + -modernize-use-emplace, + -modernize-use-nullptr,# it went crazy with three-way comparison operators, + -modernize-use-trailing-return-type, + -modernize-return-braced-init-list, + -modernize-concat-nested-namespaces, + -modernize-use-nodiscard, + -modernize-use-default-member-init, + -modernize-type-traits,# we need to support C++14, + -modernize-deprecated-headers, + ,# There's a lot of these and most of them are probably not useful, + -modernize-pass-by-value, + + performance-*, + -performance-enum-size, + + portability-*, + + readability-*, + -readability-braces-around-statements, + -readability-container-size-empty, + -readability-convert-member-functions-to-static, + -readability-else-after-return, + -readability-function-cognitive-complexity, + -readability-function-size, + -readability-identifier-length, + -readability-implicit-bool-conversion, + -readability-isolate-declaration, + -readability-magic-numbers, + -readability-named-parameter, + -readability-qualified-auto, + -readability-redundant-access-specifiers, + -readability-simplify-boolean-expr, + -readability-static-definition-in-anonymous-namespace, + -readability-uppercase-literal-suffix, + -readability-use-anyofallof, + -readability-avoid-return-with-void-value, + + ,# time hogs, + -bugprone-throw-keyword-missing, + -modernize-replace-auto-ptr, + -readability-identifier-naming, + + ,# We cannot use this until clang-tidy supports custom unique_ptr, + -bugprone-use-after-move, + ,# Doesn't recognize unevaluated context in CATCH_MOVE and CATCH_FORWARD, + -bugprone-macro-repeated-side-effects, +WarningsAsErrors: >- + clang-analyzer-core.*, + clang-analyzer-cplusplus.*, + clang-analyzer-security.*, + clang-analyzer-unix.*, + performance-move-const-arg, + performance-unnecessary-value-param, + readability-duplicate-include, +HeaderFilterRegex: '.*\.(c|cxx|cpp)$' +FormatStyle: none +CheckOptions: {} +... diff --git a/.conan/test_package/CMakeLists.txt b/.conan/test_package/CMakeLists.txt index 6ee069c01e..00a6af23df 100644 --- a/.conan/test_package/CMakeLists.txt +++ b/.conan/test_package/CMakeLists.txt @@ -1,12 +1,8 @@ -cmake_minimum_required(VERSION 3.2.0) -project(test_package CXX) +cmake_minimum_required(VERSION 3.15) +project(PackageTest CXX) -include("${CMAKE_BINARY_DIR}/conanbuildinfo.cmake") -conan_basic_setup() +find_package(Catch2 CONFIG REQUIRED) -find_package(Catch2 REQUIRED CONFIG) - -add_executable(${PROJECT_NAME} test_package.cpp) - -target_link_libraries(${PROJECT_NAME} Catch2::Catch2WithMain) -set_target_properties(${PROJECT_NAME} PROPERTIES CXX_STANDARD 14) +add_executable(test_package test_package.cpp) +target_link_libraries(test_package Catch2::Catch2WithMain) +target_compile_features(test_package PRIVATE cxx_std_14) diff --git a/.conan/test_package/conanfile.py b/.conan/test_package/conanfile.py index 069ace61ef..dc03876433 100644 --- a/.conan/test_package/conanfile.py +++ b/.conan/test_package/conanfile.py @@ -1,12 +1,28 @@ #!/usr/bin/env python # -*- coding: utf-8 -*- -from conans import ConanFile, CMake +from conan import ConanFile +from conan.tools.cmake import CMake, cmake_layout +from conan.tools.build import can_run +from conan.tools.files import save, load import os class TestPackageConan(ConanFile): settings = "os", "compiler", "build_type", "arch" - generators = "cmake_find_package_multi", "cmake" + generators = "CMakeToolchain", "CMakeDeps", "VirtualRunEnv" + test_type = "explicit" + + def requirements(self): + self.requires(self.tested_reference_str) + + def layout(self): + cmake_layout(self) + + def generate(self): + save(self, os.path.join(self.build_folder, "package_folder"), + self.dependencies[self.tested_reference_str].package_folder) + save(self, os.path.join(self.build_folder, "license"), + self.dependencies[self.tested_reference_str].license) def build(self): cmake = CMake(self) @@ -14,7 +30,11 @@ def build(self): cmake.build() def test(self): - assert os.path.isfile(os.path.join( - self.deps_cpp_info["catch2"].rootpath, "licenses", "LICENSE.txt")) - bin_path = os.path.join("bin", "test_package") - self.run("%s -s" % bin_path, run_environment=True) + if can_run(self): + cmd = os.path.join(self.cpp.build.bindir, "test_package") + self.run(cmd, env="conanrun") + + package_folder = load(self, os.path.join(self.build_folder, "package_folder")) + license = load(self, os.path.join(self.build_folder, "license")) + assert os.path.isfile(os.path.join(package_folder, "licenses", "LICENSE.txt")) + assert license == 'BSL-1.0' diff --git a/.github/workflows/linux-meson-builds.yml b/.github/workflows/linux-meson-builds.yml index 4ffa0243a7..4a6cfd5bbb 100644 --- a/.github/workflows/linux-meson-builds.yml +++ b/.github/workflows/linux-meson-builds.yml @@ -40,6 +40,5 @@ jobs: - name: Run tests working-directory: ${{runner.workspace}}/meson-build - # Hardcode 2 cores we know are there run: | meson test --verbose diff --git a/.github/workflows/linux-other-builds.yml b/.github/workflows/linux-other-builds.yml index 4a7f5ecc6c..6993c8159c 100644 --- a/.github/workflows/linux-other-builds.yml +++ b/.github/workflows/linux-other-builds.yml @@ -102,5 +102,53 @@ jobs: env: CTEST_OUTPUT_ON_FAILURE: 1 working-directory: ${{runner.workspace}}/build - # Hardcode 2 cores we know are there - run: ctest -C ${{matrix.build_type}} -j 2 ${{matrix.other_ctest_args}} + run: ctest -C ${{matrix.build_type}} -j `nproc` ${{matrix.other_ctest_args}} + clang-tidy: + name: clang-tidy ${{matrix.version}}, ${{matrix.build_description}}, C++${{matrix.std}} ${{matrix.build_type}} + runs-on: ubuntu-22.04 + strategy: + matrix: + include: + - version: "15" + build_description: all + build_type: Debug + std: 17 + other_pkgs: '' + cmake_configurations: -DCATCH_BUILD_EXAMPLES=ON -DCATCH_ENABLE_CMAKE_HELPER_TESTS=ON + steps: + - uses: actions/checkout@v4 + + - name: Prepare environment + run: | + sudo apt-get update + sudo apt-get install -y ninja-build clang-${{matrix.version}} clang-tidy-${{matrix.version}} ${{matrix.other_pkgs}} + + - name: Configure build + working-directory: ${{runner.workspace}} + env: + CXX: clang++-${{matrix.version}} + CXXFLAGS: ${{matrix.cxxflags}} + # Note: $GITHUB_WORKSPACE is distinct from ${{runner.workspace}}. + # This is important + run: | + clangtidy="clang-tidy-${{matrix.version}};-use-color" + # Use a dummy compiler/linker/ar/ranlib to effectively disable the + # compilation and only run clang-tidy. + cmake -Bbuild -H$GITHUB_WORKSPACE \ + -DCMAKE_BUILD_TYPE=${{matrix.build_type}} \ + -DCMAKE_CXX_STANDARD=${{matrix.std}} \ + -DCMAKE_CXX_STANDARD_REQUIRED=ON \ + -DCMAKE_CXX_EXTENSIONS=OFF \ + -DCATCH_DEVELOPMENT_BUILD=ON \ + -DCMAKE_CXX_CLANG_TIDY="$clangtidy" \ + -DCMAKE_CXX_COMPILER_LAUNCHER=/usr/bin/true \ + -DCMAKE_AR=/usr/bin/true \ + -DCMAKE_CXX_COMPILER_AR=/usr/bin/true \ + -DCMAKE_RANLIB=/usr/bin/true \ + -DCMAKE_CXX_LINK_EXECUTABLE=/usr/bin/true \ + ${{matrix.cmake_configurations}} \ + -G Ninja + + - name: Run clang-tidy + working-directory: ${{runner.workspace}}/build + run: ninja diff --git a/.github/workflows/linux-simple-builds.yml b/.github/workflows/linux-simple-builds.yml index a32eb597ea..4cca31619e 100644 --- a/.github/workflows/linux-simple-builds.yml +++ b/.github/workflows/linux-simple-builds.yml @@ -120,5 +120,4 @@ jobs: env: CTEST_OUTPUT_ON_FAILURE: 1 working-directory: ${{runner.workspace}}/build - # Hardcode 2 cores we know are there - run: ctest -C ${{matrix.build_type}} -j 2 + run: ctest -C ${{matrix.build_type}} -j `nproc` diff --git a/.github/workflows/mac-builds-m1.yml b/.github/workflows/mac-builds-m1.yml new file mode 100644 index 0000000000..4820466d40 --- /dev/null +++ b/.github/workflows/mac-builds-m1.yml @@ -0,0 +1,44 @@ +name: M1 Mac builds + +on: [push, pull_request] + +jobs: + build: + runs-on: macos-14 + strategy: + matrix: + cxx: + - clang++ + build_type: [Debug, Release] + std: [14, 17] + include: + - build_type: Debug + examples: ON + extra_tests: ON + + steps: + - uses: actions/checkout@v4 + + - name: Configure build + working-directory: ${{runner.workspace}} + env: + CXX: ${{matrix.cxx}} + CXXFLAGS: ${{matrix.cxxflags}} + run: | + cmake -Bbuild -H$GITHUB_WORKSPACE \ + -DCMAKE_BUILD_TYPE=${{matrix.build_type}} \ + -DCMAKE_CXX_STANDARD=${{matrix.std}} \ + -DCMAKE_CXX_STANDARD_REQUIRED=ON \ + -DCATCH_DEVELOPMENT_BUILD=ON \ + -DCATCH_BUILD_EXAMPLES=${{matrix.examples}} \ + -DCATCH_BUILD_EXTRA_TESTS=${{matrix.examples}} + + - name: Build tests + lib + working-directory: ${{runner.workspace}}/build + run: make -j `sysctl -n hw.ncpu` + + - name: Run tests + env: + CTEST_OUTPUT_ON_FAILURE: 1 + working-directory: ${{runner.workspace}}/build + run: ctest -C ${{matrix.build_type}} -j `sysctl -n hw.ncpu` diff --git a/.github/workflows/mac-builds.yml b/.github/workflows/mac-builds.yml index 259d8b367b..fe11e819f8 100644 --- a/.github/workflows/mac-builds.yml +++ b/.github/workflows/mac-builds.yml @@ -4,15 +4,10 @@ on: [push, pull_request] jobs: build: - # macos-12 updated to a toolchain that crashes when linking the - # test binary. This seems to be a known bug in that version, - # and will eventually get fixed in an update. After that, we can go - # back to newer macos images. - runs-on: macos-11 + runs-on: macos-12 strategy: matrix: cxx: - - g++-11 - clang++ build_type: [Debug, Release] std: [14, 17] @@ -29,8 +24,6 @@ jobs: env: CXX: ${{matrix.cxx}} CXXFLAGS: ${{matrix.cxxflags}} - # Note: $GITHUB_WORKSPACE is distinct from ${{runner.workspace}}. - # This is important run: | cmake -Bbuild -H$GITHUB_WORKSPACE \ -DCMAKE_BUILD_TYPE=${{matrix.build_type}} \ diff --git a/.github/workflows/package-manager-builds.yaml b/.github/workflows/package-manager-builds.yaml new file mode 100644 index 0000000000..6d90d14054 --- /dev/null +++ b/.github/workflows/package-manager-builds.yaml @@ -0,0 +1,31 @@ +name: Package Manager Builds + +on: [push, pull_request] + +jobs: + conan_builds: + name: Conan ${{matrix.conan_version}} + runs-on: ubuntu-20.04 + strategy: + matrix: + conan_version: + - '1.63' + - '2.1' + + include: + # Conan 1 has default profiles installed + - conan_version: '1.63' + profile_generate: 'false' + + steps: + - uses: actions/checkout@v4 + + - name: Install conan + run: pip install conan==${{matrix.conan_version}} + + - name: Setup conan profiles + if: matrix.profile_generate != 'false' + run: conan profile detect + + - name: Run conan package create + run: conan create . -tf .conan/test_package diff --git a/.gitignore b/.gitignore index 27f6bc0b30..dbf9f40a9b 100644 --- a/.gitignore +++ b/.gitignore @@ -25,7 +25,9 @@ Build cmake-build-* benchmark-dir .conan/test_package/build +**/CMakeUserPresets.json bazel-* +MODULE.bazel.lock build-fuzzers debug-build .vscode @@ -35,3 +37,4 @@ msvc-sln* docs/doxygen *.cache compile_commands.json +**/*.unapproved.txt diff --git a/CMake/CatchMiscFunctions.cmake b/CMake/CatchMiscFunctions.cmake index de6b7ae3fd..05bc83c021 100644 --- a/CMake/CatchMiscFunctions.cmake +++ b/CMake/CatchMiscFunctions.cmake @@ -68,6 +68,7 @@ function(add_warnings_to_targets targets) "-Wmissing-noreturn" "-Wmissing-prototypes" "-Wmissing-variable-declarations" + "-Wnon-virtual-dtor" "-Wnull-dereference" "-Wold-style-cast" "-Woverloaded-virtual" @@ -78,6 +79,7 @@ function(add_warnings_to_targets targets) "-Wreturn-std-move" "-Wshadow" "-Wstrict-aliasing" + "-Wsubobject-linkage" "-Wsuggest-destructor-override" "-Wsuggest-override" "-Wundef" diff --git a/CMakeLists.txt b/CMakeLists.txt index 2cfb6cd143..7bad26c3ac 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -11,6 +11,7 @@ endif() option(CATCH_INSTALL_DOCS "Install documentation alongside library" ON) option(CATCH_INSTALL_EXTRAS "Install extras (CMake scripts, debugger helpers) alongside library" ON) option(CATCH_DEVELOPMENT_BUILD "Build tests, enable warnings, enable Werror, etc" OFF) +option(CATCH_ENABLE_REPRODUCIBLE_BUILD "Add compiler flags for improving build reproducibility" ON) include(CMakeDependentOption) cmake_dependent_option(CATCH_BUILD_TESTING "Build the SelfTest project" ON "CATCH_DEVELOPMENT_BUILD" OFF) @@ -32,7 +33,7 @@ if (CMAKE_BINARY_DIR STREQUAL CMAKE_CURRENT_SOURCE_DIR) endif() project(Catch2 - VERSION 3.5.0 # CML version placeholder, don't delete + VERSION 3.7.1 # CML version placeholder, don't delete LANGUAGES CXX # HOMEPAGE_URL is not supported until CMake version 3.12, which # we do not target yet. @@ -75,8 +76,6 @@ endif() set(CATCH_DIR ${CMAKE_CURRENT_SOURCE_DIR}) set(SOURCES_DIR ${CATCH_DIR}/src/catch2) set(SELF_TEST_DIR ${CATCH_DIR}/tests/SelfTest) -set(BENCHMARK_DIR ${CATCH_DIR}/tests/Benchmark) -set(EXAMPLES_DIR ${CATCH_DIR}/examples) # We need to bring-in the variables defined there to this scope add_subdirectory(src) @@ -199,4 +198,4 @@ if (NOT_SUBPROJECT) include( CPack ) -endif(NOT_SUBPROJECT) +endif() diff --git a/Doxyfile b/Doxyfile index 07b385ec10..914e598481 100644 --- a/Doxyfile +++ b/Doxyfile @@ -1,4 +1,4 @@ -# Doxyfile 1.8.16 +# Doxyfile 1.9.1 # This file describes the settings to be used by the documentation system # doxygen (www.doxygen.org) for a project. @@ -32,7 +32,7 @@ DOXYFILE_ENCODING = UTF-8 # title of most generated pages and in a few other places. # The default value is: My Project. -PROJECT_NAME = "Catch2" +PROJECT_NAME = Catch2 # The PROJECT_NUMBER tag can be used to enter a project or revision number. This # could be handy for archiving the generated documentation or if some version @@ -51,6 +51,7 @@ PROJECT_BRIEF = "Popular C++ unit testing framework" # pixels and the maximum width should not exceed 200 pixels. Doxygen will copy # the logo to the output directory. +PROJECT_LOGO = # The OUTPUT_DIRECTORY tag is used to specify the (relative or absolute) path # into which the generated documentation will be written. If a relative path is @@ -216,6 +217,14 @@ QT_AUTOBRIEF = YES MULTILINE_CPP_IS_BRIEF = NO +# By default Python docstrings are displayed as preformatted text and doxygen's +# special commands cannot be used. By setting PYTHON_DOCSTRING to NO the +# doxygen's special commands can be used and the contents of the docstring +# documentation blocks is shown as doxygen documentation. +# The default value is: YES. + +PYTHON_DOCSTRING = YES + # If the INHERIT_DOCS tag is set to YES then an undocumented member inherits the # documentation from any documented member that it re-implements. # The default value is: YES. @@ -251,13 +260,7 @@ TAB_SIZE = 4 # a double escape (\\{ and \\}) ALIASES = "complexity=@par Complexity:" \ - "noexcept=**Noexcept**" - -# This tag can be used to specify a number of word-keyword mappings (TCL only). -# A mapping has the form "name=value". For example adding "class=itcl::class" -# will allow you to use the command class in the itcl::class meaning. - -TCL_SUBST = + noexcept=**Noexcept** # Set the OPTIMIZE_OUTPUT_FOR_C tag to YES if your project consists of C sources # only. Doxygen will then generate output that is more tailored for C. For @@ -299,19 +302,22 @@ OPTIMIZE_OUTPUT_SLICE = NO # parses. With this tag you can assign which parser to use for a given # extension. Doxygen has a built-in mapping, but you can override or extend it # using this tag. The format is ext=language, where ext is a file extension, and -# language is one of the parsers supported by doxygen: IDL, Java, Javascript, -# Csharp (C#), C, C++, D, PHP, md (Markdown), Objective-C, Python, Slice, +# language is one of the parsers supported by doxygen: IDL, Java, JavaScript, +# Csharp (C#), C, C++, D, PHP, md (Markdown), Objective-C, Python, Slice, VHDL, # Fortran (fixed format Fortran: FortranFixed, free formatted Fortran: # FortranFree, unknown formatted Fortran: Fortran. In the later case the parser # tries to guess whether the code is fixed or free formatted code, this is the -# default for Fortran type files), VHDL, tcl. For instance to make doxygen treat -# .inc files as Fortran files (default is PHP), and .f files as C (default is -# Fortran), use: inc=Fortran f=C. +# default for Fortran type files). For instance to make doxygen treat .inc files +# as Fortran files (default is PHP), and .f files as C (default is Fortran), +# use: inc=Fortran f=C. # # Note: For files without extension you can use no_extension as a placeholder. # # Note that for custom extensions you also need to set FILE_PATTERNS otherwise -# the files are not read by doxygen. +# the files are not read by doxygen. When specifying no_extension you should add +# * to the FILE_PATTERNS. +# +# Note see also the list of default file extension mappings. EXTENSION_MAPPING = @@ -445,6 +451,19 @@ TYPEDEF_HIDES_STRUCT = NO LOOKUP_CACHE_SIZE = 0 +# The NUM_PROC_THREADS specifies the number threads doxygen is allowed to use +# during processing. When set to 0 doxygen will based this on the number of +# cores available in the system. You can set it explicitly to a value larger +# than 0 to get more control over the balance between CPU load and processing +# speed. At this moment only the input processing can be done using multiple +# threads. Since this is still an experimental feature the default is set to 1, +# which efficively disables parallel processing. Please report any issues you +# encounter. Generating dot graphs in parallel is controlled by the +# DOT_NUM_THREADS setting. +# Minimum value: 0, maximum value: 32, default value: 1. + +NUM_PROC_THREADS = 1 + #--------------------------------------------------------------------------- # Build related configuration options #--------------------------------------------------------------------------- @@ -508,6 +527,13 @@ EXTRACT_LOCAL_METHODS = NO EXTRACT_ANON_NSPACES = NO +# If this flag is set to YES, the name of an unnamed parameter in a declaration +# will be determined by the corresponding definition. By default unnamed +# parameters remain unnamed in the output. +# The default value is: YES. + +RESOLVE_UNNAMED_PARAMS = YES + # If the HIDE_UNDOC_MEMBERS tag is set to YES, doxygen will hide all # undocumented members inside documented classes or files. If set to NO these # members will be included in the various overviews, but no documentation @@ -525,8 +551,8 @@ HIDE_UNDOC_MEMBERS = NO HIDE_UNDOC_CLASSES = NO # If the HIDE_FRIEND_COMPOUNDS tag is set to YES, doxygen will hide all friend -# (class|struct|union) declarations. If set to NO, these declarations will be -# included in the documentation. +# declarations. If set to NO, these declarations will be included in the +# documentation. # The default value is: NO. HIDE_FRIEND_COMPOUNDS = NO @@ -545,11 +571,18 @@ HIDE_IN_BODY_DOCS = NO INTERNAL_DOCS = NO -# If the CASE_SENSE_NAMES tag is set to NO then doxygen will only generate file -# names in lower-case letters. If set to YES, upper-case letters are also -# allowed. This is useful if you have classes or files whose names only differ -# in case and if your file system supports case sensitive file names. Windows -# (including Cygwin) ands Mac users are advised to set this option to NO. +# With the correct setting of option CASE_SENSE_NAMES doxygen will better be +# able to match the capabilities of the underlying filesystem. In case the +# filesystem is case sensitive (i.e. it supports files in the same directory +# whose names only differ in casing), the option must be set to YES to properly +# deal with such files in case they appear in the input. For filesystems that +# are not case sensitive the option should be be set to NO to properly deal with +# output files written for symbols that only differ in casing, such as for two +# classes, one named CLASS and the other named Class, and to also support +# references to files without having to specify the exact matching casing. On +# Windows (including Cygwin) and MacOS, users should typically set this option +# to NO, whereas on Linux or other Unix flavors it should typically be set to +# YES. # The default value is: system dependent. CASE_SENSE_NAMES = NO @@ -788,7 +821,10 @@ WARN_IF_DOC_ERROR = YES WARN_NO_PARAMDOC = YES # If the WARN_AS_ERROR tag is set to YES then doxygen will immediately stop when -# a warning is encountered. +# a warning is encountered. If the WARN_AS_ERROR tag is set to FAIL_ON_WARNINGS +# then doxygen will continue running as if WARN_AS_ERROR tag is set to NO, but +# at the end of the doxygen process doxygen will return with a non-zero status. +# Possible values are: NO, YES and FAIL_ON_WARNINGS. # The default value is: NO. WARN_AS_ERROR = NO @@ -819,13 +855,13 @@ WARN_LOGFILE = doxygen.errors # spaces. See also FILE_PATTERNS and EXTENSION_MAPPING # Note: If this tag is empty the current directory is searched. -INPUT = "src/catch2" +INPUT = src/catch2 # This tag can be used to specify the character encoding of the source files # that doxygen parses. Internally doxygen uses the UTF-8 encoding. Doxygen uses # libiconv (or the iconv built into libc) for the transcoding. See the libiconv -# documentation (see: https://www.gnu.org/software/libiconv/) for the list of -# possible encodings. +# documentation (see: +# https://www.gnu.org/software/libiconv/) for the list of possible encodings. # The default value is: UTF-8. INPUT_ENCODING = UTF-8 @@ -838,13 +874,61 @@ INPUT_ENCODING = UTF-8 # need to set EXTENSION_MAPPING for the extension otherwise the files are not # read by doxygen. # +# Note the list of default checked file patterns might differ from the list of +# default file extension mappings. +# # If left blank the following patterns are tested:*.c, *.cc, *.cxx, *.cpp, # *.c++, *.java, *.ii, *.ixx, *.ipp, *.i++, *.inl, *.idl, *.ddl, *.odl, *.h, # *.hh, *.hxx, *.hpp, *.h++, *.cs, *.d, *.php, *.php4, *.php5, *.phtml, *.inc, -# *.m, *.markdown, *.md, *.mm, *.dox, *.py, *.pyw, *.f90, *.f95, *.f03, *.f08, -# *.f, *.for, *.tcl, *.vhd, *.vhdl, *.ucf, *.qsf and *.ice. - -# FILE_PATTERNS = +# *.m, *.markdown, *.md, *.mm, *.dox (to be provided as doxygen C comment), +# *.py, *.pyw, *.f90, *.f95, *.f03, *.f08, *.f18, *.f, *.for, *.vhd, *.vhdl, +# *.ucf, *.qsf and *.ice. + +FILE_PATTERNS = *.c \ + *.cc \ + *.cxx \ + *.cpp \ + *.c++ \ + *.java \ + *.ii \ + *.ixx \ + *.ipp \ + *.i++ \ + *.inl \ + *.idl \ + *.ddl \ + *.odl \ + *.h \ + *.hh \ + *.hxx \ + *.hpp \ + *.h++ \ + *.cs \ + *.d \ + *.php \ + *.php4 \ + *.php5 \ + *.phtml \ + *.inc \ + *.m \ + *.markdown \ + *.md \ + *.mm \ + *.dox \ + *.py \ + *.pyw \ + *.f90 \ + *.f95 \ + *.f03 \ + *.f08 \ + *.f18 \ + *.f \ + *.for \ + *.vhd \ + *.vhdl \ + *.ucf \ + *.qsf \ + *.ice # The RECURSIVE tag can be used to specify whether or not subdirectories should # be searched for input files as well. @@ -968,6 +1052,7 @@ FILTER_SOURCE_PATTERNS = # (index.html). This can be useful if you have a project on for instance GitHub # and want to reuse the introduction page also for the doxygen output. +USE_MDFILE_AS_MAINPAGE = #--------------------------------------------------------------------------- # Configuration options related to source browsing @@ -1055,6 +1140,44 @@ USE_HTAGS = NO VERBATIM_HEADERS = YES +# If the CLANG_ASSISTED_PARSING tag is set to YES then doxygen will use the +# clang parser (see: +# http://clang.llvm.org/) for more accurate parsing at the cost of reduced +# performance. This can be particularly helpful with template rich C++ code for +# which doxygen's built-in parser lacks the necessary type information. +# Note: The availability of this option depends on whether or not doxygen was +# generated with the -Duse_libclang=ON option for CMake. +# The default value is: NO. + +CLANG_ASSISTED_PARSING = NO + +# If clang assisted parsing is enabled and the CLANG_ADD_INC_PATHS tag is set to +# YES then doxygen will add the directory of each input to the include path. +# The default value is: YES. + +CLANG_ADD_INC_PATHS = YES + +# If clang assisted parsing is enabled you can provide the compiler with command +# line options that you would normally use when invoking the compiler. Note that +# the include paths will already be set by doxygen for the files and directories +# specified with INPUT and INCLUDE_PATH. +# This tag requires that the tag CLANG_ASSISTED_PARSING is set to YES. + +CLANG_OPTIONS = + +# If clang assisted parsing is enabled you can provide the clang parser with the +# path to the directory containing a file called compile_commands.json. This +# file is the compilation database (see: +# http://clang.llvm.org/docs/HowToSetupToolingForLLVM.html) containing the +# options used when the source files were built. This is equivalent to +# specifying the -p option to a clang tool, such as clang-check. These options +# will then be passed to the parser. Any options specified with CLANG_OPTIONS +# will be added as well. +# Note: The availability of this option depends on whether or not doxygen was +# generated with the -Duse_libclang=ON option for CMake. + +CLANG_DATABASE_PATH = + #--------------------------------------------------------------------------- # Configuration options related to the alphabetical class index #--------------------------------------------------------------------------- @@ -1066,13 +1189,6 @@ VERBATIM_HEADERS = YES ALPHABETICAL_INDEX = YES -# The COLS_IN_ALPHA_INDEX tag can be used to specify the number of columns in -# which the alphabetical index list will be split. -# Minimum value: 1, maximum value: 20, default value: 5. -# This tag requires that the tag ALPHABETICAL_INDEX is set to YES. - -COLS_IN_ALPHA_INDEX = 5 - # In case all classes in a project start with a common prefix, all classes will # be put under the same header in the alphabetical index. The IGNORE_PREFIX tag # can be used to specify a prefix (or a list of prefixes) that should be ignored @@ -1211,9 +1327,9 @@ HTML_TIMESTAMP = NO # If the HTML_DYNAMIC_MENUS tag is set to YES then the generated HTML # documentation will contain a main index with vertical navigation menus that -# are dynamically created via Javascript. If disabled, the navigation index will +# are dynamically created via JavaScript. If disabled, the navigation index will # consists of multiple levels of tabs that are statically embedded in every HTML -# page. Disable this option to support browsers that do not have Javascript, +# page. Disable this option to support browsers that do not have JavaScript, # like the Qt help browser. # The default value is: YES. # This tag requires that the tag GENERATE_HTML is set to YES. @@ -1243,10 +1359,11 @@ HTML_INDEX_NUM_ENTRIES = 100 # If the GENERATE_DOCSET tag is set to YES, additional index files will be # generated that can be used as input for Apple's Xcode 3 integrated development -# environment (see: https://developer.apple.com/xcode/), introduced with OSX -# 10.5 (Leopard). To create a documentation set, doxygen will generate a -# Makefile in the HTML output directory. Running make will produce the docset in -# that directory and running make install will install the docset in +# environment (see: +# https://developer.apple.com/xcode/), introduced with OSX 10.5 (Leopard). To +# create a documentation set, doxygen will generate a Makefile in the HTML +# output directory. Running make will produce the docset in that directory and +# running make install will install the docset in # ~/Library/Developer/Shared/Documentation/DocSets so that Xcode will find it at # startup. See https://developer.apple.com/library/archive/featuredarticles/Doxy # genXcode/_index.html for more information. @@ -1288,8 +1405,8 @@ DOCSET_PUBLISHER_NAME = Publisher # If the GENERATE_HTMLHELP tag is set to YES then doxygen generates three # additional HTML index files: index.hhp, index.hhc, and index.hhk. The # index.hhp is a project file that can be read by Microsoft's HTML Help Workshop -# (see: https://www.microsoft.com/en-us/download/details.aspx?id=21138) on -# Windows. +# (see: +# https://www.microsoft.com/en-us/download/details.aspx?id=21138) on Windows. # # The HTML Help Workshop contains a compiler that can convert all HTML output # generated by doxygen into a single compiled HTML file (.chm). Compiled HTML @@ -1364,7 +1481,8 @@ QCH_FILE = # The QHP_NAMESPACE tag specifies the namespace to use when generating Qt Help # Project output. For more information please see Qt Help Project / Namespace -# (see: https://doc.qt.io/archives/qt-4.8/qthelpproject.html#namespace). +# (see: +# https://doc.qt.io/archives/qt-4.8/qthelpproject.html#namespace). # The default value is: org.doxygen.Project. # This tag requires that the tag GENERATE_QHP is set to YES. @@ -1372,8 +1490,8 @@ QHP_NAMESPACE = org.doxygen.Project # The QHP_VIRTUAL_FOLDER tag specifies the namespace to use when generating Qt # Help Project output. For more information please see Qt Help Project / Virtual -# Folders (see: https://doc.qt.io/archives/qt-4.8/qthelpproject.html#virtual- -# folders). +# Folders (see: +# https://doc.qt.io/archives/qt-4.8/qthelpproject.html#virtual-folders). # The default value is: doc. # This tag requires that the tag GENERATE_QHP is set to YES. @@ -1381,16 +1499,16 @@ QHP_VIRTUAL_FOLDER = doc # If the QHP_CUST_FILTER_NAME tag is set, it specifies the name of a custom # filter to add. For more information please see Qt Help Project / Custom -# Filters (see: https://doc.qt.io/archives/qt-4.8/qthelpproject.html#custom- -# filters). +# Filters (see: +# https://doc.qt.io/archives/qt-4.8/qthelpproject.html#custom-filters). # This tag requires that the tag GENERATE_QHP is set to YES. QHP_CUST_FILTER_NAME = # The QHP_CUST_FILTER_ATTRS tag specifies the list of the attributes of the # custom filter to add. For more information please see Qt Help Project / Custom -# Filters (see: https://doc.qt.io/archives/qt-4.8/qthelpproject.html#custom- -# filters). +# Filters (see: +# https://doc.qt.io/archives/qt-4.8/qthelpproject.html#custom-filters). # This tag requires that the tag GENERATE_QHP is set to YES. QHP_CUST_FILTER_ATTRS = @@ -1402,9 +1520,9 @@ QHP_CUST_FILTER_ATTRS = QHP_SECT_FILTER_ATTRS = -# The QHG_LOCATION tag can be used to specify the location of Qt's -# qhelpgenerator. If non-empty doxygen will try to run qhelpgenerator on the -# generated .qhp file. +# The QHG_LOCATION tag can be used to specify the location (absolute path +# including file name) of Qt's qhelpgenerator. If non-empty doxygen will try to +# run qhelpgenerator on the generated .qhp file. # This tag requires that the tag GENERATE_QHP is set to YES. QHG_LOCATION = @@ -1481,6 +1599,17 @@ TREEVIEW_WIDTH = 250 EXT_LINKS_IN_WINDOW = NO +# If the HTML_FORMULA_FORMAT option is set to svg, doxygen will use the pdf2svg +# tool (see https://github.com/dawbarton/pdf2svg) or inkscape (see +# https://inkscape.org) to generate formulas as SVG images instead of PNGs for +# the HTML output. These images will generally look nicer at scaled resolutions. +# Possible values are: png (the default) and svg (looks nicer but requires the +# pdf2svg or inkscape tool). +# The default value is: png. +# This tag requires that the tag GENERATE_HTML is set to YES. + +HTML_FORMULA_FORMAT = png + # Use this tag to change the font size of LaTeX formulas included as images in # the HTML documentation. When you change the font size after a successful # doxygen run you need to manually remove any form_*.png images from the HTML @@ -1501,8 +1630,14 @@ FORMULA_FONTSIZE = 10 FORMULA_TRANSPARENT = YES +# The FORMULA_MACROFILE can contain LaTeX \newcommand and \renewcommand commands +# to create new LaTeX commands to be used in formulas as building blocks. See +# the section "Including formulas" for details. + +FORMULA_MACROFILE = + # Enable the USE_MATHJAX option to render LaTeX formulas using MathJax (see -# https://www.mathjax.org) which uses client side Javascript for the rendering +# https://www.mathjax.org) which uses client side JavaScript for the rendering # instead of using pre-rendered bitmaps. Use this if you do not have LaTeX # installed or if you want to formulas look prettier in the HTML output. When # enabled you may also need to install MathJax separately and configure the path @@ -1514,7 +1649,7 @@ USE_MATHJAX = YES # When MathJax is enabled you can set the default output format to be used for # the MathJax output. See the MathJax site (see: -# http://docs.mathjax.org/en/latest/output.html) for more details. +# http://docs.mathjax.org/en/v2.7-latest/output.html) for more details. # Possible values are: HTML-CSS (which is slower, but has the best # compatibility), NativeMML (i.e. MathML) and SVG. # The default value is: HTML-CSS. @@ -1530,7 +1665,7 @@ MATHJAX_FORMAT = HTML-CSS # Content Delivery Network so you can quickly see the result without installing # MathJax. However, it is strongly recommended to install a local copy of # MathJax from https://www.mathjax.org before deployment. -# The default value is: https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.5/. +# The default value is: https://cdn.jsdelivr.net/npm/mathjax@2. # This tag requires that the tag USE_MATHJAX is set to YES. MATHJAX_RELPATH = http://cdn.mathjax.org/mathjax/latest @@ -1545,7 +1680,8 @@ MATHJAX_EXTENSIONS = TeX/AMSmath \ # The MATHJAX_CODEFILE tag can be used to specify a file with javascript pieces # of code that will be used on startup of the MathJax code. See the MathJax site -# (see: http://docs.mathjax.org/en/latest/output.html) for more details. For an +# (see: +# http://docs.mathjax.org/en/v2.7-latest/output.html) for more details. For an # example see the documentation. # This tag requires that the tag USE_MATHJAX is set to YES. @@ -1573,7 +1709,7 @@ MATHJAX_CODEFILE = SEARCHENGINE = YES # When the SERVER_BASED_SEARCH tag is enabled the search engine will be -# implemented using a web server instead of a web client using Javascript. There +# implemented using a web server instead of a web client using JavaScript. There # are two flavors of web server based searching depending on the EXTERNAL_SEARCH # setting. When disabled, doxygen will generate a PHP script for searching and # an index file used by the script. When EXTERNAL_SEARCH is enabled the indexing @@ -1592,7 +1728,8 @@ SERVER_BASED_SEARCH = NO # # Doxygen ships with an example indexer (doxyindexer) and search engine # (doxysearch.cgi) which are based on the open source search engine library -# Xapian (see: https://xapian.org/). +# Xapian (see: +# https://xapian.org/). # # See the section "External Indexing and Searching" for details. # The default value is: NO. @@ -1605,8 +1742,9 @@ EXTERNAL_SEARCH = NO # # Doxygen ships with an example indexer (doxyindexer) and search engine # (doxysearch.cgi) which are based on the open source search engine library -# Xapian (see: https://xapian.org/). See the section "External Indexing and -# Searching" for details. +# Xapian (see: +# https://xapian.org/). See the section "External Indexing and Searching" for +# details. # This tag requires that the tag SEARCHENGINE is set to YES. SEARCHENGINE_URL = @@ -1770,9 +1908,11 @@ LATEX_EXTRA_FILES = PDF_HYPERLINKS = YES -# If the USE_PDFLATEX tag is set to YES, doxygen will use pdflatex to generate -# the PDF file directly from the LaTeX files. Set this option to YES, to get a -# higher quality PDF documentation. +# If the USE_PDFLATEX tag is set to YES, doxygen will use the engine as +# specified with LATEX_CMD_NAME to generate the PDF file directly from the LaTeX +# files. Set this option to YES, to get a higher quality PDF documentation. +# +# See also section LATEX_CMD_NAME for selecting the engine. # The default value is: YES. # This tag requires that the tag GENERATE_LATEX is set to YES. @@ -2204,7 +2344,7 @@ HIDE_UNDOC_RELATIONS = YES # http://www.graphviz.org/), a graph visualization toolkit from AT&T and Lucent # Bell Labs. The other options in this section have no effect if this option is # set to NO -# The default value is: NO. +# The default value is: YES. HAVE_DOT = YES @@ -2283,10 +2423,32 @@ UML_LOOK = NO # but if the number exceeds 15, the total amount of fields shown is limited to # 10. # Minimum value: 0, maximum value: 100, default value: 10. -# This tag requires that the tag HAVE_DOT is set to YES. +# This tag requires that the tag UML_LOOK is set to YES. UML_LIMIT_NUM_FIELDS = 10 +# If the DOT_UML_DETAILS tag is set to NO, doxygen will show attributes and +# methods without types and arguments in the UML graphs. If the DOT_UML_DETAILS +# tag is set to YES, doxygen will add type and arguments for attributes and +# methods in the UML graphs. If the DOT_UML_DETAILS tag is set to NONE, doxygen +# will not generate fields with class member information in the UML graphs. The +# class diagrams will look similar to the default class diagrams but using UML +# notation for the relationships. +# Possible values are: NO, YES and NONE. +# The default value is: NO. +# This tag requires that the tag UML_LOOK is set to YES. + +DOT_UML_DETAILS = NO + +# The DOT_WRAP_THRESHOLD tag can be used to set the maximum number of characters +# to display on a single line. If the actual line length exceeds this threshold +# significantly it will wrapped across multiple lines. Some heuristics are apply +# to avoid ugly line breaks. +# Minimum value: 0, maximum value: 1000, default value: 17. +# This tag requires that the tag HAVE_DOT is set to YES. + +DOT_WRAP_THRESHOLD = 17 + # If the TEMPLATE_RELATIONS tag is set to YES then the inheritance and # collaboration graphs will show the relations between templates and their # instances. @@ -2360,7 +2522,9 @@ DIRECTORY_GRAPH = NO # Note: If you choose svg you need to set HTML_FILE_EXTENSION to xhtml in order # to make the SVG files visible in IE 9+ (other browsers do not have this # requirement). -# Possible values are: png, jpg, gif, svg, png:gd, png:gd:gd, png:cairo, +# Possible values are: png, png:cairo, png:cairo:cairo, png:cairo:gd, png:gd, +# png:gd:gd, jpg, jpg:cairo, jpg:cairo:gd, jpg:gd, jpg:gd:gd, gif, gif:cairo, +# gif:cairo:gd, gif:gd, gif:gd:gd, svg, png:gd, png:gd:gd, png:cairo, # png:cairo:gd, png:cairo:cairo, png:cairo:gdiplus, png:gdiplus and # png:gdiplus:gdiplus. # The default value is: png. @@ -2476,9 +2640,11 @@ DOT_MULTI_TARGETS = YES GENERATE_LEGEND = YES -# If the DOT_CLEANUP tag is set to YES, doxygen will remove the intermediate dot +# If the DOT_CLEANUP tag is set to YES, doxygen will remove the intermediate # files that are used to generate the various graphs. +# +# Note: This setting is not only used for dot files but also for msc and +# plantuml temporary files. # The default value is: YES. -# This tag requires that the tag HAVE_DOT is set to YES. DOT_CLEANUP = YES diff --git a/MODULE.bazel b/MODULE.bazel new file mode 100644 index 0000000000..4d7ec860e0 --- /dev/null +++ b/MODULE.bazel @@ -0,0 +1,3 @@ +module(name = "catch2") + +bazel_dep(name = "bazel_skylib", version = "1.7.1") diff --git a/WORKSPACE.bazel b/WORKSPACE.bazel index a5c6182d7f..e48080a4bf 100644 --- a/WORKSPACE.bazel +++ b/WORKSPACE.bazel @@ -4,10 +4,10 @@ load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive") http_archive( name = "bazel_skylib", - sha256 = "66ffd9315665bfaafc96b52278f57c7e2dd09f5ede279ea6d39b2be471e7e3aa", + sha256 = "bc283cdfcd526a52c3201279cda4bc298652efa898b10b4db0837dc51652756f", urls = [ - "https://mirror.bazel.build/github.com/bazelbuild/bazel-skylib/releases/download/1.4.2/bazel-skylib-1.4.2.tar.gz", - "https://github.com/bazelbuild/bazel-skylib/releases/download/1.4.2/bazel-skylib-1.4.2.tar.gz", + "https://mirror.bazel.build/github.com/bazelbuild/bazel-skylib/releases/download/1.7.1/bazel-skylib-1.7.1.tar.gz", + "https://github.com/bazelbuild/bazel-skylib/releases/download/1.7.1/bazel-skylib-1.7.1.tar.gz", ], ) diff --git a/appveyor.yml b/appveyor.yml index 7a0ad83ffd..ba4556ea6c 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -5,10 +5,10 @@ version: "{build}-{branch}" clone_depth: 20 # We want to build everything, except for branches that are explicitly -# for messing around with travis. +# for messing around with Github Actions. branches: except: - - /dev-travis.+/ + - /devel-gha.+/ # We need a more up to date pip because Python 2.7 is EOL soon @@ -70,3 +70,14 @@ environment: additional_flags: "/permissive- /std:c++latest" platform: x64 configuration: Debug + + - FLAVOR: VS 2017 x64 Debug + APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2017 + platform: x64 + configuration: Debug + + - FLAVOR: VS 2017 x64 Release Coverage + APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2017 + coverage: 1 + platform: x64 + configuration: Debug diff --git a/conanfile.py b/conanfile.py old mode 100644 new mode 100755 index 7aa27ef599..7a3ac7c37a --- a/conanfile.py +++ b/conanfile.py @@ -1,5 +1,14 @@ #!/usr/bin/env python -from conans import ConanFile, CMake, tools +from conan import ConanFile +from conan.tools.cmake import CMake, CMakeToolchain, CMakeDeps, cmake_layout +from conan.tools.files import copy, rmdir +from conan.tools.build import check_min_cppstd +from conan.tools.scm import Version +from conan.errors import ConanInvalidConfiguration +import os +import re + +required_conan_version = ">=1.53.0" class CatchConan(ConanFile): name = "catch2" @@ -8,53 +17,113 @@ class CatchConan(ConanFile): url = "https://github.com/catchorg/Catch2" homepage = url license = "BSL-1.0" + version = "latest" + settings = "os", "compiler", "build_type", "arch" + extension_properties = {"compatibility_cppstd": False} - exports = "LICENSE.txt" - exports_sources = ("src/*", "CMakeLists.txt", "CMake/*", "extras/*") + options = { + "shared": [True, False], + "fPIC": [True, False], + } + default_options = { + "shared": False, + "fPIC": True, + } - settings = "os", "compiler", "build_type", "arch" + @property + def _min_cppstd(self): + return "14" - generators = "cmake" + @property + def _compilers_minimum_version(self): + return { + "gcc": "7", + "Visual Studio": "15", + "msvc": "191", + "clang": "5", + "apple-clang": "10", + } - def _configure_cmake(self): - cmake = CMake(self) - cmake.definitions["BUILD_TESTING"] = "OFF" - cmake.definitions["CATCH_INSTALL_DOCS"] = "OFF" - cmake.definitions["CATCH_INSTALL_EXTRAS"] = "ON" - cmake.configure(build_folder="build") - return cmake + + def set_version(self): + pattern = re.compile(r"\w*VERSION (\d+\.\d+\.\d+) # CML version placeholder, don't delete") + with open("CMakeLists.txt") as file: + for line in file: + result = pattern.search(line) + if result: + self.version = result.group(1) + + self.output.info(f'Using version: {self.version}') + + def export(self): + copy(self, "LICENSE.txt", src=self.recipe_folder, dst=self.export_folder) + + def export_sources(self): + copy(self, "CMakeLists.txt", src=self.recipe_folder, dst=self.export_sources_folder) + copy(self, "src/*", src=self.recipe_folder, dst=self.export_sources_folder) + copy(self, "extras/*", src=self.recipe_folder, dst=self.export_sources_folder) + copy(self, "CMake/*", src=self.recipe_folder, dst=self.export_sources_folder) + + def config_options(self): + if self.settings.os == "Windows": + del self.options.fPIC + + def configure(self): + if self.options.shared: + self.options.rm_safe("fPIC") + + def layout(self): + cmake_layout(self) + + def validate(self): + if self.settings.compiler.get_safe("cppstd"): + check_min_cppstd(self, self._min_cppstd) + # INFO: Conan 1.x does not specify cppstd by default, so we need to check the compiler version instead. + minimum_version = self._compilers_minimum_version.get(str(self.settings.compiler), False) + if minimum_version and Version(self.settings.compiler.version) < minimum_version: + raise ConanInvalidConfiguration(f"{self.ref} requires C++{self._min_cppstd}, which your compiler doesn't support") + + def generate(self): + tc = CMakeToolchain(self) + tc.cache_variables["BUILD_TESTING"] = False + tc.cache_variables["CATCH_INSTALL_DOCS"] = False + tc.cache_variables["CATCH_INSTALL_EXTRAS"] = True + tc.generate() + + deps = CMakeDeps(self) + deps.generate() def build(self): - # We need this workaround until the toolchains feature - # to inject stuff like MD/MT - line_to_replace = 'list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_LIST_DIR}/CMake")' - tools.replace_in_file("CMakeLists.txt", line_to_replace, - '''{} -include("{}/conanbuildinfo.cmake") -conan_basic_setup()'''.format(line_to_replace, self.install_folder.replace("\\", "/"))) - - cmake = self._configure_cmake() + cmake = CMake(self) + cmake.configure() cmake.build() def package(self): - self.copy(pattern="LICENSE.txt", dst="licenses") - cmake = self._configure_cmake() + copy(self, "LICENSE.txt", src=str(self.recipe_folder), dst=os.path.join(self.package_folder, "licenses")) + cmake = CMake(self) cmake.install() + rmdir(self, os.path.join(self.package_folder, "share")) + rmdir(self, os.path.join(self.package_folder, "lib", "cmake")) + copy(self, "*.cmake", src=os.path.join(self.export_sources_folder, "extras"), + dst=os.path.join(self.package_folder, "lib", "cmake", "Catch2")) def package_info(self): lib_suffix = "d" if self.settings.build_type == "Debug" else "" - self.cpp_info.names["cmake_find_package"] = "Catch2" - self.cpp_info.names["cmake_find_package_multi"] = "Catch2" + self.cpp_info.set_property("cmake_file_name", "Catch2") + self.cpp_info.set_property("cmake_target_name", "Catch2::Catch2WithMain") + self.cpp_info.set_property("pkg_config_name", "catch2-with-main") + # Catch2 - self.cpp_info.components["catch2base"].names["cmake_find_package"] = "Catch2" - self.cpp_info.components["catch2base"].names["cmake_find_package_multi"] = "Catch2" - self.cpp_info.components["catch2base"].names["pkg_config"] = "Catch2" + self.cpp_info.components["catch2base"].set_property("cmake_file_name", "Catch2::Catch2") + self.cpp_info.components["catch2base"].set_property("cmake_target_name", "Catch2::Catch2") + self.cpp_info.components["catch2base"].set_property("pkg_config_name", "catch2") self.cpp_info.components["catch2base"].libs = ["Catch2" + lib_suffix] self.cpp_info.components["catch2base"].builddirs.append("lib/cmake/Catch2") + # Catch2WithMain - self.cpp_info.components["catch2main"].names["cmake_find_package"] = "Catch2WithMain" - self.cpp_info.components["catch2main"].names["cmake_find_package_multi"] = "Catch2WithMain" - self.cpp_info.components["catch2main"].names["pkg_config"] = "Catch2WithMain" + self.cpp_info.components["catch2main"].set_property("cmake_file_name", "Catch2::Catch2WithMain") + self.cpp_info.components["catch2main"].set_property("cmake_target_name", "Catch2::Catch2WithMain") + self.cpp_info.components["catch2main"].set_property("pkg_config_name", "catch2-with-main") self.cpp_info.components["catch2main"].libs = ["Catch2Main" + lib_suffix] self.cpp_info.components["catch2main"].requires = ["catch2base"] diff --git a/docs/assertions.md b/docs/assertions.md index 40faa5ebca..f3dcdd484f 100644 --- a/docs/assertions.md +++ b/docs/assertions.md @@ -110,7 +110,7 @@ Expects that an exception is thrown that, when converted to a string, matches th e.g. ```cpp -REQUIRE_THROWS_WITH( openThePodBayDoors(), Contains( "afraid" ) && Contains( "can't do that" ) ); +REQUIRE_THROWS_WITH( openThePodBayDoors(), ContainsSubstring( "afraid" ) && ContainsSubstring( "can't do that" ) ); REQUIRE_THROWS_WITH( dismantleHal(), "My mind is going" ); ``` diff --git a/docs/cmake-integration.md b/docs/cmake-integration.md index 86666efe2b..ad6ca00455 100644 --- a/docs/cmake-integration.md +++ b/docs/cmake-integration.md @@ -8,6 +8,7 @@ [`CATCH_CONFIG_*` customization options in CMake](#catch_config_-customization-options-in-cmake)
[Installing Catch2 from git repository](#installing-catch2-from-git-repository)
[Installing Catch2 from vcpkg](#installing-catch2-from-vcpkg)
+[Installing Catch2 from Bazel](#installing-catch2-from-bazel)
Because we use CMake to build Catch2, we also provide a couple of integration points for our users. @@ -384,7 +385,7 @@ install it to the default location, like so: ``` $ git clone https://github.com/catchorg/Catch2.git $ cd Catch2 -$ cmake -Bbuild -H. -DBUILD_TESTING=OFF +$ cmake -B build -S . -DBUILD_TESTING=OFF $ sudo cmake --build build/ --target install ``` @@ -408,6 +409,24 @@ cd vcpkg The catch2 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](https://github.com/Microsoft/vcpkg) on the vcpkg repository. +## Installing Catch2 from Bazel + +Catch2 is now a supported module in the Bazel Central Registry. You only need to add one line to your MODULE.bazel file; +please see https://registry.bazel.build/modules/catch2 for the latest supported version. + +You can then add `catch2_main` to each of your C++ test build rules as follows: + +``` +cc_test( + name = "example_test", + srcs = ["example_test.cpp"], + deps = [ + ":example", + "@catch2//:catch2_main", + ], +) +``` + --- [Home](Readme.md#top) diff --git a/docs/command-line.md b/docs/command-line.md index bb483959d5..7e69bf12e7 100644 --- a/docs/command-line.md +++ b/docs/command-line.md @@ -145,7 +145,7 @@ only tests that match the positive filters are included. You can also match test names with special characters by escaping them with a backslash (`"\"`), e.g. a test named `"Do A, then B"` is matched -by "Do A\, then B" test spec. Backslash also escapes itself. +by `"Do A\, then B"` test spec. Backslash also escapes itself. ### Examples @@ -194,7 +194,8 @@ verbose and human-friendly output. Reporters are also individually configurable. To pass configuration options to the reporter, you append `::key=value` to the reporter specification -as many times as you want, e.g. `--reporter xml::out=someFile.xml`. +as many times as you want, e.g. `--reporter xml::out=someFile.xml` or +`--reporter custom::colour-mode=ansi::Xoption=2`. The keys must either be prefixed by "X", in which case they are not parsed by Catch2 and are only passed down to the reporter, or one of options @@ -365,14 +366,14 @@ There are currently two warnings implemented: ## Reporting timings
-d, --durations <yes/no>
-When set to ```yes``` Catch will report the duration of each test case, in milliseconds. Note that it does this regardless of whether a test case passes or fails. Note, also, the certain reporters (e.g. Junit) always report test case durations regardless of this option being set or not. +When set to ```yes``` Catch will report the duration of each test case, in seconds with millisecond precision. Note that it does this regardless of whether a test case passes or fails. Note, also, the certain reporters (e.g. Junit) always report test case durations regardless of this option being set or not.
-D, --min-duration <value>
> `--min-duration` was [introduced](https://github.com/catchorg/Catch2/pull/1910) in Catch2 2.13.0 When set, Catch will report the duration of each test case that took more -than <value> seconds, in milliseconds. This option is overridden by both +than <value> seconds, in seconds with millisecond precision. This option is overridden by both `-d yes` and `-d no`, so that either all durations are reported, or none are. diff --git a/docs/contributing.md b/docs/contributing.md index d9f87fc1a1..d21323d991 100644 --- a/docs/contributing.md +++ b/docs/contributing.md @@ -107,8 +107,7 @@ cmake -B debug-build -S . -DCMAKE_BUILD_TYPE=Debug --preset all-tests cmake --build debug-build # 4. Run the tests using CTest -cd debug-build -ctest -j 4 --output-on-failure -C Debug +ctest -j 4 --output-on-failure -C Debug --test-dir debug-build ``` snippet source | anchor diff --git a/docs/deprecations.md b/docs/deprecations.md index 1fb79aaa0f..0b5bee1355 100644 --- a/docs/deprecations.md +++ b/docs/deprecations.md @@ -35,6 +35,19 @@ being aborted (when using `--abort` or `--abortx`). It is however **NOT** invoked for test cases that are [explicitly skipped using the `SKIP` macro](skipping-passing-failing.md#top). + +### Non-const function for `TEST_CASE_METHOD` + +> Deprecated in Catch2 vX.Y.Z + +Currently, the member function generated for `TEST_CASE_METHOD` is +not `const` qualified. In the future, the generated member function will +be `const` qualified, just as `TEST_CASE_PERSISTENT_FIXTURE` does. + +If you are mutating the fixture instance from within the test case, and +want to keep doing so in the future, mark the mutated members as `mutable`. + + --- [Home](Readme.md#top) diff --git a/docs/generators.md b/docs/generators.md index 8bca54c751..eb1a255a6d 100644 --- a/docs/generators.md +++ b/docs/generators.md @@ -206,12 +206,26 @@ or OO ranges. Unlike `std::uniform_int_distribution`, Catch2's generators also support various single-byte integral types, such as `char` or `bool`. -Given the same seed, the output from the integral generators is -reproducible across different platforms. For floating point generators, -we only promise reproducibility on platforms that obey the IEEE 754 -standard, and where `float` is 4 bytes and `double` is 8 bytes. We provide -no guarantees for `long double`, as the internals of `long double` can -vary wildly across different platforms. + +#### Reproducibility + +Given the same seed, the output from the integral generators is fully +reproducible across different platforms. + +For floating point generators, the situation is much more complex. +Generally Catch2 only promises reproducibility (or even just correctness!) +on platforms that obey the IEEE-754 standard. Furthermore, reproducibility +only applies between binaries that perform floating point math in the +same way, e.g. if you compile a binary targetting the x87 FPU and another +one targetting SSE2 for floating point math, their results will vary. +Similarly, binaries compiled with compiler flags that relax the IEEE-754 +adherence, e.g. `-ffast-math`, might provide different results than those +compiled for strict IEEE-754 adherence. + +Finally, we provide zero guarantees on the reproducibility of generating +`long double`s, as the internals of `long double` varies across different +platforms. + ## Generator interface diff --git a/docs/limitations.md b/docs/limitations.md index 099dd82a51..f5f60ba853 100644 --- a/docs/limitations.md +++ b/docs/limitations.md @@ -173,3 +173,19 @@ TEST_CASE("b") { If you are seeing a problem like this, i.e. weird test paths that trigger only under Clang with `libc++`, or only under very specific version of `libstdc++`, it is very likely you are seeing this. The only known workaround is to use a fixed version of your standard library. + +### Visual Studio 2022 -- can't compile assertion with the spaceship operator + +[The C++ standard requires that `std::foo_ordering` is only comparable with +a literal 0](https://eel.is/c++draft/cmp#categories.pre-3). There are +multiple strategies a stdlib implementation can take to achieve this, and +MSVC's STL has changed the strategy they use between two releases of VS 2022. + +With the new strategy, `REQUIRE((a <=> b) == 0)` no longer compiles under +MSVC. Note that Catch2 can compile code using MSVC STL's new strategy, +but only when compiled with a C++20 conforming compiler. MSVC is currently +not conformant enough, but `clang-cl` will compile the assertion above +using MSVC STL without problem. + +This change got in with MSVC v19.37](https://godbolt.org/z/KG9obzdvE). + diff --git a/docs/list-of-examples.md b/docs/list-of-examples.md index a919408adf..40d3f71174 100644 --- a/docs/list-of-examples.md +++ b/docs/list-of-examples.md @@ -8,6 +8,7 @@ - Assertion: [REQUIRE, CHECK](../examples/030-Asn-Require-Check.cpp) - Fixture: [Sections](../examples/100-Fix-Section.cpp) - Fixture: [Class-based fixtures](../examples/110-Fix-ClassFixture.cpp) +- Fixture: [Persistent fixtures](../examples/111-Fix-PersistentFixture.cpp) - BDD: [SCENARIO, GIVEN, WHEN, THEN](../examples/120-Bdd-ScenarioGivenWhenThen.cpp) - Listener: [Listeners](../examples/210-Evt-EventListeners.cpp) - Configuration: [Provide your own output streams](../examples/231-Cfg-OutputStreams.cpp) diff --git a/docs/logging.md b/docs/logging.md index dbd4f912ad..7970938698 100644 --- a/docs/logging.md +++ b/docs/logging.md @@ -114,6 +114,10 @@ Similar to `INFO`, but messages are not limited to their own scope: They are rem The message is always reported but does not fail the test. +**SUCCEED(** _message expression_ **)** + +The message is reported and the test case succeeds. + **FAIL(** _message expression_ **)** The message is reported and the test case fails. diff --git a/docs/matchers.md b/docs/matchers.md index b96cc5f4de..4b9445ae63 100644 --- a/docs/matchers.md +++ b/docs/matchers.md @@ -50,25 +50,43 @@ Both of the string matchers used in the examples above live in the `catch_matchers_string.hpp` header, so to compile the code above also requires `#include `. +### Combining operators and lifetimes + **IMPORTANT**: The combining operators do not take ownership of the -matcher objects being combined. This means that if you store combined -matcher object, you have to ensure that the matchers being combined -outlive its last use. What this means is that the following code leads -to a use-after-free (UAF): +matcher objects being combined. + +This means that if you store combined matcher object, you have to ensure +that the individual matchers being combined outlive the combined matcher. +Note that the negation matcher from `!` also counts as combining matcher +for this. +Explained on an example, this is fine ```cpp -#include -#include +CHECK_THAT(value, WithinAbs(0, 2e-2) && !WithinULP(0., 1)); +``` -TEST_CASE("Bugs, bugs, bugs", "[Bug]"){ - std::string str = "Bugs as a service"; +and so is this +```cpp +auto is_close_to_zero = WithinAbs(0, 2e-2); +auto is_zero = WithinULP(0., 1); - auto match_expression = Catch::Matchers::EndsWith( "as a service" ) || - (Catch::Matchers::StartsWith( "Big data" ) && !Catch::Matchers::ContainsSubstring( "web scale" ) ); - REQUIRE_THAT(str, match_expression); -} +CHECK_THAT(value, is_close_to_zero && !is_zero); ``` +but this is not +```cpp +auto is_close_to_zero = WithinAbs(0, 2e-2); +auto is_zero = WithinULP(0., 1); +auto is_close_to_but_not_zero = is_close_to_zero && !is_zero; + +CHECK_THAT(a_value, is_close_to_but_not_zero); // UAF +``` + +because `!is_zero` creates a temporary instance of Negation matcher, +which the `is_close_to_but_not_zero` refers to. After the line ends, +the temporary is destroyed and the combined `is_close_to_but_not_zero` +matcher now refers to non-existent object, so using it causes use-after-free. + ## Built-in matchers @@ -192,15 +210,36 @@ The other miscellaneous matcher utility is exception matching. #### Matching exceptions -Catch2 provides a utility macro for asserting that an expression -throws exception of specific type, and that the exception has desired -properties. The macro is `REQUIRE_THROWS_MATCHES(expr, ExceptionType, Matcher)`. +Because exceptions are a bit special, Catch2 has a separate macro for them. + + +The basic form is + +``` +REQUIRE_THROWS_MATCHES(expr, ExceptionType, Matcher) +``` + +and it checks that the `expr` throws an exception, that exception is derived +from the `ExceptionType` type, and then `Matcher::match` is called on +the caught exception. > `REQUIRE_THROWS_MATCHES` macro lives in `catch2/matchers/catch_matchers.hpp` +For one-off checks you can use the `Predicate` matcher above, e.g. + +```cpp +REQUIRE_THROWS_MATCHES(parse(...), + parse_error, + Predicate([] (parse_error const& err) -> bool { return err.line() == 1; }) +); +``` -Catch2 currently provides two matchers for exceptions. -These are: +but if you intend to thoroughly test your error reporting, I recommend +defining a specialized matcher. + + +Catch2 also provides 2 built-in matchers for checking the error message +inside an exception (it must be derived from `std::exception`): * `Message(std::string message)`. * `MessageMatches(Matcher matcher)`. @@ -218,10 +257,7 @@ REQUIRE_THROWS_MATCHES(throwsDerivedException(), DerivedException, Message("De REQUIRE_THROWS_MATCHES(throwsDerivedException(), DerivedException, MessageMatches(StartsWith("DerivedException"))); ``` -Note that `DerivedException` in the example above has to derive from -`std::exception` for the example to work. - -> the exception message matcher lives in `catch2/matchers/catch_matchers_exception.hpp` +> the exception message matchers live in `catch2/matchers/catch_matchers_exception.hpp` ### Generic range Matchers diff --git a/docs/other-macros.md b/docs/other-macros.md index 24a0fb6e6f..79990a6a5f 100644 --- a/docs/other-macros.md +++ b/docs/other-macros.md @@ -93,30 +93,6 @@ TEST_CASE("STATIC_CHECK showcase", "[traits]") { ## Test case related macros -* `METHOD_AS_TEST_CASE` - -`METHOD_AS_TEST_CASE( member-function-pointer, description )` lets you -register a member function of a class as a Catch2 test case. The class -will be separately instantiated for each method registered in this way. - -```cpp -class TestClass { - std::string s; - -public: - TestClass() - :s( "hello" ) - {} - - void testCase() { - REQUIRE( s == "hello" ); - } -}; - - -METHOD_AS_TEST_CASE( TestClass::testCase, "Use class's method as a test case", "[class]" ) -``` - * `REGISTER_TEST_CASE` `REGISTER_TEST_CASE( function, description )` let's you register diff --git a/docs/release-notes.md b/docs/release-notes.md index d263487f8c..5f2d92ae91 100644 --- a/docs/release-notes.md +++ b/docs/release-notes.md @@ -2,6 +2,13 @@ # Release notes **Contents**
+[3.7.1](#371)
+[3.7.0](#370)
+[3.6.0](#360)
+[3.5.4](#354)
+[3.5.3](#353)
+[3.5.2](#352)
+[3.5.1](#351)
[3.5.0](#350)
[3.4.0](#340)
[3.3.2](#332)
@@ -58,6 +65,137 @@ [Even Older versions](#even-older-versions)
+## 3.7.1 + +### Improvements +* Applied the JUnit reporter's optimization from last release to the SonarQube reporter +* Suppressed `-Wuseless-cast` in `CHECK_THROWS_MATCHES` (#2904) +* Standardize exit codes for various failures + * Running no tests is now guaranteed to exit with 2 (without the `--allow-running-no-tests` flag) + * All tests skipped is now always 4 (...) + * Assertion failures are now always 42 + * and so on + +### Fixes +* Fixed out-of-bounds access when the arg parser encounters single `-` as an argument (#2905) + +### Miscellaneous +* Added `catch_config_prefix_messages.hpp` to meson build (#2903) +* `catch_discover_tests` now supports skipped tests (#2873) + * You can get the old behaviour by calling `catch_discover_tests` with `SKIP_IS_FAILURE` option. + + +## 3.7.0 + +### Improvements +* Slightly improved compile times of benchmarks +* Made the resolution estimation in benchmarks slightly more precise +* Added new test case macro, `TEST_CASE_PERSISTENT_FIXTURE` (#2885, #1602) + * Unlike `TEST_CASE_METHOD`, the same underlying instance is used for all partial runs of that test case +* **MASSIVELY** improved performance of the JUnit reporter when handling successful assertions (#2897) + * For 1 test case and 10M assertions, the new reporter runs 3x faster and uses up only 8 MB of memory, while the old one needs 7 GB of memory. +* Reworked how output redirects works. + * Combining a reporter writing to stdout with capturing reporter no longer leads to the capturing reporter seeing all of the other reporter's output. + * The file based redirect no longer opens up a new temporary file for each partial test case run, so it will not run out of temporary files when running many tests in single process. + +### Miscellaneous +* Better documentation for matchers on thrown exceptions (`REQUIRE_THROWS_MATCHES`) +* Improved `catch_discover_tests`'s handling of environment paths (#2878) + * It won't reorder paths in `DL_PATHS` or `DYLD_FRAMEWORK_PATHS` args + * It won't overwrite the environment paths for test discovery + + +## 3.6.0 + +### Fixes +* Fixed Windows ARM64 build by fixing the preprocessor condition guarding use `_umul128` intrinsic. +* Fixed Windows ARM64EC build by removing intrinsic pragma it does not understand. (#2858) + * Why doesn't the x64-emulation build mode understand x64 pragmas? Don't ask me, ask the MSVC guys. +* Fixed the JUnit reporter sometimes crashing when reporting a fatal error. (#1210, #2855) + * The binary will still exit, but through the original error, rather than secondary error inside the reporter. + * The underlying fix applies to all reporters, not just the JUnit one, but only JUnit was currently causing troubles. + +### Improvements +* Disable `-Wnon-virtual-dtor` in Decomposer and Matchers (#2854) +* `precision` in floating point stringmakers defaults to `max_digits10`. + * This means that floating point values will be printed with enough precision to disambiguate any two floats. +* Column wrapping ignores ansi colour codes when calculating string width (#2833, #2849) + * This makes the output much more readable when the provided messages contain colour codes. + +### Miscellaneous +* Conan support improvements + * `compatibility_cppstr` is set to False. (#2860) + * This means that Conan won't let you mix library and project with different C++ standard settings. + * The implementation library CMake target name through Conan is properly set to `Catch2::Catch2` (#2861) +* `SelfTest` target can be built through Bazel (#2857) + + +## 3.5.4 + +### Fixes +* Fixed potential compilation error when asked to generate random integers whose type did not match `std::(u)int*_t`. + * This manifested itself when generating random `size_t`s on MacOS +* Added missing outlined destructor causing `Wdelete-incomplete` when compiling against libstdc++ in C++23 mode (#2852) +* Fixed regression where decomposing assertion with const instance of `std::foo_ordering` would not compile + +### Improvements +* Reintroduced support for GCC 5 and 6 (#2836) + * As with VS2017, if they start causing trouble again, they will be dropped again. +* Added workaround for targetting newest MacOS (Sonoma) using GCC (#2837, #2839) +* `CATCH_CONFIG_DEFAULT_REPORTER` can now be an arbitrary reporter spec + * Previously it could only be a plain reporter name, so it was impossible to compile in custom arguments to the reporter. +* Improved performance of generating 64bit random integers by 20+% + +### Miscellaneous +* Significantly improved Conan in-tree recipe (#2831) +* `DL_PATHS` in `catch_discover_tests` now supports multiple arguments (#2852, #2736) +* Fixed preprocessor logic for checking whether we expect reproducible floating point results in tests. +* Improved the floating point tests structure to avoid `Wunused` when the reproducibility tests are disabled (#2845) + + +## 3.5.3 + +### Fixes +* Fixed OOB access when computing filename tag (from the `-#` flag) for file without extension (#2798) +* Fixed the linking against `log` on Android to be `PRIVATE` (#2815) +* Fixed `Wuseless-cast` in benchmarking internals (#2823) + +### Improvements +* Restored compatibility with VS2017 (#2792, #2822) + * The baseline for Catch2 is still C++14 with some reasonable workarounds for specific compilers, so if VS2017 starts acting up again, the support will be dropped again. +* Suppressed clang-tidy's `bugprone-chained-comparison` in assertions (#2801) +* Improved the static analysis mode to evaluate arguments to `TEST_CASE` and `SECTION` (#2817) + * Clang-tidy should no longer warn about runtime arguments to these macros being unused in static analysis mode. + * Clang-tidy can warn on issues involved arguments to these macros. +* Added support for literal-zero detectors based on `consteval` constructors + * This is required for compiling `REQUIRE((a <=> b) == 0)` against MSVC's stdlib. + * Sadly, MSVC still cannot compile this assertion as it does not implement C++20 correctly. + * You can use `clang-cl` with MSVC's stdlib instead. + * If for some godforsaken reasons you want to understand this better, read the two relevant commits: [`dc51386b9fd61f99ea9c660d01867e6ad489b403`](https://github.com/catchorg/Catch2/commit/dc51386b9fd61f99ea9c660d01867e6ad489b403), and [`0787132fc82a75e3fb255aa9484ca1dc1eff2a30`](https://github.com/catchorg/Catch2/commit/0787132fc82a75e3fb255aa9484ca1dc1eff2a30). + +### Miscellaneous +* Disabled tests for FP random generator reproducibility on non-SSE2 x86 targets (#2796) +* Modified the in-tree Conan recipe to support Conan 2 (#2805) + + +## 3.5.2 + +### Fixes +* Fixed `-Wsubobject-linkage` in the Console reporter (#2794) +* Fixed adding new CLI Options to lvalue parser using `|` (#2787) + + +## 3.5.1 + +### Improvements +* Significantly improved performance of the CLI parsing. + * This includes the cost of preparing the CLI parser, so Catch2's binaries start much faster. + +### Miscellaneous +* Added support for Bazel modules (#2781) +* Added CMake option to disable the build reproducibility settings (#2785) +* Added `log` library linking to the Meson build (#2784) + ## 3.5.0 @@ -75,7 +213,7 @@ * Catch2 should automatically disable getenv when compiled for XBox. * Compiling Catch2 with exceptions disabled no longer triggers `Wunused-function` (#2726) * **`random` Generators for integral types are now reproducible across different platforms** - * Unlike ``, Catch2's generators also support 1 byte integral types (`char`, `bool`, ...) + * Unlike ``, Catch2's generators also support 1 byte integral types (`char`, `bool`, ...) * **`random` Generators for `float` and `double` are now reproducible across different platforms** * `long double` varies across different platforms too much to be reproducible * This guarantee applies only to platforms with IEEE 754 floats. diff --git a/docs/reporters.md b/docs/reporters.md index e2abfe34d0..20ef5e5529 100644 --- a/docs/reporters.md +++ b/docs/reporters.md @@ -5,7 +5,7 @@ Reporters are a customization point for most of Catch2's output, e.g. formatting and writing out [assertions (whether passing or failing), sections, test cases, benchmarks, and so on](reporter-events.md#top). -Catch2 comes with a bunch of reporters by default (currently 8), and +Catch2 comes with a bunch of reporters by default (currently 9), and you can also write your own reporter. Because multiple reporters can be active at the same time, your own reporters do not even have to handle all reporter event, just the ones you are interested in, e.g. benchmarks. diff --git a/docs/test-cases-and-sections.md b/docs/test-cases-and-sections.md index 01c898bb64..14db55aee1 100644 --- a/docs/test-cases-and-sections.md +++ b/docs/test-cases-and-sections.md @@ -48,7 +48,7 @@ For more detail on command line selection see [the command line docs](command-li Tag names are not case sensitive and can contain any ASCII characters. This means that tags `[tag with spaces]` and `[I said "good day"]` are both allowed tags and can be filtered on. However, escapes are not -supported however and `[\]]` is not a valid tag. +supported and `[\]]` is not a valid tag. The same tag can be specified multiple times for a single test case, but only one of the instances of identical tags will be kept. Which one diff --git a/docs/test-fixtures.md b/docs/test-fixtures.md index 9c9eaa18c0..653b50e029 100644 --- a/docs/test-fixtures.md +++ b/docs/test-fixtures.md @@ -1,9 +1,30 @@ # Test fixtures -## Defining test fixtures +**Contents**
+[Non-Templated test fixtures](#non-templated-test-fixtures)
+[Templated test fixtures](#templated-test-fixtures)
+[Signature-based parameterised test fixtures](#signature-based-parametrised-test-fixtures)
+[Template fixtures with types specified in template type lists](#template-fixtures-with-types-specified-in-template-type-lists)
-Although Catch allows you to group tests together as [sections within a test case](test-cases-and-sections.md), it can still be convenient, sometimes, to group them using a more traditional test fixture. Catch fully supports this too. You define the test fixture as a simple structure: +## Non-Templated test fixtures + +Although Catch2 allows you to group tests together as +[sections within a test case](test-cases-and-sections.md), it can still +be convenient, sometimes, to group them using a more traditional test. +Catch2 fully supports this too with 3 different macros for +non-templated test fixtures. They are: + +| Macro | Description | +|----------|-------------| +|1. `TEST_CASE_METHOD(className, ...)`| Creates a uniquely named class which inherits from the class specified by `className`. The test function will be a member of this derived class. An instance of the derived class will be created for every partial run of the test case. | +|2. `METHOD_AS_TEST_CASE(member-function, ...)`| Uses `member-function` as the test function. An instance of the class will be created for each partial run of the test case. | +|3. `TEST_CASE_PERSISTENT_FIXTURE(className, ...)`| Creates a uniquely named class which inherits from the class specified by `className`. The test function will be a member of this derived class. An instance of the derived class will be created at the start of the test run. That instance will be destroyed once the entire test case has ended. | + +### 1. `TEST_CASE_METHOD` + + +You define a `TEST_CASE_METHOD` test fixture as a simple structure: ```c++ class UniqueTestsFixture { @@ -30,8 +51,116 @@ class UniqueTestsFixture { } ``` -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. +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. + +### 2. `METHOD_AS_TEST_CASE` + +`METHOD_AS_TEST_CASE` lets you register a member function of a class +as a Catch2 test case. The class will be separately instantiated +for each method registered in this way. + +```cpp +class TestClass { + std::string s; + +public: + TestClass() + :s( "hello" ) + {} + + void testCase() { + REQUIRE( s == "hello" ); + } +}; + + +METHOD_AS_TEST_CASE( TestClass::testCase, "Use class's method as a test case", "[class]" ) +``` + +This type of fixture is similar to [TEST_CASE_METHOD](#1-test_case_method) except in this +case it will directly use the provided class to create an object rather than a derived +class. + +### 3. `TEST_CASE_PERSISTENT_FIXTURE` + +> [Introduced](https://github.com/catchorg/Catch2/pull/2885) in Catch2 3.7.0 + +`TEST_CASE_PERSISTENT_FIXTURE` behaves in the same way as +[TEST_CASE_METHOD](#1-test_case_method) except that there will only be +one instance created throughout the entire run of a test case. To +demonstrate this have a look at the following example: + +```cpp +class ClassWithExpensiveSetup { +public: + ClassWithExpensiveSetup() { + // expensive construction + std::this_thread::sleep_for( std::chrono::seconds( 2 ) ); + } + + ~ClassWithExpensiveSetup() noexcept { + // expensive destruction + std::this_thread::sleep_for( std::chrono::seconds( 1 ) ); + } + + int getInt() const { return 42; } +}; + +struct MyFixture { + mutable int myInt = 0; + ClassWithExpensiveSetup expensive; +}; + +TEST_CASE_PERSISTENT_FIXTURE( MyFixture, "Tests with MyFixture" ) { + + const int val = myInt++; + + SECTION( "First partial run" ) { + const auto otherValue = expensive.getInt(); + REQUIRE( val == 0 ); + REQUIRE( otherValue == 42 ); + } + + SECTION( "Second partial run" ) { REQUIRE( val == 1 ); } +} +``` + +This example demonstates two possible use-cases of this fixture type: +1. Improve test run times by reducing the amount of expensive and +redundant setup and tear-down required. +2. Reusing results from the previous partial run, in the current +partial run. + +This test case will be executed twice as there are two leaf sections. +On the first run `val` will be `0` and on the second run `val` will be +`1`. This demonstrates that we were able to use the results of the +previous partial run in subsequent partial runs. + +Additionally, we are simulating an expensive object using +`std::this_thread::sleep_for`, but real world use-cases could be: +1. Creating a D3D12/Vulkan device +2. Connecting to a database +3. Loading a file. + +The fixture object (`MyFixture`) will be constructed just before the +test case begins, and it will be destroyed just after the test case +ends. Therefore, this expensive object will only be created and +destroyed once during the execution of this test case. If we had used +`TEST_CASE_METHOD`, `MyFixture` would have been created and destroyed +twice during the execution of this test case. + +NOTE: The member function which runs the test case is `const`. Therefore +if you want to mutate any member of the fixture it must be marked as +`mutable` as shown in this example. This is to make it clear that +the initial state of the fixture is intended to mutate during the +execution of the test case. +## Templated test fixtures Catch2 also provides `TEMPLATE_TEST_CASE_METHOD` and `TEMPLATE_PRODUCT_TEST_CASE_METHOD` that can be used together @@ -93,7 +222,7 @@ _While there is an upper limit on the number of types you can specify in single `TEMPLATE_TEST_CASE_METHOD` or `TEMPLATE_PRODUCT_TEST_CASE_METHOD`, the limit is very high and should not be encountered in practice._ -## Signature-based parametrised test fixtures +## Signature-based parameterised test fixtures > [Introduced](https://github.com/catchorg/Catch2/issues/1609) in Catch2 2.8.0. diff --git a/docs/tutorial.md b/docs/tutorial.md index dfccac888d..fb5a5b37ca 100644 --- a/docs/tutorial.md +++ b/docs/tutorial.md @@ -16,7 +16,7 @@ Ideally you should be using Catch2 through its [CMake integration](cmake-integra Catch2 also provides pkg-config files and two file (header + cpp) distribution, but this documentation will assume you are using CMake. If you are using the two file distribution instead, remember to replace -the included header with `catch_amalgamated.hpp`. +the included header with `catch_amalgamated.hpp` ([step by step instructions](migrate-v2-to-v3.md#how-to-migrate-projects-from-v2-to-v3)). ## Writing tests diff --git a/examples/111-Fix-PersistentFixture.cpp b/examples/111-Fix-PersistentFixture.cpp new file mode 100644 index 0000000000..2bef90ff7c --- /dev/null +++ b/examples/111-Fix-PersistentFixture.cpp @@ -0,0 +1,74 @@ + +// Copyright Catch2 Authors +// Distributed under the Boost Software License, Version 1.0. +// (See accompanying file LICENSE.txt or copy at +// https://www.boost.org/LICENSE_1_0.txt) + +// SPDX-License-Identifier: BSL-1.0 + +// Fixture.cpp + +// Catch2 has three ways to express fixtures: +// - Sections +// - Traditional class-based fixtures that are created and destroyed on every +// partial run +// - Traditional class-based fixtures that are created at the start of a test +// case and destroyed at the end of a test case (this file) + +// main() provided by linkage to Catch2WithMain + +#include + +#include + +class ClassWithExpensiveSetup { +public: + ClassWithExpensiveSetup() { + // Imagine some really expensive set up here. + // e.g. + // setting up a D3D12/Vulkan Device, + // connecting to a database, + // loading a file + // etc etc etc + std::this_thread::sleep_for( std::chrono::seconds( 2 ) ); + } + + ~ClassWithExpensiveSetup() noexcept { + // We can do any clean up of the expensive class in the destructor + // e.g. + // destroy D3D12/Vulkan Device, + // disconnecting from a database, + // release file handle + // etc etc etc + std::this_thread::sleep_for( std::chrono::seconds( 1 ) ); + } + + int getInt() const { return 42; } +}; + +struct MyFixture { + + // The test case member function is const. + // Therefore we need to mark any member of the fixture + // that needs to mutate as mutable. + mutable int myInt = 0; + ClassWithExpensiveSetup expensive; +}; + +// Only one object of type MyFixture will be instantiated for the run +// of this test case even though there are two leaf sections. +// This is useful if your test case requires an object that is +// expensive to create and could be reused for each partial run of the +// test case. +TEST_CASE_PERSISTENT_FIXTURE( MyFixture, "Tests with MyFixture" ) { + + const int val = myInt++; + + SECTION( "First partial run" ) { + const auto otherValue = expensive.getInt(); + REQUIRE( val == 0 ); + REQUIRE( otherValue == 42 ); + } + + SECTION( "Second partial run" ) { REQUIRE( val == 1 ); } +} \ No newline at end of file diff --git a/examples/210-Evt-EventListeners.cpp b/examples/210-Evt-EventListeners.cpp index 56b050d411..d05dfaaa5a 100644 --- a/examples/210-Evt-EventListeners.cpp +++ b/examples/210-Evt-EventListeners.cpp @@ -385,8 +385,7 @@ struct MyListener : Catch::EventListenerBase { CATCH_REGISTER_LISTENER( MyListener ) // Get rid of Wweak-tables -MyListener::~MyListener() {} - +MyListener::~MyListener() = default; // ----------------------------------------------------------------------- // 3. Test cases: diff --git a/examples/231-Cfg-OutputStreams.cpp b/examples/231-Cfg-OutputStreams.cpp index da1713cf8c..5aee38bc25 100644 --- a/examples/231-Cfg-OutputStreams.cpp +++ b/examples/231-Cfg-OutputStreams.cpp @@ -22,7 +22,7 @@ class out_buff : public std::stringbuf { std::FILE* m_stream; public: out_buff(std::FILE* stream):m_stream(stream) {} - ~out_buff(); + ~out_buff() override; int sync() override { int ret = 0; for (unsigned char c : str()) { diff --git a/examples/232-Cfg-CustomMain.cpp b/examples/232-Cfg-CustomMain.cpp new file mode 100644 index 0000000000..2704099377 --- /dev/null +++ b/examples/232-Cfg-CustomMain.cpp @@ -0,0 +1,41 @@ + +// Copyright Catch2 Authors +// Distributed under the Boost Software License, Version 1.0. +// (See accompanying file LICENSE.txt or copy at +// https://www.boost.org/LICENSE_1_0.txt) + +// SPDX-License-Identifier: BSL-1.0 + +// 232-Cfg-CustomMain.cpp +// Show how to use custom main and add a custom option to the CLI parser + +#include + +#include + +int main(int argc, char** argv) { + Catch::Session session; // There must be exactly one instance + + int height = 0; // Some user variable you want to be able to set + + // Build a new parser on top of Catch2's + using namespace Catch::Clara; + auto cli + = session.cli() // Get Catch2's command line parser + | Opt( height, "height" ) // bind variable to a new option, with a hint string + ["--height"] // the option names it will respond to + ("how high?"); // description string for the help output + + // Now pass the new composite back to Catch2 so it uses that + session.cli( cli ); + + // Let Catch2 (using Clara) parse the command line + int returnCode = session.applyCommandLine( argc, argv ); + if( returnCode != 0 ) // Indicates a command line error + return returnCode; + + // if set on the command line then 'height' is now set at this point + std::cout << "height: " << height << '\n'; + + return session.run(); +} diff --git a/examples/300-Gen-OwnGenerator.cpp b/examples/300-Gen-OwnGenerator.cpp index b5d951ac47..9cb02e396a 100644 --- a/examples/300-Gen-OwnGenerator.cpp +++ b/examples/300-Gen-OwnGenerator.cpp @@ -21,7 +21,7 @@ namespace { // This class shows how to implement a simple generator for Catch tests -class RandomIntGenerator : public Catch::Generators::IGenerator { +class RandomIntGenerator final : public Catch::Generators::IGenerator { std::minstd_rand m_rand; std::uniform_int_distribution<> m_dist; int current_number; diff --git a/examples/301-Gen-MapTypeConversion.cpp b/examples/301-Gen-MapTypeConversion.cpp index a065d87ae7..0a2844836f 100644 --- a/examples/301-Gen-MapTypeConversion.cpp +++ b/examples/301-Gen-MapTypeConversion.cpp @@ -24,12 +24,12 @@ namespace { // Returns a line from a stream. You could have it e.g. read lines from // a file, but to avoid problems with paths in examples, we will use // a fixed stringstream. -class LineGenerator : public Catch::Generators::IGenerator { +class LineGenerator final : public Catch::Generators::IGenerator { std::string m_line; std::stringstream m_stream; public: - LineGenerator() { - m_stream.str("1\n2\n3\n4\n"); + explicit LineGenerator( std::string const& lines ) { + m_stream.str( lines ); if (!next()) { Catch::Generators::Detail::throw_generator_exception("Couldn't read a single line"); } @@ -49,18 +49,19 @@ std::string const& LineGenerator::get() const { // This helper function provides a nicer UX when instantiating the generator // Notice that it returns an instance of GeneratorWrapper, which // is a value-wrapper around std::unique_ptr>. -Catch::Generators::GeneratorWrapper lines(std::string /* ignored for example */) { +Catch::Generators::GeneratorWrapper +lines( std::string const& lines ) { return Catch::Generators::GeneratorWrapper( - new LineGenerator() - ); + new LineGenerator( lines ) ); } } // end anonymous namespace TEST_CASE("filter can convert types inside the generator expression", "[example][generator]") { - auto num = GENERATE(map([](std::string const& line) { return std::stoi(line); }, - lines("fake-file"))); + auto num = GENERATE( + map( []( std::string const& line ) { return std::stoi( line ); }, + lines( "1\n2\n3\n4\n" ) ) ); REQUIRE(num > 0); } diff --git a/examples/CMakeLists.txt b/examples/CMakeLists.txt index f993334180..4647df1dd9 100644 --- a/examples/CMakeLists.txt +++ b/examples/CMakeLists.txt @@ -28,8 +28,10 @@ set( SOURCES_IDIOMATIC_EXAMPLES 030-Asn-Require-Check.cpp 100-Fix-Section.cpp 110-Fix-ClassFixture.cpp + 111-Fix-PersistentFixture.cpp 120-Bdd-ScenarioGivenWhenThen.cpp 210-Evt-EventListeners.cpp + 232-Cfg-CustomMain.cpp 300-Gen-OwnGenerator.cpp 301-Gen-MapTypeConversion.cpp 302-Gen-Table.cpp @@ -42,8 +44,7 @@ set( TARGETS_IDIOMATIC_EXAMPLES ${BASENAMES_IDIOMATIC_EXAMPLES} ) foreach( name ${TARGETS_IDIOMATIC_EXAMPLES} ) - add_executable( ${name} - ${EXAMPLES_DIR}/${name}.cpp ) + add_executable( ${name} ${name}.cpp ) endforeach() set(ALL_EXAMPLE_TARGETS @@ -53,7 +54,7 @@ set(ALL_EXAMPLE_TARGETS ) foreach( name ${ALL_EXAMPLE_TARGETS} ) - target_link_libraries( ${name} Catch2 Catch2WithMain ) + target_link_libraries( ${name} Catch2WithMain ) endforeach() diff --git a/extras/Catch.cmake b/extras/Catch.cmake index 8f30688c52..c1712885fa 100644 --- a/extras/Catch.cmake +++ b/extras/Catch.cmake @@ -38,6 +38,7 @@ same as the Catch name; see also ``TEST_PREFIX`` and ``TEST_SUFFIX``. [OUTPUT_PREFIX prefix] [OUTPUT_SUFFIX suffix] [DISCOVERY_MODE ] + [SKIP_IS_FAILURE] ) ``catch_discover_tests`` sets up a post-build command on the test executable @@ -124,7 +125,14 @@ same as the Catch name; see also ``TEST_PREFIX`` and ``TEST_SUFFIX``. test executable and when the tests are executed themselves. This requires cmake/ctest >= 3.22. - `DISCOVERY_MODE mode`` + ``DL_FRAMEWORK_PATHS path...`` + Specifies paths that need to be set for the dynamic linker to find libraries + packaged as frameworks on Apple platforms when running the test executable + (DYLD_FRAMEWORK_PATH). These paths will both be set when retrieving the list + of test cases from the test executable and when the tests are executed themselves. + This requires cmake/ctest >= 3.22. + + ``DISCOVERY_MODE mode`` Provides control over when ``catch_discover_tests`` performs test discovery. By default, ``POST_BUILD`` sets up a post-build command to perform test discovery at build time. In certain scenarios, like cross-compiling, this ``POST_BUILD`` @@ -136,6 +144,9 @@ same as the Catch name; see also ``TEST_PREFIX`` and ``TEST_SUFFIX``. ``CMAKE_CATCH_DISCOVER_TESTS_DISCOVERY_MODE`` variable if it is not passed when calling ``catch_discover_tests``. This provides a mechanism for globally selecting a preferred test discovery behavior without having to modify each call site. + + ``SKIP_IS_FAILURE`` + Disables skipped test detection. #]=======================================================================] @@ -144,9 +155,9 @@ function(catch_discover_tests TARGET) cmake_parse_arguments( "" - "" + "SKIP_IS_FAILURE" "TEST_PREFIX;TEST_SUFFIX;WORKING_DIRECTORY;TEST_LIST;REPORTER;OUTPUT_DIR;OUTPUT_PREFIX;OUTPUT_SUFFIX;DISCOVERY_MODE" - "TEST_SPEC;EXTRA_ARGS;PROPERTIES;DL_PATHS" + "TEST_SPEC;EXTRA_ARGS;PROPERTIES;DL_PATHS;DL_FRAMEWORK_PATHS" ${ARGN} ) @@ -156,10 +167,11 @@ function(catch_discover_tests TARGET) if(NOT _TEST_LIST) set(_TEST_LIST ${TARGET}_TESTS) endif() - if (_DL_PATHS) - if(${CMAKE_VERSION} VERSION_LESS "3.22.0") - message(FATAL_ERROR "The DL_PATHS option requires at least cmake 3.22") - endif() + if(_DL_PATHS AND ${CMAKE_VERSION} VERSION_LESS "3.22.0") + message(FATAL_ERROR "The DL_PATHS option requires at least cmake 3.22") + endif() + if(_DL_FRAMEWORK_PATHS AND ${CMAKE_VERSION} VERSION_LESS "3.22.0") + message(FATAL_ERROR "The DL_FRAMEWORK_PATHS option requires at least cmake 3.22") endif() if(NOT _DISCOVERY_MODE) if(NOT CMAKE_CATCH_DISCOVER_TESTS_DISCOVERY_MODE) @@ -184,6 +196,9 @@ function(catch_discover_tests TARGET) TARGET ${TARGET} PROPERTY CROSSCOMPILING_EMULATOR ) + if (NOT _SKIP_IS_FAILURE) + set(_PROPERTIES ${_PROPERTIES} SKIP_RETURN_CODE 4) + endif() if(_DISCOVERY_MODE STREQUAL "POST_BUILD") add_custom_command( @@ -205,6 +220,7 @@ function(catch_discover_tests TARGET) -D "TEST_OUTPUT_PREFIX=${_OUTPUT_PREFIX}" -D "TEST_OUTPUT_SUFFIX=${_OUTPUT_SUFFIX}" -D "TEST_DL_PATHS=${_DL_PATHS}" + -D "TEST_DL_FRAMEWORK_PATHS=${_DL_FRAMEWORK_PATHS}" -D "CTEST_FILE=${ctest_tests_file}" -P "${_CATCH_DISCOVER_TESTS_SCRIPT}" VERBATIM @@ -250,6 +266,7 @@ function(catch_discover_tests TARGET) " TEST_OUTPUT_SUFFIX" " [==[" "${_OUTPUT_SUFFIX}" "]==]" "\n" " CTEST_FILE" " [==[" "${ctest_tests_file}" "]==]" "\n" " TEST_DL_PATHS" " [==[" "${_DL_PATHS}" "]==]" "\n" + " TEST_DL_FRAMEWORK_PATHS" " [==[" "${_DL_FRAMEWORK_PATHS}" "]==]" "\n" " CTEST_FILE" " [==[" "${CTEST_FILE}" "]==]" "\n" " )" "\n" " endif()" "\n" diff --git a/extras/CatchAddTests.cmake b/extras/CatchAddTests.cmake index 692e340566..399a839d92 100644 --- a/extras/CatchAddTests.cmake +++ b/extras/CatchAddTests.cmake @@ -21,8 +21,8 @@ function(catch_discover_tests_impl) cmake_parse_arguments( "" "" - "TEST_EXECUTABLE;TEST_WORKING_DIR;TEST_DL_PATHS;TEST_OUTPUT_DIR;TEST_OUTPUT_PREFIX;TEST_OUTPUT_SUFFIX;TEST_PREFIX;TEST_REPORTER;TEST_SPEC;TEST_SUFFIX;TEST_LIST;CTEST_FILE" - "TEST_EXTRA_ARGS;TEST_PROPERTIES;TEST_EXECUTOR" + "TEST_EXECUTABLE;TEST_WORKING_DIR;TEST_OUTPUT_DIR;TEST_OUTPUT_PREFIX;TEST_OUTPUT_SUFFIX;TEST_PREFIX;TEST_REPORTER;TEST_SPEC;TEST_SUFFIX;TEST_LIST;CTEST_FILE" + "TEST_EXTRA_ARGS;TEST_PROPERTIES;TEST_EXECUTOR;TEST_DL_PATHS;TEST_DL_FRAMEWORK_PATHS" ${ARGN} ) @@ -36,6 +36,8 @@ function(catch_discover_tests_impl) set(output_prefix ${_TEST_OUTPUT_PREFIX}) set(output_suffix ${_TEST_OUTPUT_SUFFIX}) set(dl_paths ${_TEST_DL_PATHS}) + set(dl_framework_paths ${_TEST_DL_FRAMEWORK_PATHS}) + set(environment_modifications "") set(script) set(suite) set(tests) @@ -56,10 +58,19 @@ function(catch_discover_tests_impl) endif() if(dl_paths) - cmake_path(CONVERT "${dl_paths}" TO_NATIVE_PATH_LIST paths) + cmake_path(CONVERT "$ENV{${dl_paths_variable_name}}" TO_NATIVE_PATH_LIST env_dl_paths) + list(PREPEND env_dl_paths "${dl_paths}") + cmake_path(CONVERT "${env_dl_paths}" TO_NATIVE_PATH_LIST paths) set(ENV{${dl_paths_variable_name}} "${paths}") endif() + if(APPLE AND dl_framework_paths) + cmake_path(CONVERT "$ENV{DYLD_FRAMEWORK_PATH}" TO_NATIVE_PATH_LIST env_dl_framework_paths) + list(PREPEND env_dl_framework_paths "${dl_framework_paths}") + cmake_path(CONVERT "${env_dl_framework_paths}" TO_NATIVE_PATH_LIST paths) + set(ENV{DYLD_FRAMEWORK_PATH} "${paths}") + endif() + execute_process( COMMAND ${_TEST_EXECUTOR} "${_TEST_EXECUTABLE}" ${spec} --list-tests --verbosity quiet OUTPUT_VARIABLE output @@ -117,7 +128,14 @@ function(catch_discover_tests_impl) if(dl_paths) foreach(path ${dl_paths}) cmake_path(NATIVE_PATH path native_path) - list(APPEND environment_modifications "${dl_paths_variable_name}=path_list_prepend:${native_path}") + list(PREPEND environment_modifications "${dl_paths_variable_name}=path_list_prepend:${native_path}") + endforeach() + endif() + + if(APPLE AND dl_framework_paths) + foreach(path ${dl_framework_paths}) + cmake_path(NATIVE_PATH path native_path) + list(PREPEND environment_modifications "DYLD_FRAMEWORK_PATH=path_list_prepend:${native_path}") endforeach() endif() @@ -187,6 +205,7 @@ if(CMAKE_SCRIPT_MODE_FILE) TEST_OUTPUT_PREFIX ${TEST_OUTPUT_PREFIX} TEST_OUTPUT_SUFFIX ${TEST_OUTPUT_SUFFIX} TEST_DL_PATHS ${TEST_DL_PATHS} + TEST_DL_FRAMEWORK_PATHS ${TEST_DL_FRAMEWORK_PATHS} CTEST_FILE ${CTEST_FILE} ) endif() diff --git a/extras/ParseAndAddCatchTests.cmake b/extras/ParseAndAddCatchTests.cmake index 4771e02996..31fc193a17 100644 --- a/extras/ParseAndAddCatchTests.cmake +++ b/extras/ParseAndAddCatchTests.cmake @@ -187,7 +187,7 @@ function(ParseAndAddCatchTests_ParseFile SourceFile TestTarget) if(result) set(HiddenTagFound ON) break() - endif(result) + endif() endforeach(label) if(PARSE_CATCH_TESTS_NO_HIDDEN_TESTS AND ${HiddenTagFound} AND ${CMAKE_VERSION} VERSION_LESS "3.9") ParseAndAddCatchTests_PrintDebugMessage("Skipping test \"${CTestName}\" as it has [!hide], [.] or [.foo] label") diff --git a/extras/catch_amalgamated.cpp b/extras/catch_amalgamated.cpp index cfc38a4636..f45c18a011 100644 --- a/extras/catch_amalgamated.cpp +++ b/extras/catch_amalgamated.cpp @@ -6,8 +6,8 @@ // SPDX-License-Identifier: BSL-1.0 -// Catch v3.5.0 -// Generated: 2023-12-11 00:51:07.662625 +// Catch v3.7.1 +// Generated: 2024-09-17 10:36:45.608896 // ---------------------------------------------------------- // This file is an amalgamation of multiple different files. // You probably shouldn't edit it directly. @@ -101,8 +101,8 @@ namespace Catch { FDuration mean = FDuration(0); int i = 0; for (auto it = first; it < last; ++it, ++i) { - samples.push_back(FDuration(*it)); - mean += FDuration(*it); + samples.push_back(*it); + mean += *it; } mean /= i; @@ -128,7 +128,13 @@ namespace Catch { namespace Catch { namespace Benchmark { namespace Detail { + struct do_nothing { + void operator()() const {} + }; + BenchmarkFunction::callable::~callable() = default; + BenchmarkFunction::BenchmarkFunction(): + f( new model{ {} } ){} } // namespace Detail } // namespace Benchmark } // namespace Catch @@ -187,21 +193,16 @@ namespace Catch { double const* last, Estimator& estimator ) { auto n = static_cast( last - first ); - std::uniform_int_distribution dist( 0, - n - 1 ); + Catch::uniform_integer_distribution dist( 0, n - 1 ); sample out; out.reserve( resamples ); - // We allocate the vector outside the loop to avoid realloc - // per resample std::vector resampled; resampled.reserve( n ); for ( size_t i = 0; i < resamples; ++i ) { resampled.clear(); for ( size_t s = 0; s < n; ++s ) { - resampled.push_back( - first[static_cast( - dist( rng ) )] ); + resampled.push_back( first[dist( rng )] ); } const auto estimate = estimator( resampled.data(), resampled.data() + resampled.size() ); @@ -563,7 +564,7 @@ bool marginComparison(double lhs, double rhs, double margin) { namespace Catch { Approx::Approx ( double value ) - : m_epsilon( std::numeric_limits::epsilon()*100. ), + : m_epsilon( static_cast(std::numeric_limits::epsilon())*100. ), m_margin( 0.0 ), m_scale( 0.0 ), m_value( value ) @@ -626,7 +627,7 @@ std::string StringMaker::convert(Catch::Approx const& value) { namespace Catch { - AssertionResultData::AssertionResultData(ResultWas::OfType _resultType, LazyExpression const & _lazyExpression): + AssertionResultData::AssertionResultData(ResultWas::OfType _resultType, LazyExpression const& _lazyExpression): lazyExpression(_lazyExpression), resultType(_resultType) {} @@ -812,14 +813,16 @@ namespace Catch { // Insert the default reporter if user hasn't asked for a specific one if ( m_data.reporterSpecifications.empty() ) { - m_data.reporterSpecifications.push_back( { #if defined( CATCH_CONFIG_DEFAULT_REPORTER ) - CATCH_CONFIG_DEFAULT_REPORTER, + const auto default_spec = CATCH_CONFIG_DEFAULT_REPORTER; #else - "console", + const auto default_spec = "console"; #endif - {}, {}, {} - } ); + auto parsed = parseReporterSpec(default_spec); + CATCH_ENFORCE( parsed, + "Cannot parse the provided default reporter spec: '" + << default_spec << '\'' ); + m_data.reporterSpecifications.push_back( std::move( *parsed ) ); } if ( enableBazelEnvSupport() ) { @@ -1043,6 +1046,8 @@ namespace Catch { m_messages.back().message += " := "; start = pos; } + break; + default:; // noop } } assert(openings.empty() && "Mismatched openings"); @@ -1165,7 +1170,13 @@ namespace Catch { namespace Catch { namespace { - const int MaxExitCode = 255; + static constexpr int TestFailureExitCode = 42; + static constexpr int UnspecifiedErrorExitCode = 1; + static constexpr int AllTestsSkippedExitCode = 4; + static constexpr int NoTestsRunExitCode = 2; + static constexpr int UnmatchedTestSpecExitCode = 3; + static constexpr int InvalidTestSpecExitCode = 5; + IEventListenerPtr createReporter(std::string const& reporterName, ReporterConfig&& config) { auto reporter = Catch::getRegistryHub().getReporterRegistry().create(reporterName, CATCH_MOVE(config)); @@ -1329,8 +1340,7 @@ namespace Catch { } int Session::applyCommandLine( int argc, char const * const * argv ) { - if( m_startupExceptions ) - return 1; + if ( m_startupExceptions ) { return UnspecifiedErrorExitCode; } auto result = m_cli.parse( Clara::Args( argc, argv ) ); @@ -1346,7 +1356,7 @@ namespace Catch { << TextFlow::Column( result.errorMessage() ).indent( 2 ) << "\n\n"; errStream->stream() << "Run with -? for usage\n\n" << std::flush; - return MaxExitCode; + return UnspecifiedErrorExitCode; } if( m_configData.showHelp ) @@ -1416,8 +1426,7 @@ namespace Catch { } int Session::runInternal() { - if( m_startupExceptions ) - return 1; + if ( m_startupExceptions ) { return UnspecifiedErrorExitCode; } if (m_configData.showHelp || m_configData.libIdentify) { return 0; @@ -1428,7 +1437,7 @@ namespace Catch { << ") must be greater than the shard index (" << m_configData.shardIndex << ")\n" << std::flush; - return 1; + return UnspecifiedErrorExitCode; } CATCH_TRY { @@ -1451,7 +1460,7 @@ namespace Catch { for ( auto const& spec : invalidSpecs ) { reporter->reportInvalidTestSpec( spec ); } - return 1; + return InvalidTestSpecExitCode; } @@ -1465,29 +1474,29 @@ namespace Catch { if ( tests.hadUnmatchedTestSpecs() && m_config->warnAboutUnmatchedTestSpecs() ) { - return 3; + // UnmatchedTestSpecExitCode + return UnmatchedTestSpecExitCode; } if ( totals.testCases.total() == 0 && !m_config->zeroTestsCountAsSuccess() ) { - return 2; + return NoTestsRunExitCode; } if ( totals.testCases.total() > 0 && totals.testCases.total() == totals.testCases.skipped && !m_config->zeroTestsCountAsSuccess() ) { - return 4; + return AllTestsSkippedExitCode; } - // Note that on unices only the lower 8 bits are usually used, clamping - // the return value to 255 prevents false negative when some multiple - // of 256 tests has failed - return (std::min) (MaxExitCode, static_cast(totals.assertions.failed)); + if ( totals.assertions.failed ) { return TestFailureExitCode; } + return 0; + } #if !defined(CATCH_CONFIG_DISABLE_EXCEPTIONS) catch( std::exception& ex ) { Catch::cerr() << ex.what() << '\n' << std::flush; - return MaxExitCode; + return UnspecifiedErrorExitCode; } #endif } @@ -1523,26 +1532,26 @@ namespace Catch { static_assert(sizeof(TestCaseProperties) == sizeof(TCP_underlying_type), "The size of the TestCaseProperties is different from the assumed size"); - TestCaseProperties operator|(TestCaseProperties lhs, TestCaseProperties rhs) { + constexpr TestCaseProperties operator|(TestCaseProperties lhs, TestCaseProperties rhs) { return static_cast( static_cast(lhs) | static_cast(rhs) ); } - TestCaseProperties& operator|=(TestCaseProperties& lhs, TestCaseProperties rhs) { + constexpr TestCaseProperties& operator|=(TestCaseProperties& lhs, TestCaseProperties rhs) { lhs = static_cast( static_cast(lhs) | static_cast(rhs) ); return lhs; } - TestCaseProperties operator&(TestCaseProperties lhs, TestCaseProperties rhs) { + constexpr TestCaseProperties operator&(TestCaseProperties lhs, TestCaseProperties rhs) { return static_cast( static_cast(lhs) & static_cast(rhs) ); } - bool applies(TestCaseProperties tcp) { + constexpr bool applies(TestCaseProperties tcp) { static_assert(static_cast(TestCaseProperties::None) == 0, "TestCaseProperties::None must be equal to 0"); return tcp != TestCaseProperties::None; @@ -1581,13 +1590,15 @@ namespace Catch { return "Anonymous test case " + std::to_string(++counter); } - StringRef extractFilenamePart(StringRef filename) { + constexpr StringRef extractFilenamePart(StringRef filename) { size_t lastDot = filename.size(); while (lastDot > 0 && filename[lastDot - 1] != '.') { --lastDot; } - --lastDot; + // In theory we could have filename without any extension in it + if ( lastDot == 0 ) { return StringRef(); } + --lastDot; size_t nameStart = lastDot; while (nameStart > 0 && filename[nameStart - 1] != '/' && filename[nameStart - 1] != '\\') { --nameStart; @@ -1597,7 +1608,7 @@ namespace Catch { } // Returns the upper bound on size of extra tags ([#file]+[.]) - size_t sizeOfExtraTags(StringRef filepath) { + constexpr size_t sizeOfExtraTags(StringRef filepath) { // [.] is 3, [#] is another 3 const size_t extras = 3 + 3; return extractFilenamePart(filepath).size() + extras; @@ -1758,10 +1769,6 @@ namespace Catch { return lhs.tags < rhs.tags; } - TestCaseInfo const& TestCaseHandle::getTestCaseInfo() const { - return *m_info; - } - } // end namespace Catch @@ -1902,7 +1909,7 @@ namespace Catch { namespace { static auto getCurrentNanosecondsSinceEpoch() -> uint64_t { - return std::chrono::duration_cast(std::chrono::high_resolution_clock::now().time_since_epoch()).count(); + return std::chrono::duration_cast(std::chrono::steady_clock::now().time_since_epoch()).count(); } } // end unnamed namespace @@ -1971,13 +1978,13 @@ namespace Detail { } } // end unnamed namespace - std::string convertIntoString(StringRef string, bool escape_invisibles) { + std::string convertIntoString(StringRef string, bool escapeInvisibles) { std::string ret; // This is enough for the "don't escape invisibles" case, and a good // lower bound on the "escape invisibles" case. ret.reserve(string.size() + 2); - if (!escape_invisibles) { + if (!escapeInvisibles) { ret += '"'; ret += string; ret += '"'; @@ -2055,7 +2062,7 @@ std::string StringMaker::convert(char const* str) { return{ "{null string}" }; } } -std::string StringMaker::convert(char* str) { +std::string StringMaker::convert(char* str) { // NOLINT(readability-non-const-parameter) if (str) { return Detail::convertIntoString( str ); } else { @@ -2152,17 +2159,17 @@ std::string StringMaker::convert(signed char value) { std::string StringMaker::convert(char c) { return ::Catch::Detail::stringify(static_cast(c)); } -std::string StringMaker::convert(unsigned char c) { - return ::Catch::Detail::stringify(static_cast(c)); +std::string StringMaker::convert(unsigned char value) { + return ::Catch::Detail::stringify(static_cast(value)); } -int StringMaker::precision = 5; +int StringMaker::precision = std::numeric_limits::max_digits10; std::string StringMaker::convert(float value) { return Detail::fpToString(value, precision) + 'f'; } -int StringMaker::precision = 10; +int StringMaker::precision = std::numeric_limits::max_digits10; std::string StringMaker::convert(double value) { return Detail::fpToString(value, precision); @@ -2273,7 +2280,7 @@ namespace Catch { } Version const& libraryVersion() { - static Version version( 3, 5, 0, "", 0 ); + static Version version( 3, 7, 1, "", 0 ); return version; } @@ -2415,9 +2422,7 @@ namespace Catch { -#include #include -#include namespace Catch { @@ -2531,8 +2536,8 @@ namespace Catch { void AssertionHandler::handleExpr( ITransientExpression const& expr ) { m_resultCapture.handleExpr( m_assertionInfo, expr, m_reaction ); } - void AssertionHandler::handleMessage(ResultWas::OfType resultType, StringRef message) { - m_resultCapture.handleMessage( m_assertionInfo, resultType, message, m_reaction ); + void AssertionHandler::handleMessage(ResultWas::OfType resultType, std::string&& message) { + m_resultCapture.handleMessage( m_assertionInfo, resultType, CATCH_MOVE(message), m_reaction ); } auto AssertionHandler::allowThrows() const -> bool { @@ -2627,13 +2632,29 @@ namespace { ; } - std::string normaliseOpt( std::string const& optName ) { -#ifdef CATCH_PLATFORM_WINDOWS - if ( optName[0] == '/' ) - return "-" + optName.substr( 1 ); - else + Catch::StringRef normaliseOpt( Catch::StringRef optName ) { + if ( optName[0] == '-' +#if defined(CATCH_PLATFORM_WINDOWS) + || optName[0] == '/' #endif - return optName; + ) { + return optName.substr( 1, optName.size() ); + } + + return optName; + } + + static size_t find_first_separator(Catch::StringRef sr) { + auto is_separator = []( char c ) { + return c == ' ' || c == ':' || c == '='; + }; + size_t pos = 0; + while (pos < sr.size()) { + if (is_separator(sr[pos])) { return pos; } + ++pos; + } + + return Catch::StringRef::npos; } } // namespace @@ -2651,23 +2672,23 @@ namespace Catch { } if ( it != itEnd ) { - auto const& next = *it; + StringRef next = *it; if ( isOptPrefix( next[0] ) ) { - auto delimiterPos = next.find_first_of( " :=" ); - if ( delimiterPos != std::string::npos ) { + auto delimiterPos = find_first_separator(next); + if ( delimiterPos != StringRef::npos ) { m_tokenBuffer.push_back( { TokenType::Option, next.substr( 0, delimiterPos ) } ); m_tokenBuffer.push_back( { TokenType::Argument, - next.substr( delimiterPos + 1 ) } ); + next.substr( delimiterPos + 1, next.size() ) } ); } else { - if ( next[1] != '-' && next.size() > 2 ) { - std::string opt = "- "; + if ( next.size() > 1 && next[1] != '-' && next.size() > 2 ) { + // Combined short args, e.g. "-ab" for "-a -b" for ( size_t i = 1; i < next.size(); ++i ) { - opt[1] = next[i]; m_tokenBuffer.push_back( - { TokenType::Option, opt } ); + { TokenType::Option, + next.substr( i, 1 ) } ); } } else { m_tokenBuffer.push_back( @@ -2727,12 +2748,12 @@ namespace Catch { size_t ParserBase::cardinality() const { return 1; } InternalParseResult ParserBase::parse( Args const& args ) const { - return parse( args.exeName(), TokenStream( args ) ); + return parse( static_cast(args.exeName()), TokenStream( args ) ); } ParseState::ParseState( ParseResultType type, - TokenStream const& remainingTokens ): - m_type( type ), m_remainingTokens( remainingTokens ) {} + TokenStream remainingTokens ): + m_type( type ), m_remainingTokens( CATCH_MOVE(remainingTokens) ) {} ParserResult BoundFlagRef::setFlag( bool flag ) { m_ref = flag; @@ -2750,34 +2771,34 @@ namespace Catch { } // namespace Detail Detail::InternalParseResult Arg::parse(std::string const&, - Detail::TokenStream const& tokens) const { + Detail::TokenStream tokens) const { auto validationResult = validate(); if (!validationResult) return Detail::InternalParseResult(validationResult); - auto remainingTokens = tokens; - auto const& token = *remainingTokens; + auto token = *tokens; if (token.type != Detail::TokenType::Argument) return Detail::InternalParseResult::ok(Detail::ParseState( - ParseResultType::NoMatch, remainingTokens)); + ParseResultType::NoMatch, CATCH_MOVE(tokens))); assert(!m_ref->isFlag()); auto valueRef = static_cast(m_ref.get()); - auto result = valueRef->setValue(remainingTokens->token); - if (!result) - return Detail::InternalParseResult(result); + auto result = valueRef->setValue(static_cast(token.token)); + if ( !result ) + return Detail::InternalParseResult( result ); else - return Detail::InternalParseResult::ok(Detail::ParseState( - ParseResultType::Matched, ++remainingTokens)); + return Detail::InternalParseResult::ok( + Detail::ParseState( ParseResultType::Matched, + CATCH_MOVE( ++tokens ) ) ); } Opt::Opt(bool& ref) : ParserRefImpl(std::make_shared(ref)) {} - std::vector Opt::getHelpColumns() const { - std::ostringstream oss; + Detail::HelpColumns Opt::getHelpColumns() const { + ReusableStringStream oss; bool first = true; for (auto const& opt : m_optNames) { if (first) @@ -2788,10 +2809,10 @@ namespace Catch { } if (!m_hint.empty()) oss << " <" << m_hint << '>'; - return { { oss.str(), m_description } }; + return { oss.str(), m_description }; } - bool Opt::isMatch(std::string const& optToken) const { + bool Opt::isMatch(StringRef optToken) const { auto normalisedToken = normaliseOpt(optToken); for (auto const& name : m_optNames) { if (normaliseOpt(name) == normalisedToken) @@ -2801,15 +2822,14 @@ namespace Catch { } Detail::InternalParseResult Opt::parse(std::string const&, - Detail::TokenStream const& tokens) const { + Detail::TokenStream tokens) const { auto validationResult = validate(); if (!validationResult) return Detail::InternalParseResult(validationResult); - auto remainingTokens = tokens; - if (remainingTokens && - remainingTokens->type == Detail::TokenType::Option) { - auto const& token = *remainingTokens; + if (tokens && + tokens->type == Detail::TokenType::Option) { + auto const& token = *tokens; if (isMatch(token.token)) { if (m_ref->isFlag()) { auto flagRef = @@ -2821,35 +2841,35 @@ namespace Catch { if (result.value() == ParseResultType::ShortCircuitAll) return Detail::InternalParseResult::ok(Detail::ParseState( - result.value(), remainingTokens)); + result.value(), CATCH_MOVE(tokens))); } else { auto valueRef = static_cast( m_ref.get()); - ++remainingTokens; - if (!remainingTokens) + ++tokens; + if (!tokens) return Detail::InternalParseResult::runtimeError( "Expected argument following " + token.token); - auto const& argToken = *remainingTokens; + auto const& argToken = *tokens; if (argToken.type != Detail::TokenType::Argument) return Detail::InternalParseResult::runtimeError( "Expected argument following " + token.token); - const auto result = valueRef->setValue(argToken.token); + const auto result = valueRef->setValue(static_cast(argToken.token)); if (!result) return Detail::InternalParseResult(result); if (result.value() == ParseResultType::ShortCircuitAll) return Detail::InternalParseResult::ok(Detail::ParseState( - result.value(), remainingTokens)); + result.value(), CATCH_MOVE(tokens))); } return Detail::InternalParseResult::ok(Detail::ParseState( - ParseResultType::Matched, ++remainingTokens)); + ParseResultType::Matched, CATCH_MOVE(++tokens))); } } return Detail::InternalParseResult::ok( - Detail::ParseState(ParseResultType::NoMatch, remainingTokens)); + Detail::ParseState(ParseResultType::NoMatch, CATCH_MOVE(tokens))); } Detail::Result Opt::validate() const { @@ -2881,9 +2901,9 @@ namespace Catch { Detail::InternalParseResult ExeName::parse(std::string const&, - Detail::TokenStream const& tokens) const { + Detail::TokenStream tokens) const { return Detail::InternalParseResult::ok( - Detail::ParseState(ParseResultType::NoMatch, tokens)); + Detail::ParseState(ParseResultType::NoMatch, CATCH_MOVE(tokens))); } ParserResult ExeName::set(std::string const& newName) { @@ -2913,9 +2933,9 @@ namespace Catch { std::vector Parser::getHelpColumns() const { std::vector cols; + cols.reserve( m_options.size() ); for ( auto const& o : m_options ) { - auto childCols = o.getHelpColumns(); - cols.insert( cols.end(), childCols.begin(), childCols.end() ); + cols.push_back(o.getHelpColumns()); } return cols; } @@ -2953,12 +2973,12 @@ namespace Catch { optWidth = ( std::min )( optWidth, consoleWidth / 2 ); - for ( auto const& cols : rows ) { - auto row = TextFlow::Column( cols.left ) + for ( auto& cols : rows ) { + auto row = TextFlow::Column( CATCH_MOVE(cols.left) ) .width( optWidth ) .indent( 2 ) + TextFlow::Spacer( 4 ) + - TextFlow::Column( cols.right ) + TextFlow::Column( static_cast(cols.descriptions) ) .width( consoleWidth - 7 - optWidth ); os << row << '\n'; } @@ -2980,7 +3000,7 @@ namespace Catch { Detail::InternalParseResult Parser::parse( std::string const& exeName, - Detail::TokenStream const& tokens ) const { + Detail::TokenStream tokens ) const { struct ParserInfo { ParserBase const* parser = nullptr; @@ -2998,7 +3018,7 @@ namespace Catch { m_exeName.set( exeName ); auto result = Detail::InternalParseResult::ok( - Detail::ParseState( ParseResultType::NoMatch, tokens ) ); + Detail::ParseState( ParseResultType::NoMatch, CATCH_MOVE(tokens) ) ); while ( result.value().remainingTokens() ) { bool tokenParsed = false; @@ -3006,7 +3026,7 @@ namespace Catch { if ( parseInfo.parser->cardinality() == 0 || parseInfo.count < parseInfo.parser->cardinality() ) { result = parseInfo.parser->parse( - exeName, result.value().remainingTokens() ); + exeName, CATCH_MOVE(result).value().remainingTokens() ); if ( !result ) return result; if ( result.value().type() != @@ -3032,7 +3052,7 @@ namespace Catch { Args::Args(int argc, char const* const* argv) : m_exeName(argv[0]), m_args(argv + 1, argv + argc) {} - Args::Args(std::initializer_list args) : + Args::Args(std::initializer_list args) : m_exeName(*args.begin()), m_args(args.begin() + 1, args.end()) {} @@ -3084,7 +3104,7 @@ namespace Catch { line = trim(line); if( !line.empty() && !startsWith( line, '#' ) ) { if( !startsWith( line, '"' ) ) - line = '"' + line + '"'; + line = '"' + CATCH_MOVE(line) + '"'; config.testsOrTags.push_back( line ); config.testsOrTags.emplace_back( "," ); } @@ -3338,8 +3358,8 @@ namespace Catch { ( "split the tests to execute into this many groups" ) | Opt( setShardIndex, "shard index" ) ["--shard-index"] - ( "index of the group of tests to execute (see --shard-count)" ) | - Opt( config.allowZeroTests ) + ( "index of the group of tests to execute (see --shard-count)" ) + | Opt( config.allowZeroTests ) ["--allow-running-no-tests"] ( "Treat 'No tests run' as a success" ) | Arg( config.testsOrTags, "test name|pattern|tags" ) @@ -3565,21 +3585,21 @@ namespace { namespace Catch { - Detail::unique_ptr makeColourImpl( ColourMode implSelection, + Detail::unique_ptr makeColourImpl( ColourMode colourSelection, IStream* stream ) { #if defined( CATCH_CONFIG_COLOUR_WIN32 ) - if ( implSelection == ColourMode::Win32 ) { + if ( colourSelection == ColourMode::Win32 ) { return Detail::make_unique( stream ); } #endif - if ( implSelection == ColourMode::ANSI ) { + if ( colourSelection == ColourMode::ANSI ) { return Detail::make_unique( stream ); } - if ( implSelection == ColourMode::None ) { + if ( colourSelection == ColourMode::None ) { return Detail::make_unique( stream ); } - if ( implSelection == ColourMode::PlatformDefault) { + if ( colourSelection == ColourMode::PlatformDefault) { #if defined( CATCH_CONFIG_COLOUR_WIN32 ) if ( Win32ColourImpl::useImplementationForStream( *stream ) ) { return Detail::make_unique( stream ); @@ -3591,7 +3611,7 @@ namespace Catch { return Detail::make_unique( stream ); } - CATCH_ERROR( "Could not create colour impl for selection " << static_cast(implSelection) ); + CATCH_ERROR( "Could not create colour impl for selection " << static_cast(colourSelection) ); } bool isColourImplAvailable( ColourMode colourSelection ) { @@ -3636,12 +3656,6 @@ namespace Catch { return *Context::currentContext; } - void Context::setResultCapture( IResultCapture* resultCapture ) { - m_resultCapture = resultCapture; - } - - void Context::setConfig( IConfig const* config ) { m_config = config; } - SimplePcg32& sharedRng() { static SimplePcg32 s_rng; return s_rng; @@ -3799,7 +3813,12 @@ namespace Catch { namespace Catch { - ITransientExpression::~ITransientExpression() = default; + void ITransientExpression::streamReconstructedExpression( + std::ostream& os ) const { + // We can't make this function pure virtual to keep ITransientExpression + // constexpr, so we write error message instead + os << "Some class derived from ITransientExpression without overriding streamReconstructedExpression"; + } void formatReconstructedExpression( std::ostream &os, std::string const& lhs, StringRef op, std::string const& rhs ) { if( lhs.size() + rhs.size() < 40 && @@ -4367,7 +4386,6 @@ namespace Detail { CATCH_ENFORCE( !m_ofs.fail(), "Unable to open file: '" << filename << '\'' ); m_ofs << std::unitbuf; } - ~FileStream() override = default; public: // IStream std::ostream& stream() override { return m_ofs; @@ -4382,7 +4400,6 @@ namespace Detail { // Store the streambuf from cout up-front because // cout may get redirected when running tests CoutStream() : m_os( Catch::cout().rdbuf() ) {} - ~CoutStream() override = default; public: // IStream std::ostream& stream() override { return m_os; } @@ -4396,7 +4413,6 @@ namespace Detail { // Store the streambuf from cerr up-front because // cout may get redirected when running tests CerrStream(): m_os( Catch::cerr().rdbuf() ) {} - ~CerrStream() override = default; public: // IStream std::ostream& stream() override { return m_os; } @@ -4414,8 +4430,6 @@ namespace Detail { m_os( m_streamBuf.get() ) {} - ~DebugOutStream() override = default; - public: // IStream std::ostream& stream() override { return m_os; } }; @@ -4470,7 +4484,7 @@ namespace Catch { m_os{ os }, m_indent_level{ indent_level } { m_os << '{'; } - JsonObjectWriter::JsonObjectWriter( JsonObjectWriter&& source ): + JsonObjectWriter::JsonObjectWriter( JsonObjectWriter&& source ) noexcept: m_os{ source.m_os }, m_indent_level{ source.m_indent_level }, m_should_comma{ source.m_should_comma }, @@ -4501,7 +4515,7 @@ namespace Catch { m_os{ os }, m_indent_level{ indent_level } { m_os << '['; } - JsonArrayWriter::JsonArrayWriter( JsonArrayWriter&& source ): + JsonArrayWriter::JsonArrayWriter( JsonArrayWriter&& source ) noexcept: m_os{ source.m_os }, m_indent_level{ source.m_indent_level }, m_should_comma{ source.m_should_comma }, @@ -4641,7 +4655,6 @@ Catch::LeakDetector::~LeakDetector() { - namespace Catch { namespace { @@ -4796,138 +4809,328 @@ namespace Catch { #include #include +#include #include -#if defined(CATCH_CONFIG_NEW_CAPTURE) - #if defined(_MSC_VER) - #include //_dup and _dup2 - #define dup _dup - #define dup2 _dup2 - #define fileno _fileno - #else - #include // dup and dup2 - #endif +#if defined( CATCH_CONFIG_NEW_CAPTURE ) +# if defined( _MSC_VER ) +# include //_dup and _dup2 +# define dup _dup +# define dup2 _dup2 +# define fileno _fileno +# else +# include // dup and dup2 +# endif #endif - namespace Catch { - RedirectedStream::RedirectedStream( std::ostream& originalStream, std::ostream& redirectionStream ) - : m_originalStream( originalStream ), - m_redirectionStream( redirectionStream ), - m_prevBuf( m_originalStream.rdbuf() ) - { - m_originalStream.rdbuf( m_redirectionStream.rdbuf() ); - } + namespace { + //! A no-op implementation, used if no reporter wants output + //! redirection. + class NoopRedirect : public OutputRedirect { + void activateImpl() override {} + void deactivateImpl() override {} + std::string getStdout() override { return {}; } + std::string getStderr() override { return {}; } + void clearBuffers() override {} + }; - RedirectedStream::~RedirectedStream() { - m_originalStream.rdbuf( m_prevBuf ); - } + /** + * Redirects specific stream's rdbuf with another's. + * + * Redirection can be stopped and started on-demand, assumes + * that the underlying stream's rdbuf aren't changed by other + * users. + */ + class RedirectedStreamNew { + std::ostream& m_originalStream; + std::ostream& m_redirectionStream; + std::streambuf* m_prevBuf; + + public: + RedirectedStreamNew( std::ostream& originalStream, + std::ostream& redirectionStream ): + m_originalStream( originalStream ), + m_redirectionStream( redirectionStream ), + m_prevBuf( m_originalStream.rdbuf() ) {} - RedirectedStdOut::RedirectedStdOut() : m_cout( Catch::cout(), m_rss.get() ) {} - auto RedirectedStdOut::str() const -> std::string { return m_rss.str(); } + void startRedirect() { + m_originalStream.rdbuf( m_redirectionStream.rdbuf() ); + } + void stopRedirect() { m_originalStream.rdbuf( m_prevBuf ); } + }; - RedirectedStdErr::RedirectedStdErr() - : m_cerr( Catch::cerr(), m_rss.get() ), - m_clog( Catch::clog(), m_rss.get() ) - {} - auto RedirectedStdErr::str() const -> std::string { return m_rss.str(); } + /** + * Redirects the `std::cout`, `std::cerr`, `std::clog` streams, + * but does not touch the actual `stdout`/`stderr` file descriptors. + */ + class StreamRedirect : public OutputRedirect { + ReusableStringStream m_redirectedOut, m_redirectedErr; + RedirectedStreamNew m_cout, m_cerr, m_clog; - RedirectedStreams::RedirectedStreams(std::string& redirectedCout, std::string& redirectedCerr) - : m_redirectedCout(redirectedCout), - m_redirectedCerr(redirectedCerr) - {} + public: + StreamRedirect(): + m_cout( Catch::cout(), m_redirectedOut.get() ), + m_cerr( Catch::cerr(), m_redirectedErr.get() ), + m_clog( Catch::clog(), m_redirectedErr.get() ) {} + + void activateImpl() override { + m_cout.startRedirect(); + m_cerr.startRedirect(); + m_clog.startRedirect(); + } + void deactivateImpl() override { + m_cout.stopRedirect(); + m_cerr.stopRedirect(); + m_clog.stopRedirect(); + } + std::string getStdout() override { return m_redirectedOut.str(); } + std::string getStderr() override { return m_redirectedErr.str(); } + void clearBuffers() override { + m_redirectedOut.str( "" ); + m_redirectedErr.str( "" ); + } + }; - RedirectedStreams::~RedirectedStreams() { - m_redirectedCout += m_redirectedStdOut.str(); - m_redirectedCerr += m_redirectedStdErr.str(); - } +#if defined( CATCH_CONFIG_NEW_CAPTURE ) -#if defined(CATCH_CONFIG_NEW_CAPTURE) + // Windows's implementation of std::tmpfile is terrible (it tries + // to create a file inside system folder, thus requiring elevated + // privileges for the binary), so we have to use tmpnam(_s) and + // create the file ourselves there. + class TempFile { + public: + TempFile( TempFile const& ) = delete; + TempFile& operator=( TempFile const& ) = delete; + TempFile( TempFile&& ) = delete; + TempFile& operator=( TempFile&& ) = delete; -#if defined(_MSC_VER) - TempFile::TempFile() { - if (tmpnam_s(m_buffer)) { - CATCH_RUNTIME_ERROR("Could not get a temp filename"); - } - if (fopen_s(&m_file, m_buffer, "w+")) { - char buffer[100]; - if (strerror_s(buffer, errno)) { - CATCH_RUNTIME_ERROR("Could not translate errno to a string"); +# if defined( _MSC_VER ) + TempFile() { + if ( tmpnam_s( m_buffer ) ) { + CATCH_RUNTIME_ERROR( "Could not get a temp filename" ); + } + if ( fopen_s( &m_file, m_buffer, "wb+" ) ) { + char buffer[100]; + if ( strerror_s( buffer, errno ) ) { + CATCH_RUNTIME_ERROR( + "Could not translate errno to a string" ); + } + CATCH_RUNTIME_ERROR( "Could not open the temp file: '" + << m_buffer + << "' because: " << buffer ); + } + } +# else + TempFile() { + m_file = std::tmpfile(); + if ( !m_file ) { + CATCH_RUNTIME_ERROR( "Could not create a temp file." ); + } + } +# endif + + ~TempFile() { + // TBD: What to do about errors here? + std::fclose( m_file ); + // We manually create the file on Windows only, on Linux + // it will be autodeleted +# if defined( _MSC_VER ) + std::remove( m_buffer ); +# endif + } + + std::FILE* getFile() { return m_file; } + std::string getContents() { + ReusableStringStream sstr; + constexpr long buffer_size = 100; + char buffer[buffer_size + 1] = {}; + long current_pos = ftell( m_file ); + CATCH_ENFORCE( current_pos >= 0, + "ftell failed, errno: " << errno ); + std::rewind( m_file ); + while ( current_pos > 0 ) { + auto read_characters = + std::fread( buffer, + 1, + std::min( buffer_size, current_pos ), + m_file ); + buffer[read_characters] = '\0'; + sstr << buffer; + current_pos -= static_cast( read_characters ); + } + return sstr.str(); + } + + void clear() { std::rewind( m_file ); } + + private: + std::FILE* m_file = nullptr; + char m_buffer[L_tmpnam] = { 0 }; + }; + + /** + * Redirects the actual `stdout`/`stderr` file descriptors. + * + * Works by replacing the file descriptors numbered 1 and 2 + * with an open temporary file. + */ + class FileRedirect : public OutputRedirect { + TempFile m_outFile, m_errFile; + int m_originalOut = -1; + int m_originalErr = -1; + + // Flushes cout/cerr/clog streams and stdout/stderr FDs + void flushEverything() { + Catch::cout() << std::flush; + fflush( stdout ); + // Since we support overriding these streams, we flush cerr + // even though std::cerr is unbuffered + Catch::cerr() << std::flush; + Catch::clog() << std::flush; + fflush( stderr ); + } + + public: + FileRedirect(): + m_originalOut( dup( fileno( stdout ) ) ), + m_originalErr( dup( fileno( stderr ) ) ) { + CATCH_ENFORCE( m_originalOut >= 0, "Could not dup stdout" ); + CATCH_ENFORCE( m_originalErr >= 0, "Could not dup stderr" ); + } + + std::string getStdout() override { return m_outFile.getContents(); } + std::string getStderr() override { return m_errFile.getContents(); } + void clearBuffers() override { + m_outFile.clear(); + m_errFile.clear(); + } + + void activateImpl() override { + // We flush before starting redirect, to ensure that we do + // not capture the end of message sent before activation. + flushEverything(); + + int ret; + ret = dup2( fileno( m_outFile.getFile() ), fileno( stdout ) ); + CATCH_ENFORCE( ret >= 0, + "dup2 to stdout has failed, errno: " << errno ); + ret = dup2( fileno( m_errFile.getFile() ), fileno( stderr ) ); + CATCH_ENFORCE( ret >= 0, + "dup2 to stderr has failed, errno: " << errno ); + } + void deactivateImpl() override { + // We flush before ending redirect, to ensure that we + // capture all messages sent while the redirect was active. + flushEverything(); + + int ret; + ret = dup2( m_originalOut, fileno( stdout ) ); + CATCH_ENFORCE( + ret >= 0, + "dup2 of original stdout has failed, errno: " << errno ); + ret = dup2( m_originalErr, fileno( stderr ) ); + CATCH_ENFORCE( + ret >= 0, + "dup2 of original stderr has failed, errno: " << errno ); } - CATCH_RUNTIME_ERROR("Could not open the temp file: '" << m_buffer << "' because: " << buffer); + }; + +#endif // CATCH_CONFIG_NEW_CAPTURE + + } // end namespace + + bool isRedirectAvailable( OutputRedirect::Kind kind ) { + switch ( kind ) { + // These two are always available + case OutputRedirect::None: + case OutputRedirect::Streams: + return true; +#if defined( CATCH_CONFIG_NEW_CAPTURE ) + case OutputRedirect::FileDescriptors: + return true; +#endif + default: + return false; } } + + Detail::unique_ptr makeOutputRedirect( bool actual ) { + if ( actual ) { + // TODO: Clean this up later +#if defined( CATCH_CONFIG_NEW_CAPTURE ) + return Detail::make_unique(); #else - TempFile::TempFile() { - m_file = std::tmpfile(); - if (!m_file) { - CATCH_RUNTIME_ERROR("Could not create a temp file."); + return Detail::make_unique(); +#endif + } else { + return Detail::make_unique(); } } -#endif + RedirectGuard scopedActivate( OutputRedirect& redirectImpl ) { + return RedirectGuard( true, redirectImpl ); + } - TempFile::~TempFile() { - // TBD: What to do about errors here? - std::fclose(m_file); - // We manually create the file on Windows only, on Linux - // it will be autodeleted -#if defined(_MSC_VER) - std::remove(m_buffer); -#endif + RedirectGuard scopedDeactivate( OutputRedirect& redirectImpl ) { + return RedirectGuard( false, redirectImpl ); } + OutputRedirect::~OutputRedirect() = default; - FILE* TempFile::getFile() { - return m_file; - } + RedirectGuard::RedirectGuard( bool activate, OutputRedirect& redirectImpl ): + m_redirect( &redirectImpl ), + m_activate( activate ), + m_previouslyActive( redirectImpl.isActive() ) { - std::string TempFile::getContents() { - std::stringstream sstr; - char buffer[100] = {}; - std::rewind(m_file); - while (std::fgets(buffer, sizeof(buffer), m_file)) { - sstr << buffer; - } - return sstr.str(); - } + // Skip cases where there is no actual state change. + if ( m_activate == m_previouslyActive ) { return; } - OutputRedirect::OutputRedirect(std::string& stdout_dest, std::string& stderr_dest) : - m_originalStdout(dup(1)), - m_originalStderr(dup(2)), - m_stdoutDest(stdout_dest), - m_stderrDest(stderr_dest) { - dup2(fileno(m_stdoutFile.getFile()), 1); - dup2(fileno(m_stderrFile.getFile()), 2); + if ( m_activate ) { + m_redirect->activate(); + } else { + m_redirect->deactivate(); + } } - OutputRedirect::~OutputRedirect() { - Catch::cout() << std::flush; - fflush(stdout); - // Since we support overriding these streams, we flush cerr - // even though std::cerr is unbuffered - Catch::cerr() << std::flush; - Catch::clog() << std::flush; - fflush(stderr); + RedirectGuard::~RedirectGuard() noexcept( false ) { + if ( m_moved ) { return; } + // Skip cases where there is no actual state change. + if ( m_activate == m_previouslyActive ) { return; } - dup2(m_originalStdout, 1); - dup2(m_originalStderr, 2); + if ( m_activate ) { + m_redirect->deactivate(); + } else { + m_redirect->activate(); + } + } - m_stdoutDest += m_stdoutFile.getContents(); - m_stderrDest += m_stderrFile.getContents(); + RedirectGuard::RedirectGuard( RedirectGuard&& rhs ) noexcept: + m_redirect( rhs.m_redirect ), + m_activate( rhs.m_activate ), + m_previouslyActive( rhs.m_previouslyActive ), + m_moved( false ) { + rhs.m_moved = true; } -#endif // CATCH_CONFIG_NEW_CAPTURE + RedirectGuard& RedirectGuard::operator=( RedirectGuard&& rhs ) noexcept { + m_redirect = rhs.m_redirect; + m_activate = rhs.m_activate; + m_previouslyActive = rhs.m_previouslyActive; + m_moved = false; + rhs.m_moved = true; + return *this; + } } // namespace Catch -#if defined(CATCH_CONFIG_NEW_CAPTURE) - #if defined(_MSC_VER) - #undef dup - #undef dup2 - #undef fileno - #endif +#if defined( CATCH_CONFIG_NEW_CAPTURE ) +# if defined( _MSC_VER ) +# undef dup +# undef dup2 +# undef fileno +# endif #endif @@ -5281,7 +5484,7 @@ namespace Catch { auto kv = splitKVPair( parts[i] ); auto key = kv.key, value = kv.value; - if ( key.empty() || value.empty() ) { + if ( key.empty() || value.empty() ) { // NOLINT(bugprone-branch-clone) return {}; } else if ( key[0] == 'X' ) { // This is a reporter-specific option, we don't check these @@ -5338,26 +5541,6 @@ ReporterSpec::ReporterSpec( -namespace Catch { - - bool isOk( ResultWas::OfType resultType ) { - return ( resultType & ResultWas::FailureBit ) == 0; - } - bool isJustInfo( int flags ) { - return flags == ResultWas::Info; - } - - ResultDisposition::Flags operator | ( ResultDisposition::Flags lhs, ResultDisposition::Flags rhs ) { - return static_cast( static_cast( lhs ) | static_cast( rhs ) ); - } - - bool shouldContinueOnFailure( int flags ) { return ( flags & ResultDisposition::ContinueOnFailure ) != 0; } - bool shouldSuppressFailure( int flags ) { return ( flags & ResultDisposition::SuppressFail ) != 0; } - -} // end namespace Catch - - - #include #include #include @@ -5429,7 +5612,6 @@ namespace Catch { TrackerContext& ctx, ITracker* parent ): TrackerBase( CATCH_MOVE( nameAndLocation ), ctx, parent ) {} - ~GeneratorTracker() override = default; static GeneratorTracker* acquire( TrackerContext& ctx, @@ -5562,6 +5744,7 @@ namespace Catch { m_config(_config), m_reporter(CATCH_MOVE(reporter)), m_lastAssertionInfo{ StringRef(), SourceLineInfo("",0), StringRef(), ResultDisposition::Normal }, + m_outputRedirect( makeOutputRedirect( m_reporter->getPreferences().shouldRedirectStdOut ) ), m_includeSuccessfulResults( m_config->includeSuccessfulResults() || m_reporter->getPreferences().shouldReportAllAssertions ) { getCurrentMutableContext().setResultCapture( this ); @@ -5577,6 +5760,7 @@ namespace Catch { auto const& testInfo = testCase.getTestCaseInfo(); m_reporter->testCaseStarting(testInfo); + testCase.prepareTestCase(); m_activeTestCase = &testCase; @@ -5627,15 +5811,17 @@ namespace Catch { m_reporter->testCasePartialStarting(testInfo, testRuns); const auto beforeRunTotals = m_totals; - std::string oneRunCout, oneRunCerr; - runCurrentTest(oneRunCout, oneRunCerr); + runCurrentTest(); + std::string oneRunCout = m_outputRedirect->getStdout(); + std::string oneRunCerr = m_outputRedirect->getStderr(); + m_outputRedirect->clearBuffers(); redirectedCout += oneRunCout; redirectedCerr += oneRunCerr; const auto singleRunTotals = m_totals.delta(beforeRunTotals); auto statsForOneRun = TestCaseStats(testInfo, singleRunTotals, CATCH_MOVE(oneRunCout), CATCH_MOVE(oneRunCerr), aborting()); - m_reporter->testCasePartialEnded(statsForOneRun, testRuns); + ++testRuns; } while (!m_testCaseTracker->isSuccessfullyCompleted() && !aborting()); @@ -5646,6 +5832,7 @@ namespace Catch { deltaTotals.testCases.failed++; } m_totals.testCases += deltaTotals.testCases; + testCase.tearDownTestCase(); m_reporter->testCaseEnded(TestCaseStats(testInfo, deltaTotals, CATCH_MOVE(redirectedCout), @@ -5679,7 +5866,10 @@ namespace Catch { m_lastAssertionPassed = true; } - m_reporter->assertionEnded(AssertionStats(result, m_messages, m_totals)); + { + auto _ = scopedDeactivate( *m_outputRedirect ); + m_reporter->assertionEnded( AssertionStats( result, m_messages, m_totals ) ); + } if ( result.getResultType() != ResultWas::Warning ) { m_messageScopes.clear(); @@ -5696,6 +5886,7 @@ namespace Catch { } void RunContext::notifyAssertionStarted( AssertionInfo const& info ) { + auto _ = scopedDeactivate( *m_outputRedirect ); m_reporter->assertionStarting( info ); } @@ -5714,7 +5905,10 @@ namespace Catch { SectionInfo sectionInfo( sectionLineInfo, static_cast(sectionName) ); m_lastAssertionInfo.lineInfo = sectionInfo.lineInfo; - m_reporter->sectionStarting(sectionInfo); + { + auto _ = scopedDeactivate( *m_outputRedirect ); + m_reporter->sectionStarting( sectionInfo ); + } assertions = m_totals.assertions; @@ -5774,7 +5968,15 @@ namespace Catch { m_activeSections.pop_back(); } - m_reporter->sectionEnded(SectionStats(CATCH_MOVE(endInfo.sectionInfo), assertions, endInfo.durationInSeconds, missingAssertions)); + { + auto _ = scopedDeactivate( *m_outputRedirect ); + m_reporter->sectionEnded( + SectionStats( CATCH_MOVE( endInfo.sectionInfo ), + assertions, + endInfo.durationInSeconds, + missingAssertions ) ); + } + m_messages.clear(); m_messageScopes.clear(); } @@ -5791,15 +5993,19 @@ namespace Catch { } void RunContext::benchmarkPreparing( StringRef name ) { - m_reporter->benchmarkPreparing(name); + auto _ = scopedDeactivate( *m_outputRedirect ); + m_reporter->benchmarkPreparing( name ); } void RunContext::benchmarkStarting( BenchmarkInfo const& info ) { + auto _ = scopedDeactivate( *m_outputRedirect ); m_reporter->benchmarkStarting( info ); } void RunContext::benchmarkEnded( BenchmarkStats<> const& stats ) { + auto _ = scopedDeactivate( *m_outputRedirect ); m_reporter->benchmarkEnded( stats ); } void RunContext::benchmarkFailed( StringRef error ) { + auto _ = scopedDeactivate( *m_outputRedirect ); m_reporter->benchmarkFailed( error ); } @@ -5830,8 +6036,13 @@ namespace Catch { } void RunContext::handleFatalErrorCondition( StringRef message ) { + // TODO: scoped deactivate here? Just give up and do best effort? + // the deactivation can break things further, OTOH so can the + // capture + auto _ = scopedDeactivate( *m_outputRedirect ); + // First notify reporter that bad things happened - m_reporter->fatalErrorEncountered(message); + m_reporter->fatalErrorEncountered( message ); // Don't rebuild the result -- the stringification itself can cause more fatal errors // Instead, fake a result data. @@ -5842,6 +6053,13 @@ namespace Catch { assertionEnded(CATCH_MOVE(result) ); resetAssertionInfo(); + // Best effort cleanup for sections that have not been destructed yet + // Since this is a fatal error, we have not had and won't have the opportunity to destruct them properly + while (!m_activeSections.empty()) { + auto nl = m_activeSections.back()->nameAndLocation(); + SectionEndInfo endInfo{ SectionInfo(CATCH_MOVE(nl.location), CATCH_MOVE(nl.name)), {}, 0.0 }; + sectionEndedEarly(CATCH_MOVE(endInfo)); + } handleUnfinishedSections(); // Recreate section for test case (as we will lose the one that was in scope) @@ -5851,7 +6069,7 @@ namespace Catch { Counts assertions; assertions.failed = 1; SectionStats testCaseSectionStats(CATCH_MOVE(testCaseSection), assertions, 0, false); - m_reporter->sectionEnded(testCaseSectionStats); + m_reporter->sectionEnded( testCaseSectionStats ); auto const& testInfo = m_activeTestCase->getTestCaseInfo(); @@ -5882,7 +6100,7 @@ namespace Catch { return m_totals.assertions.failed >= static_cast(m_config->abortAfter()); } - void RunContext::runCurrentTest(std::string & redirectedCout, std::string & redirectedCerr) { + void RunContext::runCurrentTest() { auto const& testCaseInfo = m_activeTestCase->getTestCaseInfo(); SectionInfo testCaseSection(testCaseInfo.lineInfo, testCaseInfo.name); m_reporter->sectionStarting(testCaseSection); @@ -5893,18 +6111,8 @@ namespace Catch { Timer timer; CATCH_TRY { - if (m_reporter->getPreferences().shouldRedirectStdOut) { -#if !defined(CATCH_CONFIG_EXPERIMENTAL_REDIRECT) - RedirectedStreams redirectedStreams(redirectedCout, redirectedCerr); - - timer.start(); - invokeActiveTestCase(); -#else - OutputRedirect r(redirectedCout, redirectedCerr); - timer.start(); - invokeActiveTestCase(); -#endif - } else { + { + auto _ = scopedActivate( *m_outputRedirect ); timer.start(); invokeActiveTestCase(); } @@ -5949,11 +6157,12 @@ namespace Catch { void RunContext::handleUnfinishedSections() { // If sections ended prematurely due to an exception we stored their // infos here so we can tear them down outside the unwind process. - for (auto it = m_unfinishedSections.rbegin(), - itEnd = m_unfinishedSections.rend(); - it != itEnd; - ++it) - sectionEnded(CATCH_MOVE(*it)); + for ( auto it = m_unfinishedSections.rbegin(), + itEnd = m_unfinishedSections.rend(); + it != itEnd; + ++it ) { + sectionEnded( CATCH_MOVE( *it ) ); + } m_unfinishedSections.clear(); } @@ -5997,13 +6206,13 @@ namespace Catch { void RunContext::handleMessage( AssertionInfo const& info, ResultWas::OfType resultType, - StringRef message, + std::string&& message, AssertionReaction& reaction ) { m_lastAssertionInfo = info; AssertionResultData data( resultType, LazyExpression( false ) ); - data.message = static_cast(message); + data.message = CATCH_MOVE( message ); AssertionResult assertionResult{ m_lastAssertionInfo, CATCH_MOVE( data ) }; @@ -6296,17 +6505,29 @@ namespace Catch { } bool replaceInPlace( std::string& str, std::string const& replaceThis, std::string const& withThis ) { - bool replaced = false; std::size_t i = str.find( replaceThis ); - while( i != std::string::npos ) { - replaced = true; - str = str.substr( 0, i ) + withThis + str.substr( i+replaceThis.size() ); - if( i < str.size()-withThis.size() ) - i = str.find( replaceThis, i+withThis.size() ); + if (i == std::string::npos) { + return false; + } + std::size_t copyBegin = 0; + std::string origStr = CATCH_MOVE(str); + str.clear(); + // There is at least one replacement, so reserve with the best guess + // we can make without actually counting the number of occurences. + str.reserve(origStr.size() - replaceThis.size() + withThis.size()); + do { + str.append(origStr, copyBegin, i-copyBegin ); + str += withThis; + copyBegin = i + replaceThis.size(); + if( copyBegin < origStr.size() ) + i = origStr.find( replaceThis, copyBegin ); else i = std::string::npos; + } while( i != std::string::npos ); + if ( copyBegin < origStr.size() ) { + str.append(origStr, copyBegin, origStr.size() ); } - return replaced; + return true; } std::vector splitStringRef( StringRef str, char delimiter ) { @@ -6527,7 +6748,6 @@ namespace Catch { return sorted; } case TestRunOrder::Randomized: { - seedRng(config); using TestWithHash = std::pair; TestCaseInfoHasher h{ config.rngSeed() }; @@ -6581,6 +6801,8 @@ namespace Catch { return getRegistryHub().getTestCaseRegistry().getAllTestsSorted( config ); } + TestRegistry::~TestRegistry() = default; + void TestRegistry::registerTest(Detail::unique_ptr testInfo, Detail::unique_ptr testInvoker) { m_handles.emplace_back(testInfo.get(), testInvoker.get()); m_viewed_test_infos.push_back(testInfo.get()); @@ -6867,6 +7089,8 @@ namespace Catch { #include namespace Catch { + void ITestInvoker::prepareTestCase() {} + void ITestInvoker::tearDownTestCase() {} ITestInvoker::~ITestInvoker() = default; namespace { @@ -6903,7 +7127,7 @@ namespace Catch { TestType m_testAsFunction; public: - TestInvokerAsFunction( TestType testAsFunction ) noexcept: + constexpr TestInvokerAsFunction( TestType testAsFunction ) noexcept: m_testAsFunction( testAsFunction ) {} void invoke() const override { m_testAsFunction(); } @@ -7183,117 +7407,228 @@ namespace { return std::memchr( chars, c, sizeof( chars ) - 1 ) != nullptr; } - bool isBoundary( std::string const& line, size_t at ) { - assert( at > 0 ); - assert( at <= line.size() ); - - return at == line.size() || - ( isWhitespace( line[at] ) && !isWhitespace( line[at - 1] ) ) || - isBreakableBefore( line[at] ) || - isBreakableAfter( line[at - 1] ); - } - } // namespace namespace Catch { namespace TextFlow { + void AnsiSkippingString::preprocessString() { + for ( auto it = m_string.begin(); it != m_string.end(); ) { + // try to read through an ansi sequence + while ( it != m_string.end() && *it == '\033' && + it + 1 != m_string.end() && *( it + 1 ) == '[' ) { + auto cursor = it + 2; + while ( cursor != m_string.end() && + ( isdigit( *cursor ) || *cursor == ';' ) ) { + ++cursor; + } + if ( cursor == m_string.end() || *cursor != 'm' ) { + break; + } + // 'm' -> 0xff + *cursor = AnsiSkippingString::sentinel; + // if we've read an ansi sequence, set the iterator and + // return to the top of the loop + it = cursor + 1; + } + if ( it != m_string.end() ) { + ++m_size; + ++it; + } + } + } + + AnsiSkippingString::AnsiSkippingString( std::string const& text ): + m_string( text ) { + preprocessString(); + } + + AnsiSkippingString::AnsiSkippingString( std::string&& text ): + m_string( CATCH_MOVE( text ) ) { + preprocessString(); + } + + AnsiSkippingString::const_iterator AnsiSkippingString::begin() const { + return const_iterator( m_string ); + } + + AnsiSkippingString::const_iterator AnsiSkippingString::end() const { + return const_iterator( m_string, const_iterator::EndTag{} ); + } + + std::string AnsiSkippingString::substring( const_iterator begin, + const_iterator end ) const { + // There's one caveat here to an otherwise simple substring: when + // making a begin iterator we might have skipped ansi sequences at + // the start. If `begin` here is a begin iterator, skipped over + // initial ansi sequences, we'll use the true beginning of the + // string. Lastly: We need to transform any chars we replaced with + // 0xff back to 'm' + auto str = std::string( begin == this->begin() ? m_string.begin() + : begin.m_it, + end.m_it ); + std::transform( str.begin(), str.end(), str.begin(), []( char c ) { + return c == AnsiSkippingString::sentinel ? 'm' : c; + } ); + return str; + } + + void AnsiSkippingString::const_iterator::tryParseAnsiEscapes() { + // check if we've landed on an ansi sequence, and if so read through + // it + while ( m_it != m_string->end() && *m_it == '\033' && + m_it + 1 != m_string->end() && *( m_it + 1 ) == '[' ) { + auto cursor = m_it + 2; + while ( cursor != m_string->end() && + ( isdigit( *cursor ) || *cursor == ';' ) ) { + ++cursor; + } + if ( cursor == m_string->end() || + *cursor != AnsiSkippingString::sentinel ) { + break; + } + // if we've read an ansi sequence, set the iterator and + // return to the top of the loop + m_it = cursor + 1; + } + } + + void AnsiSkippingString::const_iterator::advance() { + assert( m_it != m_string->end() ); + m_it++; + tryParseAnsiEscapes(); + } + + void AnsiSkippingString::const_iterator::unadvance() { + assert( m_it != m_string->begin() ); + m_it--; + // if *m_it is 0xff, scan back to the \033 and then m_it-- once more + // (and repeat check) + while ( *m_it == AnsiSkippingString::sentinel ) { + while ( *m_it != '\033' ) { + assert( m_it != m_string->begin() ); + m_it--; + } + // if this happens, we must have been a begin iterator that had + // skipped over ansi sequences at the start of a string + assert( m_it != m_string->begin() ); + assert( *m_it == '\033' ); + m_it--; + } + } + + static bool isBoundary( AnsiSkippingString const& line, + AnsiSkippingString::const_iterator it ) { + return it == line.end() || + ( isWhitespace( *it ) && + !isWhitespace( *it.oneBefore() ) ) || + isBreakableBefore( *it ) || + isBreakableAfter( *it.oneBefore() ); + } void Column::const_iterator::calcLength() { m_addHyphen = false; m_parsedTo = m_lineStart; + AnsiSkippingString const& current_line = m_column.m_string; - std::string const& current_line = m_column.m_string; - if ( current_line[m_lineStart] == '\n' ) { - ++m_parsedTo; + if ( m_parsedTo == current_line.end() ) { + m_lineEnd = m_parsedTo; + return; } + assert( m_lineStart != current_line.end() ); + if ( *m_lineStart == '\n' ) { ++m_parsedTo; } + const auto maxLineLength = m_column.m_width - indentSize(); - const auto maxParseTo = std::min(current_line.size(), m_lineStart + maxLineLength); - while ( m_parsedTo < maxParseTo && - current_line[m_parsedTo] != '\n' ) { + std::size_t lineLength = 0; + while ( m_parsedTo != current_line.end() && + lineLength < maxLineLength && *m_parsedTo != '\n' ) { ++m_parsedTo; + ++lineLength; } // If we encountered a newline before the column is filled, // then we linebreak at the newline and consider this line // finished. - if ( m_parsedTo < m_lineStart + maxLineLength ) { - m_lineLength = m_parsedTo - m_lineStart; + if ( lineLength < maxLineLength ) { + m_lineEnd = m_parsedTo; } else { // Look for a natural linebreak boundary in the column // (We look from the end, so that the first found boundary is // the right one) - size_t newLineLength = maxLineLength; - while ( newLineLength > 0 && !isBoundary( current_line, m_lineStart + newLineLength ) ) { - --newLineLength; + m_lineEnd = m_parsedTo; + while ( lineLength > 0 && + !isBoundary( current_line, m_lineEnd ) ) { + --lineLength; + --m_lineEnd; } - while ( newLineLength > 0 && - isWhitespace( current_line[m_lineStart + newLineLength - 1] ) ) { - --newLineLength; + while ( lineLength > 0 && + isWhitespace( *m_lineEnd.oneBefore() ) ) { + --lineLength; + --m_lineEnd; } - // If we found one, then that is where we linebreak - if ( newLineLength > 0 ) { - m_lineLength = newLineLength; - } else { - // Otherwise we have to split text with a hyphen + // If we found one, then that is where we linebreak, otherwise + // we have to split text with a hyphen + if ( lineLength == 0 ) { m_addHyphen = true; - m_lineLength = maxLineLength - 1; + m_lineEnd = m_parsedTo.oneBefore(); } } } size_t Column::const_iterator::indentSize() const { - auto initial = - m_lineStart == 0 ? m_column.m_initialIndent : std::string::npos; + auto initial = m_lineStart == m_column.m_string.begin() + ? m_column.m_initialIndent + : std::string::npos; return initial == std::string::npos ? m_column.m_indent : initial; } - std::string - Column::const_iterator::addIndentAndSuffix( size_t position, - size_t length ) const { + std::string Column::const_iterator::addIndentAndSuffix( + AnsiSkippingString::const_iterator start, + AnsiSkippingString::const_iterator end ) const { std::string ret; const auto desired_indent = indentSize(); - ret.reserve( desired_indent + length + m_addHyphen ); + // ret.reserve( desired_indent + (end - start) + m_addHyphen ); ret.append( desired_indent, ' ' ); - ret.append( m_column.m_string, position, length ); - if ( m_addHyphen ) { - ret.push_back( '-' ); - } + // ret.append( start, end ); + ret += m_column.m_string.substring( start, end ); + if ( m_addHyphen ) { ret.push_back( '-' ); } return ret; } - Column::const_iterator::const_iterator( Column const& column ): m_column( column ) { + Column::const_iterator::const_iterator( Column const& column ): + m_column( column ), + m_lineStart( column.m_string.begin() ), + m_lineEnd( column.m_string.begin() ), + m_parsedTo( column.m_string.begin() ) { assert( m_column.m_width > m_column.m_indent ); assert( m_column.m_initialIndent == std::string::npos || m_column.m_width > m_column.m_initialIndent ); calcLength(); - if ( m_lineLength == 0 ) { - m_lineStart = m_column.m_string.size(); + if ( m_lineStart == m_lineEnd ) { + m_lineStart = m_column.m_string.end(); } } std::string Column::const_iterator::operator*() const { assert( m_lineStart <= m_parsedTo ); - return addIndentAndSuffix( m_lineStart, m_lineLength ); + return addIndentAndSuffix( m_lineStart, m_lineEnd ); } Column::const_iterator& Column::const_iterator::operator++() { - m_lineStart += m_lineLength; - std::string const& current_line = m_column.m_string; - if ( m_lineStart < current_line.size() && current_line[m_lineStart] == '\n' ) { - m_lineStart += 1; + m_lineStart = m_lineEnd; + AnsiSkippingString const& current_line = m_column.m_string; + if ( m_lineStart != current_line.end() && *m_lineStart == '\n' ) { + m_lineStart++; } else { - while ( m_lineStart < current_line.size() && - isWhitespace( current_line[m_lineStart] ) ) { + while ( m_lineStart != current_line.end() && + isWhitespace( *m_lineStart ) ) { ++m_lineStart; } } - if ( m_lineStart != current_line.size() ) { - calcLength(); - } + if ( m_lineStart != current_line.end() ) { calcLength(); } return *this; } @@ -7390,23 +7725,36 @@ namespace Catch { return os; } - Columns Column::operator+( Column const& other ) { + Columns operator+( Column const& lhs, Column const& rhs ) { Columns cols; - cols += *this; - cols += other; + cols += lhs; + cols += rhs; return cols; } - - Columns& Columns::operator+=( Column const& col ) { - m_columns.push_back( col ); - return *this; + Columns operator+( Column&& lhs, Column&& rhs ) { + Columns cols; + cols += CATCH_MOVE( lhs ); + cols += CATCH_MOVE( rhs ); + return cols; } - Columns Columns::operator+( Column const& col ) { - Columns combined = *this; - combined += col; + Columns& operator+=( Columns& lhs, Column const& rhs ) { + lhs.m_columns.push_back( rhs ); + return lhs; + } + Columns& operator+=( Columns& lhs, Column&& rhs ) { + lhs.m_columns.push_back( CATCH_MOVE( rhs ) ); + return lhs; + } + Columns operator+( Columns const& lhs, Column const& rhs ) { + auto combined( lhs ); + combined += rhs; return combined; } + Columns operator+( Columns&& lhs, Column&& rhs ) { + lhs += CATCH_MOVE( rhs ); + return CATCH_MOVE( lhs ); + } } // namespace TextFlow } // namespace Catch @@ -7514,36 +7862,16 @@ namespace { os.flags(f); } - bool shouldNewline(XmlFormatting fmt) { + constexpr bool shouldNewline(XmlFormatting fmt) { return !!(static_cast>(fmt & XmlFormatting::Newline)); } - bool shouldIndent(XmlFormatting fmt) { + constexpr bool shouldIndent(XmlFormatting fmt) { return !!(static_cast>(fmt & XmlFormatting::Indent)); } } // anonymous namespace - XmlFormatting operator | (XmlFormatting lhs, XmlFormatting rhs) { - return static_cast( - static_cast>(lhs) | - static_cast>(rhs) - ); - } - - XmlFormatting operator & (XmlFormatting lhs, XmlFormatting rhs) { - return static_cast( - static_cast>(lhs) & - static_cast>(rhs) - ); - } - - - XmlEncode::XmlEncode( StringRef str, ForWhat forWhat ) - : m_str( str ), - m_forWhat( forWhat ) - {} - void XmlEncode::encodeTo( std::ostream& os ) const { // Apostrophe escaping not necessary if we always use " to write attributes // (see: http://www.w3.org/TR/xml/#syntax) @@ -8040,7 +8368,7 @@ namespace Detail { std::string WithinRelMatcher::describe() const { Catch::ReusableStringStream sstr; - sstr << "and " << m_target << " are within " << m_epsilon * 100. << "% of each other"; + sstr << "and " << ::Catch::Detail::stringify(m_target) << " are within " << m_epsilon * 100. << "% of each other"; return sstr.str(); } @@ -8775,13 +9103,6 @@ findMax( std::size_t& i, std::size_t& j, std::size_t& k, std::size_t& l ) { return l; } -enum class Justification { Left, Right }; - -struct ColumnInfo { - std::string name; - std::size_t width; - Justification justification; -}; struct ColumnBreak {}; struct RowBreak {}; struct OutputFlush {}; @@ -8859,6 +9180,14 @@ class Duration { }; } // end anon namespace +enum class Justification { Left, Right }; + +struct ColumnInfo { + std::string name; + std::size_t width; + Justification justification; +}; + class TablePrinter { std::ostream& m_os; std::vector m_columnInfos; @@ -8881,11 +9210,10 @@ class TablePrinter { *this << RowBreak(); TextFlow::Columns headerCols; - auto spacer = TextFlow::Spacer(2); for (auto const& info : m_columnInfos) { assert(info.width > 2); headerCols += TextFlow::Column(info.name).width(info.width - 2); - headerCols += spacer; + headerCols += TextFlow::Spacer( 2 ); } m_os << headerCols << '\n'; @@ -9086,8 +9414,8 @@ void ConsoleReporter::testRunEnded(TestRunStats const& _testRunStats) { m_stream << '\n' << std::flush; StreamingReporterBase::testRunEnded(_testRunStats); } -void ConsoleReporter::testRunStarting(TestRunInfo const& _testInfo) { - StreamingReporterBase::testRunStarting(_testInfo); +void ConsoleReporter::testRunStarting(TestRunInfo const& _testRunInfo) { + StreamingReporterBase::testRunStarting(_testRunInfo); if ( m_config->testSpec().hasFilters() ) { m_stream << m_colour->guardColour( Colour::BrightYellow ) << "Filters: " << m_config->testSpec() << '\n'; @@ -9240,8 +9568,7 @@ namespace Catch { namespace { struct BySectionInfo { BySectionInfo( SectionInfo const& other ): m_other( other ) {} - BySectionInfo( BySectionInfo const& other ): - m_other( other.m_other ) {} + BySectionInfo( BySectionInfo const& other ) = default; bool operator()( Detail::unique_ptr const& node ) const { @@ -9866,8 +10193,8 @@ namespace Catch { return "Outputs listings as JSON. Test listing is Work-in-Progress!"; } - void JsonReporter::testRunStarting( TestRunInfo const& testInfo ) { - StreamingReporterBase::testRunStarting( testInfo ); + void JsonReporter::testRunStarting( TestRunInfo const& runInfo ) { + StreamingReporterBase::testRunStarting( runInfo ); endListing(); assert( isInside( Writer::Object ) ); @@ -10165,7 +10492,7 @@ namespace Catch { static void normalizeNamespaceMarkers(std::string& str) { std::size_t pos = str.find( "::" ); - while ( pos != str.npos ) { + while ( pos != std::string::npos ) { str.replace( pos, 2, "." ); pos += 1; pos = str.find( "::", pos ); @@ -10179,7 +10506,7 @@ namespace Catch { xml( m_stream ) { m_preferences.shouldRedirectStdOut = true; - m_preferences.shouldReportAllAssertions = true; + m_preferences.shouldReportAllAssertions = false; m_shouldStoreSuccesfulAssertions = false; } @@ -10289,7 +10616,7 @@ namespace Catch { if( !rootName.empty() ) name = rootName + '/' + name; - if( sectionNode.hasAnyAssertions() + if ( sectionNode.stats.assertions.total() > 0 || !sectionNode.stdOut.empty() || !sectionNode.stdErr.empty() ) { XmlWriter::ScopedElement e = xml.scopedElement( "testcase" ); @@ -10677,9 +11004,9 @@ namespace Catch { if (!rootName.empty()) name = rootName + '/' + name; - if ( sectionNode.hasAnyAssertions() + if ( sectionNode.stats.assertions.total() > 0 || !sectionNode.stdOut.empty() - || !sectionNode.stdErr.empty() ) { + || !sectionNode.stdErr.empty() ) { XmlWriter::ScopedElement e = xml.scopedElement("testCase"); xml.writeAttribute("name"_sr, name); xml.writeAttribute("duration"_sr, static_cast(sectionNode.stats.durationInSeconds * 1000)); diff --git a/extras/catch_amalgamated.hpp b/extras/catch_amalgamated.hpp index bec588d4fe..b7c768b8d5 100644 --- a/extras/catch_amalgamated.hpp +++ b/extras/catch_amalgamated.hpp @@ -6,8 +6,8 @@ // SPDX-License-Identifier: BSL-1.0 -// Catch v3.5.0 -// Generated: 2023-12-11 00:51:06.770598 +// Catch v3.7.1 +// Generated: 2024-09-17 10:36:40.974985 // ---------------------------------------------------------- // This file is an amalgamation of multiple different files. // You probably shouldn't edit it directly. @@ -87,6 +87,9 @@ // See e.g.: // https://opensource.apple.com/source/CarbonHeaders/CarbonHeaders-18.1/TargetConditionals.h.auto.html #ifdef __APPLE__ +# ifndef __has_extension +# define __has_extension(x) 0 +# endif # include # if (defined(TARGET_OS_OSX) && TARGET_OS_OSX == 1) || \ (defined(TARGET_OS_MAC) && TARGET_OS_MAC == 1) @@ -114,14 +117,14 @@ #ifdef __cplusplus -# if (__cplusplus >= 201402L) || (defined(_MSVC_LANG) && _MSVC_LANG >= 201402L) -# define CATCH_CPP14_OR_GREATER -# endif - # if (__cplusplus >= 201703L) || (defined(_MSVC_LANG) && _MSVC_LANG >= 201703L) # define CATCH_CPP17_OR_GREATER # endif +# if (__cplusplus >= 202002L) || (defined(_MSVC_LANG) && _MSVC_LANG >= 202002L) +# define CATCH_CPP20_OR_GREATER +# endif + #endif // Only GCC compiler should be used in this block, so other compilers trying to @@ -552,10 +555,15 @@ namespace Catch { friend void cleanUpContext(); public: - IResultCapture* getResultCapture() const { return m_resultCapture; } - IConfig const* getConfig() const { return m_config; } - void setResultCapture( IResultCapture* resultCapture ); - void setConfig( IConfig const* config ); + constexpr IResultCapture* getResultCapture() const { + return m_resultCapture; + } + constexpr IConfig const* getConfig() const { return m_config; } + constexpr void setResultCapture( IResultCapture* resultCapture ) { + m_resultCapture = resultCapture; + } + constexpr void setConfig( IConfig const* config ) { m_config = config; } + }; Context& getCurrentMutableContext(); @@ -666,7 +674,6 @@ namespace Catch { #define CATCH_INTERFACES_CAPTURE_HPP_INCLUDED #include -#include @@ -690,6 +697,8 @@ namespace Catch { using size_type = std::size_t; using const_iterator = const char*; + static constexpr size_type npos{ static_cast( -1 ) }; + private: static constexpr char const* const s_empty = ""; @@ -740,7 +749,7 @@ namespace Catch { } // Returns a substring of [start, start + length). - // If start + length > size(), then the substring is [start, start + size()). + // If start + length > size(), then the substring is [start, size()). // If start > size(), then the substring is empty. constexpr StringRef substr(size_type start, size_type length) const noexcept { if (start < m_size) { @@ -760,8 +769,8 @@ namespace Catch { constexpr const_iterator end() const { return m_start + m_size; } - friend std::string& operator += (std::string& lhs, StringRef sr); - friend std::ostream& operator << (std::ostream& os, StringRef sr); + friend std::string& operator += (std::string& lhs, StringRef rhs); + friend std::ostream& operator << (std::ostream& os, StringRef str); friend std::string operator+(StringRef lhs, StringRef rhs); /** @@ -814,8 +823,10 @@ namespace Catch { }; }; - bool isOk( ResultWas::OfType resultType ); - bool isJustInfo( int flags ); + constexpr bool isOk( ResultWas::OfType resultType ) { + return ( resultType & ResultWas::FailureBit ) == 0; + } + constexpr bool isJustInfo( int flags ) { return flags == ResultWas::Info; } // ResultDisposition::Flags enum @@ -827,11 +838,18 @@ namespace Catch { SuppressFail = 0x08 // Failures are reported but do not fail the test }; }; - ResultDisposition::Flags operator | ( ResultDisposition::Flags lhs, ResultDisposition::Flags rhs ); + constexpr ResultDisposition::Flags operator|( ResultDisposition::Flags lhs, + ResultDisposition::Flags rhs ) { + return static_cast( static_cast( lhs ) | + static_cast( rhs ) ); + } - bool shouldContinueOnFailure( int flags ); - inline bool isFalseTest( int flags ) { return ( flags & ResultDisposition::FalseTest ) != 0; } - bool shouldSuppressFailure( int flags ); + constexpr bool isFalseTest( int flags ) { + return ( flags & ResultDisposition::FalseTest ) != 0; + } + constexpr bool shouldSuppressFailure( int flags ) { + return ( flags & ResultDisposition::SuppressFail ) != 0; + } } // end namespace Catch @@ -1049,7 +1067,7 @@ namespace Catch { virtual void handleMessage ( AssertionInfo const& info, ResultWas::OfType resultType, - StringRef message, + std::string&& message, AssertionReaction& reaction ) = 0; virtual void handleUnexpectedExceptionNotThrown ( AssertionInfo const& info, @@ -1297,7 +1315,7 @@ namespace Catch { int high_mild = 0; // 1.5 to 3 times IQR above Q3 int high_severe = 0; // more than 3 times IQR above Q3 - int total() const { + constexpr int total() const { return low_severe + low_mild + high_mild + high_severe; } }; @@ -1579,22 +1597,17 @@ namespace Catch { private: struct callable { virtual void call(Chronometer meter) const = 0; - virtual Catch::Detail::unique_ptr clone() const = 0; virtual ~callable(); // = default; callable() = default; - callable(callable const&) = default; - callable& operator=(callable const&) = default; + callable(callable&&) = default; + callable& operator=(callable&&) = default; }; template struct model : public callable { model(Fun&& fun_) : fun(CATCH_MOVE(fun_)) {} model(Fun const& fun_) : fun(fun_) {} - Catch::Detail::unique_ptr clone() const override { - return Catch::Detail::make_unique>( *this ); - } - void call(Chronometer meter) const override { call(meter, is_callable()); } @@ -1608,14 +1621,8 @@ namespace Catch { Fun fun; }; - struct do_nothing { void operator()() const {} }; - - template - BenchmarkFunction(model* c) : f(c) {} - public: - BenchmarkFunction() - : f(new model{ {} }) {} + BenchmarkFunction(); template ::value, int> = 0> @@ -1625,20 +1632,12 @@ namespace Catch { BenchmarkFunction( BenchmarkFunction&& that ) noexcept: f( CATCH_MOVE( that.f ) ) {} - BenchmarkFunction(BenchmarkFunction const& that) - : f(that.f->clone()) {} - BenchmarkFunction& operator=( BenchmarkFunction&& that ) noexcept { f = CATCH_MOVE( that.f ); return *this; } - BenchmarkFunction& operator=(BenchmarkFunction const& that) { - f = that.f->clone(); - return *this; - } - void operator()(Chronometer meter) const { f->call(meter); } private: @@ -1775,7 +1774,7 @@ namespace Catch { template TimingOf measure(Fun&& fun, Args&&... args) { auto start = Clock::now(); - auto&& r = Detail::complete_invoke(fun, CATCH_FORWARD(args)...); + auto&& r = Detail::complete_invoke(CATCH_FORWARD(fun), CATCH_FORWARD(args)...); auto end = Clock::now(); auto delta = end - start; return { delta, CATCH_FORWARD(r), 1 }; @@ -1941,15 +1940,17 @@ namespace Catch { namespace Detail { template std::vector resolution(int k) { - std::vector> times; - times.reserve(static_cast(k + 1)); - for ( int i = 0; i < k + 1; ++i ) { - times.push_back( Clock::now() ); + const size_t points = static_cast( k + 1 ); + // To avoid overhead from the branch inside vector::push_back, + // we allocate them all and then overwrite. + std::vector> times(points); + for ( auto& time : times ) { + time = Clock::now(); } std::vector deltas; deltas.reserve(static_cast(k)); - for ( size_t idx = 1; idx < times.size(); ++idx ) { + for ( size_t idx = 1; idx < points; ++idx ) { deltas.push_back( static_cast( ( times[idx] - times[idx - 1] ).count() ) ); } @@ -1969,12 +1970,12 @@ namespace Catch { template int warmup() { - return run_for_at_least(std::chrono::duration_cast(warmup_time), warmup_seed, &resolution) + return run_for_at_least(warmup_time, warmup_seed, &resolution) .iterations; } template EnvironmentEstimate estimate_clock_resolution(int iterations) { - auto r = run_for_at_least(std::chrono::duration_cast(clock_resolution_estimation_time), iterations, &resolution) + auto r = run_for_at_least(clock_resolution_estimation_time, iterations, &resolution) .result; return { FDuration(mean(r.data(), r.data() + r.size())), @@ -1996,7 +1997,7 @@ namespace Catch { }; time_clock(1); int iters = clock_cost_estimation_iterations; - auto&& r = run_for_at_least(std::chrono::duration_cast(clock_cost_estimation_time), iters, time_clock); + auto&& r = run_for_at_least(clock_cost_estimation_time, iters, time_clock); std::vector times; int nsamples = static_cast(std::ceil(time_limit / r.elapsed)); times.reserve(static_cast(nsamples)); @@ -2098,12 +2099,12 @@ namespace Catch { : fun(CATCH_MOVE(func)), name(CATCH_MOVE(benchmarkName)) {} template - ExecutionPlan prepare(const IConfig &cfg, Environment env) const { + ExecutionPlan prepare(const IConfig &cfg, Environment env) { auto min_time = env.clock_resolution.mean * Detail::minimum_ticks; auto run_time = std::max(min_time, std::chrono::duration_cast(cfg.benchmarkWarmupTime())); auto&& test = Detail::run_for_at_least(std::chrono::duration_cast(run_time), 1, fun); int new_iters = static_cast(std::ceil(min_time * test.iterations / test.elapsed)); - return { new_iters, test.elapsed / test.iterations * new_iters * cfg.benchmarkSamples(), fun, std::chrono::duration_cast(cfg.benchmarkWarmupTime()), Detail::warmup_iterations }; + return { new_iters, test.elapsed / test.iterations * new_iters * cfg.benchmarkSamples(), CATCH_MOVE(fun), std::chrono::duration_cast(cfg.benchmarkWarmupTime()), Detail::warmup_iterations }; } template @@ -2694,11 +2695,11 @@ namespace Catch { }; template<> struct StringMaker { - static std::string convert(signed char c); + static std::string convert(signed char value); }; template<> struct StringMaker { - static std::string convert(unsigned char c); + static std::string convert(unsigned char value); }; template<> @@ -3279,13 +3280,13 @@ namespace Catch { ITransientExpression const* m_transientExpression = nullptr; bool m_isNegated; public: - LazyExpression( bool isNegated ): + constexpr LazyExpression( bool isNegated ): m_isNegated(isNegated) {} - LazyExpression(LazyExpression const& other) = default; + constexpr LazyExpression(LazyExpression const& other) = default; LazyExpression& operator = ( LazyExpression const& ) = delete; - explicit operator bool() const { + constexpr explicit operator bool() const { return m_transientExpression != nullptr; } @@ -3342,6 +3343,18 @@ namespace Catch { #endif // CATCH_ASSERTION_RESULT_HPP_INCLUDED +#ifndef CATCH_CASE_SENSITIVE_HPP_INCLUDED +#define CATCH_CASE_SENSITIVE_HPP_INCLUDED + +namespace Catch { + + enum class CaseSensitive { Yes, No }; + +} // namespace Catch + +#endif // CATCH_CASE_SENSITIVE_HPP_INCLUDED + + #ifndef CATCH_CONFIG_HPP_INCLUDED #define CATCH_CONFIG_HPP_INCLUDED @@ -3361,18 +3374,6 @@ namespace Catch { #define CATCH_WILDCARD_PATTERN_HPP_INCLUDED - -#ifndef CATCH_CASE_SENSITIVE_HPP_INCLUDED -#define CATCH_CASE_SENSITIVE_HPP_INCLUDED - -namespace Catch { - - enum class CaseSensitive { Yes, No }; - -} // namespace Catch - -#endif // CATCH_CASE_SENSITIVE_HPP_INCLUDED - #include namespace Catch @@ -3639,141 +3640,6 @@ namespace Catch { #define CATCH_REPORTER_SPEC_PARSER_HPP_INCLUDED - -#ifndef CATCH_CONSOLE_COLOUR_HPP_INCLUDED -#define CATCH_CONSOLE_COLOUR_HPP_INCLUDED - - -#include -#include - -namespace Catch { - - enum class ColourMode : std::uint8_t; - class IStream; - - struct Colour { - enum Code { - None = 0, - - White, - Red, - Green, - Blue, - Cyan, - Yellow, - Grey, - - Bright = 0x10, - - BrightRed = Bright | Red, - BrightGreen = Bright | Green, - LightGrey = Bright | Grey, - BrightWhite = Bright | White, - BrightYellow = Bright | Yellow, - - // By intention - FileName = LightGrey, - Warning = BrightYellow, - ResultError = BrightRed, - ResultSuccess = BrightGreen, - ResultExpectedFailure = Warning, - - Error = BrightRed, - Success = Green, - Skip = LightGrey, - - OriginalExpression = Cyan, - ReconstructedExpression = BrightYellow, - - SecondaryText = LightGrey, - Headers = White - }; - }; - - class ColourImpl { - protected: - //! The associated stream of this ColourImpl instance - IStream* m_stream; - public: - ColourImpl( IStream* stream ): m_stream( stream ) {} - - //! RAII wrapper around writing specific colour of text using specific - //! colour impl into a stream. - class ColourGuard { - ColourImpl const* m_colourImpl; - Colour::Code m_code; - bool m_engaged = false; - - public: - //! Does **not** engage the guard/start the colour - ColourGuard( Colour::Code code, - ColourImpl const* colour ); - - ColourGuard( ColourGuard const& rhs ) = delete; - ColourGuard& operator=( ColourGuard const& rhs ) = delete; - - ColourGuard( ColourGuard&& rhs ) noexcept; - ColourGuard& operator=( ColourGuard&& rhs ) noexcept; - - //! Removes colour _if_ the guard was engaged - ~ColourGuard(); - - /** - * Explicitly engages colour for given stream. - * - * The API based on operator<< should be preferred. - */ - ColourGuard& engage( std::ostream& stream ) &; - /** - * Explicitly engages colour for given stream. - * - * The API based on operator<< should be preferred. - */ - ColourGuard&& engage( std::ostream& stream ) &&; - - private: - //! Engages the guard and starts using colour - friend std::ostream& operator<<( std::ostream& lhs, - ColourGuard& guard ) { - guard.engageImpl( lhs ); - return lhs; - } - //! Engages the guard and starts using colour - friend std::ostream& operator<<( std::ostream& lhs, - ColourGuard&& guard) { - guard.engageImpl( lhs ); - return lhs; - } - - void engageImpl( std::ostream& stream ); - - }; - - virtual ~ColourImpl(); // = default - /** - * Creates a guard object for given colour and this colour impl - * - * **Important:** - * the guard starts disengaged, and has to be engaged explicitly. - */ - ColourGuard guardColour( Colour::Code colourCode ); - - private: - virtual void use( Colour::Code colourCode ) const = 0; - }; - - //! Provides ColourImpl based on global config and target compilation platform - Detail::unique_ptr makeColourImpl( ColourMode colourSelection, - IStream* stream ); - - //! Checks if specific colour impl has been compiled into the binary - bool isColourImplAvailable( ColourMode colourSelection ); - -} // end namespace Catch - -#endif // CATCH_CONSOLE_COLOUR_HPP_INCLUDED - #include #include #include @@ -3899,7 +3765,7 @@ namespace Catch { bool benchmarkNoAnalysis = false; unsigned int benchmarkSamples = 100; double benchmarkConfidenceInterval = 0.95; - unsigned int benchmarkResamples = 100000; + unsigned int benchmarkResamples = 100'000; std::chrono::milliseconds::rep benchmarkWarmupTime = 100; Verbosity verbosity = Verbosity::Normal; @@ -4159,7 +4025,7 @@ namespace Catch { do { \ Catch::AssertionHandler catchAssertionHandler( macroName##_catch_sr, CATCH_INTERNAL_LINEINFO, Catch::StringRef(), resultDisposition ); \ catchAssertionHandler.handleMessage( messageType, ( Catch::MessageStream() << __VA_ARGS__ + ::Catch::StreamEndStop() ).m_stream.str() ); \ - INTERNAL_CATCH_REACT( catchAssertionHandler ) \ + catchAssertionHandler.complete(); \ } while( false ) /////////////////////////////////////////////////////////////////////////////// @@ -4387,17 +4253,16 @@ namespace Catch { enum class TokenType { Option, Argument }; struct Token { TokenType type; - std::string token; + StringRef token; }; // Abstracts iterators into args as a stream of tokens, with option // arguments uniformly handled class TokenStream { - using Iterator = std::vector::const_iterator; + using Iterator = std::vector::const_iterator; Iterator it; Iterator itEnd; std::vector m_tokenBuffer; - void loadBuffer(); public: @@ -4449,12 +4314,17 @@ namespace Catch { ResultType m_type; }; - template class ResultValueBase : public ResultBase { + template + class ResultValueBase : public ResultBase { public: - auto value() const -> T const& { + T const& value() const& { enforceOk(); return m_value; } + T&& value() && { + enforceOk(); + return CATCH_MOVE( m_value ); + } protected: ResultValueBase( ResultType type ): ResultBase( type ) {} @@ -4464,13 +4334,23 @@ namespace Catch { if ( m_type == ResultType::Ok ) new ( &m_value ) T( other.m_value ); } + ResultValueBase( ResultValueBase&& other ): + ResultBase( other ) { + if ( m_type == ResultType::Ok ) + new ( &m_value ) T( CATCH_MOVE(other.m_value) ); + } + - ResultValueBase( ResultType, T const& value ): ResultBase( ResultType::Ok ) { + ResultValueBase( ResultType, T const& value ): + ResultBase( ResultType::Ok ) { new ( &m_value ) T( value ); } + ResultValueBase( ResultType, T&& value ): + ResultBase( ResultType::Ok ) { + new ( &m_value ) T( CATCH_MOVE(value) ); + } - auto operator=( ResultValueBase const& other ) - -> ResultValueBase& { + ResultValueBase& operator=( ResultValueBase const& other ) { if ( m_type == ResultType::Ok ) m_value.~T(); ResultBase::operator=( other ); @@ -4478,6 +4358,14 @@ namespace Catch { new ( &m_value ) T( other.m_value ); return *this; } + ResultValueBase& operator=( ResultValueBase&& other ) { + if ( m_type == ResultType::Ok ) m_value.~T(); + ResultBase::operator=( other ); + if ( m_type == ResultType::Ok ) + new ( &m_value ) T( CATCH_MOVE(other.m_value) ); + return *this; + } + ~ResultValueBase() override { if ( m_type == ResultType::Ok ) @@ -4505,8 +4393,8 @@ namespace Catch { } template - static auto ok( U const& value ) -> BasicResult { - return { ResultType::Ok, value }; + static auto ok( U&& value ) -> BasicResult { + return { ResultType::Ok, CATCH_FORWARD(value) }; } static auto ok() -> BasicResult { return { ResultType::Ok }; } static auto logicError( std::string&& message ) @@ -4553,12 +4441,15 @@ namespace Catch { class ParseState { public: ParseState( ParseResultType type, - TokenStream const& remainingTokens ); + TokenStream remainingTokens ); ParseResultType type() const { return m_type; } - TokenStream const& remainingTokens() const { + TokenStream const& remainingTokens() const& { return m_remainingTokens; } + TokenStream&& remainingTokens() && { + return CATCH_MOVE( m_remainingTokens ); + } private: ParseResultType m_type; @@ -4571,7 +4462,7 @@ namespace Catch { struct HelpColumns { std::string left; - std::string right; + StringRef descriptions; }; template @@ -4731,7 +4622,7 @@ namespace Catch { virtual ~ParserBase() = default; virtual auto validate() const -> Result { return Result::ok(); } virtual auto parse( std::string const& exeName, - TokenStream const& tokens ) const + TokenStream tokens ) const -> InternalParseResult = 0; virtual size_t cardinality() const; @@ -4751,8 +4642,8 @@ namespace Catch { protected: Optionality m_optionality = Optionality::Optional; std::shared_ptr m_ref; - std::string m_hint; - std::string m_description; + StringRef m_hint; + StringRef m_description; explicit ParserRefImpl( std::shared_ptr const& ref ): m_ref( ref ) {} @@ -4761,28 +4652,32 @@ namespace Catch { template ParserRefImpl( accept_many_t, LambdaT const& ref, - std::string const& hint ): + StringRef hint ): m_ref( std::make_shared>( ref ) ), m_hint( hint ) {} template ::value>> - ParserRefImpl( T& ref, std::string const& hint ): + ParserRefImpl( T& ref, StringRef hint ): m_ref( std::make_shared>( ref ) ), m_hint( hint ) {} template ::value>> - ParserRefImpl( LambdaT const& ref, std::string const& hint ): + ParserRefImpl( LambdaT const& ref, StringRef hint ): m_ref( std::make_shared>( ref ) ), m_hint( hint ) {} - auto operator()( std::string const& description ) -> DerivedT& { + DerivedT& operator()( StringRef description ) & { m_description = description; return static_cast( *this ); } + DerivedT&& operator()( StringRef description ) && { + m_description = description; + return static_cast( *this ); + } auto optional() -> DerivedT& { m_optionality = Optionality::Optional; @@ -4805,7 +4700,7 @@ namespace Catch { return 1; } - std::string const& hint() const { return m_hint; } + StringRef hint() const { return m_hint; } }; } // namespace detail @@ -4819,13 +4714,13 @@ namespace Catch { Detail::InternalParseResult parse(std::string const&, - Detail::TokenStream const& tokens) const override; + Detail::TokenStream tokens) const override; }; // A parser for options class Opt : public Detail::ParserRefImpl { protected: - std::vector m_optNames; + std::vector m_optNames; public: template @@ -4838,33 +4733,37 @@ namespace Catch { template ::value>> - Opt( LambdaT const& ref, std::string const& hint ): + Opt( LambdaT const& ref, StringRef hint ): ParserRefImpl( ref, hint ) {} template - Opt( accept_many_t, LambdaT const& ref, std::string const& hint ): + Opt( accept_many_t, LambdaT const& ref, StringRef hint ): ParserRefImpl( accept_many, ref, hint ) {} template ::value>> - Opt( T& ref, std::string const& hint ): + Opt( T& ref, StringRef hint ): ParserRefImpl( ref, hint ) {} - auto operator[](std::string const& optName) -> Opt& { + Opt& operator[]( StringRef optName ) & { m_optNames.push_back(optName); return *this; } + Opt&& operator[]( StringRef optName ) && { + m_optNames.push_back( optName ); + return CATCH_MOVE(*this); + } - std::vector getHelpColumns() const; + Detail::HelpColumns getHelpColumns() const; - bool isMatch(std::string const& optToken) const; + bool isMatch(StringRef optToken) const; using ParserBase::parse; Detail::InternalParseResult parse(std::string const&, - Detail::TokenStream const& tokens) const override; + Detail::TokenStream tokens) const override; Detail::Result validate() const override; }; @@ -4887,7 +4786,7 @@ namespace Catch { // handled specially Detail::InternalParseResult parse(std::string const&, - Detail::TokenStream const& tokens) const override; + Detail::TokenStream tokens) const override; std::string const& name() const { return *m_name; } Detail::ParserResult set(std::string const& newName); @@ -4912,16 +4811,28 @@ namespace Catch { return *this; } - auto operator|=(Opt const& opt) -> Parser& { - m_options.push_back(opt); - return *this; + friend Parser& operator|=( Parser& p, Opt const& opt ) { + p.m_options.push_back( opt ); + return p; + } + friend Parser& operator|=( Parser& p, Opt&& opt ) { + p.m_options.push_back( CATCH_MOVE(opt) ); + return p; } Parser& operator|=(Parser const& other); template - auto operator|(T const& other) const -> Parser { - return Parser(*this) |= other; + friend Parser operator|( Parser const& p, T&& rhs ) { + Parser temp( p ); + temp |= rhs; + return temp; + } + + template + friend Parser operator|( Parser&& p, T&& rhs ) { + p |= CATCH_FORWARD(rhs); + return CATCH_MOVE(p); } std::vector getHelpColumns() const; @@ -4939,21 +4850,23 @@ namespace Catch { using ParserBase::parse; Detail::InternalParseResult parse(std::string const& exeName, - Detail::TokenStream const& tokens) const override; + Detail::TokenStream tokens) const override; }; - // Transport for raw args (copied from main args, or supplied via - // init list for testing) + /** + * Wrapper over argc + argv, assumes that the inputs outlive it + */ class Args { friend Detail::TokenStream; - std::string m_exeName; - std::vector m_args; + StringRef m_exeName; + std::vector m_args; public: Args(int argc, char const* const* argv); - Args(std::initializer_list args); + // Helper constructor for testing + Args(std::initializer_list args); - std::string const& exeName() const { return m_exeName; } + StringRef exeName() const { return m_exeName; } }; @@ -5233,6 +5146,86 @@ namespace Detail { #include #include +/** \file + * Why does decomposing look the way it does: + * + * Conceptually, decomposing is simple. We change `REQUIRE( a == b )` into + * `Decomposer{} <= a == b`, so that `Decomposer{} <= a` is evaluated first, + * and our custom operator is used for `a == b`, because `a` is transformed + * into `ExprLhs` and then into `BinaryExpr`. + * + * In practice, decomposing ends up a mess, because we have to support + * various fun things. + * + * 1) Types that are only comparable with literal 0, and they do this by + * comparing against a magic type with pointer constructor and deleted + * other constructors. Example: `REQUIRE((a <=> b) == 0)` in libstdc++ + * + * 2) Types that are only comparable with literal 0, and they do this by + * comparing against a magic type with consteval integer constructor. + * Example: `REQUIRE((a <=> b) == 0)` in current MSVC STL. + * + * 3) Types that have no linkage, and so we cannot form a reference to + * them. Example: some implementations of traits. + * + * 4) Starting with C++20, when the compiler sees `a == b`, it also uses + * `b == a` when constructing the overload set. For us this means that + * when the compiler handles `ExprLhs == b`, it also tries to resolve + * the overload set for `b == ExprLhs`. + * + * To accomodate these use cases, decomposer ended up rather complex. + * + * 1) These types are handled by adding SFINAE overloads to our comparison + * operators, checking whether `T == U` are comparable with the given + * operator, and if not, whether T (or U) are comparable with literal 0. + * If yes, the overload compares T (or U) with 0 literal inline in the + * definition. + * + * Note that for extra correctness, we check that the other type is + * either an `int` (literal 0 is captured as `int` by templates), or + * a `long` (some platforms use 0L for `NULL` and we want to support + * that for pointer comparisons). + * + * 2) For these types, `is_foo_comparable` is true, but letting + * them fall into the overload that actually does `T == int` causes + * compilation error. Handling them requires that the decomposition + * is `constexpr`, so that P2564R3 applies and the `consteval` from + * their accompanying magic type is propagated through the `constexpr` + * call stack. + * + * However this is not enough to handle these types automatically, + * because our default is to capture types by reference, to avoid + * runtime copies. While these references cannot become dangling, + * they outlive the constexpr context and thus the default capture + * path cannot be actually constexpr. + * + * The solution is to capture these types by value, by explicitly + * specializing `Catch::capture_by_value` for them. Catch2 provides + * specialization for `std::foo_ordering`s, but users can specialize + * the trait for their own types as well. + * + * 3) If a type has no linkage, we also cannot capture it by reference. + * The solution is once again to capture them by value. We handle + * the common cases by using `std::is_arithmetic` as the default + * for `Catch::capture_by_value`, but that is only a some-effort + * heuristic. But as with 2), users can specialize `capture_by_value` + * for their own types as needed. + * + * 4) To support C++20 and make the SFINAE on our decomposing operators + * work, the SFINAE has to happen in return type, rather than in + * a template type. This is due to our use of logical type traits + * (`conjunction`/`disjunction`/`negation`), that we use to workaround + * an issue in older (9-) versions of GCC. I still blame C++20 for + * this, because without the comparison order switching, the logical + * traits could still be used in template type. + * + * There are also other side concerns, e.g. supporting both `REQUIRE(a)` + * and `REQUIRE(a == b)`, or making `REQUIRE_THAT(a, IsEqual(b))` slot + * nicely into the same expression handling logic, but these are rather + * straightforward and add only a bit of complexity (e.g. common base + * class for decomposed expressions). + */ + #ifdef _MSC_VER #pragma warning(push) #pragma warning(disable:4389) // '==' : signed/unsigned mismatch @@ -5245,13 +5238,46 @@ namespace Detail { #ifdef __clang__ # pragma clang diagnostic push # pragma clang diagnostic ignored "-Wsign-compare" +# pragma clang diagnostic ignored "-Wnon-virtual-dtor" #elif defined __GNUC__ # pragma GCC diagnostic push # pragma GCC diagnostic ignored "-Wsign-compare" +# pragma GCC diagnostic ignored "-Wnon-virtual-dtor" +#endif + +#if defined(CATCH_CPP20_OR_GREATER) && __has_include() +# include +# if defined( __cpp_lib_three_way_comparison ) && \ + __cpp_lib_three_way_comparison >= 201907L +# define CATCH_CONFIG_CPP20_COMPARE_OVERLOADS +# endif #endif namespace Catch { + namespace Detail { + // This was added in C++20, but we require only C++14 for now. + template + using RemoveCVRef_t = std::remove_cv_t>; + } + + // Note: There is nothing that stops us from extending this, + // e.g. to `std::is_scalar`, but the more encompassing + // traits are usually also more expensive. For now we + // keep this as it used to be and it can be changed later. + template + struct capture_by_value + : std::integral_constant{}> {}; + +#if defined( CATCH_CONFIG_CPP20_COMPARE_OVERLOADS ) + template <> + struct capture_by_value : std::true_type {}; + template <> + struct capture_by_value : std::true_type {}; + template <> + struct capture_by_value : std::true_type {}; +#endif + template struct always_false : std::false_type {}; @@ -5259,23 +5285,22 @@ namespace Catch { bool m_isBinaryExpression; bool m_result; + protected: + ~ITransientExpression() = default; + public: - auto isBinaryExpression() const -> bool { return m_isBinaryExpression; } - auto getResult() const -> bool { return m_result; } - virtual void streamReconstructedExpression( std::ostream &os ) const = 0; + constexpr auto isBinaryExpression() const -> bool { return m_isBinaryExpression; } + constexpr auto getResult() const -> bool { return m_result; } + //! This function **has** to be overriden by the derived class. + virtual void streamReconstructedExpression( std::ostream& os ) const; - ITransientExpression( bool isBinaryExpression, bool result ) + constexpr ITransientExpression( bool isBinaryExpression, bool result ) : m_isBinaryExpression( isBinaryExpression ), m_result( result ) {} - ITransientExpression() = default; - ITransientExpression(ITransientExpression const&) = default; - ITransientExpression& operator=(ITransientExpression const&) = default; - - // We don't actually need a virtual destructor, but many static analysers - // complain if it's not here :-( - virtual ~ITransientExpression(); // = default; + constexpr ITransientExpression( ITransientExpression const& ) = default; + constexpr ITransientExpression& operator=( ITransientExpression const& ) = default; friend std::ostream& operator<<(std::ostream& out, ITransientExpression const& expr) { expr.streamReconstructedExpression(out); @@ -5297,7 +5322,7 @@ namespace Catch { } public: - BinaryExpr( bool comparisonResult, LhsT lhs, StringRef op, RhsT rhs ) + constexpr BinaryExpr( bool comparisonResult, LhsT lhs, StringRef op, RhsT rhs ) : ITransientExpression{ true, comparisonResult }, m_lhs( lhs ), m_op( op ), @@ -5370,7 +5395,7 @@ namespace Catch { } public: - explicit UnaryExpr( LhsT lhs ) + explicit constexpr UnaryExpr( LhsT lhs ) : ITransientExpression{ false, static_cast(lhs) }, m_lhs( lhs ) {} @@ -5381,31 +5406,31 @@ namespace Catch { class ExprLhs { LhsT m_lhs; public: - explicit ExprLhs( LhsT lhs ) : m_lhs( lhs ) {} + explicit constexpr ExprLhs( LhsT lhs ) : m_lhs( lhs ) {} #define CATCH_INTERNAL_DEFINE_EXPRESSION_EQUALITY_OPERATOR( id, op ) \ template \ - friend auto operator op( ExprLhs&& lhs, RhsT&& rhs ) \ - ->std::enable_if_t< \ + constexpr friend auto operator op( ExprLhs&& lhs, RhsT&& rhs ) \ + -> std::enable_if_t< \ Detail::conjunction, \ - Detail::negation>>>::value, \ + Detail::negation>>>::value, \ BinaryExpr> { \ return { \ static_cast( lhs.m_lhs op rhs ), lhs.m_lhs, #op##_sr, rhs }; \ } \ template \ - friend auto operator op( ExprLhs&& lhs, RhsT rhs ) \ - ->std::enable_if_t< \ + constexpr friend auto operator op( ExprLhs&& lhs, RhsT rhs ) \ + -> std::enable_if_t< \ Detail::conjunction, \ - std::is_arithmetic>::value, \ + capture_by_value>::value, \ BinaryExpr> { \ return { \ static_cast( lhs.m_lhs op rhs ), lhs.m_lhs, #op##_sr, rhs }; \ } \ template \ - friend auto operator op( ExprLhs&& lhs, RhsT rhs ) \ - ->std::enable_if_t< \ + constexpr friend auto operator op( ExprLhs&& lhs, RhsT rhs ) \ + -> std::enable_if_t< \ Detail::conjunction< \ Detail::negation>, \ Detail::is_eq_0_comparable, \ @@ -5418,8 +5443,8 @@ namespace Catch { static_cast( lhs.m_lhs op 0 ), lhs.m_lhs, #op##_sr, rhs }; \ } \ template \ - friend auto operator op( ExprLhs&& lhs, RhsT rhs ) \ - ->std::enable_if_t< \ + constexpr friend auto operator op( ExprLhs&& lhs, RhsT rhs ) \ + -> std::enable_if_t< \ Detail::conjunction< \ Detail::negation>, \ Detail::is_eq_0_comparable, \ @@ -5436,29 +5461,30 @@ namespace Catch { #undef CATCH_INTERNAL_DEFINE_EXPRESSION_EQUALITY_OPERATOR + #define CATCH_INTERNAL_DEFINE_EXPRESSION_COMPARISON_OPERATOR( id, op ) \ template \ - friend auto operator op( ExprLhs&& lhs, RhsT&& rhs ) \ - ->std::enable_if_t< \ + constexpr friend auto operator op( ExprLhs&& lhs, RhsT&& rhs ) \ + -> std::enable_if_t< \ Detail::conjunction, \ - Detail::negation>>>::value, \ + Detail::negation>>>::value, \ BinaryExpr> { \ return { \ static_cast( lhs.m_lhs op rhs ), lhs.m_lhs, #op##_sr, rhs }; \ } \ template \ - friend auto operator op( ExprLhs&& lhs, RhsT rhs ) \ - ->std::enable_if_t< \ + constexpr friend auto operator op( ExprLhs&& lhs, RhsT rhs ) \ + -> std::enable_if_t< \ Detail::conjunction, \ - std::is_arithmetic>::value, \ + capture_by_value>::value, \ BinaryExpr> { \ return { \ static_cast( lhs.m_lhs op rhs ), lhs.m_lhs, #op##_sr, rhs }; \ } \ template \ - friend auto operator op( ExprLhs&& lhs, RhsT rhs ) \ - ->std::enable_if_t< \ + constexpr friend auto operator op( ExprLhs&& lhs, RhsT rhs ) \ + -> std::enable_if_t< \ Detail::conjunction< \ Detail::negation>, \ Detail::is_##id##_0_comparable, \ @@ -5469,8 +5495,8 @@ namespace Catch { static_cast( lhs.m_lhs op 0 ), lhs.m_lhs, #op##_sr, rhs }; \ } \ template \ - friend auto operator op( ExprLhs&& lhs, RhsT rhs ) \ - ->std::enable_if_t< \ + constexpr friend auto operator op( ExprLhs&& lhs, RhsT rhs ) \ + -> std::enable_if_t< \ Detail::conjunction< \ Detail::negation>, \ Detail::is_##id##_0_comparable, \ @@ -5490,17 +5516,17 @@ namespace Catch { #define CATCH_INTERNAL_DEFINE_EXPRESSION_OPERATOR( op ) \ template \ - friend auto operator op( ExprLhs&& lhs, RhsT&& rhs ) \ - ->std::enable_if_t< \ - !std::is_arithmetic>::value, \ + constexpr friend auto operator op( ExprLhs&& lhs, RhsT&& rhs ) \ + -> std::enable_if_t< \ + !capture_by_value>::value, \ BinaryExpr> { \ return { \ static_cast( lhs.m_lhs op rhs ), lhs.m_lhs, #op##_sr, rhs }; \ } \ template \ - friend auto operator op( ExprLhs&& lhs, RhsT rhs ) \ - ->std::enable_if_t::value, \ - BinaryExpr> { \ + constexpr friend auto operator op( ExprLhs&& lhs, RhsT rhs ) \ + -> std::enable_if_t::value, \ + BinaryExpr> { \ return { \ static_cast( lhs.m_lhs op rhs ), lhs.m_lhs, #op##_sr, rhs }; \ } @@ -5525,19 +5551,22 @@ namespace Catch { "wrap the expression inside parentheses, or decompose it"); } - auto makeUnaryExpr() const -> UnaryExpr { + constexpr auto makeUnaryExpr() const -> UnaryExpr { return UnaryExpr{ m_lhs }; } }; struct Decomposer { - template>::value, int> = 0> - friend auto operator <= ( Decomposer &&, T && lhs ) -> ExprLhs { + template >::value, + int> = 0> + constexpr friend auto operator <= ( Decomposer &&, T && lhs ) -> ExprLhs { return ExprLhs{ lhs }; } - template::value, int> = 0> - friend auto operator <= ( Decomposer &&, T value ) -> ExprLhs { + template ::value, int> = 0> + constexpr friend auto operator <= ( Decomposer &&, T value ) -> ExprLhs { return ExprLhs{ value }; } }; @@ -5585,12 +5614,12 @@ namespace Catch { template - void handleExpr( ExprLhs const& expr ) { + constexpr void handleExpr( ExprLhs const& expr ) { handleExpr( expr.makeUnaryExpr() ); } void handleExpr( ITransientExpression const& expr ); - void handleMessage(ResultWas::OfType resultType, StringRef message); + void handleMessage(ResultWas::OfType resultType, std::string&& message); void handleExceptionThrownAsExpected(); void handleUnexpectedExceptionNotThrown(); @@ -5646,8 +5675,6 @@ namespace Catch { #endif -#define INTERNAL_CATCH_REACT( handler ) handler.complete(); - /////////////////////////////////////////////////////////////////////////////// #define INTERNAL_CATCH_TEST( macroName, resultDisposition, ... ) \ do { /* NOLINT(bugprone-infinite-loop) */ \ @@ -5657,10 +5684,10 @@ namespace Catch { INTERNAL_CATCH_TRY { \ CATCH_INTERNAL_START_WARNINGS_SUPPRESSION \ CATCH_INTERNAL_SUPPRESS_PARENTHESES_WARNINGS \ - catchAssertionHandler.handleExpr( Catch::Decomposer() <= __VA_ARGS__ ); \ + catchAssertionHandler.handleExpr( Catch::Decomposer() <= __VA_ARGS__ ); /* NOLINT(bugprone-chained-comparison) */ \ CATCH_INTERNAL_STOP_WARNINGS_SUPPRESSION \ } INTERNAL_CATCH_CATCH( catchAssertionHandler ) \ - INTERNAL_CATCH_REACT( catchAssertionHandler ) \ + catchAssertionHandler.complete(); \ } while( (void)0, (false) && static_cast( !!(__VA_ARGS__) ) ) // the expression here is never evaluated at runtime but it forces the compiler to give it a look // The double negation silences MSVC's C4800 warning, the static_cast forces short-circuit evaluation if the type has overloaded &&. @@ -5688,7 +5715,7 @@ namespace Catch { catch( ... ) { \ catchAssertionHandler.handleUnexpectedInflightException(); \ } \ - INTERNAL_CATCH_REACT( catchAssertionHandler ) \ + catchAssertionHandler.complete(); \ } while( false ) /////////////////////////////////////////////////////////////////////////////// @@ -5709,7 +5736,7 @@ namespace Catch { } \ else \ catchAssertionHandler.handleThrowingCallSkipped(); \ - INTERNAL_CATCH_REACT( catchAssertionHandler ) \ + catchAssertionHandler.complete(); \ } while( false ) /////////////////////////////////////////////////////////////////////////////// @@ -5733,7 +5760,7 @@ namespace Catch { } \ else \ catchAssertionHandler.handleThrowingCallSkipped(); \ - INTERNAL_CATCH_REACT( catchAssertionHandler ) \ + catchAssertionHandler.complete(); \ } while( false ) @@ -5757,7 +5784,7 @@ namespace Catch { } \ else \ catchAssertionHandler.handleThrowingCallSkipped(); \ - INTERNAL_CATCH_REACT( catchAssertionHandler ) \ + catchAssertionHandler.complete(); \ } while( false ) #endif // CATCH_CONFIG_DISABLE @@ -5872,7 +5899,9 @@ namespace Catch { namespace Detail { // Intentionally without linkage, as it should only be used as a dummy // symbol for static analysis. - int GetNewSectionHint(); + // The arguments are used as a dummy for checking warnings in the passed + // expressions. + int GetNewSectionHint( StringRef, const char* const = nullptr ); } // namespace Detail } // namespace Catch @@ -5883,7 +5912,8 @@ namespace Catch { CATCH_INTERNAL_SUPPRESS_SHADOW_WARNINGS \ if ( [[maybe_unused]] const int catchInternalPreviousSectionHint = \ catchInternalSectionHint, \ - catchInternalSectionHint = Catch::Detail::GetNewSectionHint(); \ + catchInternalSectionHint = \ + Catch::Detail::GetNewSectionHint(__VA_ARGS__); \ catchInternalPreviousSectionHint == __LINE__ ) \ CATCH_INTERNAL_STOP_WARNINGS_SUPPRESSION @@ -5893,7 +5923,8 @@ namespace Catch { CATCH_INTERNAL_SUPPRESS_SHADOW_WARNINGS \ if ( [[maybe_unused]] const int catchInternalPreviousSectionHint = \ catchInternalSectionHint, \ - catchInternalSectionHint = Catch::Detail::GetNewSectionHint(); \ + catchInternalSectionHint = Catch::Detail::GetNewSectionHint( \ + ( Catch::ReusableStringStream() << __VA_ARGS__ ).str()); \ catchInternalPreviousSectionHint == __LINE__ ) \ CATCH_INTERNAL_STOP_WARNINGS_SUPPRESSION @@ -5915,6 +5946,8 @@ namespace Catch { class ITestInvoker { public: + virtual void prepareTestCase(); + virtual void tearDownTestCase(); virtual void invoke() const = 0; virtual ~ITestInvoker(); // = default }; @@ -5952,7 +5985,8 @@ template class TestInvokerAsMethod : public ITestInvoker { void (C::*m_testAsMethod)(); public: - TestInvokerAsMethod( void (C::*testAsMethod)() ) noexcept : m_testAsMethod( testAsMethod ) {} + constexpr TestInvokerAsMethod( void ( C::*testAsMethod )() ) noexcept: + m_testAsMethod( testAsMethod ) {} void invoke() const override { C obj; @@ -5967,13 +6001,41 @@ Detail::unique_ptr makeTestInvoker( void (C::*testAsMethod)() ) { return Detail::make_unique>( testAsMethod ); } -struct NameAndTags { - constexpr NameAndTags( StringRef name_ = StringRef(), - StringRef tags_ = StringRef() ) noexcept: - name( name_ ), tags( tags_ ) {} - StringRef name; - StringRef tags; -}; +template +class TestInvokerFixture : public ITestInvoker { + void ( C::*m_testAsMethod )() const; + Detail::unique_ptr m_fixture = nullptr; + +public: + constexpr TestInvokerFixture( void ( C::*testAsMethod )() const ) noexcept: + m_testAsMethod( testAsMethod ) {} + + void prepareTestCase() override { + m_fixture = Detail::make_unique(); + } + + void tearDownTestCase() override { + m_fixture.reset(); + } + + void invoke() const override { + auto* f = m_fixture.get(); + ( f->*m_testAsMethod )(); + } +}; + +template +Detail::unique_ptr makeTestInvokerFixture( void ( C::*testAsMethod )() const ) { + return Detail::make_unique>( testAsMethod ); +} + +struct NameAndTags { + constexpr NameAndTags( StringRef name_ = StringRef(), + StringRef tags_ = StringRef() ) noexcept: + name( name_ ), tags( tags_ ) {} + StringRef name; + StringRef tags; +}; struct AutoReg : Detail::NonCopyable { AutoReg( Detail::unique_ptr invoker, SourceLineInfo const& lineInfo, StringRef classOrMethod, NameAndTags const& nameAndTags ) noexcept; @@ -6015,7 +6077,7 @@ struct AutoReg : Detail::NonCopyable { namespace Catch { namespace Detail { struct DummyUse { - DummyUse( void ( * )( int ) ); + DummyUse( void ( * )( int ), Catch::NameAndTags const& ); }; } // namespace Detail } // namespace Catch @@ -6027,18 +6089,18 @@ namespace Catch { // tests can compile. The redefined `TEST_CASE` shadows this with param. static int catchInternalSectionHint = 0; -# define INTERNAL_CATCH_TESTCASE2( fname ) \ +# define INTERNAL_CATCH_TESTCASE2( fname, ... ) \ static void fname( int ); \ CATCH_INTERNAL_START_WARNINGS_SUPPRESSION \ CATCH_INTERNAL_SUPPRESS_GLOBALS_WARNINGS \ CATCH_INTERNAL_SUPPRESS_UNUSED_VARIABLE_WARNINGS \ static const Catch::Detail::DummyUse INTERNAL_CATCH_UNIQUE_NAME( \ - dummyUser )( &(fname) ); \ + dummyUser )( &(fname), Catch::NameAndTags{ __VA_ARGS__ } ); \ CATCH_INTERNAL_SUPPRESS_SHADOW_WARNINGS \ static void fname( [[maybe_unused]] int catchInternalSectionHint ) \ CATCH_INTERNAL_STOP_WARNINGS_SUPPRESSION # define INTERNAL_CATCH_TESTCASE( ... ) \ - INTERNAL_CATCH_TESTCASE2( INTERNAL_CATCH_UNIQUE_NAME( dummyFunction ) ) + INTERNAL_CATCH_TESTCASE2( INTERNAL_CATCH_UNIQUE_NAME( dummyFunction ), __VA_ARGS__ ) #endif // CATCH_CONFIG_EXPERIMENTAL_STATIC_ANALYSIS_SUPPORT @@ -6063,6 +6125,26 @@ static int catchInternalSectionHint = 0; #define INTERNAL_CATCH_TEST_CASE_METHOD( ClassName, ... ) \ INTERNAL_CATCH_TEST_CASE_METHOD2( INTERNAL_CATCH_UNIQUE_NAME( CATCH2_INTERNAL_TEST_ ), ClassName, __VA_ARGS__ ) + /////////////////////////////////////////////////////////////////////////////// + #define INTERNAL_CATCH_TEST_CASE_PERSISTENT_FIXTURE2( TestName, ClassName, ... ) \ + CATCH_INTERNAL_START_WARNINGS_SUPPRESSION \ + CATCH_INTERNAL_SUPPRESS_GLOBALS_WARNINGS \ + CATCH_INTERNAL_SUPPRESS_UNUSED_VARIABLE_WARNINGS \ + namespace { \ + struct TestName : INTERNAL_CATCH_REMOVE_PARENS( ClassName ) { \ + void test() const; \ + }; \ + const Catch::AutoReg INTERNAL_CATCH_UNIQUE_NAME( autoRegistrar )( \ + Catch::makeTestInvokerFixture( &TestName::test ), \ + CATCH_INTERNAL_LINEINFO, \ + #ClassName##_catch_sr, \ + Catch::NameAndTags{ __VA_ARGS__ } ); /* NOLINT */ \ + } \ + CATCH_INTERNAL_STOP_WARNINGS_SUPPRESSION \ + void TestName::test() const + #define INTERNAL_CATCH_TEST_CASE_PERSISTENT_FIXTURE( ClassName, ... ) \ + INTERNAL_CATCH_TEST_CASE_PERSISTENT_FIXTURE2( INTERNAL_CATCH_UNIQUE_NAME( CATCH2_INTERNAL_TEST_ ), ClassName, __VA_ARGS__ ) + /////////////////////////////////////////////////////////////////////////////// #define INTERNAL_CATCH_METHOD_AS_TEST_CASE( QualifiedMethod, ... ) \ @@ -6120,6 +6202,7 @@ static int catchInternalSectionHint = 0; #define CATCH_TEST_CASE( ... ) INTERNAL_CATCH_TESTCASE( __VA_ARGS__ ) #define CATCH_TEST_CASE_METHOD( className, ... ) INTERNAL_CATCH_TEST_CASE_METHOD( className, __VA_ARGS__ ) #define CATCH_METHOD_AS_TEST_CASE( method, ... ) INTERNAL_CATCH_METHOD_AS_TEST_CASE( method, __VA_ARGS__ ) + #define CATCH_TEST_CASE_PERSISTENT_FIXTURE( className, ... ) INTERNAL_CATCH_TEST_CASE_PERSISTENT_FIXTURE( className, __VA_ARGS__ ) #define CATCH_REGISTER_TEST_CASE( Function, ... ) INTERNAL_CATCH_REGISTER_TESTCASE( Function, __VA_ARGS__ ) #define CATCH_SECTION( ... ) INTERNAL_CATCH_SECTION( __VA_ARGS__ ) #define CATCH_DYNAMIC_SECTION( ... ) INTERNAL_CATCH_DYNAMIC_SECTION( __VA_ARGS__ ) @@ -6174,6 +6257,7 @@ static int catchInternalSectionHint = 0; #define CATCH_TEST_CASE( ... ) INTERNAL_CATCH_TESTCASE_NO_REGISTRATION(INTERNAL_CATCH_UNIQUE_NAME( CATCH2_INTERNAL_TEST_ )) #define CATCH_TEST_CASE_METHOD( className, ... ) INTERNAL_CATCH_TESTCASE_NO_REGISTRATION(INTERNAL_CATCH_UNIQUE_NAME( CATCH2_INTERNAL_TEST_ )) #define CATCH_METHOD_AS_TEST_CASE( method, ... ) + #define CATCH_TEST_CASE_PERSISTENT_FIXTURE( className, ... ) INTERNAL_CATCH_TESTCASE_NO_REGISTRATION(INTERNAL_CATCH_UNIQUE_NAME( CATCH2_INTERNAL_TEST_ )) #define CATCH_REGISTER_TEST_CASE( Function, ... ) (void)(0) #define CATCH_SECTION( ... ) #define CATCH_DYNAMIC_SECTION( ... ) @@ -6219,6 +6303,7 @@ static int catchInternalSectionHint = 0; #define TEST_CASE( ... ) INTERNAL_CATCH_TESTCASE( __VA_ARGS__ ) #define TEST_CASE_METHOD( className, ... ) INTERNAL_CATCH_TEST_CASE_METHOD( className, __VA_ARGS__ ) #define METHOD_AS_TEST_CASE( method, ... ) INTERNAL_CATCH_METHOD_AS_TEST_CASE( method, __VA_ARGS__ ) + #define TEST_CASE_PERSISTENT_FIXTURE( className, ... ) INTERNAL_CATCH_TEST_CASE_PERSISTENT_FIXTURE( className, __VA_ARGS__ ) #define REGISTER_TEST_CASE( Function, ... ) INTERNAL_CATCH_REGISTER_TESTCASE( Function, __VA_ARGS__ ) #define SECTION( ... ) INTERNAL_CATCH_SECTION( __VA_ARGS__ ) #define DYNAMIC_SECTION( ... ) INTERNAL_CATCH_DYNAMIC_SECTION( __VA_ARGS__ ) @@ -6272,6 +6357,7 @@ static int catchInternalSectionHint = 0; #define TEST_CASE( ... ) INTERNAL_CATCH_TESTCASE_NO_REGISTRATION(INTERNAL_CATCH_UNIQUE_NAME( CATCH2_INTERNAL_TEST_ ), __VA_ARGS__) #define TEST_CASE_METHOD( className, ... ) INTERNAL_CATCH_TESTCASE_NO_REGISTRATION(INTERNAL_CATCH_UNIQUE_NAME( CATCH2_INTERNAL_TEST_ )) #define METHOD_AS_TEST_CASE( method, ... ) + #define TEST_CASE_PERSISTENT_FIXTURE( className, ... ) INTERNAL_CATCH_TESTCASE_NO_REGISTRATION(INTERNAL_CATCH_UNIQUE_NAME( CATCH2_INTERNAL_TEST_ ), __VA_ARGS__) #define REGISTER_TEST_CASE( Function, ... ) (void)(0) #define SECTION( ... ) #define DYNAMIC_SECTION( ... ) @@ -6997,6 +7083,7 @@ namespace Catch { }; class ITestInvoker; + struct NameAndTags; enum class TestCaseProperties : uint8_t { None = 0, @@ -7020,7 +7107,7 @@ namespace Catch { struct TestCaseInfo : Detail::NonCopyable { TestCaseInfo(StringRef _className, - NameAndTags const& _tags, + NameAndTags const& _nameAndTags, SourceLineInfo const& _lineInfo); bool isHidden() const; @@ -7061,14 +7148,24 @@ namespace Catch { TestCaseInfo* m_info; ITestInvoker* m_invoker; public: - TestCaseHandle(TestCaseInfo* info, ITestInvoker* invoker) : + constexpr TestCaseHandle(TestCaseInfo* info, ITestInvoker* invoker) : m_info(info), m_invoker(invoker) {} + void prepareTestCase() const { + m_invoker->prepareTestCase(); + } + + void tearDownTestCase() const { + m_invoker->tearDownTestCase(); + } + void invoke() const { m_invoker->invoke(); } - TestCaseInfo const& getTestCaseInfo() const; + constexpr TestCaseInfo const& getTestCaseInfo() const { + return *m_info; + } }; Detail::unique_ptr @@ -7131,7 +7228,7 @@ namespace Catch { class ExceptionTranslator : public IExceptionTranslator { public: - ExceptionTranslator( std::string(*translateFunction)( T const& ) ) + constexpr ExceptionTranslator( std::string(*translateFunction)( T const& ) ) : m_translateFunction( translateFunction ) {} @@ -7232,8 +7329,8 @@ namespace Catch { #define CATCH_VERSION_MACROS_HPP_INCLUDED #define CATCH_VERSION_MAJOR 3 -#define CATCH_VERSION_MINOR 5 -#define CATCH_VERSION_PATCH 0 +#define CATCH_VERSION_MINOR 7 +#define CATCH_VERSION_PATCH 1 #endif // CATCH_VERSION_MACROS_HPP_INCLUDED @@ -7391,12 +7488,6 @@ namespace Detail { } public: - ~IGenerator() override = default; - IGenerator() = default; - IGenerator(IGenerator const&) = default; - IGenerator& operator=(IGenerator const&) = default; - - // Returns the current element of the generator // // \Precondition The generator is either freshly constructed, @@ -7911,6 +8002,34 @@ namespace Catch { #include #include +// Note: We use the usual enable-disable-autodetect dance here even though +// we do not support these in CMake configuration options (yet?). +// It is highly unlikely that we will need to make these actually +// user-configurable, but this will make it simpler if weend up needing +// it, and it provides an escape hatch to the users who need it. +#if defined( __SIZEOF_INT128__ ) +# define CATCH_CONFIG_INTERNAL_UINT128 +// Unlike GCC, MSVC does not polyfill umul as mulh + mul pair on ARM machines. +// Currently we do not bother doing this ourselves, but we could if it became +// important for perf. +#elif defined( _MSC_VER ) && defined( _M_X64 ) +# define CATCH_CONFIG_INTERNAL_MSVC_UMUL128 +#endif + +#if defined( CATCH_CONFIG_INTERNAL_UINT128 ) && \ + !defined( CATCH_CONFIG_NO_UINT128 ) && \ + !defined( CATCH_CONFIG_UINT128 ) +#define CATCH_CONFIG_UINT128 +#endif + +#if defined( CATCH_CONFIG_INTERNAL_MSVC_UMUL128 ) && \ + !defined( CATCH_CONFIG_NO_MSVC_UMUL128 ) && \ + !defined( CATCH_CONFIG_MSVC_UMUL128 ) +# define CATCH_CONFIG_MSVC_UMUL128 +# include +#endif + + namespace Catch { namespace Detail { @@ -7938,65 +8057,57 @@ namespace Catch { struct ExtendedMultResult { T upper; T lower; - friend bool operator==( ExtendedMultResult const& lhs, - ExtendedMultResult const& rhs ) { - return lhs.upper == rhs.upper && lhs.lower == rhs.lower; + constexpr bool operator==( ExtendedMultResult const& rhs ) const { + return upper == rhs.upper && lower == rhs.lower; } }; - // Returns 128 bit result of multiplying lhs and rhs + /** + * Returns 128 bit result of lhs * rhs using portable C++ code + * + * This implementation is almost twice as fast as naive long multiplication, + * and unlike intrinsic-based approach, it supports constexpr evaluation. + */ constexpr ExtendedMultResult - extendedMult( std::uint64_t lhs, std::uint64_t rhs ) { - // We use the simple long multiplication approach for - // correctness, we can use platform specific builtins - // for performance later. - - // Split the lhs and rhs into two 32bit "digits", so that we can - // do 64 bit arithmetic to handle carry bits. - // 32b 32b 32b 32b - // lhs L1 L2 - // * rhs R1 R2 - // ------------------------ - // | R2 * L2 | - // | R2 * L1 | - // | R1 * L2 | - // | R1 * L1 | - // ------------------------- - // | a | b | c | d | - + extendedMultPortable(std::uint64_t lhs, std::uint64_t rhs) { #define CarryBits( x ) ( x >> 32 ) #define Digits( x ) ( x & 0xFF'FF'FF'FF ) - - auto r2l2 = Digits( rhs ) * Digits( lhs ); - auto r2l1 = Digits( rhs ) * CarryBits( lhs ); - auto r1l2 = CarryBits( rhs ) * Digits( lhs ); - auto r1l1 = CarryBits( rhs ) * CarryBits( lhs ); - - // Sum to columns first - auto d = Digits( r2l2 ); - auto c = CarryBits( r2l2 ) + Digits( r2l1 ) + Digits( r1l2 ); - auto b = CarryBits( r2l1 ) + CarryBits( r1l2 ) + Digits( r1l1 ); - auto a = CarryBits( r1l1 ); - - // Propagate carries between columns - c += CarryBits( d ); - b += CarryBits( c ); - a += CarryBits( b ); - - // Remove the used carries - c = Digits( c ); - b = Digits( b ); - a = Digits( a ); - + std::uint64_t lhs_low = Digits( lhs ); + std::uint64_t rhs_low = Digits( rhs ); + std::uint64_t low_low = ( lhs_low * rhs_low ); + std::uint64_t high_high = CarryBits( lhs ) * CarryBits( rhs ); + + // We add in carry bits from low-low already + std::uint64_t high_low = + ( CarryBits( lhs ) * rhs_low ) + CarryBits( low_low ); + // Note that we can add only low bits from high_low, to avoid + // overflow with large inputs + std::uint64_t low_high = + ( lhs_low * CarryBits( rhs ) ) + Digits( high_low ); + + return { high_high + CarryBits( high_low ) + CarryBits( low_high ), + ( low_high << 32 ) | Digits( low_low ) }; #undef CarryBits #undef Digits + } - return { - a << 32 | b, // upper 64 bits - c << 32 | d // lower 64 bits - }; + //! Returns 128 bit result of lhs * rhs + inline ExtendedMultResult + extendedMult( std::uint64_t lhs, std::uint64_t rhs ) { +#if defined( CATCH_CONFIG_UINT128 ) + auto result = __uint128_t( lhs ) * __uint128_t( rhs ); + return { static_cast( result >> 64 ), + static_cast( result ) }; +#elif defined( CATCH_CONFIG_MSVC_UMUL128 ) + std::uint64_t high; + std::uint64_t low = _umul128( lhs, rhs, &high ); + return { high, low }; +#else + return extendedMultPortable( lhs, rhs ); +#endif } + template constexpr ExtendedMultResult extendedMult( UInt lhs, UInt rhs ) { static_assert( std::is_unsigned::value, @@ -8064,6 +8175,7 @@ namespace Catch { * get by simple casting ([0, ..., INT_MAX, INT_MIN, ..., -1]) */ template + constexpr std::enable_if_t::value, UnsignedType> transposeToNaturalOrder( UnsignedType in ) { static_assert( @@ -8084,6 +8196,7 @@ namespace Catch { template + constexpr std::enable_if_t::value, UnsignedType> transposeToNaturalOrder(UnsignedType in) { static_assert( @@ -8100,22 +8213,6 @@ namespace Catch { namespace Catch { - namespace Detail { - // Indirection to enable make_unsigned behaviour. - template - struct make_unsigned { - using type = std::make_unsigned_t; - }; - - template <> - struct make_unsigned { - using type = uint8_t; - }; - - template - using make_unsigned_t = typename make_unsigned::type; - } - /** * Implementation of uniform distribution on integers. * @@ -8131,14 +8228,14 @@ template class uniform_integer_distribution { static_assert(std::is_integral::value, "..."); - using UnsignedIntegerType = Detail::make_unsigned_t; + using UnsignedIntegerType = Detail::SizedUnsignedType_t; - // We store the left range bound converted to internal representation, - // because it will be used in computation in the () operator. + // Only the left bound is stored, and we store it converted to its + // unsigned image. This avoids having to do the conversions inside + // the operator(), at the cost of having to do the conversion in + // the a() getter. The right bound is only needed in the b() getter, + // so we recompute it there from other stored data. UnsignedIntegerType m_a; - // After initialization, right bound is only used for the b() getter, - // so we keep it in the original type. - IntegerType m_b; // How many different values are there in [a, b]. a == b => 1, can be 0 for distribution over all values in the type. UnsignedIntegerType m_ab_distance; @@ -8151,25 +8248,24 @@ class uniform_integer_distribution { // distribution will be reused many times and this is an optimization. UnsignedIntegerType m_rejection_threshold = 0; - // Assumes m_b and m_a are already filled - UnsignedIntegerType computeDistance() const { - // This overflows and returns 0 if ua == 0 and ub == TYPE_MAX. + static constexpr UnsignedIntegerType computeDistance(IntegerType a, IntegerType b) { + // This overflows and returns 0 if a == 0 and b == TYPE_MAX. // We handle that later when generating the number. - return transposeTo(m_b) - m_a + 1; + return transposeTo(b) - transposeTo(a) + 1; } - static UnsignedIntegerType computeRejectionThreshold(UnsignedIntegerType ab_distance) { + static constexpr UnsignedIntegerType computeRejectionThreshold(UnsignedIntegerType ab_distance) { // distance == 0 means that we will return all possible values from // the type's range, and that we shouldn't reject anything. if ( ab_distance == 0 ) { return 0; } return ( ~ab_distance + 1 ) % ab_distance; } - static UnsignedIntegerType transposeTo(IntegerType in) { + static constexpr UnsignedIntegerType transposeTo(IntegerType in) { return Detail::transposeToNaturalOrder( static_cast( in ) ); } - static IntegerType transposeBack(UnsignedIntegerType in) { + static constexpr IntegerType transposeBack(UnsignedIntegerType in) { return static_cast( Detail::transposeToNaturalOrder(in) ); } @@ -8177,16 +8273,15 @@ class uniform_integer_distribution { public: using result_type = IntegerType; - uniform_integer_distribution( IntegerType a, IntegerType b ): + constexpr uniform_integer_distribution( IntegerType a, IntegerType b ): m_a( transposeTo(a) ), - m_b( b ), - m_ab_distance( computeDistance() ), + m_ab_distance( computeDistance(a, b) ), m_rejection_threshold( computeRejectionThreshold(m_ab_distance) ) { assert( a <= b ); } template - result_type operator()( Generator& g ) { + constexpr result_type operator()( Generator& g ) { // All possible values of result_type are valid. if ( m_ab_distance == 0 ) { return transposeBack( Detail::fillBitsFrom( g ) ); @@ -8204,8 +8299,8 @@ class uniform_integer_distribution { return transposeBack(m_a + emul.upper); } - result_type a() const { return transposeBack(m_a); } - result_type b() const { return m_b; } + constexpr result_type a() const { return transposeBack(m_a); } + constexpr result_type b() const { return transposeBack(m_ab_distance + m_a - 1); } }; } // end namespace Catch @@ -9065,6 +9160,141 @@ namespace Catch { #endif // CATCH_CONFIG_UNCAUGHT_EXCEPTIONS_HPP_INCLUDED +#ifndef CATCH_CONSOLE_COLOUR_HPP_INCLUDED +#define CATCH_CONSOLE_COLOUR_HPP_INCLUDED + + +#include +#include + +namespace Catch { + + enum class ColourMode : std::uint8_t; + class IStream; + + struct Colour { + enum Code { + None = 0, + + White, + Red, + Green, + Blue, + Cyan, + Yellow, + Grey, + + Bright = 0x10, + + BrightRed = Bright | Red, + BrightGreen = Bright | Green, + LightGrey = Bright | Grey, + BrightWhite = Bright | White, + BrightYellow = Bright | Yellow, + + // By intention + FileName = LightGrey, + Warning = BrightYellow, + ResultError = BrightRed, + ResultSuccess = BrightGreen, + ResultExpectedFailure = Warning, + + Error = BrightRed, + Success = Green, + Skip = LightGrey, + + OriginalExpression = Cyan, + ReconstructedExpression = BrightYellow, + + SecondaryText = LightGrey, + Headers = White + }; + }; + + class ColourImpl { + protected: + //! The associated stream of this ColourImpl instance + IStream* m_stream; + public: + ColourImpl( IStream* stream ): m_stream( stream ) {} + + //! RAII wrapper around writing specific colour of text using specific + //! colour impl into a stream. + class ColourGuard { + ColourImpl const* m_colourImpl; + Colour::Code m_code; + bool m_engaged = false; + + public: + //! Does **not** engage the guard/start the colour + ColourGuard( Colour::Code code, + ColourImpl const* colour ); + + ColourGuard( ColourGuard const& rhs ) = delete; + ColourGuard& operator=( ColourGuard const& rhs ) = delete; + + ColourGuard( ColourGuard&& rhs ) noexcept; + ColourGuard& operator=( ColourGuard&& rhs ) noexcept; + + //! Removes colour _if_ the guard was engaged + ~ColourGuard(); + + /** + * Explicitly engages colour for given stream. + * + * The API based on operator<< should be preferred. + */ + ColourGuard& engage( std::ostream& stream ) &; + /** + * Explicitly engages colour for given stream. + * + * The API based on operator<< should be preferred. + */ + ColourGuard&& engage( std::ostream& stream ) &&; + + private: + //! Engages the guard and starts using colour + friend std::ostream& operator<<( std::ostream& lhs, + ColourGuard& guard ) { + guard.engageImpl( lhs ); + return lhs; + } + //! Engages the guard and starts using colour + friend std::ostream& operator<<( std::ostream& lhs, + ColourGuard&& guard) { + guard.engageImpl( lhs ); + return lhs; + } + + void engageImpl( std::ostream& stream ); + + }; + + virtual ~ColourImpl(); // = default + /** + * Creates a guard object for given colour and this colour impl + * + * **Important:** + * the guard starts disengaged, and has to be engaged explicitly. + */ + ColourGuard guardColour( Colour::Code colourCode ); + + private: + virtual void use( Colour::Code colourCode ) const = 0; + }; + + //! Provides ColourImpl based on global config and target compilation platform + Detail::unique_ptr makeColourImpl( ColourMode colourSelection, + IStream* stream ); + + //! Checks if specific colour impl has been compiled into the binary + bool isColourImplAvailable( ColourMode colourSelection ); + +} // end namespace Catch + +#endif // CATCH_CONSOLE_COLOUR_HPP_INCLUDED + + #ifndef CATCH_CONSOLE_WIDTH_HPP_INCLUDED #define CATCH_CONSOLE_WIDTH_HPP_INCLUDED @@ -9280,7 +9510,7 @@ namespace Catch { std::vector> m_enumInfos; - EnumInfo const& registerEnum( StringRef enumName, StringRef allEnums, std::vector const& values) override; + EnumInfo const& registerEnum( StringRef enumName, StringRef allValueNames, std::vector const& values) override; }; std::vector parseEnums( StringRef enums ); @@ -9340,7 +9570,6 @@ namespace Catch { #ifndef CATCH_FATAL_CONDITION_HANDLER_HPP_INCLUDED #define CATCH_FATAL_CONDITION_HANDLER_HPP_INCLUDED - #include namespace Catch { @@ -9529,6 +9758,7 @@ namespace Catch { typename Sentinel, typename T, typename Comparator> + constexpr ForwardIter find_sentinel( ForwardIter start, Sentinel sentinel, T const& value, @@ -9544,6 +9774,7 @@ namespace Catch { typename Sentinel, typename T, typename Comparator> + constexpr std::ptrdiff_t count_sentinel( ForwardIter start, Sentinel sentinel, T const& value, @@ -9557,6 +9788,7 @@ namespace Catch { } template + constexpr std::enable_if_t::value, std::ptrdiff_t> sentinel_distance( ForwardIter iter, const Sentinel sentinel ) { @@ -9569,8 +9801,8 @@ namespace Catch { } template - std::ptrdiff_t sentinel_distance( ForwardIter first, - ForwardIter last ) { + constexpr std::ptrdiff_t sentinel_distance( ForwardIter first, + ForwardIter last ) { return std::distance( first, last ); } @@ -9579,11 +9811,11 @@ namespace Catch { typename ForwardIter2, typename Sentinel2, typename Comparator> - bool check_element_counts( ForwardIter1 first_1, - const Sentinel1 end_1, - ForwardIter2 first_2, - const Sentinel2 end_2, - Comparator cmp ) { + constexpr bool check_element_counts( ForwardIter1 first_1, + const Sentinel1 end_1, + ForwardIter2 first_2, + const Sentinel2 end_2, + Comparator cmp ) { auto cursor = first_1; while ( cursor != end_1 ) { if ( find_sentinel( first_1, cursor, *cursor, cmp ) == @@ -9613,11 +9845,11 @@ namespace Catch { typename ForwardIter2, typename Sentinel2, typename Comparator> - bool is_permutation( ForwardIter1 first_1, - const Sentinel1 end_1, - ForwardIter2 first_2, - const Sentinel2 end_2, - Comparator cmp ) { + constexpr bool is_permutation( ForwardIter1 first_1, + const Sentinel1 end_1, + ForwardIter2 first_2, + const Sentinel2 end_2, + Comparator cmp ) { // TODO: no optimization for stronger iterators, because we would also have to constrain on sentinel vs not sentinel types // TODO: Comparator has to be "both sides", e.g. a == b => b == a // This skips shared prefix of the two ranges @@ -9754,7 +9986,7 @@ namespace Catch { JsonObjectWriter( std::ostream& os ); JsonObjectWriter( std::ostream& os, std::uint64_t indent_level ); - JsonObjectWriter( JsonObjectWriter&& source ); + JsonObjectWriter( JsonObjectWriter&& source ) noexcept; JsonObjectWriter& operator=( JsonObjectWriter&& source ) = delete; ~JsonObjectWriter(); @@ -9773,7 +10005,7 @@ namespace Catch { JsonArrayWriter( std::ostream& os ); JsonArrayWriter( std::ostream& os, std::uint64_t indent_level ); - JsonArrayWriter( JsonArrayWriter&& source ); + JsonArrayWriter( JsonArrayWriter&& source ) noexcept; JsonArrayWriter& operator=( JsonArrayWriter&& source ) = delete; ~JsonArrayWriter(); @@ -9864,106 +10096,67 @@ namespace Catch { #define CATCH_OUTPUT_REDIRECT_HPP_INCLUDED -#include -#include +#include #include namespace Catch { - class RedirectedStream { - std::ostream& m_originalStream; - std::ostream& m_redirectionStream; - std::streambuf* m_prevBuf; - - public: - RedirectedStream( std::ostream& originalStream, std::ostream& redirectionStream ); - ~RedirectedStream(); - }; - - class RedirectedStdOut { - ReusableStringStream m_rss; - RedirectedStream m_cout; - public: - RedirectedStdOut(); - auto str() const -> std::string; - }; - - // StdErr has two constituent streams in C++, std::cerr and std::clog - // This means that we need to redirect 2 streams into 1 to keep proper - // order of writes - class RedirectedStdErr { - ReusableStringStream m_rss; - RedirectedStream m_cerr; - RedirectedStream m_clog; + class OutputRedirect { + bool m_redirectActive = false; + virtual void activateImpl() = 0; + virtual void deactivateImpl() = 0; public: - RedirectedStdErr(); - auto str() const -> std::string; - }; + enum Kind { + //! No redirect (noop implementation) + None, + //! Redirect std::cout/std::cerr/std::clog streams internally + Streams, + //! Redirect the stdout/stderr file descriptors into files + FileDescriptors, + }; - class RedirectedStreams { - public: - RedirectedStreams(RedirectedStreams const&) = delete; - RedirectedStreams& operator=(RedirectedStreams const&) = delete; - RedirectedStreams(RedirectedStreams&&) = delete; - RedirectedStreams& operator=(RedirectedStreams&&) = delete; + virtual ~OutputRedirect(); // = default; - RedirectedStreams(std::string& redirectedCout, std::string& redirectedCerr); - ~RedirectedStreams(); - private: - std::string& m_redirectedCout; - std::string& m_redirectedCerr; - RedirectedStdOut m_redirectedStdOut; - RedirectedStdErr m_redirectedStdErr; + // TODO: Do we want to check that redirect is not active before retrieving the output? + virtual std::string getStdout() = 0; + virtual std::string getStderr() = 0; + virtual void clearBuffers() = 0; + bool isActive() const { return m_redirectActive; } + void activate() { + assert( !m_redirectActive && "redirect is already active" ); + activateImpl(); + m_redirectActive = true; + } + void deactivate() { + assert( m_redirectActive && "redirect is not active" ); + deactivateImpl(); + m_redirectActive = false; + } }; -#if defined(CATCH_CONFIG_NEW_CAPTURE) - - // Windows's implementation of std::tmpfile is terrible (it tries - // to create a file inside system folder, thus requiring elevated - // privileges for the binary), so we have to use tmpnam(_s) and - // create the file ourselves there. - class TempFile { - public: - TempFile(TempFile const&) = delete; - TempFile& operator=(TempFile const&) = delete; - TempFile(TempFile&&) = delete; - TempFile& operator=(TempFile&&) = delete; - - TempFile(); - ~TempFile(); - - std::FILE* getFile(); - std::string getContents(); - - private: - std::FILE* m_file = nullptr; - #if defined(_MSC_VER) - char m_buffer[L_tmpnam] = { 0 }; - #endif - }; + bool isRedirectAvailable( OutputRedirect::Kind kind); + Detail::unique_ptr makeOutputRedirect( bool actual ); + class RedirectGuard { + OutputRedirect* m_redirect; + bool m_activate; + bool m_previouslyActive; + bool m_moved = false; - class OutputRedirect { public: - OutputRedirect(OutputRedirect const&) = delete; - OutputRedirect& operator=(OutputRedirect const&) = delete; - OutputRedirect(OutputRedirect&&) = delete; - OutputRedirect& operator=(OutputRedirect&&) = delete; + RedirectGuard( bool activate, OutputRedirect& redirectImpl ); + ~RedirectGuard() noexcept( false ); + RedirectGuard( RedirectGuard const& ) = delete; + RedirectGuard& operator=( RedirectGuard const& ) = delete; - OutputRedirect(std::string& stdout_dest, std::string& stderr_dest); - ~OutputRedirect(); - - private: - int m_originalStdout = -1; - int m_originalStderr = -1; - TempFile m_stdoutFile; - TempFile m_stderrFile; - std::string& m_stdoutDest; - std::string& m_stderrDest; + // C++14 needs move-able guards to return them from functions + RedirectGuard( RedirectGuard&& rhs ) noexcept; + RedirectGuard& operator=( RedirectGuard&& rhs ) noexcept; }; -#endif + RedirectGuard scopedActivate( OutputRedirect& redirectImpl ); + RedirectGuard scopedDeactivate( OutputRedirect& redirectImpl ); } // end namespace Catch @@ -10286,6 +10479,7 @@ namespace Catch { class IConfig; class IEventListener; using IEventListenerPtr = Detail::unique_ptr; + class OutputRedirect; /////////////////////////////////////////////////////////////////////////// @@ -10311,7 +10505,7 @@ namespace Catch { void handleMessage ( AssertionInfo const& info, ResultWas::OfType resultType, - StringRef message, + std::string&& message, AssertionReaction& reaction ) override; void handleUnexpectedExceptionNotThrown ( AssertionInfo const& info, @@ -10372,7 +10566,7 @@ namespace Catch { private: - void runCurrentTest( std::string& redirectedCout, std::string& redirectedCerr ); + void runCurrentTest(); void invokeActiveTestCase(); void resetAssertionInfo(); @@ -10405,6 +10599,7 @@ namespace Catch { std::vector m_unfinishedSections; std::vector m_activeSections; TrackerContext m_trackerContext; + Detail::unique_ptr m_outputRedirect; FatalConditionHandler m_fatalConditionhandler; bool m_lastAssertionPassed = false; bool m_shouldReportUnexpected = true; @@ -10421,7 +10616,7 @@ namespace Catch { #ifndef CATCH_SHARDING_HPP_INCLUDED #define CATCH_SHARDING_HPP_INCLUDED - +#include #include #include @@ -10662,14 +10857,14 @@ namespace Catch { class TestRegistry : public ITestCaseRegistry { public: - ~TestRegistry() override = default; - void registerTest( Detail::unique_ptr testInfo, Detail::unique_ptr testInvoker ); std::vector const& getAllInfos() const override; std::vector const& getAllTests() const override; std::vector const& getAllTestsSorted( IConfig const& config ) const override; + ~TestRegistry() override; // = default + private: std::vector> m_owned_test_infos; // Keeps a materialized vector for `getAllInfos`. @@ -10769,6 +10964,7 @@ namespace Catch { #ifndef CATCH_TEXTFLOW_HPP_INCLUDED #define CATCH_TEXTFLOW_HPP_INCLUDED + #include #include #include @@ -10778,6 +10974,107 @@ namespace Catch { class Columns; + /** + * Abstraction for a string with ansi escape sequences that + * automatically skips over escapes when iterating. Only graphical + * escape sequences are considered. + * + * Internal representation: + * An escape sequence looks like \033[39;49m + * We need bidirectional iteration and the unbound length of escape + * sequences poses a problem for operator-- To make this work we'll + * replace the last `m` with a 0xff (this is a codepoint that won't have + * any utf-8 meaning). + */ + class AnsiSkippingString { + std::string m_string; + std::size_t m_size = 0; + + // perform 0xff replacement and calculate m_size + void preprocessString(); + + public: + class const_iterator; + using iterator = const_iterator; + // note: must be u-suffixed or this will cause a "truncation of + // constant value" warning on MSVC + static constexpr char sentinel = static_cast( 0xffu ); + + explicit AnsiSkippingString( std::string const& text ); + explicit AnsiSkippingString( std::string&& text ); + + const_iterator begin() const; + const_iterator end() const; + + size_t size() const { return m_size; } + + std::string substring( const_iterator begin, + const_iterator end ) const; + }; + + class AnsiSkippingString::const_iterator { + friend AnsiSkippingString; + struct EndTag {}; + + const std::string* m_string; + std::string::const_iterator m_it; + + explicit const_iterator( const std::string& string, EndTag ): + m_string( &string ), m_it( string.end() ) {} + + void tryParseAnsiEscapes(); + void advance(); + void unadvance(); + + public: + using difference_type = std::ptrdiff_t; + using value_type = char; + using pointer = value_type*; + using reference = value_type&; + using iterator_category = std::bidirectional_iterator_tag; + + explicit const_iterator( const std::string& string ): + m_string( &string ), m_it( string.begin() ) { + tryParseAnsiEscapes(); + } + + char operator*() const { return *m_it; } + + const_iterator& operator++() { + advance(); + return *this; + } + const_iterator operator++( int ) { + iterator prev( *this ); + operator++(); + return prev; + } + const_iterator& operator--() { + unadvance(); + return *this; + } + const_iterator operator--( int ) { + iterator prev( *this ); + operator--(); + return prev; + } + + bool operator==( const_iterator const& other ) const { + return m_it == other.m_it; + } + bool operator!=( const_iterator const& other ) const { + return !operator==( other ); + } + bool operator<=( const_iterator const& other ) const { + return m_it <= other.m_it; + } + + const_iterator oneBefore() const { + auto it = *this; + return --it; + } + }; + /** * Represents a column of text with specific width and indentation * @@ -10787,17 +11084,18 @@ namespace Catch { */ class Column { // String to be written out - std::string m_string; + AnsiSkippingString m_string; // Width of the column for linebreaking size_t m_width = CATCH_CONFIG_CONSOLE_WIDTH - 1; - // Indentation of other lines (including first if initial indent is unset) + // Indentation of other lines (including first if initial indent is + // unset) size_t m_indent = 0; // Indentation of the first line size_t m_initialIndent = std::string::npos; public: /** - * Iterates "lines" in `Column` and return sthem + * Iterates "lines" in `Column` and returns them */ class const_iterator { friend Column; @@ -10805,16 +11103,19 @@ namespace Catch { Column const& m_column; // Where does the current line start? - size_t m_lineStart = 0; + AnsiSkippingString::const_iterator m_lineStart; // How long should the current line be? - size_t m_lineLength = 0; + AnsiSkippingString::const_iterator m_lineEnd; // How far have we checked the string to iterate? - size_t m_parsedTo = 0; + AnsiSkippingString::const_iterator m_parsedTo; // Should a '-' be appended to the line? bool m_addHyphen = false; const_iterator( Column const& column, EndTag ): - m_column( column ), m_lineStart( m_column.m_string.size() ) {} + m_column( column ), + m_lineStart( m_column.m_string.end() ), + m_lineEnd( column.m_string.end() ), + m_parsedTo( column.m_string.end() ) {} // Calculates the length of the current line void calcLength(); @@ -10824,8 +11125,9 @@ namespace Catch { // Creates an indented and (optionally) suffixed string from // current iterator position, indentation and length. - std::string addIndentAndSuffix( size_t position, - size_t length ) const; + std::string addIndentAndSuffix( + AnsiSkippingString::const_iterator start, + AnsiSkippingString::const_iterator end ) const; public: using difference_type = std::ptrdiff_t; @@ -10842,7 +11144,8 @@ namespace Catch { const_iterator operator++( int ); bool operator==( const_iterator const& other ) const { - return m_lineStart == other.m_lineStart && &m_column == &other.m_column; + return m_lineStart == other.m_lineStart && + &m_column == &other.m_column; } bool operator!=( const_iterator const& other ) const { return !operator==( other ); @@ -10851,29 +11154,47 @@ namespace Catch { using iterator = const_iterator; explicit Column( std::string const& text ): m_string( text ) {} + explicit Column( std::string&& text ): + m_string( CATCH_MOVE( text ) ) {} - Column& width( size_t newWidth ) { + Column& width( size_t newWidth ) & { assert( newWidth > 0 ); m_width = newWidth; return *this; } - Column& indent( size_t newIndent ) { + Column&& width( size_t newWidth ) && { + assert( newWidth > 0 ); + m_width = newWidth; + return CATCH_MOVE( *this ); + } + Column& indent( size_t newIndent ) & { m_indent = newIndent; return *this; } - Column& initialIndent( size_t newIndent ) { + Column&& indent( size_t newIndent ) && { + m_indent = newIndent; + return CATCH_MOVE( *this ); + } + Column& initialIndent( size_t newIndent ) & { m_initialIndent = newIndent; return *this; } + Column&& initialIndent( size_t newIndent ) && { + m_initialIndent = newIndent; + return CATCH_MOVE( *this ); + } size_t width() const { return m_width; } const_iterator begin() const { return const_iterator( *this ); } - const_iterator end() const { return { *this, const_iterator::EndTag{} }; } + const_iterator end() const { + return { *this, const_iterator::EndTag{} }; + } friend std::ostream& operator<<( std::ostream& os, Column const& col ); - Columns operator+( Column const& other ); + friend Columns operator+( Column const& lhs, Column const& rhs ); + friend Columns operator+( Column&& lhs, Column&& rhs ); }; //! Creates a column that serves as an empty space of specific width @@ -10917,8 +11238,10 @@ namespace Catch { iterator begin() const { return iterator( *this ); } iterator end() const { return { *this, iterator::EndTag() }; } - Columns& operator+=( Column const& col ); - Columns operator+( Column const& col ); + friend Columns& operator+=( Columns& lhs, Column const& rhs ); + friend Columns& operator+=( Columns& lhs, Column&& rhs ); + friend Columns operator+( Columns const& lhs, Column const& rhs ); + friend Columns operator+( Columns&& lhs, Column&& rhs ); friend std::ostream& operator<<( std::ostream& os, Columns const& cols ); @@ -10967,16 +11290,25 @@ namespace Catch { #include #include +#include namespace Catch { - enum class XmlFormatting { + enum class XmlFormatting : std::uint8_t { None = 0x00, Indent = 0x01, Newline = 0x02, }; - XmlFormatting operator | (XmlFormatting lhs, XmlFormatting rhs); - XmlFormatting operator & (XmlFormatting lhs, XmlFormatting rhs); + constexpr XmlFormatting operator|( XmlFormatting lhs, XmlFormatting rhs ) { + return static_cast( static_cast( lhs ) | + static_cast( rhs ) ); + } + + constexpr XmlFormatting operator&( XmlFormatting lhs, XmlFormatting rhs ) { + return static_cast( static_cast( lhs ) & + static_cast( rhs ) ); + } + /** * Helper for XML-encoding text (escaping angle brackets, quotes, etc) @@ -10988,7 +11320,9 @@ namespace Catch { public: enum ForWhat { ForTextNodes, ForAttributes }; - XmlEncode( StringRef str, ForWhat forWhat = ForTextNodes ); + constexpr XmlEncode( StringRef str, ForWhat forWhat = ForTextNodes ): + m_str( str ), m_forWhat( forWhat ) {} + void encodeTo( std::ostream& os ) const; @@ -11136,12 +11470,22 @@ namespace Catch { namespace Catch { +#ifdef __clang__ +# pragma clang diagnostic push +# pragma clang diagnostic ignored "-Wsign-compare" +# pragma clang diagnostic ignored "-Wnon-virtual-dtor" +#elif defined __GNUC__ +# pragma GCC diagnostic push +# pragma GCC diagnostic ignored "-Wsign-compare" +# pragma GCC diagnostic ignored "-Wnon-virtual-dtor" +#endif + template class MatchExpr : public ITransientExpression { ArgT && m_arg; MatcherT const& m_matcher; public: - MatchExpr( ArgT && arg, MatcherT const& matcher ) + constexpr MatchExpr( ArgT && arg, MatcherT const& matcher ) : ITransientExpression{ true, matcher.match( arg ) }, // not forwarding arg here on purpose m_arg( CATCH_FORWARD(arg) ), m_matcher( matcher ) @@ -11154,6 +11498,13 @@ namespace Catch { } }; +#ifdef __clang__ +# pragma clang diagnostic pop +#elif defined __GNUC__ +# pragma GCC diagnostic pop +#endif + + namespace Matchers { template class MatcherBase; @@ -11164,7 +11515,8 @@ namespace Catch { void handleExceptionMatchExpr( AssertionHandler& handler, StringMatcher const& matcher ); template - auto makeMatchExpr( ArgT && arg, MatcherT const& matcher ) -> MatchExpr { + constexpr MatchExpr + makeMatchExpr( ArgT&& arg, MatcherT const& matcher ) { return MatchExpr( CATCH_FORWARD(arg), matcher ); } @@ -11178,7 +11530,7 @@ namespace Catch { INTERNAL_CATCH_TRY { \ catchAssertionHandler.handleExpr( Catch::makeMatchExpr( arg, matcher ) ); \ } INTERNAL_CATCH_CATCH( catchAssertionHandler ) \ - INTERNAL_CATCH_REACT( catchAssertionHandler ) \ + catchAssertionHandler.complete(); \ } while( false ) @@ -11188,7 +11540,10 @@ namespace Catch { Catch::AssertionHandler catchAssertionHandler( macroName##_catch_sr, CATCH_INTERNAL_LINEINFO, CATCH_INTERNAL_STRINGIFY(__VA_ARGS__) ", " CATCH_INTERNAL_STRINGIFY(exceptionType) ", " CATCH_INTERNAL_STRINGIFY(matcher), resultDisposition ); \ if( catchAssertionHandler.allowThrows() ) \ try { \ + CATCH_INTERNAL_START_WARNINGS_SUPPRESSION \ + CATCH_INTERNAL_SUPPRESS_USELESS_CAST_WARNINGS \ static_cast(__VA_ARGS__ ); \ + CATCH_INTERNAL_STOP_WARNINGS_SUPPRESSION \ catchAssertionHandler.handleUnexpectedExceptionNotThrown(); \ } \ catch( exceptionType const& ex ) { \ @@ -11199,7 +11554,7 @@ namespace Catch { } \ else \ catchAssertionHandler.handleThrowingCallSkipped(); \ - INTERNAL_CATCH_REACT( catchAssertionHandler ) \ + catchAssertionHandler.complete(); \ } while( false ) @@ -12268,12 +12623,14 @@ namespace Catch { public: template + constexpr RangeEqualsMatcher( TargetRangeLike2&& range, Equality2&& predicate ): m_desired( CATCH_FORWARD( range ) ), m_predicate( CATCH_FORWARD( predicate ) ) {} template + constexpr bool match( RangeLike&& rng ) const { auto rng_start = begin( rng ); const auto rng_end = end( rng ); @@ -12306,12 +12663,14 @@ namespace Catch { public: template + constexpr UnorderedRangeEqualsMatcher( TargetRangeLike2&& range, Equality2&& predicate ): m_desired( CATCH_FORWARD( range ) ), m_predicate( CATCH_FORWARD( predicate ) ) {} template + constexpr bool match( RangeLike&& rng ) const { using std::begin; using std::end; @@ -12335,6 +12694,7 @@ namespace Catch { * Uses `std::equal_to` to do the comparison */ template + constexpr std::enable_if_t::value, RangeEqualsMatcher>> RangeEquals( RangeLike&& range ) { @@ -12348,6 +12708,7 @@ namespace Catch { * Uses to provided predicate `predicate` to do the comparisons */ template + constexpr RangeEqualsMatcher RangeEquals( RangeLike&& range, Equality&& predicate ) { return { CATCH_FORWARD( range ), CATCH_FORWARD( predicate ) }; @@ -12360,6 +12721,7 @@ namespace Catch { * Uses `std::equal_to` to do the comparison */ template + constexpr std::enable_if_t< !Detail::is_matcher::value, UnorderedRangeEqualsMatcher>> @@ -12374,6 +12736,7 @@ namespace Catch { * Uses to provided predicate `predicate` to do the comparisons */ template + constexpr UnorderedRangeEqualsMatcher UnorderedRangeEquals( RangeLike&& range, Equality&& predicate ) { return { CATCH_FORWARD( range ), CATCH_FORWARD( predicate ) }; @@ -13312,8 +13675,6 @@ namespace Catch { public: JunitReporter(ReporterConfig&& _config); - ~JunitReporter() override = default; - static std::string getDescription(); void testRunStarting(TestRunInfo const& runInfo) override; @@ -13398,7 +13759,7 @@ namespace Catch { void assertionEnded( AssertionStats const& assertionStats ) override; void sectionEnded( SectionStats const& sectionStats ) override; - void testCasePartialEnded(TestCaseStats const& testInfo, uint64_t partNumber) override; + void testCasePartialEnded(TestCaseStats const& testStats, uint64_t partNumber) override; void testCaseEnded( TestCaseStats const& testCaseStats ) override; void testRunEnded( TestRunStats const& testRunStats ) override; @@ -13550,12 +13911,10 @@ namespace Catch { : CumulativeReporterBase(CATCH_MOVE(config)) , xml(m_stream) { m_preferences.shouldRedirectStdOut = true; - m_preferences.shouldReportAllAssertions = true; + m_preferences.shouldReportAllAssertions = false; m_shouldStoreSuccesfulAssertions = false; } - ~SonarQubeReporter() override = default; - static std::string getDescription() { using namespace std::string_literals; return "Reports test results in the Generic Test Data SonarQube XML format"s; @@ -13568,7 +13927,7 @@ namespace Catch { xml.endElement(); } - void writeRun( TestRunNode const& groupNode ); + void writeRun( TestRunNode const& runNode ); void writeTestFile(StringRef filename, std::vector const& testCaseNodes); @@ -13602,7 +13961,6 @@ namespace Catch { StreamingReporterBase( CATCH_MOVE(config) ) { m_preferences.shouldReportAllAssertions = true; } - ~TAPReporter() override = default; static std::string getDescription() { using namespace std::string_literals; @@ -13654,8 +14012,8 @@ namespace Catch { return "Reports test results as TeamCity service messages"s; } - void testRunStarting( TestRunInfo const& groupInfo ) override; - void testRunEnded( TestRunStats const& testGroupStats ) override; + void testRunStarting( TestRunInfo const& runInfo ) override; + void testRunEnded( TestRunStats const& runStats ) override; void assertionEnded(AssertionStats const& assertionStats) override; diff --git a/meson.build b/meson.build index 1c5b80a198..99bf3aff31 100644 --- a/meson.build +++ b/meson.build @@ -8,7 +8,7 @@ project( 'catch2', 'cpp', - version: '3.5.0', # CML version placeholder, don't delete + version: '3.7.1', # CML version placeholder, don't delete license: 'BSL-1.0', meson_version: '>=0.54.1', ) diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index d01aab2d5c..c40de040e2 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -48,6 +48,7 @@ set(IMPL_HEADERS ${SOURCES_DIR}/catch_approx.hpp ${SOURCES_DIR}/catch_assertion_info.hpp ${SOURCES_DIR}/catch_assertion_result.hpp + ${SOURCES_DIR}/catch_case_sensitive.hpp ${SOURCES_DIR}/catch_config.hpp ${SOURCES_DIR}/catch_get_random_seed.hpp ${SOURCES_DIR}/catch_message.hpp @@ -67,13 +68,13 @@ set(IMPL_HEADERS ${SOURCES_DIR}/catch_version_macros.hpp ${SOURCES_DIR}/internal/catch_assertion_handler.hpp ${SOURCES_DIR}/internal/catch_case_insensitive_comparisons.hpp - ${SOURCES_DIR}/internal/catch_case_sensitive.hpp ${SOURCES_DIR}/internal/catch_clara.hpp ${SOURCES_DIR}/internal/catch_commandline.hpp ${SOURCES_DIR}/internal/catch_compare_traits.hpp ${SOURCES_DIR}/internal/catch_compiler_capabilities.hpp ${SOURCES_DIR}/internal/catch_config_android_logwrite.hpp ${SOURCES_DIR}/internal/catch_config_counter.hpp + ${SOURCES_DIR}/internal/catch_config_prefix_messages.hpp ${SOURCES_DIR}/internal/catch_config_static_analysis_support.hpp ${SOURCES_DIR}/internal/catch_config_uncaught_exceptions.hpp ${SOURCES_DIR}/internal/catch_config_wchar.hpp @@ -194,7 +195,6 @@ set(IMPL_SOURCES ${SOURCES_DIR}/internal/catch_random_seed_generation.cpp ${SOURCES_DIR}/internal/catch_reporter_registry.cpp ${SOURCES_DIR}/internal/catch_reporter_spec_parser.cpp - ${SOURCES_DIR}/internal/catch_result_type.cpp ${SOURCES_DIR}/internal/catch_reusable_string_stream.cpp ${SOURCES_DIR}/internal/catch_run_context.cpp ${SOURCES_DIR}/internal/catch_section.cpp @@ -348,11 +348,13 @@ source_group("generated headers" ) add_library(Catch2 ${ALL_FILES}) -add_build_reproducibility_settings(Catch2) +if (CATCH_ENABLE_REPRODUCIBLE_BUILD) + add_build_reproducibility_settings(Catch2) +endif() add_library(Catch2::Catch2 ALIAS Catch2) if (ANDROID) - target_link_libraries(Catch2 INTERFACE log) + target_link_libraries(Catch2 PRIVATE log) endif() set_target_properties(Catch2 PROPERTIES @@ -360,29 +362,10 @@ set_target_properties(Catch2 PROPERTIES VERSION ${PROJECT_VERSION} SOVERSION ${PROJECT_VERSION}) -# depend on bunch of C++11 and C++14 features to have C++14 enabled by default +# require C++14 target_compile_features(Catch2 PUBLIC - cxx_alignas - cxx_alignof - cxx_attributes - cxx_auto_type - cxx_constexpr - cxx_defaulted_functions - cxx_deleted_functions - cxx_final - cxx_lambdas - cxx_noexcept - cxx_override - cxx_range_for - cxx_rvalue_references - cxx_static_assert - cxx_strong_enums - cxx_trailing_return_types - cxx_unicode_literals - cxx_user_literals - cxx_variable_templates - cxx_variadic_macros + cxx_std_14 ) configure_file( @@ -401,7 +384,9 @@ target_include_directories(Catch2 add_library(Catch2WithMain ${SOURCES_DIR}/internal/catch_main.cpp ) -add_build_reproducibility_settings(Catch2WithMain) +if (CATCH_ENABLE_REPRODUCIBLE_BUILD) + add_build_reproducibility_settings(Catch2WithMain) +endif() add_library(Catch2::Catch2WithMain ALIAS Catch2WithMain) target_link_libraries(Catch2WithMain PUBLIC Catch2) set_target_properties(Catch2WithMain @@ -471,26 +456,7 @@ if (CATCH_BUILD_EXAMPLES OR CATCH_BUILD_EXTRA_TESTS) ) target_compile_features(Catch2_buildall_interface INTERFACE - cxx_alignas - cxx_alignof - cxx_attributes - cxx_auto_type - cxx_constexpr - cxx_defaulted_functions - cxx_deleted_functions - cxx_final - cxx_lambdas - cxx_noexcept - cxx_override - cxx_range_for - cxx_rvalue_references - cxx_static_assert - cxx_strong_enums - cxx_trailing_return_types - cxx_unicode_literals - cxx_user_literals - cxx_variable_templates - cxx_variadic_macros + cxx_std_14 ) endif() diff --git a/src/catch2/benchmark/catch_benchmark.hpp b/src/catch2/benchmark/catch_benchmark.hpp index 3db40bb048..d0f88cfc23 100644 --- a/src/catch2/benchmark/catch_benchmark.hpp +++ b/src/catch2/benchmark/catch_benchmark.hpp @@ -45,12 +45,12 @@ namespace Catch { : fun(CATCH_MOVE(func)), name(CATCH_MOVE(benchmarkName)) {} template - ExecutionPlan prepare(const IConfig &cfg, Environment env) const { + ExecutionPlan prepare(const IConfig &cfg, Environment env) { auto min_time = env.clock_resolution.mean * Detail::minimum_ticks; auto run_time = std::max(min_time, std::chrono::duration_cast(cfg.benchmarkWarmupTime())); auto&& test = Detail::run_for_at_least(std::chrono::duration_cast(run_time), 1, fun); int new_iters = static_cast(std::ceil(min_time * test.iterations / test.elapsed)); - return { new_iters, test.elapsed / test.iterations * new_iters * cfg.benchmarkSamples(), fun, std::chrono::duration_cast(cfg.benchmarkWarmupTime()), Detail::warmup_iterations }; + return { new_iters, test.elapsed / test.iterations * new_iters * cfg.benchmarkSamples(), CATCH_MOVE(fun), std::chrono::duration_cast(cfg.benchmarkWarmupTime()), Detail::warmup_iterations }; } template diff --git a/src/catch2/benchmark/catch_outlier_classification.hpp b/src/catch2/benchmark/catch_outlier_classification.hpp index e31d65d4a2..b9a11782a0 100644 --- a/src/catch2/benchmark/catch_outlier_classification.hpp +++ b/src/catch2/benchmark/catch_outlier_classification.hpp @@ -19,7 +19,7 @@ namespace Catch { int high_mild = 0; // 1.5 to 3 times IQR above Q3 int high_severe = 0; // more than 3 times IQR above Q3 - int total() const { + constexpr int total() const { return low_severe + low_mild + high_mild + high_severe; } }; diff --git a/src/catch2/benchmark/detail/catch_analyse.cpp b/src/catch2/benchmark/detail/catch_analyse.cpp index 7d27daf195..14d7f4506d 100644 --- a/src/catch2/benchmark/detail/catch_analyse.cpp +++ b/src/catch2/benchmark/detail/catch_analyse.cpp @@ -63,8 +63,8 @@ namespace Catch { FDuration mean = FDuration(0); int i = 0; for (auto it = first; it < last; ++it, ++i) { - samples.push_back(FDuration(*it)); - mean += FDuration(*it); + samples.push_back(*it); + mean += *it; } mean /= i; diff --git a/src/catch2/benchmark/detail/catch_benchmark_function.cpp b/src/catch2/benchmark/detail/catch_benchmark_function.cpp index b437d04929..66d4e619b4 100644 --- a/src/catch2/benchmark/detail/catch_benchmark_function.cpp +++ b/src/catch2/benchmark/detail/catch_benchmark_function.cpp @@ -11,7 +11,13 @@ namespace Catch { namespace Benchmark { namespace Detail { + struct do_nothing { + void operator()() const {} + }; + BenchmarkFunction::callable::~callable() = default; + BenchmarkFunction::BenchmarkFunction(): + f( new model{ {} } ){} } // namespace Detail } // namespace Benchmark } // namespace Catch diff --git a/src/catch2/benchmark/detail/catch_benchmark_function.hpp b/src/catch2/benchmark/detail/catch_benchmark_function.hpp index 144e4b6e43..a03cb112fb 100644 --- a/src/catch2/benchmark/detail/catch_benchmark_function.hpp +++ b/src/catch2/benchmark/detail/catch_benchmark_function.hpp @@ -35,22 +35,17 @@ namespace Catch { private: struct callable { virtual void call(Chronometer meter) const = 0; - virtual Catch::Detail::unique_ptr clone() const = 0; virtual ~callable(); // = default; callable() = default; - callable(callable const&) = default; - callable& operator=(callable const&) = default; + callable(callable&&) = default; + callable& operator=(callable&&) = default; }; template struct model : public callable { model(Fun&& fun_) : fun(CATCH_MOVE(fun_)) {} model(Fun const& fun_) : fun(fun_) {} - Catch::Detail::unique_ptr clone() const override { - return Catch::Detail::make_unique>( *this ); - } - void call(Chronometer meter) const override { call(meter, is_callable()); } @@ -64,14 +59,8 @@ namespace Catch { Fun fun; }; - struct do_nothing { void operator()() const {} }; - - template - BenchmarkFunction(model* c) : f(c) {} - public: - BenchmarkFunction() - : f(new model{ {} }) {} + BenchmarkFunction(); template ::value, int> = 0> @@ -81,20 +70,12 @@ namespace Catch { BenchmarkFunction( BenchmarkFunction&& that ) noexcept: f( CATCH_MOVE( that.f ) ) {} - BenchmarkFunction(BenchmarkFunction const& that) - : f(that.f->clone()) {} - BenchmarkFunction& operator=( BenchmarkFunction&& that ) noexcept { f = CATCH_MOVE( that.f ); return *this; } - BenchmarkFunction& operator=(BenchmarkFunction const& that) { - f = that.f->clone(); - return *this; - } - void operator()(Chronometer meter) const { f->call(meter); } private: diff --git a/src/catch2/benchmark/detail/catch_estimate_clock.hpp b/src/catch2/benchmark/detail/catch_estimate_clock.hpp index 918484a90f..6da24ce536 100644 --- a/src/catch2/benchmark/detail/catch_estimate_clock.hpp +++ b/src/catch2/benchmark/detail/catch_estimate_clock.hpp @@ -27,15 +27,17 @@ namespace Catch { namespace Detail { template std::vector resolution(int k) { - std::vector> times; - times.reserve(static_cast(k + 1)); - for ( int i = 0; i < k + 1; ++i ) { - times.push_back( Clock::now() ); + const size_t points = static_cast( k + 1 ); + // To avoid overhead from the branch inside vector::push_back, + // we allocate them all and then overwrite. + std::vector> times(points); + for ( auto& time : times ) { + time = Clock::now(); } std::vector deltas; deltas.reserve(static_cast(k)); - for ( size_t idx = 1; idx < times.size(); ++idx ) { + for ( size_t idx = 1; idx < points; ++idx ) { deltas.push_back( static_cast( ( times[idx] - times[idx - 1] ).count() ) ); } @@ -55,12 +57,12 @@ namespace Catch { template int warmup() { - return run_for_at_least(std::chrono::duration_cast(warmup_time), warmup_seed, &resolution) + return run_for_at_least(warmup_time, warmup_seed, &resolution) .iterations; } template EnvironmentEstimate estimate_clock_resolution(int iterations) { - auto r = run_for_at_least(std::chrono::duration_cast(clock_resolution_estimation_time), iterations, &resolution) + auto r = run_for_at_least(clock_resolution_estimation_time, iterations, &resolution) .result; return { FDuration(mean(r.data(), r.data() + r.size())), @@ -82,7 +84,7 @@ namespace Catch { }; time_clock(1); int iters = clock_cost_estimation_iterations; - auto&& r = run_for_at_least(std::chrono::duration_cast(clock_cost_estimation_time), iters, time_clock); + auto&& r = run_for_at_least(clock_cost_estimation_time, iters, time_clock); std::vector times; int nsamples = static_cast(std::ceil(time_limit / r.elapsed)); times.reserve(static_cast(nsamples)); diff --git a/src/catch2/benchmark/detail/catch_measure.hpp b/src/catch2/benchmark/detail/catch_measure.hpp index 37494a68f6..a8049072a2 100644 --- a/src/catch2/benchmark/detail/catch_measure.hpp +++ b/src/catch2/benchmark/detail/catch_measure.hpp @@ -20,7 +20,7 @@ namespace Catch { template TimingOf measure(Fun&& fun, Args&&... args) { auto start = Clock::now(); - auto&& r = Detail::complete_invoke(fun, CATCH_FORWARD(args)...); + auto&& r = Detail::complete_invoke(CATCH_FORWARD(fun), CATCH_FORWARD(args)...); auto end = Clock::now(); auto delta = end - start; return { delta, CATCH_FORWARD(r), 1 }; diff --git a/src/catch2/benchmark/detail/catch_stats.cpp b/src/catch2/benchmark/detail/catch_stats.cpp index 2dd2d864f8..e6de359c44 100644 --- a/src/catch2/benchmark/detail/catch_stats.cpp +++ b/src/catch2/benchmark/detail/catch_stats.cpp @@ -12,6 +12,7 @@ #include #include #include +#include #include #include @@ -38,21 +39,16 @@ namespace Catch { double const* last, Estimator& estimator ) { auto n = static_cast( last - first ); - std::uniform_int_distribution dist( 0, - n - 1 ); + Catch::uniform_integer_distribution dist( 0, n - 1 ); sample out; out.reserve( resamples ); - // We allocate the vector outside the loop to avoid realloc - // per resample std::vector resampled; resampled.reserve( n ); for ( size_t i = 0; i < resamples; ++i ) { resampled.clear(); for ( size_t s = 0; s < n; ++s ) { - resampled.push_back( - first[static_cast( - dist( rng ) )] ); + resampled.push_back( first[dist( rng )] ); } const auto estimate = estimator( resampled.data(), resampled.data() + resampled.size() ); diff --git a/src/catch2/catch_all.hpp b/src/catch2/catch_all.hpp index f2cc853659..5715995507 100644 --- a/src/catch2/catch_all.hpp +++ b/src/catch2/catch_all.hpp @@ -26,6 +26,7 @@ #include #include #include +#include #include #include #include @@ -47,7 +48,6 @@ #include #include #include -#include #include #include #include diff --git a/src/catch2/catch_approx.cpp b/src/catch2/catch_approx.cpp index 9ad4ce3ee7..08c6799b13 100644 --- a/src/catch2/catch_approx.cpp +++ b/src/catch2/catch_approx.cpp @@ -25,7 +25,7 @@ bool marginComparison(double lhs, double rhs, double margin) { namespace Catch { Approx::Approx ( double value ) - : m_epsilon( std::numeric_limits::epsilon()*100. ), + : m_epsilon( static_cast(std::numeric_limits::epsilon())*100. ), m_margin( 0.0 ), m_scale( 0.0 ), m_value( value ) diff --git a/src/catch2/catch_assertion_result.cpp b/src/catch2/catch_assertion_result.cpp index 61d4fd068a..dba86229f4 100644 --- a/src/catch2/catch_assertion_result.cpp +++ b/src/catch2/catch_assertion_result.cpp @@ -11,7 +11,7 @@ namespace Catch { - AssertionResultData::AssertionResultData(ResultWas::OfType _resultType, LazyExpression const & _lazyExpression): + AssertionResultData::AssertionResultData(ResultWas::OfType _resultType, LazyExpression const& _lazyExpression): lazyExpression(_lazyExpression), resultType(_resultType) {} diff --git a/src/catch2/internal/catch_case_sensitive.hpp b/src/catch2/catch_case_sensitive.hpp similarity index 100% rename from src/catch2/internal/catch_case_sensitive.hpp rename to src/catch2/catch_case_sensitive.hpp diff --git a/src/catch2/catch_config.cpp b/src/catch2/catch_config.cpp index 34f50f1751..352c1f424a 100644 --- a/src/catch2/catch_config.cpp +++ b/src/catch2/catch_config.cpp @@ -107,14 +107,16 @@ namespace Catch { // Insert the default reporter if user hasn't asked for a specific one if ( m_data.reporterSpecifications.empty() ) { - m_data.reporterSpecifications.push_back( { #if defined( CATCH_CONFIG_DEFAULT_REPORTER ) - CATCH_CONFIG_DEFAULT_REPORTER, + const auto default_spec = CATCH_CONFIG_DEFAULT_REPORTER; #else - "console", + const auto default_spec = "console"; #endif - {}, {}, {} - } ); + auto parsed = parseReporterSpec(default_spec); + CATCH_ENFORCE( parsed, + "Cannot parse the provided default reporter spec: '" + << default_spec << '\'' ); + m_data.reporterSpecifications.push_back( std::move( *parsed ) ); } if ( enableBazelEnvSupport() ) { diff --git a/src/catch2/catch_config.hpp b/src/catch2/catch_config.hpp index 784de4aa5b..17e983e5cc 100644 --- a/src/catch2/catch_config.hpp +++ b/src/catch2/catch_config.hpp @@ -69,7 +69,7 @@ namespace Catch { bool benchmarkNoAnalysis = false; unsigned int benchmarkSamples = 100; double benchmarkConfidenceInterval = 0.95; - unsigned int benchmarkResamples = 100000; + unsigned int benchmarkResamples = 100'000; std::chrono::milliseconds::rep benchmarkWarmupTime = 100; Verbosity verbosity = Verbosity::Normal; diff --git a/src/catch2/catch_message.cpp b/src/catch2/catch_message.cpp index 384f180e55..7b09ab8745 100644 --- a/src/catch2/catch_message.cpp +++ b/src/catch2/catch_message.cpp @@ -91,6 +91,8 @@ namespace Catch { m_messages.back().message += " := "; start = pos; } + break; + default:; // noop } } assert(openings.empty() && "Mismatched openings"); diff --git a/src/catch2/catch_message.hpp b/src/catch2/catch_message.hpp index 05325ee8f5..0a738341c2 100644 --- a/src/catch2/catch_message.hpp +++ b/src/catch2/catch_message.hpp @@ -94,7 +94,7 @@ namespace Catch { do { \ Catch::AssertionHandler catchAssertionHandler( macroName##_catch_sr, CATCH_INTERNAL_LINEINFO, Catch::StringRef(), resultDisposition ); \ catchAssertionHandler.handleMessage( messageType, ( Catch::MessageStream() << __VA_ARGS__ + ::Catch::StreamEndStop() ).m_stream.str() ); \ - INTERNAL_CATCH_REACT( catchAssertionHandler ) \ + catchAssertionHandler.complete(); \ } while( false ) /////////////////////////////////////////////////////////////////////////////// diff --git a/src/catch2/catch_registry_hub.cpp b/src/catch2/catch_registry_hub.cpp index 8716db3a7d..3a594678ba 100644 --- a/src/catch2/catch_registry_hub.cpp +++ b/src/catch2/catch_registry_hub.cpp @@ -20,7 +20,6 @@ #include #include #include -#include #include diff --git a/src/catch2/catch_session.cpp b/src/catch2/catch_session.cpp index f1ed5f9cc5..a4a410c96c 100644 --- a/src/catch2/catch_session.cpp +++ b/src/catch2/catch_session.cpp @@ -34,7 +34,13 @@ namespace Catch { namespace { - const int MaxExitCode = 255; + static constexpr int TestFailureExitCode = 42; + static constexpr int UnspecifiedErrorExitCode = 1; + static constexpr int AllTestsSkippedExitCode = 4; + static constexpr int NoTestsRunExitCode = 2; + static constexpr int UnmatchedTestSpecExitCode = 3; + static constexpr int InvalidTestSpecExitCode = 5; + IEventListenerPtr createReporter(std::string const& reporterName, ReporterConfig&& config) { auto reporter = Catch::getRegistryHub().getReporterRegistry().create(reporterName, CATCH_MOVE(config)); @@ -198,8 +204,7 @@ namespace Catch { } int Session::applyCommandLine( int argc, char const * const * argv ) { - if( m_startupExceptions ) - return 1; + if ( m_startupExceptions ) { return UnspecifiedErrorExitCode; } auto result = m_cli.parse( Clara::Args( argc, argv ) ); @@ -215,7 +220,7 @@ namespace Catch { << TextFlow::Column( result.errorMessage() ).indent( 2 ) << "\n\n"; errStream->stream() << "Run with -? for usage\n\n" << std::flush; - return MaxExitCode; + return UnspecifiedErrorExitCode; } if( m_configData.showHelp ) @@ -285,8 +290,7 @@ namespace Catch { } int Session::runInternal() { - if( m_startupExceptions ) - return 1; + if ( m_startupExceptions ) { return UnspecifiedErrorExitCode; } if (m_configData.showHelp || m_configData.libIdentify) { return 0; @@ -297,7 +301,7 @@ namespace Catch { << ") must be greater than the shard index (" << m_configData.shardIndex << ")\n" << std::flush; - return 1; + return UnspecifiedErrorExitCode; } CATCH_TRY { @@ -320,7 +324,7 @@ namespace Catch { for ( auto const& spec : invalidSpecs ) { reporter->reportInvalidTestSpec( spec ); } - return 1; + return InvalidTestSpecExitCode; } @@ -334,29 +338,29 @@ namespace Catch { if ( tests.hadUnmatchedTestSpecs() && m_config->warnAboutUnmatchedTestSpecs() ) { - return 3; + // UnmatchedTestSpecExitCode + return UnmatchedTestSpecExitCode; } if ( totals.testCases.total() == 0 && !m_config->zeroTestsCountAsSuccess() ) { - return 2; + return NoTestsRunExitCode; } if ( totals.testCases.total() > 0 && totals.testCases.total() == totals.testCases.skipped && !m_config->zeroTestsCountAsSuccess() ) { - return 4; + return AllTestsSkippedExitCode; } - // Note that on unices only the lower 8 bits are usually used, clamping - // the return value to 255 prevents false negative when some multiple - // of 256 tests has failed - return (std::min) (MaxExitCode, static_cast(totals.assertions.failed)); + if ( totals.assertions.failed ) { return TestFailureExitCode; } + return 0; + } #if !defined(CATCH_CONFIG_DISABLE_EXCEPTIONS) catch( std::exception& ex ) { Catch::cerr() << ex.what() << '\n' << std::flush; - return MaxExitCode; + return UnspecifiedErrorExitCode; } #endif } diff --git a/src/catch2/catch_test_case_info.cpp b/src/catch2/catch_test_case_info.cpp index e9dad57787..9d64e532a6 100644 --- a/src/catch2/catch_test_case_info.cpp +++ b/src/catch2/catch_test_case_info.cpp @@ -9,6 +9,7 @@ #include #include #include +#include #include #include @@ -21,26 +22,26 @@ namespace Catch { static_assert(sizeof(TestCaseProperties) == sizeof(TCP_underlying_type), "The size of the TestCaseProperties is different from the assumed size"); - TestCaseProperties operator|(TestCaseProperties lhs, TestCaseProperties rhs) { + constexpr TestCaseProperties operator|(TestCaseProperties lhs, TestCaseProperties rhs) { return static_cast( static_cast(lhs) | static_cast(rhs) ); } - TestCaseProperties& operator|=(TestCaseProperties& lhs, TestCaseProperties rhs) { + constexpr TestCaseProperties& operator|=(TestCaseProperties& lhs, TestCaseProperties rhs) { lhs = static_cast( static_cast(lhs) | static_cast(rhs) ); return lhs; } - TestCaseProperties operator&(TestCaseProperties lhs, TestCaseProperties rhs) { + constexpr TestCaseProperties operator&(TestCaseProperties lhs, TestCaseProperties rhs) { return static_cast( static_cast(lhs) & static_cast(rhs) ); } - bool applies(TestCaseProperties tcp) { + constexpr bool applies(TestCaseProperties tcp) { static_assert(static_cast(TestCaseProperties::None) == 0, "TestCaseProperties::None must be equal to 0"); return tcp != TestCaseProperties::None; @@ -79,13 +80,15 @@ namespace Catch { return "Anonymous test case " + std::to_string(++counter); } - StringRef extractFilenamePart(StringRef filename) { + constexpr StringRef extractFilenamePart(StringRef filename) { size_t lastDot = filename.size(); while (lastDot > 0 && filename[lastDot - 1] != '.') { --lastDot; } - --lastDot; + // In theory we could have filename without any extension in it + if ( lastDot == 0 ) { return StringRef(); } + --lastDot; size_t nameStart = lastDot; while (nameStart > 0 && filename[nameStart - 1] != '/' && filename[nameStart - 1] != '\\') { --nameStart; @@ -95,7 +98,7 @@ namespace Catch { } // Returns the upper bound on size of extra tags ([#file]+[.]) - size_t sizeOfExtraTags(StringRef filepath) { + constexpr size_t sizeOfExtraTags(StringRef filepath) { // [.] is 3, [#] is another 3 const size_t extras = 3 + 3; return extractFilenamePart(filepath).size() + extras; @@ -256,8 +259,4 @@ namespace Catch { return lhs.tags < rhs.tags; } - TestCaseInfo const& TestCaseHandle::getTestCaseInfo() const { - return *m_info; - } - } // end namespace Catch diff --git a/src/catch2/catch_test_case_info.hpp b/src/catch2/catch_test_case_info.hpp index 5ff3e3e720..3466660c0a 100644 --- a/src/catch2/catch_test_case_info.hpp +++ b/src/catch2/catch_test_case_info.hpp @@ -8,10 +8,10 @@ #ifndef CATCH_TEST_CASE_INFO_HPP_INCLUDED #define CATCH_TEST_CASE_INFO_HPP_INCLUDED +#include #include #include #include -#include #include @@ -44,6 +44,7 @@ namespace Catch { }; class ITestInvoker; + struct NameAndTags; enum class TestCaseProperties : uint8_t { None = 0, @@ -67,7 +68,7 @@ namespace Catch { struct TestCaseInfo : Detail::NonCopyable { TestCaseInfo(StringRef _className, - NameAndTags const& _tags, + NameAndTags const& _nameAndTags, SourceLineInfo const& _lineInfo); bool isHidden() const; @@ -108,14 +109,24 @@ namespace Catch { TestCaseInfo* m_info; ITestInvoker* m_invoker; public: - TestCaseHandle(TestCaseInfo* info, ITestInvoker* invoker) : + constexpr TestCaseHandle(TestCaseInfo* info, ITestInvoker* invoker) : m_info(info), m_invoker(invoker) {} + void prepareTestCase() const { + m_invoker->prepareTestCase(); + } + + void tearDownTestCase() const { + m_invoker->tearDownTestCase(); + } + void invoke() const { m_invoker->invoke(); } - TestCaseInfo const& getTestCaseInfo() const; + constexpr TestCaseInfo const& getTestCaseInfo() const { + return *m_info; + } }; Detail::unique_ptr diff --git a/src/catch2/catch_test_macros.hpp b/src/catch2/catch_test_macros.hpp index 1088afbedd..6ee2129f85 100644 --- a/src/catch2/catch_test_macros.hpp +++ b/src/catch2/catch_test_macros.hpp @@ -43,6 +43,7 @@ #define CATCH_TEST_CASE( ... ) INTERNAL_CATCH_TESTCASE( __VA_ARGS__ ) #define CATCH_TEST_CASE_METHOD( className, ... ) INTERNAL_CATCH_TEST_CASE_METHOD( className, __VA_ARGS__ ) #define CATCH_METHOD_AS_TEST_CASE( method, ... ) INTERNAL_CATCH_METHOD_AS_TEST_CASE( method, __VA_ARGS__ ) + #define CATCH_TEST_CASE_PERSISTENT_FIXTURE( className, ... ) INTERNAL_CATCH_TEST_CASE_PERSISTENT_FIXTURE( className, __VA_ARGS__ ) #define CATCH_REGISTER_TEST_CASE( Function, ... ) INTERNAL_CATCH_REGISTER_TESTCASE( Function, __VA_ARGS__ ) #define CATCH_SECTION( ... ) INTERNAL_CATCH_SECTION( __VA_ARGS__ ) #define CATCH_DYNAMIC_SECTION( ... ) INTERNAL_CATCH_DYNAMIC_SECTION( __VA_ARGS__ ) @@ -97,6 +98,7 @@ #define CATCH_TEST_CASE( ... ) INTERNAL_CATCH_TESTCASE_NO_REGISTRATION(INTERNAL_CATCH_UNIQUE_NAME( CATCH2_INTERNAL_TEST_ )) #define CATCH_TEST_CASE_METHOD( className, ... ) INTERNAL_CATCH_TESTCASE_NO_REGISTRATION(INTERNAL_CATCH_UNIQUE_NAME( CATCH2_INTERNAL_TEST_ )) #define CATCH_METHOD_AS_TEST_CASE( method, ... ) + #define CATCH_TEST_CASE_PERSISTENT_FIXTURE( className, ... ) INTERNAL_CATCH_TESTCASE_NO_REGISTRATION(INTERNAL_CATCH_UNIQUE_NAME( CATCH2_INTERNAL_TEST_ )) #define CATCH_REGISTER_TEST_CASE( Function, ... ) (void)(0) #define CATCH_SECTION( ... ) #define CATCH_DYNAMIC_SECTION( ... ) @@ -142,6 +144,7 @@ #define TEST_CASE( ... ) INTERNAL_CATCH_TESTCASE( __VA_ARGS__ ) #define TEST_CASE_METHOD( className, ... ) INTERNAL_CATCH_TEST_CASE_METHOD( className, __VA_ARGS__ ) #define METHOD_AS_TEST_CASE( method, ... ) INTERNAL_CATCH_METHOD_AS_TEST_CASE( method, __VA_ARGS__ ) + #define TEST_CASE_PERSISTENT_FIXTURE( className, ... ) INTERNAL_CATCH_TEST_CASE_PERSISTENT_FIXTURE( className, __VA_ARGS__ ) #define REGISTER_TEST_CASE( Function, ... ) INTERNAL_CATCH_REGISTER_TESTCASE( Function, __VA_ARGS__ ) #define SECTION( ... ) INTERNAL_CATCH_SECTION( __VA_ARGS__ ) #define DYNAMIC_SECTION( ... ) INTERNAL_CATCH_DYNAMIC_SECTION( __VA_ARGS__ ) @@ -195,6 +198,7 @@ #define TEST_CASE( ... ) INTERNAL_CATCH_TESTCASE_NO_REGISTRATION(INTERNAL_CATCH_UNIQUE_NAME( CATCH2_INTERNAL_TEST_ ), __VA_ARGS__) #define TEST_CASE_METHOD( className, ... ) INTERNAL_CATCH_TESTCASE_NO_REGISTRATION(INTERNAL_CATCH_UNIQUE_NAME( CATCH2_INTERNAL_TEST_ )) #define METHOD_AS_TEST_CASE( method, ... ) + #define TEST_CASE_PERSISTENT_FIXTURE( className, ... ) INTERNAL_CATCH_TESTCASE_NO_REGISTRATION(INTERNAL_CATCH_UNIQUE_NAME( CATCH2_INTERNAL_TEST_ ), __VA_ARGS__) #define REGISTER_TEST_CASE( Function, ... ) (void)(0) #define SECTION( ... ) #define DYNAMIC_SECTION( ... ) diff --git a/src/catch2/catch_timer.cpp b/src/catch2/catch_timer.cpp index d75ea70c8b..51396654d3 100644 --- a/src/catch2/catch_timer.cpp +++ b/src/catch2/catch_timer.cpp @@ -13,7 +13,7 @@ namespace Catch { namespace { static auto getCurrentNanosecondsSinceEpoch() -> uint64_t { - return std::chrono::duration_cast(std::chrono::high_resolution_clock::now().time_since_epoch()).count(); + return std::chrono::duration_cast(std::chrono::steady_clock::now().time_since_epoch()).count(); } } // end unnamed namespace diff --git a/src/catch2/catch_tostring.cpp b/src/catch2/catch_tostring.cpp index b97cf560dc..3f034d1aaa 100644 --- a/src/catch2/catch_tostring.cpp +++ b/src/catch2/catch_tostring.cpp @@ -54,13 +54,13 @@ namespace Detail { } } // end unnamed namespace - std::string convertIntoString(StringRef string, bool escape_invisibles) { + std::string convertIntoString(StringRef string, bool escapeInvisibles) { std::string ret; // This is enough for the "don't escape invisibles" case, and a good // lower bound on the "escape invisibles" case. ret.reserve(string.size() + 2); - if (!escape_invisibles) { + if (!escapeInvisibles) { ret += '"'; ret += string; ret += '"'; @@ -138,7 +138,7 @@ std::string StringMaker::convert(char const* str) { return{ "{null string}" }; } } -std::string StringMaker::convert(char* str) { +std::string StringMaker::convert(char* str) { // NOLINT(readability-non-const-parameter) if (str) { return Detail::convertIntoString( str ); } else { @@ -235,17 +235,17 @@ std::string StringMaker::convert(signed char value) { std::string StringMaker::convert(char c) { return ::Catch::Detail::stringify(static_cast(c)); } -std::string StringMaker::convert(unsigned char c) { - return ::Catch::Detail::stringify(static_cast(c)); +std::string StringMaker::convert(unsigned char value) { + return ::Catch::Detail::stringify(static_cast(value)); } -int StringMaker::precision = 5; +int StringMaker::precision = std::numeric_limits::max_digits10; std::string StringMaker::convert(float value) { return Detail::fpToString(value, precision) + 'f'; } -int StringMaker::precision = 10; +int StringMaker::precision = std::numeric_limits::max_digits10; std::string StringMaker::convert(double value) { return Detail::fpToString(value, precision); diff --git a/src/catch2/catch_tostring.hpp b/src/catch2/catch_tostring.hpp index f3fb0beb79..67a7c1d228 100644 --- a/src/catch2/catch_tostring.hpp +++ b/src/catch2/catch_tostring.hpp @@ -279,11 +279,11 @@ namespace Catch { }; template<> struct StringMaker { - static std::string convert(signed char c); + static std::string convert(signed char value); }; template<> struct StringMaker { - static std::string convert(unsigned char c); + static std::string convert(unsigned char value); }; template<> diff --git a/src/catch2/catch_translate_exception.hpp b/src/catch2/catch_translate_exception.hpp index 5a4dc5e376..2bf8d36079 100644 --- a/src/catch2/catch_translate_exception.hpp +++ b/src/catch2/catch_translate_exception.hpp @@ -25,7 +25,7 @@ namespace Catch { class ExceptionTranslator : public IExceptionTranslator { public: - ExceptionTranslator( std::string(*translateFunction)( T const& ) ) + constexpr ExceptionTranslator( std::string(*translateFunction)( T const& ) ) : m_translateFunction( translateFunction ) {} diff --git a/src/catch2/catch_version.cpp b/src/catch2/catch_version.cpp index dbf8b4b20b..1701f3adf5 100644 --- a/src/catch2/catch_version.cpp +++ b/src/catch2/catch_version.cpp @@ -36,7 +36,7 @@ namespace Catch { } Version const& libraryVersion() { - static Version version( 3, 5, 0, "", 0 ); + static Version version( 3, 7, 1, "", 0 ); return version; } diff --git a/src/catch2/catch_version_macros.hpp b/src/catch2/catch_version_macros.hpp index fbe1188ccd..88b5d0d02b 100644 --- a/src/catch2/catch_version_macros.hpp +++ b/src/catch2/catch_version_macros.hpp @@ -9,7 +9,7 @@ #define CATCH_VERSION_MACROS_HPP_INCLUDED #define CATCH_VERSION_MAJOR 3 -#define CATCH_VERSION_MINOR 5 -#define CATCH_VERSION_PATCH 0 +#define CATCH_VERSION_MINOR 7 +#define CATCH_VERSION_PATCH 1 #endif // CATCH_VERSION_MACROS_HPP_INCLUDED diff --git a/src/catch2/generators/catch_generators.hpp b/src/catch2/generators/catch_generators.hpp index 117f190193..0f35a9968a 100644 --- a/src/catch2/generators/catch_generators.hpp +++ b/src/catch2/generators/catch_generators.hpp @@ -37,12 +37,6 @@ namespace Detail { } public: - ~IGenerator() override = default; - IGenerator() = default; - IGenerator(IGenerator const&) = default; - IGenerator& operator=(IGenerator const&) = default; - - // Returns the current element of the generator // // \Precondition The generator is either freshly constructed, diff --git a/src/catch2/generators/catch_generators_random.hpp b/src/catch2/generators/catch_generators_random.hpp index d5f307d40c..712835619e 100644 --- a/src/catch2/generators/catch_generators_random.hpp +++ b/src/catch2/generators/catch_generators_random.hpp @@ -8,7 +8,6 @@ #ifndef CATCH_GENERATORS_RANDOM_HPP_INCLUDED #define CATCH_GENERATORS_RANDOM_HPP_INCLUDED -#include #include #include #include diff --git a/src/catch2/interfaces/catch_interfaces_capture.hpp b/src/catch2/interfaces/catch_interfaces_capture.hpp index a1876a4cad..9e5431d247 100644 --- a/src/catch2/interfaces/catch_interfaces_capture.hpp +++ b/src/catch2/interfaces/catch_interfaces_capture.hpp @@ -9,7 +9,6 @@ #define CATCH_INTERFACES_CAPTURE_HPP_INCLUDED #include -#include #include #include @@ -77,7 +76,7 @@ namespace Catch { virtual void handleMessage ( AssertionInfo const& info, ResultWas::OfType resultType, - StringRef message, + std::string&& message, AssertionReaction& reaction ) = 0; virtual void handleUnexpectedExceptionNotThrown ( AssertionInfo const& info, diff --git a/src/catch2/interfaces/catch_interfaces_reporter.cpp b/src/catch2/interfaces/catch_interfaces_reporter.cpp index 3274bcf50e..90536bb366 100644 --- a/src/catch2/interfaces/catch_interfaces_reporter.cpp +++ b/src/catch2/interfaces/catch_interfaces_reporter.cpp @@ -7,19 +7,11 @@ // SPDX-License-Identifier: BSL-1.0 #include #include -#include -#include #include -#include -#include -#include -#include #include #include -#include #include -#include namespace Catch { diff --git a/src/catch2/interfaces/catch_interfaces_reporter.hpp b/src/catch2/interfaces/catch_interfaces_reporter.hpp index b40fce3128..a052c5db1d 100644 --- a/src/catch2/interfaces/catch_interfaces_reporter.hpp +++ b/src/catch2/interfaces/catch_interfaces_reporter.hpp @@ -15,7 +15,6 @@ #include #include #include -#include #include #include diff --git a/src/catch2/interfaces/catch_interfaces_test_invoker.hpp b/src/catch2/interfaces/catch_interfaces_test_invoker.hpp index 3caeff9a32..124a7f7d4a 100644 --- a/src/catch2/interfaces/catch_interfaces_test_invoker.hpp +++ b/src/catch2/interfaces/catch_interfaces_test_invoker.hpp @@ -12,6 +12,8 @@ namespace Catch { class ITestInvoker { public: + virtual void prepareTestCase(); + virtual void tearDownTestCase(); virtual void invoke() const = 0; virtual ~ITestInvoker(); // = default }; diff --git a/src/catch2/internal/catch_assertion_handler.cpp b/src/catch2/internal/catch_assertion_handler.cpp index e5232f70c9..9a28e79c21 100644 --- a/src/catch2/internal/catch_assertion_handler.cpp +++ b/src/catch2/internal/catch_assertion_handler.cpp @@ -8,10 +8,8 @@ #include #include #include -#include #include #include -#include #include namespace Catch { @@ -30,8 +28,8 @@ namespace Catch { void AssertionHandler::handleExpr( ITransientExpression const& expr ) { m_resultCapture.handleExpr( m_assertionInfo, expr, m_reaction ); } - void AssertionHandler::handleMessage(ResultWas::OfType resultType, StringRef message) { - m_resultCapture.handleMessage( m_assertionInfo, resultType, message, m_reaction ); + void AssertionHandler::handleMessage(ResultWas::OfType resultType, std::string&& message) { + m_resultCapture.handleMessage( m_assertionInfo, resultType, CATCH_MOVE(message), m_reaction ); } auto AssertionHandler::allowThrows() const -> bool { diff --git a/src/catch2/internal/catch_assertion_handler.hpp b/src/catch2/internal/catch_assertion_handler.hpp index 01dd7801d1..c71c6898fd 100644 --- a/src/catch2/internal/catch_assertion_handler.hpp +++ b/src/catch2/internal/catch_assertion_handler.hpp @@ -42,12 +42,12 @@ namespace Catch { template - void handleExpr( ExprLhs const& expr ) { + constexpr void handleExpr( ExprLhs const& expr ) { handleExpr( expr.makeUnaryExpr() ); } void handleExpr( ITransientExpression const& expr ); - void handleMessage(ResultWas::OfType resultType, StringRef message); + void handleMessage(ResultWas::OfType resultType, std::string&& message); void handleExceptionThrownAsExpected(); void handleUnexpectedExceptionNotThrown(); diff --git a/src/catch2/internal/catch_clara.cpp b/src/catch2/internal/catch_clara.cpp index c9bc76959d..f9dd913857 100644 --- a/src/catch2/internal/catch_clara.cpp +++ b/src/catch2/internal/catch_clara.cpp @@ -11,6 +11,7 @@ #include #include #include +#include #include #include @@ -24,13 +25,29 @@ namespace { ; } - std::string normaliseOpt( std::string const& optName ) { -#ifdef CATCH_PLATFORM_WINDOWS - if ( optName[0] == '/' ) - return "-" + optName.substr( 1 ); - else + Catch::StringRef normaliseOpt( Catch::StringRef optName ) { + if ( optName[0] == '-' +#if defined(CATCH_PLATFORM_WINDOWS) + || optName[0] == '/' #endif - return optName; + ) { + return optName.substr( 1, optName.size() ); + } + + return optName; + } + + static size_t find_first_separator(Catch::StringRef sr) { + auto is_separator = []( char c ) { + return c == ' ' || c == ':' || c == '='; + }; + size_t pos = 0; + while (pos < sr.size()) { + if (is_separator(sr[pos])) { return pos; } + ++pos; + } + + return Catch::StringRef::npos; } } // namespace @@ -48,23 +65,23 @@ namespace Catch { } if ( it != itEnd ) { - auto const& next = *it; + StringRef next = *it; if ( isOptPrefix( next[0] ) ) { - auto delimiterPos = next.find_first_of( " :=" ); - if ( delimiterPos != std::string::npos ) { + auto delimiterPos = find_first_separator(next); + if ( delimiterPos != StringRef::npos ) { m_tokenBuffer.push_back( { TokenType::Option, next.substr( 0, delimiterPos ) } ); m_tokenBuffer.push_back( { TokenType::Argument, - next.substr( delimiterPos + 1 ) } ); + next.substr( delimiterPos + 1, next.size() ) } ); } else { - if ( next[1] != '-' && next.size() > 2 ) { - std::string opt = "- "; + if ( next.size() > 1 && next[1] != '-' && next.size() > 2 ) { + // Combined short args, e.g. "-ab" for "-a -b" for ( size_t i = 1; i < next.size(); ++i ) { - opt[1] = next[i]; m_tokenBuffer.push_back( - { TokenType::Option, opt } ); + { TokenType::Option, + next.substr( i, 1 ) } ); } } else { m_tokenBuffer.push_back( @@ -124,12 +141,12 @@ namespace Catch { size_t ParserBase::cardinality() const { return 1; } InternalParseResult ParserBase::parse( Args const& args ) const { - return parse( args.exeName(), TokenStream( args ) ); + return parse( static_cast(args.exeName()), TokenStream( args ) ); } ParseState::ParseState( ParseResultType type, - TokenStream const& remainingTokens ): - m_type( type ), m_remainingTokens( remainingTokens ) {} + TokenStream remainingTokens ): + m_type( type ), m_remainingTokens( CATCH_MOVE(remainingTokens) ) {} ParserResult BoundFlagRef::setFlag( bool flag ) { m_ref = flag; @@ -147,34 +164,34 @@ namespace Catch { } // namespace Detail Detail::InternalParseResult Arg::parse(std::string const&, - Detail::TokenStream const& tokens) const { + Detail::TokenStream tokens) const { auto validationResult = validate(); if (!validationResult) return Detail::InternalParseResult(validationResult); - auto remainingTokens = tokens; - auto const& token = *remainingTokens; + auto token = *tokens; if (token.type != Detail::TokenType::Argument) return Detail::InternalParseResult::ok(Detail::ParseState( - ParseResultType::NoMatch, remainingTokens)); + ParseResultType::NoMatch, CATCH_MOVE(tokens))); assert(!m_ref->isFlag()); auto valueRef = static_cast(m_ref.get()); - auto result = valueRef->setValue(remainingTokens->token); - if (!result) - return Detail::InternalParseResult(result); + auto result = valueRef->setValue(static_cast(token.token)); + if ( !result ) + return Detail::InternalParseResult( result ); else - return Detail::InternalParseResult::ok(Detail::ParseState( - ParseResultType::Matched, ++remainingTokens)); + return Detail::InternalParseResult::ok( + Detail::ParseState( ParseResultType::Matched, + CATCH_MOVE( ++tokens ) ) ); } Opt::Opt(bool& ref) : ParserRefImpl(std::make_shared(ref)) {} - std::vector Opt::getHelpColumns() const { - std::ostringstream oss; + Detail::HelpColumns Opt::getHelpColumns() const { + ReusableStringStream oss; bool first = true; for (auto const& opt : m_optNames) { if (first) @@ -185,10 +202,10 @@ namespace Catch { } if (!m_hint.empty()) oss << " <" << m_hint << '>'; - return { { oss.str(), m_description } }; + return { oss.str(), m_description }; } - bool Opt::isMatch(std::string const& optToken) const { + bool Opt::isMatch(StringRef optToken) const { auto normalisedToken = normaliseOpt(optToken); for (auto const& name : m_optNames) { if (normaliseOpt(name) == normalisedToken) @@ -198,15 +215,14 @@ namespace Catch { } Detail::InternalParseResult Opt::parse(std::string const&, - Detail::TokenStream const& tokens) const { + Detail::TokenStream tokens) const { auto validationResult = validate(); if (!validationResult) return Detail::InternalParseResult(validationResult); - auto remainingTokens = tokens; - if (remainingTokens && - remainingTokens->type == Detail::TokenType::Option) { - auto const& token = *remainingTokens; + if (tokens && + tokens->type == Detail::TokenType::Option) { + auto const& token = *tokens; if (isMatch(token.token)) { if (m_ref->isFlag()) { auto flagRef = @@ -218,35 +234,35 @@ namespace Catch { if (result.value() == ParseResultType::ShortCircuitAll) return Detail::InternalParseResult::ok(Detail::ParseState( - result.value(), remainingTokens)); + result.value(), CATCH_MOVE(tokens))); } else { auto valueRef = static_cast( m_ref.get()); - ++remainingTokens; - if (!remainingTokens) + ++tokens; + if (!tokens) return Detail::InternalParseResult::runtimeError( "Expected argument following " + token.token); - auto const& argToken = *remainingTokens; + auto const& argToken = *tokens; if (argToken.type != Detail::TokenType::Argument) return Detail::InternalParseResult::runtimeError( "Expected argument following " + token.token); - const auto result = valueRef->setValue(argToken.token); + const auto result = valueRef->setValue(static_cast(argToken.token)); if (!result) return Detail::InternalParseResult(result); if (result.value() == ParseResultType::ShortCircuitAll) return Detail::InternalParseResult::ok(Detail::ParseState( - result.value(), remainingTokens)); + result.value(), CATCH_MOVE(tokens))); } return Detail::InternalParseResult::ok(Detail::ParseState( - ParseResultType::Matched, ++remainingTokens)); + ParseResultType::Matched, CATCH_MOVE(++tokens))); } } return Detail::InternalParseResult::ok( - Detail::ParseState(ParseResultType::NoMatch, remainingTokens)); + Detail::ParseState(ParseResultType::NoMatch, CATCH_MOVE(tokens))); } Detail::Result Opt::validate() const { @@ -278,9 +294,9 @@ namespace Catch { Detail::InternalParseResult ExeName::parse(std::string const&, - Detail::TokenStream const& tokens) const { + Detail::TokenStream tokens) const { return Detail::InternalParseResult::ok( - Detail::ParseState(ParseResultType::NoMatch, tokens)); + Detail::ParseState(ParseResultType::NoMatch, CATCH_MOVE(tokens))); } ParserResult ExeName::set(std::string const& newName) { @@ -310,9 +326,9 @@ namespace Catch { std::vector Parser::getHelpColumns() const { std::vector cols; + cols.reserve( m_options.size() ); for ( auto const& o : m_options ) { - auto childCols = o.getHelpColumns(); - cols.insert( cols.end(), childCols.begin(), childCols.end() ); + cols.push_back(o.getHelpColumns()); } return cols; } @@ -350,12 +366,12 @@ namespace Catch { optWidth = ( std::min )( optWidth, consoleWidth / 2 ); - for ( auto const& cols : rows ) { - auto row = TextFlow::Column( cols.left ) + for ( auto& cols : rows ) { + auto row = TextFlow::Column( CATCH_MOVE(cols.left) ) .width( optWidth ) .indent( 2 ) + TextFlow::Spacer( 4 ) + - TextFlow::Column( cols.right ) + TextFlow::Column( static_cast(cols.descriptions) ) .width( consoleWidth - 7 - optWidth ); os << row << '\n'; } @@ -377,7 +393,7 @@ namespace Catch { Detail::InternalParseResult Parser::parse( std::string const& exeName, - Detail::TokenStream const& tokens ) const { + Detail::TokenStream tokens ) const { struct ParserInfo { ParserBase const* parser = nullptr; @@ -395,7 +411,7 @@ namespace Catch { m_exeName.set( exeName ); auto result = Detail::InternalParseResult::ok( - Detail::ParseState( ParseResultType::NoMatch, tokens ) ); + Detail::ParseState( ParseResultType::NoMatch, CATCH_MOVE(tokens) ) ); while ( result.value().remainingTokens() ) { bool tokenParsed = false; @@ -403,7 +419,7 @@ namespace Catch { if ( parseInfo.parser->cardinality() == 0 || parseInfo.count < parseInfo.parser->cardinality() ) { result = parseInfo.parser->parse( - exeName, result.value().remainingTokens() ); + exeName, CATCH_MOVE(result).value().remainingTokens() ); if ( !result ) return result; if ( result.value().type() != @@ -429,7 +445,7 @@ namespace Catch { Args::Args(int argc, char const* const* argv) : m_exeName(argv[0]), m_args(argv + 1, argv + argc) {} - Args::Args(std::initializer_list args) : + Args::Args(std::initializer_list args) : m_exeName(*args.begin()), m_args(args.begin() + 1, args.end()) {} diff --git a/src/catch2/internal/catch_clara.hpp b/src/catch2/internal/catch_clara.hpp index 9117b65e84..d869593bff 100644 --- a/src/catch2/internal/catch_clara.hpp +++ b/src/catch2/internal/catch_clara.hpp @@ -29,6 +29,7 @@ # endif #endif +#include #include #include #include @@ -101,17 +102,16 @@ namespace Catch { enum class TokenType { Option, Argument }; struct Token { TokenType type; - std::string token; + StringRef token; }; // Abstracts iterators into args as a stream of tokens, with option // arguments uniformly handled class TokenStream { - using Iterator = std::vector::const_iterator; + using Iterator = std::vector::const_iterator; Iterator it; Iterator itEnd; std::vector m_tokenBuffer; - void loadBuffer(); public: @@ -163,12 +163,17 @@ namespace Catch { ResultType m_type; }; - template class ResultValueBase : public ResultBase { + template + class ResultValueBase : public ResultBase { public: - auto value() const -> T const& { + T const& value() const& { enforceOk(); return m_value; } + T&& value() && { + enforceOk(); + return CATCH_MOVE( m_value ); + } protected: ResultValueBase( ResultType type ): ResultBase( type ) {} @@ -178,13 +183,23 @@ namespace Catch { if ( m_type == ResultType::Ok ) new ( &m_value ) T( other.m_value ); } + ResultValueBase( ResultValueBase&& other ): + ResultBase( other ) { + if ( m_type == ResultType::Ok ) + new ( &m_value ) T( CATCH_MOVE(other.m_value) ); + } + - ResultValueBase( ResultType, T const& value ): ResultBase( ResultType::Ok ) { + ResultValueBase( ResultType, T const& value ): + ResultBase( ResultType::Ok ) { new ( &m_value ) T( value ); } + ResultValueBase( ResultType, T&& value ): + ResultBase( ResultType::Ok ) { + new ( &m_value ) T( CATCH_MOVE(value) ); + } - auto operator=( ResultValueBase const& other ) - -> ResultValueBase& { + ResultValueBase& operator=( ResultValueBase const& other ) { if ( m_type == ResultType::Ok ) m_value.~T(); ResultBase::operator=( other ); @@ -192,6 +207,14 @@ namespace Catch { new ( &m_value ) T( other.m_value ); return *this; } + ResultValueBase& operator=( ResultValueBase&& other ) { + if ( m_type == ResultType::Ok ) m_value.~T(); + ResultBase::operator=( other ); + if ( m_type == ResultType::Ok ) + new ( &m_value ) T( CATCH_MOVE(other.m_value) ); + return *this; + } + ~ResultValueBase() override { if ( m_type == ResultType::Ok ) @@ -219,8 +242,8 @@ namespace Catch { } template - static auto ok( U const& value ) -> BasicResult { - return { ResultType::Ok, value }; + static auto ok( U&& value ) -> BasicResult { + return { ResultType::Ok, CATCH_FORWARD(value) }; } static auto ok() -> BasicResult { return { ResultType::Ok }; } static auto logicError( std::string&& message ) @@ -267,12 +290,15 @@ namespace Catch { class ParseState { public: ParseState( ParseResultType type, - TokenStream const& remainingTokens ); + TokenStream remainingTokens ); ParseResultType type() const { return m_type; } - TokenStream const& remainingTokens() const { + TokenStream const& remainingTokens() const& { return m_remainingTokens; } + TokenStream&& remainingTokens() && { + return CATCH_MOVE( m_remainingTokens ); + } private: ParseResultType m_type; @@ -285,7 +311,7 @@ namespace Catch { struct HelpColumns { std::string left; - std::string right; + StringRef descriptions; }; template @@ -445,7 +471,7 @@ namespace Catch { virtual ~ParserBase() = default; virtual auto validate() const -> Result { return Result::ok(); } virtual auto parse( std::string const& exeName, - TokenStream const& tokens ) const + TokenStream tokens ) const -> InternalParseResult = 0; virtual size_t cardinality() const; @@ -465,8 +491,8 @@ namespace Catch { protected: Optionality m_optionality = Optionality::Optional; std::shared_ptr m_ref; - std::string m_hint; - std::string m_description; + StringRef m_hint; + StringRef m_description; explicit ParserRefImpl( std::shared_ptr const& ref ): m_ref( ref ) {} @@ -475,28 +501,32 @@ namespace Catch { template ParserRefImpl( accept_many_t, LambdaT const& ref, - std::string const& hint ): + StringRef hint ): m_ref( std::make_shared>( ref ) ), m_hint( hint ) {} template ::value>> - ParserRefImpl( T& ref, std::string const& hint ): + ParserRefImpl( T& ref, StringRef hint ): m_ref( std::make_shared>( ref ) ), m_hint( hint ) {} template ::value>> - ParserRefImpl( LambdaT const& ref, std::string const& hint ): + ParserRefImpl( LambdaT const& ref, StringRef hint ): m_ref( std::make_shared>( ref ) ), m_hint( hint ) {} - auto operator()( std::string const& description ) -> DerivedT& { + DerivedT& operator()( StringRef description ) & { m_description = description; return static_cast( *this ); } + DerivedT&& operator()( StringRef description ) && { + m_description = description; + return static_cast( *this ); + } auto optional() -> DerivedT& { m_optionality = Optionality::Optional; @@ -519,7 +549,7 @@ namespace Catch { return 1; } - std::string const& hint() const { return m_hint; } + StringRef hint() const { return m_hint; } }; } // namespace detail @@ -533,13 +563,13 @@ namespace Catch { Detail::InternalParseResult parse(std::string const&, - Detail::TokenStream const& tokens) const override; + Detail::TokenStream tokens) const override; }; // A parser for options class Opt : public Detail::ParserRefImpl { protected: - std::vector m_optNames; + std::vector m_optNames; public: template @@ -552,33 +582,37 @@ namespace Catch { template ::value>> - Opt( LambdaT const& ref, std::string const& hint ): + Opt( LambdaT const& ref, StringRef hint ): ParserRefImpl( ref, hint ) {} template - Opt( accept_many_t, LambdaT const& ref, std::string const& hint ): + Opt( accept_many_t, LambdaT const& ref, StringRef hint ): ParserRefImpl( accept_many, ref, hint ) {} template ::value>> - Opt( T& ref, std::string const& hint ): + Opt( T& ref, StringRef hint ): ParserRefImpl( ref, hint ) {} - auto operator[](std::string const& optName) -> Opt& { + Opt& operator[]( StringRef optName ) & { m_optNames.push_back(optName); return *this; } + Opt&& operator[]( StringRef optName ) && { + m_optNames.push_back( optName ); + return CATCH_MOVE(*this); + } - std::vector getHelpColumns() const; + Detail::HelpColumns getHelpColumns() const; - bool isMatch(std::string const& optToken) const; + bool isMatch(StringRef optToken) const; using ParserBase::parse; Detail::InternalParseResult parse(std::string const&, - Detail::TokenStream const& tokens) const override; + Detail::TokenStream tokens) const override; Detail::Result validate() const override; }; @@ -601,7 +635,7 @@ namespace Catch { // handled specially Detail::InternalParseResult parse(std::string const&, - Detail::TokenStream const& tokens) const override; + Detail::TokenStream tokens) const override; std::string const& name() const { return *m_name; } Detail::ParserResult set(std::string const& newName); @@ -626,16 +660,28 @@ namespace Catch { return *this; } - auto operator|=(Opt const& opt) -> Parser& { - m_options.push_back(opt); - return *this; + friend Parser& operator|=( Parser& p, Opt const& opt ) { + p.m_options.push_back( opt ); + return p; + } + friend Parser& operator|=( Parser& p, Opt&& opt ) { + p.m_options.push_back( CATCH_MOVE(opt) ); + return p; } Parser& operator|=(Parser const& other); template - auto operator|(T const& other) const -> Parser { - return Parser(*this) |= other; + friend Parser operator|( Parser const& p, T&& rhs ) { + Parser temp( p ); + temp |= rhs; + return temp; + } + + template + friend Parser operator|( Parser&& p, T&& rhs ) { + p |= CATCH_FORWARD(rhs); + return CATCH_MOVE(p); } std::vector getHelpColumns() const; @@ -653,21 +699,23 @@ namespace Catch { using ParserBase::parse; Detail::InternalParseResult parse(std::string const& exeName, - Detail::TokenStream const& tokens) const override; + Detail::TokenStream tokens) const override; }; - // Transport for raw args (copied from main args, or supplied via - // init list for testing) + /** + * Wrapper over argc + argv, assumes that the inputs outlive it + */ class Args { friend Detail::TokenStream; - std::string m_exeName; - std::vector m_args; + StringRef m_exeName; + std::vector m_args; public: Args(int argc, char const* const* argv); - Args(std::initializer_list args); + // Helper constructor for testing + Args(std::initializer_list args); - std::string const& exeName() const { return m_exeName; } + StringRef exeName() const { return m_exeName; } }; diff --git a/src/catch2/internal/catch_commandline.cpp b/src/catch2/internal/catch_commandline.cpp index 4ac1847b20..212f17745a 100644 --- a/src/catch2/internal/catch_commandline.cpp +++ b/src/catch2/internal/catch_commandline.cpp @@ -9,6 +9,7 @@ #include #include +#include #include #include #include @@ -46,7 +47,7 @@ namespace Catch { line = trim(line); if( !line.empty() && !startsWith( line, '#' ) ) { if( !startsWith( line, '"' ) ) - line = '"' + line + '"'; + line = '"' + CATCH_MOVE(line) + '"'; config.testsOrTags.push_back( line ); config.testsOrTags.emplace_back( "," ); } @@ -300,8 +301,8 @@ namespace Catch { ( "split the tests to execute into this many groups" ) | Opt( setShardIndex, "shard index" ) ["--shard-index"] - ( "index of the group of tests to execute (see --shard-count)" ) | - Opt( config.allowZeroTests ) + ( "index of the group of tests to execute (see --shard-count)" ) + | Opt( config.allowZeroTests ) ["--allow-running-no-tests"] ( "Treat 'No tests run' as a success" ) | Arg( config.testsOrTags, "test name|pattern|tags" ) diff --git a/src/catch2/internal/catch_compiler_capabilities.hpp b/src/catch2/internal/catch_compiler_capabilities.hpp index dacae01b70..7f09da5177 100644 --- a/src/catch2/internal/catch_compiler_capabilities.hpp +++ b/src/catch2/internal/catch_compiler_capabilities.hpp @@ -29,14 +29,14 @@ #ifdef __cplusplus -# if (__cplusplus >= 201402L) || (defined(_MSVC_LANG) && _MSVC_LANG >= 201402L) -# define CATCH_CPP14_OR_GREATER -# endif - # if (__cplusplus >= 201703L) || (defined(_MSVC_LANG) && _MSVC_LANG >= 201703L) # define CATCH_CPP17_OR_GREATER # endif +# if (__cplusplus >= 202002L) || (defined(_MSVC_LANG) && _MSVC_LANG >= 202002L) +# define CATCH_CPP20_OR_GREATER +# endif + #endif // Only GCC compiler should be used in this block, so other compilers trying to diff --git a/src/catch2/internal/catch_console_colour.cpp b/src/catch2/internal/catch_console_colour.cpp index e1238816af..b19e01ecce 100644 --- a/src/catch2/internal/catch_console_colour.cpp +++ b/src/catch2/internal/catch_console_colour.cpp @@ -230,21 +230,21 @@ namespace { namespace Catch { - Detail::unique_ptr makeColourImpl( ColourMode implSelection, + Detail::unique_ptr makeColourImpl( ColourMode colourSelection, IStream* stream ) { #if defined( CATCH_CONFIG_COLOUR_WIN32 ) - if ( implSelection == ColourMode::Win32 ) { + if ( colourSelection == ColourMode::Win32 ) { return Detail::make_unique( stream ); } #endif - if ( implSelection == ColourMode::ANSI ) { + if ( colourSelection == ColourMode::ANSI ) { return Detail::make_unique( stream ); } - if ( implSelection == ColourMode::None ) { + if ( colourSelection == ColourMode::None ) { return Detail::make_unique( stream ); } - if ( implSelection == ColourMode::PlatformDefault) { + if ( colourSelection == ColourMode::PlatformDefault) { #if defined( CATCH_CONFIG_COLOUR_WIN32 ) if ( Win32ColourImpl::useImplementationForStream( *stream ) ) { return Detail::make_unique( stream ); @@ -256,7 +256,7 @@ namespace Catch { return Detail::make_unique( stream ); } - CATCH_ERROR( "Could not create colour impl for selection " << static_cast(implSelection) ); + CATCH_ERROR( "Could not create colour impl for selection " << static_cast(colourSelection) ); } bool isColourImplAvailable( ColourMode colourSelection ) { diff --git a/src/catch2/internal/catch_context.cpp b/src/catch2/internal/catch_context.cpp index 3b1cc27747..8acf1eda62 100644 --- a/src/catch2/internal/catch_context.cpp +++ b/src/catch2/internal/catch_context.cpp @@ -27,12 +27,6 @@ namespace Catch { return *Context::currentContext; } - void Context::setResultCapture( IResultCapture* resultCapture ) { - m_resultCapture = resultCapture; - } - - void Context::setConfig( IConfig const* config ) { m_config = config; } - SimplePcg32& sharedRng() { static SimplePcg32 s_rng; return s_rng; diff --git a/src/catch2/internal/catch_context.hpp b/src/catch2/internal/catch_context.hpp index 6ccb3b3189..4d8a5da1b6 100644 --- a/src/catch2/internal/catch_context.hpp +++ b/src/catch2/internal/catch_context.hpp @@ -26,10 +26,15 @@ namespace Catch { friend void cleanUpContext(); public: - IResultCapture* getResultCapture() const { return m_resultCapture; } - IConfig const* getConfig() const { return m_config; } - void setResultCapture( IResultCapture* resultCapture ); - void setConfig( IConfig const* config ); + constexpr IResultCapture* getResultCapture() const { + return m_resultCapture; + } + constexpr IConfig const* getConfig() const { return m_config; } + constexpr void setResultCapture( IResultCapture* resultCapture ) { + m_resultCapture = resultCapture; + } + constexpr void setConfig( IConfig const* config ) { m_config = config; } + }; Context& getCurrentMutableContext(); diff --git a/src/catch2/internal/catch_decomposer.cpp b/src/catch2/internal/catch_decomposer.cpp index 3f398fcc2b..17a7bc9551 100644 --- a/src/catch2/internal/catch_decomposer.cpp +++ b/src/catch2/internal/catch_decomposer.cpp @@ -10,7 +10,12 @@ namespace Catch { - ITransientExpression::~ITransientExpression() = default; + void ITransientExpression::streamReconstructedExpression( + std::ostream& os ) const { + // We can't make this function pure virtual to keep ITransientExpression + // constexpr, so we write error message instead + os << "Some class derived from ITransientExpression without overriding streamReconstructedExpression"; + } void formatReconstructedExpression( std::ostream &os, std::string const& lhs, StringRef op, std::string const& rhs ) { if( lhs.size() + rhs.size() < 40 && diff --git a/src/catch2/internal/catch_decomposer.hpp b/src/catch2/internal/catch_decomposer.hpp index e0e46c1de8..adce89f2a3 100644 --- a/src/catch2/internal/catch_decomposer.hpp +++ b/src/catch2/internal/catch_decomposer.hpp @@ -13,10 +13,91 @@ #include #include #include +#include #include #include +/** \file + * Why does decomposing look the way it does: + * + * Conceptually, decomposing is simple. We change `REQUIRE( a == b )` into + * `Decomposer{} <= a == b`, so that `Decomposer{} <= a` is evaluated first, + * and our custom operator is used for `a == b`, because `a` is transformed + * into `ExprLhs` and then into `BinaryExpr`. + * + * In practice, decomposing ends up a mess, because we have to support + * various fun things. + * + * 1) Types that are only comparable with literal 0, and they do this by + * comparing against a magic type with pointer constructor and deleted + * other constructors. Example: `REQUIRE((a <=> b) == 0)` in libstdc++ + * + * 2) Types that are only comparable with literal 0, and they do this by + * comparing against a magic type with consteval integer constructor. + * Example: `REQUIRE((a <=> b) == 0)` in current MSVC STL. + * + * 3) Types that have no linkage, and so we cannot form a reference to + * them. Example: some implementations of traits. + * + * 4) Starting with C++20, when the compiler sees `a == b`, it also uses + * `b == a` when constructing the overload set. For us this means that + * when the compiler handles `ExprLhs == b`, it also tries to resolve + * the overload set for `b == ExprLhs`. + * + * To accomodate these use cases, decomposer ended up rather complex. + * + * 1) These types are handled by adding SFINAE overloads to our comparison + * operators, checking whether `T == U` are comparable with the given + * operator, and if not, whether T (or U) are comparable with literal 0. + * If yes, the overload compares T (or U) with 0 literal inline in the + * definition. + * + * Note that for extra correctness, we check that the other type is + * either an `int` (literal 0 is captured as `int` by templates), or + * a `long` (some platforms use 0L for `NULL` and we want to support + * that for pointer comparisons). + * + * 2) For these types, `is_foo_comparable` is true, but letting + * them fall into the overload that actually does `T == int` causes + * compilation error. Handling them requires that the decomposition + * is `constexpr`, so that P2564R3 applies and the `consteval` from + * their accompanying magic type is propagated through the `constexpr` + * call stack. + * + * However this is not enough to handle these types automatically, + * because our default is to capture types by reference, to avoid + * runtime copies. While these references cannot become dangling, + * they outlive the constexpr context and thus the default capture + * path cannot be actually constexpr. + * + * The solution is to capture these types by value, by explicitly + * specializing `Catch::capture_by_value` for them. Catch2 provides + * specialization for `std::foo_ordering`s, but users can specialize + * the trait for their own types as well. + * + * 3) If a type has no linkage, we also cannot capture it by reference. + * The solution is once again to capture them by value. We handle + * the common cases by using `std::is_arithmetic` as the default + * for `Catch::capture_by_value`, but that is only a some-effort + * heuristic. But as with 2), users can specialize `capture_by_value` + * for their own types as needed. + * + * 4) To support C++20 and make the SFINAE on our decomposing operators + * work, the SFINAE has to happen in return type, rather than in + * a template type. This is due to our use of logical type traits + * (`conjunction`/`disjunction`/`negation`), that we use to workaround + * an issue in older (9-) versions of GCC. I still blame C++20 for + * this, because without the comparison order switching, the logical + * traits could still be used in template type. + * + * There are also other side concerns, e.g. supporting both `REQUIRE(a)` + * and `REQUIRE(a == b)`, or making `REQUIRE_THAT(a, IsEqual(b))` slot + * nicely into the same expression handling logic, but these are rather + * straightforward and add only a bit of complexity (e.g. common base + * class for decomposed expressions). + */ + #ifdef _MSC_VER #pragma warning(push) #pragma warning(disable:4389) // '==' : signed/unsigned mismatch @@ -29,13 +110,46 @@ #ifdef __clang__ # pragma clang diagnostic push # pragma clang diagnostic ignored "-Wsign-compare" +# pragma clang diagnostic ignored "-Wnon-virtual-dtor" #elif defined __GNUC__ # pragma GCC diagnostic push # pragma GCC diagnostic ignored "-Wsign-compare" +# pragma GCC diagnostic ignored "-Wnon-virtual-dtor" +#endif + +#if defined(CATCH_CPP20_OR_GREATER) && __has_include() +# include +# if defined( __cpp_lib_three_way_comparison ) && \ + __cpp_lib_three_way_comparison >= 201907L +# define CATCH_CONFIG_CPP20_COMPARE_OVERLOADS +# endif #endif namespace Catch { + namespace Detail { + // This was added in C++20, but we require only C++14 for now. + template + using RemoveCVRef_t = std::remove_cv_t>; + } + + // Note: There is nothing that stops us from extending this, + // e.g. to `std::is_scalar`, but the more encompassing + // traits are usually also more expensive. For now we + // keep this as it used to be and it can be changed later. + template + struct capture_by_value + : std::integral_constant{}> {}; + +#if defined( CATCH_CONFIG_CPP20_COMPARE_OVERLOADS ) + template <> + struct capture_by_value : std::true_type {}; + template <> + struct capture_by_value : std::true_type {}; + template <> + struct capture_by_value : std::true_type {}; +#endif + template struct always_false : std::false_type {}; @@ -43,23 +157,22 @@ namespace Catch { bool m_isBinaryExpression; bool m_result; + protected: + ~ITransientExpression() = default; + public: - auto isBinaryExpression() const -> bool { return m_isBinaryExpression; } - auto getResult() const -> bool { return m_result; } - virtual void streamReconstructedExpression( std::ostream &os ) const = 0; + constexpr auto isBinaryExpression() const -> bool { return m_isBinaryExpression; } + constexpr auto getResult() const -> bool { return m_result; } + //! This function **has** to be overriden by the derived class. + virtual void streamReconstructedExpression( std::ostream& os ) const; - ITransientExpression( bool isBinaryExpression, bool result ) + constexpr ITransientExpression( bool isBinaryExpression, bool result ) : m_isBinaryExpression( isBinaryExpression ), m_result( result ) {} - ITransientExpression() = default; - ITransientExpression(ITransientExpression const&) = default; - ITransientExpression& operator=(ITransientExpression const&) = default; - - // We don't actually need a virtual destructor, but many static analysers - // complain if it's not here :-( - virtual ~ITransientExpression(); // = default; + constexpr ITransientExpression( ITransientExpression const& ) = default; + constexpr ITransientExpression& operator=( ITransientExpression const& ) = default; friend std::ostream& operator<<(std::ostream& out, ITransientExpression const& expr) { expr.streamReconstructedExpression(out); @@ -81,7 +194,7 @@ namespace Catch { } public: - BinaryExpr( bool comparisonResult, LhsT lhs, StringRef op, RhsT rhs ) + constexpr BinaryExpr( bool comparisonResult, LhsT lhs, StringRef op, RhsT rhs ) : ITransientExpression{ true, comparisonResult }, m_lhs( lhs ), m_op( op ), @@ -154,7 +267,7 @@ namespace Catch { } public: - explicit UnaryExpr( LhsT lhs ) + explicit constexpr UnaryExpr( LhsT lhs ) : ITransientExpression{ false, static_cast(lhs) }, m_lhs( lhs ) {} @@ -165,31 +278,31 @@ namespace Catch { class ExprLhs { LhsT m_lhs; public: - explicit ExprLhs( LhsT lhs ) : m_lhs( lhs ) {} + explicit constexpr ExprLhs( LhsT lhs ) : m_lhs( lhs ) {} #define CATCH_INTERNAL_DEFINE_EXPRESSION_EQUALITY_OPERATOR( id, op ) \ template \ - friend auto operator op( ExprLhs&& lhs, RhsT&& rhs ) \ - ->std::enable_if_t< \ + constexpr friend auto operator op( ExprLhs&& lhs, RhsT&& rhs ) \ + -> std::enable_if_t< \ Detail::conjunction, \ - Detail::negation>>>::value, \ + Detail::negation>>>::value, \ BinaryExpr> { \ return { \ static_cast( lhs.m_lhs op rhs ), lhs.m_lhs, #op##_sr, rhs }; \ } \ template \ - friend auto operator op( ExprLhs&& lhs, RhsT rhs ) \ - ->std::enable_if_t< \ + constexpr friend auto operator op( ExprLhs&& lhs, RhsT rhs ) \ + -> std::enable_if_t< \ Detail::conjunction, \ - std::is_arithmetic>::value, \ + capture_by_value>::value, \ BinaryExpr> { \ return { \ static_cast( lhs.m_lhs op rhs ), lhs.m_lhs, #op##_sr, rhs }; \ } \ template \ - friend auto operator op( ExprLhs&& lhs, RhsT rhs ) \ - ->std::enable_if_t< \ + constexpr friend auto operator op( ExprLhs&& lhs, RhsT rhs ) \ + -> std::enable_if_t< \ Detail::conjunction< \ Detail::negation>, \ Detail::is_eq_0_comparable, \ @@ -202,8 +315,8 @@ namespace Catch { static_cast( lhs.m_lhs op 0 ), lhs.m_lhs, #op##_sr, rhs }; \ } \ template \ - friend auto operator op( ExprLhs&& lhs, RhsT rhs ) \ - ->std::enable_if_t< \ + constexpr friend auto operator op( ExprLhs&& lhs, RhsT rhs ) \ + -> std::enable_if_t< \ Detail::conjunction< \ Detail::negation>, \ Detail::is_eq_0_comparable, \ @@ -220,29 +333,30 @@ namespace Catch { #undef CATCH_INTERNAL_DEFINE_EXPRESSION_EQUALITY_OPERATOR + #define CATCH_INTERNAL_DEFINE_EXPRESSION_COMPARISON_OPERATOR( id, op ) \ template \ - friend auto operator op( ExprLhs&& lhs, RhsT&& rhs ) \ - ->std::enable_if_t< \ + constexpr friend auto operator op( ExprLhs&& lhs, RhsT&& rhs ) \ + -> std::enable_if_t< \ Detail::conjunction, \ - Detail::negation>>>::value, \ + Detail::negation>>>::value, \ BinaryExpr> { \ return { \ static_cast( lhs.m_lhs op rhs ), lhs.m_lhs, #op##_sr, rhs }; \ } \ template \ - friend auto operator op( ExprLhs&& lhs, RhsT rhs ) \ - ->std::enable_if_t< \ + constexpr friend auto operator op( ExprLhs&& lhs, RhsT rhs ) \ + -> std::enable_if_t< \ Detail::conjunction, \ - std::is_arithmetic>::value, \ + capture_by_value>::value, \ BinaryExpr> { \ return { \ static_cast( lhs.m_lhs op rhs ), lhs.m_lhs, #op##_sr, rhs }; \ } \ template \ - friend auto operator op( ExprLhs&& lhs, RhsT rhs ) \ - ->std::enable_if_t< \ + constexpr friend auto operator op( ExprLhs&& lhs, RhsT rhs ) \ + -> std::enable_if_t< \ Detail::conjunction< \ Detail::negation>, \ Detail::is_##id##_0_comparable, \ @@ -253,8 +367,8 @@ namespace Catch { static_cast( lhs.m_lhs op 0 ), lhs.m_lhs, #op##_sr, rhs }; \ } \ template \ - friend auto operator op( ExprLhs&& lhs, RhsT rhs ) \ - ->std::enable_if_t< \ + constexpr friend auto operator op( ExprLhs&& lhs, RhsT rhs ) \ + -> std::enable_if_t< \ Detail::conjunction< \ Detail::negation>, \ Detail::is_##id##_0_comparable, \ @@ -274,17 +388,17 @@ namespace Catch { #define CATCH_INTERNAL_DEFINE_EXPRESSION_OPERATOR( op ) \ template \ - friend auto operator op( ExprLhs&& lhs, RhsT&& rhs ) \ - ->std::enable_if_t< \ - !std::is_arithmetic>::value, \ + constexpr friend auto operator op( ExprLhs&& lhs, RhsT&& rhs ) \ + -> std::enable_if_t< \ + !capture_by_value>::value, \ BinaryExpr> { \ return { \ static_cast( lhs.m_lhs op rhs ), lhs.m_lhs, #op##_sr, rhs }; \ } \ template \ - friend auto operator op( ExprLhs&& lhs, RhsT rhs ) \ - ->std::enable_if_t::value, \ - BinaryExpr> { \ + constexpr friend auto operator op( ExprLhs&& lhs, RhsT rhs ) \ + -> std::enable_if_t::value, \ + BinaryExpr> { \ return { \ static_cast( lhs.m_lhs op rhs ), lhs.m_lhs, #op##_sr, rhs }; \ } @@ -309,19 +423,22 @@ namespace Catch { "wrap the expression inside parentheses, or decompose it"); } - auto makeUnaryExpr() const -> UnaryExpr { + constexpr auto makeUnaryExpr() const -> UnaryExpr { return UnaryExpr{ m_lhs }; } }; struct Decomposer { - template>::value, int> = 0> - friend auto operator <= ( Decomposer &&, T && lhs ) -> ExprLhs { + template >::value, + int> = 0> + constexpr friend auto operator <= ( Decomposer &&, T && lhs ) -> ExprLhs { return ExprLhs{ lhs }; } - template::value, int> = 0> - friend auto operator <= ( Decomposer &&, T value ) -> ExprLhs { + template ::value, int> = 0> + constexpr friend auto operator <= ( Decomposer &&, T value ) -> ExprLhs { return ExprLhs{ value }; } }; diff --git a/src/catch2/internal/catch_enum_values_registry.hpp b/src/catch2/internal/catch_enum_values_registry.hpp index 999059ae8f..de994c3597 100644 --- a/src/catch2/internal/catch_enum_values_registry.hpp +++ b/src/catch2/internal/catch_enum_values_registry.hpp @@ -24,7 +24,7 @@ namespace Catch { std::vector> m_enumInfos; - EnumInfo const& registerEnum( StringRef enumName, StringRef allEnums, std::vector const& values) override; + EnumInfo const& registerEnum( StringRef enumName, StringRef allValueNames, std::vector const& values) override; }; std::vector parseEnums( StringRef enums ); diff --git a/src/catch2/internal/catch_fatal_condition_handler.cpp b/src/catch2/internal/catch_fatal_condition_handler.cpp index f9702b1847..9ef5b21795 100644 --- a/src/catch2/internal/catch_fatal_condition_handler.cpp +++ b/src/catch2/internal/catch_fatal_condition_handler.cpp @@ -26,6 +26,7 @@ #include +#include #include #include #include diff --git a/src/catch2/internal/catch_fatal_condition_handler.hpp b/src/catch2/internal/catch_fatal_condition_handler.hpp index ce07f9b6a7..81728b563a 100644 --- a/src/catch2/internal/catch_fatal_condition_handler.hpp +++ b/src/catch2/internal/catch_fatal_condition_handler.hpp @@ -8,9 +8,6 @@ #ifndef CATCH_FATAL_CONDITION_HANDLER_HPP_INCLUDED #define CATCH_FATAL_CONDITION_HANDLER_HPP_INCLUDED -#include -#include - #include namespace Catch { diff --git a/src/catch2/internal/catch_is_permutation.hpp b/src/catch2/internal/catch_is_permutation.hpp index 708053d35c..c77a6d3b43 100644 --- a/src/catch2/internal/catch_is_permutation.hpp +++ b/src/catch2/internal/catch_is_permutation.hpp @@ -18,6 +18,7 @@ namespace Catch { typename Sentinel, typename T, typename Comparator> + constexpr ForwardIter find_sentinel( ForwardIter start, Sentinel sentinel, T const& value, @@ -33,6 +34,7 @@ namespace Catch { typename Sentinel, typename T, typename Comparator> + constexpr std::ptrdiff_t count_sentinel( ForwardIter start, Sentinel sentinel, T const& value, @@ -46,6 +48,7 @@ namespace Catch { } template + constexpr std::enable_if_t::value, std::ptrdiff_t> sentinel_distance( ForwardIter iter, const Sentinel sentinel ) { @@ -58,8 +61,8 @@ namespace Catch { } template - std::ptrdiff_t sentinel_distance( ForwardIter first, - ForwardIter last ) { + constexpr std::ptrdiff_t sentinel_distance( ForwardIter first, + ForwardIter last ) { return std::distance( first, last ); } @@ -68,11 +71,11 @@ namespace Catch { typename ForwardIter2, typename Sentinel2, typename Comparator> - bool check_element_counts( ForwardIter1 first_1, - const Sentinel1 end_1, - ForwardIter2 first_2, - const Sentinel2 end_2, - Comparator cmp ) { + constexpr bool check_element_counts( ForwardIter1 first_1, + const Sentinel1 end_1, + ForwardIter2 first_2, + const Sentinel2 end_2, + Comparator cmp ) { auto cursor = first_1; while ( cursor != end_1 ) { if ( find_sentinel( first_1, cursor, *cursor, cmp ) == @@ -102,11 +105,11 @@ namespace Catch { typename ForwardIter2, typename Sentinel2, typename Comparator> - bool is_permutation( ForwardIter1 first_1, - const Sentinel1 end_1, - ForwardIter2 first_2, - const Sentinel2 end_2, - Comparator cmp ) { + constexpr bool is_permutation( ForwardIter1 first_1, + const Sentinel1 end_1, + ForwardIter2 first_2, + const Sentinel2 end_2, + Comparator cmp ) { // TODO: no optimization for stronger iterators, because we would also have to constrain on sentinel vs not sentinel types // TODO: Comparator has to be "both sides", e.g. a == b => b == a // This skips shared prefix of the two ranges diff --git a/src/catch2/internal/catch_istream.cpp b/src/catch2/internal/catch_istream.cpp index bf0f66e423..2867ce747c 100644 --- a/src/catch2/internal/catch_istream.cpp +++ b/src/catch2/internal/catch_istream.cpp @@ -80,7 +80,6 @@ namespace Detail { CATCH_ENFORCE( !m_ofs.fail(), "Unable to open file: '" << filename << '\'' ); m_ofs << std::unitbuf; } - ~FileStream() override = default; public: // IStream std::ostream& stream() override { return m_ofs; @@ -95,7 +94,6 @@ namespace Detail { // Store the streambuf from cout up-front because // cout may get redirected when running tests CoutStream() : m_os( Catch::cout().rdbuf() ) {} - ~CoutStream() override = default; public: // IStream std::ostream& stream() override { return m_os; } @@ -109,7 +107,6 @@ namespace Detail { // Store the streambuf from cerr up-front because // cout may get redirected when running tests CerrStream(): m_os( Catch::cerr().rdbuf() ) {} - ~CerrStream() override = default; public: // IStream std::ostream& stream() override { return m_os; } @@ -127,8 +124,6 @@ namespace Detail { m_os( m_streamBuf.get() ) {} - ~DebugOutStream() override = default; - public: // IStream std::ostream& stream() override { return m_os; } }; diff --git a/src/catch2/internal/catch_jsonwriter.cpp b/src/catch2/internal/catch_jsonwriter.cpp index ff65a9d346..1a96e3489f 100644 --- a/src/catch2/internal/catch_jsonwriter.cpp +++ b/src/catch2/internal/catch_jsonwriter.cpp @@ -31,7 +31,7 @@ namespace Catch { m_os{ os }, m_indent_level{ indent_level } { m_os << '{'; } - JsonObjectWriter::JsonObjectWriter( JsonObjectWriter&& source ): + JsonObjectWriter::JsonObjectWriter( JsonObjectWriter&& source ) noexcept: m_os{ source.m_os }, m_indent_level{ source.m_indent_level }, m_should_comma{ source.m_should_comma }, @@ -62,7 +62,7 @@ namespace Catch { m_os{ os }, m_indent_level{ indent_level } { m_os << '['; } - JsonArrayWriter::JsonArrayWriter( JsonArrayWriter&& source ): + JsonArrayWriter::JsonArrayWriter( JsonArrayWriter&& source ) noexcept: m_os{ source.m_os }, m_indent_level{ source.m_indent_level }, m_should_comma{ source.m_should_comma }, diff --git a/src/catch2/internal/catch_jsonwriter.hpp b/src/catch2/internal/catch_jsonwriter.hpp index 59c044e450..23b56d13a0 100644 --- a/src/catch2/internal/catch_jsonwriter.hpp +++ b/src/catch2/internal/catch_jsonwriter.hpp @@ -65,7 +65,7 @@ namespace Catch { JsonObjectWriter( std::ostream& os ); JsonObjectWriter( std::ostream& os, std::uint64_t indent_level ); - JsonObjectWriter( JsonObjectWriter&& source ); + JsonObjectWriter( JsonObjectWriter&& source ) noexcept; JsonObjectWriter& operator=( JsonObjectWriter&& source ) = delete; ~JsonObjectWriter(); @@ -84,7 +84,7 @@ namespace Catch { JsonArrayWriter( std::ostream& os ); JsonArrayWriter( std::ostream& os, std::uint64_t indent_level ); - JsonArrayWriter( JsonArrayWriter&& source ); + JsonArrayWriter( JsonArrayWriter&& source ) noexcept; JsonArrayWriter& operator=( JsonArrayWriter&& source ) = delete; ~JsonArrayWriter(); diff --git a/src/catch2/internal/catch_lazy_expr.hpp b/src/catch2/internal/catch_lazy_expr.hpp index 36e0ac5002..c6ff224111 100644 --- a/src/catch2/internal/catch_lazy_expr.hpp +++ b/src/catch2/internal/catch_lazy_expr.hpp @@ -22,13 +22,13 @@ namespace Catch { ITransientExpression const* m_transientExpression = nullptr; bool m_isNegated; public: - LazyExpression( bool isNegated ): + constexpr LazyExpression( bool isNegated ): m_isNegated(isNegated) {} - LazyExpression(LazyExpression const& other) = default; + constexpr LazyExpression(LazyExpression const& other) = default; LazyExpression& operator = ( LazyExpression const& ) = delete; - explicit operator bool() const { + constexpr explicit operator bool() const { return m_transientExpression != nullptr; } diff --git a/src/catch2/internal/catch_list.cpp b/src/catch2/internal/catch_list.cpp index 97e4c59315..5bd06a2aef 100644 --- a/src/catch2/internal/catch_list.cpp +++ b/src/catch2/internal/catch_list.cpp @@ -14,10 +14,7 @@ #include #include #include - -#include #include -#include #include namespace Catch { diff --git a/src/catch2/internal/catch_output_redirect.cpp b/src/catch2/internal/catch_output_redirect.cpp index 02f7c98268..245e1376cf 100644 --- a/src/catch2/internal/catch_output_redirect.cpp +++ b/src/catch2/internal/catch_output_redirect.cpp @@ -5,142 +5,335 @@ // https://www.boost.org/LICENSE_1_0.txt) // SPDX-License-Identifier: BSL-1.0 -#include +#include #include +#include +#include +#include #include #include #include +#include #include -#if defined(CATCH_CONFIG_NEW_CAPTURE) - #if defined(_MSC_VER) - #include //_dup and _dup2 - #define dup _dup - #define dup2 _dup2 - #define fileno _fileno - #else - #include // dup and dup2 - #endif +#if defined( CATCH_CONFIG_NEW_CAPTURE ) +# if defined( _MSC_VER ) +# include //_dup and _dup2 +# define dup _dup +# define dup2 _dup2 +# define fileno _fileno +# else +# include // dup and dup2 +# endif #endif - namespace Catch { - RedirectedStream::RedirectedStream( std::ostream& originalStream, std::ostream& redirectionStream ) - : m_originalStream( originalStream ), - m_redirectionStream( redirectionStream ), - m_prevBuf( m_originalStream.rdbuf() ) - { - m_originalStream.rdbuf( m_redirectionStream.rdbuf() ); - } + namespace { + //! A no-op implementation, used if no reporter wants output + //! redirection. + class NoopRedirect : public OutputRedirect { + void activateImpl() override {} + void deactivateImpl() override {} + std::string getStdout() override { return {}; } + std::string getStderr() override { return {}; } + void clearBuffers() override {} + }; - RedirectedStream::~RedirectedStream() { - m_originalStream.rdbuf( m_prevBuf ); - } + /** + * Redirects specific stream's rdbuf with another's. + * + * Redirection can be stopped and started on-demand, assumes + * that the underlying stream's rdbuf aren't changed by other + * users. + */ + class RedirectedStreamNew { + std::ostream& m_originalStream; + std::ostream& m_redirectionStream; + std::streambuf* m_prevBuf; - RedirectedStdOut::RedirectedStdOut() : m_cout( Catch::cout(), m_rss.get() ) {} - auto RedirectedStdOut::str() const -> std::string { return m_rss.str(); } + public: + RedirectedStreamNew( std::ostream& originalStream, + std::ostream& redirectionStream ): + m_originalStream( originalStream ), + m_redirectionStream( redirectionStream ), + m_prevBuf( m_originalStream.rdbuf() ) {} - RedirectedStdErr::RedirectedStdErr() - : m_cerr( Catch::cerr(), m_rss.get() ), - m_clog( Catch::clog(), m_rss.get() ) - {} - auto RedirectedStdErr::str() const -> std::string { return m_rss.str(); } + void startRedirect() { + m_originalStream.rdbuf( m_redirectionStream.rdbuf() ); + } + void stopRedirect() { m_originalStream.rdbuf( m_prevBuf ); } + }; - RedirectedStreams::RedirectedStreams(std::string& redirectedCout, std::string& redirectedCerr) - : m_redirectedCout(redirectedCout), - m_redirectedCerr(redirectedCerr) - {} + /** + * Redirects the `std::cout`, `std::cerr`, `std::clog` streams, + * but does not touch the actual `stdout`/`stderr` file descriptors. + */ + class StreamRedirect : public OutputRedirect { + ReusableStringStream m_redirectedOut, m_redirectedErr; + RedirectedStreamNew m_cout, m_cerr, m_clog; - RedirectedStreams::~RedirectedStreams() { - m_redirectedCout += m_redirectedStdOut.str(); - m_redirectedCerr += m_redirectedStdErr.str(); - } + public: + StreamRedirect(): + m_cout( Catch::cout(), m_redirectedOut.get() ), + m_cerr( Catch::cerr(), m_redirectedErr.get() ), + m_clog( Catch::clog(), m_redirectedErr.get() ) {} -#if defined(CATCH_CONFIG_NEW_CAPTURE) + void activateImpl() override { + m_cout.startRedirect(); + m_cerr.startRedirect(); + m_clog.startRedirect(); + } + void deactivateImpl() override { + m_cout.stopRedirect(); + m_cerr.stopRedirect(); + m_clog.stopRedirect(); + } + std::string getStdout() override { return m_redirectedOut.str(); } + std::string getStderr() override { return m_redirectedErr.str(); } + void clearBuffers() override { + m_redirectedOut.str( "" ); + m_redirectedErr.str( "" ); + } + }; -#if defined(_MSC_VER) - TempFile::TempFile() { - if (tmpnam_s(m_buffer)) { - CATCH_RUNTIME_ERROR("Could not get a temp filename"); - } - if (fopen_s(&m_file, m_buffer, "w+")) { - char buffer[100]; - if (strerror_s(buffer, errno)) { - CATCH_RUNTIME_ERROR("Could not translate errno to a string"); +#if defined( CATCH_CONFIG_NEW_CAPTURE ) + + // Windows's implementation of std::tmpfile is terrible (it tries + // to create a file inside system folder, thus requiring elevated + // privileges for the binary), so we have to use tmpnam(_s) and + // create the file ourselves there. + class TempFile { + public: + TempFile( TempFile const& ) = delete; + TempFile& operator=( TempFile const& ) = delete; + TempFile( TempFile&& ) = delete; + TempFile& operator=( TempFile&& ) = delete; + +# if defined( _MSC_VER ) + TempFile() { + if ( tmpnam_s( m_buffer ) ) { + CATCH_RUNTIME_ERROR( "Could not get a temp filename" ); + } + if ( fopen_s( &m_file, m_buffer, "wb+" ) ) { + char buffer[100]; + if ( strerror_s( buffer, errno ) ) { + CATCH_RUNTIME_ERROR( + "Could not translate errno to a string" ); + } + CATCH_RUNTIME_ERROR( "Could not open the temp file: '" + << m_buffer + << "' because: " << buffer ); + } + } +# else + TempFile() { + m_file = std::tmpfile(); + if ( !m_file ) { + CATCH_RUNTIME_ERROR( "Could not create a temp file." ); + } + } +# endif + + ~TempFile() { + // TBD: What to do about errors here? + std::fclose( m_file ); + // We manually create the file on Windows only, on Linux + // it will be autodeleted +# if defined( _MSC_VER ) + std::remove( m_buffer ); +# endif + } + + std::FILE* getFile() { return m_file; } + std::string getContents() { + ReusableStringStream sstr; + constexpr long buffer_size = 100; + char buffer[buffer_size + 1] = {}; + long current_pos = ftell( m_file ); + CATCH_ENFORCE( current_pos >= 0, + "ftell failed, errno: " << errno ); + std::rewind( m_file ); + while ( current_pos > 0 ) { + auto read_characters = + std::fread( buffer, + 1, + std::min( buffer_size, current_pos ), + m_file ); + buffer[read_characters] = '\0'; + sstr << buffer; + current_pos -= static_cast( read_characters ); + } + return sstr.str(); + } + + void clear() { std::rewind( m_file ); } + + private: + std::FILE* m_file = nullptr; + char m_buffer[L_tmpnam] = { 0 }; + }; + + /** + * Redirects the actual `stdout`/`stderr` file descriptors. + * + * Works by replacing the file descriptors numbered 1 and 2 + * with an open temporary file. + */ + class FileRedirect : public OutputRedirect { + TempFile m_outFile, m_errFile; + int m_originalOut = -1; + int m_originalErr = -1; + + // Flushes cout/cerr/clog streams and stdout/stderr FDs + void flushEverything() { + Catch::cout() << std::flush; + fflush( stdout ); + // Since we support overriding these streams, we flush cerr + // even though std::cerr is unbuffered + Catch::cerr() << std::flush; + Catch::clog() << std::flush; + fflush( stderr ); + } + + public: + FileRedirect(): + m_originalOut( dup( fileno( stdout ) ) ), + m_originalErr( dup( fileno( stderr ) ) ) { + CATCH_ENFORCE( m_originalOut >= 0, "Could not dup stdout" ); + CATCH_ENFORCE( m_originalErr >= 0, "Could not dup stderr" ); } - CATCH_RUNTIME_ERROR("Could not open the temp file: '" << m_buffer << "' because: " << buffer); + + std::string getStdout() override { return m_outFile.getContents(); } + std::string getStderr() override { return m_errFile.getContents(); } + void clearBuffers() override { + m_outFile.clear(); + m_errFile.clear(); + } + + void activateImpl() override { + // We flush before starting redirect, to ensure that we do + // not capture the end of message sent before activation. + flushEverything(); + + int ret; + ret = dup2( fileno( m_outFile.getFile() ), fileno( stdout ) ); + CATCH_ENFORCE( ret >= 0, + "dup2 to stdout has failed, errno: " << errno ); + ret = dup2( fileno( m_errFile.getFile() ), fileno( stderr ) ); + CATCH_ENFORCE( ret >= 0, + "dup2 to stderr has failed, errno: " << errno ); + } + void deactivateImpl() override { + // We flush before ending redirect, to ensure that we + // capture all messages sent while the redirect was active. + flushEverything(); + + int ret; + ret = dup2( m_originalOut, fileno( stdout ) ); + CATCH_ENFORCE( + ret >= 0, + "dup2 of original stdout has failed, errno: " << errno ); + ret = dup2( m_originalErr, fileno( stderr ) ); + CATCH_ENFORCE( + ret >= 0, + "dup2 of original stderr has failed, errno: " << errno ); + } + }; + +#endif // CATCH_CONFIG_NEW_CAPTURE + + } // end namespace + + bool isRedirectAvailable( OutputRedirect::Kind kind ) { + switch ( kind ) { + // These two are always available + case OutputRedirect::None: + case OutputRedirect::Streams: + return true; +#if defined( CATCH_CONFIG_NEW_CAPTURE ) + case OutputRedirect::FileDescriptors: + return true; +#endif + default: + return false; } } + + Detail::unique_ptr makeOutputRedirect( bool actual ) { + if ( actual ) { + // TODO: Clean this up later +#if defined( CATCH_CONFIG_NEW_CAPTURE ) + return Detail::make_unique(); #else - TempFile::TempFile() { - m_file = std::tmpfile(); - if (!m_file) { - CATCH_RUNTIME_ERROR("Could not create a temp file."); + return Detail::make_unique(); +#endif + } else { + return Detail::make_unique(); } } -#endif + RedirectGuard scopedActivate( OutputRedirect& redirectImpl ) { + return RedirectGuard( true, redirectImpl ); + } - TempFile::~TempFile() { - // TBD: What to do about errors here? - std::fclose(m_file); - // We manually create the file on Windows only, on Linux - // it will be autodeleted -#if defined(_MSC_VER) - std::remove(m_buffer); -#endif + RedirectGuard scopedDeactivate( OutputRedirect& redirectImpl ) { + return RedirectGuard( false, redirectImpl ); } + OutputRedirect::~OutputRedirect() = default; - FILE* TempFile::getFile() { - return m_file; - } + RedirectGuard::RedirectGuard( bool activate, OutputRedirect& redirectImpl ): + m_redirect( &redirectImpl ), + m_activate( activate ), + m_previouslyActive( redirectImpl.isActive() ) { - std::string TempFile::getContents() { - std::stringstream sstr; - char buffer[100] = {}; - std::rewind(m_file); - while (std::fgets(buffer, sizeof(buffer), m_file)) { - sstr << buffer; - } - return sstr.str(); - } + // Skip cases where there is no actual state change. + if ( m_activate == m_previouslyActive ) { return; } - OutputRedirect::OutputRedirect(std::string& stdout_dest, std::string& stderr_dest) : - m_originalStdout(dup(1)), - m_originalStderr(dup(2)), - m_stdoutDest(stdout_dest), - m_stderrDest(stderr_dest) { - dup2(fileno(m_stdoutFile.getFile()), 1); - dup2(fileno(m_stderrFile.getFile()), 2); + if ( m_activate ) { + m_redirect->activate(); + } else { + m_redirect->deactivate(); + } } - OutputRedirect::~OutputRedirect() { - Catch::cout() << std::flush; - fflush(stdout); - // Since we support overriding these streams, we flush cerr - // even though std::cerr is unbuffered - Catch::cerr() << std::flush; - Catch::clog() << std::flush; - fflush(stderr); + RedirectGuard::~RedirectGuard() noexcept( false ) { + if ( m_moved ) { return; } + // Skip cases where there is no actual state change. + if ( m_activate == m_previouslyActive ) { return; } - dup2(m_originalStdout, 1); - dup2(m_originalStderr, 2); + if ( m_activate ) { + m_redirect->deactivate(); + } else { + m_redirect->activate(); + } + } - m_stdoutDest += m_stdoutFile.getContents(); - m_stderrDest += m_stderrFile.getContents(); + RedirectGuard::RedirectGuard( RedirectGuard&& rhs ) noexcept: + m_redirect( rhs.m_redirect ), + m_activate( rhs.m_activate ), + m_previouslyActive( rhs.m_previouslyActive ), + m_moved( false ) { + rhs.m_moved = true; } -#endif // CATCH_CONFIG_NEW_CAPTURE + RedirectGuard& RedirectGuard::operator=( RedirectGuard&& rhs ) noexcept { + m_redirect = rhs.m_redirect; + m_activate = rhs.m_activate; + m_previouslyActive = rhs.m_previouslyActive; + m_moved = false; + rhs.m_moved = true; + return *this; + } } // namespace Catch -#if defined(CATCH_CONFIG_NEW_CAPTURE) - #if defined(_MSC_VER) - #undef dup - #undef dup2 - #undef fileno - #endif +#if defined( CATCH_CONFIG_NEW_CAPTURE ) +# if defined( _MSC_VER ) +# undef dup +# undef dup2 +# undef fileno +# endif #endif diff --git a/src/catch2/internal/catch_output_redirect.hpp b/src/catch2/internal/catch_output_redirect.hpp index dc89223b92..51b796baa1 100644 --- a/src/catch2/internal/catch_output_redirect.hpp +++ b/src/catch2/internal/catch_output_redirect.hpp @@ -8,110 +8,69 @@ #ifndef CATCH_OUTPUT_REDIRECT_HPP_INCLUDED #define CATCH_OUTPUT_REDIRECT_HPP_INCLUDED -#include -#include -#include +#include -#include -#include +#include #include namespace Catch { - class RedirectedStream { - std::ostream& m_originalStream; - std::ostream& m_redirectionStream; - std::streambuf* m_prevBuf; - - public: - RedirectedStream( std::ostream& originalStream, std::ostream& redirectionStream ); - ~RedirectedStream(); - }; - - class RedirectedStdOut { - ReusableStringStream m_rss; - RedirectedStream m_cout; - public: - RedirectedStdOut(); - auto str() const -> std::string; - }; - - // StdErr has two constituent streams in C++, std::cerr and std::clog - // This means that we need to redirect 2 streams into 1 to keep proper - // order of writes - class RedirectedStdErr { - ReusableStringStream m_rss; - RedirectedStream m_cerr; - RedirectedStream m_clog; + class OutputRedirect { + bool m_redirectActive = false; + virtual void activateImpl() = 0; + virtual void deactivateImpl() = 0; public: - RedirectedStdErr(); - auto str() const -> std::string; + enum Kind { + //! No redirect (noop implementation) + None, + //! Redirect std::cout/std::cerr/std::clog streams internally + Streams, + //! Redirect the stdout/stderr file descriptors into files + FileDescriptors, + }; + + virtual ~OutputRedirect(); // = default; + + // TODO: Do we want to check that redirect is not active before retrieving the output? + virtual std::string getStdout() = 0; + virtual std::string getStderr() = 0; + virtual void clearBuffers() = 0; + bool isActive() const { return m_redirectActive; } + void activate() { + assert( !m_redirectActive && "redirect is already active" ); + activateImpl(); + m_redirectActive = true; + } + void deactivate() { + assert( m_redirectActive && "redirect is not active" ); + deactivateImpl(); + m_redirectActive = false; + } }; - class RedirectedStreams { - public: - RedirectedStreams(RedirectedStreams const&) = delete; - RedirectedStreams& operator=(RedirectedStreams const&) = delete; - RedirectedStreams(RedirectedStreams&&) = delete; - RedirectedStreams& operator=(RedirectedStreams&&) = delete; - - RedirectedStreams(std::string& redirectedCout, std::string& redirectedCerr); - ~RedirectedStreams(); - private: - std::string& m_redirectedCout; - std::string& m_redirectedCerr; - RedirectedStdOut m_redirectedStdOut; - RedirectedStdErr m_redirectedStdErr; - }; + bool isRedirectAvailable( OutputRedirect::Kind kind); + Detail::unique_ptr makeOutputRedirect( bool actual ); -#if defined(CATCH_CONFIG_NEW_CAPTURE) + class RedirectGuard { + OutputRedirect* m_redirect; + bool m_activate; + bool m_previouslyActive; + bool m_moved = false; - // Windows's implementation of std::tmpfile is terrible (it tries - // to create a file inside system folder, thus requiring elevated - // privileges for the binary), so we have to use tmpnam(_s) and - // create the file ourselves there. - class TempFile { public: - TempFile(TempFile const&) = delete; - TempFile& operator=(TempFile const&) = delete; - TempFile(TempFile&&) = delete; - TempFile& operator=(TempFile&&) = delete; - - TempFile(); - ~TempFile(); - - std::FILE* getFile(); - std::string getContents(); - - private: - std::FILE* m_file = nullptr; - #if defined(_MSC_VER) - char m_buffer[L_tmpnam] = { 0 }; - #endif - }; + RedirectGuard( bool activate, OutputRedirect& redirectImpl ); + ~RedirectGuard() noexcept( false ); + RedirectGuard( RedirectGuard const& ) = delete; + RedirectGuard& operator=( RedirectGuard const& ) = delete; - class OutputRedirect { - public: - OutputRedirect(OutputRedirect const&) = delete; - OutputRedirect& operator=(OutputRedirect const&) = delete; - OutputRedirect(OutputRedirect&&) = delete; - OutputRedirect& operator=(OutputRedirect&&) = delete; - - - OutputRedirect(std::string& stdout_dest, std::string& stderr_dest); - ~OutputRedirect(); - - private: - int m_originalStdout = -1; - int m_originalStderr = -1; - TempFile m_stdoutFile; - TempFile m_stderrFile; - std::string& m_stdoutDest; - std::string& m_stderrDest; + // C++14 needs move-able guards to return them from functions + RedirectGuard( RedirectGuard&& rhs ) noexcept; + RedirectGuard& operator=( RedirectGuard&& rhs ) noexcept; }; -#endif + RedirectGuard scopedActivate( OutputRedirect& redirectImpl ); + RedirectGuard scopedDeactivate( OutputRedirect& redirectImpl ); } // end namespace Catch diff --git a/src/catch2/internal/catch_platform.hpp b/src/catch2/internal/catch_platform.hpp index b11d9ccde7..b653a58c5e 100644 --- a/src/catch2/internal/catch_platform.hpp +++ b/src/catch2/internal/catch_platform.hpp @@ -11,6 +11,9 @@ // See e.g.: // https://opensource.apple.com/source/CarbonHeaders/CarbonHeaders-18.1/TargetConditionals.h.auto.html #ifdef __APPLE__ +# ifndef __has_extension +# define __has_extension(x) 0 +# endif # include # if (defined(TARGET_OS_OSX) && TARGET_OS_OSX == 1) || \ (defined(TARGET_OS_MAC) && TARGET_OS_MAC == 1) diff --git a/src/catch2/internal/catch_random_integer_helpers.hpp b/src/catch2/internal/catch_random_integer_helpers.hpp index 1c450f05c3..be4bbe9203 100644 --- a/src/catch2/internal/catch_random_integer_helpers.hpp +++ b/src/catch2/internal/catch_random_integer_helpers.hpp @@ -14,6 +14,34 @@ #include #include +// Note: We use the usual enable-disable-autodetect dance here even though +// we do not support these in CMake configuration options (yet?). +// It is highly unlikely that we will need to make these actually +// user-configurable, but this will make it simpler if weend up needing +// it, and it provides an escape hatch to the users who need it. +#if defined( __SIZEOF_INT128__ ) +# define CATCH_CONFIG_INTERNAL_UINT128 +// Unlike GCC, MSVC does not polyfill umul as mulh + mul pair on ARM machines. +// Currently we do not bother doing this ourselves, but we could if it became +// important for perf. +#elif defined( _MSC_VER ) && defined( _M_X64 ) +# define CATCH_CONFIG_INTERNAL_MSVC_UMUL128 +#endif + +#if defined( CATCH_CONFIG_INTERNAL_UINT128 ) && \ + !defined( CATCH_CONFIG_NO_UINT128 ) && \ + !defined( CATCH_CONFIG_UINT128 ) +#define CATCH_CONFIG_UINT128 +#endif + +#if defined( CATCH_CONFIG_INTERNAL_MSVC_UMUL128 ) && \ + !defined( CATCH_CONFIG_NO_MSVC_UMUL128 ) && \ + !defined( CATCH_CONFIG_MSVC_UMUL128 ) +# define CATCH_CONFIG_MSVC_UMUL128 +# include +#endif + + namespace Catch { namespace Detail { @@ -41,65 +69,57 @@ namespace Catch { struct ExtendedMultResult { T upper; T lower; - friend bool operator==( ExtendedMultResult const& lhs, - ExtendedMultResult const& rhs ) { - return lhs.upper == rhs.upper && lhs.lower == rhs.lower; + constexpr bool operator==( ExtendedMultResult const& rhs ) const { + return upper == rhs.upper && lower == rhs.lower; } }; - // Returns 128 bit result of multiplying lhs and rhs + /** + * Returns 128 bit result of lhs * rhs using portable C++ code + * + * This implementation is almost twice as fast as naive long multiplication, + * and unlike intrinsic-based approach, it supports constexpr evaluation. + */ constexpr ExtendedMultResult - extendedMult( std::uint64_t lhs, std::uint64_t rhs ) { - // We use the simple long multiplication approach for - // correctness, we can use platform specific builtins - // for performance later. - - // Split the lhs and rhs into two 32bit "digits", so that we can - // do 64 bit arithmetic to handle carry bits. - // 32b 32b 32b 32b - // lhs L1 L2 - // * rhs R1 R2 - // ------------------------ - // | R2 * L2 | - // | R2 * L1 | - // | R1 * L2 | - // | R1 * L1 | - // ------------------------- - // | a | b | c | d | - + extendedMultPortable(std::uint64_t lhs, std::uint64_t rhs) { #define CarryBits( x ) ( x >> 32 ) #define Digits( x ) ( x & 0xFF'FF'FF'FF ) - - auto r2l2 = Digits( rhs ) * Digits( lhs ); - auto r2l1 = Digits( rhs ) * CarryBits( lhs ); - auto r1l2 = CarryBits( rhs ) * Digits( lhs ); - auto r1l1 = CarryBits( rhs ) * CarryBits( lhs ); - - // Sum to columns first - auto d = Digits( r2l2 ); - auto c = CarryBits( r2l2 ) + Digits( r2l1 ) + Digits( r1l2 ); - auto b = CarryBits( r2l1 ) + CarryBits( r1l2 ) + Digits( r1l1 ); - auto a = CarryBits( r1l1 ); - - // Propagate carries between columns - c += CarryBits( d ); - b += CarryBits( c ); - a += CarryBits( b ); - - // Remove the used carries - c = Digits( c ); - b = Digits( b ); - a = Digits( a ); - + std::uint64_t lhs_low = Digits( lhs ); + std::uint64_t rhs_low = Digits( rhs ); + std::uint64_t low_low = ( lhs_low * rhs_low ); + std::uint64_t high_high = CarryBits( lhs ) * CarryBits( rhs ); + + // We add in carry bits from low-low already + std::uint64_t high_low = + ( CarryBits( lhs ) * rhs_low ) + CarryBits( low_low ); + // Note that we can add only low bits from high_low, to avoid + // overflow with large inputs + std::uint64_t low_high = + ( lhs_low * CarryBits( rhs ) ) + Digits( high_low ); + + return { high_high + CarryBits( high_low ) + CarryBits( low_high ), + ( low_high << 32 ) | Digits( low_low ) }; #undef CarryBits #undef Digits + } - return { - a << 32 | b, // upper 64 bits - c << 32 | d // lower 64 bits - }; + //! Returns 128 bit result of lhs * rhs + inline ExtendedMultResult + extendedMult( std::uint64_t lhs, std::uint64_t rhs ) { +#if defined( CATCH_CONFIG_UINT128 ) + auto result = __uint128_t( lhs ) * __uint128_t( rhs ); + return { static_cast( result >> 64 ), + static_cast( result ) }; +#elif defined( CATCH_CONFIG_MSVC_UMUL128 ) + std::uint64_t high; + std::uint64_t low = _umul128( lhs, rhs, &high ); + return { high, low }; +#else + return extendedMultPortable( lhs, rhs ); +#endif } + template constexpr ExtendedMultResult extendedMult( UInt lhs, UInt rhs ) { static_assert( std::is_unsigned::value, @@ -167,6 +187,7 @@ namespace Catch { * get by simple casting ([0, ..., INT_MAX, INT_MIN, ..., -1]) */ template + constexpr std::enable_if_t::value, UnsignedType> transposeToNaturalOrder( UnsignedType in ) { static_assert( @@ -187,6 +208,7 @@ namespace Catch { template + constexpr std::enable_if_t::value, UnsignedType> transposeToNaturalOrder(UnsignedType in) { static_assert( diff --git a/src/catch2/internal/catch_reporter_spec_parser.cpp b/src/catch2/internal/catch_reporter_spec_parser.cpp index 8b88b170a5..2b08758a03 100644 --- a/src/catch2/internal/catch_reporter_spec_parser.cpp +++ b/src/catch2/internal/catch_reporter_spec_parser.cpp @@ -117,7 +117,7 @@ namespace Catch { auto kv = splitKVPair( parts[i] ); auto key = kv.key, value = kv.value; - if ( key.empty() || value.empty() ) { + if ( key.empty() || value.empty() ) { // NOLINT(bugprone-branch-clone) return {}; } else if ( key[0] == 'X' ) { // This is a reporter-specific option, we don't check these diff --git a/src/catch2/internal/catch_reporter_spec_parser.hpp b/src/catch2/internal/catch_reporter_spec_parser.hpp index d446ce98b4..9f447ee2f7 100644 --- a/src/catch2/internal/catch_reporter_spec_parser.hpp +++ b/src/catch2/internal/catch_reporter_spec_parser.hpp @@ -8,7 +8,7 @@ #ifndef CATCH_REPORTER_SPEC_PARSER_HPP_INCLUDED #define CATCH_REPORTER_SPEC_PARSER_HPP_INCLUDED -#include +#include #include #include diff --git a/src/catch2/internal/catch_result_type.cpp b/src/catch2/internal/catch_result_type.cpp deleted file mode 100644 index 6cedce7169..0000000000 --- a/src/catch2/internal/catch_result_type.cpp +++ /dev/null @@ -1,26 +0,0 @@ - -// Copyright Catch2 Authors -// Distributed under the Boost Software License, Version 1.0. -// (See accompanying file LICENSE.txt or copy at -// https://www.boost.org/LICENSE_1_0.txt) - -// SPDX-License-Identifier: BSL-1.0 -#include - -namespace Catch { - - bool isOk( ResultWas::OfType resultType ) { - return ( resultType & ResultWas::FailureBit ) == 0; - } - bool isJustInfo( int flags ) { - return flags == ResultWas::Info; - } - - ResultDisposition::Flags operator | ( ResultDisposition::Flags lhs, ResultDisposition::Flags rhs ) { - return static_cast( static_cast( lhs ) | static_cast( rhs ) ); - } - - bool shouldContinueOnFailure( int flags ) { return ( flags & ResultDisposition::ContinueOnFailure ) != 0; } - bool shouldSuppressFailure( int flags ) { return ( flags & ResultDisposition::SuppressFail ) != 0; } - -} // end namespace Catch diff --git a/src/catch2/internal/catch_result_type.hpp b/src/catch2/internal/catch_result_type.hpp index e66afaff00..69a6ef1413 100644 --- a/src/catch2/internal/catch_result_type.hpp +++ b/src/catch2/internal/catch_result_type.hpp @@ -33,8 +33,10 @@ namespace Catch { }; }; - bool isOk( ResultWas::OfType resultType ); - bool isJustInfo( int flags ); + constexpr bool isOk( ResultWas::OfType resultType ) { + return ( resultType & ResultWas::FailureBit ) == 0; + } + constexpr bool isJustInfo( int flags ) { return flags == ResultWas::Info; } // ResultDisposition::Flags enum @@ -46,11 +48,18 @@ namespace Catch { SuppressFail = 0x08 // Failures are reported but do not fail the test }; }; - ResultDisposition::Flags operator | ( ResultDisposition::Flags lhs, ResultDisposition::Flags rhs ); - - bool shouldContinueOnFailure( int flags ); - inline bool isFalseTest( int flags ) { return ( flags & ResultDisposition::FalseTest ) != 0; } - bool shouldSuppressFailure( int flags ); + constexpr ResultDisposition::Flags operator|( ResultDisposition::Flags lhs, + ResultDisposition::Flags rhs ) { + return static_cast( static_cast( lhs ) | + static_cast( rhs ) ); + } + + constexpr bool isFalseTest( int flags ) { + return ( flags & ResultDisposition::FalseTest ) != 0; + } + constexpr bool shouldSuppressFailure( int flags ) { + return ( flags & ResultDisposition::SuppressFail ) != 0; + } } // end namespace Catch diff --git a/src/catch2/internal/catch_run_context.cpp b/src/catch2/internal/catch_run_context.cpp index e568100d60..2a102fbeec 100644 --- a/src/catch2/internal/catch_run_context.cpp +++ b/src/catch2/internal/catch_run_context.cpp @@ -38,7 +38,6 @@ namespace Catch { TrackerContext& ctx, ITracker* parent ): TrackerBase( CATCH_MOVE( nameAndLocation ), ctx, parent ) {} - ~GeneratorTracker() override = default; static GeneratorTracker* acquire( TrackerContext& ctx, @@ -171,6 +170,7 @@ namespace Catch { m_config(_config), m_reporter(CATCH_MOVE(reporter)), m_lastAssertionInfo{ StringRef(), SourceLineInfo("",0), StringRef(), ResultDisposition::Normal }, + m_outputRedirect( makeOutputRedirect( m_reporter->getPreferences().shouldRedirectStdOut ) ), m_includeSuccessfulResults( m_config->includeSuccessfulResults() || m_reporter->getPreferences().shouldReportAllAssertions ) { getCurrentMutableContext().setResultCapture( this ); @@ -186,6 +186,7 @@ namespace Catch { auto const& testInfo = testCase.getTestCaseInfo(); m_reporter->testCaseStarting(testInfo); + testCase.prepareTestCase(); m_activeTestCase = &testCase; @@ -236,15 +237,17 @@ namespace Catch { m_reporter->testCasePartialStarting(testInfo, testRuns); const auto beforeRunTotals = m_totals; - std::string oneRunCout, oneRunCerr; - runCurrentTest(oneRunCout, oneRunCerr); + runCurrentTest(); + std::string oneRunCout = m_outputRedirect->getStdout(); + std::string oneRunCerr = m_outputRedirect->getStderr(); + m_outputRedirect->clearBuffers(); redirectedCout += oneRunCout; redirectedCerr += oneRunCerr; const auto singleRunTotals = m_totals.delta(beforeRunTotals); auto statsForOneRun = TestCaseStats(testInfo, singleRunTotals, CATCH_MOVE(oneRunCout), CATCH_MOVE(oneRunCerr), aborting()); - m_reporter->testCasePartialEnded(statsForOneRun, testRuns); + ++testRuns; } while (!m_testCaseTracker->isSuccessfullyCompleted() && !aborting()); @@ -255,6 +258,7 @@ namespace Catch { deltaTotals.testCases.failed++; } m_totals.testCases += deltaTotals.testCases; + testCase.tearDownTestCase(); m_reporter->testCaseEnded(TestCaseStats(testInfo, deltaTotals, CATCH_MOVE(redirectedCout), @@ -288,7 +292,10 @@ namespace Catch { m_lastAssertionPassed = true; } - m_reporter->assertionEnded(AssertionStats(result, m_messages, m_totals)); + { + auto _ = scopedDeactivate( *m_outputRedirect ); + m_reporter->assertionEnded( AssertionStats( result, m_messages, m_totals ) ); + } if ( result.getResultType() != ResultWas::Warning ) { m_messageScopes.clear(); @@ -305,6 +312,7 @@ namespace Catch { } void RunContext::notifyAssertionStarted( AssertionInfo const& info ) { + auto _ = scopedDeactivate( *m_outputRedirect ); m_reporter->assertionStarting( info ); } @@ -323,7 +331,10 @@ namespace Catch { SectionInfo sectionInfo( sectionLineInfo, static_cast(sectionName) ); m_lastAssertionInfo.lineInfo = sectionInfo.lineInfo; - m_reporter->sectionStarting(sectionInfo); + { + auto _ = scopedDeactivate( *m_outputRedirect ); + m_reporter->sectionStarting( sectionInfo ); + } assertions = m_totals.assertions; @@ -383,7 +394,15 @@ namespace Catch { m_activeSections.pop_back(); } - m_reporter->sectionEnded(SectionStats(CATCH_MOVE(endInfo.sectionInfo), assertions, endInfo.durationInSeconds, missingAssertions)); + { + auto _ = scopedDeactivate( *m_outputRedirect ); + m_reporter->sectionEnded( + SectionStats( CATCH_MOVE( endInfo.sectionInfo ), + assertions, + endInfo.durationInSeconds, + missingAssertions ) ); + } + m_messages.clear(); m_messageScopes.clear(); } @@ -400,15 +419,19 @@ namespace Catch { } void RunContext::benchmarkPreparing( StringRef name ) { - m_reporter->benchmarkPreparing(name); + auto _ = scopedDeactivate( *m_outputRedirect ); + m_reporter->benchmarkPreparing( name ); } void RunContext::benchmarkStarting( BenchmarkInfo const& info ) { + auto _ = scopedDeactivate( *m_outputRedirect ); m_reporter->benchmarkStarting( info ); } void RunContext::benchmarkEnded( BenchmarkStats<> const& stats ) { + auto _ = scopedDeactivate( *m_outputRedirect ); m_reporter->benchmarkEnded( stats ); } void RunContext::benchmarkFailed( StringRef error ) { + auto _ = scopedDeactivate( *m_outputRedirect ); m_reporter->benchmarkFailed( error ); } @@ -439,8 +462,13 @@ namespace Catch { } void RunContext::handleFatalErrorCondition( StringRef message ) { + // TODO: scoped deactivate here? Just give up and do best effort? + // the deactivation can break things further, OTOH so can the + // capture + auto _ = scopedDeactivate( *m_outputRedirect ); + // First notify reporter that bad things happened - m_reporter->fatalErrorEncountered(message); + m_reporter->fatalErrorEncountered( message ); // Don't rebuild the result -- the stringification itself can cause more fatal errors // Instead, fake a result data. @@ -451,6 +479,13 @@ namespace Catch { assertionEnded(CATCH_MOVE(result) ); resetAssertionInfo(); + // Best effort cleanup for sections that have not been destructed yet + // Since this is a fatal error, we have not had and won't have the opportunity to destruct them properly + while (!m_activeSections.empty()) { + auto nl = m_activeSections.back()->nameAndLocation(); + SectionEndInfo endInfo{ SectionInfo(CATCH_MOVE(nl.location), CATCH_MOVE(nl.name)), {}, 0.0 }; + sectionEndedEarly(CATCH_MOVE(endInfo)); + } handleUnfinishedSections(); // Recreate section for test case (as we will lose the one that was in scope) @@ -460,7 +495,7 @@ namespace Catch { Counts assertions; assertions.failed = 1; SectionStats testCaseSectionStats(CATCH_MOVE(testCaseSection), assertions, 0, false); - m_reporter->sectionEnded(testCaseSectionStats); + m_reporter->sectionEnded( testCaseSectionStats ); auto const& testInfo = m_activeTestCase->getTestCaseInfo(); @@ -491,7 +526,7 @@ namespace Catch { return m_totals.assertions.failed >= static_cast(m_config->abortAfter()); } - void RunContext::runCurrentTest(std::string & redirectedCout, std::string & redirectedCerr) { + void RunContext::runCurrentTest() { auto const& testCaseInfo = m_activeTestCase->getTestCaseInfo(); SectionInfo testCaseSection(testCaseInfo.lineInfo, testCaseInfo.name); m_reporter->sectionStarting(testCaseSection); @@ -502,18 +537,8 @@ namespace Catch { Timer timer; CATCH_TRY { - if (m_reporter->getPreferences().shouldRedirectStdOut) { -#if !defined(CATCH_CONFIG_EXPERIMENTAL_REDIRECT) - RedirectedStreams redirectedStreams(redirectedCout, redirectedCerr); - - timer.start(); - invokeActiveTestCase(); -#else - OutputRedirect r(redirectedCout, redirectedCerr); - timer.start(); - invokeActiveTestCase(); -#endif - } else { + { + auto _ = scopedActivate( *m_outputRedirect ); timer.start(); invokeActiveTestCase(); } @@ -558,11 +583,12 @@ namespace Catch { void RunContext::handleUnfinishedSections() { // If sections ended prematurely due to an exception we stored their // infos here so we can tear them down outside the unwind process. - for (auto it = m_unfinishedSections.rbegin(), - itEnd = m_unfinishedSections.rend(); - it != itEnd; - ++it) - sectionEnded(CATCH_MOVE(*it)); + for ( auto it = m_unfinishedSections.rbegin(), + itEnd = m_unfinishedSections.rend(); + it != itEnd; + ++it ) { + sectionEnded( CATCH_MOVE( *it ) ); + } m_unfinishedSections.clear(); } @@ -606,13 +632,13 @@ namespace Catch { void RunContext::handleMessage( AssertionInfo const& info, ResultWas::OfType resultType, - StringRef message, + std::string&& message, AssertionReaction& reaction ) { m_lastAssertionInfo = info; AssertionResultData data( resultType, LazyExpression( false ) ); - data.message = static_cast(message); + data.message = CATCH_MOVE( message ); AssertionResult assertionResult{ m_lastAssertionInfo, CATCH_MOVE( data ) }; diff --git a/src/catch2/internal/catch_run_context.hpp b/src/catch2/internal/catch_run_context.hpp index c749304d3b..c66fec0ce9 100644 --- a/src/catch2/internal/catch_run_context.hpp +++ b/src/catch2/internal/catch_run_context.hpp @@ -29,6 +29,7 @@ namespace Catch { class IConfig; class IEventListener; using IEventListenerPtr = Detail::unique_ptr; + class OutputRedirect; /////////////////////////////////////////////////////////////////////////// @@ -54,7 +55,7 @@ namespace Catch { void handleMessage ( AssertionInfo const& info, ResultWas::OfType resultType, - StringRef message, + std::string&& message, AssertionReaction& reaction ) override; void handleUnexpectedExceptionNotThrown ( AssertionInfo const& info, @@ -115,7 +116,7 @@ namespace Catch { private: - void runCurrentTest( std::string& redirectedCout, std::string& redirectedCerr ); + void runCurrentTest(); void invokeActiveTestCase(); void resetAssertionInfo(); @@ -148,6 +149,7 @@ namespace Catch { std::vector m_unfinishedSections; std::vector m_activeSections; TrackerContext m_trackerContext; + Detail::unique_ptr m_outputRedirect; FatalConditionHandler m_fatalConditionhandler; bool m_lastAssertionPassed = false; bool m_shouldReportUnexpected = true; diff --git a/src/catch2/internal/catch_section.cpp b/src/catch2/internal/catch_section.cpp index 061732b1d8..677c2164c2 100644 --- a/src/catch2/internal/catch_section.cpp +++ b/src/catch2/internal/catch_section.cpp @@ -6,7 +6,7 @@ // SPDX-License-Identifier: BSL-1.0 #include -#include +#include #include #include diff --git a/src/catch2/internal/catch_section.hpp b/src/catch2/internal/catch_section.hpp index 8c894eeb87..e56c79f32d 100644 --- a/src/catch2/internal/catch_section.hpp +++ b/src/catch2/internal/catch_section.hpp @@ -69,7 +69,9 @@ namespace Catch { namespace Detail { // Intentionally without linkage, as it should only be used as a dummy // symbol for static analysis. - int GetNewSectionHint(); + // The arguments are used as a dummy for checking warnings in the passed + // expressions. + int GetNewSectionHint( StringRef, const char* const = nullptr ); } // namespace Detail } // namespace Catch @@ -80,7 +82,8 @@ namespace Catch { CATCH_INTERNAL_SUPPRESS_SHADOW_WARNINGS \ if ( [[maybe_unused]] const int catchInternalPreviousSectionHint = \ catchInternalSectionHint, \ - catchInternalSectionHint = Catch::Detail::GetNewSectionHint(); \ + catchInternalSectionHint = \ + Catch::Detail::GetNewSectionHint(__VA_ARGS__); \ catchInternalPreviousSectionHint == __LINE__ ) \ CATCH_INTERNAL_STOP_WARNINGS_SUPPRESSION @@ -90,7 +93,8 @@ namespace Catch { CATCH_INTERNAL_SUPPRESS_SHADOW_WARNINGS \ if ( [[maybe_unused]] const int catchInternalPreviousSectionHint = \ catchInternalSectionHint, \ - catchInternalSectionHint = Catch::Detail::GetNewSectionHint(); \ + catchInternalSectionHint = Catch::Detail::GetNewSectionHint( \ + ( Catch::ReusableStringStream() << __VA_ARGS__ ).str()); \ catchInternalPreviousSectionHint == __LINE__ ) \ CATCH_INTERNAL_STOP_WARNINGS_SUPPRESSION diff --git a/src/catch2/internal/catch_sharding.hpp b/src/catch2/internal/catch_sharding.hpp index d0e4cfa13f..22561f4bf1 100644 --- a/src/catch2/internal/catch_sharding.hpp +++ b/src/catch2/internal/catch_sharding.hpp @@ -8,8 +8,7 @@ #ifndef CATCH_SHARDING_HPP_INCLUDED #define CATCH_SHARDING_HPP_INCLUDED -#include - +#include #include #include diff --git a/src/catch2/internal/catch_string_manip.cpp b/src/catch2/internal/catch_string_manip.cpp index 0c889ca181..ce1abaa048 100644 --- a/src/catch2/internal/catch_string_manip.cpp +++ b/src/catch2/internal/catch_string_manip.cpp @@ -5,6 +5,7 @@ // https://www.boost.org/LICENSE_1_0.txt) // SPDX-License-Identifier: BSL-1.0 +#include #include #include @@ -65,17 +66,29 @@ namespace Catch { } bool replaceInPlace( std::string& str, std::string const& replaceThis, std::string const& withThis ) { - bool replaced = false; std::size_t i = str.find( replaceThis ); - while( i != std::string::npos ) { - replaced = true; - str = str.substr( 0, i ) + withThis + str.substr( i+replaceThis.size() ); - if( i < str.size()-withThis.size() ) - i = str.find( replaceThis, i+withThis.size() ); + if (i == std::string::npos) { + return false; + } + std::size_t copyBegin = 0; + std::string origStr = CATCH_MOVE(str); + str.clear(); + // There is at least one replacement, so reserve with the best guess + // we can make without actually counting the number of occurences. + str.reserve(origStr.size() - replaceThis.size() + withThis.size()); + do { + str.append(origStr, copyBegin, i-copyBegin ); + str += withThis; + copyBegin = i + replaceThis.size(); + if( copyBegin < origStr.size() ) + i = origStr.find( replaceThis, copyBegin ); else i = std::string::npos; + } while( i != std::string::npos ); + if ( copyBegin < origStr.size() ) { + str.append(origStr, copyBegin, origStr.size() ); } - return replaced; + return true; } std::vector splitStringRef( StringRef str, char delimiter ) { diff --git a/src/catch2/internal/catch_stringref.hpp b/src/catch2/internal/catch_stringref.hpp index 99bb9a986a..421ce71292 100644 --- a/src/catch2/internal/catch_stringref.hpp +++ b/src/catch2/internal/catch_stringref.hpp @@ -25,6 +25,8 @@ namespace Catch { using size_type = std::size_t; using const_iterator = const char*; + static constexpr size_type npos{ static_cast( -1 ) }; + private: static constexpr char const* const s_empty = ""; @@ -75,7 +77,7 @@ namespace Catch { } // Returns a substring of [start, start + length). - // If start + length > size(), then the substring is [start, start + size()). + // If start + length > size(), then the substring is [start, size()). // If start > size(), then the substring is empty. constexpr StringRef substr(size_type start, size_type length) const noexcept { if (start < m_size) { @@ -95,8 +97,8 @@ namespace Catch { constexpr const_iterator end() const { return m_start + m_size; } - friend std::string& operator += (std::string& lhs, StringRef sr); - friend std::ostream& operator << (std::ostream& os, StringRef sr); + friend std::string& operator += (std::string& lhs, StringRef rhs); + friend std::ostream& operator << (std::ostream& os, StringRef str); friend std::string operator+(StringRef lhs, StringRef rhs); /** diff --git a/src/catch2/internal/catch_tag_alias_registry.cpp b/src/catch2/internal/catch_tag_alias_registry.cpp index 4fd0d55798..510df167f9 100644 --- a/src/catch2/internal/catch_tag_alias_registry.cpp +++ b/src/catch2/internal/catch_tag_alias_registry.cpp @@ -6,7 +6,6 @@ // SPDX-License-Identifier: BSL-1.0 #include -#include #include #include #include diff --git a/src/catch2/internal/catch_test_case_registry_impl.cpp b/src/catch2/internal/catch_test_case_registry_impl.cpp index f1702979e7..e77e7bceed 100644 --- a/src/catch2/internal/catch_test_case_registry_impl.cpp +++ b/src/catch2/internal/catch_test_case_registry_impl.cpp @@ -7,12 +7,9 @@ // SPDX-License-Identifier: BSL-1.0 #include -#include #include #include #include -#include -#include #include #include #include @@ -73,7 +70,6 @@ namespace Catch { return sorted; } case TestRunOrder::Randomized: { - seedRng(config); using TestWithHash = std::pair; TestCaseInfoHasher h{ config.rngSeed() }; @@ -127,6 +123,8 @@ namespace Catch { return getRegistryHub().getTestCaseRegistry().getAllTestsSorted( config ); } + TestRegistry::~TestRegistry() = default; + void TestRegistry::registerTest(Detail::unique_ptr testInfo, Detail::unique_ptr testInvoker) { m_handles.emplace_back(testInfo.get(), testInvoker.get()); m_viewed_test_infos.push_back(testInfo.get()); diff --git a/src/catch2/internal/catch_test_case_registry_impl.hpp b/src/catch2/internal/catch_test_case_registry_impl.hpp index a4a27ed122..fbca89f900 100644 --- a/src/catch2/internal/catch_test_case_registry_impl.hpp +++ b/src/catch2/internal/catch_test_case_registry_impl.hpp @@ -30,14 +30,14 @@ namespace Catch { class TestRegistry : public ITestCaseRegistry { public: - ~TestRegistry() override = default; - void registerTest( Detail::unique_ptr testInfo, Detail::unique_ptr testInvoker ); std::vector const& getAllInfos() const override; std::vector const& getAllTests() const override; std::vector const& getAllTestsSorted( IConfig const& config ) const override; + ~TestRegistry() override; // = default + private: std::vector> m_owned_test_infos; // Keeps a materialized vector for `getAllInfos`. diff --git a/src/catch2/internal/catch_test_macro_impl.hpp b/src/catch2/internal/catch_test_macro_impl.hpp index 59c851e8f7..ccd5bb3578 100644 --- a/src/catch2/internal/catch_test_macro_impl.hpp +++ b/src/catch2/internal/catch_test_macro_impl.hpp @@ -38,8 +38,6 @@ #endif -#define INTERNAL_CATCH_REACT( handler ) handler.complete(); - /////////////////////////////////////////////////////////////////////////////// #define INTERNAL_CATCH_TEST( macroName, resultDisposition, ... ) \ do { /* NOLINT(bugprone-infinite-loop) */ \ @@ -49,10 +47,10 @@ INTERNAL_CATCH_TRY { \ CATCH_INTERNAL_START_WARNINGS_SUPPRESSION \ CATCH_INTERNAL_SUPPRESS_PARENTHESES_WARNINGS \ - catchAssertionHandler.handleExpr( Catch::Decomposer() <= __VA_ARGS__ ); \ + catchAssertionHandler.handleExpr( Catch::Decomposer() <= __VA_ARGS__ ); /* NOLINT(bugprone-chained-comparison) */ \ CATCH_INTERNAL_STOP_WARNINGS_SUPPRESSION \ } INTERNAL_CATCH_CATCH( catchAssertionHandler ) \ - INTERNAL_CATCH_REACT( catchAssertionHandler ) \ + catchAssertionHandler.complete(); \ } while( (void)0, (false) && static_cast( !!(__VA_ARGS__) ) ) // the expression here is never evaluated at runtime but it forces the compiler to give it a look // The double negation silences MSVC's C4800 warning, the static_cast forces short-circuit evaluation if the type has overloaded &&. @@ -80,7 +78,7 @@ catch( ... ) { \ catchAssertionHandler.handleUnexpectedInflightException(); \ } \ - INTERNAL_CATCH_REACT( catchAssertionHandler ) \ + catchAssertionHandler.complete(); \ } while( false ) /////////////////////////////////////////////////////////////////////////////// @@ -101,7 +99,7 @@ } \ else \ catchAssertionHandler.handleThrowingCallSkipped(); \ - INTERNAL_CATCH_REACT( catchAssertionHandler ) \ + catchAssertionHandler.complete(); \ } while( false ) /////////////////////////////////////////////////////////////////////////////// @@ -125,7 +123,7 @@ } \ else \ catchAssertionHandler.handleThrowingCallSkipped(); \ - INTERNAL_CATCH_REACT( catchAssertionHandler ) \ + catchAssertionHandler.complete(); \ } while( false ) @@ -149,7 +147,7 @@ } \ else \ catchAssertionHandler.handleThrowingCallSkipped(); \ - INTERNAL_CATCH_REACT( catchAssertionHandler ) \ + catchAssertionHandler.complete(); \ } while( false ) #endif // CATCH_CONFIG_DISABLE diff --git a/src/catch2/internal/catch_test_registry.cpp b/src/catch2/internal/catch_test_registry.cpp index e9c999fecd..d017c50e7a 100644 --- a/src/catch2/internal/catch_test_registry.cpp +++ b/src/catch2/internal/catch_test_registry.cpp @@ -16,6 +16,8 @@ #include namespace Catch { + void ITestInvoker::prepareTestCase() {} + void ITestInvoker::tearDownTestCase() {} ITestInvoker::~ITestInvoker() = default; namespace { @@ -52,7 +54,7 @@ namespace Catch { TestType m_testAsFunction; public: - TestInvokerAsFunction( TestType testAsFunction ) noexcept: + constexpr TestInvokerAsFunction( TestType testAsFunction ) noexcept: m_testAsFunction( testAsFunction ) {} void invoke() const override { m_testAsFunction(); } diff --git a/src/catch2/internal/catch_test_registry.hpp b/src/catch2/internal/catch_test_registry.hpp index 7766fe1113..5c3a226d63 100644 --- a/src/catch2/internal/catch_test_registry.hpp +++ b/src/catch2/internal/catch_test_registry.hpp @@ -32,7 +32,8 @@ template class TestInvokerAsMethod : public ITestInvoker { void (C::*m_testAsMethod)(); public: - TestInvokerAsMethod( void (C::*testAsMethod)() ) noexcept : m_testAsMethod( testAsMethod ) {} + constexpr TestInvokerAsMethod( void ( C::*testAsMethod )() ) noexcept: + m_testAsMethod( testAsMethod ) {} void invoke() const override { C obj; @@ -47,6 +48,34 @@ Detail::unique_ptr makeTestInvoker( void (C::*testAsMethod)() ) { return Detail::make_unique>( testAsMethod ); } +template +class TestInvokerFixture : public ITestInvoker { + void ( C::*m_testAsMethod )() const; + Detail::unique_ptr m_fixture = nullptr; + +public: + constexpr TestInvokerFixture( void ( C::*testAsMethod )() const ) noexcept: + m_testAsMethod( testAsMethod ) {} + + void prepareTestCase() override { + m_fixture = Detail::make_unique(); + } + + void tearDownTestCase() override { + m_fixture.reset(); + } + + void invoke() const override { + auto* f = m_fixture.get(); + ( f->*m_testAsMethod )(); + } +}; + +template +Detail::unique_ptr makeTestInvokerFixture( void ( C::*testAsMethod )() const ) { + return Detail::make_unique>( testAsMethod ); +} + struct NameAndTags { constexpr NameAndTags( StringRef name_ = StringRef(), StringRef tags_ = StringRef() ) noexcept: @@ -95,7 +124,7 @@ struct AutoReg : Detail::NonCopyable { namespace Catch { namespace Detail { struct DummyUse { - DummyUse( void ( * )( int ) ); + DummyUse( void ( * )( int ), Catch::NameAndTags const& ); }; } // namespace Detail } // namespace Catch @@ -107,18 +136,18 @@ namespace Catch { // tests can compile. The redefined `TEST_CASE` shadows this with param. static int catchInternalSectionHint = 0; -# define INTERNAL_CATCH_TESTCASE2( fname ) \ +# define INTERNAL_CATCH_TESTCASE2( fname, ... ) \ static void fname( int ); \ CATCH_INTERNAL_START_WARNINGS_SUPPRESSION \ CATCH_INTERNAL_SUPPRESS_GLOBALS_WARNINGS \ CATCH_INTERNAL_SUPPRESS_UNUSED_VARIABLE_WARNINGS \ static const Catch::Detail::DummyUse INTERNAL_CATCH_UNIQUE_NAME( \ - dummyUser )( &(fname) ); \ + dummyUser )( &(fname), Catch::NameAndTags{ __VA_ARGS__ } ); \ CATCH_INTERNAL_SUPPRESS_SHADOW_WARNINGS \ static void fname( [[maybe_unused]] int catchInternalSectionHint ) \ CATCH_INTERNAL_STOP_WARNINGS_SUPPRESSION # define INTERNAL_CATCH_TESTCASE( ... ) \ - INTERNAL_CATCH_TESTCASE2( INTERNAL_CATCH_UNIQUE_NAME( dummyFunction ) ) + INTERNAL_CATCH_TESTCASE2( INTERNAL_CATCH_UNIQUE_NAME( dummyFunction ), __VA_ARGS__ ) #endif // CATCH_CONFIG_EXPERIMENTAL_STATIC_ANALYSIS_SUPPORT @@ -143,6 +172,26 @@ static int catchInternalSectionHint = 0; #define INTERNAL_CATCH_TEST_CASE_METHOD( ClassName, ... ) \ INTERNAL_CATCH_TEST_CASE_METHOD2( INTERNAL_CATCH_UNIQUE_NAME( CATCH2_INTERNAL_TEST_ ), ClassName, __VA_ARGS__ ) + /////////////////////////////////////////////////////////////////////////////// + #define INTERNAL_CATCH_TEST_CASE_PERSISTENT_FIXTURE2( TestName, ClassName, ... ) \ + CATCH_INTERNAL_START_WARNINGS_SUPPRESSION \ + CATCH_INTERNAL_SUPPRESS_GLOBALS_WARNINGS \ + CATCH_INTERNAL_SUPPRESS_UNUSED_VARIABLE_WARNINGS \ + namespace { \ + struct TestName : INTERNAL_CATCH_REMOVE_PARENS( ClassName ) { \ + void test() const; \ + }; \ + const Catch::AutoReg INTERNAL_CATCH_UNIQUE_NAME( autoRegistrar )( \ + Catch::makeTestInvokerFixture( &TestName::test ), \ + CATCH_INTERNAL_LINEINFO, \ + #ClassName##_catch_sr, \ + Catch::NameAndTags{ __VA_ARGS__ } ); /* NOLINT */ \ + } \ + CATCH_INTERNAL_STOP_WARNINGS_SUPPRESSION \ + void TestName::test() const + #define INTERNAL_CATCH_TEST_CASE_PERSISTENT_FIXTURE( ClassName, ... ) \ + INTERNAL_CATCH_TEST_CASE_PERSISTENT_FIXTURE2( INTERNAL_CATCH_UNIQUE_NAME( CATCH2_INTERNAL_TEST_ ), ClassName, __VA_ARGS__ ) + /////////////////////////////////////////////////////////////////////////////// #define INTERNAL_CATCH_METHOD_AS_TEST_CASE( QualifiedMethod, ... ) \ diff --git a/src/catch2/internal/catch_textflow.cpp b/src/catch2/internal/catch_textflow.cpp index 7eac973258..1c21d20e56 100644 --- a/src/catch2/internal/catch_textflow.cpp +++ b/src/catch2/internal/catch_textflow.cpp @@ -26,117 +26,228 @@ namespace { return std::memchr( chars, c, sizeof( chars ) - 1 ) != nullptr; } - bool isBoundary( std::string const& line, size_t at ) { - assert( at > 0 ); - assert( at <= line.size() ); - - return at == line.size() || - ( isWhitespace( line[at] ) && !isWhitespace( line[at - 1] ) ) || - isBreakableBefore( line[at] ) || - isBreakableAfter( line[at - 1] ); - } - } // namespace namespace Catch { namespace TextFlow { + void AnsiSkippingString::preprocessString() { + for ( auto it = m_string.begin(); it != m_string.end(); ) { + // try to read through an ansi sequence + while ( it != m_string.end() && *it == '\033' && + it + 1 != m_string.end() && *( it + 1 ) == '[' ) { + auto cursor = it + 2; + while ( cursor != m_string.end() && + ( isdigit( *cursor ) || *cursor == ';' ) ) { + ++cursor; + } + if ( cursor == m_string.end() || *cursor != 'm' ) { + break; + } + // 'm' -> 0xff + *cursor = AnsiSkippingString::sentinel; + // if we've read an ansi sequence, set the iterator and + // return to the top of the loop + it = cursor + 1; + } + if ( it != m_string.end() ) { + ++m_size; + ++it; + } + } + } + + AnsiSkippingString::AnsiSkippingString( std::string const& text ): + m_string( text ) { + preprocessString(); + } + + AnsiSkippingString::AnsiSkippingString( std::string&& text ): + m_string( CATCH_MOVE( text ) ) { + preprocessString(); + } + + AnsiSkippingString::const_iterator AnsiSkippingString::begin() const { + return const_iterator( m_string ); + } + + AnsiSkippingString::const_iterator AnsiSkippingString::end() const { + return const_iterator( m_string, const_iterator::EndTag{} ); + } + + std::string AnsiSkippingString::substring( const_iterator begin, + const_iterator end ) const { + // There's one caveat here to an otherwise simple substring: when + // making a begin iterator we might have skipped ansi sequences at + // the start. If `begin` here is a begin iterator, skipped over + // initial ansi sequences, we'll use the true beginning of the + // string. Lastly: We need to transform any chars we replaced with + // 0xff back to 'm' + auto str = std::string( begin == this->begin() ? m_string.begin() + : begin.m_it, + end.m_it ); + std::transform( str.begin(), str.end(), str.begin(), []( char c ) { + return c == AnsiSkippingString::sentinel ? 'm' : c; + } ); + return str; + } + + void AnsiSkippingString::const_iterator::tryParseAnsiEscapes() { + // check if we've landed on an ansi sequence, and if so read through + // it + while ( m_it != m_string->end() && *m_it == '\033' && + m_it + 1 != m_string->end() && *( m_it + 1 ) == '[' ) { + auto cursor = m_it + 2; + while ( cursor != m_string->end() && + ( isdigit( *cursor ) || *cursor == ';' ) ) { + ++cursor; + } + if ( cursor == m_string->end() || + *cursor != AnsiSkippingString::sentinel ) { + break; + } + // if we've read an ansi sequence, set the iterator and + // return to the top of the loop + m_it = cursor + 1; + } + } + + void AnsiSkippingString::const_iterator::advance() { + assert( m_it != m_string->end() ); + m_it++; + tryParseAnsiEscapes(); + } + + void AnsiSkippingString::const_iterator::unadvance() { + assert( m_it != m_string->begin() ); + m_it--; + // if *m_it is 0xff, scan back to the \033 and then m_it-- once more + // (and repeat check) + while ( *m_it == AnsiSkippingString::sentinel ) { + while ( *m_it != '\033' ) { + assert( m_it != m_string->begin() ); + m_it--; + } + // if this happens, we must have been a begin iterator that had + // skipped over ansi sequences at the start of a string + assert( m_it != m_string->begin() ); + assert( *m_it == '\033' ); + m_it--; + } + } + + static bool isBoundary( AnsiSkippingString const& line, + AnsiSkippingString::const_iterator it ) { + return it == line.end() || + ( isWhitespace( *it ) && + !isWhitespace( *it.oneBefore() ) ) || + isBreakableBefore( *it ) || + isBreakableAfter( *it.oneBefore() ); + } void Column::const_iterator::calcLength() { m_addHyphen = false; m_parsedTo = m_lineStart; + AnsiSkippingString const& current_line = m_column.m_string; - std::string const& current_line = m_column.m_string; - if ( current_line[m_lineStart] == '\n' ) { - ++m_parsedTo; + if ( m_parsedTo == current_line.end() ) { + m_lineEnd = m_parsedTo; + return; } + assert( m_lineStart != current_line.end() ); + if ( *m_lineStart == '\n' ) { ++m_parsedTo; } + const auto maxLineLength = m_column.m_width - indentSize(); - const auto maxParseTo = std::min(current_line.size(), m_lineStart + maxLineLength); - while ( m_parsedTo < maxParseTo && - current_line[m_parsedTo] != '\n' ) { + std::size_t lineLength = 0; + while ( m_parsedTo != current_line.end() && + lineLength < maxLineLength && *m_parsedTo != '\n' ) { ++m_parsedTo; + ++lineLength; } // If we encountered a newline before the column is filled, // then we linebreak at the newline and consider this line // finished. - if ( m_parsedTo < m_lineStart + maxLineLength ) { - m_lineLength = m_parsedTo - m_lineStart; + if ( lineLength < maxLineLength ) { + m_lineEnd = m_parsedTo; } else { // Look for a natural linebreak boundary in the column // (We look from the end, so that the first found boundary is // the right one) - size_t newLineLength = maxLineLength; - while ( newLineLength > 0 && !isBoundary( current_line, m_lineStart + newLineLength ) ) { - --newLineLength; + m_lineEnd = m_parsedTo; + while ( lineLength > 0 && + !isBoundary( current_line, m_lineEnd ) ) { + --lineLength; + --m_lineEnd; } - while ( newLineLength > 0 && - isWhitespace( current_line[m_lineStart + newLineLength - 1] ) ) { - --newLineLength; + while ( lineLength > 0 && + isWhitespace( *m_lineEnd.oneBefore() ) ) { + --lineLength; + --m_lineEnd; } - // If we found one, then that is where we linebreak - if ( newLineLength > 0 ) { - m_lineLength = newLineLength; - } else { - // Otherwise we have to split text with a hyphen + // If we found one, then that is where we linebreak, otherwise + // we have to split text with a hyphen + if ( lineLength == 0 ) { m_addHyphen = true; - m_lineLength = maxLineLength - 1; + m_lineEnd = m_parsedTo.oneBefore(); } } } size_t Column::const_iterator::indentSize() const { - auto initial = - m_lineStart == 0 ? m_column.m_initialIndent : std::string::npos; + auto initial = m_lineStart == m_column.m_string.begin() + ? m_column.m_initialIndent + : std::string::npos; return initial == std::string::npos ? m_column.m_indent : initial; } - std::string - Column::const_iterator::addIndentAndSuffix( size_t position, - size_t length ) const { + std::string Column::const_iterator::addIndentAndSuffix( + AnsiSkippingString::const_iterator start, + AnsiSkippingString::const_iterator end ) const { std::string ret; const auto desired_indent = indentSize(); - ret.reserve( desired_indent + length + m_addHyphen ); + // ret.reserve( desired_indent + (end - start) + m_addHyphen ); ret.append( desired_indent, ' ' ); - ret.append( m_column.m_string, position, length ); - if ( m_addHyphen ) { - ret.push_back( '-' ); - } + // ret.append( start, end ); + ret += m_column.m_string.substring( start, end ); + if ( m_addHyphen ) { ret.push_back( '-' ); } return ret; } - Column::const_iterator::const_iterator( Column const& column ): m_column( column ) { + Column::const_iterator::const_iterator( Column const& column ): + m_column( column ), + m_lineStart( column.m_string.begin() ), + m_lineEnd( column.m_string.begin() ), + m_parsedTo( column.m_string.begin() ) { assert( m_column.m_width > m_column.m_indent ); assert( m_column.m_initialIndent == std::string::npos || m_column.m_width > m_column.m_initialIndent ); calcLength(); - if ( m_lineLength == 0 ) { - m_lineStart = m_column.m_string.size(); + if ( m_lineStart == m_lineEnd ) { + m_lineStart = m_column.m_string.end(); } } std::string Column::const_iterator::operator*() const { assert( m_lineStart <= m_parsedTo ); - return addIndentAndSuffix( m_lineStart, m_lineLength ); + return addIndentAndSuffix( m_lineStart, m_lineEnd ); } Column::const_iterator& Column::const_iterator::operator++() { - m_lineStart += m_lineLength; - std::string const& current_line = m_column.m_string; - if ( m_lineStart < current_line.size() && current_line[m_lineStart] == '\n' ) { - m_lineStart += 1; + m_lineStart = m_lineEnd; + AnsiSkippingString const& current_line = m_column.m_string; + if ( m_lineStart != current_line.end() && *m_lineStart == '\n' ) { + m_lineStart++; } else { - while ( m_lineStart < current_line.size() && - isWhitespace( current_line[m_lineStart] ) ) { + while ( m_lineStart != current_line.end() && + isWhitespace( *m_lineStart ) ) { ++m_lineStart; } } - if ( m_lineStart != current_line.size() ) { - calcLength(); - } + if ( m_lineStart != current_line.end() ) { calcLength(); } return *this; } @@ -233,23 +344,36 @@ namespace Catch { return os; } - Columns Column::operator+( Column const& other ) { + Columns operator+( Column const& lhs, Column const& rhs ) { Columns cols; - cols += *this; - cols += other; + cols += lhs; + cols += rhs; return cols; } - - Columns& Columns::operator+=( Column const& col ) { - m_columns.push_back( col ); - return *this; + Columns operator+( Column&& lhs, Column&& rhs ) { + Columns cols; + cols += CATCH_MOVE( lhs ); + cols += CATCH_MOVE( rhs ); + return cols; } - Columns Columns::operator+( Column const& col ) { - Columns combined = *this; - combined += col; + Columns& operator+=( Columns& lhs, Column const& rhs ) { + lhs.m_columns.push_back( rhs ); + return lhs; + } + Columns& operator+=( Columns& lhs, Column&& rhs ) { + lhs.m_columns.push_back( CATCH_MOVE( rhs ) ); + return lhs; + } + Columns operator+( Columns const& lhs, Column const& rhs ) { + auto combined( lhs ); + combined += rhs; return combined; } + Columns operator+( Columns&& lhs, Column&& rhs ) { + lhs += CATCH_MOVE( rhs ); + return CATCH_MOVE( lhs ); + } } // namespace TextFlow } // namespace Catch diff --git a/src/catch2/internal/catch_textflow.hpp b/src/catch2/internal/catch_textflow.hpp index 0776ab9227..2d9d78a50a 100644 --- a/src/catch2/internal/catch_textflow.hpp +++ b/src/catch2/internal/catch_textflow.hpp @@ -8,8 +8,10 @@ #ifndef CATCH_TEXTFLOW_HPP_INCLUDED #define CATCH_TEXTFLOW_HPP_INCLUDED -#include #include +#include + +#include #include #include @@ -18,6 +20,107 @@ namespace Catch { class Columns; + /** + * Abstraction for a string with ansi escape sequences that + * automatically skips over escapes when iterating. Only graphical + * escape sequences are considered. + * + * Internal representation: + * An escape sequence looks like \033[39;49m + * We need bidirectional iteration and the unbound length of escape + * sequences poses a problem for operator-- To make this work we'll + * replace the last `m` with a 0xff (this is a codepoint that won't have + * any utf-8 meaning). + */ + class AnsiSkippingString { + std::string m_string; + std::size_t m_size = 0; + + // perform 0xff replacement and calculate m_size + void preprocessString(); + + public: + class const_iterator; + using iterator = const_iterator; + // note: must be u-suffixed or this will cause a "truncation of + // constant value" warning on MSVC + static constexpr char sentinel = static_cast( 0xffu ); + + explicit AnsiSkippingString( std::string const& text ); + explicit AnsiSkippingString( std::string&& text ); + + const_iterator begin() const; + const_iterator end() const; + + size_t size() const { return m_size; } + + std::string substring( const_iterator begin, + const_iterator end ) const; + }; + + class AnsiSkippingString::const_iterator { + friend AnsiSkippingString; + struct EndTag {}; + + const std::string* m_string; + std::string::const_iterator m_it; + + explicit const_iterator( const std::string& string, EndTag ): + m_string( &string ), m_it( string.end() ) {} + + void tryParseAnsiEscapes(); + void advance(); + void unadvance(); + + public: + using difference_type = std::ptrdiff_t; + using value_type = char; + using pointer = value_type*; + using reference = value_type&; + using iterator_category = std::bidirectional_iterator_tag; + + explicit const_iterator( const std::string& string ): + m_string( &string ), m_it( string.begin() ) { + tryParseAnsiEscapes(); + } + + char operator*() const { return *m_it; } + + const_iterator& operator++() { + advance(); + return *this; + } + const_iterator operator++( int ) { + iterator prev( *this ); + operator++(); + return prev; + } + const_iterator& operator--() { + unadvance(); + return *this; + } + const_iterator operator--( int ) { + iterator prev( *this ); + operator--(); + return prev; + } + + bool operator==( const_iterator const& other ) const { + return m_it == other.m_it; + } + bool operator!=( const_iterator const& other ) const { + return !operator==( other ); + } + bool operator<=( const_iterator const& other ) const { + return m_it <= other.m_it; + } + + const_iterator oneBefore() const { + auto it = *this; + return --it; + } + }; + /** * Represents a column of text with specific width and indentation * @@ -27,17 +130,18 @@ namespace Catch { */ class Column { // String to be written out - std::string m_string; + AnsiSkippingString m_string; // Width of the column for linebreaking size_t m_width = CATCH_CONFIG_CONSOLE_WIDTH - 1; - // Indentation of other lines (including first if initial indent is unset) + // Indentation of other lines (including first if initial indent is + // unset) size_t m_indent = 0; // Indentation of the first line size_t m_initialIndent = std::string::npos; public: /** - * Iterates "lines" in `Column` and return sthem + * Iterates "lines" in `Column` and returns them */ class const_iterator { friend Column; @@ -45,16 +149,19 @@ namespace Catch { Column const& m_column; // Where does the current line start? - size_t m_lineStart = 0; + AnsiSkippingString::const_iterator m_lineStart; // How long should the current line be? - size_t m_lineLength = 0; + AnsiSkippingString::const_iterator m_lineEnd; // How far have we checked the string to iterate? - size_t m_parsedTo = 0; + AnsiSkippingString::const_iterator m_parsedTo; // Should a '-' be appended to the line? bool m_addHyphen = false; const_iterator( Column const& column, EndTag ): - m_column( column ), m_lineStart( m_column.m_string.size() ) {} + m_column( column ), + m_lineStart( m_column.m_string.end() ), + m_lineEnd( column.m_string.end() ), + m_parsedTo( column.m_string.end() ) {} // Calculates the length of the current line void calcLength(); @@ -64,8 +171,9 @@ namespace Catch { // Creates an indented and (optionally) suffixed string from // current iterator position, indentation and length. - std::string addIndentAndSuffix( size_t position, - size_t length ) const; + std::string addIndentAndSuffix( + AnsiSkippingString::const_iterator start, + AnsiSkippingString::const_iterator end ) const; public: using difference_type = std::ptrdiff_t; @@ -82,7 +190,8 @@ namespace Catch { const_iterator operator++( int ); bool operator==( const_iterator const& other ) const { - return m_lineStart == other.m_lineStart && &m_column == &other.m_column; + return m_lineStart == other.m_lineStart && + &m_column == &other.m_column; } bool operator!=( const_iterator const& other ) const { return !operator==( other ); @@ -91,29 +200,47 @@ namespace Catch { using iterator = const_iterator; explicit Column( std::string const& text ): m_string( text ) {} + explicit Column( std::string&& text ): + m_string( CATCH_MOVE( text ) ) {} - Column& width( size_t newWidth ) { + Column& width( size_t newWidth ) & { assert( newWidth > 0 ); m_width = newWidth; return *this; } - Column& indent( size_t newIndent ) { + Column&& width( size_t newWidth ) && { + assert( newWidth > 0 ); + m_width = newWidth; + return CATCH_MOVE( *this ); + } + Column& indent( size_t newIndent ) & { m_indent = newIndent; return *this; } - Column& initialIndent( size_t newIndent ) { + Column&& indent( size_t newIndent ) && { + m_indent = newIndent; + return CATCH_MOVE( *this ); + } + Column& initialIndent( size_t newIndent ) & { m_initialIndent = newIndent; return *this; } + Column&& initialIndent( size_t newIndent ) && { + m_initialIndent = newIndent; + return CATCH_MOVE( *this ); + } size_t width() const { return m_width; } const_iterator begin() const { return const_iterator( *this ); } - const_iterator end() const { return { *this, const_iterator::EndTag{} }; } + const_iterator end() const { + return { *this, const_iterator::EndTag{} }; + } friend std::ostream& operator<<( std::ostream& os, Column const& col ); - Columns operator+( Column const& other ); + friend Columns operator+( Column const& lhs, Column const& rhs ); + friend Columns operator+( Column&& lhs, Column&& rhs ); }; //! Creates a column that serves as an empty space of specific width @@ -157,8 +284,10 @@ namespace Catch { iterator begin() const { return iterator( *this ); } iterator end() const { return { *this, iterator::EndTag() }; } - Columns& operator+=( Column const& col ); - Columns operator+( Column const& col ); + friend Columns& operator+=( Columns& lhs, Column const& rhs ); + friend Columns& operator+=( Columns& lhs, Column&& rhs ); + friend Columns operator+( Columns const& lhs, Column const& rhs ); + friend Columns operator+( Columns&& lhs, Column&& rhs ); friend std::ostream& operator<<( std::ostream& os, Columns const& cols ); diff --git a/src/catch2/internal/catch_uncaught_exceptions.cpp b/src/catch2/internal/catch_uncaught_exceptions.cpp index 704d6e1ca9..8cfabc0f8b 100644 --- a/src/catch2/internal/catch_uncaught_exceptions.cpp +++ b/src/catch2/internal/catch_uncaught_exceptions.cpp @@ -7,7 +7,6 @@ // SPDX-License-Identifier: BSL-1.0 #include -#include #include #include diff --git a/src/catch2/internal/catch_uniform_integer_distribution.hpp b/src/catch2/internal/catch_uniform_integer_distribution.hpp index 3b62357901..799a93e269 100644 --- a/src/catch2/internal/catch_uniform_integer_distribution.hpp +++ b/src/catch2/internal/catch_uniform_integer_distribution.hpp @@ -13,22 +13,6 @@ namespace Catch { - namespace Detail { - // Indirection to enable make_unsigned behaviour. - template - struct make_unsigned { - using type = std::make_unsigned_t; - }; - - template <> - struct make_unsigned { - using type = uint8_t; - }; - - template - using make_unsigned_t = typename make_unsigned::type; - } - /** * Implementation of uniform distribution on integers. * @@ -44,14 +28,14 @@ template class uniform_integer_distribution { static_assert(std::is_integral::value, "..."); - using UnsignedIntegerType = Detail::make_unsigned_t; + using UnsignedIntegerType = Detail::SizedUnsignedType_t; - // We store the left range bound converted to internal representation, - // because it will be used in computation in the () operator. + // Only the left bound is stored, and we store it converted to its + // unsigned image. This avoids having to do the conversions inside + // the operator(), at the cost of having to do the conversion in + // the a() getter. The right bound is only needed in the b() getter, + // so we recompute it there from other stored data. UnsignedIntegerType m_a; - // After initialization, right bound is only used for the b() getter, - // so we keep it in the original type. - IntegerType m_b; // How many different values are there in [a, b]. a == b => 1, can be 0 for distribution over all values in the type. UnsignedIntegerType m_ab_distance; @@ -64,25 +48,24 @@ class uniform_integer_distribution { // distribution will be reused many times and this is an optimization. UnsignedIntegerType m_rejection_threshold = 0; - // Assumes m_b and m_a are already filled - UnsignedIntegerType computeDistance() const { - // This overflows and returns 0 if ua == 0 and ub == TYPE_MAX. + static constexpr UnsignedIntegerType computeDistance(IntegerType a, IntegerType b) { + // This overflows and returns 0 if a == 0 and b == TYPE_MAX. // We handle that later when generating the number. - return transposeTo(m_b) - m_a + 1; + return transposeTo(b) - transposeTo(a) + 1; } - static UnsignedIntegerType computeRejectionThreshold(UnsignedIntegerType ab_distance) { + static constexpr UnsignedIntegerType computeRejectionThreshold(UnsignedIntegerType ab_distance) { // distance == 0 means that we will return all possible values from // the type's range, and that we shouldn't reject anything. if ( ab_distance == 0 ) { return 0; } return ( ~ab_distance + 1 ) % ab_distance; } - static UnsignedIntegerType transposeTo(IntegerType in) { + static constexpr UnsignedIntegerType transposeTo(IntegerType in) { return Detail::transposeToNaturalOrder( static_cast( in ) ); } - static IntegerType transposeBack(UnsignedIntegerType in) { + static constexpr IntegerType transposeBack(UnsignedIntegerType in) { return static_cast( Detail::transposeToNaturalOrder(in) ); } @@ -90,16 +73,15 @@ class uniform_integer_distribution { public: using result_type = IntegerType; - uniform_integer_distribution( IntegerType a, IntegerType b ): + constexpr uniform_integer_distribution( IntegerType a, IntegerType b ): m_a( transposeTo(a) ), - m_b( b ), - m_ab_distance( computeDistance() ), + m_ab_distance( computeDistance(a, b) ), m_rejection_threshold( computeRejectionThreshold(m_ab_distance) ) { assert( a <= b ); } template - result_type operator()( Generator& g ) { + constexpr result_type operator()( Generator& g ) { // All possible values of result_type are valid. if ( m_ab_distance == 0 ) { return transposeBack( Detail::fillBitsFrom( g ) ); @@ -117,8 +99,8 @@ class uniform_integer_distribution { return transposeBack(m_a + emul.upper); } - result_type a() const { return transposeBack(m_a); } - result_type b() const { return m_b; } + constexpr result_type a() const { return transposeBack(m_a); } + constexpr result_type b() const { return transposeBack(m_ab_distance + m_a - 1); } }; } // end namespace Catch diff --git a/src/catch2/internal/catch_wildcard_pattern.hpp b/src/catch2/internal/catch_wildcard_pattern.hpp index 72479ba878..4f4108597d 100644 --- a/src/catch2/internal/catch_wildcard_pattern.hpp +++ b/src/catch2/internal/catch_wildcard_pattern.hpp @@ -8,7 +8,7 @@ #ifndef CATCH_WILDCARD_PATTERN_HPP_INCLUDED #define CATCH_WILDCARD_PATTERN_HPP_INCLUDED -#include +#include #include diff --git a/src/catch2/internal/catch_xmlwriter.cpp b/src/catch2/internal/catch_xmlwriter.cpp index 6c1d45df48..ccf63a56e5 100644 --- a/src/catch2/internal/catch_xmlwriter.cpp +++ b/src/catch2/internal/catch_xmlwriter.cpp @@ -53,36 +53,16 @@ namespace { os.flags(f); } - bool shouldNewline(XmlFormatting fmt) { + constexpr bool shouldNewline(XmlFormatting fmt) { return !!(static_cast>(fmt & XmlFormatting::Newline)); } - bool shouldIndent(XmlFormatting fmt) { + constexpr bool shouldIndent(XmlFormatting fmt) { return !!(static_cast>(fmt & XmlFormatting::Indent)); } } // anonymous namespace - XmlFormatting operator | (XmlFormatting lhs, XmlFormatting rhs) { - return static_cast( - static_cast>(lhs) | - static_cast>(rhs) - ); - } - - XmlFormatting operator & (XmlFormatting lhs, XmlFormatting rhs) { - return static_cast( - static_cast>(lhs) & - static_cast>(rhs) - ); - } - - - XmlEncode::XmlEncode( StringRef str, ForWhat forWhat ) - : m_str( str ), - m_forWhat( forWhat ) - {} - void XmlEncode::encodeTo( std::ostream& os ) const { // Apostrophe escaping not necessary if we always use " to write attributes // (see: http://www.w3.org/TR/xml/#syntax) diff --git a/src/catch2/internal/catch_xmlwriter.hpp b/src/catch2/internal/catch_xmlwriter.hpp index ec55f3c468..22b42c5c8f 100644 --- a/src/catch2/internal/catch_xmlwriter.hpp +++ b/src/catch2/internal/catch_xmlwriter.hpp @@ -13,16 +13,25 @@ #include #include +#include namespace Catch { - enum class XmlFormatting { + enum class XmlFormatting : std::uint8_t { None = 0x00, Indent = 0x01, Newline = 0x02, }; - XmlFormatting operator | (XmlFormatting lhs, XmlFormatting rhs); - XmlFormatting operator & (XmlFormatting lhs, XmlFormatting rhs); + constexpr XmlFormatting operator|( XmlFormatting lhs, XmlFormatting rhs ) { + return static_cast( static_cast( lhs ) | + static_cast( rhs ) ); + } + + constexpr XmlFormatting operator&( XmlFormatting lhs, XmlFormatting rhs ) { + return static_cast( static_cast( lhs ) & + static_cast( rhs ) ); + } + /** * Helper for XML-encoding text (escaping angle brackets, quotes, etc) @@ -34,7 +43,9 @@ namespace Catch { public: enum ForWhat { ForTextNodes, ForAttributes }; - XmlEncode( StringRef str, ForWhat forWhat = ForTextNodes ); + constexpr XmlEncode( StringRef str, ForWhat forWhat = ForTextNodes ): + m_str( str ), m_forWhat( forWhat ) {} + void encodeTo( std::ostream& os ) const; diff --git a/src/catch2/matchers/catch_matchers_floating_point.cpp b/src/catch2/matchers/catch_matchers_floating_point.cpp index 206332ef73..fc7b444e43 100644 --- a/src/catch2/matchers/catch_matchers_floating_point.cpp +++ b/src/catch2/matchers/catch_matchers_floating_point.cpp @@ -176,7 +176,7 @@ namespace Detail { std::string WithinRelMatcher::describe() const { Catch::ReusableStringStream sstr; - sstr << "and " << m_target << " are within " << m_epsilon * 100. << "% of each other"; + sstr << "and " << ::Catch::Detail::stringify(m_target) << " are within " << m_epsilon * 100. << "% of each other"; return sstr.str(); } diff --git a/src/catch2/matchers/catch_matchers_range_equals.hpp b/src/catch2/matchers/catch_matchers_range_equals.hpp index 95b781a430..c4feece4bc 100644 --- a/src/catch2/matchers/catch_matchers_range_equals.hpp +++ b/src/catch2/matchers/catch_matchers_range_equals.hpp @@ -28,12 +28,14 @@ namespace Catch { public: template + constexpr RangeEqualsMatcher( TargetRangeLike2&& range, Equality2&& predicate ): m_desired( CATCH_FORWARD( range ) ), m_predicate( CATCH_FORWARD( predicate ) ) {} template + constexpr bool match( RangeLike&& rng ) const { auto rng_start = begin( rng ); const auto rng_end = end( rng ); @@ -66,12 +68,14 @@ namespace Catch { public: template + constexpr UnorderedRangeEqualsMatcher( TargetRangeLike2&& range, Equality2&& predicate ): m_desired( CATCH_FORWARD( range ) ), m_predicate( CATCH_FORWARD( predicate ) ) {} template + constexpr bool match( RangeLike&& rng ) const { using std::begin; using std::end; @@ -95,6 +99,7 @@ namespace Catch { * Uses `std::equal_to` to do the comparison */ template + constexpr std::enable_if_t::value, RangeEqualsMatcher>> RangeEquals( RangeLike&& range ) { @@ -108,6 +113,7 @@ namespace Catch { * Uses to provided predicate `predicate` to do the comparisons */ template + constexpr RangeEqualsMatcher RangeEquals( RangeLike&& range, Equality&& predicate ) { return { CATCH_FORWARD( range ), CATCH_FORWARD( predicate ) }; @@ -120,6 +126,7 @@ namespace Catch { * Uses `std::equal_to` to do the comparison */ template + constexpr std::enable_if_t< !Detail::is_matcher::value, UnorderedRangeEqualsMatcher>> @@ -134,6 +141,7 @@ namespace Catch { * Uses to provided predicate `predicate` to do the comparisons */ template + constexpr UnorderedRangeEqualsMatcher UnorderedRangeEquals( RangeLike&& range, Equality&& predicate ) { return { CATCH_FORWARD( range ), CATCH_FORWARD( predicate ) }; diff --git a/src/catch2/matchers/catch_matchers_string.hpp b/src/catch2/matchers/catch_matchers_string.hpp index 718022e31c..61a385d0af 100644 --- a/src/catch2/matchers/catch_matchers_string.hpp +++ b/src/catch2/matchers/catch_matchers_string.hpp @@ -8,9 +8,9 @@ #ifndef CATCH_MATCHERS_STRING_HPP_INCLUDED #define CATCH_MATCHERS_STRING_HPP_INCLUDED -#include -#include #include +#include +#include #include diff --git a/src/catch2/matchers/internal/catch_matchers_impl.hpp b/src/catch2/matchers/internal/catch_matchers_impl.hpp index 2ee9f0c094..24a3f8b690 100644 --- a/src/catch2/matchers/internal/catch_matchers_impl.hpp +++ b/src/catch2/matchers/internal/catch_matchers_impl.hpp @@ -18,12 +18,22 @@ namespace Catch { +#ifdef __clang__ +# pragma clang diagnostic push +# pragma clang diagnostic ignored "-Wsign-compare" +# pragma clang diagnostic ignored "-Wnon-virtual-dtor" +#elif defined __GNUC__ +# pragma GCC diagnostic push +# pragma GCC diagnostic ignored "-Wsign-compare" +# pragma GCC diagnostic ignored "-Wnon-virtual-dtor" +#endif + template class MatchExpr : public ITransientExpression { ArgT && m_arg; MatcherT const& m_matcher; public: - MatchExpr( ArgT && arg, MatcherT const& matcher ) + constexpr MatchExpr( ArgT && arg, MatcherT const& matcher ) : ITransientExpression{ true, matcher.match( arg ) }, // not forwarding arg here on purpose m_arg( CATCH_FORWARD(arg) ), m_matcher( matcher ) @@ -36,6 +46,13 @@ namespace Catch { } }; +#ifdef __clang__ +# pragma clang diagnostic pop +#elif defined __GNUC__ +# pragma GCC diagnostic pop +#endif + + namespace Matchers { template class MatcherBase; @@ -46,7 +63,8 @@ namespace Catch { void handleExceptionMatchExpr( AssertionHandler& handler, StringMatcher const& matcher ); template - auto makeMatchExpr( ArgT && arg, MatcherT const& matcher ) -> MatchExpr { + constexpr MatchExpr + makeMatchExpr( ArgT&& arg, MatcherT const& matcher ) { return MatchExpr( CATCH_FORWARD(arg), matcher ); } @@ -60,7 +78,7 @@ namespace Catch { INTERNAL_CATCH_TRY { \ catchAssertionHandler.handleExpr( Catch::makeMatchExpr( arg, matcher ) ); \ } INTERNAL_CATCH_CATCH( catchAssertionHandler ) \ - INTERNAL_CATCH_REACT( catchAssertionHandler ) \ + catchAssertionHandler.complete(); \ } while( false ) @@ -70,7 +88,10 @@ namespace Catch { Catch::AssertionHandler catchAssertionHandler( macroName##_catch_sr, CATCH_INTERNAL_LINEINFO, CATCH_INTERNAL_STRINGIFY(__VA_ARGS__) ", " CATCH_INTERNAL_STRINGIFY(exceptionType) ", " CATCH_INTERNAL_STRINGIFY(matcher), resultDisposition ); \ if( catchAssertionHandler.allowThrows() ) \ try { \ + CATCH_INTERNAL_START_WARNINGS_SUPPRESSION \ + CATCH_INTERNAL_SUPPRESS_USELESS_CAST_WARNINGS \ static_cast(__VA_ARGS__ ); \ + CATCH_INTERNAL_STOP_WARNINGS_SUPPRESSION \ catchAssertionHandler.handleUnexpectedExceptionNotThrown(); \ } \ catch( exceptionType const& ex ) { \ @@ -81,7 +102,7 @@ namespace Catch { } \ else \ catchAssertionHandler.handleThrowingCallSkipped(); \ - INTERNAL_CATCH_REACT( catchAssertionHandler ) \ + catchAssertionHandler.complete(); \ } while( false ) diff --git a/src/catch2/meson.build b/src/catch2/meson.build index 4b9f3e8e4e..65be34378a 100644 --- a/src/catch2/meson.build +++ b/src/catch2/meson.build @@ -18,6 +18,8 @@ configure_file( configuration: conf_data, ) +fs = import('fs') + benchmark_headers = [ 'benchmark/catch_benchmark.hpp', 'benchmark/catch_benchmark_all.hpp', @@ -72,13 +74,13 @@ internal_headers = [ 'interfaces/catch_interfaces_testcase.hpp', 'internal/catch_assertion_handler.hpp', 'internal/catch_case_insensitive_comparisons.hpp', - 'internal/catch_case_sensitive.hpp', 'internal/catch_clara.hpp', 'internal/catch_commandline.hpp', 'internal/catch_compare_traits.hpp', 'internal/catch_compiler_capabilities.hpp', 'internal/catch_config_android_logwrite.hpp', 'internal/catch_config_counter.hpp', + 'internal/catch_config_prefix_messages.hpp', 'internal/catch_config_static_analysis_support.hpp', 'internal/catch_config_uncaught_exceptions.hpp', 'internal/catch_config_wchar.hpp', @@ -171,6 +173,7 @@ internal_headers = [ 'catch_approx.hpp', 'catch_assertion_info.hpp', 'catch_assertion_result.hpp', + 'catch_case_sensitive.hpp', 'catch_config.hpp', 'catch_get_random_seed.hpp', 'catch_message.hpp', @@ -231,7 +234,6 @@ internal_sources = files( 'internal/catch_random_seed_generation.cpp', 'internal/catch_reporter_registry.cpp', 'internal/catch_reporter_spec_parser.cpp', - 'internal/catch_result_type.cpp', 'internal/catch_reusable_string_stream.cpp', 'internal/catch_run_context.cpp', 'internal/catch_section.cpp', @@ -340,9 +342,19 @@ foreach file : headers install_headers(file, subdir: join_paths(include_subdir, folder)) endforeach +catch2_dependencies = [] +# Check if this is an Android NDK build. +if ((host_machine.system() == 'android') or + # Check if this is an Android Termux build. + (host_machine.system() == 'linux' and fs.is_dir('/data/data/com.termux'))) + log_dep = meson.get_compiler('cpp').find_library('log') + catch2_dependencies += log_dep +endif + catch2 = static_library( 'Catch2', sources, + dependencies: catch2_dependencies, include_directories: '..', install: true, ) diff --git a/src/catch2/reporters/catch_reporter_console.cpp b/src/catch2/reporters/catch_reporter_console.cpp index bbde5ec974..c5678548d5 100644 --- a/src/catch2/reporters/catch_reporter_console.cpp +++ b/src/catch2/reporters/catch_reporter_console.cpp @@ -209,13 +209,6 @@ findMax( std::size_t& i, std::size_t& j, std::size_t& k, std::size_t& l ) { return l; } -enum class Justification { Left, Right }; - -struct ColumnInfo { - std::string name; - std::size_t width; - Justification justification; -}; struct ColumnBreak {}; struct RowBreak {}; struct OutputFlush {}; @@ -293,6 +286,14 @@ class Duration { }; } // end anon namespace +enum class Justification { Left, Right }; + +struct ColumnInfo { + std::string name; + std::size_t width; + Justification justification; +}; + class TablePrinter { std::ostream& m_os; std::vector m_columnInfos; @@ -315,11 +316,10 @@ class TablePrinter { *this << RowBreak(); TextFlow::Columns headerCols; - auto spacer = TextFlow::Spacer(2); for (auto const& info : m_columnInfos) { assert(info.width > 2); headerCols += TextFlow::Column(info.name).width(info.width - 2); - headerCols += spacer; + headerCols += TextFlow::Spacer( 2 ); } m_os << headerCols << '\n'; @@ -520,8 +520,8 @@ void ConsoleReporter::testRunEnded(TestRunStats const& _testRunStats) { m_stream << '\n' << std::flush; StreamingReporterBase::testRunEnded(_testRunStats); } -void ConsoleReporter::testRunStarting(TestRunInfo const& _testInfo) { - StreamingReporterBase::testRunStarting(_testInfo); +void ConsoleReporter::testRunStarting(TestRunInfo const& _testRunInfo) { + StreamingReporterBase::testRunStarting(_testRunInfo); if ( m_config->testSpec().hasFilters() ) { m_stream << m_colour->guardColour( Colour::BrightYellow ) << "Filters: " << m_config->testSpec() << '\n'; diff --git a/src/catch2/reporters/catch_reporter_cumulative_base.cpp b/src/catch2/reporters/catch_reporter_cumulative_base.cpp index 5e10632621..09169632b4 100644 --- a/src/catch2/reporters/catch_reporter_cumulative_base.cpp +++ b/src/catch2/reporters/catch_reporter_cumulative_base.cpp @@ -16,8 +16,7 @@ namespace Catch { namespace { struct BySectionInfo { BySectionInfo( SectionInfo const& other ): m_other( other ) {} - BySectionInfo( BySectionInfo const& other ): - m_other( other.m_other ) {} + BySectionInfo( BySectionInfo const& other ) = default; bool operator()( Detail::unique_ptr const& node ) const { diff --git a/src/catch2/reporters/catch_reporter_json.cpp b/src/catch2/reporters/catch_reporter_json.cpp index 1f0db8b0db..6a8e655f01 100644 --- a/src/catch2/reporters/catch_reporter_json.cpp +++ b/src/catch2/reporters/catch_reporter_json.cpp @@ -133,8 +133,8 @@ namespace Catch { return "Outputs listings as JSON. Test listing is Work-in-Progress!"; } - void JsonReporter::testRunStarting( TestRunInfo const& testInfo ) { - StreamingReporterBase::testRunStarting( testInfo ); + void JsonReporter::testRunStarting( TestRunInfo const& runInfo ) { + StreamingReporterBase::testRunStarting( runInfo ); endListing(); assert( isInside( Writer::Object ) ); diff --git a/src/catch2/reporters/catch_reporter_junit.cpp b/src/catch2/reporters/catch_reporter_junit.cpp index fc5cae34ad..27bdfe28f7 100644 --- a/src/catch2/reporters/catch_reporter_junit.cpp +++ b/src/catch2/reporters/catch_reporter_junit.cpp @@ -74,7 +74,7 @@ namespace Catch { static void normalizeNamespaceMarkers(std::string& str) { std::size_t pos = str.find( "::" ); - while ( pos != str.npos ) { + while ( pos != std::string::npos ) { str.replace( pos, 2, "." ); pos += 1; pos = str.find( "::", pos ); @@ -88,7 +88,7 @@ namespace Catch { xml( m_stream ) { m_preferences.shouldRedirectStdOut = true; - m_preferences.shouldReportAllAssertions = true; + m_preferences.shouldReportAllAssertions = false; m_shouldStoreSuccesfulAssertions = false; } @@ -198,7 +198,7 @@ namespace Catch { if( !rootName.empty() ) name = rootName + '/' + name; - if( sectionNode.hasAnyAssertions() + if ( sectionNode.stats.assertions.total() > 0 || !sectionNode.stdOut.empty() || !sectionNode.stdErr.empty() ) { XmlWriter::ScopedElement e = xml.scopedElement( "testcase" ); diff --git a/src/catch2/reporters/catch_reporter_junit.hpp b/src/catch2/reporters/catch_reporter_junit.hpp index 87c7c5679e..7cb53c25b5 100644 --- a/src/catch2/reporters/catch_reporter_junit.hpp +++ b/src/catch2/reporters/catch_reporter_junit.hpp @@ -19,8 +19,6 @@ namespace Catch { public: JunitReporter(ReporterConfig&& _config); - ~JunitReporter() override = default; - static std::string getDescription(); void testRunStarting(TestRunInfo const& runInfo) override; diff --git a/src/catch2/reporters/catch_reporter_multi.hpp b/src/catch2/reporters/catch_reporter_multi.hpp index c43f511f8d..661138371b 100644 --- a/src/catch2/reporters/catch_reporter_multi.hpp +++ b/src/catch2/reporters/catch_reporter_multi.hpp @@ -53,7 +53,7 @@ namespace Catch { void assertionEnded( AssertionStats const& assertionStats ) override; void sectionEnded( SectionStats const& sectionStats ) override; - void testCasePartialEnded(TestCaseStats const& testInfo, uint64_t partNumber) override; + void testCasePartialEnded(TestCaseStats const& testStats, uint64_t partNumber) override; void testCaseEnded( TestCaseStats const& testCaseStats ) override; void testRunEnded( TestRunStats const& testRunStats ) override; diff --git a/src/catch2/reporters/catch_reporter_sonarqube.cpp b/src/catch2/reporters/catch_reporter_sonarqube.cpp index 9c391b1f4f..2c3eb1cd79 100644 --- a/src/catch2/reporters/catch_reporter_sonarqube.cpp +++ b/src/catch2/reporters/catch_reporter_sonarqube.cpp @@ -73,9 +73,9 @@ namespace Catch { if (!rootName.empty()) name = rootName + '/' + name; - if ( sectionNode.hasAnyAssertions() + if ( sectionNode.stats.assertions.total() > 0 || !sectionNode.stdOut.empty() - || !sectionNode.stdErr.empty() ) { + || !sectionNode.stdErr.empty() ) { XmlWriter::ScopedElement e = xml.scopedElement("testCase"); xml.writeAttribute("name"_sr, name); xml.writeAttribute("duration"_sr, static_cast(sectionNode.stats.durationInSeconds * 1000)); diff --git a/src/catch2/reporters/catch_reporter_sonarqube.hpp b/src/catch2/reporters/catch_reporter_sonarqube.hpp index cad6deec8c..509f411e3d 100644 --- a/src/catch2/reporters/catch_reporter_sonarqube.hpp +++ b/src/catch2/reporters/catch_reporter_sonarqube.hpp @@ -21,12 +21,10 @@ namespace Catch { : CumulativeReporterBase(CATCH_MOVE(config)) , xml(m_stream) { m_preferences.shouldRedirectStdOut = true; - m_preferences.shouldReportAllAssertions = true; + m_preferences.shouldReportAllAssertions = false; m_shouldStoreSuccesfulAssertions = false; } - ~SonarQubeReporter() override = default; - static std::string getDescription() { using namespace std::string_literals; return "Reports test results in the Generic Test Data SonarQube XML format"s; @@ -39,7 +37,7 @@ namespace Catch { xml.endElement(); } - void writeRun( TestRunNode const& groupNode ); + void writeRun( TestRunNode const& runNode ); void writeTestFile(StringRef filename, std::vector const& testCaseNodes); diff --git a/src/catch2/reporters/catch_reporter_tap.hpp b/src/catch2/reporters/catch_reporter_tap.hpp index fe45df63e8..e6889bb110 100644 --- a/src/catch2/reporters/catch_reporter_tap.hpp +++ b/src/catch2/reporters/catch_reporter_tap.hpp @@ -19,7 +19,6 @@ namespace Catch { StreamingReporterBase( CATCH_MOVE(config) ) { m_preferences.shouldReportAllAssertions = true; } - ~TAPReporter() override = default; static std::string getDescription() { using namespace std::string_literals; diff --git a/src/catch2/reporters/catch_reporter_teamcity.hpp b/src/catch2/reporters/catch_reporter_teamcity.hpp index 04feb2e6dc..662e989265 100644 --- a/src/catch2/reporters/catch_reporter_teamcity.hpp +++ b/src/catch2/reporters/catch_reporter_teamcity.hpp @@ -35,8 +35,8 @@ namespace Catch { return "Reports test results as TeamCity service messages"s; } - void testRunStarting( TestRunInfo const& groupInfo ) override; - void testRunEnded( TestRunStats const& testGroupStats ) override; + void testRunStarting( TestRunInfo const& runInfo ) override; + void testRunEnded( TestRunStats const& runStats ) override; void assertionEnded(AssertionStats const& assertionStats) override; diff --git a/tests/BUILD.bazel b/tests/BUILD.bazel new file mode 100644 index 0000000000..5f0362fb6b --- /dev/null +++ b/tests/BUILD.bazel @@ -0,0 +1,83 @@ +load("@rules_cc//cc:defs.bzl", "cc_library", "cc_test") + +package(default_visibility = ["//visibility:public"]) + +cc_library( + name = "catch2_self_test_helper", + srcs = ["SelfTest/helpers/parse_test_spec.cpp"], + hdrs = [ + "SelfTest/helpers/parse_test_spec.hpp", + "SelfTest/helpers/range_test_helpers.hpp", + "SelfTest/helpers/type_with_lit_0_comparisons.hpp", + ], + includes = ["SelfTest"], + deps = [ + "//:catch2", + ], +) + +cc_test( + name = "catch2_self_test", + size = "small", + srcs = [ + "SelfTest/IntrospectiveTests/Algorithms.tests.cpp", + "SelfTest/IntrospectiveTests/Clara.tests.cpp", + "SelfTest/IntrospectiveTests/CmdLine.tests.cpp", + "SelfTest/IntrospectiveTests/CmdLineHelpers.tests.cpp", + "SelfTest/IntrospectiveTests/ColourImpl.tests.cpp", + "SelfTest/IntrospectiveTests/Details.tests.cpp", + "SelfTest/IntrospectiveTests/FloatingPoint.tests.cpp", + "SelfTest/IntrospectiveTests/GeneratorsImpl.tests.cpp", + "SelfTest/IntrospectiveTests/Integer.tests.cpp", + "SelfTest/IntrospectiveTests/InternalBenchmark.tests.cpp", + "SelfTest/IntrospectiveTests/Parse.tests.cpp", + "SelfTest/IntrospectiveTests/PartTracker.tests.cpp", + "SelfTest/IntrospectiveTests/RandomNumberGeneration.tests.cpp", + "SelfTest/IntrospectiveTests/Reporters.tests.cpp", + "SelfTest/IntrospectiveTests/Sharding.tests.cpp", + "SelfTest/IntrospectiveTests/Stream.tests.cpp", + "SelfTest/IntrospectiveTests/String.tests.cpp", + "SelfTest/IntrospectiveTests/StringManip.tests.cpp", + "SelfTest/IntrospectiveTests/Tag.tests.cpp", + "SelfTest/IntrospectiveTests/TestCaseInfoHasher.tests.cpp", + "SelfTest/IntrospectiveTests/TestSpec.tests.cpp", + "SelfTest/IntrospectiveTests/TestSpecParser.tests.cpp", + "SelfTest/IntrospectiveTests/TextFlow.tests.cpp", + "SelfTest/IntrospectiveTests/ToString.tests.cpp", + "SelfTest/IntrospectiveTests/Traits.tests.cpp", + "SelfTest/IntrospectiveTests/UniquePtr.tests.cpp", + "SelfTest/IntrospectiveTests/Xml.tests.cpp", + "SelfTest/TestRegistrations.cpp", + "SelfTest/TimingTests/Sleep.tests.cpp", + "SelfTest/UsageTests/Approx.tests.cpp", + "SelfTest/UsageTests/BDD.tests.cpp", + "SelfTest/UsageTests/Benchmark.tests.cpp", + "SelfTest/UsageTests/Class.tests.cpp", + "SelfTest/UsageTests/Compilation.tests.cpp", + "SelfTest/UsageTests/Condition.tests.cpp", + "SelfTest/UsageTests/Decomposition.tests.cpp", + "SelfTest/UsageTests/EnumToString.tests.cpp", + "SelfTest/UsageTests/Exception.tests.cpp", + "SelfTest/UsageTests/Generators.tests.cpp", + "SelfTest/UsageTests/Matchers.tests.cpp", + "SelfTest/UsageTests/MatchersRanges.tests.cpp", + "SelfTest/UsageTests/Message.tests.cpp", + "SelfTest/UsageTests/Misc.tests.cpp", + "SelfTest/UsageTests/ToStringByte.tests.cpp", + "SelfTest/UsageTests/ToStringChrono.tests.cpp", + "SelfTest/UsageTests/ToStringGeneral.tests.cpp", + "SelfTest/UsageTests/ToStringOptional.tests.cpp", + "SelfTest/UsageTests/ToStringPair.tests.cpp", + "SelfTest/UsageTests/ToStringTuple.tests.cpp", + "SelfTest/UsageTests/ToStringVariant.tests.cpp", + "SelfTest/UsageTests/ToStringVector.tests.cpp", + "SelfTest/UsageTests/ToStringWhich.tests.cpp", + "SelfTest/UsageTests/Tricky.tests.cpp", + "SelfTest/UsageTests/VariadicMacros.tests.cpp", + ], + deps = [ + ":catch2_self_test_helper", + "//:catch2", + "//:catch2_main", + ], +) diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt index d3ab14a7f6..37a5977e04 100644 --- a/tests/CMakeLists.txt +++ b/tests/CMakeLists.txt @@ -59,7 +59,7 @@ if (CATCH_BUILD_SURROGATES) ) target_link_libraries(Catch2SurrogateTarget PRIVATE Catch2WithMain) -endif(CATCH_BUILD_SURROGATES) +endif() #### # Temporary workaround for VS toolset changes in 2017 @@ -70,7 +70,7 @@ if (MSVC) configure_file(${CATCH_DIR}/tools/misc/SelfTest.vcxproj.user ${CMAKE_BINARY_DIR}/tests COPYONLY) -endif(MSVC) #Temporary workaround +endif() #Temporary workaround # define the sources of the self test diff --git a/tests/ExtraTests/CMakeLists.txt b/tests/ExtraTests/CMakeLists.txt index 2a810e2584..9f6d8173f6 100644 --- a/tests/ExtraTests/CMakeLists.txt +++ b/tests/ExtraTests/CMakeLists.txt @@ -183,7 +183,7 @@ if (NOT WIN32) PROPERTIES PASS_REGULAR_EXPRESSION "Catch will terminate" ) -endif(NOT WIN32) +endif() add_test(NAME CATCH_CONFIG_DISABLE_EXCEPTIONS-3 COMMAND DisabledExceptions-CustomHandler "Tests that run") @@ -467,6 +467,18 @@ set_tests_properties( PASS_REGULAR_EXPRESSION "Errors occurred during startup!" ) +add_executable(ReportingCrashWithJunitReporter ${TESTS_DIR}/X36-ReportingCrashWithJunitReporter.cpp) +target_link_libraries(ReportingCrashWithJunitReporter PRIVATE Catch2::Catch2WithMain) +add_test( + NAME Reporters::CrashInJunitReporter + COMMAND ${CMAKE_COMMAND} -E env $ --reporter JUnit +) +set_tests_properties( + Reporters::CrashInJunitReporter + PROPERTIES + PASS_REGULAR_EXPRESSION "" + LABELS "uses-signals" +) add_executable(AssertionStartingEventGoesBeforeAssertionIsEvaluated X20-AssertionStartingEventGoesBeforeAssertionIsEvaluated.cpp @@ -556,6 +568,7 @@ add_executable(AmalgamatedTestCompilation ${CATCH_DIR}/extras/catch_amalgamated.cpp ) target_include_directories(AmalgamatedTestCompilation PRIVATE ${CATCH_DIR}/extras) +target_compile_features(AmalgamatedTestCompilation PRIVATE cxx_std_14) add_test(NAME AmalgamatedFileTest COMMAND AmalgamatedTestCompilation) set_tests_properties( diff --git a/tests/ExtraTests/X02-DisabledMacros.cpp b/tests/ExtraTests/X02-DisabledMacros.cpp index 68bc2add60..231adfb05b 100644 --- a/tests/ExtraTests/X02-DisabledMacros.cpp +++ b/tests/ExtraTests/X02-DisabledMacros.cpp @@ -11,34 +11,28 @@ * and expressions in assertion macros are not run. */ - -#include #include +#include #include #include #include struct foo { - foo(){ - REQUIRE_NOTHROW( print() ); - } - void print() const { - std::cout << "This should not happen\n"; - } + foo() { REQUIRE_NOTHROW( print() ); } + void print() const { std::cout << "This should not happen\n"; } }; -#if defined(__clang__) -#pragma clang diagnostic push -#pragma clang diagnostic ignored "-Wglobal-constructors" +#if defined( __clang__ ) +# pragma clang diagnostic push +# pragma clang diagnostic ignored "-Wglobal-constructors" #endif // Construct foo, but `foo::print` should not be run static foo f; - -#if defined(__clang__) +#if defined( __clang__ ) // The test is unused since the registration is disabled -#pragma clang diagnostic ignored "-Wunused-function" +# pragma clang diagnostic ignored "-Wunused-function" #endif // This test should not be run, because it won't be registered @@ -60,6 +54,26 @@ TEST_CASE( "Disabled Macros" ) { BENCHMARK( "Disabled benchmark" ) { REQUIRE( 1 == 2 ); }; } -#if defined(__clang__) -#pragma clang diagnostic pop +struct DisabledFixture {}; + +TEST_CASE_PERSISTENT_FIXTURE( DisabledFixture, "Disabled Persistent Fixture" ) { + CHECK( 1 == 2 ); + REQUIRE( 1 == 2 ); + std::cout << "This should not happen\n"; + FAIL(); + + // Test that static assertions don't fire when macros are disabled + STATIC_CHECK( 0 == 1 ); + STATIC_REQUIRE( !true ); + + CAPTURE( 1 ); + CAPTURE( 1, "captured" ); + + REQUIRE_THAT( 1, + Catch::Matchers::Predicate( []( int ) { return false; } ) ); + BENCHMARK( "Disabled benchmark" ) { REQUIRE( 1 == 2 ); }; +} + +#if defined( __clang__ ) +# pragma clang diagnostic pop #endif diff --git a/tests/ExtraTests/X22-BenchmarksInCumulativeReporter.cpp b/tests/ExtraTests/X22-BenchmarksInCumulativeReporter.cpp index af03ce30ae..33399a6869 100644 --- a/tests/ExtraTests/X22-BenchmarksInCumulativeReporter.cpp +++ b/tests/ExtraTests/X22-BenchmarksInCumulativeReporter.cpp @@ -34,7 +34,7 @@ class CumulativeBenchmarkReporter final : public Catch::CumulativeReporterBase { return "Custom reporter for testing cumulative reporter base"; } - virtual void testRunEndedCumulative() override; + void testRunEndedCumulative() override; }; CATCH_REGISTER_REPORTER("testReporter", CumulativeBenchmarkReporter) diff --git a/tests/ExtraTests/X29-CustomArgumentsForReporters.cpp b/tests/ExtraTests/X29-CustomArgumentsForReporters.cpp index 9bd816efcb..13d9fc1869 100644 --- a/tests/ExtraTests/X29-CustomArgumentsForReporters.cpp +++ b/tests/ExtraTests/X29-CustomArgumentsForReporters.cpp @@ -36,6 +36,7 @@ class TestReporter : public Catch::StreamingReporterBase { void testRunStarting( Catch::TestRunInfo const& ) override { std::vector> options; + options.reserve( m_customOptions.size() ); for ( auto const& kv : m_customOptions ) { options.push_back( kv ); } diff --git a/tests/ExtraTests/X36-ReportingCrashWithJunitReporter.cpp b/tests/ExtraTests/X36-ReportingCrashWithJunitReporter.cpp new file mode 100644 index 0000000000..34f4cd854f --- /dev/null +++ b/tests/ExtraTests/X36-ReportingCrashWithJunitReporter.cpp @@ -0,0 +1,32 @@ + +// Copyright Catch2 Authors +// Distributed under the Boost Software License, Version 1.0. +// (See accompanying file LICENSE.txt or copy at +// https://www.boost.org/LICENSE_1_0.txt) + +// SPDX-License-Identifier: BSL-1.0 + +/**\file + * Checks that signals/SEH within open section does not hard crash JUnit + * (or similar reporter) while we are trying to report fatal error. + */ + +#include + +#include + +// On Windows we need to send SEH and not signal to test the +// RunContext::handleFatalErrorCondition code path +#if defined( _MSC_VER ) +# include +#endif + +TEST_CASE( "raises signal" ) { + SECTION( "section" ) { +#if defined( _MSC_VER ) + RaiseException( 0xC0000005, 0, 0, NULL ); +#else + std::raise( SIGILL ); +#endif + } +} diff --git a/tests/ExtraTests/X91-AmalgamatedCatch.cpp b/tests/ExtraTests/X91-AmalgamatedCatch.cpp index c00462be74..78d45a2c1c 100644 --- a/tests/ExtraTests/X91-AmalgamatedCatch.cpp +++ b/tests/ExtraTests/X91-AmalgamatedCatch.cpp @@ -16,10 +16,10 @@ TEST_CASE("Just a dummy test") { auto i = GENERATE(1, 2, 3); SECTION("a") { - REQUIRE(1 != 4); + REQUIRE(i != 4); } SECTION("b") { - CHECK(1 != 5); + CHECK(i != 5); } REQUIRE_THAT(1, Catch::Matchers::Predicate([](int i) { diff --git a/tests/SelfTest/Baselines/automake.sw.approved.txt b/tests/SelfTest/Baselines/automake.sw.approved.txt index 88c23e1737..08fbf09c53 100644 --- a/tests/SelfTest/Baselines/automake.sw.approved.txt +++ b/tests/SelfTest/Baselines/automake.sw.approved.txt @@ -68,6 +68,8 @@ Nor would this :test-result: PASS A TEMPLATE_TEST_CASE_METHOD_SIG based test run that succeeds - 6 :test-result: FAIL A TEST_CASE_METHOD based test run that fails :test-result: PASS A TEST_CASE_METHOD based test run that succeeds +:test-result: FAIL A TEST_CASE_PERSISTENT_FIXTURE based test run that fails +:test-result: PASS A TEST_CASE_PERSISTENT_FIXTURE based test run that succeeds :test-result: PASS A Template product test case - Foo :test-result: PASS A Template product test case - Foo :test-result: PASS A Template product test case - std::vector @@ -103,6 +105,7 @@ Nor would this :test-result: PASS CaseInsensitiveEqualsTo is case insensitive :test-result: PASS CaseInsensitiveLess is case insensitive :test-result: PASS Character pretty printing +:test-result: PASS Clara::Arg does not crash on incomplete input :test-result: PASS Clara::Arg supports single-arg parse the way Opt does :test-result: PASS Clara::Opt supports accept-many lambdas :test-result: PASS ColourGuard behaviour @@ -354,7 +357,6 @@ b1! :test-result: FAIL nested sections can be skipped dynamically at runtime :test-result: PASS non streamable - with conv. op :test-result: PASS non-copyable objects -:test-result: PASS normal_cdf :test-result: PASS normal_quantile :test-result: PASS not allowed :test-result: FAIL not prints unscoped info from previous failures diff --git a/tests/SelfTest/Baselines/automake.sw.multi.approved.txt b/tests/SelfTest/Baselines/automake.sw.multi.approved.txt index a37b1a2b5d..c4b7b96707 100644 --- a/tests/SelfTest/Baselines/automake.sw.multi.approved.txt +++ b/tests/SelfTest/Baselines/automake.sw.multi.approved.txt @@ -66,6 +66,8 @@ :test-result: PASS A TEMPLATE_TEST_CASE_METHOD_SIG based test run that succeeds - 6 :test-result: FAIL A TEST_CASE_METHOD based test run that fails :test-result: PASS A TEST_CASE_METHOD based test run that succeeds +:test-result: FAIL A TEST_CASE_PERSISTENT_FIXTURE based test run that fails +:test-result: PASS A TEST_CASE_PERSISTENT_FIXTURE based test run that succeeds :test-result: PASS A Template product test case - Foo :test-result: PASS A Template product test case - Foo :test-result: PASS A Template product test case - std::vector @@ -101,6 +103,7 @@ :test-result: PASS CaseInsensitiveEqualsTo is case insensitive :test-result: PASS CaseInsensitiveLess is case insensitive :test-result: PASS Character pretty printing +:test-result: PASS Clara::Arg does not crash on incomplete input :test-result: PASS Clara::Arg supports single-arg parse the way Opt does :test-result: PASS Clara::Opt supports accept-many lambdas :test-result: PASS ColourGuard behaviour @@ -343,7 +346,6 @@ :test-result: FAIL nested sections can be skipped dynamically at runtime :test-result: PASS non streamable - with conv. op :test-result: PASS non-copyable objects -:test-result: PASS normal_cdf :test-result: PASS normal_quantile :test-result: PASS not allowed :test-result: FAIL not prints unscoped info from previous failures diff --git a/tests/SelfTest/Baselines/compact.sw.approved.txt b/tests/SelfTest/Baselines/compact.sw.approved.txt index 0669fdbbbe..1f0dd01255 100644 --- a/tests/SelfTest/Baselines/compact.sw.approved.txt +++ b/tests/SelfTest/Baselines/compact.sw.approved.txt @@ -241,6 +241,10 @@ Class.tests.cpp:: passed: Nttp_Fixture::value > 0 for: 3 > 0 Class.tests.cpp:: passed: Nttp_Fixture::value > 0 for: 6 > 0 Class.tests.cpp:: failed: m_a == 2 for: 1 == 2 Class.tests.cpp:: passed: m_a == 1 for: 1 == 1 +Class.tests.cpp:: passed: m_a++ == 0 for: 0 == 0 +Class.tests.cpp:: failed: m_a == 0 for: 1 == 0 +Class.tests.cpp:: passed: m_a++ == 0 for: 0 == 0 +Class.tests.cpp:: passed: m_a == 1 for: 1 == 1 Misc.tests.cpp:: passed: x.size() == 0 for: 0 == 0 Misc.tests.cpp:: passed: x.size() == 0 for: 0 == 0 Misc.tests.cpp:: passed: x.size() == 0 for: 0 == 0 @@ -249,12 +253,22 @@ Misc.tests.cpp:: passed: x.size() > 0 for: 42 > 0 Misc.tests.cpp:: passed: x.size() > 0 for: 9 > 0 Misc.tests.cpp:: passed: x.size() > 0 for: 42 > 0 Misc.tests.cpp:: passed: x.size() > 0 for: 9 > 0 -Approx.tests.cpp:: passed: d == 1.23_a for: 1.23 == Approx( 1.23 ) -Approx.tests.cpp:: passed: d != 1.22_a for: 1.23 != Approx( 1.22 ) -Approx.tests.cpp:: passed: -d == -1.23_a for: -1.23 == Approx( -1.23 ) -Approx.tests.cpp:: passed: d == 1.2_a .epsilon(.1) for: 1.23 == Approx( 1.2 ) -Approx.tests.cpp:: passed: d != 1.2_a .epsilon(.001) for: 1.23 != Approx( 1.2 ) -Approx.tests.cpp:: passed: d == 1_a .epsilon(.3) for: 1.23 == Approx( 1.0 ) +Approx.tests.cpp:: passed: d == 1.23_a for: 1.22999999999999998 +== +Approx( 1.22999999999999998 ) +Approx.tests.cpp:: passed: d != 1.22_a for: 1.22999999999999998 +!= +Approx( 1.21999999999999997 ) +Approx.tests.cpp:: passed: -d == -1.23_a for: -1.22999999999999998 +== +Approx( -1.22999999999999998 ) +Approx.tests.cpp:: passed: d == 1.2_a .epsilon(.1) for: 1.22999999999999998 +== +Approx( 1.19999999999999996 ) +Approx.tests.cpp:: passed: d != 1.2_a .epsilon(.001) for: 1.22999999999999998 +!= +Approx( 1.19999999999999996 ) +Approx.tests.cpp:: passed: d == 1_a .epsilon(.3) for: 1.22999999999999998 == Approx( 1.0 ) Misc.tests.cpp:: passed: with 1 message: 'that's not flying - that's failing in style' Misc.tests.cpp:: failed: explicitly with 1 message: 'to infinity and beyond' Tricky.tests.cpp:: failed: &o1 == &o2 for: 0x == 0x @@ -263,8 +277,8 @@ Approx.tests.cpp:: passed: 104.0 != Approx(100.0) for: 104.0 != App Approx.tests.cpp:: passed: 104.0 == Approx(100.0).margin(5) for: 104.0 == Approx( 100.0 ) Approx.tests.cpp:: passed: 104.0 == Approx(100.0).margin(4) for: 104.0 == Approx( 100.0 ) Approx.tests.cpp:: passed: 104.0 != Approx(100.0).margin(3) for: 104.0 != Approx( 100.0 ) -Approx.tests.cpp:: passed: 100.3 != Approx(100.0) for: 100.3 != Approx( 100.0 ) -Approx.tests.cpp:: passed: 100.3 == Approx(100.0).margin(0.5) for: 100.3 == Approx( 100.0 ) +Approx.tests.cpp:: passed: 100.3 != Approx(100.0) for: 100.29999999999999716 != Approx( 100.0 ) +Approx.tests.cpp:: passed: 100.3 == Approx(100.0).margin(0.5) for: 100.29999999999999716 == Approx( 100.0 ) Tricky.tests.cpp:: passed: i++ == 7 for: 7 == 7 Tricky.tests.cpp:: passed: i++ == 8 for: 8 == 8 Exception.tests.cpp:: passed: 1 == 1 @@ -282,19 +296,33 @@ Approx.tests.cpp:: passed: 0.0f == Approx(0.25f).margin(0.25f) for: Approx.tests.cpp:: passed: 0.5f == Approx(0.25f).margin(0.25f) for: 0.5f == Approx( 0.25 ) Approx.tests.cpp:: passed: 245.0f == Approx(245.25f).margin(0.25f) for: 245.0f == Approx( 245.25 ) Approx.tests.cpp:: passed: 245.5f == Approx(245.25f).margin(0.25f) for: 245.5f == Approx( 245.25 ) -Approx.tests.cpp:: passed: divide( 22, 7 ) == Approx( 3.141 ).epsilon( 0.001 ) for: 3.1428571429 == Approx( 3.141 ) -Approx.tests.cpp:: passed: divide( 22, 7 ) != Approx( 3.141 ).epsilon( 0.0001 ) for: 3.1428571429 != Approx( 3.141 ) -Approx.tests.cpp:: passed: d != Approx( 1.231 ) for: 1.23 != Approx( 1.231 ) -Approx.tests.cpp:: passed: d == Approx( 1.231 ).epsilon( 0.1 ) for: 1.23 == Approx( 1.231 ) -Approx.tests.cpp:: passed: 1.23f == Approx( 1.23f ) for: 1.23f == Approx( 1.2300000191 ) +Approx.tests.cpp:: passed: divide( 22, 7 ) == Approx( 3.141 ).epsilon( 0.001 ) for: 3.14285714285714279 +== +Approx( 3.14100000000000001 ) +Approx.tests.cpp:: passed: divide( 22, 7 ) != Approx( 3.141 ).epsilon( 0.0001 ) for: 3.14285714285714279 +!= +Approx( 3.14100000000000001 ) +Approx.tests.cpp:: passed: d != Approx( 1.231 ) for: 1.22999999999999998 +!= +Approx( 1.23100000000000009 ) +Approx.tests.cpp:: passed: d == Approx( 1.231 ).epsilon( 0.1 ) for: 1.22999999999999998 +== +Approx( 1.23100000000000009 ) +Approx.tests.cpp:: passed: 1.23f == Approx( 1.23f ) for: 1.230000019f +== +Approx( 1.23000001907348633 ) Approx.tests.cpp:: passed: 0.0f == Approx( 0.0f ) for: 0.0f == Approx( 0.0 ) Approx.tests.cpp:: passed: 1 == Approx( 1 ) for: 1 == Approx( 1.0 ) Approx.tests.cpp:: passed: 0 == Approx( 0 ) for: 0 == Approx( 0.0 ) Approx.tests.cpp:: passed: 1.0f == Approx( 1 ) for: 1.0f == Approx( 1.0 ) Approx.tests.cpp:: passed: 0 == Approx( dZero) for: 0 == Approx( 0.0 ) Approx.tests.cpp:: passed: 0 == Approx( dSmall ).margin( 0.001 ) for: 0 == Approx( 0.00001 ) -Approx.tests.cpp:: passed: 1.234f == Approx( dMedium ) for: 1.234f == Approx( 1.234 ) -Approx.tests.cpp:: passed: dMedium == Approx( 1.234f ) for: 1.234 == Approx( 1.2339999676 ) +Approx.tests.cpp:: passed: 1.234f == Approx( dMedium ) for: 1.233999968f +== +Approx( 1.23399999999999999 ) +Approx.tests.cpp:: passed: dMedium == Approx( 1.234f ) for: 1.23399999999999999 +== +Approx( 1.23399996757507324 ) Matchers.tests.cpp:: passed: 1, Predicate( alwaysTrue, "always true" ) for: 1 matches predicate: "always true" Matchers.tests.cpp:: passed: 1, !Predicate( alwaysFalse, "always false" ) for: 1 not matches predicate: "always false" Matchers.tests.cpp:: passed: "Hello olleH", Predicate( []( std::string const& str ) -> bool { return str.front() == str.back(); }, "First and last character should be equal" ) for: "Hello olleH" matches predicate: "First and last character should be equal" @@ -350,20 +378,22 @@ Details.tests.cpp:: passed: lt( "a", "b" ) for: true Details.tests.cpp:: passed: lt( "a", "B" ) for: true Details.tests.cpp:: passed: lt( "A", "b" ) for: true Details.tests.cpp:: passed: lt( "A", "B" ) for: true -ToStringGeneral.tests.cpp:: passed: tab == '\t' for: '\t' == '\t' -ToStringGeneral.tests.cpp:: passed: newline == '\n' for: '\n' == '\n' -ToStringGeneral.tests.cpp:: passed: carr_return == '\r' for: '\r' == '\r' -ToStringGeneral.tests.cpp:: passed: form_feed == '\f' for: '\f' == '\f' -ToStringGeneral.tests.cpp:: passed: space == ' ' for: ' ' == ' ' -ToStringGeneral.tests.cpp:: passed: c == chars[i] for: 'a' == 'a' -ToStringGeneral.tests.cpp:: passed: c == chars[i] for: 'z' == 'z' -ToStringGeneral.tests.cpp:: passed: c == chars[i] for: 'A' == 'A' -ToStringGeneral.tests.cpp:: passed: c == chars[i] for: 'Z' == 'Z' -ToStringGeneral.tests.cpp:: passed: null_terminator == '\0' for: 0 == 0 -ToStringGeneral.tests.cpp:: passed: c == i for: 2 == 2 -ToStringGeneral.tests.cpp:: passed: c == i for: 3 == 3 -ToStringGeneral.tests.cpp:: passed: c == i for: 4 == 4 -ToStringGeneral.tests.cpp:: passed: c == i for: 5 == 5 +ToStringGeneral.tests.cpp:: passed: ::Catch::Detail::stringify('\t') == "'\\t'" for: "'\t'" == "'\t'" +ToStringGeneral.tests.cpp:: passed: ::Catch::Detail::stringify('\n') == "'\\n'" for: "'\n'" == "'\n'" +ToStringGeneral.tests.cpp:: passed: ::Catch::Detail::stringify('\r') == "'\\r'" for: "'\r'" == "'\r'" +ToStringGeneral.tests.cpp:: passed: ::Catch::Detail::stringify('\f') == "'\\f'" for: "'\f'" == "'\f'" +ToStringGeneral.tests.cpp:: passed: ::Catch::Detail::stringify( ' ' ) == "' '" for: "' '" == "' '" +ToStringGeneral.tests.cpp:: passed: ::Catch::Detail::stringify( 'A' ) == "'A'" for: "'A'" == "'A'" +ToStringGeneral.tests.cpp:: passed: ::Catch::Detail::stringify( 'z' ) == "'z'" for: "'z'" == "'z'" +ToStringGeneral.tests.cpp:: passed: ::Catch::Detail::stringify( '\0' ) == "0" for: "0" == "0" +ToStringGeneral.tests.cpp:: passed: ::Catch::Detail::stringify( static_cast(2) ) == "2" for: "2" == "2" +ToStringGeneral.tests.cpp:: passed: ::Catch::Detail::stringify( static_cast(5) ) == "5" for: "5" == "5" +Clara.tests.cpp:: passed: name.empty() for: true +Clara.tests.cpp:: passed: result for: {?} +Clara.tests.cpp:: passed: result.type() == Catch::Clara::Detail::ResultType::Ok for: 0 == 0 +Clara.tests.cpp:: passed: parsed.type() == Catch::Clara::ParseResultType::NoMatch for: 1 == 1 +Clara.tests.cpp:: passed: parsed.remainingTokens().count() == 2 for: 2 == 2 +Clara.tests.cpp:: passed: name.empty() for: true Clara.tests.cpp:: passed: name.empty() for: true Clara.tests.cpp:: passed: name == "foo" for: "foo" == "foo" Clara.tests.cpp:: passed: !(parse_result) for: !{?} @@ -513,7 +543,7 @@ Stream.tests.cpp:: passed: Catch::makeStream( "-" )->isConsole() fo Exception.tests.cpp:: failed: unexpected exception with message: 'custom exception - not std'; expression was: throwCustom() Exception.tests.cpp:: failed: unexpected exception with message: 'custom exception - not std'; expression was: throwCustom(), std::exception Exception.tests.cpp:: failed: unexpected exception with message: 'custom std exception' -Approx.tests.cpp:: passed: 101.000001 != Approx(100).epsilon(0.01) for: 101.000001 != Approx( 100.0 ) +Approx.tests.cpp:: passed: 101.000001 != Approx(100).epsilon(0.01) for: 101.00000099999999748 != Approx( 100.0 ) Approx.tests.cpp:: passed: std::pow(10, -5) != Approx(std::pow(10, -7)) for: 0.00001 != Approx( 0.0000001 ) ToString.tests.cpp:: passed: enumInfo->lookup(0) == "Value1" for: Value1 == "Value1" ToString.tests.cpp:: passed: enumInfo->lookup(1) == "Value2" for: Value2 == "Value2" @@ -533,27 +563,39 @@ EnumToString.tests.cpp:: passed: stringify( EnumClass3::Value4 ) == EnumToString.tests.cpp:: passed: stringify( ec3 ) == "Value2" for: "Value2" == "Value2" EnumToString.tests.cpp:: passed: stringify( Bikeshed::Colours::Red ) == "Red" for: "Red" == "Red" EnumToString.tests.cpp:: passed: stringify( Bikeshed::Colours::Blue ) == "Blue" for: "Blue" == "Blue" -Approx.tests.cpp:: passed: 101.01 != Approx(100).epsilon(0.01) for: 101.01 != Approx( 100.0 ) +Approx.tests.cpp:: passed: 101.01 != Approx(100).epsilon(0.01) for: 101.01000000000000512 != Approx( 100.0 ) Condition.tests.cpp:: failed: data.int_seven == 6 for: 7 == 6 Condition.tests.cpp:: failed: data.int_seven == 8 for: 7 == 8 Condition.tests.cpp:: failed: data.int_seven == 0 for: 7 == 0 -Condition.tests.cpp:: failed: data.float_nine_point_one == Approx( 9.11f ) for: 9.1f == Approx( 9.1099996567 ) -Condition.tests.cpp:: failed: data.float_nine_point_one == Approx( 9.0f ) for: 9.1f == Approx( 9.0 ) -Condition.tests.cpp:: failed: data.float_nine_point_one == Approx( 1 ) for: 9.1f == Approx( 1.0 ) -Condition.tests.cpp:: failed: data.float_nine_point_one == Approx( 0 ) for: 9.1f == Approx( 0.0 ) -Condition.tests.cpp:: failed: data.double_pi == Approx( 3.1415 ) for: 3.1415926535 == Approx( 3.1415 ) +Condition.tests.cpp:: failed: data.float_nine_point_one == Approx( 9.11f ) for: 9.100000381f +== +Approx( 9.10999965667724609 ) +Condition.tests.cpp:: failed: data.float_nine_point_one == Approx( 9.0f ) for: 9.100000381f == Approx( 9.0 ) +Condition.tests.cpp:: failed: data.float_nine_point_one == Approx( 1 ) for: 9.100000381f == Approx( 1.0 ) +Condition.tests.cpp:: failed: data.float_nine_point_one == Approx( 0 ) for: 9.100000381f == Approx( 0.0 ) +Condition.tests.cpp:: failed: data.double_pi == Approx( 3.1415 ) for: 3.14159265350000005 +== +Approx( 3.14150000000000018 ) Condition.tests.cpp:: failed: data.str_hello == "goodbye" for: "hello" == "goodbye" Condition.tests.cpp:: failed: data.str_hello == "hell" for: "hello" == "hell" Condition.tests.cpp:: failed: data.str_hello == "hello1" for: "hello" == "hello1" Condition.tests.cpp:: failed: data.str_hello.size() == 6 for: 5 == 6 -Condition.tests.cpp:: failed: x == Approx( 1.301 ) for: 1.3 == Approx( 1.301 ) +Condition.tests.cpp:: failed: x == Approx( 1.301 ) for: 1.30000000000000027 +== +Approx( 1.30099999999999993 ) Condition.tests.cpp:: passed: data.int_seven == 7 for: 7 == 7 -Condition.tests.cpp:: passed: data.float_nine_point_one == Approx( 9.1f ) for: 9.1f == Approx( 9.1000003815 ) -Condition.tests.cpp:: passed: data.double_pi == Approx( 3.1415926535 ) for: 3.1415926535 == Approx( 3.1415926535 ) +Condition.tests.cpp:: passed: data.float_nine_point_one == Approx( 9.1f ) for: 9.100000381f +== +Approx( 9.10000038146972656 ) +Condition.tests.cpp:: passed: data.double_pi == Approx( 3.1415926535 ) for: 3.14159265350000005 +== +Approx( 3.14159265350000005 ) Condition.tests.cpp:: passed: data.str_hello == "hello" for: "hello" == "hello" Condition.tests.cpp:: passed: "hello" == data.str_hello for: "hello" == "hello" Condition.tests.cpp:: passed: data.str_hello.size() == 5 for: 5 == 5 -Condition.tests.cpp:: passed: x == Approx( 1.3 ) for: 1.3 == Approx( 1.3 ) +Condition.tests.cpp:: passed: x == Approx( 1.3 ) for: 1.30000000000000027 +== +Approx( 1.30000000000000004 ) Matchers.tests.cpp:: passed: testStringForMatching(), Equals( "this string contains 'abc' as a substring" ) for: "this string contains 'abc' as a substring" equals: "this string contains 'abc' as a substring" Matchers.tests.cpp:: passed: testStringForMatching(), Equals( "this string contains 'ABC' as a substring", Catch::CaseSensitive::No ) for: "this string contains 'abc' as a substring" equals: "this string contains 'abc' as a substring" (case insensitive) Matchers.tests.cpp:: failed: testStringForMatching(), Equals( "this string contains 'ABC' as a substring" ) for: "this string contains 'abc' as a substring" equals: "this string contains 'ABC' as a substring" @@ -600,21 +642,21 @@ Misc.tests.cpp:: passed: Factorial(2) == 2 for: 2 == 2 Misc.tests.cpp:: passed: Factorial(3) == 6 for: 6 == 6 Misc.tests.cpp:: passed: Factorial(10) == 3628800 for: 3628800 (0x) == 3628800 (0x) GeneratorsImpl.tests.cpp:: passed: filter( []( int ) { return false; }, value( 3 ) ), Catch::GeneratorException -Matchers.tests.cpp:: passed: 10., WithinRel( 11.1, 0.1 ) for: 10.0 and 11.1 are within 10% of each other -Matchers.tests.cpp:: passed: 10., !WithinRel( 11.2, 0.1 ) for: 10.0 not and 11.2 are within 10% of each other -Matchers.tests.cpp:: passed: 1., !WithinRel( 0., 0.99 ) for: 1.0 not and 0 are within 99% of each other -Matchers.tests.cpp:: passed: -0., WithinRel( 0. ) for: -0.0 and 0 are within 2.22045e-12% of each other -Matchers.tests.cpp:: passed: v1, WithinRel( v2 ) for: 0.0 and 2.22507e-308 are within 2.22045e-12% of each other +Matchers.tests.cpp:: passed: 10., WithinRel( 11.1, 0.1 ) for: 10.0 and 11.09999999999999964 are within 10% of each other +Matchers.tests.cpp:: passed: 10., !WithinRel( 11.2, 0.1 ) for: 10.0 not and 11.19999999999999929 are within 10% of each other +Matchers.tests.cpp:: passed: 1., !WithinRel( 0., 0.99 ) for: 1.0 not and 0.0 are within 99% of each other +Matchers.tests.cpp:: passed: -0., WithinRel( 0. ) for: -0.0 and 0.0 are within 2.22045e-12% of each other +Matchers.tests.cpp:: passed: v1, WithinRel( v2 ) for: 0.0 and 0.0 are within 2.22045e-12% of each other Matchers.tests.cpp:: passed: 1., WithinAbs( 1., 0 ) for: 1.0 is within 0.0 of 1.0 Matchers.tests.cpp:: passed: 0., WithinAbs( 1., 1 ) for: 0.0 is within 1.0 of 1.0 -Matchers.tests.cpp:: passed: 0., !WithinAbs( 1., 0.99 ) for: 0.0 not is within 0.99 of 1.0 -Matchers.tests.cpp:: passed: 0., !WithinAbs( 1., 0.99 ) for: 0.0 not is within 0.99 of 1.0 +Matchers.tests.cpp:: passed: 0., !WithinAbs( 1., 0.99 ) for: 0.0 not is within 0.98999999999999999 of 1.0 +Matchers.tests.cpp:: passed: 0., !WithinAbs( 1., 0.99 ) for: 0.0 not is within 0.98999999999999999 of 1.0 Matchers.tests.cpp:: passed: 11., !WithinAbs( 10., 0.5 ) for: 11.0 not is within 0.5 of 10.0 Matchers.tests.cpp:: passed: 10., !WithinAbs( 11., 0.5 ) for: 10.0 not is within 0.5 of 11.0 Matchers.tests.cpp:: passed: -10., WithinAbs( -10., 0.5 ) for: -10.0 is within 0.5 of -10.0 -Matchers.tests.cpp:: passed: -10., WithinAbs( -9.6, 0.5 ) for: -10.0 is within 0.5 of -9.6 +Matchers.tests.cpp:: passed: -10., WithinAbs( -9.6, 0.5 ) for: -10.0 is within 0.5 of -9.59999999999999964 Matchers.tests.cpp:: passed: 1., WithinULP( 1., 0 ) for: 1.0 is within 0 ULPs of 1.0000000000000000e+00 ([1.0000000000000000e+00, 1.0000000000000000e+00]) -Matchers.tests.cpp:: passed: nextafter( 1., 2. ), WithinULP( 1., 1 ) for: 1.0 is within 1 ULPs of 1.0000000000000000e+00 ([9.9999999999999989e-01, 1.0000000000000002e+00]) +Matchers.tests.cpp:: passed: nextafter( 1., 2. ), WithinULP( 1., 1 ) for: 1.00000000000000022 is within 1 ULPs of 1.0000000000000000e+00 ([9.9999999999999989e-01, 1.0000000000000002e+00]) Matchers.tests.cpp:: passed: 0., WithinULP( nextafter( 0., 1. ), 1 ) for: 0.0 is within 1 ULPs of 4.9406564584124654e-324 ([0.0000000000000000e+00, 9.8813129168249309e-324]) Matchers.tests.cpp:: passed: 1., WithinULP( nextafter( 1., 0. ), 1 ) for: 1.0 is within 1 ULPs of 9.9999999999999989e-01 ([9.9999999999999978e-01, 1.0000000000000000e+00]) Matchers.tests.cpp:: passed: 1., !WithinULP( nextafter( 1., 2. ), 0 ) for: 1.0 not is within 0 ULPs of 1.0000000000000002e+00 ([1.0000000000000002e+00, 1.0000000000000002e+00]) @@ -622,7 +664,7 @@ Matchers.tests.cpp:: passed: 1., WithinULP( 1., 0 ) for: 1.0 is wit Matchers.tests.cpp:: passed: -0., WithinULP( 0., 0 ) for: -0.0 is within 0 ULPs of 0.0000000000000000e+00 ([0.0000000000000000e+00, 0.0000000000000000e+00]) Matchers.tests.cpp:: passed: 1., WithinAbs( 1., 0.5 ) || WithinULP( 2., 1 ) for: 1.0 ( is within 0.5 of 1.0 or is within 1 ULPs of 2.0000000000000000e+00 ([1.9999999999999998e+00, 2.0000000000000004e+00]) ) Matchers.tests.cpp:: passed: 1., WithinAbs( 2., 0.5 ) || WithinULP( 1., 0 ) for: 1.0 ( is within 0.5 of 2.0 or is within 0 ULPs of 1.0000000000000000e+00 ([1.0000000000000000e+00, 1.0000000000000000e+00]) ) -Matchers.tests.cpp:: passed: 0.0001, WithinAbs( 0., 0.001 ) || WithinRel( 0., 0.1 ) for: 0.0001 ( is within 0.001 of 0.0 or and 0 are within 10% of each other ) +Matchers.tests.cpp:: passed: 0.0001, WithinAbs( 0., 0.001 ) || WithinRel( 0., 0.1 ) for: 0.0001 ( is within 0.001 of 0.0 or and 0.0 are within 10% of each other ) Matchers.tests.cpp:: passed: WithinAbs( 1., 0. ) Matchers.tests.cpp:: passed: WithinAbs( 1., -1. ), std::domain_error Matchers.tests.cpp:: passed: WithinULP( 1., 0 ) @@ -630,23 +672,23 @@ Matchers.tests.cpp:: passed: WithinRel( 1., 0. ) Matchers.tests.cpp:: passed: WithinRel( 1., -0.2 ), std::domain_error Matchers.tests.cpp:: passed: WithinRel( 1., 1. ), std::domain_error Matchers.tests.cpp:: passed: 1., !IsNaN() for: 1.0 not is NaN -Matchers.tests.cpp:: passed: 10.f, WithinRel( 11.1f, 0.1f ) for: 10.0f and 11.1 are within 10% of each other -Matchers.tests.cpp:: passed: 10.f, !WithinRel( 11.2f, 0.1f ) for: 10.0f not and 11.2 are within 10% of each other -Matchers.tests.cpp:: passed: 1.f, !WithinRel( 0.f, 0.99f ) for: 1.0f not and 0 are within 99% of each other -Matchers.tests.cpp:: passed: -0.f, WithinRel( 0.f ) for: -0.0f and 0 are within 0.00119209% of each other -Matchers.tests.cpp:: passed: v1, WithinRel( v2 ) for: 0.0f and 1.17549e-38 are within 0.00119209% of each other +Matchers.tests.cpp:: passed: 10.f, WithinRel( 11.1f, 0.1f ) for: 10.0f and 11.10000038146972656 are within 10% of each other +Matchers.tests.cpp:: passed: 10.f, !WithinRel( 11.2f, 0.1f ) for: 10.0f not and 11.19999980926513672 are within 10% of each other +Matchers.tests.cpp:: passed: 1.f, !WithinRel( 0.f, 0.99f ) for: 1.0f not and 0.0 are within 99% of each other +Matchers.tests.cpp:: passed: -0.f, WithinRel( 0.f ) for: -0.0f and 0.0 are within 0.00119209% of each other +Matchers.tests.cpp:: passed: v1, WithinRel( v2 ) for: 0.0f and 0.0 are within 0.00119209% of each other Matchers.tests.cpp:: passed: 1.f, WithinAbs( 1.f, 0 ) for: 1.0f is within 0.0 of 1.0 Matchers.tests.cpp:: passed: 0.f, WithinAbs( 1.f, 1 ) for: 0.0f is within 1.0 of 1.0 -Matchers.tests.cpp:: passed: 0.f, !WithinAbs( 1.f, 0.99f ) for: 0.0f not is within 0.9900000095 of 1.0 -Matchers.tests.cpp:: passed: 0.f, !WithinAbs( 1.f, 0.99f ) for: 0.0f not is within 0.9900000095 of 1.0 +Matchers.tests.cpp:: passed: 0.f, !WithinAbs( 1.f, 0.99f ) for: 0.0f not is within 0.99000000953674316 of 1.0 +Matchers.tests.cpp:: passed: 0.f, !WithinAbs( 1.f, 0.99f ) for: 0.0f not is within 0.99000000953674316 of 1.0 Matchers.tests.cpp:: passed: 0.f, WithinAbs( -0.f, 0 ) for: 0.0f is within 0.0 of -0.0 Matchers.tests.cpp:: passed: 11.f, !WithinAbs( 10.f, 0.5f ) for: 11.0f not is within 0.5 of 10.0 Matchers.tests.cpp:: passed: 10.f, !WithinAbs( 11.f, 0.5f ) for: 10.0f not is within 0.5 of 11.0 Matchers.tests.cpp:: passed: -10.f, WithinAbs( -10.f, 0.5f ) for: -10.0f is within 0.5 of -10.0 -Matchers.tests.cpp:: passed: -10.f, WithinAbs( -9.6f, 0.5f ) for: -10.0f is within 0.5 of -9.6000003815 +Matchers.tests.cpp:: passed: -10.f, WithinAbs( -9.6f, 0.5f ) for: -10.0f is within 0.5 of -9.60000038146972656 Matchers.tests.cpp:: passed: 1.f, WithinULP( 1.f, 0 ) for: 1.0f is within 0 ULPs of 1.00000000e+00f ([1.00000000e+00, 1.00000000e+00]) Matchers.tests.cpp:: passed: -1.f, WithinULP( -1.f, 0 ) for: -1.0f is within 0 ULPs of -1.00000000e+00f ([-1.00000000e+00, -1.00000000e+00]) -Matchers.tests.cpp:: passed: nextafter( 1.f, 2.f ), WithinULP( 1.f, 1 ) for: 1.0f is within 1 ULPs of 1.00000000e+00f ([9.99999940e-01, 1.00000012e+00]) +Matchers.tests.cpp:: passed: nextafter( 1.f, 2.f ), WithinULP( 1.f, 1 ) for: 1.000000119f is within 1 ULPs of 1.00000000e+00f ([9.99999940e-01, 1.00000012e+00]) Matchers.tests.cpp:: passed: 0.f, WithinULP( nextafter( 0.f, 1.f ), 1 ) for: 0.0f is within 1 ULPs of 1.40129846e-45f ([0.00000000e+00, 2.80259693e-45]) Matchers.tests.cpp:: passed: 1.f, WithinULP( nextafter( 1.f, 0.f ), 1 ) for: 1.0f is within 1 ULPs of 9.99999940e-01f ([9.99999881e-01, 1.00000000e+00]) Matchers.tests.cpp:: passed: 1.f, !WithinULP( nextafter( 1.f, 2.f ), 0 ) for: 1.0f not is within 0 ULPs of 1.00000012e+00f ([1.00000012e+00, 1.00000012e+00]) @@ -654,7 +696,7 @@ Matchers.tests.cpp:: passed: 1.f, WithinULP( 1.f, 0 ) for: 1.0f is Matchers.tests.cpp:: passed: -0.f, WithinULP( 0.f, 0 ) for: -0.0f is within 0 ULPs of 0.00000000e+00f ([0.00000000e+00, 0.00000000e+00]) Matchers.tests.cpp:: passed: 1.f, WithinAbs( 1.f, 0.5 ) || WithinULP( 1.f, 1 ) for: 1.0f ( is within 0.5 of 1.0 or is within 1 ULPs of 1.00000000e+00f ([9.99999940e-01, 1.00000012e+00]) ) Matchers.tests.cpp:: passed: 1.f, WithinAbs( 2.f, 0.5 ) || WithinULP( 1.f, 0 ) for: 1.0f ( is within 0.5 of 2.0 or is within 0 ULPs of 1.00000000e+00f ([1.00000000e+00, 1.00000000e+00]) ) -Matchers.tests.cpp:: passed: 0.0001f, WithinAbs( 0.f, 0.001f ) || WithinRel( 0.f, 0.1f ) for: 0.0001f ( is within 0.001 of 0.0 or and 0 are within 10% of each other ) +Matchers.tests.cpp:: passed: 0.0001f, WithinAbs( 0.f, 0.001f ) || WithinRel( 0.f, 0.1f ) for: 0.0001f ( is within 0.00100000004749745 of 0.0 or and 0.0 are within 10% of each other ) Matchers.tests.cpp:: passed: WithinAbs( 1.f, 0.f ) Matchers.tests.cpp:: passed: WithinAbs( 1.f, -1.f ), std::domain_error Matchers.tests.cpp:: passed: WithinULP( 1.f, 0 ) @@ -834,68 +876,122 @@ GeneratorsImpl.tests.cpp:: passed: gen.get() == 5 for: 5 == 5 GeneratorsImpl.tests.cpp:: passed: !(gen.next()) for: !false GeneratorsImpl.tests.cpp:: passed: gen.get() == Approx(expected) for: -1.0 == Approx( -1.0 ) with 1 message: 'Current expected value is -1' GeneratorsImpl.tests.cpp:: passed: gen.next() for: true with 1 message: 'Current expected value is -1' -GeneratorsImpl.tests.cpp:: passed: gen.get() == Approx(expected) for: -0.9 == Approx( -0.9 ) with 1 message: 'Current expected value is -0.9' +GeneratorsImpl.tests.cpp:: passed: gen.get() == Approx(expected) for: -0.90000000000000002 +== +Approx( -0.90000000000000002 ) with 1 message: 'Current expected value is -0.9' GeneratorsImpl.tests.cpp:: passed: gen.next() for: true with 1 message: 'Current expected value is -0.9' -GeneratorsImpl.tests.cpp:: passed: gen.get() == Approx(expected) for: -0.8 == Approx( -0.8 ) with 1 message: 'Current expected value is -0.8' +GeneratorsImpl.tests.cpp:: passed: gen.get() == Approx(expected) for: -0.80000000000000004 +== +Approx( -0.80000000000000004 ) with 1 message: 'Current expected value is -0.8' GeneratorsImpl.tests.cpp:: passed: gen.next() for: true with 1 message: 'Current expected value is -0.8' -GeneratorsImpl.tests.cpp:: passed: gen.get() == Approx(expected) for: -0.7 == Approx( -0.7 ) with 1 message: 'Current expected value is -0.7' +GeneratorsImpl.tests.cpp:: passed: gen.get() == Approx(expected) for: -0.70000000000000007 +== +Approx( -0.70000000000000007 ) with 1 message: 'Current expected value is -0.7' GeneratorsImpl.tests.cpp:: passed: gen.next() for: true with 1 message: 'Current expected value is -0.7' -GeneratorsImpl.tests.cpp:: passed: gen.get() == Approx(expected) for: -0.6 == Approx( -0.6 ) with 1 message: 'Current expected value is -0.6' +GeneratorsImpl.tests.cpp:: passed: gen.get() == Approx(expected) for: -0.60000000000000009 +== +Approx( -0.60000000000000009 ) with 1 message: 'Current expected value is -0.6' GeneratorsImpl.tests.cpp:: passed: gen.next() for: true with 1 message: 'Current expected value is -0.6' -GeneratorsImpl.tests.cpp:: passed: gen.get() == Approx(expected) for: -0.5 == Approx( -0.5 ) with 1 message: 'Current expected value is -0.5' +GeneratorsImpl.tests.cpp:: passed: gen.get() == Approx(expected) for: -0.50000000000000011 +== +Approx( -0.50000000000000011 ) with 1 message: 'Current expected value is -0.5' GeneratorsImpl.tests.cpp:: passed: gen.next() for: true with 1 message: 'Current expected value is -0.5' -GeneratorsImpl.tests.cpp:: passed: gen.get() == Approx(expected) for: -0.4 == Approx( -0.4 ) with 1 message: 'Current expected value is -0.4' +GeneratorsImpl.tests.cpp:: passed: gen.get() == Approx(expected) for: -0.40000000000000013 +== +Approx( -0.40000000000000013 ) with 1 message: 'Current expected value is -0.4' GeneratorsImpl.tests.cpp:: passed: gen.next() for: true with 1 message: 'Current expected value is -0.4' -GeneratorsImpl.tests.cpp:: passed: gen.get() == Approx(expected) for: -0.3 == Approx( -0.3 ) with 1 message: 'Current expected value is -0.3' +GeneratorsImpl.tests.cpp:: passed: gen.get() == Approx(expected) for: -0.30000000000000016 +== +Approx( -0.30000000000000016 ) with 1 message: 'Current expected value is -0.3' GeneratorsImpl.tests.cpp:: passed: gen.next() for: true with 1 message: 'Current expected value is -0.3' -GeneratorsImpl.tests.cpp:: passed: gen.get() == Approx(expected) for: -0.2 == Approx( -0.2 ) with 1 message: 'Current expected value is -0.2' +GeneratorsImpl.tests.cpp:: passed: gen.get() == Approx(expected) for: -0.20000000000000015 +== +Approx( -0.20000000000000015 ) with 1 message: 'Current expected value is -0.2' GeneratorsImpl.tests.cpp:: passed: gen.next() for: true with 1 message: 'Current expected value is -0.2' -GeneratorsImpl.tests.cpp:: passed: gen.get() == Approx(expected) for: -0.1 == Approx( -0.1 ) with 1 message: 'Current expected value is -0.1' +GeneratorsImpl.tests.cpp:: passed: gen.get() == Approx(expected) for: -0.10000000000000014 +== +Approx( -0.10000000000000014 ) with 1 message: 'Current expected value is -0.1' GeneratorsImpl.tests.cpp:: passed: gen.next() for: true with 1 message: 'Current expected value is -0.1' -GeneratorsImpl.tests.cpp:: passed: gen.get() == Approx(expected) for: -0.0 == Approx( -0.0 ) with 1 message: 'Current expected value is -1.38778e-16' +GeneratorsImpl.tests.cpp:: passed: gen.get() == Approx(expected) for: -0.00000000000000014 +== +Approx( -0.00000000000000014 ) with 1 message: 'Current expected value is -1.38778e-16' GeneratorsImpl.tests.cpp:: passed: gen.next() for: true with 1 message: 'Current expected value is -1.38778e-16' -GeneratorsImpl.tests.cpp:: passed: gen.get() == Approx(expected) for: 0.1 == Approx( 0.1 ) with 1 message: 'Current expected value is 0.1' +GeneratorsImpl.tests.cpp:: passed: gen.get() == Approx(expected) for: 0.09999999999999987 +== +Approx( 0.09999999999999987 ) with 1 message: 'Current expected value is 0.1' GeneratorsImpl.tests.cpp:: passed: gen.next() for: true with 1 message: 'Current expected value is 0.1' -GeneratorsImpl.tests.cpp:: passed: gen.get() == Approx(expected) for: 0.2 == Approx( 0.2 ) with 1 message: 'Current expected value is 0.2' +GeneratorsImpl.tests.cpp:: passed: gen.get() == Approx(expected) for: 0.19999999999999987 +== +Approx( 0.19999999999999987 ) with 1 message: 'Current expected value is 0.2' GeneratorsImpl.tests.cpp:: passed: gen.next() for: true with 1 message: 'Current expected value is 0.2' -GeneratorsImpl.tests.cpp:: passed: gen.get() == Approx(expected) for: 0.3 == Approx( 0.3 ) with 1 message: 'Current expected value is 0.3' +GeneratorsImpl.tests.cpp:: passed: gen.get() == Approx(expected) for: 0.29999999999999988 +== +Approx( 0.29999999999999988 ) with 1 message: 'Current expected value is 0.3' GeneratorsImpl.tests.cpp:: passed: gen.next() for: true with 1 message: 'Current expected value is 0.3' -GeneratorsImpl.tests.cpp:: passed: gen.get() == Approx(expected) for: 0.4 == Approx( 0.4 ) with 1 message: 'Current expected value is 0.4' +GeneratorsImpl.tests.cpp:: passed: gen.get() == Approx(expected) for: 0.39999999999999991 +== +Approx( 0.39999999999999991 ) with 1 message: 'Current expected value is 0.4' GeneratorsImpl.tests.cpp:: passed: gen.next() for: true with 1 message: 'Current expected value is 0.4' -GeneratorsImpl.tests.cpp:: passed: gen.get() == Approx(expected) for: 0.5 == Approx( 0.5 ) with 1 message: 'Current expected value is 0.5' +GeneratorsImpl.tests.cpp:: passed: gen.get() == Approx(expected) for: 0.49999999999999989 +== +Approx( 0.49999999999999989 ) with 1 message: 'Current expected value is 0.5' GeneratorsImpl.tests.cpp:: passed: gen.next() for: true with 1 message: 'Current expected value is 0.5' -GeneratorsImpl.tests.cpp:: passed: gen.get() == Approx(expected) for: 0.6 == Approx( 0.6 ) with 1 message: 'Current expected value is 0.6' +GeneratorsImpl.tests.cpp:: passed: gen.get() == Approx(expected) for: 0.59999999999999987 +== +Approx( 0.59999999999999987 ) with 1 message: 'Current expected value is 0.6' GeneratorsImpl.tests.cpp:: passed: gen.next() for: true with 1 message: 'Current expected value is 0.6' -GeneratorsImpl.tests.cpp:: passed: gen.get() == Approx(expected) for: 0.7 == Approx( 0.7 ) with 1 message: 'Current expected value is 0.7' +GeneratorsImpl.tests.cpp:: passed: gen.get() == Approx(expected) for: 0.69999999999999984 +== +Approx( 0.69999999999999984 ) with 1 message: 'Current expected value is 0.7' GeneratorsImpl.tests.cpp:: passed: gen.next() for: true with 1 message: 'Current expected value is 0.7' -GeneratorsImpl.tests.cpp:: passed: gen.get() == Approx(expected) for: 0.8 == Approx( 0.8 ) with 1 message: 'Current expected value is 0.8' +GeneratorsImpl.tests.cpp:: passed: gen.get() == Approx(expected) for: 0.79999999999999982 +== +Approx( 0.79999999999999982 ) with 1 message: 'Current expected value is 0.8' GeneratorsImpl.tests.cpp:: passed: gen.next() for: true with 1 message: 'Current expected value is 0.8' -GeneratorsImpl.tests.cpp:: passed: gen.get() == Approx(expected) for: 0.9 == Approx( 0.9 ) with 1 message: 'Current expected value is 0.9' +GeneratorsImpl.tests.cpp:: passed: gen.get() == Approx(expected) for: 0.8999999999999998 +== +Approx( 0.8999999999999998 ) with 1 message: 'Current expected value is 0.9' GeneratorsImpl.tests.cpp:: passed: gen.next() for: true with 1 message: 'Current expected value is 0.9' -GeneratorsImpl.tests.cpp:: passed: gen.get() == Approx( rangeEnd ) for: 1.0 == Approx( 1.0 ) +GeneratorsImpl.tests.cpp:: passed: gen.get() == Approx( rangeEnd ) for: 0.99999999999999978 == Approx( 1.0 ) GeneratorsImpl.tests.cpp:: passed: !(gen.next()) for: !false GeneratorsImpl.tests.cpp:: passed: gen.get() == Approx(expected) for: -1.0 == Approx( -1.0 ) with 1 message: 'Current expected value is -1' GeneratorsImpl.tests.cpp:: passed: gen.next() for: true with 1 message: 'Current expected value is -1' -GeneratorsImpl.tests.cpp:: passed: gen.get() == Approx(expected) for: -0.7 == Approx( -0.7 ) with 1 message: 'Current expected value is -0.7' +GeneratorsImpl.tests.cpp:: passed: gen.get() == Approx(expected) for: -0.69999999999999996 +== +Approx( -0.69999999999999996 ) with 1 message: 'Current expected value is -0.7' GeneratorsImpl.tests.cpp:: passed: gen.next() for: true with 1 message: 'Current expected value is -0.7' -GeneratorsImpl.tests.cpp:: passed: gen.get() == Approx(expected) for: -0.4 == Approx( -0.4 ) with 1 message: 'Current expected value is -0.4' +GeneratorsImpl.tests.cpp:: passed: gen.get() == Approx(expected) for: -0.39999999999999997 +== +Approx( -0.39999999999999997 ) with 1 message: 'Current expected value is -0.4' GeneratorsImpl.tests.cpp:: passed: gen.next() for: true with 1 message: 'Current expected value is -0.4' -GeneratorsImpl.tests.cpp:: passed: gen.get() == Approx(expected) for: -0.1 == Approx( -0.1 ) with 1 message: 'Current expected value is -0.1' +GeneratorsImpl.tests.cpp:: passed: gen.get() == Approx(expected) for: -0.09999999999999998 +== +Approx( -0.09999999999999998 ) with 1 message: 'Current expected value is -0.1' GeneratorsImpl.tests.cpp:: passed: gen.next() for: true with 1 message: 'Current expected value is -0.1' -GeneratorsImpl.tests.cpp:: passed: gen.get() == Approx(expected) for: 0.2 == Approx( 0.2 ) with 1 message: 'Current expected value is 0.2' +GeneratorsImpl.tests.cpp:: passed: gen.get() == Approx(expected) for: 0.20000000000000001 +== +Approx( 0.20000000000000001 ) with 1 message: 'Current expected value is 0.2' GeneratorsImpl.tests.cpp:: passed: gen.next() for: true with 1 message: 'Current expected value is 0.2' GeneratorsImpl.tests.cpp:: passed: gen.get() == Approx(expected) for: 0.5 == Approx( 0.5 ) with 1 message: 'Current expected value is 0.5' GeneratorsImpl.tests.cpp:: passed: gen.next() for: true with 1 message: 'Current expected value is 0.5' GeneratorsImpl.tests.cpp:: passed: !(gen.next()) for: !false GeneratorsImpl.tests.cpp:: passed: gen.get() == Approx(expected) for: -1.0 == Approx( -1.0 ) with 1 message: 'Current expected value is -1' GeneratorsImpl.tests.cpp:: passed: gen.next() for: true with 1 message: 'Current expected value is -1' -GeneratorsImpl.tests.cpp:: passed: gen.get() == Approx(expected) for: -0.7 == Approx( -0.7 ) with 1 message: 'Current expected value is -0.7' +GeneratorsImpl.tests.cpp:: passed: gen.get() == Approx(expected) for: -0.69999999999999996 +== +Approx( -0.69999999999999996 ) with 1 message: 'Current expected value is -0.7' GeneratorsImpl.tests.cpp:: passed: gen.next() for: true with 1 message: 'Current expected value is -0.7' -GeneratorsImpl.tests.cpp:: passed: gen.get() == Approx(expected) for: -0.4 == Approx( -0.4 ) with 1 message: 'Current expected value is -0.4' +GeneratorsImpl.tests.cpp:: passed: gen.get() == Approx(expected) for: -0.39999999999999997 +== +Approx( -0.39999999999999997 ) with 1 message: 'Current expected value is -0.4' GeneratorsImpl.tests.cpp:: passed: gen.next() for: true with 1 message: 'Current expected value is -0.4' -GeneratorsImpl.tests.cpp:: passed: gen.get() == Approx(expected) for: -0.1 == Approx( -0.1 ) with 1 message: 'Current expected value is -0.1' +GeneratorsImpl.tests.cpp:: passed: gen.get() == Approx(expected) for: -0.09999999999999998 +== +Approx( -0.09999999999999998 ) with 1 message: 'Current expected value is -0.1' GeneratorsImpl.tests.cpp:: passed: gen.next() for: true with 1 message: 'Current expected value is -0.1' -GeneratorsImpl.tests.cpp:: passed: gen.get() == Approx(expected) for: 0.2 == Approx( 0.2 ) with 1 message: 'Current expected value is 0.2' +GeneratorsImpl.tests.cpp:: passed: gen.get() == Approx(expected) for: 0.20000000000000001 +== +Approx( 0.20000000000000001 ) with 1 message: 'Current expected value is 0.2' GeneratorsImpl.tests.cpp:: passed: gen.next() for: true with 1 message: 'Current expected value is 0.2' GeneratorsImpl.tests.cpp:: passed: gen.get() == Approx(expected) for: 0.5 == Approx( 0.5 ) with 1 message: 'Current expected value is 0.5' GeneratorsImpl.tests.cpp:: passed: gen.next() for: true with 1 message: 'Current expected value is 0.5' @@ -926,10 +1022,18 @@ GeneratorsImpl.tests.cpp:: passed: gen.get() == -4 for: -4 == -4 GeneratorsImpl.tests.cpp:: passed: gen.next() for: true GeneratorsImpl.tests.cpp:: passed: gen.get() == -7 for: -7 == -7 GeneratorsImpl.tests.cpp:: passed: !(gen.next()) for: !false -Approx.tests.cpp:: passed: d >= Approx( 1.22 ) for: 1.23 >= Approx( 1.22 ) -Approx.tests.cpp:: passed: d >= Approx( 1.23 ) for: 1.23 >= Approx( 1.23 ) -Approx.tests.cpp:: passed: !(d >= Approx( 1.24 )) for: !(1.23 >= Approx( 1.24 )) -Approx.tests.cpp:: passed: d >= Approx( 1.24 ).epsilon(0.1) for: 1.23 >= Approx( 1.24 ) +Approx.tests.cpp:: passed: d >= Approx( 1.22 ) for: 1.22999999999999998 +>= +Approx( 1.21999999999999997 ) +Approx.tests.cpp:: passed: d >= Approx( 1.23 ) for: 1.22999999999999998 +>= +Approx( 1.22999999999999998 ) +Approx.tests.cpp:: passed: !(d >= Approx( 1.24 )) for: !(1.22999999999999998 +>= +Approx( 1.23999999999999999 )) +Approx.tests.cpp:: passed: d >= Approx( 1.24 ).epsilon(0.1) for: 1.22999999999999998 +>= +Approx( 1.23999999999999999 ) TestCaseInfoHasher.tests.cpp:: passed: h1( dummy ) != h2( dummy ) for: 3422778688 (0x) != 130711275 (0x) @@ -968,17 +1072,25 @@ Message.tests.cpp:: passed: i < 10 for: 9 < 10 with 2 messages: 'cu Message.tests.cpp:: failed: i < 10 for: 10 < 10 with 2 messages: 'current counter 10' and 'i := 10' AssertionHandler.tests.cpp:: failed: unexpected exception with message: 'Exception translation was disabled by CATCH_CONFIG_FAST_COMPILE'; expression was: Dummy Condition.tests.cpp:: failed: data.int_seven != 7 for: 7 != 7 -Condition.tests.cpp:: failed: data.float_nine_point_one != Approx( 9.1f ) for: 9.1f != Approx( 9.1000003815 ) -Condition.tests.cpp:: failed: data.double_pi != Approx( 3.1415926535 ) for: 3.1415926535 != Approx( 3.1415926535 ) +Condition.tests.cpp:: failed: data.float_nine_point_one != Approx( 9.1f ) for: 9.100000381f +!= +Approx( 9.10000038146972656 ) +Condition.tests.cpp:: failed: data.double_pi != Approx( 3.1415926535 ) for: 3.14159265350000005 +!= +Approx( 3.14159265350000005 ) Condition.tests.cpp:: failed: data.str_hello != "hello" for: "hello" != "hello" Condition.tests.cpp:: failed: data.str_hello.size() != 5 for: 5 != 5 Condition.tests.cpp:: passed: data.int_seven != 6 for: 7 != 6 Condition.tests.cpp:: passed: data.int_seven != 8 for: 7 != 8 -Condition.tests.cpp:: passed: data.float_nine_point_one != Approx( 9.11f ) for: 9.1f != Approx( 9.1099996567 ) -Condition.tests.cpp:: passed: data.float_nine_point_one != Approx( 9.0f ) for: 9.1f != Approx( 9.0 ) -Condition.tests.cpp:: passed: data.float_nine_point_one != Approx( 1 ) for: 9.1f != Approx( 1.0 ) -Condition.tests.cpp:: passed: data.float_nine_point_one != Approx( 0 ) for: 9.1f != Approx( 0.0 ) -Condition.tests.cpp:: passed: data.double_pi != Approx( 3.1415 ) for: 3.1415926535 != Approx( 3.1415 ) +Condition.tests.cpp:: passed: data.float_nine_point_one != Approx( 9.11f ) for: 9.100000381f +!= +Approx( 9.10999965667724609 ) +Condition.tests.cpp:: passed: data.float_nine_point_one != Approx( 9.0f ) for: 9.100000381f != Approx( 9.0 ) +Condition.tests.cpp:: passed: data.float_nine_point_one != Approx( 1 ) for: 9.100000381f != Approx( 1.0 ) +Condition.tests.cpp:: passed: data.float_nine_point_one != Approx( 0 ) for: 9.100000381f != Approx( 0.0 ) +Condition.tests.cpp:: passed: data.double_pi != Approx( 3.1415 ) for: 3.14159265350000005 +!= +Approx( 3.14150000000000018 ) Condition.tests.cpp:: passed: data.str_hello != "goodbye" for: "hello" != "goodbye" Condition.tests.cpp:: passed: data.str_hello != "hell" for: "hello" != "hell" Condition.tests.cpp:: passed: data.str_hello != "hello1" for: "hello" != "hello1" @@ -1069,10 +1181,18 @@ Json.tests.cpp:: passed: sstream.str() == "\"\\r\"" for: ""\r"" == Json.tests.cpp:: passed: sstream.str() == "\"\\t\"" for: ""\t"" == ""\t"" Json.tests.cpp:: passed: sstream.str() == "\"\\\\/\\t\\r\\n\"" for: ""\\/\t\r\n"" == ""\\/\t\r\n"" Compilation.tests.cpp:: passed: []() { return true; }() for: true -Approx.tests.cpp:: passed: d <= Approx( 1.24 ) for: 1.23 <= Approx( 1.24 ) -Approx.tests.cpp:: passed: d <= Approx( 1.23 ) for: 1.23 <= Approx( 1.23 ) -Approx.tests.cpp:: passed: !(d <= Approx( 1.22 )) for: !(1.23 <= Approx( 1.22 )) -Approx.tests.cpp:: passed: d <= Approx( 1.22 ).epsilon(0.1) for: 1.23 <= Approx( 1.22 ) +Approx.tests.cpp:: passed: d <= Approx( 1.24 ) for: 1.22999999999999998 +<= +Approx( 1.23999999999999999 ) +Approx.tests.cpp:: passed: d <= Approx( 1.23 ) for: 1.22999999999999998 +<= +Approx( 1.22999999999999998 ) +Approx.tests.cpp:: passed: !(d <= Approx( 1.22 )) for: !(1.22999999999999998 +<= +Approx( 1.21999999999999997 )) +Approx.tests.cpp:: passed: d <= Approx( 1.22 ).epsilon(0.1) for: 1.22999999999999998 +<= +Approx( 1.21999999999999997 ) Misc.tests.cpp:: passed: with 1 message: 'was called' Matchers.tests.cpp:: passed: testStringForMatching(), ContainsSubstring( "string" ) && ContainsSubstring( "abc" ) && ContainsSubstring( "substring" ) && ContainsSubstring( "contains" ) for: "this string contains 'abc' as a substring" ( contains: "string" and contains: "abc" and contains: "substring" and contains: "contains" ) Matchers.tests.cpp:: passed: testStringForMatching(), ContainsSubstring( "string" ) || ContainsSubstring( "different" ) || ContainsSubstring( "random" ) for: "this string contains 'abc' as a substring" ( contains: "string" or contains: "different" or contains: "random" ) @@ -1139,9 +1259,9 @@ Condition.tests.cpp:: failed: data.int_seven < 0 for: 7 < 0 Condition.tests.cpp:: failed: data.int_seven < -1 for: 7 < -1 Condition.tests.cpp:: failed: data.int_seven >= 8 for: 7 >= 8 Condition.tests.cpp:: failed: data.int_seven <= 6 for: 7 <= 6 -Condition.tests.cpp:: failed: data.float_nine_point_one < 9 for: 9.1f < 9 -Condition.tests.cpp:: failed: data.float_nine_point_one > 10 for: 9.1f > 10 -Condition.tests.cpp:: failed: data.float_nine_point_one > 9.2 for: 9.1f > 9.2 +Condition.tests.cpp:: failed: data.float_nine_point_one < 9 for: 9.100000381f < 9 +Condition.tests.cpp:: failed: data.float_nine_point_one > 10 for: 9.100000381f > 10 +Condition.tests.cpp:: failed: data.float_nine_point_one > 9.2 for: 9.100000381f > 9.19999999999999929 Condition.tests.cpp:: failed: data.str_hello > "hello" for: "hello" > "hello" Condition.tests.cpp:: failed: data.str_hello < "hello" for: "hello" < "hello" Condition.tests.cpp:: failed: data.str_hello > "hellp" for: "hello" > "hellp" @@ -1158,9 +1278,9 @@ Condition.tests.cpp:: passed: data.int_seven >= 7 for: 7 >= 7 Condition.tests.cpp:: passed: data.int_seven >= 6 for: 7 >= 6 Condition.tests.cpp:: passed: data.int_seven <= 7 for: 7 <= 7 Condition.tests.cpp:: passed: data.int_seven <= 8 for: 7 <= 8 -Condition.tests.cpp:: passed: data.float_nine_point_one > 9 for: 9.1f > 9 -Condition.tests.cpp:: passed: data.float_nine_point_one < 10 for: 9.1f < 10 -Condition.tests.cpp:: passed: data.float_nine_point_one < 9.2 for: 9.1f < 9.2 +Condition.tests.cpp:: passed: data.float_nine_point_one > 9 for: 9.100000381f > 9 +Condition.tests.cpp:: passed: data.float_nine_point_one < 10 for: 9.100000381f < 10 +Condition.tests.cpp:: passed: data.float_nine_point_one < 9.2 for: 9.100000381f < 9.19999999999999929 Condition.tests.cpp:: passed: data.str_hello <= "hello" for: "hello" <= "hello" Condition.tests.cpp:: passed: data.str_hello >= "hello" for: "hello" >= "hello" Condition.tests.cpp:: passed: data.str_hello < "hellp" for: "hello" < "hellp" @@ -1358,7 +1478,9 @@ CmdLine.tests.cpp:: passed: config.benchmarkSamples == 200 for: 200 CmdLine.tests.cpp:: passed: cli.parse({ "test", "--benchmark-resamples=20000" }) for: {?} CmdLine.tests.cpp:: passed: config.benchmarkResamples == 20000 for: 20000 (0x) == 20000 (0x) CmdLine.tests.cpp:: passed: cli.parse({ "test", "--benchmark-confidence-interval=0.99" }) for: {?} -CmdLine.tests.cpp:: passed: config.benchmarkConfidenceInterval == Catch::Approx(0.99) for: 0.99 == Approx( 0.99 ) +CmdLine.tests.cpp:: passed: config.benchmarkConfidenceInterval == Catch::Approx(0.99) for: 0.98999999999999999 +== +Approx( 0.98999999999999999 ) CmdLine.tests.cpp:: passed: cli.parse({ "test", "--benchmark-no-analysis" }) for: {?} CmdLine.tests.cpp:: passed: config.benchmarkNoAnalysis for: true CmdLine.tests.cpp:: passed: cli.parse({ "test", "--benchmark-warmup-time=10" }) for: {?} @@ -1613,14 +1735,30 @@ BDD.tests.cpp:: passed: v.size() == 0 for: 0 == 0 A string sent directly to stdout A string sent directly to stderr A string sent to stderr via clog -Approx.tests.cpp:: passed: d == Approx( 1.23 ) for: 1.23 == Approx( 1.23 ) -Approx.tests.cpp:: passed: d != Approx( 1.22 ) for: 1.23 != Approx( 1.22 ) -Approx.tests.cpp:: passed: d != Approx( 1.24 ) for: 1.23 != Approx( 1.24 ) -Approx.tests.cpp:: passed: d == 1.23_a for: 1.23 == Approx( 1.23 ) -Approx.tests.cpp:: passed: d != 1.22_a for: 1.23 != Approx( 1.22 ) -Approx.tests.cpp:: passed: Approx( d ) == 1.23 for: Approx( 1.23 ) == 1.23 -Approx.tests.cpp:: passed: Approx( d ) != 1.22 for: Approx( 1.23 ) != 1.22 -Approx.tests.cpp:: passed: Approx( d ) != 1.24 for: Approx( 1.23 ) != 1.24 +Approx.tests.cpp:: passed: d == Approx( 1.23 ) for: 1.22999999999999998 +== +Approx( 1.22999999999999998 ) +Approx.tests.cpp:: passed: d != Approx( 1.22 ) for: 1.22999999999999998 +!= +Approx( 1.21999999999999997 ) +Approx.tests.cpp:: passed: d != Approx( 1.24 ) for: 1.22999999999999998 +!= +Approx( 1.23999999999999999 ) +Approx.tests.cpp:: passed: d == 1.23_a for: 1.22999999999999998 +== +Approx( 1.22999999999999998 ) +Approx.tests.cpp:: passed: d != 1.22_a for: 1.22999999999999998 +!= +Approx( 1.21999999999999997 ) +Approx.tests.cpp:: passed: Approx( d ) == 1.23 for: Approx( 1.22999999999999998 ) +== +1.22999999999999998 +Approx.tests.cpp:: passed: Approx( d ) != 1.22 for: Approx( 1.22999999999999998 ) +!= +1.21999999999999997 +Approx.tests.cpp:: passed: Approx( d ) != 1.24 for: Approx( 1.22999999999999998 ) +!= +1.23999999999999999 Message from section one Message from section two Matchers.tests.cpp:: failed: testStringForMatching(), StartsWith( "This String" ) for: "this string contains 'abc' as a substring" starts with: "This String" @@ -1737,13 +1875,13 @@ Tag.tests.cpp:: passed: testCase.tags, VectorContains( Tag( "tag wi Class.tests.cpp:: passed: Template_Fixture::m_a == 1 for: 1 == 1 Class.tests.cpp:: passed: Template_Fixture::m_a == 1 for: 1 == 1 Class.tests.cpp:: passed: Template_Fixture::m_a == 1 for: 1.0 == 1 -Misc.tests.cpp:: passed: sizeof(TestType) > 0 for: 1 > 0 -Misc.tests.cpp:: passed: sizeof(TestType) > 0 for: 4 > 0 -Misc.tests.cpp:: passed: sizeof(TestType) > 0 for: 1 > 0 -Misc.tests.cpp:: passed: sizeof(TestType) > 0 for: 4 > 0 -Misc.tests.cpp:: passed: sizeof(TestType) > 0 for: 4 > 0 -Misc.tests.cpp:: passed: sizeof(TestType) > 0 for: 1 > 0 -Misc.tests.cpp:: passed: sizeof(TestType) > 0 for: 4 > 0 +Misc.tests.cpp:: passed: std::is_default_constructible::value for: true +Misc.tests.cpp:: passed: std::is_default_constructible::value for: true +Misc.tests.cpp:: passed: std::is_trivially_copyable::value for: true +Misc.tests.cpp:: passed: std::is_trivially_copyable::value for: true +Misc.tests.cpp:: passed: std::is_arithmetic::value for: true +Misc.tests.cpp:: passed: std::is_arithmetic::value for: true +Misc.tests.cpp:: passed: std::is_arithmetic::value for: true Misc.tests.cpp:: passed: v.size() == 5 for: 5 == 5 Misc.tests.cpp:: passed: v.capacity() >= 5 for: 5 >= 5 Misc.tests.cpp:: passed: v.size() == 10 for: 10 == 10 @@ -2029,7 +2167,7 @@ MatchersRanges.tests.cpp:: passed: a, !RangeEquals( b ) for: { 1, 2 MatchersRanges.tests.cpp:: passed: a, UnorderedRangeEquals( b ) for: { 1, 2, 3 } unordered elements are { 3, 2, 1 } MatchersRanges.tests.cpp:: passed: vector_a, RangeEquals( array_a_plus_1, close_enough ) for: { 1, 2, 3 } elements are { 2, 3, 4 } MatchersRanges.tests.cpp:: passed: vector_a, UnorderedRangeEquals( array_a_plus_1, close_enough ) for: { 1, 2, 3 } unordered elements are { 2, 3, 4 } -Exception.tests.cpp:: failed: unexpected exception with message: '3.14' +Exception.tests.cpp:: failed: unexpected exception with message: '3.14000000000000012' UniquePtr.tests.cpp:: passed: bptr->i == 3 for: 3 == 3 UniquePtr.tests.cpp:: passed: bptr->i == 3 for: 3 == 3 MatchersRanges.tests.cpp:: passed: data, AllMatch(SizeIs(5)) for: { { 0, 1, 2, 3, 5 }, { 4, -3, -2, 5, 0 }, { 0, 0, 0, 5, 0 }, { 0, -5, 0, 5, 0 }, { 1, 0, 0, -1, 5 } } all match has size == 5 @@ -2175,14 +2313,26 @@ MatchersRanges.tests.cpp:: passed: arr, !SizeIs(!Lt(3)) for: { 0, 0 MatchersRanges.tests.cpp:: passed: map, SizeIs(3) for: { {?}, {?}, {?} } has size == 3 MatchersRanges.tests.cpp:: passed: unrelated::ADL_size{}, SizeIs(12) for: {?} has size == 12 MatchersRanges.tests.cpp:: passed: has_size{}, SizeIs(13) for: {?} has size == 13 -Approx.tests.cpp:: passed: d == approx( 1.23 ) for: 1.23 == Approx( 1.23 ) -Approx.tests.cpp:: passed: d == approx( 1.22 ) for: 1.23 == Approx( 1.22 ) -Approx.tests.cpp:: passed: d == approx( 1.24 ) for: 1.23 == Approx( 1.24 ) -Approx.tests.cpp:: passed: d != approx( 1.25 ) for: 1.23 != Approx( 1.25 ) -Approx.tests.cpp:: passed: approx( d ) == 1.23 for: Approx( 1.23 ) == 1.23 -Approx.tests.cpp:: passed: approx( d ) == 1.22 for: Approx( 1.23 ) == 1.22 -Approx.tests.cpp:: passed: approx( d ) == 1.24 for: Approx( 1.23 ) == 1.24 -Approx.tests.cpp:: passed: approx( d ) != 1.25 for: Approx( 1.23 ) != 1.25 +Approx.tests.cpp:: passed: d == approx( 1.23 ) for: 1.22999999999999998 +== +Approx( 1.22999999999999998 ) +Approx.tests.cpp:: passed: d == approx( 1.22 ) for: 1.22999999999999998 +== +Approx( 1.21999999999999997 ) +Approx.tests.cpp:: passed: d == approx( 1.24 ) for: 1.22999999999999998 +== +Approx( 1.23999999999999999 ) +Approx.tests.cpp:: passed: d != approx( 1.25 ) for: 1.22999999999999998 != Approx( 1.25 ) +Approx.tests.cpp:: passed: approx( d ) == 1.23 for: Approx( 1.22999999999999998 ) +== +1.22999999999999998 +Approx.tests.cpp:: passed: approx( d ) == 1.22 for: Approx( 1.22999999999999998 ) +== +1.21999999999999997 +Approx.tests.cpp:: passed: approx( d ) == 1.24 for: Approx( 1.22999999999999998 ) +== +1.23999999999999999 +Approx.tests.cpp:: passed: approx( d ) != 1.25 for: Approx( 1.22999999999999998 ) != 1.25 VariadicMacros.tests.cpp:: passed: with 1 message: 'no assertions' Matchers.tests.cpp:: passed: empty, Approx( empty ) for: { } is approx: { } Matchers.tests.cpp:: passed: v1, Approx( v1 ) for: { 1.0, 2.0, 3.0 } is approx: { 1.0, 2.0, 3.0 } @@ -2357,9 +2507,15 @@ Skip.tests.cpp:: skipped: 'skipping because answer = 41' Skip.tests.cpp:: passed: Skip.tests.cpp:: skipped: 'skipping because answer = 43' Tag.tests.cpp:: passed: Catch::TestCaseInfo("", { "test with an empty tag", "[]" }, dummySourceLineInfo) -InternalBenchmark.tests.cpp:: passed: erfc_inv(1.103560) == Approx(-0.09203687623843015) for: -0.0920368762 == Approx( -0.0920368762 ) -InternalBenchmark.tests.cpp:: passed: erfc_inv(1.067400) == Approx(-0.05980291115763361) for: -0.0598029112 == Approx( -0.0598029112 ) -InternalBenchmark.tests.cpp:: passed: erfc_inv(0.050000) == Approx(1.38590382434967796) for: 1.3859038243 == Approx( 1.3859038243 ) +InternalBenchmark.tests.cpp:: passed: erfc_inv(1.103560) == Approx(-0.09203687623843015) for: -0.09203687623843014 +== +Approx( -0.09203687623843015 ) +InternalBenchmark.tests.cpp:: passed: erfc_inv(1.067400) == Approx(-0.05980291115763361) for: -0.05980291115763361 +== +Approx( -0.05980291115763361 ) +InternalBenchmark.tests.cpp:: passed: erfc_inv(0.050000) == Approx(1.38590382434967796) for: 1.38590382434967774 +== +Approx( 1.38590382434967796 ) InternalBenchmark.tests.cpp:: passed: res.mean.count() == rate for: 2000.0 == 2000 (0x) InternalBenchmark.tests.cpp:: passed: res.outliers.total() == 0 for: 0 == 0 Misc.tests.cpp:: passed: @@ -2436,14 +2592,15 @@ Skip.tests.cpp:: skipped: ! Tricky.tests.cpp:: passed: s == "7" for: "7" == "7" Tricky.tests.cpp:: passed: ti == typeid(int) for: {?} == {?} -InternalBenchmark.tests.cpp:: passed: normal_cdf(0.000000) == Approx(0.50000000000000000) for: 0.5 == Approx( 0.5 ) -InternalBenchmark.tests.cpp:: passed: normal_cdf(1.000000) == Approx(0.84134474606854293) for: 0.8413447461 == Approx( 0.8413447461 ) -InternalBenchmark.tests.cpp:: passed: normal_cdf(-1.000000) == Approx(0.15865525393145705) for: 0.1586552539 == Approx( 0.1586552539 ) -InternalBenchmark.tests.cpp:: passed: normal_cdf(2.809729) == Approx(0.99752083845315409) for: 0.9975208385 == Approx( 0.9975208385 ) -InternalBenchmark.tests.cpp:: passed: normal_cdf(-1.352570) == Approx(0.08809652095066035) for: 0.088096521 == Approx( 0.088096521 ) -InternalBenchmark.tests.cpp:: passed: normal_quantile(0.551780) == Approx(0.13015979861484198) for: 0.1301597986 == Approx( 0.1301597986 ) -InternalBenchmark.tests.cpp:: passed: normal_quantile(0.533700) == Approx(0.08457408802851875) for: 0.084574088 == Approx( 0.084574088 ) -InternalBenchmark.tests.cpp:: passed: normal_quantile(0.025000) == Approx(-1.95996398454005449) for: -1.9599639845 == Approx( -1.9599639845 ) +InternalBenchmark.tests.cpp:: passed: normal_quantile(0.551780) == Approx(0.13015979861484198) for: 0.13015979861484195 +== +Approx( 0.13015979861484198 ) +InternalBenchmark.tests.cpp:: passed: normal_quantile(0.533700) == Approx(0.08457408802851875) for: 0.08457408802851875 +== +Approx( 0.08457408802851875 ) +InternalBenchmark.tests.cpp:: passed: normal_quantile(0.025000) == Approx(-1.95996398454005449) for: -1.95996398454005405 +== +Approx( -1.95996398454005449 ) Misc.tests.cpp:: passed: Message.tests.cpp:: passed: true with 1 message: 'this MAY be seen only for the FIRST assertion IF info is printed for passing assertions' Message.tests.cpp:: passed: true with 1 message: 'this MAY be seen only for the SECOND assertion IF info is printed for passing assertions' @@ -2483,6 +2640,10 @@ StringManip.tests.cpp:: passed: Catch::replaceInPlace(letters, lett StringManip.tests.cpp:: passed: letters == "replaced" for: "replaced" == "replaced" StringManip.tests.cpp:: passed: !(Catch::replaceInPlace(letters, "x", "z")) for: !false StringManip.tests.cpp:: passed: letters == letters for: "abcdefcg" == "abcdefcg" +StringManip.tests.cpp:: passed: Catch::replaceInPlace(letters, "c", "cc") for: true +StringManip.tests.cpp:: passed: letters == "abccdefccg" for: "abccdefccg" == "abccdefccg" +StringManip.tests.cpp:: passed: Catch::replaceInPlace(s, "--", "-") for: true +StringManip.tests.cpp:: passed: s == "--" for: "--" == "--" StringManip.tests.cpp:: passed: Catch::replaceInPlace(s, "'", "|'") for: true StringManip.tests.cpp:: passed: s == "didn|'t" for: "didn|'t" == "didn|'t" Stream.tests.cpp:: passed: Catch::makeStream( "%somestream" ) @@ -2609,19 +2770,19 @@ EnumToString.tests.cpp:: passed: ::Catch::Detail::stringify(e0) == EnumToString.tests.cpp:: passed: ::Catch::Detail::stringify(e1) == "1" for: "1" == "1" ToStringTuple.tests.cpp:: passed: "{ }" == ::Catch::Detail::stringify(type{}) for: "{ }" == "{ }" ToStringTuple.tests.cpp:: passed: "{ }" == ::Catch::Detail::stringify(value) for: "{ }" == "{ }" -ToStringTuple.tests.cpp:: passed: "1.2f" == ::Catch::Detail::stringify(float(1.2)) for: "1.2f" == "1.2f" -ToStringTuple.tests.cpp:: passed: "{ 1.2f, 0 }" == ::Catch::Detail::stringify(type{1.2f,0}) for: "{ 1.2f, 0 }" == "{ 1.2f, 0 }" +ToStringTuple.tests.cpp:: passed: "1.5f" == ::Catch::Detail::stringify(float(1.5)) for: "1.5f" == "1.5f" +ToStringTuple.tests.cpp:: passed: "{ 1.5f, 0 }" == ::Catch::Detail::stringify(type{1.5f,0}) for: "{ 1.5f, 0 }" == "{ 1.5f, 0 }" ToStringTuple.tests.cpp:: passed: "{ 0 }" == ::Catch::Detail::stringify(type{0}) for: "{ 0 }" == "{ 0 }" ToStringTuple.tests.cpp:: passed: "{ \"hello\", \"world\" }" == ::Catch::Detail::stringify(type{"hello","world"}) for: "{ "hello", "world" }" == "{ "hello", "world" }" -ToStringTuple.tests.cpp:: passed: "{ { 42 }, { }, 1.2f }" == ::Catch::Detail::stringify(value) for: "{ { 42 }, { }, 1.2f }" +ToStringTuple.tests.cpp:: passed: "{ { 42 }, { }, 1.5f }" == ::Catch::Detail::stringify(value) for: "{ { 42 }, { }, 1.5f }" == -"{ { 42 }, { }, 1.2f }" +"{ { 42 }, { }, 1.5f }" InternalBenchmark.tests.cpp:: passed: e.point == 23 for: 23.0 == 23 InternalBenchmark.tests.cpp:: passed: e.upper_bound == 23 for: 23.0 == 23 InternalBenchmark.tests.cpp:: passed: e.lower_bound == 23 for: 23.0 == 23 -InternalBenchmark.tests.cpp:: passed: e.confidence_interval == 0.95 for: 0.95 == 0.95 +InternalBenchmark.tests.cpp:: passed: e.confidence_interval == 0.95 for: 0.94999999999999996 == 0.94999999999999996 RandomNumberGeneration.tests.cpp:: passed: dist.a() == -10 for: -10 == -10 RandomNumberGeneration.tests.cpp:: passed: dist.b() == 10 for: 10 == 10 UniquePtr.tests.cpp:: passed: !(ptr) for: !{?} @@ -2689,7 +2850,7 @@ InternalBenchmark.tests.cpp:: passed: med == 18. for: 18.0 == 18.0 InternalBenchmark.tests.cpp:: passed: q3 == 23. for: 23.0 == 23.0 Misc.tests.cpp:: passed: Misc.tests.cpp:: passed: -test cases: 417 | 312 passed | 85 failed | 6 skipped | 14 failed as expected -assertions: 2260 | 2079 passed | 146 failed | 35 failed as expected +test cases: 419 | 313 passed | 86 failed | 6 skipped | 14 failed as expected +assertions: 2265 | 2083 passed | 147 failed | 35 failed as expected diff --git a/tests/SelfTest/Baselines/compact.sw.multi.approved.txt b/tests/SelfTest/Baselines/compact.sw.multi.approved.txt index 214fef74b8..77812a62a6 100644 --- a/tests/SelfTest/Baselines/compact.sw.multi.approved.txt +++ b/tests/SelfTest/Baselines/compact.sw.multi.approved.txt @@ -239,6 +239,10 @@ Class.tests.cpp:: passed: Nttp_Fixture::value > 0 for: 3 > 0 Class.tests.cpp:: passed: Nttp_Fixture::value > 0 for: 6 > 0 Class.tests.cpp:: failed: m_a == 2 for: 1 == 2 Class.tests.cpp:: passed: m_a == 1 for: 1 == 1 +Class.tests.cpp:: passed: m_a++ == 0 for: 0 == 0 +Class.tests.cpp:: failed: m_a == 0 for: 1 == 0 +Class.tests.cpp:: passed: m_a++ == 0 for: 0 == 0 +Class.tests.cpp:: passed: m_a == 1 for: 1 == 1 Misc.tests.cpp:: passed: x.size() == 0 for: 0 == 0 Misc.tests.cpp:: passed: x.size() == 0 for: 0 == 0 Misc.tests.cpp:: passed: x.size() == 0 for: 0 == 0 @@ -247,12 +251,22 @@ Misc.tests.cpp:: passed: x.size() > 0 for: 42 > 0 Misc.tests.cpp:: passed: x.size() > 0 for: 9 > 0 Misc.tests.cpp:: passed: x.size() > 0 for: 42 > 0 Misc.tests.cpp:: passed: x.size() > 0 for: 9 > 0 -Approx.tests.cpp:: passed: d == 1.23_a for: 1.23 == Approx( 1.23 ) -Approx.tests.cpp:: passed: d != 1.22_a for: 1.23 != Approx( 1.22 ) -Approx.tests.cpp:: passed: -d == -1.23_a for: -1.23 == Approx( -1.23 ) -Approx.tests.cpp:: passed: d == 1.2_a .epsilon(.1) for: 1.23 == Approx( 1.2 ) -Approx.tests.cpp:: passed: d != 1.2_a .epsilon(.001) for: 1.23 != Approx( 1.2 ) -Approx.tests.cpp:: passed: d == 1_a .epsilon(.3) for: 1.23 == Approx( 1.0 ) +Approx.tests.cpp:: passed: d == 1.23_a for: 1.22999999999999998 +== +Approx( 1.22999999999999998 ) +Approx.tests.cpp:: passed: d != 1.22_a for: 1.22999999999999998 +!= +Approx( 1.21999999999999997 ) +Approx.tests.cpp:: passed: -d == -1.23_a for: -1.22999999999999998 +== +Approx( -1.22999999999999998 ) +Approx.tests.cpp:: passed: d == 1.2_a .epsilon(.1) for: 1.22999999999999998 +== +Approx( 1.19999999999999996 ) +Approx.tests.cpp:: passed: d != 1.2_a .epsilon(.001) for: 1.22999999999999998 +!= +Approx( 1.19999999999999996 ) +Approx.tests.cpp:: passed: d == 1_a .epsilon(.3) for: 1.22999999999999998 == Approx( 1.0 ) Misc.tests.cpp:: passed: with 1 message: 'that's not flying - that's failing in style' Misc.tests.cpp:: failed: explicitly with 1 message: 'to infinity and beyond' Tricky.tests.cpp:: failed: &o1 == &o2 for: 0x == 0x @@ -261,8 +275,8 @@ Approx.tests.cpp:: passed: 104.0 != Approx(100.0) for: 104.0 != App Approx.tests.cpp:: passed: 104.0 == Approx(100.0).margin(5) for: 104.0 == Approx( 100.0 ) Approx.tests.cpp:: passed: 104.0 == Approx(100.0).margin(4) for: 104.0 == Approx( 100.0 ) Approx.tests.cpp:: passed: 104.0 != Approx(100.0).margin(3) for: 104.0 != Approx( 100.0 ) -Approx.tests.cpp:: passed: 100.3 != Approx(100.0) for: 100.3 != Approx( 100.0 ) -Approx.tests.cpp:: passed: 100.3 == Approx(100.0).margin(0.5) for: 100.3 == Approx( 100.0 ) +Approx.tests.cpp:: passed: 100.3 != Approx(100.0) for: 100.29999999999999716 != Approx( 100.0 ) +Approx.tests.cpp:: passed: 100.3 == Approx(100.0).margin(0.5) for: 100.29999999999999716 == Approx( 100.0 ) Tricky.tests.cpp:: passed: i++ == 7 for: 7 == 7 Tricky.tests.cpp:: passed: i++ == 8 for: 8 == 8 Exception.tests.cpp:: passed: 1 == 1 @@ -280,19 +294,33 @@ Approx.tests.cpp:: passed: 0.0f == Approx(0.25f).margin(0.25f) for: Approx.tests.cpp:: passed: 0.5f == Approx(0.25f).margin(0.25f) for: 0.5f == Approx( 0.25 ) Approx.tests.cpp:: passed: 245.0f == Approx(245.25f).margin(0.25f) for: 245.0f == Approx( 245.25 ) Approx.tests.cpp:: passed: 245.5f == Approx(245.25f).margin(0.25f) for: 245.5f == Approx( 245.25 ) -Approx.tests.cpp:: passed: divide( 22, 7 ) == Approx( 3.141 ).epsilon( 0.001 ) for: 3.1428571429 == Approx( 3.141 ) -Approx.tests.cpp:: passed: divide( 22, 7 ) != Approx( 3.141 ).epsilon( 0.0001 ) for: 3.1428571429 != Approx( 3.141 ) -Approx.tests.cpp:: passed: d != Approx( 1.231 ) for: 1.23 != Approx( 1.231 ) -Approx.tests.cpp:: passed: d == Approx( 1.231 ).epsilon( 0.1 ) for: 1.23 == Approx( 1.231 ) -Approx.tests.cpp:: passed: 1.23f == Approx( 1.23f ) for: 1.23f == Approx( 1.2300000191 ) +Approx.tests.cpp:: passed: divide( 22, 7 ) == Approx( 3.141 ).epsilon( 0.001 ) for: 3.14285714285714279 +== +Approx( 3.14100000000000001 ) +Approx.tests.cpp:: passed: divide( 22, 7 ) != Approx( 3.141 ).epsilon( 0.0001 ) for: 3.14285714285714279 +!= +Approx( 3.14100000000000001 ) +Approx.tests.cpp:: passed: d != Approx( 1.231 ) for: 1.22999999999999998 +!= +Approx( 1.23100000000000009 ) +Approx.tests.cpp:: passed: d == Approx( 1.231 ).epsilon( 0.1 ) for: 1.22999999999999998 +== +Approx( 1.23100000000000009 ) +Approx.tests.cpp:: passed: 1.23f == Approx( 1.23f ) for: 1.230000019f +== +Approx( 1.23000001907348633 ) Approx.tests.cpp:: passed: 0.0f == Approx( 0.0f ) for: 0.0f == Approx( 0.0 ) Approx.tests.cpp:: passed: 1 == Approx( 1 ) for: 1 == Approx( 1.0 ) Approx.tests.cpp:: passed: 0 == Approx( 0 ) for: 0 == Approx( 0.0 ) Approx.tests.cpp:: passed: 1.0f == Approx( 1 ) for: 1.0f == Approx( 1.0 ) Approx.tests.cpp:: passed: 0 == Approx( dZero) for: 0 == Approx( 0.0 ) Approx.tests.cpp:: passed: 0 == Approx( dSmall ).margin( 0.001 ) for: 0 == Approx( 0.00001 ) -Approx.tests.cpp:: passed: 1.234f == Approx( dMedium ) for: 1.234f == Approx( 1.234 ) -Approx.tests.cpp:: passed: dMedium == Approx( 1.234f ) for: 1.234 == Approx( 1.2339999676 ) +Approx.tests.cpp:: passed: 1.234f == Approx( dMedium ) for: 1.233999968f +== +Approx( 1.23399999999999999 ) +Approx.tests.cpp:: passed: dMedium == Approx( 1.234f ) for: 1.23399999999999999 +== +Approx( 1.23399996757507324 ) Matchers.tests.cpp:: passed: 1, Predicate( alwaysTrue, "always true" ) for: 1 matches predicate: "always true" Matchers.tests.cpp:: passed: 1, !Predicate( alwaysFalse, "always false" ) for: 1 not matches predicate: "always false" Matchers.tests.cpp:: passed: "Hello olleH", Predicate( []( std::string const& str ) -> bool { return str.front() == str.back(); }, "First and last character should be equal" ) for: "Hello olleH" matches predicate: "First and last character should be equal" @@ -348,20 +376,22 @@ Details.tests.cpp:: passed: lt( "a", "b" ) for: true Details.tests.cpp:: passed: lt( "a", "B" ) for: true Details.tests.cpp:: passed: lt( "A", "b" ) for: true Details.tests.cpp:: passed: lt( "A", "B" ) for: true -ToStringGeneral.tests.cpp:: passed: tab == '\t' for: '\t' == '\t' -ToStringGeneral.tests.cpp:: passed: newline == '\n' for: '\n' == '\n' -ToStringGeneral.tests.cpp:: passed: carr_return == '\r' for: '\r' == '\r' -ToStringGeneral.tests.cpp:: passed: form_feed == '\f' for: '\f' == '\f' -ToStringGeneral.tests.cpp:: passed: space == ' ' for: ' ' == ' ' -ToStringGeneral.tests.cpp:: passed: c == chars[i] for: 'a' == 'a' -ToStringGeneral.tests.cpp:: passed: c == chars[i] for: 'z' == 'z' -ToStringGeneral.tests.cpp:: passed: c == chars[i] for: 'A' == 'A' -ToStringGeneral.tests.cpp:: passed: c == chars[i] for: 'Z' == 'Z' -ToStringGeneral.tests.cpp:: passed: null_terminator == '\0' for: 0 == 0 -ToStringGeneral.tests.cpp:: passed: c == i for: 2 == 2 -ToStringGeneral.tests.cpp:: passed: c == i for: 3 == 3 -ToStringGeneral.tests.cpp:: passed: c == i for: 4 == 4 -ToStringGeneral.tests.cpp:: passed: c == i for: 5 == 5 +ToStringGeneral.tests.cpp:: passed: ::Catch::Detail::stringify('\t') == "'\\t'" for: "'\t'" == "'\t'" +ToStringGeneral.tests.cpp:: passed: ::Catch::Detail::stringify('\n') == "'\\n'" for: "'\n'" == "'\n'" +ToStringGeneral.tests.cpp:: passed: ::Catch::Detail::stringify('\r') == "'\\r'" for: "'\r'" == "'\r'" +ToStringGeneral.tests.cpp:: passed: ::Catch::Detail::stringify('\f') == "'\\f'" for: "'\f'" == "'\f'" +ToStringGeneral.tests.cpp:: passed: ::Catch::Detail::stringify( ' ' ) == "' '" for: "' '" == "' '" +ToStringGeneral.tests.cpp:: passed: ::Catch::Detail::stringify( 'A' ) == "'A'" for: "'A'" == "'A'" +ToStringGeneral.tests.cpp:: passed: ::Catch::Detail::stringify( 'z' ) == "'z'" for: "'z'" == "'z'" +ToStringGeneral.tests.cpp:: passed: ::Catch::Detail::stringify( '\0' ) == "0" for: "0" == "0" +ToStringGeneral.tests.cpp:: passed: ::Catch::Detail::stringify( static_cast(2) ) == "2" for: "2" == "2" +ToStringGeneral.tests.cpp:: passed: ::Catch::Detail::stringify( static_cast(5) ) == "5" for: "5" == "5" +Clara.tests.cpp:: passed: name.empty() for: true +Clara.tests.cpp:: passed: result for: {?} +Clara.tests.cpp:: passed: result.type() == Catch::Clara::Detail::ResultType::Ok for: 0 == 0 +Clara.tests.cpp:: passed: parsed.type() == Catch::Clara::ParseResultType::NoMatch for: 1 == 1 +Clara.tests.cpp:: passed: parsed.remainingTokens().count() == 2 for: 2 == 2 +Clara.tests.cpp:: passed: name.empty() for: true Clara.tests.cpp:: passed: name.empty() for: true Clara.tests.cpp:: passed: name == "foo" for: "foo" == "foo" Clara.tests.cpp:: passed: !(parse_result) for: !{?} @@ -511,7 +541,7 @@ Stream.tests.cpp:: passed: Catch::makeStream( "-" )->isConsole() fo Exception.tests.cpp:: failed: unexpected exception with message: 'custom exception - not std'; expression was: throwCustom() Exception.tests.cpp:: failed: unexpected exception with message: 'custom exception - not std'; expression was: throwCustom(), std::exception Exception.tests.cpp:: failed: unexpected exception with message: 'custom std exception' -Approx.tests.cpp:: passed: 101.000001 != Approx(100).epsilon(0.01) for: 101.000001 != Approx( 100.0 ) +Approx.tests.cpp:: passed: 101.000001 != Approx(100).epsilon(0.01) for: 101.00000099999999748 != Approx( 100.0 ) Approx.tests.cpp:: passed: std::pow(10, -5) != Approx(std::pow(10, -7)) for: 0.00001 != Approx( 0.0000001 ) ToString.tests.cpp:: passed: enumInfo->lookup(0) == "Value1" for: Value1 == "Value1" ToString.tests.cpp:: passed: enumInfo->lookup(1) == "Value2" for: Value2 == "Value2" @@ -531,27 +561,39 @@ EnumToString.tests.cpp:: passed: stringify( EnumClass3::Value4 ) == EnumToString.tests.cpp:: passed: stringify( ec3 ) == "Value2" for: "Value2" == "Value2" EnumToString.tests.cpp:: passed: stringify( Bikeshed::Colours::Red ) == "Red" for: "Red" == "Red" EnumToString.tests.cpp:: passed: stringify( Bikeshed::Colours::Blue ) == "Blue" for: "Blue" == "Blue" -Approx.tests.cpp:: passed: 101.01 != Approx(100).epsilon(0.01) for: 101.01 != Approx( 100.0 ) +Approx.tests.cpp:: passed: 101.01 != Approx(100).epsilon(0.01) for: 101.01000000000000512 != Approx( 100.0 ) Condition.tests.cpp:: failed: data.int_seven == 6 for: 7 == 6 Condition.tests.cpp:: failed: data.int_seven == 8 for: 7 == 8 Condition.tests.cpp:: failed: data.int_seven == 0 for: 7 == 0 -Condition.tests.cpp:: failed: data.float_nine_point_one == Approx( 9.11f ) for: 9.1f == Approx( 9.1099996567 ) -Condition.tests.cpp:: failed: data.float_nine_point_one == Approx( 9.0f ) for: 9.1f == Approx( 9.0 ) -Condition.tests.cpp:: failed: data.float_nine_point_one == Approx( 1 ) for: 9.1f == Approx( 1.0 ) -Condition.tests.cpp:: failed: data.float_nine_point_one == Approx( 0 ) for: 9.1f == Approx( 0.0 ) -Condition.tests.cpp:: failed: data.double_pi == Approx( 3.1415 ) for: 3.1415926535 == Approx( 3.1415 ) +Condition.tests.cpp:: failed: data.float_nine_point_one == Approx( 9.11f ) for: 9.100000381f +== +Approx( 9.10999965667724609 ) +Condition.tests.cpp:: failed: data.float_nine_point_one == Approx( 9.0f ) for: 9.100000381f == Approx( 9.0 ) +Condition.tests.cpp:: failed: data.float_nine_point_one == Approx( 1 ) for: 9.100000381f == Approx( 1.0 ) +Condition.tests.cpp:: failed: data.float_nine_point_one == Approx( 0 ) for: 9.100000381f == Approx( 0.0 ) +Condition.tests.cpp:: failed: data.double_pi == Approx( 3.1415 ) for: 3.14159265350000005 +== +Approx( 3.14150000000000018 ) Condition.tests.cpp:: failed: data.str_hello == "goodbye" for: "hello" == "goodbye" Condition.tests.cpp:: failed: data.str_hello == "hell" for: "hello" == "hell" Condition.tests.cpp:: failed: data.str_hello == "hello1" for: "hello" == "hello1" Condition.tests.cpp:: failed: data.str_hello.size() == 6 for: 5 == 6 -Condition.tests.cpp:: failed: x == Approx( 1.301 ) for: 1.3 == Approx( 1.301 ) +Condition.tests.cpp:: failed: x == Approx( 1.301 ) for: 1.30000000000000027 +== +Approx( 1.30099999999999993 ) Condition.tests.cpp:: passed: data.int_seven == 7 for: 7 == 7 -Condition.tests.cpp:: passed: data.float_nine_point_one == Approx( 9.1f ) for: 9.1f == Approx( 9.1000003815 ) -Condition.tests.cpp:: passed: data.double_pi == Approx( 3.1415926535 ) for: 3.1415926535 == Approx( 3.1415926535 ) +Condition.tests.cpp:: passed: data.float_nine_point_one == Approx( 9.1f ) for: 9.100000381f +== +Approx( 9.10000038146972656 ) +Condition.tests.cpp:: passed: data.double_pi == Approx( 3.1415926535 ) for: 3.14159265350000005 +== +Approx( 3.14159265350000005 ) Condition.tests.cpp:: passed: data.str_hello == "hello" for: "hello" == "hello" Condition.tests.cpp:: passed: "hello" == data.str_hello for: "hello" == "hello" Condition.tests.cpp:: passed: data.str_hello.size() == 5 for: 5 == 5 -Condition.tests.cpp:: passed: x == Approx( 1.3 ) for: 1.3 == Approx( 1.3 ) +Condition.tests.cpp:: passed: x == Approx( 1.3 ) for: 1.30000000000000027 +== +Approx( 1.30000000000000004 ) Matchers.tests.cpp:: passed: testStringForMatching(), Equals( "this string contains 'abc' as a substring" ) for: "this string contains 'abc' as a substring" equals: "this string contains 'abc' as a substring" Matchers.tests.cpp:: passed: testStringForMatching(), Equals( "this string contains 'ABC' as a substring", Catch::CaseSensitive::No ) for: "this string contains 'abc' as a substring" equals: "this string contains 'abc' as a substring" (case insensitive) Matchers.tests.cpp:: failed: testStringForMatching(), Equals( "this string contains 'ABC' as a substring" ) for: "this string contains 'abc' as a substring" equals: "this string contains 'ABC' as a substring" @@ -598,21 +640,21 @@ Misc.tests.cpp:: passed: Factorial(2) == 2 for: 2 == 2 Misc.tests.cpp:: passed: Factorial(3) == 6 for: 6 == 6 Misc.tests.cpp:: passed: Factorial(10) == 3628800 for: 3628800 (0x) == 3628800 (0x) GeneratorsImpl.tests.cpp:: passed: filter( []( int ) { return false; }, value( 3 ) ), Catch::GeneratorException -Matchers.tests.cpp:: passed: 10., WithinRel( 11.1, 0.1 ) for: 10.0 and 11.1 are within 10% of each other -Matchers.tests.cpp:: passed: 10., !WithinRel( 11.2, 0.1 ) for: 10.0 not and 11.2 are within 10% of each other -Matchers.tests.cpp:: passed: 1., !WithinRel( 0., 0.99 ) for: 1.0 not and 0 are within 99% of each other -Matchers.tests.cpp:: passed: -0., WithinRel( 0. ) for: -0.0 and 0 are within 2.22045e-12% of each other -Matchers.tests.cpp:: passed: v1, WithinRel( v2 ) for: 0.0 and 2.22507e-308 are within 2.22045e-12% of each other +Matchers.tests.cpp:: passed: 10., WithinRel( 11.1, 0.1 ) for: 10.0 and 11.09999999999999964 are within 10% of each other +Matchers.tests.cpp:: passed: 10., !WithinRel( 11.2, 0.1 ) for: 10.0 not and 11.19999999999999929 are within 10% of each other +Matchers.tests.cpp:: passed: 1., !WithinRel( 0., 0.99 ) for: 1.0 not and 0.0 are within 99% of each other +Matchers.tests.cpp:: passed: -0., WithinRel( 0. ) for: -0.0 and 0.0 are within 2.22045e-12% of each other +Matchers.tests.cpp:: passed: v1, WithinRel( v2 ) for: 0.0 and 0.0 are within 2.22045e-12% of each other Matchers.tests.cpp:: passed: 1., WithinAbs( 1., 0 ) for: 1.0 is within 0.0 of 1.0 Matchers.tests.cpp:: passed: 0., WithinAbs( 1., 1 ) for: 0.0 is within 1.0 of 1.0 -Matchers.tests.cpp:: passed: 0., !WithinAbs( 1., 0.99 ) for: 0.0 not is within 0.99 of 1.0 -Matchers.tests.cpp:: passed: 0., !WithinAbs( 1., 0.99 ) for: 0.0 not is within 0.99 of 1.0 +Matchers.tests.cpp:: passed: 0., !WithinAbs( 1., 0.99 ) for: 0.0 not is within 0.98999999999999999 of 1.0 +Matchers.tests.cpp:: passed: 0., !WithinAbs( 1., 0.99 ) for: 0.0 not is within 0.98999999999999999 of 1.0 Matchers.tests.cpp:: passed: 11., !WithinAbs( 10., 0.5 ) for: 11.0 not is within 0.5 of 10.0 Matchers.tests.cpp:: passed: 10., !WithinAbs( 11., 0.5 ) for: 10.0 not is within 0.5 of 11.0 Matchers.tests.cpp:: passed: -10., WithinAbs( -10., 0.5 ) for: -10.0 is within 0.5 of -10.0 -Matchers.tests.cpp:: passed: -10., WithinAbs( -9.6, 0.5 ) for: -10.0 is within 0.5 of -9.6 +Matchers.tests.cpp:: passed: -10., WithinAbs( -9.6, 0.5 ) for: -10.0 is within 0.5 of -9.59999999999999964 Matchers.tests.cpp:: passed: 1., WithinULP( 1., 0 ) for: 1.0 is within 0 ULPs of 1.0000000000000000e+00 ([1.0000000000000000e+00, 1.0000000000000000e+00]) -Matchers.tests.cpp:: passed: nextafter( 1., 2. ), WithinULP( 1., 1 ) for: 1.0 is within 1 ULPs of 1.0000000000000000e+00 ([9.9999999999999989e-01, 1.0000000000000002e+00]) +Matchers.tests.cpp:: passed: nextafter( 1., 2. ), WithinULP( 1., 1 ) for: 1.00000000000000022 is within 1 ULPs of 1.0000000000000000e+00 ([9.9999999999999989e-01, 1.0000000000000002e+00]) Matchers.tests.cpp:: passed: 0., WithinULP( nextafter( 0., 1. ), 1 ) for: 0.0 is within 1 ULPs of 4.9406564584124654e-324 ([0.0000000000000000e+00, 9.8813129168249309e-324]) Matchers.tests.cpp:: passed: 1., WithinULP( nextafter( 1., 0. ), 1 ) for: 1.0 is within 1 ULPs of 9.9999999999999989e-01 ([9.9999999999999978e-01, 1.0000000000000000e+00]) Matchers.tests.cpp:: passed: 1., !WithinULP( nextafter( 1., 2. ), 0 ) for: 1.0 not is within 0 ULPs of 1.0000000000000002e+00 ([1.0000000000000002e+00, 1.0000000000000002e+00]) @@ -620,7 +662,7 @@ Matchers.tests.cpp:: passed: 1., WithinULP( 1., 0 ) for: 1.0 is wit Matchers.tests.cpp:: passed: -0., WithinULP( 0., 0 ) for: -0.0 is within 0 ULPs of 0.0000000000000000e+00 ([0.0000000000000000e+00, 0.0000000000000000e+00]) Matchers.tests.cpp:: passed: 1., WithinAbs( 1., 0.5 ) || WithinULP( 2., 1 ) for: 1.0 ( is within 0.5 of 1.0 or is within 1 ULPs of 2.0000000000000000e+00 ([1.9999999999999998e+00, 2.0000000000000004e+00]) ) Matchers.tests.cpp:: passed: 1., WithinAbs( 2., 0.5 ) || WithinULP( 1., 0 ) for: 1.0 ( is within 0.5 of 2.0 or is within 0 ULPs of 1.0000000000000000e+00 ([1.0000000000000000e+00, 1.0000000000000000e+00]) ) -Matchers.tests.cpp:: passed: 0.0001, WithinAbs( 0., 0.001 ) || WithinRel( 0., 0.1 ) for: 0.0001 ( is within 0.001 of 0.0 or and 0 are within 10% of each other ) +Matchers.tests.cpp:: passed: 0.0001, WithinAbs( 0., 0.001 ) || WithinRel( 0., 0.1 ) for: 0.0001 ( is within 0.001 of 0.0 or and 0.0 are within 10% of each other ) Matchers.tests.cpp:: passed: WithinAbs( 1., 0. ) Matchers.tests.cpp:: passed: WithinAbs( 1., -1. ), std::domain_error Matchers.tests.cpp:: passed: WithinULP( 1., 0 ) @@ -628,23 +670,23 @@ Matchers.tests.cpp:: passed: WithinRel( 1., 0. ) Matchers.tests.cpp:: passed: WithinRel( 1., -0.2 ), std::domain_error Matchers.tests.cpp:: passed: WithinRel( 1., 1. ), std::domain_error Matchers.tests.cpp:: passed: 1., !IsNaN() for: 1.0 not is NaN -Matchers.tests.cpp:: passed: 10.f, WithinRel( 11.1f, 0.1f ) for: 10.0f and 11.1 are within 10% of each other -Matchers.tests.cpp:: passed: 10.f, !WithinRel( 11.2f, 0.1f ) for: 10.0f not and 11.2 are within 10% of each other -Matchers.tests.cpp:: passed: 1.f, !WithinRel( 0.f, 0.99f ) for: 1.0f not and 0 are within 99% of each other -Matchers.tests.cpp:: passed: -0.f, WithinRel( 0.f ) for: -0.0f and 0 are within 0.00119209% of each other -Matchers.tests.cpp:: passed: v1, WithinRel( v2 ) for: 0.0f and 1.17549e-38 are within 0.00119209% of each other +Matchers.tests.cpp:: passed: 10.f, WithinRel( 11.1f, 0.1f ) for: 10.0f and 11.10000038146972656 are within 10% of each other +Matchers.tests.cpp:: passed: 10.f, !WithinRel( 11.2f, 0.1f ) for: 10.0f not and 11.19999980926513672 are within 10% of each other +Matchers.tests.cpp:: passed: 1.f, !WithinRel( 0.f, 0.99f ) for: 1.0f not and 0.0 are within 99% of each other +Matchers.tests.cpp:: passed: -0.f, WithinRel( 0.f ) for: -0.0f and 0.0 are within 0.00119209% of each other +Matchers.tests.cpp:: passed: v1, WithinRel( v2 ) for: 0.0f and 0.0 are within 0.00119209% of each other Matchers.tests.cpp:: passed: 1.f, WithinAbs( 1.f, 0 ) for: 1.0f is within 0.0 of 1.0 Matchers.tests.cpp:: passed: 0.f, WithinAbs( 1.f, 1 ) for: 0.0f is within 1.0 of 1.0 -Matchers.tests.cpp:: passed: 0.f, !WithinAbs( 1.f, 0.99f ) for: 0.0f not is within 0.9900000095 of 1.0 -Matchers.tests.cpp:: passed: 0.f, !WithinAbs( 1.f, 0.99f ) for: 0.0f not is within 0.9900000095 of 1.0 +Matchers.tests.cpp:: passed: 0.f, !WithinAbs( 1.f, 0.99f ) for: 0.0f not is within 0.99000000953674316 of 1.0 +Matchers.tests.cpp:: passed: 0.f, !WithinAbs( 1.f, 0.99f ) for: 0.0f not is within 0.99000000953674316 of 1.0 Matchers.tests.cpp:: passed: 0.f, WithinAbs( -0.f, 0 ) for: 0.0f is within 0.0 of -0.0 Matchers.tests.cpp:: passed: 11.f, !WithinAbs( 10.f, 0.5f ) for: 11.0f not is within 0.5 of 10.0 Matchers.tests.cpp:: passed: 10.f, !WithinAbs( 11.f, 0.5f ) for: 10.0f not is within 0.5 of 11.0 Matchers.tests.cpp:: passed: -10.f, WithinAbs( -10.f, 0.5f ) for: -10.0f is within 0.5 of -10.0 -Matchers.tests.cpp:: passed: -10.f, WithinAbs( -9.6f, 0.5f ) for: -10.0f is within 0.5 of -9.6000003815 +Matchers.tests.cpp:: passed: -10.f, WithinAbs( -9.6f, 0.5f ) for: -10.0f is within 0.5 of -9.60000038146972656 Matchers.tests.cpp:: passed: 1.f, WithinULP( 1.f, 0 ) for: 1.0f is within 0 ULPs of 1.00000000e+00f ([1.00000000e+00, 1.00000000e+00]) Matchers.tests.cpp:: passed: -1.f, WithinULP( -1.f, 0 ) for: -1.0f is within 0 ULPs of -1.00000000e+00f ([-1.00000000e+00, -1.00000000e+00]) -Matchers.tests.cpp:: passed: nextafter( 1.f, 2.f ), WithinULP( 1.f, 1 ) for: 1.0f is within 1 ULPs of 1.00000000e+00f ([9.99999940e-01, 1.00000012e+00]) +Matchers.tests.cpp:: passed: nextafter( 1.f, 2.f ), WithinULP( 1.f, 1 ) for: 1.000000119f is within 1 ULPs of 1.00000000e+00f ([9.99999940e-01, 1.00000012e+00]) Matchers.tests.cpp:: passed: 0.f, WithinULP( nextafter( 0.f, 1.f ), 1 ) for: 0.0f is within 1 ULPs of 1.40129846e-45f ([0.00000000e+00, 2.80259693e-45]) Matchers.tests.cpp:: passed: 1.f, WithinULP( nextafter( 1.f, 0.f ), 1 ) for: 1.0f is within 1 ULPs of 9.99999940e-01f ([9.99999881e-01, 1.00000000e+00]) Matchers.tests.cpp:: passed: 1.f, !WithinULP( nextafter( 1.f, 2.f ), 0 ) for: 1.0f not is within 0 ULPs of 1.00000012e+00f ([1.00000012e+00, 1.00000012e+00]) @@ -652,7 +694,7 @@ Matchers.tests.cpp:: passed: 1.f, WithinULP( 1.f, 0 ) for: 1.0f is Matchers.tests.cpp:: passed: -0.f, WithinULP( 0.f, 0 ) for: -0.0f is within 0 ULPs of 0.00000000e+00f ([0.00000000e+00, 0.00000000e+00]) Matchers.tests.cpp:: passed: 1.f, WithinAbs( 1.f, 0.5 ) || WithinULP( 1.f, 1 ) for: 1.0f ( is within 0.5 of 1.0 or is within 1 ULPs of 1.00000000e+00f ([9.99999940e-01, 1.00000012e+00]) ) Matchers.tests.cpp:: passed: 1.f, WithinAbs( 2.f, 0.5 ) || WithinULP( 1.f, 0 ) for: 1.0f ( is within 0.5 of 2.0 or is within 0 ULPs of 1.00000000e+00f ([1.00000000e+00, 1.00000000e+00]) ) -Matchers.tests.cpp:: passed: 0.0001f, WithinAbs( 0.f, 0.001f ) || WithinRel( 0.f, 0.1f ) for: 0.0001f ( is within 0.001 of 0.0 or and 0 are within 10% of each other ) +Matchers.tests.cpp:: passed: 0.0001f, WithinAbs( 0.f, 0.001f ) || WithinRel( 0.f, 0.1f ) for: 0.0001f ( is within 0.00100000004749745 of 0.0 or and 0.0 are within 10% of each other ) Matchers.tests.cpp:: passed: WithinAbs( 1.f, 0.f ) Matchers.tests.cpp:: passed: WithinAbs( 1.f, -1.f ), std::domain_error Matchers.tests.cpp:: passed: WithinULP( 1.f, 0 ) @@ -832,68 +874,122 @@ GeneratorsImpl.tests.cpp:: passed: gen.get() == 5 for: 5 == 5 GeneratorsImpl.tests.cpp:: passed: !(gen.next()) for: !false GeneratorsImpl.tests.cpp:: passed: gen.get() == Approx(expected) for: -1.0 == Approx( -1.0 ) with 1 message: 'Current expected value is -1' GeneratorsImpl.tests.cpp:: passed: gen.next() for: true with 1 message: 'Current expected value is -1' -GeneratorsImpl.tests.cpp:: passed: gen.get() == Approx(expected) for: -0.9 == Approx( -0.9 ) with 1 message: 'Current expected value is -0.9' +GeneratorsImpl.tests.cpp:: passed: gen.get() == Approx(expected) for: -0.90000000000000002 +== +Approx( -0.90000000000000002 ) with 1 message: 'Current expected value is -0.9' GeneratorsImpl.tests.cpp:: passed: gen.next() for: true with 1 message: 'Current expected value is -0.9' -GeneratorsImpl.tests.cpp:: passed: gen.get() == Approx(expected) for: -0.8 == Approx( -0.8 ) with 1 message: 'Current expected value is -0.8' +GeneratorsImpl.tests.cpp:: passed: gen.get() == Approx(expected) for: -0.80000000000000004 +== +Approx( -0.80000000000000004 ) with 1 message: 'Current expected value is -0.8' GeneratorsImpl.tests.cpp:: passed: gen.next() for: true with 1 message: 'Current expected value is -0.8' -GeneratorsImpl.tests.cpp:: passed: gen.get() == Approx(expected) for: -0.7 == Approx( -0.7 ) with 1 message: 'Current expected value is -0.7' +GeneratorsImpl.tests.cpp:: passed: gen.get() == Approx(expected) for: -0.70000000000000007 +== +Approx( -0.70000000000000007 ) with 1 message: 'Current expected value is -0.7' GeneratorsImpl.tests.cpp:: passed: gen.next() for: true with 1 message: 'Current expected value is -0.7' -GeneratorsImpl.tests.cpp:: passed: gen.get() == Approx(expected) for: -0.6 == Approx( -0.6 ) with 1 message: 'Current expected value is -0.6' +GeneratorsImpl.tests.cpp:: passed: gen.get() == Approx(expected) for: -0.60000000000000009 +== +Approx( -0.60000000000000009 ) with 1 message: 'Current expected value is -0.6' GeneratorsImpl.tests.cpp:: passed: gen.next() for: true with 1 message: 'Current expected value is -0.6' -GeneratorsImpl.tests.cpp:: passed: gen.get() == Approx(expected) for: -0.5 == Approx( -0.5 ) with 1 message: 'Current expected value is -0.5' +GeneratorsImpl.tests.cpp:: passed: gen.get() == Approx(expected) for: -0.50000000000000011 +== +Approx( -0.50000000000000011 ) with 1 message: 'Current expected value is -0.5' GeneratorsImpl.tests.cpp:: passed: gen.next() for: true with 1 message: 'Current expected value is -0.5' -GeneratorsImpl.tests.cpp:: passed: gen.get() == Approx(expected) for: -0.4 == Approx( -0.4 ) with 1 message: 'Current expected value is -0.4' +GeneratorsImpl.tests.cpp:: passed: gen.get() == Approx(expected) for: -0.40000000000000013 +== +Approx( -0.40000000000000013 ) with 1 message: 'Current expected value is -0.4' GeneratorsImpl.tests.cpp:: passed: gen.next() for: true with 1 message: 'Current expected value is -0.4' -GeneratorsImpl.tests.cpp:: passed: gen.get() == Approx(expected) for: -0.3 == Approx( -0.3 ) with 1 message: 'Current expected value is -0.3' +GeneratorsImpl.tests.cpp:: passed: gen.get() == Approx(expected) for: -0.30000000000000016 +== +Approx( -0.30000000000000016 ) with 1 message: 'Current expected value is -0.3' GeneratorsImpl.tests.cpp:: passed: gen.next() for: true with 1 message: 'Current expected value is -0.3' -GeneratorsImpl.tests.cpp:: passed: gen.get() == Approx(expected) for: -0.2 == Approx( -0.2 ) with 1 message: 'Current expected value is -0.2' +GeneratorsImpl.tests.cpp:: passed: gen.get() == Approx(expected) for: -0.20000000000000015 +== +Approx( -0.20000000000000015 ) with 1 message: 'Current expected value is -0.2' GeneratorsImpl.tests.cpp:: passed: gen.next() for: true with 1 message: 'Current expected value is -0.2' -GeneratorsImpl.tests.cpp:: passed: gen.get() == Approx(expected) for: -0.1 == Approx( -0.1 ) with 1 message: 'Current expected value is -0.1' +GeneratorsImpl.tests.cpp:: passed: gen.get() == Approx(expected) for: -0.10000000000000014 +== +Approx( -0.10000000000000014 ) with 1 message: 'Current expected value is -0.1' GeneratorsImpl.tests.cpp:: passed: gen.next() for: true with 1 message: 'Current expected value is -0.1' -GeneratorsImpl.tests.cpp:: passed: gen.get() == Approx(expected) for: -0.0 == Approx( -0.0 ) with 1 message: 'Current expected value is -1.38778e-16' +GeneratorsImpl.tests.cpp:: passed: gen.get() == Approx(expected) for: -0.00000000000000014 +== +Approx( -0.00000000000000014 ) with 1 message: 'Current expected value is -1.38778e-16' GeneratorsImpl.tests.cpp:: passed: gen.next() for: true with 1 message: 'Current expected value is -1.38778e-16' -GeneratorsImpl.tests.cpp:: passed: gen.get() == Approx(expected) for: 0.1 == Approx( 0.1 ) with 1 message: 'Current expected value is 0.1' +GeneratorsImpl.tests.cpp:: passed: gen.get() == Approx(expected) for: 0.09999999999999987 +== +Approx( 0.09999999999999987 ) with 1 message: 'Current expected value is 0.1' GeneratorsImpl.tests.cpp:: passed: gen.next() for: true with 1 message: 'Current expected value is 0.1' -GeneratorsImpl.tests.cpp:: passed: gen.get() == Approx(expected) for: 0.2 == Approx( 0.2 ) with 1 message: 'Current expected value is 0.2' +GeneratorsImpl.tests.cpp:: passed: gen.get() == Approx(expected) for: 0.19999999999999987 +== +Approx( 0.19999999999999987 ) with 1 message: 'Current expected value is 0.2' GeneratorsImpl.tests.cpp:: passed: gen.next() for: true with 1 message: 'Current expected value is 0.2' -GeneratorsImpl.tests.cpp:: passed: gen.get() == Approx(expected) for: 0.3 == Approx( 0.3 ) with 1 message: 'Current expected value is 0.3' +GeneratorsImpl.tests.cpp:: passed: gen.get() == Approx(expected) for: 0.29999999999999988 +== +Approx( 0.29999999999999988 ) with 1 message: 'Current expected value is 0.3' GeneratorsImpl.tests.cpp:: passed: gen.next() for: true with 1 message: 'Current expected value is 0.3' -GeneratorsImpl.tests.cpp:: passed: gen.get() == Approx(expected) for: 0.4 == Approx( 0.4 ) with 1 message: 'Current expected value is 0.4' +GeneratorsImpl.tests.cpp:: passed: gen.get() == Approx(expected) for: 0.39999999999999991 +== +Approx( 0.39999999999999991 ) with 1 message: 'Current expected value is 0.4' GeneratorsImpl.tests.cpp:: passed: gen.next() for: true with 1 message: 'Current expected value is 0.4' -GeneratorsImpl.tests.cpp:: passed: gen.get() == Approx(expected) for: 0.5 == Approx( 0.5 ) with 1 message: 'Current expected value is 0.5' +GeneratorsImpl.tests.cpp:: passed: gen.get() == Approx(expected) for: 0.49999999999999989 +== +Approx( 0.49999999999999989 ) with 1 message: 'Current expected value is 0.5' GeneratorsImpl.tests.cpp:: passed: gen.next() for: true with 1 message: 'Current expected value is 0.5' -GeneratorsImpl.tests.cpp:: passed: gen.get() == Approx(expected) for: 0.6 == Approx( 0.6 ) with 1 message: 'Current expected value is 0.6' +GeneratorsImpl.tests.cpp:: passed: gen.get() == Approx(expected) for: 0.59999999999999987 +== +Approx( 0.59999999999999987 ) with 1 message: 'Current expected value is 0.6' GeneratorsImpl.tests.cpp:: passed: gen.next() for: true with 1 message: 'Current expected value is 0.6' -GeneratorsImpl.tests.cpp:: passed: gen.get() == Approx(expected) for: 0.7 == Approx( 0.7 ) with 1 message: 'Current expected value is 0.7' +GeneratorsImpl.tests.cpp:: passed: gen.get() == Approx(expected) for: 0.69999999999999984 +== +Approx( 0.69999999999999984 ) with 1 message: 'Current expected value is 0.7' GeneratorsImpl.tests.cpp:: passed: gen.next() for: true with 1 message: 'Current expected value is 0.7' -GeneratorsImpl.tests.cpp:: passed: gen.get() == Approx(expected) for: 0.8 == Approx( 0.8 ) with 1 message: 'Current expected value is 0.8' +GeneratorsImpl.tests.cpp:: passed: gen.get() == Approx(expected) for: 0.79999999999999982 +== +Approx( 0.79999999999999982 ) with 1 message: 'Current expected value is 0.8' GeneratorsImpl.tests.cpp:: passed: gen.next() for: true with 1 message: 'Current expected value is 0.8' -GeneratorsImpl.tests.cpp:: passed: gen.get() == Approx(expected) for: 0.9 == Approx( 0.9 ) with 1 message: 'Current expected value is 0.9' +GeneratorsImpl.tests.cpp:: passed: gen.get() == Approx(expected) for: 0.8999999999999998 +== +Approx( 0.8999999999999998 ) with 1 message: 'Current expected value is 0.9' GeneratorsImpl.tests.cpp:: passed: gen.next() for: true with 1 message: 'Current expected value is 0.9' -GeneratorsImpl.tests.cpp:: passed: gen.get() == Approx( rangeEnd ) for: 1.0 == Approx( 1.0 ) +GeneratorsImpl.tests.cpp:: passed: gen.get() == Approx( rangeEnd ) for: 0.99999999999999978 == Approx( 1.0 ) GeneratorsImpl.tests.cpp:: passed: !(gen.next()) for: !false GeneratorsImpl.tests.cpp:: passed: gen.get() == Approx(expected) for: -1.0 == Approx( -1.0 ) with 1 message: 'Current expected value is -1' GeneratorsImpl.tests.cpp:: passed: gen.next() for: true with 1 message: 'Current expected value is -1' -GeneratorsImpl.tests.cpp:: passed: gen.get() == Approx(expected) for: -0.7 == Approx( -0.7 ) with 1 message: 'Current expected value is -0.7' +GeneratorsImpl.tests.cpp:: passed: gen.get() == Approx(expected) for: -0.69999999999999996 +== +Approx( -0.69999999999999996 ) with 1 message: 'Current expected value is -0.7' GeneratorsImpl.tests.cpp:: passed: gen.next() for: true with 1 message: 'Current expected value is -0.7' -GeneratorsImpl.tests.cpp:: passed: gen.get() == Approx(expected) for: -0.4 == Approx( -0.4 ) with 1 message: 'Current expected value is -0.4' +GeneratorsImpl.tests.cpp:: passed: gen.get() == Approx(expected) for: -0.39999999999999997 +== +Approx( -0.39999999999999997 ) with 1 message: 'Current expected value is -0.4' GeneratorsImpl.tests.cpp:: passed: gen.next() for: true with 1 message: 'Current expected value is -0.4' -GeneratorsImpl.tests.cpp:: passed: gen.get() == Approx(expected) for: -0.1 == Approx( -0.1 ) with 1 message: 'Current expected value is -0.1' +GeneratorsImpl.tests.cpp:: passed: gen.get() == Approx(expected) for: -0.09999999999999998 +== +Approx( -0.09999999999999998 ) with 1 message: 'Current expected value is -0.1' GeneratorsImpl.tests.cpp:: passed: gen.next() for: true with 1 message: 'Current expected value is -0.1' -GeneratorsImpl.tests.cpp:: passed: gen.get() == Approx(expected) for: 0.2 == Approx( 0.2 ) with 1 message: 'Current expected value is 0.2' +GeneratorsImpl.tests.cpp:: passed: gen.get() == Approx(expected) for: 0.20000000000000001 +== +Approx( 0.20000000000000001 ) with 1 message: 'Current expected value is 0.2' GeneratorsImpl.tests.cpp:: passed: gen.next() for: true with 1 message: 'Current expected value is 0.2' GeneratorsImpl.tests.cpp:: passed: gen.get() == Approx(expected) for: 0.5 == Approx( 0.5 ) with 1 message: 'Current expected value is 0.5' GeneratorsImpl.tests.cpp:: passed: gen.next() for: true with 1 message: 'Current expected value is 0.5' GeneratorsImpl.tests.cpp:: passed: !(gen.next()) for: !false GeneratorsImpl.tests.cpp:: passed: gen.get() == Approx(expected) for: -1.0 == Approx( -1.0 ) with 1 message: 'Current expected value is -1' GeneratorsImpl.tests.cpp:: passed: gen.next() for: true with 1 message: 'Current expected value is -1' -GeneratorsImpl.tests.cpp:: passed: gen.get() == Approx(expected) for: -0.7 == Approx( -0.7 ) with 1 message: 'Current expected value is -0.7' +GeneratorsImpl.tests.cpp:: passed: gen.get() == Approx(expected) for: -0.69999999999999996 +== +Approx( -0.69999999999999996 ) with 1 message: 'Current expected value is -0.7' GeneratorsImpl.tests.cpp:: passed: gen.next() for: true with 1 message: 'Current expected value is -0.7' -GeneratorsImpl.tests.cpp:: passed: gen.get() == Approx(expected) for: -0.4 == Approx( -0.4 ) with 1 message: 'Current expected value is -0.4' +GeneratorsImpl.tests.cpp:: passed: gen.get() == Approx(expected) for: -0.39999999999999997 +== +Approx( -0.39999999999999997 ) with 1 message: 'Current expected value is -0.4' GeneratorsImpl.tests.cpp:: passed: gen.next() for: true with 1 message: 'Current expected value is -0.4' -GeneratorsImpl.tests.cpp:: passed: gen.get() == Approx(expected) for: -0.1 == Approx( -0.1 ) with 1 message: 'Current expected value is -0.1' +GeneratorsImpl.tests.cpp:: passed: gen.get() == Approx(expected) for: -0.09999999999999998 +== +Approx( -0.09999999999999998 ) with 1 message: 'Current expected value is -0.1' GeneratorsImpl.tests.cpp:: passed: gen.next() for: true with 1 message: 'Current expected value is -0.1' -GeneratorsImpl.tests.cpp:: passed: gen.get() == Approx(expected) for: 0.2 == Approx( 0.2 ) with 1 message: 'Current expected value is 0.2' +GeneratorsImpl.tests.cpp:: passed: gen.get() == Approx(expected) for: 0.20000000000000001 +== +Approx( 0.20000000000000001 ) with 1 message: 'Current expected value is 0.2' GeneratorsImpl.tests.cpp:: passed: gen.next() for: true with 1 message: 'Current expected value is 0.2' GeneratorsImpl.tests.cpp:: passed: gen.get() == Approx(expected) for: 0.5 == Approx( 0.5 ) with 1 message: 'Current expected value is 0.5' GeneratorsImpl.tests.cpp:: passed: gen.next() for: true with 1 message: 'Current expected value is 0.5' @@ -924,10 +1020,18 @@ GeneratorsImpl.tests.cpp:: passed: gen.get() == -4 for: -4 == -4 GeneratorsImpl.tests.cpp:: passed: gen.next() for: true GeneratorsImpl.tests.cpp:: passed: gen.get() == -7 for: -7 == -7 GeneratorsImpl.tests.cpp:: passed: !(gen.next()) for: !false -Approx.tests.cpp:: passed: d >= Approx( 1.22 ) for: 1.23 >= Approx( 1.22 ) -Approx.tests.cpp:: passed: d >= Approx( 1.23 ) for: 1.23 >= Approx( 1.23 ) -Approx.tests.cpp:: passed: !(d >= Approx( 1.24 )) for: !(1.23 >= Approx( 1.24 )) -Approx.tests.cpp:: passed: d >= Approx( 1.24 ).epsilon(0.1) for: 1.23 >= Approx( 1.24 ) +Approx.tests.cpp:: passed: d >= Approx( 1.22 ) for: 1.22999999999999998 +>= +Approx( 1.21999999999999997 ) +Approx.tests.cpp:: passed: d >= Approx( 1.23 ) for: 1.22999999999999998 +>= +Approx( 1.22999999999999998 ) +Approx.tests.cpp:: passed: !(d >= Approx( 1.24 )) for: !(1.22999999999999998 +>= +Approx( 1.23999999999999999 )) +Approx.tests.cpp:: passed: d >= Approx( 1.24 ).epsilon(0.1) for: 1.22999999999999998 +>= +Approx( 1.23999999999999999 ) TestCaseInfoHasher.tests.cpp:: passed: h1( dummy ) != h2( dummy ) for: 3422778688 (0x) != 130711275 (0x) @@ -966,17 +1070,25 @@ Message.tests.cpp:: passed: i < 10 for: 9 < 10 with 2 messages: 'cu Message.tests.cpp:: failed: i < 10 for: 10 < 10 with 2 messages: 'current counter 10' and 'i := 10' AssertionHandler.tests.cpp:: failed: unexpected exception with message: 'Exception translation was disabled by CATCH_CONFIG_FAST_COMPILE'; expression was: Dummy Condition.tests.cpp:: failed: data.int_seven != 7 for: 7 != 7 -Condition.tests.cpp:: failed: data.float_nine_point_one != Approx( 9.1f ) for: 9.1f != Approx( 9.1000003815 ) -Condition.tests.cpp:: failed: data.double_pi != Approx( 3.1415926535 ) for: 3.1415926535 != Approx( 3.1415926535 ) +Condition.tests.cpp:: failed: data.float_nine_point_one != Approx( 9.1f ) for: 9.100000381f +!= +Approx( 9.10000038146972656 ) +Condition.tests.cpp:: failed: data.double_pi != Approx( 3.1415926535 ) for: 3.14159265350000005 +!= +Approx( 3.14159265350000005 ) Condition.tests.cpp:: failed: data.str_hello != "hello" for: "hello" != "hello" Condition.tests.cpp:: failed: data.str_hello.size() != 5 for: 5 != 5 Condition.tests.cpp:: passed: data.int_seven != 6 for: 7 != 6 Condition.tests.cpp:: passed: data.int_seven != 8 for: 7 != 8 -Condition.tests.cpp:: passed: data.float_nine_point_one != Approx( 9.11f ) for: 9.1f != Approx( 9.1099996567 ) -Condition.tests.cpp:: passed: data.float_nine_point_one != Approx( 9.0f ) for: 9.1f != Approx( 9.0 ) -Condition.tests.cpp:: passed: data.float_nine_point_one != Approx( 1 ) for: 9.1f != Approx( 1.0 ) -Condition.tests.cpp:: passed: data.float_nine_point_one != Approx( 0 ) for: 9.1f != Approx( 0.0 ) -Condition.tests.cpp:: passed: data.double_pi != Approx( 3.1415 ) for: 3.1415926535 != Approx( 3.1415 ) +Condition.tests.cpp:: passed: data.float_nine_point_one != Approx( 9.11f ) for: 9.100000381f +!= +Approx( 9.10999965667724609 ) +Condition.tests.cpp:: passed: data.float_nine_point_one != Approx( 9.0f ) for: 9.100000381f != Approx( 9.0 ) +Condition.tests.cpp:: passed: data.float_nine_point_one != Approx( 1 ) for: 9.100000381f != Approx( 1.0 ) +Condition.tests.cpp:: passed: data.float_nine_point_one != Approx( 0 ) for: 9.100000381f != Approx( 0.0 ) +Condition.tests.cpp:: passed: data.double_pi != Approx( 3.1415 ) for: 3.14159265350000005 +!= +Approx( 3.14150000000000018 ) Condition.tests.cpp:: passed: data.str_hello != "goodbye" for: "hello" != "goodbye" Condition.tests.cpp:: passed: data.str_hello != "hell" for: "hello" != "hell" Condition.tests.cpp:: passed: data.str_hello != "hello1" for: "hello" != "hello1" @@ -1067,10 +1179,18 @@ Json.tests.cpp:: passed: sstream.str() == "\"\\r\"" for: ""\r"" == Json.tests.cpp:: passed: sstream.str() == "\"\\t\"" for: ""\t"" == ""\t"" Json.tests.cpp:: passed: sstream.str() == "\"\\\\/\\t\\r\\n\"" for: ""\\/\t\r\n"" == ""\\/\t\r\n"" Compilation.tests.cpp:: passed: []() { return true; }() for: true -Approx.tests.cpp:: passed: d <= Approx( 1.24 ) for: 1.23 <= Approx( 1.24 ) -Approx.tests.cpp:: passed: d <= Approx( 1.23 ) for: 1.23 <= Approx( 1.23 ) -Approx.tests.cpp:: passed: !(d <= Approx( 1.22 )) for: !(1.23 <= Approx( 1.22 )) -Approx.tests.cpp:: passed: d <= Approx( 1.22 ).epsilon(0.1) for: 1.23 <= Approx( 1.22 ) +Approx.tests.cpp:: passed: d <= Approx( 1.24 ) for: 1.22999999999999998 +<= +Approx( 1.23999999999999999 ) +Approx.tests.cpp:: passed: d <= Approx( 1.23 ) for: 1.22999999999999998 +<= +Approx( 1.22999999999999998 ) +Approx.tests.cpp:: passed: !(d <= Approx( 1.22 )) for: !(1.22999999999999998 +<= +Approx( 1.21999999999999997 )) +Approx.tests.cpp:: passed: d <= Approx( 1.22 ).epsilon(0.1) for: 1.22999999999999998 +<= +Approx( 1.21999999999999997 ) Misc.tests.cpp:: passed: with 1 message: 'was called' Matchers.tests.cpp:: passed: testStringForMatching(), ContainsSubstring( "string" ) && ContainsSubstring( "abc" ) && ContainsSubstring( "substring" ) && ContainsSubstring( "contains" ) for: "this string contains 'abc' as a substring" ( contains: "string" and contains: "abc" and contains: "substring" and contains: "contains" ) Matchers.tests.cpp:: passed: testStringForMatching(), ContainsSubstring( "string" ) || ContainsSubstring( "different" ) || ContainsSubstring( "random" ) for: "this string contains 'abc' as a substring" ( contains: "string" or contains: "different" or contains: "random" ) @@ -1137,9 +1257,9 @@ Condition.tests.cpp:: failed: data.int_seven < 0 for: 7 < 0 Condition.tests.cpp:: failed: data.int_seven < -1 for: 7 < -1 Condition.tests.cpp:: failed: data.int_seven >= 8 for: 7 >= 8 Condition.tests.cpp:: failed: data.int_seven <= 6 for: 7 <= 6 -Condition.tests.cpp:: failed: data.float_nine_point_one < 9 for: 9.1f < 9 -Condition.tests.cpp:: failed: data.float_nine_point_one > 10 for: 9.1f > 10 -Condition.tests.cpp:: failed: data.float_nine_point_one > 9.2 for: 9.1f > 9.2 +Condition.tests.cpp:: failed: data.float_nine_point_one < 9 for: 9.100000381f < 9 +Condition.tests.cpp:: failed: data.float_nine_point_one > 10 for: 9.100000381f > 10 +Condition.tests.cpp:: failed: data.float_nine_point_one > 9.2 for: 9.100000381f > 9.19999999999999929 Condition.tests.cpp:: failed: data.str_hello > "hello" for: "hello" > "hello" Condition.tests.cpp:: failed: data.str_hello < "hello" for: "hello" < "hello" Condition.tests.cpp:: failed: data.str_hello > "hellp" for: "hello" > "hellp" @@ -1156,9 +1276,9 @@ Condition.tests.cpp:: passed: data.int_seven >= 7 for: 7 >= 7 Condition.tests.cpp:: passed: data.int_seven >= 6 for: 7 >= 6 Condition.tests.cpp:: passed: data.int_seven <= 7 for: 7 <= 7 Condition.tests.cpp:: passed: data.int_seven <= 8 for: 7 <= 8 -Condition.tests.cpp:: passed: data.float_nine_point_one > 9 for: 9.1f > 9 -Condition.tests.cpp:: passed: data.float_nine_point_one < 10 for: 9.1f < 10 -Condition.tests.cpp:: passed: data.float_nine_point_one < 9.2 for: 9.1f < 9.2 +Condition.tests.cpp:: passed: data.float_nine_point_one > 9 for: 9.100000381f > 9 +Condition.tests.cpp:: passed: data.float_nine_point_one < 10 for: 9.100000381f < 10 +Condition.tests.cpp:: passed: data.float_nine_point_one < 9.2 for: 9.100000381f < 9.19999999999999929 Condition.tests.cpp:: passed: data.str_hello <= "hello" for: "hello" <= "hello" Condition.tests.cpp:: passed: data.str_hello >= "hello" for: "hello" >= "hello" Condition.tests.cpp:: passed: data.str_hello < "hellp" for: "hello" < "hellp" @@ -1356,7 +1476,9 @@ CmdLine.tests.cpp:: passed: config.benchmarkSamples == 200 for: 200 CmdLine.tests.cpp:: passed: cli.parse({ "test", "--benchmark-resamples=20000" }) for: {?} CmdLine.tests.cpp:: passed: config.benchmarkResamples == 20000 for: 20000 (0x) == 20000 (0x) CmdLine.tests.cpp:: passed: cli.parse({ "test", "--benchmark-confidence-interval=0.99" }) for: {?} -CmdLine.tests.cpp:: passed: config.benchmarkConfidenceInterval == Catch::Approx(0.99) for: 0.99 == Approx( 0.99 ) +CmdLine.tests.cpp:: passed: config.benchmarkConfidenceInterval == Catch::Approx(0.99) for: 0.98999999999999999 +== +Approx( 0.98999999999999999 ) CmdLine.tests.cpp:: passed: cli.parse({ "test", "--benchmark-no-analysis" }) for: {?} CmdLine.tests.cpp:: passed: config.benchmarkNoAnalysis for: true CmdLine.tests.cpp:: passed: cli.parse({ "test", "--benchmark-warmup-time=10" }) for: {?} @@ -1608,14 +1730,30 @@ BDD.tests.cpp:: passed: v.capacity() >= 10 for: 10 >= 10 BDD.tests.cpp:: passed: v.size() == 0 for: 0 == 0 BDD.tests.cpp:: passed: v.capacity() >= 10 for: 10 >= 10 BDD.tests.cpp:: passed: v.size() == 0 for: 0 == 0 -Approx.tests.cpp:: passed: d == Approx( 1.23 ) for: 1.23 == Approx( 1.23 ) -Approx.tests.cpp:: passed: d != Approx( 1.22 ) for: 1.23 != Approx( 1.22 ) -Approx.tests.cpp:: passed: d != Approx( 1.24 ) for: 1.23 != Approx( 1.24 ) -Approx.tests.cpp:: passed: d == 1.23_a for: 1.23 == Approx( 1.23 ) -Approx.tests.cpp:: passed: d != 1.22_a for: 1.23 != Approx( 1.22 ) -Approx.tests.cpp:: passed: Approx( d ) == 1.23 for: Approx( 1.23 ) == 1.23 -Approx.tests.cpp:: passed: Approx( d ) != 1.22 for: Approx( 1.23 ) != 1.22 -Approx.tests.cpp:: passed: Approx( d ) != 1.24 for: Approx( 1.23 ) != 1.24 +Approx.tests.cpp:: passed: d == Approx( 1.23 ) for: 1.22999999999999998 +== +Approx( 1.22999999999999998 ) +Approx.tests.cpp:: passed: d != Approx( 1.22 ) for: 1.22999999999999998 +!= +Approx( 1.21999999999999997 ) +Approx.tests.cpp:: passed: d != Approx( 1.24 ) for: 1.22999999999999998 +!= +Approx( 1.23999999999999999 ) +Approx.tests.cpp:: passed: d == 1.23_a for: 1.22999999999999998 +== +Approx( 1.22999999999999998 ) +Approx.tests.cpp:: passed: d != 1.22_a for: 1.22999999999999998 +!= +Approx( 1.21999999999999997 ) +Approx.tests.cpp:: passed: Approx( d ) == 1.23 for: Approx( 1.22999999999999998 ) +== +1.22999999999999998 +Approx.tests.cpp:: passed: Approx( d ) != 1.22 for: Approx( 1.22999999999999998 ) +!= +1.21999999999999997 +Approx.tests.cpp:: passed: Approx( d ) != 1.24 for: Approx( 1.22999999999999998 ) +!= +1.23999999999999999 Matchers.tests.cpp:: failed: testStringForMatching(), StartsWith( "This String" ) for: "this string contains 'abc' as a substring" starts with: "This String" Matchers.tests.cpp:: failed: testStringForMatching(), StartsWith( "string", Catch::CaseSensitive::No ) for: "this string contains 'abc' as a substring" starts with: "string" (case insensitive) ToStringGeneral.tests.cpp:: passed: Catch::Detail::stringify(singular) == "{ 1 }" for: "{ 1 }" == "{ 1 }" @@ -1730,13 +1868,13 @@ Tag.tests.cpp:: passed: testCase.tags, VectorContains( Tag( "tag wi Class.tests.cpp:: passed: Template_Fixture::m_a == 1 for: 1 == 1 Class.tests.cpp:: passed: Template_Fixture::m_a == 1 for: 1 == 1 Class.tests.cpp:: passed: Template_Fixture::m_a == 1 for: 1.0 == 1 -Misc.tests.cpp:: passed: sizeof(TestType) > 0 for: 1 > 0 -Misc.tests.cpp:: passed: sizeof(TestType) > 0 for: 4 > 0 -Misc.tests.cpp:: passed: sizeof(TestType) > 0 for: 1 > 0 -Misc.tests.cpp:: passed: sizeof(TestType) > 0 for: 4 > 0 -Misc.tests.cpp:: passed: sizeof(TestType) > 0 for: 4 > 0 -Misc.tests.cpp:: passed: sizeof(TestType) > 0 for: 1 > 0 -Misc.tests.cpp:: passed: sizeof(TestType) > 0 for: 4 > 0 +Misc.tests.cpp:: passed: std::is_default_constructible::value for: true +Misc.tests.cpp:: passed: std::is_default_constructible::value for: true +Misc.tests.cpp:: passed: std::is_trivially_copyable::value for: true +Misc.tests.cpp:: passed: std::is_trivially_copyable::value for: true +Misc.tests.cpp:: passed: std::is_arithmetic::value for: true +Misc.tests.cpp:: passed: std::is_arithmetic::value for: true +Misc.tests.cpp:: passed: std::is_arithmetic::value for: true Misc.tests.cpp:: passed: v.size() == 5 for: 5 == 5 Misc.tests.cpp:: passed: v.capacity() >= 5 for: 5 >= 5 Misc.tests.cpp:: passed: v.size() == 10 for: 10 == 10 @@ -2022,7 +2160,7 @@ MatchersRanges.tests.cpp:: passed: a, !RangeEquals( b ) for: { 1, 2 MatchersRanges.tests.cpp:: passed: a, UnorderedRangeEquals( b ) for: { 1, 2, 3 } unordered elements are { 3, 2, 1 } MatchersRanges.tests.cpp:: passed: vector_a, RangeEquals( array_a_plus_1, close_enough ) for: { 1, 2, 3 } elements are { 2, 3, 4 } MatchersRanges.tests.cpp:: passed: vector_a, UnorderedRangeEquals( array_a_plus_1, close_enough ) for: { 1, 2, 3 } unordered elements are { 2, 3, 4 } -Exception.tests.cpp:: failed: unexpected exception with message: '3.14' +Exception.tests.cpp:: failed: unexpected exception with message: '3.14000000000000012' UniquePtr.tests.cpp:: passed: bptr->i == 3 for: 3 == 3 UniquePtr.tests.cpp:: passed: bptr->i == 3 for: 3 == 3 MatchersRanges.tests.cpp:: passed: data, AllMatch(SizeIs(5)) for: { { 0, 1, 2, 3, 5 }, { 4, -3, -2, 5, 0 }, { 0, 0, 0, 5, 0 }, { 0, -5, 0, 5, 0 }, { 1, 0, 0, -1, 5 } } all match has size == 5 @@ -2168,14 +2306,26 @@ MatchersRanges.tests.cpp:: passed: arr, !SizeIs(!Lt(3)) for: { 0, 0 MatchersRanges.tests.cpp:: passed: map, SizeIs(3) for: { {?}, {?}, {?} } has size == 3 MatchersRanges.tests.cpp:: passed: unrelated::ADL_size{}, SizeIs(12) for: {?} has size == 12 MatchersRanges.tests.cpp:: passed: has_size{}, SizeIs(13) for: {?} has size == 13 -Approx.tests.cpp:: passed: d == approx( 1.23 ) for: 1.23 == Approx( 1.23 ) -Approx.tests.cpp:: passed: d == approx( 1.22 ) for: 1.23 == Approx( 1.22 ) -Approx.tests.cpp:: passed: d == approx( 1.24 ) for: 1.23 == Approx( 1.24 ) -Approx.tests.cpp:: passed: d != approx( 1.25 ) for: 1.23 != Approx( 1.25 ) -Approx.tests.cpp:: passed: approx( d ) == 1.23 for: Approx( 1.23 ) == 1.23 -Approx.tests.cpp:: passed: approx( d ) == 1.22 for: Approx( 1.23 ) == 1.22 -Approx.tests.cpp:: passed: approx( d ) == 1.24 for: Approx( 1.23 ) == 1.24 -Approx.tests.cpp:: passed: approx( d ) != 1.25 for: Approx( 1.23 ) != 1.25 +Approx.tests.cpp:: passed: d == approx( 1.23 ) for: 1.22999999999999998 +== +Approx( 1.22999999999999998 ) +Approx.tests.cpp:: passed: d == approx( 1.22 ) for: 1.22999999999999998 +== +Approx( 1.21999999999999997 ) +Approx.tests.cpp:: passed: d == approx( 1.24 ) for: 1.22999999999999998 +== +Approx( 1.23999999999999999 ) +Approx.tests.cpp:: passed: d != approx( 1.25 ) for: 1.22999999999999998 != Approx( 1.25 ) +Approx.tests.cpp:: passed: approx( d ) == 1.23 for: Approx( 1.22999999999999998 ) +== +1.22999999999999998 +Approx.tests.cpp:: passed: approx( d ) == 1.22 for: Approx( 1.22999999999999998 ) +== +1.21999999999999997 +Approx.tests.cpp:: passed: approx( d ) == 1.24 for: Approx( 1.22999999999999998 ) +== +1.23999999999999999 +Approx.tests.cpp:: passed: approx( d ) != 1.25 for: Approx( 1.22999999999999998 ) != 1.25 VariadicMacros.tests.cpp:: passed: with 1 message: 'no assertions' Matchers.tests.cpp:: passed: empty, Approx( empty ) for: { } is approx: { } Matchers.tests.cpp:: passed: v1, Approx( v1 ) for: { 1.0, 2.0, 3.0 } is approx: { 1.0, 2.0, 3.0 } @@ -2350,9 +2500,15 @@ Skip.tests.cpp:: skipped: 'skipping because answer = 41' Skip.tests.cpp:: passed: Skip.tests.cpp:: skipped: 'skipping because answer = 43' Tag.tests.cpp:: passed: Catch::TestCaseInfo("", { "test with an empty tag", "[]" }, dummySourceLineInfo) -InternalBenchmark.tests.cpp:: passed: erfc_inv(1.103560) == Approx(-0.09203687623843015) for: -0.0920368762 == Approx( -0.0920368762 ) -InternalBenchmark.tests.cpp:: passed: erfc_inv(1.067400) == Approx(-0.05980291115763361) for: -0.0598029112 == Approx( -0.0598029112 ) -InternalBenchmark.tests.cpp:: passed: erfc_inv(0.050000) == Approx(1.38590382434967796) for: 1.3859038243 == Approx( 1.3859038243 ) +InternalBenchmark.tests.cpp:: passed: erfc_inv(1.103560) == Approx(-0.09203687623843015) for: -0.09203687623843014 +== +Approx( -0.09203687623843015 ) +InternalBenchmark.tests.cpp:: passed: erfc_inv(1.067400) == Approx(-0.05980291115763361) for: -0.05980291115763361 +== +Approx( -0.05980291115763361 ) +InternalBenchmark.tests.cpp:: passed: erfc_inv(0.050000) == Approx(1.38590382434967796) for: 1.38590382434967774 +== +Approx( 1.38590382434967796 ) InternalBenchmark.tests.cpp:: passed: res.mean.count() == rate for: 2000.0 == 2000 (0x) InternalBenchmark.tests.cpp:: passed: res.outliers.total() == 0 for: 0 == 0 Misc.tests.cpp:: passed: @@ -2425,14 +2581,15 @@ Misc.tests.cpp:: passed: a != b for: 1 != 2 Skip.tests.cpp:: skipped: Tricky.tests.cpp:: passed: s == "7" for: "7" == "7" Tricky.tests.cpp:: passed: ti == typeid(int) for: {?} == {?} -InternalBenchmark.tests.cpp:: passed: normal_cdf(0.000000) == Approx(0.50000000000000000) for: 0.5 == Approx( 0.5 ) -InternalBenchmark.tests.cpp:: passed: normal_cdf(1.000000) == Approx(0.84134474606854293) for: 0.8413447461 == Approx( 0.8413447461 ) -InternalBenchmark.tests.cpp:: passed: normal_cdf(-1.000000) == Approx(0.15865525393145705) for: 0.1586552539 == Approx( 0.1586552539 ) -InternalBenchmark.tests.cpp:: passed: normal_cdf(2.809729) == Approx(0.99752083845315409) for: 0.9975208385 == Approx( 0.9975208385 ) -InternalBenchmark.tests.cpp:: passed: normal_cdf(-1.352570) == Approx(0.08809652095066035) for: 0.088096521 == Approx( 0.088096521 ) -InternalBenchmark.tests.cpp:: passed: normal_quantile(0.551780) == Approx(0.13015979861484198) for: 0.1301597986 == Approx( 0.1301597986 ) -InternalBenchmark.tests.cpp:: passed: normal_quantile(0.533700) == Approx(0.08457408802851875) for: 0.084574088 == Approx( 0.084574088 ) -InternalBenchmark.tests.cpp:: passed: normal_quantile(0.025000) == Approx(-1.95996398454005449) for: -1.9599639845 == Approx( -1.9599639845 ) +InternalBenchmark.tests.cpp:: passed: normal_quantile(0.551780) == Approx(0.13015979861484198) for: 0.13015979861484195 +== +Approx( 0.13015979861484198 ) +InternalBenchmark.tests.cpp:: passed: normal_quantile(0.533700) == Approx(0.08457408802851875) for: 0.08457408802851875 +== +Approx( 0.08457408802851875 ) +InternalBenchmark.tests.cpp:: passed: normal_quantile(0.025000) == Approx(-1.95996398454005449) for: -1.95996398454005405 +== +Approx( -1.95996398454005449 ) Misc.tests.cpp:: passed: Message.tests.cpp:: passed: true with 1 message: 'this MAY be seen only for the FIRST assertion IF info is printed for passing assertions' Message.tests.cpp:: passed: true with 1 message: 'this MAY be seen only for the SECOND assertion IF info is printed for passing assertions' @@ -2472,6 +2629,10 @@ StringManip.tests.cpp:: passed: Catch::replaceInPlace(letters, lett StringManip.tests.cpp:: passed: letters == "replaced" for: "replaced" == "replaced" StringManip.tests.cpp:: passed: !(Catch::replaceInPlace(letters, "x", "z")) for: !false StringManip.tests.cpp:: passed: letters == letters for: "abcdefcg" == "abcdefcg" +StringManip.tests.cpp:: passed: Catch::replaceInPlace(letters, "c", "cc") for: true +StringManip.tests.cpp:: passed: letters == "abccdefccg" for: "abccdefccg" == "abccdefccg" +StringManip.tests.cpp:: passed: Catch::replaceInPlace(s, "--", "-") for: true +StringManip.tests.cpp:: passed: s == "--" for: "--" == "--" StringManip.tests.cpp:: passed: Catch::replaceInPlace(s, "'", "|'") for: true StringManip.tests.cpp:: passed: s == "didn|'t" for: "didn|'t" == "didn|'t" Stream.tests.cpp:: passed: Catch::makeStream( "%somestream" ) @@ -2598,19 +2759,19 @@ EnumToString.tests.cpp:: passed: ::Catch::Detail::stringify(e0) == EnumToString.tests.cpp:: passed: ::Catch::Detail::stringify(e1) == "1" for: "1" == "1" ToStringTuple.tests.cpp:: passed: "{ }" == ::Catch::Detail::stringify(type{}) for: "{ }" == "{ }" ToStringTuple.tests.cpp:: passed: "{ }" == ::Catch::Detail::stringify(value) for: "{ }" == "{ }" -ToStringTuple.tests.cpp:: passed: "1.2f" == ::Catch::Detail::stringify(float(1.2)) for: "1.2f" == "1.2f" -ToStringTuple.tests.cpp:: passed: "{ 1.2f, 0 }" == ::Catch::Detail::stringify(type{1.2f,0}) for: "{ 1.2f, 0 }" == "{ 1.2f, 0 }" +ToStringTuple.tests.cpp:: passed: "1.5f" == ::Catch::Detail::stringify(float(1.5)) for: "1.5f" == "1.5f" +ToStringTuple.tests.cpp:: passed: "{ 1.5f, 0 }" == ::Catch::Detail::stringify(type{1.5f,0}) for: "{ 1.5f, 0 }" == "{ 1.5f, 0 }" ToStringTuple.tests.cpp:: passed: "{ 0 }" == ::Catch::Detail::stringify(type{0}) for: "{ 0 }" == "{ 0 }" ToStringTuple.tests.cpp:: passed: "{ \"hello\", \"world\" }" == ::Catch::Detail::stringify(type{"hello","world"}) for: "{ "hello", "world" }" == "{ "hello", "world" }" -ToStringTuple.tests.cpp:: passed: "{ { 42 }, { }, 1.2f }" == ::Catch::Detail::stringify(value) for: "{ { 42 }, { }, 1.2f }" +ToStringTuple.tests.cpp:: passed: "{ { 42 }, { }, 1.5f }" == ::Catch::Detail::stringify(value) for: "{ { 42 }, { }, 1.5f }" == -"{ { 42 }, { }, 1.2f }" +"{ { 42 }, { }, 1.5f }" InternalBenchmark.tests.cpp:: passed: e.point == 23 for: 23.0 == 23 InternalBenchmark.tests.cpp:: passed: e.upper_bound == 23 for: 23.0 == 23 InternalBenchmark.tests.cpp:: passed: e.lower_bound == 23 for: 23.0 == 23 -InternalBenchmark.tests.cpp:: passed: e.confidence_interval == 0.95 for: 0.95 == 0.95 +InternalBenchmark.tests.cpp:: passed: e.confidence_interval == 0.95 for: 0.94999999999999996 == 0.94999999999999996 RandomNumberGeneration.tests.cpp:: passed: dist.a() == -10 for: -10 == -10 RandomNumberGeneration.tests.cpp:: passed: dist.b() == 10 for: 10 == 10 UniquePtr.tests.cpp:: passed: !(ptr) for: !{?} @@ -2678,7 +2839,7 @@ InternalBenchmark.tests.cpp:: passed: med == 18. for: 18.0 == 18.0 InternalBenchmark.tests.cpp:: passed: q3 == 23. for: 23.0 == 23.0 Misc.tests.cpp:: passed: Misc.tests.cpp:: passed: -test cases: 417 | 312 passed | 85 failed | 6 skipped | 14 failed as expected -assertions: 2260 | 2079 passed | 146 failed | 35 failed as expected +test cases: 419 | 313 passed | 86 failed | 6 skipped | 14 failed as expected +assertions: 2265 | 2083 passed | 147 failed | 35 failed as expected diff --git a/tests/SelfTest/Baselines/console.std.approved.txt b/tests/SelfTest/Baselines/console.std.approved.txt index 2542625656..1003e549af 100644 --- a/tests/SelfTest/Baselines/console.std.approved.txt +++ b/tests/SelfTest/Baselines/console.std.approved.txt @@ -297,6 +297,18 @@ Class.tests.cpp:: FAILED: with expansion: 1 == 2 +------------------------------------------------------------------------------- +A TEST_CASE_PERSISTENT_FIXTURE based test run that fails + Second partial run +------------------------------------------------------------------------------- +Class.tests.cpp: +............................................................................... + +Class.tests.cpp:: FAILED: + REQUIRE( m_a == 0 ) +with expansion: + 1 == 0 + ------------------------------------------------------------------------------- A couple of nested sections followed by a failure ------------------------------------------------------------------------------- @@ -434,27 +446,31 @@ with expansion: Condition.tests.cpp:: FAILED: CHECK( data.float_nine_point_one == Approx( 9.11f ) ) with expansion: - 9.1f == Approx( 9.1099996567 ) + 9.100000381f + == + Approx( 9.10999965667724609 ) Condition.tests.cpp:: FAILED: CHECK( data.float_nine_point_one == Approx( 9.0f ) ) with expansion: - 9.1f == Approx( 9.0 ) + 9.100000381f == Approx( 9.0 ) Condition.tests.cpp:: FAILED: CHECK( data.float_nine_point_one == Approx( 1 ) ) with expansion: - 9.1f == Approx( 1.0 ) + 9.100000381f == Approx( 1.0 ) Condition.tests.cpp:: FAILED: CHECK( data.float_nine_point_one == Approx( 0 ) ) with expansion: - 9.1f == Approx( 0.0 ) + 9.100000381f == Approx( 0.0 ) Condition.tests.cpp:: FAILED: CHECK( data.double_pi == Approx( 3.1415 ) ) with expansion: - 3.1415926535 == Approx( 3.1415 ) + 3.14159265350000005 + == + Approx( 3.14150000000000018 ) Condition.tests.cpp:: FAILED: CHECK( data.str_hello == "goodbye" ) @@ -479,7 +495,9 @@ with expansion: Condition.tests.cpp:: FAILED: CHECK( x == Approx( 1.301 ) ) with expansion: - 1.3 == Approx( 1.301 ) + 1.30000000000000027 + == + Approx( 1.30099999999999993 ) ------------------------------------------------------------------------------- Equals string matcher @@ -696,12 +714,16 @@ with expansion: Condition.tests.cpp:: FAILED: CHECK( data.float_nine_point_one != Approx( 9.1f ) ) with expansion: - 9.1f != Approx( 9.1000003815 ) + 9.100000381f + != + Approx( 9.10000038146972656 ) Condition.tests.cpp:: FAILED: CHECK( data.double_pi != Approx( 3.1415926535 ) ) with expansion: - 3.1415926535 != Approx( 3.1415926535 ) + 3.14159265350000005 + != + Approx( 3.14159265350000005 ) Condition.tests.cpp:: FAILED: CHECK( data.str_hello != "hello" ) @@ -855,17 +877,17 @@ with expansion: Condition.tests.cpp:: FAILED: CHECK( data.float_nine_point_one < 9 ) with expansion: - 9.1f < 9 + 9.100000381f < 9 Condition.tests.cpp:: FAILED: CHECK( data.float_nine_point_one > 10 ) with expansion: - 9.1f > 10 + 9.100000381f > 10 Condition.tests.cpp:: FAILED: CHECK( data.float_nine_point_one > 9.2 ) with expansion: - 9.1f > 9.2 + 9.100000381f > 9.19999999999999929 Condition.tests.cpp:: FAILED: CHECK( data.str_hello > "hello" ) @@ -1060,7 +1082,7 @@ Exception.tests.cpp: Exception.tests.cpp:: FAILED: due to unexpected exception with message: - 3.14 + 3.14000000000000012 ------------------------------------------------------------------------------- Vector Approx matcher -- failing @@ -1588,6 +1610,6 @@ due to unexpected exception with message: Why would you throw a std::string? =============================================================================== -test cases: 417 | 326 passed | 70 failed | 7 skipped | 14 failed as expected -assertions: 2243 | 2079 passed | 129 failed | 35 failed as expected +test cases: 419 | 327 passed | 71 failed | 7 skipped | 14 failed as expected +assertions: 2248 | 2083 passed | 130 failed | 35 failed as expected diff --git a/tests/SelfTest/Baselines/console.sw.approved.txt b/tests/SelfTest/Baselines/console.sw.approved.txt index 077b7bf750..3519b7716a 100644 --- a/tests/SelfTest/Baselines/console.sw.approved.txt +++ b/tests/SelfTest/Baselines/console.sw.approved.txt @@ -2023,6 +2023,54 @@ A TEST_CASE_METHOD based test run that succeeds Class.tests.cpp: ............................................................................... +Class.tests.cpp:: PASSED: + REQUIRE( m_a == 1 ) +with expansion: + 1 == 1 + +------------------------------------------------------------------------------- +A TEST_CASE_PERSISTENT_FIXTURE based test run that fails + First partial run +------------------------------------------------------------------------------- +Class.tests.cpp: +............................................................................... + +Class.tests.cpp:: PASSED: + REQUIRE( m_a++ == 0 ) +with expansion: + 0 == 0 + +------------------------------------------------------------------------------- +A TEST_CASE_PERSISTENT_FIXTURE based test run that fails + Second partial run +------------------------------------------------------------------------------- +Class.tests.cpp: +............................................................................... + +Class.tests.cpp:: FAILED: + REQUIRE( m_a == 0 ) +with expansion: + 1 == 0 + +------------------------------------------------------------------------------- +A TEST_CASE_PERSISTENT_FIXTURE based test run that succeeds + First partial run +------------------------------------------------------------------------------- +Class.tests.cpp: +............................................................................... + +Class.tests.cpp:: PASSED: + REQUIRE( m_a++ == 0 ) +with expansion: + 0 == 0 + +------------------------------------------------------------------------------- +A TEST_CASE_PERSISTENT_FIXTURE based test run that succeeds + Second partial run +------------------------------------------------------------------------------- +Class.tests.cpp: +............................................................................... + Class.tests.cpp:: PASSED: REQUIRE( m_a == 1 ) with expansion: @@ -2125,32 +2173,42 @@ Approx.tests.cpp: Approx.tests.cpp:: PASSED: REQUIRE( d == 1.23_a ) with expansion: - 1.23 == Approx( 1.23 ) + 1.22999999999999998 + == + Approx( 1.22999999999999998 ) Approx.tests.cpp:: PASSED: REQUIRE( d != 1.22_a ) with expansion: - 1.23 != Approx( 1.22 ) + 1.22999999999999998 + != + Approx( 1.21999999999999997 ) Approx.tests.cpp:: PASSED: REQUIRE( -d == -1.23_a ) with expansion: - -1.23 == Approx( -1.23 ) + -1.22999999999999998 + == + Approx( -1.22999999999999998 ) Approx.tests.cpp:: PASSED: REQUIRE( d == 1.2_a .epsilon(.1) ) with expansion: - 1.23 == Approx( 1.2 ) + 1.22999999999999998 + == + Approx( 1.19999999999999996 ) Approx.tests.cpp:: PASSED: REQUIRE( d != 1.2_a .epsilon(.001) ) with expansion: - 1.23 != Approx( 1.2 ) + 1.22999999999999998 + != + Approx( 1.19999999999999996 ) Approx.tests.cpp:: PASSED: REQUIRE( d == 1_a .epsilon(.3) ) with expansion: - 1.23 == Approx( 1.0 ) + 1.22999999999999998 == Approx( 1.0 ) ------------------------------------------------------------------------------- A couple of nested sections followed by a failure @@ -2219,12 +2277,12 @@ with expansion: Approx.tests.cpp:: PASSED: REQUIRE( 100.3 != Approx(100.0) ) with expansion: - 100.3 != Approx( 100.0 ) + 100.29999999999999716 != Approx( 100.0 ) Approx.tests.cpp:: PASSED: REQUIRE( 100.3 == Approx(100.0).margin(0.5) ) with expansion: - 100.3 == Approx( 100.0 ) + 100.29999999999999716 == Approx( 100.0 ) ------------------------------------------------------------------------------- An empty test with no assertions @@ -2342,12 +2400,16 @@ Approx.tests.cpp: Approx.tests.cpp:: PASSED: REQUIRE( divide( 22, 7 ) == Approx( 3.141 ).epsilon( 0.001 ) ) with expansion: - 3.1428571429 == Approx( 3.141 ) + 3.14285714285714279 + == + Approx( 3.14100000000000001 ) Approx.tests.cpp:: PASSED: REQUIRE( divide( 22, 7 ) != Approx( 3.141 ).epsilon( 0.0001 ) ) with expansion: - 3.1428571429 != Approx( 3.141 ) + 3.14285714285714279 + != + Approx( 3.14100000000000001 ) ------------------------------------------------------------------------------- Approximate comparisons with different epsilons @@ -2358,12 +2420,16 @@ Approx.tests.cpp: Approx.tests.cpp:: PASSED: REQUIRE( d != Approx( 1.231 ) ) with expansion: - 1.23 != Approx( 1.231 ) + 1.22999999999999998 + != + Approx( 1.23100000000000009 ) Approx.tests.cpp:: PASSED: REQUIRE( d == Approx( 1.231 ).epsilon( 0.1 ) ) with expansion: - 1.23 == Approx( 1.231 ) + 1.22999999999999998 + == + Approx( 1.23100000000000009 ) ------------------------------------------------------------------------------- Approximate comparisons with floats @@ -2374,7 +2440,9 @@ Approx.tests.cpp: Approx.tests.cpp:: PASSED: REQUIRE( 1.23f == Approx( 1.23f ) ) with expansion: - 1.23f == Approx( 1.2300000191 ) + 1.230000019f + == + Approx( 1.23000001907348633 ) Approx.tests.cpp:: PASSED: REQUIRE( 0.0f == Approx( 0.0f ) ) @@ -2421,12 +2489,16 @@ with expansion: Approx.tests.cpp:: PASSED: REQUIRE( 1.234f == Approx( dMedium ) ) with expansion: - 1.234f == Approx( 1.234 ) + 1.233999968f + == + Approx( 1.23399999999999999 ) Approx.tests.cpp:: PASSED: REQUIRE( dMedium == Approx( 1.234f ) ) with expansion: - 1.234 == Approx( 1.2339999676 ) + 1.23399999999999999 + == + Approx( 1.23399996757507324 ) ------------------------------------------------------------------------------- Arbitrary predicate matcher @@ -2904,24 +2976,24 @@ ToStringGeneral.tests.cpp: ............................................................................... ToStringGeneral.tests.cpp:: PASSED: - CHECK( tab == '\t' ) + CHECK( ::Catch::Detail::stringify('\t') == "'\\t'" ) with expansion: - '\t' == '\t' + "'\t'" == "'\t'" ToStringGeneral.tests.cpp:: PASSED: - CHECK( newline == '\n' ) + CHECK( ::Catch::Detail::stringify('\n') == "'\\n'" ) with expansion: - '\n' == '\n' + "'\n'" == "'\n'" ToStringGeneral.tests.cpp:: PASSED: - CHECK( carr_return == '\r' ) + CHECK( ::Catch::Detail::stringify('\r') == "'\\r'" ) with expansion: - '\r' == '\r' + "'\r'" == "'\r'" ToStringGeneral.tests.cpp:: PASSED: - CHECK( form_feed == '\f' ) + CHECK( ::Catch::Detail::stringify('\f') == "'\\f'" ) with expansion: - '\f' == '\f' + "'\f'" == "'\f'" ------------------------------------------------------------------------------- Character pretty printing @@ -2931,29 +3003,19 @@ ToStringGeneral.tests.cpp: ............................................................................... ToStringGeneral.tests.cpp:: PASSED: - CHECK( space == ' ' ) -with expansion: - ' ' == ' ' - -ToStringGeneral.tests.cpp:: PASSED: - REQUIRE( c == chars[i] ) + CHECK( ::Catch::Detail::stringify( ' ' ) == "' '" ) with expansion: - 'a' == 'a' + "' '" == "' '" ToStringGeneral.tests.cpp:: PASSED: - REQUIRE( c == chars[i] ) + CHECK( ::Catch::Detail::stringify( 'A' ) == "'A'" ) with expansion: - 'z' == 'z' + "'A'" == "'A'" ToStringGeneral.tests.cpp:: PASSED: - REQUIRE( c == chars[i] ) + CHECK( ::Catch::Detail::stringify( 'z' ) == "'z'" ) with expansion: - 'A' == 'A' - -ToStringGeneral.tests.cpp:: PASSED: - REQUIRE( c == chars[i] ) -with expansion: - 'Z' == 'Z' + "'z'" == "'z'" ------------------------------------------------------------------------------- Character pretty printing @@ -2963,29 +3025,55 @@ ToStringGeneral.tests.cpp: ............................................................................... ToStringGeneral.tests.cpp:: PASSED: - CHECK( null_terminator == '\0' ) + CHECK( ::Catch::Detail::stringify( '\0' ) == "0" ) with expansion: - 0 == 0 + "0" == "0" ToStringGeneral.tests.cpp:: PASSED: - REQUIRE( c == i ) + CHECK( ::Catch::Detail::stringify( static_cast(2) ) == "2" ) with expansion: - 2 == 2 + "2" == "2" ToStringGeneral.tests.cpp:: PASSED: - REQUIRE( c == i ) + CHECK( ::Catch::Detail::stringify( static_cast(5) ) == "5" ) with expansion: - 3 == 3 + "5" == "5" -ToStringGeneral.tests.cpp:: PASSED: - REQUIRE( c == i ) +------------------------------------------------------------------------------- +Clara::Arg does not crash on incomplete input +------------------------------------------------------------------------------- +Clara.tests.cpp: +............................................................................... + +Clara.tests.cpp:: PASSED: + CHECK( name.empty() ) with expansion: - 4 == 4 + true -ToStringGeneral.tests.cpp:: PASSED: - REQUIRE( c == i ) +Clara.tests.cpp:: PASSED: + CHECK( result ) with expansion: - 5 == 5 + {?} + +Clara.tests.cpp:: PASSED: + CHECK( result.type() == Catch::Clara::Detail::ResultType::Ok ) +with expansion: + 0 == 0 + +Clara.tests.cpp:: PASSED: + CHECK( parsed.type() == Catch::Clara::ParseResultType::NoMatch ) +with expansion: + 1 == 1 + +Clara.tests.cpp:: PASSED: + CHECK( parsed.remainingTokens().count() == 2 ) +with expansion: + 2 == 2 + +Clara.tests.cpp:: PASSED: + CHECK( name.empty() ) +with expansion: + true ------------------------------------------------------------------------------- Clara::Arg supports single-arg parse the way Opt does @@ -3926,7 +4014,7 @@ Approx.tests.cpp: Approx.tests.cpp:: PASSED: REQUIRE( 101.000001 != Approx(100).epsilon(0.01) ) with expansion: - 101.000001 != Approx( 100.0 ) + 101.00000099999999748 != Approx( 100.0 ) Approx.tests.cpp:: PASSED: REQUIRE( std::pow(10, -5) != Approx(std::pow(10, -7)) ) @@ -4053,7 +4141,7 @@ Approx.tests.cpp: Approx.tests.cpp:: PASSED: REQUIRE( 101.01 != Approx(100).epsilon(0.01) ) with expansion: - 101.01 != Approx( 100.0 ) + 101.01000000000000512 != Approx( 100.0 ) ------------------------------------------------------------------------------- Equality checks that should fail @@ -4079,27 +4167,31 @@ with expansion: Condition.tests.cpp:: FAILED: CHECK( data.float_nine_point_one == Approx( 9.11f ) ) with expansion: - 9.1f == Approx( 9.1099996567 ) + 9.100000381f + == + Approx( 9.10999965667724609 ) Condition.tests.cpp:: FAILED: CHECK( data.float_nine_point_one == Approx( 9.0f ) ) with expansion: - 9.1f == Approx( 9.0 ) + 9.100000381f == Approx( 9.0 ) Condition.tests.cpp:: FAILED: CHECK( data.float_nine_point_one == Approx( 1 ) ) with expansion: - 9.1f == Approx( 1.0 ) + 9.100000381f == Approx( 1.0 ) Condition.tests.cpp:: FAILED: CHECK( data.float_nine_point_one == Approx( 0 ) ) with expansion: - 9.1f == Approx( 0.0 ) + 9.100000381f == Approx( 0.0 ) Condition.tests.cpp:: FAILED: CHECK( data.double_pi == Approx( 3.1415 ) ) with expansion: - 3.1415926535 == Approx( 3.1415 ) + 3.14159265350000005 + == + Approx( 3.14150000000000018 ) Condition.tests.cpp:: FAILED: CHECK( data.str_hello == "goodbye" ) @@ -4124,7 +4216,9 @@ with expansion: Condition.tests.cpp:: FAILED: CHECK( x == Approx( 1.301 ) ) with expansion: - 1.3 == Approx( 1.301 ) + 1.30000000000000027 + == + Approx( 1.30099999999999993 ) ------------------------------------------------------------------------------- Equality checks that should succeed @@ -4140,12 +4234,16 @@ with expansion: Condition.tests.cpp:: PASSED: REQUIRE( data.float_nine_point_one == Approx( 9.1f ) ) with expansion: - 9.1f == Approx( 9.1000003815 ) + 9.100000381f + == + Approx( 9.10000038146972656 ) Condition.tests.cpp:: PASSED: REQUIRE( data.double_pi == Approx( 3.1415926535 ) ) with expansion: - 3.1415926535 == Approx( 3.1415926535 ) + 3.14159265350000005 + == + Approx( 3.14159265350000005 ) Condition.tests.cpp:: PASSED: REQUIRE( data.str_hello == "hello" ) @@ -4165,7 +4263,9 @@ with expansion: Condition.tests.cpp:: PASSED: REQUIRE( x == Approx( 1.3 ) ) with expansion: - 1.3 == Approx( 1.3 ) + 1.30000000000000027 + == + Approx( 1.30000000000000004 ) ------------------------------------------------------------------------------- Equals @@ -4497,22 +4597,22 @@ Matchers.tests.cpp: Matchers.tests.cpp:: PASSED: REQUIRE_THAT( 10., WithinRel( 11.1, 0.1 ) ) with expansion: - 10.0 and 11.1 are within 10% of each other + 10.0 and 11.09999999999999964 are within 10% of each other Matchers.tests.cpp:: PASSED: REQUIRE_THAT( 10., !WithinRel( 11.2, 0.1 ) ) with expansion: - 10.0 not and 11.2 are within 10% of each other + 10.0 not and 11.19999999999999929 are within 10% of each other Matchers.tests.cpp:: PASSED: REQUIRE_THAT( 1., !WithinRel( 0., 0.99 ) ) with expansion: - 1.0 not and 0 are within 99% of each other + 1.0 not and 0.0 are within 99% of each other Matchers.tests.cpp:: PASSED: REQUIRE_THAT( -0., WithinRel( 0. ) ) with expansion: - -0.0 and 0 are within 2.22045e-12% of each other + -0.0 and 0.0 are within 2.22045e-12% of each other ------------------------------------------------------------------------------- Floating point matchers: double @@ -4525,7 +4625,7 @@ Matchers.tests.cpp: Matchers.tests.cpp:: PASSED: REQUIRE_THAT( v1, WithinRel( v2 ) ) with expansion: - 0.0 and 2.22507e-308 are within 2.22045e-12% of each other + 0.0 and 0.0 are within 2.22045e-12% of each other ------------------------------------------------------------------------------- Floating point matchers: double @@ -4547,12 +4647,12 @@ with expansion: Matchers.tests.cpp:: PASSED: REQUIRE_THAT( 0., !WithinAbs( 1., 0.99 ) ) with expansion: - 0.0 not is within 0.99 of 1.0 + 0.0 not is within 0.98999999999999999 of 1.0 Matchers.tests.cpp:: PASSED: REQUIRE_THAT( 0., !WithinAbs( 1., 0.99 ) ) with expansion: - 0.0 not is within 0.99 of 1.0 + 0.0 not is within 0.98999999999999999 of 1.0 Matchers.tests.cpp:: PASSED: REQUIRE_THAT( 11., !WithinAbs( 10., 0.5 ) ) @@ -4572,7 +4672,7 @@ with expansion: Matchers.tests.cpp:: PASSED: REQUIRE_THAT( -10., WithinAbs( -9.6, 0.5 ) ) with expansion: - -10.0 is within 0.5 of -9.6 + -10.0 is within 0.5 of -9.59999999999999964 ------------------------------------------------------------------------------- Floating point matchers: double @@ -4590,8 +4690,8 @@ with expansion: Matchers.tests.cpp:: PASSED: REQUIRE_THAT( nextafter( 1., 2. ), WithinULP( 1., 1 ) ) with expansion: - 1.0 is within 1 ULPs of 1.0000000000000000e+00 ([9.9999999999999989e-01, 1. - 0000000000000002e+00]) + 1.00000000000000022 is within 1 ULPs of 1.0000000000000000e+00 ([9. + 9999999999999989e-01, 1.0000000000000002e+00]) Matchers.tests.cpp:: PASSED: REQUIRE_THAT( 0., WithinULP( nextafter( 0., 1. ), 1 ) ) @@ -4645,7 +4745,7 @@ with expansion: Matchers.tests.cpp:: PASSED: REQUIRE_THAT( 0.0001, WithinAbs( 0., 0.001 ) || WithinRel( 0., 0.1 ) ) with expansion: - 0.0001 ( is within 0.001 of 0.0 or and 0 are within 10% of each other ) + 0.0001 ( is within 0.001 of 0.0 or and 0.0 are within 10% of each other ) ------------------------------------------------------------------------------- Floating point matchers: double @@ -4694,22 +4794,22 @@ Matchers.tests.cpp: Matchers.tests.cpp:: PASSED: REQUIRE_THAT( 10.f, WithinRel( 11.1f, 0.1f ) ) with expansion: - 10.0f and 11.1 are within 10% of each other + 10.0f and 11.10000038146972656 are within 10% of each other Matchers.tests.cpp:: PASSED: REQUIRE_THAT( 10.f, !WithinRel( 11.2f, 0.1f ) ) with expansion: - 10.0f not and 11.2 are within 10% of each other + 10.0f not and 11.19999980926513672 are within 10% of each other Matchers.tests.cpp:: PASSED: REQUIRE_THAT( 1.f, !WithinRel( 0.f, 0.99f ) ) with expansion: - 1.0f not and 0 are within 99% of each other + 1.0f not and 0.0 are within 99% of each other Matchers.tests.cpp:: PASSED: REQUIRE_THAT( -0.f, WithinRel( 0.f ) ) with expansion: - -0.0f and 0 are within 0.00119209% of each other + -0.0f and 0.0 are within 0.00119209% of each other ------------------------------------------------------------------------------- Floating point matchers: float @@ -4722,7 +4822,7 @@ Matchers.tests.cpp: Matchers.tests.cpp:: PASSED: REQUIRE_THAT( v1, WithinRel( v2 ) ) with expansion: - 0.0f and 1.17549e-38 are within 0.00119209% of each other + 0.0f and 0.0 are within 0.00119209% of each other ------------------------------------------------------------------------------- Floating point matchers: float @@ -4744,12 +4844,12 @@ with expansion: Matchers.tests.cpp:: PASSED: REQUIRE_THAT( 0.f, !WithinAbs( 1.f, 0.99f ) ) with expansion: - 0.0f not is within 0.9900000095 of 1.0 + 0.0f not is within 0.99000000953674316 of 1.0 Matchers.tests.cpp:: PASSED: REQUIRE_THAT( 0.f, !WithinAbs( 1.f, 0.99f ) ) with expansion: - 0.0f not is within 0.9900000095 of 1.0 + 0.0f not is within 0.99000000953674316 of 1.0 Matchers.tests.cpp:: PASSED: REQUIRE_THAT( 0.f, WithinAbs( -0.f, 0 ) ) @@ -4774,7 +4874,7 @@ with expansion: Matchers.tests.cpp:: PASSED: REQUIRE_THAT( -10.f, WithinAbs( -9.6f, 0.5f ) ) with expansion: - -10.0f is within 0.5 of -9.6000003815 + -10.0f is within 0.5 of -9.60000038146972656 ------------------------------------------------------------------------------- Floating point matchers: float @@ -4797,7 +4897,8 @@ with expansion: Matchers.tests.cpp:: PASSED: REQUIRE_THAT( nextafter( 1.f, 2.f ), WithinULP( 1.f, 1 ) ) with expansion: - 1.0f is within 1 ULPs of 1.00000000e+00f ([9.99999940e-01, 1.00000012e+00]) + 1.000000119f is within 1 ULPs of 1.00000000e+00f ([9.99999940e-01, 1. + 00000012e+00]) Matchers.tests.cpp:: PASSED: REQUIRE_THAT( 0.f, WithinULP( nextafter( 0.f, 1.f ), 1 ) ) @@ -4847,7 +4948,8 @@ with expansion: Matchers.tests.cpp:: PASSED: REQUIRE_THAT( 0.0001f, WithinAbs( 0.f, 0.001f ) || WithinRel( 0.f, 0.1f ) ) with expansion: - 0.0001f ( is within 0.001 of 0.0 or and 0 are within 10% of each other ) + 0.0001f ( is within 0.00100000004749745 of 0.0 or and 0.0 are within 10% of + each other ) ------------------------------------------------------------------------------- Floating point matchers: float @@ -6288,7 +6390,9 @@ with message: GeneratorsImpl.tests.cpp:: PASSED: REQUIRE( gen.get() == Approx(expected) ) with expansion: - -0.9 == Approx( -0.9 ) + -0.90000000000000002 + == + Approx( -0.90000000000000002 ) with message: Current expected value is -0.9 @@ -6302,7 +6406,9 @@ with message: GeneratorsImpl.tests.cpp:: PASSED: REQUIRE( gen.get() == Approx(expected) ) with expansion: - -0.8 == Approx( -0.8 ) + -0.80000000000000004 + == + Approx( -0.80000000000000004 ) with message: Current expected value is -0.8 @@ -6316,7 +6422,9 @@ with message: GeneratorsImpl.tests.cpp:: PASSED: REQUIRE( gen.get() == Approx(expected) ) with expansion: - -0.7 == Approx( -0.7 ) + -0.70000000000000007 + == + Approx( -0.70000000000000007 ) with message: Current expected value is -0.7 @@ -6330,7 +6438,9 @@ with message: GeneratorsImpl.tests.cpp:: PASSED: REQUIRE( gen.get() == Approx(expected) ) with expansion: - -0.6 == Approx( -0.6 ) + -0.60000000000000009 + == + Approx( -0.60000000000000009 ) with message: Current expected value is -0.6 @@ -6344,7 +6454,9 @@ with message: GeneratorsImpl.tests.cpp:: PASSED: REQUIRE( gen.get() == Approx(expected) ) with expansion: - -0.5 == Approx( -0.5 ) + -0.50000000000000011 + == + Approx( -0.50000000000000011 ) with message: Current expected value is -0.5 @@ -6358,7 +6470,9 @@ with message: GeneratorsImpl.tests.cpp:: PASSED: REQUIRE( gen.get() == Approx(expected) ) with expansion: - -0.4 == Approx( -0.4 ) + -0.40000000000000013 + == + Approx( -0.40000000000000013 ) with message: Current expected value is -0.4 @@ -6372,7 +6486,9 @@ with message: GeneratorsImpl.tests.cpp:: PASSED: REQUIRE( gen.get() == Approx(expected) ) with expansion: - -0.3 == Approx( -0.3 ) + -0.30000000000000016 + == + Approx( -0.30000000000000016 ) with message: Current expected value is -0.3 @@ -6386,7 +6502,9 @@ with message: GeneratorsImpl.tests.cpp:: PASSED: REQUIRE( gen.get() == Approx(expected) ) with expansion: - -0.2 == Approx( -0.2 ) + -0.20000000000000015 + == + Approx( -0.20000000000000015 ) with message: Current expected value is -0.2 @@ -6400,7 +6518,9 @@ with message: GeneratorsImpl.tests.cpp:: PASSED: REQUIRE( gen.get() == Approx(expected) ) with expansion: - -0.1 == Approx( -0.1 ) + -0.10000000000000014 + == + Approx( -0.10000000000000014 ) with message: Current expected value is -0.1 @@ -6414,7 +6534,9 @@ with message: GeneratorsImpl.tests.cpp:: PASSED: REQUIRE( gen.get() == Approx(expected) ) with expansion: - -0.0 == Approx( -0.0 ) + -0.00000000000000014 + == + Approx( -0.00000000000000014 ) with message: Current expected value is -1.38778e-16 @@ -6428,7 +6550,9 @@ with message: GeneratorsImpl.tests.cpp:: PASSED: REQUIRE( gen.get() == Approx(expected) ) with expansion: - 0.1 == Approx( 0.1 ) + 0.09999999999999987 + == + Approx( 0.09999999999999987 ) with message: Current expected value is 0.1 @@ -6442,7 +6566,9 @@ with message: GeneratorsImpl.tests.cpp:: PASSED: REQUIRE( gen.get() == Approx(expected) ) with expansion: - 0.2 == Approx( 0.2 ) + 0.19999999999999987 + == + Approx( 0.19999999999999987 ) with message: Current expected value is 0.2 @@ -6456,7 +6582,9 @@ with message: GeneratorsImpl.tests.cpp:: PASSED: REQUIRE( gen.get() == Approx(expected) ) with expansion: - 0.3 == Approx( 0.3 ) + 0.29999999999999988 + == + Approx( 0.29999999999999988 ) with message: Current expected value is 0.3 @@ -6470,7 +6598,9 @@ with message: GeneratorsImpl.tests.cpp:: PASSED: REQUIRE( gen.get() == Approx(expected) ) with expansion: - 0.4 == Approx( 0.4 ) + 0.39999999999999991 + == + Approx( 0.39999999999999991 ) with message: Current expected value is 0.4 @@ -6484,7 +6614,9 @@ with message: GeneratorsImpl.tests.cpp:: PASSED: REQUIRE( gen.get() == Approx(expected) ) with expansion: - 0.5 == Approx( 0.5 ) + 0.49999999999999989 + == + Approx( 0.49999999999999989 ) with message: Current expected value is 0.5 @@ -6498,7 +6630,9 @@ with message: GeneratorsImpl.tests.cpp:: PASSED: REQUIRE( gen.get() == Approx(expected) ) with expansion: - 0.6 == Approx( 0.6 ) + 0.59999999999999987 + == + Approx( 0.59999999999999987 ) with message: Current expected value is 0.6 @@ -6512,7 +6646,9 @@ with message: GeneratorsImpl.tests.cpp:: PASSED: REQUIRE( gen.get() == Approx(expected) ) with expansion: - 0.7 == Approx( 0.7 ) + 0.69999999999999984 + == + Approx( 0.69999999999999984 ) with message: Current expected value is 0.7 @@ -6526,7 +6662,9 @@ with message: GeneratorsImpl.tests.cpp:: PASSED: REQUIRE( gen.get() == Approx(expected) ) with expansion: - 0.8 == Approx( 0.8 ) + 0.79999999999999982 + == + Approx( 0.79999999999999982 ) with message: Current expected value is 0.8 @@ -6540,7 +6678,9 @@ with message: GeneratorsImpl.tests.cpp:: PASSED: REQUIRE( gen.get() == Approx(expected) ) with expansion: - 0.9 == Approx( 0.9 ) + 0.8999999999999998 + == + Approx( 0.8999999999999998 ) with message: Current expected value is 0.9 @@ -6554,7 +6694,7 @@ with message: GeneratorsImpl.tests.cpp:: PASSED: REQUIRE( gen.get() == Approx( rangeEnd ) ) with expansion: - 1.0 == Approx( 1.0 ) + 0.99999999999999978 == Approx( 1.0 ) GeneratorsImpl.tests.cpp:: PASSED: REQUIRE_FALSE( gen.next() ) @@ -6588,7 +6728,9 @@ with message: GeneratorsImpl.tests.cpp:: PASSED: REQUIRE( gen.get() == Approx(expected) ) with expansion: - -0.7 == Approx( -0.7 ) + -0.69999999999999996 + == + Approx( -0.69999999999999996 ) with message: Current expected value is -0.7 @@ -6602,7 +6744,9 @@ with message: GeneratorsImpl.tests.cpp:: PASSED: REQUIRE( gen.get() == Approx(expected) ) with expansion: - -0.4 == Approx( -0.4 ) + -0.39999999999999997 + == + Approx( -0.39999999999999997 ) with message: Current expected value is -0.4 @@ -6616,7 +6760,9 @@ with message: GeneratorsImpl.tests.cpp:: PASSED: REQUIRE( gen.get() == Approx(expected) ) with expansion: - -0.1 == Approx( -0.1 ) + -0.09999999999999998 + == + Approx( -0.09999999999999998 ) with message: Current expected value is -0.1 @@ -6630,7 +6776,9 @@ with message: GeneratorsImpl.tests.cpp:: PASSED: REQUIRE( gen.get() == Approx(expected) ) with expansion: - 0.2 == Approx( 0.2 ) + 0.20000000000000001 + == + Approx( 0.20000000000000001 ) with message: Current expected value is 0.2 @@ -6687,7 +6835,9 @@ with message: GeneratorsImpl.tests.cpp:: PASSED: REQUIRE( gen.get() == Approx(expected) ) with expansion: - -0.7 == Approx( -0.7 ) + -0.69999999999999996 + == + Approx( -0.69999999999999996 ) with message: Current expected value is -0.7 @@ -6701,7 +6851,9 @@ with message: GeneratorsImpl.tests.cpp:: PASSED: REQUIRE( gen.get() == Approx(expected) ) with expansion: - -0.4 == Approx( -0.4 ) + -0.39999999999999997 + == + Approx( -0.39999999999999997 ) with message: Current expected value is -0.4 @@ -6715,7 +6867,9 @@ with message: GeneratorsImpl.tests.cpp:: PASSED: REQUIRE( gen.get() == Approx(expected) ) with expansion: - -0.1 == Approx( -0.1 ) + -0.09999999999999998 + == + Approx( -0.09999999999999998 ) with message: Current expected value is -0.1 @@ -6729,7 +6883,9 @@ with message: GeneratorsImpl.tests.cpp:: PASSED: REQUIRE( gen.get() == Approx(expected) ) with expansion: - 0.2 == Approx( 0.2 ) + 0.20000000000000001 + == + Approx( 0.20000000000000001 ) with message: Current expected value is 0.2 @@ -6928,22 +7084,30 @@ Approx.tests.cpp: Approx.tests.cpp:: PASSED: REQUIRE( d >= Approx( 1.22 ) ) with expansion: - 1.23 >= Approx( 1.22 ) + 1.22999999999999998 + >= + Approx( 1.21999999999999997 ) Approx.tests.cpp:: PASSED: REQUIRE( d >= Approx( 1.23 ) ) with expansion: - 1.23 >= Approx( 1.23 ) + 1.22999999999999998 + >= + Approx( 1.22999999999999998 ) Approx.tests.cpp:: PASSED: REQUIRE_FALSE( d >= Approx( 1.24 ) ) with expansion: - !(1.23 >= Approx( 1.24 )) + !(1.22999999999999998 + >= + Approx( 1.23999999999999999 )) Approx.tests.cpp:: PASSED: REQUIRE( d >= Approx( 1.24 ).epsilon(0.1) ) with expansion: - 1.23 >= Approx( 1.24 ) + 1.22999999999999998 + >= + Approx( 1.23999999999999999 ) ------------------------------------------------------------------------------- Hashers with different seed produce different hash with same test case @@ -7224,12 +7388,16 @@ with expansion: Condition.tests.cpp:: FAILED: CHECK( data.float_nine_point_one != Approx( 9.1f ) ) with expansion: - 9.1f != Approx( 9.1000003815 ) + 9.100000381f + != + Approx( 9.10000038146972656 ) Condition.tests.cpp:: FAILED: CHECK( data.double_pi != Approx( 3.1415926535 ) ) with expansion: - 3.1415926535 != Approx( 3.1415926535 ) + 3.14159265350000005 + != + Approx( 3.14159265350000005 ) Condition.tests.cpp:: FAILED: CHECK( data.str_hello != "hello" ) @@ -7260,27 +7428,31 @@ with expansion: Condition.tests.cpp:: PASSED: REQUIRE( data.float_nine_point_one != Approx( 9.11f ) ) with expansion: - 9.1f != Approx( 9.1099996567 ) + 9.100000381f + != + Approx( 9.10999965667724609 ) Condition.tests.cpp:: PASSED: REQUIRE( data.float_nine_point_one != Approx( 9.0f ) ) with expansion: - 9.1f != Approx( 9.0 ) + 9.100000381f != Approx( 9.0 ) Condition.tests.cpp:: PASSED: REQUIRE( data.float_nine_point_one != Approx( 1 ) ) with expansion: - 9.1f != Approx( 1.0 ) + 9.100000381f != Approx( 1.0 ) Condition.tests.cpp:: PASSED: REQUIRE( data.float_nine_point_one != Approx( 0 ) ) with expansion: - 9.1f != Approx( 0.0 ) + 9.100000381f != Approx( 0.0 ) Condition.tests.cpp:: PASSED: REQUIRE( data.double_pi != Approx( 3.1415 ) ) with expansion: - 3.1415926535 != Approx( 3.1415 ) + 3.14159265350000005 + != + Approx( 3.14150000000000018 ) Condition.tests.cpp:: PASSED: REQUIRE( data.str_hello != "goodbye" ) @@ -7607,22 +7779,30 @@ Approx.tests.cpp: Approx.tests.cpp:: PASSED: REQUIRE( d <= Approx( 1.24 ) ) with expansion: - 1.23 <= Approx( 1.24 ) + 1.22999999999999998 + <= + Approx( 1.23999999999999999 ) Approx.tests.cpp:: PASSED: REQUIRE( d <= Approx( 1.23 ) ) with expansion: - 1.23 <= Approx( 1.23 ) + 1.22999999999999998 + <= + Approx( 1.22999999999999998 ) Approx.tests.cpp:: PASSED: REQUIRE_FALSE( d <= Approx( 1.22 ) ) with expansion: - !(1.23 <= Approx( 1.22 )) + !(1.22999999999999998 + <= + Approx( 1.21999999999999997 )) Approx.tests.cpp:: PASSED: REQUIRE( d <= Approx( 1.22 ).epsilon(0.1) ) with expansion: - 1.23 <= Approx( 1.22 ) + 1.22999999999999998 + <= + Approx( 1.21999999999999997 ) ------------------------------------------------------------------------------- ManuallyRegistered @@ -8175,17 +8355,17 @@ with expansion: Condition.tests.cpp:: FAILED: CHECK( data.float_nine_point_one < 9 ) with expansion: - 9.1f < 9 + 9.100000381f < 9 Condition.tests.cpp:: FAILED: CHECK( data.float_nine_point_one > 10 ) with expansion: - 9.1f > 10 + 9.100000381f > 10 Condition.tests.cpp:: FAILED: CHECK( data.float_nine_point_one > 9.2 ) with expansion: - 9.1f > 9.2 + 9.100000381f > 9.19999999999999929 Condition.tests.cpp:: FAILED: CHECK( data.str_hello > "hello" ) @@ -8276,17 +8456,17 @@ with expansion: Condition.tests.cpp:: PASSED: REQUIRE( data.float_nine_point_one > 9 ) with expansion: - 9.1f > 9 + 9.100000381f > 9 Condition.tests.cpp:: PASSED: REQUIRE( data.float_nine_point_one < 10 ) with expansion: - 9.1f < 10 + 9.100000381f < 10 Condition.tests.cpp:: PASSED: REQUIRE( data.float_nine_point_one < 9.2 ) with expansion: - 9.1f < 9.2 + 9.100000381f < 9.19999999999999929 Condition.tests.cpp:: PASSED: REQUIRE( data.str_hello <= "hello" ) @@ -9642,7 +9822,9 @@ with expansion: CmdLine.tests.cpp:: PASSED: REQUIRE( config.benchmarkConfidenceInterval == Catch::Approx(0.99) ) with expansion: - 0.99 == Approx( 0.99 ) + 0.98999999999999999 + == + Approx( 0.98999999999999999 ) ------------------------------------------------------------------------------- Process can be configured on command line @@ -10863,42 +11045,58 @@ Approx.tests.cpp: Approx.tests.cpp:: PASSED: REQUIRE( d == Approx( 1.23 ) ) with expansion: - 1.23 == Approx( 1.23 ) + 1.22999999999999998 + == + Approx( 1.22999999999999998 ) Approx.tests.cpp:: PASSED: REQUIRE( d != Approx( 1.22 ) ) with expansion: - 1.23 != Approx( 1.22 ) + 1.22999999999999998 + != + Approx( 1.21999999999999997 ) Approx.tests.cpp:: PASSED: REQUIRE( d != Approx( 1.24 ) ) with expansion: - 1.23 != Approx( 1.24 ) + 1.22999999999999998 + != + Approx( 1.23999999999999999 ) Approx.tests.cpp:: PASSED: REQUIRE( d == 1.23_a ) with expansion: - 1.23 == Approx( 1.23 ) + 1.22999999999999998 + == + Approx( 1.22999999999999998 ) Approx.tests.cpp:: PASSED: REQUIRE( d != 1.22_a ) with expansion: - 1.23 != Approx( 1.22 ) + 1.22999999999999998 + != + Approx( 1.21999999999999997 ) Approx.tests.cpp:: PASSED: REQUIRE( Approx( d ) == 1.23 ) with expansion: - Approx( 1.23 ) == 1.23 + Approx( 1.22999999999999998 ) + == + 1.22999999999999998 Approx.tests.cpp:: PASSED: REQUIRE( Approx( d ) != 1.22 ) with expansion: - Approx( 1.23 ) != 1.22 + Approx( 1.22999999999999998 ) + != + 1.21999999999999997 Approx.tests.cpp:: PASSED: REQUIRE( Approx( d ) != 1.24 ) with expansion: - Approx( 1.23 ) != 1.24 + Approx( 1.22999999999999998 ) + != + 1.23999999999999999 Message from section one ------------------------------------------------------------------------------- @@ -11675,9 +11873,9 @@ Misc.tests.cpp: ............................................................................... Misc.tests.cpp:: PASSED: - REQUIRE( sizeof(TestType) > 0 ) + REQUIRE( std::is_default_constructible::value ) with expansion: - 1 > 0 + true ------------------------------------------------------------------------------- Template test case with test types specified inside non-copyable and non- @@ -11687,9 +11885,9 @@ Misc.tests.cpp: ............................................................................... Misc.tests.cpp:: PASSED: - REQUIRE( sizeof(TestType) > 0 ) + REQUIRE( std::is_default_constructible::value ) with expansion: - 4 > 0 + true ------------------------------------------------------------------------------- Template test case with test types specified inside non-default-constructible @@ -11699,9 +11897,9 @@ Misc.tests.cpp: ............................................................................... Misc.tests.cpp:: PASSED: - REQUIRE( sizeof(TestType) > 0 ) + REQUIRE( std::is_trivially_copyable::value ) with expansion: - 1 > 0 + true ------------------------------------------------------------------------------- Template test case with test types specified inside non-default-constructible @@ -11711,9 +11909,9 @@ Misc.tests.cpp: ............................................................................... Misc.tests.cpp:: PASSED: - REQUIRE( sizeof(TestType) > 0 ) + REQUIRE( std::is_trivially_copyable::value ) with expansion: - 4 > 0 + true ------------------------------------------------------------------------------- Template test case with test types specified inside std::tuple - MyTypes - 0 @@ -11722,9 +11920,9 @@ Misc.tests.cpp: ............................................................................... Misc.tests.cpp:: PASSED: - REQUIRE( sizeof(TestType) > 0 ) + REQUIRE( std::is_arithmetic::value ) with expansion: - 4 > 0 + true ------------------------------------------------------------------------------- Template test case with test types specified inside std::tuple - MyTypes - 1 @@ -11733,9 +11931,9 @@ Misc.tests.cpp: ............................................................................... Misc.tests.cpp:: PASSED: - REQUIRE( sizeof(TestType) > 0 ) + REQUIRE( std::is_arithmetic::value ) with expansion: - 1 > 0 + true ------------------------------------------------------------------------------- Template test case with test types specified inside std::tuple - MyTypes - 2 @@ -11744,9 +11942,9 @@ Misc.tests.cpp: ............................................................................... Misc.tests.cpp:: PASSED: - REQUIRE( sizeof(TestType) > 0 ) + REQUIRE( std::is_arithmetic::value ) with expansion: - 4 > 0 + true ------------------------------------------------------------------------------- TemplateTest: vectors can be sized and resized - float @@ -13801,7 +13999,7 @@ Exception.tests.cpp: Exception.tests.cpp:: FAILED: due to unexpected exception with message: - 3.14 + 3.14000000000000012 ------------------------------------------------------------------------------- Upcasting special member functions @@ -15045,42 +15243,54 @@ Approx.tests.cpp: Approx.tests.cpp:: PASSED: REQUIRE( d == approx( 1.23 ) ) with expansion: - 1.23 == Approx( 1.23 ) + 1.22999999999999998 + == + Approx( 1.22999999999999998 ) Approx.tests.cpp:: PASSED: REQUIRE( d == approx( 1.22 ) ) with expansion: - 1.23 == Approx( 1.22 ) + 1.22999999999999998 + == + Approx( 1.21999999999999997 ) Approx.tests.cpp:: PASSED: REQUIRE( d == approx( 1.24 ) ) with expansion: - 1.23 == Approx( 1.24 ) + 1.22999999999999998 + == + Approx( 1.23999999999999999 ) Approx.tests.cpp:: PASSED: REQUIRE( d != approx( 1.25 ) ) with expansion: - 1.23 != Approx( 1.25 ) + 1.22999999999999998 != Approx( 1.25 ) Approx.tests.cpp:: PASSED: REQUIRE( approx( d ) == 1.23 ) with expansion: - Approx( 1.23 ) == 1.23 + Approx( 1.22999999999999998 ) + == + 1.22999999999999998 Approx.tests.cpp:: PASSED: REQUIRE( approx( d ) == 1.22 ) with expansion: - Approx( 1.23 ) == 1.22 + Approx( 1.22999999999999998 ) + == + 1.21999999999999997 Approx.tests.cpp:: PASSED: REQUIRE( approx( d ) == 1.24 ) with expansion: - Approx( 1.23 ) == 1.24 + Approx( 1.22999999999999998 ) + == + 1.23999999999999999 Approx.tests.cpp:: PASSED: REQUIRE( approx( d ) != 1.25 ) with expansion: - Approx( 1.23 ) != 1.25 + Approx( 1.22999999999999998 ) != 1.25 ------------------------------------------------------------------------------- Variadic macros @@ -16273,17 +16483,23 @@ InternalBenchmark.tests.cpp: InternalBenchmark.tests.cpp:: PASSED: CHECK( erfc_inv(1.103560) == Approx(-0.09203687623843015) ) with expansion: - -0.0920368762 == Approx( -0.0920368762 ) + -0.09203687623843014 + == + Approx( -0.09203687623843015 ) InternalBenchmark.tests.cpp:: PASSED: CHECK( erfc_inv(1.067400) == Approx(-0.05980291115763361) ) with expansion: - -0.0598029112 == Approx( -0.0598029112 ) + -0.05980291115763361 + == + Approx( -0.05980291115763361 ) InternalBenchmark.tests.cpp:: PASSED: CHECK( erfc_inv(0.050000) == Approx(1.38590382434967796) ) with expansion: - 1.3859038243 == Approx( 1.3859038243 ) + 1.38590382434967774 + == + Approx( 1.38590382434967796 ) ------------------------------------------------------------------------------- estimate_clock_resolution @@ -16943,37 +17159,6 @@ Tricky.tests.cpp:: PASSED: with expansion: {?} == {?} -------------------------------------------------------------------------------- -normal_cdf -------------------------------------------------------------------------------- -InternalBenchmark.tests.cpp: -............................................................................... - -InternalBenchmark.tests.cpp:: PASSED: - CHECK( normal_cdf(0.000000) == Approx(0.50000000000000000) ) -with expansion: - 0.5 == Approx( 0.5 ) - -InternalBenchmark.tests.cpp:: PASSED: - CHECK( normal_cdf(1.000000) == Approx(0.84134474606854293) ) -with expansion: - 0.8413447461 == Approx( 0.8413447461 ) - -InternalBenchmark.tests.cpp:: PASSED: - CHECK( normal_cdf(-1.000000) == Approx(0.15865525393145705) ) -with expansion: - 0.1586552539 == Approx( 0.1586552539 ) - -InternalBenchmark.tests.cpp:: PASSED: - CHECK( normal_cdf(2.809729) == Approx(0.99752083845315409) ) -with expansion: - 0.9975208385 == Approx( 0.9975208385 ) - -InternalBenchmark.tests.cpp:: PASSED: - CHECK( normal_cdf(-1.352570) == Approx(0.08809652095066035) ) -with expansion: - 0.088096521 == Approx( 0.088096521 ) - ------------------------------------------------------------------------------- normal_quantile ------------------------------------------------------------------------------- @@ -16983,17 +17168,23 @@ InternalBenchmark.tests.cpp: InternalBenchmark.tests.cpp:: PASSED: CHECK( normal_quantile(0.551780) == Approx(0.13015979861484198) ) with expansion: - 0.1301597986 == Approx( 0.1301597986 ) + 0.13015979861484195 + == + Approx( 0.13015979861484198 ) InternalBenchmark.tests.cpp:: PASSED: CHECK( normal_quantile(0.533700) == Approx(0.08457408802851875) ) with expansion: - 0.084574088 == Approx( 0.084574088 ) + 0.08457408802851875 + == + Approx( 0.08457408802851875 ) InternalBenchmark.tests.cpp:: PASSED: CHECK( normal_quantile(0.025000) == Approx(-1.95996398454005449) ) with expansion: - -1.9599639845 == Approx( -1.9599639845 ) + -1.95996398454005405 + == + Approx( -1.95996398454005449 ) ------------------------------------------------------------------------------- not allowed @@ -17309,6 +17500,42 @@ StringManip.tests.cpp:: PASSED: with expansion: "abcdefcg" == "abcdefcg" +------------------------------------------------------------------------------- +replaceInPlace + no replace in already-replaced string + lengthening +------------------------------------------------------------------------------- +StringManip.tests.cpp: +............................................................................... + +StringManip.tests.cpp:: PASSED: + CHECK( Catch::replaceInPlace(letters, "c", "cc") ) +with expansion: + true + +StringManip.tests.cpp:: PASSED: + CHECK( letters == "abccdefccg" ) +with expansion: + "abccdefccg" == "abccdefccg" + +------------------------------------------------------------------------------- +replaceInPlace + no replace in already-replaced string + shortening +------------------------------------------------------------------------------- +StringManip.tests.cpp: +............................................................................... + +StringManip.tests.cpp:: PASSED: + CHECK( Catch::replaceInPlace(s, "--", "-") ) +with expansion: + true + +StringManip.tests.cpp:: PASSED: + CHECK( s == "--" ) +with expansion: + "--" == "--" + ------------------------------------------------------------------------------- replaceInPlace escape ' @@ -18176,14 +18403,14 @@ ToStringTuple.tests.cpp: ............................................................................... ToStringTuple.tests.cpp:: PASSED: - CHECK( "1.2f" == ::Catch::Detail::stringify(float(1.2)) ) + CHECK( "1.5f" == ::Catch::Detail::stringify(float(1.5)) ) with expansion: - "1.2f" == "1.2f" + "1.5f" == "1.5f" ToStringTuple.tests.cpp:: PASSED: - CHECK( "{ 1.2f, 0 }" == ::Catch::Detail::stringify(type{1.2f,0}) ) + CHECK( "{ 1.5f, 0 }" == ::Catch::Detail::stringify(type{1.5f,0}) ) with expansion: - "{ 1.2f, 0 }" == "{ 1.2f, 0 }" + "{ 1.5f, 0 }" == "{ 1.5f, 0 }" ------------------------------------------------------------------------------- tuple @@ -18216,11 +18443,11 @@ ToStringTuple.tests.cpp: ............................................................................... ToStringTuple.tests.cpp:: PASSED: - CHECK( "{ { 42 }, { }, 1.2f }" == ::Catch::Detail::stringify(value) ) + CHECK( "{ { 42 }, { }, 1.5f }" == ::Catch::Detail::stringify(value) ) with expansion: - "{ { 42 }, { }, 1.2f }" + "{ { 42 }, { }, 1.5f }" == - "{ { 42 }, { }, 1.2f }" + "{ { 42 }, { }, 1.5f }" ------------------------------------------------------------------------------- uniform samples @@ -18246,7 +18473,7 @@ with expansion: InternalBenchmark.tests.cpp:: PASSED: CHECK( e.confidence_interval == 0.95 ) with expansion: - 0.95 == 0.95 + 0.94999999999999996 == 0.94999999999999996 ------------------------------------------------------------------------------- uniform_integer_distribution can return the bounds @@ -18751,6 +18978,6 @@ Misc.tests.cpp: Misc.tests.cpp:: PASSED: =============================================================================== -test cases: 417 | 312 passed | 85 failed | 6 skipped | 14 failed as expected -assertions: 2260 | 2079 passed | 146 failed | 35 failed as expected +test cases: 419 | 313 passed | 86 failed | 6 skipped | 14 failed as expected +assertions: 2265 | 2083 passed | 147 failed | 35 failed as expected diff --git a/tests/SelfTest/Baselines/console.sw.multi.approved.txt b/tests/SelfTest/Baselines/console.sw.multi.approved.txt index 5d204990c6..1fe0b73e68 100644 --- a/tests/SelfTest/Baselines/console.sw.multi.approved.txt +++ b/tests/SelfTest/Baselines/console.sw.multi.approved.txt @@ -2021,6 +2021,54 @@ A TEST_CASE_METHOD based test run that succeeds Class.tests.cpp: ............................................................................... +Class.tests.cpp:: PASSED: + REQUIRE( m_a == 1 ) +with expansion: + 1 == 1 + +------------------------------------------------------------------------------- +A TEST_CASE_PERSISTENT_FIXTURE based test run that fails + First partial run +------------------------------------------------------------------------------- +Class.tests.cpp: +............................................................................... + +Class.tests.cpp:: PASSED: + REQUIRE( m_a++ == 0 ) +with expansion: + 0 == 0 + +------------------------------------------------------------------------------- +A TEST_CASE_PERSISTENT_FIXTURE based test run that fails + Second partial run +------------------------------------------------------------------------------- +Class.tests.cpp: +............................................................................... + +Class.tests.cpp:: FAILED: + REQUIRE( m_a == 0 ) +with expansion: + 1 == 0 + +------------------------------------------------------------------------------- +A TEST_CASE_PERSISTENT_FIXTURE based test run that succeeds + First partial run +------------------------------------------------------------------------------- +Class.tests.cpp: +............................................................................... + +Class.tests.cpp:: PASSED: + REQUIRE( m_a++ == 0 ) +with expansion: + 0 == 0 + +------------------------------------------------------------------------------- +A TEST_CASE_PERSISTENT_FIXTURE based test run that succeeds + Second partial run +------------------------------------------------------------------------------- +Class.tests.cpp: +............................................................................... + Class.tests.cpp:: PASSED: REQUIRE( m_a == 1 ) with expansion: @@ -2123,32 +2171,42 @@ Approx.tests.cpp: Approx.tests.cpp:: PASSED: REQUIRE( d == 1.23_a ) with expansion: - 1.23 == Approx( 1.23 ) + 1.22999999999999998 + == + Approx( 1.22999999999999998 ) Approx.tests.cpp:: PASSED: REQUIRE( d != 1.22_a ) with expansion: - 1.23 != Approx( 1.22 ) + 1.22999999999999998 + != + Approx( 1.21999999999999997 ) Approx.tests.cpp:: PASSED: REQUIRE( -d == -1.23_a ) with expansion: - -1.23 == Approx( -1.23 ) + -1.22999999999999998 + == + Approx( -1.22999999999999998 ) Approx.tests.cpp:: PASSED: REQUIRE( d == 1.2_a .epsilon(.1) ) with expansion: - 1.23 == Approx( 1.2 ) + 1.22999999999999998 + == + Approx( 1.19999999999999996 ) Approx.tests.cpp:: PASSED: REQUIRE( d != 1.2_a .epsilon(.001) ) with expansion: - 1.23 != Approx( 1.2 ) + 1.22999999999999998 + != + Approx( 1.19999999999999996 ) Approx.tests.cpp:: PASSED: REQUIRE( d == 1_a .epsilon(.3) ) with expansion: - 1.23 == Approx( 1.0 ) + 1.22999999999999998 == Approx( 1.0 ) ------------------------------------------------------------------------------- A couple of nested sections followed by a failure @@ -2217,12 +2275,12 @@ with expansion: Approx.tests.cpp:: PASSED: REQUIRE( 100.3 != Approx(100.0) ) with expansion: - 100.3 != Approx( 100.0 ) + 100.29999999999999716 != Approx( 100.0 ) Approx.tests.cpp:: PASSED: REQUIRE( 100.3 == Approx(100.0).margin(0.5) ) with expansion: - 100.3 == Approx( 100.0 ) + 100.29999999999999716 == Approx( 100.0 ) ------------------------------------------------------------------------------- An empty test with no assertions @@ -2340,12 +2398,16 @@ Approx.tests.cpp: Approx.tests.cpp:: PASSED: REQUIRE( divide( 22, 7 ) == Approx( 3.141 ).epsilon( 0.001 ) ) with expansion: - 3.1428571429 == Approx( 3.141 ) + 3.14285714285714279 + == + Approx( 3.14100000000000001 ) Approx.tests.cpp:: PASSED: REQUIRE( divide( 22, 7 ) != Approx( 3.141 ).epsilon( 0.0001 ) ) with expansion: - 3.1428571429 != Approx( 3.141 ) + 3.14285714285714279 + != + Approx( 3.14100000000000001 ) ------------------------------------------------------------------------------- Approximate comparisons with different epsilons @@ -2356,12 +2418,16 @@ Approx.tests.cpp: Approx.tests.cpp:: PASSED: REQUIRE( d != Approx( 1.231 ) ) with expansion: - 1.23 != Approx( 1.231 ) + 1.22999999999999998 + != + Approx( 1.23100000000000009 ) Approx.tests.cpp:: PASSED: REQUIRE( d == Approx( 1.231 ).epsilon( 0.1 ) ) with expansion: - 1.23 == Approx( 1.231 ) + 1.22999999999999998 + == + Approx( 1.23100000000000009 ) ------------------------------------------------------------------------------- Approximate comparisons with floats @@ -2372,7 +2438,9 @@ Approx.tests.cpp: Approx.tests.cpp:: PASSED: REQUIRE( 1.23f == Approx( 1.23f ) ) with expansion: - 1.23f == Approx( 1.2300000191 ) + 1.230000019f + == + Approx( 1.23000001907348633 ) Approx.tests.cpp:: PASSED: REQUIRE( 0.0f == Approx( 0.0f ) ) @@ -2419,12 +2487,16 @@ with expansion: Approx.tests.cpp:: PASSED: REQUIRE( 1.234f == Approx( dMedium ) ) with expansion: - 1.234f == Approx( 1.234 ) + 1.233999968f + == + Approx( 1.23399999999999999 ) Approx.tests.cpp:: PASSED: REQUIRE( dMedium == Approx( 1.234f ) ) with expansion: - 1.234 == Approx( 1.2339999676 ) + 1.23399999999999999 + == + Approx( 1.23399996757507324 ) ------------------------------------------------------------------------------- Arbitrary predicate matcher @@ -2902,24 +2974,24 @@ ToStringGeneral.tests.cpp: ............................................................................... ToStringGeneral.tests.cpp:: PASSED: - CHECK( tab == '\t' ) + CHECK( ::Catch::Detail::stringify('\t') == "'\\t'" ) with expansion: - '\t' == '\t' + "'\t'" == "'\t'" ToStringGeneral.tests.cpp:: PASSED: - CHECK( newline == '\n' ) + CHECK( ::Catch::Detail::stringify('\n') == "'\\n'" ) with expansion: - '\n' == '\n' + "'\n'" == "'\n'" ToStringGeneral.tests.cpp:: PASSED: - CHECK( carr_return == '\r' ) + CHECK( ::Catch::Detail::stringify('\r') == "'\\r'" ) with expansion: - '\r' == '\r' + "'\r'" == "'\r'" ToStringGeneral.tests.cpp:: PASSED: - CHECK( form_feed == '\f' ) + CHECK( ::Catch::Detail::stringify('\f') == "'\\f'" ) with expansion: - '\f' == '\f' + "'\f'" == "'\f'" ------------------------------------------------------------------------------- Character pretty printing @@ -2929,29 +3001,19 @@ ToStringGeneral.tests.cpp: ............................................................................... ToStringGeneral.tests.cpp:: PASSED: - CHECK( space == ' ' ) -with expansion: - ' ' == ' ' - -ToStringGeneral.tests.cpp:: PASSED: - REQUIRE( c == chars[i] ) + CHECK( ::Catch::Detail::stringify( ' ' ) == "' '" ) with expansion: - 'a' == 'a' + "' '" == "' '" ToStringGeneral.tests.cpp:: PASSED: - REQUIRE( c == chars[i] ) + CHECK( ::Catch::Detail::stringify( 'A' ) == "'A'" ) with expansion: - 'z' == 'z' + "'A'" == "'A'" ToStringGeneral.tests.cpp:: PASSED: - REQUIRE( c == chars[i] ) + CHECK( ::Catch::Detail::stringify( 'z' ) == "'z'" ) with expansion: - 'A' == 'A' - -ToStringGeneral.tests.cpp:: PASSED: - REQUIRE( c == chars[i] ) -with expansion: - 'Z' == 'Z' + "'z'" == "'z'" ------------------------------------------------------------------------------- Character pretty printing @@ -2961,29 +3023,55 @@ ToStringGeneral.tests.cpp: ............................................................................... ToStringGeneral.tests.cpp:: PASSED: - CHECK( null_terminator == '\0' ) + CHECK( ::Catch::Detail::stringify( '\0' ) == "0" ) with expansion: - 0 == 0 + "0" == "0" ToStringGeneral.tests.cpp:: PASSED: - REQUIRE( c == i ) + CHECK( ::Catch::Detail::stringify( static_cast(2) ) == "2" ) with expansion: - 2 == 2 + "2" == "2" ToStringGeneral.tests.cpp:: PASSED: - REQUIRE( c == i ) + CHECK( ::Catch::Detail::stringify( static_cast(5) ) == "5" ) with expansion: - 3 == 3 + "5" == "5" -ToStringGeneral.tests.cpp:: PASSED: - REQUIRE( c == i ) +------------------------------------------------------------------------------- +Clara::Arg does not crash on incomplete input +------------------------------------------------------------------------------- +Clara.tests.cpp: +............................................................................... + +Clara.tests.cpp:: PASSED: + CHECK( name.empty() ) with expansion: - 4 == 4 + true -ToStringGeneral.tests.cpp:: PASSED: - REQUIRE( c == i ) +Clara.tests.cpp:: PASSED: + CHECK( result ) with expansion: - 5 == 5 + {?} + +Clara.tests.cpp:: PASSED: + CHECK( result.type() == Catch::Clara::Detail::ResultType::Ok ) +with expansion: + 0 == 0 + +Clara.tests.cpp:: PASSED: + CHECK( parsed.type() == Catch::Clara::ParseResultType::NoMatch ) +with expansion: + 1 == 1 + +Clara.tests.cpp:: PASSED: + CHECK( parsed.remainingTokens().count() == 2 ) +with expansion: + 2 == 2 + +Clara.tests.cpp:: PASSED: + CHECK( name.empty() ) +with expansion: + true ------------------------------------------------------------------------------- Clara::Arg supports single-arg parse the way Opt does @@ -3924,7 +4012,7 @@ Approx.tests.cpp: Approx.tests.cpp:: PASSED: REQUIRE( 101.000001 != Approx(100).epsilon(0.01) ) with expansion: - 101.000001 != Approx( 100.0 ) + 101.00000099999999748 != Approx( 100.0 ) Approx.tests.cpp:: PASSED: REQUIRE( std::pow(10, -5) != Approx(std::pow(10, -7)) ) @@ -4051,7 +4139,7 @@ Approx.tests.cpp: Approx.tests.cpp:: PASSED: REQUIRE( 101.01 != Approx(100).epsilon(0.01) ) with expansion: - 101.01 != Approx( 100.0 ) + 101.01000000000000512 != Approx( 100.0 ) ------------------------------------------------------------------------------- Equality checks that should fail @@ -4077,27 +4165,31 @@ with expansion: Condition.tests.cpp:: FAILED: CHECK( data.float_nine_point_one == Approx( 9.11f ) ) with expansion: - 9.1f == Approx( 9.1099996567 ) + 9.100000381f + == + Approx( 9.10999965667724609 ) Condition.tests.cpp:: FAILED: CHECK( data.float_nine_point_one == Approx( 9.0f ) ) with expansion: - 9.1f == Approx( 9.0 ) + 9.100000381f == Approx( 9.0 ) Condition.tests.cpp:: FAILED: CHECK( data.float_nine_point_one == Approx( 1 ) ) with expansion: - 9.1f == Approx( 1.0 ) + 9.100000381f == Approx( 1.0 ) Condition.tests.cpp:: FAILED: CHECK( data.float_nine_point_one == Approx( 0 ) ) with expansion: - 9.1f == Approx( 0.0 ) + 9.100000381f == Approx( 0.0 ) Condition.tests.cpp:: FAILED: CHECK( data.double_pi == Approx( 3.1415 ) ) with expansion: - 3.1415926535 == Approx( 3.1415 ) + 3.14159265350000005 + == + Approx( 3.14150000000000018 ) Condition.tests.cpp:: FAILED: CHECK( data.str_hello == "goodbye" ) @@ -4122,7 +4214,9 @@ with expansion: Condition.tests.cpp:: FAILED: CHECK( x == Approx( 1.301 ) ) with expansion: - 1.3 == Approx( 1.301 ) + 1.30000000000000027 + == + Approx( 1.30099999999999993 ) ------------------------------------------------------------------------------- Equality checks that should succeed @@ -4138,12 +4232,16 @@ with expansion: Condition.tests.cpp:: PASSED: REQUIRE( data.float_nine_point_one == Approx( 9.1f ) ) with expansion: - 9.1f == Approx( 9.1000003815 ) + 9.100000381f + == + Approx( 9.10000038146972656 ) Condition.tests.cpp:: PASSED: REQUIRE( data.double_pi == Approx( 3.1415926535 ) ) with expansion: - 3.1415926535 == Approx( 3.1415926535 ) + 3.14159265350000005 + == + Approx( 3.14159265350000005 ) Condition.tests.cpp:: PASSED: REQUIRE( data.str_hello == "hello" ) @@ -4163,7 +4261,9 @@ with expansion: Condition.tests.cpp:: PASSED: REQUIRE( x == Approx( 1.3 ) ) with expansion: - 1.3 == Approx( 1.3 ) + 1.30000000000000027 + == + Approx( 1.30000000000000004 ) ------------------------------------------------------------------------------- Equals @@ -4495,22 +4595,22 @@ Matchers.tests.cpp: Matchers.tests.cpp:: PASSED: REQUIRE_THAT( 10., WithinRel( 11.1, 0.1 ) ) with expansion: - 10.0 and 11.1 are within 10% of each other + 10.0 and 11.09999999999999964 are within 10% of each other Matchers.tests.cpp:: PASSED: REQUIRE_THAT( 10., !WithinRel( 11.2, 0.1 ) ) with expansion: - 10.0 not and 11.2 are within 10% of each other + 10.0 not and 11.19999999999999929 are within 10% of each other Matchers.tests.cpp:: PASSED: REQUIRE_THAT( 1., !WithinRel( 0., 0.99 ) ) with expansion: - 1.0 not and 0 are within 99% of each other + 1.0 not and 0.0 are within 99% of each other Matchers.tests.cpp:: PASSED: REQUIRE_THAT( -0., WithinRel( 0. ) ) with expansion: - -0.0 and 0 are within 2.22045e-12% of each other + -0.0 and 0.0 are within 2.22045e-12% of each other ------------------------------------------------------------------------------- Floating point matchers: double @@ -4523,7 +4623,7 @@ Matchers.tests.cpp: Matchers.tests.cpp:: PASSED: REQUIRE_THAT( v1, WithinRel( v2 ) ) with expansion: - 0.0 and 2.22507e-308 are within 2.22045e-12% of each other + 0.0 and 0.0 are within 2.22045e-12% of each other ------------------------------------------------------------------------------- Floating point matchers: double @@ -4545,12 +4645,12 @@ with expansion: Matchers.tests.cpp:: PASSED: REQUIRE_THAT( 0., !WithinAbs( 1., 0.99 ) ) with expansion: - 0.0 not is within 0.99 of 1.0 + 0.0 not is within 0.98999999999999999 of 1.0 Matchers.tests.cpp:: PASSED: REQUIRE_THAT( 0., !WithinAbs( 1., 0.99 ) ) with expansion: - 0.0 not is within 0.99 of 1.0 + 0.0 not is within 0.98999999999999999 of 1.0 Matchers.tests.cpp:: PASSED: REQUIRE_THAT( 11., !WithinAbs( 10., 0.5 ) ) @@ -4570,7 +4670,7 @@ with expansion: Matchers.tests.cpp:: PASSED: REQUIRE_THAT( -10., WithinAbs( -9.6, 0.5 ) ) with expansion: - -10.0 is within 0.5 of -9.6 + -10.0 is within 0.5 of -9.59999999999999964 ------------------------------------------------------------------------------- Floating point matchers: double @@ -4588,8 +4688,8 @@ with expansion: Matchers.tests.cpp:: PASSED: REQUIRE_THAT( nextafter( 1., 2. ), WithinULP( 1., 1 ) ) with expansion: - 1.0 is within 1 ULPs of 1.0000000000000000e+00 ([9.9999999999999989e-01, 1. - 0000000000000002e+00]) + 1.00000000000000022 is within 1 ULPs of 1.0000000000000000e+00 ([9. + 9999999999999989e-01, 1.0000000000000002e+00]) Matchers.tests.cpp:: PASSED: REQUIRE_THAT( 0., WithinULP( nextafter( 0., 1. ), 1 ) ) @@ -4643,7 +4743,7 @@ with expansion: Matchers.tests.cpp:: PASSED: REQUIRE_THAT( 0.0001, WithinAbs( 0., 0.001 ) || WithinRel( 0., 0.1 ) ) with expansion: - 0.0001 ( is within 0.001 of 0.0 or and 0 are within 10% of each other ) + 0.0001 ( is within 0.001 of 0.0 or and 0.0 are within 10% of each other ) ------------------------------------------------------------------------------- Floating point matchers: double @@ -4692,22 +4792,22 @@ Matchers.tests.cpp: Matchers.tests.cpp:: PASSED: REQUIRE_THAT( 10.f, WithinRel( 11.1f, 0.1f ) ) with expansion: - 10.0f and 11.1 are within 10% of each other + 10.0f and 11.10000038146972656 are within 10% of each other Matchers.tests.cpp:: PASSED: REQUIRE_THAT( 10.f, !WithinRel( 11.2f, 0.1f ) ) with expansion: - 10.0f not and 11.2 are within 10% of each other + 10.0f not and 11.19999980926513672 are within 10% of each other Matchers.tests.cpp:: PASSED: REQUIRE_THAT( 1.f, !WithinRel( 0.f, 0.99f ) ) with expansion: - 1.0f not and 0 are within 99% of each other + 1.0f not and 0.0 are within 99% of each other Matchers.tests.cpp:: PASSED: REQUIRE_THAT( -0.f, WithinRel( 0.f ) ) with expansion: - -0.0f and 0 are within 0.00119209% of each other + -0.0f and 0.0 are within 0.00119209% of each other ------------------------------------------------------------------------------- Floating point matchers: float @@ -4720,7 +4820,7 @@ Matchers.tests.cpp: Matchers.tests.cpp:: PASSED: REQUIRE_THAT( v1, WithinRel( v2 ) ) with expansion: - 0.0f and 1.17549e-38 are within 0.00119209% of each other + 0.0f and 0.0 are within 0.00119209% of each other ------------------------------------------------------------------------------- Floating point matchers: float @@ -4742,12 +4842,12 @@ with expansion: Matchers.tests.cpp:: PASSED: REQUIRE_THAT( 0.f, !WithinAbs( 1.f, 0.99f ) ) with expansion: - 0.0f not is within 0.9900000095 of 1.0 + 0.0f not is within 0.99000000953674316 of 1.0 Matchers.tests.cpp:: PASSED: REQUIRE_THAT( 0.f, !WithinAbs( 1.f, 0.99f ) ) with expansion: - 0.0f not is within 0.9900000095 of 1.0 + 0.0f not is within 0.99000000953674316 of 1.0 Matchers.tests.cpp:: PASSED: REQUIRE_THAT( 0.f, WithinAbs( -0.f, 0 ) ) @@ -4772,7 +4872,7 @@ with expansion: Matchers.tests.cpp:: PASSED: REQUIRE_THAT( -10.f, WithinAbs( -9.6f, 0.5f ) ) with expansion: - -10.0f is within 0.5 of -9.6000003815 + -10.0f is within 0.5 of -9.60000038146972656 ------------------------------------------------------------------------------- Floating point matchers: float @@ -4795,7 +4895,8 @@ with expansion: Matchers.tests.cpp:: PASSED: REQUIRE_THAT( nextafter( 1.f, 2.f ), WithinULP( 1.f, 1 ) ) with expansion: - 1.0f is within 1 ULPs of 1.00000000e+00f ([9.99999940e-01, 1.00000012e+00]) + 1.000000119f is within 1 ULPs of 1.00000000e+00f ([9.99999940e-01, 1. + 00000012e+00]) Matchers.tests.cpp:: PASSED: REQUIRE_THAT( 0.f, WithinULP( nextafter( 0.f, 1.f ), 1 ) ) @@ -4845,7 +4946,8 @@ with expansion: Matchers.tests.cpp:: PASSED: REQUIRE_THAT( 0.0001f, WithinAbs( 0.f, 0.001f ) || WithinRel( 0.f, 0.1f ) ) with expansion: - 0.0001f ( is within 0.001 of 0.0 or and 0 are within 10% of each other ) + 0.0001f ( is within 0.00100000004749745 of 0.0 or and 0.0 are within 10% of + each other ) ------------------------------------------------------------------------------- Floating point matchers: float @@ -6286,7 +6388,9 @@ with message: GeneratorsImpl.tests.cpp:: PASSED: REQUIRE( gen.get() == Approx(expected) ) with expansion: - -0.9 == Approx( -0.9 ) + -0.90000000000000002 + == + Approx( -0.90000000000000002 ) with message: Current expected value is -0.9 @@ -6300,7 +6404,9 @@ with message: GeneratorsImpl.tests.cpp:: PASSED: REQUIRE( gen.get() == Approx(expected) ) with expansion: - -0.8 == Approx( -0.8 ) + -0.80000000000000004 + == + Approx( -0.80000000000000004 ) with message: Current expected value is -0.8 @@ -6314,7 +6420,9 @@ with message: GeneratorsImpl.tests.cpp:: PASSED: REQUIRE( gen.get() == Approx(expected) ) with expansion: - -0.7 == Approx( -0.7 ) + -0.70000000000000007 + == + Approx( -0.70000000000000007 ) with message: Current expected value is -0.7 @@ -6328,7 +6436,9 @@ with message: GeneratorsImpl.tests.cpp:: PASSED: REQUIRE( gen.get() == Approx(expected) ) with expansion: - -0.6 == Approx( -0.6 ) + -0.60000000000000009 + == + Approx( -0.60000000000000009 ) with message: Current expected value is -0.6 @@ -6342,7 +6452,9 @@ with message: GeneratorsImpl.tests.cpp:: PASSED: REQUIRE( gen.get() == Approx(expected) ) with expansion: - -0.5 == Approx( -0.5 ) + -0.50000000000000011 + == + Approx( -0.50000000000000011 ) with message: Current expected value is -0.5 @@ -6356,7 +6468,9 @@ with message: GeneratorsImpl.tests.cpp:: PASSED: REQUIRE( gen.get() == Approx(expected) ) with expansion: - -0.4 == Approx( -0.4 ) + -0.40000000000000013 + == + Approx( -0.40000000000000013 ) with message: Current expected value is -0.4 @@ -6370,7 +6484,9 @@ with message: GeneratorsImpl.tests.cpp:: PASSED: REQUIRE( gen.get() == Approx(expected) ) with expansion: - -0.3 == Approx( -0.3 ) + -0.30000000000000016 + == + Approx( -0.30000000000000016 ) with message: Current expected value is -0.3 @@ -6384,7 +6500,9 @@ with message: GeneratorsImpl.tests.cpp:: PASSED: REQUIRE( gen.get() == Approx(expected) ) with expansion: - -0.2 == Approx( -0.2 ) + -0.20000000000000015 + == + Approx( -0.20000000000000015 ) with message: Current expected value is -0.2 @@ -6398,7 +6516,9 @@ with message: GeneratorsImpl.tests.cpp:: PASSED: REQUIRE( gen.get() == Approx(expected) ) with expansion: - -0.1 == Approx( -0.1 ) + -0.10000000000000014 + == + Approx( -0.10000000000000014 ) with message: Current expected value is -0.1 @@ -6412,7 +6532,9 @@ with message: GeneratorsImpl.tests.cpp:: PASSED: REQUIRE( gen.get() == Approx(expected) ) with expansion: - -0.0 == Approx( -0.0 ) + -0.00000000000000014 + == + Approx( -0.00000000000000014 ) with message: Current expected value is -1.38778e-16 @@ -6426,7 +6548,9 @@ with message: GeneratorsImpl.tests.cpp:: PASSED: REQUIRE( gen.get() == Approx(expected) ) with expansion: - 0.1 == Approx( 0.1 ) + 0.09999999999999987 + == + Approx( 0.09999999999999987 ) with message: Current expected value is 0.1 @@ -6440,7 +6564,9 @@ with message: GeneratorsImpl.tests.cpp:: PASSED: REQUIRE( gen.get() == Approx(expected) ) with expansion: - 0.2 == Approx( 0.2 ) + 0.19999999999999987 + == + Approx( 0.19999999999999987 ) with message: Current expected value is 0.2 @@ -6454,7 +6580,9 @@ with message: GeneratorsImpl.tests.cpp:: PASSED: REQUIRE( gen.get() == Approx(expected) ) with expansion: - 0.3 == Approx( 0.3 ) + 0.29999999999999988 + == + Approx( 0.29999999999999988 ) with message: Current expected value is 0.3 @@ -6468,7 +6596,9 @@ with message: GeneratorsImpl.tests.cpp:: PASSED: REQUIRE( gen.get() == Approx(expected) ) with expansion: - 0.4 == Approx( 0.4 ) + 0.39999999999999991 + == + Approx( 0.39999999999999991 ) with message: Current expected value is 0.4 @@ -6482,7 +6612,9 @@ with message: GeneratorsImpl.tests.cpp:: PASSED: REQUIRE( gen.get() == Approx(expected) ) with expansion: - 0.5 == Approx( 0.5 ) + 0.49999999999999989 + == + Approx( 0.49999999999999989 ) with message: Current expected value is 0.5 @@ -6496,7 +6628,9 @@ with message: GeneratorsImpl.tests.cpp:: PASSED: REQUIRE( gen.get() == Approx(expected) ) with expansion: - 0.6 == Approx( 0.6 ) + 0.59999999999999987 + == + Approx( 0.59999999999999987 ) with message: Current expected value is 0.6 @@ -6510,7 +6644,9 @@ with message: GeneratorsImpl.tests.cpp:: PASSED: REQUIRE( gen.get() == Approx(expected) ) with expansion: - 0.7 == Approx( 0.7 ) + 0.69999999999999984 + == + Approx( 0.69999999999999984 ) with message: Current expected value is 0.7 @@ -6524,7 +6660,9 @@ with message: GeneratorsImpl.tests.cpp:: PASSED: REQUIRE( gen.get() == Approx(expected) ) with expansion: - 0.8 == Approx( 0.8 ) + 0.79999999999999982 + == + Approx( 0.79999999999999982 ) with message: Current expected value is 0.8 @@ -6538,7 +6676,9 @@ with message: GeneratorsImpl.tests.cpp:: PASSED: REQUIRE( gen.get() == Approx(expected) ) with expansion: - 0.9 == Approx( 0.9 ) + 0.8999999999999998 + == + Approx( 0.8999999999999998 ) with message: Current expected value is 0.9 @@ -6552,7 +6692,7 @@ with message: GeneratorsImpl.tests.cpp:: PASSED: REQUIRE( gen.get() == Approx( rangeEnd ) ) with expansion: - 1.0 == Approx( 1.0 ) + 0.99999999999999978 == Approx( 1.0 ) GeneratorsImpl.tests.cpp:: PASSED: REQUIRE_FALSE( gen.next() ) @@ -6586,7 +6726,9 @@ with message: GeneratorsImpl.tests.cpp:: PASSED: REQUIRE( gen.get() == Approx(expected) ) with expansion: - -0.7 == Approx( -0.7 ) + -0.69999999999999996 + == + Approx( -0.69999999999999996 ) with message: Current expected value is -0.7 @@ -6600,7 +6742,9 @@ with message: GeneratorsImpl.tests.cpp:: PASSED: REQUIRE( gen.get() == Approx(expected) ) with expansion: - -0.4 == Approx( -0.4 ) + -0.39999999999999997 + == + Approx( -0.39999999999999997 ) with message: Current expected value is -0.4 @@ -6614,7 +6758,9 @@ with message: GeneratorsImpl.tests.cpp:: PASSED: REQUIRE( gen.get() == Approx(expected) ) with expansion: - -0.1 == Approx( -0.1 ) + -0.09999999999999998 + == + Approx( -0.09999999999999998 ) with message: Current expected value is -0.1 @@ -6628,7 +6774,9 @@ with message: GeneratorsImpl.tests.cpp:: PASSED: REQUIRE( gen.get() == Approx(expected) ) with expansion: - 0.2 == Approx( 0.2 ) + 0.20000000000000001 + == + Approx( 0.20000000000000001 ) with message: Current expected value is 0.2 @@ -6685,7 +6833,9 @@ with message: GeneratorsImpl.tests.cpp:: PASSED: REQUIRE( gen.get() == Approx(expected) ) with expansion: - -0.7 == Approx( -0.7 ) + -0.69999999999999996 + == + Approx( -0.69999999999999996 ) with message: Current expected value is -0.7 @@ -6699,7 +6849,9 @@ with message: GeneratorsImpl.tests.cpp:: PASSED: REQUIRE( gen.get() == Approx(expected) ) with expansion: - -0.4 == Approx( -0.4 ) + -0.39999999999999997 + == + Approx( -0.39999999999999997 ) with message: Current expected value is -0.4 @@ -6713,7 +6865,9 @@ with message: GeneratorsImpl.tests.cpp:: PASSED: REQUIRE( gen.get() == Approx(expected) ) with expansion: - -0.1 == Approx( -0.1 ) + -0.09999999999999998 + == + Approx( -0.09999999999999998 ) with message: Current expected value is -0.1 @@ -6727,7 +6881,9 @@ with message: GeneratorsImpl.tests.cpp:: PASSED: REQUIRE( gen.get() == Approx(expected) ) with expansion: - 0.2 == Approx( 0.2 ) + 0.20000000000000001 + == + Approx( 0.20000000000000001 ) with message: Current expected value is 0.2 @@ -6926,22 +7082,30 @@ Approx.tests.cpp: Approx.tests.cpp:: PASSED: REQUIRE( d >= Approx( 1.22 ) ) with expansion: - 1.23 >= Approx( 1.22 ) + 1.22999999999999998 + >= + Approx( 1.21999999999999997 ) Approx.tests.cpp:: PASSED: REQUIRE( d >= Approx( 1.23 ) ) with expansion: - 1.23 >= Approx( 1.23 ) + 1.22999999999999998 + >= + Approx( 1.22999999999999998 ) Approx.tests.cpp:: PASSED: REQUIRE_FALSE( d >= Approx( 1.24 ) ) with expansion: - !(1.23 >= Approx( 1.24 )) + !(1.22999999999999998 + >= + Approx( 1.23999999999999999 )) Approx.tests.cpp:: PASSED: REQUIRE( d >= Approx( 1.24 ).epsilon(0.1) ) with expansion: - 1.23 >= Approx( 1.24 ) + 1.22999999999999998 + >= + Approx( 1.23999999999999999 ) ------------------------------------------------------------------------------- Hashers with different seed produce different hash with same test case @@ -7222,12 +7386,16 @@ with expansion: Condition.tests.cpp:: FAILED: CHECK( data.float_nine_point_one != Approx( 9.1f ) ) with expansion: - 9.1f != Approx( 9.1000003815 ) + 9.100000381f + != + Approx( 9.10000038146972656 ) Condition.tests.cpp:: FAILED: CHECK( data.double_pi != Approx( 3.1415926535 ) ) with expansion: - 3.1415926535 != Approx( 3.1415926535 ) + 3.14159265350000005 + != + Approx( 3.14159265350000005 ) Condition.tests.cpp:: FAILED: CHECK( data.str_hello != "hello" ) @@ -7258,27 +7426,31 @@ with expansion: Condition.tests.cpp:: PASSED: REQUIRE( data.float_nine_point_one != Approx( 9.11f ) ) with expansion: - 9.1f != Approx( 9.1099996567 ) + 9.100000381f + != + Approx( 9.10999965667724609 ) Condition.tests.cpp:: PASSED: REQUIRE( data.float_nine_point_one != Approx( 9.0f ) ) with expansion: - 9.1f != Approx( 9.0 ) + 9.100000381f != Approx( 9.0 ) Condition.tests.cpp:: PASSED: REQUIRE( data.float_nine_point_one != Approx( 1 ) ) with expansion: - 9.1f != Approx( 1.0 ) + 9.100000381f != Approx( 1.0 ) Condition.tests.cpp:: PASSED: REQUIRE( data.float_nine_point_one != Approx( 0 ) ) with expansion: - 9.1f != Approx( 0.0 ) + 9.100000381f != Approx( 0.0 ) Condition.tests.cpp:: PASSED: REQUIRE( data.double_pi != Approx( 3.1415 ) ) with expansion: - 3.1415926535 != Approx( 3.1415 ) + 3.14159265350000005 + != + Approx( 3.14150000000000018 ) Condition.tests.cpp:: PASSED: REQUIRE( data.str_hello != "goodbye" ) @@ -7605,22 +7777,30 @@ Approx.tests.cpp: Approx.tests.cpp:: PASSED: REQUIRE( d <= Approx( 1.24 ) ) with expansion: - 1.23 <= Approx( 1.24 ) + 1.22999999999999998 + <= + Approx( 1.23999999999999999 ) Approx.tests.cpp:: PASSED: REQUIRE( d <= Approx( 1.23 ) ) with expansion: - 1.23 <= Approx( 1.23 ) + 1.22999999999999998 + <= + Approx( 1.22999999999999998 ) Approx.tests.cpp:: PASSED: REQUIRE_FALSE( d <= Approx( 1.22 ) ) with expansion: - !(1.23 <= Approx( 1.22 )) + !(1.22999999999999998 + <= + Approx( 1.21999999999999997 )) Approx.tests.cpp:: PASSED: REQUIRE( d <= Approx( 1.22 ).epsilon(0.1) ) with expansion: - 1.23 <= Approx( 1.22 ) + 1.22999999999999998 + <= + Approx( 1.21999999999999997 ) ------------------------------------------------------------------------------- ManuallyRegistered @@ -8173,17 +8353,17 @@ with expansion: Condition.tests.cpp:: FAILED: CHECK( data.float_nine_point_one < 9 ) with expansion: - 9.1f < 9 + 9.100000381f < 9 Condition.tests.cpp:: FAILED: CHECK( data.float_nine_point_one > 10 ) with expansion: - 9.1f > 10 + 9.100000381f > 10 Condition.tests.cpp:: FAILED: CHECK( data.float_nine_point_one > 9.2 ) with expansion: - 9.1f > 9.2 + 9.100000381f > 9.19999999999999929 Condition.tests.cpp:: FAILED: CHECK( data.str_hello > "hello" ) @@ -8274,17 +8454,17 @@ with expansion: Condition.tests.cpp:: PASSED: REQUIRE( data.float_nine_point_one > 9 ) with expansion: - 9.1f > 9 + 9.100000381f > 9 Condition.tests.cpp:: PASSED: REQUIRE( data.float_nine_point_one < 10 ) with expansion: - 9.1f < 10 + 9.100000381f < 10 Condition.tests.cpp:: PASSED: REQUIRE( data.float_nine_point_one < 9.2 ) with expansion: - 9.1f < 9.2 + 9.100000381f < 9.19999999999999929 Condition.tests.cpp:: PASSED: REQUIRE( data.str_hello <= "hello" ) @@ -9640,7 +9820,9 @@ with expansion: CmdLine.tests.cpp:: PASSED: REQUIRE( config.benchmarkConfidenceInterval == Catch::Approx(0.99) ) with expansion: - 0.99 == Approx( 0.99 ) + 0.98999999999999999 + == + Approx( 0.98999999999999999 ) ------------------------------------------------------------------------------- Process can be configured on command line @@ -10858,42 +11040,58 @@ Approx.tests.cpp: Approx.tests.cpp:: PASSED: REQUIRE( d == Approx( 1.23 ) ) with expansion: - 1.23 == Approx( 1.23 ) + 1.22999999999999998 + == + Approx( 1.22999999999999998 ) Approx.tests.cpp:: PASSED: REQUIRE( d != Approx( 1.22 ) ) with expansion: - 1.23 != Approx( 1.22 ) + 1.22999999999999998 + != + Approx( 1.21999999999999997 ) Approx.tests.cpp:: PASSED: REQUIRE( d != Approx( 1.24 ) ) with expansion: - 1.23 != Approx( 1.24 ) + 1.22999999999999998 + != + Approx( 1.23999999999999999 ) Approx.tests.cpp:: PASSED: REQUIRE( d == 1.23_a ) with expansion: - 1.23 == Approx( 1.23 ) + 1.22999999999999998 + == + Approx( 1.22999999999999998 ) Approx.tests.cpp:: PASSED: REQUIRE( d != 1.22_a ) with expansion: - 1.23 != Approx( 1.22 ) + 1.22999999999999998 + != + Approx( 1.21999999999999997 ) Approx.tests.cpp:: PASSED: REQUIRE( Approx( d ) == 1.23 ) with expansion: - Approx( 1.23 ) == 1.23 + Approx( 1.22999999999999998 ) + == + 1.22999999999999998 Approx.tests.cpp:: PASSED: REQUIRE( Approx( d ) != 1.22 ) with expansion: - Approx( 1.23 ) != 1.22 + Approx( 1.22999999999999998 ) + != + 1.21999999999999997 Approx.tests.cpp:: PASSED: REQUIRE( Approx( d ) != 1.24 ) with expansion: - Approx( 1.23 ) != 1.24 + Approx( 1.22999999999999998 ) + != + 1.23999999999999999 ------------------------------------------------------------------------------- Standard output from all sections is reported @@ -11668,9 +11866,9 @@ Misc.tests.cpp: ............................................................................... Misc.tests.cpp:: PASSED: - REQUIRE( sizeof(TestType) > 0 ) + REQUIRE( std::is_default_constructible::value ) with expansion: - 1 > 0 + true ------------------------------------------------------------------------------- Template test case with test types specified inside non-copyable and non- @@ -11680,9 +11878,9 @@ Misc.tests.cpp: ............................................................................... Misc.tests.cpp:: PASSED: - REQUIRE( sizeof(TestType) > 0 ) + REQUIRE( std::is_default_constructible::value ) with expansion: - 4 > 0 + true ------------------------------------------------------------------------------- Template test case with test types specified inside non-default-constructible @@ -11692,9 +11890,9 @@ Misc.tests.cpp: ............................................................................... Misc.tests.cpp:: PASSED: - REQUIRE( sizeof(TestType) > 0 ) + REQUIRE( std::is_trivially_copyable::value ) with expansion: - 1 > 0 + true ------------------------------------------------------------------------------- Template test case with test types specified inside non-default-constructible @@ -11704,9 +11902,9 @@ Misc.tests.cpp: ............................................................................... Misc.tests.cpp:: PASSED: - REQUIRE( sizeof(TestType) > 0 ) + REQUIRE( std::is_trivially_copyable::value ) with expansion: - 4 > 0 + true ------------------------------------------------------------------------------- Template test case with test types specified inside std::tuple - MyTypes - 0 @@ -11715,9 +11913,9 @@ Misc.tests.cpp: ............................................................................... Misc.tests.cpp:: PASSED: - REQUIRE( sizeof(TestType) > 0 ) + REQUIRE( std::is_arithmetic::value ) with expansion: - 4 > 0 + true ------------------------------------------------------------------------------- Template test case with test types specified inside std::tuple - MyTypes - 1 @@ -11726,9 +11924,9 @@ Misc.tests.cpp: ............................................................................... Misc.tests.cpp:: PASSED: - REQUIRE( sizeof(TestType) > 0 ) + REQUIRE( std::is_arithmetic::value ) with expansion: - 1 > 0 + true ------------------------------------------------------------------------------- Template test case with test types specified inside std::tuple - MyTypes - 2 @@ -11737,9 +11935,9 @@ Misc.tests.cpp: ............................................................................... Misc.tests.cpp:: PASSED: - REQUIRE( sizeof(TestType) > 0 ) + REQUIRE( std::is_arithmetic::value ) with expansion: - 4 > 0 + true ------------------------------------------------------------------------------- TemplateTest: vectors can be sized and resized - float @@ -13794,7 +13992,7 @@ Exception.tests.cpp: Exception.tests.cpp:: FAILED: due to unexpected exception with message: - 3.14 + 3.14000000000000012 ------------------------------------------------------------------------------- Upcasting special member functions @@ -15038,42 +15236,54 @@ Approx.tests.cpp: Approx.tests.cpp:: PASSED: REQUIRE( d == approx( 1.23 ) ) with expansion: - 1.23 == Approx( 1.23 ) + 1.22999999999999998 + == + Approx( 1.22999999999999998 ) Approx.tests.cpp:: PASSED: REQUIRE( d == approx( 1.22 ) ) with expansion: - 1.23 == Approx( 1.22 ) + 1.22999999999999998 + == + Approx( 1.21999999999999997 ) Approx.tests.cpp:: PASSED: REQUIRE( d == approx( 1.24 ) ) with expansion: - 1.23 == Approx( 1.24 ) + 1.22999999999999998 + == + Approx( 1.23999999999999999 ) Approx.tests.cpp:: PASSED: REQUIRE( d != approx( 1.25 ) ) with expansion: - 1.23 != Approx( 1.25 ) + 1.22999999999999998 != Approx( 1.25 ) Approx.tests.cpp:: PASSED: REQUIRE( approx( d ) == 1.23 ) with expansion: - Approx( 1.23 ) == 1.23 + Approx( 1.22999999999999998 ) + == + 1.22999999999999998 Approx.tests.cpp:: PASSED: REQUIRE( approx( d ) == 1.22 ) with expansion: - Approx( 1.23 ) == 1.22 + Approx( 1.22999999999999998 ) + == + 1.21999999999999997 Approx.tests.cpp:: PASSED: REQUIRE( approx( d ) == 1.24 ) with expansion: - Approx( 1.23 ) == 1.24 + Approx( 1.22999999999999998 ) + == + 1.23999999999999999 Approx.tests.cpp:: PASSED: REQUIRE( approx( d ) != 1.25 ) with expansion: - Approx( 1.23 ) != 1.25 + Approx( 1.22999999999999998 ) != 1.25 ------------------------------------------------------------------------------- Variadic macros @@ -16266,17 +16476,23 @@ InternalBenchmark.tests.cpp: InternalBenchmark.tests.cpp:: PASSED: CHECK( erfc_inv(1.103560) == Approx(-0.09203687623843015) ) with expansion: - -0.0920368762 == Approx( -0.0920368762 ) + -0.09203687623843014 + == + Approx( -0.09203687623843015 ) InternalBenchmark.tests.cpp:: PASSED: CHECK( erfc_inv(1.067400) == Approx(-0.05980291115763361) ) with expansion: - -0.0598029112 == Approx( -0.0598029112 ) + -0.05980291115763361 + == + Approx( -0.05980291115763361 ) InternalBenchmark.tests.cpp:: PASSED: CHECK( erfc_inv(0.050000) == Approx(1.38590382434967796) ) with expansion: - 1.3859038243 == Approx( 1.3859038243 ) + 1.38590382434967774 + == + Approx( 1.38590382434967796 ) ------------------------------------------------------------------------------- estimate_clock_resolution @@ -16932,37 +17148,6 @@ Tricky.tests.cpp:: PASSED: with expansion: {?} == {?} -------------------------------------------------------------------------------- -normal_cdf -------------------------------------------------------------------------------- -InternalBenchmark.tests.cpp: -............................................................................... - -InternalBenchmark.tests.cpp:: PASSED: - CHECK( normal_cdf(0.000000) == Approx(0.50000000000000000) ) -with expansion: - 0.5 == Approx( 0.5 ) - -InternalBenchmark.tests.cpp:: PASSED: - CHECK( normal_cdf(1.000000) == Approx(0.84134474606854293) ) -with expansion: - 0.8413447461 == Approx( 0.8413447461 ) - -InternalBenchmark.tests.cpp:: PASSED: - CHECK( normal_cdf(-1.000000) == Approx(0.15865525393145705) ) -with expansion: - 0.1586552539 == Approx( 0.1586552539 ) - -InternalBenchmark.tests.cpp:: PASSED: - CHECK( normal_cdf(2.809729) == Approx(0.99752083845315409) ) -with expansion: - 0.9975208385 == Approx( 0.9975208385 ) - -InternalBenchmark.tests.cpp:: PASSED: - CHECK( normal_cdf(-1.352570) == Approx(0.08809652095066035) ) -with expansion: - 0.088096521 == Approx( 0.088096521 ) - ------------------------------------------------------------------------------- normal_quantile ------------------------------------------------------------------------------- @@ -16972,17 +17157,23 @@ InternalBenchmark.tests.cpp: InternalBenchmark.tests.cpp:: PASSED: CHECK( normal_quantile(0.551780) == Approx(0.13015979861484198) ) with expansion: - 0.1301597986 == Approx( 0.1301597986 ) + 0.13015979861484195 + == + Approx( 0.13015979861484198 ) InternalBenchmark.tests.cpp:: PASSED: CHECK( normal_quantile(0.533700) == Approx(0.08457408802851875) ) with expansion: - 0.084574088 == Approx( 0.084574088 ) + 0.08457408802851875 + == + Approx( 0.08457408802851875 ) InternalBenchmark.tests.cpp:: PASSED: CHECK( normal_quantile(0.025000) == Approx(-1.95996398454005449) ) with expansion: - -1.9599639845 == Approx( -1.9599639845 ) + -1.95996398454005405 + == + Approx( -1.95996398454005449 ) ------------------------------------------------------------------------------- not allowed @@ -17298,6 +17489,42 @@ StringManip.tests.cpp:: PASSED: with expansion: "abcdefcg" == "abcdefcg" +------------------------------------------------------------------------------- +replaceInPlace + no replace in already-replaced string + lengthening +------------------------------------------------------------------------------- +StringManip.tests.cpp: +............................................................................... + +StringManip.tests.cpp:: PASSED: + CHECK( Catch::replaceInPlace(letters, "c", "cc") ) +with expansion: + true + +StringManip.tests.cpp:: PASSED: + CHECK( letters == "abccdefccg" ) +with expansion: + "abccdefccg" == "abccdefccg" + +------------------------------------------------------------------------------- +replaceInPlace + no replace in already-replaced string + shortening +------------------------------------------------------------------------------- +StringManip.tests.cpp: +............................................................................... + +StringManip.tests.cpp:: PASSED: + CHECK( Catch::replaceInPlace(s, "--", "-") ) +with expansion: + true + +StringManip.tests.cpp:: PASSED: + CHECK( s == "--" ) +with expansion: + "--" == "--" + ------------------------------------------------------------------------------- replaceInPlace escape ' @@ -18165,14 +18392,14 @@ ToStringTuple.tests.cpp: ............................................................................... ToStringTuple.tests.cpp:: PASSED: - CHECK( "1.2f" == ::Catch::Detail::stringify(float(1.2)) ) + CHECK( "1.5f" == ::Catch::Detail::stringify(float(1.5)) ) with expansion: - "1.2f" == "1.2f" + "1.5f" == "1.5f" ToStringTuple.tests.cpp:: PASSED: - CHECK( "{ 1.2f, 0 }" == ::Catch::Detail::stringify(type{1.2f,0}) ) + CHECK( "{ 1.5f, 0 }" == ::Catch::Detail::stringify(type{1.5f,0}) ) with expansion: - "{ 1.2f, 0 }" == "{ 1.2f, 0 }" + "{ 1.5f, 0 }" == "{ 1.5f, 0 }" ------------------------------------------------------------------------------- tuple @@ -18205,11 +18432,11 @@ ToStringTuple.tests.cpp: ............................................................................... ToStringTuple.tests.cpp:: PASSED: - CHECK( "{ { 42 }, { }, 1.2f }" == ::Catch::Detail::stringify(value) ) + CHECK( "{ { 42 }, { }, 1.5f }" == ::Catch::Detail::stringify(value) ) with expansion: - "{ { 42 }, { }, 1.2f }" + "{ { 42 }, { }, 1.5f }" == - "{ { 42 }, { }, 1.2f }" + "{ { 42 }, { }, 1.5f }" ------------------------------------------------------------------------------- uniform samples @@ -18235,7 +18462,7 @@ with expansion: InternalBenchmark.tests.cpp:: PASSED: CHECK( e.confidence_interval == 0.95 ) with expansion: - 0.95 == 0.95 + 0.94999999999999996 == 0.94999999999999996 ------------------------------------------------------------------------------- uniform_integer_distribution can return the bounds @@ -18740,6 +18967,6 @@ Misc.tests.cpp: Misc.tests.cpp:: PASSED: =============================================================================== -test cases: 417 | 312 passed | 85 failed | 6 skipped | 14 failed as expected -assertions: 2260 | 2079 passed | 146 failed | 35 failed as expected +test cases: 419 | 313 passed | 86 failed | 6 skipped | 14 failed as expected +assertions: 2265 | 2083 passed | 147 failed | 35 failed as expected diff --git a/tests/SelfTest/Baselines/junit.sw.approved.txt b/tests/SelfTest/Baselines/junit.sw.approved.txt index 48eccfc3d1..33f207c5d2 100644 --- a/tests/SelfTest/Baselines/junit.sw.approved.txt +++ b/tests/SelfTest/Baselines/junit.sw.approved.txt @@ -1,7 +1,7 @@ - + @@ -12,6 +12,7 @@ + @@ -30,10 +31,12 @@ Nor would this + + @@ -56,6 +59,7 @@ failure to init at Generators.tests.cpp: + @@ -89,6 +93,7 @@ at Misc.tests.cpp: + @@ -147,6 +152,7 @@ at Condition.tests.cpp: + @@ -313,6 +319,19 @@ at Class.tests.cpp: + + + +FAILED: + REQUIRE( m_a == 0 ) +with expansion: + 1 == 0 +at Class.tests.cpp: + + + + + @@ -329,6 +348,7 @@ to infinity and beyond at Misc.tests.cpp: + @@ -347,6 +367,7 @@ at Tricky.tests.cpp: + @@ -364,6 +385,7 @@ at Exception.tests.cpp: + @@ -371,30 +393,39 @@ at Exception.tests.cpp: + + + + + + + + + @@ -412,8 +443,10 @@ at Exception.tests.cpp: + + @@ -433,6 +466,7 @@ with expansion: at Matchers.tests.cpp: + @@ -517,35 +551,39 @@ at Condition.tests.cpp: FAILED: CHECK( data.float_nine_point_one == Approx( 9.11f ) ) with expansion: - 9.1f == Approx( 9.1099996567 ) + 9.100000381f + == + Approx( 9.10999965667724609 ) at Condition.tests.cpp: FAILED: CHECK( data.float_nine_point_one == Approx( 9.0f ) ) with expansion: - 9.1f == Approx( 9.0 ) + 9.100000381f == Approx( 9.0 ) at Condition.tests.cpp: FAILED: CHECK( data.float_nine_point_one == Approx( 1 ) ) with expansion: - 9.1f == Approx( 1.0 ) + 9.100000381f == Approx( 1.0 ) at Condition.tests.cpp: FAILED: CHECK( data.float_nine_point_one == Approx( 0 ) ) with expansion: - 9.1f == Approx( 0.0 ) + 9.100000381f == Approx( 0.0 ) at Condition.tests.cpp: FAILED: CHECK( data.double_pi == Approx( 3.1415 ) ) with expansion: - 3.1415926535 == Approx( 3.1415 ) + 3.14159265350000005 + == + Approx( 3.14150000000000018 ) at Condition.tests.cpp: @@ -580,7 +618,9 @@ at Condition.tests.cpp: FAILED: CHECK( x == Approx( 1.301 ) ) with expansion: - 1.3 == Approx( 1.301 ) + 1.30000000000000027 + == + Approx( 1.30099999999999993 ) at Condition.tests.cpp: @@ -649,6 +689,7 @@ at Matchers.tests.cpp: + @@ -694,6 +735,7 @@ at Message.tests.cpp: + @@ -701,6 +743,7 @@ at Message.tests.cpp: + @@ -709,46 +752,64 @@ at Message.tests.cpp: + + + + + + + + + + + + + + + + + + @@ -828,14 +889,18 @@ at Condition.tests.cpp: FAILED: CHECK( data.float_nine_point_one != Approx( 9.1f ) ) with expansion: - 9.1f != Approx( 9.1000003815 ) + 9.100000381f + != + Approx( 9.10000038146972656 ) at Condition.tests.cpp: FAILED: CHECK( data.double_pi != Approx( 3.1415926535 ) ) with expansion: - 3.1415926535 != Approx( 3.1415926535 ) + 3.14159265350000005 + != + Approx( 3.14159265350000005 ) at Condition.tests.cpp: @@ -854,6 +919,7 @@ at Condition.tests.cpp: + @@ -863,6 +929,7 @@ at Condition.tests.cpp: + @@ -898,6 +965,9 @@ with expansion: at Matchers.tests.cpp: + + + @@ -905,6 +975,9 @@ FAILED: at Condition.tests.cpp: + + + @@ -912,6 +985,9 @@ FAILED: at Condition.tests.cpp: + + + @@ -919,6 +995,9 @@ FAILED: at Condition.tests.cpp: + + + @@ -1011,21 +1090,21 @@ at Condition.tests.cpp: FAILED: CHECK( data.float_nine_point_one < 9 ) with expansion: - 9.1f < 9 + 9.100000381f < 9 at Condition.tests.cpp: FAILED: CHECK( data.float_nine_point_one > 10 ) with expansion: - 9.1f > 10 + 9.100000381f > 10 at Condition.tests.cpp: FAILED: CHECK( data.float_nine_point_one > 9.2 ) with expansion: - 9.1f > 9.2 + 9.100000381f > 9.19999999999999929 at Condition.tests.cpp: @@ -1086,6 +1165,7 @@ at Condition.tests.cpp: + @@ -1103,9 +1183,11 @@ at Message.tests.cpp: + + @@ -1113,44 +1195,58 @@ at Message.tests.cpp: + + + + + + + + + + + + + + @@ -1230,14 +1326,27 @@ at Matchers.tests.cpp: + + + + + + + + + + + + + @@ -1249,6 +1358,8 @@ A string sent to stderr via clog + + Message from section one @@ -1272,15 +1383,18 @@ with expansion: at Matchers.tests.cpp: + + + @@ -1289,13 +1403,16 @@ at Matchers.tests.cpp: + + + @@ -1320,6 +1437,7 @@ with expansion: at Misc.tests.cpp: + @@ -1419,6 +1537,7 @@ at Misc.tests.cpp: + @@ -1442,91 +1561,126 @@ at Exception.tests.cpp: + + + + FAILED: -3.14 +3.14000000000000012 at Exception.tests.cpp: + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + FAILED: @@ -1545,11 +1699,13 @@ with expansion: at Matchers.tests.cpp: + + FAILED: @@ -1681,10 +1837,12 @@ unexpected exception at Exception.tests.cpp: + + @@ -1702,6 +1860,7 @@ at Skip.tests.cpp: + @@ -1725,6 +1884,7 @@ with expansion: at Misc.tests.cpp: + @@ -1749,6 +1909,8 @@ at Skip.tests.cpp: + + @@ -1795,6 +1957,8 @@ FAILED: at Skip.tests.cpp: + + @@ -1810,7 +1974,10 @@ previous unscoped info SHOULD not be seen at Message.tests.cpp: + + + FAILED: @@ -1888,12 +2055,15 @@ at Misc.tests.cpp: + + + FAILED: @@ -1903,10 +2073,15 @@ with expansion: at Misc.tests.cpp: + + + + + SKIPPED @@ -1922,7 +2097,6 @@ b1! - @@ -1936,6 +2110,7 @@ at Message.tests.cpp: + @@ -1958,19 +2133,26 @@ this SHOULD be seen only ONCE at Message.tests.cpp: + + + + + + + @@ -2026,11 +2208,13 @@ at Message.tests.cpp: + + @@ -2076,6 +2260,7 @@ at Exception.tests.cpp: + @@ -2097,6 +2282,7 @@ at Exception.tests.cpp: + diff --git a/tests/SelfTest/Baselines/junit.sw.multi.approved.txt b/tests/SelfTest/Baselines/junit.sw.multi.approved.txt index d270c88fb6..876a4db47d 100644 --- a/tests/SelfTest/Baselines/junit.sw.multi.approved.txt +++ b/tests/SelfTest/Baselines/junit.sw.multi.approved.txt @@ -1,6 +1,6 @@ - + @@ -11,6 +11,7 @@ + @@ -29,10 +30,12 @@ Nor would this + + @@ -55,6 +58,7 @@ failure to init at Generators.tests.cpp: + @@ -88,6 +92,7 @@ at Misc.tests.cpp: + @@ -146,6 +151,7 @@ at Condition.tests.cpp: + @@ -312,6 +318,19 @@ at Class.tests.cpp: + + + +FAILED: + REQUIRE( m_a == 0 ) +with expansion: + 1 == 0 +at Class.tests.cpp: + + + + + @@ -328,6 +347,7 @@ to infinity and beyond at Misc.tests.cpp: + @@ -346,6 +366,7 @@ at Tricky.tests.cpp: + @@ -363,6 +384,7 @@ at Exception.tests.cpp: + @@ -370,30 +392,39 @@ at Exception.tests.cpp: + + + + + + + + + @@ -411,8 +442,10 @@ at Exception.tests.cpp: + + @@ -432,6 +465,7 @@ with expansion: at Matchers.tests.cpp: + @@ -516,35 +550,39 @@ at Condition.tests.cpp: FAILED: CHECK( data.float_nine_point_one == Approx( 9.11f ) ) with expansion: - 9.1f == Approx( 9.1099996567 ) + 9.100000381f + == + Approx( 9.10999965667724609 ) at Condition.tests.cpp: FAILED: CHECK( data.float_nine_point_one == Approx( 9.0f ) ) with expansion: - 9.1f == Approx( 9.0 ) + 9.100000381f == Approx( 9.0 ) at Condition.tests.cpp: FAILED: CHECK( data.float_nine_point_one == Approx( 1 ) ) with expansion: - 9.1f == Approx( 1.0 ) + 9.100000381f == Approx( 1.0 ) at Condition.tests.cpp: FAILED: CHECK( data.float_nine_point_one == Approx( 0 ) ) with expansion: - 9.1f == Approx( 0.0 ) + 9.100000381f == Approx( 0.0 ) at Condition.tests.cpp: FAILED: CHECK( data.double_pi == Approx( 3.1415 ) ) with expansion: - 3.1415926535 == Approx( 3.1415 ) + 3.14159265350000005 + == + Approx( 3.14150000000000018 ) at Condition.tests.cpp: @@ -579,7 +617,9 @@ at Condition.tests.cpp: FAILED: CHECK( x == Approx( 1.301 ) ) with expansion: - 1.3 == Approx( 1.301 ) + 1.30000000000000027 + == + Approx( 1.30099999999999993 ) at Condition.tests.cpp: @@ -648,6 +688,7 @@ at Matchers.tests.cpp: + @@ -693,6 +734,7 @@ at Message.tests.cpp: + @@ -700,6 +742,7 @@ at Message.tests.cpp: + @@ -708,46 +751,64 @@ at Message.tests.cpp: + + + + + + + + + + + + + + + + + + @@ -827,14 +888,18 @@ at Condition.tests.cpp: FAILED: CHECK( data.float_nine_point_one != Approx( 9.1f ) ) with expansion: - 9.1f != Approx( 9.1000003815 ) + 9.100000381f + != + Approx( 9.10000038146972656 ) at Condition.tests.cpp: FAILED: CHECK( data.double_pi != Approx( 3.1415926535 ) ) with expansion: - 3.1415926535 != Approx( 3.1415926535 ) + 3.14159265350000005 + != + Approx( 3.14159265350000005 ) at Condition.tests.cpp: @@ -853,6 +918,7 @@ at Condition.tests.cpp: + @@ -862,6 +928,7 @@ at Condition.tests.cpp: + @@ -897,6 +964,9 @@ with expansion: at Matchers.tests.cpp: + + + @@ -904,6 +974,9 @@ FAILED: at Condition.tests.cpp: + + + @@ -911,6 +984,9 @@ FAILED: at Condition.tests.cpp: + + + @@ -918,6 +994,9 @@ FAILED: at Condition.tests.cpp: + + + @@ -1010,21 +1089,21 @@ at Condition.tests.cpp: FAILED: CHECK( data.float_nine_point_one < 9 ) with expansion: - 9.1f < 9 + 9.100000381f < 9 at Condition.tests.cpp: FAILED: CHECK( data.float_nine_point_one > 10 ) with expansion: - 9.1f > 10 + 9.100000381f > 10 at Condition.tests.cpp: FAILED: CHECK( data.float_nine_point_one > 9.2 ) with expansion: - 9.1f > 9.2 + 9.100000381f > 9.19999999999999929 at Condition.tests.cpp: @@ -1085,6 +1164,7 @@ at Condition.tests.cpp: + @@ -1102,9 +1182,11 @@ at Message.tests.cpp: + + @@ -1112,44 +1194,58 @@ at Message.tests.cpp: + + + + + + + + + + + + + + @@ -1229,14 +1325,27 @@ at Matchers.tests.cpp: + + + + + + + + + + + + + @@ -1248,6 +1357,8 @@ A string sent to stderr via clog + + Message from section one @@ -1271,15 +1382,18 @@ with expansion: at Matchers.tests.cpp: + + + @@ -1288,13 +1402,16 @@ at Matchers.tests.cpp: + + + @@ -1319,6 +1436,7 @@ with expansion: at Misc.tests.cpp: + @@ -1418,6 +1536,7 @@ at Misc.tests.cpp: + @@ -1441,91 +1560,126 @@ at Exception.tests.cpp: + + + + FAILED: -3.14 +3.14000000000000012 at Exception.tests.cpp: + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + FAILED: @@ -1544,11 +1698,13 @@ with expansion: at Matchers.tests.cpp: + + FAILED: @@ -1680,10 +1836,12 @@ unexpected exception at Exception.tests.cpp: + + @@ -1701,6 +1859,7 @@ at Skip.tests.cpp: + @@ -1724,6 +1883,7 @@ with expansion: at Misc.tests.cpp: + @@ -1748,6 +1908,8 @@ at Skip.tests.cpp: + + @@ -1794,6 +1956,8 @@ FAILED: at Skip.tests.cpp: + + @@ -1809,7 +1973,10 @@ previous unscoped info SHOULD not be seen at Message.tests.cpp: + + + FAILED: @@ -1887,12 +2054,15 @@ at Misc.tests.cpp: + + + FAILED: @@ -1902,10 +2072,15 @@ with expansion: at Misc.tests.cpp: + + + + + SKIPPED @@ -1921,7 +2096,6 @@ b1! - @@ -1935,6 +2109,7 @@ at Message.tests.cpp: + @@ -1957,19 +2132,26 @@ this SHOULD be seen only ONCE at Message.tests.cpp: + + + + + + + @@ -2025,11 +2207,13 @@ at Message.tests.cpp: + + @@ -2075,6 +2259,7 @@ at Exception.tests.cpp: + @@ -2096,6 +2281,7 @@ at Exception.tests.cpp: + diff --git a/tests/SelfTest/Baselines/sonarqube.sw.approved.txt b/tests/SelfTest/Baselines/sonarqube.sw.approved.txt index 36b05e54dc..1839724099 100644 --- a/tests/SelfTest/Baselines/sonarqube.sw.approved.txt +++ b/tests/SelfTest/Baselines/sonarqube.sw.approved.txt @@ -13,52 +13,68 @@ at AssertionHandler.tests.cpp: + + + + + + + + + + + + + + + + @@ -67,13 +83,16 @@ at AssertionHandler.tests.cpp: + + + @@ -82,35 +101,49 @@ at AssertionHandler.tests.cpp: + + + + + + + + + + + + + + @@ -121,7 +154,6 @@ at AssertionHandler.tests.cpp: - @@ -131,6 +163,7 @@ at AssertionHandler.tests.cpp: + @@ -140,6 +173,7 @@ at AssertionHandler.tests.cpp: + @@ -151,10 +185,12 @@ at AssertionHandler.tests.cpp: + + @@ -177,6 +213,7 @@ at AssertionHandler.tests.cpp: + @@ -218,6 +255,7 @@ at AssertionHandler.tests.cpp: + @@ -231,11 +269,13 @@ at AssertionHandler.tests.cpp: + + @@ -244,29 +284,37 @@ at AssertionHandler.tests.cpp: + + + + + + + + @@ -278,6 +326,7 @@ at AssertionHandler.tests.cpp: + @@ -285,6 +334,7 @@ at AssertionHandler.tests.cpp: + @@ -298,16 +348,20 @@ at AssertionHandler.tests.cpp: + + + + @@ -318,6 +372,7 @@ at AssertionHandler.tests.cpp: + @@ -347,14 +402,27 @@ at AssertionHandler.tests.cpp: + + + + + + + + + + + + + @@ -518,6 +586,19 @@ at Class.tests.cpp: + + + +FAILED: + REQUIRE( m_a == 0 ) +with expansion: + 1 == 0 +at Class.tests.cpp: + + + + + @@ -527,6 +608,7 @@ at Class.tests.cpp: + @@ -620,35 +702,39 @@ at Condition.tests.cpp: FAILED: CHECK( data.float_nine_point_one == Approx( 9.11f ) ) with expansion: - 9.1f == Approx( 9.1099996567 ) + 9.100000381f +== +Approx( 9.10999965667724609 ) at Condition.tests.cpp: FAILED: CHECK( data.float_nine_point_one == Approx( 9.0f ) ) with expansion: - 9.1f == Approx( 9.0 ) + 9.100000381f == Approx( 9.0 ) at Condition.tests.cpp: FAILED: CHECK( data.float_nine_point_one == Approx( 1 ) ) with expansion: - 9.1f == Approx( 1.0 ) + 9.100000381f == Approx( 1.0 ) at Condition.tests.cpp: FAILED: CHECK( data.float_nine_point_one == Approx( 0 ) ) with expansion: - 9.1f == Approx( 0.0 ) + 9.100000381f == Approx( 0.0 ) at Condition.tests.cpp: FAILED: CHECK( data.double_pi == Approx( 3.1415 ) ) with expansion: - 3.1415926535 == Approx( 3.1415 ) + 3.14159265350000005 +== +Approx( 3.14150000000000018 ) at Condition.tests.cpp: @@ -683,7 +769,9 @@ at Condition.tests.cpp: FAILED: CHECK( x == Approx( 1.301 ) ) with expansion: - 1.3 == Approx( 1.301 ) + 1.30000000000000027 +== +Approx( 1.30099999999999993 ) at Condition.tests.cpp: @@ -700,14 +788,18 @@ at Condition.tests.cpp: FAILED: CHECK( data.float_nine_point_one != Approx( 9.1f ) ) with expansion: - 9.1f != Approx( 9.1000003815 ) + 9.100000381f +!= +Approx( 9.10000038146972656 ) at Condition.tests.cpp: FAILED: CHECK( data.double_pi != Approx( 3.1415926535 ) ) with expansion: - 3.1415926535 != Approx( 3.1415926535 ) + 3.14159265350000005 +!= +Approx( 3.14159265350000005 ) at Condition.tests.cpp: @@ -726,24 +818,28 @@ at Condition.tests.cpp: + FAILED: at Condition.tests.cpp: + FAILED: at Condition.tests.cpp: + FAILED: at Condition.tests.cpp: + FAILED: @@ -811,21 +907,21 @@ at Condition.tests.cpp: FAILED: CHECK( data.float_nine_point_one < 9 ) with expansion: - 9.1f < 9 + 9.100000381f < 9 at Condition.tests.cpp: FAILED: CHECK( data.float_nine_point_one > 10 ) with expansion: - 9.1f > 10 + 9.100000381f > 10 at Condition.tests.cpp: FAILED: CHECK( data.float_nine_point_one > 9.2 ) with expansion: - 9.1f > 9.2 + 9.100000381f > 9.19999999999999929 at Condition.tests.cpp: @@ -910,6 +1006,7 @@ at Decomposition.tests.cpp: + FAILED: @@ -959,6 +1056,7 @@ custom std exception at Exception.tests.cpp: + @@ -1007,7 +1105,7 @@ at Exception.tests.cpp: FAILED: -3.14 +3.14000000000000012 at Exception.tests.cpp: @@ -1050,6 +1148,7 @@ unexpected exception at Exception.tests.cpp: + FAILED: @@ -1069,21 +1168,27 @@ at Generators.tests.cpp: + + + + + + @@ -1093,6 +1198,7 @@ at Generators.tests.cpp: + @@ -1102,8 +1208,10 @@ at Generators.tests.cpp: + + @@ -1200,6 +1308,7 @@ at Matchers.tests.cpp: + @@ -1207,6 +1316,7 @@ at Matchers.tests.cpp: + @@ -1279,10 +1389,13 @@ at Matchers.tests.cpp: + + + FAILED: @@ -1301,11 +1414,13 @@ with expansion: at Matchers.tests.cpp: + + FAILED: @@ -1400,82 +1515,114 @@ at Matchers.tests.cpp: + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + @@ -1574,6 +1721,8 @@ at Message.tests.cpp: + + @@ -1590,6 +1739,8 @@ previous unscoped info SHOULD not be seen at Message.tests.cpp: + + @@ -1662,6 +1813,7 @@ with expansion: at Misc.tests.cpp: + @@ -1682,7 +1834,9 @@ to infinity and beyond at Misc.tests.cpp: + + @@ -1811,10 +1965,14 @@ with expansion: at Misc.tests.cpp: + + + + FAILED: @@ -1891,6 +2049,8 @@ Testing if fib[7] (21) is even at Misc.tests.cpp: + + FAILED: @@ -1900,14 +2060,18 @@ with expansion: at Misc.tests.cpp: + + + + FAILED: @@ -1926,6 +2090,7 @@ at Misc.tests.cpp: + @@ -1996,6 +2161,9 @@ FAILED: at Skip.tests.cpp: + + + SKIPPED @@ -2003,6 +2171,7 @@ at Skip.tests.cpp: + @@ -2031,20 +2200,26 @@ at Skip.tests.cpp: + + + + + + @@ -2089,6 +2264,7 @@ FAILED: at Tricky.tests.cpp: + @@ -2124,6 +2300,7 @@ at Tricky.tests.cpp: + @@ -2132,6 +2309,7 @@ at Tricky.tests.cpp: + diff --git a/tests/SelfTest/Baselines/sonarqube.sw.multi.approved.txt b/tests/SelfTest/Baselines/sonarqube.sw.multi.approved.txt index c9d3d205bb..77348788ad 100644 --- a/tests/SelfTest/Baselines/sonarqube.sw.multi.approved.txt +++ b/tests/SelfTest/Baselines/sonarqube.sw.multi.approved.txt @@ -12,52 +12,68 @@ at AssertionHandler.tests.cpp: + + + + + + + + + + + + + + + + @@ -66,13 +82,16 @@ at AssertionHandler.tests.cpp: + + + @@ -81,35 +100,49 @@ at AssertionHandler.tests.cpp: + + + + + + + + + + + + + + @@ -120,7 +153,6 @@ at AssertionHandler.tests.cpp: - @@ -130,6 +162,7 @@ at AssertionHandler.tests.cpp: + @@ -139,6 +172,7 @@ at AssertionHandler.tests.cpp: + @@ -150,10 +184,12 @@ at AssertionHandler.tests.cpp: + + @@ -176,6 +212,7 @@ at AssertionHandler.tests.cpp: + @@ -217,6 +254,7 @@ at AssertionHandler.tests.cpp: + @@ -230,11 +268,13 @@ at AssertionHandler.tests.cpp: + + @@ -243,29 +283,37 @@ at AssertionHandler.tests.cpp: + + + + + + + + @@ -277,6 +325,7 @@ at AssertionHandler.tests.cpp: + @@ -284,6 +333,7 @@ at AssertionHandler.tests.cpp: + @@ -297,16 +347,20 @@ at AssertionHandler.tests.cpp: + + + + @@ -317,6 +371,7 @@ at AssertionHandler.tests.cpp: + @@ -346,14 +401,27 @@ at AssertionHandler.tests.cpp: + + + + + + + + + + + + + @@ -517,6 +585,19 @@ at Class.tests.cpp: + + + +FAILED: + REQUIRE( m_a == 0 ) +with expansion: + 1 == 0 +at Class.tests.cpp: + + + + + @@ -526,6 +607,7 @@ at Class.tests.cpp: + @@ -619,35 +701,39 @@ at Condition.tests.cpp: FAILED: CHECK( data.float_nine_point_one == Approx( 9.11f ) ) with expansion: - 9.1f == Approx( 9.1099996567 ) + 9.100000381f +== +Approx( 9.10999965667724609 ) at Condition.tests.cpp: FAILED: CHECK( data.float_nine_point_one == Approx( 9.0f ) ) with expansion: - 9.1f == Approx( 9.0 ) + 9.100000381f == Approx( 9.0 ) at Condition.tests.cpp: FAILED: CHECK( data.float_nine_point_one == Approx( 1 ) ) with expansion: - 9.1f == Approx( 1.0 ) + 9.100000381f == Approx( 1.0 ) at Condition.tests.cpp: FAILED: CHECK( data.float_nine_point_one == Approx( 0 ) ) with expansion: - 9.1f == Approx( 0.0 ) + 9.100000381f == Approx( 0.0 ) at Condition.tests.cpp: FAILED: CHECK( data.double_pi == Approx( 3.1415 ) ) with expansion: - 3.1415926535 == Approx( 3.1415 ) + 3.14159265350000005 +== +Approx( 3.14150000000000018 ) at Condition.tests.cpp: @@ -682,7 +768,9 @@ at Condition.tests.cpp: FAILED: CHECK( x == Approx( 1.301 ) ) with expansion: - 1.3 == Approx( 1.301 ) + 1.30000000000000027 +== +Approx( 1.30099999999999993 ) at Condition.tests.cpp: @@ -699,14 +787,18 @@ at Condition.tests.cpp: FAILED: CHECK( data.float_nine_point_one != Approx( 9.1f ) ) with expansion: - 9.1f != Approx( 9.1000003815 ) + 9.100000381f +!= +Approx( 9.10000038146972656 ) at Condition.tests.cpp: FAILED: CHECK( data.double_pi != Approx( 3.1415926535 ) ) with expansion: - 3.1415926535 != Approx( 3.1415926535 ) + 3.14159265350000005 +!= +Approx( 3.14159265350000005 ) at Condition.tests.cpp: @@ -725,24 +817,28 @@ at Condition.tests.cpp: + FAILED: at Condition.tests.cpp: + FAILED: at Condition.tests.cpp: + FAILED: at Condition.tests.cpp: + FAILED: @@ -810,21 +906,21 @@ at Condition.tests.cpp: FAILED: CHECK( data.float_nine_point_one < 9 ) with expansion: - 9.1f < 9 + 9.100000381f < 9 at Condition.tests.cpp: FAILED: CHECK( data.float_nine_point_one > 10 ) with expansion: - 9.1f > 10 + 9.100000381f > 10 at Condition.tests.cpp: FAILED: CHECK( data.float_nine_point_one > 9.2 ) with expansion: - 9.1f > 9.2 + 9.100000381f > 9.19999999999999929 at Condition.tests.cpp: @@ -909,6 +1005,7 @@ at Decomposition.tests.cpp: + FAILED: @@ -958,6 +1055,7 @@ custom std exception at Exception.tests.cpp: + @@ -1006,7 +1104,7 @@ at Exception.tests.cpp: FAILED: -3.14 +3.14000000000000012 at Exception.tests.cpp: @@ -1049,6 +1147,7 @@ unexpected exception at Exception.tests.cpp: + FAILED: @@ -1068,21 +1167,27 @@ at Generators.tests.cpp: + + + + + + @@ -1092,6 +1197,7 @@ at Generators.tests.cpp: + @@ -1101,8 +1207,10 @@ at Generators.tests.cpp: + + @@ -1199,6 +1307,7 @@ at Matchers.tests.cpp: + @@ -1206,6 +1315,7 @@ at Matchers.tests.cpp: + @@ -1278,10 +1388,13 @@ at Matchers.tests.cpp: + + + FAILED: @@ -1300,11 +1413,13 @@ with expansion: at Matchers.tests.cpp: + + FAILED: @@ -1399,82 +1514,114 @@ at Matchers.tests.cpp: + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + @@ -1573,6 +1720,8 @@ at Message.tests.cpp: + + @@ -1589,6 +1738,8 @@ previous unscoped info SHOULD not be seen at Message.tests.cpp: + + @@ -1661,6 +1812,7 @@ with expansion: at Misc.tests.cpp: + @@ -1681,7 +1833,9 @@ to infinity and beyond at Misc.tests.cpp: + + @@ -1810,10 +1964,14 @@ with expansion: at Misc.tests.cpp: + + + + FAILED: @@ -1890,6 +2048,8 @@ Testing if fib[7] (21) is even at Misc.tests.cpp: + + FAILED: @@ -1899,14 +2059,18 @@ with expansion: at Misc.tests.cpp: + + + + FAILED: @@ -1925,6 +2089,7 @@ at Misc.tests.cpp: + @@ -1995,6 +2160,9 @@ FAILED: at Skip.tests.cpp: + + + SKIPPED @@ -2002,6 +2170,7 @@ at Skip.tests.cpp: + @@ -2030,20 +2199,26 @@ at Skip.tests.cpp: + + + + + + @@ -2088,6 +2263,7 @@ FAILED: at Tricky.tests.cpp: + @@ -2123,6 +2299,7 @@ at Tricky.tests.cpp: + @@ -2131,6 +2308,7 @@ at Tricky.tests.cpp: + diff --git a/tests/SelfTest/Baselines/tap.sw.approved.txt b/tests/SelfTest/Baselines/tap.sw.approved.txt index a02dbd9543..ea53d4210b 100644 --- a/tests/SelfTest/Baselines/tap.sw.approved.txt +++ b/tests/SelfTest/Baselines/tap.sw.approved.txt @@ -478,6 +478,14 @@ ok {test-number} - Nttp_Fixture::value > 0 for: 6 > 0 not ok {test-number} - m_a == 2 for: 1 == 2 # A TEST_CASE_METHOD based test run that succeeds ok {test-number} - m_a == 1 for: 1 == 1 +# A TEST_CASE_PERSISTENT_FIXTURE based test run that fails +ok {test-number} - m_a++ == 0 for: 0 == 0 +# A TEST_CASE_PERSISTENT_FIXTURE based test run that fails +not ok {test-number} - m_a == 0 for: 1 == 0 +# A TEST_CASE_PERSISTENT_FIXTURE based test run that succeeds +ok {test-number} - m_a++ == 0 for: 0 == 0 +# A TEST_CASE_PERSISTENT_FIXTURE based test run that succeeds +ok {test-number} - m_a == 1 for: 1 == 1 # A Template product test case - Foo ok {test-number} - x.size() == 0 for: 0 == 0 # A Template product test case - Foo @@ -495,17 +503,17 @@ ok {test-number} - x.size() > 0 for: 42 > 0 # A Template product test case with array signature - std::array ok {test-number} - x.size() > 0 for: 9 > 0 # A comparison that uses literals instead of the normal constructor -ok {test-number} - d == 1.23_a for: 1.23 == Approx( 1.23 ) +ok {test-number} - d == 1.23_a for: 1.22999999999999998 == Approx( 1.22999999999999998 ) # A comparison that uses literals instead of the normal constructor -ok {test-number} - d != 1.22_a for: 1.23 != Approx( 1.22 ) +ok {test-number} - d != 1.22_a for: 1.22999999999999998 != Approx( 1.21999999999999997 ) # A comparison that uses literals instead of the normal constructor -ok {test-number} - -d == -1.23_a for: -1.23 == Approx( -1.23 ) +ok {test-number} - -d == -1.23_a for: -1.22999999999999998 == Approx( -1.22999999999999998 ) # A comparison that uses literals instead of the normal constructor -ok {test-number} - d == 1.2_a .epsilon(.1) for: 1.23 == Approx( 1.2 ) +ok {test-number} - d == 1.2_a .epsilon(.1) for: 1.22999999999999998 == Approx( 1.19999999999999996 ) # A comparison that uses literals instead of the normal constructor -ok {test-number} - d != 1.2_a .epsilon(.001) for: 1.23 != Approx( 1.2 ) +ok {test-number} - d != 1.2_a .epsilon(.001) for: 1.22999999999999998 != Approx( 1.19999999999999996 ) # A comparison that uses literals instead of the normal constructor -ok {test-number} - d == 1_a .epsilon(.3) for: 1.23 == Approx( 1.0 ) +ok {test-number} - d == 1_a .epsilon(.3) for: 1.22999999999999998 == Approx( 1.0 ) # A couple of nested sections followed by a failure ok {test-number} - with 1 message: 'that's not flying - that's failing in style' # A couple of nested sections followed by a failure @@ -523,9 +531,9 @@ ok {test-number} - 104.0 == Approx(100.0).margin(4) for: 104.0 == Approx( 100.0 # Absolute margin ok {test-number} - 104.0 != Approx(100.0).margin(3) for: 104.0 != Approx( 100.0 ) # Absolute margin -ok {test-number} - 100.3 != Approx(100.0) for: 100.3 != Approx( 100.0 ) +ok {test-number} - 100.3 != Approx(100.0) for: 100.29999999999999716 != Approx( 100.0 ) # Absolute margin -ok {test-number} - 100.3 == Approx(100.0).margin(0.5) for: 100.3 == Approx( 100.0 ) +ok {test-number} - 100.3 == Approx(100.0).margin(0.5) for: 100.29999999999999716 == Approx( 100.0 ) # An expression with side-effects should only be evaluated once ok {test-number} - i++ == 7 for: 7 == 7 # An expression with side-effects should only be evaluated once @@ -561,15 +569,15 @@ ok {test-number} - 245.0f == Approx(245.25f).margin(0.25f) for: 245.0f == Approx # Approx with exactly-representable margin ok {test-number} - 245.5f == Approx(245.25f).margin(0.25f) for: 245.5f == Approx( 245.25 ) # Approximate PI -ok {test-number} - divide( 22, 7 ) == Approx( 3.141 ).epsilon( 0.001 ) for: 3.1428571429 == Approx( 3.141 ) +ok {test-number} - divide( 22, 7 ) == Approx( 3.141 ).epsilon( 0.001 ) for: 3.14285714285714279 == Approx( 3.14100000000000001 ) # Approximate PI -ok {test-number} - divide( 22, 7 ) != Approx( 3.141 ).epsilon( 0.0001 ) for: 3.1428571429 != Approx( 3.141 ) +ok {test-number} - divide( 22, 7 ) != Approx( 3.141 ).epsilon( 0.0001 ) for: 3.14285714285714279 != Approx( 3.14100000000000001 ) # Approximate comparisons with different epsilons -ok {test-number} - d != Approx( 1.231 ) for: 1.23 != Approx( 1.231 ) +ok {test-number} - d != Approx( 1.231 ) for: 1.22999999999999998 != Approx( 1.23100000000000009 ) # Approximate comparisons with different epsilons -ok {test-number} - d == Approx( 1.231 ).epsilon( 0.1 ) for: 1.23 == Approx( 1.231 ) +ok {test-number} - d == Approx( 1.231 ).epsilon( 0.1 ) for: 1.22999999999999998 == Approx( 1.23100000000000009 ) # Approximate comparisons with floats -ok {test-number} - 1.23f == Approx( 1.23f ) for: 1.23f == Approx( 1.2300000191 ) +ok {test-number} - 1.23f == Approx( 1.23f ) for: 1.230000019f == Approx( 1.23000001907348633 ) # Approximate comparisons with floats ok {test-number} - 0.0f == Approx( 0.0f ) for: 0.0f == Approx( 0.0 ) # Approximate comparisons with ints @@ -583,9 +591,9 @@ ok {test-number} - 0 == Approx( dZero) for: 0 == Approx( 0.0 ) # Approximate comparisons with mixed numeric types ok {test-number} - 0 == Approx( dSmall ).margin( 0.001 ) for: 0 == Approx( 0.00001 ) # Approximate comparisons with mixed numeric types -ok {test-number} - 1.234f == Approx( dMedium ) for: 1.234f == Approx( 1.234 ) +ok {test-number} - 1.234f == Approx( dMedium ) for: 1.233999968f == Approx( 1.23399999999999999 ) # Approximate comparisons with mixed numeric types -ok {test-number} - dMedium == Approx( 1.234f ) for: 1.234 == Approx( 1.2339999676 ) +ok {test-number} - dMedium == Approx( 1.234f ) for: 1.23399999999999999 == Approx( 1.23399996757507324 ) # Arbitrary predicate matcher ok {test-number} - 1, Predicate( alwaysTrue, "always true" ) for: 1 matches predicate: "always true" # Arbitrary predicate matcher @@ -697,33 +705,37 @@ ok {test-number} - lt( "A", "b" ) for: true # CaseInsensitiveLess is case insensitive ok {test-number} - lt( "A", "B" ) for: true # Character pretty printing -ok {test-number} - tab == '\t' for: '\t' == '\t' -# Character pretty printing -ok {test-number} - newline == '\n' for: '\n' == '\n' -# Character pretty printing -ok {test-number} - carr_return == '\r' for: '\r' == '\r' -# Character pretty printing -ok {test-number} - form_feed == '\f' for: '\f' == '\f' +ok {test-number} - ::Catch::Detail::stringify('\t') == "'\\t'" for: "'\t'" == "'\t'" # Character pretty printing -ok {test-number} - space == ' ' for: ' ' == ' ' +ok {test-number} - ::Catch::Detail::stringify('\n') == "'\\n'" for: "'\n'" == "'\n'" # Character pretty printing -ok {test-number} - c == chars[i] for: 'a' == 'a' +ok {test-number} - ::Catch::Detail::stringify('\r') == "'\\r'" for: "'\r'" == "'\r'" # Character pretty printing -ok {test-number} - c == chars[i] for: 'z' == 'z' +ok {test-number} - ::Catch::Detail::stringify('\f') == "'\\f'" for: "'\f'" == "'\f'" # Character pretty printing -ok {test-number} - c == chars[i] for: 'A' == 'A' +ok {test-number} - ::Catch::Detail::stringify( ' ' ) == "' '" for: "' '" == "' '" # Character pretty printing -ok {test-number} - c == chars[i] for: 'Z' == 'Z' +ok {test-number} - ::Catch::Detail::stringify( 'A' ) == "'A'" for: "'A'" == "'A'" # Character pretty printing -ok {test-number} - null_terminator == '\0' for: 0 == 0 +ok {test-number} - ::Catch::Detail::stringify( 'z' ) == "'z'" for: "'z'" == "'z'" # Character pretty printing -ok {test-number} - c == i for: 2 == 2 +ok {test-number} - ::Catch::Detail::stringify( '\0' ) == "0" for: "0" == "0" # Character pretty printing -ok {test-number} - c == i for: 3 == 3 +ok {test-number} - ::Catch::Detail::stringify( static_cast(2) ) == "2" for: "2" == "2" # Character pretty printing -ok {test-number} - c == i for: 4 == 4 -# Character pretty printing -ok {test-number} - c == i for: 5 == 5 +ok {test-number} - ::Catch::Detail::stringify( static_cast(5) ) == "5" for: "5" == "5" +# Clara::Arg does not crash on incomplete input +ok {test-number} - name.empty() for: true +# Clara::Arg does not crash on incomplete input +ok {test-number} - result for: {?} +# Clara::Arg does not crash on incomplete input +ok {test-number} - result.type() == Catch::Clara::Detail::ResultType::Ok for: 0 == 0 +# Clara::Arg does not crash on incomplete input +ok {test-number} - parsed.type() == Catch::Clara::ParseResultType::NoMatch for: 1 == 1 +# Clara::Arg does not crash on incomplete input +ok {test-number} - parsed.remainingTokens().count() == 2 for: 2 == 2 +# Clara::Arg does not crash on incomplete input +ok {test-number} - name.empty() for: true # Clara::Arg supports single-arg parse the way Opt does ok {test-number} - name.empty() for: true # Clara::Arg supports single-arg parse the way Opt does @@ -975,7 +987,7 @@ not ok {test-number} - unexpected exception with message: 'custom exception - no # Custom std-exceptions can be custom translated not ok {test-number} - unexpected exception with message: 'custom std exception' # Default scale is invisible to comparison -ok {test-number} - 101.000001 != Approx(100).epsilon(0.01) for: 101.000001 != Approx( 100.0 ) +ok {test-number} - 101.000001 != Approx(100).epsilon(0.01) for: 101.00000099999999748 != Approx( 100.0 ) # Default scale is invisible to comparison ok {test-number} - std::pow(10, -5) != Approx(std::pow(10, -7)) for: 0.00001 != Approx( 0.0000001 ) # Directly creating an EnumInfo @@ -1007,7 +1019,7 @@ ok {test-number} - stringify( Bikeshed::Colours::Red ) == "Red" for: "Red" == "R # Enums in namespaces can quickly have stringification enabled using REGISTER_ENUM ok {test-number} - stringify( Bikeshed::Colours::Blue ) == "Blue" for: "Blue" == "Blue" # Epsilon only applies to Approx's value -ok {test-number} - 101.01 != Approx(100).epsilon(0.01) for: 101.01 != Approx( 100.0 ) +ok {test-number} - 101.01 != Approx(100).epsilon(0.01) for: 101.01000000000000512 != Approx( 100.0 ) # Equality checks that should fail not ok {test-number} - data.int_seven == 6 for: 7 == 6 # Equality checks that should fail @@ -1015,15 +1027,15 @@ not ok {test-number} - data.int_seven == 8 for: 7 == 8 # Equality checks that should fail not ok {test-number} - data.int_seven == 0 for: 7 == 0 # Equality checks that should fail -not ok {test-number} - data.float_nine_point_one == Approx( 9.11f ) for: 9.1f == Approx( 9.1099996567 ) +not ok {test-number} - data.float_nine_point_one == Approx( 9.11f ) for: 9.100000381f == Approx( 9.10999965667724609 ) # Equality checks that should fail -not ok {test-number} - data.float_nine_point_one == Approx( 9.0f ) for: 9.1f == Approx( 9.0 ) +not ok {test-number} - data.float_nine_point_one == Approx( 9.0f ) for: 9.100000381f == Approx( 9.0 ) # Equality checks that should fail -not ok {test-number} - data.float_nine_point_one == Approx( 1 ) for: 9.1f == Approx( 1.0 ) +not ok {test-number} - data.float_nine_point_one == Approx( 1 ) for: 9.100000381f == Approx( 1.0 ) # Equality checks that should fail -not ok {test-number} - data.float_nine_point_one == Approx( 0 ) for: 9.1f == Approx( 0.0 ) +not ok {test-number} - data.float_nine_point_one == Approx( 0 ) for: 9.100000381f == Approx( 0.0 ) # Equality checks that should fail -not ok {test-number} - data.double_pi == Approx( 3.1415 ) for: 3.1415926535 == Approx( 3.1415 ) +not ok {test-number} - data.double_pi == Approx( 3.1415 ) for: 3.14159265350000005 == Approx( 3.14150000000000018 ) # Equality checks that should fail not ok {test-number} - data.str_hello == "goodbye" for: "hello" == "goodbye" # Equality checks that should fail @@ -1033,13 +1045,13 @@ not ok {test-number} - data.str_hello == "hello1" for: "hello" == "hello1" # Equality checks that should fail not ok {test-number} - data.str_hello.size() == 6 for: 5 == 6 # Equality checks that should fail -not ok {test-number} - x == Approx( 1.301 ) for: 1.3 == Approx( 1.301 ) +not ok {test-number} - x == Approx( 1.301 ) for: 1.30000000000000027 == Approx( 1.30099999999999993 ) # Equality checks that should succeed ok {test-number} - data.int_seven == 7 for: 7 == 7 # Equality checks that should succeed -ok {test-number} - data.float_nine_point_one == Approx( 9.1f ) for: 9.1f == Approx( 9.1000003815 ) +ok {test-number} - data.float_nine_point_one == Approx( 9.1f ) for: 9.100000381f == Approx( 9.10000038146972656 ) # Equality checks that should succeed -ok {test-number} - data.double_pi == Approx( 3.1415926535 ) for: 3.1415926535 == Approx( 3.1415926535 ) +ok {test-number} - data.double_pi == Approx( 3.1415926535 ) for: 3.14159265350000005 == Approx( 3.14159265350000005 ) # Equality checks that should succeed ok {test-number} - data.str_hello == "hello" for: "hello" == "hello" # Equality checks that should succeed @@ -1047,7 +1059,7 @@ ok {test-number} - "hello" == data.str_hello for: "hello" == "hello" # Equality checks that should succeed ok {test-number} - data.str_hello.size() == 5 for: 5 == 5 # Equality checks that should succeed -ok {test-number} - x == Approx( 1.3 ) for: 1.3 == Approx( 1.3 ) +ok {test-number} - x == Approx( 1.3 ) for: 1.30000000000000027 == Approx( 1.30000000000000004 ) # Equals ok {test-number} - testStringForMatching(), Equals( "this string contains 'abc' as a substring" ) for: "this string contains 'abc' as a substring" equals: "this string contains 'abc' as a substring" # Equals @@ -1133,23 +1145,23 @@ ok {test-number} - Factorial(10) == 3628800 for: 3628800 (0x) == 362 # Filter generator throws exception for empty generator ok {test-number} - filter( []( int ) { return false; }, value( 3 ) ), Catch::GeneratorException # Floating point matchers: double -ok {test-number} - 10., WithinRel( 11.1, 0.1 ) for: 10.0 and 11.1 are within 10% of each other +ok {test-number} - 10., WithinRel( 11.1, 0.1 ) for: 10.0 and 11.09999999999999964 are within 10% of each other # Floating point matchers: double -ok {test-number} - 10., !WithinRel( 11.2, 0.1 ) for: 10.0 not and 11.2 are within 10% of each other +ok {test-number} - 10., !WithinRel( 11.2, 0.1 ) for: 10.0 not and 11.19999999999999929 are within 10% of each other # Floating point matchers: double -ok {test-number} - 1., !WithinRel( 0., 0.99 ) for: 1.0 not and 0 are within 99% of each other +ok {test-number} - 1., !WithinRel( 0., 0.99 ) for: 1.0 not and 0.0 are within 99% of each other # Floating point matchers: double -ok {test-number} - -0., WithinRel( 0. ) for: -0.0 and 0 are within 2.22045e-12% of each other +ok {test-number} - -0., WithinRel( 0. ) for: -0.0 and 0.0 are within 2.22045e-12% of each other # Floating point matchers: double -ok {test-number} - v1, WithinRel( v2 ) for: 0.0 and 2.22507e-308 are within 2.22045e-12% of each other +ok {test-number} - v1, WithinRel( v2 ) for: 0.0 and 0.0 are within 2.22045e-12% of each other # Floating point matchers: double ok {test-number} - 1., WithinAbs( 1., 0 ) for: 1.0 is within 0.0 of 1.0 # Floating point matchers: double ok {test-number} - 0., WithinAbs( 1., 1 ) for: 0.0 is within 1.0 of 1.0 # Floating point matchers: double -ok {test-number} - 0., !WithinAbs( 1., 0.99 ) for: 0.0 not is within 0.99 of 1.0 +ok {test-number} - 0., !WithinAbs( 1., 0.99 ) for: 0.0 not is within 0.98999999999999999 of 1.0 # Floating point matchers: double -ok {test-number} - 0., !WithinAbs( 1., 0.99 ) for: 0.0 not is within 0.99 of 1.0 +ok {test-number} - 0., !WithinAbs( 1., 0.99 ) for: 0.0 not is within 0.98999999999999999 of 1.0 # Floating point matchers: double ok {test-number} - 11., !WithinAbs( 10., 0.5 ) for: 11.0 not is within 0.5 of 10.0 # Floating point matchers: double @@ -1157,11 +1169,11 @@ ok {test-number} - 10., !WithinAbs( 11., 0.5 ) for: 10.0 not is within 0.5 of 11 # Floating point matchers: double ok {test-number} - -10., WithinAbs( -10., 0.5 ) for: -10.0 is within 0.5 of -10.0 # Floating point matchers: double -ok {test-number} - -10., WithinAbs( -9.6, 0.5 ) for: -10.0 is within 0.5 of -9.6 +ok {test-number} - -10., WithinAbs( -9.6, 0.5 ) for: -10.0 is within 0.5 of -9.59999999999999964 # Floating point matchers: double ok {test-number} - 1., WithinULP( 1., 0 ) for: 1.0 is within 0 ULPs of 1.0000000000000000e+00 ([1.0000000000000000e+00, 1.0000000000000000e+00]) # Floating point matchers: double -ok {test-number} - nextafter( 1., 2. ), WithinULP( 1., 1 ) for: 1.0 is within 1 ULPs of 1.0000000000000000e+00 ([9.9999999999999989e-01, 1.0000000000000002e+00]) +ok {test-number} - nextafter( 1., 2. ), WithinULP( 1., 1 ) for: 1.00000000000000022 is within 1 ULPs of 1.0000000000000000e+00 ([9.9999999999999989e-01, 1.0000000000000002e+00]) # Floating point matchers: double ok {test-number} - 0., WithinULP( nextafter( 0., 1. ), 1 ) for: 0.0 is within 1 ULPs of 4.9406564584124654e-324 ([0.0000000000000000e+00, 9.8813129168249309e-324]) # Floating point matchers: double @@ -1177,7 +1189,7 @@ ok {test-number} - 1., WithinAbs( 1., 0.5 ) || WithinULP( 2., 1 ) for: 1.0 ( is # Floating point matchers: double ok {test-number} - 1., WithinAbs( 2., 0.5 ) || WithinULP( 1., 0 ) for: 1.0 ( is within 0.5 of 2.0 or is within 0 ULPs of 1.0000000000000000e+00 ([1.0000000000000000e+00, 1.0000000000000000e+00]) ) # Floating point matchers: double -ok {test-number} - 0.0001, WithinAbs( 0., 0.001 ) || WithinRel( 0., 0.1 ) for: 0.0001 ( is within 0.001 of 0.0 or and 0 are within 10% of each other ) +ok {test-number} - 0.0001, WithinAbs( 0., 0.001 ) || WithinRel( 0., 0.1 ) for: 0.0001 ( is within 0.001 of 0.0 or and 0.0 are within 10% of each other ) # Floating point matchers: double ok {test-number} - WithinAbs( 1., 0. ) # Floating point matchers: double @@ -1193,23 +1205,23 @@ ok {test-number} - WithinRel( 1., 1. ), std::domain_error # Floating point matchers: double ok {test-number} - 1., !IsNaN() for: 1.0 not is NaN # Floating point matchers: float -ok {test-number} - 10.f, WithinRel( 11.1f, 0.1f ) for: 10.0f and 11.1 are within 10% of each other +ok {test-number} - 10.f, WithinRel( 11.1f, 0.1f ) for: 10.0f and 11.10000038146972656 are within 10% of each other # Floating point matchers: float -ok {test-number} - 10.f, !WithinRel( 11.2f, 0.1f ) for: 10.0f not and 11.2 are within 10% of each other +ok {test-number} - 10.f, !WithinRel( 11.2f, 0.1f ) for: 10.0f not and 11.19999980926513672 are within 10% of each other # Floating point matchers: float -ok {test-number} - 1.f, !WithinRel( 0.f, 0.99f ) for: 1.0f not and 0 are within 99% of each other +ok {test-number} - 1.f, !WithinRel( 0.f, 0.99f ) for: 1.0f not and 0.0 are within 99% of each other # Floating point matchers: float -ok {test-number} - -0.f, WithinRel( 0.f ) for: -0.0f and 0 are within 0.00119209% of each other +ok {test-number} - -0.f, WithinRel( 0.f ) for: -0.0f and 0.0 are within 0.00119209% of each other # Floating point matchers: float -ok {test-number} - v1, WithinRel( v2 ) for: 0.0f and 1.17549e-38 are within 0.00119209% of each other +ok {test-number} - v1, WithinRel( v2 ) for: 0.0f and 0.0 are within 0.00119209% of each other # Floating point matchers: float ok {test-number} - 1.f, WithinAbs( 1.f, 0 ) for: 1.0f is within 0.0 of 1.0 # Floating point matchers: float ok {test-number} - 0.f, WithinAbs( 1.f, 1 ) for: 0.0f is within 1.0 of 1.0 # Floating point matchers: float -ok {test-number} - 0.f, !WithinAbs( 1.f, 0.99f ) for: 0.0f not is within 0.9900000095 of 1.0 +ok {test-number} - 0.f, !WithinAbs( 1.f, 0.99f ) for: 0.0f not is within 0.99000000953674316 of 1.0 # Floating point matchers: float -ok {test-number} - 0.f, !WithinAbs( 1.f, 0.99f ) for: 0.0f not is within 0.9900000095 of 1.0 +ok {test-number} - 0.f, !WithinAbs( 1.f, 0.99f ) for: 0.0f not is within 0.99000000953674316 of 1.0 # Floating point matchers: float ok {test-number} - 0.f, WithinAbs( -0.f, 0 ) for: 0.0f is within 0.0 of -0.0 # Floating point matchers: float @@ -1219,13 +1231,13 @@ ok {test-number} - 10.f, !WithinAbs( 11.f, 0.5f ) for: 10.0f not is within 0.5 o # Floating point matchers: float ok {test-number} - -10.f, WithinAbs( -10.f, 0.5f ) for: -10.0f is within 0.5 of -10.0 # Floating point matchers: float -ok {test-number} - -10.f, WithinAbs( -9.6f, 0.5f ) for: -10.0f is within 0.5 of -9.6000003815 +ok {test-number} - -10.f, WithinAbs( -9.6f, 0.5f ) for: -10.0f is within 0.5 of -9.60000038146972656 # Floating point matchers: float ok {test-number} - 1.f, WithinULP( 1.f, 0 ) for: 1.0f is within 0 ULPs of 1.00000000e+00f ([1.00000000e+00, 1.00000000e+00]) # Floating point matchers: float ok {test-number} - -1.f, WithinULP( -1.f, 0 ) for: -1.0f is within 0 ULPs of -1.00000000e+00f ([-1.00000000e+00, -1.00000000e+00]) # Floating point matchers: float -ok {test-number} - nextafter( 1.f, 2.f ), WithinULP( 1.f, 1 ) for: 1.0f is within 1 ULPs of 1.00000000e+00f ([9.99999940e-01, 1.00000012e+00]) +ok {test-number} - nextafter( 1.f, 2.f ), WithinULP( 1.f, 1 ) for: 1.000000119f is within 1 ULPs of 1.00000000e+00f ([9.99999940e-01, 1.00000012e+00]) # Floating point matchers: float ok {test-number} - 0.f, WithinULP( nextafter( 0.f, 1.f ), 1 ) for: 0.0f is within 1 ULPs of 1.40129846e-45f ([0.00000000e+00, 2.80259693e-45]) # Floating point matchers: float @@ -1241,7 +1253,7 @@ ok {test-number} - 1.f, WithinAbs( 1.f, 0.5 ) || WithinULP( 1.f, 1 ) for: 1.0f ( # Floating point matchers: float ok {test-number} - 1.f, WithinAbs( 2.f, 0.5 ) || WithinULP( 1.f, 0 ) for: 1.0f ( is within 0.5 of 2.0 or is within 0 ULPs of 1.00000000e+00f ([1.00000000e+00, 1.00000000e+00]) ) # Floating point matchers: float -ok {test-number} - 0.0001f, WithinAbs( 0.f, 0.001f ) || WithinRel( 0.f, 0.1f ) for: 0.0001f ( is within 0.001 of 0.0 or and 0 are within 10% of each other ) +ok {test-number} - 0.0001f, WithinAbs( 0.f, 0.001f ) || WithinRel( 0.f, 0.1f ) for: 0.0001f ( is within 0.00100000004749745 of 0.0 or and 0.0 are within 10% of each other ) # Floating point matchers: float ok {test-number} - WithinAbs( 1.f, 0.f ) # Floating point matchers: float @@ -1601,83 +1613,83 @@ ok {test-number} - gen.get() == Approx(expected) for: -1.0 == Approx( -1.0 ) wit # Generators internals ok {test-number} - gen.next() for: true with 1 message: 'Current expected value is -1' # Generators internals -ok {test-number} - gen.get() == Approx(expected) for: -0.9 == Approx( -0.9 ) with 1 message: 'Current expected value is -0.9' +ok {test-number} - gen.get() == Approx(expected) for: -0.90000000000000002 == Approx( -0.90000000000000002 ) with 1 message: 'Current expected value is -0.9' # Generators internals ok {test-number} - gen.next() for: true with 1 message: 'Current expected value is -0.9' # Generators internals -ok {test-number} - gen.get() == Approx(expected) for: -0.8 == Approx( -0.8 ) with 1 message: 'Current expected value is -0.8' +ok {test-number} - gen.get() == Approx(expected) for: -0.80000000000000004 == Approx( -0.80000000000000004 ) with 1 message: 'Current expected value is -0.8' # Generators internals ok {test-number} - gen.next() for: true with 1 message: 'Current expected value is -0.8' # Generators internals -ok {test-number} - gen.get() == Approx(expected) for: -0.7 == Approx( -0.7 ) with 1 message: 'Current expected value is -0.7' +ok {test-number} - gen.get() == Approx(expected) for: -0.70000000000000007 == Approx( -0.70000000000000007 ) with 1 message: 'Current expected value is -0.7' # Generators internals ok {test-number} - gen.next() for: true with 1 message: 'Current expected value is -0.7' # Generators internals -ok {test-number} - gen.get() == Approx(expected) for: -0.6 == Approx( -0.6 ) with 1 message: 'Current expected value is -0.6' +ok {test-number} - gen.get() == Approx(expected) for: -0.60000000000000009 == Approx( -0.60000000000000009 ) with 1 message: 'Current expected value is -0.6' # Generators internals ok {test-number} - gen.next() for: true with 1 message: 'Current expected value is -0.6' # Generators internals -ok {test-number} - gen.get() == Approx(expected) for: -0.5 == Approx( -0.5 ) with 1 message: 'Current expected value is -0.5' +ok {test-number} - gen.get() == Approx(expected) for: -0.50000000000000011 == Approx( -0.50000000000000011 ) with 1 message: 'Current expected value is -0.5' # Generators internals ok {test-number} - gen.next() for: true with 1 message: 'Current expected value is -0.5' # Generators internals -ok {test-number} - gen.get() == Approx(expected) for: -0.4 == Approx( -0.4 ) with 1 message: 'Current expected value is -0.4' +ok {test-number} - gen.get() == Approx(expected) for: -0.40000000000000013 == Approx( -0.40000000000000013 ) with 1 message: 'Current expected value is -0.4' # Generators internals ok {test-number} - gen.next() for: true with 1 message: 'Current expected value is -0.4' # Generators internals -ok {test-number} - gen.get() == Approx(expected) for: -0.3 == Approx( -0.3 ) with 1 message: 'Current expected value is -0.3' +ok {test-number} - gen.get() == Approx(expected) for: -0.30000000000000016 == Approx( -0.30000000000000016 ) with 1 message: 'Current expected value is -0.3' # Generators internals ok {test-number} - gen.next() for: true with 1 message: 'Current expected value is -0.3' # Generators internals -ok {test-number} - gen.get() == Approx(expected) for: -0.2 == Approx( -0.2 ) with 1 message: 'Current expected value is -0.2' +ok {test-number} - gen.get() == Approx(expected) for: -0.20000000000000015 == Approx( -0.20000000000000015 ) with 1 message: 'Current expected value is -0.2' # Generators internals ok {test-number} - gen.next() for: true with 1 message: 'Current expected value is -0.2' # Generators internals -ok {test-number} - gen.get() == Approx(expected) for: -0.1 == Approx( -0.1 ) with 1 message: 'Current expected value is -0.1' +ok {test-number} - gen.get() == Approx(expected) for: -0.10000000000000014 == Approx( -0.10000000000000014 ) with 1 message: 'Current expected value is -0.1' # Generators internals ok {test-number} - gen.next() for: true with 1 message: 'Current expected value is -0.1' # Generators internals -ok {test-number} - gen.get() == Approx(expected) for: -0.0 == Approx( -0.0 ) with 1 message: 'Current expected value is -1.38778e-16' +ok {test-number} - gen.get() == Approx(expected) for: -0.00000000000000014 == Approx( -0.00000000000000014 ) with 1 message: 'Current expected value is -1.38778e-16' # Generators internals ok {test-number} - gen.next() for: true with 1 message: 'Current expected value is -1.38778e-16' # Generators internals -ok {test-number} - gen.get() == Approx(expected) for: 0.1 == Approx( 0.1 ) with 1 message: 'Current expected value is 0.1' +ok {test-number} - gen.get() == Approx(expected) for: 0.09999999999999987 == Approx( 0.09999999999999987 ) with 1 message: 'Current expected value is 0.1' # Generators internals ok {test-number} - gen.next() for: true with 1 message: 'Current expected value is 0.1' # Generators internals -ok {test-number} - gen.get() == Approx(expected) for: 0.2 == Approx( 0.2 ) with 1 message: 'Current expected value is 0.2' +ok {test-number} - gen.get() == Approx(expected) for: 0.19999999999999987 == Approx( 0.19999999999999987 ) with 1 message: 'Current expected value is 0.2' # Generators internals ok {test-number} - gen.next() for: true with 1 message: 'Current expected value is 0.2' # Generators internals -ok {test-number} - gen.get() == Approx(expected) for: 0.3 == Approx( 0.3 ) with 1 message: 'Current expected value is 0.3' +ok {test-number} - gen.get() == Approx(expected) for: 0.29999999999999988 == Approx( 0.29999999999999988 ) with 1 message: 'Current expected value is 0.3' # Generators internals ok {test-number} - gen.next() for: true with 1 message: 'Current expected value is 0.3' # Generators internals -ok {test-number} - gen.get() == Approx(expected) for: 0.4 == Approx( 0.4 ) with 1 message: 'Current expected value is 0.4' +ok {test-number} - gen.get() == Approx(expected) for: 0.39999999999999991 == Approx( 0.39999999999999991 ) with 1 message: 'Current expected value is 0.4' # Generators internals ok {test-number} - gen.next() for: true with 1 message: 'Current expected value is 0.4' # Generators internals -ok {test-number} - gen.get() == Approx(expected) for: 0.5 == Approx( 0.5 ) with 1 message: 'Current expected value is 0.5' +ok {test-number} - gen.get() == Approx(expected) for: 0.49999999999999989 == Approx( 0.49999999999999989 ) with 1 message: 'Current expected value is 0.5' # Generators internals ok {test-number} - gen.next() for: true with 1 message: 'Current expected value is 0.5' # Generators internals -ok {test-number} - gen.get() == Approx(expected) for: 0.6 == Approx( 0.6 ) with 1 message: 'Current expected value is 0.6' +ok {test-number} - gen.get() == Approx(expected) for: 0.59999999999999987 == Approx( 0.59999999999999987 ) with 1 message: 'Current expected value is 0.6' # Generators internals ok {test-number} - gen.next() for: true with 1 message: 'Current expected value is 0.6' # Generators internals -ok {test-number} - gen.get() == Approx(expected) for: 0.7 == Approx( 0.7 ) with 1 message: 'Current expected value is 0.7' +ok {test-number} - gen.get() == Approx(expected) for: 0.69999999999999984 == Approx( 0.69999999999999984 ) with 1 message: 'Current expected value is 0.7' # Generators internals ok {test-number} - gen.next() for: true with 1 message: 'Current expected value is 0.7' # Generators internals -ok {test-number} - gen.get() == Approx(expected) for: 0.8 == Approx( 0.8 ) with 1 message: 'Current expected value is 0.8' +ok {test-number} - gen.get() == Approx(expected) for: 0.79999999999999982 == Approx( 0.79999999999999982 ) with 1 message: 'Current expected value is 0.8' # Generators internals ok {test-number} - gen.next() for: true with 1 message: 'Current expected value is 0.8' # Generators internals -ok {test-number} - gen.get() == Approx(expected) for: 0.9 == Approx( 0.9 ) with 1 message: 'Current expected value is 0.9' +ok {test-number} - gen.get() == Approx(expected) for: 0.8999999999999998 == Approx( 0.8999999999999998 ) with 1 message: 'Current expected value is 0.9' # Generators internals ok {test-number} - gen.next() for: true with 1 message: 'Current expected value is 0.9' # Generators internals -ok {test-number} - gen.get() == Approx( rangeEnd ) for: 1.0 == Approx( 1.0 ) +ok {test-number} - gen.get() == Approx( rangeEnd ) for: 0.99999999999999978 == Approx( 1.0 ) # Generators internals ok {test-number} - !(gen.next()) for: !false # Generators internals @@ -1685,19 +1697,19 @@ ok {test-number} - gen.get() == Approx(expected) for: -1.0 == Approx( -1.0 ) wit # Generators internals ok {test-number} - gen.next() for: true with 1 message: 'Current expected value is -1' # Generators internals -ok {test-number} - gen.get() == Approx(expected) for: -0.7 == Approx( -0.7 ) with 1 message: 'Current expected value is -0.7' +ok {test-number} - gen.get() == Approx(expected) for: -0.69999999999999996 == Approx( -0.69999999999999996 ) with 1 message: 'Current expected value is -0.7' # Generators internals ok {test-number} - gen.next() for: true with 1 message: 'Current expected value is -0.7' # Generators internals -ok {test-number} - gen.get() == Approx(expected) for: -0.4 == Approx( -0.4 ) with 1 message: 'Current expected value is -0.4' +ok {test-number} - gen.get() == Approx(expected) for: -0.39999999999999997 == Approx( -0.39999999999999997 ) with 1 message: 'Current expected value is -0.4' # Generators internals ok {test-number} - gen.next() for: true with 1 message: 'Current expected value is -0.4' # Generators internals -ok {test-number} - gen.get() == Approx(expected) for: -0.1 == Approx( -0.1 ) with 1 message: 'Current expected value is -0.1' +ok {test-number} - gen.get() == Approx(expected) for: -0.09999999999999998 == Approx( -0.09999999999999998 ) with 1 message: 'Current expected value is -0.1' # Generators internals ok {test-number} - gen.next() for: true with 1 message: 'Current expected value is -0.1' # Generators internals -ok {test-number} - gen.get() == Approx(expected) for: 0.2 == Approx( 0.2 ) with 1 message: 'Current expected value is 0.2' +ok {test-number} - gen.get() == Approx(expected) for: 0.20000000000000001 == Approx( 0.20000000000000001 ) with 1 message: 'Current expected value is 0.2' # Generators internals ok {test-number} - gen.next() for: true with 1 message: 'Current expected value is 0.2' # Generators internals @@ -1711,19 +1723,19 @@ ok {test-number} - gen.get() == Approx(expected) for: -1.0 == Approx( -1.0 ) wit # Generators internals ok {test-number} - gen.next() for: true with 1 message: 'Current expected value is -1' # Generators internals -ok {test-number} - gen.get() == Approx(expected) for: -0.7 == Approx( -0.7 ) with 1 message: 'Current expected value is -0.7' +ok {test-number} - gen.get() == Approx(expected) for: -0.69999999999999996 == Approx( -0.69999999999999996 ) with 1 message: 'Current expected value is -0.7' # Generators internals ok {test-number} - gen.next() for: true with 1 message: 'Current expected value is -0.7' # Generators internals -ok {test-number} - gen.get() == Approx(expected) for: -0.4 == Approx( -0.4 ) with 1 message: 'Current expected value is -0.4' +ok {test-number} - gen.get() == Approx(expected) for: -0.39999999999999997 == Approx( -0.39999999999999997 ) with 1 message: 'Current expected value is -0.4' # Generators internals ok {test-number} - gen.next() for: true with 1 message: 'Current expected value is -0.4' # Generators internals -ok {test-number} - gen.get() == Approx(expected) for: -0.1 == Approx( -0.1 ) with 1 message: 'Current expected value is -0.1' +ok {test-number} - gen.get() == Approx(expected) for: -0.09999999999999998 == Approx( -0.09999999999999998 ) with 1 message: 'Current expected value is -0.1' # Generators internals ok {test-number} - gen.next() for: true with 1 message: 'Current expected value is -0.1' # Generators internals -ok {test-number} - gen.get() == Approx(expected) for: 0.2 == Approx( 0.2 ) with 1 message: 'Current expected value is 0.2' +ok {test-number} - gen.get() == Approx(expected) for: 0.20000000000000001 == Approx( 0.20000000000000001 ) with 1 message: 'Current expected value is 0.2' # Generators internals ok {test-number} - gen.next() for: true with 1 message: 'Current expected value is 0.2' # Generators internals @@ -1785,13 +1797,13 @@ ok {test-number} - gen.get() == -7 for: -7 == -7 # Generators internals ok {test-number} - !(gen.next()) for: !false # Greater-than inequalities with different epsilons -ok {test-number} - d >= Approx( 1.22 ) for: 1.23 >= Approx( 1.22 ) +ok {test-number} - d >= Approx( 1.22 ) for: 1.22999999999999998 >= Approx( 1.21999999999999997 ) # Greater-than inequalities with different epsilons -ok {test-number} - d >= Approx( 1.23 ) for: 1.23 >= Approx( 1.23 ) +ok {test-number} - d >= Approx( 1.23 ) for: 1.22999999999999998 >= Approx( 1.22999999999999998 ) # Greater-than inequalities with different epsilons -ok {test-number} - !(d >= Approx( 1.24 )) for: !(1.23 >= Approx( 1.24 )) +ok {test-number} - !(d >= Approx( 1.24 )) for: !(1.22999999999999998 >= Approx( 1.23999999999999999 )) # Greater-than inequalities with different epsilons -ok {test-number} - d >= Approx( 1.24 ).epsilon(0.1) for: 1.23 >= Approx( 1.24 ) +ok {test-number} - d >= Approx( 1.24 ).epsilon(0.1) for: 1.22999999999999998 >= Approx( 1.23999999999999999 ) # Hashers with different seed produce different hash with same test case ok {test-number} - h1( dummy ) != h2( dummy ) for: 3422778688 (0x) != 130711275 (0x) # Hashers with same seed produce same hash @@ -1845,9 +1857,9 @@ not ok {test-number} - unexpected exception with message: 'Exception translation # Inequality checks that should fail not ok {test-number} - data.int_seven != 7 for: 7 != 7 # Inequality checks that should fail -not ok {test-number} - data.float_nine_point_one != Approx( 9.1f ) for: 9.1f != Approx( 9.1000003815 ) +not ok {test-number} - data.float_nine_point_one != Approx( 9.1f ) for: 9.100000381f != Approx( 9.10000038146972656 ) # Inequality checks that should fail -not ok {test-number} - data.double_pi != Approx( 3.1415926535 ) for: 3.1415926535 != Approx( 3.1415926535 ) +not ok {test-number} - data.double_pi != Approx( 3.1415926535 ) for: 3.14159265350000005 != Approx( 3.14159265350000005 ) # Inequality checks that should fail not ok {test-number} - data.str_hello != "hello" for: "hello" != "hello" # Inequality checks that should fail @@ -1857,15 +1869,15 @@ ok {test-number} - data.int_seven != 6 for: 7 != 6 # Inequality checks that should succeed ok {test-number} - data.int_seven != 8 for: 7 != 8 # Inequality checks that should succeed -ok {test-number} - data.float_nine_point_one != Approx( 9.11f ) for: 9.1f != Approx( 9.1099996567 ) +ok {test-number} - data.float_nine_point_one != Approx( 9.11f ) for: 9.100000381f != Approx( 9.10999965667724609 ) # Inequality checks that should succeed -ok {test-number} - data.float_nine_point_one != Approx( 9.0f ) for: 9.1f != Approx( 9.0 ) +ok {test-number} - data.float_nine_point_one != Approx( 9.0f ) for: 9.100000381f != Approx( 9.0 ) # Inequality checks that should succeed -ok {test-number} - data.float_nine_point_one != Approx( 1 ) for: 9.1f != Approx( 1.0 ) +ok {test-number} - data.float_nine_point_one != Approx( 1 ) for: 9.100000381f != Approx( 1.0 ) # Inequality checks that should succeed -ok {test-number} - data.float_nine_point_one != Approx( 0 ) for: 9.1f != Approx( 0.0 ) +ok {test-number} - data.float_nine_point_one != Approx( 0 ) for: 9.100000381f != Approx( 0.0 ) # Inequality checks that should succeed -ok {test-number} - data.double_pi != Approx( 3.1415 ) for: 3.1415926535 != Approx( 3.1415 ) +ok {test-number} - data.double_pi != Approx( 3.1415 ) for: 3.14159265350000005 != Approx( 3.14150000000000018 ) # Inequality checks that should succeed ok {test-number} - data.str_hello != "goodbye" for: "hello" != "goodbye" # Inequality checks that should succeed @@ -1913,13 +1925,13 @@ ok {test-number} - sstream.str() == "\"\\\\/\\t\\r\\n\"" for: ""\\/\t\r\n"" == " # Lambdas in assertions ok {test-number} - []() { return true; }() for: true # Less-than inequalities with different epsilons -ok {test-number} - d <= Approx( 1.24 ) for: 1.23 <= Approx( 1.24 ) +ok {test-number} - d <= Approx( 1.24 ) for: 1.22999999999999998 <= Approx( 1.23999999999999999 ) # Less-than inequalities with different epsilons -ok {test-number} - d <= Approx( 1.23 ) for: 1.23 <= Approx( 1.23 ) +ok {test-number} - d <= Approx( 1.23 ) for: 1.22999999999999998 <= Approx( 1.22999999999999998 ) # Less-than inequalities with different epsilons -ok {test-number} - !(d <= Approx( 1.22 )) for: !(1.23 <= Approx( 1.22 )) +ok {test-number} - !(d <= Approx( 1.22 )) for: !(1.22999999999999998 <= Approx( 1.21999999999999997 )) # Less-than inequalities with different epsilons -ok {test-number} - d <= Approx( 1.22 ).epsilon(0.1) for: 1.23 <= Approx( 1.22 ) +ok {test-number} - d <= Approx( 1.22 ).epsilon(0.1) for: 1.22999999999999998 <= Approx( 1.21999999999999997 ) # ManuallyRegistered ok {test-number} - with 1 message: 'was called' # Matchers can be (AllOf) composed with the && operator @@ -2049,11 +2061,11 @@ not ok {test-number} - data.int_seven >= 8 for: 7 >= 8 # Ordering comparison checks that should fail not ok {test-number} - data.int_seven <= 6 for: 7 <= 6 # Ordering comparison checks that should fail -not ok {test-number} - data.float_nine_point_one < 9 for: 9.1f < 9 +not ok {test-number} - data.float_nine_point_one < 9 for: 9.100000381f < 9 # Ordering comparison checks that should fail -not ok {test-number} - data.float_nine_point_one > 10 for: 9.1f > 10 +not ok {test-number} - data.float_nine_point_one > 10 for: 9.100000381f > 10 # Ordering comparison checks that should fail -not ok {test-number} - data.float_nine_point_one > 9.2 for: 9.1f > 9.2 +not ok {test-number} - data.float_nine_point_one > 9.2 for: 9.100000381f > 9.19999999999999929 # Ordering comparison checks that should fail not ok {test-number} - data.str_hello > "hello" for: "hello" > "hello" # Ordering comparison checks that should fail @@ -2087,11 +2099,11 @@ ok {test-number} - data.int_seven <= 7 for: 7 <= 7 # Ordering comparison checks that should succeed ok {test-number} - data.int_seven <= 8 for: 7 <= 8 # Ordering comparison checks that should succeed -ok {test-number} - data.float_nine_point_one > 9 for: 9.1f > 9 +ok {test-number} - data.float_nine_point_one > 9 for: 9.100000381f > 9 # Ordering comparison checks that should succeed -ok {test-number} - data.float_nine_point_one < 10 for: 9.1f < 10 +ok {test-number} - data.float_nine_point_one < 10 for: 9.100000381f < 10 # Ordering comparison checks that should succeed -ok {test-number} - data.float_nine_point_one < 9.2 for: 9.1f < 9.2 +ok {test-number} - data.float_nine_point_one < 9.2 for: 9.100000381f < 9.19999999999999929 # Ordering comparison checks that should succeed ok {test-number} - data.str_hello <= "hello" for: "hello" <= "hello" # Ordering comparison checks that should succeed @@ -2427,7 +2439,7 @@ ok {test-number} - config.benchmarkResamples == 20000 for: 20000 (0x # Process can be configured on command line ok {test-number} - cli.parse({ "test", "--benchmark-confidence-interval=0.99" }) for: {?} # Process can be configured on command line -ok {test-number} - config.benchmarkConfidenceInterval == Catch::Approx(0.99) for: 0.99 == Approx( 0.99 ) +ok {test-number} - config.benchmarkConfidenceInterval == Catch::Approx(0.99) for: 0.98999999999999999 == Approx( 0.98999999999999999 ) # Process can be configured on command line ok {test-number} - cli.parse({ "test", "--benchmark-no-analysis" }) for: {?} # Process can be configured on command line @@ -2608,21 +2620,21 @@ A string sent directly to stdout A string sent directly to stderr A string sent to stderr via clog # Some simple comparisons between doubles -ok {test-number} - d == Approx( 1.23 ) for: 1.23 == Approx( 1.23 ) +ok {test-number} - d == Approx( 1.23 ) for: 1.22999999999999998 == Approx( 1.22999999999999998 ) # Some simple comparisons between doubles -ok {test-number} - d != Approx( 1.22 ) for: 1.23 != Approx( 1.22 ) +ok {test-number} - d != Approx( 1.22 ) for: 1.22999999999999998 != Approx( 1.21999999999999997 ) # Some simple comparisons between doubles -ok {test-number} - d != Approx( 1.24 ) for: 1.23 != Approx( 1.24 ) +ok {test-number} - d != Approx( 1.24 ) for: 1.22999999999999998 != Approx( 1.23999999999999999 ) # Some simple comparisons between doubles -ok {test-number} - d == 1.23_a for: 1.23 == Approx( 1.23 ) +ok {test-number} - d == 1.23_a for: 1.22999999999999998 == Approx( 1.22999999999999998 ) # Some simple comparisons between doubles -ok {test-number} - d != 1.22_a for: 1.23 != Approx( 1.22 ) +ok {test-number} - d != 1.22_a for: 1.22999999999999998 != Approx( 1.21999999999999997 ) # Some simple comparisons between doubles -ok {test-number} - Approx( d ) == 1.23 for: Approx( 1.23 ) == 1.23 +ok {test-number} - Approx( d ) == 1.23 for: Approx( 1.22999999999999998 ) == 1.22999999999999998 # Some simple comparisons between doubles -ok {test-number} - Approx( d ) != 1.22 for: Approx( 1.23 ) != 1.22 +ok {test-number} - Approx( d ) != 1.22 for: Approx( 1.22999999999999998 ) != 1.21999999999999997 # Some simple comparisons between doubles -ok {test-number} - Approx( d ) != 1.24 for: Approx( 1.23 ) != 1.24 +ok {test-number} - Approx( d ) != 1.24 for: Approx( 1.22999999999999998 ) != 1.23999999999999999 Message from section one Message from section two # StartsWith string matcher @@ -2812,19 +2824,19 @@ ok {test-number} - Template_Fixture::m_a == 1 for: 1 == 1 # Template test case method with test types specified inside std::tuple - MyTypes - 2 ok {test-number} - Template_Fixture::m_a == 1 for: 1.0 == 1 # Template test case with test types specified inside non-copyable and non-movable std::tuple - NonCopyableAndNonMovableTypes - 0 -ok {test-number} - sizeof(TestType) > 0 for: 1 > 0 +ok {test-number} - std::is_default_constructible::value for: true # Template test case with test types specified inside non-copyable and non-movable std::tuple - NonCopyableAndNonMovableTypes - 1 -ok {test-number} - sizeof(TestType) > 0 for: 4 > 0 +ok {test-number} - std::is_default_constructible::value for: true # Template test case with test types specified inside non-default-constructible std::tuple - MyNonDefaultConstructibleTypes - 0 -ok {test-number} - sizeof(TestType) > 0 for: 1 > 0 +ok {test-number} - std::is_trivially_copyable::value for: true # Template test case with test types specified inside non-default-constructible std::tuple - MyNonDefaultConstructibleTypes - 1 -ok {test-number} - sizeof(TestType) > 0 for: 4 > 0 +ok {test-number} - std::is_trivially_copyable::value for: true # Template test case with test types specified inside std::tuple - MyTypes - 0 -ok {test-number} - sizeof(TestType) > 0 for: 4 > 0 +ok {test-number} - std::is_arithmetic::value for: true # Template test case with test types specified inside std::tuple - MyTypes - 1 -ok {test-number} - sizeof(TestType) > 0 for: 1 > 0 +ok {test-number} - std::is_arithmetic::value for: true # Template test case with test types specified inside std::tuple - MyTypes - 2 -ok {test-number} - sizeof(TestType) > 0 for: 4 > 0 +ok {test-number} - std::is_arithmetic::value for: true # TemplateTest: vectors can be sized and resized - float ok {test-number} - v.size() == 5 for: 5 == 5 # TemplateTest: vectors can be sized and resized - float @@ -3334,7 +3346,7 @@ ok {test-number} - vector_a, RangeEquals( array_a_plus_1, close_enough ) for: { # Type conversions of RangeEquals and similar ok {test-number} - vector_a, UnorderedRangeEquals( array_a_plus_1, close_enough ) for: { 1, 2, 3 } unordered elements are { 2, 3, 4 } # Unexpected exceptions can be translated -not ok {test-number} - unexpected exception with message: '3.14' +not ok {test-number} - unexpected exception with message: '3.14000000000000012' # Upcasting special member functions ok {test-number} - bptr->i == 3 for: 3 == 3 # Upcasting special member functions @@ -3626,21 +3638,21 @@ ok {test-number} - unrelated::ADL_size{}, SizeIs(12) for: {?} has size == 12 # Usage of the SizeIs range matcher ok {test-number} - has_size{}, SizeIs(13) for: {?} has size == 13 # Use a custom approx -ok {test-number} - d == approx( 1.23 ) for: 1.23 == Approx( 1.23 ) +ok {test-number} - d == approx( 1.23 ) for: 1.22999999999999998 == Approx( 1.22999999999999998 ) # Use a custom approx -ok {test-number} - d == approx( 1.22 ) for: 1.23 == Approx( 1.22 ) +ok {test-number} - d == approx( 1.22 ) for: 1.22999999999999998 == Approx( 1.21999999999999997 ) # Use a custom approx -ok {test-number} - d == approx( 1.24 ) for: 1.23 == Approx( 1.24 ) +ok {test-number} - d == approx( 1.24 ) for: 1.22999999999999998 == Approx( 1.23999999999999999 ) # Use a custom approx -ok {test-number} - d != approx( 1.25 ) for: 1.23 != Approx( 1.25 ) +ok {test-number} - d != approx( 1.25 ) for: 1.22999999999999998 != Approx( 1.25 ) # Use a custom approx -ok {test-number} - approx( d ) == 1.23 for: Approx( 1.23 ) == 1.23 +ok {test-number} - approx( d ) == 1.23 for: Approx( 1.22999999999999998 ) == 1.22999999999999998 # Use a custom approx -ok {test-number} - approx( d ) == 1.22 for: Approx( 1.23 ) == 1.22 +ok {test-number} - approx( d ) == 1.22 for: Approx( 1.22999999999999998 ) == 1.21999999999999997 # Use a custom approx -ok {test-number} - approx( d ) == 1.24 for: Approx( 1.23 ) == 1.24 +ok {test-number} - approx( d ) == 1.24 for: Approx( 1.22999999999999998 ) == 1.23999999999999999 # Use a custom approx -ok {test-number} - approx( d ) != 1.25 for: Approx( 1.23 ) != 1.25 +ok {test-number} - approx( d ) != 1.25 for: Approx( 1.22999999999999998 ) != 1.25 # Variadic macros ok {test-number} - with 1 message: 'no assertions' # Vector Approx matcher @@ -3966,11 +3978,11 @@ ok {test-number} - # SKIP 'skipping because answer = 43' # empty tags are not allowed ok {test-number} - Catch::TestCaseInfo("", { "test with an empty tag", "[]" }, dummySourceLineInfo) # erfc_inv -ok {test-number} - erfc_inv(1.103560) == Approx(-0.09203687623843015) for: -0.0920368762 == Approx( -0.0920368762 ) +ok {test-number} - erfc_inv(1.103560) == Approx(-0.09203687623843015) for: -0.09203687623843014 == Approx( -0.09203687623843015 ) # erfc_inv -ok {test-number} - erfc_inv(1.067400) == Approx(-0.05980291115763361) for: -0.0598029112 == Approx( -0.0598029112 ) +ok {test-number} - erfc_inv(1.067400) == Approx(-0.05980291115763361) for: -0.05980291115763361 == Approx( -0.05980291115763361 ) # erfc_inv -ok {test-number} - erfc_inv(0.050000) == Approx(1.38590382434967796) for: 1.3859038243 == Approx( 1.3859038243 ) +ok {test-number} - erfc_inv(0.050000) == Approx(1.38590382434967796) for: 1.38590382434967774 == Approx( 1.38590382434967796 ) # estimate_clock_resolution ok {test-number} - res.mean.count() == rate for: 2000.0 == 2000 (0x) # estimate_clock_resolution @@ -4115,22 +4127,12 @@ ok {test-number} - # SKIP ok {test-number} - s == "7" for: "7" == "7" # non-copyable objects ok {test-number} - ti == typeid(int) for: {?} == {?} -# normal_cdf -ok {test-number} - normal_cdf(0.000000) == Approx(0.50000000000000000) for: 0.5 == Approx( 0.5 ) -# normal_cdf -ok {test-number} - normal_cdf(1.000000) == Approx(0.84134474606854293) for: 0.8413447461 == Approx( 0.8413447461 ) -# normal_cdf -ok {test-number} - normal_cdf(-1.000000) == Approx(0.15865525393145705) for: 0.1586552539 == Approx( 0.1586552539 ) -# normal_cdf -ok {test-number} - normal_cdf(2.809729) == Approx(0.99752083845315409) for: 0.9975208385 == Approx( 0.9975208385 ) -# normal_cdf -ok {test-number} - normal_cdf(-1.352570) == Approx(0.08809652095066035) for: 0.088096521 == Approx( 0.088096521 ) # normal_quantile -ok {test-number} - normal_quantile(0.551780) == Approx(0.13015979861484198) for: 0.1301597986 == Approx( 0.1301597986 ) +ok {test-number} - normal_quantile(0.551780) == Approx(0.13015979861484198) for: 0.13015979861484195 == Approx( 0.13015979861484198 ) # normal_quantile -ok {test-number} - normal_quantile(0.533700) == Approx(0.08457408802851875) for: 0.084574088 == Approx( 0.084574088 ) +ok {test-number} - normal_quantile(0.533700) == Approx(0.08457408802851875) for: 0.08457408802851875 == Approx( 0.08457408802851875 ) # normal_quantile -ok {test-number} - normal_quantile(0.025000) == Approx(-1.95996398454005449) for: -1.9599639845 == Approx( -1.9599639845 ) +ok {test-number} - normal_quantile(0.025000) == Approx(-1.95996398454005449) for: -1.95996398454005405 == Approx( -1.95996398454005449 ) # not allowed ok {test-number} - # not prints unscoped info from previous failures @@ -4206,6 +4208,14 @@ ok {test-number} - !(Catch::replaceInPlace(letters, "x", "z")) for: !false # replaceInPlace ok {test-number} - letters == letters for: "abcdefcg" == "abcdefcg" # replaceInPlace +ok {test-number} - Catch::replaceInPlace(letters, "c", "cc") for: true +# replaceInPlace +ok {test-number} - letters == "abccdefccg" for: "abccdefccg" == "abccdefccg" +# replaceInPlace +ok {test-number} - Catch::replaceInPlace(s, "--", "-") for: true +# replaceInPlace +ok {test-number} - s == "--" for: "--" == "--" +# replaceInPlace ok {test-number} - Catch::replaceInPlace(s, "'", "|'") for: true # replaceInPlace ok {test-number} - s == "didn|'t" for: "didn|'t" == "didn|'t" @@ -4406,15 +4416,15 @@ ok {test-number} - "{ }" == ::Catch::Detail::stringify(type{}) for: "{ }" == "{ # tuple<> ok {test-number} - "{ }" == ::Catch::Detail::stringify(value) for: "{ }" == "{ }" # tuple -ok {test-number} - "1.2f" == ::Catch::Detail::stringify(float(1.2)) for: "1.2f" == "1.2f" +ok {test-number} - "1.5f" == ::Catch::Detail::stringify(float(1.5)) for: "1.5f" == "1.5f" # tuple -ok {test-number} - "{ 1.2f, 0 }" == ::Catch::Detail::stringify(type{1.2f,0}) for: "{ 1.2f, 0 }" == "{ 1.2f, 0 }" +ok {test-number} - "{ 1.5f, 0 }" == ::Catch::Detail::stringify(type{1.5f,0}) for: "{ 1.5f, 0 }" == "{ 1.5f, 0 }" # tuple ok {test-number} - "{ 0 }" == ::Catch::Detail::stringify(type{0}) for: "{ 0 }" == "{ 0 }" # tuple ok {test-number} - "{ \"hello\", \"world\" }" == ::Catch::Detail::stringify(type{"hello","world"}) for: "{ "hello", "world" }" == "{ "hello", "world" }" # tuple,tuple<>,float> -ok {test-number} - "{ { 42 }, { }, 1.2f }" == ::Catch::Detail::stringify(value) for: "{ { 42 }, { }, 1.2f }" == "{ { 42 }, { }, 1.2f }" +ok {test-number} - "{ { 42 }, { }, 1.5f }" == ::Catch::Detail::stringify(value) for: "{ { 42 }, { }, 1.5f }" == "{ { 42 }, { }, 1.5f }" # uniform samples ok {test-number} - e.point == 23 for: 23.0 == 23 # uniform samples @@ -4422,7 +4432,7 @@ ok {test-number} - e.upper_bound == 23 for: 23.0 == 23 # uniform samples ok {test-number} - e.lower_bound == 23 for: 23.0 == 23 # uniform samples -ok {test-number} - e.confidence_interval == 0.95 for: 0.95 == 0.95 +ok {test-number} - e.confidence_interval == 0.95 for: 0.94999999999999996 == 0.94999999999999996 # uniform_integer_distribution can return the bounds ok {test-number} - dist.a() == -10 for: -10 == -10 # uniform_integer_distribution can return the bounds @@ -4549,5 +4559,5 @@ ok {test-number} - q3 == 23. for: 23.0 == 23.0 ok {test-number} - # xmlentitycheck ok {test-number} - -1..2272 +1..2277 diff --git a/tests/SelfTest/Baselines/tap.sw.multi.approved.txt b/tests/SelfTest/Baselines/tap.sw.multi.approved.txt index 13449bd40b..3f8f72ebb4 100644 --- a/tests/SelfTest/Baselines/tap.sw.multi.approved.txt +++ b/tests/SelfTest/Baselines/tap.sw.multi.approved.txt @@ -476,6 +476,14 @@ ok {test-number} - Nttp_Fixture::value > 0 for: 6 > 0 not ok {test-number} - m_a == 2 for: 1 == 2 # A TEST_CASE_METHOD based test run that succeeds ok {test-number} - m_a == 1 for: 1 == 1 +# A TEST_CASE_PERSISTENT_FIXTURE based test run that fails +ok {test-number} - m_a++ == 0 for: 0 == 0 +# A TEST_CASE_PERSISTENT_FIXTURE based test run that fails +not ok {test-number} - m_a == 0 for: 1 == 0 +# A TEST_CASE_PERSISTENT_FIXTURE based test run that succeeds +ok {test-number} - m_a++ == 0 for: 0 == 0 +# A TEST_CASE_PERSISTENT_FIXTURE based test run that succeeds +ok {test-number} - m_a == 1 for: 1 == 1 # A Template product test case - Foo ok {test-number} - x.size() == 0 for: 0 == 0 # A Template product test case - Foo @@ -493,17 +501,17 @@ ok {test-number} - x.size() > 0 for: 42 > 0 # A Template product test case with array signature - std::array ok {test-number} - x.size() > 0 for: 9 > 0 # A comparison that uses literals instead of the normal constructor -ok {test-number} - d == 1.23_a for: 1.23 == Approx( 1.23 ) +ok {test-number} - d == 1.23_a for: 1.22999999999999998 == Approx( 1.22999999999999998 ) # A comparison that uses literals instead of the normal constructor -ok {test-number} - d != 1.22_a for: 1.23 != Approx( 1.22 ) +ok {test-number} - d != 1.22_a for: 1.22999999999999998 != Approx( 1.21999999999999997 ) # A comparison that uses literals instead of the normal constructor -ok {test-number} - -d == -1.23_a for: -1.23 == Approx( -1.23 ) +ok {test-number} - -d == -1.23_a for: -1.22999999999999998 == Approx( -1.22999999999999998 ) # A comparison that uses literals instead of the normal constructor -ok {test-number} - d == 1.2_a .epsilon(.1) for: 1.23 == Approx( 1.2 ) +ok {test-number} - d == 1.2_a .epsilon(.1) for: 1.22999999999999998 == Approx( 1.19999999999999996 ) # A comparison that uses literals instead of the normal constructor -ok {test-number} - d != 1.2_a .epsilon(.001) for: 1.23 != Approx( 1.2 ) +ok {test-number} - d != 1.2_a .epsilon(.001) for: 1.22999999999999998 != Approx( 1.19999999999999996 ) # A comparison that uses literals instead of the normal constructor -ok {test-number} - d == 1_a .epsilon(.3) for: 1.23 == Approx( 1.0 ) +ok {test-number} - d == 1_a .epsilon(.3) for: 1.22999999999999998 == Approx( 1.0 ) # A couple of nested sections followed by a failure ok {test-number} - with 1 message: 'that's not flying - that's failing in style' # A couple of nested sections followed by a failure @@ -521,9 +529,9 @@ ok {test-number} - 104.0 == Approx(100.0).margin(4) for: 104.0 == Approx( 100.0 # Absolute margin ok {test-number} - 104.0 != Approx(100.0).margin(3) for: 104.0 != Approx( 100.0 ) # Absolute margin -ok {test-number} - 100.3 != Approx(100.0) for: 100.3 != Approx( 100.0 ) +ok {test-number} - 100.3 != Approx(100.0) for: 100.29999999999999716 != Approx( 100.0 ) # Absolute margin -ok {test-number} - 100.3 == Approx(100.0).margin(0.5) for: 100.3 == Approx( 100.0 ) +ok {test-number} - 100.3 == Approx(100.0).margin(0.5) for: 100.29999999999999716 == Approx( 100.0 ) # An expression with side-effects should only be evaluated once ok {test-number} - i++ == 7 for: 7 == 7 # An expression with side-effects should only be evaluated once @@ -559,15 +567,15 @@ ok {test-number} - 245.0f == Approx(245.25f).margin(0.25f) for: 245.0f == Approx # Approx with exactly-representable margin ok {test-number} - 245.5f == Approx(245.25f).margin(0.25f) for: 245.5f == Approx( 245.25 ) # Approximate PI -ok {test-number} - divide( 22, 7 ) == Approx( 3.141 ).epsilon( 0.001 ) for: 3.1428571429 == Approx( 3.141 ) +ok {test-number} - divide( 22, 7 ) == Approx( 3.141 ).epsilon( 0.001 ) for: 3.14285714285714279 == Approx( 3.14100000000000001 ) # Approximate PI -ok {test-number} - divide( 22, 7 ) != Approx( 3.141 ).epsilon( 0.0001 ) for: 3.1428571429 != Approx( 3.141 ) +ok {test-number} - divide( 22, 7 ) != Approx( 3.141 ).epsilon( 0.0001 ) for: 3.14285714285714279 != Approx( 3.14100000000000001 ) # Approximate comparisons with different epsilons -ok {test-number} - d != Approx( 1.231 ) for: 1.23 != Approx( 1.231 ) +ok {test-number} - d != Approx( 1.231 ) for: 1.22999999999999998 != Approx( 1.23100000000000009 ) # Approximate comparisons with different epsilons -ok {test-number} - d == Approx( 1.231 ).epsilon( 0.1 ) for: 1.23 == Approx( 1.231 ) +ok {test-number} - d == Approx( 1.231 ).epsilon( 0.1 ) for: 1.22999999999999998 == Approx( 1.23100000000000009 ) # Approximate comparisons with floats -ok {test-number} - 1.23f == Approx( 1.23f ) for: 1.23f == Approx( 1.2300000191 ) +ok {test-number} - 1.23f == Approx( 1.23f ) for: 1.230000019f == Approx( 1.23000001907348633 ) # Approximate comparisons with floats ok {test-number} - 0.0f == Approx( 0.0f ) for: 0.0f == Approx( 0.0 ) # Approximate comparisons with ints @@ -581,9 +589,9 @@ ok {test-number} - 0 == Approx( dZero) for: 0 == Approx( 0.0 ) # Approximate comparisons with mixed numeric types ok {test-number} - 0 == Approx( dSmall ).margin( 0.001 ) for: 0 == Approx( 0.00001 ) # Approximate comparisons with mixed numeric types -ok {test-number} - 1.234f == Approx( dMedium ) for: 1.234f == Approx( 1.234 ) +ok {test-number} - 1.234f == Approx( dMedium ) for: 1.233999968f == Approx( 1.23399999999999999 ) # Approximate comparisons with mixed numeric types -ok {test-number} - dMedium == Approx( 1.234f ) for: 1.234 == Approx( 1.2339999676 ) +ok {test-number} - dMedium == Approx( 1.234f ) for: 1.23399999999999999 == Approx( 1.23399996757507324 ) # Arbitrary predicate matcher ok {test-number} - 1, Predicate( alwaysTrue, "always true" ) for: 1 matches predicate: "always true" # Arbitrary predicate matcher @@ -695,33 +703,37 @@ ok {test-number} - lt( "A", "b" ) for: true # CaseInsensitiveLess is case insensitive ok {test-number} - lt( "A", "B" ) for: true # Character pretty printing -ok {test-number} - tab == '\t' for: '\t' == '\t' -# Character pretty printing -ok {test-number} - newline == '\n' for: '\n' == '\n' -# Character pretty printing -ok {test-number} - carr_return == '\r' for: '\r' == '\r' -# Character pretty printing -ok {test-number} - form_feed == '\f' for: '\f' == '\f' +ok {test-number} - ::Catch::Detail::stringify('\t') == "'\\t'" for: "'\t'" == "'\t'" # Character pretty printing -ok {test-number} - space == ' ' for: ' ' == ' ' +ok {test-number} - ::Catch::Detail::stringify('\n') == "'\\n'" for: "'\n'" == "'\n'" # Character pretty printing -ok {test-number} - c == chars[i] for: 'a' == 'a' +ok {test-number} - ::Catch::Detail::stringify('\r') == "'\\r'" for: "'\r'" == "'\r'" # Character pretty printing -ok {test-number} - c == chars[i] for: 'z' == 'z' +ok {test-number} - ::Catch::Detail::stringify('\f') == "'\\f'" for: "'\f'" == "'\f'" # Character pretty printing -ok {test-number} - c == chars[i] for: 'A' == 'A' +ok {test-number} - ::Catch::Detail::stringify( ' ' ) == "' '" for: "' '" == "' '" # Character pretty printing -ok {test-number} - c == chars[i] for: 'Z' == 'Z' +ok {test-number} - ::Catch::Detail::stringify( 'A' ) == "'A'" for: "'A'" == "'A'" # Character pretty printing -ok {test-number} - null_terminator == '\0' for: 0 == 0 +ok {test-number} - ::Catch::Detail::stringify( 'z' ) == "'z'" for: "'z'" == "'z'" # Character pretty printing -ok {test-number} - c == i for: 2 == 2 +ok {test-number} - ::Catch::Detail::stringify( '\0' ) == "0" for: "0" == "0" # Character pretty printing -ok {test-number} - c == i for: 3 == 3 +ok {test-number} - ::Catch::Detail::stringify( static_cast(2) ) == "2" for: "2" == "2" # Character pretty printing -ok {test-number} - c == i for: 4 == 4 -# Character pretty printing -ok {test-number} - c == i for: 5 == 5 +ok {test-number} - ::Catch::Detail::stringify( static_cast(5) ) == "5" for: "5" == "5" +# Clara::Arg does not crash on incomplete input +ok {test-number} - name.empty() for: true +# Clara::Arg does not crash on incomplete input +ok {test-number} - result for: {?} +# Clara::Arg does not crash on incomplete input +ok {test-number} - result.type() == Catch::Clara::Detail::ResultType::Ok for: 0 == 0 +# Clara::Arg does not crash on incomplete input +ok {test-number} - parsed.type() == Catch::Clara::ParseResultType::NoMatch for: 1 == 1 +# Clara::Arg does not crash on incomplete input +ok {test-number} - parsed.remainingTokens().count() == 2 for: 2 == 2 +# Clara::Arg does not crash on incomplete input +ok {test-number} - name.empty() for: true # Clara::Arg supports single-arg parse the way Opt does ok {test-number} - name.empty() for: true # Clara::Arg supports single-arg parse the way Opt does @@ -973,7 +985,7 @@ not ok {test-number} - unexpected exception with message: 'custom exception - no # Custom std-exceptions can be custom translated not ok {test-number} - unexpected exception with message: 'custom std exception' # Default scale is invisible to comparison -ok {test-number} - 101.000001 != Approx(100).epsilon(0.01) for: 101.000001 != Approx( 100.0 ) +ok {test-number} - 101.000001 != Approx(100).epsilon(0.01) for: 101.00000099999999748 != Approx( 100.0 ) # Default scale is invisible to comparison ok {test-number} - std::pow(10, -5) != Approx(std::pow(10, -7)) for: 0.00001 != Approx( 0.0000001 ) # Directly creating an EnumInfo @@ -1005,7 +1017,7 @@ ok {test-number} - stringify( Bikeshed::Colours::Red ) == "Red" for: "Red" == "R # Enums in namespaces can quickly have stringification enabled using REGISTER_ENUM ok {test-number} - stringify( Bikeshed::Colours::Blue ) == "Blue" for: "Blue" == "Blue" # Epsilon only applies to Approx's value -ok {test-number} - 101.01 != Approx(100).epsilon(0.01) for: 101.01 != Approx( 100.0 ) +ok {test-number} - 101.01 != Approx(100).epsilon(0.01) for: 101.01000000000000512 != Approx( 100.0 ) # Equality checks that should fail not ok {test-number} - data.int_seven == 6 for: 7 == 6 # Equality checks that should fail @@ -1013,15 +1025,15 @@ not ok {test-number} - data.int_seven == 8 for: 7 == 8 # Equality checks that should fail not ok {test-number} - data.int_seven == 0 for: 7 == 0 # Equality checks that should fail -not ok {test-number} - data.float_nine_point_one == Approx( 9.11f ) for: 9.1f == Approx( 9.1099996567 ) +not ok {test-number} - data.float_nine_point_one == Approx( 9.11f ) for: 9.100000381f == Approx( 9.10999965667724609 ) # Equality checks that should fail -not ok {test-number} - data.float_nine_point_one == Approx( 9.0f ) for: 9.1f == Approx( 9.0 ) +not ok {test-number} - data.float_nine_point_one == Approx( 9.0f ) for: 9.100000381f == Approx( 9.0 ) # Equality checks that should fail -not ok {test-number} - data.float_nine_point_one == Approx( 1 ) for: 9.1f == Approx( 1.0 ) +not ok {test-number} - data.float_nine_point_one == Approx( 1 ) for: 9.100000381f == Approx( 1.0 ) # Equality checks that should fail -not ok {test-number} - data.float_nine_point_one == Approx( 0 ) for: 9.1f == Approx( 0.0 ) +not ok {test-number} - data.float_nine_point_one == Approx( 0 ) for: 9.100000381f == Approx( 0.0 ) # Equality checks that should fail -not ok {test-number} - data.double_pi == Approx( 3.1415 ) for: 3.1415926535 == Approx( 3.1415 ) +not ok {test-number} - data.double_pi == Approx( 3.1415 ) for: 3.14159265350000005 == Approx( 3.14150000000000018 ) # Equality checks that should fail not ok {test-number} - data.str_hello == "goodbye" for: "hello" == "goodbye" # Equality checks that should fail @@ -1031,13 +1043,13 @@ not ok {test-number} - data.str_hello == "hello1" for: "hello" == "hello1" # Equality checks that should fail not ok {test-number} - data.str_hello.size() == 6 for: 5 == 6 # Equality checks that should fail -not ok {test-number} - x == Approx( 1.301 ) for: 1.3 == Approx( 1.301 ) +not ok {test-number} - x == Approx( 1.301 ) for: 1.30000000000000027 == Approx( 1.30099999999999993 ) # Equality checks that should succeed ok {test-number} - data.int_seven == 7 for: 7 == 7 # Equality checks that should succeed -ok {test-number} - data.float_nine_point_one == Approx( 9.1f ) for: 9.1f == Approx( 9.1000003815 ) +ok {test-number} - data.float_nine_point_one == Approx( 9.1f ) for: 9.100000381f == Approx( 9.10000038146972656 ) # Equality checks that should succeed -ok {test-number} - data.double_pi == Approx( 3.1415926535 ) for: 3.1415926535 == Approx( 3.1415926535 ) +ok {test-number} - data.double_pi == Approx( 3.1415926535 ) for: 3.14159265350000005 == Approx( 3.14159265350000005 ) # Equality checks that should succeed ok {test-number} - data.str_hello == "hello" for: "hello" == "hello" # Equality checks that should succeed @@ -1045,7 +1057,7 @@ ok {test-number} - "hello" == data.str_hello for: "hello" == "hello" # Equality checks that should succeed ok {test-number} - data.str_hello.size() == 5 for: 5 == 5 # Equality checks that should succeed -ok {test-number} - x == Approx( 1.3 ) for: 1.3 == Approx( 1.3 ) +ok {test-number} - x == Approx( 1.3 ) for: 1.30000000000000027 == Approx( 1.30000000000000004 ) # Equals ok {test-number} - testStringForMatching(), Equals( "this string contains 'abc' as a substring" ) for: "this string contains 'abc' as a substring" equals: "this string contains 'abc' as a substring" # Equals @@ -1131,23 +1143,23 @@ ok {test-number} - Factorial(10) == 3628800 for: 3628800 (0x) == 362 # Filter generator throws exception for empty generator ok {test-number} - filter( []( int ) { return false; }, value( 3 ) ), Catch::GeneratorException # Floating point matchers: double -ok {test-number} - 10., WithinRel( 11.1, 0.1 ) for: 10.0 and 11.1 are within 10% of each other +ok {test-number} - 10., WithinRel( 11.1, 0.1 ) for: 10.0 and 11.09999999999999964 are within 10% of each other # Floating point matchers: double -ok {test-number} - 10., !WithinRel( 11.2, 0.1 ) for: 10.0 not and 11.2 are within 10% of each other +ok {test-number} - 10., !WithinRel( 11.2, 0.1 ) for: 10.0 not and 11.19999999999999929 are within 10% of each other # Floating point matchers: double -ok {test-number} - 1., !WithinRel( 0., 0.99 ) for: 1.0 not and 0 are within 99% of each other +ok {test-number} - 1., !WithinRel( 0., 0.99 ) for: 1.0 not and 0.0 are within 99% of each other # Floating point matchers: double -ok {test-number} - -0., WithinRel( 0. ) for: -0.0 and 0 are within 2.22045e-12% of each other +ok {test-number} - -0., WithinRel( 0. ) for: -0.0 and 0.0 are within 2.22045e-12% of each other # Floating point matchers: double -ok {test-number} - v1, WithinRel( v2 ) for: 0.0 and 2.22507e-308 are within 2.22045e-12% of each other +ok {test-number} - v1, WithinRel( v2 ) for: 0.0 and 0.0 are within 2.22045e-12% of each other # Floating point matchers: double ok {test-number} - 1., WithinAbs( 1., 0 ) for: 1.0 is within 0.0 of 1.0 # Floating point matchers: double ok {test-number} - 0., WithinAbs( 1., 1 ) for: 0.0 is within 1.0 of 1.0 # Floating point matchers: double -ok {test-number} - 0., !WithinAbs( 1., 0.99 ) for: 0.0 not is within 0.99 of 1.0 +ok {test-number} - 0., !WithinAbs( 1., 0.99 ) for: 0.0 not is within 0.98999999999999999 of 1.0 # Floating point matchers: double -ok {test-number} - 0., !WithinAbs( 1., 0.99 ) for: 0.0 not is within 0.99 of 1.0 +ok {test-number} - 0., !WithinAbs( 1., 0.99 ) for: 0.0 not is within 0.98999999999999999 of 1.0 # Floating point matchers: double ok {test-number} - 11., !WithinAbs( 10., 0.5 ) for: 11.0 not is within 0.5 of 10.0 # Floating point matchers: double @@ -1155,11 +1167,11 @@ ok {test-number} - 10., !WithinAbs( 11., 0.5 ) for: 10.0 not is within 0.5 of 11 # Floating point matchers: double ok {test-number} - -10., WithinAbs( -10., 0.5 ) for: -10.0 is within 0.5 of -10.0 # Floating point matchers: double -ok {test-number} - -10., WithinAbs( -9.6, 0.5 ) for: -10.0 is within 0.5 of -9.6 +ok {test-number} - -10., WithinAbs( -9.6, 0.5 ) for: -10.0 is within 0.5 of -9.59999999999999964 # Floating point matchers: double ok {test-number} - 1., WithinULP( 1., 0 ) for: 1.0 is within 0 ULPs of 1.0000000000000000e+00 ([1.0000000000000000e+00, 1.0000000000000000e+00]) # Floating point matchers: double -ok {test-number} - nextafter( 1., 2. ), WithinULP( 1., 1 ) for: 1.0 is within 1 ULPs of 1.0000000000000000e+00 ([9.9999999999999989e-01, 1.0000000000000002e+00]) +ok {test-number} - nextafter( 1., 2. ), WithinULP( 1., 1 ) for: 1.00000000000000022 is within 1 ULPs of 1.0000000000000000e+00 ([9.9999999999999989e-01, 1.0000000000000002e+00]) # Floating point matchers: double ok {test-number} - 0., WithinULP( nextafter( 0., 1. ), 1 ) for: 0.0 is within 1 ULPs of 4.9406564584124654e-324 ([0.0000000000000000e+00, 9.8813129168249309e-324]) # Floating point matchers: double @@ -1175,7 +1187,7 @@ ok {test-number} - 1., WithinAbs( 1., 0.5 ) || WithinULP( 2., 1 ) for: 1.0 ( is # Floating point matchers: double ok {test-number} - 1., WithinAbs( 2., 0.5 ) || WithinULP( 1., 0 ) for: 1.0 ( is within 0.5 of 2.0 or is within 0 ULPs of 1.0000000000000000e+00 ([1.0000000000000000e+00, 1.0000000000000000e+00]) ) # Floating point matchers: double -ok {test-number} - 0.0001, WithinAbs( 0., 0.001 ) || WithinRel( 0., 0.1 ) for: 0.0001 ( is within 0.001 of 0.0 or and 0 are within 10% of each other ) +ok {test-number} - 0.0001, WithinAbs( 0., 0.001 ) || WithinRel( 0., 0.1 ) for: 0.0001 ( is within 0.001 of 0.0 or and 0.0 are within 10% of each other ) # Floating point matchers: double ok {test-number} - WithinAbs( 1., 0. ) # Floating point matchers: double @@ -1191,23 +1203,23 @@ ok {test-number} - WithinRel( 1., 1. ), std::domain_error # Floating point matchers: double ok {test-number} - 1., !IsNaN() for: 1.0 not is NaN # Floating point matchers: float -ok {test-number} - 10.f, WithinRel( 11.1f, 0.1f ) for: 10.0f and 11.1 are within 10% of each other +ok {test-number} - 10.f, WithinRel( 11.1f, 0.1f ) for: 10.0f and 11.10000038146972656 are within 10% of each other # Floating point matchers: float -ok {test-number} - 10.f, !WithinRel( 11.2f, 0.1f ) for: 10.0f not and 11.2 are within 10% of each other +ok {test-number} - 10.f, !WithinRel( 11.2f, 0.1f ) for: 10.0f not and 11.19999980926513672 are within 10% of each other # Floating point matchers: float -ok {test-number} - 1.f, !WithinRel( 0.f, 0.99f ) for: 1.0f not and 0 are within 99% of each other +ok {test-number} - 1.f, !WithinRel( 0.f, 0.99f ) for: 1.0f not and 0.0 are within 99% of each other # Floating point matchers: float -ok {test-number} - -0.f, WithinRel( 0.f ) for: -0.0f and 0 are within 0.00119209% of each other +ok {test-number} - -0.f, WithinRel( 0.f ) for: -0.0f and 0.0 are within 0.00119209% of each other # Floating point matchers: float -ok {test-number} - v1, WithinRel( v2 ) for: 0.0f and 1.17549e-38 are within 0.00119209% of each other +ok {test-number} - v1, WithinRel( v2 ) for: 0.0f and 0.0 are within 0.00119209% of each other # Floating point matchers: float ok {test-number} - 1.f, WithinAbs( 1.f, 0 ) for: 1.0f is within 0.0 of 1.0 # Floating point matchers: float ok {test-number} - 0.f, WithinAbs( 1.f, 1 ) for: 0.0f is within 1.0 of 1.0 # Floating point matchers: float -ok {test-number} - 0.f, !WithinAbs( 1.f, 0.99f ) for: 0.0f not is within 0.9900000095 of 1.0 +ok {test-number} - 0.f, !WithinAbs( 1.f, 0.99f ) for: 0.0f not is within 0.99000000953674316 of 1.0 # Floating point matchers: float -ok {test-number} - 0.f, !WithinAbs( 1.f, 0.99f ) for: 0.0f not is within 0.9900000095 of 1.0 +ok {test-number} - 0.f, !WithinAbs( 1.f, 0.99f ) for: 0.0f not is within 0.99000000953674316 of 1.0 # Floating point matchers: float ok {test-number} - 0.f, WithinAbs( -0.f, 0 ) for: 0.0f is within 0.0 of -0.0 # Floating point matchers: float @@ -1217,13 +1229,13 @@ ok {test-number} - 10.f, !WithinAbs( 11.f, 0.5f ) for: 10.0f not is within 0.5 o # Floating point matchers: float ok {test-number} - -10.f, WithinAbs( -10.f, 0.5f ) for: -10.0f is within 0.5 of -10.0 # Floating point matchers: float -ok {test-number} - -10.f, WithinAbs( -9.6f, 0.5f ) for: -10.0f is within 0.5 of -9.6000003815 +ok {test-number} - -10.f, WithinAbs( -9.6f, 0.5f ) for: -10.0f is within 0.5 of -9.60000038146972656 # Floating point matchers: float ok {test-number} - 1.f, WithinULP( 1.f, 0 ) for: 1.0f is within 0 ULPs of 1.00000000e+00f ([1.00000000e+00, 1.00000000e+00]) # Floating point matchers: float ok {test-number} - -1.f, WithinULP( -1.f, 0 ) for: -1.0f is within 0 ULPs of -1.00000000e+00f ([-1.00000000e+00, -1.00000000e+00]) # Floating point matchers: float -ok {test-number} - nextafter( 1.f, 2.f ), WithinULP( 1.f, 1 ) for: 1.0f is within 1 ULPs of 1.00000000e+00f ([9.99999940e-01, 1.00000012e+00]) +ok {test-number} - nextafter( 1.f, 2.f ), WithinULP( 1.f, 1 ) for: 1.000000119f is within 1 ULPs of 1.00000000e+00f ([9.99999940e-01, 1.00000012e+00]) # Floating point matchers: float ok {test-number} - 0.f, WithinULP( nextafter( 0.f, 1.f ), 1 ) for: 0.0f is within 1 ULPs of 1.40129846e-45f ([0.00000000e+00, 2.80259693e-45]) # Floating point matchers: float @@ -1239,7 +1251,7 @@ ok {test-number} - 1.f, WithinAbs( 1.f, 0.5 ) || WithinULP( 1.f, 1 ) for: 1.0f ( # Floating point matchers: float ok {test-number} - 1.f, WithinAbs( 2.f, 0.5 ) || WithinULP( 1.f, 0 ) for: 1.0f ( is within 0.5 of 2.0 or is within 0 ULPs of 1.00000000e+00f ([1.00000000e+00, 1.00000000e+00]) ) # Floating point matchers: float -ok {test-number} - 0.0001f, WithinAbs( 0.f, 0.001f ) || WithinRel( 0.f, 0.1f ) for: 0.0001f ( is within 0.001 of 0.0 or and 0 are within 10% of each other ) +ok {test-number} - 0.0001f, WithinAbs( 0.f, 0.001f ) || WithinRel( 0.f, 0.1f ) for: 0.0001f ( is within 0.00100000004749745 of 0.0 or and 0.0 are within 10% of each other ) # Floating point matchers: float ok {test-number} - WithinAbs( 1.f, 0.f ) # Floating point matchers: float @@ -1599,83 +1611,83 @@ ok {test-number} - gen.get() == Approx(expected) for: -1.0 == Approx( -1.0 ) wit # Generators internals ok {test-number} - gen.next() for: true with 1 message: 'Current expected value is -1' # Generators internals -ok {test-number} - gen.get() == Approx(expected) for: -0.9 == Approx( -0.9 ) with 1 message: 'Current expected value is -0.9' +ok {test-number} - gen.get() == Approx(expected) for: -0.90000000000000002 == Approx( -0.90000000000000002 ) with 1 message: 'Current expected value is -0.9' # Generators internals ok {test-number} - gen.next() for: true with 1 message: 'Current expected value is -0.9' # Generators internals -ok {test-number} - gen.get() == Approx(expected) for: -0.8 == Approx( -0.8 ) with 1 message: 'Current expected value is -0.8' +ok {test-number} - gen.get() == Approx(expected) for: -0.80000000000000004 == Approx( -0.80000000000000004 ) with 1 message: 'Current expected value is -0.8' # Generators internals ok {test-number} - gen.next() for: true with 1 message: 'Current expected value is -0.8' # Generators internals -ok {test-number} - gen.get() == Approx(expected) for: -0.7 == Approx( -0.7 ) with 1 message: 'Current expected value is -0.7' +ok {test-number} - gen.get() == Approx(expected) for: -0.70000000000000007 == Approx( -0.70000000000000007 ) with 1 message: 'Current expected value is -0.7' # Generators internals ok {test-number} - gen.next() for: true with 1 message: 'Current expected value is -0.7' # Generators internals -ok {test-number} - gen.get() == Approx(expected) for: -0.6 == Approx( -0.6 ) with 1 message: 'Current expected value is -0.6' +ok {test-number} - gen.get() == Approx(expected) for: -0.60000000000000009 == Approx( -0.60000000000000009 ) with 1 message: 'Current expected value is -0.6' # Generators internals ok {test-number} - gen.next() for: true with 1 message: 'Current expected value is -0.6' # Generators internals -ok {test-number} - gen.get() == Approx(expected) for: -0.5 == Approx( -0.5 ) with 1 message: 'Current expected value is -0.5' +ok {test-number} - gen.get() == Approx(expected) for: -0.50000000000000011 == Approx( -0.50000000000000011 ) with 1 message: 'Current expected value is -0.5' # Generators internals ok {test-number} - gen.next() for: true with 1 message: 'Current expected value is -0.5' # Generators internals -ok {test-number} - gen.get() == Approx(expected) for: -0.4 == Approx( -0.4 ) with 1 message: 'Current expected value is -0.4' +ok {test-number} - gen.get() == Approx(expected) for: -0.40000000000000013 == Approx( -0.40000000000000013 ) with 1 message: 'Current expected value is -0.4' # Generators internals ok {test-number} - gen.next() for: true with 1 message: 'Current expected value is -0.4' # Generators internals -ok {test-number} - gen.get() == Approx(expected) for: -0.3 == Approx( -0.3 ) with 1 message: 'Current expected value is -0.3' +ok {test-number} - gen.get() == Approx(expected) for: -0.30000000000000016 == Approx( -0.30000000000000016 ) with 1 message: 'Current expected value is -0.3' # Generators internals ok {test-number} - gen.next() for: true with 1 message: 'Current expected value is -0.3' # Generators internals -ok {test-number} - gen.get() == Approx(expected) for: -0.2 == Approx( -0.2 ) with 1 message: 'Current expected value is -0.2' +ok {test-number} - gen.get() == Approx(expected) for: -0.20000000000000015 == Approx( -0.20000000000000015 ) with 1 message: 'Current expected value is -0.2' # Generators internals ok {test-number} - gen.next() for: true with 1 message: 'Current expected value is -0.2' # Generators internals -ok {test-number} - gen.get() == Approx(expected) for: -0.1 == Approx( -0.1 ) with 1 message: 'Current expected value is -0.1' +ok {test-number} - gen.get() == Approx(expected) for: -0.10000000000000014 == Approx( -0.10000000000000014 ) with 1 message: 'Current expected value is -0.1' # Generators internals ok {test-number} - gen.next() for: true with 1 message: 'Current expected value is -0.1' # Generators internals -ok {test-number} - gen.get() == Approx(expected) for: -0.0 == Approx( -0.0 ) with 1 message: 'Current expected value is -1.38778e-16' +ok {test-number} - gen.get() == Approx(expected) for: -0.00000000000000014 == Approx( -0.00000000000000014 ) with 1 message: 'Current expected value is -1.38778e-16' # Generators internals ok {test-number} - gen.next() for: true with 1 message: 'Current expected value is -1.38778e-16' # Generators internals -ok {test-number} - gen.get() == Approx(expected) for: 0.1 == Approx( 0.1 ) with 1 message: 'Current expected value is 0.1' +ok {test-number} - gen.get() == Approx(expected) for: 0.09999999999999987 == Approx( 0.09999999999999987 ) with 1 message: 'Current expected value is 0.1' # Generators internals ok {test-number} - gen.next() for: true with 1 message: 'Current expected value is 0.1' # Generators internals -ok {test-number} - gen.get() == Approx(expected) for: 0.2 == Approx( 0.2 ) with 1 message: 'Current expected value is 0.2' +ok {test-number} - gen.get() == Approx(expected) for: 0.19999999999999987 == Approx( 0.19999999999999987 ) with 1 message: 'Current expected value is 0.2' # Generators internals ok {test-number} - gen.next() for: true with 1 message: 'Current expected value is 0.2' # Generators internals -ok {test-number} - gen.get() == Approx(expected) for: 0.3 == Approx( 0.3 ) with 1 message: 'Current expected value is 0.3' +ok {test-number} - gen.get() == Approx(expected) for: 0.29999999999999988 == Approx( 0.29999999999999988 ) with 1 message: 'Current expected value is 0.3' # Generators internals ok {test-number} - gen.next() for: true with 1 message: 'Current expected value is 0.3' # Generators internals -ok {test-number} - gen.get() == Approx(expected) for: 0.4 == Approx( 0.4 ) with 1 message: 'Current expected value is 0.4' +ok {test-number} - gen.get() == Approx(expected) for: 0.39999999999999991 == Approx( 0.39999999999999991 ) with 1 message: 'Current expected value is 0.4' # Generators internals ok {test-number} - gen.next() for: true with 1 message: 'Current expected value is 0.4' # Generators internals -ok {test-number} - gen.get() == Approx(expected) for: 0.5 == Approx( 0.5 ) with 1 message: 'Current expected value is 0.5' +ok {test-number} - gen.get() == Approx(expected) for: 0.49999999999999989 == Approx( 0.49999999999999989 ) with 1 message: 'Current expected value is 0.5' # Generators internals ok {test-number} - gen.next() for: true with 1 message: 'Current expected value is 0.5' # Generators internals -ok {test-number} - gen.get() == Approx(expected) for: 0.6 == Approx( 0.6 ) with 1 message: 'Current expected value is 0.6' +ok {test-number} - gen.get() == Approx(expected) for: 0.59999999999999987 == Approx( 0.59999999999999987 ) with 1 message: 'Current expected value is 0.6' # Generators internals ok {test-number} - gen.next() for: true with 1 message: 'Current expected value is 0.6' # Generators internals -ok {test-number} - gen.get() == Approx(expected) for: 0.7 == Approx( 0.7 ) with 1 message: 'Current expected value is 0.7' +ok {test-number} - gen.get() == Approx(expected) for: 0.69999999999999984 == Approx( 0.69999999999999984 ) with 1 message: 'Current expected value is 0.7' # Generators internals ok {test-number} - gen.next() for: true with 1 message: 'Current expected value is 0.7' # Generators internals -ok {test-number} - gen.get() == Approx(expected) for: 0.8 == Approx( 0.8 ) with 1 message: 'Current expected value is 0.8' +ok {test-number} - gen.get() == Approx(expected) for: 0.79999999999999982 == Approx( 0.79999999999999982 ) with 1 message: 'Current expected value is 0.8' # Generators internals ok {test-number} - gen.next() for: true with 1 message: 'Current expected value is 0.8' # Generators internals -ok {test-number} - gen.get() == Approx(expected) for: 0.9 == Approx( 0.9 ) with 1 message: 'Current expected value is 0.9' +ok {test-number} - gen.get() == Approx(expected) for: 0.8999999999999998 == Approx( 0.8999999999999998 ) with 1 message: 'Current expected value is 0.9' # Generators internals ok {test-number} - gen.next() for: true with 1 message: 'Current expected value is 0.9' # Generators internals -ok {test-number} - gen.get() == Approx( rangeEnd ) for: 1.0 == Approx( 1.0 ) +ok {test-number} - gen.get() == Approx( rangeEnd ) for: 0.99999999999999978 == Approx( 1.0 ) # Generators internals ok {test-number} - !(gen.next()) for: !false # Generators internals @@ -1683,19 +1695,19 @@ ok {test-number} - gen.get() == Approx(expected) for: -1.0 == Approx( -1.0 ) wit # Generators internals ok {test-number} - gen.next() for: true with 1 message: 'Current expected value is -1' # Generators internals -ok {test-number} - gen.get() == Approx(expected) for: -0.7 == Approx( -0.7 ) with 1 message: 'Current expected value is -0.7' +ok {test-number} - gen.get() == Approx(expected) for: -0.69999999999999996 == Approx( -0.69999999999999996 ) with 1 message: 'Current expected value is -0.7' # Generators internals ok {test-number} - gen.next() for: true with 1 message: 'Current expected value is -0.7' # Generators internals -ok {test-number} - gen.get() == Approx(expected) for: -0.4 == Approx( -0.4 ) with 1 message: 'Current expected value is -0.4' +ok {test-number} - gen.get() == Approx(expected) for: -0.39999999999999997 == Approx( -0.39999999999999997 ) with 1 message: 'Current expected value is -0.4' # Generators internals ok {test-number} - gen.next() for: true with 1 message: 'Current expected value is -0.4' # Generators internals -ok {test-number} - gen.get() == Approx(expected) for: -0.1 == Approx( -0.1 ) with 1 message: 'Current expected value is -0.1' +ok {test-number} - gen.get() == Approx(expected) for: -0.09999999999999998 == Approx( -0.09999999999999998 ) with 1 message: 'Current expected value is -0.1' # Generators internals ok {test-number} - gen.next() for: true with 1 message: 'Current expected value is -0.1' # Generators internals -ok {test-number} - gen.get() == Approx(expected) for: 0.2 == Approx( 0.2 ) with 1 message: 'Current expected value is 0.2' +ok {test-number} - gen.get() == Approx(expected) for: 0.20000000000000001 == Approx( 0.20000000000000001 ) with 1 message: 'Current expected value is 0.2' # Generators internals ok {test-number} - gen.next() for: true with 1 message: 'Current expected value is 0.2' # Generators internals @@ -1709,19 +1721,19 @@ ok {test-number} - gen.get() == Approx(expected) for: -1.0 == Approx( -1.0 ) wit # Generators internals ok {test-number} - gen.next() for: true with 1 message: 'Current expected value is -1' # Generators internals -ok {test-number} - gen.get() == Approx(expected) for: -0.7 == Approx( -0.7 ) with 1 message: 'Current expected value is -0.7' +ok {test-number} - gen.get() == Approx(expected) for: -0.69999999999999996 == Approx( -0.69999999999999996 ) with 1 message: 'Current expected value is -0.7' # Generators internals ok {test-number} - gen.next() for: true with 1 message: 'Current expected value is -0.7' # Generators internals -ok {test-number} - gen.get() == Approx(expected) for: -0.4 == Approx( -0.4 ) with 1 message: 'Current expected value is -0.4' +ok {test-number} - gen.get() == Approx(expected) for: -0.39999999999999997 == Approx( -0.39999999999999997 ) with 1 message: 'Current expected value is -0.4' # Generators internals ok {test-number} - gen.next() for: true with 1 message: 'Current expected value is -0.4' # Generators internals -ok {test-number} - gen.get() == Approx(expected) for: -0.1 == Approx( -0.1 ) with 1 message: 'Current expected value is -0.1' +ok {test-number} - gen.get() == Approx(expected) for: -0.09999999999999998 == Approx( -0.09999999999999998 ) with 1 message: 'Current expected value is -0.1' # Generators internals ok {test-number} - gen.next() for: true with 1 message: 'Current expected value is -0.1' # Generators internals -ok {test-number} - gen.get() == Approx(expected) for: 0.2 == Approx( 0.2 ) with 1 message: 'Current expected value is 0.2' +ok {test-number} - gen.get() == Approx(expected) for: 0.20000000000000001 == Approx( 0.20000000000000001 ) with 1 message: 'Current expected value is 0.2' # Generators internals ok {test-number} - gen.next() for: true with 1 message: 'Current expected value is 0.2' # Generators internals @@ -1783,13 +1795,13 @@ ok {test-number} - gen.get() == -7 for: -7 == -7 # Generators internals ok {test-number} - !(gen.next()) for: !false # Greater-than inequalities with different epsilons -ok {test-number} - d >= Approx( 1.22 ) for: 1.23 >= Approx( 1.22 ) +ok {test-number} - d >= Approx( 1.22 ) for: 1.22999999999999998 >= Approx( 1.21999999999999997 ) # Greater-than inequalities with different epsilons -ok {test-number} - d >= Approx( 1.23 ) for: 1.23 >= Approx( 1.23 ) +ok {test-number} - d >= Approx( 1.23 ) for: 1.22999999999999998 >= Approx( 1.22999999999999998 ) # Greater-than inequalities with different epsilons -ok {test-number} - !(d >= Approx( 1.24 )) for: !(1.23 >= Approx( 1.24 )) +ok {test-number} - !(d >= Approx( 1.24 )) for: !(1.22999999999999998 >= Approx( 1.23999999999999999 )) # Greater-than inequalities with different epsilons -ok {test-number} - d >= Approx( 1.24 ).epsilon(0.1) for: 1.23 >= Approx( 1.24 ) +ok {test-number} - d >= Approx( 1.24 ).epsilon(0.1) for: 1.22999999999999998 >= Approx( 1.23999999999999999 ) # Hashers with different seed produce different hash with same test case ok {test-number} - h1( dummy ) != h2( dummy ) for: 3422778688 (0x) != 130711275 (0x) # Hashers with same seed produce same hash @@ -1843,9 +1855,9 @@ not ok {test-number} - unexpected exception with message: 'Exception translation # Inequality checks that should fail not ok {test-number} - data.int_seven != 7 for: 7 != 7 # Inequality checks that should fail -not ok {test-number} - data.float_nine_point_one != Approx( 9.1f ) for: 9.1f != Approx( 9.1000003815 ) +not ok {test-number} - data.float_nine_point_one != Approx( 9.1f ) for: 9.100000381f != Approx( 9.10000038146972656 ) # Inequality checks that should fail -not ok {test-number} - data.double_pi != Approx( 3.1415926535 ) for: 3.1415926535 != Approx( 3.1415926535 ) +not ok {test-number} - data.double_pi != Approx( 3.1415926535 ) for: 3.14159265350000005 != Approx( 3.14159265350000005 ) # Inequality checks that should fail not ok {test-number} - data.str_hello != "hello" for: "hello" != "hello" # Inequality checks that should fail @@ -1855,15 +1867,15 @@ ok {test-number} - data.int_seven != 6 for: 7 != 6 # Inequality checks that should succeed ok {test-number} - data.int_seven != 8 for: 7 != 8 # Inequality checks that should succeed -ok {test-number} - data.float_nine_point_one != Approx( 9.11f ) for: 9.1f != Approx( 9.1099996567 ) +ok {test-number} - data.float_nine_point_one != Approx( 9.11f ) for: 9.100000381f != Approx( 9.10999965667724609 ) # Inequality checks that should succeed -ok {test-number} - data.float_nine_point_one != Approx( 9.0f ) for: 9.1f != Approx( 9.0 ) +ok {test-number} - data.float_nine_point_one != Approx( 9.0f ) for: 9.100000381f != Approx( 9.0 ) # Inequality checks that should succeed -ok {test-number} - data.float_nine_point_one != Approx( 1 ) for: 9.1f != Approx( 1.0 ) +ok {test-number} - data.float_nine_point_one != Approx( 1 ) for: 9.100000381f != Approx( 1.0 ) # Inequality checks that should succeed -ok {test-number} - data.float_nine_point_one != Approx( 0 ) for: 9.1f != Approx( 0.0 ) +ok {test-number} - data.float_nine_point_one != Approx( 0 ) for: 9.100000381f != Approx( 0.0 ) # Inequality checks that should succeed -ok {test-number} - data.double_pi != Approx( 3.1415 ) for: 3.1415926535 != Approx( 3.1415 ) +ok {test-number} - data.double_pi != Approx( 3.1415 ) for: 3.14159265350000005 != Approx( 3.14150000000000018 ) # Inequality checks that should succeed ok {test-number} - data.str_hello != "goodbye" for: "hello" != "goodbye" # Inequality checks that should succeed @@ -1911,13 +1923,13 @@ ok {test-number} - sstream.str() == "\"\\\\/\\t\\r\\n\"" for: ""\\/\t\r\n"" == " # Lambdas in assertions ok {test-number} - []() { return true; }() for: true # Less-than inequalities with different epsilons -ok {test-number} - d <= Approx( 1.24 ) for: 1.23 <= Approx( 1.24 ) +ok {test-number} - d <= Approx( 1.24 ) for: 1.22999999999999998 <= Approx( 1.23999999999999999 ) # Less-than inequalities with different epsilons -ok {test-number} - d <= Approx( 1.23 ) for: 1.23 <= Approx( 1.23 ) +ok {test-number} - d <= Approx( 1.23 ) for: 1.22999999999999998 <= Approx( 1.22999999999999998 ) # Less-than inequalities with different epsilons -ok {test-number} - !(d <= Approx( 1.22 )) for: !(1.23 <= Approx( 1.22 )) +ok {test-number} - !(d <= Approx( 1.22 )) for: !(1.22999999999999998 <= Approx( 1.21999999999999997 )) # Less-than inequalities with different epsilons -ok {test-number} - d <= Approx( 1.22 ).epsilon(0.1) for: 1.23 <= Approx( 1.22 ) +ok {test-number} - d <= Approx( 1.22 ).epsilon(0.1) for: 1.22999999999999998 <= Approx( 1.21999999999999997 ) # ManuallyRegistered ok {test-number} - with 1 message: 'was called' # Matchers can be (AllOf) composed with the && operator @@ -2047,11 +2059,11 @@ not ok {test-number} - data.int_seven >= 8 for: 7 >= 8 # Ordering comparison checks that should fail not ok {test-number} - data.int_seven <= 6 for: 7 <= 6 # Ordering comparison checks that should fail -not ok {test-number} - data.float_nine_point_one < 9 for: 9.1f < 9 +not ok {test-number} - data.float_nine_point_one < 9 for: 9.100000381f < 9 # Ordering comparison checks that should fail -not ok {test-number} - data.float_nine_point_one > 10 for: 9.1f > 10 +not ok {test-number} - data.float_nine_point_one > 10 for: 9.100000381f > 10 # Ordering comparison checks that should fail -not ok {test-number} - data.float_nine_point_one > 9.2 for: 9.1f > 9.2 +not ok {test-number} - data.float_nine_point_one > 9.2 for: 9.100000381f > 9.19999999999999929 # Ordering comparison checks that should fail not ok {test-number} - data.str_hello > "hello" for: "hello" > "hello" # Ordering comparison checks that should fail @@ -2085,11 +2097,11 @@ ok {test-number} - data.int_seven <= 7 for: 7 <= 7 # Ordering comparison checks that should succeed ok {test-number} - data.int_seven <= 8 for: 7 <= 8 # Ordering comparison checks that should succeed -ok {test-number} - data.float_nine_point_one > 9 for: 9.1f > 9 +ok {test-number} - data.float_nine_point_one > 9 for: 9.100000381f > 9 # Ordering comparison checks that should succeed -ok {test-number} - data.float_nine_point_one < 10 for: 9.1f < 10 +ok {test-number} - data.float_nine_point_one < 10 for: 9.100000381f < 10 # Ordering comparison checks that should succeed -ok {test-number} - data.float_nine_point_one < 9.2 for: 9.1f < 9.2 +ok {test-number} - data.float_nine_point_one < 9.2 for: 9.100000381f < 9.19999999999999929 # Ordering comparison checks that should succeed ok {test-number} - data.str_hello <= "hello" for: "hello" <= "hello" # Ordering comparison checks that should succeed @@ -2425,7 +2437,7 @@ ok {test-number} - config.benchmarkResamples == 20000 for: 20000 (0x # Process can be configured on command line ok {test-number} - cli.parse({ "test", "--benchmark-confidence-interval=0.99" }) for: {?} # Process can be configured on command line -ok {test-number} - config.benchmarkConfidenceInterval == Catch::Approx(0.99) for: 0.99 == Approx( 0.99 ) +ok {test-number} - config.benchmarkConfidenceInterval == Catch::Approx(0.99) for: 0.98999999999999999 == Approx( 0.98999999999999999 ) # Process can be configured on command line ok {test-number} - cli.parse({ "test", "--benchmark-no-analysis" }) for: {?} # Process can be configured on command line @@ -2603,21 +2615,21 @@ ok {test-number} - v.capacity() >= 10 for: 10 >= 10 # Scenario: Vector resizing affects size and capacity ok {test-number} - v.size() == 0 for: 0 == 0 # Some simple comparisons between doubles -ok {test-number} - d == Approx( 1.23 ) for: 1.23 == Approx( 1.23 ) +ok {test-number} - d == Approx( 1.23 ) for: 1.22999999999999998 == Approx( 1.22999999999999998 ) # Some simple comparisons between doubles -ok {test-number} - d != Approx( 1.22 ) for: 1.23 != Approx( 1.22 ) +ok {test-number} - d != Approx( 1.22 ) for: 1.22999999999999998 != Approx( 1.21999999999999997 ) # Some simple comparisons between doubles -ok {test-number} - d != Approx( 1.24 ) for: 1.23 != Approx( 1.24 ) +ok {test-number} - d != Approx( 1.24 ) for: 1.22999999999999998 != Approx( 1.23999999999999999 ) # Some simple comparisons between doubles -ok {test-number} - d == 1.23_a for: 1.23 == Approx( 1.23 ) +ok {test-number} - d == 1.23_a for: 1.22999999999999998 == Approx( 1.22999999999999998 ) # Some simple comparisons between doubles -ok {test-number} - d != 1.22_a for: 1.23 != Approx( 1.22 ) +ok {test-number} - d != 1.22_a for: 1.22999999999999998 != Approx( 1.21999999999999997 ) # Some simple comparisons between doubles -ok {test-number} - Approx( d ) == 1.23 for: Approx( 1.23 ) == 1.23 +ok {test-number} - Approx( d ) == 1.23 for: Approx( 1.22999999999999998 ) == 1.22999999999999998 # Some simple comparisons between doubles -ok {test-number} - Approx( d ) != 1.22 for: Approx( 1.23 ) != 1.22 +ok {test-number} - Approx( d ) != 1.22 for: Approx( 1.22999999999999998 ) != 1.21999999999999997 # Some simple comparisons between doubles -ok {test-number} - Approx( d ) != 1.24 for: Approx( 1.23 ) != 1.24 +ok {test-number} - Approx( d ) != 1.24 for: Approx( 1.22999999999999998 ) != 1.23999999999999999 # StartsWith string matcher not ok {test-number} - testStringForMatching(), StartsWith( "This String" ) for: "this string contains 'abc' as a substring" starts with: "This String" # StartsWith string matcher @@ -2805,19 +2817,19 @@ ok {test-number} - Template_Fixture::m_a == 1 for: 1 == 1 # Template test case method with test types specified inside std::tuple - MyTypes - 2 ok {test-number} - Template_Fixture::m_a == 1 for: 1.0 == 1 # Template test case with test types specified inside non-copyable and non-movable std::tuple - NonCopyableAndNonMovableTypes - 0 -ok {test-number} - sizeof(TestType) > 0 for: 1 > 0 +ok {test-number} - std::is_default_constructible::value for: true # Template test case with test types specified inside non-copyable and non-movable std::tuple - NonCopyableAndNonMovableTypes - 1 -ok {test-number} - sizeof(TestType) > 0 for: 4 > 0 +ok {test-number} - std::is_default_constructible::value for: true # Template test case with test types specified inside non-default-constructible std::tuple - MyNonDefaultConstructibleTypes - 0 -ok {test-number} - sizeof(TestType) > 0 for: 1 > 0 +ok {test-number} - std::is_trivially_copyable::value for: true # Template test case with test types specified inside non-default-constructible std::tuple - MyNonDefaultConstructibleTypes - 1 -ok {test-number} - sizeof(TestType) > 0 for: 4 > 0 +ok {test-number} - std::is_trivially_copyable::value for: true # Template test case with test types specified inside std::tuple - MyTypes - 0 -ok {test-number} - sizeof(TestType) > 0 for: 4 > 0 +ok {test-number} - std::is_arithmetic::value for: true # Template test case with test types specified inside std::tuple - MyTypes - 1 -ok {test-number} - sizeof(TestType) > 0 for: 1 > 0 +ok {test-number} - std::is_arithmetic::value for: true # Template test case with test types specified inside std::tuple - MyTypes - 2 -ok {test-number} - sizeof(TestType) > 0 for: 4 > 0 +ok {test-number} - std::is_arithmetic::value for: true # TemplateTest: vectors can be sized and resized - float ok {test-number} - v.size() == 5 for: 5 == 5 # TemplateTest: vectors can be sized and resized - float @@ -3327,7 +3339,7 @@ ok {test-number} - vector_a, RangeEquals( array_a_plus_1, close_enough ) for: { # Type conversions of RangeEquals and similar ok {test-number} - vector_a, UnorderedRangeEquals( array_a_plus_1, close_enough ) for: { 1, 2, 3 } unordered elements are { 2, 3, 4 } # Unexpected exceptions can be translated -not ok {test-number} - unexpected exception with message: '3.14' +not ok {test-number} - unexpected exception with message: '3.14000000000000012' # Upcasting special member functions ok {test-number} - bptr->i == 3 for: 3 == 3 # Upcasting special member functions @@ -3619,21 +3631,21 @@ ok {test-number} - unrelated::ADL_size{}, SizeIs(12) for: {?} has size == 12 # Usage of the SizeIs range matcher ok {test-number} - has_size{}, SizeIs(13) for: {?} has size == 13 # Use a custom approx -ok {test-number} - d == approx( 1.23 ) for: 1.23 == Approx( 1.23 ) +ok {test-number} - d == approx( 1.23 ) for: 1.22999999999999998 == Approx( 1.22999999999999998 ) # Use a custom approx -ok {test-number} - d == approx( 1.22 ) for: 1.23 == Approx( 1.22 ) +ok {test-number} - d == approx( 1.22 ) for: 1.22999999999999998 == Approx( 1.21999999999999997 ) # Use a custom approx -ok {test-number} - d == approx( 1.24 ) for: 1.23 == Approx( 1.24 ) +ok {test-number} - d == approx( 1.24 ) for: 1.22999999999999998 == Approx( 1.23999999999999999 ) # Use a custom approx -ok {test-number} - d != approx( 1.25 ) for: 1.23 != Approx( 1.25 ) +ok {test-number} - d != approx( 1.25 ) for: 1.22999999999999998 != Approx( 1.25 ) # Use a custom approx -ok {test-number} - approx( d ) == 1.23 for: Approx( 1.23 ) == 1.23 +ok {test-number} - approx( d ) == 1.23 for: Approx( 1.22999999999999998 ) == 1.22999999999999998 # Use a custom approx -ok {test-number} - approx( d ) == 1.22 for: Approx( 1.23 ) == 1.22 +ok {test-number} - approx( d ) == 1.22 for: Approx( 1.22999999999999998 ) == 1.21999999999999997 # Use a custom approx -ok {test-number} - approx( d ) == 1.24 for: Approx( 1.23 ) == 1.24 +ok {test-number} - approx( d ) == 1.24 for: Approx( 1.22999999999999998 ) == 1.23999999999999999 # Use a custom approx -ok {test-number} - approx( d ) != 1.25 for: Approx( 1.23 ) != 1.25 +ok {test-number} - approx( d ) != 1.25 for: Approx( 1.22999999999999998 ) != 1.25 # Variadic macros ok {test-number} - with 1 message: 'no assertions' # Vector Approx matcher @@ -3959,11 +3971,11 @@ ok {test-number} - # SKIP 'skipping because answer = 43' # empty tags are not allowed ok {test-number} - Catch::TestCaseInfo("", { "test with an empty tag", "[]" }, dummySourceLineInfo) # erfc_inv -ok {test-number} - erfc_inv(1.103560) == Approx(-0.09203687623843015) for: -0.0920368762 == Approx( -0.0920368762 ) +ok {test-number} - erfc_inv(1.103560) == Approx(-0.09203687623843015) for: -0.09203687623843014 == Approx( -0.09203687623843015 ) # erfc_inv -ok {test-number} - erfc_inv(1.067400) == Approx(-0.05980291115763361) for: -0.0598029112 == Approx( -0.0598029112 ) +ok {test-number} - erfc_inv(1.067400) == Approx(-0.05980291115763361) for: -0.05980291115763361 == Approx( -0.05980291115763361 ) # erfc_inv -ok {test-number} - erfc_inv(0.050000) == Approx(1.38590382434967796) for: 1.3859038243 == Approx( 1.3859038243 ) +ok {test-number} - erfc_inv(0.050000) == Approx(1.38590382434967796) for: 1.38590382434967774 == Approx( 1.38590382434967796 ) # estimate_clock_resolution ok {test-number} - res.mean.count() == rate for: 2000.0 == 2000 (0x) # estimate_clock_resolution @@ -4104,22 +4116,12 @@ ok {test-number} - # SKIP ok {test-number} - s == "7" for: "7" == "7" # non-copyable objects ok {test-number} - ti == typeid(int) for: {?} == {?} -# normal_cdf -ok {test-number} - normal_cdf(0.000000) == Approx(0.50000000000000000) for: 0.5 == Approx( 0.5 ) -# normal_cdf -ok {test-number} - normal_cdf(1.000000) == Approx(0.84134474606854293) for: 0.8413447461 == Approx( 0.8413447461 ) -# normal_cdf -ok {test-number} - normal_cdf(-1.000000) == Approx(0.15865525393145705) for: 0.1586552539 == Approx( 0.1586552539 ) -# normal_cdf -ok {test-number} - normal_cdf(2.809729) == Approx(0.99752083845315409) for: 0.9975208385 == Approx( 0.9975208385 ) -# normal_cdf -ok {test-number} - normal_cdf(-1.352570) == Approx(0.08809652095066035) for: 0.088096521 == Approx( 0.088096521 ) # normal_quantile -ok {test-number} - normal_quantile(0.551780) == Approx(0.13015979861484198) for: 0.1301597986 == Approx( 0.1301597986 ) +ok {test-number} - normal_quantile(0.551780) == Approx(0.13015979861484198) for: 0.13015979861484195 == Approx( 0.13015979861484198 ) # normal_quantile -ok {test-number} - normal_quantile(0.533700) == Approx(0.08457408802851875) for: 0.084574088 == Approx( 0.084574088 ) +ok {test-number} - normal_quantile(0.533700) == Approx(0.08457408802851875) for: 0.08457408802851875 == Approx( 0.08457408802851875 ) # normal_quantile -ok {test-number} - normal_quantile(0.025000) == Approx(-1.95996398454005449) for: -1.9599639845 == Approx( -1.9599639845 ) +ok {test-number} - normal_quantile(0.025000) == Approx(-1.95996398454005449) for: -1.95996398454005405 == Approx( -1.95996398454005449 ) # not allowed ok {test-number} - # not prints unscoped info from previous failures @@ -4195,6 +4197,14 @@ ok {test-number} - !(Catch::replaceInPlace(letters, "x", "z")) for: !false # replaceInPlace ok {test-number} - letters == letters for: "abcdefcg" == "abcdefcg" # replaceInPlace +ok {test-number} - Catch::replaceInPlace(letters, "c", "cc") for: true +# replaceInPlace +ok {test-number} - letters == "abccdefccg" for: "abccdefccg" == "abccdefccg" +# replaceInPlace +ok {test-number} - Catch::replaceInPlace(s, "--", "-") for: true +# replaceInPlace +ok {test-number} - s == "--" for: "--" == "--" +# replaceInPlace ok {test-number} - Catch::replaceInPlace(s, "'", "|'") for: true # replaceInPlace ok {test-number} - s == "didn|'t" for: "didn|'t" == "didn|'t" @@ -4395,15 +4405,15 @@ ok {test-number} - "{ }" == ::Catch::Detail::stringify(type{}) for: "{ }" == "{ # tuple<> ok {test-number} - "{ }" == ::Catch::Detail::stringify(value) for: "{ }" == "{ }" # tuple -ok {test-number} - "1.2f" == ::Catch::Detail::stringify(float(1.2)) for: "1.2f" == "1.2f" +ok {test-number} - "1.5f" == ::Catch::Detail::stringify(float(1.5)) for: "1.5f" == "1.5f" # tuple -ok {test-number} - "{ 1.2f, 0 }" == ::Catch::Detail::stringify(type{1.2f,0}) for: "{ 1.2f, 0 }" == "{ 1.2f, 0 }" +ok {test-number} - "{ 1.5f, 0 }" == ::Catch::Detail::stringify(type{1.5f,0}) for: "{ 1.5f, 0 }" == "{ 1.5f, 0 }" # tuple ok {test-number} - "{ 0 }" == ::Catch::Detail::stringify(type{0}) for: "{ 0 }" == "{ 0 }" # tuple ok {test-number} - "{ \"hello\", \"world\" }" == ::Catch::Detail::stringify(type{"hello","world"}) for: "{ "hello", "world" }" == "{ "hello", "world" }" # tuple,tuple<>,float> -ok {test-number} - "{ { 42 }, { }, 1.2f }" == ::Catch::Detail::stringify(value) for: "{ { 42 }, { }, 1.2f }" == "{ { 42 }, { }, 1.2f }" +ok {test-number} - "{ { 42 }, { }, 1.5f }" == ::Catch::Detail::stringify(value) for: "{ { 42 }, { }, 1.5f }" == "{ { 42 }, { }, 1.5f }" # uniform samples ok {test-number} - e.point == 23 for: 23.0 == 23 # uniform samples @@ -4411,7 +4421,7 @@ ok {test-number} - e.upper_bound == 23 for: 23.0 == 23 # uniform samples ok {test-number} - e.lower_bound == 23 for: 23.0 == 23 # uniform samples -ok {test-number} - e.confidence_interval == 0.95 for: 0.95 == 0.95 +ok {test-number} - e.confidence_interval == 0.95 for: 0.94999999999999996 == 0.94999999999999996 # uniform_integer_distribution can return the bounds ok {test-number} - dist.a() == -10 for: -10 == -10 # uniform_integer_distribution can return the bounds @@ -4538,5 +4548,5 @@ ok {test-number} - q3 == 23. for: 23.0 == 23.0 ok {test-number} - # xmlentitycheck ok {test-number} - -1..2272 +1..2277 diff --git a/tests/SelfTest/Baselines/teamcity.sw.approved.txt b/tests/SelfTest/Baselines/teamcity.sw.approved.txt index 2a2c40cfc8..9a59fa6de6 100644 --- a/tests/SelfTest/Baselines/teamcity.sw.approved.txt +++ b/tests/SelfTest/Baselines/teamcity.sw.approved.txt @@ -166,6 +166,11 @@ ##teamcity[testFinished name='A TEST_CASE_METHOD based test run that fails' duration="{duration}"] ##teamcity[testStarted name='A TEST_CASE_METHOD based test run that succeeds'] ##teamcity[testFinished name='A TEST_CASE_METHOD based test run that succeeds' duration="{duration}"] +##teamcity[testStarted name='A TEST_CASE_PERSISTENT_FIXTURE based test run that fails'] +##teamcity[testFailed name='A TEST_CASE_PERSISTENT_FIXTURE based test run that fails' message='-------------------------------------------------------------------------------|nSecond partial run|n-------------------------------------------------------------------------------|nClass.tests.cpp:|n...............................................................................|n|nClass.tests.cpp:|nexpression failed|n REQUIRE( m_a == 0 )|nwith expansion:|n 1 == 0|n'] +##teamcity[testFinished name='A TEST_CASE_PERSISTENT_FIXTURE based test run that fails' duration="{duration}"] +##teamcity[testStarted name='A TEST_CASE_PERSISTENT_FIXTURE based test run that succeeds'] +##teamcity[testFinished name='A TEST_CASE_PERSISTENT_FIXTURE based test run that succeeds' duration="{duration}"] ##teamcity[testStarted name='A Template product test case - Foo'] ##teamcity[testFinished name='A Template product test case - Foo' duration="{duration}"] ##teamcity[testStarted name='A Template product test case - Foo'] @@ -240,6 +245,8 @@ ##teamcity[testFinished name='CaseInsensitiveLess is case insensitive' duration="{duration}"] ##teamcity[testStarted name='Character pretty printing'] ##teamcity[testFinished name='Character pretty printing' duration="{duration}"] +##teamcity[testStarted name='Clara::Arg does not crash on incomplete input'] +##teamcity[testFinished name='Clara::Arg does not crash on incomplete input' duration="{duration}"] ##teamcity[testStarted name='Clara::Arg supports single-arg parse the way Opt does'] ##teamcity[testFinished name='Clara::Arg supports single-arg parse the way Opt does' duration="{duration}"] ##teamcity[testStarted name='Clara::Opt supports accept-many lambdas'] @@ -318,16 +325,16 @@ ##teamcity[testIgnored name='Equality checks that should fail' message='Condition.tests.cpp:|n...............................................................................|n|nCondition.tests.cpp:|nexpression failed|n CHECK( data.int_seven == 6 )|nwith expansion:|n 7 == 6|n- failure ignore as test marked as |'ok to fail|'|n'] ##teamcity[testIgnored name='Equality checks that should fail' message='Condition.tests.cpp:|nexpression failed|n CHECK( data.int_seven == 8 )|nwith expansion:|n 7 == 8|n- failure ignore as test marked as |'ok to fail|'|n'] ##teamcity[testIgnored name='Equality checks that should fail' message='Condition.tests.cpp:|nexpression failed|n CHECK( data.int_seven == 0 )|nwith expansion:|n 7 == 0|n- failure ignore as test marked as |'ok to fail|'|n'] -##teamcity[testIgnored name='Equality checks that should fail' message='Condition.tests.cpp:|nexpression failed|n CHECK( data.float_nine_point_one == Approx( 9.11f ) )|nwith expansion:|n 9.1f == Approx( 9.1099996567 )|n- failure ignore as test marked as |'ok to fail|'|n'] -##teamcity[testIgnored name='Equality checks that should fail' message='Condition.tests.cpp:|nexpression failed|n CHECK( data.float_nine_point_one == Approx( 9.0f ) )|nwith expansion:|n 9.1f == Approx( 9.0 )|n- failure ignore as test marked as |'ok to fail|'|n'] -##teamcity[testIgnored name='Equality checks that should fail' message='Condition.tests.cpp:|nexpression failed|n CHECK( data.float_nine_point_one == Approx( 1 ) )|nwith expansion:|n 9.1f == Approx( 1.0 )|n- failure ignore as test marked as |'ok to fail|'|n'] -##teamcity[testIgnored name='Equality checks that should fail' message='Condition.tests.cpp:|nexpression failed|n CHECK( data.float_nine_point_one == Approx( 0 ) )|nwith expansion:|n 9.1f == Approx( 0.0 )|n- failure ignore as test marked as |'ok to fail|'|n'] -##teamcity[testIgnored name='Equality checks that should fail' message='Condition.tests.cpp:|nexpression failed|n CHECK( data.double_pi == Approx( 3.1415 ) )|nwith expansion:|n 3.1415926535 == Approx( 3.1415 )|n- failure ignore as test marked as |'ok to fail|'|n'] +##teamcity[testIgnored name='Equality checks that should fail' message='Condition.tests.cpp:|nexpression failed|n CHECK( data.float_nine_point_one == Approx( 9.11f ) )|nwith expansion:|n 9.100000381f|n==|nApprox( 9.10999965667724609 )|n- failure ignore as test marked as |'ok to fail|'|n'] +##teamcity[testIgnored name='Equality checks that should fail' message='Condition.tests.cpp:|nexpression failed|n CHECK( data.float_nine_point_one == Approx( 9.0f ) )|nwith expansion:|n 9.100000381f == Approx( 9.0 )|n- failure ignore as test marked as |'ok to fail|'|n'] +##teamcity[testIgnored name='Equality checks that should fail' message='Condition.tests.cpp:|nexpression failed|n CHECK( data.float_nine_point_one == Approx( 1 ) )|nwith expansion:|n 9.100000381f == Approx( 1.0 )|n- failure ignore as test marked as |'ok to fail|'|n'] +##teamcity[testIgnored name='Equality checks that should fail' message='Condition.tests.cpp:|nexpression failed|n CHECK( data.float_nine_point_one == Approx( 0 ) )|nwith expansion:|n 9.100000381f == Approx( 0.0 )|n- failure ignore as test marked as |'ok to fail|'|n'] +##teamcity[testIgnored name='Equality checks that should fail' message='Condition.tests.cpp:|nexpression failed|n CHECK( data.double_pi == Approx( 3.1415 ) )|nwith expansion:|n 3.14159265350000005|n==|nApprox( 3.14150000000000018 )|n- failure ignore as test marked as |'ok to fail|'|n'] ##teamcity[testIgnored name='Equality checks that should fail' message='Condition.tests.cpp:|nexpression failed|n CHECK( data.str_hello == "goodbye" )|nwith expansion:|n "hello" == "goodbye"|n- failure ignore as test marked as |'ok to fail|'|n'] ##teamcity[testIgnored name='Equality checks that should fail' message='Condition.tests.cpp:|nexpression failed|n CHECK( data.str_hello == "hell" )|nwith expansion:|n "hello" == "hell"|n- failure ignore as test marked as |'ok to fail|'|n'] ##teamcity[testIgnored name='Equality checks that should fail' message='Condition.tests.cpp:|nexpression failed|n CHECK( data.str_hello == "hello1" )|nwith expansion:|n "hello" == "hello1"|n- failure ignore as test marked as |'ok to fail|'|n'] ##teamcity[testIgnored name='Equality checks that should fail' message='Condition.tests.cpp:|nexpression failed|n CHECK( data.str_hello.size() == 6 )|nwith expansion:|n 5 == 6|n- failure ignore as test marked as |'ok to fail|'|n'] -##teamcity[testIgnored name='Equality checks that should fail' message='Condition.tests.cpp:|nexpression failed|n CHECK( x == Approx( 1.301 ) )|nwith expansion:|n 1.3 == Approx( 1.301 )|n- failure ignore as test marked as |'ok to fail|'|n'] +##teamcity[testIgnored name='Equality checks that should fail' message='Condition.tests.cpp:|nexpression failed|n CHECK( x == Approx( 1.301 ) )|nwith expansion:|n 1.30000000000000027|n==|nApprox( 1.30099999999999993 )|n- failure ignore as test marked as |'ok to fail|'|n'] ##teamcity[testFinished name='Equality checks that should fail' duration="{duration}"] ##teamcity[testStarted name='Equality checks that should succeed'] ##teamcity[testFinished name='Equality checks that should succeed' duration="{duration}"] @@ -415,8 +422,8 @@ ##teamcity[testFinished name='Incomplete AssertionHandler' duration="{duration}"] ##teamcity[testStarted name='Inequality checks that should fail'] ##teamcity[testIgnored name='Inequality checks that should fail' message='Condition.tests.cpp:|n...............................................................................|n|nCondition.tests.cpp:|nexpression failed|n CHECK( data.int_seven != 7 )|nwith expansion:|n 7 != 7|n- failure ignore as test marked as |'ok to fail|'|n'] -##teamcity[testIgnored name='Inequality checks that should fail' message='Condition.tests.cpp:|nexpression failed|n CHECK( data.float_nine_point_one != Approx( 9.1f ) )|nwith expansion:|n 9.1f != Approx( 9.1000003815 )|n- failure ignore as test marked as |'ok to fail|'|n'] -##teamcity[testIgnored name='Inequality checks that should fail' message='Condition.tests.cpp:|nexpression failed|n CHECK( data.double_pi != Approx( 3.1415926535 ) )|nwith expansion:|n 3.1415926535 != Approx( 3.1415926535 )|n- failure ignore as test marked as |'ok to fail|'|n'] +##teamcity[testIgnored name='Inequality checks that should fail' message='Condition.tests.cpp:|nexpression failed|n CHECK( data.float_nine_point_one != Approx( 9.1f ) )|nwith expansion:|n 9.100000381f|n!=|nApprox( 9.10000038146972656 )|n- failure ignore as test marked as |'ok to fail|'|n'] +##teamcity[testIgnored name='Inequality checks that should fail' message='Condition.tests.cpp:|nexpression failed|n CHECK( data.double_pi != Approx( 3.1415926535 ) )|nwith expansion:|n 3.14159265350000005|n!=|nApprox( 3.14159265350000005 )|n- failure ignore as test marked as |'ok to fail|'|n'] ##teamcity[testIgnored name='Inequality checks that should fail' message='Condition.tests.cpp:|nexpression failed|n CHECK( data.str_hello != "hello" )|nwith expansion:|n "hello" != "hello"|n- failure ignore as test marked as |'ok to fail|'|n'] ##teamcity[testIgnored name='Inequality checks that should fail' message='Condition.tests.cpp:|nexpression failed|n CHECK( data.str_hello.size() != 5 )|nwith expansion:|n 5 != 5|n- failure ignore as test marked as |'ok to fail|'|n'] ##teamcity[testFinished name='Inequality checks that should fail' duration="{duration}"] @@ -479,9 +486,9 @@ ##teamcity[testFailed name='Ordering comparison checks that should fail' message='Condition.tests.cpp:|nexpression failed|n CHECK( data.int_seven < -1 )|nwith expansion:|n 7 < -1|n'] ##teamcity[testFailed name='Ordering comparison checks that should fail' message='Condition.tests.cpp:|nexpression failed|n CHECK( data.int_seven >= 8 )|nwith expansion:|n 7 >= 8|n'] ##teamcity[testFailed name='Ordering comparison checks that should fail' message='Condition.tests.cpp:|nexpression failed|n CHECK( data.int_seven <= 6 )|nwith expansion:|n 7 <= 6|n'] -##teamcity[testFailed name='Ordering comparison checks that should fail' message='Condition.tests.cpp:|nexpression failed|n CHECK( data.float_nine_point_one < 9 )|nwith expansion:|n 9.1f < 9|n'] -##teamcity[testFailed name='Ordering comparison checks that should fail' message='Condition.tests.cpp:|nexpression failed|n CHECK( data.float_nine_point_one > 10 )|nwith expansion:|n 9.1f > 10|n'] -##teamcity[testFailed name='Ordering comparison checks that should fail' message='Condition.tests.cpp:|nexpression failed|n CHECK( data.float_nine_point_one > 9.2 )|nwith expansion:|n 9.1f > 9.2|n'] +##teamcity[testFailed name='Ordering comparison checks that should fail' message='Condition.tests.cpp:|nexpression failed|n CHECK( data.float_nine_point_one < 9 )|nwith expansion:|n 9.100000381f < 9|n'] +##teamcity[testFailed name='Ordering comparison checks that should fail' message='Condition.tests.cpp:|nexpression failed|n CHECK( data.float_nine_point_one > 10 )|nwith expansion:|n 9.100000381f > 10|n'] +##teamcity[testFailed name='Ordering comparison checks that should fail' message='Condition.tests.cpp:|nexpression failed|n CHECK( data.float_nine_point_one > 9.2 )|nwith expansion:|n 9.100000381f > 9.19999999999999929|n'] ##teamcity[testFailed name='Ordering comparison checks that should fail' message='Condition.tests.cpp:|nexpression failed|n CHECK( data.str_hello > "hello" )|nwith expansion:|n "hello" > "hello"|n'] ##teamcity[testFailed name='Ordering comparison checks that should fail' message='Condition.tests.cpp:|nexpression failed|n CHECK( data.str_hello < "hello" )|nwith expansion:|n "hello" < "hello"|n'] ##teamcity[testFailed name='Ordering comparison checks that should fail' message='Condition.tests.cpp:|nexpression failed|n CHECK( data.str_hello > "hellp" )|nwith expansion:|n "hello" > "hellp"|n'] @@ -673,7 +680,7 @@ ##teamcity[testStarted name='Type conversions of RangeEquals and similar'] ##teamcity[testFinished name='Type conversions of RangeEquals and similar' duration="{duration}"] ##teamcity[testStarted name='Unexpected exceptions can be translated'] -##teamcity[testFailed name='Unexpected exceptions can be translated' message='Exception.tests.cpp:|n...............................................................................|n|nException.tests.cpp:|nunexpected exception with message:|n "3.14"'] +##teamcity[testFailed name='Unexpected exceptions can be translated' message='Exception.tests.cpp:|n...............................................................................|n|nException.tests.cpp:|nunexpected exception with message:|n "3.14000000000000012"'] ##teamcity[testFinished name='Unexpected exceptions can be translated' duration="{duration}"] ##teamcity[testStarted name='Upcasting special member functions'] ##teamcity[testFinished name='Upcasting special member functions' duration="{duration}"] @@ -861,8 +868,6 @@ loose text artifact ##teamcity[testFinished name='non streamable - with conv. op' duration="{duration}"] ##teamcity[testStarted name='non-copyable objects'] ##teamcity[testFinished name='non-copyable objects' duration="{duration}"] -##teamcity[testStarted name='normal_cdf'] -##teamcity[testFinished name='normal_cdf' duration="{duration}"] ##teamcity[testStarted name='normal_quantile'] ##teamcity[testFinished name='normal_quantile' duration="{duration}"] ##teamcity[testStarted name='not allowed'] diff --git a/tests/SelfTest/Baselines/teamcity.sw.multi.approved.txt b/tests/SelfTest/Baselines/teamcity.sw.multi.approved.txt index 24ed5d9887..989a37fe53 100644 --- a/tests/SelfTest/Baselines/teamcity.sw.multi.approved.txt +++ b/tests/SelfTest/Baselines/teamcity.sw.multi.approved.txt @@ -166,6 +166,11 @@ ##teamcity[testFinished name='A TEST_CASE_METHOD based test run that fails' duration="{duration}"] ##teamcity[testStarted name='A TEST_CASE_METHOD based test run that succeeds'] ##teamcity[testFinished name='A TEST_CASE_METHOD based test run that succeeds' duration="{duration}"] +##teamcity[testStarted name='A TEST_CASE_PERSISTENT_FIXTURE based test run that fails'] +##teamcity[testFailed name='A TEST_CASE_PERSISTENT_FIXTURE based test run that fails' message='-------------------------------------------------------------------------------|nSecond partial run|n-------------------------------------------------------------------------------|nClass.tests.cpp:|n...............................................................................|n|nClass.tests.cpp:|nexpression failed|n REQUIRE( m_a == 0 )|nwith expansion:|n 1 == 0|n'] +##teamcity[testFinished name='A TEST_CASE_PERSISTENT_FIXTURE based test run that fails' duration="{duration}"] +##teamcity[testStarted name='A TEST_CASE_PERSISTENT_FIXTURE based test run that succeeds'] +##teamcity[testFinished name='A TEST_CASE_PERSISTENT_FIXTURE based test run that succeeds' duration="{duration}"] ##teamcity[testStarted name='A Template product test case - Foo'] ##teamcity[testFinished name='A Template product test case - Foo' duration="{duration}"] ##teamcity[testStarted name='A Template product test case - Foo'] @@ -240,6 +245,8 @@ ##teamcity[testFinished name='CaseInsensitiveLess is case insensitive' duration="{duration}"] ##teamcity[testStarted name='Character pretty printing'] ##teamcity[testFinished name='Character pretty printing' duration="{duration}"] +##teamcity[testStarted name='Clara::Arg does not crash on incomplete input'] +##teamcity[testFinished name='Clara::Arg does not crash on incomplete input' duration="{duration}"] ##teamcity[testStarted name='Clara::Arg supports single-arg parse the way Opt does'] ##teamcity[testFinished name='Clara::Arg supports single-arg parse the way Opt does' duration="{duration}"] ##teamcity[testStarted name='Clara::Opt supports accept-many lambdas'] @@ -318,16 +325,16 @@ ##teamcity[testIgnored name='Equality checks that should fail' message='Condition.tests.cpp:|n...............................................................................|n|nCondition.tests.cpp:|nexpression failed|n CHECK( data.int_seven == 6 )|nwith expansion:|n 7 == 6|n- failure ignore as test marked as |'ok to fail|'|n'] ##teamcity[testIgnored name='Equality checks that should fail' message='Condition.tests.cpp:|nexpression failed|n CHECK( data.int_seven == 8 )|nwith expansion:|n 7 == 8|n- failure ignore as test marked as |'ok to fail|'|n'] ##teamcity[testIgnored name='Equality checks that should fail' message='Condition.tests.cpp:|nexpression failed|n CHECK( data.int_seven == 0 )|nwith expansion:|n 7 == 0|n- failure ignore as test marked as |'ok to fail|'|n'] -##teamcity[testIgnored name='Equality checks that should fail' message='Condition.tests.cpp:|nexpression failed|n CHECK( data.float_nine_point_one == Approx( 9.11f ) )|nwith expansion:|n 9.1f == Approx( 9.1099996567 )|n- failure ignore as test marked as |'ok to fail|'|n'] -##teamcity[testIgnored name='Equality checks that should fail' message='Condition.tests.cpp:|nexpression failed|n CHECK( data.float_nine_point_one == Approx( 9.0f ) )|nwith expansion:|n 9.1f == Approx( 9.0 )|n- failure ignore as test marked as |'ok to fail|'|n'] -##teamcity[testIgnored name='Equality checks that should fail' message='Condition.tests.cpp:|nexpression failed|n CHECK( data.float_nine_point_one == Approx( 1 ) )|nwith expansion:|n 9.1f == Approx( 1.0 )|n- failure ignore as test marked as |'ok to fail|'|n'] -##teamcity[testIgnored name='Equality checks that should fail' message='Condition.tests.cpp:|nexpression failed|n CHECK( data.float_nine_point_one == Approx( 0 ) )|nwith expansion:|n 9.1f == Approx( 0.0 )|n- failure ignore as test marked as |'ok to fail|'|n'] -##teamcity[testIgnored name='Equality checks that should fail' message='Condition.tests.cpp:|nexpression failed|n CHECK( data.double_pi == Approx( 3.1415 ) )|nwith expansion:|n 3.1415926535 == Approx( 3.1415 )|n- failure ignore as test marked as |'ok to fail|'|n'] +##teamcity[testIgnored name='Equality checks that should fail' message='Condition.tests.cpp:|nexpression failed|n CHECK( data.float_nine_point_one == Approx( 9.11f ) )|nwith expansion:|n 9.100000381f|n==|nApprox( 9.10999965667724609 )|n- failure ignore as test marked as |'ok to fail|'|n'] +##teamcity[testIgnored name='Equality checks that should fail' message='Condition.tests.cpp:|nexpression failed|n CHECK( data.float_nine_point_one == Approx( 9.0f ) )|nwith expansion:|n 9.100000381f == Approx( 9.0 )|n- failure ignore as test marked as |'ok to fail|'|n'] +##teamcity[testIgnored name='Equality checks that should fail' message='Condition.tests.cpp:|nexpression failed|n CHECK( data.float_nine_point_one == Approx( 1 ) )|nwith expansion:|n 9.100000381f == Approx( 1.0 )|n- failure ignore as test marked as |'ok to fail|'|n'] +##teamcity[testIgnored name='Equality checks that should fail' message='Condition.tests.cpp:|nexpression failed|n CHECK( data.float_nine_point_one == Approx( 0 ) )|nwith expansion:|n 9.100000381f == Approx( 0.0 )|n- failure ignore as test marked as |'ok to fail|'|n'] +##teamcity[testIgnored name='Equality checks that should fail' message='Condition.tests.cpp:|nexpression failed|n CHECK( data.double_pi == Approx( 3.1415 ) )|nwith expansion:|n 3.14159265350000005|n==|nApprox( 3.14150000000000018 )|n- failure ignore as test marked as |'ok to fail|'|n'] ##teamcity[testIgnored name='Equality checks that should fail' message='Condition.tests.cpp:|nexpression failed|n CHECK( data.str_hello == "goodbye" )|nwith expansion:|n "hello" == "goodbye"|n- failure ignore as test marked as |'ok to fail|'|n'] ##teamcity[testIgnored name='Equality checks that should fail' message='Condition.tests.cpp:|nexpression failed|n CHECK( data.str_hello == "hell" )|nwith expansion:|n "hello" == "hell"|n- failure ignore as test marked as |'ok to fail|'|n'] ##teamcity[testIgnored name='Equality checks that should fail' message='Condition.tests.cpp:|nexpression failed|n CHECK( data.str_hello == "hello1" )|nwith expansion:|n "hello" == "hello1"|n- failure ignore as test marked as |'ok to fail|'|n'] ##teamcity[testIgnored name='Equality checks that should fail' message='Condition.tests.cpp:|nexpression failed|n CHECK( data.str_hello.size() == 6 )|nwith expansion:|n 5 == 6|n- failure ignore as test marked as |'ok to fail|'|n'] -##teamcity[testIgnored name='Equality checks that should fail' message='Condition.tests.cpp:|nexpression failed|n CHECK( x == Approx( 1.301 ) )|nwith expansion:|n 1.3 == Approx( 1.301 )|n- failure ignore as test marked as |'ok to fail|'|n'] +##teamcity[testIgnored name='Equality checks that should fail' message='Condition.tests.cpp:|nexpression failed|n CHECK( x == Approx( 1.301 ) )|nwith expansion:|n 1.30000000000000027|n==|nApprox( 1.30099999999999993 )|n- failure ignore as test marked as |'ok to fail|'|n'] ##teamcity[testFinished name='Equality checks that should fail' duration="{duration}"] ##teamcity[testStarted name='Equality checks that should succeed'] ##teamcity[testFinished name='Equality checks that should succeed' duration="{duration}"] @@ -415,8 +422,8 @@ ##teamcity[testFinished name='Incomplete AssertionHandler' duration="{duration}"] ##teamcity[testStarted name='Inequality checks that should fail'] ##teamcity[testIgnored name='Inequality checks that should fail' message='Condition.tests.cpp:|n...............................................................................|n|nCondition.tests.cpp:|nexpression failed|n CHECK( data.int_seven != 7 )|nwith expansion:|n 7 != 7|n- failure ignore as test marked as |'ok to fail|'|n'] -##teamcity[testIgnored name='Inequality checks that should fail' message='Condition.tests.cpp:|nexpression failed|n CHECK( data.float_nine_point_one != Approx( 9.1f ) )|nwith expansion:|n 9.1f != Approx( 9.1000003815 )|n- failure ignore as test marked as |'ok to fail|'|n'] -##teamcity[testIgnored name='Inequality checks that should fail' message='Condition.tests.cpp:|nexpression failed|n CHECK( data.double_pi != Approx( 3.1415926535 ) )|nwith expansion:|n 3.1415926535 != Approx( 3.1415926535 )|n- failure ignore as test marked as |'ok to fail|'|n'] +##teamcity[testIgnored name='Inequality checks that should fail' message='Condition.tests.cpp:|nexpression failed|n CHECK( data.float_nine_point_one != Approx( 9.1f ) )|nwith expansion:|n 9.100000381f|n!=|nApprox( 9.10000038146972656 )|n- failure ignore as test marked as |'ok to fail|'|n'] +##teamcity[testIgnored name='Inequality checks that should fail' message='Condition.tests.cpp:|nexpression failed|n CHECK( data.double_pi != Approx( 3.1415926535 ) )|nwith expansion:|n 3.14159265350000005|n!=|nApprox( 3.14159265350000005 )|n- failure ignore as test marked as |'ok to fail|'|n'] ##teamcity[testIgnored name='Inequality checks that should fail' message='Condition.tests.cpp:|nexpression failed|n CHECK( data.str_hello != "hello" )|nwith expansion:|n "hello" != "hello"|n- failure ignore as test marked as |'ok to fail|'|n'] ##teamcity[testIgnored name='Inequality checks that should fail' message='Condition.tests.cpp:|nexpression failed|n CHECK( data.str_hello.size() != 5 )|nwith expansion:|n 5 != 5|n- failure ignore as test marked as |'ok to fail|'|n'] ##teamcity[testFinished name='Inequality checks that should fail' duration="{duration}"] @@ -479,9 +486,9 @@ ##teamcity[testFailed name='Ordering comparison checks that should fail' message='Condition.tests.cpp:|nexpression failed|n CHECK( data.int_seven < -1 )|nwith expansion:|n 7 < -1|n'] ##teamcity[testFailed name='Ordering comparison checks that should fail' message='Condition.tests.cpp:|nexpression failed|n CHECK( data.int_seven >= 8 )|nwith expansion:|n 7 >= 8|n'] ##teamcity[testFailed name='Ordering comparison checks that should fail' message='Condition.tests.cpp:|nexpression failed|n CHECK( data.int_seven <= 6 )|nwith expansion:|n 7 <= 6|n'] -##teamcity[testFailed name='Ordering comparison checks that should fail' message='Condition.tests.cpp:|nexpression failed|n CHECK( data.float_nine_point_one < 9 )|nwith expansion:|n 9.1f < 9|n'] -##teamcity[testFailed name='Ordering comparison checks that should fail' message='Condition.tests.cpp:|nexpression failed|n CHECK( data.float_nine_point_one > 10 )|nwith expansion:|n 9.1f > 10|n'] -##teamcity[testFailed name='Ordering comparison checks that should fail' message='Condition.tests.cpp:|nexpression failed|n CHECK( data.float_nine_point_one > 9.2 )|nwith expansion:|n 9.1f > 9.2|n'] +##teamcity[testFailed name='Ordering comparison checks that should fail' message='Condition.tests.cpp:|nexpression failed|n CHECK( data.float_nine_point_one < 9 )|nwith expansion:|n 9.100000381f < 9|n'] +##teamcity[testFailed name='Ordering comparison checks that should fail' message='Condition.tests.cpp:|nexpression failed|n CHECK( data.float_nine_point_one > 10 )|nwith expansion:|n 9.100000381f > 10|n'] +##teamcity[testFailed name='Ordering comparison checks that should fail' message='Condition.tests.cpp:|nexpression failed|n CHECK( data.float_nine_point_one > 9.2 )|nwith expansion:|n 9.100000381f > 9.19999999999999929|n'] ##teamcity[testFailed name='Ordering comparison checks that should fail' message='Condition.tests.cpp:|nexpression failed|n CHECK( data.str_hello > "hello" )|nwith expansion:|n "hello" > "hello"|n'] ##teamcity[testFailed name='Ordering comparison checks that should fail' message='Condition.tests.cpp:|nexpression failed|n CHECK( data.str_hello < "hello" )|nwith expansion:|n "hello" < "hello"|n'] ##teamcity[testFailed name='Ordering comparison checks that should fail' message='Condition.tests.cpp:|nexpression failed|n CHECK( data.str_hello > "hellp" )|nwith expansion:|n "hello" > "hellp"|n'] @@ -673,7 +680,7 @@ ##teamcity[testStarted name='Type conversions of RangeEquals and similar'] ##teamcity[testFinished name='Type conversions of RangeEquals and similar' duration="{duration}"] ##teamcity[testStarted name='Unexpected exceptions can be translated'] -##teamcity[testFailed name='Unexpected exceptions can be translated' message='Exception.tests.cpp:|n...............................................................................|n|nException.tests.cpp:|nunexpected exception with message:|n "3.14"'] +##teamcity[testFailed name='Unexpected exceptions can be translated' message='Exception.tests.cpp:|n...............................................................................|n|nException.tests.cpp:|nunexpected exception with message:|n "3.14000000000000012"'] ##teamcity[testFinished name='Unexpected exceptions can be translated' duration="{duration}"] ##teamcity[testStarted name='Upcasting special member functions'] ##teamcity[testFinished name='Upcasting special member functions' duration="{duration}"] @@ -860,8 +867,6 @@ ##teamcity[testFinished name='non streamable - with conv. op' duration="{duration}"] ##teamcity[testStarted name='non-copyable objects'] ##teamcity[testFinished name='non-copyable objects' duration="{duration}"] -##teamcity[testStarted name='normal_cdf'] -##teamcity[testFinished name='normal_cdf' duration="{duration}"] ##teamcity[testStarted name='normal_quantile'] ##teamcity[testFinished name='normal_quantile' duration="{duration}"] ##teamcity[testStarted name='not allowed'] diff --git a/tests/SelfTest/Baselines/xml.sw.approved.txt b/tests/SelfTest/Baselines/xml.sw.approved.txt index be57798bf7..c64c5a7bf9 100644 --- a/tests/SelfTest/Baselines/xml.sw.approved.txt +++ b/tests/SelfTest/Baselines/xml.sw.approved.txt @@ -2056,6 +2056,56 @@ Nor would this + +
+ + + m_a++ == 0 + + + 0 == 0 + + + +
+
+ + + m_a == 0 + + + 1 == 0 + + + +
+ +
+ +
+ + + m_a++ == 0 + + + 0 == 0 + + + +
+
+ + + m_a == 1 + + + 1 == 1 + + + +
+ +
@@ -2150,7 +2200,9 @@ Nor would this d == 1.23_a - 1.23 == Approx( 1.23 ) + 1.22999999999999998 +== +Approx( 1.22999999999999998 ) @@ -2158,7 +2210,9 @@ Nor would this d != 1.22_a - 1.23 != Approx( 1.22 ) + 1.22999999999999998 +!= +Approx( 1.21999999999999997 ) @@ -2166,7 +2220,9 @@ Nor would this -d == -1.23_a - -1.23 == Approx( -1.23 ) + -1.22999999999999998 +== +Approx( -1.22999999999999998 ) @@ -2174,7 +2230,9 @@ Nor would this d == 1.2_a .epsilon(.1) - 1.23 == Approx( 1.2 ) + 1.22999999999999998 +== +Approx( 1.19999999999999996 ) @@ -2182,7 +2240,9 @@ Nor would this d != 1.2_a .epsilon(.001) - 1.23 != Approx( 1.2 ) + 1.22999999999999998 +!= +Approx( 1.19999999999999996 ) @@ -2190,7 +2250,7 @@ Nor would this d == 1_a .epsilon(.3) - 1.23 == Approx( 1.0 ) + 1.22999999999999998 == Approx( 1.0 ) @@ -2264,7 +2324,7 @@ Nor would this 100.3 != Approx(100.0) - 100.3 != Approx( 100.0 ) + 100.29999999999999716 != Approx( 100.0 ) @@ -2272,7 +2332,7 @@ Nor would this 100.3 == Approx(100.0).margin(0.5) - 100.3 == Approx( 100.0 ) + 100.29999999999999716 == Approx( 100.0 ) @@ -2432,7 +2492,9 @@ Nor would this divide( 22, 7 ) == Approx( 3.141 ).epsilon( 0.001 ) - 3.1428571429 == Approx( 3.141 ) + 3.14285714285714279 +== +Approx( 3.14100000000000001 ) @@ -2440,7 +2502,9 @@ Nor would this divide( 22, 7 ) != Approx( 3.141 ).epsilon( 0.0001 ) - 3.1428571429 != Approx( 3.141 ) + 3.14285714285714279 +!= +Approx( 3.14100000000000001 ) @@ -2451,7 +2515,9 @@ Nor would this d != Approx( 1.231 ) - 1.23 != Approx( 1.231 ) + 1.22999999999999998 +!= +Approx( 1.23100000000000009 ) @@ -2459,7 +2525,9 @@ Nor would this d == Approx( 1.231 ).epsilon( 0.1 ) - 1.23 == Approx( 1.231 ) + 1.22999999999999998 +== +Approx( 1.23100000000000009 ) @@ -2470,7 +2538,9 @@ Nor would this 1.23f == Approx( 1.23f ) - 1.23f == Approx( 1.2300000191 ) + 1.230000019f +== +Approx( 1.23000001907348633 ) @@ -2532,7 +2602,9 @@ Nor would this 1.234f == Approx( dMedium ) - 1.234f == Approx( 1.234 ) + 1.233999968f +== +Approx( 1.23399999999999999 ) @@ -2540,7 +2612,9 @@ Nor would this dMedium == Approx( 1.234f ) - 1.234 == Approx( 1.2339999676 ) + 1.23399999999999999 +== +Approx( 1.23399996757507324 ) @@ -3142,34 +3216,34 @@ Nor would this
- tab == '\t' + ::Catch::Detail::stringify('\t') == "'\\t'" - '\t' == '\t' + "'\t'" == "'\t'" - newline == '\n' + ::Catch::Detail::stringify('\n') == "'\\n'" - '\n' == '\n' + "'\n'" == "'\n'" - carr_return == '\r' + ::Catch::Detail::stringify('\r') == "'\\r'" - '\r' == '\r' + "'\r'" == "'\r'" - form_feed == '\f' + ::Catch::Detail::stringify('\f') == "'\\f'" - '\f' == '\f' + "'\f'" == "'\f'" @@ -3177,91 +3251,110 @@ Nor would this
- space == ' ' + ::Catch::Detail::stringify( ' ' ) == "' '" - ' ' == ' ' + "' '" == "' '" - - - c == chars[i] - - - 'a' == 'a' - - - - - c == chars[i] - - - 'z' == 'z' - - - + - c == chars[i] + ::Catch::Detail::stringify( 'A' ) == "'A'" - 'A' == 'A' + "'A'" == "'A'" - + - c == chars[i] + ::Catch::Detail::stringify( 'z' ) == "'z'" - 'Z' == 'Z' + "'z'" == "'z'" - +
- null_terminator == '\0' + ::Catch::Detail::stringify( '\0' ) == "0" - 0 == 0 + "0" == "0" - - - c == i - - - 2 == 2 - - - - - c == i - - - 3 == 3 - - - + - c == i + ::Catch::Detail::stringify( static_cast<char>(2) ) == "2" - 4 == 4 + "2" == "2" - + - c == i + ::Catch::Detail::stringify( static_cast<char>(5) ) == "5" - 5 == 5 + "5" == "5" - +
+ + + + name.empty() + + + true + + + + + result + + + {?} + + + + + result.type() == Catch::Clara::Detail::ResultType::Ok + + + 0 == 0 + + + + + parsed.type() == Catch::Clara::ParseResultType::NoMatch + + + 1 == 1 + + + + + parsed.remainingTokens().count() == 2 + + + 2 == 2 + + + + + name.empty() + + + true + + + + @@ -4322,7 +4415,7 @@ C 101.000001 != Approx(100).epsilon(0.01) - 101.000001 != Approx( 100.0 ) + 101.00000099999999748 != Approx( 100.0 ) @@ -4470,7 +4563,7 @@ C 101.01 != Approx(100).epsilon(0.01) - 101.01 != Approx( 100.0 ) + 101.01000000000000512 != Approx( 100.0 ) @@ -4505,7 +4598,9 @@ C data.float_nine_point_one == Approx( 9.11f ) - 9.1f == Approx( 9.1099996567 ) + 9.100000381f +== +Approx( 9.10999965667724609 ) @@ -4513,7 +4608,7 @@ C data.float_nine_point_one == Approx( 9.0f ) - 9.1f == Approx( 9.0 ) + 9.100000381f == Approx( 9.0 ) @@ -4521,7 +4616,7 @@ C data.float_nine_point_one == Approx( 1 ) - 9.1f == Approx( 1.0 ) + 9.100000381f == Approx( 1.0 ) @@ -4529,7 +4624,7 @@ C data.float_nine_point_one == Approx( 0 ) - 9.1f == Approx( 0.0 ) + 9.100000381f == Approx( 0.0 ) @@ -4537,7 +4632,9 @@ C data.double_pi == Approx( 3.1415 ) - 3.1415926535 == Approx( 3.1415 ) + 3.14159265350000005 +== +Approx( 3.14150000000000018 ) @@ -4577,7 +4674,9 @@ C x == Approx( 1.301 ) - 1.3 == Approx( 1.301 ) + 1.30000000000000027 +== +Approx( 1.30099999999999993 ) @@ -4596,7 +4695,9 @@ C data.float_nine_point_one == Approx( 9.1f ) - 9.1f == Approx( 9.1000003815 ) + 9.100000381f +== +Approx( 9.10000038146972656 ) @@ -4604,7 +4705,9 @@ C data.double_pi == Approx( 3.1415926535 ) - 3.1415926535 == Approx( 3.1415926535 ) + 3.14159265350000005 +== +Approx( 3.14159265350000005 ) @@ -4636,7 +4739,9 @@ C x == Approx( 1.3 ) - 1.3 == Approx( 1.3 ) + 1.30000000000000027 +== +Approx( 1.30000000000000004 ) @@ -5038,7 +5143,7 @@ C 10., WithinRel( 11.1, 0.1 ) - 10.0 and 11.1 are within 10% of each other + 10.0 and 11.09999999999999964 are within 10% of each other @@ -5046,7 +5151,7 @@ C 10., !WithinRel( 11.2, 0.1 ) - 10.0 not and 11.2 are within 10% of each other + 10.0 not and 11.19999999999999929 are within 10% of each other @@ -5054,7 +5159,7 @@ C 1., !WithinRel( 0., 0.99 ) - 1.0 not and 0 are within 99% of each other + 1.0 not and 0.0 are within 99% of each other @@ -5062,7 +5167,7 @@ C -0., WithinRel( 0. ) - -0.0 and 0 are within 2.22045e-12% of each other + -0.0 and 0.0 are within 2.22045e-12% of each other
@@ -5071,7 +5176,7 @@ C v1, WithinRel( v2 ) - 0.0 and 2.22507e-308 are within 2.22045e-12% of each other + 0.0 and 0.0 are within 2.22045e-12% of each other @@ -5100,7 +5205,7 @@ C 0., !WithinAbs( 1., 0.99 ) - 0.0 not is within 0.99 of 1.0 + 0.0 not is within 0.98999999999999999 of 1.0 @@ -5108,7 +5213,7 @@ C 0., !WithinAbs( 1., 0.99 ) - 0.0 not is within 0.99 of 1.0 + 0.0 not is within 0.98999999999999999 of 1.0 @@ -5140,7 +5245,7 @@ C -10., WithinAbs( -9.6, 0.5 ) - -10.0 is within 0.5 of -9.6 + -10.0 is within 0.5 of -9.59999999999999964 @@ -5159,7 +5264,7 @@ C nextafter( 1., 2. ), WithinULP( 1., 1 ) - 1.0 is within 1 ULPs of 1.0000000000000000e+00 ([9.9999999999999989e-01, 1.0000000000000002e+00]) + 1.00000000000000022 is within 1 ULPs of 1.0000000000000000e+00 ([9.9999999999999989e-01, 1.0000000000000002e+00]) @@ -5226,7 +5331,7 @@ C 0.0001, WithinAbs( 0., 0.001 ) || WithinRel( 0., 0.1 ) - 0.0001 ( is within 0.001 of 0.0 or and 0 are within 10% of each other ) + 0.0001 ( is within 0.001 of 0.0 or and 0.0 are within 10% of each other ) @@ -5302,7 +5407,7 @@ C 10.f, WithinRel( 11.1f, 0.1f ) - 10.0f and 11.1 are within 10% of each other + 10.0f and 11.10000038146972656 are within 10% of each other @@ -5310,7 +5415,7 @@ C 10.f, !WithinRel( 11.2f, 0.1f ) - 10.0f not and 11.2 are within 10% of each other + 10.0f not and 11.19999980926513672 are within 10% of each other @@ -5318,7 +5423,7 @@ C 1.f, !WithinRel( 0.f, 0.99f ) - 1.0f not and 0 are within 99% of each other + 1.0f not and 0.0 are within 99% of each other @@ -5326,7 +5431,7 @@ C -0.f, WithinRel( 0.f ) - -0.0f and 0 are within 0.00119209% of each other + -0.0f and 0.0 are within 0.00119209% of each other
@@ -5335,7 +5440,7 @@ C v1, WithinRel( v2 ) - 0.0f and 1.17549e-38 are within 0.00119209% of each other + 0.0f and 0.0 are within 0.00119209% of each other @@ -5364,7 +5469,7 @@ C 0.f, !WithinAbs( 1.f, 0.99f ) - 0.0f not is within 0.9900000095 of 1.0 + 0.0f not is within 0.99000000953674316 of 1.0 @@ -5372,7 +5477,7 @@ C 0.f, !WithinAbs( 1.f, 0.99f ) - 0.0f not is within 0.9900000095 of 1.0 + 0.0f not is within 0.99000000953674316 of 1.0 @@ -5412,7 +5517,7 @@ C -10.f, WithinAbs( -9.6f, 0.5f ) - -10.0f is within 0.5 of -9.6000003815 + -10.0f is within 0.5 of -9.60000038146972656 @@ -5439,7 +5544,7 @@ C nextafter( 1.f, 2.f ), WithinULP( 1.f, 1 ) - 1.0f is within 1 ULPs of 1.00000000e+00f ([9.99999940e-01, 1.00000012e+00]) + 1.000000119f is within 1 ULPs of 1.00000000e+00f ([9.99999940e-01, 1.00000012e+00]) @@ -5506,7 +5611,7 @@ C 0.0001f, WithinAbs( 0.f, 0.001f ) || WithinRel( 0.f, 0.1f ) - 0.0001f ( is within 0.001 of 0.0 or and 0 are within 10% of each other ) + 0.0001f ( is within 0.00100000004749745 of 0.0 or and 0.0 are within 10% of each other ) @@ -7306,7 +7411,9 @@ C gen.get() == Approx(expected) - -0.9 == Approx( -0.9 ) + -0.90000000000000002 +== +Approx( -0.90000000000000002 ) @@ -7328,7 +7435,9 @@ C gen.get() == Approx(expected) - -0.8 == Approx( -0.8 ) + -0.80000000000000004 +== +Approx( -0.80000000000000004 ) @@ -7350,7 +7459,9 @@ C gen.get() == Approx(expected) - -0.7 == Approx( -0.7 ) + -0.70000000000000007 +== +Approx( -0.70000000000000007 ) @@ -7372,7 +7483,9 @@ C gen.get() == Approx(expected) - -0.6 == Approx( -0.6 ) + -0.60000000000000009 +== +Approx( -0.60000000000000009 ) @@ -7394,7 +7507,9 @@ C gen.get() == Approx(expected) - -0.5 == Approx( -0.5 ) + -0.50000000000000011 +== +Approx( -0.50000000000000011 ) @@ -7416,7 +7531,9 @@ C gen.get() == Approx(expected) - -0.4 == Approx( -0.4 ) + -0.40000000000000013 +== +Approx( -0.40000000000000013 ) @@ -7438,7 +7555,9 @@ C gen.get() == Approx(expected) - -0.3 == Approx( -0.3 ) + -0.30000000000000016 +== +Approx( -0.30000000000000016 ) @@ -7460,7 +7579,9 @@ C gen.get() == Approx(expected) - -0.2 == Approx( -0.2 ) + -0.20000000000000015 +== +Approx( -0.20000000000000015 ) @@ -7482,7 +7603,9 @@ C gen.get() == Approx(expected) - -0.1 == Approx( -0.1 ) + -0.10000000000000014 +== +Approx( -0.10000000000000014 ) @@ -7504,7 +7627,9 @@ C gen.get() == Approx(expected) - -0.0 == Approx( -0.0 ) + -0.00000000000000014 +== +Approx( -0.00000000000000014 ) @@ -7526,7 +7651,9 @@ C gen.get() == Approx(expected) - 0.1 == Approx( 0.1 ) + 0.09999999999999987 +== +Approx( 0.09999999999999987 ) @@ -7548,7 +7675,9 @@ C gen.get() == Approx(expected) - 0.2 == Approx( 0.2 ) + 0.19999999999999987 +== +Approx( 0.19999999999999987 ) @@ -7570,7 +7699,9 @@ C gen.get() == Approx(expected) - 0.3 == Approx( 0.3 ) + 0.29999999999999988 +== +Approx( 0.29999999999999988 ) @@ -7592,7 +7723,9 @@ C gen.get() == Approx(expected) - 0.4 == Approx( 0.4 ) + 0.39999999999999991 +== +Approx( 0.39999999999999991 ) @@ -7614,7 +7747,9 @@ C gen.get() == Approx(expected) - 0.5 == Approx( 0.5 ) + 0.49999999999999989 +== +Approx( 0.49999999999999989 ) @@ -7636,7 +7771,9 @@ C gen.get() == Approx(expected) - 0.6 == Approx( 0.6 ) + 0.59999999999999987 +== +Approx( 0.59999999999999987 ) @@ -7658,7 +7795,9 @@ C gen.get() == Approx(expected) - 0.7 == Approx( 0.7 ) + 0.69999999999999984 +== +Approx( 0.69999999999999984 ) @@ -7680,7 +7819,9 @@ C gen.get() == Approx(expected) - 0.8 == Approx( 0.8 ) + 0.79999999999999982 +== +Approx( 0.79999999999999982 ) @@ -7702,7 +7843,9 @@ C gen.get() == Approx(expected) - 0.9 == Approx( 0.9 ) + 0.8999999999999998 +== +Approx( 0.8999999999999998 ) @@ -7721,7 +7864,7 @@ C gen.get() == Approx( rangeEnd ) - 1.0 == Approx( 1.0 ) + 0.99999999999999978 == Approx( 1.0 ) @@ -7774,7 +7917,9 @@ C gen.get() == Approx(expected) - -0.7 == Approx( -0.7 ) + -0.69999999999999996 +== +Approx( -0.69999999999999996 ) @@ -7796,7 +7941,9 @@ C gen.get() == Approx(expected) - -0.4 == Approx( -0.4 ) + -0.39999999999999997 +== +Approx( -0.39999999999999997 ) @@ -7818,7 +7965,9 @@ C gen.get() == Approx(expected) - -0.1 == Approx( -0.1 ) + -0.09999999999999998 +== +Approx( -0.09999999999999998 ) @@ -7840,7 +7989,9 @@ C gen.get() == Approx(expected) - 0.2 == Approx( 0.2 ) + 0.20000000000000001 +== +Approx( 0.20000000000000001 ) @@ -7926,7 +8077,9 @@ C gen.get() == Approx(expected) - -0.7 == Approx( -0.7 ) + -0.69999999999999996 +== +Approx( -0.69999999999999996 ) @@ -7948,7 +8101,9 @@ C gen.get() == Approx(expected) - -0.4 == Approx( -0.4 ) + -0.39999999999999997 +== +Approx( -0.39999999999999997 ) @@ -7970,7 +8125,9 @@ C gen.get() == Approx(expected) - -0.1 == Approx( -0.1 ) + -0.09999999999999998 +== +Approx( -0.09999999999999998 ) @@ -7992,7 +8149,9 @@ C gen.get() == Approx(expected) - 0.2 == Approx( 0.2 ) + 0.20000000000000001 +== +Approx( 0.20000000000000001 ) @@ -8296,7 +8455,9 @@ C d >= Approx( 1.22 ) - 1.23 >= Approx( 1.22 ) + 1.22999999999999998 +>= +Approx( 1.21999999999999997 ) @@ -8304,7 +8465,9 @@ C d >= Approx( 1.23 ) - 1.23 >= Approx( 1.23 ) + 1.22999999999999998 +>= +Approx( 1.22999999999999998 ) @@ -8312,7 +8475,9 @@ C !(d >= Approx( 1.24 )) - !(1.23 >= Approx( 1.24 )) + !(1.22999999999999998 +>= +Approx( 1.23999999999999999 )) @@ -8320,7 +8485,9 @@ C d >= Approx( 1.24 ).epsilon(0.1) - 1.23 >= Approx( 1.24 ) + 1.22999999999999998 +>= +Approx( 1.23999999999999999 ) @@ -8694,7 +8861,9 @@ C data.float_nine_point_one != Approx( 9.1f ) - 9.1f != Approx( 9.1000003815 ) + 9.100000381f +!= +Approx( 9.10000038146972656 ) @@ -8702,7 +8871,9 @@ C data.double_pi != Approx( 3.1415926535 ) - 3.1415926535 != Approx( 3.1415926535 ) + 3.14159265350000005 +!= +Approx( 3.14159265350000005 ) @@ -8745,7 +8916,9 @@ C data.float_nine_point_one != Approx( 9.11f ) - 9.1f != Approx( 9.1099996567 ) + 9.100000381f +!= +Approx( 9.10999965667724609 ) @@ -8753,7 +8926,7 @@ C data.float_nine_point_one != Approx( 9.0f ) - 9.1f != Approx( 9.0 ) + 9.100000381f != Approx( 9.0 ) @@ -8761,7 +8934,7 @@ C data.float_nine_point_one != Approx( 1 ) - 9.1f != Approx( 1.0 ) + 9.100000381f != Approx( 1.0 ) @@ -8769,7 +8942,7 @@ C data.float_nine_point_one != Approx( 0 ) - 9.1f != Approx( 0.0 ) + 9.100000381f != Approx( 0.0 ) @@ -8777,7 +8950,9 @@ C data.double_pi != Approx( 3.1415 ) - 3.1415926535 != Approx( 3.1415 ) + 3.14159265350000005 +!= +Approx( 3.14150000000000018 ) @@ -9102,7 +9277,9 @@ C d <= Approx( 1.24 ) - 1.23 <= Approx( 1.24 ) + 1.22999999999999998 +<= +Approx( 1.23999999999999999 ) @@ -9110,7 +9287,9 @@ C d <= Approx( 1.23 ) - 1.23 <= Approx( 1.23 ) + 1.22999999999999998 +<= +Approx( 1.22999999999999998 ) @@ -9118,7 +9297,9 @@ C !(d <= Approx( 1.22 )) - !(1.23 <= Approx( 1.22 )) + !(1.22999999999999998 +<= +Approx( 1.21999999999999997 )) @@ -9126,7 +9307,9 @@ C d <= Approx( 1.22 ).epsilon(0.1) - 1.23 <= Approx( 1.22 ) + 1.22999999999999998 +<= +Approx( 1.21999999999999997 ) @@ -9657,7 +9840,7 @@ C data.float_nine_point_one < 9 - 9.1f < 9 + 9.100000381f < 9 @@ -9665,7 +9848,7 @@ C data.float_nine_point_one > 10 - 9.1f > 10 + 9.100000381f > 10 @@ -9673,7 +9856,7 @@ C data.float_nine_point_one > 9.2 - 9.1f > 9.2 + 9.100000381f > 9.19999999999999929 @@ -9812,7 +9995,7 @@ C data.float_nine_point_one > 9 - 9.1f > 9 + 9.100000381f > 9 @@ -9820,7 +10003,7 @@ C data.float_nine_point_one < 10 - 9.1f < 10 + 9.100000381f < 10 @@ -9828,7 +10011,7 @@ C data.float_nine_point_one < 9.2 - 9.1f < 9.2 + 9.100000381f < 9.19999999999999929 @@ -11563,7 +11746,9 @@ C config.benchmarkConfidenceInterval == Catch::Approx(0.99) - 0.99 == Approx( 0.99 ) + 0.98999999999999999 +== +Approx( 0.98999999999999999 ) @@ -12709,7 +12894,9 @@ A string sent to stderr via clog d == Approx( 1.23 ) - 1.23 == Approx( 1.23 ) + 1.22999999999999998 +== +Approx( 1.22999999999999998 ) @@ -12717,7 +12904,9 @@ A string sent to stderr via clog d != Approx( 1.22 ) - 1.23 != Approx( 1.22 ) + 1.22999999999999998 +!= +Approx( 1.21999999999999997 ) @@ -12725,7 +12914,9 @@ A string sent to stderr via clog d != Approx( 1.24 ) - 1.23 != Approx( 1.24 ) + 1.22999999999999998 +!= +Approx( 1.23999999999999999 ) @@ -12733,7 +12924,9 @@ A string sent to stderr via clog d == 1.23_a - 1.23 == Approx( 1.23 ) + 1.22999999999999998 +== +Approx( 1.22999999999999998 ) @@ -12741,7 +12934,9 @@ A string sent to stderr via clog d != 1.22_a - 1.23 != Approx( 1.22 ) + 1.22999999999999998 +!= +Approx( 1.21999999999999997 ) @@ -12749,7 +12944,9 @@ A string sent to stderr via clog Approx( d ) == 1.23 - Approx( 1.23 ) == 1.23 + Approx( 1.22999999999999998 ) +== +1.22999999999999998 @@ -12757,7 +12954,9 @@ A string sent to stderr via clog Approx( d ) != 1.22 - Approx( 1.23 ) != 1.22 + Approx( 1.22999999999999998 ) +!= +1.21999999999999997 @@ -12765,7 +12964,9 @@ A string sent to stderr via clog Approx( d ) != 1.24 - Approx( 1.23 ) != 1.24 + Approx( 1.22999999999999998 ) +!= +1.23999999999999999 @@ -13592,10 +13793,10 @@ Message from section two - sizeof(TestType) > 0 + std::is_default_constructible<TestType>::value - 1 > 0 + true @@ -13603,10 +13804,10 @@ Message from section two - sizeof(TestType) > 0 + std::is_default_constructible<TestType>::value - 4 > 0 + true @@ -13614,10 +13815,10 @@ Message from section two - sizeof(TestType) > 0 + std::is_trivially_copyable<TestType>::value - 1 > 0 + true @@ -13625,10 +13826,10 @@ Message from section two - sizeof(TestType) > 0 + std::is_trivially_copyable<TestType>::value - 4 > 0 + true @@ -13636,10 +13837,10 @@ Message from section two - sizeof(TestType) > 0 + std::is_arithmetic<TestType>::value - 4 > 0 + true @@ -13647,10 +13848,10 @@ Message from section two - sizeof(TestType) > 0 + std::is_arithmetic<TestType>::value - 1 > 0 + true @@ -13658,10 +13859,10 @@ Message from section two - sizeof(TestType) > 0 + std::is_arithmetic<TestType>::value - 4 > 0 + true @@ -15955,7 +16156,7 @@ There is no extra whitespace here - 3.14 + 3.14000000000000012 @@ -17500,7 +17701,9 @@ There is no extra whitespace here d == approx( 1.23 ) - 1.23 == Approx( 1.23 ) + 1.22999999999999998 +== +Approx( 1.22999999999999998 ) @@ -17508,7 +17711,9 @@ There is no extra whitespace here d == approx( 1.22 ) - 1.23 == Approx( 1.22 ) + 1.22999999999999998 +== +Approx( 1.21999999999999997 ) @@ -17516,7 +17721,9 @@ There is no extra whitespace here d == approx( 1.24 ) - 1.23 == Approx( 1.24 ) + 1.22999999999999998 +== +Approx( 1.23999999999999999 ) @@ -17524,7 +17731,7 @@ There is no extra whitespace here d != approx( 1.25 ) - 1.23 != Approx( 1.25 ) + 1.22999999999999998 != Approx( 1.25 ) @@ -17532,7 +17739,9 @@ There is no extra whitespace here approx( d ) == 1.23 - Approx( 1.23 ) == 1.23 + Approx( 1.22999999999999998 ) +== +1.22999999999999998 @@ -17540,7 +17749,9 @@ There is no extra whitespace here approx( d ) == 1.22 - Approx( 1.23 ) == 1.22 + Approx( 1.22999999999999998 ) +== +1.21999999999999997 @@ -17548,7 +17759,9 @@ There is no extra whitespace here approx( d ) == 1.24 - Approx( 1.23 ) == 1.24 + Approx( 1.22999999999999998 ) +== +1.23999999999999999 @@ -17556,7 +17769,7 @@ There is no extra whitespace here approx( d ) != 1.25 - Approx( 1.23 ) != 1.25 + Approx( 1.22999999999999998 ) != 1.25 @@ -19008,7 +19221,9 @@ There is no extra whitespace here erfc_inv(1.103560) == Approx(-0.09203687623843015) - -0.0920368762 == Approx( -0.0920368762 ) + -0.09203687623843014 +== +Approx( -0.09203687623843015 ) @@ -19016,7 +19231,9 @@ There is no extra whitespace here erfc_inv(1.067400) == Approx(-0.05980291115763361) - -0.0598029112 == Approx( -0.0598029112 ) + -0.05980291115763361 +== +Approx( -0.05980291115763361 ) @@ -19024,7 +19241,9 @@ There is no extra whitespace here erfc_inv(0.050000) == Approx(1.38590382434967796) - 1.3859038243 == Approx( 1.3859038243 ) + 1.38590382434967774 +== +Approx( 1.38590382434967796 ) @@ -19615,56 +19834,15 @@ b1! - - - - normal_cdf(0.000000) == Approx(0.50000000000000000) - - - 0.5 == Approx( 0.5 ) - - - - - normal_cdf(1.000000) == Approx(0.84134474606854293) - - - 0.8413447461 == Approx( 0.8413447461 ) - - - - - normal_cdf(-1.000000) == Approx(0.15865525393145705) - - - 0.1586552539 == Approx( 0.1586552539 ) - - - - - normal_cdf(2.809729) == Approx(0.99752083845315409) - - - 0.9975208385 == Approx( 0.9975208385 ) - - - - - normal_cdf(-1.352570) == Approx(0.08809652095066035) - - - 0.088096521 == Approx( 0.088096521 ) - - - - normal_quantile(0.551780) == Approx(0.13015979861484198) - 0.1301597986 == Approx( 0.1301597986 ) + 0.13015979861484195 +== +Approx( 0.13015979861484198 ) @@ -19672,7 +19850,9 @@ b1! normal_quantile(0.533700) == Approx(0.08457408802851875) - 0.084574088 == Approx( 0.084574088 ) + 0.08457408802851875 +== +Approx( 0.08457408802851875 ) @@ -19680,7 +19860,9 @@ b1! normal_quantile(0.025000) == Approx(-1.95996398454005449) - -1.9599639845 == Approx( -1.9599639845 ) + -1.95996398454005405 +== +Approx( -1.95996398454005449 ) @@ -20066,6 +20248,50 @@ b1!
+
+
+ + + Catch::replaceInPlace(letters, "c", "cc") + + + true + + + + + letters == "abccdefccg" + + + "abccdefccg" == "abccdefccg" + + + +
+ +
+
+
+ + + Catch::replaceInPlace(s, "--", "-") + + + true + + + + + s == "--" + + + "--" == "--" + + + +
+ +
@@ -21046,18 +21272,18 @@ b1! - "1.2f" == ::Catch::Detail::stringify(float(1.2)) + "1.5f" == ::Catch::Detail::stringify(float(1.5)) - "1.2f" == "1.2f" + "1.5f" == "1.5f" - "{ 1.2f, 0 }" == ::Catch::Detail::stringify(type{1.2f,0}) + "{ 1.5f, 0 }" == ::Catch::Detail::stringify(type{1.5f,0}) - "{ 1.2f, 0 }" == "{ 1.2f, 0 }" + "{ 1.5f, 0 }" == "{ 1.5f, 0 }" @@ -21089,12 +21315,12 @@ b1! - "{ { 42 }, { }, 1.2f }" == ::Catch::Detail::stringify(value) + "{ { 42 }, { }, 1.5f }" == ::Catch::Detail::stringify(value) - "{ { 42 }, { }, 1.2f }" + "{ { 42 }, { }, 1.5f }" == -"{ { 42 }, { }, 1.2f }" +"{ { 42 }, { }, 1.5f }" @@ -21129,7 +21355,7 @@ b1! e.confidence_interval == 0.95 - 0.95 == 0.95 + 0.94999999999999996 == 0.94999999999999996 @@ -21707,6 +21933,6 @@ b1!
- - + + diff --git a/tests/SelfTest/Baselines/xml.sw.multi.approved.txt b/tests/SelfTest/Baselines/xml.sw.multi.approved.txt index 08ff6c4370..d35ba1af5a 100644 --- a/tests/SelfTest/Baselines/xml.sw.multi.approved.txt +++ b/tests/SelfTest/Baselines/xml.sw.multi.approved.txt @@ -2056,6 +2056,56 @@ Nor would this + +
+ + + m_a++ == 0 + + + 0 == 0 + + + +
+
+ + + m_a == 0 + + + 1 == 0 + + + +
+ +
+ +
+ + + m_a++ == 0 + + + 0 == 0 + + + +
+
+ + + m_a == 1 + + + 1 == 1 + + + +
+ +
@@ -2150,7 +2200,9 @@ Nor would this d == 1.23_a - 1.23 == Approx( 1.23 ) + 1.22999999999999998 +== +Approx( 1.22999999999999998 ) @@ -2158,7 +2210,9 @@ Nor would this d != 1.22_a - 1.23 != Approx( 1.22 ) + 1.22999999999999998 +!= +Approx( 1.21999999999999997 ) @@ -2166,7 +2220,9 @@ Nor would this -d == -1.23_a - -1.23 == Approx( -1.23 ) + -1.22999999999999998 +== +Approx( -1.22999999999999998 ) @@ -2174,7 +2230,9 @@ Nor would this d == 1.2_a .epsilon(.1) - 1.23 == Approx( 1.2 ) + 1.22999999999999998 +== +Approx( 1.19999999999999996 ) @@ -2182,7 +2240,9 @@ Nor would this d != 1.2_a .epsilon(.001) - 1.23 != Approx( 1.2 ) + 1.22999999999999998 +!= +Approx( 1.19999999999999996 ) @@ -2190,7 +2250,7 @@ Nor would this d == 1_a .epsilon(.3) - 1.23 == Approx( 1.0 ) + 1.22999999999999998 == Approx( 1.0 ) @@ -2264,7 +2324,7 @@ Nor would this 100.3 != Approx(100.0) - 100.3 != Approx( 100.0 ) + 100.29999999999999716 != Approx( 100.0 ) @@ -2272,7 +2332,7 @@ Nor would this 100.3 == Approx(100.0).margin(0.5) - 100.3 == Approx( 100.0 ) + 100.29999999999999716 == Approx( 100.0 ) @@ -2432,7 +2492,9 @@ Nor would this divide( 22, 7 ) == Approx( 3.141 ).epsilon( 0.001 ) - 3.1428571429 == Approx( 3.141 ) + 3.14285714285714279 +== +Approx( 3.14100000000000001 ) @@ -2440,7 +2502,9 @@ Nor would this divide( 22, 7 ) != Approx( 3.141 ).epsilon( 0.0001 ) - 3.1428571429 != Approx( 3.141 ) + 3.14285714285714279 +!= +Approx( 3.14100000000000001 ) @@ -2451,7 +2515,9 @@ Nor would this d != Approx( 1.231 ) - 1.23 != Approx( 1.231 ) + 1.22999999999999998 +!= +Approx( 1.23100000000000009 ) @@ -2459,7 +2525,9 @@ Nor would this d == Approx( 1.231 ).epsilon( 0.1 ) - 1.23 == Approx( 1.231 ) + 1.22999999999999998 +== +Approx( 1.23100000000000009 ) @@ -2470,7 +2538,9 @@ Nor would this 1.23f == Approx( 1.23f ) - 1.23f == Approx( 1.2300000191 ) + 1.230000019f +== +Approx( 1.23000001907348633 ) @@ -2532,7 +2602,9 @@ Nor would this 1.234f == Approx( dMedium ) - 1.234f == Approx( 1.234 ) + 1.233999968f +== +Approx( 1.23399999999999999 ) @@ -2540,7 +2612,9 @@ Nor would this dMedium == Approx( 1.234f ) - 1.234 == Approx( 1.2339999676 ) + 1.23399999999999999 +== +Approx( 1.23399996757507324 ) @@ -3142,34 +3216,34 @@ Nor would this
- tab == '\t' + ::Catch::Detail::stringify('\t') == "'\\t'" - '\t' == '\t' + "'\t'" == "'\t'" - newline == '\n' + ::Catch::Detail::stringify('\n') == "'\\n'" - '\n' == '\n' + "'\n'" == "'\n'" - carr_return == '\r' + ::Catch::Detail::stringify('\r') == "'\\r'" - '\r' == '\r' + "'\r'" == "'\r'" - form_feed == '\f' + ::Catch::Detail::stringify('\f') == "'\\f'" - '\f' == '\f' + "'\f'" == "'\f'" @@ -3177,91 +3251,110 @@ Nor would this
- space == ' ' + ::Catch::Detail::stringify( ' ' ) == "' '" - ' ' == ' ' + "' '" == "' '" - - - c == chars[i] - - - 'a' == 'a' - - - - - c == chars[i] - - - 'z' == 'z' - - - + - c == chars[i] + ::Catch::Detail::stringify( 'A' ) == "'A'" - 'A' == 'A' + "'A'" == "'A'" - + - c == chars[i] + ::Catch::Detail::stringify( 'z' ) == "'z'" - 'Z' == 'Z' + "'z'" == "'z'" - +
- null_terminator == '\0' + ::Catch::Detail::stringify( '\0' ) == "0" - 0 == 0 + "0" == "0" - - - c == i - - - 2 == 2 - - - - - c == i - - - 3 == 3 - - - + - c == i + ::Catch::Detail::stringify( static_cast<char>(2) ) == "2" - 4 == 4 + "2" == "2" - + - c == i + ::Catch::Detail::stringify( static_cast<char>(5) ) == "5" - 5 == 5 + "5" == "5" - +
+ + + + name.empty() + + + true + + + + + result + + + {?} + + + + + result.type() == Catch::Clara::Detail::ResultType::Ok + + + 0 == 0 + + + + + parsed.type() == Catch::Clara::ParseResultType::NoMatch + + + 1 == 1 + + + + + parsed.remainingTokens().count() == 2 + + + 2 == 2 + + + + + name.empty() + + + true + + + + @@ -4322,7 +4415,7 @@ C 101.000001 != Approx(100).epsilon(0.01) - 101.000001 != Approx( 100.0 ) + 101.00000099999999748 != Approx( 100.0 ) @@ -4470,7 +4563,7 @@ C 101.01 != Approx(100).epsilon(0.01) - 101.01 != Approx( 100.0 ) + 101.01000000000000512 != Approx( 100.0 ) @@ -4505,7 +4598,9 @@ C data.float_nine_point_one == Approx( 9.11f ) - 9.1f == Approx( 9.1099996567 ) + 9.100000381f +== +Approx( 9.10999965667724609 ) @@ -4513,7 +4608,7 @@ C data.float_nine_point_one == Approx( 9.0f ) - 9.1f == Approx( 9.0 ) + 9.100000381f == Approx( 9.0 ) @@ -4521,7 +4616,7 @@ C data.float_nine_point_one == Approx( 1 ) - 9.1f == Approx( 1.0 ) + 9.100000381f == Approx( 1.0 ) @@ -4529,7 +4624,7 @@ C data.float_nine_point_one == Approx( 0 ) - 9.1f == Approx( 0.0 ) + 9.100000381f == Approx( 0.0 ) @@ -4537,7 +4632,9 @@ C data.double_pi == Approx( 3.1415 ) - 3.1415926535 == Approx( 3.1415 ) + 3.14159265350000005 +== +Approx( 3.14150000000000018 ) @@ -4577,7 +4674,9 @@ C x == Approx( 1.301 ) - 1.3 == Approx( 1.301 ) + 1.30000000000000027 +== +Approx( 1.30099999999999993 ) @@ -4596,7 +4695,9 @@ C data.float_nine_point_one == Approx( 9.1f ) - 9.1f == Approx( 9.1000003815 ) + 9.100000381f +== +Approx( 9.10000038146972656 ) @@ -4604,7 +4705,9 @@ C data.double_pi == Approx( 3.1415926535 ) - 3.1415926535 == Approx( 3.1415926535 ) + 3.14159265350000005 +== +Approx( 3.14159265350000005 ) @@ -4636,7 +4739,9 @@ C x == Approx( 1.3 ) - 1.3 == Approx( 1.3 ) + 1.30000000000000027 +== +Approx( 1.30000000000000004 ) @@ -5038,7 +5143,7 @@ C 10., WithinRel( 11.1, 0.1 ) - 10.0 and 11.1 are within 10% of each other + 10.0 and 11.09999999999999964 are within 10% of each other @@ -5046,7 +5151,7 @@ C 10., !WithinRel( 11.2, 0.1 ) - 10.0 not and 11.2 are within 10% of each other + 10.0 not and 11.19999999999999929 are within 10% of each other @@ -5054,7 +5159,7 @@ C 1., !WithinRel( 0., 0.99 ) - 1.0 not and 0 are within 99% of each other + 1.0 not and 0.0 are within 99% of each other @@ -5062,7 +5167,7 @@ C -0., WithinRel( 0. ) - -0.0 and 0 are within 2.22045e-12% of each other + -0.0 and 0.0 are within 2.22045e-12% of each other
@@ -5071,7 +5176,7 @@ C v1, WithinRel( v2 ) - 0.0 and 2.22507e-308 are within 2.22045e-12% of each other + 0.0 and 0.0 are within 2.22045e-12% of each other @@ -5100,7 +5205,7 @@ C 0., !WithinAbs( 1., 0.99 ) - 0.0 not is within 0.99 of 1.0 + 0.0 not is within 0.98999999999999999 of 1.0 @@ -5108,7 +5213,7 @@ C 0., !WithinAbs( 1., 0.99 ) - 0.0 not is within 0.99 of 1.0 + 0.0 not is within 0.98999999999999999 of 1.0 @@ -5140,7 +5245,7 @@ C -10., WithinAbs( -9.6, 0.5 ) - -10.0 is within 0.5 of -9.6 + -10.0 is within 0.5 of -9.59999999999999964 @@ -5159,7 +5264,7 @@ C nextafter( 1., 2. ), WithinULP( 1., 1 ) - 1.0 is within 1 ULPs of 1.0000000000000000e+00 ([9.9999999999999989e-01, 1.0000000000000002e+00]) + 1.00000000000000022 is within 1 ULPs of 1.0000000000000000e+00 ([9.9999999999999989e-01, 1.0000000000000002e+00]) @@ -5226,7 +5331,7 @@ C 0.0001, WithinAbs( 0., 0.001 ) || WithinRel( 0., 0.1 ) - 0.0001 ( is within 0.001 of 0.0 or and 0 are within 10% of each other ) + 0.0001 ( is within 0.001 of 0.0 or and 0.0 are within 10% of each other ) @@ -5302,7 +5407,7 @@ C 10.f, WithinRel( 11.1f, 0.1f ) - 10.0f and 11.1 are within 10% of each other + 10.0f and 11.10000038146972656 are within 10% of each other @@ -5310,7 +5415,7 @@ C 10.f, !WithinRel( 11.2f, 0.1f ) - 10.0f not and 11.2 are within 10% of each other + 10.0f not and 11.19999980926513672 are within 10% of each other @@ -5318,7 +5423,7 @@ C 1.f, !WithinRel( 0.f, 0.99f ) - 1.0f not and 0 are within 99% of each other + 1.0f not and 0.0 are within 99% of each other @@ -5326,7 +5431,7 @@ C -0.f, WithinRel( 0.f ) - -0.0f and 0 are within 0.00119209% of each other + -0.0f and 0.0 are within 0.00119209% of each other
@@ -5335,7 +5440,7 @@ C v1, WithinRel( v2 ) - 0.0f and 1.17549e-38 are within 0.00119209% of each other + 0.0f and 0.0 are within 0.00119209% of each other @@ -5364,7 +5469,7 @@ C 0.f, !WithinAbs( 1.f, 0.99f ) - 0.0f not is within 0.9900000095 of 1.0 + 0.0f not is within 0.99000000953674316 of 1.0 @@ -5372,7 +5477,7 @@ C 0.f, !WithinAbs( 1.f, 0.99f ) - 0.0f not is within 0.9900000095 of 1.0 + 0.0f not is within 0.99000000953674316 of 1.0 @@ -5412,7 +5517,7 @@ C -10.f, WithinAbs( -9.6f, 0.5f ) - -10.0f is within 0.5 of -9.6000003815 + -10.0f is within 0.5 of -9.60000038146972656 @@ -5439,7 +5544,7 @@ C nextafter( 1.f, 2.f ), WithinULP( 1.f, 1 ) - 1.0f is within 1 ULPs of 1.00000000e+00f ([9.99999940e-01, 1.00000012e+00]) + 1.000000119f is within 1 ULPs of 1.00000000e+00f ([9.99999940e-01, 1.00000012e+00]) @@ -5506,7 +5611,7 @@ C 0.0001f, WithinAbs( 0.f, 0.001f ) || WithinRel( 0.f, 0.1f ) - 0.0001f ( is within 0.001 of 0.0 or and 0 are within 10% of each other ) + 0.0001f ( is within 0.00100000004749745 of 0.0 or and 0.0 are within 10% of each other ) @@ -7306,7 +7411,9 @@ C gen.get() == Approx(expected) - -0.9 == Approx( -0.9 ) + -0.90000000000000002 +== +Approx( -0.90000000000000002 ) @@ -7328,7 +7435,9 @@ C gen.get() == Approx(expected) - -0.8 == Approx( -0.8 ) + -0.80000000000000004 +== +Approx( -0.80000000000000004 ) @@ -7350,7 +7459,9 @@ C gen.get() == Approx(expected) - -0.7 == Approx( -0.7 ) + -0.70000000000000007 +== +Approx( -0.70000000000000007 ) @@ -7372,7 +7483,9 @@ C gen.get() == Approx(expected) - -0.6 == Approx( -0.6 ) + -0.60000000000000009 +== +Approx( -0.60000000000000009 ) @@ -7394,7 +7507,9 @@ C gen.get() == Approx(expected) - -0.5 == Approx( -0.5 ) + -0.50000000000000011 +== +Approx( -0.50000000000000011 ) @@ -7416,7 +7531,9 @@ C gen.get() == Approx(expected) - -0.4 == Approx( -0.4 ) + -0.40000000000000013 +== +Approx( -0.40000000000000013 ) @@ -7438,7 +7555,9 @@ C gen.get() == Approx(expected) - -0.3 == Approx( -0.3 ) + -0.30000000000000016 +== +Approx( -0.30000000000000016 ) @@ -7460,7 +7579,9 @@ C gen.get() == Approx(expected) - -0.2 == Approx( -0.2 ) + -0.20000000000000015 +== +Approx( -0.20000000000000015 ) @@ -7482,7 +7603,9 @@ C gen.get() == Approx(expected) - -0.1 == Approx( -0.1 ) + -0.10000000000000014 +== +Approx( -0.10000000000000014 ) @@ -7504,7 +7627,9 @@ C gen.get() == Approx(expected) - -0.0 == Approx( -0.0 ) + -0.00000000000000014 +== +Approx( -0.00000000000000014 ) @@ -7526,7 +7651,9 @@ C gen.get() == Approx(expected) - 0.1 == Approx( 0.1 ) + 0.09999999999999987 +== +Approx( 0.09999999999999987 ) @@ -7548,7 +7675,9 @@ C gen.get() == Approx(expected) - 0.2 == Approx( 0.2 ) + 0.19999999999999987 +== +Approx( 0.19999999999999987 ) @@ -7570,7 +7699,9 @@ C gen.get() == Approx(expected) - 0.3 == Approx( 0.3 ) + 0.29999999999999988 +== +Approx( 0.29999999999999988 ) @@ -7592,7 +7723,9 @@ C gen.get() == Approx(expected) - 0.4 == Approx( 0.4 ) + 0.39999999999999991 +== +Approx( 0.39999999999999991 ) @@ -7614,7 +7747,9 @@ C gen.get() == Approx(expected) - 0.5 == Approx( 0.5 ) + 0.49999999999999989 +== +Approx( 0.49999999999999989 ) @@ -7636,7 +7771,9 @@ C gen.get() == Approx(expected) - 0.6 == Approx( 0.6 ) + 0.59999999999999987 +== +Approx( 0.59999999999999987 ) @@ -7658,7 +7795,9 @@ C gen.get() == Approx(expected) - 0.7 == Approx( 0.7 ) + 0.69999999999999984 +== +Approx( 0.69999999999999984 ) @@ -7680,7 +7819,9 @@ C gen.get() == Approx(expected) - 0.8 == Approx( 0.8 ) + 0.79999999999999982 +== +Approx( 0.79999999999999982 ) @@ -7702,7 +7843,9 @@ C gen.get() == Approx(expected) - 0.9 == Approx( 0.9 ) + 0.8999999999999998 +== +Approx( 0.8999999999999998 ) @@ -7721,7 +7864,7 @@ C gen.get() == Approx( rangeEnd ) - 1.0 == Approx( 1.0 ) + 0.99999999999999978 == Approx( 1.0 ) @@ -7774,7 +7917,9 @@ C gen.get() == Approx(expected) - -0.7 == Approx( -0.7 ) + -0.69999999999999996 +== +Approx( -0.69999999999999996 ) @@ -7796,7 +7941,9 @@ C gen.get() == Approx(expected) - -0.4 == Approx( -0.4 ) + -0.39999999999999997 +== +Approx( -0.39999999999999997 ) @@ -7818,7 +7965,9 @@ C gen.get() == Approx(expected) - -0.1 == Approx( -0.1 ) + -0.09999999999999998 +== +Approx( -0.09999999999999998 ) @@ -7840,7 +7989,9 @@ C gen.get() == Approx(expected) - 0.2 == Approx( 0.2 ) + 0.20000000000000001 +== +Approx( 0.20000000000000001 ) @@ -7926,7 +8077,9 @@ C gen.get() == Approx(expected) - -0.7 == Approx( -0.7 ) + -0.69999999999999996 +== +Approx( -0.69999999999999996 ) @@ -7948,7 +8101,9 @@ C gen.get() == Approx(expected) - -0.4 == Approx( -0.4 ) + -0.39999999999999997 +== +Approx( -0.39999999999999997 ) @@ -7970,7 +8125,9 @@ C gen.get() == Approx(expected) - -0.1 == Approx( -0.1 ) + -0.09999999999999998 +== +Approx( -0.09999999999999998 ) @@ -7992,7 +8149,9 @@ C gen.get() == Approx(expected) - 0.2 == Approx( 0.2 ) + 0.20000000000000001 +== +Approx( 0.20000000000000001 ) @@ -8296,7 +8455,9 @@ C d >= Approx( 1.22 ) - 1.23 >= Approx( 1.22 ) + 1.22999999999999998 +>= +Approx( 1.21999999999999997 ) @@ -8304,7 +8465,9 @@ C d >= Approx( 1.23 ) - 1.23 >= Approx( 1.23 ) + 1.22999999999999998 +>= +Approx( 1.22999999999999998 ) @@ -8312,7 +8475,9 @@ C !(d >= Approx( 1.24 )) - !(1.23 >= Approx( 1.24 )) + !(1.22999999999999998 +>= +Approx( 1.23999999999999999 )) @@ -8320,7 +8485,9 @@ C d >= Approx( 1.24 ).epsilon(0.1) - 1.23 >= Approx( 1.24 ) + 1.22999999999999998 +>= +Approx( 1.23999999999999999 ) @@ -8694,7 +8861,9 @@ C data.float_nine_point_one != Approx( 9.1f ) - 9.1f != Approx( 9.1000003815 ) + 9.100000381f +!= +Approx( 9.10000038146972656 ) @@ -8702,7 +8871,9 @@ C data.double_pi != Approx( 3.1415926535 ) - 3.1415926535 != Approx( 3.1415926535 ) + 3.14159265350000005 +!= +Approx( 3.14159265350000005 ) @@ -8745,7 +8916,9 @@ C data.float_nine_point_one != Approx( 9.11f ) - 9.1f != Approx( 9.1099996567 ) + 9.100000381f +!= +Approx( 9.10999965667724609 ) @@ -8753,7 +8926,7 @@ C data.float_nine_point_one != Approx( 9.0f ) - 9.1f != Approx( 9.0 ) + 9.100000381f != Approx( 9.0 ) @@ -8761,7 +8934,7 @@ C data.float_nine_point_one != Approx( 1 ) - 9.1f != Approx( 1.0 ) + 9.100000381f != Approx( 1.0 ) @@ -8769,7 +8942,7 @@ C data.float_nine_point_one != Approx( 0 ) - 9.1f != Approx( 0.0 ) + 9.100000381f != Approx( 0.0 ) @@ -8777,7 +8950,9 @@ C data.double_pi != Approx( 3.1415 ) - 3.1415926535 != Approx( 3.1415 ) + 3.14159265350000005 +!= +Approx( 3.14150000000000018 ) @@ -9102,7 +9277,9 @@ C d <= Approx( 1.24 ) - 1.23 <= Approx( 1.24 ) + 1.22999999999999998 +<= +Approx( 1.23999999999999999 ) @@ -9110,7 +9287,9 @@ C d <= Approx( 1.23 ) - 1.23 <= Approx( 1.23 ) + 1.22999999999999998 +<= +Approx( 1.22999999999999998 ) @@ -9118,7 +9297,9 @@ C !(d <= Approx( 1.22 )) - !(1.23 <= Approx( 1.22 )) + !(1.22999999999999998 +<= +Approx( 1.21999999999999997 )) @@ -9126,7 +9307,9 @@ C d <= Approx( 1.22 ).epsilon(0.1) - 1.23 <= Approx( 1.22 ) + 1.22999999999999998 +<= +Approx( 1.21999999999999997 ) @@ -9657,7 +9840,7 @@ C data.float_nine_point_one < 9 - 9.1f < 9 + 9.100000381f < 9 @@ -9665,7 +9848,7 @@ C data.float_nine_point_one > 10 - 9.1f > 10 + 9.100000381f > 10 @@ -9673,7 +9856,7 @@ C data.float_nine_point_one > 9.2 - 9.1f > 9.2 + 9.100000381f > 9.19999999999999929 @@ -9812,7 +9995,7 @@ C data.float_nine_point_one > 9 - 9.1f > 9 + 9.100000381f > 9 @@ -9820,7 +10003,7 @@ C data.float_nine_point_one < 10 - 9.1f < 10 + 9.100000381f < 10 @@ -9828,7 +10011,7 @@ C data.float_nine_point_one < 9.2 - 9.1f < 9.2 + 9.100000381f < 9.19999999999999929 @@ -11563,7 +11746,9 @@ C config.benchmarkConfidenceInterval == Catch::Approx(0.99) - 0.99 == Approx( 0.99 ) + 0.98999999999999999 +== +Approx( 0.98999999999999999 ) @@ -12709,7 +12894,9 @@ A string sent to stderr via clog d == Approx( 1.23 ) - 1.23 == Approx( 1.23 ) + 1.22999999999999998 +== +Approx( 1.22999999999999998 ) @@ -12717,7 +12904,9 @@ A string sent to stderr via clog d != Approx( 1.22 ) - 1.23 != Approx( 1.22 ) + 1.22999999999999998 +!= +Approx( 1.21999999999999997 ) @@ -12725,7 +12914,9 @@ A string sent to stderr via clog d != Approx( 1.24 ) - 1.23 != Approx( 1.24 ) + 1.22999999999999998 +!= +Approx( 1.23999999999999999 ) @@ -12733,7 +12924,9 @@ A string sent to stderr via clog d == 1.23_a - 1.23 == Approx( 1.23 ) + 1.22999999999999998 +== +Approx( 1.22999999999999998 ) @@ -12741,7 +12934,9 @@ A string sent to stderr via clog d != 1.22_a - 1.23 != Approx( 1.22 ) + 1.22999999999999998 +!= +Approx( 1.21999999999999997 ) @@ -12749,7 +12944,9 @@ A string sent to stderr via clog Approx( d ) == 1.23 - Approx( 1.23 ) == 1.23 + Approx( 1.22999999999999998 ) +== +1.22999999999999998 @@ -12757,7 +12954,9 @@ A string sent to stderr via clog Approx( d ) != 1.22 - Approx( 1.23 ) != 1.22 + Approx( 1.22999999999999998 ) +!= +1.21999999999999997 @@ -12765,7 +12964,9 @@ A string sent to stderr via clog Approx( d ) != 1.24 - Approx( 1.23 ) != 1.24 + Approx( 1.22999999999999998 ) +!= +1.23999999999999999 @@ -13592,10 +13793,10 @@ Message from section two - sizeof(TestType) > 0 + std::is_default_constructible<TestType>::value - 1 > 0 + true @@ -13603,10 +13804,10 @@ Message from section two - sizeof(TestType) > 0 + std::is_default_constructible<TestType>::value - 4 > 0 + true @@ -13614,10 +13815,10 @@ Message from section two - sizeof(TestType) > 0 + std::is_trivially_copyable<TestType>::value - 1 > 0 + true @@ -13625,10 +13826,10 @@ Message from section two - sizeof(TestType) > 0 + std::is_trivially_copyable<TestType>::value - 4 > 0 + true @@ -13636,10 +13837,10 @@ Message from section two - sizeof(TestType) > 0 + std::is_arithmetic<TestType>::value - 4 > 0 + true @@ -13647,10 +13848,10 @@ Message from section two - sizeof(TestType) > 0 + std::is_arithmetic<TestType>::value - 1 > 0 + true @@ -13658,10 +13859,10 @@ Message from section two - sizeof(TestType) > 0 + std::is_arithmetic<TestType>::value - 4 > 0 + true @@ -15955,7 +16156,7 @@ There is no extra whitespace here - 3.14 + 3.14000000000000012 @@ -17500,7 +17701,9 @@ There is no extra whitespace here d == approx( 1.23 ) - 1.23 == Approx( 1.23 ) + 1.22999999999999998 +== +Approx( 1.22999999999999998 ) @@ -17508,7 +17711,9 @@ There is no extra whitespace here d == approx( 1.22 ) - 1.23 == Approx( 1.22 ) + 1.22999999999999998 +== +Approx( 1.21999999999999997 ) @@ -17516,7 +17721,9 @@ There is no extra whitespace here d == approx( 1.24 ) - 1.23 == Approx( 1.24 ) + 1.22999999999999998 +== +Approx( 1.23999999999999999 ) @@ -17524,7 +17731,7 @@ There is no extra whitespace here d != approx( 1.25 ) - 1.23 != Approx( 1.25 ) + 1.22999999999999998 != Approx( 1.25 ) @@ -17532,7 +17739,9 @@ There is no extra whitespace here approx( d ) == 1.23 - Approx( 1.23 ) == 1.23 + Approx( 1.22999999999999998 ) +== +1.22999999999999998 @@ -17540,7 +17749,9 @@ There is no extra whitespace here approx( d ) == 1.22 - Approx( 1.23 ) == 1.22 + Approx( 1.22999999999999998 ) +== +1.21999999999999997 @@ -17548,7 +17759,9 @@ There is no extra whitespace here approx( d ) == 1.24 - Approx( 1.23 ) == 1.24 + Approx( 1.22999999999999998 ) +== +1.23999999999999999 @@ -17556,7 +17769,7 @@ There is no extra whitespace here approx( d ) != 1.25 - Approx( 1.23 ) != 1.25 + Approx( 1.22999999999999998 ) != 1.25 @@ -19008,7 +19221,9 @@ There is no extra whitespace here erfc_inv(1.103560) == Approx(-0.09203687623843015) - -0.0920368762 == Approx( -0.0920368762 ) + -0.09203687623843014 +== +Approx( -0.09203687623843015 ) @@ -19016,7 +19231,9 @@ There is no extra whitespace here erfc_inv(1.067400) == Approx(-0.05980291115763361) - -0.0598029112 == Approx( -0.0598029112 ) + -0.05980291115763361 +== +Approx( -0.05980291115763361 ) @@ -19024,7 +19241,9 @@ There is no extra whitespace here erfc_inv(0.050000) == Approx(1.38590382434967796) - 1.3859038243 == Approx( 1.3859038243 ) + 1.38590382434967774 +== +Approx( 1.38590382434967796 ) @@ -19614,56 +19833,15 @@ b1! - - - - normal_cdf(0.000000) == Approx(0.50000000000000000) - - - 0.5 == Approx( 0.5 ) - - - - - normal_cdf(1.000000) == Approx(0.84134474606854293) - - - 0.8413447461 == Approx( 0.8413447461 ) - - - - - normal_cdf(-1.000000) == Approx(0.15865525393145705) - - - 0.1586552539 == Approx( 0.1586552539 ) - - - - - normal_cdf(2.809729) == Approx(0.99752083845315409) - - - 0.9975208385 == Approx( 0.9975208385 ) - - - - - normal_cdf(-1.352570) == Approx(0.08809652095066035) - - - 0.088096521 == Approx( 0.088096521 ) - - - - normal_quantile(0.551780) == Approx(0.13015979861484198) - 0.1301597986 == Approx( 0.1301597986 ) + 0.13015979861484195 +== +Approx( 0.13015979861484198 ) @@ -19671,7 +19849,9 @@ b1! normal_quantile(0.533700) == Approx(0.08457408802851875) - 0.084574088 == Approx( 0.084574088 ) + 0.08457408802851875 +== +Approx( 0.08457408802851875 ) @@ -19679,7 +19859,9 @@ b1! normal_quantile(0.025000) == Approx(-1.95996398454005449) - -1.9599639845 == Approx( -1.9599639845 ) + -1.95996398454005405 +== +Approx( -1.95996398454005449 ) @@ -20065,6 +20247,50 @@ b1!
+
+
+ + + Catch::replaceInPlace(letters, "c", "cc") + + + true + + + + + letters == "abccdefccg" + + + "abccdefccg" == "abccdefccg" + + + +
+ +
+
+
+ + + Catch::replaceInPlace(s, "--", "-") + + + true + + + + + s == "--" + + + "--" == "--" + + + +
+ +
@@ -21045,18 +21271,18 @@ b1! - "1.2f" == ::Catch::Detail::stringify(float(1.2)) + "1.5f" == ::Catch::Detail::stringify(float(1.5)) - "1.2f" == "1.2f" + "1.5f" == "1.5f" - "{ 1.2f, 0 }" == ::Catch::Detail::stringify(type{1.2f,0}) + "{ 1.5f, 0 }" == ::Catch::Detail::stringify(type{1.5f,0}) - "{ 1.2f, 0 }" == "{ 1.2f, 0 }" + "{ 1.5f, 0 }" == "{ 1.5f, 0 }" @@ -21088,12 +21314,12 @@ b1! - "{ { 42 }, { }, 1.2f }" == ::Catch::Detail::stringify(value) + "{ { 42 }, { }, 1.5f }" == ::Catch::Detail::stringify(value) - "{ { 42 }, { }, 1.2f }" + "{ { 42 }, { }, 1.5f }" == -"{ { 42 }, { }, 1.2f }" +"{ { 42 }, { }, 1.5f }" @@ -21128,7 +21354,7 @@ b1! e.confidence_interval == 0.95 - 0.95 == 0.95 + 0.94999999999999996 == 0.94999999999999996 @@ -21706,6 +21932,6 @@ b1!
- - + + diff --git a/tests/SelfTest/IntrospectiveTests/Clara.tests.cpp b/tests/SelfTest/IntrospectiveTests/Clara.tests.cpp index 14ba433dad..53023b5025 100644 --- a/tests/SelfTest/IntrospectiveTests/Clara.tests.cpp +++ b/tests/SelfTest/IntrospectiveTests/Clara.tests.cpp @@ -51,6 +51,21 @@ TEST_CASE("Clara::Arg supports single-arg parse the way Opt does", "[clara][arg] REQUIRE(name == "foo"); } +TEST_CASE("Clara::Arg does not crash on incomplete input", "[clara][arg][compilation]") { + std::string name; + auto p = Catch::Clara::Arg(name, "-"); + + CHECK(name.empty()); + + auto result = p.parse( Catch::Clara::Args{ "UnitTest", "-" } ); + CHECK( result ); + CHECK( result.type() == Catch::Clara::Detail::ResultType::Ok ); + const auto& parsed = result.value(); + CHECK( parsed.type() == Catch::Clara::ParseResultType::NoMatch ); + CHECK( parsed.remainingTokens().count() == 2 ); + CHECK( name.empty() ); +} + TEST_CASE("Clara::Opt supports accept-many lambdas", "[clara][opt]") { using namespace Catch::Clara; std::vector res; diff --git a/tests/SelfTest/IntrospectiveTests/Details.tests.cpp b/tests/SelfTest/IntrospectiveTests/Details.tests.cpp index d7175756b5..5566bb5977 100644 --- a/tests/SelfTest/IntrospectiveTests/Details.tests.cpp +++ b/tests/SelfTest/IntrospectiveTests/Details.tests.cpp @@ -120,13 +120,13 @@ TEST_CASE( "Optional supports move ops", "[optional][approvals]" ) { } SECTION( "Move construction from optional" ) { Optional opt_B( CATCH_MOVE( opt_A ) ); - REQUIRE( opt_A->has_moved ); + REQUIRE( opt_A->has_moved ); // NOLINT(clang-analyzer-cplusplus.Move) } SECTION( "Move assignment from optional" ) { Optional opt_B( opt_A ); REQUIRE_FALSE( opt_A->has_moved ); opt_B = CATCH_MOVE( opt_A ); - REQUIRE( opt_A->has_moved ); + REQUIRE( opt_A->has_moved ); // NOLINT(clang-analyzer-cplusplus.Move) } } diff --git a/tests/SelfTest/IntrospectiveTests/FloatingPoint.tests.cpp b/tests/SelfTest/IntrospectiveTests/FloatingPoint.tests.cpp index eaf22a44a1..d2181702d1 100644 --- a/tests/SelfTest/IntrospectiveTests/FloatingPoint.tests.cpp +++ b/tests/SelfTest/IntrospectiveTests/FloatingPoint.tests.cpp @@ -123,6 +123,12 @@ TEST_CASE( "count_equidistant_floats", CHECK( count_floats_with_scaled_ulp( 1., 1.5 ) == 1ull << 51 ); CHECK( count_floats_with_scaled_ulp( 1.25, 1.5 ) == 1ull << 50 ); CHECK( count_floats_with_scaled_ulp( 1.f, 1.5f ) == 1 << 22 ); + CHECK( count_floats_with_scaled_ulp( -std::numeric_limits::max(), + std::numeric_limits::max() ) == + 33554430 ); // (1 << 25) - 2 due to not including infinities + CHECK( count_floats_with_scaled_ulp( -std::numeric_limits::max(), + std::numeric_limits::max() ) == + 18014398509481982 ); // (1 << 54) - 2 due to not including infinities STATIC_REQUIRE( std::is_same #include #include -#include // Tests of generator implementation details TEST_CASE("Generators internals", "[generators][internals]") { diff --git a/tests/SelfTest/IntrospectiveTests/Integer.tests.cpp b/tests/SelfTest/IntrospectiveTests/Integer.tests.cpp index fd620ebbf1..8955f4001a 100644 --- a/tests/SelfTest/IntrospectiveTests/Integer.tests.cpp +++ b/tests/SelfTest/IntrospectiveTests/Integer.tests.cpp @@ -8,6 +8,7 @@ #include #include +#include namespace { template @@ -20,6 +21,58 @@ namespace { CHECK( extendedMult( b, a ) == ExtendedMultResult{ upper_result, lower_result } ); } + + // Simple (and slow) implmentation of extended multiplication for tests + constexpr Catch::Detail::ExtendedMultResult + extendedMultNaive( std::uint64_t lhs, std::uint64_t rhs ) { + // This is a simple long multiplication, where we split lhs and rhs + // into two 32-bit "digits", so that we can do ops with carry in 64-bits. + // + // 32b 32b 32b 32b + // lhs L1 L2 + // * rhs R1 R2 + // ------------------------ + // | R2 * L2 | + // | R2 * L1 | + // | R1 * L2 | + // | R1 * L1 | + // ------------------------- + // | a | b | c | d | + +#define CarryBits( x ) ( x >> 32 ) +#define Digits( x ) ( x & 0xFF'FF'FF'FF ) + + auto r2l2 = Digits( rhs ) * Digits( lhs ); + auto r2l1 = Digits( rhs ) * CarryBits( lhs ); + auto r1l2 = CarryBits( rhs ) * Digits( lhs ); + auto r1l1 = CarryBits( rhs ) * CarryBits( lhs ); + + // Sum to columns first + auto d = Digits( r2l2 ); + auto c = CarryBits( r2l2 ) + Digits( r2l1 ) + Digits( r1l2 ); + auto b = CarryBits( r2l1 ) + CarryBits( r1l2 ) + Digits( r1l1 ); + auto a = CarryBits( r1l1 ); + + // Propagate carries between columns + c += CarryBits( d ); + b += CarryBits( c ); + a += CarryBits( b ); + + // Remove the used carries + c = Digits( c ); + b = Digits( b ); + a = Digits( a ); + +#undef CarryBits +#undef Digits + + return { + a << 32 | b, // upper 64 bits + c << 32 | d // lower 64 bits + }; + } + + } // namespace TEST_CASE( "extendedMult 64x64", "[Integer][approvals]" ) { @@ -62,6 +115,27 @@ TEST_CASE( "extendedMult 64x64", "[Integer][approvals]" ) { 0xdf44'2d22'ce48'59b9 ); } +TEST_CASE("extendedMult 64x64 - all implementations", "[integer][approvals]") { + using Catch::Detail::extendedMult; + using Catch::Detail::extendedMultPortable; + using Catch::Detail::fillBitsFrom; + + std::random_device rng; + for (size_t i = 0; i < 100; ++i) { + auto a = fillBitsFrom( rng ); + auto b = fillBitsFrom( rng ); + CAPTURE( a, b ); + + auto naive_ab = extendedMultNaive( a, b ); + + REQUIRE( naive_ab == extendedMultNaive( b, a ) ); + REQUIRE( naive_ab == extendedMultPortable( a, b ) ); + REQUIRE( naive_ab == extendedMultPortable( b, a ) ); + REQUIRE( naive_ab == extendedMult( a, b ) ); + REQUIRE( naive_ab == extendedMult( b, a ) ); + } +} + TEST_CASE( "SizedUnsignedType helpers", "[integer][approvals]" ) { using Catch::Detail::SizedUnsignedType_t; using Catch::Detail::DoubleWidthUnsignedType_t; diff --git a/tests/SelfTest/IntrospectiveTests/InternalBenchmark.tests.cpp b/tests/SelfTest/IntrospectiveTests/InternalBenchmark.tests.cpp index bc8d715b47..69251d9739 100644 --- a/tests/SelfTest/IntrospectiveTests/InternalBenchmark.tests.cpp +++ b/tests/SelfTest/IntrospectiveTests/InternalBenchmark.tests.cpp @@ -172,7 +172,7 @@ TEST_CASE("uniform samples", "[benchmark]") { } -TEST_CASE("normal_cdf", "[benchmark]") { +TEST_CASE("normal_cdf", "[benchmark][approvals]") { using Catch::Benchmark::Detail::normal_cdf; using Catch::Approx; CHECK(normal_cdf(0.000000) == Approx(0.50000000000000000)); diff --git a/tests/SelfTest/IntrospectiveTests/RandomNumberGeneration.tests.cpp b/tests/SelfTest/IntrospectiveTests/RandomNumberGeneration.tests.cpp index 03be6c9cad..8932321535 100644 --- a/tests/SelfTest/IntrospectiveTests/RandomNumberGeneration.tests.cpp +++ b/tests/SelfTest/IntrospectiveTests/RandomNumberGeneration.tests.cpp @@ -140,7 +140,9 @@ TEMPLATE_TEST_CASE( "uniform_integer_distribution can handle unit ranges", uint32_t, int32_t, uint64_t, - int64_t ) { + int64_t, + size_t, + ptrdiff_t) { // We want random seed to sample different parts of the rng state, // the output is predetermined anyway std::random_device rd; @@ -493,6 +495,21 @@ TEMPLATE_TEST_CASE( "uniform_integer_distribution is reproducible", REQUIRE_THAT(generated, Catch::Matchers::RangeEquals(uniform_integer_test_params::expected)); } +// The reproducibility tests assume that operations on `float`/`double` +// happen in the same precision as the operated-upon type. This is +// generally true, unless the code is compiled for 32 bit targets without +// SSE2 enabled, in which case the operations are done in the x87 FPU, +// which usually implies doing math in 80 bit floats, and then rounding +// into smaller type when the type is saved into memory. This obviously +// leads to a different answer, than doing the math in the correct precision. +#if ( defined( _MSC_VER ) && _M_IX86_FP < 2 ) || \ + ( defined( __GNUC__ ) && \ + ( ( defined( __i386__ ) || defined( __x86_64__ ) ) ) && \ + !defined( __SSE2_MATH__ ) ) +# define CATCH_TEST_CONFIG_DISABLE_FLOAT_REPRODUCIBILITY_TESTS +#endif + +#if !defined( CATCH_TEST_CONFIG_DISABLE_FLOAT_REPRODUCIBILITY_TESTS ) namespace { template @@ -570,6 +587,8 @@ TEMPLATE_TEST_CASE( "uniform_floating_point_distribution is reproducible", REQUIRE_THAT( generated, Catch::Matchers::RangeEquals( uniform_fp_test_params::expected ) ); } +#endif // ^^ float reproducibility tests are enabled + TEMPLATE_TEST_CASE( "uniform_floating_point_distribution can handle unitary ranges", "[rng][distribution][floating-point][approvals]", float, @@ -579,7 +598,7 @@ TEMPLATE_TEST_CASE( "uniform_floating_point_distribution can handle unitary rang CAPTURE( seed ); Catch::SimplePcg32 pcg( seed ); - const auto highest = uniform_fp_test_params::highest; + const auto highest = TestType(385.125); Catch::uniform_floating_point_distribution dist( highest, highest ); diff --git a/tests/SelfTest/IntrospectiveTests/Reporters.tests.cpp b/tests/SelfTest/IntrospectiveTests/Reporters.tests.cpp index e5a65bda59..86ba1175d4 100644 --- a/tests/SelfTest/IntrospectiveTests/Reporters.tests.cpp +++ b/tests/SelfTest/IntrospectiveTests/Reporters.tests.cpp @@ -107,7 +107,7 @@ TEST_CASE( "Reporter's write listings to provided stream", "[reporters]" ) { for (auto const& factory : factories) { INFO("Tested reporter: " << factory.first); auto sstream = Catch::Detail::make_unique(); - auto& sstreamRef = *sstream.get(); + auto& sstreamRef = *sstream; Catch::ConfigData cfg_data; cfg_data.rngSeed = 1234; diff --git a/tests/SelfTest/IntrospectiveTests/StringManip.tests.cpp b/tests/SelfTest/IntrospectiveTests/StringManip.tests.cpp index 36554ddc3b..f30573cc5c 100644 --- a/tests/SelfTest/IntrospectiveTests/StringManip.tests.cpp +++ b/tests/SelfTest/IntrospectiveTests/StringManip.tests.cpp @@ -57,6 +57,17 @@ TEST_CASE("replaceInPlace", "[string-manip]") { CHECK_FALSE(Catch::replaceInPlace(letters, "x", "z")); CHECK(letters == letters); } + SECTION("no replace in already-replaced string") { + SECTION("lengthening") { + CHECK(Catch::replaceInPlace(letters, "c", "cc")); + CHECK(letters == "abccdefccg"); + } + SECTION("shortening") { + std::string s = "----"; + CHECK(Catch::replaceInPlace(s, "--", "-")); + CHECK(s == "--"); + } + } SECTION("escape '") { std::string s = "didn't"; CHECK(Catch::replaceInPlace(s, "'", "|'")); diff --git a/tests/SelfTest/IntrospectiveTests/TestSpec.tests.cpp b/tests/SelfTest/IntrospectiveTests/TestSpec.tests.cpp index 9c4eb03b1a..11a7a7a836 100644 --- a/tests/SelfTest/IntrospectiveTests/TestSpec.tests.cpp +++ b/tests/SelfTest/IntrospectiveTests/TestSpec.tests.cpp @@ -236,7 +236,7 @@ TEST_CASE( "Parse test names and tags", "[command-line][test-spec][approvals]" ) CHECK( spec.matches( *tcD ) == false ); } SECTION( "two wildcarded names" ) { - TestSpec spec = parseTestSpec( "\"longer*\"\"*spaces\"" ); + TestSpec spec = parseTestSpec( R"("longer*""*spaces")" ); CHECK( spec.hasFilters() == true ); CHECK( spec.matches( *tcA ) == false ); CHECK( spec.matches( *tcB ) == false ); diff --git a/tests/SelfTest/IntrospectiveTests/TextFlow.tests.cpp b/tests/SelfTest/IntrospectiveTests/TextFlow.tests.cpp index 82de5a27f5..de03ed09af 100644 --- a/tests/SelfTest/IntrospectiveTests/TextFlow.tests.cpp +++ b/tests/SelfTest/IntrospectiveTests/TextFlow.tests.cpp @@ -12,6 +12,7 @@ #include using Catch::TextFlow::Column; +using Catch::TextFlow::AnsiSkippingString; namespace { static std::string as_written(Column const& c) { @@ -152,7 +153,7 @@ TEST_CASE( "TextFlow::Column respects indentation for empty lines", std::string written = as_written(col); - REQUIRE(as_written(col) == " \n \n third line"); + REQUIRE(written == " \n \n third line"); } TEST_CASE( "TextFlow::Column leading/trailing whitespace", @@ -198,3 +199,202 @@ TEST_CASE( "#1400 - TextFlow::Column wrapping would sometimes duplicate words", " in \n" " convallis posuere, libero nisi ultricies orci, nec lobortis."); } + +TEST_CASE( "TextFlow::AnsiSkippingString skips ansi sequences", + "[TextFlow][ansiskippingstring][approvals]" ) { + + SECTION("basic string") { + std::string text = "a\033[38;2;98;174;239mb\033[38mc\033[0md\033[me"; + AnsiSkippingString str(text); + + SECTION( "iterates forward" ) { + auto it = str.begin(); + CHECK(*it == 'a'); + ++it; + CHECK(*it == 'b'); + ++it; + CHECK(*it == 'c'); + ++it; + CHECK(*it == 'd'); + ++it; + CHECK(*it == 'e'); + ++it; + CHECK(it == str.end()); + } + SECTION( "iterates backwards" ) { + auto it = str.end(); + --it; + CHECK(*it == 'e'); + --it; + CHECK(*it == 'd'); + --it; + CHECK(*it == 'c'); + --it; + CHECK(*it == 'b'); + --it; + CHECK(*it == 'a'); + CHECK(it == str.begin()); + } + } + + SECTION( "ansi escape sequences at the start" ) { + std::string text = "\033[38;2;98;174;239ma\033[38;2;98;174;239mb\033[38mc\033[0md\033[me"; + AnsiSkippingString str(text); + auto it = str.begin(); + CHECK(*it == 'a'); + ++it; + CHECK(*it == 'b'); + ++it; + CHECK(*it == 'c'); + ++it; + CHECK(*it == 'd'); + ++it; + CHECK(*it == 'e'); + ++it; + CHECK(it == str.end()); + --it; + CHECK(*it == 'e'); + --it; + CHECK(*it == 'd'); + --it; + CHECK(*it == 'c'); + --it; + CHECK(*it == 'b'); + --it; + CHECK(*it == 'a'); + CHECK(it == str.begin()); + } + + SECTION( "ansi escape sequences at the end" ) { + std::string text = "a\033[38;2;98;174;239mb\033[38mc\033[0md\033[me\033[38;2;98;174;239m"; + AnsiSkippingString str(text); + auto it = str.begin(); + CHECK(*it == 'a'); + ++it; + CHECK(*it == 'b'); + ++it; + CHECK(*it == 'c'); + ++it; + CHECK(*it == 'd'); + ++it; + CHECK(*it == 'e'); + ++it; + CHECK(it == str.end()); + --it; + CHECK(*it == 'e'); + --it; + CHECK(*it == 'd'); + --it; + CHECK(*it == 'c'); + --it; + CHECK(*it == 'b'); + --it; + CHECK(*it == 'a'); + CHECK(it == str.begin()); + } + + SECTION( "skips consecutive escapes" ) { + std::string text = "\033[38;2;98;174;239m\033[38;2;98;174;239ma\033[38;2;98;174;239mb\033[38m\033[38m\033[38mc\033[0md\033[me"; + AnsiSkippingString str(text); + auto it = str.begin(); + CHECK(*it == 'a'); + ++it; + CHECK(*it == 'b'); + ++it; + CHECK(*it == 'c'); + ++it; + CHECK(*it == 'd'); + ++it; + CHECK(*it == 'e'); + ++it; + CHECK(it == str.end()); + --it; + CHECK(*it == 'e'); + --it; + CHECK(*it == 'd'); + --it; + CHECK(*it == 'c'); + --it; + CHECK(*it == 'b'); + --it; + CHECK(*it == 'a'); + CHECK(it == str.begin()); + } + + SECTION( "handles incomplete ansi sequences" ) { + std::string text = "a\033[b\033[30c\033[30;d\033[30;2e"; + AnsiSkippingString str(text); + CHECK(std::string(str.begin(), str.end()) == text); + } +} + +TEST_CASE( "TextFlow::AnsiSkippingString computes the size properly", + "[TextFlow][ansiskippingstring][approvals]" ) { + std::string text = "\033[38;2;98;174;239m\033[38;2;98;174;239ma\033[38;2;98;174;239mb\033[38m\033[38m\033[38mc\033[0md\033[me"; + AnsiSkippingString str(text); + CHECK(str.size() == 5); +} + +TEST_CASE( "TextFlow::AnsiSkippingString substrings properly", + "[TextFlow][ansiskippingstring][approvals]" ) { + SECTION("basic test") { + std::string text = "a\033[38;2;98;174;239mb\033[38mc\033[0md\033[me"; + AnsiSkippingString str(text); + auto a = str.begin(); + auto b = str.begin(); + ++b; + ++b; + CHECK(str.substring(a, b) == "a\033[38;2;98;174;239mb\033[38m"); + ++a; + ++b; + CHECK(str.substring(a, b) == "b\033[38mc\033[0m"); + CHECK(str.substring(a, str.end()) == "b\033[38mc\033[0md\033[me"); + CHECK(str.substring(str.begin(), str.end()) == text); + } + SECTION("escapes at the start") { + std::string text = "\033[38;2;98;174;239m\033[38;2;98;174;239ma\033[38;2;98;174;239mb\033[38m\033[38m\033[38mc\033[0md\033[me"; + AnsiSkippingString str(text); + auto a = str.begin(); + auto b = str.begin(); + ++b; + ++b; + CHECK(str.substring(a, b) == "\033[38;2;98;174;239m\033[38;2;98;174;239ma\033[38;2;98;174;239mb\033[38m\033[38m\033[38m"); + ++a; + ++b; + CHECK(str.substring(a, b) == "b\033[38m\033[38m\033[38mc\033[0m"); + CHECK(str.substring(a, str.end()) == "b\033[38m\033[38m\033[38mc\033[0md\033[me"); + CHECK(str.substring(str.begin(), str.end()) == text); + } + SECTION("escapes at the end") { + std::string text = "a\033[38;2;98;174;239mb\033[38mc\033[0md\033[me\033[38m"; + AnsiSkippingString str(text); + auto a = str.begin(); + auto b = str.begin(); + ++b; + ++b; + CHECK(str.substring(a, b) == "a\033[38;2;98;174;239mb\033[38m"); + ++a; + ++b; + CHECK(str.substring(a, b) == "b\033[38mc\033[0m"); + CHECK(str.substring(a, str.end()) == "b\033[38mc\033[0md\033[me\033[38m"); + CHECK(str.substring(str.begin(), str.end()) == text); + } +} + +TEST_CASE( "TextFlow::Column skips ansi escape sequences", + "[TextFlow][column][approvals]" ) { + std::string text = "\033[38;2;98;174;239m\033[38;2;198;120;221mThe quick brown \033[38;2;198;120;221mfox jumped over the lazy dog\033[0m"; + Column col(text); + + SECTION( "width=20" ) { + col.width( 20 ); + REQUIRE( as_written( col ) == "\033[38;2;98;174;239m\033[38;2;198;120;221mThe quick brown \033[38;2;198;120;221mfox\n" + "jumped over the lazy\n" + "dog\033[0m" ); + } + + SECTION( "width=80" ) { + col.width( 80 ); + REQUIRE( as_written( col ) == text ); + } +} diff --git a/tests/SelfTest/TestRegistrations.cpp b/tests/SelfTest/TestRegistrations.cpp index 6476773529..d7a6966fe8 100644 --- a/tests/SelfTest/TestRegistrations.cpp +++ b/tests/SelfTest/TestRegistrations.cpp @@ -20,7 +20,6 @@ CATCH_REGISTER_TAG_ALIAS("[@tricky]", "[tricky]~[.]") #ifdef __clang__ # pragma clang diagnostic ignored "-Wpadded" # pragma clang diagnostic ignored "-Wweak-vtables" -# pragma clang diagnostic ignored "-Wc++98-compat" #endif /** diff --git a/tests/SelfTest/UsageTests/Benchmark.tests.cpp b/tests/SelfTest/UsageTests/Benchmark.tests.cpp index 557b2131c6..c489eaa856 100644 --- a/tests/SelfTest/UsageTests/Benchmark.tests.cpp +++ b/tests/SelfTest/UsageTests/Benchmark.tests.cpp @@ -90,14 +90,14 @@ TEST_CASE("Benchmark containers", "[!benchmark]") { }; REQUIRE(v.size() == size); - int array[size]; + int array[size] {}; BENCHMARK("A fixed size array that should require no allocations") { for (int i = 0; i < size; ++i) array[i] = i; }; int sum = 0; - for (int i = 0; i < size; ++i) - sum += array[i]; + for (int val : array) + sum += val; REQUIRE(sum > size); SECTION("XYZ") { @@ -121,8 +121,8 @@ TEST_CASE("Benchmark containers", "[!benchmark]") { runs = benchmarkIndex; }; - for (size_t i = 0; i < v.size(); ++i) { - REQUIRE(v[i] == runs); + for (int val : v) { + REQUIRE(val == runs); } } } @@ -135,8 +135,8 @@ TEST_CASE("Benchmark containers", "[!benchmark]") { for (int i = 0; i < size; ++i) v[i] = generated; }; - for (size_t i = 0; i < v.size(); ++i) { - REQUIRE(v[i] == generated); + for (int val : v) { + REQUIRE(val == generated); } } diff --git a/tests/SelfTest/UsageTests/Class.tests.cpp b/tests/SelfTest/UsageTests/Class.tests.cpp index bab7a68437..75510f10d0 100644 --- a/tests/SelfTest/UsageTests/Class.tests.cpp +++ b/tests/SelfTest/UsageTests/Class.tests.cpp @@ -32,6 +32,10 @@ namespace { int m_a; }; + struct Persistent_Fixture { + mutable int m_a = 0; + }; + template struct Template_Fixture { Template_Fixture(): m_a( 1 ) {} @@ -39,7 +43,7 @@ namespace { }; template struct Template_Fixture_2 { - Template_Fixture_2() {} + Template_Fixture_2() = default; T m_a; }; @@ -64,6 +68,17 @@ TEST_CASE_METHOD( Fixture, "A TEST_CASE_METHOD based test run that succeeds", "[ REQUIRE( m_a == 1 ); } +TEST_CASE_PERSISTENT_FIXTURE( Persistent_Fixture, "A TEST_CASE_PERSISTENT_FIXTURE based test run that succeeds", "[class]" ) +{ + SECTION( "First partial run" ) { + REQUIRE( m_a++ == 0 ); + } + + SECTION( "Second partial run" ) { + REQUIRE( m_a == 1 ); + } +} + TEMPLATE_TEST_CASE_METHOD(Template_Fixture, "A TEMPLATE_TEST_CASE_METHOD based test run that succeeds", "[class][template]", int, float, double) { REQUIRE( Template_Fixture::m_a == 1 ); } @@ -96,6 +111,17 @@ namespace Inner REQUIRE( m_a == 2 ); } + TEST_CASE_PERSISTENT_FIXTURE( Persistent_Fixture, "A TEST_CASE_PERSISTENT_FIXTURE based test run that fails", "[.][class][failing]" ) + { + SECTION( "First partial run" ) { + REQUIRE( m_a++ == 0 ); + } + + SECTION( "Second partial run" ) { + REQUIRE( m_a == 0 ); + } + } + TEMPLATE_TEST_CASE_METHOD(Template_Fixture,"A TEMPLATE_TEST_CASE_METHOD based test run that fails", "[.][class][template][failing]", int, float, double) { REQUIRE( Template_Fixture::m_a == 2 ); diff --git a/tests/SelfTest/UsageTests/Compilation.tests.cpp b/tests/SelfTest/UsageTests/Compilation.tests.cpp index 1cdcfb788e..a7fbf08fc9 100644 --- a/tests/SelfTest/UsageTests/Compilation.tests.cpp +++ b/tests/SelfTest/UsageTests/Compilation.tests.cpp @@ -313,11 +313,12 @@ TEST_CASE("ADL universal operators don't hijack expression deconstruction", "[co REQUIRE(0 ^ adl::always_true{}); } -TEST_CASE( "#2555 - types that can only be compared with 0 literal (not int/long) are supported", "[compilation][approvals]" ) { +TEST_CASE( "#2555 - types that can only be compared with 0 literal implemented as pointer conversion are supported", + "[compilation][approvals]" ) { REQUIRE( TypeWithLit0Comparisons{} < 0 ); REQUIRE_FALSE( 0 < TypeWithLit0Comparisons{} ); REQUIRE( TypeWithLit0Comparisons{} <= 0 ); - REQUIRE_FALSE( 0 > TypeWithLit0Comparisons{} ); + REQUIRE_FALSE( 0 <= TypeWithLit0Comparisons{} ); REQUIRE( TypeWithLit0Comparisons{} > 0 ); REQUIRE_FALSE( 0 > TypeWithLit0Comparisons{} ); @@ -330,6 +331,105 @@ TEST_CASE( "#2555 - types that can only be compared with 0 literal (not int/long REQUIRE_FALSE( 0 != TypeWithLit0Comparisons{} ); } +// These tests require `consteval` to propagate through `constexpr` calls +// which is a late DR against C++20. +#if defined( CATCH_CPP20_OR_GREATER ) && defined( __cpp_consteval ) && \ + __cpp_consteval >= 202211L +// Can't have internal linkage to avoid warnings +void ZeroLiteralErrorFunc(); +namespace { + struct ZeroLiteralConsteval { + template , int> = 0> + consteval ZeroLiteralConsteval( T zero ) noexcept { + if ( zero != 0 ) { ZeroLiteralErrorFunc(); } + } + }; + + // Should only be constructible from literal 0. Uses the propagating + // consteval constructor trick (currently used by MSVC, might be used + // by libc++ in the future as well). + struct TypeWithConstevalLit0Comparison { +# define DEFINE_COMP_OP( op ) \ + constexpr friend bool operator op( TypeWithConstevalLit0Comparison, \ + ZeroLiteralConsteval ) { \ + return true; \ + } \ + constexpr friend bool operator op( ZeroLiteralConsteval, \ + TypeWithConstevalLit0Comparison ) { \ + return false; \ + } \ + /* std::orderings only have these for ==, but we add them for all \ + operators so we can test all overloads for decomposer */ \ + constexpr friend bool operator op( TypeWithConstevalLit0Comparison, \ + TypeWithConstevalLit0Comparison ) { \ + return true; \ + } + + DEFINE_COMP_OP( < ) + DEFINE_COMP_OP( <= ) + DEFINE_COMP_OP( > ) + DEFINE_COMP_OP( >= ) + DEFINE_COMP_OP( == ) + DEFINE_COMP_OP( != ) + +#undef DEFINE_COMP_OP + }; + +} // namespace + +namespace Catch { + template <> + struct capture_by_value : std::true_type {}; +} + +TEST_CASE( "#2555 - types that can only be compared with 0 literal implemented as consteval check are supported", + "[compilation][approvals]" ) { + REQUIRE( TypeWithConstevalLit0Comparison{} < 0 ); + REQUIRE_FALSE( 0 < TypeWithConstevalLit0Comparison{} ); + REQUIRE( TypeWithConstevalLit0Comparison{} <= 0 ); + REQUIRE_FALSE( 0 <= TypeWithConstevalLit0Comparison{} ); + + REQUIRE( TypeWithConstevalLit0Comparison{} > 0 ); + REQUIRE_FALSE( 0 > TypeWithConstevalLit0Comparison{} ); + REQUIRE( TypeWithConstevalLit0Comparison{} >= 0 ); + REQUIRE_FALSE( 0 >= TypeWithConstevalLit0Comparison{} ); + + REQUIRE( TypeWithConstevalLit0Comparison{} == 0 ); + REQUIRE_FALSE( 0 == TypeWithConstevalLit0Comparison{} ); + REQUIRE( TypeWithConstevalLit0Comparison{} != 0 ); + REQUIRE_FALSE( 0 != TypeWithConstevalLit0Comparison{} ); +} + +// We check all comparison ops to test, even though orderings, the primary +// motivation for this functionality, only have self-comparison (and thus +// have the ambiguity issue) for `==` and `!=`. +TEST_CASE( "Comparing const instances of type registered with capture_by_value", + "[regression][approvals][compilation]" ) { + SECTION("Type with consteval-int constructor") { + auto const const_Lit0Type_1 = TypeWithConstevalLit0Comparison{}; + auto const const_Lit0Type_2 = TypeWithConstevalLit0Comparison{}; + REQUIRE( const_Lit0Type_1 == const_Lit0Type_2 ); + REQUIRE( const_Lit0Type_1 <= const_Lit0Type_2 ); + REQUIRE( const_Lit0Type_1 < const_Lit0Type_2 ); + REQUIRE( const_Lit0Type_1 >= const_Lit0Type_2 ); + REQUIRE( const_Lit0Type_1 > const_Lit0Type_2 ); + REQUIRE( const_Lit0Type_1 != const_Lit0Type_2 ); + } + SECTION("Type with constexpr-int constructor") { + auto const const_Lit0Type_1 = TypeWithLit0Comparisons{}; + auto const const_Lit0Type_2 = TypeWithLit0Comparisons{}; + REQUIRE( const_Lit0Type_1 == const_Lit0Type_2 ); + REQUIRE( const_Lit0Type_1 <= const_Lit0Type_2 ); + REQUIRE( const_Lit0Type_1 < const_Lit0Type_2 ); + REQUIRE( const_Lit0Type_1 >= const_Lit0Type_2 ); + REQUIRE( const_Lit0Type_1 > const_Lit0Type_2 ); + REQUIRE( const_Lit0Type_1 != const_Lit0Type_2 ); + } +} + +#endif // C++20 consteval + + namespace { struct MultipleImplicitConstructors { MultipleImplicitConstructors( double ) {} @@ -353,3 +453,17 @@ TEST_CASE("#2571 - tests compile types that have multiple implicit constructors REQUIRE( mic1 > mic2 ); REQUIRE( mic1 >= mic2 ); } + +#if defined( CATCH_CONFIG_CPP20_COMPARE_OVERLOADS ) +// This test does not test all the related codepaths, but it is the original +// reproducer +TEST_CASE( "Comparing const std::weak_ordering instances must compile", + "[compilation][approvals][regression]" ) { + auto const const_ordering_1 = std::weak_ordering::less; + auto const const_ordering_2 = std::weak_ordering::less; + auto plain_ordering_1 = std::weak_ordering::less; + REQUIRE( const_ordering_1 == plain_ordering_1 ); + REQUIRE( const_ordering_1 == const_ordering_2 ); + REQUIRE( plain_ordering_1 == const_ordering_1 ); +} +#endif diff --git a/tests/SelfTest/UsageTests/Exception.tests.cpp b/tests/SelfTest/UsageTests/Exception.tests.cpp index 4f91a30c47..7c6b0c86a8 100644 --- a/tests/SelfTest/UsageTests/Exception.tests.cpp +++ b/tests/SelfTest/UsageTests/Exception.tests.cpp @@ -119,7 +119,7 @@ TEST_CASE( "When unchecked exceptions are thrown, but caught, they do not affect try { throw std::domain_error( "unexpected exception" ); } - catch(...) {} + catch(...) {} // NOLINT(bugprone-empty-catch) } @@ -152,7 +152,7 @@ TEST_CASE( "Custom exceptions can be translated when testing for throwing as som } TEST_CASE( "Unexpected exceptions can be translated", "[.][failing][!throws]" ) { - throw double( 3.14 ); + throw double( 3.14 ); // NOLINT(readability-redundant-casting): the type is important here, so we want to be explicit } TEST_CASE("Thrown string literals are translated", "[.][failing][!throws]") { diff --git a/tests/SelfTest/UsageTests/Matchers.tests.cpp b/tests/SelfTest/UsageTests/Matchers.tests.cpp index 74bedf5ea9..7c4501c67b 100644 --- a/tests/SelfTest/UsageTests/Matchers.tests.cpp +++ b/tests/SelfTest/UsageTests/Matchers.tests.cpp @@ -1027,7 +1027,6 @@ TEST_CASE( "Combining MatchNotOfGeneric does not nest", } struct EvilAddressOfOperatorUsed : std::exception { - EvilAddressOfOperatorUsed() {} const char* what() const noexcept override { return "overloaded address-of operator of matcher was used instead of " "std::addressof"; @@ -1035,7 +1034,6 @@ struct EvilAddressOfOperatorUsed : std::exception { }; struct EvilCommaOperatorUsed : std::exception { - EvilCommaOperatorUsed() {} const char* what() const noexcept override { return "overloaded comma operator of matcher was used"; } @@ -1073,7 +1071,6 @@ struct ImmovableMatcher : Catch::Matchers::MatcherGenericBase { }; struct MatcherWasMovedOrCopied : std::exception { - MatcherWasMovedOrCopied() {} const char* what() const noexcept override { return "attempted to copy or move a matcher"; } @@ -1081,17 +1078,20 @@ struct MatcherWasMovedOrCopied : std::exception { struct ThrowOnCopyOrMoveMatcher : Catch::Matchers::MatcherGenericBase { ThrowOnCopyOrMoveMatcher() = default; - [[noreturn]] ThrowOnCopyOrMoveMatcher( ThrowOnCopyOrMoveMatcher const& ): - Catch::Matchers::MatcherGenericBase() { + + [[noreturn]] ThrowOnCopyOrMoveMatcher( ThrowOnCopyOrMoveMatcher const& other ): + Catch::Matchers::MatcherGenericBase( other ) { throw MatcherWasMovedOrCopied(); } - [[noreturn]] ThrowOnCopyOrMoveMatcher( ThrowOnCopyOrMoveMatcher&& ): - Catch::Matchers::MatcherGenericBase() { + // NOLINTNEXTLINE(performance-noexcept-move-constructor) + [[noreturn]] ThrowOnCopyOrMoveMatcher( ThrowOnCopyOrMoveMatcher&& other ): + Catch::Matchers::MatcherGenericBase( CATCH_MOVE(other) ) { throw MatcherWasMovedOrCopied(); } ThrowOnCopyOrMoveMatcher& operator=( ThrowOnCopyOrMoveMatcher const& ) { throw MatcherWasMovedOrCopied(); } + // NOLINTNEXTLINE(performance-noexcept-move-constructor) ThrowOnCopyOrMoveMatcher& operator=( ThrowOnCopyOrMoveMatcher&& ) { throw MatcherWasMovedOrCopied(); } diff --git a/tests/SelfTest/UsageTests/Message.tests.cpp b/tests/SelfTest/UsageTests/Message.tests.cpp index 6367bf5918..7626e0055f 100644 --- a/tests/SelfTest/UsageTests/Message.tests.cpp +++ b/tests/SelfTest/UsageTests/Message.tests.cpp @@ -80,20 +80,20 @@ TEST_CASE( "Output from all sections is reported", "[failing][messages][.]" ) { TEST_CASE( "Standard output from all sections is reported", "[messages][.]" ) { SECTION( "one" ) { - std::cout << "Message from section one" << std::endl; + std::cout << "Message from section one\n"; } SECTION( "two" ) { - std::cout << "Message from section two" << std::endl; + std::cout << "Message from section two\n"; } } TEST_CASE( "Standard error is reported and redirected", "[messages][.][approvals]" ) { SECTION( "std::cerr" ) { - std::cerr << "Write to std::cerr" << std::endl; + std::cerr << "Write to std::cerr\n"; } SECTION( "std::clog" ) { - std::clog << "Write to std::clog" << std::endl; + std::clog << "Write to std::clog\n"; } SECTION( "Interleaved writes to cerr and clog" ) { std::cerr << "Inter"; @@ -101,7 +101,7 @@ TEST_CASE( "Standard error is reported and redirected", "[messages][.][approvals std::cerr << ' '; std::clog << "writes"; std::cerr << " to error"; - std::clog << " streams" << std::endl; + std::clog << " streams\n" << std::flush; } } diff --git a/tests/SelfTest/UsageTests/Misc.tests.cpp b/tests/SelfTest/UsageTests/Misc.tests.cpp index 7f06704b41..3697f0695c 100644 --- a/tests/SelfTest/UsageTests/Misc.tests.cpp +++ b/tests/SelfTest/UsageTests/Misc.tests.cpp @@ -11,11 +11,6 @@ #include #include -#ifdef __clang__ -# pragma clang diagnostic ignored "-Wc++98-compat" -# pragma clang diagnostic ignored "-Wc++98-compat-pedantic" -#endif - #include #include @@ -158,9 +153,9 @@ TEST_CASE( "looped tests", "[.][failing]" ) { } TEST_CASE( "Sends stuff to stdout and stderr", "[.]" ) { - std::cout << "A string sent directly to stdout" << std::endl; - std::cerr << "A string sent directly to stderr" << std::endl; - std::clog << "A string sent to stderr via clog" << std::endl; + std::cout << "A string sent directly to stdout\n" << std::flush; + std::cerr << "A string sent directly to stderr\n" << std::flush; + std::clog << "A string sent to stderr via clog\n" << std::flush; } TEST_CASE( "null strings" ) { @@ -396,7 +391,7 @@ TEMPLATE_PRODUCT_TEST_CASE("Product with differing arities", "[template][product using MyTypes = std::tuple; TEMPLATE_LIST_TEST_CASE("Template test case with test types specified inside std::tuple", "[template][list]", MyTypes) { - REQUIRE(sizeof(TestType) > 0); + REQUIRE(std::is_arithmetic::value); } struct NonDefaultConstructibleType { @@ -406,7 +401,7 @@ struct NonDefaultConstructibleType { using MyNonDefaultConstructibleTypes = std::tuple; TEMPLATE_LIST_TEST_CASE("Template test case with test types specified inside non-default-constructible std::tuple", "[template][list]", MyNonDefaultConstructibleTypes) { - REQUIRE(sizeof(TestType) > 0); + REQUIRE(std::is_trivially_copyable::value); } struct NonCopyableAndNonMovableType { @@ -421,7 +416,7 @@ struct NonCopyableAndNonMovableType { using NonCopyableAndNonMovableTypes = std::tuple; TEMPLATE_LIST_TEST_CASE("Template test case with test types specified inside non-copyable and non-movable std::tuple", "[template][list]", NonCopyableAndNonMovableTypes) { - REQUIRE(sizeof(TestType) > 0); + REQUIRE(std::is_default_constructible::value); } // https://github.com/philsquared/Catch/issues/166 diff --git a/tests/SelfTest/UsageTests/ToStringGeneral.tests.cpp b/tests/SelfTest/UsageTests/ToStringGeneral.tests.cpp index 28d60196cb..78c0c80a8d 100644 --- a/tests/SelfTest/UsageTests/ToStringGeneral.tests.cpp +++ b/tests/SelfTest/UsageTests/ToStringGeneral.tests.cpp @@ -14,31 +14,20 @@ TEST_CASE( "Character pretty printing" ){ SECTION("Specifically escaped"){ - char tab = '\t'; - char newline = '\n'; - char carr_return = '\r'; - char form_feed = '\f'; - CHECK(tab == '\t'); - CHECK(newline == '\n'); - CHECK(carr_return == '\r'); - CHECK(form_feed == '\f'); + CHECK(::Catch::Detail::stringify('\t') == "'\\t'"); + CHECK(::Catch::Detail::stringify('\n') == "'\\n'"); + CHECK(::Catch::Detail::stringify('\r') == "'\\r'"); + CHECK(::Catch::Detail::stringify('\f') == "'\\f'"); } SECTION("General chars"){ - char space = ' '; - CHECK(space == ' '); - char chars[] = {'a', 'z', 'A', 'Z'}; - for (int i = 0; i < 4; ++i){ - char c = chars[i]; - REQUIRE(c == chars[i]); - } + CHECK(::Catch::Detail::stringify( ' ' ) == "' '" ); + CHECK(::Catch::Detail::stringify( 'A' ) == "'A'" ); + CHECK(::Catch::Detail::stringify( 'z' ) == "'z'" ); } SECTION("Low ASCII"){ - char null_terminator = '\0'; - CHECK(null_terminator == '\0'); - for (int i = 2; i < 6; ++i){ - char c = static_cast(i); - REQUIRE(c == i); - } + CHECK(::Catch::Detail::stringify( '\0' ) == "0" ); + CHECK(::Catch::Detail::stringify( static_cast(2) ) == "2" ); + CHECK(::Catch::Detail::stringify( static_cast(5) ) == "5" ); } } @@ -135,8 +124,8 @@ TEST_CASE("Precision of floating point stringification can be set", "[toString][ const auto oldPrecision = sm::precision; const float testFloat = 1.12345678901234567899f; - auto str1 = sm::convert(testFloat); sm::precision = 5; + auto str1 = sm::convert( testFloat ); // "1." prefix = 2 chars, f suffix is another char CHECK(str1.size() == 3 + 5); diff --git a/tests/SelfTest/UsageTests/ToStringTuple.tests.cpp b/tests/SelfTest/UsageTests/ToStringTuple.tests.cpp index b2813a8178..9d1d2c462d 100644 --- a/tests/SelfTest/UsageTests/ToStringTuple.tests.cpp +++ b/tests/SelfTest/UsageTests/ToStringTuple.tests.cpp @@ -29,8 +29,8 @@ TEST_CASE( "tuple", "[toString][tuple]" ) TEST_CASE( "tuple", "[toString][tuple]" ) { typedef std::tuple type; - CHECK( "1.2f" == ::Catch::Detail::stringify(float(1.2)) ); - CHECK( "{ 1.2f, 0 }" == ::Catch::Detail::stringify(type{1.2f,0}) ); + CHECK( "1.5f" == ::Catch::Detail::stringify(float(1.5)) ); + CHECK( "{ 1.5f, 0 }" == ::Catch::Detail::stringify(type{1.5f,0}) ); } TEST_CASE( "tuple", "[toString][tuple]" ) @@ -42,8 +42,8 @@ TEST_CASE( "tuple", "[toString][tuple]" ) TEST_CASE( "tuple,tuple<>,float>", "[toString][tuple]" ) { typedef std::tuple,std::tuple<>,float> type; - type value { std::tuple{42}, {}, 1.2f }; - CHECK( "{ { 42 }, { }, 1.2f }" == ::Catch::Detail::stringify(value) ); + type value { std::tuple{42}, {}, 1.5f }; + CHECK( "{ { 42 }, { }, 1.5f }" == ::Catch::Detail::stringify(value) ); } TEST_CASE( "tuple", "[approvals][toString][tuple]" ) { diff --git a/tests/SelfTest/UsageTests/Tricky.tests.cpp b/tests/SelfTest/UsageTests/Tricky.tests.cpp index 25770340a0..041d78675e 100644 --- a/tests/SelfTest/UsageTests/Tricky.tests.cpp +++ b/tests/SelfTest/UsageTests/Tricky.tests.cpp @@ -261,7 +261,7 @@ TEST_CASE( "non streamable - with conv. op", "[Tricky]" ) inline void foo() {} -typedef void (*fooptr_t)(); +using fooptr_t = void (*)(); TEST_CASE( "Comparing function pointers", "[Tricky][function pointer]" ) { @@ -281,7 +281,7 @@ struct S TEST_CASE( "Comparing member function pointers", "[Tricky][member function pointer][approvals]" ) { - typedef void (S::*MF)(); + using MF = void (S::*)(); MF m = &S::f; CHECK( m == &S::f ); diff --git a/tests/SelfTest/helpers/type_with_lit_0_comparisons.hpp b/tests/SelfTest/helpers/type_with_lit_0_comparisons.hpp index 202c3af4d9..a8e517c052 100644 --- a/tests/SelfTest/helpers/type_with_lit_0_comparisons.hpp +++ b/tests/SelfTest/helpers/type_with_lit_0_comparisons.hpp @@ -12,23 +12,34 @@ #include // Should only be constructible from literal 0. +// Based on the constructor from pointer trick, used by libstdc++ and libc++ +// (formerly also MSVC, but they've moved to consteval int constructor). // Used by `TypeWithLit0Comparisons` for testing comparison // ops that only work with literal zero, the way std::*orderings do -struct ZeroLiteralDetector { - constexpr ZeroLiteralDetector( ZeroLiteralDetector* ) noexcept {} +struct ZeroLiteralAsPointer { + constexpr ZeroLiteralAsPointer( ZeroLiteralAsPointer* ) noexcept {} template ::value>> - constexpr ZeroLiteralDetector( T ) = delete; + constexpr ZeroLiteralAsPointer( T ) = delete; }; + struct TypeWithLit0Comparisons { -#define DEFINE_COMP_OP( op ) \ - friend bool operator op( TypeWithLit0Comparisons, ZeroLiteralDetector ) { \ - return true; \ - } \ - friend bool operator op( ZeroLiteralDetector, TypeWithLit0Comparisons ) { \ - return false; \ +#define DEFINE_COMP_OP( op ) \ + constexpr friend bool operator op( TypeWithLit0Comparisons, \ + ZeroLiteralAsPointer ) { \ + return true; \ + } \ + constexpr friend bool operator op( ZeroLiteralAsPointer, \ + TypeWithLit0Comparisons ) { \ + return false; \ + } \ + /* std::orderings only have these for ==, but we add them for all \ + operators so we can test all overloads for decomposer */ \ + constexpr friend bool operator op( TypeWithLit0Comparisons, \ + TypeWithLit0Comparisons ) { \ + return true; \ } DEFINE_COMP_OP( < ) diff --git a/tests/TestScripts/DiscoverTests/CMakeLists.txt b/tests/TestScripts/DiscoverTests/CMakeLists.txt index d19f2f8897..5105cddb64 100644 --- a/tests/TestScripts/DiscoverTests/CMakeLists.txt +++ b/tests/TestScripts/DiscoverTests/CMakeLists.txt @@ -11,6 +11,12 @@ add_executable(tests add_subdirectory(${CATCH2_PATH} catch2-build) target_link_libraries(tests PRIVATE Catch2::Catch2WithMain) -include(CTest) +enable_testing() include(Catch) -catch_discover_tests(tests) +set(extra_args) +if (CMAKE_VERSION GREATER_EQUAL 3.27) + list(APPEND extra_args + DL_PATHS "${CMAKE_CURRENT_LIST_DIR};${CMAKE_CURRENT_LIST_DIR}/.." + ) +endif () +catch_discover_tests(tests ${extra_args}) diff --git a/tests/TestScripts/DiscoverTests/VerifyRegistration.py b/tests/TestScripts/DiscoverTests/VerifyRegistration.py index 9ec42f24ca..9800674f25 100644 --- a/tests/TestScripts/DiscoverTests/VerifyRegistration.py +++ b/tests/TestScripts/DiscoverTests/VerifyRegistration.py @@ -10,7 +10,24 @@ import os import subprocess import sys +import re +import json +cmake_version_regex = re.compile('cmake version (\d+)\.(\d+)\.(\d+)') + +def get_cmake_version(): + result = subprocess.run(['cmake', '--version'], + capture_output = True, + check = True, + text = True) + version_match = cmake_version_regex.match(result.stdout) + if not version_match: + print('Could not find cmake version in output') + print(f"output: '{result.stdout}'") + exit(4) + return (int(version_match.group(1)), + int(version_match.group(2)), + int(version_match.group(3))) def build_project(sources_dir, output_base_path, catch2_path): build_dir = os.path.join(output_base_path, 'ctest-registration-test') @@ -62,8 +79,7 @@ def get_test_names(build_path): root = ET.fromstring(result.stdout) return [tc.text for tc in root.findall('TestCase/Name')] - -def list_ctest_tests(build_path): +def get_ctest_listing(build_path): old_path = os.getcwd() os.chdir(build_path) @@ -73,10 +89,10 @@ def list_ctest_tests(build_path): check = True, text = True) os.chdir(old_path) + return result.stdout - import json - - ctest_response = json.loads(result.stdout) +def extract_tests_from_ctest(ctest_output): + ctest_response = json.loads(ctest_output) tests = ctest_response['tests'] test_names = [] for test in tests: @@ -90,6 +106,15 @@ def list_ctest_tests(build_path): return test_names +def check_DL_PATHS(ctest_output): + ctest_response = json.loads(ctest_output) + tests = ctest_response['tests'] + for test in tests: + properties = test['properties'] + for property in properties: + if property['name'] == 'ENVIRONMENT_MODIFICATION': + assert len(property['value']) == 2, f"The test provides 2 arguments to DL_PATHS, but instead found {len(property['value'])}" + def escape_catch2_test_name(name): for char in ('\\', ',', '[', ']'): name = name.replace(char, f"\\{char}") @@ -106,7 +131,8 @@ def escape_catch2_test_name(name): build_path = build_project(sources_dir, output_base_path, catch2_path) catch_test_names = [escape_catch2_test_name(name) for name in get_test_names(build_path)] - ctest_test_names = list_ctest_tests(build_path) + ctest_output = get_ctest_listing(build_path) + ctest_test_names = extract_tests_from_ctest(ctest_output) mismatched = 0 for catch_test in catch_test_names: @@ -121,3 +147,7 @@ def escape_catch2_test_name(name): if mismatched: print(f"Found {mismatched} mismatched tests catch test names and ctest test commands!") exit(1) + + cmake_version = get_cmake_version() + if cmake_version >= (3, 27): + check_DL_PATHS(ctest_output) diff --git a/tests/TestScripts/testBazelReporter.py b/tests/TestScripts/testBazelReporter.py index d0893f8160..573eafd24f 100644 --- a/tests/TestScripts/testBazelReporter.py +++ b/tests/TestScripts/testBazelReporter.py @@ -52,7 +52,7 @@ ) stdout = ret.stdout except subprocess.SubprocessError as ex: - if ex.returncode == 1: + if ex.returncode == 42: # The test cases are allowed to fail. test_passing = False stdout = ex.stdout diff --git a/tests/TestScripts/testConfigureDefaultReporter.py b/tests/TestScripts/testConfigureDefaultReporter.py index 5bf9787122..119e1ca26c 100644 --- a/tests/TestScripts/testConfigureDefaultReporter.py +++ b/tests/TestScripts/testConfigureDefaultReporter.py @@ -28,14 +28,23 @@ catch2_source_path = os.path.abspath(sys.argv[1]) build_dir_path = os.path.join(os.path.abspath(sys.argv[2]), 'CMakeConfigTests', 'DefaultReporter') +output_file = f"{build_dir_path}/foo.xml" +# We need to escape backslashes in Windows paths, because otherwise they +# are interpreted as escape characters in strings, and cause compilation +# error. +escaped_output_file = output_file.replace('\\', '\\\\') configure_and_build(catch2_source_path, build_dir_path, - [("CATCH_CONFIG_DEFAULT_REPORTER", "xml")]) + [("CATCH_CONFIG_DEFAULT_REPORTER", f"xml::out={escaped_output_file}")]) stdout, _ = run_and_return_output(os.path.join(build_dir_path, 'tests'), 'SelfTest', ['[approx][custom]']) -xml_tag = '' -if xml_tag not in stdout: - print("Could not find '{}' in the stdout".format(xml_tag)) - print('stdout: "{}"'.format(stdout)) +if not os.path.exists(output_file): + print(f'Did not find the {output_file} file') exit(2) + +xml_tag = '' +with open(output_file, 'r', encoding='utf-8') as file: + if xml_tag not in file.read(): + print(f"Could not find '{xml_tag}' in the file") + exit(3) diff --git a/tools/misc/appveyorTestRunScript.bat b/tools/misc/appveyorTestRunScript.bat index 5982fc9290..661bae2406 100644 --- a/tools/misc/appveyorTestRunScript.bat +++ b/tools/misc/appveyorTestRunScript.bat @@ -5,7 +5,7 @@ reg add "HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion\AeDebug\AutoExclusion cd Build if "%CONFIGURATION%"=="Debug" ( if "%coverage%"=="1" ( - ctest -j 2 -C %CONFIGURATION% -D ExperimentalMemCheck || exit /b !ERRORLEVEL! + ctest -j 2 -C %CONFIGURATION% -D ExperimentalMemCheck -LE uses-signals || exit /b !ERRORLEVEL! python ..\tools\misc\appveyorMergeCoverageScript.py || exit /b !ERRORLEVEL! codecov --root .. --no-color --disable gcov -f cobertura.xml -t %CODECOV_TOKEN% || exit /b !ERRORLEVEL! ) else ( diff --git a/tools/scripts/buildAndTest.cmd b/tools/scripts/buildAndTest.cmd index 7c10e564f0..fa3591246c 100644 --- a/tools/scripts/buildAndTest.cmd +++ b/tools/scripts/buildAndTest.cmd @@ -12,6 +12,5 @@ rem 3. Run the actual build cmake --build debug-build rem 4. Run the tests using CTest -cd debug-build -ctest -j 4 --output-on-failure -C Debug +ctest -j 4 --output-on-failure -C Debug --test-dir debug-build rem end-snippet diff --git a/tools/scripts/buildAndTest.sh b/tools/scripts/buildAndTest.sh index 01a82837a3..0383c97ee9 100755 --- a/tools/scripts/buildAndTest.sh +++ b/tools/scripts/buildAndTest.sh @@ -14,6 +14,5 @@ cmake -B debug-build -S . -DCMAKE_BUILD_TYPE=Debug --preset all-tests cmake --build debug-build # 4. Run the tests using CTest -cd debug-build -ctest -j 4 --output-on-failure -C Debug +ctest -j 4 --output-on-failure -C Debug --test-dir debug-build # end-snippet diff --git a/tools/scripts/releaseCommon.py b/tools/scripts/releaseCommon.py index 1ff4af291c..81efa7623c 100644 --- a/tools/scripts/releaseCommon.py +++ b/tools/scripts/releaseCommon.py @@ -89,7 +89,7 @@ def updateCmakeFile(version): def updateMesonFile(version): with open(mesonPath, 'rb') as file: lines = file.readlines() - replacementRegex = re.compile(b'''version\s*:\s*'(\\d+.\\d+.\\d+)', # CML version placeholder, don't delete''') + replacementRegex = re.compile(b'''version\\s*:\\s*'(\\d+.\\d+.\\d+)', # CML version placeholder, don't delete''') replacement = '''version: '{0}', # CML version placeholder, don't delete'''.format(version.getVersionString()).encode('ascii') with open(mesonPath, 'wb') as file: for line in lines: