@micro-os-plus/micro-test-plus 3.3.0 → 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 +339 -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
@@ -1,399 +0,0 @@
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++ source file with implementations for the µTest++ test reporter
21
- * methods.
22
- *
23
- * @details
24
- * This source file contains the core implementations for the test reporting
25
- * facilities of the µTest++ framework. It provides the logic for formatting
26
- * and outputting test results, including operator overloads for a wide range
27
- * of value types, containers, and comparison expressions, as well as
28
- * structured output for logical and exception-related assertions.
29
- *
30
- * The test reporter is responsible for presenting test outcomes in a clear,
31
- * consistent, and expressive manner, supporting both value and pointer
32
- * semantics, and providing detailed diagnostics for both successful and failed
33
- * test cases. Special attention is given to formatting, colour highlighting,
34
- * and extensibility, enabling professional and readable test reports suitable
35
- * for embedded and general C++ development.
36
- *
37
- * All definitions reside within the `micro_os_plus::micro_test_plus`
38
- * namespace, ensuring clear separation from user code and minimising the risk
39
- * of naming conflicts.
40
- *
41
- * This file must be included when building the µTest++ library.
42
- */
43
-
44
- // ----------------------------------------------------------------------------
45
-
46
- #if defined(MICRO_OS_PLUS_INCLUDE_CONFIG_H)
47
- #include <micro-os-plus/config.h>
48
- #endif // MICRO_OS_PLUS_INCLUDE_CONFIG_H
49
-
50
- #include <micro-os-plus/micro-test-plus.h>
51
-
52
- // ----------------------------------------------------------------------------
53
-
54
- #pragma GCC diagnostic ignored "-Waggregate-return"
55
- #if defined(__clang__)
56
- #pragma clang diagnostic ignored "-Wunknown-warning-option"
57
- #pragma clang diagnostic ignored "-Wc++98-compat"
58
- #pragma clang diagnostic ignored "-Wc++98-compat-pedantic"
59
- #endif
60
-
61
- namespace micro_os_plus::micro_test_plus
62
- {
63
- // --------------------------------------------------------------------------
64
-
65
- test_reporter::~test_reporter () = default;
66
-
67
- // --------------------------------------------------------------------------
68
-
69
- /**
70
- * @details
71
- * The `endl` function inserts a newline character into the specified
72
- * `test_reporter` stream and flushes its output buffer. This operation
73
- * ensures that each test output line is clearly separated and immediately
74
- * visible, facilitating the readability and clarity of test results across
75
- * all test cases and folders within the µTest++ framework.
76
- */
77
- test_reporter&
78
- endl (test_reporter& stream)
79
- {
80
- reporter->endline ();
81
- return stream;
82
- }
83
-
84
- /**
85
- * @details
86
- * This operator overload enables manipulators, such as `endl`, to be used
87
- * with the `test_reporter` stream in a manner similar to standard C++
88
- * streams. When a manipulator function is passed, it is invoked with the
89
- * current `test_reporter` instance, allowing for seamless integration of
90
- * stream operations and improved readability of test output across all test
91
- * cases and folders.
92
- */
93
- test_reporter&
94
- test_reporter::operator<< (test_reporter& (*func) (test_reporter&))
95
- {
96
- // Call the endl function.
97
- (*func) (*this);
98
- return *this;
99
- }
100
-
101
- /**
102
- * @details
103
- * This operator overload appends the contents of the provided
104
- * `std::string_view` to the internal output buffer of the `test_reporter`.
105
- * It enables seamless streaming of string data into the reporter, supporting
106
- * clear and efficient formatting of test output across all test cases and
107
- * folders.
108
- */
109
- test_reporter&
110
- test_reporter::operator<< (std::string_view sv)
111
- {
112
- out_.append (sv);
113
- return *this;
114
- }
115
-
116
- /**
117
- * @details
118
- * This operator overload appends the specified character to the internal
119
- * output buffer of the `test_reporter`. It enables efficient streaming of
120
- * individual characters into the reporter, supporting precise and flexible
121
- * formatting of test output across all test cases and folders.
122
- */
123
- test_reporter&
124
- test_reporter::operator<< (char c)
125
- {
126
- out_.append (1, c);
127
- return *this;
128
- }
129
-
130
- /**
131
- * @details
132
- * This operator overload appends the contents of the provided C-style string
133
- * to the internal output buffer of the `test_reporter`. It enables efficient
134
- * streaming of string literals and character arrays into the reporter,
135
- * supporting clear and flexible formatting of test output across all test
136
- * cases and folders.
137
- */
138
- test_reporter&
139
- test_reporter::operator<< (const char* s)
140
- {
141
- out_.append (s);
142
- return *this;
143
- }
144
-
145
- /**
146
- * @details
147
- * This operator overload appends the contents of the provided modifiable
148
- * C-style string to the internal output buffer of the `test_reporter`. It
149
- * enables efficient streaming of mutable string data into the reporter,
150
- * supporting clear and flexible formatting of test output across all test
151
- * cases and folders.
152
- */
153
- test_reporter&
154
- test_reporter::operator<< (char* s)
155
- {
156
- out_.append (s);
157
- return *this;
158
- }
159
-
160
- /**
161
- * @details
162
- * This operator overload appends the string representation of the specified
163
- * boolean value to the internal output buffer of the `test_reporter`. It
164
- * enables clear and direct streaming of boolean results into the reporter,
165
- * supporting precise and readable formatting of test output across all test
166
- * cases and folders.
167
- */
168
- test_reporter&
169
- test_reporter::operator<< (bool v)
170
- {
171
- out_.append (v ? "true" : "false");
172
- return *this;
173
- }
174
-
175
- /**
176
- * @details
177
- * This operator overload appends the string "nullptr" to the internal output
178
- * buffer of the `test_reporter`. It enables clear and explicit streaming of
179
- * null pointer values into the reporter, supporting precise and readable
180
- * formatting of test output across all test cases and folders.
181
- */
182
- test_reporter&
183
- test_reporter::operator<< (std::nullptr_t)
184
- {
185
- out_.append ("nullptr");
186
- return *this;
187
- }
188
-
189
- /**
190
- * @details
191
- * This operator overload appends the string representation of the specified
192
- * signed character to the internal output buffer of the `test_reporter`. It
193
- * enables precise and readable streaming of character values into the
194
- * reporter, supporting clear formatting of test output across all test cases
195
- * and folders.
196
- */
197
- test_reporter&
198
- test_reporter::operator<< (signed char c)
199
- {
200
- out_.append (std::to_string (c));
201
- out_.append ("c");
202
- return *this;
203
- }
204
-
205
- /**
206
- * @details
207
- * This operator overload appends the string representation of the specified
208
- * unsigned character to the internal output buffer of the `test_reporter`.
209
- * It enables precise and readable streaming of unsigned character values
210
- * into the reporter, supporting clear formatting of test output across all
211
- * test cases and folders.
212
- */
213
- test_reporter&
214
- test_reporter::operator<< (unsigned char c)
215
- {
216
- out_.append (std::to_string (static_cast<int> (c)));
217
- out_.append ("uc");
218
- return *this;
219
- }
220
-
221
- /**
222
- * @details
223
- * This operator overload appends the string representation of the specified
224
- * signed short integer to the internal output buffer of the `test_reporter`.
225
- * It enables precise and readable streaming of signed short values into the
226
- * reporter, supporting clear formatting of test output across all test cases
227
- * and folders.
228
- */
229
- test_reporter&
230
- test_reporter::operator<< (signed short v)
231
- {
232
- out_.append (std::to_string (v));
233
- out_.append ("s");
234
- return *this;
235
- }
236
-
237
- /**
238
- * @details
239
- * This operator overload appends the string representation of the specified
240
- * unsigned short integer to the internal output buffer of the
241
- * `test_reporter`. It enables precise and readable streaming of unsigned
242
- * short values into the reporter, supporting clear formatting of test output
243
- * across all test cases and folders.
244
- */
245
- test_reporter&
246
- test_reporter::operator<< (unsigned short v)
247
- {
248
- out_.append (std::to_string (static_cast<long> (v)));
249
- out_.append ("us");
250
- return *this;
251
- }
252
-
253
- /**
254
- * @details
255
- * This operator overload appends the string representation of the specified
256
- * signed integer to the internal output buffer of the `test_reporter`. It
257
- * enables precise and readable streaming of signed integer values into the
258
- * reporter, supporting clear formatting of test output across all test cases
259
- * and folders.
260
- */
261
- test_reporter&
262
- test_reporter::operator<< (signed int v)
263
- {
264
- out_.append (std::to_string (v));
265
- return *this;
266
- }
267
-
268
- /**
269
- * @details
270
- * This operator overload appends the string representation of the specified
271
- * unsigned integer to the internal output buffer of the `test_reporter`. It
272
- * enables precise and readable streaming of unsigned integer values into the
273
- * reporter, supporting clear formatting of test output across all test cases
274
- * and folders.
275
- */
276
- test_reporter&
277
- test_reporter::operator<< (unsigned int v)
278
- {
279
- out_.append (std::to_string (v));
280
- out_.append ("u");
281
- return *this;
282
- }
283
-
284
- /**
285
- * @details
286
- * This operator overload appends the string representation of the specified
287
- * signed long integer to the internal output buffer of the `test_reporter`.
288
- * It enables precise and readable streaming of signed long values into the
289
- * reporter, supporting clear formatting of test output across all test cases
290
- * and folders.
291
- */
292
- test_reporter&
293
- test_reporter::operator<< (signed long v)
294
- {
295
- out_.append (std::to_string (v));
296
- out_.append ("l");
297
- return *this;
298
- }
299
-
300
- /**
301
- * @details
302
- * This operator overload appends the string representation of the specified
303
- * unsigned long integer to the internal output buffer of the
304
- * `test_reporter`. It enables precise and readable streaming of unsigned
305
- * long values into the reporter, supporting clear formatting of test output
306
- * across all test cases and folders.
307
- */
308
- test_reporter&
309
- test_reporter::operator<< (unsigned long v)
310
- {
311
- out_.append (std::to_string (v));
312
- out_.append ("ul");
313
- return *this;
314
- }
315
-
316
- /**
317
- * @details
318
- * This operator overload appends the string representation of the specified
319
- * signed long long integer to the internal output buffer of the
320
- * `test_reporter`. It enables precise and readable streaming of signed long
321
- * long values into the reporter, supporting clear formatting of test output
322
- * across all test cases and folders.
323
- */
324
- test_reporter&
325
- test_reporter::operator<< (signed long long v)
326
- {
327
- out_.append (std::to_string (v));
328
- out_.append ("ll");
329
- return *this;
330
- }
331
-
332
- /**
333
- * @details
334
- * This operator overload appends the string representation of the specified
335
- * unsigned long long integer to the internal output buffer of the
336
- * `test_reporter`. It enables precise and readable streaming of unsigned
337
- * long long values into the reporter, supporting clear formatting of test
338
- * output across all test cases and folders.
339
- */
340
- test_reporter&
341
- test_reporter::operator<< (unsigned long long v)
342
- {
343
- out_.append (std::to_string (v));
344
- out_.append ("ull");
345
- return *this;
346
- }
347
-
348
- /**
349
- * @details
350
- * This operator overload appends the string representation of the specified
351
- * floating-point value to the internal output buffer of the `test_reporter`,
352
- * followed by the character 'f' to indicate a float type. It enables precise
353
- * and readable streaming of float values into the reporter, supporting clear
354
- * formatting of test output across all test cases and folders.
355
- */
356
- test_reporter&
357
- test_reporter::operator<< (float v)
358
- {
359
- out_.append (std::to_string (v));
360
- out_.append ("f");
361
- return *this;
362
- }
363
-
364
- /**
365
- * @details
366
- * This operator overload appends the string representation of the specified
367
- * double-precision floating-point value to the internal output buffer of the
368
- * `test_reporter`. It enables precise and readable streaming of double
369
- * values into the reporter, supporting clear formatting of test output
370
- * across all test cases and folders.
371
- */
372
- test_reporter&
373
- test_reporter::operator<< (double v)
374
- {
375
- out_.append (std::to_string (v));
376
- return *this;
377
- }
378
-
379
- /**
380
- * @details
381
- * This operator overload appends the string representation of the specified
382
- * long double-precision floating-point value to the internal output buffer
383
- * of the `test_reporter`, followed by the character 'l' to indicate a long
384
- * double type. It enables precise and readable streaming of long double
385
- * values into the reporter, supporting clear formatting of test output
386
- * across all test cases and folders.
387
- */
388
- test_reporter&
389
- test_reporter::operator<< (long double v)
390
- {
391
- out_.append (std::to_string (v));
392
- out_.append ("l");
393
- return *this;
394
- }
395
-
396
- // --------------------------------------------------------------------------
397
- } // namespace micro_os_plus::micro_test_plus
398
-
399
- // ----------------------------------------------------------------------------
@@ -1,311 +0,0 @@
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++ source file with implementations for the µTest++ test runner
21
- * methods.
22
- *
23
- * @details
24
- * This source file contains the core implementations for the test runner
25
- * facilities of the µTest++ framework. It provides the logic for initialising
26
- * the test environment, registering and managing test suites, handling
27
- * command-line arguments, orchestrating test execution, and determining the
28
- * overall test result. The implementation supports automated discovery and
29
- * execution of test suites, flexible verbosity control, and robust mechanisms
30
- * for aborting test execution in critical scenarios.
31
- *
32
- * All definitions reside within the `micro_os_plus::micro_test_plus`
33
- * namespace, ensuring clear separation from user code and minimising the risk
34
- * of naming conflicts.
35
- *
36
- * This file must be included when building the µTest++ library.
37
- */
38
-
39
- // ----------------------------------------------------------------------------
40
-
41
- #if defined(MICRO_OS_PLUS_INCLUDE_CONFIG_H)
42
- #include <micro-os-plus/config.h>
43
- #endif // MICRO_OS_PLUS_INCLUDE_CONFIG_H
44
-
45
- #include <micro-os-plus/micro-test-plus.h>
46
-
47
- #include <stdio.h>
48
- #include <stdlib.h>
49
- #include <vector>
50
-
51
- // ----------------------------------------------------------------------------
52
-
53
- #pragma GCC diagnostic ignored "-Waggregate-return"
54
- #if defined(__clang__)
55
- #pragma clang diagnostic ignored "-Wc++98-compat"
56
- #pragma clang diagnostic ignored "-Wc++98-c++11-c++14-compat"
57
- #pragma clang diagnostic ignored "-Wunknown-warning-option"
58
- #endif
59
-
60
- namespace micro_os_plus::micro_test_plus
61
- {
62
- // --------------------------------------------------------------------------
63
-
64
- /**
65
- * @details
66
- * The constructor initialises a new instance of the `test_runner` class,
67
- * preparing the test runner for managing test suites and cases within the
68
- * µTest++ framework. If tracing is enabled, it outputs the function
69
- * signature for diagnostic purposes. This setup ensures the test runner is
70
- * ready to coordinate the registration, execution, and reporting of tests
71
- * across all test cases and folders.
72
- */
73
- test_runner::test_runner ()
74
- {
75
- #if defined(MICRO_OS_PLUS_TRACE_MICRO_TEST_PLUS)
76
- printf ("%s\n", __PRETTY_FUNCTION__);
77
- #endif // MICRO_OS_PLUS_TRACE_MICRO_TEST_PLUS
78
- }
79
-
80
- #pragma GCC diagnostic push
81
- #if defined(__clang__)
82
- #pragma clang diagnostic ignored "-Wunsafe-buffer-usage"
83
- #endif
84
- /**
85
- * @details
86
- * This method initialises the test runner by capturing the command-line
87
- * arguments and the default test suite name, configuring the framework for
88
- * subsequent test execution. It parses the arguments to determine the
89
- * desired verbosity level (normal, verbose, quiet, or silent) and applies
90
- * this setting to the test reporter. The method also outputs build and
91
- * environment information when appropriate, aiding diagnostics and
92
- * transparency. Finally, it creates and registers the default test suite,
93
- * preparing the framework to manage and execute all test cases and suites
94
- * across the project’s folders.
95
- */
96
- void
97
- test_runner::initialize (int argc, char* argv[], const char* name)
98
- {
99
- #if defined(MICRO_OS_PLUS_TRACE_MICRO_TEST_PLUS)
100
- printf ("%s\n", __PRETTY_FUNCTION__);
101
- #endif // MICRO_OS_PLUS_TRACE_MICRO_TEST_PLUS
102
-
103
- #if defined(_WIN32) || defined(CLOCK_MONOTONIC)
104
- #if defined(_WIN32)
105
- timespec_get (&begin_time, TIME_UTC);
106
- #else
107
- clock_gettime (CLOCK_MONOTONIC, &begin_time);
108
- #endif
109
- #endif
110
-
111
- argc_ = argc;
112
- argv_ = argv;
113
-
114
- default_suite_name_ = name;
115
-
116
- #if !(defined(MICRO_OS_PLUS_INCLUDE_STARTUP) && defined(MICRO_OS_PLUS_TRACE))
117
- #if defined(MICRO_OS_PLUS_DEBUG)
118
- printf ("argv[");
119
- for (int i = 0; i < argc; ++i)
120
- {
121
- if (i > 0)
122
- {
123
- printf (", ");
124
- }
125
- printf ("'%s'", argv[i]);
126
- }
127
- puts ("]");
128
- #endif // defined(MICRO_OS_PLUS_DEBUG)
129
- #endif // !defined(MICRO_OS_PLUS_INCLUDE_STARTUP)
130
-
131
- verbosity_t verbosity = verbosity::normal;
132
- const char* reporter_name = "tap";
133
- for (int i = 0; i < argc; ++i)
134
- {
135
- if (strcmp (argv[i], "--verbose") == 0)
136
- {
137
- verbosity = verbosity::verbose;
138
- }
139
- else if (strcmp (argv[i], "--quiet") == 0)
140
- {
141
- verbosity = verbosity::quiet;
142
- }
143
- else if (strcmp (argv[i], "--silent") == 0)
144
- {
145
- verbosity = verbosity::silent;
146
- }
147
- else if (strncmp (argv[i], "--reporter=", 11) == 0)
148
- {
149
- reporter_name = argv[i] + 11;
150
- }
151
- }
152
-
153
- // Initialize and configure the reporter.
154
- if (strcmp (reporter_name, "basic") == 0)
155
- {
156
- reporter = new test_reporter_basic ();
157
- }
158
- else if (strcmp (reporter_name, "tap") == 0)
159
- {
160
- reporter = new test_reporter_tap ();
161
- }
162
- else
163
- {
164
- fprintf (stderr, "error: unknown reporter '%s'\n", reporter_name);
165
- exit (1);
166
- }
167
- reporter->verbosity = verbosity;
168
-
169
- // ------------------------------------------------------------------------
170
-
171
- #if !(defined(MICRO_OS_PLUS_INCLUDE_STARTUP) && defined(MICRO_OS_PLUS_TRACE))
172
- if (verbosity == verbosity::normal || verbosity == verbosity::verbose)
173
- {
174
- #if defined(__clang__)
175
- printf ("Built with clang " __VERSION__);
176
- #elif defined(__GNUC__)
177
- printf ("Built with GCC " __VERSION__);
178
- #elif defined(_MSC_VER)
179
- // https://docs.microsoft.com/en-us/cpp/preprocessor/predefined-macros?view=msvc-170
180
- printf ("Built with MSVC %d", _MSC_VER);
181
- #else
182
- printf ("Built with an unknown compiler");
183
- #endif
184
- #if !(defined(__APPLE__) || defined(__linux__) || defined(__unix__) \
185
- || defined(WIN32))
186
- // This is relevant only on bare-metal.
187
- #if defined(__ARM_PCS_VFP) || defined(__ARM_FP)
188
- printf (", with FP");
189
- #else
190
- printf (", no FP");
191
- #endif
192
- #endif
193
- #if defined(__EXCEPTIONS)
194
- printf (", with exceptions");
195
- #else
196
- printf (", no exceptions");
197
- #endif
198
- #if defined(MICRO_OS_PLUS_DEBUG)
199
- printf (", with MICRO_OS_PLUS_DEBUG");
200
- #endif
201
- puts (".");
202
- }
203
- #endif // !defined(MICRO_OS_PLUS_INCLUDE_STARTUP)
204
-
205
- // ------------------------------------------------------------------------
206
-
207
- default_test_suite = new test_suite_base (default_suite_name_);
208
- current_test_suite = default_test_suite;
209
-
210
- // Deferred to first test case or test suite end, to allow various
211
- // initialisations to display their messages.
212
- // reporter->begin_test (test_suites_count ());
213
- // default_test_suite_->begin_test_suite ();
214
- }
215
- #pragma GCC diagnostic pop
216
-
217
- int
218
- test_runner::exit_code (void)
219
- {
220
- bool was_successful = true;
221
-
222
- if (!default_test_suite->unused ())
223
- {
224
- default_test_suite->end_test_suite ();
225
- was_successful = default_test_suite->was_successful ();
226
-
227
- totals.successful_checks += default_test_suite->successful_checks ();
228
- totals.failed_checks += default_test_suite->failed_checks ();
229
- totals.test_cases_count += default_test_suite->test_cases_count ();
230
- }
231
-
232
- if (test_suites != nullptr)
233
- {
234
- for (auto test_suite : *test_suites)
235
- {
236
- current_test_suite = test_suite;
237
-
238
- test_suite->begin_test_suite ();
239
- test_suite->run ();
240
- test_suite->end_test_suite ();
241
-
242
- was_successful &= test_suite->was_successful ();
243
-
244
- totals.successful_checks += test_suite->successful_checks ();
245
- totals.failed_checks += test_suite->failed_checks ();
246
- totals.test_cases_count += test_suite->test_cases_count ();
247
- }
248
- if (reporter->verbosity != verbosity::silent)
249
- {
250
- // printf ("\n");
251
- }
252
- }
253
-
254
- #if defined(_WIN32) || defined(CLOCK_MONOTONIC)
255
- #if defined(_WIN32)
256
- timespec_get (&end_time, TIME_UTC);
257
- #else
258
- clock_gettime (CLOCK_MONOTONIC, &end_time);
259
- #endif
260
- #endif
261
-
262
- reporter->end_test (*this);
263
-
264
- return was_successful ? 0 : 1;
265
- }
266
-
267
- /**
268
- * @details
269
- * This method registers a new test suite with the test runner. If the
270
- * internal collection of test suites has not yet been created, it is
271
- * initialised at this point. The provided test suite is then added to the
272
- * collection, enabling the framework to manage and execute multiple test
273
- * suites across different files and folders within the project.
274
- *
275
- * Called by test suite constructors to register themselves with the
276
- * runner, enabling automatic management and execution.
277
- */
278
- void
279
- test_runner::register_test_suite (test_suite_base* suite)
280
- {
281
- #if 0 // defined(MICRO_OS_PLUS_TRACE_MICRO_TEST_PLUS)
282
- printf ("%s\n", __PRETTY_FUNCTION__);
283
- #endif // MICRO_OS_PLUS_TRACE_MICRO_TEST_PLUS
284
-
285
- if (test_suites == nullptr)
286
- {
287
- test_suites = new std::vector<test_suite_base*> ();
288
- }
289
- test_suites->push_back (suite);
290
- suite->index = test_suites->size () + 1;
291
- }
292
-
293
- /**
294
- * @details
295
- * This method immediately terminates the process by invoking the standard C
296
- * library `abort()` function. It is used to halt test execution in critical
297
- * failure scenarios, ensuring that no further tests are run and that the
298
- * cause of the failure can be promptly investigated. This approach provides
299
- * a robust mechanism for enforcing strict test outcomes across all test
300
- * cases and folders.
301
- */
302
- void
303
- test_runner::abort (void)
304
- {
305
- ::abort ();
306
- }
307
-
308
- // --------------------------------------------------------------------------
309
- } // namespace micro_os_plus::micro_test_plus
310
-
311
- // ----------------------------------------------------------------------------