@micro-os-plus/micro-test-plus 4.0.0 → 4.1.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +95 -0
- package/CMakeLists.txt +74 -24
- package/README.md +3 -2
- package/include/micro-os-plus/micro-test-plus/README.md +6 -0
- package/include/micro-os-plus/micro-test-plus/deferred-reporter.h +29 -54
- package/include/micro-os-plus/micro-test-plus/detail.h +166 -705
- package/include/micro-os-plus/micro-test-plus/exceptions.h +5 -6
- package/include/micro-os-plus/micro-test-plus/expression-formatter.h +669 -0
- package/include/micro-os-plus/micro-test-plus/function-comparators.h +5 -0
- package/include/micro-os-plus/micro-test-plus/inlines/deferred-reporter-inlines.h +25 -30
- package/include/micro-os-plus/micro-test-plus/inlines/detail-inlines.h +711 -0
- package/include/micro-os-plus/micro-test-plus/inlines/exceptions-inline.h +137 -0
- package/include/micro-os-plus/micro-test-plus/inlines/expression-formatter-inlines.h +510 -0
- package/include/micro-os-plus/micro-test-plus/inlines/function-comparators-inlines.h +17 -76
- package/include/micro-os-plus/micro-test-plus/inlines/literals-inlines.h +47 -25
- package/include/micro-os-plus/micro-test-plus/inlines/math-inlines.h +7 -7
- package/include/micro-os-plus/micro-test-plus/inlines/operators-inlines.h +275 -0
- package/include/micro-os-plus/micro-test-plus/inlines/reflection-inlines.h +4 -4
- package/include/micro-os-plus/micro-test-plus/inlines/reporter-inlines.h +53 -394
- package/include/micro-os-plus/micro-test-plus/inlines/runner-inlines.h +38 -0
- package/include/micro-os-plus/micro-test-plus/inlines/runner-totals-inlines.h +152 -0
- package/include/micro-os-plus/micro-test-plus/inlines/test-inlines.h +231 -45
- package/include/micro-os-plus/micro-test-plus/inlines/timings-inlines.h +120 -0
- package/include/micro-os-plus/micro-test-plus/inlines/type-traits-inlines.h +202 -0
- package/include/micro-os-plus/micro-test-plus/literals.h +8 -14
- package/include/micro-os-plus/micro-test-plus/math.h +5 -0
- package/include/micro-os-plus/micro-test-plus/operators.h +19 -169
- package/include/micro-os-plus/micro-test-plus/reflection.h +5 -12
- package/include/micro-os-plus/micro-test-plus/reporter-human.h +17 -11
- package/include/micro-os-plus/micro-test-plus/reporter-tap.h +14 -8
- package/include/micro-os-plus/micro-test-plus/reporter.h +101 -424
- package/include/micro-os-plus/micro-test-plus/runner-totals.h +162 -176
- package/include/micro-os-plus/micro-test-plus/runner.h +61 -42
- package/include/micro-os-plus/micro-test-plus/test.h +450 -506
- package/include/micro-os-plus/micro-test-plus/timings.h +259 -262
- package/include/micro-os-plus/micro-test-plus/type-traits.h +30 -52
- package/include/micro-os-plus/micro-test-plus/utility.h +5 -4
- package/include/micro-os-plus/micro-test-plus.h +33 -24
- package/meson.build +1 -0
- package/package.json +11 -3
- package/src/deferred-reporter.cpp +21 -2
- package/src/expression-formatter.cpp +289 -0
- package/src/reflection.cpp +3 -1
- package/src/reporter-human.cpp +31 -37
- package/src/reporter-tap.cpp +25 -35
- package/src/reporter.cpp +36 -231
- package/src/runner-totals.cpp +6 -3
- package/src/runner.cpp +131 -25
- package/src/test.cpp +120 -113
- package/src/timings.cpp +6 -5
- package/src/utility.cpp +1 -1
|
@@ -75,51 +75,49 @@ namespace micro_os_plus::micro_test_plus
|
|
|
75
75
|
{
|
|
76
76
|
// --------------------------------------------------------------------------
|
|
77
77
|
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
#if defined(__clang__)
|
|
81
|
-
#pragma clang diagnostic ignored "-Wunsafe-buffer-usage"
|
|
82
|
-
#pragma clang diagnostic ignored "-Wunsafe-buffer-usage-in-libc-call"
|
|
83
|
-
#endif
|
|
84
|
-
#endif
|
|
85
|
-
template <class T>
|
|
86
|
-
void
|
|
87
|
-
reporter::append_number_ (std::string& buffer, const T v)
|
|
78
|
+
inline detail::indent_t
|
|
79
|
+
indent (size_t level)
|
|
88
80
|
{
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
81
|
+
return { level };
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
// ==========================================================================
|
|
85
|
+
|
|
86
|
+
/**
|
|
87
|
+
* @details
|
|
88
|
+
* Returns the verbosity level stored in `verbosity_`.
|
|
89
|
+
*/
|
|
90
|
+
inline auto
|
|
91
|
+
reporter::verbosity () const -> micro_test_plus::verbosity
|
|
92
|
+
{
|
|
93
|
+
return verbosity_;
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
/**
|
|
97
|
+
* @details
|
|
98
|
+
* Returns a reference to the `expression_formatter` instance used by the
|
|
99
|
+
* reporter for formatting expressions in test reports. This allows the
|
|
100
|
+
* reporter to delegate the formatting of complex expressions to the
|
|
101
|
+
* `expression_formatter`, which provides a consistent and extensible way to
|
|
102
|
+
* convert various types of values and expressions into their string
|
|
103
|
+
* representations for output in test reports.
|
|
104
|
+
*/
|
|
105
|
+
inline detail::expression_formatter&
|
|
106
|
+
reporter::expression ()
|
|
107
|
+
{
|
|
108
|
+
return expression_;
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
/**
|
|
112
|
+
* @details
|
|
113
|
+
* Returns the ANSI colour code for pass or fail, depending on the boolean
|
|
114
|
+
* condition provided.
|
|
115
|
+
*/
|
|
116
|
+
inline auto
|
|
117
|
+
reporter::colour_ (const bool cond) const
|
|
118
|
+
{
|
|
119
|
+
return cond ? colours_.pass : colours_.fail;
|
|
119
120
|
}
|
|
120
|
-
#if defined(__GNUC__)
|
|
121
|
-
#pragma GCC diagnostic pop
|
|
122
|
-
#endif
|
|
123
121
|
|
|
124
122
|
// --------------------------------------------------------------------------
|
|
125
123
|
|
|
@@ -170,364 +168,25 @@ namespace micro_os_plus::micro_test_plus
|
|
|
170
168
|
|
|
171
169
|
/**
|
|
172
170
|
* @details
|
|
173
|
-
* This operator overload
|
|
174
|
-
*
|
|
175
|
-
*
|
|
176
|
-
*
|
|
177
|
-
*
|
|
178
|
-
*
|
|
179
|
-
*
|
|
180
|
-
*
|
|
181
|
-
*
|
|
182
|
-
*
|
|
183
|
-
* This approach promotes flexibility and maintainability, allowing new types
|
|
184
|
-
* to be supported with minimal changes to the reporting infrastructure.
|
|
185
|
-
*/
|
|
186
|
-
template <class T>
|
|
187
|
-
requires type_traits::is_op<T>
|
|
188
|
-
reporter&
|
|
189
|
-
reporter::operator<< (const T& t)
|
|
190
|
-
{
|
|
191
|
-
*this << detail::get (t);
|
|
192
|
-
return *this;
|
|
193
|
-
}
|
|
194
|
-
|
|
195
|
-
/**
|
|
196
|
-
* @details
|
|
197
|
-
* This operator overload enables the `reporter` to output
|
|
198
|
-
* strongly-typed integral values in a clear and consistent decimal format.
|
|
199
|
-
*
|
|
200
|
-
* The value is converted to a string using `std::to_string` after being cast
|
|
201
|
-
* to `long long`, ensuring accurate formatting and compatibility across
|
|
202
|
-
* platforms. The resulting string is appended to the internal output buffer,
|
|
203
|
-
* allowing integral values to be included in test reports and diagnostics.
|
|
204
|
-
*
|
|
205
|
-
* This approach ensures precise and unambiguous representation of integral
|
|
206
|
-
* values, which is particularly advantageous for verifying test results and
|
|
207
|
-
* facilitating debugging.
|
|
208
|
-
*/
|
|
209
|
-
template <class T>
|
|
210
|
-
reporter&
|
|
211
|
-
reporter::operator<< (const type_traits::genuine_integral_value<T>& v)
|
|
212
|
-
{
|
|
213
|
-
append_number_ (buffer_, static_cast<long long> (v.get ()));
|
|
214
|
-
return *this;
|
|
215
|
-
}
|
|
216
|
-
|
|
217
|
-
/**
|
|
218
|
-
* @details
|
|
219
|
-
* This operator overload enables the `reporter` to output container
|
|
220
|
-
* types in a structured and readable format.
|
|
221
|
-
*
|
|
222
|
-
* The contents of the container are enclosed in curly braces and each
|
|
223
|
-
* element is separated by a comma and a space. The operator iterates over
|
|
224
|
-
* the container, formatting each element in sequence, which ensures clarity
|
|
225
|
-
* and consistency in test reports and diagnostics.
|
|
226
|
-
*
|
|
227
|
-
* This approach provides a clear visual representation of container
|
|
228
|
-
* contents, making it easier to interpret test results and debug issues
|
|
229
|
-
* involving collections of values.
|
|
171
|
+
* This template operator overload allows the `reporter` to output values of
|
|
172
|
+
* any arithmetic type (integral or floating-point) in a consistent and
|
|
173
|
+
* readable format. The value is formatted using the `append_number_` helper
|
|
174
|
+
* function, which handles the conversion to a string representation with
|
|
175
|
+
* appropriate type suffixes where applicable (e.g., "f" for float, "l" for
|
|
176
|
+
* long double). This enables numeric values to be included in test reports
|
|
177
|
+
* and diagnostics in a clear and unambiguous manner, supporting the
|
|
178
|
+
* verification of test cases that involve arithmetic expressions and
|
|
179
|
+
* comparisons.
|
|
230
180
|
*/
|
|
231
181
|
template <class T>
|
|
232
|
-
requires
|
|
182
|
+
requires std::is_arithmetic_v<T>
|
|
233
183
|
reporter&
|
|
234
|
-
reporter::operator<< (
|
|
184
|
+
reporter::operator<< (T v)
|
|
235
185
|
{
|
|
236
|
-
|
|
237
|
-
auto first = true;
|
|
238
|
-
for (const auto& arg : t)
|
|
239
|
-
{
|
|
240
|
-
*this << (first ? "" : ", ") << arg;
|
|
241
|
-
first = false;
|
|
242
|
-
}
|
|
243
|
-
*this << '}';
|
|
186
|
+
detail::append_number_ (buffer_, v);
|
|
244
187
|
return *this;
|
|
245
188
|
}
|
|
246
189
|
|
|
247
|
-
/**
|
|
248
|
-
* @details
|
|
249
|
-
* This operator overload enables the `reporter` to output equality
|
|
250
|
-
* comparison expressions in a clear and expressive format.
|
|
251
|
-
*
|
|
252
|
-
* The left-hand side and right-hand side values are formatted and separated
|
|
253
|
-
* by the equality operator (`==`), with appropriate colour highlighting
|
|
254
|
-
* applied for improved readability in test reports and diagnostics. This
|
|
255
|
-
* structured output assists in quickly identifying the values involved in
|
|
256
|
-
* equality assertions and facilitates efficient debugging of test failures.
|
|
257
|
-
*/
|
|
258
|
-
template <class Lhs_T, class Rhs_T>
|
|
259
|
-
reporter&
|
|
260
|
-
reporter::operator<< (const detail::eq_<Lhs_T, Rhs_T>& op)
|
|
261
|
-
{
|
|
262
|
-
return (*this << colour_ (op) << op.lhs () << " == " << op.rhs ()
|
|
263
|
-
<< colours_.none);
|
|
264
|
-
}
|
|
265
|
-
|
|
266
|
-
/**
|
|
267
|
-
* @details
|
|
268
|
-
* This operator overload enables the `reporter` to output inequality
|
|
269
|
-
* comparison expressions in a clear and expressive format.
|
|
270
|
-
*
|
|
271
|
-
* The left-hand side and right-hand side values are formatted and separated
|
|
272
|
-
* by the inequality operator (`!=`), with appropriate colour highlighting
|
|
273
|
-
* applied for improved readability in test reports and diagnostics. This
|
|
274
|
-
* structured output assists in quickly identifying the values involved in
|
|
275
|
-
* inequality assertions and facilitates efficient debugging of test
|
|
276
|
-
* failures.
|
|
277
|
-
*/
|
|
278
|
-
template <class Lhs_T, class Rhs_T>
|
|
279
|
-
reporter&
|
|
280
|
-
reporter::operator<< (const detail::ne_<Lhs_T, Rhs_T>& op)
|
|
281
|
-
{
|
|
282
|
-
return (*this << colour_ (op) << op.lhs () << " != " << op.rhs ()
|
|
283
|
-
<< colours_.none);
|
|
284
|
-
}
|
|
285
|
-
|
|
286
|
-
/**
|
|
287
|
-
* @details
|
|
288
|
-
* This operator overload enables the `reporter` to output greater-than
|
|
289
|
-
* comparison expressions in a clear and expressive format.
|
|
290
|
-
*
|
|
291
|
-
* The left-hand side and right-hand side values are formatted and separated
|
|
292
|
-
* by the greater-than operator (`>`), with appropriate colour highlighting
|
|
293
|
-
* applied for improved readability in test reports and diagnostics. This
|
|
294
|
-
* structured output assists in quickly identifying the values involved in
|
|
295
|
-
* greater-than assertions and facilitates efficient debugging of test
|
|
296
|
-
* failures.
|
|
297
|
-
*/
|
|
298
|
-
template <class Lhs_T, class Rhs_T>
|
|
299
|
-
reporter&
|
|
300
|
-
reporter::operator<< (const detail::gt_<Lhs_T, Rhs_T>& op)
|
|
301
|
-
{
|
|
302
|
-
return (*this << colour_ (op) << op.lhs () << " > " << op.rhs ()
|
|
303
|
-
<< colours_.none);
|
|
304
|
-
}
|
|
305
|
-
|
|
306
|
-
/**
|
|
307
|
-
* @details
|
|
308
|
-
* This operator overload enables the `reporter` to output
|
|
309
|
-
* greater-than-or-equal-to comparison expressions in a clear and expressive
|
|
310
|
-
* format.
|
|
311
|
-
*
|
|
312
|
-
* The left-hand side and right-hand side values are formatted and separated
|
|
313
|
-
* by the greater-than-or-equal-to operator (`>=`), with appropriate colour
|
|
314
|
-
* highlighting applied for improved readability in test reports and
|
|
315
|
-
* diagnostics. This structured output assists in quickly identifying the
|
|
316
|
-
* values involved in greater-than-or-equal-to assertions and facilitates
|
|
317
|
-
* efficient debugging of test failures.
|
|
318
|
-
*/
|
|
319
|
-
template <class Lhs_T, class Rhs_T>
|
|
320
|
-
reporter&
|
|
321
|
-
reporter::operator<< (const detail::ge_<Lhs_T, Rhs_T>& op)
|
|
322
|
-
{
|
|
323
|
-
return (*this << colour_ (op) << op.lhs () << " >= " << op.rhs ()
|
|
324
|
-
<< colours_.none);
|
|
325
|
-
}
|
|
326
|
-
|
|
327
|
-
/**
|
|
328
|
-
* @details
|
|
329
|
-
* This operator overload enables the `reporter` to output less-than
|
|
330
|
-
* comparison expressions in a clear and expressive format.
|
|
331
|
-
*
|
|
332
|
-
* The left-hand side and right-hand side values are formatted and separated
|
|
333
|
-
* by the less-than operator (`<`), with appropriate colour highlighting
|
|
334
|
-
* applied for improved readability in test reports and diagnostics. This
|
|
335
|
-
* structured output assists in quickly identifying the values involved in
|
|
336
|
-
* less-than assertions and facilitates efficient debugging of test failures.
|
|
337
|
-
*/
|
|
338
|
-
template <class Lhs_T, class Rhs_T>
|
|
339
|
-
reporter&
|
|
340
|
-
reporter::operator<< (const detail::lt_<Rhs_T, Lhs_T>& op)
|
|
341
|
-
{
|
|
342
|
-
return (*this << colour_ (op) << op.lhs () << " < " << op.rhs ()
|
|
343
|
-
<< colours_.none);
|
|
344
|
-
}
|
|
345
|
-
|
|
346
|
-
/**
|
|
347
|
-
* @details
|
|
348
|
-
* This operator overload enables the `reporter` to output
|
|
349
|
-
* less-than-or-equal-to comparison expressions in a clear and expressive
|
|
350
|
-
* format.
|
|
351
|
-
*
|
|
352
|
-
* The left-hand side and right-hand side values are formatted and separated
|
|
353
|
-
* by the less-than-or-equal-to operator (`<=`), with appropriate colour
|
|
354
|
-
* highlighting applied for improved readability in test reports and
|
|
355
|
-
* diagnostics. This structured output assists in quickly identifying the
|
|
356
|
-
* values involved in less-than-or-equal-to assertions and facilitates
|
|
357
|
-
* efficient debugging of test failures.
|
|
358
|
-
*/
|
|
359
|
-
template <class Lhs_T, class Rhs_T>
|
|
360
|
-
reporter&
|
|
361
|
-
reporter::operator<< (const detail::le_<Rhs_T, Lhs_T>& op)
|
|
362
|
-
{
|
|
363
|
-
return (*this << colour_ (op) << op.lhs () << " <= " << op.rhs ()
|
|
364
|
-
<< colours_.none);
|
|
365
|
-
}
|
|
366
|
-
|
|
367
|
-
/**
|
|
368
|
-
* @details
|
|
369
|
-
* This operator overload enables the `reporter` to output logical
|
|
370
|
-
* conjunction (AND) expressions in a clear and structured format.
|
|
371
|
-
*
|
|
372
|
-
* The left-hand side and right-hand side expressions are enclosed in
|
|
373
|
-
* parentheses and separated by the word "and", with appropriate colour
|
|
374
|
-
* highlighting applied for improved readability in test reports and
|
|
375
|
-
* diagnostics. This presentation assists in quickly identifying the
|
|
376
|
-
* components of logical assertions and facilitates efficient debugging of
|
|
377
|
-
* test failures involving compound conditions.
|
|
378
|
-
*/
|
|
379
|
-
template <class Lhs_T, class Rhs_T>
|
|
380
|
-
reporter&
|
|
381
|
-
reporter::operator<< (const detail::and_<Lhs_T, Rhs_T>& op)
|
|
382
|
-
{
|
|
383
|
-
return (*this << '(' << op.lhs () << colour_ (op) << " and "
|
|
384
|
-
<< colours_.none << op.rhs () << ')');
|
|
385
|
-
}
|
|
386
|
-
|
|
387
|
-
/**
|
|
388
|
-
* @details
|
|
389
|
-
* This operator overload enables the `reporter` to output logical
|
|
390
|
-
* disjunction (OR) expressions in a clear and structured format.
|
|
391
|
-
*
|
|
392
|
-
* The left-hand side and right-hand side expressions are enclosed in
|
|
393
|
-
* parentheses and separated by the word "or", with appropriate colour
|
|
394
|
-
* highlighting applied for improved readability in test reports and
|
|
395
|
-
* diagnostics. This presentation assists in quickly identifying the
|
|
396
|
-
* components of logical assertions and facilitates efficient debugging of
|
|
397
|
-
* test failures involving compound conditions.
|
|
398
|
-
*/
|
|
399
|
-
template <class Lhs_T, class Rhs_T>
|
|
400
|
-
reporter&
|
|
401
|
-
reporter::operator<< (const detail::or_<Lhs_T, Rhs_T>& op)
|
|
402
|
-
{
|
|
403
|
-
return (*this << '(' << op.lhs () << colour_ (op) << " or "
|
|
404
|
-
<< colours_.none << op.rhs () << ')');
|
|
405
|
-
}
|
|
406
|
-
|
|
407
|
-
/**
|
|
408
|
-
* @details
|
|
409
|
-
* This operator overload enhances readability and clarity by formatting the
|
|
410
|
-
* output when handling negated expressions. It applies colour styling for
|
|
411
|
-
* improved distinction and appends the negated value accordingly, ensuring
|
|
412
|
-
* that logical negations are clearly represented in test reports and
|
|
413
|
-
* diagnostics.
|
|
414
|
-
*/
|
|
415
|
-
template <class T>
|
|
416
|
-
reporter&
|
|
417
|
-
reporter::operator<< (const detail::not_<T>& op)
|
|
418
|
-
{
|
|
419
|
-
return (*this << colour_ (op) << "not " << op.operand () << colours_.none);
|
|
420
|
-
}
|
|
421
|
-
|
|
422
|
-
#if defined(__cpp_exceptions)
|
|
423
|
-
/**
|
|
424
|
-
* @details
|
|
425
|
-
* This operator overload provides structured output for expressions that may
|
|
426
|
-
* throw exceptions. It applies colour styling for clarity and includes the
|
|
427
|
-
* exception type name for precise identification.
|
|
428
|
-
*
|
|
429
|
-
* When invoked, the output highlights the `throws` qualifier along with the
|
|
430
|
-
* specific exception type, making it immediately apparent which exception is
|
|
431
|
-
* expected. This enhances the readability and professionalism of test
|
|
432
|
-
* reports, and assists in the precise identification and debugging of
|
|
433
|
-
* exception-related test cases.
|
|
434
|
-
*/
|
|
435
|
-
template <class Expr_T, class Exception_T>
|
|
436
|
-
reporter&
|
|
437
|
-
reporter::operator<< (const detail::throws_<Expr_T, Exception_T>& op)
|
|
438
|
-
{
|
|
439
|
-
return (*this << colour_ (op) << "throws<"
|
|
440
|
-
<< reflection::type_name<Exception_T> () << ">"
|
|
441
|
-
<< colours_.none);
|
|
442
|
-
}
|
|
443
|
-
|
|
444
|
-
/**
|
|
445
|
-
* @details
|
|
446
|
-
* This operator overload formats output for expressions that may throw
|
|
447
|
-
* exceptions. It applies colour styling for clarity and ensures a structured
|
|
448
|
-
* representation of the exception handling mechanism.
|
|
449
|
-
*
|
|
450
|
-
* When invoked, the output highlights the `throws` qualifier, making it
|
|
451
|
-
* immediately apparent when an expression is expected to throw, thereby
|
|
452
|
-
* improving the readability and professionalism of the test output.
|
|
453
|
-
*/
|
|
454
|
-
template <class Expr_T>
|
|
455
|
-
reporter&
|
|
456
|
-
reporter::operator<< (const detail::throws_<Expr_T, void>& op)
|
|
457
|
-
{
|
|
458
|
-
return (*this << colour_ (op) << "throws" << colours_.none);
|
|
459
|
-
}
|
|
460
|
-
|
|
461
|
-
/**
|
|
462
|
-
* @details
|
|
463
|
-
* This operator overload formats output for expressions that do not throw
|
|
464
|
-
* exceptions. It applies colour styling for clarity and ensures a structured
|
|
465
|
-
* and concise representation of exception safety within test reports.
|
|
466
|
-
*
|
|
467
|
-
* The output highlights the `nothrow` qualifier, making it immediately
|
|
468
|
-
* apparent when an expression is guaranteed not to throw, thereby improving
|
|
469
|
-
* the readability and professionalism of the test output.
|
|
470
|
-
*/
|
|
471
|
-
template <class Expr_T>
|
|
472
|
-
reporter&
|
|
473
|
-
reporter::operator<< (const detail::nothrow_<Expr_T>& op)
|
|
474
|
-
{
|
|
475
|
-
return (*this << colour_ (op) << "nothrow" << colours_.none);
|
|
476
|
-
}
|
|
477
|
-
#endif
|
|
478
|
-
|
|
479
|
-
/**
|
|
480
|
-
* @details
|
|
481
|
-
* Outputs a pass prefix, followed by either the provided message or, if
|
|
482
|
-
* the message is empty, the evaluated expression itself. A pass suffix is
|
|
483
|
-
* then appended to complete the output, ensuring that successful test
|
|
484
|
-
* outcomes are presented in a clear and consistent manner.
|
|
485
|
-
*/
|
|
486
|
-
template <class Expr_T>
|
|
487
|
-
void
|
|
488
|
-
reporter::pass (Expr_T& expr, std::string& message, subtest& subtest)
|
|
489
|
-
{
|
|
490
|
-
// current_test_suite->current_test_case.index++;
|
|
491
|
-
|
|
492
|
-
output_pass_prefix_ (message, subtest);
|
|
493
|
-
|
|
494
|
-
if (message.empty ())
|
|
495
|
-
{
|
|
496
|
-
// If there is no message, display the evaluated expression.
|
|
497
|
-
*this << expr;
|
|
498
|
-
}
|
|
499
|
-
|
|
500
|
-
output_pass_suffix_ (subtest);
|
|
501
|
-
}
|
|
502
|
-
|
|
503
|
-
/**
|
|
504
|
-
* @details
|
|
505
|
-
* This function reports a test failure and formats the output in a clear and
|
|
506
|
-
* consistent manner. It provides contextual information, including the
|
|
507
|
-
* precise source location, and appends the evaluated expression when
|
|
508
|
-
* applicable. The failure handling process ensures uniformity in the
|
|
509
|
-
* presentation of unsuccessful test cases, aiding in the rapid
|
|
510
|
-
* identification and diagnosis of issues within test reports.
|
|
511
|
-
*/
|
|
512
|
-
template <class Expr_T>
|
|
513
|
-
void
|
|
514
|
-
reporter::fail (Expr_T& expr, bool abort, std::string& message,
|
|
515
|
-
const reflection::source_location& location,
|
|
516
|
-
subtest& subtest)
|
|
517
|
-
{
|
|
518
|
-
// current_test_suite->current_test_case.index++;
|
|
519
|
-
|
|
520
|
-
const bool hasExpression = type_traits::is_op<Expr_T>;
|
|
521
|
-
output_fail_prefix_ (message, hasExpression, location, subtest);
|
|
522
|
-
|
|
523
|
-
if constexpr (type_traits::is_op<Expr_T>)
|
|
524
|
-
{
|
|
525
|
-
*this << expr;
|
|
526
|
-
}
|
|
527
|
-
|
|
528
|
-
output_fail_suffix_ (location, abort, subtest);
|
|
529
|
-
}
|
|
530
|
-
|
|
531
190
|
// --------------------------------------------------------------------------
|
|
532
191
|
} // namespace micro_os_plus::micro_test_plus
|
|
533
192
|
|
|
@@ -45,6 +45,12 @@
|
|
|
45
45
|
|
|
46
46
|
// ----------------------------------------------------------------------------
|
|
47
47
|
|
|
48
|
+
#if defined(MICRO_OS_PLUS_TRACE)
|
|
49
|
+
#include <micro-os-plus/diag/trace.h>
|
|
50
|
+
#endif // MICRO_OS_PLUS_TRACE
|
|
51
|
+
|
|
52
|
+
// ----------------------------------------------------------------------------
|
|
53
|
+
|
|
48
54
|
#if defined(__GNUC__)
|
|
49
55
|
#pragma GCC diagnostic push
|
|
50
56
|
#pragma GCC diagnostic ignored "-Waggregate-return"
|
|
@@ -60,6 +66,38 @@
|
|
|
60
66
|
|
|
61
67
|
namespace micro_os_plus::micro_test_plus
|
|
62
68
|
{
|
|
69
|
+
// ==========================================================================
|
|
70
|
+
|
|
71
|
+
/**
|
|
72
|
+
* @details
|
|
73
|
+
* Returns a reference to the reporter object stored in the unique pointer.
|
|
74
|
+
*/
|
|
75
|
+
inline class reporter&
|
|
76
|
+
runner::reporter (void) const noexcept
|
|
77
|
+
{
|
|
78
|
+
return *reporter_;
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
/**
|
|
82
|
+
* @details
|
|
83
|
+
* Returns a reference to the `timestamps` member.
|
|
84
|
+
*/
|
|
85
|
+
inline detail::timestamps&
|
|
86
|
+
runner::timings () noexcept
|
|
87
|
+
{
|
|
88
|
+
return timings_;
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
/**
|
|
92
|
+
* @details
|
|
93
|
+
* Returns a const reference to the `timestamps` member.
|
|
94
|
+
*/
|
|
95
|
+
inline const detail::timestamps&
|
|
96
|
+
runner::timings () const noexcept
|
|
97
|
+
{
|
|
98
|
+
return timings_;
|
|
99
|
+
}
|
|
100
|
+
|
|
63
101
|
// --------------------------------------------------------------------------
|
|
64
102
|
|
|
65
103
|
/**
|
|
@@ -0,0 +1,152 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* This file is part of the µOS++ project (https://micro-os-plus.github.io/).
|
|
3
|
+
* Copyright (c) 2021-2026 Liviu Ionescu. All rights reserved.
|
|
4
|
+
*
|
|
5
|
+
* Permission to use, copy, modify, and/or distribute this software for any
|
|
6
|
+
* purpose is hereby granted, under the terms of the MIT license.
|
|
7
|
+
*
|
|
8
|
+
* If a copy of the license was not distributed with this file, it can be
|
|
9
|
+
* obtained from https://opensource.org/licenses/mit.
|
|
10
|
+
*
|
|
11
|
+
* Major parts of the code are inspired from v1.1.8 of the Boost UT project,
|
|
12
|
+
* released under the terms of the Boost Version 1.0 Software License,
|
|
13
|
+
* which can be obtained from https://www.boost.org/LICENSE_1_0.txt.
|
|
14
|
+
*/
|
|
15
|
+
|
|
16
|
+
// ----------------------------------------------------------------------------
|
|
17
|
+
|
|
18
|
+
/**
|
|
19
|
+
* @file
|
|
20
|
+
* @brief C++ header file with inline implementations for the µTest++
|
|
21
|
+
* runner totals.
|
|
22
|
+
*
|
|
23
|
+
* @details
|
|
24
|
+
* This header provides the inline method bodies for the `runner_totals`
|
|
25
|
+
* class, separated from the class declaration in `runner-totals.h` to
|
|
26
|
+
* enforce the project convention that declarations reside in headers
|
|
27
|
+
* and implementations reside in inline files.
|
|
28
|
+
*
|
|
29
|
+
* All definitions reside within the `micro_os_plus::micro_test_plus`
|
|
30
|
+
* namespace, ensuring clear separation from user code and minimising
|
|
31
|
+
* the risk of naming conflicts.
|
|
32
|
+
*/
|
|
33
|
+
|
|
34
|
+
#ifndef MICRO_TEST_PLUS_RUNNER_TOTALS_INLINES_H_
|
|
35
|
+
#define MICRO_TEST_PLUS_RUNNER_TOTALS_INLINES_H_
|
|
36
|
+
|
|
37
|
+
// ----------------------------------------------------------------------------
|
|
38
|
+
|
|
39
|
+
#ifdef __cplusplus
|
|
40
|
+
|
|
41
|
+
// ----------------------------------------------------------------------------
|
|
42
|
+
|
|
43
|
+
#if defined(__GNUC__)
|
|
44
|
+
#pragma GCC diagnostic push
|
|
45
|
+
#if defined(__clang__)
|
|
46
|
+
#pragma clang diagnostic ignored "-Wc++98-compat"
|
|
47
|
+
#endif
|
|
48
|
+
#endif
|
|
49
|
+
|
|
50
|
+
// ============================================================================
|
|
51
|
+
|
|
52
|
+
namespace micro_os_plus::micro_test_plus::detail
|
|
53
|
+
{
|
|
54
|
+
// ==========================================================================
|
|
55
|
+
|
|
56
|
+
/**
|
|
57
|
+
* @details
|
|
58
|
+
* Adds `count` to the `successful_checks_` counter.
|
|
59
|
+
*/
|
|
60
|
+
inline void
|
|
61
|
+
runner_totals::increment_successful_checks (size_t count) noexcept
|
|
62
|
+
{
|
|
63
|
+
successful_checks_ += count;
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
/**
|
|
67
|
+
* @details
|
|
68
|
+
* Adds `count` to the `failed_checks_` counter.
|
|
69
|
+
*/
|
|
70
|
+
inline void
|
|
71
|
+
runner_totals::increment_failed_checks (size_t count) noexcept
|
|
72
|
+
{
|
|
73
|
+
failed_checks_ += count;
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
/**
|
|
77
|
+
* @details
|
|
78
|
+
* Adds `count` to the `executed_subtests_` counter.
|
|
79
|
+
*/
|
|
80
|
+
inline void
|
|
81
|
+
runner_totals::increment_executed_subtests (size_t count) noexcept
|
|
82
|
+
{
|
|
83
|
+
executed_subtests_ += count;
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
/**
|
|
87
|
+
* @details
|
|
88
|
+
* Returns the value of the `successful_checks_` counter.
|
|
89
|
+
*/
|
|
90
|
+
inline size_t
|
|
91
|
+
runner_totals::successful_checks () const noexcept
|
|
92
|
+
{
|
|
93
|
+
return successful_checks_;
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
/**
|
|
97
|
+
* @details
|
|
98
|
+
* Returns the value of the `failed_checks_` counter.
|
|
99
|
+
*/
|
|
100
|
+
inline size_t
|
|
101
|
+
runner_totals::failed_checks () const noexcept
|
|
102
|
+
{
|
|
103
|
+
return failed_checks_;
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
/**
|
|
107
|
+
* @details
|
|
108
|
+
* Returns the sum of `successful_checks_` and `failed_checks_`.
|
|
109
|
+
*/
|
|
110
|
+
inline size_t
|
|
111
|
+
runner_totals::executed_checks () const noexcept
|
|
112
|
+
{
|
|
113
|
+
return successful_checks_ + failed_checks_;
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
/**
|
|
117
|
+
* @details
|
|
118
|
+
* Returns the value of the `executed_subtests_` counter.
|
|
119
|
+
*/
|
|
120
|
+
inline size_t
|
|
121
|
+
runner_totals::executed_subtests () const noexcept
|
|
122
|
+
{
|
|
123
|
+
return executed_subtests_;
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
/**
|
|
127
|
+
* @details
|
|
128
|
+
* A runner with no checks at all is considered successful, as it
|
|
129
|
+
* did not fail any check.
|
|
130
|
+
*/
|
|
131
|
+
inline bool
|
|
132
|
+
runner_totals::was_successful (void) const noexcept
|
|
133
|
+
{
|
|
134
|
+
return failed_checks_ == 0;
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
// --------------------------------------------------------------------------
|
|
138
|
+
} // namespace micro_os_plus::micro_test_plus::detail
|
|
139
|
+
|
|
140
|
+
#if defined(__GNUC__)
|
|
141
|
+
#pragma GCC diagnostic pop
|
|
142
|
+
#endif
|
|
143
|
+
|
|
144
|
+
// ----------------------------------------------------------------------------
|
|
145
|
+
|
|
146
|
+
#endif // __cplusplus
|
|
147
|
+
|
|
148
|
+
// ----------------------------------------------------------------------------
|
|
149
|
+
|
|
150
|
+
#endif // MICRO_TEST_PLUS_RUNNER_TOTALS_INLINES_H_
|
|
151
|
+
|
|
152
|
+
// ----------------------------------------------------------------------------
|