42#ifndef MICRO_TEST_PLUS_DETAIL_INLINES_H_
43#define MICRO_TEST_PLUS_DETAIL_INLINES_H_
56#pragma GCC diagnostic push
57#pragma GCC diagnostic ignored "-Waggregate-return"
59#pragma clang diagnostic ignored "-Wc++98-compat"
60#pragma clang diagnostic ignored "-Wc++98-compat-pedantic"
83 if constexpr (
requires { t.get (); })
109 operator bool ()
const
133 template <
class Lhs_T,
class Rhs_T>
146 template <
class Lhs_T,
class Rhs_T>
148 operator bool ()
const
159 template <
class Lhs_T,
class Rhs_T>
172 template <
class Lhs_T,
class Rhs_T>
188 template <
class Lhs_T,
class Rhs_T>
197 using std::operator==;
198 using std::operator<;
201#pragma GCC diagnostic push
202#pragma GCC diagnostic ignored "-Wfloat-equal"
203#pragma GCC diagnostic ignored "-Wconversion"
204#pragma GCC diagnostic ignored "-Wdouble-promotion"
205#pragma GCC diagnostic ignored "-Wsign-compare"
206#if defined(__clang__)
207#pragma clang diagnostic ignored "-Wimplicit-int-float-conversion"
208#pragma clang diagnostic ignored "-Wpedantic"
216 return Lhs_T::value == Rhs_T::value;
243#pragma GCC diagnostic pop
258 template <
class Lhs_T,
class Rhs_T>
262 using std::operator==;
263 using std::operator!=;
264 using std::operator>;
267#pragma GCC diagnostic push
268#pragma GCC diagnostic ignored "-Wfloat-equal"
269#pragma GCC diagnostic ignored "-Wconversion"
270#pragma GCC diagnostic ignored "-Wdouble-promotion"
271#pragma GCC diagnostic ignored "-Wsign-compare"
272#if defined(__clang__)
273#pragma clang diagnostic ignored "-Wimplicit-int-float-conversion"
274#pragma clang diagnostic ignored "-Wpedantic"
280 return Lhs_T::value != Rhs_T::value;
301#pragma GCC diagnostic pop
316 template <
class Lhs_T,
class Rhs_T>
320 using std::operator>;
323#pragma GCC diagnostic push
324#pragma GCC diagnostic ignored "-Wconversion"
325#pragma GCC diagnostic ignored "-Wdouble-promotion"
326#pragma GCC diagnostic ignored "-Wsign-compare"
327#if defined(__clang__)
328#pragma clang diagnostic ignored "-Wimplicit-int-float-conversion"
329#pragma clang diagnostic ignored "-Wpedantic"
335 return Lhs_T::value > Rhs_T::value;
342#pragma GCC diagnostic pop
357 template <
class Lhs_T,
class Rhs_T>
361 using std::operator>=;
364#pragma GCC diagnostic push
365#pragma GCC diagnostic ignored "-Wconversion"
366#pragma GCC diagnostic ignored "-Wdouble-promotion"
367#pragma GCC diagnostic ignored "-Wsign-compare"
368#if defined(__clang__)
369#pragma clang diagnostic ignored "-Wimplicit-int-float-conversion"
370#pragma clang diagnostic ignored "-Wpedantic"
376 return Lhs_T::value >= Rhs_T::value;
383#pragma GCC diagnostic pop
398 template <
class Lhs_T,
class Rhs_T>
402 using std::operator<;
405#pragma GCC diagnostic push
406#pragma GCC diagnostic ignored "-Wconversion"
407#pragma GCC diagnostic ignored "-Wdouble-promotion"
408#pragma GCC diagnostic ignored "-Wsign-compare"
409#if defined(__clang__)
410#pragma clang diagnostic ignored "-Wimplicit-int-float-conversion"
411#pragma clang diagnostic ignored "-Wpedantic"
417 return Lhs_T::value < Rhs_T::value;
424#pragma GCC diagnostic pop
439 template <
class Lhs_T,
class Rhs_T>
443 using std::operator<=;
446#pragma GCC diagnostic push
447#pragma GCC diagnostic ignored "-Wconversion"
448#pragma GCC diagnostic ignored "-Wdouble-promotion"
449#pragma GCC diagnostic ignored "-Wsign-compare"
450#if defined(__clang__)
451#pragma clang diagnostic ignored "-Wimplicit-int-float-conversion"
452#pragma clang diagnostic ignored "-Wpedantic"
458 return Lhs_T::value <= Rhs_T::value;
465#pragma GCC diagnostic pop
479 template <
class Lhs_T,
class Rhs_T>
482 lhs,
rhs,
static_cast<bool> (
lhs) and
static_cast<bool> (
rhs)
495 template <
class Lhs_T,
class Rhs_T>
498 lhs,
rhs,
static_cast<bool> (
lhs) or
static_cast<bool> (
rhs)
512 :
unary_op_<T>{ t, not
static_cast<bool> (t) }
518#if defined(__cpp_exceptions)
534 constexpr callable_op_::
535 operator bool ()
const
550 template <
class Callable_T,
class Exception_T>
552 const Callable_T& func)
559 catch (
const Exception_T&)
581 template <
class Callable_T>
607 template <
class Callable_T>
629#pragma GCC diagnostic push
630#if defined(__clang__)
631#pragma clang diagnostic ignored "-Wunsafe-buffer-usage"
632#pragma clang diagnostic ignored "-Wunsafe-buffer-usage-in-libc-call"
651 requires std::is_arithmetic_v<T>
656 if constexpr (std::is_same_v<T, long double>)
659 || (defined(__SIZEOF_LONG_DOUBLE__) \
660 && __SIZEOF_LONG_DOUBLE__ == __SIZEOF_DOUBLE__)
666 const auto [ptr, ec] = std::to_chars (buf, buf +
sizeof (buf),
667 static_cast<double> (v));
668 if (ec == std::errc{})
669 buffer.append (buf, ptr);
675 snprintf (buf,
sizeof (buf),
"%Lg", v);
681 const auto [ptr, ec] = std::to_chars (buf, buf +
sizeof (buf), v);
682 if (ec == std::errc{})
683 buffer.append (buf, ptr);
688#pragma GCC diagnostic pop
700#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.