@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.
Files changed (51) hide show
  1. package/CHANGELOG.md +95 -0
  2. package/CMakeLists.txt +74 -24
  3. package/README.md +3 -2
  4. package/include/micro-os-plus/micro-test-plus/README.md +6 -0
  5. package/include/micro-os-plus/micro-test-plus/deferred-reporter.h +29 -54
  6. package/include/micro-os-plus/micro-test-plus/detail.h +166 -705
  7. package/include/micro-os-plus/micro-test-plus/exceptions.h +5 -6
  8. package/include/micro-os-plus/micro-test-plus/expression-formatter.h +669 -0
  9. package/include/micro-os-plus/micro-test-plus/function-comparators.h +5 -0
  10. package/include/micro-os-plus/micro-test-plus/inlines/deferred-reporter-inlines.h +25 -30
  11. package/include/micro-os-plus/micro-test-plus/inlines/detail-inlines.h +711 -0
  12. package/include/micro-os-plus/micro-test-plus/inlines/exceptions-inline.h +137 -0
  13. package/include/micro-os-plus/micro-test-plus/inlines/expression-formatter-inlines.h +510 -0
  14. package/include/micro-os-plus/micro-test-plus/inlines/function-comparators-inlines.h +17 -76
  15. package/include/micro-os-plus/micro-test-plus/inlines/literals-inlines.h +47 -25
  16. package/include/micro-os-plus/micro-test-plus/inlines/math-inlines.h +7 -7
  17. package/include/micro-os-plus/micro-test-plus/inlines/operators-inlines.h +275 -0
  18. package/include/micro-os-plus/micro-test-plus/inlines/reflection-inlines.h +4 -4
  19. package/include/micro-os-plus/micro-test-plus/inlines/reporter-inlines.h +53 -394
  20. package/include/micro-os-plus/micro-test-plus/inlines/runner-inlines.h +38 -0
  21. package/include/micro-os-plus/micro-test-plus/inlines/runner-totals-inlines.h +152 -0
  22. package/include/micro-os-plus/micro-test-plus/inlines/test-inlines.h +231 -45
  23. package/include/micro-os-plus/micro-test-plus/inlines/timings-inlines.h +120 -0
  24. package/include/micro-os-plus/micro-test-plus/inlines/type-traits-inlines.h +202 -0
  25. package/include/micro-os-plus/micro-test-plus/literals.h +8 -14
  26. package/include/micro-os-plus/micro-test-plus/math.h +5 -0
  27. package/include/micro-os-plus/micro-test-plus/operators.h +19 -169
  28. package/include/micro-os-plus/micro-test-plus/reflection.h +5 -12
  29. package/include/micro-os-plus/micro-test-plus/reporter-human.h +17 -11
  30. package/include/micro-os-plus/micro-test-plus/reporter-tap.h +14 -8
  31. package/include/micro-os-plus/micro-test-plus/reporter.h +101 -424
  32. package/include/micro-os-plus/micro-test-plus/runner-totals.h +162 -176
  33. package/include/micro-os-plus/micro-test-plus/runner.h +61 -42
  34. package/include/micro-os-plus/micro-test-plus/test.h +450 -506
  35. package/include/micro-os-plus/micro-test-plus/timings.h +259 -262
  36. package/include/micro-os-plus/micro-test-plus/type-traits.h +30 -52
  37. package/include/micro-os-plus/micro-test-plus/utility.h +5 -4
  38. package/include/micro-os-plus/micro-test-plus.h +33 -24
  39. package/meson.build +1 -0
  40. package/package.json +11 -3
  41. package/src/deferred-reporter.cpp +21 -2
  42. package/src/expression-formatter.cpp +289 -0
  43. package/src/reflection.cpp +3 -1
  44. package/src/reporter-human.cpp +31 -37
  45. package/src/reporter-tap.cpp +25 -35
  46. package/src/reporter.cpp +36 -231
  47. package/src/runner-totals.cpp +6 -3
  48. package/src/runner.cpp +131 -25
  49. package/src/test.cpp +120 -113
  50. package/src/timings.cpp +6 -5
  51. package/src/utility.cpp +1 -1
@@ -0,0 +1,137 @@
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
+ * exceptions comparators.
22
+ *
23
+ * @details
24
+ * This header provides the inline implementations for the exception comparator
25
+ * templates used within the µTest++ framework.
26
+ *
27
+ * ...
28
+ *
29
+ * All definitions reside within the `micro_os_plus::micro_test_plus`
30
+ * namespace, ensuring clear separation from user code and minimising the risk
31
+ * of naming conflicts.
32
+ *
33
+ * The header files are organised within the
34
+ * `include/micro-os-plus/micro-test-plus` folder to maintain a structured and
35
+ * modular codebase.
36
+ *
37
+ * This file is intended solely for internal use within the framework and
38
+ * should not be included directly by user code.
39
+ */
40
+
41
+ #ifndef MICRO_TEST_PLUS_EXCEPTIONS_INLINES_H_
42
+ #define MICRO_TEST_PLUS_EXCEPTIONS_INLINES_H_
43
+
44
+ // ----------------------------------------------------------------------------
45
+
46
+ #ifdef __cplusplus
47
+
48
+ // ----------------------------------------------------------------------------
49
+
50
+ #if defined(__GNUC__)
51
+ #pragma GCC diagnostic push
52
+ #pragma GCC diagnostic ignored "-Waggregate-return"
53
+ #if defined(__clang__)
54
+ #pragma clang diagnostic ignored "-Wc++98-compat"
55
+ #pragma clang diagnostic ignored "-Wc++98-compat-pedantic"
56
+ #endif
57
+ #endif
58
+
59
+ // ============================================================================
60
+
61
+ namespace micro_os_plus::micro_test_plus
62
+ {
63
+ // --------------------------------------------------------------------------
64
+ // Exceptions related comparators.
65
+
66
+ #if defined(__cpp_exceptions)
67
+
68
+ /**
69
+ * @details
70
+ * The `throws` function template verifies whether invoking the provided
71
+ * callable object results in the throwing of a specific exception type
72
+ * within the µTest++ framework. This is useful for testing error handling
73
+ * and exception safety in code under test.
74
+ *
75
+ * The function returns an output stream, allowing optional messages to be
76
+ * appended to the test report for diagnostic purposes.
77
+ */
78
+ template <class Exception_T, class Callable_T>
79
+ constexpr auto
80
+ throws (const Callable_T& func)
81
+ {
82
+ return detail::throws_<Callable_T, Exception_T>{ func };
83
+ }
84
+
85
+ /**
86
+ * @details
87
+ * The `throws` function template verifies whether invoking the provided
88
+ * callable object results in the throwing of any exception within the
89
+ * µTest++ framework. This is useful for testing general exception safety and
90
+ * ensuring that code under test properly signals error conditions.
91
+ *
92
+ * The function returns an output stream, allowing optional messages to be
93
+ * appended to the test report for diagnostic purposes.
94
+ */
95
+ template <class Callable_T>
96
+ constexpr auto
97
+ throws (const Callable_T& func)
98
+ {
99
+ return detail::throws_<Callable_T>{ func };
100
+ }
101
+
102
+ /**
103
+ * @details
104
+ * The `nothrow` function template verifies whether invoking the provided
105
+ * callable object does not result in the throwing of any exception within
106
+ * the µTest++ framework. This is useful for testing exception safety and
107
+ * ensuring that code under test does not unexpectedly signal error
108
+ * conditions.
109
+ *
110
+ * The function returns an output stream, allowing optional messages to be
111
+ * appended to the test report for diagnostic purposes.
112
+ */
113
+ template <class Callable_T>
114
+ constexpr auto
115
+ nothrow (const Callable_T& func)
116
+ {
117
+ return detail::nothrow_<Callable_T>{ func };
118
+ }
119
+
120
+ #endif // defined(__cpp_exceptions)
121
+
122
+ // --------------------------------------------------------------------------
123
+ } // namespace micro_os_plus::micro_test_plus
124
+
125
+ #if defined(__GNUC__)
126
+ #pragma GCC diagnostic pop
127
+ #endif
128
+
129
+ // ----------------------------------------------------------------------------
130
+
131
+ #endif // __cplusplus
132
+
133
+ // ----------------------------------------------------------------------------
134
+
135
+ #endif // MICRO_TEST_PLUS_EXCEPTIONS_INLINE_H_
136
+
137
+ // ----------------------------------------------------------------------------
@@ -0,0 +1,510 @@
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
+ * expression formatter.
22
+ *
23
+ * @details
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.
31
+ *
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
+ *
37
+ * All definitions reside within the `micro_os_plus::micro_test_plus`
38
+ * namespace.
39
+ *
40
+ * This file is intended solely for internal use within the framework and
41
+ * should not be included directly by user code.
42
+ */
43
+
44
+ #ifndef MICRO_TEST_PLUS_EXPRESSION_FORMATTER_INLINES_H_
45
+ #define MICRO_TEST_PLUS_EXPRESSION_FORMATTER_INLINES_H_
46
+
47
+ // ----------------------------------------------------------------------------
48
+
49
+ #ifdef __cplusplus
50
+
51
+ // ----------------------------------------------------------------------------
52
+
53
+ #include <cstdio>
54
+
55
+ #include "micro-os-plus/micro-test-plus/reflection.h"
56
+
57
+ // ----------------------------------------------------------------------------
58
+
59
+ #if defined(__GNUC__)
60
+ #pragma GCC diagnostic push
61
+ #pragma GCC diagnostic ignored "-Waggregate-return"
62
+ #if defined(__clang__)
63
+ #pragma clang diagnostic ignored "-Wc++98-compat"
64
+ #pragma clang diagnostic ignored "-Wc++98-compat-pedantic"
65
+ #endif
66
+ #endif
67
+
68
+ // ============================================================================
69
+
70
+ namespace micro_os_plus::micro_test_plus::detail
71
+ {
72
+ // --------------------------------------------------------------------------
73
+
74
+ /**
75
+ * @details
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.
182
+ */
183
+ template <typename T>
184
+ expression_formatter&
185
+ expression_formatter::operator<< (T* v)
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
198
+ char buff[20];
199
+ snprintf (buff, sizeof (buff), "%p", reinterpret_cast<void*> (v));
200
+ buffer_.append (buff);
201
+ #if defined(__GNUC__)
202
+ #pragma GCC diagnostic pop
203
+ #endif
204
+ return *this;
205
+ }
206
+
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)
217
+ {
218
+ *this << detail::get (t);
219
+ return *this;
220
+ }
221
+
222
+ /**
223
+ * @details
224
+ * Casts the underlying integral value to `long long` and formats
225
+ * it without a type suffix, appending the result to the buffer.
226
+ */
227
+ template <class T>
228
+ expression_formatter&
229
+ expression_formatter::operator<< (
230
+ const type_traits::genuine_integral_value<T>& v)
231
+ {
232
+ detail::append_number_ (buffer_, static_cast<long long> (v.get ()));
233
+ return *this;
234
+ }
235
+
236
+ /**
237
+ * @details
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.
241
+ */
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)
246
+ {
247
+ *this << '{';
248
+ auto first = true;
249
+ for (const auto& arg : t)
250
+ {
251
+ *this << (first ? "" : ", ") << arg;
252
+ first = false;
253
+ }
254
+ *this << '}';
255
+ return *this;
256
+ }
257
+
258
+ // --------------------------------------------------------------------------
259
+ // Compound expression operators (without colour codes).
260
+
261
+ /**
262
+ * @details
263
+ * This operator overload enables the `reporter` to output equality
264
+ * comparison expressions in a clear and expressive format.
265
+ *
266
+ * The left-hand side and right-hand side values are formatted and separated
267
+ * by the equality operator (`==`), with appropriate colour highlighting
268
+ * applied for improved readability in test reports and diagnostics. This
269
+ * structured output assists in quickly identifying the values involved in
270
+ * equality assertions and facilitates efficient debugging of test failures.
271
+ */
272
+ template <class Lhs_T, class Rhs_T>
273
+ expression_formatter&
274
+ expression_formatter::operator<< (const detail::eq_<Lhs_T, Rhs_T>& op)
275
+ {
276
+ return (*this << colour_ (op) << op.lhs () << " == " << op.rhs ()
277
+ << colours_.none);
278
+ }
279
+
280
+ /**
281
+ * @details
282
+ * This operator overload enables the `reporter` to output inequality
283
+ * comparison expressions in a clear and expressive format.
284
+ *
285
+ * The left-hand side and right-hand side values are formatted and separated
286
+ * by the inequality operator (`!=`), with appropriate colour highlighting
287
+ * applied for improved readability in test reports and diagnostics. This
288
+ * structured output assists in quickly identifying the values involved in
289
+ * inequality assertions and facilitates efficient debugging of test
290
+ * failures.
291
+ */
292
+ template <class Lhs_T, class Rhs_T>
293
+ expression_formatter&
294
+ expression_formatter::operator<< (const detail::ne_<Lhs_T, Rhs_T>& op)
295
+ {
296
+ return (*this << colour_ (op) << op.lhs () << " != " << op.rhs ()
297
+ << colours_.none);
298
+ }
299
+
300
+ /**
301
+ * @details
302
+ * This operator overload enables the `reporter` to output greater-than
303
+ * comparison expressions in a clear and expressive format.
304
+ *
305
+ * The left-hand side and right-hand side values are formatted and separated
306
+ * by the greater-than operator (`>`), with appropriate colour highlighting
307
+ * applied for improved readability in test reports and diagnostics. This
308
+ * structured output assists in quickly identifying the values involved in
309
+ * greater-than assertions and facilitates efficient debugging of test
310
+ * failures.
311
+ */
312
+ template <class Lhs_T, class Rhs_T>
313
+ expression_formatter&
314
+ expression_formatter::operator<< (const detail::gt_<Lhs_T, Rhs_T>& op)
315
+ {
316
+ return (*this << colour_ (op) << op.lhs () << " > " << op.rhs ()
317
+ << colours_.none);
318
+ }
319
+
320
+ /**
321
+ * @details
322
+ * This operator overload enables the `reporter` to output
323
+ * greater-than-or-equal-to comparison expressions in a clear and expressive
324
+ * format.
325
+ *
326
+ * The left-hand side and right-hand side values are formatted and separated
327
+ * by the greater-than-or-equal-to operator (`>=`), with appropriate colour
328
+ * highlighting applied for improved readability in test reports and
329
+ * diagnostics. This structured output assists in quickly identifying the
330
+ * values involved in greater-than-or-equal-to assertions and facilitates
331
+ * efficient debugging of test failures.
332
+ */
333
+ template <class Lhs_T, class Rhs_T>
334
+ expression_formatter&
335
+ expression_formatter::operator<< (const detail::ge_<Lhs_T, Rhs_T>& op)
336
+ {
337
+ return (*this << colour_ (op) << op.lhs () << " >= " << op.rhs ()
338
+ << colours_.none);
339
+ }
340
+
341
+ /**
342
+ * @details
343
+ * This operator overload enables the `reporter` to output less-than
344
+ * comparison expressions in a clear and expressive format.
345
+ *
346
+ * The left-hand side and right-hand side values are formatted and separated
347
+ * by the less-than operator (`<`), with appropriate colour highlighting
348
+ * applied for improved readability in test reports and diagnostics. This
349
+ * structured output assists in quickly identifying the values involved in
350
+ * less-than assertions and facilitates efficient debugging of test failures.
351
+ */
352
+ template <class Lhs_T, class Rhs_T>
353
+ expression_formatter&
354
+ expression_formatter::operator<< (const detail::lt_<Rhs_T, Lhs_T>& op)
355
+ {
356
+ return (*this << colour_ (op) << op.lhs () << " < " << op.rhs ()
357
+ << colours_.none);
358
+ }
359
+
360
+ /**
361
+ * @details
362
+ * This operator overload enables the `reporter` to output
363
+ * less-than-or-equal-to comparison expressions in a clear and expressive
364
+ * format.
365
+ *
366
+ * The left-hand side and right-hand side values are formatted and separated
367
+ * by the less-than-or-equal-to operator (`<=`), with appropriate colour
368
+ * highlighting applied for improved readability in test reports and
369
+ * diagnostics. This structured output assists in quickly identifying the
370
+ * values involved in less-than-or-equal-to assertions and facilitates
371
+ * efficient debugging of test failures.
372
+ */
373
+ template <class Lhs_T, class Rhs_T>
374
+ expression_formatter&
375
+ expression_formatter::operator<< (const detail::le_<Rhs_T, Lhs_T>& op)
376
+ {
377
+ return (*this << colour_ (op) << op.lhs () << " <= " << op.rhs ()
378
+ << colours_.none);
379
+ }
380
+
381
+ /**
382
+ * @details
383
+ * This operator overload enables the `reporter` to output logical
384
+ * conjunction (AND) expressions in a clear and structured format.
385
+ *
386
+ * The left-hand side and right-hand side expressions are enclosed in
387
+ * parentheses and separated by the word "and", with appropriate colour
388
+ * highlighting applied for improved readability in test reports and
389
+ * diagnostics. This presentation assists in quickly identifying the
390
+ * components of logical assertions and facilitates efficient debugging of
391
+ * test failures involving compound conditions.
392
+ */
393
+ template <class Lhs_T, class Rhs_T>
394
+ expression_formatter&
395
+ expression_formatter::operator<< (const detail::and_<Lhs_T, Rhs_T>& op)
396
+ {
397
+ return (*this << '(' << op.lhs () << colour_ (op) << " and "
398
+ << colours_.none << op.rhs () << ')');
399
+ }
400
+
401
+ /**
402
+ * @details
403
+ * This operator overload enables the `reporter` to output logical
404
+ * disjunction (OR) expressions in a clear and structured format.
405
+ *
406
+ * The left-hand side and right-hand side expressions are enclosed in
407
+ * parentheses and separated by the word "or", with appropriate colour
408
+ * highlighting applied for improved readability in test reports and
409
+ * diagnostics. This presentation assists in quickly identifying the
410
+ * components of logical assertions and facilitates efficient debugging of
411
+ * test failures involving compound conditions.
412
+ */
413
+ template <class Lhs_T, class Rhs_T>
414
+ expression_formatter&
415
+ expression_formatter::operator<< (const detail::or_<Lhs_T, Rhs_T>& op)
416
+ {
417
+ return (*this << '(' << op.lhs () << colour_ (op) << " or "
418
+ << colours_.none << op.rhs () << ')');
419
+ }
420
+
421
+ /**
422
+ * @details
423
+ * This operator overload enhances readability and clarity by formatting the
424
+ * output when handling negated expressions. It applies colour styling for
425
+ * improved distinction and appends the negated value accordingly, ensuring
426
+ * that logical negations are clearly represented in test reports and
427
+ * diagnostics.
428
+ */
429
+ template <class T>
430
+ expression_formatter&
431
+ expression_formatter::operator<< (const detail::not_<T>& op)
432
+ {
433
+ return (*this << colour_ (op) << "not " << op.operand () << colours_.none);
434
+ }
435
+
436
+ #if defined(__cpp_exceptions)
437
+ /**
438
+ * @details
439
+ * This operator overload provides structured output for expressions that may
440
+ * throw exceptions. It applies colour styling for clarity and includes the
441
+ * exception type name for precise identification.
442
+ *
443
+ * When invoked, the output highlights the `throws` qualifier along with the
444
+ * specific exception type, making it immediately apparent which exception is
445
+ * expected. This enhances the readability and professionalism of test
446
+ * reports, and assists in the precise identification and debugging of
447
+ * exception-related test cases.
448
+ */
449
+ template <class Callable_T, class Exception_T>
450
+ expression_formatter&
451
+ expression_formatter::operator<< (
452
+ const detail::throws_<Callable_T, Exception_T>& op)
453
+ {
454
+ return (*this << colour_ (op) << "throws<"
455
+ << reflection::type_name<Exception_T> () << ">"
456
+ << colours_.none);
457
+ }
458
+
459
+ /**
460
+ * @details
461
+ * This operator overload formats output for expressions that may throw
462
+ * exceptions. It applies colour styling for clarity and ensures a structured
463
+ * representation of the exception handling mechanism.
464
+ *
465
+ * When invoked, the output highlights the `throws` qualifier, making it
466
+ * immediately apparent when an expression is expected to throw, thereby
467
+ * improving the readability and professionalism of the test output.
468
+ */
469
+ template <class Callable_T>
470
+ expression_formatter&
471
+ expression_formatter::operator<< (
472
+ const detail::throws_<Callable_T, void>& op)
473
+ {
474
+ return (*this << colour_ (op) << "throws" << colours_.none);
475
+ }
476
+
477
+ /**
478
+ * @details
479
+ * This operator overload formats output for expressions that do not throw
480
+ * exceptions. It applies colour styling for clarity and ensures a structured
481
+ * and concise representation of exception safety within test reports.
482
+ *
483
+ * The output highlights the `nothrow` qualifier, making it immediately
484
+ * apparent when an expression is guaranteed not to throw, thereby improving
485
+ * the readability and professionalism of the test output.
486
+ */
487
+ template <class Callable_T>
488
+ expression_formatter&
489
+ expression_formatter::operator<< (const detail::nothrow_<Callable_T>& op)
490
+ {
491
+ return (*this << colour_ (op) << "nothrow" << colours_.none);
492
+ }
493
+ #endif
494
+
495
+ // --------------------------------------------------------------------------
496
+ } // namespace micro_os_plus::micro_test_plus::detail
497
+
498
+ #if defined(__GNUC__)
499
+ #pragma GCC diagnostic pop
500
+ #endif
501
+
502
+ // ----------------------------------------------------------------------------
503
+
504
+ #endif // __cplusplus
505
+
506
+ // ----------------------------------------------------------------------------
507
+
508
+ #endif // MICRO_TEST_PLUS_EXPRESSION_FORMATTER_INLINES_H_
509
+
510
+ // ----------------------------------------------------------------------------