micro-test-plus 5.0.1
µTest++ Testing Framework
Loading...
Searching...
No Matches
runner-inlines.h
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 * Major parts of the code are inspired from v1.1.8 of the Boost UT project,
12 * released under the terms of the Boost Version 1.0 Software License,
13 * which can be obtained from https://www.boost.org/LICENSE_1_0.txt.
14 */
15
16// ----------------------------------------------------------------------------
17
38
39#ifndef MICRO_OS_PLUS_MICRO_TEST_PLUS_INLINES_RUNNER_INLINES_H_
40#define MICRO_OS_PLUS_MICRO_TEST_PLUS_INLINES_RUNNER_INLINES_H_
41
42// ----------------------------------------------------------------------------
43
44#if defined(__cplusplus)
45
46// ----------------------------------------------------------------------------
47
48#if __has_include("micro-os-plus/diag/trace.h")
49#include "micro-os-plus/diag/trace.h"
50#endif // __has_include("micro-os-plus/diag/trace.h")
51
52// ----------------------------------------------------------------------------
53
54#if defined(__GNUC__)
55#pragma GCC diagnostic push
56
57#pragma GCC diagnostic ignored "-Waggregate-return"
58#if defined(__clang__)
59#pragma clang diagnostic ignored "-Wunknown-warning-option"
60#pragma clang diagnostic ignored "-Wc++98-compat"
61#pragma clang diagnostic ignored "-Wc++98-compat-pedantic"
62#pragma clang diagnostic ignored "-Wunsafe-buffer-usage-in-libc-call"
63#else // GCC only
64#pragma GCC diagnostic ignored "-Wredundant-tags"
65#endif // defined(__clang__)
66#endif // defined(__GNUC__)
67
68// ============================================================================
69
71{
72 // ==========================================================================
73
78 inline class reporter&
79 runner::reporter (void) const noexcept
80 {
81 return *reporter_;
82 }
83
88 inline detail::timestamps&
89 runner::timings () noexcept
90 {
91 return timings_;
92 }
93
98 inline const detail::timestamps&
99 runner::timings () const noexcept
100 {
101 return timings_;
102 }
103
104 // --------------------------------------------------------------------------
105
113 template <typename Callable_T, typename... Args_T>
114 void
115 runner::suite (const char* name, Callable_T&& callable,
116 Args_T&&... arguments)
117 {
118#if defined(MICRO_OS_PLUS_MICRO_TEST_PLUS_TRACE_ENABLED)
119 trace::printf ("%s '%s'\n", __PRETTY_FUNCTION__, name);
120#endif // MICRO_OS_PLUS_MICRO_TEST_PLUS_TRACE_ENABLED
121
122 auto child_suite = std::make_unique<class suite> (
123 name, *this, std::forward<Callable_T> (callable),
124 std::forward<Args_T> (arguments)...);
125
126 register_suite_ (std::move (child_suite));
127 }
128
129 // --------------------------------------------------------------------------
130} // namespace micro_os_plus::micro_test_plus
131
132#if defined(__GNUC__)
133#pragma GCC diagnostic pop
134#endif // defined(__GNUC__)
135
136// ----------------------------------------------------------------------------
137
138#endif // defined(__cplusplus)
139
140// ----------------------------------------------------------------------------
141
142#endif // MICRO_OS_PLUS_MICRO_TEST_PLUS_INLINES_RUNNER_INLINES_H_
143
144// ----------------------------------------------------------------------------
const char * name(void) const noexcept
Gets the node name.
A begin/end timestamp pair used to measure elapsed time.
Definition timings.h:214
Reporter to display test results, including operand values and types for failures.
Definition reporter.h:195
detail::timestamps & timings() noexcept
Gets the timings for this runner.
class reporter & reporter(void) const noexcept
Returns a reference to the test reporter.
void suite(const char *name, Callable_T &&callable, Args_T &&... arguments)
Adds a test suite to the runner.
detail::timestamps timings_
Timings for this runner.
Definition runner.h:344
void register_suite_(std::unique_ptr< class suite > suite)
Registers a test suite with the runner.
Definition runner.cpp:291
std::unique_ptr< class reporter > reporter_
Pointer to the test reporter used for outputting test results.
Definition runner.h:339
Primary namespace for the µTest++ testing framework.