@micro-os-plus/micro-test-plus 3.2.2 → 3.2.3

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 (41) hide show
  1. package/.cmake-format.yaml +11 -0
  2. package/CHANGELOG.md +352 -2
  3. package/CMakeLists.txt +32 -30
  4. package/LICENSE +1 -1
  5. package/README.md +1 -1
  6. package/{xcdl.json → config/xcdl-build.json} +6 -6
  7. package/include/micro-os-plus/micro-test-plus/detail.h +1885 -0
  8. package/include/micro-os-plus/micro-test-plus/function-comparators.h +333 -0
  9. package/include/micro-os-plus/micro-test-plus/inlines/details-inlines.h +172 -0
  10. package/include/micro-os-plus/micro-test-plus/inlines/function-comparators-inlines.h +341 -0
  11. package/include/micro-os-plus/micro-test-plus/inlines/literals-inlines.h +604 -0
  12. package/include/micro-os-plus/micro-test-plus/inlines/math-inlines.h +315 -0
  13. package/include/micro-os-plus/micro-test-plus/inlines/micro-test-plus-inlines.h +313 -0
  14. package/include/micro-os-plus/micro-test-plus/inlines/reflection-inlines.h +170 -0
  15. package/include/micro-os-plus/micro-test-plus/inlines/test-reporter-inlines.h +471 -0
  16. package/include/micro-os-plus/micro-test-plus/inlines/test-suite-inlines.h +115 -0
  17. package/include/micro-os-plus/micro-test-plus/literals.h +912 -0
  18. package/include/micro-os-plus/micro-test-plus/math.h +217 -0
  19. package/include/micro-os-plus/micro-test-plus/operators.h +514 -0
  20. package/include/micro-os-plus/micro-test-plus/reflection.h +233 -0
  21. package/include/micro-os-plus/micro-test-plus/test-reporter.h +801 -0
  22. package/include/micro-os-plus/micro-test-plus/test-runner.h +241 -0
  23. package/include/micro-os-plus/micro-test-plus/test-suite.h +456 -0
  24. package/include/micro-os-plus/micro-test-plus/type-traits.h +1148 -0
  25. package/include/micro-os-plus/micro-test-plus.h +169 -551
  26. package/meson.build +5 -5
  27. package/package.json +29 -34
  28. package/src/micro-test-plus.cpp +131 -35
  29. package/src/test-reporter.cpp +348 -6
  30. package/src/test-runner.cpp +69 -5
  31. package/src/test-suite.cpp +124 -5
  32. package/include/micro-os-plus/detail.h +0 -765
  33. package/include/micro-os-plus/inlines.h +0 -209
  34. package/include/micro-os-plus/literals.h +0 -512
  35. package/include/micro-os-plus/math.h +0 -204
  36. package/include/micro-os-plus/reflection.h +0 -139
  37. package/include/micro-os-plus/test-reporter-inlines.h +0 -230
  38. package/include/micro-os-plus/test-reporter.h +0 -356
  39. package/include/micro-os-plus/test-runner.h +0 -132
  40. package/include/micro-os-plus/test-suite.h +0 -306
  41. package/include/micro-os-plus/type-traits.h +0 -389
@@ -0,0 +1,233 @@
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 declarations for the µTest++ reflection
21
+ * utilities.
22
+ *
23
+ * @details
24
+ * This header provides the declarations for the reflection utilities used
25
+ * within the µTest++ framework. It defines interfaces for obtaining source
26
+ * location information and extracting type names at compile time, supporting
27
+ * advanced diagnostics and reporting capabilities.
28
+ *
29
+ * The reflection utilities include a local implementation of `source_location`
30
+ * for environments lacking C++20 standard support, as well as functions for
31
+ * extracting concise type names using compiler-specific macros such as
32
+ * `__PRETTY_FUNCTION__`. These facilities enable precise identification of
33
+ * code locations and types in test reports, enhancing the clarity and
34
+ * professionalism of diagnostic output.
35
+ *
36
+ * All definitions reside within the
37
+ * `micro_os_plus::micro_test_plus::reflection` namespace, ensuring clear
38
+ * separation from user code and minimising the risk of naming conflicts.
39
+ *
40
+ * The header files are organised within the
41
+ * `include/micro-os-plus/micro-test-plus` folder to maintain a structured and
42
+ * modular codebase.
43
+ *
44
+ * This file is intended solely for internal use within the framework and
45
+ * should not be included directly by user code.
46
+ */
47
+
48
+ #ifndef MICRO_TEST_PLUS_REFLECTION_H_
49
+ #define MICRO_TEST_PLUS_REFLECTION_H_
50
+
51
+ // ----------------------------------------------------------------------------
52
+
53
+ #ifdef __cplusplus
54
+
55
+ // ----------------------------------------------------------------------------
56
+
57
+ #include <string_view>
58
+
59
+ #if defined(__cpp_lib_source_location)
60
+ #include <source_location>
61
+ #endif
62
+
63
+ // ----------------------------------------------------------------------------
64
+
65
+ #if defined(__GNUC__)
66
+ #pragma GCC diagnostic push
67
+ #pragma GCC diagnostic ignored "-Wpadded"
68
+ #pragma GCC diagnostic ignored "-Waggregate-return"
69
+ #if defined(__clang__)
70
+ #pragma clang diagnostic ignored "-Wc++98-compat"
71
+ #pragma clang diagnostic ignored "-Wunknown-warning-option"
72
+ #endif
73
+ #endif
74
+
75
+ namespace micro_os_plus::micro_test_plus
76
+ {
77
+ // --------------------------------------------------------------------------
78
+
79
+ /**
80
+ * @namespace micro_os_plus::micro_test_plus::reflection
81
+ * @brief Reflection utilities for the µTest++ testing framework.
82
+ *
83
+ * @details
84
+ * The `reflection` namespace provides facilities for obtaining source
85
+ * location information and type names at compile time, thereby supporting
86
+ * advanced reporting and diagnostics within the µTest++ framework.
87
+ *
88
+ * It includes a local implementation of `source_location` for environments
89
+ * lacking C++20 standard support, as well as utilities for extracting
90
+ * concise type names from compiler-specific macros such as
91
+ * `__PRETTY_FUNCTION__`.
92
+ *
93
+ * All definitions within this namespace are intended to facilitate advanced
94
+ * reflection and reporting capabilities.
95
+ */
96
+ namespace reflection
97
+ {
98
+ // ------------------------------------------------------------------------
99
+
100
+ #if defined(__cpp_lib_source_location)
101
+ /**
102
+ * @brief Alias for source location information.
103
+ *
104
+ * @details
105
+ * The `source_location` type provides access to source code location
106
+ * details, such as file name and line number, for enhanced diagnostics and
107
+ * reporting within the µTest++ framework. When C++20 standard support is
108
+ * available, this alias refers to `std::source_location`; otherwise, a
109
+ * local implementation is used to ensure consistent functionality across
110
+ * all supported environments. This abstraction enables precise
111
+ * identification of code locations in test reports, supporting clear and
112
+ * professional diagnostics across all files and folders.
113
+ */
114
+ using source_location = std::source_location;
115
+ #else
116
+ /**
117
+ * @brief Local implementation of source location information for
118
+ * diagnostics.
119
+ *
120
+ * @details
121
+ * This class provides a lightweight, constexpr-compatible alternative to
122
+ * `std::source_location` for environments lacking C++20 standard support.
123
+ *
124
+ * It enables retrieval of the file name and line number at the point of
125
+ * invocation, supporting enhanced diagnostics and reporting within the
126
+ * µTest++ framework.
127
+ *
128
+ * The static `current()` method captures the current source location,
129
+ * using compiler built-ins where available, or defaulting to `"unknown"`
130
+ * and zero otherwise.
131
+ *
132
+ * @since 3.0.0
133
+ *
134
+ * @headerfile micro-test-plus.h <micro-os-plus/micro-test-plus.h>
135
+ */
136
+ class source_location
137
+ {
138
+ public:
139
+ /**
140
+ * @brief Obtain the current source location.
141
+ *
142
+ * @param file The file name (automatically provided by the compiler).
143
+ * @param line The line number (automatically provided by the compiler).
144
+ * @return A `source_location` instance with the captured information.
145
+ */
146
+ [[nodiscard]] static constexpr source_location
147
+ current (
148
+ #if (__has_builtin(__builtin_FILE) and __has_builtin(__builtin_LINE))
149
+ const char* file = __builtin_FILE (),
150
+ unsigned int line = __builtin_LINE ()
151
+ #else
152
+ const char* file = "unknown", unsigned int line = {}
153
+ #endif
154
+ ) noexcept;
155
+
156
+ /**
157
+ * @brief Retrieve the file name associated with this source location.
158
+ *
159
+ * @par Parameters
160
+ * None.
161
+ * @return The file name as a constant character pointer.
162
+ */
163
+ [[nodiscard]] constexpr auto
164
+ file_name (void) const noexcept;
165
+
166
+ /**
167
+ * @brief Retrieve the line number associated with this source location.
168
+ *
169
+ * @par Parameters
170
+ * None.
171
+ * @return The line number as an unsigned integer.
172
+ */
173
+ [[nodiscard]] constexpr auto
174
+ line (void) const noexcept;
175
+
176
+ private:
177
+ /**
178
+ * @brief The file name where the source location was captured.
179
+ */
180
+ const char* file_{ "unknown" };
181
+
182
+ /**
183
+ * @brief The line number where the source location was captured.
184
+ */
185
+ unsigned int line_{};
186
+ };
187
+
188
+ #endif
189
+
190
+ /**
191
+ * @brief Extract a short type or function name from a fully qualified
192
+ * name.
193
+ *
194
+ * @param name The fully qualified name as a C-string.
195
+ * @return A pointer to the short name within the input string.
196
+ */
197
+ const char*
198
+ short_name (const char* name);
199
+
200
+ // TODO: update for the new namespaces.
201
+
202
+ /**
203
+ * @brief Extract the type name from the `__PRETTY_FUNCTION__` macro.
204
+ *
205
+ * @tparam T The type whose name is to be extracted.
206
+ *
207
+ * @par Parameters
208
+ * None.
209
+ * @return A `std::string_view` containing the extracted type name.
210
+ */
211
+ template <class T>
212
+ [[nodiscard]] constexpr auto
213
+ type_name (void) -> std::string_view;
214
+
215
+ // ------------------------------------------------------------------------
216
+ } // namespace reflection
217
+
218
+ // --------------------------------------------------------------------------
219
+ } // namespace micro_os_plus::micro_test_plus
220
+
221
+ #if defined(__GNUC__)
222
+ #pragma GCC diagnostic pop
223
+ #endif
224
+
225
+ // ----------------------------------------------------------------------------
226
+
227
+ #endif // __cplusplus
228
+
229
+ // ----------------------------------------------------------------------------
230
+
231
+ #endif // MICRO_TEST_PLUS_REFLECTION_H_
232
+
233
+ // ----------------------------------------------------------------------------