@micro-os-plus/micro-test-plus 3.3.1 → 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 (65) hide show
  1. package/CHANGELOG.md +412 -2
  2. package/CMakeLists.txt +134 -28
  3. package/README.md +3 -2
  4. package/config/xcdl-build.json +11 -4
  5. package/include/micro-os-plus/micro-test-plus/README.md +6 -0
  6. package/include/micro-os-plus/micro-test-plus/deferred-reporter.h +267 -0
  7. package/include/micro-os-plus/micro-test-plus/detail.h +272 -1425
  8. package/include/micro-os-plus/micro-test-plus/exceptions.h +125 -0
  9. package/include/micro-os-plus/micro-test-plus/expression-formatter.h +669 -0
  10. package/include/micro-os-plus/micro-test-plus/function-comparators.h +15 -7
  11. package/include/micro-os-plus/micro-test-plus/inlines/{details-inlines.h → deferred-reporter-inlines.h} +66 -44
  12. package/include/micro-os-plus/micro-test-plus/inlines/detail-inlines.h +711 -0
  13. package/include/micro-os-plus/micro-test-plus/inlines/exceptions-inline.h +137 -0
  14. package/include/micro-os-plus/micro-test-plus/inlines/{test-reporter-inlines.h → expression-formatter-inlines.h} +232 -198
  15. package/include/micro-os-plus/micro-test-plus/inlines/function-comparators-inlines.h +24 -20
  16. package/include/micro-os-plus/micro-test-plus/inlines/literals-inlines.h +50 -31
  17. package/include/micro-os-plus/micro-test-plus/inlines/math-inlines.h +25 -19
  18. package/include/micro-os-plus/micro-test-plus/inlines/operators-inlines.h +275 -0
  19. package/include/micro-os-plus/micro-test-plus/inlines/reflection-inlines.h +39 -21
  20. package/include/micro-os-plus/micro-test-plus/inlines/reporter-inlines.h +205 -0
  21. package/include/micro-os-plus/micro-test-plus/inlines/runner-inlines.h +151 -0
  22. package/include/micro-os-plus/micro-test-plus/inlines/runner-totals-inlines.h +152 -0
  23. package/include/micro-os-plus/micro-test-plus/inlines/test-inlines.h +555 -0
  24. package/include/micro-os-plus/micro-test-plus/inlines/timings-inlines.h +120 -0
  25. package/include/micro-os-plus/micro-test-plus/inlines/type-traits-inlines.h +231 -0
  26. package/include/micro-os-plus/micro-test-plus/inlines/utility-inlines.h +126 -0
  27. package/include/micro-os-plus/micro-test-plus/literals.h +12 -17
  28. package/include/micro-os-plus/micro-test-plus/math.h +14 -6
  29. package/include/micro-os-plus/micro-test-plus/operators.h +53 -209
  30. package/include/micro-os-plus/micro-test-plus/reflection.h +8 -4
  31. package/include/micro-os-plus/micro-test-plus/{test-reporter-basic.h → reporter-human.h} +80 -74
  32. package/include/micro-os-plus/micro-test-plus/{test-reporter-tap.h → reporter-tap.h} +77 -71
  33. package/include/micro-os-plus/micro-test-plus/reporter.h +619 -0
  34. package/include/micro-os-plus/micro-test-plus/runner-totals.h +250 -0
  35. package/include/micro-os-plus/micro-test-plus/runner.h +472 -0
  36. package/include/micro-os-plus/micro-test-plus/test.h +1013 -0
  37. package/include/micro-os-plus/micro-test-plus/timings.h +363 -0
  38. package/include/micro-os-plus/micro-test-plus/type-traits.h +223 -577
  39. package/include/micro-os-plus/micro-test-plus/utility.h +136 -0
  40. package/include/micro-os-plus/micro-test-plus.h +42 -236
  41. package/meson.build +11 -6
  42. package/package.json +11 -3
  43. package/src/deferred-reporter.cpp +137 -0
  44. package/src/expression-formatter.cpp +289 -0
  45. package/src/reflection.cpp +97 -0
  46. package/src/reporter-human.cpp +816 -0
  47. package/src/reporter-tap.cpp +772 -0
  48. package/src/reporter.cpp +481 -0
  49. package/src/runner-totals.cpp +98 -0
  50. package/src/runner.cpp +669 -0
  51. package/src/test.cpp +503 -0
  52. package/src/timings.cpp +210 -0
  53. package/src/utility.cpp +163 -0
  54. package/.cmake-format.yaml +0 -11
  55. package/include/micro-os-plus/micro-test-plus/inlines/micro-test-plus-inlines.h +0 -313
  56. package/include/micro-os-plus/micro-test-plus/inlines/test-suite-inlines.h +0 -115
  57. package/include/micro-os-plus/micro-test-plus/test-reporter.h +0 -846
  58. package/include/micro-os-plus/micro-test-plus/test-runner.h +0 -281
  59. package/include/micro-os-plus/micro-test-plus/test-suite.h +0 -492
  60. package/src/micro-test-plus.cpp +0 -316
  61. package/src/test-reporter-basic.cpp +0 -466
  62. package/src/test-reporter-tap.cpp +0 -530
  63. package/src/test-reporter.cpp +0 -399
  64. package/src/test-runner.cpp +0 -311
  65. package/src/test-suite.cpp +0 -304
@@ -0,0 +1,151 @@
1
+ /*
2
+ * This file is part of the µOS++ project (https://micro-os-plus.github.io/).
3
+ * Copyright (c) 2021-2026 Liviu Ionescu. All rights reserved.
4
+ *
5
+ * Permission to use, copy, modify, and/or distribute this software for any
6
+ * purpose is hereby granted, under the terms of the MIT license.
7
+ *
8
+ * If a copy of the license was not distributed with this file, it can be
9
+ * obtained from https://opensource.org/licenses/mit.
10
+ *
11
+ * Major parts of the code are inspired from v1.1.8 of the Boost UT project,
12
+ * released under the terms of the Boost Version 1.0 Software License,
13
+ * which can be obtained from https://www.boost.org/LICENSE_1_0.txt.
14
+ */
15
+
16
+ // ----------------------------------------------------------------------------
17
+
18
+ /**
19
+ * @file
20
+ * @brief C++ header file with inline implementations for the µTest++ test
21
+ * runner.
22
+ *
23
+ * @details
24
+ * This header provides the inline template implementation for
25
+ * `runner::suite()`, the method used to create and register a named test
26
+ * suite with a `runner` instance. The method constructs a `suite` object
27
+ * on the heap (wrapped in `std::unique_ptr`), transfers ownership to the
28
+ * runner via `register_suite_()`, and the newly created suite runs
29
+ * immediately as part of the registration process.
30
+ *
31
+ * The implementation is separated into this inline header so that the
32
+ * template definition is visible at every call site without cluttering the
33
+ * main `runner.h` declaration file.
34
+ *
35
+ * This file is intended solely for internal use within the framework and
36
+ * should not be included directly by user code.
37
+ */
38
+
39
+ #ifndef MICRO_TEST_PLUS_TEST_RUNNER_INLINES_H_
40
+ #define MICRO_TEST_PLUS_TEST_RUNNER_INLINES_H_
41
+
42
+ // ----------------------------------------------------------------------------
43
+
44
+ #ifdef __cplusplus
45
+
46
+ // ----------------------------------------------------------------------------
47
+
48
+ #if defined(MICRO_OS_PLUS_TRACE)
49
+ #include <micro-os-plus/diag/trace.h>
50
+ #endif // MICRO_OS_PLUS_TRACE
51
+
52
+ // ----------------------------------------------------------------------------
53
+
54
+ #if defined(__GNUC__)
55
+ #pragma GCC diagnostic push
56
+ #pragma GCC diagnostic ignored "-Waggregate-return"
57
+ #if defined(__clang__)
58
+ #pragma clang diagnostic ignored "-Wc++98-compat"
59
+ #pragma clang diagnostic ignored "-Wc++98-compat-pedantic"
60
+ #else // GCC only
61
+ #pragma GCC diagnostic ignored "-Wredundant-tags"
62
+ #endif
63
+ #endif
64
+
65
+ // ============================================================================
66
+
67
+ namespace micro_os_plus::micro_test_plus
68
+ {
69
+ // ==========================================================================
70
+
71
+ /**
72
+ * @details
73
+ * Returns a reference to the reporter object stored in the unique pointer.
74
+ */
75
+ inline class reporter&
76
+ runner::reporter (void) const noexcept
77
+ {
78
+ return *reporter_;
79
+ }
80
+
81
+ /**
82
+ * @details
83
+ * Returns a reference to the `timestamps` member.
84
+ */
85
+ inline detail::timestamps&
86
+ runner::timings () noexcept
87
+ {
88
+ return timings_;
89
+ }
90
+
91
+ /**
92
+ * @details
93
+ * Returns a const reference to the `timestamps` member.
94
+ */
95
+ inline const detail::timestamps&
96
+ runner::timings () const noexcept
97
+ {
98
+ return timings_;
99
+ }
100
+
101
+ // --------------------------------------------------------------------------
102
+
103
+ /**
104
+ * @details
105
+ * Constructs a `suite` object on the heap, binding the callable and any
106
+ * additional arguments, then transfers ownership to the runner via
107
+ * `register_suite_()`. The suite runs immediately as part of the
108
+ * registration process.
109
+ */
110
+ template <typename Callable_T, typename... Args_T>
111
+ void
112
+ runner::suite (const char* name, Callable_T&& callable,
113
+ Args_T&&... arguments)
114
+ {
115
+ #if defined(MICRO_OS_PLUS_TRACE) \
116
+ && defined(MICRO_OS_PLUS_TRACE_MICRO_TEST_PLUS)
117
+ #if defined(__GNUC__)
118
+ #pragma GCC diagnostic push
119
+ #if defined(__clang__)
120
+ #pragma clang diagnostic ignored "-Wunsafe-buffer-usage-in-libc-call"
121
+ #endif
122
+ #endif
123
+ trace::printf ("%s '%s'\n", __PRETTY_FUNCTION__, name);
124
+ #if defined(__GNUC__)
125
+ #pragma GCC diagnostic pop
126
+ #endif
127
+ #endif // MICRO_OS_PLUS_TRACE_MICRO_TEST_PLUS
128
+
129
+ auto child_suite = std::make_unique<class suite> (
130
+ name, *this, std::forward<Callable_T> (callable),
131
+ std::forward<Args_T> (arguments)...);
132
+
133
+ register_suite_ (std::move (child_suite));
134
+ }
135
+
136
+ // --------------------------------------------------------------------------
137
+ } // namespace micro_os_plus::micro_test_plus
138
+
139
+ #if defined(__GNUC__)
140
+ #pragma GCC diagnostic pop
141
+ #endif
142
+
143
+ // ----------------------------------------------------------------------------
144
+
145
+ #endif // __cplusplus
146
+
147
+ // ----------------------------------------------------------------------------
148
+
149
+ #endif // MICRO_TEST_PLUS_TEST_RUNNER_INLINES_H_
150
+
151
+ // ----------------------------------------------------------------------------
@@ -0,0 +1,152 @@
1
+ /*
2
+ * This file is part of the µOS++ project (https://micro-os-plus.github.io/).
3
+ * Copyright (c) 2021-2026 Liviu Ionescu. All rights reserved.
4
+ *
5
+ * Permission to use, copy, modify, and/or distribute this software for any
6
+ * purpose is hereby granted, under the terms of the MIT license.
7
+ *
8
+ * If a copy of the license was not distributed with this file, it can be
9
+ * obtained from https://opensource.org/licenses/mit.
10
+ *
11
+ * Major parts of the code are inspired from v1.1.8 of the Boost UT project,
12
+ * released under the terms of the Boost Version 1.0 Software License,
13
+ * which can be obtained from https://www.boost.org/LICENSE_1_0.txt.
14
+ */
15
+
16
+ // ----------------------------------------------------------------------------
17
+
18
+ /**
19
+ * @file
20
+ * @brief C++ header file with inline implementations for the µTest++
21
+ * runner totals.
22
+ *
23
+ * @details
24
+ * This header provides the inline method bodies for the `runner_totals`
25
+ * class, separated from the class declaration in `runner-totals.h` to
26
+ * enforce the project convention that declarations reside in headers
27
+ * and implementations reside in inline files.
28
+ *
29
+ * All definitions reside within the `micro_os_plus::micro_test_plus`
30
+ * namespace, ensuring clear separation from user code and minimising
31
+ * the risk of naming conflicts.
32
+ */
33
+
34
+ #ifndef MICRO_TEST_PLUS_RUNNER_TOTALS_INLINES_H_
35
+ #define MICRO_TEST_PLUS_RUNNER_TOTALS_INLINES_H_
36
+
37
+ // ----------------------------------------------------------------------------
38
+
39
+ #ifdef __cplusplus
40
+
41
+ // ----------------------------------------------------------------------------
42
+
43
+ #if defined(__GNUC__)
44
+ #pragma GCC diagnostic push
45
+ #if defined(__clang__)
46
+ #pragma clang diagnostic ignored "-Wc++98-compat"
47
+ #endif
48
+ #endif
49
+
50
+ // ============================================================================
51
+
52
+ namespace micro_os_plus::micro_test_plus::detail
53
+ {
54
+ // ==========================================================================
55
+
56
+ /**
57
+ * @details
58
+ * Adds `count` to the `successful_checks_` counter.
59
+ */
60
+ inline void
61
+ runner_totals::increment_successful_checks (size_t count) noexcept
62
+ {
63
+ successful_checks_ += count;
64
+ }
65
+
66
+ /**
67
+ * @details
68
+ * Adds `count` to the `failed_checks_` counter.
69
+ */
70
+ inline void
71
+ runner_totals::increment_failed_checks (size_t count) noexcept
72
+ {
73
+ failed_checks_ += count;
74
+ }
75
+
76
+ /**
77
+ * @details
78
+ * Adds `count` to the `executed_subtests_` counter.
79
+ */
80
+ inline void
81
+ runner_totals::increment_executed_subtests (size_t count) noexcept
82
+ {
83
+ executed_subtests_ += count;
84
+ }
85
+
86
+ /**
87
+ * @details
88
+ * Returns the value of the `successful_checks_` counter.
89
+ */
90
+ inline size_t
91
+ runner_totals::successful_checks () const noexcept
92
+ {
93
+ return successful_checks_;
94
+ }
95
+
96
+ /**
97
+ * @details
98
+ * Returns the value of the `failed_checks_` counter.
99
+ */
100
+ inline size_t
101
+ runner_totals::failed_checks () const noexcept
102
+ {
103
+ return failed_checks_;
104
+ }
105
+
106
+ /**
107
+ * @details
108
+ * Returns the sum of `successful_checks_` and `failed_checks_`.
109
+ */
110
+ inline size_t
111
+ runner_totals::executed_checks () const noexcept
112
+ {
113
+ return successful_checks_ + failed_checks_;
114
+ }
115
+
116
+ /**
117
+ * @details
118
+ * Returns the value of the `executed_subtests_` counter.
119
+ */
120
+ inline size_t
121
+ runner_totals::executed_subtests () const noexcept
122
+ {
123
+ return executed_subtests_;
124
+ }
125
+
126
+ /**
127
+ * @details
128
+ * A runner with no checks at all is considered successful, as it
129
+ * did not fail any check.
130
+ */
131
+ inline bool
132
+ runner_totals::was_successful (void) const noexcept
133
+ {
134
+ return failed_checks_ == 0;
135
+ }
136
+
137
+ // --------------------------------------------------------------------------
138
+ } // namespace micro_os_plus::micro_test_plus::detail
139
+
140
+ #if defined(__GNUC__)
141
+ #pragma GCC diagnostic pop
142
+ #endif
143
+
144
+ // ----------------------------------------------------------------------------
145
+
146
+ #endif // __cplusplus
147
+
148
+ // ----------------------------------------------------------------------------
149
+
150
+ #endif // MICRO_TEST_PLUS_RUNNER_TOTALS_INLINES_H_
151
+
152
+ // ----------------------------------------------------------------------------