///Gets the input file (if any) ///Runs the histogram application by giving this file as input ///compares the result files with expected outputs in the given path bool RunTestsUnderDirectory(std::string dirPath) { std::ifstream expectedErrorsStream; std::ifstream expectedOutputStream; //trying to open expected_errors file std::string expectedErrorsPath = dirPath + "/expected_errors.txt"; expectedErrorsStream.open(expectedErrorsPath); if (!expectedErrorsStream.is_open() || !expectedErrorsStream.good()) { return false; } //trying to open expected output file std::string expectedOutputPath = dirPath + "/expected_output.txt"; expectedOutputStream.open(expectedOutputPath); if (!expectedOutputStream.is_open() || !expectedOutputStream.good()) { return false; } //running the application with input.txt under given folder FileHistogramApplicationCls<float>* app = new FileHistogramApplicationCls<float>(dirPath + "/input.txt"); app->CreateAndReportHistogram(); delete app; std::string receivedErrorsPath = dirPath + "/received_errors.txt"; std::string receivedOutputPath = dirPath + "/received_output.txt"; CopyFileToTestDirectory("error.txt", receivedErrorsPath); CopyFileToTestDirectory("output.txt", receivedOutputPath); //compares outputs with expected results bool hasTestPassed = CompareFiles(receivedErrorsPath, expectedErrorsPath) && CompareFiles(receivedOutputPath, expectedOutputPath); //prints the test results std::cout << "Test result for input under " << dirPath << " is " << (hasTestPassed ? "PASS" : "FAIL") << std::endl; return true; }
void TSessionTest::RunTests() // // Run tests on iFs file server session // { testDriveList(); testDriveInfo(); testVolumeInfo(); testSetVolume(); testPath(); CreateTestDirectory(_L("\\SESSION_TEST\\TFSRV\\")); testInitialisation(); testSubst(); CopyFileToTestDirectory(); MakeAndDeleteFiles(); }