2 // Copyright (c) 2016-2017 Vinnie Falco (vinnie dot falco at gmail dot com)
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)
7 // Official repository: https://github.com/boostorg/beast
10 #ifndef BOOST_BEAST_UNIT_TEST_MATCH_HPP
11 #define BOOST_BEAST_UNIT_TEST_MATCH_HPP
13 #include <boost/beast/unit_test/suite_info.hpp>
20 // Predicate for implementing matches
26 // Run all tests except manual ones
29 // Run tests that match in any field
38 // Match on module (used internally)
41 // Match nothing (used internally)
51 template<class = void>
53 selector(mode_t mode, std::string const& pattern = "");
55 template<class = void>
57 operator()(suite_info const& s);
60 //------------------------------------------------------------------------------
63 selector::selector(mode_t mode, std::string const& pattern)
67 if(mode_ == automatch && pattern.empty())
73 selector::operator()(suite_info const& s)
79 if(s.name() == pat_ || s.full_name() == pat_)
86 if(pat_ == s.module())
89 library_ = s.library();
94 if(pat_ == s.library())
103 return pat_ == s.name();
106 return pat_ == s.module() && ! s.manual();
109 return pat_ == s.library() && ! s.manual();
123 //------------------------------------------------------------------------------
125 // Utility functions for producing predicates to select suites.
127 /** Returns a predicate that implements a smart matching rule.
128 The predicate checks the suite, module, and library fields of the
129 suite_info in that order. When it finds a match, it changes modes
130 depending on what was found:
132 If a suite is matched first, then only the suite is selected. The
133 suite may be marked manual.
135 If a module is matched first, then only suites from that module
136 and library not marked manual are selected from then on.
138 If a library is matched first, then only suites from that library
139 not marked manual are selected from then on.
144 match_auto(std::string const& name)
146 return selector(selector::automatch, name);
149 /** Return a predicate that matches all suites not marked manual. */
154 return selector(selector::all);
157 /** Returns a predicate that matches a specific suite. */
160 match_suite(std::string const& name)
162 return selector(selector::suite, name);
165 /** Returns a predicate that matches all suites in a library. */
168 match_library(std::string const& name)
170 return selector(selector::library, name);