@micro-os-plus/micro-test-plus 3.1.2 → 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 +44 -0
- package/include/micro-os-plus/detail.h +15 -0
- package/include/micro-os-plus/inlines.h +8 -4
- package/include/micro-os-plus/literals.h +109 -10
- package/include/micro-os-plus/micro-test-plus.h +6 -3
- package/include/micro-os-plus/reflection.h +1 -0
- package/include/micro-os-plus/test-reporter.h +3 -0
- package/include/micro-os-plus/test-runner.h +1 -0
- package/include/micro-os-plus/test-suite.h +2 -0
- package/include/micro-os-plus/type-traits.h +32 -0
- package/package.json +1 -1
- package/src/micro-test-plus.cpp +5 -3
package/CHANGELOG.md
CHANGED
|
@@ -6,6 +6,50 @@ Please check
|
|
|
6
6
|
[GitHub](https://github.com/micro-os-plus/micro-test-plus-xpack/issues/)
|
|
7
7
|
and close existing issues and pull requests.
|
|
8
8
|
|
|
9
|
+
## 2023-12-06
|
|
10
|
+
|
|
11
|
+
* v3.2.0
|
|
12
|
+
* 90963ce micro-test-plus.h cosmetics
|
|
13
|
+
* c57c46e literals.h: silence clang deprecation warning
|
|
14
|
+
* f776b18 doxygen metadata: add @headerfile
|
|
15
|
+
* 94ff7d7 website: use to_*
|
|
16
|
+
* 9d4f8bb tests/sample-test.cpp: use to_*
|
|
17
|
+
* 24606d7 literals.h: add to_*, deprecate _*
|
|
18
|
+
|
|
19
|
+
## 2023-12-05
|
|
20
|
+
|
|
21
|
+
* 76ddc99 user-guide.md: use mt::
|
|
22
|
+
* 86adedf doxygen metadata: use mt:: in examples
|
|
23
|
+
* 71db099 tests: use explicit mt::
|
|
24
|
+
* c508d4f testing.md: remove reference to test-all.yml
|
|
25
|
+
* 11a1f31 testing.md: update
|
|
26
|
+
* 1ee57a8 testing.md: fix typo
|
|
27
|
+
* 749e2d6 testing.md: add clang 17
|
|
28
|
+
* 221a630 rename xpack-development
|
|
29
|
+
* 06419e5 tests/package.json: enable gcc11
|
|
30
|
+
* 03cb2ed tests/package.json: bump deps
|
|
31
|
+
|
|
32
|
+
## 2023-12-04
|
|
33
|
+
|
|
34
|
+
* ebe7e55 package-lock.json updates
|
|
35
|
+
* 17e8859 tests/package.json: add clang 17
|
|
36
|
+
* 75e585a micro-test-plus.cpp: silence warning for clang 17
|
|
37
|
+
|
|
38
|
+
## 2023-11-30
|
|
39
|
+
|
|
40
|
+
* b4ff766 website/package.json: #v2.3.1
|
|
41
|
+
* 19a43d6 testing.md update
|
|
42
|
+
* 822e464 rework tests with platforms sub-folder
|
|
43
|
+
* 2aef49a website/package.json: explicit #v2.3.0
|
|
44
|
+
* 313fd41 website/package.json: explicit #2.3.0
|
|
45
|
+
* 80d0fe8 testing.md: updates
|
|
46
|
+
|
|
47
|
+
## 2023-11-29
|
|
48
|
+
|
|
49
|
+
* 2227c94 3.1.2
|
|
50
|
+
* 552865e prepare v3.1.2
|
|
51
|
+
* 993d0f7 testing.md: updates
|
|
52
|
+
|
|
9
53
|
## 2023-11-28
|
|
10
54
|
|
|
11
55
|
* 21393a5 ci.yml cosmetics
|
|
@@ -47,6 +47,7 @@ namespace micro_os_plus::micro_test_plus
|
|
|
47
47
|
{
|
|
48
48
|
/**
|
|
49
49
|
* @brief An object used to pass assertion parameters to the evaluator.
|
|
50
|
+
* @headerfile micro-test-plus.h <micro-os-plus/micro-test-plus.h>
|
|
50
51
|
*/
|
|
51
52
|
template <class Expr_T>
|
|
52
53
|
struct assertion
|
|
@@ -95,6 +96,7 @@ namespace micro_os_plus::micro_test_plus
|
|
|
95
96
|
|
|
96
97
|
/**
|
|
97
98
|
* @brief Equality comparator.
|
|
99
|
+
* @headerfile micro-test-plus.h <micro-os-plus/micro-test-plus.h>
|
|
98
100
|
*/
|
|
99
101
|
template <class Lhs_T, class Rhs_T>
|
|
100
102
|
struct eq_ : type_traits::op
|
|
@@ -180,6 +182,7 @@ namespace micro_os_plus::micro_test_plus
|
|
|
180
182
|
|
|
181
183
|
/**
|
|
182
184
|
* @brief Non-equality comparator.
|
|
185
|
+
* @headerfile micro-test-plus.h <micro-os-plus/micro-test-plus.h>
|
|
183
186
|
*/
|
|
184
187
|
template <class Lhs_T, class Rhs_T>
|
|
185
188
|
struct ne_ : type_traits::op
|
|
@@ -254,6 +257,7 @@ namespace micro_os_plus::micro_test_plus
|
|
|
254
257
|
|
|
255
258
|
/**
|
|
256
259
|
* @brief Greater than comparator.
|
|
260
|
+
* @headerfile micro-test-plus.h <micro-os-plus/micro-test-plus.h>
|
|
257
261
|
*/
|
|
258
262
|
template <class Lhs_T, class Rhs_T>
|
|
259
263
|
struct gt_ : type_traits::op
|
|
@@ -311,6 +315,7 @@ namespace micro_os_plus::micro_test_plus
|
|
|
311
315
|
|
|
312
316
|
/**
|
|
313
317
|
* @brief Greater than or equal comparator.
|
|
318
|
+
* @headerfile micro-test-plus.h <micro-os-plus/micro-test-plus.h>
|
|
314
319
|
*/
|
|
315
320
|
template <class Lhs_T, class Rhs_T>
|
|
316
321
|
struct ge_ : type_traits::op
|
|
@@ -368,6 +373,7 @@ namespace micro_os_plus::micro_test_plus
|
|
|
368
373
|
|
|
369
374
|
/**
|
|
370
375
|
* @brief Less than comparator.
|
|
376
|
+
* @headerfile micro-test-plus.h <micro-os-plus/micro-test-plus.h>
|
|
371
377
|
*/
|
|
372
378
|
template <class Lhs_T, class Rhs_T>
|
|
373
379
|
struct lt_ : type_traits::op
|
|
@@ -426,6 +432,7 @@ namespace micro_os_plus::micro_test_plus
|
|
|
426
432
|
|
|
427
433
|
/**
|
|
428
434
|
* @brief Less than or equal comparator.
|
|
435
|
+
* @headerfile micro-test-plus.h <micro-os-plus/micro-test-plus.h>
|
|
429
436
|
*/
|
|
430
437
|
template <class Lhs_T, class Rhs_T>
|
|
431
438
|
struct le_ : type_traits::op
|
|
@@ -485,6 +492,7 @@ namespace micro_os_plus::micro_test_plus
|
|
|
485
492
|
|
|
486
493
|
/**
|
|
487
494
|
* @brief Logical and operator.
|
|
495
|
+
* @headerfile micro-test-plus.h <micro-os-plus/micro-test-plus.h>
|
|
488
496
|
*/
|
|
489
497
|
template <class Lhs_T, class Rhs_T>
|
|
490
498
|
struct and_ : type_traits::op
|
|
@@ -520,6 +528,7 @@ namespace micro_os_plus::micro_test_plus
|
|
|
520
528
|
|
|
521
529
|
/**
|
|
522
530
|
* @brief Logical or operator.
|
|
531
|
+
* @headerfile micro-test-plus.h <micro-os-plus/micro-test-plus.h>
|
|
523
532
|
*/
|
|
524
533
|
template <class Lhs_T, class Rhs_T>
|
|
525
534
|
struct or_ : type_traits::op
|
|
@@ -555,6 +564,7 @@ namespace micro_os_plus::micro_test_plus
|
|
|
555
564
|
|
|
556
565
|
/**
|
|
557
566
|
* @brief Logical not operator.
|
|
567
|
+
* @headerfile micro-test-plus.h <micro-os-plus/micro-test-plus.h>
|
|
558
568
|
*/
|
|
559
569
|
template <class T>
|
|
560
570
|
struct not_ : type_traits::op
|
|
@@ -583,6 +593,7 @@ namespace micro_os_plus::micro_test_plus
|
|
|
583
593
|
#if defined(__cpp_exceptions)
|
|
584
594
|
/**
|
|
585
595
|
* @brief Operator to check if the expression throws a specific exception.
|
|
596
|
+
* @headerfile micro-test-plus.h <micro-os-plus/micro-test-plus.h>
|
|
586
597
|
*/
|
|
587
598
|
template <class Callable_T, class Exception_T = void>
|
|
588
599
|
struct throws_ : type_traits::op
|
|
@@ -617,6 +628,7 @@ namespace micro_os_plus::micro_test_plus
|
|
|
617
628
|
|
|
618
629
|
/**
|
|
619
630
|
* @brief Operator to check if the expression throws any exception.
|
|
631
|
+
* @headerfile micro-test-plus.h <micro-os-plus/micro-test-plus.h>
|
|
620
632
|
*/
|
|
621
633
|
template <class Callable_T>
|
|
622
634
|
struct throws_<Callable_T, void> : type_traits::op
|
|
@@ -647,6 +659,7 @@ namespace micro_os_plus::micro_test_plus
|
|
|
647
659
|
|
|
648
660
|
/**
|
|
649
661
|
* @brief Operator to check if the expression does not throw any exception.
|
|
662
|
+
* @headerfile micro-test-plus.h <micro-os-plus/micro-test-plus.h>
|
|
650
663
|
*/
|
|
651
664
|
template <class Callable_T>
|
|
652
665
|
struct nothrow_ : type_traits::op
|
|
@@ -681,6 +694,7 @@ namespace micro_os_plus::micro_test_plus
|
|
|
681
694
|
/**
|
|
682
695
|
* @brief Base class for a deferred reporter, that collects the
|
|
683
696
|
* messages into a string.
|
|
697
|
+
* @headerfile micro-test-plus.h <micro-os-plus/micro-test-plus.h>
|
|
684
698
|
*/
|
|
685
699
|
class deferred_reporter_base
|
|
686
700
|
{
|
|
@@ -715,6 +729,7 @@ namespace micro_os_plus::micro_test_plus
|
|
|
715
729
|
/**
|
|
716
730
|
* @brief Class template for a deferred reporter specific
|
|
717
731
|
* to an expression.
|
|
732
|
+
* @headerfile micro-test-plus.h <micro-os-plus/micro-test-plus.h>
|
|
718
733
|
*/
|
|
719
734
|
template <class Expr_T>
|
|
720
735
|
class deferred_reporter : public deferred_reporter_base
|
|
@@ -75,8 +75,10 @@ namespace micro_os_plus::micro_test_plus
|
|
|
75
75
|
* @par Example
|
|
76
76
|
*
|
|
77
77
|
* ```cpp
|
|
78
|
-
*
|
|
79
|
-
*
|
|
78
|
+
* namespace mt = micro_os_plus::micro_test_plus;
|
|
79
|
+
*
|
|
80
|
+
* mt::test_case ("Check answer with comparator", [] {
|
|
81
|
+
* mt::expect (mt::eq (compute_answer (), 42)) << "answer is 42";
|
|
80
82
|
* });
|
|
81
83
|
* ```
|
|
82
84
|
*/
|
|
@@ -155,8 +157,10 @@ namespace micro_os_plus::micro_test_plus
|
|
|
155
157
|
*
|
|
156
158
|
* @par Example
|
|
157
159
|
* ```cpp
|
|
158
|
-
*
|
|
159
|
-
*
|
|
160
|
+
* namespace mt = micro_os_plus::micro_test_plus;
|
|
161
|
+
*
|
|
162
|
+
* mt::expect (std::vector<std::string_view>{ "a", "b" }
|
|
163
|
+
* == mt::utility::split<std::string_view> ("a.b", "."))
|
|
160
164
|
* << "a.b splits into [a,b]";
|
|
161
165
|
* ```
|
|
162
166
|
*/
|
|
@@ -347,39 +347,132 @@ namespace micro_os_plus::micro_test_plus
|
|
|
347
347
|
|
|
348
348
|
// --------------------------------------------------------------------------
|
|
349
349
|
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
350
|
+
#if defined(__GNUC__)
|
|
351
|
+
#pragma GCC diagnostic push
|
|
352
|
+
#if defined(__clang__)
|
|
353
|
+
#pragma clang diagnostic ignored "-Wdocumentation-deprecated-sync"
|
|
354
|
+
#endif
|
|
355
|
+
#endif
|
|
354
356
|
|
|
355
|
-
|
|
356
|
-
// that are recognised by the comparators.
|
|
357
|
-
// The syntax is similar to function calls, like `_i(expression)`, but the
|
|
358
|
-
// results have custom types expected by comparators.
|
|
357
|
+
/** @deprecated Use `to_b` (since 3.2.0). */
|
|
359
358
|
using _b = type_traits::value<bool>;
|
|
359
|
+
/** @deprecated Use `to_c` (since 3.2.0). */
|
|
360
360
|
using _c = type_traits::value<char>;
|
|
361
|
+
/** @deprecated Use `to_sc` (since 3.2.0). */
|
|
361
362
|
using _sc = type_traits::value<signed char>;
|
|
363
|
+
/** @deprecated Use `to_s` (since 3.2.0). */
|
|
362
364
|
using _s = type_traits::value<short>;
|
|
365
|
+
/** @deprecated Use `to_i` (since 3.2.0). */
|
|
363
366
|
using _i = type_traits::value<int>;
|
|
367
|
+
/** @deprecated Use `to_l` (since 3.2.0). */
|
|
364
368
|
using _l = type_traits::value<long>;
|
|
369
|
+
/** @deprecated Use `to_ll` (since 3.2.0). */
|
|
365
370
|
using _ll = type_traits::value<long long>;
|
|
371
|
+
/** @deprecated Use `to_u` (since 3.2.0). */
|
|
366
372
|
using _u = type_traits::value<unsigned>;
|
|
373
|
+
/** @deprecated Use `to_uc` (since 3.2.0). */
|
|
367
374
|
using _uc = type_traits::value<unsigned char>;
|
|
375
|
+
/** @deprecated Use `to_us` (since 3.2.0). */
|
|
368
376
|
using _us = type_traits::value<unsigned short>;
|
|
377
|
+
/** @deprecated Use `to_ul` (since 3.2.0). */
|
|
369
378
|
using _ul = type_traits::value<unsigned long>;
|
|
379
|
+
/** @deprecated Use `to_ull` (since 3.2.0). */
|
|
370
380
|
using _ull = type_traits::value<unsigned long long>;
|
|
381
|
+
/** @deprecated Use `to_i8` (since 3.2.0). */
|
|
371
382
|
using _i8 = type_traits::value<std::int8_t>;
|
|
383
|
+
/** @deprecated Use `to_i16` (since 3.2.0). */
|
|
372
384
|
using _i16 = type_traits::value<std::int16_t>;
|
|
385
|
+
/** @deprecated Use `to_i32` (since 3.2.0). */
|
|
373
386
|
using _i32 = type_traits::value<std::int32_t>;
|
|
387
|
+
/** @deprecated Use `to_i64` (since 3.2.0). */
|
|
374
388
|
using _i64 = type_traits::value<std::int64_t>;
|
|
389
|
+
/** @deprecated Use `to_u8` (since 3.2.0). */
|
|
375
390
|
using _u8 = type_traits::value<std::uint8_t>;
|
|
391
|
+
/** @deprecated Use `to_u16` (since 3.2.0). */
|
|
376
392
|
using _u16 = type_traits::value<std::uint16_t>;
|
|
393
|
+
/** @deprecated Use `to_u32` (since 3.2.0). */
|
|
377
394
|
using _u32 = type_traits::value<std::uint32_t>;
|
|
395
|
+
/** @deprecated Use `to_u64` (since 3.2.0). */
|
|
378
396
|
using _u64 = type_traits::value<std::uint64_t>;
|
|
397
|
+
/** @deprecated Use `to_f` (since 3.2.0). */
|
|
379
398
|
using _f = type_traits::value<float>;
|
|
399
|
+
/** @deprecated Use `to_d` (since 3.2.0). */
|
|
380
400
|
using _d = type_traits::value<double>;
|
|
401
|
+
/** @deprecated Use `to_ld` (since 3.2.0). */
|
|
381
402
|
using _ld = type_traits::value<long double>;
|
|
382
403
|
|
|
404
|
+
/**
|
|
405
|
+
* @deprecated Use `to_t` (since 3.2.0).
|
|
406
|
+
* @headerfile micro-test-plus.h <micro-os-plus/micro-test-plus.h>
|
|
407
|
+
*/
|
|
408
|
+
template <class T>
|
|
409
|
+
struct _t : type_traits::value<T>
|
|
410
|
+
{
|
|
411
|
+
constexpr explicit _t (const T& t) : type_traits::value<T>{ t }
|
|
412
|
+
{
|
|
413
|
+
}
|
|
414
|
+
};
|
|
415
|
+
|
|
416
|
+
#if defined(__GNUC__)
|
|
417
|
+
#pragma GCC diagnostic pop
|
|
418
|
+
#endif
|
|
419
|
+
|
|
420
|
+
/**
|
|
421
|
+
* @addtogroup micro-test-plus-literals
|
|
422
|
+
* @{
|
|
423
|
+
*/
|
|
424
|
+
|
|
425
|
+
// Wrappers that can be used to convert dynamic values to specific types
|
|
426
|
+
// that are recognised by the comparators.
|
|
427
|
+
// The syntax is similar to function calls, like `_i(expression)`, but the
|
|
428
|
+
// results have custom types expected by comparators.
|
|
429
|
+
/** @since 3.2.0 */
|
|
430
|
+
using to_b = type_traits::value<bool>;
|
|
431
|
+
/** @since 3.2.0 */
|
|
432
|
+
using to_c = type_traits::value<char>;
|
|
433
|
+
/** @since 3.2.0 */
|
|
434
|
+
using to_sc = type_traits::value<signed char>;
|
|
435
|
+
/** @since 3.2.0 */
|
|
436
|
+
using to_s = type_traits::value<short>;
|
|
437
|
+
/** @since 3.2.0 */
|
|
438
|
+
using to_i = type_traits::value<int>;
|
|
439
|
+
/** @since 3.2.0 */
|
|
440
|
+
using to_l = type_traits::value<long>;
|
|
441
|
+
/** @since 3.2.0 */
|
|
442
|
+
using to_ll = type_traits::value<long long>;
|
|
443
|
+
/** @since 3.2.0 */
|
|
444
|
+
using to_u = type_traits::value<unsigned>;
|
|
445
|
+
/** @since 3.2.0 */
|
|
446
|
+
using to_uc = type_traits::value<unsigned char>;
|
|
447
|
+
/** @since 3.2.0 */
|
|
448
|
+
using to_us = type_traits::value<unsigned short>;
|
|
449
|
+
/** @since 3.2.0 */
|
|
450
|
+
using to_ul = type_traits::value<unsigned long>;
|
|
451
|
+
/** @since 3.2.0 */
|
|
452
|
+
using to_ull = type_traits::value<unsigned long long>;
|
|
453
|
+
/** @since 3.2.0 */
|
|
454
|
+
using to_i8 = type_traits::value<std::int8_t>;
|
|
455
|
+
/** @since 3.2.0 */
|
|
456
|
+
using to_i16 = type_traits::value<std::int16_t>;
|
|
457
|
+
/** @since 3.2.0 */
|
|
458
|
+
using to_i32 = type_traits::value<std::int32_t>;
|
|
459
|
+
/** @since 3.2.0 */
|
|
460
|
+
using to_i64 = type_traits::value<std::int64_t>;
|
|
461
|
+
/** @since 3.2.0 */
|
|
462
|
+
using to_u8 = type_traits::value<std::uint8_t>;
|
|
463
|
+
/** @since 3.2.0 */
|
|
464
|
+
using to_u16 = type_traits::value<std::uint16_t>;
|
|
465
|
+
/** @since 3.2.0 */
|
|
466
|
+
using to_u32 = type_traits::value<std::uint32_t>;
|
|
467
|
+
/** @since 3.2.0 */
|
|
468
|
+
using to_u64 = type_traits::value<std::uint64_t>;
|
|
469
|
+
/** @since 3.2.0 */
|
|
470
|
+
using to_f = type_traits::value<float>;
|
|
471
|
+
/** @since 3.2.0 */
|
|
472
|
+
using to_d = type_traits::value<double>;
|
|
473
|
+
/** @since 3.2.0 */
|
|
474
|
+
using to_ld = type_traits::value<long double>;
|
|
475
|
+
|
|
383
476
|
/**
|
|
384
477
|
* @}
|
|
385
478
|
*/
|
|
@@ -387,11 +480,17 @@ namespace micro_os_plus::micro_test_plus
|
|
|
387
480
|
/**
|
|
388
481
|
* @ingroup micro-test-plus-literals
|
|
389
482
|
* @brief Template for wrapping any other type.
|
|
483
|
+
* @headerfile micro-test-plus.h <micro-os-plus/micro-test-plus.h>
|
|
484
|
+
* @since 3.2.0
|
|
485
|
+
*
|
|
486
|
+
* @details
|
|
487
|
+
* A public class used only to convert the type.
|
|
390
488
|
*/
|
|
391
489
|
template <class T>
|
|
392
|
-
struct
|
|
490
|
+
struct to_t : type_traits::value<T>
|
|
393
491
|
{
|
|
394
|
-
|
|
492
|
+
/** @brief Constructor. */
|
|
493
|
+
constexpr explicit to_t (const T& t) : type_traits::value<T>{ t }
|
|
395
494
|
{
|
|
396
495
|
}
|
|
397
496
|
};
|
|
@@ -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__)
|
|
@@ -128,7 +127,9 @@ namespace micro_os_plus::micro_test_plus
|
|
|
128
127
|
*
|
|
129
128
|
* @par Example
|
|
130
129
|
* ```cpp
|
|
131
|
-
*
|
|
130
|
+
* namespace mt = micro_os_plus::micro_test_plus;
|
|
131
|
+
*
|
|
132
|
+
* mt::expect (compute_answer () == 42) << "answer is 42";
|
|
132
133
|
* ```
|
|
133
134
|
*/
|
|
134
135
|
template <class Expr_T, type_traits::requires_t<
|
|
@@ -156,7 +157,9 @@ namespace micro_os_plus::micro_test_plus
|
|
|
156
157
|
*
|
|
157
158
|
* @par Example
|
|
158
159
|
* ```cpp
|
|
159
|
-
*
|
|
160
|
+
* namespace mt = micro_os_plus::micro_test_plus;
|
|
161
|
+
*
|
|
162
|
+
* mt::assume (compute_answer () == 42) << "answer is 42";
|
|
160
163
|
* ```
|
|
161
164
|
*/
|
|
162
165
|
template <class Expr_T, type_traits::requires_t<
|
|
@@ -49,6 +49,7 @@ namespace micro_os_plus::micro_test_plus
|
|
|
49
49
|
|
|
50
50
|
/**
|
|
51
51
|
* @brief Colours used to highlight pass vs. fail.
|
|
52
|
+
* @headerfile micro-test-plus.h <micro-os-plus/micro-test-plus.h>
|
|
52
53
|
*/
|
|
53
54
|
struct colors
|
|
54
55
|
{
|
|
@@ -59,6 +60,7 @@ namespace micro_os_plus::micro_test_plus
|
|
|
59
60
|
|
|
60
61
|
/**
|
|
61
62
|
* @brief The verbosity levels.
|
|
63
|
+
* @headerfile micro-test-plus.h <micro-os-plus/micro-test-plus.h>
|
|
62
64
|
*/
|
|
63
65
|
enum class verbosity
|
|
64
66
|
{
|
|
@@ -80,6 +82,7 @@ namespace micro_os_plus::micro_test_plus
|
|
|
80
82
|
/**
|
|
81
83
|
* @brief Reporter to display the test results. For failed
|
|
82
84
|
* tests it prints the actual values of the operands, with their types.
|
|
85
|
+
* @headerfile micro-test-plus.h <micro-os-plus/micro-test-plus.h>
|
|
83
86
|
*/
|
|
84
87
|
class test_reporter
|
|
85
88
|
{
|
|
@@ -46,6 +46,7 @@ namespace micro_os_plus::micro_test_plus
|
|
|
46
46
|
/**
|
|
47
47
|
* @brief The test runner. It maintains a list of test suites which
|
|
48
48
|
* automatically register themselves in their constructors.
|
|
49
|
+
* @headerfile micro-test-plus.h <micro-os-plus/micro-test-plus.h>
|
|
49
50
|
*/
|
|
50
51
|
class test_runner
|
|
51
52
|
{
|
|
@@ -45,6 +45,7 @@ namespace micro_os_plus::micro_test_plus
|
|
|
45
45
|
|
|
46
46
|
/**
|
|
47
47
|
* @brief Base class for all test suites.
|
|
48
|
+
* @headerfile micro-test-plus.h <micro-os-plus/micro-test-plus.h>
|
|
48
49
|
*/
|
|
49
50
|
class test_suite_base
|
|
50
51
|
{
|
|
@@ -249,6 +250,7 @@ namespace micro_os_plus::micro_test_plus
|
|
|
249
250
|
* @ingroup micro-test-plus-test-suites
|
|
250
251
|
* @brief Test suites are classes that represent a named group of
|
|
251
252
|
* test cases which self register to the runner.
|
|
253
|
+
* @headerfile micro-test-plus.h <micro-os-plus/micro-test-plus.h>
|
|
252
254
|
*/
|
|
253
255
|
class test_suite : public test_suite_base
|
|
254
256
|
{
|
|
@@ -45,11 +45,17 @@ namespace micro_os_plus::micro_test_plus
|
|
|
45
45
|
*/
|
|
46
46
|
namespace type_traits
|
|
47
47
|
{
|
|
48
|
+
/**
|
|
49
|
+
* @headerfile micro-test-plus.h <micro-os-plus/micro-test-plus.h>
|
|
50
|
+
*/
|
|
48
51
|
template <class...>
|
|
49
52
|
struct list
|
|
50
53
|
{
|
|
51
54
|
};
|
|
52
55
|
|
|
56
|
+
/**
|
|
57
|
+
* @headerfile micro-test-plus.h <micro-os-plus/micro-test-plus.h>
|
|
58
|
+
*/
|
|
53
59
|
template <class T, class...>
|
|
54
60
|
struct identity
|
|
55
61
|
{
|
|
@@ -69,6 +75,9 @@ namespace micro_os_plus::micro_test_plus
|
|
|
69
75
|
};
|
|
70
76
|
#endif
|
|
71
77
|
|
|
78
|
+
/**
|
|
79
|
+
* @headerfile micro-test-plus.h <micro-os-plus/micro-test-plus.h>
|
|
80
|
+
*/
|
|
72
81
|
template <class R, class... Args_T>
|
|
73
82
|
struct function_traits<R (*) (Args_T...)>
|
|
74
83
|
{
|
|
@@ -76,6 +85,9 @@ namespace micro_os_plus::micro_test_plus
|
|
|
76
85
|
using args = list<Args_T...>;
|
|
77
86
|
};
|
|
78
87
|
|
|
88
|
+
/**
|
|
89
|
+
* @headerfile micro-test-plus.h <micro-os-plus/micro-test-plus.h>
|
|
90
|
+
*/
|
|
79
91
|
template <class R, class... Args_T>
|
|
80
92
|
struct function_traits<R (Args_T...)>
|
|
81
93
|
{
|
|
@@ -83,6 +95,9 @@ namespace micro_os_plus::micro_test_plus
|
|
|
83
95
|
using args = list<Args_T...>;
|
|
84
96
|
};
|
|
85
97
|
|
|
98
|
+
/**
|
|
99
|
+
* @headerfile micro-test-plus.h <micro-os-plus/micro-test-plus.h>
|
|
100
|
+
*/
|
|
86
101
|
template <class R, class T, class... Args_T>
|
|
87
102
|
struct function_traits<R (T::*) (Args_T...)>
|
|
88
103
|
{
|
|
@@ -90,6 +105,9 @@ namespace micro_os_plus::micro_test_plus
|
|
|
90
105
|
using args = list<Args_T...>;
|
|
91
106
|
};
|
|
92
107
|
|
|
108
|
+
/**
|
|
109
|
+
* @headerfile micro-test-plus.h <micro-os-plus/micro-test-plus.h>
|
|
110
|
+
*/
|
|
93
111
|
template <class R, class T, class... Args_T>
|
|
94
112
|
struct function_traits<R (T::*) (Args_T...) const>
|
|
95
113
|
{
|
|
@@ -159,11 +177,17 @@ namespace micro_os_plus::micro_test_plus
|
|
|
159
177
|
constexpr auto is_convertible_v = is_convertible<From, To> (0);
|
|
160
178
|
#endif
|
|
161
179
|
|
|
180
|
+
/**
|
|
181
|
+
* @headerfile micro-test-plus.h <micro-os-plus/micro-test-plus.h>
|
|
182
|
+
*/
|
|
162
183
|
template <bool>
|
|
163
184
|
struct requires_
|
|
164
185
|
{
|
|
165
186
|
};
|
|
166
187
|
|
|
188
|
+
/**
|
|
189
|
+
* @headerfile micro-test-plus.h <micro-os-plus/micro-test-plus.h>
|
|
190
|
+
*/
|
|
167
191
|
template <>
|
|
168
192
|
struct requires_<true>
|
|
169
193
|
{
|
|
@@ -175,6 +199,7 @@ namespace micro_os_plus::micro_test_plus
|
|
|
175
199
|
|
|
176
200
|
/**
|
|
177
201
|
* @brief Empty base class of all operators.
|
|
202
|
+
* @headerfile micro-test-plus.h <micro-os-plus/micro-test-plus.h>
|
|
178
203
|
*/
|
|
179
204
|
struct op
|
|
180
205
|
{
|
|
@@ -183,6 +208,7 @@ namespace micro_os_plus::micro_test_plus
|
|
|
183
208
|
/**
|
|
184
209
|
* @brief A generic integral constant.
|
|
185
210
|
* It has a getter and a '-' operator to return the negative value.
|
|
211
|
+
* @headerfile micro-test-plus.h <micro-os-plus/micro-test-plus.h>
|
|
186
212
|
*/
|
|
187
213
|
template <auto N>
|
|
188
214
|
struct integral_constant : op
|
|
@@ -213,6 +239,7 @@ namespace micro_os_plus::micro_test_plus
|
|
|
213
239
|
* @brief A generic floating point constant, with custom size
|
|
214
240
|
* and precision.
|
|
215
241
|
* It has a getter and a '-' operator to return the negative value.
|
|
242
|
+
* @headerfile micro-test-plus.h <micro-os-plus/micro-test-plus.h>
|
|
216
243
|
*/
|
|
217
244
|
template <class T, auto N, auto D, auto Size, auto P = 1>
|
|
218
245
|
struct floating_point_constant : op
|
|
@@ -242,6 +269,9 @@ namespace micro_os_plus::micro_test_plus
|
|
|
242
269
|
}
|
|
243
270
|
};
|
|
244
271
|
|
|
272
|
+
/**
|
|
273
|
+
* @headerfile micro-test-plus.h <micro-os-plus/micro-test-plus.h>
|
|
274
|
+
*/
|
|
245
275
|
template <class T>
|
|
246
276
|
struct genuine_integral_value : op
|
|
247
277
|
{
|
|
@@ -271,6 +301,7 @@ namespace micro_os_plus::micro_test_plus
|
|
|
271
301
|
|
|
272
302
|
/**
|
|
273
303
|
* @brief Class defining a generic value, accessible via a getter.
|
|
304
|
+
* @headerfile micro-test-plus.h <micro-os-plus/micro-test-plus.h>
|
|
274
305
|
*/
|
|
275
306
|
template <class T, class = int>
|
|
276
307
|
struct value : type_traits::op
|
|
@@ -301,6 +332,7 @@ namespace micro_os_plus::micro_test_plus
|
|
|
301
332
|
* in addition to the actual value, has an epsilon, to use the
|
|
302
333
|
* desired precision during comparisons.
|
|
303
334
|
* If missing, the default is 1 / (10^decimals).
|
|
335
|
+
* @headerfile micro-test-plus.h <micro-os-plus/micro-test-plus.h>
|
|
304
336
|
*/
|
|
305
337
|
template <class T>
|
|
306
338
|
struct value<T,
|
package/package.json
CHANGED
package/src/micro-test-plus.cpp
CHANGED
|
@@ -93,11 +93,11 @@ namespace micro_os_plus::micro_test_plus
|
|
|
93
93
|
#pragma clang diagnostic ignored "-Wunsafe-buffer-usage"
|
|
94
94
|
#endif
|
|
95
95
|
const char* p = strrchr (name, '/');
|
|
96
|
-
#pragma GCC diagnostic pop
|
|
97
96
|
if (p != nullptr)
|
|
98
97
|
return p + 1;
|
|
99
98
|
else
|
|
100
99
|
return name;
|
|
100
|
+
#pragma GCC diagnostic pop
|
|
101
101
|
}
|
|
102
102
|
|
|
103
103
|
} // namespace reflection
|
|
@@ -113,8 +113,10 @@ namespace micro_os_plus::micro_test_plus
|
|
|
113
113
|
* @par Examples
|
|
114
114
|
*
|
|
115
115
|
* ```cpp
|
|
116
|
-
*
|
|
117
|
-
*
|
|
116
|
+
* namespace mt = micro_os_plus::micro_test_plus;
|
|
117
|
+
*
|
|
118
|
+
* mt::expect (mt::utility::is_match ("abc", "a?c")) << "abc matches a?c";
|
|
119
|
+
* mt::expect (mt::utility::is_match ("abc", "a*c")) << "abc matches a*c";
|
|
118
120
|
* ```
|
|
119
121
|
*/
|
|
120
122
|
[[nodiscard]] bool
|