mirror of
https://github.com/catchorg/Catch2.git
synced 2025-01-11 12:23:30 +01:00
migrated Pattern to std::shared_ptr
This commit is contained in:
parent
0807a6910f
commit
851e40a4bb
@ -22,10 +22,12 @@
|
|||||||
namespace Catch {
|
namespace Catch {
|
||||||
|
|
||||||
class TestSpec {
|
class TestSpec {
|
||||||
struct Pattern : SharedImpl<> {
|
struct Pattern {
|
||||||
virtual ~Pattern();
|
virtual ~Pattern();
|
||||||
virtual bool matches( TestCaseInfo const& testCase ) const = 0;
|
virtual bool matches( TestCaseInfo const& testCase ) const = 0;
|
||||||
};
|
};
|
||||||
|
using PatternPtr = std::shared_ptr<Pattern>;
|
||||||
|
|
||||||
class NamePattern : public Pattern {
|
class NamePattern : public Pattern {
|
||||||
public:
|
public:
|
||||||
NamePattern( std::string const& name )
|
NamePattern( std::string const& name )
|
||||||
@ -52,15 +54,15 @@ namespace Catch {
|
|||||||
|
|
||||||
class ExcludedPattern : public Pattern {
|
class ExcludedPattern : public Pattern {
|
||||||
public:
|
public:
|
||||||
ExcludedPattern( Ptr<Pattern> const& underlyingPattern ) : m_underlyingPattern( underlyingPattern ) {}
|
ExcludedPattern( PatternPtr const& underlyingPattern ) : m_underlyingPattern( underlyingPattern ) {}
|
||||||
virtual ~ExcludedPattern();
|
virtual ~ExcludedPattern();
|
||||||
virtual bool matches( TestCaseInfo const& testCase ) const { return !m_underlyingPattern->matches( testCase ); }
|
virtual bool matches( TestCaseInfo const& testCase ) const { return !m_underlyingPattern->matches( testCase ); }
|
||||||
private:
|
private:
|
||||||
Ptr<Pattern> m_underlyingPattern;
|
PatternPtr m_underlyingPattern;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct Filter {
|
struct Filter {
|
||||||
std::vector<Ptr<Pattern> > m_patterns;
|
std::vector<PatternPtr> m_patterns;
|
||||||
|
|
||||||
bool matches( TestCaseInfo const& testCase ) const {
|
bool matches( TestCaseInfo const& testCase ) const {
|
||||||
// All patterns in a filter must match for the filter to be a match
|
// All patterns in a filter must match for the filter to be a match
|
||||||
|
@ -104,9 +104,9 @@ namespace Catch {
|
|||||||
token = token.substr( 8 );
|
token = token.substr( 8 );
|
||||||
}
|
}
|
||||||
if( !token.empty() ) {
|
if( !token.empty() ) {
|
||||||
Ptr<TestSpec::Pattern> pattern = new T( token );
|
TestSpec::PatternPtr pattern = std::make_shared<T>( token );
|
||||||
if( m_exclusion )
|
if( m_exclusion )
|
||||||
pattern = new TestSpec::ExcludedPattern( pattern );
|
pattern = std::make_shared<TestSpec::ExcludedPattern>( pattern );
|
||||||
m_currentFilter.m_patterns.push_back( pattern );
|
m_currentFilter.m_patterns.push_back( pattern );
|
||||||
}
|
}
|
||||||
m_exclusion = false;
|
m_exclusion = false;
|
||||||
|
Loading…
Reference in New Issue
Block a user