42#ifndef MICRO_OS_PLUS_MICRO_TEST_PLUS_INLINES_DETAIL_INLINES_H_
43#define MICRO_OS_PLUS_MICRO_TEST_PLUS_INLINES_DETAIL_INLINES_H_
47#if defined(__cplusplus)
56#pragma GCC diagnostic push
58#pragma GCC diagnostic ignored "-Waggregate-return"
60#pragma clang diagnostic ignored "-Wunknown-warning-option"
61#pragma clang diagnostic ignored "-Wc++98-compat"
62#pragma clang diagnostic ignored "-Wc++98-compat-pedantic"
85 if constexpr (
requires { t.get (); })
111 operator bool ()
const
135 template <
class Lhs_T,
class Rhs_T>
148 template <
class Lhs_T,
class Rhs_T>
150 operator bool ()
const
161 template <
class Lhs_T,
class Rhs_T>
174 template <
class Lhs_T,
class Rhs_T>
190 template <
class Lhs_T,
class Rhs_T>
199 using std::operator==;
200 using std::operator<;
203#pragma GCC diagnostic push
205#pragma GCC diagnostic ignored "-Wfloat-equal"
206#pragma GCC diagnostic ignored "-Wconversion"
207#pragma GCC diagnostic ignored "-Wdouble-promotion"
208#pragma GCC diagnostic ignored "-Wsign-compare"
209#if defined(__clang__)
210#pragma clang diagnostic ignored "-Wimplicit-int-float-conversion"
211#pragma clang diagnostic ignored "-Wpedantic"
220 return Lhs_T::value == Rhs_T::value;
248#pragma GCC diagnostic pop
263 template <
class Lhs_T,
class Rhs_T>
267 using std::operator==;
268 using std::operator!=;
269 using std::operator>;
272#pragma GCC diagnostic push
274#pragma GCC diagnostic ignored "-Wfloat-equal"
275#pragma GCC diagnostic ignored "-Wconversion"
276#pragma GCC diagnostic ignored "-Wdouble-promotion"
277#pragma GCC diagnostic ignored "-Wsign-compare"
278#if defined(__clang__)
279#pragma clang diagnostic ignored "-Wimplicit-int-float-conversion"
280#pragma clang diagnostic ignored "-Wpedantic"
287 return Lhs_T::value != Rhs_T::value;
309#pragma GCC diagnostic pop
324 template <
class Lhs_T,
class Rhs_T>
328 using std::operator>;
331#pragma GCC diagnostic push
333#pragma GCC diagnostic ignored "-Wconversion"
334#pragma GCC diagnostic ignored "-Wdouble-promotion"
335#pragma GCC diagnostic ignored "-Wsign-compare"
336#if defined(__clang__)
337#pragma clang diagnostic ignored "-Wimplicit-int-float-conversion"
338#pragma clang diagnostic ignored "-Wpedantic"
345 return Lhs_T::value > Rhs_T::value;
353#pragma GCC diagnostic pop
368 template <
class Lhs_T,
class Rhs_T>
372 using std::operator>=;
375#pragma GCC diagnostic push
377#pragma GCC diagnostic ignored "-Wconversion"
378#pragma GCC diagnostic ignored "-Wdouble-promotion"
379#pragma GCC diagnostic ignored "-Wsign-compare"
380#if defined(__clang__)
381#pragma clang diagnostic ignored "-Wimplicit-int-float-conversion"
382#pragma clang diagnostic ignored "-Wpedantic"
389 return Lhs_T::value >= Rhs_T::value;
397#pragma GCC diagnostic pop
412 template <
class Lhs_T,
class Rhs_T>
416 using std::operator<;
419#pragma GCC diagnostic push
421#pragma GCC diagnostic ignored "-Wconversion"
422#pragma GCC diagnostic ignored "-Wdouble-promotion"
423#pragma GCC diagnostic ignored "-Wsign-compare"
424#if defined(__clang__)
425#pragma clang diagnostic ignored "-Wimplicit-int-float-conversion"
426#pragma clang diagnostic ignored "-Wpedantic"
433 return Lhs_T::value < Rhs_T::value;
441#pragma GCC diagnostic pop
456 template <
class Lhs_T,
class Rhs_T>
460 using std::operator<=;
463#pragma GCC diagnostic push
465#pragma GCC diagnostic ignored "-Wconversion"
466#pragma GCC diagnostic ignored "-Wdouble-promotion"
467#pragma GCC diagnostic ignored "-Wsign-compare"
468#if defined(__clang__)
469#pragma clang diagnostic ignored "-Wimplicit-int-float-conversion"
470#pragma clang diagnostic ignored "-Wpedantic"
477 return Lhs_T::value <= Rhs_T::value;
485#pragma GCC diagnostic pop
499 template <
class Lhs_T,
class Rhs_T>
502 lhs,
rhs,
static_cast<bool> (
lhs) and
static_cast<bool> (
rhs)
515 template <
class Lhs_T,
class Rhs_T>
518 lhs,
rhs,
static_cast<bool> (
lhs) or
static_cast<bool> (
rhs)
532 :
unary_op_<T>{ t, not
static_cast<bool> (t) }
538#if defined(__cpp_exceptions)
554 constexpr callable_op_::
555 operator bool ()
const
570 template <
class Callable_T,
class Exception_T>
572 const Callable_T& func)
579 catch (
const Exception_T&)
601 template <
class Callable_T>
627 template <
class Callable_T>
649#pragma GCC diagnostic push
651#if defined(__clang__)
652#pragma clang diagnostic ignored "-Wunsafe-buffer-usage"
653#pragma clang diagnostic ignored "-Wunsafe-buffer-usage-in-libc-call"
672 requires std::is_arithmetic_v<T>
677 if constexpr (std::is_same_v<T, long double>)
680 || (defined(__SIZEOF_LONG_DOUBLE__) \
681 && __SIZEOF_LONG_DOUBLE__ == __SIZEOF_DOUBLE__)
687 const auto [ptr, ec] = std::to_chars (buf, buf +
sizeof (buf),
688 static_cast<double> (v));
689 if (ec == std::errc{})
690 buffer.append (buf, ptr);
696 snprintf (buf,
sizeof (buf),
"%Lg", v);
702 const auto [ptr, ec] = std::to_chars (buf, buf +
sizeof (buf), v);
703 if (ec == std::errc{})
704 buffer.append (buf, ptr);
709#pragma GCC diagnostic pop
721#pragma GCC diagnostic pop
C++20 concept satisfied when T provides an epsilon member.
C++20 concept satisfied when T provides a value member.
Internal implementation details for the µTest++ framework.
void append_number_(std::string &buffer, T v)
Appends the string representation of a numeric value to a buffer, using std::to_chars for allocation-...
constexpr auto get(const T &t)
Generic getter function template for value retrieval.
constexpr auto min_value(const T &lhs, const T &rhs) noexcept -> const T &
Computes the minimum of two comparable values.
constexpr auto abs(const T t) noexcept -> T
Computes the absolute value of a given comparable value.
Primary namespace for the µTest++ testing framework.
constexpr and_(const Lhs_T &lhs={}, const Rhs_T &rhs={})
Constructs a logical AND comparator for the given operands.
const bool value_
Stores the result of the comparison.
constexpr auto lhs(void) const
Retrieves the left-hand operand.
constexpr binary_op_(const Lhs_T &lhs, const Rhs_T &rhs, bool value)
Constructs a binary comparator with the given operands and pre-computed result.
const Rhs_T rhs_
Stores the right-hand operand.
const Lhs_T lhs_
Stores the left-hand operand.
constexpr auto rhs(void) const
Retrieves the right-hand operand.
constexpr callable_op_(bool value)
Constructs a callable operator with the pre-computed boolean result.
const bool value_
Stores the result of the callable invocation.
constexpr eq_(const Lhs_T &lhs={}, const Rhs_T &rhs={})
Constructs an equality comparator for the given operands.
constexpr ge_(const Lhs_T &lhs={}, const Rhs_T &rhs={})
Constructs a greater than or equal comparator for the given operands.
constexpr gt_(const Lhs_T &lhs={}, const Rhs_T &rhs={})
Constructs a greater than comparator for the given operands.
constexpr le_(const Lhs_T &lhs={}, const Rhs_T &rhs={})
Constructs a less than or equal comparator for the given operands.
constexpr lt_(const Lhs_T &lhs={}, const Rhs_T &rhs={})
Constructs a less than comparator for the given operands.
constexpr ne_(const Lhs_T &lhs={}, const Rhs_T &rhs={})
Constructs a non-equality comparator for the given operands.
constexpr not_(const T &t={})
Constructs a logical NOT comparator for the given operand.
constexpr nothrow_(const Callable_T &func)
Constructs a nothrow checking operator for the given callable.
constexpr or_(const Lhs_T &lhs={}, const Rhs_T &rhs={})
Constructs a logical OR comparator for the given operands.
constexpr throws_(const Callable_T &func)
Constructs an exception checking operator for the given callable.
const T t_
Stores the operand.
constexpr auto operand() const
Retrieves the wrapped operand expression.
constexpr unary_op_(const T &t, bool value)
Constructs a unary comparator with the given operand and pre-computed result.
const bool value_
Stores the result of the operation.