Skip to main content

detail Namespace

Internal implementation details for the µTest++ framework. More...

Definition

namespace micro_os_plus::micro_test_plus::detail { ... }

Classes Index

structand_<Lhs_T, Rhs_T>

Logical AND comparator struct template. More...

structassertion<Expr_T>

Assertion struct template for parameter passing to the evaluator. More...

structbinary_op_<Lhs_T, Rhs_T>

Common base struct template for binary comparators. More...

structcallable_op_

Common base struct for callable-wrapping operators. More...

structcolours

Colours used to highlight pass and fail results in test reports. More...

classdeferred_reporter

Deferred reporter class for a specific expression. More...

classdeferred_reporter_base

Base class for a deferred reporter that collects messages into a string. More...

structeq_<Lhs_T, Rhs_T>

Equality comparator struct template. More...

classexpression_formatter

Formats values and expressions into an owned string buffer. More...

structge_<Lhs_T, Rhs_T>

Greater than or equal comparator struct template. More...

structgt_<Lhs_T, Rhs_T>

Greater than comparator struct template. More...

structindent_t

Parameterised stream manipulator for outputting indentation. More...

structle_<Lhs_T, Rhs_T>

Less than or equal comparator struct template. More...

structlt_<Lhs_T, Rhs_T>

Less than comparator struct template. More...

structne_<Lhs_T, Rhs_T>

Non-equality comparator struct template. More...

structnot_<T>

Logical NOT comparator struct template. More...

structnothrow_<Callable_T>

Operator struct template to check if an expression does not throw any exception. More...

structor_<Lhs_T, Rhs_T>

Logical OR comparator struct template. More...

classrunnable<Self_T>

CRTP base class factoring out callable storage, rule-of-five, and run() logic shared by subtest and suite. More...

classrunnable_base

Non-template base for all runnable objects (suites and subtests). More...

classrunner_totals

Aggregated pass/fail/subtest counters for a node in the test tree. More...

classtest_node

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

structthrows_<Callable_T, Exception_T>

Operator struct template to check if an expression throws a specific exception. More...

structthrows_<Callable_T, void>

Operator struct template to check if an expression throws any exception. More...

classtimestamp

A single point-in-time measurement, wrapping a timespec value. More...

classtimestamps

A begin/end timestamp pair used to measure elapsed time. More...

structunary_op_<T>

Common base struct template for unary comparators. More...

Functions Index

template <typename Lhs_T, typename Rhs_T>
and_ (const Lhs_T &, const Rhs_T &) -> and_< Lhs_T, Rhs_T >
template <class T>
voidappend_number_ (std::string &buffer, T v)

Appends the string representation of a numeric value to a buffer, using std::to_chars for allocation-free, locale-independent formatting. More...

template <typename Lhs_T, typename Rhs_T>
eq_ (const Lhs_T &, const Rhs_T &) -> eq_< Lhs_T, Rhs_T >
template <typename Lhs_T, typename Rhs_T>
ge_ (const Lhs_T &, const Rhs_T &) -> ge_< Lhs_T, Rhs_T >
template <class T>
constexpr autoget (const T &t)

Generic getter function template for value retrieval. More...

template <typename Lhs_T, typename Rhs_T>
gt_ (const Lhs_T &, const Rhs_T &) -> gt_< Lhs_T, Rhs_T >
template <typename Lhs_T, typename Rhs_T>
le_ (const Lhs_T &, const Rhs_T &) -> le_< Lhs_T, Rhs_T >
template <typename Lhs_T, typename Rhs_T>
lt_ (const Lhs_T &, const Rhs_T &) -> lt_< Lhs_T, Rhs_T >
template <typename Lhs_T, typename Rhs_T>
ne_ (const Lhs_T &, const Rhs_T &) -> ne_< Lhs_T, Rhs_T >
template <typename T>
not_ (const T &) -> not_< T >
template <typename Lhs_T, typename Rhs_T>
or_ (const Lhs_T &, const Rhs_T &) -> or_< Lhs_T, Rhs_T >
voidregister_static_suite (static_runner &static_runner_ref, static_suite &static_suite_ref)

Registers a static suite with a static runner. More...

runner &to_runner (static_runner &static_runner_ref) noexcept

Converts a static_runner reference to a runner reference. More...

Variables Index

constexpr colourscolours_red_green = ...

Description

Internal implementation details for the µTest++ framework.

The detail namespace encapsulates the internal mechanisms, helper structures, and implementation utilities employed by the µTest++ testing framework. These components do not form part of the public API and may be modified without prior notice.

Within this namespace, one will find assertion handling, generic getter utilities, comparator structures for logical and relational operations, mechanisms for exception checking, and base classes for deferred reporting of test results.

All definitions within detail are intended exclusively for internal use, ensuring a clear distinction between user-facing and internal components. This approach enhances maintainability, mitigates the risk of naming conflicts, and keeps the public API succinct.

The relevant header files are organised within the include/micro-os-plus folder to maintain a structured and modular codebase.

Functions

and_()

template <typename Lhs_T, typename Rhs_T>
micro_os_plus::micro_test_plus::detail::and_ (const Lhs_T &, const Rhs_T &)

Definition at line 524 of file detail.h.

append_number_()

template <class T>
void micro_os_plus::micro_test_plus::detail::append_number_ (std::string & buffer, T v)

Appends the string representation of a numeric value to a buffer, using std::to_chars for allocation-free, locale-independent formatting.

Template Parameters
T

The numeric type to format.

Parameters
buffer

The string to append to.

v

The value to format.

Returns

Nothing.

For long double, a platform-specific path is chosen:

  • On Windows and on platforms where long double has the same storage width as double (e.g., ARM, RISC-V), the value is cast to double and formatted with std::to_chars.
  • On x86-64 Linux/macOS with 80-bit extended precision, snprintf with Lg is used as a portable fallback because std::to_chars for long double may be unavailable when linking with lld.

For all other numeric types, std::to_chars is called directly, providing locale-independent, allocation-free formatting.

Definition at line 674 of file detail-inlines.h.

674 append_number_ (std::string& buffer, const T v)
675 {
676 char buf[32];
677 if constexpr (std::is_same_v<T, long double>)
678 {
679#if defined(_WIN32) \
680 || (defined(__SIZEOF_LONG_DOUBLE__) \
681 && __SIZEOF_LONG_DOUBLE__ == __SIZEOF_DOUBLE__)
682 // On Windows (all toolchains: MinGW, Clang, MSVC), the C runtime
683 // does not handle the %Lg printf specifier correctly for 80-bit
684 // long double, producing garbage output. On platforms where long
685 // double has the same width as double (ARM, RISC-V), the cast is
686 // lossless. In both cases, cast to double and use std::to_chars.
687 const auto [ptr, ec] = std::to_chars (buf, buf + sizeof (buf),
688 static_cast<double> (v));
689 if (ec == std::errc{})
690 buffer.append (buf, ptr);
691#else
692 // On x86-64 Linux/macOS with 80-bit extended-precision long double,
693 // std::to_chars for long double may be unavailable (e.g., with lld).
694 // Use snprintf as a portable fallback; %Lg is supported correctly
695 // by glibc and libc++ on these platforms.
696 snprintf (buf, sizeof (buf), "%Lg", v);
697 buffer.append (buf);
698#endif // defined(_WIN32) || (defined(__SIZEOF_LONG_DOUBLE__) && __SIZEOF_LONG_DOUBLE__ == __SIZEOF_DOUBLE__)
699 }
700 else
701 {
702 const auto [ptr, ec] = std::to_chars (buf, buf + sizeof (buf), v);
703 if (ec == std::errc{})
704 buffer.append (buf, ptr);
705 }
706 }

Referenced by micro_os_plus::micro_test_plus::detail::expression_formatter::operator<<, micro_os_plus::micro_test_plus::detail::expression_formatter::operator<<, micro_os_plus::micro_test_plus::detail::expression_formatter::operator<<, micro_os_plus::micro_test_plus::detail::expression_formatter::operator<<, micro_os_plus::micro_test_plus::detail::expression_formatter::operator<<, micro_os_plus::micro_test_plus::detail::expression_formatter::operator<<, micro_os_plus::micro_test_plus::detail::expression_formatter::operator<<, micro_os_plus::micro_test_plus::detail::expression_formatter::operator<<, micro_os_plus::micro_test_plus::detail::expression_formatter::operator<<, micro_os_plus::micro_test_plus::detail::expression_formatter::operator<<, micro_os_plus::micro_test_plus::detail::expression_formatter::operator<<, micro_os_plus::micro_test_plus::detail::expression_formatter::operator<<, micro_os_plus::micro_test_plus::detail::expression_formatter::operator<<, micro_os_plus::micro_test_plus::detail::expression_formatter::operator<< and micro_os_plus::micro_test_plus::reporter::operator<<.

eq_()

template <typename Lhs_T, typename Rhs_T>
micro_os_plus::micro_test_plus::detail::eq_ (const Lhs_T &, const Rhs_T &)

Definition at line 327 of file detail.h.

ge_()

template <typename Lhs_T, typename Rhs_T>
micro_os_plus::micro_test_plus::detail::ge_ (const Lhs_T &, const Rhs_T &)

Definition at line 425 of file detail.h.

get()

template <class T>
auto micro_os_plus::micro_test_plus::detail::get (const T & t)
nodiscard constexpr

Generic getter function template for value retrieval.

Template Parameters
T

The type from which the value is to be retrieved.

Parameters
t

The object or value to be accessed.

Returns

The value obtained via the relevant getter implementation.

If the type T provides a get() member function, it is invoked and its result returned. Otherwise the argument itself is returned unchanged. The selection is performed at compile time via if constexpr with an inline requires expression.

Definition at line 83 of file detail-inlines.h.

83 get (const T& t)
84 {
85 if constexpr (requires { t.get (); })
86 return t.get ();
87 else
88 return t;
89 }

Referenced by micro_os_plus::micro_test_plus::detail::eq_< Lhs_T, Rhs_T >::eq_, micro_os_plus::micro_test_plus::detail::ge_< Lhs_T, Rhs_T >::ge_, micro_os_plus::micro_test_plus::detail::gt_< Lhs_T, Rhs_T >::gt_, micro_os_plus::micro_test_plus::detail::le_< Lhs_T, Rhs_T >::le_, micro_os_plus::micro_test_plus::detail::lt_< Lhs_T, Rhs_T >::lt_, micro_os_plus::micro_test_plus::detail::ne_< Lhs_T, Rhs_T >::ne_, micro_os_plus::micro_test_plus::detail::binary_op_< Lhs_T, Rhs_T >::lhs, micro_os_plus::micro_test_plus::detail::unary_op_< T >::operand, micro_os_plus::micro_test_plus::detail::expression_formatter::operator<< and micro_os_plus::micro_test_plus::detail::binary_op_< Lhs_T, Rhs_T >::rhs.

gt_()

template <typename Lhs_T, typename Rhs_T>
micro_os_plus::micro_test_plus::detail::gt_ (const Lhs_T &, const Rhs_T &)

Definition at line 391 of file detail.h.

le_()

template <typename Lhs_T, typename Rhs_T>
micro_os_plus::micro_test_plus::detail::le_ (const Lhs_T &, const Rhs_T &)

Definition at line 491 of file detail.h.

lt_()

template <typename Lhs_T, typename Rhs_T>
micro_os_plus::micro_test_plus::detail::lt_ (const Lhs_T &, const Rhs_T &)

Definition at line 457 of file detail.h.

ne_()

template <typename Lhs_T, typename Rhs_T>
micro_os_plus::micro_test_plus::detail::ne_ (const Lhs_T &, const Rhs_T &)

Definition at line 359 of file detail.h.

not_()

template <typename T>
micro_os_plus::micro_test_plus::detail::not_ (const T &)

Definition at line 587 of file detail.h.

or_()

template <typename Lhs_T, typename Rhs_T>
micro_os_plus::micro_test_plus::detail::or_ (const Lhs_T &, const Rhs_T &)

Definition at line 557 of file detail.h.

register_static_suite()

void micro_os_plus::micro_test_plus::detail::register_static_suite (static_runner & static_runner_ref, static_suite & static_suite_ref)

Registers a static suite with a static runner.

This declaration allows test-inlines.h to request registration without requiring the complete static_runner type in that header.

Parameters
static_runner_ref

The destination static runner.

static_suite_ref

The static suite to register.

Performs static-suite registration where static_runner is complete, allowing header-only template code to avoid direct dependence on runner.h include order.

Declaration at line 131 of file test.h, definition at line 95 of file runner.cpp.

96 static_suite& static_suite_ref)
97 {
98 static_runner::register_static_suite (static_runner_ref, static_suite_ref);
99 }

Reference micro_os_plus::micro_test_plus::static_runner::register_static_suite.

to_runner()

runner & micro_os_plus::micro_test_plus::detail::to_runner (static_runner & static_runner_ref)
noexcept

Converts a static_runner reference to a runner reference.

This declaration breaks the include-order cycle between test and runner headers. The definition is provided in a translation unit where both types are complete, so the conversion remains type-safe.

Parameters
static_runner_ref

The source static_runner reference.

Returns

The same object viewed as its runner base.

Performs the static_runner to runner upcast where both types are complete, allowing headers with only forward declarations to request this conversion safely.

Declaration at line 118 of file test.h, definition at line 83 of file runner.cpp.

83 detail::to_runner (static_runner& static_runner_ref) noexcept
84 {
85 return static_cast<runner&> (static_runner_ref);
86 }

Variables

colours_red_green

colours micro_os_plus::micro_test_plus::detail::colours_red_green
constexpr
Initialiser
                                           = {   "\033[0m",   "\033[32m",   "\033[31m" }

Definition at line 132 of file expression-formatter.h.

132 inline constexpr colours colours_red_green = {
133 "\033[0m",
134 "\033[32m",
135 "\033[31m"
136 };

Referenced by micro_os_plus::micro_test_plus::reporter_human::reporter_human.


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


Generated via doxygen2docusaurus 2.2.2 by Doxygen 1.17.0.