@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
@@ -1,12 +1,12 @@
1
1
  /*
2
2
  * This file is part of the µOS++ project (https://micro-os-plus.github.io/).
3
- * Copyright (c) 2021 Liviu Ionescu. All rights reserved.
3
+ * Copyright (c) 2021-2026 Liviu Ionescu. All rights reserved.
4
4
  *
5
- * Permission to use, copy, modify, and/or distribute this software
6
- * for any purpose is hereby granted, under the terms of the MIT license.
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
7
  *
8
- * If a copy of the license was not distributed with this file, it can
9
- * be obtained from https://opensource.org/licenses/mit.
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
10
  *
11
11
  * Major parts of the code are inspired from v1.1.8 of the Boost UT project,
12
12
  * released under the terms of the Boost Version 1.0 Software License,
@@ -15,6 +15,34 @@
15
15
 
16
16
  // ----------------------------------------------------------------------------
17
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
+
18
46
  #if defined(MICRO_OS_PLUS_INCLUDE_CONFIG_H)
19
47
  #include <micro-os-plus/config.h>
20
48
  #endif // MICRO_OS_PLUS_INCLUDE_CONFIG_H
@@ -25,6 +53,7 @@
25
53
 
26
54
  #pragma GCC diagnostic ignored "-Waggregate-return"
27
55
  #if defined(__clang__)
56
+ #pragma clang diagnostic ignored "-Wunknown-warning-option"
28
57
  #pragma clang diagnostic ignored "-Wc++98-compat"
29
58
  #pragma clang diagnostic ignored "-Wc++98-compat-pedantic"
30
59
  #endif
@@ -33,6 +62,14 @@ namespace micro_os_plus::micro_test_plus
33
62
  {
34
63
  // --------------------------------------------------------------------------
35
64
 
65
+ /**
66
+ * @details
67
+ * The `endl` function inserts a newline character into the specified
68
+ * `test_reporter` stream and flushes its output buffer. This operation
69
+ * ensures that each test output line is clearly separated and immediately
70
+ * visible, facilitating the readability and clarity of test results across
71
+ * all test cases and folders within the µTest++ framework.
72
+ */
36
73
  test_reporter&
37
74
  endl (test_reporter& stream)
38
75
  {
@@ -42,6 +79,18 @@ namespace micro_os_plus::micro_test_plus
42
79
 
43
80
  // --------------------------------------------------------------------------
44
81
 
82
+ /**
83
+ * @details
84
+ * This method outputs the prefix for a passing test result, applying the
85
+ * appropriate colour formatting and symbols to clearly indicate success. If
86
+ * the output occurs within a test case, additional indentation is applied
87
+ * for readability. The prefix includes a tick symbol (`✓`) and, if provided,
88
+ * an associated message. Colour formatting is reset after the prefix to
89
+ * maintain consistent output style across all test cases and folders.
90
+ *
91
+ * The prefix/suffix methods help shorten the code
92
+ * generated by the template methods.
93
+ */
45
94
  void
46
95
  test_reporter::output_pass_prefix_ (std::string& message)
47
96
  {
@@ -58,6 +107,21 @@ namespace micro_os_plus::micro_test_plus
58
107
  }
59
108
  }
60
109
 
110
+ /**
111
+ * @details
112
+ * The `endl` function acts as a stream manipulator for the `test_reporter`,
113
+ * inserting a line ending into the output buffer and flushing the current
114
+ * content if necessary. This ensures that test report output is clearly
115
+ * separated and formatted, improving readability and professionalism in the
116
+ * presentation of test results.
117
+ *
118
+ * Using `endl` in conjunction with the `test_reporter` output operators
119
+ * provides a familiar and convenient mechanism for managing line breaks,
120
+ * similar to standard C++ stream manipulators.
121
+ *
122
+ * The prefix/suffix methods help shorten the code
123
+ * generated by the template methods.
124
+ */
61
125
  void
62
126
  test_reporter::output_pass_suffix_ (void)
63
127
  {
@@ -66,6 +130,17 @@ namespace micro_os_plus::micro_test_plus
66
130
  flush ();
67
131
  }
68
132
 
133
+ /**
134
+ * @details
135
+ * This method outputs the prefix for a failing test result, applying the
136
+ * appropriate colour formatting and symbols to clearly indicate failure. If
137
+ * the output occurs within a test case, additional indentation is applied
138
+ * for readability. The prefix includes a cross symbol (`✗`), an optional
139
+ * message, and the label "FAILED". The source location is appended in
140
+ * parentheses, showing the file or folder name and line number where the
141
+ * failure occurred. Colour formatting is reset after the prefix to maintain
142
+ * consistent output style across all test cases and folders.
143
+ */
69
144
  void
70
145
  test_reporter::output_fail_prefix_ (
71
146
  std::string& message, const reflection::source_location& location)
@@ -97,6 +172,15 @@ namespace micro_os_plus::micro_test_plus
97
172
  #pragma GCC diagnostic pop
98
173
  }
99
174
 
175
+ /**
176
+ * @details
177
+ * This method outputs the suffix for a failing test result by closing the
178
+ * location information, appending an "aborted..." message if the test was
179
+ * aborted, and then adding a newline to the test output. The output stream
180
+ * is flushed to ensure immediate visibility. This approach guarantees that
181
+ * failure results are clearly separated, promptly reported, and easily
182
+ * distinguishable across all test cases and folders.
183
+ */
100
184
  void
101
185
  test_reporter::output_fail_suffix_ (bool abort)
102
186
  {
@@ -110,6 +194,15 @@ namespace micro_os_plus::micro_test_plus
110
194
  flush ();
111
195
  }
112
196
 
197
+ /**
198
+ * @details
199
+ * This operator overload enables manipulators, such as `endl`, to be used
200
+ * with the `test_reporter` stream in a manner similar to standard C++
201
+ * streams. When a manipulator function is passed, it is invoked with the
202
+ * current `test_reporter` instance, allowing for seamless integration of
203
+ * stream operations and improved readability of test output across all test
204
+ * cases and folders.
205
+ */
113
206
  test_reporter&
114
207
  test_reporter::operator<< (test_reporter& (*func) (test_reporter&))
115
208
  {
@@ -118,6 +211,14 @@ namespace micro_os_plus::micro_test_plus
118
211
  return *this;
119
212
  }
120
213
 
214
+ /**
215
+ * @details
216
+ * This method appends a newline character to the internal output buffer of
217
+ * the `test_reporter` and immediately flushes the stream. This ensures that
218
+ * each line of test output is clearly separated and promptly displayed,
219
+ * enhancing the readability and organisation of test results across all test
220
+ * cases and folders.
221
+ */
121
222
  void
122
223
  test_reporter::endline (void)
123
224
  {
@@ -125,12 +226,27 @@ namespace micro_os_plus::micro_test_plus
125
226
  flush ();
126
227
  }
127
228
 
229
+ /**
230
+ * @details
231
+ * This method flushes the output buffer of the `test_reporter` by
232
+ * synchronising it with the standard output stream. This guarantees that all
233
+ * pending test output is immediately written and visible, ensuring prompt
234
+ * and reliable reporting of test results across all test cases and folders.
235
+ */
128
236
  void
129
237
  test_reporter::flush (void)
130
238
  {
131
239
  fflush (stdout); // Sync STDOUT.
132
240
  }
133
241
 
242
+ /**
243
+ * @details
244
+ * This operator overload appends the contents of the provided
245
+ * `std::string_view` to the internal output buffer of the `test_reporter`.
246
+ * It enables seamless streaming of string data into the reporter, supporting
247
+ * clear and efficient formatting of test output across all test cases and
248
+ * folders.
249
+ */
134
250
  test_reporter&
135
251
  test_reporter::operator<< (std::string_view sv)
136
252
  {
@@ -138,6 +254,13 @@ namespace micro_os_plus::micro_test_plus
138
254
  return *this;
139
255
  }
140
256
 
257
+ /**
258
+ * @details
259
+ * This operator overload appends the specified character to the internal
260
+ * output buffer of the `test_reporter`. It enables efficient streaming of
261
+ * individual characters into the reporter, supporting precise and flexible
262
+ * formatting of test output across all test cases and folders.
263
+ */
141
264
  test_reporter&
142
265
  test_reporter::operator<< (char c)
143
266
  {
@@ -145,6 +268,14 @@ namespace micro_os_plus::micro_test_plus
145
268
  return *this;
146
269
  }
147
270
 
271
+ /**
272
+ * @details
273
+ * This operator overload appends the contents of the provided C-style string
274
+ * to the internal output buffer of the `test_reporter`. It enables efficient
275
+ * streaming of string literals and character arrays into the reporter,
276
+ * supporting clear and flexible formatting of test output across all test
277
+ * cases and folders.
278
+ */
148
279
  test_reporter&
149
280
  test_reporter::operator<< (const char* s)
150
281
  {
@@ -152,6 +283,14 @@ namespace micro_os_plus::micro_test_plus
152
283
  return *this;
153
284
  }
154
285
 
286
+ /**
287
+ * @details
288
+ * This operator overload appends the contents of the provided modifiable
289
+ * C-style string to the internal output buffer of the `test_reporter`. It
290
+ * enables efficient streaming of mutable string data into the reporter,
291
+ * supporting clear and flexible formatting of test output across all test
292
+ * cases and folders.
293
+ */
155
294
  test_reporter&
156
295
  test_reporter::operator<< (char* s)
157
296
  {
@@ -159,6 +298,14 @@ namespace micro_os_plus::micro_test_plus
159
298
  return *this;
160
299
  }
161
300
 
301
+ /**
302
+ * @details
303
+ * This operator overload appends the string representation of the specified
304
+ * boolean value to the internal output buffer of the `test_reporter`. It
305
+ * enables clear and direct streaming of boolean results into the reporter,
306
+ * supporting precise and readable formatting of test output across all test
307
+ * cases and folders.
308
+ */
162
309
  test_reporter&
163
310
  test_reporter::operator<< (bool v)
164
311
  {
@@ -166,6 +313,13 @@ namespace micro_os_plus::micro_test_plus
166
313
  return *this;
167
314
  }
168
315
 
316
+ /**
317
+ * @details
318
+ * This operator overload appends the string "nullptr" to the internal output
319
+ * buffer of the `test_reporter`. It enables clear and explicit streaming of
320
+ * null pointer values into the reporter, supporting precise and readable
321
+ * formatting of test output across all test cases and folders.
322
+ */
169
323
  test_reporter&
170
324
  test_reporter::operator<< (std::nullptr_t)
171
325
  {
@@ -173,6 +327,14 @@ namespace micro_os_plus::micro_test_plus
173
327
  return *this;
174
328
  }
175
329
 
330
+ /**
331
+ * @details
332
+ * This operator overload appends the string representation of the specified
333
+ * signed character to the internal output buffer of the `test_reporter`. It
334
+ * enables precise and readable streaming of character values into the
335
+ * reporter, supporting clear formatting of test output across all test cases
336
+ * and folders.
337
+ */
176
338
  test_reporter&
177
339
  test_reporter::operator<< (signed char c)
178
340
  {
@@ -181,6 +343,14 @@ namespace micro_os_plus::micro_test_plus
181
343
  return *this;
182
344
  }
183
345
 
346
+ /**
347
+ * @details
348
+ * This operator overload appends the string representation of the specified
349
+ * unsigned character to the internal output buffer of the `test_reporter`.
350
+ * It enables precise and readable streaming of unsigned character values
351
+ * into the reporter, supporting clear formatting of test output across all
352
+ * test cases and folders.
353
+ */
184
354
  test_reporter&
185
355
  test_reporter::operator<< (unsigned char c)
186
356
  {
@@ -189,6 +359,14 @@ namespace micro_os_plus::micro_test_plus
189
359
  return *this;
190
360
  }
191
361
 
362
+ /**
363
+ * @details
364
+ * This operator overload appends the string representation of the specified
365
+ * signed short integer to the internal output buffer of the `test_reporter`.
366
+ * It enables precise and readable streaming of signed short values into the
367
+ * reporter, supporting clear formatting of test output across all test cases
368
+ * and folders.
369
+ */
192
370
  test_reporter&
193
371
  test_reporter::operator<< (signed short v)
194
372
  {
@@ -197,6 +375,14 @@ namespace micro_os_plus::micro_test_plus
197
375
  return *this;
198
376
  }
199
377
 
378
+ /**
379
+ * @details
380
+ * This operator overload appends the string representation of the specified
381
+ * unsigned short integer to the internal output buffer of the
382
+ * `test_reporter`. It enables precise and readable streaming of unsigned
383
+ * short values into the reporter, supporting clear formatting of test output
384
+ * across all test cases and folders.
385
+ */
200
386
  test_reporter&
201
387
  test_reporter::operator<< (unsigned short v)
202
388
  {
@@ -205,6 +391,14 @@ namespace micro_os_plus::micro_test_plus
205
391
  return *this;
206
392
  }
207
393
 
394
+ /**
395
+ * @details
396
+ * This operator overload appends the string representation of the specified
397
+ * signed integer to the internal output buffer of the `test_reporter`. It
398
+ * enables precise and readable streaming of signed integer values into the
399
+ * reporter, supporting clear formatting of test output across all test cases
400
+ * and folders.
401
+ */
208
402
  test_reporter&
209
403
  test_reporter::operator<< (signed int v)
210
404
  {
@@ -212,6 +406,14 @@ namespace micro_os_plus::micro_test_plus
212
406
  return *this;
213
407
  }
214
408
 
409
+ /**
410
+ * @details
411
+ * This operator overload appends the string representation of the specified
412
+ * unsigned integer to the internal output buffer of the `test_reporter`. It
413
+ * enables precise and readable streaming of unsigned integer values into the
414
+ * reporter, supporting clear formatting of test output across all test cases
415
+ * and folders.
416
+ */
215
417
  test_reporter&
216
418
  test_reporter::operator<< (unsigned int v)
217
419
  {
@@ -220,6 +422,14 @@ namespace micro_os_plus::micro_test_plus
220
422
  return *this;
221
423
  }
222
424
 
425
+ /**
426
+ * @details
427
+ * This operator overload appends the string representation of the specified
428
+ * signed long integer to the internal output buffer of the `test_reporter`.
429
+ * It enables precise and readable streaming of signed long values into the
430
+ * reporter, supporting clear formatting of test output across all test cases
431
+ * and folders.
432
+ */
223
433
  test_reporter&
224
434
  test_reporter::operator<< (signed long v)
225
435
  {
@@ -228,6 +438,14 @@ namespace micro_os_plus::micro_test_plus
228
438
  return *this;
229
439
  }
230
440
 
441
+ /**
442
+ * @details
443
+ * This operator overload appends the string representation of the specified
444
+ * unsigned long integer to the internal output buffer of the
445
+ * `test_reporter`. It enables precise and readable streaming of unsigned
446
+ * long values into the reporter, supporting clear formatting of test output
447
+ * across all test cases and folders.
448
+ */
231
449
  test_reporter&
232
450
  test_reporter::operator<< (unsigned long v)
233
451
  {
@@ -236,6 +454,14 @@ namespace micro_os_plus::micro_test_plus
236
454
  return *this;
237
455
  }
238
456
 
457
+ /**
458
+ * @details
459
+ * This operator overload appends the string representation of the specified
460
+ * signed long long integer to the internal output buffer of the
461
+ * `test_reporter`. It enables precise and readable streaming of signed long
462
+ * long values into the reporter, supporting clear formatting of test output
463
+ * across all test cases and folders.
464
+ */
239
465
  test_reporter&
240
466
  test_reporter::operator<< (signed long long v)
241
467
  {
@@ -244,6 +470,14 @@ namespace micro_os_plus::micro_test_plus
244
470
  return *this;
245
471
  }
246
472
 
473
+ /**
474
+ * @details
475
+ * This operator overload appends the string representation of the specified
476
+ * unsigned long long integer to the internal output buffer of the
477
+ * `test_reporter`. It enables precise and readable streaming of unsigned
478
+ * long long values into the reporter, supporting clear formatting of test
479
+ * output across all test cases and folders.
480
+ */
247
481
  test_reporter&
248
482
  test_reporter::operator<< (unsigned long long v)
249
483
  {
@@ -252,6 +486,14 @@ namespace micro_os_plus::micro_test_plus
252
486
  return *this;
253
487
  }
254
488
 
489
+ /**
490
+ * @details
491
+ * This operator overload appends the string representation of the specified
492
+ * floating-point value to the internal output buffer of the `test_reporter`,
493
+ * followed by the character 'f' to indicate a float type. It enables precise
494
+ * and readable streaming of float values into the reporter, supporting clear
495
+ * formatting of test output across all test cases and folders.
496
+ */
255
497
  test_reporter&
256
498
  test_reporter::operator<< (float v)
257
499
  {
@@ -260,6 +502,14 @@ namespace micro_os_plus::micro_test_plus
260
502
  return *this;
261
503
  }
262
504
 
505
+ /**
506
+ * @details
507
+ * This operator overload appends the string representation of the specified
508
+ * double-precision floating-point value to the internal output buffer of the
509
+ * `test_reporter`. It enables precise and readable streaming of double
510
+ * values into the reporter, supporting clear formatting of test output
511
+ * across all test cases and folders.
512
+ */
263
513
  test_reporter&
264
514
  test_reporter::operator<< (double v)
265
515
  {
@@ -267,6 +517,15 @@ namespace micro_os_plus::micro_test_plus
267
517
  return *this;
268
518
  }
269
519
 
520
+ /**
521
+ * @details
522
+ * This operator overload appends the string representation of the specified
523
+ * long double-precision floating-point value to the internal output buffer
524
+ * of the `test_reporter`, followed by the character 'l' to indicate a long
525
+ * double type. It enables precise and readable streaming of long double
526
+ * values into the reporter, supporting clear formatting of test output
527
+ * across all test cases and folders.
528
+ */
270
529
  test_reporter&
271
530
  test_reporter::operator<< (long double v)
272
531
  {
@@ -275,6 +534,17 @@ namespace micro_os_plus::micro_test_plus
275
534
  return *this;
276
535
  }
277
536
 
537
+ /**
538
+ * @details
539
+ * This method marks the beginning of a test case, setting the internal state
540
+ * to indicate that test output is now within a test case context. If there
541
+ * is pending output and the verbosity level is set to verbose, it ensures
542
+ * that output is properly separated and displayed, adding an empty line if
543
+ * necessary. The output buffer is cleared and the stream is flushed to
544
+ * guarantee that all previous output is visible before the new test case
545
+ * begins. This approach enhances the clarity and organisation of test
546
+ * results across all test cases and folders.
547
+ */
278
548
  void
279
549
  test_reporter::begin_test_case ([[maybe_unused]] const char* name)
280
550
  {
@@ -295,6 +565,18 @@ namespace micro_os_plus::micro_test_plus
295
565
  flush ();
296
566
  }
297
567
 
568
+ /**
569
+ * @details
570
+ * This method marks the end of a test case, summarising its outcome and
571
+ * outputting the results with appropriate formatting and colour coding. If
572
+ * any checks have failed, a failure message is displayed, including the
573
+ * number of successful and failed checks. For passing test cases, a success
574
+ * message is shown with the total number of checks. The output is adjusted
575
+ * according to the verbosity level, and additional spacing is managed for
576
+ * clarity. The output buffer is cleared and the stream is flushed to ensure
577
+ * all results are immediately visible, supporting clear and organised
578
+ * reporting across all test cases and folders.
579
+ */
298
580
  void
299
581
  test_reporter::end_test_case ([[maybe_unused]] const char* name)
300
582
  {
@@ -306,6 +588,10 @@ namespace micro_os_plus::micro_test_plus
306
588
  {
307
589
  printf ("\n");
308
590
  }
591
+ #pragma GCC diagnostic push
592
+ #if defined(__clang__)
593
+ #pragma clang diagnostic ignored "-Wunsafe-buffer-usage-in-libc-call"
594
+ #endif
309
595
  printf (" • %s - test case started\n", name);
310
596
  output ();
311
597
  printf (
@@ -317,6 +603,7 @@ namespace micro_os_plus::micro_test_plus
317
603
  ? "check"
318
604
  : "checks",
319
605
  current_test_suite->current_test_case.failed_checks);
606
+ #pragma GCC diagnostic pop
320
607
  add_empty_line = true;
321
608
  }
322
609
  else
@@ -327,6 +614,10 @@ namespace micro_os_plus::micro_test_plus
327
614
  }
328
615
  if (verbosity == verbosity::verbose)
329
616
  {
617
+ #pragma GCC diagnostic push
618
+ #if defined(__clang__)
619
+ #pragma clang diagnostic ignored "-Wunsafe-buffer-usage-in-libc-call"
620
+ #endif
330
621
  printf (" • %s - test case started\n", name);
331
622
  output ();
332
623
  printf (
@@ -337,11 +628,15 @@ namespace micro_os_plus::micro_test_plus
337
628
  == 1
338
629
  ? "check"
339
630
  : "checks");
340
-
631
+ #pragma GCC diagnostic pop
341
632
  add_empty_line = true;
342
633
  }
343
634
  else
344
635
  {
636
+ #pragma GCC diagnostic push
637
+ #if defined(__clang__)
638
+ #pragma clang diagnostic ignored "-Wunsafe-buffer-usage-in-libc-call"
639
+ #endif
345
640
  printf (
346
641
  " %s✓%s %s - test case passed (%d %s)\n", colors_.pass,
347
642
  colors_.none, name,
@@ -350,6 +645,7 @@ namespace micro_os_plus::micro_test_plus
350
645
  == 1
351
646
  ? "check"
352
647
  : "checks");
648
+ #pragma GCC diagnostic pop
353
649
 
354
650
  add_empty_line = false;
355
651
  }
@@ -362,6 +658,16 @@ namespace micro_os_plus::micro_test_plus
362
658
  is_in_test_case_ = false;
363
659
  }
364
660
 
661
+ /**
662
+ * @details
663
+ * This method marks the beginning of a test suite, ensuring that output is
664
+ * properly separated and clearly presented. If there is pending output, the
665
+ * stream is flushed and an empty line is added for clarity. For silent or
666
+ * quiet verbosity levels, output is suppressed. Otherwise, a message
667
+ * indicating the start of the test suite is displayed. This approach
668
+ * enhances the organisation and readability of test results across all test
669
+ * cases and folders.
670
+ */
365
671
  void
366
672
  test_reporter::begin_test_suite (const char* name)
367
673
  {
@@ -377,11 +683,28 @@ namespace micro_os_plus::micro_test_plus
377
683
  return;
378
684
  }
379
685
 
686
+ #pragma GCC diagnostic push
687
+ #if defined(__clang__)
688
+ #pragma clang diagnostic ignored "-Wunsafe-buffer-usage-in-libc-call"
689
+ #endif
380
690
  printf ("• %s - test suite started\n", name);
691
+ #pragma GCC diagnostic pop
381
692
 
382
693
  add_empty_line = true;
383
694
  }
384
695
 
696
+ /**
697
+ * @details
698
+ * This method marks the end of a test suite, summarising the overall results
699
+ * and presenting them with appropriate formatting and colour coding. If the
700
+ * suite contains test cases and the verbosity is not set to quiet, an empty
701
+ * line is added for clarity. For suites with no failed checks and at least
702
+ * one successful check, a success message is displayed, including the number
703
+ * of checks and test cases. Otherwise, a failure message is shown, detailing
704
+ * the number of successful and failed checks, as well as the total number of
705
+ * test cases. The output is immediately flushed to ensure prompt and
706
+ * organised reporting across all test cases and folders.
707
+ */
385
708
  void
386
709
  test_reporter::end_test_suite (test_suite_base& suite)
387
710
  {
@@ -399,15 +722,24 @@ namespace micro_os_plus::micro_test_plus
399
722
  // Also fail if none passed.
400
723
  if (suite.failed_checks () == 0 && suite.successful_checks () != 0)
401
724
  {
725
+ #pragma GCC diagnostic push
726
+ #if defined(__clang__)
727
+ #pragma clang diagnostic ignored "-Wunsafe-buffer-usage-in-libc-call"
728
+ #endif
402
729
  printf ("%s✓%s %s - test suite passed (%d %s in %d test %s)\n",
403
730
  colors_.pass, colors_.none, suite.name (),
404
731
  suite.successful_checks (),
405
732
  suite.successful_checks () == 1 ? "check" : "checks",
406
733
  suite.test_cases (),
407
734
  suite.test_cases () == 1 ? "case" : "cases");
735
+ #pragma GCC diagnostic pop
408
736
  }
409
737
  else
410
738
  {
739
+ #pragma GCC diagnostic push
740
+ #if defined(__clang__)
741
+ #pragma clang diagnostic ignored "-Wunsafe-buffer-usage-in-libc-call"
742
+ #endif
411
743
  printf ("%s✗%s %s - test suite %sFAILED%s (%d %s passed, %d failed, "
412
744
  "in %d test %s)\n",
413
745
  colors_.fail, colors_.none, suite.name (), colors_.fail,
@@ -415,10 +747,20 @@ namespace micro_os_plus::micro_test_plus
415
747
  suite.successful_checks () == 1 ? "check" : "checks",
416
748
  suite.failed_checks (), suite.test_cases (),
417
749
  suite.test_cases () == 1 ? "case" : "cases");
750
+ #pragma GCC diagnostic pop
418
751
  }
419
752
  flush ();
420
753
  }
421
754
 
755
+ /**
756
+ * @details
757
+ * This method writes the contents of the internal output buffer to the
758
+ * standard output stream without appending a newline character. After
759
+ * outputting the buffer, it is cleared to prepare for subsequent output.
760
+ * This approach ensures that test results are presented promptly and
761
+ * efficiently, supporting clear and organised reporting across all test
762
+ * cases and folders.
763
+ */
422
764
  void
423
765
  test_reporter::output (void)
424
766
  {