@micro-os-plus/micro-test-plus 3.3.1 → 4.0.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 (53) hide show
  1. package/CHANGELOG.md +330 -2
  2. package/CMakeLists.txt +79 -23
  3. package/README.md +1 -1
  4. package/config/xcdl-build.json +11 -4
  5. package/include/micro-os-plus/micro-test-plus/deferred-reporter.h +292 -0
  6. package/include/micro-os-plus/micro-test-plus/detail.h +462 -1076
  7. package/include/micro-os-plus/micro-test-plus/exceptions.h +126 -0
  8. package/include/micro-os-plus/micro-test-plus/function-comparators.h +10 -7
  9. package/include/micro-os-plus/micro-test-plus/inlines/{details-inlines.h → deferred-reporter-inlines.h} +49 -22
  10. package/include/micro-os-plus/micro-test-plus/inlines/function-comparators-inlines.h +67 -4
  11. package/include/micro-os-plus/micro-test-plus/inlines/literals-inlines.h +3 -6
  12. package/include/micro-os-plus/micro-test-plus/inlines/math-inlines.h +21 -15
  13. package/include/micro-os-plus/micro-test-plus/inlines/reflection-inlines.h +35 -17
  14. package/include/micro-os-plus/micro-test-plus/inlines/{test-reporter-inlines.h → reporter-inlines.h} +176 -106
  15. package/include/micro-os-plus/micro-test-plus/inlines/{test-suite-inlines.h → runner-inlines.h} +41 -43
  16. package/include/micro-os-plus/micro-test-plus/inlines/test-inlines.h +369 -0
  17. package/include/micro-os-plus/micro-test-plus/inlines/utility-inlines.h +126 -0
  18. package/include/micro-os-plus/micro-test-plus/literals.h +4 -3
  19. package/include/micro-os-plus/micro-test-plus/math.h +9 -6
  20. package/include/micro-os-plus/micro-test-plus/operators.h +38 -44
  21. package/include/micro-os-plus/micro-test-plus/reflection.h +15 -4
  22. package/include/micro-os-plus/micro-test-plus/{test-reporter-basic.h → reporter-human.h} +72 -72
  23. package/include/micro-os-plus/micro-test-plus/{test-reporter-tap.h → reporter-tap.h} +69 -69
  24. package/include/micro-os-plus/micro-test-plus/{test-reporter.h → reporter.h} +296 -200
  25. package/include/micro-os-plus/micro-test-plus/runner-totals.h +264 -0
  26. package/include/micro-os-plus/micro-test-plus/runner.h +453 -0
  27. package/include/micro-os-plus/micro-test-plus/test.h +1069 -0
  28. package/include/micro-os-plus/micro-test-plus/timings.h +366 -0
  29. package/include/micro-os-plus/micro-test-plus/type-traits.h +239 -545
  30. package/include/micro-os-plus/micro-test-plus/utility.h +135 -0
  31. package/include/micro-os-plus/micro-test-plus.h +25 -228
  32. package/meson.build +10 -6
  33. package/package.json +1 -1
  34. package/src/deferred-reporter.cpp +118 -0
  35. package/src/reflection.cpp +95 -0
  36. package/src/reporter-human.cpp +822 -0
  37. package/src/reporter-tap.cpp +782 -0
  38. package/src/reporter.cpp +676 -0
  39. package/src/runner-totals.cpp +95 -0
  40. package/src/runner.cpp +563 -0
  41. package/src/test.cpp +496 -0
  42. package/src/timings.cpp +209 -0
  43. package/src/utility.cpp +163 -0
  44. package/.cmake-format.yaml +0 -11
  45. package/include/micro-os-plus/micro-test-plus/inlines/micro-test-plus-inlines.h +0 -313
  46. package/include/micro-os-plus/micro-test-plus/test-runner.h +0 -281
  47. package/include/micro-os-plus/micro-test-plus/test-suite.h +0 -492
  48. package/src/micro-test-plus.cpp +0 -316
  49. package/src/test-reporter-basic.cpp +0 -466
  50. package/src/test-reporter-tap.cpp +0 -530
  51. package/src/test-reporter.cpp +0 -399
  52. package/src/test-runner.cpp +0 -311
  53. package/src/test-suite.cpp +0 -304
@@ -20,8 +20,8 @@
20
20
  * @brief C++ header file with declarations for the µTest++ TAP test reporter.
21
21
  *
22
22
  * @details
23
- * This header provides the declaration for `test_reporter_tap`, a concrete
24
- * implementation of the `test_reporter` abstract interface that formats test
23
+ * This header provides the declaration for `reporter_tap`, a concrete
24
+ * implementation of the `reporter` abstract interface that formats test
25
25
  * results according to the Test Anything Protocol (TAP).
26
26
  *
27
27
  * All definitions reside within the `micro_os_plus::micro_test_plus`
@@ -45,7 +45,7 @@
45
45
 
46
46
  // ----------------------------------------------------------------------------
47
47
 
48
- #include "test-reporter.h"
48
+ #include "reporter.h"
49
49
 
50
50
  // ----------------------------------------------------------------------------
51
51
 
@@ -57,21 +57,23 @@
57
57
  #endif
58
58
  #endif
59
59
 
60
+ // ============================================================================
61
+
60
62
  namespace micro_os_plus::micro_test_plus
61
63
  {
62
64
  // --------------------------------------------------------------------------
63
65
 
64
66
  /**
65
- * @brief TAP (Test Anything Protocol) implementation of `test_reporter`.
67
+ * @brief TAP (Test Anything Protocol) implementation of `reporter`.
66
68
  *
67
69
  * @details
68
- * `test_reporter_tap` provides a concrete implementation of the
69
- * `test_reporter` abstract interface that formats test results according to
70
+ * `reporter_tap` provides a concrete implementation of the
71
+ * `reporter` abstract interface that formats test results according to
70
72
  * the Test Anything Protocol (TAP). It accumulates output in an internal
71
73
  * string buffer and writes it to the standard output stream.
72
74
  *
73
75
  * Users who require custom output behaviour (e.g. redirecting to a serial
74
- * port on bare-metal targets) may derive a new class from `test_reporter`
76
+ * port on bare-metal targets) may derive a new class from `reporter`
75
77
  * and supply an instance via the `reporter` global pointer before calling
76
78
  * `initialize()`.
77
79
  *
@@ -81,160 +83,155 @@ namespace micro_os_plus::micro_test_plus
81
83
  *
82
84
  * @headerfile micro-test-plus.h <micro-os-plus/micro-test-plus.h>
83
85
  */
84
- class test_reporter_tap final : public test_reporter
86
+ class reporter_tap final : public reporter
85
87
  {
86
88
  public:
87
89
  /**
88
- * @brief Default constructor for the test_reporter_tap class.
90
+ * @brief Constructor for the reporter_tap class.
89
91
  *
90
92
  * @details
91
93
  * The rule of five is enforced to prevent accidental copying or moving.
94
+ *
95
+ * @param argvs Owning pointer to the command-line arguments vector;
96
+ * the reporter takes ownership via move.
92
97
  */
93
- test_reporter_tap () = default;
98
+ reporter_tap (std::unique_ptr<std::vector<std::string_view>> argvs);
94
99
 
95
100
  /**
96
101
  * @brief Deleted copy constructor to prevent copying.
97
102
  */
98
- test_reporter_tap (const test_reporter_tap&) = delete;
103
+ reporter_tap (const reporter_tap&) = delete;
99
104
 
100
105
  /**
101
106
  * @brief Deleted move constructor to prevent moving.
102
107
  */
103
- test_reporter_tap (test_reporter_tap&&) = delete;
108
+ reporter_tap (reporter_tap&&) = delete;
104
109
 
105
110
  /**
106
111
  * @brief Deleted copy assignment operator to prevent copying.
107
112
  */
108
- test_reporter_tap&
109
- operator= (const test_reporter_tap&)
110
- = delete;
113
+ reporter_tap&
114
+ operator= (const reporter_tap&) = delete;
111
115
 
112
116
  /**
113
117
  * @brief Deleted move assignment operator to prevent moving.
114
118
  */
115
- test_reporter_tap&
116
- operator= (test_reporter_tap&&)
117
- = delete;
119
+ reporter_tap&
120
+ operator= (reporter_tap&&) = delete;
118
121
 
119
122
  /**
120
- * @brief Destructor for the test_reporter_tap class.
123
+ * @brief Destructor for the reporter_tap class.
121
124
  */
122
- ~test_reporter_tap () override = default;
125
+ ~reporter_tap () override;
126
+
127
+ // ------------------------------------------------------------------------
123
128
 
124
129
  /**
125
- * @brief Inserts a line ending into the output buffer.
130
+ * @brief Output operator for the `indent_t` manipulator.
126
131
  *
127
- * @par Parameters
128
- * None.
129
- * @par Returns
130
- * Nothing.
132
+ * @param m The indentation manipulator produced by `indent(n)`.
133
+ * @return Reference to the current reporter instance.
131
134
  */
132
- void
133
- endline (void) override;
135
+ reporter_tap&
136
+ operator<< (indent_t m);
137
+
138
+ // Bring base class operator<< overloads into scope to prevent name hiding.
139
+ using reporter::operator<<;
140
+
141
+ // ------------------------------------------------------------------------
134
142
 
135
143
  /**
136
- * @brief Mark the beginning of a test case.
144
+ * @brief Mark the beginning of a test session.
137
145
  *
138
- * @param name The name of the test case.
146
+ * @param runner Reference to the test runner.
139
147
  * @par Returns
140
148
  * Nothing.
141
149
  */
142
150
  void
143
- begin_test_case (const char* name) override;
151
+ begin_session (runner& runner) override;
144
152
 
145
153
  /**
146
- * @brief Mark the end of a test case.
154
+ * @brief Mark the end of a test session.
147
155
  *
148
- * @param name The name of the test case.
156
+ * @param runner Reference to the test runner.
149
157
  * @par Returns
150
158
  * Nothing.
151
159
  */
152
160
  void
153
- end_test_case (const char* name) override;
161
+ end_session (runner& runner) override;
154
162
 
155
163
  /**
156
164
  * @brief Mark the beginning of a test suite.
157
165
  *
158
- * @param name The name of the test suite.
166
+ * @param suite Reference to the test suite.
159
167
  * @par Returns
160
168
  * Nothing.
161
169
  */
162
- void
163
- begin_test_suite (const char* name) override;
170
+ virtual void
171
+ begin_suite (suite& suite) override;
164
172
 
165
173
  /**
166
174
  * @brief Mark the end of a test suite.
167
175
  *
168
- * @param suite Reference to the test suite base.
176
+ * @param suite Reference to the test suite.
169
177
  * @par Returns
170
178
  * Nothing.
171
179
  */
172
- void
173
- end_test_suite (test_suite_base& suite) override;
180
+ virtual void
181
+ end_suite (suite& suite) override;
174
182
 
175
183
  /**
176
- * @brief Mark the beginning of a test.
184
+ * @brief Mark the beginning of a subtest.
177
185
  *
178
- * @param test_suites_count The number of test suites, or zero if unknown.
186
+ * @param subtest Reference to the subtest.
179
187
  * @par Returns
180
188
  * Nothing.
181
189
  */
182
- void
183
- begin_test (size_t test_suites_count) override;
190
+ virtual void
191
+ begin_subtest (subtest& subtest) override;
184
192
 
185
193
  /**
186
- * @brief Mark the end of a test.
194
+ * @brief Mark the end of a subtest.
187
195
  *
188
- * @param runner Reference to the test runner.
196
+ * @param subtest Reference to the subtest.
189
197
  * @par Returns
190
198
  * Nothing.
191
199
  */
192
- void
193
- end_test (test_runner& runner) override;
200
+ virtual void
201
+ end_subtest (subtest& subtest) override;
194
202
 
195
203
  /**
196
- * @brief Flush the current buffered content.
204
+ * @brief Returns the TAP comment prefix string `"# "`.
197
205
  *
198
206
  * @par Parameters
199
207
  * None.
200
- * @par Returns
201
- * Nothing.
208
+ * @return The string `"# "`, used to prefix comment lines in TAP
209
+ * output.
202
210
  */
203
- void
204
- flush (void) override;
205
-
206
- /**
207
- * @brief Output the current buffered content.
208
- *
209
- * @par Parameters
210
- * None.
211
- * @par Returns
212
- * Nothing.
213
- */
214
- void
215
- output (void) override;
211
+ virtual const char*
212
+ get_comment_prefix (void) override;
216
213
 
217
214
  protected:
218
215
  /**
219
216
  * @brief Outputs the prefix for a passing condition.
220
217
  *
221
218
  * @param message The message to display.
219
+ * @param subtest The subtest that owns this check.
222
220
  * @par Returns
223
221
  * Nothing.
224
222
  */
225
223
  void
226
- output_pass_prefix_ (std::string& message) override;
224
+ output_pass_prefix_ (std::string& message, subtest& subtest) override;
227
225
 
228
226
  /**
229
227
  * @brief Outputs the suffix for a passing condition.
230
228
  *
231
- * @par Parameters
232
- * None.
229
+ * @param subtest The subtest that owns this check.
233
230
  * @par Returns
234
231
  * Nothing.
235
232
  */
236
233
  void
237
- output_pass_suffix_ (void) override;
234
+ output_pass_suffix_ (subtest& subtest) override;
238
235
 
239
236
  /**
240
237
  * @brief Outputs the prefix for a failing condition.
@@ -243,24 +240,27 @@ namespace micro_os_plus::micro_test_plus
243
240
  * @param hasExpression Whether the failure is associated with an
244
241
  * expression.
245
242
  * @param location The source location of the failure.
243
+ * @param subtest The subtest that owns this check.
246
244
  * @par Returns
247
245
  * Nothing.
248
246
  */
249
247
  void
250
248
  output_fail_prefix_ (std::string& message, const bool hasExpression,
251
- const reflection::source_location& location) override;
249
+ const reflection::source_location& location,
250
+ subtest& subtest) override;
252
251
 
253
252
  /**
254
253
  * @brief Outputs the suffix for a failing condition.
255
254
  *
256
255
  * @param location The source location of the failure.
257
256
  * @param abort Whether to abort execution after failure.
257
+ * @param subtest The subtest that owns this check.
258
258
  * @par Returns
259
259
  * Nothing.
260
260
  */
261
261
  void
262
262
  output_fail_suffix_ (const reflection::source_location& location,
263
- bool abort) override;
263
+ bool abort, subtest& subtest) override;
264
264
  };
265
265
 
266
266
  // --------------------------------------------------------------------------