@micro-os-plus/micro-test-plus 4.0.0 → 4.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (51) hide show
  1. package/CHANGELOG.md +82 -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 +231 -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 +19 -67
  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
@@ -54,6 +54,10 @@
54
54
  #include <charconv>
55
55
  #include <cstdio>
56
56
 
57
+ #if defined(MICRO_OS_PLUS_TRACE)
58
+ #include <micro-os-plus/diag/trace.h>
59
+ #endif // MICRO_OS_PLUS_TRACE
60
+
57
61
  // ----------------------------------------------------------------------------
58
62
 
59
63
  #if defined(__GNUC__)
@@ -73,6 +77,18 @@ namespace micro_os_plus::micro_test_plus
73
77
 
74
78
  namespace detail
75
79
  {
80
+ // ========================================================================
81
+
82
+ /**
83
+ * @details
84
+ * Returns the result value stored in `value_`.
85
+ */
86
+ inline bool
87
+ deferred_reporter_base::value () const
88
+ {
89
+ return value_;
90
+ }
91
+
76
92
  // ------------------------------------------------------------------------
77
93
 
78
94
  /**
@@ -138,44 +154,23 @@ namespace micro_os_plus::micro_test_plus
138
154
  * contextual information for reporting purposes.
139
155
  */
140
156
  template <class Expr_T>
141
- deferred_reporter<Expr_T>::deferred_reporter (
157
+ deferred_reporter::deferred_reporter (
142
158
  const Expr_T& expr, bool abort,
143
- const reflection::source_location& location, subtest& subtest)
144
- : deferred_reporter_base{ static_cast<bool> (expr), location,
145
- subtest },
146
- expr_{ expr }
159
+ const reflection::source_location& location, subtest& subtest,
160
+ expression_formatter& expression)
161
+ : deferred_reporter_base{ static_cast<bool> (expr), location, subtest }
162
+
147
163
  {
148
164
  #if defined(MICRO_OS_PLUS_TRACE) \
149
165
  && defined(MICRO_OS_PLUS_TRACE_MICRO_TEST_PLUS_CONSTRUCTORS)
150
166
  trace::printf ("%s\n", __PRETTY_FUNCTION__);
151
167
  #endif // MICRO_OS_PLUS_TRACE_MICRO_TEST_PLUS_CONSTRUCTORS
152
168
  abort_ = abort;
153
- }
169
+ has_expression_ = type_traits::is_op<Expr_T>;
154
170
 
155
- /**
156
- * @details
157
- * The destructor finalises the deferred reporting process for a test
158
- * expression. If the evaluated expression is true, the reporter records a
159
- * successful outcome along with any accumulated message. If the expression
160
- * is false, the reporter records a failure, including the abort status,
161
- * message, and source location for comprehensive reporting.
162
- *
163
- * This mechanism ensures that all relevant information about the test
164
- * outcome is captured and reported accurately when the deferred reporter
165
- * goes out of scope.
166
- */
167
- template <class Expr_T>
168
- deferred_reporter<Expr_T>::~deferred_reporter ()
169
- {
170
- if (value_) [[likely]]
171
- {
172
- subtest_.reporter ().pass (expr_, deferred_output_, subtest_);
173
- }
174
- else
175
- {
176
- subtest_.reporter ().fail (expr_, abort_, deferred_output_,
177
- location_, subtest_);
178
- }
171
+ expression.clear ();
172
+
173
+ expression << expr;
179
174
  }
180
175
 
181
176
  // ------------------------------------------------------------------------