rippled
Loading...
Searching...
No Matches
suite_info.h
1//
2// Copyright (c) 2013-2017 Vinnie Falco (vinnie dot falco at gmail dot com)
3//
4// Distributed under the Boost Software License, Version 1.0. (See accompanying
5// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
6//
7
8#ifndef BEAST_UNIT_TEST_SUITE_INFO_HPP
9#define BEAST_UNIT_TEST_SUITE_INFO_HPP
10
11#include <cstring>
12#include <functional>
13#include <string>
14#include <utility>
15
16namespace beast {
17namespace unit_test {
18
19class runner;
20
23{
24 using run_type = std::function<void(runner&)>;
25
29 bool manual_;
32
33public:
38 bool manual,
39 int priority,
41 : name_(std::move(name))
42 , module_(std::move(module))
43 , library_(std::move(library))
45 , priority_(priority)
46 , run_(std::move(run))
47 {
48 }
49
50 std::string const&
51 name() const
52 {
53 return name_;
54 }
55
56 std::string const&
57 module() const
58 {
59 return module_;
60 }
61
62 std::string const&
63 library() const
64 {
65 return library_;
66 }
67
69 bool
70 manual() const
71 {
72 return manual_;
73 }
74
77 full_name() const
78 {
79 return library_ + "." + module_ + "." + name_;
80 }
81
83 void
84 run(runner& r) const
85 {
86 run_(r);
87 }
88
89 friend bool
90 operator<(suite_info const& lhs, suite_info const& rhs)
91 {
92 // we want higher priority suites sorted first, thus the negation
93 // of priority value here
95 -lhs.priority_, lhs.library_, lhs.module_, lhs.name_) <
97 -rhs.priority_, rhs.library_, rhs.module_, rhs.name_);
98 }
99};
100
101//------------------------------------------------------------------------------
102
104template <class Suite>
105suite_info
107 std::string name,
108 std::string module,
109 std::string library,
110 bool manual,
111 int priority)
112{
113 return suite_info(
114 std::move(name),
115 std::move(module),
116 std::move(library),
117 manual,
118 priority,
119 [](runner& r) { Suite{}(r); });
120}
121
122} // namespace unit_test
123} // namespace beast
124
125#endif
Unit test runner interface.
Definition runner.h:27
Associates a unit test type with metadata.
Definition suite_info.h:23
friend bool operator<(suite_info const &lhs, suite_info const &rhs)
Definition suite_info.h:90
suite_info(std::string name, std::string module, std::string library, bool manual, int priority, run_type run)
Definition suite_info.h:34
std::string full_name() const
Return the canonical suite name as a string.
Definition suite_info.h:77
bool manual() const
Returns true if this suite only runs manually.
Definition suite_info.h:70
void run(runner &r) const
Run a new instance of the associated test suite.
Definition suite_info.h:84
std::string const & library() const
Definition suite_info.h:63
std::string const & module() const
Definition suite_info.h:57
std::string const & name() const
Definition suite_info.h:51
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:106
STL namespace.