cppunit-cvs Mailing List for CppUnit - C++ port of JUnit (Page 4)
Brought to you by:
blep
You can subscribe to this list here.
2004 |
Jan
|
Feb
|
Mar
|
Apr
|
May
|
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
(94) |
Dec
|
---|---|---|---|---|---|---|---|---|---|---|---|---|
2005 |
Jan
|
Feb
(114) |
Mar
(80) |
Apr
|
May
|
Jun
(36) |
Jul
(67) |
Aug
(37) |
Sep
(33) |
Oct
(28) |
Nov
(91) |
Dec
(16) |
2006 |
Jan
(1) |
Feb
(7) |
Mar
(45) |
Apr
|
May
|
Jun
(36) |
Jul
(7) |
Aug
|
Sep
(32) |
Oct
(3) |
Nov
|
Dec
|
2007 |
Jan
(29) |
Feb
(11) |
Mar
(5) |
Apr
|
May
|
Jun
|
Jul
|
Aug
(35) |
Sep
|
Oct
|
Nov
|
Dec
|
2008 |
Jan
|
Feb
(14) |
Mar
|
Apr
|
May
|
Jun
(5) |
Jul
(13) |
Aug
|
Sep
|
Oct
(3) |
Nov
|
Dec
(15) |
From: Baptiste L. <bl...@us...> - 2007-08-15 11:21:01
|
Update of /cvsroot/cppunit/cppunit2/src/cpput In directory sc8-pr-cvs4.sourceforge.net:/tmp/cvs-serv8069/src/cpput Modified Files: registry.cpp testcase.cpp Log Message: Added support for light test fixture (a la CppUnitLite). See lightfixture.h and example/light_fixture. Added support for direct declaration and registration of test in plain C function. See testfunction.h and example/test_function. Index: registry.cpp =================================================================== RCS file: /cvsroot/cppunit/cppunit2/src/cpput/registry.cpp,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** registry.cpp 13 Nov 2005 10:12:01 -0000 1.5 --- registry.cpp 15 Aug 2007 11:20:57 -0000 1.6 *************** *** 64,67 **** --- 64,74 ---- + void + Registry::addChildToDefault( const std::string &childSuiteName ) + { + addChild( defaultParentSuiteName(), childSuiteName ); + } + + bool Registry::removeChild( const std::string &parentSuiteName, Index: testcase.cpp =================================================================== RCS file: /cvsroot/cppunit/cppunit2/src/cpput/testcase.cpp,v retrieving revision 1.15 retrieving revision 1.16 diff -C2 -d -r1.15 -r1.16 *** testcase.cpp 13 Nov 2005 10:12:01 -0000 1.15 --- testcase.cpp 15 Aug 2007 11:20:57 -0000 1.16 *************** *** 119,122 **** --- 119,128 ---- + TestPtr CPPUT_API makeTestCase( void (*run)(), + const std::string &name ) + { + return TestPtr( new TestCase( CppTL::cfn0(run), name ) ); + } + TestPtr makeTestCase( const CppTL::Functor0 &run, |
From: Baptiste L. <bl...@us...> - 2007-08-15 11:21:00
|
Update of /cvsroot/cppunit/cppunit2/doc In directory sc8-pr-cvs4.sourceforge.net:/tmp/cvs-serv8069/doc Modified Files: cpput.dox cpput_todo.dox Log Message: Added support for light test fixture (a la CppUnitLite). See lightfixture.h and example/light_fixture. Added support for direct declaration and registration of test in plain C function. See testfunction.h and example/test_function. Index: cpput.dox =================================================================== RCS file: /cvsroot/cppunit/cppunit2/doc/cpput.dox,v retrieving revision 1.6 retrieving revision 1.7 diff -C2 -d -r1.6 -r1.7 *** cpput.dox 7 Sep 2006 22:45:50 -0000 1.6 --- cpput.dox 15 Aug 2007 11:20:57 -0000 1.7 *************** *** 64,67 **** --- 64,72 ---- A test case is usually created using CppUT::makeTestCase() that instantiate CppUT::TestCase. + + Notes that test case instantiation is usually only done when you need to create your own + convenience test case macro or you are populating a TestSuite with parametrized TestCase. + The framework provides severable way to create and register test case, see \ref section_lightfixture, + \ref section_testfixture, \ref section_testfunction. \subsection section_assertions Making assertions *************** *** 215,218 **** --- 220,253 ---- to abort the test. + \subsection section_testfixture Creating TestCase: TestFixture + + A TestFixture is a class that implements multiple test cases sharing the same setUp/tearDown steps. + Test cases are implements as "void test()" member function and each test case has its own instance + of the test fixture. + + A TestFixture support the following features: + - TestFixture may be a template class + - polymorphism: you can subclass a TestFixture and adds more test or override setUp/teardown + virtual member functions. + - TestExtendedData can be specified for each test + - TestFixture test cases are grouped within a TestSuite + - macro usage is limited to a declaration of the test member function and is clearly separated + from code. + + \subsection section_lightfixture Creating TestCase: light Fixture + + A Light test fixture is similar to a TestFixture but does not support the following features: + - templated test class + - can not subclass a light test fixture and share common test cases + - macro usage is intrusive and hides member function declaration. + + On the positive side, it is easier on the wrist. + + \subsection section_testfunction Creating TestCase: test functions + + A test case can be implemented as a plain C function "void test()". + + + <hr> \section section_projectlinks Project links *************** *** 220,225 **** - <a HREF="http://www.sourceforge.net/projects/cppunit">cppunit sourceforge project</a> - - <hr> \section _rlinks Related links --- 255,258 ---- Index: cpput_todo.dox =================================================================== RCS file: /cvsroot/cppunit/cppunit2/doc/cpput_todo.dox,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** cpput_todo.dox 3 Sep 2006 07:58:58 -0000 1.2 --- cpput_todo.dox 15 Aug 2007 11:20:57 -0000 1.3 *************** *** 120,124 **** <hr> ! \section todo_light_unit_tests Lightweight unit test declarations Needs: provides an alternative mecanism to implement fixture with less code --- 120,124 ---- <hr> ! \section todo_light_unit_tests Lightweight unit test declarations [DONE] Needs: provides an alternative mecanism to implement fixture with less code *************** *** 337,340 **** --- 337,346 ---- then the later override the other one. + <hr> + \section todo_testfunction_extendeddata Add support for TestExtendedData in test function. + Adds variant ..._WITH_SPECIFICS for all testfunction macros. + \section todo_registry_default Handle orphan test suite in the Registry + Provides a feature to automatically parent orphan test suite in the Registry, to either + the default test suite or a specific test suite. */ \ No newline at end of file |
From: Baptiste L. <bl...@us...> - 2007-08-15 11:21:00
|
Update of /cvsroot/cppunit/cppunit2/include/cpput In directory sc8-pr-cvs4.sourceforge.net:/tmp/cvs-serv8069/include/cpput Modified Files: registry.h testcase.h Log Message: Added support for light test fixture (a la CppUnitLite). See lightfixture.h and example/light_fixture. Added support for direct declaration and registration of test in plain C function. See testfunction.h and example/test_function. Index: testcase.h =================================================================== RCS file: /cvsroot/cppunit/cppunit2/include/cpput/testcase.h,v retrieving revision 1.14 retrieving revision 1.15 diff -C2 -d -r1.14 -r1.15 *** testcase.h 12 Nov 2005 20:55:46 -0000 1.14 --- testcase.h 15 Aug 2007 11:20:57 -0000 1.15 *************** *** 75,78 **** --- 75,85 ---- * \ingroup group_testcases */ + TestPtr CPPUT_API makeTestCase( void (*run)(), + const std::string &name ); + + + /*! \brief Creates a TestCase with the specified name and run functor. + * \ingroup group_testcases + */ TestPtr CPPUT_API makeTestCase( const CppTL::Functor0 &run, const std::string &name ); Index: registry.h =================================================================== RCS file: /cvsroot/cppunit/cppunit2/include/cpput/registry.h,v retrieving revision 1.8 retrieving revision 1.9 diff -C2 -d -r1.8 -r1.9 *** registry.h 11 Nov 2005 23:23:48 -0000 1.8 --- registry.h 15 Aug 2007 11:20:57 -0000 1.9 *************** *** 21,25 **** /*! \ingroup group_testregistry ! */ class CPPUT_API Registry { --- 21,28 ---- /*! \ingroup group_testregistry ! * Static registry for all tests. ! * Any suite or test added to the registry by a dynamic library that contains test should ! * be removed using remove(). Helper macros take carre of this. ! */ class CPPUT_API Registry { *************** *** 33,36 **** --- 36,40 ---- void addChild( const std::string &parentSuiteName, const std::string &childSuiteName ); + void addChildToDefault( const std::string &childSuiteName ); bool removeChild( const std::string &parentSuiteName, *************** *** 182,185 **** --- 186,196 ---- { public: + explicit SuiteRelationshipRegisterer( const std::string &childSuiteName ) + : childSuiteName_( childSuiteName ) + , parentSuiteName_( Registry::defaultParentSuiteName() ) + { + Registry::instance().addChildToDefault( childSuiteName ); + } + SuiteRelationshipRegisterer( const std::string &parentSuiteName, const std::string &childSuiteName ) *************** *** 205,209 **** */ #define CPPUT_REGISTER_SUITE_RELATIONSHIP( parentSuiteName, childSuiteName ) \ ! static CppUT::SuiteRelationshipRegisterer \ CPPTL_MAKE_UNIQUE_NAME(cpputSuiteRelationShipRegisterer )( \ parentSuiteName, \ --- 216,220 ---- */ #define CPPUT_REGISTER_SUITE_RELATIONSHIP( parentSuiteName, childSuiteName ) \ ! static ::CppUT::SuiteRelationshipRegisterer \ CPPTL_MAKE_UNIQUE_NAME(cpputSuiteRelationShipRegisterer )( \ parentSuiteName, \ *************** *** 214,221 **** */ #define CPPUT_REGISTER_SUITE_RELATIONSHIP_TO_DEFAULT( childSuiteName ) \ ! CPPUT_REGISTER_SUITE_RELATIONSHIP( \ ! CppUT::Registry::instance().getDefaultName(), \ ! childSuiteName ) } // namespace CppUT --- 225,285 ---- */ #define CPPUT_REGISTER_SUITE_RELATIONSHIP_TO_DEFAULT( childSuiteName ) \ ! static ::CppUT::SuiteRelationshipRegisterer \ ! CPPTL_MAKE_UNIQUE_NAME(cpputSuiteRelationShipRegisterer )( \ ! childSuiteName ) ! ! ! // Plain C function tests ! ! /*! \ingroup group_testregistry ! * \brief Helper object used to statically register a TestFactory. ! */ ! class TestFactoryRegisterer ! { ! public: ! typedef TestPtr (*FactoryFn)(); ! ! TestFactoryRegisterer( FactoryFn testFactory ) ! { ! testFactoryId_ = Registry::instance().addToDefault( CppTL::cfn0r<TestPtr>(testFactory) ); ! } + TestFactoryRegisterer( TestFactory testFactory ) + { + testFactoryId_ = Registry::instance().addToDefault( testFactory ); + } + + TestFactoryRegisterer( TestFactory testFactory, const std::string &parentSuiteName ) + { + testFactoryId_ = Registry::instance().add( parentSuiteName, testFactory ); + } + + TestFactoryRegisterer( FactoryFn testFactory, const std::string &parentSuiteName ) + { + testFactoryId_ = Registry::instance().add( parentSuiteName, CppTL::cfn0r<TestPtr>(testFactory) ); + } + + ~TestFactoryRegisterer() + { + Registry::instance().remove( testFactoryId_ ); + } + + private: + TestFactoryId testFactoryId_; + }; + + /*! \ingroup group_testregistry + * \brief Register the specified TestFactory in the default Registry suite. + */ + #define CPPUT_REGISTER_TESTFACTORY_TO_DEFAULT( testFactory ) \ + static ::CppUT::TestFactoryRegisterer \ + CPPTL_MAKE_UNIQUE_NAME(cpputTestFactoryRegisterer)( testFactory ) + + /*! \ingroup group_testregistry + * \brief Register the specified TestFactory in the specified Registry suite. + */ + #define CPPUT_REGISTER_TESTFACTORY_IN( testFactory, parentSuiteName ) \ + static ::CppUT::TestFactoryRegisterer \ + CPPTL_MAKE_UNIQUE_NAME(cpputTestFactoryRegisterer)( testFactory, parentSuiteName ) } // namespace CppUT |
From: Baptiste L. <bl...@us...> - 2007-08-14 17:42:18
|
Update of /cvsroot/cppunit/cppunit2/doc In directory sc8-pr-cvs4.sourceforge.net:/tmp/cvs-serv9695 Modified Files: SConscript coding_guidelines.dox Log Message: - worked-around scons installation of doxygen without testing its existence. Index: coding_guidelines.dox =================================================================== RCS file: /cvsroot/cppunit/cppunit2/doc/coding_guidelines.dox,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** coding_guidelines.dox 7 Sep 2006 22:45:50 -0000 1.1 --- coding_guidelines.dox 14 Aug 2007 17:42:14 -0000 1.2 *************** *** 261,272 **** \section cg_guidelines Guidelines - - config.h included in all headers (may be indirectly) - - DLL macros - - Forwards all classes and typedef in forwards.h - - RAII - standard interfaces, but CppTL::ConstString as attribute to ensure thread-safety. - - no member function template (use free function instead) - - no cast style function template, use CppTL::Type instead (link issue with VC6) - use assertions to check precondition (or intermediate condition in complex algorithm) ! */ --- 261,403 ---- \section cg_guidelines Guidelines - standard interfaces, but CppTL::ConstString as attribute to ensure thread-safety. - use assertions to check precondition (or intermediate condition in complex algorithm) ! \subsection cg_gl_headers Headers ! ! <DIV class='cg_rule'> ! <b>Rules:</b> All headers must either include the file <tt>config.</tt> of their library or include ! anything of the library (and therefore include the file <tt>config.</tt> indirectly). ! </DIV> ! ! <DIV class='cg_rule'> ! <b>Rules:</b> All classes and typedef must be exported using the <tt>XYZ_API</tt> macro, ! where <tt>XYZ</tt> is the library macro prefix (see [\ref cg_macro]). ! </DIV> ! ! <DIV class='cg_rule'> ! <b>Rules:</b> All classes must be forward declared in <tt>forwards.h</tt> header of the library. ! </DIV> ! ! \subsection cg_gl_using_namespace Using namespace directive ! ! <DIV class='cg_rule'> ! <b>Rules:</b> Never use the <tt>using namespace</tt> directive in any headers. ! </DIV> ! ! Recommendation: Avoid the <tt>using namespace</tt> directive in any sources. ! ! Rational: avoid poluting namespaces of sources including that header; enhance ! code readability by making obvious from which library a type/function originate from. ! ! \subsection cg_gl_language_feature C++ language feature restrictions ! ! \subsubsection cg_gl_nocastfn No cast style function template ! ! <DIV class='cg_rule'> ! <b>Rules:</b> All function template template argument must be deduced from ! parameters. Use CppTL::Type to explicitly pass the type as a parameter if needed. ! </DIV> ! ! Rationale: some older compilers only includes function parameters type in the ! function signature used for link, resulting in very strange bug if cast style ! function templtes are used. ! ! ! Example: ! \code ! // usage: get<int>( value); ! template<class ValueType> ! CppTL::Any &get( const CppTL::Any &value ); // BAD ! ! // usage: get(value,CppTL::Type<int>()); ! template<class ValueType> ! CppTL::Any &get( const CppTL::Any &value, ! CppTL::Type<ValueType> ); // OK ! \endcode ! ! \subsubsection cg_gl_mtf Template member functions ! ! <DIV class='cg_rule'> ! <b>Rules:</b> Do not use template member functions (e.g. template methods). ! </DIV> ! ! Template member functions should be avoided as they are not well supported by older ! compiler (e.g. VC++ 6.0). Usually, a template free functions can be used instead, taking ! as first parameter an instance of the class type. ! ! Examples: ! \code ! class Any ! { ! // Limited portability ! template<class ValueType> ! void set( const ValueType &newValue ); // BAD ! }; ! ! // Most portable, use class any as first parameter ! template<class ValueType> ! CppTL::Any &set( CppTL::Any &value, const ValueType &newValue ); // OK ! \endcode ! ! \subsection cg_gl_exception_safety Exception safety ! ! We distinguish three levels of exception safety that a (member/free) function may provide: ! - No exception safety guaranty: the function might leak some resources, and leave the application in an undetermined state if an exception is thrown ! - Weak exception safety guaranty: the function will not leak any resources, but leave the application in an undetermined state ! - Strong exception safety guaranty: the function will not leak any resources, and the application will be in the same state as before the function call if an exception is thrown. ! ! <DIV class='cg_rule'> ! <b>Rules:</b> All code should provide at least the weak exception safety guaranty. ! See [\ref cg_gl_raii] for tips on how to do that easily. ! </DIV> ! ! Strongly recommended reading: Exceptional C++, by Herb Sutter. This book contains ! very detailed examples explaining the some of the techniques exposed below (@todo). ! Many of the articles of this book started their life in Guru of the Week columns: ! http://www.gotw.ca/gotw/. ! ! ! \subsection cg_gl_exception_spec Exception Specifications ! ! Exception specification is the throw clause that specify the list of exception ! of function may throw (see example below). ! ! <DIV class='cg_rule'> ! <b>Rules:</b> Do not use throw specification unless required (subclassing std::exception for example). ! </DIV> ! ! Rationale: Compilers dont deal as the one would expect in face of exception specification. ! They often generate extra code and may disable inlining. ! See boost guideline for detailed explanation: ! http://www.boost.org/more/lib_guide.htm#Exception-specification. ! ! Recommendation: Document exception thrown by functions with comment ! ! Example: ! ! \code ! double getValueAt( int index ) throw(IndexError); // BAD ! ! // / \exception IndexError is raised if the provided index is invalid. ! double getValueAt( int index ); // GOOD ! \endcode ! ! ! \subsection cg_gl_raii Resource Acquisition Is Initialization principle (RAII) ! ! The essence of this principle is simple: ! - acquire the resource in the constructor of a resource holder object ! - release the resource in the destructor of that same object ! ! In the most simple case, resource is memory. A very common usage of this ! principle is probably for locking/unlocking exclusive lock. ! ! C++ guaranty that the destructor will always be called if the function returns or an ! exception is thrown. ! ! CppTL::ScopedPtr and CppTL::Mutex::ScopedLockGuard are examples of such objects. ! @todo ! ! ! */ \ No newline at end of file Index: SConscript =================================================================== RCS file: /cvsroot/cppunit/cppunit2/doc/SConscript,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** SConscript 16 Mar 2007 22:41:38 -0000 1.2 --- SConscript 14 Aug 2007 17:42:14 -0000 1.3 *************** *** 2,6 **** import os.path ! if 'doxygen' in env['TOOLS']: doc_topdir = env['ROOTBUILD_DIR'] env['DOXYGEN_DOC_TOP_DIR'] = doc_topdir --- 2,6 ---- import os.path ! if env['HAS_DOXYGEN']: doc_topdir = env['ROOTBUILD_DIR'] env['DOXYGEN_DOC_TOP_DIR'] = doc_topdir |
From: Baptiste L. <bl...@us...> - 2007-08-14 17:31:13
|
Update of /cvsroot/cppunit/cppunit2/src/cpputtest In directory sc8-pr-cvs4.sourceforge.net:/tmp/cvs-serv5281/src/cpputtest Modified Files: assertenumtest.cpp assertstringtest.cpp commandlineoptionstest.cpp commandlineoptionstest.h mocktestlistener.h smallmaptest.cpp smallmaptest.h testinfotest.cpp Log Message: Modified assertion implementation to force evaluation of user condition expression first, while preserving delegation to function, overloading and optional parameters feature. See CPPUT_BEGIN_ASSERTION_MACRO() documentation in testinfo.h for an example to update your custom assertion code. New implementation rely on operator evaluation order and operator overloading. The trick is documented in CPPUT_BEGIN_ASSERTION_MACRO(). Index: smallmaptest.cpp =================================================================== RCS file: /cvsroot/cppunit/cppunit2/src/cpputtest/smallmaptest.cpp,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** smallmaptest.cpp 6 Sep 2006 19:23:26 -0000 1.2 --- smallmaptest.cpp 14 Aug 2007 17:30:52 -0000 1.3 *************** *** 18,28 **** ! void SmallMapTest::checkEraseRange( int minSeed, int maxSeed, int beginRange, int endRange) { ! CppUT::checkTrue( beginRange >= minSeed && beginRange <= maxSeed ); ! CppUT::checkTrue( endRange >= minSeed && endRange <= maxSeed ); ! CppUT::checkTrue( beginRange <= endRange ); ! CppUT::checkTrue( minSeed <= maxSeed ); SmallMapIntInt sm; for ( int generator = minSeed; generator < maxSeed; ++generator ) --- 18,30 ---- ! CppUT::CheckerResult SmallMapTest::checkEraseRange( int minSeed, int maxSeed, int beginRange, int endRange) { ! CppUT::CheckerResult result; ! result.compose( CppUT::checkTrue( beginRange >= minSeed && beginRange <= maxSeed ) ); ! result.compose( CppUT::checkTrue( endRange >= minSeed && endRange <= maxSeed ) ); ! result.compose( CppUT::checkTrue( beginRange <= endRange ) ); ! result.compose( CppUT::checkTrue( minSeed <= maxSeed ) ); ! // @todo fix this and skip following if result has failed. SmallMapIntInt sm; for ( int generator = minSeed; generator < maxSeed; ++generator ) *************** *** 34,46 **** CppTL::ConstString msg = "Checking key: " + CppTL::toString( checker ); int expected = (checker >= beginRange && checker < endRange) ? 0 : 1; ! CppUT::checkEquals( expected, sm.count(checker), msg ); } ! CppUT::checkEquals( maxSeed-minSeed - (endRange-beginRange), sm.size() ); } ! void SmallMapTest::checkEraseIterator( int minSeed, int maxSeed, int value ) { CppUT::checkTrue( minSeed <= maxSeed && value >= minSeed && value < maxSeed ); SmallMapIntInt sm; --- 36,50 ---- CppTL::ConstString msg = "Checking key: " + CppTL::toString( checker ); int expected = (checker >= beginRange && checker < endRange) ? 0 : 1; ! result.compose( CppUT::checkEquals( expected, sm.count(checker), msg ) ); } ! result.compose( CppUT::checkEquals( maxSeed-minSeed - (endRange-beginRange), sm.size() ) ); ! return result; } ! CppUT::CheckerResult SmallMapTest::checkEraseIterator( int minSeed, int maxSeed, int value ) { + CppUT::CheckerResult result; CppUT::checkTrue( minSeed <= maxSeed && value >= minSeed && value < maxSeed ); SmallMapIntInt sm; *************** *** 52,58 **** CppTL::ConstString msg = "Checking key: " + CppTL::toString( checker ); int expected = (checker == value) ? 0 : 1; ! CppUT::checkEquals( expected, sm.count(checker), msg ); } ! CppUT::checkEquals( maxSeed-minSeed - 1, sm.size() ); } --- 56,63 ---- CppTL::ConstString msg = "Checking key: " + CppTL::toString( checker ); int expected = (checker == value) ? 0 : 1; ! result.compose( CppUT::checkEquals( expected, sm.count(checker), msg ) ); } ! result.compose( CppUT::checkEquals( maxSeed-minSeed - 1, sm.size() ) ); ! return result; } Index: commandlineoptionstest.h =================================================================== RCS file: /cvsroot/cppunit/cppunit2/src/cpputtest/commandlineoptionstest.h,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** commandlineoptionstest.h 13 Nov 2005 10:12:01 -0000 1.4 --- commandlineoptionstest.h 14 Aug 2007 17:30:52 -0000 1.5 *************** *** 51,59 **** private: ! void checkParse( CppUTTools::CommandLineOptions::OptionsDescription &description, ! const char *argv[] ); ! void checkParseBadOption( CppUTTools::CommandLineOptions::OptionsDescription &description, ! const char *argv[], ! const CppTL::ConstString &badOptionName ); enum LogLevel { --- 51,59 ---- private: ! CppUT::CheckerResult checkParse( CppUTTools::CommandLineOptions::OptionsDescription &description, ! const char *argv[] ); ! CppUT::CheckerResult checkParseBadOption( CppUTTools::CommandLineOptions::OptionsDescription &description, ! const char *argv[], ! const CppTL::ConstString &badOptionName ); enum LogLevel { Index: assertenumtest.cpp =================================================================== RCS file: /cvsroot/cppunit/cppunit2/src/cpputtest/assertenumtest.cpp,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** assertenumtest.cpp 23 Feb 2005 23:09:29 -0000 1.3 --- assertenumtest.cpp 14 Aug 2007 17:30:52 -0000 1.4 *************** *** 41,62 **** { CPPUT_ASSERT_ASSERTION_FAIL(( CPPUT_ASSERT_SEQUENCE_EQUAL( CppTL::Enum::container( vEmpty_ ), ! CppTL::Enum::container( v123_ ) ) )); CPPUT_ASSERT_ASSERTION_FAIL(( CPPUT_ASSERT_SEQUENCE_EQUAL( CppTL::Enum::container( v123_ ), ! CppTL::Enum::container( v321_ ) ) )); CPPUT_ASSERT_ASSERTION_FAIL(( CPPUT_ASSERT_SEQUENCE_EQUAL( CppTL::Enum::container( v123_ ), ! CppTL::Enum::container( v122_ ) ) )); CPPUT_ASSERT_ASSERTION_FAIL(( CPPUT_ASSERT_SEQUENCE_EQUAL( CppTL::Enum::container( v123_ ), ! CppTL::Enum::container( v4321_ ) ) )); CPPUT_ASSERT_ASSERTION_FAIL(( CPPUT_ASSERT_SEQUENCE_EQUAL( CppTL::Enum::container( v123_ ), ! CppTL::Enum::container( v1234_ ) ) )); CPPUT_ASSERT_ASSERTION_FAIL(( CPPUT_ASSERT_SEQUENCE_EQUAL( CppTL::Enum::container( v1234_ ), ! CppTL::Enum::container( v123_ ) ) )); CPPUT_ASSERT_ASSERTION_PASS(( CPPUT_ASSERT_SEQUENCE_EQUAL( CppTL::Enum::container( vEmpty_ ), ! CppTL::Enum::container( vEmpty_ ) ) )); CPPUT_ASSERT_ASSERTION_PASS(( CPPUT_ASSERT_SEQUENCE_EQUAL( CppTL::Enum::container( v122_ ), ! CppTL::Enum::container( v122_ ) ) )); CPPUT_ASSERT_ASSERTION_PASS(( CPPUT_ASSERT_SEQUENCE_EQUAL( CppTL::Enum::container( v1234_ ), ! CppTL::Enum::container( v1234_ ) ) )); } --- 41,62 ---- { CPPUT_ASSERT_ASSERTION_FAIL(( CPPUT_ASSERT_SEQUENCE_EQUAL( CppTL::Enum::container( vEmpty_ ), ! CppTL::Enum::container( v123_ ) ) )); CPPUT_ASSERT_ASSERTION_FAIL(( CPPUT_ASSERT_SEQUENCE_EQUAL( CppTL::Enum::container( v123_ ), ! CppTL::Enum::container( v321_ ) ) )); CPPUT_ASSERT_ASSERTION_FAIL(( CPPUT_ASSERT_SEQUENCE_EQUAL( CppTL::Enum::container( v123_ ), ! CppTL::Enum::container( v122_ ) ) )); CPPUT_ASSERT_ASSERTION_FAIL(( CPPUT_ASSERT_SEQUENCE_EQUAL( CppTL::Enum::container( v123_ ), ! CppTL::Enum::container( v4321_ ) ) )); CPPUT_ASSERT_ASSERTION_FAIL(( CPPUT_ASSERT_SEQUENCE_EQUAL( CppTL::Enum::container( v123_ ), ! CppTL::Enum::container( v1234_ ) ) )); CPPUT_ASSERT_ASSERTION_FAIL(( CPPUT_ASSERT_SEQUENCE_EQUAL( CppTL::Enum::container( v1234_ ), ! CppTL::Enum::container( v123_ ) ) )); CPPUT_ASSERT_ASSERTION_PASS(( CPPUT_ASSERT_SEQUENCE_EQUAL( CppTL::Enum::container( vEmpty_ ), ! CppTL::Enum::container( vEmpty_ ) ) )); CPPUT_ASSERT_ASSERTION_PASS(( CPPUT_ASSERT_SEQUENCE_EQUAL( CppTL::Enum::container( v122_ ), ! CppTL::Enum::container( v122_ ) ) )); CPPUT_ASSERT_ASSERTION_PASS(( CPPUT_ASSERT_SEQUENCE_EQUAL( CppTL::Enum::container( v1234_ ), ! CppTL::Enum::container( v1234_ ) ) )); } Index: commandlineoptionstest.cpp =================================================================== RCS file: /cvsroot/cppunit/cppunit2/src/cpputtest/commandlineoptionstest.cpp,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** commandlineoptionstest.cpp 27 Feb 2005 10:17:06 -0000 1.5 --- commandlineoptionstest.cpp 14 Aug 2007 17:30:52 -0000 1.6 *************** *** 28,35 **** ! void CommandLineOptionsTest::checkParse( CommandLineOptions::OptionsDescription &description, const char *argv[] ) { delete values_; values_ = new CommandLineOptions::OptionsValues(); --- 28,36 ---- ! CppUT::CheckerResult CommandLineOptionsTest::checkParse( CommandLineOptions::OptionsDescription &description, const char *argv[] ) { + CppUT::CheckerResult result; // What can make the test fails ??? delete values_; values_ = new CommandLineOptions::OptionsValues(); *************** *** 42,64 **** values_->validate( description ); values_->store( description ); } ! void CommandLineOptionsTest::checkParseBadOption( CommandLineOptions::OptionsDescription &description, const char *argv[], const CppTL::ConstString &badOptionName ) { try { ! checkParse( description, argv ); ! CppUT::fail( "Bad option '" + badOptionName + "' not detected" ); } catch ( const CommandLineOptions::CommandLineParseError &e ) { ! CppUT::checkEquals( CommandLineOptions::CommandLineParseError::invalidOptionName, ! e.cause() ); ! CppUT::checkEquals( badOptionName, e.optionName() ); } } --- 43,69 ---- values_->validate( description ); values_->store( description ); + return result; } ! CppUT::CheckerResult CommandLineOptionsTest::checkParseBadOption( CommandLineOptions::OptionsDescription &description, const char *argv[], const CppTL::ConstString &badOptionName ) { + CppUT::CheckerResult result; try { ! result = checkParse( description, argv ); ! result.setFailed(); ! result.message_.add( "Bad option '" + badOptionName + "' not detected" ); } catch ( const CommandLineOptions::CommandLineParseError &e ) { ! result.compose( CppUT::checkEquals( CommandLineOptions::CommandLineParseError::invalidOptionName, ! e.cause() ) ); ! result.compose( CppUT::checkEquals( badOptionName, e.optionName() ) ); } + return result; } Index: smallmaptest.h =================================================================== RCS file: /cvsroot/cppunit/cppunit2/src/cpputtest/smallmaptest.h,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** smallmaptest.h 5 Jun 2006 12:09:26 -0000 1.1 --- smallmaptest.h 14 Aug 2007 17:30:52 -0000 1.2 *************** *** 34,39 **** private: ! void checkEraseRange( int minSeed, int maxSeed, int beginRange, int endRange); ! void checkEraseIterator( int minSeed, int maxSeed, int value ); }; --- 34,39 ---- private: ! CppUT::CheckerResult checkEraseRange( int minSeed, int maxSeed, int beginRange, int endRange); ! CppUT::CheckerResult checkEraseIterator( int minSeed, int maxSeed, int value ); }; Index: mocktestlistener.h =================================================================== RCS file: /cvsroot/cppunit/cppunit2/src/cpputtest/mocktestlistener.h,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** mocktestlistener.h 4 Aug 2004 06:43:57 -0000 1.3 --- mocktestlistener.h 14 Aug 2007 17:30:52 -0000 1.4 *************** *** 25,29 **** { ++testResultCount_; ! if ( result.failed() ) ++testFailedCount_; else --- 25,29 ---- { ++testResultCount_; ! if ( result.setFailed() ) ++testFailedCount_; else Index: assertstringtest.cpp =================================================================== RCS file: /cvsroot/cppunit/cppunit2/src/cpputtest/assertstringtest.cpp,v retrieving revision 1.6 retrieving revision 1.7 diff -C2 -d -r1.6 -r1.7 *** assertstringtest.cpp 1 Feb 2006 18:26:17 -0000 1.6 --- assertstringtest.cpp 14 Aug 2007 17:30:52 -0000 1.7 *************** *** 7,10 **** --- 7,11 ---- #endif + namespace { *************** *** 132,133 **** --- 133,140 ---- } + + + + + + Index: testinfotest.cpp =================================================================== RCS file: /cvsroot/cppunit/cppunit2/src/cpputtest/testinfotest.cpp,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** testinfotest.cpp 13 Nov 2005 10:12:01 -0000 1.2 --- testinfotest.cpp 14 Aug 2007 17:30:52 -0000 1.3 *************** *** 25,40 **** } ! void check( int assertion, int failed, int ignored, CppUT::TestStatus::Status status = CppUT::TestStatus::passed ) { ! CppUT::checkEquals( assertion, status_.assertionCount(), "bad assertion count" ); ! CppUT::checkEquals( failed, status_.failedAssertionCount(), "bad failed assertion count" ); ! CppUT::checkEquals( ignored, status_.ignoredFailureCount(), "bad ignored failure count" ); ! CppUT::checkEquals( status, status_.status(), "bad status" ); ! ! // restore original status ! CppUT::TestInfo::threadInstance().testStatus() = status_; } --- 25,39 ---- } ! CppUT::CheckerResult check( int assertion, int failed, int ignored, CppUT::TestStatus::Status status = CppUT::TestStatus::passed ) { ! CppUT::CheckerResult result; ! result.compose( CppUT::checkEquals( assertion, status_.assertionCount(), "bad assertion count" ) ); ! result.compose( CppUT::checkEquals( failed, status_.failedAssertionCount(), "bad failed assertion count" ) ); ! result.compose( CppUT::checkEquals( ignored, status_.ignoredFailureCount(), "bad ignored failure count" ) ); ! result.compose( CppUT::checkEquals( status, status_.status(), "bad status" ) ); ! return result; } *************** *** 105,110 **** } ! void verify() { std::string expected; std::string actual; --- 104,110 ---- } ! CppUT::CheckerResult verify() { + CppUT::CheckerResult result; std::string expected; std::string actual; *************** *** 119,131 **** if ( index < minCount || expectedEvents_.size() != actualEvents_.size() ) { ! CppUT::Message message( "Expected and actual test event sequences did not match" ); std::string indexStr = CppTL::toString( index ).c_str(); ! message.add( "Difference at index " + indexStr ); ! message.add( "Expected:\n" + toString( expectedEvents_ ) ); ! message.add( "Actual :\n" + toString( actualEvents_ ) ); ! CppUT::fail( message ); } reset(); } --- 119,132 ---- if ( index < minCount || expectedEvents_.size() != actualEvents_.size() ) { ! result.setFailed(); ! result.message_ = CppUT::Message( "Expected and actual test event sequences did not match" ); std::string indexStr = CppTL::toString( index ).c_str(); ! result.message_.add( "Difference at index " + indexStr ); ! result.message_.add( "Expected:\n" + toString( expectedEvents_ ) ); ! result.message_.add( "Actual :\n" + toString( actualEvents_ ) ); } reset(); + return result; } *************** *** 160,167 **** // Assumes a local variable named 'count of type AssertionCount is declared ! #define TESTINFO_ASSERT_STATUS_IS \ count.captureStatus(), /* capture test statistics */ \ CPPUT_BEGIN_ASSERTION_MACRO() /* warning: change test statistics */ \ ! count.check #define TESTINFO_IGNORE( assertion ) \ --- 161,175 ---- // Assumes a local variable named 'count of type AssertionCount is declared ! #define TESTINFO_ASSERT_STATISTICS_ARE( assertion, failed, ignore ) \ count.captureStatus(), /* capture test statistics */ \ CPPUT_BEGIN_ASSERTION_MACRO() /* warning: change test statistics */ \ ! count.check( assertion, failed, ignore ); \ ! CppUT::TestInfo::threadInstance().testStatus() = count.status_; ! ! #define TESTINFO_ASSERT_STATUS_IS( assertion, failed, ignore, status ) \ ! count.captureStatus(), /* capture test statistics */ \ ! CPPUT_BEGIN_ASSERTION_MACRO() /* warning: change test statistics */ \ ! count.check( assertion, failed, ignore, status ); \ ! CppUT::TestInfo::threadInstance().testStatus() = count.status_; #define TESTINFO_IGNORE( assertion ) \ *************** *** 180,189 **** count.resetStatistics(); CPPUT_ASSERT( true ); ! TESTINFO_ASSERT_STATUS_IS( 1, 0, 0 ); // successful checking assertion count.resetStatistics(); CPPUT_CHECK( true ); ! TESTINFO_ASSERT_STATUS_IS( 1, 0, 0 ); // failing aborting assertion --- 188,197 ---- count.resetStatistics(); CPPUT_ASSERT( true ); ! TESTINFO_ASSERT_STATISTICS_ARE( 1, 0, 0 ); // successful checking assertion count.resetStatistics(); CPPUT_CHECK( true ); ! TESTINFO_ASSERT_STATISTICS_ARE( 1, 0, 0 ); // failing aborting assertion *************** *** 210,219 **** count.resetStatistics(); CPPUT_IGNORE_FAILURE(( CPPUT_ASSERT( false ) )); ! TESTINFO_ASSERT_STATUS_IS( 1, 0, 1 ); // ignored failing checking assertion count.resetStatistics(); CPPUT_IGNORE_FAILURE(( CPPUT_CHECK( false ) )); ! TESTINFO_ASSERT_STATUS_IS( 1, 0, 1 ); // skipped test --- 218,227 ---- count.resetStatistics(); CPPUT_IGNORE_FAILURE(( CPPUT_ASSERT( false ) )); ! TESTINFO_ASSERT_STATISTICS_ARE( 1, 0, 1 ); // ignored failing checking assertion count.resetStatistics(); CPPUT_IGNORE_FAILURE(( CPPUT_CHECK( false ) )); ! TESTINFO_ASSERT_STATISTICS_ARE( 1, 0, 1 ); // skipped test |
From: Baptiste L. <bl...@us...> - 2007-08-14 17:31:12
|
Update of /cvsroot/cppunit/cppunit2/makefiles/vs71 In directory sc8-pr-cvs4.sourceforge.net:/tmp/cvs-serv5281/makefiles/vs71 Modified Files: cpptl_lib.vcproj cpput_lib.vcproj Log Message: Modified assertion implementation to force evaluation of user condition expression first, while preserving delegation to function, overloading and optional parameters feature. See CPPUT_BEGIN_ASSERTION_MACRO() documentation in testinfo.h for an example to update your custom assertion code. New implementation rely on operator evaluation order and operator overloading. The trick is documented in CPPUT_BEGIN_ASSERTION_MACRO(). Index: cpput_lib.vcproj =================================================================== RCS file: /cvsroot/cppunit/cppunit2/makefiles/vs71/cpput_lib.vcproj,v retrieving revision 1.6 retrieving revision 1.7 diff -C2 -d -r1.6 -r1.7 *** cpput_lib.vcproj 3 Sep 2006 07:15:49 -0000 1.6 --- cpput_lib.vcproj 14 Aug 2007 17:30:52 -0000 1.7 *************** *** 153,161 **** --- 153,176 ---- Filter=""> <File + RelativePath="..\..\doc\coding_guidelines.dox"> + </File> + <File RelativePath="..\..\doc\cpput.dox"> </File> <File + RelativePath="..\..\doc\cpput_todo.dox"> + </File> + <File + RelativePath="..\..\doc\custom.css"> + </File> + <File RelativePath="..\..\doc\doxyfile.in"> </File> + <File + RelativePath="..\..\doc\footer.html"> + </File> + <File + RelativePath="..\..\doc\header.html"> + </File> </Filter> <File Index: cpptl_lib.vcproj =================================================================== RCS file: /cvsroot/cppunit/cppunit2/makefiles/vs71/cpptl_lib.vcproj,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** cpptl_lib.vcproj 5 Jun 2006 12:02:56 -0000 1.3 --- cpptl_lib.vcproj 14 Aug 2007 17:30:52 -0000 1.4 *************** *** 223,226 **** --- 223,229 ---- </File> <File + RelativePath="..\..\include\cpptl\enum2string.h"> + </File> + <File RelativePath="..\..\include\cpptl\smallmap.h"> </File> |
From: Baptiste L. <bl...@us...> - 2007-08-14 17:31:12
|
Update of /cvsroot/cppunit/cppunit2/scons-tools In directory sc8-pr-cvs4.sourceforge.net:/tmp/cvs-serv5281/scons-tools Modified Files: doxygen.py Log Message: Modified assertion implementation to force evaluation of user condition expression first, while preserving delegation to function, overloading and optional parameters feature. See CPPUT_BEGIN_ASSERTION_MACRO() documentation in testinfo.h for an example to update your custom assertion code. New implementation rely on operator evaluation order and operator overloading. The trick is documented in CPPUT_BEGIN_ASSERTION_MACRO(). Index: doxygen.py =================================================================== RCS file: /cvsroot/cppunit/cppunit2/scons-tools/doxygen.py,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** doxygen.py 16 Mar 2007 22:41:39 -0000 1.3 --- doxygen.py 14 Aug 2007 17:30:52 -0000 1.4 *************** *** 18,36 **** Doxygen tool. This is currently for Doxygen 1.4.6. """ ! doxyfile_builder = env.Builder( ! action = env.Action("cd ${SOURCE.dir} && ${DOXYGEN} ${SOURCE.file}", ! varlist=['$SOURCES']), ! emitter = DoxyEmitter, ! single_source = True, ! ) ! ! env.Append(BUILDERS = { ! 'Doxygen': doxyfile_builder, ! }) ! env.AppendUnique( ! DOXYGEN = 'doxygen', ! ) def exists(env): --- 18,37 ---- Doxygen tool. This is currently for Doxygen 1.4.6. """ + env['HAS_DOXYGEN'] = exists( env ) + if env['HAS_DOXYGEN']: + doxyfile_builder = env.Builder( + action = env.Action("cd ${SOURCE.dir} && ${DOXYGEN} ${SOURCE.file}", + varlist=['$SOURCES']), + emitter = DoxyEmitter, + single_source = True, + ) ! env.Append(BUILDERS = { ! 'Doxygen': doxyfile_builder, ! }) ! env.AppendUnique( ! DOXYGEN = 'doxygen', ! ) def exists(env): |
From: Baptiste L. <bl...@us...> - 2007-08-14 17:31:12
|
Update of /cvsroot/cppunit/cppunit2/include/cpput In directory sc8-pr-cvs4.sourceforge.net:/tmp/cvs-serv5281/include/cpput Modified Files: assertcommon.h assertenum.h assertstring.h forwards.h resource.h testinfo.h Log Message: Modified assertion implementation to force evaluation of user condition expression first, while preserving delegation to function, overloading and optional parameters feature. See CPPUT_BEGIN_ASSERTION_MACRO() documentation in testinfo.h for an example to update your custom assertion code. New implementation rely on operator evaluation order and operator overloading. The trick is documented in CPPUT_BEGIN_ASSERTION_MACRO(). Index: testinfo.h =================================================================== RCS file: /cvsroot/cppunit/cppunit2/include/cpput/testinfo.h,v retrieving revision 1.20 retrieving revision 1.21 diff -C2 -d -r1.20 -r1.21 *** testinfo.h 13 Nov 2005 23:02:16 -0000 1.20 --- testinfo.h 14 Aug 2007 17:30:52 -0000 1.21 *************** *** 10,13 **** --- 10,14 ---- namespace CppUT { + /*! \brief Exception thrown when an aborting assertion fails. */ *************** *** 46,54 **** public: SourceLocation( const char *file = 0, ! unsigned int line =0, ! const char *function = 0 ) : file_( file ) , line_( line ) - , function_( function ) { } --- 47,53 ---- public: SourceLocation( const char *file = 0, ! unsigned int line =0 ) : file_( file ) , line_( line ) { } *************** *** 57,61 **** { file_ = 0; - function_ = 0; line_ = 0; } --- 56,59 ---- *************** *** 67,71 **** const char *file_; - const char *function_; unsigned int line_; }; --- 65,68 ---- *************** *** 166,169 **** --- 163,307 ---- + /// All checker functions used in assert and check macro should returns an object of this type. + class CheckerResult + { + public: + CheckerResult() + : status_( TestStatus::passed ) + , message_( "" ) + { + } + + void setFailed() + { + status_ = TestStatus::failed; + } + + /// Compose current result with another once. Used to chain checker functions. + /// If other status is skipped, then current status become skipped; + /// otherwise if other status is failed, then current status become failed; + /// otherwise current status remained unchanged. + /// \c other message is appended at the end of the current message. + void compose( const CheckerResult &other ) + { + switch ( status_ ) + { + case TestStatus::failed: + case TestStatus::passed: + if ( other.status_ != TestStatus::passed ) + status_ = other.status_; + break; + case TestStatus::skipped: + break; + default: + CPPTL_DEBUG_ASSERT_UNREACHABLE; + } + message_.extend( other.message_ ); + } + + TestStatus::Status status_; + Message message_; + }; + + namespace Impl { + + /// Implementation detail of CPPUT_BEGIN_ASSERTION_MACRO() & CPPUT_BEGIN_CHECKING_MACRO(). + class CheckerLineLocation + { + public: + const CheckerResult *result_; + unsigned long line_; + }; + + struct FileLocationMarker {}; + + + /// Implementation detail of CPPUT_BEGIN_ASSERTION_MACRO() & CPPUT_BEGIN_CHECKING_MACRO(). + class CheckerFileLocation + { + public: + const CheckerLineLocation *lineData_; + const char *file_; + }; + + /// Implementation detail of CPPUT_BEGIN_ASSERTION_MACRO() & CPPUT_BEGIN_CHECKING_MACRO(). + class AssertionTrigger + { + public: + static AssertionTrigger aborting; + static AssertionTrigger checking; + + AssertionTrigger &operator +=( const CheckerFileLocation &fileLocation ); + }; + + } // end of namespace Impl + + + /*! Starts an aborting assertion macro (throw an exception on assertion failure). + * \ingroup group_custom_assertions + * This macro provides the following properties for assertion: + * - condition is evaluated first to ease debugging of unit tests + * - assertion can take a variable number of parameters (typicaly an optional message). + * + * Typically, as little code as possible is put in assertion macro code to ease debugging. + * Usually, an assertion macro just start a function call: + * \code + * #define CPPUT_ASSERT_IS_EVEN \ + * CPPUT_BEGIN_ASSERTION_MACRO() checkIsEven + * #define CPPUT_ASSERT_IS_EVEN \ + * CPPUT_BEGIN_CHECKING_MACRO() checkIsEven + * + * CheckerResult checkIsEven( int x, const char *message = "" ) + * { + * CheckerResult result; + * if ( x % 2 != 0 ) + * { + * result.setFailed(); + * result.message_.add( message ); + * } + * return result; + * } + * void someTest() + * { + * CPPUT_CHECK_IS_EVEN( 1 ); + * CPPUT_CHECK_IS_EVEN( 2 ); + * } + * \endcode + * + * In the example above, both a checking and asserting macro have been implemented. The code to + * check the assertion is factorized in a single function than can take a variable number of parameters + * and be easily debugged. + * + * Implementation notes: + * + * This is achieved using a trick based on operator evaluation order described below: + * Basicaly an assertion has the following form: + * AssertionTrigger::aborting += __FILE__ + __LINE__ / checkCondition( condition expression ); + * For simplicity, we will use the following compact form for reference : + * x += f + l / checkCond( condition ); + * checkCond must returns an CheckerResult which as overloaded operator /. + * operator = evaluate right to left + * operator + evaluate left to right + * operator / evaluate left to right and as priority over +. + * So 'condition expression' is evaluted first, then checkCond(condition) is evaluated. + * Then 'l / checkCond(condition)' is evaluated, + * followed by f + l/ checkCond(condition) which yield to an CheckerFileLocation. Finally, + * x += f + l / checkCond( condition ) is evaluated, basically calling AssertionTrigger + * overloaded operator += with the final CheckerFileLocation that contains details about the assertion, + * as well as file/line location. + * \see CPPUT_BEGIN_CHECKING_MACRO. + */ + # define CPPUT_BEGIN_ASSERTION_MACRO() \ + CppUT::Impl::AssertionTrigger::aborting += (const CppUT::Impl::FileLocationMarker *)__FILE__ + __LINE__ / + + /*! Starts a checking assertion macro (continue test execution even on failure). + * \ingroup group_custom_assertions + * \see CPPUT_BEGIN_ASSERTION_MACRO() for example and implementation notes. + */ + # define CPPUT_BEGIN_CHECKING_MACRO() \ + CppUT::Impl::AssertionTrigger::checking += (const CppUT::Impl::FileLocationMarker *)__FILE__ + __LINE__ / + + + /*! \brief Provides notification of failed assertions and log events. */ *************** *** 248,259 **** TestStatus &testStatus(); ! void newAssertion( AssertionType type, ! const char *fileName, ! unsigned int lineNumber, ! const char *functionName = 0 ); ! ! Assertion ¤tAssertion(); ! ! void realizeAssertion(); void handleUnexpectedException( const Assertion &fault ); --- 386,393 ---- TestStatus &testStatus(); ! void handleAssertion( const char *file, ! unsigned int line, ! const CheckerResult &result, ! bool isAbortingAssertion ); void handleUnexpectedException( const Assertion &fault ); *************** *** 271,294 **** }; - /*! \brief Returns the current assertion. - * \ingroup group_custom_assertions - * \sa TestInfo - */ - Assertion &CPPUT_API currentAssertion(); - - /*! \brief Realizes the current assertion. - * \ingroup group_custom_assertions - * Pass the current assertion to the TestResultUpdater and set the test status to - * TestStatus::failed. - * - * If the current assertion type is abortingAssertion then an AbortingAssertionException - * is thrown. - * - * @exception AbortingAssertionException If assertionType was set to - * abortingAssertion. - * \sa TestInfo - */ - void CPPUT_API realizeAssertion(); - /*! \brief Log an event. * \sa TestInfo --- 405,408 ---- *************** *** 314,317 **** --- 428,449 ---- + inline CppUT::Impl::CheckerLineLocation operator /( unsigned long line, const CppUT::CheckerResult &result ) + { + CppUT::Impl::CheckerLineLocation lineData; + lineData.result_ = &result; + lineData.line_ = line; + return lineData; + } + + + inline CppUT::Impl::CheckerFileLocation operator +( const CppUT::Impl::FileLocationMarker *file, const CppUT::Impl::CheckerLineLocation &lineData ) + { + CppUT::Impl::CheckerFileLocation fileData; + fileData.file_ = (const char *)file; + fileData.lineData_ = &lineData; + return fileData; + } + + #endif // CPPUT_TESTINFO_H_INCLUDED Index: assertenum.h =================================================================== RCS file: /cvsroot/cppunit/cppunit2/include/cpput/assertenum.h,v retrieving revision 1.12 retrieving revision 1.13 diff -C2 -d -r1.12 -r1.13 *** assertenum.h 13 Nov 2005 10:12:01 -0000 1.12 --- assertenum.h 14 Aug 2007 17:30:52 -0000 1.13 *************** *** 127,142 **** ,class ActualStringizer ,class EqualityPredicate> ! void checkCustomHeterogeneousSequenceEqual( const ExpectedEnumerator &expected, ! const ActualEnumerator &actual, ! ExpectedStringizer expectedStringizer, ! ActualStringizer actualStringizer, ! EqualityPredicate comparator, ! const Message &message ) { unsigned int diffIndex = Impl::getSequenceDiffIndex( expected, actual, comparator ); if ( diffIndex == Impl::noDifference ) ! return; typedef CppTL::SliceEnumerator<ExpectedEnumerator> ExpectedEnumeratorSlice; --- 127,143 ---- ,class ActualStringizer ,class EqualityPredicate> ! CheckerResult checkCustomHeterogeneousSequenceEqual( const ExpectedEnumerator &expected, ! const ActualEnumerator &actual, ! ExpectedStringizer expectedStringizer, ! ActualStringizer actualStringizer, ! EqualityPredicate comparator, ! const Message &message ) { + CheckerResult result; unsigned int diffIndex = Impl::getSequenceDiffIndex( expected, actual, comparator ); if ( diffIndex == Impl::noDifference ) ! return result; typedef CppTL::SliceEnumerator<ExpectedEnumerator> ExpectedEnumeratorSlice; *************** *** 146,160 **** ActualEnumeratorSlice actualDiff = CppTL::Enum::slice( actual, diffIndex ); ! Message newMessage( message ); ! newMessage.add( translate( "Sequences are not identical." ) ); ! newMessage.add( translate( "Divergence position (0 based): " ) + stringize(diffIndex) ); if ( common.is_open() ) ! newMessage.add( translate( "Common:\n" ) + enumToStringCustom(common, ! expectedStringizer) ); ! newMessage.add( translate( "Expected:\n" ) + enumToStringCustom(expectedDiff, ! expectedStringizer) ); ! newMessage.add( translate( "Actual:\n" ) + enumToStringCustom(actualDiff, ! actualStringizer) ); ! fail( newMessage ); } --- 147,162 ---- ActualEnumeratorSlice actualDiff = CppTL::Enum::slice( actual, diffIndex ); ! result.setFailed(); ! result.message_ = message; ! result.message_.add( translate( "Sequences are not identical." ) ); ! result.message_.add( translate( "Divergence position (0 based): " ) + stringize(diffIndex) ); if ( common.is_open() ) ! result.message_.add( translate( "Common:\n" ) + enumToStringCustom(common, ! expectedStringizer) ); ! result.message_.add( translate( "Expected:\n" ) + enumToStringCustom(expectedDiff, ! expectedStringizer) ); ! result.message_.add( translate( "Actual:\n" ) + enumToStringCustom(actualDiff, ! actualStringizer) ); ! return result; } *************** *** 162,174 **** ,class StringizerType ,class EqualityPredicate> ! void checkCustomSequenceEqual( const EnumeratorType &expected, ! const EnumeratorType &actual, ! StringizerType stringizer, ! EqualityPredicate comparator, ! const Message &message ) { ! checkCustomHeterogeneousSequenceEqual( expected, actual, ! stringizer, stringizer, ! comparator, message ); } --- 164,176 ---- ,class StringizerType ,class EqualityPredicate> ! CheckerResult checkCustomSequenceEqual( const EnumeratorType &expected, ! const EnumeratorType &actual, ! StringizerType stringizer, ! EqualityPredicate comparator, ! const Message &message ) { ! return checkCustomHeterogeneousSequenceEqual( expected, actual, ! stringizer, stringizer, ! comparator, message ); } *************** *** 176,189 **** ,class StringizerType ,class EqualityPredicate> ! void checkCustomStringSequenceEqual( const EnumeratorType &expected, ! const EnumeratorType &actual, ! StringizerType stringizer, ! const Message &message = Message() ) { typedef CPPTL_TYPENAME EnumeratorType::value_type ValueType; DefaultComparator<ValueType,ValueType> comparator; ! checkCustomHeterogeneousSequenceEqual( expected, actual, ! stringizer, stringizer, ! comparator, message ); } --- 178,191 ---- ,class StringizerType ,class EqualityPredicate> ! CheckerResult checkCustomStringSequenceEqual( const EnumeratorType &expected, ! const EnumeratorType &actual, ! StringizerType stringizer, ! const Message &message = Message() ) { typedef CPPTL_TYPENAME EnumeratorType::value_type ValueType; DefaultComparator<ValueType,ValueType> comparator; ! return checkCustomHeterogeneousSequenceEqual( expected, actual, ! stringizer, stringizer, ! comparator, message ); } *************** *** 191,204 **** ,class ActualEnumerator ,class EqualityPredicate> ! void checkCustomEqualitySequenceEqual( const ExpectedEnumerator &expected, ! const ActualEnumerator &actual, ! EqualityPredicate comparator, ! const Message &message = Message() ) { typedef DefaultStringizer<CPPTL_TYPENAME ExpectedEnumerator::value_type> ExpectedStringizer; typedef DefaultStringizer<CPPTL_TYPENAME ActualEnumerator::value_type> ActualStringizer; ! checkCustomHeterogeneousSequenceEqual( expected, actual, ! ExpectedStringizer(), ActualStringizer(), ! comparator, message ); } --- 193,206 ---- ,class ActualEnumerator ,class EqualityPredicate> ! CheckerResult checkCustomEqualitySequenceEqual( const ExpectedEnumerator &expected, ! const ActualEnumerator &actual, ! EqualityPredicate comparator, ! const Message &message = Message() ) { typedef DefaultStringizer<CPPTL_TYPENAME ExpectedEnumerator::value_type> ExpectedStringizer; typedef DefaultStringizer<CPPTL_TYPENAME ActualEnumerator::value_type> ActualStringizer; ! return checkCustomHeterogeneousSequenceEqual( expected, actual, ! ExpectedStringizer(), ActualStringizer(), ! comparator, message ); } *************** *** 206,216 **** template<class ExpectedEnumeratorType ,class ActualEnumeratorType> ! void checkSequenceEqual( const ExpectedEnumeratorType &expected, ! const ActualEnumeratorType &actual, ! const Message &message = Message() ) { DefaultComparator<CPPTL_TYPENAME ExpectedEnumeratorType::value_type ,CPPTL_TYPENAME ActualEnumeratorType::value_type> comparator; ! checkCustomEqualitySequenceEqual( expected, actual, comparator, message ); } --- 208,218 ---- template<class ExpectedEnumeratorType ,class ActualEnumeratorType> ! CheckerResult checkSequenceEqual( const ExpectedEnumeratorType &expected, ! const ActualEnumeratorType &actual, ! const Message &message = Message() ) { DefaultComparator<CPPTL_TYPENAME ExpectedEnumeratorType::value_type ,CPPTL_TYPENAME ActualEnumeratorType::value_type> comparator; ! return checkCustomEqualitySequenceEqual( expected, actual, comparator, message ); } *************** *** 218,240 **** ,class ActualEnumeratorType ,class EqualityPredicate> ! void checkCustomEqualityStlSequenceEqual( const ExpectedEnumeratorType &expected, ! const ActualEnumeratorType &actual, ! EqualityPredicate comparator, ! const Message &message = Message() ) { ! checkCustomEqualitySequenceEqual( CppTL::Enum::container( expected ), ! CppTL::Enum::container( actual ), ! comparator, message ); } template<class ExpectedEnumeratorType ,class ActualEnumeratorType> ! void checkStlSequenceEqual( const ExpectedEnumeratorType &expected, ! const ActualEnumeratorType &actual, ! const Message &message = Message() ) { ! checkSequenceEqual( CppTL::Enum::container( expected ), ! CppTL::Enum::container( actual ), ! message ); } --- 220,242 ---- ,class ActualEnumeratorType ,class EqualityPredicate> ! CheckerResult checkCustomEqualityStlSequenceEqual( const ExpectedEnumeratorType &expected, ! const ActualEnumeratorType &actual, ! EqualityPredicate comparator, ! const Message &message = Message() ) { ! return checkCustomEqualitySequenceEqual( CppTL::Enum::container( expected ), ! CppTL::Enum::container( actual ), ! comparator, message ); } template<class ExpectedEnumeratorType ,class ActualEnumeratorType> ! CheckerResult checkStlSequenceEqual( const ExpectedEnumeratorType &expected, ! const ActualEnumeratorType &actual, ! const Message &message = Message() ) { ! return checkSequenceEqual( CppTL::Enum::container( expected ), ! CppTL::Enum::container( actual ), ! message ); } *************** *** 244,254 **** ,class ActualStringizer ,class EqualityPredicate> ! void checkCustomHeterogeneousSetEqual( const ExpectedEnumerator &expected, ! const ActualEnumerator &actual, ! ExpectedStringizer expectedStringizer, ! ActualStringizer actualStringizer, ! EqualityPredicate predicate, ! const Message &message ) { std::deque<CPPTL_TYPENAME ExpectedEnumerator::value_type> missing; std::deque<CPPTL_TYPENAME ActualEnumerator::value_type> extraneous; --- 246,257 ---- ,class ActualStringizer ,class EqualityPredicate> ! CheckerResult checkCustomHeterogeneousSetEqual( const ExpectedEnumerator &expected, ! const ActualEnumerator &actual, ! ExpectedStringizer expectedStringizer, ! ActualStringizer actualStringizer, ! EqualityPredicate predicate, ! const Message &message ) { + CheckerResult result; std::deque<CPPTL_TYPENAME ExpectedEnumerator::value_type> missing; std::deque<CPPTL_TYPENAME ActualEnumerator::value_type> extraneous; *************** *** 257,274 **** predicate ); if ( missing.empty() && extraneous.empty() ) ! return; ! Message newMessage( message ); ! newMessage.add( translate( "Sets do not contain the same items." ) ); ! newMessage.add( translate( "Actual:\n" ) + enumToStringCustom(actual,actualStringizer) ); if ( missing.size() > 0 ) ! newMessage.add( translate( "Missing:\n" ) + ! enumToStringCustom( CppTL::Enum::container(missing), ! expectedStringizer ) ); if ( extraneous.size() > 0 ) ! newMessage.add( translate( "Extraneous:\n" ) + ! enumToStringCustom( CppTL::Enum::container(extraneous), ! actualStringizer ) ); ! fail( newMessage ); } --- 260,278 ---- predicate ); if ( missing.empty() && extraneous.empty() ) ! return result; ! result.setFailed(); ! result.message_ = message; ! result.message_.add( translate( "Sets do not contain the same items." ) ); ! result.message_.add( translate( "Actual:\n" ) + enumToStringCustom(actual,actualStringizer) ); if ( missing.size() > 0 ) ! result.message_.add( translate( "Missing:\n" ) + ! enumToStringCustom( CppTL::Enum::container(missing), ! expectedStringizer ) ); if ( extraneous.size() > 0 ) ! result.message_.add( translate( "Extraneous:\n" ) + ! enumToStringCustom( CppTL::Enum::container(extraneous), ! actualStringizer ) ); ! return result; } *************** *** 277,289 **** ,class ItemStringizer ,class EqualityPredicate> ! void checkCustomSetEqual( const ExpectedEnumerator &expected, ! const ActualEnumerator &actual, ! ItemStringizer itemStringizer, ! EqualityPredicate comparator, ! const Message &message = Message() ) { ! checkCustomHeterogeneousSetEqual( expected, actual, ! itemStringizer, itemStringizer, ! comparator, message ); } --- 281,293 ---- ,class ItemStringizer ,class EqualityPredicate> ! CheckerResult checkCustomSetEqual( const ExpectedEnumerator &expected, ! const ActualEnumerator &actual, ! ItemStringizer itemStringizer, ! EqualityPredicate comparator, ! const Message &message = Message() ) { ! return checkCustomHeterogeneousSetEqual( expected, actual, ! itemStringizer, itemStringizer, ! comparator, message ); } *************** *** 291,302 **** ,class ActualEnumerator ,class ItemStringizer> ! void checkCustomStringSetEqual( const ExpectedEnumerator &expected, ! const ActualEnumerator &actual, ! ItemStringizer itemStringizer, ! const Message &message = Message() ) { DefaultComparator<CPPTL_TYPENAME ExpectedEnumerator::value_type ,CPPTL_TYPENAME ActualEnumerator::value_type> comparator; ! checkCustomSetEqual( expected, actual, itemStringizer, comparator, message ); } --- 295,306 ---- ,class ActualEnumerator ,class ItemStringizer> ! CheckerResult checkCustomStringSetEqual( const ExpectedEnumerator &expected, ! const ActualEnumerator &actual, ! ItemStringizer itemStringizer, ! const Message &message = Message() ) { DefaultComparator<CPPTL_TYPENAME ExpectedEnumerator::value_type ,CPPTL_TYPENAME ActualEnumerator::value_type> comparator; ! return checkCustomSetEqual( expected, actual, itemStringizer, comparator, message ); } *************** *** 304,339 **** ,class ActualEnumerator ,class EqualityPredicate> ! void checkCustomEqualitySetEqual( const ExpectedEnumerator &expected, ! const ActualEnumerator &actual, ! EqualityPredicate comparator, ! const Message &message = Message() ) { typedef DefaultStringizer<CPPTL_TYPENAME ExpectedEnumerator::value_type> ExpectedStringizer; typedef DefaultStringizer<CPPTL_TYPENAME ActualEnumerator::value_type> ActualStringizer; ! checkCustomHeterogeneousSetEqual( expected, actual, ! ExpectedStringizer(), ActualStringizer(), ! comparator, message ); } template<class ExpectedEnumerator ,class ActualEnumerator> ! void checkSetEqual( const ExpectedEnumerator &expected, ! const ActualEnumerator &actual, ! const Message &message = Message() ) { DefaultComparator<CPPTL_TYPENAME ExpectedEnumerator::value_type ,CPPTL_TYPENAME ActualEnumerator::value_type> comparator; ! checkCustomEqualitySetEqual( expected, actual, comparator, message ); } template<class ExpectedStlSet ,class ActualStlSet> ! void checkStlSetEqual( const ExpectedStlSet &expected, ! const ActualStlSet &actual, ! const Message &message = Message() ) { ! checkSetEqual( CppTL::Enum::container( expected ), ! CppTL::Enum::container( actual ), ! message ); } --- 308,343 ---- ,class ActualEnumerator ,class EqualityPredicate> ! CheckerResult checkCustomEqualitySetEqual( const ExpectedEnumerator &expected, ! const ActualEnumerator &actual, ! EqualityPredicate comparator, ! const Message &message = Message() ) { typedef DefaultStringizer<CPPTL_TYPENAME ExpectedEnumerator::value_type> ExpectedStringizer; typedef DefaultStringizer<CPPTL_TYPENAME ActualEnumerator::value_type> ActualStringizer; ! return checkCustomHeterogeneousSetEqual( expected, actual, ! ExpectedStringizer(), ActualStringizer(), ! comparator, message ); } template<class ExpectedEnumerator ,class ActualEnumerator> ! CheckerResult checkSetEqual( const ExpectedEnumerator &expected, ! const ActualEnumerator &actual, ! const Message &message = Message() ) { DefaultComparator<CPPTL_TYPENAME ExpectedEnumerator::value_type ,CPPTL_TYPENAME ActualEnumerator::value_type> comparator; ! return checkCustomEqualitySetEqual( expected, actual, comparator, message ); } template<class ExpectedStlSet ,class ActualStlSet> ! CheckerResult checkStlSetEqual( const ExpectedStlSet &expected, ! const ActualStlSet &actual, ! const Message &message = Message() ) { ! return checkSetEqual( CppTL::Enum::container( expected ), ! CppTL::Enum::container( actual ), ! message ); } *************** *** 341,352 **** ,class ActualSetType ,class EqualityPredicate> ! void checkCustomEqualityStlSetEqual( const ExpectedSetType &expected, ! const ActualSetType &actual, ! EqualityPredicate predicate, ! const Message &message = Message() ) { ! checkSetEqual( CppTL::Enum::container( expected ), ! CppTL::Enum::container( actual ), ! predicate, message ); } --- 345,356 ---- ,class ActualSetType ,class EqualityPredicate> ! CheckerResult checkCustomEqualityStlSetEqual( const ExpectedSetType &expected, ! const ActualSetType &actual, ! EqualityPredicate predicate, ! const Message &message = Message() ) { ! return checkSetEqual( CppTL::Enum::container( expected ), ! CppTL::Enum::container( actual ), ! predicate, message ); } Index: forwards.h =================================================================== RCS file: /cvsroot/cppunit/cppunit2/include/cpput/forwards.h,v retrieving revision 1.20 retrieving revision 1.21 diff -C2 -d -r1.20 -r1.21 *** forwards.h 8 Nov 2005 21:50:33 -0000 1.20 --- forwards.h 14 Aug 2007 17:30:52 -0000 1.21 *************** *** 18,26 **** class ExceptionGuardElement; class ExceptionGuard; - class TestInfo; - class TestResultUpdater; class TestSuite; class TestVisitor; typedef CppTL::IntrusivePtr<AbstractTestCase> AbstractTestCasePtr; typedef CppTL::IntrusivePtr<AbstractTestSuite> AbstractTestSuitePtr; --- 18,29 ---- class ExceptionGuardElement; class ExceptionGuard; class TestSuite; class TestVisitor; + // testinfo.h + class CheckerResult; + class TestInfo; + class TestResultUpdater; + typedef CppTL::IntrusivePtr<AbstractTestCase> AbstractTestCasePtr; typedef CppTL::IntrusivePtr<AbstractTestSuite> AbstractTestSuitePtr; Index: assertcommon.h =================================================================== RCS file: /cvsroot/cppunit/cppunit2/include/cpput/assertcommon.h,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** assertcommon.h 2 Sep 2006 11:24:53 -0000 1.3 --- assertcommon.h 14 Aug 2007 17:30:52 -0000 1.4 *************** *** 11,44 **** namespace CppUT { ! void CPPUT_API fail(); ! ! void CPPUT_API fail( const LazyMessage &message ); ! void CPPUT_API checkTrue( bool shouldBeTrue, ! const LazyMessage &message = LazyMessage::none ); ! void CPPUT_API checkFalse( bool shouldBeFalse, ! const LazyMessage &message = LazyMessage::none ); ! void CPPUT_API checkAssertionFail( bool assertionFailed, const LazyMessage &message = LazyMessage::none ); ! void CPPUT_API checkAssertionPass( bool assertionFailed, ! const LazyMessage &message = LazyMessage::none ); ! Message CPPUT_API buildEqualityFailedMessage( const std::string &expected, ! const std::string &actual, ! const LazyMessage &message = LazyMessage::none ); template<typename FirstType ,typename SecondType> ! Message makeEqualityFailedMessage( const FirstType &expected, ! const SecondType &actual, ! const LazyMessage &message = LazyMessage::none ) { std::string strExpected = stringize( expected ); std::string strActual = stringize( actual ); ! return buildEqualityFailedMessage( strExpected, strActual, message ); } --- 11,48 ---- namespace CppUT { ! CheckerResult CPPUT_API pass(); ! CheckerResult CPPUT_API fail(); ! CheckerResult CPPUT_API fail( const LazyMessage &message ); ! CheckerResult CPPUT_API checkTrue( bool shouldBeTrue, const LazyMessage &message = LazyMessage::none ); ! CheckerResult CPPUT_API checkFalse( bool shouldBeFalse, ! const LazyMessage &message = LazyMessage::none ); ! CheckerResult CPPUT_API checkAssertionFail( bool assertionFailed, ! const LazyMessage &message = LazyMessage::none ); ! ! CheckerResult CPPUT_API checkAssertionPass( bool assertionFailed, ! const LazyMessage &message = LazyMessage::none ); ! ! void CPPUT_API buildEqualityFailedMessage( CheckerResult &result, ! const std::string &expected, ! const std::string &actual, ! const LazyMessage &message = LazyMessage::none ); template<typename FirstType ,typename SecondType> ! void makeEqualityFailedMessage( CheckerResult &result, ! const FirstType &expected, ! const SecondType &actual, ! const LazyMessage &message = LazyMessage::none ) { std::string strExpected = stringize( expected ); std::string strActual = stringize( actual ); ! buildEqualityFailedMessage( result, strExpected, strActual, message ); } *************** *** 46,86 **** ,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 LazyMessage &message = LazyMessage::none ) { ! if ( equalityTest( expected, actual ) ) ! return; ! ! fail( makeEqualityFailedMessage( expected, actual, message ) ); } ! Message CPPUT_API buildUnequalityFailedMessage( const std::string &expected, ! const std::string &actual, ! const LazyMessage &message = LazyMessage::none ); template<typename FirstType ,typename SecondType> ! Message makeUnequalityFailedMessage( const FirstType &expected, ! const SecondType &actual, ! const LazyMessage &message = LazyMessage::none ) { std::string strExpected = stringize( expected ); std::string strActual = stringize( actual ); ! return buildUnequalityFailedMessage( strExpected, strActual, message ); } --- 50,92 ---- ,typename SecondType ,typename EqualityFunctorType> ! CheckerResult checkEquals( const FirstType &expected, ! const SecondType &actual, ! EqualityFunctorType equality, ! const Message &message ) { ! CheckerResult result; ! if ( !equality( expected, actual ) ) ! makeEqualityFailedMessage( result, expected, actual, message ); ! return result; } template<typename FirstType ,typename SecondType> ! CheckerResult checkEquals( const FirstType &expected, ! const SecondType &actual, ! const LazyMessage &message = LazyMessage::none ) { ! CheckerResult result; ! if ( !equalityTest( expected, actual ) ) ! makeEqualityFailedMessage( result, expected, actual, message ); ! return result; } ! void CPPUT_API buildUnequalityFailedMessage( CheckerResult &result, ! const std::string &expected, ! const std::string &actual, ! const LazyMessage &message = LazyMessage::none ); template<typename FirstType ,typename SecondType> ! void makeUnequalityFailedMessage( CheckerResult &result, ! const FirstType &expected, ! const SecondType &actual, ! const LazyMessage &message = LazyMessage::none ) { std::string strExpected = stringize( expected ); std::string strActual = stringize( actual ); ! buildUnequalityFailedMessage( result, strExpected, strActual, message ); } *************** *** 88,118 **** ,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 LazyMessage &message = LazyMessage::none ) { ! if ( !( equalityTest( expected, actual ) ) ) ! return; ! ! fail( makeUnequalityFailedMessage( expected, actual, message ) ); } ! void CPPUT_API checkDoubleEquals( double expected, ! double actual, ! double tolerance, ! const LazyMessage &message = LazyMessage::none ); void CPPUT_API skipCurrentTest(); --- 94,124 ---- ,typename SecondType ,typename EqualityFunctorType> ! CheckerResult checkNotEquals( const FirstType &expected, ! const SecondType &actual, ! EqualityFunctorType equality, ! const Message &message ) { ! CheckerResult result; ! if ( equality( expected, actual ) ) ! makeUnequalityFailedMessage( result, expected, actual, message ); ! return result; } template<typename FirstType ,typename SecondType> ! CheckerResult checkNotEquals( const FirstType &expected, ! const SecondType &actual, ! const LazyMessage &message = LazyMessage::none ) { ! CheckerResult result; ! if ( equalityTest( expected, actual ) ) ! makeUnequalityFailedMessage( result, expected, actual, message ); ! return result; } ! CheckerResult CPPUT_API checkDoubleEquals( double expected, ! double actual, ! double tolerance, ! const LazyMessage &message = LazyMessage::none ); void CPPUT_API skipCurrentTest(); *************** *** 121,152 **** - /*! 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 --- 127,134 ---- // basic assertions ! /*! \brief Always fails and abort current test with the given message. * \ingroup group_assertions * \see CppUT::fail *************** *** 156,159 **** --- 138,159 ---- ::CppUT::fail + /*! \brief Always fails with the given message, but continue current test. + * \ingroup group_assertions + * \see CppUT::fail + */ + # define CPPUT_CHECKING_FAIL \ + CPPUT_BEGIN_CHECKING_MACRO() \ + ::CppUT::fail + + /*! \brief Always succeed. Only used for succeed branch of a fail/pass assertion. + * \ingroup group_assertions + * This is required to increase the assertion count made in the test, in the case + * policy such as 'test fails in no assertion are done.' + */ + # define CPPUT_PASS \ + CPPUT_BEGIN_CHECKING_MACRO() \ + ::CppUT::pass + + /*! \brief Asserts that an expression evaluate to true. * \ingroup group_assertions *************** *** 277,297 **** /*! \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 ) --- 277,299 ---- /*! \internal + * @todo catch other unexpected exception. Use generic get exception type handler. + * Implementation notes: we need to call the failMacro outside the try/catch to + * ensure the AbortingAssertionException is not caught by the catch clause. */ ! # define _CPPUT_ASSERT_THROW_IMPL( failMacro, expression, ExceptionType ) \ ! try { \ ! bool noExceptionThrown = true; \ ! try { \ ! expression; \ ! } catch ( const ExceptionType & ) { \ ! CPPUT_PASS(); \ ! noExceptionThrown = false; \ ! } \ ! if ( noExceptionThrown ) \ ! failMacro( "Expected exception: " #ExceptionType \ ! " not thrown." ); \ ! } catch ( ... ) { /* catch like do while(false), but avoid warning */ \ ! throw; \ ! } *************** *** 300,304 **** */ # 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 --- 302,306 ---- */ # define CPPUT_ASSERT_THROW( expression, ExceptionType ) \ ! _CPPUT_ASSERT_THROW_IMPL( CPPUT_FAIL, expression, ExceptionType ) /*! \brief Checks that an expression throw an exception of a specified type *************** *** 306,316 **** */ # 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 ) { \ --- 308,318 ---- */ # define CPPUT_CHECK_THROW( expression, ExceptionType ) \ ! _CPPUT_CHECK_THROW_IMPL( CPPUT_CHECKING_FAIL, expression, ExceptionType ) /*! \internal + * @todo replace with generic exception handler to get type & data. */ ! # define _CPPUT_ASSERT_NO_THROW_IMPL( failMacro, expression ) \ try { \ expression; \ } catch ( const std::exception &e ) { \ *************** *** 318,325 **** message.add( "Type: " + \ ::CppTL::getObjectTypeName( e, "std::exception" ) ); \ ! message.add( std::string("What: ") + e.what() ); \ ! ::CppUT::fail( message ); \ } catch ( ... ) { \ ! ::CppUT::fail( "Unexpected exception caught" ); \ } --- 320,327 ---- message.add( "Type: " + \ ::CppTL::getObjectTypeName( e, "std::exception" ) ); \ ! message.add( std::string("What: ") + e.what() ); \ ! failMacro( message ); \ } catch ( ... ) { \ ! failMacro( "Unexpected exception caught" ); \ } *************** *** 329,333 **** */ # define CPPUT_ASSERT_NO_THROW( expression ) \ ! _CPPUT_ASSERT_NO_THROW_IMPL( abortingAssertion, expression ) /*! \brief Checks that an expression does not throw any exception --- 331,335 ---- */ # define CPPUT_ASSERT_NO_THROW( expression ) \ ! _CPPUT_ASSERT_NO_THROW_IMPL( CPPUT_FAIL, expression ) /*! \brief Checks that an expression does not throw any exception *************** *** 335,339 **** */ # define CPPUT_CHECK_NO_THROW( expression ) \ ! _CPPUT_ASSERT_NO_THROW_IMPL( checkingAssertion, expression ) --- 337,341 ---- */ # define CPPUT_CHECK_NO_THROW( expression ) \ ! _CPPUT_ASSERT_NO_THROW_IMPL( CPPUT_CHECKING_FAIL, expression ) *************** *** 348,354 **** * properties are captured for later inspection. */ ! # define _CPPUT_ASSERT_ASSERTION_FAIL_MESSAGE_IMPL( assertionType, assertion, message ) \ { \ - CPPUT_CHECK_POINT( assertionType ); \ bool assertionFailedCppUT_ = false; \ { \ --- 350,355 ---- * properties are captured for later inspection. */ ! # define _CPPUT_ASSERT_ASSERTION_FAIL_MESSAGE_IMPL( beginMacro, assertion, message ) \ { \ bool assertionFailedCppUT_ = false; \ { \ *************** *** 360,364 **** assertionFailedCppUT_ = ::CppUT::TestInfo::threadInstance().testStatus().hasFailed(); \ } \ ! ::CppUT::checkAssertionFail( assertionFailedCppUT_, message ); \ } --- 361,365 ---- assertionFailedCppUT_ = ::CppUT::TestInfo::threadInstance().testStatus().hasFailed(); \ } \ ! beginMacro() ::CppUT::checkAssertionFail( assertionFailedCppUT_, message ); \ } *************** *** 367,371 **** */ # 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) --- 368,372 ---- */ # define CPPUT_ASSERT_ASSERTION_FAIL_MESSAGE( assertion, message ) \ ! _CPPUT_ASSERT_ASSERTION_FAIL_MESSAGE_IMPL( CPPUT_BEGIN_ASSERTION_MACRO, assertion, message ) /*! \brief Checks that an assertion fails (for use to unit test custom assertion) *************** *** 373,377 **** */ # 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) --- 374,378 ---- */ # define CPPUT_CHECK_ASSERTION_FAIL_MESSAGE( assertion, message ) \ ! _CPPUT_CHECK_ASSERTION_FAIL_MESSAGE_IMPL( CPPUT_BEGIN_CHECKING_MACRO, assertion, message ) /*! \brief Asserts that an assertion fails (for use to unit test custom assertion) *************** *** 389,395 **** /*! \internal */ ! # define _CPPUT_ASSERT_ASSERTION_PASS_MESSAGE_IMPL( assertionType, assertion, message ) \ { \ - CPPUT_CHECK_POINT( assertionType ); \ bool assertionFailedCppUT_ = false; \ { \ --- 390,395 ---- /*! \internal */ ! # define _CPPUT_ASSERT_ASSERTION_PASS_MESSAGE_IMPL( beginMacro, assertion, message ) \ { \ bool assertionFailedCppUT_ = false; \ { \ *************** *** 401,405 **** assertionFailedCppUT_ = ::CppUT::TestInfo::threadInstance().testStatus().hasFailed(); \ } \ ! ::CppUT::checkAssertionPass( assertionFailedCppUT_, message ); \ } --- 401,405 ---- assertionFailedCppUT_ = ::CppUT::TestInfo::threadInstance().testStatus().hasFailed(); \ } \ ! beginMacro() ::CppUT::checkAssertionPass( assertionFailedCppUT_, message ); \ } *************** *** 409,413 **** */ # define CPPUT_ASSERT_ASSERTION_PASS_MESSAGE( assertion, message ) \ ! _CPPUT_ASSERT_ASSERTION_PASS_MESSAGE_IMPL( abortingAssertion, assertion, message ) --- 409,413 ---- */ # define CPPUT_ASSERT_ASSERTION_PASS_MESSAGE( assertion, message ) \ ! _CPPUT_ASSERT_ASSERTION_PASS_MESSAGE_IMPL( CPPUT_BEGIN_ASSERTION_MACRO, assertion, message ) *************** *** 416,420 **** */ # define CPPUT_CHECK_ASSERTION_PASS_MESSAGE( assertion, message ) \ ! _CPPUT_CHECK_ASSERTION_PASS_MESSAGE_IMPL( checkingAssertion, assertion, message ) --- 416,420 ---- */ # define CPPUT_CHECK_ASSERTION_PASS_MESSAGE( assertion, message ) \ ! _CPPUT_CHECK_ASSERTION_PASS_MESSAGE_IMPL( CPPUT_BEGIN_CHECKING_MACRO, assertion, message ) *************** *** 431,435 **** CPPUT_CHECK_ASSERTION_PASS_MESSAGE( assertion, ::CppUT::Message() ) ! /*! \brief Skips and aborts the current test. * \ingroup group_assertions * --- 431,435 ---- CPPUT_CHECK_ASSERTION_PASS_MESSAGE( assertion, ::CppUT::Message() ) ! /*! \brief Skips the current test (test is aborted via thrown exception). * \ingroup group_assertions * *************** *** 456,464 **** * * \warning Be sure to always use <b>double braces</b> around the macro parameter to avoid ! * preprocessor mess. */ # define CPPUT_IGNORE_FAILURE( assertion ) \ { \ - CPPUT_CHECK_POINT( checkingAssertion ); \ bool failedCppUT_; \ { \ --- 456,463 ---- * * \warning Be sure to always use <b>double braces</b> around the macro parameter to avoid ! * preprocessor mess and portability issues. */ # define CPPUT_IGNORE_FAILURE( assertion ) \ { \ bool failedCppUT_; \ { \ *************** *** 469,472 **** --- 468,472 ---- } \ } \ + CPPUT_BEGIN_CHECKING_MACRO() \ ::CppUT::checkAssertionFail( failedCppUT_, #assertion ); \ } Index: assertstring.h =================================================================== RCS file: /cvsroot/cppunit/cppunit2/include/cpput/assertstring.h,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** assertstring.h 13 Nov 2005 10:12:01 -0000 1.5 --- assertstring.h 14 Aug 2007 17:30:52 -0000 1.6 *************** *** 6,56 **** namespace CppUT { ! void CPPUT_API checkStdStringStartsWith( const std::string &string, ! const std::string &pattern, ! const Message &message ); ! void CPPUT_API checkStdStringEndsWith( const std::string &string, ! const std::string &pattern, ! const Message &message ); ! void CPPUT_API checkStdStringContains( const std::string &str... [truncated message content] |
From: Baptiste L. <bl...@us...> - 2007-08-14 17:31:12
|
Update of /cvsroot/cppunit/cppunit2 In directory sc8-pr-cvs4.sourceforge.net:/tmp/cvs-serv5281 Modified Files: TODO sconstruct Added Files: changelog.txt Log Message: Modified assertion implementation to force evaluation of user condition expression first, while preserving delegation to function, overloading and optional parameters feature. See CPPUT_BEGIN_ASSERTION_MACRO() documentation in testinfo.h for an example to update your custom assertion code. New implementation rely on operator evaluation order and operator overloading. The trick is documented in CPPUT_BEGIN_ASSERTION_MACRO(). Index: sconstruct =================================================================== RCS file: /cvsroot/cppunit/cppunit2/sconstruct,v retrieving revision 1.31 retrieving revision 1.32 diff -C2 -d -r1.31 -r1.32 *** sconstruct 16 Mar 2007 22:41:39 -0000 1.31 --- sconstruct 14 Aug 2007 17:30:52 -0000 1.32 *************** *** 6,9 **** --- 6,10 ---- # http://www.scons.org/wiki/DynamicSourceGenerator # (see Gary mail on the user ML 19/07/2006 @ 17h25) + # May be a scons issue: tool is added without calling exists() [e.g. added tool may not exist] --- NEW FILE: changelog.txt --- * 2007/08/14 blep Modified assertion implementation to force evaluation of user condition expression first, while preserving delegation to function, overloading and optional parameters feature. See CPPUT_BEGIN_ASSERTION_MACRO() documentation in testinfo.h for an example to update your custom assertion code. Index: TODO =================================================================== RCS file: /cvsroot/cppunit/cppunit2/TODO,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** TODO 2 Sep 2006 11:24:53 -0000 1.3 --- TODO 14 Aug 2007 17:30:52 -0000 1.4 *************** *** 1,3 **** - * figure out how CHECK/ASSERT can be made more friendly to developper when debugging - => avoid stepping into cppunit code before processing the assertion. * complete works on the CommandLines library => likely moved to opentest. --- 1 ---- |
From: Baptiste L. <bl...@us...> - 2007-08-14 17:31:12
|
Update of /cvsroot/cppunit/cppunit2/src/cpput In directory sc8-pr-cvs4.sourceforge.net:/tmp/cvs-serv5281/src/cpput Modified Files: assert.cpp assertstring.cpp exceptionguard.cpp testinfo.cpp Log Message: Modified assertion implementation to force evaluation of user condition expression first, while preserving delegation to function, overloading and optional parameters feature. See CPPUT_BEGIN_ASSERTION_MACRO() documentation in testinfo.h for an example to update your custom assertion code. New implementation rely on operator evaluation order and operator overloading. The trick is documented in CPPUT_BEGIN_ASSERTION_MACRO(). Index: assert.cpp =================================================================== RCS file: /cvsroot/cppunit/cppunit2/src/cpput/assert.cpp,v retrieving revision 1.19 retrieving revision 1.20 diff -C2 -d -r1.19 -r1.20 *** assert.cpp 2 Sep 2006 11:24:53 -0000 1.19 --- assert.cpp 14 Aug 2007 17:30:52 -0000 1.20 *************** *** 9,106 **** ! void fail() { ! fail( translate("Assertion Failed") ); } ! void fail( const LazyMessage &message ) { ! currentAssertion().setMessages( message.makeMessage() ); ! realizeAssertion(); } ! void checkTrue( bool shouldBeTrue, const LazyMessage &message ) { ! if ( shouldBeTrue ) ! return; ! ! Message newMessage( message.makeMessage() ); ! newMessage.insertAt( 0, translate( "expression did not evaluate to true." ) ); ! fail( newMessage ); } ! void checkFalse( bool shouldBeFalse, const LazyMessage &message ) { ! if ( !shouldBeFalse ) ! return; ! ! Message newMessage( message.makeMessage() ); ! newMessage.insertAt( 0, translate( "expression did not evaluate to false." ) ); ! fail( newMessage ); } ! void checkAssertionFail( bool assertionFailed, const LazyMessage &message ) { ! if ( assertionFailed ) ! return; ! ! Message newMessage( translate( "Assertion expression did not fail as expected." ) ); ! newMessage.extend( message.makeMessage() ); ! fail( message ); } ! void checkAssertionPass( bool assertionFailed, const LazyMessage &message ) { ! if ( !assertionFailed ) ! return; ! ! Message newMessage( translate( "Assertion expression did not pass as expected." ) ); ! newMessage.extend( message.makeMessage() ); ! fail( message ); } ! Message ! buildEqualityFailedMessage( const std::string &expected, const std::string &actual, const LazyMessage &message ) { ! Message newMessage( message.makeMessage() ); ! newMessage.add( translate( "Equality assertion failed." ) ); ! newMessage.add( translate( "Expected: " ) + expected ); ! newMessage.add( translate( "Actual : " ) + actual ); ! return newMessage; } ! Message ! buildUnequalityFailedMessage( const std::string &expected, const std::string &actual, const LazyMessage &message ) { ! Message newMessage( message.makeMessage() ); ! newMessage.add( translate( "Unequality assertion failed (expected & actual should be different)." ) ); ! newMessage.add( translate( "Expected: " ) + expected ); ! newMessage.add( translate( "Actual : " ) + actual ); ! return newMessage; } ! void checkDoubleEquals( double expected, double actual, --- 9,125 ---- ! CheckerResult ! pass() ! { ! return CheckerResult(); ! } ! ! ! CheckerResult fail() { ! return fail( translate("Assertion Failed") ); } ! CheckerResult fail( const LazyMessage &message ) { ! CheckerResult result; ! result.setFailed(); ! result.message_ = message.makeMessage(); ! return result; } ! CheckerResult checkTrue( bool shouldBeTrue, const LazyMessage &message ) { ! CheckerResult result; ! if ( !shouldBeTrue ) ! { ! result.message_ = message.makeMessage(); ! result.message_.insertAt( 0, translate( "expression did not evaluate to true." ) ); ! result.setFailed(); ! } ! return result; } ! CheckerResult checkFalse( bool shouldBeFalse, const LazyMessage &message ) { ! CheckerResult result; ! if ( shouldBeFalse ) ! { ! result.message_ = message.makeMessage(); ! result.message_.insertAt( 0, translate( "expression did not evaluate to false." ) ); ! result.setFailed(); ! } ! return result; } ! CheckerResult checkAssertionFail( bool assertionFailed, const LazyMessage &message ) { ! CheckerResult result; ! if ( !assertionFailed ) ! { ! result.message_ = Message( translate( "Assertion expression did not fail as expected." ) ); ! result.message_.extend( message.makeMessage() ); ! result.setFailed(); ! } ! return result; } ! CheckerResult checkAssertionPass( bool assertionFailed, const LazyMessage &message ) { ! CheckerResult result; ! if ( assertionFailed ) ! { ! result.message_ = Message( translate( "Assertion expression did not pass as expected." ) ); ! result.message_.extend( message.makeMessage() ); ! result.setFailed(); ! } ! return result; } ! void ! buildEqualityFailedMessage( CheckerResult &result, ! const std::string &expected, const std::string &actual, const LazyMessage &message ) { ! result.setFailed(); ! result.message_ = message.makeMessage(); ! result.message_.add( translate( "Equality assertion failed." ) ); ! result.message_.add( translate( "Expected: " ) + expected ); ! result.message_.add( translate( "Actual : " ) + actual ); } ! void ! buildUnequalityFailedMessage( CheckerResult &result, ! const std::string &expected, const std::string &actual, const LazyMessage &message ) { ! result.setFailed(); ! result.message_ = message.makeMessage(); ! result.message_.add( translate( "Unequality assertion failed (expected & actual should be different)." ) ); ! result.message_.add( translate( "Expected: " ) + expected ); ! result.message_.add( translate( "Actual : " ) + actual ); } ! CheckerResult checkDoubleEquals( double expected, double actual, *************** *** 108,124 **** const LazyMessage &message ) { double diff = expected - actual; if ( diff < 0 ) diff = -diff; ! if ( diff <= tolerance ) ! return; ! ! Message newMessage( message.makeMessage() ); ! newMessage.add( translate( "Double equality assertion failed." ) ); ! newMessage.add( translate( "Expected: " ) + CppTL::toString( expected ) ); ! newMessage.add( translate( "Actual : " ) + CppTL::toString( actual ) ); ! newMessage.add( translate( "Tolerance : " ) + CppTL::toString( tolerance ) ); ! newMessage.add( translate( "Actual difference : " ) + CppTL::toString( diff ) ); ! fail( newMessage ); } --- 127,145 ---- const LazyMessage &message ) { + CheckerResult result; double diff = expected - actual; if ( diff < 0 ) diff = -diff; ! if ( diff > tolerance ) ! { ! result.setFailed(); ! result.message_ = message.makeMessage(); ! result.message_.add( translate( "Double equality assertion failed." ) ); ! result.message_.add( translate( "Expected: " ) + CppTL::toString( expected ) ); ! result.message_.add( translate( "Actual : " ) + CppTL::toString( actual ) ); ! result.message_.add( translate( "Tolerance : " ) + CppTL::toString( tolerance ) ); ! result.message_.add( translate( "Actual difference : " ) + CppTL::toString( diff ) ); ! } ! return result; } Index: assertstring.cpp =================================================================== RCS file: /cvsroot/cppunit/cppunit2/src/cpput/assertstring.cpp,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** assertstring.cpp 2 Jul 2005 20:27:36 -0000 1.4 --- assertstring.cpp 14 Aug 2007 17:30:52 -0000 1.5 *************** *** 4,84 **** namespace CppUT { ! void checkStdStringStartsWith( const std::string &string, const std::string &pattern, const Message &message ) { ! if ( string.substr( 0, pattern.length() ) == pattern ) ! return; ! ! Message newMessage( message ); ! newMessage.add( translate( "String does not start with the expected pattern." ) ); ! newMessage.add( translate( "Expected start: " ) + CppTL::quoteMultiLineString( pattern ) ); ! newMessage.add( translate( "Actual string: " ) + CppTL::quoteMultiLineString( string ) ); ! fail( newMessage ); } ! void checkStdStringEndsWith( const std::string &string, const std::string &pattern, const Message &message ) { ! if ( string.length() >= pattern.length() && ! string.substr( string.length() - pattern.length() ) == pattern ) ! return; ! ! Message newMessage( message ); ! newMessage.add( translate( "String does not end with the expected pattern." ) ); ! newMessage.add( translate( "Expected end: " ) + CppTL::quoteMultiLineString( pattern ) ); ! newMessage.add( translate( "Actual string: " ) + CppTL::quoteMultiLineString( string ) ); ! fail( newMessage ); } ! void checkStdStringContains( const std::string &string, const std::string &pattern, const Message &message ) { ! if ( string.find( pattern ) != std::string::npos ) ! return; ! ! Message newMessage( message ); ! newMessage.add( translate( "String does not contain the expected pattern." ) ); ! newMessage.add( translate( "Expected pattern: " ) + CppTL::quoteMultiLineString( pattern ) ); ! newMessage.add( translate( "Actual string: " ) + CppTL::quoteMultiLineString( string ) ); ! fail( newMessage ); } ! void checkStdStringEquals( const std::string &expected, const std::string &actual, const Message &message ) { ! if ( actual == expected ) ! return; ! ! unsigned int differenceIndex = 0; ! while ( differenceIndex < actual.length() && ! differenceIndex < expected.length() && ! actual[differenceIndex] == expected[differenceIndex] ) { ! ++differenceIndex; ! } ! std::string common = expected.substr( 0, differenceIndex ); ! std::string actualTail = actual.substr( differenceIndex ); ! std::string expectedTail = expected.substr( differenceIndex ); ! Message newMessage( message ); ! newMessage.add( translate( "Strings are not equal." ) ); ! if ( !common.empty() ) ! newMessage.add( translate( "Common: " ) + CppTL::quoteMultiLineString( common ) ); ! newMessage.add( translate( "Divergence position (0 based): " ) + stringize( differenceIndex ) ); ! newMessage.add( translate( "Expected (at divergence): " ) + CppTL::quoteMultiLineString( expectedTail ) ); ! newMessage.add( translate( "Actual (at divergence): " ) + CppTL::quoteMultiLineString( actualTail ) ); ! fail( newMessage ); } --- 4,92 ---- namespace CppUT { ! CheckerResult checkStdStringStartsWith( const std::string &string, const std::string &pattern, const Message &message ) { ! CheckerResult result; ! if ( string.substr( 0, pattern.length() ) != pattern ) ! { ! result.setFailed(); ! result.message_ = message; ! result.message_.add( translate( "String does not start with the expected pattern." ) ); ! result.message_.add( translate( "Expected start: " ) + CppTL::quoteMultiLineString( pattern ) ); ! result.message_.add( translate( "Actual string: " ) + CppTL::quoteMultiLineString( string ) ); ! } ! return result; } ! CheckerResult checkStdStringEndsWith( const std::string &string, const std::string &pattern, const Message &message ) { ! CheckerResult result; ! if ( string.length() < pattern.length() || ! string.substr( string.length() - pattern.length() ) != pattern ) ! { ! result.setFailed(); ! result.message_ = message; ! result.message_.add( translate( "String does not end with the expected pattern." ) ); ! result.message_.add( translate( "Expected end: " ) + CppTL::quoteMultiLineString( pattern ) ); ! result.message_.add( translate( "Actual string: " ) + CppTL::quoteMultiLineString( string ) ); ! } ! return result; } ! CheckerResult checkStdStringContains( const std::string &string, const std::string &pattern, const Message &message ) { ! CheckerResult result; ! if ( string.find( pattern ) == std::string::npos ) ! { ! result.setFailed(); ! result.message_ = message; ! result.message_.add( translate( "String does not contain the expected pattern." ) ); ! result.message_.add( translate( "Expected pattern: " ) + CppTL::quoteMultiLineString( pattern ) ); ! result.message_.add( translate( "Actual string: " ) + CppTL::quoteMultiLineString( string ) ); ! } ! return result; } ! CheckerResult checkStdStringEquals( const std::string &expected, const std::string &actual, const Message &message ) { ! CheckerResult result; ! if ( actual != expected ) { ! unsigned int differenceIndex = 0; ! while ( differenceIndex < actual.length() && ! differenceIndex < expected.length() && ! actual[differenceIndex] == expected[differenceIndex] ) ! { ! ++differenceIndex; ! } ! std::string common = expected.substr( 0, differenceIndex ); ! std::string actualTail = actual.substr( differenceIndex ); ! std::string expectedTail = expected.substr( differenceIndex ); ! result.setFailed(); ! result.message_ = message; ! result.message_.add( translate( "Strings are not equal." ) ); ! if ( !common.empty() ) ! result.message_.add( translate( "Common: " ) + CppTL::quoteMultiLineString( common ) ); ! result.message_.add( translate( "Divergence position (0 based): " ) + stringize( differenceIndex ) ); ! result.message_.add( translate( "Expected (at divergence): " ) + CppTL::quoteMultiLineString( expectedTail ) ); ! result.message_.add( translate( "Actual (at divergence): " ) + CppTL::quoteMultiLineString( actualTail ) ); ! } ! return result; } Index: testinfo.cpp =================================================================== RCS file: /cvsroot/cppunit/cppunit2/src/cpput/testinfo.cpp,v retrieving revision 1.21 retrieving revision 1.22 diff -C2 -d -r1.21 -r1.22 *** testinfo.cpp 5 Jun 2006 13:22:58 -0000 1.21 --- testinfo.cpp 14 Aug 2007 17:30:52 -0000 1.22 *************** *** 5,8 **** --- 5,29 ---- namespace CppUT { + + // ////////////////////////////////////////////////////////////////// + // ////////////////////////////////////////////////////////////////// + // Class AssertionTrigger + // ////////////////////////////////////////////////////////////////// + // ////////////////////////////////////////////////////////////////// + namespace Impl { + AssertionTrigger AssertionTrigger::aborting; + AssertionTrigger AssertionTrigger::checking; + + AssertionTrigger & + AssertionTrigger::operator +=( const CheckerFileLocation &fileLocation ) + { + const char *file = fileLocation.file_; + unsigned int line = fileLocation.lineData_->line_; + const CheckerResult &result = *(fileLocation.lineData_->result_); + TestInfo::threadInstance().handleAssertion( file, line, result, this == &aborting ); + return *this; + } + } // end namespace Impl + // ////////////////////////////////////////////////////////////////// // ////////////////////////////////////////////////////////////////// *************** *** 277,281 **** { testStatus_ = TestStatus( TestStatus::passed ); - currentAssertion_ = Assertion(); assertionType_ = abortingAssertion; } --- 298,301 ---- *************** *** 290,328 **** void ! TestInfo::newAssertion( AssertionType type, ! const char *fileName, ! unsigned int lineNumber, ! const char *functionName ) ! { ! currentAssertion_ = Assertion( Assertion::assertion, ! SourceLocation( fileName, ! lineNumber, ! functionName ) ); ! testStatus_.increaseAssertionCount(); ! assertionType_ = type; ! } ! ! ! Assertion & ! TestInfo::currentAssertion() ! { ! return currentAssertion_; ! } ! ! ! void ! TestInfo::realizeAssertion() { ! testStatus_.increaseFailedAssertionCount(); ! if ( updater_ ) ! updater_->addResultAssertion( currentAssertion_ ); ! if ( assertionType_ == abortingAssertion ) ! { ! std::string message; ! if ( abortingAssertionMode_ != fastAbortingAssertion ) ! message = currentAssertion_.toString().c_str(); ! throw AbortingAssertionException( message ); } } --- 310,347 ---- void ! TestInfo::handleAssertion( const char *file, ! unsigned int line, ! const CheckerResult &result, ! bool isAbortingAssertion ) { ! switch ( result.status_ ) ! { ! case TestStatus::passed: // do nothing (assertion count increased) ! testStatus_.increaseAssertionCount(); ! break; ! case TestStatus::failed: ! { ! testStatus_.increaseAssertionCount(); ! testStatus_.increaseFailedAssertionCount(); ! Assertion assertion( Assertion::assertion, SourceLocation( file, line ) ); ! assertion.setMessages( result.message_ ); ! if ( updater_ ) ! updater_->addResultAssertion( assertion ); ! if ( isAbortingAssertion ) ! { ! std::string message; ! if ( abortingAssertionMode_ != fastAbortingAssertion ) ! message = assertion.toString().c_str(); ! throw AbortingAssertionException( message ); ! } ! } ! break; ! case TestStatus::skipped: ! // @todo handle this correctly. ! break; ! default: ! CPPTL_DEBUG_ASSERT_UNREACHABLE; } } *************** *** 424,449 **** - //void newAssertion( AssertionType type, - // const char *fileName, - // unsigned int lineNumber, - // const char *functionName ) - //{ - // TestInfo::data().newAssertion( type, fileName, lineNumber, functionName ); - //} - - - Assertion & - currentAssertion() - { - return TestInfo::threadInstance().currentAssertion(); - } - - - void realizeAssertion() - { - TestInfo::threadInstance().realizeAssertion(); - } - - void log( const Json::Value &log ) { --- 443,446 ---- Index: exceptionguard.cpp =================================================================== RCS file: /cvsroot/cppunit/cppunit2/src/cpput/exceptionguard.cpp,v retrieving revision 1.11 retrieving revision 1.12 diff -C2 -d -r1.11 -r1.12 *** exceptionguard.cpp 5 Jun 2006 13:22:58 -0000 1.11 --- exceptionguard.cpp 14 Aug 2007 17:30:52 -0000 1.12 *************** *** 3,6 **** --- 3,7 ---- #include <cpptl/typename.h> #include <cpptl/functor.h> + #include <cpptl/conststring.h> namespace CppUT { |
From: Baptiste L. <bl...@us...> - 2007-03-19 02:13:33
|
Update of /cvsroot/cppunit/cppunit2/doc In directory sc8-pr-cvs4.sourceforge.net:/tmp/cvs-serv20791/doc Modified Files: SConscript doxyfile.in Log Message: - made doxygen generation more robust: no longer attempt to manage dependencies. Index: SConscript =================================================================== RCS file: /cvsroot/cppunit/cppunit2/doc/SConscript,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** SConscript 1 Sep 2006 20:12:11 -0000 1.1 --- SConscript 16 Mar 2007 22:41:38 -0000 1.2 *************** *** 4,20 **** if 'doxygen' in env['TOOLS']: doc_topdir = env['ROOTBUILD_DIR'] doxyfile = env.SubstInFile( '#doc/doxyfile', 'doxyfile.in', SUBST_DICT = { '%CPPUNIT_VERSION%' : env['CPPUNIT_VERSION'], '%TOPDIR%' : env.Dir('#').abspath, ! '%DOC_TOPDIR%' : str(doc_topdir) } ) doc_cmd = env.Doxygen( doxyfile ) env.Alias('doc', doc_cmd) env.AlwaysBuild(doc_cmd) ! ! for dir in doc_cmd: ! filename = os.path.split(dir.path)[1] ! targz_path = os.path.join( env['DIST_DIR'], '%s.tar.gz' % filename ) ! zip_doc_cmd = env.TarGz( targz_path, [env.Dir(dir)], ! TARGZ_BASEDIR = doc_topdir ) ! env.Alias( 'doc-dist', zip_doc_cmd ) --- 4,23 ---- if 'doxygen' in env['TOOLS']: doc_topdir = env['ROOTBUILD_DIR'] + env['DOXYGEN_DOC_TOP_DIR'] = doc_topdir + env['DOXYGEN_HTML_DIR'] = env.Dir( 'cppunit2-doc-html-' + env['CPPUNIT_VERSION'] ) doxyfile = env.SubstInFile( '#doc/doxyfile', 'doxyfile.in', SUBST_DICT = { '%CPPUNIT_VERSION%' : env['CPPUNIT_VERSION'], '%TOPDIR%' : env.Dir('#').abspath, ! '%DOC_TOPDIR%' : str(doc_topdir), ! '%HTML_OUTPUT%' : str(env['DOXYGEN_HTML_DIR']) } ) doc_cmd = env.Doxygen( doxyfile ) env.Alias('doc', doc_cmd) env.AlwaysBuild(doc_cmd) ! ## ! ## for dir in doc_cmd: ! ## filename = os.path.split(dir.path)[1] ! ## targz_path = os.path.join( env['DIST_DIR'], '%s.tar.gz' % filename ) ! ## zip_doc_cmd = env.TarGz( targz_path, [env.Dir(dir)], ! ## TARGZ_BASEDIR = doc_topdir ) ! ## env.Alias( 'doc-dist', zip_doc_cmd ) Index: doxyfile.in =================================================================== RCS file: /cvsroot/cppunit/cppunit2/doc/doxyfile.in,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** doxyfile.in 7 Sep 2006 22:45:50 -0000 1.3 --- doxyfile.in 16 Mar 2007 22:41:39 -0000 1.4 *************** *** 107,111 **** #--------------------------------------------------------------------------- GENERATE_HTML = YES ! HTML_OUTPUT = cppunit2-doc-html-%CPPUNIT_VERSION% HTML_FILE_EXTENSION = .html HTML_HEADER = header.html --- 107,111 ---- #--------------------------------------------------------------------------- GENERATE_HTML = YES ! HTML_OUTPUT = %HTML_OUTPUT% HTML_FILE_EXTENSION = .html HTML_HEADER = header.html |
From: Baptiste L. <bl...@us...> - 2007-03-19 02:13:33
|
Update of /cvsroot/cppunit/cppunit2/scons-tools In directory sc8-pr-cvs4.sourceforge.net:/tmp/cvs-serv20791/scons-tools Modified Files: doxygen.py Log Message: - made doxygen generation more robust: no longer attempt to manage dependencies. Index: doxygen.py =================================================================== RCS file: /cvsroot/cppunit/cppunit2/scons-tools/doxygen.py,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** doxygen.py 1 Sep 2006 19:48:11 -0000 1.2 --- doxygen.py 16 Mar 2007 22:41:39 -0000 1.3 *************** *** 1,173 **** ! # Big issue: ! # emitter depends on doxyfile which is generated from doxyfile.in. ! # build fails after cleaning and relaunching the build. import os import os.path - import glob - from fnmatch import fnmatch - - def DoxyfileParse(file_contents): - """ - Parse a Doxygen source file and return a dictionary of all the values. - Values will be strings and lists of strings. - """ - data = {} - - import shlex - lex = shlex.shlex(instream = file_contents, posix = True) - lex.wordchars += "*+./-:" - lex.whitespace = lex.whitespace.replace("\n", "") - lex.escape = "" - - lineno = lex.lineno - last_backslash_lineno = lineno - token = lex.get_token() - key = token # the first token should be a key - last_token = "" - key_token = False - next_key = False - new_data = True - - def append_data(data, key, new_data, token): - if new_data or len(data[key]) == 0: - data[key].append(token) - else: - data[key][-1] += token - - while token: - if token in ['\n']: - if last_token not in ['\\']: - key_token = True - elif token in ['\\']: - pass - elif key_token: - key = token - key_token = False - else: - if token == "+=": - if not data.has_key(key): - data[key] = list() - elif token == "=": - data[key] = list() - else: - append_data( data, key, new_data, token ) - new_data = True - - last_token = token - token = lex.get_token() - - if last_token == '\\' and token != '\n': - new_data = False - append_data( data, key, new_data, '\\' ) - - # compress lists of len 1 into single strings - for (k, v) in data.items(): - if len(v) == 0: - data.pop(k) - - # items in the following list will be kept as lists and not converted to strings - if k in ["INPUT", "FILE_PATTERNS", "EXCLUDE_PATTERNS"]: - continue - - if len(v) == 1: - data[k] = v[0] - - return data - - def DoxySourceScan(node, env, path): - """ - Doxygen Doxyfile source scanner. This should scan the Doxygen file and add - any files used to generate docs to the list of source files. - """ - default_file_patterns = [ - '*.c', '*.cc', '*.cxx', '*.cpp', '*.c++', '*.java', '*.ii', '*.ixx', - '*.ipp', '*.i++', '*.inl', '*.h', '*.hh ', '*.hxx', '*.hpp', '*.h++', - '*.idl', '*.odl', '*.cs', '*.php', '*.php3', '*.inc', '*.m', '*.mm', - '*.py', - ] - - default_exclude_patterns = [ - '*~', - ] - - sources = [] - - data = DoxyfileParse(node.get_contents()) - - if data.get("RECURSIVE", "NO") == "YES": - recursive = True - else: - recursive = False - - file_patterns = data.get("FILE_PATTERNS", default_file_patterns) - exclude_patterns = data.get("EXCLUDE_PATTERNS", default_exclude_patterns) - - doxyfile_dir = str( node.dir ) - - ## print 'running from', os.getcwd() - for node in data.get("INPUT", []): - node_real_path = os.path.normpath( os.path.join( doxyfile_dir, node ) ) - if os.path.isfile(node_real_path): - ## print str(node), 'is a file' - sources.append(node) - elif os.path.isdir(node_real_path): - ## print str(node), 'is a directory' - if recursive: - for root, dirs, files in os.walk(node): - for f in files: - filename = os.path.join(root, f) - - pattern_check = reduce(lambda x, y: x or bool(fnmatch(filename, y)), file_patterns, False) - exclude_check = reduce(lambda x, y: x and fnmatch(filename, y), exclude_patterns, True) - - if pattern_check and not exclude_check: - sources.append(filename) - ## print ' adding source', os.path.abspath( filename ) - else: - for pattern in file_patterns: - sources.extend(glob.glob(os.path.join( node, pattern))) - ## else: - ## print str(node), 'is neither a file nor a directory' - sources = map( lambda path: env.File(path), sources ) - return sources - - - def DoxySourceScanCheck(node, env): - """Check if we should scan this file""" - return os.path.isfile(node.path) def DoxyEmitter(source, target, env): """Doxygen Doxyfile emitter""" ! # possible output formats and their default values and output locations ! output_formats = { ! "HTML": ("YES", "html"), ! "LATEX": ("YES", "latex"), ! "RTF": ("NO", "rtf"), ! "MAN": ("YES", "man"), ! "XML": ("NO", "xml"), ! } ! ! ## print '#### DoxyEmitter:', source[0].abspath, os.path.exists( source[0].abspath ) ! data = DoxyfileParse(source[0].get_contents()) ! ! targets = [] ! out_dir = data.get("OUTPUT_DIRECTORY", ".") ! ! # add our output locations ! for (k, v) in output_formats.items(): ! if data.get("GENERATE_" + k, v[0]) == "YES": ! targets.append(env.Dir( os.path.join(out_dir, data.get(k + "_OUTPUT", v[1]))) ) ! ! # don't clobber targets ! for node in targets: ! env.Precious(node) ! ! # set up cleaning stuff ! for node in targets: ! clean_cmd = env.Clean(node, node) ! env.Depends( clean_cmd, source ) ! ! return (targets, source) def generate(env): --- 1,15 ---- ! # DOXYGEN_DOC_TOP_DIR ! # DOXYGEN_HTML_DIR ! # import os import os.path def DoxyEmitter(source, target, env): """Doxygen Doxyfile emitter""" ! output_dir = os.path.join( str(env['DOXYGEN_DOC_TOP_DIR']), str(env['DOXYGEN_HTML_DIR']) ) ! target_file = env.File( os.path.join( str(output_dir), 'index.html' ) ) ! env.Clean( target_file, output_dir ) ! return [ target_file ], source def generate(env): *************** *** 176,184 **** Doxygen tool. This is currently for Doxygen 1.4.6. """ - doxyfile_scanner = env.Scanner( - DoxySourceScan, - "DoxySourceScan", - scan_check = DoxySourceScanCheck, - ) doxyfile_builder = env.Builder( --- 18,21 ---- *************** *** 186,192 **** varlist=['$SOURCES']), emitter = DoxyEmitter, - target_factory = env.fs.Entry, single_source = True, - source_scanner = doxyfile_scanner, ) --- 23,27 ---- |
From: Baptiste L. <bl...@us...> - 2007-03-18 11:59:38
|
Update of /cvsroot/cppunit/cppunit2 In directory sc8-pr-cvs4.sourceforge.net:/tmp/cvs-serv20791 Modified Files: sconstruct Log Message: - made doxygen generation more robust: no longer attempt to manage dependencies. Index: sconstruct =================================================================== RCS file: /cvsroot/cppunit/cppunit2/sconstruct,v retrieving revision 1.30 retrieving revision 1.31 diff -C2 -d -r1.30 -r1.31 *** sconstruct 6 Sep 2006 19:23:26 -0000 1.30 --- sconstruct 16 Mar 2007 22:41:39 -0000 1.31 *************** *** 28,31 **** --- 28,32 ---- platform = ARGUMENTS['platform'] except KeyError: + import sys print 'You must specify a "platform"' sys.exit(2) |
From: Steven R. <sm...@us...> - 2007-03-05 03:17:33
|
Update of /cvsroot/cppunit/cppunit/include/cppunit/portability In directory sc8-pr-cvs4.sourceforge.net:/tmp/cvs-serv25848/include/cppunit/portability Modified Files: FloatingPoint.h Log Message: Make floatingPointIsFinite() return int. Fix comment about comparisons and IEEE NaN. Index: FloatingPoint.h =================================================================== RCS file: /cvsroot/cppunit/cppunit/include/cppunit/portability/FloatingPoint.h,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** FloatingPoint.h 25 Feb 2007 03:54:35 -0000 1.2 --- FloatingPoint.h 5 Mar 2007 03:17:27 -0000 1.3 *************** *** 8,13 **** /// \brief Tests if a floating-point is a NaN. ! // According to IEEE-754 floating point standard, NaN comparison should always ! // be 'false'. // At least Microsoft Visual Studio 6 is known not to implement this test correctly. // It emits the following code to test equality: --- 8,16 ---- /// \brief Tests if a floating-point is a NaN. ! // According to IEEE-754 floating point standard, ! // (see e.g. page 8 of ! // http://www.cs.berkeley.edu/~wkahan/ieee754status/ieee754.ps) ! // all comparisons with NaN are false except "x != x", which is true. ! // // At least Microsoft Visual Studio 6 is known not to implement this test correctly. // It emits the following code to test equality: *************** *** 33,42 **** /// \brief Tests if a floating-point is finite. /// @return \c true if x is neither a NaN, nor +inf, nor -inf, \c false otherwise. ! inline bool floatingPointIsFinite( double x ) { #if defined(CPPUNIT_HAVE_ISFINITE) ! return (bool)isfinite( x ); #elif defined(CPPUNIT_HAVE_FINITE) ! return (bool)finite( x ); #elif defined(CPPUNIT_HAVE__FINITE) return _finite(x); --- 36,45 ---- /// \brief Tests if a floating-point is finite. /// @return \c true if x is neither a NaN, nor +inf, nor -inf, \c false otherwise. ! inline int floatingPointIsFinite( double x ) { #if defined(CPPUNIT_HAVE_ISFINITE) ! return isfinite( x ); #elif defined(CPPUNIT_HAVE_FINITE) ! return finite( x ); #elif defined(CPPUNIT_HAVE__FINITE) return _finite(x); |
From: Steven R. <sm...@us...> - 2007-03-05 03:17:32
|
Update of /cvsroot/cppunit/cppunit In directory sc8-pr-cvs4.sourceforge.net:/tmp/cvs-serv25848 Modified Files: ChangeLog Log Message: Make floatingPointIsFinite() return int. Fix comment about comparisons and IEEE NaN. Index: ChangeLog =================================================================== RCS file: /cvsroot/cppunit/cppunit/ChangeLog,v retrieving revision 1.264 retrieving revision 1.265 diff -C2 -d -r1.264 -r1.265 *** ChangeLog 25 Feb 2007 09:21:45 -0000 1.264 --- ChangeLog 5 Mar 2007 03:17:27 -0000 1.265 *************** *** 1,2 **** --- 1,7 ---- + 2007-03-04 Steve M. Robbins <sm...@su...> + + * include/cppunit/portability/FloatingPoint.h (floatingPointIsFinite): Change + return type to int, following the convention of isfinite(), finite(), etc. + 2007-02-25 Baptiste Lepilleur <bl...@us...> |
From: Baptiste L. <bl...@us...> - 2007-02-25 09:21:49
|
Update of /cvsroot/cppunit/cppunit In directory sc8-pr-cvs4.sourceforge.net:/tmp/cvs-serv13323 Modified Files: ChangeLog Log Message: * doc/cookbook.dox: changed suite() to return a TestSuite instead of a Test to avoid introducing unnecessary complexity. Index: ChangeLog =================================================================== RCS file: /cvsroot/cppunit/cppunit/ChangeLog,v retrieving revision 1.263 retrieving revision 1.264 diff -C2 -d -r1.263 -r1.264 *** ChangeLog 25 Feb 2007 03:54:34 -0000 1.263 --- ChangeLog 25 Feb 2007 09:21:45 -0000 1.264 *************** *** 1,2 **** --- 1,7 ---- + 2007-02-25 Baptiste Lepilleur <bl...@us...> + + * doc/cookbook.dox: changed suite() to return a TestSuite instead + of a Test to avoid introducing unnecessary complexity. + 2007-02-24 Steve M. Robbins <sm...@su...> |
From: Baptiste L. <bl...@us...> - 2007-02-25 09:21:49
|
Update of /cvsroot/cppunit/cppunit/doc In directory sc8-pr-cvs4.sourceforge.net:/tmp/cvs-serv13323/doc Modified Files: cookbook.dox Log Message: * doc/cookbook.dox: changed suite() to return a TestSuite instead of a Test to avoid introducing unnecessary complexity. Index: cookbook.dox =================================================================== RCS file: /cvsroot/cppunit/cppunit/doc/cookbook.dox,v retrieving revision 1.8 retrieving revision 1.9 diff -C2 -d -r1.8 -r1.9 *** cookbook.dox 27 Nov 2005 18:32:31 -0000 1.8 --- cookbook.dox 25 Feb 2007 09:21:45 -0000 1.9 *************** *** 275,279 **** \code public: ! static CppUnit::Test *suite() { CppUnit::TestSuite *suiteOfTests = new CppUnit::TestSuite( "ComplexNumberTest" ); --- 275,279 ---- \code public: ! static CppUnit::TestSuite *suite() { CppUnit::TestSuite *suiteOfTests = new CppUnit::TestSuite( "ComplexNumberTest" ); |
From: Baptiste L. <bl...@us...> - 2007-02-25 08:49:17
|
Update of /cvsroot/cppunit/cppunit/examples/cppunittest In directory sc8-pr-cvs4.sourceforge.net:/tmp/cvs-serv1787/examples/cppunittest Modified Files: TestAssertTest.cpp Log Message: - removed wrong comment. Index: TestAssertTest.cpp =================================================================== RCS file: /cvsroot/cppunit/cppunit/examples/cppunittest/TestAssertTest.cpp,v retrieving revision 1.14 retrieving revision 1.15 diff -C2 -d -r1.14 -r1.15 *** TestAssertTest.cpp 24 Feb 2007 21:13:04 -0000 1.14 --- TestAssertTest.cpp 25 Feb 2007 08:49:12 -0000 1.15 *************** *** 233,237 **** CPPUNIT_ASSERT_ASSERTION_PASS( CPPUNIT_ASSERT_DOUBLES_EQUAL( inf, inf, 1.0 ) ); // NaN tests ! CPPUNIT_ASSERT_ASSERTION_FAIL( CPPUNIT_ASSERT_DOUBLES_EQUAL( nan, 0.0, 1.0 ) ); // this one fails CPPUNIT_ASSERT_ASSERTION_FAIL( CPPUNIT_ASSERT_DOUBLES_EQUAL( nan, nan, 1.0 ) ); CPPUNIT_ASSERT_ASSERTION_FAIL( CPPUNIT_ASSERT_DOUBLES_EQUAL( nan, inf, 1.0 ) ); --- 233,237 ---- CPPUNIT_ASSERT_ASSERTION_PASS( CPPUNIT_ASSERT_DOUBLES_EQUAL( inf, inf, 1.0 ) ); // NaN tests ! CPPUNIT_ASSERT_ASSERTION_FAIL( CPPUNIT_ASSERT_DOUBLES_EQUAL( nan, 0.0, 1.0 ) ); CPPUNIT_ASSERT_ASSERTION_FAIL( CPPUNIT_ASSERT_DOUBLES_EQUAL( nan, nan, 1.0 ) ); CPPUNIT_ASSERT_ASSERTION_FAIL( CPPUNIT_ASSERT_DOUBLES_EQUAL( nan, inf, 1.0 ) ); |
From: Steven R. <sm...@us...> - 2007-02-25 03:54:39
|
Update of /cvsroot/cppunit/cppunit/include/cppunit/portability In directory sc8-pr-cvs4.sourceforge.net:/tmp/cvs-serv23570/include/cppunit/portability Modified Files: FloatingPoint.h Log Message: portability/FloatingPoint.h must include Portability.h Index: FloatingPoint.h =================================================================== RCS file: /cvsroot/cppunit/cppunit/include/cppunit/portability/FloatingPoint.h,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** FloatingPoint.h 24 Feb 2007 21:13:04 -0000 1.1 --- FloatingPoint.h 25 Feb 2007 03:54:35 -0000 1.2 *************** *** 2,5 **** --- 2,6 ---- #define CPPUNIT_PORTABILITY_FLOATINGPOINT_H_INCLUDED + #include <cppunit/Portability.h> #include <math.h> |
From: Steven R. <sm...@us...> - 2007-02-25 03:54:39
|
Update of /cvsroot/cppunit/cppunit In directory sc8-pr-cvs4.sourceforge.net:/tmp/cvs-serv23570 Modified Files: ChangeLog Log Message: portability/FloatingPoint.h must include Portability.h Index: ChangeLog =================================================================== RCS file: /cvsroot/cppunit/cppunit/ChangeLog,v retrieving revision 1.262 retrieving revision 1.263 diff -C2 -d -r1.262 -r1.263 *** ChangeLog 24 Feb 2007 21:13:03 -0000 1.262 --- ChangeLog 25 Feb 2007 03:54:34 -0000 1.263 *************** *** 1,2 **** --- 1,6 ---- + 2007-02-24 Steve M. Robbins <sm...@su...> + + * include/cppunit/portability/FloatingPoint.h: Include Portability.h. + 2007-02-24 Baptiste Lepilleur <bl...@us...> |
From: Baptiste L. <bl...@us...> - 2007-02-24 21:13:12
|
Update of /cvsroot/cppunit/cppunit In directory sc8-pr-cvs4.sourceforge.net:/tmp/cvs-serv9552 Modified Files: ChangeLog Log Message: * src/cppunit/TestAssert.cpp (assertDoubleEquals): Moved finite & NaN tests to include/cppunit/portability/FloatingPoint.h. Changed implementation assertDoubleEquals to explicitly test for NaN in case of non-finite values to force equality failure in the presence of NaN. Previous implementation failed on Microsoft Visual Studio 6 (on this platform: NaN == NaN). * examples/cppunittest/TestAssertTest.cpp: Add more unit tests to test the portable floating-point primitive. Added missing include <limits>. * include/cppunit/portability/Makefile.am: * include/cppunit/portability/FloatingPoint.h: Added file. Extracted isfinite() from TestAssert.cpp. * include/cppunit/config-evc4: * include/cppunit/config-msvc6: Added support for _finite(). Index: ChangeLog =================================================================== RCS file: /cvsroot/cppunit/cppunit/ChangeLog,v retrieving revision 1.261 retrieving revision 1.262 diff -C2 -d -r1.261 -r1.262 *** ChangeLog 31 Jan 2007 05:27:06 -0000 1.261 --- ChangeLog 24 Feb 2007 21:13:03 -0000 1.262 *************** *** 1,2 **** --- 1,21 ---- + 2007-02-24 Baptiste Lepilleur <bl...@us...> + + * src/cppunit/TestAssert.cpp (assertDoubleEquals): Moved finite & NaN + tests to include/cppunit/portability/FloatingPoint.h. Changed + implementation assertDoubleEquals to explicitly test for NaN + in case of non-finite values to force equality failure in the + presence of NaN. Previous implementation failed on Microsoft + Visual Studio 6 (on this platform: NaN == NaN). + * examples/cppunittest/TestAssertTest.cpp: Add more unit tests to + test the portable floating-point primitive. Added missing + include <limits>. + + * include/cppunit/portability/Makefile.am: + * include/cppunit/portability/FloatingPoint.h: Added file. Extracted + isfinite() from TestAssert.cpp. + + * include/cppunit/config-evc4: + * include/cppunit/config-msvc6: Added support for _finite(). + 2007-01-30 Steve M. Robbins <sm...@su...> |
From: Baptiste L. <bl...@us...> - 2007-02-24 21:13:12
|
Update of /cvsroot/cppunit/cppunit/include/cppunit/portability In directory sc8-pr-cvs4.sourceforge.net:/tmp/cvs-serv9552/include/cppunit/portability Modified Files: Makefile.am Added Files: FloatingPoint.h Log Message: * src/cppunit/TestAssert.cpp (assertDoubleEquals): Moved finite & NaN tests to include/cppunit/portability/FloatingPoint.h. Changed implementation assertDoubleEquals to explicitly test for NaN in case of non-finite values to force equality failure in the presence of NaN. Previous implementation failed on Microsoft Visual Studio 6 (on this platform: NaN == NaN). * examples/cppunittest/TestAssertTest.cpp: Add more unit tests to test the portable floating-point primitive. Added missing include <limits>. * include/cppunit/portability/Makefile.am: * include/cppunit/portability/FloatingPoint.h: Added file. Extracted isfinite() from TestAssert.cpp. * include/cppunit/config-evc4: * include/cppunit/config-msvc6: Added support for _finite(). Index: Makefile.am =================================================================== RCS file: /cvsroot/cppunit/cppunit/include/cppunit/portability/Makefile.am,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** Makefile.am 25 Jun 2004 10:54:47 -0000 1.3 --- Makefile.am 24 Feb 2007 21:13:04 -0000 1.4 *************** *** 2,9 **** libcppunitinclude_HEADERS = \ ! CppUnitDeque.h \ ! CppUnitMap.h \ ! CppUnitSet.h \ ! CppUnitStack.h \ CppUnitVector.h \ ! Stream.h --- 2,10 ---- libcppunitinclude_HEADERS = \ ! CppUnitDeque.h \ ! CppUnitMap.h \ ! CppUnitSet.h \ ! CppUnitStack.h \ CppUnitVector.h \ ! FloatingPoint.h \ ! Stream.h --- NEW FILE: FloatingPoint.h --- #ifndef CPPUNIT_PORTABILITY_FLOATINGPOINT_H_INCLUDED #define CPPUNIT_PORTABILITY_FLOATINGPOINT_H_INCLUDED #include <math.h> CPPUNIT_NS_BEGIN /// \brief Tests if a floating-point is a NaN. // According to IEEE-754 floating point standard, NaN comparison should always // be 'false'. // At least Microsoft Visual Studio 6 is known not to implement this test correctly. // It emits the following code to test equality: // fcomp qword ptr [nan] // fnstsw ax // copie fp (floating-point) status register to ax // test ah,40h // test bit 14 of ax (0x4000) => C3 of fp status register // According to the following documentation on the x86 floating point status register, // the C2 bit should be tested to test for NaN value. // http://webster.cs.ucr.edu/AoA/Windows/HTML/RealArithmetic.html#1000117 // In Microsoft Visual Studio 2003 & 2005, the test is implemented with: // test ah,44h // Visual Studio 2005 test both C2 & C3... // // To work around this, a NaN is assumed to be detected if no strict ordering is found. inline bool floatingPointIsUnordered( double x ) { // x != x will detect a NaN on conformant platform // (2.0 < x && x < 1.0) will detect a NaN on non conformant platform: // => no ordering can be found for x. return (x != x) || (2.0 < x && x < 1.0); } /// \brief Tests if a floating-point is finite. /// @return \c true if x is neither a NaN, nor +inf, nor -inf, \c false otherwise. inline bool floatingPointIsFinite( double x ) { #if defined(CPPUNIT_HAVE_ISFINITE) return (bool)isfinite( x ); #elif defined(CPPUNIT_HAVE_FINITE) return (bool)finite( x ); #elif defined(CPPUNIT_HAVE__FINITE) return _finite(x); #else double testInf = x * 0.0; // Produce 0.0 if x is finite, a NaN otherwise. return testInf == 0.0 && !floatingPointIsUnordered(testInf); #endif } CPPUNIT_NS_END #endif // CPPUNIT_PORTABILITY_FLOATINGPOINT_H_INCLUDED |
From: Baptiste L. <bl...@us...> - 2007-02-24 21:13:12
|
Update of /cvsroot/cppunit/cppunit/include/cppunit/config In directory sc8-pr-cvs4.sourceforge.net:/tmp/cvs-serv9552/include/cppunit/config Modified Files: config-evc4.h config-msvc6.h Log Message: * src/cppunit/TestAssert.cpp (assertDoubleEquals): Moved finite & NaN tests to include/cppunit/portability/FloatingPoint.h. Changed implementation assertDoubleEquals to explicitly test for NaN in case of non-finite values to force equality failure in the presence of NaN. Previous implementation failed on Microsoft Visual Studio 6 (on this platform: NaN == NaN). * examples/cppunittest/TestAssertTest.cpp: Add more unit tests to test the portable floating-point primitive. Added missing include <limits>. * include/cppunit/portability/Makefile.am: * include/cppunit/portability/FloatingPoint.h: Added file. Extracted isfinite() from TestAssert.cpp. * include/cppunit/config-evc4: * include/cppunit/config-msvc6: Added support for _finite(). Index: config-evc4.h =================================================================== RCS file: /cvsroot/cppunit/cppunit/include/cppunit/config/config-evc4.h,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** config-evc4.h 25 Jun 2004 12:15:24 -0000 1.2 --- config-evc4.h 24 Feb 2007 21:13:04 -0000 1.3 *************** *** 61,64 **** --- 61,69 ---- #endif + /* define to 1 if the compiler has _finite() */ + #ifndef CPPUNIT_HAVE__FINITE + #define CPPUNIT_HAVE__FINITE 1 + #endif + // Uncomment to turn on STL wrapping => use this to test compilation. // This will make CppUnit subclass std::vector & co to provide default Index: config-msvc6.h =================================================================== RCS file: /cvsroot/cppunit/cppunit/include/cppunit/config/config-msvc6.h,v retrieving revision 1.10 retrieving revision 1.11 diff -C2 -d -r1.10 -r1.11 *** config-msvc6.h 30 Jul 2005 07:02:38 -0000 1.10 --- config-msvc6.h 24 Feb 2007 21:13:04 -0000 1.11 *************** *** 65,68 **** --- 65,73 ---- #define CPPUNIT_HAVE_CPP_CAST 1 + /* define to 1 if the compiler has _finite() */ + #ifndef CPPUNIT_HAVE__FINITE + #define CPPUNIT_HAVE__FINITE 1 + #endif + // Uncomment to turn on STL wrapping => use this to test compilation. |
From: Baptiste L. <bl...@us...> - 2007-02-24 21:13:12
|
Update of /cvsroot/cppunit/cppunit/src/cppunit In directory sc8-pr-cvs4.sourceforge.net:/tmp/cvs-serv9552/src/cppunit Modified Files: TestAssert.cpp cppunit.dsp Log Message: * src/cppunit/TestAssert.cpp (assertDoubleEquals): Moved finite & NaN tests to include/cppunit/portability/FloatingPoint.h. Changed implementation assertDoubleEquals to explicitly test for NaN in case of non-finite values to force equality failure in the presence of NaN. Previous implementation failed on Microsoft Visual Studio 6 (on this platform: NaN == NaN). * examples/cppunittest/TestAssertTest.cpp: Add more unit tests to test the portable floating-point primitive. Added missing include <limits>. * include/cppunit/portability/Makefile.am: * include/cppunit/portability/FloatingPoint.h: Added file. Extracted isfinite() from TestAssert.cpp. * include/cppunit/config-evc4: * include/cppunit/config-msvc6: Added support for _finite(). Index: cppunit.dsp =================================================================== RCS file: /cvsroot/cppunit/cppunit/src/cppunit/cppunit.dsp,v retrieving revision 1.54 retrieving revision 1.55 diff -C2 -d -r1.54 -r1.55 *** cppunit.dsp 13 Oct 2005 20:35:50 -0000 1.54 --- cppunit.dsp 24 Feb 2007 21:13:04 -0000 1.55 *************** *** 248,251 **** --- 248,255 ---- # Begin Source File + SOURCE=..\..\include\cppunit\portability\FloatingPoint.h + # End Source File + # Begin Source File + SOURCE=..\..\include\cppunit\Portability.h # End Source File Index: TestAssert.cpp =================================================================== RCS file: /cvsroot/cppunit/cppunit/src/cppunit/TestAssert.cpp,v retrieving revision 1.13 retrieving revision 1.14 diff -C2 -d -r1.13 -r1.14 *** TestAssert.cpp 27 Jan 2007 05:45:08 -0000 1.13 --- TestAssert.cpp 24 Feb 2007 21:13:04 -0000 1.14 *************** *** 1,18 **** #include <cppunit/TestAssert.h> ! ! #include <math.h> ! ! #if !defined(CPPUNIT_HAVE_ISFINITE) ! ! static inline bool isfinite( double x ) ! { ! #if defined(CPPUNIT_HAVE_FINITE) ! return finite( x ); ! #else ! return ( x * 0.0 ) == 0.0; ! #endif ! } ! ! #endif CPPUNIT_NS_BEGIN --- 1,4 ---- #include <cppunit/TestAssert.h> ! #include <cppunit/portability/FloatingPoint.h> CPPUNIT_NS_BEGIN *************** *** 31,38 **** bool equal; ! if ( isfinite(expected) && isfinite(actual) ) equal = fabs( expected - actual ) <= delta; else ! equal = expected == actual; Asserter::failNotEqualIf( !equal, --- 17,37 ---- bool equal; ! if ( floatingPointIsFinite(expected) && floatingPointIsFinite(actual) ) equal = fabs( expected - actual ) <= delta; else ! { ! // If expected or actual is not finite, it may be +inf, -inf or NaN (Not a Number). ! // Value of +inf or -inf leads to a true equality regardless of delta if both ! // expected and actual have the same value (infinity sign). ! // NaN Value should always lead to a failed equality. ! if ( floatingPointIsUnordered(expected) || floatingPointIsUnordered(actual) ) ! { ! equal = false; // expected or actual is a NaN ! } ! else // ordered values, +inf or -inf comparison ! { ! equal = expected == actual; ! } ! } Asserter::failNotEqualIf( !equal, |
From: Baptiste L. <bl...@us...> - 2007-02-24 21:13:12
|
Update of /cvsroot/cppunit/cppunit/examples/cppunittest In directory sc8-pr-cvs4.sourceforge.net:/tmp/cvs-serv9552/examples/cppunittest Modified Files: CppUnitTestMain.dsp TestAssertTest.cpp Log Message: * src/cppunit/TestAssert.cpp (assertDoubleEquals): Moved finite & NaN tests to include/cppunit/portability/FloatingPoint.h. Changed implementation assertDoubleEquals to explicitly test for NaN in case of non-finite values to force equality failure in the presence of NaN. Previous implementation failed on Microsoft Visual Studio 6 (on this platform: NaN == NaN). * examples/cppunittest/TestAssertTest.cpp: Add more unit tests to test the portable floating-point primitive. Added missing include <limits>. * include/cppunit/portability/Makefile.am: * include/cppunit/portability/FloatingPoint.h: Added file. Extracted isfinite() from TestAssert.cpp. * include/cppunit/config-evc4: * include/cppunit/config-msvc6: Added support for _finite(). Index: TestAssertTest.cpp =================================================================== RCS file: /cvsroot/cppunit/cppunit/examples/cppunittest/TestAssertTest.cpp,v retrieving revision 1.13 retrieving revision 1.14 diff -C2 -d -r1.13 -r1.14 *** TestAssertTest.cpp 31 Jan 2007 05:27:07 -0000 1.13 --- TestAssertTest.cpp 24 Feb 2007 21:13:04 -0000 1.14 *************** *** 1,5 **** --- 1,7 ---- #include "CoreSuite.h" #include "TestAssertTest.h" + #include <cppunit/portability/FloatingPoint.h> #include <algorithm> + #include <limits> /* *************** *** 193,206 **** } void TestAssertTest::testAssertDoubleNonFinite() { double inf = std::numeric_limits<double>::infinity(); CPPUNIT_ASSERT_ASSERTION_FAIL( CPPUNIT_ASSERT_DOUBLES_EQUAL( inf, 0.0, 1.0 ) ); CPPUNIT_ASSERT_ASSERTION_FAIL( CPPUNIT_ASSERT_DOUBLES_EQUAL( 0.0, inf, 1.0 ) ); CPPUNIT_ASSERT_ASSERTION_PASS( CPPUNIT_ASSERT_DOUBLES_EQUAL( inf, inf, 1.0 ) ); ! ! double nan = std::numeric_limits<double>::quiet_NaN(); ! CPPUNIT_ASSERT_ASSERTION_FAIL( CPPUNIT_ASSERT_DOUBLES_EQUAL( nan, 0.0, 1.0 ) ); CPPUNIT_ASSERT_ASSERTION_FAIL( CPPUNIT_ASSERT_DOUBLES_EQUAL( nan, nan, 1.0 ) ); CPPUNIT_ASSERT_ASSERTION_FAIL( CPPUNIT_ASSERT_DOUBLES_EQUAL( nan, inf, 1.0 ) ); --- 195,237 ---- } + void TestAssertTest::testAssertDoubleNonFinite() { double inf = std::numeric_limits<double>::infinity(); + double nan = std::numeric_limits<double>::quiet_NaN(); + // test our portable floating-point primitives that detect NaN values + CPPUNIT_ASSERT( CPPUNIT_NS::floatingPointIsUnordered( nan ) ); + CPPUNIT_ASSERT( !CPPUNIT_NS::floatingPointIsUnordered( inf ) ); + CPPUNIT_ASSERT( !CPPUNIT_NS::floatingPointIsUnordered( -inf ) ); + CPPUNIT_ASSERT( !CPPUNIT_NS::floatingPointIsUnordered( 1.0 ) ); + CPPUNIT_ASSERT( !CPPUNIT_NS::floatingPointIsUnordered( 1.5 ) ); + CPPUNIT_ASSERT( !CPPUNIT_NS::floatingPointIsUnordered( 2.0 ) ); + CPPUNIT_ASSERT( !CPPUNIT_NS::floatingPointIsUnordered( 2.5 ) ); + CPPUNIT_ASSERT( !CPPUNIT_NS::floatingPointIsUnordered( 0.0 ) ); + CPPUNIT_ASSERT( !CPPUNIT_NS::floatingPointIsUnordered( -1.0 ) ); + CPPUNIT_ASSERT( !CPPUNIT_NS::floatingPointIsUnordered( -2.0 ) ); + // test our portable floating-point primitives that detect finite values + CPPUNIT_ASSERT( CPPUNIT_NS::floatingPointIsFinite( 0.0 ) ); + CPPUNIT_ASSERT( CPPUNIT_NS::floatingPointIsFinite( 0.5 ) ); + CPPUNIT_ASSERT( CPPUNIT_NS::floatingPointIsFinite( 1.0 ) ); + CPPUNIT_ASSERT( CPPUNIT_NS::floatingPointIsFinite( 1.5 ) ); + CPPUNIT_ASSERT( CPPUNIT_NS::floatingPointIsFinite( 2.0 ) ); + CPPUNIT_ASSERT( CPPUNIT_NS::floatingPointIsFinite( 2.5 ) ); + CPPUNIT_ASSERT( CPPUNIT_NS::floatingPointIsFinite( -1.5 ) ); + CPPUNIT_ASSERT( !CPPUNIT_NS::floatingPointIsFinite( nan ) ); + CPPUNIT_ASSERT( !CPPUNIT_NS::floatingPointIsFinite( inf ) ); + CPPUNIT_ASSERT( !CPPUNIT_NS::floatingPointIsFinite( -inf ) ); + // Infinity tests + CPPUNIT_ASSERT( inf == inf ); + CPPUNIT_ASSERT( -inf == -inf ); + CPPUNIT_ASSERT( -inf != inf ); + CPPUNIT_ASSERT( -inf < inf ); + CPPUNIT_ASSERT( inf > -inf ); CPPUNIT_ASSERT_ASSERTION_FAIL( CPPUNIT_ASSERT_DOUBLES_EQUAL( inf, 0.0, 1.0 ) ); CPPUNIT_ASSERT_ASSERTION_FAIL( CPPUNIT_ASSERT_DOUBLES_EQUAL( 0.0, inf, 1.0 ) ); CPPUNIT_ASSERT_ASSERTION_PASS( CPPUNIT_ASSERT_DOUBLES_EQUAL( inf, inf, 1.0 ) ); ! // NaN tests ! CPPUNIT_ASSERT_ASSERTION_FAIL( CPPUNIT_ASSERT_DOUBLES_EQUAL( nan, 0.0, 1.0 ) ); // this one fails CPPUNIT_ASSERT_ASSERTION_FAIL( CPPUNIT_ASSERT_DOUBLES_EQUAL( nan, nan, 1.0 ) ); CPPUNIT_ASSERT_ASSERTION_FAIL( CPPUNIT_ASSERT_DOUBLES_EQUAL( nan, inf, 1.0 ) ); Index: CppUnitTestMain.dsp =================================================================== RCS file: /cvsroot/cppunit/cppunit/examples/cppunittest/CppUnitTestMain.dsp,v retrieving revision 1.27 retrieving revision 1.28 diff -C2 -d -r1.27 -r1.28 *** CppUnitTestMain.dsp 13 Oct 2005 20:35:51 -0000 1.27 --- CppUnitTestMain.dsp 24 Feb 2007 21:13:03 -0000 1.28 *************** *** 177,180 **** --- 177,188 ---- # Begin Source File + SOURCE=.\assertion_traitsTest.cpp + # End Source File + # Begin Source File + + SOURCE=.\assertion_traitsTest.h + # End Source File + # Begin Source File + SOURCE=.\ExceptionTest.cpp # End Source File |