[Cppunit-devel] assertion_traits<double> must be removed
Brought to you by:
blep
From: CppUnit d. m. l. <cpp...@li...> - 2006-11-16 06:10:42
|
Hello, The macro CPPUNIT_ASSERT_EQUAL uses a templated traits class, CppUnit::assertion_traits<T> with member function equals() to test for =20 equality. For the generic case, equals() is defined using operator=3D=3D(), 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 functio= n 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 =20 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. Baptiste? -Steve |