bool Test::test_NumFileGen5() { bool isPassed = false; const int AMOUNT = 100; const int LOW = 0; const int HIGH = 5000; std::string randomFileName = "test_random.dat"; std::ifstream randomFile(randomFileName); std::size_t fileAmount = 0; int temp = 0; std::vector<int> nums; NumberFileGenerator::random(randomFileName, AMOUNT, LOW, HIGH); m_testNum++; printTestMessage(m_testNum, "random method creates files with numbers in random order"); randomFile >> fileAmount; while(!randomFile.eof()) { randomFile >> temp; nums.push_back(temp); } //should not be sorted, though there is a very small chance it could isPassed = (!isSortedDescending(nums) && !isSortedAscending(nums)); if(!isPassed) { std::cerr << "ERROR: File does not appear to be random. Check manually." << std::endl; } if(fileAmount != nums.size()) { std::cerr << "ERROR: " << fileAmount << " value excepted in file, " << nums.size() << " read. Is there a newline after last number?" << std::endl; isPassed = false; } printPassFail(isPassed); randomFile.close(); return (isPassed); }
bool Test::test_NumFileGen4() { bool isPassed = false; const int AMOUNT = 100; std::string descendingFileName = "test_descending.dat"; std::ifstream descendingFile(descendingFileName); std::size_t fileAmount = 0; int temp = 0; std::vector<int> nums; NumberFileGenerator::descending(descendingFileName, AMOUNT); m_testNum++; printTestMessage(m_testNum, "descending method creates files with numbers in descending order"); descendingFile >> fileAmount; while(!descendingFile.eof()) { descendingFile >> temp; nums.push_back(temp); } isPassed = isSortedDescending(nums); if(fileAmount != nums.size()) { std::cerr << "ERROR: " << fileAmount << " value excepted in file, " << nums.size() << " read. Is there a newline after last number?" << std::endl; isPassed = false; } printPassFail(isPassed); descendingFile.close(); return (isPassed); }
//--------------------------------------------------------------------- bool ScaledPixelCountLodStrategy::isSorted(const Mesh::LodValueList& values) const { // Check if values are sorted descending return isSortedDescending(values); }