micro-test-plus 5.0.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.

Private 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 comparison.

Detailed Description

template<class Lhs_T, class Rhs_T>
struct micro_os_plus::micro_test_plus::detail::ne_< Lhs_T, Rhs_T >

Derived from binary_op_, this struct checks whether the left-hand operand is not equal to the right-hand operand. It is used within test expressions to provide human-readable inequality assertions with enhanced reporting of the actual and expected values upon failure.

Template Parameters
Lhs_TThe type of the left-hand operand.
Rhs_TThe type of the right-hand operand.

Definition at line 346 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 = {} )
constexpr
Parameters
lhsThe left-hand operand.
rhsThe right-hand operand.

Evaluates the non-equality of lhs and rhs inside an immediately invoked lambda and passes the boolean result to the binary_op_ base class constructor. Supports types with static value members, types with an epsilon precision member, and generic types.

Definition at line 264 of file detail-inlines.h.

266 {
267 using std::operator==;
268 using std::operator!=;
269 using std::operator>;
270
271#if defined(__GNUC__)
272#pragma GCC diagnostic push
273
274#pragma GCC diagnostic ignored "-Wfloat-equal"
275#pragma GCC diagnostic ignored "-Wconversion"
276#pragma GCC diagnostic ignored "-Wdouble-promotion"
277#pragma GCC diagnostic ignored "-Wsign-compare"
278#if defined(__clang__)
279#pragma clang diagnostic ignored "-Wimplicit-int-float-conversion"
280#pragma clang diagnostic ignored "-Wpedantic"
281#endif // defined(__clang__)
282#endif // defined(__GNUC__)
283
286 {
287 return Lhs_T::value != Rhs_T::value;
288 }
289 else if constexpr (type_traits::has_epsilon<Lhs_T>
291 {
292 return math::abs (get (lhs) - get (rhs))
293 >= math::min_value (lhs.epsilon, rhs.epsilon);
294 }
295 else if constexpr (type_traits::has_epsilon<Lhs_T>)
296 {
297 return math::abs (get (lhs) - get (rhs)) >= lhs.epsilon;
298 }
299 else if constexpr (type_traits::has_epsilon<Rhs_T>)
300 {
301 return math::abs (get (lhs) - get (rhs)) >= rhs.epsilon;
302 }
303 else
304 {
305 return get (lhs) != get (rhs);
306 }
307
308#if defined(__GNUC__)
309#pragma GCC diagnostic pop
310#endif // defined(__GNUC__)
311 }() }
312 {
313 }
constexpr auto get(const T &t)
Generic getter function template for value retrieval.
constexpr auto min_value(const T &lhs, const T &rhs) noexcept -> const T &
Computes the minimum of two comparable values.
constexpr auto abs(const T t) noexcept -> T
Computes the absolute value of a given comparable value.
constexpr auto lhs(void) const
Retrieves the left-hand operand.
constexpr binary_op_(const Lhs_T &lhs, const Rhs_T &rhs, bool value)
Constructs a binary comparator with the given operands and pre-computed result.
constexpr auto rhs(void) const
Retrieves the right-hand operand.
Non-equality comparator struct template.
Definition detail.h:347

References micro_os_plus::micro_test_plus::detail::binary_op_< Lhs_T, Rhs_T >::binary_op_(), micro_os_plus::micro_test_plus::math::abs(), micro_os_plus::micro_test_plus::detail::get(), micro_os_plus::micro_test_plus::detail::binary_op_< Lhs_T, Rhs_T >::lhs(), micro_os_plus::micro_test_plus::math::min_value(), and micro_os_plus::micro_test_plus::detail::binary_op_< Lhs_T, Rhs_T >::rhs().

Member Function Documentation

◆ lhs()

template<class Lhs_T, class Rhs_T>
auto micro_os_plus::micro_test_plus::detail::binary_op_< Lhs_T, Rhs_T >::lhs ( void ) const
nodiscardconstexprinherited
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 163 of file detail-inlines.h.

164 {
165 return get (lhs_);
166 }
const Lhs_T lhs_
Stores the left-hand operand.
Definition detail.h:281

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

Referenced by micro_os_plus::micro_test_plus::detail::and_< Lhs_T, Rhs_T >::and_(), binary_op_(), micro_os_plus::micro_test_plus::detail::eq_< Lhs_T, Rhs_T >::eq_(), micro_os_plus::micro_test_plus::detail::ge_< Lhs_T, Rhs_T >::ge_(), micro_os_plus::micro_test_plus::detail::gt_< Lhs_T, Rhs_T >::gt_(), micro_os_plus::micro_test_plus::detail::le_< Lhs_T, Rhs_T >::le_(), micro_os_plus::micro_test_plus::detail::lt_< Lhs_T, Rhs_T >::lt_(), micro_os_plus::micro_test_plus::detail::ne_< Lhs_T, Rhs_T >::ne_(), micro_os_plus::micro_test_plus::detail::or_< Lhs_T, Rhs_T >::or_(), micro_os_plus::micro_test_plus::detail::expression_formatter::operator<<(), micro_os_plus::micro_test_plus::detail::expression_formatter::operator<<(), micro_os_plus::micro_test_plus::detail::expression_formatter::operator<<(), micro_os_plus::micro_test_plus::detail::expression_formatter::operator<<(), micro_os_plus::micro_test_plus::detail::expression_formatter::operator<<(), micro_os_plus::micro_test_plus::detail::expression_formatter::operator<<(), micro_os_plus::micro_test_plus::detail::expression_formatter::operator<<(), and micro_os_plus::micro_test_plus::detail::expression_formatter::operator<<().

◆ operator bool()

template<class Lhs_T, class Rhs_T>
micro_os_plus::micro_test_plus::detail::binary_op_< Lhs_T, Rhs_T >::operator bool ( ) const
nodiscardconstexprinherited
Parameters
None.
Returns
The result of the comparison.

Returns the pre-computed boolean result stored by the derived comparator's constructor.

Definition at line 149 of file detail-inlines.h.

151 {
152 return value_;
153 }
const bool value_
Stores the result of the comparison.
Definition detail.h:294

References binary_op_(), and value_.

◆ rhs()

template<class Lhs_T, class Rhs_T>
auto micro_os_plus::micro_test_plus::detail::binary_op_< Lhs_T, Rhs_T >::rhs ( void ) const
nodiscardconstexprinherited
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 176 of file detail-inlines.h.

177 {
178 return get (rhs_);
179 }
const Rhs_T rhs_
Stores the right-hand operand.
Definition detail.h:289

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

Referenced by micro_os_plus::micro_test_plus::detail::and_< Lhs_T, Rhs_T >::and_(), binary_op_(), micro_os_plus::micro_test_plus::detail::eq_< Lhs_T, Rhs_T >::eq_(), micro_os_plus::micro_test_plus::detail::ge_< Lhs_T, Rhs_T >::ge_(), micro_os_plus::micro_test_plus::detail::gt_< Lhs_T, Rhs_T >::gt_(), micro_os_plus::micro_test_plus::detail::le_< Lhs_T, Rhs_T >::le_(), micro_os_plus::micro_test_plus::detail::lt_< Lhs_T, Rhs_T >::lt_(), micro_os_plus::micro_test_plus::detail::ne_< Lhs_T, Rhs_T >::ne_(), micro_os_plus::micro_test_plus::detail::or_< Lhs_T, Rhs_T >::or_(), micro_os_plus::micro_test_plus::detail::expression_formatter::operator<<(), micro_os_plus::micro_test_plus::detail::expression_formatter::operator<<(), micro_os_plus::micro_test_plus::detail::expression_formatter::operator<<(), micro_os_plus::micro_test_plus::detail::expression_formatter::operator<<(), micro_os_plus::micro_test_plus::detail::expression_formatter::operator<<(), micro_os_plus::micro_test_plus::detail::expression_formatter::operator<<(), micro_os_plus::micro_test_plus::detail::expression_formatter::operator<<(), and micro_os_plus::micro_test_plus::detail::expression_formatter::operator<<().

Member Data Documentation

◆ lhs_

template<class Lhs_T, class Rhs_T>
const Lhs_T micro_os_plus::micro_test_plus::detail::binary_op_< Lhs_T, Rhs_T >::lhs_ {}
privateinherited
Note
Operands are stored by value; passing a large container will copy it into this member.

Definition at line 281 of file detail.h.

281{};

Referenced by binary_op_(), and lhs().

◆ rhs_

template<class Lhs_T, class Rhs_T>
const Rhs_T micro_os_plus::micro_test_plus::detail::binary_op_< Lhs_T, Rhs_T >::rhs_ {}
privateinherited
Note
Operands are stored by value; passing a large container will copy it into this member.

Definition at line 289 of file detail.h.

289{};

Referenced by binary_op_(), and rhs().

◆ value_

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

Definition at line 294 of file detail.h.

294{};

Referenced by binary_op_(), and operator bool().


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