Thread: [Mockpp-commits] mockpp/3party/cxxtest/cxxtest Descriptions.cpp,1.1,1.2 GlobalFixture.cpp,1.1,1.2 Li
Brought to you by:
ewald-arnold
Update of /cvsroot/mockpp/mockpp/3party/cxxtest/cxxtest In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv3761/3party/cxxtest/cxxtest Modified Files: Descriptions.cpp GlobalFixture.cpp LinkedList.cpp Makefile.am RealDescriptions.cpp ValueTraits.cpp ValueTraits.h Log Message: basic integration of cxxtest Index: RealDescriptions.cpp =================================================================== RCS file: /cvsroot/mockpp/mockpp/3party/cxxtest/cxxtest/RealDescriptions.cpp,v retrieving revision 1.1 retrieving revision 1.2 diff -u -d -r1.1 -r1.2 --- RealDescriptions.cpp 9 Dec 2005 15:57:51 -0000 1.1 +++ RealDescriptions.cpp 9 Dec 2005 20:40:42 -0000 1.2 @@ -8,12 +8,14 @@ #include <cxxtest/RealDescriptions.h> -namespace CxxTest +namespace CxxTest { + List RealSuiteDescription::_suites = { 0, 0 }; + RealTestDescription::RealTestDescription() { } - + RealTestDescription::RealTestDescription( List &argList, SuiteDescription &argSuite, unsigned argLine, @@ -32,7 +34,7 @@ _testName = argTestName; attach( argList ); } - + bool RealTestDescription::setUp() { if ( !suite() ) @@ -97,7 +99,7 @@ _TS_CATCH_ABORT( {} ) ___TSM_CATCH( file(), line(), "Exception thrown from test" ); } - + RealSuiteDescription::RealSuiteDescription() {} RealSuiteDescription::RealSuiteDescription( const char *argFile, unsigned argLine, @@ -116,7 +118,7 @@ _line = argLine; _suiteName = argSuiteName; _tests = &argTests; - + attach( _suites ); } @@ -128,9 +130,9 @@ const TestDescription *RealSuiteDescription::firstTest() const { return (const RealTestDescription *)_tests->head(); } SuiteDescription *RealSuiteDescription::next() { return (RealSuiteDescription *)Link::next(); } const SuiteDescription *RealSuiteDescription::next() const { return (const RealSuiteDescription *)Link::next(); } - + unsigned RealSuiteDescription::numTests() const { return _tests->size(); } - + const TestDescription &RealSuiteDescription::testDescription( unsigned i ) const { return *(RealTestDescription *)_tests->nth( i ); @@ -140,7 +142,7 @@ { _tests->activateAll(); } - + bool RealSuiteDescription::leaveOnly( const char *testName ) { for ( TestDescription *td = firstTest(); td != 0; td = td->next() ) { @@ -149,9 +151,9 @@ return true; } } - return false; + return false; } - + StaticSuiteDescription::StaticSuiteDescription() {} StaticSuiteDescription::StaticSuiteDescription( const char *argFile, unsigned argLine, const char *argSuiteName, TestSuite &argSuite, @@ -168,7 +170,7 @@ RealSuiteDescription::initialize( argFile, argLine, argSuiteName, argTests ); doInitialize( argSuite ); } - + void StaticSuiteDescription::doInitialize( TestSuite &argSuite ) { _suite = &argSuite; @@ -204,17 +206,17 @@ _createLine = argCreateLine; _destroyLine = argDestroyLine; } - + List &RealWorldDescription::suites() { return RealSuiteDescription::_suites; } - + unsigned RealWorldDescription::numSuites( void ) const { return suites().size(); } - + unsigned RealWorldDescription::numTotalTests( void ) const { unsigned count = 0; @@ -222,7 +224,7 @@ count += sd->numTests(); return count; } - + SuiteDescription *RealWorldDescription::firstSuite() { return (RealSuiteDescription *)suites().head(); @@ -258,7 +260,7 @@ } return false; } - + bool RealWorldDescription::setUp() { for ( GlobalFixture *gf = GlobalFixture::firstGlobalFixture(); gf != 0; gf = gf->nextGlobalFixture() ) { Index: ValueTraits.h =================================================================== RCS file: /cvsroot/mockpp/mockpp/3party/cxxtest/cxxtest/ValueTraits.h,v retrieving revision 1.1 retrieving revision 1.2 diff -u -d -r1.1 -r1.2 --- ValueTraits.h 9 Dec 2005 15:57:51 -0000 1.1 +++ ValueTraits.h 9 Dec 2005 20:40:42 -0000 1.2 @@ -4,7 +4,7 @@ // // ValueTraits are used by CxxTest to convert arbitrary // values used in TS_ASSERT_EQUALS() to a string representation. -// +// // This header file contains value traits for builtin integral types. // To declare value traits for new types you should instantiate the class // ValueTraits<YourClass>. @@ -18,7 +18,7 @@ # define CXXTEST_TEMPLATE_INSTANTIATION template<> #endif // _CXXTEST_OLD_TEMPLATE_SYNTAX -namespace CxxTest +namespace CxxTest { // // This is how we use the value traits @@ -75,11 +75,11 @@ { enum { MAX_BYTES = 8 }; char _asString[sizeof("{ ") + sizeof("XX ") * MAX_BYTES + sizeof("... }")]; - + public: ValueTraits( const T &t ) { bytesToString( (const unsigned char *)&t, sizeof(T), MAX_BYTES, _asString ); } const char *asString( void ) const { return _asString; } - }; + }; // // traits( T t ) @@ -112,7 +112,7 @@ # else // !_CXXTEST_NO_COPY_CONST # define CXXTEST_COPY_CONST_TRAITS(CXXTEST_CLASS) CXXTEST_COPY_TRAITS(CXXTEST_CLASS, const CXXTEST_CLASS) # endif // _CXXTEST_NO_COPY_CONST - + // // Avoid compiler warnings about unsigned types always >= 0 // @@ -149,7 +149,7 @@ *s++ = '-'; n = abs(n); } - + N digit = 1; while ( digit <= (n / base) ) digit *= base; @@ -167,7 +167,7 @@ // All the specific ValueTraits follow. // You can #define CXXTEST_USER_VALUE_TRAITS if you don't want them // - + #ifndef CXXTEST_USER_VALUE_TRAITS // // ValueTraits: const char * const & @@ -178,7 +178,7 @@ { ValueTraits &operator=( const ValueTraits & ); const char *_asString; - + public: ValueTraits( const char * const &value ) : _asString( value ) {} ValueTraits( const ValueTraits &other ) : _asString( other._asString ) {} @@ -190,12 +190,12 @@ // // ValueTraits: bool - // + // CXXTEST_TEMPLATE_INSTANTIATION class ValueTraits<const bool> { bool _value; - + public: ValueTraits( const bool value ) : _value( value ) {} const char *asString( void ) const { return _value ? "true" : "false"; } @@ -249,7 +249,7 @@ }; CXXTEST_COPY_CONST_TRAITS( signed long int ); - + // // ValueTraits: unsigned long // @@ -264,17 +264,17 @@ }; CXXTEST_COPY_CONST_TRAITS( unsigned long int ); - + // // All decimals are the same as the long version // - + CXXTEST_COPY_TRAITS( const signed int, const signed long int ); CXXTEST_COPY_TRAITS( const unsigned int, const unsigned long int ); CXXTEST_COPY_TRAITS( const signed short int, const signed long int ); CXXTEST_COPY_TRAITS( const unsigned short int, const unsigned long int ); CXXTEST_COPY_TRAITS( const unsigned char, const unsigned long int ); - + CXXTEST_COPY_CONST_TRAITS( signed int ); CXXTEST_COPY_CONST_TRAITS( unsigned int ); CXXTEST_COPY_CONST_TRAITS( signed short int ); @@ -310,7 +310,7 @@ class ValueTraits<const double> { public: - ValueTraits( double t ) + ValueTraits( double t ) { ( requiredDigitsOnLeft( t ) > MAX_DIGITS_ON_LEFT ) ? hugeNumber( t ) : @@ -318,7 +318,7 @@ } const char *asString( void ) const { return _asString; } - + private: enum { MAX_DIGITS_ON_LEFT = 24, DIGITS_ON_RIGHT = 4, BASE = 10 }; char _asString[1 + MAX_DIGITS_ON_LEFT + 1 + DIGITS_ON_RIGHT + 1]; Index: GlobalFixture.cpp =================================================================== RCS file: /cvsroot/mockpp/mockpp/3party/cxxtest/cxxtest/GlobalFixture.cpp,v retrieving revision 1.1 retrieving revision 1.2 diff -u -d -r1.1 -r1.2 --- GlobalFixture.cpp 9 Dec 2005 15:57:51 -0000 1.1 +++ GlobalFixture.cpp 9 Dec 2005 20:40:42 -0000 1.2 @@ -3,16 +3,18 @@ #include <cxxtest/GlobalFixture.h> -namespace CxxTest +namespace CxxTest { + List GlobalFixture::_list = { 0, 0 }; + bool GlobalFixture::setUpWorld() { return true; } bool GlobalFixture::tearDownWorld() { return true; } bool GlobalFixture::setUp() { return true; } bool GlobalFixture::tearDown() { return true; } - + GlobalFixture::GlobalFixture() { attach( _list ); } GlobalFixture::~GlobalFixture() { detach( _list ); } - + GlobalFixture *GlobalFixture::firstGlobalFixture() { return (GlobalFixture *)_list.head(); } GlobalFixture *GlobalFixture::lastGlobalFixture() { return (GlobalFixture *)_list.tail(); } GlobalFixture *GlobalFixture::nextGlobalFixture() { return (GlobalFixture *)next(); } Index: Makefile.am =================================================================== RCS file: /cvsroot/mockpp/mockpp/3party/cxxtest/cxxtest/Makefile.am,v retrieving revision 1.1 retrieving revision 1.2 diff -u -d -r1.1 -r1.2 --- Makefile.am 9 Dec 2005 16:19:16 -0000 1.1 +++ Makefile.am 9 Dec 2005 20:40:42 -0000 1.2 @@ -1,38 +1,48 @@ -cxxtest_SOURCES = -Descriptions.cpp \ -DummyDescriptions.cpp \ -GlobalFixture.cpp \ -LinkedList.cpp \ -RealDescriptions.cpp \ -Root.cpp \ -TestSuite.cpp \ -TestTracker.cpp \ -ValueTraits.cpp - -cxxtest_HEADERS= -Descriptions.h \ -DummyDescriptions.h \ -ErrorFormatter.h \ -ErrorPrinter.h \ -Flags.h \ -GlobalFixture.h \ -Gui.h \ -LinkedList.h \ -Mock.h \ -ParenPrinter.h \ -QtGui.h \ -RealDescriptions.h \ -SelfTest.h \ -StdHeaders.h \ -StdioFilePrinter.h \ -StdioPrinter.h \ -StdValueTraits.h \ -TeeListener.h \ -TestListener.h \ -TestRunner.h \ -TestSuite.h \ -TestTracker.h \ -ValueTraits.h \ -Win32Gui.h \ -X11Gui.h \ -YesNoRunner.h +INCLUDES = $(all_includes) -I$(top_srcdir) -I$(top_srcdir)/3party/cxxtest -I$(top_builddir) $(EA_EXTRA_INC) +DEFAULT_INCLUDES = $(INCLUDES) + +lib_LTLIBRARIES = libmockpp_cxxtest.la + +libmockpp_cxxtest_la_LDFLAGS = -no-undefined -version-info \ + $(LT_CURRENT):$(LT_REVISION):$(LT_AGE) + +libmockpp_cxxtestincludedir = $(includedir)/mockpp/mockpp_cxxtest + +libmockpp_cxxtest_la_SOURCES = \ + Descriptions.cpp \ + DummyDescriptions.cpp \ + GlobalFixture.cpp \ + LinkedList.cpp \ + RealDescriptions.cpp \ + TestSuite.cpp \ + TestTracker.cpp \ + ValueTraits.cpp +# Root.cpp + +libmockpp_cxxtestinclude_HEADERS = \ + Descriptions.h \ + DummyDescriptions.h \ + ErrorFormatter.h \ + ErrorPrinter.h \ + Flags.h \ + GlobalFixture.h \ + Gui.h \ + LinkedList.h \ + Mock.h \ + ParenPrinter.h \ + QtGui.h \ + RealDescriptions.h \ + SelfTest.h \ + StdHeaders.h \ + StdioFilePrinter.h \ + StdioPrinter.h \ + StdValueTraits.h \ + TeeListener.h \ + TestListener.h \ + TestRunner.h \ + TestSuite.h \ + TestTracker.h \ + ValueTraits.h \ + Win32Gui.h \ + X11Gui.h \ + YesNoRunner.h Index: LinkedList.cpp =================================================================== RCS file: /cvsroot/mockpp/mockpp/3party/cxxtest/cxxtest/LinkedList.cpp,v retrieving revision 1.1 retrieving revision 1.2 diff -u -d -r1.1 -r1.2 --- LinkedList.cpp 9 Dec 2005 15:57:51 -0000 1.1 +++ LinkedList.cpp 9 Dec 2005 20:40:42 -0000 1.2 @@ -5,14 +5,11 @@ namespace CxxTest { - List GlobalFixture::_list = { 0, 0 }; - List RealSuiteDescription::_suites = { 0, 0 }; - void List::initialize() { _head = _tail = 0; } - + Link *List::head() { Link *l = _head; @@ -89,12 +86,12 @@ Link::~Link() { } - + bool Link::active() const { return _active; } - + void Link::setActive( bool value ) { _active = value; @@ -104,12 +101,12 @@ { return _next; } - + Link * Link::justPrev() { return _prev; } - + Link * Link::next() { Link *l = _next; @@ -117,7 +114,7 @@ l = l->_next; return l; } - + Link * Link::prev() { Link *l = _prev; @@ -125,7 +122,7 @@ l = l->_prev; return l; } - + const Link * Link::next() const { Link *l = _next; @@ -133,7 +130,7 @@ l = l->_next; return l; } - + const Link * Link::prev() const { Link *l = _prev; @@ -141,7 +138,7 @@ l = l->_prev; return l; } - + void Link::attach( List &l ) { if ( l._tail ) @@ -149,7 +146,7 @@ _prev = l._tail; _next = 0; - + if ( l._head == 0 ) l._head = this; l._tail = this; @@ -161,7 +158,7 @@ _prev->_next = _next; else l._head = _next; - + if ( _next ) _next->_prev = _prev; else Index: ValueTraits.cpp =================================================================== RCS file: /cvsroot/mockpp/mockpp/3party/cxxtest/cxxtest/ValueTraits.cpp,v retrieving revision 1.1 retrieving revision 1.2 diff -u -d -r1.1 -r1.2 --- ValueTraits.cpp 9 Dec 2005 15:57:51 -0000 1.1 +++ ValueTraits.cpp 9 Dec 2005 20:40:42 -0000 1.2 @@ -3,12 +3,12 @@ #include <cxxtest/ValueTraits.h> -namespace CxxTest +namespace CxxTest { // // Non-inline functions from ValueTraits.h // - + char digitToChar( unsigned digit ) { if ( digit < 10 ) @@ -26,7 +26,7 @@ asHex[2] = '\0'; return asHex; } - + char *copyString( char *dst, const char *src ) { while ( (*dst = *src) != '\0' ) { @@ -78,13 +78,13 @@ { return charToString( (unsigned long)(unsigned char)c, s ); } - + char *bytesToString( const unsigned char *bytes, unsigned numBytes, unsigned maxBytes, char *s ) { bool truncate = (numBytes > maxBytes); if ( truncate ) numBytes = maxBytes; - + s = copyString( s, "{ " ); for ( unsigned i = 0; i < numBytes; ++ i, ++ bytes ) s = copyString( copyString( s, byteToHex( *bytes ) ), " " ); @@ -120,7 +120,7 @@ s = copyString( s, "E" ); s = numberToString( requiredDigitsOnLeft( t ) - 1, s ); } - + void ValueTraits<const double>::normalNumber( double t ) { char *s = doNegative( t ); Index: Descriptions.cpp =================================================================== RCS file: /cvsroot/mockpp/mockpp/3party/cxxtest/cxxtest/Descriptions.cpp,v retrieving revision 1.1 retrieving revision 1.2 diff -u -d -r1.1 -r1.2 --- Descriptions.cpp 9 Dec 2005 15:57:51 -0000 1.1 +++ Descriptions.cpp 9 Dec 2005 20:40:42 -0000 1.2 @@ -2,13 +2,14 @@ #define __cxxtest__Descriptions_cpp__ #include <cxxtest/Descriptions.h> +#include <cxxtest/ValueTraits.h> namespace CxxTest { TestDescription::~TestDescription() {} SuiteDescription::~SuiteDescription() {} WorldDescription::~WorldDescription() {} - + // // Convert total tests to string // |