mirror of
https://github.com/catchorg/Catch2.git
synced 2025-09-17 10:25:39 +02:00
Compare commits
74 Commits
v1.2.1-dev
...
v2.0.0-dev
Author | SHA1 | Date | |
---|---|---|---|
![]() |
f4ba8aaf19 | ||
![]() |
25899ea20e | ||
![]() |
36cee598cf | ||
![]() |
506b915f7f | ||
![]() |
5cab3cc1b8 | ||
![]() |
d2642325ae | ||
![]() |
8fa41d96c7 | ||
![]() |
693355cc75 | ||
![]() |
5e0db60443 | ||
![]() |
ce547c1799 | ||
![]() |
28aece6a7a | ||
![]() |
bd8688cded | ||
![]() |
c70170e904 | ||
![]() |
6789dfa2ba | ||
![]() |
fdc8a2b2df | ||
![]() |
eea9357284 | ||
![]() |
73968f29a5 | ||
![]() |
b77b45a390 | ||
![]() |
2ebe11660c | ||
![]() |
e55273db19 | ||
![]() |
e4fa62a14e | ||
![]() |
a49f088032 | ||
![]() |
ed6e9128a4 | ||
![]() |
92356769f1 | ||
![]() |
d10b73f9f1 | ||
![]() |
71fd2c2fdf | ||
![]() |
08844e7e57 | ||
![]() |
054e3c5b43 | ||
![]() |
f3e7722cc6 | ||
![]() |
315c83ad87 | ||
![]() |
9576ad9108 | ||
![]() |
e91738103c | ||
![]() |
8c32b49d5f | ||
![]() |
ece529ae7c | ||
![]() |
9e42153fe5 | ||
![]() |
c81778ecd0 | ||
![]() |
f5642be7b4 | ||
![]() |
7e34619f03 | ||
![]() |
4636be9744 | ||
![]() |
015e07100e | ||
![]() |
bc8840cbb8 | ||
![]() |
471bd2556a | ||
![]() |
aa49823bc0 | ||
![]() |
52a417df7b | ||
![]() |
0b523db6b9 | ||
![]() |
b8515929b8 | ||
![]() |
3deb3e010f | ||
![]() |
73a140fb9e | ||
![]() |
ef62b578e2 | ||
![]() |
f4389b4fdb | ||
![]() |
4b99be6a9a | ||
![]() |
293e54dcbe | ||
![]() |
9a6a0865f2 | ||
![]() |
2c6411e70a | ||
![]() |
1cb993970a | ||
![]() |
b3b2352045 | ||
![]() |
c9a188df45 | ||
![]() |
e904aa7f6e | ||
![]() |
d43a47efca | ||
![]() |
a0de07d45b | ||
![]() |
0c1c9fa922 | ||
![]() |
166ca2e819 | ||
![]() |
d234ed1a67 | ||
![]() |
7fd7c5b8c8 | ||
![]() |
312b94e532 | ||
![]() |
40d0d2f656 | ||
![]() |
19520157fb | ||
![]() |
ad7edd0680 | ||
![]() |
8a05f46a37 | ||
![]() |
e73583d556 | ||
![]() |
afcc38efc5 | ||
![]() |
368714e7aa | ||
![]() |
4cb74761d9 | ||
![]() |
c06e1909ae |
164
.travis.yml
164
.travis.yml
@@ -1,19 +1,163 @@
|
|||||||
language: cpp
|
language: cpp
|
||||||
|
sudo: false
|
||||||
|
|
||||||
compiler:
|
cache:
|
||||||
- clang
|
ccache: true
|
||||||
- gcc
|
directories:
|
||||||
|
- $HOME/.ccache
|
||||||
|
|
||||||
env:
|
env:
|
||||||
- BUILD_TYPE=Debug
|
global:
|
||||||
- BUILD_TYPE=Release
|
- USE_CCACHE=1
|
||||||
|
- CCACHE_COMPRESS=1
|
||||||
|
- CCACHE_MAXSIZE=200M
|
||||||
|
- CCACHE_CPP2=1
|
||||||
|
|
||||||
|
|
||||||
|
matrix:
|
||||||
|
include:
|
||||||
|
|
||||||
|
# 1/ Linux Clang Builds
|
||||||
|
- os: linux
|
||||||
|
compiler: clang
|
||||||
|
addons: &clang35
|
||||||
|
apt:
|
||||||
|
sources: ['llvm-toolchain-precise-3.5', 'ubuntu-toolchain-r-test']
|
||||||
|
packages: ['clang-3.5']
|
||||||
|
env: COMPILER='ccache clang++-3.5' BUILD_TYPE='Release'
|
||||||
|
|
||||||
|
- os: linux
|
||||||
|
compiler: clang
|
||||||
|
addons: *clang35
|
||||||
|
env: COMPILER='ccache clang++-3.5' BUILD_TYPE='Debug'
|
||||||
|
|
||||||
|
|
||||||
|
- os: linux
|
||||||
|
compiler: clang
|
||||||
|
addons: &clang36
|
||||||
|
apt:
|
||||||
|
sources: ['llvm-toolchain-precise-3.6', 'ubuntu-toolchain-r-test']
|
||||||
|
packages: ['clang-3.6']
|
||||||
|
env: COMPILER='ccache clang++-3.6' BUILD_TYPE='Release'
|
||||||
|
|
||||||
|
- os: linux
|
||||||
|
compiler: clang
|
||||||
|
addons: *clang36
|
||||||
|
env: COMPILER='ccache clang++-3.6' BUILD_TYPE='Debug'
|
||||||
|
|
||||||
|
|
||||||
|
- os: linux
|
||||||
|
compiler: clang
|
||||||
|
addons: &clang37
|
||||||
|
apt:
|
||||||
|
sources: ['llvm-toolchain-precise-3.7', 'ubuntu-toolchain-r-test']
|
||||||
|
packages: ['clang-3.7']
|
||||||
|
env: COMPILER='ccache clang++-3.7' BUILD_TYPE='Release'
|
||||||
|
|
||||||
|
- os: linux
|
||||||
|
compiler: clang
|
||||||
|
addons: *clang37
|
||||||
|
env: COMPILER='ccache clang++-3.7' BUILD_TYPE='Debug'
|
||||||
|
|
||||||
|
|
||||||
|
- os: linux
|
||||||
|
compiler: clang
|
||||||
|
addons: &clang38
|
||||||
|
apt:
|
||||||
|
sources: ['llvm-toolchain-precise', 'ubuntu-toolchain-r-test']
|
||||||
|
packages: ['clang-3.8']
|
||||||
|
env: COMPILER='ccache clang++-3.8' BUILD_TYPE='Release'
|
||||||
|
|
||||||
|
- os: linux
|
||||||
|
compiler: clang
|
||||||
|
addons: *clang38
|
||||||
|
env: COMPILER='ccache clang++-3.8' BUILD_TYPE='Debug'
|
||||||
|
|
||||||
|
|
||||||
|
# 2/ Linux GCC Builds
|
||||||
|
- os: linux
|
||||||
|
compiler: gcc
|
||||||
|
addons: &gcc48
|
||||||
|
apt:
|
||||||
|
sources: ['ubuntu-toolchain-r-test']
|
||||||
|
packages: ['g++-4.8']
|
||||||
|
env: COMPILER='ccache g++-4.8' BUILD_TYPE='Release'
|
||||||
|
|
||||||
|
- os: linux
|
||||||
|
compiler: gcc
|
||||||
|
addons: *gcc48
|
||||||
|
env: COMPILER='ccache g++-4.8' BUILD_TYPE='Debug'
|
||||||
|
|
||||||
|
|
||||||
|
- os: linux
|
||||||
|
compiler: gcc
|
||||||
|
addons: &gcc49
|
||||||
|
apt:
|
||||||
|
sources: ['ubuntu-toolchain-r-test']
|
||||||
|
packages: ['g++-4.9']
|
||||||
|
env: COMPILER='ccache g++-4.9' BUILD_TYPE='Release'
|
||||||
|
|
||||||
|
- os: linux
|
||||||
|
compiler: gcc
|
||||||
|
addons: *gcc49
|
||||||
|
env: COMPILER='ccache g++-4.9' BUILD_TYPE='Debug'
|
||||||
|
|
||||||
|
|
||||||
|
- os: linux
|
||||||
|
compiler: gcc
|
||||||
|
addons: &gcc5
|
||||||
|
apt:
|
||||||
|
sources: ['ubuntu-toolchain-r-test']
|
||||||
|
packages: ['g++-5']
|
||||||
|
env: COMPILER='ccache g++-5' BUILD_TYPE='Release'
|
||||||
|
|
||||||
|
- os: linux
|
||||||
|
compiler: gcc
|
||||||
|
addons: *gcc5
|
||||||
|
env: COMPILER='ccache g++-5' BUILD_TYPE='Debug'
|
||||||
|
|
||||||
|
|
||||||
|
# 3/ OSX Clang Builds
|
||||||
|
- os: osx
|
||||||
|
osx_image: xcode6.4
|
||||||
|
compiler: clang
|
||||||
|
env: COMPILER='ccache clang++' BUILD_TYPE='Debug'
|
||||||
|
|
||||||
|
- os: osx
|
||||||
|
osx_image: xcode6.4
|
||||||
|
compiler: clang
|
||||||
|
env: COMPILER='ccache clang++' BUILD_TYPE='Release'
|
||||||
|
|
||||||
|
|
||||||
|
- os: osx
|
||||||
|
osx_image: xcode7
|
||||||
|
compiler: clang
|
||||||
|
env: COMPILER='ccache clang++' BUILD_TYPE='Debug'
|
||||||
|
|
||||||
|
- os: osx
|
||||||
|
osx_image: xcode7
|
||||||
|
compiler: clang
|
||||||
|
env: COMPILER='ccache clang++' BUILD_TYPE='Release'
|
||||||
|
|
||||||
|
|
||||||
install:
|
install:
|
||||||
- cmake -Hprojects/CMake -BBuild -DCMAKE_BUILD_TYPE=$BUILD_TYPE
|
- DEPS_DIR="${TRAVIS_BUILD_DIR}/deps"
|
||||||
|
- mkdir -p ${DEPS_DIR} && cd ${DEPS_DIR}
|
||||||
|
- |
|
||||||
|
if [[ "${TRAVIS_OS_NAME}" == "linux" ]]; then
|
||||||
|
CMAKE_URL="http://www.cmake.org/files/v3.3/cmake-3.3.2-Linux-x86_64.tar.gz"
|
||||||
|
mkdir cmake && travis_retry wget --quiet -O - ${CMAKE_URL} | tar --strip-components=1 -xz -C cmake
|
||||||
|
export PATH=${DEPS_DIR}/cmake/bin:${PATH}
|
||||||
|
elif [[ "${TRAVIS_OS_NAME}" == "osx" ]]; then
|
||||||
|
brew install cmake ccache
|
||||||
|
fi
|
||||||
|
|
||||||
|
before_script:
|
||||||
|
- export CXX=${COMPILER}
|
||||||
|
- cd ${TRAVIS_BUILD_DIR}
|
||||||
|
- cmake -Hprojects/CMake -BBuild -DCMAKE_BUILD_TYPE=${BUILD_TYPE}
|
||||||
- cd Build
|
- cd Build
|
||||||
- make
|
|
||||||
- cd ..
|
|
||||||
|
|
||||||
script:
|
script:
|
||||||
- cd Build
|
- make -j 2
|
||||||
- ctest -V
|
- ctest -V -j 2
|
||||||
|
@@ -1,6 +1,6 @@
|
|||||||

|

|
||||||
|
|
||||||
*v1.2.1-develop.11*
|
*v2.0.0-develop.2*
|
||||||
|
|
||||||
Build status (on Travis CI) [](https://travis-ci.org/philsquared/Catch)
|
Build status (on Travis CI) [](https://travis-ci.org/philsquared/Catch)
|
||||||
|
|
||||||
|
@@ -58,6 +58,9 @@ This can be useful on certain platforms that do not provide ```std::cout``` and
|
|||||||
CATCH_CONFIG_CPP11_IS_ENUM // std::is_enum is supported?
|
CATCH_CONFIG_CPP11_IS_ENUM // std::is_enum is supported?
|
||||||
CATCH_CONFIG_CPP11_TUPLE // std::tuple is supported
|
CATCH_CONFIG_CPP11_TUPLE // std::tuple is supported
|
||||||
CATCH_CONFIG_VARIADIC_MACROS // Usually pre-C++11 compiler extensions are sufficient
|
CATCH_CONFIG_VARIADIC_MACROS // Usually pre-C++11 compiler extensions are sufficient
|
||||||
|
CATCH_CONFIG_CPP11_LONG_LONG // generates overloads for the long long type
|
||||||
|
CATCH_CONFIG_CPP11_OVERRIDE // CATCH_OVERRIDE expands to override (for virtual function implementations)
|
||||||
|
CATCH_CONFIG_CPP11_UNIQUE_PTR // Use std::unique_ptr instead of std::auto_ptr
|
||||||
|
|
||||||
Catch has some basic compiler detection that will attempt to select the appropriate mix of these macros. However being incomplete - and often without access to the respective compilers - this detection tends to be conservative.
|
Catch has some basic compiler detection that will attempt to select the appropriate mix of these macros. However being incomplete - and often without access to the respective compilers - this detection tends to be conservative.
|
||||||
So overriding control is given to the user. If a compiler supports a feature (and Catch does not already detect it) then one or more of these may be defined to enable it (or suppress it, in some cases). If you do do this please raise an issue, specifying your compiler version (ideally with an idea of how to detect it) and stating that it has such support.
|
So overriding control is given to the user. If a compiler supports a feature (and Catch does not already detect it) then one or more of these may be defined to enable it (or suppress it, in some cases). If you do do this please raise an issue, specifying your compiler version (ideally with an idea of how to detect it) and stating that it has such support.
|
||||||
|
@@ -55,6 +55,16 @@ namespace Catch {
|
|||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
|
## Exceptions
|
||||||
|
|
||||||
|
By default all exceptions deriving from `std::exception` will be translated to strings by calling the `what()` method. For exception types that do not derive from `std::exception` - or if `what()` does not return a suitable string - use `CATCH_TRANSLATE_EXCEPTION`. This defines a function that takes your exception type, by reference, and returns a string. It can appear anywhere in the code - it doesn't have to be in the same translation unit. For example:
|
||||||
|
|
||||||
|
```
|
||||||
|
CATCH_TRANSLATE_EXCEPTION( MyType& ex ) {
|
||||||
|
return ex.message();
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
---
|
---
|
||||||
|
|
||||||
[Home](Readme.md)
|
[Home](Readme.md)
|
||||||
|
@@ -96,7 +96,7 @@ Although this was a simple test it's been enough to demonstrate a few things abo
|
|||||||
|
|
||||||
Most test frameworks have a class-based fixture mechanism. That is, test cases map to methods on a class and common setup and teardown can be performed in ```setup()``` and ```teardown()``` methods (or constructor/ destructor in languages, like C++, that support deterministic destruction).
|
Most test frameworks have a class-based fixture mechanism. That is, test cases map to methods on a class and common setup and teardown can be performed in ```setup()``` and ```teardown()``` methods (or constructor/ destructor in languages, like C++, that support deterministic destruction).
|
||||||
|
|
||||||
While Catch fully supports this way of working there are a few problems with the approach. In particular, the way your code must be split up and the blunt granularity of cause problems. You can only have one setup/ teardown pair across a set of methods, but sometimes you want slightly different setup in each method, or you may even want several levels of setup (a concept which we will clarify later on in this tutorial). It was <a href="http://jamesnewkirk.typepad.com/posts/2007/09/why-you-should-.html">problems like these</a> that led James Newkirk, who led the team that built NUnit, to start again from scratch and <a href="http://jamesnewkirk.typepad.com/posts/2007/09/announcing-xuni.html">build xUnit</a>).
|
While Catch fully supports this way of working there are a few problems with the approach. In particular the way your code must be split up, and the blunt granularity of it, may cause problems. You can only have one setup/ teardown pair across a set of methods, but sometimes you want slightly different setup in each method, or you may even want several levels of setup (a concept which we will clarify later on in this tutorial). It was <a href="http://jamesnewkirk.typepad.com/posts/2007/09/why-you-should-.html">problems like these</a> that led James Newkirk, who led the team that built NUnit, to start again from scratch and <a href="http://jamesnewkirk.typepad.com/posts/2007/09/announcing-xuni.html">build xUnit</a>).
|
||||||
|
|
||||||
Catch takes a different approach (to both NUnit and xUnit) that is a more natural fit for C++ and the C family of languages. This is best explained through an example:
|
Catch takes a different approach (to both NUnit and xUnit) that is a more natural fit for C++ and the C family of languages. This is best explained through an example:
|
||||||
|
|
||||||
|
@@ -29,11 +29,9 @@
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include "internal/catch_notimplemented_exception.h"
|
#include "internal/catch_notimplemented_exception.h"
|
||||||
#include "internal/catch_context.h"
|
|
||||||
#include "internal/catch_test_registry.hpp"
|
#include "internal/catch_test_registry.hpp"
|
||||||
#include "internal/catch_capture.hpp"
|
#include "internal/catch_capture.hpp"
|
||||||
#include "internal/catch_section.h"
|
#include "internal/catch_section.h"
|
||||||
#include "internal/catch_generators.hpp"
|
|
||||||
#include "internal/catch_interfaces_exception.h"
|
#include "internal/catch_interfaces_exception.h"
|
||||||
#include "internal/catch_approx.hpp"
|
#include "internal/catch_approx.hpp"
|
||||||
#include "internal/catch_matchers.hpp"
|
#include "internal/catch_matchers.hpp"
|
||||||
@@ -43,7 +41,6 @@
|
|||||||
// These files are included here so the single_include script doesn't put them
|
// These files are included here so the single_include script doesn't put them
|
||||||
// in the conditionally compiled sections
|
// in the conditionally compiled sections
|
||||||
#include "internal/catch_test_case_info.h"
|
#include "internal/catch_test_case_info.h"
|
||||||
#include "internal/catch_interfaces_runner.h"
|
|
||||||
|
|
||||||
#ifdef __OBJC__
|
#ifdef __OBJC__
|
||||||
#include "internal/catch_objc.hpp"
|
#include "internal/catch_objc.hpp"
|
||||||
@@ -99,6 +96,7 @@
|
|||||||
#define CATCH_TEST_CASE( ... ) INTERNAL_CATCH_TESTCASE( __VA_ARGS__ )
|
#define CATCH_TEST_CASE( ... ) INTERNAL_CATCH_TESTCASE( __VA_ARGS__ )
|
||||||
#define CATCH_TEST_CASE_METHOD( className, ... ) INTERNAL_CATCH_TEST_CASE_METHOD( className, __VA_ARGS__ )
|
#define CATCH_TEST_CASE_METHOD( className, ... ) INTERNAL_CATCH_TEST_CASE_METHOD( className, __VA_ARGS__ )
|
||||||
#define CATCH_METHOD_AS_TEST_CASE( method, ... ) INTERNAL_CATCH_METHOD_AS_TEST_CASE( method, __VA_ARGS__ )
|
#define CATCH_METHOD_AS_TEST_CASE( method, ... ) INTERNAL_CATCH_METHOD_AS_TEST_CASE( method, __VA_ARGS__ )
|
||||||
|
#define CATCH_REGISTER_TEST_CASE( ... ) INTERNAL_CATCH_REGISTER_TESTCASE( __VA_ARGS__ )
|
||||||
#define CATCH_SECTION( ... ) INTERNAL_CATCH_SECTION( __VA_ARGS__ )
|
#define CATCH_SECTION( ... ) INTERNAL_CATCH_SECTION( __VA_ARGS__ )
|
||||||
#define CATCH_FAIL( ... ) INTERNAL_CATCH_MSG( Catch::ResultWas::ExplicitFailure, Catch::ResultDisposition::Normal, "CATCH_FAIL", __VA_ARGS__ )
|
#define CATCH_FAIL( ... ) INTERNAL_CATCH_MSG( Catch::ResultWas::ExplicitFailure, Catch::ResultDisposition::Normal, "CATCH_FAIL", __VA_ARGS__ )
|
||||||
#define CATCH_SUCCEED( ... ) INTERNAL_CATCH_MSG( Catch::ResultWas::Ok, Catch::ResultDisposition::ContinueOnFailure, "CATCH_SUCCEED", __VA_ARGS__ )
|
#define CATCH_SUCCEED( ... ) INTERNAL_CATCH_MSG( Catch::ResultWas::Ok, Catch::ResultDisposition::ContinueOnFailure, "CATCH_SUCCEED", __VA_ARGS__ )
|
||||||
@@ -106,6 +104,7 @@
|
|||||||
#define CATCH_TEST_CASE( name, description ) INTERNAL_CATCH_TESTCASE( name, description )
|
#define CATCH_TEST_CASE( name, description ) INTERNAL_CATCH_TESTCASE( name, description )
|
||||||
#define CATCH_TEST_CASE_METHOD( className, name, description ) INTERNAL_CATCH_TEST_CASE_METHOD( className, name, description )
|
#define CATCH_TEST_CASE_METHOD( className, name, description ) INTERNAL_CATCH_TEST_CASE_METHOD( className, name, description )
|
||||||
#define CATCH_METHOD_AS_TEST_CASE( method, name, description ) INTERNAL_CATCH_METHOD_AS_TEST_CASE( method, name, description )
|
#define CATCH_METHOD_AS_TEST_CASE( method, name, description ) INTERNAL_CATCH_METHOD_AS_TEST_CASE( method, name, description )
|
||||||
|
#define CATCH_REGISTER_TEST_CASE( function, name, description ) INTERNAL_CATCH_REGISTER_TESTCASE( function, name, description )
|
||||||
#define CATCH_SECTION( name, description ) INTERNAL_CATCH_SECTION( name, description )
|
#define CATCH_SECTION( name, description ) INTERNAL_CATCH_SECTION( name, description )
|
||||||
#define CATCH_FAIL( msg ) INTERNAL_CATCH_MSG( Catch::ResultWas::ExplicitFailure, Catch::ResultDisposition::Normal, "CATCH_FAIL", msg )
|
#define CATCH_FAIL( msg ) INTERNAL_CATCH_MSG( Catch::ResultWas::ExplicitFailure, Catch::ResultDisposition::Normal, "CATCH_FAIL", msg )
|
||||||
#define CATCH_SUCCEED( msg ) INTERNAL_CATCH_MSG( Catch::ResultWas::Ok, Catch::ResultDisposition::ContinueOnFailure, "CATCH_SUCCEED", msg )
|
#define CATCH_SUCCEED( msg ) INTERNAL_CATCH_MSG( Catch::ResultWas::Ok, Catch::ResultDisposition::ContinueOnFailure, "CATCH_SUCCEED", msg )
|
||||||
@@ -115,8 +114,6 @@
|
|||||||
#define CATCH_REGISTER_REPORTER( name, reporterType ) INTERNAL_CATCH_REGISTER_REPORTER( name, reporterType )
|
#define CATCH_REGISTER_REPORTER( name, reporterType ) INTERNAL_CATCH_REGISTER_REPORTER( name, reporterType )
|
||||||
#define CATCH_REGISTER_LEGACY_REPORTER( name, reporterType ) INTERNAL_CATCH_REGISTER_LEGACY_REPORTER( name, reporterType )
|
#define CATCH_REGISTER_LEGACY_REPORTER( name, reporterType ) INTERNAL_CATCH_REGISTER_LEGACY_REPORTER( name, reporterType )
|
||||||
|
|
||||||
#define CATCH_GENERATE( expr) INTERNAL_CATCH_GENERATE( expr )
|
|
||||||
|
|
||||||
// "BDD-style" convenience wrappers
|
// "BDD-style" convenience wrappers
|
||||||
#ifdef CATCH_CONFIG_VARIADIC_MACROS
|
#ifdef CATCH_CONFIG_VARIADIC_MACROS
|
||||||
#define CATCH_SCENARIO( ... ) CATCH_TEST_CASE( "Scenario: " __VA_ARGS__ )
|
#define CATCH_SCENARIO( ... ) CATCH_TEST_CASE( "Scenario: " __VA_ARGS__ )
|
||||||
@@ -166,6 +163,7 @@
|
|||||||
#define TEST_CASE( ... ) INTERNAL_CATCH_TESTCASE( __VA_ARGS__ )
|
#define TEST_CASE( ... ) INTERNAL_CATCH_TESTCASE( __VA_ARGS__ )
|
||||||
#define TEST_CASE_METHOD( className, ... ) INTERNAL_CATCH_TEST_CASE_METHOD( className, __VA_ARGS__ )
|
#define TEST_CASE_METHOD( className, ... ) INTERNAL_CATCH_TEST_CASE_METHOD( className, __VA_ARGS__ )
|
||||||
#define METHOD_AS_TEST_CASE( method, ... ) INTERNAL_CATCH_METHOD_AS_TEST_CASE( method, __VA_ARGS__ )
|
#define METHOD_AS_TEST_CASE( method, ... ) INTERNAL_CATCH_METHOD_AS_TEST_CASE( method, __VA_ARGS__ )
|
||||||
|
#define REGISTER_TEST_CASE( ... ) INTERNAL_CATCH_REGISTER_TESTCASE( __VA_ARGS__ )
|
||||||
#define SECTION( ... ) INTERNAL_CATCH_SECTION( __VA_ARGS__ )
|
#define SECTION( ... ) INTERNAL_CATCH_SECTION( __VA_ARGS__ )
|
||||||
#define FAIL( ... ) INTERNAL_CATCH_MSG( Catch::ResultWas::ExplicitFailure, Catch::ResultDisposition::Normal, "FAIL", __VA_ARGS__ )
|
#define FAIL( ... ) INTERNAL_CATCH_MSG( Catch::ResultWas::ExplicitFailure, Catch::ResultDisposition::Normal, "FAIL", __VA_ARGS__ )
|
||||||
#define SUCCEED( ... ) INTERNAL_CATCH_MSG( Catch::ResultWas::Ok, Catch::ResultDisposition::ContinueOnFailure, "SUCCEED", __VA_ARGS__ )
|
#define SUCCEED( ... ) INTERNAL_CATCH_MSG( Catch::ResultWas::Ok, Catch::ResultDisposition::ContinueOnFailure, "SUCCEED", __VA_ARGS__ )
|
||||||
@@ -173,6 +171,7 @@
|
|||||||
#define TEST_CASE( name, description ) INTERNAL_CATCH_TESTCASE( name, description )
|
#define TEST_CASE( name, description ) INTERNAL_CATCH_TESTCASE( name, description )
|
||||||
#define TEST_CASE_METHOD( className, name, description ) INTERNAL_CATCH_TEST_CASE_METHOD( className, name, description )
|
#define TEST_CASE_METHOD( className, name, description ) INTERNAL_CATCH_TEST_CASE_METHOD( className, name, description )
|
||||||
#define METHOD_AS_TEST_CASE( method, name, description ) INTERNAL_CATCH_METHOD_AS_TEST_CASE( method, name, description )
|
#define METHOD_AS_TEST_CASE( method, name, description ) INTERNAL_CATCH_METHOD_AS_TEST_CASE( method, name, description )
|
||||||
|
#define REGISTER_TEST_CASE( method, name, description ) INTERNAL_CATCH_REGISTER_TESTCASE( method, name, description )
|
||||||
#define SECTION( name, description ) INTERNAL_CATCH_SECTION( name, description )
|
#define SECTION( name, description ) INTERNAL_CATCH_SECTION( name, description )
|
||||||
#define FAIL( msg ) INTERNAL_CATCH_MSG( Catch::ResultWas::ExplicitFailure, Catch::ResultDisposition::Normal, "FAIL", msg )
|
#define FAIL( msg ) INTERNAL_CATCH_MSG( Catch::ResultWas::ExplicitFailure, Catch::ResultDisposition::Normal, "FAIL", msg )
|
||||||
#define SUCCEED( msg ) INTERNAL_CATCH_MSG( Catch::ResultWas::Ok, Catch::ResultDisposition::ContinueOnFailure, "SUCCEED", msg )
|
#define SUCCEED( msg ) INTERNAL_CATCH_MSG( Catch::ResultWas::Ok, Catch::ResultDisposition::ContinueOnFailure, "SUCCEED", msg )
|
||||||
@@ -182,8 +181,6 @@
|
|||||||
#define REGISTER_REPORTER( name, reporterType ) INTERNAL_CATCH_REGISTER_REPORTER( name, reporterType )
|
#define REGISTER_REPORTER( name, reporterType ) INTERNAL_CATCH_REGISTER_REPORTER( name, reporterType )
|
||||||
#define REGISTER_LEGACY_REPORTER( name, reporterType ) INTERNAL_CATCH_REGISTER_LEGACY_REPORTER( name, reporterType )
|
#define REGISTER_LEGACY_REPORTER( name, reporterType ) INTERNAL_CATCH_REGISTER_LEGACY_REPORTER( name, reporterType )
|
||||||
|
|
||||||
#define GENERATE( expr) INTERNAL_CATCH_GENERATE( expr )
|
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#define CATCH_TRANSLATE_EXCEPTION( signature ) INTERNAL_CATCH_TRANSLATE_EXCEPTION( signature )
|
#define CATCH_TRANSLATE_EXCEPTION( signature ) INTERNAL_CATCH_TRANSLATE_EXCEPTION( signature )
|
||||||
|
@@ -10,7 +10,7 @@
|
|||||||
|
|
||||||
#include "internal/catch_commandline.hpp"
|
#include "internal/catch_commandline.hpp"
|
||||||
#include "internal/catch_list.hpp"
|
#include "internal/catch_list.hpp"
|
||||||
#include "internal/catch_runner_impl.hpp"
|
#include "internal/catch_run_context.hpp"
|
||||||
#include "internal/catch_test_spec.hpp"
|
#include "internal/catch_test_spec.hpp"
|
||||||
#include "internal/catch_version.h"
|
#include "internal/catch_version.h"
|
||||||
#include "internal/catch_text.h"
|
#include "internal/catch_text.h"
|
||||||
@@ -21,11 +21,7 @@
|
|||||||
|
|
||||||
namespace Catch {
|
namespace Catch {
|
||||||
|
|
||||||
Ptr<IStreamingReporter> makeReporter( Ptr<Config> const& config ) {
|
Ptr<IStreamingReporter> createReporter( std::string const& reporterName, Ptr<Config> const& config ) {
|
||||||
std::string reporterName = config->getReporterName().empty()
|
|
||||||
? "console"
|
|
||||||
: config->getReporterName();
|
|
||||||
|
|
||||||
Ptr<IStreamingReporter> reporter = getRegistryHub().getReporterRegistry().create( reporterName, config.get() );
|
Ptr<IStreamingReporter> reporter = getRegistryHub().getReporterRegistry().create( reporterName, config.get() );
|
||||||
if( !reporter ) {
|
if( !reporter ) {
|
||||||
std::ostringstream oss;
|
std::ostringstream oss;
|
||||||
@@ -35,26 +31,36 @@ namespace Catch {
|
|||||||
return reporter;
|
return reporter;
|
||||||
}
|
}
|
||||||
|
|
||||||
void openStreamInto( Ptr<Config> const& config, std::ofstream& ofs ) {
|
Ptr<IStreamingReporter> makeReporter( Ptr<Config> const& config ) {
|
||||||
// Open output file, if specified
|
std::vector<std::string> reporters = config->getReporterNames();
|
||||||
if( !config->getFilename().empty() ) {
|
if( reporters.empty() )
|
||||||
ofs.open( config->getFilename().c_str() );
|
reporters.push_back( "console" );
|
||||||
if( ofs.fail() ) {
|
|
||||||
std::ostringstream oss;
|
Ptr<IStreamingReporter> reporter;
|
||||||
oss << "Unable to open file: '" << config->getFilename() << "'";
|
for( std::vector<std::string>::const_iterator it = reporters.begin(), itEnd = reporters.end();
|
||||||
throw std::domain_error( oss.str() );
|
it != itEnd;
|
||||||
}
|
++it )
|
||||||
config->setStreamBuf( ofs.rdbuf() );
|
reporter = addReporter( reporter, createReporter( *it, config ) );
|
||||||
|
return reporter;
|
||||||
}
|
}
|
||||||
|
Ptr<IStreamingReporter> addListeners( Ptr<IConfig const> const& config, Ptr<IStreamingReporter> reporters ) {
|
||||||
|
IReporterRegistry::Listeners listeners = getRegistryHub().getReporterRegistry().getListeners();
|
||||||
|
for( IReporterRegistry::Listeners::const_iterator it = listeners.begin(), itEnd = listeners.end();
|
||||||
|
it != itEnd;
|
||||||
|
++it )
|
||||||
|
reporters = addReporter(reporters, (*it)->create( ReporterConfig( config ) ) );
|
||||||
|
return reporters;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
Totals runTests( Ptr<Config> const& config ) {
|
Totals runTests( Ptr<Config> const& config ) {
|
||||||
|
|
||||||
std::ofstream ofs;
|
Ptr<IConfig const> iconfig = config.get();
|
||||||
openStreamInto( config, ofs );
|
|
||||||
Ptr<IStreamingReporter> reporter = makeReporter( config );
|
|
||||||
|
|
||||||
RunContext context( config.get(), reporter );
|
Ptr<IStreamingReporter> reporter = makeReporter( config );
|
||||||
|
reporter = addListeners( iconfig, reporter );
|
||||||
|
|
||||||
|
RunContext context( iconfig, reporter );
|
||||||
|
|
||||||
Totals totals;
|
Totals totals;
|
||||||
|
|
||||||
@@ -64,36 +70,22 @@ namespace Catch {
|
|||||||
if( !testSpec.hasFilters() )
|
if( !testSpec.hasFilters() )
|
||||||
testSpec = TestSpecParser( ITagAliasRegistry::get() ).parse( "~[.]" ).testSpec(); // All not hidden tests
|
testSpec = TestSpecParser( ITagAliasRegistry::get() ).parse( "~[.]" ).testSpec(); // All not hidden tests
|
||||||
|
|
||||||
std::vector<TestCase> testCases;
|
std::vector<TestCase> const& allTestCases = getAllTestCasesSorted( *iconfig );
|
||||||
getRegistryHub().getTestCaseRegistry().getFilteredTests( testSpec, *config, testCases );
|
for( std::vector<TestCase>::const_iterator it = allTestCases.begin(), itEnd = allTestCases.end();
|
||||||
|
|
||||||
std::set<TestCase> testsAlreadyRun;
|
|
||||||
for( std::vector<TestCase>::const_iterator it = testCases.begin(), itEnd = testCases.end();
|
|
||||||
it != itEnd;
|
it != itEnd;
|
||||||
++it ) {
|
++it ) {
|
||||||
if( testsAlreadyRun.find( *it ) == testsAlreadyRun.end() ) {
|
if( !context.isAborting() && matchTest( *it, testSpec, *iconfig ) )
|
||||||
|
|
||||||
if( context.aborting() )
|
|
||||||
break;
|
|
||||||
|
|
||||||
totals += context.runTest( *it );
|
totals += context.runTest( *it );
|
||||||
testsAlreadyRun.insert( *it );
|
else
|
||||||
}
|
|
||||||
}
|
|
||||||
std::vector<TestCase> skippedTestCases;
|
|
||||||
getRegistryHub().getTestCaseRegistry().getFilteredTests( testSpec, *config, skippedTestCases, true );
|
|
||||||
|
|
||||||
for( std::vector<TestCase>::const_iterator it = skippedTestCases.begin(), itEnd = skippedTestCases.end();
|
|
||||||
it != itEnd;
|
|
||||||
++it )
|
|
||||||
reporter->skipTest( *it );
|
reporter->skipTest( *it );
|
||||||
|
}
|
||||||
|
|
||||||
context.testGroupEnded( config->name(), totals, 1, 1 );
|
context.testGroupEnded( iconfig->name(), totals, 1, 1 );
|
||||||
return totals;
|
return totals;
|
||||||
}
|
}
|
||||||
|
|
||||||
void applyFilenamesAsTags() {
|
void applyFilenamesAsTags( IConfig const& config ) {
|
||||||
std::vector<TestCase> const& tests = getRegistryHub().getTestCaseRegistry().getAllTests();
|
std::vector<TestCase> const& tests = getAllTestCasesSorted( config );
|
||||||
for(std::size_t i = 0; i < tests.size(); ++i ) {
|
for(std::size_t i = 0; i < tests.size(); ++i ) {
|
||||||
TestCase& test = const_cast<TestCase&>( tests[i] );
|
TestCase& test = const_cast<TestCase&>( tests[i] );
|
||||||
std::set<std::string> tags = test.tags;
|
std::set<std::string> tags = test.tags;
|
||||||
@@ -139,7 +131,7 @@ namespace Catch {
|
|||||||
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;
|
||||||
}
|
}
|
||||||
|
|
||||||
int applyCommandLine( int argc, char* const argv[], OnUnusedOptions::DoWhat unusedOptionBehaviour = OnUnusedOptions::Fail ) {
|
int applyCommandLine( int argc, char const* const argv[], OnUnusedOptions::DoWhat unusedOptionBehaviour = OnUnusedOptions::Fail ) {
|
||||||
try {
|
try {
|
||||||
m_cli.setThrowOnUnrecognisedTokens( unusedOptionBehaviour == OnUnusedOptions::Fail );
|
m_cli.setThrowOnUnrecognisedTokens( unusedOptionBehaviour == OnUnusedOptions::Fail );
|
||||||
m_unusedTokens = m_cli.parseInto( argc, argv, m_configData );
|
m_unusedTokens = m_cli.parseInto( argc, argv, m_configData );
|
||||||
@@ -166,7 +158,7 @@ namespace Catch {
|
|||||||
m_config.reset();
|
m_config.reset();
|
||||||
}
|
}
|
||||||
|
|
||||||
int run( int argc, char* const argv[] ) {
|
int run( int argc, char const* const argv[] ) {
|
||||||
|
|
||||||
int returnCode = applyCommandLine( argc, argv );
|
int returnCode = applyCommandLine( argc, argv );
|
||||||
if( returnCode == 0 )
|
if( returnCode == 0 )
|
||||||
@@ -182,11 +174,11 @@ namespace Catch {
|
|||||||
{
|
{
|
||||||
config(); // Force config to be constructed
|
config(); // Force config to be constructed
|
||||||
|
|
||||||
if( m_configData.filenamesAsTags )
|
|
||||||
applyFilenamesAsTags();
|
|
||||||
|
|
||||||
seedRng( *m_config );
|
seedRng( *m_config );
|
||||||
|
|
||||||
|
if( m_configData.filenamesAsTags )
|
||||||
|
applyFilenamesAsTags( *m_config );
|
||||||
|
|
||||||
// Handle list request
|
// Handle list request
|
||||||
if( Option<std::size_t> listed = list( config() ) )
|
if( Option<std::size_t> listed = list( config() ) )
|
||||||
return static_cast<int>( *listed );
|
return static_cast<int>( *listed );
|
||||||
@@ -213,7 +205,6 @@ namespace Catch {
|
|||||||
m_config = new Config( m_configData );
|
m_config = new Config( m_configData );
|
||||||
return *m_config;
|
return *m_config;
|
||||||
}
|
}
|
||||||
|
|
||||||
private:
|
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;
|
7
include/external/clara.h
vendored
7
include/external/clara.h
vendored
@@ -503,12 +503,7 @@ namespace Clara {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
// NOTE: std::auto_ptr is deprecated in c++11/c++0x
|
typedef CATCH_AUTO_PTR( Arg ) ArgAutoPtr;
|
||||||
#if defined(__cplusplus) && __cplusplus > 199711L
|
|
||||||
typedef std::unique_ptr<Arg> ArgAutoPtr;
|
|
||||||
#else
|
|
||||||
typedef std::auto_ptr<Arg> ArgAutoPtr;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
friend void addOptName( Arg& arg, std::string const& optName )
|
friend void addOptName( Arg& arg, std::string const& optName )
|
||||||
{
|
{
|
||||||
|
@@ -10,13 +10,14 @@
|
|||||||
|
|
||||||
#include "catch_result_builder.h"
|
#include "catch_result_builder.h"
|
||||||
#include "catch_message.h"
|
#include "catch_message.h"
|
||||||
#include "catch_interfaces_capture.h"
|
|
||||||
#include "catch_debugger.h"
|
#include "catch_debugger.h"
|
||||||
#include "catch_common.h"
|
#include "catch_common.h"
|
||||||
#include "catch_tostring.h"
|
#include "catch_tostring.h"
|
||||||
#include "catch_interfaces_runner.h"
|
|
||||||
#include "catch_compiler_capabilities.h"
|
#include "catch_compiler_capabilities.h"
|
||||||
|
|
||||||
|
namespace Catch {
|
||||||
|
AssertionResult const* getLastResult();
|
||||||
|
}
|
||||||
|
|
||||||
///////////////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////////////
|
||||||
// In the event of a failure works out if the debugger needs to be invoked
|
// In the event of a failure works out if the debugger needs to be invoked
|
||||||
@@ -44,12 +45,12 @@
|
|||||||
///////////////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////////////
|
||||||
#define INTERNAL_CATCH_IF( expr, resultDisposition, macroName ) \
|
#define INTERNAL_CATCH_IF( expr, resultDisposition, macroName ) \
|
||||||
INTERNAL_CATCH_TEST( expr, resultDisposition, macroName ); \
|
INTERNAL_CATCH_TEST( expr, resultDisposition, macroName ); \
|
||||||
if( Catch::getResultCapture().getLastResult()->succeeded() )
|
if( Catch::getLastResult()->succeeded() )
|
||||||
|
|
||||||
///////////////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////////////
|
||||||
#define INTERNAL_CATCH_ELSE( expr, resultDisposition, macroName ) \
|
#define INTERNAL_CATCH_ELSE( expr, resultDisposition, macroName ) \
|
||||||
INTERNAL_CATCH_TEST( expr, resultDisposition, macroName ); \
|
INTERNAL_CATCH_TEST( expr, resultDisposition, macroName ); \
|
||||||
if( !Catch::getResultCapture().getLastResult()->succeeded() )
|
if( !Catch::getLastResult()->succeeded() )
|
||||||
|
|
||||||
///////////////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////////////
|
||||||
#define INTERNAL_CATCH_NO_THROW( expr, resultDisposition, macroName ) \
|
#define INTERNAL_CATCH_NO_THROW( expr, resultDisposition, macroName ) \
|
||||||
@@ -129,14 +130,14 @@
|
|||||||
///////////////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////////////
|
||||||
#define INTERNAL_CHECK_THAT( arg, matcher, resultDisposition, macroName ) \
|
#define INTERNAL_CHECK_THAT( arg, matcher, resultDisposition, macroName ) \
|
||||||
do { \
|
do { \
|
||||||
Catch::ResultBuilder __catchResult( macroName, CATCH_INTERNAL_LINEINFO, #arg " " #matcher, resultDisposition ); \
|
Catch::ResultBuilder __catchResult( macroName, CATCH_INTERNAL_LINEINFO, #arg ", " #matcher, resultDisposition ); \
|
||||||
try { \
|
try { \
|
||||||
std::string matcherAsString = ::Catch::Matchers::matcher.toString(); \
|
std::string matcherAsString = (matcher).toString(); \
|
||||||
__catchResult \
|
__catchResult \
|
||||||
.setLhs( Catch::toString( arg ) ) \
|
.setLhs( Catch::toString( arg ) ) \
|
||||||
.setRhs( matcherAsString == Catch::Detail::unprintableString ? #matcher : matcherAsString ) \
|
.setRhs( matcherAsString == Catch::Detail::unprintableString ? #matcher : matcherAsString ) \
|
||||||
.setOp( "matches" ) \
|
.setOp( "matches" ) \
|
||||||
.setResultType( ::Catch::Matchers::matcher.match( arg ) ); \
|
.setResultType( (matcher).match( arg ) ); \
|
||||||
__catchResult.captureExpression(); \
|
__catchResult.captureExpression(); \
|
||||||
} catch( ... ) { \
|
} catch( ... ) { \
|
||||||
__catchResult.useActiveException( resultDisposition | Catch::ResultDisposition::ContinueOnFailure ); \
|
__catchResult.useActiveException( resultDisposition | Catch::ResultDisposition::ContinueOnFailure ); \
|
||||||
|
@@ -23,6 +23,7 @@ namespace Catch {
|
|||||||
config.abortAfter = x;
|
config.abortAfter = x;
|
||||||
}
|
}
|
||||||
inline void addTestOrTags( ConfigData& config, std::string const& _testSpec ) { config.testsOrTags.push_back( _testSpec ); }
|
inline void addTestOrTags( ConfigData& config, std::string const& _testSpec ) { config.testsOrTags.push_back( _testSpec ); }
|
||||||
|
inline void addReporterName( ConfigData& config, std::string const& _reporterName ) { config.reporterNames.push_back( _reporterName ); }
|
||||||
|
|
||||||
inline void addWarning( ConfigData& config, std::string const& _warning ) {
|
inline void addWarning( ConfigData& config, std::string const& _warning ) {
|
||||||
if( _warning == "NoAssertions" )
|
if( _warning == "NoAssertions" )
|
||||||
@@ -116,7 +117,7 @@ namespace Catch {
|
|||||||
cli["-r"]["--reporter"]
|
cli["-r"]["--reporter"]
|
||||||
// .placeholder( "name[:filename]" )
|
// .placeholder( "name[:filename]" )
|
||||||
.describe( "reporter to use (defaults to console)" )
|
.describe( "reporter to use (defaults to console)" )
|
||||||
.bind( &ConfigData::reporterName, "name" );
|
.bind( &addReporterName, "name" );
|
||||||
|
|
||||||
cli["-n"]["--name"]
|
cli["-n"]["--name"]
|
||||||
.describe( "suite name" )
|
.describe( "suite name" )
|
||||||
|
@@ -10,7 +10,11 @@
|
|||||||
|
|
||||||
#define INTERNAL_CATCH_UNIQUE_NAME_LINE2( name, line ) name##line
|
#define INTERNAL_CATCH_UNIQUE_NAME_LINE2( name, line ) name##line
|
||||||
#define INTERNAL_CATCH_UNIQUE_NAME_LINE( name, line ) INTERNAL_CATCH_UNIQUE_NAME_LINE2( name, line )
|
#define INTERNAL_CATCH_UNIQUE_NAME_LINE( name, line ) INTERNAL_CATCH_UNIQUE_NAME_LINE2( name, line )
|
||||||
|
#ifdef CATCH_CONFIG_COUNTER
|
||||||
|
# define INTERNAL_CATCH_UNIQUE_NAME( name ) INTERNAL_CATCH_UNIQUE_NAME_LINE( name, __COUNTER__ )
|
||||||
|
#else
|
||||||
# define INTERNAL_CATCH_UNIQUE_NAME( name ) INTERNAL_CATCH_UNIQUE_NAME_LINE( name, __LINE__ )
|
# define INTERNAL_CATCH_UNIQUE_NAME( name ) INTERNAL_CATCH_UNIQUE_NAME_LINE( name, __LINE__ )
|
||||||
|
#endif
|
||||||
|
|
||||||
#define INTERNAL_CATCH_STRINGIFY2( expr ) #expr
|
#define INTERNAL_CATCH_STRINGIFY2( expr ) #expr
|
||||||
#define INTERNAL_CATCH_STRINGIFY( expr ) INTERNAL_CATCH_STRINGIFY2( expr )
|
#define INTERNAL_CATCH_STRINGIFY( expr ) INTERNAL_CATCH_STRINGIFY2( expr )
|
||||||
|
@@ -87,7 +87,9 @@ namespace Catch {
|
|||||||
std::srand( config.rngSeed() );
|
std::srand( config.rngSeed() );
|
||||||
}
|
}
|
||||||
unsigned int rngSeed() {
|
unsigned int rngSeed() {
|
||||||
return getCurrentContext().getConfig()->rngSeed();
|
return getCurrentConfig()
|
||||||
|
? getCurrentConfig()->rngSeed()
|
||||||
|
: 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::ostream& operator << ( std::ostream& os, SourceLineInfo const& info ) {
|
std::ostream& operator << ( std::ostream& os, SourceLineInfo const& info ) {
|
||||||
|
@@ -17,11 +17,17 @@
|
|||||||
// CATCH_CONFIG_CPP11_IS_ENUM : std::is_enum is supported?
|
// CATCH_CONFIG_CPP11_IS_ENUM : std::is_enum is supported?
|
||||||
// CATCH_CONFIG_CPP11_TUPLE : std::tuple is supported
|
// CATCH_CONFIG_CPP11_TUPLE : std::tuple is supported
|
||||||
// CATCH_CONFIG_CPP11_LONG_LONG : is long long supported?
|
// CATCH_CONFIG_CPP11_LONG_LONG : is long long supported?
|
||||||
|
// CATCH_CONFIG_CPP11_OVERRIDE : is override supported?
|
||||||
|
// CATCH_CONFIG_CPP11_UNIQUE_PTR : is unique_ptr supported (otherwise use auto_ptr)
|
||||||
|
|
||||||
// CATCH_CONFIG_CPP11_OR_GREATER : Is C++11 supported?
|
// CATCH_CONFIG_CPP11_OR_GREATER : Is C++11 supported?
|
||||||
|
|
||||||
// CATCH_CONFIG_VARIADIC_MACROS : are variadic macros supported?
|
// CATCH_CONFIG_VARIADIC_MACROS : are variadic macros supported?
|
||||||
|
// CATCH_CONFIG_COUNTER : is the __COUNTER__ macro supported?
|
||||||
|
// ****************
|
||||||
|
// Note to maintainers: if new toggles are added please document them
|
||||||
|
// in configuration.md, too
|
||||||
|
// ****************
|
||||||
|
|
||||||
// In general each macro has a _NO_<feature name> form
|
// In general each macro has a _NO_<feature name> form
|
||||||
// (e.g. CATCH_CONFIG_CPP11_NO_NULLPTR) which disables the feature.
|
// (e.g. CATCH_CONFIG_CPP11_NO_NULLPTR) which disables the feature.
|
||||||
@@ -83,6 +89,7 @@
|
|||||||
|
|
||||||
#if (_MSC_VER >= 1600)
|
#if (_MSC_VER >= 1600)
|
||||||
# define CATCH_INTERNAL_CONFIG_CPP11_NULLPTR
|
# define CATCH_INTERNAL_CONFIG_CPP11_NULLPTR
|
||||||
|
# define CATCH_INTERNAL_CONFIG_CPP11_UNIQUE_PTR
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if (_MSC_VER >= 1900 ) // (VC++ 13 (VS2015))
|
#if (_MSC_VER >= 1900 ) // (VC++ 13 (VS2015))
|
||||||
@@ -92,6 +99,8 @@
|
|||||||
|
|
||||||
#endif // _MSC_VER
|
#endif // _MSC_VER
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
// Use variadic macros if the compiler supports them
|
// Use variadic macros if the compiler supports them
|
||||||
#if ( defined _MSC_VER && _MSC_VER > 1400 && !defined __EDGE__) || \
|
#if ( defined _MSC_VER && _MSC_VER > 1400 && !defined __EDGE__) || \
|
||||||
( defined __WAVE__ && __WAVE_HAS_VARIADICS ) || \
|
( defined __WAVE__ && __WAVE_HAS_VARIADICS ) || \
|
||||||
@@ -102,11 +111,20 @@
|
|||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
// Use __COUNTER__ if the compiler supports it
|
||||||
|
#if ( defined _MSC_VER && _MSC_VER >= 1300 ) || \
|
||||||
|
( defined __GNUC__ && __GNUC__ >= 4 && __GNUC_MINOR__ >= 3 ) || \
|
||||||
|
( defined __clang__ && __clang_major__ >= 3 )
|
||||||
|
|
||||||
|
#define CATCH_INTERNAL_CONFIG_COUNTER
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
// C++ language feature support
|
// C++ language feature support
|
||||||
|
|
||||||
// catch all support for C++11
|
// catch all support for C++11
|
||||||
#if (__cplusplus >= 201103L)
|
#if defined(__cplusplus) && __cplusplus >= 201103L
|
||||||
|
|
||||||
# define CATCH_CPP11_OR_GREATER
|
# define CATCH_CPP11_OR_GREATER
|
||||||
|
|
||||||
@@ -138,6 +156,14 @@
|
|||||||
# define CATCH_INTERNAL_CONFIG_CPP11_LONG_LONG
|
# define CATCH_INTERNAL_CONFIG_CPP11_LONG_LONG
|
||||||
# endif
|
# endif
|
||||||
|
|
||||||
|
# if !defined(CATCH_INTERNAL_CONFIG_CPP11_OVERRIDE)
|
||||||
|
# define CATCH_INTERNAL_CONFIG_CPP11_OVERRIDE
|
||||||
|
# endif
|
||||||
|
# if !defined(CATCH_INTERNAL_CONFIG_CPP11_UNIQUE_PTR)
|
||||||
|
# define CATCH_INTERNAL_CONFIG_CPP11_UNIQUE_PTR
|
||||||
|
# endif
|
||||||
|
|
||||||
|
|
||||||
#endif // __cplusplus >= 201103L
|
#endif // __cplusplus >= 201103L
|
||||||
|
|
||||||
// Now set the actual defines based on the above + anything the user has configured
|
// Now set the actual defines based on the above + anything the user has configured
|
||||||
@@ -159,9 +185,18 @@
|
|||||||
#if defined(CATCH_INTERNAL_CONFIG_VARIADIC_MACROS) && !defined(CATCH_CONFIG_NO_VARIADIC_MACROS) && !defined(CATCH_CONFIG_VARIADIC_MACROS)
|
#if defined(CATCH_INTERNAL_CONFIG_VARIADIC_MACROS) && !defined(CATCH_CONFIG_NO_VARIADIC_MACROS) && !defined(CATCH_CONFIG_VARIADIC_MACROS)
|
||||||
# define CATCH_CONFIG_VARIADIC_MACROS
|
# define CATCH_CONFIG_VARIADIC_MACROS
|
||||||
#endif
|
#endif
|
||||||
#if defined(CATCH_INTERNAL_CONFIG_CPP11_LONG_LONG) && !defined(CATCH_CONFIG_NO_LONG_LONG) && !defined(CATCH_CONFIG_CPP11_LONG_LONG)
|
#if defined(CATCH_INTERNAL_CONFIG_CPP11_LONG_LONG) && !defined(CATCH_CONFIG_NO_LONG_LONG) && !defined(CATCH_CONFIG_CPP11_LONG_LONG) && !defined(CATCH_CONFIG_NO_CPP11)
|
||||||
# define CATCH_CONFIG_CPP11_LONG_LONG
|
# define CATCH_CONFIG_CPP11_LONG_LONG
|
||||||
#endif
|
#endif
|
||||||
|
#if defined(CATCH_INTERNAL_CONFIG_CPP11_OVERRIDE) && !defined(CATCH_CONFIG_NO_OVERRIDE) && !defined(CATCH_CONFIG_CPP11_OVERRIDE) && !defined(CATCH_CONFIG_NO_CPP11)
|
||||||
|
# define CATCH_CONFIG_CPP11_OVERRIDE
|
||||||
|
#endif
|
||||||
|
#if defined(CATCH_INTERNAL_CONFIG_CPP11_UNIQUE_PTR) && !defined(CATCH_CONFIG_NO_UNIQUE_PTR) && !defined(CATCH_CONFIG_CPP11_UNIQUE_PTR) && !defined(CATCH_CONFIG_NO_CPP11)
|
||||||
|
# define CATCH_CONFIG_CPP11_UNIQUE_PTR
|
||||||
|
#endif
|
||||||
|
#if defined(CATCH_INTERNAL_CONFIG_COUNTER) && !defined(CATCH_CONFIG_NO_COUNTER) && !defined(CATCH_CONFIG_COUNTER)
|
||||||
|
# define CATCH_CONFIG_COUNTER
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
// noexcept support:
|
// noexcept support:
|
||||||
@@ -180,5 +215,19 @@
|
|||||||
# define CATCH_NULL NULL
|
# define CATCH_NULL NULL
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
// override support
|
||||||
|
#ifdef CATCH_CONFIG_CPP11_OVERRIDE
|
||||||
|
# define CATCH_OVERRIDE override
|
||||||
|
#else
|
||||||
|
# define CATCH_OVERRIDE
|
||||||
|
#endif
|
||||||
|
|
||||||
|
// unique_ptr support
|
||||||
|
#ifdef CATCH_CONFIG_CPP11_UNIQUE_PTR
|
||||||
|
# define CATCH_AUTO_PTR( T ) std::unique_ptr<T>
|
||||||
|
#else
|
||||||
|
# define CATCH_AUTO_PTR( T ) std::auto_ptr<T>
|
||||||
|
#endif
|
||||||
|
|
||||||
#endif // TWOBLUECUBES_CATCH_COMPILER_CAPABILITIES_HPP_INCLUDED
|
#endif // TWOBLUECUBES_CATCH_COMPILER_CAPABILITIES_HPP_INCLUDED
|
||||||
|
|
||||||
|
@@ -9,7 +9,6 @@
|
|||||||
#define TWOBLUECUBES_CATCH_CONFIG_HPP_INCLUDED
|
#define TWOBLUECUBES_CATCH_CONFIG_HPP_INCLUDED
|
||||||
|
|
||||||
#include "catch_test_spec_parser.hpp"
|
#include "catch_test_spec_parser.hpp"
|
||||||
#include "catch_context.h"
|
|
||||||
#include "catch_interfaces_config.h"
|
#include "catch_interfaces_config.h"
|
||||||
#include "catch_stream.h"
|
#include "catch_stream.h"
|
||||||
|
|
||||||
@@ -68,11 +67,11 @@ namespace Catch {
|
|||||||
ShowDurations::OrNot showDurations;
|
ShowDurations::OrNot showDurations;
|
||||||
RunTests::InWhatOrder runOrder;
|
RunTests::InWhatOrder runOrder;
|
||||||
|
|
||||||
std::string reporterName;
|
|
||||||
std::string outputFilename;
|
std::string outputFilename;
|
||||||
std::string name;
|
std::string name;
|
||||||
std::string processName;
|
std::string processName;
|
||||||
|
|
||||||
|
std::vector<std::string> reporterNames;
|
||||||
std::vector<std::string> testsOrTags;
|
std::vector<std::string> testsOrTags;
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -85,12 +84,11 @@ namespace Catch {
|
|||||||
public:
|
public:
|
||||||
|
|
||||||
Config()
|
Config()
|
||||||
: m_os( Catch::cout().rdbuf() )
|
|
||||||
{}
|
{}
|
||||||
|
|
||||||
Config( ConfigData const& data )
|
Config( ConfigData const& data )
|
||||||
: m_data( data ),
|
: m_data( data ),
|
||||||
m_os( Catch::cout().rdbuf() )
|
m_stream( openStream() )
|
||||||
{
|
{
|
||||||
if( !data.testsOrTags.empty() ) {
|
if( !data.testsOrTags.empty() ) {
|
||||||
TestSpecParser parser( ITagAliasRegistry::get() );
|
TestSpecParser parser( ITagAliasRegistry::get() );
|
||||||
@@ -101,12 +99,6 @@ namespace Catch {
|
|||||||
}
|
}
|
||||||
|
|
||||||
virtual ~Config() {
|
virtual ~Config() {
|
||||||
m_os.rdbuf( Catch::cout().rdbuf() );
|
|
||||||
m_stream.release();
|
|
||||||
}
|
|
||||||
|
|
||||||
void setFilename( std::string const& filename ) {
|
|
||||||
m_data.outputFilename = filename;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string const& getFilename() const {
|
std::string const& getFilename() const {
|
||||||
@@ -122,18 +114,7 @@ namespace Catch {
|
|||||||
|
|
||||||
bool shouldDebugBreak() const { return m_data.shouldDebugBreak; }
|
bool shouldDebugBreak() const { return m_data.shouldDebugBreak; }
|
||||||
|
|
||||||
void setStreamBuf( std::streambuf* buf ) {
|
std::vector<std::string> getReporterNames() const { return m_data.reporterNames; }
|
||||||
m_os.rdbuf( buf ? buf : Catch::cout().rdbuf() );
|
|
||||||
}
|
|
||||||
|
|
||||||
void useStream( std::string const& streamName ) {
|
|
||||||
Stream stream = createStream( streamName );
|
|
||||||
setStreamBuf( stream.streamBuf );
|
|
||||||
m_stream.release();
|
|
||||||
m_stream = stream;
|
|
||||||
}
|
|
||||||
|
|
||||||
std::string getReporterName() const { return m_data.reporterName; }
|
|
||||||
|
|
||||||
int abortAfter() const { return m_data.abortAfter; }
|
int abortAfter() const { return m_data.abortAfter; }
|
||||||
|
|
||||||
@@ -144,7 +125,7 @@ namespace Catch {
|
|||||||
|
|
||||||
// IConfig interface
|
// IConfig interface
|
||||||
virtual bool allowThrows() const { return !m_data.noThrow; }
|
virtual bool allowThrows() const { return !m_data.noThrow; }
|
||||||
virtual std::ostream& stream() const { return m_os; }
|
virtual std::ostream& stream() const { return m_stream->stream(); }
|
||||||
virtual std::string name() const { return m_data.name.empty() ? m_data.processName : m_data.name; }
|
virtual std::string name() const { return m_data.name.empty() ? m_data.processName : m_data.name; }
|
||||||
virtual bool includeSuccessfulResults() const { return m_data.showSuccessfulTests; }
|
virtual bool includeSuccessfulResults() const { return m_data.showSuccessfulTests; }
|
||||||
virtual bool warnAboutMissingAssertions() const { return m_data.warnings & WarnAbout::NoAssertions; }
|
virtual bool warnAboutMissingAssertions() const { return m_data.warnings & WarnAbout::NoAssertions; }
|
||||||
@@ -154,14 +135,25 @@ namespace Catch {
|
|||||||
virtual bool forceColour() const { return m_data.forceColour; }
|
virtual bool forceColour() const { return m_data.forceColour; }
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
||||||
|
IStream const* openStream() {
|
||||||
|
if( m_data.outputFilename.empty() )
|
||||||
|
return new CoutStream();
|
||||||
|
else if( m_data.outputFilename[0] == '%' ) {
|
||||||
|
if( m_data.outputFilename == "%debug" )
|
||||||
|
return new DebugOutStream();
|
||||||
|
else
|
||||||
|
throw std::domain_error( "Unrecognised stream: " + m_data.outputFilename );
|
||||||
|
}
|
||||||
|
else
|
||||||
|
return new FileStream( m_data.outputFilename );
|
||||||
|
}
|
||||||
ConfigData m_data;
|
ConfigData m_data;
|
||||||
|
|
||||||
Stream m_stream;
|
std::auto_ptr<IStream const> m_stream;
|
||||||
mutable std::ostream m_os;
|
|
||||||
TestSpec m_testSpec;
|
TestSpec m_testSpec;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
} // end namespace Catch
|
} // end namespace Catch
|
||||||
|
|
||||||
#endif // TWOBLUECUBES_CATCH_CONFIG_HPP_INCLUDED
|
#endif // TWOBLUECUBES_CATCH_CONFIG_HPP_INCLUDED
|
||||||
|
@@ -145,7 +145,7 @@ namespace {
|
|||||||
};
|
};
|
||||||
|
|
||||||
IColourImpl* platformColourInstance() {
|
IColourImpl* platformColourInstance() {
|
||||||
Ptr<IConfig const> config = getCurrentContext().getConfig();
|
IConfig const* config = getCurrentConfig();
|
||||||
return (config && config->forceColour()) || isatty(STDOUT_FILENO)
|
return (config && config->forceColour()) || isatty(STDOUT_FILENO)
|
||||||
? PosixColourImpl::instance()
|
? PosixColourImpl::instance()
|
||||||
: NoColourImpl::instance();
|
: NoColourImpl::instance();
|
||||||
|
@@ -1,53 +0,0 @@
|
|||||||
/*
|
|
||||||
* Created by Phil on 31/12/2010.
|
|
||||||
* Copyright 2010 Two Blue Cubes Ltd. All rights reserved.
|
|
||||||
*
|
|
||||||
* 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)
|
|
||||||
*/
|
|
||||||
#ifndef TWOBLUECUBES_CATCH_CONTEXT_H_INCLUDED
|
|
||||||
#define TWOBLUECUBES_CATCH_CONTEXT_H_INCLUDED
|
|
||||||
|
|
||||||
#include "catch_interfaces_generators.h"
|
|
||||||
#include "catch_ptr.hpp"
|
|
||||||
|
|
||||||
#include <memory>
|
|
||||||
#include <vector>
|
|
||||||
#include <stdlib.h>
|
|
||||||
|
|
||||||
namespace Catch {
|
|
||||||
|
|
||||||
class TestCase;
|
|
||||||
class Stream;
|
|
||||||
struct IResultCapture;
|
|
||||||
struct IRunner;
|
|
||||||
struct IGeneratorsForTest;
|
|
||||||
struct IConfig;
|
|
||||||
|
|
||||||
struct IContext
|
|
||||||
{
|
|
||||||
virtual ~IContext();
|
|
||||||
|
|
||||||
virtual IResultCapture* getResultCapture() = 0;
|
|
||||||
virtual IRunner* getRunner() = 0;
|
|
||||||
virtual size_t getGeneratorIndex( std::string const& fileInfo, size_t totalSize ) = 0;
|
|
||||||
virtual bool advanceGeneratorsForCurrentTest() = 0;
|
|
||||||
virtual Ptr<IConfig const> getConfig() const = 0;
|
|
||||||
};
|
|
||||||
|
|
||||||
struct IMutableContext : IContext
|
|
||||||
{
|
|
||||||
virtual ~IMutableContext();
|
|
||||||
virtual void setResultCapture( IResultCapture* resultCapture ) = 0;
|
|
||||||
virtual void setRunner( IRunner* runner ) = 0;
|
|
||||||
virtual void setConfig( Ptr<IConfig const> const& config ) = 0;
|
|
||||||
};
|
|
||||||
|
|
||||||
IContext& getCurrentContext();
|
|
||||||
IMutableContext& getCurrentMutableContext();
|
|
||||||
void cleanUpContext();
|
|
||||||
Stream createStream( std::string const& streamName );
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
#endif // TWOBLUECUBES_CATCH_CONTEXT_H_INCLUDED
|
|
@@ -1,112 +0,0 @@
|
|||||||
/*
|
|
||||||
* Created by Phil on 31/12/2010.
|
|
||||||
* Copyright 2010 Two Blue Cubes Ltd. All rights reserved.
|
|
||||||
*
|
|
||||||
* 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)
|
|
||||||
*/
|
|
||||||
#ifndef TWOBLUECUBES_CATCH_CONTEXT_IMPL_HPP_INCLUDED
|
|
||||||
#define TWOBLUECUBES_CATCH_CONTEXT_IMPL_HPP_INCLUDED
|
|
||||||
|
|
||||||
#include "catch_runner_impl.hpp"
|
|
||||||
|
|
||||||
#include "catch_context.h"
|
|
||||||
#include "catch_stream.hpp"
|
|
||||||
|
|
||||||
namespace Catch {
|
|
||||||
|
|
||||||
class Context : public IMutableContext {
|
|
||||||
|
|
||||||
Context() : m_config( CATCH_NULL ), m_runner( CATCH_NULL ), m_resultCapture( CATCH_NULL ) {}
|
|
||||||
Context( Context const& );
|
|
||||||
void operator=( Context const& );
|
|
||||||
|
|
||||||
public: // IContext
|
|
||||||
virtual IResultCapture* getResultCapture() {
|
|
||||||
return m_resultCapture;
|
|
||||||
}
|
|
||||||
virtual IRunner* getRunner() {
|
|
||||||
return m_runner;
|
|
||||||
}
|
|
||||||
virtual size_t getGeneratorIndex( std::string const& fileInfo, size_t totalSize ) {
|
|
||||||
return getGeneratorsForCurrentTest()
|
|
||||||
.getGeneratorInfo( fileInfo, totalSize )
|
|
||||||
.getCurrentIndex();
|
|
||||||
}
|
|
||||||
virtual bool advanceGeneratorsForCurrentTest() {
|
|
||||||
IGeneratorsForTest* generators = findGeneratorsForCurrentTest();
|
|
||||||
return generators && generators->moveNext();
|
|
||||||
}
|
|
||||||
|
|
||||||
virtual Ptr<IConfig const> getConfig() const {
|
|
||||||
return m_config;
|
|
||||||
}
|
|
||||||
|
|
||||||
public: // IMutableContext
|
|
||||||
virtual void setResultCapture( IResultCapture* resultCapture ) {
|
|
||||||
m_resultCapture = resultCapture;
|
|
||||||
}
|
|
||||||
virtual void setRunner( IRunner* runner ) {
|
|
||||||
m_runner = runner;
|
|
||||||
}
|
|
||||||
virtual void setConfig( Ptr<IConfig const> const& config ) {
|
|
||||||
m_config = config;
|
|
||||||
}
|
|
||||||
|
|
||||||
friend IMutableContext& getCurrentMutableContext();
|
|
||||||
|
|
||||||
private:
|
|
||||||
IGeneratorsForTest* findGeneratorsForCurrentTest() {
|
|
||||||
std::string testName = getResultCapture()->getCurrentTestName();
|
|
||||||
|
|
||||||
std::map<std::string, IGeneratorsForTest*>::const_iterator it =
|
|
||||||
m_generatorsByTestName.find( testName );
|
|
||||||
return it != m_generatorsByTestName.end()
|
|
||||||
? it->second
|
|
||||||
: CATCH_NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
IGeneratorsForTest& getGeneratorsForCurrentTest() {
|
|
||||||
IGeneratorsForTest* generators = findGeneratorsForCurrentTest();
|
|
||||||
if( !generators ) {
|
|
||||||
std::string testName = getResultCapture()->getCurrentTestName();
|
|
||||||
generators = createGeneratorsForTest();
|
|
||||||
m_generatorsByTestName.insert( std::make_pair( testName, generators ) );
|
|
||||||
}
|
|
||||||
return *generators;
|
|
||||||
}
|
|
||||||
|
|
||||||
private:
|
|
||||||
Ptr<IConfig const> m_config;
|
|
||||||
IRunner* m_runner;
|
|
||||||
IResultCapture* m_resultCapture;
|
|
||||||
std::map<std::string, IGeneratorsForTest*> m_generatorsByTestName;
|
|
||||||
};
|
|
||||||
|
|
||||||
namespace {
|
|
||||||
Context* currentContext = CATCH_NULL;
|
|
||||||
}
|
|
||||||
IMutableContext& getCurrentMutableContext() {
|
|
||||||
if( !currentContext )
|
|
||||||
currentContext = new Context();
|
|
||||||
return *currentContext;
|
|
||||||
}
|
|
||||||
IContext& getCurrentContext() {
|
|
||||||
return getCurrentMutableContext();
|
|
||||||
}
|
|
||||||
|
|
||||||
Stream createStream( std::string const& streamName ) {
|
|
||||||
if( streamName == "stdout" ) return Stream( Catch::cout().rdbuf(), false );
|
|
||||||
if( streamName == "stderr" ) return Stream( Catch::cerr().rdbuf(), false );
|
|
||||||
if( streamName == "debug" ) return Stream( new StreamBufImpl<OutputDebugWriter>, true );
|
|
||||||
|
|
||||||
throw std::domain_error( "Unknown stream: " + streamName );
|
|
||||||
}
|
|
||||||
|
|
||||||
void cleanUpContext() {
|
|
||||||
delete currentContext;
|
|
||||||
currentContext = CATCH_NULL;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
#endif // TWOBLUECUBES_CATCH_CONTEXT_IMPL_HPP_INCLUDED
|
|
@@ -11,7 +11,7 @@
|
|||||||
#ifndef __OBJC__
|
#ifndef __OBJC__
|
||||||
|
|
||||||
// Standard C/C++ main entry point
|
// Standard C/C++ main entry point
|
||||||
int main (int argc, char * const argv[]) {
|
int main (int argc, char * argv[]) {
|
||||||
return Catch::Session().run( argc, argv );
|
return Catch::Session().run( argc, argv );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -32,13 +32,13 @@ namespace Catch {
|
|||||||
#ifdef __OBJC__
|
#ifdef __OBJC__
|
||||||
// In Objective-C try objective-c exceptions first
|
// In Objective-C try objective-c exceptions first
|
||||||
@try {
|
@try {
|
||||||
throw;
|
return tryTranslators();
|
||||||
}
|
}
|
||||||
@catch (NSException *exception) {
|
@catch (NSException *exception) {
|
||||||
return Catch::toString( [exception description] );
|
return Catch::toString( [exception description] );
|
||||||
}
|
}
|
||||||
#else
|
#else
|
||||||
throw;
|
return tryTranslators();
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
catch( TestFailureException& ) {
|
catch( TestFailureException& ) {
|
||||||
@@ -54,20 +54,15 @@ namespace Catch {
|
|||||||
return msg;
|
return msg;
|
||||||
}
|
}
|
||||||
catch(...) {
|
catch(...) {
|
||||||
return tryTranslators( m_translators.begin() );
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
std::string tryTranslators( std::vector<const IExceptionTranslator*>::const_iterator it ) const {
|
|
||||||
if( it == m_translators.end() )
|
|
||||||
return "Unknown exception";
|
return "Unknown exception";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
try {
|
std::string tryTranslators() const {
|
||||||
return (*it)->translate();
|
if( m_translators.empty() )
|
||||||
}
|
throw;
|
||||||
catch(...) {
|
else
|
||||||
return tryTranslators( it+1 );
|
return m_translators[0]->translate( m_translators.begin()+1, m_translators.end() );
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
@@ -14,9 +14,8 @@ namespace Catch {
|
|||||||
|
|
||||||
// Report the error condition then exit the process
|
// Report the error condition then exit the process
|
||||||
inline void fatal( std::string const& message, int exitCode ) {
|
inline void fatal( std::string const& message, int exitCode ) {
|
||||||
IContext& context = Catch::getCurrentContext();
|
IRunContext& runContext = getCurrentRunContext();
|
||||||
IResultCapture* resultCapture = context.getResultCapture();
|
runContext.handleFatalErrorCondition( message );
|
||||||
resultCapture->handleFatalErrorCondition( message );
|
|
||||||
|
|
||||||
if( Catch::alwaysTrue() ) // avoids "no return" warnings
|
if( Catch::alwaysTrue() ) // avoids "no return" warnings
|
||||||
exit( exitCode );
|
exit( exitCode );
|
||||||
|
@@ -1,190 +0,0 @@
|
|||||||
/*
|
|
||||||
* Created by Phil on 27/01/2011.
|
|
||||||
* Copyright 2011 Two Blue Cubes Ltd. All rights reserved.
|
|
||||||
*
|
|
||||||
* 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)
|
|
||||||
*/
|
|
||||||
#ifndef TWOBLUECUBES_CATCH_GENERATORS_HPP_INCLUDED
|
|
||||||
#define TWOBLUECUBES_CATCH_GENERATORS_HPP_INCLUDED
|
|
||||||
|
|
||||||
#include "catch_context.h"
|
|
||||||
|
|
||||||
#include <iterator>
|
|
||||||
#include <vector>
|
|
||||||
#include <string>
|
|
||||||
#include <stdlib.h>
|
|
||||||
|
|
||||||
namespace Catch {
|
|
||||||
|
|
||||||
template<typename T>
|
|
||||||
struct IGenerator {
|
|
||||||
virtual ~IGenerator() {}
|
|
||||||
virtual T getValue( std::size_t index ) const = 0;
|
|
||||||
virtual std::size_t size () const = 0;
|
|
||||||
};
|
|
||||||
|
|
||||||
template<typename T>
|
|
||||||
class BetweenGenerator : public IGenerator<T> {
|
|
||||||
public:
|
|
||||||
BetweenGenerator( T from, T to ) : m_from( from ), m_to( to ){}
|
|
||||||
|
|
||||||
virtual T getValue( std::size_t index ) const {
|
|
||||||
return m_from+static_cast<int>( index );
|
|
||||||
}
|
|
||||||
|
|
||||||
virtual std::size_t size() const {
|
|
||||||
return static_cast<std::size_t>( 1+m_to-m_from );
|
|
||||||
}
|
|
||||||
|
|
||||||
private:
|
|
||||||
|
|
||||||
T m_from;
|
|
||||||
T m_to;
|
|
||||||
};
|
|
||||||
|
|
||||||
template<typename T>
|
|
||||||
class ValuesGenerator : public IGenerator<T> {
|
|
||||||
public:
|
|
||||||
ValuesGenerator(){}
|
|
||||||
|
|
||||||
void add( T value ) {
|
|
||||||
m_values.push_back( value );
|
|
||||||
}
|
|
||||||
|
|
||||||
virtual T getValue( std::size_t index ) const {
|
|
||||||
return m_values[index];
|
|
||||||
}
|
|
||||||
|
|
||||||
virtual std::size_t size() const {
|
|
||||||
return m_values.size();
|
|
||||||
}
|
|
||||||
|
|
||||||
private:
|
|
||||||
std::vector<T> m_values;
|
|
||||||
};
|
|
||||||
|
|
||||||
template<typename T>
|
|
||||||
class CompositeGenerator {
|
|
||||||
public:
|
|
||||||
CompositeGenerator() : m_totalSize( 0 ) {}
|
|
||||||
|
|
||||||
// *** Move semantics, similar to auto_ptr ***
|
|
||||||
CompositeGenerator( CompositeGenerator& other )
|
|
||||||
: m_fileInfo( other.m_fileInfo ),
|
|
||||||
m_totalSize( 0 )
|
|
||||||
{
|
|
||||||
move( other );
|
|
||||||
}
|
|
||||||
|
|
||||||
CompositeGenerator& setFileInfo( const char* fileInfo ) {
|
|
||||||
m_fileInfo = fileInfo;
|
|
||||||
return *this;
|
|
||||||
}
|
|
||||||
|
|
||||||
~CompositeGenerator() {
|
|
||||||
deleteAll( m_composed );
|
|
||||||
}
|
|
||||||
|
|
||||||
operator T () const {
|
|
||||||
size_t overallIndex = getCurrentContext().getGeneratorIndex( m_fileInfo, m_totalSize );
|
|
||||||
|
|
||||||
typename std::vector<const IGenerator<T>*>::const_iterator it = m_composed.begin();
|
|
||||||
typename std::vector<const IGenerator<T>*>::const_iterator itEnd = m_composed.end();
|
|
||||||
for( size_t index = 0; it != itEnd; ++it )
|
|
||||||
{
|
|
||||||
const IGenerator<T>* generator = *it;
|
|
||||||
if( overallIndex >= index && overallIndex < index + generator->size() )
|
|
||||||
{
|
|
||||||
return generator->getValue( overallIndex-index );
|
|
||||||
}
|
|
||||||
index += generator->size();
|
|
||||||
}
|
|
||||||
CATCH_INTERNAL_ERROR( "Indexed past end of generated range" );
|
|
||||||
return T(); // Suppress spurious "not all control paths return a value" warning in Visual Studio - if you know how to fix this please do so
|
|
||||||
}
|
|
||||||
|
|
||||||
void add( const IGenerator<T>* generator ) {
|
|
||||||
m_totalSize += generator->size();
|
|
||||||
m_composed.push_back( generator );
|
|
||||||
}
|
|
||||||
|
|
||||||
CompositeGenerator& then( CompositeGenerator& other ) {
|
|
||||||
move( other );
|
|
||||||
return *this;
|
|
||||||
}
|
|
||||||
|
|
||||||
CompositeGenerator& then( T value ) {
|
|
||||||
ValuesGenerator<T>* valuesGen = new ValuesGenerator<T>();
|
|
||||||
valuesGen->add( value );
|
|
||||||
add( valuesGen );
|
|
||||||
return *this;
|
|
||||||
}
|
|
||||||
|
|
||||||
private:
|
|
||||||
|
|
||||||
void move( CompositeGenerator& other ) {
|
|
||||||
std::copy( other.m_composed.begin(), other.m_composed.end(), std::back_inserter( m_composed ) );
|
|
||||||
m_totalSize += other.m_totalSize;
|
|
||||||
other.m_composed.clear();
|
|
||||||
}
|
|
||||||
|
|
||||||
std::vector<const IGenerator<T>*> m_composed;
|
|
||||||
std::string m_fileInfo;
|
|
||||||
size_t m_totalSize;
|
|
||||||
};
|
|
||||||
|
|
||||||
namespace Generators
|
|
||||||
{
|
|
||||||
template<typename T>
|
|
||||||
CompositeGenerator<T> between( T from, T to ) {
|
|
||||||
CompositeGenerator<T> generators;
|
|
||||||
generators.add( new BetweenGenerator<T>( from, to ) );
|
|
||||||
return generators;
|
|
||||||
}
|
|
||||||
|
|
||||||
template<typename T>
|
|
||||||
CompositeGenerator<T> values( T val1, T val2 ) {
|
|
||||||
CompositeGenerator<T> generators;
|
|
||||||
ValuesGenerator<T>* valuesGen = new ValuesGenerator<T>();
|
|
||||||
valuesGen->add( val1 );
|
|
||||||
valuesGen->add( val2 );
|
|
||||||
generators.add( valuesGen );
|
|
||||||
return generators;
|
|
||||||
}
|
|
||||||
|
|
||||||
template<typename T>
|
|
||||||
CompositeGenerator<T> values( T val1, T val2, T val3 ){
|
|
||||||
CompositeGenerator<T> generators;
|
|
||||||
ValuesGenerator<T>* valuesGen = new ValuesGenerator<T>();
|
|
||||||
valuesGen->add( val1 );
|
|
||||||
valuesGen->add( val2 );
|
|
||||||
valuesGen->add( val3 );
|
|
||||||
generators.add( valuesGen );
|
|
||||||
return generators;
|
|
||||||
}
|
|
||||||
|
|
||||||
template<typename T>
|
|
||||||
CompositeGenerator<T> values( T val1, T val2, T val3, T val4 ) {
|
|
||||||
CompositeGenerator<T> generators;
|
|
||||||
ValuesGenerator<T>* valuesGen = new ValuesGenerator<T>();
|
|
||||||
valuesGen->add( val1 );
|
|
||||||
valuesGen->add( val2 );
|
|
||||||
valuesGen->add( val3 );
|
|
||||||
valuesGen->add( val4 );
|
|
||||||
generators.add( valuesGen );
|
|
||||||
return generators;
|
|
||||||
}
|
|
||||||
|
|
||||||
} // end namespace Generators
|
|
||||||
|
|
||||||
using namespace Generators;
|
|
||||||
|
|
||||||
} // end namespace Catch
|
|
||||||
|
|
||||||
#define INTERNAL_CATCH_LINESTR2( line ) #line
|
|
||||||
#define INTERNAL_CATCH_LINESTR( line ) INTERNAL_CATCH_LINESTR2( line )
|
|
||||||
|
|
||||||
#define INTERNAL_CATCH_GENERATE( expr ) expr.setFileInfo( __FILE__ "(" INTERNAL_CATCH_LINESTR( __LINE__ ) ")" )
|
|
||||||
|
|
||||||
#endif // TWOBLUECUBES_CATCH_GENERATORS_HPP_INCLUDED
|
|
@@ -1,86 +0,0 @@
|
|||||||
/*
|
|
||||||
* Created by Phil on 28/01/2011.
|
|
||||||
* Copyright 2011 Two Blue Cubes Ltd. All rights reserved.
|
|
||||||
*
|
|
||||||
* 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)
|
|
||||||
*/
|
|
||||||
#ifndef TWOBLUECUBES_CATCH_GENERATORS_IMPL_HPP_INCLUDED
|
|
||||||
#define TWOBLUECUBES_CATCH_GENERATORS_IMPL_HPP_INCLUDED
|
|
||||||
|
|
||||||
#include "catch_interfaces_generators.h"
|
|
||||||
|
|
||||||
#include "catch_common.h"
|
|
||||||
|
|
||||||
#include <vector>
|
|
||||||
#include <string>
|
|
||||||
#include <map>
|
|
||||||
|
|
||||||
namespace Catch {
|
|
||||||
|
|
||||||
struct GeneratorInfo : IGeneratorInfo {
|
|
||||||
|
|
||||||
GeneratorInfo( std::size_t size )
|
|
||||||
: m_size( size ),
|
|
||||||
m_currentIndex( 0 )
|
|
||||||
{}
|
|
||||||
|
|
||||||
bool moveNext() {
|
|
||||||
if( ++m_currentIndex == m_size ) {
|
|
||||||
m_currentIndex = 0;
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
std::size_t getCurrentIndex() const {
|
|
||||||
return m_currentIndex;
|
|
||||||
}
|
|
||||||
|
|
||||||
std::size_t m_size;
|
|
||||||
std::size_t m_currentIndex;
|
|
||||||
};
|
|
||||||
|
|
||||||
///////////////////////////////////////////////////////////////////////////
|
|
||||||
|
|
||||||
class GeneratorsForTest : public IGeneratorsForTest {
|
|
||||||
|
|
||||||
public:
|
|
||||||
~GeneratorsForTest() {
|
|
||||||
deleteAll( m_generatorsInOrder );
|
|
||||||
}
|
|
||||||
|
|
||||||
IGeneratorInfo& getGeneratorInfo( std::string const& fileInfo, std::size_t size ) {
|
|
||||||
std::map<std::string, IGeneratorInfo*>::const_iterator it = m_generatorsByName.find( fileInfo );
|
|
||||||
if( it == m_generatorsByName.end() ) {
|
|
||||||
IGeneratorInfo* info = new GeneratorInfo( size );
|
|
||||||
m_generatorsByName.insert( std::make_pair( fileInfo, info ) );
|
|
||||||
m_generatorsInOrder.push_back( info );
|
|
||||||
return *info;
|
|
||||||
}
|
|
||||||
return *it->second;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool moveNext() {
|
|
||||||
std::vector<IGeneratorInfo*>::const_iterator it = m_generatorsInOrder.begin();
|
|
||||||
std::vector<IGeneratorInfo*>::const_iterator itEnd = m_generatorsInOrder.end();
|
|
||||||
for(; it != itEnd; ++it ) {
|
|
||||||
if( (*it)->moveNext() )
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
private:
|
|
||||||
std::map<std::string, IGeneratorInfo*> m_generatorsByName;
|
|
||||||
std::vector<IGeneratorInfo*> m_generatorsInOrder;
|
|
||||||
};
|
|
||||||
|
|
||||||
IGeneratorsForTest* createGeneratorsForTest()
|
|
||||||
{
|
|
||||||
return new GeneratorsForTest();
|
|
||||||
}
|
|
||||||
|
|
||||||
} // end namespace Catch
|
|
||||||
|
|
||||||
#endif // TWOBLUECUBES_CATCH_GENERATORS_IMPL_HPP_INCLUDED
|
|
@@ -16,12 +16,10 @@
|
|||||||
#pragma clang diagnostic ignored "-Wweak-vtables"
|
#pragma clang diagnostic ignored "-Wweak-vtables"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include "../catch_runner.hpp"
|
#include "../catch_session.hpp"
|
||||||
#include "catch_registry_hub.hpp"
|
#include "catch_registry_hub.hpp"
|
||||||
#include "catch_notimplemented_exception.hpp"
|
#include "catch_notimplemented_exception.hpp"
|
||||||
#include "catch_context_impl.hpp"
|
|
||||||
#include "catch_console_colour_impl.hpp"
|
#include "catch_console_colour_impl.hpp"
|
||||||
#include "catch_generators_impl.hpp"
|
|
||||||
#include "catch_assertionresult.hpp"
|
#include "catch_assertionresult.hpp"
|
||||||
#include "catch_test_case_info.hpp"
|
#include "catch_test_case_info.hpp"
|
||||||
#include "catch_test_spec.hpp"
|
#include "catch_test_spec.hpp"
|
||||||
@@ -35,18 +33,26 @@
|
|||||||
#include "catch_tostring.hpp"
|
#include "catch_tostring.hpp"
|
||||||
#include "catch_result_builder.hpp"
|
#include "catch_result_builder.hpp"
|
||||||
#include "catch_tag_alias_registry.hpp"
|
#include "catch_tag_alias_registry.hpp"
|
||||||
|
#include "catch_test_case_tracker.hpp"
|
||||||
|
#include "catch_stream.hpp"
|
||||||
|
|
||||||
|
#include "../reporters/catch_reporter_multi.hpp"
|
||||||
#include "../reporters/catch_reporter_xml.hpp"
|
#include "../reporters/catch_reporter_xml.hpp"
|
||||||
#include "../reporters/catch_reporter_junit.hpp"
|
#include "../reporters/catch_reporter_junit.hpp"
|
||||||
#include "../reporters/catch_reporter_console.hpp"
|
#include "../reporters/catch_reporter_console.hpp"
|
||||||
#include "../reporters/catch_reporter_compact.hpp"
|
#include "../reporters/catch_reporter_compact.hpp"
|
||||||
|
|
||||||
namespace Catch {
|
namespace Catch {
|
||||||
|
// These are all here to avoid warnings about not having any out of line
|
||||||
|
// virtual methods
|
||||||
NonCopyable::~NonCopyable() {}
|
NonCopyable::~NonCopyable() {}
|
||||||
IShared::~IShared() {}
|
IShared::~IShared() {}
|
||||||
|
IStream::~IStream() CATCH_NOEXCEPT {}
|
||||||
|
FileStream::~FileStream() CATCH_NOEXCEPT {}
|
||||||
|
CoutStream::~CoutStream() CATCH_NOEXCEPT {}
|
||||||
|
DebugOutStream::~DebugOutStream() CATCH_NOEXCEPT {}
|
||||||
StreamBufBase::~StreamBufBase() CATCH_NOEXCEPT {}
|
StreamBufBase::~StreamBufBase() CATCH_NOEXCEPT {}
|
||||||
IContext::~IContext() {}
|
IRunContext::~IRunContext() {}
|
||||||
IResultCapture::~IResultCapture() {}
|
|
||||||
ITestCase::~ITestCase() {}
|
ITestCase::~ITestCase() {}
|
||||||
ITestCaseRegistry::~ITestCaseRegistry() {}
|
ITestCaseRegistry::~ITestCaseRegistry() {}
|
||||||
IRegistryHub::~IRegistryHub() {}
|
IRegistryHub::~IRegistryHub() {}
|
||||||
@@ -68,15 +74,11 @@ namespace Catch {
|
|||||||
StreamingReporterBase::~StreamingReporterBase() {}
|
StreamingReporterBase::~StreamingReporterBase() {}
|
||||||
ConsoleReporter::~ConsoleReporter() {}
|
ConsoleReporter::~ConsoleReporter() {}
|
||||||
CompactReporter::~CompactReporter() {}
|
CompactReporter::~CompactReporter() {}
|
||||||
IRunner::~IRunner() {}
|
|
||||||
IMutableContext::~IMutableContext() {}
|
|
||||||
IConfig::~IConfig() {}
|
IConfig::~IConfig() {}
|
||||||
XmlReporter::~XmlReporter() {}
|
XmlReporter::~XmlReporter() {}
|
||||||
JunitReporter::~JunitReporter() {}
|
JunitReporter::~JunitReporter() {}
|
||||||
TestRegistry::~TestRegistry() {}
|
TestRegistry::~TestRegistry() {}
|
||||||
FreeFunctionTestCase::~FreeFunctionTestCase() {}
|
FreeFunctionTestCase::~FreeFunctionTestCase() {}
|
||||||
IGeneratorInfo::~IGeneratorInfo() {}
|
|
||||||
IGeneratorsForTest::~IGeneratorsForTest() {}
|
|
||||||
WildcardPattern::~WildcardPattern() {}
|
WildcardPattern::~WildcardPattern() {}
|
||||||
TestSpec::Pattern::~Pattern() {}
|
TestSpec::Pattern::~Pattern() {}
|
||||||
TestSpec::NamePattern::~NamePattern() {}
|
TestSpec::NamePattern::~NamePattern() {}
|
||||||
@@ -89,6 +91,13 @@ namespace Catch {
|
|||||||
Matchers::Impl::StdString::EndsWith::~EndsWith() {}
|
Matchers::Impl::StdString::EndsWith::~EndsWith() {}
|
||||||
|
|
||||||
void Config::dummy() {}
|
void Config::dummy() {}
|
||||||
|
|
||||||
|
namespace TestCaseTracking {
|
||||||
|
ITracker::~ITracker() {}
|
||||||
|
TrackerBase::~TrackerBase() {}
|
||||||
|
SectionTracker::~SectionTracker() {}
|
||||||
|
IndexTracker::~IndexTracker() {}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef __clang__
|
#ifdef __clang__
|
||||||
|
@@ -16,30 +16,42 @@ namespace Catch {
|
|||||||
|
|
||||||
class TestCase;
|
class TestCase;
|
||||||
class AssertionResult;
|
class AssertionResult;
|
||||||
|
class ScopedMessageBuilder;
|
||||||
|
|
||||||
struct AssertionInfo;
|
struct AssertionInfo;
|
||||||
struct SectionInfo;
|
struct SectionInfo;
|
||||||
|
struct SectionEndInfo;
|
||||||
struct MessageInfo;
|
struct MessageInfo;
|
||||||
class ScopedMessageBuilder;
|
|
||||||
struct Counts;
|
struct Counts;
|
||||||
|
struct IConfig;
|
||||||
|
|
||||||
struct IResultCapture {
|
struct IRunContext {
|
||||||
|
|
||||||
virtual ~IResultCapture();
|
virtual ~IRunContext();
|
||||||
|
|
||||||
virtual void assertionEnded( AssertionResult const& result ) = 0;
|
virtual void assertionEnded( AssertionResult const& result ) = 0;
|
||||||
|
|
||||||
virtual bool sectionStarted( SectionInfo const& sectionInfo,
|
virtual bool sectionStarted( SectionInfo const& sectionInfo,
|
||||||
Counts& assertions ) = 0;
|
Counts& assertions ) = 0;
|
||||||
virtual void sectionEnded( SectionInfo const& name, Counts const& assertions, double _durationInSeconds ) = 0;
|
virtual void sectionEnded( SectionEndInfo const& endInfo ) = 0;
|
||||||
|
virtual void sectionEndedEarly( SectionEndInfo const& endInfo ) = 0;
|
||||||
|
|
||||||
virtual void pushScopedMessage( MessageInfo const& message ) = 0;
|
virtual void pushScopedMessage( MessageInfo const& message ) = 0;
|
||||||
virtual void popScopedMessage( MessageInfo const& message ) = 0;
|
virtual void popScopedMessage( MessageInfo const& message ) = 0;
|
||||||
|
|
||||||
virtual std::string getCurrentTestName() const = 0;
|
|
||||||
virtual const AssertionResult* getLastResult() const = 0;
|
|
||||||
|
|
||||||
virtual void handleFatalErrorCondition( std::string const& message ) = 0;
|
virtual void handleFatalErrorCondition( std::string const& message ) = 0;
|
||||||
|
|
||||||
|
virtual std::string getCurrentTestName() const = 0;
|
||||||
|
virtual AssertionResult const* getLastResult() const = 0;
|
||||||
|
virtual bool isAborting() const = 0;
|
||||||
|
|
||||||
|
virtual IConfig const& config() const = 0;
|
||||||
};
|
};
|
||||||
|
|
||||||
IResultCapture& getResultCapture();
|
IRunContext* tryGetCurrentRunContext();
|
||||||
|
IRunContext& getCurrentRunContext();
|
||||||
|
|
||||||
|
IConfig const* getCurrentConfig();
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif // TWOBLUECUBES_CATCH_INTERFACES_CAPTURE_H_INCLUDED
|
#endif // TWOBLUECUBES_CATCH_INTERFACES_CAPTURE_H_INCLUDED
|
||||||
|
@@ -9,15 +9,20 @@
|
|||||||
#define TWOBLUECUBES_CATCH_INTERFACES_EXCEPTION_H_INCLUDED
|
#define TWOBLUECUBES_CATCH_INTERFACES_EXCEPTION_H_INCLUDED
|
||||||
|
|
||||||
#include <string>
|
#include <string>
|
||||||
|
#include <vector>
|
||||||
|
|
||||||
#include "catch_interfaces_registry_hub.h"
|
#include "catch_interfaces_registry_hub.h"
|
||||||
|
|
||||||
namespace Catch {
|
namespace Catch {
|
||||||
|
|
||||||
typedef std::string(*exceptionTranslateFunction)();
|
typedef std::string(*exceptionTranslateFunction)();
|
||||||
|
|
||||||
|
struct IExceptionTranslator;
|
||||||
|
typedef std::vector<const IExceptionTranslator*> ExceptionTranslators;
|
||||||
|
|
||||||
struct IExceptionTranslator {
|
struct IExceptionTranslator {
|
||||||
virtual ~IExceptionTranslator();
|
virtual ~IExceptionTranslator();
|
||||||
virtual std::string translate() const = 0;
|
virtual std::string translate( ExceptionTranslators::const_iterator it, ExceptionTranslators::const_iterator itEnd ) const = 0;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct IExceptionTranslatorRegistry {
|
struct IExceptionTranslatorRegistry {
|
||||||
@@ -35,9 +40,12 @@ namespace Catch {
|
|||||||
: m_translateFunction( translateFunction )
|
: m_translateFunction( translateFunction )
|
||||||
{}
|
{}
|
||||||
|
|
||||||
virtual std::string translate() const {
|
virtual std::string translate( ExceptionTranslators::const_iterator it, ExceptionTranslators::const_iterator itEnd ) const CATCH_OVERRIDE {
|
||||||
try {
|
try {
|
||||||
|
if( it == itEnd )
|
||||||
throw;
|
throw;
|
||||||
|
else
|
||||||
|
return (*it)->translate( it+1, itEnd );
|
||||||
}
|
}
|
||||||
catch( T& ex ) {
|
catch( T& ex ) {
|
||||||
return m_translateFunction( ex );
|
return m_translateFunction( ex );
|
||||||
@@ -58,9 +66,11 @@ namespace Catch {
|
|||||||
}
|
}
|
||||||
|
|
||||||
///////////////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////////////
|
||||||
#define INTERNAL_CATCH_TRANSLATE_EXCEPTION( signature ) \
|
#define INTERNAL_CATCH_TRANSLATE_EXCEPTION2( translatorName, signature ) \
|
||||||
static std::string INTERNAL_CATCH_UNIQUE_NAME( catch_internal_ExceptionTranslator )( signature ); \
|
static std::string translatorName( signature ); \
|
||||||
namespace{ Catch::ExceptionTranslatorRegistrar INTERNAL_CATCH_UNIQUE_NAME( catch_internal_ExceptionRegistrar )( &INTERNAL_CATCH_UNIQUE_NAME( catch_internal_ExceptionTranslator ) ); }\
|
namespace{ Catch::ExceptionTranslatorRegistrar INTERNAL_CATCH_UNIQUE_NAME( catch_internal_ExceptionRegistrar )( &translatorName ); }\
|
||||||
static std::string INTERNAL_CATCH_UNIQUE_NAME( catch_internal_ExceptionTranslator )( signature )
|
static std::string translatorName( signature )
|
||||||
|
|
||||||
|
#define INTERNAL_CATCH_TRANSLATE_EXCEPTION( signature ) INTERNAL_CATCH_TRANSLATE_EXCEPTION2( INTERNAL_CATCH_UNIQUE_NAME( catch_internal_ExceptionTranslator ), signature )
|
||||||
|
|
||||||
#endif // TWOBLUECUBES_CATCH_INTERFACES_EXCEPTION_H_INCLUDED
|
#endif // TWOBLUECUBES_CATCH_INTERFACES_EXCEPTION_H_INCLUDED
|
||||||
|
@@ -1,32 +0,0 @@
|
|||||||
/*
|
|
||||||
* Created by Phil on 7/8/2012.
|
|
||||||
* Copyright 2011 Two Blue Cubes Ltd. All rights reserved.
|
|
||||||
*
|
|
||||||
* 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)
|
|
||||||
*/
|
|
||||||
#ifndef TWOBLUECUBES_CATCH_INTERFACES_GENERATORS_H_INCLUDED
|
|
||||||
#define TWOBLUECUBES_CATCH_INTERFACES_GENERATORS_H_INCLUDED
|
|
||||||
|
|
||||||
#include <string>
|
|
||||||
|
|
||||||
namespace Catch {
|
|
||||||
|
|
||||||
struct IGeneratorInfo {
|
|
||||||
virtual ~IGeneratorInfo();
|
|
||||||
virtual bool moveNext() = 0;
|
|
||||||
virtual std::size_t getCurrentIndex() const = 0;
|
|
||||||
};
|
|
||||||
|
|
||||||
struct IGeneratorsForTest {
|
|
||||||
virtual ~IGeneratorsForTest();
|
|
||||||
|
|
||||||
virtual IGeneratorInfo& getGeneratorInfo( std::string const& fileInfo, std::size_t size ) = 0;
|
|
||||||
virtual bool moveNext() = 0;
|
|
||||||
};
|
|
||||||
|
|
||||||
IGeneratorsForTest* createGeneratorsForTest();
|
|
||||||
|
|
||||||
} // end namespace Catch
|
|
||||||
|
|
||||||
#endif // TWOBLUECUBES_CATCH_INTERFACES_GENERATORS_H_INCLUDED
|
|
@@ -8,6 +8,8 @@
|
|||||||
#ifndef TWOBLUECUBES_CATCH_INTERFACES_REGISTRY_HUB_H_INCLUDED
|
#ifndef TWOBLUECUBES_CATCH_INTERFACES_REGISTRY_HUB_H_INCLUDED
|
||||||
#define TWOBLUECUBES_CATCH_INTERFACES_REGISTRY_HUB_H_INCLUDED
|
#define TWOBLUECUBES_CATCH_INTERFACES_REGISTRY_HUB_H_INCLUDED
|
||||||
|
|
||||||
|
#include "catch_ptr.hpp"
|
||||||
|
|
||||||
#include <string>
|
#include <string>
|
||||||
|
|
||||||
namespace Catch {
|
namespace Catch {
|
||||||
@@ -29,7 +31,8 @@ namespace Catch {
|
|||||||
|
|
||||||
struct IMutableRegistryHub {
|
struct IMutableRegistryHub {
|
||||||
virtual ~IMutableRegistryHub();
|
virtual ~IMutableRegistryHub();
|
||||||
virtual void registerReporter( std::string const& name, IReporterFactory* factory ) = 0;
|
virtual void registerReporter( std::string const& name, Ptr<IReporterFactory> const& factory ) = 0;
|
||||||
|
virtual void registerListener( Ptr<IReporterFactory> const& factory ) = 0;
|
||||||
virtual void registerTest( TestCase const& testInfo ) = 0;
|
virtual void registerTest( TestCase const& testInfo ) = 0;
|
||||||
virtual void registerTranslator( const IExceptionTranslator* translator ) = 0;
|
virtual void registerTranslator( const IExceptionTranslator* translator ) = 0;
|
||||||
};
|
};
|
||||||
|
@@ -26,18 +26,18 @@
|
|||||||
namespace Catch
|
namespace Catch
|
||||||
{
|
{
|
||||||
struct ReporterConfig {
|
struct ReporterConfig {
|
||||||
explicit ReporterConfig( Ptr<IConfig> const& _fullConfig )
|
explicit ReporterConfig( Ptr<IConfig const> const& _fullConfig )
|
||||||
: m_stream( &_fullConfig->stream() ), m_fullConfig( _fullConfig ) {}
|
: m_stream( &_fullConfig->stream() ), m_fullConfig( _fullConfig ) {}
|
||||||
|
|
||||||
ReporterConfig( Ptr<IConfig> const& _fullConfig, std::ostream& _stream )
|
ReporterConfig( Ptr<IConfig const> const& _fullConfig, std::ostream& _stream )
|
||||||
: m_stream( &_stream ), m_fullConfig( _fullConfig ) {}
|
: m_stream( &_stream ), m_fullConfig( _fullConfig ) {}
|
||||||
|
|
||||||
std::ostream& stream() const { return *m_stream; }
|
std::ostream& stream() const { return *m_stream; }
|
||||||
Ptr<IConfig> fullConfig() const { return m_fullConfig; }
|
Ptr<IConfig const> fullConfig() const { return m_fullConfig; }
|
||||||
|
|
||||||
private:
|
private:
|
||||||
std::ostream* m_stream;
|
std::ostream* m_stream;
|
||||||
Ptr<IConfig> m_fullConfig;
|
Ptr<IConfig const> m_fullConfig;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct ReporterPreferences {
|
struct ReporterPreferences {
|
||||||
@@ -240,6 +240,7 @@ namespace Catch
|
|||||||
|
|
||||||
// The return value indicates if the messages buffer should be cleared:
|
// The return value indicates if the messages buffer should be cleared:
|
||||||
virtual bool assertionEnded( AssertionStats const& assertionStats ) = 0;
|
virtual bool assertionEnded( AssertionStats const& assertionStats ) = 0;
|
||||||
|
|
||||||
virtual void sectionEnded( SectionStats const& sectionStats ) = 0;
|
virtual void sectionEnded( SectionStats const& sectionStats ) = 0;
|
||||||
virtual void testCaseEnded( TestCaseStats const& testCaseStats ) = 0;
|
virtual void testCaseEnded( TestCaseStats const& testCaseStats ) = 0;
|
||||||
virtual void testGroupEnded( TestGroupStats const& testGroupStats ) = 0;
|
virtual void testGroupEnded( TestGroupStats const& testGroupStats ) = 0;
|
||||||
@@ -249,20 +250,24 @@ namespace Catch
|
|||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
struct IReporterFactory {
|
struct IReporterFactory : IShared {
|
||||||
virtual ~IReporterFactory();
|
virtual ~IReporterFactory();
|
||||||
virtual IStreamingReporter* create( ReporterConfig const& config ) const = 0;
|
virtual IStreamingReporter* create( ReporterConfig const& config ) const = 0;
|
||||||
virtual std::string getDescription() const = 0;
|
virtual std::string getDescription() const = 0;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct IReporterRegistry {
|
struct IReporterRegistry {
|
||||||
typedef std::map<std::string, IReporterFactory*> FactoryMap;
|
typedef std::map<std::string, Ptr<IReporterFactory> > FactoryMap;
|
||||||
|
typedef std::vector<Ptr<IReporterFactory> > Listeners;
|
||||||
|
|
||||||
virtual ~IReporterRegistry();
|
virtual ~IReporterRegistry();
|
||||||
virtual IStreamingReporter* create( std::string const& name, Ptr<IConfig> const& config ) const = 0;
|
virtual IStreamingReporter* create( std::string const& name, Ptr<IConfig const> const& config ) const = 0;
|
||||||
virtual FactoryMap const& getFactories() const = 0;
|
virtual FactoryMap const& getFactories() const = 0;
|
||||||
|
virtual Listeners const& getListeners() const = 0;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
Ptr<IStreamingReporter> addReporter( Ptr<IStreamingReporter> const& existingReporter, Ptr<IStreamingReporter> const& additionalReporter );
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif // TWOBLUECUBES_CATCH_INTERFACES_REPORTER_H_INCLUDED
|
#endif // TWOBLUECUBES_CATCH_INTERFACES_REPORTER_H_INCLUDED
|
||||||
|
@@ -1,20 +0,0 @@
|
|||||||
/*
|
|
||||||
* Created by Phil on 07/01/2011.
|
|
||||||
* Copyright 2011 Two Blue Cubes Ltd. All rights reserved.
|
|
||||||
*
|
|
||||||
* 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)
|
|
||||||
*/
|
|
||||||
#ifndef TWOBLUECUBES_CATCH_INTERFACES_RUNNER_H_INCLUDED
|
|
||||||
#define TWOBLUECUBES_CATCH_INTERFACES_RUNNER_H_INCLUDED
|
|
||||||
|
|
||||||
namespace Catch {
|
|
||||||
class TestCase;
|
|
||||||
|
|
||||||
struct IRunner {
|
|
||||||
virtual ~IRunner();
|
|
||||||
virtual bool aborting() const = 0;
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
#endif // TWOBLUECUBES_CATCH_INTERFACES_RUNNER_H_INCLUDED
|
|
@@ -28,9 +28,13 @@ namespace Catch {
|
|||||||
struct ITestCaseRegistry {
|
struct ITestCaseRegistry {
|
||||||
virtual ~ITestCaseRegistry();
|
virtual ~ITestCaseRegistry();
|
||||||
virtual std::vector<TestCase> const& getAllTests() const = 0;
|
virtual std::vector<TestCase> const& getAllTests() const = 0;
|
||||||
virtual void getFilteredTests( TestSpec const& testSpec, IConfig const& config, std::vector<TestCase>& matchingTestCases, bool negated = false ) const = 0;
|
virtual std::vector<TestCase> const& getAllTestsSorted( IConfig const& config ) const = 0;
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
bool matchTest( TestCase const& testCase, TestSpec const& testSpec, IConfig const& config );
|
||||||
|
std::vector<TestCase> filterTests( std::vector<TestCase> const& testCases, TestSpec const& testSpec, IConfig const& config );
|
||||||
|
std::vector<TestCase> const& getAllTestCasesSorted( IConfig const& config );
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif // TWOBLUECUBES_CATCH_INTERFACES_TESTCASE_H_INCLUDED
|
#endif // TWOBLUECUBES_CATCH_INTERFACES_TESTCASE_H_INCLUDED
|
||||||
|
@@ -34,8 +34,7 @@ namespace Catch {
|
|||||||
nameAttr.setInitialIndent( 2 ).setIndent( 4 );
|
nameAttr.setInitialIndent( 2 ).setIndent( 4 );
|
||||||
tagsAttr.setIndent( 6 );
|
tagsAttr.setIndent( 6 );
|
||||||
|
|
||||||
std::vector<TestCase> matchedTestCases;
|
std::vector<TestCase> matchedTestCases = filterTests( getAllTestCasesSorted( config ), testSpec, config );
|
||||||
getRegistryHub().getTestCaseRegistry().getFilteredTests( testSpec, config, matchedTestCases );
|
|
||||||
for( std::vector<TestCase>::const_iterator it = matchedTestCases.begin(), itEnd = matchedTestCases.end();
|
for( std::vector<TestCase>::const_iterator it = matchedTestCases.begin(), itEnd = matchedTestCases.end();
|
||||||
it != itEnd;
|
it != itEnd;
|
||||||
++it ) {
|
++it ) {
|
||||||
@@ -63,8 +62,7 @@ namespace Catch {
|
|||||||
if( !config.testSpec().hasFilters() )
|
if( !config.testSpec().hasFilters() )
|
||||||
testSpec = TestSpecParser( ITagAliasRegistry::get() ).parse( "*" ).testSpec();
|
testSpec = TestSpecParser( ITagAliasRegistry::get() ).parse( "*" ).testSpec();
|
||||||
std::size_t matchedTests = 0;
|
std::size_t matchedTests = 0;
|
||||||
std::vector<TestCase> matchedTestCases;
|
std::vector<TestCase> matchedTestCases = filterTests( getAllTestCasesSorted( config ), testSpec, config );
|
||||||
getRegistryHub().getTestCaseRegistry().getFilteredTests( testSpec, config, matchedTestCases );
|
|
||||||
for( std::vector<TestCase>::const_iterator it = matchedTestCases.begin(), itEnd = matchedTestCases.end();
|
for( std::vector<TestCase>::const_iterator it = matchedTestCases.begin(), itEnd = matchedTestCases.end();
|
||||||
it != itEnd;
|
it != itEnd;
|
||||||
++it ) {
|
++it ) {
|
||||||
@@ -104,8 +102,7 @@ namespace Catch {
|
|||||||
|
|
||||||
std::map<std::string, TagInfo> tagCounts;
|
std::map<std::string, TagInfo> tagCounts;
|
||||||
|
|
||||||
std::vector<TestCase> matchedTestCases;
|
std::vector<TestCase> matchedTestCases = filterTests( getAllTestCasesSorted( config ), testSpec, config );
|
||||||
getRegistryHub().getTestCaseRegistry().getFilteredTests( testSpec, config, matchedTestCases );
|
|
||||||
for( std::vector<TestCase>::const_iterator it = matchedTestCases.begin(), itEnd = matchedTestCases.end();
|
for( std::vector<TestCase>::const_iterator it = matchedTestCases.begin(), itEnd = matchedTestCases.end();
|
||||||
it != itEnd;
|
it != itEnd;
|
||||||
++it ) {
|
++it ) {
|
||||||
|
@@ -12,6 +12,12 @@ namespace Catch {
|
|||||||
namespace Matchers {
|
namespace Matchers {
|
||||||
namespace Impl {
|
namespace Impl {
|
||||||
|
|
||||||
|
namespace Generic {
|
||||||
|
template<typename ExpressionT> class AllOf;
|
||||||
|
template<typename ExpressionT> class AnyOf;
|
||||||
|
template<typename ExpressionT> class Not;
|
||||||
|
}
|
||||||
|
|
||||||
template<typename ExpressionT>
|
template<typename ExpressionT>
|
||||||
struct Matcher : SharedImpl<IShared>
|
struct Matcher : SharedImpl<IShared>
|
||||||
{
|
{
|
||||||
@@ -21,6 +27,10 @@ namespace Matchers {
|
|||||||
virtual Ptr<Matcher> clone() const = 0;
|
virtual Ptr<Matcher> clone() const = 0;
|
||||||
virtual bool match( ExpressionT const& expr ) const = 0;
|
virtual bool match( ExpressionT const& expr ) const = 0;
|
||||||
virtual std::string toString() const = 0;
|
virtual std::string toString() const = 0;
|
||||||
|
|
||||||
|
Generic::AllOf<ExpressionT> operator && ( Matcher<ExpressionT> const& other ) const;
|
||||||
|
Generic::AnyOf<ExpressionT> operator || ( Matcher<ExpressionT> const& other ) const;
|
||||||
|
Generic::Not<ExpressionT> operator ! () const;
|
||||||
};
|
};
|
||||||
|
|
||||||
template<typename DerivedT, typename ExpressionT>
|
template<typename DerivedT, typename ExpressionT>
|
||||||
@@ -32,6 +42,22 @@ namespace Matchers {
|
|||||||
};
|
};
|
||||||
|
|
||||||
namespace Generic {
|
namespace Generic {
|
||||||
|
template<typename ExpressionT>
|
||||||
|
class Not : public MatcherImpl<Not<ExpressionT>, ExpressionT> {
|
||||||
|
public:
|
||||||
|
explicit Not( Matcher<ExpressionT> const& matcher ) : m_matcher(matcher.clone()) {}
|
||||||
|
Not( Not const& other ) : m_matcher( other.m_matcher ) {}
|
||||||
|
|
||||||
|
virtual bool match( ExpressionT const& expr ) const CATCH_OVERRIDE {
|
||||||
|
return !m_matcher->match( expr );
|
||||||
|
}
|
||||||
|
|
||||||
|
virtual std::string toString() const CATCH_OVERRIDE {
|
||||||
|
return "not " + m_matcher->toString();
|
||||||
|
}
|
||||||
|
private:
|
||||||
|
Ptr< Matcher<ExpressionT> > m_matcher;
|
||||||
|
};
|
||||||
|
|
||||||
template<typename ExpressionT>
|
template<typename ExpressionT>
|
||||||
class AllOf : public MatcherImpl<AllOf<ExpressionT>, ExpressionT> {
|
class AllOf : public MatcherImpl<AllOf<ExpressionT>, ExpressionT> {
|
||||||
@@ -63,6 +89,12 @@ namespace Matchers {
|
|||||||
return oss.str();
|
return oss.str();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
AllOf operator && ( Matcher<ExpressionT> const& other ) const {
|
||||||
|
AllOf allOfExpr( *this );
|
||||||
|
allOfExpr.add( other );
|
||||||
|
return allOfExpr;
|
||||||
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
std::vector<Ptr<Matcher<ExpressionT> > > m_matchers;
|
std::vector<Ptr<Matcher<ExpressionT> > > m_matchers;
|
||||||
};
|
};
|
||||||
@@ -97,12 +129,40 @@ namespace Matchers {
|
|||||||
return oss.str();
|
return oss.str();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
AnyOf operator || ( Matcher<ExpressionT> const& other ) const {
|
||||||
|
AnyOf anyOfExpr( *this );
|
||||||
|
anyOfExpr.add( other );
|
||||||
|
return anyOfExpr;
|
||||||
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
std::vector<Ptr<Matcher<ExpressionT> > > m_matchers;
|
std::vector<Ptr<Matcher<ExpressionT> > > m_matchers;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
} // namespace Generic
|
||||||
|
|
||||||
|
template<typename ExpressionT>
|
||||||
|
Generic::AllOf<ExpressionT> Matcher<ExpressionT>::operator && ( Matcher<ExpressionT> const& other ) const {
|
||||||
|
Generic::AllOf<ExpressionT> allOfExpr;
|
||||||
|
allOfExpr.add( *this );
|
||||||
|
allOfExpr.add( other );
|
||||||
|
return allOfExpr;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
template<typename ExpressionT>
|
||||||
|
Generic::AnyOf<ExpressionT> Matcher<ExpressionT>::operator || ( Matcher<ExpressionT> const& other ) const {
|
||||||
|
Generic::AnyOf<ExpressionT> anyOfExpr;
|
||||||
|
anyOfExpr.add( *this );
|
||||||
|
anyOfExpr.add( other );
|
||||||
|
return anyOfExpr;
|
||||||
|
}
|
||||||
|
|
||||||
|
template<typename ExpressionT>
|
||||||
|
Generic::Not<ExpressionT> Matcher<ExpressionT>::operator ! () const {
|
||||||
|
return Generic::Not<ExpressionT>( *this );
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
namespace StdString {
|
namespace StdString {
|
||||||
|
|
||||||
inline std::string makeString( std::string const& str ) { return str; }
|
inline std::string makeString( std::string const& str ) { return str; }
|
||||||
@@ -204,6 +264,11 @@ namespace Matchers {
|
|||||||
|
|
||||||
// The following functions create the actual matcher objects.
|
// The following functions create the actual matcher objects.
|
||||||
// This allows the types to be inferred
|
// This allows the types to be inferred
|
||||||
|
template<typename ExpressionT>
|
||||||
|
inline Impl::Generic::Not<ExpressionT> Not( Impl::Matcher<ExpressionT> const& m ) {
|
||||||
|
return Impl::Generic::Not<ExpressionT>( m );
|
||||||
|
}
|
||||||
|
|
||||||
template<typename ExpressionT>
|
template<typename ExpressionT>
|
||||||
inline Impl::Generic::AllOf<ExpressionT> AllOf( Impl::Matcher<ExpressionT> const& m1,
|
inline Impl::Generic::AllOf<ExpressionT> AllOf( Impl::Matcher<ExpressionT> const& m1,
|
||||||
Impl::Matcher<ExpressionT> const& m2 ) {
|
Impl::Matcher<ExpressionT> const& m2 ) {
|
||||||
|
@@ -14,6 +14,8 @@
|
|||||||
|
|
||||||
namespace Catch {
|
namespace Catch {
|
||||||
|
|
||||||
|
struct IRunContext;
|
||||||
|
|
||||||
struct MessageInfo {
|
struct MessageInfo {
|
||||||
MessageInfo( std::string const& _macroName,
|
MessageInfo( std::string const& _macroName,
|
||||||
SourceLineInfo const& _lineInfo,
|
SourceLineInfo const& _lineInfo,
|
||||||
@@ -58,6 +60,7 @@ namespace Catch {
|
|||||||
ScopedMessage( ScopedMessage const& other );
|
ScopedMessage( ScopedMessage const& other );
|
||||||
~ScopedMessage();
|
~ScopedMessage();
|
||||||
|
|
||||||
|
IRunContext& m_runContext;
|
||||||
MessageInfo m_info;
|
MessageInfo m_info;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@@ -28,17 +28,19 @@ namespace Catch {
|
|||||||
////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
ScopedMessage::ScopedMessage( MessageBuilder const& builder )
|
ScopedMessage::ScopedMessage( MessageBuilder const& builder )
|
||||||
: m_info( builder.m_info )
|
: m_info( builder.m_info ),
|
||||||
|
m_runContext( getCurrentRunContext() )
|
||||||
{
|
{
|
||||||
m_info.message = builder.m_stream.str();
|
m_info.message = builder.m_stream.str();
|
||||||
getResultCapture().pushScopedMessage( m_info );
|
m_runContext.pushScopedMessage( m_info );
|
||||||
}
|
}
|
||||||
ScopedMessage::ScopedMessage( ScopedMessage const& other )
|
ScopedMessage::ScopedMessage( ScopedMessage const& other )
|
||||||
: m_info( other.m_info )
|
: m_info( other.m_info ),
|
||||||
|
m_runContext( other.m_runContext )
|
||||||
{}
|
{}
|
||||||
|
|
||||||
ScopedMessage::~ScopedMessage() {
|
ScopedMessage::~ScopedMessage() {
|
||||||
getResultCapture().popScopedMessage( m_info );
|
m_runContext.popScopedMessage( m_info );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@@ -26,24 +26,27 @@ namespace Catch {
|
|||||||
public: // IRegistryHub
|
public: // IRegistryHub
|
||||||
RegistryHub() {
|
RegistryHub() {
|
||||||
}
|
}
|
||||||
virtual IReporterRegistry const& getReporterRegistry() const {
|
virtual IReporterRegistry const& getReporterRegistry() const CATCH_OVERRIDE {
|
||||||
return m_reporterRegistry;
|
return m_reporterRegistry;
|
||||||
}
|
}
|
||||||
virtual ITestCaseRegistry const& getTestCaseRegistry() const {
|
virtual ITestCaseRegistry const& getTestCaseRegistry() const CATCH_OVERRIDE {
|
||||||
return m_testCaseRegistry;
|
return m_testCaseRegistry;
|
||||||
}
|
}
|
||||||
virtual IExceptionTranslatorRegistry& getExceptionTranslatorRegistry() {
|
virtual IExceptionTranslatorRegistry& getExceptionTranslatorRegistry() CATCH_OVERRIDE {
|
||||||
return m_exceptionTranslatorRegistry;
|
return m_exceptionTranslatorRegistry;
|
||||||
}
|
}
|
||||||
|
|
||||||
public: // IMutableRegistryHub
|
public: // IMutableRegistryHub
|
||||||
virtual void registerReporter( std::string const& name, IReporterFactory* factory ) {
|
virtual void registerReporter( std::string const& name, Ptr<IReporterFactory> const& factory ) CATCH_OVERRIDE {
|
||||||
m_reporterRegistry.registerReporter( name, factory );
|
m_reporterRegistry.registerReporter( name, factory );
|
||||||
}
|
}
|
||||||
virtual void registerTest( TestCase const& testInfo ) {
|
virtual void registerListener( Ptr<IReporterFactory> const& factory ) CATCH_OVERRIDE {
|
||||||
|
m_reporterRegistry.registerListener( factory );
|
||||||
|
}
|
||||||
|
virtual void registerTest( TestCase const& testInfo ) CATCH_OVERRIDE {
|
||||||
m_testCaseRegistry.registerTest( testInfo );
|
m_testCaseRegistry.registerTest( testInfo );
|
||||||
}
|
}
|
||||||
virtual void registerTranslator( const IExceptionTranslator* translator ) {
|
virtual void registerTranslator( const IExceptionTranslator* translator ) CATCH_OVERRIDE {
|
||||||
m_exceptionTranslatorRegistry.registerTranslator( translator );
|
m_exceptionTranslatorRegistry.registerTranslator( translator );
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -71,7 +74,6 @@ namespace Catch {
|
|||||||
void cleanUp() {
|
void cleanUp() {
|
||||||
delete getTheRegistryHub();
|
delete getTheRegistryHub();
|
||||||
getTheRegistryHub() = CATCH_NULL;
|
getTheRegistryHub() = CATCH_NULL;
|
||||||
cleanUpContext();
|
|
||||||
}
|
}
|
||||||
std::string translateActiveException() {
|
std::string translateActiveException() {
|
||||||
return getRegistryHub().getExceptionTranslatorRegistry().translateActiveException();
|
return getRegistryHub().getExceptionTranslatorRegistry().translateActiveException();
|
||||||
|
@@ -36,7 +36,7 @@ namespace Catch {
|
|||||||
template<typename T>
|
template<typename T>
|
||||||
class ReporterRegistrar {
|
class ReporterRegistrar {
|
||||||
|
|
||||||
class ReporterFactory : public IReporterFactory {
|
class ReporterFactory : public SharedImpl<IReporterFactory> {
|
||||||
|
|
||||||
// *** Please Note ***:
|
// *** Please Note ***:
|
||||||
// - If you end up here looking at a compiler error because it's trying to register
|
// - If you end up here looking at a compiler error because it's trying to register
|
||||||
@@ -64,11 +64,35 @@ namespace Catch {
|
|||||||
getMutableRegistryHub().registerReporter( name, new ReporterFactory() );
|
getMutableRegistryHub().registerReporter( name, new ReporterFactory() );
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
template<typename T>
|
||||||
|
class ListenerRegistrar {
|
||||||
|
|
||||||
|
class ListenerFactory : public SharedImpl<IReporterFactory> {
|
||||||
|
|
||||||
|
virtual IStreamingReporter* create( ReporterConfig const& config ) const {
|
||||||
|
return new T( config );
|
||||||
|
}
|
||||||
|
virtual std::string getDescription() const {
|
||||||
|
return "";
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
public:
|
||||||
|
|
||||||
|
ListenerRegistrar() {
|
||||||
|
getMutableRegistryHub().registerListener( new ListenerFactory() );
|
||||||
|
}
|
||||||
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
#define INTERNAL_CATCH_REGISTER_LEGACY_REPORTER( name, reporterType ) \
|
#define INTERNAL_CATCH_REGISTER_LEGACY_REPORTER( name, reporterType ) \
|
||||||
namespace{ Catch::LegacyReporterRegistrar<reporterType> catch_internal_RegistrarFor##reporterType( name ); }
|
namespace{ Catch::LegacyReporterRegistrar<reporterType> catch_internal_RegistrarFor##reporterType( name ); }
|
||||||
|
|
||||||
#define INTERNAL_CATCH_REGISTER_REPORTER( name, reporterType ) \
|
#define INTERNAL_CATCH_REGISTER_REPORTER( name, reporterType ) \
|
||||||
namespace{ Catch::ReporterRegistrar<reporterType> catch_internal_RegistrarFor##reporterType( name ); }
|
namespace{ Catch::ReporterRegistrar<reporterType> catch_internal_RegistrarFor##reporterType( name ); }
|
||||||
|
|
||||||
|
#define INTERNAL_CATCH_REGISTER_LISTENER( listenerType ) \
|
||||||
|
namespace{ Catch::ListenerRegistrar<listenerType> catch_internal_RegistrarFor##listenerType; }
|
||||||
|
|
||||||
#endif // TWOBLUECUBES_CATCH_REPORTER_REGISTRARS_HPP_INCLUDED
|
#endif // TWOBLUECUBES_CATCH_REPORTER_REGISTRARS_HPP_INCLUDED
|
||||||
|
@@ -18,27 +18,32 @@ namespace Catch {
|
|||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
virtual ~ReporterRegistry() {
|
virtual ~ReporterRegistry() CATCH_OVERRIDE {}
|
||||||
deleteAllValues( m_factories );
|
|
||||||
}
|
|
||||||
|
|
||||||
virtual IStreamingReporter* create( std::string const& name, Ptr<IConfig> const& config ) const {
|
virtual IStreamingReporter* create( std::string const& name, Ptr<IConfig const> const& config ) const CATCH_OVERRIDE {
|
||||||
FactoryMap::const_iterator it = m_factories.find( name );
|
FactoryMap::const_iterator it = m_factories.find( name );
|
||||||
if( it == m_factories.end() )
|
if( it == m_factories.end() )
|
||||||
return CATCH_NULL;
|
return CATCH_NULL;
|
||||||
return it->second->create( ReporterConfig( config ) );
|
return it->second->create( ReporterConfig( config ) );
|
||||||
}
|
}
|
||||||
|
|
||||||
void registerReporter( std::string const& name, IReporterFactory* factory ) {
|
void registerReporter( std::string const& name, Ptr<IReporterFactory> const& factory ) {
|
||||||
m_factories.insert( std::make_pair( name, factory ) );
|
m_factories.insert( std::make_pair( name, factory ) );
|
||||||
}
|
}
|
||||||
|
void registerListener( Ptr<IReporterFactory> const& factory ) {
|
||||||
|
m_listeners.push_back( factory );
|
||||||
|
}
|
||||||
|
|
||||||
FactoryMap const& getFactories() const {
|
virtual FactoryMap const& getFactories() const CATCH_OVERRIDE {
|
||||||
return m_factories;
|
return m_factories;
|
||||||
}
|
}
|
||||||
|
virtual Listeners const& getListeners() const CATCH_OVERRIDE {
|
||||||
|
return m_listeners;
|
||||||
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
FactoryMap m_factories;
|
FactoryMap m_factories;
|
||||||
|
Listeners m_listeners;
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -15,6 +15,7 @@
|
|||||||
|
|
||||||
namespace Catch {
|
namespace Catch {
|
||||||
|
|
||||||
|
struct IRunContext;
|
||||||
struct TestFailureException{};
|
struct TestFailureException{};
|
||||||
|
|
||||||
template<typename T> class ExpressionLhs;
|
template<typename T> class ExpressionLhs;
|
||||||
@@ -77,6 +78,7 @@ namespace Catch {
|
|||||||
bool allowThrows() const;
|
bool allowThrows() const;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
IRunContext& m_runContext;
|
||||||
AssertionInfo m_assertionInfo;
|
AssertionInfo m_assertionInfo;
|
||||||
AssertionResultData m_data;
|
AssertionResultData m_data;
|
||||||
struct ExprComponents {
|
struct ExprComponents {
|
||||||
|
@@ -9,9 +9,7 @@
|
|||||||
#define TWOBLUECUBES_CATCH_RESULT_BUILDER_HPP_INCLUDED
|
#define TWOBLUECUBES_CATCH_RESULT_BUILDER_HPP_INCLUDED
|
||||||
|
|
||||||
#include "catch_result_builder.h"
|
#include "catch_result_builder.h"
|
||||||
#include "catch_context.h"
|
|
||||||
#include "catch_interfaces_config.h"
|
#include "catch_interfaces_config.h"
|
||||||
#include "catch_interfaces_runner.h"
|
|
||||||
#include "catch_interfaces_capture.h"
|
#include "catch_interfaces_capture.h"
|
||||||
#include "catch_interfaces_registry_hub.h"
|
#include "catch_interfaces_registry_hub.h"
|
||||||
#include "catch_wildcard_pattern.hpp"
|
#include "catch_wildcard_pattern.hpp"
|
||||||
@@ -28,7 +26,8 @@ namespace Catch {
|
|||||||
char const* capturedExpression,
|
char const* capturedExpression,
|
||||||
ResultDisposition::Flags resultDisposition,
|
ResultDisposition::Flags resultDisposition,
|
||||||
char const* secondArg )
|
char const* secondArg )
|
||||||
: m_assertionInfo( macroName, lineInfo, capturedExpressionWithSecondArgument( capturedExpression, secondArg ), resultDisposition ),
|
: m_runContext( getCurrentRunContext() ),
|
||||||
|
m_assertionInfo( macroName, lineInfo, capturedExpressionWithSecondArgument( capturedExpression, secondArg ), resultDisposition ),
|
||||||
m_shouldDebugBreak( false ),
|
m_shouldDebugBreak( false ),
|
||||||
m_shouldThrow( false )
|
m_shouldThrow( false )
|
||||||
{}
|
{}
|
||||||
@@ -98,12 +97,12 @@ namespace Catch {
|
|||||||
}
|
}
|
||||||
void ResultBuilder::handleResult( AssertionResult const& result )
|
void ResultBuilder::handleResult( AssertionResult const& result )
|
||||||
{
|
{
|
||||||
getResultCapture().assertionEnded( result );
|
m_runContext.assertionEnded( result );
|
||||||
|
|
||||||
if( !result.isOk() ) {
|
if( !result.isOk() ) {
|
||||||
if( getCurrentContext().getConfig()->shouldDebugBreak() )
|
if( m_runContext.config().shouldDebugBreak() )
|
||||||
m_shouldDebugBreak = true;
|
m_shouldDebugBreak = true;
|
||||||
if( getCurrentContext().getRunner()->aborting() || (m_assertionInfo.resultDisposition & ResultDisposition::Normal) )
|
if( m_runContext.isAborting() || (m_assertionInfo.resultDisposition & ResultDisposition::Normal) )
|
||||||
m_shouldThrow = true;
|
m_shouldThrow = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -113,7 +112,7 @@ namespace Catch {
|
|||||||
}
|
}
|
||||||
|
|
||||||
bool ResultBuilder::shouldDebugBreak() const { return m_shouldDebugBreak; }
|
bool ResultBuilder::shouldDebugBreak() const { return m_shouldDebugBreak; }
|
||||||
bool ResultBuilder::allowThrows() const { return getCurrentContext().getConfig()->allowThrows(); }
|
bool ResultBuilder::allowThrows() const { return m_runContext.config().allowThrows(); }
|
||||||
|
|
||||||
AssertionResult ResultBuilder::build() const
|
AssertionResult ResultBuilder::build() const
|
||||||
{
|
{
|
||||||
|
@@ -8,7 +8,7 @@
|
|||||||
#ifndef TWOBLUECUBES_CATCH_RUNNER_IMPL_HPP_INCLUDED
|
#ifndef TWOBLUECUBES_CATCH_RUNNER_IMPL_HPP_INCLUDED
|
||||||
#define TWOBLUECUBES_CATCH_RUNNER_IMPL_HPP_INCLUDED
|
#define TWOBLUECUBES_CATCH_RUNNER_IMPL_HPP_INCLUDED
|
||||||
|
|
||||||
#include "catch_interfaces_runner.h"
|
#include "catch_interfaces_capture.h"
|
||||||
#include "catch_interfaces_reporter.h"
|
#include "catch_interfaces_reporter.h"
|
||||||
#include "catch_interfaces_exception.h"
|
#include "catch_interfaces_exception.h"
|
||||||
#include "catch_config.hpp"
|
#include "catch_config.hpp"
|
||||||
@@ -52,7 +52,34 @@ namespace Catch {
|
|||||||
|
|
||||||
///////////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
class RunContext : public IResultCapture, public IRunner {
|
namespace {
|
||||||
|
IRunContext* s_currentRunContext = CATCH_NULL;
|
||||||
|
|
||||||
|
void setCurrentRunContext( IRunContext* context ) {
|
||||||
|
s_currentRunContext = context;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
IRunContext* tryGetCurrentRunContext() {
|
||||||
|
return s_currentRunContext;
|
||||||
|
}
|
||||||
|
IRunContext& getCurrentRunContext() {
|
||||||
|
if( IRunContext* capture = tryGetCurrentRunContext() )
|
||||||
|
return *capture;
|
||||||
|
else
|
||||||
|
throw std::logic_error( "No current test runner" );
|
||||||
|
}
|
||||||
|
IConfig const* getCurrentConfig() {
|
||||||
|
if( IRunContext* capture = tryGetCurrentRunContext() )
|
||||||
|
return &capture->config();
|
||||||
|
else
|
||||||
|
return CATCH_NULL;
|
||||||
|
}
|
||||||
|
AssertionResult const* getLastResult() {
|
||||||
|
return getCurrentRunContext().getLastResult();
|
||||||
|
}
|
||||||
|
|
||||||
|
class RunContext : public IRunContext {
|
||||||
|
|
||||||
RunContext( RunContext const& );
|
RunContext( RunContext const& );
|
||||||
void operator =( RunContext const& );
|
void operator =( RunContext const& );
|
||||||
@@ -61,84 +88,66 @@ namespace Catch {
|
|||||||
|
|
||||||
explicit RunContext( Ptr<IConfig const> const& _config, Ptr<IStreamingReporter> const& reporter )
|
explicit RunContext( Ptr<IConfig const> const& _config, Ptr<IStreamingReporter> const& reporter )
|
||||||
: m_runInfo( _config->name() ),
|
: m_runInfo( _config->name() ),
|
||||||
m_context( getCurrentMutableContext() ),
|
|
||||||
m_activeTestCase( CATCH_NULL ),
|
|
||||||
m_config( _config ),
|
m_config( _config ),
|
||||||
m_reporter( reporter ),
|
m_reporter( reporter ),
|
||||||
m_prevRunner( m_context.getRunner() ),
|
m_activeTestCaseInfo( CATCH_NULL )
|
||||||
m_prevResultCapture( m_context.getResultCapture() ),
|
|
||||||
m_prevConfig( m_context.getConfig() )
|
|
||||||
{
|
{
|
||||||
m_context.setRunner( this );
|
setCurrentRunContext( this );
|
||||||
m_context.setConfig( m_config );
|
|
||||||
m_context.setResultCapture( this );
|
|
||||||
m_reporter->testRunStarting( m_runInfo );
|
m_reporter->testRunStarting( m_runInfo );
|
||||||
}
|
}
|
||||||
|
|
||||||
virtual ~RunContext() {
|
virtual ~RunContext() {
|
||||||
m_reporter->testRunEnded( TestRunStats( m_runInfo, m_totals, aborting() ) );
|
m_reporter->testRunEnded( TestRunStats( m_runInfo, m_totals, isAborting() ) );
|
||||||
m_context.setRunner( m_prevRunner );
|
setCurrentRunContext( CATCH_NULL );
|
||||||
m_context.setConfig( Ptr<IConfig const>() );
|
|
||||||
m_context.setResultCapture( m_prevResultCapture );
|
|
||||||
m_context.setConfig( m_prevConfig );
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void testGroupStarting( std::string const& testSpec, std::size_t groupIndex, std::size_t groupsCount ) {
|
void testGroupStarting( std::string const& testSpec, std::size_t groupIndex, std::size_t groupsCount ) {
|
||||||
m_reporter->testGroupStarting( GroupInfo( testSpec, groupIndex, groupsCount ) );
|
m_reporter->testGroupStarting( GroupInfo( testSpec, groupIndex, groupsCount ) );
|
||||||
}
|
}
|
||||||
void testGroupEnded( std::string const& testSpec, Totals const& totals, std::size_t groupIndex, std::size_t groupsCount ) {
|
void testGroupEnded( std::string const& testSpec, Totals const& totals, std::size_t groupIndex, std::size_t groupsCount ) {
|
||||||
m_reporter->testGroupEnded( TestGroupStats( GroupInfo( testSpec, groupIndex, groupsCount ), totals, aborting() ) );
|
m_reporter->testGroupEnded( TestGroupStats( GroupInfo( testSpec, groupIndex, groupsCount ), totals, isAborting() ) );
|
||||||
}
|
}
|
||||||
|
|
||||||
Totals runTest( TestCase const& testCase ) {
|
Totals runTest( TestCase const& testCase ) {
|
||||||
|
m_activeTestCaseInfo = &testCase;
|
||||||
|
|
||||||
Totals prevTotals = m_totals;
|
Totals prevTotals = m_totals;
|
||||||
|
std::string redirectedCout, redirectedCerr;
|
||||||
|
|
||||||
std::string redirectedCout;
|
m_reporter->testCaseStarting( testCase );
|
||||||
std::string redirectedCerr;
|
|
||||||
|
|
||||||
TestCaseInfo testInfo = testCase.getTestCaseInfo();
|
ITracker* m_testCaseTracker;
|
||||||
|
|
||||||
m_reporter->testCaseStarting( testInfo );
|
|
||||||
|
|
||||||
m_activeTestCase = &testCase;
|
|
||||||
m_testCaseTracker = TestCaseTracker( testInfo.name );
|
|
||||||
|
|
||||||
|
m_trackerContext.startRun();
|
||||||
do {
|
do {
|
||||||
do {
|
m_trackerContext.startCycle();
|
||||||
runCurrentTest( redirectedCout, redirectedCerr );
|
m_testCaseTracker = &SectionTracker::acquire( m_trackerContext, testCase.name );
|
||||||
|
runTest( testCase, redirectedCout, redirectedCerr );
|
||||||
}
|
}
|
||||||
while( !m_testCaseTracker->isCompleted() && !aborting() );
|
while( !m_testCaseTracker->isSuccessfullyCompleted() && !isAborting() );
|
||||||
}
|
|
||||||
while( getCurrentContext().advanceGeneratorsForCurrentTest() && !aborting() );
|
|
||||||
|
|
||||||
Totals deltaTotals = m_totals.delta( prevTotals );
|
Totals deltaTotals = m_totals.delta( prevTotals );
|
||||||
m_totals.testCases += deltaTotals.testCases;
|
m_totals.testCases += deltaTotals.testCases;
|
||||||
m_reporter->testCaseEnded( TestCaseStats( testInfo,
|
m_reporter->testCaseEnded( TestCaseStats( testCase,
|
||||||
deltaTotals,
|
deltaTotals,
|
||||||
redirectedCout,
|
redirectedCout,
|
||||||
redirectedCerr,
|
redirectedCerr,
|
||||||
aborting() ) );
|
isAborting() ) );
|
||||||
|
|
||||||
m_activeTestCase = CATCH_NULL;
|
m_activeTestCaseInfo = CATCH_NULL;
|
||||||
m_testCaseTracker.reset();
|
|
||||||
|
|
||||||
return deltaTotals;
|
return deltaTotals;
|
||||||
}
|
}
|
||||||
|
|
||||||
Ptr<IConfig const> config() const {
|
private: // IRunContext
|
||||||
return m_config;
|
|
||||||
}
|
|
||||||
|
|
||||||
private: // IResultCapture
|
|
||||||
|
|
||||||
|
|
||||||
virtual void assertionEnded( AssertionResult const& result ) {
|
virtual void assertionEnded( AssertionResult const& result ) CATCH_OVERRIDE {
|
||||||
if( result.getResultType() == ResultWas::Ok ) {
|
if( result.getResultType() == ResultWas::Ok )
|
||||||
m_totals.assertions.passed++;
|
m_totals.assertions.passed++;
|
||||||
}
|
else if( !result.isOk() )
|
||||||
else if( !result.isOk() ) {
|
|
||||||
m_totals.assertions.failed++;
|
m_totals.assertions.failed++;
|
||||||
}
|
|
||||||
|
|
||||||
if( m_reporter->assertionEnded( AssertionStats( result, m_messages, m_totals ) ) )
|
if( m_reporter->assertionEnded( AssertionStats( result, m_messages, m_totals ) ) )
|
||||||
m_messages.clear();
|
m_messages.clear();
|
||||||
@@ -148,16 +157,17 @@ namespace Catch {
|
|||||||
m_lastResult = result;
|
m_lastResult = result;
|
||||||
}
|
}
|
||||||
|
|
||||||
virtual bool sectionStarted (
|
virtual bool sectionStarted
|
||||||
SectionInfo const& sectionInfo,
|
( SectionInfo const& sectionInfo,
|
||||||
Counts& assertions
|
Counts& assertions ) CATCH_OVERRIDE
|
||||||
)
|
|
||||||
{
|
{
|
||||||
std::ostringstream oss;
|
std::ostringstream oss;
|
||||||
oss << sectionInfo.name << "@" << sectionInfo.lineInfo;
|
oss << sectionInfo.name << "@" << sectionInfo.lineInfo;
|
||||||
|
|
||||||
if( !m_testCaseTracker->enterSection( oss.str() ) )
|
ITracker& sectionTracker = SectionTracker::acquire( m_trackerContext, oss.str() );
|
||||||
|
if( !sectionTracker.isOpen() )
|
||||||
return false;
|
return false;
|
||||||
|
m_activeSections.push_back( §ionTracker );
|
||||||
|
|
||||||
m_lastAssertionInfo.lineInfo = sectionInfo.lineInfo;
|
m_lastAssertionInfo.lineInfo = sectionInfo.lineInfo;
|
||||||
|
|
||||||
@@ -168,49 +178,62 @@ namespace Catch {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
bool testForMissingAssertions( Counts& assertions ) {
|
bool testForMissingAssertions( Counts& assertions ) {
|
||||||
if( assertions.total() != 0 ||
|
if( assertions.total() != 0 )
|
||||||
!m_config->warnAboutMissingAssertions() ||
|
return false;
|
||||||
m_testCaseTracker->currentSectionHasChildren() )
|
if( !m_config->warnAboutMissingAssertions() )
|
||||||
|
return false;
|
||||||
|
if( m_trackerContext.currentTracker().hasChildren() )
|
||||||
return false;
|
return false;
|
||||||
m_totals.assertions.failed++;
|
m_totals.assertions.failed++;
|
||||||
assertions.failed++;
|
assertions.failed++;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
virtual void sectionEnded( SectionInfo const& info, Counts const& prevAssertions, double _durationInSeconds ) {
|
virtual void sectionEnded( SectionEndInfo const& endInfo ) CATCH_OVERRIDE {
|
||||||
if( std::uncaught_exception() ) {
|
Counts assertions = m_totals.assertions - endInfo.prevAssertions;
|
||||||
m_unfinishedSections.push_back( UnfinishedSections( info, prevAssertions, _durationInSeconds ) );
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
Counts assertions = m_totals.assertions - prevAssertions;
|
|
||||||
bool missingAssertions = testForMissingAssertions( assertions );
|
bool missingAssertions = testForMissingAssertions( assertions );
|
||||||
|
|
||||||
m_testCaseTracker->leaveSection();
|
if( !m_activeSections.empty() ) {
|
||||||
|
m_activeSections.back()->close();
|
||||||
|
m_activeSections.pop_back();
|
||||||
|
}
|
||||||
|
|
||||||
m_reporter->sectionEnded( SectionStats( info, assertions, _durationInSeconds, missingAssertions ) );
|
m_reporter->sectionEnded( SectionStats( endInfo.sectionInfo, assertions, endInfo.durationInSeconds, missingAssertions ) );
|
||||||
m_messages.clear();
|
m_messages.clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
virtual void pushScopedMessage( MessageInfo const& message ) {
|
virtual void sectionEndedEarly( SectionEndInfo const& endInfo ) CATCH_OVERRIDE {
|
||||||
|
if( m_unfinishedSections.empty() )
|
||||||
|
m_activeSections.back()->fail();
|
||||||
|
else
|
||||||
|
m_activeSections.back()->close();
|
||||||
|
m_activeSections.pop_back();
|
||||||
|
|
||||||
|
m_unfinishedSections.push_back( endInfo );
|
||||||
|
}
|
||||||
|
|
||||||
|
virtual void pushScopedMessage( MessageInfo const& message ) CATCH_OVERRIDE {
|
||||||
m_messages.push_back( message );
|
m_messages.push_back( message );
|
||||||
}
|
}
|
||||||
|
|
||||||
virtual void popScopedMessage( MessageInfo const& message ) {
|
virtual void popScopedMessage( MessageInfo const& message ) CATCH_OVERRIDE {
|
||||||
m_messages.erase( std::remove( m_messages.begin(), m_messages.end(), message ), m_messages.end() );
|
m_messages.erase( std::remove( m_messages.begin(), m_messages.end(), message ), m_messages.end() );
|
||||||
}
|
}
|
||||||
|
|
||||||
virtual std::string getCurrentTestName() const {
|
virtual std::string getCurrentTestName() const CATCH_OVERRIDE {
|
||||||
return m_activeTestCase
|
return m_activeTestCaseInfo
|
||||||
? m_activeTestCase->getTestCaseInfo().name
|
? m_activeTestCaseInfo->name
|
||||||
: "";
|
: "";
|
||||||
}
|
}
|
||||||
|
|
||||||
virtual const AssertionResult* getLastResult() const {
|
virtual AssertionResult const* getLastResult() const CATCH_OVERRIDE {
|
||||||
return &m_lastResult;
|
return &m_lastResult;
|
||||||
}
|
}
|
||||||
|
virtual IConfig const& config() const CATCH_OVERRIDE {
|
||||||
|
return *m_config;
|
||||||
|
}
|
||||||
|
|
||||||
virtual void handleFatalErrorCondition( std::string const& message ) {
|
virtual void handleFatalErrorCondition( std::string const& message ) CATCH_OVERRIDE {
|
||||||
ResultBuilder resultBuilder = makeUnexpectedResultBuilder();
|
ResultBuilder resultBuilder = makeUnexpectedResultBuilder();
|
||||||
resultBuilder.setResultType( ResultWas::FatalErrorCondition );
|
resultBuilder.setResultType( ResultWas::FatalErrorCondition );
|
||||||
resultBuilder << message;
|
resultBuilder << message;
|
||||||
@@ -219,19 +242,19 @@ namespace Catch {
|
|||||||
handleUnfinishedSections();
|
handleUnfinishedSections();
|
||||||
|
|
||||||
// Recreate section for test case (as we will lose the one that was in scope)
|
// Recreate section for test case (as we will lose the one that was in scope)
|
||||||
TestCaseInfo const& testCaseInfo = m_activeTestCase->getTestCaseInfo();
|
SectionInfo testCaseSection
|
||||||
SectionInfo testCaseSection( testCaseInfo.lineInfo, testCaseInfo.name, testCaseInfo.description );
|
( m_activeTestCaseInfo->lineInfo,
|
||||||
|
m_activeTestCaseInfo->name,
|
||||||
|
m_activeTestCaseInfo->description );
|
||||||
|
|
||||||
Counts assertions;
|
Counts assertions;
|
||||||
assertions.failed = 1;
|
assertions.failed = 1;
|
||||||
SectionStats testCaseSectionStats( testCaseSection, assertions, 0, false );
|
SectionStats testCaseSectionStats( testCaseSection, assertions, 0, false );
|
||||||
m_reporter->sectionEnded( testCaseSectionStats );
|
m_reporter->sectionEnded( testCaseSectionStats );
|
||||||
|
|
||||||
TestCaseInfo testInfo = m_activeTestCase->getTestCaseInfo();
|
|
||||||
|
|
||||||
Totals deltaTotals;
|
Totals deltaTotals;
|
||||||
deltaTotals.testCases.failed = 1;
|
deltaTotals.testCases.failed = 1;
|
||||||
m_reporter->testCaseEnded( TestCaseStats( testInfo,
|
m_reporter->testCaseEnded( TestCaseStats( *m_activeTestCaseInfo,
|
||||||
deltaTotals,
|
deltaTotals,
|
||||||
"",
|
"",
|
||||||
"",
|
"",
|
||||||
@@ -243,21 +266,19 @@ namespace Catch {
|
|||||||
|
|
||||||
public:
|
public:
|
||||||
// !TBD We need to do this another way!
|
// !TBD We need to do this another way!
|
||||||
bool aborting() const {
|
bool isAborting() const {
|
||||||
return m_totals.assertions.failed == static_cast<std::size_t>( m_config->abortAfter() );
|
return m_totals.assertions.failed == static_cast<std::size_t>( m_config->abortAfter() );
|
||||||
}
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
||||||
void runCurrentTest( std::string& redirectedCout, std::string& redirectedCerr ) {
|
void runTest( TestCase const& testCase, std::string& redirectedCout, std::string& redirectedCerr ) {
|
||||||
TestCaseInfo const& testCaseInfo = m_activeTestCase->getTestCaseInfo();
|
SectionInfo testCaseSection( testCase.lineInfo, testCase.name, testCase.description );
|
||||||
SectionInfo testCaseSection( testCaseInfo.lineInfo, testCaseInfo.name, testCaseInfo.description );
|
|
||||||
m_reporter->sectionStarting( testCaseSection );
|
m_reporter->sectionStarting( testCaseSection );
|
||||||
Counts prevAssertions = m_totals.assertions;
|
Counts prevAssertions = m_totals.assertions;
|
||||||
double duration = 0;
|
double duration = 0;
|
||||||
try {
|
try {
|
||||||
m_lastAssertionInfo = AssertionInfo( "TEST_CASE", testCaseInfo.lineInfo, "", ResultDisposition::Normal );
|
m_lastAssertionInfo = AssertionInfo( "TEST_CASE", testCase.lineInfo, "", ResultDisposition::Normal );
|
||||||
TestCaseTracker::Guard guard( *m_testCaseTracker );
|
|
||||||
|
|
||||||
seedRng( *m_config );
|
seedRng( *m_config );
|
||||||
|
|
||||||
@@ -266,10 +287,10 @@ namespace Catch {
|
|||||||
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 );
|
StreamRedirect cerrRedir( Catch::cerr(), redirectedCerr );
|
||||||
invokeActiveTestCase();
|
invokeTestCase( testCase );
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
invokeActiveTestCase();
|
invokeTestCase( testCase );
|
||||||
}
|
}
|
||||||
duration = timer.getElapsedSeconds();
|
duration = timer.getElapsedSeconds();
|
||||||
}
|
}
|
||||||
@@ -279,13 +300,15 @@ namespace Catch {
|
|||||||
catch(...) {
|
catch(...) {
|
||||||
makeUnexpectedResultBuilder().useActiveException();
|
makeUnexpectedResultBuilder().useActiveException();
|
||||||
}
|
}
|
||||||
|
m_trackerContext.currentTracker().close();
|
||||||
|
|
||||||
handleUnfinishedSections();
|
handleUnfinishedSections();
|
||||||
m_messages.clear();
|
m_messages.clear();
|
||||||
|
|
||||||
Counts assertions = m_totals.assertions - prevAssertions;
|
Counts assertions = m_totals.assertions - prevAssertions;
|
||||||
bool missingAssertions = testForMissingAssertions( assertions );
|
bool missingAssertions = testForMissingAssertions( assertions );
|
||||||
|
|
||||||
if( testCaseInfo.okToFail() ) {
|
if( testCase.okToFail() ) {
|
||||||
std::swap( assertions.failedButOk, assertions.failed );
|
std::swap( assertions.failedButOk, assertions.failed );
|
||||||
m_totals.assertions.failed -= assertions.failedButOk;
|
m_totals.assertions.failed -= assertions.failedButOk;
|
||||||
m_totals.assertions.failedButOk += assertions.failedButOk;
|
m_totals.assertions.failedButOk += assertions.failedButOk;
|
||||||
@@ -295,10 +318,9 @@ namespace Catch {
|
|||||||
m_reporter->sectionEnded( testCaseSectionStats );
|
m_reporter->sectionEnded( testCaseSectionStats );
|
||||||
}
|
}
|
||||||
|
|
||||||
void invokeActiveTestCase() {
|
static void invokeTestCase( TestCase const& testCase ) {
|
||||||
FatalConditionHandler fatalConditionHandler; // Handle signals
|
FatalConditionHandler fatalConditionHandler; // Handle signals
|
||||||
m_activeTestCase->invoke();
|
testCase.invoke();
|
||||||
fatalConditionHandler.reset();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
@@ -313,47 +335,29 @@ namespace Catch {
|
|||||||
void handleUnfinishedSections() {
|
void handleUnfinishedSections() {
|
||||||
// If sections ended prematurely due to an exception we stored their
|
// If sections ended prematurely due to an exception we stored their
|
||||||
// infos here so we can tear them down outside the unwind process.
|
// infos here so we can tear them down outside the unwind process.
|
||||||
for( std::vector<UnfinishedSections>::const_reverse_iterator it = m_unfinishedSections.rbegin(),
|
for( std::vector<SectionEndInfo>::const_reverse_iterator it = m_unfinishedSections.rbegin(),
|
||||||
itEnd = m_unfinishedSections.rend();
|
itEnd = m_unfinishedSections.rend();
|
||||||
it != itEnd;
|
it != itEnd;
|
||||||
++it )
|
++it )
|
||||||
sectionEnded( it->info, it->prevAssertions, it->durationInSeconds );
|
sectionEnded( *it );
|
||||||
m_unfinishedSections.clear();
|
m_unfinishedSections.clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
struct UnfinishedSections {
|
|
||||||
UnfinishedSections( SectionInfo const& _info, Counts const& _prevAssertions, double _durationInSeconds )
|
|
||||||
: info( _info ), prevAssertions( _prevAssertions ), durationInSeconds( _durationInSeconds )
|
|
||||||
{}
|
|
||||||
|
|
||||||
SectionInfo info;
|
|
||||||
Counts prevAssertions;
|
|
||||||
double durationInSeconds;
|
|
||||||
};
|
|
||||||
|
|
||||||
TestRunInfo m_runInfo;
|
TestRunInfo m_runInfo;
|
||||||
IMutableContext& m_context;
|
|
||||||
TestCase const* m_activeTestCase;
|
|
||||||
Option<TestCaseTracker> m_testCaseTracker;
|
|
||||||
AssertionResult m_lastResult;
|
|
||||||
|
|
||||||
Ptr<IConfig const> m_config;
|
Ptr<IConfig const> m_config;
|
||||||
Totals m_totals;
|
|
||||||
Ptr<IStreamingReporter> m_reporter;
|
Ptr<IStreamingReporter> m_reporter;
|
||||||
std::vector<MessageInfo> m_messages;
|
TrackerContext m_trackerContext;
|
||||||
IRunner* m_prevRunner;
|
Totals m_totals;
|
||||||
IResultCapture* m_prevResultCapture;
|
|
||||||
Ptr<IConfig const> m_prevConfig;
|
|
||||||
AssertionInfo m_lastAssertionInfo;
|
|
||||||
std::vector<UnfinishedSections> m_unfinishedSections;
|
|
||||||
};
|
|
||||||
|
|
||||||
IResultCapture& getResultCapture() {
|
// Transient state
|
||||||
if( IResultCapture* capture = getCurrentContext().getResultCapture() )
|
TestCaseInfo const* m_activeTestCaseInfo;
|
||||||
return *capture;
|
AssertionResult m_lastResult;
|
||||||
else
|
AssertionInfo m_lastAssertionInfo;
|
||||||
throw std::logic_error( "No result capture instance" );
|
std::vector<SectionEndInfo> m_unfinishedSections;
|
||||||
}
|
std::vector<ITracker*> m_activeSections;
|
||||||
|
std::vector<MessageInfo> m_messages;
|
||||||
|
};
|
||||||
|
|
||||||
} // end namespace Catch
|
} // end namespace Catch
|
||||||
|
|
@@ -16,6 +16,8 @@
|
|||||||
|
|
||||||
namespace Catch {
|
namespace Catch {
|
||||||
|
|
||||||
|
struct IRunContext;
|
||||||
|
|
||||||
class Section : NonCopyable {
|
class Section : NonCopyable {
|
||||||
public:
|
public:
|
||||||
Section( SectionInfo const& info );
|
Section( SectionInfo const& info );
|
||||||
@@ -29,6 +31,7 @@ namespace Catch {
|
|||||||
|
|
||||||
std::string m_name;
|
std::string m_name;
|
||||||
Counts m_assertions;
|
Counts m_assertions;
|
||||||
|
IRunContext& m_runContext;
|
||||||
bool m_sectionIncluded;
|
bool m_sectionIncluded;
|
||||||
Timer m_timer;
|
Timer m_timer;
|
||||||
};
|
};
|
||||||
|
@@ -26,14 +26,20 @@ namespace Catch {
|
|||||||
|
|
||||||
Section::Section( SectionInfo const& info )
|
Section::Section( SectionInfo const& info )
|
||||||
: m_info( info ),
|
: m_info( info ),
|
||||||
m_sectionIncluded( getResultCapture().sectionStarted( m_info, m_assertions ) )
|
m_runContext( getCurrentRunContext() ),
|
||||||
|
m_sectionIncluded( m_runContext.sectionStarted( m_info, m_assertions ) )
|
||||||
{
|
{
|
||||||
m_timer.start();
|
m_timer.start();
|
||||||
}
|
}
|
||||||
|
|
||||||
Section::~Section() {
|
Section::~Section() {
|
||||||
if( m_sectionIncluded )
|
if( m_sectionIncluded ) {
|
||||||
getResultCapture().sectionEnded( m_info, m_assertions, m_timer.getElapsedSeconds() );
|
SectionEndInfo endInfo( m_info, m_assertions, m_timer.getElapsedSeconds() );
|
||||||
|
if( std::uncaught_exception() )
|
||||||
|
m_runContext.sectionEndedEarly( endInfo );
|
||||||
|
else
|
||||||
|
m_runContext.sectionEnded( endInfo );
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// This indicates whether the section should be executed or not
|
// This indicates whether the section should be executed or not
|
||||||
|
@@ -9,6 +9,7 @@
|
|||||||
#define TWOBLUECUBES_CATCH_SECTION_INFO_H_INCLUDED
|
#define TWOBLUECUBES_CATCH_SECTION_INFO_H_INCLUDED
|
||||||
|
|
||||||
#include "catch_common.h"
|
#include "catch_common.h"
|
||||||
|
#include "catch_totals.hpp"
|
||||||
|
|
||||||
namespace Catch {
|
namespace Catch {
|
||||||
|
|
||||||
@@ -23,6 +24,16 @@ namespace Catch {
|
|||||||
SourceLineInfo lineInfo;
|
SourceLineInfo lineInfo;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
struct SectionEndInfo {
|
||||||
|
SectionEndInfo( SectionInfo const& _sectionInfo, Counts const& _prevAssertions, double _durationInSeconds )
|
||||||
|
: sectionInfo( _sectionInfo ), prevAssertions( _prevAssertions ), durationInSeconds( _durationInSeconds )
|
||||||
|
{}
|
||||||
|
|
||||||
|
SectionInfo sectionInfo;
|
||||||
|
Counts prevAssertions;
|
||||||
|
double durationInSeconds;
|
||||||
|
};
|
||||||
|
|
||||||
} // end namespace Catch
|
} // end namespace Catch
|
||||||
|
|
||||||
#endif // TWOBLUECUBES_CATCH_SECTION_INFO_H_INCLUDED
|
#endif // TWOBLUECUBES_CATCH_SECTION_INFO_H_INCLUDED
|
||||||
|
@@ -9,28 +9,56 @@
|
|||||||
#ifndef TWOBLUECUBES_CATCH_STREAM_H_INCLUDED
|
#ifndef TWOBLUECUBES_CATCH_STREAM_H_INCLUDED
|
||||||
#define TWOBLUECUBES_CATCH_STREAM_H_INCLUDED
|
#define TWOBLUECUBES_CATCH_STREAM_H_INCLUDED
|
||||||
|
|
||||||
#include <streambuf>
|
#include "catch_compiler_capabilities.h"
|
||||||
|
#include "catch_streambuf.h"
|
||||||
|
|
||||||
#ifdef __clang__
|
#include <streambuf>
|
||||||
#pragma clang diagnostic ignored "-Wpadded"
|
#include <ostream>
|
||||||
#endif
|
#include <fstream>
|
||||||
|
#include <memory>
|
||||||
|
|
||||||
namespace Catch {
|
namespace Catch {
|
||||||
|
|
||||||
class Stream {
|
|
||||||
public:
|
|
||||||
Stream();
|
|
||||||
Stream( std::streambuf* _streamBuf, bool _isOwned );
|
|
||||||
void release();
|
|
||||||
|
|
||||||
std::streambuf* streamBuf;
|
|
||||||
|
|
||||||
private:
|
|
||||||
bool isOwned;
|
|
||||||
};
|
|
||||||
|
|
||||||
std::ostream& cout();
|
std::ostream& cout();
|
||||||
std::ostream& cerr();
|
std::ostream& cerr();
|
||||||
|
|
||||||
|
|
||||||
|
struct IStream {
|
||||||
|
virtual ~IStream() CATCH_NOEXCEPT;
|
||||||
|
virtual std::ostream& stream() const = 0;
|
||||||
|
};
|
||||||
|
|
||||||
|
class FileStream : public IStream {
|
||||||
|
mutable std::ofstream m_ofs;
|
||||||
|
public:
|
||||||
|
FileStream( std::string const& filename );
|
||||||
|
virtual ~FileStream() CATCH_NOEXCEPT;
|
||||||
|
public: // IStream
|
||||||
|
virtual std::ostream& stream() const CATCH_OVERRIDE;
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
class CoutStream : public IStream {
|
||||||
|
mutable std::ostream m_os;
|
||||||
|
public:
|
||||||
|
CoutStream();
|
||||||
|
virtual ~CoutStream() CATCH_NOEXCEPT;
|
||||||
|
|
||||||
|
public: // IStream
|
||||||
|
virtual std::ostream& stream() const CATCH_OVERRIDE;
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
class DebugOutStream : public IStream {
|
||||||
|
CATCH_AUTO_PTR( StreamBufBase ) m_streamBuf;
|
||||||
|
mutable std::ostream m_os;
|
||||||
|
public:
|
||||||
|
DebugOutStream();
|
||||||
|
virtual ~DebugOutStream() CATCH_NOEXCEPT;
|
||||||
|
|
||||||
|
public: // IStream
|
||||||
|
virtual std::ostream& stream() const CATCH_OVERRIDE;
|
||||||
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif // TWOBLUECUBES_CATCH_STREAM_H_INCLUDED
|
#endif // TWOBLUECUBES_CATCH_STREAM_H_INCLUDED
|
||||||
|
@@ -10,7 +10,6 @@
|
|||||||
#define TWOBLUECUBES_CATCH_STREAM_HPP_INCLUDED
|
#define TWOBLUECUBES_CATCH_STREAM_HPP_INCLUDED
|
||||||
|
|
||||||
#include "catch_stream.h"
|
#include "catch_stream.h"
|
||||||
#include "catch_streambuf.h"
|
|
||||||
#include "catch_debugger.h"
|
#include "catch_debugger.h"
|
||||||
|
|
||||||
#include <stdexcept>
|
#include <stdexcept>
|
||||||
@@ -57,6 +56,20 @@ namespace Catch {
|
|||||||
|
|
||||||
///////////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
|
||||||
|
FileStream::FileStream( std::string const& filename ) {
|
||||||
|
m_ofs.open( filename.c_str() );
|
||||||
|
if( m_ofs.fail() ) {
|
||||||
|
std::ostringstream oss;
|
||||||
|
oss << "Unable to open file: '" << filename << "'";
|
||||||
|
throw std::domain_error( oss.str() );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
std::ostream& FileStream::stream() const {
|
||||||
|
return m_ofs;
|
||||||
|
}
|
||||||
|
|
||||||
struct OutputDebugWriter {
|
struct OutputDebugWriter {
|
||||||
|
|
||||||
void operator()( std::string const&str ) {
|
void operator()( std::string const&str ) {
|
||||||
@@ -64,22 +77,26 @@ namespace Catch {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
Stream::Stream()
|
DebugOutStream::DebugOutStream()
|
||||||
: streamBuf( CATCH_NULL ), isOwned( false )
|
: m_streamBuf( new StreamBufImpl<OutputDebugWriter>() ),
|
||||||
|
m_os( m_streamBuf.get() )
|
||||||
{}
|
{}
|
||||||
|
|
||||||
Stream::Stream( std::streambuf* _streamBuf, bool _isOwned )
|
std::ostream& DebugOutStream::stream() const {
|
||||||
: streamBuf( _streamBuf ), isOwned( _isOwned )
|
return m_os;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Store the streambuf from cout up-front because
|
||||||
|
// cout may get redirected when running tests
|
||||||
|
CoutStream::CoutStream()
|
||||||
|
: m_os( Catch::cout().rdbuf() )
|
||||||
{}
|
{}
|
||||||
|
|
||||||
void Stream::release() {
|
std::ostream& CoutStream::stream() const {
|
||||||
if( isOwned ) {
|
return m_os;
|
||||||
delete streamBuf;
|
|
||||||
streamBuf = CATCH_NULL;
|
|
||||||
isOwned = false;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
#ifndef CATCH_CONFIG_NOSTDOUT // If you #define this you must implement this functions
|
#ifndef CATCH_CONFIG_NOSTDOUT // If you #define this you must implement this functions
|
||||||
std::ostream& cout() {
|
std::ostream& cout() {
|
||||||
return std::cout;
|
return std::cout;
|
||||||
|
@@ -5,9 +5,6 @@
|
|||||||
* file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
|
* file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#ifndef TWOBLUECUBES_CATCH_SUPPRESS_WARNINGS_H_INCLUDED
|
|
||||||
#define TWOBLUECUBES_CATCH_SUPPRESS_WARNINGS_H_INCLUDED
|
|
||||||
|
|
||||||
#ifdef __clang__
|
#ifdef __clang__
|
||||||
# ifdef __ICC // icpc defines the __clang__ macro
|
# ifdef __ICC // icpc defines the __clang__ macro
|
||||||
# pragma warning(push)
|
# pragma warning(push)
|
||||||
@@ -22,6 +19,7 @@
|
|||||||
# pragma clang diagnostic ignored "-Wc++98-compat"
|
# pragma clang diagnostic ignored "-Wc++98-compat"
|
||||||
# pragma clang diagnostic ignored "-Wc++98-compat-pedantic"
|
# pragma clang diagnostic ignored "-Wc++98-compat-pedantic"
|
||||||
# pragma clang diagnostic ignored "-Wswitch-enum"
|
# pragma clang diagnostic ignored "-Wswitch-enum"
|
||||||
|
# pragma clang diagnostic ignored "-Wcovered-switch-default"
|
||||||
# endif
|
# endif
|
||||||
#elif defined __GNUC__
|
#elif defined __GNUC__
|
||||||
# pragma GCC diagnostic ignored "-Wvariadic-macros"
|
# pragma GCC diagnostic ignored "-Wvariadic-macros"
|
||||||
@@ -29,5 +27,3 @@
|
|||||||
# pragma GCC diagnostic push
|
# pragma GCC diagnostic push
|
||||||
# pragma GCC diagnostic ignored "-Wpadded"
|
# pragma GCC diagnostic ignored "-Wpadded"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#endif // TWOBLUECUBES_CATCH_SUPPRESS_WARNINGS_H_INCLUDED
|
|
||||||
|
@@ -11,7 +11,6 @@
|
|||||||
#include "catch_test_registry.hpp"
|
#include "catch_test_registry.hpp"
|
||||||
#include "catch_test_case_info.h"
|
#include "catch_test_case_info.h"
|
||||||
#include "catch_test_spec.hpp"
|
#include "catch_test_spec.hpp"
|
||||||
#include "catch_context.h"
|
|
||||||
|
|
||||||
#include <vector>
|
#include <vector>
|
||||||
#include <set>
|
#include <set>
|
||||||
@@ -21,7 +20,6 @@
|
|||||||
|
|
||||||
namespace Catch {
|
namespace Catch {
|
||||||
|
|
||||||
class TestRegistry : public ITestCaseRegistry {
|
|
||||||
struct LexSort {
|
struct LexSort {
|
||||||
bool operator() (TestCase i,TestCase j) const { return (i<j);}
|
bool operator() (TestCase i,TestCase j) const { return (i<j);}
|
||||||
};
|
};
|
||||||
@@ -29,8 +27,69 @@ namespace Catch {
|
|||||||
int operator()( int n ) const { return std::rand() % n; }
|
int operator()( int n ) const { return std::rand() % n; }
|
||||||
};
|
};
|
||||||
|
|
||||||
|
inline std::vector<TestCase> sortTests( IConfig const& config, std::vector<TestCase> const& unsortedTestCases ) {
|
||||||
|
|
||||||
|
std::vector<TestCase> sorted = unsortedTestCases;
|
||||||
|
|
||||||
|
switch( config.runOrder() ) {
|
||||||
|
case RunTests::InLexicographicalOrder:
|
||||||
|
std::sort( sorted.begin(), sorted.end(), LexSort() );
|
||||||
|
break;
|
||||||
|
case RunTests::InRandomOrder:
|
||||||
|
{
|
||||||
|
seedRng( config );
|
||||||
|
|
||||||
|
RandomNumberGenerator rng;
|
||||||
|
std::random_shuffle( sorted.begin(), sorted.end(), rng );
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case RunTests::InDeclarationOrder:
|
||||||
|
// already in declaration order
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
return sorted;
|
||||||
|
}
|
||||||
|
bool matchTest( TestCase const& testCase, TestSpec const& testSpec, IConfig const& config ) {
|
||||||
|
return testSpec.matches( testCase ) && ( config.allowThrows() || !testCase.throws() );
|
||||||
|
}
|
||||||
|
|
||||||
|
void enforceNoDuplicateTestCases( std::vector<TestCase> const& functions ) {
|
||||||
|
std::set<TestCase> seenFunctions;
|
||||||
|
for( std::vector<TestCase>::const_iterator it = functions.begin(), itEnd = functions.end();
|
||||||
|
it != itEnd;
|
||||||
|
++it ) {
|
||||||
|
std::pair<std::set<TestCase>::const_iterator, bool> prev = seenFunctions.insert( *it );
|
||||||
|
if( !prev.second ){
|
||||||
|
Catch::cerr()
|
||||||
|
<< Colour( Colour::Red )
|
||||||
|
<< "error: TEST_CASE( \"" << it->name << "\" ) already defined.\n"
|
||||||
|
<< "\tFirst seen at " << prev.first->getTestCaseInfo().lineInfo << "\n"
|
||||||
|
<< "\tRedefined at " << it->getTestCaseInfo().lineInfo << std::endl;
|
||||||
|
exit(1);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
std::vector<TestCase> filterTests( std::vector<TestCase> const& testCases, TestSpec const& testSpec, IConfig const& config ) {
|
||||||
|
std::vector<TestCase> filtered;
|
||||||
|
filtered.reserve( testCases.size() );
|
||||||
|
for( std::vector<TestCase>::const_iterator it = testCases.begin(), itEnd = testCases.end();
|
||||||
|
it != itEnd;
|
||||||
|
++it )
|
||||||
|
if( matchTest( *it, testSpec, config ) )
|
||||||
|
filtered.push_back( *it );
|
||||||
|
return filtered;
|
||||||
|
}
|
||||||
|
std::vector<TestCase> const& getAllTestCasesSorted( IConfig const& config ) {
|
||||||
|
return getRegistryHub().getTestCaseRegistry().getAllTestsSorted( config );
|
||||||
|
}
|
||||||
|
|
||||||
|
class TestRegistry : public ITestCaseRegistry {
|
||||||
public:
|
public:
|
||||||
TestRegistry() : m_unnamedCount( 0 ) {}
|
TestRegistry()
|
||||||
|
: m_currentSortOrder( RunTests::InDeclarationOrder ),
|
||||||
|
m_unnamedCount( 0 )
|
||||||
|
{}
|
||||||
virtual ~TestRegistry();
|
virtual ~TestRegistry();
|
||||||
|
|
||||||
virtual void registerTest( TestCase const& testCase ) {
|
virtual void registerTest( TestCase const& testCase ) {
|
||||||
@@ -40,70 +99,27 @@ namespace Catch {
|
|||||||
oss << "Anonymous test case " << ++m_unnamedCount;
|
oss << "Anonymous test case " << ++m_unnamedCount;
|
||||||
return registerTest( testCase.withName( oss.str() ) );
|
return registerTest( testCase.withName( oss.str() ) );
|
||||||
}
|
}
|
||||||
|
m_functions.push_back( testCase );
|
||||||
if( m_functions.find( testCase ) == m_functions.end() ) {
|
|
||||||
m_functions.insert( testCase );
|
|
||||||
m_functionsInOrder.push_back( testCase );
|
|
||||||
if( !testCase.isHidden() )
|
|
||||||
m_nonHiddenFunctions.push_back( testCase );
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
TestCase const& prev = *m_functions.find( testCase );
|
|
||||||
{
|
|
||||||
Colour colourGuard( Colour::Red );
|
|
||||||
Catch::cerr() << "error: TEST_CASE( \"" << name << "\" ) already defined.\n"
|
|
||||||
<< "\tFirst seen at " << prev.getTestCaseInfo().lineInfo << "\n"
|
|
||||||
<< "\tRedefined at " << testCase.getTestCaseInfo().lineInfo << std::endl;
|
|
||||||
}
|
|
||||||
exit(1);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
virtual std::vector<TestCase> const& getAllTests() const {
|
virtual std::vector<TestCase> const& getAllTests() const {
|
||||||
return m_functionsInOrder;
|
return m_functions;
|
||||||
}
|
}
|
||||||
|
virtual std::vector<TestCase> const& getAllTestsSorted( IConfig const& config ) const {
|
||||||
|
if( m_sortedFunctions.empty() )
|
||||||
|
enforceNoDuplicateTestCases( m_functions );
|
||||||
|
|
||||||
virtual std::vector<TestCase> const& getAllNonHiddenTests() const {
|
if( m_currentSortOrder != config.runOrder() || m_sortedFunctions.empty() ) {
|
||||||
return m_nonHiddenFunctions;
|
m_sortedFunctions = sortTests( config, m_functions );
|
||||||
|
m_currentSortOrder = config.runOrder();
|
||||||
}
|
}
|
||||||
|
return m_sortedFunctions;
|
||||||
virtual void getFilteredTests( TestSpec const& testSpec, IConfig const& config, std::vector<TestCase>& matchingTestCases, bool negated = false ) const {
|
|
||||||
|
|
||||||
for( std::vector<TestCase>::const_iterator it = m_functionsInOrder.begin(),
|
|
||||||
itEnd = m_functionsInOrder.end();
|
|
||||||
it != itEnd;
|
|
||||||
++it ) {
|
|
||||||
bool includeTest = testSpec.matches( *it ) && ( config.allowThrows() || !it->throws() );
|
|
||||||
if( includeTest != negated )
|
|
||||||
matchingTestCases.push_back( *it );
|
|
||||||
}
|
|
||||||
sortTests( config, matchingTestCases );
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
std::vector<TestCase> m_functions;
|
||||||
static void sortTests( IConfig const& config, std::vector<TestCase>& matchingTestCases ) {
|
mutable RunTests::InWhatOrder m_currentSortOrder;
|
||||||
|
mutable std::vector<TestCase> m_sortedFunctions;
|
||||||
switch( config.runOrder() ) {
|
|
||||||
case RunTests::InLexicographicalOrder:
|
|
||||||
std::sort( matchingTestCases.begin(), matchingTestCases.end(), LexSort() );
|
|
||||||
break;
|
|
||||||
case RunTests::InRandomOrder:
|
|
||||||
{
|
|
||||||
seedRng( config );
|
|
||||||
|
|
||||||
RandomNumberGenerator rng;
|
|
||||||
std::random_shuffle( matchingTestCases.begin(), matchingTestCases.end(), rng );
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
case RunTests::InDeclarationOrder:
|
|
||||||
// already in declaration order
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
std::set<TestCase> m_functions;
|
|
||||||
std::vector<TestCase> m_functionsInOrder;
|
|
||||||
std::vector<TestCase> m_nonHiddenFunctions;
|
|
||||||
size_t m_unnamedCount;
|
size_t m_unnamedCount;
|
||||||
std::ios_base::Init m_ostreamInit; // Forces cout/ cerr to be initialised
|
std::ios_base::Init m_ostreamInit; // Forces cout/ cerr to be initialised
|
||||||
};
|
};
|
||||||
@@ -138,28 +154,37 @@ namespace Catch {
|
|||||||
return className;
|
return className;
|
||||||
}
|
}
|
||||||
|
|
||||||
///////////////////////////////////////////////////////////////////////////
|
void registerTestCase
|
||||||
|
( ITestCase* testCase,
|
||||||
AutoReg::AutoReg( TestFunction function,
|
|
||||||
SourceLineInfo const& lineInfo,
|
|
||||||
NameAndDesc const& nameAndDesc ) {
|
|
||||||
registerTestCase( new FreeFunctionTestCase( function ), "", nameAndDesc, lineInfo );
|
|
||||||
}
|
|
||||||
|
|
||||||
AutoReg::~AutoReg() {}
|
|
||||||
|
|
||||||
void AutoReg::registerTestCase( ITestCase* testCase,
|
|
||||||
char const* classOrQualifiedMethodName,
|
char const* classOrQualifiedMethodName,
|
||||||
NameAndDesc const& nameAndDesc,
|
NameAndDesc const& nameAndDesc,
|
||||||
SourceLineInfo const& lineInfo ) {
|
SourceLineInfo const& lineInfo ) {
|
||||||
|
|
||||||
getMutableRegistryHub().registerTest
|
getMutableRegistryHub().registerTest
|
||||||
( makeTestCase( testCase,
|
( makeTestCase
|
||||||
|
( testCase,
|
||||||
extractClassName( classOrQualifiedMethodName ),
|
extractClassName( classOrQualifiedMethodName ),
|
||||||
nameAndDesc.name,
|
nameAndDesc.name,
|
||||||
nameAndDesc.description,
|
nameAndDesc.description,
|
||||||
lineInfo ) );
|
lineInfo ) );
|
||||||
}
|
}
|
||||||
|
void registerTestCaseFunction
|
||||||
|
( TestFunction function,
|
||||||
|
SourceLineInfo const& lineInfo,
|
||||||
|
NameAndDesc const& nameAndDesc ) {
|
||||||
|
registerTestCase( new FreeFunctionTestCase( function ), "", nameAndDesc, lineInfo );
|
||||||
|
}
|
||||||
|
|
||||||
|
///////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
AutoReg::AutoReg
|
||||||
|
( TestFunction function,
|
||||||
|
SourceLineInfo const& lineInfo,
|
||||||
|
NameAndDesc const& nameAndDesc ) {
|
||||||
|
registerTestCaseFunction( function, lineInfo, nameAndDesc );
|
||||||
|
}
|
||||||
|
|
||||||
|
AutoReg::~AutoReg() {}
|
||||||
|
|
||||||
} // end namespace Catch
|
} // end namespace Catch
|
||||||
|
|
||||||
|
@@ -9,141 +9,307 @@
|
|||||||
#define TWOBLUECUBES_CATCH_TEST_CASE_TRACKER_HPP_INCLUDED
|
#define TWOBLUECUBES_CATCH_TEST_CASE_TRACKER_HPP_INCLUDED
|
||||||
|
|
||||||
#include "catch_compiler_capabilities.h"
|
#include "catch_compiler_capabilities.h"
|
||||||
|
#include "catch_ptr.hpp"
|
||||||
|
|
||||||
#include <map>
|
#include <map>
|
||||||
#include <string>
|
#include <string>
|
||||||
#include <assert.h>
|
#include <assert.h>
|
||||||
|
#include <vector>
|
||||||
|
|
||||||
namespace Catch {
|
namespace Catch {
|
||||||
namespace SectionTracking {
|
namespace TestCaseTracking {
|
||||||
|
|
||||||
class TrackedSection {
|
struct ITracker : SharedImpl<> {
|
||||||
|
virtual ~ITracker();
|
||||||
|
|
||||||
typedef std::map<std::string, TrackedSection> TrackedSections;
|
// static queries
|
||||||
|
virtual std::string name() const = 0;
|
||||||
|
|
||||||
|
// dynamic queries
|
||||||
|
virtual bool isComplete() const = 0; // Successfully completed or failed
|
||||||
|
virtual bool isSuccessfullyCompleted() const = 0;
|
||||||
|
virtual bool isOpen() const = 0; // Started but not complete
|
||||||
|
virtual bool hasChildren() const = 0;
|
||||||
|
|
||||||
|
virtual ITracker& parent() = 0;
|
||||||
|
|
||||||
|
// actions
|
||||||
|
virtual void close() = 0; // Successfully complete
|
||||||
|
virtual void fail() = 0;
|
||||||
|
virtual void markAsNeedingAnotherRun() = 0;
|
||||||
|
|
||||||
|
virtual void addChild( Ptr<ITracker> const& child ) = 0;
|
||||||
|
virtual ITracker* findChild( std::string const& name ) = 0;
|
||||||
|
virtual void openChild() = 0;
|
||||||
|
};
|
||||||
|
|
||||||
|
class TrackerContext {
|
||||||
|
|
||||||
public:
|
|
||||||
enum RunState {
|
enum RunState {
|
||||||
NotStarted,
|
NotStarted,
|
||||||
Executing,
|
Executing,
|
||||||
ExecutingChildren,
|
CompletedCycle
|
||||||
Completed
|
|
||||||
};
|
};
|
||||||
|
|
||||||
TrackedSection( std::string const& name, TrackedSection* parent )
|
Ptr<ITracker> m_rootTracker;
|
||||||
: m_name( name ), m_runState( NotStarted ), m_parent( parent )
|
ITracker* m_currentTracker;
|
||||||
|
RunState m_runState;
|
||||||
|
|
||||||
|
public:
|
||||||
|
|
||||||
|
static TrackerContext& instance() {
|
||||||
|
static TrackerContext s_instance;
|
||||||
|
return s_instance;
|
||||||
|
}
|
||||||
|
|
||||||
|
TrackerContext()
|
||||||
|
: m_currentTracker( CATCH_NULL ),
|
||||||
|
m_runState( NotStarted )
|
||||||
{}
|
{}
|
||||||
|
|
||||||
RunState runState() const { return m_runState; }
|
|
||||||
|
|
||||||
TrackedSection* findChild( std::string const& childName );
|
ITracker& startRun();
|
||||||
TrackedSection* acquireChild( std::string const& childName );
|
|
||||||
|
|
||||||
void enter() {
|
void endRun() {
|
||||||
if( m_runState == NotStarted )
|
m_rootTracker.reset();
|
||||||
|
m_currentTracker = CATCH_NULL;
|
||||||
|
m_runState = NotStarted;
|
||||||
|
}
|
||||||
|
|
||||||
|
void startCycle() {
|
||||||
|
m_currentTracker = m_rootTracker.get();
|
||||||
m_runState = Executing;
|
m_runState = Executing;
|
||||||
}
|
}
|
||||||
void leave();
|
void completeCycle() {
|
||||||
|
m_runState = CompletedCycle;
|
||||||
TrackedSection* getParent() {
|
|
||||||
return m_parent;
|
|
||||||
}
|
}
|
||||||
bool hasChildren() const {
|
|
||||||
|
bool completedCycle() const {
|
||||||
|
return m_runState == CompletedCycle;
|
||||||
|
}
|
||||||
|
ITracker& currentTracker() {
|
||||||
|
return *m_currentTracker;
|
||||||
|
}
|
||||||
|
void setCurrentTracker( ITracker* tracker ) {
|
||||||
|
m_currentTracker = tracker;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
class TrackerBase : public ITracker {
|
||||||
|
protected:
|
||||||
|
enum CycleState {
|
||||||
|
NotStarted,
|
||||||
|
Executing,
|
||||||
|
ExecutingChildren,
|
||||||
|
NeedsAnotherRun,
|
||||||
|
CompletedSuccessfully,
|
||||||
|
Failed
|
||||||
|
};
|
||||||
|
class TrackerHasName {
|
||||||
|
std::string m_name;
|
||||||
|
public:
|
||||||
|
TrackerHasName( std::string const& name ) : m_name( name ) {}
|
||||||
|
bool operator ()( Ptr<ITracker> const& tracker ) {
|
||||||
|
return tracker->name() == m_name;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
typedef std::vector<Ptr<ITracker> > Children;
|
||||||
|
std::string m_name;
|
||||||
|
TrackerContext& m_ctx;
|
||||||
|
ITracker* m_parent;
|
||||||
|
Children m_children;
|
||||||
|
CycleState m_runState;
|
||||||
|
public:
|
||||||
|
TrackerBase( std::string const& name, TrackerContext& ctx, ITracker* parent )
|
||||||
|
: m_name( name ),
|
||||||
|
m_ctx( ctx ),
|
||||||
|
m_parent( parent ),
|
||||||
|
m_runState( NotStarted )
|
||||||
|
{}
|
||||||
|
virtual ~TrackerBase();
|
||||||
|
|
||||||
|
virtual std::string name() const CATCH_OVERRIDE {
|
||||||
|
return m_name;
|
||||||
|
}
|
||||||
|
virtual bool isComplete() const CATCH_OVERRIDE {
|
||||||
|
return m_runState == CompletedSuccessfully || m_runState == Failed;
|
||||||
|
}
|
||||||
|
virtual bool isSuccessfullyCompleted() const CATCH_OVERRIDE {
|
||||||
|
return m_runState == CompletedSuccessfully;
|
||||||
|
}
|
||||||
|
virtual bool isOpen() const CATCH_OVERRIDE {
|
||||||
|
return m_runState != NotStarted && !isComplete();
|
||||||
|
}
|
||||||
|
virtual bool hasChildren() const CATCH_OVERRIDE {
|
||||||
return !m_children.empty();
|
return !m_children.empty();
|
||||||
}
|
}
|
||||||
|
|
||||||
private:
|
|
||||||
std::string m_name;
|
|
||||||
RunState m_runState;
|
|
||||||
TrackedSections m_children;
|
|
||||||
TrackedSection* m_parent;
|
|
||||||
};
|
|
||||||
|
|
||||||
inline TrackedSection* TrackedSection::findChild( std::string const& childName ) {
|
virtual void addChild( Ptr<ITracker> const& child ) CATCH_OVERRIDE {
|
||||||
TrackedSections::iterator it = m_children.find( childName );
|
m_children.push_back( child );
|
||||||
return it != m_children.end()
|
}
|
||||||
? &it->second
|
|
||||||
|
virtual ITracker* findChild( std::string const& name ) CATCH_OVERRIDE {
|
||||||
|
Children::const_iterator it = std::find_if( m_children.begin(), m_children.end(), TrackerHasName( name ) );
|
||||||
|
return( it != m_children.end() )
|
||||||
|
? it->get()
|
||||||
: CATCH_NULL;
|
: CATCH_NULL;
|
||||||
}
|
}
|
||||||
inline TrackedSection* TrackedSection::acquireChild( std::string const& childName ) {
|
virtual ITracker& parent() CATCH_OVERRIDE {
|
||||||
if( TrackedSection* child = findChild( childName ) )
|
assert( m_parent ); // Should always be non-null except for root
|
||||||
return child;
|
return *m_parent;
|
||||||
m_children.insert( std::make_pair( childName, TrackedSection( childName, this ) ) );
|
|
||||||
return findChild( childName );
|
|
||||||
}
|
}
|
||||||
inline void TrackedSection::leave() {
|
|
||||||
for( TrackedSections::const_iterator it = m_children.begin(), itEnd = m_children.end();
|
virtual void openChild() CATCH_OVERRIDE {
|
||||||
it != itEnd;
|
if( m_runState != ExecutingChildren ) {
|
||||||
++it )
|
|
||||||
if( it->second.runState() != Completed ) {
|
|
||||||
m_runState = ExecutingChildren;
|
m_runState = ExecutingChildren;
|
||||||
return;
|
if( m_parent )
|
||||||
|
m_parent->openChild();
|
||||||
}
|
}
|
||||||
m_runState = Completed;
|
}
|
||||||
|
void open() {
|
||||||
|
m_runState = Executing;
|
||||||
|
moveToThis();
|
||||||
|
if( m_parent )
|
||||||
|
m_parent->openChild();
|
||||||
}
|
}
|
||||||
|
|
||||||
class TestCaseTracker {
|
virtual void close() CATCH_OVERRIDE {
|
||||||
|
|
||||||
|
// Close any still open children (e.g. generators)
|
||||||
|
while( &m_ctx.currentTracker() != this )
|
||||||
|
m_ctx.currentTracker().close();
|
||||||
|
|
||||||
|
switch( m_runState ) {
|
||||||
|
case NotStarted:
|
||||||
|
case CompletedSuccessfully:
|
||||||
|
case Failed:
|
||||||
|
throw std::logic_error( "Illogical state" );
|
||||||
|
|
||||||
|
case NeedsAnotherRun:
|
||||||
|
break;;
|
||||||
|
|
||||||
|
case Executing:
|
||||||
|
m_runState = CompletedSuccessfully;
|
||||||
|
break;
|
||||||
|
case ExecutingChildren:
|
||||||
|
if( m_children.empty() || m_children.back()->isComplete() )
|
||||||
|
m_runState = CompletedSuccessfully;
|
||||||
|
break;
|
||||||
|
|
||||||
|
default:
|
||||||
|
throw std::logic_error( "Unexpected state" );
|
||||||
|
}
|
||||||
|
moveToParent();
|
||||||
|
m_ctx.completeCycle();
|
||||||
|
}
|
||||||
|
virtual void fail() CATCH_OVERRIDE {
|
||||||
|
m_runState = Failed;
|
||||||
|
if( m_parent )
|
||||||
|
m_parent->markAsNeedingAnotherRun();
|
||||||
|
moveToParent();
|
||||||
|
m_ctx.completeCycle();
|
||||||
|
}
|
||||||
|
virtual void markAsNeedingAnotherRun() CATCH_OVERRIDE {
|
||||||
|
m_runState = NeedsAnotherRun;
|
||||||
|
}
|
||||||
|
private:
|
||||||
|
void moveToParent() {
|
||||||
|
assert( m_parent );
|
||||||
|
m_ctx.setCurrentTracker( m_parent );
|
||||||
|
}
|
||||||
|
void moveToThis() {
|
||||||
|
m_ctx.setCurrentTracker( this );
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
class SectionTracker : public TrackerBase {
|
||||||
public:
|
public:
|
||||||
TestCaseTracker( std::string const& testCaseName )
|
SectionTracker( std::string const& name, TrackerContext& ctx, ITracker* parent )
|
||||||
: m_testCase( testCaseName, CATCH_NULL ),
|
: TrackerBase( name, ctx, parent )
|
||||||
m_currentSection( &m_testCase ),
|
|
||||||
m_completedASectionThisRun( false )
|
|
||||||
{}
|
{}
|
||||||
|
virtual ~SectionTracker();
|
||||||
|
|
||||||
bool enterSection( std::string const& name ) {
|
static SectionTracker& acquire( TrackerContext& ctx, std::string const& name ) {
|
||||||
TrackedSection* child = m_currentSection->acquireChild( name );
|
SectionTracker* section = CATCH_NULL;
|
||||||
if( m_completedASectionThisRun || child->runState() == TrackedSection::Completed )
|
|
||||||
return false;
|
|
||||||
|
|
||||||
m_currentSection = child;
|
ITracker& currentTracker = ctx.currentTracker();
|
||||||
m_currentSection->enter();
|
if( ITracker* childTracker = currentTracker.findChild( name ) ) {
|
||||||
return true;
|
section = dynamic_cast<SectionTracker*>( childTracker );
|
||||||
|
assert( section );
|
||||||
}
|
}
|
||||||
void leaveSection() {
|
else {
|
||||||
m_currentSection->leave();
|
section = new SectionTracker( name, ctx, ¤tTracker );
|
||||||
m_currentSection = m_currentSection->getParent();
|
currentTracker.addChild( section );
|
||||||
assert( m_currentSection != CATCH_NULL );
|
|
||||||
m_completedASectionThisRun = true;
|
|
||||||
}
|
}
|
||||||
|
if( !ctx.completedCycle() && !section->isComplete() ) {
|
||||||
|
|
||||||
bool currentSectionHasChildren() const {
|
section->open();
|
||||||
return m_currentSection->hasChildren();
|
|
||||||
}
|
}
|
||||||
bool isCompleted() const {
|
return *section;
|
||||||
return m_testCase.runState() == TrackedSection::Completed;
|
|
||||||
}
|
}
|
||||||
|
};
|
||||||
|
|
||||||
class Guard {
|
class IndexTracker : public TrackerBase {
|
||||||
|
int m_size;
|
||||||
|
int m_index;
|
||||||
public:
|
public:
|
||||||
Guard( TestCaseTracker& tracker ) : m_tracker( tracker ) {
|
IndexTracker( std::string const& name, TrackerContext& ctx, ITracker* parent, int size )
|
||||||
m_tracker.enterTestCase();
|
: TrackerBase( name, ctx, parent ),
|
||||||
|
m_size( size ),
|
||||||
|
m_index( -1 )
|
||||||
|
{}
|
||||||
|
virtual ~IndexTracker();
|
||||||
|
|
||||||
|
static IndexTracker& acquire( TrackerContext& ctx, std::string const& name, int size ) {
|
||||||
|
IndexTracker* tracker = CATCH_NULL;
|
||||||
|
|
||||||
|
ITracker& currentTracker = ctx.currentTracker();
|
||||||
|
if( ITracker* childTracker = currentTracker.findChild( name ) ) {
|
||||||
|
tracker = dynamic_cast<IndexTracker*>( childTracker );
|
||||||
|
assert( tracker );
|
||||||
}
|
}
|
||||||
~Guard() {
|
else {
|
||||||
m_tracker.leaveTestCase();
|
tracker = new IndexTracker( name, ctx, ¤tTracker, size );
|
||||||
|
currentTracker.addChild( tracker );
|
||||||
|
}
|
||||||
|
|
||||||
|
if( !ctx.completedCycle() && !tracker->isComplete() ) {
|
||||||
|
if( tracker->m_runState != ExecutingChildren && tracker->m_runState != NeedsAnotherRun )
|
||||||
|
tracker->moveNext();
|
||||||
|
tracker->open();
|
||||||
|
}
|
||||||
|
|
||||||
|
return *tracker;
|
||||||
|
}
|
||||||
|
|
||||||
|
int index() const { return m_index; }
|
||||||
|
|
||||||
|
void moveNext() {
|
||||||
|
m_index++;
|
||||||
|
m_children.clear();
|
||||||
|
}
|
||||||
|
|
||||||
|
virtual void close() CATCH_OVERRIDE {
|
||||||
|
TrackerBase::close();
|
||||||
|
if( m_runState == CompletedSuccessfully && m_index < m_size-1 )
|
||||||
|
m_runState = Executing;
|
||||||
}
|
}
|
||||||
private:
|
|
||||||
Guard( Guard const& );
|
|
||||||
void operator = ( Guard const& );
|
|
||||||
TestCaseTracker& m_tracker;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
private:
|
inline ITracker& TrackerContext::startRun() {
|
||||||
void enterTestCase() {
|
m_rootTracker = new SectionTracker( "{root}", *this, CATCH_NULL );
|
||||||
m_currentSection = &m_testCase;
|
m_currentTracker = CATCH_NULL;
|
||||||
m_completedASectionThisRun = false;
|
m_runState = Executing;
|
||||||
m_testCase.enter();
|
return *m_rootTracker;
|
||||||
}
|
|
||||||
void leaveTestCase() {
|
|
||||||
m_testCase.leave();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
TrackedSection m_testCase;
|
} // namespace TestCaseTracking
|
||||||
TrackedSection* m_currentSection;
|
|
||||||
bool m_completedASectionThisRun;
|
|
||||||
};
|
|
||||||
|
|
||||||
} // namespace SectionTracking
|
using TestCaseTracking::ITracker;
|
||||||
|
using TestCaseTracking::TrackerContext;
|
||||||
using SectionTracking::TestCaseTracker;
|
using TestCaseTracking::SectionTracker;
|
||||||
|
using TestCaseTracking::IndexTracker;
|
||||||
|
|
||||||
} // namespace Catch
|
} // namespace Catch
|
||||||
|
|
||||||
|
@@ -42,28 +42,33 @@ struct NameAndDesc {
|
|||||||
const char* description;
|
const char* description;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
void registerTestCase
|
||||||
|
( ITestCase* testCase,
|
||||||
|
char const* className,
|
||||||
|
NameAndDesc const& nameAndDesc,
|
||||||
|
SourceLineInfo const& lineInfo );
|
||||||
|
|
||||||
struct AutoReg {
|
struct AutoReg {
|
||||||
|
|
||||||
AutoReg( TestFunction function,
|
AutoReg
|
||||||
|
( TestFunction function,
|
||||||
SourceLineInfo const& lineInfo,
|
SourceLineInfo const& lineInfo,
|
||||||
NameAndDesc const& nameAndDesc );
|
NameAndDesc const& nameAndDesc );
|
||||||
|
|
||||||
template<typename C>
|
template<typename C>
|
||||||
AutoReg( void (C::*method)(),
|
AutoReg
|
||||||
|
( void (C::*method)(),
|
||||||
char const* className,
|
char const* className,
|
||||||
NameAndDesc const& nameAndDesc,
|
NameAndDesc const& nameAndDesc,
|
||||||
SourceLineInfo const& lineInfo ) {
|
SourceLineInfo const& lineInfo ) {
|
||||||
registerTestCase( new MethodTestCase<C>( method ),
|
|
||||||
|
registerTestCase
|
||||||
|
( new MethodTestCase<C>( method ),
|
||||||
className,
|
className,
|
||||||
nameAndDesc,
|
nameAndDesc,
|
||||||
lineInfo );
|
lineInfo );
|
||||||
}
|
}
|
||||||
|
|
||||||
void registerTestCase( ITestCase* testCase,
|
|
||||||
char const* className,
|
|
||||||
NameAndDesc const& nameAndDesc,
|
|
||||||
SourceLineInfo const& lineInfo );
|
|
||||||
|
|
||||||
~AutoReg();
|
~AutoReg();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
@@ -71,50 +76,70 @@ private:
|
|||||||
void operator= ( AutoReg const& );
|
void operator= ( AutoReg const& );
|
||||||
};
|
};
|
||||||
|
|
||||||
|
void registerTestCaseFunction
|
||||||
|
( TestFunction function,
|
||||||
|
SourceLineInfo const& lineInfo,
|
||||||
|
NameAndDesc const& nameAndDesc );
|
||||||
|
|
||||||
} // end namespace Catch
|
} // end namespace Catch
|
||||||
|
|
||||||
#ifdef CATCH_CONFIG_VARIADIC_MACROS
|
#ifdef CATCH_CONFIG_VARIADIC_MACROS
|
||||||
///////////////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////////////
|
||||||
|
#define INTERNAL_CATCH_TESTCASE2( TestName, ... ) \
|
||||||
|
static void TestName(); \
|
||||||
|
namespace{ Catch::AutoReg INTERNAL_CATCH_UNIQUE_NAME( autoRegistrar )( &TestName, CATCH_INTERNAL_LINEINFO, Catch::NameAndDesc( __VA_ARGS__ ) ); }\
|
||||||
|
static void TestName()
|
||||||
#define INTERNAL_CATCH_TESTCASE( ... ) \
|
#define INTERNAL_CATCH_TESTCASE( ... ) \
|
||||||
static void INTERNAL_CATCH_UNIQUE_NAME( ____C_A_T_C_H____T_E_S_T____ )(); \
|
INTERNAL_CATCH_TESTCASE2( INTERNAL_CATCH_UNIQUE_NAME( ____C_A_T_C_H____T_E_S_T____ ), __VA_ARGS__ )
|
||||||
namespace{ Catch::AutoReg INTERNAL_CATCH_UNIQUE_NAME( autoRegistrar )( &INTERNAL_CATCH_UNIQUE_NAME( ____C_A_T_C_H____T_E_S_T____ ), CATCH_INTERNAL_LINEINFO, Catch::NameAndDesc( __VA_ARGS__ ) ); }\
|
|
||||||
static void INTERNAL_CATCH_UNIQUE_NAME( ____C_A_T_C_H____T_E_S_T____ )()
|
|
||||||
|
|
||||||
///////////////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////////////
|
||||||
#define INTERNAL_CATCH_METHOD_AS_TEST_CASE( QualifiedMethod, ... ) \
|
#define INTERNAL_CATCH_METHOD_AS_TEST_CASE( QualifiedMethod, ... ) \
|
||||||
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 ); }
|
||||||
|
|
||||||
///////////////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////////////
|
||||||
#define INTERNAL_CATCH_TEST_CASE_METHOD( ClassName, ... )\
|
#define INTERNAL_CATCH_TEST_CASE_METHOD2( TestName, ClassName, ... )\
|
||||||
namespace{ \
|
namespace{ \
|
||||||
struct INTERNAL_CATCH_UNIQUE_NAME( ____C_A_T_C_H____T_E_S_T____ ) : ClassName{ \
|
struct TestName : ClassName{ \
|
||||||
void test(); \
|
void test(); \
|
||||||
}; \
|
}; \
|
||||||
Catch::AutoReg INTERNAL_CATCH_UNIQUE_NAME( autoRegistrar ) ( &INTERNAL_CATCH_UNIQUE_NAME( ____C_A_T_C_H____T_E_S_T____ )::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 ); \
|
||||||
} \
|
} \
|
||||||
void INTERNAL_CATCH_UNIQUE_NAME( ____C_A_T_C_H____T_E_S_T____ )::test()
|
void TestName::test()
|
||||||
|
#define INTERNAL_CATCH_TEST_CASE_METHOD( ClassName, ... ) \
|
||||||
|
INTERNAL_CATCH_TEST_CASE_METHOD2( INTERNAL_CATCH_UNIQUE_NAME( ____C_A_T_C_H____T_E_S_T____ ), ClassName, __VA_ARGS__ )
|
||||||
|
|
||||||
|
///////////////////////////////////////////////////////////////////////////////
|
||||||
|
#define INTERNAL_CATCH_REGISTER_TESTCASE( Function, ... ) \
|
||||||
|
Catch::AutoReg( Function, CATCH_INTERNAL_LINEINFO, Catch::NameAndDesc( __VA_ARGS__ ) );
|
||||||
|
|
||||||
#else
|
#else
|
||||||
///////////////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////////////
|
||||||
|
#define INTERNAL_CATCH_TESTCASE2( TestName, Name, Desc ) \
|
||||||
|
static void TestName(); \
|
||||||
|
namespace{ Catch::AutoReg INTERNAL_CATCH_UNIQUE_NAME( autoRegistrar )( &TestName, CATCH_INTERNAL_LINEINFO, Catch::NameAndDesc( Name, Desc ) ); }\
|
||||||
|
static void TestName()
|
||||||
#define INTERNAL_CATCH_TESTCASE( Name, Desc ) \
|
#define INTERNAL_CATCH_TESTCASE( Name, Desc ) \
|
||||||
static void INTERNAL_CATCH_UNIQUE_NAME( ____C_A_T_C_H____T_E_S_T____ )(); \
|
INTERNAL_CATCH_TESTCASE2( INTERNAL_CATCH_UNIQUE_NAME( ____C_A_T_C_H____T_E_S_T____ ), Name, Desc )
|
||||||
namespace{ Catch::AutoReg INTERNAL_CATCH_UNIQUE_NAME( autoRegistrar )( &INTERNAL_CATCH_UNIQUE_NAME( ____C_A_T_C_H____T_E_S_T____ ), CATCH_INTERNAL_LINEINFO, Catch::NameAndDesc( Name, Desc ) ); }\
|
|
||||||
static void INTERNAL_CATCH_UNIQUE_NAME( ____C_A_T_C_H____T_E_S_T____ )()
|
|
||||||
|
|
||||||
///////////////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////////////
|
||||||
#define INTERNAL_CATCH_METHOD_AS_TEST_CASE( QualifiedMethod, Name, Desc ) \
|
#define INTERNAL_CATCH_METHOD_AS_TEST_CASE( QualifiedMethod, Name, Desc ) \
|
||||||
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 ); }
|
||||||
|
|
||||||
///////////////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////////////
|
||||||
#define INTERNAL_CATCH_TEST_CASE_METHOD( ClassName, TestName, Desc )\
|
#define INTERNAL_CATCH_TEST_CASE_METHOD2( TestCaseName, ClassName, TestName, Desc )\
|
||||||
namespace{ \
|
namespace{ \
|
||||||
struct INTERNAL_CATCH_UNIQUE_NAME( ____C_A_T_C_H____T_E_S_T____ ) : ClassName{ \
|
struct TestCaseName : ClassName{ \
|
||||||
void test(); \
|
void test(); \
|
||||||
}; \
|
}; \
|
||||||
Catch::AutoReg INTERNAL_CATCH_UNIQUE_NAME( autoRegistrar ) ( &INTERNAL_CATCH_UNIQUE_NAME( ____C_A_T_C_H____T_E_S_T____ )::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 ); \
|
||||||
} \
|
} \
|
||||||
void INTERNAL_CATCH_UNIQUE_NAME( ____C_A_T_C_H____T_E_S_T____ )::test()
|
void TestCaseName::test()
|
||||||
|
#define INTERNAL_CATCH_TEST_CASE_METHOD( ClassName, TestName, Desc )\
|
||||||
|
INTERNAL_CATCH_TEST_CASE_METHOD2( INTERNAL_CATCH_UNIQUE_NAME( ____C_A_T_C_H____T_E_S_T____ ), ClassName, TestName, Desc )
|
||||||
|
|
||||||
|
///////////////////////////////////////////////////////////////////////////////
|
||||||
|
#define INTERNAL_CATCH_REGISTER_TESTCASE( Function, Name, Desc ) \
|
||||||
|
Catch::AutoReg( Function, CATCH_INTERNAL_LINEINFO, Catch::NameAndDesc( Name, Desc ) );
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#endif // TWOBLUECUBES_CATCH_TEST_REGISTRY_HPP_INCLUDED
|
#endif // TWOBLUECUBES_CATCH_TEST_REGISTRY_HPP_INCLUDED
|
||||||
|
@@ -55,10 +55,13 @@ namespace Detail {
|
|||||||
|
|
||||||
std::string toString( std::string const& value ) {
|
std::string toString( std::string const& value ) {
|
||||||
std::string s = value;
|
std::string s = value;
|
||||||
if( getCurrentContext().getConfig()->showInvisibles() ) {
|
IConfig const* config = getCurrentConfig();
|
||||||
|
if( config && config->showInvisibles() ) {
|
||||||
for(size_t i = 0; i < s.size(); ++i ) {
|
for(size_t i = 0; i < s.size(); ++i ) {
|
||||||
std::string subs;
|
std::string subs;
|
||||||
switch( s[i] ) {
|
switch( s[i] ) {
|
||||||
|
case '\r': subs = "\\r"; break;
|
||||||
|
case '\l': subs = "\\l"; break;
|
||||||
case '\n': subs = "\\n"; break;
|
case '\n': subs = "\\n"; break;
|
||||||
case '\t': subs = "\\t"; break;
|
case '\t': subs = "\\t"; break;
|
||||||
default: break;
|
default: break;
|
||||||
|
@@ -37,7 +37,7 @@ namespace Catch {
|
|||||||
return os;
|
return os;
|
||||||
}
|
}
|
||||||
|
|
||||||
Version libraryVersion( 1, 2, 1, "develop", 11 );
|
Version libraryVersion( 2, 0, 0, "develop", 2 );
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -19,47 +19,53 @@ namespace Catch {
|
|||||||
StreamingReporterBase( ReporterConfig const& _config )
|
StreamingReporterBase( ReporterConfig const& _config )
|
||||||
: m_config( _config.fullConfig() ),
|
: m_config( _config.fullConfig() ),
|
||||||
stream( _config.stream() )
|
stream( _config.stream() )
|
||||||
{}
|
{
|
||||||
|
m_reporterPrefs.shouldRedirectStdOut = false;
|
||||||
|
}
|
||||||
|
|
||||||
virtual ~StreamingReporterBase();
|
virtual ReporterPreferences getPreferences() const CATCH_OVERRIDE {
|
||||||
|
return m_reporterPrefs;
|
||||||
|
}
|
||||||
|
|
||||||
virtual void noMatchingTestCases( std::string const& ) {}
|
virtual ~StreamingReporterBase() CATCH_OVERRIDE;
|
||||||
|
|
||||||
virtual void testRunStarting( TestRunInfo const& _testRunInfo ) {
|
virtual void noMatchingTestCases( std::string const& ) CATCH_OVERRIDE {}
|
||||||
|
|
||||||
|
virtual void testRunStarting( TestRunInfo const& _testRunInfo ) CATCH_OVERRIDE {
|
||||||
currentTestRunInfo = _testRunInfo;
|
currentTestRunInfo = _testRunInfo;
|
||||||
}
|
}
|
||||||
virtual void testGroupStarting( GroupInfo const& _groupInfo ) {
|
virtual void testGroupStarting( GroupInfo const& _groupInfo ) CATCH_OVERRIDE {
|
||||||
currentGroupInfo = _groupInfo;
|
currentGroupInfo = _groupInfo;
|
||||||
}
|
}
|
||||||
|
|
||||||
virtual void testCaseStarting( TestCaseInfo const& _testInfo ) {
|
virtual void testCaseStarting( TestCaseInfo const& _testInfo ) CATCH_OVERRIDE {
|
||||||
currentTestCaseInfo = _testInfo;
|
currentTestCaseInfo = _testInfo;
|
||||||
}
|
}
|
||||||
virtual void sectionStarting( SectionInfo const& _sectionInfo ) {
|
virtual void sectionStarting( SectionInfo const& _sectionInfo ) CATCH_OVERRIDE {
|
||||||
m_sectionStack.push_back( _sectionInfo );
|
m_sectionStack.push_back( _sectionInfo );
|
||||||
}
|
}
|
||||||
|
|
||||||
virtual void sectionEnded( SectionStats const& /* _sectionStats */ ) {
|
virtual void sectionEnded( SectionStats const& /* _sectionStats */ ) CATCH_OVERRIDE {
|
||||||
m_sectionStack.pop_back();
|
m_sectionStack.pop_back();
|
||||||
}
|
}
|
||||||
virtual void testCaseEnded( TestCaseStats const& /* _testCaseStats */ ) {
|
virtual void testCaseEnded( TestCaseStats const& /* _testCaseStats */ ) CATCH_OVERRIDE {
|
||||||
currentTestCaseInfo.reset();
|
currentTestCaseInfo.reset();
|
||||||
}
|
}
|
||||||
virtual void testGroupEnded( TestGroupStats const& /* _testGroupStats */ ) {
|
virtual void testGroupEnded( TestGroupStats const& /* _testGroupStats */ ) CATCH_OVERRIDE {
|
||||||
currentGroupInfo.reset();
|
currentGroupInfo.reset();
|
||||||
}
|
}
|
||||||
virtual void testRunEnded( TestRunStats const& /* _testRunStats */ ) {
|
virtual void testRunEnded( TestRunStats const& /* _testRunStats */ ) CATCH_OVERRIDE {
|
||||||
currentTestCaseInfo.reset();
|
currentTestCaseInfo.reset();
|
||||||
currentGroupInfo.reset();
|
currentGroupInfo.reset();
|
||||||
currentTestRunInfo.reset();
|
currentTestRunInfo.reset();
|
||||||
}
|
}
|
||||||
|
|
||||||
virtual void skipTest( TestCaseInfo const& ) {
|
virtual void skipTest( TestCaseInfo const& ) CATCH_OVERRIDE {
|
||||||
// Don't do anything with this by default.
|
// Don't do anything with this by default.
|
||||||
// It can optionally be overridden in the derived class.
|
// It can optionally be overridden in the derived class.
|
||||||
}
|
}
|
||||||
|
|
||||||
Ptr<IConfig> m_config;
|
Ptr<IConfig const> m_config;
|
||||||
std::ostream& stream;
|
std::ostream& stream;
|
||||||
|
|
||||||
LazyStat<TestRunInfo> currentTestRunInfo;
|
LazyStat<TestRunInfo> currentTestRunInfo;
|
||||||
@@ -67,6 +73,7 @@ namespace Catch {
|
|||||||
LazyStat<TestCaseInfo> currentTestCaseInfo;
|
LazyStat<TestCaseInfo> currentTestCaseInfo;
|
||||||
|
|
||||||
std::vector<SectionInfo> m_sectionStack;
|
std::vector<SectionInfo> m_sectionStack;
|
||||||
|
ReporterPreferences m_reporterPrefs;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct CumulativeReporterBase : SharedImpl<IStreamingReporter> {
|
struct CumulativeReporterBase : SharedImpl<IStreamingReporter> {
|
||||||
@@ -118,15 +125,21 @@ namespace Catch {
|
|||||||
CumulativeReporterBase( ReporterConfig const& _config )
|
CumulativeReporterBase( ReporterConfig const& _config )
|
||||||
: m_config( _config.fullConfig() ),
|
: m_config( _config.fullConfig() ),
|
||||||
stream( _config.stream() )
|
stream( _config.stream() )
|
||||||
{}
|
{
|
||||||
|
m_reporterPrefs.shouldRedirectStdOut = false;
|
||||||
|
}
|
||||||
~CumulativeReporterBase();
|
~CumulativeReporterBase();
|
||||||
|
|
||||||
virtual void testRunStarting( TestRunInfo const& ) {}
|
virtual ReporterPreferences getPreferences() const CATCH_OVERRIDE {
|
||||||
virtual void testGroupStarting( GroupInfo const& ) {}
|
return m_reporterPrefs;
|
||||||
|
}
|
||||||
|
|
||||||
virtual void testCaseStarting( TestCaseInfo const& ) {}
|
virtual void testRunStarting( TestRunInfo const& ) CATCH_OVERRIDE {}
|
||||||
|
virtual void testGroupStarting( GroupInfo const& ) CATCH_OVERRIDE {}
|
||||||
|
|
||||||
virtual void sectionStarting( SectionInfo const& sectionInfo ) {
|
virtual void testCaseStarting( TestCaseInfo const& ) CATCH_OVERRIDE {}
|
||||||
|
|
||||||
|
virtual void sectionStarting( SectionInfo const& sectionInfo ) CATCH_OVERRIDE {
|
||||||
SectionStats incompleteStats( sectionInfo, Counts(), 0, false );
|
SectionStats incompleteStats( sectionInfo, Counts(), 0, false );
|
||||||
Ptr<SectionNode> node;
|
Ptr<SectionNode> node;
|
||||||
if( m_sectionStack.empty() ) {
|
if( m_sectionStack.empty() ) {
|
||||||
@@ -151,7 +164,7 @@ namespace Catch {
|
|||||||
m_deepestSection = node;
|
m_deepestSection = node;
|
||||||
}
|
}
|
||||||
|
|
||||||
virtual void assertionStarting( AssertionInfo const& ) {}
|
virtual void assertionStarting( AssertionInfo const& ) CATCH_OVERRIDE {}
|
||||||
|
|
||||||
virtual bool assertionEnded( AssertionStats const& assertionStats ) {
|
virtual bool assertionEnded( AssertionStats const& assertionStats ) {
|
||||||
assert( !m_sectionStack.empty() );
|
assert( !m_sectionStack.empty() );
|
||||||
@@ -159,13 +172,13 @@ namespace Catch {
|
|||||||
sectionNode.assertions.push_back( assertionStats );
|
sectionNode.assertions.push_back( assertionStats );
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
virtual void sectionEnded( SectionStats const& sectionStats ) {
|
virtual void sectionEnded( SectionStats const& sectionStats ) CATCH_OVERRIDE {
|
||||||
assert( !m_sectionStack.empty() );
|
assert( !m_sectionStack.empty() );
|
||||||
SectionNode& node = *m_sectionStack.back();
|
SectionNode& node = *m_sectionStack.back();
|
||||||
node.stats = sectionStats;
|
node.stats = sectionStats;
|
||||||
m_sectionStack.pop_back();
|
m_sectionStack.pop_back();
|
||||||
}
|
}
|
||||||
virtual void testCaseEnded( TestCaseStats const& testCaseStats ) {
|
virtual void testCaseEnded( TestCaseStats const& testCaseStats ) CATCH_OVERRIDE {
|
||||||
Ptr<TestCaseNode> node = new TestCaseNode( testCaseStats );
|
Ptr<TestCaseNode> node = new TestCaseNode( testCaseStats );
|
||||||
assert( m_sectionStack.size() == 0 );
|
assert( m_sectionStack.size() == 0 );
|
||||||
node->children.push_back( m_rootSection );
|
node->children.push_back( m_rootSection );
|
||||||
@@ -176,12 +189,12 @@ namespace Catch {
|
|||||||
m_deepestSection->stdOut = testCaseStats.stdOut;
|
m_deepestSection->stdOut = testCaseStats.stdOut;
|
||||||
m_deepestSection->stdErr = testCaseStats.stdErr;
|
m_deepestSection->stdErr = testCaseStats.stdErr;
|
||||||
}
|
}
|
||||||
virtual void testGroupEnded( TestGroupStats const& testGroupStats ) {
|
virtual void testGroupEnded( TestGroupStats const& testGroupStats ) CATCH_OVERRIDE {
|
||||||
Ptr<TestGroupNode> node = new TestGroupNode( testGroupStats );
|
Ptr<TestGroupNode> node = new TestGroupNode( testGroupStats );
|
||||||
node->children.swap( m_testCases );
|
node->children.swap( m_testCases );
|
||||||
m_testGroups.push_back( node );
|
m_testGroups.push_back( node );
|
||||||
}
|
}
|
||||||
virtual void testRunEnded( TestRunStats const& testRunStats ) {
|
virtual void testRunEnded( TestRunStats const& testRunStats ) CATCH_OVERRIDE {
|
||||||
Ptr<TestRunNode> node = new TestRunNode( testRunStats );
|
Ptr<TestRunNode> node = new TestRunNode( testRunStats );
|
||||||
node->children.swap( m_testGroups );
|
node->children.swap( m_testGroups );
|
||||||
m_testRuns.push_back( node );
|
m_testRuns.push_back( node );
|
||||||
@@ -189,9 +202,9 @@ namespace Catch {
|
|||||||
}
|
}
|
||||||
virtual void testRunEndedCumulative() = 0;
|
virtual void testRunEndedCumulative() = 0;
|
||||||
|
|
||||||
virtual void skipTest( TestCaseInfo const& ) {}
|
virtual void skipTest( TestCaseInfo const& ) CATCH_OVERRIDE {}
|
||||||
|
|
||||||
Ptr<IConfig> m_config;
|
Ptr<IConfig const> m_config;
|
||||||
std::ostream& stream;
|
std::ostream& stream;
|
||||||
std::vector<AssertionStats> m_assertions;
|
std::vector<AssertionStats> m_assertions;
|
||||||
std::vector<std::vector<Ptr<SectionNode> > > m_sections;
|
std::vector<std::vector<Ptr<SectionNode> > > m_sections;
|
||||||
@@ -203,6 +216,7 @@ namespace Catch {
|
|||||||
Ptr<SectionNode> m_rootSection;
|
Ptr<SectionNode> m_rootSection;
|
||||||
Ptr<SectionNode> m_deepestSection;
|
Ptr<SectionNode> m_deepestSection;
|
||||||
std::vector<Ptr<SectionNode> > m_sectionStack;
|
std::vector<Ptr<SectionNode> > m_sectionStack;
|
||||||
|
ReporterPreferences m_reporterPrefs;
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -216,6 +230,18 @@ namespace Catch {
|
|||||||
return line;
|
return line;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
struct TestEventListenerBase : StreamingReporterBase {
|
||||||
|
TestEventListenerBase( ReporterConfig const& _config )
|
||||||
|
: StreamingReporterBase( _config )
|
||||||
|
{}
|
||||||
|
|
||||||
|
virtual void assertionStarting( AssertionInfo const& ) CATCH_OVERRIDE {}
|
||||||
|
virtual bool assertionEnded( AssertionStats const& ) CATCH_OVERRIDE {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
} // end namespace Catch
|
} // end namespace Catch
|
||||||
|
|
||||||
#endif // TWOBLUECUBES_CATCH_REPORTER_BASES_HPP_INCLUDED
|
#endif // TWOBLUECUBES_CATCH_REPORTER_BASES_HPP_INCLUDED
|
||||||
|
@@ -21,24 +21,19 @@ namespace Catch {
|
|||||||
m_headerPrinted( false )
|
m_headerPrinted( false )
|
||||||
{}
|
{}
|
||||||
|
|
||||||
virtual ~ConsoleReporter();
|
virtual ~ConsoleReporter() CATCH_OVERRIDE;
|
||||||
static std::string getDescription() {
|
static std::string getDescription() {
|
||||||
return "Reports test results as plain lines of text";
|
return "Reports test results as plain lines of text";
|
||||||
}
|
}
|
||||||
virtual ReporterPreferences getPreferences() const {
|
|
||||||
ReporterPreferences prefs;
|
|
||||||
prefs.shouldRedirectStdOut = false;
|
|
||||||
return prefs;
|
|
||||||
}
|
|
||||||
|
|
||||||
virtual void noMatchingTestCases( std::string const& spec ) {
|
virtual void noMatchingTestCases( std::string const& spec ) CATCH_OVERRIDE {
|
||||||
stream << "No test cases matched '" << spec << "'" << std::endl;
|
stream << "No test cases matched '" << spec << "'" << std::endl;
|
||||||
}
|
}
|
||||||
|
|
||||||
virtual void assertionStarting( AssertionInfo const& ) {
|
virtual void assertionStarting( AssertionInfo const& ) CATCH_OVERRIDE {
|
||||||
}
|
}
|
||||||
|
|
||||||
virtual bool assertionEnded( AssertionStats const& _assertionStats ) {
|
virtual bool assertionEnded( AssertionStats const& _assertionStats ) CATCH_OVERRIDE {
|
||||||
AssertionResult const& result = _assertionStats.assertionResult;
|
AssertionResult const& result = _assertionStats.assertionResult;
|
||||||
|
|
||||||
bool printInfoMessages = true;
|
bool printInfoMessages = true;
|
||||||
@@ -58,11 +53,11 @@ namespace Catch {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
virtual void sectionStarting( SectionInfo const& _sectionInfo ) {
|
virtual void sectionStarting( SectionInfo const& _sectionInfo ) CATCH_OVERRIDE {
|
||||||
m_headerPrinted = false;
|
m_headerPrinted = false;
|
||||||
StreamingReporterBase::sectionStarting( _sectionInfo );
|
StreamingReporterBase::sectionStarting( _sectionInfo );
|
||||||
}
|
}
|
||||||
virtual void sectionEnded( SectionStats const& _sectionStats ) {
|
virtual void sectionEnded( SectionStats const& _sectionStats ) CATCH_OVERRIDE {
|
||||||
if( _sectionStats.missingAssertions ) {
|
if( _sectionStats.missingAssertions ) {
|
||||||
lazyPrint();
|
lazyPrint();
|
||||||
Colour colour( Colour::ResultError );
|
Colour colour( Colour::ResultError );
|
||||||
@@ -84,11 +79,11 @@ namespace Catch {
|
|||||||
StreamingReporterBase::sectionEnded( _sectionStats );
|
StreamingReporterBase::sectionEnded( _sectionStats );
|
||||||
}
|
}
|
||||||
|
|
||||||
virtual void testCaseEnded( TestCaseStats const& _testCaseStats ) {
|
virtual void testCaseEnded( TestCaseStats const& _testCaseStats ) CATCH_OVERRIDE {
|
||||||
StreamingReporterBase::testCaseEnded( _testCaseStats );
|
StreamingReporterBase::testCaseEnded( _testCaseStats );
|
||||||
m_headerPrinted = false;
|
m_headerPrinted = false;
|
||||||
}
|
}
|
||||||
virtual void testGroupEnded( TestGroupStats const& _testGroupStats ) {
|
virtual void testGroupEnded( TestGroupStats const& _testGroupStats ) CATCH_OVERRIDE {
|
||||||
if( currentGroupInfo.used ) {
|
if( currentGroupInfo.used ) {
|
||||||
printSummaryDivider();
|
printSummaryDivider();
|
||||||
stream << "Summary for group '" << _testGroupStats.groupInfo.name << "':\n";
|
stream << "Summary for group '" << _testGroupStats.groupInfo.name << "':\n";
|
||||||
@@ -97,7 +92,7 @@ namespace Catch {
|
|||||||
}
|
}
|
||||||
StreamingReporterBase::testGroupEnded( _testGroupStats );
|
StreamingReporterBase::testGroupEnded( _testGroupStats );
|
||||||
}
|
}
|
||||||
virtual void testRunEnded( TestRunStats const& _testRunStats ) {
|
virtual void testRunEnded( TestRunStats const& _testRunStats ) CATCH_OVERRIDE {
|
||||||
printTotalsDivider( _testRunStats.totals );
|
printTotalsDivider( _testRunStats.totals );
|
||||||
printTotals( _testRunStats.totals );
|
printTotals( _testRunStats.totals );
|
||||||
stream << std::endl;
|
stream << std::endl;
|
||||||
|
@@ -23,28 +23,24 @@ namespace Catch {
|
|||||||
JunitReporter( ReporterConfig const& _config )
|
JunitReporter( ReporterConfig const& _config )
|
||||||
: CumulativeReporterBase( _config ),
|
: CumulativeReporterBase( _config ),
|
||||||
xml( _config.stream() )
|
xml( _config.stream() )
|
||||||
{}
|
{
|
||||||
|
m_reporterPrefs.shouldRedirectStdOut = true;
|
||||||
|
}
|
||||||
|
|
||||||
~JunitReporter();
|
virtual ~JunitReporter() CATCH_OVERRIDE;
|
||||||
|
|
||||||
static std::string getDescription() {
|
static std::string getDescription() {
|
||||||
return "Reports test results in an XML format that looks like Ant's junitreport target";
|
return "Reports test results in an XML format that looks like Ant's junitreport target";
|
||||||
}
|
}
|
||||||
|
|
||||||
virtual void noMatchingTestCases( std::string const& /*spec*/ ) {}
|
virtual void noMatchingTestCases( std::string const& /*spec*/ ) CATCH_OVERRIDE {}
|
||||||
|
|
||||||
virtual ReporterPreferences getPreferences() const {
|
virtual void testRunStarting( TestRunInfo const& runInfo ) CATCH_OVERRIDE {
|
||||||
ReporterPreferences prefs;
|
|
||||||
prefs.shouldRedirectStdOut = true;
|
|
||||||
return prefs;
|
|
||||||
}
|
|
||||||
|
|
||||||
virtual void testRunStarting( TestRunInfo const& runInfo ) {
|
|
||||||
CumulativeReporterBase::testRunStarting( runInfo );
|
CumulativeReporterBase::testRunStarting( runInfo );
|
||||||
xml.startElement( "testsuites" );
|
xml.startElement( "testsuites" );
|
||||||
}
|
}
|
||||||
|
|
||||||
virtual void testGroupStarting( GroupInfo const& groupInfo ) {
|
virtual void testGroupStarting( GroupInfo const& groupInfo ) CATCH_OVERRIDE {
|
||||||
suiteTimer.start();
|
suiteTimer.start();
|
||||||
stdOutForSuite.str("");
|
stdOutForSuite.str("");
|
||||||
stdErrForSuite.str("");
|
stdErrForSuite.str("");
|
||||||
@@ -52,25 +48,25 @@ namespace Catch {
|
|||||||
CumulativeReporterBase::testGroupStarting( groupInfo );
|
CumulativeReporterBase::testGroupStarting( groupInfo );
|
||||||
}
|
}
|
||||||
|
|
||||||
virtual bool assertionEnded( AssertionStats const& assertionStats ) {
|
virtual bool assertionEnded( AssertionStats const& assertionStats ) CATCH_OVERRIDE {
|
||||||
if( assertionStats.assertionResult.getResultType() == ResultWas::ThrewException )
|
if( assertionStats.assertionResult.getResultType() == ResultWas::ThrewException )
|
||||||
unexpectedExceptions++;
|
unexpectedExceptions++;
|
||||||
return CumulativeReporterBase::assertionEnded( assertionStats );
|
return CumulativeReporterBase::assertionEnded( assertionStats );
|
||||||
}
|
}
|
||||||
|
|
||||||
virtual void testCaseEnded( TestCaseStats const& testCaseStats ) {
|
virtual void testCaseEnded( TestCaseStats const& testCaseStats ) CATCH_OVERRIDE {
|
||||||
stdOutForSuite << testCaseStats.stdOut;
|
stdOutForSuite << testCaseStats.stdOut;
|
||||||
stdErrForSuite << testCaseStats.stdErr;
|
stdErrForSuite << testCaseStats.stdErr;
|
||||||
CumulativeReporterBase::testCaseEnded( testCaseStats );
|
CumulativeReporterBase::testCaseEnded( testCaseStats );
|
||||||
}
|
}
|
||||||
|
|
||||||
virtual void testGroupEnded( TestGroupStats const& testGroupStats ) {
|
virtual void testGroupEnded( TestGroupStats const& testGroupStats ) CATCH_OVERRIDE {
|
||||||
double suiteTime = suiteTimer.getElapsedSeconds();
|
double suiteTime = suiteTimer.getElapsedSeconds();
|
||||||
CumulativeReporterBase::testGroupEnded( testGroupStats );
|
CumulativeReporterBase::testGroupEnded( testGroupStats );
|
||||||
writeGroup( *m_testGroups.back(), suiteTime );
|
writeGroup( *m_testGroups.back(), suiteTime );
|
||||||
}
|
}
|
||||||
|
|
||||||
virtual void testRunEndedCumulative() {
|
virtual void testRunEndedCumulative() CATCH_OVERRIDE {
|
||||||
xml.endElement();
|
xml.endElement();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
147
include/reporters/catch_reporter_multi.hpp
Normal file
147
include/reporters/catch_reporter_multi.hpp
Normal file
@@ -0,0 +1,147 @@
|
|||||||
|
/*
|
||||||
|
* Created by Phil on 5/08/2015.
|
||||||
|
* Copyright 2015 Two Blue Cubes Ltd. All rights reserved.
|
||||||
|
*
|
||||||
|
* 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)
|
||||||
|
*/
|
||||||
|
#ifndef TWOBLUECUBES_CATCH_REPORTER_MULTI_HPP_INCLUDED
|
||||||
|
#define TWOBLUECUBES_CATCH_REPORTER_MULTI_HPP_INCLUDED
|
||||||
|
|
||||||
|
#include "../internal/catch_interfaces_reporter.h"
|
||||||
|
|
||||||
|
namespace Catch {
|
||||||
|
|
||||||
|
class MultipleReporters : public SharedImpl<IStreamingReporter> {
|
||||||
|
typedef std::vector<Ptr<IStreamingReporter> > Reporters;
|
||||||
|
Reporters m_reporters;
|
||||||
|
|
||||||
|
public:
|
||||||
|
void add( Ptr<IStreamingReporter> const& reporter ) {
|
||||||
|
m_reporters.push_back( reporter );
|
||||||
|
}
|
||||||
|
|
||||||
|
public: // IStreamingReporter
|
||||||
|
|
||||||
|
virtual ReporterPreferences getPreferences() const CATCH_OVERRIDE {
|
||||||
|
return m_reporters[0]->getPreferences();
|
||||||
|
}
|
||||||
|
|
||||||
|
virtual void noMatchingTestCases( std::string const& spec ) CATCH_OVERRIDE {
|
||||||
|
for( Reporters::const_iterator it = m_reporters.begin(), itEnd = m_reporters.end();
|
||||||
|
it != itEnd;
|
||||||
|
++it )
|
||||||
|
(*it)->noMatchingTestCases( spec );
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
virtual void testRunStarting( TestRunInfo const& testRunInfo ) CATCH_OVERRIDE {
|
||||||
|
for( Reporters::const_iterator it = m_reporters.begin(), itEnd = m_reporters.end();
|
||||||
|
it != itEnd;
|
||||||
|
++it )
|
||||||
|
(*it)->testRunStarting( testRunInfo );
|
||||||
|
}
|
||||||
|
|
||||||
|
virtual void testGroupStarting( GroupInfo const& groupInfo ) CATCH_OVERRIDE {
|
||||||
|
for( Reporters::const_iterator it = m_reporters.begin(), itEnd = m_reporters.end();
|
||||||
|
it != itEnd;
|
||||||
|
++it )
|
||||||
|
(*it)->testGroupStarting( groupInfo );
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
virtual void testCaseStarting( TestCaseInfo const& testInfo ) CATCH_OVERRIDE {
|
||||||
|
for( Reporters::const_iterator it = m_reporters.begin(), itEnd = m_reporters.end();
|
||||||
|
it != itEnd;
|
||||||
|
++it )
|
||||||
|
(*it)->testCaseStarting( testInfo );
|
||||||
|
}
|
||||||
|
|
||||||
|
virtual void sectionStarting( SectionInfo const& sectionInfo ) CATCH_OVERRIDE {
|
||||||
|
for( Reporters::const_iterator it = m_reporters.begin(), itEnd = m_reporters.end();
|
||||||
|
it != itEnd;
|
||||||
|
++it )
|
||||||
|
(*it)->sectionStarting( sectionInfo );
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
virtual void assertionStarting( AssertionInfo const& assertionInfo ) CATCH_OVERRIDE {
|
||||||
|
for( Reporters::const_iterator it = m_reporters.begin(), itEnd = m_reporters.end();
|
||||||
|
it != itEnd;
|
||||||
|
++it )
|
||||||
|
(*it)->assertionStarting( assertionInfo );
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// The return value indicates if the messages buffer should be cleared:
|
||||||
|
virtual bool assertionEnded( AssertionStats const& assertionStats ) CATCH_OVERRIDE {
|
||||||
|
bool clearBuffer = false;
|
||||||
|
for( Reporters::const_iterator it = m_reporters.begin(), itEnd = m_reporters.end();
|
||||||
|
it != itEnd;
|
||||||
|
++it )
|
||||||
|
clearBuffer |= (*it)->assertionEnded( assertionStats );
|
||||||
|
return clearBuffer;
|
||||||
|
}
|
||||||
|
|
||||||
|
virtual void sectionEnded( SectionStats const& sectionStats ) CATCH_OVERRIDE {
|
||||||
|
for( Reporters::const_iterator it = m_reporters.begin(), itEnd = m_reporters.end();
|
||||||
|
it != itEnd;
|
||||||
|
++it )
|
||||||
|
(*it)->sectionEnded( sectionStats );
|
||||||
|
}
|
||||||
|
|
||||||
|
virtual void testCaseEnded( TestCaseStats const& testCaseStats ) CATCH_OVERRIDE {
|
||||||
|
for( Reporters::const_iterator it = m_reporters.begin(), itEnd = m_reporters.end();
|
||||||
|
it != itEnd;
|
||||||
|
++it )
|
||||||
|
(*it)->testCaseEnded( testCaseStats );
|
||||||
|
}
|
||||||
|
|
||||||
|
virtual void testGroupEnded( TestGroupStats const& testGroupStats ) CATCH_OVERRIDE {
|
||||||
|
for( Reporters::const_iterator it = m_reporters.begin(), itEnd = m_reporters.end();
|
||||||
|
it != itEnd;
|
||||||
|
++it )
|
||||||
|
(*it)->testGroupEnded( testGroupStats );
|
||||||
|
}
|
||||||
|
|
||||||
|
virtual void testRunEnded( TestRunStats const& testRunStats ) CATCH_OVERRIDE {
|
||||||
|
for( Reporters::const_iterator it = m_reporters.begin(), itEnd = m_reporters.end();
|
||||||
|
it != itEnd;
|
||||||
|
++it )
|
||||||
|
(*it)->testRunEnded( testRunStats );
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
virtual void skipTest( TestCaseInfo const& testInfo ) CATCH_OVERRIDE {
|
||||||
|
for( Reporters::const_iterator it = m_reporters.begin(), itEnd = m_reporters.end();
|
||||||
|
it != itEnd;
|
||||||
|
++it )
|
||||||
|
(*it)->skipTest( testInfo );
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
Ptr<IStreamingReporter> addReporter( Ptr<IStreamingReporter> const& existingReporter, Ptr<IStreamingReporter> const& additionalReporter ) {
|
||||||
|
Ptr<IStreamingReporter> resultingReporter;
|
||||||
|
|
||||||
|
if( existingReporter ) {
|
||||||
|
MultipleReporters* multi = dynamic_cast<MultipleReporters*>( existingReporter.get() );
|
||||||
|
if( !multi ) {
|
||||||
|
multi = new MultipleReporters;
|
||||||
|
resultingReporter = Ptr<IStreamingReporter>( multi );
|
||||||
|
if( existingReporter )
|
||||||
|
multi->add( existingReporter );
|
||||||
|
}
|
||||||
|
else
|
||||||
|
resultingReporter = existingReporter;
|
||||||
|
multi->add( additionalReporter );
|
||||||
|
}
|
||||||
|
else
|
||||||
|
resultingReporter = additionalReporter;
|
||||||
|
|
||||||
|
return resultingReporter;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
} // end namespace Catch
|
||||||
|
|
||||||
|
#endif // TWOBLUECUBES_CATCH_REPORTER_MULTI_HPP_INCLUDED
|
@@ -19,6 +19,8 @@
|
|||||||
#ifdef __clang__
|
#ifdef __clang__
|
||||||
# pragma clang diagnostic push
|
# pragma clang diagnostic push
|
||||||
# pragma clang diagnostic ignored "-Wpadded"
|
# pragma clang diagnostic ignored "-Wpadded"
|
||||||
|
# pragma clang diagnostic ignored "-Wc++98-compat"
|
||||||
|
# pragma clang diagnostic ignored "-Wc++98-compat-pedantic"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
namespace Catch {
|
namespace Catch {
|
||||||
@@ -27,7 +29,9 @@ namespace Catch {
|
|||||||
TeamCityReporter( ReporterConfig const& _config )
|
TeamCityReporter( ReporterConfig const& _config )
|
||||||
: StreamingReporterBase( _config ),
|
: StreamingReporterBase( _config ),
|
||||||
m_headerPrintedForThisSection( false )
|
m_headerPrintedForThisSection( false )
|
||||||
{}
|
{
|
||||||
|
m_reporterPrefs.shouldRedirectStdOut = true;
|
||||||
|
}
|
||||||
|
|
||||||
static std::string escape( std::string const& str ) {
|
static std::string escape( std::string const& str ) {
|
||||||
std::string escaped = str;
|
std::string escaped = str;
|
||||||
@@ -39,18 +43,13 @@ namespace Catch {
|
|||||||
replaceInPlace( escaped, "]", "|]" );
|
replaceInPlace( escaped, "]", "|]" );
|
||||||
return escaped;
|
return escaped;
|
||||||
}
|
}
|
||||||
virtual ~TeamCityReporter();
|
virtual ~TeamCityReporter() CATCH_OVERRIDE;
|
||||||
|
|
||||||
static std::string getDescription() {
|
static std::string getDescription() {
|
||||||
return "Reports test results as TeamCity service messages";
|
return "Reports test results as TeamCity service messages";
|
||||||
}
|
}
|
||||||
virtual ReporterPreferences getPreferences() const {
|
|
||||||
ReporterPreferences prefs;
|
|
||||||
prefs.shouldRedirectStdOut = true;
|
|
||||||
return prefs;
|
|
||||||
}
|
|
||||||
|
|
||||||
virtual void skipTest( TestCaseInfo const& testInfo ) {
|
virtual void skipTest( TestCaseInfo const& testInfo ) CATCH_OVERRIDE {
|
||||||
stream << "##teamcity[testIgnored name='"
|
stream << "##teamcity[testIgnored name='"
|
||||||
<< escape( testInfo.name ) << "'";
|
<< escape( testInfo.name ) << "'";
|
||||||
if( testInfo.isHidden() )
|
if( testInfo.isHidden() )
|
||||||
@@ -60,24 +59,24 @@ namespace Catch {
|
|||||||
stream << "]\n";
|
stream << "]\n";
|
||||||
}
|
}
|
||||||
|
|
||||||
virtual void noMatchingTestCases( std::string const& /* spec */ ) {}
|
virtual void noMatchingTestCases( std::string const& /* spec */ ) CATCH_OVERRIDE {}
|
||||||
|
|
||||||
virtual void testGroupStarting( GroupInfo const& groupInfo ) {
|
virtual void testGroupStarting( GroupInfo const& groupInfo ) CATCH_OVERRIDE {
|
||||||
StreamingReporterBase::testGroupStarting( groupInfo );
|
StreamingReporterBase::testGroupStarting( groupInfo );
|
||||||
stream << "##teamcity[testSuiteStarted name='"
|
stream << "##teamcity[testSuiteStarted name='"
|
||||||
<< escape( groupInfo.name ) << "']\n";
|
<< escape( groupInfo.name ) << "']\n";
|
||||||
}
|
}
|
||||||
virtual void testGroupEnded( TestGroupStats const& testGroupStats ) {
|
virtual void testGroupEnded( TestGroupStats const& testGroupStats ) CATCH_OVERRIDE {
|
||||||
StreamingReporterBase::testGroupEnded( testGroupStats );
|
StreamingReporterBase::testGroupEnded( testGroupStats );
|
||||||
stream << "##teamcity[testSuiteFinished name='"
|
stream << "##teamcity[testSuiteFinished name='"
|
||||||
<< escape( testGroupStats.groupInfo.name ) << "']\n";
|
<< escape( testGroupStats.groupInfo.name ) << "']\n";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
virtual void assertionStarting( AssertionInfo const& ) {
|
virtual void assertionStarting( AssertionInfo const& ) CATCH_OVERRIDE {
|
||||||
}
|
}
|
||||||
|
|
||||||
virtual bool assertionEnded( AssertionStats const& assertionStats ) {
|
virtual bool assertionEnded( AssertionStats const& assertionStats ) CATCH_OVERRIDE {
|
||||||
AssertionResult const& result = assertionStats.assertionResult;
|
AssertionResult const& result = assertionStats.assertionResult;
|
||||||
if( !result.isOk() ) {
|
if( !result.isOk() ) {
|
||||||
|
|
||||||
@@ -143,18 +142,18 @@ namespace Catch {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
virtual void sectionStarting( SectionInfo const& sectionInfo ) {
|
virtual void sectionStarting( SectionInfo const& sectionInfo ) CATCH_OVERRIDE {
|
||||||
m_headerPrintedForThisSection = false;
|
m_headerPrintedForThisSection = false;
|
||||||
StreamingReporterBase::sectionStarting( sectionInfo );
|
StreamingReporterBase::sectionStarting( sectionInfo );
|
||||||
}
|
}
|
||||||
|
|
||||||
virtual void testCaseStarting( TestCaseInfo const& testInfo ) {
|
virtual void testCaseStarting( TestCaseInfo const& testInfo ) CATCH_OVERRIDE {
|
||||||
StreamingReporterBase::testCaseStarting( testInfo );
|
StreamingReporterBase::testCaseStarting( testInfo );
|
||||||
stream << "##teamcity[testStarted name='"
|
stream << "##teamcity[testStarted name='"
|
||||||
<< escape( testInfo.name ) << "']\n";
|
<< escape( testInfo.name ) << "']\n";
|
||||||
}
|
}
|
||||||
|
|
||||||
virtual void testCaseEnded( TestCaseStats const& testCaseStats ) {
|
virtual void testCaseEnded( TestCaseStats const& testCaseStats ) CATCH_OVERRIDE {
|
||||||
StreamingReporterBase::testCaseEnded( testCaseStats );
|
StreamingReporterBase::testCaseEnded( testCaseStats );
|
||||||
if( !testCaseStats.stdOut.empty() )
|
if( !testCaseStats.stdOut.empty() )
|
||||||
stream << "##teamcity[testStdOut name='"
|
stream << "##teamcity[testStdOut name='"
|
||||||
|
@@ -21,26 +21,23 @@ namespace Catch {
|
|||||||
XmlReporter( ReporterConfig const& _config )
|
XmlReporter( ReporterConfig const& _config )
|
||||||
: StreamingReporterBase( _config ),
|
: StreamingReporterBase( _config ),
|
||||||
m_sectionDepth( 0 )
|
m_sectionDepth( 0 )
|
||||||
{}
|
{
|
||||||
|
m_reporterPrefs.shouldRedirectStdOut = true;
|
||||||
|
}
|
||||||
|
|
||||||
virtual ~XmlReporter();
|
virtual ~XmlReporter() CATCH_OVERRIDE;
|
||||||
|
|
||||||
static std::string getDescription() {
|
static std::string getDescription() {
|
||||||
return "Reports test results as an XML document";
|
return "Reports test results as an XML document";
|
||||||
}
|
}
|
||||||
|
|
||||||
public: // StreamingReporterBase
|
public: // StreamingReporterBase
|
||||||
virtual ReporterPreferences getPreferences() const {
|
|
||||||
ReporterPreferences prefs;
|
|
||||||
prefs.shouldRedirectStdOut = true;
|
|
||||||
return prefs;
|
|
||||||
}
|
|
||||||
|
|
||||||
virtual void noMatchingTestCases( std::string const& s ) {
|
virtual void noMatchingTestCases( std::string const& s ) CATCH_OVERRIDE {
|
||||||
StreamingReporterBase::noMatchingTestCases( s );
|
StreamingReporterBase::noMatchingTestCases( s );
|
||||||
}
|
}
|
||||||
|
|
||||||
virtual void testRunStarting( TestRunInfo const& testInfo ) {
|
virtual void testRunStarting( TestRunInfo const& testInfo ) CATCH_OVERRIDE {
|
||||||
StreamingReporterBase::testRunStarting( testInfo );
|
StreamingReporterBase::testRunStarting( testInfo );
|
||||||
m_xml.setStream( stream );
|
m_xml.setStream( stream );
|
||||||
m_xml.startElement( "Catch" );
|
m_xml.startElement( "Catch" );
|
||||||
@@ -48,13 +45,13 @@ namespace Catch {
|
|||||||
m_xml.writeAttribute( "name", m_config->name() );
|
m_xml.writeAttribute( "name", m_config->name() );
|
||||||
}
|
}
|
||||||
|
|
||||||
virtual void testGroupStarting( GroupInfo const& groupInfo ) {
|
virtual void testGroupStarting( GroupInfo const& groupInfo ) CATCH_OVERRIDE {
|
||||||
StreamingReporterBase::testGroupStarting( groupInfo );
|
StreamingReporterBase::testGroupStarting( groupInfo );
|
||||||
m_xml.startElement( "Group" )
|
m_xml.startElement( "Group" )
|
||||||
.writeAttribute( "name", groupInfo.name );
|
.writeAttribute( "name", groupInfo.name );
|
||||||
}
|
}
|
||||||
|
|
||||||
virtual void testCaseStarting( TestCaseInfo const& testInfo ) {
|
virtual void testCaseStarting( TestCaseInfo const& testInfo ) CATCH_OVERRIDE {
|
||||||
StreamingReporterBase::testCaseStarting(testInfo);
|
StreamingReporterBase::testCaseStarting(testInfo);
|
||||||
m_xml.startElement( "TestCase" ).writeAttribute( "name", trim( testInfo.name ) );
|
m_xml.startElement( "TestCase" ).writeAttribute( "name", trim( testInfo.name ) );
|
||||||
|
|
||||||
@@ -62,7 +59,7 @@ namespace Catch {
|
|||||||
m_testCaseTimer.start();
|
m_testCaseTimer.start();
|
||||||
}
|
}
|
||||||
|
|
||||||
virtual void sectionStarting( SectionInfo const& sectionInfo ) {
|
virtual void sectionStarting( SectionInfo const& sectionInfo ) CATCH_OVERRIDE {
|
||||||
StreamingReporterBase::sectionStarting( sectionInfo );
|
StreamingReporterBase::sectionStarting( sectionInfo );
|
||||||
if( m_sectionDepth++ > 0 ) {
|
if( m_sectionDepth++ > 0 ) {
|
||||||
m_xml.startElement( "Section" )
|
m_xml.startElement( "Section" )
|
||||||
@@ -71,9 +68,9 @@ namespace Catch {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
virtual void assertionStarting( AssertionInfo const& ) { }
|
virtual void assertionStarting( AssertionInfo const& ) CATCH_OVERRIDE { }
|
||||||
|
|
||||||
virtual bool assertionEnded( AssertionStats const& assertionStats ) {
|
virtual bool assertionEnded( AssertionStats const& assertionStats ) CATCH_OVERRIDE {
|
||||||
const AssertionResult& assertionResult = assertionStats.assertionResult;
|
const AssertionResult& assertionResult = assertionStats.assertionResult;
|
||||||
|
|
||||||
// Print any info messages in <Info> tags.
|
// Print any info messages in <Info> tags.
|
||||||
@@ -144,7 +141,7 @@ namespace Catch {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
virtual void sectionEnded( SectionStats const& sectionStats ) {
|
virtual void sectionEnded( SectionStats const& sectionStats ) CATCH_OVERRIDE {
|
||||||
StreamingReporterBase::sectionEnded( sectionStats );
|
StreamingReporterBase::sectionEnded( sectionStats );
|
||||||
if( --m_sectionDepth > 0 ) {
|
if( --m_sectionDepth > 0 ) {
|
||||||
XmlWriter::ScopedElement e = m_xml.scopedElement( "OverallResults" );
|
XmlWriter::ScopedElement e = m_xml.scopedElement( "OverallResults" );
|
||||||
@@ -159,7 +156,7 @@ namespace Catch {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
virtual void testCaseEnded( TestCaseStats const& testCaseStats ) {
|
virtual void testCaseEnded( TestCaseStats const& testCaseStats ) CATCH_OVERRIDE {
|
||||||
StreamingReporterBase::testCaseEnded( testCaseStats );
|
StreamingReporterBase::testCaseEnded( testCaseStats );
|
||||||
XmlWriter::ScopedElement e = m_xml.scopedElement( "OverallResult" );
|
XmlWriter::ScopedElement e = m_xml.scopedElement( "OverallResult" );
|
||||||
e.writeAttribute( "success", testCaseStats.totals.assertions.allOk() );
|
e.writeAttribute( "success", testCaseStats.totals.assertions.allOk() );
|
||||||
@@ -170,7 +167,7 @@ namespace Catch {
|
|||||||
m_xml.endElement();
|
m_xml.endElement();
|
||||||
}
|
}
|
||||||
|
|
||||||
virtual void testGroupEnded( TestGroupStats const& testGroupStats ) {
|
virtual void testGroupEnded( TestGroupStats const& testGroupStats ) CATCH_OVERRIDE {
|
||||||
StreamingReporterBase::testGroupEnded( testGroupStats );
|
StreamingReporterBase::testGroupEnded( testGroupStats );
|
||||||
// TODO: Check testGroupStats.aborting and act accordingly.
|
// TODO: Check testGroupStats.aborting and act accordingly.
|
||||||
m_xml.scopedElement( "OverallResults" )
|
m_xml.scopedElement( "OverallResults" )
|
||||||
@@ -180,7 +177,7 @@ namespace Catch {
|
|||||||
m_xml.endElement();
|
m_xml.endElement();
|
||||||
}
|
}
|
||||||
|
|
||||||
virtual void testRunEnded( TestRunStats const& testRunStats ) {
|
virtual void testRunEnded( TestRunStats const& testRunStats ) CATCH_OVERRIDE {
|
||||||
StreamingReporterBase::testRunEnded( testRunStats );
|
StreamingReporterBase::testRunEnded( testRunStats );
|
||||||
m_xml.scopedElement( "OverallResults" )
|
m_xml.scopedElement( "OverallResults" )
|
||||||
.writeAttribute( "successes", testRunStats.totals.assertions.passed )
|
.writeAttribute( "successes", testRunStats.totals.assertions.passed )
|
||||||
|
@@ -22,7 +22,7 @@ set(SOURCES
|
|||||||
${SELF_TEST_DIR}/GeneratorTests.cpp
|
${SELF_TEST_DIR}/GeneratorTests.cpp
|
||||||
${SELF_TEST_DIR}/MessageTests.cpp
|
${SELF_TEST_DIR}/MessageTests.cpp
|
||||||
${SELF_TEST_DIR}/MiscTests.cpp
|
${SELF_TEST_DIR}/MiscTests.cpp
|
||||||
${SELF_TEST_DIR}/SectionTrackerTests.cpp
|
${SELF_TEST_DIR}/PartTrackerTests.cpp
|
||||||
${SELF_TEST_DIR}/TestMain.cpp
|
${SELF_TEST_DIR}/TestMain.cpp
|
||||||
${SELF_TEST_DIR}/TrickyTests.cpp
|
${SELF_TEST_DIR}/TrickyTests.cpp
|
||||||
${SELF_TEST_DIR}/VariadicMacrosTests.cpp
|
${SELF_TEST_DIR}/VariadicMacrosTests.cpp
|
||||||
|
@@ -356,7 +356,7 @@ due to unexpected exception with message:
|
|||||||
expected exception
|
expected exception
|
||||||
|
|
||||||
-------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------
|
||||||
Unexpected custom exceptions can be translated
|
Non-std exceptions can be translated
|
||||||
-------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------
|
||||||
ExceptionTests.cpp:<line number>
|
ExceptionTests.cpp:<line number>
|
||||||
...............................................................................
|
...............................................................................
|
||||||
@@ -365,6 +365,16 @@ ExceptionTests.cpp:<line number>: FAILED:
|
|||||||
due to unexpected exception with message:
|
due to unexpected exception with message:
|
||||||
custom exception
|
custom exception
|
||||||
|
|
||||||
|
-------------------------------------------------------------------------------
|
||||||
|
Custom std-exceptions can be custom translated
|
||||||
|
-------------------------------------------------------------------------------
|
||||||
|
ExceptionTests.cpp:<line number>
|
||||||
|
...............................................................................
|
||||||
|
|
||||||
|
ExceptionTests.cpp:<line number>: FAILED:
|
||||||
|
due to unexpected exception with message:
|
||||||
|
custom std exception
|
||||||
|
|
||||||
-------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------
|
||||||
Custom exceptions can be translated when testing for nothrow
|
Custom exceptions can be translated when testing for nothrow
|
||||||
-------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------
|
||||||
@@ -670,7 +680,7 @@ MiscTests.cpp:<line number>
|
|||||||
...............................................................................
|
...............................................................................
|
||||||
|
|
||||||
MiscTests.cpp:<line number>: FAILED:
|
MiscTests.cpp:<line number>: FAILED:
|
||||||
CHECK_THAT( testStringForMatching() Contains( "not there" ) )
|
CHECK_THAT( testStringForMatching(), Contains( "not there" ) )
|
||||||
with expansion:
|
with expansion:
|
||||||
"this string contains 'abc' as a substring" contains: "not there"
|
"this string contains 'abc' as a substring" contains: "not there"
|
||||||
|
|
||||||
@@ -681,7 +691,7 @@ MiscTests.cpp:<line number>
|
|||||||
...............................................................................
|
...............................................................................
|
||||||
|
|
||||||
MiscTests.cpp:<line number>: FAILED:
|
MiscTests.cpp:<line number>: FAILED:
|
||||||
CHECK_THAT( testStringForMatching() StartsWith( "string" ) )
|
CHECK_THAT( testStringForMatching(), StartsWith( "string" ) )
|
||||||
with expansion:
|
with expansion:
|
||||||
"this string contains 'abc' as a substring" starts with: "string"
|
"this string contains 'abc' as a substring" starts with: "string"
|
||||||
|
|
||||||
@@ -692,7 +702,7 @@ MiscTests.cpp:<line number>
|
|||||||
...............................................................................
|
...............................................................................
|
||||||
|
|
||||||
MiscTests.cpp:<line number>: FAILED:
|
MiscTests.cpp:<line number>: FAILED:
|
||||||
CHECK_THAT( testStringForMatching() EndsWith( "this" ) )
|
CHECK_THAT( testStringForMatching(), EndsWith( "this" ) )
|
||||||
with expansion:
|
with expansion:
|
||||||
"this string contains 'abc' as a substring" ends with: "this"
|
"this string contains 'abc' as a substring" ends with: "this"
|
||||||
|
|
||||||
@@ -703,10 +713,33 @@ MiscTests.cpp:<line number>
|
|||||||
...............................................................................
|
...............................................................................
|
||||||
|
|
||||||
MiscTests.cpp:<line number>: FAILED:
|
MiscTests.cpp:<line number>: FAILED:
|
||||||
CHECK_THAT( testStringForMatching() Equals( "something else" ) )
|
CHECK_THAT( testStringForMatching(), Equals( "something else" ) )
|
||||||
with expansion:
|
with expansion:
|
||||||
"this string contains 'abc' as a substring" equals: "something else"
|
"this string contains 'abc' as a substring" equals: "something else"
|
||||||
|
|
||||||
|
-------------------------------------------------------------------------------
|
||||||
|
Matchers can be composed with both && and || - failing
|
||||||
|
-------------------------------------------------------------------------------
|
||||||
|
MiscTests.cpp:<line number>
|
||||||
|
...............................................................................
|
||||||
|
|
||||||
|
MiscTests.cpp:<line number>: FAILED:
|
||||||
|
CHECK_THAT( testStringForMatching(), ( Contains( "string" ) || Contains( "different" ) ) && Contains( "random" ) )
|
||||||
|
with expansion:
|
||||||
|
"this string contains 'abc' as a substring" ( ( contains: "string" or
|
||||||
|
contains: "different" ) and contains: "random" )
|
||||||
|
|
||||||
|
-------------------------------------------------------------------------------
|
||||||
|
Matchers can be negated (Not) with the ! operator - failing
|
||||||
|
-------------------------------------------------------------------------------
|
||||||
|
MiscTests.cpp:<line number>
|
||||||
|
...............................................................................
|
||||||
|
|
||||||
|
MiscTests.cpp:<line number>: FAILED:
|
||||||
|
CHECK_THAT( testStringForMatching(), !Contains( "substring" ) )
|
||||||
|
with expansion:
|
||||||
|
"this string contains 'abc' as a substring" not contains: "substring"
|
||||||
|
|
||||||
-------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------
|
||||||
Nice descriptive name
|
Nice descriptive name
|
||||||
-------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------
|
||||||
@@ -797,6 +830,6 @@ with expansion:
|
|||||||
"first" == "second"
|
"first" == "second"
|
||||||
|
|
||||||
===============================================================================
|
===============================================================================
|
||||||
test cases: 159 | 119 passed | 39 failed | 1 failed as expected
|
test cases: 165 | 122 passed | 42 failed | 1 failed as expected
|
||||||
assertions: 784 | 691 passed | 80 failed | 13 failed as expected
|
assertions: 768 | 672 passed | 83 failed | 13 failed as expected
|
||||||
|
|
||||||
|
File diff suppressed because it is too large
Load Diff
@@ -1,5 +1,5 @@
|
|||||||
<testsuites>
|
<testsuites>
|
||||||
<testsuite name="CatchSelfTest" errors="12" failures="88" tests="804" hostname="tbd" time="{duration}" timestamp="tbd">
|
<testsuite name="CatchSelfTest" errors="13" failures="72" tests="770" hostname="tbd" time="{duration}" timestamp="tbd">
|
||||||
<testcase classname="global" name="toString(enum)" time="{duration}"/>
|
<testcase classname="global" name="toString(enum)" time="{duration}"/>
|
||||||
<testcase classname="global" name="toString(enum w/operator<<)" time="{duration}"/>
|
<testcase classname="global" name="toString(enum w/operator<<)" time="{duration}"/>
|
||||||
<testcase classname="global" name="toString(enum class)" time="{duration}"/>
|
<testcase classname="global" name="toString(enum class)" time="{duration}"/>
|
||||||
@@ -226,9 +226,15 @@ expected exception
|
|||||||
ExceptionTests.cpp:<line number>
|
ExceptionTests.cpp:<line number>
|
||||||
</error>
|
</error>
|
||||||
</testcase>
|
</testcase>
|
||||||
<testcase classname="global" name="Unexpected custom exceptions can be translated" time="{duration}">
|
<testcase classname="global" name="Non-std exceptions can be translated" time="{duration}">
|
||||||
<error type="TEST_CASE">
|
<error type="TEST_CASE">
|
||||||
custom exception
|
custom exception
|
||||||
|
ExceptionTests.cpp:<line number>
|
||||||
|
</error>
|
||||||
|
</testcase>
|
||||||
|
<testcase classname="global" name="Custom std-exceptions can be custom translated" time="{duration}">
|
||||||
|
<error type="TEST_CASE">
|
||||||
|
custom std exception
|
||||||
ExceptionTests.cpp:<line number>
|
ExceptionTests.cpp:<line number>
|
||||||
</error>
|
</error>
|
||||||
</testcase>
|
</testcase>
|
||||||
@@ -259,8 +265,6 @@ ExceptionTests.cpp:<line number>
|
|||||||
ExceptionTests.cpp:<line number>
|
ExceptionTests.cpp:<line number>
|
||||||
</failure>
|
</failure>
|
||||||
</testcase>
|
</testcase>
|
||||||
<testcase classname="global" name="Generators over two ranges" time="{duration}"/>
|
|
||||||
<testcase classname="global" name="Generator over a range of pairs" time="{duration}"/>
|
|
||||||
<testcase classname="global" name="INFO and WARN do not abort tests" time="{duration}"/>
|
<testcase classname="global" name="INFO and WARN do not abort tests" time="{duration}"/>
|
||||||
<testcase classname="global" name="SUCCEED counts as a test pass" time="{duration}"/>
|
<testcase classname="global" name="SUCCEED counts as a test pass" time="{duration}"/>
|
||||||
<testcase classname="global" name="INFO gets logged on failure" time="{duration}">
|
<testcase classname="global" name="INFO gets logged on failure" time="{duration}">
|
||||||
@@ -341,6 +345,11 @@ MessageTests.cpp:<line number>
|
|||||||
MiscTests.cpp:<line number>
|
MiscTests.cpp:<line number>
|
||||||
</failure>
|
</failure>
|
||||||
</testcase>
|
</testcase>
|
||||||
|
<testcase classname="more nested SECTION tests" name="s1/s3" time="{duration}"/>
|
||||||
|
<testcase classname="more nested SECTION tests" name="s1/s4" time="{duration}"/>
|
||||||
|
<testcase classname="even more nested SECTION tests" name="c/d (leaf)" time="{duration}"/>
|
||||||
|
<testcase classname="even more nested SECTION tests" name="c/e (leaf)" time="{duration}"/>
|
||||||
|
<testcase classname="even more nested SECTION tests" name="f (leaf)" time="{duration}"/>
|
||||||
<testcase classname="looped SECTION tests" name="s1" time="{duration}">
|
<testcase classname="looped SECTION tests" name="s1" time="{duration}">
|
||||||
<failure message="0 > 1" type="CHECK">
|
<failure message="0 > 1" type="CHECK">
|
||||||
MiscTests.cpp:<line number>
|
MiscTests.cpp:<line number>
|
||||||
@@ -399,6 +408,8 @@ MiscTests.cpp:<line number>
|
|||||||
MiscTests.cpp:<line number>
|
MiscTests.cpp:<line number>
|
||||||
</failure>
|
</failure>
|
||||||
</testcase>
|
</testcase>
|
||||||
|
<testcase classname="xmlentitycheck" name="embedded xml" time="{duration}"/>
|
||||||
|
<testcase classname="xmlentitycheck" name="encoded chars" time="{duration}"/>
|
||||||
<testcase classname="global" name="send a single char to INFO" time="{duration}">
|
<testcase classname="global" name="send a single char to INFO" time="{duration}">
|
||||||
<failure message="false" type="REQUIRE">
|
<failure message="false" type="REQUIRE">
|
||||||
3
|
3
|
||||||
@@ -431,6 +442,20 @@ MiscTests.cpp:<line number>
|
|||||||
<testcase classname="global" name="AllOf matcher" time="{duration}"/>
|
<testcase classname="global" name="AllOf matcher" time="{duration}"/>
|
||||||
<testcase classname="global" name="AnyOf matcher" time="{duration}"/>
|
<testcase classname="global" name="AnyOf matcher" time="{duration}"/>
|
||||||
<testcase classname="global" name="Equals" time="{duration}"/>
|
<testcase classname="global" name="Equals" time="{duration}"/>
|
||||||
|
<testcase classname="global" name="Matchers can be (AllOf) composed with the && operator" time="{duration}"/>
|
||||||
|
<testcase classname="global" name="Matchers can be (AnyOf) composed with the || operator" time="{duration}"/>
|
||||||
|
<testcase classname="global" name="Matchers can be composed with both && and ||" time="{duration}"/>
|
||||||
|
<testcase classname="global" name="Matchers can be composed with both && and || - failing" time="{duration}">
|
||||||
|
<failure message=""this string contains 'abc' as a substring" ( ( contains: "string" or contains: "different" ) and contains: "random" )" type="CHECK_THAT">
|
||||||
|
MiscTests.cpp:<line number>
|
||||||
|
</failure>
|
||||||
|
</testcase>
|
||||||
|
<testcase classname="global" name="Matchers can be negated (Not) with the ! operator" time="{duration}"/>
|
||||||
|
<testcase classname="global" name="Matchers can be negated (Not) with the ! operator - failing" time="{duration}">
|
||||||
|
<failure message=""this string contains 'abc' as a substring" not contains: "substring"" type="CHECK_THAT">
|
||||||
|
MiscTests.cpp:<line number>
|
||||||
|
</failure>
|
||||||
|
</testcase>
|
||||||
<testcase classname="global" name="Factorials are computed" time="{duration}"/>
|
<testcase classname="global" name="Factorials are computed" time="{duration}"/>
|
||||||
<testcase classname="global" name="Nice descriptive name" time="{duration}"/>
|
<testcase classname="global" name="Nice descriptive name" time="{duration}"/>
|
||||||
<testcase classname="vectors can be sized and resized" name="root" time="{duration}"/>
|
<testcase classname="vectors can be sized and resized" name="root" time="{duration}"/>
|
||||||
@@ -478,6 +503,7 @@ MiscTests.cpp:<line number>
|
|||||||
<testcase classname="Process can be configured on command line" name="test lists/Specify one test case exclusion using ~" time="{duration}"/>
|
<testcase classname="Process can be configured on command line" name="test lists/Specify one test case exclusion using ~" time="{duration}"/>
|
||||||
<testcase classname="Process can be configured on command line" name="reporter/-r/console" time="{duration}"/>
|
<testcase classname="Process can be configured on command line" name="reporter/-r/console" time="{duration}"/>
|
||||||
<testcase classname="Process can be configured on command line" name="reporter/-r/xml" time="{duration}"/>
|
<testcase classname="Process can be configured on command line" name="reporter/-r/xml" time="{duration}"/>
|
||||||
|
<testcase classname="Process can be configured on command line" name="reporter/-r xml and junit" time="{duration}"/>
|
||||||
<testcase classname="Process can be configured on command line" name="reporter/--reporter/junit" time="{duration}"/>
|
<testcase classname="Process can be configured on command line" name="reporter/--reporter/junit" time="{duration}"/>
|
||||||
<testcase classname="Process can be configured on command line" name="debugger/-b" time="{duration}"/>
|
<testcase classname="Process can be configured on command line" name="debugger/-b" time="{duration}"/>
|
||||||
<testcase classname="Process can be configured on command line" name="debugger/--break" time="{duration}"/>
|
<testcase classname="Process can be configured on command line" name="debugger/--break" time="{duration}"/>
|
||||||
@@ -519,6 +545,7 @@ hello
|
|||||||
</testcase>
|
</testcase>
|
||||||
<testcase classname="global" name="Text can be formatted using the Text class" time="{duration}"/>
|
<testcase classname="global" name="Text can be formatted using the Text class" time="{duration}"/>
|
||||||
<testcase classname="global" name="Long text is truncted" time="{duration}"/>
|
<testcase classname="global" name="Long text is truncted" time="{duration}"/>
|
||||||
|
<testcase classname="global" name="ManuallyRegistered" time="{duration}"/>
|
||||||
<testcase classname="global" name="Parsing a std::pair" time="{duration}"/>
|
<testcase classname="global" name="Parsing a std::pair" time="{duration}"/>
|
||||||
<testcase classname="global" name="Where there is more to the expression after the RHS" time="{duration}"/>
|
<testcase classname="global" name="Where there is more to the expression after the RHS" time="{duration}"/>
|
||||||
<testcase classname="global" name="Where the LHS is not a simple value" time="{duration}"/>
|
<testcase classname="global" name="Where the LHS is not a simple value" time="{duration}"/>
|
||||||
@@ -565,6 +592,23 @@ TrickyTests.cpp:<line number>
|
|||||||
<testcase classname="global" name="toString( vectors<has_toString )" time="{duration}"/>
|
<testcase classname="global" name="toString( vectors<has_toString )" time="{duration}"/>
|
||||||
<testcase classname="global" name="toString( vectors<has_maker )" time="{duration}"/>
|
<testcase classname="global" name="toString( vectors<has_maker )" time="{duration}"/>
|
||||||
<testcase classname="global" name="toString( vectors<has_maker_and_toString )" time="{duration}"/>
|
<testcase classname="global" name="toString( vectors<has_maker_and_toString )" time="{duration}"/>
|
||||||
|
<testcase classname="Tracker" name="root" time="{duration}"/>
|
||||||
|
<testcase classname="Tracker" name="successfully close one section" time="{duration}"/>
|
||||||
|
<testcase classname="Tracker" name="fail one section" time="{duration}"/>
|
||||||
|
<testcase classname="Tracker" name="fail one section/re-enter after failed section" time="{duration}"/>
|
||||||
|
<testcase classname="Tracker" name="fail one section/re-enter after failed section and find next section" time="{duration}"/>
|
||||||
|
<testcase classname="Tracker" name="successfully close one section, then find another" time="{duration}"/>
|
||||||
|
<testcase classname="Tracker" name="successfully close one section, then find another/Re-enter - skips S1 and enters S2" time="{duration}"/>
|
||||||
|
<testcase classname="Tracker" name="successfully close one section, then find another/Re-enter - skips S1 and enters S2/Successfully close S2" time="{duration}"/>
|
||||||
|
<testcase classname="Tracker" name="successfully close one section, then find another/Re-enter - skips S1 and enters S2/fail S2" time="{duration}"/>
|
||||||
|
<testcase classname="Tracker" name="open a nested section" time="{duration}"/>
|
||||||
|
<testcase classname="Tracker" name="start a generator" time="{duration}"/>
|
||||||
|
<testcase classname="Tracker" name="start a generator/close outer section" time="{duration}"/>
|
||||||
|
<testcase classname="Tracker" name="start a generator/close outer section/Re-enter for second generation" time="{duration}"/>
|
||||||
|
<testcase classname="Tracker" name="start a generator/Start a new inner section" time="{duration}"/>
|
||||||
|
<testcase classname="Tracker" name="start a generator/Start a new inner section/Re-enter for second generation" time="{duration}"/>
|
||||||
|
<testcase classname="Tracker" name="start a generator/Fail an inner section" time="{duration}"/>
|
||||||
|
<testcase classname="Tracker" name="start a generator/Fail an inner section/Re-enter for second generation" time="{duration}"/>
|
||||||
<testcase classname="global" name="std::pair<int,std::string> -> toString" time="{duration}"/>
|
<testcase classname="global" name="std::pair<int,std::string> -> toString" time="{duration}"/>
|
||||||
<testcase classname="global" name="std::pair<int,const std::string> -> toString" time="{duration}"/>
|
<testcase classname="global" name="std::pair<int,const std::string> -> toString" time="{duration}"/>
|
||||||
<testcase classname="global" name="std::vector<std::pair<std::string,int> > -> toString" time="{duration}"/>
|
<testcase classname="global" name="std::vector<std::pair<std::string,int> > -> toString" time="{duration}"/>
|
||||||
@@ -624,11 +668,6 @@ TrickyTests.cpp:<line number>
|
|||||||
<testcase classname="Scenario: This is a really long scenario name to see how the list command deals with wrapping" name="Given: A section name that is so long that it cannot fit in a single console width/When: The test headers are printed as part of the normal running of the scenario/Then: The, deliberately very long and overly verbose (you see what I did there?) section names must wrap, along with an indent" time="{duration}"/>
|
<testcase classname="Scenario: This is a really long scenario name to see how the list command deals with wrapping" name="Given: A section name that is so long that it cannot fit in a single console width/When: The test headers are printed as part of the normal running of the scenario/Then: The, deliberately very long and overly verbose (you see what I did there?) section names must wrap, along with an indent" time="{duration}"/>
|
||||||
<testcase classname="Fixture" name="Scenario: BDD tests requiring Fixtures to provide commonly-accessed data or methods/Given: No operations precede me" time="{duration}"/>
|
<testcase classname="Fixture" name="Scenario: BDD tests requiring Fixtures to provide commonly-accessed data or methods/Given: No operations precede me" time="{duration}"/>
|
||||||
<testcase classname="Fixture" name="Scenario: BDD tests requiring Fixtures to provide commonly-accessed data or methods/Given: No operations precede me/When: We get the count/Then: Subsequently values are higher" time="{duration}"/>
|
<testcase classname="Fixture" name="Scenario: BDD tests requiring Fixtures to provide commonly-accessed data or methods/Given: No operations precede me/When: We get the count/Then: Subsequently values are higher" time="{duration}"/>
|
||||||
<testcase classname="section tracking" name="root" time="{duration}"/>
|
|
||||||
<testcase classname="section tracking" name="test case with no sections" time="{duration}"/>
|
|
||||||
<testcase classname="section tracking" name="test case with one section" time="{duration}"/>
|
|
||||||
<testcase classname="section tracking" name="test case with two consecutive sections" time="{duration}"/>
|
|
||||||
<testcase classname="section tracking" name="test case with one section within another" time="{duration}"/>
|
|
||||||
<system-out>
|
<system-out>
|
||||||
Message from section one
|
Message from section one
|
||||||
Message from section two
|
Message from section two
|
||||||
|
File diff suppressed because it is too large
Load Diff
@@ -106,22 +106,51 @@ private:
|
|||||||
std::string m_msg;
|
std::string m_msg;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
class CustomStdException : public std::exception
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
CustomStdException( const std::string& msg )
|
||||||
|
: m_msg( msg )
|
||||||
|
{}
|
||||||
|
~CustomStdException() CATCH_NOEXCEPT {}
|
||||||
|
|
||||||
|
std::string getMessage() const
|
||||||
|
{
|
||||||
|
return m_msg;
|
||||||
|
}
|
||||||
|
|
||||||
|
private:
|
||||||
|
std::string m_msg;
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
CATCH_TRANSLATE_EXCEPTION( CustomException& ex )
|
CATCH_TRANSLATE_EXCEPTION( CustomException& ex )
|
||||||
{
|
{
|
||||||
return ex.getMessage();
|
return ex.getMessage();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
CATCH_TRANSLATE_EXCEPTION( CustomStdException& ex )
|
||||||
|
{
|
||||||
|
return ex.getMessage();
|
||||||
|
}
|
||||||
|
|
||||||
CATCH_TRANSLATE_EXCEPTION( double& ex )
|
CATCH_TRANSLATE_EXCEPTION( double& ex )
|
||||||
{
|
{
|
||||||
return Catch::toString( ex );
|
return Catch::toString( ex );
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_CASE("Unexpected custom exceptions can be translated", "[.][failing]" )
|
TEST_CASE("Non-std exceptions can be translated", "[.][failing]" )
|
||||||
{
|
{
|
||||||
if( Catch::alwaysTrue() )
|
if( Catch::alwaysTrue() )
|
||||||
throw CustomException( "custom exception" );
|
throw CustomException( "custom exception" );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
TEST_CASE("Custom std-exceptions can be custom translated", "[.][failing]" )
|
||||||
|
{
|
||||||
|
if( Catch::alwaysTrue() )
|
||||||
|
throw CustomException( "custom std exception" );
|
||||||
|
}
|
||||||
|
|
||||||
inline void throwCustom() {
|
inline void throwCustom() {
|
||||||
if( Catch::alwaysTrue() )
|
if( Catch::alwaysTrue() )
|
||||||
throw CustomException( "custom exception - not std" );
|
throw CustomException( "custom exception - not std" );
|
||||||
|
@@ -1,42 +1,2 @@
|
|||||||
/*
|
// The old generators have been removed
|
||||||
* Created by Phil on 28/01/2011.
|
// A new generator implementation is coming
|
||||||
* Copyright 2011 Two Blue Cubes Ltd. All rights reserved.
|
|
||||||
*
|
|
||||||
* 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)
|
|
||||||
*/
|
|
||||||
|
|
||||||
// This define means we have to prefix all the CATCH macros with CATCH_
|
|
||||||
// We're using it here to test it out
|
|
||||||
#define CATCH_CONFIG_PREFIX_ALL
|
|
||||||
#include "catch.hpp"
|
|
||||||
|
|
||||||
inline int multiply( int a, int b )
|
|
||||||
{
|
|
||||||
return a*b;
|
|
||||||
}
|
|
||||||
|
|
||||||
CATCH_TEST_CASE( "Generators over two ranges", "[generators]" )
|
|
||||||
{
|
|
||||||
using namespace Catch::Generators;
|
|
||||||
|
|
||||||
int i = CATCH_GENERATE( between( 1, 5 ).then( values( 15, 20, 21 ).then( 36 ) ) );
|
|
||||||
int j = CATCH_GENERATE( between( 100, 107 ) );
|
|
||||||
|
|
||||||
CATCH_REQUIRE( multiply( i, 2 ) == i*2 );
|
|
||||||
CATCH_REQUIRE( multiply( j, 2 ) == j*2 );
|
|
||||||
}
|
|
||||||
|
|
||||||
struct IntPair { int first, second; };
|
|
||||||
|
|
||||||
CATCH_TEST_CASE( "Generator over a range of pairs", "[generators]" )
|
|
||||||
{
|
|
||||||
using namespace Catch::Generators;
|
|
||||||
|
|
||||||
IntPair p[] = { { 0, 1 }, { 2, 3 } };
|
|
||||||
|
|
||||||
IntPair* i = CATCH_GENERATE( between( p, &p[1] ) );
|
|
||||||
|
|
||||||
CATCH_REQUIRE( i->first == i->second-1 );
|
|
||||||
|
|
||||||
}
|
|
||||||
|
@@ -7,14 +7,16 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
#include "catch.hpp"
|
#include "catch.hpp"
|
||||||
#include "internal/catch_xmlwriter.hpp"
|
|
||||||
|
|
||||||
#include <iostream>
|
|
||||||
|
|
||||||
#ifdef __clang__
|
#ifdef __clang__
|
||||||
|
# pragma clang diagnostic ignored "-Wc++98-compat"
|
||||||
# pragma clang diagnostic ignored "-Wc++98-compat-pedantic"
|
# pragma clang diagnostic ignored "-Wc++98-compat-pedantic"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#include "../include/internal/catch_xmlwriter.hpp"
|
||||||
|
|
||||||
|
#include <iostream>
|
||||||
|
|
||||||
TEST_CASE( "random SECTION tests", "[.][sections][failing]" )
|
TEST_CASE( "random SECTION tests", "[.][sections][failing]" )
|
||||||
{
|
{
|
||||||
int a = 1;
|
int a = 1;
|
||||||
@@ -78,15 +80,18 @@ TEST_CASE( "even more nested SECTION tests", "[sections]" )
|
|||||||
{
|
{
|
||||||
SECTION( "d (leaf)", "" )
|
SECTION( "d (leaf)", "" )
|
||||||
{
|
{
|
||||||
|
SUCCEED(""); // avoid failing due to no tests
|
||||||
}
|
}
|
||||||
|
|
||||||
SECTION( "e (leaf)", "" )
|
SECTION( "e (leaf)", "" )
|
||||||
{
|
{
|
||||||
|
SUCCEED(""); // avoid failing due to no tests
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
SECTION( "f (leaf)", "" )
|
SECTION( "f (leaf)", "" )
|
||||||
{
|
{
|
||||||
|
SUCCEED(""); // avoid failing due to no tests
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -175,11 +180,11 @@ TEST_CASE( "xmlentitycheck", "" )
|
|||||||
{
|
{
|
||||||
SECTION( "embedded xml", "<test>it should be possible to embed xml characters, such as <, \" or &, or even whole <xml>documents</xml> within an attribute</test>" )
|
SECTION( "embedded xml", "<test>it should be possible to embed xml characters, such as <, \" or &, or even whole <xml>documents</xml> within an attribute</test>" )
|
||||||
{
|
{
|
||||||
// No test
|
SUCCEED(""); // We need this here to stop it failing due to no tests
|
||||||
}
|
}
|
||||||
SECTION( "encoded chars", "these should all be encoded: &&&\"\"\"<<<&\"<<&\"" )
|
SECTION( "encoded chars", "these should all be encoded: &&&\"\"\"<<<&\"<<&\"" )
|
||||||
{
|
{
|
||||||
// No test
|
SUCCEED(""); // We need this here to stop it failing due to no tests
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -203,6 +208,12 @@ inline const char* testStringForMatching()
|
|||||||
{
|
{
|
||||||
return "this string contains 'abc' as a substring";
|
return "this string contains 'abc' as a substring";
|
||||||
}
|
}
|
||||||
|
inline const char* testStringForMatching2()
|
||||||
|
{
|
||||||
|
return "some completely different text that contains one common word";
|
||||||
|
}
|
||||||
|
|
||||||
|
using namespace Catch::Matchers;
|
||||||
|
|
||||||
TEST_CASE("String matchers", "[matchers]" )
|
TEST_CASE("String matchers", "[matchers]" )
|
||||||
{
|
{
|
||||||
@@ -251,6 +262,42 @@ TEST_CASE("Equals", "[matchers]")
|
|||||||
CHECK_THAT( testStringForMatching(), Equals( "this string contains 'abc' as a substring" ) );
|
CHECK_THAT( testStringForMatching(), Equals( "this string contains 'abc' as a substring" ) );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
TEST_CASE("Matchers can be (AllOf) composed with the && operator", "[matchers][operators][operator&&]")
|
||||||
|
{
|
||||||
|
CHECK_THAT( testStringForMatching(),
|
||||||
|
Contains( "string" ) &&
|
||||||
|
Contains( "abc" ) &&
|
||||||
|
Contains( "substring" ) &&
|
||||||
|
Contains( "contains" ) );
|
||||||
|
}
|
||||||
|
|
||||||
|
TEST_CASE("Matchers can be (AnyOf) composed with the || operator", "[matchers][operators][operator||]")
|
||||||
|
{
|
||||||
|
CHECK_THAT( testStringForMatching(), Contains( "string" ) || Contains( "different" ) || Contains( "random" ) );
|
||||||
|
CHECK_THAT( testStringForMatching2(), Contains( "string" ) || Contains( "different" ) || Contains( "random" ) );
|
||||||
|
}
|
||||||
|
|
||||||
|
TEST_CASE("Matchers can be composed with both && and ||", "[matchers][operators][operator||][operator&&]")
|
||||||
|
{
|
||||||
|
CHECK_THAT( testStringForMatching(), ( Contains( "string" ) || Contains( "different" ) ) && Contains( "substring" ) );
|
||||||
|
}
|
||||||
|
|
||||||
|
TEST_CASE("Matchers can be composed with both && and || - failing", "[matchers][operators][operator||][operator&&][.failing]")
|
||||||
|
{
|
||||||
|
CHECK_THAT( testStringForMatching(), ( Contains( "string" ) || Contains( "different" ) ) && Contains( "random" ) );
|
||||||
|
}
|
||||||
|
|
||||||
|
TEST_CASE("Matchers can be negated (Not) with the ! operator", "[matchers][operators][not]")
|
||||||
|
{
|
||||||
|
CHECK_THAT( testStringForMatching(), !Contains( "different" ) );
|
||||||
|
}
|
||||||
|
|
||||||
|
TEST_CASE("Matchers can be negated (Not) with the ! operator - failing", "[matchers][operators][not][.failing]")
|
||||||
|
{
|
||||||
|
CHECK_THAT( testStringForMatching(), !Contains( "substring" ) );
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
inline unsigned int Factorial( unsigned int number )
|
inline unsigned int Factorial( unsigned int number )
|
||||||
{
|
{
|
||||||
// return number <= 1 ? number : Factorial(number-1)*number;
|
// return number <= 1 ? number : Factorial(number-1)*number;
|
||||||
@@ -428,6 +475,8 @@ TEST_CASE( "long long" ) {
|
|||||||
|
|
||||||
//TEST_CASE( "Divide by Zero signal handler", "[.][sig]" ) {
|
//TEST_CASE( "Divide by Zero signal handler", "[.][sig]" ) {
|
||||||
// int i = 0;
|
// int i = 0;
|
||||||
|
// SECTION( "s" ) {
|
||||||
// int x = 10/i; // This should cause the signal to fire
|
// int x = 10/i; // This should cause the signal to fire
|
||||||
// CHECK( x == 0 );
|
// CHECK( x == 0 );
|
||||||
// }
|
// }
|
||||||
|
//}
|
||||||
|
328
projects/SelfTest/PartTrackerTests.cpp
Normal file
328
projects/SelfTest/PartTrackerTests.cpp
Normal file
@@ -0,0 +1,328 @@
|
|||||||
|
/*
|
||||||
|
* Created by Phil on 1/10/2015.
|
||||||
|
* Copyright 2015 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)
|
||||||
|
*/
|
||||||
|
#include "internal/catch_suppress_warnings.h"
|
||||||
|
#include "internal/catch_test_case_tracker.hpp"
|
||||||
|
|
||||||
|
|
||||||
|
namespace Catch
|
||||||
|
{
|
||||||
|
class LocalContext {
|
||||||
|
|
||||||
|
public:
|
||||||
|
TrackerContext& operator()() const {
|
||||||
|
return TrackerContext::instance();
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
} // namespace Catch
|
||||||
|
|
||||||
|
inline Catch::TrackerContext& C_A_T_C_H_Context() {
|
||||||
|
return Catch::TrackerContext::instance();
|
||||||
|
}
|
||||||
|
|
||||||
|
// -------------------
|
||||||
|
|
||||||
|
#include "catch.hpp"
|
||||||
|
|
||||||
|
using namespace Catch;
|
||||||
|
|
||||||
|
//inline void testCase( Catch::LocalContext const& C_A_T_C_H_Context ) {
|
||||||
|
//
|
||||||
|
// REQUIRE( C_A_T_C_H_Context().i() == 42 );
|
||||||
|
//}
|
||||||
|
|
||||||
|
TEST_CASE( "Tracker", "" ) {
|
||||||
|
|
||||||
|
TrackerContext ctx;
|
||||||
|
ctx.startRun();
|
||||||
|
ctx.startCycle();
|
||||||
|
|
||||||
|
ITracker& testCase = SectionTracker::acquire( ctx, "Testcase" );
|
||||||
|
REQUIRE( testCase.isOpen() );
|
||||||
|
|
||||||
|
ITracker& s1 = SectionTracker::acquire( ctx, "S1" );
|
||||||
|
REQUIRE( s1.isOpen() );
|
||||||
|
|
||||||
|
SECTION( "successfully close one section", "" ) {
|
||||||
|
s1.close();
|
||||||
|
REQUIRE( s1.isSuccessfullyCompleted() );
|
||||||
|
REQUIRE( testCase.isComplete() == false );
|
||||||
|
|
||||||
|
testCase.close();
|
||||||
|
REQUIRE( ctx.completedCycle() );
|
||||||
|
REQUIRE( testCase.isSuccessfullyCompleted() );
|
||||||
|
}
|
||||||
|
|
||||||
|
SECTION( "fail one section", "" ) {
|
||||||
|
s1.fail();
|
||||||
|
REQUIRE( s1.isComplete() );
|
||||||
|
REQUIRE( s1.isSuccessfullyCompleted() == false );
|
||||||
|
REQUIRE( testCase.isComplete() == false );
|
||||||
|
|
||||||
|
testCase.close();
|
||||||
|
REQUIRE( ctx.completedCycle() );
|
||||||
|
REQUIRE( testCase.isSuccessfullyCompleted() == false );
|
||||||
|
|
||||||
|
SECTION( "re-enter after failed section", "" ) {
|
||||||
|
ctx.startCycle();
|
||||||
|
ITracker& testCase2 = SectionTracker::acquire( ctx, "Testcase" );
|
||||||
|
REQUIRE( testCase2.isOpen() );
|
||||||
|
|
||||||
|
ITracker& s1b = SectionTracker::acquire( ctx, "S1" );
|
||||||
|
REQUIRE( s1b.isOpen() == false );
|
||||||
|
|
||||||
|
testCase2.close();
|
||||||
|
REQUIRE( ctx.completedCycle() );
|
||||||
|
REQUIRE( testCase.isComplete() );
|
||||||
|
REQUIRE( testCase.isSuccessfullyCompleted() );
|
||||||
|
}
|
||||||
|
SECTION( "re-enter after failed section and find next section", "" ) {
|
||||||
|
ctx.startCycle();
|
||||||
|
ITracker& testCase2 = SectionTracker::acquire( ctx, "Testcase" );
|
||||||
|
REQUIRE( testCase2.isOpen() );
|
||||||
|
|
||||||
|
ITracker& s1b = SectionTracker::acquire( ctx, "S1" );
|
||||||
|
REQUIRE( s1b.isOpen() == false );
|
||||||
|
|
||||||
|
ITracker& s2 = SectionTracker::acquire( ctx, "S2" );
|
||||||
|
REQUIRE( s2.isOpen() );
|
||||||
|
|
||||||
|
s2.close();
|
||||||
|
REQUIRE( ctx.completedCycle() );
|
||||||
|
|
||||||
|
testCase2.close();
|
||||||
|
REQUIRE( testCase.isComplete() );
|
||||||
|
REQUIRE( testCase.isSuccessfullyCompleted() );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
SECTION( "successfully close one section, then find another", "" ) {
|
||||||
|
s1.close();
|
||||||
|
|
||||||
|
ITracker& s2 = SectionTracker::acquire( ctx, "S2" );
|
||||||
|
REQUIRE( s2.isOpen() == false );
|
||||||
|
|
||||||
|
testCase.close();
|
||||||
|
REQUIRE( testCase.isComplete() == false );
|
||||||
|
|
||||||
|
SECTION( "Re-enter - skips S1 and enters S2", "" ) {
|
||||||
|
ctx.startCycle();
|
||||||
|
ITracker& testCase2 = SectionTracker::acquire( ctx, "Testcase" );
|
||||||
|
REQUIRE( testCase2.isOpen() );
|
||||||
|
|
||||||
|
ITracker& s1b = SectionTracker::acquire( ctx, "S1" );
|
||||||
|
REQUIRE( s1b.isOpen() == false );
|
||||||
|
|
||||||
|
ITracker& s2b = SectionTracker::acquire( ctx, "S2" );
|
||||||
|
REQUIRE( s2b.isOpen() );
|
||||||
|
|
||||||
|
REQUIRE( ctx.completedCycle() == false );
|
||||||
|
|
||||||
|
SECTION ("Successfully close S2") {
|
||||||
|
s2b.close();
|
||||||
|
REQUIRE( ctx.completedCycle() );
|
||||||
|
|
||||||
|
REQUIRE( s2b.isSuccessfullyCompleted() );
|
||||||
|
REQUIRE( testCase2.isComplete() == false );
|
||||||
|
|
||||||
|
testCase2.close();
|
||||||
|
REQUIRE( testCase2.isSuccessfullyCompleted() );
|
||||||
|
}
|
||||||
|
SECTION ("fail S2") {
|
||||||
|
s2b.fail();
|
||||||
|
REQUIRE( ctx.completedCycle() );
|
||||||
|
|
||||||
|
REQUIRE( s2b.isComplete() );
|
||||||
|
REQUIRE( s2b.isSuccessfullyCompleted() == false );
|
||||||
|
|
||||||
|
testCase2.close();
|
||||||
|
REQUIRE( testCase2.isSuccessfullyCompleted() == false );
|
||||||
|
|
||||||
|
// Need a final cycle
|
||||||
|
ctx.startCycle();
|
||||||
|
ITracker& testCase3 = SectionTracker::acquire( ctx, "Testcase" );
|
||||||
|
REQUIRE( testCase3.isOpen() );
|
||||||
|
|
||||||
|
ITracker& s1c = SectionTracker::acquire( ctx, "S1" );
|
||||||
|
REQUIRE( s1c.isOpen() == false );
|
||||||
|
|
||||||
|
ITracker& s2c = SectionTracker::acquire( ctx, "S2" );
|
||||||
|
REQUIRE( s2c.isOpen() == false );
|
||||||
|
|
||||||
|
testCase3.close();
|
||||||
|
REQUIRE( testCase3.isSuccessfullyCompleted() );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
SECTION( "open a nested section", "" ) {
|
||||||
|
ITracker& s2 = SectionTracker::acquire( ctx, "S2" );
|
||||||
|
REQUIRE( s2.isOpen() );
|
||||||
|
|
||||||
|
s2.close();
|
||||||
|
REQUIRE( s2.isComplete() );
|
||||||
|
REQUIRE( s1.isComplete() == false );
|
||||||
|
|
||||||
|
s1.close();
|
||||||
|
REQUIRE( s1.isComplete() );
|
||||||
|
REQUIRE( testCase.isComplete() == false );
|
||||||
|
|
||||||
|
testCase.close();
|
||||||
|
REQUIRE( testCase.isComplete() );
|
||||||
|
}
|
||||||
|
|
||||||
|
SECTION( "start a generator", "" ) {
|
||||||
|
IndexTracker& g1 = IndexTracker::acquire( ctx, "G1", 2 );
|
||||||
|
REQUIRE( g1.isOpen() );
|
||||||
|
REQUIRE( g1.index() == 0 );
|
||||||
|
|
||||||
|
REQUIRE( g1.isComplete() == false );
|
||||||
|
REQUIRE( s1.isComplete() == false );
|
||||||
|
|
||||||
|
SECTION( "close outer section" )
|
||||||
|
{
|
||||||
|
s1.close();
|
||||||
|
REQUIRE( s1.isComplete() == false );
|
||||||
|
testCase.close();
|
||||||
|
REQUIRE( testCase.isSuccessfullyCompleted() == false );
|
||||||
|
|
||||||
|
SECTION( "Re-enter for second generation", "" ) {
|
||||||
|
ctx.startCycle();
|
||||||
|
ITracker& testCase2 = SectionTracker::acquire( ctx, "Testcase" );
|
||||||
|
REQUIRE( testCase2.isOpen() );
|
||||||
|
|
||||||
|
ITracker& s1b = SectionTracker::acquire( ctx, "S1" );
|
||||||
|
REQUIRE( s1b.isOpen() );
|
||||||
|
|
||||||
|
|
||||||
|
IndexTracker& g1b = IndexTracker::acquire( ctx, "G1", 2 );
|
||||||
|
REQUIRE( g1b.isOpen() );
|
||||||
|
REQUIRE( g1b.index() == 1 );
|
||||||
|
|
||||||
|
REQUIRE( s1.isComplete() == false );
|
||||||
|
|
||||||
|
s1b.close();
|
||||||
|
REQUIRE( s1b.isComplete() );
|
||||||
|
REQUIRE( g1b.isComplete() );
|
||||||
|
testCase2.close();
|
||||||
|
REQUIRE( testCase2.isComplete() );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
SECTION( "Start a new inner section", "" ) {
|
||||||
|
ITracker& s2 = SectionTracker::acquire( ctx, "S2" );
|
||||||
|
REQUIRE( s2.isOpen() );
|
||||||
|
|
||||||
|
s2.close();
|
||||||
|
REQUIRE( s2.isComplete() );
|
||||||
|
|
||||||
|
s1.close();
|
||||||
|
REQUIRE( s1.isComplete() == false );
|
||||||
|
|
||||||
|
testCase.close();
|
||||||
|
REQUIRE( testCase.isComplete() == false );
|
||||||
|
|
||||||
|
SECTION( "Re-enter for second generation", "" ) {
|
||||||
|
ctx.startCycle();
|
||||||
|
ITracker& testCase2 = SectionTracker::acquire( ctx, "Testcase" );
|
||||||
|
REQUIRE( testCase2.isOpen() );
|
||||||
|
|
||||||
|
ITracker& s1b = SectionTracker::acquire( ctx, "S1" );
|
||||||
|
REQUIRE( s1b.isOpen() );
|
||||||
|
|
||||||
|
// generator - next value
|
||||||
|
IndexTracker& g1b = IndexTracker::acquire( ctx, "G1", 2 );
|
||||||
|
REQUIRE( g1b.isOpen() );
|
||||||
|
REQUIRE( g1b.index() == 1 );
|
||||||
|
|
||||||
|
// inner section again
|
||||||
|
ITracker& s2b = SectionTracker::acquire( ctx, "S2" );
|
||||||
|
REQUIRE( s2b.isOpen() );
|
||||||
|
|
||||||
|
s2b.close();
|
||||||
|
REQUIRE( s2b.isComplete() );
|
||||||
|
|
||||||
|
s1b.close();
|
||||||
|
REQUIRE( g1b.isComplete() );
|
||||||
|
REQUIRE( s1b.isComplete() );
|
||||||
|
|
||||||
|
testCase2.close();
|
||||||
|
REQUIRE( testCase2.isComplete() );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
SECTION( "Fail an inner section", "" ) {
|
||||||
|
ITracker& s2 = SectionTracker::acquire( ctx, "S2" );
|
||||||
|
REQUIRE( s2.isOpen() );
|
||||||
|
|
||||||
|
s2.fail();
|
||||||
|
REQUIRE( s2.isComplete() );
|
||||||
|
REQUIRE( s2.isSuccessfullyCompleted() == false );
|
||||||
|
|
||||||
|
s1.close();
|
||||||
|
REQUIRE( s1.isComplete() == false );
|
||||||
|
|
||||||
|
testCase.close();
|
||||||
|
REQUIRE( testCase.isComplete() == false );
|
||||||
|
|
||||||
|
SECTION( "Re-enter for second generation", "" ) {
|
||||||
|
ctx.startCycle();
|
||||||
|
ITracker& testCase2 = SectionTracker::acquire( ctx, "Testcase" );
|
||||||
|
REQUIRE( testCase2.isOpen() );
|
||||||
|
|
||||||
|
ITracker& s1b = SectionTracker::acquire( ctx, "S1" );
|
||||||
|
REQUIRE( s1b.isOpen() );
|
||||||
|
|
||||||
|
// generator - still same value
|
||||||
|
IndexTracker& g1b = IndexTracker::acquire( ctx, "G1", 2 );
|
||||||
|
REQUIRE( g1b.isOpen() );
|
||||||
|
REQUIRE( g1b.index() == 0 );
|
||||||
|
|
||||||
|
// inner section again - this time won't open
|
||||||
|
ITracker& s2b = SectionTracker::acquire( ctx, "S2" );
|
||||||
|
REQUIRE( s2b.isOpen() == false );
|
||||||
|
|
||||||
|
s1b.close();
|
||||||
|
REQUIRE( g1b.isComplete() == false );
|
||||||
|
REQUIRE( s1b.isComplete() == false );
|
||||||
|
|
||||||
|
testCase2.close();
|
||||||
|
REQUIRE( testCase2.isComplete() == false );
|
||||||
|
|
||||||
|
// Another cycle - now should complete
|
||||||
|
ctx.startCycle();
|
||||||
|
ITracker& testCase3 = SectionTracker::acquire( ctx, "Testcase" );
|
||||||
|
REQUIRE( testCase3.isOpen() );
|
||||||
|
|
||||||
|
ITracker& s1c = SectionTracker::acquire( ctx, "S1" );
|
||||||
|
REQUIRE( s1c.isOpen() );
|
||||||
|
|
||||||
|
// generator - now next value
|
||||||
|
IndexTracker& g1c = IndexTracker::acquire( ctx, "G1", 2 );
|
||||||
|
REQUIRE( g1c.isOpen() );
|
||||||
|
REQUIRE( g1c.index() == 1 );
|
||||||
|
|
||||||
|
// inner section - now should open again
|
||||||
|
ITracker& s2c = SectionTracker::acquire( ctx, "S2" );
|
||||||
|
REQUIRE( s2c.isOpen() );
|
||||||
|
|
||||||
|
s2c.close();
|
||||||
|
REQUIRE( s2c.isComplete() );
|
||||||
|
|
||||||
|
s1c.close();
|
||||||
|
REQUIRE( g1c.isComplete() );
|
||||||
|
REQUIRE( s1c.isComplete() );
|
||||||
|
|
||||||
|
testCase3.close();
|
||||||
|
REQUIRE( testCase3.isComplete() );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// !TBD"
|
||||||
|
// nested generator
|
||||||
|
// two sections within a generator
|
||||||
|
}
|
||||||
|
}
|
@@ -1,118 +0,0 @@
|
|||||||
/*
|
|
||||||
* Created by Phil on 20/07/2013.
|
|
||||||
* Copyright 2013 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)
|
|
||||||
*/
|
|
||||||
|
|
||||||
#ifdef __clang__
|
|
||||||
# pragma clang diagnostic ignored "-Wpadded"
|
|
||||||
# pragma clang diagnostic ignored "-Wc++98-compat"
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#include "internal/catch_test_case_tracker.hpp"
|
|
||||||
|
|
||||||
#include "catch.hpp"
|
|
||||||
|
|
||||||
TEST_CASE( "section tracking", "" ) {
|
|
||||||
|
|
||||||
using namespace Catch;
|
|
||||||
TestCaseTracker testCaseTracker( "test case" );
|
|
||||||
|
|
||||||
const std::string section1Name = "section 1";
|
|
||||||
const std::string section2Name = "section 2";
|
|
||||||
|
|
||||||
CHECK_FALSE( testCaseTracker.isCompleted() );
|
|
||||||
|
|
||||||
SECTION( "test case with no sections", "" ) {
|
|
||||||
|
|
||||||
{
|
|
||||||
TestCaseTracker::Guard guard( testCaseTracker );
|
|
||||||
CHECK_FALSE( testCaseTracker.isCompleted() );
|
|
||||||
}
|
|
||||||
CHECK( testCaseTracker.isCompleted() );
|
|
||||||
}
|
|
||||||
|
|
||||||
SECTION( "test case with one section", "" ) {
|
|
||||||
|
|
||||||
{
|
|
||||||
TestCaseTracker::Guard guard( testCaseTracker );
|
|
||||||
|
|
||||||
// Enter section? - yes
|
|
||||||
CHECK( testCaseTracker.enterSection( section1Name ) );
|
|
||||||
CHECK_FALSE( testCaseTracker.isCompleted() );
|
|
||||||
testCaseTracker.leaveSection();
|
|
||||||
|
|
||||||
// Leave test case - now complete
|
|
||||||
}
|
|
||||||
CHECK( testCaseTracker.isCompleted() );
|
|
||||||
|
|
||||||
// ...
|
|
||||||
|
|
||||||
// Enter test case again
|
|
||||||
{
|
|
||||||
TestCaseTracker::Guard guard( testCaseTracker );
|
|
||||||
|
|
||||||
// Enter section? - no - now complete
|
|
||||||
CHECK_FALSE( testCaseTracker.enterSection( section1Name ) );
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
SECTION( "test case with two consecutive sections", "" ) {
|
|
||||||
|
|
||||||
// Enter test case
|
|
||||||
{
|
|
||||||
TestCaseTracker::Guard guard( testCaseTracker );
|
|
||||||
|
|
||||||
// Enter section 1? - yes
|
|
||||||
CHECK( testCaseTracker.enterSection( section1Name ) );
|
|
||||||
testCaseTracker.leaveSection();
|
|
||||||
|
|
||||||
// Enter section 2? - no - we just exected section 1
|
|
||||||
CHECK_FALSE( testCaseTracker.enterSection( section2Name ) );
|
|
||||||
|
|
||||||
// Leave test case - incomplete (still need to visit section 2)
|
|
||||||
}
|
|
||||||
CHECK_FALSE( testCaseTracker.isCompleted() );
|
|
||||||
|
|
||||||
// ...
|
|
||||||
|
|
||||||
// Enter test case again
|
|
||||||
{
|
|
||||||
TestCaseTracker::Guard guard( testCaseTracker );
|
|
||||||
|
|
||||||
// Enter section 1? - no, already done now
|
|
||||||
CHECK_FALSE( testCaseTracker.enterSection( section1Name ) );
|
|
||||||
|
|
||||||
// Enter section 2? - yes
|
|
||||||
CHECK( testCaseTracker.enterSection( section2Name ) );
|
|
||||||
testCaseTracker.leaveSection();
|
|
||||||
|
|
||||||
// Leave test case - now complete
|
|
||||||
}
|
|
||||||
CHECK( testCaseTracker.isCompleted() );
|
|
||||||
}
|
|
||||||
|
|
||||||
SECTION( "test case with one section within another", "" ) {
|
|
||||||
|
|
||||||
// Enter test case again
|
|
||||||
{
|
|
||||||
TestCaseTracker::Guard guard( testCaseTracker );
|
|
||||||
|
|
||||||
// Enter section 1? - yes
|
|
||||||
CHECK( testCaseTracker.enterSection( section1Name ) );
|
|
||||||
|
|
||||||
// Enter section 2? - yes
|
|
||||||
CHECK( testCaseTracker.enterSection( section2Name ) );
|
|
||||||
|
|
||||||
CHECK_FALSE( testCaseTracker.isCompleted() );
|
|
||||||
|
|
||||||
testCaseTracker.leaveSection(); // section 2
|
|
||||||
testCaseTracker.leaveSection(); // section 1
|
|
||||||
|
|
||||||
// Leave test case - now complete
|
|
||||||
}
|
|
||||||
CHECK( testCaseTracker.isCompleted() );
|
|
||||||
}
|
|
||||||
}
|
|
@@ -1 +1,2 @@
|
|||||||
|
#include "catch_suppress_warnings.h"
|
||||||
#include "catch_interfaces_exception.h"
|
#include "catch_interfaces_exception.h"
|
||||||
|
@@ -1 +0,0 @@
|
|||||||
#include "catch_interfaces_generators.h"
|
|
||||||
|
@@ -1,2 +1,3 @@
|
|||||||
// This file is only here to verify (to the extent possible) the self sufficiency of the header
|
// This file is only here to verify (to the extent possible) the self sufficiency of the header
|
||||||
|
#include "catch_suppress_warnings.h"
|
||||||
#include "catch_interfaces_registry_hub.h"
|
#include "catch_interfaces_registry_hub.h"
|
||||||
|
@@ -1 +0,0 @@
|
|||||||
#include "catch_interfaces_runner.h"
|
|
@@ -1,2 +1,3 @@
|
|||||||
// This file is only here to verify (to the extent possible) the self sufficiency of the header
|
// This file is only here to verify (to the extent possible) the self sufficiency of the header
|
||||||
|
#include "catch_suppress_warnings.h"
|
||||||
#include "catch_stream.h"
|
#include "catch_stream.h"
|
||||||
|
@@ -11,6 +11,8 @@
|
|||||||
|
|
||||||
TEST_CASE( "Tag alias can be registered against tag patterns", "" ) {
|
TEST_CASE( "Tag alias can be registered against tag patterns", "" ) {
|
||||||
|
|
||||||
|
using namespace Catch::Matchers;
|
||||||
|
|
||||||
Catch::TagAliasRegistry registry;
|
Catch::TagAliasRegistry registry;
|
||||||
|
|
||||||
registry.add( "[@zzz]", "[one][two]", Catch::SourceLineInfo( "file", 2 ) );
|
registry.add( "[@zzz]", "[one][two]", Catch::SourceLineInfo( "file", 2 ) );
|
||||||
|
@@ -8,7 +8,7 @@
|
|||||||
|
|
||||||
#define CATCH_CONFIG_MAIN
|
#define CATCH_CONFIG_MAIN
|
||||||
#include "catch.hpp"
|
#include "catch.hpp"
|
||||||
#include "reporters/catch_reporter_teamcity.hpp"
|
#include "../include/reporters/catch_reporter_teamcity.hpp"
|
||||||
|
|
||||||
// Some example tag aliases
|
// Some example tag aliases
|
||||||
CATCH_REGISTER_TAG_ALIAS( "[@nhf]", "[failing]~[.]" )
|
CATCH_REGISTER_TAG_ALIAS( "[@nhf]", "[failing]~[.]" )
|
||||||
@@ -44,6 +44,8 @@ inline Catch::TestCase fakeTestCase( const char* name, const char* desc = "" ){
|
|||||||
|
|
||||||
TEST_CASE( "Process can be configured on command line", "[config][command-line]" ) {
|
TEST_CASE( "Process can be configured on command line", "[config][command-line]" ) {
|
||||||
|
|
||||||
|
using namespace Catch::Matchers;
|
||||||
|
|
||||||
Catch::ConfigData config;
|
Catch::ConfigData config;
|
||||||
|
|
||||||
SECTION( "default - no arguments", "" ) {
|
SECTION( "default - no arguments", "" ) {
|
||||||
@@ -53,7 +55,7 @@ TEST_CASE( "Process can be configured on command line", "[config][command-line]"
|
|||||||
CHECK( config.shouldDebugBreak == false );
|
CHECK( config.shouldDebugBreak == false );
|
||||||
CHECK( config.abortAfter == -1 );
|
CHECK( config.abortAfter == -1 );
|
||||||
CHECK( config.noThrow == false );
|
CHECK( config.noThrow == false );
|
||||||
CHECK( config.reporterName.empty() );
|
CHECK( config.reporterNames.empty() );
|
||||||
}
|
}
|
||||||
|
|
||||||
SECTION( "test lists", "" ) {
|
SECTION( "test lists", "" ) {
|
||||||
@@ -90,19 +92,27 @@ TEST_CASE( "Process can be configured on command line", "[config][command-line]"
|
|||||||
const char* argv[] = { "test", "-r", "console" };
|
const char* argv[] = { "test", "-r", "console" };
|
||||||
CHECK_NOTHROW( parseIntoConfig( argv, config ) );
|
CHECK_NOTHROW( parseIntoConfig( argv, config ) );
|
||||||
|
|
||||||
REQUIRE( config.reporterName == "console" );
|
REQUIRE( config.reporterNames[0] == "console" );
|
||||||
}
|
}
|
||||||
SECTION( "-r/xml", "" ) {
|
SECTION( "-r/xml", "" ) {
|
||||||
const char* argv[] = { "test", "-r", "xml" };
|
const char* argv[] = { "test", "-r", "xml" };
|
||||||
CHECK_NOTHROW( parseIntoConfig( argv, config ) );
|
CHECK_NOTHROW( parseIntoConfig( argv, config ) );
|
||||||
|
|
||||||
REQUIRE( config.reporterName == "xml" );
|
REQUIRE( config.reporterNames[0] == "xml" );
|
||||||
|
}
|
||||||
|
SECTION( "-r xml and junit", "" ) {
|
||||||
|
const char* argv[] = { "test", "-r", "xml", "-r", "junit" };
|
||||||
|
CHECK_NOTHROW( parseIntoConfig( argv, config ) );
|
||||||
|
|
||||||
|
REQUIRE( config.reporterNames.size() == 2 );
|
||||||
|
REQUIRE( config.reporterNames[0] == "xml" );
|
||||||
|
REQUIRE( config.reporterNames[1] == "junit" );
|
||||||
}
|
}
|
||||||
SECTION( "--reporter/junit", "" ) {
|
SECTION( "--reporter/junit", "" ) {
|
||||||
const char* argv[] = { "test", "--reporter", "junit" };
|
const char* argv[] = { "test", "--reporter", "junit" };
|
||||||
CHECK_NOTHROW( parseIntoConfig( argv, config ) );
|
CHECK_NOTHROW( parseIntoConfig( argv, config ) );
|
||||||
|
|
||||||
REQUIRE( config.reporterName == "junit" );
|
REQUIRE( config.reporterNames[0] == "junit" );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -439,3 +449,13 @@ TEST_CASE( "Long text is truncted", "[Text][Truncated]" ) {
|
|||||||
CHECK_THAT( t.toString(), EndsWith( "... message truncated due to excessive size" ) );
|
CHECK_THAT( t.toString(), EndsWith( "... message truncated due to excessive size" ) );
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
inline void manuallyRegisteredTestFunction() {
|
||||||
|
SUCCEED( "was called" );
|
||||||
|
}
|
||||||
|
struct AutoTestReg {
|
||||||
|
AutoTestReg() {
|
||||||
|
REGISTER_TEST_CASE( manuallyRegisteredTestFunction, "ManuallyRegistered", "" );
|
||||||
|
}
|
||||||
|
};
|
||||||
|
AutoTestReg autoTestReg;
|
||||||
|
@@ -7,6 +7,7 @@
|
|||||||
objects = {
|
objects = {
|
||||||
|
|
||||||
/* Begin PBXBuildFile section */
|
/* Begin PBXBuildFile section */
|
||||||
|
26059AF21BD4B94C003D575C /* PartTrackerTests.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 26059AF11BD4B94C003D575C /* PartTrackerTests.cpp */; };
|
||||||
263F7A4719B6FCBF009474C2 /* EnumToString.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 263F7A4619B6FCBF009474C2 /* EnumToString.cpp */; };
|
263F7A4719B6FCBF009474C2 /* EnumToString.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 263F7A4619B6FCBF009474C2 /* EnumToString.cpp */; };
|
||||||
263F7A4B19B6FE1E009474C2 /* ToStringPair.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 263F7A4819B6FE1E009474C2 /* ToStringPair.cpp */; };
|
263F7A4B19B6FE1E009474C2 /* ToStringPair.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 263F7A4819B6FE1E009474C2 /* ToStringPair.cpp */; };
|
||||||
263F7A4C19B6FE1E009474C2 /* ToStringVector.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 263F7A4919B6FE1E009474C2 /* ToStringVector.cpp */; };
|
263F7A4C19B6FE1E009474C2 /* ToStringVector.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 263F7A4919B6FE1E009474C2 /* ToStringVector.cpp */; };
|
||||||
@@ -17,7 +18,6 @@
|
|||||||
26711C8F195D465C0033EDA2 /* TagAliasTests.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 26711C8D195D465C0033EDA2 /* TagAliasTests.cpp */; };
|
26711C8F195D465C0033EDA2 /* TagAliasTests.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 26711C8D195D465C0033EDA2 /* TagAliasTests.cpp */; };
|
||||||
26847E5F16BBADB40043B9C1 /* catch_message.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 26847E5D16BBADB40043B9C1 /* catch_message.cpp */; };
|
26847E5F16BBADB40043B9C1 /* catch_message.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 26847E5D16BBADB40043B9C1 /* catch_message.cpp */; };
|
||||||
2691574C1A532A280054F1ED /* ToStringTuple.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 2691574B1A532A280054F1ED /* ToStringTuple.cpp */; };
|
2691574C1A532A280054F1ED /* ToStringTuple.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 2691574B1A532A280054F1ED /* ToStringTuple.cpp */; };
|
||||||
26948286179A9AB900ED166E /* SectionTrackerTests.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 26948284179A9AB900ED166E /* SectionTrackerTests.cpp */; };
|
|
||||||
2694A1FD16A0000E004816E3 /* catch_text.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 2694A1FB16A0000E004816E3 /* catch_text.cpp */; };
|
2694A1FD16A0000E004816E3 /* catch_text.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 2694A1FB16A0000E004816E3 /* catch_text.cpp */; };
|
||||||
26E1B7D319213BC900812682 /* CmdLineTests.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 26E1B7D119213BC900812682 /* CmdLineTests.cpp */; };
|
26E1B7D319213BC900812682 /* CmdLineTests.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 26E1B7D119213BC900812682 /* CmdLineTests.cpp */; };
|
||||||
4A45DA2416161EF9004F8D6B /* catch_console_colour.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4A45DA2316161EF9004F8D6B /* catch_console_colour.cpp */; };
|
4A45DA2416161EF9004F8D6B /* catch_console_colour.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4A45DA2316161EF9004F8D6B /* catch_console_colour.cpp */; };
|
||||||
@@ -27,7 +27,6 @@
|
|||||||
4A45DA2D16161FA2004F8D6B /* catch_interfaces_capture.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4A45DA2C16161FA2004F8D6B /* catch_interfaces_capture.cpp */; };
|
4A45DA2D16161FA2004F8D6B /* catch_interfaces_capture.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4A45DA2C16161FA2004F8D6B /* catch_interfaces_capture.cpp */; };
|
||||||
4A45DA3116161FFC004F8D6B /* catch_interfaces_reporter.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4A45DA3016161FFB004F8D6B /* catch_interfaces_reporter.cpp */; };
|
4A45DA3116161FFC004F8D6B /* catch_interfaces_reporter.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4A45DA3016161FFB004F8D6B /* catch_interfaces_reporter.cpp */; };
|
||||||
4A45DA3316162047004F8D6B /* catch_interfaces_exception.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4A45DA3216162047004F8D6B /* catch_interfaces_exception.cpp */; };
|
4A45DA3316162047004F8D6B /* catch_interfaces_exception.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4A45DA3216162047004F8D6B /* catch_interfaces_exception.cpp */; };
|
||||||
4A45DA3516162071004F8D6B /* catch_interfaces_runner.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4A45DA3416162071004F8D6B /* catch_interfaces_runner.cpp */; };
|
|
||||||
4A6D0C27149B3D3B00DB3EAA /* CatchSelfTest.1 in CopyFiles */ = {isa = PBXBuildFile; fileRef = 4A6D0C26149B3D3B00DB3EAA /* CatchSelfTest.1 */; };
|
4A6D0C27149B3D3B00DB3EAA /* CatchSelfTest.1 in CopyFiles */ = {isa = PBXBuildFile; fileRef = 4A6D0C26149B3D3B00DB3EAA /* CatchSelfTest.1 */; };
|
||||||
4A6D0C37149B3D9E00DB3EAA /* ApproxTests.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4A6D0C2D149B3D9E00DB3EAA /* ApproxTests.cpp */; };
|
4A6D0C37149B3D9E00DB3EAA /* ApproxTests.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4A6D0C2D149B3D9E00DB3EAA /* ApproxTests.cpp */; };
|
||||||
4A6D0C38149B3D9E00DB3EAA /* ClassTests.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4A6D0C2F149B3D9E00DB3EAA /* ClassTests.cpp */; };
|
4A6D0C38149B3D9E00DB3EAA /* ClassTests.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4A6D0C2F149B3D9E00DB3EAA /* ClassTests.cpp */; };
|
||||||
@@ -62,6 +61,7 @@
|
|||||||
/* End PBXCopyFilesBuildPhase section */
|
/* End PBXCopyFilesBuildPhase section */
|
||||||
|
|
||||||
/* Begin PBXFileReference section */
|
/* Begin PBXFileReference section */
|
||||||
|
26059AF11BD4B94C003D575C /* PartTrackerTests.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = PartTrackerTests.cpp; path = ../../../SelfTest/PartTrackerTests.cpp; sourceTree = "<group>"; };
|
||||||
261488FA184C81130041FBEB /* catch_test_spec.hpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.h; path = catch_test_spec.hpp; sourceTree = "<group>"; };
|
261488FA184C81130041FBEB /* catch_test_spec.hpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.h; path = catch_test_spec.hpp; sourceTree = "<group>"; };
|
||||||
261488FC184D1DC10041FBEB /* catch_stream.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = catch_stream.h; sourceTree = "<group>"; };
|
261488FC184D1DC10041FBEB /* catch_stream.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = catch_stream.h; sourceTree = "<group>"; };
|
||||||
261488FD184D21290041FBEB /* catch_section_info.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = catch_section_info.h; sourceTree = "<group>"; };
|
261488FD184D21290041FBEB /* catch_section_info.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = catch_section_info.h; sourceTree = "<group>"; };
|
||||||
@@ -100,7 +100,6 @@
|
|||||||
2691574B1A532A280054F1ED /* ToStringTuple.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = ToStringTuple.cpp; path = ../../../SelfTest/ToStringTuple.cpp; sourceTree = "<group>"; };
|
2691574B1A532A280054F1ED /* ToStringTuple.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = ToStringTuple.cpp; path = ../../../SelfTest/ToStringTuple.cpp; sourceTree = "<group>"; };
|
||||||
26926E8318D7777D004E10F2 /* clara.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = clara.h; path = ../../../../include/external/clara.h; sourceTree = "<group>"; };
|
26926E8318D7777D004E10F2 /* clara.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = clara.h; path = ../../../../include/external/clara.h; sourceTree = "<group>"; };
|
||||||
26926E8418D77809004E10F2 /* tbc_text_format.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = tbc_text_format.h; path = ../../../../include/external/tbc_text_format.h; sourceTree = "<group>"; };
|
26926E8418D77809004E10F2 /* tbc_text_format.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = tbc_text_format.h; path = ../../../../include/external/tbc_text_format.h; sourceTree = "<group>"; };
|
||||||
26948284179A9AB900ED166E /* SectionTrackerTests.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = SectionTrackerTests.cpp; path = ../../../SelfTest/SectionTrackerTests.cpp; sourceTree = "<group>"; };
|
|
||||||
26948287179EF7F900ED166E /* catch_test_case_tracker.hpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.h; path = catch_test_case_tracker.hpp; sourceTree = "<group>"; };
|
26948287179EF7F900ED166E /* catch_test_case_tracker.hpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.h; path = catch_test_case_tracker.hpp; sourceTree = "<group>"; };
|
||||||
2694A1FB16A0000E004816E3 /* catch_text.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = catch_text.cpp; sourceTree = "<group>"; };
|
2694A1FB16A0000E004816E3 /* catch_text.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = catch_text.cpp; sourceTree = "<group>"; };
|
||||||
269831E519078C1600BB0CE0 /* catch_tostring.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = catch_tostring.h; sourceTree = "<group>"; };
|
269831E519078C1600BB0CE0 /* catch_tostring.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = catch_tostring.h; sourceTree = "<group>"; };
|
||||||
@@ -110,6 +109,7 @@
|
|||||||
26DACF2F17206D3400A21326 /* catch_text.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = catch_text.h; sourceTree = "<group>"; };
|
26DACF2F17206D3400A21326 /* catch_text.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = catch_text.h; sourceTree = "<group>"; };
|
||||||
26DFD3B11B53F84700FD6F16 /* catch_wildcard_pattern.hpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.h; path = catch_wildcard_pattern.hpp; sourceTree = "<group>"; };
|
26DFD3B11B53F84700FD6F16 /* catch_wildcard_pattern.hpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.h; path = catch_wildcard_pattern.hpp; sourceTree = "<group>"; };
|
||||||
26E1B7D119213BC900812682 /* CmdLineTests.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = CmdLineTests.cpp; path = ../../../SelfTest/CmdLineTests.cpp; sourceTree = "<group>"; };
|
26E1B7D119213BC900812682 /* CmdLineTests.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = CmdLineTests.cpp; path = ../../../SelfTest/CmdLineTests.cpp; sourceTree = "<group>"; };
|
||||||
|
26EDFBD91B72011F00B1873C /* catch_reporter_multi.hpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.h; path = catch_reporter_multi.hpp; sourceTree = "<group>"; };
|
||||||
4A084F1C15DACEEA0027E631 /* catch_test_case_info.hpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.h; path = catch_test_case_info.hpp; sourceTree = "<group>"; };
|
4A084F1C15DACEEA0027E631 /* catch_test_case_info.hpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.h; path = catch_test_case_info.hpp; sourceTree = "<group>"; };
|
||||||
4A3D7DD01503869D005F9203 /* catch_matchers.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = catch_matchers.hpp; sourceTree = "<group>"; };
|
4A3D7DD01503869D005F9203 /* catch_matchers.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = catch_matchers.hpp; sourceTree = "<group>"; };
|
||||||
4A45DA2316161EF9004F8D6B /* catch_console_colour.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = catch_console_colour.cpp; path = ../../../SelfTest/SurrogateCpps/catch_console_colour.cpp; sourceTree = "<group>"; };
|
4A45DA2316161EF9004F8D6B /* catch_console_colour.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = catch_console_colour.cpp; path = ../../../SelfTest/SurrogateCpps/catch_console_colour.cpp; sourceTree = "<group>"; };
|
||||||
@@ -119,7 +119,6 @@
|
|||||||
4A45DA2C16161FA2004F8D6B /* catch_interfaces_capture.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = catch_interfaces_capture.cpp; path = ../../../SelfTest/SurrogateCpps/catch_interfaces_capture.cpp; sourceTree = "<group>"; };
|
4A45DA2C16161FA2004F8D6B /* catch_interfaces_capture.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = catch_interfaces_capture.cpp; path = ../../../SelfTest/SurrogateCpps/catch_interfaces_capture.cpp; sourceTree = "<group>"; };
|
||||||
4A45DA3016161FFB004F8D6B /* catch_interfaces_reporter.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = catch_interfaces_reporter.cpp; path = ../../../SelfTest/SurrogateCpps/catch_interfaces_reporter.cpp; sourceTree = "<group>"; };
|
4A45DA3016161FFB004F8D6B /* catch_interfaces_reporter.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = catch_interfaces_reporter.cpp; path = ../../../SelfTest/SurrogateCpps/catch_interfaces_reporter.cpp; sourceTree = "<group>"; };
|
||||||
4A45DA3216162047004F8D6B /* catch_interfaces_exception.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = catch_interfaces_exception.cpp; path = ../../../SelfTest/SurrogateCpps/catch_interfaces_exception.cpp; sourceTree = "<group>"; };
|
4A45DA3216162047004F8D6B /* catch_interfaces_exception.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = catch_interfaces_exception.cpp; path = ../../../SelfTest/SurrogateCpps/catch_interfaces_exception.cpp; sourceTree = "<group>"; };
|
||||||
4A45DA3416162071004F8D6B /* catch_interfaces_runner.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = catch_interfaces_runner.cpp; path = ../../../SelfTest/SurrogateCpps/catch_interfaces_runner.cpp; sourceTree = "<group>"; };
|
|
||||||
4A4B0F9715CE6CFB00AE2392 /* catch_registry_hub.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; lineEnding = 0; path = catch_registry_hub.hpp; sourceTree = "<group>"; xcLanguageSpecificationIdentifier = xcode.lang.cpp; };
|
4A4B0F9715CE6CFB00AE2392 /* catch_registry_hub.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; lineEnding = 0; path = catch_registry_hub.hpp; sourceTree = "<group>"; xcLanguageSpecificationIdentifier = xcode.lang.cpp; };
|
||||||
4A4B0F9915CE6EC100AE2392 /* catch_interfaces_registry_hub.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; lineEnding = 0; path = catch_interfaces_registry_hub.h; sourceTree = "<group>"; xcLanguageSpecificationIdentifier = xcode.lang.objcpp; };
|
4A4B0F9915CE6EC100AE2392 /* catch_interfaces_registry_hub.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; lineEnding = 0; path = catch_interfaces_registry_hub.h; sourceTree = "<group>"; xcLanguageSpecificationIdentifier = xcode.lang.objcpp; };
|
||||||
4A4B0F9A15CEF84800AE2392 /* catch_notimplemented_exception.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = catch_notimplemented_exception.h; sourceTree = "<group>"; };
|
4A4B0F9A15CEF84800AE2392 /* catch_notimplemented_exception.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = catch_notimplemented_exception.h; sourceTree = "<group>"; };
|
||||||
@@ -136,7 +135,7 @@
|
|||||||
4A6D0C34149B3D9E00DB3EAA /* MiscTests.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = MiscTests.cpp; path = ../../../SelfTest/MiscTests.cpp; sourceTree = "<group>"; };
|
4A6D0C34149B3D9E00DB3EAA /* MiscTests.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = MiscTests.cpp; path = ../../../SelfTest/MiscTests.cpp; sourceTree = "<group>"; };
|
||||||
4A6D0C35149B3D9E00DB3EAA /* TestMain.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = TestMain.cpp; path = ../../../SelfTest/TestMain.cpp; sourceTree = "<group>"; };
|
4A6D0C35149B3D9E00DB3EAA /* TestMain.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = TestMain.cpp; path = ../../../SelfTest/TestMain.cpp; sourceTree = "<group>"; };
|
||||||
4A6D0C36149B3D9E00DB3EAA /* TrickyTests.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = TrickyTests.cpp; path = ../../../SelfTest/TrickyTests.cpp; sourceTree = "<group>"; };
|
4A6D0C36149B3D9E00DB3EAA /* TrickyTests.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = TrickyTests.cpp; path = ../../../SelfTest/TrickyTests.cpp; sourceTree = "<group>"; };
|
||||||
4A6D0C42149B3E1500DB3EAA /* catch_runner.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; lineEnding = 0; name = catch_runner.hpp; path = ../../../../include/catch_runner.hpp; sourceTree = "<group>"; xcLanguageSpecificationIdentifier = xcode.lang.cpp; };
|
4A6D0C42149B3E1500DB3EAA /* catch_session.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; lineEnding = 0; name = catch_session.hpp; path = ../../../../include/catch_session.hpp; sourceTree = "<group>"; xcLanguageSpecificationIdentifier = xcode.lang.cpp; };
|
||||||
4A6D0C43149B3E1500DB3EAA /* catch_with_main.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; name = catch_with_main.hpp; path = ../../../../include/catch_with_main.hpp; sourceTree = "<group>"; };
|
4A6D0C43149B3E1500DB3EAA /* catch_with_main.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; name = catch_with_main.hpp; path = ../../../../include/catch_with_main.hpp; sourceTree = "<group>"; };
|
||||||
4A6D0C44149B3E1500DB3EAA /* catch.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; name = catch.hpp; path = ../../../../include/catch.hpp; sourceTree = "<group>"; };
|
4A6D0C44149B3E1500DB3EAA /* catch.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; name = catch.hpp; path = ../../../../include/catch.hpp; sourceTree = "<group>"; };
|
||||||
4A6D0C46149B3E3D00DB3EAA /* catch_approx.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = catch_approx.hpp; sourceTree = "<group>"; };
|
4A6D0C46149B3E3D00DB3EAA /* catch_approx.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = catch_approx.hpp; sourceTree = "<group>"; };
|
||||||
@@ -148,14 +147,9 @@
|
|||||||
4A6D0C4C149B3E3D00DB3EAA /* catch_default_main.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = catch_default_main.hpp; sourceTree = "<group>"; };
|
4A6D0C4C149B3E3D00DB3EAA /* catch_default_main.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = catch_default_main.hpp; sourceTree = "<group>"; };
|
||||||
4A6D0C4D149B3E3D00DB3EAA /* catch_evaluate.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; lineEnding = 0; path = catch_evaluate.hpp; sourceTree = "<group>"; xcLanguageSpecificationIdentifier = xcode.lang.cpp; };
|
4A6D0C4D149B3E3D00DB3EAA /* catch_evaluate.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; lineEnding = 0; path = catch_evaluate.hpp; sourceTree = "<group>"; xcLanguageSpecificationIdentifier = xcode.lang.cpp; };
|
||||||
4A6D0C4E149B3E3D00DB3EAA /* catch_exception_translator_registry.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = catch_exception_translator_registry.hpp; sourceTree = "<group>"; };
|
4A6D0C4E149B3E3D00DB3EAA /* catch_exception_translator_registry.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = catch_exception_translator_registry.hpp; sourceTree = "<group>"; };
|
||||||
4A6D0C4F149B3E3D00DB3EAA /* catch_generators.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = catch_generators.hpp; sourceTree = "<group>"; };
|
|
||||||
4A6D0C50149B3E3D00DB3EAA /* catch_generators_impl.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = catch_generators_impl.hpp; sourceTree = "<group>"; };
|
|
||||||
4A6D0C51149B3E3D00DB3EAA /* catch_context.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = catch_context.h; sourceTree = "<group>"; };
|
|
||||||
4A6D0C52149B3E3D00DB3EAA /* catch_context_impl.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = catch_context_impl.hpp; sourceTree = "<group>"; };
|
|
||||||
4A6D0C53149B3E3D00DB3EAA /* catch_interfaces_capture.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = catch_interfaces_capture.h; sourceTree = "<group>"; };
|
4A6D0C53149B3E3D00DB3EAA /* catch_interfaces_capture.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = catch_interfaces_capture.h; sourceTree = "<group>"; };
|
||||||
4A6D0C54149B3E3D00DB3EAA /* catch_interfaces_exception.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; lineEnding = 0; path = catch_interfaces_exception.h; sourceTree = "<group>"; xcLanguageSpecificationIdentifier = xcode.lang.objcpp; };
|
4A6D0C54149B3E3D00DB3EAA /* catch_interfaces_exception.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; lineEnding = 0; path = catch_interfaces_exception.h; sourceTree = "<group>"; xcLanguageSpecificationIdentifier = xcode.lang.objcpp; };
|
||||||
4A6D0C55149B3E3D00DB3EAA /* catch_interfaces_reporter.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = catch_interfaces_reporter.h; sourceTree = "<group>"; };
|
4A6D0C55149B3E3D00DB3EAA /* catch_interfaces_reporter.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = catch_interfaces_reporter.h; sourceTree = "<group>"; };
|
||||||
4A6D0C56149B3E3D00DB3EAA /* catch_interfaces_runner.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = catch_interfaces_runner.h; sourceTree = "<group>"; };
|
|
||||||
4A6D0C57149B3E3D00DB3EAA /* catch_interfaces_testcase.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = catch_interfaces_testcase.h; sourceTree = "<group>"; };
|
4A6D0C57149B3E3D00DB3EAA /* catch_interfaces_testcase.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = catch_interfaces_testcase.h; sourceTree = "<group>"; };
|
||||||
4A6D0C58149B3E3D00DB3EAA /* catch_list.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; lineEnding = 0; path = catch_list.hpp; sourceTree = "<group>"; xcLanguageSpecificationIdentifier = xcode.lang.cpp; };
|
4A6D0C58149B3E3D00DB3EAA /* catch_list.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; lineEnding = 0; path = catch_list.hpp; sourceTree = "<group>"; xcLanguageSpecificationIdentifier = xcode.lang.cpp; };
|
||||||
4A6D0C59149B3E3D00DB3EAA /* catch_objc.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = catch_objc.hpp; sourceTree = "<group>"; };
|
4A6D0C59149B3E3D00DB3EAA /* catch_objc.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = catch_objc.hpp; sourceTree = "<group>"; };
|
||||||
@@ -163,7 +157,7 @@
|
|||||||
4A6D0C5B149B3E3D00DB3EAA /* catch_reporter_registry.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = catch_reporter_registry.hpp; sourceTree = "<group>"; };
|
4A6D0C5B149B3E3D00DB3EAA /* catch_reporter_registry.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = catch_reporter_registry.hpp; sourceTree = "<group>"; };
|
||||||
4A6D0C5C149B3E3D00DB3EAA /* catch_result_type.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = catch_result_type.h; sourceTree = "<group>"; };
|
4A6D0C5C149B3E3D00DB3EAA /* catch_result_type.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = catch_result_type.h; sourceTree = "<group>"; };
|
||||||
4A6D0C5D149B3E3D00DB3EAA /* catch_assertionresult.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; lineEnding = 0; path = catch_assertionresult.h; sourceTree = "<group>"; xcLanguageSpecificationIdentifier = xcode.lang.objcpp; };
|
4A6D0C5D149B3E3D00DB3EAA /* catch_assertionresult.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; lineEnding = 0; path = catch_assertionresult.h; sourceTree = "<group>"; xcLanguageSpecificationIdentifier = xcode.lang.objcpp; };
|
||||||
4A6D0C5E149B3E3D00DB3EAA /* catch_runner_impl.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; lineEnding = 0; path = catch_runner_impl.hpp; sourceTree = "<group>"; xcLanguageSpecificationIdentifier = xcode.lang.cpp; };
|
4A6D0C5E149B3E3D00DB3EAA /* catch_run_context.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; lineEnding = 0; path = catch_run_context.hpp; sourceTree = "<group>"; xcLanguageSpecificationIdentifier = xcode.lang.cpp; };
|
||||||
4A6D0C5F149B3E3D00DB3EAA /* catch_section.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = catch_section.hpp; sourceTree = "<group>"; };
|
4A6D0C5F149B3E3D00DB3EAA /* catch_section.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = catch_section.hpp; sourceTree = "<group>"; };
|
||||||
4A6D0C60149B3E3D00DB3EAA /* catch_stream.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = catch_stream.hpp; sourceTree = "<group>"; };
|
4A6D0C60149B3E3D00DB3EAA /* catch_stream.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = catch_stream.hpp; sourceTree = "<group>"; };
|
||||||
4A6D0C61149B3E3D00DB3EAA /* catch_test_case_info.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = catch_test_case_info.h; sourceTree = "<group>"; };
|
4A6D0C61149B3E3D00DB3EAA /* catch_test_case_info.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = catch_test_case_info.h; sourceTree = "<group>"; };
|
||||||
@@ -174,7 +168,6 @@
|
|||||||
4A6D0C68149B3E3D00DB3EAA /* catch_reporter_xml.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = catch_reporter_xml.hpp; sourceTree = "<group>"; };
|
4A6D0C68149B3E3D00DB3EAA /* catch_reporter_xml.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = catch_reporter_xml.hpp; sourceTree = "<group>"; };
|
||||||
4A7ADB4314F631E10094FE10 /* catch_totals.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = catch_totals.hpp; sourceTree = "<group>"; };
|
4A7ADB4314F631E10094FE10 /* catch_totals.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = catch_totals.hpp; sourceTree = "<group>"; };
|
||||||
4A7DB2CD1652FE4B00FA6523 /* catch_version.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = catch_version.h; path = ../../../../include/internal/catch_version.h; sourceTree = "<group>"; };
|
4A7DB2CD1652FE4B00FA6523 /* catch_version.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = catch_version.h; path = ../../../../include/internal/catch_version.h; sourceTree = "<group>"; };
|
||||||
4A90B59B15D0F61A00EF71BC /* catch_interfaces_generators.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = catch_interfaces_generators.h; sourceTree = "<group>"; };
|
|
||||||
4A90B59D15D24FE900EF71BC /* catch_assertionresult.hpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.h; lineEnding = 0; path = catch_assertionresult.hpp; sourceTree = "<group>"; xcLanguageSpecificationIdentifier = xcode.lang.cpp; };
|
4A90B59D15D24FE900EF71BC /* catch_assertionresult.hpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.h; lineEnding = 0; path = catch_assertionresult.hpp; sourceTree = "<group>"; xcLanguageSpecificationIdentifier = xcode.lang.cpp; };
|
||||||
4AA7B8B4165428BA003155F6 /* catch_version.hpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.h; name = catch_version.hpp; path = ../../../../include/internal/catch_version.hpp; sourceTree = "<group>"; };
|
4AA7B8B4165428BA003155F6 /* catch_version.hpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.h; name = catch_version.hpp; path = ../../../../include/internal/catch_version.hpp; sourceTree = "<group>"; };
|
||||||
4AB1C73514F97BDA00F31DF7 /* catch_console_colour_impl.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; lineEnding = 0; path = catch_console_colour_impl.hpp; sourceTree = "<group>"; xcLanguageSpecificationIdentifier = xcode.lang.cpp; };
|
4AB1C73514F97BDA00F31DF7 /* catch_console_colour_impl.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; lineEnding = 0; path = catch_console_colour_impl.hpp; sourceTree = "<group>"; xcLanguageSpecificationIdentifier = xcode.lang.cpp; };
|
||||||
@@ -211,7 +204,7 @@
|
|||||||
266E9AD317290E710061DAB2 /* Introspective Tests */ = {
|
266E9AD317290E710061DAB2 /* Introspective Tests */ = {
|
||||||
isa = PBXGroup;
|
isa = PBXGroup;
|
||||||
children = (
|
children = (
|
||||||
26948284179A9AB900ED166E /* SectionTrackerTests.cpp */,
|
26059AF11BD4B94C003D575C /* PartTrackerTests.cpp */,
|
||||||
26E1B7D119213BC900812682 /* CmdLineTests.cpp */,
|
26E1B7D119213BC900812682 /* CmdLineTests.cpp */,
|
||||||
26711C8D195D465C0033EDA2 /* TagAliasTests.cpp */,
|
26711C8D195D465C0033EDA2 /* TagAliasTests.cpp */,
|
||||||
);
|
);
|
||||||
@@ -285,7 +278,7 @@
|
|||||||
4AA7B8B4165428BA003155F6 /* catch_version.hpp */,
|
4AA7B8B4165428BA003155F6 /* catch_version.hpp */,
|
||||||
4A8E4DCF160A34E200194CBD /* SurrogateCpps */,
|
4A8E4DCF160A34E200194CBD /* SurrogateCpps */,
|
||||||
4A6D0C44149B3E1500DB3EAA /* catch.hpp */,
|
4A6D0C44149B3E1500DB3EAA /* catch.hpp */,
|
||||||
4A6D0C42149B3E1500DB3EAA /* catch_runner.hpp */,
|
4A6D0C42149B3E1500DB3EAA /* catch_session.hpp */,
|
||||||
4A6D0C43149B3E1500DB3EAA /* catch_with_main.hpp */,
|
4A6D0C43149B3E1500DB3EAA /* catch_with_main.hpp */,
|
||||||
4A6D0C45149B3E3D00DB3EAA /* internal */,
|
4A6D0C45149B3E3D00DB3EAA /* internal */,
|
||||||
4A6D0C65149B3E3D00DB3EAA /* reporters */,
|
4A6D0C65149B3E3D00DB3EAA /* reporters */,
|
||||||
@@ -318,6 +311,7 @@
|
|||||||
4A6D0C68149B3E3D00DB3EAA /* catch_reporter_xml.hpp */,
|
4A6D0C68149B3E3D00DB3EAA /* catch_reporter_xml.hpp */,
|
||||||
4AB42F84166F3E1A0099F2C8 /* catch_reporter_console.hpp */,
|
4AB42F84166F3E1A0099F2C8 /* catch_reporter_console.hpp */,
|
||||||
2691574A1A4480C50054F1ED /* catch_reporter_teamcity.hpp */,
|
2691574A1A4480C50054F1ED /* catch_reporter_teamcity.hpp */,
|
||||||
|
26EDFBD91B72011F00B1873C /* catch_reporter_multi.hpp */,
|
||||||
);
|
);
|
||||||
name = reporters;
|
name = reporters;
|
||||||
path = ../../../../include/reporters;
|
path = ../../../../include/reporters;
|
||||||
@@ -338,7 +332,6 @@
|
|||||||
4A45DA2C16161FA2004F8D6B /* catch_interfaces_capture.cpp */,
|
4A45DA2C16161FA2004F8D6B /* catch_interfaces_capture.cpp */,
|
||||||
4A45DA3216162047004F8D6B /* catch_interfaces_exception.cpp */,
|
4A45DA3216162047004F8D6B /* catch_interfaces_exception.cpp */,
|
||||||
4A45DA3016161FFB004F8D6B /* catch_interfaces_reporter.cpp */,
|
4A45DA3016161FFB004F8D6B /* catch_interfaces_reporter.cpp */,
|
||||||
4A45DA3416162071004F8D6B /* catch_interfaces_runner.cpp */,
|
|
||||||
4AB3D99C1616216500C9A0F8 /* catch_interfaces_testcase.cpp */,
|
4AB3D99C1616216500C9A0F8 /* catch_interfaces_testcase.cpp */,
|
||||||
4AB3D99F1616219100C9A0F8 /* catch_interfaces_config.cpp */,
|
4AB3D99F1616219100C9A0F8 /* catch_interfaces_config.cpp */,
|
||||||
4AB3D9A1161621B500C9A0F8 /* catch_interfaces_generators.cpp */,
|
4AB3D9A1161621B500C9A0F8 /* catch_interfaces_generators.cpp */,
|
||||||
@@ -356,9 +349,7 @@
|
|||||||
263FD06017AF8DF200988A20 /* catch_timer.hpp */,
|
263FD06017AF8DF200988A20 /* catch_timer.hpp */,
|
||||||
4A4B0F9C15CEFA8300AE2392 /* catch_impl.hpp */,
|
4A4B0F9C15CEFA8300AE2392 /* catch_impl.hpp */,
|
||||||
4A4B0F9715CE6CFB00AE2392 /* catch_registry_hub.hpp */,
|
4A4B0F9715CE6CFB00AE2392 /* catch_registry_hub.hpp */,
|
||||||
4A6D0C50149B3E3D00DB3EAA /* catch_generators_impl.hpp */,
|
4A6D0C5E149B3E3D00DB3EAA /* catch_run_context.hpp */,
|
||||||
4A6D0C52149B3E3D00DB3EAA /* catch_context_impl.hpp */,
|
|
||||||
4A6D0C5E149B3E3D00DB3EAA /* catch_runner_impl.hpp */,
|
|
||||||
4A6D0C62149B3E3D00DB3EAA /* catch_test_case_registry_impl.hpp */,
|
4A6D0C62149B3E3D00DB3EAA /* catch_test_case_registry_impl.hpp */,
|
||||||
4AB1C73514F97BDA00F31DF7 /* catch_console_colour_impl.hpp */,
|
4AB1C73514F97BDA00F31DF7 /* catch_console_colour_impl.hpp */,
|
||||||
4A4B0F9B15CEF8C400AE2392 /* catch_notimplemented_exception.hpp */,
|
4A4B0F9B15CEF8C400AE2392 /* catch_notimplemented_exception.hpp */,
|
||||||
@@ -377,7 +368,6 @@
|
|||||||
269831E519078C1600BB0CE0 /* catch_tostring.h */,
|
269831E519078C1600BB0CE0 /* catch_tostring.h */,
|
||||||
269831E619078CA200BB0CE0 /* catch_tostring.hpp */,
|
269831E619078CA200BB0CE0 /* catch_tostring.hpp */,
|
||||||
4A6D0C4D149B3E3D00DB3EAA /* catch_evaluate.hpp */,
|
4A6D0C4D149B3E3D00DB3EAA /* catch_evaluate.hpp */,
|
||||||
4A6D0C4F149B3E3D00DB3EAA /* catch_generators.hpp */,
|
|
||||||
4A6D0C5C149B3E3D00DB3EAA /* catch_result_type.h */,
|
4A6D0C5C149B3E3D00DB3EAA /* catch_result_type.h */,
|
||||||
4A6D0C5D149B3E3D00DB3EAA /* catch_assertionresult.h */,
|
4A6D0C5D149B3E3D00DB3EAA /* catch_assertionresult.h */,
|
||||||
261488FE184DC32F0041FBEB /* catch_section.h */,
|
261488FE184DC32F0041FBEB /* catch_section.h */,
|
||||||
@@ -410,7 +400,6 @@
|
|||||||
261488FA184C81130041FBEB /* catch_test_spec.hpp */,
|
261488FA184C81130041FBEB /* catch_test_spec.hpp */,
|
||||||
2656C21F1925E5100040DB02 /* catch_test_spec_parser.hpp */,
|
2656C21F1925E5100040DB02 /* catch_test_spec_parser.hpp */,
|
||||||
4A6D0C4A149B3E3D00DB3EAA /* catch_config.hpp */,
|
4A6D0C4A149B3E3D00DB3EAA /* catch_config.hpp */,
|
||||||
4A6D0C51149B3E3D00DB3EAA /* catch_context.h */,
|
|
||||||
4A6D0C61149B3E3D00DB3EAA /* catch_test_case_info.h */,
|
4A6D0C61149B3E3D00DB3EAA /* catch_test_case_info.h */,
|
||||||
4A7ADB4314F631E10094FE10 /* catch_totals.hpp */,
|
4A7ADB4314F631E10094FE10 /* catch_totals.hpp */,
|
||||||
4AB77CB71553B72B00857BF0 /* catch_section_info.hpp */,
|
4AB77CB71553B72B00857BF0 /* catch_section_info.hpp */,
|
||||||
@@ -438,10 +427,8 @@
|
|||||||
4A6D0C53149B3E3D00DB3EAA /* catch_interfaces_capture.h */,
|
4A6D0C53149B3E3D00DB3EAA /* catch_interfaces_capture.h */,
|
||||||
4A6D0C54149B3E3D00DB3EAA /* catch_interfaces_exception.h */,
|
4A6D0C54149B3E3D00DB3EAA /* catch_interfaces_exception.h */,
|
||||||
4A6D0C55149B3E3D00DB3EAA /* catch_interfaces_reporter.h */,
|
4A6D0C55149B3E3D00DB3EAA /* catch_interfaces_reporter.h */,
|
||||||
4A6D0C56149B3E3D00DB3EAA /* catch_interfaces_runner.h */,
|
|
||||||
4A6D0C57149B3E3D00DB3EAA /* catch_interfaces_testcase.h */,
|
4A6D0C57149B3E3D00DB3EAA /* catch_interfaces_testcase.h */,
|
||||||
4AFC661D157E96A7009D58CF /* catch_interfaces_config.h */,
|
4AFC661D157E96A7009D58CF /* catch_interfaces_config.h */,
|
||||||
4A90B59B15D0F61A00EF71BC /* catch_interfaces_generators.h */,
|
|
||||||
26711C90195D46CD0033EDA2 /* catch_interfaces_tag_alias_registry.h */,
|
26711C90195D46CD0033EDA2 /* catch_interfaces_tag_alias_registry.h */,
|
||||||
);
|
);
|
||||||
name = Interfaces;
|
name = Interfaces;
|
||||||
@@ -546,6 +533,7 @@
|
|||||||
4A6D0C3E149B3D9E00DB3EAA /* TestMain.cpp in Sources */,
|
4A6D0C3E149B3D9E00DB3EAA /* TestMain.cpp in Sources */,
|
||||||
4A6D0C3F149B3D9E00DB3EAA /* TrickyTests.cpp in Sources */,
|
4A6D0C3F149B3D9E00DB3EAA /* TrickyTests.cpp in Sources */,
|
||||||
263F7A4D19B6FE1E009474C2 /* ToStringWhich.cpp in Sources */,
|
263F7A4D19B6FE1E009474C2 /* ToStringWhich.cpp in Sources */,
|
||||||
|
26059AF21BD4B94C003D575C /* PartTrackerTests.cpp in Sources */,
|
||||||
263F7A4B19B6FE1E009474C2 /* ToStringPair.cpp in Sources */,
|
263F7A4B19B6FE1E009474C2 /* ToStringPair.cpp in Sources */,
|
||||||
4AEE032016142F910071E950 /* catch_common.cpp in Sources */,
|
4AEE032016142F910071E950 /* catch_common.cpp in Sources */,
|
||||||
263F7A4C19B6FE1E009474C2 /* ToStringVector.cpp in Sources */,
|
263F7A4C19B6FE1E009474C2 /* ToStringVector.cpp in Sources */,
|
||||||
@@ -563,7 +551,6 @@
|
|||||||
4A45DA3316162047004F8D6B /* catch_interfaces_exception.cpp in Sources */,
|
4A45DA3316162047004F8D6B /* catch_interfaces_exception.cpp in Sources */,
|
||||||
2691574C1A532A280054F1ED /* ToStringTuple.cpp in Sources */,
|
2691574C1A532A280054F1ED /* ToStringTuple.cpp in Sources */,
|
||||||
26711C8F195D465C0033EDA2 /* TagAliasTests.cpp in Sources */,
|
26711C8F195D465C0033EDA2 /* TagAliasTests.cpp in Sources */,
|
||||||
4A45DA3516162071004F8D6B /* catch_interfaces_runner.cpp in Sources */,
|
|
||||||
4AB3D99D1616216500C9A0F8 /* catch_interfaces_testcase.cpp in Sources */,
|
4AB3D99D1616216500C9A0F8 /* catch_interfaces_testcase.cpp in Sources */,
|
||||||
4AB3D9A01616219100C9A0F8 /* catch_interfaces_config.cpp in Sources */,
|
4AB3D9A01616219100C9A0F8 /* catch_interfaces_config.cpp in Sources */,
|
||||||
4AB3D9A2161621B500C9A0F8 /* catch_interfaces_generators.cpp in Sources */,
|
4AB3D9A2161621B500C9A0F8 /* catch_interfaces_generators.cpp in Sources */,
|
||||||
@@ -572,7 +559,6 @@
|
|||||||
26847E5F16BBADB40043B9C1 /* catch_message.cpp in Sources */,
|
26847E5F16BBADB40043B9C1 /* catch_message.cpp in Sources */,
|
||||||
266B06B816F3A60A004ED264 /* VariadicMacrosTests.cpp in Sources */,
|
266B06B816F3A60A004ED264 /* VariadicMacrosTests.cpp in Sources */,
|
||||||
266ECD74170F3C620030D735 /* BDDTests.cpp in Sources */,
|
266ECD74170F3C620030D735 /* BDDTests.cpp in Sources */,
|
||||||
26948286179A9AB900ED166E /* SectionTrackerTests.cpp in Sources */,
|
|
||||||
);
|
);
|
||||||
runOnlyForDeploymentPostprocessing = 0;
|
runOnlyForDeploymentPostprocessing = 0;
|
||||||
};
|
};
|
||||||
|
@@ -10,31 +10,31 @@
|
|||||||
<string>CatchSelfTestSingle</string>
|
<string>CatchSelfTestSingle</string>
|
||||||
<key>IDESourceControlProjectOriginsDictionary</key>
|
<key>IDESourceControlProjectOriginsDictionary</key>
|
||||||
<dict>
|
<dict>
|
||||||
<key>01DD8CA9-7DC3-46BC-B998-EFF40EA3485F</key>
|
<key>90C00904F36E6ADB57A7313E998815D255B0DEAF</key>
|
||||||
<string>ssh://github.com/philsquared/Catch.git</string>
|
<string>https://github.com/philsquared/Catch.git</string>
|
||||||
</dict>
|
</dict>
|
||||||
<key>IDESourceControlProjectPath</key>
|
<key>IDESourceControlProjectPath</key>
|
||||||
<string>projects/XCode4/CatchSelfTest/CatchSelfTestSingle.xcodeproj/project.xcworkspace</string>
|
<string>projects/XCode/CatchSelfTest/CatchSelfTestSingle.xcodeproj</string>
|
||||||
<key>IDESourceControlProjectRelativeInstallPathDictionary</key>
|
<key>IDESourceControlProjectRelativeInstallPathDictionary</key>
|
||||||
<dict>
|
<dict>
|
||||||
<key>01DD8CA9-7DC3-46BC-B998-EFF40EA3485F</key>
|
<key>90C00904F36E6ADB57A7313E998815D255B0DEAF</key>
|
||||||
<string>../../../../..</string>
|
<string>../../../../..</string>
|
||||||
</dict>
|
</dict>
|
||||||
<key>IDESourceControlProjectURL</key>
|
<key>IDESourceControlProjectURL</key>
|
||||||
<string>ssh://github.com/philsquared/Catch.git</string>
|
<string>https://github.com/philsquared/Catch.git</string>
|
||||||
<key>IDESourceControlProjectVersion</key>
|
<key>IDESourceControlProjectVersion</key>
|
||||||
<integer>110</integer>
|
<integer>111</integer>
|
||||||
<key>IDESourceControlProjectWCCIdentifier</key>
|
<key>IDESourceControlProjectWCCIdentifier</key>
|
||||||
<string>01DD8CA9-7DC3-46BC-B998-EFF40EA3485F</string>
|
<string>90C00904F36E6ADB57A7313E998815D255B0DEAF</string>
|
||||||
<key>IDESourceControlProjectWCConfigurations</key>
|
<key>IDESourceControlProjectWCConfigurations</key>
|
||||||
<array>
|
<array>
|
||||||
<dict>
|
<dict>
|
||||||
<key>IDESourceControlRepositoryExtensionIdentifierKey</key>
|
<key>IDESourceControlRepositoryExtensionIdentifierKey</key>
|
||||||
<string>public.vcs.git</string>
|
<string>public.vcs.git</string>
|
||||||
<key>IDESourceControlWCCIdentifierKey</key>
|
<key>IDESourceControlWCCIdentifierKey</key>
|
||||||
<string>01DD8CA9-7DC3-46BC-B998-EFF40EA3485F</string>
|
<string>90C00904F36E6ADB57A7313E998815D255B0DEAF</string>
|
||||||
<key>IDESourceControlWCCName</key>
|
<key>IDESourceControlWCCName</key>
|
||||||
<string>Catch</string>
|
<string>Catch-Develop</string>
|
||||||
</dict>
|
</dict>
|
||||||
</array>
|
</array>
|
||||||
</dict>
|
</dict>
|
||||||
|
46
scripts/fixTrailingWhitespace.py
Normal file
46
scripts/fixTrailingWhitespace.py
Normal file
@@ -0,0 +1,46 @@
|
|||||||
|
from __future__ import print_function
|
||||||
|
import os
|
||||||
|
from scriptCommon import catchPath
|
||||||
|
|
||||||
|
changedFiles = 0
|
||||||
|
|
||||||
|
def isSourceFile( path ):
|
||||||
|
return path.endswith( ".cpp" ) or path.endswith( ".h" ) or path.endswith( ".hpp" )
|
||||||
|
|
||||||
|
def fixAllFilesInDir( dir ):
|
||||||
|
for f in os.listdir( dir ):
|
||||||
|
path = os.path.join( dir,f )
|
||||||
|
if os.path.isfile( path ):
|
||||||
|
if isSourceFile( path ):
|
||||||
|
fixFile( path )
|
||||||
|
else:
|
||||||
|
fixAllFilesInDir( path )
|
||||||
|
|
||||||
|
def fixFile( path ):
|
||||||
|
f = open( path, 'r' )
|
||||||
|
lines = []
|
||||||
|
changed = 0
|
||||||
|
for line in f:
|
||||||
|
trimmed = line.rstrip() + "\n"
|
||||||
|
if trimmed != line:
|
||||||
|
changed = changed +1
|
||||||
|
lines.append( trimmed )
|
||||||
|
f.close()
|
||||||
|
if changed > 0:
|
||||||
|
global changedFiles
|
||||||
|
changedFiles = changedFiles + 1
|
||||||
|
print( path + ":" )
|
||||||
|
print( " - fixed " + str(changed) + " line(s)" )
|
||||||
|
altPath = path + ".backup"
|
||||||
|
os.rename( path, altPath )
|
||||||
|
f2 = open( path, 'w' )
|
||||||
|
for line in lines:
|
||||||
|
f2.write( line )
|
||||||
|
f2.close()
|
||||||
|
os.remove( altPath )
|
||||||
|
|
||||||
|
fixAllFilesInDir(catchPath)
|
||||||
|
if changedFiles > 0:
|
||||||
|
print( "Fixed " + str(changedFiles) + " file(s)" )
|
||||||
|
else:
|
||||||
|
print( "No trailing whitespace found" )
|
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user