@micro-os-plus/micro-test-plus 3.1.1 → 3.2.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.
- package/CHANGELOG.md +347 -1
- package/CMakeLists.txt +9 -11
- package/README.md +12 -1226
- package/include/micro-os-plus/detail.h +69 -36
- package/include/micro-os-plus/inlines.h +50 -7
- package/include/micro-os-plus/literals.h +257 -29
- package/include/micro-os-plus/micro-test-plus.h +257 -68
- package/include/micro-os-plus/reflection.h +10 -5
- package/include/micro-os-plus/test-reporter-inlines.h +2 -2
- package/include/micro-os-plus/test-reporter.h +14 -4
- package/include/micro-os-plus/test-runner.h +3 -2
- package/include/micro-os-plus/test-suite.h +72 -6
- package/include/micro-os-plus/type-traits.h +54 -10
- package/meson.build +23 -17
- package/package.json +25 -535
- package/src/micro-test-plus.cpp +45 -0
- package/src/test-reporter.cpp +11 -1
- package/src/test-runner.cpp +11 -4
|
@@ -40,7 +40,6 @@
|
|
|
40
40
|
|
|
41
41
|
#if defined(__GNUC__)
|
|
42
42
|
#pragma GCC diagnostic push
|
|
43
|
-
|
|
44
43
|
#pragma GCC diagnostic ignored "-Wpadded"
|
|
45
44
|
#pragma GCC diagnostic ignored "-Waggregate-return"
|
|
46
45
|
#if defined(__clang__)
|
|
@@ -62,41 +61,81 @@ namespace micro_os_plus::micro_test_plus
|
|
|
62
61
|
// Public API.
|
|
63
62
|
|
|
64
63
|
/**
|
|
64
|
+
* @ingroup micro-test-plus-inits
|
|
65
65
|
* @brief Initialize the test framework.
|
|
66
|
+
* @param [in] argc The number of arguments.
|
|
67
|
+
* @param [in] argv Array of pointers to null terminated arguments.
|
|
68
|
+
* @param [in] name The name of the default test suite.
|
|
69
|
+
* @par Returns
|
|
70
|
+
* Nothing.
|
|
66
71
|
*/
|
|
67
72
|
void
|
|
68
73
|
initialize (int argc, char* argv[], const char* name = "Main");
|
|
69
74
|
|
|
70
75
|
/**
|
|
71
|
-
* @
|
|
76
|
+
* @ingroup micro-test-plus-inits
|
|
77
|
+
* @brief Complete the test and return the exit code.
|
|
78
|
+
* @par Parameters
|
|
79
|
+
* None.
|
|
80
|
+
* @return 0 for success, 1 for failure.
|
|
72
81
|
*/
|
|
73
|
-
|
|
74
|
-
void
|
|
75
|
-
test_case (const char* name, Callable_T&& func, Args_T&&... arguments);
|
|
82
|
+
[[nodiscard]] int
|
|
83
|
+
exit_code (void);
|
|
76
84
|
|
|
77
85
|
/**
|
|
78
|
-
* @
|
|
79
|
-
* and
|
|
86
|
+
* @ingroup micro-test-plus-test-case
|
|
87
|
+
* @brief Define and execute a test case.
|
|
88
|
+
* @tparam Callable_T The type of an object that can be called.
|
|
89
|
+
* @tparam Args_T The type of the callable arguments.
|
|
90
|
+
* @param [in] name The test case name or description.
|
|
91
|
+
* A short string used in the report.
|
|
92
|
+
* @param [in] callable A generic callable object,
|
|
93
|
+
* invoked to perform the test. Usually a lambda.
|
|
94
|
+
* @param [in] arguments A possibly empty list of arguments to be
|
|
95
|
+
* passed to the callable.
|
|
96
|
+
* @par Returns
|
|
97
|
+
* Nothing.
|
|
80
98
|
*/
|
|
81
|
-
|
|
82
|
-
|
|
99
|
+
template <typename Callable_T, typename... Args_T>
|
|
100
|
+
void
|
|
101
|
+
test_case (const char* name, Callable_T&& callable, Args_T&&... arguments);
|
|
83
102
|
|
|
84
103
|
/**
|
|
85
|
-
* @
|
|
86
|
-
*
|
|
87
|
-
*
|
|
88
|
-
*
|
|
89
|
-
*
|
|
104
|
+
* @ingroup micro-test-plus-expectations
|
|
105
|
+
* @brief Evaluate a generic condition and report the results.
|
|
106
|
+
* @tparam Expr_T The type of the custom expression.
|
|
107
|
+
* @param [in] expr Logical expression to evaluate.
|
|
108
|
+
* @param [in] sl Optional source location, by default the current line.
|
|
109
|
+
* @return An output stream to write optional messages.
|
|
90
110
|
*
|
|
91
|
-
*
|
|
111
|
+
* @details
|
|
112
|
+
* The expression can be any logical expression, but, in order to
|
|
113
|
+
* allow the framework to help identify the reason why the check failed
|
|
114
|
+
* (by displaying the actual vs. the expected values), the expression
|
|
115
|
+
* should use the provided `eq()`, `ne()`, `lt()`, `le()`, `gt()`, `ge()`
|
|
116
|
+
* comparators, or, if the custom operators namespace is included,
|
|
117
|
+
* to use the custom type operands.
|
|
118
|
+
*
|
|
119
|
+
* The function template can be used only for expressions that evaluate to
|
|
92
120
|
* a boolean or use custom comparators/operators derived from the
|
|
93
|
-
* local `op` type.
|
|
121
|
+
* local `detail::op` type.
|
|
122
|
+
*
|
|
123
|
+
* For generic checks performed with standard C/C++
|
|
124
|
+
*`if` statements outside the `expect()` logical expression
|
|
125
|
+
* (like complex `try`/`catch` statements),
|
|
126
|
+
* the results can be reported with `expect(true)` or `expect(false)`.
|
|
127
|
+
*
|
|
128
|
+
* @par Example
|
|
129
|
+
* ```cpp
|
|
130
|
+
* namespace mt = micro_os_plus::micro_test_plus;
|
|
131
|
+
*
|
|
132
|
+
* mt::expect (compute_answer () == 42) << "answer is 42";
|
|
133
|
+
* ```
|
|
94
134
|
*/
|
|
95
|
-
template <
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
Expr_T> or type_traits::is_convertible_v<Expr_T, bool>> = 0>
|
|
135
|
+
template <class Expr_T, type_traits::requires_t<
|
|
136
|
+
type_traits::is_op_v<Expr_T>
|
|
137
|
+
or type_traits::is_convertible_v<Expr_T, bool>>
|
|
138
|
+
= 0>
|
|
100
139
|
constexpr auto
|
|
101
140
|
expect (const Expr_T& expr, const reflection::source_location& sl
|
|
102
141
|
= reflection::source_location::current ())
|
|
@@ -105,17 +144,28 @@ namespace micro_os_plus::micro_test_plus
|
|
|
105
144
|
}
|
|
106
145
|
|
|
107
146
|
/**
|
|
147
|
+
* @ingroup micro-test-plus-assumptions
|
|
108
148
|
* @brief Check a condition and, if false, abort.
|
|
149
|
+
* @tparam Expr_T The type of the custom expression.
|
|
150
|
+
* @param [in] expr Logical expression to evaluate.
|
|
151
|
+
* @param [in] sl Optional source location, by default the current line.
|
|
152
|
+
* @return An output stream to write optional messages.
|
|
109
153
|
*
|
|
110
154
|
* The template is usable only for expressions that evaluate to
|
|
111
155
|
* a boolean or use custom comparators/operators derived from the
|
|
112
|
-
* local `op` type.
|
|
156
|
+
* local `detail::op` type.
|
|
157
|
+
*
|
|
158
|
+
* @par Example
|
|
159
|
+
* ```cpp
|
|
160
|
+
* namespace mt = micro_os_plus::micro_test_plus;
|
|
161
|
+
*
|
|
162
|
+
* mt::assume (compute_answer () == 42) << "answer is 42";
|
|
163
|
+
* ```
|
|
113
164
|
*/
|
|
114
|
-
template <
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
Expr_T> or type_traits::is_convertible_v<Expr_T, bool>> = 0>
|
|
165
|
+
template <class Expr_T, type_traits::requires_t<
|
|
166
|
+
type_traits::is_op_v<Expr_T>
|
|
167
|
+
or type_traits::is_convertible_v<Expr_T, bool>>
|
|
168
|
+
= 0>
|
|
119
169
|
constexpr auto
|
|
120
170
|
assume (const Expr_T& expr, const reflection::source_location& sl
|
|
121
171
|
= reflection::source_location::current ())
|
|
@@ -127,7 +177,12 @@ namespace micro_os_plus::micro_test_plus
|
|
|
127
177
|
|
|
128
178
|
#if defined(__cpp_exceptions)
|
|
129
179
|
/**
|
|
180
|
+
* @ingroup micro-test-plus-exceptions
|
|
130
181
|
* @brief Check if a callable throws a specific exception.
|
|
182
|
+
* @tparam Exception_T Type of the exception.
|
|
183
|
+
* @tparam Callable_T The type of an object that can be called.
|
|
184
|
+
* @param [in] func Function to check.
|
|
185
|
+
* @return An output stream to write optional messages.
|
|
131
186
|
*/
|
|
132
187
|
template <class Exception_T, class Callable_T>
|
|
133
188
|
[[nodiscard]] constexpr auto
|
|
@@ -137,7 +192,11 @@ namespace micro_os_plus::micro_test_plus
|
|
|
137
192
|
}
|
|
138
193
|
|
|
139
194
|
/**
|
|
195
|
+
* @ingroup micro-test-plus-exceptions
|
|
140
196
|
* @brief Check if a callable throws an exception (any exception).
|
|
197
|
+
* @tparam Callable_T The type of an object that can be called.
|
|
198
|
+
* @param [in] func Function to check.
|
|
199
|
+
* @return An output stream to write optional messages.
|
|
141
200
|
*/
|
|
142
201
|
template <class Callable_T>
|
|
143
202
|
[[nodiscard]] constexpr auto
|
|
@@ -147,7 +206,11 @@ namespace micro_os_plus::micro_test_plus
|
|
|
147
206
|
}
|
|
148
207
|
|
|
149
208
|
/**
|
|
209
|
+
* @ingroup micro-test-plus-exceptions
|
|
150
210
|
* @brief Check if a callable doesn't throw an exception.
|
|
211
|
+
* @tparam Callable_T The type of an object that can be called.
|
|
212
|
+
* @param [in] func Function to check.
|
|
213
|
+
* @return An output stream to write optional messages.
|
|
151
214
|
*/
|
|
152
215
|
template <class Callable_T>
|
|
153
216
|
[[nodiscard]] constexpr auto
|
|
@@ -160,8 +223,14 @@ namespace micro_os_plus::micro_test_plus
|
|
|
160
223
|
// --------------------------------------------------------------------------
|
|
161
224
|
|
|
162
225
|
/**
|
|
226
|
+
* @ingroup micro-test-plus-function-comparators
|
|
163
227
|
* @brief Generic equality comparator. Matches any
|
|
164
228
|
* non-pointer type.
|
|
229
|
+
* @tparam Lhs_T Type of the left hand side operand.
|
|
230
|
+
* @tparam Rhs_T Type of the right hand side operand.
|
|
231
|
+
* @param [in] lhs Left hand side operand.
|
|
232
|
+
* @param [in] rhs Right hand side operand.
|
|
233
|
+
* @return True if the operands are equal.
|
|
165
234
|
*/
|
|
166
235
|
template <class Lhs_T, class Rhs_T>
|
|
167
236
|
[[nodiscard]] constexpr auto
|
|
@@ -171,8 +240,14 @@ namespace micro_os_plus::micro_test_plus
|
|
|
171
240
|
}
|
|
172
241
|
|
|
173
242
|
/**
|
|
243
|
+
* @ingroup micro-test-plus-function-comparators
|
|
174
244
|
* @brief Pointer equality comparator. Matches pointers
|
|
175
245
|
* to any types.
|
|
246
|
+
* @tparam Lhs_T Type of the left hand side operand.
|
|
247
|
+
* @tparam Rhs_T Type of the right hand side operand.
|
|
248
|
+
* @param [in] lhs Left hand side operand.
|
|
249
|
+
* @param [in] rhs Right hand side operand.
|
|
250
|
+
* @return True if the pointers are equal.
|
|
176
251
|
*/
|
|
177
252
|
template <class Lhs_T, class Rhs_T>
|
|
178
253
|
[[nodiscard]] constexpr auto
|
|
@@ -182,7 +257,13 @@ namespace micro_os_plus::micro_test_plus
|
|
|
182
257
|
}
|
|
183
258
|
|
|
184
259
|
/**
|
|
260
|
+
* @ingroup micro-test-plus-function-comparators
|
|
185
261
|
* @brief Generic non-equality comparator.
|
|
262
|
+
* @tparam Lhs_T Type of the left hand side operand.
|
|
263
|
+
* @tparam Rhs_T Type of the right hand side operand.
|
|
264
|
+
* @param [in] lhs Left hand side operand.
|
|
265
|
+
* @param [in] rhs Right hand side operand.
|
|
266
|
+
* @return True if the operands are not equal.
|
|
186
267
|
*/
|
|
187
268
|
template <class Lhs_T, class Rhs_T>
|
|
188
269
|
[[nodiscard]] constexpr auto
|
|
@@ -192,7 +273,13 @@ namespace micro_os_plus::micro_test_plus
|
|
|
192
273
|
}
|
|
193
274
|
|
|
194
275
|
/**
|
|
276
|
+
* @ingroup micro-test-plus-function-comparators
|
|
195
277
|
* @brief Pointer non-equality comparator.
|
|
278
|
+
* @tparam Lhs_T Type of the left hand side operand.
|
|
279
|
+
* @tparam Rhs_T Type of the right hand side operand.
|
|
280
|
+
* @param [in] lhs Left hand side operand.
|
|
281
|
+
* @param [in] rhs Right hand side operand.
|
|
282
|
+
* @return True if the pointers are not equal.
|
|
196
283
|
*/
|
|
197
284
|
template <class Lhs_T, class Rhs_T>
|
|
198
285
|
[[nodiscard]] constexpr auto
|
|
@@ -202,7 +289,13 @@ namespace micro_os_plus::micro_test_plus
|
|
|
202
289
|
}
|
|
203
290
|
|
|
204
291
|
/**
|
|
292
|
+
* @ingroup micro-test-plus-function-comparators
|
|
205
293
|
* @brief Generic greater than comparator.
|
|
294
|
+
* @tparam Lhs_T Type of the left hand side operand.
|
|
295
|
+
* @tparam Rhs_T Type of the right hand side operand.
|
|
296
|
+
* @param [in] lhs Left hand side operand.
|
|
297
|
+
* @param [in] rhs Right hand side operand.
|
|
298
|
+
* @return True if lhs > rhs.
|
|
206
299
|
*/
|
|
207
300
|
template <class Lhs_T, class Rhs_T>
|
|
208
301
|
[[nodiscard]] constexpr auto
|
|
@@ -212,7 +305,13 @@ namespace micro_os_plus::micro_test_plus
|
|
|
212
305
|
}
|
|
213
306
|
|
|
214
307
|
/**
|
|
308
|
+
* @ingroup micro-test-plus-function-comparators
|
|
215
309
|
* @brief Pointer greater than comparator.
|
|
310
|
+
* @tparam Lhs_T Type of the left hand side operand.
|
|
311
|
+
* @tparam Rhs_T Type of the right hand side operand.
|
|
312
|
+
* @param [in] lhs Left hand side operand.
|
|
313
|
+
* @param [in] rhs Right hand side operand.
|
|
314
|
+
* @return True if the lhs pointer > rhs pointer.
|
|
216
315
|
*/
|
|
217
316
|
template <class Lhs_T, class Rhs_T>
|
|
218
317
|
[[nodiscard]] constexpr auto
|
|
@@ -222,7 +321,13 @@ namespace micro_os_plus::micro_test_plus
|
|
|
222
321
|
}
|
|
223
322
|
|
|
224
323
|
/**
|
|
324
|
+
* @ingroup micro-test-plus-function-comparators
|
|
225
325
|
* @brief Generic greater than or equal comparator.
|
|
326
|
+
* @tparam Lhs_T Type of the left hand side operand.
|
|
327
|
+
* @tparam Rhs_T Type of the right hand side operand.
|
|
328
|
+
* @param [in] lhs Left hand side operand.
|
|
329
|
+
* @param [in] rhs Right hand side operand.
|
|
330
|
+
* @return True if lhs >= rhs.
|
|
226
331
|
*/
|
|
227
332
|
template <class Lhs_T, class Rhs_T>
|
|
228
333
|
[[nodiscard]] constexpr auto
|
|
@@ -232,7 +337,13 @@ namespace micro_os_plus::micro_test_plus
|
|
|
232
337
|
}
|
|
233
338
|
|
|
234
339
|
/**
|
|
340
|
+
* @ingroup micro-test-plus-function-comparators
|
|
235
341
|
* @brief Pointer greater than or equal comparator.
|
|
342
|
+
* @tparam Lhs_T Type of the left hand side operand.
|
|
343
|
+
* @tparam Rhs_T Type of the right hand side operand.
|
|
344
|
+
* @param [in] lhs Left hand side operand.
|
|
345
|
+
* @param [in] rhs Right hand side operand.
|
|
346
|
+
* @return True if the lhs pointer >= rhs pointer.
|
|
236
347
|
*/
|
|
237
348
|
template <class Lhs_T, class Rhs_T>
|
|
238
349
|
[[nodiscard]] constexpr auto
|
|
@@ -242,7 +353,13 @@ namespace micro_os_plus::micro_test_plus
|
|
|
242
353
|
}
|
|
243
354
|
|
|
244
355
|
/**
|
|
356
|
+
* @ingroup micro-test-plus-function-comparators
|
|
245
357
|
* @brief Generic less than comparator.
|
|
358
|
+
* @tparam Lhs_T Type of the left hand side operand.
|
|
359
|
+
* @tparam Rhs_T Type of the right hand side operand.
|
|
360
|
+
* @param [in] lhs Left hand side operand.
|
|
361
|
+
* @param [in] rhs Right hand side operand.
|
|
362
|
+
* @return True if lhs < rhs.
|
|
246
363
|
*/
|
|
247
364
|
template <class Lhs_T, class Rhs_T>
|
|
248
365
|
[[nodiscard]] constexpr auto
|
|
@@ -252,7 +369,13 @@ namespace micro_os_plus::micro_test_plus
|
|
|
252
369
|
}
|
|
253
370
|
|
|
254
371
|
/**
|
|
372
|
+
* @ingroup micro-test-plus-function-comparators
|
|
255
373
|
* @brief Generic less than comparator.
|
|
374
|
+
* @tparam Lhs_T Type of the left hand side operand.
|
|
375
|
+
* @tparam Rhs_T Type of the right hand side operand.
|
|
376
|
+
* @param [in] lhs Left hand side operand.
|
|
377
|
+
* @param [in] rhs Right hand side operand.
|
|
378
|
+
* @return True if the lhs pointer < rhs pointer.
|
|
256
379
|
*/
|
|
257
380
|
template <class Lhs_T, class Rhs_T>
|
|
258
381
|
[[nodiscard]] constexpr auto
|
|
@@ -262,7 +385,13 @@ namespace micro_os_plus::micro_test_plus
|
|
|
262
385
|
}
|
|
263
386
|
|
|
264
387
|
/**
|
|
388
|
+
* @ingroup micro-test-plus-function-comparators
|
|
265
389
|
* @brief Generic less than or equal comparator.
|
|
390
|
+
* @tparam Lhs_T Type of the left hand side operand.
|
|
391
|
+
* @tparam Rhs_T Type of the right hand side operand.
|
|
392
|
+
* @param [in] lhs Left hand side operand.
|
|
393
|
+
* @param [in] rhs Right hand side operand.
|
|
394
|
+
* @return True if lhs <= rhs.
|
|
266
395
|
*/
|
|
267
396
|
template <class Lhs_T, class Rhs_T>
|
|
268
397
|
[[nodiscard]] constexpr auto
|
|
@@ -272,7 +401,13 @@ namespace micro_os_plus::micro_test_plus
|
|
|
272
401
|
}
|
|
273
402
|
|
|
274
403
|
/**
|
|
404
|
+
* @ingroup micro-test-plus-function-comparators
|
|
275
405
|
* @brief Generic less than or equal comparator.
|
|
406
|
+
* @tparam Lhs_T Type of the left hand side operand.
|
|
407
|
+
* @tparam Rhs_T Type of the right hand side operand.
|
|
408
|
+
* @param [in] lhs Left hand side operand.
|
|
409
|
+
* @param [in] rhs Right hand side operand.
|
|
410
|
+
* @return True if the lhs pointer <= rhs pointer.
|
|
276
411
|
*/
|
|
277
412
|
template <class Lhs_T, class Rhs_T>
|
|
278
413
|
[[nodiscard]] constexpr auto
|
|
@@ -282,7 +417,14 @@ namespace micro_os_plus::micro_test_plus
|
|
|
282
417
|
}
|
|
283
418
|
|
|
284
419
|
/**
|
|
285
|
-
* @
|
|
420
|
+
* @ingroup micro-test-plus-logical-functions
|
|
421
|
+
* @brief Generic logical **not**.
|
|
422
|
+
* @tparam Expr_T Type of the operand.
|
|
423
|
+
* @param [in] expr Logical expression.
|
|
424
|
+
* @return True if the operand is false.
|
|
425
|
+
*
|
|
426
|
+
* @note
|
|
427
|
+
* The underscore is intentional,
|
|
286
428
|
* to differentiate from the standard operator.
|
|
287
429
|
*/
|
|
288
430
|
template <class Expr_T>
|
|
@@ -293,7 +435,16 @@ namespace micro_os_plus::micro_test_plus
|
|
|
293
435
|
}
|
|
294
436
|
|
|
295
437
|
/**
|
|
296
|
-
* @
|
|
438
|
+
* @ingroup micro-test-plus-logical-functions
|
|
439
|
+
* @brief Generic logical **and**.
|
|
440
|
+
* @tparam Lhs_T Type of the left hand side operand.
|
|
441
|
+
* @tparam Rhs_T Type of the right hand side operand.
|
|
442
|
+
* @param [in] lhs Left hand side operand.
|
|
443
|
+
* @param [in] rhs Right hand side operand.
|
|
444
|
+
* @return True if both operand expressions are true.
|
|
445
|
+
*
|
|
446
|
+
* @note
|
|
447
|
+
* The underscore is intentional,
|
|
297
448
|
* to differentiate from the standard operator.
|
|
298
449
|
*/
|
|
299
450
|
template <class Lhs_T, class Rhs_T>
|
|
@@ -304,7 +455,16 @@ namespace micro_os_plus::micro_test_plus
|
|
|
304
455
|
}
|
|
305
456
|
|
|
306
457
|
/**
|
|
307
|
-
* @
|
|
458
|
+
* @ingroup micro-test-plus-logical-functions
|
|
459
|
+
* @brief Generic logical **or**.
|
|
460
|
+
* @tparam Lhs_T Type of the left hand side operand.
|
|
461
|
+
* @tparam Rhs_T Type of the right hand side operand.
|
|
462
|
+
* @param [in] lhs Left hand side operand.
|
|
463
|
+
* @param [in] rhs Right hand side operand.
|
|
464
|
+
* @return True if at least one of the operand expressions is true.
|
|
465
|
+
*
|
|
466
|
+
* @note
|
|
467
|
+
* The underscore is intentional,
|
|
308
468
|
* to differentiate from the standard operator.
|
|
309
469
|
*/
|
|
310
470
|
template <class Lhs_T, class Rhs_T>
|
|
@@ -340,7 +500,8 @@ namespace micro_os_plus::micro_test_plus
|
|
|
340
500
|
namespace operators
|
|
341
501
|
{
|
|
342
502
|
/**
|
|
343
|
-
* @
|
|
503
|
+
* @ingroup micro-test-plus-string-operators
|
|
504
|
+
* @brief Equality operator for `string_view` objects.
|
|
344
505
|
*/
|
|
345
506
|
[[nodiscard]] constexpr auto
|
|
346
507
|
operator== (std::string_view lhs, std::string_view rhs)
|
|
@@ -349,7 +510,8 @@ namespace micro_os_plus::micro_test_plus
|
|
|
349
510
|
}
|
|
350
511
|
|
|
351
512
|
/**
|
|
352
|
-
* @
|
|
513
|
+
* @ingroup micro-test-plus-string-operators
|
|
514
|
+
* @brief Non-equality operator for `string_view` objects.
|
|
353
515
|
*/
|
|
354
516
|
[[nodiscard]] constexpr auto
|
|
355
517
|
operator!= (std::string_view lhs, std::string_view rhs)
|
|
@@ -358,6 +520,7 @@ namespace micro_os_plus::micro_test_plus
|
|
|
358
520
|
}
|
|
359
521
|
|
|
360
522
|
/**
|
|
523
|
+
* @ingroup micro-test-plus-container-operators
|
|
361
524
|
* @brief Equality operator for containers.
|
|
362
525
|
*/
|
|
363
526
|
template <class T,
|
|
@@ -369,6 +532,7 @@ namespace micro_os_plus::micro_test_plus
|
|
|
369
532
|
}
|
|
370
533
|
|
|
371
534
|
/**
|
|
535
|
+
* @ingroup micro-test-plus-container-operators
|
|
372
536
|
* @brief Non-equality operator for containers.
|
|
373
537
|
*/
|
|
374
538
|
template <class T,
|
|
@@ -380,13 +544,14 @@ namespace micro_os_plus::micro_test_plus
|
|
|
380
544
|
}
|
|
381
545
|
|
|
382
546
|
/**
|
|
547
|
+
* @ingroup micro-test-plus-operators
|
|
383
548
|
* @brief Equality operator. It matches only if at least one
|
|
384
549
|
* operand is of local type (derived from local `op`).
|
|
385
550
|
*/
|
|
386
|
-
template <
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
551
|
+
template <class Lhs_T, class Rhs_T,
|
|
552
|
+
type_traits::requires_t<type_traits::is_op_v<Lhs_T>
|
|
553
|
+
or type_traits::is_op_v<Rhs_T>>
|
|
554
|
+
= 0>
|
|
390
555
|
[[nodiscard]] constexpr auto
|
|
391
556
|
operator== (const Lhs_T& lhs, const Rhs_T& rhs)
|
|
392
557
|
{
|
|
@@ -394,13 +559,14 @@ namespace micro_os_plus::micro_test_plus
|
|
|
394
559
|
}
|
|
395
560
|
|
|
396
561
|
/**
|
|
562
|
+
* @ingroup micro-test-plus-operators
|
|
397
563
|
* @brief Non-equality operator. It matches only if at least one
|
|
398
564
|
* operand is of local type (derived from local `op`).
|
|
399
565
|
*/
|
|
400
|
-
template <
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
566
|
+
template <class Lhs_T, class Rhs_T,
|
|
567
|
+
type_traits::requires_t<type_traits::is_op_v<Lhs_T>
|
|
568
|
+
or type_traits::is_op_v<Rhs_T>>
|
|
569
|
+
= 0>
|
|
404
570
|
[[nodiscard]] constexpr auto
|
|
405
571
|
operator!= (const Lhs_T& lhs, const Rhs_T& rhs)
|
|
406
572
|
{
|
|
@@ -408,13 +574,14 @@ namespace micro_os_plus::micro_test_plus
|
|
|
408
574
|
}
|
|
409
575
|
|
|
410
576
|
/**
|
|
577
|
+
* @ingroup micro-test-plus-operators
|
|
411
578
|
* @brief Greater than operator. It matches only if at least one
|
|
412
579
|
* operand is of local type (derived from local `op`).
|
|
413
580
|
*/
|
|
414
|
-
template <
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
581
|
+
template <class Lhs_T, class Rhs_T,
|
|
582
|
+
type_traits::requires_t<type_traits::is_op_v<Lhs_T>
|
|
583
|
+
or type_traits::is_op_v<Rhs_T>>
|
|
584
|
+
= 0>
|
|
418
585
|
[[nodiscard]] constexpr auto
|
|
419
586
|
operator> (const Lhs_T& lhs, const Rhs_T& rhs)
|
|
420
587
|
{
|
|
@@ -422,13 +589,14 @@ namespace micro_os_plus::micro_test_plus
|
|
|
422
589
|
}
|
|
423
590
|
|
|
424
591
|
/**
|
|
592
|
+
* @ingroup micro-test-plus-operators
|
|
425
593
|
* @brief Greater than or equal operator. It matches only if at least one
|
|
426
594
|
* operand is of local type (derived from local `op`).
|
|
427
595
|
*/
|
|
428
|
-
template <
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
596
|
+
template <class Lhs_T, class Rhs_T,
|
|
597
|
+
type_traits::requires_t<type_traits::is_op_v<Lhs_T>
|
|
598
|
+
or type_traits::is_op_v<Rhs_T>>
|
|
599
|
+
= 0>
|
|
432
600
|
[[nodiscard]] constexpr auto
|
|
433
601
|
operator>= (const Lhs_T& lhs, const Rhs_T& rhs)
|
|
434
602
|
{
|
|
@@ -436,13 +604,14 @@ namespace micro_os_plus::micro_test_plus
|
|
|
436
604
|
}
|
|
437
605
|
|
|
438
606
|
/**
|
|
607
|
+
* @ingroup micro-test-plus-operators
|
|
439
608
|
* @brief Less than operator. It matches only if at least one
|
|
440
609
|
* operand is of local type (derived from local `op`).
|
|
441
610
|
*/
|
|
442
|
-
template <
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
611
|
+
template <class Lhs_T, class Rhs_T,
|
|
612
|
+
type_traits::requires_t<type_traits::is_op_v<Lhs_T>
|
|
613
|
+
or type_traits::is_op_v<Rhs_T>>
|
|
614
|
+
= 0>
|
|
446
615
|
[[nodiscard]] constexpr auto
|
|
447
616
|
operator< (const Lhs_T& lhs, const Rhs_T& rhs)
|
|
448
617
|
{
|
|
@@ -450,13 +619,14 @@ namespace micro_os_plus::micro_test_plus
|
|
|
450
619
|
}
|
|
451
620
|
|
|
452
621
|
/**
|
|
622
|
+
* @ingroup micro-test-plus-operators
|
|
453
623
|
* @brief Less than or equal operator. It matches only if at least one
|
|
454
624
|
* operand is of local type (derived from local `op`).
|
|
455
625
|
*/
|
|
456
|
-
template <
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
626
|
+
template <class Lhs_T, class Rhs_T,
|
|
627
|
+
type_traits::requires_t<type_traits::is_op_v<Lhs_T>
|
|
628
|
+
or type_traits::is_op_v<Rhs_T>>
|
|
629
|
+
= 0>
|
|
460
630
|
[[nodiscard]] constexpr auto
|
|
461
631
|
operator<= (const Lhs_T& lhs, const Rhs_T& rhs)
|
|
462
632
|
{
|
|
@@ -464,13 +634,14 @@ namespace micro_os_plus::micro_test_plus
|
|
|
464
634
|
}
|
|
465
635
|
|
|
466
636
|
/**
|
|
467
|
-
* @
|
|
637
|
+
* @ingroup micro-test-plus-operators
|
|
638
|
+
* @brief Logical `&&` (and) operator. It matches only if at least one
|
|
468
639
|
* operand is of local type (derived from local `op`).
|
|
469
640
|
*/
|
|
470
|
-
template <
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
641
|
+
template <class Lhs_T, class Rhs_T,
|
|
642
|
+
type_traits::requires_t<type_traits::is_op_v<Lhs_T>
|
|
643
|
+
or type_traits::is_op_v<Rhs_T>>
|
|
644
|
+
= 0>
|
|
474
645
|
[[nodiscard]] constexpr auto
|
|
475
646
|
operator and (const Lhs_T& lhs, const Rhs_T& rhs)
|
|
476
647
|
{
|
|
@@ -478,13 +649,14 @@ namespace micro_os_plus::micro_test_plus
|
|
|
478
649
|
}
|
|
479
650
|
|
|
480
651
|
/**
|
|
481
|
-
* @
|
|
652
|
+
* @ingroup micro-test-plus-operators
|
|
653
|
+
* @brief Logical `||` (or) operator. It matches only if at least one
|
|
482
654
|
* operand is of local type (derived from local `op`).
|
|
483
655
|
*/
|
|
484
|
-
template <
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
|
|
656
|
+
template <class Lhs_T, class Rhs_T,
|
|
657
|
+
type_traits::requires_t<type_traits::is_op_v<Lhs_T>
|
|
658
|
+
or type_traits::is_op_v<Rhs_T>>
|
|
659
|
+
= 0>
|
|
488
660
|
[[nodiscard]] constexpr auto
|
|
489
661
|
operator or (const Lhs_T& lhs, const Rhs_T& rhs)
|
|
490
662
|
{
|
|
@@ -492,12 +664,13 @@ namespace micro_os_plus::micro_test_plus
|
|
|
492
664
|
}
|
|
493
665
|
|
|
494
666
|
/**
|
|
495
|
-
* @
|
|
667
|
+
* @ingroup micro-test-plus-operators
|
|
668
|
+
* @brief Logical `!` (not) operator. It matches only if the
|
|
496
669
|
* operand is of local type (derived from local `op`).
|
|
497
670
|
*/
|
|
498
671
|
template <class T, type_traits::requires_t<type_traits::is_op_v<T>> = 0>
|
|
499
672
|
[[nodiscard]] constexpr auto
|
|
500
|
-
operator not
|
|
673
|
+
operator not(const T& t)
|
|
501
674
|
{
|
|
502
675
|
return detail::not_{ t };
|
|
503
676
|
}
|
|
@@ -505,9 +678,25 @@ namespace micro_os_plus::micro_test_plus
|
|
|
505
678
|
|
|
506
679
|
namespace utility
|
|
507
680
|
{
|
|
681
|
+
/**
|
|
682
|
+
* @ingroup micro-test-plus-utility-functions
|
|
683
|
+
* @brief Check if a string matches a pattern.
|
|
684
|
+
* @param [in] input String view to check.
|
|
685
|
+
* @param [in] pattern Sting view with the pattern.
|
|
686
|
+
* @return True if the string matches the pattern.
|
|
687
|
+
*/
|
|
508
688
|
[[nodiscard]] bool
|
|
509
689
|
is_match (std::string_view input, std::string_view pattern);
|
|
510
690
|
|
|
691
|
+
/**
|
|
692
|
+
* @ingroup micro-test-plus-utility-functions
|
|
693
|
+
* @brief Split a string into a vector of sub-strings.
|
|
694
|
+
* @tparam T Type of the input string.
|
|
695
|
+
* @tparam Delim_T Type of the delimiter.
|
|
696
|
+
* @param [in] input Input string to split.
|
|
697
|
+
* @param [in] delim Delimiter string.
|
|
698
|
+
* @return An array of strings.
|
|
699
|
+
*/
|
|
511
700
|
template <class T, class Delim_T>
|
|
512
701
|
[[nodiscard]] auto
|
|
513
702
|
split (T input, Delim_T delim) -> std::vector<T>;
|
|
@@ -37,6 +37,7 @@
|
|
|
37
37
|
#pragma GCC diagnostic ignored "-Waggregate-return"
|
|
38
38
|
#if defined(__clang__)
|
|
39
39
|
#pragma clang diagnostic ignored "-Wc++98-compat"
|
|
40
|
+
#pragma clang diagnostic ignored "-Wunknown-warning-option"
|
|
40
41
|
#endif
|
|
41
42
|
#endif
|
|
42
43
|
|
|
@@ -51,6 +52,7 @@ namespace micro_os_plus::micro_test_plus
|
|
|
51
52
|
#else
|
|
52
53
|
/**
|
|
53
54
|
* @brief Local implementation of the std::source_location.
|
|
55
|
+
* @headerfile micro-test-plus.h <micro-os-plus/micro-test-plus.h>
|
|
54
56
|
*/
|
|
55
57
|
class source_location
|
|
56
58
|
{
|
|
@@ -58,7 +60,7 @@ namespace micro_os_plus::micro_test_plus
|
|
|
58
60
|
[[nodiscard]] static constexpr auto
|
|
59
61
|
current (
|
|
60
62
|
#if (__has_builtin(__builtin_FILE) and __has_builtin(__builtin_LINE))
|
|
61
|
-
const char* file = __builtin_FILE(), int line = __builtin_LINE()
|
|
63
|
+
const char* file = __builtin_FILE (), int line = __builtin_LINE ()
|
|
62
64
|
#else
|
|
63
65
|
const char* file = "unknown", int line = {}
|
|
64
66
|
#endif
|
|
@@ -102,12 +104,15 @@ namespace micro_os_plus::micro_test_plus
|
|
|
102
104
|
type_name () -> std::string_view
|
|
103
105
|
{
|
|
104
106
|
#if defined(__clang__)
|
|
105
|
-
|
|
106
|
-
|
|
107
|
+
#pragma GCC diagnostic push
|
|
108
|
+
#pragma clang diagnostic ignored "-Wunsafe-buffer-usage"
|
|
109
|
+
// printf("|%s|%zu|\n", __PRETTY_FUNCTION__, sizeof
|
|
110
|
+
// (__PRETTY_FUNCTION__)); printf("|%s|\n", &__PRETTY_FUNCTION__[78]);
|
|
107
111
|
return { &__PRETTY_FUNCTION__[78], sizeof (__PRETTY_FUNCTION__) - 80 };
|
|
112
|
+
#pragma GCC diagnostic pop
|
|
108
113
|
#elif defined(__GNUC__)
|
|
109
|
-
// printf("|%s|%zu|\n", __PRETTY_FUNCTION__, sizeof
|
|
110
|
-
// printf("|%s|\n", &__PRETTY_FUNCTION__[93]);
|
|
114
|
+
// printf("|%s|%zu|\n", __PRETTY_FUNCTION__, sizeof
|
|
115
|
+
// (__PRETTY_FUNCTION__)); printf("|%s|\n", &__PRETTY_FUNCTION__[93]);
|
|
111
116
|
return { &__PRETTY_FUNCTION__[93], sizeof (__PRETTY_FUNCTION__) - 144 };
|
|
112
117
|
#else
|
|
113
118
|
#error "Unsupported compiler"
|
|
@@ -71,8 +71,8 @@ namespace micro_os_plus::micro_test_plus
|
|
|
71
71
|
}
|
|
72
72
|
|
|
73
73
|
template <class T,
|
|
74
|
-
type_traits::requires_t<type_traits::is_container_v<
|
|
75
|
-
|
|
74
|
+
type_traits::requires_t<type_traits::is_container_v<T>
|
|
75
|
+
and not type_traits::has_npos_v<T>>>
|
|
76
76
|
test_reporter&
|
|
77
77
|
test_reporter::operator<< (T&& t)
|
|
78
78
|
{
|