37#ifndef MICRO_OS_PLUS_MICRO_TEST_PLUS_DETAIL_H_
38#define MICRO_OS_PLUS_MICRO_TEST_PLUS_DETAIL_H_
42#if defined(__cplusplus)
46#if __has_include("micro-os-plus/project-config.h")
47#include "micro-os-plus/project-config.h"
50#if __has_include("micro-os-plus/micro-test-plus-defines.h")
51#include "micro-os-plus/micro-test-plus-defines.h"
93#if defined(_WIN32) && defined(__clang__) && !defined(__MINGW32__)
94#define MICRO_OS_PLUS_MICRO_TEST_PLUS_PRI_SIZE "Iu"
95#elif defined(_WIN32) && defined(__GNUC__) && !defined(__clang__)
97#define MICRO_OS_PLUS_MICRO_TEST_PLUS_PRI_SIZE "llu"
99#define MICRO_OS_PLUS_MICRO_TEST_PLUS_PRI_SIZE "u"
102#define MICRO_OS_PLUS_MICRO_TEST_PLUS_PRI_SIZE "zu"
108#pragma GCC diagnostic push
110#pragma GCC diagnostic ignored "-Wpadded"
111#pragma GCC diagnostic ignored "-Waggregate-return"
112#if defined(__clang__)
113#pragma clang diagnostic ignored "-Wc++98-compat"
114#pragma clang diagnostic ignored "-Wdocumentation"
167 [[nodiscard]]
decltype (
auto)
constexpr unwrap (
const T& t);
169#if defined(MICRO_OS_PLUS_MICRO_TEST_PLUS_DEPRECATED_ENABLED)
196 template <
class Lhs_T,
class Rhs_T>
197 requires (extension::has_epsilon<Lhs_T> or extension::has_epsilon<Rhs_T>)
198 [[nodiscard]]
constexpr bool
235 std::is_lvalue_reference_v<T>
236 and not std::is_copy_constructible_v<std::remove_cvref_t<T>>,
237 const std::remove_reference_t<T>&, std::remove_cvref_t<T>>;
282 [[nodiscard]]
constexpr
283 operator bool ()
const;
296 [[nodiscard]]
constexpr decltype (
auto)
341 template <
class Lhs_T,
class Rhs_T>
359 template <
class L,
class R>
369 [[nodiscard]]
constexpr
370 operator bool ()
const;
383 [[nodiscard]]
constexpr decltype (
auto)
397 [[nodiscard]]
constexpr decltype (
auto)
451 static constexpr const char*
symbol =
" == ";
453#if defined(MICRO_OS_PLUS_MICRO_TEST_PLUS_DEPRECATED_ENABLED)
485 template <
class Lhs_T,
class Rhs_T>
486 [[nodiscard, gnu::always_inline]]
static constexpr bool
487 apply (
const Lhs_T& lhs,
const Rhs_T& rhs);
510 static constexpr const char*
symbol =
" != ";
512#if defined(MICRO_OS_PLUS_MICRO_TEST_PLUS_DEPRECATED_ENABLED)
544 template <
class Lhs_T,
class Rhs_T>
545 [[nodiscard, gnu::always_inline]]
static constexpr bool
546 apply (
const Lhs_T& lhs,
const Rhs_T& rhs);
569 static constexpr const char*
symbol =
" > ";
571#if defined(MICRO_OS_PLUS_MICRO_TEST_PLUS_DEPRECATED_ENABLED)
603 template <
class Lhs_T,
class Rhs_T>
604 [[nodiscard, gnu::always_inline]]
static constexpr bool
605 apply (
const Lhs_T& lhs,
const Rhs_T& rhs);
628 static constexpr const char*
symbol =
" >= ";
630#if defined(MICRO_OS_PLUS_MICRO_TEST_PLUS_DEPRECATED_ENABLED)
662 template <
class Lhs_T,
class Rhs_T>
663 [[nodiscard, gnu::always_inline]]
static constexpr bool
664 apply (
const Lhs_T& lhs,
const Rhs_T& rhs);
687 static constexpr const char*
symbol =
" < ";
689#if defined(MICRO_OS_PLUS_MICRO_TEST_PLUS_DEPRECATED_ENABLED)
721 template <
class Lhs_T,
class Rhs_T>
722 [[nodiscard, gnu::always_inline]]
static constexpr bool
723 apply (
const Lhs_T& lhs,
const Rhs_T& rhs);
746 static constexpr const char*
symbol =
" <= ";
748#if defined(MICRO_OS_PLUS_MICRO_TEST_PLUS_DEPRECATED_ENABLED)
780 template <
class Lhs_T,
class Rhs_T>
781 [[nodiscard, gnu::always_inline]]
static constexpr bool
782 apply (
const Lhs_T& lhs,
const Rhs_T& rhs);
812 [[nodiscard]]
constexpr auto
813 as_operand (T&& t)
noexcept ->
decltype (
auto);
829 std::declval<
const std::remove_cvref_t<T>&> ()))>;
885 template <
class Lhs_T,
class Rhs_T,
class Compare_T>
902 template <
class L,
class R>
907#if !defined(__DOXYGEN__)
923 template <
class L,
class R>
940 template <
class Lhs_T,
class Rhs_T,
class Compare_T>
943 std::declval<Lhs_T> ()))>,
945 std::declval<Rhs_T> ()))>,
973 template <
class Lhs_T,
class Rhs_T,
class Epsilon_T>
974 [[nodiscard]]
constexpr bool
1001 template <
class Lhs_T,
class Rhs_T,
class Epsilon_T>
1019 template <
class L,
class R,
class E>
1033 [[nodiscard]]
constexpr decltype (
auto)
1054 template <
class Lhs_T,
class Rhs_T,
class Epsilon_T>
1081 template <
class Lhs_T,
class Rhs_T>
1097 template <
class L,
class R>
1110 template <
typename Lhs_T,
typename Rhs_T>
1136 template <
class Lhs_T,
class Rhs_T>
1152 template <
class L,
class R>
1165 template <
typename Lhs_T,
typename Rhs_T>
1209 requires (not std::is_same_v<std::remove_cvref_t<U>,
not_op<T>>)
1210 explicit constexpr not_op (U&& t);
1251 template <
class T,
class Predicate_T>
1270#if !defined(__DOXYGEN__)
1300 template <
class T,
class Predicate_T>
1327#if defined(__cpp_exceptions)
1419 [[nodiscard]]
constexpr
1420 operator bool ()
const;
1432 outcome (
void)
const noexcept;
1442 [[nodiscard]]
const std::string&
1443 what (
void)
const noexcept;
1496 template <
class Exception_T =
void>
1508 template <
class Callable_T>
1509 requires std::invocable<Callable_T&>
1540 template <
class Callable_T>
1541 requires std::invocable<Callable_T&>
1573 template <
class Callable_T>
1574 requires std::invocable<Callable_T&>
1593 requires std::is_arithmetic_v<T>
1631 concept character = std::is_same_v<std::remove_cv_t<T>,
char>
1632 or std::is_same_v<std::remove_cv_t<T>,
wchar_t>
1633 or std::is_same_v<std::remove_cv_t<T>,
char8_t>
1634 or std::is_same_v<std::remove_cv_t<T>,
char16_t>
1635 or std::is_same_v<std::remove_cv_t<T>,
char32_t>;
1652 and not std::is_volatile_v<std::remove_pointer_t<T>>;
1672 template <
character Char_T>
1695 std::size_t capacity)
noexcept;
1705 [[nodiscard]]
constexpr std::basic_string_view<Char_T>
1716 [[nodiscard]]
constexpr bool
1758 template <
character Char_T>
1759 [[nodiscard]]
constexpr bool
1777 template <
character Char_T>
1778 [[nodiscard]]
constexpr bool
1781 std::type_identity_t<std::basic_string_view<Char_T>> rhs)
noexcept;
1791 template <
character Char_T>
1792 [[nodiscard]]
constexpr bool
1804 template <
character Char_T>
1805 [[nodiscard]]
constexpr std::strong_ordering
1818 template <
character Char_T>
1819 [[nodiscard]]
constexpr std::strong_ordering
1822 std::type_identity_t<std::basic_string_view<Char_T>> rhs)
noexcept;
1854 constexpr array_operand (
const T* first, std::size_t count)
noexcept;
1863 [[nodiscard]]
constexpr const T*
1864 begin (
void)
const noexcept;
1873 [[nodiscard]]
constexpr const T*
1874 end (
void)
const noexcept;
1905 template <
class T,
class R>
1907 and std::equality_comparable_with<
1909 [[nodiscard]]
constexpr bool
1922 template <
class T,
class R>
1924 and std::three_way_comparable_with<
1926 [[nodiscard]]
constexpr auto
1968 = std::is_arithmetic_v<detail::unwrapped_t<T>>
1969 and not std::is_same_v<detail::unwrapped_t<T>,
bool>
1970 and not std::is_same_v<detail::unwrapped_t<T>,
char>
1971 and not std::is_same_v<detail::unwrapped_t<T>,
wchar_t>
1972 and not std::is_same_v<detail::unwrapped_t<T>,
char8_t>
1973 and not std::is_same_v<detail::unwrapped_t<T>,
char16_t>
1974 and not std::is_same_v<detail::unwrapped_t<T>,
char32_t>;
1982#if defined(__GNUC__)
1983#pragma GCC diagnostic pop
Concept satisfied by the pointers to the character types.
Concept satisfied by the character types.
Concept satisfied when T provides both begin() and end() member functions returning an iterator and i...
Concept satisfied when T is a valid operand of the approximate comparator.
Concept satisfied by a tag that defines a custom comparator.
Concept satisfied by a tag that defines a custom predicate.
C++ header file with inline implementations for the µTest++ internal detail namespace.
C++ header file with declarations for the µTest++ extension concepts.
static constexpr bool within_tolerance_result
Deprecated result when the operands are within the tolerance.
static constexpr bool within_tolerance_result
Deprecated result when the operands are within the tolerance.
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.
static constexpr bool within_tolerance_result
Deprecated result when the operands are within the tolerance.
static constexpr bool within_tolerance_result
Deprecated result when the operands are within the tolerance.
static constexpr bool within_tolerance_result
Deprecated result when the operands are within the tolerance.
static constexpr bool within_tolerance_result
Deprecated result when the operands are within the tolerance.
C++ header file with declarations for the µTest++ mathematical utilities.
std::remove_cvref_t< decltype(detail::unwrap( std::declval< const std::remove_cvref_t< T > & >()))> unwrapped_t
The type of an operand, after the framework wrappers are removed by detail::unwrap().
void append_number(std::string &buffer, T v)
Appends the shortest decimal representation of a numeric value to a buffer.
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.
constexpr auto as_operand(T &&t) noexcept -> decltype(auto)
Prepares an operand of a comparator.
decltype(auto) constexpr unwrap(const T &t)
Returns the value wrapped by a framework type, or the operand itself.
void append_pointer(std::string &buffer, T *v)
Appends the hexadecimal address of a pointer to a buffer.
throw_outcome
The kind of exception thrown by the callable of a check.
@ std_exception
A std::exception that was not the expected one was thrown; its what() is kept.
@ none
Nothing was thrown, or the expected exception was thrown.
@ unknown_exception
Another exception was thrown.
basic_c_string< char > c_string
The C string operand of char strings.
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.
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.
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 > > stored_operand_t
The type with which an expression stores an operand.
The templates and the concepts for extending the µTest++ testing framework.
Primary namespace for the µTest++ testing framework.
Logical AND comparator struct template.
constexpr and_op(L &&lhs, R &&rhs)
Constructs a logical AND comparator for the given operands.
Approximate comparator struct template.
constexpr approx_op(L &&lhs, R &&rhs, E &&epsilon)
Constructs an approximate comparator for the given operands.
constexpr decltype(auto) epsilon(void) const
Retrieves the tolerance.
Epsilon_T epsilon_
The stored tolerance.
An array operand of a comparator, other than a character array.
std::size_t count_
The number of elements.
const T * first_
The first element.
constexpr const T * begin(void) const noexcept
Returns an iterator to the first element.
constexpr array_operand(const T *first, std::size_t count) noexcept
Constructs the operand from the first element and the size of an array.
constexpr const T * end(void) const noexcept
Returns an iterator past the last element.
A C string operand of a comparator.
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.
constexpr basic_c_string(const Char_T *str) noexcept
Constructs the operand from a pointer to a null-terminated string.
constexpr basic_c_string(const Char_T *str, std::size_t capacity) noexcept
Constructs the operand from an array of characters.
constexpr decltype(auto) lhs(void) const
Retrieves the left-hand operand.
Rhs_T rhs_
Stores the right-hand operand.
constexpr binary_op(L &&lhs, R &&rhs, bool value)
Constructs a binary comparator with the given operands and pre-computed result.
const bool value_
Stores the result of the comparison.
Lhs_T lhs_
Stores the left-hand operand.
constexpr decltype(auto) rhs(void) const
Retrieves the right-hand operand.
callable_op(callable_result &&result)
Constructs a callable operator with the pre-computed result.
std::string what_
Stores the what() of the std::exception thrown, when the check failed.
throw_outcome outcome_
Stores what the invocation threw, when the check failed.
throw_outcome outcome(void) const noexcept
Retrieves what the invocation threw.
const std::string & what(void) const noexcept
Retrieves the what() of the std::exception thrown.
const bool value_
Stores the result of the callable invocation.
The result of the invocation of the callable of a check.
std::string what
The what() of the std::exception thrown, if any.
throw_outcome outcome
What was thrown, when the check failed.
bool value
The result of the check.
Relational comparator struct template.
constexpr compare_op(L &&lhs, R &&rhs, Compare_T)
Constructs a comparator for the given operands.
Equality tag for compare_op.
static constexpr bool apply(const Lhs_T &lhs, const Rhs_T &rhs)
Compares the operands with ==.
static constexpr const char * symbol
The operator symbol, as displayed in the failure reports.
The exception thrown to stop a test case after a failed require().
Greater than or equal tag for compare_op.
static constexpr const char * symbol
The operator symbol, as displayed in the failure reports.
static constexpr bool apply(const Lhs_T &lhs, const Rhs_T &rhs)
Compares the operands with >=.
Greater than tag for compare_op.
static constexpr bool apply(const Lhs_T &lhs, const Rhs_T &rhs)
Compares the operands with >.
static constexpr const char * symbol
The operator symbol, as displayed in the failure reports.
Less than or equal tag for compare_op.
static constexpr const char * symbol
The operator symbol, as displayed in the failure reports.
static constexpr bool apply(const Lhs_T &lhs, const Rhs_T &rhs)
Compares the operands with <=.
Less than tag for compare_op.
static constexpr const char * symbol
The operator symbol, as displayed in the failure reports.
static constexpr bool apply(const Lhs_T &lhs, const Rhs_T &rhs)
Compares the operands with <.
Non-equality tag for compare_op.
static constexpr bool apply(const Lhs_T &lhs, const Rhs_T &rhs)
Compares the operands with !=.
static constexpr const char * symbol
The operator symbol, as displayed in the failure reports.
constexpr not_op(U &&t)
Constructs a logical NOT comparator for the given operand.
nothrow_op(Callable_T &&func)
Constructs a nothrow checking operator for the given callable.
Empty base struct for the framework expression types.
Logical OR comparator struct template.
constexpr or_op(L &&lhs, R &&rhs)
Constructs a logical OR comparator for the given operands.
Unary predicate struct template.
constexpr predicate_op(U &&t, Predicate_T)
Constructs a predicate for the given operand.
The type of the elements of a range, as iterated by a range-based for statement.
throws_op(Callable_T &&func)
Constructs an exception checking operator for the given callable.
throws_op(Callable_T &&func)
Constructs an exception checking operator for the given callable.
constexpr decltype(auto) operand(void) const
Retrieves the wrapped operand expression.
constexpr unary_op(U &&t, bool value)
Constructs a unary comparator with the given operand and pre-computed result.
const bool value_
Stores the result of the operation.
Struct template representing a generic value, accessible via a getter.
constexpr compare_op(L &&lhs, R &&rhs, Compare_T)
Constructs a comparator for the given operands.
constexpr predicate_op(U &&t, Predicate_T)
Constructs a predicate for the given operand.