diff options
| author | Baptiste Lepilleur <gaiacrtn@free.fr> | 2007-02-24 20:13:04 +0000 |
|---|---|---|
| committer | Baptiste Lepilleur <gaiacrtn@free.fr> | 2007-02-24 20:13:04 +0000 |
| commit | 0d30a2aec28085cfb9fe359c321c289609b884ca (patch) | |
| tree | d5848b1cb981a9fa5ba351b5eb01e4a0e06e1cf8 /include/cppunit/TestAssert.h | |
| parent | 3ca9c5d071cb8162c89fd514a6116ee6b450d763 (diff) | |
| download | cppunit-0d30a2aec28085cfb9fe359c321c289609b884ca.tar.gz | |
Src/cppunit/TestAssert.
src/cppunit/TestAssert.cpp (assertDoubleEquals): Moved finite & NaN
tests to include/cppunit/portability/FloatingPoint.h. Changed
implementation assertDoubleEquals to explicitly test for NaN
in case of non-finite values to force equality failure in the
presence of NaN. Previous implementation failed on Microsoft
Visual Studio 6 (on this platform: NaN == NaN).
* examples/cppunittest/TestAssertTest.cpp: Add more unit tests to
test the portable floating-point primitive. Added missing
include <limits>.
* include/cppunit/portability/Makefile.am:
* include/cppunit/portability/FloatingPoint.h: Added file. Extracted
isfinite() from TestAssert.cpp.
* include/cppunit/config-evc4:
* include/cppunit/config-msvc6: Added support for _finite().
Diffstat (limited to 'include/cppunit/TestAssert.h')
| -rw-r--r-- | include/cppunit/TestAssert.h | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/include/cppunit/TestAssert.h b/include/cppunit/TestAssert.h index 07783a2..f74797b 100644 --- a/include/cppunit/TestAssert.h +++ b/include/cppunit/TestAssert.h @@ -109,6 +109,7 @@ void assertEquals( const T& expected, /*! \brief (Implementation) Asserts that two double are equals given a tolerance. * Use CPPUNIT_ASSERT_DOUBLES_EQUAL instead of this function. * \sa Asserter::failNotEqual(). + * \sa CPPUNIT_ASSERT_DOUBLES_EQUAL for detailed semantic of the assertion. */ void CPPUNIT_API assertDoubleEquals( double expected, double actual, @@ -218,6 +219,13 @@ void CPPUNIT_API assertDoubleEquals( double expected, /*! \brief Macro for primitive double value comparisons. * \ingroup Assertions + * + * The assertion pass if both expected and actual are finite and + * \c fabs( \c expected - \c actual ) <= \c delta. + * If either \c expected or actual are infinite (+/- inf), the + * assertion pass if \c expected == \c actual. + * If either \c expected or \c actual is a NaN (not a number), then + * the assertion fails. */ #define CPPUNIT_ASSERT_DOUBLES_EQUAL(expected,actual,delta) \ ( CPPUNIT_NS::assertDoubleEquals( (expected), \ @@ -230,6 +238,7 @@ void CPPUNIT_API assertDoubleEquals( double expected, /*! \brief Macro for primitive double value comparisons, setting a * user-supplied message in case of failure. * \ingroup Assertions + * \sa CPPUNIT_ASSERT_DOUBLES_EQUAL for detailed semantic of the assertion. */ #define CPPUNIT_ASSERT_DOUBLES_EQUAL_MESSAGE(message,expected,actual,delta) \ ( CPPUNIT_NS::assertDoubleEquals( (expected), \ |
