@micro-os-plus/micro-test-plus 4.0.0 → 4.1.0
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 +82 -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 +231 -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 +19 -67
- 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
|
@@ -59,9 +59,12 @@
|
|
|
59
59
|
#include <string>
|
|
60
60
|
#include <memory>
|
|
61
61
|
#include <vector>
|
|
62
|
+
#include <charconv>
|
|
62
63
|
|
|
63
64
|
#include "type-traits.h"
|
|
64
65
|
#include "detail.h"
|
|
66
|
+
#include "expression-formatter.h"
|
|
67
|
+
#include "reflection.h"
|
|
65
68
|
|
|
66
69
|
// ----------------------------------------------------------------------------
|
|
67
70
|
|
|
@@ -81,46 +84,6 @@ namespace micro_os_plus::micro_test_plus
|
|
|
81
84
|
{
|
|
82
85
|
// --------------------------------------------------------------------------
|
|
83
86
|
|
|
84
|
-
/**
|
|
85
|
-
* @struct colours
|
|
86
|
-
* @brief Colours used to highlight pass and fail results in test reports.
|
|
87
|
-
*
|
|
88
|
-
* @details
|
|
89
|
-
* The `colours` structure defines ANSI escape sequences for terminal output,
|
|
90
|
-
* enabling colour-coded highlighting of test outcomes. The `pass` member
|
|
91
|
-
* specifies the colour for successful results (typically green), while the
|
|
92
|
-
* `fail` member specifies the colour for failed results (typically red). The
|
|
93
|
-
* `none` member resets the colour to the terminal default.
|
|
94
|
-
*
|
|
95
|
-
* These colour codes enhance the clarity and professionalism of test reports
|
|
96
|
-
* by making it immediately apparent which tests have passed or failed,
|
|
97
|
-
* thereby improving the overall user experience when reviewing test results.
|
|
98
|
-
*
|
|
99
|
-
* @var colours::none
|
|
100
|
-
* ANSI escape sequence to reset the terminal colour to default.
|
|
101
|
-
* @var colours::pass
|
|
102
|
-
* ANSI escape sequence to set the terminal colour for passing results
|
|
103
|
-
* (green).
|
|
104
|
-
* @var colours::fail
|
|
105
|
-
* ANSI escape sequence to set the terminal colour for failing results (red).
|
|
106
|
-
*
|
|
107
|
-
* @headerfile micro-test-plus.h <micro-os-plus/micro-test-plus.h>
|
|
108
|
-
*/
|
|
109
|
-
struct colours
|
|
110
|
-
{
|
|
111
|
-
const char* none = ""; /**< @brief Terminal colour reset sequence. */
|
|
112
|
-
const char* pass
|
|
113
|
-
= ""; /**< @brief Terminal colour sequence for passing tests. */
|
|
114
|
-
const char* fail
|
|
115
|
-
= ""; /**< @brief Terminal colour sequence for failing tests. */
|
|
116
|
-
};
|
|
117
|
-
|
|
118
|
-
inline constexpr colours colours_red_green = {
|
|
119
|
-
"\033[0m", /**< @brief Terminal colour reset sequence. */
|
|
120
|
-
"\033[32m", /**< @brief Green colour sequence for passing tests. */
|
|
121
|
-
"\033[31m" /**< @brief Red colour sequence for failing tests. */
|
|
122
|
-
};
|
|
123
|
-
|
|
124
87
|
/**
|
|
125
88
|
* @brief The verbosity levels for test reporting.
|
|
126
89
|
*
|
|
@@ -147,6 +110,8 @@ namespace micro_os_plus::micro_test_plus
|
|
|
147
110
|
// Forward definitions.
|
|
148
111
|
class reporter;
|
|
149
112
|
class runner;
|
|
113
|
+
class suite;
|
|
114
|
+
class subtest;
|
|
150
115
|
|
|
151
116
|
/**
|
|
152
117
|
* @brief Output stream manipulator for ending a line in test reports.
|
|
@@ -158,17 +123,24 @@ namespace micro_os_plus::micro_test_plus
|
|
|
158
123
|
reporter&
|
|
159
124
|
endl (reporter& stream);
|
|
160
125
|
|
|
161
|
-
|
|
162
|
-
* @brief Parameterised stream manipulator for outputting indentation.
|
|
163
|
-
*
|
|
164
|
-
* @details
|
|
165
|
-
* Holds the indentation level; used with `operator<<` on `reporter`
|
|
166
|
-
* so that `*this << indent(n) << "text"` works naturally in chains.
|
|
167
|
-
*/
|
|
168
|
-
struct indent_t
|
|
126
|
+
namespace detail
|
|
169
127
|
{
|
|
170
|
-
|
|
171
|
-
|
|
128
|
+
// ------------------------------------------------------------------------
|
|
129
|
+
|
|
130
|
+
/**
|
|
131
|
+
* @brief Parameterised stream manipulator for outputting indentation.
|
|
132
|
+
*
|
|
133
|
+
* @details
|
|
134
|
+
* Holds the indentation level; used with `operator<<` on `reporter`
|
|
135
|
+
* so that `*this << indent(n) << "text"` works naturally in chains.
|
|
136
|
+
*/
|
|
137
|
+
struct indent_t
|
|
138
|
+
{
|
|
139
|
+
size_t level; /**< @brief Number of four-space indentation levels. */
|
|
140
|
+
};
|
|
141
|
+
|
|
142
|
+
// ------------------------------------------------------------------------
|
|
143
|
+
} // namespace detail
|
|
172
144
|
|
|
173
145
|
/**
|
|
174
146
|
* @brief Factory function that creates an `indent_t` manipulator.
|
|
@@ -176,11 +148,10 @@ namespace micro_os_plus::micro_test_plus
|
|
|
176
148
|
* @param level The number of four-space indentation levels.
|
|
177
149
|
* @return An `indent_t` value for use with `operator<<`.
|
|
178
150
|
*/
|
|
179
|
-
[[nodiscard]]
|
|
180
|
-
indent (size_t level)
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
}
|
|
151
|
+
[[nodiscard]] detail::indent_t
|
|
152
|
+
indent (size_t level);
|
|
153
|
+
|
|
154
|
+
// ==========================================================================
|
|
184
155
|
|
|
185
156
|
/**
|
|
186
157
|
* @brief Reporter to display test results, including operand values and
|
|
@@ -217,11 +188,6 @@ namespace micro_os_plus::micro_test_plus
|
|
|
217
188
|
/**
|
|
218
189
|
* @brief Constructor for the reporter class.
|
|
219
190
|
*
|
|
220
|
-
* @details
|
|
221
|
-
* Parses the command-line arguments to determine the desired verbosity
|
|
222
|
-
* level and applies it to the reporter. The `--verbose`, `--quiet`, and
|
|
223
|
-
* `--silent` options are recognised.
|
|
224
|
-
*
|
|
225
191
|
* @param argvs Owning pointer to the command-line arguments vector;
|
|
226
192
|
* the reporter takes ownership via move.
|
|
227
193
|
*/
|
|
@@ -275,121 +241,17 @@ namespace micro_os_plus::micro_test_plus
|
|
|
275
241
|
reporter& operator<< (std::nullptr_t);
|
|
276
242
|
|
|
277
243
|
/**
|
|
278
|
-
* @brief Output operator for
|
|
279
|
-
*
|
|
280
|
-
* @param c The signed char value to output.
|
|
281
|
-
* @return Reference to the current reporter instance.
|
|
282
|
-
*/
|
|
283
|
-
reporter&
|
|
284
|
-
operator<< (signed char c);
|
|
285
|
-
|
|
286
|
-
/**
|
|
287
|
-
* @brief Output operator for unsigned char values.
|
|
288
|
-
*
|
|
289
|
-
* @param c The unsigned char value to output.
|
|
290
|
-
* @return Reference to the current reporter instance.
|
|
291
|
-
*/
|
|
292
|
-
reporter&
|
|
293
|
-
operator<< (unsigned char c);
|
|
294
|
-
|
|
295
|
-
/**
|
|
296
|
-
* @brief Output operator for signed short values.
|
|
297
|
-
*
|
|
298
|
-
* @param v The signed short value to output.
|
|
299
|
-
* @return Reference to the current reporter instance.
|
|
300
|
-
*/
|
|
301
|
-
reporter&
|
|
302
|
-
operator<< (signed short v);
|
|
303
|
-
|
|
304
|
-
/**
|
|
305
|
-
* @brief Output operator for unsigned short values.
|
|
306
|
-
*
|
|
307
|
-
* @param v The unsigned short value to output.
|
|
308
|
-
* @return Reference to the current reporter instance.
|
|
309
|
-
*/
|
|
310
|
-
reporter&
|
|
311
|
-
operator<< (unsigned short v);
|
|
312
|
-
|
|
313
|
-
/**
|
|
314
|
-
* @brief Output operator for signed int values.
|
|
315
|
-
*
|
|
316
|
-
* @param v The signed int value to output.
|
|
317
|
-
* @return Reference to the current reporter instance.
|
|
318
|
-
*/
|
|
319
|
-
reporter&
|
|
320
|
-
operator<< (signed int v);
|
|
321
|
-
|
|
322
|
-
/**
|
|
323
|
-
* @brief Output operator for unsigned int values.
|
|
244
|
+
* @brief Output operator for arithmetic types, with type suffixes.
|
|
324
245
|
*
|
|
325
|
-
* @
|
|
326
|
-
* @return Reference to the current reporter instance.
|
|
327
|
-
*/
|
|
328
|
-
reporter&
|
|
329
|
-
operator<< (unsigned int v);
|
|
330
|
-
|
|
331
|
-
/**
|
|
332
|
-
* @brief Output operator for signed long values.
|
|
333
|
-
*
|
|
334
|
-
* @param v The signed long value to output.
|
|
335
|
-
* @return Reference to the current reporter instance.
|
|
336
|
-
*/
|
|
337
|
-
reporter&
|
|
338
|
-
operator<< (signed long v);
|
|
339
|
-
|
|
340
|
-
/**
|
|
341
|
-
* @brief Output operator for unsigned long values.
|
|
246
|
+
* @tparam T The arithmetic type.
|
|
342
247
|
*
|
|
343
|
-
* @param v The
|
|
344
|
-
* @return Reference to the current reporter instance.
|
|
345
|
-
*/
|
|
346
|
-
reporter&
|
|
347
|
-
operator<< (unsigned long v);
|
|
348
|
-
|
|
349
|
-
/**
|
|
350
|
-
* @brief Output operator for signed long long values.
|
|
351
|
-
*
|
|
352
|
-
* @param v The signed long long value to output.
|
|
353
|
-
* @return Reference to the current reporter instance.
|
|
354
|
-
*/
|
|
355
|
-
reporter&
|
|
356
|
-
operator<< (signed long long v);
|
|
357
|
-
|
|
358
|
-
/**
|
|
359
|
-
* @brief Output operator for unsigned long long values.
|
|
360
|
-
*
|
|
361
|
-
* @param v The unsigned long long value to output.
|
|
362
|
-
* @return Reference to the current reporter instance.
|
|
363
|
-
*/
|
|
364
|
-
reporter&
|
|
365
|
-
operator<< (unsigned long long v);
|
|
366
|
-
|
|
367
|
-
/**
|
|
368
|
-
* @brief Output operator for float values.
|
|
369
|
-
*
|
|
370
|
-
* @param v The float value to output.
|
|
371
|
-
* @return Reference to the current reporter instance.
|
|
372
|
-
*/
|
|
373
|
-
reporter&
|
|
374
|
-
operator<< (float v);
|
|
375
|
-
|
|
376
|
-
/**
|
|
377
|
-
* @brief Output operator for double values.
|
|
378
|
-
*
|
|
379
|
-
* @param v The double value to output.
|
|
380
|
-
* @return Reference to the current reporter instance.
|
|
381
|
-
*/
|
|
382
|
-
reporter&
|
|
383
|
-
operator<< (double v);
|
|
384
|
-
|
|
385
|
-
/**
|
|
386
|
-
* @brief Output operator for long double values.
|
|
387
|
-
*
|
|
388
|
-
* @param v The long double value to output.
|
|
248
|
+
* @param v The value to output.
|
|
389
249
|
* @return Reference to the current reporter instance.
|
|
390
250
|
*/
|
|
251
|
+
template <class T>
|
|
252
|
+
requires std::is_arithmetic_v<T>
|
|
391
253
|
reporter&
|
|
392
|
-
operator<< (
|
|
254
|
+
operator<< (T v);
|
|
393
255
|
|
|
394
256
|
/**
|
|
395
257
|
* @brief Output operator to display any pointer.
|
|
@@ -415,202 +277,6 @@ namespace micro_os_plus::micro_test_plus
|
|
|
415
277
|
// ------------------------------------------------------------------------
|
|
416
278
|
// Specific operators.
|
|
417
279
|
|
|
418
|
-
/**
|
|
419
|
-
* @brief Output operator for types with a getter.
|
|
420
|
-
*
|
|
421
|
-
* @tparam T The type with a getter method.
|
|
422
|
-
*
|
|
423
|
-
* @param t The object to output.
|
|
424
|
-
* @return Reference to the current reporter instance.
|
|
425
|
-
*/
|
|
426
|
-
template <class T>
|
|
427
|
-
requires type_traits::is_op<T>
|
|
428
|
-
reporter&
|
|
429
|
-
operator<< (const T& t);
|
|
430
|
-
|
|
431
|
-
/**
|
|
432
|
-
* @brief Output operator to display genuine integers, without the type
|
|
433
|
-
* suffix.
|
|
434
|
-
*
|
|
435
|
-
* @tparam T The underlying integral type.
|
|
436
|
-
*
|
|
437
|
-
* @param v The strongly-typed integral value to output.
|
|
438
|
-
* @return Reference to the current reporter instance.
|
|
439
|
-
*/
|
|
440
|
-
template <class T>
|
|
441
|
-
reporter&
|
|
442
|
-
operator<< (const type_traits::genuine_integral_value<T>& v);
|
|
443
|
-
|
|
444
|
-
/**
|
|
445
|
-
* @brief Output operator to display containers. Iterates all members.
|
|
446
|
-
*
|
|
447
|
-
* @tparam T The container type.
|
|
448
|
-
*
|
|
449
|
-
* @param t The container to output.
|
|
450
|
-
* @return Reference to the current reporter instance.
|
|
451
|
-
*/
|
|
452
|
-
template <class T>
|
|
453
|
-
requires (type_traits::container_like<T>
|
|
454
|
-
and not type_traits::has_npos<T>)
|
|
455
|
-
reporter&
|
|
456
|
-
operator<< (const T& t);
|
|
457
|
-
|
|
458
|
-
/**
|
|
459
|
-
* @brief Output operator to display eq() expressions.
|
|
460
|
-
*
|
|
461
|
-
* @tparam Lhs_T The left-hand side type.
|
|
462
|
-
* @tparam Rhs_T The right-hand side type.
|
|
463
|
-
*
|
|
464
|
-
* @param op The equality comparator expression.
|
|
465
|
-
* @return Reference to the current reporter instance.
|
|
466
|
-
*/
|
|
467
|
-
template <class Lhs_T, class Rhs_T>
|
|
468
|
-
reporter&
|
|
469
|
-
operator<< (const detail::eq_<Lhs_T, Rhs_T>& op);
|
|
470
|
-
|
|
471
|
-
/**
|
|
472
|
-
* @brief Output operator to display ne() expressions.
|
|
473
|
-
*
|
|
474
|
-
* @tparam Lhs_T The left-hand side type.
|
|
475
|
-
* @tparam Rhs_T The right-hand side type.
|
|
476
|
-
*
|
|
477
|
-
* @param op The inequality comparator expression.
|
|
478
|
-
* @return Reference to the current reporter instance.
|
|
479
|
-
*/
|
|
480
|
-
template <class Lhs_T, class Rhs_T>
|
|
481
|
-
reporter&
|
|
482
|
-
operator<< (const detail::ne_<Lhs_T, Rhs_T>& op);
|
|
483
|
-
|
|
484
|
-
/**
|
|
485
|
-
* @brief Output operator to display gt() expressions.
|
|
486
|
-
*
|
|
487
|
-
* @tparam Lhs_T The left-hand side type.
|
|
488
|
-
* @tparam Rhs_T The right-hand side type.
|
|
489
|
-
*
|
|
490
|
-
* @param op The greater-than comparator expression.
|
|
491
|
-
* @return Reference to the current reporter instance.
|
|
492
|
-
*/
|
|
493
|
-
template <class Lhs_T, class Rhs_T>
|
|
494
|
-
reporter&
|
|
495
|
-
operator<< (const detail::gt_<Lhs_T, Rhs_T>& op);
|
|
496
|
-
|
|
497
|
-
/**
|
|
498
|
-
* @brief Output operator to display ge() expressions.
|
|
499
|
-
*
|
|
500
|
-
* @tparam Lhs_T The left-hand side type.
|
|
501
|
-
* @tparam Rhs_T The right-hand side type.
|
|
502
|
-
*
|
|
503
|
-
* @param op The greater-than-or-equal-to comparator expression.
|
|
504
|
-
* @return Reference to the current reporter instance.
|
|
505
|
-
*/
|
|
506
|
-
template <class Lhs_T, class Rhs_T>
|
|
507
|
-
reporter&
|
|
508
|
-
operator<< (const detail::ge_<Lhs_T, Rhs_T>& op);
|
|
509
|
-
|
|
510
|
-
/**
|
|
511
|
-
* @brief Output operator to display lt() expressions.
|
|
512
|
-
*
|
|
513
|
-
* @tparam Lhs_T The left-hand side type.
|
|
514
|
-
* @tparam Rhs_T The right-hand side type.
|
|
515
|
-
*
|
|
516
|
-
* @param op The less-than comparator expression.
|
|
517
|
-
* @return Reference to the current reporter instance.
|
|
518
|
-
*/
|
|
519
|
-
template <class Lhs_T, class Rhs_T>
|
|
520
|
-
reporter&
|
|
521
|
-
operator<< (const detail::lt_<Rhs_T, Lhs_T>& op);
|
|
522
|
-
|
|
523
|
-
/**
|
|
524
|
-
* @brief Output operator to display le() expressions.
|
|
525
|
-
*
|
|
526
|
-
* @tparam Lhs_T The left-hand side type.
|
|
527
|
-
* @tparam Rhs_T The right-hand side type.
|
|
528
|
-
*
|
|
529
|
-
* @param op The less-than-or-equal-to comparator expression.
|
|
530
|
-
* @return Reference to the current reporter instance.
|
|
531
|
-
*/
|
|
532
|
-
template <class Lhs_T, class Rhs_T>
|
|
533
|
-
reporter&
|
|
534
|
-
operator<< (const detail::le_<Rhs_T, Lhs_T>& op);
|
|
535
|
-
|
|
536
|
-
/**
|
|
537
|
-
* @brief Output operator to display and() expressions.
|
|
538
|
-
*
|
|
539
|
-
* @tparam Lhs_T The left-hand side type.
|
|
540
|
-
* @tparam Rhs_T The right-hand side type.
|
|
541
|
-
*
|
|
542
|
-
* @param op The logical conjunction (AND) expression.
|
|
543
|
-
* @return Reference to the current reporter instance.
|
|
544
|
-
*/
|
|
545
|
-
template <class Lhs_T, class Rhs_T>
|
|
546
|
-
reporter&
|
|
547
|
-
operator<< (const detail::and_<Lhs_T, Rhs_T>& op);
|
|
548
|
-
|
|
549
|
-
/**
|
|
550
|
-
* @brief Output operator to display or() expressions.
|
|
551
|
-
*
|
|
552
|
-
* @tparam Lhs_T The left-hand side type.
|
|
553
|
-
* @tparam Rhs_T The right-hand side type.
|
|
554
|
-
*
|
|
555
|
-
* @param op The logical disjunction (OR) expression.
|
|
556
|
-
* @return Reference to the current reporter instance.
|
|
557
|
-
*/
|
|
558
|
-
template <class Lhs_T, class Rhs_T>
|
|
559
|
-
reporter&
|
|
560
|
-
operator<< (const detail::or_<Lhs_T, Rhs_T>& op);
|
|
561
|
-
|
|
562
|
-
/**
|
|
563
|
-
* @brief Output operator to display not() expressions.
|
|
564
|
-
*
|
|
565
|
-
* @tparam T The operand type.
|
|
566
|
-
*
|
|
567
|
-
* @param op The logical negation expression.
|
|
568
|
-
* @return Reference to the current reporter instance.
|
|
569
|
-
*/
|
|
570
|
-
template <class T>
|
|
571
|
-
reporter&
|
|
572
|
-
operator<< (const detail::not_<T>& op);
|
|
573
|
-
|
|
574
|
-
#if defined(__cpp_exceptions)
|
|
575
|
-
/**
|
|
576
|
-
* @brief Output operator to display throws expressions for a specific
|
|
577
|
-
* exception type.
|
|
578
|
-
*
|
|
579
|
-
* @tparam Expr_T The expression type.
|
|
580
|
-
* @tparam Exception_T The exception type.
|
|
581
|
-
*
|
|
582
|
-
* @param op The throws comparator expression.
|
|
583
|
-
* @return Reference to the current reporter instance.
|
|
584
|
-
*/
|
|
585
|
-
template <class Expr_T, class Exception_T>
|
|
586
|
-
reporter&
|
|
587
|
-
operator<< (const detail::throws_<Expr_T, Exception_T>& op);
|
|
588
|
-
|
|
589
|
-
/**
|
|
590
|
-
* @brief Output operator to display throws expressions for any exception.
|
|
591
|
-
*
|
|
592
|
-
* @tparam Expr_T The expression type.
|
|
593
|
-
*
|
|
594
|
-
* @param op The throws comparator expression.
|
|
595
|
-
* @return Reference to the current reporter instance.
|
|
596
|
-
*/
|
|
597
|
-
template <class Expr_T>
|
|
598
|
-
reporter&
|
|
599
|
-
operator<< (const detail::throws_<Expr_T, void>& op);
|
|
600
|
-
|
|
601
|
-
/**
|
|
602
|
-
* @brief Output operator to display nothrow expressions.
|
|
603
|
-
*
|
|
604
|
-
* @tparam Expr_T The expression type.
|
|
605
|
-
*
|
|
606
|
-
* @param op The nothrow comparator expression.
|
|
607
|
-
* @return Reference to the current reporter instance.
|
|
608
|
-
*/
|
|
609
|
-
template <class Expr_T>
|
|
610
|
-
reporter&
|
|
611
|
-
operator<< (const detail::nothrow_<Expr_T>& op);
|
|
612
|
-
#endif
|
|
613
|
-
|
|
614
280
|
// ------------------------------------------------------------------------
|
|
615
281
|
|
|
616
282
|
/**
|
|
@@ -656,35 +322,33 @@ namespace micro_os_plus::micro_test_plus
|
|
|
656
322
|
/**
|
|
657
323
|
* @brief Report a passed condition.
|
|
658
324
|
*
|
|
659
|
-
* @tparam Expr_T The expression type.
|
|
660
|
-
*
|
|
661
|
-
* @param expr The evaluated expression.
|
|
662
325
|
* @param message The message to display.
|
|
326
|
+
* @param expression The string representation of the expression.
|
|
663
327
|
* @param subtest The subtest that owns this check.
|
|
664
328
|
* @par Returns
|
|
665
329
|
* Nothing.
|
|
666
330
|
*/
|
|
667
|
-
template <class Expr_T>
|
|
668
331
|
void
|
|
669
|
-
pass (
|
|
332
|
+
pass (std::string& message, const std::string& expression,
|
|
333
|
+
subtest& subtest);
|
|
670
334
|
|
|
671
335
|
/**
|
|
672
336
|
* @brief Report a failed condition.
|
|
673
337
|
*
|
|
674
|
-
* @tparam Expr_T The expression type.
|
|
675
|
-
*
|
|
676
|
-
* @param expr The evaluated expression.
|
|
677
338
|
* @param abort Whether to abort execution after failure.
|
|
678
339
|
* @param message The message to display.
|
|
340
|
+
* @param expression The string representation of the expression.
|
|
341
|
+
* @param has_expression Whether the expression is a compound op to
|
|
342
|
+
* display.
|
|
679
343
|
* @param location The source location of the failure.
|
|
680
344
|
* @param subtest The subtest that owns this check.
|
|
681
345
|
* @par Returns
|
|
682
346
|
* Nothing.
|
|
683
347
|
*/
|
|
684
|
-
template <class Expr_T>
|
|
685
348
|
void
|
|
686
|
-
fail (
|
|
687
|
-
const reflection::source_location& location,
|
|
349
|
+
fail (bool abort, std::string& message, const std::string& expression,
|
|
350
|
+
bool has_expression, const reflection::source_location& location,
|
|
351
|
+
subtest& subtest);
|
|
688
352
|
|
|
689
353
|
// ------------------------------------------------------------------------
|
|
690
354
|
|
|
@@ -696,7 +360,8 @@ namespace micro_os_plus::micro_test_plus
|
|
|
696
360
|
* Nothing.
|
|
697
361
|
*/
|
|
698
362
|
virtual void
|
|
699
|
-
begin_session (runner& runner)
|
|
363
|
+
begin_session (runner& runner)
|
|
364
|
+
= 0;
|
|
700
365
|
|
|
701
366
|
/**
|
|
702
367
|
* @brief Mark the end of a test session.
|
|
@@ -706,7 +371,8 @@ namespace micro_os_plus::micro_test_plus
|
|
|
706
371
|
* Nothing.
|
|
707
372
|
*/
|
|
708
373
|
virtual void
|
|
709
|
-
end_session (runner& runner)
|
|
374
|
+
end_session (runner& runner)
|
|
375
|
+
= 0;
|
|
710
376
|
|
|
711
377
|
/**
|
|
712
378
|
* @brief Mark the beginning of a test suite.
|
|
@@ -716,7 +382,8 @@ namespace micro_os_plus::micro_test_plus
|
|
|
716
382
|
* Nothing.
|
|
717
383
|
*/
|
|
718
384
|
virtual void
|
|
719
|
-
begin_suite (suite& suite)
|
|
385
|
+
begin_suite (suite& suite)
|
|
386
|
+
= 0;
|
|
720
387
|
|
|
721
388
|
/**
|
|
722
389
|
* @brief Mark the end of a test suite.
|
|
@@ -726,7 +393,8 @@ namespace micro_os_plus::micro_test_plus
|
|
|
726
393
|
* Nothing.
|
|
727
394
|
*/
|
|
728
395
|
virtual void
|
|
729
|
-
end_suite (suite& suite)
|
|
396
|
+
end_suite (suite& suite)
|
|
397
|
+
= 0;
|
|
730
398
|
|
|
731
399
|
/**
|
|
732
400
|
* @brief Mark the beginning of a subtest.
|
|
@@ -736,7 +404,8 @@ namespace micro_os_plus::micro_test_plus
|
|
|
736
404
|
* Nothing.
|
|
737
405
|
*/
|
|
738
406
|
virtual void
|
|
739
|
-
begin_subtest (subtest& subtest)
|
|
407
|
+
begin_subtest (subtest& subtest)
|
|
408
|
+
= 0;
|
|
740
409
|
|
|
741
410
|
/**
|
|
742
411
|
* @brief Mark the end of a subtest.
|
|
@@ -746,21 +415,19 @@ namespace micro_os_plus::micro_test_plus
|
|
|
746
415
|
* Nothing.
|
|
747
416
|
*/
|
|
748
417
|
virtual void
|
|
749
|
-
end_subtest (subtest& subtest)
|
|
418
|
+
end_subtest (subtest& subtest)
|
|
419
|
+
= 0;
|
|
750
420
|
|
|
751
421
|
/**
|
|
752
422
|
* @brief Returns the comment-prefix string used by this reporter format.
|
|
753
423
|
*
|
|
754
|
-
* @details
|
|
755
|
-
* Human reporters return an empty string; TAP reporters return `"# "`
|
|
756
|
-
* so that diagnostic lines conform to the TAP specification.
|
|
757
|
-
*
|
|
758
424
|
* @par Parameters
|
|
759
425
|
* None.
|
|
760
426
|
* @return A null-terminated prefix string.
|
|
761
427
|
*/
|
|
762
428
|
virtual const char*
|
|
763
|
-
get_comment_prefix (void)
|
|
429
|
+
get_comment_prefix (void)
|
|
430
|
+
= 0;
|
|
764
431
|
|
|
765
432
|
/**
|
|
766
433
|
* @brief Returns the current verbosity level.
|
|
@@ -770,10 +437,18 @@ namespace micro_os_plus::micro_test_plus
|
|
|
770
437
|
* @return The active `verbosity` value.
|
|
771
438
|
*/
|
|
772
439
|
auto
|
|
773
|
-
verbosity () const -> micro_test_plus::verbosity
|
|
774
|
-
|
|
775
|
-
|
|
776
|
-
|
|
440
|
+
verbosity () const -> micro_test_plus::verbosity;
|
|
441
|
+
|
|
442
|
+
/**
|
|
443
|
+
* @brief Provides access to the expression formatter for this reporter.
|
|
444
|
+
*
|
|
445
|
+
* @par Parameters
|
|
446
|
+
* None.
|
|
447
|
+
* @return Reference to the `expression_formatter` instance used by this
|
|
448
|
+
* reporter.
|
|
449
|
+
*/
|
|
450
|
+
detail::expression_formatter&
|
|
451
|
+
expression ();
|
|
777
452
|
|
|
778
453
|
// ------------------------------------------------------------------------
|
|
779
454
|
|
|
@@ -783,16 +458,9 @@ namespace micro_os_plus::micro_test_plus
|
|
|
783
458
|
*
|
|
784
459
|
* @param cond Boolean value indicating pass (true) or fail (false).
|
|
785
460
|
* @return The corresponding ANSI colour code as a string.
|
|
786
|
-
*
|
|
787
|
-
* @details
|
|
788
|
-
* Returns the ANSI colour code for pass or fail, depending on the boolean
|
|
789
|
-
* condition provided.
|
|
790
461
|
*/
|
|
791
462
|
[[nodiscard]] inline auto
|
|
792
|
-
colour_ (const bool cond) const
|
|
793
|
-
{
|
|
794
|
-
return cond ? colours_.pass : colours_.fail;
|
|
795
|
-
}
|
|
463
|
+
colour_ (const bool cond) const;
|
|
796
464
|
|
|
797
465
|
void
|
|
798
466
|
write_buffer_to_file_ (void);
|
|
@@ -817,7 +485,8 @@ namespace micro_os_plus::micro_test_plus
|
|
|
817
485
|
* Nothing.
|
|
818
486
|
*/
|
|
819
487
|
virtual void
|
|
820
|
-
output_pass_prefix_ (std::string& message, subtest& subtest)
|
|
488
|
+
output_pass_prefix_ (std::string& message, subtest& subtest)
|
|
489
|
+
= 0;
|
|
821
490
|
|
|
822
491
|
/**
|
|
823
492
|
* @brief Outputs the suffix for a passing condition.
|
|
@@ -827,13 +496,14 @@ namespace micro_os_plus::micro_test_plus
|
|
|
827
496
|
* Nothing.
|
|
828
497
|
*/
|
|
829
498
|
virtual void
|
|
830
|
-
output_pass_suffix_ (subtest& subtest)
|
|
499
|
+
output_pass_suffix_ (subtest& subtest)
|
|
500
|
+
= 0;
|
|
831
501
|
|
|
832
502
|
/**
|
|
833
503
|
* @brief Outputs the prefix for a failing condition.
|
|
834
504
|
*
|
|
835
505
|
* @param message The message to display.
|
|
836
|
-
* @param
|
|
506
|
+
* @param has_expression Whether the failure is associated with an
|
|
837
507
|
* expression.
|
|
838
508
|
* @param location The source location of the failure.
|
|
839
509
|
* @param subtest The subtest that owns this check.
|
|
@@ -841,9 +511,10 @@ namespace micro_os_plus::micro_test_plus
|
|
|
841
511
|
* Nothing.
|
|
842
512
|
*/
|
|
843
513
|
virtual void
|
|
844
|
-
output_fail_prefix_ (std::string& message, const bool
|
|
514
|
+
output_fail_prefix_ (std::string& message, const bool has_expression,
|
|
845
515
|
const reflection::source_location& location,
|
|
846
|
-
subtest& subtest)
|
|
516
|
+
subtest& subtest)
|
|
517
|
+
= 0;
|
|
847
518
|
|
|
848
519
|
/**
|
|
849
520
|
* @brief Outputs the suffix for a failing condition.
|
|
@@ -856,23 +527,8 @@ namespace micro_os_plus::micro_test_plus
|
|
|
856
527
|
*/
|
|
857
528
|
virtual void
|
|
858
529
|
output_fail_suffix_ (const reflection::source_location& location,
|
|
859
|
-
bool abort, subtest& subtest)
|
|
860
|
-
|
|
861
|
-
/**
|
|
862
|
-
* @brief Appends the string representation of a numeric value to a
|
|
863
|
-
* buffer, using `std::to_chars` for allocation-free, locale-independent
|
|
864
|
-
* formatting.
|
|
865
|
-
*
|
|
866
|
-
* @tparam T The numeric type to format.
|
|
867
|
-
*
|
|
868
|
-
* @param buffer The string to append to.
|
|
869
|
-
* @param v The value to format.
|
|
870
|
-
* @par Returns
|
|
871
|
-
* Nothing.
|
|
872
|
-
*/
|
|
873
|
-
template <class T>
|
|
874
|
-
static void
|
|
875
|
-
append_number_ (std::string& buffer, T v);
|
|
530
|
+
bool abort, subtest& subtest)
|
|
531
|
+
= 0;
|
|
876
532
|
|
|
877
533
|
protected:
|
|
878
534
|
/**
|
|
@@ -883,13 +539,29 @@ namespace micro_os_plus::micro_test_plus
|
|
|
883
539
|
/**
|
|
884
540
|
* @brief ANSI colour codes for output formatting.
|
|
885
541
|
*/
|
|
886
|
-
colours colours_{};
|
|
542
|
+
detail::colours colours_{};
|
|
887
543
|
|
|
888
544
|
/**
|
|
889
|
-
* @brief
|
|
545
|
+
* @brief Output accumulation buffer.
|
|
546
|
+
*
|
|
547
|
+
* @details
|
|
548
|
+
* Accumulates all reporter output until it is written to standard
|
|
549
|
+
* output or the output file via `write_buffer_to_stdout()` or
|
|
550
|
+
* `write_buffer_to_file_()`.
|
|
890
551
|
*/
|
|
891
552
|
std::string buffer_{};
|
|
892
553
|
|
|
554
|
+
/**
|
|
555
|
+
* @brief Expression formatter for pass and fail reporting.
|
|
556
|
+
*
|
|
557
|
+
* @details
|
|
558
|
+
* Used in `pass()` and `fail()` to format expression values before
|
|
559
|
+
* appending the result to `buffer_`. Will also be used by
|
|
560
|
+
* `detail::deferred_reporter` to pre-format expressions at
|
|
561
|
+
* construction time.
|
|
562
|
+
*/
|
|
563
|
+
detail::expression_formatter expression_{ colours_ };
|
|
564
|
+
|
|
893
565
|
/**
|
|
894
566
|
* @brief Controls whether to add an empty line between successful test
|
|
895
567
|
* cases.
|
|
@@ -935,6 +607,11 @@ namespace micro_os_plus::micro_test_plus
|
|
|
935
607
|
|
|
936
608
|
#endif // __cplusplus
|
|
937
609
|
|
|
610
|
+
// ============================================================================
|
|
611
|
+
// Templates & constexpr implementations.
|
|
612
|
+
|
|
613
|
+
#include "inlines/reporter-inlines.h"
|
|
614
|
+
|
|
938
615
|
// ----------------------------------------------------------------------------
|
|
939
616
|
|
|
940
617
|
#endif // MICRO_TEST_PLUS_TEST_REPORTER_H_
|