2013-12-03 19:52:41 +01:00
|
|
|
/*
|
2014-05-16 19:28:58 +02:00
|
|
|
* Created by Phil on 14/8/2012.
|
|
|
|
* Copyright 2010 Two Blue Cubes Ltd. All rights reserved.
|
2013-12-03 19:52:41 +01:00
|
|
|
*
|
|
|
|
* 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_HPP_INCLUDED
|
|
|
|
#define TWOBLUECUBES_CATCH_TEST_SPEC_HPP_INCLUDED
|
|
|
|
|
2014-05-16 19:28:58 +02:00
|
|
|
#ifdef __clang__
|
|
|
|
#pragma clang diagnostic push
|
|
|
|
#pragma clang diagnostic ignored "-Wpadded"
|
|
|
|
#endif
|
2013-12-03 19:52:41 +01:00
|
|
|
|
2017-09-07 12:24:33 +02:00
|
|
|
#include "catch_wildcard_pattern.h"
|
2014-05-16 19:28:58 +02:00
|
|
|
#include "catch_test_case_info.h"
|
|
|
|
|
|
|
|
#include <string>
|
|
|
|
#include <vector>
|
2017-04-26 18:04:00 +02:00
|
|
|
#include <memory>
|
2014-05-16 19:28:58 +02:00
|
|
|
|
|
|
|
namespace Catch {
|
2015-11-04 19:01:28 +01:00
|
|
|
|
2014-05-16 19:28:58 +02:00
|
|
|
class TestSpec {
|
2017-04-25 22:01:40 +02:00
|
|
|
struct Pattern {
|
2017-09-07 16:51:33 +02:00
|
|
|
virtual ~Pattern();
|
2014-05-16 19:28:58 +02:00
|
|
|
virtual bool matches( TestCaseInfo const& testCase ) const = 0;
|
|
|
|
};
|
2017-04-25 22:01:40 +02:00
|
|
|
using PatternPtr = std::shared_ptr<Pattern>;
|
|
|
|
|
2014-05-16 19:28:58 +02:00
|
|
|
class NamePattern : public Pattern {
|
|
|
|
public:
|
2017-07-19 10:13:47 +02:00
|
|
|
NamePattern( std::string const& name );
|
2017-09-07 16:51:33 +02:00
|
|
|
virtual ~NamePattern();
|
2017-07-25 17:16:28 +02:00
|
|
|
virtual bool matches( TestCaseInfo const& testCase ) const override;
|
2014-05-16 19:28:58 +02:00
|
|
|
private:
|
2015-07-13 16:03:04 +02:00
|
|
|
WildcardPattern m_wildcardPattern;
|
2014-05-16 19:28:58 +02:00
|
|
|
};
|
2015-11-04 19:01:28 +01:00
|
|
|
|
2014-05-16 19:28:58 +02:00
|
|
|
class TagPattern : public Pattern {
|
|
|
|
public:
|
2017-07-19 10:13:47 +02:00
|
|
|
TagPattern( std::string const& tag );
|
2017-09-07 16:51:33 +02:00
|
|
|
virtual ~TagPattern();
|
2017-07-25 17:16:28 +02:00
|
|
|
virtual bool matches( TestCaseInfo const& testCase ) const override;
|
2014-05-16 19:28:58 +02:00
|
|
|
private:
|
|
|
|
std::string m_tag;
|
|
|
|
};
|
2015-11-04 19:01:28 +01:00
|
|
|
|
2014-05-16 19:28:58 +02:00
|
|
|
class ExcludedPattern : public Pattern {
|
|
|
|
public:
|
2017-07-19 10:13:47 +02:00
|
|
|
ExcludedPattern( PatternPtr const& underlyingPattern );
|
2017-09-07 16:51:33 +02:00
|
|
|
virtual ~ExcludedPattern();
|
2017-07-25 17:16:28 +02:00
|
|
|
virtual bool matches( TestCaseInfo const& testCase ) const override;
|
2014-05-16 19:28:58 +02:00
|
|
|
private:
|
2017-04-25 22:01:40 +02:00
|
|
|
PatternPtr m_underlyingPattern;
|
2014-05-16 19:28:58 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
struct Filter {
|
2017-04-25 22:01:40 +02:00
|
|
|
std::vector<PatternPtr> m_patterns;
|
2014-05-16 19:28:58 +02:00
|
|
|
|
2017-07-19 10:13:47 +02:00
|
|
|
bool matches( TestCaseInfo const& testCase ) const;
|
2014-05-16 19:28:58 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
public:
|
2017-07-19 10:13:47 +02:00
|
|
|
bool hasFilters() const;
|
|
|
|
bool matches( TestCaseInfo const& testCase ) const;
|
2014-05-16 19:28:58 +02:00
|
|
|
|
|
|
|
private:
|
|
|
|
std::vector<Filter> m_filters;
|
|
|
|
|
|
|
|
friend class TestSpecParser;
|
|
|
|
};
|
|
|
|
}
|
|
|
|
|
|
|
|
#ifdef __clang__
|
|
|
|
#pragma clang diagnostic pop
|
|
|
|
#endif
|
2013-12-03 19:52:41 +01:00
|
|
|
|
|
|
|
#endif // TWOBLUECUBES_CATCH_TEST_SPEC_HPP_INCLUDED
|