mirror of
https://github.com/catchorg/Catch2.git
synced 2025-09-13 08:55:39 +02:00
Compare commits
68 Commits
Author | SHA1 | Date | |
---|---|---|---|
![]() |
74effafca7 | ||
![]() |
7d0cfd27ce | ||
![]() |
3fe4d394a5 | ||
![]() |
b97e9a2f8b | ||
![]() |
34f7cfe046 | ||
![]() |
07b9bda1d2 | ||
![]() |
84e8b696b1 | ||
![]() |
2d91035404 | ||
![]() |
2a3606f8e3 | ||
![]() |
a6cf19abff | ||
![]() |
06586b7180 | ||
![]() |
93b3d2cb8f | ||
![]() |
a90473df28 | ||
![]() |
c9d9699ca8 | ||
![]() |
296955c437 | ||
![]() |
664cbf702c | ||
![]() |
fb6700df54 | ||
![]() |
da6c2a6914 | ||
![]() |
9c07718b5f | ||
![]() |
5ca44b6872 | ||
![]() |
a04bd6d436 | ||
![]() |
784f6dfb34 | ||
![]() |
7818e2666d | ||
![]() |
cd30dd1a70 | ||
![]() |
8e8c0c1675 | ||
![]() |
b6e7c9bd7a | ||
![]() |
180d9242f5 | ||
![]() |
b7bd52cc98 | ||
![]() |
b07a2bdf87 | ||
![]() |
c03e8fce92 | ||
![]() |
27640a5a96 | ||
![]() |
dd3867bbcd | ||
![]() |
387f8d254d | ||
![]() |
c65eccd68e | ||
![]() |
61c5675c11 | ||
![]() |
70e4af9d44 | ||
![]() |
8f41bdb92d | ||
![]() |
7fa5d9ca94 | ||
![]() |
feaf355489 | ||
![]() |
2ce6c74f8f | ||
![]() |
9688891868 | ||
![]() |
4f21bb72ff | ||
![]() |
b435e0d7c7 | ||
![]() |
ba0a09fd9e | ||
![]() |
7e4038d848 | ||
![]() |
92d714ee12 | ||
![]() |
705a1bf527 | ||
![]() |
d5613fb18a | ||
![]() |
62875c857e | ||
![]() |
ec2074e558 | ||
![]() |
7575749e56 | ||
![]() |
8a2ff20982 | ||
![]() |
d3377c791d | ||
![]() |
c5dfa73d56 | ||
![]() |
d65091fa06 | ||
![]() |
7a22bad763 | ||
![]() |
8ebe94ca2e | ||
![]() |
106d7e2a74 | ||
![]() |
a53ea30723 | ||
![]() |
8d380a7399 | ||
![]() |
3083de9ea6 | ||
![]() |
431e8d06e7 | ||
![]() |
6f32db35af | ||
![]() |
7013e388f7 | ||
![]() |
0270afb21b | ||
![]() |
df7c5622b9 | ||
![]() |
3491804598 | ||
![]() |
6234e3d54d |
18
.travis.yml
18
.travis.yml
@@ -192,15 +192,15 @@ matrix:
|
|||||||
env: COMPILER='g++-6' BUILD_TYPE='Debug' CPP14=1
|
env: COMPILER='g++-6' BUILD_TYPE='Debug' CPP14=1
|
||||||
|
|
||||||
# 4b/ Linux C++14 Clang builds
|
# 4b/ Linux C++14 Clang builds
|
||||||
- os: linux
|
# - os: linux
|
||||||
compiler: clang
|
# compiler: clang
|
||||||
addons: *clang38
|
# addons: *clang38
|
||||||
env: COMPILER='clang++-3.8' BUILD_TYPE='Release' CPP14=1
|
# env: COMPILER='clang++-3.8' BUILD_TYPE='Release' CPP14=1
|
||||||
|
#
|
||||||
- os: linux
|
# - os: linux
|
||||||
compiler: clang
|
# compiler: clang
|
||||||
addons: *clang38
|
# addons: *clang38
|
||||||
env: COMPILER='clang++-3.8' BUILD_TYPE='Debug' CPP14=1
|
# env: COMPILER='clang++-3.8' BUILD_TYPE='Debug' CPP14=1
|
||||||
|
|
||||||
|
|
||||||
# 5/ OSX Clang Builds
|
# 5/ OSX Clang Builds
|
||||||
|
46
CODE_OF_CONDUCT.md
Normal file
46
CODE_OF_CONDUCT.md
Normal file
@@ -0,0 +1,46 @@
|
|||||||
|
# Contributor Covenant Code of Conduct
|
||||||
|
|
||||||
|
## Our Pledge
|
||||||
|
|
||||||
|
In the interest of fostering an open and welcoming environment, we as contributors and maintainers pledge to making participation in our project and our community a harassment-free experience for everyone, regardless of age, body size, disability, ethnicity, gender identity and expression, level of experience, nationality, personal appearance, race, religion, or sexual identity and orientation.
|
||||||
|
|
||||||
|
## Our Standards
|
||||||
|
|
||||||
|
Examples of behavior that contributes to creating a positive environment include:
|
||||||
|
|
||||||
|
* Using welcoming and inclusive language
|
||||||
|
* Being respectful of differing viewpoints and experiences
|
||||||
|
* Gracefully accepting constructive criticism
|
||||||
|
* Focusing on what is best for the community
|
||||||
|
* Showing empathy towards other community members
|
||||||
|
|
||||||
|
Examples of unacceptable behavior by participants include:
|
||||||
|
|
||||||
|
* The use of sexualized language or imagery and unwelcome sexual attention or advances
|
||||||
|
* Trolling, insulting/derogatory comments, and personal or political attacks
|
||||||
|
* Public or private harassment
|
||||||
|
* Publishing others' private information, such as a physical or electronic address, without explicit permission
|
||||||
|
* Other conduct which could reasonably be considered inappropriate in a professional setting
|
||||||
|
|
||||||
|
## Our Responsibilities
|
||||||
|
|
||||||
|
Project maintainers are responsible for clarifying the standards of acceptable behavior and are expected to take appropriate and fair corrective action in response to any instances of unacceptable behavior.
|
||||||
|
|
||||||
|
Project maintainers have the right and responsibility to remove, edit, or reject comments, commits, code, wiki edits, issues, and other contributions that are not aligned to this Code of Conduct, or to ban temporarily or permanently any contributor for other behaviors that they deem inappropriate, threatening, offensive, or harmful.
|
||||||
|
|
||||||
|
## Scope
|
||||||
|
|
||||||
|
This Code of Conduct applies both within project spaces and in public spaces when an individual is representing the project or its community. Examples of representing a project or community include using an official project e-mail address, posting via an official social media account, or acting as an appointed representative at an online or offline event. Representation of a project may be further defined and clarified by project maintainers.
|
||||||
|
|
||||||
|
## Enforcement
|
||||||
|
|
||||||
|
Instances of abusive, harassing, or otherwise unacceptable behavior may be reported by contacting the project team at github@philnash.me. The project team will review and investigate all complaints, and will respond in a way that it deems appropriate to the circumstances. The project team is obligated to maintain confidentiality with regard to the reporter of an incident. Further details of specific enforcement policies may be posted separately.
|
||||||
|
|
||||||
|
Project maintainers who do not follow or enforce the Code of Conduct in good faith may face temporary or permanent repercussions as determined by other members of the project's leadership.
|
||||||
|
|
||||||
|
## Attribution
|
||||||
|
|
||||||
|
This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4, available at [http://contributor-covenant.org/version/1/4][version]
|
||||||
|
|
||||||
|
[homepage]: http://contributor-covenant.org
|
||||||
|
[version]: http://contributor-covenant.org/version/1/4/
|
@@ -3,8 +3,9 @@
|
|||||||
[](https://github.com/philsquared/catch/releases)
|
[](https://github.com/philsquared/catch/releases)
|
||||||
[](https://travis-ci.org/philsquared/Catch)
|
[](https://travis-ci.org/philsquared/Catch)
|
||||||
[](https://ci.appveyor.com/project/philsquared/catch/branch/master)
|
[](https://ci.appveyor.com/project/philsquared/catch/branch/master)
|
||||||
|
[](https://wandbox.org/permlink/q3wLegtaHunTHSls)
|
||||||
|
|
||||||
<a href="https://github.com/philsquared/Catch/releases/download/v1.9.6/catch.hpp">The latest, single header, version can be downloaded directly using this link</a>
|
<a href="https://github.com/philsquared/Catch/releases/download/v1.12.1/catch.hpp">The latest, single header, version can be downloaded directly using this link</a>
|
||||||
|
|
||||||
## What's the Catch?
|
## What's the Catch?
|
||||||
|
|
||||||
@@ -21,3 +22,7 @@ This documentation comprises these three parts:
|
|||||||
* Issues and bugs can be raised on the [Issue tracker on GitHub](https://github.com/philsquared/Catch/issues)
|
* Issues and bugs can be raised on the [Issue tracker on GitHub](https://github.com/philsquared/Catch/issues)
|
||||||
* For discussion or questions please use [the dedicated Google Groups forum](https://groups.google.com/forum/?fromgroups#!forum/catch-forum)
|
* For discussion or questions please use [the dedicated Google Groups forum](https://groups.google.com/forum/?fromgroups#!forum/catch-forum)
|
||||||
* See [who else is using Catch](docs/opensource-users.md)
|
* See [who else is using Catch](docs/opensource-users.md)
|
||||||
|
|
||||||
|
## Help us out
|
||||||
|
We're currently running [a survey](https://www.surveymonkey.co.uk/r/TLLYQJW) to help us shape the future of Catch.
|
||||||
|
Please take a few moments to fill it out (there's only ten questions).
|
||||||
|
19
conanfile.py
Normal file
19
conanfile.py
Normal file
@@ -0,0 +1,19 @@
|
|||||||
|
#!/usr/bin/env python
|
||||||
|
from conans import ConanFile
|
||||||
|
|
||||||
|
|
||||||
|
class CatchConan(ConanFile):
|
||||||
|
name = "Catch"
|
||||||
|
version = "1.12.1"
|
||||||
|
description = "A modern, C++-native, header-only, framework for unit-tests, TDD and BDD"
|
||||||
|
author = "philsquared"
|
||||||
|
generators = "cmake"
|
||||||
|
exports_sources = "single_include/*"
|
||||||
|
url = "https://github.com/philsquared/Catch"
|
||||||
|
license = "Boost Software License - Version 1.0. http://www.boost.org/LICENSE_1_0.txt"
|
||||||
|
|
||||||
|
def package(self):
|
||||||
|
self.copy(pattern="catch.hpp", src="single_include", dst="include")
|
||||||
|
|
||||||
|
def package_id(self):
|
||||||
|
self.info.header_only()
|
@@ -30,12 +30,24 @@
|
|||||||
# #
|
# #
|
||||||
# PARSE_CATCH_TESTS_VERBOSE (Default OFF) #
|
# PARSE_CATCH_TESTS_VERBOSE (Default OFF) #
|
||||||
# -- enables debug messages #
|
# -- enables debug messages #
|
||||||
|
# PARSE_CATCH_TESTS_NO_HIDDEN_TESTS (Default OFF) #
|
||||||
|
# -- excludes tests marked with [!hide], [.] or [.foo] tags #
|
||||||
|
# PARSE_CATCH_TESTS_ADD_FIXTURE_IN_TEST_NAME (Default ON) #
|
||||||
|
# -- adds fixture class name to the test name #
|
||||||
|
# PARSE_CATCH_TESTS_ADD_TARGET_IN_TEST_NAME (Default ON) #
|
||||||
|
# -- adds cmake target name to the test name #
|
||||||
|
# PARSE_CATCH_TESTS_ADD_TO_CONFIGURE_DEPENDS (Default OFF) #
|
||||||
|
# -- causes CMake to rerun when file with tests changes so that new tests will be discovered #
|
||||||
# #
|
# #
|
||||||
#==================================================================================================#
|
#==================================================================================================#
|
||||||
|
|
||||||
cmake_minimum_required(VERSION 2.8.8)
|
cmake_minimum_required(VERSION 2.8.8)
|
||||||
|
|
||||||
option(PARSE_CATCH_TESTS_VERBOSE "Print Catch to CTest parser debug messages" OFF)
|
option(PARSE_CATCH_TESTS_VERBOSE "Print Catch to CTest parser debug messages" OFF)
|
||||||
|
option(PARSE_CATCH_TESTS_NO_HIDDEN_TESTS "Exclude tests with [!hide], [.] or [.foo] tags" OFF)
|
||||||
|
option(PARSE_CATCH_TESTS_ADD_FIXTURE_IN_TEST_NAME "Add fixture class name to the test name" ON)
|
||||||
|
option(PARSE_CATCH_TESTS_ADD_TARGET_IN_TEST_NAME "Add target name to the test name" ON)
|
||||||
|
option(PARSE_CATCH_TESTS_ADD_TO_CONFIGURE_DEPENDS "Add test file to CMAKE_CONFIGURE_DEPENDS property" OFF)
|
||||||
|
|
||||||
function(PrintDebugMessage)
|
function(PrintDebugMessage)
|
||||||
if(PARSE_CATCH_TESTS_VERBOSE)
|
if(PARSE_CATCH_TESTS_VERBOSE)
|
||||||
@@ -76,6 +88,15 @@ function(ParseFile SourceFile TestTarget)
|
|||||||
# Find definition of test names
|
# Find definition of test names
|
||||||
string(REGEX MATCHALL "[ \t]*(CATCH_)?(TEST_CASE_METHOD|SCENARIO|TEST_CASE)[ \t]*\\([^\)]+\\)+[ \t\n]*{+[ \t]*(//[^\n]*[Tt][Ii][Mm][Ee][Oo][Uu][Tt][ \t]*[0-9]+)*" Tests "${Contents}")
|
string(REGEX MATCHALL "[ \t]*(CATCH_)?(TEST_CASE_METHOD|SCENARIO|TEST_CASE)[ \t]*\\([^\)]+\\)+[ \t\n]*{+[ \t]*(//[^\n]*[Tt][Ii][Mm][Ee][Oo][Uu][Tt][ \t]*[0-9]+)*" Tests "${Contents}")
|
||||||
|
|
||||||
|
if(PARSE_CATCH_TESTS_ADD_TO_CONFIGURE_DEPENDS AND Tests)
|
||||||
|
PrintDebugMessage("Adding ${SourceFile} to CMAKE_CONFIGURE_DEPENDS property")
|
||||||
|
set_property(
|
||||||
|
DIRECTORY
|
||||||
|
APPEND
|
||||||
|
PROPERTY CMAKE_CONFIGURE_DEPENDS ${SourceFile}
|
||||||
|
)
|
||||||
|
endif()
|
||||||
|
|
||||||
foreach(TestName ${Tests})
|
foreach(TestName ${Tests})
|
||||||
# Strip newlines
|
# Strip newlines
|
||||||
string(REGEX REPLACE "\\\\\n|\n" "" TestName "${TestName}")
|
string(REGEX REPLACE "\\\\\n|\n" "" TestName "${TestName}")
|
||||||
@@ -103,12 +124,14 @@ function(ParseFile SourceFile TestTarget)
|
|||||||
if("${TestType}" STREQUAL "SCENARIO")
|
if("${TestType}" STREQUAL "SCENARIO")
|
||||||
set(Name "Scenario: ${Name}")
|
set(Name "Scenario: ${Name}")
|
||||||
endif()
|
endif()
|
||||||
if(TestFixture)
|
if(PARSE_CATCH_TESTS_ADD_FIXTURE_IN_TEST_NAME AND TestFixture)
|
||||||
set(CTestName "${TestFixture}:${Name}")
|
set(CTestName "${TestFixture}:${Name}")
|
||||||
else()
|
else()
|
||||||
set(CTestName "${Name}")
|
set(CTestName "${Name}")
|
||||||
endif()
|
endif()
|
||||||
set(CTestName "${TestTarget}:${CTestName}")
|
if(PARSE_CATCH_TESTS_ADD_TARGET_IN_TEST_NAME)
|
||||||
|
set(CTestName "${TestTarget}:${CTestName}")
|
||||||
|
endif()
|
||||||
# add target to labels to enable running all tests added from this target
|
# add target to labels to enable running all tests added from this target
|
||||||
set(Labels ${TestTarget})
|
set(Labels ${TestTarget})
|
||||||
if(TestStringsLength EQUAL 2)
|
if(TestStringsLength EQUAL 2)
|
||||||
@@ -124,15 +147,28 @@ function(ParseFile SourceFile TestTarget)
|
|||||||
|
|
||||||
list(APPEND Labels ${Tags})
|
list(APPEND Labels ${Tags})
|
||||||
|
|
||||||
PrintDebugMessage("Adding test \"${CTestName}\"")
|
list(FIND Labels "!hide" IndexOfHideLabel)
|
||||||
if(Labels)
|
set(HiddenTagFound OFF)
|
||||||
PrintDebugMessage("Setting labels to ${Labels}")
|
foreach(label ${Labels})
|
||||||
endif()
|
string(REGEX MATCH "^!hide|^\\." result ${label})
|
||||||
|
if(result)
|
||||||
|
set(HiddenTagFound ON)
|
||||||
|
break()
|
||||||
|
endif(result)
|
||||||
|
endforeach(label)
|
||||||
|
if(PARSE_CATCH_TESTS_NO_HIDDEN_TESTS AND ${HiddenTagFound})
|
||||||
|
PrintDebugMessage("Skipping test \"${CTestName}\" as it has [!hide], [.] or [.foo] label")
|
||||||
|
else()
|
||||||
|
PrintDebugMessage("Adding test \"${CTestName}\"")
|
||||||
|
if(Labels)
|
||||||
|
PrintDebugMessage("Setting labels to ${Labels}")
|
||||||
|
endif()
|
||||||
|
|
||||||
# Add the test and set its properties
|
# Add the test and set its properties
|
||||||
add_test(NAME "\"${CTestName}\"" COMMAND ${TestTarget} ${Name} ${AdditionalCatchParameters})
|
add_test(NAME "\"${CTestName}\"" COMMAND ${TestTarget} ${Name} ${AdditionalCatchParameters})
|
||||||
set_tests_properties("\"${CTestName}\"" PROPERTIES FAIL_REGULAR_EXPRESSION "No tests ran"
|
set_tests_properties("\"${CTestName}\"" PROPERTIES FAIL_REGULAR_EXPRESSION "No tests ran"
|
||||||
LABELS "${Labels}")
|
LABELS "${Labels}")
|
||||||
|
endif()
|
||||||
|
|
||||||
endforeach()
|
endforeach()
|
||||||
endfunction()
|
endfunction()
|
||||||
|
@@ -57,7 +57,7 @@ This way `Approx` is constructed with reasonable defaults, covering most simple
|
|||||||
|
|
||||||
* __epsilon__ - epsilon serves to set the percentage by which a result can be erroneous, before it is rejected. By default set to `std::numeric_limits<float>::epsilon()*100`.
|
* __epsilon__ - epsilon serves to set the percentage by which a result can be erroneous, 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 a result can be erroneous before it is rejected. By default set to `0.0`.
|
* __margin__ - margin serves to set the the absolute value by which a result can be erroneous before it is rejected. By default set to `0.0`.
|
||||||
* __scale__ - scale serves to adjust the base for comparison used by epsilon, can be used when By default set to `1.0`.
|
* __scale__ - scale serves to adjust the base for comparison used by epsilon. By default set to `1.0`.
|
||||||
|
|
||||||
#### epsilon example
|
#### epsilon example
|
||||||
```cpp
|
```cpp
|
||||||
@@ -77,7 +77,7 @@ Approx target = Approx(100).margin(5);
|
|||||||
```
|
```
|
||||||
|
|
||||||
#### scale
|
#### scale
|
||||||
Scale can be useful if the computation leading to the result worked on different scale, than is used by the results (and thus expected errors are on a different scale than would be expected based on the results alone).
|
Scale can be useful if the computation leading to the result worked on different scale, than is used by the results (and thus expected errors are on a different scale than would be expected based on the results alone), i.e. an additional not scaling difference will be accepted, because | current - target | < eps_rel + eps_abs (while eps_rel = max(current, target) * epsilon, eps_abs = epsilon * scale) will be checked.
|
||||||
|
|
||||||
|
|
||||||
## Exceptions
|
## Exceptions
|
||||||
@@ -138,4 +138,4 @@ For more details, along with workarounds, see the section on [the limitations pa
|
|||||||
|
|
||||||
---
|
---
|
||||||
|
|
||||||
[Home](Readme.md)
|
[Home](Readme.md)
|
||||||
|
@@ -15,7 +15,7 @@ The XML Reporter writes in an XML format that is specific to Catch.
|
|||||||
|
|
||||||
The advantage of this format is that it corresponds well to the way Catch works (especially the more unusual features, such as nested sections) and is a fully streaming format - that is it writes output as it goes, without having to store up all its results before it can start writing.
|
The advantage of this format is that it corresponds well to the way Catch works (especially the more unusual features, such as nested sections) and is a fully streaming format - that is it writes output as it goes, without having to store up all its results before it can start writing.
|
||||||
|
|
||||||
The disadvantage is that, being specific to Catch, no existing build servers understand the format natively. It can be used as input to an XSLT transformation that could covert it to, say, HTML - although this loses the streaming advantage, of course.
|
The disadvantage is that, being specific to Catch, no existing build servers understand the format natively. It can be used as input to an XSLT transformation that could convert it to, say, HTML - although this loses the streaming advantage, of course.
|
||||||
|
|
||||||
## JUnit Reporter
|
## JUnit Reporter
|
||||||
```-r junit```
|
```-r junit```
|
||||||
|
@@ -27,6 +27,8 @@ Click one of the followings links to take you straight to that option - or scrol
|
|||||||
<a href="#listing-available-tests-tags-or-reporters"> ` --list-reporters`</a><br />
|
<a href="#listing-available-tests-tags-or-reporters"> ` --list-reporters`</a><br />
|
||||||
<a href="#order"> ` --order`</a><br />
|
<a href="#order"> ` --order`</a><br />
|
||||||
<a href="#rng-seed"> ` --rng-seed`</a><br />
|
<a href="#rng-seed"> ` --rng-seed`</a><br />
|
||||||
|
<a href="#libidentify"> ` --libidentify`</a><br />
|
||||||
|
<a href="#wait-for-keypress"> ` --wait-for-keypress`</a><br />
|
||||||
|
|
||||||
</br>
|
</br>
|
||||||
|
|
||||||
@@ -213,6 +215,20 @@ Alternatively if the keyword ```time``` is provided then the result of calling `
|
|||||||
|
|
||||||
In either case the actual value for the seed is printed as part of Catch's output so if an issue is discovered that is sensitive to test ordering the ordering can be reproduced - even if it was originally seeded from ```std::time(0)```.
|
In either case the actual value for the seed is printed as part of Catch's output so if an issue is discovered that is sensitive to test ordering the ordering can be reproduced - even if it was originally seeded from ```std::time(0)```.
|
||||||
|
|
||||||
|
<a id="libidentify"></a>
|
||||||
|
## Identify framework and version according to the libIdentify standard
|
||||||
|
<pre>--libidentify</pre>
|
||||||
|
|
||||||
|
See [The LibIdentify repo for more information and examples](https://github.com/janwilmans/LibIdentify).
|
||||||
|
|
||||||
|
<a id="wait-for-keypress"></a>
|
||||||
|
## Wait for key before continuing
|
||||||
|
<pre>--wait-for-keypress <start|exit|both></pre>
|
||||||
|
|
||||||
|
Will cause the executable to print a message and wait until the return/ enter key is pressed before continuing -
|
||||||
|
either before running any tests, after running all tests - or both, depending on the argument.
|
||||||
|
|
||||||
|
|
||||||
<a id="usage"></a>
|
<a id="usage"></a>
|
||||||
## Usage
|
## Usage
|
||||||
<pre>-h, -?, --help</pre>
|
<pre>-h, -?, --help</pre>
|
||||||
|
@@ -43,12 +43,19 @@ By default a console width of 80 is assumed but this can be controlled by defini
|
|||||||
|
|
||||||
CATCH_CONFIG_NOSTDOUT
|
CATCH_CONFIG_NOSTDOUT
|
||||||
|
|
||||||
Catch does not use ```std::cout``` and ```std::cerr``` directly but gets them from ```Catch::cout()``` and ```Catch::cerr()``` respectively. If the above identifier is defined these functions are left unimplemented and you must implement them yourself. Their signatures are:
|
Catch does not use ```std::cout```, ```std::cerr``` and ```std::clog``` directly but gets them from ```Catch::cout()```, ```Catch::cerr()``` and ```Catch::clog``` respectively. If the above identifier is defined these functions are left unimplemented and you must implement them yourself. Their signatures are:
|
||||||
|
|
||||||
std::ostream& cout();
|
std::ostream& cout();
|
||||||
std::ostream& cerr();
|
std::ostream& cerr();
|
||||||
|
std::ostream& clog();
|
||||||
|
|
||||||
This can be useful on certain platforms that do not provide ```std::cout``` and ```std::cerr```, such as certain embedded systems.
|
This can be useful on certain platforms that do not provide the standard iostreams, such as certain embedded systems.
|
||||||
|
|
||||||
|
# Default reporter
|
||||||
|
|
||||||
|
CATCH_CONFIG_DEFAULT_REPORTER <reporter>
|
||||||
|
|
||||||
|
The default reporter (reporter used when no reporters are explicitly specified) can be overriden during compilation time by using the above macro. Note that desired value of the macro is a C string and quotes have to be escaped during compilation: `clang++ test.cpp -DCATCH_CONFIG_DEFAULT_REPORTER=\"xml\"`.
|
||||||
|
|
||||||
# C++ conformance toggles
|
# C++ conformance toggles
|
||||||
|
|
||||||
@@ -100,6 +107,7 @@ TEST_CASE ("Error in streamable check") {
|
|||||||
CATCH_CONFIG_FAST_COMPILE // Sacrifices some (rather minor) features for compilation speed
|
CATCH_CONFIG_FAST_COMPILE // Sacrifices some (rather minor) features for compilation speed
|
||||||
CATCH_CONFIG_POSIX_SIGNALS // Enable handling POSIX signals
|
CATCH_CONFIG_POSIX_SIGNALS // Enable handling POSIX signals
|
||||||
CATCH_CONFIG_WINDOWS_CRTDBG // Enable leak checking using Windows's CRT Debug Heap
|
CATCH_CONFIG_WINDOWS_CRTDBG // Enable leak checking using Windows's CRT Debug Heap
|
||||||
|
CATCH_CONFIG_DISABLE_STRINGIFICATION // Disable stringifying the original expression
|
||||||
|
|
||||||
Currently Catch enables `CATCH_CONFIG_WINDOWS_SEH` only when compiled with MSVC, because some versions of MinGW do not have the necessary Win32 API support.
|
Currently Catch enables `CATCH_CONFIG_WINDOWS_SEH` only when compiled with MSVC, because some versions of MinGW do not have the necessary Win32 API support.
|
||||||
|
|
||||||
@@ -116,6 +124,10 @@ Defining this flag speeds up compilation of test files by ~20%, by making 2 chan
|
|||||||
|
|
||||||
`CATCH_CONFIG_FAST_COMPILE` has to be either defined, or not defined, in all translation units that are linked into single test binary, or the behaviour of setting `-b` flag and throwing unexpected exceptions will be unpredictable.
|
`CATCH_CONFIG_FAST_COMPILE` has to be either defined, or not defined, in all translation units that are linked into single test binary, or the behaviour of setting `-b` flag and throwing unexpected exceptions will be unpredictable.
|
||||||
|
|
||||||
|
## `CATCH_CONFIG_DISABLE_STRINGIFICATION`
|
||||||
|
This toggle enables a workaround for VS 2017 bug. For details see
|
||||||
|
[known limitations](limitations.md#visual-studio-2017----raw-string-literal-in-assert-fails-to-compile).
|
||||||
|
|
||||||
# Windows header clutter
|
# Windows header clutter
|
||||||
|
|
||||||
On Windows Catch includes `windows.h`. To minimize global namespace clutter in the implementation file, it defines `NOMINMAX` and `WIN32_LEAN_AND_MEAN` before including it. You can control this behaviour via two macros:
|
On Windows Catch includes `windows.h`. To minimize global namespace clutter in the implementation file, it defines `NOMINMAX` and `WIN32_LEAN_AND_MEAN` before including it. You can control this behaviour via two macros:
|
||||||
|
@@ -50,6 +50,38 @@ Both of these solutions have their problems, but should let you wring parallelis
|
|||||||
## 3rd party bugs
|
## 3rd party bugs
|
||||||
This section outlines known bugs in 3rd party components (this means compilers, standard libraries, standard runtimes).
|
This section outlines known bugs in 3rd party components (this means compilers, standard libraries, standard runtimes).
|
||||||
|
|
||||||
|
### Visual Studio 2017 -- raw string literal in assert fails to compile
|
||||||
|
There is a known bug in Visual Studio 2017 (VC 15), that causes compilation error when preprocessor attempts to stringize a raw string literal (`#` preprocessor is applied to it). This snippet is sufficient to trigger the compilation error:
|
||||||
|
```cpp
|
||||||
|
#define CATCH_CONFIG_MAIN
|
||||||
|
#include "catch.hpp"
|
||||||
|
|
||||||
|
TEST_CASE("test") {
|
||||||
|
CHECK(std::string(R"("\)") == "\"\\");
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
Catch provides a workaround, it is possible to disable stringification of original expressions by defining `CATCH_CONFIG_DISABLE_STRINGIFICATION`:
|
||||||
|
```cpp
|
||||||
|
#define CATCH_CONFIG_FAST_COMPILE
|
||||||
|
#define CATCH_CONFIG_DISABLE_STRINGIFICATION
|
||||||
|
#include "catch.hpp"
|
||||||
|
|
||||||
|
TEST_CASE("test") {
|
||||||
|
CHECK(std::string(R"("\)") == "\"\\");
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
_Do note that this changes the output somewhat_
|
||||||
|
```
|
||||||
|
catchwork\test1.cpp(6):
|
||||||
|
PASSED:
|
||||||
|
CHECK( Disabled by CATCH_CONFIG_DISABLE_STRINGIFICATION )
|
||||||
|
with expansion:
|
||||||
|
""\" == ""\"
|
||||||
|
```
|
||||||
|
|
||||||
|
|
||||||
### Visual Studio 2013 -- do-while loop withing range based for fails to compile (C2059)
|
### Visual Studio 2013 -- do-while loop withing range based for fails to compile (C2059)
|
||||||
There is a known bug in Visual Studio 2013 (VC 12), that causes compilation error if range based for is followed by an assertion macro, without enclosing the block in braces. This snippet is sufficient to trigger the error
|
There is a known bug in Visual Studio 2013 (VC 12), that causes compilation error if range based for is followed by an assertion macro, without enclosing the block in braces. This snippet is sufficient to trigger the error
|
||||||
```cpp
|
```cpp
|
||||||
|
@@ -13,6 +13,7 @@ which consists of either a single matcher or one or more matchers combined using
|
|||||||
For example, to assert that a string ends with a certain substring:
|
For example, to assert that a string ends with a certain substring:
|
||||||
|
|
||||||
```c++
|
```c++
|
||||||
|
using Catch::Matchers::EndsWith; // or Catch::EndsWith
|
||||||
std::string str = getStringFromSomewhere();
|
std::string str = getStringFromSomewhere();
|
||||||
REQUIRE_THAT( str, EndsWith( "as a service" ) );
|
REQUIRE_THAT( str, EndsWith( "as a service" ) );
|
||||||
```
|
```
|
||||||
@@ -34,7 +35,7 @@ REQUIRE_THAT( str,
|
|||||||
```
|
```
|
||||||
|
|
||||||
## Built in matchers
|
## Built in matchers
|
||||||
Currently Catch has some string matchers and some vector matchers.
|
Currently Catch has some string matchers and some vector matchers. They are in the `Catch::Matchers` and `Catch` namespaces.
|
||||||
The string matchers are `StartsWith`, `EndsWith`, `Contains` and `Equals`. Each of them also takes an optional second argument, that decides case sensitivity (by-default, they are case sensitive).
|
The string matchers are `StartsWith`, `EndsWith`, `Contains` and `Equals`. Each of them also takes an optional second argument, that decides case sensitivity (by-default, they are case sensitive).
|
||||||
The vector matchers are `Contains`, `VectorContains` and `Equals`. `VectorContains` looks for a single element in the matched vector, `Contains` looks for a set (vector) of elements inside the matched vector.
|
The vector matchers are `Contains`, `VectorContains` and `Equals`. `VectorContains` looks for a single element in the matched vector, `Contains` looks for a set (vector) of elements inside the matched vector.
|
||||||
|
|
||||||
|
@@ -1,6 +1,6 @@
|
|||||||
# Open Source projects using Catch
|
# Open Source projects using Catch
|
||||||
|
|
||||||
Catch is great for open source. With it's [liberal license](../LICENSE.txt) and single-header, dependency-free, distribution
|
Catch is great for open source. With its [liberal license](../LICENSE.txt) and single-header, dependency-free, distribution
|
||||||
it's easy to just drop the header into your project and start writing tests - what's not to like?
|
it's easy to just drop the header into your project and start writing tests - what's not to like?
|
||||||
|
|
||||||
As a result Catch is now being used in many Open Source projects, including some quite well known ones.
|
As a result Catch is now being used in many Open Source projects, including some quite well known ones.
|
||||||
@@ -25,6 +25,9 @@ The core part of the Chakra Javascript engine that powers Microsoft Edge
|
|||||||
### [ChaiScript](https://github.com/ChaiScript/ChaiScript)
|
### [ChaiScript](https://github.com/ChaiScript/ChaiScript)
|
||||||
A, header-only, embedded scripting language designed from the ground up to directly target C++ and take advantage of modern C++ development techniques
|
A, header-only, embedded scripting language designed from the ground up to directly target C++ and take advantage of modern C++ development techniques
|
||||||
|
|
||||||
|
### [Clara](https://github.com/philsquared/Clara)
|
||||||
|
A, single-header-only, type-safe, command line parser - which also prints formatted usage strings.
|
||||||
|
|
||||||
### [Couchbase-lite-core](https://github.com/couchbase/couchbase-lite-core)
|
### [Couchbase-lite-core](https://github.com/couchbase/couchbase-lite-core)
|
||||||
The next-generation core storage and query engine for Couchbase Lite/
|
The next-generation core storage and query engine for Couchbase Lite/
|
||||||
|
|
||||||
@@ -52,14 +55,23 @@ A C++ client library for Consul. Consul is a distributed tool for discovering an
|
|||||||
### [Reactive-Extensions/ RxCpp](https://github.com/Reactive-Extensions/RxCpp)
|
### [Reactive-Extensions/ RxCpp](https://github.com/Reactive-Extensions/RxCpp)
|
||||||
A library of algorithms for values-distributed-in-time
|
A library of algorithms for values-distributed-in-time
|
||||||
|
|
||||||
|
### [TextFlowCpp](https://github.com/philsquared/textflowcpp)
|
||||||
|
A small, single-header-only, library for wrapping and composing columns of text
|
||||||
|
|
||||||
### [Trompeloeil](https://github.com/rollbear/trompeloeil)
|
### [Trompeloeil](https://github.com/rollbear/trompeloeil)
|
||||||
A thread safe header only mocking framework for C++14
|
A thread safe header only mocking framework for C++14
|
||||||
|
|
||||||
|
### [args](https://github.com/Taywee/args)
|
||||||
|
A simple header-only C++ argument parser library.
|
||||||
|
|
||||||
## Applications & Tools
|
## Applications & Tools
|
||||||
|
|
||||||
### [ArangoDB](https://github.com/arangodb/arangodb)
|
### [ArangoDB](https://github.com/arangodb/arangodb)
|
||||||
ArangoDB is a native multi-model database with flexible data models for documents, graphs, and key-values.
|
ArangoDB is a native multi-model database with flexible data models for documents, graphs, and key-values.
|
||||||
|
|
||||||
|
### [Giada - Your Hardcore Loop Machine](https://github.com/monocasual/giada)
|
||||||
|
Minimal, open-source and cross-platform audio tool for live music production.
|
||||||
|
|
||||||
### [MAME](https://github.com/mamedev/mame)
|
### [MAME](https://github.com/mamedev/mame)
|
||||||
MAME originally stood for Multiple Arcade Machine Emulator
|
MAME originally stood for Multiple Arcade Machine Emulator
|
||||||
|
|
||||||
|
@@ -1,3 +1,75 @@
|
|||||||
|
# 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.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)
|
||||||
|
* Previously it was meant and documented as inclusive, but the check itself wasn't
|
||||||
|
* This means that `REQUIRE( 0.25f == Approx( 0.0f ).margin( 0.25f ) )` passes, instead of fails
|
||||||
|
* `RandomNumberGenerator::result_type` is now unsigned (#1050)
|
||||||
|
|
||||||
|
### 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)
|
||||||
|
* On some platforms, output from redirected streams would show up only after the tests finished running
|
||||||
|
* `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.0
|
||||||
|
|
||||||
|
### 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
|
||||||
|
* Added [libidentify](https://github.com/janwilmans/LibIdentify) support
|
||||||
|
* Added "wait-for-keypress" option
|
||||||
|
|
||||||
|
|
||||||
|
# 1.9.7
|
||||||
|
|
||||||
|
### Fixes
|
||||||
|
* Various warnings from clang-tidy, Resharper-C++ and PVS Studio have been addressed (#957)
|
||||||
|
* Dynamically generated sections are now properly reported (#963)
|
||||||
|
* Writes to `std::clog` are redirected for reporters (#989)
|
||||||
|
* Previously only `std::cerr` writes were redirected
|
||||||
|
* Interleaved writes to `std::cerr` and `std::clog` are combined properly
|
||||||
|
* Assertions failed before signals/structured exceptions fails test case are properly reported as failed (#990)
|
||||||
|
|
||||||
|
### Improvements
|
||||||
|
* Catch's runtime overhead has been decreased further (#940)
|
||||||
|
* Added support for IBM i ILE c++ compiler (#976)
|
||||||
|
* This means that AS/400 is now supported.
|
||||||
|
* The default reporter can be configured at compile time (#978)
|
||||||
|
* That is, the reporter used if no reporter is explicitly specified
|
||||||
|
|
||||||
|
### Other
|
||||||
|
* `ParseAndAddCatchTests` cmake script has couple new customization options
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
# 1.9.6
|
# 1.9.6
|
||||||
|
|
||||||
### Improvements
|
### Improvements
|
||||||
|
@@ -2,43 +2,62 @@
|
|||||||
|
|
||||||
When enough changes have accumulated, it is time to release new version of Catch. This document describes the proces in doing so, that no steps are forgotten. Note that all referenced scripts can be found in the `scripts/` directory.
|
When enough changes have accumulated, it is time to release new version of Catch. This document describes the proces in doing so, that no steps are forgotten. Note that all referenced scripts can be found in the `scripts/` directory.
|
||||||
|
|
||||||
|
## Neccessary steps
|
||||||
|
|
||||||
## Approval testing
|
These steps are neccessary and have to be performed before each new release. They serve to make sure that the new release is correct and linked-to from the standard places.
|
||||||
|
|
||||||
|
|
||||||
|
### Approval testing
|
||||||
|
|
||||||
Catch's releases are primarily validated against output from previous release, stored in `projects/SelfTest/Baselines`. To validate current sources, build the SelfTest binary and pass it to the `approvalTests.py` script: `approvalTests.py <path/to/SelfTest>`.
|
Catch's releases are primarily validated against output from previous release, stored in `projects/SelfTest/Baselines`. To validate current sources, build the SelfTest binary and pass it to the `approvalTests.py` script: `approvalTests.py <path/to/SelfTest>`.
|
||||||
|
|
||||||
There should be no differences, as Approval tests should be updated when changes to Catch are made, but if there are, then they need to be manually reviewed and either approved (using `approve.py`) or Catch requires other fixes.
|
There should be no differences, as Approval tests should be updated when changes to Catch are made, but if there are, then they need to be manually reviewed and either approved (using `approve.py`) or Catch requires other fixes.
|
||||||
|
|
||||||
|
|
||||||
## Incrementing version number
|
### Incrementing version number
|
||||||
|
|
||||||
Catch uses a variant of [semantic versioning](http://semver.org/), with breaking API changes (and thus major version increments) being very rare. Thus, the release will usually increment the patch version, when it only contains couple of bugfixes, or minor version, when it contains new functionality, or larger changes in implementation of current functionality.
|
Catch uses a variant of [semantic versioning](http://semver.org/), with breaking API changes (and thus major version increments) being very rare. Thus, the release will usually increment the patch version, when it only contains couple of bugfixes, or minor version, when it contains new functionality, or larger changes in implementation of current functionality.
|
||||||
|
|
||||||
After deciding which part of version number should be incremented, you can use one of the `*Release.py` scripts to perform the required changes to Catch.
|
After deciding which part of version number should be incremented, you can use one of the `*Release.py` scripts to perform the required changes to Catch.
|
||||||
|
|
||||||
|
|
||||||
## Generate updated single-include header
|
### Generate updated single-include header
|
||||||
|
|
||||||
After updating version number, regenerate single-include header using `generateSingleHeader.py`.
|
After updating version number, regenerate single-include header using `generateSingleHeader.py`.
|
||||||
|
|
||||||
|
|
||||||
## Release notes
|
### Release notes
|
||||||
|
|
||||||
Once a release is ready, release notes need to be written. They should summarize changes done since last release. For rough idea of expected notes see previous releases. Once written, release notes should be placed in `docs/release-notes.md`.
|
Once a release is ready, release notes need to be written. They should summarize changes done since last release. For rough idea of expected notes see previous releases. Once written, release notes should be placed in `docs/release-notes.md`.
|
||||||
|
|
||||||
|
|
||||||
## Commit and push update to GitHub
|
### Commit and push update to GitHub
|
||||||
|
|
||||||
After version number is incremented, single-include header is regenerated and release notes are updated, changes should be commited and pushed to GitHub.
|
After version number is incremented, single-include header is regenerated and release notes are updated, changes should be commited and pushed to GitHub.
|
||||||
|
|
||||||
|
|
||||||
## Release on GitHub
|
### Release on GitHub
|
||||||
|
|
||||||
After pushing changes to GitHub, GitHub release *needs* to be created. Tag version and release title should be same as the new version, description should contain the release notes for the current release. Single header version of `catch.hpp` *needs* to be attached as a binary, as that is where the official download link links to. Preferably it should use linux line endings.
|
After pushing changes to GitHub, GitHub release *needs* to be created. Tag version and release title should be same as the new version, description should contain the release notes for the current release. Single header version of `catch.hpp` *needs* to be attached as a binary, as that is where the official download link links to. Preferably it should use linux line endings.
|
||||||
|
|
||||||
|
## Optional steps
|
||||||
|
|
||||||
## vcpkg update
|
The following steps are optional, and do not have to be performed when releasing new version of Catch. However, they are *should* happen, but they can happen the next day without losing anything significant.
|
||||||
|
|
||||||
As a last step, optionally update Microsoft's package manager [vcpkg](https://github.com/Microsoft/vcpkg) with Catch's new version. `updateVcpkgPackage.py` can do a lot of neccessary work for you, but it assumes that you have your fork of vcpkg checked out in a directory next to the directory, where you have checked out Catch.
|
|
||||||
|
|
||||||
It creates a branch and commits neccessary changes, that you then should review, synchronize and open a PR against.
|
### vcpkg update
|
||||||
|
|
||||||
|
Catch is maintaining its own port in Microsoft's package manager [vcpkg](https://github.com/Microsoft/vcpkg). This means that when new version of Catch is released, it should be posted there as well. `updateVcpkgPackage.py` can do a lot of neccessary work for you, it creates a branch and commits neccessary changes. You should review these changes, push and open a PR against vcpkg's upstream.
|
||||||
|
|
||||||
|
Note that the script assumes you have your fork of vcpkg checked out in a directory next to the directory where you have checked out Catch, like so:
|
||||||
|
```
|
||||||
|
GitHub
|
||||||
|
Catch
|
||||||
|
vcpkg
|
||||||
|
```
|
||||||
|
|
||||||
|
|
||||||
|
### Wandbox update
|
||||||
|
|
||||||
|
Recently we also included a link to wandbox with preloaded Catch on the main page. Strictly speaking it is unneccessary to update this after every release, Catch usually does not change that much between versions, but it should be kept up to date anyway.
|
||||||
|
|
||||||
|
@@ -38,19 +38,19 @@ All tag names beginning with non-alphanumeric characters are reserved by Catch.
|
|||||||
|
|
||||||
* `[!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`.
|
* `[!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`.
|
||||||
|
|
||||||
* `[!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 the your tests.
|
* `[!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.
|
||||||
|
|
||||||
* `[!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.
|
* `[!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.
|
||||||
|
|
||||||
* `[!nonportable]` - Indicates that behaviour may vary between platforms or compilers.
|
* `[!nonportable]` - Indicates that behaviour may vary between platforms or compilers.
|
||||||
|
|
||||||
* `[#<filename>]` - running with `-#` or `--filenames-as-tags` causes Catch to add the filename, prefixed with `#` (and with any extension stripped) as a tag. e.g. tests in testfile.cpp would all be tagged `[#testfile]`.
|
* `[#<filename>]` - running with `-#` or `--filenames-as-tags` causes Catch to add the filename, prefixed with `#` (and with any extension stripped), as a tag to all contained tests, e.g. tests in testfile.cpp would all be tagged `[#testfile]`.
|
||||||
|
|
||||||
* `[@<alias>]` - tag aliases all begin with `@` (see below).
|
* `[@<alias>]` - tag aliases all begin with `@` (see below).
|
||||||
|
|
||||||
## Tag aliases
|
## Tag aliases
|
||||||
|
|
||||||
Between tag expressions and wildcarded test names (as well as combinations of the two) quite complex patterns can be constructed to direct which test cases are run. If a complex pattern is used often it is convenient to be able to create an alias for the expression. this can be done, in code, using the following form:
|
Between tag expressions and wildcarded test names (as well as combinations of the two) quite complex patterns can be constructed to direct which test cases are run. If a complex pattern is used often it is convenient to be able to create an alias for the expression. This can be done, in code, using the following form:
|
||||||
|
|
||||||
CATCH_REGISTER_TAG_ALIAS( <alias string>, <tag expression> )
|
CATCH_REGISTER_TAG_ALIAS( <alias string>, <tag expression> )
|
||||||
|
|
||||||
|
@@ -80,7 +80,7 @@ unsigned int Factorial( unsigned int number ) {
|
|||||||
|
|
||||||
Now all the tests pass.
|
Now all the tests pass.
|
||||||
|
|
||||||
Of course there are still more issues to do deal with. For example we'll hit problems when the return value starts to exceed the range of an unsigned int. With factorials that can happen quite quickly. You might want to add tests for such cases and decide how to handle them. We'll stop short of doing that here.
|
Of course there are still more issues to deal with. For example we'll hit problems when the return value starts to exceed the range of an unsigned int. With factorials that can happen quite quickly. You might want to add tests for such cases and decide how to handle them. We'll stop short of doing that here.
|
||||||
|
|
||||||
## What did we do here?
|
## What did we do here?
|
||||||
|
|
||||||
|
@@ -31,10 +31,14 @@ namespace Catch {
|
|||||||
return reporter;
|
return reporter;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#if !defined(CATCH_CONFIG_DEFAULT_REPORTER)
|
||||||
|
#define CATCH_CONFIG_DEFAULT_REPORTER "console"
|
||||||
|
#endif
|
||||||
|
|
||||||
Ptr<IStreamingReporter> makeReporter( Ptr<Config> const& config ) {
|
Ptr<IStreamingReporter> makeReporter( Ptr<Config> const& config ) {
|
||||||
std::vector<std::string> reporters = config->getReporterNames();
|
std::vector<std::string> reporters = config->getReporterNames();
|
||||||
if( reporters.empty() )
|
if( reporters.empty() )
|
||||||
reporters.push_back( "console" );
|
reporters.push_back( CATCH_CONFIG_DEFAULT_REPORTER );
|
||||||
|
|
||||||
Ptr<IStreamingReporter> reporter;
|
Ptr<IStreamingReporter> reporter;
|
||||||
for( std::vector<std::string>::const_iterator it = reporters.begin(), itEnd = reporters.end();
|
for( std::vector<std::string>::const_iterator it = reporters.begin(), itEnd = reporters.end();
|
||||||
@@ -95,11 +99,11 @@ namespace Catch {
|
|||||||
if( lastSlash != std::string::npos )
|
if( lastSlash != std::string::npos )
|
||||||
filename = filename.substr( lastSlash+1 );
|
filename = filename.substr( lastSlash+1 );
|
||||||
|
|
||||||
std::string::size_type lastDot = filename.find_last_of( "." );
|
std::string::size_type lastDot = filename.find_last_of( '.' );
|
||||||
if( lastDot != std::string::npos )
|
if( lastDot != std::string::npos )
|
||||||
filename = filename.substr( 0, lastDot );
|
filename = filename.substr( 0, lastDot );
|
||||||
|
|
||||||
tags.insert( "#" + filename );
|
tags.insert( '#' + filename );
|
||||||
setTags( test, tags );
|
setTags( test, tags );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -130,6 +134,13 @@ namespace Catch {
|
|||||||
m_cli.usage( Catch::cout(), processName );
|
m_cli.usage( Catch::cout(), processName );
|
||||||
Catch::cout() << "For more detail usage please see the project docs\n" << std::endl;
|
Catch::cout() << "For more detail usage please see the project docs\n" << std::endl;
|
||||||
}
|
}
|
||||||
|
void libIdentify() {
|
||||||
|
Catch::cout()
|
||||||
|
<< std::left << std::setw(16) << "description: " << "A Catch test executable\n"
|
||||||
|
<< std::left << std::setw(16) << "category: " << "testframework\n"
|
||||||
|
<< std::left << std::setw(16) << "framework: " << "Catch Test\n"
|
||||||
|
<< std::left << std::setw(16) << "version: " << libraryVersion() << std::endl;
|
||||||
|
}
|
||||||
|
|
||||||
int applyCommandLine( int argc, char const* const* const argv, OnUnusedOptions::DoWhat unusedOptionBehaviour = OnUnusedOptions::Fail ) {
|
int applyCommandLine( int argc, char const* const* const argv, OnUnusedOptions::DoWhat unusedOptionBehaviour = OnUnusedOptions::Fail ) {
|
||||||
try {
|
try {
|
||||||
@@ -137,6 +148,8 @@ namespace Catch {
|
|||||||
m_unusedTokens = m_cli.parseInto( Clara::argsToVector( argc, argv ), m_configData );
|
m_unusedTokens = m_cli.parseInto( Clara::argsToVector( argc, argv ), m_configData );
|
||||||
if( m_configData.showHelp )
|
if( m_configData.showHelp )
|
||||||
showHelp( m_configData.processName );
|
showHelp( m_configData.processName );
|
||||||
|
if( m_configData.libIdentify )
|
||||||
|
libIdentify();
|
||||||
m_config.reset();
|
m_config.reset();
|
||||||
}
|
}
|
||||||
catch( std::exception& ex ) {
|
catch( std::exception& ex ) {
|
||||||
@@ -193,7 +206,36 @@ namespace Catch {
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
int run() {
|
int run() {
|
||||||
if( m_configData.showHelp )
|
if( ( m_configData.waitForKeypress & WaitForKeypress::BeforeStart ) != 0 ) {
|
||||||
|
Catch::cout() << "...waiting for enter/ return before starting" << std::endl;
|
||||||
|
static_cast<void>(std::getchar());
|
||||||
|
}
|
||||||
|
int exitCode = runInternal();
|
||||||
|
if( ( m_configData.waitForKeypress & WaitForKeypress::BeforeExit ) != 0 ) {
|
||||||
|
Catch::cout() << "...waiting for enter/ return before exiting, with code: " << exitCode << std::endl;
|
||||||
|
static_cast<void>(std::getchar());
|
||||||
|
}
|
||||||
|
return exitCode;
|
||||||
|
}
|
||||||
|
|
||||||
|
Clara::CommandLine<ConfigData> const& cli() const {
|
||||||
|
return m_cli;
|
||||||
|
}
|
||||||
|
std::vector<Clara::Parser::Token> const& unusedTokens() const {
|
||||||
|
return m_unusedTokens;
|
||||||
|
}
|
||||||
|
ConfigData& configData() {
|
||||||
|
return m_configData;
|
||||||
|
}
|
||||||
|
Config& config() {
|
||||||
|
if( !m_config )
|
||||||
|
m_config = new Config( m_configData );
|
||||||
|
return *m_config;
|
||||||
|
}
|
||||||
|
private:
|
||||||
|
|
||||||
|
int runInternal() {
|
||||||
|
if( m_configData.showHelp || m_configData.libIdentify )
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
try
|
try
|
||||||
@@ -217,21 +259,6 @@ namespace Catch {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Clara::CommandLine<ConfigData> const& cli() const {
|
|
||||||
return m_cli;
|
|
||||||
}
|
|
||||||
std::vector<Clara::Parser::Token> const& unusedTokens() const {
|
|
||||||
return m_unusedTokens;
|
|
||||||
}
|
|
||||||
ConfigData& configData() {
|
|
||||||
return m_configData;
|
|
||||||
}
|
|
||||||
Config& config() {
|
|
||||||
if( !m_config )
|
|
||||||
m_config = new Config( m_configData );
|
|
||||||
return *m_config;
|
|
||||||
}
|
|
||||||
private:
|
|
||||||
Clara::CommandLine<ConfigData> m_cli;
|
Clara::CommandLine<ConfigData> m_cli;
|
||||||
std::vector<Clara::Parser::Token> m_unusedTokens;
|
std::vector<Clara::Parser::Token> m_unusedTokens;
|
||||||
ConfigData m_configData;
|
ConfigData m_configData;
|
||||||
|
2
include/external/clara.h
vendored
2
include/external/clara.h
vendored
@@ -151,7 +151,7 @@ namespace Tbc {
|
|||||||
return oss.str();
|
return oss.str();
|
||||||
}
|
}
|
||||||
|
|
||||||
inline friend std::ostream& operator << ( std::ostream& _stream, Text const& _text ) {
|
friend std::ostream& operator << ( std::ostream& _stream, Text const& _text ) {
|
||||||
for( Text::const_iterator it = _text.begin(), itEnd = _text.end();
|
for( Text::const_iterator it = _text.begin(), itEnd = _text.end();
|
||||||
it != itEnd; ++it ) {
|
it != itEnd; ++it ) {
|
||||||
if( it != _text.begin() )
|
if( it != _text.begin() )
|
||||||
|
@@ -29,13 +29,6 @@ namespace Detail {
|
|||||||
m_value( value )
|
m_value( value )
|
||||||
{}
|
{}
|
||||||
|
|
||||||
Approx( Approx const& other )
|
|
||||||
: m_epsilon( other.m_epsilon ),
|
|
||||||
m_margin( other.m_margin ),
|
|
||||||
m_scale( other.m_scale ),
|
|
||||||
m_value( other.m_value )
|
|
||||||
{}
|
|
||||||
|
|
||||||
static Approx custom() {
|
static Approx custom() {
|
||||||
return Approx( 0 );
|
return Approx( 0 );
|
||||||
}
|
}
|
||||||
@@ -64,7 +57,8 @@ namespace Detail {
|
|||||||
if (relativeOK) {
|
if (relativeOK) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
return std::fabs(lhs_v - rhs.m_value) < rhs.m_margin;
|
|
||||||
|
return std::fabs(lhs_v - rhs.m_value) <= rhs.m_margin;
|
||||||
}
|
}
|
||||||
|
|
||||||
template <typename T, typename = typename std::enable_if<std::is_constructible<double, T>::value>::type>
|
template <typename T, typename = typename std::enable_if<std::is_constructible<double, T>::value>::type>
|
||||||
@@ -137,7 +131,7 @@ namespace Detail {
|
|||||||
if (relativeOK) {
|
if (relativeOK) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
return std::fabs(lhs - rhs.m_value) < rhs.m_margin;
|
return std::fabs(lhs - rhs.m_value) <= rhs.m_margin;
|
||||||
}
|
}
|
||||||
|
|
||||||
friend bool operator == ( Approx const& lhs, double rhs ) {
|
friend bool operator == ( Approx const& lhs, double rhs ) {
|
||||||
|
@@ -39,7 +39,7 @@ namespace Catch {
|
|||||||
|
|
||||||
struct AssertionInfo
|
struct AssertionInfo
|
||||||
{
|
{
|
||||||
AssertionInfo() {}
|
AssertionInfo();
|
||||||
AssertionInfo( char const * _macroName,
|
AssertionInfo( char const * _macroName,
|
||||||
SourceLineInfo const& _lineInfo,
|
SourceLineInfo const& _lineInfo,
|
||||||
char const * _capturedExpression,
|
char const * _capturedExpression,
|
||||||
|
@@ -13,6 +13,8 @@
|
|||||||
namespace Catch {
|
namespace Catch {
|
||||||
|
|
||||||
|
|
||||||
|
AssertionInfo::AssertionInfo():macroName(""), capturedExpression(""), resultDisposition(ResultDisposition::Normal), secondArg(""){}
|
||||||
|
|
||||||
AssertionInfo::AssertionInfo( char const * _macroName,
|
AssertionInfo::AssertionInfo( char const * _macroName,
|
||||||
SourceLineInfo const& _lineInfo,
|
SourceLineInfo const& _lineInfo,
|
||||||
char const * _capturedExpression,
|
char const * _capturedExpression,
|
||||||
@@ -64,7 +66,7 @@ namespace Catch {
|
|||||||
|
|
||||||
std::string AssertionResult::getExpression() const {
|
std::string AssertionResult::getExpression() const {
|
||||||
if( isFalseTest( m_info.resultDisposition ) )
|
if( isFalseTest( m_info.resultDisposition ) )
|
||||||
return '!' + capturedExpressionWithSecondArgument(m_info.capturedExpression, m_info.secondArg);
|
return "!(" + capturedExpressionWithSecondArgument(m_info.capturedExpression, m_info.secondArg) + ")";
|
||||||
else
|
else
|
||||||
return capturedExpressionWithSecondArgument(m_info.capturedExpression, m_info.secondArg);
|
return capturedExpressionWithSecondArgument(m_info.capturedExpression, m_info.secondArg);
|
||||||
}
|
}
|
||||||
|
@@ -18,6 +18,12 @@
|
|||||||
#include "catch_compiler_capabilities.h"
|
#include "catch_compiler_capabilities.h"
|
||||||
|
|
||||||
|
|
||||||
|
#if !defined(CATCH_CONFIG_DISABLE_STRINGIFICATION)
|
||||||
|
# define CATCH_INTERNAL_STRINGIFY(expr) #expr
|
||||||
|
#else
|
||||||
|
# define CATCH_INTERNAL_STRINGIFY(expr) "Disabled by CATCH_CONFIG_DISABLE_STRINGIFICATION"
|
||||||
|
#endif
|
||||||
|
|
||||||
#if defined(CATCH_CONFIG_FAST_COMPILE)
|
#if defined(CATCH_CONFIG_FAST_COMPILE)
|
||||||
///////////////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////////////
|
||||||
// We can speedup compilation significantly by breaking into debugger lower in
|
// We can speedup compilation significantly by breaking into debugger lower in
|
||||||
@@ -33,7 +39,7 @@
|
|||||||
// the exception before it propagates back up to the runner.
|
// the exception before it propagates back up to the runner.
|
||||||
#define INTERNAL_CATCH_TEST_NO_TRY( macroName, resultDisposition, expr ) \
|
#define INTERNAL_CATCH_TEST_NO_TRY( macroName, resultDisposition, expr ) \
|
||||||
do { \
|
do { \
|
||||||
Catch::ResultBuilder __catchResult( macroName, CATCH_INTERNAL_LINEINFO, #expr, resultDisposition ); \
|
Catch::ResultBuilder __catchResult( macroName, CATCH_INTERNAL_LINEINFO, CATCH_INTERNAL_STRINGIFY(expr), resultDisposition ); \
|
||||||
__catchResult.setExceptionGuard(); \
|
__catchResult.setExceptionGuard(); \
|
||||||
CATCH_INTERNAL_SUPPRESS_PARENTHESES_WARNINGS \
|
CATCH_INTERNAL_SUPPRESS_PARENTHESES_WARNINGS \
|
||||||
( __catchResult <= expr ).endExpression(); \
|
( __catchResult <= expr ).endExpression(); \
|
||||||
@@ -45,9 +51,9 @@
|
|||||||
|
|
||||||
#define INTERNAL_CHECK_THAT_NO_TRY( macroName, matcher, resultDisposition, arg ) \
|
#define INTERNAL_CHECK_THAT_NO_TRY( macroName, matcher, resultDisposition, arg ) \
|
||||||
do { \
|
do { \
|
||||||
Catch::ResultBuilder __catchResult( macroName, CATCH_INTERNAL_LINEINFO, #arg ", " #matcher, resultDisposition ); \
|
Catch::ResultBuilder __catchResult( macroName, CATCH_INTERNAL_LINEINFO, CATCH_INTERNAL_STRINGIFY(arg) ", " CATCH_INTERNAL_STRINGIFY(matcher), resultDisposition ); \
|
||||||
__catchResult.setExceptionGuard(); \
|
__catchResult.setExceptionGuard(); \
|
||||||
__catchResult.captureMatch( arg, matcher, #matcher ); \
|
__catchResult.captureMatch( arg, matcher, CATCH_INTERNAL_STRINGIFY(matcher) ); \
|
||||||
__catchResult.unsetExceptionGuard(); \
|
__catchResult.unsetExceptionGuard(); \
|
||||||
INTERNAL_CATCH_REACT( __catchResult ) \
|
INTERNAL_CATCH_REACT( __catchResult ) \
|
||||||
} while( Catch::alwaysFalse() )
|
} while( Catch::alwaysFalse() )
|
||||||
@@ -67,7 +73,7 @@
|
|||||||
///////////////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////////////
|
||||||
#define INTERNAL_CATCH_TEST( macroName, resultDisposition, expr ) \
|
#define INTERNAL_CATCH_TEST( macroName, resultDisposition, expr ) \
|
||||||
do { \
|
do { \
|
||||||
Catch::ResultBuilder __catchResult( macroName, CATCH_INTERNAL_LINEINFO, #expr, resultDisposition ); \
|
Catch::ResultBuilder __catchResult( macroName, CATCH_INTERNAL_LINEINFO, CATCH_INTERNAL_STRINGIFY(expr), resultDisposition ); \
|
||||||
try { \
|
try { \
|
||||||
CATCH_INTERNAL_SUPPRESS_PARENTHESES_WARNINGS \
|
CATCH_INTERNAL_SUPPRESS_PARENTHESES_WARNINGS \
|
||||||
( __catchResult <= expr ).endExpression(); \
|
( __catchResult <= expr ).endExpression(); \
|
||||||
@@ -83,17 +89,17 @@
|
|||||||
///////////////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////////////
|
||||||
#define INTERNAL_CATCH_IF( macroName, resultDisposition, expr ) \
|
#define INTERNAL_CATCH_IF( macroName, resultDisposition, expr ) \
|
||||||
INTERNAL_CATCH_TEST( macroName, resultDisposition, expr ); \
|
INTERNAL_CATCH_TEST( macroName, resultDisposition, expr ); \
|
||||||
if( Catch::getResultCapture().getLastResult()->succeeded() )
|
if( Catch::getResultCapture().lastAssertionPassed() )
|
||||||
|
|
||||||
///////////////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////////////
|
||||||
#define INTERNAL_CATCH_ELSE( macroName, resultDisposition, expr ) \
|
#define INTERNAL_CATCH_ELSE( macroName, resultDisposition, expr ) \
|
||||||
INTERNAL_CATCH_TEST( macroName, resultDisposition, expr ); \
|
INTERNAL_CATCH_TEST( macroName, resultDisposition, expr ); \
|
||||||
if( !Catch::getResultCapture().getLastResult()->succeeded() )
|
if( !Catch::getResultCapture().lastAssertionPassed() )
|
||||||
|
|
||||||
///////////////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////////////
|
||||||
#define INTERNAL_CATCH_NO_THROW( macroName, resultDisposition, expr ) \
|
#define INTERNAL_CATCH_NO_THROW( macroName, resultDisposition, expr ) \
|
||||||
do { \
|
do { \
|
||||||
Catch::ResultBuilder __catchResult( macroName, CATCH_INTERNAL_LINEINFO, #expr, resultDisposition ); \
|
Catch::ResultBuilder __catchResult( macroName, CATCH_INTERNAL_LINEINFO, CATCH_INTERNAL_STRINGIFY(expr), resultDisposition ); \
|
||||||
try { \
|
try { \
|
||||||
static_cast<void>(expr); \
|
static_cast<void>(expr); \
|
||||||
__catchResult.captureResult( Catch::ResultWas::Ok ); \
|
__catchResult.captureResult( Catch::ResultWas::Ok ); \
|
||||||
@@ -107,7 +113,7 @@
|
|||||||
///////////////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////////////
|
||||||
#define INTERNAL_CATCH_THROWS( macroName, resultDisposition, matcher, expr ) \
|
#define INTERNAL_CATCH_THROWS( macroName, resultDisposition, matcher, expr ) \
|
||||||
do { \
|
do { \
|
||||||
Catch::ResultBuilder __catchResult( macroName, CATCH_INTERNAL_LINEINFO, #expr, resultDisposition, #matcher ); \
|
Catch::ResultBuilder __catchResult( macroName, CATCH_INTERNAL_LINEINFO, CATCH_INTERNAL_STRINGIFY(expr), resultDisposition, CATCH_INTERNAL_STRINGIFY(matcher) ); \
|
||||||
if( __catchResult.allowThrows() ) \
|
if( __catchResult.allowThrows() ) \
|
||||||
try { \
|
try { \
|
||||||
static_cast<void>(expr); \
|
static_cast<void>(expr); \
|
||||||
@@ -124,7 +130,7 @@
|
|||||||
///////////////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////////////
|
||||||
#define INTERNAL_CATCH_THROWS_AS( macroName, exceptionType, resultDisposition, expr ) \
|
#define INTERNAL_CATCH_THROWS_AS( macroName, exceptionType, resultDisposition, expr ) \
|
||||||
do { \
|
do { \
|
||||||
Catch::ResultBuilder __catchResult( macroName, CATCH_INTERNAL_LINEINFO, #expr ", " #exceptionType, resultDisposition ); \
|
Catch::ResultBuilder __catchResult( macroName, CATCH_INTERNAL_LINEINFO, CATCH_INTERNAL_STRINGIFY(expr) ", " CATCH_INTERNAL_STRINGIFY(exceptionType), resultDisposition ); \
|
||||||
if( __catchResult.allowThrows() ) \
|
if( __catchResult.allowThrows() ) \
|
||||||
try { \
|
try { \
|
||||||
static_cast<void>(expr); \
|
static_cast<void>(expr); \
|
||||||
@@ -168,9 +174,9 @@
|
|||||||
///////////////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////////////
|
||||||
#define INTERNAL_CHECK_THAT( macroName, matcher, resultDisposition, arg ) \
|
#define INTERNAL_CHECK_THAT( macroName, matcher, resultDisposition, arg ) \
|
||||||
do { \
|
do { \
|
||||||
Catch::ResultBuilder __catchResult( macroName, CATCH_INTERNAL_LINEINFO, #arg ", " #matcher, resultDisposition ); \
|
Catch::ResultBuilder __catchResult( macroName, CATCH_INTERNAL_LINEINFO, CATCH_INTERNAL_STRINGIFY(arg) ", " CATCH_INTERNAL_STRINGIFY(matcher), resultDisposition ); \
|
||||||
try { \
|
try { \
|
||||||
__catchResult.captureMatch( arg, matcher, #matcher ); \
|
__catchResult.captureMatch( arg, matcher, CATCH_INTERNAL_STRINGIFY(matcher) ); \
|
||||||
} catch( ... ) { \
|
} catch( ... ) { \
|
||||||
__catchResult.useActiveException( resultDisposition | Catch::ResultDisposition::ContinueOnFailure ); \
|
__catchResult.useActiveException( resultDisposition | Catch::ResultDisposition::ContinueOnFailure ); \
|
||||||
} \
|
} \
|
||||||
|
@@ -76,6 +76,19 @@ namespace Catch {
|
|||||||
else
|
else
|
||||||
throw std::runtime_error( "colour mode must be one of: auto, yes or no" );
|
throw std::runtime_error( "colour mode must be one of: auto, yes or no" );
|
||||||
}
|
}
|
||||||
|
inline void setWaitForKeypress( ConfigData& config, std::string const& keypress ) {
|
||||||
|
std::string keypressLc = toLower( keypress );
|
||||||
|
if( keypressLc == "start" )
|
||||||
|
config.waitForKeypress = WaitForKeypress::BeforeStart;
|
||||||
|
else if( keypressLc == "exit" )
|
||||||
|
config.waitForKeypress = WaitForKeypress::BeforeExit;
|
||||||
|
else if( keypressLc == "both" )
|
||||||
|
config.waitForKeypress = WaitForKeypress::BeforeStartAndExit;
|
||||||
|
else
|
||||||
|
throw std::runtime_error( "keypress argument must be one of: start, exit or both. '" + keypress + "' not recognised" );
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
inline void forceColour( ConfigData& config ) {
|
inline void forceColour( ConfigData& config ) {
|
||||||
config.useColour = UseColour::Yes;
|
config.useColour = UseColour::Yes;
|
||||||
}
|
}
|
||||||
@@ -211,6 +224,14 @@ namespace Catch {
|
|||||||
.describe( "should output be colourised" )
|
.describe( "should output be colourised" )
|
||||||
.bind( &setUseColour, "yes|no" );
|
.bind( &setUseColour, "yes|no" );
|
||||||
|
|
||||||
|
cli["--libidentify"]
|
||||||
|
.describe( "report name and version according to libidentify standard" )
|
||||||
|
.bind( &ConfigData::libIdentify );
|
||||||
|
|
||||||
|
cli["--wait-for-keypress"]
|
||||||
|
.describe( "waits for a keypress before exiting" )
|
||||||
|
.bind( &setWaitForKeypress, "start|exit|both" );
|
||||||
|
|
||||||
return cli;
|
return cli;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -61,14 +61,14 @@ namespace Catch {
|
|||||||
};
|
};
|
||||||
|
|
||||||
template<typename ContainerT>
|
template<typename ContainerT>
|
||||||
inline void deleteAll( ContainerT& container ) {
|
void deleteAll( ContainerT& container ) {
|
||||||
typename ContainerT::const_iterator it = container.begin();
|
typename ContainerT::const_iterator it = container.begin();
|
||||||
typename ContainerT::const_iterator itEnd = container.end();
|
typename ContainerT::const_iterator itEnd = container.end();
|
||||||
for(; it != itEnd; ++it )
|
for(; it != itEnd; ++it )
|
||||||
delete *it;
|
delete *it;
|
||||||
}
|
}
|
||||||
template<typename AssociativeContainerT>
|
template<typename AssociativeContainerT>
|
||||||
inline void deleteAllValues( AssociativeContainerT& container ) {
|
void deleteAllValues( AssociativeContainerT& container ) {
|
||||||
typename AssociativeContainerT::const_iterator it = container.begin();
|
typename AssociativeContainerT::const_iterator it = container.begin();
|
||||||
typename AssociativeContainerT::const_iterator itEnd = container.end();
|
typename AssociativeContainerT::const_iterator itEnd = container.end();
|
||||||
for(; it != itEnd; ++it )
|
for(; it != itEnd; ++it )
|
||||||
|
@@ -89,6 +89,10 @@
|
|||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#ifdef __OS400__
|
||||||
|
# define CATCH_INTERNAL_CONFIG_NO_POSIX_SIGNALS
|
||||||
|
# define CATCH_CONFIG_COLOUR_NONE
|
||||||
|
#endif
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
// Cygwin
|
// Cygwin
|
||||||
@@ -173,7 +177,12 @@
|
|||||||
( defined __GNUC__ && ( __GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 3 )) ) || \
|
( defined __GNUC__ && ( __GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 3 )) ) || \
|
||||||
( defined __clang__ && __clang_major__ >= 3 )
|
( defined __clang__ && __clang_major__ >= 3 )
|
||||||
|
|
||||||
#define CATCH_INTERNAL_CONFIG_COUNTER
|
// Use of __COUNTER__ is suppressed during code analysis in CLion/AppCode 2017.2.x and former,
|
||||||
|
// because __COUNTER__ is not properly handled by it.
|
||||||
|
// This does not affect compilation
|
||||||
|
#if ( !defined __JETBRAINS_IDE__ || __JETBRAINS_IDE__ >= 20170300L )
|
||||||
|
#define CATCH_INTERNAL_CONFIG_COUNTER
|
||||||
|
#endif
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@@ -254,10 +263,7 @@
|
|||||||
#if defined(CATCH_INTERNAL_CONFIG_CPP11_UNIQUE_PTR) && !defined(CATCH_CONFIG_CPP11_NO_UNIQUE_PTR) && !defined(CATCH_CONFIG_CPP11_UNIQUE_PTR) && !defined(CATCH_CONFIG_NO_CPP11)
|
#if defined(CATCH_INTERNAL_CONFIG_CPP11_UNIQUE_PTR) && !defined(CATCH_CONFIG_CPP11_NO_UNIQUE_PTR) && !defined(CATCH_CONFIG_CPP11_UNIQUE_PTR) && !defined(CATCH_CONFIG_NO_CPP11)
|
||||||
# define CATCH_CONFIG_CPP11_UNIQUE_PTR
|
# define CATCH_CONFIG_CPP11_UNIQUE_PTR
|
||||||
#endif
|
#endif
|
||||||
// Use of __COUNTER__ is suppressed if __JETBRAINS_IDE__ is #defined (meaning we're being parsed by a JetBrains IDE for
|
#if defined(CATCH_INTERNAL_CONFIG_COUNTER) && !defined(CATCH_CONFIG_NO_COUNTER) && !defined(CATCH_CONFIG_COUNTER)
|
||||||
// analytics) because, at time of writing, __COUNTER__ is not properly handled by it.
|
|
||||||
// This does not affect compilation
|
|
||||||
#if defined(CATCH_INTERNAL_CONFIG_COUNTER) && !defined(CATCH_CONFIG_NO_COUNTER) && !defined(CATCH_CONFIG_COUNTER) && !defined(__JETBRAINS_IDE__)
|
|
||||||
# define CATCH_CONFIG_COUNTER
|
# define CATCH_CONFIG_COUNTER
|
||||||
#endif
|
#endif
|
||||||
#if defined(CATCH_INTERNAL_CONFIG_CPP11_SHUFFLE) && !defined(CATCH_CONFIG_CPP11_NO_SHUFFLE) && !defined(CATCH_CONFIG_CPP11_SHUFFLE) && !defined(CATCH_CONFIG_NO_CPP11)
|
#if defined(CATCH_INTERNAL_CONFIG_CPP11_SHUFFLE) && !defined(CATCH_CONFIG_CPP11_NO_SHUFFLE) && !defined(CATCH_CONFIG_CPP11_SHUFFLE) && !defined(CATCH_CONFIG_NO_CPP11)
|
||||||
|
@@ -38,13 +38,15 @@ namespace Catch {
|
|||||||
showHelp( false ),
|
showHelp( false ),
|
||||||
showInvisibles( false ),
|
showInvisibles( false ),
|
||||||
filenamesAsTags( false ),
|
filenamesAsTags( false ),
|
||||||
|
libIdentify( false ),
|
||||||
abortAfter( -1 ),
|
abortAfter( -1 ),
|
||||||
rngSeed( 0 ),
|
rngSeed( 0 ),
|
||||||
verbosity( Verbosity::Normal ),
|
verbosity( Verbosity::Normal ),
|
||||||
warnings( WarnAbout::Nothing ),
|
warnings( WarnAbout::Nothing ),
|
||||||
showDurations( ShowDurations::DefaultForReporter ),
|
showDurations( ShowDurations::DefaultForReporter ),
|
||||||
runOrder( RunTests::InDeclarationOrder ),
|
runOrder( RunTests::InDeclarationOrder ),
|
||||||
useColour( UseColour::Auto )
|
useColour( UseColour::Auto ),
|
||||||
|
waitForKeypress( WaitForKeypress::Never )
|
||||||
{}
|
{}
|
||||||
|
|
||||||
bool listTests;
|
bool listTests;
|
||||||
@@ -59,6 +61,7 @@ namespace Catch {
|
|||||||
bool showHelp;
|
bool showHelp;
|
||||||
bool showInvisibles;
|
bool showInvisibles;
|
||||||
bool filenamesAsTags;
|
bool filenamesAsTags;
|
||||||
|
bool libIdentify;
|
||||||
|
|
||||||
int abortAfter;
|
int abortAfter;
|
||||||
unsigned int rngSeed;
|
unsigned int rngSeed;
|
||||||
@@ -68,6 +71,7 @@ namespace Catch {
|
|||||||
ShowDurations::OrNot showDurations;
|
ShowDurations::OrNot showDurations;
|
||||||
RunTests::InWhatOrder runOrder;
|
RunTests::InWhatOrder runOrder;
|
||||||
UseColour::YesOrNo useColour;
|
UseColour::YesOrNo useColour;
|
||||||
|
WaitForKeypress::When waitForKeypress;
|
||||||
|
|
||||||
std::string outputFilename;
|
std::string outputFilename;
|
||||||
std::string name;
|
std::string name;
|
||||||
|
@@ -26,9 +26,9 @@ namespace Catch{
|
|||||||
#if defined(__ppc64__) || defined(__ppc__)
|
#if defined(__ppc64__) || defined(__ppc__)
|
||||||
#define CATCH_TRAP() \
|
#define CATCH_TRAP() \
|
||||||
__asm__("li r0, 20\nsc\nnop\nli r0, 37\nli r4, 2\nsc\nnop\n" \
|
__asm__("li r0, 20\nsc\nnop\nli r0, 37\nli r4, 2\nsc\nnop\n" \
|
||||||
: : : "memory","r0","r3","r4" )
|
: : : "memory","r0","r3","r4" ) /* NOLINT */
|
||||||
#else
|
#else
|
||||||
#define CATCH_TRAP() __asm__("int $3\n" : : )
|
#define CATCH_TRAP() __asm__("int $3\n" : : /* NOLINT */ )
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#elif defined(CATCH_PLATFORM_LINUX)
|
#elif defined(CATCH_PLATFORM_LINUX)
|
||||||
@@ -36,7 +36,7 @@ namespace Catch{
|
|||||||
// directly at the location of the failing check instead of breaking inside
|
// directly at the location of the failing check instead of breaking inside
|
||||||
// raise() called from it, i.e. one stack frame below.
|
// raise() called from it, i.e. one stack frame below.
|
||||||
#if defined(__GNUC__) && (defined(__i386) || defined(__x86_64))
|
#if defined(__GNUC__) && (defined(__i386) || defined(__x86_64))
|
||||||
#define CATCH_TRAP() asm volatile ("int $3")
|
#define CATCH_TRAP() asm volatile ("int $3") /* NOLINT */
|
||||||
#else // Fall back to the generic way.
|
#else // Fall back to the generic way.
|
||||||
#include <signal.h>
|
#include <signal.h>
|
||||||
|
|
||||||
|
@@ -11,6 +11,7 @@
|
|||||||
#ifdef _MSC_VER
|
#ifdef _MSC_VER
|
||||||
#pragma warning(push)
|
#pragma warning(push)
|
||||||
#pragma warning(disable:4389) // '==' : signed/unsigned mismatch
|
#pragma warning(disable:4389) // '==' : signed/unsigned mismatch
|
||||||
|
#pragma warning(disable:4018) // more "signed/unsigned mismatch"
|
||||||
#pragma warning(disable:4312) // Converting int to T* using reinterpret_cast (issue on x64 platform)
|
#pragma warning(disable:4312) // Converting int to T* using reinterpret_cast (issue on x64 platform)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@@ -37,7 +38,7 @@ namespace Internal {
|
|||||||
template<> struct OperatorTraits<IsGreaterThanOrEqualTo>{ static const char* getName(){ return ">="; } };
|
template<> struct OperatorTraits<IsGreaterThanOrEqualTo>{ static const char* getName(){ return ">="; } };
|
||||||
|
|
||||||
template<typename T>
|
template<typename T>
|
||||||
inline T& opCast(T const& t) { return const_cast<T&>(t); }
|
T& opCast(T const& t) { return const_cast<T&>(t); }
|
||||||
|
|
||||||
// nullptr_t support based on pull request #154 from Konstantin Baumann
|
// nullptr_t support based on pull request #154 from Konstantin Baumann
|
||||||
#ifdef CATCH_CONFIG_CPP11_NULLPTR
|
#ifdef CATCH_CONFIG_CPP11_NULLPTR
|
||||||
@@ -48,7 +49,7 @@ namespace Internal {
|
|||||||
// So the compare overloads can be operator agnostic we convey the operator as a template
|
// So the compare overloads can be operator agnostic we convey the operator as a template
|
||||||
// enum, which is used to specialise an Evaluator for doing the comparison.
|
// enum, which is used to specialise an Evaluator for doing the comparison.
|
||||||
template<typename T1, typename T2, Operator Op>
|
template<typename T1, typename T2, Operator Op>
|
||||||
class Evaluator{};
|
struct Evaluator{};
|
||||||
|
|
||||||
template<typename T1, typename T2>
|
template<typename T1, typename T2>
|
||||||
struct Evaluator<T1, T2, IsEqualTo> {
|
struct Evaluator<T1, T2, IsEqualTo> {
|
||||||
|
@@ -41,6 +41,10 @@ namespace Catch {
|
|||||||
virtual void exceptionEarlyReported() = 0;
|
virtual void exceptionEarlyReported() = 0;
|
||||||
|
|
||||||
virtual void handleFatalErrorCondition( std::string const& message ) = 0;
|
virtual void handleFatalErrorCondition( std::string const& message ) = 0;
|
||||||
|
|
||||||
|
virtual bool lastAssertionPassed() = 0;
|
||||||
|
virtual void assertionPassed() = 0;
|
||||||
|
virtual void assertionRun() = 0;
|
||||||
};
|
};
|
||||||
|
|
||||||
IResultCapture& getResultCapture();
|
IResultCapture& getResultCapture();
|
||||||
|
@@ -42,6 +42,12 @@ namespace Catch {
|
|||||||
Yes,
|
Yes,
|
||||||
No
|
No
|
||||||
}; };
|
}; };
|
||||||
|
struct WaitForKeypress { enum When {
|
||||||
|
Never,
|
||||||
|
BeforeStart = 1,
|
||||||
|
BeforeExit = 2,
|
||||||
|
BeforeStartAndExit = BeforeStart | BeforeExit
|
||||||
|
}; };
|
||||||
|
|
||||||
class TestSpec;
|
class TestSpec;
|
||||||
|
|
||||||
|
@@ -147,23 +147,23 @@ namespace Matchers {
|
|||||||
// This allows the types to be inferred
|
// This allows the types to be inferred
|
||||||
// - deprecated: prefer ||, && and !
|
// - deprecated: prefer ||, && and !
|
||||||
template<typename T>
|
template<typename T>
|
||||||
inline Impl::MatchNotOf<T> Not( Impl::MatcherBase<T> const& underlyingMatcher ) {
|
Impl::MatchNotOf<T> Not( Impl::MatcherBase<T> const& underlyingMatcher ) {
|
||||||
return Impl::MatchNotOf<T>( underlyingMatcher );
|
return Impl::MatchNotOf<T>( underlyingMatcher );
|
||||||
}
|
}
|
||||||
template<typename T>
|
template<typename T>
|
||||||
inline Impl::MatchAllOf<T> AllOf( Impl::MatcherBase<T> const& m1, Impl::MatcherBase<T> const& m2 ) {
|
Impl::MatchAllOf<T> AllOf( Impl::MatcherBase<T> const& m1, Impl::MatcherBase<T> const& m2 ) {
|
||||||
return Impl::MatchAllOf<T>() && m1 && m2;
|
return Impl::MatchAllOf<T>() && m1 && m2;
|
||||||
}
|
}
|
||||||
template<typename T>
|
template<typename T>
|
||||||
inline Impl::MatchAllOf<T> AllOf( Impl::MatcherBase<T> const& m1, Impl::MatcherBase<T> const& m2, Impl::MatcherBase<T> const& m3 ) {
|
Impl::MatchAllOf<T> AllOf( Impl::MatcherBase<T> const& m1, Impl::MatcherBase<T> const& m2, Impl::MatcherBase<T> const& m3 ) {
|
||||||
return Impl::MatchAllOf<T>() && m1 && m2 && m3;
|
return Impl::MatchAllOf<T>() && m1 && m2 && m3;
|
||||||
}
|
}
|
||||||
template<typename T>
|
template<typename T>
|
||||||
inline Impl::MatchAnyOf<T> AnyOf( Impl::MatcherBase<T> const& m1, Impl::MatcherBase<T> const& m2 ) {
|
Impl::MatchAnyOf<T> AnyOf( Impl::MatcherBase<T> const& m1, Impl::MatcherBase<T> const& m2 ) {
|
||||||
return Impl::MatchAnyOf<T>() || m1 || m2;
|
return Impl::MatchAnyOf<T>() || m1 || m2;
|
||||||
}
|
}
|
||||||
template<typename T>
|
template<typename T>
|
||||||
inline Impl::MatchAnyOf<T> AnyOf( Impl::MatcherBase<T> const& m1, Impl::MatcherBase<T> const& m2, Impl::MatcherBase<T> const& m3 ) {
|
Impl::MatchAnyOf<T> AnyOf( Impl::MatcherBase<T> const& m1, Impl::MatcherBase<T> const& m2, Impl::MatcherBase<T> const& m3 ) {
|
||||||
return Impl::MatchAnyOf<T>() || m1 || m2 || m3;
|
return Impl::MatchAnyOf<T>() || m1 || m2 || m3;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -37,11 +37,18 @@ namespace Catch {
|
|||||||
: m_info( other.m_info )
|
: m_info( other.m_info )
|
||||||
{}
|
{}
|
||||||
|
|
||||||
|
#if defined(_MSC_VER)
|
||||||
|
#pragma warning(push)
|
||||||
|
#pragma warning(disable:4996) // std::uncaught_exception is deprecated in C++17
|
||||||
|
#endif
|
||||||
ScopedMessage::~ScopedMessage() {
|
ScopedMessage::~ScopedMessage() {
|
||||||
if ( !std::uncaught_exception() ){
|
if ( !std::uncaught_exception() ){
|
||||||
getResultCapture().popScopedMessage(m_info);
|
getResultCapture().popScopedMessage(m_info);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
#if defined(_MSC_VER)
|
||||||
|
#pragma warning(pop)
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
} // end namespace Catch
|
} // end namespace Catch
|
||||||
|
@@ -16,7 +16,6 @@ namespace Catch {
|
|||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
NotImplementedException( SourceLineInfo const& lineInfo );
|
NotImplementedException( SourceLineInfo const& lineInfo );
|
||||||
NotImplementedException( NotImplementedException const& ) {}
|
|
||||||
|
|
||||||
virtual ~NotImplementedException() CATCH_NOEXCEPT {}
|
virtual ~NotImplementedException() CATCH_NOEXCEPT {}
|
||||||
|
|
||||||
|
@@ -47,7 +47,7 @@ namespace Catch {
|
|||||||
|
|
||||||
template<typename T>
|
template<typename T>
|
||||||
ResultBuilder& operator << ( T const& value ) {
|
ResultBuilder& operator << ( T const& value ) {
|
||||||
m_stream().oss << value;
|
stream().oss << value;
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -81,6 +81,16 @@ namespace Catch {
|
|||||||
AssertionInfo m_assertionInfo;
|
AssertionInfo m_assertionInfo;
|
||||||
AssertionResultData m_data;
|
AssertionResultData m_data;
|
||||||
|
|
||||||
|
CopyableStream &stream()
|
||||||
|
{
|
||||||
|
if(!m_usedStream)
|
||||||
|
{
|
||||||
|
m_usedStream = true;
|
||||||
|
m_stream().oss.str("");
|
||||||
|
}
|
||||||
|
return m_stream();
|
||||||
|
}
|
||||||
|
|
||||||
static CopyableStream &m_stream()
|
static CopyableStream &m_stream()
|
||||||
{
|
{
|
||||||
static CopyableStream s;
|
static CopyableStream s;
|
||||||
@@ -90,6 +100,7 @@ namespace Catch {
|
|||||||
bool m_shouldDebugBreak;
|
bool m_shouldDebugBreak;
|
||||||
bool m_shouldThrow;
|
bool m_shouldThrow;
|
||||||
bool m_guardException;
|
bool m_guardException;
|
||||||
|
bool m_usedStream;
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace Catch
|
} // namespace Catch
|
||||||
@@ -100,7 +111,7 @@ namespace Catch {
|
|||||||
namespace Catch {
|
namespace Catch {
|
||||||
|
|
||||||
template<typename T>
|
template<typename T>
|
||||||
inline ExpressionLhs<T const&> ResultBuilder::operator <= ( T const& operand ) {
|
ExpressionLhs<T const&> ResultBuilder::operator <= ( T const& operand ) {
|
||||||
return ExpressionLhs<T const&>( *this, operand );
|
return ExpressionLhs<T const&>( *this, operand );
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -109,7 +120,7 @@ namespace Catch {
|
|||||||
}
|
}
|
||||||
|
|
||||||
template<typename ArgT, typename MatcherT>
|
template<typename ArgT, typename MatcherT>
|
||||||
inline void ResultBuilder::captureMatch( ArgT const& arg, MatcherT const& matcher,
|
void ResultBuilder::captureMatch( ArgT const& arg, MatcherT const& matcher,
|
||||||
char const* matcherString ) {
|
char const* matcherString ) {
|
||||||
MatchExpression<ArgT const&, MatcherT const&> expr( arg, matcher, matcherString );
|
MatchExpression<ArgT const&, MatcherT const&> expr( arg, matcher, matcherString );
|
||||||
setResultType( matcher.match( arg ) );
|
setResultType( matcher.match( arg ) );
|
||||||
|
@@ -26,15 +26,14 @@ namespace Catch {
|
|||||||
: m_assertionInfo( macroName, lineInfo, capturedExpression, resultDisposition, secondArg ),
|
: m_assertionInfo( macroName, lineInfo, capturedExpression, resultDisposition, secondArg ),
|
||||||
m_shouldDebugBreak( false ),
|
m_shouldDebugBreak( false ),
|
||||||
m_shouldThrow( false ),
|
m_shouldThrow( false ),
|
||||||
m_guardException( false )
|
m_guardException( false ),
|
||||||
{
|
m_usedStream( false )
|
||||||
m_stream().oss.str("");
|
{}
|
||||||
}
|
|
||||||
|
|
||||||
ResultBuilder::~ResultBuilder() {
|
ResultBuilder::~ResultBuilder() {
|
||||||
#if defined(CATCH_CONFIG_FAST_COMPILE)
|
#if defined(CATCH_CONFIG_FAST_COMPILE)
|
||||||
if ( m_guardException ) {
|
if ( m_guardException ) {
|
||||||
m_stream().oss << "Exception translation was disabled by CATCH_CONFIG_FAST_COMPILE";
|
stream().oss << "Exception translation was disabled by CATCH_CONFIG_FAST_COMPILE";
|
||||||
captureResult( ResultWas::ThrewException );
|
captureResult( ResultWas::ThrewException );
|
||||||
getCurrentContext().getResultCapture()->exceptionEarlyReported();
|
getCurrentContext().getResultCapture()->exceptionEarlyReported();
|
||||||
}
|
}
|
||||||
@@ -51,13 +50,25 @@ namespace Catch {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void ResultBuilder::endExpression( DecomposedExpression const& expr ) {
|
void ResultBuilder::endExpression( DecomposedExpression const& expr ) {
|
||||||
AssertionResult result = build( expr );
|
// Flip bool results if FalseTest flag is set
|
||||||
handleResult( result );
|
if( isFalseTest( m_assertionInfo.resultDisposition ) ) {
|
||||||
|
m_data.negate( expr.isBinaryExpression() );
|
||||||
|
}
|
||||||
|
|
||||||
|
getResultCapture().assertionRun();
|
||||||
|
|
||||||
|
if(getCurrentContext().getConfig()->includeSuccessfulResults() || m_data.resultType != ResultWas::Ok)
|
||||||
|
{
|
||||||
|
AssertionResult result = build( expr );
|
||||||
|
handleResult( result );
|
||||||
|
}
|
||||||
|
else
|
||||||
|
getResultCapture().assertionPassed();
|
||||||
}
|
}
|
||||||
|
|
||||||
void ResultBuilder::useActiveException( ResultDisposition::Flags resultDisposition ) {
|
void ResultBuilder::useActiveException( ResultDisposition::Flags resultDisposition ) {
|
||||||
m_assertionInfo.resultDisposition = resultDisposition;
|
m_assertionInfo.resultDisposition = resultDisposition;
|
||||||
m_stream().oss << Catch::translateActiveException();
|
stream().oss << Catch::translateActiveException();
|
||||||
captureResult( ResultWas::ThrewException );
|
captureResult( ResultWas::ThrewException );
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -140,12 +151,8 @@ namespace Catch {
|
|||||||
assert( m_data.resultType != ResultWas::Unknown );
|
assert( m_data.resultType != ResultWas::Unknown );
|
||||||
AssertionResultData data = m_data;
|
AssertionResultData data = m_data;
|
||||||
|
|
||||||
// Flip bool results if FalseTest flag is set
|
if(m_usedStream)
|
||||||
if( isFalseTest( m_assertionInfo.resultDisposition ) ) {
|
data.message = m_stream().oss.str();
|
||||||
data.negate( expr.isBinaryExpression() );
|
|
||||||
}
|
|
||||||
|
|
||||||
data.message = m_stream().oss.str();
|
|
||||||
data.decomposedExpression = &expr; // for lazy reconstruction
|
data.decomposedExpression = &expr; // for lazy reconstruction
|
||||||
return AssertionResult( m_assertionInfo, data );
|
return AssertionResult( m_assertionInfo, data );
|
||||||
}
|
}
|
||||||
|
@@ -22,6 +22,7 @@
|
|||||||
#include "catch_result_builder.h"
|
#include "catch_result_builder.h"
|
||||||
#include "catch_fatal_condition.hpp"
|
#include "catch_fatal_condition.hpp"
|
||||||
|
|
||||||
|
|
||||||
#include <set>
|
#include <set>
|
||||||
#include <string>
|
#include <string>
|
||||||
|
|
||||||
@@ -50,6 +51,29 @@ namespace Catch {
|
|||||||
std::string& m_targetString;
|
std::string& m_targetString;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
// StdErr has two constituent streams in C++, std::cerr and std::clog
|
||||||
|
// This means that we need to redirect 2 streams into 1 to keep proper
|
||||||
|
// order of writes and cannot use StreamRedirect on its own
|
||||||
|
class StdErrRedirect {
|
||||||
|
public:
|
||||||
|
StdErrRedirect(std::string& targetString)
|
||||||
|
:m_cerrBuf( cerr().rdbuf() ), m_clogBuf(clog().rdbuf()),
|
||||||
|
m_targetString(targetString){
|
||||||
|
cerr().rdbuf(m_oss.rdbuf());
|
||||||
|
clog().rdbuf(m_oss.rdbuf());
|
||||||
|
}
|
||||||
|
~StdErrRedirect() {
|
||||||
|
m_targetString += m_oss.str();
|
||||||
|
cerr().rdbuf(m_cerrBuf);
|
||||||
|
clog().rdbuf(m_clogBuf);
|
||||||
|
}
|
||||||
|
private:
|
||||||
|
std::streambuf* m_cerrBuf;
|
||||||
|
std::streambuf* m_clogBuf;
|
||||||
|
std::ostringstream m_oss;
|
||||||
|
std::string& m_targetString;
|
||||||
|
};
|
||||||
|
|
||||||
///////////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
class RunContext : public IResultCapture, public IRunner {
|
class RunContext : public IResultCapture, public IRunner {
|
||||||
@@ -142,7 +166,10 @@ namespace Catch {
|
|||||||
m_totals.assertions.passed++;
|
m_totals.assertions.passed++;
|
||||||
}
|
}
|
||||||
else if( !result.isOk() ) {
|
else if( !result.isOk() ) {
|
||||||
m_totals.assertions.failed++;
|
if( m_activeTestCase->getTestCaseInfo().okToFail() )
|
||||||
|
m_totals.assertions.failedButOk++;
|
||||||
|
else
|
||||||
|
m_totals.assertions.failed++;
|
||||||
}
|
}
|
||||||
|
|
||||||
// We have no use for the return value (whether messages should be cleared), because messages were made scoped
|
// We have no use for the return value (whether messages should be cleared), because messages were made scoped
|
||||||
@@ -154,6 +181,23 @@ namespace Catch {
|
|||||||
m_lastResult = result;
|
m_lastResult = result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
virtual bool lastAssertionPassed()
|
||||||
|
{
|
||||||
|
return m_totals.assertions.passed == (m_prevPassed + 1);
|
||||||
|
}
|
||||||
|
|
||||||
|
virtual void assertionPassed()
|
||||||
|
{
|
||||||
|
m_totals.assertions.passed++;
|
||||||
|
m_lastAssertionInfo.capturedExpression = "{Unknown expression after the reported line}";
|
||||||
|
m_lastAssertionInfo.macroName = "";
|
||||||
|
}
|
||||||
|
|
||||||
|
virtual void assertionRun()
|
||||||
|
{
|
||||||
|
m_prevPassed = m_totals.assertions.passed;
|
||||||
|
}
|
||||||
|
|
||||||
virtual bool sectionStarted (
|
virtual bool sectionStarted (
|
||||||
SectionInfo const& sectionInfo,
|
SectionInfo const& sectionInfo,
|
||||||
Counts& assertions
|
Counts& assertions
|
||||||
@@ -254,6 +298,7 @@ namespace Catch {
|
|||||||
|
|
||||||
Totals deltaTotals;
|
Totals deltaTotals;
|
||||||
deltaTotals.testCases.failed = 1;
|
deltaTotals.testCases.failed = 1;
|
||||||
|
deltaTotals.assertions.failed = 1;
|
||||||
m_reporter->testCaseEnded( TestCaseStats( testInfo,
|
m_reporter->testCaseEnded( TestCaseStats( testInfo,
|
||||||
deltaTotals,
|
deltaTotals,
|
||||||
std::string(),
|
std::string(),
|
||||||
@@ -288,7 +333,7 @@ namespace Catch {
|
|||||||
timer.start();
|
timer.start();
|
||||||
if( m_reporter->getPreferences().shouldRedirectStdOut ) {
|
if( m_reporter->getPreferences().shouldRedirectStdOut ) {
|
||||||
StreamRedirect coutRedir( Catch::cout(), redirectedCout );
|
StreamRedirect coutRedir( Catch::cout(), redirectedCout );
|
||||||
StreamRedirect cerrRedir( Catch::cerr(), redirectedCerr );
|
StdErrRedirect errRedir( redirectedCerr );
|
||||||
invokeActiveTestCase();
|
invokeActiveTestCase();
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
@@ -313,12 +358,6 @@ namespace Catch {
|
|||||||
Counts assertions = m_totals.assertions - prevAssertions;
|
Counts assertions = m_totals.assertions - prevAssertions;
|
||||||
bool missingAssertions = testForMissingAssertions( assertions );
|
bool missingAssertions = testForMissingAssertions( assertions );
|
||||||
|
|
||||||
if( testCaseInfo.okToFail() ) {
|
|
||||||
std::swap( assertions.failedButOk, assertions.failed );
|
|
||||||
m_totals.assertions.failed -= assertions.failedButOk;
|
|
||||||
m_totals.assertions.failedButOk += assertions.failedButOk;
|
|
||||||
}
|
|
||||||
|
|
||||||
SectionStats testCaseSectionStats( testCaseSection, assertions, duration, missingAssertions );
|
SectionStats testCaseSectionStats( testCaseSection, assertions, duration, missingAssertions );
|
||||||
m_reporter->sectionEnded( testCaseSectionStats );
|
m_reporter->sectionEnded( testCaseSectionStats );
|
||||||
}
|
}
|
||||||
@@ -364,6 +403,7 @@ namespace Catch {
|
|||||||
std::vector<SectionEndInfo> m_unfinishedSections;
|
std::vector<SectionEndInfo> m_unfinishedSections;
|
||||||
std::vector<ITracker*> m_activeSections;
|
std::vector<ITracker*> m_activeSections;
|
||||||
TrackerContext m_trackerContext;
|
TrackerContext m_trackerContext;
|
||||||
|
size_t m_prevPassed;
|
||||||
bool m_shouldReportUnexpected;
|
bool m_shouldReportUnexpected;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@@ -21,6 +21,7 @@ namespace Catch {
|
|||||||
|
|
||||||
std::ostream& cout();
|
std::ostream& cout();
|
||||||
std::ostream& cerr();
|
std::ostream& cerr();
|
||||||
|
std::ostream& clog();
|
||||||
|
|
||||||
|
|
||||||
struct IStream {
|
struct IStream {
|
||||||
|
@@ -103,6 +103,9 @@ namespace Catch {
|
|||||||
std::ostream& cerr() {
|
std::ostream& cerr() {
|
||||||
return std::cerr;
|
return std::cerr;
|
||||||
}
|
}
|
||||||
|
std::ostream& clog() {
|
||||||
|
return std::clog;
|
||||||
|
}
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -22,14 +22,14 @@
|
|||||||
namespace Catch {
|
namespace Catch {
|
||||||
|
|
||||||
struct RandomNumberGenerator {
|
struct RandomNumberGenerator {
|
||||||
typedef std::ptrdiff_t result_type;
|
typedef unsigned int result_type;
|
||||||
|
|
||||||
result_type operator()( result_type n ) const { return std::rand() % n; }
|
result_type operator()( result_type n ) const { return std::rand() % n; }
|
||||||
|
|
||||||
#ifdef CATCH_CONFIG_CPP11_SHUFFLE
|
#ifdef CATCH_CONFIG_CPP11_SHUFFLE
|
||||||
static constexpr result_type min() { return 0; }
|
static constexpr result_type (min)() { return 0; }
|
||||||
static constexpr result_type max() { return 1000000; }
|
static constexpr result_type (max)() { return 1000000; }
|
||||||
result_type operator()() const { return std::rand() % max(); }
|
result_type operator()() const { return std::rand() % (max)(); }
|
||||||
#endif
|
#endif
|
||||||
template<typename V>
|
template<typename V>
|
||||||
static void shuffle( V& vector ) {
|
static void shuffle( V& vector ) {
|
||||||
|
@@ -88,7 +88,7 @@ void registerTestCaseFunction
|
|||||||
#define INTERNAL_CATCH_TESTCASE2( TestName, ... ) \
|
#define INTERNAL_CATCH_TESTCASE2( TestName, ... ) \
|
||||||
static void TestName(); \
|
static void TestName(); \
|
||||||
CATCH_INTERNAL_SUPPRESS_ETD_WARNINGS \
|
CATCH_INTERNAL_SUPPRESS_ETD_WARNINGS \
|
||||||
namespace{ Catch::AutoReg INTERNAL_CATCH_UNIQUE_NAME( autoRegistrar )( &TestName, CATCH_INTERNAL_LINEINFO, Catch::NameAndDesc( __VA_ARGS__ ) ); } \
|
namespace{ Catch::AutoReg INTERNAL_CATCH_UNIQUE_NAME( autoRegistrar )( &TestName, CATCH_INTERNAL_LINEINFO, Catch::NameAndDesc( __VA_ARGS__ ) ); } /* NOLINT */ \
|
||||||
CATCH_INTERNAL_UNSUPPRESS_ETD_WARNINGS \
|
CATCH_INTERNAL_UNSUPPRESS_ETD_WARNINGS \
|
||||||
static void TestName()
|
static void TestName()
|
||||||
#define INTERNAL_CATCH_TESTCASE( ... ) \
|
#define INTERNAL_CATCH_TESTCASE( ... ) \
|
||||||
@@ -97,7 +97,7 @@ void registerTestCaseFunction
|
|||||||
///////////////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////////////
|
||||||
#define INTERNAL_CATCH_METHOD_AS_TEST_CASE( QualifiedMethod, ... ) \
|
#define INTERNAL_CATCH_METHOD_AS_TEST_CASE( QualifiedMethod, ... ) \
|
||||||
CATCH_INTERNAL_SUPPRESS_ETD_WARNINGS \
|
CATCH_INTERNAL_SUPPRESS_ETD_WARNINGS \
|
||||||
namespace{ Catch::AutoReg INTERNAL_CATCH_UNIQUE_NAME( autoRegistrar )( &QualifiedMethod, "&" #QualifiedMethod, Catch::NameAndDesc( __VA_ARGS__ ), CATCH_INTERNAL_LINEINFO ); } \
|
namespace{ Catch::AutoReg INTERNAL_CATCH_UNIQUE_NAME( autoRegistrar )( &QualifiedMethod, "&" #QualifiedMethod, Catch::NameAndDesc( __VA_ARGS__ ), CATCH_INTERNAL_LINEINFO ); } /* NOLINT */ \
|
||||||
CATCH_INTERNAL_UNSUPPRESS_ETD_WARNINGS
|
CATCH_INTERNAL_UNSUPPRESS_ETD_WARNINGS
|
||||||
|
|
||||||
///////////////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////////////
|
||||||
@@ -107,7 +107,7 @@ void registerTestCaseFunction
|
|||||||
struct TestName : ClassName{ \
|
struct TestName : ClassName{ \
|
||||||
void test(); \
|
void test(); \
|
||||||
}; \
|
}; \
|
||||||
Catch::AutoReg INTERNAL_CATCH_UNIQUE_NAME( autoRegistrar ) ( &TestName::test, #ClassName, Catch::NameAndDesc( __VA_ARGS__ ), CATCH_INTERNAL_LINEINFO ); \
|
Catch::AutoReg INTERNAL_CATCH_UNIQUE_NAME( autoRegistrar ) ( &TestName::test, #ClassName, Catch::NameAndDesc( __VA_ARGS__ ), CATCH_INTERNAL_LINEINFO ); /* NOLINT */ \
|
||||||
} \
|
} \
|
||||||
CATCH_INTERNAL_UNSUPPRESS_ETD_WARNINGS \
|
CATCH_INTERNAL_UNSUPPRESS_ETD_WARNINGS \
|
||||||
void TestName::test()
|
void TestName::test()
|
||||||
@@ -117,7 +117,7 @@ void registerTestCaseFunction
|
|||||||
///////////////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////////////
|
||||||
#define INTERNAL_CATCH_REGISTER_TESTCASE( Function, ... ) \
|
#define INTERNAL_CATCH_REGISTER_TESTCASE( Function, ... ) \
|
||||||
CATCH_INTERNAL_SUPPRESS_ETD_WARNINGS \
|
CATCH_INTERNAL_SUPPRESS_ETD_WARNINGS \
|
||||||
Catch::AutoReg( Function, CATCH_INTERNAL_LINEINFO, Catch::NameAndDesc( __VA_ARGS__ ) ); \
|
Catch::AutoReg( Function, CATCH_INTERNAL_LINEINFO, Catch::NameAndDesc( __VA_ARGS__ ) ); /* NOLINT */ \
|
||||||
CATCH_INTERNAL_UNSUPPRESS_ETD_WARNINGS
|
CATCH_INTERNAL_UNSUPPRESS_ETD_WARNINGS
|
||||||
|
|
||||||
#else
|
#else
|
||||||
@@ -125,7 +125,7 @@ void registerTestCaseFunction
|
|||||||
#define INTERNAL_CATCH_TESTCASE2( TestName, Name, Desc ) \
|
#define INTERNAL_CATCH_TESTCASE2( TestName, Name, Desc ) \
|
||||||
static void TestName(); \
|
static void TestName(); \
|
||||||
CATCH_INTERNAL_SUPPRESS_ETD_WARNINGS \
|
CATCH_INTERNAL_SUPPRESS_ETD_WARNINGS \
|
||||||
namespace{ Catch::AutoReg INTERNAL_CATCH_UNIQUE_NAME( autoRegistrar )( &TestName, CATCH_INTERNAL_LINEINFO, Catch::NameAndDesc( Name, Desc ) ); }\
|
namespace{ Catch::AutoReg INTERNAL_CATCH_UNIQUE_NAME( autoRegistrar )( &TestName, CATCH_INTERNAL_LINEINFO, Catch::NameAndDesc( Name, Desc ) ); } /* NOLINT */ \
|
||||||
CATCH_INTERNAL_UNSUPPRESS_ETD_WARNINGS \
|
CATCH_INTERNAL_UNSUPPRESS_ETD_WARNINGS \
|
||||||
static void TestName()
|
static void TestName()
|
||||||
#define INTERNAL_CATCH_TESTCASE( Name, Desc ) \
|
#define INTERNAL_CATCH_TESTCASE( Name, Desc ) \
|
||||||
@@ -134,7 +134,7 @@ void registerTestCaseFunction
|
|||||||
///////////////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////////////
|
||||||
#define INTERNAL_CATCH_METHOD_AS_TEST_CASE( QualifiedMethod, Name, Desc ) \
|
#define INTERNAL_CATCH_METHOD_AS_TEST_CASE( QualifiedMethod, Name, Desc ) \
|
||||||
CATCH_INTERNAL_SUPPRESS_ETD_WARNINGS \
|
CATCH_INTERNAL_SUPPRESS_ETD_WARNINGS \
|
||||||
namespace{ Catch::AutoReg INTERNAL_CATCH_UNIQUE_NAME( autoRegistrar )( &QualifiedMethod, "&" #QualifiedMethod, Catch::NameAndDesc( Name, Desc ), CATCH_INTERNAL_LINEINFO ); } \
|
namespace{ Catch::AutoReg INTERNAL_CATCH_UNIQUE_NAME( autoRegistrar )( &QualifiedMethod, "&" #QualifiedMethod, Catch::NameAndDesc( Name, Desc ), CATCH_INTERNAL_LINEINFO ); } /* NOLINT */ \
|
||||||
CATCH_INTERNAL_UNSUPPRESS_ETD_WARNINGS
|
CATCH_INTERNAL_UNSUPPRESS_ETD_WARNINGS
|
||||||
|
|
||||||
///////////////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////////////
|
||||||
@@ -144,7 +144,7 @@ void registerTestCaseFunction
|
|||||||
struct TestCaseName : ClassName{ \
|
struct TestCaseName : ClassName{ \
|
||||||
void test(); \
|
void test(); \
|
||||||
}; \
|
}; \
|
||||||
Catch::AutoReg INTERNAL_CATCH_UNIQUE_NAME( autoRegistrar ) ( &TestCaseName::test, #ClassName, Catch::NameAndDesc( TestName, Desc ), CATCH_INTERNAL_LINEINFO ); \
|
Catch::AutoReg INTERNAL_CATCH_UNIQUE_NAME( autoRegistrar ) ( &TestCaseName::test, #ClassName, Catch::NameAndDesc( TestName, Desc ), CATCH_INTERNAL_LINEINFO ); /* NOLINT */ \
|
||||||
} \
|
} \
|
||||||
CATCH_INTERNAL_UNSUPPRESS_ETD_WARNINGS \
|
CATCH_INTERNAL_UNSUPPRESS_ETD_WARNINGS \
|
||||||
void TestCaseName::test()
|
void TestCaseName::test()
|
||||||
@@ -154,7 +154,7 @@ void registerTestCaseFunction
|
|||||||
///////////////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////////////
|
||||||
#define INTERNAL_CATCH_REGISTER_TESTCASE( Function, Name, Desc ) \
|
#define INTERNAL_CATCH_REGISTER_TESTCASE( Function, Name, Desc ) \
|
||||||
CATCH_INTERNAL_SUPPRESS_ETD_WARNINGS \
|
CATCH_INTERNAL_SUPPRESS_ETD_WARNINGS \
|
||||||
Catch::AutoReg( Function, CATCH_INTERNAL_LINEINFO, Catch::NameAndDesc( Name, Desc ) ); \
|
Catch::AutoReg( Function, CATCH_INTERNAL_LINEINFO, Catch::NameAndDesc( Name, Desc ) ); /* NOLINT */ \
|
||||||
CATCH_INTERNAL_UNSUPPRESS_ETD_WARNINGS
|
CATCH_INTERNAL_UNSUPPRESS_ETD_WARNINGS
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
@@ -30,7 +30,7 @@ namespace Catch {
|
|||||||
ITagAliasRegistry const* m_tagAliases;
|
ITagAliasRegistry const* m_tagAliases;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
TestSpecParser( ITagAliasRegistry const& tagAliases ) : m_tagAliases( &tagAliases ) {}
|
TestSpecParser( ITagAliasRegistry const& tagAliases ) :m_mode(None), m_exclusion(false), m_start(0), m_pos(0), m_tagAliases( &tagAliases ) {}
|
||||||
|
|
||||||
TestSpecParser& parse( std::string const& arg ) {
|
TestSpecParser& parse( std::string const& arg ) {
|
||||||
m_mode = None;
|
m_mode = None;
|
||||||
|
@@ -153,7 +153,7 @@ namespace Detail {
|
|||||||
std::string rawMemoryToString( const void *object, std::size_t size );
|
std::string rawMemoryToString( const void *object, std::size_t size );
|
||||||
|
|
||||||
template<typename T>
|
template<typename T>
|
||||||
inline std::string rawMemoryToString( const T& object ) {
|
std::string rawMemoryToString( const T& object ) {
|
||||||
return rawMemoryToString( &object, sizeof(object) );
|
return rawMemoryToString( &object, sizeof(object) );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -38,7 +38,7 @@ namespace Catch {
|
|||||||
}
|
}
|
||||||
|
|
||||||
inline Version libraryVersion() {
|
inline Version libraryVersion() {
|
||||||
static Version version( 1, 9, 6, "", 0 );
|
static Version version( 1, 12, 1, "", 0 );
|
||||||
return version;
|
return version;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -137,7 +137,8 @@ namespace Catch {
|
|||||||
BySectionInfo( SectionInfo const& other ) : m_other( other ) {}
|
BySectionInfo( SectionInfo const& other ) : m_other( other ) {}
|
||||||
BySectionInfo( BySectionInfo const& other ) : m_other( other.m_other ) {}
|
BySectionInfo( BySectionInfo const& other ) : m_other( other.m_other ) {}
|
||||||
bool operator() ( Ptr<SectionNode> const& node ) const {
|
bool operator() ( Ptr<SectionNode> const& node ) const {
|
||||||
return node->stats.sectionInfo.lineInfo == m_other.lineInfo;
|
return ((node->stats.sectionInfo.name == m_other.name) &&
|
||||||
|
(node->stats.sectionInfo.lineInfo == m_other.lineInfo));
|
||||||
}
|
}
|
||||||
private:
|
private:
|
||||||
void operator=( BySectionInfo const& );
|
void operator=( BySectionInfo const& );
|
||||||
|
@@ -52,6 +52,7 @@ namespace Catch {
|
|||||||
JunitReporter( ReporterConfig const& _config )
|
JunitReporter( ReporterConfig const& _config )
|
||||||
: CumulativeReporterBase( _config ),
|
: CumulativeReporterBase( _config ),
|
||||||
xml( _config.stream() ),
|
xml( _config.stream() ),
|
||||||
|
unexpectedExceptions( 0 ),
|
||||||
m_okToFail( false )
|
m_okToFail( false )
|
||||||
{
|
{
|
||||||
m_reporterPrefs.shouldRedirectStdOut = true;
|
m_reporterPrefs.shouldRedirectStdOut = true;
|
||||||
|
@@ -141,6 +141,7 @@ namespace Catch {
|
|||||||
<< "]\n";
|
<< "]\n";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
stream.flush();
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -154,6 +155,7 @@ namespace Catch {
|
|||||||
StreamingReporterBase::testCaseStarting( testInfo );
|
StreamingReporterBase::testCaseStarting( testInfo );
|
||||||
stream << "##teamcity[testStarted name='"
|
stream << "##teamcity[testStarted name='"
|
||||||
<< escape( testInfo.name ) << "']\n";
|
<< escape( testInfo.name ) << "']\n";
|
||||||
|
stream.flush();
|
||||||
}
|
}
|
||||||
|
|
||||||
virtual void testCaseEnded( TestCaseStats const& testCaseStats ) CATCH_OVERRIDE {
|
virtual void testCaseEnded( TestCaseStats const& testCaseStats ) CATCH_OVERRIDE {
|
||||||
@@ -169,6 +171,7 @@ namespace Catch {
|
|||||||
stream << "##teamcity[testFinished name='"
|
stream << "##teamcity[testFinished name='"
|
||||||
<< escape( testCaseStats.testInfo.name ) << "' duration='"
|
<< escape( testCaseStats.testInfo.name ) << "' duration='"
|
||||||
<< m_testTimer.getElapsedMilliseconds() << "']\n";
|
<< m_testTimer.getElapsedMilliseconds() << "']\n";
|
||||||
|
stream.flush();
|
||||||
}
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
@@ -97,12 +97,12 @@ namespace Catch {
|
|||||||
|
|
||||||
bool includeResults = m_config->includeSuccessfulResults() || !result.isOk();
|
bool includeResults = m_config->includeSuccessfulResults() || !result.isOk();
|
||||||
|
|
||||||
if( includeResults ) {
|
if( includeResults || result.getResultType() == ResultWas::Warning ) {
|
||||||
// Print any info messages in <Info> tags.
|
// Print any info messages in <Info> tags.
|
||||||
for( std::vector<MessageInfo>::const_iterator it = assertionStats.infoMessages.begin(), itEnd = assertionStats.infoMessages.end();
|
for( std::vector<MessageInfo>::const_iterator it = assertionStats.infoMessages.begin(), itEnd = assertionStats.infoMessages.end();
|
||||||
it != itEnd;
|
it != itEnd;
|
||||||
++it ) {
|
++it ) {
|
||||||
if( it->type == ResultWas::Info ) {
|
if( it->type == ResultWas::Info && includeResults ) {
|
||||||
m_xml.scopedElement( "Info" )
|
m_xml.scopedElement( "Info" )
|
||||||
.writeText( it->message );
|
.writeText( it->message );
|
||||||
} else if ( it->type == ResultWas::Warning ) {
|
} else if ( it->type == ResultWas::Warning ) {
|
||||||
|
@@ -24,6 +24,8 @@ TEST_CASE
|
|||||||
REQUIRE( Approx( d ) == 1.23 );
|
REQUIRE( Approx( d ) == 1.23 );
|
||||||
REQUIRE( Approx( d ) != 1.22 );
|
REQUIRE( Approx( d ) != 1.22 );
|
||||||
REQUIRE( Approx( d ) != 1.24 );
|
REQUIRE( Approx( d ) != 1.24 );
|
||||||
|
|
||||||
|
REQUIRE( 0 == Approx(0) );
|
||||||
}
|
}
|
||||||
|
|
||||||
///////////////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////////////
|
||||||
@@ -146,11 +148,22 @@ TEST_CASE( "Approximate PI", "[Approx][PI]" )
|
|||||||
TEST_CASE( "Absolute margin", "[Approx]" ) {
|
TEST_CASE( "Absolute margin", "[Approx]" ) {
|
||||||
REQUIRE( 104.0 != Approx(100.0) );
|
REQUIRE( 104.0 != Approx(100.0) );
|
||||||
REQUIRE( 104.0 == Approx(100.0).margin(5) );
|
REQUIRE( 104.0 == Approx(100.0).margin(5) );
|
||||||
|
REQUIRE( 104.0 == Approx(100.0).margin(4) );
|
||||||
REQUIRE( 104.0 != Approx(100.0).margin(3) );
|
REQUIRE( 104.0 != Approx(100.0).margin(3) );
|
||||||
REQUIRE( 100.3 != Approx(100.0) );
|
REQUIRE( 100.3 != Approx(100.0) );
|
||||||
REQUIRE( 100.3 == Approx(100.0).margin(0.5) );
|
REQUIRE( 100.3 == Approx(100.0).margin(0.5) );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
TEST_CASE("Approx with exactly-representable margin", "[Approx]") {
|
||||||
|
CHECK( 0.25f == Approx(0.0f).margin(0.25f) );
|
||||||
|
|
||||||
|
CHECK( 0.0f == Approx(0.25f).margin(0.25f) );
|
||||||
|
CHECK( 0.5f == Approx(0.25f).margin(0.25f) );
|
||||||
|
|
||||||
|
CHECK( 245.0f == Approx(245.25f).margin(0.25f) );
|
||||||
|
CHECK( 245.5f == Approx(245.25f).margin(0.25f) );
|
||||||
|
}
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
#if defined(CATCH_CONFIG_CPP11_TYPE_TRAITS)
|
#if defined(CATCH_CONFIG_CPP11_TYPE_TRAITS)
|
||||||
|
@@ -58,6 +58,8 @@ with expansion:
|
|||||||
|
|
||||||
ConditionTests.cpp:<line number>: FAILED:
|
ConditionTests.cpp:<line number>: FAILED:
|
||||||
CHECK_FALSE( true )
|
CHECK_FALSE( true )
|
||||||
|
with expansion:
|
||||||
|
!true
|
||||||
|
|
||||||
ConditionTests.cpp:<line number>: FAILED:
|
ConditionTests.cpp:<line number>: FAILED:
|
||||||
CHECK( !trueValue )
|
CHECK( !trueValue )
|
||||||
@@ -76,8 +78,6 @@ with expansion:
|
|||||||
|
|
||||||
ConditionTests.cpp:<line number>: FAILED:
|
ConditionTests.cpp:<line number>: FAILED:
|
||||||
CHECK_FALSE( 1 == 1 )
|
CHECK_FALSE( 1 == 1 )
|
||||||
with expansion:
|
|
||||||
!(1 == 1)
|
|
||||||
|
|
||||||
-------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------
|
||||||
A METHOD_AS_TEST_CASE based test run that fails
|
A METHOD_AS_TEST_CASE based test run that fails
|
||||||
@@ -622,6 +622,9 @@ with messages:
|
|||||||
|
|
||||||
A string sent directly to stdout
|
A string sent directly to stdout
|
||||||
A string sent directly to stderr
|
A string sent directly to stderr
|
||||||
|
Write to std::cerr
|
||||||
|
Write to std::clog
|
||||||
|
Interleaved writes to error streams
|
||||||
Message from section one
|
Message from section one
|
||||||
Message from section two
|
Message from section two
|
||||||
-------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------
|
||||||
@@ -953,6 +956,6 @@ with expansion:
|
|||||||
"first" == "second"
|
"first" == "second"
|
||||||
|
|
||||||
===============================================================================
|
===============================================================================
|
||||||
test cases: 168 | 119 passed | 45 failed | 4 failed as expected
|
test cases: 171 | 122 passed | 45 failed | 4 failed as expected
|
||||||
assertions: 968 | 859 passed | 88 failed | 21 failed as expected
|
assertions: 980 | 871 passed | 88 failed | 21 failed as expected
|
||||||
|
|
||||||
|
@@ -123,6 +123,66 @@ PASSED:
|
|||||||
with expansion:
|
with expansion:
|
||||||
1 == 1
|
1 == 1
|
||||||
|
|
||||||
|
-------------------------------------------------------------------------------
|
||||||
|
#961 -- Dynamically created sections should all be reported
|
||||||
|
Looped section 0
|
||||||
|
-------------------------------------------------------------------------------
|
||||||
|
MiscTests.cpp:<line number>
|
||||||
|
...............................................................................
|
||||||
|
|
||||||
|
MiscTests.cpp:<line number>:
|
||||||
|
PASSED:
|
||||||
|
with message:
|
||||||
|
Everything is OK
|
||||||
|
|
||||||
|
-------------------------------------------------------------------------------
|
||||||
|
#961 -- Dynamically created sections should all be reported
|
||||||
|
Looped section 1
|
||||||
|
-------------------------------------------------------------------------------
|
||||||
|
MiscTests.cpp:<line number>
|
||||||
|
...............................................................................
|
||||||
|
|
||||||
|
MiscTests.cpp:<line number>:
|
||||||
|
PASSED:
|
||||||
|
with message:
|
||||||
|
Everything is OK
|
||||||
|
|
||||||
|
-------------------------------------------------------------------------------
|
||||||
|
#961 -- Dynamically created sections should all be reported
|
||||||
|
Looped section 2
|
||||||
|
-------------------------------------------------------------------------------
|
||||||
|
MiscTests.cpp:<line number>
|
||||||
|
...............................................................................
|
||||||
|
|
||||||
|
MiscTests.cpp:<line number>:
|
||||||
|
PASSED:
|
||||||
|
with message:
|
||||||
|
Everything is OK
|
||||||
|
|
||||||
|
-------------------------------------------------------------------------------
|
||||||
|
#961 -- Dynamically created sections should all be reported
|
||||||
|
Looped section 3
|
||||||
|
-------------------------------------------------------------------------------
|
||||||
|
MiscTests.cpp:<line number>
|
||||||
|
...............................................................................
|
||||||
|
|
||||||
|
MiscTests.cpp:<line number>:
|
||||||
|
PASSED:
|
||||||
|
with message:
|
||||||
|
Everything is OK
|
||||||
|
|
||||||
|
-------------------------------------------------------------------------------
|
||||||
|
#961 -- Dynamically created sections should all be reported
|
||||||
|
Looped section 4
|
||||||
|
-------------------------------------------------------------------------------
|
||||||
|
MiscTests.cpp:<line number>
|
||||||
|
...............................................................................
|
||||||
|
|
||||||
|
MiscTests.cpp:<line number>:
|
||||||
|
PASSED:
|
||||||
|
with message:
|
||||||
|
Everything is OK
|
||||||
|
|
||||||
-------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------
|
||||||
'Not' checks that should fail
|
'Not' checks that should fail
|
||||||
-------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------
|
||||||
@@ -142,6 +202,8 @@ with expansion:
|
|||||||
|
|
||||||
ConditionTests.cpp:<line number>: FAILED:
|
ConditionTests.cpp:<line number>: FAILED:
|
||||||
CHECK_FALSE( true )
|
CHECK_FALSE( true )
|
||||||
|
with expansion:
|
||||||
|
!true
|
||||||
|
|
||||||
ConditionTests.cpp:<line number>: FAILED:
|
ConditionTests.cpp:<line number>: FAILED:
|
||||||
CHECK( !trueValue )
|
CHECK( !trueValue )
|
||||||
@@ -160,8 +222,6 @@ with expansion:
|
|||||||
|
|
||||||
ConditionTests.cpp:<line number>: FAILED:
|
ConditionTests.cpp:<line number>: FAILED:
|
||||||
CHECK_FALSE( 1 == 1 )
|
CHECK_FALSE( 1 == 1 )
|
||||||
with expansion:
|
|
||||||
!(1 == 1)
|
|
||||||
|
|
||||||
-------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------
|
||||||
'Not' checks that should succeed
|
'Not' checks that should succeed
|
||||||
@@ -186,6 +246,8 @@ with expansion:
|
|||||||
ConditionTests.cpp:<line number>:
|
ConditionTests.cpp:<line number>:
|
||||||
PASSED:
|
PASSED:
|
||||||
REQUIRE_FALSE( false )
|
REQUIRE_FALSE( false )
|
||||||
|
with expansion:
|
||||||
|
!false
|
||||||
|
|
||||||
ConditionTests.cpp:<line number>:
|
ConditionTests.cpp:<line number>:
|
||||||
PASSED:
|
PASSED:
|
||||||
@@ -208,8 +270,6 @@ with expansion:
|
|||||||
ConditionTests.cpp:<line number>:
|
ConditionTests.cpp:<line number>:
|
||||||
PASSED:
|
PASSED:
|
||||||
REQUIRE_FALSE( 1 == 2 )
|
REQUIRE_FALSE( 1 == 2 )
|
||||||
with expansion:
|
|
||||||
!(1 == 2)
|
|
||||||
|
|
||||||
-------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------
|
||||||
(unimplemented) static bools can be evaluated
|
(unimplemented) static bools can be evaluated
|
||||||
@@ -397,6 +457,12 @@ PASSED:
|
|||||||
with expansion:
|
with expansion:
|
||||||
104.0 == Approx( 100.0 )
|
104.0 == Approx( 100.0 )
|
||||||
|
|
||||||
|
ApproxTests.cpp:<line number>:
|
||||||
|
PASSED:
|
||||||
|
REQUIRE( 104.0 == Approx(100.0).margin(4) )
|
||||||
|
with expansion:
|
||||||
|
104.0 == Approx( 100.0 )
|
||||||
|
|
||||||
ApproxTests.cpp:<line number>:
|
ApproxTests.cpp:<line number>:
|
||||||
PASSED:
|
PASSED:
|
||||||
REQUIRE( 104.0 != Approx(100.0).margin(3) )
|
REQUIRE( 104.0 != Approx(100.0).margin(3) )
|
||||||
@@ -492,6 +558,42 @@ with expansion:
|
|||||||
"this string contains 'abc' as a substring" ( contains: "not there" or
|
"this string contains 'abc' as a substring" ( contains: "not there" or
|
||||||
contains: "string" )
|
contains: "string" )
|
||||||
|
|
||||||
|
-------------------------------------------------------------------------------
|
||||||
|
Approx with exactly-representable margin
|
||||||
|
-------------------------------------------------------------------------------
|
||||||
|
ApproxTests.cpp:<line number>
|
||||||
|
...............................................................................
|
||||||
|
|
||||||
|
ApproxTests.cpp:<line number>:
|
||||||
|
PASSED:
|
||||||
|
CHECK( 0.25f == Approx(0.0f).margin(0.25f) )
|
||||||
|
with expansion:
|
||||||
|
0.25f == Approx( 0.0 )
|
||||||
|
|
||||||
|
ApproxTests.cpp:<line number>:
|
||||||
|
PASSED:
|
||||||
|
CHECK( 0.0f == Approx(0.25f).margin(0.25f) )
|
||||||
|
with expansion:
|
||||||
|
0.0f == Approx( 0.25 )
|
||||||
|
|
||||||
|
ApproxTests.cpp:<line number>:
|
||||||
|
PASSED:
|
||||||
|
CHECK( 0.5f == Approx(0.25f).margin(0.25f) )
|
||||||
|
with expansion:
|
||||||
|
0.5f == Approx( 0.25 )
|
||||||
|
|
||||||
|
ApproxTests.cpp:<line number>:
|
||||||
|
PASSED:
|
||||||
|
CHECK( 245.0f == Approx(245.25f).margin(0.25f) )
|
||||||
|
with expansion:
|
||||||
|
245.0f == Approx( 245.25 )
|
||||||
|
|
||||||
|
ApproxTests.cpp:<line number>:
|
||||||
|
PASSED:
|
||||||
|
CHECK( 245.5f == Approx(245.25f).margin(0.25f) )
|
||||||
|
with expansion:
|
||||||
|
245.5f == Approx( 245.25 )
|
||||||
|
|
||||||
-------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------
|
||||||
Approximate PI
|
Approximate PI
|
||||||
-------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------
|
||||||
@@ -6786,6 +6888,45 @@ PASSED:
|
|||||||
with expansion:
|
with expansion:
|
||||||
Approx( 1.23 ) != 1.24
|
Approx( 1.23 ) != 1.24
|
||||||
|
|
||||||
|
ApproxTests.cpp:<line number>:
|
||||||
|
PASSED:
|
||||||
|
REQUIRE( 0 == Approx(0) )
|
||||||
|
with expansion:
|
||||||
|
0 == Approx( 0.0 )
|
||||||
|
|
||||||
|
Write to std::cerr
|
||||||
|
-------------------------------------------------------------------------------
|
||||||
|
Standard error is reported and redirected
|
||||||
|
std::cerr
|
||||||
|
-------------------------------------------------------------------------------
|
||||||
|
MessageTests.cpp:<line number>
|
||||||
|
...............................................................................
|
||||||
|
|
||||||
|
|
||||||
|
No assertions in section 'std::cerr'
|
||||||
|
|
||||||
|
Write to std::clog
|
||||||
|
-------------------------------------------------------------------------------
|
||||||
|
Standard error is reported and redirected
|
||||||
|
std::clog
|
||||||
|
-------------------------------------------------------------------------------
|
||||||
|
MessageTests.cpp:<line number>
|
||||||
|
...............................................................................
|
||||||
|
|
||||||
|
|
||||||
|
No assertions in section 'std::clog'
|
||||||
|
|
||||||
|
Interleaved writes to error streams
|
||||||
|
-------------------------------------------------------------------------------
|
||||||
|
Standard error is reported and redirected
|
||||||
|
Interleaved writes to cerr and clog
|
||||||
|
-------------------------------------------------------------------------------
|
||||||
|
MessageTests.cpp:<line number>
|
||||||
|
...............................................................................
|
||||||
|
|
||||||
|
|
||||||
|
No assertions in section 'Interleaved writes to cerr and clog'
|
||||||
|
|
||||||
Message from section one
|
Message from section one
|
||||||
-------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------
|
||||||
Standard output from all sections is reported
|
Standard output from all sections is reported
|
||||||
@@ -9483,6 +9624,6 @@ MiscTests.cpp:<line number>:
|
|||||||
PASSED:
|
PASSED:
|
||||||
|
|
||||||
===============================================================================
|
===============================================================================
|
||||||
test cases: 168 | 118 passed | 46 failed | 4 failed as expected
|
test cases: 171 | 120 passed | 47 failed | 4 failed as expected
|
||||||
assertions: 970 | 859 passed | 90 failed | 21 failed as expected
|
assertions: 985 | 871 passed | 93 failed | 21 failed as expected
|
||||||
|
|
||||||
|
@@ -123,6 +123,66 @@ PASSED:
|
|||||||
with expansion:
|
with expansion:
|
||||||
1 == 1
|
1 == 1
|
||||||
|
|
||||||
|
-------------------------------------------------------------------------------
|
||||||
|
#961 -- Dynamically created sections should all be reported
|
||||||
|
Looped section 0
|
||||||
|
-------------------------------------------------------------------------------
|
||||||
|
MiscTests.cpp:<line number>
|
||||||
|
...............................................................................
|
||||||
|
|
||||||
|
MiscTests.cpp:<line number>:
|
||||||
|
PASSED:
|
||||||
|
with message:
|
||||||
|
Everything is OK
|
||||||
|
|
||||||
|
-------------------------------------------------------------------------------
|
||||||
|
#961 -- Dynamically created sections should all be reported
|
||||||
|
Looped section 1
|
||||||
|
-------------------------------------------------------------------------------
|
||||||
|
MiscTests.cpp:<line number>
|
||||||
|
...............................................................................
|
||||||
|
|
||||||
|
MiscTests.cpp:<line number>:
|
||||||
|
PASSED:
|
||||||
|
with message:
|
||||||
|
Everything is OK
|
||||||
|
|
||||||
|
-------------------------------------------------------------------------------
|
||||||
|
#961 -- Dynamically created sections should all be reported
|
||||||
|
Looped section 2
|
||||||
|
-------------------------------------------------------------------------------
|
||||||
|
MiscTests.cpp:<line number>
|
||||||
|
...............................................................................
|
||||||
|
|
||||||
|
MiscTests.cpp:<line number>:
|
||||||
|
PASSED:
|
||||||
|
with message:
|
||||||
|
Everything is OK
|
||||||
|
|
||||||
|
-------------------------------------------------------------------------------
|
||||||
|
#961 -- Dynamically created sections should all be reported
|
||||||
|
Looped section 3
|
||||||
|
-------------------------------------------------------------------------------
|
||||||
|
MiscTests.cpp:<line number>
|
||||||
|
...............................................................................
|
||||||
|
|
||||||
|
MiscTests.cpp:<line number>:
|
||||||
|
PASSED:
|
||||||
|
with message:
|
||||||
|
Everything is OK
|
||||||
|
|
||||||
|
-------------------------------------------------------------------------------
|
||||||
|
#961 -- Dynamically created sections should all be reported
|
||||||
|
Looped section 4
|
||||||
|
-------------------------------------------------------------------------------
|
||||||
|
MiscTests.cpp:<line number>
|
||||||
|
...............................................................................
|
||||||
|
|
||||||
|
MiscTests.cpp:<line number>:
|
||||||
|
PASSED:
|
||||||
|
with message:
|
||||||
|
Everything is OK
|
||||||
|
|
||||||
-------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------
|
||||||
'Not' checks that should fail
|
'Not' checks that should fail
|
||||||
-------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------
|
||||||
@@ -142,8 +202,10 @@ with expansion:
|
|||||||
|
|
||||||
ConditionTests.cpp:<line number>: FAILED:
|
ConditionTests.cpp:<line number>: FAILED:
|
||||||
CHECK_FALSE( true )
|
CHECK_FALSE( true )
|
||||||
|
with expansion:
|
||||||
|
!true
|
||||||
|
|
||||||
===============================================================================
|
===============================================================================
|
||||||
test cases: 6 | 3 passed | 1 failed | 2 failed as expected
|
test cases: 7 | 4 passed | 1 failed | 2 failed as expected
|
||||||
assertions: 18 | 11 passed | 4 failed | 3 failed as expected
|
assertions: 23 | 16 passed | 4 failed | 3 failed as expected
|
||||||
|
|
||||||
|
@@ -1,6 +1,6 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8"?>
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
<testsuitesspanner>
|
<testsuitesspanner>
|
||||||
<testsuite name="<exe-name>" errors="13" failures="78" tests="971" hostname="tbd" time="{duration}" timestamp="{iso8601-timestamp}">
|
<testsuite name="<exe-name>" errors="13" failures="81" tests="986" hostname="tbd" time="{duration}" timestamp="{iso8601-timestamp}">
|
||||||
<testcase classname="global" name="# A test name that starts with a #" time="{duration}"/>
|
<testcase classname="global" name="# A test name that starts with a #" time="{duration}"/>
|
||||||
<testcase classname="#748 - captures with unexpected exceptions" name="outside assertions" time="{duration}">
|
<testcase classname="#748 - captures with unexpected exceptions" name="outside assertions" time="{duration}">
|
||||||
<error type="TEST_CASE">
|
<error type="TEST_CASE">
|
||||||
@@ -24,6 +24,11 @@ ExceptionTests.cpp:<line number>
|
|||||||
MiscTests.cpp:<line number>
|
MiscTests.cpp:<line number>
|
||||||
</failure>
|
</failure>
|
||||||
</testcase>
|
</testcase>
|
||||||
|
<testcase classname="#961 -- Dynamically created sections should all be reported" name="Looped section 0" time="{duration}"/>
|
||||||
|
<testcase classname="#961 -- Dynamically created sections should all be reported" name="Looped section 1" time="{duration}"/>
|
||||||
|
<testcase classname="#961 -- Dynamically created sections should all be reported" name="Looped section 2" time="{duration}"/>
|
||||||
|
<testcase classname="#961 -- Dynamically created sections should all be reported" name="Looped section 3" time="{duration}"/>
|
||||||
|
<testcase classname="#961 -- Dynamically created sections should all be reported" name="Looped section 4" time="{duration}"/>
|
||||||
<testcase classname="global" name="'Not' checks that should fail" time="{duration}">
|
<testcase classname="global" name="'Not' checks that should fail" time="{duration}">
|
||||||
<failure message="false != false" type="CHECK">
|
<failure message="false != false" type="CHECK">
|
||||||
ConditionTests.cpp:<line number>
|
ConditionTests.cpp:<line number>
|
||||||
@@ -94,6 +99,7 @@ ExceptionTests.cpp:<line number>
|
|||||||
</testcase>
|
</testcase>
|
||||||
<testcase classname="global" name="Anonymous test case 1" time="{duration}"/>
|
<testcase classname="global" name="Anonymous test case 1" time="{duration}"/>
|
||||||
<testcase classname="global" name="AnyOf matcher" time="{duration}"/>
|
<testcase classname="global" name="AnyOf matcher" time="{duration}"/>
|
||||||
|
<testcase classname="global" name="Approx with exactly-representable margin" time="{duration}"/>
|
||||||
<testcase classname="global" name="Approximate PI" time="{duration}"/>
|
<testcase classname="global" name="Approximate PI" time="{duration}"/>
|
||||||
<testcase classname="global" name="Approximate comparisons with different epsilons" time="{duration}"/>
|
<testcase classname="global" name="Approximate comparisons with different epsilons" time="{duration}"/>
|
||||||
<testcase classname="global" name="Approximate comparisons with floats" time="{duration}"/>
|
<testcase classname="global" name="Approximate comparisons with floats" time="{duration}"/>
|
||||||
@@ -475,6 +481,13 @@ A string sent directly to stderr
|
|||||||
</system-err>
|
</system-err>
|
||||||
</testcase>
|
</testcase>
|
||||||
<testcase classname="global" name="Some simple comparisons between doubles" time="{duration}"/>
|
<testcase classname="global" name="Some simple comparisons between doubles" time="{duration}"/>
|
||||||
|
<testcase classname="Standard error is reported and redirected" name="Interleaved writes to cerr and clog" time="{duration}">
|
||||||
|
<system-err>
|
||||||
|
Write to std::cerr
|
||||||
|
Write to std::clog
|
||||||
|
Interleaved writes to error streams
|
||||||
|
</system-err>
|
||||||
|
</testcase>
|
||||||
<testcase classname="Standard output from all sections is reported" name="two" time="{duration}">
|
<testcase classname="Standard output from all sections is reported" name="two" time="{duration}">
|
||||||
<system-out>
|
<system-out>
|
||||||
Message from section one
|
Message from section one
|
||||||
@@ -750,6 +763,9 @@ hello
|
|||||||
</system-out>
|
</system-out>
|
||||||
<system-err>
|
<system-err>
|
||||||
A string sent directly to stderr
|
A string sent directly to stderr
|
||||||
|
Write to std::cerr
|
||||||
|
Write to std::clog
|
||||||
|
Interleaved writes to error streams
|
||||||
</system-err>
|
</system-err>
|
||||||
</testsuite>
|
</testsuite>
|
||||||
</testsuites>
|
</testsuites>
|
||||||
|
@@ -12,7 +12,7 @@
|
|||||||
<Exception filename="projects/<exe-name>/ExceptionTests.cpp" >
|
<Exception filename="projects/<exe-name>/ExceptionTests.cpp" >
|
||||||
expected exception
|
expected exception
|
||||||
</Exception>
|
</Exception>
|
||||||
<OverallResults successes="0" failures="1" expectedFailures="0"/>
|
<OverallResults successes="0" failures="0" expectedFailures="1"/>
|
||||||
</Section>
|
</Section>
|
||||||
<Section name="inside REQUIRE_NOTHROW" filename="projects/<exe-name>/ExceptionTests.cpp" >
|
<Section name="inside REQUIRE_NOTHROW" filename="projects/<exe-name>/ExceptionTests.cpp" >
|
||||||
<Info>
|
<Info>
|
||||||
@@ -29,7 +29,7 @@
|
|||||||
expected exception
|
expected exception
|
||||||
</Exception>
|
</Exception>
|
||||||
</Expression>
|
</Expression>
|
||||||
<OverallResults successes="0" failures="1" expectedFailures="0"/>
|
<OverallResults successes="0" failures="0" expectedFailures="1"/>
|
||||||
</Section>
|
</Section>
|
||||||
<Section name="inside REQUIRE_THROWS" filename="projects/<exe-name>/ExceptionTests.cpp" >
|
<Section name="inside REQUIRE_THROWS" filename="projects/<exe-name>/ExceptionTests.cpp" >
|
||||||
<Info>
|
<Info>
|
||||||
@@ -136,6 +136,24 @@
|
|||||||
</Expression>
|
</Expression>
|
||||||
<OverallResult success="true"/>
|
<OverallResult success="true"/>
|
||||||
</TestCase>
|
</TestCase>
|
||||||
|
<TestCase name="#961 -- Dynamically created sections should all be reported" tags="[.][hide]" filename="projects/<exe-name>/MiscTests.cpp" >
|
||||||
|
<Section name="Looped section 0" filename="projects/<exe-name>/MiscTests.cpp" >
|
||||||
|
<OverallResults successes="1" failures="0" expectedFailures="0"/>
|
||||||
|
</Section>
|
||||||
|
<Section name="Looped section 1" filename="projects/<exe-name>/MiscTests.cpp" >
|
||||||
|
<OverallResults successes="1" failures="0" expectedFailures="0"/>
|
||||||
|
</Section>
|
||||||
|
<Section name="Looped section 2" filename="projects/<exe-name>/MiscTests.cpp" >
|
||||||
|
<OverallResults successes="1" failures="0" expectedFailures="0"/>
|
||||||
|
</Section>
|
||||||
|
<Section name="Looped section 3" filename="projects/<exe-name>/MiscTests.cpp" >
|
||||||
|
<OverallResults successes="1" failures="0" expectedFailures="0"/>
|
||||||
|
</Section>
|
||||||
|
<Section name="Looped section 4" filename="projects/<exe-name>/MiscTests.cpp" >
|
||||||
|
<OverallResults successes="1" failures="0" expectedFailures="0"/>
|
||||||
|
</Section>
|
||||||
|
<OverallResult success="true"/>
|
||||||
|
</TestCase>
|
||||||
<TestCase name="'Not' checks that should fail" tags="[.][failing][hide]" filename="projects/<exe-name>/ConditionTests.cpp" >
|
<TestCase name="'Not' checks that should fail" tags="[.][failing][hide]" filename="projects/<exe-name>/ConditionTests.cpp" >
|
||||||
<Expression success="false" type="CHECK" filename="projects/<exe-name>/ConditionTests.cpp" >
|
<Expression success="false" type="CHECK" filename="projects/<exe-name>/ConditionTests.cpp" >
|
||||||
<Original>
|
<Original>
|
||||||
@@ -163,7 +181,7 @@
|
|||||||
</Expression>
|
</Expression>
|
||||||
<Expression success="false" type="CHECK_FALSE" filename="projects/<exe-name>/ConditionTests.cpp" >
|
<Expression success="false" type="CHECK_FALSE" filename="projects/<exe-name>/ConditionTests.cpp" >
|
||||||
<Original>
|
<Original>
|
||||||
!true
|
!(true)
|
||||||
</Original>
|
</Original>
|
||||||
<Expanded>
|
<Expanded>
|
||||||
!true
|
!true
|
||||||
@@ -179,7 +197,7 @@
|
|||||||
</Expression>
|
</Expression>
|
||||||
<Expression success="false" type="CHECK_FALSE" filename="projects/<exe-name>/ConditionTests.cpp" >
|
<Expression success="false" type="CHECK_FALSE" filename="projects/<exe-name>/ConditionTests.cpp" >
|
||||||
<Original>
|
<Original>
|
||||||
!trueValue
|
!(trueValue)
|
||||||
</Original>
|
</Original>
|
||||||
<Expanded>
|
<Expanded>
|
||||||
!true
|
!true
|
||||||
@@ -195,7 +213,7 @@
|
|||||||
</Expression>
|
</Expression>
|
||||||
<Expression success="false" type="CHECK_FALSE" filename="projects/<exe-name>/ConditionTests.cpp" >
|
<Expression success="false" type="CHECK_FALSE" filename="projects/<exe-name>/ConditionTests.cpp" >
|
||||||
<Original>
|
<Original>
|
||||||
!1 == 1
|
!(1 == 1)
|
||||||
</Original>
|
</Original>
|
||||||
<Expanded>
|
<Expanded>
|
||||||
!(1 == 1)
|
!(1 == 1)
|
||||||
@@ -230,7 +248,7 @@
|
|||||||
</Expression>
|
</Expression>
|
||||||
<Expression success="true" type="REQUIRE_FALSE" filename="projects/<exe-name>/ConditionTests.cpp" >
|
<Expression success="true" type="REQUIRE_FALSE" filename="projects/<exe-name>/ConditionTests.cpp" >
|
||||||
<Original>
|
<Original>
|
||||||
!false
|
!(false)
|
||||||
</Original>
|
</Original>
|
||||||
<Expanded>
|
<Expanded>
|
||||||
!false
|
!false
|
||||||
@@ -246,7 +264,7 @@
|
|||||||
</Expression>
|
</Expression>
|
||||||
<Expression success="true" type="REQUIRE_FALSE" filename="projects/<exe-name>/ConditionTests.cpp" >
|
<Expression success="true" type="REQUIRE_FALSE" filename="projects/<exe-name>/ConditionTests.cpp" >
|
||||||
<Original>
|
<Original>
|
||||||
!falseValue
|
!(falseValue)
|
||||||
</Original>
|
</Original>
|
||||||
<Expanded>
|
<Expanded>
|
||||||
!false
|
!false
|
||||||
@@ -262,7 +280,7 @@
|
|||||||
</Expression>
|
</Expression>
|
||||||
<Expression success="true" type="REQUIRE_FALSE" filename="projects/<exe-name>/ConditionTests.cpp" >
|
<Expression success="true" type="REQUIRE_FALSE" filename="projects/<exe-name>/ConditionTests.cpp" >
|
||||||
<Original>
|
<Original>
|
||||||
!1 == 2
|
!(1 == 2)
|
||||||
</Original>
|
</Original>
|
||||||
<Expanded>
|
<Expanded>
|
||||||
!(1 == 2)
|
!(1 == 2)
|
||||||
@@ -342,7 +360,7 @@
|
|||||||
</Expression>
|
</Expression>
|
||||||
<Expression success="true" type="REQUIRE_FALSE" filename="projects/<exe-name>/TrickyTests.cpp" >
|
<Expression success="true" type="REQUIRE_FALSE" filename="projects/<exe-name>/TrickyTests.cpp" >
|
||||||
<Original>
|
<Original>
|
||||||
!is_true<false>::value
|
!(is_true<false>::value)
|
||||||
</Original>
|
</Original>
|
||||||
<Expanded>
|
<Expanded>
|
||||||
!false
|
!false
|
||||||
@@ -444,6 +462,14 @@
|
|||||||
104.0 == Approx( 100.0 )
|
104.0 == Approx( 100.0 )
|
||||||
</Expanded>
|
</Expanded>
|
||||||
</Expression>
|
</Expression>
|
||||||
|
<Expression success="true" type="REQUIRE" filename="projects/<exe-name>/ApproxTests.cpp" >
|
||||||
|
<Original>
|
||||||
|
104.0 == Approx(100.0).margin(4)
|
||||||
|
</Original>
|
||||||
|
<Expanded>
|
||||||
|
104.0 == Approx( 100.0 )
|
||||||
|
</Expanded>
|
||||||
|
</Expression>
|
||||||
<Expression success="true" type="REQUIRE" filename="projects/<exe-name>/ApproxTests.cpp" >
|
<Expression success="true" type="REQUIRE" filename="projects/<exe-name>/ApproxTests.cpp" >
|
||||||
<Original>
|
<Original>
|
||||||
104.0 != Approx(100.0).margin(3)
|
104.0 != Approx(100.0).margin(3)
|
||||||
@@ -547,6 +573,49 @@
|
|||||||
</Expression>
|
</Expression>
|
||||||
<OverallResult success="true"/>
|
<OverallResult success="true"/>
|
||||||
</TestCase>
|
</TestCase>
|
||||||
|
<TestCase name="Approx with exactly-representable margin" tags="[Approx]" filename="projects/<exe-name>/ApproxTests.cpp" >
|
||||||
|
<Expression success="true" type="CHECK" filename="projects/<exe-name>/ApproxTests.cpp" >
|
||||||
|
<Original>
|
||||||
|
0.25f == Approx(0.0f).margin(0.25f)
|
||||||
|
</Original>
|
||||||
|
<Expanded>
|
||||||
|
0.25f == Approx( 0.0 )
|
||||||
|
</Expanded>
|
||||||
|
</Expression>
|
||||||
|
<Expression success="true" type="CHECK" filename="projects/<exe-name>/ApproxTests.cpp" >
|
||||||
|
<Original>
|
||||||
|
0.0f == Approx(0.25f).margin(0.25f)
|
||||||
|
</Original>
|
||||||
|
<Expanded>
|
||||||
|
0.0f == Approx( 0.25 )
|
||||||
|
</Expanded>
|
||||||
|
</Expression>
|
||||||
|
<Expression success="true" type="CHECK" filename="projects/<exe-name>/ApproxTests.cpp" >
|
||||||
|
<Original>
|
||||||
|
0.5f == Approx(0.25f).margin(0.25f)
|
||||||
|
</Original>
|
||||||
|
<Expanded>
|
||||||
|
0.5f == Approx( 0.25 )
|
||||||
|
</Expanded>
|
||||||
|
</Expression>
|
||||||
|
<Expression success="true" type="CHECK" filename="projects/<exe-name>/ApproxTests.cpp" >
|
||||||
|
<Original>
|
||||||
|
245.0f == Approx(245.25f).margin(0.25f)
|
||||||
|
</Original>
|
||||||
|
<Expanded>
|
||||||
|
245.0f == Approx( 245.25 )
|
||||||
|
</Expanded>
|
||||||
|
</Expression>
|
||||||
|
<Expression success="true" type="CHECK" filename="projects/<exe-name>/ApproxTests.cpp" >
|
||||||
|
<Original>
|
||||||
|
245.5f == Approx(245.25f).margin(0.25f)
|
||||||
|
</Original>
|
||||||
|
<Expanded>
|
||||||
|
245.5f == Approx( 245.25 )
|
||||||
|
</Expanded>
|
||||||
|
</Expression>
|
||||||
|
<OverallResult success="true"/>
|
||||||
|
</TestCase>
|
||||||
<TestCase name="Approximate PI" tags="[Approx][PI]" filename="projects/<exe-name>/ApproxTests.cpp" >
|
<TestCase name="Approximate PI" tags="[Approx][PI]" filename="projects/<exe-name>/ApproxTests.cpp" >
|
||||||
<Expression success="true" type="REQUIRE" filename="projects/<exe-name>/ApproxTests.cpp" >
|
<Expression success="true" type="REQUIRE" filename="projects/<exe-name>/ApproxTests.cpp" >
|
||||||
<Original>
|
<Original>
|
||||||
@@ -2690,7 +2759,7 @@
|
|||||||
</Expression>
|
</Expression>
|
||||||
<Expression success="true" type="REQUIRE_FALSE" filename="projects/<exe-name>/ApproxTests.cpp" >
|
<Expression success="true" type="REQUIRE_FALSE" filename="projects/<exe-name>/ApproxTests.cpp" >
|
||||||
<Original>
|
<Original>
|
||||||
!d >= Approx( 1.24 )
|
!(d >= Approx( 1.24 ))
|
||||||
</Original>
|
</Original>
|
||||||
<Expanded>
|
<Expanded>
|
||||||
!(1.23 >= Approx( 1.24 ))
|
!(1.23 >= Approx( 1.24 ))
|
||||||
@@ -2950,7 +3019,7 @@
|
|||||||
</Expression>
|
</Expression>
|
||||||
<Expression success="true" type="REQUIRE_FALSE" filename="projects/<exe-name>/ApproxTests.cpp" >
|
<Expression success="true" type="REQUIRE_FALSE" filename="projects/<exe-name>/ApproxTests.cpp" >
|
||||||
<Original>
|
<Original>
|
||||||
!d <= Approx( 1.22 )
|
!(d <= Approx( 1.22 ))
|
||||||
</Original>
|
</Original>
|
||||||
<Expanded>
|
<Expanded>
|
||||||
!(1.23 <= Approx( 1.22 ))
|
!(1.23 <= Approx( 1.22 ))
|
||||||
@@ -4708,7 +4777,7 @@ re>"
|
|||||||
</Expression>
|
</Expression>
|
||||||
<Expression success="true" type="CHECK_FALSE" filename="projects/<exe-name>/TrickyTests.cpp" >
|
<Expression success="true" type="CHECK_FALSE" filename="projects/<exe-name>/TrickyTests.cpp" >
|
||||||
<Original>
|
<Original>
|
||||||
!False
|
!(False)
|
||||||
</Original>
|
</Original>
|
||||||
<Expanded>
|
<Expanded>
|
||||||
!0
|
!0
|
||||||
@@ -7307,8 +7376,34 @@ A string sent directly to stderr
|
|||||||
Approx( 1.23 ) != 1.24
|
Approx( 1.23 ) != 1.24
|
||||||
</Expanded>
|
</Expanded>
|
||||||
</Expression>
|
</Expression>
|
||||||
|
<Expression success="true" type="REQUIRE" filename="projects/<exe-name>/ApproxTests.cpp" >
|
||||||
|
<Original>
|
||||||
|
0 == Approx(0)
|
||||||
|
</Original>
|
||||||
|
<Expanded>
|
||||||
|
0 == Approx( 0.0 )
|
||||||
|
</Expanded>
|
||||||
|
</Expression>
|
||||||
<OverallResult success="true"/>
|
<OverallResult success="true"/>
|
||||||
</TestCase>
|
</TestCase>
|
||||||
|
<TestCase name="Standard error is reported and redirected" tags="[.][hide][messages]" filename="projects/<exe-name>/MessageTests.cpp" >
|
||||||
|
<Section name="std::cerr" filename="projects/<exe-name>/MessageTests.cpp" >
|
||||||
|
<OverallResults successes="0" failures="1" expectedFailures="0"/>
|
||||||
|
</Section>
|
||||||
|
<Section name="std::clog" filename="projects/<exe-name>/MessageTests.cpp" >
|
||||||
|
<OverallResults successes="0" failures="1" expectedFailures="0"/>
|
||||||
|
</Section>
|
||||||
|
<Section name="Interleaved writes to cerr and clog" filename="projects/<exe-name>/MessageTests.cpp" >
|
||||||
|
<OverallResults successes="0" failures="1" expectedFailures="0"/>
|
||||||
|
</Section>
|
||||||
|
<OverallResult success="false">
|
||||||
|
<StdErr>
|
||||||
|
Write to std::cerr
|
||||||
|
Write to std::clog
|
||||||
|
Interleaved writes to error streams
|
||||||
|
</StdErr>
|
||||||
|
</OverallResult>
|
||||||
|
</TestCase>
|
||||||
<TestCase name="Standard output from all sections is reported" tags="[.][hide][messages]" filename="projects/<exe-name>/MessageTests.cpp" >
|
<TestCase name="Standard output from all sections is reported" tags="[.][hide][messages]" filename="projects/<exe-name>/MessageTests.cpp" >
|
||||||
<Section name="one" filename="projects/<exe-name>/MessageTests.cpp" >
|
<Section name="one" filename="projects/<exe-name>/MessageTests.cpp" >
|
||||||
<OverallResults successes="0" failures="1" expectedFailures="0"/>
|
<OverallResults successes="0" failures="1" expectedFailures="0"/>
|
||||||
@@ -9673,7 +9768,7 @@ spanner <OverallResult success="true"/>
|
|||||||
<Section name="replace no chars" filename="projects/<exe-name>/TestMain.cpp" >
|
<Section name="replace no chars" filename="projects/<exe-name>/TestMain.cpp" >
|
||||||
<Expression success="true" type="CHECK_FALSE" filename="projects/<exe-name>/TestMain.cpp" >
|
<Expression success="true" type="CHECK_FALSE" filename="projects/<exe-name>/TestMain.cpp" >
|
||||||
<Original>
|
<Original>
|
||||||
!replaceInPlace( letters, "x", "z" )
|
!(replaceInPlace( letters, "x", "z" ))
|
||||||
</Original>
|
</Original>
|
||||||
<Expanded>
|
<Expanded>
|
||||||
!false
|
!false
|
||||||
@@ -10143,7 +10238,7 @@ spanner <OverallResult success="true"/>
|
|||||||
</Section>
|
</Section>
|
||||||
<OverallResult success="true"/>
|
<OverallResult success="true"/>
|
||||||
</TestCase>
|
</TestCase>
|
||||||
<OverallResults successes="859" failures="91" expectedFailures="21"/>
|
<OverallResults successes="871" failures="94" expectedFailures="21"/>
|
||||||
</Group>
|
</Group>
|
||||||
<OverallResults successes="859" failures="90" expectedFailures="21"/>
|
<OverallResults successes="871" failures="93" expectedFailures="21"/>
|
||||||
</Catch>
|
</Catch>
|
||||||
|
@@ -99,6 +99,23 @@ TEST_CASE( "Standard output from all sections is reported", "[messages][.]" )
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
TEST_CASE( "Standard error is reported and redirected", "[messages][.]" ) {
|
||||||
|
SECTION( "std::cerr" ) {
|
||||||
|
std::cerr << "Write to std::cerr" << std::endl;
|
||||||
|
}
|
||||||
|
SECTION( "std::clog" ) {
|
||||||
|
std::clog << "Write to std::clog" << std::endl;
|
||||||
|
}
|
||||||
|
SECTION( "Interleaved writes to cerr and clog" ) {
|
||||||
|
std::cerr << "Inter";
|
||||||
|
std::clog << "leaved";
|
||||||
|
std::cerr << ' ';
|
||||||
|
std::clog << "writes";
|
||||||
|
std::cerr << " to error";
|
||||||
|
std::clog << " streams\n";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
TEST_CASE( "SCOPED_INFO is reset for each loop", "[messages][failing][.]" )
|
TEST_CASE( "SCOPED_INFO is reset for each loop", "[messages][failing][.]" )
|
||||||
{
|
{
|
||||||
for( int i=0; i<100; i++ )
|
for( int i=0; i<100; i++ )
|
||||||
|
@@ -405,3 +405,11 @@ TEST_CASE( "#835 -- errno should not be touched by Catch", "[!shouldfail]" ) {
|
|||||||
CHECK(f() == 0);
|
CHECK(f() == 0);
|
||||||
REQUIRE(errno == 1); // Check that f() doesn't touch errno.
|
REQUIRE(errno == 1); // Check that f() doesn't touch errno.
|
||||||
}
|
}
|
||||||
|
|
||||||
|
TEST_CASE( "#961 -- Dynamically created sections should all be reported", "[.]" ) {
|
||||||
|
for (char i = '0'; i < '5'; ++i) {
|
||||||
|
SECTION(std::string("Looped section ") + i) {
|
||||||
|
SUCCEED( "Everything is OK" );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
@@ -407,3 +407,9 @@ TEST_CASE( "has printf", "" ) {
|
|||||||
// This can cause problems as, currently, stdout itself is not redirect - only the cout (and cerr) buffer
|
// This can cause problems as, currently, stdout itself is not redirect - only the cout (and cerr) buffer
|
||||||
printf( "spanner" );
|
printf( "spanner" );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
TEST_CASE( "null deref", "[.][failing][!nonportable]" ) {
|
||||||
|
CHECK( false );
|
||||||
|
int *x = NULL;
|
||||||
|
*x = 1;
|
||||||
|
}
|
||||||
|
@@ -7,5 +7,7 @@ v = Version()
|
|||||||
v.incrementBuildNumber()
|
v.incrementBuildNumber()
|
||||||
v.updateVersionFile()
|
v.updateVersionFile()
|
||||||
v.updateReadmeFile()
|
v.updateReadmeFile()
|
||||||
|
v.updateConanFile()
|
||||||
|
v.updateConanTestFile()
|
||||||
|
|
||||||
print( "Updated Version.hpp and README to v{0}".format( v.getVersionString() ) )
|
print( "Updated Version.hpp, README and Conan to v{0}".format( v.getVersionString() ) )
|
||||||
|
@@ -9,97 +9,100 @@ import datetime
|
|||||||
import string
|
import string
|
||||||
|
|
||||||
from scriptCommon import catchPath
|
from scriptCommon import catchPath
|
||||||
from releaseCommon import Version
|
|
||||||
|
|
||||||
|
|
||||||
includesParser = re.compile( r'\s*#\s*include\s*"(.*)"' )
|
def generate(v):
|
||||||
guardParser = re.compile( r'\s*#.*TWOBLUECUBES_CATCH_.*_INCLUDED')
|
includesParser = re.compile( r'\s*#\s*include\s*"(.*)"' )
|
||||||
defineParser = re.compile( r'\s*#define')
|
guardParser = re.compile( r'\s*#.*TWOBLUECUBES_CATCH_.*_INCLUDED')
|
||||||
ifParser = re.compile( r'\s*#ifndef TWOBLUECUBES_CATCH_.*_INCLUDED')
|
defineParser = re.compile( r'\s*#define')
|
||||||
endIfParser = re.compile( r'\s*#endif // TWOBLUECUBES_CATCH_.*_INCLUDED')
|
ifParser = re.compile( r'\s*#ifndef TWOBLUECUBES_CATCH_.*_INCLUDED')
|
||||||
ifImplParser = re.compile( r'\s*#ifdef CATCH_CONFIG_RUNNER' )
|
endIfParser = re.compile( r'\s*#endif // TWOBLUECUBES_CATCH_.*_INCLUDED')
|
||||||
commentParser1 = re.compile( r'^\s*/\*')
|
ifImplParser = re.compile( r'\s*#ifdef CATCH_CONFIG_RUNNER' )
|
||||||
commentParser2 = re.compile( r'^ \*')
|
commentParser1 = re.compile( r'^\s*/\*')
|
||||||
blankParser = re.compile( r'^\s*$')
|
commentParser2 = re.compile( r'^ \*')
|
||||||
seenHeaders = set([])
|
blankParser = re.compile( r'^\s*$')
|
||||||
rootPath = os.path.join( catchPath, 'include/' )
|
seenHeaders = set([])
|
||||||
outputPath = os.path.join( catchPath, 'single_include/catch.hpp' )
|
rootPath = os.path.join( catchPath, 'include/' )
|
||||||
|
outputPath = os.path.join( catchPath, 'single_include/catch.hpp' )
|
||||||
|
|
||||||
includeImpl = True
|
|
||||||
|
|
||||||
for arg in sys.argv[1:]:
|
globals = {
|
||||||
arg = string.lower(arg)
|
'ifdefs' : 0,
|
||||||
if arg == "noimpl":
|
'implIfDefs' : -1,
|
||||||
includeImpl = False
|
'includeImpl': True
|
||||||
print( "Not including impl code" )
|
}
|
||||||
else:
|
|
||||||
print( "\n** Unrecognised argument: " + arg + " **\n" )
|
|
||||||
exit(1)
|
|
||||||
|
|
||||||
out = open( outputPath, 'w' )
|
for arg in sys.argv[1:]:
|
||||||
ifdefs = 0
|
arg = string.lower(arg)
|
||||||
implIfDefs = -1
|
if arg == "noimpl":
|
||||||
|
globals['includeImpl'] = False
|
||||||
def write( line ):
|
print( "Not including impl code" )
|
||||||
if includeImpl or implIfDefs == -1:
|
|
||||||
out.write( line )
|
|
||||||
|
|
||||||
def parseFile( path, filename ):
|
|
||||||
global ifdefs
|
|
||||||
global implIfDefs
|
|
||||||
|
|
||||||
f = open( path + filename, 'r' )
|
|
||||||
blanks = 0
|
|
||||||
for line in f:
|
|
||||||
if ifParser.match( line ):
|
|
||||||
ifdefs = ifdefs + 1
|
|
||||||
elif endIfParser.match( line ):
|
|
||||||
ifdefs = ifdefs - 1
|
|
||||||
if ifdefs == implIfDefs:
|
|
||||||
implIfDefs = -1
|
|
||||||
m = includesParser.match( line )
|
|
||||||
if m:
|
|
||||||
header = m.group(1)
|
|
||||||
headerPath, sep, headerFile = header.rpartition( "/" )
|
|
||||||
if not headerFile in seenHeaders:
|
|
||||||
if headerFile != "tbc_text_format.h" and headerFile != "clara.h":
|
|
||||||
seenHeaders.add( headerFile )
|
|
||||||
write( "// #included from: {0}\n".format( header ) )
|
|
||||||
if headerPath == "internal" and path.endswith("internal/"):
|
|
||||||
headerPath = ""
|
|
||||||
sep = ""
|
|
||||||
if os.path.exists( path + headerPath + sep + headerFile ):
|
|
||||||
parseFile( path + headerPath + sep, headerFile )
|
|
||||||
else:
|
|
||||||
parseFile( rootPath + headerPath + sep, headerFile )
|
|
||||||
else:
|
else:
|
||||||
if ifImplParser.match(line):
|
print( "\n** Unrecognised argument: " + arg + " **\n" )
|
||||||
implIfDefs = ifdefs
|
exit(1)
|
||||||
if (not guardParser.match( line ) or defineParser.match( line ) ) and not commentParser1.match( line )and not commentParser2.match( line ):
|
|
||||||
if blankParser.match( line ):
|
out = open( outputPath, 'w' )
|
||||||
blanks = blanks + 1
|
|
||||||
else:
|
def write( line ):
|
||||||
blanks = 0
|
if globals['includeImpl'] or globals['implIfDefs'] == -1:
|
||||||
if blanks < 2:
|
out.write( line )
|
||||||
write( line.rstrip() + "\n" )
|
|
||||||
|
def parseFile( path, filename ):
|
||||||
|
f = open( path + filename, 'r' )
|
||||||
|
blanks = 0
|
||||||
|
for line in f:
|
||||||
|
if ifParser.match( line ):
|
||||||
|
globals['ifdefs'] += 1
|
||||||
|
elif endIfParser.match( line ):
|
||||||
|
globals['ifdefs'] -= 1
|
||||||
|
if globals['ifdefs'] == globals['implIfDefs']:
|
||||||
|
globals['implIfDefs'] = -1
|
||||||
|
m = includesParser.match( line )
|
||||||
|
if m:
|
||||||
|
header = m.group(1)
|
||||||
|
headerPath, sep, headerFile = header.rpartition( "/" )
|
||||||
|
if not headerFile in seenHeaders:
|
||||||
|
if headerFile != "tbc_text_format.h" and headerFile != "clara.h":
|
||||||
|
seenHeaders.add( headerFile )
|
||||||
|
write( "// #included from: {0}\n".format( header ) )
|
||||||
|
if headerPath == "internal" and path.endswith("internal/"):
|
||||||
|
headerPath = ""
|
||||||
|
sep = ""
|
||||||
|
if os.path.exists( path + headerPath + sep + headerFile ):
|
||||||
|
parseFile( path + headerPath + sep, headerFile )
|
||||||
|
else:
|
||||||
|
parseFile( rootPath + headerPath + sep, headerFile )
|
||||||
|
else:
|
||||||
|
if ifImplParser.match(line):
|
||||||
|
globals['implIfDefs'] = globals['ifdefs']
|
||||||
|
if (not guardParser.match( line ) or defineParser.match( line ) ) and not commentParser1.match( line )and not commentParser2.match( line ):
|
||||||
|
if blankParser.match( line ):
|
||||||
|
blanks = blanks + 1
|
||||||
|
else:
|
||||||
|
blanks = 0
|
||||||
|
if blanks < 2:
|
||||||
|
write( line.rstrip() + "\n" )
|
||||||
|
|
||||||
|
|
||||||
v = Version()
|
out.write( "/*\n" )
|
||||||
out.write( "/*\n" )
|
out.write( " * Catch v{0}\n".format( v.getVersionString() ) )
|
||||||
out.write( " * Catch v{0}\n".format( v.getVersionString() ) )
|
out.write( " * Generated: {0}\n".format( datetime.datetime.now() ) )
|
||||||
out.write( " * Generated: {0}\n".format( datetime.datetime.now() ) )
|
out.write( " * ----------------------------------------------------------\n" )
|
||||||
out.write( " * ----------------------------------------------------------\n" )
|
out.write( " * This file has been merged from multiple headers. Please don't edit it directly\n" )
|
||||||
out.write( " * This file has been merged from multiple headers. Please don't edit it directly\n" )
|
out.write( " * Copyright (c) 2012 Two Blue Cubes Ltd. All rights reserved.\n" )
|
||||||
out.write( " * Copyright (c) 2012 Two Blue Cubes Ltd. All rights reserved.\n" )
|
out.write( " *\n" )
|
||||||
out.write( " *\n" )
|
out.write( " * Distributed under the Boost Software License, Version 1.0. (See accompanying\n" )
|
||||||
out.write( " * Distributed under the Boost Software License, Version 1.0. (See accompanying\n" )
|
out.write( " * file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)\n" )
|
||||||
out.write( " * file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)\n" )
|
out.write( " */\n" )
|
||||||
out.write( " */\n" )
|
out.write( "#ifndef TWOBLUECUBES_SINGLE_INCLUDE_CATCH_HPP_INCLUDED\n" )
|
||||||
out.write( "#ifndef TWOBLUECUBES_SINGLE_INCLUDE_CATCH_HPP_INCLUDED\n" )
|
out.write( "#define TWOBLUECUBES_SINGLE_INCLUDE_CATCH_HPP_INCLUDED\n" )
|
||||||
out.write( "#define TWOBLUECUBES_SINGLE_INCLUDE_CATCH_HPP_INCLUDED\n" )
|
|
||||||
|
|
||||||
parseFile( rootPath, 'catch.hpp' )
|
parseFile( rootPath, 'catch.hpp' )
|
||||||
|
|
||||||
out.write( "#endif // TWOBLUECUBES_SINGLE_INCLUDE_CATCH_HPP_INCLUDED\n\n" )
|
out.write( "#endif // TWOBLUECUBES_SINGLE_INCLUDE_CATCH_HPP_INCLUDED\n\n" )
|
||||||
|
out.close()
|
||||||
|
print ("Generated single include for Catch v{0}\n".format( v.getVersionString() ) )
|
||||||
|
|
||||||
print ("Generated single include for Catch v{0}\n".format( v.getVersionString() ) )
|
if __name__ == '__main__':
|
||||||
|
from releaseCommon import Version
|
||||||
|
generate(Version())
|
||||||
|
@@ -1,11 +1,10 @@
|
|||||||
#!/usr/bin/env python
|
#!/usr/bin/env python
|
||||||
|
|
||||||
from __future__ import print_function
|
from __future__ import print_function
|
||||||
from releaseCommon import Version
|
import releaseCommon
|
||||||
|
|
||||||
v = Version()
|
v = releaseCommon.Version()
|
||||||
v.incrementMajorVersion()
|
v.incrementMajorVersion()
|
||||||
v.updateVersionFile()
|
releaseCommon.performUpdates(v)
|
||||||
v.updateReadmeFile()
|
|
||||||
|
|
||||||
print( "Updated Version.hpp and README to v{0}".format( v.getVersionString() ) )
|
print( "Updated Version.hpp, README and Conan to v{0}".format( v.getVersionString() ) )
|
||||||
|
@@ -1,11 +1,10 @@
|
|||||||
#!/usr/bin/env python
|
#!/usr/bin/env python
|
||||||
|
|
||||||
from __future__ import print_function
|
from __future__ import print_function
|
||||||
from releaseCommon import Version
|
import releaseCommon
|
||||||
|
|
||||||
v = Version()
|
v = releaseCommon.Version()
|
||||||
v.incrementMinorVersion()
|
v.incrementMinorVersion()
|
||||||
v.updateVersionFile()
|
releaseCommon.performUpdates(v)
|
||||||
v.updateReadmeFile()
|
|
||||||
|
|
||||||
print( "Updated Version.hpp and README to v{0}".format( v.getVersionString() ) )
|
print( "Updated Version.hpp, README and Conan to v{0}".format( v.getVersionString() ) )
|
||||||
|
@@ -1,11 +1,10 @@
|
|||||||
#!/usr/bin/env python
|
#!/usr/bin/env python
|
||||||
|
|
||||||
from __future__ import print_function
|
from __future__ import print_function
|
||||||
from releaseCommon import Version
|
import releaseCommon
|
||||||
|
|
||||||
v = Version()
|
v = releaseCommon.Version()
|
||||||
v.incrementPatchNumber()
|
v.incrementPatchNumber()
|
||||||
v.updateVersionFile()
|
releaseCommon.performUpdates(v)
|
||||||
v.updateReadmeFile()
|
|
||||||
|
|
||||||
print( "Updated Version.hpp and README to v{0}".format( v.getVersionString() ) )
|
print( "Updated Version.hpp, README and Conan to v{0}".format( v.getVersionString() ) )
|
||||||
|
@@ -6,11 +6,15 @@ import re
|
|||||||
import string
|
import string
|
||||||
|
|
||||||
from scriptCommon import catchPath
|
from scriptCommon import catchPath
|
||||||
|
import generateSingleHeader
|
||||||
|
import updateWandbox
|
||||||
|
|
||||||
versionParser = re.compile( r'(\s*static\sVersion\sversion)\s*\(\s*(.*)\s*,\s*(.*)\s*,\s*(.*)\s*,\s*\"(.*)\"\s*,\s*(.*)\s*\).*' )
|
versionParser = re.compile( r'(\s*static\sVersion\sversion)\s*\(\s*(.*)\s*,\s*(.*)\s*,\s*(.*)\s*,\s*\"(.*)\"\s*,\s*(.*)\s*\).*' )
|
||||||
rootPath = os.path.join( catchPath, 'include/' )
|
rootPath = os.path.join( catchPath, 'include/' )
|
||||||
versionPath = os.path.join( rootPath, "internal/catch_version.hpp" )
|
versionPath = os.path.join( rootPath, "internal/catch_version.hpp" )
|
||||||
readmePath = os.path.join( catchPath, "README.md" )
|
readmePath = os.path.join( catchPath, "README.md" )
|
||||||
|
conanPath = os.path.join(catchPath, 'conanfile.py')
|
||||||
|
conanTestPath = os.path.join(catchPath, 'test_package', 'conanfile.py')
|
||||||
|
|
||||||
class Version:
|
class Version:
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
@@ -74,15 +78,61 @@ class Version:
|
|||||||
for line in lines:
|
for line in lines:
|
||||||
f.write( line + "\n" )
|
f.write( line + "\n" )
|
||||||
|
|
||||||
def updateReadmeFile(self):
|
def updateReadmeFile(version):
|
||||||
downloadParser = re.compile( r'<a href=\"https://github.com/philsquared/Catch/releases/download/v\d+\.\d+\.\d+/catch.hpp\">' )
|
downloadParser = re.compile( r'<a href=\"https://github.com/philsquared/Catch/releases/download/v\d+\.\d+\.\d+/catch.hpp\">' )
|
||||||
f = open( readmePath, 'r' )
|
success, wandboxLink = updateWandbox.uploadFiles()
|
||||||
lines = []
|
if not success:
|
||||||
for line in f:
|
print('Error when uploading to wandbox: {}'.format(wandboxLink))
|
||||||
lines.append( line.rstrip() )
|
exit(1)
|
||||||
f.close()
|
f = open( readmePath, 'r' )
|
||||||
f = open( readmePath, 'w' )
|
lines = []
|
||||||
for line in lines:
|
for line in f:
|
||||||
line = downloadParser.sub( r'<a href="https://github.com/philsquared/Catch/releases/download/v{0}/catch.hpp">'.format(self.getVersionString()) , line)
|
lines.append( line.rstrip() )
|
||||||
f.write( line + "\n" )
|
f.close()
|
||||||
|
f = open( readmePath, 'w' )
|
||||||
|
for line in lines:
|
||||||
|
line = downloadParser.sub( r'<a href="https://github.com/philsquared/Catch/releases/download/v{0}/catch.hpp">'.format(version.getVersionString()) , line)
|
||||||
|
if '[]' in line:
|
||||||
|
line = '[]({0})'.format(wandboxLink)
|
||||||
|
f.write( line + "\n" )
|
||||||
|
|
||||||
|
def updateConanFile(version):
|
||||||
|
conanParser = re.compile( r' version = "\d+\.\d+\.\d+.*"')
|
||||||
|
f = open( conanPath, 'r' )
|
||||||
|
lines = []
|
||||||
|
for line in f:
|
||||||
|
m = conanParser.match( line )
|
||||||
|
if m:
|
||||||
|
lines.append( ' version = "{0}"'.format(format(version.getVersionString())) )
|
||||||
|
else:
|
||||||
|
lines.append( line.rstrip() )
|
||||||
|
f.close()
|
||||||
|
f = open( conanPath, 'w' )
|
||||||
|
for line in lines:
|
||||||
|
f.write( line + "\n" )
|
||||||
|
|
||||||
|
def updateConanTestFile(version):
|
||||||
|
conanParser = re.compile( r' requires = \"Catch\/\d+\.\d+\.\d+.*@%s\/%s\" % \(username, channel\)')
|
||||||
|
f = open( conanTestPath, 'r' )
|
||||||
|
lines = []
|
||||||
|
for line in f:
|
||||||
|
m = conanParser.match( line )
|
||||||
|
if m:
|
||||||
|
lines.append( ' requires = "Catch/{0}@%s/%s" % (username, channel)'.format(format(version.getVersionString())) )
|
||||||
|
else:
|
||||||
|
lines.append( line.rstrip() )
|
||||||
|
f.close()
|
||||||
|
f = open( conanTestPath, 'w' )
|
||||||
|
for line in lines:
|
||||||
|
f.write( line + "\n" )
|
||||||
|
|
||||||
|
def performUpdates(version):
|
||||||
|
# First update version file, so we can regenerate single header and
|
||||||
|
# have it ready for upload to wandbox, when updating readme
|
||||||
|
version.updateVersionFile()
|
||||||
|
# ToDo: Regenerate single header
|
||||||
|
generateSingleHeader.generate(version)
|
||||||
|
updateReadmeFile(version)
|
||||||
|
|
||||||
|
updateConanFile(version)
|
||||||
|
updateConanTestFile(version)
|
||||||
|
@@ -8,7 +8,7 @@ from releaseCommon import Version
|
|||||||
|
|
||||||
print(catchPath)
|
print(catchPath)
|
||||||
|
|
||||||
default_path = '../vcpkg/ports/catch/'
|
default_path = '../vcpkg/ports/catch-classic/'
|
||||||
|
|
||||||
def adjusted_path(path):
|
def adjusted_path(path):
|
||||||
return os.path.join(catchPath, path)
|
return os.path.join(catchPath, path)
|
||||||
@@ -57,24 +57,21 @@ def update_portfile(path, header_hash, licence_hash):
|
|||||||
for line in f:
|
for line in f:
|
||||||
lines.append(line)
|
lines.append(line)
|
||||||
with open(portfile_path, 'w') as f:
|
with open(portfile_path, 'w') as f:
|
||||||
# Two things we need to change/update
|
# There are three things we need to change/update
|
||||||
# 1) Link and hash of releaseCommon
|
# 1) CATCH_VERSION cmake variable
|
||||||
# 2) Link and hash of licence
|
# 2) Hash of header
|
||||||
|
# 3) Hash of licence
|
||||||
# We could assume licence never changes, but where is the fun in that?
|
# We could assume licence never changes, but where is the fun in that?
|
||||||
first_hash = True
|
|
||||||
for line in lines:
|
for line in lines:
|
||||||
# Check what we are updating
|
# Update the version
|
||||||
|
if 'set(CATCH_VERSION' in line:
|
||||||
|
line = 'set(CATCH_VERSION v{})\n'.format(v.getVersionString())
|
||||||
|
|
||||||
|
# Determine which file we are updating
|
||||||
if 'vcpkg_download_distfile' in line:
|
if 'vcpkg_download_distfile' in line:
|
||||||
kind = line.split('(')[-1].strip()
|
kind = line.split('(')[-1].strip()
|
||||||
print(kind)
|
|
||||||
|
|
||||||
# Deal with URLS
|
# Update the hashes
|
||||||
if 'URLS' in line and kind == 'HEADER':
|
|
||||||
line = ' URLS "https://github.com/philsquared/Catch/releases/download/v{}/catch.hpp"\n'.format(v.getVersionString())
|
|
||||||
if 'URLS' in line and kind == 'LICENSE':
|
|
||||||
line = ' URLS "https://raw.githubusercontent.com/philsquared/Catch/v{}/LICENSE.txt"\n'.format(v.getVersionString())
|
|
||||||
|
|
||||||
# Deal with hashes
|
|
||||||
if 'SHA512' in line and kind == 'HEADER':
|
if 'SHA512' in line and kind == 'HEADER':
|
||||||
line = ' SHA512 {}\n'.format(header_hash)
|
line = ' SHA512 {}\n'.format(header_hash)
|
||||||
if 'SHA512' in line and kind == 'LICENSE':
|
if 'SHA512' in line and kind == 'LICENSE':
|
||||||
@@ -86,8 +83,6 @@ def git_push(path_to_repo):
|
|||||||
v = Version()
|
v = Version()
|
||||||
ver_string = v.getVersionString()
|
ver_string = v.getVersionString()
|
||||||
|
|
||||||
# Move to the repo dir
|
|
||||||
old_path = os.getcwd()
|
|
||||||
os.chdir(path_to_repo)
|
os.chdir(path_to_repo)
|
||||||
|
|
||||||
# Work with git
|
# Work with git
|
||||||
|
47
scripts/updateWandbox.py
Normal file
47
scripts/updateWandbox.py
Normal file
@@ -0,0 +1,47 @@
|
|||||||
|
#!/usr/bin/env python
|
||||||
|
|
||||||
|
import json
|
||||||
|
import os
|
||||||
|
import urllib2
|
||||||
|
|
||||||
|
from scriptCommon import catchPath
|
||||||
|
|
||||||
|
def upload(options):
|
||||||
|
request = urllib2.Request('http://melpon.org/wandbox/api/compile.json')
|
||||||
|
request.add_header('Content-Type', 'application/json')
|
||||||
|
response = urllib2.urlopen(request, json.dumps(options))
|
||||||
|
return json.loads(response.read())
|
||||||
|
|
||||||
|
main_file = '''
|
||||||
|
#define CATCH_CONFIG_MAIN // This tells Catch to provide a main() - only do this in one cpp file
|
||||||
|
#include "catch.hpp"
|
||||||
|
|
||||||
|
unsigned int Factorial( unsigned int number ) {
|
||||||
|
return number <= 1 ? number : Factorial(number-1)*number;
|
||||||
|
}
|
||||||
|
|
||||||
|
TEST_CASE( "Factorials are computed", "[factorial]" ) {
|
||||||
|
REQUIRE( Factorial(1) == 1 );
|
||||||
|
REQUIRE( Factorial(2) == 2 );
|
||||||
|
REQUIRE( Factorial(3) == 6 );
|
||||||
|
REQUIRE( Factorial(10) == 3628800 );
|
||||||
|
}
|
||||||
|
'''
|
||||||
|
|
||||||
|
def uploadFiles():
|
||||||
|
response = upload({
|
||||||
|
'compiler': 'gcc-head',
|
||||||
|
'code': main_file,
|
||||||
|
'codes': [{
|
||||||
|
'file': 'catch.hpp',
|
||||||
|
'code': open(os.path.join(catchPath, 'single_include', 'catch.hpp')).read()
|
||||||
|
}],
|
||||||
|
'options': 'c++11,cpp-no-pedantic,boost-nothing',
|
||||||
|
'compiler-option-raw': '-DCATCH_CONFIG_FAST_COMPILE',
|
||||||
|
'save': True
|
||||||
|
})
|
||||||
|
|
||||||
|
if 'status' in response and not 'compiler_error' in response:
|
||||||
|
return True, response['url']
|
||||||
|
else:
|
||||||
|
return False, response
|
@@ -1,6 +1,6 @@
|
|||||||
/*
|
/*
|
||||||
* Catch v1.9.6
|
* Catch v1.12.1
|
||||||
* Generated: 2017-06-27 12:19:54.557875
|
* Generated: 2018-03-02 21:17:41.036711
|
||||||
* ----------------------------------------------------------
|
* ----------------------------------------------------------
|
||||||
* This file has been merged from multiple headers. Please don't edit it directly
|
* This file has been merged from multiple headers. Please don't edit it directly
|
||||||
* Copyright (c) 2012 Two Blue Cubes Ltd. All rights reserved.
|
* Copyright (c) 2012 Two Blue Cubes Ltd. All rights reserved.
|
||||||
@@ -145,6 +145,11 @@
|
|||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#ifdef __OS400__
|
||||||
|
# define CATCH_INTERNAL_CONFIG_NO_POSIX_SIGNALS
|
||||||
|
# define CATCH_CONFIG_COLOUR_NONE
|
||||||
|
#endif
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
// Cygwin
|
// Cygwin
|
||||||
#ifdef __CYGWIN__
|
#ifdef __CYGWIN__
|
||||||
@@ -223,7 +228,12 @@
|
|||||||
( defined __GNUC__ && ( __GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 3 )) ) || \
|
( defined __GNUC__ && ( __GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 3 )) ) || \
|
||||||
( defined __clang__ && __clang_major__ >= 3 )
|
( defined __clang__ && __clang_major__ >= 3 )
|
||||||
|
|
||||||
#define CATCH_INTERNAL_CONFIG_COUNTER
|
// Use of __COUNTER__ is suppressed during code analysis in CLion/AppCode 2017.2.x and former,
|
||||||
|
// because __COUNTER__ is not properly handled by it.
|
||||||
|
// This does not affect compilation
|
||||||
|
#if ( !defined __JETBRAINS_IDE__ || __JETBRAINS_IDE__ >= 20170300L )
|
||||||
|
#define CATCH_INTERNAL_CONFIG_COUNTER
|
||||||
|
#endif
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@@ -304,10 +314,7 @@
|
|||||||
#if defined(CATCH_INTERNAL_CONFIG_CPP11_UNIQUE_PTR) && !defined(CATCH_CONFIG_CPP11_NO_UNIQUE_PTR) && !defined(CATCH_CONFIG_CPP11_UNIQUE_PTR) && !defined(CATCH_CONFIG_NO_CPP11)
|
#if defined(CATCH_INTERNAL_CONFIG_CPP11_UNIQUE_PTR) && !defined(CATCH_CONFIG_CPP11_NO_UNIQUE_PTR) && !defined(CATCH_CONFIG_CPP11_UNIQUE_PTR) && !defined(CATCH_CONFIG_NO_CPP11)
|
||||||
# define CATCH_CONFIG_CPP11_UNIQUE_PTR
|
# define CATCH_CONFIG_CPP11_UNIQUE_PTR
|
||||||
#endif
|
#endif
|
||||||
// Use of __COUNTER__ is suppressed if __JETBRAINS_IDE__ is #defined (meaning we're being parsed by a JetBrains IDE for
|
#if defined(CATCH_INTERNAL_CONFIG_COUNTER) && !defined(CATCH_CONFIG_NO_COUNTER) && !defined(CATCH_CONFIG_COUNTER)
|
||||||
// analytics) because, at time of writing, __COUNTER__ is not properly handled by it.
|
|
||||||
// This does not affect compilation
|
|
||||||
#if defined(CATCH_INTERNAL_CONFIG_COUNTER) && !defined(CATCH_CONFIG_NO_COUNTER) && !defined(CATCH_CONFIG_COUNTER) && !defined(__JETBRAINS_IDE__)
|
|
||||||
# define CATCH_CONFIG_COUNTER
|
# define CATCH_CONFIG_COUNTER
|
||||||
#endif
|
#endif
|
||||||
#if defined(CATCH_INTERNAL_CONFIG_CPP11_SHUFFLE) && !defined(CATCH_CONFIG_CPP11_NO_SHUFFLE) && !defined(CATCH_CONFIG_CPP11_SHUFFLE) && !defined(CATCH_CONFIG_NO_CPP11)
|
#if defined(CATCH_INTERNAL_CONFIG_CPP11_SHUFFLE) && !defined(CATCH_CONFIG_CPP11_NO_SHUFFLE) && !defined(CATCH_CONFIG_CPP11_SHUFFLE) && !defined(CATCH_CONFIG_NO_CPP11)
|
||||||
@@ -414,14 +421,14 @@ namespace Catch {
|
|||||||
};
|
};
|
||||||
|
|
||||||
template<typename ContainerT>
|
template<typename ContainerT>
|
||||||
inline void deleteAll( ContainerT& container ) {
|
void deleteAll( ContainerT& container ) {
|
||||||
typename ContainerT::const_iterator it = container.begin();
|
typename ContainerT::const_iterator it = container.begin();
|
||||||
typename ContainerT::const_iterator itEnd = container.end();
|
typename ContainerT::const_iterator itEnd = container.end();
|
||||||
for(; it != itEnd; ++it )
|
for(; it != itEnd; ++it )
|
||||||
delete *it;
|
delete *it;
|
||||||
}
|
}
|
||||||
template<typename AssociativeContainerT>
|
template<typename AssociativeContainerT>
|
||||||
inline void deleteAllValues( AssociativeContainerT& container ) {
|
void deleteAllValues( AssociativeContainerT& container ) {
|
||||||
typename AssociativeContainerT::const_iterator it = container.begin();
|
typename AssociativeContainerT::const_iterator it = container.begin();
|
||||||
typename AssociativeContainerT::const_iterator itEnd = container.end();
|
typename AssociativeContainerT::const_iterator itEnd = container.end();
|
||||||
for(; it != itEnd; ++it )
|
for(; it != itEnd; ++it )
|
||||||
@@ -501,7 +508,6 @@ namespace Catch {
|
|||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
NotImplementedException( SourceLineInfo const& lineInfo );
|
NotImplementedException( SourceLineInfo const& lineInfo );
|
||||||
NotImplementedException( NotImplementedException const& ) {}
|
|
||||||
|
|
||||||
virtual ~NotImplementedException() CATCH_NOEXCEPT {}
|
virtual ~NotImplementedException() CATCH_NOEXCEPT {}
|
||||||
|
|
||||||
@@ -771,7 +777,7 @@ void registerTestCaseFunction
|
|||||||
#define INTERNAL_CATCH_TESTCASE2( TestName, ... ) \
|
#define INTERNAL_CATCH_TESTCASE2( TestName, ... ) \
|
||||||
static void TestName(); \
|
static void TestName(); \
|
||||||
CATCH_INTERNAL_SUPPRESS_ETD_WARNINGS \
|
CATCH_INTERNAL_SUPPRESS_ETD_WARNINGS \
|
||||||
namespace{ Catch::AutoReg INTERNAL_CATCH_UNIQUE_NAME( autoRegistrar )( &TestName, CATCH_INTERNAL_LINEINFO, Catch::NameAndDesc( __VA_ARGS__ ) ); } \
|
namespace{ Catch::AutoReg INTERNAL_CATCH_UNIQUE_NAME( autoRegistrar )( &TestName, CATCH_INTERNAL_LINEINFO, Catch::NameAndDesc( __VA_ARGS__ ) ); } /* NOLINT */ \
|
||||||
CATCH_INTERNAL_UNSUPPRESS_ETD_WARNINGS \
|
CATCH_INTERNAL_UNSUPPRESS_ETD_WARNINGS \
|
||||||
static void TestName()
|
static void TestName()
|
||||||
#define INTERNAL_CATCH_TESTCASE( ... ) \
|
#define INTERNAL_CATCH_TESTCASE( ... ) \
|
||||||
@@ -780,7 +786,7 @@ void registerTestCaseFunction
|
|||||||
///////////////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////////////
|
||||||
#define INTERNAL_CATCH_METHOD_AS_TEST_CASE( QualifiedMethod, ... ) \
|
#define INTERNAL_CATCH_METHOD_AS_TEST_CASE( QualifiedMethod, ... ) \
|
||||||
CATCH_INTERNAL_SUPPRESS_ETD_WARNINGS \
|
CATCH_INTERNAL_SUPPRESS_ETD_WARNINGS \
|
||||||
namespace{ Catch::AutoReg INTERNAL_CATCH_UNIQUE_NAME( autoRegistrar )( &QualifiedMethod, "&" #QualifiedMethod, Catch::NameAndDesc( __VA_ARGS__ ), CATCH_INTERNAL_LINEINFO ); } \
|
namespace{ Catch::AutoReg INTERNAL_CATCH_UNIQUE_NAME( autoRegistrar )( &QualifiedMethod, "&" #QualifiedMethod, Catch::NameAndDesc( __VA_ARGS__ ), CATCH_INTERNAL_LINEINFO ); } /* NOLINT */ \
|
||||||
CATCH_INTERNAL_UNSUPPRESS_ETD_WARNINGS
|
CATCH_INTERNAL_UNSUPPRESS_ETD_WARNINGS
|
||||||
|
|
||||||
///////////////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////////////
|
||||||
@@ -790,7 +796,7 @@ void registerTestCaseFunction
|
|||||||
struct TestName : ClassName{ \
|
struct TestName : ClassName{ \
|
||||||
void test(); \
|
void test(); \
|
||||||
}; \
|
}; \
|
||||||
Catch::AutoReg INTERNAL_CATCH_UNIQUE_NAME( autoRegistrar ) ( &TestName::test, #ClassName, Catch::NameAndDesc( __VA_ARGS__ ), CATCH_INTERNAL_LINEINFO ); \
|
Catch::AutoReg INTERNAL_CATCH_UNIQUE_NAME( autoRegistrar ) ( &TestName::test, #ClassName, Catch::NameAndDesc( __VA_ARGS__ ), CATCH_INTERNAL_LINEINFO ); /* NOLINT */ \
|
||||||
} \
|
} \
|
||||||
CATCH_INTERNAL_UNSUPPRESS_ETD_WARNINGS \
|
CATCH_INTERNAL_UNSUPPRESS_ETD_WARNINGS \
|
||||||
void TestName::test()
|
void TestName::test()
|
||||||
@@ -800,7 +806,7 @@ void registerTestCaseFunction
|
|||||||
///////////////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////////////
|
||||||
#define INTERNAL_CATCH_REGISTER_TESTCASE( Function, ... ) \
|
#define INTERNAL_CATCH_REGISTER_TESTCASE( Function, ... ) \
|
||||||
CATCH_INTERNAL_SUPPRESS_ETD_WARNINGS \
|
CATCH_INTERNAL_SUPPRESS_ETD_WARNINGS \
|
||||||
Catch::AutoReg( Function, CATCH_INTERNAL_LINEINFO, Catch::NameAndDesc( __VA_ARGS__ ) ); \
|
Catch::AutoReg( Function, CATCH_INTERNAL_LINEINFO, Catch::NameAndDesc( __VA_ARGS__ ) ); /* NOLINT */ \
|
||||||
CATCH_INTERNAL_UNSUPPRESS_ETD_WARNINGS
|
CATCH_INTERNAL_UNSUPPRESS_ETD_WARNINGS
|
||||||
|
|
||||||
#else
|
#else
|
||||||
@@ -808,7 +814,7 @@ void registerTestCaseFunction
|
|||||||
#define INTERNAL_CATCH_TESTCASE2( TestName, Name, Desc ) \
|
#define INTERNAL_CATCH_TESTCASE2( TestName, Name, Desc ) \
|
||||||
static void TestName(); \
|
static void TestName(); \
|
||||||
CATCH_INTERNAL_SUPPRESS_ETD_WARNINGS \
|
CATCH_INTERNAL_SUPPRESS_ETD_WARNINGS \
|
||||||
namespace{ Catch::AutoReg INTERNAL_CATCH_UNIQUE_NAME( autoRegistrar )( &TestName, CATCH_INTERNAL_LINEINFO, Catch::NameAndDesc( Name, Desc ) ); }\
|
namespace{ Catch::AutoReg INTERNAL_CATCH_UNIQUE_NAME( autoRegistrar )( &TestName, CATCH_INTERNAL_LINEINFO, Catch::NameAndDesc( Name, Desc ) ); } /* NOLINT */ \
|
||||||
CATCH_INTERNAL_UNSUPPRESS_ETD_WARNINGS \
|
CATCH_INTERNAL_UNSUPPRESS_ETD_WARNINGS \
|
||||||
static void TestName()
|
static void TestName()
|
||||||
#define INTERNAL_CATCH_TESTCASE( Name, Desc ) \
|
#define INTERNAL_CATCH_TESTCASE( Name, Desc ) \
|
||||||
@@ -817,7 +823,7 @@ void registerTestCaseFunction
|
|||||||
///////////////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////////////
|
||||||
#define INTERNAL_CATCH_METHOD_AS_TEST_CASE( QualifiedMethod, Name, Desc ) \
|
#define INTERNAL_CATCH_METHOD_AS_TEST_CASE( QualifiedMethod, Name, Desc ) \
|
||||||
CATCH_INTERNAL_SUPPRESS_ETD_WARNINGS \
|
CATCH_INTERNAL_SUPPRESS_ETD_WARNINGS \
|
||||||
namespace{ Catch::AutoReg INTERNAL_CATCH_UNIQUE_NAME( autoRegistrar )( &QualifiedMethod, "&" #QualifiedMethod, Catch::NameAndDesc( Name, Desc ), CATCH_INTERNAL_LINEINFO ); } \
|
namespace{ Catch::AutoReg INTERNAL_CATCH_UNIQUE_NAME( autoRegistrar )( &QualifiedMethod, "&" #QualifiedMethod, Catch::NameAndDesc( Name, Desc ), CATCH_INTERNAL_LINEINFO ); } /* NOLINT */ \
|
||||||
CATCH_INTERNAL_UNSUPPRESS_ETD_WARNINGS
|
CATCH_INTERNAL_UNSUPPRESS_ETD_WARNINGS
|
||||||
|
|
||||||
///////////////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////////////
|
||||||
@@ -827,7 +833,7 @@ void registerTestCaseFunction
|
|||||||
struct TestCaseName : ClassName{ \
|
struct TestCaseName : ClassName{ \
|
||||||
void test(); \
|
void test(); \
|
||||||
}; \
|
}; \
|
||||||
Catch::AutoReg INTERNAL_CATCH_UNIQUE_NAME( autoRegistrar ) ( &TestCaseName::test, #ClassName, Catch::NameAndDesc( TestName, Desc ), CATCH_INTERNAL_LINEINFO ); \
|
Catch::AutoReg INTERNAL_CATCH_UNIQUE_NAME( autoRegistrar ) ( &TestCaseName::test, #ClassName, Catch::NameAndDesc( TestName, Desc ), CATCH_INTERNAL_LINEINFO ); /* NOLINT */ \
|
||||||
} \
|
} \
|
||||||
CATCH_INTERNAL_UNSUPPRESS_ETD_WARNINGS \
|
CATCH_INTERNAL_UNSUPPRESS_ETD_WARNINGS \
|
||||||
void TestCaseName::test()
|
void TestCaseName::test()
|
||||||
@@ -837,7 +843,7 @@ void registerTestCaseFunction
|
|||||||
///////////////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////////////
|
||||||
#define INTERNAL_CATCH_REGISTER_TESTCASE( Function, Name, Desc ) \
|
#define INTERNAL_CATCH_REGISTER_TESTCASE( Function, Name, Desc ) \
|
||||||
CATCH_INTERNAL_SUPPRESS_ETD_WARNINGS \
|
CATCH_INTERNAL_SUPPRESS_ETD_WARNINGS \
|
||||||
Catch::AutoReg( Function, CATCH_INTERNAL_LINEINFO, Catch::NameAndDesc( Name, Desc ) ); \
|
Catch::AutoReg( Function, CATCH_INTERNAL_LINEINFO, Catch::NameAndDesc( Name, Desc ) ); /* NOLINT */ \
|
||||||
CATCH_INTERNAL_UNSUPPRESS_ETD_WARNINGS
|
CATCH_INTERNAL_UNSUPPRESS_ETD_WARNINGS
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
@@ -933,7 +939,7 @@ namespace Catch {
|
|||||||
|
|
||||||
struct AssertionInfo
|
struct AssertionInfo
|
||||||
{
|
{
|
||||||
AssertionInfo() {}
|
AssertionInfo();
|
||||||
AssertionInfo( char const * _macroName,
|
AssertionInfo( char const * _macroName,
|
||||||
SourceLineInfo const& _lineInfo,
|
SourceLineInfo const& _lineInfo,
|
||||||
char const * _capturedExpression,
|
char const * _capturedExpression,
|
||||||
@@ -1158,23 +1164,23 @@ namespace Matchers {
|
|||||||
// This allows the types to be inferred
|
// This allows the types to be inferred
|
||||||
// - deprecated: prefer ||, && and !
|
// - deprecated: prefer ||, && and !
|
||||||
template<typename T>
|
template<typename T>
|
||||||
inline Impl::MatchNotOf<T> Not( Impl::MatcherBase<T> const& underlyingMatcher ) {
|
Impl::MatchNotOf<T> Not( Impl::MatcherBase<T> const& underlyingMatcher ) {
|
||||||
return Impl::MatchNotOf<T>( underlyingMatcher );
|
return Impl::MatchNotOf<T>( underlyingMatcher );
|
||||||
}
|
}
|
||||||
template<typename T>
|
template<typename T>
|
||||||
inline Impl::MatchAllOf<T> AllOf( Impl::MatcherBase<T> const& m1, Impl::MatcherBase<T> const& m2 ) {
|
Impl::MatchAllOf<T> AllOf( Impl::MatcherBase<T> const& m1, Impl::MatcherBase<T> const& m2 ) {
|
||||||
return Impl::MatchAllOf<T>() && m1 && m2;
|
return Impl::MatchAllOf<T>() && m1 && m2;
|
||||||
}
|
}
|
||||||
template<typename T>
|
template<typename T>
|
||||||
inline Impl::MatchAllOf<T> AllOf( Impl::MatcherBase<T> const& m1, Impl::MatcherBase<T> const& m2, Impl::MatcherBase<T> const& m3 ) {
|
Impl::MatchAllOf<T> AllOf( Impl::MatcherBase<T> const& m1, Impl::MatcherBase<T> const& m2, Impl::MatcherBase<T> const& m3 ) {
|
||||||
return Impl::MatchAllOf<T>() && m1 && m2 && m3;
|
return Impl::MatchAllOf<T>() && m1 && m2 && m3;
|
||||||
}
|
}
|
||||||
template<typename T>
|
template<typename T>
|
||||||
inline Impl::MatchAnyOf<T> AnyOf( Impl::MatcherBase<T> const& m1, Impl::MatcherBase<T> const& m2 ) {
|
Impl::MatchAnyOf<T> AnyOf( Impl::MatcherBase<T> const& m1, Impl::MatcherBase<T> const& m2 ) {
|
||||||
return Impl::MatchAnyOf<T>() || m1 || m2;
|
return Impl::MatchAnyOf<T>() || m1 || m2;
|
||||||
}
|
}
|
||||||
template<typename T>
|
template<typename T>
|
||||||
inline Impl::MatchAnyOf<T> AnyOf( Impl::MatcherBase<T> const& m1, Impl::MatcherBase<T> const& m2, Impl::MatcherBase<T> const& m3 ) {
|
Impl::MatchAnyOf<T> AnyOf( Impl::MatcherBase<T> const& m1, Impl::MatcherBase<T> const& m2, Impl::MatcherBase<T> const& m3 ) {
|
||||||
return Impl::MatchAnyOf<T>() || m1 || m2 || m3;
|
return Impl::MatchAnyOf<T>() || m1 || m2 || m3;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1219,7 +1225,7 @@ namespace Catch {
|
|||||||
|
|
||||||
template<typename T>
|
template<typename T>
|
||||||
ResultBuilder& operator << ( T const& value ) {
|
ResultBuilder& operator << ( T const& value ) {
|
||||||
m_stream().oss << value;
|
stream().oss << value;
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1253,6 +1259,16 @@ namespace Catch {
|
|||||||
AssertionInfo m_assertionInfo;
|
AssertionInfo m_assertionInfo;
|
||||||
AssertionResultData m_data;
|
AssertionResultData m_data;
|
||||||
|
|
||||||
|
CopyableStream &stream()
|
||||||
|
{
|
||||||
|
if(!m_usedStream)
|
||||||
|
{
|
||||||
|
m_usedStream = true;
|
||||||
|
m_stream().oss.str("");
|
||||||
|
}
|
||||||
|
return m_stream();
|
||||||
|
}
|
||||||
|
|
||||||
static CopyableStream &m_stream()
|
static CopyableStream &m_stream()
|
||||||
{
|
{
|
||||||
static CopyableStream s;
|
static CopyableStream s;
|
||||||
@@ -1262,6 +1278,7 @@ namespace Catch {
|
|||||||
bool m_shouldDebugBreak;
|
bool m_shouldDebugBreak;
|
||||||
bool m_shouldThrow;
|
bool m_shouldThrow;
|
||||||
bool m_guardException;
|
bool m_guardException;
|
||||||
|
bool m_usedStream;
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace Catch
|
} // namespace Catch
|
||||||
@@ -1276,6 +1293,7 @@ namespace Catch {
|
|||||||
#ifdef _MSC_VER
|
#ifdef _MSC_VER
|
||||||
#pragma warning(push)
|
#pragma warning(push)
|
||||||
#pragma warning(disable:4389) // '==' : signed/unsigned mismatch
|
#pragma warning(disable:4389) // '==' : signed/unsigned mismatch
|
||||||
|
#pragma warning(disable:4018) // more "signed/unsigned mismatch"
|
||||||
#pragma warning(disable:4312) // Converting int to T* using reinterpret_cast (issue on x64 platform)
|
#pragma warning(disable:4312) // Converting int to T* using reinterpret_cast (issue on x64 platform)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@@ -1302,7 +1320,7 @@ namespace Internal {
|
|||||||
template<> struct OperatorTraits<IsGreaterThanOrEqualTo>{ static const char* getName(){ return ">="; } };
|
template<> struct OperatorTraits<IsGreaterThanOrEqualTo>{ static const char* getName(){ return ">="; } };
|
||||||
|
|
||||||
template<typename T>
|
template<typename T>
|
||||||
inline T& opCast(T const& t) { return const_cast<T&>(t); }
|
T& opCast(T const& t) { return const_cast<T&>(t); }
|
||||||
|
|
||||||
// nullptr_t support based on pull request #154 from Konstantin Baumann
|
// nullptr_t support based on pull request #154 from Konstantin Baumann
|
||||||
#ifdef CATCH_CONFIG_CPP11_NULLPTR
|
#ifdef CATCH_CONFIG_CPP11_NULLPTR
|
||||||
@@ -1312,7 +1330,7 @@ namespace Internal {
|
|||||||
// So the compare overloads can be operator agnostic we convey the operator as a template
|
// So the compare overloads can be operator agnostic we convey the operator as a template
|
||||||
// enum, which is used to specialise an Evaluator for doing the comparison.
|
// enum, which is used to specialise an Evaluator for doing the comparison.
|
||||||
template<typename T1, typename T2, Operator Op>
|
template<typename T1, typename T2, Operator Op>
|
||||||
class Evaluator{};
|
struct Evaluator{};
|
||||||
|
|
||||||
template<typename T1, typename T2>
|
template<typename T1, typename T2>
|
||||||
struct Evaluator<T1, T2, IsEqualTo> {
|
struct Evaluator<T1, T2, IsEqualTo> {
|
||||||
@@ -1667,7 +1685,7 @@ namespace Detail {
|
|||||||
std::string rawMemoryToString( const void *object, std::size_t size );
|
std::string rawMemoryToString( const void *object, std::size_t size );
|
||||||
|
|
||||||
template<typename T>
|
template<typename T>
|
||||||
inline std::string rawMemoryToString( const T& object ) {
|
std::string rawMemoryToString( const T& object ) {
|
||||||
return rawMemoryToString( &object, sizeof(object) );
|
return rawMemoryToString( &object, sizeof(object) );
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1956,7 +1974,7 @@ private:
|
|||||||
namespace Catch {
|
namespace Catch {
|
||||||
|
|
||||||
template<typename T>
|
template<typename T>
|
||||||
inline ExpressionLhs<T const&> ResultBuilder::operator <= ( T const& operand ) {
|
ExpressionLhs<T const&> ResultBuilder::operator <= ( T const& operand ) {
|
||||||
return ExpressionLhs<T const&>( *this, operand );
|
return ExpressionLhs<T const&>( *this, operand );
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1965,7 +1983,7 @@ namespace Catch {
|
|||||||
}
|
}
|
||||||
|
|
||||||
template<typename ArgT, typename MatcherT>
|
template<typename ArgT, typename MatcherT>
|
||||||
inline void ResultBuilder::captureMatch( ArgT const& arg, MatcherT const& matcher,
|
void ResultBuilder::captureMatch( ArgT const& arg, MatcherT const& matcher,
|
||||||
char const* matcherString ) {
|
char const* matcherString ) {
|
||||||
MatchExpression<ArgT const&, MatcherT const&> expr( arg, matcher, matcherString );
|
MatchExpression<ArgT const&, MatcherT const&> expr( arg, matcher, matcherString );
|
||||||
setResultType( matcher.match( arg ) );
|
setResultType( matcher.match( arg ) );
|
||||||
@@ -2064,6 +2082,10 @@ namespace Catch {
|
|||||||
virtual void exceptionEarlyReported() = 0;
|
virtual void exceptionEarlyReported() = 0;
|
||||||
|
|
||||||
virtual void handleFatalErrorCondition( std::string const& message ) = 0;
|
virtual void handleFatalErrorCondition( std::string const& message ) = 0;
|
||||||
|
|
||||||
|
virtual bool lastAssertionPassed() = 0;
|
||||||
|
virtual void assertionPassed() = 0;
|
||||||
|
virtual void assertionRun() = 0;
|
||||||
};
|
};
|
||||||
|
|
||||||
IResultCapture& getResultCapture();
|
IResultCapture& getResultCapture();
|
||||||
@@ -2106,9 +2128,9 @@ namespace Catch{
|
|||||||
#if defined(__ppc64__) || defined(__ppc__)
|
#if defined(__ppc64__) || defined(__ppc__)
|
||||||
#define CATCH_TRAP() \
|
#define CATCH_TRAP() \
|
||||||
__asm__("li r0, 20\nsc\nnop\nli r0, 37\nli r4, 2\nsc\nnop\n" \
|
__asm__("li r0, 20\nsc\nnop\nli r0, 37\nli r4, 2\nsc\nnop\n" \
|
||||||
: : : "memory","r0","r3","r4" )
|
: : : "memory","r0","r3","r4" ) /* NOLINT */
|
||||||
#else
|
#else
|
||||||
#define CATCH_TRAP() __asm__("int $3\n" : : )
|
#define CATCH_TRAP() __asm__("int $3\n" : : /* NOLINT */ )
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#elif defined(CATCH_PLATFORM_LINUX)
|
#elif defined(CATCH_PLATFORM_LINUX)
|
||||||
@@ -2116,7 +2138,7 @@ namespace Catch{
|
|||||||
// directly at the location of the failing check instead of breaking inside
|
// directly at the location of the failing check instead of breaking inside
|
||||||
// raise() called from it, i.e. one stack frame below.
|
// raise() called from it, i.e. one stack frame below.
|
||||||
#if defined(__GNUC__) && (defined(__i386) || defined(__x86_64))
|
#if defined(__GNUC__) && (defined(__i386) || defined(__x86_64))
|
||||||
#define CATCH_TRAP() asm volatile ("int $3")
|
#define CATCH_TRAP() asm volatile ("int $3") /* NOLINT */
|
||||||
#else // Fall back to the generic way.
|
#else // Fall back to the generic way.
|
||||||
#include <signal.h>
|
#include <signal.h>
|
||||||
|
|
||||||
@@ -2147,6 +2169,12 @@ namespace Catch {
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#if !defined(CATCH_CONFIG_DISABLE_STRINGIFICATION)
|
||||||
|
# define CATCH_INTERNAL_STRINGIFY(expr) #expr
|
||||||
|
#else
|
||||||
|
# define CATCH_INTERNAL_STRINGIFY(expr) "Disabled by CATCH_CONFIG_DISABLE_STRINGIFICATION"
|
||||||
|
#endif
|
||||||
|
|
||||||
#if defined(CATCH_CONFIG_FAST_COMPILE)
|
#if defined(CATCH_CONFIG_FAST_COMPILE)
|
||||||
///////////////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////////////
|
||||||
// We can speedup compilation significantly by breaking into debugger lower in
|
// We can speedup compilation significantly by breaking into debugger lower in
|
||||||
@@ -2162,7 +2190,7 @@ namespace Catch {
|
|||||||
// the exception before it propagates back up to the runner.
|
// the exception before it propagates back up to the runner.
|
||||||
#define INTERNAL_CATCH_TEST_NO_TRY( macroName, resultDisposition, expr ) \
|
#define INTERNAL_CATCH_TEST_NO_TRY( macroName, resultDisposition, expr ) \
|
||||||
do { \
|
do { \
|
||||||
Catch::ResultBuilder __catchResult( macroName, CATCH_INTERNAL_LINEINFO, #expr, resultDisposition ); \
|
Catch::ResultBuilder __catchResult( macroName, CATCH_INTERNAL_LINEINFO, CATCH_INTERNAL_STRINGIFY(expr), resultDisposition ); \
|
||||||
__catchResult.setExceptionGuard(); \
|
__catchResult.setExceptionGuard(); \
|
||||||
CATCH_INTERNAL_SUPPRESS_PARENTHESES_WARNINGS \
|
CATCH_INTERNAL_SUPPRESS_PARENTHESES_WARNINGS \
|
||||||
( __catchResult <= expr ).endExpression(); \
|
( __catchResult <= expr ).endExpression(); \
|
||||||
@@ -2174,9 +2202,9 @@ namespace Catch {
|
|||||||
|
|
||||||
#define INTERNAL_CHECK_THAT_NO_TRY( macroName, matcher, resultDisposition, arg ) \
|
#define INTERNAL_CHECK_THAT_NO_TRY( macroName, matcher, resultDisposition, arg ) \
|
||||||
do { \
|
do { \
|
||||||
Catch::ResultBuilder __catchResult( macroName, CATCH_INTERNAL_LINEINFO, #arg ", " #matcher, resultDisposition ); \
|
Catch::ResultBuilder __catchResult( macroName, CATCH_INTERNAL_LINEINFO, CATCH_INTERNAL_STRINGIFY(arg) ", " CATCH_INTERNAL_STRINGIFY(matcher), resultDisposition ); \
|
||||||
__catchResult.setExceptionGuard(); \
|
__catchResult.setExceptionGuard(); \
|
||||||
__catchResult.captureMatch( arg, matcher, #matcher ); \
|
__catchResult.captureMatch( arg, matcher, CATCH_INTERNAL_STRINGIFY(matcher) ); \
|
||||||
__catchResult.unsetExceptionGuard(); \
|
__catchResult.unsetExceptionGuard(); \
|
||||||
INTERNAL_CATCH_REACT( __catchResult ) \
|
INTERNAL_CATCH_REACT( __catchResult ) \
|
||||||
} while( Catch::alwaysFalse() )
|
} while( Catch::alwaysFalse() )
|
||||||
@@ -2195,7 +2223,7 @@ namespace Catch {
|
|||||||
///////////////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////////////
|
||||||
#define INTERNAL_CATCH_TEST( macroName, resultDisposition, expr ) \
|
#define INTERNAL_CATCH_TEST( macroName, resultDisposition, expr ) \
|
||||||
do { \
|
do { \
|
||||||
Catch::ResultBuilder __catchResult( macroName, CATCH_INTERNAL_LINEINFO, #expr, resultDisposition ); \
|
Catch::ResultBuilder __catchResult( macroName, CATCH_INTERNAL_LINEINFO, CATCH_INTERNAL_STRINGIFY(expr), resultDisposition ); \
|
||||||
try { \
|
try { \
|
||||||
CATCH_INTERNAL_SUPPRESS_PARENTHESES_WARNINGS \
|
CATCH_INTERNAL_SUPPRESS_PARENTHESES_WARNINGS \
|
||||||
( __catchResult <= expr ).endExpression(); \
|
( __catchResult <= expr ).endExpression(); \
|
||||||
@@ -2211,17 +2239,17 @@ namespace Catch {
|
|||||||
///////////////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////////////
|
||||||
#define INTERNAL_CATCH_IF( macroName, resultDisposition, expr ) \
|
#define INTERNAL_CATCH_IF( macroName, resultDisposition, expr ) \
|
||||||
INTERNAL_CATCH_TEST( macroName, resultDisposition, expr ); \
|
INTERNAL_CATCH_TEST( macroName, resultDisposition, expr ); \
|
||||||
if( Catch::getResultCapture().getLastResult()->succeeded() )
|
if( Catch::getResultCapture().lastAssertionPassed() )
|
||||||
|
|
||||||
///////////////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////////////
|
||||||
#define INTERNAL_CATCH_ELSE( macroName, resultDisposition, expr ) \
|
#define INTERNAL_CATCH_ELSE( macroName, resultDisposition, expr ) \
|
||||||
INTERNAL_CATCH_TEST( macroName, resultDisposition, expr ); \
|
INTERNAL_CATCH_TEST( macroName, resultDisposition, expr ); \
|
||||||
if( !Catch::getResultCapture().getLastResult()->succeeded() )
|
if( !Catch::getResultCapture().lastAssertionPassed() )
|
||||||
|
|
||||||
///////////////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////////////
|
||||||
#define INTERNAL_CATCH_NO_THROW( macroName, resultDisposition, expr ) \
|
#define INTERNAL_CATCH_NO_THROW( macroName, resultDisposition, expr ) \
|
||||||
do { \
|
do { \
|
||||||
Catch::ResultBuilder __catchResult( macroName, CATCH_INTERNAL_LINEINFO, #expr, resultDisposition ); \
|
Catch::ResultBuilder __catchResult( macroName, CATCH_INTERNAL_LINEINFO, CATCH_INTERNAL_STRINGIFY(expr), resultDisposition ); \
|
||||||
try { \
|
try { \
|
||||||
static_cast<void>(expr); \
|
static_cast<void>(expr); \
|
||||||
__catchResult.captureResult( Catch::ResultWas::Ok ); \
|
__catchResult.captureResult( Catch::ResultWas::Ok ); \
|
||||||
@@ -2235,7 +2263,7 @@ namespace Catch {
|
|||||||
///////////////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////////////
|
||||||
#define INTERNAL_CATCH_THROWS( macroName, resultDisposition, matcher, expr ) \
|
#define INTERNAL_CATCH_THROWS( macroName, resultDisposition, matcher, expr ) \
|
||||||
do { \
|
do { \
|
||||||
Catch::ResultBuilder __catchResult( macroName, CATCH_INTERNAL_LINEINFO, #expr, resultDisposition, #matcher ); \
|
Catch::ResultBuilder __catchResult( macroName, CATCH_INTERNAL_LINEINFO, CATCH_INTERNAL_STRINGIFY(expr), resultDisposition, CATCH_INTERNAL_STRINGIFY(matcher) ); \
|
||||||
if( __catchResult.allowThrows() ) \
|
if( __catchResult.allowThrows() ) \
|
||||||
try { \
|
try { \
|
||||||
static_cast<void>(expr); \
|
static_cast<void>(expr); \
|
||||||
@@ -2252,7 +2280,7 @@ namespace Catch {
|
|||||||
///////////////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////////////
|
||||||
#define INTERNAL_CATCH_THROWS_AS( macroName, exceptionType, resultDisposition, expr ) \
|
#define INTERNAL_CATCH_THROWS_AS( macroName, exceptionType, resultDisposition, expr ) \
|
||||||
do { \
|
do { \
|
||||||
Catch::ResultBuilder __catchResult( macroName, CATCH_INTERNAL_LINEINFO, #expr ", " #exceptionType, resultDisposition ); \
|
Catch::ResultBuilder __catchResult( macroName, CATCH_INTERNAL_LINEINFO, CATCH_INTERNAL_STRINGIFY(expr) ", " CATCH_INTERNAL_STRINGIFY(exceptionType), resultDisposition ); \
|
||||||
if( __catchResult.allowThrows() ) \
|
if( __catchResult.allowThrows() ) \
|
||||||
try { \
|
try { \
|
||||||
static_cast<void>(expr); \
|
static_cast<void>(expr); \
|
||||||
@@ -2295,9 +2323,9 @@ namespace Catch {
|
|||||||
///////////////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////////////
|
||||||
#define INTERNAL_CHECK_THAT( macroName, matcher, resultDisposition, arg ) \
|
#define INTERNAL_CHECK_THAT( macroName, matcher, resultDisposition, arg ) \
|
||||||
do { \
|
do { \
|
||||||
Catch::ResultBuilder __catchResult( macroName, CATCH_INTERNAL_LINEINFO, #arg ", " #matcher, resultDisposition ); \
|
Catch::ResultBuilder __catchResult( macroName, CATCH_INTERNAL_LINEINFO, CATCH_INTERNAL_STRINGIFY(arg) ", " CATCH_INTERNAL_STRINGIFY(matcher), resultDisposition ); \
|
||||||
try { \
|
try { \
|
||||||
__catchResult.captureMatch( arg, matcher, #matcher ); \
|
__catchResult.captureMatch( arg, matcher, CATCH_INTERNAL_STRINGIFY(matcher) ); \
|
||||||
} catch( ... ) { \
|
} catch( ... ) { \
|
||||||
__catchResult.useActiveException( resultDisposition | Catch::ResultDisposition::ContinueOnFailure ); \
|
__catchResult.useActiveException( resultDisposition | Catch::ResultDisposition::ContinueOnFailure ); \
|
||||||
} \
|
} \
|
||||||
@@ -2776,13 +2804,6 @@ namespace Detail {
|
|||||||
m_value( value )
|
m_value( value )
|
||||||
{}
|
{}
|
||||||
|
|
||||||
Approx( Approx const& other )
|
|
||||||
: m_epsilon( other.m_epsilon ),
|
|
||||||
m_margin( other.m_margin ),
|
|
||||||
m_scale( other.m_scale ),
|
|
||||||
m_value( other.m_value )
|
|
||||||
{}
|
|
||||||
|
|
||||||
static Approx custom() {
|
static Approx custom() {
|
||||||
return Approx( 0 );
|
return Approx( 0 );
|
||||||
}
|
}
|
||||||
@@ -2810,7 +2831,8 @@ namespace Detail {
|
|||||||
if (relativeOK) {
|
if (relativeOK) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
return std::fabs(lhs_v - rhs.m_value) < rhs.m_margin;
|
|
||||||
|
return std::fabs(lhs_v - rhs.m_value) <= rhs.m_margin;
|
||||||
}
|
}
|
||||||
|
|
||||||
template <typename T, typename = typename std::enable_if<std::is_constructible<double, T>::value>::type>
|
template <typename T, typename = typename std::enable_if<std::is_constructible<double, T>::value>::type>
|
||||||
@@ -2882,7 +2904,7 @@ namespace Detail {
|
|||||||
if (relativeOK) {
|
if (relativeOK) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
return std::fabs(lhs - rhs.m_value) < rhs.m_margin;
|
return std::fabs(lhs - rhs.m_value) <= rhs.m_margin;
|
||||||
}
|
}
|
||||||
|
|
||||||
friend bool operator == ( Approx const& lhs, double rhs ) {
|
friend bool operator == ( Approx const& lhs, double rhs ) {
|
||||||
@@ -3706,7 +3728,7 @@ namespace Catch {
|
|||||||
ITagAliasRegistry const* m_tagAliases;
|
ITagAliasRegistry const* m_tagAliases;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
TestSpecParser( ITagAliasRegistry const& tagAliases ) : m_tagAliases( &tagAliases ) {}
|
TestSpecParser( ITagAliasRegistry const& tagAliases ) :m_mode(None), m_exclusion(false), m_start(0), m_pos(0), m_tagAliases( &tagAliases ) {}
|
||||||
|
|
||||||
TestSpecParser& parse( std::string const& arg ) {
|
TestSpecParser& parse( std::string const& arg ) {
|
||||||
m_mode = None;
|
m_mode = None;
|
||||||
@@ -3840,6 +3862,12 @@ namespace Catch {
|
|||||||
Yes,
|
Yes,
|
||||||
No
|
No
|
||||||
}; };
|
}; };
|
||||||
|
struct WaitForKeypress { enum When {
|
||||||
|
Never,
|
||||||
|
BeforeStart = 1,
|
||||||
|
BeforeExit = 2,
|
||||||
|
BeforeStartAndExit = BeforeStart | BeforeExit
|
||||||
|
}; };
|
||||||
|
|
||||||
class TestSpec;
|
class TestSpec;
|
||||||
|
|
||||||
@@ -3890,6 +3918,7 @@ namespace Catch {
|
|||||||
|
|
||||||
std::ostream& cout();
|
std::ostream& cout();
|
||||||
std::ostream& cerr();
|
std::ostream& cerr();
|
||||||
|
std::ostream& clog();
|
||||||
|
|
||||||
struct IStream {
|
struct IStream {
|
||||||
virtual ~IStream() CATCH_NOEXCEPT;
|
virtual ~IStream() CATCH_NOEXCEPT;
|
||||||
@@ -3952,13 +3981,15 @@ namespace Catch {
|
|||||||
showHelp( false ),
|
showHelp( false ),
|
||||||
showInvisibles( false ),
|
showInvisibles( false ),
|
||||||
filenamesAsTags( false ),
|
filenamesAsTags( false ),
|
||||||
|
libIdentify( false ),
|
||||||
abortAfter( -1 ),
|
abortAfter( -1 ),
|
||||||
rngSeed( 0 ),
|
rngSeed( 0 ),
|
||||||
verbosity( Verbosity::Normal ),
|
verbosity( Verbosity::Normal ),
|
||||||
warnings( WarnAbout::Nothing ),
|
warnings( WarnAbout::Nothing ),
|
||||||
showDurations( ShowDurations::DefaultForReporter ),
|
showDurations( ShowDurations::DefaultForReporter ),
|
||||||
runOrder( RunTests::InDeclarationOrder ),
|
runOrder( RunTests::InDeclarationOrder ),
|
||||||
useColour( UseColour::Auto )
|
useColour( UseColour::Auto ),
|
||||||
|
waitForKeypress( WaitForKeypress::Never )
|
||||||
{}
|
{}
|
||||||
|
|
||||||
bool listTests;
|
bool listTests;
|
||||||
@@ -3973,6 +4004,7 @@ namespace Catch {
|
|||||||
bool showHelp;
|
bool showHelp;
|
||||||
bool showInvisibles;
|
bool showInvisibles;
|
||||||
bool filenamesAsTags;
|
bool filenamesAsTags;
|
||||||
|
bool libIdentify;
|
||||||
|
|
||||||
int abortAfter;
|
int abortAfter;
|
||||||
unsigned int rngSeed;
|
unsigned int rngSeed;
|
||||||
@@ -3982,6 +4014,7 @@ namespace Catch {
|
|||||||
ShowDurations::OrNot showDurations;
|
ShowDurations::OrNot showDurations;
|
||||||
RunTests::InWhatOrder runOrder;
|
RunTests::InWhatOrder runOrder;
|
||||||
UseColour::YesOrNo useColour;
|
UseColour::YesOrNo useColour;
|
||||||
|
WaitForKeypress::When waitForKeypress;
|
||||||
|
|
||||||
std::string outputFilename;
|
std::string outputFilename;
|
||||||
std::string name;
|
std::string name;
|
||||||
@@ -4222,7 +4255,7 @@ namespace Tbc {
|
|||||||
return oss.str();
|
return oss.str();
|
||||||
}
|
}
|
||||||
|
|
||||||
inline friend std::ostream& operator << ( std::ostream& _stream, Text const& _text ) {
|
friend std::ostream& operator << ( std::ostream& _stream, Text const& _text ) {
|
||||||
for( Text::const_iterator it = _text.begin(), itEnd = _text.end();
|
for( Text::const_iterator it = _text.begin(), itEnd = _text.end();
|
||||||
it != itEnd; ++it ) {
|
it != itEnd; ++it ) {
|
||||||
if( it != _text.begin() )
|
if( it != _text.begin() )
|
||||||
@@ -5175,6 +5208,18 @@ namespace Catch {
|
|||||||
else
|
else
|
||||||
throw std::runtime_error( "colour mode must be one of: auto, yes or no" );
|
throw std::runtime_error( "colour mode must be one of: auto, yes or no" );
|
||||||
}
|
}
|
||||||
|
inline void setWaitForKeypress( ConfigData& config, std::string const& keypress ) {
|
||||||
|
std::string keypressLc = toLower( keypress );
|
||||||
|
if( keypressLc == "start" )
|
||||||
|
config.waitForKeypress = WaitForKeypress::BeforeStart;
|
||||||
|
else if( keypressLc == "exit" )
|
||||||
|
config.waitForKeypress = WaitForKeypress::BeforeExit;
|
||||||
|
else if( keypressLc == "both" )
|
||||||
|
config.waitForKeypress = WaitForKeypress::BeforeStartAndExit;
|
||||||
|
else
|
||||||
|
throw std::runtime_error( "keypress argument must be one of: start, exit or both. '" + keypress + "' not recognised" );
|
||||||
|
};
|
||||||
|
|
||||||
inline void forceColour( ConfigData& config ) {
|
inline void forceColour( ConfigData& config ) {
|
||||||
config.useColour = UseColour::Yes;
|
config.useColour = UseColour::Yes;
|
||||||
}
|
}
|
||||||
@@ -5310,6 +5355,14 @@ namespace Catch {
|
|||||||
.describe( "should output be colourised" )
|
.describe( "should output be colourised" )
|
||||||
.bind( &setUseColour, "yes|no" );
|
.bind( &setUseColour, "yes|no" );
|
||||||
|
|
||||||
|
cli["--libidentify"]
|
||||||
|
.describe( "report name and version according to libidentify standard" )
|
||||||
|
.bind( &ConfigData::libIdentify );
|
||||||
|
|
||||||
|
cli["--wait-for-keypress"]
|
||||||
|
.describe( "waits for a keypress before exiting" )
|
||||||
|
.bind( &setWaitForKeypress, "start|exit|both" );
|
||||||
|
|
||||||
return cli;
|
return cli;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -6574,6 +6627,29 @@ namespace Catch {
|
|||||||
std::string& m_targetString;
|
std::string& m_targetString;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
// StdErr has two constituent streams in C++, std::cerr and std::clog
|
||||||
|
// This means that we need to redirect 2 streams into 1 to keep proper
|
||||||
|
// order of writes and cannot use StreamRedirect on its own
|
||||||
|
class StdErrRedirect {
|
||||||
|
public:
|
||||||
|
StdErrRedirect(std::string& targetString)
|
||||||
|
:m_cerrBuf( cerr().rdbuf() ), m_clogBuf(clog().rdbuf()),
|
||||||
|
m_targetString(targetString){
|
||||||
|
cerr().rdbuf(m_oss.rdbuf());
|
||||||
|
clog().rdbuf(m_oss.rdbuf());
|
||||||
|
}
|
||||||
|
~StdErrRedirect() {
|
||||||
|
m_targetString += m_oss.str();
|
||||||
|
cerr().rdbuf(m_cerrBuf);
|
||||||
|
clog().rdbuf(m_clogBuf);
|
||||||
|
}
|
||||||
|
private:
|
||||||
|
std::streambuf* m_cerrBuf;
|
||||||
|
std::streambuf* m_clogBuf;
|
||||||
|
std::ostringstream m_oss;
|
||||||
|
std::string& m_targetString;
|
||||||
|
};
|
||||||
|
|
||||||
///////////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
class RunContext : public IResultCapture, public IRunner {
|
class RunContext : public IResultCapture, public IRunner {
|
||||||
@@ -6664,7 +6740,10 @@ namespace Catch {
|
|||||||
m_totals.assertions.passed++;
|
m_totals.assertions.passed++;
|
||||||
}
|
}
|
||||||
else if( !result.isOk() ) {
|
else if( !result.isOk() ) {
|
||||||
m_totals.assertions.failed++;
|
if( m_activeTestCase->getTestCaseInfo().okToFail() )
|
||||||
|
m_totals.assertions.failedButOk++;
|
||||||
|
else
|
||||||
|
m_totals.assertions.failed++;
|
||||||
}
|
}
|
||||||
|
|
||||||
// We have no use for the return value (whether messages should be cleared), because messages were made scoped
|
// We have no use for the return value (whether messages should be cleared), because messages were made scoped
|
||||||
@@ -6676,6 +6755,23 @@ namespace Catch {
|
|||||||
m_lastResult = result;
|
m_lastResult = result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
virtual bool lastAssertionPassed()
|
||||||
|
{
|
||||||
|
return m_totals.assertions.passed == (m_prevPassed + 1);
|
||||||
|
}
|
||||||
|
|
||||||
|
virtual void assertionPassed()
|
||||||
|
{
|
||||||
|
m_totals.assertions.passed++;
|
||||||
|
m_lastAssertionInfo.capturedExpression = "{Unknown expression after the reported line}";
|
||||||
|
m_lastAssertionInfo.macroName = "";
|
||||||
|
}
|
||||||
|
|
||||||
|
virtual void assertionRun()
|
||||||
|
{
|
||||||
|
m_prevPassed = m_totals.assertions.passed;
|
||||||
|
}
|
||||||
|
|
||||||
virtual bool sectionStarted (
|
virtual bool sectionStarted (
|
||||||
SectionInfo const& sectionInfo,
|
SectionInfo const& sectionInfo,
|
||||||
Counts& assertions
|
Counts& assertions
|
||||||
@@ -6776,6 +6872,7 @@ namespace Catch {
|
|||||||
|
|
||||||
Totals deltaTotals;
|
Totals deltaTotals;
|
||||||
deltaTotals.testCases.failed = 1;
|
deltaTotals.testCases.failed = 1;
|
||||||
|
deltaTotals.assertions.failed = 1;
|
||||||
m_reporter->testCaseEnded( TestCaseStats( testInfo,
|
m_reporter->testCaseEnded( TestCaseStats( testInfo,
|
||||||
deltaTotals,
|
deltaTotals,
|
||||||
std::string(),
|
std::string(),
|
||||||
@@ -6810,7 +6907,7 @@ namespace Catch {
|
|||||||
timer.start();
|
timer.start();
|
||||||
if( m_reporter->getPreferences().shouldRedirectStdOut ) {
|
if( m_reporter->getPreferences().shouldRedirectStdOut ) {
|
||||||
StreamRedirect coutRedir( Catch::cout(), redirectedCout );
|
StreamRedirect coutRedir( Catch::cout(), redirectedCout );
|
||||||
StreamRedirect cerrRedir( Catch::cerr(), redirectedCerr );
|
StdErrRedirect errRedir( redirectedCerr );
|
||||||
invokeActiveTestCase();
|
invokeActiveTestCase();
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
@@ -6835,12 +6932,6 @@ namespace Catch {
|
|||||||
Counts assertions = m_totals.assertions - prevAssertions;
|
Counts assertions = m_totals.assertions - prevAssertions;
|
||||||
bool missingAssertions = testForMissingAssertions( assertions );
|
bool missingAssertions = testForMissingAssertions( assertions );
|
||||||
|
|
||||||
if( testCaseInfo.okToFail() ) {
|
|
||||||
std::swap( assertions.failedButOk, assertions.failed );
|
|
||||||
m_totals.assertions.failed -= assertions.failedButOk;
|
|
||||||
m_totals.assertions.failedButOk += assertions.failedButOk;
|
|
||||||
}
|
|
||||||
|
|
||||||
SectionStats testCaseSectionStats( testCaseSection, assertions, duration, missingAssertions );
|
SectionStats testCaseSectionStats( testCaseSection, assertions, duration, missingAssertions );
|
||||||
m_reporter->sectionEnded( testCaseSectionStats );
|
m_reporter->sectionEnded( testCaseSectionStats );
|
||||||
}
|
}
|
||||||
@@ -6886,6 +6977,7 @@ namespace Catch {
|
|||||||
std::vector<SectionEndInfo> m_unfinishedSections;
|
std::vector<SectionEndInfo> m_unfinishedSections;
|
||||||
std::vector<ITracker*> m_activeSections;
|
std::vector<ITracker*> m_activeSections;
|
||||||
TrackerContext m_trackerContext;
|
TrackerContext m_trackerContext;
|
||||||
|
size_t m_prevPassed;
|
||||||
bool m_shouldReportUnexpected;
|
bool m_shouldReportUnexpected;
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -6944,10 +7036,14 @@ namespace Catch {
|
|||||||
return reporter;
|
return reporter;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#if !defined(CATCH_CONFIG_DEFAULT_REPORTER)
|
||||||
|
#define CATCH_CONFIG_DEFAULT_REPORTER "console"
|
||||||
|
#endif
|
||||||
|
|
||||||
Ptr<IStreamingReporter> makeReporter( Ptr<Config> const& config ) {
|
Ptr<IStreamingReporter> makeReporter( Ptr<Config> const& config ) {
|
||||||
std::vector<std::string> reporters = config->getReporterNames();
|
std::vector<std::string> reporters = config->getReporterNames();
|
||||||
if( reporters.empty() )
|
if( reporters.empty() )
|
||||||
reporters.push_back( "console" );
|
reporters.push_back( CATCH_CONFIG_DEFAULT_REPORTER );
|
||||||
|
|
||||||
Ptr<IStreamingReporter> reporter;
|
Ptr<IStreamingReporter> reporter;
|
||||||
for( std::vector<std::string>::const_iterator it = reporters.begin(), itEnd = reporters.end();
|
for( std::vector<std::string>::const_iterator it = reporters.begin(), itEnd = reporters.end();
|
||||||
@@ -7007,11 +7103,11 @@ namespace Catch {
|
|||||||
if( lastSlash != std::string::npos )
|
if( lastSlash != std::string::npos )
|
||||||
filename = filename.substr( lastSlash+1 );
|
filename = filename.substr( lastSlash+1 );
|
||||||
|
|
||||||
std::string::size_type lastDot = filename.find_last_of( "." );
|
std::string::size_type lastDot = filename.find_last_of( '.' );
|
||||||
if( lastDot != std::string::npos )
|
if( lastDot != std::string::npos )
|
||||||
filename = filename.substr( 0, lastDot );
|
filename = filename.substr( 0, lastDot );
|
||||||
|
|
||||||
tags.insert( "#" + filename );
|
tags.insert( '#' + filename );
|
||||||
setTags( test, tags );
|
setTags( test, tags );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -7042,6 +7138,13 @@ namespace Catch {
|
|||||||
m_cli.usage( Catch::cout(), processName );
|
m_cli.usage( Catch::cout(), processName );
|
||||||
Catch::cout() << "For more detail usage please see the project docs\n" << std::endl;
|
Catch::cout() << "For more detail usage please see the project docs\n" << std::endl;
|
||||||
}
|
}
|
||||||
|
void libIdentify() {
|
||||||
|
Catch::cout()
|
||||||
|
<< std::left << std::setw(16) << "description: " << "A Catch test executable\n"
|
||||||
|
<< std::left << std::setw(16) << "category: " << "testframework\n"
|
||||||
|
<< std::left << std::setw(16) << "framework: " << "Catch Test\n"
|
||||||
|
<< std::left << std::setw(16) << "version: " << libraryVersion() << std::endl;
|
||||||
|
}
|
||||||
|
|
||||||
int applyCommandLine( int argc, char const* const* const argv, OnUnusedOptions::DoWhat unusedOptionBehaviour = OnUnusedOptions::Fail ) {
|
int applyCommandLine( int argc, char const* const* const argv, OnUnusedOptions::DoWhat unusedOptionBehaviour = OnUnusedOptions::Fail ) {
|
||||||
try {
|
try {
|
||||||
@@ -7049,6 +7152,8 @@ namespace Catch {
|
|||||||
m_unusedTokens = m_cli.parseInto( Clara::argsToVector( argc, argv ), m_configData );
|
m_unusedTokens = m_cli.parseInto( Clara::argsToVector( argc, argv ), m_configData );
|
||||||
if( m_configData.showHelp )
|
if( m_configData.showHelp )
|
||||||
showHelp( m_configData.processName );
|
showHelp( m_configData.processName );
|
||||||
|
if( m_configData.libIdentify )
|
||||||
|
libIdentify();
|
||||||
m_config.reset();
|
m_config.reset();
|
||||||
}
|
}
|
||||||
catch( std::exception& ex ) {
|
catch( std::exception& ex ) {
|
||||||
@@ -7105,7 +7210,36 @@ namespace Catch {
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
int run() {
|
int run() {
|
||||||
if( m_configData.showHelp )
|
if( ( m_configData.waitForKeypress & WaitForKeypress::BeforeStart ) != 0 ) {
|
||||||
|
Catch::cout() << "...waiting for enter/ return before starting" << std::endl;
|
||||||
|
static_cast<void>(std::getchar());
|
||||||
|
}
|
||||||
|
int exitCode = runInternal();
|
||||||
|
if( ( m_configData.waitForKeypress & WaitForKeypress::BeforeExit ) != 0 ) {
|
||||||
|
Catch::cout() << "...waiting for enter/ return before exiting, with code: " << exitCode << std::endl;
|
||||||
|
static_cast<void>(std::getchar());
|
||||||
|
}
|
||||||
|
return exitCode;
|
||||||
|
}
|
||||||
|
|
||||||
|
Clara::CommandLine<ConfigData> const& cli() const {
|
||||||
|
return m_cli;
|
||||||
|
}
|
||||||
|
std::vector<Clara::Parser::Token> const& unusedTokens() const {
|
||||||
|
return m_unusedTokens;
|
||||||
|
}
|
||||||
|
ConfigData& configData() {
|
||||||
|
return m_configData;
|
||||||
|
}
|
||||||
|
Config& config() {
|
||||||
|
if( !m_config )
|
||||||
|
m_config = new Config( m_configData );
|
||||||
|
return *m_config;
|
||||||
|
}
|
||||||
|
private:
|
||||||
|
|
||||||
|
int runInternal() {
|
||||||
|
if( m_configData.showHelp || m_configData.libIdentify )
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
try
|
try
|
||||||
@@ -7129,21 +7263,6 @@ namespace Catch {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Clara::CommandLine<ConfigData> const& cli() const {
|
|
||||||
return m_cli;
|
|
||||||
}
|
|
||||||
std::vector<Clara::Parser::Token> const& unusedTokens() const {
|
|
||||||
return m_unusedTokens;
|
|
||||||
}
|
|
||||||
ConfigData& configData() {
|
|
||||||
return m_configData;
|
|
||||||
}
|
|
||||||
Config& config() {
|
|
||||||
if( !m_config )
|
|
||||||
m_config = new Config( m_configData );
|
|
||||||
return *m_config;
|
|
||||||
}
|
|
||||||
private:
|
|
||||||
Clara::CommandLine<ConfigData> m_cli;
|
Clara::CommandLine<ConfigData> m_cli;
|
||||||
std::vector<Clara::Parser::Token> m_unusedTokens;
|
std::vector<Clara::Parser::Token> m_unusedTokens;
|
||||||
ConfigData m_configData;
|
ConfigData m_configData;
|
||||||
@@ -7168,14 +7287,14 @@ namespace Catch {
|
|||||||
namespace Catch {
|
namespace Catch {
|
||||||
|
|
||||||
struct RandomNumberGenerator {
|
struct RandomNumberGenerator {
|
||||||
typedef std::ptrdiff_t result_type;
|
typedef unsigned int result_type;
|
||||||
|
|
||||||
result_type operator()( result_type n ) const { return std::rand() % n; }
|
result_type operator()( result_type n ) const { return std::rand() % n; }
|
||||||
|
|
||||||
#ifdef CATCH_CONFIG_CPP11_SHUFFLE
|
#ifdef CATCH_CONFIG_CPP11_SHUFFLE
|
||||||
static constexpr result_type min() { return 0; }
|
static constexpr result_type (min)() { return 0; }
|
||||||
static constexpr result_type max() { return 1000000; }
|
static constexpr result_type (max)() { return 1000000; }
|
||||||
result_type operator()() const { return std::rand() % max(); }
|
result_type operator()() const { return std::rand() % (max)(); }
|
||||||
#endif
|
#endif
|
||||||
template<typename V>
|
template<typename V>
|
||||||
static void shuffle( V& vector ) {
|
static void shuffle( V& vector ) {
|
||||||
@@ -7663,6 +7782,9 @@ namespace Catch {
|
|||||||
std::ostream& cerr() {
|
std::ostream& cerr() {
|
||||||
return std::cerr;
|
return std::cerr;
|
||||||
}
|
}
|
||||||
|
std::ostream& clog() {
|
||||||
|
return std::clog;
|
||||||
|
}
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -8033,6 +8155,8 @@ namespace Catch {
|
|||||||
|
|
||||||
namespace Catch {
|
namespace Catch {
|
||||||
|
|
||||||
|
AssertionInfo::AssertionInfo():macroName(""), capturedExpression(""), resultDisposition(ResultDisposition::Normal), secondArg(""){}
|
||||||
|
|
||||||
AssertionInfo::AssertionInfo( char const * _macroName,
|
AssertionInfo::AssertionInfo( char const * _macroName,
|
||||||
SourceLineInfo const& _lineInfo,
|
SourceLineInfo const& _lineInfo,
|
||||||
char const * _capturedExpression,
|
char const * _capturedExpression,
|
||||||
@@ -8084,7 +8208,7 @@ namespace Catch {
|
|||||||
|
|
||||||
std::string AssertionResult::getExpression() const {
|
std::string AssertionResult::getExpression() const {
|
||||||
if( isFalseTest( m_info.resultDisposition ) )
|
if( isFalseTest( m_info.resultDisposition ) )
|
||||||
return '!' + capturedExpressionWithSecondArgument(m_info.capturedExpression, m_info.secondArg);
|
return "!(" + capturedExpressionWithSecondArgument(m_info.capturedExpression, m_info.secondArg) + ")";
|
||||||
else
|
else
|
||||||
return capturedExpressionWithSecondArgument(m_info.capturedExpression, m_info.secondArg);
|
return capturedExpressionWithSecondArgument(m_info.capturedExpression, m_info.secondArg);
|
||||||
}
|
}
|
||||||
@@ -8342,7 +8466,7 @@ namespace Catch {
|
|||||||
}
|
}
|
||||||
|
|
||||||
inline Version libraryVersion() {
|
inline Version libraryVersion() {
|
||||||
static Version version( 1, 9, 6, "", 0 );
|
static Version version( 1, 12, 1, "", 0 );
|
||||||
return version;
|
return version;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -8377,11 +8501,18 @@ namespace Catch {
|
|||||||
: m_info( other.m_info )
|
: m_info( other.m_info )
|
||||||
{}
|
{}
|
||||||
|
|
||||||
|
#if defined(_MSC_VER)
|
||||||
|
#pragma warning(push)
|
||||||
|
#pragma warning(disable:4996) // std::uncaught_exception is deprecated in C++17
|
||||||
|
#endif
|
||||||
ScopedMessage::~ScopedMessage() {
|
ScopedMessage::~ScopedMessage() {
|
||||||
if ( !std::uncaught_exception() ){
|
if ( !std::uncaught_exception() ){
|
||||||
getResultCapture().popScopedMessage(m_info);
|
getResultCapture().popScopedMessage(m_info);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
#if defined(_MSC_VER)
|
||||||
|
#pragma warning(pop)
|
||||||
|
#endif
|
||||||
|
|
||||||
} // end namespace Catch
|
} // end namespace Catch
|
||||||
|
|
||||||
@@ -9050,15 +9181,14 @@ namespace Catch {
|
|||||||
: m_assertionInfo( macroName, lineInfo, capturedExpression, resultDisposition, secondArg ),
|
: m_assertionInfo( macroName, lineInfo, capturedExpression, resultDisposition, secondArg ),
|
||||||
m_shouldDebugBreak( false ),
|
m_shouldDebugBreak( false ),
|
||||||
m_shouldThrow( false ),
|
m_shouldThrow( false ),
|
||||||
m_guardException( false )
|
m_guardException( false ),
|
||||||
{
|
m_usedStream( false )
|
||||||
m_stream().oss.str("");
|
{}
|
||||||
}
|
|
||||||
|
|
||||||
ResultBuilder::~ResultBuilder() {
|
ResultBuilder::~ResultBuilder() {
|
||||||
#if defined(CATCH_CONFIG_FAST_COMPILE)
|
#if defined(CATCH_CONFIG_FAST_COMPILE)
|
||||||
if ( m_guardException ) {
|
if ( m_guardException ) {
|
||||||
m_stream().oss << "Exception translation was disabled by CATCH_CONFIG_FAST_COMPILE";
|
stream().oss << "Exception translation was disabled by CATCH_CONFIG_FAST_COMPILE";
|
||||||
captureResult( ResultWas::ThrewException );
|
captureResult( ResultWas::ThrewException );
|
||||||
getCurrentContext().getResultCapture()->exceptionEarlyReported();
|
getCurrentContext().getResultCapture()->exceptionEarlyReported();
|
||||||
}
|
}
|
||||||
@@ -9075,13 +9205,25 @@ namespace Catch {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void ResultBuilder::endExpression( DecomposedExpression const& expr ) {
|
void ResultBuilder::endExpression( DecomposedExpression const& expr ) {
|
||||||
AssertionResult result = build( expr );
|
// Flip bool results if FalseTest flag is set
|
||||||
handleResult( result );
|
if( isFalseTest( m_assertionInfo.resultDisposition ) ) {
|
||||||
|
m_data.negate( expr.isBinaryExpression() );
|
||||||
|
}
|
||||||
|
|
||||||
|
getResultCapture().assertionRun();
|
||||||
|
|
||||||
|
if(getCurrentContext().getConfig()->includeSuccessfulResults() || m_data.resultType != ResultWas::Ok)
|
||||||
|
{
|
||||||
|
AssertionResult result = build( expr );
|
||||||
|
handleResult( result );
|
||||||
|
}
|
||||||
|
else
|
||||||
|
getResultCapture().assertionPassed();
|
||||||
}
|
}
|
||||||
|
|
||||||
void ResultBuilder::useActiveException( ResultDisposition::Flags resultDisposition ) {
|
void ResultBuilder::useActiveException( ResultDisposition::Flags resultDisposition ) {
|
||||||
m_assertionInfo.resultDisposition = resultDisposition;
|
m_assertionInfo.resultDisposition = resultDisposition;
|
||||||
m_stream().oss << Catch::translateActiveException();
|
stream().oss << Catch::translateActiveException();
|
||||||
captureResult( ResultWas::ThrewException );
|
captureResult( ResultWas::ThrewException );
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -9163,12 +9305,8 @@ namespace Catch {
|
|||||||
assert( m_data.resultType != ResultWas::Unknown );
|
assert( m_data.resultType != ResultWas::Unknown );
|
||||||
AssertionResultData data = m_data;
|
AssertionResultData data = m_data;
|
||||||
|
|
||||||
// Flip bool results if FalseTest flag is set
|
if(m_usedStream)
|
||||||
if( isFalseTest( m_assertionInfo.resultDisposition ) ) {
|
data.message = m_stream().oss.str();
|
||||||
data.negate( expr.isBinaryExpression() );
|
|
||||||
}
|
|
||||||
|
|
||||||
data.message = m_stream().oss.str();
|
|
||||||
data.decomposedExpression = &expr; // for lazy reconstruction
|
data.decomposedExpression = &expr; // for lazy reconstruction
|
||||||
return AssertionResult( m_assertionInfo, data );
|
return AssertionResult( m_assertionInfo, data );
|
||||||
}
|
}
|
||||||
@@ -9597,7 +9735,8 @@ namespace Catch {
|
|||||||
BySectionInfo( SectionInfo const& other ) : m_other( other ) {}
|
BySectionInfo( SectionInfo const& other ) : m_other( other ) {}
|
||||||
BySectionInfo( BySectionInfo const& other ) : m_other( other.m_other ) {}
|
BySectionInfo( BySectionInfo const& other ) : m_other( other.m_other ) {}
|
||||||
bool operator() ( Ptr<SectionNode> const& node ) const {
|
bool operator() ( Ptr<SectionNode> const& node ) const {
|
||||||
return node->stats.sectionInfo.lineInfo == m_other.lineInfo;
|
return ((node->stats.sectionInfo.name == m_other.name) &&
|
||||||
|
(node->stats.sectionInfo.lineInfo == m_other.lineInfo));
|
||||||
}
|
}
|
||||||
private:
|
private:
|
||||||
void operator=( BySectionInfo const& );
|
void operator=( BySectionInfo const& );
|
||||||
@@ -10148,12 +10287,12 @@ namespace Catch {
|
|||||||
|
|
||||||
bool includeResults = m_config->includeSuccessfulResults() || !result.isOk();
|
bool includeResults = m_config->includeSuccessfulResults() || !result.isOk();
|
||||||
|
|
||||||
if( includeResults ) {
|
if( includeResults || result.getResultType() == ResultWas::Warning ) {
|
||||||
// Print any info messages in <Info> tags.
|
// Print any info messages in <Info> tags.
|
||||||
for( std::vector<MessageInfo>::const_iterator it = assertionStats.infoMessages.begin(), itEnd = assertionStats.infoMessages.end();
|
for( std::vector<MessageInfo>::const_iterator it = assertionStats.infoMessages.begin(), itEnd = assertionStats.infoMessages.end();
|
||||||
it != itEnd;
|
it != itEnd;
|
||||||
++it ) {
|
++it ) {
|
||||||
if( it->type == ResultWas::Info ) {
|
if( it->type == ResultWas::Info && includeResults ) {
|
||||||
m_xml.scopedElement( "Info" )
|
m_xml.scopedElement( "Info" )
|
||||||
.writeText( it->message );
|
.writeText( it->message );
|
||||||
} else if ( it->type == ResultWas::Warning ) {
|
} else if ( it->type == ResultWas::Warning ) {
|
||||||
@@ -10319,6 +10458,7 @@ namespace Catch {
|
|||||||
JunitReporter( ReporterConfig const& _config )
|
JunitReporter( ReporterConfig const& _config )
|
||||||
: CumulativeReporterBase( _config ),
|
: CumulativeReporterBase( _config ),
|
||||||
xml( _config.stream() ),
|
xml( _config.stream() ),
|
||||||
|
unexpectedExceptions( 0 ),
|
||||||
m_okToFail( false )
|
m_okToFail( false )
|
||||||
{
|
{
|
||||||
m_reporterPrefs.shouldRedirectStdOut = true;
|
m_reporterPrefs.shouldRedirectStdOut = true;
|
||||||
|
7
test_package/CMakeLists.txt
Normal file
7
test_package/CMakeLists.txt
Normal file
@@ -0,0 +1,7 @@
|
|||||||
|
cmake_minimum_required(VERSION 3.0)
|
||||||
|
project(CatchTest CXX)
|
||||||
|
|
||||||
|
include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake)
|
||||||
|
conan_basic_setup()
|
||||||
|
|
||||||
|
add_executable(${CMAKE_PROJECT_NAME} MainTest.cpp)
|
21
test_package/MainTest.cpp
Normal file
21
test_package/MainTest.cpp
Normal file
@@ -0,0 +1,21 @@
|
|||||||
|
/*
|
||||||
|
* Created by Phil on 22/10/2010.
|
||||||
|
* Copyright 2010 Two Blue Cubes Ltd
|
||||||
|
*
|
||||||
|
* Distributed under the Boost Software License, Version 1.0. (See accompanying
|
||||||
|
* file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
|
||||||
|
*/
|
||||||
|
#define CATCH_CONFIG_MAIN
|
||||||
|
#include "catch.hpp"
|
||||||
|
|
||||||
|
unsigned int Factorial( unsigned int number ) {
|
||||||
|
return number > 1 ? Factorial(number-1)*number : 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
TEST_CASE( "Factorials are computed", "[factorial]" ) {
|
||||||
|
REQUIRE( Factorial(0) == 1 );
|
||||||
|
REQUIRE( Factorial(1) == 1 );
|
||||||
|
REQUIRE( Factorial(2) == 2 );
|
||||||
|
REQUIRE( Factorial(3) == 6 );
|
||||||
|
REQUIRE( Factorial(10) == 3628800 );
|
||||||
|
}
|
21
test_package/conanfile.py
Normal file
21
test_package/conanfile.py
Normal file
@@ -0,0 +1,21 @@
|
|||||||
|
#!/usr/bin/env python
|
||||||
|
from os import getenv
|
||||||
|
from os import path
|
||||||
|
from conans import ConanFile
|
||||||
|
from conans import CMake
|
||||||
|
|
||||||
|
|
||||||
|
class CatchConanTest(ConanFile):
|
||||||
|
generators = "cmake"
|
||||||
|
settings = "os", "compiler", "arch", "build_type"
|
||||||
|
username = getenv("CONAN_USERNAME", "philsquared")
|
||||||
|
channel = getenv("CONAN_CHANNEL", "testing")
|
||||||
|
requires = "Catch/1.12.1@%s/%s" % (username, channel)
|
||||||
|
|
||||||
|
def build(self):
|
||||||
|
cmake = CMake(self)
|
||||||
|
cmake.configure(build_dir="./")
|
||||||
|
cmake.build()
|
||||||
|
|
||||||
|
def test(self):
|
||||||
|
self.run(path.join("bin", "CatchTest"))
|
Reference in New Issue
Block a user