micro-test-plus 6.0.1
µTest++ Testing Framework
Loading...
Searching...
No Matches
micro_os_plus::micro_test_plus::detail Namespace Reference

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

Namespaces

namespace  anonymous_namespace{expression-formatter.cpp}
 Local helpers of the expression formatter.
namespace  anonymous_namespace{reporter-tap.cpp}
 Local helpers of the TAP reporter.
namespace  anonymous_namespace{reporter.cpp}
 Local helpers of the reporter base class.
namespace  comparison_lookup
 Names for the checks of the comparison operators, looked up as the apply() functions look them up.
namespace  math
 Internal mathematical utilities for the µTest++ testing framework.

Classes

struct  and_op
 Logical AND comparator struct template. More...
struct  approx_op
 Approximate comparator struct template. More...
struct  array_operand
 An array operand of a comparator, other than a character array. More...
struct  basic_c_string
 A C string operand of a comparator. More...
struct  binary_op
 Common base struct template for binary comparators. More...
class  bound_callable
 Function object that holds a callable and the additional arguments it is invoked with. More...
struct  callable_op
 Common base struct for callable-wrapping operators. More...
class  callable_ref
 Non-owning reference to a callable invoked with a Self_T& argument. More...
struct  callable_result
 The result of the invocation of the callable of a check. More...
class  check_result
 The result of one check, reported when destroyed. More...
struct  colours
 Colours used to highlight pass and fail results in test reports. More...
struct  compare_op
 Relational comparator struct template. More...
struct  comparison_integer
 The integer type used to compare a value of type T. More...
struct  comparison_integer< T >
 The integer type used to compare a character type. More...
struct  equal_to
 Equality tag for compare_op. More...
class  expression_formatter
 Formats values and expressions into an owned string buffer. More...
struct  failed_requirement
 The exception thrown to stop a test case after a failed require(). More...
struct  failure_info
 The details of a check, displayed when it fails. More...
struct  floating_point_constant
 Struct template representing a generic floating-point constant with custom size and precision. More...
struct  greater
 Greater than tag for compare_op. More...
struct  greater_equal
 Greater than or equal tag for compare_op. More...
struct  indentation
 Parameterised stream manipulator for outputting indentation. More...
struct  integral_constant
 Struct template representing a generic integral constant. More...
struct  integral_min_magnitude
 Struct template representing the absolute value of the minimum of a signed integral type, as written in a literal. More...
struct  is_bool_wrapper
 Trait marking the wrappers of a bool, whose condition is ambiguous. More...
struct  is_bool_wrapper< std::optional< T > >
 The specialisation for std::optional<bool>.
struct  is_bool_wrapper< std::shared_ptr< T > >
 The specialisation for std::shared_ptr of bool.
struct  is_bool_wrapper< std::unique_ptr< T, Deleter_T > >
 The specialisation for std::unique_ptr of bool.
struct  less
 Less than tag for compare_op. More...
struct  less_equal
 Less than or equal tag for compare_op. More...
struct  named_bool
 Struct representing a named boolean constant, created by the _b literal. More...
struct  not_equal_to
 Non-equality tag for compare_op. More...
struct  not_op
 Logical NOT comparator struct template. More...
struct  nothrow_op
 Operator struct to check if an expression does not throw any exception. More...
struct  op
 Empty base struct for the framework expression types. More...
struct  or_op
 Logical OR comparator struct template. More...
struct  output_route
 The destinations of a record. More...
struct  plain_text
 Writes values as text, as the messages of the checks are written. More...
struct  predicate_op
 Unary predicate struct template. More...
struct  range_element
 The type of the elements of a range, as iterated by a range-based for statement. More...
struct  range_element< T >
 The type of the elements of a range with begin() and end() members. More...
class  reporter
 Abstract base class for the reporters that display test results, including operand values for failures. More...
class  reporter_human
 Human (standard output) implementation of reporter. More...
class  reporter_tap
 TAP (Test Anything Protocol) implementation of reporter. More...
class  runnable_base
 Non-template base for all runnable objects (suites and test cases). More...
class  stopwatch
 Measures the elapsed time of an operation. More...
struct  throws_op
 Operator struct template to check if an expression throws a specific exception. More...
struct  throws_op< void >
 Operator struct to check if an expression throws any exception. More...
class  timestamp
 Deprecated clock reading. More...
struct  unary_op
 Common base struct template for unary comparators. More...
struct  value
 Struct template representing a generic value, accessible via a getter. More...
struct  value< T >
 Struct template representing a floating-point value with precision control. More...
struct  value_base
 Base struct template providing common storage and accessors for run-time value-wrapper types. More...

Concepts

concept  ambiguous_condition
 Concept satisfied by the wrappers of a bool, whose condition is ambiguous.
concept  character
 Concept satisfied by the character types.
concept  character_pointer
 Concept satisfied by the pointers to the character types.
concept  comparable
 Concept satisfied when two operands can be compared by the comparator selected by Op.
concept  comparable_operands
 Concept satisfied when the operands of a comparator can be written and compared.
concept  container_like
 Concept satisfied when T provides both begin() and end() member functions returning an iterator and its sentinel.
concept  formattable_range
 Concept satisfied when T is a range that the formatter writes element by element.
concept  free_printable
 Concept satisfied by the types that have a free operator<< for the formatter.
concept  free_range
 Concept satisfied when T provides begin() and end() only as functions found by argument-dependent lookup.
concept  function_pointer_pair
 Concept satisfied by two pointers, one of which points to a function.
concept  generic_callable
 Concept satisfied by a callable object whose call operator is not a single non-template member function.
concept  has_value
 Concept satisfied when T is a framework compile-time constant.
concept  lazy_message
 Concept satisfied when T is a callable object that returns a printable message.
concept  legacy_checkable
 Concept satisfied when a type was accepted by expect() and require() before the exclusion of the suspicious conditions.
concept  member_printable
 Concept satisfied by the types that the formatter writes with one of its own member functions operator<<.
concept  message_argument
 Concept satisfied when T can be appended to the message of a check.
concept  sign_mixed_integers
 Concept satisfied by two integer types of different signedness.
concept  static_suite_body
 The body of a static suite written for v5.0.1, whose first parameter is a static_suite& reference.
concept  string_like
 Concept satisfied when T is a string, convertible to a std::basic_string_view of a character type.
concept  suite_body
 Concept satisfied by a callable object that can be the body of a suite.
concept  suspicious_condition
 Concept satisfied when a type is contextually convertible to bool, but is most likely not a condition.
concept  tag_has_symbol
 Concept satisfied when the tag of a comparator or of a predicate has a symbol that can be written.
concept  test_body
 Concept satisfied by a callable object that can be the body of a test case.
concept  test_values_range
 Concept satisfied when T is a range of values for test_each().
concept  test_values_tuple
 Concept satisfied when T is a tuple of values for test_each().
concept  unsupported_condition
 Concept satisfied by a value that expect() and require() do not accept.

Typedefs

using c_string = basic_c_string<char>
 The C string operand of char strings.
template<class T>
using comparison_integer_t = typename comparison_integer<T>::type
 Alias of the integer type used to compare the type T.
template<class T>
using comparison_operand_t = unwrapped_t<decltype (detail::as_operand (std::declval<T> ()))>
 The type with which an operand of a comparator is compared.
using runner_totals = counters
 Deprecated name of counters.
template<class T>
using stored_operand_t
 The type with which an expression stores an operand.
using timestamps = stopwatch
 Deprecated name of stopwatch.
template<class T>
using unwrapped_t
 The type of an operand, after the framework wrappers are removed by detail::unwrap().

Enumerations

enum class  check_kind {
  expectation ,
  requirement
}
 The kind of a check, which determines what happens when it fails. More...
enum class  comparison : unsigned char {
  equal ,
  not_equal ,
  greater ,
  greater_equal ,
  less ,
  less_equal
}
 The comparison operators, as the template argument of the comparable concept. More...
enum class  record_kind : uint8_t {
  info ,
  suite_heading ,
  suite_result ,
  test_case_heading ,
  test_case_result ,
  skipped ,
  passed_check ,
  failed_check ,
  total ,
  abort
}
 The kinds of records written by the reporters. More...
enum class  throw_outcome : unsigned char {
  none ,
  std_exception ,
  unknown_exception
}
 The kind of exception thrown by the callable of a check. More...

Functions

template<typename Lhs_T, typename Rhs_T>
 and_op (Lhs_T &&, Rhs_T &&) -> and_op< stored_operand_t< Lhs_T >, stored_operand_t< Rhs_T > >
 Deduction guide for the logical AND comparator.
void append_control_escape (std::string &text, char c)
 Appends the escape sequence of a control character.
template<class T>
requires std::is_arithmetic_v<T>
void append_number (std::string &buffer, T v)
 Appends the shortest decimal representation of a numeric value to a buffer.
template<class T>
void append_pointer (std::string &buffer, T *v)
 Appends the hexadecimal address of a pointer to a buffer.
template<class Lhs_T, class Rhs_T, class Epsilon_T>
 approx_op (Lhs_T &&, Rhs_T &&, Epsilon_T &&) -> approx_op< stored_operand_t< Lhs_T >, stored_operand_t< Rhs_T >, stored_operand_t< Epsilon_T > >
 Deduction guide for the approximate comparator.
template<class T>
constexpr comparison_integer_t< T > as_comparison_integer (const T value) noexcept
 Converts an integer or a character to the type used to compare it.
template<class T>
constexpr auto as_operand (T &&t) noexcept -> decltype(auto)
 Prepares an operand of a comparator.
template<typename Self_T, typename Callable_T, typename... Args_T>
auto bind_callable (Callable_T &&callable, Args_T &&... arguments)
 Creates the function object that holds the body of a test case or suite.
template<class Lhs_T, class Rhs_T, class Compare_T>
 compare_op (Lhs_T &&, Rhs_T &&, Compare_T) -> compare_op< stored_operand_t< decltype(detail::as_operand(std::declval< Lhs_T >()))>, stored_operand_t< decltype(detail::as_operand(std::declval< Rhs_T >()))>, Compare_T >
 Deduction guide for the relational comparator.
template<class Lhs_T, class Rhs_T, class Epsilon_T>
constexpr bool differ_by_at_most (Lhs_T lhs, Rhs_T rhs, Epsilon_T epsilon)
 Tells whether two numbers differ by at most a tolerance.
reporter & endl (reporter &stream)
 Output stream manipulator for ending a line in test reports.
void escape_control_characters (std::string &name)
 Escapes the control characters of a name.
indentation indent (size_t level)
 Factory function that creates an indentation manipulator.
template<class T, char... Cs>
constexpr auto integral_literal (void)
 Creates the compile-time constant of an integer literal.
template<class T, class R>
requires (container_like<R> and std::three_way_comparable_with< T, typename range_element<R>::type>)
constexpr auto operator<=> (const array_operand< T > &lhs, const R &rhs)
 Orders an array operand and a range lexicographically.
template<character Char_T>
constexpr std::strong_ordering operator<=> (const basic_c_string< Char_T > &lhs, const basic_c_string< Char_T > &rhs) noexcept
 Orders two C string operands.
template<character Char_T>
constexpr std::strong_ordering operator<=> (const basic_c_string< Char_T > &lhs, std::type_identity_t< std::basic_string_view< Char_T > > rhs) noexcept
 Orders a C string operand and a string.
template<class T, class R>
requires (container_like<R> and std::equality_comparable_with< T, typename range_element<R>::type>)
constexpr bool operator== (const array_operand< T > &lhs, const R &rhs)
 Compares an array operand with a range for equality.
template<character Char_T>
constexpr bool operator== (const basic_c_string< Char_T > &lhs, const basic_c_string< Char_T > &rhs) noexcept
 Compares two C string operands for equality.
template<character Char_T>
constexpr bool operator== (const basic_c_string< Char_T > &lhs, std::nullptr_t) noexcept
 Checks whether a C string operand is a null pointer.
template<character Char_T>
constexpr bool operator== (const basic_c_string< Char_T > &lhs, std::type_identity_t< std::basic_string_view< Char_T > > rhs) noexcept
 Compares a C string operand with a string.
template<typename Lhs_T, typename Rhs_T>
 or_op (Lhs_T &&, Rhs_T &&) -> or_op< stored_operand_t< Lhs_T >, stored_operand_t< Rhs_T > >
 Deduction guide for the logical OR comparator.
template<class T, class Predicate_T>
 predicate_op (T &&, Predicate_T) -> predicate_op< stored_operand_t< decltype(detail::as_operand(std::declval< T >()))>, Predicate_T >
 Deduction guide for the unary predicate.
void read_clock (timespec &ts) noexcept
 Reads the system clock.
template<class Tag_T>
constexpr void reject_compare_tag (void) noexcept
 Stops the compilation of a compare_op whose tag is rejected, with a message that tells why.
template<comparison Op, class Lhs_T, class Rhs_T>
constexpr void reject_comparison (void) noexcept
 Stops the compilation of a comparator whose operands are rejected, with a message that tells why.
template<class Tag_T>
constexpr void reject_predicate_tag (void) noexcept
 Stops the compilation of a predicate_op whose tag is rejected, with a message that tells why.
template<typename Callable_T, typename... Args_T>
constexpr void reject_suite_body (void) noexcept
 Stops the compilation with a message that tells what the body of a suite takes.
template<typename Callable_T, typename... Args_T>
constexpr void reject_test_body (void) noexcept
 Stops the compilation with a message that tells what the body of a test case takes.
template<class Self_T, class Values_T, class Callable_T>
void test_each_value (Self_T &self, const located_name &name, Values_T &&values, Callable_T &callable)
 Adds and runs a test case for each value.
template<class T>
decltype(auto) constexpr unwrap (const T &t)
 Returns the value wrapped by a framework type, or the operand itself.
template<class T>
constexpr decltype(auto) unwrap (const T &t)
 Returns the value wrapped by a framework type, or the operand itself.
template<class Lhs_T, class Rhs_T>
requires (extension::has_epsilon<Lhs_T> or extension::has_epsilon<Rhs_T>)
constexpr bool within_tolerance (const Lhs_T &lhs, const Rhs_T &rhs)
 Deprecated check whether two operands are equal within the tolerance of the floating-point wrappers.

Variables

constexpr colours colours_none {}
 Predefined colour set, without escape sequences.
constexpr colours colours_red_green
 Predefined colour set, with green for pass and red for fail.
template<typename... Ts>
constexpr bool dependent_false_v = false
 A value that is always false, but depends on the template arguments.

Detailed Description

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 the deprecated value wrappers (declared in deprecated.h), the value unwrapping helper, comparator structures for logical and relational operations, mechanisms for exception checking, the reporters, the check result, and the expression formatter.

All definitions within detail are intended exclusively for internal use; the applications do not need to name them.

Typedef Documentation

◆ c_string

The type to which as_operand() converts the char arrays, including the string literals, and the char pointers; the framework itself names basic_c_string, and the alias is kept for the tests that name the type of a comparator.

Definition at line 1746 of file detail.h.

◆ comparison_integer_t

Used by sign_mixed_integers, to tell the signedness, and by as_comparison_integer(), to convert the operands.

Template Parameters
TThe type of the operand.

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

◆ comparison_operand_t

template<class T>
using micro_os_plus::micro_test_plus::detail::comparison_operand_t = unwrapped_t<decltype (detail::as_operand (std::declval<T> ()))>

The type of the operand after as_operand() and unwrap(), without references and qualifiers; for example detail::basic_c_string<char> for a string literal.

Template Parameters
TThe type deduced for the operand, possibly a reference.

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

◆ stored_operand_t

Initial value:
std::conditional_t<
std::is_lvalue_reference_v<T>
and not std::is_copy_constructible_v<std::remove_cvref_t<T>>,
const std::remove_reference_t<T>&, std::remove_cvref_t<T>>

Applied by the deduction guides and the factory functions to the type deduced for a forwarding reference: X& (or const X&) for an lvalue, X for an rvalue.

An lvalue is copied into the expression, so that an expression built in a function from its parameters, and returned, does not refer to the destroyed locals of that function. An rvalue is moved into the expression, so that an expression that outlives the statement, like auto op = eq (f (), 1);, does not refer to a destroyed temporary.

The arrays and the character pointers are first converted by as_operand() to basic_c_string or array_operand, which are stored, but which refer to the characters or to the elements of the operand, without copying them; such an expression is valid only as long as the operand.

Only an lvalue of a class type that cannot be copied (for example a std::unique_ptr) is stored as a const reference; such a reference remains valid only as long as the named operand, which is always the case within the statement that checks the expression.

Template Parameters
TThe type deduced for a forwarding reference.

Definition at line 234 of file detail.h.

◆ unwrapped_t

Initial value:
std::remove_cvref_t<decltype (detail::unwrap (
std::declval<const std::remove_cvref_t<T>&> ()))>
decltype(auto) constexpr unwrap(const T &t)
Returns the value wrapped by a framework type, or the operand itself.
Template Parameters
TThe type of the operand, possibly a reference.

Without references and qualifiers; for example int for a to_i wrapper and for a 42_i literal, and the type itself for the other operands. Used by extension::approx_operand and by comparison_operand_t.

Definition at line 828 of file detail.h.

Enumeration Type Documentation

◆ check_kind

An enumeration rather than a Boolean flag, so that the call sites name the kind of the check.

Enumerator
expectation 

A check created by expect().

A failure is reported and counted, and the test case continues.

requirement 

A check created by require().

A failure is reported and counted, and the test case is stopped, or, without exceptions, the test execution is aborted.

Definition at line 93 of file check-result.h.

94 {
102
111 };

◆ comparison

enum class micro_os_plus::micro_test_plus::detail::comparison : unsigned char
strong

A single concept, parametrised by the operator, checks the operands of all the comparators (eq(), ne(), gt(), ge(), lt(), and le()).

Enumerator
equal 

The == operator, checked by eq().

not_equal 

The != operator, checked by ne().

greater 

The > operator, checked by gt().

greater_equal 

The >= operator, checked by ge().

less 

The < operator, checked by lt().

less_equal 

The <= operator, checked by le().

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

417 : unsigned char
418 {
420 equal,
422 not_equal,
424 greater,
428 less,
@ greater_equal
The >= operator, checked by ge().
@ less_equal
The <= operator, checked by le().
@ not_equal
The != operator, checked by ne().

◆ record_kind

The output policy, which decides where each kind of record is written at each verbosity level, is in reporter::route(). The concrete reporters only format the records and ask where they go.

Enumerator
info 

The informational lines written at the beginning of the session.

suite_heading 

The heading that marks the beginning of a suite.

suite_result 

The result line of a suite.

test_case_heading 

The heading that marks the beginning of a test case.

test_case_result 

The result line of a test case.

skipped 

The line of a suite or of a test case skipped by the filter.

passed_check 

The line of a passed check.

failed_check 

The lines of a failed check, or the failure of a suite.

total 

The totals of the session.

abort 

The report of an aborted test execution.

Definition at line 160 of file reporter.h.

161 {
166 info,
167
172
177
182
187
192 skipped,
193
198
203
207 total,
208
212 abort
213 };
@ test_case_result
The result line of a test case.
Definition reporter.h:186
@ test_case_heading
The heading that marks the beginning of a test case.
Definition reporter.h:181
@ abort
The report of an aborted test execution.
Definition reporter.h:212
@ suite_heading
The heading that marks the beginning of a suite.
Definition reporter.h:171
@ info
The informational lines written at the beginning of the session.
Definition reporter.h:166
@ failed_check
The lines of a failed check, or the failure of a suite.
Definition reporter.h:202
@ skipped
The line of a suite or of a test case skipped by the filter.
Definition reporter.h:192

◆ throw_outcome

enum class micro_os_plus::micro_test_plus::detail::throw_outcome : unsigned char
strong

Kept only when the check failed, to be written in the report.

Enumerator
none 

Nothing was thrown, or the expected exception was thrown.

std_exception 

A std::exception that was not the expected one was thrown; its what() is kept.

unknown_exception 

Another exception was thrown.

Definition at line 1335 of file detail.h.

1336 {
1340 none,
1341
1347
1352 };
@ std_exception
A std::exception that was not the expected one was thrown; its what() is kept.
Definition detail.h:1346
@ none
Nothing was thrown, or the expected exception was thrown.
Definition detail.h:1340
@ unknown_exception
Another exception was thrown.
Definition detail.h:1351

Function Documentation

◆ and_op()

template<typename Lhs_T, typename Rhs_T>
micro_os_plus::micro_test_plus::detail::and_op ( Lhs_T && ,
Rhs_T &&  ) -> and_op< stored_operand_t< Lhs_T >, stored_operand_t< Rhs_T > >

Deduces Lhs_T and Rhs_T from the constructor arguments, so that and_op{ lhs, rhs } can be written without explicit template arguments. The operand types are deduced as forwarding references, and stored as stored_operand_t selects.

◆ append_control_escape()

void micro_os_plus::micro_test_plus::detail::append_control_escape ( std::string & text,
char c )

Writes the usual escape of the character (\\0, \\a, \\b, \\t, \\n, \\v, \\f, or \\r), or \\xHH for the other ones. Used for the characters of the messages and of the names that would otherwise reach the console and the output files unchanged. Defined in src/expression-formatter.cpp.

Parameters
textThe text to append to.
cThe control character.

The usual escapes for the characters that have one; the other ones, including DEL, as \\xHH.

Definition at line 401 of file expression-formatter.cpp.

402 {
403 switch (c)
404 {
405 case '\0':
406 text.append ("\\0");
407 break;
408 case '\a':
409 text.append ("\\a");
410 break;
411 case '\b':
412 text.append ("\\b");
413 break;
414 case '\t':
415 text.append ("\\t");
416 break;
417 case '\n':
418 text.append ("\\n");
419 break;
420 case '\v':
421 text.append ("\\v");
422 break;
423 case '\f':
424 text.append ("\\f");
425 break;
426 case '\r':
427 text.append ("\\r");
428 break;
429 default:
430 append_hex (text, static_cast<unsigned char> (c), "\\x", 2);
431 break;
432 }
433 }

References append_control_escape().

Referenced by append_control_escape(), micro_os_plus::micro_test_plus::detail::anonymous_namespace{expression-formatter.cpp}::append_plain(), escape_control_characters(), and micro_os_plus::micro_test_plus::detail::expression_formatter::operator<<().

◆ append_number()

template<class T>
requires std::is_arithmetic_v<T>
void micro_os_plus::micro_test_plus::detail::append_number ( std::string & buffer,
T v )
Template Parameters
TThe numeric type to format.
Parameters
bufferThe string to append to.
vThe value to format.
Returns
Nothing.

The value is formatted into a local buffer, which is then appended to buffer.

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. 32-bit Arm), the value is cast to double and formatted with std::to_chars.
  • On all other platforms (e.g. x86-64 Linux/macOS with 80-bit extended precision, or AArch64 and RISC-V with 128-bit quad precision), snprintf with %.*Lg is used as a portable fallback, because std::to_chars for long double may be unavailable (e.g. when linking with lld). The precision starts at LDBL_DIG and is increased until the text reads back, with strtold, as the same value, up to LDBL_DECIMAL_DIG, which always reads back exactly. This gives the shortest exact form, as std::to_chars gives for the other types; a shorter form would need fewer than LDBL_DIG digits, and Lg removes the trailing zeros, so starting at LDBL_DIG does not lose it. For zero and the subnormal values, which have fewer significant digits, the precision starts at 1. The value of errno, which strtold may set for subnormal values, is preserved. If no precision reads back exactly, the C library handles long double with the precision of double (e.g. newlib on AArch64 and RISC-V), and the value is cast to double and formatted with std::to_chars, as above.

For all other numeric types, std::to_chars is called directly, providing locale-independent formatting. The snprintf() path uses the decimal point of the C locale, which is . unless the application changes it with setlocale().

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

1350 {
1351 if constexpr (std::is_same_v<T, long double>)
1352 {
1353#if defined(_WIN32) \
1354 || (defined(__SIZEOF_LONG_DOUBLE__) \
1355 && __SIZEOF_LONG_DOUBLE__ == __SIZEOF_DOUBLE__)
1356 // On Windows (all toolchains: MinGW, Clang, MSVC), the C runtime
1357 // does not handle the %Lg printf specifier correctly for 80-bit
1358 // long double, producing garbage output. On platforms where long
1359 // double has the same width as double (e.g. 32-bit Arm), the cast
1360 // is lossless. In both cases, cast to double and use
1361 // std::to_chars.
1362 char buf[32];
1363 const auto [ptr, ec] = std::to_chars (buf, buf + sizeof (buf),
1364 static_cast<double> (v));
1365 if (ec == std::errc{})
1366 buffer.append (buf, ptr);
1367#else
1368 // On other platforms (80-bit extended precision on x86-64,
1369 // 128-bit quad precision on AArch64 and RISC-V), std::to_chars
1370 // for long double may be unavailable (e.g., with lld).
1371 // Use snprintf as a portable fallback; %Lg is supported by the C
1372 // libraries used on these platforms (e.g. glibc, the macOS libc,
1373 // and newlib, the latter with the precision of double on AArch64
1374 // and RISC-V). Use the smallest precision that reads back as the
1375 // same value; the buffer fits the 36 digits of the 128-bit
1376 // format, with the sign, the point, and the exponent.
1377 char buf[48];
1378 const int saved_errno = errno;
1379 // The subnormal values have fewer significant digits.
1380 const int min_precision
1381 = (v > -LDBL_MIN && v < LDBL_MIN) ? 1 : LDBL_DIG;
1382 bool is_exact = false;
1383 for (int precision = min_precision; precision <= LDBL_DECIMAL_DIG;
1384 ++precision)
1385 {
1386 // GCC 11 does not know the range of the precision, and
1387 // warns that the text may be truncated; it cannot be, since
1388 // the precision is at most LDBL_DECIMAL_DIG.
1389#if defined(__GNUC__) && !defined(__clang__)
1390#pragma GCC diagnostic push
1391#pragma GCC diagnostic ignored "-Wformat-truncation"
1392#endif // defined(__GNUC__) && !defined(__clang__)
1393 snprintf (buf, sizeof (buf), "%.*Lg", precision, v);
1394#if defined(__GNUC__) && !defined(__clang__)
1395#pragma GCC diagnostic pop
1396#endif // defined(__GNUC__) && !defined(__clang__)
1397 // A NaN is never equal to itself, and has no digits.
1398 if (v != v || strtold (buf, nullptr) == v)
1399 {
1400 is_exact = true;
1401 break;
1402 }
1403 }
1404 errno = saved_errno;
1405 if (is_exact)
1406 {
1407 buffer.append (buf);
1408 }
1409 else
1410 {
1411 // The C library formats or reads long double with the
1412 // precision of double (e.g. newlib on AArch64 and RISC-V),
1413 // and its long text would only show the error of the
1414 // conversion; use the shortest form of the double value,
1415 // as on the platforms above.
1416 const auto [ptr, ec] = std::to_chars (buf, buf + sizeof (buf),
1417 static_cast<double> (v));
1418 if (ec == std::errc{})
1419 buffer.append (buf, ptr);
1420 }
1421#endif // long double formatting
1422 }
1423 else
1424 {
1425 char buf[32];
1426 const auto [ptr, ec] = std::to_chars (buf, buf + sizeof (buf), v);
1427 if (ec == std::errc{})
1428 buffer.append (buf, ptr);
1429 }

References append_number().

Referenced by micro_os_plus::micro_test_plus::detail::expression_formatter::append_first_difference(), append_number(), 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::detail::reporter::operator<<().

◆ append_pointer()

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

Shared by the reporter and the expression_formatter, so that the pointers are displayed identically in the messages and in the expressions. Pointers to const or volatile objects, and function pointers, are accepted too.

Template Parameters
TThe type pointed to (an object or a function type).
Parameters
bufferThe string to append to.
vThe pointer.
Returns
Nothing.

Null pointers are rendered as "0x0", regardless of the platform, avoiding platform-specific representations such as "(nil)" on Linux/glibc. Non-null pointers are formatted with snprintf(), using the p specifier.

The p specifier expects a void*. Object pointers are converted implicitly to const volatile void*, which accepts any qualification, and the qualifiers are then removed with const_cast; a reinterpret_cast to void* would not compile for pointers to const objects. The object is not accessed. Function pointers, which do not convert to void* implicitly, use reinterpret_cast.

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

1456 {
1457 if (v == nullptr)
1458 {
1459 buffer.append ("0x0");
1460 return;
1461 }
1462
1463 void* p;
1464 if constexpr (std::is_function_v<T>)
1465 {
1466 p = reinterpret_cast<void*> (v);
1467 }
1468 else
1469 {
1470 const volatile void* cvp = v;
1471 p = const_cast<void*> (cvp);
1472 }
1473
1474#if defined(__GNUC__)
1475#pragma GCC diagnostic push
1476
1477#if defined(__clang__)
1478#pragma clang diagnostic ignored "-Wunsafe-buffer-usage-in-libc-call"
1479#endif // defined(__clang__)
1480#endif // defined(__GNUC__)
1481
1482 char buf[20];
1483 snprintf (buf, sizeof (buf), "%p", p);
1484 buffer.append (buf);
1485
1486#if defined(__GNUC__)
1487#pragma GCC diagnostic pop
1488#endif // defined(__GNUC__)

References append_pointer().

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

◆ approx_op()

template<class Lhs_T, class Rhs_T, class Epsilon_T>
micro_os_plus::micro_test_plus::detail::approx_op ( Lhs_T && ,
Rhs_T && ,
Epsilon_T &&  ) -> approx_op< stored_operand_t< Lhs_T >, stored_operand_t< Rhs_T >, stored_operand_t< Epsilon_T > >

Deduces Lhs_T, Rhs_T, and Epsilon_T from the constructor arguments, which are stored as stored_operand_t selects.

◆ as_comparison_integer()

template<class T>
comparison_integer_t< T > micro_os_plus::micro_test_plus::detail::as_comparison_integer ( const T value)
nodiscardconstexprnoexcept

The conversion keeps the value, since the type has the same size and signedness. Applied to both operands of the std::cmp_*() functions, which do not accept the character types.

Template Parameters
TThe type of the operand.
Parameters
valueThe operand.
Returns
The value, as comparison_integer_t<T>.

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

344 {
345 return static_cast<comparison_integer_t<T>> (value);
346 }
typename comparison_integer< T >::type comparison_integer_t
Alias of the integer type used to compare the type T.
Struct template representing a generic value, accessible via a getter.
Definition deprecated.h:629

References as_comparison_integer().

Referenced by micro_os_plus::micro_test_plus::detail::equal_to::apply(), micro_os_plus::micro_test_plus::detail::greater::apply(), micro_os_plus::micro_test_plus::detail::greater_equal::apply(), micro_os_plus::micro_test_plus::detail::less::apply(), micro_os_plus::micro_test_plus::detail::less_equal::apply(), micro_os_plus::micro_test_plus::detail::not_equal_to::apply(), and as_comparison_integer().

◆ as_operand()

template<class T>
auto micro_os_plus::micro_test_plus::detail::as_operand ( T && t) -> decltype(auto)
nodiscardconstexprnoexcept

The arrays and the pointers of the character types (char, wchar_t, char8_t, char16_t, and char32_t, but not signed char or unsigned char, which are byte buffers) are converted to basic_c_string, so that they are compared by content; the other arrays, including those of volatile characters, are converted to array_operand, so that they are compared element by element, the functions to function pointers, and all other operands are returned unchanged, so the other pointers, including the pointers to volatile characters, and the functions are compared by address.

The other operands are forwarded, so that the comparator moves a temporary, and refers to a named operand.

Template Parameters
TThe type deduced for the forwarding reference.
Parameters
tThe operand.
Returns
A basic_c_string for the C strings, an array_operand for the other arrays, otherwise t, forwarded.

Arrays of the character types are converted using their size as a bound, pointers to them using the null terminator; the const qualifier of the characters is ignored. The volatile characters are not strings, since basic_c_string cannot refer to them: an array of them is converted to array_operand, like the other arrays, and compared element by element, and a pointer to them is forwarded, and compared by address, like the other pointers. The functions are converted to function pointers. Every other operand is forwarded, unchanged, as an lvalue or an rvalue reference.

The qualifiers of an array are those of its elements, so the element type is taken from the type of the argument, not from the type without qualifiers, which would lose the volatile of the elements, and the conversion to the pointer to const elements would not compile.

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

1727 {
1728 using type = std::remove_cvref_t<T>;
1729 // The cv-qualifiers of an array are those of its elements, which
1730 // std::remove_cvref_t removes; keep volatile for the element type.
1731 using element_type = std::remove_const_t<
1732 std::remove_extent_t<std::remove_reference_t<T>>>;
1733
1734 if constexpr (std::is_array_v<type> && character<element_type>
1735 && not std::is_volatile_v<element_type>)
1736 {
1738 t, std::extent_v<type>
1739 };
1740 }
1741 else if constexpr (character_pointer<type>)
1742 {
1743 return basic_c_string<std::remove_cv_t<std::remove_pointer_t<type>>>{
1744 t
1745 };
1746 }
1747 else if constexpr (std::is_array_v<type>)
1748 {
1749 // Other arrays (e.g. byte buffers) are compared by content.
1751 static_cast<const element_type*> (t), std::extent_v<type>
1752 };
1753 }
1754 else if constexpr (std::is_function_v<type>)
1755 {
1756 // Functions are compared by address, as function pointers.
1757 return &t;
1758 }
1759 else
1760 {
1761 return std::forward<T> (t);
1762 }
Concept satisfied by the character types.
Definition detail.h:1631
An array operand of a comparator, other than a character array.
Definition detail.h:1846
A C string operand of a comparator.
Definition detail.h:1674

References as_operand().

Referenced by micro_os_plus::micro_test_plus::detail::compare_op< Lhs_T, Rhs_T, Compare_T >::compare_op(), micro_os_plus::micro_test_plus::detail::predicate_op< T, Predicate_T >::predicate_op(), as_operand(), compare_op(), micro_os_plus::micro_test_plus::eq(), micro_os_plus::micro_test_plus::ge(), micro_os_plus::micro_test_plus::gt(), micro_os_plus::micro_test_plus::le(), micro_os_plus::micro_test_plus::lt(), and micro_os_plus::micro_test_plus::ne().

◆ bind_callable()

template<typename Self_T, typename Callable_T, typename... Args_T>
auto micro_os_plus::micro_test_plus::detail::bind_callable ( Callable_T && callable,
Args_T &&... arguments )
nodiscard

Without additional arguments, the callable already has the signature void (Self_T&), and a copy of it is returned, without a wrapper.

Otherwise, a bound_callable stores copies of the callable and of the arguments (decayed, as by auto), since a suite may run after the caller's temporaries are gone; the callable receives the copies as non-const lvalues. A reference parameter thus refers to the copy; to refer to the caller's object, pass a pointer, or std::ref(), which converts to a T& parameter (an auto& parameter receives the std::reference_wrapper itself).

The returned object holds a copy of the callable (decayed, as by auto) when there are no additional arguments; otherwise it is a bound_callable that holds copies of the callable and of the arguments, and passes the arguments after the leading reference, which is passed when the body is invoked. No memory is allocated, other than by the copies themselves.

A suite stores the object in a std::function, since it runs later; a test case, which runs immediately, refers to it with a callable_ref.

Template Parameters
Self_TThe type referred to by the first parameter of the callable (test_case or suite).
Callable_TThe type of the callable object.
Args_TThe types of the additional callable arguments.
Parameters
callableA generic callable object, usually a lambda.
argumentsA possibly empty list of arguments forwarded to the callable after the leading Self_T& reference.
Returns
The function object, invocable with a Self_T& argument.

Definition at line 344 of file test-inlines.h.

345 {
346 if constexpr (sizeof...(arguments) == 0)
347 {
348 return std::forward<Callable_T> (callable);
349 }
350 else
351 {
352 return bound_callable<Self_T, std::decay_t<Callable_T>,
353 std::decay_t<Args_T>...>{
354 std::forward<Callable_T> (callable),
355 std::forward<Args_T> (arguments)...
356 };
357 }
358 }

References bind_callable().

Referenced by bind_callable(), and micro_os_plus::micro_test_plus::detail::runnable_base::create_test_case().

◆ compare_op()

template<class Lhs_T, class Rhs_T, class Compare_T>
micro_os_plus::micro_test_plus::detail::compare_op ( Lhs_T && ,
Rhs_T && ,
Compare_T  ) -> compare_op< stored_operand_t< decltype(detail::as_operand(std::declval< Lhs_T >()))>, stored_operand_t< decltype(detail::as_operand(std::declval< Rhs_T >()))>, Compare_T >

Deduces Lhs_T, Rhs_T, and Compare_T from the constructor arguments, so that compare_op{ lhs, rhs, equal_to{} } can be written without explicit template arguments. The operand types are deduced as forwarding references, prepared by as_operand(), and stored as stored_operand_t selects.

References as_operand(), and differ_by_at_most().

◆ differ_by_at_most()

template<class Lhs_T, class Rhs_T, class Epsilon_T>
bool micro_os_plus::micro_test_plus::detail::differ_by_at_most ( Lhs_T lhs,
Rhs_T rhs,
Epsilon_T epsilon )
nodiscardconstexpr

If the three values are integers, the distance is computed exactly, as an unsigned value, also for operands of mixed signedness, and compared with the tolerance with std::cmp_less_equal(), so that neither overflows nor wraps around. Otherwise, the values are converted to their common floating-point type, and the absolute value of the difference is compared with the tolerance. A negative tolerance, or a NaN, makes the result false.

Template Parameters
Lhs_TThe arithmetic type of the first value.
Rhs_TThe arithmetic type of the second value.
Epsilon_TThe arithmetic type of the tolerance.
Parameters
lhsThe first value.
rhsThe second value.
epsilonThe tolerance.
Return values
trueThe distance between the values is less than or equal to the tolerance.
falseOtherwise.

For the integers, the larger value is selected with std::cmp_less(), and the distance is computed in std::uintmax_t: when both values have the same sign, as the modular difference of their conversions, which is exact; otherwise, as the sum of the larger value and of the magnitude of the negative one. A sum that does not fit in std::uintmax_t is flagged as an overflow, and gives false, since the true distance is larger than any tolerance. The tolerance is compared with std::cmp_less_equal(), so a negative one gives false.

For the other types, the values are converted to their common type, which is a floating-point one, so std::int64_t values compared with a float tolerance lose precision; the comparison is inclusive, so a distance equal to the tolerance succeeds. Two equal values, including two infinities of the same sign, whose difference would be NaN, are at the distance zero; a NaN operand always fails.

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

942 {
943 if constexpr (std::is_integral_v<Lhs_T> and std::is_integral_v<Rhs_T>
944 and std::is_integral_v<Epsilon_T>)
945 {
946 bool overflow = false;
947 const auto distance
948 = [&overflow] (auto larger,
949 auto smaller) constexpr -> std::uintmax_t
950 {
951 if constexpr (std::is_signed_v<decltype (smaller)>)
952 {
953 if (smaller < 0 and std::cmp_greater_equal (larger, 0))
954 {
955 // The magnitude of the negative value, without
956 // negating the minimum of its type.
957 const auto magnitude
958 = static_cast<std::uintmax_t> (-(smaller + 1)) + 1u;
959 const auto upper = static_cast<std::uintmax_t> (larger);
960 if (upper > std::numeric_limits<std::uintmax_t>::max ()
961 - magnitude)
962 {
963 overflow = true;
964 return std::numeric_limits<std::uintmax_t>::max ();
965 }
966 return upper + magnitude;
967 }
968 }
969 return static_cast<std::uintmax_t> (larger)
970 - static_cast<std::uintmax_t> (smaller);
971 };
972
973 const std::uintmax_t difference = std::cmp_less (lhs, rhs)
974 ? distance (rhs, lhs)
975 : distance (lhs, rhs);
976 return !overflow && std::cmp_less_equal (difference, epsilon);
977 }
978 else
979 {
980 using float_type = std::common_type_t<Lhs_T, Rhs_T, Epsilon_T>;
981 const auto left = static_cast<float_type> (lhs);
982 const auto right = static_cast<float_type> (rhs);
983
984#if defined(__GNUC__)
985#pragma GCC diagnostic push
986#pragma GCC diagnostic ignored "-Wfloat-equal"
987#endif // defined(__GNUC__)
988 // The exact comparison is deliberate, for the infinities.
989 const float_type distance
990 = (left == right) ? float_type{} : math::abs (left - right);
991#if defined(__GNUC__)
992#pragma GCC diagnostic pop
993#endif // defined(__GNUC__)
994
995 return distance <= static_cast<float_type> (epsilon);
996 }
constexpr auto abs(const T t) noexcept -> T
Computes the absolute value of a given comparable value.

References micro_os_plus::micro_test_plus::detail::math::abs(), and differ_by_at_most().

Referenced by micro_os_plus::micro_test_plus::detail::approx_op< Lhs_T, Rhs_T, Epsilon_T >::approx_op(), compare_op(), and differ_by_at_most().

◆ endl()

reporter & micro_os_plus::micro_test_plus::detail::endl ( reporter & stream)

Calls reporter::end_line(), which appends a line ending to the internal buffer. Unlike std::endl, it does not flush; the buffer is written later, by the concrete reporters.

Parameters
streamReference to the reporter instance.
Returns
Reference to the same reporter instance, enabling chaining of output operations.

The endl function calls reporter::end_line(), which appends a newline character to the buffer of the specified reporter.

Definition at line 218 of file reporter.cpp.

219 {
220 stream.end_line ();
221 return stream;
222 }
void end_line(void)
Appends a line ending to the internal output buffer.
Definition reporter.cpp:232

References micro_os_plus::micro_test_plus::detail::reporter::end_line(), and endl().

Referenced by endl(), micro_os_plus::micro_test_plus::detail::reporter_human::fail_suite(), micro_os_plus::micro_test_plus::detail::reporter_tap::fail_suite(), micro_os_plus::micro_test_plus::detail::reporter_tap::output_fail_prefix(), micro_os_plus::micro_test_plus::detail::reporter_human::output_fail_suffix(), micro_os_plus::micro_test_plus::detail::reporter_tap::output_fail_suffix(), micro_os_plus::micro_test_plus::detail::reporter_human::output_pass_suffix(), micro_os_plus::micro_test_plus::detail::reporter_tap::output_pass_suffix(), and micro_os_plus::micro_test_plus::detail::reporter_tap::pass_without_text().

◆ escape_control_characters()

void micro_os_plus::micro_test_plus::detail::escape_control_characters ( std::string & name)

Replaces, in place, the control characters other than the tab, including the line feed and the NUL, with their escape sequences, so that the names reach the console and the output files as one line of visible text. Defined in src/test.cpp.

Parameters
nameThe name to escape.

The text is scanned first, so that a name without control characters is not touched. The tab is kept; all the other control characters, including the line feed and the NUL, and DEL, are replaced.

Definition at line 80 of file test.cpp.

81 {
82 const auto is_control = [] (char c)
83 {
84 const auto unit = static_cast<unsigned char> (c);
85 return (unit < 0x20 && c != '\t') || unit == 0x7F;
86 };
87
88 std::size_t first = 0;
89 while (first < name.size () && !is_control (name[first]))
90 {
91 ++first;
92 }
93 if (first == name.size ())
94 {
95 return;
96 }
97
98 std::string escaped (name, 0, first);
99 escaped.reserve (name.size () + 8);
100 for (std::size_t i = first; i < name.size (); ++i)
101 {
102 if (is_control (name[i]))
103 {
104 append_control_escape (escaped, name[i]);
105 }
106 else
107 {
108 escaped.push_back (name[i]);
109 }
110 }
111 name = std::move (escaped);
112 }
void append_control_escape(std::string &text, char c)
Appends the escape sequence of a control character.

References append_control_escape(), and escape_control_characters().

Referenced by micro_os_plus::micro_test_plus::located_name::located_name(), micro_os_plus::micro_test_plus::located_name::located_name(), micro_os_plus::micro_test_plus::located_name::located_name(), micro_os_plus::micro_test_plus::located_name::located_name(), and escape_control_characters().

◆ indent()

indentation micro_os_plus::micro_test_plus::detail::indent ( size_t level)
inlinenodiscard

Returns an indentation aggregate initialised with level.

Allows writing reporter << indent(n) instead of constructing the manipulator explicitly.

Parameters
levelThe number of four-space indentation levels.
Returns
An indentation value for use with operator<<.

Definition at line 64 of file reporter-inlines.h.

65 {
66 return { level };
67 }

References indent().

Referenced by micro_os_plus::micro_test_plus::detail::reporter_human::begin_test_case(), micro_os_plus::micro_test_plus::detail::reporter_tap::begin_test_case(), micro_os_plus::micro_test_plus::detail::reporter_human::display_open_heading(), micro_os_plus::micro_test_plus::detail::reporter_tap::display_open_heading(), micro_os_plus::micro_test_plus::detail::reporter_tap::end_suite(), micro_os_plus::micro_test_plus::detail::reporter_human::end_test_case(), micro_os_plus::micro_test_plus::detail::reporter_tap::end_test_case(), micro_os_plus::micro_test_plus::detail::reporter_human::fail_suite(), micro_os_plus::micro_test_plus::detail::reporter_tap::fail_suite(), indent(), micro_os_plus::micro_test_plus::detail::reporter_human::output_fail_prefix(), micro_os_plus::micro_test_plus::detail::reporter_tap::output_fail_prefix(), micro_os_plus::micro_test_plus::detail::reporter_tap::output_fail_suffix(), micro_os_plus::micro_test_plus::detail::reporter_human::output_pass_prefix(), micro_os_plus::micro_test_plus::detail::reporter_tap::output_pass_prefix(), micro_os_plus::micro_test_plus::detail::reporter_tap::pass_without_text(), micro_os_plus::micro_test_plus::detail::reporter_human::skip_test_case(), and micro_os_plus::micro_test_plus::detail::reporter_tap::skip_test_case().

◆ integral_literal()

template<class T, char... Cs>
auto micro_os_plus::micro_test_plus::detail::integral_literal ( void )
nodiscardconstexpr
Template Parameters
TThe integral type of the literal.
CsThe characters of the literal, as received by a literal operator template.

Used by the integer literal operators (_i, _u8, etc.).

Parameters
None.
Returns
An integral_constant with the value of the literal, or, when the value is the absolute value of the minimum of a signed T, an integral_min_magnitude<T>, valid only when negated.

The value is checked by math::integer_magnitude(), which accepts, for the signed types, the absolute value of the minimum; this value does not fit in T, so it is represented by integral_min_magnitude<T>.

Definition at line 581 of file deprecated-inlines.h.

582 {
583 constexpr unsigned long long magnitude
584 = math::integer_magnitude<T, Cs...> ();
585
586 if constexpr (magnitude > static_cast<unsigned long long> (
587 std::numeric_limits<T>::max ()))
588 {
590 }
591 else
592 {
593 return integral_constant<static_cast<T> (magnitude)>{};
594 }
595 }
consteval auto integer_magnitude(void) -> unsigned long long
Computes the value of an integer literal of type T, before any negation.
constexpr integral_constant(void) noexcept
Default constructor.
Struct template representing the absolute value of the minimum of a signed integral type,...
Definition deprecated.h:483

References micro_os_plus::micro_test_plus::detail::integral_constant< N >::integral_constant(), micro_os_plus::micro_test_plus::detail::math::integer_magnitude(), and integral_literal().

Referenced by integral_literal(), micro_os_plus::micro_test_plus::literals::operator""_c(), micro_os_plus::micro_test_plus::literals::operator""_i(), micro_os_plus::micro_test_plus::literals::operator""_i16(), micro_os_plus::micro_test_plus::literals::operator""_i32(), micro_os_plus::micro_test_plus::literals::operator""_i64(), micro_os_plus::micro_test_plus::literals::operator""_i8(), micro_os_plus::micro_test_plus::literals::operator""_l(), micro_os_plus::micro_test_plus::literals::operator""_ll(), micro_os_plus::micro_test_plus::literals::operator""_s(), micro_os_plus::micro_test_plus::literals::operator""_sc(), micro_os_plus::micro_test_plus::literals::operator""_u(), micro_os_plus::micro_test_plus::literals::operator""_u16(), micro_os_plus::micro_test_plus::literals::operator""_u32(), micro_os_plus::micro_test_plus::literals::operator""_u64(), micro_os_plus::micro_test_plus::literals::operator""_u8(), micro_os_plus::micro_test_plus::literals::operator""_uc(), micro_os_plus::micro_test_plus::literals::operator""_ul(), micro_os_plus::micro_test_plus::literals::operator""_ull(), and micro_os_plus::micro_test_plus::literals::operator""_us().

◆ operator<=>() [1/3]

template<class T, class R>
requires (container_like<R> and std::three_way_comparable_with< T, typename range_element<R>::type>)
auto micro_os_plus::micro_test_plus::detail::operator<=> ( const array_operand< T > & lhs,
const R & rhs )
nodiscardconstexpr
Template Parameters
TThe element type of the array operand.
RThe type of the range.
Parameters
lhsThe array operand.
rhsThe range, which may be another array operand.
Returns
The lexicographic order of the elements.

A range that is a prefix of the other is the lesser one.

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

1698 => (const array_operand<T>& lhs, const R& rhs)
1699 {
1700 return std::lexicographical_compare_three_way (lhs.begin (), lhs.end (),
1701 rhs.begin (), rhs.end ());
constexpr const T * begin(void) const noexcept
Returns an iterator to the first element.
constexpr const T * end(void) const noexcept
Returns an iterator past the last element.

References micro_os_plus::micro_test_plus::detail::array_operand< T >::begin(), micro_os_plus::micro_test_plus::detail::array_operand< T >::end(), and operator<=>().

◆ operator<=>() [2/3]

template<character Char_T>
std::strong_ordering micro_os_plus::micro_test_plus::detail::operator<=> ( const basic_c_string< Char_T > & lhs,
const basic_c_string< Char_T > & rhs )
nodiscardconstexprnoexcept
Template Parameters
Char_TThe character type.
Parameters
lhsThe left operand.
rhsThe right operand.
Returns
The lexicographic order of the characters; a null pointer is equal to another null pointer and less than any string.

A null pointer orders before any string.

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

1596 => (const basic_c_string<Char_T>& lhs,
1597 const basic_c_string<Char_T>& rhs) noexcept
1598 {
1599 if (lhs.is_null () || rhs.is_null ())
1600 {
1601 return !lhs.is_null () <=> !rhs.is_null ();
1602 }
1603 return lhs.view () <=> rhs.view ();
constexpr bool is_null(void) const noexcept
Returns whether the operand is a null pointer.
constexpr std::basic_string_view< Char_T > view(void) const noexcept
Returns the characters, as a string view.

Referenced by operator<=>().

◆ operator<=>() [3/3]

template<character Char_T>
std::strong_ordering micro_os_plus::micro_test_plus::detail::operator<=> ( const basic_c_string< Char_T > & lhs,
std::type_identity_t< std::basic_string_view< Char_T > > rhs )
nodiscardconstexprnoexcept
Template Parameters
Char_TThe character type.
Parameters
lhsThe C string operand.
rhsThe string.
Returns
The lexicographic order of the characters; a null pointer is less than any string.

A null pointer orders before any string.

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

1612 => (
1613 const basic_c_string<Char_T>& lhs,
1614 std::type_identity_t<std::basic_string_view<Char_T>> rhs) noexcept
1615 {
1616 if (lhs.is_null ())
1617 {
1618 return std::strong_ordering::less;
1619 }
1620 return lhs.view () <=> rhs;

◆ operator==() [1/4]

template<class T, class R>
requires (container_like<R> and std::equality_comparable_with< T, typename range_element<R>::type>)
bool micro_os_plus::micro_test_plus::detail::operator== ( const array_operand< T > & lhs,
const R & rhs )
nodiscardconstexpr
Template Parameters
TThe element type of the array operand.
RThe type of the range.
Parameters
lhsThe array operand.
rhsThe range, which may be another array operand.
Return values
trueThe ranges have the same size and equal elements.
falseOtherwise.

Ranges of different sizes are not equal, without comparing any element. The elements are compared as the scalar operands of eq() are, with equal_to::apply(), so that integers of different signedness are compared by value, not by converting the signed one to the unsigned type.

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

1683 {
1684 return std::equal (lhs.begin (), lhs.end (), rhs.begin (), rhs.end (),
1685 [] (const auto& l, const auto& r)
1686 { return equal_to::apply (l, r); });

References micro_os_plus::micro_test_plus::detail::array_operand< T >::begin(), and micro_os_plus::micro_test_plus::detail::array_operand< T >::end().

◆ operator==() [2/4]

template<character Char_T>
bool micro_os_plus::micro_test_plus::detail::operator== ( const basic_c_string< Char_T > & lhs,
const basic_c_string< Char_T > & rhs )
nodiscardconstexprnoexcept
Template Parameters
Char_TThe character type.
Parameters
lhsThe left operand.
rhsThe right operand.
Return values
trueBoth are null, or both are strings with the same characters.
falseOtherwise.

Two null pointers are equal; a null pointer is not equal to any string, not even an empty one.

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

1558 {
1559 if (lhs.is_null () || rhs.is_null ())
1560 {
1561 return lhs.is_null () && rhs.is_null ();
1562 }
1563 return lhs.view () == rhs.view ();

◆ operator==() [3/4]

template<character Char_T>
bool micro_os_plus::micro_test_plus::detail::operator== ( const basic_c_string< Char_T > & lhs,
std::nullptr_t  )
nodiscardconstexprnoexcept
Template Parameters
Char_TThe character type.
Parameters
lhsThe C string operand.
Return values
trueThe operand is a null pointer.
falseOtherwise.

Returns whether the operand is a null pointer.

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

1586 {
1587 return lhs.is_null ();

◆ operator==() [4/4]

template<character Char_T>
bool micro_os_plus::micro_test_plus::detail::operator== ( const basic_c_string< Char_T > & lhs,
std::type_identity_t< std::basic_string_view< Char_T > > rhs )
nodiscardconstexprnoexcept

Also used for the standard strings of the same character type, which convert to the string view, and, as a rewritten candidate, with the operands in the reverse order.

Template Parameters
Char_TThe character type.
Parameters
lhsThe C string operand.
rhsThe string.
Return values
trueThe operand is not null and has the same characters.
falseOtherwise.

A null pointer is not equal to any string.

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

1575 {
1576 return !lhs.is_null () && lhs.view () == rhs;

◆ or_op()

template<typename Lhs_T, typename Rhs_T>
micro_os_plus::micro_test_plus::detail::or_op ( Lhs_T && ,
Rhs_T &&  ) -> or_op< stored_operand_t< Lhs_T >, stored_operand_t< Rhs_T > >

Deduces Lhs_T and Rhs_T from the constructor arguments, so that or_op{ lhs, rhs } can be written without explicit template arguments. The operand types are deduced as forwarding references, and stored as stored_operand_t selects.

◆ predicate_op()

template<class T, class Predicate_T>
micro_os_plus::micro_test_plus::detail::predicate_op ( T && ,
Predicate_T  ) -> predicate_op< stored_operand_t< decltype(detail::as_operand(std::declval< T >()))>, Predicate_T >

Deduces T and Predicate_T from the constructor arguments, so that predicate_op{ t, even{} } can be written without explicit template arguments. The operand type is deduced as a forwarding reference, prepared by as_operand(), and stored as stored_operand_t selects.

◆ read_clock()

void micro_os_plus::micro_test_plus::detail::read_clock ( timespec & ts)
noexcept

Isolates the platform-specific access to the system clock, used by stopwatch and by the deprecated timestamp class. The clock is monotonic on POSIX; without a clock, ts is left unchanged, so the callers clear it first when a zero value must mean that the clock was not read.

Parameters
[out]tsThe timespec where the reading is stored.
Returns
Nothing.

On Windows, the current time is captured via timespec_get() with TIME_UTC. On POSIX platforms with CLOCK_MONOTONIC defined, clock_gettime(CLOCK_MONOTONIC) is used to obtain a monotonic reading. On platforms where neither macro is defined, ts is left unchanged.

Definition at line 66 of file stopwatch.cpp.

67 {
68#if defined(_WIN32)
69 timespec_get (&ts, TIME_UTC);
70#elif defined(CLOCK_MONOTONIC)
71 clock_gettime (CLOCK_MONOTONIC, &ts);
72#else
73 (void)ts;
74#endif // defined(_WIN32) || defined(CLOCK_MONOTONIC)
75 }

References read_clock().

Referenced by micro_os_plus::micro_test_plus::detail::timestamp::timestamp(), read_clock(), micro_os_plus::micro_test_plus::detail::stopwatch::start(), micro_os_plus::micro_test_plus::detail::stopwatch::stop(), micro_os_plus::micro_test_plus::detail::stopwatch::timestamp_begin(), and micro_os_plus::micro_test_plus::detail::stopwatch::timestamp_end().

◆ reject_compare_tag()

template<class Tag_T>
void micro_os_plus::micro_test_plus::detail::reject_compare_tag ( void )
constexprnoexcept

Always fails the static assertion that applies, since it is called only when extension::compare_tag is not satisfied: the missing or unprintable symbol is reported first, then the apply() that cannot be called with the operands, or whose result is not convertible to bool.

Template Parameters
Tag_TThe tag of the comparator.
Parameters
None.
Returns
Nothing.

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

780 {
781 if constexpr (not tag_has_symbol<Tag_T>)
782 {
783 static_assert (not std::is_same_v<Tag_T, Tag_T>,
784 "the tag of a comparator needs a static member "
785 "symbol that can be written, such as a const "
786 "char*");
787 }
788 else
789 {
790 static_assert (not std::is_same_v<Tag_T, Tag_T>,
791 "the tag of a comparator needs a static member "
792 "function apply (lhs, rhs) that can be called with "
793 "the operands and returns a value convertible to "
794 "bool");
795 }
Concept satisfied when the tag of a comparator or of a predicate has a symbol that can be written.

References reject_compare_tag().

Referenced by reject_compare_tag().

◆ reject_comparison()

template<comparison Op, class Lhs_T, class Rhs_T>
void micro_os_plus::micro_test_plus::detail::reject_comparison ( void )
constexprnoexcept

Always fails the static assertion that applies, since it is called only when comparable_operands is not satisfied: an operand that cannot be written is reported first, then the operator that the operands do not support. Called by the overloads of the comparators that accept the rejected operands, so that the compiler shows this message instead of a list of the unsatisfied constraints.

Template Parameters
OpThe comparison of the comparator.
Lhs_TThe type of the left operand.
Rhs_TThe type of the right operand.
Parameters
None.
Returns
Nothing.

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

559 {
560 if constexpr (not extension::printable<Lhs_T>
562 {
563 static_assert (not std::is_same_v<Lhs_T, Lhs_T>,
564 "an operand of the comparator cannot be written in "
565 "the report; define an operator<< (mt::"
566 "expression_formatter&, const T&) in the namespace "
567 "of its type");
568 }
569 else if constexpr (Op == comparison::equal)
570 {
571 static_assert (not std::is_same_v<Lhs_T, Lhs_T>,
572 "the operands of eq () cannot be compared with ==");
573 }
574 else if constexpr (Op == comparison::not_equal)
575 {
576 static_assert (not std::is_same_v<Lhs_T, Lhs_T>,
577 "the operands of ne () cannot be compared with !=");
578 }
579 else if constexpr (Op == comparison::greater)
580 {
581 static_assert (not std::is_same_v<Lhs_T, Lhs_T>,
582 "the operands of gt () cannot be compared with >");
583 }
584 else if constexpr (Op == comparison::greater_equal)
585 {
586 static_assert (not std::is_same_v<Lhs_T, Lhs_T>,
587 "the operands of ge () cannot be compared with >=");
588 }
589 else if constexpr (Op == comparison::less)
590 {
591 static_assert (not std::is_same_v<Lhs_T, Lhs_T>,
592 "the operands of lt () cannot be compared with <");
593 }
594 else
595 {
596 static_assert (not std::is_same_v<Lhs_T, Lhs_T>,
597 "the operands of le () cannot be compared with <=");
598 }
Concept satisfied when a type can be appended to the message of a check result via operator<<.
Definition extension.h:433

References equal, greater, greater_equal, less, not_equal, and reject_comparison().

Referenced by reject_comparison().

◆ reject_predicate_tag()

template<class Tag_T>
void micro_os_plus::micro_test_plus::detail::reject_predicate_tag ( void )
constexprnoexcept

As reject_compare_tag(), for the tag of a predicate, whose apply() takes one operand; called only when extension::predicate_tag is not satisfied.

Template Parameters
Tag_TThe tag of the predicate.
Parameters
None.
Returns
Nothing.

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

817 {
818 if constexpr (not tag_has_symbol<Tag_T>)
819 {
820 static_assert (not std::is_same_v<Tag_T, Tag_T>,
821 "the tag of a predicate needs a static member "
822 "symbol that can be written, such as a const "
823 "char*");
824 }
825 else
826 {
827 static_assert (not std::is_same_v<Tag_T, Tag_T>,
828 "the tag of a predicate needs a static member "
829 "function apply (operand) that can be called with "
830 "the operand and returns a value convertible to "
831 "bool");
832 }

References reject_predicate_tag().

Referenced by reject_predicate_tag().

◆ reject_suite_body()

template<typename Callable_T, typename... Args_T>
void micro_os_plus::micro_test_plus::detail::reject_suite_body ( void )
constexprnoexcept

Always fails the static assertion that applies, since it is called only when suite_body is not satisfied. A body that cannot be copied, or a body written for a test case, is recognised, to say so.

Called by the overloads of runner::add_suite() and of the static_suite constructor that are selected when the callable is not a valid body, as reject_test_body() is for the test cases.

Template Parameters
Callable_TThe type of the callable.
Args_TThe types of the additional arguments.
Parameters
None.
Returns
Nothing.

Definition at line 448 of file test-inlines.h.

449 {
450 if constexpr (not std::is_copy_constructible_v<std::decay_t<Callable_T>>
451 or not(std::is_copy_constructible_v<std::decay_t<Args_T>>
452 and ...))
453 {
454 static_assert (dependent_false_v<Callable_T, Args_T...>,
455 "the body of a suite and its additional arguments "
456 "must be copyable, since the suite runs later");
457 }
458 else if constexpr (std::is_invocable_v<std::decay_t<Callable_T>&,
459 test_case&,
460 std::decay_t<Args_T>&...>)
461 {
462 static_assert (dependent_false_v<Callable_T, Args_T...>,
463 "the body of a suite takes a suite& as its first "
464 "parameter, not a test_case&");
465 }
466 else
467 {
468 static_assert (dependent_false_v<Callable_T, Args_T...>,
469 "the body of a suite takes a suite& as its first "
470 "parameter, followed by the additional arguments");
471 }
472 }
A named, runnable test case that lives inside a suite.
Definition test.h:1362
constexpr bool dependent_false_v
A value that is always false, but depends on the template arguments.
Definition test.h:1258

References dependent_false_v, and reject_suite_body().

Referenced by micro_os_plus::micro_test_plus::runner::add_suite(), and reject_suite_body().

◆ reject_test_body()

template<typename Callable_T, typename... Args_T>
void micro_os_plus::micro_test_plus::detail::reject_test_body ( void )
constexprnoexcept

Always fails the static assertion that applies, since it is called only when test_body is not satisfied. A body written for a suite is recognised, to say so.

Called by the overloads of test_case::test() and suite::test() that are selected when the callable is not a valid body, so that the diagnostic names the mistake in the terms of the application, instead of the concepts and the instantiation stack. Never called at run time.

Template Parameters
Callable_TThe type of the callable.
Args_TThe types of the additional arguments.
Parameters
None.
Returns
Nothing.

Definition at line 422 of file test-inlines.h.

423 {
424 if constexpr (std::is_invocable_v<std::decay_t<Callable_T>&, suite&,
425 std::decay_t<Args_T>&...>)
426 {
427 static_assert (dependent_false_v<Callable_T, Args_T...>,
428 "the body of a test case takes a test_case& as its "
429 "first parameter, not a suite&");
430 }
431 else
432 {
433 static_assert (dependent_false_v<Callable_T, Args_T...>,
434 "the body of a test case takes a test_case& as its "
435 "first parameter, followed by the additional "
436 "arguments passed to test ()");
437 }
438 }
A named, runnable test suite registered with the test runner.
Definition test.h:2059

References dependent_false_v, and reject_test_body().

Referenced by reject_test_body().

◆ test_each_value()

template<class Self_T, class Values_T, class Callable_T>
void micro_os_plus::micro_test_plus::detail::test_each_value ( Self_T & self,
const located_name & name,
Values_T && values,
Callable_T & callable )

For each value, the name is built in a local string, which lives while the test case runs, since a test case runs within the call to test(), and the test case is added with test(), with the location of the call to test_each(). The callable receives each value as a const lvalue, referring to the element itself; neither the values nor the callable are copied. The values of a range are iterated by a range-based for statement, and those of a tuple are expanded by std::apply(), in order.

The common implementation of test_case::test_each() and suite::test_each().

Template Parameters
Self_TThe type of the test case or suite.
Values_TThe type of the range or tuple of values.
Callable_TThe type of the callable object.
Parameters
selfThe test case or suite to which the test cases are added.
nameThe common name of the test cases.
valuesThe range or tuple of values.
callableThe callable object, invoked with the test case and each value.
Returns
Nothing.

Definition at line 1029 of file test-inlines.h.

1031 {
1032 std::size_t position = 0;
1033
1034 const auto run_one
1035 = [&self, &name, &callable, &position] (const auto& value)
1036 {
1037 ++position;
1038
1039 std::string text{ name.name () };
1040 text += " (";
1041 if constexpr (extension::printable<
1042 std::remove_cvref_t<decltype (value)>>)
1043 {
1044 plain_text::append (text, value);
1045 }
1046 else
1047 {
1048 text += '#';
1049 plain_text::append (text, position);
1050 }
1051 text += ')';
1052
1053 // The test case runs within this call, so the value and the
1054 // callable are captured by reference, not copied.
1055 self.test (located_name{ std::move (text), name.location () },
1056 [&callable, &value] (auto& test_self)
1057 {
1058 if constexpr (std::is_member_pointer_v<
1059 std::remove_cvref_t<Callable_T>>)
1060 {
1061 std::invoke (callable, test_self, value);
1062 }
1063 else
1064 {
1065 callable (test_self, value);
1066 }
1067 });
1068 };
1069
1070 if constexpr (test_values_range<Values_T>)
1071 {
1072 for (const auto& value : values)
1073 {
1074 run_one (value);
1075 }
1076 }
1077 else
1078 {
1079 std::apply ([&run_one] (const auto&... elements)
1080 { (run_one (elements), ...); }, values);
1081 }
1082 }
Concept satisfied when T is a range of values for test_each().
Definition test.h:1139
static void append(std::string &text, const T &value)
Appends a value to a text, in the plain mode of the formatter.

References micro_os_plus::micro_test_plus::detail::plain_text::append(), micro_os_plus::micro_test_plus::located_name::location(), micro_os_plus::micro_test_plus::located_name::name(), and test_each_value().

Referenced by micro_os_plus::micro_test_plus::suite::test_each(), micro_os_plus::micro_test_plus::suite::test_each(), micro_os_plus::micro_test_plus::test_case::test_each(), micro_os_plus::micro_test_plus::test_case::test_each(), and test_each_value().

◆ unwrap() [1/2]

template<class T>
decltype(auto) constexpr micro_os_plus::micro_test_plus::detail::unwrap ( const T & t)
nodiscardconstexpr

Always call it qualified, as detail::unwrap(), so that argument-dependent lookup cannot select a function of the application, defined in the namespace of an operand.

The operand is returned by reference, without a copy; the result is valid only as long as the operand.

Template Parameters
TThe type of the operand.
Parameters
tThe operand.
Returns
The value returned by t.get() for the framework wrappers (the literals and the to_* wrappers), otherwise a reference to t.

If the type T is a framework expression type (see extension::is_op) that provides a get() member function, it is invoked and its result returned. Otherwise a reference to the argument itself is returned, so that the types of the application, even those with a get() member function, are compared with their own operators, without a copy. The selection is performed at compile time via if constexpr with an inline requires expression; the return type is deduced with decltype (auto) from the selected branch.

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

99 {
100#if defined(MICRO_OS_PLUS_MICRO_TEST_PLUS_DEPRECATED_ENABLED)
101 if constexpr (extension::is_op<T> && requires { t.get (); })
102 return t.get ();
103 else
104#endif // defined(MICRO_OS_PLUS_MICRO_TEST_PLUS_DEPRECATED_ENABLED)
105 return t;
106 }
Concept satisfied when a type is a framework expression type.
Definition extension.h:320

References unwrap().

Referenced by micro_os_plus::micro_test_plus::detail::approx_op< Lhs_T, Rhs_T, Epsilon_T >::approx_op(), micro_os_plus::micro_test_plus::detail::compare_op< Lhs_T, Rhs_T, Compare_T >::compare_op(), micro_os_plus::micro_test_plus::detail::predicate_op< T, Predicate_T >::predicate_op(), micro_os_plus::micro_test_plus::detail::approx_op< Lhs_T, Rhs_T, Epsilon_T >::epsilon(), 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<<(), micro_os_plus::micro_test_plus::detail::binary_op< Lhs_T, Rhs_T >::rhs(), unwrap(), and within_tolerance().

◆ unwrap() [2/2]

template<class T>
decltype(auto) micro_os_plus::micro_test_plus::detail::unwrap ( const T & t)
nodiscardconstexpr

If the type T is a framework expression type (see extension::is_op) that provides a get() member function, it is invoked and its result returned. Otherwise a reference to the argument itself is returned, so that the types of the application, even those with a get() member function, are compared with their own operators, without a copy. The selection is performed at compile time via if constexpr with an inline requires expression; the return type is deduced with decltype (auto) from the selected branch.

Always call it qualified, as detail::unwrap(), so that argument-dependent lookup cannot select a function of the application, defined in the namespace of an operand.

The operand is returned by reference, without a copy; the result is valid only as long as the operand.

Template Parameters
TThe type of the operand.
Parameters
tThe operand.
Returns
The value returned by t.get() for the framework wrappers (the literals and the to_* wrappers), otherwise a reference to t.

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

99 {
100#if defined(MICRO_OS_PLUS_MICRO_TEST_PLUS_DEPRECATED_ENABLED)
101 if constexpr (extension::is_op<T> && requires { t.get (); })
102 return t.get ();
103 else
104#endif // defined(MICRO_OS_PLUS_MICRO_TEST_PLUS_DEPRECATED_ENABLED)
105 return t;
106 }

References unwrap().

Referenced by micro_os_plus::micro_test_plus::detail::approx_op< Lhs_T, Rhs_T, Epsilon_T >::approx_op(), micro_os_plus::micro_test_plus::detail::compare_op< Lhs_T, Rhs_T, Compare_T >::compare_op(), micro_os_plus::micro_test_plus::detail::predicate_op< T, Predicate_T >::predicate_op(), micro_os_plus::micro_test_plus::detail::approx_op< Lhs_T, Rhs_T, Epsilon_T >::epsilon(), 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<<(), micro_os_plus::micro_test_plus::detail::binary_op< Lhs_T, Rhs_T >::rhs(), unwrap(), and within_tolerance().

Variable Documentation

◆ colours_none

colours micro_os_plus::micro_test_plus::detail::colours_none {}
inlineconstexpr

Used by the formatters that write the messages of the checks, which are never coloured; all members are empty strings.

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

Referenced by micro_os_plus::micro_test_plus::detail::expression_formatter::expression_formatter(), and micro_os_plus::micro_test_plus::detail::expression_formatter::expression_formatter().

◆ colours_red_green

colours micro_os_plus::micro_test_plus::detail::colours_red_green
inlineconstexpr
Initial value:
= {
"\033[0m",
"\033[32m",
"\033[31m"
}

Assigned by reporters that output to a colour-capable terminal; the members are, in order, the reset, pass, and fail ANSI escape sequences.

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

Referenced by micro_os_plus::micro_test_plus::detail::reporter_human::reporter_human().

◆ dependent_false_v

template<typename... Ts>
bool micro_os_plus::micro_test_plus::detail::dependent_false_v = false
inlineconstexpr

Used as the condition of the static_assert of the functions that reject an argument, so that they fail only when instantiated, and their diagnostic has the message, not the concepts that were not satisfied.

Template Parameters
TsThe template arguments to depend on.

Definition at line 1258 of file test.h.

Referenced by reject_suite_body(), and reject_test_body().