2012-08-14 20:35:30 +02:00
|
|
|
/*
|
|
|
|
* Created by Phil on 14/8/2012.
|
|
|
|
* Copyright 2010 Two Blue Cubes Ltd. All rights reserved.
|
|
|
|
*
|
|
|
|
* Distributed under the Boost Software License, Version 1.0. (See accompanying
|
|
|
|
* file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
|
|
|
|
*/
|
2012-09-17 07:42:29 +02:00
|
|
|
#ifndef TWOBLUECUBES_CATCH_TEST_SPEC_H_INCLUDED
|
|
|
|
#define TWOBLUECUBES_CATCH_TEST_SPEC_H_INCLUDED
|
2012-08-14 20:35:30 +02:00
|
|
|
|
2013-12-03 19:52:41 +01:00
|
|
|
#include "catch_tags.h"
|
2012-08-28 09:20:18 +02:00
|
|
|
|
2012-08-14 20:35:30 +02:00
|
|
|
#include <string>
|
2012-08-28 09:20:18 +02:00
|
|
|
#include <vector>
|
2012-08-14 20:35:30 +02:00
|
|
|
|
|
|
|
namespace Catch {
|
2013-07-03 20:14:59 +02:00
|
|
|
|
2013-12-03 19:52:41 +01:00
|
|
|
class TestCase;
|
|
|
|
|
2012-08-23 21:08:50 +02:00
|
|
|
struct IfFilterMatches{ enum DoWhat {
|
2012-09-07 18:52:15 +02:00
|
|
|
AutoDetectBehaviour,
|
2012-08-23 21:08:50 +02:00
|
|
|
IncludeTests,
|
|
|
|
ExcludeTests
|
|
|
|
}; };
|
2012-08-14 20:35:30 +02:00
|
|
|
|
2012-08-23 21:08:50 +02:00
|
|
|
class TestCaseFilter {
|
2012-08-24 09:23:50 +02:00
|
|
|
enum WildcardPosition {
|
|
|
|
NoWildcard = 0,
|
|
|
|
WildcardAtStart = 1,
|
|
|
|
WildcardAtEnd = 2,
|
|
|
|
WildcardAtBothEnds = WildcardAtStart | WildcardAtEnd
|
|
|
|
};
|
2013-03-25 09:46:48 +01:00
|
|
|
|
2012-08-14 20:35:30 +02:00
|
|
|
public:
|
2013-12-03 19:52:41 +01:00
|
|
|
TestCaseFilter( std::string const& testSpec, IfFilterMatches::DoWhat matchBehaviour = IfFilterMatches::AutoDetectBehaviour );
|
2012-08-14 20:35:30 +02:00
|
|
|
|
2013-12-03 19:52:41 +01:00
|
|
|
IfFilterMatches::DoWhat getFilterType() const;
|
|
|
|
bool shouldInclude( TestCase const& testCase ) const;
|
2013-07-03 20:14:59 +02:00
|
|
|
|
2012-08-23 21:08:50 +02:00
|
|
|
private:
|
2013-12-03 19:52:41 +01:00
|
|
|
bool isMatch( TestCase const& testCase ) const;
|
2012-08-27 22:48:15 +02:00
|
|
|
|
2012-08-24 09:23:50 +02:00
|
|
|
std::string m_stringToMatch;
|
2012-08-23 21:08:50 +02:00
|
|
|
IfFilterMatches::DoWhat m_filterType;
|
2012-08-24 09:23:50 +02:00
|
|
|
WildcardPosition m_wildcardPosition;
|
2012-08-14 20:35:30 +02:00
|
|
|
};
|
2012-08-23 21:08:50 +02:00
|
|
|
|
|
|
|
class TestCaseFilters {
|
|
|
|
public:
|
2013-12-03 19:52:41 +01:00
|
|
|
TestCaseFilters( std::string const& name );
|
|
|
|
std::string getName() const;
|
|
|
|
void addFilter( TestCaseFilter const& filter );
|
|
|
|
void addTags( std::string const& tagPattern );
|
|
|
|
bool shouldInclude( TestCase const& testCase ) const;
|
2013-07-03 20:14:59 +02:00
|
|
|
|
2012-08-23 21:08:50 +02:00
|
|
|
private:
|
2012-09-26 19:38:26 +02:00
|
|
|
std::vector<TagExpression> m_tagExpressions;
|
2012-08-23 21:08:50 +02:00
|
|
|
std::vector<TestCaseFilter> m_inclusionFilters;
|
|
|
|
std::vector<TestCaseFilter> m_exclusionFilters;
|
|
|
|
std::string m_name;
|
|
|
|
};
|
|
|
|
|
2012-08-14 20:35:30 +02:00
|
|
|
}
|
|
|
|
|
2012-09-17 07:42:29 +02:00
|
|
|
#endif // TWOBLUECUBES_CATCH_TEST_SPEC_H_INCLUDED
|