46#ifndef MICRO_OS_PLUS_MICRO_TEST_PLUS_INLINES_TEST_INLINES_H_
47#define MICRO_OS_PLUS_MICRO_TEST_PLUS_INLINES_TEST_INLINES_H_
51#if defined(__cplusplus)
58#if __has_include("micro-os-plus/diag/trace.h")
59#include "micro-os-plus/diag/trace.h"
68#pragma GCC diagnostic push
70#pragma GCC diagnostic ignored "-Waggregate-return"
72#pragma clang diagnostic ignored "-Wunknown-warning-option"
73#pragma clang diagnostic ignored "-Wc++98-compat"
74#pragma clang diagnostic ignored "-Wc++98-compat-pedantic"
75#pragma clang diagnostic ignored "-Wunsafe-buffer-usage-in-libc-call"
77#pragma GCC diagnostic ignored "-Wredundant-tags"
192 template <
typename Self_T>
193 template <
typename Callable_T,
typename... Args_T>
196 Args_T&&... arguments)
204 if constexpr (
sizeof...(arguments) == 0)
206 callable_ = std::forward<Callable_T> (callable);
210 callable_ = std::bind (std::forward<Callable_T> (callable),
211 std::placeholders::_1,
212 std::forward<Args_T> (arguments)...);
215#if defined(MICRO_OS_PLUS_MICRO_TEST_PLUS_TRACE_CONSTRUCTORS_ENABLED)
216 trace::printf (
"%s '%s' %zu\n", __PRETTY_FUNCTION__,
name,
own_index_);
226 template <
typename Self_T>
229#if defined(MICRO_OS_PLUS_MICRO_TEST_PLUS_TRACE_CONSTRUCTORS_ENABLED)
230 trace::printf (
"%s '%s'\n", __PRETTY_FUNCTION__,
name_);
244 template <
typename Callable_T,
typename... Args_T>
248 Args_T&&... arguments)
250 std::forward<Callable_T> (callable),
251 std::forward<Args_T> (arguments)... },
252 parent_suite_{ parent_suite }, nesting_depth_{ nesting_depth }
254#if defined(MICRO_OS_PLUS_MICRO_TEST_PLUS_TRACE_CONSTRUCTORS_ENABLED)
255 trace::printf (
"%s '%s' %zu %zu\n", __PRETTY_FUNCTION__, name, own_index_,
266 template <
typename Callable_T,
typename... Args_T>
269 Args_T&&... arguments)
271#if defined(MICRO_OS_PLUS_MICRO_TEST_PLUS_TRACE_ENABLED)
272 trace::printf (
"%s '%s'\n", __PRETTY_FUNCTION__,
name);
276 auto child_subtest = std::make_unique<subtest> (
278 std::forward<Callable_T> (callable),
279 std::forward<Args_T> (arguments)...);
290 template <
class Expr_T>
305 template <
class Expr_T>
333 template <
typename Callable_T,
typename... Args_T>
335 Args_T&&... arguments)
337 std::forward<Args_T> (arguments)... }
339#if defined(MICRO_OS_PLUS_MICRO_TEST_PLUS_TRACE_CONSTRUCTORS_ENABLED)
340 trace::printf (
"%s '%s' %zu\n", __PRETTY_FUNCTION__,
name,
own_index_);
345#pragma GCC diagnostic push
347#if defined(__clang__)
348#pragma clang diagnostic ignored "-Wdocumentation"
388 template <
typename Callable_T,
typename... Args_T>
392#if defined(MICRO_OS_PLUS_MICRO_TEST_PLUS_TRACE_ENABLED)
393 trace::printf (
"%s '%s'\n", __PRETTY_FUNCTION__,
name);
399 std::forward<Callable_T> (callable),
400 std::forward<Args_T> (arguments)...);
448 template <
typename Callable_T,
typename... Args_T>
450 Callable_T&& callable, Args_T&&... arguments)
455 if constexpr (
sizeof...(arguments) == 0)
462 std::placeholders::_1,
463 std::forward<Args_T> (arguments)...);
466#if defined(MICRO_OS_PLUS_MICRO_TEST_PLUS_TRACE_CONSTRUCTORS_ENABLED)
467 trace::printf (
"%s '%s' %zu\n", __PRETTY_FUNCTION__,
name,
own_index_);
479#pragma GCC diagnostic pop
480#pragma GCC diagnostic pop
Deferred reporter class for a specific expression.
class runner & runner(void) const noexcept
Gets the test runner associated with this test runnable.
size_t current_subtest_index() const noexcept
Returns the index of the most recently created child subtest.
runnable_base(const char *name, runner &runner, size_t own_index)
Constructs a runnable_base with a name, runner, and index.
void after_subtest_create_(std::unique_ptr< subtest > child_test, suite &suite)
size_t own_index_
The test index, counting from 1.
size_t own_index() const noexcept
Returns the positional index of this object within its parent.
size_t current_subtest_index_
The subtest index, counting from 1.
class reporter & reporter(void) const noexcept
size_t children_subtests_count(void) const noexcept
Returns the number of direct child subtests owned by this node.
class runner & runner_
Reference to the test runner that owns this object.
size_t increment_subtest_index() noexcept
Increments and returns the child subtest sequential index.
std::vector< std::unique_ptr< subtest > > children_subtests_
Owning collection of direct child subtests.
std::function< void(suite &)> callable_
runnable(const char *name, class runner &runner, size_t own_index, Callable_T &&callable, Args_T &&... arguments)
Class template constructor.
virtual ~runnable() override
Virtual destructor.
Aggregated pass/fail/subtest counters for a node in the test tree.
const char * name(void) const noexcept
Gets the node name.
runner_totals totals_
Totals for the test node, including nested cases.
runner_totals & totals() noexcept
Gets the totals for the test.
const char * name_
The test node name.
A begin/end timestamp pair used to measure elapsed time.
Local implementation of source location information for diagnostics.
detail::expression_formatter & expression()
Provides access to the expression formatter for this reporter.
The test runner for the µTest++ framework.
A runner variant that also manages statically-registered test suites.
std::function< void(static_suite &)> static_callable_
Callable storing the static suite body and any bound arguments. Invoked with a reference to the concr...
static_suite(const char *name, static_runner &runner, Callable_T &&callable, Args_T &&... arguments)
Class template constructor for static_suite.
suite & parent_suite_
Reference to the parent suite that owns this subtest.
void test(const char *name, Callable_T &&callable, Args_T &&... arguments)
Adds a test case to the suite.
subtest(const char *name, class runner &runner, suite &parent_suite, size_t own_index, size_t nesting_depth, Callable_T &&callable, Args_T &&... arguments)
Constructs a subtest with a name, runner, parent suite, index, nesting depth, and callable.
size_t nesting_depth_
The nesting depth of this subtest within the suite.
size_t nesting_depth() const noexcept
Returns the nesting depth of this subtest.
A named, runnable test suite registered with the test runner.
suite(const char *name, class runner &runner, Callable_T &&callable, Args_T &&... arguments)
Constructs a suite with a name, runner, and callable body.
detail::timestamps timings_
Timing measurements for this suite's execution.
detail::timestamps & timings() noexcept
Gets the timings for this suite.
void test(const char *name, Callable_T &&callable, Args_T &&... arguments)
Adds a test case to the suite.
const char * name(void) const noexcept
Gets the node name.
C++20 concept satisfied when a type can be used as a test expression in expect() or assume().
C++ header file with declarations for the µTest++ deferred reporter.
auto assume(const Expr_T &expr, const reflection::source_location &sl=reflection::source_location::current())
Check a condition and, if false, abort test execution.
auto expect(const Expr_T &expr, const reflection::source_location &sl=reflection::source_location::current())
Evaluate a generic condition and report the results.
Internal implementation details for the µTest++ framework.
void register_static_suite(static_runner &static_runner_ref, static_suite &static_suite_ref)
Registers a static suite with a static runner.
Primary namespace for the µTest++ testing framework.
C++ header file with declarations for the µTest++ test reporter.