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 = {})
276 using std::operator==;
277 using std::operator<;
280#pragma GCC diagnostic push
281#pragma GCC diagnostic ignored "-Wfloat-equal"
282#pragma GCC diagnostic ignored "-Wconversion"
283#pragma GCC diagnostic ignored "-Wdouble-promotion"
284#pragma GCC diagnostic ignored "-Wsign-compare"
285#if defined(__clang__)
286#pragma clang diagnostic ignored "-Wimplicit-int-float-conversion"
287#pragma clang diagnostic ignored "-Wpedantic"
295 return Lhs_T::value == Rhs_T::value;
322#pragma GCC diagnostic pop
339 [[nodiscard]]
constexpr
340 operator bool ()
const
357 [[nodiscard]]
constexpr auto
375 [[nodiscard]]
constexpr auto
398 template <
typename Lhs_T,
typename Rhs_T>
430 template <
class Lhs_T,
class Rhs_T>
444 constexpr ne_ (
const Lhs_T&
lhs = {},
const Rhs_T& rhs = {})
445 : lhs_{ lhs }, rhs_{ rhs }, value_{ [&] {
446 using std::operator==;
447 using std::operator!=;
448 using std::operator>;
451#pragma GCC diagnostic push
452#pragma GCC diagnostic ignored "-Wfloat-equal"
453#pragma GCC diagnostic ignored "-Wconversion"
454#pragma GCC diagnostic ignored "-Wdouble-promotion"
455#pragma GCC diagnostic ignored "-Wsign-compare"
456#if defined(__clang__)
457#pragma clang diagnostic ignored "-Wimplicit-int-float-conversion"
458#pragma clang diagnostic ignored "-Wpedantic"
464 return Lhs_T::value != Rhs_T::value;
466 else if constexpr (type_traits::has_epsilon_v<Lhs_T>
467 and type_traits::has_epsilon_v<Rhs_T>)
469 return math::abs (get (lhs_) - get (rhs_))
470 > math::min_value (Lhs_T::epsilon, Rhs_T::epsilon);
472 else if constexpr (type_traits::has_epsilon_v<Lhs_T>)
474 return math::abs (get (lhs_) - get (rhs_)) > Lhs_T::epsilon;
476 else if constexpr (type_traits::has_epsilon_v<Rhs_T>)
478 return math::abs (get (lhs_) - get (rhs_)) > Rhs_T::epsilon;
482 return get (lhs_) !=
get (rhs_);
485#pragma GCC diagnostic pop
502 [[nodiscard]]
constexpr
503 operator bool ()
const
520 [[nodiscard]]
constexpr auto
538 [[nodiscard]]
constexpr auto
561 template <
typename Lhs_T,
typename Rhs_T>
591 template <
class Lhs_T,
class Rhs_T>
605 constexpr gt_ (
const Lhs_T&
lhs = {},
const Rhs_T& rhs = {})
606 : lhs_{ lhs }, rhs_{ rhs }, value_{ [&] {
607 using std::operator>;
610#pragma GCC diagnostic push
611#pragma GCC diagnostic ignored "-Wconversion"
612#pragma GCC diagnostic ignored "-Wdouble-promotion"
613#pragma GCC diagnostic ignored "-Wsign-compare"
614#if defined(__clang__)
615#pragma clang diagnostic ignored "-Wimplicit-int-float-conversion"
616#pragma clang diagnostic ignored "-Wpedantic"
622 return Lhs_T::value > Rhs_T::value;
626 return get (lhs_) > get (rhs_);
629#pragma GCC diagnostic pop
647 [[nodiscard]]
constexpr
648 operator bool ()
const
665 [[nodiscard]]
constexpr auto
670 [[nodiscard]]
constexpr auto
706 template <
typename Lhs_T,
typename Rhs_T>
736 template <
class Lhs_T,
class Rhs_T>
752 constexpr ge_ (
const Lhs_T&
lhs = {},
const Rhs_T& rhs = {})
753 : lhs_{ lhs }, rhs_{ rhs }, value_{ [&] {
754 using std::operator>=;
757#pragma GCC diagnostic push
758#pragma GCC diagnostic ignored "-Wconversion"
759#pragma GCC diagnostic ignored "-Wdouble-promotion"
760#pragma GCC diagnostic ignored "-Wsign-compare"
761#if defined(__clang__)
762#pragma clang diagnostic ignored "-Wimplicit-int-float-conversion"
763#pragma clang diagnostic ignored "-Wpedantic"
769 return Lhs_T::value >= Rhs_T::value;
773 return get (lhs_) >= get (rhs_);
776#pragma GCC diagnostic pop
794 [[nodiscard]]
constexpr
795 operator bool ()
const
812 [[nodiscard]]
constexpr auto
830 [[nodiscard]]
constexpr auto
853 template <
typename Lhs_T,
typename Rhs_T>
883 template <
class Lhs_T,
class Rhs_T>
897 constexpr lt_ (
const Lhs_T&
lhs = {},
const Rhs_T& rhs = {})
898 : lhs_{ lhs }, rhs_{ rhs }, value_{ [&] {
899 using std::operator<;
902#pragma GCC diagnostic push
903#pragma GCC diagnostic ignored "-Wconversion"
904#pragma GCC diagnostic ignored "-Wdouble-promotion"
905#pragma GCC diagnostic ignored "-Wsign-compare"
906#if defined(__clang__)
907#pragma clang diagnostic ignored "-Wimplicit-int-float-conversion"
908#pragma clang diagnostic ignored "-Wpedantic"
914 return Lhs_T::value < Rhs_T::value;
918 return get (lhs_) < get (rhs_);
921#pragma GCC diagnostic pop
939 [[nodiscard]]
constexpr
940 operator bool ()
const
957 [[nodiscard]]
constexpr auto
975 [[nodiscard]]
constexpr auto
999 template <
typename Lhs_T,
typename Rhs_T>
1029 template <
class Lhs_T,
class Rhs_T>
1045 constexpr le_ (
const Lhs_T&
lhs = {},
const Rhs_T& rhs = {})
1046 : lhs_{ lhs }, rhs_{ rhs }, value_{ [&] {
1047 using std::operator<=;
1049#if defined(__GNUC__)
1050#pragma GCC diagnostic push
1051#pragma GCC diagnostic ignored "-Wconversion"
1052#pragma GCC diagnostic ignored "-Wdouble-promotion"
1053#pragma GCC diagnostic ignored "-Wsign-compare"
1054#if defined(__clang__)
1055#pragma clang diagnostic ignored "-Wimplicit-int-float-conversion"
1056#pragma clang diagnostic ignored "-Wpedantic"
1062 return Lhs_T::value <= Rhs_T::value;
1066 return get (lhs_) <= get (rhs_);
1068#if defined(__GNUC__)
1069#pragma GCC diagnostic pop
1087 [[nodiscard]]
constexpr
1088 operator bool ()
const
1106 [[nodiscard]]
constexpr auto
1124 [[nodiscard]]
constexpr auto
1147 template <
typename Lhs_T,
typename Rhs_T>
1176 template <
class Lhs_T,
class Rhs_T>
1190 constexpr and_ (
const Lhs_T&
lhs = {},
const Rhs_T& rhs = {})
1191 : lhs_{ lhs }, rhs_{ rhs },
1192 value_{ static_cast<bool> (lhs) and static_cast<bool> (rhs) }
1207 [[nodiscard]]
constexpr
1208 operator bool ()
const
1225 [[nodiscard]]
constexpr auto
1243 [[nodiscard]]
constexpr auto
1266 template <
typename Lhs_T,
typename Rhs_T>
1295 template <
class Lhs_T,
class Rhs_T>
1309 constexpr or_ (
const Lhs_T&
lhs = {},
const Rhs_T& rhs = {})
1310 : lhs_{ lhs }, rhs_{ rhs },
1311 value_{ static_cast<bool> (lhs) or static_cast<bool> (rhs) }
1326 [[nodiscard]]
constexpr
1327 operator bool ()
const
1344 [[nodiscard]]
constexpr auto
1362 [[nodiscard]]
constexpr auto
1385 template <
typename Lhs_T,
typename Rhs_T>
1426 explicit constexpr not_ (
const T& t = {})
1427 : t_{ t }, value_{ not static_cast<bool> (t) }
1442 [[nodiscard]]
constexpr
1443 operator bool ()
const
1459 [[nodiscard]]
constexpr auto
1477 template <
typename T>
1482#if defined(__cpp_exceptions)
1510 template <
class Callable_T,
class Exception_T =
void>
1524 constexpr explicit throws_ (
const Callable_T& func)
1530 catch (
const Exception_T&)
1555 [[nodiscard]]
constexpr
1556 operator bool ()
const
1593 template <
class Callable_T>
1607 constexpr explicit throws_ (
const Callable_T& func)
1633 [[nodiscard]]
constexpr
1634 operator bool ()
const
1671 template <
class Callable_T>
1710 [[nodiscard]]
constexpr
1711 operator bool ()
const
1771 operator<< (
const T& msg);
1785 [[nodiscard]]
constexpr bool
1835 template <
class Expr_T>
1852 const Expr_T& expr,
bool abort,
1873#if defined(__GNUC__)
1874#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.