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

Tag and test case name querying are now case insensitive

Commit
17479c6e499996c220c71ce4e5bf17de7b7d248c
Author
Phil Nash ·
Parents
d78cfe127591

Files · Download .tar.gz

Changes

 include/internal/catch_common.h                          |  3 +++
 include/internal/catch_tags.hpp                          | 10 ++++++++--
 include/internal/catch_test_spec.h                       |  6 +++++-
 projects/XCode4/CatchSelfTest/CatchSelfTest/BDDTests.cpp |  3 +--
 4 files changed, 17 insertions(+), 5 deletions(-)

diff --git a/include/internal/catch_common.h b/include/internal/catch_common.h
index 55acbd4f..e06796b8 100644
--- a/include/internal/catch_common.h
+++ b/include/internal/catch_common.h
@@ -80,6 +80,9 @@ namespace Catch {
     inline bool contains( const std::string& s, const std::string& infix ) {
         return s.find( infix ) != std::string::npos;
     }
+    inline void toLower( std::string& s ) {
+        std::transform( s.begin(), s.end(), s.begin(), ::tolower );
+    }
 
     struct pluralise {
         pluralise( std::size_t count, const std::string& label )
diff --git a/include/internal/catch_tags.hpp b/include/internal/catch_tags.hpp
index 510bff3c..15c3c3d8 100644
--- a/include/internal/catch_tags.hpp
+++ b/include/internal/catch_tags.hpp
@@ -8,6 +8,8 @@
 #ifndef TWOBLUECUBES_CATCH_TAGS_HPP_INCLUDED
 #define TWOBLUECUBES_CATCH_TAGS_HPP_INCLUDED
 
+#include "catch_common.h"
+
 #include <string>
 #include <set>
 #include <map>
@@ -68,7 +70,9 @@ namespace Catch {
 
     private:
         virtual void acceptTag( const std::string& tag ) {
-            m_tags.insert( tag );
+            std::string lcTag = tag;
+            toLower( lcTag );
+            m_tags.insert( lcTag );
         }
         virtual void acceptChar( char c ) {
             m_remainder += c;
@@ -111,7 +115,9 @@ namespace Catch {
         typedef std::map<std::string, Tag> TagMap;
     public:
         void add( const Tag& tag ) {
-            m_tags.insert( std::make_pair( tag.getName(), tag ) );
+            std::string tagName = tag.getName();
+            toLower( tagName );
+            m_tags.insert( std::make_pair( tagName, tag ) );
         }
 
         bool empty() const {
diff --git a/include/internal/catch_test_spec.h b/include/internal/catch_test_spec.h
index 3a30c4ea..ab1895ac 100644
--- a/include/internal/catch_test_spec.h
+++ b/include/internal/catch_test_spec.h
@@ -10,6 +10,7 @@
 
 #include "catch_test_case_info.h"
 #include "catch_tags.hpp"
+#include "catch_common.h"
 
 #include <string>
 #include <vector>
@@ -36,6 +37,8 @@ namespace Catch {
             m_filterType( matchBehaviour ),
             m_wildcardPosition( NoWildcard )
         {
+            toLower( m_stringToMatch );
+
             if( m_filterType == IfFilterMatches::AutoDetectBehaviour ) {
                 if( startsWith( m_stringToMatch, "exclude:" ) ) {
                     m_stringToMatch = m_stringToMatch.substr( 8 );
@@ -75,7 +78,8 @@ namespace Catch {
 #endif
 
         bool isMatch( const TestCase& testCase ) const {
-            const std::string& name = testCase.getTestCaseInfo().name;
+            std::string name = testCase.getTestCaseInfo().name;
+            toLower( name );
 
             switch( m_wildcardPosition ) {
                 case NoWildcard:
diff --git a/projects/XCode4/CatchSelfTest/CatchSelfTest/BDDTests.cpp b/projects/XCode4/CatchSelfTest/CatchSelfTest/BDDTests.cpp
index e9971bd3..76cae47a 100644
--- a/projects/XCode4/CatchSelfTest/CatchSelfTest/BDDTests.cpp
+++ b/projects/XCode4/CatchSelfTest/CatchSelfTest/BDDTests.cpp
@@ -23,7 +23,7 @@
 inline bool itDoesThis(){ return true; }
 inline bool itDoesThat(){ return true; }
 
-SCENARIO( "Do that thing with the thing", "[tags]" ) {
+SCENARIO( "Do that thing with the thing", "[Tags]" ) {
     GIVEN( "This stuff exists" ) {
         // make stuff exist
         WHEN( "I do this" ) {
@@ -35,6 +35,5 @@ SCENARIO( "Do that thing with the thing", "[tags]" ) {
                     REQUIRE( itDoesThat() );
             }
         }
-        
     }
 }