int main () { //test default constructor std::cout << "Test Default Constructor . . . "; storage::sheetYSub *test = new storage::sheetYSub; printTest( (*test)[0][0] == storage::filler && test->vecSize == 1 && test->subVecSize == 1 ); std::cout << "Test Destructor . . . "; delete test; std::cout << "pass \n"; size_t length = 10; size_t width = 6; storage::user_prec phil = 12.34; storage::boolVec_t myBoolVec(width, true); //test filler constructor std::cout << "Test filler constructor . . . "; test = new storage::sheetYSub(length, myBoolVec ); printTest( test->vecSize == length && (*test)[length-1].size() == width && (*test)[length-1][width-1] == storage::filler); delete test; //test element constructor std::cout << "Test element constructor . . . "; test = new storage::sheetYSub(length , vector<bool>( true,width ) , phil ); printTest( (*test)[0][0] == phil ); delete test; //test vector constructor std::cout << "Test boolean constructor . . . "; for ( size_t s = 0; s < width/2; s++) myBoolVec[s] = false; test = new storage::sheetYSub( length, myBoolVec, phil ); printTest( test->subVecSize == width - width/2 ); //test packing std::cout << "Test packing . . . "; storage::y_vec myVec; for ( int n = 1; n <= width; n++ ) myVec.push_back(n); test->pack(myVec); cout << endl; test->printTo(); delete test; return EXIT_SUCCESS; }
int main(int argc, char *argv[]) { int sizeOfElement = sizeof(int); int *ins = calloc(1,sizeof(int)); Tree tree = new_tree (sizeOfElement, navigateItem, NULL, NULL, NULL); printf("*******TREE VISUALISATION**********\n\n"); printf("TREE STARTS EMPTY\n\n"); printf("INSERTING VALUES 1-10\n\n"); for (int i = 1; i <= 10; i++) { tree_insert(&tree, &i, NULL); printTest(&tree, printInt); printf("\n"); } printf("DELETING VALUE 10\n\n"); *ins = 10; tree_delete(&tree, ins, NULL); printTest(&tree, printInt); printf("\n"); printf("DELETING VALUE 8\n\n"); *ins = 8; tree_delete(&tree, ins, NULL); printTest(&tree, printInt); printf("\n"); if (tree != NULL) { destroy_tree(&tree); } if (ins != NULL) { free(ins); } return 0; }
static void testBsr (void) { ___BTPUSH; printTest ("int_bsr"); assert (int_bsr (0x00) == 0); assert (int_bsr (0x01) == 1); assert (int_bsr (0x02) == 2); assert (int_bsr (0x03) == 2); assert (int_bsr (0x04) == 3); assert (int_bsr (0x05) == 3); assert (int_bsr (0x06) == 3); assert (int_bsr (0x07) == 3); assert (int_bsr (0x08) == 4); assert (int_bsr (0x09) == 4); assert (int_bsr (0x0A) == 4); assert (int_bsr (0x0B) == 4); assert (int_bsr (0x0C) == 4); assert (int_bsr (0x0D) == 4); assert (int_bsr (0x0E) == 4); assert (int_bsr (0x0F) == 4); assert (int_bsr (0x10) == 5); assert (int_bsr (0x20) == 6); assert (int_bsr (0xC3) == 8); assert (int_bsr (0xCD20) == 16); assert (int_bsr (0xE80000) == 24); assert (int_bsr (0x40003001) == 31); assert (int_bsr (0x80000000) == 32); assert (int_bsr (-2) == 32); assert (int_bsr (-1) == 32); printOk (); ___BTPOP; }
static std::ostream &printTest(std::ostream &out, const CppUnit::Test *test) { out << test->getName() << "\n"; for (unsigned int i = 0; i < test->getChildTestCount(); ++i) { printTest(out, test->getChildTestAt(i)); } return out << std::flush; }
void ClockerListener::printStatistics() const { printTest( 0, "" ); std::cout << std::endl; std::cout << "Total elapsed time: "; printTime( m_model->totalElapsedTime() ); std::cout << ", average test case time: "; printTime( m_model->averageTestCaseTime() ); }
void frameTest(bool** ledArray, float topMargin, float leftMargin, float botEnd, float rightEnd) { //Windows: //Sleep(5); //system("cls"); //Linux: usleep(50000); system("clear"); printTest(ledArray, topMargin, leftMargin, botEnd, rightEnd); }
void ClockerListener::printStatistics() const { printTest( 0, "" ); CPPUNIT_NS::stdCOut() << "\n"; CPPUNIT_NS::stdCOut() << "Total elapsed time: "; printTime( m_model->totalElapsedTime() ); CPPUNIT_NS::stdCOut() << ", average test case time: "; printTime( m_model->averageTestCaseTime() ); }
void run() { while (_glInit) { printTest(); qi::os::sleep(1); } std::cout << "Stop running" << std::endl; fflush(stdout); }
int main() // The main function will run through the test cases as outlined in the // attached assignment documentation { DLinkedList<int> list; // initialize the list int size = 5; // initialize a size int testCase = 1; // initialize test cases std::cout << "Creating initial list... " << std::endl << std::endl; // create the list addList(list, size); for (int i = -1; i <= size; i++) // run through first 6 test cases { printTest(testCase); // inform us of which test case testCase++; // increment test case list.swap(i); // attempt to swap items printList(list); // print the current list } std::cout << "Emptying list... " << std::endl << std::endl; // delete the contents of the list while (!list.empty()) // check for an empty list { list.removeFront(); // remove front item from list printList(list); // print out current list } int i = 1; // initialize counter while (i <= 2) // run final two test cases { printTest(testCase); // inform us of which test case testCase++; // increment test case list.swap(0); // try to swap the lead element list.addFront(i); // add an item to the list printList(list); // print the current list i++; // increment counter } return EXIT_SUCCESS; // exit successfully }
int main(int argc,char **argv){ printTest(&testfun, 1, 3); return 0; }
void project1() { codeFile = fopen("input.txt", "r"); output = fopen("cleaninput.txt", "w"); initArrays(); load1(); printCleanInput(); cleanArrayList(); findToken(); //errorCheck(); printLexemeTable(); printTest(); }
inline threadTest::~threadTest() { _glInit = false; _glThread.interrupt(); std::cout << "Interrupting main thread" << std::endl; fflush(stdout); _glThread.join(); std::cout << "Joinning main thread" << std::endl; fflush(stdout); printTest(); std::cout << "Main thread destroyed" << std::endl; fflush(stdout); };
int main() { /* initialize bare minimum game variables */ int seed = 101; // seed for game init int numPlayers = 2; // number of players int kCards[10] = {adventurer, council_room, feast, // kingdom cards gardens, mine, remodel, smithy, village, baron, great_hall}; struct gameState gState; int r = initializeGame(numPlayers, kCards, seed, &gState); // initialize a new game int s; // exit status for function /* extra parameters specific to this function */ int currentPlayer; int card; /* game state variables used by this function */ int num; /* counter variables */ // test over all players for(currentPlayer = 0; currentPlayer < numPlayers; currentPlayer++){ // test over different cards for(card = 0; card < 20; card += 3){ // test over some quantities of the chosen card for(num = 0; num <= 9; num += 3){ memset(&gState, 23, sizeof(struct gameState)); // clear the game state r = initializeGame(numPlayers, kCards, seed, &gState); // initialize the game // set add'l game variables initCards(&gState, num, card, currentPlayer); // call the function under test s = fullDeckCount(currentPlayer, card, &gState); if(s == num){ printPass(); } else printFail(); printTest("correct total of cards returned", num, s); } } } return 0; }
void ClockerListener::printTest( int testIndex, const std::string &indentString ) const { std::string indent = indentString; const int indentLength = 3; printTestIndent( indentString, indentLength ); printTime( m_model->testTimeFor( testIndex ) ); CPPUNIT_NS::stdCOut() << m_model->testPathFor( testIndex ).getChildTest()->getName(); CPPUNIT_NS::stdCOut() << "\n"; if ( m_model->childCountFor( testIndex ) == 0 ) indent+= std::string( indentLength, ' ' ); else indent+= "|" + std::string( indentLength -1, ' ' ); for ( int index =0; index < m_model->childCountFor( testIndex ); ++index ) printTest( m_model->childAtFor( testIndex, index ), indent ); }
static void testBsf (void) { ___BTPUSH; printTest ("int_bsf"); assert (int_bsf (0x00) == 0); assert (int_bsf (0x01) == 0); assert (int_bsf (0x02) == 1); assert (int_bsf (0x03) == 0); assert (int_bsf (0x04) == 2); assert (int_bsf (0x05) == 0); assert (int_bsf (0x06) == 1); assert (int_bsf (0x07) == 0); assert (int_bsf (0x08) == 3); assert (int_bsf (0x09) == 0); assert (int_bsf (0x0A) == 1); assert (int_bsf (0x0B) == 0); assert (int_bsf (0x0C) == 2); assert (int_bsf (0x0D) == 0); assert (int_bsf (0x0E) == 1); assert (int_bsf (0x0F) == 0); assert (int_bsf (0x10) == 4); assert (int_bsf (0x80000000) == 31); assert (int_bsf (0x90000000) == 28); assert (int_bsf (0xA0000000) == 29); assert (int_bsf (0xB0000000) == 28); assert (int_bsf (0xC0000000) == 30); assert (int_bsf (0xD0000000) == 28); assert (int_bsf (0xD8740000) == 18); assert (int_bsf (0xD8740002) == 1); assert (int_bsf (0xE0000000) == 29); assert (int_bsf (0xF0000000) == 28); assert (int_bsf (-8) == 3); assert (int_bsf (-6) == 1); assert (int_bsf (-4) == 2); assert (int_bsf (-2) == 1); assert (int_bsf (-1) == 0); printOk (); ___BTPOP; }
// Print test vectors. static void printTestVectors(double maxTime) { // Generate vectors for password and salt from 0 to 255 for t_cost = 0 .. 7 and m_cost = 0 .. 7 uint8_t *password = (uint8_t *)"password"; uint8_t *salt = (uint8_t *)"saltsaltsaltsalt"; bool tooLong = false; for(uint32_t i = 0; i < 256 && !tooLong; i++) { uint8_t v = i; uint32_t t_cost = MIN_TCOST; uint32_t m_cost = MIN_MCOST; validateCosts(&t_cost, &m_cost); if(MIN_SALTLEN == 0) { printTest(maxTime, 32, &v, 1, NULL, 0, t_cost, m_cost); printTest(maxTime, 32, NULL, 0, &v, 1, t_cost, m_cost); tooLong = !printTest(maxTime, 32, &v, 1, &v, 1, t_cost, m_cost); } else { tooLong = !printTest(maxTime, 32, &v, 1, salt, MIN_SALTLEN, t_cost, m_cost); } } // Generate vectors for a good range of m_cost and t_cost uint32_t t_cost = MIN_TCOST; while(t_cost <= MAX_TCOST) { tooLong = false; uint32_t m_cost = MIN_MCOST; validateCosts(&t_cost, &m_cost); while(m_cost <= MAX_MCOST && !tooLong) { tooLong = !printTest(maxTime, 32, password, 8, salt, 16, t_cost, m_cost); if(tooLong && m_cost == MIN_MCOST) { return; } if(tooLong) { break; } if(m_cost == 0) { m_cost = 1; } else if(MCOST_LOGARITHMIC) { m_cost++; } else { m_cost += 1 + (m_cost >> 1); } validateCosts(&t_cost, &m_cost); } if(t_cost == 0) { t_cost = 1; } else if(TCOST_LOGARITHMIC) { t_cost++; } else { t_cost += 1 + (t_cost >> 1); } validateCosts(&t_cost, &m_cost); } // Generate different output lengths for(uint32_t i = MIN_OUTLEN; i < MAX_OUTLEN; i++) { uint32_t t_cost = MIN_TCOST; uint32_t m_cost = MIN_MCOST; validateCosts(&t_cost, &m_cost); printTest(maxTime, i, password, 8, salt, 16, MIN_TCOST, MIN_MCOST); } }
int main(){ printf("Hello World\n"); printTest(); return 0; }
int main() { /* initialize bare minimum game variables */ int seed = 101; // seed for game init int numPlayers = 2; // number of players int kCards[10] = {adventurer, council_room, feast, // kingdom cards gardens, mine, remodel, smithy, village, baron, great_hall}; struct gameState gState; int r = initializeGame(numPlayers, kCards, seed, &gState); // initialize a new game int s; // exit status for function /* extra parameters specific to this function */ int currentPlayer; /* game state variables used by this function */ int card; int coins; int handCount; /* counter variables */ // test over all players for(currentPlayer = 0; currentPlayer < numPlayers; currentPlayer++){ // test over some choices of card to buy for(card = council_room; card < smithy; card++){ // test over some initial hand counts for(handCount = 0; handCount < 3; handCount ++){ memset(&gState, 23, sizeof(struct gameState)); // clear the game state r = initializeGame(numPlayers, kCards, seed, &gState); // initialize the game // set add'l game variables initCopper(&gState, currentPlayer, handCount); // initialze player's hand gState.coins = 0; // and 0 coins gState.discardCount[currentPlayer] = 0; // and 0 discards updateCoins(currentPlayer, &gState, 0); // and update for correct # of coins // get # of coins before playing card coins = gState.coins; // call the function under test s = cardFeast(&gState, currentPlayer, card); // tests // check for the purchased card in discard pile if(findCard(&gState, currentPlayer, card) == 1){ printPass(); } else printFail(); printTest("presence of purchased card in discard", 1, findCard(&gState, currentPlayer, card), currentPlayer); // check # of coins updateCoins(currentPlayer, &gState, 0); if(coins == gState.coins){ printPass(); } else printFail(); printTest("# of coins in game state", coins, gState.coins, currentPlayer); } } } return 0; }
/* Test program */ int main(int argc, char** argv) { CppUnit::TestResult testresult; CppUnit::TestResultCollector collectedresults; CppUnit::TestRunner testrunner; std::ofstream fb; std::list< std::string > test_list; #ifdef HAVE_GETOPT_LONG int c; struct option long_options[] = { {"help", 0, 0, 'h'}, {"list", 0, 0, 'l'}, {0, 0, 0, 0} }; while ((c = getopt_long(argc, argv, "hl", long_options, NULL)) != -1) { switch (c) { case 'h': std::cout << "Usage: " << argv[0] << " [test name]\n"; std::cout << "\nOptions:\n" << " -h, --help Show this help message and exit\n" << " -l, --list List available tests and exit" << std::endl; exit(EXIT_SUCCESS); case 'l': { CppUnit::Test *t = CppUnit::TestFactoryRegistry::getRegistry().makeTest(); std::cout << "Available test suites:\n"; printTest(std::cout, t); delete t; exit(EXIT_SUCCESS); } } } if (optind < argc) { while (optind < argc) { test_list.push_back(argv[optind++]); } } #endif testresult.addListener(&collectedresults); testrunner.addTest(CppUnit::TestFactoryRegistry::getRegistry().makeTest()); if (test_list.empty()) testrunner.run(testresult); else { std::list<std::string>::const_iterator it; for (it = test_list.begin(); it != test_list.end(); ++it) { testrunner.run(testresult, *it); } } fb.open((std::string(argv[0]) + ".xml").c_str()); CppUnit::XmlOutputter xml_outputter(&collectedresults, fb); xml_outputter.write(); fb.close(); fb.open((std::string(argv[0]) + ".cmp").c_str()); CppUnit::CompilerOutputter comp_outputter(&collectedresults, fb); comp_outputter.write(); fb.close(); CppUnit::TextOutputter txt_outputter(&collectedresults, std::cout); txt_outputter.write(); return collectedresults.wasSuccessful() ? 0 : 1; }