micro-test-plus 3.3.1
µTest++ Testing Framework
Loading...
Searching...
No Matches
micro_os_plus::micro_test_plus::detail::ne_< Lhs_T, Rhs_T > Struct Template Reference

Non-equality comparator struct template. More...

#include <micro-os-plus/micro-test-plus.h>

Inheritance diagram for micro_os_plus::micro_test_plus::detail::ne_< Lhs_T, Rhs_T >:

Public Member Functions

constexpr ne_ (const Lhs_T &lhs={}, const Rhs_T &rhs={})
 Constructs a non-equality comparator for the given operands.
constexpr auto lhs (void) const
 Retrieves the left-hand operand.
constexpr operator bool () const
 Conversion operator to boolean.
constexpr auto rhs (void) const
 Retrieves the right-hand operand.

Public Attributes

const Lhs_T lhs_ {}
 Stores the left-hand operand.
const Rhs_T rhs_ {}
 Stores the right-hand operand.
const bool value_ {}
 Stores the result of the non-equality comparison.

Detailed Description

template<class Lhs_T, class Rhs_T>
struct micro_os_plus::micro_test_plus::detail::ne_< Lhs_T, Rhs_T >
Template Parameters
Lhs_TThe type of the left-hand operand.
Rhs_TThe type of the right-hand operand.

The ne_ struct template provides a type-safe mechanism for evaluating non-equality between two operands within the framework.

This comparator supports a variety of operand types, including those with static values, types with precision (epsilon), and generic types. For types with static values, the comparison is performed directly. For types supporting precision, the comparison accounts for the smallest epsilon to ensure accuracy, particularly for floating-point types. For all other types, the generic getter is used to retrieve and compare the values.

The implementation is optimised for use in embedded environments and supports both compile-time and run-time evaluation.

All definitions are intended for internal use within the framework and are implemented in the include/micro-os-plus folder to maintain a structured and modular codebase.

Definition at line 437 of file detail.h.

Constructor & Destructor Documentation

◆ ne_()

template<class Lhs_T, class Rhs_T>
micro_os_plus::micro_test_plus::detail::ne_< Lhs_T, Rhs_T >::ne_ ( const Lhs_T & lhs = {},
const Rhs_T & rhs = {} )
inlineconstexpr
Parameters
lhsThe left-hand operand.
rhsThe right-hand operand.

Evaluates the non-equality of the provided operands at construction, supporting static values, types with precision, and generic types. The result is stored in the value_ member for efficient access.

Definition at line 450 of file detail.h.

450 {}, const Rhs_T& rhs = {})
451 : lhs_{ lhs }, rhs_{ rhs }, value_{
452 [&]
453 {
454 using std::operator==;
455 using std::operator!=;
456 using std::operator>;
457
458#if defined(__GNUC__)
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"
467#endif
468#endif
471 {
472 return Lhs_T::value != Rhs_T::value;
473 }
474 else if constexpr (type_traits::has_epsilon_v<Lhs_T>
476 {
477 return math::abs (get (lhs_) - get (rhs_))
480 }
481 else if constexpr (type_traits::has_epsilon_v<Lhs_T>)
482 {
483 return math::abs (get (lhs_) - get (rhs_))
485 }
486 else if constexpr (type_traits::has_epsilon_v<Rhs_T>)
487 {
488 return math::abs (get (lhs_) - get (rhs_))
490 }
491 else
492 {
493 return get (lhs_) != get (rhs_);
494 }
495#if defined(__GNUC__)
496#pragma GCC diagnostic pop
497#endif
498 }()
499 }
500 {
501 }
constexpr auto get(const T &t)
Generic getter function template for value retrieval.
Definition detail.h:223
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.
Non-equality comparator struct template.
Definition detail.h:438
const Rhs_T rhs_
Stores the right-hand operand.
Definition detail.h:564
constexpr auto rhs(void) const
Retrieves the right-hand operand.
Definition detail.h:551
constexpr auto lhs(void) const
Retrieves the left-hand operand.
Definition detail.h:533
const bool value_
Stores the result of the non-equality comparison.
Definition detail.h:569
const Lhs_T lhs_
Stores the left-hand operand.
Definition detail.h:559

References lhs().

Member Function Documentation

◆ lhs()

template<class Lhs_T, class Rhs_T>
auto micro_os_plus::micro_test_plus::detail::ne_< Lhs_T, Rhs_T >::lhs ( void ) const
inlinenodiscardconstexpr
Parameters
None.
Returns
The extracted left-hand operand.

Returns the value of the left-hand operand, applying the generic getter to ensure correct extraction for both custom and standard types.

Definition at line 533 of file detail.h.

534 {
535 return get (lhs_);
536 }

References micro_os_plus::micro_test_plus::detail::get(), and lhs_.

Referenced by ne_(), and micro_os_plus::micro_test_plus::test_reporter::operator<<().

◆ operator bool()

template<class Lhs_T, class Rhs_T>
micro_os_plus::micro_test_plus::detail::ne_< Lhs_T, Rhs_T >::operator bool ( ) const
inlinenodiscardconstexpr
Parameters
None.
Return values
trueThe operands are considered not equal.
falseThe operands are considered equal.

Returns the result of the non-equality comparison.

Definition at line 515 of file detail.h.

516 {
517 return value_;
518 }

References value_.

◆ rhs()

template<class Lhs_T, class Rhs_T>
auto micro_os_plus::micro_test_plus::detail::ne_< Lhs_T, Rhs_T >::rhs ( void ) const
inlinenodiscardconstexpr
Parameters
None.
Returns
The extracted right-hand operand.

Returns the value of the right-hand operand, applying the generic getter to ensure correct extraction for both custom and standard types.

Definition at line 551 of file detail.h.

552 {
553 return get (rhs_);
554 }

References micro_os_plus::micro_test_plus::detail::get(), and rhs_.

Referenced by micro_os_plus::micro_test_plus::test_reporter::operator<<().

Member Data Documentation

◆ lhs_

template<class Lhs_T, class Rhs_T>
const Lhs_T micro_os_plus::micro_test_plus::detail::ne_< Lhs_T, Rhs_T >::lhs_ {}

Definition at line 559 of file detail.h.

559{};

Referenced by lhs().

◆ rhs_

template<class Lhs_T, class Rhs_T>
const Rhs_T micro_os_plus::micro_test_plus::detail::ne_< Lhs_T, Rhs_T >::rhs_ {}

Definition at line 564 of file detail.h.

564{};

Referenced by rhs().

◆ value_

template<class Lhs_T, class Rhs_T>
const bool micro_os_plus::micro_test_plus::detail::ne_< Lhs_T, Rhs_T >::value_ {}

Definition at line 569 of file detail.h.

569{};

Referenced by operator bool().


The documentation for this struct was generated from the following file: