Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020 #ifndef _BASICMAINTEST_HXX_
00021 #define _BASICMAINTEST_HXX_
00022
00023 #include <cppunit/CompilerOutputter.h>
00024 #include <cppunit/TestResult.h>
00025 #include <cppunit/TestResultCollector.h>
00026 #include <cppunit/TextTestProgressListener.h>
00027 #include <cppunit/BriefTestProgressListener.h>
00028 #include <cppunit/extensions/TestFactoryRegistry.h>
00029 #include <cppunit/TestRunner.h>
00030 #include <stdexcept>
00031
00032 #include <iostream>
00033 #include <fstream>
00034
00035 #ifndef WIN32
00036 #include <fpu_control.h>
00037 #endif
00038
00039
00044
00045
00046 int main(int argc, char* argv[])
00047 {
00048 #ifndef WIN32
00049 fpu_control_t cw = _FPU_DEFAULT & ~(_FPU_MASK_IM | _FPU_MASK_ZM | _FPU_MASK_OM);
00050 _FPU_SETCW(cw);
00051 #endif
00052
00053 CPPUNIT_NS::TestResult controller;
00054
00055
00056 CPPUNIT_NS::TestResultCollector result;
00057 controller.addListener( &result );
00058
00059
00060 #ifdef WIN32
00061 CPPUNIT_NS::TextTestProgressListener progress;
00062 #else
00063 CPPUNIT_NS::BriefTestProgressListener progress;
00064 #endif
00065 controller.addListener( &progress );
00066
00067
00068
00069 CPPUNIT_NS::Test *suite =
00070 CPPUNIT_NS::TestFactoryRegistry::getRegistry().makeTest();
00071
00072
00073
00074 CPPUNIT_NS::TestRunner runner;
00075 runner.addTest( suite );
00076 runner.run( controller);
00077
00078
00079
00080 std::ofstream testFile;
00081 testFile.open("UnitTestsResult", std::ios::out | std::ios::trunc);
00082
00083 CPPUNIT_NS::CompilerOutputter outputter( &result, testFile );
00084 outputter.write();
00085
00086
00087
00088 bool wasSucessful = result.wasSuccessful();
00089 testFile.close();
00090
00091
00092
00093 return wasSucessful ? 0 : 1;
00094 }
00095
00096 #endif