micro-test-plus 4.1.0
µTest++ Testing Framework
Loading...
Searching...
No Matches
micro_os_plus::micro_test_plus::detail::test_node Class Reference

Base class for runners and runable tests. More...

#include <micro-os-plus/micro-test-plus.h>

Inheritance diagram for micro_os_plus::micro_test_plus::detail::test_node:

Public Member Functions

 test_node (const char *name)
 Constructs a test node.
 test_node (const test_node &)=delete
 Deleted copy constructor to prevent copying.
 test_node (test_node &&)=delete
 Deleted move constructor to prevent moving.
virtual ~test_node ()
 Virtual destructor for the test_node class.
const char * name (void) const noexcept
 Gets the node name.
test_nodeoperator= (const test_node &)=delete
 Deleted copy assignment operator to prevent copying.
test_nodeoperator= (test_node &&)=delete
 Deleted move assignment operator to prevent moving.
const runner_totalstotals () const noexcept
 Gets the totals for the test (const overload).
runner_totalstotals () noexcept
 Gets the totals for the test.

Protected Attributes

const char * name_
 The test node name.
runner_totals totals_
 Totals for the test node, including nested cases.

Detailed Description

The test_node class provides the foundational interface for managing test within the µTest++ framework. It maintains counters for successful and failed checks, tracks test cases, and offers methods for marking the commencement and completion of test cases and suites.

This class ensures consistent state management and reporting for all derived classes. It also provides utility methods for querying the node's name, the number of successful and failed checks, the number of test cases, and the overall result of the node.

All members and methods are defined within the micro_os_plus::micro_test_plus namespace, ensuring clear separation from user code and minimising the risk of naming conflicts.

Definition at line 145 of file test.h.

Constructor & Destructor Documentation

◆ test_node() [1/3]

micro_os_plus::micro_test_plus::detail::test_node::test_node ( const char * name)
Parameters
[in]nameThe test node name.

Stores the supplied name pointer, which is expected to point to a string with a lifetime exceeding that of this instance. If tracing is enabled, the name is output for diagnostic purposes.

Definition at line 84 of file test.cpp.

84 : name_{ name }
85 {
86#if defined(MICRO_OS_PLUS_TRACE) \
87 && defined(MICRO_OS_PLUS_TRACE_MICRO_TEST_PLUS_CONSTRUCTORS)
88#if defined(__GNUC__)
89#pragma GCC diagnostic push
90#if defined(__clang__)
91#pragma clang diagnostic ignored "-Wunsafe-buffer-usage-in-libc-call"
92#endif
93#endif
94 trace::printf ("%s '%s'\n", __PRETTY_FUNCTION__, name);
95#if defined(__GNUC__)
96#pragma GCC diagnostic pop
97#endif
98#endif // MICRO_OS_PLUS_TRACE_MICRO_TEST_PLUS_CONSTRUCTORS
99 }
const char * name(void) const noexcept
Gets the node name.
const char * name_
The test node name.
Definition test.h:224

References name(), and name_.

Referenced by micro_os_plus::micro_test_plus::detail::runnable_base::runnable_base(), micro_os_plus::micro_test_plus::runner::runner(), micro_os_plus::micro_test_plus::runner::runner(), test_node(), test_node(), operator=(), and operator=().

◆ test_node() [2/3]

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

References test_node().

◆ test_node() [3/3]

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

References test_node().

◆ ~test_node()

micro_os_plus::micro_test_plus::detail::test_node::~test_node ( )
virtual

No resources are owned by test_node; the destructor performs no explicit clean-up. If tracing is enabled, the node name is output for diagnostic purposes.

Definition at line 107 of file test.cpp.

108 {
109#if defined(MICRO_OS_PLUS_TRACE) \
110 && defined(MICRO_OS_PLUS_TRACE_MICRO_TEST_PLUS_CONSTRUCTORS)
111#if defined(__GNUC__)
112#pragma GCC diagnostic push
113#if defined(__clang__)
114#pragma clang diagnostic ignored "-Wunsafe-buffer-usage-in-libc-call"
115#endif
116#endif
117 trace::printf ("%s '%s'\n", __PRETTY_FUNCTION__, name_);
118#if defined(__GNUC__)
119#pragma GCC diagnostic pop
120#endif
121#endif // MICRO_OS_PLUS_TRACE_MICRO_TEST_PLUS_CONSTRUCTORS
122 }

References name_.

Member Function Documentation

◆ name()

◆ operator=() [1/2]

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

References test_node().

◆ operator=() [2/2]

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

References test_node(), and totals().

◆ totals() [1/2]

const runner_totals & micro_os_plus::micro_test_plus::detail::test_node::totals ( ) const
inlinenodiscardnoexcept
Parameters
None.
Returns
A const reference to the runner_totals instance.

Returns a const reference to the runner_totals member.

Definition at line 111 of file test-inlines.h.

112 {
113 return totals_;
114 }
runner_totals totals_
Totals for the test node, including nested cases.
Definition test.h:229

References totals_.

◆ totals() [2/2]

Member Data Documentation

◆ name_

const char* micro_os_plus::micro_test_plus::detail::test_node::name_
protected
Note
Derived classes may access this member directly in addition to the public name() getter.

Definition at line 224 of file test.h.

Referenced by test_node(), micro_os_plus::micro_test_plus::detail::runnable< Self_T >::~runnable(), micro_os_plus::micro_test_plus::detail::runnable_base::~runnable_base(), ~test_node(), and name().

◆ totals_


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