File indexing completed on 2025-07-01 08:09:28
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010 #ifndef BOOST_BEAST_UNIT_TEST_MATCH_HPP
0011 #define BOOST_BEAST_UNIT_TEST_MATCH_HPP
0012
0013 #include <boost/beast/_experimental/unit_test/suite_info.hpp>
0014 #include <string>
0015
0016 namespace boost {
0017 namespace beast {
0018 namespace unit_test {
0019
0020
0021 class selector
0022 {
0023 public:
0024 enum mode_t
0025 {
0026
0027 all,
0028
0029
0030 automatch,
0031
0032
0033 suite,
0034
0035
0036 library,
0037
0038
0039 module,
0040
0041
0042 none
0043 };
0044
0045 private:
0046 mode_t mode_;
0047 std::string pat_;
0048 std::string library_;
0049
0050 public:
0051 template<class = void>
0052 explicit
0053 selector(mode_t mode, std::string const& pattern = "");
0054
0055 template<class = void>
0056 bool
0057 operator()(suite_info const& s);
0058 };
0059
0060
0061
0062 template<class>
0063 selector::selector(mode_t mode, std::string const& pattern)
0064 : mode_(mode)
0065 , pat_(pattern)
0066 {
0067 if(mode_ == automatch && pattern.empty())
0068 mode_ = all;
0069 }
0070
0071 template<class>
0072 bool
0073 selector::operator()(suite_info const& s)
0074 {
0075 switch(mode_)
0076 {
0077 case automatch:
0078
0079 if(s.name() == pat_ || s.full_name() == pat_)
0080 {
0081 mode_ = none;
0082 return true;
0083 }
0084
0085
0086 if(pat_ == s.module())
0087 {
0088 mode_ = module;
0089 library_ = s.library();
0090 return ! s.manual();
0091 }
0092
0093
0094 if(pat_ == s.library())
0095 {
0096 mode_ = library;
0097 return ! s.manual();
0098 }
0099
0100 return false;
0101
0102 case suite:
0103 return pat_ == s.name();
0104
0105 case module:
0106 return pat_ == s.module() && ! s.manual();
0107
0108 case library:
0109 return pat_ == s.library() && ! s.manual();
0110
0111 case none:
0112 return false;
0113
0114 case all:
0115 default:
0116 break;
0117 };
0118
0119 return ! s.manual();
0120 }
0121
0122
0123
0124
0125
0126
0127
0128
0129
0130
0131
0132
0133
0134
0135
0136
0137
0138
0139
0140
0141 inline
0142 selector
0143 match_auto(std::string const& name)
0144 {
0145 return selector(selector::automatch, name);
0146 }
0147
0148
0149 inline
0150 selector
0151 match_all()
0152 {
0153 return selector(selector::all);
0154 }
0155
0156
0157 inline
0158 selector
0159 match_suite(std::string const& name)
0160 {
0161 return selector(selector::suite, name);
0162 }
0163
0164
0165 inline
0166 selector
0167 match_library(std::string const& name)
0168 {
0169 return selector(selector::library, name);
0170 }
0171
0172 }
0173 }
0174 }
0175
0176 #endif