Skip to content

Equality test should not require arguments to be orderable #163

Closed
@jgfoster

Description

@jgfoster

cpp/unittest/Compare.h: 13 and 14 seem to test equality in terms of ordering. I'd like to be able to compare two objects that understand equality without implying an order ("Is Adam < Eve?").

/Users/jfoster/code/Arduino/LiquidCrystal/vendor/bundle/ruby/2.6.0/gems/arduino_ci-0.3.0/cpp/unittest/Compare.h:13:71: error: invalid operands to binary expression ('const BitCollector' and 'const std::__1::vector<int, std::__1::allocator<int> >')
  inline static bool equal(const A &a,const B &b)       { return (!(a < b)) && (!(b < a)); }
                                                                    ~ ^ ~
/Users/jfoster/code/Arduino/LiquidCrystal/vendor/bundle/ruby/2.6.0/gems/arduino_ci-0.3.0/cpp/unittest/Compare.h:107:107: note: in instantiation of member function 'Compare<BitCollector, std::__1::vector<int, std::__1::allocator<int> > >::equal' requested here
template <typename A, typename B> bool compareEqual(      const A &a, const B &b) { return Compare<A, B>::equal(      a, b); }
                                                                                                          ^
/Users/jfoster/code/Arduino/LiquidCrystal/test/Common.cpp:143:3: note: in instantiation of function template specialization 'compareEqual<BitCollector, std::__1::vector<int, std::__1::allocator<int> > >' requested here
  assertEqual(pinValues, expected);
  ^

In particular, I'd like to implement operator==() in my subclass of DataStreamObserver so that I can encapsulate the comparison and not have to do it in every test. The work-around isn't too hard, but this seems like an unnecessary limitation.

Metadata

Metadata

Assignees

No one assigned

    Labels

    help wantedExtra attention is neededquestionFurther information is requestedunittest libsThe assert / assure / unittest reporting apparatus is affected

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions