48#ifndef MICRO_TEST_PLUS_TEST_H_
49#define MICRO_TEST_PLUS_TEST_H_
68#pragma GCC diagnostic push
69#pragma GCC diagnostic ignored "-Wpadded"
71#pragma clang diagnostic ignored "-Wc++98-compat"
73#pragma GCC diagnostic ignored "-Wsuggest-final-types"
74#pragma GCC diagnostic ignored "-Wsuggest-final-methods"
75#pragma GCC diagnostic ignored "-Wredundant-tags"
109 to_runner (static_runner& static_runner_ref)
noexcept;
123 static_suite& static_suite_ref);
193 [[nodiscard]]
const char*
194 name (
void)
const noexcept;
379 [[nodiscard]] class
runner&
380 runner (
void) const noexcept;
442 template <typename Self_T>
459 template <
typename Callable_T,
typename... Args_T>
461 Callable_T&& callable, Args_T&&... arguments);
562 template <
typename Callable_T,
typename... Args_T>
565 Args_T&&... arguments);
610 template <
typename Callable_T,
typename... Args_T>
612 test (
const char*
name, Callable_T&& callable, Args_T&&... arguments);
630 template <
class Expr_T>
650 template <
class Expr_T>
730 template <
typename Callable_T,
typename... Args_T>
732 Args_T&&... arguments);
761 virtual ~suite ()
override;
777 template <
typename Callable_T,
typename... Args_T>
779 test (
const char*
name, Callable_T&& callable, Args_T&&... arguments);
800 [[nodiscard]] const
detail::timestamps&
889 name (
const char* new_name)
noexcept;
939 template <
typename Callable_T,
typename... Args_T>
941 Callable_T&& callable, Args_T&&... arguments);
997#pragma GCC diagnostic pop
runnable_base(const runnable_base &)=delete
Deleted copy constructor to prevent copying.
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.
runnable_base(runnable_base &&)=delete
Deleted move constructor to prevent moving.
void after_subtest_create_(std::unique_ptr< subtest > child_test, suite &suite)
Registers a newly constructed child subtest and executes it immediately.
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
Gets the test reporter associated with this test runnable.
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.
void abort(const reflection::source_location &sl=reflection::source_location::current())
Aborts test execution via the owning runner.
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.
CRTP base class factoring out callable storage, rule-of-five, and run() logic shared by subtest and s...
std::function< void(Self_T &)> callable_
Callable storing the test body and any bound arguments. Invoked with a reference to the derived Self_...
runnable(const char *name, class runner &runner, size_t own_index, Callable_T &&callable, Args_T &&... arguments)
Class template constructor.
runnable(const runnable &)=delete
Deleted copy constructor to prevent copying.
runnable(runnable &&)=delete
Deleted move constructor to prevent moving.
virtual void run(void)=0
Runs the test function by invoking the stored callable with the derived self instance.
Aggregated pass/fail/subtest counters for a node in the test tree.
const char * name(void) const noexcept
Gets the node name.
virtual ~test_node()
Virtual destructor for the test_node class.
runner_totals totals_
Totals for the test node, including nested cases.
runner_totals & totals() noexcept
Gets the totals for the test.
test_node(const char *name)
Constructs a test node.
test_node(test_node &&)=delete
Deleted move constructor to prevent moving.
const char * name_
The test node name.
test_node(const test_node &)=delete
Deleted copy constructor to prevent copying.
test_node & operator=(const test_node &)=delete
Deleted copy assignment operator to prevent copying.
A begin/end timestamp pair used to measure elapsed time.
Local implementation of source location information for diagnostics.
static constexpr source_location current(const char *file="unknown", unsigned int line={}) noexcept
Obtain the current source location.
Reporter to display test results, including operand values and types for failures.
The test runner for the µTest++ framework.
A runner variant that also manages statically-registered test suites.
A test suite designed for static (namespace-scope) registration with a static_runner.
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(static_suite &&)=delete
Deleted move constructor to prevent moving.
virtual void run(void) override
Executes the static suite body using the stored static callable.
static_suite(const char *name, static_runner &runner, Callable_T &&callable, Args_T &&... arguments)
Class template constructor for static_suite.
static_suite(const static_suite &)=delete
Deleted copy constructor to prevent copying.
A named, runnable test case that lives inside a suite.
suite & parent_suite_
Reference to the parent suite that owns this subtest.
subtest(subtest &&)=delete
Deleted move constructor to prevent moving.
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.
virtual void run(void) override
Executes the subtest body by invoking the stored callable.
subtest(const subtest &)=delete
Deleted copy constructor to prevent copying.
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.
virtual void run(void) override
Executes the suite body by invoking the stored callable.
suite(const suite &)=delete
Deleted copy constructor to prevent copying.
detail::timestamps timings_
Timing measurements for this suite's execution.
detail::timestamps & timings() noexcept
Gets the timings for this suite.
suite(suite &&)=delete
Deleted move constructor to prevent moving.
void test(const char *name, Callable_T &&callable, Args_T &&... arguments)
Adds a test case to the suite.
top_suite(top_suite &&)=delete
Deleted move constructor to prevent moving.
void name(const char *new_name) noexcept
Sets the name of the top-level suite.
top_suite(const char *name, class runner &runner)
Constructs the top-level suite with a name and runner reference.
top_suite(const top_suite &)=delete
Deleted copy constructor to prevent copying.
C++20 concept satisfied when a type can be used as a test expression in expect() or assume().
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.
runner & to_runner(static_runner &static_runner_ref) noexcept
Converts a static_runner reference to a runner reference.
void register_static_suite(static_runner &static_runner_ref, static_suite &static_suite_ref)
Registers a static suite with a static runner.
Reflection utilities for the µTest++ testing framework.
Primary namespace for the µTest++ testing framework.
C++ header file with declarations for the µTest++ reflection utilities.
C++ header file with declarations for the µTest++ runner totals.
C++ header file with inline implementations for the µTest++ test suite.
C++ header file with declarations for the µTest++ timing utilities.
C++ header file with declarations for the µTest++ type trait utilities and metaprogramming support.