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
|
|
|
|
2019-08-06 20:51:19 +02:00
|
|
|
struct IConfig;
|
|
|
|
|
2014-05-16 19:28:58 +02:00
|
|
|
class TestSpec {
|
2019-08-06 20:51:19 +02:00
|
|
|
class Pattern {
|
|
|
|
public:
|
|
|
|
explicit Pattern( std::string const& name );
|
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;
|
2019-08-06 20:51:19 +02:00
|
|
|
std::string const& name() const;
|
|
|
|
private:
|
|
|
|
std::string const m_name;
|
2014-05-16 19:28:58 +02:00
|
|
|
};
|
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:
|
2019-08-06 20:51:19 +02:00
|
|
|
explicit NamePattern( std::string const& name, std::string const& filterString );
|
2018-07-12 14:27:06 +02:00
|
|
|
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:
|
2019-08-06 20:51:19 +02:00
|
|
|
explicit TagPattern( std::string const& tag, std::string const& filterString );
|
2018-07-12 14:27:06 +02:00
|
|
|
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
|
|
|
struct Filter {
|
2019-06-22 20:26:03 +02:00
|
|
|
std::vector<PatternPtr> m_required;
|
|
|
|
std::vector<PatternPtr> m_forbidden;
|
2014-05-16 19:28:58 +02:00
|
|
|
|
2017-07-19 10:13:47 +02:00
|
|
|
bool matches( TestCaseInfo const& testCase ) const;
|
2019-08-06 20:51:19 +02:00
|
|
|
std::string name() const;
|
2014-05-16 19:28:58 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
public:
|
2019-08-06 20:51:19 +02:00
|
|
|
struct FilterMatch {
|
|
|
|
std::string name;
|
2019-11-04 21:35:57 +01:00
|
|
|
std::vector<TestCaseHandle const*> tests;
|
2019-08-06 20:51:19 +02:00
|
|
|
};
|
|
|
|
using Matches = std::vector<FilterMatch>;
|
2019-10-19 15:50:46 +02:00
|
|
|
using vectorStrings = std::vector<std::string>;
|
2019-08-06 20:51:19 +02:00
|
|
|
|
2017-07-19 10:13:47 +02:00
|
|
|
bool hasFilters() const;
|
|
|
|
bool matches( TestCaseInfo const& testCase ) const;
|
2019-11-04 21:35:57 +01:00
|
|
|
Matches matchesByFilter( std::vector<TestCaseHandle> const& testCases, IConfig const& config ) const;
|
2019-10-19 15:50:46 +02:00
|
|
|
const vectorStrings & getInvalidArgs() const;
|
2014-05-16 19:28:58 +02:00
|
|
|
|
|
|
|
private:
|
|
|
|
std::vector<Filter> m_filters;
|
2019-10-19 15:50:46 +02:00
|
|
|
std::vector<std::string> m_invalidArgs;
|
2014-05-16 19:28:58 +02:00
|
|
|
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
|