RoadTest.cpp
Go to the documentation of this file.
00001 /****************************************************************************
00002 **
00003 ** Copyright (c) 2008-2011 C.B. Barber. All rights reserved.
00004 ** $Id: //main/2011/qhull/src/road/RoadTest.cpp#3 $$Change: 1342 $
00005 ** $Date: 2011/03/07 $$Author: bbarber $
00006 **
00007 ****************************************************************************/
00008 
00009 //pre-compiled headers
00010 #include <iostream>
00011 #include <stdexcept>
00012 #include "RoadTest.h"
00013 
00014 using std::cout;
00015 using std::endl;
00016 
00017 namespace orgQhull {
00018 
00019 #//class variable
00020 
00021 QList<RoadTest*> RoadTest::
00022 s_testcases;
00023 
00024 int RoadTest::
00025 s_test_count= 0;
00026 
00027 int RoadTest::
00028 s_test_fail= 0;
00029 
00030 QStringList RoadTest::
00031 s_failed_tests;
00032 
00033 #//Slot
00034 
00036 void RoadTest::
00037 cleanup()
00038 {
00039     s_test_count++;
00040     if(QTest::currentTestFailed()){
00041         recordFailedTest();
00042     }
00043 }//cleanup
00044 
00045 #//Helper
00046 
00047 void RoadTest::
00048 recordFailedTest()
00049 {
00050     s_test_fail++;
00051     QString className= metaObject()->className();
00052     s_failed_tests << className + "::" + QTest::currentTestFunction();
00053 }
00054 
00055 #//class function
00056 
00057 int RoadTest::
00058 runTests(QStringList arguments)
00059 {
00060     int result= 0; // assume success
00061 
00062     foreach(RoadTest *testcase, s_testcases){
00063         try{
00064             result += QTest::qExec(testcase, arguments);
00065         }catch(const std::exception &e){
00066             cout << "FAIL!  : Threw error ";
00067             cout << e.what() << endl;
00068     s_test_count++;
00069             testcase->recordFailedTest();
00070             // Qt 4.5.2 OK.  In Qt 4.3.3, qtestcase did not clear currentTestObject
00071         }
00072     }
00073     if(s_test_fail){
00074         cout << "Failed " << s_test_fail << " of " << s_test_count << " tests.\n";
00075         cout << s_failed_tests.join("\n").toLocal8Bit().constData() << std::endl;
00076     }else{
00077         cout << "Passed " << s_test_count << " tests.\n";
00078     }
00079     return result;
00080 }//runTests
00081 
00082 }//orgQhull
00083 
00084 #include "moc/moc_RoadTest.cpp"


libqhull-ours
Author(s): Robert Krug
autogenerated on Mon Jan 6 2014 11:32:11