X-Git-Url: http://git.salome-platform.org/gitweb/?a=blobdiff_plain;f=src%2FHYDRO_tests%2FTestLib_Listener.cxx;h=7c79e858d763a15bd30a16b5719844002e3920ab;hb=5ac23856072a615487ce98401d28fb3b7934150c;hp=593c8d6e29b3404c4531c09bbf312c39fb9692e8;hpb=acfd496c5826a46a6b42bf1aa9bf091af80c8b13;p=modules%2Fhydro.git diff --git a/src/HYDRO_tests/TestLib_Listener.cxx b/src/HYDRO_tests/TestLib_Listener.cxx index 593c8d6e..7c79e858 100644 --- a/src/HYDRO_tests/TestLib_Listener.cxx +++ b/src/HYDRO_tests/TestLib_Listener.cxx @@ -18,7 +18,10 @@ #include #include +#include +#include #include +#include #ifdef WIN32 #include @@ -69,7 +72,7 @@ INT64 GetTimeForCurrentThreadInMs() \brief Constructor */ TestLib_Listener::TestLib_Listener() -: myStart( 0 ), myComplete( 0 ) +: myStart( 0 ), myComplete( 0 ), myNbTests( 0 ), myNbSuites( 0 ) { } @@ -122,6 +125,18 @@ void TestLib_Listener::endTest( CppUnit::Test* theTest ) INT64 anExecTimeMS = aCurTime - myStart; myComplete += anExecTimeMS; std::cout << " " << anExecTimeMS << " ms" << std::endl; + + myNbTests++; +} + +int TestLib_Listener::GetNbTests() const +{ + return myNbTests; +} + +int TestLib_Listener::GetNbSuites() const +{ + return myNbSuites; } /** @@ -138,6 +153,7 @@ void TestLib_Listener::startSuite( CppUnit::Test* theTest ) */ void TestLib_Listener::endSuite( CppUnit::Test* theTest ) { + myNbSuites++; } /** @@ -146,5 +162,27 @@ void TestLib_Listener::endSuite( CppUnit::Test* theTest ) */ void TestLib_Listener::addFailure( const CppUnit::TestFailure& theFailure ) { + std::string failedTest = theFailure.failedTest()->getName(); + CppUnit::SourceLine failedLocation = theFailure.sourceLine(); + + QString aFile = QString::fromStdString( failedLocation.fileName() ); + aFile.replace( '\\', '/' ); + QStringList parts = aFile.split( '/' ); + aFile = parts.last(); + std::string cFile = aFile.toStdString(); + + int aLine = failedLocation.lineNumber(); + + static char aBuf[1024]; + sprintf( aBuf, "Failed %s: %s : %i", failedTest.c_str(), cFile.c_str(), aLine ); + + myFailures.push_back( aBuf ); } +void TestLib_Listener::DumpFailures() +{ + int n = (int)myFailures.size(); + printf( "FAILED TESTS: %i\n", n ); + for( int i=0; i