[Cppunit-cvs] cppunit2/include/cpput assertcommon.h,NONE,1.1 assertenum.h,1.11,1.12 assertstring.h,1
Brought to you by:
blep
From: Baptiste L. <bl...@us...> - 2005-11-13 10:12:09
|
Update of /cvsroot/cppunit/cppunit2/include/cpput In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv10041/include/cpput Modified Files: assertenum.h assertstring.h equality.h stringize.h testfixture.h Added Files: assertcommon.h Removed Files: assert.h Log Message: - renamed include/cpput/assert.h to include/cpput/assertcommon.h. This avoid clash with include <assert.h> in doxygen documentation - most Impl namespaces are now hidden from documentation using \cond and \endcond. Index: assertenum.h =================================================================== RCS file: /cvsroot/cppunit/cppunit2/include/cpput/assertenum.h,v retrieving revision 1.11 retrieving revision 1.12 diff -C2 -d -r1.11 -r1.12 *** assertenum.h 11 Nov 2005 23:23:48 -0000 1.11 --- assertenum.h 13 Nov 2005 10:12:01 -0000 1.12 *************** *** 2,6 **** # define CPPUT_ASSERTENUM_H_INCLUDED ! # include <cpput/assert.h> # include <cpptl/enumerator.h> # include <functional> --- 2,6 ---- # define CPPUT_ASSERTENUM_H_INCLUDED ! # include <cpput/assertcommon.h> # include <cpptl/enumerator.h> # include <functional> *************** *** 55,58 **** --- 55,59 ---- + /// \cond implementation_detail namespace Impl { *************** *** 119,122 **** --- 120,124 ---- } // namespace Impl + /// \endcond template<class ExpectedEnumerator --- assert.h DELETED --- Index: testfixture.h =================================================================== RCS file: /cvsroot/cppunit/cppunit2/include/cpput/testfixture.h,v retrieving revision 1.13 retrieving revision 1.14 diff -C2 -d -r1.13 -r1.14 *** testfixture.h 11 Nov 2005 23:23:48 -0000 1.13 --- testfixture.h 13 Nov 2005 10:12:01 -0000 1.14 *************** *** 43,46 **** --- 43,47 ---- + /// \cond implementation_detail namespace Impl { *************** *** 92,95 **** --- 93,97 ---- }; } // namespace Impl + /// \endcond implementation_detail Index: stringize.h =================================================================== RCS file: /cvsroot/cppunit/cppunit2/include/cpput/stringize.h,v retrieving revision 1.10 retrieving revision 1.11 diff -C2 -d -r1.10 -r1.11 *** stringize.h 12 Nov 2005 20:55:46 -0000 1.10 --- stringize.h 13 Nov 2005 10:12:01 -0000 1.11 *************** *** 160,163 **** --- 160,164 ---- #endif + /// \cond implementation_detail namespace Impl { *************** *** 187,190 **** --- 188,193 ---- } // namespace Impl + /// \endcond implementation_detail + /*! \ingroup group_assertions_support Index: assertstring.h =================================================================== RCS file: /cvsroot/cppunit/cppunit2/include/cpput/assertstring.h,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** assertstring.h 11 Nov 2005 23:23:48 -0000 1.4 --- assertstring.h 13 Nov 2005 10:12:01 -0000 1.5 *************** *** 2,6 **** # define CPPUT_ASSERTSTRING_H_INCLUDED ! # include <cpput/assert.h> namespace CppUT { --- 2,6 ---- # define CPPUT_ASSERTSTRING_H_INCLUDED ! # include <cpput/assertcommon.h> namespace CppUT { --- NEW FILE: assertcommon.h --- #ifndef CPPUT_ASSERT_H_INCLUDED # define CPPUT_ASSERT_H_INCLUDED # include <cpput/equality.h> # include <cpput/message.h> # include <cpput/stringize.h> # include <cpput/testinfo.h> # include <cpput/translate.h> # include <cpptl/typename.h> namespace CppUT { void CPPUT_API fail( const Message &message = translate( "Assertion failed." ) ); void CPPUT_API checkTrue( bool shouldBeTrue, const Message &message = Message() ); void CPPUT_API checkFalse( bool shouldBeFalse, const Message &message = Message() ); void CPPUT_API checkAssertionFail( bool assertionFailed, const Message &message = Message() ); void CPPUT_API checkAssertionPass( bool assertionFailed, const Message &message = Message() ); Message CPPUT_API buildEqualityFailedMessage( const std::string &expected, const std::string &actual, const Message &message = Message() ); template<typename FirstType ,typename SecondType> Message makeEqualityFailedMessage( const FirstType &expected, const SecondType &actual, const Message &message = Message() ) { std::string strExpected = stringize( expected ); std::string strActual = stringize( actual ); return buildEqualityFailedMessage( strExpected, strActual, message ); } template<typename FirstType ,typename SecondType ,typename EqualityFunctorType> void checkEquals( const FirstType &expected, const SecondType &actual, EqualityFunctorType equality, const Message &message ) { if ( equality( expected, actual ) ) return; fail( makeEqualityFailedMessage( expected, actual, message ) ); } template<typename FirstType ,typename SecondType> void checkEquals( const FirstType &expected, const SecondType &actual, const Message &message = Message() ) { if ( equalityTest( expected, actual ) ) return; fail( makeEqualityFailedMessage( expected, actual, message ) ); } Message CPPUT_API buildUnequalityFailedMessage( const std::string &expected, const std::string &actual, const Message &message = Message() ); template<typename FirstType ,typename SecondType> Message makeUnequalityFailedMessage( const FirstType &expected, const SecondType &actual, const Message &message = Message() ) { std::string strExpected = stringize( expected ); std::string strActual = stringize( actual ); return buildUnequalityFailedMessage( strExpected, strActual, message ); } template<typename FirstType ,typename SecondType ,typename EqualityFunctorType> void checkNotEquals( const FirstType &expected, const SecondType &actual, EqualityFunctorType equality, const Message &message ) { if ( !( equality( expected, actual ) ) ) return; fail( makeUnequalityFailedMessage( expected, actual, message ) ); } template<typename FirstType ,typename SecondType> void checkNotEquals( const FirstType &expected, const SecondType &actual, const Message &message = Message() ) { if ( !( equalityTest( expected, actual ) ) ) return; fail( makeUnequalityFailedMessage( expected, actual, message ) ); } void CPPUT_API checkDoubleEquals( double expected, double actual, double tolerance, const Message &message = Message() ); void CPPUT_API skipCurrentTest(); } // namespace CppUT /*! Starts either an aborting assertion or a checking assertion macro. * \ingroup group_custom_assertions * \internal * __func__ should contains the current fonction name on many compiler (C99 compiler extension). See: * http://publib.boulder.ibm.com/infocenter/pseries/index.jsp?topic=/com.ibm.vacpp7a.doc/language/ref/clrc02predefined_identifiers.htm * Available if __C99__FUNC__ is defined: * http://publib.boulder.ibm.com/infocenter/pseries/index.jsp?topic=/com.ibm.vacpp7a.doc/language/ref/clrapxaix_macros.htm */ # define CPPUT_CHECK_POINT( assertionType ) \ ::CppUT::TestInfo::threadInstance().newAssertion( ::CppUT::assertionType, \ __FILE__, \ __LINE__ ) /*! Starts an aborting assertion macro. * \ingroup group_custom_assertions */ # define CPPUT_BEGIN_ASSERTION_MACRO() \ CPPUT_CHECK_POINT( abortingAssertion ), /*! Starts a checking assertion macro. * \ingroup group_custom_assertions */ # define CPPUT_BEGIN_CHECKING_MACRO() \ CPPUT_CHECK_POINT( checkingAssertion ), // basic assertions /*! \brief Always fails with the given message. * \ingroup group_assertions * \see CppUT::fail */ # define CPPUT_FAIL \ CPPUT_BEGIN_ASSERTION_MACRO() \ ::CppUT::fail /*! \brief Asserts that an expression evaluate to true. * \ingroup group_assertions * \see CppUT::checkTrue */ # define CPPUT_ASSERT \ CPPUT_BEGIN_ASSERTION_MACRO() \ ::CppUT::checkTrue /*! \brief Checks that an expression evaluate to true. * \ingroup group_assertions * \see CppUT::checkTrue */ # define CPPUT_CHECK \ CPPUT_BEGIN_CHECKING_MACRO() \ ::CppUT::checkTrue /*! \brief Asserts that an expression evaluate to true. * \ingroup group_assertions * The expression source code is written in the assertion diagnostic in case of failure. * \see CppUT::checkTrue */ # define CPPUT_ASSERT_EXPR( expression ) \ CPPUT_ASSERT( (expression), #expression ) /*! \brief Checks that an expression evaluate to true. * \ingroup group_assertions * The expression source code is written in the assertion diagnostic in case of failure. * \see CppUT::checkTrue */ # define CPPUT_CHECK_EXPR( expression ) \ CPPUT_CHECK( (expression), #expression ) /*! \brief Asserts that an expression evaluate to false. * \ingroup group_assertions * \see CppUT::checkFalse */ # define CPPUT_ASSERT_FALSE \ CPPUT_BEGIN_ASSERTION_MACRO() \ ::CppUT::checkFalse /*! \brief Checks that an expression evaluate to false. * \ingroup group_assertions * \see CppUT::checkFalse */ # define CPPUT_CHECK_FALSE \ CPPUT_BEGIN_CHECKING_MACRO() \ ::CppUT::checkFalse /*! \brief Asserts that an expression evaluate to false. * \ingroup group_assertions * The expression source code is written in the assertion diagnostic in case of failure. * \see CppUT::checkFalse */ # define CPPUT_ASSERT_EXPR_FALSE( expression ) \ CPPUT_ASSERT_FALSE( (expression), #expression ) /*! \brief Checks that an expression evaluate to false. * \ingroup group_assertions * The expression source code is written in the assertion diagnostic in case of failure. * \see CppUT::checkFalse */ # define CPPUT_CHECK_EXPR_FALSE( expression ) \ CPPUT_CHECK_FALSE( (expression), #expression ) /*! \brief Asserts that two values are equal. * \ingroup group_assertions * - The values must be comparable using CppUT::equalityTest * - The values must be convertible to std::string using CppUT::stringize * \see CppUT::checkEquals */ # define CPPUT_ASSERT_EQUAL \ CPPUT_BEGIN_ASSERTION_MACRO() \ ::CppUT::checkEquals /*! \brief Checks that two values are equal. * \ingroup group_assertions * - The values must be comparable using CppUT::equalityTest * - The values must be convertible to std::string using CppUT::stringize * \see CppUT::checkEquals */ # define CPPUT_CHECK_EQUAL \ CPPUT_BEGIN_CHECKING_MACRO() \ ::CppUT::checkEquals /*! \brief Asserts that two values are not equal. * \ingroup group_assertions * - The values must be comparable using CppUT::equalityTest * - The values must be convertible to std::string using CppUT::stringize * \see CppUT::checkNotEquals */ # define CPPUT_ASSERT_NOT_EQUAL \ CPPUT_BEGIN_ASSERTION_MACRO() \ ::CppUT::checkNotEquals /*! \brief Checks that two values are not equal. * \ingroup group_assertions * - The values must be comparable using CppUT::equalityTest * - The values must be convertible to std::string using CppUT::stringize * \see CppUT::checkNotEquals */ # define CPPUT_CHECK_NOT_EQUAL \ CPPUT_BEGIN_CHECKING_MACRO() \ ::CppUT::checkNotEquals /*! \brief Asserts that two double are equals given a tolerance * \ingroup group_assertions * \see ::CppUT::checkDoubleEquals */ # define CPPUT_ASSERT_DOUBLE_EQUAL \ CPPUT_BEGIN_ASSERTION_MACRO() \ ::CppUT::checkDoubleEquals /*! \brief Checks that two double are equals given a tolerance * \ingroup group_assertions * \see ::CppUT::checkDoubleEquals */ # define CPPUT_CHECK_DOUBLE_EQUAL \ CPPUT_BEGIN_CHECKING_MACRO() \ ::CppUT::checkDoubleEquals /*! \internal */ # define _CPPUT_ASSERT_THROW_IMPL( assertionType, expression, ExceptionType ) \ do { \ CPPUT_CHECK_POINT( assertionType ); \ bool cpputExceptionThrown_ = false; \ try { \ expression; \ } catch ( const ExceptionType & ) { \ cpputExceptionThrown_ = true; \ } \ \ if ( cpputExceptionThrown_ ) \ break; \ \ ::CppUT::fail( "Expected exception: " #ExceptionType \ " not thrown." ); \ } while ( false ) /*! \brief Asserts that an expression throw an exception of a specified type * \ingroup group_assertions */ # define CPPUT_ASSERT_THROW( expression, ExceptionType ) \ _CPPUT_ASSERT_THROW_IMPL( abortingAssertion, expression, ExceptionType ) /*! \brief Checks that an expression throw an exception of a specified type * \ingroup group_assertions */ # define CPPUT_CHECK_THROW( expression, ExceptionType ) \ _CPPUT_CHECK_THROW_IMPL( checkingAssertion, expression, ExceptionType ) /*! \internal */ # define _CPPUT_ASSERT_NO_THROW_IMPL( assertionType, expression ) \ try { \ CPPUT_CHECK_POINT( assertionType ); \ expression; \ } catch ( const std::exception &e ) { \ ::CppUT::Message message( "Unexpected exception caught" ); \ message.add( "Type: " + \ ::CppTL::getObjectTypeName( e, "std::exception" ) ); \ message.add( std::string("What: ") + e.what() ); \ ::CppUT::fail( message ); \ } catch ( ... ) { \ ::CppUT::fail( "Unexpected exception caught" ); \ } /*! \brief Asserts that an expression does not throw any exception * \ingroup group_assertions */ # define CPPUT_ASSERT_NO_THROW( expression ) \ _CPPUT_ASSERT_NO_THROW_IMPL( abortingAssertion, expression ) /*! \brief Checks that an expression does not throw any exception * \ingroup group_assertions */ # define CPPUT_CHECK_NO_THROW( expression ) \ _CPPUT_ASSERT_NO_THROW_IMPL( checkingAssertion, expression ) /*! \internal * Notes: implementing that assertion checking is a bit tricky since all the state * about the current test/assertions is stored in a "static" and * we don't want the tested assertion to polute the test result * of the current test. * TestInfo::ScopedContextOverride is used to create a temporary * context for the tested assertion. After the assertion, the * result of the assertion (did it failed), and the test result * properties are captured for later inspection. */ # define _CPPUT_ASSERT_ASSERTION_FAIL_MESSAGE_IMPL( assertionType, assertion, message ) \ { \ CPPUT_CHECK_POINT( assertionType ); \ bool assertionFailedCppUT_ = false; \ { \ ::CppUT::TestInfo::ScopedContextOverride contextSwitchCppUT_; \ try { \ assertion; \ } catch ( const ::CppUT::AbortingAssertionException & ) { \ } \ assertionFailedCppUT_ = ::CppUT::TestInfo::threadInstance().testStatus().hasFailed(); \ } \ ::CppUT::checkAssertionFail( assertionFailedCppUT_, message ); \ } /*! \brief Asserts that an assertion fails (for use to unit test custom assertion) * \ingroup group_assertions */ # define CPPUT_ASSERT_ASSERTION_FAIL_MESSAGE( assertion, message ) \ _CPPUT_ASSERT_ASSERTION_FAIL_MESSAGE_IMPL( abortingAssertion, assertion, message ) /*! \brief Checks that an assertion fails (for use to unit test custom assertion) * \ingroup group_assertions */ # define CPPUT_CHECK_ASSERTION_FAIL_MESSAGE( assertion, message ) \ _CPPUT_CHECK_ASSERTION_FAIL_MESSAGE_IMPL( checkingAssertion, assertion, message ) /*! \brief Asserts that an assertion fails (for use to unit test custom assertion) * \ingroup group_assertions */ # define CPPUT_ASSERT_ASSERTION_FAIL( assertion ) \ CPPUT_ASSERT_ASSERTION_FAIL_MESSAGE( assertion, ::CppUT::Message() ) /*! \brief Checks that an assertion fails (for use to unit test custom assertion) * \ingroup group_assertions */ # define CPPUT_CHECK_ASSERTION_FAIL( assertion ) \ CPPUT_CHECK_ASSERTION_FAIL_MESSAGE( assertion, ::CppUT::Message() ) /*! \internal */ # define _CPPUT_ASSERT_ASSERTION_PASS_MESSAGE_IMPL( assertionType, assertion, message ) \ { \ CPPUT_CHECK_POINT( assertionType ); \ bool assertionFailedCppUT_ = false; \ { \ ::CppUT::TestInfo::ScopedContextOverride contextSwitchCppUT_; \ try { \ assertion; \ } catch ( const ::CppUT::AbortingAssertionException & ) { \ } \ assertionFailedCppUT_ = ::CppUT::TestInfo::threadInstance().testStatus().hasFailed(); \ } \ ::CppUT::checkAssertionPass( assertionFailedCppUT_, message ); \ } /*! \brief Asserts that an assertion is successful (for use to unit test custom assertion) * \ingroup group_assertions */ # define CPPUT_ASSERT_ASSERTION_PASS_MESSAGE( assertion, message ) \ _CPPUT_ASSERT_ASSERTION_PASS_MESSAGE_IMPL( abortingAssertion, assertion, message ) /*! \brief Checks that an assertion is successful (for use to unit test custom assertion) * \ingroup group_assertions */ # define CPPUT_CHECK_ASSERTION_PASS_MESSAGE( assertion, message ) \ _CPPUT_CHECK_ASSERTION_PASS_MESSAGE_IMPL( checkingAssertion, assertion, message ) /*! \brief Asserts that an assertion is successful (for use to unit test custom assertion) * \ingroup group_assertions */ # define CPPUT_ASSERT_ASSERTION_PASS( assertion ) \ CPPUT_ASSERT_ASSERTION_PASS_MESSAGE( assertion, ::CppUT::Message() ) /*! \brief Checks that an assertion is successful (for use to unit test custom assertion) * \ingroup group_assertions */ # define CPPUT_CHECK_ASSERTION_PASS( assertion ) \ CPPUT_CHECK_ASSERTION_PASS_MESSAGE( assertion, ::CppUT::Message() ) /*! \brief Skips and aborts the current test. * \ingroup group_assertions * * Cause the current test to be skipped. Its status will be 'TestStatus::skipped', * unless an assertion failed before. */ # define CPPUT_SKIP_TEST \ ::CppUT::skipCurrentTest /*! \brief Checks that an assertion fail, but ignore its failure * \ingroup group_assertions * * A typical usage of CPPUT_IGNORE_FAILURE is to ignore a failing assertion temporary. * Even if the assertion fails, it does not cause the test to fail, but increased * CppUT::TestStatus::ignoredFailureCount() instead. * * Notes that CPPUT_IGNORE_FAILURE also checks that the \c assertion fails (just like * CPPUT_CHECK_ASSERTION_FAIL) and will therefore cause the test to fail if the * assertion did not fail. * * \code * CPPUT_IGNORE_FAILURE(( CPPUT_ASSERT_EQUAL( 1, 2 )); * \endcode * * \warning Be sure to always use double brace around the macro parameter to avoid * preprocessor mess. */ # define CPPUT_IGNORE_FAILURE( assertion ) \ { \ CPPUT_CHECK_POINT( checkingAssertion ); \ bool failedCppUT_; \ { \ ::CppUT::TestInfo::IgnoreFailureScopedContextOverride contextSwitchCppUT_( failedCppUT_ );\ try { \ assertion; \ } catch ( const ::CppUT::AbortingAssertionException & ) { \ } \ } \ ::CppUT::checkAssertionFail( failedCppUT_, #assertion ); \ } #endif // CPPUT_ASSERT_H_INCLUDED Index: equality.h =================================================================== RCS file: /cvsroot/cppunit/cppunit2/include/cpput/equality.h,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** equality.h 11 Nov 2005 23:23:48 -0000 1.5 --- equality.h 13 Nov 2005 10:12:01 -0000 1.6 *************** *** 42,45 **** --- 42,46 ---- + /// \cond implementation_detail namespace Impl { template<typename AType, typename BType> *************** *** 56,59 **** --- 57,61 ---- } // namespace Impl + /// \endcond implementation_detail /*! \ingroup group_assertions_support |