mirror of
https://github.com/catchorg/Catch2.git
synced 2024-11-22 21:36:11 +01:00
Fix for comma separated tags on the command line
- also added more test for tags
This commit is contained in:
parent
649cd13c4d
commit
41b27af45b
@ -121,9 +121,10 @@ namespace Catch {
|
|||||||
}
|
}
|
||||||
|
|
||||||
bool matches( std::set<std::string> const& tags ) const {
|
bool matches( std::set<std::string> const& tags ) const {
|
||||||
TagMap::const_iterator it = m_tags.begin();
|
for( TagMap::const_iterator
|
||||||
TagMap::const_iterator itEnd = m_tags.end();
|
it = m_tags.begin(), itEnd = m_tags.end();
|
||||||
for(; it != itEnd; ++it ) {
|
it != itEnd;
|
||||||
|
++it ) {
|
||||||
bool found = tags.find( it->first ) != tags.end();
|
bool found = tags.find( it->first ) != tags.end();
|
||||||
if( found == it->second.isNegated() )
|
if( found == it->second.isNegated() )
|
||||||
return false;
|
return false;
|
||||||
@ -138,9 +139,10 @@ namespace Catch {
|
|||||||
class TagExpression {
|
class TagExpression {
|
||||||
public:
|
public:
|
||||||
bool matches( std::set<std::string> const& tags ) const {
|
bool matches( std::set<std::string> const& tags ) const {
|
||||||
std::vector<TagSet>::const_iterator it = m_tagSets.begin();
|
for( std::vector<TagSet>::const_iterator
|
||||||
std::vector<TagSet>::const_iterator itEnd = m_tagSets.end();
|
it = m_tagSets.begin(), itEnd = m_tagSets.end();
|
||||||
for(; it != itEnd; ++it )
|
it != itEnd;
|
||||||
|
++it )
|
||||||
if( it->matches( tags ) )
|
if( it->matches( tags ) )
|
||||||
return true;
|
return true;
|
||||||
return false;
|
return false;
|
||||||
@ -173,6 +175,7 @@ namespace Catch {
|
|||||||
break;
|
break;
|
||||||
case ',':
|
case ',':
|
||||||
m_exp.m_tagSets.push_back( m_currentTagSet );
|
m_exp.m_tagSets.push_back( m_currentTagSet );
|
||||||
|
m_currentTagSet = TagSet();
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -86,7 +86,7 @@ std::string parseIntoConfigAndReturnError( const char * (&argv)[size], Catch::Co
|
|||||||
return "";
|
return "";
|
||||||
}
|
}
|
||||||
|
|
||||||
inline Catch::TestCase fakeTestCase( const char* name ){ return Catch::makeTestCase( NULL, "", name, "", CATCH_INTERNAL_LINEINFO ); }
|
inline Catch::TestCase fakeTestCase( const char* name, const char* desc = "" ){ return Catch::makeTestCase( NULL, "", name, desc, CATCH_INTERNAL_LINEINFO ); }
|
||||||
|
|
||||||
TEST_CASE( "Process can be configured on command line", "[config][command-line]" ) {
|
TEST_CASE( "Process can be configured on command line", "[config][command-line]" ) {
|
||||||
|
|
||||||
@ -336,6 +336,15 @@ TEST_CASE( "selftest/tags", "" ) {
|
|||||||
CHECK( twoTags.matchesTags( p4 ) == true );
|
CHECK( twoTags.matchesTags( p4 ) == true );
|
||||||
CHECK( twoTags.matchesTags( p5 ) == true );
|
CHECK( twoTags.matchesTags( p5 ) == true );
|
||||||
}
|
}
|
||||||
|
SECTION( "complex", "" ) {
|
||||||
|
CHECK( fakeTestCase( "test", "[one][.]" ).matchesTags( p1 ) );
|
||||||
|
CHECK_FALSE( fakeTestCase( "test", "[one][.]" ).matchesTags( p5 ) );
|
||||||
|
CHECK( fakeTestCase( "test", "[three]" ).matchesTags( p4 ) );
|
||||||
|
CHECK( fakeTestCase( "test", "[three]" ).matchesTags( p5 ) );
|
||||||
|
CHECK( fakeTestCase( "test", "[three]" ).matchesTags( "[three]~[one]" ) );
|
||||||
|
CHECK( fakeTestCase( "test", "[unit][not_apple]" ).matchesTags( "[unit]" ) );
|
||||||
|
CHECK_FALSE( fakeTestCase( "test", "[unit][not_apple]" ).matchesTags( "[unit]~[not_apple]" ) );
|
||||||
|
}
|
||||||
|
|
||||||
SECTION( "one tag with characters either side", "" ) {
|
SECTION( "one tag with characters either side", "" ) {
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user