-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathgen_utils.cpp
More file actions
29 lines (26 loc) · 1.07 KB
/
gen_utils.cpp
File metadata and controls
29 lines (26 loc) · 1.07 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
#include "gen_utils.hpp"
#include "utils.hpp"
/**
* @brief Returns 2 streams: for prompt input files and for solution input files.
*
* @note The caller is responsible for closing the file streams using its close() method.
*/
std::pair<std::ofstream, std::ofstream> setupTest(std::uint64_t testNumber) {
std::ostringstream promptStream;
promptStream << dirs.at("promptInputDirectory") << "/" << testNumber << ".in";
std::string promptInPath = promptStream.str();
std::ostringstream solutionStream;
solutionStream << dirs.at("solutionInputDirectory") << "/" << testNumber << ".in";
std::string solutionInPath = solutionStream.str();
std::ofstream promptInFile(promptInPath);
if (!promptInFile) {
std::cerr << "Error: Could not open the file " << promptInPath << std::endl;
exit(1);
}
std::ofstream solutionInFile(solutionInPath);
if (!solutionInFile) {
std::cerr << "Error: Could not open the file " << solutionInPath << std::endl;
exit(1);
}
return {std::move(promptInFile), std::move(solutionInFile)};
}