C++ source file with implementations for the µTest++ test reporter methods. More...
Namespaces Index
Functions Index
test_reporter & | endl (test_reporter &stream) |
| Output stream manipulator for ending a line in test reports. More... |
|
Description
C++ source file with implementations for the µTest++ test reporter methods.
This source file contains the core implementations for the test reporting facilities of the µTest++ framework. It provides the logic for formatting and outputting test results, including operator overloads for a wide range of value types, containers, and comparison expressions, as well as structured output for logical and exception-related assertions.
The test reporter is responsible for presenting test outcomes in a clear, consistent, and expressive manner, supporting both value and pointer semantics, and providing detailed diagnostics for both successful and failed test cases. Special attention is given to formatting, colour highlighting, and extensibility, enabling professional and readable test reports suitable for embedded and general C++ development.
All definitions reside within the micro_os_plus::micro_test_plus
namespace, ensuring clear separation from user code and minimising the risk of naming conflicts.
This file must be included when building the µTest++ library.
Functions
endl()
test_reporter & micro_os_plus::micro_test_plus::endl (test_reporter & stream) |
|
Output stream manipulator for ending a line in test reports.
- Parameters
- Returns
Reference to the same test_reporter
instance, enabling chaining of output operations.
The endl
function inserts a newline character into the specified test_reporter
stream and flushes its output buffer. This operation ensures that each test output line is clearly separated and immediately visible, facilitating the readability and clarity of test results across all test cases and folders within the µTest++ framework.
Definition at line 73 of file test-reporter.cpp.
File Listing
The file content with the documentation metadata removed is:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
43
44
45
46#if defined(MICRO_OS_PLUS_INCLUDE_CONFIG_H)
47#include <micro-os-plus/config.h>
48#endif
49
51
52
53
54#pragma GCC diagnostic ignored "-Waggregate-return"
55#if defined(__clang__)
56#pragma clang diagnostic ignored "-Wc++98-compat"
57#pragma clang diagnostic ignored "-Wc++98-compat-pedantic"
58#endif
59
61{
62
63
74 {
76 return stream;
77 }
78
79
80
93 void
95 {
98 {
99 *this << " ";
100 }
101 *this << " ✓ ";
103 if (!message.empty ())
104 {
105 *this << message.c_str ();
106 }
107 }
108
124 void
126 {
128
130 }
131
143 void
146 {
149 {
150 *this << " ";
151 }
152 *this << " ✗ ";
154 if (!message.empty ())
155 {
156 *this << message.c_str ();
157 *this << " ";
158 }
160#pragma GCC diagnostic push
161#if defined(__clang__)
162#pragma clang diagnostic ignored "-Wsign-conversion"
163#elif defined(__GNUC__)
164#pragma GCC diagnostic ignored "-Wnarrowing"
165#pragma GCC diagnostic ignored "-Wsign-conversion"
166#endif
170 };
171#pragma GCC diagnostic pop
172 }
173
183 void
185 {
186 *this << ")";
187 if (abort)
188 {
189 *this << " aborted...";
190 }
192
194 }
195
207 {
208
209 (*func) (*this);
210 return *this;
211 }
212
221 void
223 {
226 }
227
235 void
237 {
238 fflush (stdout);
239 }
240
251 {
253 return *this;
254 }
255
265 {
267 return *this;
268 }
269
280 {
282 return *this;
283 }
284
295 {
297 return *this;
298 }
299
310 {
311 out_.append (v ? "true" : "false"); 312 return *this;
313 }
314
324 {
325 out_.append ("nullptr"); 326 return *this;
327 }
328
339 {
340 out_.append (std::to_string (c)); 342 return *this;
343 }
344
355 {
356 out_.append (std::to_string (static_cast<int> (c))); 358 return *this;
359 }
360
371 {
372 out_.append (std::to_string (v)); 374 return *this;
375 }
376
387 {
388 out_.append (std::to_string (static_cast<long> (v))); 390 return *this;
391 }
392
403 {
404 out_.append (std::to_string (v)); 405 return *this;
406 }
407
418 {
419 out_.append (std::to_string (v)); 421 return *this;
422 }
423
434 {
435 out_.append (std::to_string (v)); 437 return *this;
438 }
439
450 {
451 out_.append (std::to_string (v)); 453 return *this;
454 }
455
466 {
467 out_.append (std::to_string (v)); 469 return *this;
470 }
471
482 {
483 out_.append (std::to_string (v)); 485 return *this;
486 }
487
498 {
499 out_.append (std::to_string (v)); 501 return *this;
502 }
503
514 {
515 out_.append (std::to_string (v)); 516 return *this;
517 }
518
530 {
531 out_.append (std::to_string (v)); 533 return *this;
534 }
535
547 void
549 {
551
553 {
555 {
556 printf ("\n");
557 }
560 }
561
563
565 }
566
579 void
581 {
583 {
585 {
586 if (true )
587 {
588 printf ("\n");
589 }
590 printf (" • %s - test case started\n", name);
592 printf (
593 " %s✗%s %s - test case %sFAILED%s (%d %s passed, %d "
594 "failed)\n",
598 ? "check"
599 : "checks",
602 }
603 else
604 {
606 {
607 printf ("\n");
608 }
610 {
611 printf (" • %s - test case started\n", name);
613 printf (
614 " %s✓%s %s - test case passed (%d %s)\n", colors_.pass, 618 == 1
619 ? "check"
620 : "checks");
621
623 }
624 else
625 {
626 printf (
627 " %s✓%s %s - test case passed (%d %s)\n", colors_.pass, 631 == 1
632 ? "check"
633 : "checks");
634
636 }
637 }
638 }
639
642
644 }
645
656 void
658 {
660 {
662 printf ("\n");
663 }
664
666 {
668 return;
669 }
670
671 printf ("• %s - test suite started\n", name);
672
674 }
675
688 void
690 {
692 {
693 return;
694 }
695
697 {
698 printf ("\n");
700 }
701
702
704 {
705 printf ("%s✓%s %s - test suite passed (%d %s in %d test %s)\n",
711 }
712 else
713 {
714 printf ("%s✗%s %s - test suite %sFAILED%s (%d %s passed, %d failed, "
715 "in %d test %s)\n",
721 }
723 }
724
734 void
736 {
737 printf ("%s", out_.c_str ()); 739 }
740
741
742}
743
744
Generated via docusaurus-plugin-doxygen by Doxygen 1.14.0.