mirror of
https://github.com/catchorg/Catch2.git
synced 2024-11-30 01:03:30 +01:00
Fixed issue with wildcards at the start of a string
This commit is contained in:
parent
b5d1cfe441
commit
fcf0deb116
@ -36,7 +36,7 @@ namespace Catch {
|
|||||||
public:
|
public:
|
||||||
NamePattern( std::string const& name ) : m_name( toLower( name ) ), m_wildcard( NoWildcard ) {
|
NamePattern( std::string const& name ) : m_name( toLower( name ) ), m_wildcard( NoWildcard ) {
|
||||||
if( startsWith( m_name, "*" ) ) {
|
if( startsWith( m_name, "*" ) ) {
|
||||||
m_name = name.substr( 1 );
|
m_name = m_name.substr( 1 );
|
||||||
m_wildcard = WildcardAtStart;
|
m_wildcard = WildcardAtStart;
|
||||||
}
|
}
|
||||||
if( endsWith( m_name, "*" ) ) {
|
if( endsWith( m_name, "*" ) ) {
|
||||||
|
@ -92,6 +92,32 @@ TEST_CASE( "Parse test names and tags", "" ) {
|
|||||||
CHECK( spec.matches( tcD ) == true );
|
CHECK( spec.matches( tcD ) == true );
|
||||||
CHECK( parseTestSpec( "*a*" ).matches( tcA ) == true );
|
CHECK( parseTestSpec( "*a*" ).matches( tcA ) == true );
|
||||||
}
|
}
|
||||||
|
SECTION( "Redundant wildcard at the start" ) {
|
||||||
|
TestSpec spec = parseTestSpec( "*a" );
|
||||||
|
CHECK( spec.hasFilters() == true );
|
||||||
|
CHECK( spec.matches( tcA ) == true );
|
||||||
|
CHECK( spec.matches( tcB ) == false );
|
||||||
|
}
|
||||||
|
SECTION( "Redundant wildcard at the end" ) {
|
||||||
|
TestSpec spec = parseTestSpec( "a*" );
|
||||||
|
CHECK( spec.hasFilters() == true );
|
||||||
|
CHECK( spec.matches( tcA ) == true );
|
||||||
|
CHECK( spec.matches( tcB ) == false );
|
||||||
|
}
|
||||||
|
SECTION( "Redundant wildcard at both ends" ) {
|
||||||
|
TestSpec spec = parseTestSpec( "*a*" );
|
||||||
|
CHECK( spec.hasFilters() == true );
|
||||||
|
CHECK( spec.matches( tcA ) == true );
|
||||||
|
CHECK( spec.matches( tcB ) == false );
|
||||||
|
}
|
||||||
|
SECTION( "Wildcard at both ends, redundant at start" ) {
|
||||||
|
TestSpec spec = parseTestSpec( "*longer*" );
|
||||||
|
CHECK( spec.hasFilters() == true );
|
||||||
|
CHECK( spec.matches( tcA ) == false );
|
||||||
|
CHECK( spec.matches( tcB ) == false );
|
||||||
|
CHECK( spec.matches( tcC ) == true );
|
||||||
|
CHECK( spec.matches( tcD ) == true );
|
||||||
|
}
|
||||||
SECTION( "Just wildcard" ) {
|
SECTION( "Just wildcard" ) {
|
||||||
TestSpec spec = parseTestSpec( "*" );
|
TestSpec spec = parseTestSpec( "*" );
|
||||||
CHECK( spec.hasFilters() == true );
|
CHECK( spec.hasFilters() == true );
|
||||||
|
Loading…
Reference in New Issue
Block a user