From 8ddca89fb7fd9ff97e3100b1962a155a69f12ea0 Mon Sep 17 00:00:00 2001 From: Felix Schurk Date: Sun, 11 Feb 2024 12:53:12 +0200 Subject: [PATCH] add output to std::cout when no file name given in driver * for demonstration purposes one can also just pipe to the terminal * if a file name is given it writes into the files --- tests/integration/driver.cpp | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/tests/integration/driver.cpp b/tests/integration/driver.cpp index b2553cf..b3551f5 100644 --- a/tests/integration/driver.cpp +++ b/tests/integration/driver.cpp @@ -7,7 +7,6 @@ int main(int argc, char **argv) { const std::string FILENAME{argv[1]}; - const std::string FILENAME_OUTPUT{argv[2]}; // read into to config file auto configFile = std::make_unique(); @@ -23,10 +22,17 @@ int main(int argc, char **argv) { parser->parse(output_pair); - std::ofstream OutputFile (FILENAME_OUTPUT); - for (auto const &str: output_pair.first) { + if (argv[2] != nullptr){ + const std::string FILENAME_OUTPUT{argv[2]}; + std::ofstream OutputFile (FILENAME_OUTPUT); + for (auto const &str: output_pair.first) { OutputFile << str << std::endl; + } + OutputFile.close(); } - - OutputFile.close(); -} \ No newline at end of file + else{ + for (auto const &str: output_pair.first) { + std::cout << str << std::endl; + } + } +}