16#ifndef MICRO_TEST_PLUS_DETAIL_H_
17#define MICRO_TEST_PLUS_DETAIL_H_
30#pragma GCC diagnostic push
31#pragma GCC diagnostic ignored "-Wpadded"
32#pragma GCC diagnostic ignored "-Waggregate-return"
34#pragma clang diagnostic ignored "-Wc++98-compat"
51 template <
class Expr_T>
66 [[nodiscard]]
constexpr auto
67 get_impl (
const T& t,
int) ->
decltype (t.get ())
77 [[nodiscard]]
constexpr auto
87 [[nodiscard]]
constexpr auto
100 template <
class Lhs_T,
class Rhs_T>
103 constexpr eq_ (
const Lhs_T&
lhs = {},
const Rhs_T&
rhs = {})
107 using std::operator==;
108 using std::operator<;
111#pragma GCC diagnostic push
112#pragma GCC diagnostic ignored "-Wfloat-equal"
113#pragma GCC diagnostic ignored "-Wconversion"
114#pragma GCC diagnostic ignored "-Wdouble-promotion"
115#pragma GCC diagnostic ignored "-Wsign-compare"
116#if defined(__clang__)
117#pragma clang diagnostic ignored "-Wimplicit-int-float-conversion"
118#pragma clang diagnostic ignored "-Wpedantic"
126 return Lhs_T::value == Rhs_T::value;
153#pragma GCC diagnostic pop
159 [[nodiscard]]
constexpr
160 operator bool ()
const
165 [[nodiscard]]
constexpr auto
171 [[nodiscard]]
constexpr auto
186 template <
class Lhs_T,
class Rhs_T>
189 constexpr ne_ (
const Lhs_T&
lhs = {},
const Rhs_T& rhs = {})
190 : lhs_{ lhs }, rhs_{ rhs }, value_{ [&] {
191 using std::operator==;
192 using std::operator!=;
193 using std::operator>;
196#pragma GCC diagnostic push
197#pragma GCC diagnostic ignored "-Wfloat-equal"
198#pragma GCC diagnostic ignored "-Wconversion"
199#pragma GCC diagnostic ignored "-Wdouble-promotion"
200#pragma GCC diagnostic ignored "-Wsign-compare"
201#if defined(__clang__)
202#pragma clang diagnostic ignored "-Wimplicit-int-float-conversion"
203#pragma clang diagnostic ignored "-Wpedantic"
209 return Lhs_T::value != Rhs_T::value;
211 else if constexpr (type_traits::has_epsilon_v<Lhs_T>
212 and type_traits::has_epsilon_v<Rhs_T>)
214 return math::abs (get (lhs_) - get (rhs_))
215 > math::min_value (Lhs_T::epsilon, Rhs_T::epsilon);
217 else if constexpr (type_traits::has_epsilon_v<Lhs_T>)
219 return math::abs (get (lhs_) - get (rhs_)) > Lhs_T::epsilon;
221 else if constexpr (type_traits::has_epsilon_v<Rhs_T>)
223 return math::abs (get (lhs_) - get (rhs_)) > Rhs_T::epsilon;
227 return get (lhs_) !=
get (rhs_);
230#pragma GCC diagnostic pop
236 [[nodiscard]]
constexpr
237 operator bool ()
const
241 [[nodiscard]]
constexpr auto
246 [[nodiscard]]
constexpr auto
261 template <
class Lhs_T,
class Rhs_T>
264 constexpr gt_ (
const Lhs_T&
lhs = {},
const Rhs_T& rhs = {})
265 : lhs_{ lhs }, rhs_{ rhs }, value_{ [&] {
266 using std::operator>;
269#pragma GCC diagnostic push
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;
285 return get (lhs_) > get (rhs_);
288#pragma GCC diagnostic pop
294 [[nodiscard]]
constexpr
295 operator bool ()
const
299 [[nodiscard]]
constexpr auto
304 [[nodiscard]]
constexpr auto
319 template <
class Lhs_T,
class Rhs_T>
322 constexpr ge_ (
const Lhs_T&
lhs = {},
const Rhs_T& rhs = {})
323 : lhs_{ lhs }, rhs_{ rhs }, value_{ [&] {
324 using std::operator>=;
327#pragma GCC diagnostic push
328#pragma GCC diagnostic ignored "-Wconversion"
329#pragma GCC diagnostic ignored "-Wdouble-promotion"
330#pragma GCC diagnostic ignored "-Wsign-compare"
331#if defined(__clang__)
332#pragma clang diagnostic ignored "-Wimplicit-int-float-conversion"
333#pragma clang diagnostic ignored "-Wpedantic"
339 return Lhs_T::value >= Rhs_T::value;
343 return get (lhs_) >= get (rhs_);
346#pragma GCC diagnostic pop
352 [[nodiscard]]
constexpr
353 operator bool ()
const
357 [[nodiscard]]
constexpr auto
362 [[nodiscard]]
constexpr auto
377 template <
class Lhs_T,
class Rhs_T>
380 constexpr lt_ (
const Lhs_T&
lhs = {},
const Rhs_T& rhs = {})
381 : lhs_{ lhs }, rhs_{ rhs }, value_{ [&] {
382 using std::operator<;
385#pragma GCC diagnostic push
386#pragma GCC diagnostic ignored "-Wconversion"
387#pragma GCC diagnostic ignored "-Wdouble-promotion"
388#pragma GCC diagnostic ignored "-Wsign-compare"
389#if defined(__clang__)
390#pragma clang diagnostic ignored "-Wimplicit-int-float-conversion"
391#pragma clang diagnostic ignored "-Wpedantic"
397 return Lhs_T::value < Rhs_T::value;
401 return get (lhs_) < get (rhs_);
404#pragma GCC diagnostic pop
410 [[nodiscard]]
constexpr
411 operator bool ()
const
415 [[nodiscard]]
constexpr auto
420 [[nodiscard]]
constexpr auto
436 template <
class Lhs_T,
class Rhs_T>
439 constexpr le_ (
const Lhs_T&
lhs = {},
const Rhs_T& rhs = {})
440 : lhs_{ lhs }, rhs_{ rhs }, value_{ [&] {
441 using std::operator<=;
444#pragma GCC diagnostic push
445#pragma GCC diagnostic ignored "-Wconversion"
446#pragma GCC diagnostic ignored "-Wdouble-promotion"
447#pragma GCC diagnostic ignored "-Wsign-compare"
448#if defined(__clang__)
449#pragma clang diagnostic ignored "-Wimplicit-int-float-conversion"
450#pragma clang diagnostic ignored "-Wpedantic"
456 return Lhs_T::value <= Rhs_T::value;
460 return get (lhs_) <= get (rhs_);
463#pragma GCC diagnostic pop
469 [[nodiscard]]
constexpr
470 operator bool ()
const
475 [[nodiscard]]
constexpr auto
481 [[nodiscard]]
constexpr auto
496 template <
class Lhs_T,
class Rhs_T>
499 constexpr and_ (
const Lhs_T&
lhs = {},
const Rhs_T& rhs = {})
500 : lhs_{ lhs }, rhs_{ rhs },
501 value_{ static_cast<bool> (lhs) and static_cast<bool> (rhs) }
505 [[nodiscard]]
constexpr
506 operator bool ()
const
511 [[nodiscard]]
constexpr auto
517 [[nodiscard]]
constexpr auto
532 template <
class Lhs_T,
class Rhs_T>
535 constexpr or_ (
const Lhs_T&
lhs = {},
const Rhs_T& rhs = {})
536 : lhs_{ lhs }, rhs_{ rhs },
537 value_{ static_cast<bool> (lhs) or static_cast<bool> (rhs) }
541 [[nodiscard]]
constexpr
542 operator bool ()
const
547 [[nodiscard]]
constexpr auto
553 [[nodiscard]]
constexpr auto
571 explicit constexpr not_ (
const T& t = {})
572 : t_{ t }, value_{ not static_cast<bool> (t) }
576 [[nodiscard]]
constexpr
577 operator bool ()
const
582 [[nodiscard]]
constexpr auto
592#if defined(__cpp_exceptions)
597 template <
class Callable_T,
class Exception_T =
void>
600 constexpr explicit throws_ (
const Callable_T& func)
606 catch (
const Exception_T&)
619 [[nodiscard]]
constexpr
620 operator bool ()
const
632 template <
class Callable_T>
635 constexpr explicit throws_ (
const Callable_T& func)
650 [[nodiscard]]
constexpr
651 operator bool ()
const
663 template <
class Callable_T>
666 constexpr explicit nothrow_ (
const Callable_T& func)
681 [[nodiscard]]
constexpr
682 operator bool ()
const
708 operator<< (
const T& msg);
710 [[nodiscard]]
constexpr bool
733 template <
class Expr_T>
738 const Expr_T& expr,
bool abort,
754#pragma GCC diagnostic pop
const reflection::source_location location_
constexpr bool value() const
std::string message_
String to collect the expectation message passed via operator<<().
deferred_reporter_base(bool value, const reflection::source_location location)
constexpr deferred_reporter(const Expr_T &expr, bool abort, const reflection::source_location &location)
Local implementation of the std::source_location.
Namespace with implementation details, not part of the public API.
constexpr auto get_impl(const T &t, int) -> decltype(t.get())
Generic getter implementation. If the type has a get() method, call it. It is recommended for custom ...
constexpr auto get(const T &t)
Generic getter, calling the getter implementation.
constexpr auto abs(const T t) -> T
Generic absolute of any value.
constexpr auto min_value(const T &lhs, const T &rhs) -> const T &
Generic minimum of two values.
static constexpr auto has_epsilon_v
static constexpr auto has_value_v
constexpr auto lhs() const
constexpr and_(const Lhs_T &lhs={}, const Rhs_T &rhs={})
constexpr auto rhs() const
An object used to pass assertion parameters to the evaluator.
reflection::source_location location
constexpr auto rhs() const
constexpr eq_(const Lhs_T &lhs={}, const Rhs_T &rhs={})
constexpr auto lhs() const
constexpr auto rhs() const
constexpr ge_(const Lhs_T &lhs={}, const Rhs_T &rhs={})
constexpr auto lhs() const
constexpr gt_(const Lhs_T &lhs={}, const Rhs_T &rhs={})
constexpr auto rhs() const
constexpr auto lhs() const
constexpr auto lhs() const
constexpr auto rhs() const
constexpr le_(const Lhs_T &lhs={}, const Rhs_T &rhs={})
constexpr auto rhs() const
constexpr auto lhs() const
constexpr lt_(const Lhs_T &lhs={}, const Rhs_T &rhs={})
constexpr ne_(const Lhs_T &lhs={}, const Rhs_T &rhs={})
constexpr auto lhs() const
constexpr auto rhs() const
constexpr auto value() const
constexpr not_(const T &t={})
constexpr nothrow_(const Callable_T &func)
constexpr auto lhs() const
constexpr auto rhs() const
constexpr or_(const Lhs_T &lhs={}, const Rhs_T &rhs={})
constexpr throws_(const Callable_T &func)
constexpr throws_(const Callable_T &func)
Empty base class of all operators.