catch2/include/internal/catch_test_spec.hpp

81 lines
2.2 KiB
C++
Raw Normal View History

/*
* 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_HPP_INCLUDED
#define TWOBLUECUBES_CATCH_TEST_SPEC_HPP_INCLUDED
#ifdef __clang__
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wpadded"
#endif
#include "catch_wildcard_pattern.hpp"
#include "catch_test_case_info.h"
#include <string>
#include <vector>
2017-04-26 18:04:00 +02:00
#include <memory>
namespace Catch {
class TestSpec {
2017-04-25 22:01:40 +02:00
struct Pattern {
2017-07-19 10:13:47 +02:00
virtual ~Pattern() = default;
virtual bool matches( TestCaseInfo const& testCase ) const = 0;
};
2017-04-25 22:01:40 +02:00
using PatternPtr = std::shared_ptr<Pattern>;
class NamePattern : public Pattern {
public:
2017-07-19 10:13:47 +02:00
NamePattern( std::string const& name );
virtual ~NamePattern() = default;
virtual bool matches( TestCaseInfo const& testCase ) const override;
private:
WildcardPattern m_wildcardPattern;
};
class TagPattern : public Pattern {
public:
2017-07-19 10:13:47 +02:00
TagPattern( std::string const& tag );
virtual ~TagPattern() = default;
virtual bool matches( TestCaseInfo const& testCase ) const override;
private:
std::string m_tag;
};
class ExcludedPattern : public Pattern {
public:
2017-07-19 10:13:47 +02:00
ExcludedPattern( PatternPtr const& underlyingPattern );
virtual ~ExcludedPattern() = default;
virtual bool matches( TestCaseInfo const& testCase ) const override;
private:
2017-04-25 22:01:40 +02:00
PatternPtr m_underlyingPattern;
};
struct Filter {
2017-04-25 22:01:40 +02:00
std::vector<PatternPtr> m_patterns;
2017-07-19 10:13:47 +02:00
bool matches( TestCaseInfo const& testCase ) const;
};
public:
2017-07-19 10:13:47 +02:00
bool hasFilters() const;
bool matches( TestCaseInfo const& testCase ) const;
private:
std::vector<Filter> m_filters;
friend class TestSpecParser;
};
}
#ifdef __clang__
#pragma clang diagnostic pop
#endif
#endif // TWOBLUECUBES_CATCH_TEST_SPEC_HPP_INCLUDED