Compare commits

..
57 Commits
Author SHA1 Message Date
Martin Hořeňovský b5373dadca v3.5.4 2024-04-10 12:05:46 +02:00
Martin Hořeňovský cd8f97e6c7 Explicitly outline TestRegistry destructor into .cpp file
This fixes compilation issue with C++23 mode against libstdc++.

Closes #2852
2024-04-08 13:57:59 +02:00
Martin Hořeňovský 05fb437cbb Fix & extend tests for comparing const instances of zero lit types 2024-04-08 13:15:35 +02:00
Martin Hořeňovský 71b11c4e33 Fix assertion for const instance of std::ordering
The issue was that `capture_by_value` was meant to be specialized
by plain type, e.g. `capture_by_value<std::weak_ordering>`, but
the TMP in Decomposer did not properly throw away `const` (and
`volatile`) qualifiers, before taking the value of `capture_by_value`.
2024-04-08 11:33:43 +02:00
Martin Hořeňovský 0a6a2ce887 Fix preprocessor check for enabling FP reproducibility tests
This solves warning about the `uniform_fp_test_params` helper
being unused on M1 mac (or any other platform using GCC and not
using SSE2).

Closes #2845
2024-04-06 20:27:15 +02:00
Martin Hořeňovský 355a6e273b Add M1 MacOS workflow 2024-04-06 20:27:14 +02:00
Martin Hořeňovský bff6e35e2b Replace last use of std::uniform_int_distribution with our own
Our implementation should be slightly faster, and has the
advantage of being consistent between platforms. This does not
have immediate user impact, because we currently use random_device
to generate random seed for resampling, but if we decide to change
this in the future, it is one less place to fix.
2024-04-03 13:28:26 +02:00
Martin Hořeňovský d99eb8bec8 Optimize 64x64 extended multiplication implementation
Now we use intrinsics when possible, and fallback to optimized
implementation in portable C++. The difference is about 4x when
we can use intrinsics and about 2x when we cannot.

This should speed up our Lemire's algorithm implementation nicely.
2024-04-03 13:28:25 +02:00
Martin Hořeňovský f181de9df4 Use SizedUnsignedType_t to pick UnsignedType for uniform_integer_distribution
The previously used `make_unsigned` approach combined with the overload
set of `extendedMult` caused compilation issues on MacOS platform. By
forcing the selection to be one of `std::uintX_t` types we don't need
to complicate the overload set further.
2024-04-03 13:27:10 +02:00
Martin HořeňovskýandGitHub 9271083a04 Merge pull request #2850 from jeremy-rifkin/jr/mention-succeed-in-loggingmd
Mention SUCCEED along with FAIL in logging.md
2024-03-30 15:59:43 +01:00
Jeremy 07701f946a Mention SUCCEED along with FAIL in logging.md 2024-03-29 15:40:18 -05:00
Martin Hořeňovský 7ce3579976 Allow CATCH_CONFIG_DEFAULT_REPORTER to be arbitrary reporter spec
Previously it could be just plain reporter name, e.g. `xml`, but
it could not specify other reporter options. This change is not
particularly useful for the built-in reporters, as it mostly comes
in handy for combining specific custom reporter with custom arguments,
and the built-in reporters do not have those.
2024-03-27 10:03:51 +01:00
Martin Hořeňovský c0dfe13bb6 Improve example for custom options in reporter spec 2024-03-26 23:28:48 +01:00
Martin Hořeňovský cad65c5003 Fix insufficiently escaped backslash in docs 2024-03-26 23:23:15 +01:00
Martin Hořeňovský ad99834c14 Add back g++ 5 and 6 to the CI builds
Previously these were removed in bbba3d8a06,
to allow Decomposer changes that were not compatible with old
GCCs. However, the compatibility was restored in
459ac8562b, and so we can restore
the builds again.
2024-03-26 18:11:01 +01:00
Martin Hořeňovský 3cd90c5c3b Add tests for multiple args to DL_PATHS in catch_discover_tests 2024-03-26 18:04:17 +01:00
Cristian LeandMartin Hořeňovský 202bdee977 Fix TEST_DL_PATHS to be multi-args
Signed-off-by: Cristian Le <cristian.le@mpsd.mpg.de>
2024-03-26 18:04:17 +01:00
Chris ThrasherandMartin Hořeňovský bfe3ff8f19 Specify minimum C++ version for amalgamated test build
This target previously did not specify its minimum C++ standard.
AppleClang was emitting warnings about the use of C++11 features
which is fixed by telling CMake that this target requires C++14.
Because this target does not link to the existing CMake targets
it never inherited that C++ standard requirement.
2024-03-13 21:12:59 +01:00
Uilian RiesandGitHub a2a3c55058 Improve Conan recipe support (#2831)
* Improve Conan recipe support
* export files
* supports c++14
* update Conan client in the CI
* Better compatibility with Conan 1.x
* Manage options and cppstd for Conan 1.x
* copy eveything from extra


Signed-off-by: Uilian Ries <uilianries@gmail.com>
2024-03-12 22:59:28 +01:00
morinmorinandMartin Hořeňovský eb8f2c5810 Add workaround for unguarded use of __has_extension 2024-03-12 22:57:59 +01:00
Chris ThrasherandMartin Hořeňovský 88f4ec3cc5 Ignore C++98 related compiler warnings
Catch2 has long since required a standard newer than C++98 so we
can safely ignore any warnings related to such old standards.
2024-03-12 22:56:37 +01:00
Chris ThrasherandMartin Hořeňovský 792c3b7549 Stop repeating conditional in endif()
This is not necessary so we can remove it. Most conditionals already
omit this anyways.
2024-03-12 22:55:12 +01:00
Chris ThrasherandMartin Hořeňovský 1a44e6f661 Use built-in CMake feature for requiring a specific language standard
This feature was added in CMake 3.8. Requiring specific language
features is an outdated approach that CMake stopped supporting in
favor of simply specifyin the specific language standard you want.

https://cmake.org/cmake/help/v3.10/prop_gbl/CMAKE_CXX_KNOWN_FEATURES.html
2024-03-12 22:54:09 +01:00
Cristian Morales VegaandMartin Hořeňovský 459ac8562b Fix build with gcc 5.4
The Core Guidelines state "A base class destructor should be either
public and virtual, or protected and non-virtual" so, hopefully, no
static analyser will complain.
2024-03-12 17:15:03 +01:00
Martin Hořeňovský 8ac8190e49 v3.5.3 2024-03-01 22:07:10 +01:00
Martin JeřábekandMartin Hořeňovský b20b365fd2 releaseCommon: fix SyntaxWarning: invalid escape sequence '\s' 2024-03-01 21:24:45 +01:00
Martin JeřábekandMartin Hořeňovský 4d8affc989 less copies and allocations in replaceInPlace 2024-03-01 21:24:45 +01:00
Martin JeřábekandMartin Hořeňovský cde3509664 Fix various useful clang-tidy warnings
* bugprone-branch-clone
* bugprone-copy-constructor-init
* bugprone-empty-catch
* bugprone-sizeof-expression
* bugprone-switch-missing-default-case
* bugprone-unused-local-non-trivial-variable
* clang-analyzer-core.uninitialized.Assign
* clang-analyzer-cplusplus.Move
* clang-analyzer-optin.cplusplus.VirtualCall
* modernize-loop-convert
* modernize-raw-string-literal
* modernize-use-equals-default
* modernize-use-override
* modernize-use-using
* performance-avoid-endl
* performance-inefficient-string-concatenation
* performance-inefficient-vector-operation
* performance-noexcept-move-constructor
* performance-unnecessary-value-param (and improve generator example)
* readability-duplicate-include
* readability-inconsistent-declaration-parameter-name
* readability-non-const-parameter
* readability-redundant-casting
* readability-redundant-member-init
* readability-redundant-smartptr-get
* readability-static-accessed-through-instance
* unused variable in amalgamted tests
2024-03-01 21:24:45 +01:00
Martin JeřábekandMartin Hořeňovský 7677c1658e ci: add clang-tidy run 2024-03-01 21:24:45 +01:00
Martin JeřábekandMartin Hořeňovský 92d3b23913 add .clang-tidy config 2024-03-01 21:24:45 +01:00
Martin JeřábekandMartin Hořeňovský dca87563bb Evaluate argument of TEST_CASE in static-analysis mode 2024-03-01 21:24:45 +01:00
Martin JeřábekandMartin Hořeňovský da303cc668 Evaluate argument of (DYNAMIC_)SECTION in static-analysis mode 2024-03-01 21:24:45 +01:00
Martin Hořeňovský c3fd4eb17e Update outdated tests for stringifying characters
Previously the tests relied purely on output changes in approvals.
Now the stringification output is checked directly as part of the
unit tests.
2024-03-01 15:09:11 +01:00
fb51116d5b Avoid useless FDuration cast in benchmark analysis (#2823)
Co-authored-by: Sven Johannsen <s.johannsen@bretgeld-engineering.de>
2024-02-26 23:25:58 +01:00
Martin Hořeňovský ed6ac8a629 Update AppVeyor exclusion branch pattern for Github Actions 2024-02-23 20:52:04 +01:00
Martin Hořeňovský e7913f1363 Reinstate VS 2017 CI in AppVeyor 2024-02-23 20:51:26 +01:00
James SmithandMartin Hořeňovský 4f3871d53f Compiler compatibility for Visual Studio 2017 (v141) for template friend operator == (#2792).
Make the operator not-friend is a sufficient solution. Closes #2792
2024-02-23 20:45:32 +01:00
Sven JohannsenandMartin Hořeňovský f476bcb633 fix double promotion in catch_approx.cpp 2024-02-21 15:02:13 +01:00
itacud95andGitHub 024cfb3542 Link Android's log with PRIVATE visibility (#2815)
INTERFACE should be used on dependencies from other than our source files.
PRIVATE should be used the include happens in our source files.

In this case (src/catch2/internal/catch_debug_console.cpp:20) the include
is from our source file.

I encountered a issue with this when building Catch2 for Android in
combination with BUILD_SHARED_LIBS. Changing the visibility to PRIVATE
fixes the issue.
2024-02-20 00:32:12 +01:00
Martin Hořeňovský 28c2f0b0c2 Mention x87 and ffast-math breaking FP random gen reproducibility 2024-02-19 15:02:11 +01:00
Martin Hořeňovský 2e1b02a0e2 Document issue with spaceship operator in assertion and MSVC 2024-02-19 15:02:10 +01:00
Martin Hořeňovský 82e9b9b5f2 Update CMake build instructions for current CMake version 2024-02-19 15:02:08 +01:00
Fernando J. Iglesias GarcíaandMartin Hořeňovský 031a163a2c Improve tutorial.md with link to two-file setup instructions. 2024-02-19 15:01:14 +01:00
Martin Hořeňovský 562f31029a Use the same Conan CMake target setup for Conan v1 and v2.
This requires Conan v1 in version 1.53.0 or greater, but that
should not pose a problem in practice.
2024-02-17 23:04:04 +01:00
Devon AdairandGitHub 62d4aecb8c Conan v2 (#2805)
* Removed Conan1 build.py file using conan package tools that are no longer supported

* Working conan 1 and 2 build with the test package. 

updated the test_package to be updated to conan 2 and fixed missing cmake. Still need to check that the license file is packaged up and that the packages look identical before the changes

* Removing debug prints and the license check that isn't working yet

* Working license file copied over as it was before

* Migrated the properties of cpp_info to conan 2. Keeping conan 1 support by checking the version of conan

https://docs.conan.io/1/migrating_to_2.0/properties.html

* Revert "Removed Conan1 build.py file using conan package tools that are no longer supported"

This reverts commit a606d1dfe6.

* Need to add a set_version to parse the version from CMakeLists.txt

Adding a package build yaml to ensure conan keeps building on 1 and 2

* Setting lowercase catch2 for pkg_config and cmake_target_name

* Fixing the namespace for conan file cmake_target_name
2024-02-17 16:42:44 +01:00
Letu RenandMartin Hořeňovský b817497528 Fix number of current reporter
There are nine reporters in Catch2 3.5.2, Automake, compact, console,
JSON, JUnit, SonarQube, TAP, TeamCity and XML.
2024-02-16 21:29:57 +01:00
Julia PaluchandMartin Hořeňovský 4f1b24df77 clarify duration unit in docs 2024-02-16 21:29:19 +01:00
3157d6bbf1 Add Bazel instructions to integration docs (#2812)
Co-authored-by: Fædon Jóhannes Sinis <fs@treble.tech>
2024-02-16 16:58:09 +01:00
Martin Hořeňovský 4570fca24b Remove obsolete C++14 define
There is no reason to have code conditional on C++14, because C++14
is the minimum supported language standard for v3.
2024-02-13 00:01:19 +01:00
Martin Hořeňovský 0787132fc8 Add documentation for the current state of decomposer 2024-02-12 13:43:21 +01:00
Martin Hořeňovský dc51386b9f Support literal-zero detectors using consteval int constructors
This was originally motivated by `REQUIRE((a <=> b) == 0)` no
longer compiling using MSVC. After some investigation, I found
that they changed their implementation of the zero literal
detector from the previous pointer-constructor with deleted
other constructors, into one that uses `consteval` constructor
from int.

This breaks the previous detection logic, because now
`is_foo_comparable<std::strong_ordering, int>` is true, but
actually trying to compare them is a compile-time error...
The solution was to make the decomposition `constexpr` and rely
on a late C++20 DR that makes it so that `consteval` propagates
up through the callstack of `constexpr` functions, until it either
runs out of `constexpr` functions, or succeeds.

However, the default handling of types in decomposition is to
take a reference to them. This reference never becomes dangling,
but because the constexpr evaluation engine cannot prove this,
decomposition paths taking references to objects cannot be
actually evaluated at compilation time. Thankfully we already
did have a value-oriented decomposition path for arithmetic types
(as these are common linkage-less types), so we could just
explicitly spell out the `std::foo_ordering` types as also being
supposed to be decomposed by-value.

Two more fun facts about these changes
 1) The original motivation of the MSVC change was to avoid
    trigering a `Wzero-as-null-pointer-constant` warning. I still
    do not believe this was a good decision.
 2) Current latest version of MSVC does not actually implement the
    aforementioned C++20 DR, so even with this commit, MSVC cannot
    compile `REQUIRE((a <=> b) == 0)`.
2024-02-12 00:52:53 +01:00
Martin Hořeňovský bbba3d8a06 Disable CI for GCC 5 and 6
They can't compile the new constexpr decomposer because
`ITransientExpression` has a defaulted virtual destructor. We could
instead drop the virtual destructor - it only exists to silence
static analysis tools complaining about having virtual functions
without virtual destructor - but GCC 5 and 6 are positively ancient,
so we drop them instead.
2024-02-11 14:36:17 +01:00
Martin Hořeňovský d937427f1f Disable tests for reproducible FP on non-SSE2 x86 targets
Without SSE2 enabled, x86 targets will use x87 FPU, which breaks
the tests checking for reproducible results from our random
floating point number generators. The output is still reproducible,
at least between binaries targetting x87, but the tests hardcode
results for the whole pipeline being done in 32/64bit precision.

Closes #2796
2024-02-11 00:25:24 +01:00
Martin Hořeňovský 2a5de4e447 Fix OOB access when computing -# tag for file without extension
It is unlikely that this would ever come in practice, but there
is no reason to fix it.

Related to #2798
2024-02-10 23:27:19 +01:00
Chris Thrasher 1078e7e95b Fix clang-tidy bugprone-chained-comparison warnings
This triggers when running clang-tidy's bugprone-* family of checks
in code which uses Catch2 even if Catch2 headers are marked as
SYSTEM headers due to how code expanded from macros is treated as
first party even if the macro comes from a 3rd party library. The
fix is luckily pretty straightforward.

This check is added in clang-tidy-18 due for release later this year.
2024-01-24 22:41:00 -07:00
Martin Hořeňovský 79205da6a6 Fix typo in release notes for v3.5.2 2024-01-15 14:23:00 +01:00
Martin Hořeňovský 658acee86e Run tests on all cores in GHA jobs 2024-01-15 14:22:45 +01:00
109 changed files with 1907 additions and 923 deletions
+81
View File
@@ -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: {}
...
+6 -10
View File
@@ -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)
+26 -6
View File
@@ -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 @@ class TestPackageConan(ConanFile):
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'
-1
View File
@@ -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
+50 -2
View File
@@ -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
+1 -2
View File
@@ -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`
+44
View File
@@ -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`
@@ -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
+1
View File
@@ -25,6 +25,7 @@ Build
cmake-build-*
benchmark-dir
.conan/test_package/build
.conan/test_package/CMakeUserPresets.json
bazel-*
build-fuzzers
debug-build
+2 -2
View File
@@ -33,7 +33,7 @@ if (CMAKE_BINARY_DIR STREQUAL CMAKE_CURRENT_SOURCE_DIR)
endif()
project(Catch2
VERSION 3.5.2 # CML version placeholder, don't delete
VERSION 3.5.4 # CML version placeholder, don't delete
LANGUAGES CXX
# HOMEPAGE_URL is not supported until CMake version 3.12, which
# we do not target yet.
@@ -200,4 +200,4 @@ if (NOT_SUBPROJECT)
include( CPack )
endif(NOT_SUBPROJECT)
endif()
+13 -2
View File
@@ -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
Regular → Executable
+99 -32
View File
@@ -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,111 @@ class CatchConan(ConanFile):
url = "https://github.com/catchorg/Catch2"
homepage = url
license = "BSL-1.0"
exports = "LICENSE.txt"
exports_sources = ("src/*", "CMakeLists.txt", "CMake/*", "extras/*")
version = "latest"
settings = "os", "compiler", "build_type", "arch"
generators = "cmake"
options = {
"shared": [True, False],
"fPIC": [True, False],
}
default_options = {
"shared": False,
"fPIC": True,
}
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
@property
def _min_cppstd(self):
return "14"
@property
def _compilers_minimum_version(self):
return {
"gcc": "7",
"Visual Studio": "15",
"msvc": "191",
"clang": "5",
"apple-clang": "10",
}
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("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"]
+19 -1
View File
@@ -384,7 +384,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 +408,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)
+5 -4
View File
@@ -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
<pre>-d, --durations &lt;yes/no></pre>
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.
<pre>-D, --min-duration &lt;value></pre>
> `--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 &lt;value> seconds, in milliseconds. This option is overridden by both
than &lt;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.
+20 -6
View File
@@ -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
+16
View File
@@ -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).
+4
View File
@@ -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.
+51 -1
View File
@@ -2,6 +2,8 @@
# Release notes
**Contents**<br>
[3.5.4](#354)<br>
[3.5.3](#353)<br>
[3.5.2](#352)<br>
[3.5.1](#351)<br>
[3.5.0](#350)<br>
@@ -60,7 +62,55 @@
[Even Older versions](#even-older-versions)<br>
## 3.5.1
## 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)
+1 -1
View File
@@ -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.
+1 -1
View File
@@ -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
+1 -2
View File
@@ -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:
+1 -1
View File
@@ -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()) {
+1 -1
View File
@@ -35,7 +35,7 @@ int main(int argc, char** argv) {
return returnCode;
// if set on the command line then 'height' is now set at this point
std::cout << "height: " << height << std::endl;
std::cout << "height: " << height << '\n';
return session.run();
}
+1 -1
View File
@@ -21,7 +21,7 @@
namespace {
// This class shows how to implement a simple generator for Catch tests
class RandomIntGenerator : public Catch::Generators::IGenerator<int> {
class RandomIntGenerator final : public Catch::Generators::IGenerator<int> {
std::minstd_rand m_rand;
std::uniform_int_distribution<> m_dist;
int current_number;
+9 -8
View File
@@ -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<std::string> {
class LineGenerator final : public Catch::Generators::IGenerator<std::string> {
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<std::string>, which
// is a value-wrapper around std::unique_ptr<IGenerator<std::string>>.
Catch::Generators::GeneratorWrapper<std::string> lines(std::string /* ignored for example */) {
Catch::Generators::GeneratorWrapper<std::string>
lines( std::string const& lines ) {
return Catch::Generators::GeneratorWrapper<std::string>(
new LineGenerator()
);
new LineGenerator( lines ) );
}
} // end anonymous namespace
TEST_CASE("filter can convert types inside the generator expression", "[example][generator]") {
auto num = GENERATE(map<int>([](std::string const& line) { return std::stoi(line); },
lines("fake-file")));
auto num = GENERATE(
map<int>( []( std::string const& line ) { return std::stoi( line ); },
lines( "1\n2\n3\n4\n" ) ) );
REQUIRE(num > 0);
}
+2 -2
View File
@@ -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"
${ARGN}
)
+1 -1
View File
@@ -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")
+66 -43
View File
@@ -6,8 +6,8 @@
// SPDX-License-Identifier: BSL-1.0
// Catch v3.5.2
// Generated: 2024-01-15 14:06:36.675713
// Catch v3.5.4
// Generated: 2024-04-10 12:03:46.281848
// ----------------------------------------------------------
// 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;
@@ -187,7 +187,7 @@ namespace Catch {
double const* last,
Estimator& estimator ) {
auto n = static_cast<size_t>( last - first );
std::uniform_int_distribution<size_t> dist( 0, n - 1 );
Catch::uniform_integer_distribution<size_t> dist( 0, n - 1 );
sample out;
out.reserve( resamples );
@@ -558,7 +558,7 @@ bool marginComparison(double lhs, double rhs, double margin) {
namespace Catch {
Approx::Approx ( double value )
: m_epsilon( std::numeric_limits<float>::epsilon()*100. ),
: m_epsilon( static_cast<double>(std::numeric_limits<float>::epsilon())*100. ),
m_margin( 0.0 ),
m_scale( 0.0 ),
m_value( value )
@@ -807,14 +807,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() ) {
@@ -1038,6 +1040,7 @@ namespace Catch {
m_messages.back().message += " := ";
start = pos;
}
default:; // noop
}
}
assert(openings.empty() && "Mismatched openings");
@@ -1581,8 +1584,10 @@ namespace Catch {
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;
@@ -1966,13 +1971,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 += '"';
@@ -2050,7 +2055,7 @@ std::string StringMaker<char const*>::convert(char const* str) {
return{ "{null string}" };
}
}
std::string StringMaker<char*>::convert(char* str) {
std::string StringMaker<char*>::convert(char* str) { // NOLINT(readability-non-const-parameter)
if (str) {
return Detail::convertIntoString( str );
} else {
@@ -2147,8 +2152,8 @@ std::string StringMaker<signed char>::convert(signed char value) {
std::string StringMaker<char>::convert(char c) {
return ::Catch::Detail::stringify(static_cast<signed char>(c));
}
std::string StringMaker<unsigned char>::convert(unsigned char c) {
return ::Catch::Detail::stringify(static_cast<char>(c));
std::string StringMaker<unsigned char>::convert(unsigned char value) {
return ::Catch::Detail::stringify(static_cast<char>(value));
}
int StringMaker<float>::precision = 5;
@@ -2268,7 +2273,7 @@ namespace Catch {
}
Version const& libraryVersion() {
static Version version( 3, 5, 2, "", 0 );
static Version version( 3, 5, 4, "", 0 );
return version;
}
@@ -3092,7 +3097,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( "," );
}
@@ -3573,21 +3578,21 @@ namespace {
namespace Catch {
Detail::unique_ptr<ColourImpl> makeColourImpl( ColourMode implSelection,
Detail::unique_ptr<ColourImpl> makeColourImpl( ColourMode colourSelection,
IStream* stream ) {
#if defined( CATCH_CONFIG_COLOUR_WIN32 )
if ( implSelection == ColourMode::Win32 ) {
if ( colourSelection == ColourMode::Win32 ) {
return Detail::make_unique<Win32ColourImpl>( stream );
}
#endif
if ( implSelection == ColourMode::ANSI ) {
if ( colourSelection == ColourMode::ANSI ) {
return Detail::make_unique<ANSIColourImpl>( stream );
}
if ( implSelection == ColourMode::None ) {
if ( colourSelection == ColourMode::None ) {
return Detail::make_unique<NoColourImpl>( stream );
}
if ( implSelection == ColourMode::PlatformDefault) {
if ( colourSelection == ColourMode::PlatformDefault) {
#if defined( CATCH_CONFIG_COLOUR_WIN32 )
if ( Win32ColourImpl::useImplementationForStream( *stream ) ) {
return Detail::make_unique<Win32ColourImpl>( stream );
@@ -3599,7 +3604,7 @@ namespace Catch {
return Detail::make_unique<NoColourImpl>( stream );
}
CATCH_ERROR( "Could not create colour impl for selection " << static_cast<int>(implSelection) );
CATCH_ERROR( "Could not create colour impl for selection " << static_cast<int>(colourSelection) );
}
bool isColourImplAvailable( ColourMode colourSelection ) {
@@ -3807,7 +3812,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 &&
@@ -4473,7 +4483,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 },
@@ -4504,7 +4514,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 },
@@ -5283,7 +5293,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
@@ -6297,17 +6307,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<StringRef> splitStringRef( StringRef str, char delimiter ) {
@@ -6581,6 +6603,8 @@ namespace Catch {
return getRegistryHub().getTestCaseRegistry().getAllTestsSorted( config );
}
TestRegistry::~TestRegistry() = default;
void TestRegistry::registerTest(Detail::unique_ptr<TestCaseInfo> testInfo, Detail::unique_ptr<ITestInvoker> testInvoker) {
m_handles.emplace_back(testInfo.get(), testInvoker.get());
m_viewed_test_infos.push_back(testInfo.get());
@@ -9099,8 +9123,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';
@@ -9253,8 +9277,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<CumulativeReporterBase::SectionNode> const&
node ) const {
@@ -9879,8 +9902,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 ) );
@@ -10178,7 +10201,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 );
+261 -135
View File
@@ -6,8 +6,8 @@
// SPDX-License-Identifier: BSL-1.0
// Catch v3.5.2
// Generated: 2024-01-15 14:06:34.036475
// Catch v3.5.4
// Generated: 2024-04-10 12:03:45.785902
// ----------------------------------------------------------
// 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 <TargetConditionals.h>
# 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
@@ -762,8 +765,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);
/**
@@ -2696,11 +2699,11 @@ namespace Catch {
};
template<>
struct StringMaker<signed char> {
static std::string convert(signed char c);
static std::string convert(signed char value);
};
template<>
struct StringMaker<unsigned char> {
static std::string convert(unsigned char c);
static std::string convert(unsigned char value);
};
template<>
@@ -5147,6 +5150,86 @@ namespace Detail {
#include <type_traits>
#include <iosfwd>
/** \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<T&>` and then into `BinaryExpr<T&, U&>`.
*
* 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<T> == b`, it also tries to resolve
* the overload set for `b == ExprLhs<T>`.
*
* 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<T, int>` 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
@@ -5164,8 +5247,39 @@ namespace Detail {
# pragma GCC diagnostic ignored "-Wsign-compare"
#endif
#if defined(CATCH_CPP20_OR_GREATER) && __has_include(<compare>)
# include <compare>
# 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 <typename T>
using RemoveCVRef_t = std::remove_cv_t<std::remove_reference_t<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 <typename T>
struct capture_by_value
: std::integral_constant<bool, std::is_arithmetic<T>{}> {};
#if defined( CATCH_CONFIG_CPP20_COMPARE_OVERLOADS )
template <>
struct capture_by_value<std::strong_ordering> : std::true_type {};
template <>
struct capture_by_value<std::weak_ordering> : std::true_type {};
template <>
struct capture_by_value<std::partial_ordering> : std::true_type {};
#endif
template <typename T>
struct always_false : std::false_type {};
@@ -5174,11 +5288,12 @@ namespace Catch {
bool m_result;
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 )
{}
@@ -5187,14 +5302,13 @@ namespace Catch {
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;
friend std::ostream& operator<<(std::ostream& out, ITransientExpression const& expr) {
expr.streamReconstructedExpression(out);
return out;
}
protected:
~ITransientExpression() = default;
};
void formatReconstructedExpression( std::ostream &os, std::string const& lhs, StringRef op, std::string const& rhs );
@@ -5211,7 +5325,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 ),
@@ -5284,7 +5398,7 @@ namespace Catch {
}
public:
explicit UnaryExpr( LhsT lhs )
explicit constexpr UnaryExpr( LhsT lhs )
: ITransientExpression{ false, static_cast<bool>(lhs) },
m_lhs( lhs )
{}
@@ -5295,31 +5409,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 <typename RhsT> \
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::is_##id##_comparable<LhsT, RhsT>, \
Detail::negation<std::is_arithmetic< \
std::remove_reference_t<RhsT>>>>::value, \
Detail::negation<capture_by_value< \
Detail::RemoveCVRef_t<RhsT>>>>::value, \
BinaryExpr<LhsT, RhsT const&>> { \
return { \
static_cast<bool>( lhs.m_lhs op rhs ), lhs.m_lhs, #op##_sr, rhs }; \
} \
template <typename RhsT> \
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::is_##id##_comparable<LhsT, RhsT>, \
std::is_arithmetic<RhsT>>::value, \
capture_by_value<RhsT>>::value, \
BinaryExpr<LhsT, RhsT>> { \
return { \
static_cast<bool>( lhs.m_lhs op rhs ), lhs.m_lhs, #op##_sr, rhs }; \
} \
template <typename RhsT> \
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##_comparable<LhsT, RhsT>>, \
Detail::is_eq_0_comparable<LhsT>, \
@@ -5332,8 +5446,8 @@ namespace Catch {
static_cast<bool>( lhs.m_lhs op 0 ), lhs.m_lhs, #op##_sr, rhs }; \
} \
template <typename RhsT> \
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##_comparable<LhsT, RhsT>>, \
Detail::is_eq_0_comparable<RhsT>, \
@@ -5350,29 +5464,30 @@ namespace Catch {
#undef CATCH_INTERNAL_DEFINE_EXPRESSION_EQUALITY_OPERATOR
#define CATCH_INTERNAL_DEFINE_EXPRESSION_COMPARISON_OPERATOR( id, op ) \
template <typename RhsT> \
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::is_##id##_comparable<LhsT, RhsT>, \
Detail::negation<std::is_arithmetic< \
std::remove_reference_t<RhsT>>>>::value, \
Detail::negation<capture_by_value< \
Detail::RemoveCVRef_t<RhsT>>>>::value, \
BinaryExpr<LhsT, RhsT const&>> { \
return { \
static_cast<bool>( lhs.m_lhs op rhs ), lhs.m_lhs, #op##_sr, rhs }; \
} \
template <typename RhsT> \
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::is_##id##_comparable<LhsT, RhsT>, \
std::is_arithmetic<RhsT>>::value, \
capture_by_value<RhsT>>::value, \
BinaryExpr<LhsT, RhsT>> { \
return { \
static_cast<bool>( lhs.m_lhs op rhs ), lhs.m_lhs, #op##_sr, rhs }; \
} \
template <typename RhsT> \
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##_comparable<LhsT, RhsT>>, \
Detail::is_##id##_0_comparable<LhsT>, \
@@ -5383,8 +5498,8 @@ namespace Catch {
static_cast<bool>( lhs.m_lhs op 0 ), lhs.m_lhs, #op##_sr, rhs }; \
} \
template <typename RhsT> \
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##_comparable<LhsT, RhsT>>, \
Detail::is_##id##_0_comparable<RhsT>, \
@@ -5404,17 +5519,17 @@ namespace Catch {
#define CATCH_INTERNAL_DEFINE_EXPRESSION_OPERATOR( op ) \
template <typename RhsT> \
friend auto operator op( ExprLhs&& lhs, RhsT&& rhs ) \
->std::enable_if_t< \
!std::is_arithmetic<std::remove_reference_t<RhsT>>::value, \
constexpr friend auto operator op( ExprLhs&& lhs, RhsT&& rhs ) \
-> std::enable_if_t< \
!capture_by_value<Detail::RemoveCVRef_t<RhsT>>::value, \
BinaryExpr<LhsT, RhsT const&>> { \
return { \
static_cast<bool>( lhs.m_lhs op rhs ), lhs.m_lhs, #op##_sr, rhs }; \
} \
template <typename RhsT> \
friend auto operator op( ExprLhs&& lhs, RhsT rhs ) \
->std::enable_if_t<std::is_arithmetic<RhsT>::value, \
BinaryExpr<LhsT, RhsT>> { \
constexpr friend auto operator op( ExprLhs&& lhs, RhsT rhs ) \
-> std::enable_if_t<capture_by_value<RhsT>::value, \
BinaryExpr<LhsT, RhsT>> { \
return { \
static_cast<bool>( lhs.m_lhs op rhs ), lhs.m_lhs, #op##_sr, rhs }; \
}
@@ -5439,19 +5554,22 @@ namespace Catch {
"wrap the expression inside parentheses, or decompose it");
}
auto makeUnaryExpr() const -> UnaryExpr<LhsT> {
constexpr auto makeUnaryExpr() const -> UnaryExpr<LhsT> {
return UnaryExpr<LhsT>{ m_lhs };
}
};
struct Decomposer {
template<typename T, std::enable_if_t<!std::is_arithmetic<std::remove_reference_t<T>>::value, int> = 0>
friend auto operator <= ( Decomposer &&, T && lhs ) -> ExprLhs<T const&> {
template <typename T,
std::enable_if_t<!capture_by_value<Detail::RemoveCVRef_t<T>>::value,
int> = 0>
constexpr friend auto operator <= ( Decomposer &&, T && lhs ) -> ExprLhs<T const&> {
return ExprLhs<const T&>{ lhs };
}
template<typename T, std::enable_if_t<std::is_arithmetic<T>::value, int> = 0>
friend auto operator <= ( Decomposer &&, T value ) -> ExprLhs<T> {
template <typename T,
std::enable_if_t<capture_by_value<T>::value, int> = 0>
constexpr friend auto operator <= ( Decomposer &&, T value ) -> ExprLhs<T> {
return ExprLhs<T>{ value };
}
};
@@ -5571,7 +5689,7 @@ 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 ) \
@@ -5786,7 +5904,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
@@ -5797,7 +5917,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
@@ -5807,7 +5928,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
@@ -5929,7 +6051,7 @@ struct AutoReg : Detail::NonCopyable {
namespace Catch {
namespace Detail {
struct DummyUse {
DummyUse( void ( * )( int ) );
DummyUse( void ( * )( int ), Catch::NameAndTags const& );
};
} // namespace Detail
} // namespace Catch
@@ -5941,18 +6063,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
@@ -6935,7 +7057,7 @@ namespace Catch {
struct TestCaseInfo : Detail::NonCopyable {
TestCaseInfo(StringRef _className,
NameAndTags const& _tags,
NameAndTags const& _nameAndTags,
SourceLineInfo const& _lineInfo);
bool isHidden() const;
@@ -7148,7 +7270,7 @@ namespace Catch {
#define CATCH_VERSION_MAJOR 3
#define CATCH_VERSION_MINOR 5
#define CATCH_VERSION_PATCH 2
#define CATCH_VERSION_PATCH 4
#endif // CATCH_VERSION_MACROS_HPP_INCLUDED
@@ -7820,6 +7942,32 @@ namespace Catch {
#include <cstdint>
#include <type_traits>
// 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
#elif defined( _MSC_VER ) && ( defined( _WIN64 ) || defined( _M_ARM64 ) )
# 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 <intrin.h>
# pragma intrinsic( _umul128 )
#endif
namespace Catch {
namespace Detail {
@@ -7847,65 +7995,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;
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<std::uint64_t>
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 )
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 );
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 );
// 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<std::uint64_t>
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<std::uint64_t>( result >> 64 ),
static_cast<std::uint64_t>( 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 <typename UInt>
constexpr ExtendedMultResult<UInt> extendedMult( UInt lhs, UInt rhs ) {
static_assert( std::is_unsigned<UInt>::value,
@@ -8009,22 +8149,6 @@ namespace Catch {
namespace Catch {
namespace Detail {
// Indirection to enable make_unsigned<bool> behaviour.
template <typename T>
struct make_unsigned {
using type = std::make_unsigned_t<T>;
};
template <>
struct make_unsigned<bool> {
using type = uint8_t;
};
template <typename T>
using make_unsigned_t = typename make_unsigned<T>::type;
}
/**
* Implementation of uniform distribution on integers.
*
@@ -8040,7 +8164,7 @@ template <typename IntegerType>
class uniform_integer_distribution {
static_assert(std::is_integral<IntegerType>::value, "...");
using UnsignedIntegerType = Detail::make_unsigned_t<IntegerType>;
using UnsignedIntegerType = Detail::SizedUnsignedType_t<sizeof(IntegerType)>;
// Only the left bound is stored, and we store it converted to its
// unsigned image. This avoids having to do the conversions inside
@@ -9322,7 +9446,7 @@ namespace Catch {
std::vector<Catch::Detail::unique_ptr<EnumInfo>> m_enumInfos;
EnumInfo const& registerEnum( StringRef enumName, StringRef allEnums, std::vector<int> const& values) override;
EnumInfo const& registerEnum( StringRef enumName, StringRef allValueNames, std::vector<int> const& values) override;
};
std::vector<StringRef> parseEnums( StringRef enums );
@@ -9795,7 +9919,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();
@@ -9814,7 +9938,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();
@@ -10709,6 +10833,8 @@ namespace Catch {
std::vector<TestCaseHandle> const& getAllTests() const override;
std::vector<TestCaseHandle> const& getAllTestsSorted( IConfig const& config ) const override;
~TestRegistry() override; // = default
private:
std::vector<Detail::unique_ptr<TestCaseInfo>> m_owned_test_infos;
// Keeps a materialized vector for `getAllInfos`.
@@ -13454,7 +13580,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;
@@ -13622,7 +13748,7 @@ namespace Catch {
xml.endElement();
}
void writeRun( TestRunNode const& groupNode );
void writeRun( TestRunNode const& runNode );
void writeTestFile(StringRef filename, std::vector<TestCaseNode const*> const& testCaseNodes);
@@ -13707,8 +13833,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;
+1 -1
View File
@@ -8,7 +8,7 @@
project(
'catch2',
'cpp',
version: '3.5.2', # CML version placeholder, don't delete
version: '3.5.4', # CML version placeholder, don't delete
license: 'BSL-1.0',
meson_version: '>=0.54.1',
)
+4 -42
View File
@@ -354,7 +354,7 @@ 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
@@ -362,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(
@@ -475,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()
@@ -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;
+2 -1
View File
@@ -12,6 +12,7 @@
#include <catch2/internal/catch_compiler_capabilities.hpp>
#include <catch2/internal/catch_floating_point_helpers.hpp>
#include <catch2/internal/catch_random_number_generator.hpp>
#include <catch2/internal/catch_uniform_integer_distribution.hpp>
#include <algorithm>
#include <cassert>
@@ -38,7 +39,7 @@ namespace Catch {
double const* last,
Estimator& estimator ) {
auto n = static_cast<size_t>( last - first );
std::uniform_int_distribution<size_t> dist( 0, n - 1 );
Catch::uniform_integer_distribution<size_t> dist( 0, n - 1 );
sample out;
out.reserve( resamples );
+1 -1
View File
@@ -25,7 +25,7 @@ bool marginComparison(double lhs, double rhs, double margin) {
namespace Catch {
Approx::Approx ( double value )
: m_epsilon( std::numeric_limits<float>::epsilon()*100. ),
: m_epsilon( static_cast<double>(std::numeric_limits<float>::epsilon())*100. ),
m_margin( 0.0 ),
m_scale( 0.0 ),
m_value( value )
+7 -5
View File
@@ -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() ) {
+1
View File
@@ -91,6 +91,7 @@ namespace Catch {
m_messages.back().message += " := ";
start = pos;
}
default:; // noop
}
}
assert(openings.empty() && "Mismatched openings");
-1
View File
@@ -20,7 +20,6 @@
#include <catch2/internal/catch_noncopyable.hpp>
#include <catch2/interfaces/catch_interfaces_reporter_factory.hpp>
#include <catch2/internal/catch_move_and_forward.hpp>
#include <catch2/internal/catch_reporter_registry.hpp>
#include <exception>
+3 -1
View File
@@ -85,8 +85,10 @@ namespace Catch {
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;
+1 -1
View File
@@ -68,7 +68,7 @@ namespace Catch {
struct TestCaseInfo : Detail::NonCopyable {
TestCaseInfo(StringRef _className,
NameAndTags const& _tags,
NameAndTags const& _nameAndTags,
SourceLineInfo const& _lineInfo);
bool isHidden() const;
+5 -5
View File
@@ -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<char const*>::convert(char const* str) {
return{ "{null string}" };
}
}
std::string StringMaker<char*>::convert(char* str) {
std::string StringMaker<char*>::convert(char* str) { // NOLINT(readability-non-const-parameter)
if (str) {
return Detail::convertIntoString( str );
} else {
@@ -235,8 +235,8 @@ std::string StringMaker<signed char>::convert(signed char value) {
std::string StringMaker<char>::convert(char c) {
return ::Catch::Detail::stringify(static_cast<signed char>(c));
}
std::string StringMaker<unsigned char>::convert(unsigned char c) {
return ::Catch::Detail::stringify(static_cast<char>(c));
std::string StringMaker<unsigned char>::convert(unsigned char value) {
return ::Catch::Detail::stringify(static_cast<char>(value));
}
int StringMaker<float>::precision = 5;
+2 -2
View File
@@ -279,11 +279,11 @@ namespace Catch {
};
template<>
struct StringMaker<signed char> {
static std::string convert(signed char c);
static std::string convert(signed char value);
};
template<>
struct StringMaker<unsigned char> {
static std::string convert(unsigned char c);
static std::string convert(unsigned char value);
};
template<>
+1 -1
View File
@@ -36,7 +36,7 @@ namespace Catch {
}
Version const& libraryVersion() {
static Version version( 3, 5, 2, "", 0 );
static Version version( 3, 5, 4, "", 0 );
return version;
}
+1 -1
View File
@@ -10,6 +10,6 @@
#define CATCH_VERSION_MAJOR 3
#define CATCH_VERSION_MINOR 5
#define CATCH_VERSION_PATCH 2
#define CATCH_VERSION_PATCH 4
#endif // CATCH_VERSION_MACROS_HPP_INCLUDED
+1 -1
View File
@@ -47,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( "," );
}
@@ -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
+6 -6
View File
@@ -230,21 +230,21 @@ namespace {
namespace Catch {
Detail::unique_ptr<ColourImpl> makeColourImpl( ColourMode implSelection,
Detail::unique_ptr<ColourImpl> makeColourImpl( ColourMode colourSelection,
IStream* stream ) {
#if defined( CATCH_CONFIG_COLOUR_WIN32 )
if ( implSelection == ColourMode::Win32 ) {
if ( colourSelection == ColourMode::Win32 ) {
return Detail::make_unique<Win32ColourImpl>( stream );
}
#endif
if ( implSelection == ColourMode::ANSI ) {
if ( colourSelection == ColourMode::ANSI ) {
return Detail::make_unique<ANSIColourImpl>( stream );
}
if ( implSelection == ColourMode::None ) {
if ( colourSelection == ColourMode::None ) {
return Detail::make_unique<NoColourImpl>( stream );
}
if ( implSelection == ColourMode::PlatformDefault) {
if ( colourSelection == ColourMode::PlatformDefault) {
#if defined( CATCH_CONFIG_COLOUR_WIN32 )
if ( Win32ColourImpl::useImplementationForStream( *stream ) ) {
return Detail::make_unique<Win32ColourImpl>( stream );
@@ -256,7 +256,7 @@ namespace Catch {
return Detail::make_unique<NoColourImpl>( stream );
}
CATCH_ERROR( "Could not create colour impl for selection " << static_cast<int>(implSelection) );
CATCH_ERROR( "Could not create colour impl for selection " << static_cast<int>(colourSelection) );
}
bool isColourImplAvailable( ColourMode colourSelection ) {
+6 -1
View File
@@ -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 &&
+160 -44
View File
@@ -13,10 +13,91 @@
#include <catch2/internal/catch_compare_traits.hpp>
#include <catch2/internal/catch_test_failure_exception.hpp>
#include <catch2/internal/catch_logical_traits.hpp>
#include <catch2/internal/catch_compiler_capabilities.hpp>
#include <type_traits>
#include <iosfwd>
/** \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<T&>` and then into `BinaryExpr<T&, U&>`.
*
* 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<T> == b`, it also tries to resolve
* the overload set for `b == ExprLhs<T>`.
*
* 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<T, int>` 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
@@ -34,8 +115,39 @@
# pragma GCC diagnostic ignored "-Wsign-compare"
#endif
#if defined(CATCH_CPP20_OR_GREATER) && __has_include(<compare>)
# include <compare>
# 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 <typename T>
using RemoveCVRef_t = std::remove_cv_t<std::remove_reference_t<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 <typename T>
struct capture_by_value
: std::integral_constant<bool, std::is_arithmetic<T>{}> {};
#if defined( CATCH_CONFIG_CPP20_COMPARE_OVERLOADS )
template <>
struct capture_by_value<std::strong_ordering> : std::true_type {};
template <>
struct capture_by_value<std::weak_ordering> : std::true_type {};
template <>
struct capture_by_value<std::partial_ordering> : std::true_type {};
#endif
template <typename T>
struct always_false : std::false_type {};
@@ -44,11 +156,12 @@ namespace Catch {
bool m_result;
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 )
{}
@@ -57,14 +170,13 @@ namespace Catch {
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;
friend std::ostream& operator<<(std::ostream& out, ITransientExpression const& expr) {
expr.streamReconstructedExpression(out);
return out;
}
protected:
~ITransientExpression() = default;
};
void formatReconstructedExpression( std::ostream &os, std::string const& lhs, StringRef op, std::string const& rhs );
@@ -81,7 +193,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 +266,7 @@ namespace Catch {
}
public:
explicit UnaryExpr( LhsT lhs )
explicit constexpr UnaryExpr( LhsT lhs )
: ITransientExpression{ false, static_cast<bool>(lhs) },
m_lhs( lhs )
{}
@@ -165,31 +277,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 <typename RhsT> \
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::is_##id##_comparable<LhsT, RhsT>, \
Detail::negation<std::is_arithmetic< \
std::remove_reference_t<RhsT>>>>::value, \
Detail::negation<capture_by_value< \
Detail::RemoveCVRef_t<RhsT>>>>::value, \
BinaryExpr<LhsT, RhsT const&>> { \
return { \
static_cast<bool>( lhs.m_lhs op rhs ), lhs.m_lhs, #op##_sr, rhs }; \
} \
template <typename RhsT> \
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::is_##id##_comparable<LhsT, RhsT>, \
std::is_arithmetic<RhsT>>::value, \
capture_by_value<RhsT>>::value, \
BinaryExpr<LhsT, RhsT>> { \
return { \
static_cast<bool>( lhs.m_lhs op rhs ), lhs.m_lhs, #op##_sr, rhs }; \
} \
template <typename RhsT> \
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##_comparable<LhsT, RhsT>>, \
Detail::is_eq_0_comparable<LhsT>, \
@@ -202,8 +314,8 @@ namespace Catch {
static_cast<bool>( lhs.m_lhs op 0 ), lhs.m_lhs, #op##_sr, rhs }; \
} \
template <typename RhsT> \
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##_comparable<LhsT, RhsT>>, \
Detail::is_eq_0_comparable<RhsT>, \
@@ -220,29 +332,30 @@ namespace Catch {
#undef CATCH_INTERNAL_DEFINE_EXPRESSION_EQUALITY_OPERATOR
#define CATCH_INTERNAL_DEFINE_EXPRESSION_COMPARISON_OPERATOR( id, op ) \
template <typename RhsT> \
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::is_##id##_comparable<LhsT, RhsT>, \
Detail::negation<std::is_arithmetic< \
std::remove_reference_t<RhsT>>>>::value, \
Detail::negation<capture_by_value< \
Detail::RemoveCVRef_t<RhsT>>>>::value, \
BinaryExpr<LhsT, RhsT const&>> { \
return { \
static_cast<bool>( lhs.m_lhs op rhs ), lhs.m_lhs, #op##_sr, rhs }; \
} \
template <typename RhsT> \
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::is_##id##_comparable<LhsT, RhsT>, \
std::is_arithmetic<RhsT>>::value, \
capture_by_value<RhsT>>::value, \
BinaryExpr<LhsT, RhsT>> { \
return { \
static_cast<bool>( lhs.m_lhs op rhs ), lhs.m_lhs, #op##_sr, rhs }; \
} \
template <typename RhsT> \
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##_comparable<LhsT, RhsT>>, \
Detail::is_##id##_0_comparable<LhsT>, \
@@ -253,8 +366,8 @@ namespace Catch {
static_cast<bool>( lhs.m_lhs op 0 ), lhs.m_lhs, #op##_sr, rhs }; \
} \
template <typename RhsT> \
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##_comparable<LhsT, RhsT>>, \
Detail::is_##id##_0_comparable<RhsT>, \
@@ -274,17 +387,17 @@ namespace Catch {
#define CATCH_INTERNAL_DEFINE_EXPRESSION_OPERATOR( op ) \
template <typename RhsT> \
friend auto operator op( ExprLhs&& lhs, RhsT&& rhs ) \
->std::enable_if_t< \
!std::is_arithmetic<std::remove_reference_t<RhsT>>::value, \
constexpr friend auto operator op( ExprLhs&& lhs, RhsT&& rhs ) \
-> std::enable_if_t< \
!capture_by_value<Detail::RemoveCVRef_t<RhsT>>::value, \
BinaryExpr<LhsT, RhsT const&>> { \
return { \
static_cast<bool>( lhs.m_lhs op rhs ), lhs.m_lhs, #op##_sr, rhs }; \
} \
template <typename RhsT> \
friend auto operator op( ExprLhs&& lhs, RhsT rhs ) \
->std::enable_if_t<std::is_arithmetic<RhsT>::value, \
BinaryExpr<LhsT, RhsT>> { \
constexpr friend auto operator op( ExprLhs&& lhs, RhsT rhs ) \
-> std::enable_if_t<capture_by_value<RhsT>::value, \
BinaryExpr<LhsT, RhsT>> { \
return { \
static_cast<bool>( lhs.m_lhs op rhs ), lhs.m_lhs, #op##_sr, rhs }; \
}
@@ -309,19 +422,22 @@ namespace Catch {
"wrap the expression inside parentheses, or decompose it");
}
auto makeUnaryExpr() const -> UnaryExpr<LhsT> {
constexpr auto makeUnaryExpr() const -> UnaryExpr<LhsT> {
return UnaryExpr<LhsT>{ m_lhs };
}
};
struct Decomposer {
template<typename T, std::enable_if_t<!std::is_arithmetic<std::remove_reference_t<T>>::value, int> = 0>
friend auto operator <= ( Decomposer &&, T && lhs ) -> ExprLhs<T const&> {
template <typename T,
std::enable_if_t<!capture_by_value<Detail::RemoveCVRef_t<T>>::value,
int> = 0>
constexpr friend auto operator <= ( Decomposer &&, T && lhs ) -> ExprLhs<T const&> {
return ExprLhs<const T&>{ lhs };
}
template<typename T, std::enable_if_t<std::is_arithmetic<T>::value, int> = 0>
friend auto operator <= ( Decomposer &&, T value ) -> ExprLhs<T> {
template <typename T,
std::enable_if_t<capture_by_value<T>::value, int> = 0>
constexpr friend auto operator <= ( Decomposer &&, T value ) -> ExprLhs<T> {
return ExprLhs<T>{ value };
}
};
@@ -24,7 +24,7 @@ namespace Catch {
std::vector<Catch::Detail::unique_ptr<EnumInfo>> m_enumInfos;
EnumInfo const& registerEnum( StringRef enumName, StringRef allEnums, std::vector<int> const& values) override;
EnumInfo const& registerEnum( StringRef enumName, StringRef allValueNames, std::vector<int> const& values) override;
};
std::vector<StringRef> parseEnums( StringRef enums );
+2 -2
View File
@@ -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 },
+2 -2
View File
@@ -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();
+3
View File
@@ -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 <TargetConditionals.h>
# if (defined(TARGET_OS_OSX) && TARGET_OS_OSX == 1) || \
(defined(TARGET_OS_MAC) && TARGET_OS_MAC == 1)
@@ -14,6 +14,32 @@
#include <cstdint>
#include <type_traits>
// 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
#elif defined( _MSC_VER ) && ( defined( _WIN64 ) || defined( _M_ARM64 ) )
# 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 <intrin.h>
# pragma intrinsic( _umul128 )
#endif
namespace Catch {
namespace Detail {
@@ -41,65 +67,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;
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<std::uint64_t>
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 )
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 );
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 );
// 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<std::uint64_t>
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<std::uint64_t>( result >> 64 ),
static_cast<std::uint64_t>( 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 <typename UInt>
constexpr ExtendedMultResult<UInt> extendedMult( UInt lhs, UInt rhs ) {
static_assert( std::is_unsigned<UInt>::value,
@@ -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
+7 -3
View File
@@ -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
+20 -7
View File
@@ -5,6 +5,7 @@
// https://www.boost.org/LICENSE_1_0.txt)
// SPDX-License-Identifier: BSL-1.0
#include <catch2/internal/catch_move_and_forward.hpp>
#include <catch2/internal/catch_string_manip.hpp>
#include <catch2/internal/catch_stringref.hpp>
@@ -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<StringRef> splitStringRef( StringRef str, char delimiter ) {
+2 -2
View File
@@ -97,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);
/**
@@ -123,6 +123,8 @@ namespace Catch {
return getRegistryHub().getTestCaseRegistry().getAllTestsSorted( config );
}
TestRegistry::~TestRegistry() = default;
void TestRegistry::registerTest(Detail::unique_ptr<TestCaseInfo> testInfo, Detail::unique_ptr<ITestInvoker> testInvoker) {
m_handles.emplace_back(testInfo.get(), testInvoker.get());
m_viewed_test_infos.push_back(testInfo.get());
@@ -36,6 +36,8 @@ namespace Catch {
std::vector<TestCaseHandle> const& getAllTests() const override;
std::vector<TestCaseHandle> const& getAllTestsSorted( IConfig const& config ) const override;
~TestRegistry() override; // = default
private:
std::vector<Detail::unique_ptr<TestCaseInfo>> m_owned_test_infos;
// Keeps a materialized vector for `getAllInfos`.
@@ -49,7 +49,7 @@
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 ) \
+4 -4
View File
@@ -95,7 +95,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 +107,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
@@ -13,22 +13,6 @@
namespace Catch {
namespace Detail {
// Indirection to enable make_unsigned<bool> behaviour.
template <typename T>
struct make_unsigned {
using type = std::make_unsigned_t<T>;
};
template <>
struct make_unsigned<bool> {
using type = uint8_t;
};
template <typename T>
using make_unsigned_t = typename make_unsigned<T>::type;
}
/**
* Implementation of uniform distribution on integers.
*
@@ -44,7 +28,7 @@ template <typename IntegerType>
class uniform_integer_distribution {
static_assert(std::is_integral<IntegerType>::value, "...");
using UnsignedIntegerType = Detail::make_unsigned_t<IntegerType>;
using UnsignedIntegerType = Detail::SizedUnsignedType_t<sizeof(IntegerType)>;
// Only the left bound is stored, and we store it converted to its
// unsigned image. This avoids having to do the conversions inside
@@ -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';
@@ -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<CumulativeReporterBase::SectionNode> const&
node ) const {
+2 -2
View File
@@ -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 ) );
@@ -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 );
@@ -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;
@@ -37,7 +37,7 @@ namespace Catch {
xml.endElement();
}
void writeRun( TestRunNode const& groupNode );
void writeRun( TestRunNode const& runNode );
void writeTestFile(StringRef filename, std::vector<TestCaseNode const*> const& testCaseNodes);
@@ -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;
+2 -2
View File
@@ -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
+2 -1
View File
@@ -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")
@@ -556,6 +556,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(
@@ -34,7 +34,7 @@ public:
return "Custom reporter for testing cumulative reporter base";
}
virtual void testRunEndedCumulative() override;
void testRunEndedCumulative() override;
};
CATCH_REGISTER_REPORTER("testReporter", CumulativeBenchmarkReporter)
@@ -36,6 +36,7 @@ public:
void testRunStarting( Catch::TestRunInfo const& ) override {
std::vector<std::pair<std::string, std::string>> options;
options.reserve( m_customOptions.size() );
for ( auto const& kv : m_customOptions ) {
options.push_back( kv );
}
+2 -2
View File
@@ -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>([](int i) {
@@ -350,20 +350,16 @@ Details.tests.cpp:<line number>: passed: lt( "a", "b" ) for: true
Details.tests.cpp:<line number>: passed: lt( "a", "B" ) for: true
Details.tests.cpp:<line number>: passed: lt( "A", "b" ) for: true
Details.tests.cpp:<line number>: passed: lt( "A", "B" ) for: true
ToStringGeneral.tests.cpp:<line number>: passed: tab == '\t' for: '\t' == '\t'
ToStringGeneral.tests.cpp:<line number>: passed: newline == '\n' for: '\n' == '\n'
ToStringGeneral.tests.cpp:<line number>: passed: carr_return == '\r' for: '\r' == '\r'
ToStringGeneral.tests.cpp:<line number>: passed: form_feed == '\f' for: '\f' == '\f'
ToStringGeneral.tests.cpp:<line number>: passed: space == ' ' for: ' ' == ' '
ToStringGeneral.tests.cpp:<line number>: passed: c == chars[i] for: 'a' == 'a'
ToStringGeneral.tests.cpp:<line number>: passed: c == chars[i] for: 'z' == 'z'
ToStringGeneral.tests.cpp:<line number>: passed: c == chars[i] for: 'A' == 'A'
ToStringGeneral.tests.cpp:<line number>: passed: c == chars[i] for: 'Z' == 'Z'
ToStringGeneral.tests.cpp:<line number>: passed: null_terminator == '\0' for: 0 == 0
ToStringGeneral.tests.cpp:<line number>: passed: c == i for: 2 == 2
ToStringGeneral.tests.cpp:<line number>: passed: c == i for: 3 == 3
ToStringGeneral.tests.cpp:<line number>: passed: c == i for: 4 == 4
ToStringGeneral.tests.cpp:<line number>: passed: c == i for: 5 == 5
ToStringGeneral.tests.cpp:<line number>: passed: ::Catch::Detail::stringify('\t') == "'\\t'" for: "'\t'" == "'\t'"
ToStringGeneral.tests.cpp:<line number>: passed: ::Catch::Detail::stringify('\n') == "'\\n'" for: "'\n'" == "'\n'"
ToStringGeneral.tests.cpp:<line number>: passed: ::Catch::Detail::stringify('\r') == "'\\r'" for: "'\r'" == "'\r'"
ToStringGeneral.tests.cpp:<line number>: passed: ::Catch::Detail::stringify('\f') == "'\\f'" for: "'\f'" == "'\f'"
ToStringGeneral.tests.cpp:<line number>: passed: ::Catch::Detail::stringify( ' ' ) == "' '" for: "' '" == "' '"
ToStringGeneral.tests.cpp:<line number>: passed: ::Catch::Detail::stringify( 'A' ) == "'A'" for: "'A'" == "'A'"
ToStringGeneral.tests.cpp:<line number>: passed: ::Catch::Detail::stringify( 'z' ) == "'z'" for: "'z'" == "'z'"
ToStringGeneral.tests.cpp:<line number>: passed: ::Catch::Detail::stringify( '\0' ) == "0" for: "0" == "0"
ToStringGeneral.tests.cpp:<line number>: passed: ::Catch::Detail::stringify( static_cast<char>(2) ) == "2" for: "2" == "2"
ToStringGeneral.tests.cpp:<line number>: passed: ::Catch::Detail::stringify( static_cast<char>(5) ) == "5" for: "5" == "5"
Clara.tests.cpp:<line number>: passed: name.empty() for: true
Clara.tests.cpp:<line number>: passed: name == "foo" for: "foo" == "foo"
Clara.tests.cpp:<line number>: passed: !(parse_result) for: !{?}
@@ -1737,13 +1733,13 @@ Tag.tests.cpp:<line number>: passed: testCase.tags, VectorContains( Tag( "tag wi
Class.tests.cpp:<line number>: passed: Template_Fixture<TestType>::m_a == 1 for: 1 == 1
Class.tests.cpp:<line number>: passed: Template_Fixture<TestType>::m_a == 1 for: 1 == 1
Class.tests.cpp:<line number>: passed: Template_Fixture<TestType>::m_a == 1 for: 1.0 == 1
Misc.tests.cpp:<line number>: passed: sizeof(TestType) > 0 for: 1 > 0
Misc.tests.cpp:<line number>: passed: sizeof(TestType) > 0 for: 4 > 0
Misc.tests.cpp:<line number>: passed: sizeof(TestType) > 0 for: 1 > 0
Misc.tests.cpp:<line number>: passed: sizeof(TestType) > 0 for: 4 > 0
Misc.tests.cpp:<line number>: passed: sizeof(TestType) > 0 for: 4 > 0
Misc.tests.cpp:<line number>: passed: sizeof(TestType) > 0 for: 1 > 0
Misc.tests.cpp:<line number>: passed: sizeof(TestType) > 0 for: 4 > 0
Misc.tests.cpp:<line number>: passed: std::is_default_constructible<TestType>::value for: true
Misc.tests.cpp:<line number>: passed: std::is_default_constructible<TestType>::value for: true
Misc.tests.cpp:<line number>: passed: std::is_trivially_copyable<TestType>::value for: true
Misc.tests.cpp:<line number>: passed: std::is_trivially_copyable<TestType>::value for: true
Misc.tests.cpp:<line number>: passed: std::is_arithmetic<TestType>::value for: true
Misc.tests.cpp:<line number>: passed: std::is_arithmetic<TestType>::value for: true
Misc.tests.cpp:<line number>: passed: std::is_arithmetic<TestType>::value for: true
Misc.tests.cpp:<line number>: passed: v.size() == 5 for: 5 == 5
Misc.tests.cpp:<line number>: passed: v.capacity() >= 5 for: 5 >= 5
Misc.tests.cpp:<line number>: passed: v.size() == 10 for: 10 == 10
@@ -2483,6 +2479,10 @@ StringManip.tests.cpp:<line number>: passed: Catch::replaceInPlace(letters, lett
StringManip.tests.cpp:<line number>: passed: letters == "replaced" for: "replaced" == "replaced"
StringManip.tests.cpp:<line number>: passed: !(Catch::replaceInPlace(letters, "x", "z")) for: !false
StringManip.tests.cpp:<line number>: passed: letters == letters for: "abcdefcg" == "abcdefcg"
StringManip.tests.cpp:<line number>: passed: Catch::replaceInPlace(letters, "c", "cc") for: true
StringManip.tests.cpp:<line number>: passed: letters == "abccdefccg" for: "abccdefccg" == "abccdefccg"
StringManip.tests.cpp:<line number>: passed: Catch::replaceInPlace(s, "--", "-") for: true
StringManip.tests.cpp:<line number>: passed: s == "--" for: "--" == "--"
StringManip.tests.cpp:<line number>: passed: Catch::replaceInPlace(s, "'", "|'") for: true
StringManip.tests.cpp:<line number>: passed: s == "didn|'t" for: "didn|'t" == "didn|'t"
Stream.tests.cpp:<line number>: passed: Catch::makeStream( "%somestream" )
@@ -348,20 +348,16 @@ Details.tests.cpp:<line number>: passed: lt( "a", "b" ) for: true
Details.tests.cpp:<line number>: passed: lt( "a", "B" ) for: true
Details.tests.cpp:<line number>: passed: lt( "A", "b" ) for: true
Details.tests.cpp:<line number>: passed: lt( "A", "B" ) for: true
ToStringGeneral.tests.cpp:<line number>: passed: tab == '\t' for: '\t' == '\t'
ToStringGeneral.tests.cpp:<line number>: passed: newline == '\n' for: '\n' == '\n'
ToStringGeneral.tests.cpp:<line number>: passed: carr_return == '\r' for: '\r' == '\r'
ToStringGeneral.tests.cpp:<line number>: passed: form_feed == '\f' for: '\f' == '\f'
ToStringGeneral.tests.cpp:<line number>: passed: space == ' ' for: ' ' == ' '
ToStringGeneral.tests.cpp:<line number>: passed: c == chars[i] for: 'a' == 'a'
ToStringGeneral.tests.cpp:<line number>: passed: c == chars[i] for: 'z' == 'z'
ToStringGeneral.tests.cpp:<line number>: passed: c == chars[i] for: 'A' == 'A'
ToStringGeneral.tests.cpp:<line number>: passed: c == chars[i] for: 'Z' == 'Z'
ToStringGeneral.tests.cpp:<line number>: passed: null_terminator == '\0' for: 0 == 0
ToStringGeneral.tests.cpp:<line number>: passed: c == i for: 2 == 2
ToStringGeneral.tests.cpp:<line number>: passed: c == i for: 3 == 3
ToStringGeneral.tests.cpp:<line number>: passed: c == i for: 4 == 4
ToStringGeneral.tests.cpp:<line number>: passed: c == i for: 5 == 5
ToStringGeneral.tests.cpp:<line number>: passed: ::Catch::Detail::stringify('\t') == "'\\t'" for: "'\t'" == "'\t'"
ToStringGeneral.tests.cpp:<line number>: passed: ::Catch::Detail::stringify('\n') == "'\\n'" for: "'\n'" == "'\n'"
ToStringGeneral.tests.cpp:<line number>: passed: ::Catch::Detail::stringify('\r') == "'\\r'" for: "'\r'" == "'\r'"
ToStringGeneral.tests.cpp:<line number>: passed: ::Catch::Detail::stringify('\f') == "'\\f'" for: "'\f'" == "'\f'"
ToStringGeneral.tests.cpp:<line number>: passed: ::Catch::Detail::stringify( ' ' ) == "' '" for: "' '" == "' '"
ToStringGeneral.tests.cpp:<line number>: passed: ::Catch::Detail::stringify( 'A' ) == "'A'" for: "'A'" == "'A'"
ToStringGeneral.tests.cpp:<line number>: passed: ::Catch::Detail::stringify( 'z' ) == "'z'" for: "'z'" == "'z'"
ToStringGeneral.tests.cpp:<line number>: passed: ::Catch::Detail::stringify( '\0' ) == "0" for: "0" == "0"
ToStringGeneral.tests.cpp:<line number>: passed: ::Catch::Detail::stringify( static_cast<char>(2) ) == "2" for: "2" == "2"
ToStringGeneral.tests.cpp:<line number>: passed: ::Catch::Detail::stringify( static_cast<char>(5) ) == "5" for: "5" == "5"
Clara.tests.cpp:<line number>: passed: name.empty() for: true
Clara.tests.cpp:<line number>: passed: name == "foo" for: "foo" == "foo"
Clara.tests.cpp:<line number>: passed: !(parse_result) for: !{?}
@@ -1730,13 +1726,13 @@ Tag.tests.cpp:<line number>: passed: testCase.tags, VectorContains( Tag( "tag wi
Class.tests.cpp:<line number>: passed: Template_Fixture<TestType>::m_a == 1 for: 1 == 1
Class.tests.cpp:<line number>: passed: Template_Fixture<TestType>::m_a == 1 for: 1 == 1
Class.tests.cpp:<line number>: passed: Template_Fixture<TestType>::m_a == 1 for: 1.0 == 1
Misc.tests.cpp:<line number>: passed: sizeof(TestType) > 0 for: 1 > 0
Misc.tests.cpp:<line number>: passed: sizeof(TestType) > 0 for: 4 > 0
Misc.tests.cpp:<line number>: passed: sizeof(TestType) > 0 for: 1 > 0
Misc.tests.cpp:<line number>: passed: sizeof(TestType) > 0 for: 4 > 0
Misc.tests.cpp:<line number>: passed: sizeof(TestType) > 0 for: 4 > 0
Misc.tests.cpp:<line number>: passed: sizeof(TestType) > 0 for: 1 > 0
Misc.tests.cpp:<line number>: passed: sizeof(TestType) > 0 for: 4 > 0
Misc.tests.cpp:<line number>: passed: std::is_default_constructible<TestType>::value for: true
Misc.tests.cpp:<line number>: passed: std::is_default_constructible<TestType>::value for: true
Misc.tests.cpp:<line number>: passed: std::is_trivially_copyable<TestType>::value for: true
Misc.tests.cpp:<line number>: passed: std::is_trivially_copyable<TestType>::value for: true
Misc.tests.cpp:<line number>: passed: std::is_arithmetic<TestType>::value for: true
Misc.tests.cpp:<line number>: passed: std::is_arithmetic<TestType>::value for: true
Misc.tests.cpp:<line number>: passed: std::is_arithmetic<TestType>::value for: true
Misc.tests.cpp:<line number>: passed: v.size() == 5 for: 5 == 5
Misc.tests.cpp:<line number>: passed: v.capacity() >= 5 for: 5 >= 5
Misc.tests.cpp:<line number>: passed: v.size() == 10 for: 10 == 10
@@ -2472,6 +2468,10 @@ StringManip.tests.cpp:<line number>: passed: Catch::replaceInPlace(letters, lett
StringManip.tests.cpp:<line number>: passed: letters == "replaced" for: "replaced" == "replaced"
StringManip.tests.cpp:<line number>: passed: !(Catch::replaceInPlace(letters, "x", "z")) for: !false
StringManip.tests.cpp:<line number>: passed: letters == letters for: "abcdefcg" == "abcdefcg"
StringManip.tests.cpp:<line number>: passed: Catch::replaceInPlace(letters, "c", "cc") for: true
StringManip.tests.cpp:<line number>: passed: letters == "abccdefccg" for: "abccdefccg" == "abccdefccg"
StringManip.tests.cpp:<line number>: passed: Catch::replaceInPlace(s, "--", "-") for: true
StringManip.tests.cpp:<line number>: passed: s == "--" for: "--" == "--"
StringManip.tests.cpp:<line number>: passed: Catch::replaceInPlace(s, "'", "|'") for: true
StringManip.tests.cpp:<line number>: passed: s == "didn|'t" for: "didn|'t" == "didn|'t"
Stream.tests.cpp:<line number>: passed: Catch::makeStream( "%somestream" )
@@ -2904,24 +2904,24 @@ ToStringGeneral.tests.cpp:<line number>
...............................................................................
ToStringGeneral.tests.cpp:<line number>: PASSED:
CHECK( tab == '\t' )
CHECK( ::Catch::Detail::stringify('\t') == "'\\t'" )
with expansion:
'\t' == '\t'
"'\t'" == "'\t'"
ToStringGeneral.tests.cpp:<line number>: PASSED:
CHECK( newline == '\n' )
CHECK( ::Catch::Detail::stringify('\n') == "'\\n'" )
with expansion:
'\n' == '\n'
"'\n'" == "'\n'"
ToStringGeneral.tests.cpp:<line number>: PASSED:
CHECK( carr_return == '\r' )
CHECK( ::Catch::Detail::stringify('\r') == "'\\r'" )
with expansion:
'\r' == '\r'
"'\r'" == "'\r'"
ToStringGeneral.tests.cpp:<line number>: PASSED:
CHECK( form_feed == '\f' )
CHECK( ::Catch::Detail::stringify('\f') == "'\\f'" )
with expansion:
'\f' == '\f'
"'\f'" == "'\f'"
-------------------------------------------------------------------------------
Character pretty printing
@@ -2931,29 +2931,19 @@ ToStringGeneral.tests.cpp:<line number>
...............................................................................
ToStringGeneral.tests.cpp:<line number>: PASSED:
CHECK( space == ' ' )
CHECK( ::Catch::Detail::stringify( ' ' ) == "' '" )
with expansion:
' ' == ' '
"' '" == "' '"
ToStringGeneral.tests.cpp:<line number>: PASSED:
REQUIRE( c == chars[i] )
CHECK( ::Catch::Detail::stringify( 'A' ) == "'A'" )
with expansion:
'a' == 'a'
"'A'" == "'A'"
ToStringGeneral.tests.cpp:<line number>: PASSED:
REQUIRE( c == chars[i] )
CHECK( ::Catch::Detail::stringify( 'z' ) == "'z'" )
with expansion:
'z' == 'z'
ToStringGeneral.tests.cpp:<line number>: PASSED:
REQUIRE( c == chars[i] )
with expansion:
'A' == 'A'
ToStringGeneral.tests.cpp:<line number>: PASSED:
REQUIRE( c == chars[i] )
with expansion:
'Z' == 'Z'
"'z'" == "'z'"
-------------------------------------------------------------------------------
Character pretty printing
@@ -2963,29 +2953,19 @@ ToStringGeneral.tests.cpp:<line number>
...............................................................................
ToStringGeneral.tests.cpp:<line number>: PASSED:
CHECK( null_terminator == '\0' )
CHECK( ::Catch::Detail::stringify( '\0' ) == "0" )
with expansion:
0 == 0
"0" == "0"
ToStringGeneral.tests.cpp:<line number>: PASSED:
REQUIRE( c == i )
CHECK( ::Catch::Detail::stringify( static_cast<char>(2) ) == "2" )
with expansion:
2 == 2
"2" == "2"
ToStringGeneral.tests.cpp:<line number>: PASSED:
REQUIRE( c == i )
CHECK( ::Catch::Detail::stringify( static_cast<char>(5) ) == "5" )
with expansion:
3 == 3
ToStringGeneral.tests.cpp:<line number>: PASSED:
REQUIRE( c == i )
with expansion:
4 == 4
ToStringGeneral.tests.cpp:<line number>: PASSED:
REQUIRE( c == i )
with expansion:
5 == 5
"5" == "5"
-------------------------------------------------------------------------------
Clara::Arg supports single-arg parse the way Opt does
@@ -11675,9 +11655,9 @@ Misc.tests.cpp:<line number>
...............................................................................
Misc.tests.cpp:<line number>: PASSED:
REQUIRE( sizeof(TestType) > 0 )
REQUIRE( std::is_default_constructible<TestType>::value )
with expansion:
1 > 0
true
-------------------------------------------------------------------------------
Template test case with test types specified inside non-copyable and non-
@@ -11687,9 +11667,9 @@ Misc.tests.cpp:<line number>
...............................................................................
Misc.tests.cpp:<line number>: PASSED:
REQUIRE( sizeof(TestType) > 0 )
REQUIRE( std::is_default_constructible<TestType>::value )
with expansion:
4 > 0
true
-------------------------------------------------------------------------------
Template test case with test types specified inside non-default-constructible
@@ -11699,9 +11679,9 @@ Misc.tests.cpp:<line number>
...............................................................................
Misc.tests.cpp:<line number>: PASSED:
REQUIRE( sizeof(TestType) > 0 )
REQUIRE( std::is_trivially_copyable<TestType>::value )
with expansion:
1 > 0
true
-------------------------------------------------------------------------------
Template test case with test types specified inside non-default-constructible
@@ -11711,9 +11691,9 @@ Misc.tests.cpp:<line number>
...............................................................................
Misc.tests.cpp:<line number>: PASSED:
REQUIRE( sizeof(TestType) > 0 )
REQUIRE( std::is_trivially_copyable<TestType>::value )
with expansion:
4 > 0
true
-------------------------------------------------------------------------------
Template test case with test types specified inside std::tuple - MyTypes - 0
@@ -11722,9 +11702,9 @@ Misc.tests.cpp:<line number>
...............................................................................
Misc.tests.cpp:<line number>: PASSED:
REQUIRE( sizeof(TestType) > 0 )
REQUIRE( std::is_arithmetic<TestType>::value )
with expansion:
4 > 0
true
-------------------------------------------------------------------------------
Template test case with test types specified inside std::tuple - MyTypes - 1
@@ -11733,9 +11713,9 @@ Misc.tests.cpp:<line number>
...............................................................................
Misc.tests.cpp:<line number>: PASSED:
REQUIRE( sizeof(TestType) > 0 )
REQUIRE( std::is_arithmetic<TestType>::value )
with expansion:
1 > 0
true
-------------------------------------------------------------------------------
Template test case with test types specified inside std::tuple - MyTypes - 2
@@ -11744,9 +11724,9 @@ Misc.tests.cpp:<line number>
...............................................................................
Misc.tests.cpp:<line number>: PASSED:
REQUIRE( sizeof(TestType) > 0 )
REQUIRE( std::is_arithmetic<TestType>::value )
with expansion:
4 > 0
true
-------------------------------------------------------------------------------
TemplateTest: vectors can be sized and resized - float
@@ -17309,6 +17289,42 @@ StringManip.tests.cpp:<line number>: PASSED:
with expansion:
"abcdefcg" == "abcdefcg"
-------------------------------------------------------------------------------
replaceInPlace
no replace in already-replaced string
lengthening
-------------------------------------------------------------------------------
StringManip.tests.cpp:<line number>
...............................................................................
StringManip.tests.cpp:<line number>: PASSED:
CHECK( Catch::replaceInPlace(letters, "c", "cc") )
with expansion:
true
StringManip.tests.cpp:<line number>: PASSED:
CHECK( letters == "abccdefccg" )
with expansion:
"abccdefccg" == "abccdefccg"
-------------------------------------------------------------------------------
replaceInPlace
no replace in already-replaced string
shortening
-------------------------------------------------------------------------------
StringManip.tests.cpp:<line number>
...............................................................................
StringManip.tests.cpp:<line number>: PASSED:
CHECK( Catch::replaceInPlace(s, "--", "-") )
with expansion:
true
StringManip.tests.cpp:<line number>: PASSED:
CHECK( s == "--" )
with expansion:
"--" == "--"
-------------------------------------------------------------------------------
replaceInPlace
escape '
@@ -2902,24 +2902,24 @@ ToStringGeneral.tests.cpp:<line number>
...............................................................................
ToStringGeneral.tests.cpp:<line number>: PASSED:
CHECK( tab == '\t' )
CHECK( ::Catch::Detail::stringify('\t') == "'\\t'" )
with expansion:
'\t' == '\t'
"'\t'" == "'\t'"
ToStringGeneral.tests.cpp:<line number>: PASSED:
CHECK( newline == '\n' )
CHECK( ::Catch::Detail::stringify('\n') == "'\\n'" )
with expansion:
'\n' == '\n'
"'\n'" == "'\n'"
ToStringGeneral.tests.cpp:<line number>: PASSED:
CHECK( carr_return == '\r' )
CHECK( ::Catch::Detail::stringify('\r') == "'\\r'" )
with expansion:
'\r' == '\r'
"'\r'" == "'\r'"
ToStringGeneral.tests.cpp:<line number>: PASSED:
CHECK( form_feed == '\f' )
CHECK( ::Catch::Detail::stringify('\f') == "'\\f'" )
with expansion:
'\f' == '\f'
"'\f'" == "'\f'"
-------------------------------------------------------------------------------
Character pretty printing
@@ -2929,29 +2929,19 @@ ToStringGeneral.tests.cpp:<line number>
...............................................................................
ToStringGeneral.tests.cpp:<line number>: PASSED:
CHECK( space == ' ' )
CHECK( ::Catch::Detail::stringify( ' ' ) == "' '" )
with expansion:
' ' == ' '
"' '" == "' '"
ToStringGeneral.tests.cpp:<line number>: PASSED:
REQUIRE( c == chars[i] )
CHECK( ::Catch::Detail::stringify( 'A' ) == "'A'" )
with expansion:
'a' == 'a'
"'A'" == "'A'"
ToStringGeneral.tests.cpp:<line number>: PASSED:
REQUIRE( c == chars[i] )
CHECK( ::Catch::Detail::stringify( 'z' ) == "'z'" )
with expansion:
'z' == 'z'
ToStringGeneral.tests.cpp:<line number>: PASSED:
REQUIRE( c == chars[i] )
with expansion:
'A' == 'A'
ToStringGeneral.tests.cpp:<line number>: PASSED:
REQUIRE( c == chars[i] )
with expansion:
'Z' == 'Z'
"'z'" == "'z'"
-------------------------------------------------------------------------------
Character pretty printing
@@ -2961,29 +2951,19 @@ ToStringGeneral.tests.cpp:<line number>
...............................................................................
ToStringGeneral.tests.cpp:<line number>: PASSED:
CHECK( null_terminator == '\0' )
CHECK( ::Catch::Detail::stringify( '\0' ) == "0" )
with expansion:
0 == 0
"0" == "0"
ToStringGeneral.tests.cpp:<line number>: PASSED:
REQUIRE( c == i )
CHECK( ::Catch::Detail::stringify( static_cast<char>(2) ) == "2" )
with expansion:
2 == 2
"2" == "2"
ToStringGeneral.tests.cpp:<line number>: PASSED:
REQUIRE( c == i )
CHECK( ::Catch::Detail::stringify( static_cast<char>(5) ) == "5" )
with expansion:
3 == 3
ToStringGeneral.tests.cpp:<line number>: PASSED:
REQUIRE( c == i )
with expansion:
4 == 4
ToStringGeneral.tests.cpp:<line number>: PASSED:
REQUIRE( c == i )
with expansion:
5 == 5
"5" == "5"
-------------------------------------------------------------------------------
Clara::Arg supports single-arg parse the way Opt does
@@ -11668,9 +11648,9 @@ Misc.tests.cpp:<line number>
...............................................................................
Misc.tests.cpp:<line number>: PASSED:
REQUIRE( sizeof(TestType) > 0 )
REQUIRE( std::is_default_constructible<TestType>::value )
with expansion:
1 > 0
true
-------------------------------------------------------------------------------
Template test case with test types specified inside non-copyable and non-
@@ -11680,9 +11660,9 @@ Misc.tests.cpp:<line number>
...............................................................................
Misc.tests.cpp:<line number>: PASSED:
REQUIRE( sizeof(TestType) > 0 )
REQUIRE( std::is_default_constructible<TestType>::value )
with expansion:
4 > 0
true
-------------------------------------------------------------------------------
Template test case with test types specified inside non-default-constructible
@@ -11692,9 +11672,9 @@ Misc.tests.cpp:<line number>
...............................................................................
Misc.tests.cpp:<line number>: PASSED:
REQUIRE( sizeof(TestType) > 0 )
REQUIRE( std::is_trivially_copyable<TestType>::value )
with expansion:
1 > 0
true
-------------------------------------------------------------------------------
Template test case with test types specified inside non-default-constructible
@@ -11704,9 +11684,9 @@ Misc.tests.cpp:<line number>
...............................................................................
Misc.tests.cpp:<line number>: PASSED:
REQUIRE( sizeof(TestType) > 0 )
REQUIRE( std::is_trivially_copyable<TestType>::value )
with expansion:
4 > 0
true
-------------------------------------------------------------------------------
Template test case with test types specified inside std::tuple - MyTypes - 0
@@ -11715,9 +11695,9 @@ Misc.tests.cpp:<line number>
...............................................................................
Misc.tests.cpp:<line number>: PASSED:
REQUIRE( sizeof(TestType) > 0 )
REQUIRE( std::is_arithmetic<TestType>::value )
with expansion:
4 > 0
true
-------------------------------------------------------------------------------
Template test case with test types specified inside std::tuple - MyTypes - 1
@@ -11726,9 +11706,9 @@ Misc.tests.cpp:<line number>
...............................................................................
Misc.tests.cpp:<line number>: PASSED:
REQUIRE( sizeof(TestType) > 0 )
REQUIRE( std::is_arithmetic<TestType>::value )
with expansion:
1 > 0
true
-------------------------------------------------------------------------------
Template test case with test types specified inside std::tuple - MyTypes - 2
@@ -11737,9 +11717,9 @@ Misc.tests.cpp:<line number>
...............................................................................
Misc.tests.cpp:<line number>: PASSED:
REQUIRE( sizeof(TestType) > 0 )
REQUIRE( std::is_arithmetic<TestType>::value )
with expansion:
4 > 0
true
-------------------------------------------------------------------------------
TemplateTest: vectors can be sized and resized - float
@@ -17298,6 +17278,42 @@ StringManip.tests.cpp:<line number>: PASSED:
with expansion:
"abcdefcg" == "abcdefcg"
-------------------------------------------------------------------------------
replaceInPlace
no replace in already-replaced string
lengthening
-------------------------------------------------------------------------------
StringManip.tests.cpp:<line number>
...............................................................................
StringManip.tests.cpp:<line number>: PASSED:
CHECK( Catch::replaceInPlace(letters, "c", "cc") )
with expansion:
true
StringManip.tests.cpp:<line number>: PASSED:
CHECK( letters == "abccdefccg" )
with expansion:
"abccdefccg" == "abccdefccg"
-------------------------------------------------------------------------------
replaceInPlace
no replace in already-replaced string
shortening
-------------------------------------------------------------------------------
StringManip.tests.cpp:<line number>
...............................................................................
StringManip.tests.cpp:<line number>: PASSED:
CHECK( Catch::replaceInPlace(s, "--", "-") )
with expansion:
true
StringManip.tests.cpp:<line number>: PASSED:
CHECK( s == "--" )
with expansion:
"--" == "--"
-------------------------------------------------------------------------------
replaceInPlace
escape '
@@ -1966,6 +1966,8 @@ at Message.tests.cpp:<line number>
<testcase classname="<exe-name>.global" name="replaceInPlace/replace last char" time="{duration}" status="run"/>
<testcase classname="<exe-name>.global" name="replaceInPlace/replace all chars" time="{duration}" status="run"/>
<testcase classname="<exe-name>.global" name="replaceInPlace/replace no chars" time="{duration}" status="run"/>
<testcase classname="<exe-name>.global" name="replaceInPlace/no replace in already-replaced string/lengthening" time="{duration}" status="run"/>
<testcase classname="<exe-name>.global" name="replaceInPlace/no replace in already-replaced string/shortening" time="{duration}" status="run"/>
<testcase classname="<exe-name>.global" name="replaceInPlace/escape '" time="{duration}" status="run"/>
<testcase classname="<exe-name>.global" name="request an unknown %-starting stream fails" time="{duration}" status="run"/>
<testcase classname="<exe-name>.global" name="resolution" time="{duration}" status="run"/>
@@ -1965,6 +1965,8 @@ at Message.tests.cpp:<line number>
<testcase classname="<exe-name>.global" name="replaceInPlace/replace last char" time="{duration}" status="run"/>
<testcase classname="<exe-name>.global" name="replaceInPlace/replace all chars" time="{duration}" status="run"/>
<testcase classname="<exe-name>.global" name="replaceInPlace/replace no chars" time="{duration}" status="run"/>
<testcase classname="<exe-name>.global" name="replaceInPlace/no replace in already-replaced string/lengthening" time="{duration}" status="run"/>
<testcase classname="<exe-name>.global" name="replaceInPlace/no replace in already-replaced string/shortening" time="{duration}" status="run"/>
<testcase classname="<exe-name>.global" name="replaceInPlace/escape '" time="{duration}" status="run"/>
<testcase classname="<exe-name>.global" name="request an unknown %-starting stream fails" time="{duration}" status="run"/>
<testcase classname="<exe-name>.global" name="resolution" time="{duration}" status="run"/>
@@ -262,6 +262,8 @@ at AssertionHandler.tests.cpp:<line number>
<testCase name="replaceInPlace/replace last char" duration="{duration}"/>
<testCase name="replaceInPlace/replace all chars" duration="{duration}"/>
<testCase name="replaceInPlace/replace no chars" duration="{duration}"/>
<testCase name="replaceInPlace/no replace in already-replaced string/lengthening" duration="{duration}"/>
<testCase name="replaceInPlace/no replace in already-replaced string/shortening" duration="{duration}"/>
<testCase name="replaceInPlace/escape '" duration="{duration}"/>
<testCase name="splitString" duration="{duration}"/>
<testCase name="startsWith" duration="{duration}"/>
@@ -261,6 +261,8 @@ at AssertionHandler.tests.cpp:<line number>
<testCase name="replaceInPlace/replace last char" duration="{duration}"/>
<testCase name="replaceInPlace/replace all chars" duration="{duration}"/>
<testCase name="replaceInPlace/replace no chars" duration="{duration}"/>
<testCase name="replaceInPlace/no replace in already-replaced string/lengthening" duration="{duration}"/>
<testCase name="replaceInPlace/no replace in already-replaced string/shortening" duration="{duration}"/>
<testCase name="replaceInPlace/escape '" duration="{duration}"/>
<testCase name="splitString" duration="{duration}"/>
<testCase name="startsWith" duration="{duration}"/>
+25 -25
View File
@@ -697,33 +697,25 @@ 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'
ok {test-number} - ::Catch::Detail::stringify('\t') == "'\\t'" for: "'\t'" == "'\t'"
# Character pretty printing
ok {test-number} - newline == '\n' for: '\n' == '\n'
ok {test-number} - ::Catch::Detail::stringify('\n') == "'\\n'" for: "'\n'" == "'\n'"
# Character pretty printing
ok {test-number} - carr_return == '\r' for: '\r' == '\r'
ok {test-number} - ::Catch::Detail::stringify('\r') == "'\\r'" for: "'\r'" == "'\r'"
# Character pretty printing
ok {test-number} - form_feed == '\f' for: '\f' == '\f'
ok {test-number} - ::Catch::Detail::stringify('\f') == "'\\f'" for: "'\f'" == "'\f'"
# Character pretty printing
ok {test-number} - space == ' ' for: ' ' == ' '
ok {test-number} - ::Catch::Detail::stringify( ' ' ) == "' '" for: "' '" == "' '"
# Character pretty printing
ok {test-number} - c == chars[i] for: 'a' == 'a'
ok {test-number} - ::Catch::Detail::stringify( 'A' ) == "'A'" for: "'A'" == "'A'"
# Character pretty printing
ok {test-number} - c == chars[i] for: 'z' == 'z'
ok {test-number} - ::Catch::Detail::stringify( 'z' ) == "'z'" for: "'z'" == "'z'"
# Character pretty printing
ok {test-number} - c == chars[i] for: 'A' == 'A'
ok {test-number} - ::Catch::Detail::stringify( '\0' ) == "0" for: "0" == "0"
# Character pretty printing
ok {test-number} - c == chars[i] for: 'Z' == 'Z'
ok {test-number} - ::Catch::Detail::stringify( static_cast<char>(2) ) == "2" for: "2" == "2"
# Character pretty printing
ok {test-number} - null_terminator == '\0' for: 0 == 0
# Character pretty printing
ok {test-number} - c == i for: 2 == 2
# Character pretty printing
ok {test-number} - c == i for: 3 == 3
# 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<char>(5) ) == "5" for: "5" == "5"
# 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
@@ -2812,19 +2804,19 @@ ok {test-number} - Template_Fixture<TestType>::m_a == 1 for: 1 == 1
# Template test case method with test types specified inside std::tuple - MyTypes - 2
ok {test-number} - Template_Fixture<TestType>::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<TestType>::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<TestType>::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<TestType>::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<TestType>::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<TestType>::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<TestType>::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<TestType>::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
@@ -4206,6 +4198,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"
@@ -695,33 +695,25 @@ 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'
ok {test-number} - ::Catch::Detail::stringify('\t') == "'\\t'" for: "'\t'" == "'\t'"
# Character pretty printing
ok {test-number} - newline == '\n' for: '\n' == '\n'
ok {test-number} - ::Catch::Detail::stringify('\n') == "'\\n'" for: "'\n'" == "'\n'"
# Character pretty printing
ok {test-number} - carr_return == '\r' for: '\r' == '\r'
ok {test-number} - ::Catch::Detail::stringify('\r') == "'\\r'" for: "'\r'" == "'\r'"
# Character pretty printing
ok {test-number} - form_feed == '\f' for: '\f' == '\f'
ok {test-number} - ::Catch::Detail::stringify('\f') == "'\\f'" for: "'\f'" == "'\f'"
# Character pretty printing
ok {test-number} - space == ' ' for: ' ' == ' '
ok {test-number} - ::Catch::Detail::stringify( ' ' ) == "' '" for: "' '" == "' '"
# Character pretty printing
ok {test-number} - c == chars[i] for: 'a' == 'a'
ok {test-number} - ::Catch::Detail::stringify( 'A' ) == "'A'" for: "'A'" == "'A'"
# Character pretty printing
ok {test-number} - c == chars[i] for: 'z' == 'z'
ok {test-number} - ::Catch::Detail::stringify( 'z' ) == "'z'" for: "'z'" == "'z'"
# Character pretty printing
ok {test-number} - c == chars[i] for: 'A' == 'A'
ok {test-number} - ::Catch::Detail::stringify( '\0' ) == "0" for: "0" == "0"
# Character pretty printing
ok {test-number} - c == chars[i] for: 'Z' == 'Z'
ok {test-number} - ::Catch::Detail::stringify( static_cast<char>(2) ) == "2" for: "2" == "2"
# Character pretty printing
ok {test-number} - null_terminator == '\0' for: 0 == 0
# Character pretty printing
ok {test-number} - c == i for: 2 == 2
# Character pretty printing
ok {test-number} - c == i for: 3 == 3
# 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<char>(5) ) == "5" for: "5" == "5"
# 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
@@ -2805,19 +2797,19 @@ ok {test-number} - Template_Fixture<TestType>::m_a == 1 for: 1 == 1
# Template test case method with test types specified inside std::tuple - MyTypes - 2
ok {test-number} - Template_Fixture<TestType>::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<TestType>::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<TestType>::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<TestType>::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<TestType>::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<TestType>::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<TestType>::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<TestType>::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
@@ -4195,6 +4187,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"
+84 -72
View File
@@ -3142,34 +3142,34 @@ Nor would this
<Section name="Specifically escaped" filename="tests/<exe-name>/UsageTests/ToStringGeneral.tests.cpp" >
<Expression success="true" type="CHECK" filename="tests/<exe-name>/UsageTests/ToStringGeneral.tests.cpp" >
<Original>
tab == '\t'
::Catch::Detail::stringify('\t') == "'\\t'"
</Original>
<Expanded>
'\t' == '\t'
"'\t'" == "'\t'"
</Expanded>
</Expression>
<Expression success="true" type="CHECK" filename="tests/<exe-name>/UsageTests/ToStringGeneral.tests.cpp" >
<Original>
newline == '\n'
::Catch::Detail::stringify('\n') == "'\\n'"
</Original>
<Expanded>
'\n' == '\n'
"'\n'" == "'\n'"
</Expanded>
</Expression>
<Expression success="true" type="CHECK" filename="tests/<exe-name>/UsageTests/ToStringGeneral.tests.cpp" >
<Original>
carr_return == '\r'
::Catch::Detail::stringify('\r') == "'\\r'"
</Original>
<Expanded>
'\r' == '\r'
"'\r'" == "'\r'"
</Expanded>
</Expression>
<Expression success="true" type="CHECK" filename="tests/<exe-name>/UsageTests/ToStringGeneral.tests.cpp" >
<Original>
form_feed == '\f'
::Catch::Detail::stringify('\f') == "'\\f'"
</Original>
<Expanded>
'\f' == '\f'
"'\f'" == "'\f'"
</Expanded>
</Expression>
<OverallResults successes="4" failures="0" expectedFailures="0" skipped="false"/>
@@ -3177,88 +3177,56 @@ Nor would this
<Section name="General chars" filename="tests/<exe-name>/UsageTests/ToStringGeneral.tests.cpp" >
<Expression success="true" type="CHECK" filename="tests/<exe-name>/UsageTests/ToStringGeneral.tests.cpp" >
<Original>
space == ' '
::Catch::Detail::stringify( ' ' ) == "' '"
</Original>
<Expanded>
' ' == ' '
"' '" == "' '"
</Expanded>
</Expression>
<Expression success="true" type="REQUIRE" filename="tests/<exe-name>/UsageTests/ToStringGeneral.tests.cpp" >
<Expression success="true" type="CHECK" filename="tests/<exe-name>/UsageTests/ToStringGeneral.tests.cpp" >
<Original>
c == chars[i]
::Catch::Detail::stringify( 'A' ) == "'A'"
</Original>
<Expanded>
'a' == 'a'
"'A'" == "'A'"
</Expanded>
</Expression>
<Expression success="true" type="REQUIRE" filename="tests/<exe-name>/UsageTests/ToStringGeneral.tests.cpp" >
<Expression success="true" type="CHECK" filename="tests/<exe-name>/UsageTests/ToStringGeneral.tests.cpp" >
<Original>
c == chars[i]
::Catch::Detail::stringify( 'z' ) == "'z'"
</Original>
<Expanded>
'z' == 'z'
"'z'" == "'z'"
</Expanded>
</Expression>
<Expression success="true" type="REQUIRE" filename="tests/<exe-name>/UsageTests/ToStringGeneral.tests.cpp" >
<Original>
c == chars[i]
</Original>
<Expanded>
'A' == 'A'
</Expanded>
</Expression>
<Expression success="true" type="REQUIRE" filename="tests/<exe-name>/UsageTests/ToStringGeneral.tests.cpp" >
<Original>
c == chars[i]
</Original>
<Expanded>
'Z' == 'Z'
</Expanded>
</Expression>
<OverallResults successes="5" failures="0" expectedFailures="0" skipped="false"/>
<OverallResults successes="3" failures="0" expectedFailures="0" skipped="false"/>
</Section>
<Section name="Low ASCII" filename="tests/<exe-name>/UsageTests/ToStringGeneral.tests.cpp" >
<Expression success="true" type="CHECK" filename="tests/<exe-name>/UsageTests/ToStringGeneral.tests.cpp" >
<Original>
null_terminator == '\0'
::Catch::Detail::stringify( '\0' ) == "0"
</Original>
<Expanded>
0 == 0
"0" == "0"
</Expanded>
</Expression>
<Expression success="true" type="REQUIRE" filename="tests/<exe-name>/UsageTests/ToStringGeneral.tests.cpp" >
<Expression success="true" type="CHECK" filename="tests/<exe-name>/UsageTests/ToStringGeneral.tests.cpp" >
<Original>
c == i
::Catch::Detail::stringify( static_cast&lt;char>(2) ) == "2"
</Original>
<Expanded>
2 == 2
"2" == "2"
</Expanded>
</Expression>
<Expression success="true" type="REQUIRE" filename="tests/<exe-name>/UsageTests/ToStringGeneral.tests.cpp" >
<Expression success="true" type="CHECK" filename="tests/<exe-name>/UsageTests/ToStringGeneral.tests.cpp" >
<Original>
c == i
::Catch::Detail::stringify( static_cast&lt;char>(5) ) == "5"
</Original>
<Expanded>
3 == 3
"5" == "5"
</Expanded>
</Expression>
<Expression success="true" type="REQUIRE" filename="tests/<exe-name>/UsageTests/ToStringGeneral.tests.cpp" >
<Original>
c == i
</Original>
<Expanded>
4 == 4
</Expanded>
</Expression>
<Expression success="true" type="REQUIRE" filename="tests/<exe-name>/UsageTests/ToStringGeneral.tests.cpp" >
<Original>
c == i
</Original>
<Expanded>
5 == 5
</Expanded>
</Expression>
<OverallResults successes="5" failures="0" expectedFailures="0" skipped="false"/>
<OverallResults successes="3" failures="0" expectedFailures="0" skipped="false"/>
</Section>
<OverallResult success="true" skips="0"/>
</TestCase>
@@ -13592,10 +13560,10 @@ Message from section two
<TestCase name="Template test case with test types specified inside non-copyable and non-movable std::tuple - NonCopyableAndNonMovableTypes - 0" tags="[list][template]" filename="tests/<exe-name>/UsageTests/Misc.tests.cpp" >
<Expression success="true" type="REQUIRE" filename="tests/<exe-name>/UsageTests/Misc.tests.cpp" >
<Original>
sizeof(TestType) > 0
std::is_default_constructible&lt;TestType>::value
</Original>
<Expanded>
1 > 0
true
</Expanded>
</Expression>
<OverallResult success="true" skips="0"/>
@@ -13603,10 +13571,10 @@ Message from section two
<TestCase name="Template test case with test types specified inside non-copyable and non-movable std::tuple - NonCopyableAndNonMovableTypes - 1" tags="[list][template]" filename="tests/<exe-name>/UsageTests/Misc.tests.cpp" >
<Expression success="true" type="REQUIRE" filename="tests/<exe-name>/UsageTests/Misc.tests.cpp" >
<Original>
sizeof(TestType) > 0
std::is_default_constructible&lt;TestType>::value
</Original>
<Expanded>
4 > 0
true
</Expanded>
</Expression>
<OverallResult success="true" skips="0"/>
@@ -13614,10 +13582,10 @@ Message from section two
<TestCase name="Template test case with test types specified inside non-default-constructible std::tuple - MyNonDefaultConstructibleTypes - 0" tags="[list][template]" filename="tests/<exe-name>/UsageTests/Misc.tests.cpp" >
<Expression success="true" type="REQUIRE" filename="tests/<exe-name>/UsageTests/Misc.tests.cpp" >
<Original>
sizeof(TestType) > 0
std::is_trivially_copyable&lt;TestType>::value
</Original>
<Expanded>
1 > 0
true
</Expanded>
</Expression>
<OverallResult success="true" skips="0"/>
@@ -13625,10 +13593,10 @@ Message from section two
<TestCase name="Template test case with test types specified inside non-default-constructible std::tuple - MyNonDefaultConstructibleTypes - 1" tags="[list][template]" filename="tests/<exe-name>/UsageTests/Misc.tests.cpp" >
<Expression success="true" type="REQUIRE" filename="tests/<exe-name>/UsageTests/Misc.tests.cpp" >
<Original>
sizeof(TestType) > 0
std::is_trivially_copyable&lt;TestType>::value
</Original>
<Expanded>
4 > 0
true
</Expanded>
</Expression>
<OverallResult success="true" skips="0"/>
@@ -13636,10 +13604,10 @@ Message from section two
<TestCase name="Template test case with test types specified inside std::tuple - MyTypes - 0" tags="[list][template]" filename="tests/<exe-name>/UsageTests/Misc.tests.cpp" >
<Expression success="true" type="REQUIRE" filename="tests/<exe-name>/UsageTests/Misc.tests.cpp" >
<Original>
sizeof(TestType) > 0
std::is_arithmetic&lt;TestType>::value
</Original>
<Expanded>
4 > 0
true
</Expanded>
</Expression>
<OverallResult success="true" skips="0"/>
@@ -13647,10 +13615,10 @@ Message from section two
<TestCase name="Template test case with test types specified inside std::tuple - MyTypes - 1" tags="[list][template]" filename="tests/<exe-name>/UsageTests/Misc.tests.cpp" >
<Expression success="true" type="REQUIRE" filename="tests/<exe-name>/UsageTests/Misc.tests.cpp" >
<Original>
sizeof(TestType) > 0
std::is_arithmetic&lt;TestType>::value
</Original>
<Expanded>
1 > 0
true
</Expanded>
</Expression>
<OverallResult success="true" skips="0"/>
@@ -13658,10 +13626,10 @@ Message from section two
<TestCase name="Template test case with test types specified inside std::tuple - MyTypes - 2" tags="[list][template]" filename="tests/<exe-name>/UsageTests/Misc.tests.cpp" >
<Expression success="true" type="REQUIRE" filename="tests/<exe-name>/UsageTests/Misc.tests.cpp" >
<Original>
sizeof(TestType) > 0
std::is_arithmetic&lt;TestType>::value
</Original>
<Expanded>
4 > 0
true
</Expanded>
</Expression>
<OverallResult success="true" skips="0"/>
@@ -20066,6 +20034,50 @@ b1!
</Expression>
<OverallResults successes="2" failures="0" expectedFailures="0" skipped="false"/>
</Section>
<Section name="no replace in already-replaced string" filename="tests/<exe-name>/IntrospectiveTests/StringManip.tests.cpp" >
<Section name="lengthening" filename="tests/<exe-name>/IntrospectiveTests/StringManip.tests.cpp" >
<Expression success="true" type="CHECK" filename="tests/<exe-name>/IntrospectiveTests/StringManip.tests.cpp" >
<Original>
Catch::replaceInPlace(letters, "c", "cc")
</Original>
<Expanded>
true
</Expanded>
</Expression>
<Expression success="true" type="CHECK" filename="tests/<exe-name>/IntrospectiveTests/StringManip.tests.cpp" >
<Original>
letters == "abccdefccg"
</Original>
<Expanded>
"abccdefccg" == "abccdefccg"
</Expanded>
</Expression>
<OverallResults successes="2" failures="0" expectedFailures="0" skipped="false"/>
</Section>
<OverallResults successes="2" failures="0" expectedFailures="0" skipped="false"/>
</Section>
<Section name="no replace in already-replaced string" filename="tests/<exe-name>/IntrospectiveTests/StringManip.tests.cpp" >
<Section name="shortening" filename="tests/<exe-name>/IntrospectiveTests/StringManip.tests.cpp" >
<Expression success="true" type="CHECK" filename="tests/<exe-name>/IntrospectiveTests/StringManip.tests.cpp" >
<Original>
Catch::replaceInPlace(s, "--", "-")
</Original>
<Expanded>
true
</Expanded>
</Expression>
<Expression success="true" type="CHECK" filename="tests/<exe-name>/IntrospectiveTests/StringManip.tests.cpp" >
<Original>
s == "--"
</Original>
<Expanded>
"--" == "--"
</Expanded>
</Expression>
<OverallResults successes="2" failures="0" expectedFailures="0" skipped="false"/>
</Section>
<OverallResults successes="2" failures="0" expectedFailures="0" skipped="false"/>
</Section>
<Section name="escape '" filename="tests/<exe-name>/IntrospectiveTests/StringManip.tests.cpp" >
<Expression success="true" type="CHECK" filename="tests/<exe-name>/IntrospectiveTests/StringManip.tests.cpp" >
<Original>
@@ -3142,34 +3142,34 @@ Nor would this
<Section name="Specifically escaped" filename="tests/<exe-name>/UsageTests/ToStringGeneral.tests.cpp" >
<Expression success="true" type="CHECK" filename="tests/<exe-name>/UsageTests/ToStringGeneral.tests.cpp" >
<Original>
tab == '\t'
::Catch::Detail::stringify('\t') == "'\\t'"
</Original>
<Expanded>
'\t' == '\t'
"'\t'" == "'\t'"
</Expanded>
</Expression>
<Expression success="true" type="CHECK" filename="tests/<exe-name>/UsageTests/ToStringGeneral.tests.cpp" >
<Original>
newline == '\n'
::Catch::Detail::stringify('\n') == "'\\n'"
</Original>
<Expanded>
'\n' == '\n'
"'\n'" == "'\n'"
</Expanded>
</Expression>
<Expression success="true" type="CHECK" filename="tests/<exe-name>/UsageTests/ToStringGeneral.tests.cpp" >
<Original>
carr_return == '\r'
::Catch::Detail::stringify('\r') == "'\\r'"
</Original>
<Expanded>
'\r' == '\r'
"'\r'" == "'\r'"
</Expanded>
</Expression>
<Expression success="true" type="CHECK" filename="tests/<exe-name>/UsageTests/ToStringGeneral.tests.cpp" >
<Original>
form_feed == '\f'
::Catch::Detail::stringify('\f') == "'\\f'"
</Original>
<Expanded>
'\f' == '\f'
"'\f'" == "'\f'"
</Expanded>
</Expression>
<OverallResults successes="4" failures="0" expectedFailures="0" skipped="false"/>
@@ -3177,88 +3177,56 @@ Nor would this
<Section name="General chars" filename="tests/<exe-name>/UsageTests/ToStringGeneral.tests.cpp" >
<Expression success="true" type="CHECK" filename="tests/<exe-name>/UsageTests/ToStringGeneral.tests.cpp" >
<Original>
space == ' '
::Catch::Detail::stringify( ' ' ) == "' '"
</Original>
<Expanded>
' ' == ' '
"' '" == "' '"
</Expanded>
</Expression>
<Expression success="true" type="REQUIRE" filename="tests/<exe-name>/UsageTests/ToStringGeneral.tests.cpp" >
<Expression success="true" type="CHECK" filename="tests/<exe-name>/UsageTests/ToStringGeneral.tests.cpp" >
<Original>
c == chars[i]
::Catch::Detail::stringify( 'A' ) == "'A'"
</Original>
<Expanded>
'a' == 'a'
"'A'" == "'A'"
</Expanded>
</Expression>
<Expression success="true" type="REQUIRE" filename="tests/<exe-name>/UsageTests/ToStringGeneral.tests.cpp" >
<Expression success="true" type="CHECK" filename="tests/<exe-name>/UsageTests/ToStringGeneral.tests.cpp" >
<Original>
c == chars[i]
::Catch::Detail::stringify( 'z' ) == "'z'"
</Original>
<Expanded>
'z' == 'z'
"'z'" == "'z'"
</Expanded>
</Expression>
<Expression success="true" type="REQUIRE" filename="tests/<exe-name>/UsageTests/ToStringGeneral.tests.cpp" >
<Original>
c == chars[i]
</Original>
<Expanded>
'A' == 'A'
</Expanded>
</Expression>
<Expression success="true" type="REQUIRE" filename="tests/<exe-name>/UsageTests/ToStringGeneral.tests.cpp" >
<Original>
c == chars[i]
</Original>
<Expanded>
'Z' == 'Z'
</Expanded>
</Expression>
<OverallResults successes="5" failures="0" expectedFailures="0" skipped="false"/>
<OverallResults successes="3" failures="0" expectedFailures="0" skipped="false"/>
</Section>
<Section name="Low ASCII" filename="tests/<exe-name>/UsageTests/ToStringGeneral.tests.cpp" >
<Expression success="true" type="CHECK" filename="tests/<exe-name>/UsageTests/ToStringGeneral.tests.cpp" >
<Original>
null_terminator == '\0'
::Catch::Detail::stringify( '\0' ) == "0"
</Original>
<Expanded>
0 == 0
"0" == "0"
</Expanded>
</Expression>
<Expression success="true" type="REQUIRE" filename="tests/<exe-name>/UsageTests/ToStringGeneral.tests.cpp" >
<Expression success="true" type="CHECK" filename="tests/<exe-name>/UsageTests/ToStringGeneral.tests.cpp" >
<Original>
c == i
::Catch::Detail::stringify( static_cast&lt;char>(2) ) == "2"
</Original>
<Expanded>
2 == 2
"2" == "2"
</Expanded>
</Expression>
<Expression success="true" type="REQUIRE" filename="tests/<exe-name>/UsageTests/ToStringGeneral.tests.cpp" >
<Expression success="true" type="CHECK" filename="tests/<exe-name>/UsageTests/ToStringGeneral.tests.cpp" >
<Original>
c == i
::Catch::Detail::stringify( static_cast&lt;char>(5) ) == "5"
</Original>
<Expanded>
3 == 3
"5" == "5"
</Expanded>
</Expression>
<Expression success="true" type="REQUIRE" filename="tests/<exe-name>/UsageTests/ToStringGeneral.tests.cpp" >
<Original>
c == i
</Original>
<Expanded>
4 == 4
</Expanded>
</Expression>
<Expression success="true" type="REQUIRE" filename="tests/<exe-name>/UsageTests/ToStringGeneral.tests.cpp" >
<Original>
c == i
</Original>
<Expanded>
5 == 5
</Expanded>
</Expression>
<OverallResults successes="5" failures="0" expectedFailures="0" skipped="false"/>
<OverallResults successes="3" failures="0" expectedFailures="0" skipped="false"/>
</Section>
<OverallResult success="true" skips="0"/>
</TestCase>
@@ -13592,10 +13560,10 @@ Message from section two
<TestCase name="Template test case with test types specified inside non-copyable and non-movable std::tuple - NonCopyableAndNonMovableTypes - 0" tags="[list][template]" filename="tests/<exe-name>/UsageTests/Misc.tests.cpp" >
<Expression success="true" type="REQUIRE" filename="tests/<exe-name>/UsageTests/Misc.tests.cpp" >
<Original>
sizeof(TestType) > 0
std::is_default_constructible&lt;TestType>::value
</Original>
<Expanded>
1 > 0
true
</Expanded>
</Expression>
<OverallResult success="true" skips="0"/>
@@ -13603,10 +13571,10 @@ Message from section two
<TestCase name="Template test case with test types specified inside non-copyable and non-movable std::tuple - NonCopyableAndNonMovableTypes - 1" tags="[list][template]" filename="tests/<exe-name>/UsageTests/Misc.tests.cpp" >
<Expression success="true" type="REQUIRE" filename="tests/<exe-name>/UsageTests/Misc.tests.cpp" >
<Original>
sizeof(TestType) > 0
std::is_default_constructible&lt;TestType>::value
</Original>
<Expanded>
4 > 0
true
</Expanded>
</Expression>
<OverallResult success="true" skips="0"/>
@@ -13614,10 +13582,10 @@ Message from section two
<TestCase name="Template test case with test types specified inside non-default-constructible std::tuple - MyNonDefaultConstructibleTypes - 0" tags="[list][template]" filename="tests/<exe-name>/UsageTests/Misc.tests.cpp" >
<Expression success="true" type="REQUIRE" filename="tests/<exe-name>/UsageTests/Misc.tests.cpp" >
<Original>
sizeof(TestType) > 0
std::is_trivially_copyable&lt;TestType>::value
</Original>
<Expanded>
1 > 0
true
</Expanded>
</Expression>
<OverallResult success="true" skips="0"/>
@@ -13625,10 +13593,10 @@ Message from section two
<TestCase name="Template test case with test types specified inside non-default-constructible std::tuple - MyNonDefaultConstructibleTypes - 1" tags="[list][template]" filename="tests/<exe-name>/UsageTests/Misc.tests.cpp" >
<Expression success="true" type="REQUIRE" filename="tests/<exe-name>/UsageTests/Misc.tests.cpp" >
<Original>
sizeof(TestType) > 0
std::is_trivially_copyable&lt;TestType>::value
</Original>
<Expanded>
4 > 0
true
</Expanded>
</Expression>
<OverallResult success="true" skips="0"/>
@@ -13636,10 +13604,10 @@ Message from section two
<TestCase name="Template test case with test types specified inside std::tuple - MyTypes - 0" tags="[list][template]" filename="tests/<exe-name>/UsageTests/Misc.tests.cpp" >
<Expression success="true" type="REQUIRE" filename="tests/<exe-name>/UsageTests/Misc.tests.cpp" >
<Original>
sizeof(TestType) > 0
std::is_arithmetic&lt;TestType>::value
</Original>
<Expanded>
4 > 0
true
</Expanded>
</Expression>
<OverallResult success="true" skips="0"/>
@@ -13647,10 +13615,10 @@ Message from section two
<TestCase name="Template test case with test types specified inside std::tuple - MyTypes - 1" tags="[list][template]" filename="tests/<exe-name>/UsageTests/Misc.tests.cpp" >
<Expression success="true" type="REQUIRE" filename="tests/<exe-name>/UsageTests/Misc.tests.cpp" >
<Original>
sizeof(TestType) > 0
std::is_arithmetic&lt;TestType>::value
</Original>
<Expanded>
1 > 0
true
</Expanded>
</Expression>
<OverallResult success="true" skips="0"/>
@@ -13658,10 +13626,10 @@ Message from section two
<TestCase name="Template test case with test types specified inside std::tuple - MyTypes - 2" tags="[list][template]" filename="tests/<exe-name>/UsageTests/Misc.tests.cpp" >
<Expression success="true" type="REQUIRE" filename="tests/<exe-name>/UsageTests/Misc.tests.cpp" >
<Original>
sizeof(TestType) > 0
std::is_arithmetic&lt;TestType>::value
</Original>
<Expanded>
4 > 0
true
</Expanded>
</Expression>
<OverallResult success="true" skips="0"/>
@@ -20065,6 +20033,50 @@ b1!
</Expression>
<OverallResults successes="2" failures="0" expectedFailures="0" skipped="false"/>
</Section>
<Section name="no replace in already-replaced string" filename="tests/<exe-name>/IntrospectiveTests/StringManip.tests.cpp" >
<Section name="lengthening" filename="tests/<exe-name>/IntrospectiveTests/StringManip.tests.cpp" >
<Expression success="true" type="CHECK" filename="tests/<exe-name>/IntrospectiveTests/StringManip.tests.cpp" >
<Original>
Catch::replaceInPlace(letters, "c", "cc")
</Original>
<Expanded>
true
</Expanded>
</Expression>
<Expression success="true" type="CHECK" filename="tests/<exe-name>/IntrospectiveTests/StringManip.tests.cpp" >
<Original>
letters == "abccdefccg"
</Original>
<Expanded>
"abccdefccg" == "abccdefccg"
</Expanded>
</Expression>
<OverallResults successes="2" failures="0" expectedFailures="0" skipped="false"/>
</Section>
<OverallResults successes="2" failures="0" expectedFailures="0" skipped="false"/>
</Section>
<Section name="no replace in already-replaced string" filename="tests/<exe-name>/IntrospectiveTests/StringManip.tests.cpp" >
<Section name="shortening" filename="tests/<exe-name>/IntrospectiveTests/StringManip.tests.cpp" >
<Expression success="true" type="CHECK" filename="tests/<exe-name>/IntrospectiveTests/StringManip.tests.cpp" >
<Original>
Catch::replaceInPlace(s, "--", "-")
</Original>
<Expanded>
true
</Expanded>
</Expression>
<Expression success="true" type="CHECK" filename="tests/<exe-name>/IntrospectiveTests/StringManip.tests.cpp" >
<Original>
s == "--"
</Original>
<Expanded>
"--" == "--"
</Expanded>
</Expression>
<OverallResults successes="2" failures="0" expectedFailures="0" skipped="false"/>
</Section>
<OverallResults successes="2" failures="0" expectedFailures="0" skipped="false"/>
</Section>
<Section name="escape '" filename="tests/<exe-name>/IntrospectiveTests/StringManip.tests.cpp" >
<Expression success="true" type="CHECK" filename="tests/<exe-name>/IntrospectiveTests/StringManip.tests.cpp" >
<Original>
@@ -120,13 +120,13 @@ TEST_CASE( "Optional supports move ops", "[optional][approvals]" ) {
}
SECTION( "Move construction from optional" ) {
Optional<MoveChecker> 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<MoveChecker> 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)
}
}
@@ -18,7 +18,6 @@
#include <catch2/generators/catch_generators_adapters.hpp>
#include <catch2/generators/catch_generators_random.hpp>
#include <catch2/generators/catch_generators_range.hpp>
#include <catch2/generators/catch_generator_exception.hpp>
// Tests of generator implementation details
TEST_CASE("Generators internals", "[generators][internals]") {
@@ -8,6 +8,7 @@
#include <catch2/catch_test_macros.hpp>
#include <catch2/internal/catch_random_integer_helpers.hpp>
#include <random>
namespace {
template <typename Int>
@@ -20,6 +21,58 @@ namespace {
CHECK( extendedMult( b, a ) ==
ExtendedMultResult<Int>{ upper_result, lower_result } );
}
// Simple (and slow) implmentation of extended multiplication for tests
constexpr Catch::Detail::ExtendedMultResult<std::uint64_t>
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<std::uint64_t>( rng );
auto b = fillBitsFrom<std::uint64_t>( 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;
@@ -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<TestType>::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 <typename T>
@@ -570,6 +587,8 @@ TEMPLATE_TEST_CASE( "uniform_floating_point_distribution is reproducible",
REQUIRE_THAT( generated, Catch::Matchers::RangeEquals( uniform_fp_test_params<TestType>::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<TestType>::highest;
const auto highest = TestType(385.125);
Catch::uniform_floating_point_distribution<TestType> dist( highest,
highest );
@@ -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<StringIStream>();
auto& sstreamRef = *sstream.get();
auto& sstreamRef = *sstream;
Catch::ConfigData cfg_data;
cfg_data.rngSeed = 1234;
@@ -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, "'", "|'"));
@@ -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 );
@@ -152,7 +152,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",
-1
View File
@@ -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
/**
@@ -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);
}
}
+1 -1
View File
@@ -39,7 +39,7 @@ namespace {
};
template <typename T> struct Template_Fixture_2 {
Template_Fixture_2() {}
Template_Fixture_2() = default;
T m_a;
};
+116 -2
View File
@@ -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 <class T, std::enable_if_t<std::is_same_v<T, int>, 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<TypeWithConstevalLit0Comparison> : 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
@@ -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]") {
+7 -7
View File
@@ -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();
}

Some files were not shown because too many files have changed in this diff Show More