Small fixes and started new section tracking code

This commit is contained in:
Phil Nash
2013-07-23 08:15:34 +01:00
parent f3d1f08c3b
commit 372a6c6fed
8 changed files with 294 additions and 13 deletions

View File

@@ -62,8 +62,8 @@ namespace Catch {
std::map<std::string, IGeneratorsForTest*>::const_iterator it =
m_generatorsByTestName.find( testName );
return it != m_generatorsByTestName.end()
? it->second
: NULL;
? it->second
: NULL;
}
IGeneratorsForTest& getGeneratorsForCurrentTest() {

View File

@@ -123,7 +123,8 @@ namespace Catch {
Equals( NSString* substr ) : StringHolder( substr ){}
virtual bool match( ExpressionType const& str ) const {
return [str isEqualToString:m_substr];
return (str != nil || m_substr == nil ) &&
[str isEqualToString:m_substr];
}
virtual std::string toString() const {
@@ -135,7 +136,8 @@ namespace Catch {
Contains( NSString* substr ) : StringHolder( substr ){}
virtual bool match( ExpressionType const& str ) const {
return [str rangeOfString:m_substr].location != NSNotFound;
return (str != nil || m_substr == nil ) &&
[str rangeOfString:m_substr].location != NSNotFound;
}
virtual std::string toString() const {
@@ -147,7 +149,8 @@ namespace Catch {
StartsWith( NSString* substr ) : StringHolder( substr ){}
virtual bool match( ExpressionType const& str ) const {
return [str rangeOfString:m_substr].location == 0;
return (str != nil || m_substr == nil ) &&
[str rangeOfString:m_substr].location == 0;
}
virtual std::string toString() const {
@@ -158,7 +161,8 @@ namespace Catch {
EndsWith( NSString* substr ) : StringHolder( substr ){}
virtual bool match( ExpressionType const& str ) const {
return [str rangeOfString:m_substr].location == [str length] - [m_substr length];
return (str != nil || m_substr == nil ) &&
[str rangeOfString:m_substr].location == [str length] - [m_substr length];
}
virtual std::string toString() const {

View File

@@ -286,6 +286,8 @@ namespace Catch {
exResult << translateActiveException();
actOnCurrentResult( exResult.buildResult( m_lastAssertionInfo ) );
}
// If sections ended prematurely due to an exception we stored their
// infos here so we can tear them down outside the unwind process.
for( std::vector<UnfinishedSections>::const_iterator it = m_unfinishedSections.begin(),
itEnd = m_unfinishedSections.end();
it != itEnd;