mirror of
https://github.com/catchorg/Catch2.git
synced 2024-11-17 03:02:24 +01:00
Merge build 30
This commit is contained in:
commit
7a6a230f74
@ -1,6 +1,6 @@
|
|||||||
![catch logo](catch-logo-small.png)
|
![catch logo](catch-logo-small.png)
|
||||||
|
|
||||||
*v1.0 build 27 (master branch)*
|
*v1.0 build 30 (master branch)*
|
||||||
|
|
||||||
Build status (on Travis CI) [![Build Status](https://travis-ci.org/philsquared/Catch.png)](https://travis-ci.org/philsquared/Catch)
|
Build status (on Travis CI) [![Build Status](https://travis-ci.org/philsquared/Catch.png)](https://travis-ci.org/philsquared/Catch)
|
||||||
|
|
||||||
|
@ -142,6 +142,7 @@ So far so good - this is already an improvement on the setup/ teardown approach
|
|||||||
|
|
||||||
The power of sections really shows, however, when we need to execute a sequence of, checked, operations. Continuing the vector example we might want to verify that after reserving a larger capacity, if we reserve smaller capacity (but still larger than the current size) then the capacity is not, in fact, changed. We can do that, naturally, like so:
|
The power of sections really shows, however, when we need to execute a sequence of, checked, operations. Continuing the vector example we might want to verify that after reserving a larger capacity, if we reserve smaller capacity (but still larger than the current size) then the capacity is not, in fact, changed. We can do that, naturally, like so:
|
||||||
|
|
||||||
|
```c++
|
||||||
SECTION( "reserving bigger changes capacity but not size" ) {
|
SECTION( "reserving bigger changes capacity but not size" ) {
|
||||||
v.reserve( 10 );
|
v.reserve( 10 );
|
||||||
|
|
||||||
@ -154,6 +155,7 @@ The power of sections really shows, however, when we need to execute a sequence
|
|||||||
REQUIRE( v.capacity() >= 10 );
|
REQUIRE( v.capacity() >= 10 );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
```
|
||||||
|
|
||||||
Sections can be nested to an arbitrary depth (limited only by your stack size). Each leaf section (i.e. a section that contains no nested sections) will be executed exactly once, on a separate path of execution from any other leaf section (so no leaf section can interfere with another). Obviously a failure in a parent section will prevent nested sections from running - but that's the idea.
|
Sections can be nested to an arbitrary depth (limited only by your stack size). Each leaf section (i.e. a section that contains no nested sections) will be executed exactly once, on a separate path of execution from any other leaf section (so no leaf section can interfere with another). Obviously a failure in a parent section will prevent nested sections from running - but that's the idea.
|
||||||
|
|
||||||
|
@ -17,6 +17,14 @@
|
|||||||
#pragma clang diagnostic ignored "-Wpadded"
|
#pragma clang diagnostic ignored "-Wpadded"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#ifdef CATCH_CONFIG_MAIN
|
||||||
|
# define CATCH_CONFIG_RUNNER
|
||||||
|
# ifndef CLARA_CONFIG_MAIN
|
||||||
|
# define CLARA_CONFIG_MAIN_NOT_DEFINED
|
||||||
|
# define CLARA_CONFIG_MAIN
|
||||||
|
# endif
|
||||||
|
#endif
|
||||||
|
|
||||||
#if (_MANAGED == 1) || (_M_CEE == 1) // detect CLR
|
#if (_MANAGED == 1) || (_M_CEE == 1) // detect CLR
|
||||||
#define INTERNAL_CATCH_VS_MANAGED
|
#define INTERNAL_CATCH_VS_MANAGED
|
||||||
#else
|
#else
|
||||||
@ -31,6 +39,13 @@
|
|||||||
|
|
||||||
#endif // detect CLR
|
#endif // detect CLR
|
||||||
|
|
||||||
|
#if defined(INTERNAL_CATCH_VS_MANAGED) || defined(INTERNAL_CATCH_VS_NATIVE)
|
||||||
|
#define INTERNAL_CATCH_INLINE inline
|
||||||
|
#define CATCH_CONFIG_RUNNER (1)
|
||||||
|
#else
|
||||||
|
#define INTERNAL_CATCH_INLINE
|
||||||
|
#endif
|
||||||
|
|
||||||
#include "internal/catch_notimplemented_exception.h"
|
#include "internal/catch_notimplemented_exception.h"
|
||||||
#include "internal/catch_context.h"
|
#include "internal/catch_context.h"
|
||||||
#include "internal/catch_test_registry.hpp"
|
#include "internal/catch_test_registry.hpp"
|
||||||
@ -51,20 +66,18 @@
|
|||||||
#include "internal/catch_objc.hpp"
|
#include "internal/catch_objc.hpp"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if defined(INTERNAL_CATCH_VS_MANAGED) || defined(INTERNAL_CATCH_VS_NATIVE)
|
#ifdef CATCH_CONFIG_RUNNER
|
||||||
#define INTERNAL_CATCH_INLINE inline
|
|
||||||
#define CATCH_CONFIG_RUNNER (1)
|
|
||||||
#else
|
|
||||||
#define INTERNAL_CATCH_INLINE
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#if defined( CATCH_CONFIG_MAIN ) || defined( CATCH_CONFIG_RUNNER )
|
|
||||||
#include "internal/catch_impl.hpp"
|
#include "internal/catch_impl.hpp"
|
||||||
#endif // CATCH_CONFIG_MAIN || CATCH_CONFIG_RUNNER
|
#endif
|
||||||
|
|
||||||
#ifdef CATCH_CONFIG_MAIN
|
#ifdef CATCH_CONFIG_MAIN
|
||||||
#include "internal/catch_default_main.hpp"
|
#include "internal/catch_default_main.hpp"
|
||||||
#endif // CATCH_CONFIG_MAIN
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
#ifdef CLARA_CONFIG_MAIN_NOT_DEFINED
|
||||||
|
# undef CLARA_CONFIG_MAIN
|
||||||
|
#endif
|
||||||
|
|
||||||
//////
|
//////
|
||||||
|
|
||||||
|
@ -9,12 +9,24 @@
|
|||||||
#ifndef TWOBLUECUBES_CATCH_CLARA_H_INCLUDED
|
#ifndef TWOBLUECUBES_CATCH_CLARA_H_INCLUDED
|
||||||
#define TWOBLUECUBES_CATCH_CLARA_H_INCLUDED
|
#define TWOBLUECUBES_CATCH_CLARA_H_INCLUDED
|
||||||
|
|
||||||
|
// Use Catch's value for console width (store Clara's off to the side, if present)
|
||||||
|
#ifdef CLARA_CONFIG_CONSOLE_WIDTH
|
||||||
|
#define CATCH_TEMP_CLARA_CONFIG_CONSOLE_WIDTH CLARA_CONFIG_CONSOLE_WIDTH
|
||||||
|
#undef CLARA_CONFIG_CONSOLE_WIDTH
|
||||||
|
#endif
|
||||||
#define CLARA_CONFIG_CONSOLE_WIDTH CATCH_CONFIG_CONSOLE_WIDTH
|
#define CLARA_CONFIG_CONSOLE_WIDTH CATCH_CONFIG_CONSOLE_WIDTH
|
||||||
|
|
||||||
|
|
||||||
// Declare Clara inside the Catch namespace
|
// Declare Clara inside the Catch namespace
|
||||||
#define STITCH_CLARA_OUTER_NAMESPACE Catch
|
#define STITCH_CLARA_OPEN_NAMESPACE namespace Catch {
|
||||||
#include "clara.h"
|
#include "clara.h"
|
||||||
#undef STITCH_CLARA_OUTER_NAMESPACE
|
#undef STITCH_CLARA_OPEN_NAMESPACE
|
||||||
|
|
||||||
|
|
||||||
|
// Restore Clara's value for console width, if present
|
||||||
|
#ifdef CATCH_TEMP_CLARA_CONFIG_CONSOLE_WIDTH
|
||||||
|
#define CLARA_CONFIG_CONSOLE_WIDTH CATCH_TEMP_CLARA_CONFIG_CONSOLE_WIDTH
|
||||||
|
#undef CATCH_TEMP_CLARA_CONFIG_CONSOLE_WIDTH
|
||||||
|
#endif
|
||||||
|
|
||||||
#endif // TWOBLUECUBES_CATCH_CLARA_H_INCLUDED
|
#endif // TWOBLUECUBES_CATCH_CLARA_H_INCLUDED
|
||||||
|
@ -55,108 +55,95 @@ namespace Catch {
|
|||||||
|
|
||||||
inline Clara::CommandLine<ConfigData> makeCommandLineParser() {
|
inline Clara::CommandLine<ConfigData> makeCommandLineParser() {
|
||||||
|
|
||||||
Clara::CommandLine<ConfigData> cli;
|
using namespace Clara;
|
||||||
|
CommandLine<ConfigData> cli;
|
||||||
|
|
||||||
cli.bindProcessName( &ConfigData::processName );
|
cli.bindProcessName( &ConfigData::processName );
|
||||||
|
|
||||||
cli.bind( &ConfigData::showHelp )
|
cli["-?"]["-h"]["--help"]
|
||||||
.describe( "display usage information" )
|
.describe( "display usage information" )
|
||||||
.shortOpt( "?")
|
.into( &ConfigData::showHelp );
|
||||||
.shortOpt( "h")
|
|
||||||
.longOpt( "help" );
|
|
||||||
|
|
||||||
cli.bind( &ConfigData::listTests )
|
cli["-l"]["--list-tests"]
|
||||||
.describe( "list all/matching test cases" )
|
.describe( "list all/matching test cases" )
|
||||||
.shortOpt( "l")
|
.into( &ConfigData::listTests );
|
||||||
.longOpt( "list-tests" );
|
|
||||||
|
|
||||||
cli.bind( &ConfigData::listTags )
|
cli["-t"]["--list-tags"]
|
||||||
.describe( "list all/matching tags" )
|
.describe( "list all/matching tags" )
|
||||||
.shortOpt( "t")
|
.into( &ConfigData::listTags );
|
||||||
.longOpt( "list-tags" );
|
|
||||||
|
|
||||||
cli.bind( &ConfigData::showSuccessfulTests )
|
cli["-s"]["--success"]
|
||||||
.describe( "include successful tests in output" )
|
.describe( "include successful tests in output" )
|
||||||
.shortOpt( "s")
|
.into( &ConfigData::showSuccessfulTests );
|
||||||
.longOpt( "success" );
|
|
||||||
|
|
||||||
cli.bind( &ConfigData::shouldDebugBreak )
|
cli["-b"]["--break"]
|
||||||
.describe( "break into debugger on failure" )
|
.describe( "break into debugger on failure" )
|
||||||
.shortOpt( "b")
|
.into( &ConfigData::shouldDebugBreak );
|
||||||
.longOpt( "break" );
|
|
||||||
|
|
||||||
cli.bind( &ConfigData::noThrow )
|
cli["-e"]["--nothrow"]
|
||||||
.describe( "skip exception tests" )
|
.describe( "skip exception tests" )
|
||||||
.shortOpt( "e")
|
.into( &ConfigData::noThrow );
|
||||||
.longOpt( "nothrow" );
|
|
||||||
|
|
||||||
cli.bind( &ConfigData::outputFilename )
|
cli["-o"]["--out"]
|
||||||
|
.placeholder( "filename" )
|
||||||
.describe( "output filename" )
|
.describe( "output filename" )
|
||||||
.shortOpt( "o")
|
.into( &ConfigData::outputFilename );
|
||||||
.longOpt( "out" )
|
|
||||||
.hint( "filename" );
|
|
||||||
|
|
||||||
cli.bind( &ConfigData::reporterName )
|
cli["-r"]["--reporter"]
|
||||||
|
// .placeholder( "name[:filename]" )
|
||||||
|
.placeholder( "name" )
|
||||||
.describe( "reporter to use (defaults to console)" )
|
.describe( "reporter to use (defaults to console)" )
|
||||||
.shortOpt( "r")
|
.into( &ConfigData::reporterName );
|
||||||
.longOpt( "reporter" )
|
|
||||||
// .hint( "name[:filename]" );
|
|
||||||
.hint( "name" );
|
|
||||||
|
|
||||||
cli.bind( &ConfigData::name )
|
cli["-n"]["--name"]
|
||||||
|
.placeholder( "name" )
|
||||||
.describe( "suite name" )
|
.describe( "suite name" )
|
||||||
.shortOpt( "n")
|
.into( &ConfigData::name );
|
||||||
.longOpt( "name" )
|
|
||||||
.hint( "name" );
|
|
||||||
|
|
||||||
cli.bind( &abortAfterFirst )
|
cli["-a"]["--abort"]
|
||||||
.describe( "abort at first failure" )
|
.describe( "abort at first failure" )
|
||||||
.shortOpt( "a")
|
.into( &abortAfterFirst );
|
||||||
.longOpt( "abort" );
|
|
||||||
|
|
||||||
cli.bind( &abortAfterX )
|
cli["-x"]["--abortx"]
|
||||||
|
.placeholder( "number of failures" )
|
||||||
.describe( "abort after x failures" )
|
.describe( "abort after x failures" )
|
||||||
.shortOpt( "x")
|
.into( &abortAfterX );
|
||||||
.longOpt( "abortx" )
|
|
||||||
.hint( "number of failures" );
|
|
||||||
|
|
||||||
cli.bind( &addWarning )
|
cli["-w"]["--warn"]
|
||||||
|
.placeholder( "warning name" )
|
||||||
.describe( "enable warnings" )
|
.describe( "enable warnings" )
|
||||||
.shortOpt( "w")
|
.into( &addWarning );
|
||||||
.longOpt( "warn" )
|
|
||||||
.hint( "warning name" );
|
|
||||||
|
|
||||||
// cli.bind( &setVerbosity )
|
// - needs updating if reinstated
|
||||||
|
// cli.into( &setVerbosity )
|
||||||
// .describe( "level of verbosity (0=no output)" )
|
// .describe( "level of verbosity (0=no output)" )
|
||||||
// .shortOpt( "v")
|
// .shortOpt( "v")
|
||||||
// .longOpt( "verbosity" )
|
// .longOpt( "verbosity" )
|
||||||
// .hint( "level" );
|
// .placeholder( "level" );
|
||||||
|
|
||||||
cli.bind( &addTestOrTags )
|
cli[_]
|
||||||
|
.placeholder( "test name, pattern or tags" )
|
||||||
.describe( "which test or tests to use" )
|
.describe( "which test or tests to use" )
|
||||||
.hint( "test name, pattern or tags" );
|
.into( &addTestOrTags );
|
||||||
|
|
||||||
cli.bind( &setShowDurations )
|
cli["-d"]["--durations"]
|
||||||
|
.placeholder( "yes/no" )
|
||||||
.describe( "show test durations" )
|
.describe( "show test durations" )
|
||||||
.shortOpt( "d")
|
.into( &setShowDurations );
|
||||||
.longOpt( "durations" )
|
|
||||||
.hint( "yes/no" );
|
|
||||||
|
|
||||||
cli.bind( &loadTestNamesFromFile )
|
cli["-f"]["--input-file"]
|
||||||
|
.placeholder( "filename" )
|
||||||
.describe( "load test names to run from a file" )
|
.describe( "load test names to run from a file" )
|
||||||
.shortOpt( "f")
|
.into( &loadTestNamesFromFile );
|
||||||
.longOpt( "input-file" )
|
|
||||||
.hint( "filename" );
|
|
||||||
|
|
||||||
// Less common commands which don't have a short form
|
// Less common commands which don't have a short form
|
||||||
cli.bind( &ConfigData::listTestNamesOnly )
|
cli["--list-test-names-only"]
|
||||||
.describe( "list all/matching test cases names only" )
|
.describe( "list all/matching test cases names only" )
|
||||||
.longOpt( "list-test-names-only" );
|
.into( &ConfigData::listTestNamesOnly );
|
||||||
|
|
||||||
cli.bind( &ConfigData::listReporters )
|
cli["--list-reporters"]
|
||||||
.describe( "list all reporters" )
|
.describe( "list all reporters" )
|
||||||
.longOpt( "list-reporters" );
|
.into( &ConfigData::listReporters );
|
||||||
|
|
||||||
|
|
||||||
return cli;
|
return cli;
|
||||||
}
|
}
|
||||||
|
@ -14,7 +14,7 @@ namespace Catch {
|
|||||||
|
|
||||||
// These numbers are maintained by a script
|
// These numbers are maintained by a script
|
||||||
template <typename T>
|
template <typename T>
|
||||||
const T LibraryVersionInfo<T>::value( 1, 0, 27, "master" );
|
const T LibraryVersionInfo<T>::value( 1, 0, 30, "master" );
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif // TWOBLUECUBES_CATCH_VERSION_HPP_INCLUDED
|
#endif // TWOBLUECUBES_CATCH_VERSION_HPP_INCLUDED
|
||||||
|
@ -29,7 +29,7 @@ namespace Catch {
|
|||||||
|
|
||||||
#ifdef INTERNAL_CATCH_VS_NATIVE
|
#ifdef INTERNAL_CATCH_VS_NATIVE
|
||||||
|
|
||||||
#pragma warning( disable : 4505 ) // required for including CppUnitTest.h at /W4
|
#pragma warning( disable:4505 ) // required for including CppUnitTest.h at /W4
|
||||||
|
|
||||||
#include <CppUnitTest.h>
|
#include <CppUnitTest.h>
|
||||||
|
|
||||||
|
@ -7,11 +7,18 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
// Only use header guard if we are not using an outer namespace
|
// Only use header guard if we are not using an outer namespace
|
||||||
#if !defined(TWOBLUECUBES_CLARA_H_INCLUDED) || defined(STITCH_CLARA_OUTER_NAMESPACE)
|
#if !defined(TWOBLUECUBES_CLARA_H_INCLUDED) || defined(STITCH_CLARA_OPEN_NAMESPACE)
|
||||||
#ifndef STITCH_CLARA_OUTER_NAMESPACE
|
|
||||||
#define TWOBLUECUBES_CLARA_H_INCLUDED
|
|
||||||
|
|
||||||
#define STITCH_TBC_TEXT_FORMAT_OUTER_NAMESPACE Clara
|
#ifndef STITCH_CLARA_OPEN_NAMESPACE
|
||||||
|
#define TWOBLUECUBES_CLARA_H_INCLUDED
|
||||||
|
#define STITCH_CLARA_OPEN_NAMESPACE
|
||||||
|
#define STITCH_CLARA_CLOSE_NAMESPACE
|
||||||
|
#else
|
||||||
|
#define STITCH_CLARA_CLOSE_NAMESPACE }
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
#define STITCH_TBC_TEXT_FORMAT_OPEN_NAMESPACE STITCH_CLARA_OPEN_NAMESPACE
|
||||||
|
|
||||||
// ----------- #included from tbc_text_format.h -----------
|
// ----------- #included from tbc_text_format.h -----------
|
||||||
|
|
||||||
@ -167,9 +174,8 @@ namespace Tbc {
|
|||||||
// ----------- end of #include from tbc_text_format.h -----------
|
// ----------- end of #include from tbc_text_format.h -----------
|
||||||
// ........... back in /Users/philnash/Dev/OSS/Clara/srcs/clara.h
|
// ........... back in /Users/philnash/Dev/OSS/Clara/srcs/clara.h
|
||||||
|
|
||||||
#endif
|
#undef STITCH_TBC_TEXT_FORMAT_OPEN_NAMESPACE
|
||||||
|
|
||||||
#undef STITCH_TBC_TEXT_FORMAT_OUTER_NAMESPACE
|
|
||||||
|
|
||||||
#include <map>
|
#include <map>
|
||||||
#include <algorithm>
|
#include <algorithm>
|
||||||
@ -177,11 +183,16 @@ namespace Tbc {
|
|||||||
#include <memory>
|
#include <memory>
|
||||||
|
|
||||||
// Use optional outer namespace
|
// Use optional outer namespace
|
||||||
#ifdef STITCH_CLARA_OUTER_NAMESPACE
|
#ifdef STITCH_CLARA_OPEN_NAMESPACE
|
||||||
namespace STITCH_CLARA_OUTER_NAMESPACE {
|
STITCH_CLARA_OPEN_NAMESPACE
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
namespace Clara {
|
namespace Clara {
|
||||||
|
|
||||||
|
struct UnpositionalTag {};
|
||||||
|
|
||||||
|
static const UnpositionalTag _;
|
||||||
|
|
||||||
namespace Detail {
|
namespace Detail {
|
||||||
|
|
||||||
#ifdef CLARA_CONSOLE_WIDTH
|
#ifdef CLARA_CONSOLE_WIDTH
|
||||||
@ -192,6 +203,10 @@ namespace Clara {
|
|||||||
|
|
||||||
using namespace Tbc;
|
using namespace Tbc;
|
||||||
|
|
||||||
|
inline bool startsWith( std::string const& str, std::string const& prefix ) {
|
||||||
|
return str.size() >= prefix.size() && str.substr( 0, prefix.size() ) == prefix;
|
||||||
|
}
|
||||||
|
|
||||||
template<typename T> struct RemoveConstRef{ typedef T type; };
|
template<typename T> struct RemoveConstRef{ typedef T type; };
|
||||||
template<typename T> struct RemoveConstRef<T&>{ typedef T type; };
|
template<typename T> struct RemoveConstRef<T&>{ typedef T type; };
|
||||||
template<typename T> struct RemoveConstRef<T const&>{ typedef T type; };
|
template<typename T> struct RemoveConstRef<T const&>{ typedef T type; };
|
||||||
@ -241,10 +256,11 @@ namespace Clara {
|
|||||||
template<typename ConfigT>
|
template<typename ConfigT>
|
||||||
class BoundArgFunction {
|
class BoundArgFunction {
|
||||||
public:
|
public:
|
||||||
|
BoundArgFunction() : functionObj( NULL ) {}
|
||||||
BoundArgFunction( IArgFunction<ConfigT>* _functionObj ) : functionObj( _functionObj ) {}
|
BoundArgFunction( IArgFunction<ConfigT>* _functionObj ) : functionObj( _functionObj ) {}
|
||||||
BoundArgFunction( BoundArgFunction const& other ) : functionObj( other.functionObj->clone() ) {}
|
BoundArgFunction( BoundArgFunction const& other ) : functionObj( other.functionObj ? other.functionObj->clone() : NULL ) {}
|
||||||
BoundArgFunction& operator = ( BoundArgFunction const& other ) {
|
BoundArgFunction& operator = ( BoundArgFunction const& other ) {
|
||||||
IArgFunction<ConfigT>* newFunctionObj = other.functionObj->clone();
|
IArgFunction<ConfigT>* newFunctionObj = other.functionObj ? other.functionObj->clone() : NULL;
|
||||||
delete functionObj;
|
delete functionObj;
|
||||||
functionObj = newFunctionObj;
|
functionObj = newFunctionObj;
|
||||||
return *this;
|
return *this;
|
||||||
@ -423,6 +439,7 @@ namespace Clara {
|
|||||||
class CommandLine {
|
class CommandLine {
|
||||||
|
|
||||||
struct Arg {
|
struct Arg {
|
||||||
|
Arg() : position( -1 ) {}
|
||||||
Arg( Detail::BoundArgFunction<ConfigT> const& _boundField ) : boundField( _boundField ), position( -1 ) {}
|
Arg( Detail::BoundArgFunction<ConfigT> const& _boundField ) : boundField( _boundField ), position( -1 ) {}
|
||||||
|
|
||||||
bool hasShortName( std::string const& shortName ) const {
|
bool hasShortName( std::string const& shortName ) const {
|
||||||
@ -438,7 +455,7 @@ namespace Clara {
|
|||||||
return _longName == longName;
|
return _longName == longName;
|
||||||
}
|
}
|
||||||
bool takesArg() const {
|
bool takesArg() const {
|
||||||
return !hint.empty();
|
return !placeholder.empty();
|
||||||
}
|
}
|
||||||
bool isFixedPositional() const {
|
bool isFixedPositional() const {
|
||||||
return position != -1;
|
return position != -1;
|
||||||
@ -455,7 +472,7 @@ namespace Clara {
|
|||||||
}
|
}
|
||||||
void validate() const {
|
void validate() const {
|
||||||
if( boundField.takesArg() && !takesArg() )
|
if( boundField.takesArg() && !takesArg() )
|
||||||
throw std::logic_error( "command line argument '" + dbgName() + "' must specify a hint" );
|
throw std::logic_error( "command line argument '" + dbgName() + "' must specify a placeholder" );
|
||||||
}
|
}
|
||||||
std::string commands() const {
|
std::string commands() const {
|
||||||
std::ostringstream oss;
|
std::ostringstream oss;
|
||||||
@ -473,8 +490,8 @@ namespace Clara {
|
|||||||
oss << ", ";
|
oss << ", ";
|
||||||
oss << "--" << longName;
|
oss << "--" << longName;
|
||||||
}
|
}
|
||||||
if( !hint.empty() )
|
if( !placeholder.empty() )
|
||||||
oss << " <" << hint << ">";
|
oss << " <" << placeholder << ">";
|
||||||
return oss.str();
|
return oss.str();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -482,7 +499,7 @@ namespace Clara {
|
|||||||
std::vector<std::string> shortNames;
|
std::vector<std::string> shortNames;
|
||||||
std::string longName;
|
std::string longName;
|
||||||
std::string description;
|
std::string description;
|
||||||
std::string hint;
|
std::string placeholder;
|
||||||
int position;
|
int position;
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -493,14 +510,14 @@ namespace Clara {
|
|||||||
typedef std::auto_ptr<Arg> ArgAutoPtr;
|
typedef std::auto_ptr<Arg> ArgAutoPtr;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
class ArgBinder {
|
class ArgBuilder {
|
||||||
public:
|
public:
|
||||||
template<typename F>
|
ArgBuilder( CommandLine* cl )
|
||||||
ArgBinder( CommandLine* cl, F f )
|
: m_cl( cl )
|
||||||
: m_cl( cl ),
|
|
||||||
m_arg( Detail::makeBoundField( f ) )
|
|
||||||
{}
|
{}
|
||||||
ArgBinder( ArgBinder& other )
|
|
||||||
|
|
||||||
|
ArgBuilder( ArgBuilder& other )
|
||||||
: m_cl( other.m_cl ),
|
: m_cl( other.m_cl ),
|
||||||
m_arg( other.m_arg )
|
m_arg( other.m_arg )
|
||||||
{
|
{
|
||||||
@ -508,7 +525,7 @@ namespace Clara {
|
|||||||
}
|
}
|
||||||
// !TBD: Need to include workarounds to be able to declare this
|
// !TBD: Need to include workarounds to be able to declare this
|
||||||
// destructor as able to throw exceptions
|
// destructor as able to throw exceptions
|
||||||
~ArgBinder() /* noexcept(false) */ {
|
~ArgBuilder() /* noexcept(false) */ {
|
||||||
if( m_cl && !std::uncaught_exception() ) {
|
if( m_cl && !std::uncaught_exception() ) {
|
||||||
m_arg.validate();
|
m_arg.validate();
|
||||||
if( m_arg.isFixedPositional() ) {
|
if( m_arg.isFixedPositional() ) {
|
||||||
@ -525,30 +542,66 @@ namespace Clara {
|
|||||||
m_cl->m_options.push_back( m_arg );
|
m_cl->m_options.push_back( m_arg );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
ArgBinder& shortOpt( std::string const& name ) {
|
|
||||||
m_arg.shortNames.push_back( name );
|
template<typename F>
|
||||||
|
void into( F f )
|
||||||
|
{
|
||||||
|
m_arg.boundField = Detail::makeBoundField( f );
|
||||||
|
}
|
||||||
|
|
||||||
|
friend void addOptName( ArgBuilder& builder, std::string const& optName )
|
||||||
|
{
|
||||||
|
if( optName.empty() )
|
||||||
|
return;
|
||||||
|
if( Detail::startsWith( optName, "--" ) ) {
|
||||||
|
if( !builder.m_arg.longName.empty() )
|
||||||
|
throw std::logic_error( "Only one long opt may be specified. '"
|
||||||
|
+ builder.m_arg.longName
|
||||||
|
+ "' already specified, now attempting to add '"
|
||||||
|
+ optName + "'" );
|
||||||
|
builder.m_arg.longName = optName.substr( 2 );
|
||||||
|
}
|
||||||
|
else if( Detail::startsWith( optName, "-" ) )
|
||||||
|
builder.m_arg.shortNames.push_back( optName.substr( 1 ) );
|
||||||
|
else
|
||||||
|
throw std::logic_error( "option must begin with - or --. Option was: '" + optName + "'" );
|
||||||
|
}
|
||||||
|
friend void setPositionalArg( ArgBuilder& builder, int position )
|
||||||
|
{
|
||||||
|
builder.m_arg.position = position;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// Can only supply placeholder after [str] - if it takes an arg
|
||||||
|
ArgBuilder& placeholder( std::string const& placeholder ) {
|
||||||
|
m_arg.placeholder = placeholder;
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
ArgBinder& longOpt( std::string const& name ) {
|
|
||||||
m_arg.longName = name;
|
ArgBuilder& describe( std::string const& description ) {
|
||||||
return *this;
|
|
||||||
}
|
|
||||||
ArgBinder& describe( std::string const& description ) {
|
|
||||||
m_arg.description = description;
|
m_arg.description = description;
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
ArgBinder& hint( std::string const& hint ) {
|
ArgBuilder& detail( std::string const& ) {
|
||||||
m_arg.hint = hint;
|
// m_arg.description = description;
|
||||||
return *this;
|
// !TBD
|
||||||
}
|
|
||||||
ArgBinder& position( int position ) {
|
|
||||||
m_arg.position = position;
|
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
CommandLine* m_cl;
|
CommandLine* m_cl;
|
||||||
Arg m_arg;
|
Arg m_arg;
|
||||||
};
|
};
|
||||||
|
class OptBuilder : public ArgBuilder {
|
||||||
|
public:
|
||||||
|
OptBuilder( CommandLine* cl ) : ArgBuilder( cl ) {}
|
||||||
|
OptBuilder( OptBuilder& other ) : ArgBuilder( other ) {}
|
||||||
|
|
||||||
|
OptBuilder& operator[]( std::string const& optName ) {
|
||||||
|
addOptName( *this, optName );
|
||||||
|
return *this;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
@ -573,11 +626,25 @@ namespace Clara {
|
|||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
|
|
||||||
template<typename F>
|
|
||||||
ArgBinder bind( F f ) {
|
OptBuilder operator[]( std::string const& optName ) {
|
||||||
ArgBinder binder( this, f );
|
OptBuilder builder( this );
|
||||||
return binder;
|
addOptName( builder, optName );
|
||||||
|
return builder;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ArgBuilder operator[]( int position ) {
|
||||||
|
ArgBuilder builder( this );
|
||||||
|
setPositionalArg( builder, position );
|
||||||
|
return builder;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Invoke this with the _ instance
|
||||||
|
ArgBuilder operator[]( UnpositionalTag ) {
|
||||||
|
ArgBuilder builder( this );
|
||||||
|
return builder;
|
||||||
|
}
|
||||||
|
|
||||||
template<typename F>
|
template<typename F>
|
||||||
void bindProcessName( F f ) {
|
void bindProcessName( F f ) {
|
||||||
m_boundProcessName = Detail::makeBoundField( f );
|
m_boundProcessName = Detail::makeBoundField( f );
|
||||||
@ -620,9 +687,9 @@ namespace Clara {
|
|||||||
os << " ";
|
os << " ";
|
||||||
typename std::map<int, Arg>::const_iterator it = m_positionalArgs.find( i );
|
typename std::map<int, Arg>::const_iterator it = m_positionalArgs.find( i );
|
||||||
if( it != m_positionalArgs.end() )
|
if( it != m_positionalArgs.end() )
|
||||||
os << "<" << it->second.hint << ">";
|
os << "<" << it->second.placeholder << ">";
|
||||||
else if( m_arg.get() )
|
else if( m_arg.get() )
|
||||||
os << "<" << m_arg->hint << ">";
|
os << "<" << m_arg->placeholder << ">";
|
||||||
else
|
else
|
||||||
throw std::logic_error( "non consecutive positional arguments with no floating args" );
|
throw std::logic_error( "non consecutive positional arguments with no floating args" );
|
||||||
}
|
}
|
||||||
@ -630,7 +697,7 @@ namespace Clara {
|
|||||||
if( m_arg.get() ) {
|
if( m_arg.get() ) {
|
||||||
if( m_highestSpecifiedArgPosition > 1 )
|
if( m_highestSpecifiedArgPosition > 1 )
|
||||||
os << " ";
|
os << " ";
|
||||||
os << "[<" << m_arg->hint << "> ...]";
|
os << "[<" << m_arg->placeholder << "> ...]";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
std::string argSynopsis() const {
|
std::string argSynopsis() const {
|
||||||
@ -770,8 +837,10 @@ namespace Clara {
|
|||||||
|
|
||||||
} // end namespace Clara
|
} // end namespace Clara
|
||||||
|
|
||||||
#ifdef STITCH_CLARA_OUTER_NAMESPACE
|
|
||||||
} // end outer namespace
|
STITCH_CLARA_CLOSE_NAMESPACE
|
||||||
#endif
|
#undef STITCH_CLARA_OPEN_NAMESPACE
|
||||||
|
#undef STITCH_CLARA_CLOSE_NAMESPACE
|
||||||
|
|
||||||
|
|
||||||
#endif // TWOBLUECUBES_CLARA_H_INCLUDED
|
#endif // TWOBLUECUBES_CLARA_H_INCLUDED
|
||||||
|
@ -12,7 +12,6 @@ set(SOURCES
|
|||||||
${SELF_TEST_DIR}/ApproxTests.cpp
|
${SELF_TEST_DIR}/ApproxTests.cpp
|
||||||
${SELF_TEST_DIR}/BDDTests.cpp
|
${SELF_TEST_DIR}/BDDTests.cpp
|
||||||
${SELF_TEST_DIR}/ClassTests.cpp
|
${SELF_TEST_DIR}/ClassTests.cpp
|
||||||
${SELF_TEST_DIR}/CmdLineTests.cpp
|
|
||||||
${SELF_TEST_DIR}/ConditionTests.cpp
|
${SELF_TEST_DIR}/ConditionTests.cpp
|
||||||
${SELF_TEST_DIR}/ExceptionTests.cpp
|
${SELF_TEST_DIR}/ExceptionTests.cpp
|
||||||
${SELF_TEST_DIR}/GeneratorTests.cpp
|
${SELF_TEST_DIR}/GeneratorTests.cpp
|
||||||
|
@ -750,5 +750,5 @@ with expansion:
|
|||||||
"first" == "second"
|
"first" == "second"
|
||||||
|
|
||||||
===============================================================================
|
===============================================================================
|
||||||
123 test cases - 36 failed (676 assertions - 91 failed)
|
122 test cases - 36 failed (658 assertions - 91 failed)
|
||||||
|
|
||||||
|
@ -6726,205 +6726,6 @@ PASSED:
|
|||||||
with message:
|
with message:
|
||||||
boo!
|
boo!
|
||||||
|
|
||||||
-------------------------------------------------------------------------------
|
|
||||||
cmdline
|
|
||||||
process name
|
|
||||||
-------------------------------------------------------------------------------
|
|
||||||
CmdLineTests.cpp:<line number>
|
|
||||||
...............................................................................
|
|
||||||
|
|
||||||
CmdLineTests.cpp:<line number>:
|
|
||||||
PASSED:
|
|
||||||
CHECK( config.processName == "test" )
|
|
||||||
with expansion:
|
|
||||||
"test" == "test"
|
|
||||||
|
|
||||||
-------------------------------------------------------------------------------
|
|
||||||
cmdline
|
|
||||||
arg separated by spaces
|
|
||||||
-------------------------------------------------------------------------------
|
|
||||||
CmdLineTests.cpp:<line number>
|
|
||||||
...............................................................................
|
|
||||||
|
|
||||||
CmdLineTests.cpp:<line number>:
|
|
||||||
PASSED:
|
|
||||||
CHECK( config.fileName == "filename.ext" )
|
|
||||||
with expansion:
|
|
||||||
"filename.ext" == "filename.ext"
|
|
||||||
|
|
||||||
-------------------------------------------------------------------------------
|
|
||||||
cmdline
|
|
||||||
arg separated by colon
|
|
||||||
-------------------------------------------------------------------------------
|
|
||||||
CmdLineTests.cpp:<line number>
|
|
||||||
...............................................................................
|
|
||||||
|
|
||||||
CmdLineTests.cpp:<line number>:
|
|
||||||
PASSED:
|
|
||||||
CHECK( config.fileName == "filename.ext" )
|
|
||||||
with expansion:
|
|
||||||
"filename.ext" == "filename.ext"
|
|
||||||
|
|
||||||
-------------------------------------------------------------------------------
|
|
||||||
cmdline
|
|
||||||
arg separated by =
|
|
||||||
-------------------------------------------------------------------------------
|
|
||||||
CmdLineTests.cpp:<line number>
|
|
||||||
...............................................................................
|
|
||||||
|
|
||||||
CmdLineTests.cpp:<line number>:
|
|
||||||
PASSED:
|
|
||||||
CHECK( config.fileName == "filename.ext" )
|
|
||||||
with expansion:
|
|
||||||
"filename.ext" == "filename.ext"
|
|
||||||
|
|
||||||
-------------------------------------------------------------------------------
|
|
||||||
cmdline
|
|
||||||
long opt
|
|
||||||
-------------------------------------------------------------------------------
|
|
||||||
CmdLineTests.cpp:<line number>
|
|
||||||
...............................................................................
|
|
||||||
|
|
||||||
CmdLineTests.cpp:<line number>:
|
|
||||||
PASSED:
|
|
||||||
CHECK( config.fileName == "%stdout" )
|
|
||||||
with expansion:
|
|
||||||
"%stdout" == "%stdout"
|
|
||||||
|
|
||||||
-------------------------------------------------------------------------------
|
|
||||||
cmdline
|
|
||||||
a number
|
|
||||||
-------------------------------------------------------------------------------
|
|
||||||
CmdLineTests.cpp:<line number>
|
|
||||||
...............................................................................
|
|
||||||
|
|
||||||
CmdLineTests.cpp:<line number>:
|
|
||||||
PASSED:
|
|
||||||
CHECK( config.number == 42 )
|
|
||||||
with expansion:
|
|
||||||
42 == 42
|
|
||||||
|
|
||||||
-------------------------------------------------------------------------------
|
|
||||||
cmdline
|
|
||||||
not a number
|
|
||||||
-------------------------------------------------------------------------------
|
|
||||||
CmdLineTests.cpp:<line number>
|
|
||||||
...............................................................................
|
|
||||||
|
|
||||||
CmdLineTests.cpp:<line number>:
|
|
||||||
PASSED:
|
|
||||||
CHECK_THROWS( parseInto( cli, argv, config ) )
|
|
||||||
|
|
||||||
CmdLineTests.cpp:<line number>:
|
|
||||||
PASSED:
|
|
||||||
CHECK( config.number == 0 )
|
|
||||||
with expansion:
|
|
||||||
0 == 0
|
|
||||||
|
|
||||||
-------------------------------------------------------------------------------
|
|
||||||
cmdline
|
|
||||||
two parsers
|
|
||||||
-------------------------------------------------------------------------------
|
|
||||||
CmdLineTests.cpp:<line number>
|
|
||||||
...............................................................................
|
|
||||||
|
|
||||||
CmdLineTests.cpp:<line number>:
|
|
||||||
PASSED:
|
|
||||||
CHECK( config1.number == 42 )
|
|
||||||
with expansion:
|
|
||||||
42 == 42
|
|
||||||
|
|
||||||
CmdLineTests.cpp:<line number>:
|
|
||||||
PASSED:
|
|
||||||
REQUIRE_FALSE( unusedTokens.empty() )
|
|
||||||
with expansion:
|
|
||||||
!false
|
|
||||||
|
|
||||||
CmdLineTests.cpp:<line number>:
|
|
||||||
PASSED:
|
|
||||||
CHECK( config2.description == "some text" )
|
|
||||||
with expansion:
|
|
||||||
"some text" == "some text"
|
|
||||||
|
|
||||||
-------------------------------------------------------------------------------
|
|
||||||
cmdline
|
|
||||||
methods
|
|
||||||
in range
|
|
||||||
-------------------------------------------------------------------------------
|
|
||||||
CmdLineTests.cpp:<line number>
|
|
||||||
...............................................................................
|
|
||||||
|
|
||||||
CmdLineTests.cpp:<line number>:
|
|
||||||
PASSED:
|
|
||||||
REQUIRE( config.index == 3 )
|
|
||||||
with expansion:
|
|
||||||
3 == 3
|
|
||||||
|
|
||||||
-------------------------------------------------------------------------------
|
|
||||||
cmdline
|
|
||||||
methods
|
|
||||||
out of range
|
|
||||||
-------------------------------------------------------------------------------
|
|
||||||
CmdLineTests.cpp:<line number>
|
|
||||||
...............................................................................
|
|
||||||
|
|
||||||
CmdLineTests.cpp:<line number>:
|
|
||||||
PASSED:
|
|
||||||
REQUIRE_THROWS( parseInto( cli, argv, config ) )
|
|
||||||
|
|
||||||
-------------------------------------------------------------------------------
|
|
||||||
cmdline
|
|
||||||
flags
|
|
||||||
set
|
|
||||||
-------------------------------------------------------------------------------
|
|
||||||
CmdLineTests.cpp:<line number>
|
|
||||||
...............................................................................
|
|
||||||
|
|
||||||
CmdLineTests.cpp:<line number>:
|
|
||||||
PASSED:
|
|
||||||
REQUIRE( config.flag )
|
|
||||||
with expansion:
|
|
||||||
true
|
|
||||||
|
|
||||||
-------------------------------------------------------------------------------
|
|
||||||
cmdline
|
|
||||||
flags
|
|
||||||
not set
|
|
||||||
-------------------------------------------------------------------------------
|
|
||||||
CmdLineTests.cpp:<line number>
|
|
||||||
...............................................................................
|
|
||||||
|
|
||||||
CmdLineTests.cpp:<line number>:
|
|
||||||
PASSED:
|
|
||||||
REQUIRE( config.flag == false )
|
|
||||||
with expansion:
|
|
||||||
false == false
|
|
||||||
|
|
||||||
-------------------------------------------------------------------------------
|
|
||||||
cmdline
|
|
||||||
positional
|
|
||||||
-------------------------------------------------------------------------------
|
|
||||||
CmdLineTests.cpp:<line number>
|
|
||||||
...............................................................................
|
|
||||||
|
|
||||||
CmdLineTests.cpp:<line number>:
|
|
||||||
PASSED:
|
|
||||||
REQUIRE( config.firstPos == "1st" )
|
|
||||||
with expansion:
|
|
||||||
"1st" == "1st"
|
|
||||||
|
|
||||||
CmdLineTests.cpp:<line number>:
|
|
||||||
PASSED:
|
|
||||||
REQUIRE( config.secondPos == "2nd" )
|
|
||||||
with expansion:
|
|
||||||
"2nd" == "2nd"
|
|
||||||
|
|
||||||
CmdLineTests.cpp:<line number>:
|
|
||||||
PASSED:
|
|
||||||
REQUIRE( config.unpositional == "3rd" )
|
|
||||||
with expansion:
|
|
||||||
"3rd" == "3rd"
|
|
||||||
|
|
||||||
-------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------
|
||||||
section tracking
|
section tracking
|
||||||
-------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------
|
||||||
@ -7158,5 +6959,5 @@ with expansion:
|
|||||||
true
|
true
|
||||||
|
|
||||||
===============================================================================
|
===============================================================================
|
||||||
123 test cases - 51 failed (695 assertions - 110 failed)
|
122 test cases - 51 failed (677 assertions - 110 failed)
|
||||||
|
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
<testsuites>
|
<testsuites>
|
||||||
<testsuite name="~_" errors="10" failures="100" tests="695" hostname="tbd" time="{duration}" timestamp="tbd">
|
<testsuite name="~_" errors="10" failures="100" tests="677" hostname="tbd" time="{duration}" timestamp="tbd">
|
||||||
<testcase classname="global" name="Some simple comparisons between doubles" time="{duration}"/>
|
<testcase classname="global" name="Some simple comparisons between doubles" time="{duration}"/>
|
||||||
<testcase classname="global" name="Approximate comparisons with different epsilons" time="{duration}"/>
|
<testcase classname="global" name="Approximate comparisons with different epsilons" time="{duration}"/>
|
||||||
<testcase classname="global" name="Approximate comparisons with floats" time="{duration}"/>
|
<testcase classname="global" name="Approximate comparisons with floats" time="{duration}"/>
|
||||||
@ -530,19 +530,6 @@ TrickyTests.cpp:<line number>
|
|||||||
<testcase classname="Scenario: Vector resizing affects size and capacity" name="Given: an empty vector/When: it is made larger/Then: the size and capacity go up/And when: it is made smaller again/Then: the size goes down but the capacity stays the same" time="{duration}"/>
|
<testcase classname="Scenario: Vector resizing affects size and capacity" name="Given: an empty vector/When: it is made larger/Then: the size and capacity go up/And when: it is made smaller again/Then: the size goes down but the capacity stays the same" time="{duration}"/>
|
||||||
<testcase classname="Scenario: Vector resizing affects size and capacity" name="Given: an empty vector/When: we reserve more space/Then: The capacity is increased but the size remains the same" time="{duration}"/>
|
<testcase classname="Scenario: Vector resizing affects size and capacity" name="Given: an empty vector/When: we reserve more space/Then: The capacity is increased but the size remains the same" time="{duration}"/>
|
||||||
<testcase classname="Scenario: This is a really long scenario name to see how the list command deals with wrapping" name="Given: A section name that is so long that it cannot fit in a single console width/When: The test headers are printed as part of the normal running of the scenario/Then: The, deliberately very long and overly verbose (you see what I did there?) section names must wrap, along with an indent" time="{duration}"/>
|
<testcase classname="Scenario: This is a really long scenario name to see how the list command deals with wrapping" name="Given: A section name that is so long that it cannot fit in a single console width/When: The test headers are printed as part of the normal running of the scenario/Then: The, deliberately very long and overly verbose (you see what I did there?) section names must wrap, along with an indent" time="{duration}"/>
|
||||||
<testcase classname="cmdline" name="process name" time="{duration}"/>
|
|
||||||
<testcase classname="cmdline" name="arg separated by spaces" time="{duration}"/>
|
|
||||||
<testcase classname="cmdline" name="arg separated by colon" time="{duration}"/>
|
|
||||||
<testcase classname="cmdline" name="arg separated by =" time="{duration}"/>
|
|
||||||
<testcase classname="cmdline" name="long opt" time="{duration}"/>
|
|
||||||
<testcase classname="cmdline" name="a number" time="{duration}"/>
|
|
||||||
<testcase classname="cmdline" name="not a number" time="{duration}"/>
|
|
||||||
<testcase classname="cmdline" name="two parsers" time="{duration}"/>
|
|
||||||
<testcase classname="cmdline" name="methods/in range" time="{duration}"/>
|
|
||||||
<testcase classname="cmdline" name="methods/out of range" time="{duration}"/>
|
|
||||||
<testcase classname="cmdline" name="flags/set" time="{duration}"/>
|
|
||||||
<testcase classname="cmdline" name="flags/not set" time="{duration}"/>
|
|
||||||
<testcase classname="cmdline" name="positional" time="{duration}"/>
|
|
||||||
<testcase classname="section tracking" name="root" time="{duration}"/>
|
<testcase classname="section tracking" name="root" time="{duration}"/>
|
||||||
<testcase classname="section tracking" name="test case with no sections" time="{duration}"/>
|
<testcase classname="section tracking" name="test case with no sections" time="{duration}"/>
|
||||||
<testcase classname="section tracking" name="test case with one section" time="{duration}"/>
|
<testcase classname="section tracking" name="test case with one section" time="{duration}"/>
|
||||||
|
@ -6967,210 +6967,6 @@ there"
|
|||||||
</Section>
|
</Section>
|
||||||
<OverallResult success="true"/>
|
<OverallResult success="true"/>
|
||||||
</TestCase>
|
</TestCase>
|
||||||
<TestCase name="cmdline">
|
|
||||||
<Section name="process name">
|
|
||||||
<Expression success="true" filename="/Users/philnash/Dev/OSS/Catch/projects/SelfTest/CmdLineTests.cpp" >
|
|
||||||
<Original>
|
|
||||||
config.processName == "test"
|
|
||||||
</Original>
|
|
||||||
<Expanded>
|
|
||||||
"test" == "test"
|
|
||||||
</Expanded>
|
|
||||||
</Expression>
|
|
||||||
<OverallResults successes="1" failures="0"/>
|
|
||||||
</Section>
|
|
||||||
<Section name="arg separated by spaces">
|
|
||||||
<Expression success="true" filename="/Users/philnash/Dev/OSS/Catch/projects/SelfTest/CmdLineTests.cpp" >
|
|
||||||
<Original>
|
|
||||||
config.fileName == "filename.ext"
|
|
||||||
</Original>
|
|
||||||
<Expanded>
|
|
||||||
"filename.ext" == "filename.ext"
|
|
||||||
</Expanded>
|
|
||||||
</Expression>
|
|
||||||
<OverallResults successes="1" failures="0"/>
|
|
||||||
</Section>
|
|
||||||
<Section name="arg separated by colon">
|
|
||||||
<Expression success="true" filename="/Users/philnash/Dev/OSS/Catch/projects/SelfTest/CmdLineTests.cpp" >
|
|
||||||
<Original>
|
|
||||||
config.fileName == "filename.ext"
|
|
||||||
</Original>
|
|
||||||
<Expanded>
|
|
||||||
"filename.ext" == "filename.ext"
|
|
||||||
</Expanded>
|
|
||||||
</Expression>
|
|
||||||
<OverallResults successes="1" failures="0"/>
|
|
||||||
</Section>
|
|
||||||
<Section name="arg separated by =">
|
|
||||||
<Expression success="true" filename="/Users/philnash/Dev/OSS/Catch/projects/SelfTest/CmdLineTests.cpp" >
|
|
||||||
<Original>
|
|
||||||
config.fileName == "filename.ext"
|
|
||||||
</Original>
|
|
||||||
<Expanded>
|
|
||||||
"filename.ext" == "filename.ext"
|
|
||||||
</Expanded>
|
|
||||||
</Expression>
|
|
||||||
<OverallResults successes="1" failures="0"/>
|
|
||||||
</Section>
|
|
||||||
<Section name="long opt">
|
|
||||||
<Expression success="true" filename="/Users/philnash/Dev/OSS/Catch/projects/SelfTest/CmdLineTests.cpp" >
|
|
||||||
<Original>
|
|
||||||
config.fileName == "%stdout"
|
|
||||||
</Original>
|
|
||||||
<Expanded>
|
|
||||||
"%stdout" == "%stdout"
|
|
||||||
</Expanded>
|
|
||||||
</Expression>
|
|
||||||
<OverallResults successes="1" failures="0"/>
|
|
||||||
</Section>
|
|
||||||
<Section name="a number">
|
|
||||||
<Expression success="true" filename="/Users/philnash/Dev/OSS/Catch/projects/SelfTest/CmdLineTests.cpp" >
|
|
||||||
<Original>
|
|
||||||
config.number == 42
|
|
||||||
</Original>
|
|
||||||
<Expanded>
|
|
||||||
42 == 42
|
|
||||||
</Expanded>
|
|
||||||
</Expression>
|
|
||||||
<OverallResults successes="1" failures="0"/>
|
|
||||||
</Section>
|
|
||||||
<Section name="not a number">
|
|
||||||
<Expression success="true" filename="/Users/philnash/Dev/OSS/Catch/projects/SelfTest/CmdLineTests.cpp" >
|
|
||||||
<Original>
|
|
||||||
parseInto( cli, argv, config )
|
|
||||||
</Original>
|
|
||||||
<Expanded>
|
|
||||||
parseInto( cli, argv, config )
|
|
||||||
</Expanded>
|
|
||||||
</Expression>
|
|
||||||
<Expression success="true" filename="/Users/philnash/Dev/OSS/Catch/projects/SelfTest/CmdLineTests.cpp" >
|
|
||||||
<Original>
|
|
||||||
config.number == 0
|
|
||||||
</Original>
|
|
||||||
<Expanded>
|
|
||||||
0 == 0
|
|
||||||
</Expanded>
|
|
||||||
</Expression>
|
|
||||||
<OverallResults successes="2" failures="0"/>
|
|
||||||
</Section>
|
|
||||||
<Section name="two parsers">
|
|
||||||
<Expression success="true" filename="/Users/philnash/Dev/OSS/Catch/projects/SelfTest/CmdLineTests.cpp" >
|
|
||||||
<Original>
|
|
||||||
config1.number == 42
|
|
||||||
</Original>
|
|
||||||
<Expanded>
|
|
||||||
42 == 42
|
|
||||||
</Expanded>
|
|
||||||
</Expression>
|
|
||||||
<Expression success="true" filename="/Users/philnash/Dev/OSS/Catch/projects/SelfTest/CmdLineTests.cpp" >
|
|
||||||
<Original>
|
|
||||||
!unusedTokens.empty()
|
|
||||||
</Original>
|
|
||||||
<Expanded>
|
|
||||||
!false
|
|
||||||
</Expanded>
|
|
||||||
</Expression>
|
|
||||||
<Expression success="true" filename="/Users/philnash/Dev/OSS/Catch/projects/SelfTest/CmdLineTests.cpp" >
|
|
||||||
<Original>
|
|
||||||
config2.description == "some text"
|
|
||||||
</Original>
|
|
||||||
<Expanded>
|
|
||||||
"some text" == "some text"
|
|
||||||
</Expanded>
|
|
||||||
</Expression>
|
|
||||||
<OverallResults successes="3" failures="0"/>
|
|
||||||
</Section>
|
|
||||||
<Section name="methods">
|
|
||||||
<OverallResults successes="0" failures="0"/>
|
|
||||||
</Section>
|
|
||||||
<Section name="methods">
|
|
||||||
<Section name="in range">
|
|
||||||
<Expression success="true" filename="/Users/philnash/Dev/OSS/Catch/projects/SelfTest/CmdLineTests.cpp" >
|
|
||||||
<Original>
|
|
||||||
config.index == 3
|
|
||||||
</Original>
|
|
||||||
<Expanded>
|
|
||||||
3 == 3
|
|
||||||
</Expanded>
|
|
||||||
</Expression>
|
|
||||||
<OverallResults successes="1" failures="0"/>
|
|
||||||
</Section>
|
|
||||||
<OverallResults successes="1" failures="0"/>
|
|
||||||
</Section>
|
|
||||||
<Section name="methods">
|
|
||||||
<Section name="out of range">
|
|
||||||
<Expression success="true" filename="/Users/philnash/Dev/OSS/Catch/projects/SelfTest/CmdLineTests.cpp" >
|
|
||||||
<Original>
|
|
||||||
parseInto( cli, argv, config )
|
|
||||||
</Original>
|
|
||||||
<Expanded>
|
|
||||||
parseInto( cli, argv, config )
|
|
||||||
</Expanded>
|
|
||||||
</Expression>
|
|
||||||
<OverallResults successes="1" failures="0"/>
|
|
||||||
</Section>
|
|
||||||
<OverallResults successes="1" failures="0"/>
|
|
||||||
</Section>
|
|
||||||
<Section name="flags">
|
|
||||||
<OverallResults successes="0" failures="0"/>
|
|
||||||
</Section>
|
|
||||||
<Section name="flags">
|
|
||||||
<Section name="set">
|
|
||||||
<Expression success="true" filename="/Users/philnash/Dev/OSS/Catch/projects/SelfTest/CmdLineTests.cpp" >
|
|
||||||
<Original>
|
|
||||||
config.flag
|
|
||||||
</Original>
|
|
||||||
<Expanded>
|
|
||||||
true
|
|
||||||
</Expanded>
|
|
||||||
</Expression>
|
|
||||||
<OverallResults successes="1" failures="0"/>
|
|
||||||
</Section>
|
|
||||||
<OverallResults successes="1" failures="0"/>
|
|
||||||
</Section>
|
|
||||||
<Section name="flags">
|
|
||||||
<Section name="not set">
|
|
||||||
<Expression success="true" filename="/Users/philnash/Dev/OSS/Catch/projects/SelfTest/CmdLineTests.cpp" >
|
|
||||||
<Original>
|
|
||||||
config.flag == false
|
|
||||||
</Original>
|
|
||||||
<Expanded>
|
|
||||||
false == false
|
|
||||||
</Expanded>
|
|
||||||
</Expression>
|
|
||||||
<OverallResults successes="1" failures="0"/>
|
|
||||||
</Section>
|
|
||||||
<OverallResults successes="1" failures="0"/>
|
|
||||||
</Section>
|
|
||||||
<Section name="positional">
|
|
||||||
<Expression success="true" filename="/Users/philnash/Dev/OSS/Catch/projects/SelfTest/CmdLineTests.cpp" >
|
|
||||||
<Original>
|
|
||||||
config.firstPos == "1st"
|
|
||||||
</Original>
|
|
||||||
<Expanded>
|
|
||||||
"1st" == "1st"
|
|
||||||
</Expanded>
|
|
||||||
</Expression>
|
|
||||||
<Expression success="true" filename="/Users/philnash/Dev/OSS/Catch/projects/SelfTest/CmdLineTests.cpp" >
|
|
||||||
<Original>
|
|
||||||
config.secondPos == "2nd"
|
|
||||||
</Original>
|
|
||||||
<Expanded>
|
|
||||||
"2nd" == "2nd"
|
|
||||||
</Expanded>
|
|
||||||
</Expression>
|
|
||||||
<Expression success="true" filename="/Users/philnash/Dev/OSS/Catch/projects/SelfTest/CmdLineTests.cpp" >
|
|
||||||
<Original>
|
|
||||||
config.unpositional == "3rd"
|
|
||||||
</Original>
|
|
||||||
<Expanded>
|
|
||||||
"3rd" == "3rd"
|
|
||||||
</Expanded>
|
|
||||||
</Expression>
|
|
||||||
<OverallResults successes="3" failures="0"/>
|
|
||||||
</Section>
|
|
||||||
<OverallResult success="true"/>
|
|
||||||
</TestCase>
|
|
||||||
<TestCase name="section tracking">
|
<TestCase name="section tracking">
|
||||||
<Expression success="true" filename="/Users/philnash/Dev/OSS/Catch/projects/SelfTest/SectionTrackerTests.cpp" >
|
<Expression success="true" filename="/Users/philnash/Dev/OSS/Catch/projects/SelfTest/SectionTrackerTests.cpp" >
|
||||||
<Original>
|
<Original>
|
||||||
@ -7418,7 +7214,7 @@ there"
|
|||||||
</Section>
|
</Section>
|
||||||
<OverallResult success="true"/>
|
<OverallResult success="true"/>
|
||||||
</TestCase>
|
</TestCase>
|
||||||
<OverallResults successes="585" failures="110"/>
|
<OverallResults successes="567" failures="110"/>
|
||||||
</Group>
|
</Group>
|
||||||
<OverallResults successes="585" failures="110"/>
|
<OverallResults successes="567" failures="110"/>
|
||||||
</Catch>
|
</Catch>
|
||||||
|
@ -1,192 +0,0 @@
|
|||||||
/*
|
|
||||||
* Created by Phil on 22/10/2010.
|
|
||||||
* Copyright 2010 Two Blue Cubes Ltd
|
|
||||||
*
|
|
||||||
* Distributed under the Boost Software License, Version 1.0. (See accompanying
|
|
||||||
* file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
|
|
||||||
*/
|
|
||||||
#ifdef __clang__
|
|
||||||
#pragma clang diagnostic ignored "-Wpadded"
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#include "internal/clara.h" // This will does not declare Clara within the Catch namespace
|
|
||||||
|
|
||||||
#include "catch.hpp"
|
|
||||||
|
|
||||||
|
|
||||||
// Helper to deduce size from array literals and pass on to parser
|
|
||||||
template<size_t size, typename ConfigT>
|
|
||||||
std::vector<Clara::Parser::Token> parseInto( Clara::CommandLine<ConfigT>& cli, char const * (&argv)[size], ConfigT& config ) {
|
|
||||||
return cli.parseInto( size, argv, config );
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
struct TestOpt {
|
|
||||||
TestOpt() : number( 0 ), index( 0 ), flag( false ) {}
|
|
||||||
|
|
||||||
std::string processName;
|
|
||||||
std::string fileName;
|
|
||||||
int number;
|
|
||||||
int index;
|
|
||||||
bool flag;
|
|
||||||
std::string firstPos;
|
|
||||||
std::string secondPos;
|
|
||||||
std::string unpositional;
|
|
||||||
|
|
||||||
void setValidIndex( int i ) {
|
|
||||||
if( i < 0 || i > 10 )
|
|
||||||
throw std::domain_error( "index must be between 0 and 10" );
|
|
||||||
index = i;
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
struct TestOpt2 {
|
|
||||||
std::string description;
|
|
||||||
};
|
|
||||||
|
|
||||||
#ifdef CATCH_CONFIG_VARIADIC_MACROS
|
|
||||||
|
|
||||||
TEST_CASE( "cmdline" ) {
|
|
||||||
|
|
||||||
TestOpt config;
|
|
||||||
Clara::CommandLine<TestOpt> cli;
|
|
||||||
cli.bindProcessName( &TestOpt::processName );
|
|
||||||
cli.bind( &TestOpt::fileName )
|
|
||||||
.describe( "specifies output file" )
|
|
||||||
.shortOpt( "o" )
|
|
||||||
.longOpt( "output" )
|
|
||||||
.hint( "filename" );
|
|
||||||
|
|
||||||
SECTION( "process name" ) {
|
|
||||||
char const * argv[] = { "test", "-o filename.ext" };
|
|
||||||
parseInto( cli, argv, config );
|
|
||||||
|
|
||||||
CHECK( config.processName == "test" );
|
|
||||||
}
|
|
||||||
SECTION( "arg separated by spaces" ) {
|
|
||||||
char const * argv[] = { "test", "-o filename.ext" };
|
|
||||||
parseInto( cli, argv, config );
|
|
||||||
|
|
||||||
CHECK( config.fileName == "filename.ext" );
|
|
||||||
}
|
|
||||||
SECTION( "arg separated by colon" ) {
|
|
||||||
const char* argv[] = { "test", "-o:filename.ext" };
|
|
||||||
parseInto( cli, argv, config );
|
|
||||||
|
|
||||||
CHECK( config.fileName == "filename.ext" );
|
|
||||||
}
|
|
||||||
SECTION( "arg separated by =" ) {
|
|
||||||
const char* argv[] = { "test", "-o=filename.ext" };
|
|
||||||
parseInto( cli, argv, config );
|
|
||||||
|
|
||||||
CHECK( config.fileName == "filename.ext" );
|
|
||||||
}
|
|
||||||
SECTION( "long opt" ) {
|
|
||||||
const char* argv[] = { "test", "--output %stdout" };
|
|
||||||
parseInto( cli, argv, config );
|
|
||||||
|
|
||||||
CHECK( config.fileName == "%stdout" );
|
|
||||||
}
|
|
||||||
|
|
||||||
cli.bind( &TestOpt::number )
|
|
||||||
.shortOpt( "n" )
|
|
||||||
.hint( "an integral value" );
|
|
||||||
|
|
||||||
SECTION( "a number" ) {
|
|
||||||
const char* argv[] = { "test", "-n 42" };
|
|
||||||
parseInto( cli, argv, config );
|
|
||||||
|
|
||||||
CHECK( config.number == 42 );
|
|
||||||
}
|
|
||||||
SECTION( "not a number" ) {
|
|
||||||
const char* argv[] = { "test", "-n forty-two" };
|
|
||||||
CHECK_THROWS( parseInto( cli, argv, config ) );
|
|
||||||
|
|
||||||
CHECK( config.number == 0 );
|
|
||||||
}
|
|
||||||
|
|
||||||
SECTION( "two parsers" ) {
|
|
||||||
|
|
||||||
TestOpt config1;
|
|
||||||
TestOpt2 config2;
|
|
||||||
Clara::CommandLine<TestOpt2> cli2;
|
|
||||||
|
|
||||||
cli2.bind( &TestOpt2::description )
|
|
||||||
.describe( "description" )
|
|
||||||
.shortOpt( "d" )
|
|
||||||
.longOpt( "description" )
|
|
||||||
.hint( "some text" );
|
|
||||||
|
|
||||||
const char* argv[] = { "test", "-n 42", "-d some text" };
|
|
||||||
std::vector<Clara::Parser::Token> unusedTokens = parseInto( cli, argv, config1 );
|
|
||||||
|
|
||||||
CHECK( config1.number == 42 );
|
|
||||||
|
|
||||||
REQUIRE_FALSE( unusedTokens.empty() );
|
|
||||||
cli2.populate( unusedTokens, config2 );
|
|
||||||
CHECK( config2.description == "some text" );
|
|
||||||
}
|
|
||||||
|
|
||||||
SECTION( "methods" ) {
|
|
||||||
cli.bind( &TestOpt::setValidIndex )
|
|
||||||
.describe( "An index, which is an integer between 0 and 10, inclusive" )
|
|
||||||
.shortOpt( "i" )
|
|
||||||
.hint( "index" );
|
|
||||||
|
|
||||||
SECTION( "in range" ) {
|
|
||||||
const char* argv[] = { "test", "-i 3" };
|
|
||||||
parseInto( cli, argv, config );
|
|
||||||
|
|
||||||
REQUIRE( config.index == 3 );
|
|
||||||
}
|
|
||||||
SECTION( "out of range" ) {
|
|
||||||
const char* argv[] = { "test", "-i 42" };
|
|
||||||
|
|
||||||
REQUIRE_THROWS( parseInto( cli, argv, config ) );
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
SECTION( "flags" ) {
|
|
||||||
cli.bind( &TestOpt::flag )
|
|
||||||
.describe( "A flag" )
|
|
||||||
.shortOpt( "f" );
|
|
||||||
|
|
||||||
SECTION( "set" ) {
|
|
||||||
const char* argv[] = { "test", "-f" };
|
|
||||||
parseInto( cli, argv, config );
|
|
||||||
|
|
||||||
REQUIRE( config.flag );
|
|
||||||
}
|
|
||||||
SECTION( "not set" ) {
|
|
||||||
const char* argv[] = { "test" };
|
|
||||||
parseInto( cli, argv, config );
|
|
||||||
|
|
||||||
REQUIRE( config.flag == false );
|
|
||||||
}
|
|
||||||
}
|
|
||||||
SECTION( "positional" ) {
|
|
||||||
cli.bind( &TestOpt::secondPos )
|
|
||||||
.describe( "Second position" )
|
|
||||||
.hint( "second arg" )
|
|
||||||
.position( 2 );
|
|
||||||
cli.bind( &TestOpt::unpositional )
|
|
||||||
.hint( "any arg" )
|
|
||||||
.describe( "Unpositional" );
|
|
||||||
cli.bind( &TestOpt::firstPos )
|
|
||||||
.describe( "First position" )
|
|
||||||
.hint( "first arg" )
|
|
||||||
.position( 1 );
|
|
||||||
|
|
||||||
// std::cout << cli.usage( "testApp" ) << std::endl;
|
|
||||||
|
|
||||||
const char* argv[] = { "test", "-f", "1st", "-o", "filename", "2nd", "3rd" };
|
|
||||||
parseInto( cli, argv, config );
|
|
||||||
|
|
||||||
REQUIRE( config.firstPos == "1st" );
|
|
||||||
REQUIRE( config.secondPos == "2nd" );
|
|
||||||
REQUIRE( config.unpositional == "3rd" );
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
#endif
|
|
@ -1,7 +1,6 @@
|
|||||||
SOURCES = ApproxTests.cpp \
|
SOURCES = ApproxTests.cpp \
|
||||||
BDDTests.cpp \
|
BDDTests.cpp \
|
||||||
ClassTests.cpp \
|
ClassTests.cpp \
|
||||||
CmdLineTests.cpp \
|
|
||||||
ConditionTests.cpp \
|
ConditionTests.cpp \
|
||||||
ExceptionTests.cpp \
|
ExceptionTests.cpp \
|
||||||
GeneratorTests.cpp \
|
GeneratorTests.cpp \
|
||||||
|
@ -138,7 +138,6 @@
|
|||||||
<ClCompile Include="..\..\SelfTest\ApproxTests.cpp" />
|
<ClCompile Include="..\..\SelfTest\ApproxTests.cpp" />
|
||||||
<ClCompile Include="..\..\SelfTest\BDDTests.cpp" />
|
<ClCompile Include="..\..\SelfTest\BDDTests.cpp" />
|
||||||
<ClCompile Include="..\..\SelfTest\ClassTests.cpp" />
|
<ClCompile Include="..\..\SelfTest\ClassTests.cpp" />
|
||||||
<ClCompile Include="..\..\SelfTest\CmdLineTests.cpp" />
|
|
||||||
<ClCompile Include="..\..\SelfTest\ConditionTests.cpp" />
|
<ClCompile Include="..\..\SelfTest\ConditionTests.cpp" />
|
||||||
<ClCompile Include="..\..\SelfTest\ExceptionTests.cpp" />
|
<ClCompile Include="..\..\SelfTest\ExceptionTests.cpp" />
|
||||||
<ClCompile Include="..\..\SelfTest\GeneratorTests.cpp" />
|
<ClCompile Include="..\..\SelfTest\GeneratorTests.cpp" />
|
||||||
|
@ -30,9 +30,6 @@
|
|||||||
<ClCompile Include="..\..\SelfTest\BDDTests.cpp">
|
<ClCompile Include="..\..\SelfTest\BDDTests.cpp">
|
||||||
<Filter>Source Files</Filter>
|
<Filter>Source Files</Filter>
|
||||||
</ClCompile>
|
</ClCompile>
|
||||||
<ClCompile Include="..\..\SelfTest\CmdLineTests.cpp">
|
|
||||||
<Filter>Source Files</Filter>
|
|
||||||
</ClCompile>
|
|
||||||
<ClCompile Include="..\..\SelfTest\ConditionTests.cpp">
|
<ClCompile Include="..\..\SelfTest\ConditionTests.cpp">
|
||||||
<Filter>Source Files</Filter>
|
<Filter>Source Files</Filter>
|
||||||
</ClCompile>
|
</ClCompile>
|
||||||
|
@ -93,7 +93,6 @@
|
|||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<ClCompile Include="..\..\..\SelfTest\ApproxTests.cpp" />
|
<ClCompile Include="..\..\..\SelfTest\ApproxTests.cpp" />
|
||||||
<ClCompile Include="..\..\..\SelfTest\BDDTests.cpp" />
|
<ClCompile Include="..\..\..\SelfTest\BDDTests.cpp" />
|
||||||
<ClCompile Include="..\..\..\SelfTest\CmdLineTests.cpp" />
|
|
||||||
<ClCompile Include="..\..\..\SelfTest\SectionTrackerTests.cpp" />
|
<ClCompile Include="..\..\..\SelfTest\SectionTrackerTests.cpp" />
|
||||||
<ClCompile Include="..\..\..\SelfTest\TestMain.cpp" />
|
<ClCompile Include="..\..\..\SelfTest\TestMain.cpp" />
|
||||||
<ClCompile Include="..\..\..\SelfTest\ClassTests.cpp" />
|
<ClCompile Include="..\..\..\SelfTest\ClassTests.cpp" />
|
||||||
|
@ -157,7 +157,6 @@
|
|||||||
<ClCompile Include="..\..\SelfTest\ApproxTests.cpp" />
|
<ClCompile Include="..\..\SelfTest\ApproxTests.cpp" />
|
||||||
<ClCompile Include="..\..\SelfTest\BDDTests.cpp" />
|
<ClCompile Include="..\..\SelfTest\BDDTests.cpp" />
|
||||||
<ClCompile Include="..\..\SelfTest\ClassTests.cpp" />
|
<ClCompile Include="..\..\SelfTest\ClassTests.cpp" />
|
||||||
<ClCompile Include="..\..\SelfTest\CmdLineTests.cpp" />
|
|
||||||
<ClCompile Include="..\..\SelfTest\ConditionTests.cpp" />
|
<ClCompile Include="..\..\SelfTest\ConditionTests.cpp" />
|
||||||
<ClCompile Include="..\..\SelfTest\ExceptionTests.cpp" />
|
<ClCompile Include="..\..\SelfTest\ExceptionTests.cpp" />
|
||||||
<ClCompile Include="..\..\SelfTest\GeneratorTests.cpp" />
|
<ClCompile Include="..\..\SelfTest\GeneratorTests.cpp" />
|
||||||
|
@ -33,9 +33,6 @@
|
|||||||
<ClCompile Include="..\..\SelfTest\ClassTests.cpp">
|
<ClCompile Include="..\..\SelfTest\ClassTests.cpp">
|
||||||
<Filter>Source Files</Filter>
|
<Filter>Source Files</Filter>
|
||||||
</ClCompile>
|
</ClCompile>
|
||||||
<ClCompile Include="..\..\SelfTest\CmdLineTests.cpp">
|
|
||||||
<Filter>Source Files</Filter>
|
|
||||||
</ClCompile>
|
|
||||||
<ClCompile Include="..\..\SelfTest\ConditionTests.cpp">
|
<ClCompile Include="..\..\SelfTest\ConditionTests.cpp">
|
||||||
<Filter>Source Files</Filter>
|
<Filter>Source Files</Filter>
|
||||||
</ClCompile>
|
</ClCompile>
|
||||||
|
@ -153,7 +153,6 @@
|
|||||||
<ClCompile Include="..\..\SelfTest\ApproxTests.cpp" />
|
<ClCompile Include="..\..\SelfTest\ApproxTests.cpp" />
|
||||||
<ClCompile Include="..\..\SelfTest\BDDTests.cpp" />
|
<ClCompile Include="..\..\SelfTest\BDDTests.cpp" />
|
||||||
<ClCompile Include="..\..\SelfTest\ClassTests.cpp" />
|
<ClCompile Include="..\..\SelfTest\ClassTests.cpp" />
|
||||||
<ClCompile Include="..\..\SelfTest\CmdLineTests.cpp" />
|
|
||||||
<ClCompile Include="..\..\SelfTest\ConditionTests.cpp" />
|
<ClCompile Include="..\..\SelfTest\ConditionTests.cpp" />
|
||||||
<ClCompile Include="..\..\SelfTest\ExceptionTests.cpp" />
|
<ClCompile Include="..\..\SelfTest\ExceptionTests.cpp" />
|
||||||
<ClCompile Include="..\..\SelfTest\GeneratorTests.cpp" />
|
<ClCompile Include="..\..\SelfTest\GeneratorTests.cpp" />
|
||||||
|
@ -41,9 +41,6 @@
|
|||||||
<ClCompile Include="..\..\SelfTest\ClassTests.cpp">
|
<ClCompile Include="..\..\SelfTest\ClassTests.cpp">
|
||||||
<Filter>Source Files</Filter>
|
<Filter>Source Files</Filter>
|
||||||
</ClCompile>
|
</ClCompile>
|
||||||
<ClCompile Include="..\..\SelfTest\CmdLineTests.cpp">
|
|
||||||
<Filter>Source Files</Filter>
|
|
||||||
</ClCompile>
|
|
||||||
<ClCompile Include="..\..\SelfTest\ConditionTests.cpp">
|
<ClCompile Include="..\..\SelfTest\ConditionTests.cpp">
|
||||||
<Filter>Source Files</Filter>
|
<Filter>Source Files</Filter>
|
||||||
</ClCompile>
|
</ClCompile>
|
||||||
|
@ -8,6 +8,7 @@
|
|||||||
#include "targetver.h"
|
#include "targetver.h"
|
||||||
|
|
||||||
// Headers for CppUnitTest
|
// Headers for CppUnitTest
|
||||||
|
#pragma warning( disable:4505 ) // required for including CppUnitTest.h at /W4
|
||||||
#include "CppUnitTest.h"
|
#include "CppUnitTest.h"
|
||||||
|
|
||||||
// TODO: reference additional headers your program requires here
|
// TODO: reference additional headers your program requires here
|
||||||
|
@ -8,7 +8,6 @@
|
|||||||
|
|
||||||
/* Begin PBXBuildFile section */
|
/* Begin PBXBuildFile section */
|
||||||
266B06B816F3A60A004ED264 /* VariadicMacrosTests.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 266B06B616F3A60A004ED264 /* VariadicMacrosTests.cpp */; };
|
266B06B816F3A60A004ED264 /* VariadicMacrosTests.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 266B06B616F3A60A004ED264 /* VariadicMacrosTests.cpp */; };
|
||||||
266E9AD617290E8E0061DAB2 /* CmdLineTests.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 266E9AD417290E8E0061DAB2 /* CmdLineTests.cpp */; };
|
|
||||||
266ECD74170F3C620030D735 /* BDDTests.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 266ECD73170F3C620030D735 /* BDDTests.cpp */; };
|
266ECD74170F3C620030D735 /* BDDTests.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 266ECD73170F3C620030D735 /* BDDTests.cpp */; };
|
||||||
26847E5F16BBADB40043B9C1 /* catch_message.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 26847E5D16BBADB40043B9C1 /* catch_message.cpp */; };
|
26847E5F16BBADB40043B9C1 /* catch_message.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 26847E5D16BBADB40043B9C1 /* catch_message.cpp */; };
|
||||||
26948286179A9AB900ED166E /* SectionTrackerTests.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 26948284179A9AB900ED166E /* SectionTrackerTests.cpp */; };
|
26948286179A9AB900ED166E /* SectionTrackerTests.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 26948284179A9AB900ED166E /* SectionTrackerTests.cpp */; };
|
||||||
@ -68,7 +67,6 @@
|
|||||||
263FD06117AF8DF200988A20 /* catch_timer.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = catch_timer.h; sourceTree = "<group>"; };
|
263FD06117AF8DF200988A20 /* catch_timer.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = catch_timer.h; sourceTree = "<group>"; };
|
||||||
266B06B616F3A60A004ED264 /* VariadicMacrosTests.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = VariadicMacrosTests.cpp; path = ../../../SelfTest/VariadicMacrosTests.cpp; sourceTree = "<group>"; };
|
266B06B616F3A60A004ED264 /* VariadicMacrosTests.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = VariadicMacrosTests.cpp; path = ../../../SelfTest/VariadicMacrosTests.cpp; sourceTree = "<group>"; };
|
||||||
266E9AD117230ACF0061DAB2 /* catch_text.hpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.h; path = catch_text.hpp; sourceTree = "<group>"; };
|
266E9AD117230ACF0061DAB2 /* catch_text.hpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.h; path = catch_text.hpp; sourceTree = "<group>"; };
|
||||||
266E9AD417290E8E0061DAB2 /* CmdLineTests.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = CmdLineTests.cpp; path = ../../../SelfTest/CmdLineTests.cpp; sourceTree = "<group>"; };
|
|
||||||
266ECD73170F3C620030D735 /* BDDTests.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = BDDTests.cpp; path = ../../../SelfTest/BDDTests.cpp; sourceTree = "<group>"; };
|
266ECD73170F3C620030D735 /* BDDTests.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = BDDTests.cpp; path = ../../../SelfTest/BDDTests.cpp; sourceTree = "<group>"; };
|
||||||
266ECD8C1713614B0030D735 /* catch_legacy_reporter_adapter.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = catch_legacy_reporter_adapter.hpp; sourceTree = "<group>"; };
|
266ECD8C1713614B0030D735 /* catch_legacy_reporter_adapter.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = catch_legacy_reporter_adapter.hpp; sourceTree = "<group>"; };
|
||||||
266ECD8D1713614B0030D735 /* catch_legacy_reporter_adapter.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = catch_legacy_reporter_adapter.h; sourceTree = "<group>"; };
|
266ECD8D1713614B0030D735 /* catch_legacy_reporter_adapter.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = catch_legacy_reporter_adapter.h; sourceTree = "<group>"; };
|
||||||
@ -193,7 +191,6 @@
|
|||||||
266E9AD317290E710061DAB2 /* Introspective Tests */ = {
|
266E9AD317290E710061DAB2 /* Introspective Tests */ = {
|
||||||
isa = PBXGroup;
|
isa = PBXGroup;
|
||||||
children = (
|
children = (
|
||||||
266E9AD417290E8E0061DAB2 /* CmdLineTests.cpp */,
|
|
||||||
26948284179A9AB900ED166E /* SectionTrackerTests.cpp */,
|
26948284179A9AB900ED166E /* SectionTrackerTests.cpp */,
|
||||||
);
|
);
|
||||||
name = "Introspective Tests";
|
name = "Introspective Tests";
|
||||||
@ -535,7 +532,6 @@
|
|||||||
26847E5F16BBADB40043B9C1 /* catch_message.cpp in Sources */,
|
26847E5F16BBADB40043B9C1 /* catch_message.cpp in Sources */,
|
||||||
266B06B816F3A60A004ED264 /* VariadicMacrosTests.cpp in Sources */,
|
266B06B816F3A60A004ED264 /* VariadicMacrosTests.cpp in Sources */,
|
||||||
266ECD74170F3C620030D735 /* BDDTests.cpp in Sources */,
|
266ECD74170F3C620030D735 /* BDDTests.cpp in Sources */,
|
||||||
266E9AD617290E8E0061DAB2 /* CmdLineTests.cpp in Sources */,
|
|
||||||
26948286179A9AB900ED166E /* SectionTrackerTests.cpp in Sources */,
|
26948286179A9AB900ED166E /* SectionTrackerTests.cpp in Sources */,
|
||||||
);
|
);
|
||||||
runOnlyForDeploymentPostprocessing = 0;
|
runOnlyForDeploymentPostprocessing = 0;
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
/*
|
/*
|
||||||
* CATCH v1.0 build 27 (master branch)
|
* CATCH v1.0 build 30 (master branch)
|
||||||
* Generated: 2014-03-05 09:23:26.023000
|
* Generated: 2014-03-10 11:19:55.332000
|
||||||
* ----------------------------------------------------------
|
* ----------------------------------------------------------
|
||||||
* This file has been merged from multiple headers. Please don't edit it directly
|
* This file has been merged from multiple headers. Please don't edit it directly
|
||||||
* Copyright (c) 2012 Two Blue Cubes Ltd. All rights reserved.
|
* Copyright (c) 2012 Two Blue Cubes Ltd. All rights reserved.
|
||||||
@ -21,6 +21,14 @@
|
|||||||
#pragma clang diagnostic ignored "-Wpadded"
|
#pragma clang diagnostic ignored "-Wpadded"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#ifdef CATCH_CONFIG_MAIN
|
||||||
|
# define CATCH_CONFIG_RUNNER
|
||||||
|
# ifndef CLARA_CONFIG_MAIN
|
||||||
|
# define CLARA_CONFIG_MAIN_NOT_DEFINED
|
||||||
|
# define CLARA_CONFIG_MAIN
|
||||||
|
# endif
|
||||||
|
#endif
|
||||||
|
|
||||||
#if (_MANAGED == 1) || (_M_CEE == 1) // detect CLR
|
#if (_MANAGED == 1) || (_M_CEE == 1) // detect CLR
|
||||||
#define INTERNAL_CATCH_VS_MANAGED
|
#define INTERNAL_CATCH_VS_MANAGED
|
||||||
#else
|
#else
|
||||||
@ -35,6 +43,13 @@
|
|||||||
|
|
||||||
#endif // detect CLR
|
#endif // detect CLR
|
||||||
|
|
||||||
|
#if defined(INTERNAL_CATCH_VS_MANAGED) || defined(INTERNAL_CATCH_VS_NATIVE)
|
||||||
|
#define INTERNAL_CATCH_INLINE inline
|
||||||
|
#define CATCH_CONFIG_RUNNER (1)
|
||||||
|
#else
|
||||||
|
#define INTERNAL_CATCH_INLINE
|
||||||
|
#endif
|
||||||
|
|
||||||
// #included from: internal/catch_notimplemented_exception.h
|
// #included from: internal/catch_notimplemented_exception.h
|
||||||
#define TWOBLUECUBES_CATCH_NOTIMPLEMENTED_EXCEPTION_H_INCLUDED
|
#define TWOBLUECUBES_CATCH_NOTIMPLEMENTED_EXCEPTION_H_INCLUDED
|
||||||
|
|
||||||
@ -4138,14 +4153,7 @@ return @ desc; \
|
|||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if defined(INTERNAL_CATCH_VS_MANAGED) || defined(INTERNAL_CATCH_VS_NATIVE)
|
#ifdef CATCH_CONFIG_RUNNER
|
||||||
#define INTERNAL_CATCH_INLINE inline
|
|
||||||
#define CATCH_CONFIG_RUNNER (1)
|
|
||||||
#else
|
|
||||||
#define INTERNAL_CATCH_INLINE
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#if defined( CATCH_CONFIG_MAIN ) || defined( CATCH_CONFIG_RUNNER )
|
|
||||||
// #included from: internal/catch_impl.hpp
|
// #included from: internal/catch_impl.hpp
|
||||||
#define TWOBLUECUBES_CATCH_IMPL_HPP_INCLUDED
|
#define TWOBLUECUBES_CATCH_IMPL_HPP_INCLUDED
|
||||||
|
|
||||||
@ -4326,18 +4334,29 @@ namespace Catch {
|
|||||||
// #included from: catch_clara.h
|
// #included from: catch_clara.h
|
||||||
#define TWOBLUECUBES_CATCH_CLARA_H_INCLUDED
|
#define TWOBLUECUBES_CATCH_CLARA_H_INCLUDED
|
||||||
|
|
||||||
|
// Use Catch's value for console width (store Clara's off to the side, if present)
|
||||||
|
#ifdef CLARA_CONFIG_CONSOLE_WIDTH
|
||||||
|
#define CATCH_TEMP_CLARA_CONFIG_CONSOLE_WIDTH CLARA_CONFIG_CONSOLE_WIDTH
|
||||||
|
#undef CLARA_CONFIG_CONSOLE_WIDTH
|
||||||
|
#endif
|
||||||
#define CLARA_CONFIG_CONSOLE_WIDTH CATCH_CONFIG_CONSOLE_WIDTH
|
#define CLARA_CONFIG_CONSOLE_WIDTH CATCH_CONFIG_CONSOLE_WIDTH
|
||||||
|
|
||||||
// Declare Clara inside the Catch namespace
|
// Declare Clara inside the Catch namespace
|
||||||
#define STITCH_CLARA_OUTER_NAMESPACE Catch
|
#define STITCH_CLARA_OPEN_NAMESPACE namespace Catch {
|
||||||
// #included from: clara.h
|
// #included from: clara.h
|
||||||
|
|
||||||
// Only use header guard if we are not using an outer namespace
|
// Only use header guard if we are not using an outer namespace
|
||||||
#if !defined(TWOBLUECUBES_CLARA_H_INCLUDED) || defined(STITCH_CLARA_OUTER_NAMESPACE)
|
#if !defined(TWOBLUECUBES_CLARA_H_INCLUDED) || defined(STITCH_CLARA_OPEN_NAMESPACE)
|
||||||
#ifndef STITCH_CLARA_OUTER_NAMESPACE
|
|
||||||
#define TWOBLUECUBES_CLARA_H_INCLUDED
|
|
||||||
|
|
||||||
#define STITCH_TBC_TEXT_FORMAT_OUTER_NAMESPACE Clara
|
#ifndef STITCH_CLARA_OPEN_NAMESPACE
|
||||||
|
#define TWOBLUECUBES_CLARA_H_INCLUDED
|
||||||
|
#define STITCH_CLARA_OPEN_NAMESPACE
|
||||||
|
#define STITCH_CLARA_CLOSE_NAMESPACE
|
||||||
|
#else
|
||||||
|
#define STITCH_CLARA_CLOSE_NAMESPACE }
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#define STITCH_TBC_TEXT_FORMAT_OPEN_NAMESPACE STITCH_CLARA_OPEN_NAMESPACE
|
||||||
|
|
||||||
// ----------- #included from tbc_text_format.h -----------
|
// ----------- #included from tbc_text_format.h -----------
|
||||||
|
|
||||||
@ -4486,9 +4505,7 @@ namespace Tbc {
|
|||||||
// ----------- end of #include from tbc_text_format.h -----------
|
// ----------- end of #include from tbc_text_format.h -----------
|
||||||
// ........... back in /Users/philnash/Dev/OSS/Clara/srcs/clara.h
|
// ........... back in /Users/philnash/Dev/OSS/Clara/srcs/clara.h
|
||||||
|
|
||||||
#endif
|
#undef STITCH_TBC_TEXT_FORMAT_OPEN_NAMESPACE
|
||||||
|
|
||||||
#undef STITCH_TBC_TEXT_FORMAT_OUTER_NAMESPACE
|
|
||||||
|
|
||||||
#include <map>
|
#include <map>
|
||||||
#include <algorithm>
|
#include <algorithm>
|
||||||
@ -4496,11 +4513,16 @@ namespace Tbc {
|
|||||||
#include <memory>
|
#include <memory>
|
||||||
|
|
||||||
// Use optional outer namespace
|
// Use optional outer namespace
|
||||||
#ifdef STITCH_CLARA_OUTER_NAMESPACE
|
#ifdef STITCH_CLARA_OPEN_NAMESPACE
|
||||||
namespace STITCH_CLARA_OUTER_NAMESPACE {
|
STITCH_CLARA_OPEN_NAMESPACE
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
namespace Clara {
|
namespace Clara {
|
||||||
|
|
||||||
|
struct UnpositionalTag {};
|
||||||
|
|
||||||
|
static const UnpositionalTag _;
|
||||||
|
|
||||||
namespace Detail {
|
namespace Detail {
|
||||||
|
|
||||||
#ifdef CLARA_CONSOLE_WIDTH
|
#ifdef CLARA_CONSOLE_WIDTH
|
||||||
@ -4511,6 +4533,10 @@ namespace Clara {
|
|||||||
|
|
||||||
using namespace Tbc;
|
using namespace Tbc;
|
||||||
|
|
||||||
|
inline bool startsWith( std::string const& str, std::string const& prefix ) {
|
||||||
|
return str.size() >= prefix.size() && str.substr( 0, prefix.size() ) == prefix;
|
||||||
|
}
|
||||||
|
|
||||||
template<typename T> struct RemoveConstRef{ typedef T type; };
|
template<typename T> struct RemoveConstRef{ typedef T type; };
|
||||||
template<typename T> struct RemoveConstRef<T&>{ typedef T type; };
|
template<typename T> struct RemoveConstRef<T&>{ typedef T type; };
|
||||||
template<typename T> struct RemoveConstRef<T const&>{ typedef T type; };
|
template<typename T> struct RemoveConstRef<T const&>{ typedef T type; };
|
||||||
@ -4560,10 +4586,11 @@ namespace Clara {
|
|||||||
template<typename ConfigT>
|
template<typename ConfigT>
|
||||||
class BoundArgFunction {
|
class BoundArgFunction {
|
||||||
public:
|
public:
|
||||||
|
BoundArgFunction() : functionObj( NULL ) {}
|
||||||
BoundArgFunction( IArgFunction<ConfigT>* _functionObj ) : functionObj( _functionObj ) {}
|
BoundArgFunction( IArgFunction<ConfigT>* _functionObj ) : functionObj( _functionObj ) {}
|
||||||
BoundArgFunction( BoundArgFunction const& other ) : functionObj( other.functionObj->clone() ) {}
|
BoundArgFunction( BoundArgFunction const& other ) : functionObj( other.functionObj ? other.functionObj->clone() : NULL ) {}
|
||||||
BoundArgFunction& operator = ( BoundArgFunction const& other ) {
|
BoundArgFunction& operator = ( BoundArgFunction const& other ) {
|
||||||
IArgFunction<ConfigT>* newFunctionObj = other.functionObj->clone();
|
IArgFunction<ConfigT>* newFunctionObj = other.functionObj ? other.functionObj->clone() : NULL;
|
||||||
delete functionObj;
|
delete functionObj;
|
||||||
functionObj = newFunctionObj;
|
functionObj = newFunctionObj;
|
||||||
return *this;
|
return *this;
|
||||||
@ -4741,6 +4768,7 @@ namespace Clara {
|
|||||||
class CommandLine {
|
class CommandLine {
|
||||||
|
|
||||||
struct Arg {
|
struct Arg {
|
||||||
|
Arg() : position( -1 ) {}
|
||||||
Arg( Detail::BoundArgFunction<ConfigT> const& _boundField ) : boundField( _boundField ), position( -1 ) {}
|
Arg( Detail::BoundArgFunction<ConfigT> const& _boundField ) : boundField( _boundField ), position( -1 ) {}
|
||||||
|
|
||||||
bool hasShortName( std::string const& shortName ) const {
|
bool hasShortName( std::string const& shortName ) const {
|
||||||
@ -4756,7 +4784,7 @@ namespace Clara {
|
|||||||
return _longName == longName;
|
return _longName == longName;
|
||||||
}
|
}
|
||||||
bool takesArg() const {
|
bool takesArg() const {
|
||||||
return !hint.empty();
|
return !placeholder.empty();
|
||||||
}
|
}
|
||||||
bool isFixedPositional() const {
|
bool isFixedPositional() const {
|
||||||
return position != -1;
|
return position != -1;
|
||||||
@ -4773,7 +4801,7 @@ namespace Clara {
|
|||||||
}
|
}
|
||||||
void validate() const {
|
void validate() const {
|
||||||
if( boundField.takesArg() && !takesArg() )
|
if( boundField.takesArg() && !takesArg() )
|
||||||
throw std::logic_error( "command line argument '" + dbgName() + "' must specify a hint" );
|
throw std::logic_error( "command line argument '" + dbgName() + "' must specify a placeholder" );
|
||||||
}
|
}
|
||||||
std::string commands() const {
|
std::string commands() const {
|
||||||
std::ostringstream oss;
|
std::ostringstream oss;
|
||||||
@ -4791,8 +4819,8 @@ namespace Clara {
|
|||||||
oss << ", ";
|
oss << ", ";
|
||||||
oss << "--" << longName;
|
oss << "--" << longName;
|
||||||
}
|
}
|
||||||
if( !hint.empty() )
|
if( !placeholder.empty() )
|
||||||
oss << " <" << hint << ">";
|
oss << " <" << placeholder << ">";
|
||||||
return oss.str();
|
return oss.str();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -4800,7 +4828,7 @@ namespace Clara {
|
|||||||
std::vector<std::string> shortNames;
|
std::vector<std::string> shortNames;
|
||||||
std::string longName;
|
std::string longName;
|
||||||
std::string description;
|
std::string description;
|
||||||
std::string hint;
|
std::string placeholder;
|
||||||
int position;
|
int position;
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -4811,14 +4839,13 @@ namespace Clara {
|
|||||||
typedef std::auto_ptr<Arg> ArgAutoPtr;
|
typedef std::auto_ptr<Arg> ArgAutoPtr;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
class ArgBinder {
|
class ArgBuilder {
|
||||||
public:
|
public:
|
||||||
template<typename F>
|
ArgBuilder( CommandLine* cl )
|
||||||
ArgBinder( CommandLine* cl, F f )
|
: m_cl( cl )
|
||||||
: m_cl( cl ),
|
|
||||||
m_arg( Detail::makeBoundField( f ) )
|
|
||||||
{}
|
{}
|
||||||
ArgBinder( ArgBinder& other )
|
|
||||||
|
ArgBuilder( ArgBuilder& other )
|
||||||
: m_cl( other.m_cl ),
|
: m_cl( other.m_cl ),
|
||||||
m_arg( other.m_arg )
|
m_arg( other.m_arg )
|
||||||
{
|
{
|
||||||
@ -4826,7 +4853,7 @@ namespace Clara {
|
|||||||
}
|
}
|
||||||
// !TBD: Need to include workarounds to be able to declare this
|
// !TBD: Need to include workarounds to be able to declare this
|
||||||
// destructor as able to throw exceptions
|
// destructor as able to throw exceptions
|
||||||
~ArgBinder() /* noexcept(false) */ {
|
~ArgBuilder() /* noexcept(false) */ {
|
||||||
if( m_cl && !std::uncaught_exception() ) {
|
if( m_cl && !std::uncaught_exception() ) {
|
||||||
m_arg.validate();
|
m_arg.validate();
|
||||||
if( m_arg.isFixedPositional() ) {
|
if( m_arg.isFixedPositional() ) {
|
||||||
@ -4843,30 +4870,65 @@ namespace Clara {
|
|||||||
m_cl->m_options.push_back( m_arg );
|
m_cl->m_options.push_back( m_arg );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
ArgBinder& shortOpt( std::string const& name ) {
|
|
||||||
m_arg.shortNames.push_back( name );
|
template<typename F>
|
||||||
|
void into( F f )
|
||||||
|
{
|
||||||
|
m_arg.boundField = Detail::makeBoundField( f );
|
||||||
|
}
|
||||||
|
|
||||||
|
friend void addOptName( ArgBuilder& builder, std::string const& optName )
|
||||||
|
{
|
||||||
|
if( optName.empty() )
|
||||||
|
return;
|
||||||
|
if( Detail::startsWith( optName, "--" ) ) {
|
||||||
|
if( !builder.m_arg.longName.empty() )
|
||||||
|
throw std::logic_error( "Only one long opt may be specified. '"
|
||||||
|
+ builder.m_arg.longName
|
||||||
|
+ "' already specified, now attempting to add '"
|
||||||
|
+ optName + "'" );
|
||||||
|
builder.m_arg.longName = optName.substr( 2 );
|
||||||
|
}
|
||||||
|
else if( Detail::startsWith( optName, "-" ) )
|
||||||
|
builder.m_arg.shortNames.push_back( optName.substr( 1 ) );
|
||||||
|
else
|
||||||
|
throw std::logic_error( "option must begin with - or --. Option was: '" + optName + "'" );
|
||||||
|
}
|
||||||
|
friend void setPositionalArg( ArgBuilder& builder, int position )
|
||||||
|
{
|
||||||
|
builder.m_arg.position = position;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Can only supply placeholder after [str] - if it takes an arg
|
||||||
|
ArgBuilder& placeholder( std::string const& placeholder ) {
|
||||||
|
m_arg.placeholder = placeholder;
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
ArgBinder& longOpt( std::string const& name ) {
|
|
||||||
m_arg.longName = name;
|
ArgBuilder& describe( std::string const& description ) {
|
||||||
return *this;
|
|
||||||
}
|
|
||||||
ArgBinder& describe( std::string const& description ) {
|
|
||||||
m_arg.description = description;
|
m_arg.description = description;
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
ArgBinder& hint( std::string const& hint ) {
|
ArgBuilder& detail( std::string const& ) {
|
||||||
m_arg.hint = hint;
|
// m_arg.description = description;
|
||||||
return *this;
|
// !TBD
|
||||||
}
|
|
||||||
ArgBinder& position( int position ) {
|
|
||||||
m_arg.position = position;
|
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
CommandLine* m_cl;
|
CommandLine* m_cl;
|
||||||
Arg m_arg;
|
Arg m_arg;
|
||||||
};
|
};
|
||||||
|
class OptBuilder : public ArgBuilder {
|
||||||
|
public:
|
||||||
|
OptBuilder( CommandLine* cl ) : ArgBuilder( cl ) {}
|
||||||
|
OptBuilder( OptBuilder& other ) : ArgBuilder( other ) {}
|
||||||
|
|
||||||
|
OptBuilder& operator[]( std::string const& optName ) {
|
||||||
|
addOptName( *this, optName );
|
||||||
|
return *this;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
@ -4891,11 +4953,24 @@ namespace Clara {
|
|||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
|
|
||||||
template<typename F>
|
OptBuilder operator[]( std::string const& optName ) {
|
||||||
ArgBinder bind( F f ) {
|
OptBuilder builder( this );
|
||||||
ArgBinder binder( this, f );
|
addOptName( builder, optName );
|
||||||
return binder;
|
return builder;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ArgBuilder operator[]( int position ) {
|
||||||
|
ArgBuilder builder( this );
|
||||||
|
setPositionalArg( builder, position );
|
||||||
|
return builder;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Invoke this with the _ instance
|
||||||
|
ArgBuilder operator[]( UnpositionalTag ) {
|
||||||
|
ArgBuilder builder( this );
|
||||||
|
return builder;
|
||||||
|
}
|
||||||
|
|
||||||
template<typename F>
|
template<typename F>
|
||||||
void bindProcessName( F f ) {
|
void bindProcessName( F f ) {
|
||||||
m_boundProcessName = Detail::makeBoundField( f );
|
m_boundProcessName = Detail::makeBoundField( f );
|
||||||
@ -4938,9 +5013,9 @@ namespace Clara {
|
|||||||
os << " ";
|
os << " ";
|
||||||
typename std::map<int, Arg>::const_iterator it = m_positionalArgs.find( i );
|
typename std::map<int, Arg>::const_iterator it = m_positionalArgs.find( i );
|
||||||
if( it != m_positionalArgs.end() )
|
if( it != m_positionalArgs.end() )
|
||||||
os << "<" << it->second.hint << ">";
|
os << "<" << it->second.placeholder << ">";
|
||||||
else if( m_arg.get() )
|
else if( m_arg.get() )
|
||||||
os << "<" << m_arg->hint << ">";
|
os << "<" << m_arg->placeholder << ">";
|
||||||
else
|
else
|
||||||
throw std::logic_error( "non consecutive positional arguments with no floating args" );
|
throw std::logic_error( "non consecutive positional arguments with no floating args" );
|
||||||
}
|
}
|
||||||
@ -4948,7 +5023,7 @@ namespace Clara {
|
|||||||
if( m_arg.get() ) {
|
if( m_arg.get() ) {
|
||||||
if( m_highestSpecifiedArgPosition > 1 )
|
if( m_highestSpecifiedArgPosition > 1 )
|
||||||
os << " ";
|
os << " ";
|
||||||
os << "[<" << m_arg->hint << "> ...]";
|
os << "[<" << m_arg->placeholder << "> ...]";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
std::string argSynopsis() const {
|
std::string argSynopsis() const {
|
||||||
@ -5088,12 +5163,18 @@ namespace Clara {
|
|||||||
|
|
||||||
} // end namespace Clara
|
} // end namespace Clara
|
||||||
|
|
||||||
#ifdef STITCH_CLARA_OUTER_NAMESPACE
|
STITCH_CLARA_CLOSE_NAMESPACE
|
||||||
} // end outer namespace
|
#undef STITCH_CLARA_OPEN_NAMESPACE
|
||||||
#endif
|
#undef STITCH_CLARA_CLOSE_NAMESPACE
|
||||||
|
|
||||||
#endif // TWOBLUECUBES_CLARA_H_INCLUDED
|
#endif // TWOBLUECUBES_CLARA_H_INCLUDED
|
||||||
#undef STITCH_CLARA_OUTER_NAMESPACE
|
#undef STITCH_CLARA_OPEN_NAMESPACE
|
||||||
|
|
||||||
|
// Restore Clara's value for console width, if present
|
||||||
|
#ifdef CATCH_TEMP_CLARA_CONFIG_CONSOLE_WIDTH
|
||||||
|
#define CLARA_CONFIG_CONSOLE_WIDTH CATCH_TEMP_CLARA_CONFIG_CONSOLE_WIDTH
|
||||||
|
#undef CATCH_TEMP_CLARA_CONFIG_CONSOLE_WIDTH
|
||||||
|
#endif
|
||||||
|
|
||||||
#include <fstream>
|
#include <fstream>
|
||||||
|
|
||||||
@ -5138,107 +5219,95 @@ namespace Catch {
|
|||||||
|
|
||||||
inline Clara::CommandLine<ConfigData> makeCommandLineParser() {
|
inline Clara::CommandLine<ConfigData> makeCommandLineParser() {
|
||||||
|
|
||||||
Clara::CommandLine<ConfigData> cli;
|
using namespace Clara;
|
||||||
|
CommandLine<ConfigData> cli;
|
||||||
|
|
||||||
cli.bindProcessName( &ConfigData::processName );
|
cli.bindProcessName( &ConfigData::processName );
|
||||||
|
|
||||||
cli.bind( &ConfigData::showHelp )
|
cli["-?"]["-h"]["--help"]
|
||||||
.describe( "display usage information" )
|
.describe( "display usage information" )
|
||||||
.shortOpt( "?")
|
.into( &ConfigData::showHelp );
|
||||||
.shortOpt( "h")
|
|
||||||
.longOpt( "help" );
|
|
||||||
|
|
||||||
cli.bind( &ConfigData::listTests )
|
cli["-l"]["--list-tests"]
|
||||||
.describe( "list all/matching test cases" )
|
.describe( "list all/matching test cases" )
|
||||||
.shortOpt( "l")
|
.into( &ConfigData::listTests );
|
||||||
.longOpt( "list-tests" );
|
|
||||||
|
|
||||||
cli.bind( &ConfigData::listTags )
|
cli["-t"]["--list-tags"]
|
||||||
.describe( "list all/matching tags" )
|
.describe( "list all/matching tags" )
|
||||||
.shortOpt( "t")
|
.into( &ConfigData::listTags );
|
||||||
.longOpt( "list-tags" );
|
|
||||||
|
|
||||||
cli.bind( &ConfigData::showSuccessfulTests )
|
cli["-s"]["--success"]
|
||||||
.describe( "include successful tests in output" )
|
.describe( "include successful tests in output" )
|
||||||
.shortOpt( "s")
|
.into( &ConfigData::showSuccessfulTests );
|
||||||
.longOpt( "success" );
|
|
||||||
|
|
||||||
cli.bind( &ConfigData::shouldDebugBreak )
|
cli["-b"]["--break"]
|
||||||
.describe( "break into debugger on failure" )
|
.describe( "break into debugger on failure" )
|
||||||
.shortOpt( "b")
|
.into( &ConfigData::shouldDebugBreak );
|
||||||
.longOpt( "break" );
|
|
||||||
|
|
||||||
cli.bind( &ConfigData::noThrow )
|
cli["-e"]["--nothrow"]
|
||||||
.describe( "skip exception tests" )
|
.describe( "skip exception tests" )
|
||||||
.shortOpt( "e")
|
.into( &ConfigData::noThrow );
|
||||||
.longOpt( "nothrow" );
|
|
||||||
|
|
||||||
cli.bind( &ConfigData::outputFilename )
|
cli["-o"]["--out"]
|
||||||
|
.placeholder( "filename" )
|
||||||
.describe( "output filename" )
|
.describe( "output filename" )
|
||||||
.shortOpt( "o")
|
.into( &ConfigData::outputFilename );
|
||||||
.longOpt( "out" )
|
|
||||||
.hint( "filename" );
|
|
||||||
|
|
||||||
cli.bind( &ConfigData::reporterName )
|
cli["-r"]["--reporter"]
|
||||||
|
// .placeholder( "name[:filename]" )
|
||||||
|
.placeholder( "name" )
|
||||||
.describe( "reporter to use (defaults to console)" )
|
.describe( "reporter to use (defaults to console)" )
|
||||||
.shortOpt( "r")
|
.into( &ConfigData::reporterName );
|
||||||
.longOpt( "reporter" )
|
|
||||||
// .hint( "name[:filename]" );
|
|
||||||
.hint( "name" );
|
|
||||||
|
|
||||||
cli.bind( &ConfigData::name )
|
cli["-n"]["--name"]
|
||||||
|
.placeholder( "name" )
|
||||||
.describe( "suite name" )
|
.describe( "suite name" )
|
||||||
.shortOpt( "n")
|
.into( &ConfigData::name );
|
||||||
.longOpt( "name" )
|
|
||||||
.hint( "name" );
|
|
||||||
|
|
||||||
cli.bind( &abortAfterFirst )
|
cli["-a"]["--abort"]
|
||||||
.describe( "abort at first failure" )
|
.describe( "abort at first failure" )
|
||||||
.shortOpt( "a")
|
.into( &abortAfterFirst );
|
||||||
.longOpt( "abort" );
|
|
||||||
|
|
||||||
cli.bind( &abortAfterX )
|
cli["-x"]["--abortx"]
|
||||||
|
.placeholder( "number of failures" )
|
||||||
.describe( "abort after x failures" )
|
.describe( "abort after x failures" )
|
||||||
.shortOpt( "x")
|
.into( &abortAfterX );
|
||||||
.longOpt( "abortx" )
|
|
||||||
.hint( "number of failures" );
|
|
||||||
|
|
||||||
cli.bind( &addWarning )
|
cli["-w"]["--warn"]
|
||||||
|
.placeholder( "warning name" )
|
||||||
.describe( "enable warnings" )
|
.describe( "enable warnings" )
|
||||||
.shortOpt( "w")
|
.into( &addWarning );
|
||||||
.longOpt( "warn" )
|
|
||||||
.hint( "warning name" );
|
|
||||||
|
|
||||||
// cli.bind( &setVerbosity )
|
// - needs updating if reinstated
|
||||||
|
// cli.into( &setVerbosity )
|
||||||
// .describe( "level of verbosity (0=no output)" )
|
// .describe( "level of verbosity (0=no output)" )
|
||||||
// .shortOpt( "v")
|
// .shortOpt( "v")
|
||||||
// .longOpt( "verbosity" )
|
// .longOpt( "verbosity" )
|
||||||
// .hint( "level" );
|
// .placeholder( "level" );
|
||||||
|
|
||||||
cli.bind( &addTestOrTags )
|
cli[_]
|
||||||
|
.placeholder( "test name, pattern or tags" )
|
||||||
.describe( "which test or tests to use" )
|
.describe( "which test or tests to use" )
|
||||||
.hint( "test name, pattern or tags" );
|
.into( &addTestOrTags );
|
||||||
|
|
||||||
cli.bind( &setShowDurations )
|
cli["-d"]["--durations"]
|
||||||
|
.placeholder( "yes/no" )
|
||||||
.describe( "show test durations" )
|
.describe( "show test durations" )
|
||||||
.shortOpt( "d")
|
.into( &setShowDurations );
|
||||||
.longOpt( "durations" )
|
|
||||||
.hint( "yes/no" );
|
|
||||||
|
|
||||||
cli.bind( &loadTestNamesFromFile )
|
cli["-f"]["--input-file"]
|
||||||
|
.placeholder( "filename" )
|
||||||
.describe( "load test names to run from a file" )
|
.describe( "load test names to run from a file" )
|
||||||
.shortOpt( "f")
|
.into( &loadTestNamesFromFile );
|
||||||
.longOpt( "input-file" )
|
|
||||||
.hint( "filename" );
|
|
||||||
|
|
||||||
// Less common commands which don't have a short form
|
// Less common commands which don't have a short form
|
||||||
cli.bind( &ConfigData::listTestNamesOnly )
|
cli["--list-test-names-only"]
|
||||||
.describe( "list all/matching test cases names only" )
|
.describe( "list all/matching test cases names only" )
|
||||||
.longOpt( "list-test-names-only" );
|
.into( &ConfigData::listTestNamesOnly );
|
||||||
|
|
||||||
cli.bind( &ConfigData::listReporters )
|
cli["--list-reporters"]
|
||||||
.describe( "list all reporters" )
|
.describe( "list all reporters" )
|
||||||
.longOpt( "list-reporters" );
|
.into( &ConfigData::listReporters );
|
||||||
|
|
||||||
return cli;
|
return cli;
|
||||||
}
|
}
|
||||||
@ -7490,7 +7559,7 @@ namespace Catch {
|
|||||||
|
|
||||||
// These numbers are maintained by a script
|
// These numbers are maintained by a script
|
||||||
template <typename T>
|
template <typename T>
|
||||||
const T LibraryVersionInfo<T>::value( 1, 0, 27, "master" );
|
const T LibraryVersionInfo<T>::value( 1, 0, 30, "master" );
|
||||||
}
|
}
|
||||||
|
|
||||||
// #included from: catch_message.hpp
|
// #included from: catch_message.hpp
|
||||||
@ -9188,7 +9257,7 @@ namespace Catch {
|
|||||||
#pragma clang diagnostic pop
|
#pragma clang diagnostic pop
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#endif // CATCH_CONFIG_MAIN || CATCH_CONFIG_RUNNER
|
#endif
|
||||||
|
|
||||||
#ifdef CATCH_CONFIG_MAIN
|
#ifdef CATCH_CONFIG_MAIN
|
||||||
// #included from: internal/catch_default_main.hpp
|
// #included from: internal/catch_default_main.hpp
|
||||||
@ -9221,7 +9290,11 @@ int main (int argc, char * const argv[]) {
|
|||||||
|
|
||||||
#endif // __OBJC__
|
#endif // __OBJC__
|
||||||
|
|
||||||
#endif // CATCH_CONFIG_MAIN
|
#endif
|
||||||
|
|
||||||
|
#ifdef CLARA_CONFIG_MAIN_NOT_DEFINED
|
||||||
|
# undef CLARA_CONFIG_MAIN
|
||||||
|
#endif
|
||||||
|
|
||||||
//////
|
//////
|
||||||
|
|
||||||
|
@ -1,192 +0,0 @@
|
|||||||
/*
|
|
||||||
* Created by Phil on 22/10/2010.
|
|
||||||
* Copyright 2010 Two Blue Cubes Ltd
|
|
||||||
*
|
|
||||||
* Distributed under the Boost Software License, Version 1.0. (See accompanying
|
|
||||||
* file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
|
|
||||||
*/
|
|
||||||
#ifdef __clang__
|
|
||||||
#pragma clang diagnostic ignored "-Wpadded"
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#include "internal/clara.h" // This will does not declare Clara within the Catch namespace
|
|
||||||
|
|
||||||
#include "catch.hpp"
|
|
||||||
|
|
||||||
|
|
||||||
// Helper to deduce size from array literals and pass on to parser
|
|
||||||
template<size_t size, typename ConfigT>
|
|
||||||
std::vector<Clara::Parser::Token> parseInto( Clara::CommandLine<ConfigT>& cli, char const * (&argv)[size], ConfigT& config ) {
|
|
||||||
return cli.parseInto( size, argv, config );
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
struct TestOpt {
|
|
||||||
TestOpt() : number( 0 ), index( 0 ), flag( false ) {}
|
|
||||||
|
|
||||||
std::string processName;
|
|
||||||
std::string fileName;
|
|
||||||
int number;
|
|
||||||
int index;
|
|
||||||
bool flag;
|
|
||||||
std::string firstPos;
|
|
||||||
std::string secondPos;
|
|
||||||
std::string unpositional;
|
|
||||||
|
|
||||||
void setValidIndex( int i ) {
|
|
||||||
if( i < 0 || i > 10 )
|
|
||||||
throw std::domain_error( "index must be between 0 and 10" );
|
|
||||||
index = i;
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
struct TestOpt2 {
|
|
||||||
std::string description;
|
|
||||||
};
|
|
||||||
|
|
||||||
#ifdef CATCH_CONFIG_VARIADIC_MACROS
|
|
||||||
|
|
||||||
TEST_CASE( "cmdline" ) {
|
|
||||||
|
|
||||||
TestOpt config;
|
|
||||||
Clara::CommandLine<TestOpt> cli;
|
|
||||||
cli.bindProcessName( &TestOpt::processName );
|
|
||||||
cli.bind( &TestOpt::fileName )
|
|
||||||
.describe( "specifies output file" )
|
|
||||||
.shortOpt( "o" )
|
|
||||||
.longOpt( "output" )
|
|
||||||
.hint( "filename" );
|
|
||||||
|
|
||||||
SECTION( "process name" ) {
|
|
||||||
char const * argv[] = { "test", "-o filename.ext" };
|
|
||||||
parseInto( cli, argv, config );
|
|
||||||
|
|
||||||
CHECK( config.processName == "test" );
|
|
||||||
}
|
|
||||||
SECTION( "arg separated by spaces" ) {
|
|
||||||
char const * argv[] = { "test", "-o filename.ext" };
|
|
||||||
parseInto( cli, argv, config );
|
|
||||||
|
|
||||||
CHECK( config.fileName == "filename.ext" );
|
|
||||||
}
|
|
||||||
SECTION( "arg separated by colon" ) {
|
|
||||||
const char* argv[] = { "test", "-o:filename.ext" };
|
|
||||||
parseInto( cli, argv, config );
|
|
||||||
|
|
||||||
CHECK( config.fileName == "filename.ext" );
|
|
||||||
}
|
|
||||||
SECTION( "arg separated by =" ) {
|
|
||||||
const char* argv[] = { "test", "-o=filename.ext" };
|
|
||||||
parseInto( cli, argv, config );
|
|
||||||
|
|
||||||
CHECK( config.fileName == "filename.ext" );
|
|
||||||
}
|
|
||||||
SECTION( "long opt" ) {
|
|
||||||
const char* argv[] = { "test", "--output %stdout" };
|
|
||||||
parseInto( cli, argv, config );
|
|
||||||
|
|
||||||
CHECK( config.fileName == "%stdout" );
|
|
||||||
}
|
|
||||||
|
|
||||||
cli.bind( &TestOpt::number )
|
|
||||||
.shortOpt( "n" )
|
|
||||||
.hint( "an integral value" );
|
|
||||||
|
|
||||||
SECTION( "a number" ) {
|
|
||||||
const char* argv[] = { "test", "-n 42" };
|
|
||||||
parseInto( cli, argv, config );
|
|
||||||
|
|
||||||
CHECK( config.number == 42 );
|
|
||||||
}
|
|
||||||
SECTION( "not a number" ) {
|
|
||||||
const char* argv[] = { "test", "-n forty-two" };
|
|
||||||
CHECK_THROWS( parseInto( cli, argv, config ) );
|
|
||||||
|
|
||||||
CHECK( config.number == 0 );
|
|
||||||
}
|
|
||||||
|
|
||||||
SECTION( "two parsers" ) {
|
|
||||||
|
|
||||||
TestOpt config1;
|
|
||||||
TestOpt2 config2;
|
|
||||||
Clara::CommandLine<TestOpt2> cli2;
|
|
||||||
|
|
||||||
cli2.bind( &TestOpt2::description )
|
|
||||||
.describe( "description" )
|
|
||||||
.shortOpt( "d" )
|
|
||||||
.longOpt( "description" )
|
|
||||||
.hint( "some text" );
|
|
||||||
|
|
||||||
const char* argv[] = { "test", "-n 42", "-d some text" };
|
|
||||||
std::vector<Clara::Parser::Token> unusedTokens = parseInto( cli, argv, config1 );
|
|
||||||
|
|
||||||
CHECK( config1.number == 42 );
|
|
||||||
|
|
||||||
REQUIRE_FALSE( unusedTokens.empty() );
|
|
||||||
cli2.populate( unusedTokens, config2 );
|
|
||||||
CHECK( config2.description == "some text" );
|
|
||||||
}
|
|
||||||
|
|
||||||
SECTION( "methods" ) {
|
|
||||||
cli.bind( &TestOpt::setValidIndex )
|
|
||||||
.describe( "An index, which is an integer between 0 and 10, inclusive" )
|
|
||||||
.shortOpt( "i" )
|
|
||||||
.hint( "index" );
|
|
||||||
|
|
||||||
SECTION( "in range" ) {
|
|
||||||
const char* argv[] = { "test", "-i 3" };
|
|
||||||
parseInto( cli, argv, config );
|
|
||||||
|
|
||||||
REQUIRE( config.index == 3 );
|
|
||||||
}
|
|
||||||
SECTION( "out of range" ) {
|
|
||||||
const char* argv[] = { "test", "-i 42" };
|
|
||||||
|
|
||||||
REQUIRE_THROWS( parseInto( cli, argv, config ) );
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
SECTION( "flags" ) {
|
|
||||||
cli.bind( &TestOpt::flag )
|
|
||||||
.describe( "A flag" )
|
|
||||||
.shortOpt( "f" );
|
|
||||||
|
|
||||||
SECTION( "set" ) {
|
|
||||||
const char* argv[] = { "test", "-f" };
|
|
||||||
parseInto( cli, argv, config );
|
|
||||||
|
|
||||||
REQUIRE( config.flag );
|
|
||||||
}
|
|
||||||
SECTION( "not set" ) {
|
|
||||||
const char* argv[] = { "test" };
|
|
||||||
parseInto( cli, argv, config );
|
|
||||||
|
|
||||||
REQUIRE( config.flag == false );
|
|
||||||
}
|
|
||||||
}
|
|
||||||
SECTION( "positional" ) {
|
|
||||||
cli.bind( &TestOpt::secondPos )
|
|
||||||
.describe( "Second position" )
|
|
||||||
.hint( "second arg" )
|
|
||||||
.position( 2 );
|
|
||||||
cli.bind( &TestOpt::unpositional )
|
|
||||||
.hint( "any arg" )
|
|
||||||
.describe( "Unpositional" );
|
|
||||||
cli.bind( &TestOpt::firstPos )
|
|
||||||
.describe( "First position" )
|
|
||||||
.hint( "first arg" )
|
|
||||||
.position( 1 );
|
|
||||||
|
|
||||||
// std::cout << cli.usage( "testApp" ) << std::endl;
|
|
||||||
|
|
||||||
const char* argv[] = { "test", "-f", "1st", "-o", "filename", "2nd", "3rd" };
|
|
||||||
parseInto( cli, argv, config );
|
|
||||||
|
|
||||||
REQUIRE( config.firstPos == "1st" );
|
|
||||||
REQUIRE( config.secondPos == "2nd" );
|
|
||||||
REQUIRE( config.unpositional == "3rd" );
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
#endif
|
|
@ -1,7 +1,6 @@
|
|||||||
SOURCES = ApproxTests.cpp \
|
SOURCES = ApproxTests.cpp \
|
||||||
BDDTests.cpp \
|
BDDTests.cpp \
|
||||||
ClassTests.cpp \
|
ClassTests.cpp \
|
||||||
CmdLineTests.cpp \
|
|
||||||
ConditionTests.cpp \
|
ConditionTests.cpp \
|
||||||
ExceptionTests.cpp \
|
ExceptionTests.cpp \
|
||||||
GeneratorTests.cpp \
|
GeneratorTests.cpp \
|
||||||
|
@ -138,7 +138,6 @@
|
|||||||
<ClCompile Include="..\..\SelfTest\ApproxTests.cpp" />
|
<ClCompile Include="..\..\SelfTest\ApproxTests.cpp" />
|
||||||
<ClCompile Include="..\..\SelfTest\BDDTests.cpp" />
|
<ClCompile Include="..\..\SelfTest\BDDTests.cpp" />
|
||||||
<ClCompile Include="..\..\SelfTest\ClassTests.cpp" />
|
<ClCompile Include="..\..\SelfTest\ClassTests.cpp" />
|
||||||
<ClCompile Include="..\..\SelfTest\CmdLineTests.cpp" />
|
|
||||||
<ClCompile Include="..\..\SelfTest\ConditionTests.cpp" />
|
<ClCompile Include="..\..\SelfTest\ConditionTests.cpp" />
|
||||||
<ClCompile Include="..\..\SelfTest\ExceptionTests.cpp" />
|
<ClCompile Include="..\..\SelfTest\ExceptionTests.cpp" />
|
||||||
<ClCompile Include="..\..\SelfTest\GeneratorTests.cpp" />
|
<ClCompile Include="..\..\SelfTest\GeneratorTests.cpp" />
|
||||||
|
@ -30,9 +30,6 @@
|
|||||||
<ClCompile Include="..\..\SelfTest\BDDTests.cpp">
|
<ClCompile Include="..\..\SelfTest\BDDTests.cpp">
|
||||||
<Filter>Source Files</Filter>
|
<Filter>Source Files</Filter>
|
||||||
</ClCompile>
|
</ClCompile>
|
||||||
<ClCompile Include="..\..\SelfTest\CmdLineTests.cpp">
|
|
||||||
<Filter>Source Files</Filter>
|
|
||||||
</ClCompile>
|
|
||||||
<ClCompile Include="..\..\SelfTest\ConditionTests.cpp">
|
<ClCompile Include="..\..\SelfTest\ConditionTests.cpp">
|
||||||
<Filter>Source Files</Filter>
|
<Filter>Source Files</Filter>
|
||||||
</ClCompile>
|
</ClCompile>
|
||||||
|
@ -93,7 +93,6 @@
|
|||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<ClCompile Include="..\..\..\SelfTest\ApproxTests.cpp" />
|
<ClCompile Include="..\..\..\SelfTest\ApproxTests.cpp" />
|
||||||
<ClCompile Include="..\..\..\SelfTest\BDDTests.cpp" />
|
<ClCompile Include="..\..\..\SelfTest\BDDTests.cpp" />
|
||||||
<ClCompile Include="..\..\..\SelfTest\CmdLineTests.cpp" />
|
|
||||||
<ClCompile Include="..\..\..\SelfTest\SectionTrackerTests.cpp" />
|
<ClCompile Include="..\..\..\SelfTest\SectionTrackerTests.cpp" />
|
||||||
<ClCompile Include="..\..\..\SelfTest\TestMain.cpp" />
|
<ClCompile Include="..\..\..\SelfTest\TestMain.cpp" />
|
||||||
<ClCompile Include="..\..\..\SelfTest\ClassTests.cpp" />
|
<ClCompile Include="..\..\..\SelfTest\ClassTests.cpp" />
|
||||||
|
@ -13,9 +13,6 @@
|
|||||||
<ClCompile Include="..\..\..\SelfTest\MiscTests.cpp">
|
<ClCompile Include="..\..\..\SelfTest\MiscTests.cpp">
|
||||||
<Filter>Sources</Filter>
|
<Filter>Sources</Filter>
|
||||||
</ClCompile>
|
</ClCompile>
|
||||||
<ClCompile Include="..\..\..\SelfTest\CmdLineTests.cpp">
|
|
||||||
<Filter>Sources</Filter>
|
|
||||||
</ClCompile>
|
|
||||||
<ClCompile Include="..\..\..\SelfTest\ConditionTests.cpp">
|
<ClCompile Include="..\..\..\SelfTest\ConditionTests.cpp">
|
||||||
<Filter>Sources</Filter>
|
<Filter>Sources</Filter>
|
||||||
</ClCompile>
|
</ClCompile>
|
||||||
|
@ -157,7 +157,6 @@
|
|||||||
<ClCompile Include="..\..\SelfTest\ApproxTests.cpp" />
|
<ClCompile Include="..\..\SelfTest\ApproxTests.cpp" />
|
||||||
<ClCompile Include="..\..\SelfTest\BDDTests.cpp" />
|
<ClCompile Include="..\..\SelfTest\BDDTests.cpp" />
|
||||||
<ClCompile Include="..\..\SelfTest\ClassTests.cpp" />
|
<ClCompile Include="..\..\SelfTest\ClassTests.cpp" />
|
||||||
<ClCompile Include="..\..\SelfTest\CmdLineTests.cpp" />
|
|
||||||
<ClCompile Include="..\..\SelfTest\ConditionTests.cpp" />
|
<ClCompile Include="..\..\SelfTest\ConditionTests.cpp" />
|
||||||
<ClCompile Include="..\..\SelfTest\ExceptionTests.cpp" />
|
<ClCompile Include="..\..\SelfTest\ExceptionTests.cpp" />
|
||||||
<ClCompile Include="..\..\SelfTest\GeneratorTests.cpp" />
|
<ClCompile Include="..\..\SelfTest\GeneratorTests.cpp" />
|
||||||
|
@ -33,9 +33,6 @@
|
|||||||
<ClCompile Include="..\..\SelfTest\ClassTests.cpp">
|
<ClCompile Include="..\..\SelfTest\ClassTests.cpp">
|
||||||
<Filter>Source Files</Filter>
|
<Filter>Source Files</Filter>
|
||||||
</ClCompile>
|
</ClCompile>
|
||||||
<ClCompile Include="..\..\SelfTest\CmdLineTests.cpp">
|
|
||||||
<Filter>Source Files</Filter>
|
|
||||||
</ClCompile>
|
|
||||||
<ClCompile Include="..\..\SelfTest\ConditionTests.cpp">
|
<ClCompile Include="..\..\SelfTest\ConditionTests.cpp">
|
||||||
<Filter>Source Files</Filter>
|
<Filter>Source Files</Filter>
|
||||||
</ClCompile>
|
</ClCompile>
|
||||||
|
@ -153,7 +153,6 @@
|
|||||||
<ClCompile Include="..\..\SelfTest\ApproxTests.cpp" />
|
<ClCompile Include="..\..\SelfTest\ApproxTests.cpp" />
|
||||||
<ClCompile Include="..\..\SelfTest\BDDTests.cpp" />
|
<ClCompile Include="..\..\SelfTest\BDDTests.cpp" />
|
||||||
<ClCompile Include="..\..\SelfTest\ClassTests.cpp" />
|
<ClCompile Include="..\..\SelfTest\ClassTests.cpp" />
|
||||||
<ClCompile Include="..\..\SelfTest\CmdLineTests.cpp" />
|
|
||||||
<ClCompile Include="..\..\SelfTest\ConditionTests.cpp" />
|
<ClCompile Include="..\..\SelfTest\ConditionTests.cpp" />
|
||||||
<ClCompile Include="..\..\SelfTest\ExceptionTests.cpp" />
|
<ClCompile Include="..\..\SelfTest\ExceptionTests.cpp" />
|
||||||
<ClCompile Include="..\..\SelfTest\GeneratorTests.cpp" />
|
<ClCompile Include="..\..\SelfTest\GeneratorTests.cpp" />
|
||||||
|
@ -41,9 +41,6 @@
|
|||||||
<ClCompile Include="..\..\SelfTest\ClassTests.cpp">
|
<ClCompile Include="..\..\SelfTest\ClassTests.cpp">
|
||||||
<Filter>Source Files</Filter>
|
<Filter>Source Files</Filter>
|
||||||
</ClCompile>
|
</ClCompile>
|
||||||
<ClCompile Include="..\..\SelfTest\CmdLineTests.cpp">
|
|
||||||
<Filter>Source Files</Filter>
|
|
||||||
</ClCompile>
|
|
||||||
<ClCompile Include="..\..\SelfTest\ConditionTests.cpp">
|
<ClCompile Include="..\..\SelfTest\ConditionTests.cpp">
|
||||||
<Filter>Source Files</Filter>
|
<Filter>Source Files</Filter>
|
||||||
</ClCompile>
|
</ClCompile>
|
||||||
|
@ -8,6 +8,7 @@
|
|||||||
#include "targetver.h"
|
#include "targetver.h"
|
||||||
|
|
||||||
// Headers for CppUnitTest
|
// Headers for CppUnitTest
|
||||||
|
#pragma warning( disable : 4505 ) // required for including CppUnitTest.h at /W4
|
||||||
#include "CppUnitTest.h"
|
#include "CppUnitTest.h"
|
||||||
|
|
||||||
// TODO: reference additional headers your program requires here
|
// TODO: reference additional headers your program requires here
|
||||||
|
Loading…
Reference in New Issue
Block a user