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#pragma once
6
7#include <cstring>
8#include <functional>
9#include <string>
10#include <utility>
11
12namespace beast {
13namespace unit_test {
14
15class runner;
16
19{
20 using run_type = std::function<void(runner&)>;
21
25 bool manual_;
28
29public:
34 bool manual,
35 int priority,
37 : name_(std::move(name))
38 , module_(std::move(module))
39 , library_(std::move(library))
41 , priority_(priority)
42 , run_(std::move(run))
43 {
44 }
45
46 std::string const&
47 name() const
48 {
49 return name_;
50 }
51
52 std::string const&
53 module() const
54 {
55 return module_;
56 }
57
58 std::string const&
59 library() const
60 {
61 return library_;
62 }
63
65 bool
66 manual() const
67 {
68 return manual_;
69 }
70
73 full_name() const
74 {
75 return library_ + "." + module_ + "." + name_;
76 }
77
79 void
80 run(runner& r) const
81 {
82 run_(r);
83 }
84
85 friend bool
86 operator<(suite_info const& lhs, suite_info const& rhs)
87 {
88 // we want higher priority suites sorted first, thus the negation
89 // of priority value here
90 return std::forward_as_tuple(-lhs.priority_, lhs.library_, lhs.module_, lhs.name_) <
92 }
93};
94
95//------------------------------------------------------------------------------
96
98template <class Suite>
99suite_info
101 std::string name,
102 std::string module,
103 std::string library,
104 bool manual,
105 int priority)
106{
107 return suite_info(
108 std::move(name), std::move(module), std::move(library), manual, priority, [](runner& r) {
109 Suite{}(r);
110 });
111}
112
113} // namespace unit_test
114} // namespace beast
Unit test runner interface.
Definition runner.h:23
Associates a unit test type with metadata.
Definition suite_info.h:19
friend bool operator<(suite_info const &lhs, suite_info const &rhs)
Definition suite_info.h:86
suite_info(std::string name, std::string module, std::string library, bool manual, int priority, run_type run)
Definition suite_info.h:30
std::string full_name() const
Return the canonical suite name as a string.
Definition suite_info.h:73
bool manual() const
Returns true if this suite only runs manually.
Definition suite_info.h:66
void run(runner &r) const
Run a new instance of the associated test suite.
Definition suite_info.h:80
std::string const & library() const
Definition suite_info.h:59
std::string const & module() const
Definition suite_info.h:53
std::string const & name() const
Definition suite_info.h:47
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:100
STL namespace.