diff options
author | Steve M. Robbins <smr@sumost.ca> | 2007-01-27 04:46:30 +0000 |
---|---|---|
committer | Steve M. Robbins <smr@sumost.ca> | 2007-01-27 04:46:30 +0000 |
commit | 2ebab48667084132c42cb033e82b89a12c375e1c (patch) | |
tree | abaeba8b4fec341ceebc811adfc25f65e4f0bff5 /examples/cppunittest/TestAssertTest.cpp | |
parent | d55799b544efac8b1d822dfa8b0ea4813a2d3ef0 (diff) | |
download | cppunit-2ebab48667084132c42cb033e82b89a12c375e1c.tar.gz |
Add unit tests for CPPUNIT_ASSERT_DOUBLES_EQUAL() that test with
non-finite values.
Diffstat (limited to 'examples/cppunittest/TestAssertTest.cpp')
-rw-r--r-- | examples/cppunittest/TestAssertTest.cpp | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/examples/cppunittest/TestAssertTest.cpp b/examples/cppunittest/TestAssertTest.cpp index 6378e40..6941901 100644 --- a/examples/cppunittest/TestAssertTest.cpp +++ b/examples/cppunittest/TestAssertTest.cpp @@ -171,6 +171,17 @@ TestAssertTest::testAssertDoubleEquals() CPPUNIT_ASSERT_ASSERTION_FAIL( CPPUNIT_ASSERT_DOUBLES_EQUAL( 1.1, 1.2, 0.09 ) ); CPPUNIT_ASSERT_ASSERTION_FAIL( CPPUNIT_ASSERT_DOUBLES_EQUAL( 1.2, 1.1, 0.09 ) ); + + double inf = std::numeric_limits<double>::infinity(); + CPPUNIT_ASSERT_ASSERTION_FAIL( CPPUNIT_ASSERT_DOUBLES_EQUAL( inf, 0.0, 1.0 ) ); + CPPUNIT_ASSERT_ASSERTION_FAIL( CPPUNIT_ASSERT_DOUBLES_EQUAL( 0.0, inf, 1.0 ) ); + CPPUNIT_ASSERT_ASSERTION_PASS( CPPUNIT_ASSERT_DOUBLES_EQUAL( inf, inf, 1.0 ) ); + + double nan = std::numeric_limits<double>::quiet_NaN(); + CPPUNIT_ASSERT_ASSERTION_FAIL( CPPUNIT_ASSERT_DOUBLES_EQUAL( nan, 0.0, 1.0 ) ); + CPPUNIT_ASSERT_ASSERTION_FAIL( CPPUNIT_ASSERT_DOUBLES_EQUAL( nan, nan, 1.0 ) ); + CPPUNIT_ASSERT_ASSERTION_FAIL( CPPUNIT_ASSERT_DOUBLES_EQUAL( nan, inf, 1.0 ) ); + CPPUNIT_ASSERT_ASSERTION_FAIL( CPPUNIT_ASSERT_DOUBLES_EQUAL( inf, nan, 1.0 ) ); } |