micro-test-plus 6.0.1
µTest++ Testing Framework
Loading...
Searching...
No Matches
reporter.cpp
Go to the documentation of this file.
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
12// ----------------------------------------------------------------------------
13
37
38// ----------------------------------------------------------------------------
39
46
47#if __has_include("micro-os-plus/diag/trace.h")
48#include "micro-os-plus/diag/trace.h"
49#endif // __has_include("micro-os-plus/diag/trace.h")
50
51#include <cstdarg>
52// For the PRIu32 macro used in snprintf() formatting of uint32_t values.
53#include <cinttypes>
54#include <limits>
55
56// ----------------------------------------------------------------------------
57
58#if defined(__GNUC__)
59#pragma GCC diagnostic ignored "-Waggregate-return"
60#if defined(__clang__)
61#pragma clang diagnostic ignored "-Wunknown-warning-option"
62#pragma clang diagnostic ignored "-Wc++98-compat"
63#pragma clang diagnostic ignored "-Wc++98-compat-pedantic"
64#pragma clang diagnostic ignored "-Wunsafe-buffer-usage-in-libc-call"
65#endif // defined(__clang__)
66#endif // defined(__GNUC__)
67
68// ============================================================================
69
70#if defined(MICRO_OS_PLUS_MICRO_TEST_PLUS_ENABLED)
71
72// ----------------------------------------------------------------------------
73
75{
76 // --------------------------------------------------------------------------
77
94 namespace
95 {
112 void
113 write_without_colours (FILE* file, std::string_view text)
114 {
115 size_t start = 0;
116 size_t pos = text.find ('\033');
117 while (pos != std::string_view::npos)
118 {
119 // Parse `ESC [ <digits and semicolons> m`.
120 size_t end = pos + 1;
121 if (end < text.size () && text[end] == '[')
122 {
123 ++end;
124 while (end < text.size ()
125 && ((text[end] >= '0' && text[end] <= '9')
126 || text[end] == ';'))
127 {
128 ++end;
129 }
130 if (end < text.size () && text[end] == 'm')
131 {
132 // A colour sequence; write the preceding text and skip
133 // it.
134 const std::string_view chunk
135 = text.substr (start, pos - start);
136 fwrite (chunk.data (), 1, chunk.size (), file);
137 start = end + 1;
138 }
139 }
140 pos = text.find ('\033', pos + 1);
141 }
142
143 const std::string_view chunk = text.substr (start);
144 fwrite (chunk.data (), 1, chunk.size (), file);
145 }
146 } // namespace
147
148 // --------------------------------------------------------------------------
149
163 : verbosity_{ opts.verbosity_level }
164 {
165#if defined(MICRO_OS_PLUS_MICRO_TEST_PLUS_TRACE_CONSTRUCTORS_ENABLED)
166 trace::printf ("%s\n", __PRETTY_FUNCTION__);
167#endif // MICRO_OS_PLUS_MICRO_TEST_PLUS_TRACE_CONSTRUCTORS_ENABLED
168
169 if (!opts.output_file_path.empty ())
170 {
171 output_file_ = fopen (opts.output_file_path.c_str (), "w");
172 if (output_file_ == nullptr)
173 {
174 fprintf (stderr, "error: failed to open output file '%s'\n",
175 opts.output_file_path.c_str ());
177 }
178 else
179 {
181 }
182 }
183
184 // Pre-allocate buffer to reduce dynamic allocations.
185 buffer_.reserve (128);
186 }
187
195 {
196#if defined(MICRO_OS_PLUS_MICRO_TEST_PLUS_TRACE_CONSTRUCTORS_ENABLED)
197 trace::printf ("%s\n", __PRETTY_FUNCTION__);
198#endif // MICRO_OS_PLUS_MICRO_TEST_PLUS_TRACE_CONSTRUCTORS_ENABLED
199
200 if (output_file_ != nullptr)
201 {
202 fflush (output_file_);
203 fclose (output_file_);
204
205 output_file_ = nullptr;
206 output_file_path_.clear ();
207 }
208 }
209
210 // --------------------------------------------------------------------------
211
217 reporter&
218 endl (reporter& stream)
219 {
220 stream.end_line ();
221 return stream;
222 }
223
231 void
233 {
234 buffer_.append ("\n");
235 }
236
243 void
245 {
246 if (output_file_ == nullptr)
247 {
248 return;
249 }
250
251 flush_streams ();
252
254 {
255 write_console ("%sTest output written to '%s'.\n", comment_prefix (),
256 output_file_path_.c_str ());
257 fflush (stdout);
258 }
259 }
260
266 const char*
267 reporter::error_prefix (void) const noexcept
268 {
269 return "error: ";
270 }
271
280 reporter::route (record_kind kind) const noexcept
281 {
282 bool console;
283 if (kind == record_kind::failed_check || kind == record_kind::total
284 || kind == record_kind::abort)
285 {
286 console = (verbosity_ != verbosity::silent);
287 }
288 else if (kind == record_kind::test_case_heading
289 || kind == record_kind::passed_check)
290 {
291 console = (verbosity_ == verbosity::verbose);
292 }
293#if defined(MICRO_OS_PLUS_STARTUP_ENABLED) \
294 && defined(MICRO_OS_PLUS_DIAG_TRACE_ENABLED)
295 else if (kind == record_kind::info)
296 {
297 // The startup code already displays this information.
298 console = false;
299 }
300#endif // defined(MICRO_OS_PLUS_STARTUP_ENABLED) && ...
301 else
302 {
303 console = (verbosity_ == verbosity::normal
305 }
306
307 return { console, output_file_ != nullptr };
308 }
309
319 bool
320 reporter::writes_passed_checks (void) const noexcept
321 {
322 return output_file_ != nullptr || verbosity_ == verbosity::verbose;
323 }
324
331 std::string_view
332 reporter::console_lines (bool failed) const noexcept
333 {
335 {
336 return buffer_;
337 }
339 {
340 return failed ? std::string_view{ buffer_ } : std::string_view{};
341 }
343 {
344 return failures_;
345 }
346 return {};
347 }
348
354 void
355 reporter::write_console_text (std::string_view text)
356 {
357 // Pass only the text, do not add an `\n` here.
358 fwrite (text.data (), 1, text.size (), stdout);
359 }
360
366 void
368 {
370 {
371 failures_.append (buffer_, begin, std::string::npos);
372 }
374 }
375
381 void
383 {
384 const size_t count = include_last || open_test_cases_.empty ()
385 ? open_test_cases_.size ()
386 : open_test_cases_.size () - 1;
387 bool is_first = true;
388 for (size_t i = 0; i < count; ++i)
389 {
391 if (open.name_displayed)
392 {
393 continue;
394 }
395
396 display_open_heading (open, is_first);
397 is_first = false;
398
399 open.name_displayed = true;
400 }
401 }
402
408 void
409 reporter::enter_suite (const suite& suite, bool displayed)
410 {
412 suite_displayed_ = displayed;
413 }
414
424 void
426 {
427 if (output_file_ == nullptr)
428 {
429 return;
430 }
431
432 // Pass only the string, do not add an `\n` here.
433 write_without_colours (output_file_, buffer_);
434 }
435
443 void
444 reporter::write_console (const char* format, ...)
445 {
446 va_list args;
447 va_start (args, format);
448 vfprintf (stdout, format, args);
449 va_end (args);
450 }
451
457 void
458 reporter::write_file (const char* format, ...)
459 {
460 if (output_file_ == nullptr)
461 {
462 return;
463 }
464
465 va_list args;
466 va_start (args, format);
467 vfprintf (output_file_, format, args);
468 va_end (args);
469 }
470
484 void
485 reporter::write_line (bool to_console, const char* format, ...)
486 {
487 if (output_file_ == nullptr && !to_console)
488 {
489 return;
490 }
491
492 va_list args;
493 va_start (args, format);
494 va_list args_copy;
495 va_copy (args_copy, args);
496
497 char local_text[128];
498 const int length
499 = vsnprintf (local_text, sizeof (local_text), format, args);
500 va_end (args);
501
502 if (length < 0)
503 {
504 va_end (args_copy);
505 return;
506 }
507
508 const size_t size = static_cast<size_t> (length);
509 std::string long_text;
510 std::string_view text{ local_text, size };
511 if (size >= sizeof (local_text))
512 {
513 // The terminating null character is written over the one kept by
514 // the string after its content.
515 long_text.resize (size);
516 vsnprintf (long_text.data (), size + 1, format, args_copy);
517 text = long_text;
518 }
519 va_end (args_copy);
520
521 if (output_file_ != nullptr)
522 {
523 write_without_colours (output_file_, text);
524 }
525
526 if (to_console)
527 {
528 fwrite (text.data (), 1, text.size (), stdout);
529 }
530 }
531
546 void
547 reporter::write_info (const std::vector<std::string>& arguments)
548 {
549 const bool to_console = route (record_kind::info).console;
550
551 if (!arguments.empty ())
552 {
553 std::string line;
554 line.reserve (256);
555 line.append (comment_prefix ());
556 line.append ("Running: ");
557
558 // Append only the file name part of argv[0].
559 line.append (utility::extract_file_name (arguments[0].c_str ()));
560
561 for (size_t i = 1; i < arguments.size (); ++i)
562 {
563 line.append (" ");
564 line.append (arguments[i]);
565 }
566 line.append ("\n");
567
568 write_line (to_console, "%s", line.c_str ());
569 }
570
571 {
572 // Build the "Built with ..." line, including the compiler version
573 // (via __VERSION__); the same line goes to the file and to stdout.
574 std::string line;
575 line.reserve (256);
576 line.append (comment_prefix ());
577 line.append ("Built with ");
578#if defined(__clang__)
579 line.append ("clang " __VERSION__);
580#elif defined(__GNUC__)
581 line.append ("GCC " __VERSION__);
582#elif defined(_MSC_VER)
583 line.append ("MSVC");
584 char msvc_ver[16];
585 snprintf (msvc_ver, sizeof (msvc_ver), " - %d", _MSC_VER);
586 line.append (msvc_ver);
587#else
588 line.append ("an unknown compiler");
589#endif // defined(__clang__)
590#if !(defined(__APPLE__) || defined(__linux__) || defined(__unix__) \
591 || defined(_WIN32))
592 // This is relevant only on bare-metal.
593#if defined(__ARM_PCS_VFP) || defined(__ARM_FP)
594 line.append (", with FP");
595#else
596 line.append (", no FP");
597#endif // defined(__ARM_PCS_VFP) || defined(__ARM_FP)
598#endif // bare-metal only
599#if defined(__cpp_exceptions)
600 line.append (", with exceptions");
601#else
602 line.append (", no exceptions");
603#endif // defined(__cpp_exceptions)
604#if defined(MICRO_OS_PLUS_DEBUG_ENABLED)
605 line.append (", with MICRO_OS_PLUS_DEBUG_ENABLED");
606#endif // defined(MICRO_OS_PLUS_DEBUG_ENABLED)
607#if defined(MICRO_OS_PLUS_DIAG_TRACE_ENABLED)
608 line.append (", with MICRO_OS_PLUS_DIAG_TRACE_ENABLED");
609#endif // defined(MICRO_OS_PLUS_DIAG_TRACE_ENABLED)
610
611 write_line (to_console, "%s\n", line.c_str ());
612 }
613 }
614
621 void
623 {
624 fflush (stdout);
625 if (output_file_ != nullptr)
626 {
627 fflush (output_file_);
628 }
629 }
630
635 bool
637 {
639 }
640
641 // --------------------------------------------------------------------------
642
652 {
653 // Call the endl function.
654 (*func) (*this);
655 return *this;
656 }
657
666 {
667 buffer_.append (m.level * indent_size_, ' ');
668 return *this;
669 }
670
677 reporter::operator<< (std::string_view sv)
678 {
679 buffer_.append (sv);
680 return *this;
681 }
682
690 {
691 buffer_.append (1, c);
692 return *this;
693 }
694
704 reporter::operator<< (const char* s)
705 {
706 if (s == nullptr)
707 {
708 buffer_.append ("nullptr");
709 }
710 else
711 {
712 buffer_.append (s);
713 }
714 return *this;
715 }
716
727 {
728 buffer_.append (v ? "true" : "false");
729 return *this;
730 }
731
738 reporter::operator<< (std::nullptr_t)
739 {
740 buffer_.append ("nullptr");
741 return *this;
742 }
743
750 void
751 reporter::pass (const std::string& message, const std::string& expression,
752 const test_case& test_case)
753 {
754 output_pass_prefix (message, test_case);
755
756 if (message.empty ())
757 {
758 *this << expression;
759 }
760
762 }
763
770 void
771 reporter::fail (const failure_info& failure, const std::string& expression,
772 const test_case& test_case)
773 {
774 const size_t begin = buffer_.size ();
775
776 output_fail_prefix (failure.message, failure.has_expression,
777 failure.location, test_case);
778
779 if (failure.has_expression)
780 {
781 *this << expression;
782 }
783
784 output_fail_suffix (failure.location, failure.kind, test_case);
785
786 mark_failure (begin);
787 }
788
794 void
796 {
797 buffer_.clear ();
798 failures_.clear ();
799 buffer_has_failures_ = false;
800 }
801
809 void
811 char (&message)[elapsed_time_size_])
812 {
813 const auto elapsed = stopwatch.elapsed ().count ();
814 if (elapsed > 0)
815 {
816 snprintf (message, sizeof (message),
817 ", time: %" PRIu32 ".%03" PRIu32 " ms",
818 static_cast<uint32_t> (elapsed / 1000),
819 static_cast<uint32_t> (elapsed % 1000));
820 }
821 else
822 {
823 message[0] = '\0';
824 }
825 }
826
827 // --------------------------------------------------------------------------
828
829 namespace
830 {
840 constexpr size_t fragment_size
841 = 21 + (std::numeric_limits<size_t>::digits10 + 1);
842
853 constexpr const char*
854 plural (size_t count) noexcept
855 {
856 return count == 1 ? "" : "s";
857 }
858
873 void
874 format_skipped (size_t count, char (&message)[fragment_size])
875 {
876 if (count > 0)
877 {
878 snprintf (message, sizeof (message),
880 count);
881 }
882 else
883 {
884 message[0] = '\0';
885 }
886 }
887 } // namespace
888
895 void
897 char (&message)[totals_size_])
898 {
899 // The fixed text, four counts, two fragments, and the terminator.
900 static_assert (totals_size_
901 >= 54 + 4 * (std::numeric_limits<size_t>::digits10 + 1)
902 + 2 * (fragment_size - 1),
903 "totals_size_ too small for the session totals");
904
905 const counters& totals = runner.totals ();
906 const size_t suites_count = runner.total_suites_count ();
907
908 char message_skipped_test_cases[fragment_size];
909 format_skipped (totals.skipped_test_cases (), message_skipped_test_cases);
910
911 char message_skipped_suites[fragment_size];
912 format_skipped (runner.skipped_suites_count (), message_skipped_suites);
913
914 snprintf (message, sizeof (message),
916 " check%s passed, %" MICRO_OS_PLUS_MICRO_TEST_PLUS_PRI_SIZE
918 " test case%s%s, %" MICRO_OS_PLUS_MICRO_TEST_PLUS_PRI_SIZE " "
919 "test suite%s%s",
920 totals.passed_checks (), plural (totals.passed_checks ()),
921 totals.failed_checks (), totals.executed_test_cases (),
922 plural (totals.executed_test_cases ()),
923 message_skipped_test_cases, suites_count, plural (suites_count),
924 message_skipped_suites);
925 }
926
932 void
934 char (&message)[totals_size_])
935 {
936 const counters& totals = suite.totals ();
937
938 char message_skipped[fragment_size];
939 format_skipped (totals.skipped_test_cases (), message_skipped);
940
941 if (totals.passed ()) [[likely]]
942 {
943 snprintf (message, sizeof (message),
946 " test case%s%s",
947 totals.passed_checks (), plural (totals.passed_checks ()),
948 totals.executed_test_cases (),
949 plural (totals.executed_test_cases ()), message_skipped);
950 }
951 else
952 {
953 snprintf (message, sizeof (message),
955 " check%s passed, %" MICRO_OS_PLUS_MICRO_TEST_PLUS_PRI_SIZE
957 " test case%s%s",
958 totals.passed_checks (), plural (totals.passed_checks ()),
959 totals.failed_checks (), totals.executed_test_cases (),
960 plural (totals.executed_test_cases ()), message_skipped);
961 }
962 }
963
969 void
971 char (&message)[totals_size_])
972 {
973 const counters& totals = test_case.totals ();
974
975 if (totals.passed ()) [[likely]]
976 {
977 snprintf (message, sizeof (message),
979 totals.passed_checks (), plural (totals.passed_checks ()));
980 }
981 else
982 {
983 char message_test_cases[fragment_size] = "";
984 if (totals.failed_test_cases () > 0)
985 {
986 snprintf (message_test_cases, sizeof (message_test_cases),
988 " test case%s failed",
989 totals.failed_test_cases (),
990 plural (totals.failed_test_cases ()));
991 }
992
993 snprintf (message, sizeof (message),
995 " check%s passed, %" MICRO_OS_PLUS_MICRO_TEST_PLUS_PRI_SIZE
996 " failed%s",
997 totals.passed_checks (), plural (totals.passed_checks ()),
998 totals.failed_checks (), message_test_cases);
999 }
1000 }
1001
1012 void
1014 {
1015 if (!buffer_.empty ())
1016 {
1017 commit_buffer ();
1018 }
1019 }
1020
1021 // --------------------------------------------------------------------------
1022} // namespace micro_os_plus::micro_test_plus::detail
1023
1024// ----------------------------------------------------------------------------
1025
1026#endif // defined(MICRO_OS_PLUS_MICRO_TEST_PLUS_ENABLED)
1027
1028// ----------------------------------------------------------------------------
Aggregated check and test case counters for a node in the test tree.
Definition counters.h:123
bool passed(void) const noexcept
Checks whether all executed checks and test cases were successful.
size_t skipped_test_cases(void) const noexcept
Returns the number of test cases skipped by the filter.
size_t executed_test_cases(void) const noexcept
Returns the number of test cases that were executed.
size_t passed_checks(void) const noexcept
Returns the number of checks that passed.
size_t failed_test_cases(void) const noexcept
Returns the number of executed test cases that failed.
size_t failed_checks(void) const noexcept
Returns the number of checks that failed.
Abstract base class for the reporters that display test results, including operand values for failure...
Definition reporter.h:276
bool has_output_file_error(void) const noexcept
Returns whether the output file could not be opened.
Definition reporter.cpp:636
std::string buffer_
Output accumulation buffer.
Definition reporter.h:1294
bool has_output_file_error_
Whether the output file could not be opened.
Definition reporter.h:1444
bool writes_passed_checks(void) const noexcept
Returns whether the passed checks are written anywhere.
Definition reporter.cpp:320
virtual void output_fail_prefix(const std::string &message, const bool has_expression, const reflection::source_location &location, const test_case &test_case)=0
Outputs the prefix for a failing condition.
const micro_test_plus::verbosity verbosity_
The verbosity level for test reporting.
Definition reporter.h:1273
FILE * output_file_
Optional output file, receiving a copy of the test report.
Definition reporter.h:1465
void end_line(void)
Appends a line ending to the internal output buffer.
Definition reporter.cpp:232
static constexpr size_t elapsed_time_size_
Size of the array that receives the elapsed time text.
Definition reporter.h:1040
void mark_failure(size_t begin)
Records that the lines appended to the buffer from a given position are a failure.
Definition reporter.cpp:367
virtual const char * comment_prefix(void) const noexcept=0
Returns the comment-prefix string used by this reporter format.
void write_buffer_to_file(void)
Writes the current buffered content to the output file.
Definition reporter.cpp:425
void announce_output_file(void)
Tells the console where the output file was written.
Definition reporter.cpp:244
void fail(const failure_info &failure, const std::string &expression, const test_case &test_case)
Reports a failed condition.
Definition reporter.cpp:771
reporter & operator<<(std::string_view sv)
Output operator for std::string_view.
Definition reporter.cpp:677
static void format_suite_totals(const suite &suite, char(&message)[totals_size_])
Formats the totals of a suite.
Definition reporter.cpp:933
void clear_buffer(void)
Clears the output buffer.
Definition reporter.cpp:795
virtual ~reporter()
Virtual destructor for the reporter class.
Definition reporter.cpp:194
void commit_outer_results(void)
Writes the results of the outer test case, if any, before a nested test case begins or is skipped.
void enter_suite(const suite &suite, bool displayed)
Notes the suite that begins, for the headings displayed later.
Definition reporter.cpp:409
static void format_test_case_totals(const test_case &test_case, char(&message)[totals_size_])
Formats the totals of a test case.
Definition reporter.cpp:970
friend class micro_test_plus::runner
The runner, which lists the test cases.
Definition reporter.h:301
bool suite_displayed_
Whether the heading of the current suite was displayed on the console.
Definition reporter.h:1410
void write_info(const std::vector< std::string > &arguments)
Writes the informational (non-result) lines to the console and to the output file.
Definition reporter.cpp:547
static void format_session_totals(const runner &runner, char(&message)[totals_size_])
Formats the totals of the test session.
Definition reporter.cpp:896
reporter(const runner_options &opts)
Constructor for the reporter class.
Definition reporter.cpp:162
static constexpr size_t indent_size_
Number of spaces per nesting level.
Definition reporter.h:1263
void flush_streams(void)
Flushes the standard output stream and the output file.
Definition reporter.cpp:622
virtual void output_pass_suffix(const test_case &test_case)=0
Outputs the suffix for a passing condition.
virtual void commit_buffer(void)=0
Writes the results buffered for the outer test case before a nested test case begins or is skipped.
void write_console_text(std::string_view text)
Writes a text to the console, unchanged.
Definition reporter.cpp:355
friend class micro_test_plus::test_case
The test case, which creates the checks.
Definition reporter.h:284
void write_file(const char *format,...)
Writes formatted text to the output file.
Definition reporter.cpp:458
bool buffer_has_failures_
Whether the output buffer contains a failed check.
Definition reporter.h:1305
virtual const char * error_prefix(void) const noexcept
Returns the prefix of the lines that report an error.
Definition reporter.cpp:267
void write_line(bool to_console, const char *format,...)
Writes formatted lines to the output file and, when requested, to the console.
Definition reporter.cpp:485
static constexpr size_t totals_size_
Size of the array that receives the totals text.
Definition reporter.h:1083
std::string failures_
The lines of the failed checks, for the quiet verbosity.
Definition reporter.h:1316
void write_console(const char *format,...)
Writes formatted text to the console.
Definition reporter.cpp:444
std::string output_file_path_
Path of the optional output file.
Definition reporter.h:1454
static void format_elapsed_time(const stopwatch &stopwatch, char(&message)[elapsed_time_size_])
Formats the elapsed time of a suite or of the session.
Definition reporter.cpp:810
const suite * current_suite_
The suite that has begun and not yet ended.
Definition reporter.h:1399
std::vector< open_test_case > open_test_cases_
The test cases that have begun and not yet ended, outermost first.
Definition reporter.h:1352
void pass(const std::string &message, const std::string &expression, const test_case &test_case)
Reports a passed condition.
Definition reporter.cpp:751
std::string_view console_lines(bool failed) const noexcept
Returns the buffered lines that the console displays when a test case or a suite ends,...
Definition reporter.cpp:332
virtual void output_fail_suffix(const reflection::source_location &location, check_kind kind, const test_case &test_case)=0
Outputs the suffix for a failing condition.
void display_open_test_cases(bool include_last)
Displays the headings not yet displayed, of the open test cases.
Definition reporter.cpp:382
virtual void output_pass_prefix(const std::string &message, const test_case &test_case)=0
Outputs the prefix for a passing condition.
output_route route(record_kind kind) const noexcept
Tells where a kind of record is written.
Definition reporter.cpp:280
virtual void display_open_heading(const open_test_case &open, bool is_first)=0
Writes the heading of an open test case.
const counters & totals(void) const noexcept
Returns the totals of the node.
Measures the elapsed time of an operation.
Definition stopwatch.h:138
std::chrono::microseconds elapsed(void) const noexcept
Returns the time elapsed between start() and stop().
The configuration of a test session, and its command-line parser.
std::string output_file_path
Path of the optional output file.
size_t skipped_suites_count(void) const noexcept
Returns the count of the test suites skipped by the filter.
Definition runner.cpp:1142
const counters & totals(void) const noexcept
Returns the totals of the test session.
size_t total_suites_count(void) const noexcept
Returns the count of all the test suites.
Definition runner.cpp:1131
A named, runnable test suite registered with the test runner.
Definition test.h:2059
C++ header file with declarations for the µTest++ counters.
#define MICRO_OS_PLUS_MICRO_TEST_PLUS_PRI_SIZE
Portable printf() conversion for the size_t values.
Definition detail.h:102
const char * extract_file_name(const char *path) noexcept
Extracts the file name component from a full path.
Definition utility.cpp:95
void format_skipped(size_t count, char(&message)[fragment_size])
Formats the number of items skipped by the filter.
Definition reporter.cpp:874
constexpr size_t fragment_size
Size of the array that receives a fragment of the totals.
Definition reporter.cpp:841
constexpr const char * plural(size_t count) noexcept
Returns the plural suffix for a count.
Definition reporter.cpp:854
void write_without_colours(FILE *file, std::string_view text)
Writes a text to a file, without the ANSI colour sequences.
Definition reporter.cpp:113
Internal implementation details for the µTest++ framework.
reporter & endl(reporter &stream)
Output stream manipulator for ending a line in test reports.
Definition reporter.cpp:218
record_kind
The kinds of records written by the reporters.
Definition reporter.h:161
@ test_case_heading
The heading that marks the beginning of a test case.
Definition reporter.h:181
@ abort
The report of an aborted test execution.
Definition reporter.h:212
@ info
The informational lines written at the beginning of the session.
Definition reporter.h:166
@ failed_check
The lines of a failed check, or the failure of a suite.
Definition reporter.h:202
C++ header file with declarations for the µTest++ test reporter.
C++ header file with declarations for the µTest++ test runner.
C++ header file with declarations for the µTest++ stopwatch.
The details of a check, displayed when it fails.
bool has_expression
Indicates whether the check has an associated expression.
reflection::source_location location
The source location of the check.
std::string message
The message passed via operator<<(), if any.
Parameterised stream manipulator for outputting indentation.
Definition reporter.h:127
size_t level
Number of four-space indentation levels.
Definition reporter.h:134
bool console
Whether the record is written to the console.
Definition reporter.h:229
A test case that has begun and not yet ended.
Definition reporter.h:1325
bool name_displayed
Whether the heading of the test case was displayed.
Definition reporter.h:1342
C++ header file with declarations for the µTest++ test hierarchy.
C++ header file with declarations for the µTest++ utility helpers.