1
- #ifndef CLASS_DESCRIPTION_H
2
- #define CLASS_DESCRIPTION_H
1
+ #ifndef CPPSPEC_CLASS_DESCRIPTION_HPP
2
+ #define CPPSPEC_CLASS_DESCRIPTION_HPP
3
3
#include " description.hpp"
4
4
5
+ namespace CppSpec {
6
+
5
7
/* *
6
8
* @brief A Description with a defined subject
7
9
*
15
17
*/
16
18
template <class T >
17
19
class ClassDescription : public Description {
18
- typedef std::function<void (ClassDescription<T>&)> block_t ;
20
+ typedef std::function<void (ClassDescription<T> &)> block_t ;
19
21
block_t body;
20
22
bool first;
21
23
std::string type = " " ;
@@ -46,13 +48,13 @@ class ClassDescription : public Description {
46
48
ClassDescription (std::string descr, T subject, block_t body)
47
49
: Description(descr), body(body), subject(subject){};
48
50
49
- ClassDescription (T& subject, block_t body)
51
+ ClassDescription (T & subject, block_t body)
50
52
: Description(Pretty::to_word(subject)),
51
53
body(body),
52
54
type(" : " + Util::demangle(typeid (T).name())),
53
55
subject(subject){};
54
56
55
- ClassDescription (std::string descr, T& subject, block_t body)
57
+ ClassDescription (std::string descr, T & subject, block_t body)
56
58
: Description(descr), body(body), subject(subject){};
57
59
58
60
template <typename U>
@@ -68,16 +70,16 @@ class ClassDescription : public Description {
68
70
block_t body)
69
71
: Description(descr), body(body), subject(T(init_list)){};
70
72
71
- ClassDescription<T>(Description& d) : Description(d){};
73
+ ClassDescription<T>(Description & d) : Description(d){};
72
74
73
75
const bool has_subject = true ;
74
76
75
- Result it (std::string descr, std::function<void (ItCd<T>&)> body);
76
- Result it (std::function<void (ItCd<T>&)> body);
77
+ Result it (std::string descr, std::function<void (ItCd<T> &)> body);
78
+ Result it (std::function<void (ItCd<T> &)> body);
77
79
Result context (T subject, block_t body);
78
- Result context (T& subject, block_t body);
80
+ Result context (T & subject, block_t body);
79
81
Result context (block_t body);
80
- Result run (BasePrinter& printer) override ;
82
+ Result run (BasePrinter & printer) override ;
81
83
virtual std::string get_descr () override ;
82
84
virtual const std::string get_descr () const override ;
83
85
};
@@ -87,7 +89,7 @@ using ClassContext = ClassDescription<T>;
87
89
88
90
template <class T >
89
91
Result ClassDescription<T>::context(
90
- T subject, std::function<void (ClassDescription&)> body) {
92
+ T subject, std::function<void (ClassDescription &)> body) {
91
93
ClassContext<T> context (subject, body);
92
94
context.set_parent (this );
93
95
context.before_eaches = this ->before_eaches ;
@@ -97,13 +99,13 @@ Result ClassDescription<T>::context(
97
99
98
100
template <class T >
99
101
Result ClassDescription<T>::context(
100
- T& subject, std::function<void (ClassDescription&)> body) {
102
+ T & subject, std::function<void (ClassDescription &)> body) {
101
103
return context (subject, body);
102
104
}
103
105
104
106
template <class T >
105
107
Result ClassDescription<T>::context(
106
- std::function<void (ClassDescription&)> body) {
108
+ std::function<void (ClassDescription &)> body) {
107
109
ClassContext<T> context (body);
108
110
context.set_parent (this );
109
111
context.before_eaches = this ->before_eaches ;
@@ -113,7 +115,7 @@ Result ClassDescription<T>::context(
113
115
114
116
template <class T >
115
117
Result Description::context (T subject,
116
- std::function<void (ClassDescription<T>&)> body) {
118
+ std::function<void (ClassDescription<T> &)> body) {
117
119
ClassContext<T> context (body);
118
120
context.subject = subject;
119
121
context.set_parent (this );
@@ -130,7 +132,7 @@ Result Description::context(T subject,
130
132
131
133
template <class T , typename U>
132
134
Result Description::context (std::initializer_list<U> init_list,
133
- std::function<void (ClassDescription<T>&)> body) {
135
+ std::function<void (ClassDescription<T> &)> body) {
134
136
ClassContext<T> context (T (init_list), body);
135
137
context.set_parent (this );
136
138
context.before_eaches = this ->before_eaches ;
@@ -161,7 +163,7 @@ Result Description::context(std::initializer_list<U> init_list,
161
163
*/
162
164
template <class T >
163
165
Result ClassDescription<T>::it(std::string name,
164
- std::function<void (ItCd<T>&)> body) {
166
+ std::function<void (ItCd<T> &)> body) {
165
167
ItCd<T> it (*this , this ->subject , name, body);
166
168
Result result = it.run (this ->get_printer ());
167
169
exec_after_eaches ();
@@ -191,7 +193,7 @@ Result ClassDescription<T>::it(std::string name,
191
193
* @return the result of the test
192
194
*/
193
195
template <class T >
194
- Result ClassDescription<T>::it(std::function<void (ItCd<T>&)> body) {
196
+ Result ClassDescription<T>::it(std::function<void (ItCd<T> &)> body) {
195
197
ItCd<T> it (*this , this ->subject , body);
196
198
Result result = it.run (this ->get_printer ());
197
199
exec_after_eaches ();
@@ -200,7 +202,7 @@ Result ClassDescription<T>::it(std::function<void(ItCd<T>&)> body) {
200
202
}
201
203
202
204
template <class T >
203
- Result ClassDescription<T>::run(BasePrinter& printer) {
205
+ Result ClassDescription<T>::run(BasePrinter & printer) {
204
206
if (not this ->has_printer ()) this ->set_printer (printer);
205
207
printer.print (*this );
206
208
body (*this );
@@ -219,7 +221,7 @@ std::string ClassDescription<T>::get_descr() {
219
221
220
222
template <class T >
221
223
const std::string ClassDescription<T>::get_descr() const {
222
- if (const_cast <ClassDescription<T>*>(this )->get_printer ().mode ==
224
+ if (const_cast <ClassDescription<T> *>(this )->get_printer ().mode ==
223
225
BasePrinter::Mode::TAP) {
224
226
return descr;
225
227
} else {
@@ -229,13 +231,13 @@ const std::string ClassDescription<T>::get_descr() const {
229
231
230
232
template <class T >
231
233
Expectations::Expectation<T> ItCd<T>::is_expected() {
232
- auto cd = static_cast <ClassDescription<T>*>(this ->get_parent ());
234
+ auto cd = static_cast <ClassDescription<T> *>(this ->get_parent ());
233
235
Expectations::Expectation<T> expectation (*this , cd->subject );
234
236
return expectation;
235
237
}
236
238
237
239
template <class T >
238
- Result ItCd<T>::run(BasePrinter& printer) {
240
+ Result ItCd<T>::run(BasePrinter & printer) {
239
241
if (!this ->needs_descr () && printer.mode == BasePrinter::Mode::verbose) {
240
242
printer.print (*this );
241
243
}
@@ -247,9 +249,10 @@ Result ItCd<T>::run(BasePrinter& printer) {
247
249
printer.print (*this );
248
250
}
249
251
250
- auto cd = static_cast <ClassDescription<T>*>(this ->get_parent ());
252
+ auto cd = static_cast <ClassDescription<T> *>(this ->get_parent ());
251
253
cd->reset_lets ();
252
254
return this ->get_status () ? Result::success : Result::failure;
253
255
}
254
256
255
- #endif /* CLASS_DESCRIPTION_H */
257
+ } // ::CppSpec
258
+ #endif // CPPSPEC_CLASS_DESCRIPTION_HPP
0 commit comments