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 "-Wunknown-warning-option"
60#pragma clang diagnostic ignored "-Wc++98-compat"
61#pragma clang diagnostic ignored "-Wc++98-compat-pedantic"
84 if constexpr (
requires { t.get (); })
110 operator bool ()
const
134 template <
class Lhs_T,
class Rhs_T>
147 template <
class Lhs_T,
class Rhs_T>
149 operator bool ()
const
160 template <
class Lhs_T,
class Rhs_T>
173 template <
class Lhs_T,
class Rhs_T>
189 template <
class Lhs_T,
class Rhs_T>
198 using std::operator==;
199 using std::operator<;
202#pragma GCC diagnostic push
203#pragma GCC diagnostic ignored "-Wfloat-equal"
204#pragma GCC diagnostic ignored "-Wconversion"
205#pragma GCC diagnostic ignored "-Wdouble-promotion"
206#pragma GCC diagnostic ignored "-Wsign-compare"
207#if defined(__clang__)
208#pragma clang diagnostic ignored "-Wimplicit-int-float-conversion"
209#pragma clang diagnostic ignored "-Wpedantic"
217 return Lhs_T::value == Rhs_T::value;
244#pragma GCC diagnostic pop
259 template <
class Lhs_T,
class Rhs_T>
263 using std::operator==;
264 using std::operator!=;
265 using std::operator>;
268#pragma GCC diagnostic push
269#pragma GCC diagnostic ignored "-Wfloat-equal"
270#pragma GCC diagnostic ignored "-Wconversion"
271#pragma GCC diagnostic ignored "-Wdouble-promotion"
272#pragma GCC diagnostic ignored "-Wsign-compare"
273#if defined(__clang__)
274#pragma clang diagnostic ignored "-Wimplicit-int-float-conversion"
275#pragma clang diagnostic ignored "-Wpedantic"
281 return Lhs_T::value != Rhs_T::value;
302#pragma GCC diagnostic pop
317 template <
class Lhs_T,
class Rhs_T>
321 using std::operator>;
324#pragma GCC diagnostic push
325#pragma GCC diagnostic ignored "-Wconversion"
326#pragma GCC diagnostic ignored "-Wdouble-promotion"
327#pragma GCC diagnostic ignored "-Wsign-compare"
328#if defined(__clang__)
329#pragma clang diagnostic ignored "-Wimplicit-int-float-conversion"
330#pragma clang diagnostic ignored "-Wpedantic"
336 return Lhs_T::value > Rhs_T::value;
343#pragma GCC diagnostic pop
358 template <
class Lhs_T,
class Rhs_T>
362 using std::operator>=;
365#pragma GCC diagnostic push
366#pragma GCC diagnostic ignored "-Wconversion"
367#pragma GCC diagnostic ignored "-Wdouble-promotion"
368#pragma GCC diagnostic ignored "-Wsign-compare"
369#if defined(__clang__)
370#pragma clang diagnostic ignored "-Wimplicit-int-float-conversion"
371#pragma clang diagnostic ignored "-Wpedantic"
377 return Lhs_T::value >= Rhs_T::value;
384#pragma GCC diagnostic pop
399 template <
class Lhs_T,
class Rhs_T>
403 using std::operator<;
406#pragma GCC diagnostic push
407#pragma GCC diagnostic ignored "-Wconversion"
408#pragma GCC diagnostic ignored "-Wdouble-promotion"
409#pragma GCC diagnostic ignored "-Wsign-compare"
410#if defined(__clang__)
411#pragma clang diagnostic ignored "-Wimplicit-int-float-conversion"
412#pragma clang diagnostic ignored "-Wpedantic"
418 return Lhs_T::value < Rhs_T::value;
425#pragma GCC diagnostic pop
440 template <
class Lhs_T,
class Rhs_T>
444 using std::operator<=;
447#pragma GCC diagnostic push
448#pragma GCC diagnostic ignored "-Wconversion"
449#pragma GCC diagnostic ignored "-Wdouble-promotion"
450#pragma GCC diagnostic ignored "-Wsign-compare"
451#if defined(__clang__)
452#pragma clang diagnostic ignored "-Wimplicit-int-float-conversion"
453#pragma clang diagnostic ignored "-Wpedantic"
459 return Lhs_T::value <= Rhs_T::value;
466#pragma GCC diagnostic pop
480 template <
class Lhs_T,
class Rhs_T>
483 lhs,
rhs,
static_cast<bool> (
lhs) and
static_cast<bool> (
rhs)
496 template <
class Lhs_T,
class Rhs_T>
499 lhs,
rhs,
static_cast<bool> (
lhs) or
static_cast<bool> (
rhs)
513 :
unary_op_<T>{ t, not
static_cast<bool> (t) }
519#if defined(__cpp_exceptions)
535 constexpr callable_op_::
536 operator bool ()
const
551 template <
class Callable_T,
class Exception_T>
553 const Callable_T& func)
560 catch (
const Exception_T&)
582 template <
class Callable_T>
608 template <
class Callable_T>
630#pragma GCC diagnostic push
631#if defined(__clang__)
632#pragma clang diagnostic ignored "-Wunsafe-buffer-usage"
633#pragma clang diagnostic ignored "-Wunsafe-buffer-usage-in-libc-call"
652 requires std::is_arithmetic_v<T>
657 if constexpr (std::is_same_v<T, long double>)
660 || (defined(__SIZEOF_LONG_DOUBLE__) \
661 && __SIZEOF_LONG_DOUBLE__ == __SIZEOF_DOUBLE__)
667 const auto [ptr, ec] = std::to_chars (buf, buf +
sizeof (buf),
668 static_cast<double> (v));
669 if (ec == std::errc{})
670 buffer.append (buf, ptr);
676 snprintf (buf,
sizeof (buf),
"%Lg", v);
682 const auto [ptr, ec] = std::to_chars (buf, buf +
sizeof (buf), v);
683 if (ec == std::errc{})
684 buffer.append (buf, ptr);
689#pragma GCC diagnostic pop
701#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.