mirror of
https://github.com/catchorg/Catch2.git
synced 2024-11-22 21:36:11 +01:00
Tag and test case name querying are now case insensitive
This commit is contained in:
parent
d78cfe1275
commit
17479c6e49
@ -80,6 +80,9 @@ namespace Catch {
|
|||||||
inline bool contains( const std::string& s, const std::string& infix ) {
|
inline bool contains( const std::string& s, const std::string& infix ) {
|
||||||
return s.find( infix ) != std::string::npos;
|
return s.find( infix ) != std::string::npos;
|
||||||
}
|
}
|
||||||
|
inline void toLower( std::string& s ) {
|
||||||
|
std::transform( s.begin(), s.end(), s.begin(), ::tolower );
|
||||||
|
}
|
||||||
|
|
||||||
struct pluralise {
|
struct pluralise {
|
||||||
pluralise( std::size_t count, const std::string& label )
|
pluralise( std::size_t count, const std::string& label )
|
||||||
|
@ -8,6 +8,8 @@
|
|||||||
#ifndef TWOBLUECUBES_CATCH_TAGS_HPP_INCLUDED
|
#ifndef TWOBLUECUBES_CATCH_TAGS_HPP_INCLUDED
|
||||||
#define TWOBLUECUBES_CATCH_TAGS_HPP_INCLUDED
|
#define TWOBLUECUBES_CATCH_TAGS_HPP_INCLUDED
|
||||||
|
|
||||||
|
#include "catch_common.h"
|
||||||
|
|
||||||
#include <string>
|
#include <string>
|
||||||
#include <set>
|
#include <set>
|
||||||
#include <map>
|
#include <map>
|
||||||
@ -68,7 +70,9 @@ namespace Catch {
|
|||||||
|
|
||||||
private:
|
private:
|
||||||
virtual void acceptTag( const std::string& tag ) {
|
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 ) {
|
virtual void acceptChar( char c ) {
|
||||||
m_remainder += c;
|
m_remainder += c;
|
||||||
@ -111,7 +115,9 @@ namespace Catch {
|
|||||||
typedef std::map<std::string, Tag> TagMap;
|
typedef std::map<std::string, Tag> TagMap;
|
||||||
public:
|
public:
|
||||||
void add( const Tag& tag ) {
|
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 {
|
bool empty() const {
|
||||||
|
@ -10,6 +10,7 @@
|
|||||||
|
|
||||||
#include "catch_test_case_info.h"
|
#include "catch_test_case_info.h"
|
||||||
#include "catch_tags.hpp"
|
#include "catch_tags.hpp"
|
||||||
|
#include "catch_common.h"
|
||||||
|
|
||||||
#include <string>
|
#include <string>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
@ -36,6 +37,8 @@ namespace Catch {
|
|||||||
m_filterType( matchBehaviour ),
|
m_filterType( matchBehaviour ),
|
||||||
m_wildcardPosition( NoWildcard )
|
m_wildcardPosition( NoWildcard )
|
||||||
{
|
{
|
||||||
|
toLower( m_stringToMatch );
|
||||||
|
|
||||||
if( m_filterType == IfFilterMatches::AutoDetectBehaviour ) {
|
if( m_filterType == IfFilterMatches::AutoDetectBehaviour ) {
|
||||||
if( startsWith( m_stringToMatch, "exclude:" ) ) {
|
if( startsWith( m_stringToMatch, "exclude:" ) ) {
|
||||||
m_stringToMatch = m_stringToMatch.substr( 8 );
|
m_stringToMatch = m_stringToMatch.substr( 8 );
|
||||||
@ -75,7 +78,8 @@ namespace Catch {
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
bool isMatch( const TestCase& testCase ) const {
|
bool isMatch( const TestCase& testCase ) const {
|
||||||
const std::string& name = testCase.getTestCaseInfo().name;
|
std::string name = testCase.getTestCaseInfo().name;
|
||||||
|
toLower( name );
|
||||||
|
|
||||||
switch( m_wildcardPosition ) {
|
switch( m_wildcardPosition ) {
|
||||||
case NoWildcard:
|
case NoWildcard:
|
||||||
|
@ -23,7 +23,7 @@
|
|||||||
inline bool itDoesThis(){ return true; }
|
inline bool itDoesThis(){ return true; }
|
||||||
inline bool itDoesThat(){ 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" ) {
|
GIVEN( "This stuff exists" ) {
|
||||||
// make stuff exist
|
// make stuff exist
|
||||||
WHEN( "I do this" ) {
|
WHEN( "I do this" ) {
|
||||||
@ -35,6 +35,5 @@ SCENARIO( "Do that thing with the thing", "[tags]" ) {
|
|||||||
REQUIRE( itDoesThat() );
|
REQUIRE( itDoesThat() );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user