From 3ca9c5d071cb8162c89fd514a6116ee6b450d763 Mon Sep 17 00:00:00 2001 From: "Steve M. Robbins" Date: Wed, 31 Jan 2007 04:27:07 +0000 Subject: Add tests of the precision generated by assertion_traits::toString(). --- examples/cppunittest/TestAssertTest.cpp | 21 ++++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) (limited to 'examples/cppunittest/TestAssertTest.cpp') 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() { -- cgit v1.2.1