main.cpp
来自「c++ 实现的矩阵运算库」· C++ 代码 · 共 121 行
CPP
121 行
#include <cppunit/CompilerOutputter.h>
#include <cppunit/TestResult.h>
#include <cppunit/TestResultCollector.h>
#include <cppunit/TestRunner.h>
#include <cppunit/TextTestProgressListener.h>
#include <cppunit/BriefTestProgressListener.h>
#include <cppunit/XmlOutputter.h>
#include <cppunit/extensions/TestFactoryRegistry.h>
#include <stdexcept>
#include <fstream>
#ifdef WIN32
#include <windows.h>
#include <conio.h>
#endif
#include "../src/TestCase_cmatrix.h"
#include "../src/TestCase_Matrix.h"
#ifdef INTEL_IPPS
#include <ippcore.h>
#endif
using namespace std;
using namespace Zenautics;
int main( int argc, char **argv )
{
#ifdef INTEL_IPPS
ippStaticInit();
#endif
// Retreive test path from command line first argument. Default to "" which resolve
// to the top level suite.
std::string testPath = std::string("");
// std::string testPath = (argc > 1) ? std::string(argv[1]) : std::string("");
// Create the event manager and test controller
CPPUNIT_NS::TestResult controller;
// Add a listener that colllects test result
CPPUNIT_NS::TestResultCollector result;
controller.addListener( &result );
// Add a listener that print dots as test run.
#ifdef WIN32
CPPUNIT_NS::TextTestProgressListener progress;
#else
CPPUNIT_NS::BriefTestProgressListener progress;
#endif
controller.addListener( &progress );
// Add the top suite to the test runner
CPPUNIT_NS::TestRunner runner;
// ADD TEST SUITES HERE
#define TEST_ALL
#ifdef TEST_ALL
// put all tests here
runner.addTest( TestCase_cmatrix::suite() );
runner.addTest( TestCase_Matrix::suite() );
#else
// put your individual test case here for localized testing
runner.addTest( TestCase_Matrix::suite() );
#endif
try
{
std::cout << "Running \n" << testPath;
runner.run( controller, testPath );
std::cerr << std::endl;
// Print test in a compiler compatible format.
CPPUNIT_NS::CompilerOutputter outputter( &result, std::cerr );
outputter.write();
// Print test results to a file
std::ofstream textFile( "TextTestReport.txt" );
CPPUNIT_NS::CompilerOutputter TextFileOutput( &result, textFile );
TextFileOutput.write();
textFile.close();
// Uncomment this for XML output
std::ofstream file( "XMLTestReport.xml" );
CPPUNIT_NS::XmlOutputter xml( &result, file );
xml.setStyleSheet( "report.xsl" );
xml.write();
file.close();
}
catch ( std::invalid_argument &e ) // Test path not resolved
{
std::cerr << std::endl
<< "ERROR: " << e.what()
<< std::endl;
#ifdef WIN32
Sleep(500); // so GDM can see his screen!
#endif
#ifdef WIN32
_getch();
#endif
_getch();
return 0;
}
catch( ... )
{
_getch();
return 0;
}
#ifdef WIN32
Sleep(500); // so GDM can see his screen!
#endif
return result.wasSuccessful() ? 0 : 1;
}
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?