Progmasoft Git

catch3

Progmasoft Catch3: an independently maintained C++17 test framework with a parallel runner, property checks, snapshots and structured results.

Clonegit clone https://git.progmasoft.com/catch3

Fix for comma separated tags on the command line

- also added more test for tags
Commit
41b27af45be6bf2990f473495418c0a104f380e6
Author
Phil Nash ·
Parents
649cd13c4d8d

Files · Download .tar.gz

Changes

 include/internal/catch_tags.hpp | 15 +++++++++------
 projects/SelfTest/TestMain.cpp  | 11 ++++++++++-
 2 files changed, 19 insertions(+), 7 deletions(-)

diff --git a/include/internal/catch_tags.hpp b/include/internal/catch_tags.hpp
index 4e7bd5a3..36ecd1d6 100644
--- a/include/internal/catch_tags.hpp
+++ b/include/internal/catch_tags.hpp
@@ -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;
             }
         }
diff --git a/projects/SelfTest/TestMain.cpp b/projects/SelfTest/TestMain.cpp
index 6ee07fb7..aae3f53b 100644
--- a/projects/SelfTest/TestMain.cpp
+++ b/projects/SelfTest/TestMain.cpp
@@ -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", "" ) {