From e6ee29a925e7c295dfb75332233ea4abf94bc267 Mon Sep 17 00:00:00 2001 From: David Beckley Date: Wed, 5 Mar 2014 16:46:20 -0800 Subject: [PATCH 1/7] Highlight block as C++ C++ syntax highlighting was not enabled on one of the blocks. --- docs/tutorial.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/docs/tutorial.md b/docs/tutorial.md index 2d75dab0..75a1b776 100644 --- a/docs/tutorial.md +++ b/docs/tutorial.md @@ -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: +```c++ SECTION( "reserving bigger changes capacity but not size" ) { 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 ); } } +``` 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. From b9fea75109c4d4c372067b651a2df9733b748879 Mon Sep 17 00:00:00 2001 From: Phil Nash Date: Thu, 6 Mar 2014 08:16:06 +0000 Subject: [PATCH 2/7] =?UTF-8?q?New=20version=20of=20Clara.=20-=20updated?= =?UTF-8?q?=20command=20line=20setup=20with=20new=20API=20-=20updated=20ST?= =?UTF-8?q?ITCH=20macros=20-=20force=20embedded=20Clara=20to=20use=20Catch?= =?UTF-8?q?=E2=80=99s=20console=20width=20(but=20restore=20it=20after)=20-?= =?UTF-8?q?=20remove=20command=20line=20tests=20(as=20these=20have=20now?= =?UTF-8?q?=20moved=20into=20the=20Clara=20project)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- include/internal/catch_clara.h | 16 +- include/internal/catch_commandline.hpp | 109 +++---- include/internal/clara.h | 157 +++++++--- projects/SelfTest/CmdLineTests.cpp | 192 ------------ .../CatchSelfTest.xcodeproj/project.pbxproj | 4 - single_include/catch.hpp | 276 +++++++++++------- 6 files changed, 348 insertions(+), 406 deletions(-) delete mode 100644 projects/SelfTest/CmdLineTests.cpp diff --git a/include/internal/catch_clara.h b/include/internal/catch_clara.h index a07bb624..e1f0c25a 100644 --- a/include/internal/catch_clara.h +++ b/include/internal/catch_clara.h @@ -9,12 +9,24 @@ #ifndef 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 // Declare Clara inside the Catch namespace -#define STITCH_CLARA_OUTER_NAMESPACE Catch +#define STITCH_CLARA_OPEN_NAMESPACE namespace Catch { #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 diff --git a/include/internal/catch_commandline.hpp b/include/internal/catch_commandline.hpp index ee19de85..126c861c 100644 --- a/include/internal/catch_commandline.hpp +++ b/include/internal/catch_commandline.hpp @@ -55,108 +55,95 @@ namespace Catch { inline Clara::CommandLine makeCommandLineParser() { - Clara::CommandLine cli; + using namespace Clara; + CommandLine cli; cli.bindProcessName( &ConfigData::processName ); - cli.bind( &ConfigData::showHelp ) + cli["-?"]["-h"]["--help"] .describe( "display usage information" ) - .shortOpt( "?") - .shortOpt( "h") - .longOpt( "help" ); + .into( &ConfigData::showHelp ); - cli.bind( &ConfigData::listTests ) + cli["-l"]["--list-tests"] .describe( "list all/matching test cases" ) - .shortOpt( "l") - .longOpt( "list-tests" ); + .into( &ConfigData::listTests ); - cli.bind( &ConfigData::listTags ) + cli["-t"]["--list-tags"] .describe( "list all/matching tags" ) - .shortOpt( "t") - .longOpt( "list-tags" ); + .into( &ConfigData::listTags ); - cli.bind( &ConfigData::showSuccessfulTests ) + cli["-s"]["--success"] .describe( "include successful tests in output" ) - .shortOpt( "s") - .longOpt( "success" ); + .into( &ConfigData::showSuccessfulTests ); - cli.bind( &ConfigData::shouldDebugBreak ) + cli["-b"]["--break"] .describe( "break into debugger on failure" ) - .shortOpt( "b") - .longOpt( "break" ); + .into( &ConfigData::shouldDebugBreak ); - cli.bind( &ConfigData::noThrow ) + cli["-e"]["--nothrow"] .describe( "skip exception tests" ) - .shortOpt( "e") - .longOpt( "nothrow" ); + .into( &ConfigData::noThrow ); - cli.bind( &ConfigData::outputFilename ) + cli["-o"]["--out"] + .placeholder( "filename" ) .describe( "output filename" ) - .shortOpt( "o") - .longOpt( "out" ) - .hint( "filename" ); + .into( &ConfigData::outputFilename ); - cli.bind( &ConfigData::reporterName ) + cli["-r"]["--reporter"] +// .placeholder( "name[:filename]" ) + .placeholder( "name" ) .describe( "reporter to use (defaults to console)" ) - .shortOpt( "r") - .longOpt( "reporter" ) -// .hint( "name[:filename]" ); - .hint( "name" ); + .into( &ConfigData::reporterName ); - cli.bind( &ConfigData::name ) + cli["-n"]["--name"] + .placeholder( "name" ) .describe( "suite name" ) - .shortOpt( "n") - .longOpt( "name" ) - .hint( "name" ); + .into( &ConfigData::name ); - cli.bind( &abortAfterFirst ) + cli["-a"]["--abort"] .describe( "abort at first failure" ) - .shortOpt( "a") - .longOpt( "abort" ); + .into( &abortAfterFirst ); - cli.bind( &abortAfterX ) + cli["-x"]["--abortx"] + .placeholder( "number of failures" ) .describe( "abort after x failures" ) - .shortOpt( "x") - .longOpt( "abortx" ) - .hint( "number of failures" ); + .into( &abortAfterX ); - cli.bind( &addWarning ) + cli["-w"]["--warn"] + .placeholder( "warning name" ) .describe( "enable warnings" ) - .shortOpt( "w") - .longOpt( "warn" ) - .hint( "warning name" ); + .into( &addWarning ); -// cli.bind( &setVerbosity ) +// - needs updating if reinstated +// cli.into( &setVerbosity ) // .describe( "level of verbosity (0=no output)" ) // .shortOpt( "v") // .longOpt( "verbosity" ) -// .hint( "level" ); +// .placeholder( "level" ); - cli.bind( &addTestOrTags ) + cli[_] + .placeholder( "test name, pattern or tags" ) .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" ) - .shortOpt( "d") - .longOpt( "durations" ) - .hint( "yes/no" ); + .into( &setShowDurations ); - cli.bind( &loadTestNamesFromFile ) + cli["-f"]["--input-file"] + .placeholder( "filename" ) .describe( "load test names to run from a file" ) - .shortOpt( "f") - .longOpt( "input-file" ) - .hint( "filename" ); + .into( &loadTestNamesFromFile ); // 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" ) - .longOpt( "list-test-names-only" ); + .into( &ConfigData::listTestNamesOnly ); - cli.bind( &ConfigData::listReporters ) + cli["--list-reporters"] .describe( "list all reporters" ) - .longOpt( "list-reporters" ); - + .into( &ConfigData::listReporters ); return cli; } diff --git a/include/internal/clara.h b/include/internal/clara.h index 41e7c221..476f2343 100644 --- a/include/internal/clara.h +++ b/include/internal/clara.h @@ -7,12 +7,18 @@ */ // Only use header guard if we are not using an outer namespace -#if !defined(TWOBLUECUBES_CLARA_H_INCLUDED) || defined(STITCH_CLARA_OUTER_NAMESPACE) -#ifndef STITCH_CLARA_OUTER_NAMESPACE +#if !defined(TWOBLUECUBES_CLARA_H_INCLUDED) || defined(STITCH_CLARA_OPEN_NAMESPACE) + +#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_OUTER_NAMESPACE Clara + +#define STITCH_TBC_TEXT_FORMAT_OPEN_NAMESPACE STITCH_CLARA_OPEN_NAMESPACE // ----------- #included from tbc_text_format.h ----------- @@ -168,7 +174,7 @@ namespace Tbc { // ----------- end of #include from tbc_text_format.h ----------- // ........... back in /Users/philnash/Dev/OSS/Clara/srcs/clara.h -#undef STITCH_TBC_TEXT_FORMAT_OUTER_NAMESPACE +#undef STITCH_TBC_TEXT_FORMAT_OPEN_NAMESPACE #include #include @@ -176,11 +182,20 @@ namespace Tbc { #include // Use optional outer namespace -#ifdef STITCH_CLARA_OUTER_NAMESPACE -namespace STITCH_CLARA_OUTER_NAMESPACE { +#ifdef STITCH_CLARA_OPEN_NAMESPACE +STITCH_CLARA_OPEN_NAMESPACE #endif namespace Clara { + + struct UnpositionalTag {}; + + extern UnpositionalTag _; + +#ifdef CLARA_CONFIG_MAIN + UnpositionalTag _; +#endif + namespace Detail { #ifdef CLARA_CONSOLE_WIDTH @@ -189,7 +204,11 @@ namespace Clara { const unsigned int consoleWidth = 80; #endif - using namespace ::Clara::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 struct RemoveConstRef{ typedef T type; }; template struct RemoveConstRef{ typedef T type; }; @@ -240,6 +259,7 @@ namespace Clara { template class BoundArgFunction { public: + BoundArgFunction() : functionObj( NULL ) {} BoundArgFunction( IArgFunction* _functionObj ) : functionObj( _functionObj ) {} BoundArgFunction( BoundArgFunction const& other ) : functionObj( other.functionObj->clone() ) {} BoundArgFunction& operator = ( BoundArgFunction const& other ) { @@ -422,6 +442,7 @@ namespace Clara { class CommandLine { struct Arg { + Arg() : position( -1 ) {} Arg( Detail::BoundArgFunction const& _boundField ) : boundField( _boundField ), position( -1 ) {} bool hasShortName( std::string const& shortName ) const { @@ -437,7 +458,7 @@ namespace Clara { return _longName == longName; } bool takesArg() const { - return !hint.empty(); + return !placeholder.empty(); } bool isFixedPositional() const { return position != -1; @@ -454,7 +475,7 @@ namespace Clara { } void validate() const { 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::ostringstream oss; @@ -472,8 +493,8 @@ namespace Clara { oss << ", "; oss << "--" << longName; } - if( !hint.empty() ) - oss << " <" << hint << ">"; + if( !placeholder.empty() ) + oss << " <" << placeholder << ">"; return oss.str(); } @@ -481,7 +502,7 @@ namespace Clara { std::vector shortNames; std::string longName; std::string description; - std::string hint; + std::string placeholder; int position; }; @@ -492,14 +513,14 @@ namespace Clara { typedef std::auto_ptr ArgAutoPtr; #endif - class ArgBinder { + class ArgBuilder { public: - template - ArgBinder( CommandLine* cl, F f ) - : m_cl( cl ), - m_arg( Detail::makeBoundField( f ) ) + ArgBuilder( CommandLine* cl ) + : m_cl( cl ) {} - ArgBinder( ArgBinder& other ) + + + ArgBuilder( ArgBuilder& other ) : m_cl( other.m_cl ), m_arg( other.m_arg ) { @@ -507,7 +528,7 @@ namespace Clara { } // !TBD: Need to include workarounds to be able to declare this // destructor as able to throw exceptions - ~ArgBinder() /* noexcept(false) */ { + ~ArgBuilder() /* noexcept(false) */ { if( m_cl && !std::uncaught_exception() ) { m_arg.validate(); if( m_arg.isFixedPositional() ) { @@ -524,30 +545,66 @@ namespace Clara { m_cl->m_options.push_back( m_arg ); } } - ArgBinder& shortOpt( std::string const& name ) { - m_arg.shortNames.push_back( name ); + + template + 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; } - ArgBinder& longOpt( std::string const& name ) { - m_arg.longName = name; - return *this; - } - ArgBinder& describe( std::string const& description ) { + + ArgBuilder& describe( std::string const& description ) { m_arg.description = description; return *this; } - ArgBinder& hint( std::string const& hint ) { - m_arg.hint = hint; - return *this; - } - ArgBinder& position( int position ) { - m_arg.position = position; + ArgBuilder& detail( std::string const& ) { +// m_arg.description = description; +// !TBD return *this; } + private: CommandLine* m_cl; 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: @@ -572,11 +629,25 @@ namespace Clara { return *this; } - template - ArgBinder bind( F f ) { - ArgBinder binder( this, f ); - return binder; + + OptBuilder operator[]( std::string const& optName ) { + OptBuilder builder( this ); + 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 void bindProcessName( F f ) { m_boundProcessName = Detail::makeBoundField( f ); @@ -619,9 +690,9 @@ namespace Clara { os << " "; typename std::map::const_iterator it = m_positionalArgs.find( i ); if( it != m_positionalArgs.end() ) - os << "<" << it->second.hint << ">"; + os << "<" << it->second.placeholder << ">"; else if( m_arg.get() ) - os << "<" << m_arg->hint << ">"; + os << "<" << m_arg->placeholder << ">"; else throw std::logic_error( "non consecutive positional arguments with no floating args" ); } @@ -629,7 +700,7 @@ namespace Clara { if( m_arg.get() ) { if( m_highestSpecifiedArgPosition > 1 ) os << " "; - os << "[<" << m_arg->hint << "> ...]"; + os << "[<" << m_arg->placeholder << "> ...]"; } } std::string argSynopsis() const { @@ -769,8 +840,10 @@ namespace Clara { } // end namespace Clara -#ifdef STITCH_CLARA_OUTER_NAMESPACE -} // end outer namespace -#endif + +STITCH_CLARA_CLOSE_NAMESPACE +#undef STITCH_CLARA_OPEN_NAMESPACE +#undef STITCH_CLARA_CLOSE_NAMESPACE + #endif // TWOBLUECUBES_CLARA_H_INCLUDED diff --git a/projects/SelfTest/CmdLineTests.cpp b/projects/SelfTest/CmdLineTests.cpp deleted file mode 100644 index 8d003fed..00000000 --- a/projects/SelfTest/CmdLineTests.cpp +++ /dev/null @@ -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 -std::vector parseInto( Clara::CommandLine& 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 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 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 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 diff --git a/projects/XCode4/CatchSelfTest/CatchSelfTest.xcodeproj/project.pbxproj b/projects/XCode4/CatchSelfTest/CatchSelfTest.xcodeproj/project.pbxproj index 4c3d6af2..03225a7f 100644 --- a/projects/XCode4/CatchSelfTest/CatchSelfTest.xcodeproj/project.pbxproj +++ b/projects/XCode4/CatchSelfTest/CatchSelfTest.xcodeproj/project.pbxproj @@ -8,7 +8,6 @@ /* Begin PBXBuildFile section */ 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 */; }; 26847E5F16BBADB40043B9C1 /* catch_message.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 26847E5D16BBADB40043B9C1 /* catch_message.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 = ""; }; 266B06B616F3A60A004ED264 /* VariadicMacrosTests.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = VariadicMacrosTests.cpp; path = ../../../SelfTest/VariadicMacrosTests.cpp; sourceTree = ""; }; 266E9AD117230ACF0061DAB2 /* catch_text.hpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.h; path = catch_text.hpp; sourceTree = ""; }; - 266E9AD417290E8E0061DAB2 /* CmdLineTests.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = CmdLineTests.cpp; path = ../../../SelfTest/CmdLineTests.cpp; sourceTree = ""; }; 266ECD73170F3C620030D735 /* BDDTests.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = BDDTests.cpp; path = ../../../SelfTest/BDDTests.cpp; sourceTree = ""; }; 266ECD8C1713614B0030D735 /* catch_legacy_reporter_adapter.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = catch_legacy_reporter_adapter.hpp; sourceTree = ""; }; 266ECD8D1713614B0030D735 /* catch_legacy_reporter_adapter.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = catch_legacy_reporter_adapter.h; sourceTree = ""; }; @@ -193,7 +191,6 @@ 266E9AD317290E710061DAB2 /* Introspective Tests */ = { isa = PBXGroup; children = ( - 266E9AD417290E8E0061DAB2 /* CmdLineTests.cpp */, 26948284179A9AB900ED166E /* SectionTrackerTests.cpp */, ); name = "Introspective Tests"; @@ -535,7 +532,6 @@ 26847E5F16BBADB40043B9C1 /* catch_message.cpp in Sources */, 266B06B816F3A60A004ED264 /* VariadicMacrosTests.cpp in Sources */, 266ECD74170F3C620030D735 /* BDDTests.cpp in Sources */, - 266E9AD617290E8E0061DAB2 /* CmdLineTests.cpp in Sources */, 26948286179A9AB900ED166E /* SectionTrackerTests.cpp in Sources */, ); runOnlyForDeploymentPostprocessing = 0; diff --git a/single_include/catch.hpp b/single_include/catch.hpp index 108bbdb5..88f00889 100644 --- a/single_include/catch.hpp +++ b/single_include/catch.hpp @@ -1,6 +1,6 @@ /* * CATCH v1.0 build 27 (master branch) - * Generated: 2014-03-01 10:36:25.999888 + * Generated: 2014-03-06 08:06:07.489513 * ---------------------------------------------------------- * This file has been merged from multiple headers. Please don't edit it directly * Copyright (c) 2012 Two Blue Cubes Ltd. All rights reserved. @@ -3005,19 +3005,29 @@ namespace Catch { // #included from: catch_clara.h #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 // Declare Clara inside the Catch namespace -#define STITCH_CLARA_OUTER_NAMESPACE Catch +#define STITCH_CLARA_OPEN_NAMESPACE namespace Catch { // #included from: clara.h // Only use header guard if we are not using an outer namespace -#if !defined(TWOBLUECUBES_CLARA_H_INCLUDED) || defined(STITCH_CLARA_OUTER_NAMESPACE) -#ifndef STITCH_CLARA_OUTER_NAMESPACE +#if !defined(TWOBLUECUBES_CLARA_H_INCLUDED) || defined(STITCH_CLARA_OPEN_NAMESPACE) + +#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_OUTER_NAMESPACE Clara +#define STITCH_TBC_TEXT_FORMAT_OPEN_NAMESPACE STITCH_CLARA_OPEN_NAMESPACE // ----------- #included from tbc_text_format.h ----------- @@ -3166,7 +3176,7 @@ namespace Tbc { // ----------- end of #include from tbc_text_format.h ----------- // ........... back in /Users/philnash/Dev/OSS/Clara/srcs/clara.h -#undef STITCH_TBC_TEXT_FORMAT_OUTER_NAMESPACE +#undef STITCH_TBC_TEXT_FORMAT_OPEN_NAMESPACE #include #include @@ -3174,11 +3184,20 @@ namespace Tbc { #include // Use optional outer namespace -#ifdef STITCH_CLARA_OUTER_NAMESPACE -namespace STITCH_CLARA_OUTER_NAMESPACE { +#ifdef STITCH_CLARA_OPEN_NAMESPACE +STITCH_CLARA_OPEN_NAMESPACE #endif namespace Clara { + + struct UnpositionalTag {}; + + extern UnpositionalTag _; + +#ifdef CLARA_CONFIG_MAIN + UnpositionalTag _; +#endif + namespace Detail { #ifdef CLARA_CONSOLE_WIDTH @@ -3187,7 +3206,11 @@ namespace Clara { const unsigned int consoleWidth = 80; #endif - using namespace ::Clara::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 struct RemoveConstRef{ typedef T type; }; template struct RemoveConstRef{ typedef T type; }; @@ -3238,6 +3261,7 @@ namespace Clara { template class BoundArgFunction { public: + BoundArgFunction() : functionObj( NULL ) {} BoundArgFunction( IArgFunction* _functionObj ) : functionObj( _functionObj ) {} BoundArgFunction( BoundArgFunction const& other ) : functionObj( other.functionObj->clone() ) {} BoundArgFunction& operator = ( BoundArgFunction const& other ) { @@ -3419,6 +3443,7 @@ namespace Clara { class CommandLine { struct Arg { + Arg() : position( -1 ) {} Arg( Detail::BoundArgFunction const& _boundField ) : boundField( _boundField ), position( -1 ) {} bool hasShortName( std::string const& shortName ) const { @@ -3434,7 +3459,7 @@ namespace Clara { return _longName == longName; } bool takesArg() const { - return !hint.empty(); + return !placeholder.empty(); } bool isFixedPositional() const { return position != -1; @@ -3451,7 +3476,7 @@ namespace Clara { } void validate() const { 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::ostringstream oss; @@ -3469,8 +3494,8 @@ namespace Clara { oss << ", "; oss << "--" << longName; } - if( !hint.empty() ) - oss << " <" << hint << ">"; + if( !placeholder.empty() ) + oss << " <" << placeholder << ">"; return oss.str(); } @@ -3478,7 +3503,7 @@ namespace Clara { std::vector shortNames; std::string longName; std::string description; - std::string hint; + std::string placeholder; int position; }; @@ -3489,14 +3514,13 @@ namespace Clara { typedef std::auto_ptr ArgAutoPtr; #endif - class ArgBinder { + class ArgBuilder { public: - template - ArgBinder( CommandLine* cl, F f ) - : m_cl( cl ), - m_arg( Detail::makeBoundField( f ) ) + ArgBuilder( CommandLine* cl ) + : m_cl( cl ) {} - ArgBinder( ArgBinder& other ) + + ArgBuilder( ArgBuilder& other ) : m_cl( other.m_cl ), m_arg( other.m_arg ) { @@ -3504,7 +3528,7 @@ namespace Clara { } // !TBD: Need to include workarounds to be able to declare this // destructor as able to throw exceptions - ~ArgBinder() /* noexcept(false) */ { + ~ArgBuilder() /* noexcept(false) */ { if( m_cl && !std::uncaught_exception() ) { m_arg.validate(); if( m_arg.isFixedPositional() ) { @@ -3521,30 +3545,65 @@ namespace Clara { m_cl->m_options.push_back( m_arg ); } } - ArgBinder& shortOpt( std::string const& name ) { - m_arg.shortNames.push_back( name ); + + template + 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; } - ArgBinder& longOpt( std::string const& name ) { - m_arg.longName = name; - return *this; - } - ArgBinder& describe( std::string const& description ) { + + ArgBuilder& describe( std::string const& description ) { m_arg.description = description; return *this; } - ArgBinder& hint( std::string const& hint ) { - m_arg.hint = hint; - return *this; - } - ArgBinder& position( int position ) { - m_arg.position = position; + ArgBuilder& detail( std::string const& ) { +// m_arg.description = description; +// !TBD return *this; } + private: CommandLine* m_cl; 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: @@ -3569,11 +3628,24 @@ namespace Clara { return *this; } - template - ArgBinder bind( F f ) { - ArgBinder binder( this, f ); - return binder; + OptBuilder operator[]( std::string const& optName ) { + OptBuilder builder( this ); + 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 void bindProcessName( F f ) { m_boundProcessName = Detail::makeBoundField( f ); @@ -3616,9 +3688,9 @@ namespace Clara { os << " "; typename std::map::const_iterator it = m_positionalArgs.find( i ); if( it != m_positionalArgs.end() ) - os << "<" << it->second.hint << ">"; + os << "<" << it->second.placeholder << ">"; else if( m_arg.get() ) - os << "<" << m_arg->hint << ">"; + os << "<" << m_arg->placeholder << ">"; else throw std::logic_error( "non consecutive positional arguments with no floating args" ); } @@ -3626,7 +3698,7 @@ namespace Clara { if( m_arg.get() ) { if( m_highestSpecifiedArgPosition > 1 ) os << " "; - os << "[<" << m_arg->hint << "> ...]"; + os << "[<" << m_arg->placeholder << "> ...]"; } } std::string argSynopsis() const { @@ -3766,12 +3838,18 @@ namespace Clara { } // end namespace Clara -#ifdef STITCH_CLARA_OUTER_NAMESPACE -} // end outer namespace -#endif +STITCH_CLARA_CLOSE_NAMESPACE +#undef STITCH_CLARA_OPEN_NAMESPACE +#undef STITCH_CLARA_CLOSE_NAMESPACE #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 @@ -3816,107 +3894,95 @@ namespace Catch { inline Clara::CommandLine makeCommandLineParser() { - Clara::CommandLine cli; + using namespace Clara; + CommandLine cli; cli.bindProcessName( &ConfigData::processName ); - cli.bind( &ConfigData::showHelp ) + cli["-?"]["-h"]["--help"] .describe( "display usage information" ) - .shortOpt( "?") - .shortOpt( "h") - .longOpt( "help" ); + .into( &ConfigData::showHelp ); - cli.bind( &ConfigData::listTests ) + cli["-l"]["--list-tests"] .describe( "list all/matching test cases" ) - .shortOpt( "l") - .longOpt( "list-tests" ); + .into( &ConfigData::listTests ); - cli.bind( &ConfigData::listTags ) + cli["-t"]["--list-tags"] .describe( "list all/matching tags" ) - .shortOpt( "t") - .longOpt( "list-tags" ); + .into( &ConfigData::listTags ); - cli.bind( &ConfigData::showSuccessfulTests ) + cli["-s"]["--success"] .describe( "include successful tests in output" ) - .shortOpt( "s") - .longOpt( "success" ); + .into( &ConfigData::showSuccessfulTests ); - cli.bind( &ConfigData::shouldDebugBreak ) + cli["-b"]["--break"] .describe( "break into debugger on failure" ) - .shortOpt( "b") - .longOpt( "break" ); + .into( &ConfigData::shouldDebugBreak ); - cli.bind( &ConfigData::noThrow ) + cli["-e"]["--nothrow"] .describe( "skip exception tests" ) - .shortOpt( "e") - .longOpt( "nothrow" ); + .into( &ConfigData::noThrow ); - cli.bind( &ConfigData::outputFilename ) + cli["-o"]["--out"] + .placeholder( "filename" ) .describe( "output filename" ) - .shortOpt( "o") - .longOpt( "out" ) - .hint( "filename" ); + .into( &ConfigData::outputFilename ); - cli.bind( &ConfigData::reporterName ) + cli["-r"]["--reporter"] +// .placeholder( "name[:filename]" ) + .placeholder( "name" ) .describe( "reporter to use (defaults to console)" ) - .shortOpt( "r") - .longOpt( "reporter" ) -// .hint( "name[:filename]" ); - .hint( "name" ); + .into( &ConfigData::reporterName ); - cli.bind( &ConfigData::name ) + cli["-n"]["--name"] + .placeholder( "name" ) .describe( "suite name" ) - .shortOpt( "n") - .longOpt( "name" ) - .hint( "name" ); + .into( &ConfigData::name ); - cli.bind( &abortAfterFirst ) + cli["-a"]["--abort"] .describe( "abort at first failure" ) - .shortOpt( "a") - .longOpt( "abort" ); + .into( &abortAfterFirst ); - cli.bind( &abortAfterX ) + cli["-x"]["--abortx"] + .placeholder( "number of failures" ) .describe( "abort after x failures" ) - .shortOpt( "x") - .longOpt( "abortx" ) - .hint( "number of failures" ); + .into( &abortAfterX ); - cli.bind( &addWarning ) + cli["-w"]["--warn"] + .placeholder( "warning name" ) .describe( "enable warnings" ) - .shortOpt( "w") - .longOpt( "warn" ) - .hint( "warning name" ); + .into( &addWarning ); -// cli.bind( &setVerbosity ) +// - needs updating if reinstated +// cli.into( &setVerbosity ) // .describe( "level of verbosity (0=no output)" ) // .shortOpt( "v") // .longOpt( "verbosity" ) -// .hint( "level" ); +// .placeholder( "level" ); - cli.bind( &addTestOrTags ) + cli[_] + .placeholder( "test name, pattern or tags" ) .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" ) - .shortOpt( "d") - .longOpt( "durations" ) - .hint( "yes/no" ); + .into( &setShowDurations ); - cli.bind( &loadTestNamesFromFile ) + cli["-f"]["--input-file"] + .placeholder( "filename" ) .describe( "load test names to run from a file" ) - .shortOpt( "f") - .longOpt( "input-file" ) - .hint( "filename" ); + .into( &loadTestNamesFromFile ); // 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" ) - .longOpt( "list-test-names-only" ); + .into( &ConfigData::listTestNamesOnly ); - cli.bind( &ConfigData::listReporters ) + cli["--list-reporters"] .describe( "list all reporters" ) - .longOpt( "list-reporters" ); + .into( &ConfigData::listReporters ); return cli; } From fd879f7e774e8a6f676c24b9c3201e8d7f5d12d7 Mon Sep 17 00:00:00 2001 From: Phil Nash Date: Thu, 6 Mar 2014 08:17:24 +0000 Subject: [PATCH 3/7] Build 28 - new version of Clara - removed command line tests --- README.md | 2 +- include/internal/catch_version.hpp | 2 +- .../Baselines/console.std.approved.txt | 2 +- .../Baselines/console.sw.approved.txt | 201 +---------------- .../SelfTest/Baselines/junit.sw.approved.txt | 15 +- .../SelfTest/Baselines/xml.sw.approved.txt | 208 +----------------- single_include/catch.hpp | 6 +- 7 files changed, 10 insertions(+), 426 deletions(-) diff --git a/README.md b/README.md index bdfdc7f8..e578936d 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ ![catch logo](catch-logo-small.png) -*v1.0 build 27 (master branch)* +*v1.0 build 28 (master branch)* Build status (on Travis CI) [![Build Status](https://travis-ci.org/philsquared/Catch.png)](https://travis-ci.org/philsquared/Catch) diff --git a/include/internal/catch_version.hpp b/include/internal/catch_version.hpp index 441f64df..06be4c17 100644 --- a/include/internal/catch_version.hpp +++ b/include/internal/catch_version.hpp @@ -13,7 +13,7 @@ namespace Catch { // These numbers are maintained by a script - Version libraryVersion( 1, 0, 27, "master" ); + Version libraryVersion( 1, 0, 28, "master" ); } #endif // TWOBLUECUBES_CATCH_VERSION_HPP_INCLUDED diff --git a/projects/SelfTest/Baselines/console.std.approved.txt b/projects/SelfTest/Baselines/console.std.approved.txt index 3bf4d6c2..e1df1550 100644 --- a/projects/SelfTest/Baselines/console.std.approved.txt +++ b/projects/SelfTest/Baselines/console.std.approved.txt @@ -750,5 +750,5 @@ with expansion: "first" == "second" =============================================================================== -123 test cases - 36 failed (676 assertions - 91 failed) +122 test cases - 36 failed (658 assertions - 91 failed) diff --git a/projects/SelfTest/Baselines/console.sw.approved.txt b/projects/SelfTest/Baselines/console.sw.approved.txt index 64ed0577..353d36ec 100644 --- a/projects/SelfTest/Baselines/console.sw.approved.txt +++ b/projects/SelfTest/Baselines/console.sw.approved.txt @@ -6726,205 +6726,6 @@ PASSED: with message: boo! -------------------------------------------------------------------------------- -cmdline - process name -------------------------------------------------------------------------------- -CmdLineTests.cpp: -............................................................................... - -CmdLineTests.cpp:: -PASSED: - CHECK( config.processName == "test" ) -with expansion: - "test" == "test" - -------------------------------------------------------------------------------- -cmdline - arg separated by spaces -------------------------------------------------------------------------------- -CmdLineTests.cpp: -............................................................................... - -CmdLineTests.cpp:: -PASSED: - CHECK( config.fileName == "filename.ext" ) -with expansion: - "filename.ext" == "filename.ext" - -------------------------------------------------------------------------------- -cmdline - arg separated by colon -------------------------------------------------------------------------------- -CmdLineTests.cpp: -............................................................................... - -CmdLineTests.cpp:: -PASSED: - CHECK( config.fileName == "filename.ext" ) -with expansion: - "filename.ext" == "filename.ext" - -------------------------------------------------------------------------------- -cmdline - arg separated by = -------------------------------------------------------------------------------- -CmdLineTests.cpp: -............................................................................... - -CmdLineTests.cpp:: -PASSED: - CHECK( config.fileName == "filename.ext" ) -with expansion: - "filename.ext" == "filename.ext" - -------------------------------------------------------------------------------- -cmdline - long opt -------------------------------------------------------------------------------- -CmdLineTests.cpp: -............................................................................... - -CmdLineTests.cpp:: -PASSED: - CHECK( config.fileName == "%stdout" ) -with expansion: - "%stdout" == "%stdout" - -------------------------------------------------------------------------------- -cmdline - a number -------------------------------------------------------------------------------- -CmdLineTests.cpp: -............................................................................... - -CmdLineTests.cpp:: -PASSED: - CHECK( config.number == 42 ) -with expansion: - 42 == 42 - -------------------------------------------------------------------------------- -cmdline - not a number -------------------------------------------------------------------------------- -CmdLineTests.cpp: -............................................................................... - -CmdLineTests.cpp:: -PASSED: - CHECK_THROWS( parseInto( cli, argv, config ) ) - -CmdLineTests.cpp:: -PASSED: - CHECK( config.number == 0 ) -with expansion: - 0 == 0 - -------------------------------------------------------------------------------- -cmdline - two parsers -------------------------------------------------------------------------------- -CmdLineTests.cpp: -............................................................................... - -CmdLineTests.cpp:: -PASSED: - CHECK( config1.number == 42 ) -with expansion: - 42 == 42 - -CmdLineTests.cpp:: -PASSED: - REQUIRE_FALSE( unusedTokens.empty() ) -with expansion: - !false - -CmdLineTests.cpp:: -PASSED: - CHECK( config2.description == "some text" ) -with expansion: - "some text" == "some text" - -------------------------------------------------------------------------------- -cmdline - methods - in range -------------------------------------------------------------------------------- -CmdLineTests.cpp: -............................................................................... - -CmdLineTests.cpp:: -PASSED: - REQUIRE( config.index == 3 ) -with expansion: - 3 == 3 - -------------------------------------------------------------------------------- -cmdline - methods - out of range -------------------------------------------------------------------------------- -CmdLineTests.cpp: -............................................................................... - -CmdLineTests.cpp:: -PASSED: - REQUIRE_THROWS( parseInto( cli, argv, config ) ) - -------------------------------------------------------------------------------- -cmdline - flags - set -------------------------------------------------------------------------------- -CmdLineTests.cpp: -............................................................................... - -CmdLineTests.cpp:: -PASSED: - REQUIRE( config.flag ) -with expansion: - true - -------------------------------------------------------------------------------- -cmdline - flags - not set -------------------------------------------------------------------------------- -CmdLineTests.cpp: -............................................................................... - -CmdLineTests.cpp:: -PASSED: - REQUIRE( config.flag == false ) -with expansion: - false == false - -------------------------------------------------------------------------------- -cmdline - positional -------------------------------------------------------------------------------- -CmdLineTests.cpp: -............................................................................... - -CmdLineTests.cpp:: -PASSED: - REQUIRE( config.firstPos == "1st" ) -with expansion: - "1st" == "1st" - -CmdLineTests.cpp:: -PASSED: - REQUIRE( config.secondPos == "2nd" ) -with expansion: - "2nd" == "2nd" - -CmdLineTests.cpp:: -PASSED: - REQUIRE( config.unpositional == "3rd" ) -with expansion: - "3rd" == "3rd" - ------------------------------------------------------------------------------- section tracking ------------------------------------------------------------------------------- @@ -7158,5 +6959,5 @@ with expansion: true =============================================================================== -123 test cases - 51 failed (695 assertions - 110 failed) +122 test cases - 51 failed (677 assertions - 110 failed) diff --git a/projects/SelfTest/Baselines/junit.sw.approved.txt b/projects/SelfTest/Baselines/junit.sw.approved.txt index 58a1d151..406bda64 100644 --- a/projects/SelfTest/Baselines/junit.sw.approved.txt +++ b/projects/SelfTest/Baselines/junit.sw.approved.txt @@ -1,5 +1,5 @@ - + @@ -530,19 +530,6 @@ TrickyTests.cpp: - - - - - - - - - - - - - diff --git a/projects/SelfTest/Baselines/xml.sw.approved.txt b/projects/SelfTest/Baselines/xml.sw.approved.txt index efbb16d3..58fef781 100644 --- a/projects/SelfTest/Baselines/xml.sw.approved.txt +++ b/projects/SelfTest/Baselines/xml.sw.approved.txt @@ -6967,210 +6967,6 @@ there" - -
- - - config.processName == "test" - - - "test" == "test" - - - -
-
- - - config.fileName == "filename.ext" - - - "filename.ext" == "filename.ext" - - - -
-
- - - config.fileName == "filename.ext" - - - "filename.ext" == "filename.ext" - - - -
-
- - - config.fileName == "filename.ext" - - - "filename.ext" == "filename.ext" - - - -
-
- - - config.fileName == "%stdout" - - - "%stdout" == "%stdout" - - - -
-
- - - config.number == 42 - - - 42 == 42 - - - -
-
- - - parseInto( cli, argv, config ) - - - parseInto( cli, argv, config ) - - - - - config.number == 0 - - - 0 == 0 - - - -
-
- - - config1.number == 42 - - - 42 == 42 - - - - - !unusedTokens.empty() - - - !false - - - - - config2.description == "some text" - - - "some text" == "some text" - - - -
-
- -
-
-
- - - config.index == 3 - - - 3 == 3 - - - -
- -
-
-
- - - parseInto( cli, argv, config ) - - - parseInto( cli, argv, config ) - - - -
- -
-
- -
-
-
- - - config.flag - - - true - - - -
- -
-
-
- - - config.flag == false - - - false == false - - - -
- -
-
- - - config.firstPos == "1st" - - - "1st" == "1st" - - - - - config.secondPos == "2nd" - - - "2nd" == "2nd" - - - - - config.unpositional == "3rd" - - - "3rd" == "3rd" - - - -
- -
@@ -7418,7 +7214,7 @@ there" - +
- + diff --git a/single_include/catch.hpp b/single_include/catch.hpp index 88f00889..f2e9b41b 100644 --- a/single_include/catch.hpp +++ b/single_include/catch.hpp @@ -1,6 +1,6 @@ /* - * CATCH v1.0 build 27 (master branch) - * Generated: 2014-03-06 08:06:07.489513 + * CATCH v1.0 build 28 (master branch) + * Generated: 2014-03-06 08:16:53.424629 * ---------------------------------------------------------- * This file has been merged from multiple headers. Please don't edit it directly * Copyright (c) 2012 Two Blue Cubes Ltd. All rights reserved. @@ -6580,7 +6580,7 @@ namespace Catch { namespace Catch { // These numbers are maintained by a script - Version libraryVersion( 1, 0, 27, "master" ); + Version libraryVersion( 1, 0, 28, "master" ); } // #included from: catch_message.hpp From 9b4c7fa0f71b81e4b51c67f67d492139b65ae980 Mon Sep 17 00:00:00 2001 From: Phil Nash Date: Thu, 6 Mar 2014 08:21:47 +0000 Subject: [PATCH 4/7] Updated cmake file with command line test removal --- projects/CMake/CMakeLists.txt | 1 - 1 file changed, 1 deletion(-) diff --git a/projects/CMake/CMakeLists.txt b/projects/CMake/CMakeLists.txt index 0a556f24..c31ec32b 100644 --- a/projects/CMake/CMakeLists.txt +++ b/projects/CMake/CMakeLists.txt @@ -12,7 +12,6 @@ set(SOURCES ${SELF_TEST_DIR}/ApproxTests.cpp ${SELF_TEST_DIR}/BDDTests.cpp ${SELF_TEST_DIR}/ClassTests.cpp - ${SELF_TEST_DIR}/CmdLineTests.cpp ${SELF_TEST_DIR}/ConditionTests.cpp ${SELF_TEST_DIR}/ExceptionTests.cpp ${SELF_TEST_DIR}/GeneratorTests.cpp From 9abb27676df9a5b398d0a1680c1fd14109454f1a Mon Sep 17 00:00:00 2001 From: Phil Nash Date: Thu, 6 Mar 2014 21:53:34 +0000 Subject: [PATCH 5/7] Fix problem (hopefully) with single source definitions from Clara - define CLARA_CONFIG_MAIN in the right place --- README.md | 2 +- include/catch.hpp | 19 ++++++++++++++++--- include/internal/catch_version.hpp | 2 +- single_include/catch.hpp | 24 ++++++++++++++++++------ 4 files changed, 36 insertions(+), 11 deletions(-) diff --git a/README.md b/README.md index e578936d..33901df2 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ ![catch logo](catch-logo-small.png) -*v1.0 build 28 (master branch)* +*v1.0 build 29 (master branch)* Build status (on Travis CI) [![Build Status](https://travis-ci.org/philsquared/Catch.png)](https://travis-ci.org/philsquared/Catch) diff --git a/include/catch.hpp b/include/catch.hpp index df162dff..cb8a19c1 100644 --- a/include/catch.hpp +++ b/include/catch.hpp @@ -17,6 +17,14 @@ #pragma clang diagnostic ignored "-Wpadded" #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 + #include "internal/catch_notimplemented_exception.h" #include "internal/catch_context.h" #include "internal/catch_test_registry.hpp" @@ -37,13 +45,18 @@ #include "internal/catch_objc.hpp" #endif -#if defined( CATCH_CONFIG_MAIN ) || defined( CATCH_CONFIG_RUNNER ) +#ifdef CATCH_CONFIG_RUNNER #include "internal/catch_impl.hpp" -#endif // CATCH_CONFIG_MAIN || CATCH_CONFIG_RUNNER +#endif #ifdef CATCH_CONFIG_MAIN #include "internal/catch_default_main.hpp" -#endif // CATCH_CONFIG_MAIN +#endif + + +#ifdef CLARA_CONFIG_MAIN_NOT_DEFINED +# undef CLARA_CONFIG_MAIN +#endif ////// diff --git a/include/internal/catch_version.hpp b/include/internal/catch_version.hpp index 06be4c17..b19a036e 100644 --- a/include/internal/catch_version.hpp +++ b/include/internal/catch_version.hpp @@ -13,7 +13,7 @@ namespace Catch { // These numbers are maintained by a script - Version libraryVersion( 1, 0, 28, "master" ); + Version libraryVersion( 1, 0, 29, "master" ); } #endif // TWOBLUECUBES_CATCH_VERSION_HPP_INCLUDED diff --git a/single_include/catch.hpp b/single_include/catch.hpp index f2e9b41b..85b99843 100644 --- a/single_include/catch.hpp +++ b/single_include/catch.hpp @@ -1,6 +1,6 @@ /* - * CATCH v1.0 build 28 (master branch) - * Generated: 2014-03-06 08:16:53.424629 + * CATCH v1.0 build 29 (master branch) + * Generated: 2014-03-06 21:52:26.886365 * ---------------------------------------------------------- * This file has been merged from multiple headers. Please don't edit it directly * Copyright (c) 2012 Two Blue Cubes Ltd. All rights reserved. @@ -21,6 +21,14 @@ #pragma clang diagnostic ignored "-Wpadded" #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 + // #included from: internal/catch_notimplemented_exception.h #define TWOBLUECUBES_CATCH_NOTIMPLEMENTED_EXCEPTION_H_INCLUDED @@ -2645,7 +2653,7 @@ return @ desc; \ #endif -#if defined( CATCH_CONFIG_MAIN ) || defined( CATCH_CONFIG_RUNNER ) +#ifdef CATCH_CONFIG_RUNNER // #included from: internal/catch_impl.hpp #define TWOBLUECUBES_CATCH_IMPL_HPP_INCLUDED @@ -6580,7 +6588,7 @@ namespace Catch { namespace Catch { // These numbers are maintained by a script - Version libraryVersion( 1, 0, 28, "master" ); + Version libraryVersion( 1, 0, 29, "master" ); } // #included from: catch_message.hpp @@ -8234,7 +8242,7 @@ namespace Catch { #pragma clang diagnostic pop #endif -#endif // CATCH_CONFIG_MAIN || CATCH_CONFIG_RUNNER +#endif #ifdef CATCH_CONFIG_MAIN // #included from: internal/catch_default_main.hpp @@ -8267,7 +8275,11 @@ int main (int argc, char * const argv[]) { #endif // __OBJC__ -#endif // CATCH_CONFIG_MAIN +#endif + +#ifdef CLARA_CONFIG_MAIN_NOT_DEFINED +# undef CLARA_CONFIG_MAIN +#endif ////// From 04f994a8fc452e8ac195d87b1eb609c4e195b7e9 Mon Sep 17 00:00:00 2001 From: Phil Nash Date: Fri, 7 Mar 2014 06:53:30 +0000 Subject: [PATCH 6/7] Updated VS2010 project (removed CmdLineTests.cpp) --- projects/VS2010/TestCatch/TestCatch/TestCatch.vcxproj | 1 - 1 file changed, 1 deletion(-) diff --git a/projects/VS2010/TestCatch/TestCatch/TestCatch.vcxproj b/projects/VS2010/TestCatch/TestCatch/TestCatch.vcxproj index a8f60653..a87366e7 100644 --- a/projects/VS2010/TestCatch/TestCatch/TestCatch.vcxproj +++ b/projects/VS2010/TestCatch/TestCatch/TestCatch.vcxproj @@ -93,7 +93,6 @@ - From dd2810d60af6fd49946dd6992536aa4fb14cb7f0 Mon Sep 17 00:00:00 2001 From: Phil Nash Date: Fri, 7 Mar 2014 06:58:33 +0000 Subject: [PATCH 7/7] build 30 - with Clara fix for null deref crash --- README.md | 2 +- include/internal/catch_version.hpp | 2 +- include/internal/clara.h | 5 +++-- single_include/catch.hpp | 10 +++++----- 4 files changed, 10 insertions(+), 9 deletions(-) diff --git a/README.md b/README.md index 33901df2..d12d676a 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ ![catch logo](catch-logo-small.png) -*v1.0 build 29 (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) diff --git a/include/internal/catch_version.hpp b/include/internal/catch_version.hpp index b19a036e..85181d64 100644 --- a/include/internal/catch_version.hpp +++ b/include/internal/catch_version.hpp @@ -13,7 +13,7 @@ namespace Catch { // These numbers are maintained by a script - Version libraryVersion( 1, 0, 29, "master" ); + Version libraryVersion( 1, 0, 30, "master" ); } #endif // TWOBLUECUBES_CATCH_VERSION_HPP_INCLUDED diff --git a/include/internal/clara.h b/include/internal/clara.h index 476f2343..a8b50575 100644 --- a/include/internal/clara.h +++ b/include/internal/clara.h @@ -176,6 +176,7 @@ namespace Tbc { #undef STITCH_TBC_TEXT_FORMAT_OPEN_NAMESPACE + #include #include #include @@ -261,9 +262,9 @@ namespace Clara { public: BoundArgFunction() : functionObj( NULL ) {} BoundArgFunction( IArgFunction* _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 ) { - IArgFunction* newFunctionObj = other.functionObj->clone(); + IArgFunction* newFunctionObj = other.functionObj ? other.functionObj->clone() : NULL; delete functionObj; functionObj = newFunctionObj; return *this; diff --git a/single_include/catch.hpp b/single_include/catch.hpp index 85b99843..20b25027 100644 --- a/single_include/catch.hpp +++ b/single_include/catch.hpp @@ -1,6 +1,6 @@ /* - * CATCH v1.0 build 29 (master branch) - * Generated: 2014-03-06 21:52:26.886365 + * CATCH v1.0 build 30 (master branch) + * Generated: 2014-03-07 06:56:50.010459 * ---------------------------------------------------------- * This file has been merged from multiple headers. Please don't edit it directly * Copyright (c) 2012 Two Blue Cubes Ltd. All rights reserved. @@ -3271,9 +3271,9 @@ namespace Clara { public: BoundArgFunction() : functionObj( NULL ) {} BoundArgFunction( IArgFunction* _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 ) { - IArgFunction* newFunctionObj = other.functionObj->clone(); + IArgFunction* newFunctionObj = other.functionObj ? other.functionObj->clone() : NULL; delete functionObj; functionObj = newFunctionObj; return *this; @@ -6588,7 +6588,7 @@ namespace Catch { namespace Catch { // These numbers are maintained by a script - Version libraryVersion( 1, 0, 29, "master" ); + Version libraryVersion( 1, 0, 30, "master" ); } // #included from: catch_message.hpp