mirror of
https://github.com/catchorg/Catch2.git
synced 2024-11-22 13:26:10 +01:00
Use char const * const * for Session::run
Needed to embed newer version of Clara Closes #1178 Closes #1031
This commit is contained in:
parent
d2ddb997a7
commit
2e285b9579
45
include/external/clara.hpp
vendored
45
include/external/clara.hpp
vendored
@ -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;
|
||||
|
@ -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;
|
||||
|
||||
|
@ -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 );
|
||||
|
||||
|
45
third_party/clara.hpp
vendored
45
third_party/clara.hpp
vendored
@ -5,7 +5,7 @@
|
||||
//
|
||||
// See https://github.com/philsquared/Clara for more details
|
||||
|
||||
// Clara v1.1.2
|
||||
// Clara v1.1.3
|
||||
|
||||
#ifndef CLARA_HPP_INCLUDED
|
||||
#define CLARA_HPP_INCLUDED
|
||||
@ -18,6 +18,15 @@
|
||||
#define CLARA_TEXTFLOW_CONFIG_CONSOLE_WIDTH 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;
|
||||
|
Loading…
Reference in New Issue
Block a user