@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
@@ -51,6 +51,9 @@
51
51
  #include <cstdio>
52
52
  #include <string>
53
53
 
54
+ #include "type-traits.h"
55
+ #include "reflection.h"
56
+
54
57
  // ----------------------------------------------------------------------------
55
58
 
56
59
  #if defined(__GNUC__)
@@ -95,20 +98,18 @@ namespace micro_os_plus::micro_test_plus
95
98
  */
96
99
  namespace detail
97
100
  {
101
+ // ========================================================================
102
+
98
103
  /**
99
104
  * @brief Assertion struct template for parameter passing to the evaluator.
100
105
  *
101
- * @tparam Expr_T The type of the expression being asserted.
102
- *
103
106
  * @details
104
- * The `assertion` struct template is used to encapsulate assertion
105
- * parameters, including the expression under evaluation and its associated
106
- * source location. This design enables precise reporting and diagnostics
107
- * within the framework.
107
+ * This structure encapsulates both the expression being tested and its
108
+ * associated source location. Used internally by the framework to pass
109
+ * assertion data through the evaluation pipeline, enabling accurate
110
+ * reporting of where assertions occur in test code.
108
111
  *
109
- * The structure is intended exclusively for internal use and is
110
- * implemented in the `include/micro-os-plus/micro-test-plus` folder to
111
- * maintain a structured and modular codebase.
112
+ * @tparam Expr_T The type of the expression being asserted.
112
113
  *
113
114
  * @headerfile micro-test-plus.h <micro-os-plus/micro-test-plus.h>
114
115
  */
@@ -126,11 +127,7 @@ namespace micro_os_plus::micro_test_plus
126
127
  reflection::source_location location{};
127
128
  };
128
129
 
129
- // ------------------------------------------------------------------------
130
-
131
- // in C++14/17/20, a function template with a deduced return type
132
- // (auto) cannot be used before its definition is visible.
133
- // Therefore it is not possible to split definitions.
130
+ // ========================================================================
134
131
 
135
132
  /**
136
133
  * @brief Generic getter function template for value retrieval.
@@ -139,51 +136,24 @@ namespace micro_os_plus::micro_test_plus
139
136
  *
140
137
  * @param t The object or value to be accessed.
141
138
  * @return The value obtained via the relevant getter implementation.
142
- *
143
- * @details
144
- * The `get` function template retrieves the value from the provided
145
- * object or type. If the type provides a `get()` member function, it
146
- * is invoked; otherwise the argument itself is returned unchanged.
147
- *
148
- * The selection is performed at compile time using `if constexpr` and
149
- * an inline `requires` expression, superseding the classic two-overload
150
- * SFINAE technique used prior to C++20.
151
- *
152
- * All definitions are intended for internal use within the framework and
153
- * are implemented in the `include/micro-os-plus/micro-test-plus` folder to
154
- * maintain a structured and modular codebase.
155
139
  */
156
140
  template <class T>
157
141
  [[nodiscard]] constexpr auto
158
- get (const T& t)
159
- {
160
- if constexpr (requires { t.get (); })
161
- return t.get ();
162
- else
163
- return t;
164
- }
142
+ get (const T& t);
165
143
 
166
- // ------------------------------------------------------------------------
144
+ // ========================================================================
167
145
 
168
146
  /**
169
147
  * @brief Common base struct template for unary comparators.
170
148
  *
171
- * @tparam T The type of the operand.
172
- *
173
149
  * @details
174
- * The `unary_op_` struct template provides the shared state and
175
- * interface for unary comparator types within the framework. It stores
176
- * the single operand and the boolean result of the operation, and
177
- * exposes a conversion operator and an operand accessor common to all
178
- * unary comparators.
179
- *
180
- * Derived comparator structs (e.g. `not_`) inherit from this base and
181
- * supply the operation-specific logic via their constructors.
150
+ * This base struct stores a single operand and the pre-computed boolean
151
+ * result of a unary operation. Derived structs such as `not_` inherit
152
+ * from this to provide logical negation. The result is computed at
153
+ * construction time, enabling consistent handling and reporting of
154
+ * operations throughout the assertion framework.
182
155
  *
183
- * All definitions are intended for internal use within the framework
184
- * and are implemented in the
185
- * `include/micro-os-plus/micro-test-plus` folder to maintain a
186
- * structured and modular codebase.
156
+ * @tparam T The type of the operand.
187
157
  *
188
158
  * @headerfile micro-test-plus.h <micro-os-plus/micro-test-plus.h>
189
159
  */
@@ -197,9 +167,7 @@ namespace micro_os_plus::micro_test_plus
197
167
  * @param t The operand.
198
168
  * @param value The pre-computed boolean result of the operation.
199
169
  */
200
- constexpr unary_op_ (const T& t, bool value) : t_{ t }, value_{ value }
201
- {
202
- }
170
+ constexpr unary_op_ (const T& t, bool value);
203
171
 
204
172
  /**
205
173
  * @brief Conversion operator to boolean.
@@ -207,16 +175,9 @@ namespace micro_os_plus::micro_test_plus
207
175
  * @par Parameters
208
176
  * None.
209
177
  * @return The result of the operation.
210
- *
211
- * @details
212
- * Returns the pre-computed boolean result stored by the derived
213
- * comparator's constructor.
214
178
  */
215
179
  [[nodiscard]] constexpr
216
- operator bool () const
217
- {
218
- return value_;
219
- }
180
+ operator bool () const;
220
181
 
221
182
  /**
222
183
  * @brief Retrieves the wrapped operand expression.
@@ -224,18 +185,9 @@ namespace micro_os_plus::micro_test_plus
224
185
  * @par Parameters
225
186
  * None.
226
187
  * @return The extracted operand value.
227
- *
228
- * @details
229
- * Returns the wrapped operand, applying the generic getter to
230
- * ensure correct extraction for both custom and standard types.
231
- * Named `operand()` to distinguish it from the boolean result
232
- * stored in `value_`.
233
188
  */
234
189
  [[nodiscard]] constexpr auto
235
- operand () const
236
- {
237
- return get (t_);
238
- }
190
+ operand () const;
239
191
 
240
192
  private:
241
193
  /**
@@ -249,29 +201,21 @@ namespace micro_os_plus::micro_test_plus
249
201
  const bool value_{};
250
202
  };
251
203
 
252
- // ------------------------------------------------------------------------
204
+ // ========================================================================
253
205
 
254
206
  /**
255
207
  * @brief Common base struct template for binary comparators.
256
208
  *
257
- * @tparam Lhs_T The type of the left-hand operand.
258
- * @tparam Rhs_T The type of the right-hand operand.
259
- *
260
209
  * @details
261
- * The `binary_op_` struct template provides the shared state and interface
262
- * for all binary comparator types within the framework. It stores the
263
- * two operands and the boolean result of the comparison, and exposes
264
- * a conversion operator and value accessors common to all binary
265
- * comparators.
266
- *
267
- * Derived comparator structs (`eq_`, `ne_`, `gt_`, `ge_`, `lt_`, `le_`,
268
- * `and_`, `or_`) inherit from this base and supply the
269
- * operation-specific logic via their constructors.
210
+ * This base struct stores two operands (left-hand and right-hand) along
211
+ * with the pre-computed boolean result of a binary comparison. Derived
212
+ * structs such as `eq_`, `lt_`, and others inherit from this to provide
213
+ * relational and logical operations. The comparison result is computed at
214
+ * construction time and cached, enabling efficient reporting and
215
+ * composition of complex assertions without repeated computation.
270
216
  *
271
- * All definitions are intended for internal use within the framework
272
- * and are implemented in the
273
- * `include/micro-os-plus/micro-test-plus` folder to maintain a
274
- * structured and modular codebase.
217
+ * @tparam Lhs_T The type of the left-hand operand.
218
+ * @tparam Rhs_T The type of the right-hand operand.
275
219
  *
276
220
  * @headerfile micro-test-plus.h <micro-os-plus/micro-test-plus.h>
277
221
  */
@@ -286,10 +230,7 @@ namespace micro_os_plus::micro_test_plus
286
230
  * @param rhs The right-hand operand.
287
231
  * @param value The pre-computed boolean result of the comparison.
288
232
  */
289
- constexpr binary_op_ (const Lhs_T& lhs, const Rhs_T& rhs, bool value)
290
- : lhs_{ lhs }, rhs_{ rhs }, value_{ value }
291
- {
292
- }
233
+ constexpr binary_op_ (const Lhs_T& lhs, const Rhs_T& rhs, bool value);
293
234
 
294
235
  /**
295
236
  * @brief Conversion operator to boolean.
@@ -297,16 +238,9 @@ namespace micro_os_plus::micro_test_plus
297
238
  * @par Parameters
298
239
  * None.
299
240
  * @return The result of the comparison.
300
- *
301
- * @details
302
- * Returns the pre-computed boolean result stored by the derived
303
- * comparator's constructor.
304
241
  */
305
242
  [[nodiscard]] constexpr
306
- operator bool () const
307
- {
308
- return value_;
309
- }
243
+ operator bool () const;
310
244
 
311
245
  /**
312
246
  * @brief Retrieves the left-hand operand.
@@ -314,17 +248,9 @@ namespace micro_os_plus::micro_test_plus
314
248
  * @par Parameters
315
249
  * None.
316
250
  * @return The extracted left-hand operand.
317
- *
318
- * @details
319
- * Returns the value of the left-hand operand, applying the generic
320
- * getter to ensure correct extraction for both custom and standard
321
- * types.
322
251
  */
323
252
  [[nodiscard]] constexpr auto
324
- lhs (void) const
325
- {
326
- return get (lhs_);
327
- }
253
+ lhs (void) const;
328
254
 
329
255
  /**
330
256
  * @brief Retrieves the right-hand operand.
@@ -332,17 +258,9 @@ namespace micro_os_plus::micro_test_plus
332
258
  * @par Parameters
333
259
  * None.
334
260
  * @return The extracted right-hand operand.
335
- *
336
- * @details
337
- * Returns the value of the right-hand operand, applying the generic
338
- * getter to ensure correct extraction for both custom and standard
339
- * types.
340
261
  */
341
262
  [[nodiscard]] constexpr auto
342
- rhs (void) const
343
- {
344
- return get (rhs_);
345
- }
263
+ rhs (void) const;
346
264
 
347
265
  private:
348
266
  /**
@@ -367,32 +285,19 @@ namespace micro_os_plus::micro_test_plus
367
285
  const bool value_{};
368
286
  };
369
287
 
370
- // ------------------------------------------------------------------------
288
+ // ========================================================================
371
289
 
372
290
  /**
373
291
  * @brief Equality comparator struct template.
374
292
  *
375
- * @tparam Lhs_T The type of the left-hand operand.
376
- * @tparam Rhs_T The type of the right-hand operand.
377
- *
378
293
  * @details
379
- * The `eq_` struct template provides a type-safe mechanism for evaluating
380
- * equality between two operands within the framework.
381
- *
382
- * This comparator supports a variety of operand types, including those
383
- * with static values, types with precision (epsilon), and generic types.
384
- * For types with static values, the comparison is performed directly. For
385
- * types supporting precision, the comparison accounts for the smallest
386
- * epsilon to ensure accuracy, particularly for floating-point types. For
387
- * all other types, the generic getter is used to retrieve and compare the
388
- * values.
389
- *
390
- * The implementation is optimised for use in embedded environments and
391
- * supports both compile-time and run-time evaluation.
294
+ * Derived from `binary_op_`, this struct checks whether the left-hand
295
+ * operand is equal to the right-hand operand. It is used within test
296
+ * expressions to provide human-readable equality assertions with
297
+ * enhanced reporting of the actual and expected values upon failure.
392
298
  *
393
- * All definitions are intended for internal use within the framework and
394
- * are implemented in the `include/micro-os-plus/micro-test-plus` folder to
395
- * maintain a structured and modular codebase.
299
+ * @tparam Lhs_T The type of the left-hand operand.
300
+ * @tparam Rhs_T The type of the right-hand operand.
396
301
  *
397
302
  * @headerfile micro-test-plus.h <micro-os-plus/micro-test-plus.h>
398
303
  */
@@ -404,103 +309,27 @@ namespace micro_os_plus::micro_test_plus
404
309
  *
405
310
  * @param lhs The left-hand operand.
406
311
  * @param rhs The right-hand operand.
407
- *
408
- * @details
409
- * Evaluates the equality of the provided operands and passes the
410
- * result to the `binary_op_` base class constructor.
411
- * Supports static values, types with precision, and generic types.
412
312
  */
413
- constexpr eq_ (const Lhs_T& lhs = {}, const Rhs_T& rhs = {})
414
- : binary_op_<Lhs_T, Rhs_T>{ lhs, rhs, [&]
415
- {
416
- // This lambda is called in the constructor to evaluate the
417
- // comparison. Its result is implicitly converted to bool via
418
- // the operator bool() of whatever type the branch returns.
419
- // This is intentional: all result types (integral_constant,
420
- // comparator objects, plain bool) define operator bool().
421
- using std::operator==;
422
- using std::operator<;
423
-
424
- #if defined(__GNUC__)
425
- #pragma GCC diagnostic push
426
- #pragma GCC diagnostic ignored "-Wfloat-equal"
427
- #pragma GCC diagnostic ignored "-Wconversion"
428
- #pragma GCC diagnostic ignored "-Wdouble-promotion"
429
- #pragma GCC diagnostic ignored "-Wsign-compare"
430
- #if defined(__clang__)
431
- #pragma clang diagnostic ignored "-Wimplicit-int-float-conversion"
432
- #pragma clang diagnostic ignored "-Wpedantic"
433
- #endif
434
- #endif
435
- if constexpr (type_traits::has_value<Lhs_T>
436
- and type_traits::has_value<Rhs_T>)
437
- {
438
- // If both types have values (like numeric constants),
439
- // compare them directly.
440
- return Lhs_T::value == Rhs_T::value;
441
- }
442
- else if constexpr (type_traits::has_epsilon<Lhs_T>
443
- and type_traits::has_epsilon<Rhs_T>)
444
- {
445
- // If both values have precision, compare them using
446
- // the smallest precision.
447
- return math::abs (get (lhs) - get (rhs))
448
- < math::min_value (lhs.epsilon, rhs.epsilon);
449
- }
450
- else if constexpr (type_traits::has_epsilon<Lhs_T>)
451
- {
452
- // If only the left operand has precision, use it.
453
- return math::abs (get (lhs) - get (rhs)) < lhs.epsilon;
454
- }
455
- else if constexpr (type_traits::has_epsilon<Rhs_T>)
456
- {
457
- // If only the right operand has precision, use it.
458
- return math::abs (get (lhs) - get (rhs)) < rhs.epsilon;
459
- }
460
- else
461
- {
462
- // Call the generic getters, which might
463
- // either call the type get() or return the value.
464
- return get (lhs) == get (rhs);
465
- }
466
- #if defined(__GNUC__)
467
- #pragma GCC diagnostic pop
468
- #endif
469
- }() }
470
- {
471
- }
313
+ constexpr eq_ (const Lhs_T& lhs = {}, const Rhs_T& rhs = {});
472
314
  };
473
315
 
474
316
  // Deduction guide.
475
317
  template <typename Lhs_T, typename Rhs_T>
476
318
  eq_ (const Lhs_T&, const Rhs_T&) -> eq_<Lhs_T, Rhs_T>;
477
319
 
478
- // ------------------------------------------------------------------------
320
+ // ========================================================================
479
321
 
480
322
  /**
481
323
  * @brief Non-equality comparator struct template.
482
324
  *
483
- * @tparam Lhs_T The type of the left-hand operand.
484
- * @tparam Rhs_T The type of the right-hand operand.
485
- *
486
325
  * @details
487
- * The `ne_` struct template provides a type-safe mechanism for evaluating
488
- * non-equality between two operands within the framework.
489
- *
490
- * This comparator supports a variety of operand types, including those
491
- * with static values, types with precision (epsilon), and generic types.
492
- * For types with static values, the comparison is performed directly. For
493
- * types supporting precision, the comparison accounts for the smallest
494
- * epsilon to ensure accuracy, particularly for floating-point types. For
495
- * all other types, the generic getter is used to retrieve and compare the
496
- * values.
326
+ * Derived from `binary_op_`, this struct checks whether the left-hand
327
+ * operand is not equal to the right-hand operand. It is used within test
328
+ * expressions to provide human-readable inequality assertions with
329
+ * enhanced reporting of the actual and expected values upon failure.
497
330
  *
498
- * The implementation is optimised for use in embedded environments and
499
- * supports both compile-time and run-time evaluation.
500
- *
501
- * All definitions are intended for internal use within the framework and
502
- * are implemented in the `include/micro-os-plus` folder to maintain a
503
- * structured and modular codebase.
331
+ * @tparam Lhs_T The type of the left-hand operand.
332
+ * @tparam Rhs_T The type of the right-hand operand.
504
333
  *
505
334
  * @headerfile micro-test-plus.h <micro-os-plus/micro-test-plus.h>
506
335
  */
@@ -512,89 +341,27 @@ namespace micro_os_plus::micro_test_plus
512
341
  *
513
342
  * @param lhs The left-hand operand.
514
343
  * @param rhs The right-hand operand.
515
- *
516
- * @details
517
- * Evaluates the non-equality of the provided operands and passes the
518
- * result to the `binary_op_` base class constructor.
519
- * Supports static values, types with precision, and generic types.
520
344
  */
521
- constexpr ne_ (const Lhs_T& lhs = {}, const Rhs_T& rhs = {})
522
- : binary_op_<Lhs_T, Rhs_T>{ lhs, rhs, [&]
523
- {
524
- using std::operator==;
525
- using std::operator!=;
526
- using std::operator>;
527
-
528
- #if defined(__GNUC__)
529
- #pragma GCC diagnostic push
530
- #pragma GCC diagnostic ignored "-Wfloat-equal"
531
- #pragma GCC diagnostic ignored "-Wconversion"
532
- #pragma GCC diagnostic ignored "-Wdouble-promotion"
533
- #pragma GCC diagnostic ignored "-Wsign-compare"
534
- #if defined(__clang__)
535
- #pragma clang diagnostic ignored "-Wimplicit-int-float-conversion"
536
- #pragma clang diagnostic ignored "-Wpedantic"
537
- #endif
538
- #endif
539
- if constexpr (type_traits::has_value<Lhs_T>
540
- and type_traits::has_value<Rhs_T>)
541
- {
542
- return Lhs_T::value != Rhs_T::value;
543
- }
544
- else if constexpr (type_traits::has_epsilon<Lhs_T>
545
- and type_traits::has_epsilon<Rhs_T>)
546
- {
547
- return math::abs (get (lhs) - get (rhs))
548
- >= math::min_value (lhs.epsilon, rhs.epsilon);
549
- }
550
- else if constexpr (type_traits::has_epsilon<Lhs_T>)
551
- {
552
- return math::abs (get (lhs) - get (rhs)) >= lhs.epsilon;
553
- }
554
- else if constexpr (type_traits::has_epsilon<Rhs_T>)
555
- {
556
- return math::abs (get (lhs) - get (rhs)) >= rhs.epsilon;
557
- }
558
- else
559
- {
560
- return get (lhs) != get (rhs);
561
- }
562
- #if defined(__GNUC__)
563
- #pragma GCC diagnostic pop
564
- #endif
565
- }() }
566
- {
567
- }
345
+ constexpr ne_ (const Lhs_T& lhs = {}, const Rhs_T& rhs = {});
568
346
  };
569
347
 
570
348
  // Deduction guide.
571
349
  template <typename Lhs_T, typename Rhs_T>
572
350
  ne_ (const Lhs_T&, const Rhs_T&) -> ne_<Lhs_T, Rhs_T>;
573
351
 
574
- // ------------------------------------------------------------------------
352
+ // ========================================================================
575
353
 
576
354
  /**
577
355
  * @brief Greater than comparator struct template.
578
356
  *
579
- * @tparam Lhs_T The type of the left-hand operand.
580
- * @tparam Rhs_T The type of the right-hand operand.
581
- *
582
357
  * @details
583
- * The `gt_` struct template provides a type-safe mechanism for evaluating
584
- * whether the left-hand operand is greater than the right-hand operand
585
- * within the framework.
358
+ * Derived from `binary_op_`, this struct checks whether the left-hand
359
+ * operand is greater than the right-hand operand. It is used within test
360
+ * expressions to provide human-readable relational assertions with
361
+ * enhanced reporting of the actual and expected values upon failure.
586
362
  *
587
- * This comparator supports a variety of operand types, including those
588
- * with static values and generic types. For types with static values, the
589
- * comparison is performed directly. For all other types, the generic
590
- * getter is used to retrieve and compare the values.
591
- *
592
- * The implementation is optimised for use in embedded environments and
593
- * supports both compile-time and run-time evaluation.
594
- *
595
- * All definitions are intended for internal use within the framework and
596
- * are implemented in the `include/micro-os-plus` folder to maintain a
597
- * structured and modular codebase.
363
+ * @tparam Lhs_T The type of the left-hand operand.
364
+ * @tparam Rhs_T The type of the right-hand operand.
598
365
  *
599
366
  * @headerfile micro-test-plus.h <micro-os-plus/micro-test-plus.h>
600
367
  */
@@ -606,73 +373,28 @@ namespace micro_os_plus::micro_test_plus
606
373
  *
607
374
  * @param lhs The left-hand operand.
608
375
  * @param rhs The right-hand operand.
609
- *
610
- * @details
611
- * Evaluates whether the left-hand operand is greater than the
612
- * right-hand operand and passes the result to the `binary_op_` base
613
- * class constructor.
614
- * Supports static values and generic types.
615
376
  */
616
- constexpr gt_ (const Lhs_T& lhs = {}, const Rhs_T& rhs = {})
617
- : binary_op_<Lhs_T, Rhs_T>{ lhs, rhs, [&]
618
- {
619
- using std::operator>;
620
-
621
- #if defined(__GNUC__)
622
- #pragma GCC diagnostic push
623
- #pragma GCC diagnostic ignored "-Wconversion"
624
- #pragma GCC diagnostic ignored "-Wdouble-promotion"
625
- #pragma GCC diagnostic ignored "-Wsign-compare"
626
- #if defined(__clang__)
627
- #pragma clang diagnostic ignored "-Wimplicit-int-float-conversion"
628
- #pragma clang diagnostic ignored "-Wpedantic"
629
- #endif
630
- #endif
631
- if constexpr (type_traits::has_value<Lhs_T>
632
- and type_traits::has_value<Rhs_T>)
633
- {
634
- return Lhs_T::value > Rhs_T::value;
635
- }
636
- else
637
- {
638
- return get (lhs) > get (rhs);
639
- }
640
- #if defined(__GNUC__)
641
- #pragma GCC diagnostic pop
642
- #endif
643
- }() }
644
- {
645
- }
377
+ constexpr gt_ (const Lhs_T& lhs = {}, const Rhs_T& rhs = {});
646
378
  };
647
379
 
648
380
  // Deduction guide.
649
381
  template <typename Lhs_T, typename Rhs_T>
650
382
  gt_ (const Lhs_T&, const Rhs_T&) -> gt_<Lhs_T, Rhs_T>;
651
383
 
652
- // ------------------------------------------------------------------------
384
+ // ========================================================================
653
385
 
654
386
  /**
655
387
  * @brief Greater than or equal comparator struct template.
656
388
  *
657
- * @tparam Lhs_T The type of the left-hand operand.
658
- * @tparam Rhs_T The type of the right-hand operand.
659
- *
660
389
  * @details
661
- * The `ge_` struct template provides a type-safe mechanism for evaluating
662
- * whether the left-hand operand is greater than or equal to the right-hand
663
- * operand within the framework.
390
+ * Derived from `binary_op_`, this struct checks whether the left-hand
391
+ * operand is greater than or equal to the right-hand operand. It is used
392
+ * within test expressions to provide human-readable relational
393
+ * assertions with enhanced reporting of the actual and expected values
394
+ * upon failure.
664
395
  *
665
- * This comparator supports a variety of operand types, including those
666
- * with static values and generic types. For types with static values, the
667
- * comparison is performed directly. For all other types, the generic
668
- * getter is used to retrieve and compare the values.
669
- *
670
- * The implementation is optimised for use in embedded environments and
671
- * supports both compile-time and run-time evaluation.
672
- *
673
- * All definitions are intended for internal use within the framework and
674
- * are implemented in the `include/micro-os-plus` folder to maintain a
675
- * structured and modular codebase.
396
+ * @tparam Lhs_T The type of the left-hand operand.
397
+ * @tparam Rhs_T The type of the right-hand operand.
676
398
  *
677
399
  * @headerfile micro-test-plus.h <micro-os-plus/micro-test-plus.h>
678
400
  */
@@ -685,73 +407,27 @@ namespace micro_os_plus::micro_test_plus
685
407
  *
686
408
  * @param lhs The left-hand operand.
687
409
  * @param rhs The right-hand operand.
688
- *
689
- * @details
690
- * Evaluates whether the left-hand operand is greater than or equal
691
- * to the right-hand operand and passes the result to the `binary_op_`
692
- * base class constructor.
693
- * Supports static values and generic types.
694
410
  */
695
- constexpr ge_ (const Lhs_T& lhs = {}, const Rhs_T& rhs = {})
696
- : binary_op_<Lhs_T, Rhs_T>{ lhs, rhs, [&]
697
- {
698
- using std::operator>=;
699
-
700
- #if defined(__GNUC__)
701
- #pragma GCC diagnostic push
702
- #pragma GCC diagnostic ignored "-Wconversion"
703
- #pragma GCC diagnostic ignored "-Wdouble-promotion"
704
- #pragma GCC diagnostic ignored "-Wsign-compare"
705
- #if defined(__clang__)
706
- #pragma clang diagnostic ignored "-Wimplicit-int-float-conversion"
707
- #pragma clang diagnostic ignored "-Wpedantic"
708
- #endif
709
- #endif
710
- if constexpr (type_traits::has_value<Lhs_T>
711
- and type_traits::has_value<Rhs_T>)
712
- {
713
- return Lhs_T::value >= Rhs_T::value;
714
- }
715
- else
716
- {
717
- return get (lhs) >= get (rhs);
718
- }
719
- #if defined(__GNUC__)
720
- #pragma GCC diagnostic pop
721
- #endif
722
- }() }
723
- {
724
- }
411
+ constexpr ge_ (const Lhs_T& lhs = {}, const Rhs_T& rhs = {});
725
412
  };
726
413
 
727
414
  // Deduction guide.
728
415
  template <typename Lhs_T, typename Rhs_T>
729
416
  ge_ (const Lhs_T&, const Rhs_T&) -> ge_<Lhs_T, Rhs_T>;
730
417
 
731
- // ------------------------------------------------------------------------
418
+ // ========================================================================
732
419
 
733
420
  /**
734
421
  * @brief Less than comparator struct template.
735
422
  *
736
- * @tparam Lhs_T The type of the left-hand operand.
737
- * @tparam Rhs_T The type of the right-hand operand.
738
- *
739
423
  * @details
740
- * The `lt_` struct template provides a type-safe mechanism for evaluating
741
- * whether the left-hand operand is less than the right-hand operand within
742
- * the framework.
743
- *
744
- * This comparator supports a variety of operand types, including those
745
- * with static values and generic types. For types with static values, the
746
- * comparison is performed directly. For all other types, the generic
747
- * getter is used to retrieve and compare the values.
424
+ * Derived from `binary_op_`, this struct checks whether the left-hand
425
+ * operand is less than the right-hand operand. It is used within test
426
+ * expressions to provide human-readable relational assertions with
427
+ * enhanced reporting of the actual and expected values upon failure.
748
428
  *
749
- * The implementation is optimised for use in embedded environments and
750
- * supports both compile-time and run-time evaluation.
751
- *
752
- * All definitions are intended for internal use within the framework and
753
- * are implemented in the `include/micro-os-plus` folder to maintain a
754
- * structured and modular codebase.
429
+ * @tparam Lhs_T The type of the left-hand operand.
430
+ * @tparam Rhs_T The type of the right-hand operand.
755
431
  *
756
432
  * @headerfile micro-test-plus.h <micro-os-plus/micro-test-plus.h>
757
433
  */
@@ -763,73 +439,28 @@ namespace micro_os_plus::micro_test_plus
763
439
  *
764
440
  * @param lhs The left-hand operand.
765
441
  * @param rhs The right-hand operand.
766
- *
767
- * @details
768
- * Evaluates whether the left-hand operand is less than the right-hand
769
- * operand and passes the result to the `binary_op_` base class
770
- * constructor.
771
- * Supports static values and generic types.
772
442
  */
773
- constexpr lt_ (const Lhs_T& lhs = {}, const Rhs_T& rhs = {})
774
- : binary_op_<Lhs_T, Rhs_T>{ lhs, rhs, [&]
775
- {
776
- using std::operator<;
777
-
778
- #if defined(__GNUC__)
779
- #pragma GCC diagnostic push
780
- #pragma GCC diagnostic ignored "-Wconversion"
781
- #pragma GCC diagnostic ignored "-Wdouble-promotion"
782
- #pragma GCC diagnostic ignored "-Wsign-compare"
783
- #if defined(__clang__)
784
- #pragma clang diagnostic ignored "-Wimplicit-int-float-conversion"
785
- #pragma clang diagnostic ignored "-Wpedantic"
786
- #endif
787
- #endif
788
- if constexpr (type_traits::has_value<Lhs_T>
789
- and type_traits::has_value<Rhs_T>)
790
- {
791
- return Lhs_T::value < Rhs_T::value;
792
- }
793
- else
794
- {
795
- return get (lhs) < get (rhs);
796
- }
797
- #if defined(__GNUC__)
798
- #pragma GCC diagnostic pop
799
- #endif
800
- }() }
801
- {
802
- }
443
+ constexpr lt_ (const Lhs_T& lhs = {}, const Rhs_T& rhs = {});
803
444
  };
804
445
 
805
446
  // Deduction guide.
806
447
  template <typename Lhs_T, typename Rhs_T>
807
448
  lt_ (const Lhs_T&, const Rhs_T&) -> lt_<Lhs_T, Rhs_T>;
808
449
 
809
- // ------------------------------------------------------------------------
450
+ // ========================================================================
810
451
 
811
452
  /**
812
453
  * @brief Less than or equal comparator struct template.
813
454
  *
814
- * @tparam Lhs_T The type of the left-hand operand.
815
- * @tparam Rhs_T The type of the right-hand operand.
816
- *
817
455
  * @details
818
- * The `le_` struct template provides a type-safe mechanism for evaluating
819
- * whether the left-hand operand is less than or equal to the right-hand
820
- * operand within the framework.
821
- *
822
- * This comparator supports a variety of operand types, including those
823
- * with static values and generic types. For types with static values, the
824
- * comparison is performed directly. For all other types, the generic
825
- * getter is used to retrieve and compare the values.
456
+ * Derived from `binary_op_`, this struct checks whether the left-hand
457
+ * operand is less than or equal to the right-hand operand. It is used
458
+ * within test expressions to provide human-readable relational
459
+ * assertions with enhanced reporting of the actual and expected values
460
+ * upon failure.
826
461
  *
827
- * The implementation is optimised for use in embedded environments and
828
- * supports both compile-time and run-time evaluation.
829
- *
830
- * All definitions are intended for internal use within the framework and
831
- * are implemented in the `include/micro-os-plus/micro-test-plus` folder to
832
- * maintain a structured and modular codebase.
462
+ * @tparam Lhs_T The type of the left-hand operand.
463
+ * @tparam Rhs_T The type of the right-hand operand.
833
464
  *
834
465
  * @headerfile micro-test-plus.h <micro-os-plus/micro-test-plus.h>
835
466
  */
@@ -842,72 +473,28 @@ namespace micro_os_plus::micro_test_plus
842
473
  *
843
474
  * @param lhs The left-hand operand.
844
475
  * @param rhs The right-hand operand.
845
- *
846
- * @details
847
- * Evaluates whether the left-hand operand is less than or equal to
848
- * the right-hand operand and passes the result to the `binary_op_` base
849
- * class constructor.
850
- * Supports static values and generic types.
851
476
  */
852
- constexpr le_ (const Lhs_T& lhs = {}, const Rhs_T& rhs = {})
853
- : binary_op_<Lhs_T, Rhs_T>{ lhs, rhs, [&]
854
- {
855
- using std::operator<=;
856
-
857
- #if defined(__GNUC__)
858
- #pragma GCC diagnostic push
859
- #pragma GCC diagnostic ignored "-Wconversion"
860
- #pragma GCC diagnostic ignored "-Wdouble-promotion"
861
- #pragma GCC diagnostic ignored "-Wsign-compare"
862
- #if defined(__clang__)
863
- #pragma clang diagnostic ignored "-Wimplicit-int-float-conversion"
864
- #pragma clang diagnostic ignored "-Wpedantic"
865
- #endif
866
- #endif
867
- if constexpr (type_traits::has_value<Lhs_T>
868
- and type_traits::has_value<Rhs_T>)
869
- {
870
- return Lhs_T::value <= Rhs_T::value;
871
- }
872
- else
873
- {
874
- return get (lhs) <= get (rhs);
875
- }
876
- #if defined(__GNUC__)
877
- #pragma GCC diagnostic pop
878
- #endif
879
- }() }
880
- {
881
- }
477
+ constexpr le_ (const Lhs_T& lhs = {}, const Rhs_T& rhs = {});
882
478
  };
883
479
 
884
480
  // Deduction guide.
885
481
  template <typename Lhs_T, typename Rhs_T>
886
482
  le_ (const Lhs_T&, const Rhs_T&) -> le_<Lhs_T, Rhs_T>;
887
483
 
888
- // ------------------------------------------------------------------------
484
+ // ========================================================================
889
485
 
890
486
  /**
891
487
  * @brief Logical AND comparator struct template.
892
488
  *
893
- * @tparam Lhs_T The type of the left-hand operand.
894
- * @tparam Rhs_T The type of the right-hand operand.
895
- *
896
489
  * @details
897
- * The `and_` struct template provides a type-safe mechanism for evaluating
898
- * the logical conjunction (AND) of two operands within the framework.
899
- *
900
- * This comparator supports a wide range of operand types, applying the
901
- * generic getter to ensure correct value extraction for both custom and
902
- * standard types. The result of the logical AND operation is stored in the
903
- * `value_` member for efficient access.
490
+ * Derived from `binary_op_`, this struct combines two sub-expressions
491
+ * with a logical AND operation. It enables composition of complex
492
+ * assertions by combining multiple conditions into a single logical
493
+ * whole, with reporting that shows the combined result and individual
494
+ * operand outcomes.
904
495
  *
905
- * The implementation is optimised for use in embedded environments and
906
- * supports both compile-time and run-time evaluation.
907
- *
908
- * All definitions are intended for internal use within the framework and
909
- * are implemented in the `include/micro-os-plus/micro-test-plus` folder to
910
- * maintain a structured and modular codebase.
496
+ * @tparam Lhs_T The type of the left-hand operand.
497
+ * @tparam Rhs_T The type of the right-hand operand.
911
498
  *
912
499
  * @headerfile micro-test-plus.h <micro-os-plus/micro-test-plus.h>
913
500
  */
@@ -919,46 +506,28 @@ namespace micro_os_plus::micro_test_plus
919
506
  *
920
507
  * @param lhs The left-hand operand.
921
508
  * @param rhs The right-hand operand.
922
- *
923
- * @details
924
- * Evaluates the logical conjunction of the provided operands and
925
- * passes the result to the `binary_op_` base class constructor.
926
509
  */
927
- constexpr and_ (const Lhs_T& lhs = {}, const Rhs_T& rhs = {})
928
- : binary_op_<Lhs_T, Rhs_T>{
929
- lhs, rhs, static_cast<bool> (lhs) and static_cast<bool> (rhs)
930
- }
931
- {
932
- }
510
+ constexpr and_ (const Lhs_T& lhs = {}, const Rhs_T& rhs = {});
933
511
  };
934
512
 
935
513
  // Deduction guide.
936
514
  template <typename Lhs_T, typename Rhs_T>
937
515
  and_ (const Lhs_T&, const Rhs_T&) -> and_<Lhs_T, Rhs_T>;
938
516
 
939
- // ------------------------------------------------------------------------
517
+ // ========================================================================
940
518
 
941
519
  /**
942
520
  * @brief Logical OR comparator struct template.
943
521
  *
944
- * @tparam Lhs_T The type of the left-hand operand.
945
- * @tparam Rhs_T The type of the right-hand operand.
946
- *
947
522
  * @details
948
- * The `or_` struct template provides a type-safe mechanism for evaluating
949
- * the logical disjunction (OR) of two operands within the framework.
950
- *
951
- * This comparator supports a wide range of operand types, applying the
952
- * generic getter to ensure correct value extraction for both custom and
953
- * standard types. The result of the logical OR operation is stored in the
954
- * `value_` member for efficient access.
955
- *
956
- * The implementation is optimised for use in embedded environments and
957
- * supports both compile-time and run-time evaluation.
523
+ * Derived from `binary_op_`, this struct combines two sub-expressions
524
+ * with a logical OR operation. It enables composition of complex
525
+ * assertions by combining multiple conditions into a single logical
526
+ * whole, with reporting that shows the combined result and individual
527
+ * operand outcomes.
958
528
  *
959
- * All definitions are intended for internal use within the framework and
960
- * are implemented in the `include/micro-os-plus/micro-test-plus` folder to
961
- * maintain a structured and modular codebase.
529
+ * @tparam Lhs_T The type of the left-hand operand.
530
+ * @tparam Rhs_T The type of the right-hand operand.
962
531
  *
963
532
  * @headerfile micro-test-plus.h <micro-os-plus/micro-test-plus.h>
964
533
  */
@@ -970,45 +539,26 @@ namespace micro_os_plus::micro_test_plus
970
539
  *
971
540
  * @param lhs The left-hand operand.
972
541
  * @param rhs The right-hand operand.
973
- *
974
- * @details
975
- * Evaluates the logical disjunction of the provided operands and
976
- * passes the result to the `binary_op_` base class constructor.
977
542
  */
978
- constexpr or_ (const Lhs_T& lhs = {}, const Rhs_T& rhs = {})
979
- : binary_op_<Lhs_T, Rhs_T>{
980
- lhs, rhs, static_cast<bool> (lhs) or static_cast<bool> (rhs)
981
- }
982
- {
983
- }
543
+ constexpr or_ (const Lhs_T& lhs = {}, const Rhs_T& rhs = {});
984
544
  };
985
545
 
986
546
  // Deduction guide.
987
547
  template <typename Lhs_T, typename Rhs_T>
988
548
  or_ (const Lhs_T&, const Rhs_T&) -> or_<Lhs_T, Rhs_T>;
989
549
 
990
- // ------------------------------------------------------------------------
550
+ // ========================================================================
991
551
 
992
552
  /**
993
553
  * @brief Logical NOT comparator struct template.
994
554
  *
995
- * @tparam T The type of the operand.
996
- *
997
555
  * @details
998
- * The `not_` struct template provides a type-safe mechanism for evaluating
999
- * the logical negation (NOT) of an operand within the framework.
556
+ * Derived from `unary_op_`, this struct negates a single sub-expression,
557
+ * enabling test writers to assert that a condition does not hold. The
558
+ * negation result is computed at construction time, ensuring consistent
559
+ * reporting throughout the assertion framework.
1000
560
  *
1001
- * This comparator supports a wide range of operand types, applying the
1002
- * generic getter to ensure correct value extraction for both custom and
1003
- * standard types. The result of the logical NOT operation is stored in the
1004
- * `value_` member for efficient access.
1005
- *
1006
- * The implementation is optimised for use in embedded environments and
1007
- * supports both compile-time and run-time evaluation.
1008
- *
1009
- * All definitions are intended for internal use within the framework and
1010
- * are implemented in the `include/micro-os-plus/micro-test-plus` folder to
1011
- * maintain a structured and modular codebase.
561
+ * @tparam T The type of the operand.
1012
562
  *
1013
563
  * @headerfile micro-test-plus.h <micro-os-plus/micro-test-plus.h>
1014
564
  */
@@ -1019,22 +569,15 @@ namespace micro_os_plus::micro_test_plus
1019
569
  * @brief Constructs a logical NOT comparator for the given operand.
1020
570
  *
1021
571
  * @param t The operand to be negated.
1022
- *
1023
- * @details
1024
- * Evaluates the logical negation of the provided operand and passes
1025
- * the result to the `unary_op_` base class constructor.
1026
572
  */
1027
- explicit constexpr not_ (const T& t = {})
1028
- : unary_op_<T>{ t, not static_cast<bool> (t) }
1029
- {
1030
- }
573
+ explicit constexpr not_ (const T& t = {});
1031
574
  };
1032
575
 
1033
576
  // Deduction guide.
1034
577
  template <typename T>
1035
578
  not_ (const T&) -> not_<T>;
1036
579
 
1037
- // ------------------------------------------------------------------------
580
+ // ========================================================================
1038
581
 
1039
582
  #if defined(__cpp_exceptions)
1040
583
 
@@ -1042,19 +585,12 @@ namespace micro_os_plus::micro_test_plus
1042
585
  * @brief Common base struct for callable-wrapping operators.
1043
586
  *
1044
587
  * @details
1045
- * The `callable_op_` struct provides the shared state and interface
1046
- * for operator types that invoke a callable and reduce the outcome to
1047
- * a single boolean result. It stores the result and exposes a
1048
- * conversion operator, which is common to `throws_` and `nothrow_`.
1049
- *
1050
- * Unlike `unary_op_` and `binary_op_`, no template parameter is
1051
- * needed because the callable itself is not retained after
1052
- * construction.
1053
- *
1054
- * All definitions are intended for internal use within the framework
1055
- * and are implemented in the
1056
- * `include/micro-os-plus/micro-test-plus` folder to maintain a
1057
- * structured and modular codebase.
588
+ * This base struct provides common functionality for operators that wrap
589
+ * callable invocations, particularly for exception-checking operations.
590
+ * Derived structs (such as `throws_` and `nothrow_`) use this base to
591
+ * store and manage the pre-computed boolean result of a callable
592
+ * invocation, enabling consistent reporting and composition of
593
+ * exception-checking assertions.
1058
594
  *
1059
595
  * @headerfile micro-test-plus.h <micro-os-plus/micro-test-plus.h>
1060
596
  */
@@ -1066,9 +602,7 @@ namespace micro_os_plus::micro_test_plus
1066
602
  *
1067
603
  * @param value The pre-computed boolean result of the invocation.
1068
604
  */
1069
- constexpr explicit callable_op_ (bool value) : value_{ value }
1070
- {
1071
- }
605
+ constexpr explicit callable_op_ (bool value);
1072
606
 
1073
607
  /**
1074
608
  * @brief Conversion operator to boolean.
@@ -1076,16 +610,9 @@ namespace micro_os_plus::micro_test_plus
1076
610
  * @par Parameters
1077
611
  * None.
1078
612
  * @return The result of the callable invocation.
1079
- *
1080
- * @details
1081
- * Returns the pre-computed boolean result stored by the derived
1082
- * operator's constructor.
1083
613
  */
1084
614
  [[nodiscard]] constexpr
1085
- operator bool () const
1086
- {
1087
- return value_;
1088
- }
615
+ operator bool () const;
1089
616
 
1090
617
  private:
1091
618
  /**
@@ -1094,32 +621,23 @@ namespace micro_os_plus::micro_test_plus
1094
621
  const bool value_{};
1095
622
  };
1096
623
 
1097
- // ------------------------------------------------------------------------
624
+ // ========================================================================
1098
625
 
1099
626
  /**
1100
627
  * @brief Operator struct template to check if an expression throws a
1101
628
  * specific exception.
1102
629
  *
630
+ * @details
631
+ * This specialisation checks whether invoking the given callable throws
632
+ * an exception of the specified type. The check is performed at
633
+ * construction time, with the result cached for reporting and
634
+ * composition. Use this when a test must verify that an operation raises
635
+ * an expected exception of a particular type.
636
+ *
1103
637
  * @tparam Callable_T The type of the callable object to be invoked.
1104
638
  * @tparam Exception_T The type of the exception to check for (defaults to
1105
639
  * `void` for any exception).
1106
640
  *
1107
- * @details
1108
- * The `throws_` struct template provides a type-safe mechanism for
1109
- * verifying whether a callable expression throws a specified exception
1110
- * type during its execution within the framework.
1111
- *
1112
- * This comparator is designed to support both custom and standard callable
1113
- * types. The result of the exception check is stored in the `value_`
1114
- * member for efficient access.
1115
- *
1116
- * The implementation is optimised for use in embedded environments and
1117
- * supports both compile-time and run-time evaluation.
1118
- *
1119
- * All definitions are intended for internal use within the framework and
1120
- * are implemented in the `include/micro-os-plus/micro-test-plus` folder to
1121
- * maintain a structured and modular codebase.
1122
- *
1123
641
  * @headerfile micro-test-plus.h <micro-os-plus/micro-test-plus.h>
1124
642
  */
1125
643
  template <class Callable_T, class Exception_T = void>
@@ -1130,56 +648,24 @@ namespace micro_os_plus::micro_test_plus
1130
648
  * callable.
1131
649
  *
1132
650
  * @param func The callable object to be invoked.
1133
- *
1134
- * @details
1135
- * Invokes the provided callable and determines whether it throws an
1136
- * exception of the specified type, then passes the result to the
1137
- * `callable_op_` base class constructor.
1138
651
  */
1139
- constexpr explicit throws_ (const Callable_T& func)
1140
- : callable_op_{ [&func]
1141
- {
1142
- try
1143
- {
1144
- func ();
1145
- }
1146
- catch (const Exception_T&)
1147
- {
1148
- return true;
1149
- }
1150
- catch (...)
1151
- {
1152
- return false;
1153
- }
1154
- return false;
1155
- }() }
1156
- {
1157
- }
652
+ constexpr explicit throws_ (const Callable_T& func);
1158
653
  };
1159
654
 
1160
- // ------------------------------------------------------------------------
655
+ // ========================================================================
1161
656
 
1162
657
  /**
1163
658
  * @brief Operator struct template to check if an expression throws any
1164
659
  * exception.
1165
660
  *
1166
- * @tparam Callable_T The type of the callable object to be invoked.
1167
- *
1168
661
  * @details
1169
- * The `throws_` struct template provides a type-safe mechanism for
1170
- * verifying whether a callable expression throws any exception during its
1171
- * execution within the framework.
1172
- *
1173
- * This comparator is designed to support both custom and standard callable
1174
- * types. The result of the exception check is stored in the `value_`
1175
- * member for efficient access.
662
+ * This partial specialisation checks whether invoking the given callable
663
+ * throws any exception, regardless of type. The check is performed at
664
+ * construction time, with the result cached for reporting and
665
+ * composition. Use this when a test must verify that an operation raises
666
+ * an exception without caring about the specific exception type.
1176
667
  *
1177
- * The implementation is optimised for use in embedded environments and
1178
- * supports both compile-time and run-time evaluation.
1179
- *
1180
- * All definitions are intended for internal use within the framework and
1181
- * are implemented in the `include/micro-os-plus/micro-test-plus` folder to
1182
- * maintain a structured and modular codebase.
668
+ * @tparam Callable_T The type of the callable object to be invoked.
1183
669
  *
1184
670
  * @headerfile micro-test-plus.h <micro-os-plus/micro-test-plus.h>
1185
671
  */
@@ -1190,53 +676,24 @@ namespace micro_os_plus::micro_test_plus
1190
676
  * @brief Constructs an exception checking operator for the given
1191
677
  * callable.
1192
678
  *
1193
- * @details
1194
- * Invokes the provided callable and determines whether it throws any
1195
- * exception, then passes the result to the `callable_op_` base
1196
- * class constructor.
1197
- *
1198
679
  * @param func The callable object to be invoked.
1199
680
  */
1200
- constexpr explicit throws_ (const Callable_T& func)
1201
- : callable_op_{ [&func]
1202
- {
1203
- try
1204
- {
1205
- func ();
1206
- }
1207
- catch (...)
1208
- {
1209
- return true;
1210
- }
1211
- return false;
1212
- }() }
1213
- {
1214
- }
681
+ constexpr explicit throws_ (const Callable_T& func);
1215
682
  };
1216
683
 
1217
- // ------------------------------------------------------------------------
684
+ // ========================================================================
1218
685
 
1219
686
  /**
1220
687
  * @brief Operator struct template to check if an expression does not throw
1221
688
  * any exception.
1222
689
  *
1223
- * @tparam Callable_T The type of the callable object to be invoked.
1224
- *
1225
690
  * @details
1226
- * The `nothrow_` struct template provides a type-safe mechanism for
1227
- * verifying whether a callable expression completes without throwing any
1228
- * exception during its execution within the framework.
691
+ * This struct checks whether invoking the given callable completes
692
+ * without throwing an exception. The check is performed at construction
693
+ * time, with the result cached for reporting and composition. Use this
694
+ * when a test must verify that an operation is exception-safe.
1229
695
  *
1230
- * This comparator is designed to support both custom and standard callable
1231
- * types. The result of the exception check is stored in the `value_`
1232
- * member for efficient access.
1233
- *
1234
- * The implementation is optimised for use in embedded environments and
1235
- * supports both compile-time and run-time evaluation.
1236
- *
1237
- * All definitions are intended for internal use within the framework and
1238
- * are implemented in the `include/micro-os-plus/micro-test-plus` folder to
1239
- * maintain a structured and modular codebase.
696
+ * @tparam Callable_T The type of the callable object to be invoked.
1240
697
  *
1241
698
  * @headerfile micro-test-plus.h <micro-os-plus/micro-test-plus.h>
1242
699
  */
@@ -1248,31 +705,30 @@ namespace micro_os_plus::micro_test_plus
1248
705
  * callable.
1249
706
  *
1250
707
  * @param func The callable object to be invoked.
1251
- *
1252
- * @details
1253
- * Invokes the provided callable and determines whether it completes
1254
- * without throwing any exception, then passes the result to the
1255
- * `callable_op_` base class constructor.
1256
708
  */
1257
- constexpr explicit nothrow_ (const Callable_T& func)
1258
- : callable_op_{ [&func]
1259
- {
1260
- try
1261
- {
1262
- func ();
1263
- }
1264
- catch (...)
1265
- {
1266
- return false;
1267
- }
1268
- return true;
1269
- }() }
1270
- {
1271
- }
709
+ constexpr explicit nothrow_ (const Callable_T& func);
1272
710
  };
1273
711
 
1274
712
  #endif
1275
713
 
714
+ // ========================================================================
715
+
716
+ /**
717
+ * @brief Appends the string representation of a numeric value to a
718
+ * buffer, using `std::to_chars` for allocation-free,
719
+ * locale-independent formatting.
720
+ *
721
+ * @tparam T The numeric type to format.
722
+ * @param buffer The string to append to.
723
+ * @param v The value to format.
724
+ * @par Returns
725
+ * Nothing.
726
+ */
727
+ template <class T>
728
+ requires std::is_arithmetic_v<T>
729
+ void
730
+ append_number_ (std::string& buffer, T v);
731
+
1276
732
  // ------------------------------------------------------------------------
1277
733
  } // namespace detail
1278
734
 
@@ -1287,6 +743,11 @@ namespace micro_os_plus::micro_test_plus
1287
743
 
1288
744
  #endif // __cplusplus
1289
745
 
746
+ // ============================================================================
747
+ // Templates & constexpr implementations.
748
+
749
+ #include "inlines/detail-inlines.h"
750
+
1290
751
  // ----------------------------------------------------------------------------
1291
752
 
1292
753
  #endif // MICRO_TEST_PLUS_DETAIL_H_