mirror of
https://github.com/catchorg/Catch2.git
synced 2025-09-11 16:05:40 +02:00
Compare commits
23 Commits
v2.0.0-dev
...
V2.0.0-dev
Author | SHA1 | Date | |
---|---|---|---|
![]() |
ae21020640 | ||
![]() |
11f716f28d | ||
![]() |
c3ddd4a7e2 | ||
![]() |
c43ce85416 | ||
![]() |
4220f2eef2 | ||
![]() |
c1a91caf00 | ||
![]() |
96c5de678d | ||
![]() |
e68485e196 | ||
![]() |
88e912b4d1 | ||
![]() |
44244713f1 | ||
![]() |
eea9e1efd7 | ||
![]() |
601b2888ec | ||
![]() |
3049445d78 | ||
![]() |
c672512979 | ||
![]() |
57b4e0b64c | ||
![]() |
75a77b6f8c | ||
![]() |
5af918eefd | ||
![]() |
05b1ca2884 | ||
![]() |
c2b7bd15c0 | ||
![]() |
ba6845a865 | ||
![]() |
2eb93f47f7 | ||
![]() |
276393e4e5 | ||
![]() |
c7d9f02d5b |
@@ -9,6 +9,7 @@ set(CATCH_DIR ${CMAKE_CURRENT_SOURCE_DIR})
|
||||
set(SELF_TEST_DIR ${CATCH_DIR}/projects/SelfTest)
|
||||
set(BENCHMARK_DIR ${CATCH_DIR}/projects/Benchmark)
|
||||
set(HEADER_DIR ${CATCH_DIR}/include)
|
||||
set(CATCH_VERSION_NUMBER 2.0.0-develop.6)
|
||||
|
||||
if(USE_CPP14)
|
||||
message(STATUS "Enabling C++14")
|
||||
@@ -275,33 +276,21 @@ set(HEADERS
|
||||
${REPORTER_HEADERS}
|
||||
)
|
||||
|
||||
|
||||
set(BENCH_SOURCES
|
||||
${BENCHMARK_DIR}/BenchMain.cpp
|
||||
${BENCHMARK_DIR}/StringificationBench.cpp
|
||||
)
|
||||
CheckFileList(BENCH_SOURCES ${BENCHMARK_DIR})
|
||||
|
||||
# Provide some groupings for IDEs
|
||||
SOURCE_GROUP("Tests" FILES ${TEST_SOURCES})
|
||||
SOURCE_GROUP("Surrogates" FILES ${SURROGATE_SOURCES})
|
||||
SOURCE_GROUP("Benchmarks" FILES ${BENCH_SOURCES})
|
||||
|
||||
# configure the executable
|
||||
include_directories(${HEADER_DIR})
|
||||
|
||||
add_definitions( -DCATCH_CONFIG_FULL_PROJECT )
|
||||
|
||||
# Projects consuming Catch via ExternalProject_Add might want to use install step
|
||||
# without building all of our selftests.
|
||||
if (NOT NO_SELFTEST)
|
||||
add_executable(SelfTest ${TEST_SOURCES} ${IMPL_SOURCES} ${REPORTER_SOURCES} ${SURROGATE_SOURCES} ${HEADERS})
|
||||
add_executable(Benchmark ${BENCH_SOURCES} ${IMPL_SOURCES} ${REPORTER_SOURCES} ${HEADERS})
|
||||
|
||||
# Add desired warnings
|
||||
if ( CMAKE_CXX_COMPILER_ID MATCHES "Clang|AppleClang|GNU" )
|
||||
target_compile_options( SelfTest PRIVATE -Wall -Wextra -Wunreachable-code )
|
||||
target_compile_options( Benchmark PRIVATE -Wall -Wextra -Wunreachable-code )
|
||||
endif()
|
||||
# Clang specific warning go here
|
||||
if ( CMAKE_CXX_COMPILER_ID MATCHES "Clang" )
|
||||
@@ -309,8 +298,7 @@ if (NOT NO_SELFTEST)
|
||||
target_compile_options( SelfTest PRIVATE -Wweak-vtables -Wexit-time-destructors -Wglobal-constructors -Wmissing-noreturn )
|
||||
endif()
|
||||
if ( CMAKE_CXX_COMPILER_ID MATCHES "MSVC" )
|
||||
target_compile_options( SelfTest PRIVATE /W4 /w44265 /WX )
|
||||
target_compile_options( Benchmark PRIVATE /W4 )
|
||||
target_compile_options( SelfTest PRIVATE /W4 /w44265 /WX /w44061 /w44062 )
|
||||
endif()
|
||||
|
||||
|
||||
@@ -331,3 +319,17 @@ endif() # !NO_SELFTEST
|
||||
|
||||
|
||||
install(DIRECTORY "single_include/" DESTINATION "include/catch")
|
||||
|
||||
## Provide some pkg-config integration
|
||||
# Don't bother on Windows
|
||||
if(NOT WIN32 OR NOT CMAKE_HOST_SYSTEM_NAME MATCHES Windows)
|
||||
|
||||
set(PKGCONFIG_INSTALL_DIR
|
||||
"${CMAKE_INSTALL_PREFIX}/share/pkgconfig"
|
||||
CACHE PATH "Path where catch.pc is installed"
|
||||
)
|
||||
|
||||
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/catch.pc.in ${CMAKE_CURRENT_BINARY_DIR}/catch.pc @ONLY)
|
||||
install(FILES ${CMAKE_CURRENT_BINARY_DIR}/catch.pc DESTINATION ${PKGCONFIG_INSTALL_DIR})
|
||||
|
||||
endif()
|
||||
|
@@ -5,7 +5,7 @@
|
||||
[](https://travis-ci.org/philsquared/Catch?branch=catch2)
|
||||
[](https://ci.appveyor.com/project/philsquared/catch/branch/catch2)
|
||||
|
||||
<a href="https://github.com/philsquared/Catch/releases/download/v2.0.0-develop.4/catch.hpp">The latest version of the single header can be downloaded directly using this link</a>
|
||||
<a href="https://github.com/philsquared/Catch/releases/download/v2.0.0-develop.6/catch.hpp">The latest version of the single header can be downloaded directly using this link</a>
|
||||
|
||||
## What's the Catch?
|
||||
|
||||
|
9
catch.pc.in
Normal file
9
catch.pc.in
Normal file
@@ -0,0 +1,9 @@
|
||||
prefix=@CMAKE_INSTALL_PREFIX@
|
||||
exec_prefix=${prefix}
|
||||
|
||||
Name: Catch
|
||||
Description: Testing library for C++
|
||||
Requires:
|
||||
Version: @CATCH_VERSION_NUMBER@
|
||||
Libs:
|
||||
Cflags: -I${prefix}/@INCLUDE_INSTALL_DIR@/include
|
@@ -4,7 +4,7 @@ from conans import ConanFile
|
||||
|
||||
class CatchConan(ConanFile):
|
||||
name = "Catch"
|
||||
version = "2.0.0-develop.5"
|
||||
version = "2.0.0-develop.6"
|
||||
description = "A modern, C++-native, header-only, framework for unit-tests, TDD and BDD"
|
||||
author = "philsquared"
|
||||
generators = "cmake"
|
||||
@@ -14,3 +14,6 @@ class CatchConan(ConanFile):
|
||||
|
||||
def package(self):
|
||||
self.copy(pattern="catch.hpp", src="single_include", dst="include")
|
||||
|
||||
def package_id(self):
|
||||
self.info.header_only()
|
||||
|
@@ -36,6 +36,8 @@
|
||||
# -- adds fixture class name to the test name #
|
||||
# PARSE_CATCH_TESTS_ADD_TARGET_IN_TEST_NAME (Default ON) #
|
||||
# -- adds cmake target name to the test name #
|
||||
# PARSE_CATCH_TESTS_ADD_TO_CONFIGURE_DEPENDS (Default OFF) #
|
||||
# -- causes CMake to rerun when file with tests changes so that new tests will be discovered #
|
||||
# #
|
||||
#==================================================================================================#
|
||||
|
||||
@@ -45,6 +47,7 @@ option(PARSE_CATCH_TESTS_VERBOSE "Print Catch to CTest parser debug messages" OF
|
||||
option(PARSE_CATCH_TESTS_NO_HIDDEN_TESTS "Exclude tests with [!hide], [.] or [.foo] tags" OFF)
|
||||
option(PARSE_CATCH_TESTS_ADD_FIXTURE_IN_TEST_NAME "Add fixture class name to the test name" ON)
|
||||
option(PARSE_CATCH_TESTS_ADD_TARGET_IN_TEST_NAME "Add target name to the test name" ON)
|
||||
option(PARSE_CATCH_TESTS_ADD_TO_CONFIGURE_DEPENDS "Add test file to CMAKE_CONFIGURE_DEPENDS property" OFF)
|
||||
|
||||
function(PrintDebugMessage)
|
||||
if(PARSE_CATCH_TESTS_VERBOSE)
|
||||
@@ -85,6 +88,15 @@ function(ParseFile SourceFile TestTarget)
|
||||
# Find definition of test names
|
||||
string(REGEX MATCHALL "[ \t]*(CATCH_)?(TEST_CASE_METHOD|SCENARIO|TEST_CASE)[ \t]*\\([^\)]+\\)+[ \t\n]*{+[ \t]*(//[^\n]*[Tt][Ii][Mm][Ee][Oo][Uu][Tt][ \t]*[0-9]+)*" Tests "${Contents}")
|
||||
|
||||
if(PARSE_CATCH_TESTS_ADD_TO_CONFIGURE_DEPENDS AND Tests)
|
||||
PrintDebugMessage("Adding ${SourceFile} to CMAKE_CONFIGURE_DEPENDS property")
|
||||
set_property(
|
||||
DIRECTORY
|
||||
APPEND
|
||||
PROPERTY CMAKE_CONFIGURE_DEPENDS ${SourceFile}
|
||||
)
|
||||
endif()
|
||||
|
||||
foreach(TestName ${Tests})
|
||||
# Strip newlines
|
||||
string(REGEX REPLACE "\\\\\n|\n" "" TestName "${TestName}")
|
||||
|
@@ -1,11 +1,11 @@
|
||||
<a id="top"></a>
|
||||
# Assertion Macros
|
||||
|
||||
**Contents**
|
||||
[Natural Expressions](#natural-expressions)
|
||||
[Exceptions](#exceptions)
|
||||
[Matcher expressions](#matcher-expressions)
|
||||
[Thread Safety](#thread-safety)
|
||||
**Contents**<br>
|
||||
[Natural Expressions](#natural-expressions)<br>
|
||||
[Exceptions](#exceptions)<br>
|
||||
[Matcher expressions](#matcher-expressions)<br>
|
||||
[Thread Safety](#thread-safety)<br>
|
||||
|
||||
Most test frameworks have a large collection of assertion macros to capture all possible conditional forms (```_EQUALS```, ```_NOTEQUALS```, ```_GREATER_THAN``` etc).
|
||||
|
||||
|
@@ -16,7 +16,7 @@ The XML Reporter writes in an XML format that is specific to Catch.
|
||||
|
||||
The advantage of this format is that it corresponds well to the way Catch works (especially the more unusual features, such as nested sections) and is a fully streaming format - that is it writes output as it goes, without having to store up all its results before it can start writing.
|
||||
|
||||
The disadvantage is that, being specific to Catch, no existing build servers understand the format natively. It can be used as input to an XSLT transformation that could covert it to, say, HTML - although this loses the streaming advantage, of course.
|
||||
The disadvantage is that, being specific to Catch, no existing build servers understand the format natively. It can be used as input to an XSLT transformation that could convert it to, say, HTML - although this loses the streaming advantage, of course.
|
||||
|
||||
### JUnit Reporter
|
||||
```-r junit```
|
||||
|
@@ -1,29 +1,29 @@
|
||||
<a id="top"></a>
|
||||
# Command line
|
||||
|
||||
**Contents**
|
||||
[Specifying which tests to run](#specifying-which-tests-to-run)
|
||||
[Choosing a reporter to use](#choosing-a-reporter-to-use)
|
||||
[Breaking into the debugger](#breaking-into-the-debugger)
|
||||
[Showing results for successful tests](#showing-results-for-successful-tests)
|
||||
[Aborting after a certain number of failures](#aborting-after-a-certain-number-of-failures)
|
||||
[Listing available tests, tags or reporters](#listing-available-tests-tags-or-reporters)
|
||||
[Sending output to a file](#sending-output-to-a-file)
|
||||
[Naming a test run](#naming-a-test-run)
|
||||
[Eliding assertions expected to throw](#eliding-assertions-expected-to-throw)
|
||||
[Make whitespace visible](#make-whitespace-visible)
|
||||
[Warnings](#warnings)
|
||||
[Reporting timings](#reporting-timings)
|
||||
[Load test names to run from a file](#load-test-names-to-run-from-a-file)
|
||||
[Just test names](#just-test-names)
|
||||
[Specify the order test cases are run](#specify-the-order-test-cases-are-run)
|
||||
[Specify a seed for the Random Number Generator](#specify-a-seed-for-the-random-number-generator)
|
||||
[Identify framework and version according to the libIdentify standard](#identify-framework-and-version-according-to-the-libidentify-standard)
|
||||
[Wait for key before continuing](#wait-for-key-before-continuing)
|
||||
[Specify multiples of clock resolution to run benchmarks for](#specify-multiples-of-clock-resolution-to-run-benchmarks-for)
|
||||
[Usage](#usage)
|
||||
[Specify the section to run](#specify-the-section-to-run)
|
||||
[Filenames as tags](#filenames-as-tags)
|
||||
**Contents**<br>
|
||||
[Specifying which tests to run](#specifying-which-tests-to-run)<br>
|
||||
[Choosing a reporter to use](#choosing-a-reporter-to-use)<br>
|
||||
[Breaking into the debugger](#breaking-into-the-debugger)<br>
|
||||
[Showing results for successful tests](#showing-results-for-successful-tests)<br>
|
||||
[Aborting after a certain number of failures](#aborting-after-a-certain-number-of-failures)<br>
|
||||
[Listing available tests, tags or reporters](#listing-available-tests-tags-or-reporters)<br>
|
||||
[Sending output to a file](#sending-output-to-a-file)<br>
|
||||
[Naming a test run](#naming-a-test-run)<br>
|
||||
[Eliding assertions expected to throw](#eliding-assertions-expected-to-throw)<br>
|
||||
[Make whitespace visible](#make-whitespace-visible)<br>
|
||||
[Warnings](#warnings)<br>
|
||||
[Reporting timings](#reporting-timings)<br>
|
||||
[Load test names to run from a file](#load-test-names-to-run-from-a-file)<br>
|
||||
[Just test names](#just-test-names)<br>
|
||||
[Specify the order test cases are run](#specify-the-order-test-cases-are-run)<br>
|
||||
[Specify a seed for the Random Number Generator](#specify-a-seed-for-the-random-number-generator)<br>
|
||||
[Identify framework and version according to the libIdentify standard](#identify-framework-and-version-according-to-the-libidentify-standard)<br>
|
||||
[Wait for key before continuing](#wait-for-key-before-continuing)<br>
|
||||
[Specify multiples of clock resolution to run benchmarks for](#specify-multiples-of-clock-resolution-to-run-benchmarks-for)<br>
|
||||
[Usage](#usage)<br>
|
||||
[Specify the section to run](#specify-the-section-to-run)<br>
|
||||
[Filenames as tags](#filenames-as-tags)<br>
|
||||
|
||||
Catch works quite nicely without any command line options at all - but for those times when you want greater control the following options are available.
|
||||
Click one of the followings links to take you straight to that option - or scroll on to browse the available options.
|
||||
|
@@ -1,15 +1,15 @@
|
||||
<a id="top"></a>
|
||||
# Compile-time configuration
|
||||
|
||||
**Contents**
|
||||
[main()/ implementation](#main-implementation)
|
||||
[Prefixing Catch macros](#prefixing-catch-macros)
|
||||
[Terminal colour](#terminal-colour)
|
||||
[Console width](#console-width)
|
||||
[stdout](#stdout)
|
||||
[Other toggles](#other-toggles)
|
||||
[Windows header clutter](#windows-header-clutter)
|
||||
[Enabling stringification](#enabling-stringification)
|
||||
**Contents**<br>
|
||||
[main()/ implementation](#main-implementation)<br>
|
||||
[Prefixing Catch macros](#prefixing-catch-macros)<br>
|
||||
[Terminal colour](#terminal-colour)<br>
|
||||
[Console width](#console-width)<br>
|
||||
[stdout](#stdout)<br>
|
||||
[Other toggles](#other-toggles)<br>
|
||||
[Windows header clutter](#windows-header-clutter)<br>
|
||||
[Enabling stringification](#enabling-stringification)<br>
|
||||
|
||||
Catch is designed to "just work" as much as possible. For most people the only configuration needed is telling Catch which source file should host all the implementation code (```CATCH_CONFIG_MAIN```).
|
||||
|
||||
@@ -106,7 +106,7 @@ When `CATCH_CONFIG_DISABLE_MATCHERS` is defined, all mentions of Catch's Matcher
|
||||
_Note: If you define `CATCH_CONFIG_DISABLE_MATCHERS` in the same file as Catch's main is implemented, your test executable will fail to link if you use Matchers anywhere._
|
||||
|
||||
### `CATCH_CONFIG_DISABLE_STRINGIFICATION`
|
||||
This toggle enables a workaround for VS 2017 bug. For details see [known limitations](limitations.md#Visual Studio 2017 -- raw string literal in assert fails to compile)
|
||||
This toggle enables a workaround for VS 2017 bug. For details see [known limitations](limitations.md#visual-studio-2017----raw-string-literal-in-assert-fails-to-compile).
|
||||
|
||||
### `CATCH_CONFIG_DISABLE`
|
||||
This toggle removes most of Catch from given file. This means that `TEST_CASE`s are not registered and assertions are turned into no-ops. Useful for keeping tests within implementation files (ie for functions with internal linkage), instead of in external files.
|
||||
|
@@ -1,7 +1,7 @@
|
||||
<a id="top"></a>
|
||||
# Open Source projects using Catch
|
||||
|
||||
Catch is great for open source. With it's [liberal license](../LICENSE.txt) and single-header, dependency-free, distribution
|
||||
Catch is great for open source. With its [liberal license](../LICENSE.txt) and single-header, dependency-free, distribution
|
||||
it's easy to just drop the header into your project and start writing tests - what's not to like?
|
||||
|
||||
As a result Catch is now being used in many Open Source projects, including some quite well known ones.
|
||||
|
@@ -57,6 +57,8 @@
|
||||
* The Reporter/Listener interface provides default, empty, implementation to preserve backward compatibility
|
||||
* Stringification of `std::chrono::duration` and `std::chrono::time_point` is now supported
|
||||
* Needs to be enabled by a per-file compile time configuration option
|
||||
* Add `pkg-config` support to CMake install command
|
||||
|
||||
|
||||
## Fixes
|
||||
* Don't use console colour if running in XCode
|
||||
@@ -67,6 +69,8 @@
|
||||
* Implemented a workaround for `std::uncaught_exception` issues in libcxxrt
|
||||
* These issues caused incorrect section traversals
|
||||
* The workaround is only partial, user's test can still trigger the issue by using `throw;` to rethrow an exception
|
||||
* Suppressed C4061 warning under MSVC
|
||||
|
||||
|
||||
## Internal changes
|
||||
* The development version now uses .cpp files instead of header files containing implementation.
|
||||
|
@@ -1,11 +1,11 @@
|
||||
<a id="top"></a>
|
||||
# Why do my tests take so long to compile?
|
||||
|
||||
**Contents**
|
||||
[Short answer](#short-answer)
|
||||
[Long answer](#long-answer)
|
||||
[Practical example](#practical-example)
|
||||
[Other possible solutions](#other-possible-solutions)
|
||||
**Contents**<br>
|
||||
[Short answer](#short-answer)<br>
|
||||
[Long answer](#long-answer)<br>
|
||||
[Practical example](#practical-example)<br>
|
||||
[Other possible solutions](#other-possible-solutions)<br>
|
||||
|
||||
Several people have reported that test code written with Catch takes much longer to compile than they would expect. Why is that?
|
||||
|
||||
|
@@ -39,13 +39,13 @@ All tag names beginning with non-alphanumeric characters are reserved by Catch.
|
||||
|
||||
* `[!throws]` - lets Catch know that this test is likely to throw an exception even if successful. This causes the test to be excluded when running with `-e` or `--nothrow`.
|
||||
|
||||
* `[!mayfail]` - doesn't fail the test if any given assertion fails (but still reports it). This can be useful to flag a work-in-progress, or a known issue that you don't want to immediately fix but still want to track in the your tests.
|
||||
* `[!mayfail]` - doesn't fail the test if any given assertion fails (but still reports it). This can be useful to flag a work-in-progress, or a known issue that you don't want to immediately fix but still want to track in your tests.
|
||||
|
||||
* `[!shouldfail]` - like `[!mayfail]` but *fails* the test if it *passes*. This can be useful if you want to be notified of accidental, or third-party, fixes.
|
||||
|
||||
* `[!nonportable]` - Indicates that behaviour may vary between platforms or compilers.
|
||||
|
||||
* `[#<filename>]` - running with `-#` or `--filenames-as-tags` causes Catch to add the filename, prefixed with `#` (and with any extension stripped) as a tag. e.g. tests in testfile.cpp would all be tagged `[#testfile]`.
|
||||
* `[#<filename>]` - running with `-#` or `--filenames-as-tags` causes Catch to add the filename, prefixed with `#` (and with any extension stripped), as a tag to all contained tests, e.g. tests in testfile.cpp would all be tagged `[#testfile]`.
|
||||
|
||||
* `[@<alias>]` - tag aliases all begin with `@` (see below).
|
||||
|
||||
@@ -53,7 +53,7 @@ All tag names beginning with non-alphanumeric characters are reserved by Catch.
|
||||
|
||||
## Tag aliases
|
||||
|
||||
Between tag expressions and wildcarded test names (as well as combinations of the two) quite complex patterns can be constructed to direct which test cases are run. If a complex pattern is used often it is convenient to be able to create an alias for the expression. this can be done, in code, using the following form:
|
||||
Between tag expressions and wildcarded test names (as well as combinations of the two) quite complex patterns can be constructed to direct which test cases are run. If a complex pattern is used often it is convenient to be able to create an alias for the expression. This can be done, in code, using the following form:
|
||||
|
||||
CATCH_REGISTER_TAG_ALIAS( <alias string>, <tag expression> )
|
||||
|
||||
|
@@ -1,14 +1,14 @@
|
||||
<a id="top"></a>
|
||||
# Tutorial
|
||||
|
||||
**Contents**
|
||||
[Getting Catch](#getting-catch)
|
||||
[Where to put it?](#where-to-put-it)
|
||||
[Writing tests](#writing-tests)
|
||||
[Test cases and sections](#test-cases-and-sections)
|
||||
[BDD-Style](#bdd-style)
|
||||
[Scaling up](#scaling-up)
|
||||
[Next steps](#next-steps)
|
||||
**Contents**<br>
|
||||
[Getting Catch](#getting-catch)<br>
|
||||
[Where to put it?](#where-to-put-it)<br>
|
||||
[Writing tests](#writing-tests)<br>
|
||||
[Test cases and sections](#test-cases-and-sections)<br>
|
||||
[BDD-Style](#bdd-style)<br>
|
||||
[Scaling up](#scaling-up)<br>
|
||||
[Next steps](#next-steps)<br>
|
||||
|
||||
## Getting Catch
|
||||
|
||||
|
25
include/external/clara.hpp
vendored
25
include/external/clara.hpp
vendored
@@ -1,4 +1,4 @@
|
||||
// v1.0
|
||||
// v1.0-develop.2
|
||||
// See https://github.com/philsquared/Clara
|
||||
|
||||
#ifndef CATCH_CLARA_HPP_INCLUDED
|
||||
@@ -409,6 +409,14 @@ namespace detail {
|
||||
std::string token;
|
||||
};
|
||||
|
||||
inline auto isOptPrefix( char c ) -> bool {
|
||||
return c == '-'
|
||||
#ifdef CATCH_PLATFORM_WINDOWS
|
||||
|| c == '/'
|
||||
#endif
|
||||
;
|
||||
}
|
||||
|
||||
// Abstracts iterators into args as a stream of tokens, with option arguments uniformly handled
|
||||
class TokenStream {
|
||||
using Iterator = std::vector<std::string>::const_iterator;
|
||||
@@ -425,7 +433,7 @@ namespace detail {
|
||||
|
||||
if( it != itEnd ) {
|
||||
auto const &next = *it;
|
||||
if( next[0] == '-' || next[0] == '/' ) {
|
||||
if( isOptPrefix( next[0] ) ) {
|
||||
auto delimiterPos = next.find_first_of( " :=" );
|
||||
if( delimiterPos != std::string::npos ) {
|
||||
m_tokenBuffer.push_back( { TokenType::Option, next.substr( 0, delimiterPos ) } );
|
||||
@@ -915,9 +923,11 @@ namespace detail {
|
||||
};
|
||||
|
||||
inline auto normaliseOpt( std::string const &optName ) -> std::string {
|
||||
#ifdef CATCH_PLATFORM_WINDOWS
|
||||
if( optName[0] == '/' )
|
||||
return "-" + optName.substr( 1 );
|
||||
else
|
||||
#endif
|
||||
return optName;
|
||||
}
|
||||
|
||||
@@ -958,11 +968,7 @@ namespace detail {
|
||||
}
|
||||
|
||||
auto isMatch( std::string const &optToken ) const -> bool {
|
||||
#ifdef CATCH_PLATFORM_WINDOWS
|
||||
auto normalisedToken = normaliseOpt( optToken );
|
||||
#else
|
||||
auto const &normalisedToken = optToken;
|
||||
#endif
|
||||
for( auto const &name : m_optNames ) {
|
||||
if( normaliseOpt( name ) == normalisedToken )
|
||||
return true;
|
||||
@@ -1012,8 +1018,13 @@ namespace detail {
|
||||
for( auto const &name : m_optNames ) {
|
||||
if( name.empty() )
|
||||
return Result::logicError( "Option name cannot be empty" );
|
||||
#ifdef CATCH_PLATFORM_WINDOWS
|
||||
if( name[0] != '-' && name[0] != '/' )
|
||||
return Result::logicError( "Option name must begin with '-' or '/'" );
|
||||
#else
|
||||
if( name[0] != '-' )
|
||||
return Result::logicError( "Option name must begin with '-'" );
|
||||
#endif
|
||||
}
|
||||
return ParserRefImpl::validate();
|
||||
}
|
||||
@@ -1103,7 +1114,7 @@ namespace detail {
|
||||
size_t consoleWidth = CATCH_CLARA_CONFIG_CONSOLE_WIDTH;
|
||||
size_t optWidth = 0;
|
||||
for( auto const &cols : rows )
|
||||
optWidth = std::max(optWidth, cols.left.size() + 2);
|
||||
optWidth = (std::max)(optWidth, cols.left.size() + 2);
|
||||
|
||||
for( auto const &cols : rows ) {
|
||||
auto row =
|
||||
|
@@ -13,7 +13,7 @@
|
||||
namespace Catch {
|
||||
namespace Detail {
|
||||
|
||||
double max(double lhs, double rhs) {
|
||||
double dmax(double lhs, double rhs) {
|
||||
if (lhs < rhs) {
|
||||
return rhs;
|
||||
}
|
||||
|
@@ -8,6 +8,7 @@
|
||||
#ifndef TWOBLUECUBES_CATCH_APPROX_HPP_INCLUDED
|
||||
#define TWOBLUECUBES_CATCH_APPROX_HPP_INCLUDED
|
||||
|
||||
#include "catch_enforce.h"
|
||||
#include "catch_tostring.h"
|
||||
|
||||
#include <cmath>
|
||||
@@ -17,7 +18,7 @@
|
||||
namespace Catch {
|
||||
namespace Detail {
|
||||
|
||||
double max(double lhs, double rhs);
|
||||
double dmax(double lhs, double rhs);
|
||||
|
||||
class Approx {
|
||||
public:
|
||||
@@ -43,11 +44,12 @@ namespace Detail {
|
||||
friend bool operator == ( const T& lhs, Approx const& rhs ) {
|
||||
// Thanks to Richard Harris for his help refining this formula
|
||||
auto lhs_v = static_cast<double>(lhs);
|
||||
bool relativeOK = std::fabs(lhs_v - rhs.m_value) < rhs.m_epsilon * (rhs.m_scale + (max)(std::fabs(lhs_v), std::fabs(rhs.m_value)));
|
||||
bool relativeOK = std::fabs(lhs_v - rhs.m_value) < rhs.m_epsilon * (rhs.m_scale +
|
||||
dmax(std::fabs(lhs_v), std::fabs(rhs.m_value)));
|
||||
if (relativeOK) {
|
||||
return true;
|
||||
}
|
||||
return std::fabs(lhs_v - rhs.m_value) < rhs.m_margin;
|
||||
return std::fabs(lhs_v - rhs.m_value) <= rhs.m_margin;
|
||||
}
|
||||
|
||||
template <typename T, typename = typename std::enable_if<std::is_constructible<double, T>::value>::type>
|
||||
@@ -94,6 +96,7 @@ namespace Detail {
|
||||
template <typename T, typename = typename std::enable_if<std::is_constructible<double, T>::value>::type>
|
||||
Approx& margin( T const& newMargin ) {
|
||||
m_margin = static_cast<double>(newMargin);
|
||||
CATCH_ENFORCE(m_margin >= 0, "Invalid Approx::margin: " << m_margin << ", Approx::Margin has to be non-negative.");
|
||||
return *this;
|
||||
}
|
||||
|
||||
|
@@ -54,8 +54,8 @@ namespace Catch {
|
||||
}
|
||||
|
||||
std::string AssertionResult::getExpression() const {
|
||||
if (isFalseTest(m_info.resultDisposition))
|
||||
return '!' + std::string(m_info.capturedExpression);
|
||||
if( isFalseTest( m_info.resultDisposition ) )
|
||||
return "!(" + std::string(m_info.capturedExpression) + ")";
|
||||
else
|
||||
return m_info.capturedExpression;
|
||||
}
|
||||
|
@@ -82,7 +82,7 @@
|
||||
|
||||
// Universal Windows platform does not support SEH
|
||||
// Or console colours (or console at all...)
|
||||
# if (WINAPI_FAMILY == WINAPI_FAMILY_APP)
|
||||
# if defined(WINAPI_FAMILY) && (WINAPI_FAMILY == WINAPI_FAMILY_APP)
|
||||
# define CATCH_CONFIG_COLOUR_NONE
|
||||
# else
|
||||
# define CATCH_INTERNAL_CONFIG_WINDOWS_SEH
|
||||
@@ -92,17 +92,16 @@
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
// All supported compilers support COUNTER macro,
|
||||
//but user still might want to turn it off
|
||||
#define CATCH_INTERNAL_CONFIG_COUNTER
|
||||
// Use of __COUNTER__ is suppressed during code analysis in
|
||||
// CLion/AppCode 2017.2.x and former, because __COUNTER__ is not properly
|
||||
// handled by it.
|
||||
// Otherwise all supported compilers support COUNTER macro,
|
||||
// but user still might want to turn it off
|
||||
#if ( !defined(__JETBRAINS_IDE__) || __JETBRAINS_IDE__ >= 20170300L )
|
||||
#define CATCH_INTERNAL_CONFIG_COUNTER
|
||||
#endif
|
||||
|
||||
|
||||
// Now set the actual defines based on the above + anything the user has configured
|
||||
|
||||
// Use of __COUNTER__ is suppressed if __JETBRAINS_IDE__ is #defined (meaning we're being parsed by a JetBrains IDE for
|
||||
// analytics) because, at time of writing, __COUNTER__ is not properly handled by it.
|
||||
// This does not affect compilation
|
||||
#if defined(CATCH_INTERNAL_CONFIG_COUNTER) && !defined(CATCH_CONFIG_NO_COUNTER) && !defined(CATCH_CONFIG_COUNTER) && !defined(__JETBRAINS_IDE__)
|
||||
#if defined(CATCH_INTERNAL_CONFIG_COUNTER) && !defined(CATCH_CONFIG_NO_COUNTER) && !defined(CATCH_CONFIG_COUNTER)
|
||||
# define CATCH_CONFIG_COUNTER
|
||||
#endif
|
||||
#if defined(CATCH_INTERNAL_CONFIG_WINDOWS_SEH) && !defined(CATCH_CONFIG_NO_WINDOWS_SEH) && !defined(CATCH_CONFIG_WINDOWS_SEH)
|
||||
|
@@ -77,7 +77,7 @@ namespace Catch {
|
||||
|
||||
// Specialised comparison functions to handle equality comparisons between ints and pointers (NULL deduces as an int)
|
||||
template<typename LhsT, typename RhsT>
|
||||
auto compareEqual( LhsT const& lhs, RhsT&& rhs ) -> bool { return lhs == rhs; };
|
||||
auto compareEqual( LhsT const& lhs, RhsT const& rhs ) -> bool { return lhs == rhs; };
|
||||
template<typename T>
|
||||
auto compareEqual( T* const& lhs, int rhs ) -> bool { return lhs == reinterpret_cast<void const*>( rhs ); }
|
||||
template<typename T>
|
||||
@@ -106,36 +106,36 @@ namespace Catch {
|
||||
ExprLhs( LhsT lhs ) : m_lhs( lhs ) {}
|
||||
|
||||
template<typename RhsT>
|
||||
auto operator == ( RhsT&& rhs ) -> BinaryExpr<LhsT, RhsT&> const {
|
||||
return BinaryExpr<LhsT, RhsT&>( compareEqual( m_lhs, rhs ), m_lhs, "==", rhs );
|
||||
auto operator == ( RhsT const& rhs ) -> BinaryExpr<LhsT, RhsT const&> const {
|
||||
return BinaryExpr<LhsT, RhsT const&>( compareEqual( m_lhs, rhs ), m_lhs, "==", rhs );
|
||||
}
|
||||
auto operator == ( bool rhs ) -> BinaryExpr<LhsT, bool> const {
|
||||
return BinaryExpr<LhsT, bool>( m_lhs == rhs, m_lhs, "==", rhs );
|
||||
}
|
||||
|
||||
template<typename RhsT>
|
||||
auto operator != ( RhsT&& rhs ) -> BinaryExpr<LhsT, RhsT&> const {
|
||||
return BinaryExpr<LhsT, RhsT&>( compareNotEqual( m_lhs, rhs ), m_lhs, "!=", rhs );
|
||||
auto operator != ( RhsT const& rhs ) -> BinaryExpr<LhsT, RhsT const&> const {
|
||||
return BinaryExpr<LhsT, RhsT const&>( compareNotEqual( m_lhs, rhs ), m_lhs, "!=", rhs );
|
||||
}
|
||||
auto operator != ( bool rhs ) -> BinaryExpr<LhsT, bool> const {
|
||||
return BinaryExpr<LhsT, bool>( m_lhs != rhs, m_lhs, "!=", rhs );
|
||||
}
|
||||
|
||||
template<typename RhsT>
|
||||
auto operator > ( RhsT&& rhs ) -> BinaryExpr<LhsT, RhsT&> const {
|
||||
return BinaryExpr<LhsT, RhsT&>( m_lhs > rhs, m_lhs, ">", rhs );
|
||||
auto operator > ( RhsT const& rhs ) -> BinaryExpr<LhsT, RhsT const&> const {
|
||||
return BinaryExpr<LhsT, RhsT const&>( m_lhs > rhs, m_lhs, ">", rhs );
|
||||
}
|
||||
template<typename RhsT>
|
||||
auto operator < ( RhsT&& rhs ) -> BinaryExpr<LhsT, RhsT&> const {
|
||||
return BinaryExpr<LhsT, RhsT&>( m_lhs < rhs, m_lhs, "<", rhs );
|
||||
auto operator < ( RhsT const& rhs ) -> BinaryExpr<LhsT, RhsT const&> const {
|
||||
return BinaryExpr<LhsT, RhsT const&>( m_lhs < rhs, m_lhs, "<", rhs );
|
||||
}
|
||||
template<typename RhsT>
|
||||
auto operator >= ( RhsT&& rhs ) -> BinaryExpr<LhsT, RhsT&> const {
|
||||
return BinaryExpr<LhsT, RhsT&>( m_lhs >= rhs, m_lhs, ">=", rhs );
|
||||
auto operator >= ( RhsT const& rhs ) -> BinaryExpr<LhsT, RhsT const&> const {
|
||||
return BinaryExpr<LhsT, RhsT const&>( m_lhs >= rhs, m_lhs, ">=", rhs );
|
||||
}
|
||||
template<typename RhsT>
|
||||
auto operator <= ( RhsT&& rhs ) -> BinaryExpr<LhsT, RhsT&> const {
|
||||
return BinaryExpr<LhsT, RhsT&>( m_lhs <= rhs, m_lhs, "<=", rhs );
|
||||
auto operator <= ( RhsT const& rhs ) -> BinaryExpr<LhsT, RhsT const&> const {
|
||||
return BinaryExpr<LhsT, RhsT const&>( m_lhs <= rhs, m_lhs, "<=", rhs );
|
||||
}
|
||||
|
||||
auto makeUnaryExpr() const -> UnaryExpr<LhsT> {
|
||||
@@ -162,4 +162,8 @@ namespace Catch {
|
||||
|
||||
} // end namespace Catch
|
||||
|
||||
#ifdef _MSC_VER
|
||||
#pragma warning(pop)
|
||||
#endif
|
||||
|
||||
#endif // TWOBLUECUBES_CATCH_DECOMPOSER_H_INCLUDED
|
||||
|
@@ -25,7 +25,7 @@ namespace Catch {
|
||||
return std::rand() % n;
|
||||
}
|
||||
RandomNumberGenerator::result_type RandomNumberGenerator::operator()() const {
|
||||
return std::rand() % max();
|
||||
return std::rand() % (max)();
|
||||
}
|
||||
|
||||
}
|
||||
|
@@ -20,10 +20,10 @@ namespace Catch {
|
||||
unsigned int rngSeed();
|
||||
|
||||
struct RandomNumberGenerator {
|
||||
using result_type = std::ptrdiff_t;
|
||||
using result_type = unsigned int;
|
||||
|
||||
static constexpr result_type min() { return 0; }
|
||||
static constexpr result_type max() { return 1000000; }
|
||||
static constexpr result_type (min)() { return 0; }
|
||||
static constexpr result_type (max)() { return 1000000; }
|
||||
|
||||
result_type operator()( result_type n ) const;
|
||||
result_type operator()() const;
|
||||
|
@@ -37,7 +37,7 @@ namespace Catch {
|
||||
}
|
||||
|
||||
Version const& libraryVersion() {
|
||||
static Version version( 2, 0, 0, "develop", 5 );
|
||||
static Version version( 2, 0, 0, "develop", 6 );
|
||||
return version;
|
||||
}
|
||||
|
||||
|
@@ -17,6 +17,14 @@
|
||||
#include <cfloat>
|
||||
#include <cstdio>
|
||||
|
||||
#if defined(_MSC_VER)
|
||||
#pragma warning(push)
|
||||
#pragma warning(disable:4061) // Not all labels are EXPLICITLY handled in switch
|
||||
// Note that 4062 (not all labels are handled
|
||||
// and default is missing) is enabled
|
||||
#endif
|
||||
|
||||
|
||||
namespace Catch {
|
||||
|
||||
namespace {
|
||||
@@ -639,3 +647,7 @@ namespace Catch {
|
||||
ConsoleReporter::~ConsoleReporter() {}
|
||||
|
||||
} // end namespace Catch
|
||||
|
||||
#if defined(_MSC_VER)
|
||||
#pragma warning(pop)
|
||||
#endif
|
||||
|
@@ -133,6 +133,7 @@ namespace Catch {
|
||||
<< "]\n";
|
||||
}
|
||||
}
|
||||
stream.flush();
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -146,6 +147,7 @@ namespace Catch {
|
||||
StreamingReporterBase::testCaseStarting( testInfo );
|
||||
stream << "##teamcity[testStarted name='"
|
||||
<< escape( testInfo.name ) << "']\n";
|
||||
stream.flush();
|
||||
}
|
||||
|
||||
void testCaseEnded( TestCaseStats const& testCaseStats ) override {
|
||||
@@ -161,6 +163,7 @@ namespace Catch {
|
||||
stream << "##teamcity[testFinished name='"
|
||||
<< escape( testCaseStats.testInfo.name ) << "' duration='"
|
||||
<< m_testTimer.getElapsedMilliseconds() << "']\n";
|
||||
stream.flush();
|
||||
}
|
||||
|
||||
private:
|
||||
|
@@ -13,6 +13,13 @@
|
||||
#include "internal/catch_xmlwriter.h"
|
||||
#include "../internal/catch_timer.h"
|
||||
|
||||
#if defined(_MSC_VER)
|
||||
#pragma warning(push)
|
||||
#pragma warning(disable:4061) // Not all labels are EXPLICITLY handled in switch
|
||||
// Note that 4062 (not all labels are handled
|
||||
// and default is missing) is enabled
|
||||
#endif
|
||||
|
||||
namespace Catch {
|
||||
class XmlReporter : public StreamingReporterBase<XmlReporter> {
|
||||
public:
|
||||
@@ -223,3 +230,7 @@ namespace Catch {
|
||||
CATCH_REGISTER_REPORTER( "xml", XmlReporter )
|
||||
|
||||
} // end namespace Catch
|
||||
|
||||
#if defined(_MSC_VER)
|
||||
#pragma warning(pop)
|
||||
#endif
|
||||
|
@@ -24,6 +24,8 @@ TEST_CASE
|
||||
REQUIRE( Approx( d ) == 1.23 );
|
||||
REQUIRE( Approx( d ) != 1.22 );
|
||||
REQUIRE( Approx( d ) != 1.24 );
|
||||
|
||||
REQUIRE( 0 == Approx(0) );
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
@@ -146,11 +148,29 @@ TEST_CASE( "Approximate PI", "[Approx][PI]" )
|
||||
TEST_CASE( "Absolute margin", "[Approx]" ) {
|
||||
REQUIRE( 104.0 != Approx(100.0) );
|
||||
REQUIRE( 104.0 == Approx(100.0).margin(5) );
|
||||
REQUIRE( 104.0 == Approx(100.0).margin(4) );
|
||||
REQUIRE( 104.0 != Approx(100.0).margin(3) );
|
||||
REQUIRE( 100.3 != Approx(100.0) );
|
||||
REQUIRE( 100.3 == Approx(100.0).margin(0.5) );
|
||||
}
|
||||
|
||||
TEST_CASE("Approx with exactly-representable margin", "[Approx]") {
|
||||
CHECK( 0.25f == Approx(0.0f).margin(0.25f) );
|
||||
|
||||
CHECK( 0.0f == Approx(0.25f).margin(0.25f) );
|
||||
CHECK( 0.5f == Approx(0.25f).margin(0.25f) );
|
||||
|
||||
CHECK( 245.0f == Approx(245.25f).margin(0.25f) );
|
||||
CHECK( 245.5f == Approx(245.25f).margin(0.25f) );
|
||||
}
|
||||
|
||||
TEST_CASE("Approx setters validate their arguments", "[Approx]") {
|
||||
REQUIRE_NOTHROW(Approx(0).margin(0));
|
||||
REQUIRE_NOTHROW(Approx(0).margin(1234656));
|
||||
|
||||
REQUIRE_THROWS_AS(Approx(0).margin(-2), std::domain_error);
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
class StrongDoubleTypedef
|
||||
|
@@ -58,6 +58,8 @@ with expansion:
|
||||
|
||||
ConditionTests.cpp:<line number>: FAILED:
|
||||
CHECK_FALSE( true )
|
||||
with expansion:
|
||||
!true
|
||||
|
||||
ConditionTests.cpp:<line number>: FAILED:
|
||||
CHECK( !trueValue )
|
||||
@@ -76,8 +78,6 @@ with expansion:
|
||||
|
||||
ConditionTests.cpp:<line number>: FAILED:
|
||||
CHECK_FALSE( 1 == 1 )
|
||||
with expansion:
|
||||
!(1 == 1)
|
||||
|
||||
-------------------------------------------------------------------------------
|
||||
A METHOD_AS_TEST_CASE based test run that fails
|
||||
@@ -1003,6 +1003,6 @@ with expansion:
|
||||
"{?}" == "1"
|
||||
|
||||
===============================================================================
|
||||
test cases: 179 | 128 passed | 47 failed | 4 failed as expected
|
||||
assertions: 884 | 767 passed | 96 failed | 21 failed as expected
|
||||
test cases: 182 | 131 passed | 47 failed | 4 failed as expected
|
||||
assertions: 896 | 779 passed | 96 failed | 21 failed as expected
|
||||
|
||||
|
@@ -235,6 +235,8 @@ with expansion:
|
||||
|
||||
ConditionTests.cpp:<line number>: FAILED:
|
||||
CHECK_FALSE( true )
|
||||
with expansion:
|
||||
!true
|
||||
|
||||
ConditionTests.cpp:<line number>: FAILED:
|
||||
CHECK( !trueValue )
|
||||
@@ -253,8 +255,6 @@ with expansion:
|
||||
|
||||
ConditionTests.cpp:<line number>: FAILED:
|
||||
CHECK_FALSE( 1 == 1 )
|
||||
with expansion:
|
||||
!(1 == 1)
|
||||
|
||||
-------------------------------------------------------------------------------
|
||||
'Not' checks that should succeed
|
||||
@@ -279,6 +279,8 @@ with expansion:
|
||||
ConditionTests.cpp:<line number>:
|
||||
PASSED:
|
||||
REQUIRE_FALSE( false )
|
||||
with expansion:
|
||||
!false
|
||||
|
||||
ConditionTests.cpp:<line number>:
|
||||
PASSED:
|
||||
@@ -301,8 +303,6 @@ with expansion:
|
||||
ConditionTests.cpp:<line number>:
|
||||
PASSED:
|
||||
REQUIRE_FALSE( 1 == 2 )
|
||||
with expansion:
|
||||
!(1 == 2)
|
||||
|
||||
-------------------------------------------------------------------------------
|
||||
(unimplemented) static bools can be evaluated
|
||||
@@ -490,6 +490,12 @@ PASSED:
|
||||
with expansion:
|
||||
104.0 == Approx( 100.0 )
|
||||
|
||||
ApproxTests.cpp:<line number>:
|
||||
PASSED:
|
||||
REQUIRE( 104.0 == Approx(100.0).margin(4) )
|
||||
with expansion:
|
||||
104.0 == Approx( 100.0 )
|
||||
|
||||
ApproxTests.cpp:<line number>:
|
||||
PASSED:
|
||||
REQUIRE( 104.0 != Approx(100.0).margin(3) )
|
||||
@@ -552,6 +558,60 @@ PASSED:
|
||||
with message:
|
||||
anonymous test case
|
||||
|
||||
-------------------------------------------------------------------------------
|
||||
Approx setters validate their arguments
|
||||
-------------------------------------------------------------------------------
|
||||
ApproxTests.cpp:<line number>
|
||||
...............................................................................
|
||||
|
||||
ApproxTests.cpp:<line number>:
|
||||
PASSED:
|
||||
REQUIRE_NOTHROW( Approx(0).margin(0) )
|
||||
|
||||
ApproxTests.cpp:<line number>:
|
||||
PASSED:
|
||||
REQUIRE_NOTHROW( Approx(0).margin(1234656) )
|
||||
|
||||
ApproxTests.cpp:<line number>:
|
||||
PASSED:
|
||||
REQUIRE_THROWS_AS( Approx(0).margin(-2), std::domain_error )
|
||||
|
||||
-------------------------------------------------------------------------------
|
||||
Approx with exactly-representable margin
|
||||
-------------------------------------------------------------------------------
|
||||
ApproxTests.cpp:<line number>
|
||||
...............................................................................
|
||||
|
||||
ApproxTests.cpp:<line number>:
|
||||
PASSED:
|
||||
CHECK( 0.25f == Approx(0.0f).margin(0.25f) )
|
||||
with expansion:
|
||||
0.25f == Approx( 0.0 )
|
||||
|
||||
ApproxTests.cpp:<line number>:
|
||||
PASSED:
|
||||
CHECK( 0.0f == Approx(0.25f).margin(0.25f) )
|
||||
with expansion:
|
||||
0.0f == Approx( 0.25 )
|
||||
|
||||
ApproxTests.cpp:<line number>:
|
||||
PASSED:
|
||||
CHECK( 0.5f == Approx(0.25f).margin(0.25f) )
|
||||
with expansion:
|
||||
0.5f == Approx( 0.25 )
|
||||
|
||||
ApproxTests.cpp:<line number>:
|
||||
PASSED:
|
||||
CHECK( 245.0f == Approx(245.25f).margin(0.25f) )
|
||||
with expansion:
|
||||
245.0f == Approx( 245.25 )
|
||||
|
||||
ApproxTests.cpp:<line number>:
|
||||
PASSED:
|
||||
CHECK( 245.5f == Approx(245.25f).margin(0.25f) )
|
||||
with expansion:
|
||||
245.5f == Approx( 245.25 )
|
||||
|
||||
-------------------------------------------------------------------------------
|
||||
Approximate PI
|
||||
-------------------------------------------------------------------------------
|
||||
@@ -738,6 +798,24 @@ PASSED:
|
||||
with expansion:
|
||||
true
|
||||
|
||||
-------------------------------------------------------------------------------
|
||||
Bitfields can be captured (#1027)
|
||||
-------------------------------------------------------------------------------
|
||||
TrickyTests.cpp:<line number>
|
||||
...............................................................................
|
||||
|
||||
TrickyTests.cpp:<line number>:
|
||||
PASSED:
|
||||
REQUIRE( y.v == 0 )
|
||||
with expansion:
|
||||
0 == 0
|
||||
|
||||
TrickyTests.cpp:<line number>:
|
||||
PASSED:
|
||||
REQUIRE( 0 == y.v )
|
||||
with expansion:
|
||||
0 == 0
|
||||
|
||||
-------------------------------------------------------------------------------
|
||||
Capture and info messages
|
||||
Capture should stringify like assertions
|
||||
@@ -4183,6 +4261,12 @@ PASSED:
|
||||
with expansion:
|
||||
Approx( 1.23 ) != 1.24
|
||||
|
||||
ApproxTests.cpp:<line number>:
|
||||
PASSED:
|
||||
REQUIRE( 0 == Approx(0) )
|
||||
with expansion:
|
||||
0 == Approx( 0.0 )
|
||||
|
||||
Message from section one
|
||||
-------------------------------------------------------------------------------
|
||||
Standard output from all sections is reported
|
||||
@@ -7490,6 +7574,6 @@ MiscTests.cpp:<line number>:
|
||||
PASSED:
|
||||
|
||||
===============================================================================
|
||||
test cases: 179 | 126 passed | 49 failed | 4 failed as expected
|
||||
assertions: 883 | 763 passed | 99 failed | 21 failed as expected
|
||||
test cases: 182 | 129 passed | 49 failed | 4 failed as expected
|
||||
assertions: 895 | 775 passed | 99 failed | 21 failed as expected
|
||||
|
||||
|
@@ -235,6 +235,8 @@ with expansion:
|
||||
|
||||
ConditionTests.cpp:<line number>: FAILED:
|
||||
CHECK_FALSE( true )
|
||||
with expansion:
|
||||
!true
|
||||
|
||||
===============================================================================
|
||||
test cases: 9 | 6 passed | 1 failed | 2 failed as expected
|
||||
|
@@ -1,7 +1,7 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<testsuitesloose text artifact
|
||||
>
|
||||
<testsuite name="<exe-name>" errors="15" failures="85" tests="884" hostname="tbd" time="{duration}" timestamp="{iso8601-timestamp}">
|
||||
<testsuite name="<exe-name>" errors="15" failures="85" tests="896" hostname="tbd" time="{duration}" timestamp="{iso8601-timestamp}">
|
||||
<testcase classname="<exe-name>.global" name="# A test name that starts with a #" time="{duration}"/>
|
||||
<testcase classname="<exe-name>.global" name="#1005: Comparing pointer to int and long (NULL can be either on various systems)" time="{duration}"/>
|
||||
<testcase classname="<exe-name>.global" name="#748 - captures with unexpected exceptions/outside assertions" time="{duration}">
|
||||
@@ -100,6 +100,8 @@ ExceptionTests.cpp:<line number>
|
||||
</error>
|
||||
</testcase>
|
||||
<testcase classname="<exe-name>.global" name="Anonymous test case 1" time="{duration}"/>
|
||||
<testcase classname="<exe-name>.global" name="Approx setters validate their arguments" time="{duration}"/>
|
||||
<testcase classname="<exe-name>.global" name="Approx with exactly-representable margin" time="{duration}"/>
|
||||
<testcase classname="<exe-name>.global" name="Approximate PI" time="{duration}"/>
|
||||
<testcase classname="<exe-name>.global" name="Approximate comparisons with different epsilons" time="{duration}"/>
|
||||
<testcase classname="<exe-name>.global" name="Approximate comparisons with floats" time="{duration}"/>
|
||||
@@ -109,6 +111,7 @@ ExceptionTests.cpp:<line number>
|
||||
<testcase classname="<exe-name>.global" name="Assertions then sections/A section" time="{duration}"/>
|
||||
<testcase classname="<exe-name>.global" name="Assertions then sections/A section/Another section" time="{duration}"/>
|
||||
<testcase classname="<exe-name>.global" name="Assertions then sections/A section/Another other section" time="{duration}"/>
|
||||
<testcase classname="<exe-name>.global" name="Bitfields can be captured (#1027)" time="{duration}"/>
|
||||
<testcase classname="<exe-name>.global" name="Capture and info messages/Capture should stringify like assertions" time="{duration}"/>
|
||||
<testcase classname="<exe-name>.global" name="Capture and info messages/Info should NOT stringify the way assertions do" time="{duration}"/>
|
||||
<testcase classname="<exe-name>.global" name="Character pretty printing/Specifically escaped" time="{duration}"/>
|
||||
|
@@ -214,7 +214,7 @@
|
||||
</Expression>
|
||||
<Expression success="false" type="CHECK_FALSE" filename="projects/<exe-name>/ConditionTests.cpp" >
|
||||
<Original>
|
||||
!true
|
||||
!(true)
|
||||
</Original>
|
||||
<Expanded>
|
||||
!true
|
||||
@@ -230,7 +230,7 @@
|
||||
</Expression>
|
||||
<Expression success="false" type="CHECK_FALSE" filename="projects/<exe-name>/ConditionTests.cpp" >
|
||||
<Original>
|
||||
!trueValue
|
||||
!(trueValue)
|
||||
</Original>
|
||||
<Expanded>
|
||||
!true
|
||||
@@ -246,7 +246,7 @@
|
||||
</Expression>
|
||||
<Expression success="false" type="CHECK_FALSE" filename="projects/<exe-name>/ConditionTests.cpp" >
|
||||
<Original>
|
||||
!1 == 1
|
||||
!(1 == 1)
|
||||
</Original>
|
||||
<Expanded>
|
||||
!(1 == 1)
|
||||
@@ -281,7 +281,7 @@
|
||||
</Expression>
|
||||
<Expression success="true" type="REQUIRE_FALSE" filename="projects/<exe-name>/ConditionTests.cpp" >
|
||||
<Original>
|
||||
!false
|
||||
!(false)
|
||||
</Original>
|
||||
<Expanded>
|
||||
!false
|
||||
@@ -297,7 +297,7 @@
|
||||
</Expression>
|
||||
<Expression success="true" type="REQUIRE_FALSE" filename="projects/<exe-name>/ConditionTests.cpp" >
|
||||
<Original>
|
||||
!falseValue
|
||||
!(falseValue)
|
||||
</Original>
|
||||
<Expanded>
|
||||
!false
|
||||
@@ -313,7 +313,7 @@
|
||||
</Expression>
|
||||
<Expression success="true" type="REQUIRE_FALSE" filename="projects/<exe-name>/ConditionTests.cpp" >
|
||||
<Original>
|
||||
!1 == 2
|
||||
!(1 == 2)
|
||||
</Original>
|
||||
<Expanded>
|
||||
!(1 == 2)
|
||||
@@ -393,7 +393,7 @@
|
||||
</Expression>
|
||||
<Expression success="true" type="REQUIRE_FALSE" filename="projects/<exe-name>/TrickyTests.cpp" >
|
||||
<Original>
|
||||
!is_true<false>::value
|
||||
!(is_true<false>::value)
|
||||
</Original>
|
||||
<Expanded>
|
||||
!false
|
||||
@@ -495,6 +495,14 @@
|
||||
104.0 == Approx( 100.0 )
|
||||
</Expanded>
|
||||
</Expression>
|
||||
<Expression success="true" type="REQUIRE" filename="projects/<exe-name>/ApproxTests.cpp" >
|
||||
<Original>
|
||||
104.0 == Approx(100.0).margin(4)
|
||||
</Original>
|
||||
<Expanded>
|
||||
104.0 == Approx( 100.0 )
|
||||
</Expanded>
|
||||
</Expression>
|
||||
<Expression success="true" type="REQUIRE" filename="projects/<exe-name>/ApproxTests.cpp" >
|
||||
<Original>
|
||||
104.0 != Approx(100.0).margin(3)
|
||||
@@ -568,6 +576,76 @@
|
||||
<TestCase name="Anonymous test case 1" filename="projects/<exe-name>/VariadicMacrosTests.cpp" >
|
||||
<OverallResult success="true"/>
|
||||
</TestCase>
|
||||
<TestCase name="Approx setters validate their arguments" tags="[Approx]" filename="projects/<exe-name>/ApproxTests.cpp" >
|
||||
<Expression success="true" type="REQUIRE_NOTHROW" filename="projects/<exe-name>/ApproxTests.cpp" >
|
||||
<Original>
|
||||
Approx(0).margin(0)
|
||||
</Original>
|
||||
<Expanded>
|
||||
Approx(0).margin(0)
|
||||
</Expanded>
|
||||
</Expression>
|
||||
<Expression success="true" type="REQUIRE_NOTHROW" filename="projects/<exe-name>/ApproxTests.cpp" >
|
||||
<Original>
|
||||
Approx(0).margin(1234656)
|
||||
</Original>
|
||||
<Expanded>
|
||||
Approx(0).margin(1234656)
|
||||
</Expanded>
|
||||
</Expression>
|
||||
<Expression success="true" type="REQUIRE_THROWS_AS" filename="projects/<exe-name>/ApproxTests.cpp" >
|
||||
<Original>
|
||||
Approx(0).margin(-2), std::domain_error
|
||||
</Original>
|
||||
<Expanded>
|
||||
Approx(0).margin(-2), std::domain_error
|
||||
</Expanded>
|
||||
</Expression>
|
||||
<OverallResult success="true"/>
|
||||
</TestCase>
|
||||
<TestCase name="Approx with exactly-representable margin" tags="[Approx]" filename="projects/<exe-name>/ApproxTests.cpp" >
|
||||
<Expression success="true" type="CHECK" filename="projects/<exe-name>/ApproxTests.cpp" >
|
||||
<Original>
|
||||
0.25f == Approx(0.0f).margin(0.25f)
|
||||
</Original>
|
||||
<Expanded>
|
||||
0.25f == Approx( 0.0 )
|
||||
</Expanded>
|
||||
</Expression>
|
||||
<Expression success="true" type="CHECK" filename="projects/<exe-name>/ApproxTests.cpp" >
|
||||
<Original>
|
||||
0.0f == Approx(0.25f).margin(0.25f)
|
||||
</Original>
|
||||
<Expanded>
|
||||
0.0f == Approx( 0.25 )
|
||||
</Expanded>
|
||||
</Expression>
|
||||
<Expression success="true" type="CHECK" filename="projects/<exe-name>/ApproxTests.cpp" >
|
||||
<Original>
|
||||
0.5f == Approx(0.25f).margin(0.25f)
|
||||
</Original>
|
||||
<Expanded>
|
||||
0.5f == Approx( 0.25 )
|
||||
</Expanded>
|
||||
</Expression>
|
||||
<Expression success="true" type="CHECK" filename="projects/<exe-name>/ApproxTests.cpp" >
|
||||
<Original>
|
||||
245.0f == Approx(245.25f).margin(0.25f)
|
||||
</Original>
|
||||
<Expanded>
|
||||
245.0f == Approx( 245.25 )
|
||||
</Expanded>
|
||||
</Expression>
|
||||
<Expression success="true" type="CHECK" filename="projects/<exe-name>/ApproxTests.cpp" >
|
||||
<Original>
|
||||
245.5f == Approx(245.25f).margin(0.25f)
|
||||
</Original>
|
||||
<Expanded>
|
||||
245.5f == Approx( 245.25 )
|
||||
</Expanded>
|
||||
</Expression>
|
||||
<OverallResult success="true"/>
|
||||
</TestCase>
|
||||
<TestCase name="Approximate PI" tags="[Approx][PI]" filename="projects/<exe-name>/ApproxTests.cpp" >
|
||||
<Expression success="true" type="REQUIRE" filename="projects/<exe-name>/ApproxTests.cpp" >
|
||||
<Original>
|
||||
@@ -750,6 +828,25 @@
|
||||
</Section>
|
||||
<OverallResult success="true"/>
|
||||
</TestCase>
|
||||
<TestCase name="Bitfields can be captured (#1027)" filename="projects/<exe-name>/TrickyTests.cpp" >
|
||||
<Expression success="true" type="REQUIRE" filename="projects/<exe-name>/TrickyTests.cpp" >
|
||||
<Original>
|
||||
y.v == 0
|
||||
</Original>
|
||||
<Expanded>
|
||||
0 == 0
|
||||
</Expanded>
|
||||
</Expression>
|
||||
<Expression success="true" type="REQUIRE" filename="projects/<exe-name>/TrickyTests.cpp" >
|
||||
<Original>
|
||||
0 == y.v
|
||||
</Original>
|
||||
<Expanded>
|
||||
0 == 0
|
||||
</Expanded>
|
||||
</Expression>
|
||||
<OverallResult success="true"/>
|
||||
</TestCase>
|
||||
<TestCase name="Capture and info messages" filename="projects/<exe-name>/ToStringGeneralTests.cpp" >
|
||||
<Section name="Capture should stringify like assertions" filename="projects/<exe-name>/ToStringGeneralTests.cpp" >
|
||||
<Info>
|
||||
@@ -956,7 +1053,7 @@
|
||||
</Expression>
|
||||
<Expression success="true" type="REQUIRE_FALSE" filename="projects/<exe-name>/TrickyTests.cpp" >
|
||||
<Original>
|
||||
!std::vector<int>{1, 2} == std::vector<int>{1, 2, 3}
|
||||
!(std::vector<int>{1, 2} == std::vector<int>{1, 2, 3})
|
||||
</Original>
|
||||
<Expanded>
|
||||
!({ 1, 2 } == { 1, 2, 3 })
|
||||
@@ -964,7 +1061,7 @@
|
||||
</Expression>
|
||||
<Expression success="true" type="CHECK_FALSE" filename="projects/<exe-name>/TrickyTests.cpp" >
|
||||
<Original>
|
||||
!std::vector<int>{1, 2} == std::vector<int>{1, 2, 3}
|
||||
!(std::vector<int>{1, 2} == std::vector<int>{1, 2, 3})
|
||||
</Original>
|
||||
<Expanded>
|
||||
!({ 1, 2 } == { 1, 2, 3 })
|
||||
@@ -1794,7 +1891,7 @@
|
||||
</Expression>
|
||||
<Expression success="true" type="REQUIRE_FALSE" filename="projects/<exe-name>/ApproxTests.cpp" >
|
||||
<Original>
|
||||
!d >= Approx( 1.24 )
|
||||
!(d >= Approx( 1.24 ))
|
||||
</Original>
|
||||
<Expanded>
|
||||
!(1.23 >= Approx( 1.24 ))
|
||||
@@ -2211,7 +2308,7 @@
|
||||
</Expression>
|
||||
<Expression success="true" type="REQUIRE_FALSE" filename="projects/<exe-name>/ApproxTests.cpp" >
|
||||
<Original>
|
||||
!d <= Approx( 1.22 )
|
||||
!(d <= Approx( 1.22 ))
|
||||
</Original>
|
||||
<Expanded>
|
||||
!(1.23 <= Approx( 1.22 ))
|
||||
@@ -2354,7 +2451,7 @@
|
||||
</Expression>
|
||||
<Expression success="true" type="CHECK_FALSE" filename="projects/<exe-name>/TrickyTests.cpp" >
|
||||
<Original>
|
||||
!False
|
||||
!(False)
|
||||
</Original>
|
||||
<Expanded>
|
||||
!{?}
|
||||
@@ -4776,6 +4873,14 @@ A string sent directly to stderr
|
||||
Approx( 1.23 ) != 1.24
|
||||
</Expanded>
|
||||
</Expression>
|
||||
<Expression success="true" type="REQUIRE" filename="projects/<exe-name>/ApproxTests.cpp" >
|
||||
<Original>
|
||||
0 == Approx(0)
|
||||
</Original>
|
||||
<Expanded>
|
||||
0 == Approx( 0.0 )
|
||||
</Expanded>
|
||||
</Expression>
|
||||
<OverallResult success="true"/>
|
||||
</TestCase>
|
||||
<TestCase name="Standard output from all sections is reported" tags="[.][messages]" filename="projects/<exe-name>/MessageTests.cpp" >
|
||||
@@ -7614,7 +7719,7 @@ loose text artifact
|
||||
<Section name="replace no chars" filename="projects/<exe-name>/TestMain.cpp" >
|
||||
<Expression success="true" type="CHECK_FALSE" filename="projects/<exe-name>/TestMain.cpp" >
|
||||
<Original>
|
||||
!Catch::replaceInPlace( letters, "x", "z" )
|
||||
!(Catch::replaceInPlace( letters, "x", "z" ))
|
||||
</Original>
|
||||
<Expanded>
|
||||
!false
|
||||
@@ -8268,7 +8373,7 @@ loose text artifact
|
||||
</Section>
|
||||
<OverallResult success="true"/>
|
||||
</TestCase>
|
||||
<OverallResults successes="763" failures="100" expectedFailures="21"/>
|
||||
<OverallResults successes="775" failures="100" expectedFailures="21"/>
|
||||
</Group>
|
||||
<OverallResults successes="763" failures="99" expectedFailures="21"/>
|
||||
<OverallResults successes="775" failures="99" expectedFailures="21"/>
|
||||
</Catch>
|
||||
|
@@ -168,7 +168,7 @@ namespace ObjectWithConversions
|
||||
{
|
||||
struct Object
|
||||
{
|
||||
operator unsigned int() {return 0xc0000000;}
|
||||
operator unsigned int() const {return 0xc0000000;}
|
||||
};
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
@@ -436,3 +436,12 @@ TEST_CASE("#925: comparing function pointer to function address failed to compil
|
||||
TestClass test;
|
||||
REQUIRE(utility::synchronizing_callback != test.testMethod_uponComplete_arg);
|
||||
}
|
||||
|
||||
TEST_CASE( "Bitfields can be captured (#1027)" ) {
|
||||
struct Y {
|
||||
uint32_t v : 1;
|
||||
};
|
||||
Y y{ 0 };
|
||||
REQUIRE( y.v == 0 );
|
||||
REQUIRE( 0 == y.v );
|
||||
}
|
||||
|
@@ -15,6 +15,7 @@ versionPath = os.path.join( rootPath, "internal/catch_version.cpp" )
|
||||
readmePath = os.path.join( catchPath, "README.md" )
|
||||
conanPath = os.path.join(catchPath, 'conanfile.py')
|
||||
conanTestPath = os.path.join(catchPath, 'test_package', 'conanfile.py')
|
||||
cmakePath = os.path.join(catchPath, 'CMakeLists.txt')
|
||||
|
||||
class Version:
|
||||
def __init__(self):
|
||||
@@ -126,6 +127,17 @@ def updateConanTestFile(version):
|
||||
for line in lines:
|
||||
f.write( line + "\n" )
|
||||
|
||||
def updateCmakeFile(version):
|
||||
cmakeParser = re.compile(r'set(CATCH_VERSION_NUMBER \d+\.\d+\.\d+)')
|
||||
with open(cmakePath, 'r') as file:
|
||||
lines = file.readlines()
|
||||
with open(cmakePath, 'w') as file:
|
||||
for line in lines:
|
||||
if 'set(CATCH_VERSION_NUMBER ' in line:
|
||||
file.write('set(CATCH_VERSION_NUMBER {0})\n'.format(version.getVersionString()))
|
||||
else:
|
||||
file.write(line)
|
||||
|
||||
def performUpdates(version):
|
||||
# First update version file, so we can regenerate single header and
|
||||
# have it ready for upload to wandbox, when updating readme
|
||||
@@ -134,3 +146,4 @@ def performUpdates(version):
|
||||
updateReadmeFile(version)
|
||||
updateConanFile(version)
|
||||
updateConanTestFile(version)
|
||||
updateCmakeFile(version)
|
||||
|
@@ -30,7 +30,7 @@ headingExcludeRelease = [2,3,4,5] # use level 1 headers for release-notes.md
|
||||
documentsDefault = os.path.join(os.path.relpath(catchPath), 'docs/*.md')
|
||||
releaseNotesName = 'release-notes.md'
|
||||
|
||||
contentTitle = '**Contents** '
|
||||
contentTitle = '**Contents**'
|
||||
contentLineNo = 4
|
||||
contentLineNdx = contentLineNo - 1
|
||||
|
||||
@@ -210,14 +210,14 @@ def createToc(headlines, hyperlink=True, top_link=False, no_toc_header=False):
|
||||
if not no_toc_header:
|
||||
if top_link:
|
||||
processed.append('<a class="mk-toclify" id="table-of-contents"></a>\n')
|
||||
processed.append(contentTitle)
|
||||
processed.append(contentTitle + '<br>')
|
||||
|
||||
for line in headlines:
|
||||
if hyperlink:
|
||||
item = '[%s](#%s) ' % (line[0], line[1])
|
||||
item = '[%s](#%s)' % (line[0], line[1])
|
||||
else:
|
||||
item = '%s- %s' % ((line[2]-1)*' ', line[0])
|
||||
processed.append(item)
|
||||
processed.append(item + '<br>')
|
||||
processed.append('\n')
|
||||
return processed
|
||||
|
||||
|
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
* Catch v2.0.0-develop.5
|
||||
* Generated: 2017-10-12 13:05:08.135067
|
||||
* Catch v2.0.0-develop.6
|
||||
* Generated: 2017-10-31 15:09:47.277913
|
||||
* ----------------------------------------------------------
|
||||
* This file has been merged from multiple headers. Please don't edit it directly
|
||||
* Copyright (c) 2017 Two Blue Cubes Ltd. All rights reserved.
|
||||
@@ -155,7 +155,7 @@
|
||||
|
||||
// Universal Windows platform does not support SEH
|
||||
// Or console colours (or console at all...)
|
||||
# if (WINAPI_FAMILY == WINAPI_FAMILY_APP)
|
||||
# if defined(WINAPI_FAMILY) && (WINAPI_FAMILY == WINAPI_FAMILY_APP)
|
||||
# define CATCH_CONFIG_COLOUR_NONE
|
||||
# else
|
||||
# define CATCH_INTERNAL_CONFIG_WINDOWS_SEH
|
||||
@@ -165,16 +165,16 @@
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
// All supported compilers support COUNTER macro,
|
||||
//but user still might want to turn it off
|
||||
#define CATCH_INTERNAL_CONFIG_COUNTER
|
||||
// Use of __COUNTER__ is suppressed during code analysis in
|
||||
// CLion/AppCode 2017.2.x and former, because __COUNTER__ is not properly
|
||||
// handled by it.
|
||||
// Otherwise all supported compilers support COUNTER macro,
|
||||
// but user still might want to turn it off
|
||||
#if ( !defined(__JETBRAINS_IDE__) || __JETBRAINS_IDE__ >= 20170300L )
|
||||
#define CATCH_INTERNAL_CONFIG_COUNTER
|
||||
#endif
|
||||
|
||||
// Now set the actual defines based on the above + anything the user has configured
|
||||
|
||||
// Use of __COUNTER__ is suppressed if __JETBRAINS_IDE__ is #defined (meaning we're being parsed by a JetBrains IDE for
|
||||
// analytics) because, at time of writing, __COUNTER__ is not properly handled by it.
|
||||
// This does not affect compilation
|
||||
#if defined(CATCH_INTERNAL_CONFIG_COUNTER) && !defined(CATCH_CONFIG_NO_COUNTER) && !defined(CATCH_CONFIG_COUNTER) && !defined(__JETBRAINS_IDE__)
|
||||
#if defined(CATCH_INTERNAL_CONFIG_COUNTER) && !defined(CATCH_CONFIG_NO_COUNTER) && !defined(CATCH_CONFIG_COUNTER)
|
||||
# define CATCH_CONFIG_COUNTER
|
||||
#endif
|
||||
#if defined(CATCH_INTERNAL_CONFIG_WINDOWS_SEH) && !defined(CATCH_CONFIG_NO_WINDOWS_SEH) && !defined(CATCH_CONFIG_WINDOWS_SEH)
|
||||
@@ -1037,7 +1037,7 @@ namespace Catch {
|
||||
|
||||
// Specialised comparison functions to handle equality comparisons between ints and pointers (NULL deduces as an int)
|
||||
template<typename LhsT, typename RhsT>
|
||||
auto compareEqual( LhsT const& lhs, RhsT&& rhs ) -> bool { return lhs == rhs; };
|
||||
auto compareEqual( LhsT const& lhs, RhsT const& rhs ) -> bool { return lhs == rhs; };
|
||||
template<typename T>
|
||||
auto compareEqual( T* const& lhs, int rhs ) -> bool { return lhs == reinterpret_cast<void const*>( rhs ); }
|
||||
template<typename T>
|
||||
@@ -1065,36 +1065,36 @@ namespace Catch {
|
||||
ExprLhs( LhsT lhs ) : m_lhs( lhs ) {}
|
||||
|
||||
template<typename RhsT>
|
||||
auto operator == ( RhsT&& rhs ) -> BinaryExpr<LhsT, RhsT&> const {
|
||||
return BinaryExpr<LhsT, RhsT&>( compareEqual( m_lhs, rhs ), m_lhs, "==", rhs );
|
||||
auto operator == ( RhsT const& rhs ) -> BinaryExpr<LhsT, RhsT const&> const {
|
||||
return BinaryExpr<LhsT, RhsT const&>( compareEqual( m_lhs, rhs ), m_lhs, "==", rhs );
|
||||
}
|
||||
auto operator == ( bool rhs ) -> BinaryExpr<LhsT, bool> const {
|
||||
return BinaryExpr<LhsT, bool>( m_lhs == rhs, m_lhs, "==", rhs );
|
||||
}
|
||||
|
||||
template<typename RhsT>
|
||||
auto operator != ( RhsT&& rhs ) -> BinaryExpr<LhsT, RhsT&> const {
|
||||
return BinaryExpr<LhsT, RhsT&>( compareNotEqual( m_lhs, rhs ), m_lhs, "!=", rhs );
|
||||
auto operator != ( RhsT const& rhs ) -> BinaryExpr<LhsT, RhsT const&> const {
|
||||
return BinaryExpr<LhsT, RhsT const&>( compareNotEqual( m_lhs, rhs ), m_lhs, "!=", rhs );
|
||||
}
|
||||
auto operator != ( bool rhs ) -> BinaryExpr<LhsT, bool> const {
|
||||
return BinaryExpr<LhsT, bool>( m_lhs != rhs, m_lhs, "!=", rhs );
|
||||
}
|
||||
|
||||
template<typename RhsT>
|
||||
auto operator > ( RhsT&& rhs ) -> BinaryExpr<LhsT, RhsT&> const {
|
||||
return BinaryExpr<LhsT, RhsT&>( m_lhs > rhs, m_lhs, ">", rhs );
|
||||
auto operator > ( RhsT const& rhs ) -> BinaryExpr<LhsT, RhsT const&> const {
|
||||
return BinaryExpr<LhsT, RhsT const&>( m_lhs > rhs, m_lhs, ">", rhs );
|
||||
}
|
||||
template<typename RhsT>
|
||||
auto operator < ( RhsT&& rhs ) -> BinaryExpr<LhsT, RhsT&> const {
|
||||
return BinaryExpr<LhsT, RhsT&>( m_lhs < rhs, m_lhs, "<", rhs );
|
||||
auto operator < ( RhsT const& rhs ) -> BinaryExpr<LhsT, RhsT const&> const {
|
||||
return BinaryExpr<LhsT, RhsT const&>( m_lhs < rhs, m_lhs, "<", rhs );
|
||||
}
|
||||
template<typename RhsT>
|
||||
auto operator >= ( RhsT&& rhs ) -> BinaryExpr<LhsT, RhsT&> const {
|
||||
return BinaryExpr<LhsT, RhsT&>( m_lhs >= rhs, m_lhs, ">=", rhs );
|
||||
auto operator >= ( RhsT const& rhs ) -> BinaryExpr<LhsT, RhsT const&> const {
|
||||
return BinaryExpr<LhsT, RhsT const&>( m_lhs >= rhs, m_lhs, ">=", rhs );
|
||||
}
|
||||
template<typename RhsT>
|
||||
auto operator <= ( RhsT&& rhs ) -> BinaryExpr<LhsT, RhsT&> const {
|
||||
return BinaryExpr<LhsT, RhsT&>( m_lhs <= rhs, m_lhs, "<=", rhs );
|
||||
auto operator <= ( RhsT const& rhs ) -> BinaryExpr<LhsT, RhsT const&> const {
|
||||
return BinaryExpr<LhsT, RhsT const&>( m_lhs <= rhs, m_lhs, "<=", rhs );
|
||||
}
|
||||
|
||||
auto makeUnaryExpr() const -> UnaryExpr<LhsT> {
|
||||
@@ -1121,6 +1121,10 @@ namespace Catch {
|
||||
|
||||
} // end namespace Catch
|
||||
|
||||
#ifdef _MSC_VER
|
||||
#pragma warning(pop)
|
||||
#endif
|
||||
|
||||
// end catch_decomposer.h
|
||||
// start catch_assertioninfo.h
|
||||
|
||||
@@ -1816,6 +1820,21 @@ namespace Catch {
|
||||
// end catch_interfaces_exception.h
|
||||
// start catch_approx.h
|
||||
|
||||
// start catch_enforce.h
|
||||
|
||||
#include <sstream>
|
||||
#include <stdexcept>
|
||||
|
||||
#define CATCH_PREPARE_EXCEPTION( type, msg ) \
|
||||
type( static_cast<std::ostringstream&&>( std::ostringstream() << msg ).str() )
|
||||
#define CATCH_INTERNAL_ERROR( msg ) \
|
||||
throw CATCH_PREPARE_EXCEPTION( std::logic_error, CATCH_INTERNAL_LINEINFO << ": Internal Catch error: " << msg);
|
||||
#define CATCH_ERROR( msg ) \
|
||||
throw CATCH_PREPARE_EXCEPTION( std::domain_error, msg )
|
||||
#define CATCH_ENFORCE( condition, msg ) \
|
||||
do{ if( !(condition) ) CATCH_ERROR( msg ); } while(false)
|
||||
|
||||
// end catch_enforce.h
|
||||
#include <cmath>
|
||||
|
||||
#include <type_traits>
|
||||
@@ -1823,7 +1842,7 @@ namespace Catch {
|
||||
namespace Catch {
|
||||
namespace Detail {
|
||||
|
||||
double max(double lhs, double rhs);
|
||||
double dmax(double lhs, double rhs);
|
||||
|
||||
class Approx {
|
||||
public:
|
||||
@@ -1848,11 +1867,12 @@ namespace Detail {
|
||||
friend bool operator == ( const T& lhs, Approx const& rhs ) {
|
||||
// Thanks to Richard Harris for his help refining this formula
|
||||
auto lhs_v = static_cast<double>(lhs);
|
||||
bool relativeOK = std::fabs(lhs_v - rhs.m_value) < rhs.m_epsilon * (rhs.m_scale + (max)(std::fabs(lhs_v), std::fabs(rhs.m_value)));
|
||||
bool relativeOK = std::fabs(lhs_v - rhs.m_value) < rhs.m_epsilon * (rhs.m_scale +
|
||||
dmax(std::fabs(lhs_v), std::fabs(rhs.m_value)));
|
||||
if (relativeOK) {
|
||||
return true;
|
||||
}
|
||||
return std::fabs(lhs_v - rhs.m_value) < rhs.m_margin;
|
||||
return std::fabs(lhs_v - rhs.m_value) <= rhs.m_margin;
|
||||
}
|
||||
|
||||
template <typename T, typename = typename std::enable_if<std::is_constructible<double, T>::value>::type>
|
||||
@@ -1899,6 +1919,7 @@ namespace Detail {
|
||||
template <typename T, typename = typename std::enable_if<std::is_constructible<double, T>::value>::type>
|
||||
Approx& margin( T const& newMargin ) {
|
||||
m_margin = static_cast<double>(newMargin);
|
||||
CATCH_ENFORCE(m_margin >= 0, "Invalid Approx::margin: " << m_margin << ", Approx::Margin has to be non-negative.");
|
||||
return *this;
|
||||
}
|
||||
|
||||
@@ -2643,21 +2664,6 @@ return @ desc; \
|
||||
|
||||
// start catch_reporter_bases.hpp
|
||||
|
||||
// start catch_enforce.h
|
||||
|
||||
#include <sstream>
|
||||
#include <stdexcept>
|
||||
|
||||
#define CATCH_PREPARE_EXCEPTION( type, msg ) \
|
||||
type( static_cast<std::ostringstream&&>( std::ostringstream() << msg ).str() )
|
||||
#define CATCH_INTERNAL_ERROR( msg ) \
|
||||
throw CATCH_PREPARE_EXCEPTION( std::logic_error, CATCH_INTERNAL_LINEINFO << ": Internal Catch error: " << msg);
|
||||
#define CATCH_ERROR( msg ) \
|
||||
throw CATCH_PREPARE_EXCEPTION( std::domain_error, msg )
|
||||
#define CATCH_ENFORCE( condition, msg ) \
|
||||
do{ if( !(condition) ) CATCH_ERROR( msg ); } while(false)
|
||||
|
||||
// end catch_enforce.h
|
||||
// start catch_interfaces_reporter.h
|
||||
|
||||
// start catch_config.hpp
|
||||
@@ -3979,7 +3985,7 @@ namespace Catch {
|
||||
namespace Catch {
|
||||
namespace Detail {
|
||||
|
||||
double max(double lhs, double rhs) {
|
||||
double dmax(double lhs, double rhs) {
|
||||
if (lhs < rhs) {
|
||||
return rhs;
|
||||
}
|
||||
@@ -4226,8 +4232,8 @@ namespace Catch {
|
||||
}
|
||||
|
||||
std::string AssertionResult::getExpression() const {
|
||||
if (isFalseTest(m_info.resultDisposition))
|
||||
return '!' + std::string(m_info.capturedExpression);
|
||||
if( isFalseTest( m_info.resultDisposition ) )
|
||||
return "!(" + std::string(m_info.capturedExpression) + ")";
|
||||
else
|
||||
return m_info.capturedExpression;
|
||||
}
|
||||
@@ -4334,7 +4340,7 @@ namespace Catch {
|
||||
#endif
|
||||
|
||||
// start clara.hpp
|
||||
// v1.0
|
||||
// v1.0-develop.2
|
||||
// See https://github.com/philsquared/Clara
|
||||
|
||||
|
||||
@@ -4737,6 +4743,14 @@ namespace detail {
|
||||
std::string token;
|
||||
};
|
||||
|
||||
inline auto isOptPrefix( char c ) -> bool {
|
||||
return c == '-'
|
||||
#ifdef CATCH_PLATFORM_WINDOWS
|
||||
|| c == '/'
|
||||
#endif
|
||||
;
|
||||
}
|
||||
|
||||
// Abstracts iterators into args as a stream of tokens, with option arguments uniformly handled
|
||||
class TokenStream {
|
||||
using Iterator = std::vector<std::string>::const_iterator;
|
||||
@@ -4753,7 +4767,7 @@ namespace detail {
|
||||
|
||||
if( it != itEnd ) {
|
||||
auto const &next = *it;
|
||||
if( next[0] == '-' || next[0] == '/' ) {
|
||||
if( isOptPrefix( next[0] ) ) {
|
||||
auto delimiterPos = next.find_first_of( " :=" );
|
||||
if( delimiterPos != std::string::npos ) {
|
||||
m_tokenBuffer.push_back( { TokenType::Option, next.substr( 0, delimiterPos ) } );
|
||||
@@ -5241,9 +5255,11 @@ namespace detail {
|
||||
};
|
||||
|
||||
inline auto normaliseOpt( std::string const &optName ) -> std::string {
|
||||
#ifdef CATCH_PLATFORM_WINDOWS
|
||||
if( optName[0] == '/' )
|
||||
return "-" + optName.substr( 1 );
|
||||
else
|
||||
#endif
|
||||
return optName;
|
||||
}
|
||||
|
||||
@@ -5284,11 +5300,7 @@ namespace detail {
|
||||
}
|
||||
|
||||
auto isMatch( std::string const &optToken ) const -> bool {
|
||||
#ifdef CATCH_PLATFORM_WINDOWS
|
||||
auto normalisedToken = normaliseOpt( optToken );
|
||||
#else
|
||||
auto const &normalisedToken = optToken;
|
||||
#endif
|
||||
for( auto const &name : m_optNames ) {
|
||||
if( normaliseOpt( name ) == normalisedToken )
|
||||
return true;
|
||||
@@ -5338,8 +5350,13 @@ namespace detail {
|
||||
for( auto const &name : m_optNames ) {
|
||||
if( name.empty() )
|
||||
return Result::logicError( "Option name cannot be empty" );
|
||||
#ifdef CATCH_PLATFORM_WINDOWS
|
||||
if( name[0] != '-' && name[0] != '/' )
|
||||
return Result::logicError( "Option name must begin with '-' or '/'" );
|
||||
#else
|
||||
if( name[0] != '-' )
|
||||
return Result::logicError( "Option name must begin with '-'" );
|
||||
#endif
|
||||
}
|
||||
return ParserRefImpl::validate();
|
||||
}
|
||||
@@ -5428,7 +5445,7 @@ namespace detail {
|
||||
size_t consoleWidth = CATCH_CLARA_CONFIG_CONSOLE_WIDTH;
|
||||
size_t optWidth = 0;
|
||||
for( auto const &cols : rows )
|
||||
optWidth = std::max(optWidth, cols.left.size() + 2);
|
||||
optWidth = (std::max)(optWidth, cols.left.size() + 2);
|
||||
|
||||
for( auto const &cols : rows ) {
|
||||
auto row =
|
||||
@@ -7188,10 +7205,10 @@ namespace Catch {
|
||||
unsigned int rngSeed();
|
||||
|
||||
struct RandomNumberGenerator {
|
||||
using result_type = std::ptrdiff_t;
|
||||
using result_type = unsigned int;
|
||||
|
||||
static constexpr result_type min() { return 0; }
|
||||
static constexpr result_type max() { return 1000000; }
|
||||
static constexpr result_type (min)() { return 0; }
|
||||
static constexpr result_type (max)() { return 1000000; }
|
||||
|
||||
result_type operator()( result_type n ) const;
|
||||
result_type operator()() const;
|
||||
@@ -7222,7 +7239,7 @@ namespace Catch {
|
||||
return std::rand() % n;
|
||||
}
|
||||
RandomNumberGenerator::result_type RandomNumberGenerator::operator()() const {
|
||||
return std::rand() % max();
|
||||
return std::rand() % (max)();
|
||||
}
|
||||
|
||||
}
|
||||
@@ -9785,7 +9802,7 @@ namespace Catch {
|
||||
}
|
||||
|
||||
Version const& libraryVersion() {
|
||||
static Version version( 2, 0, 0, "develop", 5 );
|
||||
static Version version( 2, 0, 0, "develop", 6 );
|
||||
return version;
|
||||
}
|
||||
|
||||
@@ -10453,6 +10470,13 @@ namespace Catch {
|
||||
#include <cfloat>
|
||||
#include <cstdio>
|
||||
|
||||
#if defined(_MSC_VER)
|
||||
#pragma warning(push)
|
||||
#pragma warning(disable:4061) // Not all labels are EXPLICITLY handled in switch
|
||||
// Note that 4062 (not all labels are handled
|
||||
// and default is missing) is enabled
|
||||
#endif
|
||||
|
||||
namespace Catch {
|
||||
|
||||
namespace {
|
||||
@@ -11074,6 +11098,10 @@ namespace Catch {
|
||||
ConsoleReporter::~ConsoleReporter() {}
|
||||
|
||||
} // end namespace Catch
|
||||
|
||||
#if defined(_MSC_VER)
|
||||
#pragma warning(pop)
|
||||
#endif
|
||||
// end catch_reporter_console.cpp
|
||||
// start catch_reporter_junit.cpp
|
||||
|
||||
@@ -11415,6 +11443,13 @@ namespace Catch {
|
||||
// end catch_reporter_multi.cpp
|
||||
// start catch_reporter_xml.cpp
|
||||
|
||||
#if defined(_MSC_VER)
|
||||
#pragma warning(push)
|
||||
#pragma warning(disable:4061) // Not all labels are EXPLICITLY handled in switch
|
||||
// Note that 4062 (not all labels are handled
|
||||
// and default is missing) is enabled
|
||||
#endif
|
||||
|
||||
namespace Catch {
|
||||
class XmlReporter : public StreamingReporterBase<XmlReporter> {
|
||||
public:
|
||||
@@ -11624,6 +11659,10 @@ namespace Catch {
|
||||
CATCH_REGISTER_REPORTER( "xml", XmlReporter )
|
||||
|
||||
} // end namespace Catch
|
||||
|
||||
#if defined(_MSC_VER)
|
||||
#pragma warning(pop)
|
||||
#endif
|
||||
// end catch_reporter_xml.cpp
|
||||
|
||||
namespace Catch {
|
||||
|
@@ -10,7 +10,7 @@ class CatchConanTest(ConanFile):
|
||||
settings = "os", "compiler", "arch", "build_type"
|
||||
username = getenv("CONAN_USERNAME", "philsquared")
|
||||
channel = getenv("CONAN_CHANNEL", "testing")
|
||||
requires = "Catch/2.0.0-develop.5@%s/%s" % (username, channel)
|
||||
requires = "Catch/2.0.0-develop.6@%s/%s" % (username, channel)
|
||||
|
||||
def build(self):
|
||||
cmake = CMake(self)
|
||||
|
41
third_party/clara.hpp
vendored
41
third_party/clara.hpp
vendored
@@ -1,4 +1,4 @@
|
||||
// v1.0
|
||||
// v1.0-develop.2
|
||||
// See https://github.com/philsquared/Clara
|
||||
|
||||
#ifndef CLARA_HPP_INCLUDED
|
||||
@@ -409,6 +409,14 @@ namespace detail {
|
||||
std::string token;
|
||||
};
|
||||
|
||||
inline auto isOptPrefix( char c ) -> bool {
|
||||
return c == '-'
|
||||
#ifdef CLARA_PLATFORM_WINDOWS
|
||||
|| c == '/'
|
||||
#endif
|
||||
;
|
||||
}
|
||||
|
||||
// Abstracts iterators into args as a stream of tokens, with option arguments uniformly handled
|
||||
class TokenStream {
|
||||
using Iterator = std::vector<std::string>::const_iterator;
|
||||
@@ -425,7 +433,7 @@ namespace detail {
|
||||
|
||||
if( it != itEnd ) {
|
||||
auto const &next = *it;
|
||||
if( next[0] == '-' || next[0] == '/' ) {
|
||||
if( isOptPrefix( next[0] ) ) {
|
||||
auto delimiterPos = next.find_first_of( " :=" );
|
||||
if( delimiterPos != std::string::npos ) {
|
||||
m_tokenBuffer.push_back( { TokenType::Option, next.substr( 0, delimiterPos ) } );
|
||||
@@ -915,9 +923,11 @@ namespace detail {
|
||||
};
|
||||
|
||||
inline auto normaliseOpt( std::string const &optName ) -> std::string {
|
||||
#ifdef CLARA_PLATFORM_WINDOWS
|
||||
if( optName[0] == '/' )
|
||||
return "-" + optName.substr( 1 );
|
||||
else
|
||||
#endif
|
||||
return optName;
|
||||
}
|
||||
|
||||
@@ -958,11 +968,7 @@ namespace detail {
|
||||
}
|
||||
|
||||
auto isMatch( std::string const &optToken ) const -> bool {
|
||||
#ifdef CLARA_PLATFORM_WINDOWS
|
||||
auto normalisedToken = normaliseOpt( optToken );
|
||||
#else
|
||||
auto const &normalisedToken = optToken;
|
||||
#endif
|
||||
for( auto const &name : m_optNames ) {
|
||||
if( normaliseOpt( name ) == normalisedToken )
|
||||
return true;
|
||||
@@ -1012,8 +1018,13 @@ namespace detail {
|
||||
for( auto const &name : m_optNames ) {
|
||||
if( name.empty() )
|
||||
return Result::logicError( "Option name cannot be empty" );
|
||||
#ifdef CLARA_PLATFORM_WINDOWS
|
||||
if( name[0] != '-' && name[0] != '/' )
|
||||
return Result::logicError( "Option name must begin with '-' or '/'" );
|
||||
#else
|
||||
if( name[0] != '-' )
|
||||
return Result::logicError( "Option name must begin with '-'" );
|
||||
#endif
|
||||
}
|
||||
return ParserRefImpl::validate();
|
||||
}
|
||||
@@ -1103,7 +1114,7 @@ namespace detail {
|
||||
size_t consoleWidth = CLARA_CONFIG_CONSOLE_WIDTH;
|
||||
size_t optWidth = 0;
|
||||
for( auto const &cols : rows )
|
||||
optWidth = std::max(optWidth, cols.left.size() + 2);
|
||||
optWidth = (std::max)(optWidth, cols.left.size() + 2);
|
||||
|
||||
for( auto const &cols : rows ) {
|
||||
auto row =
|
||||
@@ -1142,10 +1153,15 @@ namespace detail {
|
||||
size_t count = 0;
|
||||
};
|
||||
const size_t totalParsers = m_options.size() + m_args.size();
|
||||
ParserInfo parseInfos[totalParsers];
|
||||
size_t i = 0;
|
||||
for( auto const& opt : m_options ) parseInfos[i++].parser = &opt;
|
||||
for( auto const& arg : m_args ) parseInfos[i++].parser = &arg;
|
||||
assert( totalParsers < 512 );
|
||||
// ParserInfo parseInfos[totalParsers]; // <-- this is what we really want to do
|
||||
ParserInfo parseInfos[512];
|
||||
|
||||
{
|
||||
size_t i = 0;
|
||||
for (auto const &opt : m_options) parseInfos[i++].parser = &opt;
|
||||
for (auto const &arg : m_args) parseInfos[i++].parser = &arg;
|
||||
}
|
||||
|
||||
m_exeName.set( exeName );
|
||||
|
||||
@@ -1153,7 +1169,8 @@ namespace detail {
|
||||
while( result.value().remainingTokens() ) {
|
||||
bool tokenParsed = false;
|
||||
|
||||
for( auto& parseInfo : parseInfos ) {
|
||||
for( size_t i = 0; i < totalParsers; ++i ) {
|
||||
auto& parseInfo = parseInfos[i];
|
||||
if( parseInfo.parser->cardinality() == 0 || parseInfo.count < parseInfo.parser->cardinality() ) {
|
||||
result = parseInfo.parser->parse(exeName, result.value().remainingTokens());
|
||||
if (!result)
|
||||
|
Reference in New Issue
Block a user