#include"main.h"#include<cppunit/CompilerOutputter.h>#include<cppunit/extensions/TestFactoryRegistry.h>#include<cppunit/TestResult.h>#include<cppunit/TestResultCollector.h>#include<cppunit/TestRunner.h>#include<cppunit/BriefTestProgressListener.h>#ifdef WITH_LOG4CXX#include"log4cxx/logger.h"#include"log4cxx/fileappender.h"#include"log4cxx/patternlayout.h"#include"log4cxx/propertyconfigurator.h"usingnamespacelog4cxx;#endifintmain(intargc,char*argv[]){#ifdef WITH_LOG4CXXLoggerPtrroot=Logger::getRootLogger();root->addAppender(newFileAppender(newPatternLayout("%d %-5p %c: %m%n"),"libtransport_test.log",false));#endifstd::vector<std::string>testsToRun;for(inti=1;i<argc;++i){std::stringparam(argv[i]);testsToRun.push_back(param);}if(testsToRun.empty()){testsToRun.push_back("");}// informs test-listener about testresultsCPPUNIT_NS::TestResulttestresult;// register listener for collecting the test-resultsCPPUNIT_NS::TestResultCollectorcollectedresults;testresult.addListener(&collectedresults);// register listener for per-test progress outputCPPUNIT_NS::BriefTestProgressListenerprogress;testresult.addListener(&progress);// insert test-suite at test-runner by registryCPPUNIT_NS::TestRunnertestrunner;testrunner.addTest(CPPUNIT_NS::TestFactoryRegistry::getRegistry().makeTest());for(std::vector<std::string>::const_iteratori=testsToRun.begin();i!=testsToRun.end();++i){try{testrunner.run(testresult,*i);}catch(conststd::exception&e){std::cerr<<"Error: "<<e.what()<<std::endl;return-1;}}// output results in compiler-formatCPPUNIT_NS::CompilerOutputtercompileroutputter(&collectedresults,std::cerr);compileroutputter.write();// return 0 if tests were successfulreturncollectedresults.wasSuccessful()?0:1;}