Read-only mirrors. Development, issues and pull requests are on GitHub.

summaryrefslogtreecommitdiffhomepage
path: root/include
diff options
context:
space:
mode:
authorMartin Hořeňovský2018-03-07 10:37:50 +0100
committerGitHub2018-03-07 10:37:50 +0100
commit552589f25bb469daa054fa37edee7f564ca1e309 (patch)
tree479c38b5fb84fa0cb65ac7b111eeda7b4bda7f8d /include
parent95c849f613a79cb3c7f59aa0589304513688aba1 (diff)
parentb11175548afa0cb6ea03b9f73d7e038cf6d6688e (diff)
downloadcatch3-552589f25bb469daa054fa37edee7f564ca1e309.tar.gz
Merge branch 'master' into master
Diffstat (limited to 'include')
-rw-r--r--include/external/clara.hpp45
-rw-r--r--include/internal/catch_capture_matchers.cpp2
-rw-r--r--include/internal/catch_compiler_capabilities.h6
-rw-r--r--include/internal/catch_run_context.cpp6
-rw-r--r--include/internal/catch_session.cpp4
-rw-r--r--include/internal/catch_session.h2
-rw-r--r--include/internal/catch_test_case_info.cpp10
-rw-r--r--include/internal/catch_test_case_info.h6
-rw-r--r--include/internal/catch_test_case_registry_impl.cpp2
-rw-r--r--include/internal/catch_test_case_registry_impl.h4
-rw-r--r--include/internal/catch_test_registry.cpp9
-rw-r--r--include/internal/catch_test_registry.h4
-rw-r--r--include/reporters/catch_reporter_tap.hpp2
13 files changed, 56 insertions, 46 deletions
diff --git a/include/external/clara.hpp b/include/external/clara.hpp
index 9c03c8e3..1762651f 100644
--- a/include/external/clara.hpp
+++ b/include/external/clara.hpp
@@ -5,7 +5,7 @@
//
// See https://github.com/philsquared/Clara for more details
-// Clara v1.1.2
+// Clara v1.1.3
#ifndef CATCH_CLARA_HPP_INCLUDED
#define CATCH_CLARA_HPP_INCLUDED
@@ -18,6 +18,15 @@
#define CATCH_CLARA_TEXTFLOW_CONFIG_CONSOLE_WIDTH CATCH_CLARA_CONFIG_CONSOLE_WIDTH
#endif
+#ifndef CLARA_CONFIG_OPTIONAL_TYPE
+#ifdef __has_include
+#if __has_include(<optional>) && __cplusplus >= 201703L
+#define CLARA_CONFIG_OPTIONAL_TYPE std::optional
+#endif
+#endif
+#endif
+
+
// ----------- #included from clara_textflow.hpp -----------
// TextFlowCpp
@@ -389,11 +398,9 @@ namespace detail {
std::vector<std::string> m_args;
public:
- Args( int argc, char *argv[] ) {
- m_exeName = argv[0];
- for( int i = 1; i < argc; ++i )
- m_args.push_back( argv[i] );
- }
+ Args( int argc, char const* const* argv )
+ : m_exeName(argv[0]),
+ m_args(argv + 1, argv + argc) {}
Args( std::initializer_list<std::string> args )
: m_exeName( *args.begin() ),
@@ -580,15 +587,13 @@ namespace detail {
protected:
void enforceOk() const override {
- // !TBD: If no exceptions, std::terminate here or something
- switch( m_type ) {
- case ResultBase::LogicError:
- throw std::logic_error( m_errorMessage );
- case ResultBase::RuntimeError:
- throw std::runtime_error( m_errorMessage );
- case ResultBase::Ok:
- break;
- }
+
+ // Errors shouldn't reach this point, but if they do
+ // the actual error message will be in m_errorMessage
+ assert( m_type != ResultBase::LogicError );
+ assert( m_type != ResultBase::RuntimeError );
+ if( m_type != ResultBase::Ok )
+ std::abort();
}
std::string m_errorMessage; // Only populated if resultType is an error
@@ -658,6 +663,16 @@ namespace detail {
return ParserResult::runtimeError( "Expected a boolean value but did not recognise: '" + source + "'" );
return ParserResult::ok( ParseResultType::Matched );
}
+#ifdef CLARA_CONFIG_OPTIONAL_TYPE
+ template<typename T>
+ inline auto convertInto( std::string const &source, std::optional<T>& target ) -> ParserResult {
+ T temp;
+ auto result = convertInto( source, temp );
+ if( result )
+ target = temp;
+ return result;
+ }
+#endif // CLARA_CONFIG_OPTIONAL_TYPE
struct NonCopyable {
NonCopyable() = default;
diff --git a/include/internal/catch_capture_matchers.cpp b/include/internal/catch_capture_matchers.cpp
index 7ef1597d..a67cc797 100644
--- a/include/internal/catch_capture_matchers.cpp
+++ b/include/internal/catch_capture_matchers.cpp
@@ -13,7 +13,7 @@ namespace Catch {
using StringMatcher = Matchers::Impl::MatcherBase<std::string>;
// This is the general overload that takes a any string matcher
- // There is another overload, in catch_assertinhandler.h/.cpp, that only takes a string and infers
+ // There is another overload, in catch_assertionhandler.h/.cpp, that only takes a string and infers
// the Equals matcher (so the header does not mention matchers)
void handleExceptionMatchExpr( AssertionHandler& handler, StringMatcher const& matcher, StringRef matcherString ) {
std::string exceptionMessage = Catch::translateActiveException();
diff --git a/include/internal/catch_compiler_capabilities.h b/include/internal/catch_compiler_capabilities.h
index 2bbba4f0..0eb266c4 100644
--- a/include/internal/catch_compiler_capabilities.h
+++ b/include/internal/catch_compiler_capabilities.h
@@ -68,11 +68,7 @@
////////////////////////////////////////////////////////////////////////////////
// We know some environments not to support full POSIX signals
#if defined(__CYGWIN__) || defined(__QNX__) || defined(__EMSCRIPTEN__) || defined(__DJGPP__)
-
-# if !defined(CATCH_CONFIG_POSIX_SIGNALS)
-# define CATCH_INTERNAL_CONFIG_NO_POSIX_SIGNALS
-# endif
-
+ #define CATCH_INTERNAL_CONFIG_NO_POSIX_SIGNALS
#endif
#ifdef __OS400__
diff --git a/include/internal/catch_run_context.cpp b/include/internal/catch_run_context.cpp
index ca78bfb4..99c77058 100644
--- a/include/internal/catch_run_context.cpp
+++ b/include/internal/catch_run_context.cpp
@@ -57,7 +57,7 @@ namespace Catch {
m_context(getCurrentMutableContext()),
m_config(_config),
m_reporter(std::move(reporter)),
- m_lastAssertionInfo{ "", SourceLineInfo("",0), "", ResultDisposition::Normal },
+ m_lastAssertionInfo{ StringRef(), SourceLineInfo("",0), StringRef(), ResultDisposition::Normal },
m_includeSuccessfulResults( m_config->includeSuccessfulResults() )
{
m_context.setRunner(this);
@@ -84,7 +84,7 @@ namespace Catch {
std::string redirectedCout;
std::string redirectedCerr;
- TestCaseInfo testInfo = testCase.getTestCaseInfo();
+ auto const& testInfo = testCase.getTestCaseInfo();
m_reporter->testCaseStarting(testInfo);
@@ -292,7 +292,7 @@ namespace Catch {
Counts prevAssertions = m_totals.assertions;
double duration = 0;
m_shouldReportUnexpected = true;
- m_lastAssertionInfo = { "TEST_CASE", testCaseInfo.lineInfo, "", ResultDisposition::Normal };
+ m_lastAssertionInfo = { "TEST_CASE"_sr, testCaseInfo.lineInfo, StringRef(), ResultDisposition::Normal };
seedRng(*m_config);
diff --git a/include/internal/catch_session.cpp b/include/internal/catch_session.cpp
index 0039fcb5..0581ac88 100644
--- a/include/internal/catch_session.cpp
+++ b/include/internal/catch_session.cpp
@@ -133,7 +133,7 @@ namespace Catch {
if ( !exceptions.empty() ) {
m_startupExceptions = true;
Colour colourGuard( Colour::Red );
- Catch::cerr() << "Errors occured during startup!" << '\n';
+ Catch::cerr() << "Errors occurred during startup!" << '\n';
// iterate over all exceptions and notify user
for ( const auto& ex_ptr : exceptions ) {
try {
@@ -165,7 +165,7 @@ namespace Catch {
<< std::left << std::setw(16) << "version: " << libraryVersion() << std::endl;
}
- int Session::applyCommandLine( int argc, char* argv[] ) {
+ int Session::applyCommandLine( int argc, char const * const * argv ) {
if( m_startupExceptions )
return 1;
diff --git a/include/internal/catch_session.h b/include/internal/catch_session.h
index 39f7a0dd..eb8013cd 100644
--- a/include/internal/catch_session.h
+++ b/include/internal/catch_session.h
@@ -25,7 +25,7 @@ namespace Catch {
void showHelp() const;
void libIdentify();
- int applyCommandLine( int argc, char* argv[] );
+ int applyCommandLine( int argc, char const * const * argv );
void useConfigData( ConfigData const& configData );
diff --git a/include/internal/catch_test_case_info.cpp b/include/internal/catch_test_case_info.cpp
index 4ab97755..9bf68912 100644
--- a/include/internal/catch_test_case_info.cpp
+++ b/include/internal/catch_test_case_info.cpp
@@ -48,8 +48,7 @@ namespace Catch {
TestCase makeTestCase( ITestInvoker* _testCase,
std::string const& _className,
- std::string const& _name,
- std::string const& _descOrTags,
+ NameAndTags const& nameAndTags,
SourceLineInfo const& _lineInfo )
{
bool isHidden = false;
@@ -58,6 +57,7 @@ namespace Catch {
std::vector<std::string> tags;
std::string desc, tag;
bool inTag = false;
+ std::string _descOrTags = nameAndTags.tags;
for (char c : _descOrTags) {
if( !inTag ) {
if( c == '[' )
@@ -85,8 +85,8 @@ namespace Catch {
tags.push_back( "." );
}
- TestCaseInfo info( _name, _className, desc, tags, _lineInfo );
- return TestCase( _testCase, info );
+ TestCaseInfo info( nameAndTags.name, _className, desc, tags, _lineInfo );
+ return TestCase( _testCase, std::move(info) );
}
void setTags( TestCaseInfo& testCaseInfo, std::vector<std::string> tags ) {
@@ -147,7 +147,7 @@ namespace Catch {
}
- TestCase::TestCase( ITestInvoker* testCase, TestCaseInfo const& info ) : TestCaseInfo( info ), test( testCase ) {}
+ TestCase::TestCase( ITestInvoker* testCase, TestCaseInfo&& info ) : TestCaseInfo( std::move(info) ), test( testCase ) {}
TestCase TestCase::withName( std::string const& _newName ) const {
diff --git a/include/internal/catch_test_case_info.h b/include/internal/catch_test_case_info.h
index 2a911b06..809c974f 100644
--- a/include/internal/catch_test_case_info.h
+++ b/include/internal/catch_test_case_info.h
@@ -9,6 +9,7 @@
#define TWOBLUECUBES_CATCH_TEST_CASE_INFO_H_INCLUDED
#include "catch_common.h"
+#include "catch_test_registry.h"
#include <string>
#include <vector>
@@ -61,7 +62,7 @@ namespace Catch {
class TestCase : public TestCaseInfo {
public:
- TestCase( ITestInvoker* testCase, TestCaseInfo const& info );
+ TestCase( ITestInvoker* testCase, TestCaseInfo&& info );
TestCase withName( std::string const& _newName ) const;
@@ -78,8 +79,7 @@ namespace Catch {
TestCase makeTestCase( ITestInvoker* testCase,
std::string const& className,
- std::string const& name,
- std::string const& description,
+ NameAndTags const& nameAndTags,
SourceLineInfo const& lineInfo );
}
diff --git a/include/internal/catch_test_case_registry_impl.cpp b/include/internal/catch_test_case_registry_impl.cpp
index 89c72392..b30b112a 100644
--- a/include/internal/catch_test_case_registry_impl.cpp
+++ b/include/internal/catch_test_case_registry_impl.cpp
@@ -96,7 +96,7 @@ namespace Catch {
m_testAsFunction();
}
- std::string extractClassName( std::string const& classOrQualifiedMethodName ) {
+ std::string extractClassName( StringRef const& classOrQualifiedMethodName ) {
std::string className = classOrQualifiedMethodName;
if( startsWith( className, '&' ) )
{
diff --git a/include/internal/catch_test_case_registry_impl.h b/include/internal/catch_test_case_registry_impl.h
index ad45e5a0..8dc5b0fe 100644
--- a/include/internal/catch_test_case_registry_impl.h
+++ b/include/internal/catch_test_case_registry_impl.h
@@ -22,7 +22,7 @@ namespace Catch {
class TestCase;
struct IConfig;
- std::vector<TestCase> sortTests( IConfig const& config, std::vector<TestCase> const& unsortedTestCases );
+ std::vector<TestCase> sortTests( IConfig const& config, std::vector<TestCase> const& unsortedTestCases );
bool matchTest( TestCase const& testCase, TestSpec const& testSpec, IConfig const& config );
void enforceNoDuplicateTestCases( std::vector<TestCase> const& functions );
@@ -58,7 +58,7 @@ namespace Catch {
};
- std::string extractClassName( std::string const& classOrQualifiedMethodName );
+ std::string extractClassName( StringRef const& classOrQualifiedMethodName );
///////////////////////////////////////////////////////////////////////////
diff --git a/include/internal/catch_test_registry.cpp b/include/internal/catch_test_registry.cpp
index ec50e92c..ac83f333 100644
--- a/include/internal/catch_test_registry.cpp
+++ b/include/internal/catch_test_registry.cpp
@@ -15,23 +15,22 @@ namespace Catch {
return new(std::nothrow) TestInvokerAsFunction( testAsFunction );
}
- NameAndTags::NameAndTags( StringRef name_ , StringRef tags_ ) noexcept : name( name_ ), tags( tags_ ) {}
+ NameAndTags::NameAndTags( StringRef const& name_ , StringRef const& tags_ ) noexcept : name( name_ ), tags( tags_ ) {}
- AutoReg::AutoReg( ITestInvoker* invoker, SourceLineInfo const& lineInfo, StringRef classOrMethod, NameAndTags const& nameAndTags ) noexcept {
+ AutoReg::AutoReg( ITestInvoker* invoker, SourceLineInfo const& lineInfo, StringRef const& classOrMethod, NameAndTags const& nameAndTags ) noexcept {
try {
getMutableRegistryHub()
.registerTest(
makeTestCase(
invoker,
extractClassName( classOrMethod ),
- nameAndTags.name,
- nameAndTags.tags,
+ nameAndTags,
lineInfo));
} catch (...) {
// Do not throw when constructing global objects, instead register the exception to be processed later
getMutableRegistryHub().registerStartupException();
}
}
-
+
AutoReg::~AutoReg() = default;
}
diff --git a/include/internal/catch_test_registry.h b/include/internal/catch_test_registry.h
index 84001018..a192a531 100644
--- a/include/internal/catch_test_registry.h
+++ b/include/internal/catch_test_registry.h
@@ -35,13 +35,13 @@ auto makeTestInvoker( void (C::*testAsMethod)() ) noexcept -> ITestInvoker* {
}
struct NameAndTags {
- NameAndTags( StringRef name_ = StringRef(), StringRef tags_ = StringRef() ) noexcept;
+ NameAndTags( StringRef const& name_ = StringRef(), StringRef const& tags_ = StringRef() ) noexcept;
StringRef name;
StringRef tags;
};
struct AutoReg : NonCopyable {
- AutoReg( ITestInvoker* invoker, SourceLineInfo const& lineInfo, StringRef classOrMethod, NameAndTags const& nameAndTags ) noexcept;
+ AutoReg( ITestInvoker* invoker, SourceLineInfo const& lineInfo, StringRef const& classOrMethod, NameAndTags const& nameAndTags ) noexcept;
~AutoReg();
};
diff --git a/include/reporters/catch_reporter_tap.hpp b/include/reporters/catch_reporter_tap.hpp
index edb75b5a..19e54ed1 100644
--- a/include/reporters/catch_reporter_tap.hpp
+++ b/include/reporters/catch_reporter_tap.hpp
@@ -26,7 +26,7 @@ namespace Catch {
~TAPReporter() override;
static std::string getDescription() {
- return "Reports test results in TAP format, suitable for test harneses";
+ return "Reports test results in TAP format, suitable for test harnesses";
}
ReporterPreferences getPreferences() const override {