File indexing completed on 2025-01-19 09:25:01
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010 #ifndef BOOST_BEAST_UNIT_TEST_SUITE_INFO_HPP
0011 #define BOOST_BEAST_UNIT_TEST_SUITE_INFO_HPP
0012
0013 #include <cstring>
0014 #include <functional>
0015 #include <string>
0016 #include <utility>
0017
0018 namespace boost {
0019 namespace beast {
0020 namespace unit_test {
0021
0022 class runner;
0023
0024
0025 class suite_info
0026 {
0027 using run_type = std::function<void(runner&)>;
0028
0029 std::string name_;
0030 std::string module_;
0031 std::string library_;
0032 bool manual_;
0033 run_type run_;
0034
0035 public:
0036 suite_info(
0037 std::string name,
0038 std::string module,
0039 std::string library,
0040 bool manual,
0041 run_type run)
0042 : name_(std::move(name))
0043 , module_(std::move(module))
0044 , library_(std::move(library))
0045 , manual_(manual)
0046 , run_(std::move(run))
0047 {
0048 }
0049
0050 std::string const&
0051 name() const
0052 {
0053 return name_;
0054 }
0055
0056 std::string const&
0057 module() const
0058 {
0059 return module_;
0060 }
0061
0062 std::string const&
0063 library() const
0064 {
0065 return library_;
0066 }
0067
0068
0069 bool
0070 manual() const
0071 {
0072 return manual_;
0073 }
0074
0075
0076 std::string
0077 full_name() const
0078 {
0079 return library_ + "." + module_ + "." + name_;
0080 }
0081
0082
0083 void
0084 run(runner& r) const
0085 {
0086 run_(r);
0087 }
0088
0089 friend
0090 bool
0091 operator<(suite_info const& lhs, suite_info const& rhs)
0092 {
0093 return
0094 std::tie(lhs.library_, lhs.module_, lhs.name_) <
0095 std::tie(rhs.library_, rhs.module_, rhs.name_);
0096 }
0097 };
0098
0099
0100
0101
0102 template<class Suite>
0103 suite_info
0104 make_suite_info(
0105 std::string name,
0106 std::string module,
0107 std::string library,
0108 bool manual)
0109 {
0110 return suite_info(
0111 std::move(name),
0112 std::move(module),
0113 std::move(library),
0114 manual,
0115 [](runner& r)
0116 {
0117 Suite{}(r);
0118 }
0119 );
0120 }
0121
0122 }
0123 }
0124 }
0125
0126 #endif