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:
31 : name_(std::move(name))
32 , module_(std::move(module))
33 , library_(std::move(library))
35 , priority_(priority)
36 , run_(std::move(run))
37 {
38 }
39
40 std::string const&
41 name() const
42 {
43 return name_;
44 }
45
46 std::string const&
47 module() const
48 {
49 return module_;
50 }
51
52 std::string const&
53 library() const
54 {
55 return library_;
56 }
57
59 bool
60 manual() const
61 {
62 return manual_;
63 }
64
67 full_name() const
68 {
69 return library_ + "." + module_ + "." + name_;
70 }
71
73 void
74 run(runner& r) const
75 {
76 run_(r);
77 }
78
79 friend bool
80 operator<(suite_info const& lhs, suite_info const& rhs)
81 {
82 // we want higher priority suites sorted first, thus the negation
83 // of priority value here
84 return std::forward_as_tuple(-lhs.priority_, lhs.library_, lhs.module_, lhs.name_) <
86 }
87};
88
89//------------------------------------------------------------------------------
90
92template <class Suite>
93suite_info
94make_suite_info(std::string name, std::string module, std::string library, bool manual, int priority)
95{
96 return suite_info(
97 std::move(name), std::move(module), std::move(library), manual, priority, [](runner& r) { Suite{}(r); });
98}
99
100} // namespace unit_test
101} // 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:80
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:67
bool manual() const
Returns true if this suite only runs manually.
Definition suite_info.h:60
void run(runner &r) const
Run a new instance of the associated test suite.
Definition suite_info.h:74
std::string const & library() const
Definition suite_info.h:53
std::string const & module() const
Definition suite_info.h:47
std::string const & name() const
Definition suite_info.h:41
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:94
STL namespace.