rippled
Loading...
Searching...
No Matches
suite_info.h
1// Distributed under the Boost Software License, Version 1.0. (See accompanying
2// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
3//
4
5#ifndef BEAST_UNIT_TEST_SUITE_INFO_HPP
6#define BEAST_UNIT_TEST_SUITE_INFO_HPP
7
8#include <cstring>
9#include <functional>
10#include <string>
11#include <utility>
12
13namespace beast {
14namespace unit_test {
15
16class runner;
17
20{
21 using run_type = std::function<void(runner&)>;
22
26 bool manual_;
29
30public:
35 bool manual,
36 int priority,
38 : name_(std::move(name))
39 , module_(std::move(module))
40 , library_(std::move(library))
42 , priority_(priority)
43 , run_(std::move(run))
44 {
45 }
46
47 std::string const&
48 name() const
49 {
50 return name_;
51 }
52
53 std::string const&
54 module() const
55 {
56 return module_;
57 }
58
59 std::string const&
60 library() const
61 {
62 return library_;
63 }
64
66 bool
67 manual() const
68 {
69 return manual_;
70 }
71
74 full_name() const
75 {
76 return library_ + "." + module_ + "." + name_;
77 }
78
80 void
81 run(runner& r) const
82 {
83 run_(r);
84 }
85
86 friend bool
87 operator<(suite_info const& lhs, suite_info const& rhs)
88 {
89 // we want higher priority suites sorted first, thus the negation
90 // of priority value here
92 -lhs.priority_, lhs.library_, lhs.module_, lhs.name_) <
94 -rhs.priority_, rhs.library_, rhs.module_, rhs.name_);
95 }
96};
97
98//------------------------------------------------------------------------------
99
101template <class Suite>
102suite_info
104 std::string name,
105 std::string module,
106 std::string library,
107 bool manual,
108 int priority)
109{
110 return suite_info(
111 std::move(name),
112 std::move(module),
113 std::move(library),
114 manual,
115 priority,
116 [](runner& r) { Suite{}(r); });
117}
118
119} // namespace unit_test
120} // namespace beast
121
122#endif
Unit test runner interface.
Definition runner.h:24
Associates a unit test type with metadata.
Definition suite_info.h:20
friend bool operator<(suite_info const &lhs, suite_info const &rhs)
Definition suite_info.h:87
suite_info(std::string name, std::string module, std::string library, bool manual, int priority, run_type run)
Definition suite_info.h:31
std::string full_name() const
Return the canonical suite name as a string.
Definition suite_info.h:74
bool manual() const
Returns true if this suite only runs manually.
Definition suite_info.h:67
void run(runner &r) const
Run a new instance of the associated test suite.
Definition suite_info.h:81
std::string const & library() const
Definition suite_info.h:60
std::string const & module() const
Definition suite_info.h:54
std::string const & name() const
Definition suite_info.h:48
T forward_as_tuple(T... args)
suite_info make_suite_info(std::string name, std::string module, std::string library, bool manual, int priority)
Convenience for producing suite_info for a given test type.
Definition suite_info.h:103
STL namespace.