[Cppunit-cvs] cppunit/src/cppunit TestAssert.cpp,1.12,1.13
Brought to you by:
blep
From: Steven R. <sm...@us...> - 2007-01-27 05:45:13
|
Update of /cvsroot/cppunit/cppunit/src/cppunit In directory sc8-pr-cvs4.sourceforge.net:/tmp/cvs-serv12622/src/cppunit Modified Files: TestAssert.cpp Log Message: Account for non-finite values in assertDoubleEquals(). Conditional inclusion of cmath rather than math.h removed since (1) it was never used as HAVE_CMATH is never defined, and (2) cmath may move isfinite() into namespace std. Index: TestAssert.cpp =================================================================== RCS file: /cvsroot/cppunit/cppunit/src/cppunit/TestAssert.cpp,v retrieving revision 1.12 retrieving revision 1.13 diff -C2 -d -r1.12 -r1.13 *** TestAssert.cpp 5 Nov 2004 22:47:20 -0000 1.12 --- TestAssert.cpp 27 Jan 2007 05:45:08 -0000 1.13 *************** *** 1,10 **** ! #if HAVE_CMATH ! # include <cmath> #else ! # include <math.h> #endif ! #include <cppunit/TestAssert.h> ! CPPUNIT_NS_BEGIN --- 1,18 ---- ! #include <cppunit/TestAssert.h> ! ! #include <math.h> ! ! #if !defined(CPPUNIT_HAVE_ISFINITE) ! ! static inline bool isfinite( double x ) ! { ! #if defined(CPPUNIT_HAVE_FINITE) ! return finite( x ); #else ! return ( x * 0.0 ) == 0.0; #endif + } ! #endif CPPUNIT_NS_BEGIN *************** *** 22,26 **** msg.addDetail( AdditionalMessage(message) ); ! Asserter::failNotEqualIf( fabs( expected - actual ) > delta, assertion_traits<double>::toString(expected), assertion_traits<double>::toString(actual), --- 30,40 ---- msg.addDetail( AdditionalMessage(message) ); ! bool equal; ! if ( isfinite(expected) && isfinite(actual) ) ! equal = fabs( expected - actual ) <= delta; ! else ! equal = expected == actual; ! ! Asserter::failNotEqualIf( !equal, assertion_traits<double>::toString(expected), assertion_traits<double>::toString(actual), |