diff options
| author | Phil Nash | 2013-03-12 18:47:53 +0000 |
|---|---|---|
| committer | Phil Nash | 2013-03-12 18:47:53 +0000 |
| commit | 17479c6e499996c220c71ce4e5bf17de7b7d248c (patch) | |
| tree | 98745e63da4d3594ae0cc91ea70f0676a2d3df04 /include | |
| parent | d78cfe127591bdd7d3effaaa782971aafd20a3f1 (diff) | |
| download | catch3-17479c6e499996c220c71ce4e5bf17de7b7d248c.tar.gz | |
Tag and test case name querying are now case insensitive
Diffstat (limited to 'include')
| -rw-r--r-- | include/internal/catch_common.h | 3 | ||||
| -rw-r--r-- | include/internal/catch_tags.hpp | 10 | ||||
| -rw-r--r-- | include/internal/catch_test_spec.h | 6 |
3 files changed, 16 insertions, 3 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: |