mirror of
https://github.com/catchorg/Catch2.git
synced 2025-09-11 16:05:40 +02:00
Compare commits
18 Commits
Author | SHA1 | Date | |
---|---|---|---|
![]() |
9e1bdca466 | ||
![]() |
be49a539e4 | ||
![]() |
558bbe7d24 | ||
![]() |
f4881f172a | ||
![]() |
de06340e7d | ||
![]() |
4dd6e81d0f | ||
![]() |
9e6d7bbf00 | ||
![]() |
dfb025cf08 | ||
![]() |
c638c57209 | ||
![]() |
a575536abe | ||
![]() |
1eb42eed97 | ||
![]() |
46e99e258f | ||
![]() |
a212fb440b | ||
![]() |
1e98c820bb | ||
![]() |
bcfa9b1775 | ||
![]() |
a3876adba6 | ||
![]() |
2a4725b40e | ||
![]() |
a81c01d4f9 |
35
.travis.yml
35
.travis.yml
@@ -237,19 +237,46 @@ matrix:
|
||||
apt:
|
||||
sources: *all_sources
|
||||
packages: ['valgrind', 'lcov', 'g++-7']
|
||||
env: COMPILER='g++-7' CPP14=1 VALGRIND=1
|
||||
|
||||
env: COMPILER='g++-7' CPP14=1 VALGRIND=1
|
||||
|
||||
- os: osx
|
||||
osx_image: xcode9.1
|
||||
compiler: clang
|
||||
env: COMPILER='clang++' CPP14=1 EXAMPLES=1 COVERAGE=1 EXTRAS=1
|
||||
|
||||
# 7/ C++17 builds
|
||||
- os: linux
|
||||
compiler: gcc
|
||||
addons: *gcc7
|
||||
env: COMPILER='g++-7' CPP17=1
|
||||
|
||||
- os: linux
|
||||
compiler: gcc
|
||||
addons: *gcc7
|
||||
env: COMPILER='g++-7' EXAMPLES=1 COVERAGE=1 EXTRAS=1 CPP17=1
|
||||
|
||||
- os: linux
|
||||
compiler: clang
|
||||
addons:
|
||||
apt:
|
||||
sources: *all_sources
|
||||
packages: ['clang-6.0', 'libstdc++-8-dev']
|
||||
env: COMPILER='clang++-6.0' CPP17=1
|
||||
|
||||
- os: linux
|
||||
compiler: clang
|
||||
addons:
|
||||
apt:
|
||||
sources: *all_sources
|
||||
packages: ['clang-6.0', 'libstdc++-8-dev']
|
||||
env: COMPILER='clang++-6.0' CPP17=1 EXAMPLES=1 COVERAGE=1 EXTRAS=1
|
||||
|
||||
install:
|
||||
- DEPS_DIR="${TRAVIS_BUILD_DIR}/deps"
|
||||
- mkdir -p ${DEPS_DIR} && cd ${DEPS_DIR}
|
||||
- |
|
||||
if [[ "${TRAVIS_OS_NAME}" == "linux" ]]; then
|
||||
CMAKE_URL="http://www.cmake.org/files/v3.5/cmake-3.5.2-Linux-x86_64.tar.gz"
|
||||
CMAKE_URL="http://cmake.org/files/v3.8/cmake-3.8.2-Linux-x86_64.tar.gz"
|
||||
mkdir cmake && travis_retry wget --no-check-certificate --quiet -O - ${CMAKE_URL} | tar --strip-components=1 -xz -C cmake
|
||||
export PATH=${DEPS_DIR}/cmake/bin:${PATH}
|
||||
elif [[ "${TRAVIS_OS_NAME}" == "osx" ]]; then
|
||||
@@ -263,7 +290,7 @@ before_script:
|
||||
- python scripts/generateSingleHeader.py
|
||||
|
||||
# Use Debug builds for running Valgrind and building examples
|
||||
- cmake -H. -BBuild-Debug -DCMAKE_BUILD_TYPE=Debug -Wdev -DUSE_CPP14=${CPP14} -DCATCH_USE_VALGRIND=${VALGRIND} -DCATCH_BUILD_EXAMPLES=${EXAMPLES} -DCATCH_ENABLE_COVERAGE=${COVERAGE} -DCATCH_BUILD_EXTRA_TESTS=${EXTRAS}
|
||||
- cmake -H. -BBuild-Debug -DCMAKE_BUILD_TYPE=Debug -Wdev -DUSE_CPP14=${CPP14} -DUSE_CPP17=${CPP17} -DCATCH_USE_VALGRIND=${VALGRIND} -DCATCH_BUILD_EXAMPLES=${EXAMPLES} -DCATCH_ENABLE_COVERAGE=${COVERAGE} -DCATCH_BUILD_EXTRA_TESTS=${EXTRAS}
|
||||
# Don't bother with release build for coverage build
|
||||
- cmake -H. -BBuild-Release -DCMAKE_BUILD_TYPE=Release -Wdev -DUSE_CPP14=${CPP14}
|
||||
|
||||
|
@@ -6,7 +6,7 @@ if(NOT DEFINED PROJECT_NAME)
|
||||
set(NOT_SUBPROJECT ON)
|
||||
endif()
|
||||
|
||||
project(Catch2 LANGUAGES CXX VERSION 2.4.0)
|
||||
project(Catch2 LANGUAGES CXX VERSION 2.4.1)
|
||||
|
||||
# Provide path for scripts
|
||||
list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_LIST_DIR}/CMake")
|
||||
|
@@ -5,11 +5,11 @@
|
||||
[](https://travis-ci.org/catchorg/Catch2)
|
||||
[](https://ci.appveyor.com/project/catchorg/catch2)
|
||||
[](https://codecov.io/gh/catchorg/Catch2)
|
||||
[](https://wandbox.org/permlink/4wRGoJ1WzLjRM7HZ)
|
||||
[](https://wandbox.org/permlink/E0msqwbW7U4PVbHn)
|
||||
[](https://discord.gg/4CWS9zD)
|
||||
|
||||
|
||||
<a href="https://github.com/catchorg/Catch2/releases/download/v2.4.0/catch.hpp">The latest version of the single header can be downloaded directly using this link</a>
|
||||
<a href="https://github.com/catchorg/Catch2/releases/download/v2.4.1/catch.hpp">The latest version of the single header can be downloaded directly using this link</a>
|
||||
|
||||
## Catch2 is released!
|
||||
|
||||
|
@@ -4,7 +4,7 @@ from conans import ConanFile, CMake
|
||||
|
||||
class CatchConan(ConanFile):
|
||||
name = "Catch"
|
||||
version = "2.4.0"
|
||||
version = "2.4.1"
|
||||
description = "A modern, C++-native, header-only, framework for unit-tests, TDD and BDD"
|
||||
author = "philsquared"
|
||||
generators = "cmake"
|
||||
|
@@ -71,7 +71,7 @@ REQUIRE( performComputation() == 2.1_a );
|
||||
`Approx` is constructed with defaults that should cover most simple cases.
|
||||
For the more complex cases, `Approx` provides 3 customization points:
|
||||
|
||||
* __epsilon__ - epsilon serves to set the percentage by which a result
|
||||
* __epsilon__ - epsilon serves to set the coefficient by which a result
|
||||
can differ from `Approx`'s value before it is rejected.
|
||||
_By default set to `std::numeric_limits<float>::epsilon()*100`._
|
||||
* __margin__ - margin serves to set the the absolute value by which
|
||||
|
@@ -1,6 +1,12 @@
|
||||
<a id="top"></a>
|
||||
# CI and other odd pieces
|
||||
|
||||
**Contents**<br>
|
||||
[Continuous Integration systems](#continuous-integration-systems)<br>
|
||||
[Other reporters](#other-reporters)<br>
|
||||
[Low-level tools](#low-level-tools)<br>
|
||||
[CMake](#cmake)<br>
|
||||
|
||||
This page talks about how Catch integrates with Continuous Integration
|
||||
Build Systems may refer to low-level tools, like CMake, or larger systems that run on servers, like Jenkins or TeamCity. This page will talk about both.
|
||||
|
||||
|
@@ -1,6 +1,12 @@
|
||||
<a id="top"></a>
|
||||
# CMake integration
|
||||
|
||||
**Contents**<br>
|
||||
[CMake target](#cmake-target)<br>
|
||||
[Automatic test registration](#automatic-test-registration)<br>
|
||||
[CMake project options](#cmake-project-options)<br>
|
||||
[Installing Catch2 from git repository](#installing-catch2-from-git-repository)<br>
|
||||
|
||||
Because we use CMake to build Catch2, we also provide a couple of
|
||||
integration points for our users.
|
||||
|
||||
@@ -47,7 +53,7 @@ to your CMake module path.
|
||||
`Catch.cmake` provides function `catch_discover_tests` to get tests from
|
||||
a target. This function works by running the resulting executable with
|
||||
`--list-test-names-only` flag, and then parsing the output to find all
|
||||
existing tests.
|
||||
existing tests.
|
||||
|
||||
#### Usage
|
||||
```cmake
|
||||
@@ -184,6 +190,27 @@ included in the installation. Defaults to `ON`.
|
||||
* `BUILD_TESTING` -- When `ON` and the project is not used as a subproject,
|
||||
Catch2's test binary will be built. Defaults to `ON`.
|
||||
|
||||
|
||||
## Installing Catch2 from git repository
|
||||
|
||||
If you cannot install Catch2 from a package manager (e.g. Ubuntu 16.04
|
||||
provides catch only in version 1.2.0) you might want to install it from
|
||||
the repository instead. Assuming you have enough rights, you can just
|
||||
install it to the default location, like so:
|
||||
```
|
||||
$ git clone https://github.com/catchorg/Catch2.git
|
||||
$ cd Catch2
|
||||
$ cmake -Bbuild -H. -DBUILD_TESTING=OFF
|
||||
$ sudo cmake --build build/ --target install
|
||||
```
|
||||
|
||||
If you do not have superuser rights, you will also need to specify
|
||||
[CMAKE_INSTALL_PREFIX](https://cmake.org/cmake/help/latest/variable/CMAKE_INSTALL_PREFIX.html)
|
||||
when configuring the build, and then modify your calls to
|
||||
[find_package](https://cmake.org/cmake/help/latest/command/find_package.html)
|
||||
accordingly.
|
||||
|
||||
|
||||
---
|
||||
|
||||
[Home](Readme.md#top)
|
||||
|
@@ -24,7 +24,7 @@
|
||||
[Usage](#usage)<br>
|
||||
[Specify the section to run](#specify-the-section-to-run)<br>
|
||||
[Filenames as tags](#filenames-as-tags)<br>
|
||||
[Override output colouring](#use-colour)<br>
|
||||
[Override output colouring](#override-output-colouring)<br>
|
||||
|
||||
Catch works quite nicely without any command line options at all - but for those times when you want greater control the following options are available.
|
||||
Click one of the followings links to take you straight to that option - or scroll on to browse the available options.
|
||||
|
@@ -3,15 +3,19 @@
|
||||
|
||||
**Contents**<br>
|
||||
[main()/ implementation](#main-implementation)<br>
|
||||
[Reporter / Listener interfaces](#reporter--listener-interfaces)<br>
|
||||
[Prefixing Catch macros](#prefixing-catch-macros)<br>
|
||||
[Terminal colour](#terminal-colour)<br>
|
||||
[Console width](#console-width)<br>
|
||||
[stdout](#stdout)<br>
|
||||
[Fallback stringifier](#fallback-stringifier)<br>
|
||||
[Default reporter](#default-reporter)<br>
|
||||
[C++11 toggles](#c11-toggles)<br>
|
||||
[C++17 toggles](#c17-toggles)<br>
|
||||
[Other toggles](#other-toggles)<br>
|
||||
[Windows header clutter](#windows-header-clutter)<br>
|
||||
[Enabling stringification](#enabling-stringification)<br>
|
||||
[Disabling exceptions](#disabling-exceptions)<br>
|
||||
|
||||
Catch is designed to "just work" as much as possible. For most people the only configuration needed is telling Catch which source file should host all the implementation code (```CATCH_CONFIG_MAIN```).
|
||||
|
||||
@@ -24,7 +28,7 @@ Nonetheless there are still some occasions where finer control is needed. For th
|
||||
|
||||
Although Catch is header only it still, internally, maintains a distinction between interface headers and headers that contain implementation. Only one source file in your test project should compile the implementation headers and this is controlled through the use of one of these macros - one of these identifiers should be defined before including Catch in *exactly one implementation file in your project*.
|
||||
|
||||
# Reporter / Listener interfaces
|
||||
## Reporter / Listener interfaces
|
||||
|
||||
CATCH_CONFIG_EXTERNAL_INTERFACES // Brings in necessary headers for Reporter/Listener implementation
|
||||
|
||||
@@ -123,6 +127,8 @@ Catch's selection, by defining either `CATCH_CONFIG_CPP11_TO_STRING` or
|
||||
## C++17 toggles
|
||||
|
||||
CATCH_CONFIG_CPP17_UNCAUGHT_EXCEPTIONS // Use std::uncaught_exceptions instead of std::uncaught_exception
|
||||
CATCH_CONFIG_CPP17_STRING_VIEW // Provide StringMaker specialization for std::string_view
|
||||
CATCH_CONFIG_CPP17_VARIANT // Override C++17 detection for CATCH_CONFIG_ENABLE_VARIANT_STRINGMAKER
|
||||
|
||||
Catch contains basic compiler/standard detection and attempts to use
|
||||
some C++17 features whenever appropriate. This automatic detection
|
||||
@@ -197,6 +203,7 @@ By default, Catch does not stringify some types from the standard library. This
|
||||
CATCH_CONFIG_ENABLE_PAIR_STRINGMAKER // Provide StringMaker specialization for std::pair
|
||||
CATCH_CONFIG_ENABLE_TUPLE_STRINGMAKER // Provide StringMaker specialization for std::tuple
|
||||
CATCH_CONFIG_ENABLE_CHRONO_STRINGMAKER // Provide StringMaker specialization for std::chrono::duration, std::chrono::timepoint
|
||||
CATCH_CONFIG_ENABLE_VARIANT_STRINGMAKER // Provide StringMaker specialization for std::variant, std::monostate (on C++17)
|
||||
CATCH_CONFIG_ENABLE_ALL_STRINGMAKERS // Defines all of the above
|
||||
|
||||
|
||||
|
@@ -1,12 +1,19 @@
|
||||
<a id="top"></a>
|
||||
# Known limitations
|
||||
|
||||
Catch has some known limitations, that we are not planning to change. Some of these are caused by our desire to support C++98 compilers, some of these are caused by our desire to keep Catch crossplatform, some exist because their priority is seen as low compared to the development effort they would need and some other yet are compiler/runtime bugs.
|
||||
Over time, some limitations of Catch2 emerged. Some of these are due
|
||||
to implementation details that cannot be easily changed, some of these
|
||||
are due to lack of development resources on our part, and some of these
|
||||
are due to plain old 3rd party bugs.
|
||||
|
||||
|
||||
## Implementation limits
|
||||
### Sections nested in loops
|
||||
|
||||
If you are using `SECTION`s inside loops, you have to create them with different name per loop's iteration. The recommended way to do so is to incorporate the loop's counter into section's name, like so
|
||||
If you are using `SECTION`s inside loops, you have to create them with
|
||||
different name per loop's iteration. The recommended way to do so is to
|
||||
incorporate the loop's counter into section's name, like so:
|
||||
|
||||
```cpp
|
||||
TEST_CASE( "Looped section" ) {
|
||||
for (char i = '0'; i < '5'; ++i) {
|
||||
@@ -17,6 +24,27 @@ TEST_CASE( "Looped section" ) {
|
||||
}
|
||||
```
|
||||
|
||||
or with a `DYNAMIC_SECTION` macro (that was made for exactly this purpose):
|
||||
|
||||
```cpp
|
||||
TEST_CASE( "Looped section" ) {
|
||||
for (char i = '0'; i < '5'; ++i) {
|
||||
DYNAMIC_SECTION( "Looped section " << i) {
|
||||
SUCCEED( "Everything is OK" );
|
||||
}
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
### Tests might be run again if last section fails
|
||||
|
||||
If the last section in a test fails, it might be run again. This is because
|
||||
Catch2 discovers `SECTION`s dynamically, as they are about to run, and
|
||||
if the last section in test case is aborted during execution (e.g. via
|
||||
the `REQUIRE` family of macros), Catch2 does not know that there are no
|
||||
more sections in that test case and must run the test case again.
|
||||
|
||||
|
||||
## Features
|
||||
This section outlines some missing features, what is their status and their possible workarounds.
|
||||
|
||||
@@ -137,3 +165,14 @@ If you are seeing a problem like this, i.e. a weird test paths that trigger only
|
||||
This is a bug in `libstdc++-4.8`, where all matching methods from `<regex>` return false. Since `Matches` uses `<regex>` internally, if the underlying implementation does not work, it doesn't work either.
|
||||
|
||||
Workaround: Use newer version of `libstdc++`.
|
||||
|
||||
|
||||
### libstdc++, `_GLIBCXX_DEBUG` macro and random ordering of tests
|
||||
|
||||
Running a Catch2 binary compiled against libstdc++ with `_GLIBCXX_DEBUG`
|
||||
macro defined with `--order rand` will cause a debug check to trigger and
|
||||
abort the run due to self-assignment.
|
||||
[This is a known bug inside libstdc++](https://stackoverflow.com/questions/22915325/avoiding-self-assignment-in-stdshuffle/23691322)
|
||||
|
||||
Workaround: Don't use `--order rand` when compiling against debug-enabled
|
||||
libstdc++.
|
||||
|
@@ -3,12 +3,15 @@
|
||||
|
||||
## Already available
|
||||
|
||||
- Catch main: [Catch-provided main](../examples/000-CatchMain.cpp)
|
||||
- Test Case: [Single-file](../examples/010-TestCase.cpp)
|
||||
- Test Case: [Multiple-file 1](../examples/020-TestCase-1.cpp), [2](../examples/020-TestCase-2.cpp)
|
||||
- Assertion: [REQUIRE, CHECK](../examples/030-Asn-Require-Check.cpp)
|
||||
- Fixture: [Sections](../examples/100-Fix-Section.cpp)
|
||||
- Fixture: [Class-based fixtures](../examples/110-Fix-ClassFixture.cpp)
|
||||
- BDD: [SCENARIO, GIVEN, WHEN, THEN](../examples/120-Bdd-ScenarioGivenWhenThen.cpp)
|
||||
- Report: [Catch-provided main](../examples/200-Rpt-CatchMain.cpp)
|
||||
- Report: [TeamCity reporter](../examples/207-Rpt-TeamCityReporter.cpp)
|
||||
- Listener: [Listeners](../examples/210-Evt-EventListeners.cpp)
|
||||
- Configuration: [Provide your own output streams](../examples/231-Cfg-OutputStreams.cpp)
|
||||
|
||||
@@ -27,7 +30,10 @@
|
||||
- Logging: [FAIL, FAIL_CHECK - Issue message and force failure/continue](../examples/170-Log-Fail.cpp)
|
||||
- Logging: [SUCCEED - Issue message and continue](../examples/180-Log-Succeed.cpp)
|
||||
- Report: [User-defined type](../examples/190-Rpt-ReportUserDefinedType.cpp)
|
||||
- Report: [Reporter](../examples/200-Rpt-UserDefinedReporter.cpp)
|
||||
- Report: [User-defined reporter](../examples/202-Rpt-UserDefinedReporter.cpp)
|
||||
- Report: [Automake reporter](../examples/205-Rpt-AutomakeReporter.cpp)
|
||||
- Report: [TAP reporter](../examples/206-Rpt-TapReporter.cpp)
|
||||
- Report: [Multiple reporter](../examples/208-Rpt-MultipleReporters.cpp)
|
||||
- Configuration: [Provide your own main()](../examples/220-Cfg-OwnMain.cpp)
|
||||
- Configuration: [Compile-time configuration](../examples/230-Cfg-CompileTimeConfiguration.cpp)
|
||||
- Configuration: [Run-time configuration](../examples/240-Cfg-RunTimeConfiguration.cpp)
|
||||
|
@@ -1,6 +1,12 @@
|
||||
<a id="top"></a>
|
||||
# Supplying main() yourself
|
||||
|
||||
**Contents**<br>
|
||||
[Let Catch take full control of args and config](#let-catch-take-full-control-of-args-and-config)<br>
|
||||
[Amending the config](#amending-the-config)<br>
|
||||
[Adding your own command line options](#adding-your-own-command-line-options)<br>
|
||||
[Version detection](#version-detection)<br>
|
||||
|
||||
The easiest way to use Catch is to let it supply ```main()``` for you and handle configuring itself from the command line.
|
||||
|
||||
This is achieved by writing ```#define CATCH_CONFIG_MAIN``` before the ```#include "catch.hpp"``` in *exactly one* source file.
|
||||
|
@@ -1,12 +1,44 @@
|
||||
<a id="top"></a>
|
||||
|
||||
# 2.4.0
|
||||
# Release notes
|
||||
**Contents**<br>
|
||||
[2.4.1](#241)<br>
|
||||
[2.4.0](#240)<br>
|
||||
[2.3.0](#230)<br>
|
||||
[2.2.3](#223)<br>
|
||||
[2.2.2](#222)<br>
|
||||
[2.2.1](#221)<br>
|
||||
[2.2.0](#220)<br>
|
||||
[2.1.2](#212)<br>
|
||||
[2.1.1](#211)<br>
|
||||
[2.1.0](#210)<br>
|
||||
[2.0.1](#201)<br>
|
||||
[Older versions](#older-versions)<br>
|
||||
[Even Older versions](#even-older-versions)<br>
|
||||
|
||||
|
||||
## 2.4.1
|
||||
|
||||
### Improvements
|
||||
* Added a StringMaker for `std::(w)string_view` (#1375, #1376)
|
||||
* Added a StringMaker for `std::variant` (#1380)
|
||||
* This one is disabled by default to avoid increased compile-time drag
|
||||
* Added detection for cygwin environment without `std::to_string` (#1396, #1397)
|
||||
|
||||
### Fixes
|
||||
* `UnorderedEqualsMatcher` will no longer accept erroneously accept
|
||||
vectors that share suffix, but are not permutation of the desired vector
|
||||
* Abort after (`-x N`) can no longer be overshot by nested `REQUIRES` and
|
||||
subsequently ignored (#1391, #1392)
|
||||
|
||||
|
||||
## 2.4.0
|
||||
|
||||
**This release brings two new experimental features, generator support
|
||||
and a `-fno-exceptions` support. Being experimental means that they
|
||||
will not be subject to the usual stability guarantees provided by semver.**
|
||||
|
||||
## Improvements
|
||||
### Improvements
|
||||
* Various small runtime performance improvements
|
||||
* `CAPTURE` macro is now variadic
|
||||
* Added `AND_GIVEN` macro (#1360)
|
||||
@@ -16,11 +48,11 @@ will not be subject to the usual stability guarantees provided by semver.**
|
||||
* Doing so limits the functionality somewhat
|
||||
* Look [into the documentation](configuration.md#disablingexceptions) for details
|
||||
|
||||
## Fixes
|
||||
### Fixes
|
||||
* Suppressed `-Wnon-virtual-dtor` warnings in Matchers (#1357)
|
||||
* Suppressed `-Wunreachable-code` warnings in floating point matchers (#1350)
|
||||
|
||||
## CMake
|
||||
### CMake
|
||||
* It is now possible to override which Python is used to run Catch's tests (#1365)
|
||||
* Catch now provides infrastructure for adding tests that check compile-time configuration
|
||||
* Catch no longer tries to install itself when used as a subproject (#1373)
|
||||
@@ -29,7 +61,7 @@ will not be subject to the usual stability guarantees provided by semver.**
|
||||
* This fixes conan installation of Catch
|
||||
|
||||
|
||||
# 2.3.0
|
||||
## 2.3.0
|
||||
|
||||
**This release changes the include paths provided by our CMake and
|
||||
pkg-config integration. The proper include path for the single-header
|
||||
@@ -40,7 +72,7 @@ than `single_include/catch.hpp`.**
|
||||
|
||||
|
||||
|
||||
## Fixes
|
||||
### Fixes
|
||||
* Fixed Objective-C++ build
|
||||
* `-Wunused-variable` suppression no longer leaks from Catch's header under Clang
|
||||
* Implementation of the experimental new output capture can now be disabled (#1335)
|
||||
@@ -48,7 +80,7 @@ than `single_include/catch.hpp`.**
|
||||
* The JUnit and XML reporters will no longer skip over successful tests when running without `-s` (#1264, #1267, #1310)
|
||||
* See improvements for more details
|
||||
|
||||
## Improvements
|
||||
### Improvements
|
||||
* pkg-config and CMake integration has been rewritten
|
||||
* If you use them, the new include path is `#include <catch2/catch.hpp>`
|
||||
* CMake installation now also installs scripts from `contrib/`
|
||||
@@ -60,12 +92,12 @@ than `single_include/catch.hpp`.**
|
||||
* This means that you can do `DYNAMIC_SECTION("For X := " << x)`.
|
||||
|
||||
|
||||
# 2.2.3
|
||||
## 2.2.3
|
||||
|
||||
**To fix some of the bugs, some behavior had to change in potentially breaking manner.**
|
||||
**This means that even though this is a patch release, it might not be a drop-in replacement.**
|
||||
|
||||
## Fixes
|
||||
### Fixes
|
||||
* Listeners are now called before reporter
|
||||
* This was always documented to be the case, now it actually works that way
|
||||
* Catch's commandline will no longer accept multiple reporters
|
||||
@@ -84,23 +116,23 @@ than `single_include/catch.hpp`.**
|
||||
* **This has potential to be a breaking change**
|
||||
* Fixed compilation error when a type has an `operator<<` with templated lhs (#1285, #1306)
|
||||
|
||||
## Improvements
|
||||
### Improvements
|
||||
* Added a new, experimental, output capture (#1243)
|
||||
* This capture can also redirect output written via C apis, e.g. `printf`
|
||||
* To opt-in, define `CATCH_CONFIG_EXPERIMENTAL_REDIRECT` in the implementation file
|
||||
* Added a new fallback stringifier for classes derived from `std::exception`
|
||||
* Both `StringMaker` specialization and `operator<<` overload are given priority
|
||||
|
||||
## Miscellaneous
|
||||
### Miscellaneous
|
||||
* `contrib/` now contains dbg scripts that skip over Catch's internals (#904, #1283)
|
||||
* `gdbinit` for gdb `lldbinit` for lldb
|
||||
* `CatchAddTests.cmake` no longer strips whitespace from tests (#1265, #1281)
|
||||
* Online documentation now describes `--use-colour` option (#1263)
|
||||
|
||||
|
||||
# 2.2.2
|
||||
## 2.2.2
|
||||
|
||||
## Fixes
|
||||
### Fixes
|
||||
* Fixed bug in `WithinAbs::match()` failing spuriously (#1228)
|
||||
* Fixed clang-tidy diagnostic about virtual call in destructor (#1226)
|
||||
* Reduced the number of GCC warnings suppression leaking out of the header (#1090, #1091)
|
||||
@@ -109,7 +141,7 @@ than `single_include/catch.hpp`.**
|
||||
* On platforms where `std::chrono::high_resolution_clock`'s resolution is low, the calibration would appear stuck
|
||||
* Fixed compilation error when stringifying static arrays of `unsigned char`s (#1238)
|
||||
|
||||
## Improvements
|
||||
### Improvements
|
||||
* XML encoder now hex-encodes invalid UTF-8 sequences (#1207)
|
||||
* This affects xml and junit reporters
|
||||
* Some invalid UTF-8 parts are left as is, e.g. surrogate pairs. This is because certain extensions of UTF-8 allow them, such as WTF-8.
|
||||
@@ -118,29 +150,29 @@ than `single_include/catch.hpp`.**
|
||||
* Added `PredicateMatcher`, a matcher that takes an arbitrary predicate function (#1236)
|
||||
* See [documentation for details](https://github.com/catchorg/Catch2/blob/master/docs/matchers.md)
|
||||
|
||||
## Others
|
||||
### Others
|
||||
* Modified CMake-installed pkg-config to allow `#include <catch.hpp>`(#1239)
|
||||
* The plans to standardize on `#include <catch2/catch.hpp>` are still in effect
|
||||
|
||||
|
||||
# 2.2.1
|
||||
## 2.2.1
|
||||
|
||||
## Fixes
|
||||
### Fixes
|
||||
* Fixed compilation error when compiling Catch2 with `std=c++17` against libc++ (#1214)
|
||||
* Clara (Catch2's CLI parsing library) used `std::optional` without including it explicitly
|
||||
* Fixed Catch2 return code always being 0 (#1215)
|
||||
* In the words of STL, "We feel superbad about letting this in"
|
||||
|
||||
|
||||
# 2.2.0
|
||||
## 2.2.0
|
||||
|
||||
## Fixes
|
||||
### Fixes
|
||||
* Hidden tests are not listed by default when listing tests (#1175)
|
||||
* This makes `catch_discover_tests` CMake script work better
|
||||
* Fixed regression that meant `<windows.h>` could potentially not be included properly (#1197)
|
||||
* Fixed installing `Catch2ConfigVersion.cmake` when Catch2 is a subproject.
|
||||
|
||||
## Improvements
|
||||
### Improvements
|
||||
* Added an option to warn (+ exit with error) when no tests were ran (#1158)
|
||||
* Use as `-w NoTests`
|
||||
* Added provisional support for Emscripten (#1114)
|
||||
@@ -152,38 +184,38 @@ than `single_include/catch.hpp`.**
|
||||
* Added support for DJGPP DOS crosscompiler (#1206)
|
||||
|
||||
|
||||
# 2.1.2
|
||||
## 2.1.2
|
||||
|
||||
## Fixes
|
||||
### Fixes
|
||||
* Fixed compilation error with `-fno-rtti` (#1165)
|
||||
* Fixed NoAssertion warnings
|
||||
* `operator<<` is used before range-based stringification (#1172)
|
||||
* Fixed `-Wpedantic` warnings (extra semicolons and binary literals) (#1173)
|
||||
|
||||
|
||||
## Improvements
|
||||
### Improvements
|
||||
* Added `CATCH_VERSION_{MAJOR,MINOR,PATCH}` macros (#1131)
|
||||
* Added `BrightYellow` colour for use in reporters (#979)
|
||||
* It is also used by ConsoleReporter for reconstructed expressions
|
||||
|
||||
## Other changes
|
||||
### Other changes
|
||||
* Catch is now exported as a CMake package and linkable target (#1170)
|
||||
|
||||
# 2.1.1
|
||||
## 2.1.1
|
||||
|
||||
## Improvements
|
||||
### Improvements
|
||||
* Static arrays are now properly stringified like ranges across MSVC/GCC/Clang
|
||||
* Embedded newer version of Clara -- v1.1.1
|
||||
* This should fix some warnings dragged in from Clara
|
||||
* MSVC's CLR exceptions are supported
|
||||
|
||||
|
||||
## Fixes
|
||||
### Fixes
|
||||
* Fixed compilation when comparison operators do not return bool (#1147)
|
||||
* Fixed CLR exceptions blowing up the executable during translation (#1138)
|
||||
|
||||
|
||||
## Other changes
|
||||
### Other changes
|
||||
* Many CMake changes
|
||||
* `NO_SELFTEST` option is deprecated, use `BUILD_TESTING` instead.
|
||||
* Catch specific CMake options were prefixed with `CATCH_` for namespacing purposes
|
||||
@@ -191,9 +223,9 @@ than `single_include/catch.hpp`.**
|
||||
|
||||
|
||||
|
||||
# 2.1.0
|
||||
## 2.1.0
|
||||
|
||||
## Improvements
|
||||
### Improvements
|
||||
* Various performance improvements
|
||||
* On top of the performance regression fixes
|
||||
* Experimental support for PCH was added (#1061)
|
||||
@@ -203,7 +235,7 @@ than `single_include/catch.hpp`.**
|
||||
* Bugs in g++ 4.x and 5.x mean that some of them have to be left in
|
||||
|
||||
|
||||
## Fixes
|
||||
### Fixes
|
||||
* Fixed performance regression from Catch classic
|
||||
* One of the performance improvement patches for Catch classic was not applied to Catch2
|
||||
* Fixed platform detection for iOS (#1084)
|
||||
@@ -216,7 +248,7 @@ than `single_include/catch.hpp`.**
|
||||
* Fixed `std::uncaught_exception` deprecation warning (#1124)
|
||||
|
||||
|
||||
## New features
|
||||
### New features
|
||||
* New Matchers
|
||||
* Regex matcher for strings, `Matches`.
|
||||
* Set-equal matcher for vectors, `UnorderedEquals`
|
||||
@@ -225,15 +257,15 @@ than `single_include/catch.hpp`.**
|
||||
* Containers are objects that respond to ADL `begin(T)` and `end(T)`.
|
||||
|
||||
|
||||
## Other changes
|
||||
### Other changes
|
||||
* Reporters will now be versioned in the `single_include` folder to ensure their compatibility with the last released version
|
||||
|
||||
|
||||
|
||||
|
||||
# 2.0.1
|
||||
## 2.0.1
|
||||
|
||||
## Breaking changes
|
||||
### Breaking changes
|
||||
* Removed C++98 support
|
||||
* Removed legacy reporter support
|
||||
* Removed legacy generator support
|
||||
@@ -263,7 +295,7 @@ than `single_include/catch.hpp`.**
|
||||
* `INFINITY == Approx(INFINITY)` returns true
|
||||
|
||||
|
||||
## Improvements
|
||||
### Improvements
|
||||
* Reporters and Listeners can be defined in files different from the main file
|
||||
* The file has to define `CATCH_CONFIG_EXTERNAL_INTERFACES` before including catch.hpp.
|
||||
* Errors that happen during set up before main are now caught and properly reported once main is entered
|
||||
@@ -297,7 +329,7 @@ than `single_include/catch.hpp`.**
|
||||
* Add `pkg-config` support to CMake install command
|
||||
|
||||
|
||||
## Fixes
|
||||
### Fixes
|
||||
* Don't use console colour if running in XCode
|
||||
* Explicit constructor in reporter base class
|
||||
* Swept out `-Wweak-vtables`, `-Wexit-time-destructors`, `-Wglobal-constructors` warnings
|
||||
@@ -309,7 +341,7 @@ than `single_include/catch.hpp`.**
|
||||
* Suppressed C4061 warning under MSVC
|
||||
|
||||
|
||||
## Internal changes
|
||||
### Internal changes
|
||||
* The development version now uses .cpp files instead of header files containing implementation.
|
||||
* This makes partial rebuilds much faster during development
|
||||
* The expression decomposition layer has been rewritten
|
||||
@@ -317,13 +349,33 @@ than `single_include/catch.hpp`.**
|
||||
* New library (TextFlow) is used for formatting text to output
|
||||
|
||||
|
||||
# Older versions
|
||||
## Older versions
|
||||
|
||||
## 1.11.x
|
||||
### 1.12.x
|
||||
|
||||
### 1.11.0
|
||||
#### 1.12.2
|
||||
##### Fixes
|
||||
* Fixed missing <cassert> include
|
||||
|
||||
#### Fixes
|
||||
#### 1.12.1
|
||||
|
||||
##### Fixes
|
||||
* Fixed deprecation warning in `ScopedMessage::~ScopedMessage`
|
||||
* All uses of `min` or `max` identifiers are now wrapped in parentheses
|
||||
* This avoids problems when Windows headers define `min` and `max` macros
|
||||
|
||||
#### 1.12.0
|
||||
|
||||
##### Fixes
|
||||
* Fixed compilation for strict C++98 mode (ie not gnu++98) and older compilers (#1103)
|
||||
* `INFO` messages are included in the `xml` reporter output even without `-s` specified.
|
||||
|
||||
|
||||
### 1.11.x
|
||||
|
||||
#### 1.11.0
|
||||
|
||||
##### Fixes
|
||||
* The original expression in `REQUIRE_FALSE( expr )` is now reporter properly as `!( expr )` (#1051)
|
||||
* Previously the parentheses were missing and `x != y` would be expanded as `!x != x`
|
||||
* `Approx::Margin` is now inclusive (#952)
|
||||
@@ -331,7 +383,7 @@ than `single_include/catch.hpp`.**
|
||||
* This means that `REQUIRE( 0.25f == Approx( 0.0f ).margin( 0.25f ) )` passes, instead of fails
|
||||
* `RandomNumberGenerator::result_type` is now unsigned (#1050)
|
||||
|
||||
#### Improvements
|
||||
##### Improvements
|
||||
* `__JETBRAINS_IDE__` macro handling is now CLion version specific (#1017)
|
||||
* When CLion 2017.3 or newer is detected, `__COUNTER__` is used instead of
|
||||
* TeamCity reporter now explicitly flushes output stream after each report (#1057)
|
||||
@@ -339,35 +391,35 @@ than `single_include/catch.hpp`.**
|
||||
* `ParseAndAddCatchTests` now can add test files as dependency to CMake configuration
|
||||
* This means you do not have to manually rerun CMake configuration step to detect new tests
|
||||
|
||||
## 1.10.x
|
||||
### 1.10.x
|
||||
|
||||
### 1.10.0
|
||||
#### 1.10.0
|
||||
|
||||
#### Fixes
|
||||
##### Fixes
|
||||
* Evaluation layer has been rewritten (backported from Catch 2)
|
||||
* The new layer is much simpler and fixes some issues (#981)
|
||||
* Implemented workaround for VS 2017 raw string literal stringification bug (#995)
|
||||
* Fixed interaction between `[!shouldfail]` and `[!mayfail]` tags and sections
|
||||
* Previously sections with failing assertions would be marked as failed, not failed-but-ok
|
||||
|
||||
#### Improvements
|
||||
##### Improvements
|
||||
* Added [libidentify](https://github.com/janwilmans/LibIdentify) support
|
||||
* Added "wait-for-keypress" option
|
||||
|
||||
## 1.9.x
|
||||
### 1.9.x
|
||||
|
||||
### 1.9.6
|
||||
#### 1.9.6
|
||||
|
||||
#### Improvements
|
||||
##### Improvements
|
||||
* Catch's runtime overhead has been significantly decreased (#937, #939)
|
||||
* Added `--list-extra-info` cli option (#934).
|
||||
* It lists all tests together with extra information, ie filename, line number and description.
|
||||
|
||||
|
||||
|
||||
### 1.9.5
|
||||
#### 1.9.5
|
||||
|
||||
#### Fixes
|
||||
##### Fixes
|
||||
* Truthy expressions are now reconstructed properly, not as booleans (#914)
|
||||
* Various warnings are no longer erroneously suppressed in test files (files that include `catch.hpp`, but do not define `CATCH_CONFIG_MAIN` or `CATCH_CONFIG_RUNNER`) (#871)
|
||||
* Catch no longer fails to link when main is compiled as C++, but linked against Objective-C (#855)
|
||||
@@ -375,35 +427,35 @@ than `single_include/catch.hpp`.**
|
||||
* Previously any GCC with minor version less than 3 would be incorrectly classified as not supporting `__COUNTER__`.
|
||||
* Suppressed C4996 warning caused by upcoming updated to MSVC 2017, marking `std::uncaught_exception` as deprecated. (#927)
|
||||
|
||||
#### Improvements
|
||||
##### Improvements
|
||||
* CMake integration script now incorporates debug messages and registers tests in an improved way (#911)
|
||||
* Various documentation improvements
|
||||
|
||||
|
||||
|
||||
### 1.9.4
|
||||
#### 1.9.4
|
||||
|
||||
#### Fixes
|
||||
##### Fixes
|
||||
* `CATCH_FAIL` macro no longer causes compilation error without variadic macro support
|
||||
* `INFO` messages are no longer cleared after being reported once
|
||||
|
||||
#### Improvements and minor changes
|
||||
##### Improvements and minor changes
|
||||
* Catch now uses `wmain` when compiled under Windows and `UNICODE` is defined.
|
||||
* Note that Catch still officially supports only ASCII
|
||||
|
||||
### 1.9.3
|
||||
#### 1.9.3
|
||||
|
||||
#### Fixes
|
||||
##### Fixes
|
||||
* Completed the fix for (lack of) uint64_t in earlier Visual Studios
|
||||
|
||||
### 1.9.2
|
||||
#### 1.9.2
|
||||
|
||||
#### Improvements and minor changes
|
||||
##### Improvements and minor changes
|
||||
* All of `Approx`'s member functions now accept strong typedefs in C++11 mode (#888)
|
||||
* Previously `Approx::scale`, `Approx::epsilon`, `Approx::margin` and `Approx::operator()` didn't.
|
||||
|
||||
|
||||
#### Fixes
|
||||
##### Fixes
|
||||
* POSIX signals are now disabled by default under QNX (#889)
|
||||
* QNX does not support current enough (2001) POSIX specification
|
||||
* JUnit no longer counts exceptions as failures if given test case is marked as ok to fail.
|
||||
@@ -411,22 +463,22 @@ than `single_include/catch.hpp`.**
|
||||
* Catch no longer attempts to define `uint64_t` on windows (#862)
|
||||
* This was causing trouble when compiled under Cygwin
|
||||
|
||||
#### Other
|
||||
##### Other
|
||||
* Catch is now compiled under MSVC 2017 using `std:c++latest` (C++17 mode) in CI
|
||||
* We now provide cmake script that autoregisters Catch tests into ctest.
|
||||
* See `contrib` folder.
|
||||
|
||||
|
||||
### 1.9.1
|
||||
#### 1.9.1
|
||||
|
||||
#### Fixes
|
||||
##### Fixes
|
||||
* Unexpected exceptions are no longer ignored by default (#885, #887)
|
||||
|
||||
|
||||
### 1.9.0
|
||||
#### 1.9.0
|
||||
|
||||
|
||||
#### Improvements and minor changes
|
||||
##### Improvements and minor changes
|
||||
* Catch no longer attempts to ensure the exception type passed by user in `REQUIRE_THROWS_AS` is a constant reference.
|
||||
* It was causing trouble when `REQUIRE_THROWS_AS` was used inside templated functions
|
||||
* This actually reverts changes made in v1.7.2
|
||||
@@ -440,7 +492,7 @@ than `single_include/catch.hpp`.**
|
||||
* When Catch is compiled using C++11, `Approx` is now constructible with anything that can be explicitly converted to `double`.
|
||||
* Captured messages are now printed on unexpected exceptions
|
||||
|
||||
#### Fixes:
|
||||
##### Fixes:
|
||||
* Clang's `-Wexit-time-destructors` should be suppressed for Catch's internals
|
||||
* GCC's `-Wparentheses` is now suppressed for all TU's that include `catch.hpp`.
|
||||
* This is functionally a revert of changes made in 1.8.0, where we tried using `_Pragma` based suppression. This should have kept the suppression local to Catch's assertions, but bugs in GCC's handling of `_Pragma`s in C++ mode meant that it did not always work.
|
||||
@@ -449,18 +501,18 @@ than `single_include/catch.hpp`.**
|
||||
* [Details can be found in documentation](configuration.md#catch_config_cpp11_stream_insertable_check)
|
||||
|
||||
|
||||
#### Other notes:
|
||||
##### Other notes:
|
||||
* We have added VS 2017 to our CI
|
||||
* Work on Catch 2 should start soon
|
||||
|
||||
|
||||
|
||||
## 1.8.x
|
||||
### 1.8.x
|
||||
|
||||
### 1.8.2
|
||||
#### 1.8.2
|
||||
|
||||
|
||||
#### Improvements and minor changes
|
||||
##### Improvements and minor changes
|
||||
* TAP reporter now behaves as if `-s` was always set
|
||||
* This should be more consistent with the protocol desired behaviour.
|
||||
* Compact reporter now obeys `-d yes` argument (#780)
|
||||
@@ -474,7 +526,7 @@ than `single_include/catch.hpp`.**
|
||||
* Listeners provide a way to hook into events generated by running your tests, including start and end of run, every test case, every section and every assertion.
|
||||
|
||||
|
||||
#### Fixes:
|
||||
##### Fixes:
|
||||
* Catch no longer attempts to reconstruct expression that led to a fatal error (#810)
|
||||
* This fixes possible signal/SEH loop when processing expressions, where the signal was triggered by expression decomposition.
|
||||
* Fixed (C4265) missing virtual destructor warning in Matchers (#844)
|
||||
@@ -491,21 +543,21 @@ than `single_include/catch.hpp`.**
|
||||
* Regression in Objective-C bindings (Matchers) fixed (#854)
|
||||
|
||||
|
||||
#### Other notes:
|
||||
##### Other notes:
|
||||
* We have added VS 2013 and 2015 to our CI
|
||||
* Catch Classic (1.x.x) now contains its own, forked, version of Clara (the argument parser).
|
||||
|
||||
|
||||
|
||||
### 1.8.1
|
||||
#### 1.8.1
|
||||
|
||||
#### Fixes
|
||||
##### Fixes
|
||||
|
||||
Cygwin issue with `gettimeofday` - `#define` was not early enough
|
||||
|
||||
### 1.8.0
|
||||
#### 1.8.0
|
||||
|
||||
#### New features/ minor changes
|
||||
##### New features/ minor changes
|
||||
|
||||
* Matchers have new, simpler (and documented) interface.
|
||||
* Catch provides string and vector matchers.
|
||||
@@ -525,7 +577,7 @@ Cygwin issue with `gettimeofday` - `#define` was not early enough
|
||||
* `Approx` now supports an optional margin of absolute error
|
||||
* It has also received [new documentation](assertions.md#top).
|
||||
|
||||
#### Fixes
|
||||
##### Fixes
|
||||
* Silenced C4312 ("conversion from int to 'ClassName *") warnings in the evaluate layer.
|
||||
* Fixed C4512 ("assignment operator could not be generated") warnings under VS2013.
|
||||
* Cygwin compatibility fixes
|
||||
@@ -536,15 +588,15 @@ Cygwin issue with `gettimeofday` - `#define` was not early enough
|
||||
* Otherwise it is supressed for the whole TU
|
||||
* Fixed test spec parser issue (with escapes in multiple names)
|
||||
|
||||
#### Other
|
||||
##### Other
|
||||
* Various documentation fixes and improvements
|
||||
|
||||
|
||||
## 1.7.x
|
||||
### 1.7.x
|
||||
|
||||
### 1.7.2
|
||||
#### 1.7.2
|
||||
|
||||
#### Fixes and minor improvements
|
||||
##### Fixes and minor improvements
|
||||
Xml:
|
||||
|
||||
(technically the first two are breaking changes but are also fixes and arguably break few if any people)
|
||||
@@ -563,9 +615,9 @@ Other:
|
||||
* Silenced a few more warnings in different circumstances
|
||||
* Travis improvements
|
||||
|
||||
### 1.7.1
|
||||
#### 1.7.1
|
||||
|
||||
#### Fixes:
|
||||
##### Fixes:
|
||||
* Fixed inconsistency in defining `NOMINMAX` and `WIN32_LEAN_AND_MEAN` inside `catch.hpp`.
|
||||
* Fixed SEH-related compilation error under older MinGW compilers, by making Windows SEH handling opt-in for compilers other than MSVC.
|
||||
* For specifics, look into the [documentation](configuration.md#top).
|
||||
@@ -575,9 +627,9 @@ Other:
|
||||
* Fixed possible infinite recursion in Windows SEH.
|
||||
* Fixed possible compilation error caused by Catch's operator overloads being ambiguous in regards to user-defined templated operators.
|
||||
|
||||
### 1.7.0
|
||||
#### 1.7.0
|
||||
|
||||
#### Features/ Changes:
|
||||
##### Features/ Changes:
|
||||
* Catch now runs significantly faster for passing tests
|
||||
* Microbenchmark focused on Catch's overhead went from ~3.4s to ~0.7s.
|
||||
* Real world test using [JSON for Modern C++](https://github.com/nlohmann/json)'s test suite went from ~6m 25s to ~4m 14s.
|
||||
@@ -591,30 +643,30 @@ Other:
|
||||
* Certain characters (space, tab, etc) are now pretty printed.
|
||||
* This means that a `char c = ' '; REQUIRE(c == '\t');` would be printed as `' ' == '\t'`, instead of ` == 9`.
|
||||
|
||||
#### Fixes:
|
||||
##### Fixes:
|
||||
* Text formatting no longer attempts to access out-of-bounds characters under certain conditions.
|
||||
* THROW family of assertions no longer trigger `-Wunused-value` on expressions containing explicit cast.
|
||||
* Breaking into debugger under OS X works again and no longer required `DEBUG` to be defined.
|
||||
* Compilation no longer breaks under certain compiler if a lambda is used inside assertion macro.
|
||||
|
||||
#### Other:
|
||||
##### Other:
|
||||
* Catch's CMakeLists now defines install command.
|
||||
* Catch's CMakeLists now generates projects with warnings enabled.
|
||||
|
||||
|
||||
## 1.6.x
|
||||
### 1.6.x
|
||||
|
||||
### 1.6.1
|
||||
#### 1.6.1
|
||||
|
||||
#### Features/ Changes:
|
||||
##### Features/ Changes:
|
||||
* Catch now supports breaking into debugger on Linux
|
||||
|
||||
#### Fixes:
|
||||
##### Fixes:
|
||||
* Generators no longer leak memory (generators are still unsupported in general)
|
||||
* JUnit reporter now reports UTC timestamps, instead of "tbd"
|
||||
* `CHECK_THAT` macro is now properly defined as `CATCH_CHECK_THAT` when using `CATCH_` prefixed macros
|
||||
|
||||
#### Other:
|
||||
##### Other:
|
||||
* Types with overloaded `&&` operator are no longer evaluated twice when used in an assertion macro.
|
||||
* The use of `__COUNTER__` is supressed when Catch is parsed by CLion
|
||||
* This change is not active when compiling a binary
|
||||
@@ -624,28 +676,28 @@ Other:
|
||||
* This can be disabled if needed, see [documentation](configuration.md#top) for details.
|
||||
|
||||
|
||||
### 1.6.0
|
||||
#### 1.6.0
|
||||
|
||||
#### Cmake/ projects:
|
||||
##### Cmake/ projects:
|
||||
* Moved CMakeLists.txt to root, made it friendlier for CLion and generating XCode and VS projects, and removed the manually maintained XCode and VS projects.
|
||||
|
||||
#### Features/ Changes:
|
||||
##### Features/ Changes:
|
||||
* Approx now supports `>=` and `<=`
|
||||
* Can now use `\` to escape chars in test names on command line
|
||||
* Standardize C++11 feature toggles
|
||||
|
||||
#### Fixes:
|
||||
##### Fixes:
|
||||
* Blue shell colour
|
||||
* Missing argument to `CATCH_CHECK_THROWS`
|
||||
* Don't encode extended ASCII in XML
|
||||
* use `std::shuffle` on more compilers (fixes deprecation warning/error)
|
||||
* Use `__COUNTER__` more consistently (where available)
|
||||
|
||||
#### Other:
|
||||
##### Other:
|
||||
* Tweaks and changes to scripts - particularly for Approval test - to make them more portable
|
||||
|
||||
|
||||
# Even Older versions
|
||||
## Even Older versions
|
||||
Release notes were not maintained prior to v1.6.0, but you should be able to work them out from the Git history
|
||||
|
||||
---
|
||||
|
@@ -25,8 +25,8 @@ Because of the way the junit format is structured the run must complete before a
|
||||
There are a few additional reporters, for specific build systems, in the Catch repository (in `include\reporters`) which you can `#include` in your project if you would like to make use of them.
|
||||
Do this in one source file - the same one you have `CATCH_CONFIG_MAIN` or `CATCH_CONFIG_RUNNER`.
|
||||
|
||||
* `teamcity` writes the native, streaming, format that [TeamCity](https://www.jetbrains.com/teamcity/) understands.
|
||||
Use this when building as part of a TeamCity build to see results as they happen.
|
||||
* `teamcity` writes the native, streaming, format that [TeamCity](https://www.jetbrains.com/teamcity/) understands.
|
||||
Use this when building as part of a TeamCity build to see results as they happen ([code example](../examples/207-Rpt-TeamCityReporter.cpp)).
|
||||
* `tap` writes in the TAP ([Test Anything Protocol](https://en.wikipedia.org/wiki/Test_Anything_Protocol)) format.
|
||||
* `automake` writes in a format that correspond to [automake .trs](https://www.gnu.org/software/automake/manual/html_node/Log-files-generation-and-test-results-recording.html) files
|
||||
|
||||
|
@@ -1,6 +1,12 @@
|
||||
<a id="top"></a>
|
||||
# String conversions
|
||||
|
||||
**Contents**<br>
|
||||
[operator << overload for std::ostream](#operator--overload-for-stdostream)<br>
|
||||
[Catch::StringMaker specialisation](#catchstringmaker-specialisation)<br>
|
||||
[Catch::is_range specialisation](#catchis_range-specialisation)<br>
|
||||
[Exceptions](#exceptions)<br>
|
||||
|
||||
Catch needs to be able to convert types you use in assertions and logging expressions into strings (for logging and reporting purposes).
|
||||
Most built-in or std types are supported out of the box but there are two ways that you can tell Catch how to convert your own types (or other, third-party types) into strings.
|
||||
|
||||
@@ -19,7 +25,7 @@ std::ostream& operator << ( std::ostream& os, T const& value ) {
|
||||
|
||||
You should put this function in the same namespace as your type and have it declared before including Catch's header.
|
||||
|
||||
## Catch::StringMaker<T> specialisation
|
||||
## Catch::StringMaker specialisation
|
||||
If you don't want to provide an ```operator <<``` overload, or you want to convert your type differently for testing purposes, you can provide a specialization for `Catch::StringMaker<T>`:
|
||||
|
||||
```
|
||||
@@ -33,7 +39,7 @@ namespace Catch {
|
||||
}
|
||||
```
|
||||
|
||||
## Catch::is_range<T> specialisation
|
||||
## Catch::is_range specialisation
|
||||
As a fallback, Catch attempts to detect if the type can be iterated
|
||||
(`begin(T)` and `end(T)` are valid) and if it can be, it is stringified
|
||||
as a range. For certain types this can lead to infinite recursion, so
|
||||
|
@@ -15,7 +15,7 @@
|
||||
The simplest way to get Catch2 is to download the latest [single header version](https://raw.githubusercontent.com/catchorg/Catch2/master/single_include/catch2/catch.hpp). The single header is generated by merging a set of individual headers but it is still just normal source code in a header file.
|
||||
|
||||
Alternative ways of getting Catch2 include using your system package
|
||||
manager, or installing it using its CMake package.
|
||||
manager, or installing it using [its CMake package](cmake-integration.md#installing-catch2-from-git-repository).
|
||||
|
||||
The full source for Catch2, including test projects, documentation, and other things, is hosted on GitHub. [http://catch-lib.net](http://catch-lib.net) will redirect you there.
|
||||
|
||||
|
27
examples/200-Rpt-CatchMain.cpp
Normal file
27
examples/200-Rpt-CatchMain.cpp
Normal file
@@ -0,0 +1,27 @@
|
||||
// 200-Rpt-CatchMain.cpp
|
||||
|
||||
// In a Catch project with multiple files, dedicate one file to compile the
|
||||
// source code of Catch itself and reuse the resulting object file for linking.
|
||||
|
||||
// Let Catch provide main():
|
||||
#define CATCH_CONFIG_MAIN
|
||||
|
||||
#include <catch2/catch.hpp>
|
||||
|
||||
#ifdef CATCH_EXAMPLE_RPT_1
|
||||
#include CATCH_EXAMPLE_RPT_1
|
||||
#endif
|
||||
|
||||
#ifdef CATCH_EXAMPLE_RPT_2
|
||||
#include CATCH_EXAMPLE_RPT_2
|
||||
#endif
|
||||
|
||||
#ifdef CATCH_EXAMPLE_RPT_3
|
||||
#include CATCH_EXAMPLE_RPT_3
|
||||
#endif
|
||||
|
||||
// That's it
|
||||
|
||||
// Compile implementation of Catch for use with files that do contain tests:
|
||||
// - g++ -std=c++11 -Wall -I$(CATCH_ROOT) -DCATCH_EXAMPLE_RPT_1=\"include/reporters/catch_reporter_teamcity.hpp\" -o 200-Rpt-CatchMainTeamCity.o -c 200-Rpt-CatchMain.cpp
|
||||
// cl -EHsc -I%CATCH_ROOT% -DCATCH_EXAMPLE_RPT_1=\"include/reporters/catch_reporter_teamcity.hpp\" -Fo200-Rpt-CatchMainTeamCity.obj -c 200-Rpt-CatchMain.cpp
|
171
examples/207-Rpt-TeamCityReporter.cpp
Normal file
171
examples/207-Rpt-TeamCityReporter.cpp
Normal file
@@ -0,0 +1,171 @@
|
||||
// 207-Rpt-TeamCityReporter.cpp
|
||||
|
||||
// Catch has built-in and external reporters:
|
||||
// Built-in:
|
||||
// - compact
|
||||
// - console
|
||||
// - junit
|
||||
// - xml
|
||||
// External:
|
||||
// - automake
|
||||
// - tap
|
||||
// - teamcity (this example)
|
||||
|
||||
// main() and reporter code provided in 200-Rpt-CatchMain.cpp
|
||||
|
||||
#include <catch2/catch.hpp>
|
||||
|
||||
#ifdef _MSC_VER
|
||||
# pragma warning (disable : 4702) // Disable warning: unreachable code
|
||||
#endif
|
||||
|
||||
TEST_CASE( "TeamCity passes unconditionally succeeding assertion", "[teamcity]" ) {
|
||||
|
||||
SUCCEED();
|
||||
}
|
||||
|
||||
TEST_CASE( "TeamCity reports unconditionally failing assertion", "[teamcity]" ) {
|
||||
|
||||
FAIL();
|
||||
}
|
||||
|
||||
TEST_CASE( "TeamCity reports failing check", "[teamcity]" ) {
|
||||
|
||||
REQUIRE( 3 == 7 );
|
||||
}
|
||||
|
||||
TEST_CASE( "TeamCity reports failing check-false", "[teamcity]" ) {
|
||||
|
||||
REQUIRE_FALSE( 3 == 3 );
|
||||
}
|
||||
|
||||
TEST_CASE( "TeamCity reports failing check-that", "[teamcity]" ) {
|
||||
|
||||
using namespace Catch;
|
||||
|
||||
REQUIRE_THAT( "hello", Contains( "world" ) );
|
||||
}
|
||||
|
||||
TEST_CASE( "TeamCity reports unexpected exception", "[teamcity]" ) {
|
||||
|
||||
REQUIRE( (throw std::runtime_error("surprise!"), true) );
|
||||
}
|
||||
|
||||
TEST_CASE( "TeamCity reports undesired exception", "[teamcity]" ) {
|
||||
|
||||
REQUIRE_NOTHROW( (throw std::runtime_error("surprise!"), true) );
|
||||
}
|
||||
|
||||
TEST_CASE( "TeamCity reports missing expected exception", "[teamcity]" ) {
|
||||
|
||||
REQUIRE_THROWS( true );
|
||||
}
|
||||
|
||||
TEST_CASE( "TeamCity reports missing specific expected exception", "[teamcity]" ) {
|
||||
|
||||
REQUIRE_THROWS_AS( throw std::bad_alloc(), std::runtime_error );
|
||||
}
|
||||
|
||||
TEST_CASE( "TeamCity reports unexpected message in expected exception", "[teamcity]" ) {
|
||||
|
||||
using namespace Catch;
|
||||
|
||||
CHECK_THROWS_WITH( throw std::runtime_error("hello"), "world" );
|
||||
CHECK_THROWS_WITH( throw std::runtime_error("hello"), Contains("world") );
|
||||
}
|
||||
|
||||
struct MyException: public std::runtime_error
|
||||
{
|
||||
MyException( char const * text )
|
||||
: std::runtime_error( text ) {}
|
||||
|
||||
~MyException() override;
|
||||
};
|
||||
|
||||
// prevent -Wweak-vtables:
|
||||
MyException::~MyException() = default;
|
||||
|
||||
struct MyExceptionMatcher : Catch::MatcherBase< std::runtime_error >
|
||||
{
|
||||
std::string m_text;
|
||||
|
||||
MyExceptionMatcher( char const * text )
|
||||
: m_text( text )
|
||||
{}
|
||||
|
||||
~MyExceptionMatcher() override;
|
||||
|
||||
bool match( std::runtime_error const & arg ) const override
|
||||
{
|
||||
return m_text == arg.what() ;
|
||||
}
|
||||
|
||||
std::string describe() const override
|
||||
{
|
||||
return "it's me";
|
||||
}
|
||||
};
|
||||
|
||||
// prevent -Wweak-vtables:
|
||||
MyExceptionMatcher::~MyExceptionMatcher() = default;
|
||||
|
||||
TEST_CASE( "TeamCity failing check-throws-matches", "[teamcity]" ) {
|
||||
|
||||
CHECK_THROWS_MATCHES( throw MyException("hello"), MyException, MyExceptionMatcher("world") );
|
||||
}
|
||||
|
||||
// [!throws] - lets Catch know that this test is likely to throw an exception even if successful.
|
||||
// This causes the test to be excluded when running with -e or --nothrow.
|
||||
|
||||
// No special effects for the reporter.
|
||||
|
||||
TEST_CASE( "TeamCity throwing exception with tag [!throws]", "[teamcity][!throws]" ) {
|
||||
|
||||
REQUIRE_THROWS( throw std::runtime_error("unsurprisingly") );
|
||||
}
|
||||
|
||||
// [!mayfail] - doesn't fail the test if any given assertion fails (but still reports it). This can be useful to flag a work-in-progress, or a known issue that you don't want to immediately fix but still want to track in your tests.
|
||||
|
||||
TEST_CASE( "TeamCity failing assertion with tag [!mayfail]", "[teamcity][!mayfail] " ) {
|
||||
|
||||
REQUIRE( 3 == 7 ); // doesn't fail test case this time, reports: testIgnored
|
||||
REQUIRE( 3 == 3 );
|
||||
}
|
||||
|
||||
// [!shouldfail] - like [!mayfail] but fails the test if it passes.
|
||||
// This can be useful if you want to be notified of accidental, or third-party, fixes.
|
||||
|
||||
TEST_CASE( "TeamCity succeeding assertion with tag [!shouldfail]", "[teamcity][!shouldfail]" ) {
|
||||
|
||||
SUCCEED( "Marked [!shouldfail]" );
|
||||
}
|
||||
|
||||
// Compile & run:
|
||||
// - g++ -std=c++11 -Wall -I$(CATCH_ROOT) -DCATCH_EXAMPLE_RPT_1=\"include/reporters/catch_reporter_teamcity.hpp\" -o 200-Rpt-CatchMainTeamCity.o -c 200-Rpt-CatchMain.cpp
|
||||
// - g++ -std=c++11 -Wall -I$(CATCH_ROOT) -o 207-Rpt-TeamCityReporter 207-Rpt-TeamCityReporter.cpp 200-Rpt-CatchMainTeamCity.o && 207-Rpt-TeamCityReporter --list-reporters
|
||||
//
|
||||
// - cl -EHsc -I%CATCH_ROOT% -DCATCH_EXAMPLE_RPT_1=\"include/reporters/catch_reporter_teamcity.hpp\" -Fo200-Rpt-CatchMainTeamCity.obj -c 200-Rpt-CatchMain.cpp
|
||||
// - cl -EHsc -I%CATCH_ROOT% 207-Rpt-TeamCityReporter.cpp 200-Rpt-CatchMainTeamCity.o && 207-Rpt-TeamCityReporter --list-reporters
|
||||
|
||||
// Compilation output (--list-reporters):
|
||||
// Available reporters:
|
||||
// compact: Reports test results on a single line, suitable for IDEs
|
||||
// console: Reports test results as plain lines of text
|
||||
// junit: Reports test results in an XML format that looks like Ant's
|
||||
// junitreport target
|
||||
// teamcity: Reports test results as TeamCity service messages
|
||||
// xml: Reports test results as an XML document
|
||||
|
||||
// Expected output (abbreviated and broken into shorter lines):
|
||||
//
|
||||
// prompt> 207-Rpt-TeamCityReporter.exe --reporter teamcity
|
||||
// ##teamcity[testSuiteStarted name='207-Rpt-TeamCityReporter.exe']
|
||||
// ##teamcity[testStarted name='TeamCity passes unconditionally succeeding assertion']
|
||||
// ##teamcity[testFinished name='TeamCity passes unconditionally succeeding assertion' duration='1']
|
||||
// ##teamcity[testStarted name='TeamCity reports unconditionally failing assertion']
|
||||
// ##teamcity[testFailed name='TeamCity reports unconditionally failing assertion' /
|
||||
// message='.../examples/207-Rpt-TeamCityReporter.cpp:23|n/
|
||||
// ...............................................................................|n|n/
|
||||
// .../examples/207-Rpt-TeamCityReporter.cpp:25|nexplicit failure']
|
||||
// ##teamcity[testFinished name='TeamCity reports unconditionally failing assertion' duration='3']
|
||||
// ...
|
@@ -8,10 +8,13 @@ cmake_minimum_required( VERSION 3.0 )
|
||||
|
||||
project( CatchExamples CXX )
|
||||
|
||||
message( STATUS "Examples included" )
|
||||
|
||||
# define folders used:
|
||||
|
||||
set( EXAMPLES_DIR ${CATCH_DIR}/examples )
|
||||
set( HEADER_DIR ${CATCH_DIR}/single_include )
|
||||
set( REPORTER_HEADER_DIR ${CATCH_DIR}/include/reporters )
|
||||
|
||||
# single-file sources:
|
||||
|
||||
@@ -43,6 +46,26 @@ set( SOURCES_IDIOMATIC_TESTS
|
||||
210-Evt-EventListeners.cpp
|
||||
)
|
||||
|
||||
# main-s for reporter-specific test sources:
|
||||
|
||||
set( SOURCES_REPORTERS_MAIN
|
||||
200-Rpt-CatchMain.cpp
|
||||
)
|
||||
|
||||
string( REPLACE ".cpp" "" BASENAMES_REPORTERS_MAIN 200-Rpt-CatchMain.cpp )
|
||||
|
||||
set( NAMES_REPORTERS TeamCity )
|
||||
|
||||
foreach( reporter ${NAMES_REPORTERS} )
|
||||
list( APPEND SOURCES_SPECIFIC_REPORTERS_MAIN ${BASENAMES_REPORTERS_MAIN}${reporter}.cpp )
|
||||
endforeach()
|
||||
|
||||
# sources to combine with 200-Rpt-CatchMain{Reporter}.cpp:
|
||||
|
||||
set( SOURCES_REPORTERS_TESTS
|
||||
207-Rpt-TeamCityReporter.cpp
|
||||
)
|
||||
|
||||
# check if all sources are listed, warn if not:
|
||||
|
||||
set( SOURCES_ALL
|
||||
@@ -50,6 +73,8 @@ set( SOURCES_ALL
|
||||
${SOURCES_SINGLE_FILE}
|
||||
${SOURCES_IDIOMATIC_MAIN}
|
||||
${SOURCES_IDIOMATIC_TESTS}
|
||||
${SOURCES_REPORTERS_MAIN}
|
||||
${SOURCES_REPORTERS_TESTS}
|
||||
)
|
||||
|
||||
foreach( name ${SOURCES_ALL} )
|
||||
@@ -62,16 +87,31 @@ CheckFileList( SOURCES_ALL_PATH ${EXAMPLES_DIR} )
|
||||
|
||||
string( REPLACE ".cpp" "" BASENAMES_SINGLE_FILE "${SOURCES_SINGLE_FILE}" )
|
||||
string( REPLACE ".cpp" "" BASENAMES_IDIOMATIC_TESTS "${SOURCES_IDIOMATIC_TESTS}" )
|
||||
string( REPLACE ".cpp" "" BASENAMES_REPORTERS_TESTS "${SOURCES_REPORTERS_TESTS}" )
|
||||
string( REPLACE ".cpp" "" BASENAMES_REPORTERS_MAIN "${SOURCES_REPORTERS_MAIN}" )
|
||||
|
||||
set( TARGETS_SINGLE_FILE ${BASENAMES_SINGLE_FILE} )
|
||||
set( TARGETS_IDIOMATIC_TESTS ${BASENAMES_IDIOMATIC_TESTS} )
|
||||
set( TARGETS_ALL ${TARGETS_SINGLE_FILE} ${TARGETS_IDIOMATIC_TESTS} 020-TestCase CatchMain )
|
||||
set( TARGETS_REPORTERS_TESTS ${BASENAMES_REPORTERS_TESTS} )
|
||||
set( TARGETS_REPORTERS_MAIN ${BASENAMES_REPORTERS_MAIN} )
|
||||
|
||||
set( TARGETS_ALL
|
||||
${TARGETS_SINGLE_FILE}
|
||||
020-TestCase
|
||||
${TARGETS_IDIOMATIC_TESTS} CatchMain
|
||||
${TARGETS_REPORTERS_TESTS} CatchMainTeamCity
|
||||
)
|
||||
|
||||
# define program targets:
|
||||
|
||||
add_library( CatchMain OBJECT ${EXAMPLES_DIR}/${SOURCES_IDIOMATIC_MAIN} ${HEADER_DIR}/catch2/catch.hpp )
|
||||
add_library( CatchMain OBJECT ${EXAMPLES_DIR}/${SOURCES_IDIOMATIC_MAIN} ${HEADER_DIR}/catch2/catch.hpp )
|
||||
#add_library( CatchMainAutomake OBJECT ${EXAMPLES_DIR}/200-Rpt-CatchMain.cpp ${HEADER_DIR}/catch2/catch.hpp )
|
||||
#add_library( CatchMainTap OBJECT ${EXAMPLES_DIR}/200-Rpt-CatchMain.cpp ${HEADER_DIR}/catch2/catch.hpp )
|
||||
add_library( CatchMainTeamCity OBJECT ${EXAMPLES_DIR}/200-Rpt-CatchMain.cpp ${HEADER_DIR}/catch2/catch.hpp )
|
||||
|
||||
add_executable( 020-TestCase ${EXAMPLES_DIR}/020-TestCase-1.cpp ${EXAMPLES_DIR}/020-TestCase-2.cpp ${HEADER_DIR}/catch2/catch.hpp )
|
||||
#target_compile_definitions( CatchMainAutomake PRIVATE CATCH_EXAMPLE_RPT_1=\"include/reporters/catch_reporter_automake.hpp\" )
|
||||
#target_compile_definitions( CatchMainTap PRIVATE CATCH_EXAMPLE_RPT_1=\"include/reporters/catch_reporter_tap.hpp\" )
|
||||
target_compile_definitions( CatchMainTeamCity PRIVATE CATCH_EXAMPLE_RPT_1=\"include/reporters/catch_reporter_teamcity.hpp\" )
|
||||
|
||||
foreach( name ${TARGETS_SINGLE_FILE} )
|
||||
add_executable( ${name} ${EXAMPLES_DIR}/${name}.cpp ${HEADER_DIR}/catch2/catch.hpp )
|
||||
@@ -81,8 +121,18 @@ foreach( name ${TARGETS_IDIOMATIC_TESTS} )
|
||||
add_executable( ${name} ${EXAMPLES_DIR}/${name}.cpp $<TARGET_OBJECTS:CatchMain> ${HEADER_DIR}/catch2/catch.hpp )
|
||||
endforeach()
|
||||
|
||||
add_executable( 020-TestCase ${EXAMPLES_DIR}/020-TestCase-1.cpp ${EXAMPLES_DIR}/020-TestCase-2.cpp ${HEADER_DIR}/catch2/catch.hpp )
|
||||
|
||||
#add_executable( 207-Rpt-AutomakeReporter ${EXAMPLES_DIR}/207-Rpt-AutomakeReporter.cpp $<TARGET_OBJECTS:CatchMainAutomake> ${HEADER_DIR}/catch2/catch.hpp )
|
||||
#add_executable( 207-Rpt-TapReporter ${EXAMPLES_DIR}/207-Rpt-TapReporter.cpp $<TARGET_OBJECTS:CatchMainTap> ${HEADER_DIR}/catch2/catch.hpp )
|
||||
add_executable( 207-Rpt-TeamCityReporter ${EXAMPLES_DIR}/207-Rpt-TeamCityReporter.cpp $<TARGET_OBJECTS:CatchMainTeamCity> ${HEADER_DIR}/catch2/catch.hpp )
|
||||
|
||||
#foreach( name ${TARGETS_REPORTERS_TESTS} )
|
||||
# add_executable( ${name} ${EXAMPLES_DIR}/${name}.cpp $<TARGET_OBJECTS:CatchMain> ${HEADER_DIR}/catch2/catch.hpp )
|
||||
#endforeach()
|
||||
|
||||
foreach( name ${TARGETS_ALL} )
|
||||
target_include_directories( ${name} PRIVATE ${HEADER_DIR} )
|
||||
target_include_directories( ${name} PRIVATE ${HEADER_DIR} ${CATCH_DIR} )
|
||||
|
||||
set_property(TARGET ${name} PROPERTY CXX_STANDARD 11)
|
||||
set_property(TARGET ${name} PROPERTY CXX_EXTENSIONS OFF)
|
||||
@@ -100,3 +150,4 @@ foreach( name ${TARGETS_ALL} )
|
||||
target_compile_options( ${name} PRIVATE /W4 /w44265 /WX )
|
||||
endif()
|
||||
endforeach()
|
||||
|
||||
|
@@ -11,7 +11,7 @@
|
||||
|
||||
#define CATCH_VERSION_MAJOR 2
|
||||
#define CATCH_VERSION_MINOR 4
|
||||
#define CATCH_VERSION_PATCH 0
|
||||
#define CATCH_VERSION_PATCH 1
|
||||
|
||||
#ifdef __clang__
|
||||
# pragma clang system_header
|
||||
|
@@ -29,11 +29,11 @@
|
||||
|
||||
#ifdef __cplusplus
|
||||
|
||||
# if __cplusplus >= 201402L
|
||||
# if (__cplusplus >= 201402L) || (defined(_MSVC_LANG) && _MSVC_LANG >= 201402L)
|
||||
# define CATCH_CPP14_OR_GREATER
|
||||
# endif
|
||||
|
||||
# if __cplusplus >= 201703L
|
||||
# if (__cplusplus >= 201703L) || (defined(_MSVC_LANG) && _MSVC_LANG >= 201703L)
|
||||
# define CATCH_CPP17_OR_GREATER
|
||||
# endif
|
||||
|
||||
@@ -109,7 +109,14 @@
|
||||
// Required for some versions of Cygwin to declare gettimeofday
|
||||
// see: http://stackoverflow.com/questions/36901803/gettimeofday-not-declared-in-this-scope-cygwin
|
||||
# define _BSD_SOURCE
|
||||
// some versions of cygwin (most) do not support std::to_string. Use the libstd check.
|
||||
// https://gcc.gnu.org/onlinedocs/gcc-4.8.2/libstdc++/api/a01053_source.html line 2812-2813
|
||||
# if !((__cplusplus >= 201103L) && defined(_GLIBCXX_USE_C99) \
|
||||
&& !defined(_GLIBCXX_HAVE_BROKEN_VSWPRINTF))
|
||||
|
||||
# define CATCH_INTERNAL_CONFIG_NO_CPP11_TO_STRING
|
||||
|
||||
# endif
|
||||
#endif // __CYGWIN__
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
@@ -154,6 +161,33 @@
|
||||
#define CATCH_INTERNAL_CONFIG_COUNTER
|
||||
#endif
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
// Check if string_view is available and usable
|
||||
// The check is split apart to work around v140 (VS2015) preprocessor issue...
|
||||
#if defined(__has_include)
|
||||
#if __has_include(<string_view>) && defined(CATCH_CPP17_OR_GREATER)
|
||||
# define CATCH_INTERNAL_CONFIG_CPP17_STRING_VIEW
|
||||
#endif
|
||||
#endif
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
// Check if variant is available and usable
|
||||
#if defined(__has_include)
|
||||
# if __has_include(<variant>) && defined(CATCH_CPP17_OR_GREATER)
|
||||
# if defined(__clang__) && (__clang_major__ < 8)
|
||||
// work around clang bug with libstdc++ https://bugs.llvm.org/show_bug.cgi?id=31852
|
||||
// fix should be in clang 8, workaround in libstdc++ 8.2
|
||||
# include <ciso646>
|
||||
# if defined(__GLIBCXX__) && defined(_GLIBCXX_RELEASE) && (_GLIBCXX_RELEASE < 9)
|
||||
# define CATCH_CONFIG_NO_CPP17_VARIANT
|
||||
# else
|
||||
# define CATCH_INTERNAL_CONFIG_CPP17_VARIANT
|
||||
# endif // defined(__GLIBCXX__) && defined(_GLIBCXX_RELEASE) && (_GLIBCXX_RELEASE < 9)
|
||||
# endif // defined(__clang__) && (__clang_major__ < 8)
|
||||
# endif // __has_include(<variant>) && defined(CATCH_CPP17_OR_GREATER)
|
||||
#endif // __has_include
|
||||
|
||||
|
||||
#if defined(CATCH_INTERNAL_CONFIG_COUNTER) && !defined(CATCH_CONFIG_NO_COUNTER) && !defined(CATCH_CONFIG_COUNTER)
|
||||
# define CATCH_CONFIG_COUNTER
|
||||
#endif
|
||||
@@ -177,6 +211,14 @@
|
||||
# define CATCH_CONFIG_CPP17_UNCAUGHT_EXCEPTIONS
|
||||
#endif
|
||||
|
||||
#if defined(CATCH_INTERNAL_CONFIG_CPP17_STRING_VIEW) && !defined(CATCH_CONFIG_NO_CPP17_STRING_VIEW) && !defined(CATCH_CONFIG_CPP17_STRING_VIEW)
|
||||
# define CATCH_CONFIG_CPP17_STRING_VIEW
|
||||
#endif
|
||||
|
||||
#if defined(CATCH_INTERNAL_CONFIG_CPP17_VARIANT) && !defined(CATCH_CONFIG_NO_CPP17_VARIANT) && !defined(CATCH_CONFIG_CPP17_VARIANT)
|
||||
# define CATCH_CONFIG_CPP17_VARIANT
|
||||
#endif
|
||||
|
||||
#if defined(CATCH_CONFIG_EXPERIMENTAL_REDIRECT)
|
||||
# define CATCH_INTERNAL_CONFIG_NEW_CAPTURE
|
||||
#endif
|
||||
|
@@ -124,7 +124,7 @@ namespace Matchers {
|
||||
auto lfirst = m_target.begin(), llast = m_target.end();
|
||||
auto rfirst = vec.begin(), rlast = vec.end();
|
||||
// Cut common prefix to optimize checking of permuted parts
|
||||
while (lfirst != llast && *lfirst != *rfirst) {
|
||||
while (lfirst != llast && *lfirst == *rfirst) {
|
||||
++lfirst; ++rfirst;
|
||||
}
|
||||
if (lfirst == llast) {
|
||||
|
@@ -313,7 +313,7 @@ namespace Catch {
|
||||
}
|
||||
|
||||
bool RunContext::aborting() const {
|
||||
return m_totals.assertions.failed == static_cast<std::size_t>(m_config->abortAfter());
|
||||
return m_totals.assertions.failed >= static_cast<std::size_t>(m_config->abortAfter());
|
||||
}
|
||||
|
||||
void RunContext::runCurrentTest(std::string & redirectedCout, std::string & redirectedCerr) {
|
||||
|
@@ -116,14 +116,9 @@ std::string StringMaker<std::string>::convert(const std::string& str) {
|
||||
return s;
|
||||
}
|
||||
|
||||
#ifdef CATCH_CONFIG_WCHAR
|
||||
std::string StringMaker<std::wstring>::convert(const std::wstring& wstr) {
|
||||
std::string s;
|
||||
s.reserve(wstr.size());
|
||||
for (auto c : wstr) {
|
||||
s += (c <= 0xff) ? static_cast<char>(c) : '?';
|
||||
}
|
||||
return ::Catch::Detail::stringify(s);
|
||||
#ifdef CATCH_CONFIG_CPP17_STRING_VIEW
|
||||
std::string StringMaker<std::string_view>::convert(std::string_view str) {
|
||||
return ::Catch::Detail::stringify(std::string{ str });
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -141,7 +136,23 @@ std::string StringMaker<char*>::convert(char* str) {
|
||||
return{ "{null string}" };
|
||||
}
|
||||
}
|
||||
|
||||
#ifdef CATCH_CONFIG_WCHAR
|
||||
std::string StringMaker<std::wstring>::convert(const std::wstring& wstr) {
|
||||
std::string s;
|
||||
s.reserve(wstr.size());
|
||||
for (auto c : wstr) {
|
||||
s += (c <= 0xff) ? static_cast<char>(c) : '?';
|
||||
}
|
||||
return ::Catch::Detail::stringify(s);
|
||||
}
|
||||
|
||||
# ifdef CATCH_CONFIG_CPP17_STRING_VIEW
|
||||
std::string StringMaker<std::wstring_view>::convert(std::wstring_view str) {
|
||||
return StringMaker<std::wstring>::convert(std::wstring(str));
|
||||
}
|
||||
# endif
|
||||
|
||||
std::string StringMaker<wchar_t const*>::convert(wchar_t const * str) {
|
||||
if (str) {
|
||||
return ::Catch::Detail::stringify(std::wstring{ str });
|
||||
|
@@ -16,6 +16,10 @@
|
||||
#include "catch_compiler_capabilities.h"
|
||||
#include "catch_stream.h"
|
||||
|
||||
#ifdef CATCH_CONFIG_CPP17_STRING_VIEW
|
||||
#include <string_view>
|
||||
#endif
|
||||
|
||||
#ifdef __OBJC__
|
||||
#include "catch_objc_arc.hpp"
|
||||
#endif
|
||||
@@ -152,10 +156,11 @@ namespace Catch {
|
||||
struct StringMaker<std::string> {
|
||||
static std::string convert(const std::string& str);
|
||||
};
|
||||
#ifdef CATCH_CONFIG_WCHAR
|
||||
|
||||
#ifdef CATCH_CONFIG_CPP17_STRING_VIEW
|
||||
template<>
|
||||
struct StringMaker<std::wstring> {
|
||||
static std::string convert(const std::wstring& wstr);
|
||||
struct StringMaker<std::string_view> {
|
||||
static std::string convert(std::string_view str);
|
||||
};
|
||||
#endif
|
||||
|
||||
@@ -169,6 +174,18 @@ namespace Catch {
|
||||
};
|
||||
|
||||
#ifdef CATCH_CONFIG_WCHAR
|
||||
template<>
|
||||
struct StringMaker<std::wstring> {
|
||||
static std::string convert(const std::wstring& wstr);
|
||||
};
|
||||
|
||||
# ifdef CATCH_CONFIG_CPP17_STRING_VIEW
|
||||
template<>
|
||||
struct StringMaker<std::wstring_view> {
|
||||
static std::string convert(std::wstring_view str);
|
||||
};
|
||||
# endif
|
||||
|
||||
template<>
|
||||
struct StringMaker<wchar_t const *> {
|
||||
static std::string convert(wchar_t const * str);
|
||||
@@ -337,6 +354,7 @@ namespace Catch {
|
||||
#if defined(CATCH_CONFIG_ENABLE_ALL_STRINGMAKERS)
|
||||
# define CATCH_CONFIG_ENABLE_PAIR_STRINGMAKER
|
||||
# define CATCH_CONFIG_ENABLE_TUPLE_STRINGMAKER
|
||||
# define CATCH_CONFIG_ENABLE_VARIANT_STRINGMAKER
|
||||
# define CATCH_CONFIG_ENABLE_CHRONO_STRINGMAKER
|
||||
#endif
|
||||
|
||||
@@ -401,6 +419,34 @@ namespace Catch {
|
||||
}
|
||||
#endif // CATCH_CONFIG_ENABLE_TUPLE_STRINGMAKER
|
||||
|
||||
#if defined(CATCH_CONFIG_ENABLE_VARIANT_STRINGMAKER) && defined(CATCH_CONFIG_CPP17_VARIANT)
|
||||
#include <variant>
|
||||
namespace Catch {
|
||||
template<>
|
||||
struct StringMaker<std::monostate> {
|
||||
static std::string convert(const std::monostate&) {
|
||||
return "{ }";
|
||||
}
|
||||
};
|
||||
|
||||
template<typename... Elements>
|
||||
struct StringMaker<std::variant<Elements...>> {
|
||||
static std::string convert(const std::variant<Elements...>& variant) {
|
||||
if (variant.valueless_by_exception()) {
|
||||
return "{valueless variant}";
|
||||
} else {
|
||||
return std::visit(
|
||||
[](const auto& value) {
|
||||
return ::Catch::Detail::stringify(value);
|
||||
},
|
||||
variant
|
||||
);
|
||||
}
|
||||
}
|
||||
};
|
||||
}
|
||||
#endif // CATCH_CONFIG_ENABLE_VARIANT_STRINGMAKER
|
||||
|
||||
namespace Catch {
|
||||
struct not_this_one {}; // Tag type for detecting which begin/ end are being selected
|
||||
|
||||
|
@@ -37,7 +37,7 @@ namespace Catch {
|
||||
}
|
||||
|
||||
Version const& libraryVersion() {
|
||||
static Version version( 2, 4, 0, "", 0 );
|
||||
static Version version( 2, 4, 1, "", 0 );
|
||||
return version;
|
||||
}
|
||||
|
||||
|
@@ -1,3 +1,4 @@
|
||||
SETLOCAL EnableDelayedExpansion
|
||||
|
||||
@REM # Possibilities:
|
||||
@REM # Debug build + coverage
|
||||
@@ -7,21 +8,15 @@
|
||||
if "%CONFIGURATION%"=="Debug" (
|
||||
if "%coverage%"=="1" (
|
||||
@REM # coverage needs to build the special helper as well as the main
|
||||
cmake -Hmisc -Bbuild-misc -A%PLATFORM%
|
||||
cmake --build build-misc
|
||||
cmake -H. -BBuild -A%PLATFORM% -DUSE_WMAIN=%wmain% -DMEMORYCHECK_COMMAND=build-misc\Debug\CoverageHelper.exe -DMEMORYCHECK_COMMAND_OPTIONS=--sep-- -DMEMORYCHECK_TYPE=Valgrind
|
||||
cmake -Hmisc -Bbuild-misc -A%PLATFORM% || exit /b !ERRORLEVEL!
|
||||
cmake --build build-misc || exit /b !ERRORLEVEL!
|
||||
cmake -H. -BBuild -A%PLATFORM% -DUSE_WMAIN=%wmain% -DMEMORYCHECK_COMMAND=build-misc\Debug\CoverageHelper.exe -DMEMORYCHECK_COMMAND_OPTIONS=--sep-- -DMEMORYCHECK_TYPE=Valgrind || exit /b !ERRORLEVEL! || exit /b !ERRORLEVEL!
|
||||
) else (
|
||||
@REM # We know that coverage is 0
|
||||
if "%examples%"=="1" (
|
||||
@REM # Examples live off the single header, so it needs to be regenerated
|
||||
python scripts\generateSingleHeader.py
|
||||
cmake -H. -BBuild -A%PLATFORM% -DUSE_WMAIN=%wmain% -DCATCH_BUILD_EXAMPLES=ON -DCATCH_BUILD_EXTRA_TESTS=ON
|
||||
) else (
|
||||
@REM # This is just a plain debug build
|
||||
cmake -H. -BBuild -A%PLATFORM% -DUSE_WMAIN=%wmain%
|
||||
)
|
||||
python scripts\generateSingleHeader.py || exit /b !ERRORLEVEL!
|
||||
cmake -H. -BBuild -A%PLATFORM% -DUSE_WMAIN=%wmain% -DCATCH_BUILD_EXAMPLES=%examples% -DCATCH_BUILD_EXTRA_TESTS=%examples% || exit /b !ERRORLEVEL!
|
||||
)
|
||||
)
|
||||
if "%CONFIGURATION%"=="Release" (
|
||||
cmake -H. -BBuild -A%PLATFORM% -DUSE_WMAIN=%wmain%
|
||||
cmake -H. -BBuild -A%PLATFORM% -DUSE_WMAIN=%wmain% || exit /b !ERRORLEVEL!
|
||||
)
|
||||
|
@@ -1,13 +1,15 @@
|
||||
SETLOCAL EnableDelayedExpansion
|
||||
|
||||
cd Build
|
||||
if "%CONFIGURATION%"=="Debug" (
|
||||
if "%coverage%"=="1" (
|
||||
ctest -j 2 -C %CONFIGURATION% -D ExperimentalMemCheck
|
||||
python ..\misc\appveyorMergeCoverageScript.py
|
||||
codecov --root .. --no-color --disable gcov -f cobertura.xml -t %CODECOV_TOKEN%
|
||||
ctest -j 2 -C %CONFIGURATION% -D ExperimentalMemCheck || exit /b !ERRORLEVEL!
|
||||
python ..\misc\appveyorMergeCoverageScript.py || exit /b !ERRORLEVEL!
|
||||
codecov --root .. --no-color --disable gcov -f cobertura.xml -t %CODECOV_TOKEN% || exit /b !ERRORLEVEL!
|
||||
) else (
|
||||
ctest -j 2 -C %CONFIGURATION%
|
||||
ctest -j 2 -C %CONFIGURATION% || exit /b !ERRORLEVEL!
|
||||
)
|
||||
)
|
||||
if "%CONFIGURATION%"=="Release" (
|
||||
ctest -j 2 -C %CONFIGURATION%
|
||||
ctest -j 2 -C %CONFIGURATION% || exit /b !ERRORLEVEL!
|
||||
)
|
||||
|
@@ -38,6 +38,7 @@ set(TEST_SOURCES
|
||||
${SELF_TEST_DIR}/UsageTests/ToStringGeneral.tests.cpp
|
||||
${SELF_TEST_DIR}/UsageTests/ToStringPair.tests.cpp
|
||||
${SELF_TEST_DIR}/UsageTests/ToStringTuple.tests.cpp
|
||||
${SELF_TEST_DIR}/UsageTests/ToStringVariant.tests.cpp
|
||||
${SELF_TEST_DIR}/UsageTests/ToStringVector.tests.cpp
|
||||
${SELF_TEST_DIR}/UsageTests/ToStringWhich.tests.cpp
|
||||
${SELF_TEST_DIR}/UsageTests/Tricky.tests.cpp
|
||||
@@ -267,7 +268,10 @@ include(CTest)
|
||||
add_executable(SelfTest ${TEST_SOURCES} ${IMPL_SOURCES} ${REPORTER_SOURCES} ${SURROGATE_SOURCES} ${HEADERS})
|
||||
target_include_directories(SelfTest PRIVATE ${HEADER_DIR})
|
||||
|
||||
if(USE_CPP14)
|
||||
if(USE_CPP17)
|
||||
message(STATUS "Enabling C++17")
|
||||
set_property(TARGET SelfTest PROPERTY CXX_STANDARD 17)
|
||||
elseif(USE_CPP14)
|
||||
message(STATUS "Enabling C++14")
|
||||
set_property(TARGET SelfTest PROPERTY CXX_STANDARD 14)
|
||||
else()
|
||||
@@ -320,7 +324,7 @@ set_tests_properties(ListTests PROPERTIES
|
||||
add_test(NAME ListTags COMMAND $<TARGET_FILE:SelfTest> --list-tags)
|
||||
set_tests_properties(ListTags PROPERTIES
|
||||
PASS_REGULAR_EXPRESSION "[0-9]+ tags"
|
||||
FAIL_REGULAR_EXPRESSION "[.]")
|
||||
FAIL_REGULAR_EXPRESSION "\\[\\.\\]")
|
||||
|
||||
add_test(NAME ListReporters COMMAND $<TARGET_FILE:SelfTest> --list-reporters)
|
||||
set_tests_properties(ListReporters PROPERTIES PASS_REGULAR_EXPRESSION "Available reporters:")
|
||||
|
@@ -740,6 +740,7 @@ Decomposition.tests.cpp:<line number>: failed: truthy(false) for: Hey, its truth
|
||||
Matchers.tests.cpp:<line number>: failed: testStringForMatching(), Matches("this STRING contains 'abc' as a substring") for: "this string contains 'abc' as a substring" matches "this STRING contains 'abc' as a substring" case sensitively
|
||||
Matchers.tests.cpp:<line number>: failed: testStringForMatching(), Matches("contains 'abc' as a substring") for: "this string contains 'abc' as a substring" matches "contains 'abc' as a substring" case sensitively
|
||||
Matchers.tests.cpp:<line number>: failed: testStringForMatching(), Matches("this string contains 'abc' as a") for: "this string contains 'abc' as a substring" matches "this string contains 'abc' as a" case sensitively
|
||||
Matchers.tests.cpp:<line number>: passed: actual, !UnorderedEquals(expected) for: { 'a', 'b' } not UnorderedEquals: { 'c', 'b' }
|
||||
Message.tests.cpp:<line number>: passed: with 1 message: 'this is a success'
|
||||
Message.tests.cpp:<line number>: passed:
|
||||
BDD.tests.cpp:<line number>: passed: before == 0 for: 0 == 0
|
||||
|
@@ -1096,6 +1096,6 @@ due to unexpected exception with message:
|
||||
Why would you throw a std::string?
|
||||
|
||||
===============================================================================
|
||||
test cases: 212 | 159 passed | 49 failed | 4 failed as expected
|
||||
assertions: 1227 | 1098 passed | 108 failed | 21 failed as expected
|
||||
test cases: 213 | 160 passed | 49 failed | 4 failed as expected
|
||||
assertions: 1228 | 1099 passed | 108 failed | 21 failed as expected
|
||||
|
||||
|
@@ -6296,6 +6296,18 @@ with expansion:
|
||||
"this string contains 'abc' as a substring" matches "this string contains
|
||||
'abc' as a" case sensitively
|
||||
|
||||
-------------------------------------------------------------------------------
|
||||
Regression test #1
|
||||
-------------------------------------------------------------------------------
|
||||
Matchers.tests.cpp:<line number>
|
||||
...............................................................................
|
||||
|
||||
Matchers.tests.cpp:<line number>:
|
||||
PASSED:
|
||||
CHECK_THAT( actual, !UnorderedEquals(expected) )
|
||||
with expansion:
|
||||
{ 'a', 'b' } not UnorderedEquals: { 'c', 'b' }
|
||||
|
||||
-------------------------------------------------------------------------------
|
||||
SUCCEED counts as a test pass
|
||||
-------------------------------------------------------------------------------
|
||||
@@ -10822,6 +10834,6 @@ Misc.tests.cpp:<line number>:
|
||||
PASSED:
|
||||
|
||||
===============================================================================
|
||||
test cases: 212 | 146 passed | 62 failed | 4 failed as expected
|
||||
assertions: 1241 | 1098 passed | 122 failed | 21 failed as expected
|
||||
test cases: 213 | 147 passed | 62 failed | 4 failed as expected
|
||||
assertions: 1242 | 1099 passed | 122 failed | 21 failed as expected
|
||||
|
||||
|
@@ -1,7 +1,7 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<testsuitesloose text artifact
|
||||
>
|
||||
<testsuite name="<exe-name>" errors="17" failures="106" tests="1242" hostname="tbd" time="{duration}" timestamp="{iso8601-timestamp}">
|
||||
<testsuite name="<exe-name>" errors="17" failures="106" tests="1243" hostname="tbd" time="{duration}" timestamp="{iso8601-timestamp}">
|
||||
<testcase classname="<exe-name>.global" name="# A test name that starts with a #" time="{duration}"/>
|
||||
<testcase classname="<exe-name>.global" name="#1005: Comparing pointer to int and long (NULL can be either on various systems)" time="{duration}"/>
|
||||
<testcase classname="<exe-name>.global" name="#1027" time="{duration}"/>
|
||||
@@ -518,6 +518,7 @@ Matchers.tests.cpp:<line number>
|
||||
Matchers.tests.cpp:<line number>
|
||||
</failure>
|
||||
</testcase>
|
||||
<testcase classname="<exe-name>.global" name="Regression test #1" time="{duration}"/>
|
||||
<testcase classname="<exe-name>.global" name="SUCCEED counts as a test pass" time="{duration}"/>
|
||||
<testcase classname="<exe-name>.global" name="SUCCEED does not require an argument" time="{duration}"/>
|
||||
<testcase classname="<exe-name>.Fixture" name="Scenario: BDD tests requiring Fixtures to provide commonly-accessed data or methods/Given: No operations precede me" time="{duration}"/>
|
||||
|
@@ -6608,6 +6608,17 @@
|
||||
</Expression>
|
||||
<OverallResult success="false"/>
|
||||
</TestCase>
|
||||
<TestCase name="Regression test #1" tags="[matchers][vector]" filename="projects/<exe-name>/UsageTests/Matchers.tests.cpp" >
|
||||
<Expression success="true" type="CHECK_THAT" filename="projects/<exe-name>/UsageTests/Matchers.tests.cpp" >
|
||||
<Original>
|
||||
actual, !UnorderedEquals(expected)
|
||||
</Original>
|
||||
<Expanded>
|
||||
{ 'a', 'b' } not UnorderedEquals: { 'c', 'b' }
|
||||
</Expanded>
|
||||
</Expression>
|
||||
<OverallResult success="true"/>
|
||||
</TestCase>
|
||||
<TestCase name="SUCCEED counts as a test pass" tags="[messages]" filename="projects/<exe-name>/UsageTests/Message.tests.cpp" >
|
||||
<OverallResult success="true"/>
|
||||
</TestCase>
|
||||
@@ -11310,7 +11321,7 @@ loose text artifact
|
||||
</Section>
|
||||
<OverallResult success="true"/>
|
||||
</TestCase>
|
||||
<OverallResults successes="1098" failures="123" expectedFailures="21"/>
|
||||
<OverallResults successes="1099" failures="123" expectedFailures="21"/>
|
||||
</Group>
|
||||
<OverallResults successes="1098" failures="122" expectedFailures="21"/>
|
||||
<OverallResults successes="1099" failures="122" expectedFailures="21"/>
|
||||
</Catch>
|
||||
|
@@ -56,7 +56,7 @@ TEST_CASE( "10x10 ints" ) {
|
||||
// but it demonstrates a possible usage.
|
||||
// Spelling out the pair like this is a bit verbose, so read on for better examples
|
||||
// - the use of structured bindings here is an optional convenience
|
||||
TEST_CASE( "strlen", "[.][approvals]" ) {
|
||||
TEST_CASE( "strlen", "[approvals]" ) {
|
||||
auto [test_input, expected] = GENERATE( values<std::pair<std::string_view, size_t>>({
|
||||
{"one", 3},
|
||||
{"two", 3},
|
||||
@@ -69,7 +69,7 @@ TEST_CASE( "strlen", "[.][approvals]" ) {
|
||||
|
||||
// A nicer way to do pairs (or more) of values - using the table generator.
|
||||
// Note, you must specify the types up-front.
|
||||
TEST_CASE( "strlen2", "[.][approvals]" ) {
|
||||
TEST_CASE( "strlen2", "[approvals]" ) {
|
||||
auto [test_input, expected] = GENERATE( table<std::string, size_t>({
|
||||
{"one", 3},
|
||||
{"two", 3},
|
||||
@@ -118,7 +118,7 @@ TEST_CASE( "Random numbers in a range", "[.][approvals]" ) {
|
||||
|
||||
static auto eatCucumbers( int start, int eat ) -> int { return start-eat; }
|
||||
|
||||
SCENARIO("Eating cucumbers", "[.][approvals]") {
|
||||
SCENARIO("Eating cucumbers", "[approvals]") {
|
||||
|
||||
auto [start, eat, left] = GENERATE( table<int,int,int> ({
|
||||
{ 12, 5, 7 },
|
||||
|
@@ -423,6 +423,15 @@ namespace { namespace MatchersTests {
|
||||
}
|
||||
}
|
||||
|
||||
TEST_CASE("Regression test #1", "[matchers][vector]") {
|
||||
// At some point, UnorderedEqualsMatcher skipped
|
||||
// mismatched prefixed before doing the comparison itself
|
||||
std::vector<char> actual = { 'a', 'b' };
|
||||
std::vector<char> expected = { 'c', 'b' };
|
||||
|
||||
CHECK_THAT(actual, !UnorderedEquals(expected));
|
||||
}
|
||||
|
||||
} } // namespace MatchersTests
|
||||
|
||||
#endif // CATCH_CONFIG_DISABLE_MATCHERS
|
||||
|
@@ -116,6 +116,18 @@ TEST_CASE("Static arrays are convertible to string", "[toString]") {
|
||||
}
|
||||
}
|
||||
|
||||
#ifdef CATCH_CONFIG_CPP17_STRING_VIEW
|
||||
|
||||
TEST_CASE("String views are stringified like other strings", "[toString][approvals]") {
|
||||
std::string_view view{"abc"};
|
||||
CHECK(Catch::Detail::stringify(view) == R"("abc")");
|
||||
|
||||
std::string_view arr[] { view };
|
||||
CHECK(Catch::Detail::stringify(arr) == R"({ "abc" })");
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
namespace {
|
||||
|
||||
struct WhatException : std::exception {
|
||||
|
84
projects/SelfTest/UsageTests/ToStringVariant.tests.cpp
Normal file
84
projects/SelfTest/UsageTests/ToStringVariant.tests.cpp
Normal file
@@ -0,0 +1,84 @@
|
||||
#define CATCH_CONFIG_ENABLE_VARIANT_STRINGMAKER
|
||||
#include "catch.hpp"
|
||||
|
||||
#if defined(CATCH_CONFIG_CPP17_VARIANT)
|
||||
|
||||
#include <string>
|
||||
#include <variant>
|
||||
|
||||
TEST_CASE( "variant<std::monostate>", "[toString][variant][approvals]")
|
||||
{
|
||||
using type = std::variant<std::monostate>;
|
||||
CHECK( "{ }" == ::Catch::Detail::stringify(type{}) );
|
||||
type value {};
|
||||
CHECK( "{ }" == ::Catch::Detail::stringify(value) );
|
||||
CHECK( "{ }" == ::Catch::Detail::stringify(std::get<0>(value)) );
|
||||
}
|
||||
|
||||
TEST_CASE( "variant<int>", "[toString][variant][approvals]")
|
||||
{
|
||||
using type = std::variant<int>;
|
||||
CHECK( "0" == ::Catch::Detail::stringify(type{0}) );
|
||||
}
|
||||
|
||||
TEST_CASE( "variant<float, int>", "[toString][variant][approvals]")
|
||||
{
|
||||
using type = std::variant<float, int>;
|
||||
CHECK( "0.5f" == ::Catch::Detail::stringify(type{0.5f}) );
|
||||
CHECK( "0" == ::Catch::Detail::stringify(type{0}) );
|
||||
|
||||
SECTION("valueless by exception") {
|
||||
struct sample {
|
||||
operator int() const { throw 42; }
|
||||
};
|
||||
|
||||
type value{1.5f};
|
||||
REQUIRE_THROWS_AS( value.emplace<int>(sample{}), int );
|
||||
REQUIRE( value.valueless_by_exception() );
|
||||
CHECK( "{valueless variant}" == ::Catch::Detail::stringify(value) );
|
||||
}
|
||||
}
|
||||
|
||||
TEST_CASE( "variant<string, int>", "[toString][variant][approvals]")
|
||||
{
|
||||
using type = std::variant<std::string, int>;
|
||||
CHECK( "\"foo\"" == ::Catch::Detail::stringify(type{"foo"}) );
|
||||
CHECK( "0" == ::Catch::Detail::stringify(type{0}) );
|
||||
}
|
||||
|
||||
TEST_CASE( "variant<variant<float, int>, string>", "[toString][variant][approvals]")
|
||||
{
|
||||
using inner = std::variant<float, int>;
|
||||
using type = std::variant<inner, std::string>;
|
||||
CHECK( "0.5f" == ::Catch::Detail::stringify(type{0.5f}) );
|
||||
CHECK( "0" == ::Catch::Detail::stringify(type{0}) );
|
||||
CHECK( "\"foo\"" == ::Catch::Detail::stringify(type{"foo"}) );
|
||||
|
||||
struct sample {
|
||||
operator int() const { throw 42; }
|
||||
};
|
||||
|
||||
SECTION("valueless nested variant") {
|
||||
type value = inner{0.5f};
|
||||
REQUIRE( std::holds_alternative<inner>(value) );
|
||||
REQUIRE( std::holds_alternative<float>(std::get<inner>(value)) );
|
||||
|
||||
REQUIRE_THROWS_AS( std::get<0>(value).emplace<int>(sample{}), int );
|
||||
|
||||
// outer variant is still valid and contains inner
|
||||
REQUIRE( std::holds_alternative<inner>(value) );
|
||||
// inner variant is valueless
|
||||
REQUIRE( std::get<inner>(value).valueless_by_exception() );
|
||||
CHECK( "{valueless variant}" == ::Catch::Detail::stringify(value) );
|
||||
}
|
||||
}
|
||||
|
||||
TEST_CASE( "variant<nullptr,int,const char *>", "[toString][variant][approvals]" )
|
||||
{
|
||||
using type = std::variant<std::nullptr_t,int,const char *>;
|
||||
CHECK( "nullptr" == ::Catch::Detail::stringify(type{nullptr}) );
|
||||
CHECK( "42" == ::Catch::Detail::stringify(type{42}) );
|
||||
CHECK( "\"Catch me\"" == ::Catch::Detail::stringify(type{"Catch me"}) );
|
||||
}
|
||||
|
||||
#endif // CATCH_INTERNAL_CONFIG_CPP17_VARIANT
|
@@ -26,7 +26,7 @@ from scriptCommon import catchPath
|
||||
minTocEntries = 4
|
||||
|
||||
headingExcludeDefault = [1,3,4,5] # use level 2 headers for at default
|
||||
headingExcludeRelease = [2,3,4,5] # use level 1 headers for release-notes.md
|
||||
headingExcludeRelease = [1,3,4,5] # use level 1 headers for release-notes.md
|
||||
|
||||
documentsDefault = os.path.join(os.path.relpath(catchPath), 'docs/*.md')
|
||||
releaseNotesName = 'release-notes.md'
|
||||
@@ -91,18 +91,20 @@ def dashifyHeadline(line):
|
||||
level = len(stripped_right) - len(stripped_both)
|
||||
stripped_wspace = stripped_both.strip()
|
||||
|
||||
# character replacements
|
||||
replaced_colon = stripped_wspace.replace('.', '')
|
||||
replaced_slash = replaced_colon.replace('/', '')
|
||||
rem_nonvalids = ''.join([c if c in VALIDS
|
||||
else '-' for c in replaced_slash])
|
||||
# GitHub's sluggification works in an interesting way
|
||||
# 1) '+', '/', '(', ')' and so on are just removed
|
||||
# 2) spaces are converted into '-' directly
|
||||
# 3) multiple -- are not collapsed
|
||||
|
||||
lowered = rem_nonvalids.lower()
|
||||
dashified = re.sub(r'(-)\1+', r'\1', lowered) # remove duplicate dashes
|
||||
dashified = dashified.strip('-') # strip dashes from start and end
|
||||
|
||||
# exception '&' (double-dash in github)
|
||||
dashified = dashified.replace('-&-', '--')
|
||||
dashified = ''
|
||||
for c in stripped_wspace:
|
||||
if c in VALIDS:
|
||||
dashified += c.lower()
|
||||
elif c.isspace():
|
||||
dashified += '-'
|
||||
else:
|
||||
# Unknown symbols are just removed
|
||||
continue
|
||||
|
||||
return [stripped_wspace, dashified, level]
|
||||
|
||||
|
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
* Catch v2.4.0
|
||||
* Generated: 2018-09-04 11:55:01.682061
|
||||
* Catch v2.4.1
|
||||
* Generated: 2018-09-28 15:50:15.645795
|
||||
* ----------------------------------------------------------
|
||||
* This file has been merged from multiple headers. Please don't edit it directly
|
||||
* Copyright (c) 2018 Two Blue Cubes Ltd. All rights reserved.
|
||||
@@ -15,7 +15,7 @@
|
||||
|
||||
#define CATCH_VERSION_MAJOR 2
|
||||
#define CATCH_VERSION_MINOR 4
|
||||
#define CATCH_VERSION_PATCH 0
|
||||
#define CATCH_VERSION_PATCH 1
|
||||
|
||||
#ifdef __clang__
|
||||
# pragma clang system_header
|
||||
@@ -121,11 +121,11 @@ namespace Catch {
|
||||
|
||||
#ifdef __cplusplus
|
||||
|
||||
# if __cplusplus >= 201402L
|
||||
# if (__cplusplus >= 201402L) || (defined(_MSVC_LANG) && _MSVC_LANG >= 201402L)
|
||||
# define CATCH_CPP14_OR_GREATER
|
||||
# endif
|
||||
|
||||
# if __cplusplus >= 201703L
|
||||
# if (__cplusplus >= 201703L) || (defined(_MSVC_LANG) && _MSVC_LANG >= 201703L)
|
||||
# define CATCH_CPP17_OR_GREATER
|
||||
# endif
|
||||
|
||||
@@ -200,7 +200,14 @@ namespace Catch {
|
||||
// Required for some versions of Cygwin to declare gettimeofday
|
||||
// see: http://stackoverflow.com/questions/36901803/gettimeofday-not-declared-in-this-scope-cygwin
|
||||
# define _BSD_SOURCE
|
||||
// some versions of cygwin (most) do not support std::to_string. Use the libstd check.
|
||||
// https://gcc.gnu.org/onlinedocs/gcc-4.8.2/libstdc++/api/a01053_source.html line 2812-2813
|
||||
# if !((__cplusplus >= 201103L) && defined(_GLIBCXX_USE_C99) \
|
||||
&& !defined(_GLIBCXX_HAVE_BROKEN_VSWPRINTF))
|
||||
|
||||
# define CATCH_INTERNAL_CONFIG_NO_CPP11_TO_STRING
|
||||
|
||||
# endif
|
||||
#endif // __CYGWIN__
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
@@ -244,6 +251,32 @@ namespace Catch {
|
||||
#define CATCH_INTERNAL_CONFIG_COUNTER
|
||||
#endif
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
// Check if string_view is available and usable
|
||||
// The check is split apart to work around v140 (VS2015) preprocessor issue...
|
||||
#if defined(__has_include)
|
||||
#if __has_include(<string_view>) && defined(CATCH_CPP17_OR_GREATER)
|
||||
# define CATCH_INTERNAL_CONFIG_CPP17_STRING_VIEW
|
||||
#endif
|
||||
#endif
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
// Check if variant is available and usable
|
||||
#if defined(__has_include)
|
||||
# if __has_include(<variant>) && defined(CATCH_CPP17_OR_GREATER)
|
||||
# if defined(__clang__) && (__clang_major__ < 8)
|
||||
// work around clang bug with libstdc++ https://bugs.llvm.org/show_bug.cgi?id=31852
|
||||
// fix should be in clang 8, workaround in libstdc++ 8.2
|
||||
# include <ciso646>
|
||||
# if defined(__GLIBCXX__) && defined(_GLIBCXX_RELEASE) && (_GLIBCXX_RELEASE < 9)
|
||||
# define CATCH_CONFIG_NO_CPP17_VARIANT
|
||||
# else
|
||||
# define CATCH_INTERNAL_CONFIG_CPP17_VARIANT
|
||||
# endif // defined(__GLIBCXX__) && defined(_GLIBCXX_RELEASE) && (_GLIBCXX_RELEASE < 9)
|
||||
# endif // defined(__clang__) && (__clang_major__ < 8)
|
||||
# endif // __has_include(<variant>) && defined(CATCH_CPP17_OR_GREATER)
|
||||
#endif // __has_include
|
||||
|
||||
#if defined(CATCH_INTERNAL_CONFIG_COUNTER) && !defined(CATCH_CONFIG_NO_COUNTER) && !defined(CATCH_CONFIG_COUNTER)
|
||||
# define CATCH_CONFIG_COUNTER
|
||||
#endif
|
||||
@@ -267,6 +300,14 @@ namespace Catch {
|
||||
# define CATCH_CONFIG_CPP17_UNCAUGHT_EXCEPTIONS
|
||||
#endif
|
||||
|
||||
#if defined(CATCH_INTERNAL_CONFIG_CPP17_STRING_VIEW) && !defined(CATCH_CONFIG_NO_CPP17_STRING_VIEW) && !defined(CATCH_CONFIG_CPP17_STRING_VIEW)
|
||||
# define CATCH_CONFIG_CPP17_STRING_VIEW
|
||||
#endif
|
||||
|
||||
#if defined(CATCH_INTERNAL_CONFIG_CPP17_VARIANT) && !defined(CATCH_CONFIG_NO_CPP17_VARIANT) && !defined(CATCH_CONFIG_CPP17_VARIANT)
|
||||
# define CATCH_CONFIG_CPP17_VARIANT
|
||||
#endif
|
||||
|
||||
#if defined(CATCH_CONFIG_EXPERIMENTAL_REDIRECT)
|
||||
# define CATCH_INTERNAL_CONFIG_NEW_CAPTURE
|
||||
#endif
|
||||
@@ -754,6 +795,10 @@ namespace Catch {
|
||||
|
||||
// end catch_stream.h
|
||||
|
||||
#ifdef CATCH_CONFIG_CPP17_STRING_VIEW
|
||||
#include <string_view>
|
||||
#endif
|
||||
|
||||
#ifdef __OBJC__
|
||||
// start catch_objc_arc.hpp
|
||||
|
||||
@@ -929,10 +974,11 @@ namespace Catch {
|
||||
struct StringMaker<std::string> {
|
||||
static std::string convert(const std::string& str);
|
||||
};
|
||||
#ifdef CATCH_CONFIG_WCHAR
|
||||
|
||||
#ifdef CATCH_CONFIG_CPP17_STRING_VIEW
|
||||
template<>
|
||||
struct StringMaker<std::wstring> {
|
||||
static std::string convert(const std::wstring& wstr);
|
||||
struct StringMaker<std::string_view> {
|
||||
static std::string convert(std::string_view str);
|
||||
};
|
||||
#endif
|
||||
|
||||
@@ -946,6 +992,18 @@ namespace Catch {
|
||||
};
|
||||
|
||||
#ifdef CATCH_CONFIG_WCHAR
|
||||
template<>
|
||||
struct StringMaker<std::wstring> {
|
||||
static std::string convert(const std::wstring& wstr);
|
||||
};
|
||||
|
||||
# ifdef CATCH_CONFIG_CPP17_STRING_VIEW
|
||||
template<>
|
||||
struct StringMaker<std::wstring_view> {
|
||||
static std::string convert(std::wstring_view str);
|
||||
};
|
||||
# endif
|
||||
|
||||
template<>
|
||||
struct StringMaker<wchar_t const *> {
|
||||
static std::string convert(wchar_t const * str);
|
||||
@@ -1114,6 +1172,7 @@ namespace Catch {
|
||||
#if defined(CATCH_CONFIG_ENABLE_ALL_STRINGMAKERS)
|
||||
# define CATCH_CONFIG_ENABLE_PAIR_STRINGMAKER
|
||||
# define CATCH_CONFIG_ENABLE_TUPLE_STRINGMAKER
|
||||
# define CATCH_CONFIG_ENABLE_VARIANT_STRINGMAKER
|
||||
# define CATCH_CONFIG_ENABLE_CHRONO_STRINGMAKER
|
||||
#endif
|
||||
|
||||
@@ -1177,6 +1236,34 @@ namespace Catch {
|
||||
}
|
||||
#endif // CATCH_CONFIG_ENABLE_TUPLE_STRINGMAKER
|
||||
|
||||
#if defined(CATCH_CONFIG_ENABLE_VARIANT_STRINGMAKER) && defined(CATCH_CONFIG_CPP17_VARIANT)
|
||||
#include <variant>
|
||||
namespace Catch {
|
||||
template<>
|
||||
struct StringMaker<std::monostate> {
|
||||
static std::string convert(const std::monostate&) {
|
||||
return "{ }";
|
||||
}
|
||||
};
|
||||
|
||||
template<typename... Elements>
|
||||
struct StringMaker<std::variant<Elements...>> {
|
||||
static std::string convert(const std::variant<Elements...>& variant) {
|
||||
if (variant.valueless_by_exception()) {
|
||||
return "{valueless variant}";
|
||||
} else {
|
||||
return std::visit(
|
||||
[](const auto& value) {
|
||||
return ::Catch::Detail::stringify(value);
|
||||
},
|
||||
variant
|
||||
);
|
||||
}
|
||||
}
|
||||
};
|
||||
}
|
||||
#endif // CATCH_CONFIG_ENABLE_VARIANT_STRINGMAKER
|
||||
|
||||
namespace Catch {
|
||||
struct not_this_one {}; // Tag type for detecting which begin/ end are being selected
|
||||
|
||||
@@ -2761,7 +2848,7 @@ namespace Matchers {
|
||||
auto lfirst = m_target.begin(), llast = m_target.end();
|
||||
auto rfirst = vec.begin(), rlast = vec.end();
|
||||
// Cut common prefix to optimize checking of permuted parts
|
||||
while (lfirst != llast && *lfirst != *rfirst) {
|
||||
while (lfirst != llast && *lfirst == *rfirst) {
|
||||
++lfirst; ++rfirst;
|
||||
}
|
||||
if (lfirst == llast) {
|
||||
@@ -9597,7 +9684,7 @@ namespace Catch {
|
||||
}
|
||||
|
||||
bool RunContext::aborting() const {
|
||||
return m_totals.assertions.failed == static_cast<std::size_t>(m_config->abortAfter());
|
||||
return m_totals.assertions.failed >= static_cast<std::size_t>(m_config->abortAfter());
|
||||
}
|
||||
|
||||
void RunContext::runCurrentTest(std::string & redirectedCout, std::string & redirectedCerr) {
|
||||
@@ -11512,14 +11599,9 @@ std::string StringMaker<std::string>::convert(const std::string& str) {
|
||||
return s;
|
||||
}
|
||||
|
||||
#ifdef CATCH_CONFIG_WCHAR
|
||||
std::string StringMaker<std::wstring>::convert(const std::wstring& wstr) {
|
||||
std::string s;
|
||||
s.reserve(wstr.size());
|
||||
for (auto c : wstr) {
|
||||
s += (c <= 0xff) ? static_cast<char>(c) : '?';
|
||||
}
|
||||
return ::Catch::Detail::stringify(s);
|
||||
#ifdef CATCH_CONFIG_CPP17_STRING_VIEW
|
||||
std::string StringMaker<std::string_view>::convert(std::string_view str) {
|
||||
return ::Catch::Detail::stringify(std::string{ str });
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -11537,7 +11619,23 @@ std::string StringMaker<char*>::convert(char* str) {
|
||||
return{ "{null string}" };
|
||||
}
|
||||
}
|
||||
|
||||
#ifdef CATCH_CONFIG_WCHAR
|
||||
std::string StringMaker<std::wstring>::convert(const std::wstring& wstr) {
|
||||
std::string s;
|
||||
s.reserve(wstr.size());
|
||||
for (auto c : wstr) {
|
||||
s += (c <= 0xff) ? static_cast<char>(c) : '?';
|
||||
}
|
||||
return ::Catch::Detail::stringify(s);
|
||||
}
|
||||
|
||||
# ifdef CATCH_CONFIG_CPP17_STRING_VIEW
|
||||
std::string StringMaker<std::wstring_view>::convert(std::wstring_view str) {
|
||||
return StringMaker<std::wstring>::convert(std::wstring(str));
|
||||
}
|
||||
# endif
|
||||
|
||||
std::string StringMaker<wchar_t const*>::convert(wchar_t const * str) {
|
||||
if (str) {
|
||||
return ::Catch::Detail::stringify(std::wstring{ str });
|
||||
@@ -11738,7 +11836,7 @@ namespace Catch {
|
||||
}
|
||||
|
||||
Version const& libraryVersion() {
|
||||
static Version version( 2, 4, 0, "", 0 );
|
||||
static Version version( 2, 4, 1, "", 0 );
|
||||
return version;
|
||||
}
|
||||
|
||||
|
@@ -10,7 +10,7 @@ class CatchConanTest(ConanFile):
|
||||
settings = "os", "compiler", "arch", "build_type"
|
||||
username = getenv("CONAN_USERNAME", "philsquared")
|
||||
channel = getenv("CONAN_CHANNEL", "testing")
|
||||
requires = "Catch/2.4.0@%s/%s" % (username, channel)
|
||||
requires = "Catch/2.4.1@%s/%s" % (username, channel)
|
||||
|
||||
def build(self):
|
||||
cmake = CMake(self)
|
||||
|
Reference in New Issue
Block a user