1 /*
2  *  Created by Phil on 14/8/2012.
3  *  Copyright 2010 Two Blue Cubes Ltd. All rights reserved.
4  *
5  *  Distributed under the Boost Software License, Version 1.0. (See accompanying
6  *  file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
7  */
8 #ifndef TWOBLUECUBES_CATCH_TEST_SPEC_HPP_INCLUDED
9 #define TWOBLUECUBES_CATCH_TEST_SPEC_HPP_INCLUDED
10 
11 #ifdef __clang__
12 #pragma clang diagnostic push
13 #pragma clang diagnostic ignored "-Wpadded"
14 #endif
15 
16 #include "catch_wildcard_pattern.h"
17 #include "catch_test_case_info.h"
18 
19 #include <string>
20 #include <vector>
21 #include <memory>
22 
23 namespace Catch {
24 
25     class TestSpec {
26         struct Pattern {
27             virtual ~Pattern();
28             virtual bool matches( TestCaseInfo const& testCase ) const = 0;
29         };
30         using PatternPtr = std::shared_ptr<Pattern>;
31 
32         class NamePattern : public Pattern {
33         public:
34             NamePattern( std::string const& name );
35             virtual ~NamePattern();
36             virtual bool matches( TestCaseInfo const& testCase ) const override;
37         private:
38             WildcardPattern m_wildcardPattern;
39         };
40 
41         class TagPattern : public Pattern {
42         public:
43             TagPattern( std::string const& tag );
44             virtual ~TagPattern();
45             virtual bool matches( TestCaseInfo const& testCase ) const override;
46         private:
47             std::string m_tag;
48         };
49 
50         class ExcludedPattern : public Pattern {
51         public:
52             ExcludedPattern( PatternPtr const& underlyingPattern );
53             virtual ~ExcludedPattern();
54             virtual bool matches( TestCaseInfo const& testCase ) const override;
55         private:
56             PatternPtr m_underlyingPattern;
57         };
58 
59         struct Filter {
60             std::vector<PatternPtr> m_patterns;
61 
62             bool matches( TestCaseInfo const& testCase ) const;
63         };
64 
65     public:
66         bool hasFilters() const;
67         bool matches( TestCaseInfo const& testCase ) const;
68 
69     private:
70         std::vector<Filter> m_filters;
71 
72         friend class TestSpecParser;
73     };
74 }
75 
76 #ifdef __clang__
77 #pragma clang diagnostic pop
78 #endif
79 
80 #endif // TWOBLUECUBES_CATCH_TEST_SPEC_HPP_INCLUDED
81