Test4Window::Test4Window(const QString &sql) : Ui::Test4Window() { Ui::Test4Window::setupUi(this); QToolBar *toolBar = QMainWindow::addToolBar("TB"); toolBar->setSizePolicy(QSizePolicy(QSizePolicy::Preferred, QSizePolicy::Fixed)); toolBar->setFocusPolicy(Qt::NoFocus); pushButton = new QPushButton("Oracle", toolBar); pushButton->setFlat(true); toolBar->addWidget(pushButton); connect(pushButton, SIGNAL(released()), this, SLOT(setLexer())); QAction *oracle = new QAction("Oracle", this); QAction *mysql = new QAction("MySQL", this); oracle->setCheckable(true); oracle->setChecked(true); mysql->setCheckable(true); mysql->setChecked(false); QActionGroup* group = new QActionGroup(this); oracle->setActionGroup(group); mysql->setActionGroup(group); menuGrammar->addAction(oracle); menuGrammar->addAction(mysql); editorLeft = new toSqlText(this); leftVerticalLayout->addWidget(editorLeft); editorLeft->setText(sql); editorLeft->enableToolTips(); editorRight = new toSqlText(this); editorRight->setHighlighter(toSqlText::Oracle); rightVerticalLayout->addWidget(editorRight); editorRight->setText(sql); editorRight->setMarginType(2, QsciScintilla::TextMarginRightJustified); editorRight->setMarginWidth(2, QString::fromLatin1("009")); editorRight->enableToolTips(); connect(oracle, SIGNAL(triggered()), this, SLOT(setOracle())); connect(mysql, SIGNAL(triggered()), this, SLOT(setMySQL())); connect(actionLoad, SIGNAL(triggered()), this, SLOT(load())); connect(actionQuit, SIGNAL(triggered()), this, SLOT(close())); QMainWindow::show(); }
int main() { int newCards = 0; int discarded = 1; int xtraCoins = 0; int shuffledCards = 0; int drawnCard1 = 0; int drawnCard2 = 0; srand(time(NULL)); int i = 0; int failed = 0; int handpos = 0, choice1 = 0, choice2 = 0, choice3 = 0, bonus = 0; int remove1, remove2; int seed = 645; int numPlayers = 4; int thisPlayer = 0; int player2 = 1; int player3 = 2; int player4 = 3; int playerArray[4] = {thisPlayer, player2, player3, player4}; struct gameState G, testG, oracleG, beforeG; int k[10] = {adventurer, embargo, village, minion, mine, cutpurse, sea_hag, tribute, smithy, council_room}; // initialize a game state and player cards initializeGame(numPlayers, k, seed, &G); printf("----------------- Testing Card: %s ----------------\n", TESTCARD); // ----------- TEST 1: choice1 = 1 = +2 cards -------------- printf("RANDOM TEST : = Play sea_hag\n\n\n"); for (i = 0; i < 1000000; ++i) { // copy a blank gamestate to testG memcpy(&testG, &G, sizeof(struct gameState)); randomizeGameState(&testG, playerArray); //Set oracleG to values after randomizing gameState memcpy(&oracleG, &testG, sizeof(struct gameState)); //This is so the original state can be printed if there is an error. memcpy(&beforeG, &testG, sizeof(struct gameState)); setOracle(&testG, &oracleG, playerArray, thisPlayer); //Perform the test... cardEffect(sea_hag, choice1, choice2, choice3, &testG, handpos, &bonus); if(!checkOracle(&testG, &oracleG, playerArray)) { printErrorReport(&testG, &oracleG, &beforeG, playerArray, i + 1); failed++; } } printf("The test ran %d times and resulted in %d failures.\n", i, failed); printf("\n >>>>> SUCCESS: Testing complete %s <<<<<\n\n", TESTCARD); return 0; }