[Cppunit-cvs] cppunit2/examples/stringize_demo SConscript,NONE,1.1 main.cpp,NONE,1.1
Brought to you by:
blep
From: Baptiste L. <bl...@us...> - 2005-09-06 07:47:43
|
Update of /cvsroot/cppunit/cppunit2/examples/stringize_demo In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv19316/examples/stringize_demo Added Files: SConscript main.cpp Log Message: * small demo that demonstrate how conversion to string can be customized. --- NEW FILE: main.cpp --- #include <examples/common/examplecommon.h> #include <cpput/testcase.h> #include <opentest/texttestdriver.h> #include <opentest/properties.h> #include <cpptl/stringtools.h> #include <deque> #include <cpput/assertenum.h> namespace ExampleNamespace { struct WeirdType { WeirdType( int x ) : x_( x ) { } bool operator ==( const WeirdType &other ) const { return x_ == other.x_; } int x_; }; } namespace CppUT { /// We override this function so that CppUnit know how to convert /// WeirType instance into a string. inline std::string toString( const ExampleNamespace::WeirdType &v ) { return CppTL::ConstString("WeirdType: x_=" + CppTL::toString( v.x_ )).str(); } } static void testStringize() { CPPUT_CHECK_EQUAL( ExampleNamespace::WeirdType(5678), ExampleNamespace::WeirdType(1234) ); std::deque<ExampleNamespace::WeirdType> a, b; b.push_back( ExampleNamespace::WeirdType( 1234 ) ); b.push_back( ExampleNamespace::WeirdType( 4567 ) ); CPPUT_CHECK_STL_SEQUENCE_EQUAL( a, b ); } int main( int argc, const char *argv[] ) { CppUT::TestSuitePtr allSuite = CppUT::makeTestSuite( "All tests" ); allSuite->add( CppUT::makeTestCase( CppTL::cfn0( &testStringize ), "testStringize" ) ); return runExampleTests( argc, argv, allSuite.get() ); } --- NEW FILE: SConscript --- Import( 'env_testing buildCppUnitExample' ) buildCppUnitExample( env_testing, Split( """ main.cpp """ ), 'stringize_demo' ) |