2 // Copyright (c) 2013-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)
8 #ifndef BEAST_UNIT_TEST_MATCH_HPP
9 #define BEAST_UNIT_TEST_MATCH_HPP
11 #include <beast/unit_test/suite_info.hpp>
17 // Predicate for implementing matches
23 // Run all tests except manual ones
26 // Run tests that match in any field
35 // Match on module (used internally)
38 // Match nothing (used internally)
48 template<class = void>
50 selector(mode_t mode, std::string const& pattern = "");
52 template<class = void>
54 operator()(suite_info const& s);
57 //------------------------------------------------------------------------------
60 selector::selector(mode_t mode, std::string const& pattern)
64 if(mode_ == automatch && pattern.empty())
70 selector::operator()(suite_info const& s)
76 if(s.name() == pat_ || s.full_name() == pat_)
83 if(pat_ == s.module())
86 library_ = s.library();
91 if(pat_ == s.library())
100 return pat_ == s.name();
103 return pat_ == s.module() && ! s.manual();
106 return pat_ == s.library() && ! s.manual();
120 //------------------------------------------------------------------------------
122 // Utility functions for producing predicates to select suites.
124 /** Returns a predicate that implements a smart matching rule.
125 The predicate checks the suite, module, and library fields of the
126 suite_info in that order. When it finds a match, it changes modes
127 depending on what was found:
129 If a suite is matched first, then only the suite is selected. The
130 suite may be marked manual.
132 If a module is matched first, then only suites from that module
133 and library not marked manual are selected from then on.
135 If a library is matched first, then only suites from that library
136 not marked manual are selected from then on.
141 match_auto(std::string const& name)
143 return selector(selector::automatch, name);
146 /** Return a predicate that matches all suites not marked manual. */
151 return selector(selector::all);
154 /** Returns a predicate that matches a specific suite. */
157 match_suite(std::string const& name)
159 return selector(selector::suite, name);
162 /** Returns a predicate that matches all suites in a library. */
165 match_library(std::string const& name)
167 return selector(selector::library, name);