Update of /cvsroot/cppunit/cppunit/examples/cppunittest
In directory sc8-pr-cvs4.sourceforge.net:/tmp/cvs-serv13223/examples/cppunittest
Modified Files:
TestAssertTest.cpp
Log Message:
Add unit tests for CPPUNIT_ASSERT_DOUBLES_EQUAL() that test with
non-finite values.
Index: TestAssertTest.cpp
===================================================================
RCS file: /cvsroot/cppunit/cppunit/examples/cppunittest/TestAssertTest.cpp,v
retrieving revision 1.10
retrieving revision 1.11
diff -C2 -d -r1.10 -r1.11
*** TestAssertTest.cpp 12 Jan 2007 05:49:43 -0000 1.10
--- TestAssertTest.cpp 27 Jan 2007 05:46:30 -0000 1.11
***************
*** 172,175 ****
--- 172,186 ----
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 ) );
}
|