diff options
author | Steve M. Robbins <smr@sumost.ca> | 2007-01-31 04:27:07 +0000 |
---|---|---|
committer | Steve M. Robbins <smr@sumost.ca> | 2007-01-31 04:27:07 +0000 |
commit | 3ca9c5d071cb8162c89fd514a6116ee6b450d763 (patch) | |
tree | de4b81cfb45d77392217dbaf8ef26414250ad65a /examples/cppunittest/TestAssertTest.cpp | |
parent | 92e722a21bb507165d4895c9a9aa92e53a1241ec (diff) | |
download | cppunit-3ca9c5d071cb8162c89fd514a6116ee6b450d763.tar.gz |
Add tests of the precision generated by
assertion_traits<double>::toString().
Diffstat (limited to 'examples/cppunittest/TestAssertTest.cpp')
-rw-r--r-- | examples/cppunittest/TestAssertTest.cpp | 21 |
1 files changed, 20 insertions, 1 deletions
diff --git a/examples/cppunittest/TestAssertTest.cpp b/examples/cppunittest/TestAssertTest.cpp index 8719440..3b621ed 100644 --- a/examples/cppunittest/TestAssertTest.cpp +++ b/examples/cppunittest/TestAssertTest.cpp @@ -135,7 +135,6 @@ TestAssertTest::testAssertEqual() CPPUNIT_ASSERT_ASSERTION_FAIL( CPPUNIT_ASSERT_EQUAL( 1, 2 ) ); } - void TestAssertTest::testAssertMessageTrue() { @@ -173,6 +172,26 @@ TestAssertTest::testAssertDoubleEquals() CPPUNIT_ASSERT_ASSERTION_FAIL( CPPUNIT_ASSERT_DOUBLES_EQUAL( 1.2, 1.1, 0.09 ) ); } +/* + * Test that the error message from CPPUNIT_ASSERT_DOUBLES_EQUAL() + * has more than the default 6 digits of precision. + */ +void +TestAssertTest::testAssertDoubleEqualsPrecision() +{ + std::string failure( "2.000000001" ); + try + { + CPPUNIT_ASSERT_DOUBLES_EQUAL( 1.0, 2.000000001, 1 ); + } + catch( CPPUNIT_NS::Exception &e ) + { + checkMessageContains( &e, failure ); + return; + } + CPPUNIT_FAIL( "Expected assertion failure" ); +} + void TestAssertTest::testAssertDoubleNonFinite() { |