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 {
|
||||
TagMap::const_iterator it = m_tags.begin();
|
||||
TagMap::const_iterator itEnd = m_tags.end();
|
||||
for(; it != itEnd; ++it ) {
|
||||
for( TagMap::const_iterator
|
||||
it = m_tags.begin(), itEnd = m_tags.end();
|
||||
it != itEnd;
|
||||
++it ) {
|
||||
bool found = tags.find( it->first ) != tags.end();
|
||||
if( found == it->second.isNegated() )
|
||||
return false;
|
||||
@ -138,9 +139,10 @@ namespace Catch {
|
||||
class TagExpression {
|
||||
public:
|
||||
bool matches( std::set<std::string> const& tags ) const {
|
||||
std::vector<TagSet>::const_iterator it = m_tagSets.begin();
|
||||
std::vector<TagSet>::const_iterator itEnd = m_tagSets.end();
|
||||
for(; it != itEnd; ++it )
|
||||
for( std::vector<TagSet>::const_iterator
|
||||
it = m_tagSets.begin(), itEnd = m_tagSets.end();
|
||||
it != itEnd;
|
||||
++it )
|
||||
if( it->matches( tags ) )
|
||||
return true;
|
||||
return false;
|
||||
@ -173,6 +175,7 @@ namespace Catch {
|
||||
break;
|
||||
case ',':
|
||||
m_exp.m_tagSets.push_back( m_currentTagSet );
|
||||
m_currentTagSet = TagSet();
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
@ -86,7 +86,7 @@ std::string parseIntoConfigAndReturnError( const char * (&argv)[size], Catch::Co
|
||||
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]" ) {
|
||||
|
||||
@ -336,6 +336,15 @@ TEST_CASE( "selftest/tags", "" ) {
|
||||
CHECK( twoTags.matchesTags( p4 ) == 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", "" ) {
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user