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 97 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 103 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 108 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 113 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 136 of file runner-totals.h, definition at line 73 of file runner-totals.cpp.

74 {
75 successful_checks_ += other.successful_checks ();
76 failed_checks_ += other.failed_checks ();
77 executed_subtests_ += other.executed_subtests ();
78
79#if defined(MICRO_OS_PLUS_MICRO_TEST_PLUS_TRACE_ENABLED)
80 trace::printf ("%s -> +%zu -%zu in xs%zu\n", __PRETTY_FUNCTION__,
82#endif // MICRO_OS_PLUS_MICRO_TEST_PLUS_TRACE_ENABLED
83
84 return *this;
85 }

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 119 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 126 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 196 of file runner-totals.h, definition at line 112 of file runner-totals-inlines.h.

113 {
115 }

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 206 of file runner-totals.h, definition at line 122 of file runner-totals-inlines.h.

123 {
124 return executed_subtests_;
125 }

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 166 of file runner-totals.h, definition at line 82 of file runner-totals-inlines.h.

83 {
84 executed_subtests_ += count;
85 }

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 156 of file runner-totals.h, definition at line 72 of file runner-totals-inlines.h.

73 {
74 failed_checks_ += count;
75 }

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 146 of file runner-totals.h, definition at line 62 of file runner-totals-inlines.h.

63 {
64 successful_checks_ += count;
65 }

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 217 of file runner-totals.h, definition at line 133 of file runner-totals-inlines.h.

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

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 233 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 228 of file runner-totals.h.

228 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 223 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.2 by Doxygen 1.17.0.