Skip to content

Commit

Permalink
re-format
Browse files Browse the repository at this point in the history
  • Loading branch information
ilg-ul committed Nov 21, 2023
1 parent 4315e9c commit b7f2791
Show file tree
Hide file tree
Showing 9 changed files with 164 additions and 121 deletions.
78 changes: 44 additions & 34 deletions include/micro-os-plus/detail.h
Original file line number Diff line number Diff line change
Expand Up @@ -117,16 +117,15 @@ namespace micro_os_plus::micro_test_plus
#pragma clang diagnostic ignored "-Wpedantic"
#endif
#endif
if constexpr (type_traits::has_value_v<
Lhs_T> and type_traits::has_value_v<Rhs_T>)
if constexpr (type_traits::has_value_v<Lhs_T>
and type_traits::has_value_v<Rhs_T>)
{
// If both types have values (like numeric constants),
// compare them directly.
return Lhs_T::value == Rhs_T::value;
}
else if constexpr (
type_traits::has_epsilon_v<
Lhs_T> and type_traits::has_epsilon_v<Rhs_T>)
else if constexpr (type_traits::has_epsilon_v<Lhs_T>
and type_traits::has_epsilon_v<Rhs_T>)
{
// If both values have precision, compare them using
// the smalles precision.
Expand Down Expand Up @@ -156,7 +155,8 @@ namespace micro_os_plus::micro_test_plus
{
}

[[nodiscard]] constexpr operator bool () const
[[nodiscard]] constexpr
operator bool () const
{
return value_;
}
Expand Down Expand Up @@ -201,14 +201,13 @@ namespace micro_os_plus::micro_test_plus
#pragma clang diagnostic ignored "-Wpedantic"
#endif
#endif
if constexpr (type_traits::has_value_v<
Lhs_T> and type_traits::has_value_v<Rhs_T>)
if constexpr (type_traits::has_value_v<Lhs_T>
and type_traits::has_value_v<Rhs_T>)
{
return Lhs_T::value != Rhs_T::value;
}
else if constexpr (
type_traits::has_epsilon_v<
Lhs_T> and type_traits::has_epsilon_v<Rhs_T>)
else if constexpr (type_traits::has_epsilon_v<Lhs_T>
and type_traits::has_epsilon_v<Rhs_T>)
{
return math::abs (get (lhs_) - get (rhs_))
> math::min_value (Lhs_T::epsilon, Rhs_T::epsilon);
Expand All @@ -232,7 +231,8 @@ namespace micro_os_plus::micro_test_plus
{
}

[[nodiscard]] constexpr operator bool () const
[[nodiscard]] constexpr
operator bool () const
{
return value_;
}
Expand Down Expand Up @@ -272,8 +272,8 @@ namespace micro_os_plus::micro_test_plus
#pragma clang diagnostic ignored "-Wpedantic"
#endif
#endif
if constexpr (type_traits::has_value_v<
Lhs_T> and type_traits::has_value_v<Rhs_T>)
if constexpr (type_traits::has_value_v<Lhs_T>
and type_traits::has_value_v<Rhs_T>)
{
return Lhs_T::value > Rhs_T::value;
}
Expand All @@ -288,7 +288,8 @@ namespace micro_os_plus::micro_test_plus
{
}

[[nodiscard]] constexpr operator bool () const
[[nodiscard]] constexpr
operator bool () const
{
return value_;
}
Expand Down Expand Up @@ -328,8 +329,8 @@ namespace micro_os_plus::micro_test_plus
#pragma clang diagnostic ignored "-Wpedantic"
#endif
#endif
if constexpr (type_traits::has_value_v<
Lhs_T> and type_traits::has_value_v<Rhs_T>)
if constexpr (type_traits::has_value_v<Lhs_T>
and type_traits::has_value_v<Rhs_T>)
{
return Lhs_T::value >= Rhs_T::value;
}
Expand All @@ -344,7 +345,8 @@ namespace micro_os_plus::micro_test_plus
{
}

[[nodiscard]] constexpr operator bool () const
[[nodiscard]] constexpr
operator bool () const
{
return value_;
}
Expand Down Expand Up @@ -384,8 +386,8 @@ namespace micro_os_plus::micro_test_plus
#pragma clang diagnostic ignored "-Wpedantic"
#endif
#endif
if constexpr (type_traits::has_value_v<
Lhs_T> and type_traits::has_value_v<Rhs_T>)
if constexpr (type_traits::has_value_v<Lhs_T>
and type_traits::has_value_v<Rhs_T>)
{
return Lhs_T::value < Rhs_T::value;
}
Expand All @@ -400,7 +402,8 @@ namespace micro_os_plus::micro_test_plus
{
}

[[nodiscard]] constexpr operator bool () const
[[nodiscard]] constexpr
operator bool () const
{
return value_;
}
Expand Down Expand Up @@ -441,8 +444,8 @@ namespace micro_os_plus::micro_test_plus
#pragma clang diagnostic ignored "-Wpedantic"
#endif
#endif
if constexpr (type_traits::has_value_v<
Lhs_T> and type_traits::has_value_v<Rhs_T>)
if constexpr (type_traits::has_value_v<Lhs_T>
and type_traits::has_value_v<Rhs_T>)
{
return Lhs_T::value <= Rhs_T::value;
}
Expand All @@ -457,7 +460,8 @@ namespace micro_os_plus::micro_test_plus
{
}

[[nodiscard]] constexpr operator bool () const
[[nodiscard]] constexpr
operator bool () const
{
return value_;
}
Expand Down Expand Up @@ -486,12 +490,13 @@ namespace micro_os_plus::micro_test_plus
struct and_ : type_traits::op
{
constexpr and_ (const Lhs_T& lhs = {}, const Rhs_T& rhs = {})
: lhs_{ lhs }, rhs_{ rhs }, value_{ static_cast<bool> (lhs)
and static_cast<bool> (rhs) }
: lhs_{ lhs }, rhs_{ rhs },
value_{ static_cast<bool> (lhs) and static_cast<bool> (rhs) }
{
}

[[nodiscard]] constexpr operator bool () const
[[nodiscard]] constexpr
operator bool () const
{
return value_;
}
Expand Down Expand Up @@ -520,12 +525,13 @@ namespace micro_os_plus::micro_test_plus
struct or_ : type_traits::op
{
constexpr or_ (const Lhs_T& lhs = {}, const Rhs_T& rhs = {})
: lhs_{ lhs }, rhs_{ rhs }, value_{ static_cast<bool> (lhs)
or static_cast<bool> (rhs) }
: lhs_{ lhs }, rhs_{ rhs },
value_{ static_cast<bool> (lhs) or static_cast<bool> (rhs) }
{
}

[[nodiscard]] constexpr operator bool () const
[[nodiscard]] constexpr
operator bool () const
{
return value_;
}
Expand Down Expand Up @@ -558,7 +564,8 @@ namespace micro_os_plus::micro_test_plus
{
}

[[nodiscard]] constexpr operator bool () const
[[nodiscard]] constexpr
operator bool () const
{
return value_;
}
Expand Down Expand Up @@ -599,7 +606,8 @@ namespace micro_os_plus::micro_test_plus
{
}

[[nodiscard]] constexpr operator bool () const
[[nodiscard]] constexpr
operator bool () const
{
return value_;
}
Expand Down Expand Up @@ -628,7 +636,8 @@ namespace micro_os_plus::micro_test_plus
{
}

[[nodiscard]] constexpr operator bool () const
[[nodiscard]] constexpr
operator bool () const
{
return value_;
}
Expand Down Expand Up @@ -657,7 +666,8 @@ namespace micro_os_plus::micro_test_plus
{
}

[[nodiscard]] constexpr operator bool () const
[[nodiscard]] constexpr
operator bool () const
{
return value_;
}
Expand Down
13 changes: 6 additions & 7 deletions include/micro-os-plus/inlines.h
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,8 @@ namespace micro_os_plus::micro_test_plus
template <typename Callable_T, typename... Args_T>
test_suite::test_suite (const char* name, Callable_T&& callable,
Args_T&&... arguments)
: test_suite_base{ name }, callable_{ std::bind (callable,
arguments...) }
: test_suite_base{ name },
callable_{ std::bind (callable, arguments...) }
{
#if defined(MICRO_TEST_PLUS_TRACE)
printf ("%s\n", __PRETTY_FUNCTION__);
Expand All @@ -54,14 +54,14 @@ namespace micro_os_plus::micro_test_plus

template <typename Callable_T, typename... Args_T>
void
test_case (const char* name, Callable_T&& func, Args_T&&... arguments)
test_case (const char* name, Callable_T&& callable, Args_T&&... arguments)
{
#if 0 // defined(MICRO_TEST_PLUS_TRACE)
printf ("%s\n", __PRETTY_FUNCTION__);
#endif // MICRO_TEST_PLUS_TRACE

current_test_suite->begin_test_case (name);
std::invoke (std::forward<Callable_T> (func),
std::invoke (std::forward<Callable_T> (callable),
std::forward<Args_T> (arguments)...);
current_test_suite->end_test_case ();
}
Expand Down Expand Up @@ -92,9 +92,8 @@ namespace micro_os_plus::micro_test_plus
constexpr deferred_reporter<Expr_T>::deferred_reporter (
const Expr_T& expr, bool abort,
const reflection::source_location& location)
: deferred_reporter_base{ static_cast<bool> (expr), location }, expr_{
expr
}
: deferred_reporter_base{ static_cast<bool> (expr), location },
expr_{ expr }
{
#if 0 // defined(MICRO_TEST_PLUS_TRACE)
printf ("%s\n", __PRETTY_FUNCTION__);
Expand Down
Loading

0 comments on commit b7f2791

Please sign in to comment.