Compare commits

..

55 Commits

Author SHA1 Message Date
Phil Nash
ac220289a6 v1.5.5:
Deal with auto_ptr and random_shuffle hard deprecations in C++14
2016-06-09 08:19:23 +01:00
Phil Nash
be3570ef22 Use std::shuffle instead of (deprecated) std::random_shuffle if C++14 detected 2016-06-09 08:15:57 +01:00
Phil Nash
a74d760d74 Switched remaining std::auto_ptrs to use CATCH_AUTO_PTR 2016-06-08 19:14:54 +01:00
Phil Nash
f666f5f0ae v1.5.4 2016-05-12 19:18:04 +01:00
Phil Nash
7940d58a2f "test" expression using !! instead of static_cast to bool.
This addresses #657 while (hopefully) maintaining fix for #574
2016-05-12 19:17:55 +01:00
Phil Nash
ebf9f3bb9d v1.5.3 2016-05-10 19:09:59 +01:00
Phil Nash
1ebebd4ab8 Merge branch 'rcdailey-throw-on-duplicate-tests' 2016-05-10 19:07:07 +01:00
Phil Nash
b57e734eb4 Merge branch 'throw-on-duplicate-tests' of git://github.com/rcdailey/Catch into rcdailey-throw-on-duplicate-tests 2016-05-10 19:06:47 +01:00
Phil Nash
5aa2b82b17 Merge pull request #656 from daniel-j-h/better_travis
Pins LLVM 3.8 (stable) instead of tracking the nightly repository
2016-05-07 23:19:26 +01:00
Phil Nash
5c198d85e6 v1.5.2 2016-05-07 23:14:04 +01:00
Phil Nash
5a6b291878 Using Clara 0.0.2.4 - fixes issue with spaces in quoted arguments 2016-05-07 23:12:46 +01:00
Daniel J. Hofmann
1706dd4f11 Pins LLVM 3.8 (stable) instead of tracking the nightly repository 2016-05-07 18:55:12 +02:00
Phil Nash
92b141ee53 v1.5.1 2016-04-28 08:13:00 +01:00
Phil Nash
4f1263d6b4 Removed use of dynamic_cast from test_case_tracker.
(Thanks to #631 and #648)
2016-04-28 08:11:12 +01:00
Phil Nash
3b19458fed Removed use of dynamic_cast for MultipleReporters
(Thanks to #630, #636 and #648)
2016-04-28 08:11:12 +01:00
Phil Nash
e5537842d0 Regenerated single include
(forgot for previously tagged release)
2016-04-25 18:56:50 +01:00
Phil Nash
0fe303b6b7 v1.5.0 (due to new embedded Clara) 2016-04-23 13:25:51 +01:00
Phil Nash
1c47fe023a Updated embedded Clara to 0.0.2.3
- has all new, more robust, token parsing.
- eliminates issue with unreachable code
- allows use of forward slashes to introduce short args on Windows
2016-04-23 13:21:29 +01:00
Phil Nash
6f3bc629be Merge branch 'AzCopey-hotfix/override-warning' 2016-04-23 13:14:08 +01:00
Phil Nash
6de7142d1f Merge pull request #634 from rafaeleyng/patch-1
Update tutorial.md
2016-04-05 18:23:22 +01:00
Rafael Eyng
7544644bb4 Update tutorial.md
Closes #633
2016-04-04 23:04:45 -03:00
Robert Dailey
86c0ea2999 [#608] Don't use exit() on duplicate test descriptions
Instead of `exit(1)`, it now throws `std::runtime_error` with the details
of the failure. This exception is handled in `run()` at a higher level where
the log is printed to cerr and the test gracefully exits.
2016-04-01 11:56:51 -05:00
Ian Copland
7075b7defb Added missing CATCH_OVERRIDE to CumulativeReporterBase::assertionEnded(). This fixes a warning when building in Xcode 7.2+ with default warning settings. 2016-03-29 17:03:09 +01:00
Phil Nash
c984fc3ecd v1.4.0
- use __COUNTER__ for unique IDS instead of __LINE__ (where possible)
+ bug fixes
2016-03-15 07:24:26 +00:00
Phil Nash
447f53e9e3 Fixed !shouldfail 2016-03-14 19:13:34 +00:00
Phil Nash
13a887ad24 Use __COUNTER__ when generating unique names instead of __LINE__, if available.
Based on PR #351
2016-03-14 07:55:00 +00:00
Phil Nash
02af70ed0b build v1.3.6 (include's David Grayson's fix for the gcc pragma) 2016-03-11 18:31:52 +00:00
Phil Nash
c362894565 Merge branch 'DavidEGrayson-pr_gcc_pragma_typo' 2016-03-11 07:59:20 +00:00
David Grayson
97e335437e Fix CATCH_INTERNAL_SUPPRESS_PARENTHESES_WARNINGS: GCC needs to be capitalized.
Fixes issue #600.
2016-03-04 19:24:10 -08:00
Phil Nash
ae5ee2cf63 v1.3.5 2016-02-29 08:17:18 +00:00
Phil Nash
f895e0d95f Rebased approvals following colour changes 2016-02-29 08:13:27 +00:00
Phil Nash
458f37ed57 Merge branch 'explicit-bool-conversion' of git://github.com/seanmiddleditch/Catch into seanmiddleditch-explicit-bool-conversion 2016-02-29 08:05:46 +00:00
Phil Nash
91bfe68a75 Suppress parentheses warnings on clang and gcc
- should address #593, #528, #521, #496 (and possibly others)
2016-02-29 08:03:48 +00:00
Phil Nash
8ccb18daa9 Added --use-colour option to give finer control over colourisation.
--force-colour is still present but deprecated (will remove in v2)
2016-02-29 08:03:48 +00:00
Phil Nash
dce2154474 Merge pull request #598 from luxe/patch-1
removes link to missing readme file
2016-02-27 17:06:57 +00:00
Trevor Hickey
e52ad48fb7 removes link to missing readme file 2016-02-26 10:29:23 -05:00
Sean Middleditch
776247af81 Support explicit operator bool
Fix for issue 596
2016-02-25 00:34:09 -08:00
Phil Nash
3b4edd7a48 Build for v1.3.4 2016-02-10 19:24:48 +00:00
Phil Nash
880a2046d9 Use Clara v0.0.1.1 2016-02-10 19:21:09 +00:00
Phil Nash
ffad3a0a39 Fix as suggested in #574
Cast expression to bool to prevent custom && from defeating short-circuiting
2016-02-10 05:49:56 +00:00
Phil Nash
3bd20bf2cd Removed reference to pre 1.0 release from README 2016-01-22 07:59:06 +00:00
Phil Nash
c7243562b0 v1.3.3 2016-01-22 07:59:06 +00:00
Phil Nash
b84e08ad6f Fix EndsWith Matcher (and refactored EndsWith and StartsWith in terms of endsWith and startsWith) (see Issue #573) 2016-01-22 07:59:06 +00:00
Phil Nash
aca16a0f99 Fixed CATCH_REGISTER_TEST_CASE too 2016-01-22 07:50:10 +00:00
Phil Nash
f294c98472 Fixed REGISTER_TEST_CASE for VS2013 (hopefully)
- see #549
2016-01-05 08:19:16 +00:00
Phil Nash
7424b23bfb v1.3.1 2015-12-28 15:07:32 +00:00
Phil Nash
dbd3a84d92 Fixed catch_with_main.hpp (no longer references deleted catch_runner.hpp) 2015-12-28 15:06:04 +00:00
Phil Nash
5262e61e9d Approvals for Matcher change (added comma) 2015-12-10 18:43:29 +00:00
Simon Warta
a5fba672e1 Add missing comma when in captured expression for matchers
Such that
CHECK_THAT( hex_encode(outbuf) Equals("B5D4045C") )
becomes
CHECK_THAT( hex_encode(outbuf), Equals("B5D4045C") )
2015-12-10 08:09:10 +00:00
Phil Nash
2106d82881 Fixed non-variadic version of REGISTER_TEST_CASE 2015-12-09 18:24:29 +00:00
Phil Nash
981347b6e4 patch build to include last two fixes 2015-12-09 18:11:48 +00:00
Phil Nash
9e341231ba main takes args by non-const char*
- see #548
2015-12-09 06:22:15 +00:00
Phil Nash
2b688e1cef Initialise m_currentSortOrder
- as reported in #545
2015-12-09 06:15:52 +00:00
Phil Nash
84d1c080d6 Keep Xcode 7.1 happy 2015-12-04 10:21:07 +00:00
Phil Nash
722315a1f5 Removed some trailing whitespace 2015-12-04 10:20:33 +00:00
42 changed files with 1351 additions and 477 deletions

View File

@@ -64,7 +64,7 @@ matrix:
compiler: clang compiler: clang
addons: &clang38 addons: &clang38
apt: apt:
sources: ['llvm-toolchain-precise', 'ubuntu-toolchain-r-test'] sources: ['llvm-toolchain-precise-3.8', 'ubuntu-toolchain-r-test']
packages: ['clang-3.8'] packages: ['clang-3.8']
env: COMPILER='ccache clang++-3.8' BUILD_TYPE='Release' env: COMPILER='ccache clang++-3.8' BUILD_TYPE='Release'

View File

@@ -1,12 +1,10 @@
![catch logo](catch-logo-small.png) ![catch logo](catch-logo-small.png)
*v1.3.0* *v1.5.5*
Build status (on Travis CI) [![Build Status](https://travis-ci.org/philsquared/Catch.png)](https://travis-ci.org/philsquared/Catch) Build status (on Travis CI) [![Build Status](https://travis-ci.org/philsquared/Catch.png)](https://travis-ci.org/philsquared/Catch)
[Please see this page if you are updating from a version before 1.0](docs/whats-changed.md) <a href="https://raw.githubusercontent.com/philsquared/Catch/master/single_include/catch.hpp">The latest, single header, version can be downloaded directly using this link</a>
<a href="https://raw.githubusercontent.com/philsquared/Catch/master/single_include/catch.hpp">[The latest, single header, version can be downloaded directly using this link]</a>
## What's the Catch? ## What's the Catch?
@@ -19,8 +17,6 @@ This documentation comprises these three parts:
* [Tutorial](docs/tutorial.md) - getting started * [Tutorial](docs/tutorial.md) - getting started
* [Reference section](docs/Readme.md) - all the details * [Reference section](docs/Readme.md) - all the details
The documentation will continue until morale improves
## More ## More
* Issues and bugs can be raised on the [Issue tracker on GitHub](https://github.com/philsquared/Catch/issues) * Issues and bugs can be raised on the [Issue tracker on GitHub](https://github.com/philsquared/Catch/issues)
* For discussion or questions please use [the dedicated Google Groups forum](https://groups.google.com/forum/?fromgroups#!forum/catch-forum) * For discussion or questions please use [the dedicated Google Groups forum](https://groups.google.com/forum/?fromgroups#!forum/catch-forum)

View File

@@ -16,5 +16,4 @@ Before looking at this material be sure to read the [tutorial](tutorial.md)
Other Other
* [Why Catch?](why-catch.md) * [Why Catch?](why-catch.md)
* [What's changed](whats-changed.md)
* [Contributing](contributing.md) * [Contributing](contributing.md)

View File

@@ -1,6 +1,6 @@
# Getting Catch # Getting Catch
The simplest way to get Catch is to download the single header version from [http://builds.catch-lib.net](http://builds.catch-lib.net). Don't be put off by the word "builds" there. The single header is generated by merging a set of individual headers but it is still just normal source code in a header file. The simplest way to get Catch is to download the latest [single header version](https://raw.githubusercontent.com/philsquared/Catch/master/single_include/catch.hpp). The single header is generated by merging a set of individual headers but it is still just normal source code in a header file.
The full source for Catch, including test projects, documentation, and other things, is hosted on GitHub. [http://catch-lib.net](http://catch-lib.net) will redirect you there. The full source for Catch, including test projects, documentation, and other things, is hosted on GitHub. [http://catch-lib.net](http://catch-lib.net) will redirect you there.

View File

@@ -1,24 +0,0 @@
## What's new in Catch for 1.0
After a long "developer preview" state Catch turned 1.0 in mid-2013. Just prior to this a large number of changes, some of them breaking, where merged from the integration branch and now form part of the 1.0 code-base. If this might affect you please read this summary through so you know what to expect.
* Calling Catch from your own ```main()``` has changed - please review [the updated docs](own-main.md)
* The command line has changed. The biggest change is that test case names and tags should now only be supplied as primary arguments - in fact the ```-t``` option has been repurposed to mean "list tags". There are [updated docs for this too](command-line.md)
* There is a new reporter interface. If you have written a custom reporter you can use the ```LegacyReporterAdapter``` to minimise any differences. Ideally you should update to the new interface - especially as it has been designed to be more robust in the face of future changes (which should be minimal).
* The docs have moved from the wiki to the repository itself. They consist of a set of markdown files in the docs folder and are referenced directly from the README in the root. You can still read them online from GitHub.
* Lots of new goodness - more documentation for which is coming. The existing docs have been updated to account for some of the changes already (e.g. variadic macros). A quick rundown:
* Variadic macros are used, where possible, so that, e.g. you can write a ```TEST_CASE``` with just a name - or even no name at all (making it an anonymous test case).
* The hierarchical naming convention is deprecated in favour of using tags (see next)
* ```TEST_CASE```s (but not ```SECTION```s) can now be tagged by placing keywords in square brackets in the second argument - e.g.: ```TEST_CASE( "A nice name", "[tag1][tag2]")```. The old style is still supported but please consider using this new style.
* Tests can still be "hidden" using the ```./``` prefix as before, but the preferred way now is to give it the ```[hide]``` tag (hidden tests are skipped if you run the test process without specifying any test specs).
* As well as ```TEST_CASE```s and ```SECTION```s you can now also use BDD-style ```SCENARIO``` (in place of ```TEST_CASE```) and ```GIVEN```, ```WHEN``` and ```THEN``` macros (in place of ```SECTION```s).
* New command line parser. Under the hood it is a complete rewrite - now powered by a command line library that will soon be spun out as a separate project: Clara. The options themselves are largely the same but there are some notable differences (as already discussed).
* Completely overhauled output from the textual reporter (now the Console reporter). This now features a much clearer, cleaner format, including good use of indentation.
More information can be found in [this blog post](http://www.levelofindirection.com/journal/2013/6/28/catch-10.html).
If you find any issues please raise issue tickets on the [issue tracker on GitHub](https://github.com/philsquared/Catch/issues) as before. For general questions, comments and suggestions, though, please use the [new forums on Google Groups](https://groups.google.com/forum/?fromgroups#!forum/catch-forum).
---
[Home](Readme.md)

View File

@@ -99,7 +99,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_REGISTER_TEST_CASE( Function, ... ) INTERNAL_CATCH_REGISTER_TESTCASE( Function, __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__ )
@@ -168,7 +168,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 REGISTER_TEST_CASE( Function, ... ) INTERNAL_CATCH_REGISTER_TESTCASE( Function, __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__ )
@@ -176,7 +176,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( ... ) INTERNAL_CATCH_REGISTER_TESTCASE( __VA_ARGS__ ) #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 )

View File

@@ -131,10 +131,10 @@ 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* const argv[], OnUnusedOptions::DoWhat unusedOptionBehaviour = OnUnusedOptions::Fail ) { int applyCommandLine( int argc, char const* 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( Clara::argsToVector( argc, argv ), m_configData );
if( m_configData.showHelp ) if( m_configData.showHelp )
showHelp( m_configData.processName ); showHelp( m_configData.processName );
m_config.reset(); m_config.reset();
@@ -158,7 +158,7 @@ namespace Catch {
m_config.reset(); m_config.reset();
} }
int run( int argc, char const* const argv[] ) { int run( int argc, char const* const* const argv ) {
int returnCode = applyCommandLine( argc, argv ); int returnCode = applyCommandLine( argc, argv );
if( returnCode == 0 ) if( returnCode == 0 )

View File

@@ -8,8 +8,7 @@
#ifndef TWOBLUECUBES_CATCH_WITH_MAIN_HPP_INCLUDED #ifndef TWOBLUECUBES_CATCH_WITH_MAIN_HPP_INCLUDED
#define TWOBLUECUBES_CATCH_WITH_MAIN_HPP_INCLUDED #define TWOBLUECUBES_CATCH_WITH_MAIN_HPP_INCLUDED
#include "catch_runner.hpp" #define CATCH_CONFIG_MAIN
#include "catch.hpp" #include "catch.hpp"
#include "internal/catch_default_main.hpp"
#endif // TWOBLUECUBES_CATCH_WITH_MAIN_HPP_INCLUDED #endif // TWOBLUECUBES_CATCH_WITH_MAIN_HPP_INCLUDED

View File

@@ -6,6 +6,8 @@
* 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)
*/ */
// Version 0.0.2.4
// Only use header guard if we are not using an outer namespace // Only use header guard if we are not using an outer namespace
#if !defined(TWOBLUECUBES_CLARA_H_INCLUDED) || defined(STITCH_CLARA_OPEN_NAMESPACE) #if !defined(TWOBLUECUBES_CLARA_H_INCLUDED) || defined(STITCH_CLARA_OPEN_NAMESPACE)
@@ -38,6 +40,7 @@
#include <string> #include <string>
#include <vector> #include <vector>
#include <sstream> #include <sstream>
#include <algorithm>
// Use optional outer namespace // Use optional outer namespace
#ifdef STITCH_TBC_TEXT_FORMAT_OUTER_NAMESPACE #ifdef STITCH_TBC_TEXT_FORMAT_OUTER_NAMESPACE
@@ -172,16 +175,179 @@ namespace Tbc {
#endif // TBC_TEXT_FORMAT_H_INCLUDED #endif // TBC_TEXT_FORMAT_H_INCLUDED
// ----------- end of #include from tbc_text_format.h ----------- // ----------- end of #include from tbc_text_format.h -----------
// ........... back in /Users/philnash/Dev/OSS/Clara/srcs/clara.h // ........... back in clara.h
#undef STITCH_TBC_TEXT_FORMAT_OPEN_NAMESPACE #undef STITCH_TBC_TEXT_FORMAT_OPEN_NAMESPACE
// ----------- #included from clara_compilers.h -----------
/*
* Created by Phil on 10/02/2016.
* Copyright 2016 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_CLARA_COMPILERS_H_INCLUDED
#define TWOBLUECUBES_CLARA_COMPILERS_H_INCLUDED
// Detect a number of compiler features - mostly C++11/14 conformance - by compiler
// The following features are defined:
//
// CLARA_CONFIG_CPP11_NULLPTR : is nullptr supported?
// CLARA_CONFIG_CPP11_NOEXCEPT : is noexcept supported?
// CLARA_CONFIG_CPP11_GENERATED_METHODS : The delete and default keywords for compiler generated methods
// CLARA_CONFIG_CPP11_OVERRIDE : is override supported?
// CLARA_CONFIG_CPP11_UNIQUE_PTR : is unique_ptr supported (otherwise use auto_ptr)
// CLARA_CONFIG_CPP11_OR_GREATER : Is C++11 supported?
// CLARA_CONFIG_VARIADIC_MACROS : are variadic macros supported?
// In general each macro has a _NO_<feature name> form
// (e.g. CLARA_CONFIG_CPP11_NO_NULLPTR) which disables the feature.
// Many features, at point of detection, define an _INTERNAL_ macro, so they
// can be combined, en-mass, with the _NO_ forms later.
// All the C++11 features can be disabled with CLARA_CONFIG_NO_CPP11
#ifdef __clang__
#if __has_feature(cxx_nullptr)
#define CLARA_INTERNAL_CONFIG_CPP11_NULLPTR
#endif
#if __has_feature(cxx_noexcept)
#define CLARA_INTERNAL_CONFIG_CPP11_NOEXCEPT
#endif
#endif // __clang__
////////////////////////////////////////////////////////////////////////////////
// GCC
#ifdef __GNUC__
#if __GNUC__ == 4 && __GNUC_MINOR__ >= 6 && defined(__GXX_EXPERIMENTAL_CXX0X__)
#define CLARA_INTERNAL_CONFIG_CPP11_NULLPTR
#endif
// - otherwise more recent versions define __cplusplus >= 201103L
// and will get picked up below
#endif // __GNUC__
////////////////////////////////////////////////////////////////////////////////
// Visual C++
#ifdef _MSC_VER
#if (_MSC_VER >= 1600)
#define CLARA_INTERNAL_CONFIG_CPP11_NULLPTR
#define CLARA_INTERNAL_CONFIG_CPP11_UNIQUE_PTR
#endif
#if (_MSC_VER >= 1900 ) // (VC++ 13 (VS2015))
#define CLARA_INTERNAL_CONFIG_CPP11_NOEXCEPT
#define CLARA_INTERNAL_CONFIG_CPP11_GENERATED_METHODS
#endif
#endif // _MSC_VER
////////////////////////////////////////////////////////////////////////////////
// C++ language feature support
// catch all support for C++11
#if defined(__cplusplus) && __cplusplus >= 201103L
#define CLARA_CPP11_OR_GREATER
#if !defined(CLARA_INTERNAL_CONFIG_CPP11_NULLPTR)
#define CLARA_INTERNAL_CONFIG_CPP11_NULLPTR
#endif
#ifndef CLARA_INTERNAL_CONFIG_CPP11_NOEXCEPT
#define CLARA_INTERNAL_CONFIG_CPP11_NOEXCEPT
#endif
#ifndef CLARA_INTERNAL_CONFIG_CPP11_GENERATED_METHODS
#define CLARA_INTERNAL_CONFIG_CPP11_GENERATED_METHODS
#endif
#if !defined(CLARA_INTERNAL_CONFIG_CPP11_OVERRIDE)
#define CLARA_INTERNAL_CONFIG_CPP11_OVERRIDE
#endif
#if !defined(CLARA_INTERNAL_CONFIG_CPP11_UNIQUE_PTR)
#define CLARA_INTERNAL_CONFIG_CPP11_UNIQUE_PTR
#endif
#endif // __cplusplus >= 201103L
// Now set the actual defines based on the above + anything the user has configured
#if defined(CLARA_INTERNAL_CONFIG_CPP11_NULLPTR) && !defined(CLARA_CONFIG_CPP11_NO_NULLPTR) && !defined(CLARA_CONFIG_CPP11_NULLPTR) && !defined(CLARA_CONFIG_NO_CPP11)
#define CLARA_CONFIG_CPP11_NULLPTR
#endif
#if defined(CLARA_INTERNAL_CONFIG_CPP11_NOEXCEPT) && !defined(CLARA_CONFIG_CPP11_NO_NOEXCEPT) && !defined(CLARA_CONFIG_CPP11_NOEXCEPT) && !defined(CLARA_CONFIG_NO_CPP11)
#define CLARA_CONFIG_CPP11_NOEXCEPT
#endif
#if defined(CLARA_INTERNAL_CONFIG_CPP11_GENERATED_METHODS) && !defined(CLARA_CONFIG_CPP11_NO_GENERATED_METHODS) && !defined(CLARA_CONFIG_CPP11_GENERATED_METHODS) && !defined(CLARA_CONFIG_NO_CPP11)
#define CLARA_CONFIG_CPP11_GENERATED_METHODS
#endif
#if defined(CLARA_INTERNAL_CONFIG_CPP11_OVERRIDE) && !defined(CLARA_CONFIG_NO_OVERRIDE) && !defined(CLARA_CONFIG_CPP11_OVERRIDE) && !defined(CLARA_CONFIG_NO_CPP11)
#define CLARA_CONFIG_CPP11_OVERRIDE
#endif
#if defined(CLARA_INTERNAL_CONFIG_CPP11_UNIQUE_PTR) && !defined(CLARA_CONFIG_NO_UNIQUE_PTR) && !defined(CLARA_CONFIG_CPP11_UNIQUE_PTR) && !defined(CLARA_CONFIG_NO_CPP11)
#define CLARA_CONFIG_CPP11_UNIQUE_PTR
#endif
// noexcept support:
#if defined(CLARA_CONFIG_CPP11_NOEXCEPT) && !defined(CLARA_NOEXCEPT)
#define CLARA_NOEXCEPT noexcept
# define CLARA_NOEXCEPT_IS(x) noexcept(x)
#else
#define CLARA_NOEXCEPT throw()
# define CLARA_NOEXCEPT_IS(x)
#endif
// nullptr support
#ifdef CLARA_CONFIG_CPP11_NULLPTR
#define CLARA_NULL nullptr
#else
#define CLARA_NULL NULL
#endif
// override support
#ifdef CLARA_CONFIG_CPP11_OVERRIDE
#define CLARA_OVERRIDE override
#else
#define CLARA_OVERRIDE
#endif
// unique_ptr support
#ifdef CLARA_CONFIG_CPP11_UNIQUE_PTR
# define CLARA_AUTO_PTR( T ) std::unique_ptr<T>
#else
# define CLARA_AUTO_PTR( T ) std::auto_ptr<T>
#endif
#endif // TWOBLUECUBES_CLARA_COMPILERS_H_INCLUDED
// ----------- end of #include from clara_compilers.h -----------
// ........... back in clara.h
#include <map> #include <map>
#include <algorithm>
#include <stdexcept> #include <stdexcept>
#include <memory> #include <memory>
#if defined(WIN32) || defined(__WIN32__) || defined(_WIN32) || defined(_MSC_VER)
#define CLARA_PLATFORM_WINDOWS
#endif
// Use optional outer namespace // Use optional outer namespace
#ifdef STITCH_CLARA_OPEN_NAMESPACE #ifdef STITCH_CLARA_OPEN_NAMESPACE
STITCH_CLARA_OPEN_NAMESPACE STITCH_CLARA_OPEN_NAMESPACE
@@ -240,23 +406,16 @@ namespace Clara {
else else
throw std::runtime_error( "Expected a boolean value but did not recognise:\n '" + _source + "'" ); throw std::runtime_error( "Expected a boolean value but did not recognise:\n '" + _source + "'" );
} }
inline void convertInto( bool _source, bool& _dest ) {
_dest = _source;
}
template<typename T>
inline void convertInto( bool, T& ) {
throw std::runtime_error( "Invalid conversion" );
}
template<typename ConfigT> template<typename ConfigT>
struct IArgFunction { struct IArgFunction {
virtual ~IArgFunction() {} virtual ~IArgFunction() {}
# ifdef CATCH_CONFIG_CPP11_GENERATED_METHODS #ifdef CLARA_CONFIG_CPP11_GENERATED_METHODS
IArgFunction() = default; IArgFunction() = default;
IArgFunction( IArgFunction const& ) = default; IArgFunction( IArgFunction const& ) = default;
# endif #endif
virtual void set( ConfigT& config, std::string const& value ) const = 0; virtual void set( ConfigT& config, std::string const& value ) const = 0;
virtual void setFlag( ConfigT& config ) const = 0;
virtual bool takesArg() const = 0; virtual bool takesArg() const = 0;
virtual IArgFunction* clone() const = 0; virtual IArgFunction* clone() const = 0;
}; };
@@ -264,11 +423,11 @@ namespace Clara {
template<typename ConfigT> template<typename ConfigT>
class BoundArgFunction { class BoundArgFunction {
public: public:
BoundArgFunction() : functionObj( CATCH_NULL ) {} BoundArgFunction() : functionObj( CLARA_NULL ) {}
BoundArgFunction( IArgFunction<ConfigT>* _functionObj ) : functionObj( _functionObj ) {} BoundArgFunction( IArgFunction<ConfigT>* _functionObj ) : functionObj( _functionObj ) {}
BoundArgFunction( BoundArgFunction const& other ) : functionObj( other.functionObj ? other.functionObj->clone() : CATCH_NULL ) {} BoundArgFunction( BoundArgFunction const& other ) : functionObj( other.functionObj ? other.functionObj->clone() : CLARA_NULL ) {}
BoundArgFunction& operator = ( BoundArgFunction const& other ) { BoundArgFunction& operator = ( BoundArgFunction const& other ) {
IArgFunction<ConfigT>* newFunctionObj = other.functionObj ? other.functionObj->clone() : CATCH_NULL; IArgFunction<ConfigT>* newFunctionObj = other.functionObj ? other.functionObj->clone() : CLARA_NULL;
delete functionObj; delete functionObj;
functionObj = newFunctionObj; functionObj = newFunctionObj;
return *this; return *this;
@@ -278,13 +437,10 @@ namespace Clara {
void set( ConfigT& config, std::string const& value ) const { void set( ConfigT& config, std::string const& value ) const {
functionObj->set( config, value ); functionObj->set( config, value );
} }
void setFlag( ConfigT& config ) const {
functionObj->setFlag( config );
}
bool takesArg() const { return functionObj->takesArg(); } bool takesArg() const { return functionObj->takesArg(); }
bool isSet() const { bool isSet() const {
return functionObj != CATCH_NULL; return functionObj != CLARA_NULL;
} }
private: private:
IArgFunction<ConfigT>* functionObj; IArgFunction<ConfigT>* functionObj;
@@ -294,7 +450,6 @@ namespace Clara {
template<typename C> template<typename C>
struct NullBinder : IArgFunction<C>{ struct NullBinder : IArgFunction<C>{
virtual void set( C&, std::string const& ) const {} virtual void set( C&, std::string const& ) const {}
virtual void setFlag( C& ) const {}
virtual bool takesArg() const { return true; } virtual bool takesArg() const { return true; }
virtual IArgFunction<C>* clone() const { return new NullBinder( *this ); } virtual IArgFunction<C>* clone() const { return new NullBinder( *this ); }
}; };
@@ -305,9 +460,6 @@ namespace Clara {
virtual void set( C& p, std::string const& stringValue ) const { virtual void set( C& p, std::string const& stringValue ) const {
convertInto( stringValue, p.*member ); convertInto( stringValue, p.*member );
} }
virtual void setFlag( C& p ) const {
convertInto( true, p.*member );
}
virtual bool takesArg() const { return !IsBool<M>::value; } virtual bool takesArg() const { return !IsBool<M>::value; }
virtual IArgFunction<C>* clone() const { return new BoundDataMember( *this ); } virtual IArgFunction<C>* clone() const { return new BoundDataMember( *this ); }
M C::* member; M C::* member;
@@ -320,11 +472,6 @@ namespace Clara {
convertInto( stringValue, value ); convertInto( stringValue, value );
(p.*member)( value ); (p.*member)( value );
} }
virtual void setFlag( C& p ) const {
typename RemoveConstRef<M>::type value;
convertInto( true, value );
(p.*member)( value );
}
virtual bool takesArg() const { return !IsBool<M>::value; } virtual bool takesArg() const { return !IsBool<M>::value; }
virtual IArgFunction<C>* clone() const { return new BoundUnaryMethod( *this ); } virtual IArgFunction<C>* clone() const { return new BoundUnaryMethod( *this ); }
void (C::*member)( M ); void (C::*member)( M );
@@ -338,9 +485,6 @@ namespace Clara {
if( value ) if( value )
(p.*member)(); (p.*member)();
} }
virtual void setFlag( C& p ) const {
(p.*member)();
}
virtual bool takesArg() const { return false; } virtual bool takesArg() const { return false; }
virtual IArgFunction<C>* clone() const { return new BoundNullaryMethod( *this ); } virtual IArgFunction<C>* clone() const { return new BoundNullaryMethod( *this ); }
void (C::*member)(); void (C::*member)();
@@ -355,9 +499,6 @@ namespace Clara {
if( value ) if( value )
function( obj ); function( obj );
} }
virtual void setFlag( C& p ) const {
function( p );
}
virtual bool takesArg() const { return false; } virtual bool takesArg() const { return false; }
virtual IArgFunction<C>* clone() const { return new BoundUnaryFunction( *this ); } virtual IArgFunction<C>* clone() const { return new BoundUnaryFunction( *this ); }
void (*function)( C& ); void (*function)( C& );
@@ -371,11 +512,6 @@ namespace Clara {
convertInto( stringValue, value ); convertInto( stringValue, value );
function( obj, value ); function( obj, value );
} }
virtual void setFlag( C& obj ) const {
typename RemoveConstRef<T>::type value;
convertInto( true, value );
function( obj, value );
}
virtual bool takesArg() const { return !IsBool<T>::value; } virtual bool takesArg() const { return !IsBool<T>::value; }
virtual IArgFunction<C>* clone() const { return new BoundBinaryFunction( *this ); } virtual IArgFunction<C>* clone() const { return new BoundBinaryFunction( *this ); }
void (*function)( C&, T ); void (*function)( C&, T );
@@ -383,8 +519,20 @@ namespace Clara {
} // namespace Detail } // namespace Detail
struct Parser { inline std::vector<std::string> argsToVector( int argc, char const* const* const argv ) {
Parser() : separators( " \t=:" ) {} std::vector<std::string> args( static_cast<std::size_t>( argc ) );
for( std::size_t i = 0; i < static_cast<std::size_t>( argc ); ++i )
args[i] = argv[i];
return args;
}
class Parser {
enum Mode { None, MaybeShortOpt, SlashOpt, ShortOpt, LongOpt, Positional };
Mode mode;
std::size_t from;
bool inQuotes;
public:
struct Token { struct Token {
enum Type { Positional, ShortOpt, LongOpt }; enum Type { Positional, ShortOpt, LongOpt };
@@ -393,38 +541,75 @@ namespace Clara {
std::string data; std::string data;
}; };
void parseIntoTokens( int argc, char const * const * argv, std::vector<Parser::Token>& tokens ) const { Parser() : mode( None ), from( 0 ), inQuotes( false ){}
void parseIntoTokens( std::vector<std::string> const& args, std::vector<Token>& tokens ) {
const std::string doubleDash = "--"; const std::string doubleDash = "--";
for( int i = 1; i < argc && argv[i] != doubleDash; ++i ) for( std::size_t i = 1; i < args.size() && args[i] != doubleDash; ++i )
parseIntoTokens( argv[i] , tokens); parseIntoTokens( args[i], tokens);
} }
void parseIntoTokens( std::string arg, std::vector<Parser::Token>& tokens ) const {
while( !arg.empty() ) { void parseIntoTokens( std::string const& arg, std::vector<Token>& tokens ) {
Parser::Token token( Parser::Token::Positional, arg ); for( std::size_t i = 0; i <= arg.size(); ++i ) {
arg = ""; char c = arg[i];
if( token.data[0] == '-' ) { if( c == '"' )
if( token.data.size() > 1 && token.data[1] == '-' ) { inQuotes = !inQuotes;
token = Parser::Token( Parser::Token::LongOpt, token.data.substr( 2 ) ); mode = handleMode( i, c, arg, tokens );
}
else {
token = Parser::Token( Parser::Token::ShortOpt, token.data.substr( 1 ) );
if( token.data.size() > 1 && separators.find( token.data[1] ) == std::string::npos ) {
arg = "-" + token.data.substr( 1 );
token.data = token.data.substr( 0, 1 );
}
}
}
if( token.type != Parser::Token::Positional ) {
std::size_t pos = token.data.find_first_of( separators );
if( pos != std::string::npos ) {
arg = token.data.substr( pos+1 );
token.data = token.data.substr( 0, pos );
}
}
tokens.push_back( token );
} }
} }
std::string separators; Mode handleMode( std::size_t i, char c, std::string const& arg, std::vector<Token>& tokens ) {
switch( mode ) {
case None: return handleNone( i, c );
case MaybeShortOpt: return handleMaybeShortOpt( i, c );
case ShortOpt:
case LongOpt:
case SlashOpt: return handleOpt( i, c, arg, tokens );
case Positional: return handlePositional( i, c, arg, tokens );
default: throw std::logic_error( "Unknown mode" );
}
}
Mode handleNone( std::size_t i, char c ) {
if( inQuotes ) {
from = i;
return Positional;
}
switch( c ) {
case '-': return MaybeShortOpt;
#ifdef CLARA_PLATFORM_WINDOWS
case '/': from = i+1; return SlashOpt;
#endif
default: from = i; return Positional;
}
}
Mode handleMaybeShortOpt( std::size_t i, char c ) {
switch( c ) {
case '-': from = i+1; return LongOpt;
default: from = i; return ShortOpt;
}
}
Mode handleOpt( std::size_t i, char c, std::string const& arg, std::vector<Token>& tokens ) {
if( std::string( ":=\0", 5 ).find( c ) == std::string::npos )
return mode;
std::string optName = arg.substr( from, i-from );
if( mode == ShortOpt )
for( std::size_t j = 0; j < optName.size(); ++j )
tokens.push_back( Token( Token::ShortOpt, optName.substr( j, 1 ) ) );
else if( mode == SlashOpt && optName.size() == 1 )
tokens.push_back( Token( Token::ShortOpt, optName ) );
else
tokens.push_back( Token( Token::LongOpt, optName ) );
return None;
}
Mode handlePositional( std::size_t i, char c, std::string const& arg, std::vector<Token>& tokens ) {
if( inQuotes || std::string( "\0", 3 ).find( c ) == std::string::npos )
return mode;
std::string data = arg.substr( from, i-from );
tokens.push_back( Token( Token::Positional, data ) );
return None;
}
}; };
template<typename ConfigT> template<typename ConfigT>
@@ -503,7 +688,7 @@ namespace Clara {
} }
}; };
typedef CATCH_AUTO_PTR( Arg ) ArgAutoPtr; typedef CLARA_AUTO_PTR( Arg ) ArgAutoPtr;
friend void addOptName( Arg& arg, std::string const& optName ) friend void addOptName( Arg& arg, std::string const& optName )
{ {
@@ -580,8 +765,8 @@ namespace Clara {
m_arg->description = description; m_arg->description = description;
return *this; return *this;
} }
ArgBuilder& detail( std::string const& _detail ) { ArgBuilder& detail( std::string const& detail ) {
m_arg->detail = _detail; m_arg->detail = detail;
return *this; return *this;
} }
@@ -665,14 +850,14 @@ namespace Clara {
maxWidth = (std::max)( maxWidth, it->commands().size() ); maxWidth = (std::max)( maxWidth, it->commands().size() );
for( it = itBegin; it != itEnd; ++it ) { for( it = itBegin; it != itEnd; ++it ) {
Detail::Text usageText( it->commands(), Detail::TextAttributes() Detail::Text usage( it->commands(), Detail::TextAttributes()
.setWidth( maxWidth+indent ) .setWidth( maxWidth+indent )
.setIndent( indent ) ); .setIndent( indent ) );
Detail::Text desc( it->description, Detail::TextAttributes() Detail::Text desc( it->description, Detail::TextAttributes()
.setWidth( width - maxWidth - 3 ) ); .setWidth( width - maxWidth - 3 ) );
for( std::size_t i = 0; i < (std::max)( usageText.size(), desc.size() ); ++i ) { for( std::size_t i = 0; i < (std::max)( usage.size(), desc.size() ); ++i ) {
std::string usageCol = i < usageText.size() ? usageText[i] : ""; std::string usageCol = i < usage.size() ? usage[i] : "";
os << usageCol; os << usageCol;
if( i < desc.size() && !desc[i].empty() ) if( i < desc.size() && !desc[i].empty() )
@@ -729,21 +914,21 @@ namespace Clara {
return oss.str(); return oss.str();
} }
ConfigT parse( int argc, char const * const * argv ) const { ConfigT parse( std::vector<std::string> const& args ) const {
ConfigT config; ConfigT config;
parseInto( argc, argv, config ); parseInto( args, config );
return config; return config;
} }
std::vector<Parser::Token> parseInto( int argc, char const * const * argv, ConfigT& config ) const { std::vector<Parser::Token> parseInto( std::vector<std::string> const& args, ConfigT& config ) const {
std::string processName = argv[0]; std::string processName = args[0];
std::size_t lastSlash = processName.find_last_of( "/\\" ); std::size_t lastSlash = processName.find_last_of( "/\\" );
if( lastSlash != std::string::npos ) if( lastSlash != std::string::npos )
processName = processName.substr( lastSlash+1 ); processName = processName.substr( lastSlash+1 );
m_boundProcessName.set( config, processName ); m_boundProcessName.set( config, processName );
std::vector<Parser::Token> tokens; std::vector<Parser::Token> tokens;
Parser parser; Parser parser;
parser.parseIntoTokens( argc, argv, tokens ); parser.parseIntoTokens( args, tokens );
return populate( tokens, config ); return populate( tokens, config );
} }
@@ -774,7 +959,7 @@ namespace Clara {
arg.boundField.set( config, tokens[++i].data ); arg.boundField.set( config, tokens[++i].data );
} }
else { else {
arg.boundField.setFlag( config ); arg.boundField.set( config, "true" );
} }
break; break;
} }

View File

@@ -33,13 +33,14 @@
do { \ do { \
Catch::ResultBuilder __catchResult( macroName, CATCH_INTERNAL_LINEINFO, #expr, resultDisposition ); \ Catch::ResultBuilder __catchResult( macroName, CATCH_INTERNAL_LINEINFO, #expr, resultDisposition ); \
try { \ try { \
CATCH_INTERNAL_SUPPRESS_PARENTHESES_WARNINGS \
( __catchResult <= expr ).endExpression(); \ ( __catchResult <= expr ).endExpression(); \
} \ } \
catch( ... ) { \ catch( ... ) { \
__catchResult.useActiveException( Catch::ResultDisposition::Normal ); \ __catchResult.useActiveException( Catch::ResultDisposition::Normal ); \
} \ } \
INTERNAL_CATCH_REACT( __catchResult ) \ INTERNAL_CATCH_REACT( __catchResult ) \
} while( Catch::isTrue( false && (expr) ) ) // expr here is never evaluated at runtime but it forces the compiler to give it a look } while( Catch::isTrue( false && !!(expr) ) ) // expr here is never evaluated at runtime but it forces the compiler to give it a look
/////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////
#define INTERNAL_CATCH_IF( expr, resultDisposition, macroName ) \ #define INTERNAL_CATCH_IF( expr, resultDisposition, macroName ) \
@@ -129,7 +130,7 @@
/////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////
#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 = (matcher).toString(); \ std::string matcherAsString = (matcher).toString(); \
__catchResult \ __catchResult \

View File

@@ -62,6 +62,21 @@ namespace Catch {
? ShowDurations::Always ? ShowDurations::Always
: ShowDurations::Never; : ShowDurations::Never;
} }
inline void setUseColour( ConfigData& config, std::string const& value ) {
std::string mode = toLower( value );
if( mode == "yes" )
config.useColour = UseColour::Yes;
else if( mode == "no" )
config.useColour = UseColour::No;
else if( mode == "auto" )
config.useColour = UseColour::Auto;
else
throw std::runtime_error( "colour mode must be one of: auto, yes or no" );
}
inline void forceColour( ConfigData& config ) {
config.useColour = UseColour::Yes;
}
inline void loadTestNamesFromFile( ConfigData& config, std::string const& _filename ) { inline void loadTestNamesFromFile( ConfigData& config, std::string const& _filename ) {
std::ifstream f( _filename.c_str() ); std::ifstream f( _filename.c_str() );
if( !f.is_open() ) if( !f.is_open() )
@@ -148,7 +163,7 @@ namespace Catch {
cli["-d"]["--durations"] cli["-d"]["--durations"]
.describe( "show test durations" ) .describe( "show test durations" )
.bind( &setShowDurations, "yes/no" ); .bind( &setShowDurations, "yes|no" );
cli["-f"]["--input-file"] cli["-f"]["--input-file"]
.describe( "load test names to run from a file" ) .describe( "load test names to run from a file" )
@@ -176,8 +191,12 @@ namespace Catch {
.bind( &setRngSeed, "'time'|number" ); .bind( &setRngSeed, "'time'|number" );
cli["--force-colour"] cli["--force-colour"]
.describe( "force colourised output" ) .describe( "force colourised output (deprecated)" )
.bind( &ConfigData::forceColour ); .bind( &forceColour );
cli["--use-colour"]
.describe( "should output be colourised" )
.bind( &setUseColour, "yes|no" );
return cli; return cli;
} }

View File

@@ -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 )
#define INTERNAL_CATCH_UNIQUE_NAME( name ) INTERNAL_CATCH_UNIQUE_NAME_LINE( 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__ )
#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 )

View File

@@ -23,7 +23,7 @@
// 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 // Note to maintainers: if new toggles are added please document them
// in configuration.md, too // in configuration.md, too
@@ -36,6 +36,18 @@
// All the C++11 features can be disabled with CATCH_CONFIG_NO_CPP11 // All the C++11 features can be disabled with CATCH_CONFIG_NO_CPP11
#ifdef __cplusplus
# if __cplusplus >= 201103L
# define CATCH_CPP11_OR_GREATER
# endif
# if __cplusplus >= 201402L
# define CATCH_CPP14_OR_GREATER
# endif
#endif
#ifdef __clang__ #ifdef __clang__
# if __has_feature(cxx_nullptr) # if __has_feature(cxx_nullptr)
@@ -46,6 +58,10 @@
# define CATCH_INTERNAL_CONFIG_CPP11_NOEXCEPT # define CATCH_INTERNAL_CONFIG_CPP11_NOEXCEPT
# endif # endif
# if defined(CATCH_CPP11_OR_GREATER)
# define CATCH_INTERNAL_SUPPRESS_PARENTHESES_WARNINGS _Pragma( "clang diagnostic ignored \"-Wparentheses\"" )
# endif
#endif // __clang__ #endif // __clang__
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
@@ -73,9 +89,13 @@
// GCC // GCC
#ifdef __GNUC__ #ifdef __GNUC__
#if __GNUC__ == 4 && __GNUC_MINOR__ >= 6 && defined(__GXX_EXPERIMENTAL_CXX0X__) # if __GNUC__ == 4 && __GNUC_MINOR__ >= 6 && defined(__GXX_EXPERIMENTAL_CXX0X__)
# define CATCH_INTERNAL_CONFIG_CPP11_NULLPTR # define CATCH_INTERNAL_CONFIG_CPP11_NULLPTR
#endif # endif
# if !defined(CATCH_INTERNAL_SUPPRESS_PARENTHESES_WARNINGS) && defined(CATCH_CPP11_OR_GREATER)
# define CATCH_INTERNAL_SUPPRESS_PARENTHESES_WARNINGS _Pragma( "GCC diagnostic ignored \"-Wparentheses\"" )
# endif
// - otherwise more recent versions define __cplusplus >= 201103L // - otherwise more recent versions define __cplusplus >= 201103L
// and will get picked up below // and will get picked up below
@@ -111,13 +131,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 defined(__cplusplus) && __cplusplus >= 201103L #if defined(CATCH_CPP11_OR_GREATER)
# define CATCH_CPP11_OR_GREATER
# if !defined(CATCH_INTERNAL_CONFIG_CPP11_NULLPTR) # if !defined(CATCH_INTERNAL_CONFIG_CPP11_NULLPTR)
# define CATCH_INTERNAL_CONFIG_CPP11_NULLPTR # define CATCH_INTERNAL_CONFIG_CPP11_NULLPTR
@@ -185,7 +212,13 @@
#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) #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 # define CATCH_CONFIG_CPP11_UNIQUE_PTR
#endif #endif
#if defined(CATCH_INTERNAL_CONFIG_COUNTER) && !defined(CATCH_CONFIG_NO_COUNTER) && !defined(CATCH_CONFIG_COUNTER)
# define CATCH_CONFIG_COUNTER
#endif
#if !defined(CATCH_INTERNAL_SUPPRESS_PARENTHESES_WARNINGS)
# define CATCH_INTERNAL_SUPPRESS_PARENTHESES_WARNINGS
#endif
// noexcept support: // noexcept support:
#if defined(CATCH_CONFIG_CPP11_NOEXCEPT) && !defined(CATCH_NOEXCEPT) #if defined(CATCH_CONFIG_CPP11_NOEXCEPT) && !defined(CATCH_NOEXCEPT)

View File

@@ -37,14 +37,14 @@ namespace Catch {
noThrow( false ), noThrow( false ),
showHelp( false ), showHelp( false ),
showInvisibles( false ), showInvisibles( false ),
forceColour( false ),
filenamesAsTags( false ), filenamesAsTags( false ),
abortAfter( -1 ), abortAfter( -1 ),
rngSeed( 0 ), rngSeed( 0 ),
verbosity( Verbosity::Normal ), verbosity( Verbosity::Normal ),
warnings( WarnAbout::Nothing ), warnings( WarnAbout::Nothing ),
showDurations( ShowDurations::DefaultForReporter ), showDurations( ShowDurations::DefaultForReporter ),
runOrder( RunTests::InDeclarationOrder ) runOrder( RunTests::InDeclarationOrder ),
useColour( UseColour::Auto )
{} {}
bool listTests; bool listTests;
@@ -57,7 +57,6 @@ namespace Catch {
bool noThrow; bool noThrow;
bool showHelp; bool showHelp;
bool showInvisibles; bool showInvisibles;
bool forceColour;
bool filenamesAsTags; bool filenamesAsTags;
int abortAfter; int abortAfter;
@@ -67,6 +66,7 @@ namespace Catch {
WarnAbout::What warnings; WarnAbout::What warnings;
ShowDurations::OrNot showDurations; ShowDurations::OrNot showDurations;
RunTests::InWhatOrder runOrder; RunTests::InWhatOrder runOrder;
UseColour::YesOrNo useColour;
std::string outputFilename; std::string outputFilename;
std::string name; std::string name;
@@ -133,7 +133,7 @@ namespace Catch {
virtual ShowDurations::OrNot showDurations() const { return m_data.showDurations; } virtual ShowDurations::OrNot showDurations() const { return m_data.showDurations; }
virtual RunTests::InWhatOrder runOrder() const { return m_data.runOrder; } virtual RunTests::InWhatOrder runOrder() const { return m_data.runOrder; }
virtual unsigned int rngSeed() const { return m_data.rngSeed; } virtual unsigned int rngSeed() const { return m_data.rngSeed; }
virtual bool forceColour() const { return m_data.forceColour; } virtual UseColour::YesOrNo useColour() const { return m_data.useColour; }
private: private:
@@ -151,7 +151,7 @@ namespace Catch {
} }
ConfigData m_data; ConfigData m_data;
std::auto_ptr<IStream const> m_stream; CATCH_AUTO_PTR( IStream const ) m_stream;
TestSpec m_testSpec; TestSpec m_testSpec;
}; };

View File

@@ -95,7 +95,18 @@ namespace {
IColourImpl* platformColourInstance() { IColourImpl* platformColourInstance() {
static Win32ColourImpl s_instance; static Win32ColourImpl s_instance;
return &s_instance;
Ptr<IConfig const> config = getCurrentContext().getConfig();
UseColour::YesOrNo colourMode = config
? config->useColour()
: UseColour::Auto;
if( colourMode == UseColour::Auto )
colourMode = !isDebuggerActive()
? UseColour::Yes
: UseColour::No;
return colourMode == UseColour::Yes
? &s_instance
: NoColourImpl::instance();
} }
} // end anon namespace } // end anon namespace
@@ -146,7 +157,14 @@ namespace {
IColourImpl* platformColourInstance() { IColourImpl* platformColourInstance() {
Ptr<IConfig const> config = getCurrentContext().getConfig(); Ptr<IConfig const> config = getCurrentContext().getConfig();
return (config && config->forceColour()) || isatty(STDOUT_FILENO) UseColour::YesOrNo colourMode = config
? config->useColour()
: UseColour::Auto;
if( colourMode == UseColour::Auto )
colourMode = (!isDebuggerActive() && isatty(STDOUT_FILENO) )
? UseColour::Yes
: UseColour::No;
return colourMode == UseColour::Yes
? PosixColourImpl::instance() ? PosixColourImpl::instance()
: NoColourImpl::instance(); : NoColourImpl::instance();
} }
@@ -171,9 +189,7 @@ namespace Catch {
Colour::~Colour(){ if( !m_moved ) use( None ); } Colour::~Colour(){ if( !m_moved ) use( None ); }
void Colour::use( Code _colourCode ) { void Colour::use( Code _colourCode ) {
static IColourImpl* impl = isDebuggerActive() static IColourImpl* impl = platformColourInstance();
? NoColourImpl::instance()
: platformColourInstance();
impl->use( _colourCode ); impl->use( _colourCode );
} }

View File

@@ -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 );
} }

View File

@@ -52,37 +52,37 @@ namespace Internal {
template<typename T1, typename T2> template<typename T1, typename T2>
struct Evaluator<T1, T2, IsEqualTo> { struct Evaluator<T1, T2, IsEqualTo> {
static bool evaluate( T1 const& lhs, T2 const& rhs) { static bool evaluate( T1 const& lhs, T2 const& rhs) {
return opCast( lhs ) == opCast( rhs ); return bool( opCast( lhs ) == opCast( rhs ) );
} }
}; };
template<typename T1, typename T2> template<typename T1, typename T2>
struct Evaluator<T1, T2, IsNotEqualTo> { struct Evaluator<T1, T2, IsNotEqualTo> {
static bool evaluate( T1 const& lhs, T2 const& rhs ) { static bool evaluate( T1 const& lhs, T2 const& rhs ) {
return opCast( lhs ) != opCast( rhs ); return bool( opCast( lhs ) != opCast( rhs ) );
} }
}; };
template<typename T1, typename T2> template<typename T1, typename T2>
struct Evaluator<T1, T2, IsLessThan> { struct Evaluator<T1, T2, IsLessThan> {
static bool evaluate( T1 const& lhs, T2 const& rhs ) { static bool evaluate( T1 const& lhs, T2 const& rhs ) {
return opCast( lhs ) < opCast( rhs ); return bool( opCast( lhs ) < opCast( rhs ) );
} }
}; };
template<typename T1, typename T2> template<typename T1, typename T2>
struct Evaluator<T1, T2, IsGreaterThan> { struct Evaluator<T1, T2, IsGreaterThan> {
static bool evaluate( T1 const& lhs, T2 const& rhs ) { static bool evaluate( T1 const& lhs, T2 const& rhs ) {
return opCast( lhs ) > opCast( rhs ); return bool( opCast( lhs ) > opCast( rhs ) );
} }
}; };
template<typename T1, typename T2> template<typename T1, typename T2>
struct Evaluator<T1, T2, IsGreaterThanOrEqualTo> { struct Evaluator<T1, T2, IsGreaterThanOrEqualTo> {
static bool evaluate( T1 const& lhs, T2 const& rhs ) { static bool evaluate( T1 const& lhs, T2 const& rhs ) {
return opCast( lhs ) >= opCast( rhs ); return bool( opCast( lhs ) >= opCast( rhs ) );
} }
}; };
template<typename T1, typename T2> template<typename T1, typename T2>
struct Evaluator<T1, T2, IsLessThanOrEqualTo> { struct Evaluator<T1, T2, IsLessThanOrEqualTo> {
static bool evaluate( T1 const& lhs, T2 const& rhs ) { static bool evaluate( T1 const& lhs, T2 const& rhs ) {
return opCast( lhs ) <= opCast( rhs ); return bool( opCast( lhs ) <= opCast( rhs ) );
} }
}; };

View File

@@ -37,6 +37,11 @@ namespace Catch {
InLexicographicalOrder, InLexicographicalOrder,
InRandomOrder InRandomOrder
}; }; }; };
struct UseColour { enum YesOrNo {
Auto,
Yes,
No
}; };
class TestSpec; class TestSpec;
@@ -56,7 +61,7 @@ namespace Catch {
virtual TestSpec const& testSpec() const = 0; virtual TestSpec const& testSpec() const = 0;
virtual RunTests::InWhatOrder runOrder() const = 0; virtual RunTests::InWhatOrder runOrder() const = 0;
virtual unsigned int rngSeed() const = 0; virtual unsigned int rngSeed() const = 0;
virtual bool forceColour() const = 0; virtual UseColour::YesOrNo useColour() const = 0;
}; };
} }

View File

@@ -19,7 +19,7 @@ namespace Catch {
struct IExceptionTranslator; struct IExceptionTranslator;
typedef std::vector<const IExceptionTranslator*> ExceptionTranslators; typedef std::vector<const IExceptionTranslator*> ExceptionTranslators;
struct IExceptionTranslator { struct IExceptionTranslator {
virtual ~IExceptionTranslator(); virtual ~IExceptionTranslator();
virtual std::string translate( ExceptionTranslators::const_iterator it, ExceptionTranslators::const_iterator itEnd ) const = 0; virtual std::string translate( ExceptionTranslators::const_iterator it, ExceptionTranslators::const_iterator itEnd ) const = 0;
@@ -66,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

View File

@@ -219,6 +219,7 @@ namespace Catch
bool aborting; bool aborting;
}; };
class MultipleReporters;
struct IStreamingReporter : IShared { struct IStreamingReporter : IShared {
virtual ~IStreamingReporter(); virtual ~IStreamingReporter();
@@ -247,6 +248,8 @@ namespace Catch
virtual void testRunEnded( TestRunStats const& testRunStats ) = 0; virtual void testRunEnded( TestRunStats const& testRunStats ) = 0;
virtual void skipTest( TestCaseInfo const& testInfo ) = 0; virtual void skipTest( TestCaseInfo const& testInfo ) = 0;
virtual MultipleReporters* tryAsMulti() { return CATCH_NULL; }
}; };

View File

@@ -17,7 +17,7 @@ namespace Matchers {
template<typename ExpressionT> class AnyOf; template<typename ExpressionT> class AnyOf;
template<typename ExpressionT> class Not; template<typename ExpressionT> class Not;
} }
template<typename ExpressionT> template<typename ExpressionT>
struct Matcher : SharedImpl<IShared> struct Matcher : SharedImpl<IShared>
{ {
@@ -27,7 +27,7 @@ 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::AllOf<ExpressionT> operator && ( Matcher<ExpressionT> const& other ) const;
Generic::AnyOf<ExpressionT> operator || ( Matcher<ExpressionT> const& other ) const; Generic::AnyOf<ExpressionT> operator || ( Matcher<ExpressionT> const& other ) const;
Generic::Not<ExpressionT> operator ! () const; Generic::Not<ExpressionT> operator ! () const;
@@ -134,13 +134,13 @@ namespace Matchers {
anyOfExpr.add( other ); anyOfExpr.add( other );
return anyOfExpr; return anyOfExpr;
} }
private: private:
std::vector<Ptr<Matcher<ExpressionT> > > m_matchers; std::vector<Ptr<Matcher<ExpressionT> > > m_matchers;
}; };
} // namespace Generic } // namespace Generic
template<typename ExpressionT> template<typename ExpressionT>
Generic::AllOf<ExpressionT> Matcher<ExpressionT>::operator && ( Matcher<ExpressionT> const& other ) const { Generic::AllOf<ExpressionT> Matcher<ExpressionT>::operator && ( Matcher<ExpressionT> const& other ) const {
Generic::AllOf<ExpressionT> allOfExpr; Generic::AllOf<ExpressionT> allOfExpr;
@@ -161,7 +161,7 @@ namespace Matchers {
Generic::Not<ExpressionT> Matcher<ExpressionT>::operator ! () const { Generic::Not<ExpressionT> Matcher<ExpressionT>::operator ! () const {
return Generic::Not<ExpressionT>( *this ); return Generic::Not<ExpressionT>( *this );
} }
namespace StdString { namespace StdString {
@@ -234,7 +234,7 @@ namespace Matchers {
virtual ~StartsWith(); virtual ~StartsWith();
virtual bool match( std::string const& expr ) const { virtual bool match( std::string const& expr ) const {
return m_data.adjustString( expr ).find( m_data.m_str ) == 0; return startsWith( m_data.adjustString( expr ), m_data.m_str );
} }
virtual std::string toString() const { virtual std::string toString() const {
return "starts with: \"" + m_data.m_str + "\"" + m_data.toStringSuffix(); return "starts with: \"" + m_data.m_str + "\"" + m_data.toStringSuffix();
@@ -251,7 +251,7 @@ namespace Matchers {
virtual ~EndsWith(); virtual ~EndsWith();
virtual bool match( std::string const& expr ) const { virtual bool match( std::string const& expr ) const {
return m_data.adjustString( expr ).find( m_data.m_str ) == expr.size() - m_data.m_str.size(); return endsWith( m_data.adjustString( expr ), m_data.m_str );
} }
virtual std::string toString() const { virtual std::string toString() const {
return "ends with: \"" + m_data.m_str + "\"" + m_data.toStringSuffix(); return "ends with: \"" + m_data.m_str + "\"" + m_data.toStringSuffix();

View File

@@ -109,6 +109,11 @@ namespace Catch {
while( getCurrentContext().advanceGeneratorsForCurrentTest() && !aborting() ); while( getCurrentContext().advanceGeneratorsForCurrentTest() && !aborting() );
Totals deltaTotals = m_totals.delta( prevTotals ); Totals deltaTotals = m_totals.delta( prevTotals );
if( testInfo.expectedToFail() && deltaTotals.testCases.passed > 0 ) {
deltaTotals.assertions.failed++;
deltaTotals.testCases.passed--;
deltaTotals.testCases.failed++;
}
m_totals.testCases += deltaTotals.testCases; m_totals.testCases += deltaTotals.testCases;
m_reporter->testCaseEnded( TestCaseStats( testInfo, m_reporter->testCaseEnded( TestCaseStats( testInfo,
deltaTotals, deltaTotals,

View File

@@ -49,7 +49,7 @@ namespace Catch {
class DebugOutStream : public IStream { class DebugOutStream : public IStream {
std::auto_ptr<StreamBufBase> m_streamBuf; CATCH_AUTO_PTR( StreamBufBase ) m_streamBuf;
mutable std::ostream m_os; mutable std::ostream m_os;
public: public:
DebugOutStream(); DebugOutStream();

View File

@@ -19,13 +19,30 @@
#include <iostream> #include <iostream>
#include <algorithm> #include <algorithm>
namespace Catch { #ifdef CATCH_CPP14_OR_GREATER
#include <random>
#endif
struct LexSort { namespace Catch {
bool operator() (TestCase i,TestCase j) const { return (i<j);}
};
struct RandomNumberGenerator { struct RandomNumberGenerator {
int operator()( int n ) const { return std::rand() % n; } typedef int result_type;
result_type operator()( result_type n ) const { return std::rand() % n; }
#ifdef CATCH_CPP14_OR_GREATER
static constexpr result_type min() { return 0; }
static constexpr result_type max() { return 1000000; }
result_type operator()() const { return std::rand() % max(); }
#endif
template<typename V>
static void shuffle( V& vector ) {
#ifdef CATCH_CPP14_OR_GREATER
std::shuffle( vector.begin(), vector.end(), RandomNumberGenerator() );
#else
std::random_shuffle( vector.begin(), vector.end(), RandomNumberGenerator() );
#endif
}
}; };
inline std::vector<TestCase> sortTests( IConfig const& config, std::vector<TestCase> const& unsortedTestCases ) { inline std::vector<TestCase> sortTests( IConfig const& config, std::vector<TestCase> const& unsortedTestCases ) {
@@ -34,14 +51,12 @@ namespace Catch {
switch( config.runOrder() ) { switch( config.runOrder() ) {
case RunTests::InLexicographicalOrder: case RunTests::InLexicographicalOrder:
std::sort( sorted.begin(), sorted.end(), LexSort() ); std::sort( sorted.begin(), sorted.end() );
break; break;
case RunTests::InRandomOrder: case RunTests::InRandomOrder:
{ {
seedRng( config ); seedRng( config );
RandomNumberGenerator::shuffle( sorted );
RandomNumberGenerator rng;
std::random_shuffle( sorted.begin(), sorted.end(), rng );
} }
break; break;
case RunTests::InDeclarationOrder: case RunTests::InDeclarationOrder:
@@ -60,13 +75,15 @@ namespace Catch {
it != itEnd; it != itEnd;
++it ) { ++it ) {
std::pair<std::set<TestCase>::const_iterator, bool> prev = seenFunctions.insert( *it ); std::pair<std::set<TestCase>::const_iterator, bool> prev = seenFunctions.insert( *it );
if( !prev.second ){ if( !prev.second ) {
Catch::cerr() std::ostringstream ss;
<< Colour( Colour::Red )
<< "error: TEST_CASE( \"" << it->name << "\" ) already defined.\n" ss << Colour( Colour::Red )
<< "\tFirst seen at " << prev.first->getTestCaseInfo().lineInfo << "\n" << "error: TEST_CASE( \"" << it->name << "\" ) already defined.\n"
<< "\tRedefined at " << it->getTestCaseInfo().lineInfo << std::endl; << "\tFirst seen at " << prev.first->getTestCaseInfo().lineInfo << "\n"
exit(1); << "\tRedefined at " << it->getTestCaseInfo().lineInfo << std::endl;
throw std::runtime_error(ss.str());
} }
} }
} }
@@ -87,7 +104,10 @@ namespace Catch {
class TestRegistry : public ITestCaseRegistry { 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 ) {
@@ -157,7 +177,7 @@ namespace Catch {
char const* classOrQualifiedMethodName, char const* classOrQualifiedMethodName,
NameAndDesc const& nameAndDesc, NameAndDesc const& nameAndDesc,
SourceLineInfo const& lineInfo ) { SourceLineInfo const& lineInfo ) {
getMutableRegistryHub().registerTest getMutableRegistryHub().registerTest
( makeTestCase ( makeTestCase
( testCase, ( testCase,
@@ -172,7 +192,7 @@ namespace Catch {
NameAndDesc const& nameAndDesc ) { NameAndDesc const& nameAndDesc ) {
registerTestCase( new FreeFunctionTestCase( function ), "", nameAndDesc, lineInfo ); registerTestCase( new FreeFunctionTestCase( function ), "", nameAndDesc, lineInfo );
} }
/////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////
AutoReg::AutoReg AutoReg::AutoReg

View File

@@ -41,6 +41,10 @@ namespace TestCaseTracking {
virtual void addChild( Ptr<ITracker> const& child ) = 0; virtual void addChild( Ptr<ITracker> const& child ) = 0;
virtual ITracker* findChild( std::string const& name ) = 0; virtual ITracker* findChild( std::string const& name ) = 0;
virtual void openChild() = 0; virtual void openChild() = 0;
// Debug/ checking
virtual bool isSectionTracker() const = 0;
virtual bool isIndexTracker() const = 0;
}; };
class TrackerContext { class TrackerContext {
@@ -167,6 +171,10 @@ namespace TestCaseTracking {
m_parent->openChild(); m_parent->openChild();
} }
} }
virtual bool isSectionTracker() const CATCH_OVERRIDE { return false; }
virtual bool isIndexTracker() const CATCH_OVERRIDE { return false; }
void open() { void open() {
m_runState = Executing; m_runState = Executing;
moveToThis(); moveToThis();
@@ -230,13 +238,16 @@ namespace TestCaseTracking {
{} {}
virtual ~SectionTracker(); virtual ~SectionTracker();
virtual bool isSectionTracker() const CATCH_OVERRIDE { return true; }
static SectionTracker& acquire( TrackerContext& ctx, std::string const& name ) { static SectionTracker& acquire( TrackerContext& ctx, std::string const& name ) {
SectionTracker* section = CATCH_NULL; SectionTracker* section = CATCH_NULL;
ITracker& currentTracker = ctx.currentTracker(); ITracker& currentTracker = ctx.currentTracker();
if( ITracker* childTracker = currentTracker.findChild( name ) ) { if( ITracker* childTracker = currentTracker.findChild( name ) ) {
section = dynamic_cast<SectionTracker*>( childTracker ); assert( childTracker );
assert( section ); assert( childTracker->isSectionTracker() );
section = static_cast<SectionTracker*>( childTracker );
} }
else { else {
section = new SectionTracker( name, ctx, &currentTracker ); section = new SectionTracker( name, ctx, &currentTracker );
@@ -261,13 +272,16 @@ namespace TestCaseTracking {
{} {}
virtual ~IndexTracker(); virtual ~IndexTracker();
virtual bool isIndexTracker() const CATCH_OVERRIDE { return true; }
static IndexTracker& acquire( TrackerContext& ctx, std::string const& name, int size ) { static IndexTracker& acquire( TrackerContext& ctx, std::string const& name, int size ) {
IndexTracker* tracker = CATCH_NULL; IndexTracker* tracker = CATCH_NULL;
ITracker& currentTracker = ctx.currentTracker(); ITracker& currentTracker = ctx.currentTracker();
if( ITracker* childTracker = currentTracker.findChild( name ) ) { if( ITracker* childTracker = currentTracker.findChild( name ) ) {
tracker = dynamic_cast<IndexTracker*>( childTracker ); assert( childTracker );
assert( tracker ); assert( childTracker->isIndexTracker() );
tracker = static_cast<IndexTracker*>( childTracker );
} }
else { else {
tracker = new IndexTracker( name, ctx, &currentTracker, size ); tracker = new IndexTracker( name, ctx, &currentTracker, size );

View File

@@ -85,24 +85,28 @@ void registerTestCaseFunction
#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, ... ) \ #define INTERNAL_CATCH_REGISTER_TESTCASE( Function, ... ) \
@@ -110,24 +114,28 @@ void registerTestCaseFunction
#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 ) \ #define INTERNAL_CATCH_REGISTER_TESTCASE( Function, Name, Desc ) \

View File

@@ -37,7 +37,7 @@ namespace Catch {
return os; return os;
} }
Version libraryVersion( 1, 3, 0, "", 0 ); Version libraryVersion( 1, 5, 5, "", 0 );
} }

View File

@@ -166,7 +166,7 @@ namespace Catch {
virtual void assertionStarting( AssertionInfo const& ) CATCH_OVERRIDE {} virtual void assertionStarting( AssertionInfo const& ) CATCH_OVERRIDE {}
virtual bool assertionEnded( AssertionStats const& assertionStats ) { virtual bool assertionEnded( AssertionStats const& assertionStats ) CATCH_OVERRIDE {
assert( !m_sectionStack.empty() ); assert( !m_sectionStack.empty() );
SectionNode& sectionNode = *m_sectionStack.back(); SectionNode& sectionNode = *m_sectionStack.back();
sectionNode.assertions.push_back( assertionStats ); sectionNode.assertions.push_back( assertionStats );

View File

@@ -349,7 +349,7 @@ namespace Catch {
if( totals.testCases.total() == 0 ) { if( totals.testCases.total() == 0 ) {
stream << Colour( Colour::Warning ) << "No tests ran\n"; stream << Colour( Colour::Warning ) << "No tests ran\n";
} }
else if( totals.assertions.total() > 0 && totals.assertions.allPassed() ) { else if( totals.assertions.total() > 0 && totals.testCases.allPassed() ) {
stream << Colour( Colour::ResultSuccess ) << "All tests passed"; stream << Colour( Colour::ResultSuccess ) << "All tests passed";
stream << " (" stream << " ("
<< pluralise( totals.assertions.passed, "assertion" ) << " in " << pluralise( totals.assertions.passed, "assertion" ) << " in "

View File

@@ -118,13 +118,18 @@ public: // IStreamingReporter
++it ) ++it )
(*it)->skipTest( testInfo ); (*it)->skipTest( testInfo );
} }
virtual MultipleReporters* tryAsMulti() CATCH_OVERRIDE {
return this;
}
}; };
Ptr<IStreamingReporter> addReporter( Ptr<IStreamingReporter> const& existingReporter, Ptr<IStreamingReporter> const& additionalReporter ) { Ptr<IStreamingReporter> addReporter( Ptr<IStreamingReporter> const& existingReporter, Ptr<IStreamingReporter> const& additionalReporter ) {
Ptr<IStreamingReporter> resultingReporter; Ptr<IStreamingReporter> resultingReporter;
if( existingReporter ) { if( existingReporter ) {
MultipleReporters* multi = dynamic_cast<MultipleReporters*>( existingReporter.get() ); MultipleReporters* multi = existingReporter->tryAsMulti();
if( !multi ) { if( !multi ) {
multi = new MultipleReporters; multi = new MultipleReporters;
resultingReporter = Ptr<IStreamingReporter>( multi ); resultingReporter = Ptr<IStreamingReporter>( multi );

View File

@@ -680,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"
@@ -691,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"
@@ -702,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"
@@ -713,7 +713,7 @@ 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"
@@ -724,7 +724,7 @@ MiscTests.cpp:<line number>
............................................................................... ...............................................................................
MiscTests.cpp:<line number>: FAILED: MiscTests.cpp:<line number>: FAILED:
CHECK_THAT( testStringForMatching() ( Contains( "string" ) || Contains( "different" ) ) && Contains( "random" ) ) CHECK_THAT( testStringForMatching(), ( Contains( "string" ) || Contains( "different" ) ) && Contains( "random" ) )
with expansion: with expansion:
"this string contains 'abc' as a substring" ( ( contains: "string" or "this string contains 'abc' as a substring" ( ( contains: "string" or
contains: "different" ) and contains: "random" ) contains: "different" ) and contains: "random" )
@@ -736,7 +736,7 @@ MiscTests.cpp:<line number>
............................................................................... ...............................................................................
MiscTests.cpp:<line number>: FAILED: MiscTests.cpp:<line number>: FAILED:
CHECK_THAT( testStringForMatching() !Contains( "substring" ) ) CHECK_THAT( testStringForMatching(), !Contains( "substring" ) )
with expansion: with expansion:
"this string contains 'abc' as a substring" not contains: "substring" "this string contains 'abc' as a substring" not contains: "substring"
@@ -830,6 +830,6 @@ with expansion:
"first" == "second" "first" == "second"
=============================================================================== ===============================================================================
test cases: 167 | 124 passed | 42 failed | 1 failed as expected test cases: 168 | 124 passed | 42 failed | 2 failed as expected
assertions: 914 | 818 passed | 83 failed | 13 failed as expected assertions: 920 | 824 passed | 78 failed | 18 failed as expected

View File

@@ -3304,25 +3304,25 @@ MiscTests.cpp:<line number>
MiscTests.cpp:<line number>: MiscTests.cpp:<line number>:
PASSED: PASSED:
REQUIRE_THAT( testStringForMatching() Contains( "string" ) ) REQUIRE_THAT( testStringForMatching(), Contains( "string" ) )
with expansion: with expansion:
"this string contains 'abc' as a substring" contains: "string" "this string contains 'abc' as a substring" contains: "string"
MiscTests.cpp:<line number>: MiscTests.cpp:<line number>:
PASSED: PASSED:
CHECK_THAT( testStringForMatching() Contains( "abc" ) ) CHECK_THAT( testStringForMatching(), Contains( "abc" ) )
with expansion: with expansion:
"this string contains 'abc' as a substring" contains: "abc" "this string contains 'abc' as a substring" contains: "abc"
MiscTests.cpp:<line number>: MiscTests.cpp:<line number>:
PASSED: PASSED:
CHECK_THAT( testStringForMatching() StartsWith( "this" ) ) CHECK_THAT( testStringForMatching(), StartsWith( "this" ) )
with expansion: with expansion:
"this string contains 'abc' as a substring" starts with: "this" "this string contains 'abc' as a substring" starts with: "this"
MiscTests.cpp:<line number>: MiscTests.cpp:<line number>:
PASSED: PASSED:
CHECK_THAT( testStringForMatching() EndsWith( "substring" ) ) CHECK_THAT( testStringForMatching(), EndsWith( "substring" ) )
with expansion: with expansion:
"this string contains 'abc' as a substring" ends with: "substring" "this string contains 'abc' as a substring" ends with: "substring"
@@ -3333,7 +3333,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"
@@ -3344,7 +3344,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"
@@ -3355,7 +3355,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"
@@ -3366,7 +3366,7 @@ 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"
@@ -3378,7 +3378,7 @@ MiscTests.cpp:<line number>
MiscTests.cpp:<line number>: MiscTests.cpp:<line number>:
PASSED: PASSED:
REQUIRE_THAT( "" Equals(nullptr) ) REQUIRE_THAT( "", Equals(nullptr) )
with expansion: with expansion:
"" equals: "" "" equals: ""
@@ -3390,7 +3390,7 @@ MiscTests.cpp:<line number>
MiscTests.cpp:<line number>: MiscTests.cpp:<line number>:
PASSED: PASSED:
CHECK_THAT( testStringForMatching() AllOf( Catch::Contains( "string" ), Catch::Contains( "abc" ) ) ) CHECK_THAT( testStringForMatching(), AllOf( Catch::Contains( "string" ), Catch::Contains( "abc" ) ) )
with expansion: with expansion:
"this string contains 'abc' as a substring" ( contains: "string" and "this string contains 'abc' as a substring" ( contains: "string" and
contains: "abc" ) contains: "abc" )
@@ -3403,14 +3403,14 @@ MiscTests.cpp:<line number>
MiscTests.cpp:<line number>: MiscTests.cpp:<line number>:
PASSED: PASSED:
CHECK_THAT( testStringForMatching() AnyOf( Catch::Contains( "string" ), Catch::Contains( "not there" ) ) ) CHECK_THAT( testStringForMatching(), AnyOf( Catch::Contains( "string" ), Catch::Contains( "not there" ) ) )
with expansion: with expansion:
"this string contains 'abc' as a substring" ( contains: "string" or contains: "this string contains 'abc' as a substring" ( contains: "string" or contains:
"not there" ) "not there" )
MiscTests.cpp:<line number>: MiscTests.cpp:<line number>:
PASSED: PASSED:
CHECK_THAT( testStringForMatching() AnyOf( Catch::Contains( "not there" ), Catch::Contains( "string" ) ) ) CHECK_THAT( testStringForMatching(), AnyOf( Catch::Contains( "not there" ), Catch::Contains( "string" ) ) )
with expansion: with expansion:
"this string contains 'abc' as a substring" ( contains: "not there" or "this string contains 'abc' as a substring" ( contains: "not there" or
contains: "string" ) contains: "string" )
@@ -3423,7 +3423,7 @@ MiscTests.cpp:<line number>
MiscTests.cpp:<line number>: MiscTests.cpp:<line number>:
PASSED: PASSED:
CHECK_THAT( testStringForMatching() Equals( "this string contains 'abc' as a substring" ) ) CHECK_THAT( testStringForMatching(), Equals( "this string contains 'abc' as a substring" ) )
with expansion: with expansion:
"this string contains 'abc' as a substring" equals: "this string contains "this string contains 'abc' as a substring" equals: "this string contains
'abc' as a substring" 'abc' as a substring"
@@ -3436,7 +3436,7 @@ MiscTests.cpp:<line number>
MiscTests.cpp:<line number>: MiscTests.cpp:<line number>:
PASSED: PASSED:
CHECK_THAT( testStringForMatching() Contains( "string" ) && Contains( "abc" ) && Contains( "substring" ) && Contains( "contains" ) ) CHECK_THAT( testStringForMatching(), Contains( "string" ) && Contains( "abc" ) && Contains( "substring" ) && Contains( "contains" ) )
with expansion: with expansion:
"this string contains 'abc' as a substring" ( contains: "string" and "this string contains 'abc' as a substring" ( contains: "string" and
contains: "abc" and contains: "substring" and contains: "contains" ) contains: "abc" and contains: "substring" and contains: "contains" )
@@ -3449,14 +3449,14 @@ MiscTests.cpp:<line number>
MiscTests.cpp:<line number>: MiscTests.cpp:<line number>:
PASSED: PASSED:
CHECK_THAT( testStringForMatching() Contains( "string" ) || Contains( "different" ) || Contains( "random" ) ) CHECK_THAT( testStringForMatching(), Contains( "string" ) || Contains( "different" ) || Contains( "random" ) )
with expansion: with expansion:
"this string contains 'abc' as a substring" ( contains: "string" or contains: "this string contains 'abc' as a substring" ( contains: "string" or contains:
"different" or contains: "random" ) "different" or contains: "random" )
MiscTests.cpp:<line number>: MiscTests.cpp:<line number>:
PASSED: PASSED:
CHECK_THAT( testStringForMatching2() Contains( "string" ) || Contains( "different" ) || Contains( "random" ) ) CHECK_THAT( testStringForMatching2(), Contains( "string" ) || Contains( "different" ) || Contains( "random" ) )
with expansion: with expansion:
"some completely different text that contains one common word" ( contains: "some completely different text that contains one common word" ( contains:
"string" or contains: "different" or contains: "random" ) "string" or contains: "different" or contains: "random" )
@@ -3469,7 +3469,7 @@ MiscTests.cpp:<line number>
MiscTests.cpp:<line number>: MiscTests.cpp:<line number>:
PASSED: PASSED:
CHECK_THAT( testStringForMatching() ( Contains( "string" ) || Contains( "different" ) ) && Contains( "substring" ) ) CHECK_THAT( testStringForMatching(), ( Contains( "string" ) || Contains( "different" ) ) && Contains( "substring" ) )
with expansion: with expansion:
"this string contains 'abc' as a substring" ( ( contains: "string" or "this string contains 'abc' as a substring" ( ( contains: "string" or
contains: "different" ) and contains: "substring" ) contains: "different" ) and contains: "substring" )
@@ -3481,7 +3481,7 @@ MiscTests.cpp:<line number>
............................................................................... ...............................................................................
MiscTests.cpp:<line number>: FAILED: MiscTests.cpp:<line number>: FAILED:
CHECK_THAT( testStringForMatching() ( Contains( "string" ) || Contains( "different" ) ) && Contains( "random" ) ) CHECK_THAT( testStringForMatching(), ( Contains( "string" ) || Contains( "different" ) ) && Contains( "random" ) )
with expansion: with expansion:
"this string contains 'abc' as a substring" ( ( contains: "string" or "this string contains 'abc' as a substring" ( ( contains: "string" or
contains: "different" ) and contains: "random" ) contains: "different" ) and contains: "random" )
@@ -3494,7 +3494,7 @@ MiscTests.cpp:<line number>
MiscTests.cpp:<line number>: MiscTests.cpp:<line number>:
PASSED: PASSED:
CHECK_THAT( testStringForMatching() !Contains( "different" ) ) CHECK_THAT( testStringForMatching(), !Contains( "different" ) )
with expansion: with expansion:
"this string contains 'abc' as a substring" not contains: "different" "this string contains 'abc' as a substring" not contains: "different"
@@ -3505,7 +3505,7 @@ MiscTests.cpp:<line number>
............................................................................... ...............................................................................
MiscTests.cpp:<line number>: FAILED: MiscTests.cpp:<line number>: FAILED:
CHECK_THAT( testStringForMatching() !Contains( "substring" ) ) CHECK_THAT( testStringForMatching(), !Contains( "substring" ) )
with expansion: with expansion:
"this string contains 'abc' as a substring" not contains: "substring" "this string contains 'abc' as a substring" not contains: "substring"
@@ -3951,6 +3951,17 @@ with expansion:
== ==
9223372036854775807 (0x<hex digits>) 9223372036854775807 (0x<hex digits>)
-------------------------------------------------------------------------------
This test 'should' fail but doesn't
-------------------------------------------------------------------------------
MiscTests.cpp:<line number>
...............................................................................
MiscTests.cpp:<line number>:
PASSED:
with message:
oops!
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
Process can be configured on command line Process can be configured on command line
default - no arguments default - no arguments
@@ -4224,7 +4235,7 @@ TestMain.cpp:<line number>
TestMain.cpp:<line number>: TestMain.cpp:<line number>:
PASSED: PASSED:
REQUIRE_THAT( parseIntoConfigAndReturnError( argv, config ) Contains( "greater than zero" ) ) REQUIRE_THAT( parseIntoConfigAndReturnError( argv, config ), Contains( "greater than zero" ) )
with expansion: with expansion:
"Value after -x or --abortAfter must be greater than zero "Value after -x or --abortAfter must be greater than zero
- while parsing: (-x, --abortx <no. failures>)" contains: "greater than zero" - while parsing: (-x, --abortx <no. failures>)" contains: "greater than zero"
@@ -4239,7 +4250,7 @@ TestMain.cpp:<line number>
TestMain.cpp:<line number>: TestMain.cpp:<line number>:
PASSED: PASSED:
REQUIRE_THAT( parseIntoConfigAndReturnError( argv, config ) Contains( "-x" ) ) REQUIRE_THAT( parseIntoConfigAndReturnError( argv, config ), Contains( "-x" ) )
with expansion: with expansion:
"Unable to convert oops to destination type "Unable to convert oops to destination type
- while parsing: (-x, --abortx <no. failures>)" contains: "-x" - while parsing: (-x, --abortx <no. failures>)" contains: "-x"
@@ -4348,8 +4359,8 @@ with expansion:
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
Process can be configured on command line Process can be configured on command line
force-colour use-colour
--force-colour without option
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
TestMain.cpp:<line number> TestMain.cpp:<line number>
............................................................................... ...............................................................................
@@ -4360,14 +4371,14 @@ PASSED:
TestMain.cpp:<line number>: TestMain.cpp:<line number>:
PASSED: PASSED:
REQUIRE( config.forceColour ) REQUIRE( config.useColour == UseColour::Auto )
with expansion: with expansion:
true 0 == 0
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
Process can be configured on command line Process can be configured on command line
force-colour use-colour
without --force-colour auto
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
TestMain.cpp:<line number> TestMain.cpp:<line number>
............................................................................... ...............................................................................
@@ -4378,9 +4389,57 @@ PASSED:
TestMain.cpp:<line number>: TestMain.cpp:<line number>:
PASSED: PASSED:
REQUIRE( !config.forceColour ) REQUIRE( config.useColour == UseColour::Auto )
with expansion: with expansion:
true 0 == 0
-------------------------------------------------------------------------------
Process can be configured on command line
use-colour
yes
-------------------------------------------------------------------------------
TestMain.cpp:<line number>
...............................................................................
TestMain.cpp:<line number>:
PASSED:
CHECK_NOTHROW( parseIntoConfig( argv, config ) )
TestMain.cpp:<line number>:
PASSED:
REQUIRE( config.useColour == UseColour::Yes )
with expansion:
1 == 1
-------------------------------------------------------------------------------
Process can be configured on command line
use-colour
no
-------------------------------------------------------------------------------
TestMain.cpp:<line number>
...............................................................................
TestMain.cpp:<line number>:
PASSED:
CHECK_NOTHROW( parseIntoConfig( argv, config ) )
TestMain.cpp:<line number>:
PASSED:
REQUIRE( config.useColour == UseColour::No )
with expansion:
2 == 2
-------------------------------------------------------------------------------
Process can be configured on command line
use-colour
error
-------------------------------------------------------------------------------
TestMain.cpp:<line number>
...............................................................................
TestMain.cpp:<line number>:
PASSED:
REQUIRE_THROWS_WITH( parseIntoConfig( argv, config ), Contains( "colour mode must be one of" ) )
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
Long strings can be wrapped Long strings can be wrapped
@@ -5000,7 +5059,7 @@ TestMain.cpp:<line number>
TestMain.cpp:<line number>: TestMain.cpp:<line number>:
PASSED: PASSED:
CHECK_THAT( t.toString() EndsWith( "... message truncated due to excessive size" ) ) CHECK_THAT( t.toString(), EndsWith( "... message truncated due to excessive size" ) )
with expansion: with expansion:
"***************************************************************************- "***************************************************************************-
***- ***-
@@ -8783,7 +8842,7 @@ TagAliasTests.cpp:<line number>
TagAliasTests.cpp:<line number>: TagAliasTests.cpp:<line number>:
PASSED: PASSED:
CHECK_THAT( what Contains( "[@zzz]" ) ) CHECK_THAT( what, Contains( "[@zzz]" ) )
with expansion: with expansion:
"error: tag alias, "[@zzz]" already registered. "error: tag alias, "[@zzz]" already registered.
First seen at file:2 First seen at file:2
@@ -8792,7 +8851,7 @@ with expansion:
TagAliasTests.cpp:<line number>: TagAliasTests.cpp:<line number>:
PASSED: PASSED:
CHECK_THAT( what Contains( "file" ) ) CHECK_THAT( what, Contains( "file" ) )
with expansion: with expansion:
"error: tag alias, "[@zzz]" already registered. "error: tag alias, "[@zzz]" already registered.
First seen at file:2 First seen at file:2
@@ -8801,7 +8860,7 @@ with expansion:
TagAliasTests.cpp:<line number>: TagAliasTests.cpp:<line number>:
PASSED: PASSED:
CHECK_THAT( what Contains( "2" ) ) CHECK_THAT( what, Contains( "2" ) )
with expansion: with expansion:
"error: tag alias, "[@zzz]" already registered. "error: tag alias, "[@zzz]" already registered.
First seen at file:2 First seen at file:2
@@ -8810,7 +8869,7 @@ with expansion:
TagAliasTests.cpp:<line number>: TagAliasTests.cpp:<line number>:
PASSED: PASSED:
CHECK_THAT( what Contains( "10" ) ) CHECK_THAT( what, Contains( "10" ) )
with expansion: with expansion:
"error: tag alias, "[@zzz]" already registered. "error: tag alias, "[@zzz]" already registered.
First seen at file:2 First seen at file:2
@@ -9045,6 +9104,6 @@ with expansion:
1 > 0 1 > 0
=============================================================================== ===============================================================================
test cases: 167 | 123 passed | 43 failed | 1 failed as expected test cases: 168 | 123 passed | 43 failed | 2 failed as expected
assertions: 916 | 818 passed | 85 failed | 13 failed as expected assertions: 922 | 824 passed | 80 failed | 18 failed as expected

View File

@@ -485,7 +485,131 @@ ConditionTests.cpp:<line number>: FAILED:
with expansion: with expansion:
9.1f != Approx( 9.1000003815 ) 9.1f != Approx( 9.1000003815 )
=============================================================================== -------------------------------------------------------------------------------
test cases: 19 | 15 passed | 3 failed | 1 failed as expected Ordering comparison checks that should succeed
assertions: 62 | 56 passed | 4 failed | 2 failed as expected -------------------------------------------------------------------------------
ConditionTests.cpp:<line number>
...............................................................................
ConditionTests.cpp:<line number>:
PASSED:
REQUIRE( data.int_seven < 8 )
with expansion:
7 < 8
ConditionTests.cpp:<line number>:
PASSED:
REQUIRE( data.int_seven > 6 )
with expansion:
7 > 6
ConditionTests.cpp:<line number>:
PASSED:
REQUIRE( data.int_seven > 0 )
with expansion:
7 > 0
ConditionTests.cpp:<line number>:
PASSED:
REQUIRE( data.int_seven > -1 )
with expansion:
7 > -1
ConditionTests.cpp:<line number>:
PASSED:
REQUIRE( data.int_seven >= 7 )
with expansion:
7 >= 7
ConditionTests.cpp:<line number>:
PASSED:
REQUIRE( data.int_seven >= 6 )
with expansion:
7 >= 6
ConditionTests.cpp:<line number>:
PASSED:
REQUIRE( data.int_seven <= 7 )
with expansion:
7 <= 7
ConditionTests.cpp:<line number>:
PASSED:
REQUIRE( data.int_seven <= 8 )
with expansion:
7 <= 8
ConditionTests.cpp:<line number>:
PASSED:
REQUIRE( data.float_nine_point_one > 9 )
with expansion:
9.1f > 9
ConditionTests.cpp:<line number>:
PASSED:
REQUIRE( data.float_nine_point_one < 10 )
with expansion:
9.1f < 10
ConditionTests.cpp:<line number>:
PASSED:
REQUIRE( data.float_nine_point_one < 9.2 )
with expansion:
9.1f < 9.2
ConditionTests.cpp:<line number>:
PASSED:
REQUIRE( data.str_hello <= "hello" )
with expansion:
"hello" <= "hello"
ConditionTests.cpp:<line number>:
PASSED:
REQUIRE( data.str_hello >= "hello" )
with expansion:
"hello" >= "hello"
ConditionTests.cpp:<line number>:
PASSED:
REQUIRE( data.str_hello < "hellp" )
with expansion:
"hello" < "hellp"
ConditionTests.cpp:<line number>:
PASSED:
REQUIRE( data.str_hello < "zebra" )
with expansion:
"hello" < "zebra"
ConditionTests.cpp:<line number>:
PASSED:
REQUIRE( data.str_hello > "hellm" )
with expansion:
"hello" > "hellm"
ConditionTests.cpp:<line number>:
PASSED:
REQUIRE( data.str_hello > "a" )
with expansion:
"hello" > "a"
-------------------------------------------------------------------------------
Ordering comparison checks that should fail
-------------------------------------------------------------------------------
ConditionTests.cpp:<line number>
...............................................................................
ConditionTests.cpp:<line number>: FAILED:
CHECK( data.int_seven > 7 )
with expansion:
7 > 7
ConditionTests.cpp:<line number>: FAILED:
CHECK( data.int_seven < 7 )
with expansion:
7 < 7
===============================================================================
test cases: 21 | 16 passed | 3 failed | 2 failed as expected
assertions: 81 | 73 passed | 4 failed | 4 failed as expected

View File

@@ -1,5 +1,5 @@
<testsuites> <testsuites>
<testsuite name="CatchSelfTest" errors="13" failures="72" tests="916" hostname="tbd" time="{duration}" timestamp="tbd"> <testsuite name="CatchSelfTest" errors="13" failures="68" tests="923" 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&lt;&lt;)" time="{duration}"/> <testcase classname="global" name="toString(enum w/operator&lt;&lt;)" time="{duration}"/>
<testcase classname="global" name="toString(enum class)" time="{duration}"/> <testcase classname="global" name="toString(enum class)" time="{duration}"/>
@@ -499,6 +499,7 @@ MiscTests.cpp:<line number>
<testcase classname="XmlEncode" name="string with control char (1)" time="{duration}"/> <testcase classname="XmlEncode" name="string with control char (1)" time="{duration}"/>
<testcase classname="XmlEncode" name="string with control char (x7F)" time="{duration}"/> <testcase classname="XmlEncode" name="string with control char (x7F)" time="{duration}"/>
<testcase classname="global" name="long long" time="{duration}"/> <testcase classname="global" name="long long" time="{duration}"/>
<testcase classname="global" name="This test 'should' fail but doesn't" time="{duration}"/>
<testcase classname="Process can be configured on command line" name="default - no arguments" time="{duration}"/> <testcase classname="Process can be configured on command line" name="default - no arguments" time="{duration}"/>
<testcase classname="Process can be configured on command line" name="test lists/1 test" time="{duration}"/> <testcase classname="Process can be configured on command line" name="test lists/1 test" time="{duration}"/>
<testcase classname="Process can be configured on command line" name="test lists/Specify one test case exclusion using exclude:" time="{duration}"/> <testcase classname="Process can be configured on command line" name="test lists/Specify one test case exclusion using exclude:" time="{duration}"/>
@@ -518,8 +519,11 @@ MiscTests.cpp:<line number>
<testcase classname="Process can be configured on command line" name="output filename/-o filename" time="{duration}"/> <testcase classname="Process can be configured on command line" name="output filename/-o filename" time="{duration}"/>
<testcase classname="Process can be configured on command line" name="output filename/--out" time="{duration}"/> <testcase classname="Process can be configured on command line" name="output filename/--out" time="{duration}"/>
<testcase classname="Process can be configured on command line" name="combinations/Single character flags can be combined" time="{duration}"/> <testcase classname="Process can be configured on command line" name="combinations/Single character flags can be combined" time="{duration}"/>
<testcase classname="Process can be configured on command line" name="force-colour/--force-colour" time="{duration}"/> <testcase classname="Process can be configured on command line" name="use-colour/without option" time="{duration}"/>
<testcase classname="Process can be configured on command line" name="force-colour/without --force-colour" time="{duration}"/> <testcase classname="Process can be configured on command line" name="use-colour/auto" time="{duration}"/>
<testcase classname="Process can be configured on command line" name="use-colour/yes" time="{duration}"/>
<testcase classname="Process can be configured on command line" name="use-colour/no" time="{duration}"/>
<testcase classname="Process can be configured on command line" name="use-colour/error" time="{duration}"/>
<testcase classname="Long strings can be wrapped" name="plain string/No wrapping" time="{duration}"/> <testcase classname="Long strings can be wrapped" name="plain string/No wrapping" time="{duration}"/>
<testcase classname="Long strings can be wrapped" name="plain string/Wrapped once" time="{duration}"/> <testcase classname="Long strings can be wrapped" name="plain string/Wrapped once" time="{duration}"/>
<testcase classname="Long strings can be wrapped" name="plain string/Wrapped twice" time="{duration}"/> <testcase classname="Long strings can be wrapped" name="plain string/Wrapped twice" time="{duration}"/>

View File

@@ -665,7 +665,7 @@
5 != 5 5 != 5
</Expanded> </Expanded>
</Expression> </Expression>
<OverallResult success="false"/> <OverallResult success="true"/>
</TestCase> </TestCase>
<TestCase name="Ordering comparison checks that should succeed"> <TestCase name="Ordering comparison checks that should succeed">
<Expression success="true" type="REQUIRE" filename="projects/SelfTest/ConditionTests.cpp" > <Expression success="true" type="REQUIRE" filename="projects/SelfTest/ConditionTests.cpp" >
@@ -3468,7 +3468,7 @@
<TestCase name="String matchers"> <TestCase name="String matchers">
<Expression success="true" type="REQUIRE_THAT" filename="projects/SelfTest/MiscTests.cpp" > <Expression success="true" type="REQUIRE_THAT" filename="projects/SelfTest/MiscTests.cpp" >
<Original> <Original>
testStringForMatching() Contains( "string" ) testStringForMatching(), Contains( "string" )
</Original> </Original>
<Expanded> <Expanded>
"this string contains 'abc' as a substring" contains: "string" "this string contains 'abc' as a substring" contains: "string"
@@ -3476,7 +3476,7 @@
</Expression> </Expression>
<Expression success="true" type="CHECK_THAT" filename="projects/SelfTest/MiscTests.cpp" > <Expression success="true" type="CHECK_THAT" filename="projects/SelfTest/MiscTests.cpp" >
<Original> <Original>
testStringForMatching() Contains( "abc" ) testStringForMatching(), Contains( "abc" )
</Original> </Original>
<Expanded> <Expanded>
"this string contains 'abc' as a substring" contains: "abc" "this string contains 'abc' as a substring" contains: "abc"
@@ -3484,7 +3484,7 @@
</Expression> </Expression>
<Expression success="true" type="CHECK_THAT" filename="projects/SelfTest/MiscTests.cpp" > <Expression success="true" type="CHECK_THAT" filename="projects/SelfTest/MiscTests.cpp" >
<Original> <Original>
testStringForMatching() StartsWith( "this" ) testStringForMatching(), StartsWith( "this" )
</Original> </Original>
<Expanded> <Expanded>
"this string contains 'abc' as a substring" starts with: "this" "this string contains 'abc' as a substring" starts with: "this"
@@ -3492,7 +3492,7 @@
</Expression> </Expression>
<Expression success="true" type="CHECK_THAT" filename="projects/SelfTest/MiscTests.cpp" > <Expression success="true" type="CHECK_THAT" filename="projects/SelfTest/MiscTests.cpp" >
<Original> <Original>
testStringForMatching() EndsWith( "substring" ) testStringForMatching(), EndsWith( "substring" )
</Original> </Original>
<Expanded> <Expanded>
"this string contains 'abc' as a substring" ends with: "substring" "this string contains 'abc' as a substring" ends with: "substring"
@@ -3503,7 +3503,7 @@
<TestCase name="Contains string matcher"> <TestCase name="Contains string matcher">
<Expression success="false" type="CHECK_THAT" filename="projects/SelfTest/MiscTests.cpp" > <Expression success="false" type="CHECK_THAT" filename="projects/SelfTest/MiscTests.cpp" >
<Original> <Original>
testStringForMatching() Contains( "not there" ) testStringForMatching(), Contains( "not there" )
</Original> </Original>
<Expanded> <Expanded>
"this string contains 'abc' as a substring" contains: "not there" "this string contains 'abc' as a substring" contains: "not there"
@@ -3514,7 +3514,7 @@
<TestCase name="StartsWith string matcher"> <TestCase name="StartsWith string matcher">
<Expression success="false" type="CHECK_THAT" filename="projects/SelfTest/MiscTests.cpp" > <Expression success="false" type="CHECK_THAT" filename="projects/SelfTest/MiscTests.cpp" >
<Original> <Original>
testStringForMatching() StartsWith( "string" ) testStringForMatching(), StartsWith( "string" )
</Original> </Original>
<Expanded> <Expanded>
"this string contains 'abc' as a substring" starts with: "string" "this string contains 'abc' as a substring" starts with: "string"
@@ -3525,7 +3525,7 @@
<TestCase name="EndsWith string matcher"> <TestCase name="EndsWith string matcher">
<Expression success="false" type="CHECK_THAT" filename="projects/SelfTest/MiscTests.cpp" > <Expression success="false" type="CHECK_THAT" filename="projects/SelfTest/MiscTests.cpp" >
<Original> <Original>
testStringForMatching() EndsWith( "this" ) testStringForMatching(), EndsWith( "this" )
</Original> </Original>
<Expanded> <Expanded>
"this string contains 'abc' as a substring" ends with: "this" "this string contains 'abc' as a substring" ends with: "this"
@@ -3536,7 +3536,7 @@
<TestCase name="Equals string matcher"> <TestCase name="Equals string matcher">
<Expression success="false" type="CHECK_THAT" filename="projects/SelfTest/MiscTests.cpp" > <Expression success="false" type="CHECK_THAT" filename="projects/SelfTest/MiscTests.cpp" >
<Original> <Original>
testStringForMatching() Equals( "something else" ) testStringForMatching(), Equals( "something else" )
</Original> </Original>
<Expanded> <Expanded>
"this string contains 'abc' as a substring" equals: "something else" "this string contains 'abc' as a substring" equals: "something else"
@@ -3547,7 +3547,7 @@
<TestCase name="Equals string matcher, with NULL"> <TestCase name="Equals string matcher, with NULL">
<Expression success="true" type="REQUIRE_THAT" filename="projects/SelfTest/MiscTests.cpp" > <Expression success="true" type="REQUIRE_THAT" filename="projects/SelfTest/MiscTests.cpp" >
<Original> <Original>
"" Equals(nullptr) "", Equals(nullptr)
</Original> </Original>
<Expanded> <Expanded>
"" equals: "" "" equals: ""
@@ -3558,7 +3558,7 @@
<TestCase name="AllOf matcher"> <TestCase name="AllOf matcher">
<Expression success="true" type="CHECK_THAT" filename="projects/SelfTest/MiscTests.cpp" > <Expression success="true" type="CHECK_THAT" filename="projects/SelfTest/MiscTests.cpp" >
<Original> <Original>
testStringForMatching() AllOf( Catch::Contains( "string" ), Catch::Contains( "abc" ) ) testStringForMatching(), AllOf( Catch::Contains( "string" ), Catch::Contains( "abc" ) )
</Original> </Original>
<Expanded> <Expanded>
"this string contains 'abc' as a substring" ( contains: "string" and contains: "abc" ) "this string contains 'abc' as a substring" ( contains: "string" and contains: "abc" )
@@ -3569,7 +3569,7 @@
<TestCase name="AnyOf matcher"> <TestCase name="AnyOf matcher">
<Expression success="true" type="CHECK_THAT" filename="projects/SelfTest/MiscTests.cpp" > <Expression success="true" type="CHECK_THAT" filename="projects/SelfTest/MiscTests.cpp" >
<Original> <Original>
testStringForMatching() AnyOf( Catch::Contains( "string" ), Catch::Contains( "not there" ) ) testStringForMatching(), AnyOf( Catch::Contains( "string" ), Catch::Contains( "not there" ) )
</Original> </Original>
<Expanded> <Expanded>
"this string contains 'abc' as a substring" ( contains: "string" or contains: "not there" ) "this string contains 'abc' as a substring" ( contains: "string" or contains: "not there" )
@@ -3577,7 +3577,7 @@
</Expression> </Expression>
<Expression success="true" type="CHECK_THAT" filename="projects/SelfTest/MiscTests.cpp" > <Expression success="true" type="CHECK_THAT" filename="projects/SelfTest/MiscTests.cpp" >
<Original> <Original>
testStringForMatching() AnyOf( Catch::Contains( "not there" ), Catch::Contains( "string" ) ) testStringForMatching(), AnyOf( Catch::Contains( "not there" ), Catch::Contains( "string" ) )
</Original> </Original>
<Expanded> <Expanded>
"this string contains 'abc' as a substring" ( contains: "not there" or contains: "string" ) "this string contains 'abc' as a substring" ( contains: "not there" or contains: "string" )
@@ -3588,7 +3588,7 @@
<TestCase name="Equals"> <TestCase name="Equals">
<Expression success="true" type="CHECK_THAT" filename="projects/SelfTest/MiscTests.cpp" > <Expression success="true" type="CHECK_THAT" filename="projects/SelfTest/MiscTests.cpp" >
<Original> <Original>
testStringForMatching() Equals( "this string contains 'abc' as a substring" ) testStringForMatching(), Equals( "this string contains 'abc' as a substring" )
</Original> </Original>
<Expanded> <Expanded>
"this string contains 'abc' as a substring" equals: "this string contains 'abc' as a substring" "this string contains 'abc' as a substring" equals: "this string contains 'abc' as a substring"
@@ -3599,7 +3599,7 @@
<TestCase name="Matchers can be (AllOf) composed with the &amp;&amp; operator"> <TestCase name="Matchers can be (AllOf) composed with the &amp;&amp; operator">
<Expression success="true" type="CHECK_THAT" filename="projects/SelfTest/MiscTests.cpp" > <Expression success="true" type="CHECK_THAT" filename="projects/SelfTest/MiscTests.cpp" >
<Original> <Original>
testStringForMatching() Contains( "string" ) &amp;&amp; Contains( "abc" ) &amp;&amp; Contains( "substring" ) &amp;&amp; Contains( "contains" ) testStringForMatching(), Contains( "string" ) &amp;&amp; Contains( "abc" ) &amp;&amp; Contains( "substring" ) &amp;&amp; Contains( "contains" )
</Original> </Original>
<Expanded> <Expanded>
"this string contains 'abc' as a substring" ( contains: "string" and contains: "abc" and contains: "substring" and contains: "contains" ) "this string contains 'abc' as a substring" ( contains: "string" and contains: "abc" and contains: "substring" and contains: "contains" )
@@ -3610,7 +3610,7 @@
<TestCase name="Matchers can be (AnyOf) composed with the || operator"> <TestCase name="Matchers can be (AnyOf) composed with the || operator">
<Expression success="true" type="CHECK_THAT" filename="projects/SelfTest/MiscTests.cpp" > <Expression success="true" type="CHECK_THAT" filename="projects/SelfTest/MiscTests.cpp" >
<Original> <Original>
testStringForMatching() Contains( "string" ) || Contains( "different" ) || Contains( "random" ) testStringForMatching(), Contains( "string" ) || Contains( "different" ) || Contains( "random" )
</Original> </Original>
<Expanded> <Expanded>
"this string contains 'abc' as a substring" ( contains: "string" or contains: "different" or contains: "random" ) "this string contains 'abc' as a substring" ( contains: "string" or contains: "different" or contains: "random" )
@@ -3618,7 +3618,7 @@
</Expression> </Expression>
<Expression success="true" type="CHECK_THAT" filename="projects/SelfTest/MiscTests.cpp" > <Expression success="true" type="CHECK_THAT" filename="projects/SelfTest/MiscTests.cpp" >
<Original> <Original>
testStringForMatching2() Contains( "string" ) || Contains( "different" ) || Contains( "random" ) testStringForMatching2(), Contains( "string" ) || Contains( "different" ) || Contains( "random" )
</Original> </Original>
<Expanded> <Expanded>
"some completely different text that contains one common word" ( contains: "string" or contains: "different" or contains: "random" ) "some completely different text that contains one common word" ( contains: "string" or contains: "different" or contains: "random" )
@@ -3629,7 +3629,7 @@
<TestCase name="Matchers can be composed with both &amp;&amp; and ||"> <TestCase name="Matchers can be composed with both &amp;&amp; and ||">
<Expression success="true" type="CHECK_THAT" filename="projects/SelfTest/MiscTests.cpp" > <Expression success="true" type="CHECK_THAT" filename="projects/SelfTest/MiscTests.cpp" >
<Original> <Original>
testStringForMatching() ( Contains( "string" ) || Contains( "different" ) ) &amp;&amp; Contains( "substring" ) testStringForMatching(), ( Contains( "string" ) || Contains( "different" ) ) &amp;&amp; Contains( "substring" )
</Original> </Original>
<Expanded> <Expanded>
"this string contains 'abc' as a substring" ( ( contains: "string" or contains: "different" ) and contains: "substring" ) "this string contains 'abc' as a substring" ( ( contains: "string" or contains: "different" ) and contains: "substring" )
@@ -3640,7 +3640,7 @@
<TestCase name="Matchers can be composed with both &amp;&amp; and || - failing"> <TestCase name="Matchers can be composed with both &amp;&amp; and || - failing">
<Expression success="false" type="CHECK_THAT" filename="projects/SelfTest/MiscTests.cpp" > <Expression success="false" type="CHECK_THAT" filename="projects/SelfTest/MiscTests.cpp" >
<Original> <Original>
testStringForMatching() ( Contains( "string" ) || Contains( "different" ) ) &amp;&amp; Contains( "random" ) testStringForMatching(), ( Contains( "string" ) || Contains( "different" ) ) &amp;&amp; Contains( "random" )
</Original> </Original>
<Expanded> <Expanded>
"this string contains 'abc' as a substring" ( ( contains: "string" or contains: "different" ) and contains: "random" ) "this string contains 'abc' as a substring" ( ( contains: "string" or contains: "different" ) and contains: "random" )
@@ -3651,7 +3651,7 @@
<TestCase name="Matchers can be negated (Not) with the ! operator"> <TestCase name="Matchers can be negated (Not) with the ! operator">
<Expression success="true" type="CHECK_THAT" filename="projects/SelfTest/MiscTests.cpp" > <Expression success="true" type="CHECK_THAT" filename="projects/SelfTest/MiscTests.cpp" >
<Original> <Original>
testStringForMatching() !Contains( "different" ) testStringForMatching(), !Contains( "different" )
</Original> </Original>
<Expanded> <Expanded>
"this string contains 'abc' as a substring" not contains: "different" "this string contains 'abc' as a substring" not contains: "different"
@@ -3662,7 +3662,7 @@
<TestCase name="Matchers can be negated (Not) with the ! operator - failing"> <TestCase name="Matchers can be negated (Not) with the ! operator - failing">
<Expression success="false" type="CHECK_THAT" filename="projects/SelfTest/MiscTests.cpp" > <Expression success="false" type="CHECK_THAT" filename="projects/SelfTest/MiscTests.cpp" >
<Original> <Original>
testStringForMatching() !Contains( "substring" ) testStringForMatching(), !Contains( "substring" )
</Original> </Original>
<Expanded> <Expanded>
"this string contains 'abc' as a substring" not contains: "substring" "this string contains 'abc' as a substring" not contains: "substring"
@@ -4085,6 +4085,9 @@
</Expression> </Expression>
<OverallResult success="true"/> <OverallResult success="true"/>
</TestCase> </TestCase>
<TestCase name="This test 'should' fail but doesn't">
<OverallResult success="false"/>
</TestCase>
<TestCase name="Process can be configured on command line"> <TestCase name="Process can be configured on command line">
<Section name="default - no arguments"> <Section name="default - no arguments">
<Expression success="true" type="CHECK_NOTHROW" filename="projects/SelfTest/TestMain.cpp" > <Expression success="true" type="CHECK_NOTHROW" filename="projects/SelfTest/TestMain.cpp" >
@@ -4415,7 +4418,7 @@
<Section name="-x must be greater than zero"> <Section name="-x must be greater than zero">
<Expression success="true" type="REQUIRE_THAT" filename="projects/SelfTest/TestMain.cpp" > <Expression success="true" type="REQUIRE_THAT" filename="projects/SelfTest/TestMain.cpp" >
<Original> <Original>
parseIntoConfigAndReturnError( argv, config ) Contains( "greater than zero" ) parseIntoConfigAndReturnError( argv, config ), Contains( "greater than zero" )
</Original> </Original>
<Expanded> <Expanded>
"Value after -x or --abortAfter must be greater than zero "Value after -x or --abortAfter must be greater than zero
@@ -4430,7 +4433,7 @@
<Section name="-x must be numeric"> <Section name="-x must be numeric">
<Expression success="true" type="REQUIRE_THAT" filename="projects/SelfTest/TestMain.cpp" > <Expression success="true" type="REQUIRE_THAT" filename="projects/SelfTest/TestMain.cpp" >
<Original> <Original>
parseIntoConfigAndReturnError( argv, config ) Contains( "-x" ) parseIntoConfigAndReturnError( argv, config ), Contains( "-x" )
</Original> </Original>
<Expanded> <Expanded>
"Unable to convert oops to destination type "Unable to convert oops to destination type
@@ -4567,8 +4570,8 @@
</Section> </Section>
<OverallResults successes="4" failures="0" expectedFailures="0"/> <OverallResults successes="4" failures="0" expectedFailures="0"/>
</Section> </Section>
<Section name="force-colour"> <Section name="use-colour">
<Section name="--force-colour"> <Section name="without option">
<Expression success="true" type="CHECK_NOTHROW" filename="projects/SelfTest/TestMain.cpp" > <Expression success="true" type="CHECK_NOTHROW" filename="projects/SelfTest/TestMain.cpp" >
<Original> <Original>
parseIntoConfig( argv, config ) parseIntoConfig( argv, config )
@@ -4579,18 +4582,18 @@
</Expression> </Expression>
<Expression success="true" type="REQUIRE" filename="projects/SelfTest/TestMain.cpp" > <Expression success="true" type="REQUIRE" filename="projects/SelfTest/TestMain.cpp" >
<Original> <Original>
config.forceColour config.useColour == UseColour::Auto
</Original> </Original>
<Expanded> <Expanded>
true 0 == 0
</Expanded> </Expanded>
</Expression> </Expression>
<OverallResults successes="2" failures="0" expectedFailures="0"/> <OverallResults successes="2" failures="0" expectedFailures="0"/>
</Section> </Section>
<OverallResults successes="2" failures="0" expectedFailures="0"/> <OverallResults successes="2" failures="0" expectedFailures="0"/>
</Section> </Section>
<Section name="force-colour"> <Section name="use-colour">
<Section name="without --force-colour"> <Section name="auto">
<Expression success="true" type="CHECK_NOTHROW" filename="projects/SelfTest/TestMain.cpp" > <Expression success="true" type="CHECK_NOTHROW" filename="projects/SelfTest/TestMain.cpp" >
<Original> <Original>
parseIntoConfig( argv, config ) parseIntoConfig( argv, config )
@@ -4601,16 +4604,74 @@
</Expression> </Expression>
<Expression success="true" type="REQUIRE" filename="projects/SelfTest/TestMain.cpp" > <Expression success="true" type="REQUIRE" filename="projects/SelfTest/TestMain.cpp" >
<Original> <Original>
!config.forceColour config.useColour == UseColour::Auto
</Original> </Original>
<Expanded> <Expanded>
true 0 == 0
</Expanded> </Expanded>
</Expression> </Expression>
<OverallResults successes="2" failures="0" expectedFailures="0"/> <OverallResults successes="2" failures="0" expectedFailures="0"/>
</Section> </Section>
<OverallResults successes="2" failures="0" expectedFailures="0"/> <OverallResults successes="2" failures="0" expectedFailures="0"/>
</Section> </Section>
<Section name="use-colour">
<Section name="yes">
<Expression success="true" type="CHECK_NOTHROW" filename="projects/SelfTest/TestMain.cpp" >
<Original>
parseIntoConfig( argv, config )
</Original>
<Expanded>
parseIntoConfig( argv, config )
</Expanded>
</Expression>
<Expression success="true" type="REQUIRE" filename="projects/SelfTest/TestMain.cpp" >
<Original>
config.useColour == UseColour::Yes
</Original>
<Expanded>
1 == 1
</Expanded>
</Expression>
<OverallResults successes="2" failures="0" expectedFailures="0"/>
</Section>
<OverallResults successes="2" failures="0" expectedFailures="0"/>
</Section>
<Section name="use-colour">
<Section name="no">
<Expression success="true" type="CHECK_NOTHROW" filename="projects/SelfTest/TestMain.cpp" >
<Original>
parseIntoConfig( argv, config )
</Original>
<Expanded>
parseIntoConfig( argv, config )
</Expanded>
</Expression>
<Expression success="true" type="REQUIRE" filename="projects/SelfTest/TestMain.cpp" >
<Original>
config.useColour == UseColour::No
</Original>
<Expanded>
2 == 2
</Expanded>
</Expression>
<OverallResults successes="2" failures="0" expectedFailures="0"/>
</Section>
<OverallResults successes="2" failures="0" expectedFailures="0"/>
</Section>
<Section name="use-colour">
<Section name="error">
<Expression success="true" type="REQUIRE_THROWS_WITH" filename="projects/SelfTest/TestMain.cpp" >
<Original>
parseIntoConfig( argv, config ), Contains( "colour mode must be one of" )
</Original>
<Expanded>
parseIntoConfig( argv, config ), Contains( "colour mode must be one of" )
</Expanded>
</Expression>
<OverallResults successes="1" failures="0" expectedFailures="0"/>
</Section>
<OverallResults successes="1" failures="0" expectedFailures="0"/>
</Section>
<OverallResult success="true"/> <OverallResult success="true"/>
</TestCase> </TestCase>
<TestCase name="Long strings can be wrapped"> <TestCase name="Long strings can be wrapped">
@@ -5276,7 +5337,7 @@ there"
<TestCase name="Long text is truncted"> <TestCase name="Long text is truncted">
<Expression success="true" type="CHECK_THAT" filename="projects/SelfTest/TestMain.cpp" > <Expression success="true" type="CHECK_THAT" filename="projects/SelfTest/TestMain.cpp" >
<Original> <Original>
t.toString() EndsWith( "... message truncated due to excessive size" ) t.toString(), EndsWith( "... message truncated due to excessive size" )
</Original> </Original>
<Expanded> <Expanded>
"******************************************************************************- "******************************************************************************-
@@ -9254,7 +9315,7 @@ there"
<Section name="The same tag alias can only be registered once"> <Section name="The same tag alias can only be registered once">
<Expression success="true" type="CHECK_THAT" filename="projects/SelfTest/TagAliasTests.cpp" > <Expression success="true" type="CHECK_THAT" filename="projects/SelfTest/TagAliasTests.cpp" >
<Original> <Original>
what Contains( "[@zzz]" ) what, Contains( "[@zzz]" )
</Original> </Original>
<Expanded> <Expanded>
"error: tag alias, "[@zzz]" already registered. "error: tag alias, "[@zzz]" already registered.
@@ -9264,7 +9325,7 @@ there"
</Expression> </Expression>
<Expression success="true" type="CHECK_THAT" filename="projects/SelfTest/TagAliasTests.cpp" > <Expression success="true" type="CHECK_THAT" filename="projects/SelfTest/TagAliasTests.cpp" >
<Original> <Original>
what Contains( "file" ) what, Contains( "file" )
</Original> </Original>
<Expanded> <Expanded>
"error: tag alias, "[@zzz]" already registered. "error: tag alias, "[@zzz]" already registered.
@@ -9274,7 +9335,7 @@ there"
</Expression> </Expression>
<Expression success="true" type="CHECK_THAT" filename="projects/SelfTest/TagAliasTests.cpp" > <Expression success="true" type="CHECK_THAT" filename="projects/SelfTest/TagAliasTests.cpp" >
<Original> <Original>
what Contains( "2" ) what, Contains( "2" )
</Original> </Original>
<Expanded> <Expanded>
"error: tag alias, "[@zzz]" already registered. "error: tag alias, "[@zzz]" already registered.
@@ -9284,7 +9345,7 @@ there"
</Expression> </Expression>
<Expression success="true" type="CHECK_THAT" filename="projects/SelfTest/TagAliasTests.cpp" > <Expression success="true" type="CHECK_THAT" filename="projects/SelfTest/TagAliasTests.cpp" >
<Original> <Original>
what Contains( "10" ) what, Contains( "10" )
</Original> </Original>
<Expanded> <Expanded>
"error: tag alias, "[@zzz]" already registered. "error: tag alias, "[@zzz]" already registered.
@@ -9505,7 +9566,7 @@ there"
</Section> </Section>
<OverallResult success="true"/> <OverallResult success="true"/>
</TestCase> </TestCase>
<OverallResults successes="818" failures="85" expectedFailures="13"/> <OverallResults successes="824" failures="81" expectedFailures="18"/>
</Group> </Group>
<OverallResults successes="818" failures="85" expectedFailures="13"/> <OverallResults successes="824" failures="80" expectedFailures="18"/>
</Catch> </Catch>

View File

@@ -101,7 +101,7 @@ TEST_CASE( "Inequality checks that should succeed", "" )
REQUIRE( data.str_hello.size() != 6 ); REQUIRE( data.str_hello.size() != 6 );
} }
TEST_CASE( "Inequality checks that should fail", "[.][failing]" ) TEST_CASE( "Inequality checks that should fail", "[.][failing][!shouldfail]" )
{ {
TestData data; TestData data;

View File

@@ -113,12 +113,12 @@ public:
: m_msg( msg ) : m_msg( msg )
{} {}
~CustomStdException() CATCH_NOEXCEPT {} ~CustomStdException() CATCH_NOEXCEPT {}
std::string getMessage() const std::string getMessage() const
{ {
return m_msg; return m_msg;
} }
private: private:
std::string m_msg; std::string m_msg;
}; };

View File

@@ -478,3 +478,8 @@ TEST_CASE( "long long" ) {
// 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 );
//} //}
TEST_CASE( "This test 'should' fail but doesn't", "[.][failing][!shouldfail]" )
{
SUCCEED( "oops!" );
}

View File

@@ -25,7 +25,7 @@ CATCH_REGISTER_TAG_ALIAS( "[@tricky]", "[tricky]~[.]" )
template<size_t size> template<size_t size>
void parseIntoConfig( const char * (&argv)[size], Catch::ConfigData& config ) { void parseIntoConfig( const char * (&argv)[size], Catch::ConfigData& config ) {
Catch::Clara::CommandLine<Catch::ConfigData> parser = Catch::makeCommandLineParser(); Catch::Clara::CommandLine<Catch::ConfigData> parser = Catch::makeCommandLineParser();
parser.parseInto( size, argv, config ); parser.parseInto( Catch::Clara::argsToVector( size, argv ), config );
} }
template<size_t size> template<size_t size>
@@ -195,19 +195,41 @@ TEST_CASE( "Process can be configured on command line", "[config][command-line]"
} }
} }
SECTION( "force-colour", "") { SECTION( "use-colour", "") {
SECTION( "--force-colour", "" ) {
const char* argv[] = { "test", "--force-colour" }; using Catch::UseColour;
CHECK_NOTHROW( parseIntoConfig( argv, config ) );
SECTION( "without option", "" ) {
REQUIRE( config.forceColour );
}
SECTION( "without --force-colour", "" ) {
const char* argv[] = { "test" }; const char* argv[] = { "test" };
CHECK_NOTHROW( parseIntoConfig( argv, config ) ); CHECK_NOTHROW( parseIntoConfig( argv, config ) );
REQUIRE( config.useColour == UseColour::Auto );
}
REQUIRE( !config.forceColour ); SECTION( "auto", "" ) {
const char* argv[] = { "test", "--use-colour", "auto" };
CHECK_NOTHROW( parseIntoConfig( argv, config ) );
REQUIRE( config.useColour == UseColour::Auto );
}
SECTION( "yes", "" ) {
const char* argv[] = { "test", "--use-colour", "yes" };
CHECK_NOTHROW( parseIntoConfig( argv, config ) );
REQUIRE( config.useColour == UseColour::Yes );
}
SECTION( "no", "" ) {
const char* argv[] = { "test", "--use-colour", "no" };
CHECK_NOTHROW( parseIntoConfig( argv, config ) );
REQUIRE( config.useColour == UseColour::No );
}
SECTION( "error", "" ) {
const char* argv[] = { "test", "--use-colour", "wrong" };
REQUIRE_THROWS_WITH( parseIntoConfig( argv, config ), Contains( "colour mode must be one of" ) );
} }
} }
} }

View File

@@ -93,7 +93,7 @@
<ItemGroup> <ItemGroup>
<ClCompile Include="..\..\..\SelfTest\ApproxTests.cpp" /> <ClCompile Include="..\..\..\SelfTest\ApproxTests.cpp" />
<ClCompile Include="..\..\..\SelfTest\BDDTests.cpp" /> <ClCompile Include="..\..\..\SelfTest\BDDTests.cpp" />
<ClCompile Include="..\..\..\SelfTest\SectionTrackerTests.cpp" /> <ClCompile Include="..\..\..\SelfTest\PartTrackerTests.cpp" />
<ClCompile Include="..\..\..\SelfTest\TestMain.cpp" /> <ClCompile Include="..\..\..\SelfTest\TestMain.cpp" />
<ClCompile Include="..\..\..\SelfTest\ClassTests.cpp" /> <ClCompile Include="..\..\..\SelfTest\ClassTests.cpp" />
<ClCompile Include="..\..\..\SelfTest\ConditionTests.cpp" /> <ClCompile Include="..\..\..\SelfTest\ConditionTests.cpp" />

View File

@@ -513,7 +513,7 @@
4A6D0C17149B3D3B00DB3EAA /* Project object */ = { 4A6D0C17149B3D3B00DB3EAA /* Project object */ = {
isa = PBXProject; isa = PBXProject;
attributes = { attributes = {
LastUpgradeCheck = 0630; LastUpgradeCheck = 0710;
}; };
buildConfigurationList = 4A6D0C1A149B3D3B00DB3EAA /* Build configuration list for PBXProject "CatchSelfTest" */; buildConfigurationList = 4A6D0C1A149B3D3B00DB3EAA /* Build configuration list for PBXProject "CatchSelfTest" */;
compatibilityVersion = "Xcode 3.2"; compatibilityVersion = "Xcode 3.2";
@@ -595,6 +595,7 @@
CLANG_WARN__EXIT_TIME_DESTRUCTORS = NO; CLANG_WARN__EXIT_TIME_DESTRUCTORS = NO;
COPY_PHASE_STRIP = NO; COPY_PHASE_STRIP = NO;
ENABLE_STRICT_OBJC_MSGSEND = YES; ENABLE_STRICT_OBJC_MSGSEND = YES;
ENABLE_TESTABILITY = YES;
GCC_C_LANGUAGE_STANDARD = gnu99; GCC_C_LANGUAGE_STANDARD = gnu99;
GCC_DYNAMIC_NO_PIC = NO; GCC_DYNAMIC_NO_PIC = NO;
GCC_ENABLE_OBJC_EXCEPTIONS = YES; GCC_ENABLE_OBJC_EXCEPTIONS = YES;

File diff suppressed because it is too large Load Diff