@micro-os-plus/micro-test-plus 3.3.1 → 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.
Files changed (65) hide show
  1. package/CHANGELOG.md +412 -2
  2. package/CMakeLists.txt +134 -28
  3. package/README.md +3 -2
  4. package/config/xcdl-build.json +11 -4
  5. package/include/micro-os-plus/micro-test-plus/README.md +6 -0
  6. package/include/micro-os-plus/micro-test-plus/deferred-reporter.h +267 -0
  7. package/include/micro-os-plus/micro-test-plus/detail.h +272 -1425
  8. package/include/micro-os-plus/micro-test-plus/exceptions.h +125 -0
  9. package/include/micro-os-plus/micro-test-plus/expression-formatter.h +669 -0
  10. package/include/micro-os-plus/micro-test-plus/function-comparators.h +15 -7
  11. package/include/micro-os-plus/micro-test-plus/inlines/{details-inlines.h → deferred-reporter-inlines.h} +66 -44
  12. package/include/micro-os-plus/micro-test-plus/inlines/detail-inlines.h +711 -0
  13. package/include/micro-os-plus/micro-test-plus/inlines/exceptions-inline.h +137 -0
  14. package/include/micro-os-plus/micro-test-plus/inlines/{test-reporter-inlines.h → expression-formatter-inlines.h} +232 -198
  15. package/include/micro-os-plus/micro-test-plus/inlines/function-comparators-inlines.h +24 -20
  16. package/include/micro-os-plus/micro-test-plus/inlines/literals-inlines.h +50 -31
  17. package/include/micro-os-plus/micro-test-plus/inlines/math-inlines.h +25 -19
  18. package/include/micro-os-plus/micro-test-plus/inlines/operators-inlines.h +275 -0
  19. package/include/micro-os-plus/micro-test-plus/inlines/reflection-inlines.h +39 -21
  20. package/include/micro-os-plus/micro-test-plus/inlines/reporter-inlines.h +205 -0
  21. package/include/micro-os-plus/micro-test-plus/inlines/runner-inlines.h +151 -0
  22. package/include/micro-os-plus/micro-test-plus/inlines/runner-totals-inlines.h +152 -0
  23. package/include/micro-os-plus/micro-test-plus/inlines/test-inlines.h +555 -0
  24. package/include/micro-os-plus/micro-test-plus/inlines/timings-inlines.h +120 -0
  25. package/include/micro-os-plus/micro-test-plus/inlines/type-traits-inlines.h +231 -0
  26. package/include/micro-os-plus/micro-test-plus/inlines/utility-inlines.h +126 -0
  27. package/include/micro-os-plus/micro-test-plus/literals.h +12 -17
  28. package/include/micro-os-plus/micro-test-plus/math.h +14 -6
  29. package/include/micro-os-plus/micro-test-plus/operators.h +53 -209
  30. package/include/micro-os-plus/micro-test-plus/reflection.h +8 -4
  31. package/include/micro-os-plus/micro-test-plus/{test-reporter-basic.h → reporter-human.h} +80 -74
  32. package/include/micro-os-plus/micro-test-plus/{test-reporter-tap.h → reporter-tap.h} +77 -71
  33. package/include/micro-os-plus/micro-test-plus/reporter.h +619 -0
  34. package/include/micro-os-plus/micro-test-plus/runner-totals.h +250 -0
  35. package/include/micro-os-plus/micro-test-plus/runner.h +472 -0
  36. package/include/micro-os-plus/micro-test-plus/test.h +1013 -0
  37. package/include/micro-os-plus/micro-test-plus/timings.h +363 -0
  38. package/include/micro-os-plus/micro-test-plus/type-traits.h +223 -577
  39. package/include/micro-os-plus/micro-test-plus/utility.h +136 -0
  40. package/include/micro-os-plus/micro-test-plus.h +42 -236
  41. package/meson.build +11 -6
  42. package/package.json +11 -3
  43. package/src/deferred-reporter.cpp +137 -0
  44. package/src/expression-formatter.cpp +289 -0
  45. package/src/reflection.cpp +97 -0
  46. package/src/reporter-human.cpp +816 -0
  47. package/src/reporter-tap.cpp +772 -0
  48. package/src/reporter.cpp +481 -0
  49. package/src/runner-totals.cpp +98 -0
  50. package/src/runner.cpp +669 -0
  51. package/src/test.cpp +503 -0
  52. package/src/timings.cpp +210 -0
  53. package/src/utility.cpp +163 -0
  54. package/.cmake-format.yaml +0 -11
  55. package/include/micro-os-plus/micro-test-plus/inlines/micro-test-plus-inlines.h +0 -313
  56. package/include/micro-os-plus/micro-test-plus/inlines/test-suite-inlines.h +0 -115
  57. package/include/micro-os-plus/micro-test-plus/test-reporter.h +0 -846
  58. package/include/micro-os-plus/micro-test-plus/test-runner.h +0 -281
  59. package/include/micro-os-plus/micro-test-plus/test-suite.h +0 -492
  60. package/src/micro-test-plus.cpp +0 -316
  61. package/src/test-reporter-basic.cpp +0 -466
  62. package/src/test-reporter-tap.cpp +0 -530
  63. package/src/test-reporter.cpp +0 -399
  64. package/src/test-runner.cpp +0 -311
  65. package/src/test-suite.cpp +0 -304
@@ -17,37 +17,32 @@
17
17
 
18
18
  /**
19
19
  * @file
20
- * @brief C++ header file with inline implementations for the µTest++ test
21
- * reporter.
20
+ * @brief C++ header file with inline implementations for the µTest++
21
+ * expression formatter.
22
22
  *
23
23
  * @details
24
- * This header provides the inline implementations for the test reporting
25
- * facilities used within the µTest++ framework. It defines the logic for
26
- * formatting and outputting test results, including operator overloads for
27
- * various value types, containers, and comparison expressions, as well as
28
- * structured output for logical and exception-related assertions.
24
+ * This header provides the inline and template method implementations for
25
+ * `expression_formatter`. The buffer accessors (`str()`, `c_str()`,
26
+ * `clear()`, `empty()`, `append()`, `reserve()`) are defined as inline
27
+ * functions for zero-overhead access. The template operators
28
+ * `operator<<(T*)`, `operator<<(is_op<T>)`,
29
+ * `operator<<(genuine_integral_value<T>)`, and `operator<<(container)` —
30
+ * are instantiated per concrete type at each call site.
29
31
  *
30
- * The implementations ensure that test outcomes are presented in a clear,
31
- * consistent, and expressive manner, supporting both value and pointer
32
- * semantics, and providing detailed diagnostics for both successful and failed
33
- * test cases. Special attention is given to formatting, colour highlighting,
34
- * and extensibility, enabling professional and readable test reports suitable
35
- * for embedded and general C++ development.
32
+ * The `append_number_()` helper is also a template, selecting between a
33
+ * `std::to_chars` path for standard numeric types and an `snprintf` fallback
34
+ * for `long double` on platforms where `std::to_chars` lacks support for
35
+ * 80-bit extended precision.
36
36
  *
37
- * All definitions reside within the `micro_os_plus::micro_test_plus::detail`
38
- * namespace, ensuring clear separation from user code and minimising the risk
39
- * of naming conflicts.
40
- *
41
- * The header files are organised within the
42
- * `include/micro-os-plus/micro-test-plus` folder to maintain a structured and
43
- * modular codebase.
37
+ * All definitions reside within the `micro_os_plus::micro_test_plus`
38
+ * namespace.
44
39
  *
45
40
  * This file is intended solely for internal use within the framework and
46
41
  * should not be included directly by user code.
47
42
  */
48
43
 
49
- #ifndef MICRO_TEST_PLUS_TEST_REPORTER_INLINES_H_
50
- #define MICRO_TEST_PLUS_TEST_REPORTER_INLINES_H_
44
+ #ifndef MICRO_TEST_PLUS_EXPRESSION_FORMATTER_INLINES_H_
45
+ #define MICRO_TEST_PLUS_EXPRESSION_FORMATTER_INLINES_H_
51
46
 
52
47
  // ----------------------------------------------------------------------------
53
48
 
@@ -55,8 +50,9 @@
55
50
 
56
51
  // ----------------------------------------------------------------------------
57
52
 
58
- #include <stdio.h>
59
- #include <cstring>
53
+ #include <cstdio>
54
+
55
+ #include "micro-os-plus/micro-test-plus/reflection.h"
60
56
 
61
57
  // ----------------------------------------------------------------------------
62
58
 
@@ -69,94 +65,184 @@
69
65
  #endif
70
66
  #endif
71
67
 
72
- namespace micro_os_plus::micro_test_plus
68
+ // ============================================================================
69
+
70
+ namespace micro_os_plus::micro_test_plus::detail
73
71
  {
74
72
  // --------------------------------------------------------------------------
75
73
 
76
74
  /**
77
75
  * @details
78
- * This operator overload enables the `test_reporter` to output pointer
79
- * values in a consistent and readable hexadecimal format.
80
- *
81
- * The pointer is formatted as a string using `snprintf` with the `%p` format
82
- * specifier, ensuring portability across platforms. The resulting string is
83
- * appended to the internal output buffer, allowing pointer values to be
84
- * included in test reports and diagnostics.
85
- *
86
- * This approach provides clear and unambiguous representation of pointer
87
- * addresses, which is particularly useful for debugging and verifying
88
- * pointer-related test cases.
76
+ * Initializes the `colours_` reference with the provided `colours` instance.
77
+ * The internal buffer is default-initialized to an empty string.
78
+ */
79
+ inline expression_formatter::expression_formatter (colours& colours) noexcept
80
+ : colours_ (colours)
81
+ {
82
+ }
83
+
84
+ // --------------------------------------------------------------------------
85
+
86
+ /**
87
+ * @details
88
+ * Returns the ANSI colour code for pass or fail, depending on the boolean
89
+ * condition provided.
90
+ */
91
+ inline auto
92
+ expression_formatter::colour_ (const bool cond) const
93
+ {
94
+ return cond ? colours_.pass : colours_.fail;
95
+ }
96
+
97
+ // --------------------------------------------------------------------------
98
+
99
+ /**
100
+ * @details
101
+ * Returns a const reference to the internal `buffer_` string.
102
+ */
103
+ inline const std::string&
104
+ expression_formatter::str () const noexcept
105
+ {
106
+ return buffer_;
107
+ }
108
+
109
+ /**
110
+ * @details
111
+ * Returns `buffer_.c_str()`, providing a pointer to the
112
+ * null-terminated contents of the internal buffer.
113
+ */
114
+ inline const char*
115
+ expression_formatter::c_str () const noexcept
116
+ {
117
+ return buffer_.c_str ();
118
+ }
119
+
120
+ /**
121
+ * @details
122
+ * Calls `buffer_.clear()`, resetting the buffer length to zero
123
+ * without releasing the allocated storage.
124
+ */
125
+ inline void
126
+ expression_formatter::clear () noexcept
127
+ {
128
+ buffer_.clear ();
129
+ }
130
+
131
+ /**
132
+ * @details
133
+ * Returns `buffer_.empty()`, indicating whether the accumulated
134
+ * string has zero length.
135
+ */
136
+ inline bool
137
+ expression_formatter::empty () const noexcept
138
+ {
139
+ return buffer_.empty ();
140
+ }
141
+
142
+ /**
143
+ * @details
144
+ * Appends @p count repetitions of @p ch to the internal buffer by
145
+ * delegating to `buffer_.append(count, ch)`.
146
+ */
147
+ inline void
148
+ expression_formatter::append (size_t count, char ch)
149
+ {
150
+ buffer_.append (count, ch);
151
+ }
152
+
153
+ /**
154
+ * @details
155
+ * Calls `buffer_.reserve(capacity)` to pre-allocate storage,
156
+ * reducing subsequent dynamic allocations.
157
+ */
158
+ inline void
159
+ expression_formatter::reserve (size_t capacity)
160
+ {
161
+ buffer_.reserve (capacity);
162
+ }
163
+
164
+ // --------------------------------------------------------------------------
165
+
166
+ #if defined(__GNUC__)
167
+ #pragma GCC diagnostic push
168
+ #if defined(__clang__)
169
+ #pragma clang diagnostic ignored "-Wunsafe-buffer-usage"
170
+ #pragma clang diagnostic ignored "-Wunsafe-buffer-usage-in-libc-call"
171
+ #endif
172
+ #endif
173
+
174
+ // --------------------------------------------------------------------------
175
+
176
+ /**
177
+ * @details
178
+ * Null pointers are rendered as `"0x0"` to avoid platform-specific
179
+ * representations such as `"(nil)"` on Linux/glibc. Non-null pointers
180
+ * are formatted as a hexadecimal address using `snprintf` with the
181
+ * `%p` specifier.
89
182
  */
90
183
  template <typename T>
91
- test_reporter&
92
- test_reporter::operator<< (T* v)
184
+ expression_formatter&
185
+ expression_formatter::operator<< (T* v)
93
186
  {
187
+ if (v == nullptr)
188
+ {
189
+ buffer_.append ("0x0");
190
+ return *this;
191
+ }
192
+ #if defined(__GNUC__)
193
+ #pragma GCC diagnostic push
194
+ #if defined(__clang__)
195
+ #pragma clang diagnostic ignored "-Wunsafe-buffer-usage-in-libc-call"
196
+ #endif
197
+ #endif
94
198
  char buff[20];
95
199
  snprintf (buff, sizeof (buff), "%p", reinterpret_cast<void*> (v));
96
- out_.append (buff);
97
-
200
+ buffer_.append (buff);
201
+ #if defined(__GNUC__)
202
+ #pragma GCC diagnostic pop
203
+ #endif
98
204
  return *this;
99
205
  }
100
206
 
101
- #if 0
102
- /**
103
- * @details
104
- * This operator overload enables the `test_reporter` to output any type that is supported by the `detail::get` mechanism, ensuring consistent formatting and extensibility.
105
- *
106
- * By delegating to `detail::get`, the operator allows for custom formatting and extraction of values, supporting a wide range of types including user-defined and framework-specific types. The resulting value is then forwarded to the appropriate output handler, ensuring seamless integration into test reports and diagnostics.
107
- *
108
- * This approach promotes flexibility and maintainability, allowing new types to be supported with minimal changes to the reporting infrastructure.
109
- */
110
- template <class T>
111
- test_reporter&
112
- test_reporter::operator<< (const T& t)
207
+ /**
208
+ * @details
209
+ * Delegates to `detail::get(t)` to obtain the displayable value
210
+ * of an op expression, then streams it through `operator<<` to
211
+ * format it into the buffer.
212
+ */
213
+ template <class T>
214
+ requires type_traits::is_op<T>
215
+ expression_formatter&
216
+ expression_formatter::operator<< (const T& t)
113
217
  {
114
218
  *this << detail::get (t);
115
219
  return *this;
116
220
  }
117
- #endif
118
221
 
119
222
  /**
120
223
  * @details
121
- * This operator overload enables the `test_reporter` to output
122
- * strongly-typed integral values in a clear and consistent decimal format.
123
- *
124
- * The value is converted to a string using `std::to_string` after being cast
125
- * to `long long`, ensuring accurate formatting and compatibility across
126
- * platforms. The resulting string is appended to the internal output buffer,
127
- * allowing integral values to be included in test reports and diagnostics.
128
- *
129
- * This approach ensures precise and unambiguous representation of integral
130
- * values, which is particularly advantageous for verifying test results and
131
- * facilitating debugging.
224
+ * Casts the underlying integral value to `long long` and formats
225
+ * it without a type suffix, appending the result to the buffer.
132
226
  */
133
227
  template <class T>
134
- test_reporter&
135
- test_reporter::operator<< (const type_traits::genuine_integral_value<T>& v)
228
+ expression_formatter&
229
+ expression_formatter::operator<< (
230
+ const type_traits::genuine_integral_value<T>& v)
136
231
  {
137
- out_.append (std::to_string (static_cast<long long> (v.get ())));
232
+ detail::append_number_ (buffer_, static_cast<long long> (v.get ()));
138
233
  return *this;
139
234
  }
140
235
 
141
236
  /**
142
237
  * @details
143
- * This operator overload enables the `test_reporter` to output container
144
- * types in a structured and readable format.
145
- *
146
- * The contents of the container are enclosed in curly braces and each
147
- * element is separated by a comma and a space. The operator iterates over
148
- * the container, formatting each element in sequence, which ensures clarity
149
- * and consistency in test reports and diagnostics.
150
- *
151
- * This approach provides a clear visual representation of container
152
- * contents, making it easier to interpret test results and debug issues
153
- * involving collections of values.
238
+ * Iterates the container and formats each element separated by
239
+ * `", "`, surrounded by `{` and `}`. Each element is streamed
240
+ * through `operator<<`, which recurses as needed for nested types.
154
241
  */
155
- template <class T,
156
- type_traits::requires_t<type_traits::is_container_v<T>
157
- and not type_traits::has_npos_v<T>>>
158
- test_reporter&
159
- test_reporter::operator<< (T&& t)
242
+ template <class T>
243
+ requires (type_traits::container_like<T> and not type_traits::has_npos<T>)
244
+ expression_formatter&
245
+ expression_formatter::operator<< (const T& t)
160
246
  {
161
247
  *this << '{';
162
248
  auto first = true;
@@ -169,9 +255,12 @@ namespace micro_os_plus::micro_test_plus
169
255
  return *this;
170
256
  }
171
257
 
258
+ // --------------------------------------------------------------------------
259
+ // Compound expression operators (without colour codes).
260
+
172
261
  /**
173
262
  * @details
174
- * This operator overload enables the `test_reporter` to output equality
263
+ * This operator overload enables the `reporter` to output equality
175
264
  * comparison expressions in a clear and expressive format.
176
265
  *
177
266
  * The left-hand side and right-hand side values are formatted and separated
@@ -181,16 +270,16 @@ namespace micro_os_plus::micro_test_plus
181
270
  * equality assertions and facilitates efficient debugging of test failures.
182
271
  */
183
272
  template <class Lhs_T, class Rhs_T>
184
- test_reporter&
185
- test_reporter::operator<< (const detail::eq_<Lhs_T, Rhs_T>& op)
273
+ expression_formatter&
274
+ expression_formatter::operator<< (const detail::eq_<Lhs_T, Rhs_T>& op)
186
275
  {
187
- return (*this << color (op) << op.lhs () << " == " << op.rhs ()
188
- << colors_.none);
276
+ return (*this << colour_ (op) << op.lhs () << " == " << op.rhs ()
277
+ << colours_.none);
189
278
  }
190
279
 
191
280
  /**
192
281
  * @details
193
- * This operator overload enables the `test_reporter` to output inequality
282
+ * This operator overload enables the `reporter` to output inequality
194
283
  * comparison expressions in a clear and expressive format.
195
284
  *
196
285
  * The left-hand side and right-hand side values are formatted and separated
@@ -201,16 +290,16 @@ namespace micro_os_plus::micro_test_plus
201
290
  * failures.
202
291
  */
203
292
  template <class Lhs_T, class Rhs_T>
204
- test_reporter&
205
- test_reporter::operator<< (const detail::ne_<Lhs_T, Rhs_T>& op)
293
+ expression_formatter&
294
+ expression_formatter::operator<< (const detail::ne_<Lhs_T, Rhs_T>& op)
206
295
  {
207
- return (*this << color (op) << op.lhs () << " != " << op.rhs ()
208
- << colors_.none);
296
+ return (*this << colour_ (op) << op.lhs () << " != " << op.rhs ()
297
+ << colours_.none);
209
298
  }
210
299
 
211
300
  /**
212
301
  * @details
213
- * This operator overload enables the `test_reporter` to output greater-than
302
+ * This operator overload enables the `reporter` to output greater-than
214
303
  * comparison expressions in a clear and expressive format.
215
304
  *
216
305
  * The left-hand side and right-hand side values are formatted and separated
@@ -221,16 +310,16 @@ namespace micro_os_plus::micro_test_plus
221
310
  * failures.
222
311
  */
223
312
  template <class Lhs_T, class Rhs_T>
224
- test_reporter&
225
- test_reporter::operator<< (const detail::gt_<Lhs_T, Rhs_T>& op)
313
+ expression_formatter&
314
+ expression_formatter::operator<< (const detail::gt_<Lhs_T, Rhs_T>& op)
226
315
  {
227
- return (*this << color (op) << op.lhs () << " > " << op.rhs ()
228
- << colors_.none);
316
+ return (*this << colour_ (op) << op.lhs () << " > " << op.rhs ()
317
+ << colours_.none);
229
318
  }
230
319
 
231
320
  /**
232
321
  * @details
233
- * This operator overload enables the `test_reporter` to output
322
+ * This operator overload enables the `reporter` to output
234
323
  * greater-than-or-equal-to comparison expressions in a clear and expressive
235
324
  * format.
236
325
  *
@@ -242,16 +331,16 @@ namespace micro_os_plus::micro_test_plus
242
331
  * efficient debugging of test failures.
243
332
  */
244
333
  template <class Lhs_T, class Rhs_T>
245
- test_reporter&
246
- test_reporter::operator<< (const detail::ge_<Lhs_T, Rhs_T>& op)
334
+ expression_formatter&
335
+ expression_formatter::operator<< (const detail::ge_<Lhs_T, Rhs_T>& op)
247
336
  {
248
- return (*this << color (op) << op.lhs () << " >= " << op.rhs ()
249
- << colors_.none);
337
+ return (*this << colour_ (op) << op.lhs () << " >= " << op.rhs ()
338
+ << colours_.none);
250
339
  }
251
340
 
252
341
  /**
253
342
  * @details
254
- * This operator overload enables the `test_reporter` to output less-than
343
+ * This operator overload enables the `reporter` to output less-than
255
344
  * comparison expressions in a clear and expressive format.
256
345
  *
257
346
  * The left-hand side and right-hand side values are formatted and separated
@@ -261,16 +350,16 @@ namespace micro_os_plus::micro_test_plus
261
350
  * less-than assertions and facilitates efficient debugging of test failures.
262
351
  */
263
352
  template <class Lhs_T, class Rhs_T>
264
- test_reporter&
265
- test_reporter::operator<< (const detail::lt_<Rhs_T, Lhs_T>& op)
353
+ expression_formatter&
354
+ expression_formatter::operator<< (const detail::lt_<Rhs_T, Lhs_T>& op)
266
355
  {
267
- return (*this << color (op) << op.lhs () << " < " << op.rhs ()
268
- << colors_.none);
356
+ return (*this << colour_ (op) << op.lhs () << " < " << op.rhs ()
357
+ << colours_.none);
269
358
  }
270
359
 
271
360
  /**
272
361
  * @details
273
- * This operator overload enables the `test_reporter` to output
362
+ * This operator overload enables the `reporter` to output
274
363
  * less-than-or-equal-to comparison expressions in a clear and expressive
275
364
  * format.
276
365
  *
@@ -282,16 +371,16 @@ namespace micro_os_plus::micro_test_plus
282
371
  * efficient debugging of test failures.
283
372
  */
284
373
  template <class Lhs_T, class Rhs_T>
285
- test_reporter&
286
- test_reporter::operator<< (const detail::le_<Rhs_T, Lhs_T>& op)
374
+ expression_formatter&
375
+ expression_formatter::operator<< (const detail::le_<Rhs_T, Lhs_T>& op)
287
376
  {
288
- return (*this << color (op) << op.lhs () << " <= " << op.rhs ()
289
- << colors_.none);
377
+ return (*this << colour_ (op) << op.lhs () << " <= " << op.rhs ()
378
+ << colours_.none);
290
379
  }
291
380
 
292
381
  /**
293
382
  * @details
294
- * This operator overload enables the `test_reporter` to output logical
383
+ * This operator overload enables the `reporter` to output logical
295
384
  * conjunction (AND) expressions in a clear and structured format.
296
385
  *
297
386
  * The left-hand side and right-hand side expressions are enclosed in
@@ -302,16 +391,16 @@ namespace micro_os_plus::micro_test_plus
302
391
  * test failures involving compound conditions.
303
392
  */
304
393
  template <class Lhs_T, class Rhs_T>
305
- test_reporter&
306
- test_reporter::operator<< (const detail::and_<Lhs_T, Rhs_T>& op)
394
+ expression_formatter&
395
+ expression_formatter::operator<< (const detail::and_<Lhs_T, Rhs_T>& op)
307
396
  {
308
- return (*this << '(' << op.lhs () << color (op) << " and " << colors_.none
309
- << op.rhs () << ')');
397
+ return (*this << '(' << op.lhs () << colour_ (op) << " and "
398
+ << colours_.none << op.rhs () << ')');
310
399
  }
311
400
 
312
401
  /**
313
402
  * @details
314
- * This operator overload enables the `test_reporter` to output logical
403
+ * This operator overload enables the `reporter` to output logical
315
404
  * disjunction (OR) expressions in a clear and structured format.
316
405
  *
317
406
  * The left-hand side and right-hand side expressions are enclosed in
@@ -322,11 +411,11 @@ namespace micro_os_plus::micro_test_plus
322
411
  * test failures involving compound conditions.
323
412
  */
324
413
  template <class Lhs_T, class Rhs_T>
325
- test_reporter&
326
- test_reporter::operator<< (const detail::or_<Lhs_T, Rhs_T>& op)
414
+ expression_formatter&
415
+ expression_formatter::operator<< (const detail::or_<Lhs_T, Rhs_T>& op)
327
416
  {
328
- return (*this << '(' << op.lhs () << color (op) << " or " << colors_.none
329
- << op.rhs () << ')');
417
+ return (*this << '(' << op.lhs () << colour_ (op) << " or "
418
+ << colours_.none << op.rhs () << ')');
330
419
  }
331
420
 
332
421
  /**
@@ -338,10 +427,10 @@ namespace micro_os_plus::micro_test_plus
338
427
  * diagnostics.
339
428
  */
340
429
  template <class T>
341
- test_reporter&
342
- test_reporter::operator<< (const detail::not_<T>& op)
430
+ expression_formatter&
431
+ expression_formatter::operator<< (const detail::not_<T>& op)
343
432
  {
344
- return (*this << color (op) << "not " << op.value () << colors_.none);
433
+ return (*this << colour_ (op) << "not " << op.operand () << colours_.none);
345
434
  }
346
435
 
347
436
  #if defined(__cpp_exceptions)
@@ -357,13 +446,14 @@ namespace micro_os_plus::micro_test_plus
357
446
  * reports, and assists in the precise identification and debugging of
358
447
  * exception-related test cases.
359
448
  */
360
- template <class Expr_T, class Exception_T>
361
- test_reporter&
362
- test_reporter::operator<< (const detail::throws_<Expr_T, Exception_T>& op)
449
+ template <class Callable_T, class Exception_T>
450
+ expression_formatter&
451
+ expression_formatter::operator<< (
452
+ const detail::throws_<Callable_T, Exception_T>& op)
363
453
  {
364
- return (*this << color (op) << "throws<"
454
+ return (*this << colour_ (op) << "throws<"
365
455
  << reflection::type_name<Exception_T> () << ">"
366
- << colors_.none);
456
+ << colours_.none);
367
457
  }
368
458
 
369
459
  /**
@@ -376,11 +466,12 @@ namespace micro_os_plus::micro_test_plus
376
466
  * immediately apparent when an expression is expected to throw, thereby
377
467
  * improving the readability and professionalism of the test output.
378
468
  */
379
- template <class Expr_T>
380
- test_reporter&
381
- test_reporter::operator<< (const detail::throws_<Expr_T, void>& op)
469
+ template <class Callable_T>
470
+ expression_formatter&
471
+ expression_formatter::operator<< (
472
+ const detail::throws_<Callable_T, void>& op)
382
473
  {
383
- return (*this << color (op) << "throws" << colors_.none);
474
+ return (*this << colour_ (op) << "throws" << colours_.none);
384
475
  }
385
476
 
386
477
  /**
@@ -393,73 +484,16 @@ namespace micro_os_plus::micro_test_plus
393
484
  * apparent when an expression is guaranteed not to throw, thereby improving
394
485
  * the readability and professionalism of the test output.
395
486
  */
396
- template <class Expr_T>
397
- test_reporter&
398
- test_reporter::operator<< (const detail::nothrow_<Expr_T>& op)
487
+ template <class Callable_T>
488
+ expression_formatter&
489
+ expression_formatter::operator<< (const detail::nothrow_<Callable_T>& op)
399
490
  {
400
- return (*this << color (op) << "nothrow" << colors_.none);
491
+ return (*this << colour_ (op) << "nothrow" << colours_.none);
401
492
  }
402
493
  #endif
403
494
 
404
- /**
405
- * @details
406
- * This operator overload formats output for expressions that do not throw
407
- * exceptions. It applies colour styling for clarity and ensures a structured
408
- * representation of exception safety.
409
- *
410
- * When invoked, the function outputs a pass prefix, followed by either the
411
- * provided message or, if the message is empty, the evaluated expression
412
- * itself. It then appends a pass suffix to complete the output. This
413
- * approach guarantees that successful test outcomes are presented in a clear
414
- * and consistent manner, enhancing the readability and professionalism of
415
- * test reports.
416
- */
417
- template <class Expr_T>
418
- void
419
- test_reporter::pass (Expr_T& expr, std::string& message)
420
- {
421
- current_test_suite->current_test_case.index++;
422
-
423
- output_pass_prefix_ (message);
424
-
425
- if (message.empty ())
426
- {
427
- // If there is no message, display the evaluated expression.
428
- *this << expr;
429
- }
430
-
431
- output_pass_suffix_ ();
432
- }
433
-
434
- /**
435
- * @details
436
- * This function reports a test failure and formats the output in a clear and
437
- * consistent manner. It provides contextual information, including the
438
- * precise source location, and appends the evaluated expression when
439
- * applicable. The failure handling process ensures uniformity in the
440
- * presentation of unsuccessful test cases, aiding in the rapid
441
- * identification and diagnosis of issues within test reports.
442
- */
443
- template <class Expr_T>
444
- void
445
- test_reporter::fail (Expr_T& expr, bool abort, std::string& message,
446
- const reflection::source_location& location)
447
- {
448
- current_test_suite->current_test_case.index++;
449
-
450
- const bool hasExpression = type_traits::is_op_v<Expr_T>;
451
- output_fail_prefix_ (message, hasExpression, location);
452
-
453
- if constexpr (type_traits::is_op_v<Expr_T>)
454
- {
455
- *this << expr;
456
- }
457
-
458
- output_fail_suffix_ (location, abort);
459
- }
460
-
461
495
  // --------------------------------------------------------------------------
462
- } // namespace micro_os_plus::micro_test_plus
496
+ } // namespace micro_os_plus::micro_test_plus::detail
463
497
 
464
498
  #if defined(__GNUC__)
465
499
  #pragma GCC diagnostic pop
@@ -471,6 +505,6 @@ namespace micro_os_plus::micro_test_plus
471
505
 
472
506
  // ----------------------------------------------------------------------------
473
507
 
474
- #endif // MICRO_TEST_PLUS_TEST_REPORTER_INLINES_H_
508
+ #endif // MICRO_TEST_PLUS_EXPRESSION_FORMATTER_INLINES_H_
475
509
 
476
510
  // ----------------------------------------------------------------------------