Wire Sysio Wire Sysion 1.0.0
Loading...
Searching...
No Matches
catch_test_spec.cpp
Go to the documentation of this file.
1/*
2 * Created by Martin on 19/07/2017.
3 *
4 * Distributed under the Boost Software License, Version 1.0. (See accompanying
5 * file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
6 */
7
8#include "catch_test_spec.h"
10
11#include <algorithm>
12#include <string>
13#include <vector>
14#include <memory>
15
16namespace Catch {
17
18 TestSpec::Pattern::~Pattern() = default;
19 TestSpec::NamePattern::~NamePattern() = default;
20 TestSpec::TagPattern::~TagPattern() = default;
21 TestSpec::ExcludedPattern::~ExcludedPattern() = default;
22
23 TestSpec::NamePattern::NamePattern( std::string const& name )
24 : m_wildcardPattern( toLower( name ), CaseSensitive::No )
25 {}
26 bool TestSpec::NamePattern::matches( TestCaseInfo const& testCase ) const {
27 return m_wildcardPattern.matches( toLower( testCase.name ) );
28 }
29
30 TestSpec::TagPattern::TagPattern( std::string const& tag ) : m_tag( toLower( tag ) ) {}
31 bool TestSpec::TagPattern::matches( TestCaseInfo const& testCase ) const {
32 return std::find(begin(testCase.lcaseTags),
33 end(testCase.lcaseTags),
34 m_tag) != end(testCase.lcaseTags);
35 }
36
37 TestSpec::ExcludedPattern::ExcludedPattern( PatternPtr const& underlyingPattern ) : m_underlyingPattern( underlyingPattern ) {}
38 bool TestSpec::ExcludedPattern::matches( TestCaseInfo const& testCase ) const { return !m_underlyingPattern->matches( testCase ); }
39
40 bool TestSpec::Filter::matches( TestCaseInfo const& testCase ) const {
41 // All patterns in a filter must match for the filter to be a match
42 for( auto const& pattern : m_patterns ) {
43 if( !pattern->matches( testCase ) )
44 return false;
45 }
46 return true;
47 }
48
49 bool TestSpec::hasFilters() const {
50 return !m_filters.empty();
51 }
52 bool TestSpec::matches( TestCaseInfo const& testCase ) const {
53 // A TestSpec matches if any filter matches
54 for( auto const& filter : m_filters )
55 if( filter.matches( testCase ) )
56 return true;
57 return false;
58 }
59}
std::string name
std::string toLower(std::string const &s)