The macro CPPUNIT_ASSERT_EQUAL uses a templated traits class, CppUnit::assertion_traits<T>, with member function equals() to test for equality. For the generic case, equals() is defined using operator==(), which is reasonable for most types. Except for floating point. Thus the macro CPPUNIT_ASSERT_DOUBLES_EQUAL() is provided. This macro does *NOT* use assertion_traits<double>. Rather, it uses special logic embodied in function CppUnit::assertDoublesEquals().
Note that since there are no specializations of assertion_traits<> provided by CppUnit, the user is free to define their own. For example, I frequently specialize assertion_traits<double>, defining equals() using a global tolerance.
In revision 1.26 of include/cppunit/TestAssert.h, the specialization assertion_traits<double> was introduced. I propose that this is a mistake that should be reverted.
The main reason is that one can no longer define one's own specialization. Furthermore, contrary to the comment above it, assertion_traits<double> is *NOT* used by CPPUNIT_ASSERT_DOUBLES_EQUAL.
Logged In: YES
user_id=130415
Originator: YES
My proposed fix, as stated above, is to remove the assertion_traits<double> specialization from TestAssert.h.
However, this specialization is a useful thing to provide, for those who want it. I propose we move it to a cppunit/extensions file; e.g. <cppunit/extensions/assertion_traits_double.h>.