void TestingWidgetFacade::loadFromHtmlDirect(QString filepath) { this->filepath = filepath; ExamsTest loadedTest = tlogic.htmlToExamsTest(filepath); int a = loadedTest.getTasksACount(); int b = loadedTest.getTasksBCount(); int c = loadedTest.getTasksCCount(); emit setTaskCount(a, b, c); setTest(loadedTest); }
static bool bitopsTests() { // Create a bit set to test BitSet setTest(48); // Set some bits setTest.set(1); setTest.set(10); setTest.set(16); setTest.set(21); setTest.set(33); setTest.set(41); // Create another set to do ops on BitSet setTest2(48); // Or with the new set setTest2.orWith(setTest); // They should be equal now if (!setTest.equals(setTest2)) { XERCES_STD_QUALIFIER wcout << L" OR of set with empty set did not create equal sets" << XERCES_STD_QUALIFIER endl; return false; } // Xor with original which should get back an empty set setTest2.xorWith(setTest); if (!setTest2.allAreCleared()) { XERCES_STD_QUALIFIER wcout << L" XOR against original set did not get back original" << XERCES_STD_QUALIFIER endl; return false; } // And them, which should have no effect setTest2.andWith(setTest); if (!setTest2.allAreCleared()) { XERCES_STD_QUALIFIER wcout << L" AND against empty set changed bits" << XERCES_STD_QUALIFIER endl; return false; } return true; }
int main() { { TestBed mainBed; TestItem::setBed(&mainBed); bool bSuccess=true; bSuccess = indexTest(); bSuccess = bSuccess && setTest(); bSuccess = bSuccess && constantTest(); bSuccess = bSuccess && booleanTest(); /* alternative if you don't like the TestItem TestBed arrangement. if(bSuccess) std::cout<<"PASSED"<<std::endl; else std::cout<<"FAILED!"<<std::endl; */ } return 0; }
bool TestingWidgetFacade::connectToTestingLogic(QObject* testinglogic) { if(!QObject::connect(this, SIGNAL(setCurrentTest(ExamsTest)), testinglogic, SLOT(setTest(ExamsTest)), Qt::AutoConnection)) { return 0; } if(!QObject::connect(this, SIGNAL(taskRequest(QString)), testinglogic, SLOT(returnTask(QString)), Qt::AutoConnection)) { return 0; } if(!QObject::connect(this, SIGNAL(helpRequest(QString)), testinglogic, SLOT(returnHelp(QString)), Qt::AutoConnection)) { return 0; } if(!QObject::connect(testinglogic, SIGNAL(tossTestTask(TestTask)), this, SLOT(showTask(TestTask)), Qt::AutoConnection)) { return 0; } if(!QObject::connect(testinglogic, SIGNAL(tossHelpCodes(QList<Key>, QList<Key>)), this, SLOT(showHelp(QList<Key>, QList<Key>)), Qt::AutoConnection)) { return 0; } if(!QObject::connect(testinglogic, SIGNAL(tossStats(User_informations)), this, SLOT(showStats(User_informations)), Qt::AutoConnection)) { return 0; } if(!QObject::connect(this, SIGNAL(firstTaskRequest()), testinglogic, SLOT(returnFirstTask()), Qt::AutoConnection)) { return 0; } return 1; }
void TestTracker::leaveTest( const TestDescription &td ) { _l->leaveTest( td ); setTest( 0 ); }
void TestTracker::enterTest( const TestDescription &td ) { setTest( &td ); _testFailedAsserts = false; _l->enterTest(td); }
void TestTracker::setSuite( const SuiteDescription *s ) { _suite = fixSuite( s ); setTest( 0 ); }
void TestingWidgetFacade::loadFromXMLDirect(QString path) { this->filepath = path; ExamsTest t = tlogic.loadTest(path); setTest(t); }
bool TestingWidgetFacade::connectToTestingWidget(QObject* testingwidget) { if(!QObject::connect(testingwidget, SIGNAL(menuJumpRequest()), this, SLOT(switchToStartWidget()), Qt::AutoConnection)) { return 0; } if(!QObject::connect(testingwidget, SIGNAL(startTestRequest()), this, SLOT(startTest()), Qt::AutoConnection)) { return 0; } if(!QObject::connect(testingwidget, SIGNAL(finishTestRequest()), this, SLOT(finishTest()), Qt::AutoConnection)) { return 0; } if(!QObject::connect(testingwidget, SIGNAL(jumpToTaskRequest(QString)), this, SLOT(displayTaskById(QString)), Qt::AutoConnection)) { return 0; } if(!QObject::connect(testingwidget, SIGNAL(jumpToTaskHelp(QString)), this, SLOT(displayHelpById(QString)), Qt::AutoConnection)) { return 0; } if(!QObject::connect(testingwidget, SIGNAL(setTestRequest(ExamsTest)), this, SLOT(setTest(ExamsTest)), Qt::AutoConnection)) { return 0; } if(!QObject::connect(testingwidget, SIGNAL(answers(QList< QPair<QString, QString> >)), this, SLOT(calculateResults(QList<QPair<QString,QString> >)), Qt::AutoConnection)) { return 0; } if(!QObject::connect(testingwidget, SIGNAL(loadTestRequest(QString)), this, SLOT(loadTest(QString)), Qt::AutoConnection)) { return 0; } if(!QObject::connect(this, SIGNAL(timeLabelUpdate(QString)), testingwidget, SLOT(setTimeLabel(QString)), Qt::AutoConnection)) { return 0; } if(!QObject::connect(this, SIGNAL(setTaskCount(int, int, int)), testingwidget, SLOT(setTaskCount(int, int, int)), Qt::AutoConnection)) { return 0; } return 1; }
// --------------------------------------------------------------------------- // Local testing methods // --------------------------------------------------------------------------- static bool basicTests() { // // Create a bitset with 32 bits. We just happen to know that this is // the unit of expansion, so it should come back with exactly that // number of bits of size. // BitSet setTest(32); if (setTest.size() != 32) { XERCES_STD_QUALIFIER wcout << L" Ctor did not create set of correct size" << XERCES_STD_QUALIFIER endl; return false; } // // Check the value of all of the bits and make sure that they all come // back zero. // const unsigned int count = setTest.size(); unsigned int index; for (index = 0; index < count; index++) { if (setTest.get(index)) { XERCES_STD_QUALIFIER wcout << L" A bit's initial value was not zero" << XERCES_STD_QUALIFIER endl; return false; } } // Make sure that allAreCleared() agrees if (!setTest.allAreCleared()) { XERCES_STD_QUALIFIER wcout << L" allAreCleared() disagrees with individual bit gets" << XERCES_STD_QUALIFIER endl; return false; } // Set and clear each bit and make sure that they come back right for (index = 0; index < count; index++) { setTest.set(index); if (!setTest.get(index)) { XERCES_STD_QUALIFIER wcout << L" Bit was set but get returned false" << XERCES_STD_QUALIFIER endl; return false; } setTest.clear(index); if (setTest.get(index)) { XERCES_STD_QUALIFIER wcout << L" Bit was cleared but get returned true" << XERCES_STD_QUALIFIER endl; return false; } } // And once more make sure they are all zero for (index = 0; index < count; index++) { if (setTest.get(index)) { XERCES_STD_QUALIFIER wcout << L" A bit remained set after clearing" << XERCES_STD_QUALIFIER endl; return false; } } // // Set some bits, then copy construct another bitset from this one. Then // see if they come out equal. // setTest.set(1); setTest.set(16); setTest.set(20); setTest.set(24); BitSet setTest2(setTest); if (!setTest.equals(setTest2)) { XERCES_STD_QUALIFIER wcout << L" Copy ctor did not create equal sets" << XERCES_STD_QUALIFIER endl; return false; } // Clear all bits of the copy and make sure they are all cleared setTest2.clearAll(); for (index = 0; index < count; index++) { if (setTest2.get(index)) { XERCES_STD_QUALIFIER wcout << L" clearAll() did not clear all bits" << XERCES_STD_QUALIFIER endl; return false; } } // Set a bit beyond the current size setTest2.set(32); // Make sure it expanded if (setTest2.size() != 64) { XERCES_STD_QUALIFIER wcout << L" Set of bit beyond size did not expand" << XERCES_STD_QUALIFIER endl; return false; } // Set all the bits for (index = 0; index < count; index++) setTest.set(index); // Make sure that allAreSet() sees them all set if (!setTest.allAreSet()) { XERCES_STD_QUALIFIER wcout << L" After setting all bits, allAreSet() returned false" << XERCES_STD_QUALIFIER endl; return false; } return true; }