mirror of
https://github.com/catchorg/Catch2.git
synced 2024-11-26 15:26:11 +01:00
Restored quick way to add test programatically
This commit is contained in:
parent
f82d65fb41
commit
c682a163b1
@ -137,6 +137,12 @@ namespace Catch {
|
|||||||
m_streambuf = newBuf;
|
m_streambuf = newBuf;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void addTestSpec( const std::string& testSpec ) {
|
||||||
|
TestCaseFilters filters( testSpec );
|
||||||
|
filters.addFilter( TestCaseFilter( testSpec ) );
|
||||||
|
m_data.filters.push_back( filters );
|
||||||
|
}
|
||||||
|
|
||||||
virtual bool includeSuccessfulResults() const {
|
virtual bool includeSuccessfulResults() const {
|
||||||
return m_data.includeWhichResults == Include::SuccessfulResults;
|
return m_data.includeWhichResults == Include::SuccessfulResults;
|
||||||
}
|
}
|
||||||
|
@ -16,6 +16,7 @@
|
|||||||
namespace Catch {
|
namespace Catch {
|
||||||
|
|
||||||
struct IfFilterMatches{ enum DoWhat {
|
struct IfFilterMatches{ enum DoWhat {
|
||||||
|
AutoDetectBehaviour,
|
||||||
IncludeTests,
|
IncludeTests,
|
||||||
ExcludeTests
|
ExcludeTests
|
||||||
}; };
|
}; };
|
||||||
@ -29,11 +30,25 @@ namespace Catch {
|
|||||||
};
|
};
|
||||||
|
|
||||||
public:
|
public:
|
||||||
TestCaseFilter( const std::string& testSpec, IfFilterMatches::DoWhat matchBehaviour = IfFilterMatches::IncludeTests )
|
TestCaseFilter( const std::string& testSpec, IfFilterMatches::DoWhat matchBehaviour = IfFilterMatches::AutoDetectBehaviour )
|
||||||
: m_stringToMatch( testSpec ),
|
: m_stringToMatch( testSpec ),
|
||||||
m_filterType( matchBehaviour ),
|
m_filterType( matchBehaviour ),
|
||||||
m_wildcardPosition( NoWildcard )
|
m_wildcardPosition( NoWildcard )
|
||||||
{
|
{
|
||||||
|
if( m_filterType == IfFilterMatches::AutoDetectBehaviour ) {
|
||||||
|
if( startsWith( m_stringToMatch, "exclude:" ) ) {
|
||||||
|
m_stringToMatch = m_stringToMatch.substr( 8 );
|
||||||
|
m_filterType = IfFilterMatches::ExcludeTests;
|
||||||
|
}
|
||||||
|
else if( startsWith( m_stringToMatch, "~" ) ) {
|
||||||
|
m_stringToMatch = m_stringToMatch.substr( 1 );
|
||||||
|
m_filterType = IfFilterMatches::ExcludeTests;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
m_filterType = IfFilterMatches::IncludeTests;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if( m_stringToMatch[0] == '*' ) {
|
if( m_stringToMatch[0] == '*' ) {
|
||||||
m_stringToMatch = m_stringToMatch.substr( 1 );
|
m_stringToMatch = m_stringToMatch.substr( 1 );
|
||||||
m_wildcardPosition = (WildcardPosition)( m_wildcardPosition | WildcardAtStart );
|
m_wildcardPosition = (WildcardPosition)( m_wildcardPosition | WildcardAtStart );
|
||||||
|
Loading…
Reference in New Issue
Block a user