bool Test::test_NumFileGen1() { bool isPassed = true; std::string ascendingFileName = "test_ascending.dat"; std::string descendingFileName = "test_descending.dat"; std::string randomFileName = "test_random.dat"; std::string singleValueFileName = "test_single.dat"; const int LOW = 0; const int HIGH = 5000; const int AMOUNT = 10; const int SINGLE_VALUE = 27; m_testNum++; printTestMessage(m_testNum, "all files creation methods create file of desired name"); NumberFileGenerator::ascending(ascendingFileName, AMOUNT); NumberFileGenerator::descending(descendingFileName, AMOUNT); NumberFileGenerator::random(randomFileName, AMOUNT, LOW, HIGH); NumberFileGenerator::singleValue(singleValueFileName, AMOUNT, SINGLE_VALUE); if(!isFileAccessible(ascendingFileName)) { std::cerr << "ERROR: " << ascendingFileName << " not accessible!" << std::endl; isPassed = false; } if(!isFileAccessible(ascendingFileName)) { std::cerr << "ERROR: " << descendingFileName << " not accessible!" << std::endl; isPassed = false; } if(!isFileAccessible(ascendingFileName)) { std::cerr << "ERROR: " << randomFileName << " not accessible!" << std::endl; isPassed = false; } if(!isFileAccessible(ascendingFileName)) { std::cerr << "ERROR: " << singleValueFileName << " not accessible!" << std::endl; isPassed = false; } printPassFail(isPassed); return (isPassed); }
bool Test::testBadFile(std::string testFileName, std::string testMessage) { bool isPassed = false; m_testNum++; printTestMessage(m_testNum, testMessage); if( isFileAccessible(testFileName) ) { try { MazeReader mr(testFileName); } catch(MazeCreationException& mce) { isPassed = true; } catch(...) { std::cerr << "ERROR: Exception thrown was not MazeCreationException" << std::endl; } } else { std::cerr << "ERROR " << testFileName << " not accessible. Place in lab folder." << std::endl; } printPassFail(isPassed); return(isPassed); }
bool SortDriver::areParametersValid(std::string sortName, std::string inputFileName){ if(isSortValid(sortName) && isFileAccessible(inputFileName)){ return true; } else{ return false; } }
bool Test::test_mazeReader06() { bool isPassed = false; std::string testFileName = "maze.txt"; const int correctRows = 5; const int correctCols = 4; m_testNum++; printTestMessage(m_testNum, "MazeReader getStartRow and getStartCol return correct values on valid maze"); if(isFileAccessible(testFileName)) { try { MazeReader mr(testFileName); if( (correctRows == mr.getStartRow()) && (correctCols == mr.getStartCol()) ) { isPassed = true; } else { std::cerr << "ERROR: expected " << correctRows << " and " << correctCols << " got " << mr.getStartRow() << " and " << mr.getStartCol() << std::endl; } } catch(...) { std::cerr << "ERROR: exception thrown with valid file" << std::endl; } } else { std::cerr << "ERROR " << testFileName << " not accessible. Place in lab folder." << std::endl; } printPassFail(isPassed); return(isPassed); }