42#ifndef MICRO_TEST_PLUS_DETAIL_H_
43#define MICRO_TEST_PLUS_DETAIL_H_
57#pragma GCC diagnostic push
58#pragma GCC diagnostic ignored "-Wpadded"
59#pragma GCC diagnostic ignored "-Waggregate-return"
61#pragma clang diagnostic ignored "-Wc++98-compat"
111 template <
class Expr_T>
159 [[nodiscard]]
constexpr auto
188 [[nodiscard]]
constexpr auto
222 [[nodiscard]]
constexpr auto
258 template <
class Lhs_T,
class Rhs_T>
272 constexpr eq_ (
const Lhs_T&
lhs = {},
const Rhs_T&
rhs = {})
278 using std::operator==;
279 using std::operator<;
282#pragma GCC diagnostic push
283#pragma GCC diagnostic ignored "-Wfloat-equal"
284#pragma GCC diagnostic ignored "-Wconversion"
285#pragma GCC diagnostic ignored "-Wdouble-promotion"
286#pragma GCC diagnostic ignored "-Wsign-compare"
287#if defined(__clang__)
288#pragma clang diagnostic ignored "-Wimplicit-int-float-conversion"
289#pragma clang diagnostic ignored "-Wpedantic"
297 return Lhs_T::value == Rhs_T::value;
327#pragma GCC diagnostic pop
345 [[nodiscard]]
constexpr
346 operator bool ()
const
363 [[nodiscard]]
constexpr auto
381 [[nodiscard]]
constexpr auto
404 template <
typename Lhs_T,
typename Rhs_T>
436 template <
class Lhs_T,
class Rhs_T>
450 constexpr ne_ (
const Lhs_T&
lhs = {},
const Rhs_T& rhs = {})
451 : lhs_{ lhs }, rhs_{ rhs }, value_{
454 using std::operator==;
455 using std::operator!=;
456 using std::operator>;
459#pragma GCC diagnostic push
460#pragma GCC diagnostic ignored "-Wfloat-equal"
461#pragma GCC diagnostic ignored "-Wconversion"
462#pragma GCC diagnostic ignored "-Wdouble-promotion"
463#pragma GCC diagnostic ignored "-Wsign-compare"
464#if defined(__clang__)
465#pragma clang diagnostic ignored "-Wimplicit-int-float-conversion"
466#pragma clang diagnostic ignored "-Wpedantic"
472 return Lhs_T::value != Rhs_T::value;
474 else if constexpr (type_traits::has_epsilon_v<Lhs_T>
475 and type_traits::has_epsilon_v<Rhs_T>)
477 return math::abs (get (lhs_) - get (rhs_))
478 > math::min_value (Lhs_T::epsilon,
481 else if constexpr (type_traits::has_epsilon_v<Lhs_T>)
483 return math::abs (get (lhs_) - get (rhs_))
486 else if constexpr (type_traits::has_epsilon_v<Rhs_T>)
488 return math::abs (get (lhs_) - get (rhs_))
493 return get (lhs_) !=
get (rhs_);
496#pragma GCC diagnostic pop
514 [[nodiscard]]
constexpr
515 operator bool ()
const
532 [[nodiscard]]
constexpr auto
550 [[nodiscard]]
constexpr auto
573 template <
typename Lhs_T,
typename Rhs_T>
603 template <
class Lhs_T,
class Rhs_T>
617 constexpr gt_ (
const Lhs_T&
lhs = {},
const Rhs_T& rhs = {})
618 : lhs_{ lhs }, rhs_{ rhs },
621 using std::operator>;
624#pragma GCC diagnostic push
625#pragma GCC diagnostic ignored "-Wconversion"
626#pragma GCC diagnostic ignored "-Wdouble-promotion"
627#pragma GCC diagnostic ignored "-Wsign-compare"
628#if defined(__clang__)
629#pragma clang diagnostic ignored "-Wimplicit-int-float-conversion"
630#pragma clang diagnostic ignored "-Wpedantic"
636 return Lhs_T::value > Rhs_T::value;
640 return get (lhs_) > get (rhs_);
643#pragma GCC diagnostic pop
661 [[nodiscard]]
constexpr
662 operator bool ()
const
679 [[nodiscard]]
constexpr auto
684 [[nodiscard]]
constexpr auto
720 template <
typename Lhs_T,
typename Rhs_T>
750 template <
class Lhs_T,
class Rhs_T>
766 constexpr ge_ (
const Lhs_T&
lhs = {},
const Rhs_T& rhs = {})
767 : lhs_{ lhs }, rhs_{ rhs },
770 using std::operator>=;
773#pragma GCC diagnostic push
774#pragma GCC diagnostic ignored "-Wconversion"
775#pragma GCC diagnostic ignored "-Wdouble-promotion"
776#pragma GCC diagnostic ignored "-Wsign-compare"
777#if defined(__clang__)
778#pragma clang diagnostic ignored "-Wimplicit-int-float-conversion"
779#pragma clang diagnostic ignored "-Wpedantic"
785 return Lhs_T::value >= Rhs_T::value;
789 return get (lhs_) >= get (rhs_);
792#pragma GCC diagnostic pop
810 [[nodiscard]]
constexpr
811 operator bool ()
const
828 [[nodiscard]]
constexpr auto
846 [[nodiscard]]
constexpr auto
869 template <
typename Lhs_T,
typename Rhs_T>
899 template <
class Lhs_T,
class Rhs_T>
913 constexpr lt_ (
const Lhs_T&
lhs = {},
const Rhs_T& rhs = {})
914 : lhs_{ lhs }, rhs_{ rhs },
917 using std::operator<;
920#pragma GCC diagnostic push
921#pragma GCC diagnostic ignored "-Wconversion"
922#pragma GCC diagnostic ignored "-Wdouble-promotion"
923#pragma GCC diagnostic ignored "-Wsign-compare"
924#if defined(__clang__)
925#pragma clang diagnostic ignored "-Wimplicit-int-float-conversion"
926#pragma clang diagnostic ignored "-Wpedantic"
932 return Lhs_T::value < Rhs_T::value;
936 return get (lhs_) < get (rhs_);
939#pragma GCC diagnostic pop
957 [[nodiscard]]
constexpr
958 operator bool ()
const
975 [[nodiscard]]
constexpr auto
993 [[nodiscard]]
constexpr auto
1017 template <
typename Lhs_T,
typename Rhs_T>
1047 template <
class Lhs_T,
class Rhs_T>
1063 constexpr le_ (
const Lhs_T&
lhs = {},
const Rhs_T& rhs = {})
1064 : lhs_{ lhs }, rhs_{ rhs },
1067 using std::operator<=;
1069#if defined(__GNUC__)
1070#pragma GCC diagnostic push
1071#pragma GCC diagnostic ignored "-Wconversion"
1072#pragma GCC diagnostic ignored "-Wdouble-promotion"
1073#pragma GCC diagnostic ignored "-Wsign-compare"
1074#if defined(__clang__)
1075#pragma clang diagnostic ignored "-Wimplicit-int-float-conversion"
1076#pragma clang diagnostic ignored "-Wpedantic"
1082 return Lhs_T::value <= Rhs_T::value;
1086 return get (lhs_) <= get (rhs_);
1088#if defined(__GNUC__)
1089#pragma GCC diagnostic pop
1107 [[nodiscard]]
constexpr
1108 operator bool ()
const
1126 [[nodiscard]]
constexpr auto
1144 [[nodiscard]]
constexpr auto
1167 template <
typename Lhs_T,
typename Rhs_T>
1196 template <
class Lhs_T,
class Rhs_T>
1210 constexpr and_ (
const Lhs_T&
lhs = {},
const Rhs_T& rhs = {})
1211 : lhs_{ lhs }, rhs_{ rhs },
1212 value_{ static_cast<bool> (lhs) and static_cast<bool> (rhs) }
1227 [[nodiscard]]
constexpr
1228 operator bool ()
const
1245 [[nodiscard]]
constexpr auto
1263 [[nodiscard]]
constexpr auto
1286 template <
typename Lhs_T,
typename Rhs_T>
1315 template <
class Lhs_T,
class Rhs_T>
1329 constexpr or_ (
const Lhs_T&
lhs = {},
const Rhs_T& rhs = {})
1330 : lhs_{ lhs }, rhs_{ rhs },
1331 value_{ static_cast<bool> (lhs) or static_cast<bool> (rhs) }
1346 [[nodiscard]]
constexpr
1347 operator bool ()
const
1364 [[nodiscard]]
constexpr auto
1382 [[nodiscard]]
constexpr auto
1405 template <
typename Lhs_T,
typename Rhs_T>
1446 explicit constexpr not_ (
const T& t = {})
1447 : t_{ t }, value_{ not static_cast<bool> (t) }
1462 [[nodiscard]]
constexpr
1463 operator bool ()
const
1479 [[nodiscard]]
constexpr auto
1497 template <
typename T>
1502#if defined(__cpp_exceptions)
1530 template <
class Callable_T,
class Exception_T =
void>
1544 constexpr explicit throws_ (
const Callable_T& func)
1551 catch (
const Exception_T&)
1576 [[nodiscard]]
constexpr
1577 operator bool ()
const
1614 template <
class Callable_T>
1628 constexpr explicit throws_ (
const Callable_T& func)
1655 [[nodiscard]]
constexpr
1656 operator bool ()
const
1693 template <
class Callable_T>
1733 [[nodiscard]]
constexpr
1734 operator bool ()
const
1794 operator<< (
const T& msg);
1808 [[nodiscard]]
constexpr bool
1858 template <
class Expr_T>
1875 const Expr_T& expr,
bool abort,
1896#if defined(__GNUC__)
1897#pragma GCC diagnostic pop
const reflection::source_location location_
Stores the source location associated with the report.
constexpr bool value() const
Retrieves the result value.
std::string message_
String to collect the expectation message passed via operator<<().
bool abort_
Indicates whether the reporting should abort further processing.
deferred_reporter_base(bool value, const reflection::source_location location)
Constructs a deferred reporter base.
bool value_
Stores the result value of the report.
constexpr deferred_reporter(const Expr_T &expr, bool abort, const reflection::source_location &location)
Constructs a deferred reporter for a specific expression.
const Expr_T expr_
Stores the expression under evaluation.
Local implementation of source location information for diagnostics.
Internal implementation details for the µTest++ framework.
constexpr auto get_impl(const T &t, int) -> decltype(t.get())
Generic getter function template for value retrieval.
constexpr auto get(const T &t)
Generic getter function template for value retrieval.
constexpr auto abs(const T t) -> T
Computes the absolute value of a given comparable value.
constexpr auto min_value(const T &lhs, const T &rhs) -> const T &
Computes the minimum of two comparable values.
static constexpr auto has_epsilon_v
Variable template to determine if a type provides an epsilon member.
static constexpr auto has_value_v
Variable template to determine if a type provides a value member.
Primary namespace for the µTest++ testing framework.
Logical AND comparator struct template.
constexpr auto rhs(void) const
Retrieves the right-hand operand.
const bool value_
Stores the result of the logical AND operation.
const Rhs_T rhs_
Stores the right-hand operand.
constexpr auto lhs(void) const
Retrieves the left-hand operand.
constexpr and_(const Lhs_T &lhs={}, const Rhs_T &rhs={})
Constructs a logical AND comparator for the given operands.
const Lhs_T lhs_
Stores the left-hand operand.
Assertion struct template for parameter passing to the evaluator.
Expr_T expr
The expression under evaluation.
reflection::source_location location
The source location associated with the assertion.
Equality comparator struct template.
constexpr eq_(const Lhs_T &lhs={}, const Rhs_T &rhs={})
Constructs an equality comparator for the given operands.
constexpr auto rhs(void) const
Retrieves the right-hand operand.
const Lhs_T lhs_
Stores the left-hand operand.
const bool value_
Stores the result of the equality comparison.
constexpr auto lhs(void) const
Retrieves the left-hand operand.
const Rhs_T rhs_
Stores the right-hand operand.
Greater than or equal comparator struct template.
const Lhs_T lhs_
Stores the left-hand operand.
constexpr auto rhs(void) const
Retrieves the right-hand operand.
constexpr ge_(const Lhs_T &lhs={}, const Rhs_T &rhs={})
Constructs a greater than or equal comparator for the given operands.
const Rhs_T rhs_
Stores the right-hand operand.
constexpr auto lhs(void) const
Retrieves the left-hand operand.
const bool value_
Stores the result of the greater than or equal comparison.
Greater than comparator struct template.
constexpr gt_(const Lhs_T &lhs={}, const Rhs_T &rhs={})
Constructs a greater than comparator for the given operands.
constexpr auto lhs(void) const
Retrieves the left-hand operand.
const bool value_
Stores the result of the greater than comparison.
constexpr auto rhs(void) const
Retrieves the right-hand operand.
const Lhs_T lhs_
Stores the left-hand operand.
const Rhs_T rhs_
Stores the right-hand operand.
Less than or equal comparator struct template.
constexpr auto rhs(void) const
Retrieves the right-hand operand.
const Lhs_T lhs_
Stores the left-hand operand.
const bool value_
Stores the result of the less than or equal comparison.
constexpr le_(const Lhs_T &lhs={}, const Rhs_T &rhs={})
Constructs a less than or equal comparator for the given operands.
const Rhs_T rhs_
Stores the right-hand operand.
constexpr auto lhs(void) const
Retrieves the left-hand operand.
Less than comparator struct template.
const Lhs_T lhs_
Stores the left-hand operand.
constexpr auto lhs(void) const
Retrieves the left-hand operand.
constexpr auto rhs(void) const
Retrieves the right-hand operand.
const bool value_
Stores the result of the less than comparison.
const Rhs_T rhs_
Stores the right-hand operand.
constexpr lt_(const Lhs_T &lhs={}, const Rhs_T &rhs={})
Constructs a less than comparator for the given operands.
Non-equality comparator struct template.
const Rhs_T rhs_
Stores the right-hand operand.
constexpr ne_(const Lhs_T &lhs={}, const Rhs_T &rhs={})
Constructs a non-equality comparator for the given operands.
constexpr auto rhs(void) const
Retrieves the right-hand operand.
constexpr auto lhs(void) const
Retrieves the left-hand operand.
const bool value_
Stores the result of the non-equality comparison.
const Lhs_T lhs_
Stores the left-hand operand.
Logical NOT comparator struct template.
constexpr auto value() const
Retrieves the value of the operand.
const T t_
Stores the operand.
constexpr not_(const T &t={})
Constructs a logical NOT comparator for the given operand.
const bool value_
Stores the result of the logical NOT operation.
constexpr nothrow_(const Callable_T &func)
Constructs a nothrow checking operator for the given callable.
const bool value_
Stores the result of the nothrow check.
Logical OR comparator struct template.
const Lhs_T lhs_
Stores the left-hand operand.
const Rhs_T rhs_
Stores the right-hand operand.
constexpr auto rhs(void) const
Retrieves the right-hand operand.
constexpr auto lhs(void) const
Retrieves the left-hand operand.
constexpr or_(const Lhs_T &lhs={}, const Rhs_T &rhs={})
Constructs a logical OR comparator for the given operands.
const bool value_
Stores the result of the logical OR operation.
constexpr throws_(const Callable_T &func)
Constructs an exception checking operator for the given callable.
const bool value_
Stores the result of the exception check.
constexpr throws_(const Callable_T &func)
Constructs an exception checking operator for the given callable.
const bool value_
Stores the result of the exception check.
Empty base struct for all operator types.