catch2/include/internal/catch_test_spec.h

66 lines
1.8 KiB
C
Raw Normal View History

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)
*/
#ifndef TWOBLUECUBES_CATCH_TEST_SPEC_H_INCLUDED
#define TWOBLUECUBES_CATCH_TEST_SPEC_H_INCLUDED
2012-08-14 20:35:30 +02:00
#include "catch_tags.h"
2012-08-14 20:35:30 +02:00
#include <string>
#include <vector>
2012-08-14 20:35:30 +02:00
namespace Catch {
class TestCase;
2012-08-23 21:08:50 +02:00
struct IfFilterMatches{ enum DoWhat {
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:
TestCaseFilter( std::string const& testSpec, IfFilterMatches::DoWhat matchBehaviour = IfFilterMatches::AutoDetectBehaviour );
2012-08-14 20:35:30 +02:00
IfFilterMatches::DoWhat getFilterType() const;
bool shouldInclude( TestCase const& testCase ) const;
2012-08-23 21:08:50 +02:00
private:
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:
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;
2012-08-23 21:08:50 +02:00
private:
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
}
#endif // TWOBLUECUBES_CATCH_TEST_SPEC_H_INCLUDED