diff options
| author | Baptiste Lepilleur <gaiacrtn@free.fr> | 2002-07-14 18:48:32 +0000 |
|---|---|---|
| committer | Baptiste Lepilleur <gaiacrtn@free.fr> | 2002-07-14 18:48:32 +0000 |
| commit | 251c1ff8aecaa608ef9e6041c2691d369430bf7b (patch) | |
| tree | 183795a04e06a8a94a64214afc2a1cc8a12a5486 /include/cppunit/TestAssert.h | |
| parent | 0807889cb53679c5a9e741e8dedc3668ef59729b (diff) | |
| download | cppunit-251c1ff8aecaa608ef9e6041c2691d369430bf7b.tar.gz | |
CodingGuideLines.
CodingGuideLines.txt: added. CppUnit's coding guidelines for portability.
* include/cppunit/portability/CppUnitStack.h: added. wrapper for std::stack.
* include/cppunit/portability/CppUnitSet.h: added. wrapper for std::set.
* include/cppunit/ui/text/TestRunner.h: fixed namespace definition for
deprecated TestRunner.
* include/cppunit/TestAssert.h:
* src/cppunit/TestAssert.cpp: removed old deprecated functions that did
not use SourceLine. Moved assertEquals() and assertDoubleEquals() into
CppUnit namespace.
* src/cppunit/TestFactoryRegistry.cpp: use CppUnitMap instead of std::map.
* src/DllPlugInTester/CommandLineParser.h: use CppUnitDeque instead
std::deque.
* examples/cppunittest/*.h:
* examples/cppunittest/*.cpp: removed all usage of CppUnitTest namespace.
Everything is now in global space.
* examples/*/*.h:
* examples/*/*.cpp: replaced usage of CppUnit:: with CPPUNIT_NS::.
* examples/ClockerPlugIn/ClockerModel.h: use CppUnit STL wrapper instead
of STL container.
Diffstat (limited to 'include/cppunit/TestAssert.h')
| -rw-r--r-- | include/cppunit/TestAssert.h | 106 |
1 files changed, 37 insertions, 69 deletions
diff --git a/include/cppunit/TestAssert.h b/include/cppunit/TestAssert.h index ba30e9c..87510df 100644 --- a/include/cppunit/TestAssert.h +++ b/include/cppunit/TestAssert.h @@ -49,66 +49,34 @@ struct assertion_traits }; -namespace TestAssert +/*! \brief (Implementation) Asserts that two objects of the same type are equals. + * Use CPPUNIT_ASSERT_EQUAL instead of this function. + * \sa assertion_traits, Asserter::failNotEqual(). + */ +template <class T> +void assertEquals( const T& expected, + const T& actual, + SourceLine sourceLine, + const std::string &message ="" ) { -#ifdef CPPUNIT_ENABLE_SOURCELINE_DEPRECATED - void CPPUNIT_API assertImplementation( bool condition, - std::string conditionExpression = "", - long lineNumber, - std::string fileName ); - - void CPPUNIT_API assertNotEqualImplementation( std::string expected, - std::string actual, - long lineNumber, - std::string fileName ); - - - template <class T> - void assertEquals( const T& expected, - const T& actual, - long lineNumber, - std::string fileName ) + if ( !assertion_traits<T>::equal(expected,actual) ) // lazy toString conversion... { - if ( !assertion_traits<T>::equal(expected,actual) ) // lazy toString conversion... - { - assertNotEqualImplementation( assertion_traits<T>::toString(expected), - assertion_traits<T>::toString(actual), - lineNumber, - fileName ); - } + Asserter::failNotEqual( assertion_traits<T>::toString(expected), + assertion_traits<T>::toString(actual), + sourceLine, + message ); } - - void CPPUNIT_API assertEquals( double expected, - double actual, - double delta, - long lineNumber, - std::string fileName ); - -#else // using SourceLine - - template <class T> - void assertEquals( const T& expected, - const T& actual, - SourceLine sourceLine, - const std::string &message ="" ) - { - if ( !assertion_traits<T>::equal(expected,actual) ) // lazy toString conversion... - { - Asserter::failNotEqual( assertion_traits<T>::toString(expected), - assertion_traits<T>::toString(actual), - sourceLine, - message ); - } - } - - void CPPUNIT_API assertDoubleEquals( double expected, - double actual, - double delta, - SourceLine sourceLine ); - -#endif } +/*! \brief (Implementation) Asserts that two double are equals given a tolerance. + * Use CPPUNIT_ASSERT_DOUBLES_EQUAL instead of this function. + * \sa Asserter::failNotEqual(). + */ +void CPPUNIT_API assertDoubleEquals( double expected, + double actual, + double delta, + SourceLine sourceLine ); + /* A set of macros which allow us to get the line number * and file name at the point of an error. @@ -155,9 +123,9 @@ namespace TestAssert #ifdef CPPUNIT_ENABLE_SOURCELINE_DEPRECATED /// Generalized macro for primitive value comparisons #define CPPUNIT_ASSERT_EQUAL(expected,actual) \ - ( CPPUNIT_NS::TestAssert::assertEquals( (expected), \ - (actual), \ - __LINE__, __FILE__ ) ) + ( CPPUNIT_NS::assertEquals( (expected), \ + (actual), \ + __LINE__, __FILE__ ) ) #else /** Asserts that two values are equals. * \ingroup Assertions @@ -176,9 +144,9 @@ namespace TestAssert * removed by specializing the CppUnit::assertion_traits. */ #define CPPUNIT_ASSERT_EQUAL(expected,actual) \ - ( CPPUNIT_NS::TestAssert::assertEquals( (expected), \ - (actual), \ - CPPUNIT_SOURCELINE() ) ) + ( CPPUNIT_NS::assertEquals( (expected), \ + (actual), \ + CPPUNIT_SOURCELINE() ) ) /** Asserts that two values are equals, provides additional messafe on failure. * \ingroup Assertions @@ -199,20 +167,20 @@ namespace TestAssert * removed by specializing the CppUnit::assertion_traits. */ #define CPPUNIT_ASSERT_EQUAL_MESSAGE(message,expected,actual) \ - ( CPPUNIT_NS::TestAssert::assertEquals( (expected), \ - (actual), \ - CPPUNIT_SOURCELINE(), \ - (message) ) ) + ( CPPUNIT_NS::assertEquals( (expected), \ + (actual), \ + CPPUNIT_SOURCELINE(), \ + (message) ) ) #endif /*! \brief Macro for primitive value comparisons * \ingroup Assertions */ #define CPPUNIT_ASSERT_DOUBLES_EQUAL(expected,actual,delta) \ - ( CPPUNIT_NS::TestAssert::assertDoubleEquals( (expected), \ - (actual), \ - (delta), \ - CPPUNIT_SOURCELINE() ) ) + ( CPPUNIT_NS::assertDoubleEquals( (expected), \ + (actual), \ + (delta), \ + CPPUNIT_SOURCELINE() ) ) // Backwards compatibility |
