@micro-os-plus/micro-test-plus 3.2.2 → 3.2.3

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.
Files changed (41) hide show
  1. package/.cmake-format.yaml +11 -0
  2. package/CHANGELOG.md +352 -2
  3. package/CMakeLists.txt +32 -30
  4. package/LICENSE +1 -1
  5. package/README.md +1 -1
  6. package/{xcdl.json → config/xcdl-build.json} +6 -6
  7. package/include/micro-os-plus/micro-test-plus/detail.h +1885 -0
  8. package/include/micro-os-plus/micro-test-plus/function-comparators.h +333 -0
  9. package/include/micro-os-plus/micro-test-plus/inlines/details-inlines.h +172 -0
  10. package/include/micro-os-plus/micro-test-plus/inlines/function-comparators-inlines.h +341 -0
  11. package/include/micro-os-plus/micro-test-plus/inlines/literals-inlines.h +604 -0
  12. package/include/micro-os-plus/micro-test-plus/inlines/math-inlines.h +315 -0
  13. package/include/micro-os-plus/micro-test-plus/inlines/micro-test-plus-inlines.h +313 -0
  14. package/include/micro-os-plus/micro-test-plus/inlines/reflection-inlines.h +170 -0
  15. package/include/micro-os-plus/micro-test-plus/inlines/test-reporter-inlines.h +471 -0
  16. package/include/micro-os-plus/micro-test-plus/inlines/test-suite-inlines.h +115 -0
  17. package/include/micro-os-plus/micro-test-plus/literals.h +912 -0
  18. package/include/micro-os-plus/micro-test-plus/math.h +217 -0
  19. package/include/micro-os-plus/micro-test-plus/operators.h +514 -0
  20. package/include/micro-os-plus/micro-test-plus/reflection.h +233 -0
  21. package/include/micro-os-plus/micro-test-plus/test-reporter.h +801 -0
  22. package/include/micro-os-plus/micro-test-plus/test-runner.h +241 -0
  23. package/include/micro-os-plus/micro-test-plus/test-suite.h +456 -0
  24. package/include/micro-os-plus/micro-test-plus/type-traits.h +1148 -0
  25. package/include/micro-os-plus/micro-test-plus.h +169 -551
  26. package/meson.build +5 -5
  27. package/package.json +29 -34
  28. package/src/micro-test-plus.cpp +131 -35
  29. package/src/test-reporter.cpp +348 -6
  30. package/src/test-runner.cpp +69 -5
  31. package/src/test-suite.cpp +124 -5
  32. package/include/micro-os-plus/detail.h +0 -765
  33. package/include/micro-os-plus/inlines.h +0 -209
  34. package/include/micro-os-plus/literals.h +0 -512
  35. package/include/micro-os-plus/math.h +0 -204
  36. package/include/micro-os-plus/reflection.h +0 -139
  37. package/include/micro-os-plus/test-reporter-inlines.h +0 -230
  38. package/include/micro-os-plus/test-reporter.h +0 -356
  39. package/include/micro-os-plus/test-runner.h +0 -132
  40. package/include/micro-os-plus/test-suite.h +0 -306
  41. package/include/micro-os-plus/type-traits.h +0 -389
@@ -0,0 +1,801 @@
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 declarations for the µTest++ test reporter.
21
+ *
22
+ * @details
23
+ * This header provides the declarations for the test reporting facilities used
24
+ * within the µTest++ framework. It defines the interfaces for formatting and
25
+ * outputting test results, including operator overloads for a wide range of
26
+ * value types, containers, and comparison expressions, as well as structured
27
+ * output for logical and exception-related assertions.
28
+ *
29
+ * The test reporter is responsible for presenting test outcomes in a clear,
30
+ * consistent, and expressive manner, supporting both value and pointer
31
+ * semantics, and providing detailed diagnostics for both successful and failed
32
+ * test cases. Special attention is given to formatting, colour highlighting,
33
+ * and extensibility, enabling professional and readable test reports suitable
34
+ * for embedded and general C++ development.
35
+ *
36
+ * All definitions reside within the `micro_os_plus::micro_test_plus`
37
+ * namespace, ensuring clear separation from user code and minimising the risk
38
+ * of naming conflicts.
39
+ *
40
+ * The header files are organised within the
41
+ * `include/micro-os-plus/micro-test-plus` folder to maintain a structured and
42
+ * modular codebase.
43
+ *
44
+ * This file is intended solely for internal use within the framework and
45
+ * should not be included directly by user code.
46
+ */
47
+
48
+ #ifndef MICRO_TEST_PLUS_TEST_REPORTER_H_
49
+ #define MICRO_TEST_PLUS_TEST_REPORTER_H_
50
+
51
+ // ----------------------------------------------------------------------------
52
+
53
+ #ifdef __cplusplus
54
+
55
+ // ----------------------------------------------------------------------------
56
+
57
+ // #include <functional>
58
+ #include <string_view>
59
+ #include <string>
60
+
61
+ #include "type-traits.h"
62
+ #include "test-suite.h"
63
+ #include "detail.h"
64
+
65
+ // ----------------------------------------------------------------------------
66
+
67
+ #if defined(__GNUC__)
68
+ #pragma GCC diagnostic push
69
+ #pragma GCC diagnostic ignored "-Wpadded"
70
+ #pragma GCC diagnostic ignored "-Waggregate-return"
71
+ #if defined(__clang__)
72
+ #pragma clang diagnostic ignored "-Wc++98-compat"
73
+ #pragma clang diagnostic ignored "-Wc++98-compat-pedantic"
74
+ #endif
75
+ #endif
76
+
77
+ namespace micro_os_plus::micro_test_plus
78
+ {
79
+ // --------------------------------------------------------------------------
80
+
81
+ /**
82
+ * @struct colors
83
+ * @brief Colours used to highlight pass and fail results in test reports.
84
+ *
85
+ * @details
86
+ * The `colors` structure defines ANSI escape sequences for terminal output,
87
+ * enabling colour-coded highlighting of test outcomes. The `pass` member
88
+ * specifies the colour for successful results (typically green), while the
89
+ * `fail` member specifies the colour for failed results (typically red). The
90
+ * `none` member resets the colour to the terminal default.
91
+ *
92
+ * These colour codes enhance the clarity and professionalism of test reports
93
+ * by making it immediately apparent which tests have passed or failed,
94
+ * thereby improving the overall user experience when reviewing test results.
95
+ *
96
+ * @var colors::none
97
+ * ANSI escape sequence to reset the terminal colour to default.
98
+ * @var colors::pass
99
+ * ANSI escape sequence to set the terminal colour for passing results
100
+ * (green).
101
+ * @var colors::fail
102
+ * ANSI escape sequence to set the terminal colour for failing results (red).
103
+ *
104
+ * @headerfile micro-test-plus.h <micro-os-plus/micro-test-plus.h>
105
+ */
106
+ struct colors
107
+ {
108
+ const char* none = "\033[0m"; /**< @brief Default colour. */
109
+ const char* pass = "\033[32m"; /**< @brief Green colour. */
110
+ const char* fail = "\033[31m"; /**< @brief Red colour. */
111
+ };
112
+
113
+ /**
114
+ * @brief The verbosity levels for test reporting.
115
+ *
116
+ * @details
117
+ * The `verbosity` enumeration defines the available levels of detail for
118
+ * test output produced by the reporting system. These levels control the
119
+ * amount and type of information displayed during test execution, allowing
120
+ * users to tailor the output to their specific requirements.
121
+ *
122
+ * Selecting an appropriate verbosity level enhances the usability of test
123
+ * reports, whether for concise summaries or comprehensive diagnostics.
124
+ *
125
+ * @headerfile micro-test-plus.h <micro-os-plus/micro-test-plus.h>
126
+ */
127
+ enum class verbosity
128
+ {
129
+ silent = 0, /**< No output is produced; only the exit code is returned. */
130
+ quiet = 1, /**< Displays results for test suites only. */
131
+ normal = 2, /**< Displays results for test suites and failed test cases. */
132
+ verbose = 3 /**< Displays all results, including passed checks, for maximum
133
+ detail. */
134
+ };
135
+
136
+ /**
137
+ * @brief Type alias for the verbosity enumeration used in test reporting.
138
+ *
139
+ * @details
140
+ * The `verbosity_t` type alias provides a convenient shorthand for referring
141
+ * to the `verbosity` enumeration, which defines the available levels of
142
+ * detail for test output within the reporting system.
143
+ *
144
+ * Using this alias improves code readability and consistency throughout the
145
+ * framework, especially when specifying or configuring verbosity levels for
146
+ * test reporters.
147
+ */
148
+ typedef verbosity verbosity_t;
149
+
150
+ // Forward definition.
151
+ class test_reporter;
152
+
153
+ /**
154
+ * @brief Output stream manipulator for ending a line in test reports.
155
+ *
156
+ * @param stream Reference to the `test_reporter` instance.
157
+ * @return Reference to the same `test_reporter` instance, enabling chaining
158
+ * of output operations.
159
+ */
160
+ test_reporter&
161
+ endl (test_reporter& stream);
162
+
163
+ // Requires events::assertion_* for and detailed operators.
164
+
165
+ /**
166
+ * @brief Reporter to display test results, including operand values and
167
+ * types for failures.
168
+ *
169
+ * @details
170
+ * The `test_reporter` class is responsible for formatting and presenting
171
+ * test results within the µTest++ framework. It provides a comprehensive
172
+ * suite of output operators for a wide range of data types, containers, and
173
+ * comparator expressions, enabling detailed and informative reporting of
174
+ * test outcomes.
175
+ *
176
+ * For failed tests, the reporter prints the actual values of the operands
177
+ * along with their types, supporting precise diagnostics and efficient
178
+ * debugging. The class supports multiple verbosity levels and colour-coded
179
+ * output to distinguish between successful and failed tests, thereby
180
+ * enhancing the clarity and professionalism of test reports.
181
+ *
182
+ * The `test_reporter` also offers methods for reporting the commencement and
183
+ * completion of test cases and suites, as well as for handling pass and fail
184
+ * conditions. Additional features include output stream manipulators,
185
+ * support for exception-related expressions, and configurable formatting
186
+ * options.
187
+ *
188
+ * All members and methods are defined within the
189
+ * `micro_os_plus::micro_test_plus` namespace, ensuring clear separation from
190
+ * user code and minimising the risk of naming conflicts.
191
+ *
192
+ * @headerfile micro-test-plus.h <micro-os-plus/micro-test-plus.h>
193
+ */
194
+ class test_reporter
195
+ {
196
+ public:
197
+ /**
198
+ * @brief Default constructor for the test_reporter class.
199
+ */
200
+ test_reporter () = default;
201
+
202
+ /**
203
+ * @brief Selects the appropriate colour code based on a condition.
204
+ *
205
+ * @param cond Boolean value indicating pass (true) or fail (false).
206
+ * @return The corresponding ANSI colour code as a string.
207
+ *
208
+ * @details
209
+ * Returns the ANSI colour code for pass or fail, depending on the boolean
210
+ * condition provided.
211
+ */
212
+ [[nodiscard]] inline auto
213
+ color (const bool cond)
214
+ {
215
+ return cond ? colors_.pass : colors_.fail;
216
+ }
217
+
218
+ /**
219
+ * @brief Output operator for std::string_view.
220
+ *
221
+ * @param sv The string view to output.
222
+ * @return Reference to the current test_reporter instance.
223
+ */
224
+ test_reporter&
225
+ operator<< (std::string_view sv);
226
+
227
+ /**
228
+ * @brief Output operator for a single character.
229
+ *
230
+ * @param c The character to output.
231
+ * @return Reference to the current test_reporter instance.
232
+ */
233
+ test_reporter&
234
+ operator<< (char c);
235
+
236
+ /**
237
+ * @brief Output operator for a constant character string.
238
+ *
239
+ * @param s The string to output.
240
+ * @return Reference to the current test_reporter instance.
241
+ */
242
+ test_reporter&
243
+ operator<< (const char* s);
244
+
245
+ /**
246
+ * @brief Output operator for a mutable character string.
247
+ *
248
+ * @param s The string to output.
249
+ * @return Reference to the current test_reporter instance.
250
+ */
251
+ test_reporter&
252
+ operator<< (char* s);
253
+
254
+ /**
255
+ * @brief Output operator for boolean values.
256
+ *
257
+ * @param v The boolean value to output.
258
+ * @return Reference to the current test_reporter instance.
259
+ */
260
+ test_reporter&
261
+ operator<< (bool v);
262
+
263
+ /**
264
+ * @brief Output operator for nullptr.
265
+ * @return Reference to the current test_reporter instance.
266
+ */
267
+ test_reporter& operator<< (std::nullptr_t);
268
+
269
+ /**
270
+ * @brief Output operator for signed char values.
271
+ *
272
+ * @param c The signed char value to output.
273
+ * @return Reference to the current test_reporter instance.
274
+ */
275
+ test_reporter&
276
+ operator<< (signed char c);
277
+
278
+ /**
279
+ * @brief Output operator for unsigned char values.
280
+ *
281
+ * @param c The unsigned char value to output.
282
+ * @return Reference to the current test_reporter instance.
283
+ */
284
+ test_reporter&
285
+ operator<< (unsigned char c);
286
+
287
+ /**
288
+ * @brief Output operator for signed short values.
289
+ *
290
+ * @param v The signed short value to output.
291
+ * @return Reference to the current test_reporter instance.
292
+ */
293
+ test_reporter&
294
+ operator<< (signed short v);
295
+
296
+ /**
297
+ * @brief Output operator for unsigned short values.
298
+ *
299
+ * @param v The unsigned short value to output.
300
+ * @return Reference to the current test_reporter instance.
301
+ */
302
+ test_reporter&
303
+ operator<< (unsigned short v);
304
+
305
+ /**
306
+ * @brief Output operator for signed int values.
307
+ *
308
+ * @param v The signed int value to output.
309
+ * @return Reference to the current test_reporter instance.
310
+ */
311
+ test_reporter&
312
+ operator<< (signed int v);
313
+
314
+ /**
315
+ * @brief Output operator for unsigned int values.
316
+ *
317
+ * @param v The unsigned int value to output.
318
+ * @return Reference to the current test_reporter instance.
319
+ */
320
+ test_reporter&
321
+ operator<< (unsigned int v);
322
+
323
+ /**
324
+ * @brief Output operator for signed long values.
325
+ *
326
+ * @param v The signed long value to output.
327
+ * @return Reference to the current test_reporter instance.
328
+ */
329
+ test_reporter&
330
+ operator<< (signed long v);
331
+
332
+ /**
333
+ * @brief Output operator for unsigned long values.
334
+ *
335
+ * @param v The unsigned long value to output.
336
+ * @return Reference to the current test_reporter instance.
337
+ */
338
+ test_reporter&
339
+ operator<< (unsigned long v);
340
+
341
+ /**
342
+ * @brief Output operator for signed long long values.
343
+ *
344
+ * @param v The signed long long value to output.
345
+ * @return Reference to the current test_reporter instance.
346
+ */
347
+ test_reporter&
348
+ operator<< (signed long long v);
349
+
350
+ /**
351
+ * @brief Output operator for unsigned long long values.
352
+ *
353
+ * @param v The unsigned long long value to output.
354
+ * @return Reference to the current test_reporter instance.
355
+ */
356
+ test_reporter&
357
+ operator<< (unsigned long long v);
358
+
359
+ /**
360
+ * @brief Output operator for float values.
361
+ *
362
+ * @param v The float value to output.
363
+ * @return Reference to the current test_reporter instance.
364
+ */
365
+ test_reporter&
366
+ operator<< (float v);
367
+
368
+ /**
369
+ * @brief Output operator for double values.
370
+ *
371
+ * @param v The double value to output.
372
+ * @return Reference to the current test_reporter instance.
373
+ */
374
+ test_reporter&
375
+ operator<< (double v);
376
+
377
+ /**
378
+ * @brief Output operator for long double values.
379
+ *
380
+ * @param v The long double value to output.
381
+ * @return Reference to the current test_reporter instance.
382
+ */
383
+ test_reporter&
384
+ operator<< (long double v);
385
+
386
+ /**
387
+ * @brief Output operator to display any pointer.
388
+ *
389
+ * @tparam T The type of the pointer.
390
+ *
391
+ * @param v The pointer value to output.
392
+ * @return Reference to the current test_reporter instance.
393
+ */
394
+ template <typename T>
395
+ test_reporter&
396
+ operator<< (T* v);
397
+
398
+ /**
399
+ * @brief Output operator to display the endl.
400
+ *
401
+ * @param func Function pointer to the stream manipulator.
402
+ * @return Reference to the current test_reporter instance.
403
+ */
404
+ test_reporter&
405
+ operator<< (test_reporter& (*func) (test_reporter&));
406
+
407
+ // ------------------------------------------------------------------------
408
+ // Specific operators.
409
+
410
+ /**
411
+ * @brief Output operator for types with a getter.
412
+ *
413
+ * @tparam T The type with a getter method.
414
+ *
415
+ * @param t The object to output.
416
+ * @return Reference to the current test_reporter instance.
417
+ */
418
+ template <class T>
419
+ test_reporter&
420
+ operator<< (const T& t);
421
+
422
+ /**
423
+ * @brief Output operator to display genuine integers, without the type
424
+ * suffix.
425
+ *
426
+ * @tparam T The underlying integral type.
427
+ *
428
+ * @param v The strongly-typed integral value to output.
429
+ * @return Reference to the current test_reporter instance.
430
+ */
431
+ template <class T>
432
+ test_reporter&
433
+ operator<< (const type_traits::genuine_integral_value<T>& v);
434
+
435
+ /**
436
+ * @brief Output operator to display containers. Iterates all members.
437
+ *
438
+ * @tparam T The container type.
439
+ *
440
+ * @param t The container to output.
441
+ * @return Reference to the current test_reporter instance.
442
+ */
443
+ template <class T,
444
+ type_traits::requires_t<type_traits::is_container_v<T>
445
+ and not type_traits::has_npos_v<T>>
446
+ = 0>
447
+ test_reporter&
448
+ operator<< (T&& t);
449
+
450
+ /**
451
+ * @brief Output operator to display eq() expressions.
452
+ *
453
+ * @tparam Lhs_T The left-hand side type.
454
+ * @tparam Rhs_T The right-hand side type.
455
+ *
456
+ * @param op The equality comparator expression.
457
+ * @return Reference to the current test_reporter instance.
458
+ */
459
+ template <class Lhs_T, class Rhs_T>
460
+ test_reporter&
461
+ operator<< (const detail::eq_<Lhs_T, Rhs_T>& op);
462
+
463
+ /**
464
+ * @brief Output operator to display ne() expressions.
465
+ *
466
+ * @tparam Lhs_T The left-hand side type.
467
+ * @tparam Rhs_T The right-hand side type.
468
+ *
469
+ * @param op The inequality comparator expression.
470
+ * @return Reference to the current test_reporter instance.
471
+ */
472
+ template <class Lhs_T, class Rhs_T>
473
+ test_reporter&
474
+ operator<< (const detail::ne_<Lhs_T, Rhs_T>& op);
475
+
476
+ /**
477
+ * @brief Output operator to display gt() expressions.
478
+ *
479
+ * @tparam Lhs_T The left-hand side type.
480
+ * @tparam Rhs_T The right-hand side type.
481
+ *
482
+ * @param op The greater-than comparator expression.
483
+ * @return Reference to the current test_reporter instance.
484
+ */
485
+ template <class Lhs_T, class Rhs_T>
486
+ test_reporter&
487
+ operator<< (const detail::gt_<Lhs_T, Rhs_T>& op);
488
+
489
+ /**
490
+ * @brief Output operator to display ge() expressions.
491
+ *
492
+ * @tparam Lhs_T The left-hand side type.
493
+ * @tparam Rhs_T The right-hand side type.
494
+ *
495
+ * @param op The greater-than-or-equal-to comparator expression.
496
+ * @return Reference to the current test_reporter instance.
497
+ */
498
+ template <class Lhs_T, class Rhs_T>
499
+ test_reporter&
500
+ operator<< (const detail::ge_<Lhs_T, Rhs_T>& op);
501
+
502
+ /**
503
+ * @brief Output operator to display lt() expressions.
504
+ *
505
+ * @tparam Lhs_T The left-hand side type.
506
+ * @tparam Rhs_T The right-hand side type.
507
+ *
508
+ * @param op The less-than comparator expression.
509
+ * @return Reference to the current test_reporter instance.
510
+ */
511
+ template <class Lhs_T, class Rhs_T>
512
+ test_reporter&
513
+ operator<< (const detail::lt_<Rhs_T, Lhs_T>& op);
514
+
515
+ /**
516
+ * @brief Output operator to display le() expressions.
517
+ *
518
+ * @tparam Lhs_T The left-hand side type.
519
+ * @tparam Rhs_T The right-hand side type.
520
+ *
521
+ * @param op The less-than-or-equal-to comparator expression.
522
+ * @return Reference to the current test_reporter instance.
523
+ */
524
+ template <class Lhs_T, class Rhs_T>
525
+ test_reporter&
526
+ operator<< (const detail::le_<Rhs_T, Lhs_T>& op);
527
+
528
+ /**
529
+ * @brief Output operator to display and() expressions.
530
+ *
531
+ * @tparam Lhs_T The left-hand side type.
532
+ * @tparam Rhs_T The right-hand side type.
533
+ *
534
+ * @param op The logical conjunction (AND) expression.
535
+ * @return Reference to the current test_reporter instance.
536
+ */
537
+ template <class Lhs_T, class Rhs_T>
538
+ test_reporter&
539
+ operator<< (const detail::and_<Lhs_T, Rhs_T>& op);
540
+
541
+ /**
542
+ * @brief Output operator to display or() expressions.
543
+ *
544
+ * @tparam Lhs_T The left-hand side type.
545
+ * @tparam Rhs_T The right-hand side type.
546
+ *
547
+ * @param op The logical disjunction (OR) expression.
548
+ * @return Reference to the current test_reporter instance.
549
+ */
550
+ template <class Lhs_T, class Rhs_T>
551
+ test_reporter&
552
+ operator<< (const detail::or_<Lhs_T, Rhs_T>& op);
553
+
554
+ /**
555
+ * @brief Output operator to display not() expressions.
556
+ *
557
+ * @tparam T The operand type.
558
+ *
559
+ * @param op The logical negation expression.
560
+ * @return Reference to the current test_reporter instance.
561
+ */
562
+ template <class T>
563
+ test_reporter&
564
+ operator<< (const detail::not_<T>& op);
565
+
566
+ #if defined(__cpp_exceptions)
567
+ /**
568
+ * @brief Output operator to display throws expressions for a specific
569
+ * exception type.
570
+ *
571
+ * @tparam Expr_T The expression type.
572
+ * @tparam Exception_T The exception type.
573
+ *
574
+ * @param op The throws comparator expression.
575
+ * @return Reference to the current test_reporter instance.
576
+ */
577
+ template <class Expr_T, class Exception_T>
578
+ test_reporter&
579
+ operator<< (const detail::throws_<Expr_T, Exception_T>& op);
580
+
581
+ /**
582
+ * @brief Output operator to display throws expressions for any exception.
583
+ *
584
+ * @tparam Expr_T The expression type.
585
+ *
586
+ * @param op The throws comparator expression.
587
+ * @return Reference to the current test_reporter instance.
588
+ */
589
+ template <class Expr_T>
590
+ test_reporter&
591
+ operator<< (const detail::throws_<Expr_T, void>& op);
592
+
593
+ /**
594
+ * @brief Output operator to display nothrow expressions.
595
+ *
596
+ * @tparam Expr_T The expression type.
597
+ *
598
+ * @param op The nothrow comparator expression.
599
+ * @return Reference to the current test_reporter instance.
600
+ */
601
+ template <class Expr_T>
602
+ test_reporter&
603
+ operator<< (const detail::nothrow_<Expr_T>& op);
604
+ #endif
605
+
606
+ /**
607
+ * @brief Inserts a line ending into the output buffer.
608
+ *
609
+ * @par Parameters
610
+ * None.
611
+ * @par Returns
612
+ * Nothing.
613
+ */
614
+ void
615
+ endline (void);
616
+
617
+ // ------------------------------------------------------------------------
618
+
619
+ /**
620
+ * @brief Report a passed condition.
621
+ *
622
+ * @tparam Expr_T The expression type.
623
+ *
624
+ * @param expr The evaluated expression.
625
+ * @param message The message to display.
626
+ * @par Returns
627
+ * Nothing.
628
+ */
629
+ template <class Expr_T>
630
+ void
631
+ pass (Expr_T& expr, std::string& message);
632
+
633
+ /**
634
+ * @brief Report a failed condition.
635
+ *
636
+ * @tparam Expr_T The expression type.
637
+ *
638
+ * @param expr The evaluated expression.
639
+ * @param abort Whether to abort execution after failure.
640
+ * @param message The message to display.
641
+ * @param location The source location of the failure.
642
+ * @par Returns
643
+ * Nothing.
644
+ */
645
+ template <class Expr_T>
646
+ void
647
+ fail (Expr_T& expr, bool abort, std::string& message,
648
+ const reflection::source_location& location);
649
+
650
+ /**
651
+ * @brief Mark the beginning of a test case.
652
+ *
653
+ * @param name The name of the test case.
654
+ * @par Returns
655
+ * Nothing.
656
+ */
657
+ void
658
+ begin_test_case (const char* name);
659
+
660
+ /**
661
+ * @brief Mark the end of a test case.
662
+ *
663
+ * @param name The name of the test case.
664
+ * @par Returns
665
+ * Nothing.
666
+ */
667
+ void
668
+ end_test_case (const char* name);
669
+
670
+ /**
671
+ * @brief Mark the beginning of a test suite.
672
+ *
673
+ * @param name The name of the test suite.
674
+ * @par Returns
675
+ * Nothing.
676
+ */
677
+ void
678
+ begin_test_suite (const char* name);
679
+
680
+ /**
681
+ * @brief Mark the end of a test suite.
682
+ *
683
+ * @param suite Reference to the test suite base.
684
+ * @par Returns
685
+ * Nothing.
686
+ */
687
+ void
688
+ end_test_suite (test_suite_base& suite);
689
+
690
+ /**
691
+ * @brief Flush the current buffered content.
692
+ *
693
+ * @par Parameters
694
+ * None.
695
+ * @par Returns
696
+ * Nothing.
697
+ */
698
+ void
699
+ flush (void);
700
+
701
+ /**
702
+ * @brief Output the current buffered content.
703
+ *
704
+ * @par Parameters
705
+ * None.
706
+ * @par Returns
707
+ * Nothing.
708
+ */
709
+ void
710
+ output (void);
711
+
712
+ /**
713
+ * @brief Controls whether to add an empty line between successful test
714
+ * cases.
715
+ *
716
+ * @details
717
+ * Used to nicely format the output.
718
+ */
719
+ bool add_empty_line{ true };
720
+
721
+ /**
722
+ * @brief The verbosity level for test reporting.
723
+ */
724
+ verbosity_t verbosity{};
725
+
726
+ protected:
727
+ /**
728
+ * @brief Outputs the prefix for a passing condition.
729
+ *
730
+ * @param message The message to display.
731
+ * @par Returns
732
+ * Nothing.
733
+ */
734
+ void
735
+ output_pass_prefix_ (std::string& message);
736
+
737
+ /**
738
+ * @brief Outputs the suffix for a passing condition.
739
+ *
740
+ * @par Parameters
741
+ * None.
742
+ * @par Returns
743
+ * Nothing.
744
+ */
745
+ void
746
+ output_pass_suffix_ (void);
747
+
748
+ /**
749
+ * @brief Outputs the prefix for a failing condition.
750
+ *
751
+ * @param message The message to display.
752
+ * @param location The source location of the failure.
753
+ * @par Returns
754
+ * Nothing.
755
+ */
756
+ void
757
+ output_fail_prefix_ (std::string& message,
758
+ const reflection::source_location& location);
759
+
760
+ /**
761
+ * @brief Outputs the suffix for a failing condition.
762
+ *
763
+ * @param abort Whether to abort execution after failure.
764
+ * @par Returns
765
+ * Nothing.
766
+ */
767
+ void
768
+ output_fail_suffix_ (bool abort);
769
+
770
+ /**
771
+ * @brief ANSI colour codes for output formatting.
772
+ */
773
+ colors colors_{};
774
+
775
+ /**
776
+ * @brief Internal output buffer for accumulating report content.
777
+ */
778
+ std::string out_{};
779
+
780
+ /**
781
+ * @brief Indicates whether the reporter is currently within a test case.
782
+ */
783
+ bool is_in_test_case_ = false;
784
+ };
785
+
786
+ // --------------------------------------------------------------------------
787
+ } // namespace micro_os_plus::micro_test_plus
788
+
789
+ #if defined(__GNUC__)
790
+ #pragma GCC diagnostic pop
791
+ #endif
792
+
793
+ // ----------------------------------------------------------------------------
794
+
795
+ #endif // __cplusplus
796
+
797
+ // ----------------------------------------------------------------------------
798
+
799
+ #endif // MICRO_TEST_PLUS_TEST_REPORTER_H_
800
+
801
+ // ----------------------------------------------------------------------------