- Fixes some test spec parser issues and some warnings (compiler and analysers)
This commit is contained in:
Phil Nash 2014-05-20 18:50:59 +01:00
parent 5daa22dcc3
commit 9241e436f9
3 changed files with 123 additions and 73 deletions

View File

@ -1,6 +1,6 @@
![catch logo](catch-logo-small.png) ![catch logo](catch-logo-small.png)
*v1.0 build 45 (master branch)* *v1.0 build 46 (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)

View File

@ -13,7 +13,7 @@
namespace Catch { namespace Catch {
// These numbers are maintained by a script // These numbers are maintained by a script
Version libraryVersion( 1, 0, 45, "master" ); Version libraryVersion( 1, 0, 46, "master" );
} }
#endif // TWOBLUECUBES_CATCH_VERSION_HPP_INCLUDED #endif // TWOBLUECUBES_CATCH_VERSION_HPP_INCLUDED

View File

@ -1,6 +1,6 @@
/* /*
* CATCH v1.0 build 45 (master branch) * CATCH v1.0 build 46 (master branch)
* Generated: 2014-05-19 18:22:42.461908 * Generated: 2014-05-20 18:49:44.156173
* ---------------------------------------------------------- * ----------------------------------------------------------
* 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.
@ -13,6 +13,10 @@
#define TWOBLUECUBES_CATCH_HPP_INCLUDED #define TWOBLUECUBES_CATCH_HPP_INCLUDED
// #included from: internal/catch_suppress_warnings.h
#define TWOBLUECUBES_CATCH_SUPPRESS_WARNINGS_H_INCLUDED
#ifdef __clang__ #ifdef __clang__
#pragma clang diagnostic ignored "-Wglobal-constructors" #pragma clang diagnostic ignored "-Wglobal-constructors"
#pragma clang diagnostic ignored "-Wvariadic-macros" #pragma clang diagnostic ignored "-Wvariadic-macros"
@ -265,6 +269,7 @@ namespace Catch {
{ {
public: public:
NotImplementedException( SourceLineInfo const& lineInfo ); NotImplementedException( SourceLineInfo const& lineInfo );
NotImplementedException( NotImplementedException const& ) {}
virtual ~NotImplementedException() CATCH_NOEXCEPT {} virtual ~NotImplementedException() CATCH_NOEXCEPT {}
@ -408,8 +413,8 @@ namespace Catch {
{ {
virtual ~IContext(); virtual ~IContext();
virtual IResultCapture& getResultCapture() = 0; virtual IResultCapture* getResultCapture() = 0;
virtual IRunner& getRunner() = 0; virtual IRunner* getRunner() = 0;
virtual size_t getGeneratorIndex( std::string const& fileInfo, size_t totalSize ) = 0; virtual size_t getGeneratorIndex( std::string const& fileInfo, size_t totalSize ) = 0;
virtual bool advanceGeneratorsForCurrentTest() = 0; virtual bool advanceGeneratorsForCurrentTest() = 0;
virtual Ptr<IConfig const> getConfig() const = 0; virtual Ptr<IConfig const> getConfig() const = 0;
@ -1358,6 +1363,7 @@ namespace Catch {
class ScopedMessage { class ScopedMessage {
public: public:
ScopedMessage( MessageBuilder const& builder ); ScopedMessage( MessageBuilder const& builder );
ScopedMessage( ScopedMessage const& other );
~ScopedMessage(); ~ScopedMessage();
MessageInfo m_info; MessageInfo m_info;
@ -1536,7 +1542,10 @@ namespace Catch {
namespace Catch { namespace Catch {
inline IResultCapture& getResultCapture() { inline IResultCapture& getResultCapture() {
return getCurrentContext().getResultCapture(); if( IResultCapture* capture = getCurrentContext().getResultCapture() )
return *capture;
else
throw std::logic_error( "No result capture instance" );
} }
template<typename MatcherT> template<typename MatcherT>
@ -2406,6 +2415,7 @@ namespace Catch {
std::string className; std::string className;
std::string description; std::string description;
std::set<std::string> tags; std::set<std::string> tags;
std::set<std::string> lcaseTags;
std::string tagsAsString; std::string tagsAsString;
SourceLineInfo lineInfo; SourceLineInfo lineInfo;
bool isHidden; bool isHidden;
@ -2750,7 +2760,7 @@ namespace Catch {
TagPattern( std::string const& tag ) : m_tag( toLower( tag ) ) {} TagPattern( std::string const& tag ) : m_tag( toLower( tag ) ) {}
virtual ~TagPattern(); virtual ~TagPattern();
virtual bool matches( TestCaseInfo const& testCase ) const { virtual bool matches( TestCaseInfo const& testCase ) const {
return testCase.tags.find( m_tag ) != testCase.tags.end(); return testCase.lcaseTags.find( m_tag ) != testCase.lcaseTags.end();
} }
private: private:
std::string m_tag; std::string m_tag;
@ -2820,10 +2830,10 @@ namespace Catch {
visitChar( m_arg[m_pos] ); visitChar( m_arg[m_pos] );
if( m_mode == Name ) if( m_mode == Name )
addPattern<TestSpec::NamePattern>(); addPattern<TestSpec::NamePattern>();
addFilter();
return *this; return *this;
} }
TestSpec testSpec() { TestSpec testSpec() {
addFilter();
return m_testSpec; return m_testSpec;
} }
private: private:
@ -3959,7 +3969,7 @@ namespace Catch {
while( std::getline( f, line ) ) { while( std::getline( f, line ) ) {
line = trim(line); line = trim(line);
if( !line.empty() && !startsWith( line, "#" ) ) if( !line.empty() && !startsWith( line, "#" ) )
addTestOrTags( config, "\"" + line + "\"" ); addTestOrTags( config, "\"" + line + "\"," );
} }
} }
@ -4270,6 +4280,7 @@ namespace Catch {
static void use( Code _colourCode ); static void use( Code _colourCode );
private: private:
Colour( Colour const& other );
static Detail::IColourImpl* impl(); static Detail::IColourImpl* impl();
}; };
@ -4655,7 +4666,24 @@ namespace Catch {
testSpec = TestSpecParser().parse( "*" ).testSpec(); testSpec = TestSpecParser().parse( "*" ).testSpec();
} }
std::map<std::string, int> tagCounts; struct TagInfo {
TagInfo() : count ( 0 ) {}
void add( std::string const& spelling ) {
++count;
spellings.insert( spelling );
}
std::string all() const {
std::string out;
for( std::set<std::string>::const_iterator it = spellings.begin(), itEnd = spellings.end();
it != itEnd;
++it )
out += "[" + *it + "]";
return out;
}
std::set<std::string> spellings;
std::size_t count;
};
std::map<std::string, TagInfo> tagCounts;
std::vector<TestCase> matchedTestCases; std::vector<TestCase> matchedTestCases;
getRegistryHub().getTestCaseRegistry().getFilteredTests( testSpec, config, matchedTestCases ); getRegistryHub().getTestCaseRegistry().getFilteredTests( testSpec, config, matchedTestCases );
@ -4667,21 +4695,21 @@ namespace Catch {
tagIt != tagItEnd; tagIt != tagItEnd;
++tagIt ) { ++tagIt ) {
std::string tagName = *tagIt; std::string tagName = *tagIt;
std::map<std::string, int>::iterator countIt = tagCounts.find( tagName ); std::string lcaseTagName = toLower( tagName );
std::map<std::string, TagInfo>::iterator countIt = tagCounts.find( lcaseTagName );
if( countIt == tagCounts.end() ) if( countIt == tagCounts.end() )
tagCounts.insert( std::make_pair( tagName, 1 ) ); countIt = tagCounts.insert( std::make_pair( lcaseTagName, TagInfo() ) ).first;
else countIt->second.add( tagName );
countIt->second++;
} }
} }
for( std::map<std::string, int>::const_iterator countIt = tagCounts.begin(), for( std::map<std::string, TagInfo>::const_iterator countIt = tagCounts.begin(),
countItEnd = tagCounts.end(); countItEnd = tagCounts.end();
countIt != countItEnd; countIt != countItEnd;
++countIt ) { ++countIt ) {
std::ostringstream oss; std::ostringstream oss;
oss << " " << countIt->second << " "; oss << " " << std::setw(2) << countIt->second.count << " ";
Text wrapper( "[" + countIt->first + "]", TextAttributes() Text wrapper( countIt->second.all(), TextAttributes()
.setInitialIndent( 0 ) .setInitialIndent( 0 )
.setIndent( oss.str().size() ) .setIndent( oss.str().size() )
.setWidth( CATCH_CONFIG_CONSOLE_WIDTH-10 ) ); .setWidth( CATCH_CONFIG_CONSOLE_WIDTH-10 ) );
@ -4910,8 +4938,8 @@ namespace Catch {
m_activeTestCase( NULL ), m_activeTestCase( NULL ),
m_config( config ), m_config( config ),
m_reporter( reporter ), m_reporter( reporter ),
m_prevRunner( &m_context.getRunner() ), m_prevRunner( m_context.getRunner() ),
m_prevResultCapture( &m_context.getResultCapture() ), m_prevResultCapture( m_context.getResultCapture() ),
m_prevConfig( m_context.getConfig() ) m_prevConfig( m_context.getConfig() )
{ {
m_context.setRunner( this ); m_context.setRunner( this );
@ -5792,11 +5820,11 @@ namespace Catch {
void operator=( Context const& ); void operator=( Context const& );
public: // IContext public: // IContext
virtual IResultCapture& getResultCapture() { virtual IResultCapture* getResultCapture() {
return *m_resultCapture; return m_resultCapture;
} }
virtual IRunner& getRunner() { virtual IRunner* getRunner() {
return *m_runner; return m_runner;
} }
virtual size_t getGeneratorIndex( std::string const& fileInfo, size_t totalSize ) { virtual size_t getGeneratorIndex( std::string const& fileInfo, size_t totalSize ) {
return getGeneratorsForCurrentTest() return getGeneratorsForCurrentTest()
@ -5827,7 +5855,7 @@ namespace Catch {
private: private:
IGeneratorsForTest* findGeneratorsForCurrentTest() { IGeneratorsForTest* findGeneratorsForCurrentTest() {
std::string testName = getResultCapture().getCurrentTestName(); std::string testName = getResultCapture()->getCurrentTestName();
std::map<std::string, IGeneratorsForTest*>::const_iterator it = std::map<std::string, IGeneratorsForTest*>::const_iterator it =
m_generatorsByTestName.find( testName ); m_generatorsByTestName.find( testName );
@ -5839,7 +5867,7 @@ namespace Catch {
IGeneratorsForTest& getGeneratorsForCurrentTest() { IGeneratorsForTest& getGeneratorsForCurrentTest() {
IGeneratorsForTest* generators = findGeneratorsForCurrentTest(); IGeneratorsForTest* generators = findGeneratorsForCurrentTest();
if( !generators ) { if( !generators ) {
std::string testName = getResultCapture().getCurrentTestName(); std::string testName = getResultCapture()->getCurrentTestName();
generators = createGeneratorsForTest(); generators = createGeneratorsForTest();
m_generatorsByTestName.insert( std::make_pair( testName, generators ) ); m_generatorsByTestName.insert( std::make_pair( testName, generators ) );
} }
@ -6332,20 +6360,21 @@ namespace Catch {
enforceNotReservedTag( tag, _lineInfo ); enforceNotReservedTag( tag, _lineInfo );
inTag = false; inTag = false;
if( tag == "hide" || tag == "." ) { if( tag == "hide" || tag == "." )
tags.insert( "hide" );
tags.insert( "." );
isHidden = true; isHidden = true;
} else
else {
tags.insert( tag ); tags.insert( tag );
}
tag.clear(); tag.clear();
} }
else else
tag += c; tag += c;
} }
} }
if( isHidden ) {
tags.insert( "hide" );
tags.insert( "." );
}
TestCaseInfo info( _name, _className, desc, tags, isHidden, _lineInfo ); TestCaseInfo info( _name, _className, desc, tags, isHidden, _lineInfo );
return TestCase( _testCase, info ); return TestCase( _testCase, info );
} }
@ -6369,6 +6398,7 @@ namespace Catch {
oss << "[" << *it << "]"; oss << "[" << *it << "]";
if( *it == "!throws" ) if( *it == "!throws" )
throws = true; throws = true;
lcaseTags.insert( toLower( *it ) );
} }
tagsAsString = oss.str(); tagsAsString = oss.str();
} }
@ -6378,6 +6408,7 @@ namespace Catch {
className( other.className ), className( other.className ),
description( other.description ), description( other.description ),
tags( other.tags ), tags( other.tags ),
lcaseTags( other.lcaseTags ),
tagsAsString( other.tagsAsString ), tagsAsString( other.tagsAsString ),
lineInfo( other.lineInfo ), lineInfo( other.lineInfo ),
isHidden( other.isHidden ), isHidden( other.isHidden ),
@ -6397,6 +6428,19 @@ namespace Catch {
return other; return other;
} }
void TestCase::swap( TestCase& other ) {
test.swap( other.test );
name.swap( other.name );
className.swap( other.className );
description.swap( other.description );
tags.swap( other.tags );
lcaseTags.swap( other.lcaseTags );
tagsAsString.swap( other.tagsAsString );
std::swap( TestCaseInfo::isHidden, static_cast<TestCaseInfo&>( other ).isHidden );
std::swap( TestCaseInfo::throws, static_cast<TestCaseInfo&>( other ).throws );
std::swap( lineInfo, other.lineInfo );
}
void TestCase::invoke() const { void TestCase::invoke() const {
test->invoke(); test->invoke();
} }
@ -6408,14 +6452,6 @@ namespace Catch {
return TestCaseInfo::throws; return TestCaseInfo::throws;
} }
void TestCase::swap( TestCase& other ) {
test.swap( other.test );
className.swap( other.className );
name.swap( other.name );
description.swap( other.description );
std::swap( lineInfo, other.lineInfo );
}
bool TestCase::operator == ( TestCase const& other ) const { bool TestCase::operator == ( TestCase const& other ) const {
return test.get() == other.test.get() && return test.get() == other.test.get() &&
name == other.name && name == other.name &&
@ -6444,7 +6480,7 @@ namespace Catch {
namespace Catch { namespace Catch {
// These numbers are maintained by a script // These numbers are maintained by a script
Version libraryVersion( 1, 0, 45, "master" ); Version libraryVersion( 1, 0, 46, "master" );
} }
// #included from: catch_message.hpp // #included from: catch_message.hpp
@ -6472,6 +6508,10 @@ namespace Catch {
m_info.message = builder.m_stream.str(); m_info.message = builder.m_stream.str();
getResultCapture().pushScopedMessage( m_info ); getResultCapture().pushScopedMessage( m_info );
} }
ScopedMessage::ScopedMessage( ScopedMessage const& other )
: m_info( other.m_info )
{}
ScopedMessage::~ScopedMessage() { ScopedMessage::~ScopedMessage() {
getResultCapture().popScopedMessage( m_info ); getResultCapture().popScopedMessage( m_info );
} }
@ -6737,14 +6777,14 @@ namespace Catch {
std::string const& name, std::string const& name,
std::string const& description ) std::string const& description )
: m_info( name, description, lineInfo ), : m_info( name, description, lineInfo ),
m_sectionIncluded( getCurrentContext().getResultCapture().sectionStarted( m_info, m_assertions ) ) m_sectionIncluded( getResultCapture().sectionStarted( m_info, m_assertions ) )
{ {
m_timer.start(); m_timer.start();
} }
Section::~Section() { Section::~Section() {
if( m_sectionIncluded ) if( m_sectionIncluded )
getCurrentContext().getResultCapture().sectionEnded( m_info, m_assertions, m_timer.getElapsedSeconds() ); getResultCapture().sectionEnded( m_info, m_assertions, m_timer.getElapsedSeconds() );
} }
// This indicates whether the section should be executed or not // This indicates whether the section should be executed or not
@ -7050,12 +7090,12 @@ namespace Catch {
struct BySectionInfo { struct BySectionInfo {
BySectionInfo( SectionInfo const& other ) : m_other( other ) {} BySectionInfo( SectionInfo const& other ) : m_other( other ) {}
BySectionInfo( BySectionInfo const& other ) : m_other( other.m_other ) {}
bool operator() ( Ptr<SectionNode> const& node ) const { bool operator() ( Ptr<SectionNode> const& node ) const {
return node->stats.sectionInfo.lineInfo == m_other.lineInfo; return node->stats.sectionInfo.lineInfo == m_other.lineInfo;
} }
private: private:
BySectionInfo& operator=( BySectionInfo const& other ); // = delete; void operator=( BySectionInfo const& );
SectionInfo const& m_other; SectionInfo const& m_other;
}; };
@ -7278,26 +7318,26 @@ namespace Catch {
endElement(); endElement();
} }
# ifndef CATCH_CPP11_OR_GREATER //# ifndef CATCH_CPP11_OR_GREATER
XmlWriter& operator = ( XmlWriter const& other ) { // XmlWriter& operator = ( XmlWriter const& other ) {
XmlWriter temp( other ); // XmlWriter temp( other );
swap( temp ); // swap( temp );
return *this; // return *this;
} // }
# else //# else
XmlWriter( XmlWriter const& ) = default; // XmlWriter( XmlWriter const& ) = default;
XmlWriter( XmlWriter && ) = default; // XmlWriter( XmlWriter && ) = default;
XmlWriter& operator = ( XmlWriter const& ) = default; // XmlWriter& operator = ( XmlWriter const& ) = default;
XmlWriter& operator = ( XmlWriter && ) = default; // XmlWriter& operator = ( XmlWriter && ) = default;
# endif //# endif
//
void swap( XmlWriter& other ) { // void swap( XmlWriter& other ) {
std::swap( m_tagIsOpen, other.m_tagIsOpen ); // std::swap( m_tagIsOpen, other.m_tagIsOpen );
std::swap( m_needsNewline, other.m_needsNewline ); // std::swap( m_needsNewline, other.m_needsNewline );
std::swap( m_tags, other.m_tags ); // std::swap( m_tags, other.m_tags );
std::swap( m_indent, other.m_indent ); // std::swap( m_indent, other.m_indent );
std::swap( m_os, other.m_os ); // std::swap( m_os, other.m_os );
} // }
XmlWriter& startElement( std::string const& name ) { XmlWriter& startElement( std::string const& name ) {
ensureTagClosed(); ensureTagClosed();
@ -7375,7 +7415,13 @@ namespace Catch {
return *this; return *this;
} }
void setStream( std::ostream& os ) {
m_os = &os;
}
private: private:
XmlWriter( XmlWriter const& );
void operator=( XmlWriter const& );
std::ostream& stream() { std::ostream& stream() {
return *m_os; return *m_os;
@ -7444,7 +7490,7 @@ namespace Catch {
} }
virtual void StartTesting() { virtual void StartTesting() {
m_xml = XmlWriter( m_config.stream() ); m_xml.setStream( m_config.stream() );
m_xml.startElement( "Catch" ); m_xml.startElement( "Catch" );
if( !m_config.fullConfig()->name().empty() ) if( !m_config.fullConfig()->name().empty() )
m_xml.writeAttribute( "name", m_config.fullConfig()->name() ); m_xml.writeAttribute( "name", m_config.fullConfig()->name() );
@ -8298,7 +8344,7 @@ namespace Catch {
private: private:
// Colour::LightGrey // Colour::LightGrey
static Colour dimColour() { return Colour::FileName; } static Colour::Code dimColour() { return Colour::FileName; }
#ifdef CATCH_PLATFORM_MAC #ifdef CATCH_PLATFORM_MAC
static const char* failedString() { return "FAILED"; } static const char* failedString() { return "FAILED"; }
@ -8313,7 +8359,7 @@ namespace Catch {
stream << result.getSourceInfo() << ":"; stream << result.getSourceInfo() << ":";
} }
void printResultType( Colour colour, std::string passOrFail ) const { void printResultType( Colour::Code colour, std::string passOrFail ) const {
if( !passOrFail.empty() ) { if( !passOrFail.empty() ) {
{ {
Colour colourGuard( colour ); Colour colourGuard( colour );
@ -8361,7 +8407,7 @@ namespace Catch {
} }
} }
void printRemainingMessages( Colour colour = dimColour() ) { void printRemainingMessages( Colour::Code colour = dimColour() ) {
if ( itMessage == messages.end() ) if ( itMessage == messages.end() )
return; return;
@ -8675,6 +8721,10 @@ int main (int argc, char * const argv[]) {
using Catch::Detail::Approx; using Catch::Detail::Approx;
// #included from: internal/catch_reenable_warnings.h
#define TWOBLUECUBES_CATCH_REENABLE_WARNINGS_H_INCLUDED
#ifdef __clang__ #ifdef __clang__
#pragma clang diagnostic pop #pragma clang diagnostic pop
#endif #endif