提交 400d0cf2 authored 作者: Iñaki Baz Castillo's avatar Iñaki Baz Castillo

Update Catch to v2.12.3

上级 a329dc14
...@@ -6,6 +6,7 @@ ...@@ -6,6 +6,7 @@
* `Transport::ReceiveRtpPacket()`: Call `RecvStreamClosed(packet->GetSsrc())` if received RTP packet does not match any `Producer`. * `Transport::ReceiveRtpPacket()`: Call `RecvStreamClosed(packet->GetSsrc())` if received RTP packet does not match any `Producer`.
* `Transport::HandleRtcpPacket()`: Ensure `Consumer` is found for received NACK Feedback packets. * `Transport::HandleRtcpPacket()`: Ensure `Consumer` is found for received NACK Feedback packets.
* Update NPM deps. * Update NPM deps.
* Update C++ `Catch` dep.
### 3.6.8 ### 3.6.8
......
---
AccessModifierOffset: '-4'
AlignEscapedNewlines: Left
AllowAllConstructorInitializersOnNextLine: 'true'
BinPackArguments: 'false'
BinPackParameters: 'false'
BreakConstructorInitializers: AfterColon
ConstructorInitializerAllOnOneLineOrOnePerLine: 'true'
DerivePointerAlignment: 'false'
FixNamespaceComments: 'true'
IncludeBlocks: Regroup
IndentCaseLabels: 'false'
IndentPPDirectives: AfterHash
IndentWidth: '4'
Language: Cpp
NamespaceIndentation: All
PointerAlignment: Left
SpaceBeforeCtorInitializerColon: 'false'
SpaceInEmptyParentheses: 'false'
SpacesInParentheses: 'true'
Standard: Cpp11
TabWidth: '4'
UseTab: Never
...
...@@ -14,7 +14,7 @@ if (CMAKE_BINARY_DIR STREQUAL CMAKE_CURRENT_SOURCE_DIR) ...@@ -14,7 +14,7 @@ if (CMAKE_BINARY_DIR STREQUAL CMAKE_CURRENT_SOURCE_DIR)
endif() endif()
project(Catch2 LANGUAGES CXX VERSION 2.12.2) project(Catch2 LANGUAGES CXX VERSION 2.12.3)
# Provide path for scripts # Provide path for scripts
list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_LIST_DIR}/CMake") list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_LIST_DIR}/CMake")
......
...@@ -5,11 +5,11 @@ ...@@ -5,11 +5,11 @@
[![Build Status](https://travis-ci.org/catchorg/Catch2.svg?branch=master)](https://travis-ci.org/catchorg/Catch2) [![Build Status](https://travis-ci.org/catchorg/Catch2.svg?branch=master)](https://travis-ci.org/catchorg/Catch2)
[![Build status](https://ci.appveyor.com/api/projects/status/github/catchorg/Catch2?svg=true)](https://ci.appveyor.com/project/catchorg/catch2) [![Build status](https://ci.appveyor.com/api/projects/status/github/catchorg/Catch2?svg=true)](https://ci.appveyor.com/project/catchorg/catch2)
[![codecov](https://codecov.io/gh/catchorg/Catch2/branch/master/graph/badge.svg)](https://codecov.io/gh/catchorg/Catch2) [![codecov](https://codecov.io/gh/catchorg/Catch2/branch/master/graph/badge.svg)](https://codecov.io/gh/catchorg/Catch2)
[![Try online](https://img.shields.io/badge/try-online-blue.svg)](https://wandbox.org/permlink/QdDfqVqDGRuwcduN) [![Try online](https://img.shields.io/badge/try-online-blue.svg)](https://wandbox.org/permlink/yfl7WhNJBY0IpgtF)
[![Join the chat in Discord: https://discord.gg/4CWS9zD](https://img.shields.io/badge/Discord-Chat!-brightgreen.svg)](https://discord.gg/4CWS9zD) [![Join the chat in Discord: https://discord.gg/4CWS9zD](https://img.shields.io/badge/Discord-Chat!-brightgreen.svg)](https://discord.gg/4CWS9zD)
<a href="https://github.com/catchorg/Catch2/releases/download/v2.12.2/catch.hpp">The latest version of the single header can be downloaded directly using this link</a> <a href="https://github.com/catchorg/Catch2/releases/download/v2.12.3/catch.hpp">The latest version of the single header can be downloaded directly using this link</a>
## Catch2 is released! ## Catch2 is released!
......
...@@ -12,17 +12,36 @@ are run once per each value in a generator. ...@@ -12,17 +12,36 @@ are run once per each value in a generator.
This is best explained with an example: This is best explained with an example:
```cpp ```cpp
TEST_CASE("Generators") { TEST_CASE("Generators") {
auto i = GENERATE(1, 2, 3); auto i = GENERATE(1, 2);
SECTION("one") { SECTION("one") {
auto j = GENERATE( -3, -2, -1 ); auto j = GENERATE(-3, -2);
REQUIRE(j < i); REQUIRE(j < i);
} }
SECTION("two") {
auto k = GENERATE(4, 5, 6);
REQUIRE(j != k);
}
} }
``` ```
The assertion in this test case will be run 9 times, because there The `SECTION` "one" will be run 4 (2*2) times, because the outer
are 3 possible values for `i` (1, 2, and 3) and there are 3 possible generator has 2 elements in it, and the inner generator also has 2
values for `j` (-3, -2, and -1). elements in it. The `SECTION` "two" will be run 6 (2*3) times. The
sections will be run in order "one", "one", "two", "two", "two", "one",
...
It is also possible to have multiple generators at the same level of
nesting. The result is the same as when generators are inside nested
sections, that is, the result will be a cartesian product of all
elements. This means that in the snippet below, the test case will be
run 6 (2*3) times.
```cpp
TEST_CASE("Generators") {
auto i = GENERATE(1, 2);
auto j = GENERATE(3, 4, 5);
}
```
There are 2 parts to generators in Catch2, the `GENERATE` macro together There are 2 parts to generators in Catch2, the `GENERATE` macro together
......
...@@ -16,6 +16,7 @@ ...@@ -16,6 +16,7 @@
- Configuration: [Provide your own output streams](../examples/231-Cfg-OutputStreams.cpp) - Configuration: [Provide your own output streams](../examples/231-Cfg-OutputStreams.cpp)
- Generators: [Create your own generator](../examples/300-Gen-OwnGenerator.cpp) - Generators: [Create your own generator](../examples/300-Gen-OwnGenerator.cpp)
- Generators: [Use map to convert types in GENERATE expression](../examples/301-Gen-MapTypeConversion.cpp) - Generators: [Use map to convert types in GENERATE expression](../examples/301-Gen-MapTypeConversion.cpp)
- Generators: [Run test with a table of input values](../examples/302-Gen-Table.cpp)
- Generators: [Use variables in generator expressions](../examples/310-Gen-VariablesInGenerators.cpp) - Generators: [Use variables in generator expressions](../examples/310-Gen-VariablesInGenerators.cpp)
- Generators: [Use custom variable capture in generator expressions](../examples/311-Gen-CustomCapture.cpp) - Generators: [Use custom variable capture in generator expressions](../examples/311-Gen-CustomCapture.cpp)
......
...@@ -2,6 +2,7 @@ ...@@ -2,6 +2,7 @@
# Release notes # Release notes
**Contents**<br> **Contents**<br>
[2.12.3](#2123)<br>
[2.12.2](#2122)<br> [2.12.2](#2122)<br>
[2.12.1](#2121)<br> [2.12.1](#2121)<br>
[2.12.0](#2120)<br> [2.12.0](#2120)<br>
...@@ -38,6 +39,26 @@ ...@@ -38,6 +39,26 @@
[Even Older versions](#even-older-versions)<br> [Even Older versions](#even-older-versions)<br>
## 2.12.3
### Fixes
* `GENERATE` nested in a for loop no longer creates multiple generators (#1913)
* Fixed copy paste error breaking `TEMPLATE_TEST_CASE_SIG` for 6 or more arguments (#1954)
* Fixed potential UB when handling non-ASCII characters in CLI args (#1943)
### Improvements
* There can be multiple calls to `GENERATE` on a single line
* Improved `fno-except` support for platforms that do not provide shims for exception-related std functions (#1950)
* E.g. the Green Hills C++ compiler
* XmlReporter now also reports test-case-level statistics (#1958)
* This is done via a new element, `OverallResultsCases`
### Miscellaneous
* Added `.clang-format` file to the repo (#1182, #1920)
* Rewrote contributing docs
* They should explain the different levels of testing and so on much better
## 2.12.2 ## 2.12.2
### Fixes ### Fixes
......
// 301-Gen-MapTypeConversion.cpp // 301-Gen-MapTypeConversion.cpp
// Shows how to use map to modify generator's return type. // Shows how to use map to modify generator's return type.
// TODO // Specifically we wrap a std::string returning generator with a generator
// that converts the strings using stoi, so the returned type is actually
// an int.
#include <catch2/catch.hpp> #include <catch2/catch.hpp>
......
// 302-Gen-Table.cpp
// Shows how to use table to run a test many times with different inputs. Lifted from examples on
// issue #850.
#include <catch2/catch.hpp>
#include <string>
struct TestSubject {
// this is the method we are going to test. It returns the length of the
// input string.
size_t GetLength( const std::string& input ) const { return input.size(); }
};
TEST_CASE("Table allows pre-computed test inputs and outputs", "[example][generator]") {
using std::make_tuple;
// do setup here as normal
TestSubject subj;
SECTION("This section is run for each row in the table") {
std::string test_input;
size_t expected_output;
std::tie( test_input, expected_output ) =
GENERATE( table<std::string, size_t>(
{ /* In this case one of the parameters to our test case is the
* expected output, but this is not required. There could be
* multiple expected values in the table, which can have any
* (fixed) number of columns.
*/
make_tuple( "one", 3 ),
make_tuple( "two", 3 ),
make_tuple( "three", 5 ),
make_tuple( "four", 4 ) } ) );
// run the test
auto result = subj.GetLength(test_input);
// capture the input data to go with the outputs.
CAPTURE(test_input);
// check it matches the pre-calculated data
REQUIRE(result == expected_output);
} // end section
}
/* Possible simplifications where less legacy toolchain support is needed:
*
* - With libstdc++6 or newer, the make_tuple() calls can be ommitted
* (technically C++17 but does not require -std in GCC/Clang). See
* https://stackoverflow.com/questions/12436586/tuple-vector-and-initializer-list
*
* - In C++17 mode std::tie() and the preceeding variable delcarations can be
* replaced by structured bindings: auto [test_input, expected] = GENERATE(
* table<std::string, size_t>({ ...
*/
// Compiling and running this file will result in 4 successful assertions
...@@ -23,11 +23,11 @@ TEST_CASE("Generate random doubles across different ranges", ...@@ -23,11 +23,11 @@ TEST_CASE("Generate random doubles across different ranges",
})); }));
auto r2(r1); auto r2(r1);
// This will take r1 by reference and r2 by value. // This will take r1 by reference and r2 by value.
// Note that there are no advantages for doing so in this example, // Note that there are no advantages for doing so in this example,
// it is done only for expository purposes. // it is done only for expository purposes.
auto number = Catch::Generators::generate( CATCH_INTERNAL_LINEINFO, auto number = Catch::Generators::generate( "custom capture generator", CATCH_INTERNAL_LINEINFO,
[&r1, r2]{ [&r1, r2]{
using namespace Catch::Generators; using namespace Catch::Generators;
return makeGenerators(take(50, random(std::get<0>(r1), std::get<1>(r2)))); return makeGenerators(take(50, random(std::get<0>(r1), std::get<1>(r2))));
......
...@@ -46,6 +46,7 @@ set( SOURCES_IDIOMATIC_TESTS ...@@ -46,6 +46,7 @@ set( SOURCES_IDIOMATIC_TESTS
210-Evt-EventListeners.cpp 210-Evt-EventListeners.cpp
300-Gen-OwnGenerator.cpp 300-Gen-OwnGenerator.cpp
301-Gen-MapTypeConversion.cpp 301-Gen-MapTypeConversion.cpp
302-Gen-Table.cpp
310-Gen-VariablesInGenerators.cpp 310-Gen-VariablesInGenerators.cpp
311-Gen-CustomCapture.cpp 311-Gen-CustomCapture.cpp
) )
......
...@@ -11,7 +11,7 @@ ...@@ -11,7 +11,7 @@
#define CATCH_VERSION_MAJOR 2 #define CATCH_VERSION_MAJOR 2
#define CATCH_VERSION_MINOR 12 #define CATCH_VERSION_MINOR 12
#define CATCH_VERSION_PATCH 2 #define CATCH_VERSION_PATCH 3
#ifdef __clang__ #ifdef __clang__
# pragma clang system_header # pragma clang system_header
......
...@@ -667,7 +667,7 @@ namespace detail { ...@@ -667,7 +667,7 @@ namespace detail {
} }
inline auto convertInto( std::string const &source, bool &target ) -> ParserResult { inline auto convertInto( std::string const &source, bool &target ) -> ParserResult {
std::string srcLC = source; std::string srcLC = source;
std::transform( srcLC.begin(), srcLC.end(), srcLC.begin(), []( char c ) { return static_cast<char>( std::tolower(c) ); } ); std::transform( srcLC.begin(), srcLC.end(), srcLC.begin(), []( unsigned char c ) { return static_cast<char>( std::tolower(c) ); } );
if (srcLC == "y" || srcLC == "1" || srcLC == "true" || srcLC == "yes" || srcLC == "on") if (srcLC == "y" || srcLC == "1" || srcLC == "true" || srcLC == "yes" || srcLC == "on")
target = true; target = true;
else if (srcLC == "n" || srcLC == "0" || srcLC == "false" || srcLC == "no" || srcLC == "off") else if (srcLC == "n" || srcLC == "0" || srcLC == "false" || srcLC == "no" || srcLC == "off")
......
...@@ -24,8 +24,8 @@ namespace Generators { ...@@ -24,8 +24,8 @@ namespace Generators {
GeneratorUntypedBase::~GeneratorUntypedBase() {} GeneratorUntypedBase::~GeneratorUntypedBase() {}
auto acquireGeneratorTracker( SourceLineInfo const& lineInfo ) -> IGeneratorTracker& { auto acquireGeneratorTracker( StringRef generatorName, SourceLineInfo const& lineInfo ) -> IGeneratorTracker& {
return getResultCapture().acquireGeneratorTracker( lineInfo ); return getResultCapture().acquireGeneratorTracker( generatorName, lineInfo );
} }
} // namespace Generators } // namespace Generators
......
...@@ -10,6 +10,7 @@ ...@@ -10,6 +10,7 @@
#include "catch_interfaces_generatortracker.h" #include "catch_interfaces_generatortracker.h"
#include "catch_common.h" #include "catch_common.h"
#include "catch_enforce.h" #include "catch_enforce.h"
#include "catch_stringref.h"
#include <memory> #include <memory>
#include <vector> #include <vector>
...@@ -181,16 +182,16 @@ namespace Generators { ...@@ -181,16 +182,16 @@ namespace Generators {
return makeGenerators( value( T( std::forward<U>( val ) ) ), std::forward<Gs>( moreGenerators )... ); return makeGenerators( value( T( std::forward<U>( val ) ) ), std::forward<Gs>( moreGenerators )... );
} }
auto acquireGeneratorTracker( SourceLineInfo const& lineInfo ) -> IGeneratorTracker&; auto acquireGeneratorTracker( StringRef generatorName, SourceLineInfo const& lineInfo ) -> IGeneratorTracker&;
template<typename L> template<typename L>
// Note: The type after -> is weird, because VS2015 cannot parse // Note: The type after -> is weird, because VS2015 cannot parse
// the expression used in the typedef inside, when it is in // the expression used in the typedef inside, when it is in
// return type. Yeah. // return type. Yeah.
auto generate( SourceLineInfo const& lineInfo, L const& generatorExpression ) -> decltype(std::declval<decltype(generatorExpression())>().get()) { auto generate( StringRef generatorName, SourceLineInfo const& lineInfo, L const& generatorExpression ) -> decltype(std::declval<decltype(generatorExpression())>().get()) {
using UnderlyingType = typename decltype(generatorExpression())::type; using UnderlyingType = typename decltype(generatorExpression())::type;
IGeneratorTracker& tracker = acquireGeneratorTracker( lineInfo ); IGeneratorTracker& tracker = acquireGeneratorTracker( generatorName, lineInfo );
if (!tracker.hasGenerator()) { if (!tracker.hasGenerator()) {
tracker.setGenerator(pf::make_unique<Generators<UnderlyingType>>(generatorExpression())); tracker.setGenerator(pf::make_unique<Generators<UnderlyingType>>(generatorExpression()));
} }
...@@ -203,10 +204,16 @@ namespace Generators { ...@@ -203,10 +204,16 @@ namespace Generators {
} // namespace Catch } // namespace Catch
#define GENERATE( ... ) \ #define GENERATE( ... ) \
Catch::Generators::generate( CATCH_INTERNAL_LINEINFO, [ ]{ using namespace Catch::Generators; return makeGenerators( __VA_ARGS__ ); } ) //NOLINT(google-build-using-namespace) Catch::Generators::generate( INTERNAL_CATCH_STRINGIZE(INTERNAL_CATCH_UNIQUE_NAME(generator)), \
CATCH_INTERNAL_LINEINFO, \
[ ]{ using namespace Catch::Generators; return makeGenerators( __VA_ARGS__ ); } ) //NOLINT(google-build-using-namespace)
#define GENERATE_COPY( ... ) \ #define GENERATE_COPY( ... ) \
Catch::Generators::generate( CATCH_INTERNAL_LINEINFO, [=]{ using namespace Catch::Generators; return makeGenerators( __VA_ARGS__ ); } ) //NOLINT(google-build-using-namespace) Catch::Generators::generate( INTERNAL_CATCH_STRINGIZE(INTERNAL_CATCH_UNIQUE_NAME(generator)), \
CATCH_INTERNAL_LINEINFO, \
[=]{ using namespace Catch::Generators; return makeGenerators( __VA_ARGS__ ); } ) //NOLINT(google-build-using-namespace)
#define GENERATE_REF( ... ) \ #define GENERATE_REF( ... ) \
Catch::Generators::generate( CATCH_INTERNAL_LINEINFO, [&]{ using namespace Catch::Generators; return makeGenerators( __VA_ARGS__ ); } ) //NOLINT(google-build-using-namespace) Catch::Generators::generate( INTERNAL_CATCH_STRINGIZE(INTERNAL_CATCH_UNIQUE_NAME(generator)), \
CATCH_INTERNAL_LINEINFO, \
[&]{ using namespace Catch::Generators; return makeGenerators( __VA_ARGS__ ); } ) //NOLINT(google-build-using-namespace)
#endif // TWOBLUECUBES_CATCH_GENERATORS_HPP_INCLUDED #endif // TWOBLUECUBES_CATCH_GENERATORS_HPP_INCLUDED
...@@ -44,7 +44,7 @@ namespace Catch { ...@@ -44,7 +44,7 @@ namespace Catch {
virtual void sectionEnded( SectionEndInfo const& endInfo ) = 0; virtual void sectionEnded( SectionEndInfo const& endInfo ) = 0;
virtual void sectionEndedEarly( SectionEndInfo const& endInfo ) = 0; virtual void sectionEndedEarly( SectionEndInfo const& endInfo ) = 0;
virtual auto acquireGeneratorTracker( SourceLineInfo const& lineInfo ) -> IGeneratorTracker& = 0; virtual auto acquireGeneratorTracker( StringRef generatorName, SourceLineInfo const& lineInfo ) -> IGeneratorTracker& = 0;
#if defined(CATCH_CONFIG_ENABLE_BENCHMARKING) #if defined(CATCH_CONFIG_ENABLE_BENCHMARKING)
virtual void benchmarkPreparing( std::string const& name ) = 0; virtual void benchmarkPreparing( std::string const& name ) = 0;
......
/* /*
* Created by Jozef on 12/11/2018. * Created by Jozef on 12/11/2018.
* Copyright 2017 Two Blue Cubes Ltd. All rights reserved. * Copyright 2017 Two Blue Cubes Ltd. All rights reserved.
...@@ -90,7 +91,7 @@ ...@@ -90,7 +91,7 @@
#define INTERNAL_CATCH_REMOVE_PARENS_4_ARG(_0, _1, _2, _3) INTERNAL_CATCH_REMOVE_PARENS(_0), INTERNAL_CATCH_REMOVE_PARENS_3_ARG(_1, _2, _3) #define INTERNAL_CATCH_REMOVE_PARENS_4_ARG(_0, _1, _2, _3) INTERNAL_CATCH_REMOVE_PARENS(_0), INTERNAL_CATCH_REMOVE_PARENS_3_ARG(_1, _2, _3)
#define INTERNAL_CATCH_REMOVE_PARENS_5_ARG(_0, _1, _2, _3, _4) INTERNAL_CATCH_REMOVE_PARENS(_0), INTERNAL_CATCH_REMOVE_PARENS_4_ARG(_1, _2, _3, _4) #define INTERNAL_CATCH_REMOVE_PARENS_5_ARG(_0, _1, _2, _3, _4) INTERNAL_CATCH_REMOVE_PARENS(_0), INTERNAL_CATCH_REMOVE_PARENS_4_ARG(_1, _2, _3, _4)
#define INTERNAL_CATCH_REMOVE_PARENS_6_ARG(_0, _1, _2, _3, _4, _5) INTERNAL_CATCH_REMOVE_PARENS(_0), INTERNAL_CATCH_REMOVE_PARENS_5_ARG(_1, _2, _3, _4, _5) #define INTERNAL_CATCH_REMOVE_PARENS_6_ARG(_0, _1, _2, _3, _4, _5) INTERNAL_CATCH_REMOVE_PARENS(_0), INTERNAL_CATCH_REMOVE_PARENS_5_ARG(_1, _2, _3, _4, _5)
#define INTERNAL_CATCH_REMOVE_PARENS_7_ARG(_0, _1, _2, _3, _4, _5, _6) INTERNAL_CATCH_REMOVE_PARENS(_0), INTERNAL_CATCH_REMOVE_PARENS_6_ARG(_1, _2, _4, _5, _6) #define INTERNAL_CATCH_REMOVE_PARENS_7_ARG(_0, _1, _2, _3, _4, _5, _6) INTERNAL_CATCH_REMOVE_PARENS(_0), INTERNAL_CATCH_REMOVE_PARENS_6_ARG(_1, _2, _3, _4, _5, _6)
#define INTERNAL_CATCH_REMOVE_PARENS_8_ARG(_0, _1, _2, _3, _4, _5, _6, _7) INTERNAL_CATCH_REMOVE_PARENS(_0), INTERNAL_CATCH_REMOVE_PARENS_7_ARG(_1, _2, _3, _4, _5, _6, _7) #define INTERNAL_CATCH_REMOVE_PARENS_8_ARG(_0, _1, _2, _3, _4, _5, _6, _7) INTERNAL_CATCH_REMOVE_PARENS(_0), INTERNAL_CATCH_REMOVE_PARENS_7_ARG(_1, _2, _3, _4, _5, _6, _7)
#define INTERNAL_CATCH_REMOVE_PARENS_9_ARG(_0, _1, _2, _3, _4, _5, _6, _7, _8) INTERNAL_CATCH_REMOVE_PARENS(_0), INTERNAL_CATCH_REMOVE_PARENS_8_ARG(_1, _2, _3, _4, _5, _6, _7, _8) #define INTERNAL_CATCH_REMOVE_PARENS_9_ARG(_0, _1, _2, _3, _4, _5, _6, _7, _8) INTERNAL_CATCH_REMOVE_PARENS(_0), INTERNAL_CATCH_REMOVE_PARENS_8_ARG(_1, _2, _3, _4, _5, _6, _7, _8)
#define INTERNAL_CATCH_REMOVE_PARENS_10_ARG(_0, _1, _2, _3, _4, _5, _6, _7, _8, _9) INTERNAL_CATCH_REMOVE_PARENS(_0), INTERNAL_CATCH_REMOVE_PARENS_9_ARG(_1, _2, _3, _4, _5, _6, _7, _8, _9) #define INTERNAL_CATCH_REMOVE_PARENS_10_ARG(_0, _1, _2, _3, _4, _5, _6, _7, _8, _9) INTERNAL_CATCH_REMOVE_PARENS(_0), INTERNAL_CATCH_REMOVE_PARENS_9_ARG(_1, _2, _3, _4, _5, _6, _7, _8, _9)
......
...@@ -59,7 +59,11 @@ namespace Catch { ...@@ -59,7 +59,11 @@ namespace Catch {
m_tagAliasRegistry.add( alias, tag, lineInfo ); m_tagAliasRegistry.add( alias, tag, lineInfo );
} }
void registerStartupException() noexcept override { void registerStartupException() noexcept override {
#if !defined(CATCH_CONFIG_DISABLE_EXCEPTIONS)
m_exceptionRegistry.add(std::current_exception()); m_exceptionRegistry.add(std::current_exception());
#else
CATCH_INTERNAL_ERROR("Attempted to register active exception under CATCH_CONFIG_DISABLE_EXCEPTIONS!");
#endif
} }
IMutableEnumValuesRegistry& getMutableEnumValuesRegistry() override { IMutableEnumValuesRegistry& getMutableEnumValuesRegistry() override {
return m_enumValuesRegistry; return m_enumValuesRegistry;
......
...@@ -25,12 +25,27 @@ namespace Catch { ...@@ -25,12 +25,27 @@ namespace Catch {
std::shared_ptr<GeneratorTracker> tracker; std::shared_ptr<GeneratorTracker> tracker;
ITracker& currentTracker = ctx.currentTracker(); ITracker& currentTracker = ctx.currentTracker();
if( TestCaseTracking::ITrackerPtr childTracker = currentTracker.findChild( nameAndLocation ) ) { // Under specific circumstances, the generator we want
// to acquire is also the current tracker. If this is
// the case, we have to avoid looking through current
// tracker's children, and instead return the current
// tracker.
// A case where this check is important is e.g.
// for (int i = 0; i < 5; ++i) {
// int n = GENERATE(1, 2);
// }
//
// without it, the code above creates 5 nested generators.
if (currentTracker.nameAndLocation() == nameAndLocation) {
auto thisTracker = currentTracker.parent().findChild(nameAndLocation);
assert(thisTracker);
assert(thisTracker->isGeneratorTracker());
tracker = std::static_pointer_cast<GeneratorTracker>(thisTracker);
} else if ( TestCaseTracking::ITrackerPtr childTracker = currentTracker.findChild( nameAndLocation ) ) {
assert( childTracker ); assert( childTracker );
assert( childTracker->isGeneratorTracker() ); assert( childTracker->isGeneratorTracker() );
tracker = std::static_pointer_cast<GeneratorTracker>( childTracker ); tracker = std::static_pointer_cast<GeneratorTracker>( childTracker );
} } else {
else {
tracker = std::make_shared<GeneratorTracker>( nameAndLocation, ctx, &currentTracker ); tracker = std::make_shared<GeneratorTracker>( nameAndLocation, ctx, &currentTracker );
currentTracker.addChild( tracker ); currentTracker.addChild( tracker );
} }
...@@ -187,9 +202,10 @@ namespace Catch { ...@@ -187,9 +202,10 @@ namespace Catch {
return true; return true;
} }
auto RunContext::acquireGeneratorTracker( SourceLineInfo const& lineInfo ) -> IGeneratorTracker& { auto RunContext::acquireGeneratorTracker( StringRef generatorName, SourceLineInfo const& lineInfo ) -> IGeneratorTracker& {
using namespace Generators; using namespace Generators;
GeneratorTracker& tracker = GeneratorTracker::acquire( m_trackerContext, TestCaseTracking::NameAndLocation( "generator", lineInfo ) ); GeneratorTracker& tracker = GeneratorTracker::acquire(m_trackerContext,
TestCaseTracking::NameAndLocation( static_cast<std::string>(generatorName), lineInfo ) );
assert( tracker.isOpen() ); assert( tracker.isOpen() );
m_lastAssertionInfo.lineInfo = lineInfo; m_lastAssertionInfo.lineInfo = lineInfo;
return tracker; return tracker;
...@@ -233,17 +249,17 @@ namespace Catch { ...@@ -233,17 +249,17 @@ namespace Catch {
#if defined(CATCH_CONFIG_ENABLE_BENCHMARKING) #if defined(CATCH_CONFIG_ENABLE_BENCHMARKING)
void RunContext::benchmarkPreparing(std::string const& name) { void RunContext::benchmarkPreparing(std::string const& name) {
m_reporter->benchmarkPreparing(name); m_reporter->benchmarkPreparing(name);
} }
void RunContext::benchmarkStarting( BenchmarkInfo const& info ) { void RunContext::benchmarkStarting( BenchmarkInfo const& info ) {
m_reporter->benchmarkStarting( info ); m_reporter->benchmarkStarting( info );
} }
void RunContext::benchmarkEnded( BenchmarkStats<> const& stats ) { void RunContext::benchmarkEnded( BenchmarkStats<> const& stats ) {
m_reporter->benchmarkEnded( stats ); m_reporter->benchmarkEnded( stats );
} }
void RunContext::benchmarkFailed(std::string const & error) { void RunContext::benchmarkFailed(std::string const & error) {
m_reporter->benchmarkFailed(error); m_reporter->benchmarkFailed(error);
} }
#endif // CATCH_CONFIG_ENABLE_BENCHMARKING #endif // CATCH_CONFIG_ENABLE_BENCHMARKING
void RunContext::pushScopedMessage(MessageInfo const & message) { void RunContext::pushScopedMessage(MessageInfo const & message) {
......
...@@ -80,7 +80,7 @@ namespace Catch { ...@@ -80,7 +80,7 @@ namespace Catch {
void sectionEnded( SectionEndInfo const& endInfo ) override; void sectionEnded( SectionEndInfo const& endInfo ) override;
void sectionEndedEarly( SectionEndInfo const& endInfo ) override; void sectionEndedEarly( SectionEndInfo const& endInfo ) override;
auto acquireGeneratorTracker( SourceLineInfo const& lineInfo ) -> IGeneratorTracker& override; auto acquireGeneratorTracker( StringRef generatorName, SourceLineInfo const& lineInfo ) -> IGeneratorTracker& override;
#if defined(CATCH_CONFIG_ENABLE_BENCHMARKING) #if defined(CATCH_CONFIG_ENABLE_BENCHMARKING)
void benchmarkPreparing( std::string const& name ) override; void benchmarkPreparing( std::string const& name ) override;
......
...@@ -9,6 +9,7 @@ ...@@ -9,6 +9,7 @@
#include "catch_startup_exception_registry.h" #include "catch_startup_exception_registry.h"
#include "catch_compiler_capabilities.h" #include "catch_compiler_capabilities.h"
#if !defined(CATCH_CONFIG_DISABLE_EXCEPTIONS)
namespace Catch { namespace Catch {
void StartupExceptionRegistry::add( std::exception_ptr const& exception ) noexcept { void StartupExceptionRegistry::add( std::exception_ptr const& exception ) noexcept {
CATCH_TRY { CATCH_TRY {
...@@ -24,3 +25,4 @@ void StartupExceptionRegistry::add( std::exception_ptr const& exception ) noexce ...@@ -24,3 +25,4 @@ void StartupExceptionRegistry::add( std::exception_ptr const& exception ) noexce
} }
} // end namespace Catch } // end namespace Catch
#endif
...@@ -15,11 +15,13 @@ ...@@ -15,11 +15,13 @@
namespace Catch { namespace Catch {
class StartupExceptionRegistry { class StartupExceptionRegistry {
#if !defined(CATCH_CONFIG_DISABLE_EXCEPTIONS)
public: public:
void add(std::exception_ptr const& exception) noexcept; void add(std::exception_ptr const& exception) noexcept;
std::vector<std::exception_ptr> const& getExceptions() const noexcept; std::vector<std::exception_ptr> const& getExceptions() const noexcept;
private: private:
std::vector<std::exception_ptr> m_exceptions; std::vector<std::exception_ptr> m_exceptions;
#endif
}; };
} // end namespace Catch } // end namespace Catch
......
...@@ -18,7 +18,7 @@ namespace Catch { ...@@ -18,7 +18,7 @@ namespace Catch {
namespace { namespace {
char toLowerCh(char c) { char toLowerCh(char c) {
return static_cast<char>( std::tolower( c ) ); return static_cast<char>( std::tolower( static_cast<unsigned char>(c) ) );
} }
} }
......
...@@ -65,15 +65,12 @@ namespace TestCaseTracking { ...@@ -65,15 +65,12 @@ namespace TestCaseTracking {
} }
TrackerBase::TrackerBase( NameAndLocation const& nameAndLocation, TrackerContext& ctx, ITracker* parent ) TrackerBase::TrackerBase( NameAndLocation const& nameAndLocation, TrackerContext& ctx, ITracker* parent ):
: m_nameAndLocation( nameAndLocation ), ITracker(nameAndLocation),
m_ctx( ctx ), m_ctx( ctx ),
m_parent( parent ) m_parent( parent )
{} {}
NameAndLocation const& TrackerBase::nameAndLocation() const {
return m_nameAndLocation;
}
bool TrackerBase::isComplete() const { bool TrackerBase::isComplete() const {
return m_runState == CompletedSuccessfully || m_runState == Failed; return m_runState == CompletedSuccessfully || m_runState == Failed;
} }
......
...@@ -23,17 +23,32 @@ namespace TestCaseTracking { ...@@ -23,17 +23,32 @@ namespace TestCaseTracking {
SourceLineInfo location; SourceLineInfo location;
NameAndLocation( std::string const& _name, SourceLineInfo const& _location ); NameAndLocation( std::string const& _name, SourceLineInfo const& _location );
friend bool operator==(NameAndLocation const& lhs, NameAndLocation const& rhs) {
return lhs.name == rhs.name
&& lhs.location == rhs.location;
}
}; };
struct ITracker; class ITracker;
using ITrackerPtr = std::shared_ptr<ITracker>; using ITrackerPtr = std::shared_ptr<ITracker>;
struct ITracker { class ITracker {
virtual ~ITracker(); NameAndLocation m_nameAndLocation;
public:
ITracker(NameAndLocation const& nameAndLoc) :
m_nameAndLocation(nameAndLoc)
{}
// static queries // static queries
virtual NameAndLocation const& nameAndLocation() const = 0; NameAndLocation const& nameAndLocation() const {
return m_nameAndLocation;
}
virtual ~ITracker();
// dynamic queries // dynamic queries
virtual bool isComplete() const = 0; // Successfully completed or failed virtual bool isComplete() const = 0; // Successfully completed or failed
...@@ -94,7 +109,6 @@ namespace TestCaseTracking { ...@@ -94,7 +109,6 @@ namespace TestCaseTracking {
}; };
using Children = std::vector<ITrackerPtr>; using Children = std::vector<ITrackerPtr>;
NameAndLocation m_nameAndLocation;
TrackerContext& m_ctx; TrackerContext& m_ctx;
ITracker* m_parent; ITracker* m_parent;
Children m_children; Children m_children;
...@@ -103,7 +117,6 @@ namespace TestCaseTracking { ...@@ -103,7 +117,6 @@ namespace TestCaseTracking {
public: public:
TrackerBase( NameAndLocation const& nameAndLocation, TrackerContext& ctx, ITracker* parent ); TrackerBase( NameAndLocation const& nameAndLocation, TrackerContext& ctx, ITracker* parent );
NameAndLocation const& nameAndLocation() const override;
bool isComplete() const override; bool isComplete() const override;
bool isSuccessfullyCompleted() const override; bool isSuccessfullyCompleted() const override;
bool isOpen() const override; bool isOpen() const override;
......
...@@ -12,7 +12,9 @@ ...@@ -12,7 +12,9 @@
namespace Catch { namespace Catch {
bool uncaught_exceptions() { bool uncaught_exceptions() {
#if defined(CATCH_CONFIG_CPP17_UNCAUGHT_EXCEPTIONS) #if defined(CATCH_CONFIG_DISABLE_EXCEPTIONS)
return false;
#elif defined(CATCH_CONFIG_CPP17_UNCAUGHT_EXCEPTIONS)
return std::uncaught_exceptions() > 0; return std::uncaught_exceptions() > 0;
#else #else
return std::uncaught_exception(); return std::uncaught_exception();
......
...@@ -37,7 +37,7 @@ namespace Catch { ...@@ -37,7 +37,7 @@ namespace Catch {
} }
Version const& libraryVersion() { Version const& libraryVersion() {
static Version version( 2, 12, 2, "", 0 ); static Version version( 2, 12, 3, "", 0 );
return version; return version;
} }
......
...@@ -207,6 +207,10 @@ namespace Catch { ...@@ -207,6 +207,10 @@ namespace Catch {
.writeAttribute( "successes", testGroupStats.totals.assertions.passed ) .writeAttribute( "successes", testGroupStats.totals.assertions.passed )
.writeAttribute( "failures", testGroupStats.totals.assertions.failed ) .writeAttribute( "failures", testGroupStats.totals.assertions.failed )
.writeAttribute( "expectedFailures", testGroupStats.totals.assertions.failedButOk ); .writeAttribute( "expectedFailures", testGroupStats.totals.assertions.failedButOk );
m_xml.scopedElement( "OverallResultsCases")
.writeAttribute( "successes", testGroupStats.totals.testCases.passed )
.writeAttribute( "failures", testGroupStats.totals.testCases.failed )
.writeAttribute( "expectedFailures", testGroupStats.totals.testCases.failedButOk );
m_xml.endElement(); m_xml.endElement();
} }
...@@ -216,6 +220,10 @@ namespace Catch { ...@@ -216,6 +220,10 @@ namespace Catch {
.writeAttribute( "successes", testRunStats.totals.assertions.passed ) .writeAttribute( "successes", testRunStats.totals.assertions.passed )
.writeAttribute( "failures", testRunStats.totals.assertions.failed ) .writeAttribute( "failures", testRunStats.totals.assertions.failed )
.writeAttribute( "expectedFailures", testRunStats.totals.assertions.failedButOk ); .writeAttribute( "expectedFailures", testRunStats.totals.assertions.failedButOk );
m_xml.scopedElement( "OverallResultsCases")
.writeAttribute( "successes", testRunStats.totals.testCases.passed )
.writeAttribute( "failures", testRunStats.totals.testCases.failed )
.writeAttribute( "expectedFailures", testRunStats.totals.testCases.failedButOk );
m_xml.endElement(); m_xml.endElement();
} }
......
...@@ -30,6 +30,15 @@ CmdLine.tests.cpp:<line number>: passed: spec.matches(fakeTestCase(R"(spec {a} c ...@@ -30,6 +30,15 @@ CmdLine.tests.cpp:<line number>: passed: spec.matches(fakeTestCase(R"(spec {a} c
CmdLine.tests.cpp:<line number>: passed: spec.matches(fakeTestCase(R"(spec [a] char)")) for: true CmdLine.tests.cpp:<line number>: passed: spec.matches(fakeTestCase(R"(spec [a] char)")) for: true
CmdLine.tests.cpp:<line number>: passed: !(spec.matches(fakeTestCase("differs but has similar tag", "[a]"))) for: !false CmdLine.tests.cpp:<line number>: passed: !(spec.matches(fakeTestCase("differs but has similar tag", "[a]"))) for: !false
CmdLine.tests.cpp:<line number>: passed: spec.matches(fakeTestCase(R"(spec \ char)")) for: true CmdLine.tests.cpp:<line number>: passed: spec.matches(fakeTestCase(R"(spec \ char)")) for: true
Generators.tests.cpp:<line number>: passed: counter < 7 for: 3 < 7
Generators.tests.cpp:<line number>: passed: counter < 7 for: 6 < 7
Generators.tests.cpp:<line number>: passed: i != j for: 1 != 3
Generators.tests.cpp:<line number>: passed: i != j for: 1 != 4
Generators.tests.cpp:<line number>: passed: i != j for: 2 != 3
Generators.tests.cpp:<line number>: passed: i != j for: 2 != 4
Misc.tests.cpp:<line number>: passed:
Misc.tests.cpp:<line number>: passed:
Misc.tests.cpp:<line number>: passed:
Exception.tests.cpp:<line number>: failed: unexpected exception with message: 'answer := 42' with 1 message: 'expected exception' Exception.tests.cpp:<line number>: failed: unexpected exception with message: 'answer := 42' with 1 message: 'expected exception'
Exception.tests.cpp:<line number>: failed: unexpected exception with message: 'answer := 42'; expression was: thisThrows() with 1 message: 'expected exception' Exception.tests.cpp:<line number>: failed: unexpected exception with message: 'answer := 42'; expression was: thisThrows() with 1 message: 'expected exception'
Exception.tests.cpp:<line number>: passed: thisThrows() with 1 message: 'answer := 42' Exception.tests.cpp:<line number>: passed: thisThrows() with 1 message: 'answer := 42'
...@@ -326,6 +335,12 @@ Condition.tests.cpp:<line number>: passed: 6 == uc for: 6 == 6 ...@@ -326,6 +335,12 @@ Condition.tests.cpp:<line number>: passed: 6 == uc for: 6 == 6
Condition.tests.cpp:<line number>: passed: (std::numeric_limits<uint32_t>::max)() > ul for: 4294967295 (0x<hex digits>) > 4 Condition.tests.cpp:<line number>: passed: (std::numeric_limits<uint32_t>::max)() > ul for: 4294967295 (0x<hex digits>) > 4
Matchers.tests.cpp:<line number>: passed: testStringForMatching2(), !composed1 for: "some completely different text that contains one common word" not ( contains: "string" or contains: "random" ) Matchers.tests.cpp:<line number>: passed: testStringForMatching2(), !composed1 for: "some completely different text that contains one common word" not ( contains: "string" or contains: "random" )
Matchers.tests.cpp:<line number>: passed: testStringForMatching2(), composed2 for: "some completely different text that contains one common word" ( contains: "string" or contains: "random" or contains: "different" ) Matchers.tests.cpp:<line number>: passed: testStringForMatching2(), composed2 for: "some completely different text that contains one common word" ( contains: "string" or contains: "random" or contains: "different" )
Matchers.tests.cpp:<line number>: passed: 1, !(first && second) for: 1 not ( CheckedTestingMatcher set to fail and CheckedTestingMatcher set to fail )
Matchers.tests.cpp:<line number>: passed: first.matchCalled for: true
Matchers.tests.cpp:<line number>: passed: !second.matchCalled for: true
Matchers.tests.cpp:<line number>: passed: 1, first || second for: 1 ( CheckedTestingMatcher set to succeed or CheckedTestingMatcher set to fail )
Matchers.tests.cpp:<line number>: passed: first.matchCalled for: true
Matchers.tests.cpp:<line number>: passed: !second.matchCalled for: true
Matchers.tests.cpp:<line number>: failed: testStringForMatching(), Contains("not there", Catch::CaseSensitive::No) for: "this string contains 'abc' as a substring" contains: "not there" (case insensitive) Matchers.tests.cpp:<line number>: failed: testStringForMatching(), Contains("not there", Catch::CaseSensitive::No) for: "this string contains 'abc' as a substring" contains: "not there" (case insensitive)
Matchers.tests.cpp:<line number>: failed: testStringForMatching(), Contains("STRING") for: "this string contains 'abc' as a substring" contains: "STRING" Matchers.tests.cpp:<line number>: failed: testStringForMatching(), Contains("STRING") for: "this string contains 'abc' as a substring" contains: "STRING"
Generators.tests.cpp:<line number>: passed: elem % 2 == 1 for: 1 == 1 Generators.tests.cpp:<line number>: passed: elem % 2 == 1 for: 1 == 1
......
...@@ -1380,6 +1380,6 @@ due to unexpected exception with message: ...@@ -1380,6 +1380,6 @@ due to unexpected exception with message:
Why would you throw a std::string? Why would you throw a std::string?
=============================================================================== ===============================================================================
test cases: 310 | 236 passed | 70 failed | 4 failed as expected test cases: 316 | 242 passed | 70 failed | 4 failed as expected
assertions: 1701 | 1549 passed | 131 failed | 21 failed as expected assertions: 1716 | 1564 passed | 131 failed | 21 failed as expected
...@@ -243,6 +243,96 @@ CmdLine.tests.cpp:<line number>: PASSED: ...@@ -243,6 +243,96 @@ CmdLine.tests.cpp:<line number>: PASSED:
with expansion: with expansion:
true true
-------------------------------------------------------------------------------
#1913 - GENERATE inside a for loop should not keep recreating the generator
-------------------------------------------------------------------------------
Generators.tests.cpp:<line number>
...............................................................................
Generators.tests.cpp:<line number>: PASSED:
REQUIRE( counter < 7 )
with expansion:
3 < 7
-------------------------------------------------------------------------------
#1913 - GENERATE inside a for loop should not keep recreating the generator
-------------------------------------------------------------------------------
Generators.tests.cpp:<line number>
...............................................................................
Generators.tests.cpp:<line number>: PASSED:
REQUIRE( counter < 7 )
with expansion:
6 < 7
-------------------------------------------------------------------------------
#1913 - GENERATEs can share a line
-------------------------------------------------------------------------------
Generators.tests.cpp:<line number>
...............................................................................
Generators.tests.cpp:<line number>: PASSED:
REQUIRE( i != j )
with expansion:
1 != 3
-------------------------------------------------------------------------------
#1913 - GENERATEs can share a line
-------------------------------------------------------------------------------
Generators.tests.cpp:<line number>
...............................................................................
Generators.tests.cpp:<line number>: PASSED:
REQUIRE( i != j )
with expansion:
1 != 4
-------------------------------------------------------------------------------
#1913 - GENERATEs can share a line
-------------------------------------------------------------------------------
Generators.tests.cpp:<line number>
...............................................................................
Generators.tests.cpp:<line number>: PASSED:
REQUIRE( i != j )
with expansion:
2 != 3
-------------------------------------------------------------------------------
#1913 - GENERATEs can share a line
-------------------------------------------------------------------------------
Generators.tests.cpp:<line number>
...............................................................................
Generators.tests.cpp:<line number>: PASSED:
REQUIRE( i != j )
with expansion:
2 != 4
-------------------------------------------------------------------------------
#1954 - 7 arg template test case sig compiles - 1, 1, 1, 1, 1, 0, 0
-------------------------------------------------------------------------------
Misc.tests.cpp:<line number>
...............................................................................
Misc.tests.cpp:<line number>: PASSED:
-------------------------------------------------------------------------------
#1954 - 7 arg template test case sig compiles - 5, 1, 1, 1, 1, 0, 0
-------------------------------------------------------------------------------
Misc.tests.cpp:<line number>
...............................................................................
Misc.tests.cpp:<line number>: PASSED:
-------------------------------------------------------------------------------
#1954 - 7 arg template test case sig compiles - 5, 3, 1, 1, 1, 0, 0
-------------------------------------------------------------------------------
Misc.tests.cpp:<line number>
...............................................................................
Misc.tests.cpp:<line number>: PASSED:
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
#748 - captures with unexpected exceptions #748 - captures with unexpected exceptions
outside assertions outside assertions
...@@ -2494,6 +2584,52 @@ with expansion: ...@@ -2494,6 +2584,52 @@ 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: "random" or contains: "different" ) "string" or contains: "random" or contains: "different" )
-------------------------------------------------------------------------------
Composed matchers shortcircuit
&&
-------------------------------------------------------------------------------
Matchers.tests.cpp:<line number>
...............................................................................
Matchers.tests.cpp:<line number>: PASSED:
CHECK_THAT( 1, !(first && second) )
with expansion:
1 not ( CheckedTestingMatcher set to fail and CheckedTestingMatcher set to
fail )
Matchers.tests.cpp:<line number>: PASSED:
REQUIRE( first.matchCalled )
with expansion:
true
Matchers.tests.cpp:<line number>: PASSED:
REQUIRE( !second.matchCalled )
with expansion:
true
-------------------------------------------------------------------------------
Composed matchers shortcircuit
||
-------------------------------------------------------------------------------
Matchers.tests.cpp:<line number>
...............................................................................
Matchers.tests.cpp:<line number>: PASSED:
CHECK_THAT( 1, first || second )
with expansion:
1 ( CheckedTestingMatcher set to succeed or CheckedTestingMatcher set to fail
)
Matchers.tests.cpp:<line number>: PASSED:
REQUIRE( first.matchCalled )
with expansion:
true
Matchers.tests.cpp:<line number>: PASSED:
REQUIRE( !second.matchCalled )
with expansion:
true
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
Contains string matcher Contains string matcher
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
...@@ -13573,6 +13709,6 @@ Misc.tests.cpp:<line number> ...@@ -13573,6 +13709,6 @@ Misc.tests.cpp:<line number>
Misc.tests.cpp:<line number>: PASSED: Misc.tests.cpp:<line number>: PASSED:
=============================================================================== ===============================================================================
test cases: 310 | 220 passed | 86 failed | 4 failed as expected test cases: 316 | 226 passed | 86 failed | 4 failed as expected
assertions: 1718 | 1549 passed | 148 failed | 21 failed as expected assertions: 1733 | 1564 passed | 148 failed | 21 failed as expected
...@@ -243,6 +243,96 @@ CmdLine.tests.cpp:<line number>: PASSED: ...@@ -243,6 +243,96 @@ CmdLine.tests.cpp:<line number>: PASSED:
with expansion: with expansion:
true true
-------------------------------------------------------------------------------
#1913 - GENERATE inside a for loop should not keep recreating the generator
-------------------------------------------------------------------------------
Generators.tests.cpp:<line number>
...............................................................................
Generators.tests.cpp:<line number>: PASSED:
REQUIRE( counter < 7 )
with expansion:
3 < 7
-------------------------------------------------------------------------------
#1913 - GENERATE inside a for loop should not keep recreating the generator
-------------------------------------------------------------------------------
Generators.tests.cpp:<line number>
...............................................................................
Generators.tests.cpp:<line number>: PASSED:
REQUIRE( counter < 7 )
with expansion:
6 < 7
-------------------------------------------------------------------------------
#1913 - GENERATEs can share a line
-------------------------------------------------------------------------------
Generators.tests.cpp:<line number>
...............................................................................
Generators.tests.cpp:<line number>: PASSED:
REQUIRE( i != j )
with expansion:
1 != 3
-------------------------------------------------------------------------------
#1913 - GENERATEs can share a line
-------------------------------------------------------------------------------
Generators.tests.cpp:<line number>
...............................................................................
Generators.tests.cpp:<line number>: PASSED:
REQUIRE( i != j )
with expansion:
1 != 4
-------------------------------------------------------------------------------
#1913 - GENERATEs can share a line
-------------------------------------------------------------------------------
Generators.tests.cpp:<line number>
...............................................................................
Generators.tests.cpp:<line number>: PASSED:
REQUIRE( i != j )
with expansion:
2 != 3
-------------------------------------------------------------------------------
#1913 - GENERATEs can share a line
-------------------------------------------------------------------------------
Generators.tests.cpp:<line number>
...............................................................................
Generators.tests.cpp:<line number>: PASSED:
REQUIRE( i != j )
with expansion:
2 != 4
-------------------------------------------------------------------------------
#1954 - 7 arg template test case sig compiles - 1, 1, 1, 1, 1, 0, 0
-------------------------------------------------------------------------------
Misc.tests.cpp:<line number>
...............................................................................
Misc.tests.cpp:<line number>: PASSED:
-------------------------------------------------------------------------------
#1954 - 7 arg template test case sig compiles - 5, 1, 1, 1, 1, 0, 0
-------------------------------------------------------------------------------
Misc.tests.cpp:<line number>
...............................................................................
Misc.tests.cpp:<line number>: PASSED:
-------------------------------------------------------------------------------
#1954 - 7 arg template test case sig compiles - 5, 3, 1, 1, 1, 0, 0
-------------------------------------------------------------------------------
Misc.tests.cpp:<line number>
...............................................................................
Misc.tests.cpp:<line number>: PASSED:
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
#748 - captures with unexpected exceptions #748 - captures with unexpected exceptions
outside assertions outside assertions
...@@ -423,6 +513,6 @@ Condition.tests.cpp:<line number>: FAILED: ...@@ -423,6 +513,6 @@ Condition.tests.cpp:<line number>: FAILED:
CHECK( true != true ) CHECK( true != true )
=============================================================================== ===============================================================================
test cases: 21 | 16 passed | 3 failed | 2 failed as expected test cases: 26 | 21 passed | 3 failed | 2 failed as expected
assertions: 49 | 42 passed | 4 failed | 3 failed as expected assertions: 58 | 51 passed | 4 failed | 3 failed as expected
<?xml version="1.0" encoding="UTF-8"?> <?xml version="1.0" encoding="UTF-8"?>
<testsuitesloose text artifact <testsuitesloose text artifact
> >
<testsuite name="<exe-name>" errors="17" failures="132" tests="1719" hostname="tbd" time="{duration}" timestamp="{iso8601-timestamp}"> <testsuite name="<exe-name>" errors="17" failures="132" tests="1734" hostname="tbd" time="{duration}" timestamp="{iso8601-timestamp}">
<properties> <properties>
<property name="filters" value="~[!nonportable]~[!benchmark]~[approvals]"/> <property name="filters" value="~[!nonportable]~[!benchmark]~[approvals]"/>
<property name="random-seed" value="1"/> <property name="random-seed" value="1"/>
...@@ -33,6 +33,11 @@ Nor would this ...@@ -33,6 +33,11 @@ Nor would this
<testcase classname="<exe-name>.global" name="#1905 -- test spec parser properly clears internal state between compound tests" time="{duration}" status="run"/> <testcase classname="<exe-name>.global" name="#1905 -- test spec parser properly clears internal state between compound tests" time="{duration}" status="run"/>
<testcase classname="<exe-name>.global" name="#1912 -- test spec parser handles escaping/Various parentheses" time="{duration}" status="run"/> <testcase classname="<exe-name>.global" name="#1912 -- test spec parser handles escaping/Various parentheses" time="{duration}" status="run"/>
<testcase classname="<exe-name>.global" name="#1912 -- test spec parser handles escaping/backslash in test name" time="{duration}" status="run"/> <testcase classname="<exe-name>.global" name="#1912 -- test spec parser handles escaping/backslash in test name" time="{duration}" status="run"/>
<testcase classname="<exe-name>.global" name="#1913 - GENERATE inside a for loop should not keep recreating the generator" time="{duration}" status="run"/>
<testcase classname="<exe-name>.global" name="#1913 - GENERATEs can share a line" time="{duration}" status="run"/>
<testcase classname="<exe-name>.global" name="#1954 - 7 arg template test case sig compiles - 1, 1, 1, 1, 1, 0, 0" time="{duration}" status="run"/>
<testcase classname="<exe-name>.global" name="#1954 - 7 arg template test case sig compiles - 5, 1, 1, 1, 1, 0, 0" time="{duration}" status="run"/>
<testcase classname="<exe-name>.global" name="#1954 - 7 arg template test case sig compiles - 5, 3, 1, 1, 1, 0, 0" time="{duration}" status="run"/>
<testcase classname="<exe-name>.global" name="#748 - captures with unexpected exceptions/outside assertions" time="{duration}" status="run"> <testcase classname="<exe-name>.global" name="#748 - captures with unexpected exceptions/outside assertions" time="{duration}" status="run">
<error type="TEST_CASE"> <error type="TEST_CASE">
FAILED: FAILED:
...@@ -361,6 +366,8 @@ Exception.tests.cpp:<line number> ...@@ -361,6 +366,8 @@ Exception.tests.cpp:<line number>
<testcase classname="<exe-name>.global" name="Comparisons between unsigned ints and negative signed ints match c++ standard behaviour" time="{duration}" status="run"/> <testcase classname="<exe-name>.global" name="Comparisons between unsigned ints and negative signed ints match c++ standard behaviour" time="{duration}" status="run"/>
<testcase classname="<exe-name>.global" name="Comparisons with int literals don't warn when mixing signed/ unsigned" time="{duration}" status="run"/> <testcase classname="<exe-name>.global" name="Comparisons with int literals don't warn when mixing signed/ unsigned" time="{duration}" status="run"/>
<testcase classname="<exe-name>.global" name="Composed matchers are distinct" time="{duration}" status="run"/> <testcase classname="<exe-name>.global" name="Composed matchers are distinct" time="{duration}" status="run"/>
<testcase classname="<exe-name>.global" name="Composed matchers shortcircuit/&amp;&amp;" time="{duration}" status="run"/>
<testcase classname="<exe-name>.global" name="Composed matchers shortcircuit/||" time="{duration}" status="run"/>
<testcase classname="<exe-name>.global" name="Contains string matcher" time="{duration}" status="run"> <testcase classname="<exe-name>.global" name="Contains string matcher" time="{duration}" status="run">
<failure message="testStringForMatching(), Contains(&quot;not there&quot;, Catch::CaseSensitive::No)" type="CHECK_THAT"> <failure message="testStringForMatching(), Contains(&quot;not there&quot;, Catch::CaseSensitive::No)" type="CHECK_THAT">
FAILED: FAILED:
......
...@@ -875,6 +875,8 @@ Exception.tests.cpp:<line number> ...@@ -875,6 +875,8 @@ Exception.tests.cpp:<line number>
</testCase> </testCase>
</file> </file>
<file path="projects/<exe-name>/UsageTests/Generators.tests.cpp"> <file path="projects/<exe-name>/UsageTests/Generators.tests.cpp">
<testCase name="#1913 - GENERATE inside a for loop should not keep recreating the generator" duration="{duration}"/>
<testCase name="#1913 - GENERATEs can share a line" duration="{duration}"/>
<testCase name="3x3x3 ints" duration="{duration}"/> <testCase name="3x3x3 ints" duration="{duration}"/>
<testCase name="Copy and then generate a range/from var and iterators" duration="{duration}"/> <testCase name="Copy and then generate a range/from var and iterators" duration="{duration}"/>
<testCase name="Copy and then generate a range/From a temporary container" duration="{duration}"/> <testCase name="Copy and then generate a range/From a temporary container" duration="{duration}"/>
...@@ -900,6 +902,8 @@ Exception.tests.cpp:<line number> ...@@ -900,6 +902,8 @@ Exception.tests.cpp:<line number>
<testCase name="Arbitrary predicate matcher/Function pointer" duration="{duration}"/> <testCase name="Arbitrary predicate matcher/Function pointer" duration="{duration}"/>
<testCase name="Arbitrary predicate matcher/Lambdas + different type" duration="{duration}"/> <testCase name="Arbitrary predicate matcher/Lambdas + different type" duration="{duration}"/>
<testCase name="Composed matchers are distinct" duration="{duration}"/> <testCase name="Composed matchers are distinct" duration="{duration}"/>
<testCase name="Composed matchers shortcircuit/&amp;&amp;" duration="{duration}"/>
<testCase name="Composed matchers shortcircuit/||" duration="{duration}"/>
<testCase name="Contains string matcher" duration="{duration}"> <testCase name="Contains string matcher" duration="{duration}">
<failure message="CHECK_THAT(testStringForMatching(), Contains(&quot;not there&quot;, Catch::CaseSensitive::No))"> <failure message="CHECK_THAT(testStringForMatching(), Contains(&quot;not there&quot;, Catch::CaseSensitive::No))">
FAILED: FAILED:
...@@ -1350,6 +1354,9 @@ Message.tests.cpp:<line number> ...@@ -1350,6 +1354,9 @@ Message.tests.cpp:<line number>
<file path="projects/<exe-name>/UsageTests/Misc.tests.cpp"> <file path="projects/<exe-name>/UsageTests/Misc.tests.cpp">
<testCase name="# A test name that starts with a #" duration="{duration}"/> <testCase name="# A test name that starts with a #" duration="{duration}"/>
<testCase name="#1175 - Hidden Test" duration="{duration}"/> <testCase name="#1175 - Hidden Test" duration="{duration}"/>
<testCase name="#1954 - 7 arg template test case sig compiles - 1, 1, 1, 1, 1, 0, 0" duration="{duration}"/>
<testCase name="#1954 - 7 arg template test case sig compiles - 5, 1, 1, 1, 1, 0, 0" duration="{duration}"/>
<testCase name="#1954 - 7 arg template test case sig compiles - 5, 3, 1, 1, 1, 0, 0" duration="{duration}"/>
<testCase name="#835 -- errno should not be touched by Catch" duration="{duration}"> <testCase name="#835 -- errno should not be touched by Catch" duration="{duration}">
<skipped message="CHECK(f() == 0)"> <skipped message="CHECK(f() == 0)">
FAILED: FAILED:
......
...@@ -264,6 +264,69 @@ Nor would this ...@@ -264,6 +264,69 @@ Nor would this
</Section> </Section>
<OverallResult success="true"/> <OverallResult success="true"/>
</TestCase> </TestCase>
<TestCase name="#1913 - GENERATE inside a for loop should not keep recreating the generator" tags="[generators][regression]" filename="projects/<exe-name>/UsageTests/Generators.tests.cpp" >
<Expression success="true" type="REQUIRE" filename="projects/<exe-name>/UsageTests/Generators.tests.cpp" >
<Original>
counter &lt; 7
</Original>
<Expanded>
3 &lt; 7
</Expanded>
</Expression>
<Expression success="true" type="REQUIRE" filename="projects/<exe-name>/UsageTests/Generators.tests.cpp" >
<Original>
counter &lt; 7
</Original>
<Expanded>
6 &lt; 7
</Expanded>
</Expression>
<OverallResult success="true"/>
</TestCase>
<TestCase name="#1913 - GENERATEs can share a line" tags="[generators][regression]" filename="projects/<exe-name>/UsageTests/Generators.tests.cpp" >
<Expression success="true" type="REQUIRE" filename="projects/<exe-name>/UsageTests/Generators.tests.cpp" >
<Original>
i != j
</Original>
<Expanded>
1 != 3
</Expanded>
</Expression>
<Expression success="true" type="REQUIRE" filename="projects/<exe-name>/UsageTests/Generators.tests.cpp" >
<Original>
i != j
</Original>
<Expanded>
1 != 4
</Expanded>
</Expression>
<Expression success="true" type="REQUIRE" filename="projects/<exe-name>/UsageTests/Generators.tests.cpp" >
<Original>
i != j
</Original>
<Expanded>
2 != 3
</Expanded>
</Expression>
<Expression success="true" type="REQUIRE" filename="projects/<exe-name>/UsageTests/Generators.tests.cpp" >
<Original>
i != j
</Original>
<Expanded>
2 != 4
</Expanded>
</Expression>
<OverallResult success="true"/>
</TestCase>
<TestCase name="#1954 - 7 arg template test case sig compiles - 1, 1, 1, 1, 1, 0, 0" tags="[!hide][.][compilation][regression]" filename="projects/<exe-name>/UsageTests/Misc.tests.cpp" >
<OverallResult success="true"/>
</TestCase>
<TestCase name="#1954 - 7 arg template test case sig compiles - 5, 1, 1, 1, 1, 0, 0" tags="[!hide][.][compilation][regression]" filename="projects/<exe-name>/UsageTests/Misc.tests.cpp" >
<OverallResult success="true"/>
</TestCase>
<TestCase name="#1954 - 7 arg template test case sig compiles - 5, 3, 1, 1, 1, 0, 0" tags="[!hide][.][compilation][regression]" filename="projects/<exe-name>/UsageTests/Misc.tests.cpp" >
<OverallResult success="true"/>
</TestCase>
<TestCase name="#748 - captures with unexpected exceptions" tags="[!hide][!shouldfail][!throws][.][failing]" filename="projects/<exe-name>/UsageTests/Exception.tests.cpp" > <TestCase name="#748 - captures with unexpected exceptions" tags="[!hide][!shouldfail][!throws][.][failing]" filename="projects/<exe-name>/UsageTests/Exception.tests.cpp" >
<Section name="outside assertions" filename="projects/<exe-name>/UsageTests/Exception.tests.cpp" > <Section name="outside assertions" filename="projects/<exe-name>/UsageTests/Exception.tests.cpp" >
<Info> <Info>
...@@ -2962,6 +3025,63 @@ Nor would this ...@@ -2962,6 +3025,63 @@ Nor would this
</Expression> </Expression>
<OverallResult success="true"/> <OverallResult success="true"/>
</TestCase> </TestCase>
<TestCase name="Composed matchers shortcircuit" tags="[composed][matchers]" filename="projects/<exe-name>/UsageTests/Matchers.tests.cpp" >
<Section name="&amp;&amp;" filename="projects/<exe-name>/UsageTests/Matchers.tests.cpp" >
<Expression success="true" type="CHECK_THAT" filename="projects/<exe-name>/UsageTests/Matchers.tests.cpp" >
<Original>
1, !(first &amp;&amp; second)
</Original>
<Expanded>
1 not ( CheckedTestingMatcher set to fail and CheckedTestingMatcher set to fail )
</Expanded>
</Expression>
<Expression success="true" type="REQUIRE" filename="projects/<exe-name>/UsageTests/Matchers.tests.cpp" >
<Original>
first.matchCalled
</Original>
<Expanded>
true
</Expanded>
</Expression>
<Expression success="true" type="REQUIRE" filename="projects/<exe-name>/UsageTests/Matchers.tests.cpp" >
<Original>
!second.matchCalled
</Original>
<Expanded>
true
</Expanded>
</Expression>
<OverallResults successes="3" failures="0" expectedFailures="0"/>
</Section>
<Section name="||" filename="projects/<exe-name>/UsageTests/Matchers.tests.cpp" >
<Expression success="true" type="CHECK_THAT" filename="projects/<exe-name>/UsageTests/Matchers.tests.cpp" >
<Original>
1, first || second
</Original>
<Expanded>
1 ( CheckedTestingMatcher set to succeed or CheckedTestingMatcher set to fail )
</Expanded>
</Expression>
<Expression success="true" type="REQUIRE" filename="projects/<exe-name>/UsageTests/Matchers.tests.cpp" >
<Original>
first.matchCalled
</Original>
<Expanded>
true
</Expanded>
</Expression>
<Expression success="true" type="REQUIRE" filename="projects/<exe-name>/UsageTests/Matchers.tests.cpp" >
<Original>
!second.matchCalled
</Original>
<Expanded>
true
</Expanded>
</Expression>
<OverallResults successes="3" failures="0" expectedFailures="0"/>
</Section>
<OverallResult success="true"/>
</TestCase>
<TestCase name="Contains string matcher" tags="[!hide][.][failing][matchers]" filename="projects/<exe-name>/UsageTests/Matchers.tests.cpp" > <TestCase name="Contains string matcher" tags="[!hide][.][failing][matchers]" filename="projects/<exe-name>/UsageTests/Matchers.tests.cpp" >
<Expression success="false" type="CHECK_THAT" filename="projects/<exe-name>/UsageTests/Matchers.tests.cpp" > <Expression success="false" type="CHECK_THAT" filename="projects/<exe-name>/UsageTests/Matchers.tests.cpp" >
<Original> <Original>
...@@ -16255,7 +16375,9 @@ loose text artifact ...@@ -16255,7 +16375,9 @@ loose text artifact
</Section> </Section>
<OverallResult success="true"/> <OverallResult success="true"/>
</TestCase> </TestCase>
<OverallResults successes="1549" failures="149" expectedFailures="21"/> <OverallResults successes="1564" failures="149" expectedFailures="21"/>
<OverallResultsCases successes="226" failures="86" expectedFailures="4"/>
</Group> </Group>
<OverallResults successes="1549" failures="148" expectedFailures="21"/> <OverallResults successes="1564" failures="148" expectedFailures="21"/>
<OverallResultsCases successes="226" failures="86" expectedFailures="4"/>
</Catch> </Catch>
...@@ -251,6 +251,22 @@ TEST_CASE("Copy and then generate a range", "[generators]") { ...@@ -251,6 +251,22 @@ TEST_CASE("Copy and then generate a range", "[generators]") {
} }
} }
TEST_CASE("#1913 - GENERATE inside a for loop should not keep recreating the generator", "[regression][generators]") {
static int counter = 0;
for (int i = 0; i < 3; ++i) {
int _ = GENERATE(1, 2);
(void)_;
++counter;
}
// There should be at most 6 (3 * 2) counter increments
REQUIRE(counter < 7);
}
TEST_CASE("#1913 - GENERATEs can share a line", "[regression][generators]") {
int i = GENERATE(1, 2); int j = GENERATE(3, 4);
REQUIRE(i != j);
}
#if defined(__clang__) #if defined(__clang__)
#pragma clang diagnostic pop #pragma clang diagnostic pop
#endif #endif
...@@ -628,6 +628,45 @@ namespace { namespace MatchersTests { ...@@ -628,6 +628,45 @@ namespace { namespace MatchersTests {
REQUIRE_THAT(testStringForMatching2(), composed2); REQUIRE_THAT(testStringForMatching2(), composed2);
} }
struct CheckedTestingMatcher : Catch::MatcherBase<int> {
mutable bool matchCalled = false;
bool matchSucceeds = false;
bool match(int const&) const override {
matchCalled = true;
return matchSucceeds;
}
std::string describe() const override {
return "CheckedTestingMatcher set to " + (matchSucceeds ? std::string("succeed") : std::string("fail"));
}
};
TEST_CASE("Composed matchers shortcircuit", "[matchers][composed]") {
// Check that if first returns false, second is not touched
CheckedTestingMatcher first, second;
SECTION("&&") {
first.matchSucceeds = false;
// This assertion doesn't actually test anything, we just
// want the composed matcher's `match` being called.
CHECK_THAT(1, !(first && second));
// These two assertions are the important ones
REQUIRE(first.matchCalled);
REQUIRE(!second.matchCalled);
}
// Check that if first returns true, second is not touched
SECTION("||") {
first.matchSucceeds = true;
// This assertion doesn't actually test anything, we just
// want the composed matcher's `match` being called.
CHECK_THAT(1, first || second);
// These two assertions are the important ones
REQUIRE(first.matchCalled);
REQUIRE(!second.matchCalled);
}
}
} } // namespace MatchersTests } } // namespace MatchersTests
#endif // CATCH_CONFIG_DISABLE_MATCHERS #endif // CATCH_CONFIG_DISABLE_MATCHERS
......
...@@ -484,4 +484,10 @@ TEST_CASE( "#1175 - Hidden Test", "[.]" ) { ...@@ -484,4 +484,10 @@ TEST_CASE( "#1175 - Hidden Test", "[.]" ) {
SUCCEED(); SUCCEED();
} }
TEMPLATE_TEST_CASE_SIG("#1954 - 7 arg template test case sig compiles", "[regression][.compilation]",
((int Tnx, int Tnu, int Tny, int Tph, int Tch, int Tineq, int Teq), Tnx, Tnu, Tny, Tph, Tch, Tineq, Teq),
(1, 1, 1, 1, 1, 0, 0), (5, 1, 1, 1, 1, 0, 0), (5, 3, 1, 1, 1, 0, 0)) {
SUCCEED();
}
}} // namespace MiscTests }} // namespace MiscTests
File mode changed from 100644 to 100755
...@@ -667,7 +667,7 @@ namespace detail { ...@@ -667,7 +667,7 @@ namespace detail {
} }
inline auto convertInto( std::string const &source, bool &target ) -> ParserResult { inline auto convertInto( std::string const &source, bool &target ) -> ParserResult {
std::string srcLC = source; std::string srcLC = source;
std::transform( srcLC.begin(), srcLC.end(), srcLC.begin(), []( char c ) { return static_cast<char>( ::tolower(c) ); } ); std::transform( srcLC.begin(), srcLC.end(), srcLC.begin(), []( unsigned char c ) { return static_cast<char>( ::tolower( c ) ); } );
if (srcLC == "y" || srcLC == "1" || srcLC == "true" || srcLC == "yes" || srcLC == "on") if (srcLC == "y" || srcLC == "1" || srcLC == "true" || srcLC == "yes" || srcLC == "on")
target = true; target = true;
else if (srcLC == "n" || srcLC == "0" || srcLC == "false" || srcLC == "no" || srcLC == "off") else if (srcLC == "n" || srcLC == "0" || srcLC == "false" || srcLC == "no" || srcLC == "off")
......
...@@ -126,7 +126,7 @@ function get_abseil_cpp() ...@@ -126,7 +126,7 @@ function get_abseil_cpp()
function get_catch() function get_catch()
{ {
GIT_REPO="https://github.com/catchorg/Catch2.git" GIT_REPO="https://github.com/catchorg/Catch2.git"
GIT_TAG="v2.12.2" GIT_TAG="v2.12.3"
DEST="deps/catch" DEST="deps/catch"
get_dep "${GIT_REPO}" "${GIT_TAG}" "${DEST}" get_dep "${GIT_REPO}" "${GIT_TAG}" "${DEST}"
......
Markdown 格式
0% 或
您添加了 0 人 到此讨论。请谨慎行事。
请先完成此评论的编辑!
请 注册 或者 后发表评论