micro-test-plus 5.0.0
µ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_TEST_PLUS_TEST_RUNNER_INLINES_H_
40#define MICRO_TEST_PLUS_TEST_RUNNER_INLINES_H_
41
42// ----------------------------------------------------------------------------
43
44#ifdef __cplusplus
45
46// ----------------------------------------------------------------------------
47
48#include <micro-os-plus/diag/trace.h>
49
50// ----------------------------------------------------------------------------
51
52#if defined(__GNUC__)
53#pragma GCC diagnostic push
54#pragma GCC diagnostic ignored "-Waggregate-return"
55#if defined(__clang__)
56#pragma clang diagnostic ignored "-Wunknown-warning-option"
57#pragma clang diagnostic ignored "-Wc++98-compat"
58#pragma clang diagnostic ignored "-Wc++98-compat-pedantic"
59#else // GCC only
60#pragma GCC diagnostic ignored "-Wredundant-tags"
61#endif
62#endif
63
64// ============================================================================
65
67{
68 // ==========================================================================
69
74 inline class reporter&
75 runner::reporter (void) const noexcept
76 {
77 return *reporter_;
78 }
79
84 inline detail::timestamps&
85 runner::timings () noexcept
86 {
87 return timings_;
88 }
89
94 inline const detail::timestamps&
95 runner::timings () const noexcept
96 {
97 return timings_;
98 }
99
100 // --------------------------------------------------------------------------
101
109 template <typename Callable_T, typename... Args_T>
110 void
111 runner::suite (const char* name, Callable_T&& callable,
112 Args_T&&... arguments)
113 {
114#if defined(MICRO_OS_PLUS_MICRO_TEST_PLUS_TRACE_ENABLED)
115#if defined(__GNUC__)
116#pragma GCC diagnostic push
117#if defined(__clang__)
118#pragma clang diagnostic ignored "-Wunsafe-buffer-usage-in-libc-call"
119#endif
120#endif
121 trace::printf ("%s '%s'\n", __PRETTY_FUNCTION__, name);
122#if defined(__GNUC__)
123#pragma GCC diagnostic pop
124#endif
125#endif // MICRO_OS_PLUS_MICRO_TEST_PLUS_TRACE_ENABLED
126
127 auto child_suite = std::make_unique<class suite> (
128 name, *this, std::forward<Callable_T> (callable),
129 std::forward<Args_T> (arguments)...);
130
131 register_suite_ (std::move (child_suite));
132 }
133
134 // --------------------------------------------------------------------------
135} // namespace micro_os_plus::micro_test_plus
136
137#if defined(__GNUC__)
138#pragma GCC diagnostic pop
139#endif
140
141// ----------------------------------------------------------------------------
142
143#endif // __cplusplus
144
145// ----------------------------------------------------------------------------
146
147#endif // MICRO_TEST_PLUS_TEST_RUNNER_INLINES_H_
148
149// ----------------------------------------------------------------------------
const char * name(void) const noexcept
Gets the node name.
A begin/end timestamp pair used to measure elapsed time.
Definition timings.h:205
Reporter to display test results, including operand values and types for failures.
Definition reporter.h:186
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:311
void register_suite_(std::unique_ptr< class suite > suite)
Registers a test suite with the runner.
Definition runner.cpp:311
std::unique_ptr< class reporter > reporter_
Pointer to the test reporter used for outputting test results.
Definition runner.h:306
Primary namespace for the µTest++ testing framework.