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/assertion_traitsTest.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/assertion_traitsTest.cpp')
| -rw-r--r-- | examples/cppunittest/assertion_traitsTest.cpp | 35 |
1 files changed, 35 insertions, 0 deletions
diff --git a/examples/cppunittest/assertion_traitsTest.cpp b/examples/cppunittest/assertion_traitsTest.cpp new file mode 100644 index 0000000..b02c732 --- /dev/null +++ b/examples/cppunittest/assertion_traitsTest.cpp @@ -0,0 +1,35 @@ +#include <cppunit/TestAssert.h> +#include "CoreSuite.h" +#include "assertion_traitsTest.h" + + +CPPUNIT_TEST_SUITE_NAMED_REGISTRATION( assertion_traitsTest, + coreSuiteName() ); + +assertion_traitsTest::assertion_traitsTest() +{ +} + + +void +assertion_traitsTest::test_toString() +{ + CPPUNIT_ASSERT_EQUAL( std::string( "abc" ), + CPPUNIT_NS::assertion_traits<char*>::toString( "abc" ) ); + + CPPUNIT_ASSERT_EQUAL( std::string( "33" ), + CPPUNIT_NS::assertion_traits<int>::toString( 33 ) ); + + // Test that assertion_traits<double>::toString() produces + // more than the standard 6 digits of precision. + CPPUNIT_ASSERT_EQUAL( std::string( "33.1" ), + CPPUNIT_NS::assertion_traits<double>::toString( 33.1 ) ); + CPPUNIT_ASSERT_EQUAL( std::string( "33.001" ), + CPPUNIT_NS::assertion_traits<double>::toString( 33.001 ) ); + CPPUNIT_ASSERT_EQUAL( std::string( "33.00001" ), + CPPUNIT_NS::assertion_traits<double>::toString( 33.00001 ) ); + CPPUNIT_ASSERT_EQUAL( std::string( "33.0000001" ), + CPPUNIT_NS::assertion_traits<double>::toString( 33.0000001 ) ); + CPPUNIT_ASSERT_EQUAL( std::string( "33.0000000001" ), + CPPUNIT_NS::assertion_traits<double>::toString( 33.0000000001 ) ); +} |
