Skip to main content

runner_totals Class

Aggregated pass/fail/subtest counters for a node in the test tree. More...

Declaration

class micro_os_plus::micro_test_plus::detail::runner_totals { ... }

Included Headers

Public Constructors Index

runner_totals ()=default

Default constructor. All counters are zero-initialised. More...

runner_totals (const runner_totals &)=delete

Deleted copy constructor to prevent copying. More...

runner_totals (runner_totals &&)=delete

Deleted move constructor to prevent moving. More...

Public Operators Index

runner_totals &operator+= (const runner_totals &other) noexcept

Accumulates the totals from another instance into this one. More...

runner_totals &operator= (const runner_totals &)=delete

Deleted copy assignment operator to prevent copying. More...

runner_totals &operator= (runner_totals &&)=delete

Deleted move assignment operator to prevent moving. More...

Public Member Functions Index

size_texecuted_checks () const noexcept

Returns the total number of checks executed. More...

size_texecuted_subtests () const noexcept

Returns the number of subtests that were executed. More...

size_tfailed_checks () const noexcept

Returns the number of checks that failed. More...

voidincrement_executed_subtests (size_t count=1) noexcept

Increments the executed-subtests counter. More...

voidincrement_failed_checks (size_t count=1) noexcept

Increments the failed-checks counter. More...

voidincrement_successful_checks (size_t count=1) noexcept

Increments the successful-checks counter. More...

size_tsuccessful_checks () const noexcept

Returns the number of checks that passed. More...

boolwas_successful (void) const noexcept

Checks whether all executed checks were successful. More...

Protected Member Attributes Index

size_texecuted_subtests_ = 0

Total number of tests executed. More...

size_tfailed_checks_ = 0

Total number of failed checks. More...

size_tsuccessful_checks_ = 0

Total number of successful checks. More...

Description

Aggregated pass/fail/subtest counters for a node in the test tree.

runner_totals records three counters that are maintained throughout a test session:

Every test_node-derived object (runner, suite, subtest) owns a runner_totals member and accumulates its counts in place. At the end of each suite or session the operator += propagates the child totals up to the parent node.

The class is non-copyable and non-movable to prevent accidental duplication of live counters.

Definition at line 88 of file runner-totals.h.

Public Constructors

runner_totals()

micro_os_plus::micro_test_plus::detail::runner_totals::runner_totals ()
default

Default constructor. All counters are zero-initialised.

Definition at line 94 of file runner-totals.h.

Referenced by runner_totals, runner_totals, operator+=, operator= and operator=.

runner_totals()

micro_os_plus::micro_test_plus::detail::runner_totals::runner_totals (const runner_totals &)
delete

Deleted copy constructor to prevent copying.

Definition at line 99 of file runner-totals.h.

Reference runner_totals.

runner_totals()

micro_os_plus::micro_test_plus::detail::runner_totals::runner_totals (runner_totals &&)
delete

Deleted move constructor to prevent moving.

Definition at line 104 of file runner-totals.h.

Reference runner_totals.

Public Operators

operator+=()

runner_totals & micro_os_plus::micro_test_plus::detail::runner_totals::operator+= (const runner_totals & other)
noexcept

Accumulates the totals from another instance into this one.

Parameters
other

The instance whose totals are to be added.

Returns

Reference to this instance.

Adds the successful check count, failed check count, and executed subtest count of other to the corresponding members of this instance. Returns a reference to *this to support chaining. When tracing is enabled, the updated totals are output for diagnostic purposes.

Declaration at line 127 of file runner-totals.h, definition at line 71 of file runner-totals.cpp.

72 {
73 successful_checks_ += other.successful_checks ();
74 failed_checks_ += other.failed_checks ();
75 executed_subtests_ += other.executed_subtests ();
76
77#if defined(MICRO_OS_PLUS_TRACE) \
78 && defined(MICRO_OS_PLUS_TRACE_MICRO_TEST_PLUS)
79#if defined(__GNUC__)
80#pragma GCC diagnostic push
81#if defined(__clang__)
82#pragma clang diagnostic ignored "-Wunsafe-buffer-usage-in-libc-call"
83#endif
84#endif
85 trace::printf ("%s -> +%zu -%zu in xs%zu\n", __PRETTY_FUNCTION__,
87#if defined(__GNUC__)
88#pragma GCC diagnostic pop
89#endif
90#endif // MICRO_OS_PLUS_TRACE_MICRO_TEST_PLUS
91
92 return *this;
93 }

References runner_totals, executed_subtests_, failed_checks_ and successful_checks_.

operator=()

runner_totals & micro_os_plus::micro_test_plus::detail::runner_totals::operator= (const runner_totals &)
delete

Deleted copy assignment operator to prevent copying.

Definition at line 110 of file runner-totals.h.

Reference runner_totals.

operator=()

runner_totals & micro_os_plus::micro_test_plus::detail::runner_totals::operator= (runner_totals &&)
delete

Deleted move assignment operator to prevent moving.

Definition at line 117 of file runner-totals.h.

References runner_totals, executed_checks, executed_subtests, failed_checks, increment_executed_subtests, increment_failed_checks, successful_checks and was_successful.

Public Member Functions

executed_checks()

size_t micro_os_plus::micro_test_plus::detail::runner_totals::executed_checks ()
inline nodiscard noexcept

Returns the total number of checks executed.

Parameters

None.

Returns

The sum of successful and failed checks.

Returns the sum of successful_checks_ and failed_checks_.

Declaration at line 187 of file runner-totals.h, definition at line 111 of file runner-totals-inlines.h.

112 {
114 }

References failed_checks_ and successful_checks_.

Referenced by micro_os_plus::micro_test_plus::reporter_tap::end_subtest, micro_os_plus::micro_test_plus::reporter_tap::end_suite and operator=.

executed_subtests()

size_t micro_os_plus::micro_test_plus::detail::runner_totals::executed_subtests ()
inline nodiscard noexcept

Returns the number of subtests that were executed.

Parameters

None.

Returns

The cumulative count of executed subtests.

Returns the value of the executed_subtests_ counter.

Declaration at line 197 of file runner-totals.h, definition at line 121 of file runner-totals-inlines.h.

122 {
123 return executed_subtests_;
124 }

Reference executed_subtests_.

Referenced by micro_os_plus::micro_test_plus::reporter_human::end_session, micro_os_plus::micro_test_plus::reporter_tap::end_session, micro_os_plus::micro_test_plus::reporter_tap::end_subtest, micro_os_plus::micro_test_plus::reporter_human::end_suite, micro_os_plus::micro_test_plus::reporter_tap::end_suite and operator=.

failed_checks()

size_t micro_os_plus::micro_test_plus::detail::runner_totals::failed_checks ()
inline nodiscard noexcept

increment_executed_subtests()

void micro_os_plus::micro_test_plus::detail::runner_totals::increment_executed_subtests (size_t count=1)
inline noexcept

Increments the executed-subtests counter.

Parameters
count

The number of subtests to add (default 1).

Returns

Nothing.

Adds count to the executed_subtests_ counter.

Declaration at line 157 of file runner-totals.h, definition at line 81 of file runner-totals-inlines.h.

82 {
83 executed_subtests_ += count;
84 }

Reference executed_subtests_.

Referenced by micro_os_plus::micro_test_plus::detail::runnable_base::after_subtest_create_ and operator=.

increment_failed_checks()

void micro_os_plus::micro_test_plus::detail::runner_totals::increment_failed_checks (size_t count=1)
inline noexcept

Increments the failed-checks counter.

Parameters
count

The number of failed checks to add (default 1).

Returns

Nothing.

Adds count to the failed_checks_ counter.

Declaration at line 147 of file runner-totals.h, definition at line 71 of file runner-totals-inlines.h.

72 {
73 failed_checks_ += count;
74 }

Reference failed_checks_.

Referenced by operator=.

increment_successful_checks()

void micro_os_plus::micro_test_plus::detail::runner_totals::increment_successful_checks (size_t count=1)
inline noexcept

Increments the successful-checks counter.

Parameters
count

The number of successful checks to add (default 1).

Returns

Nothing.

Adds count to the successful_checks_ counter.

Declaration at line 137 of file runner-totals.h, definition at line 61 of file runner-totals-inlines.h.

62 {
63 successful_checks_ += count;
64 }

Reference successful_checks_.

successful_checks()

size_t micro_os_plus::micro_test_plus::detail::runner_totals::successful_checks ()
inline nodiscard noexcept

was_successful()

bool micro_os_plus::micro_test_plus::detail::runner_totals::was_successful (void)
inline nodiscard noexcept

Checks whether all executed checks were successful.

Parameters

None.

Return Values
true

No checks failed.

false

At least one check failed.

A runner with no checks at all is considered successful, as it did not fail any check.

Declaration at line 208 of file runner-totals.h, definition at line 132 of file runner-totals-inlines.h.

132 runner_totals::was_successful (void) const noexcept
133 {
134 return failed_checks_ == 0;
135 }

Reference failed_checks_.

Referenced by micro_os_plus::micro_test_plus::reporter_human::end_session, micro_os_plus::micro_test_plus::reporter_human::end_subtest, micro_os_plus::micro_test_plus::reporter_tap::end_subtest, micro_os_plus::micro_test_plus::reporter_human::end_suite, micro_os_plus::micro_test_plus::reporter_tap::end_suite and operator=.

Protected Member Attributes

executed_subtests_

size_t micro_os_plus::micro_test_plus::detail::runner_totals::executed_subtests_ = 0
protected

Total number of tests executed.

Definition at line 224 of file runner-totals.h.

Referenced by executed_subtests, increment_executed_subtests and operator+=.

failed_checks_

size_t micro_os_plus::micro_test_plus::detail::runner_totals::failed_checks_ = 0
protected

Total number of failed checks.

Definition at line 219 of file runner-totals.h.

219 size_t failed_checks_ = 0;

Referenced by executed_checks, failed_checks, increment_failed_checks, operator+= and was_successful.

successful_checks_

size_t micro_os_plus::micro_test_plus::detail::runner_totals::successful_checks_ = 0
protected

Total number of successful checks.

Definition at line 214 of file runner-totals.h.

Referenced by executed_checks, increment_successful_checks, operator+= and successful_checks.


The documentation for this class was generated from the following files:


Generated via doxygen2docusaurus 2.2.0 by Doxygen 1.17.0.