diff --git a/include/cli/clifilesession.h b/include/cli/clifilesession.h index 68177e5..561e6aa 100644 --- a/include/cli/clifilesession.h +++ b/include/cli/clifilesession.h @@ -64,13 +64,10 @@ class CliFileSession : public CliSession { Prompt(); std::string line; - if (!in.good()) - Exit(); - std::getline(in, line); - if (in.eof()) - Exit(); - else + if (std::getline(in, line)) Feed(line); + else + Exit(); } } diff --git a/test/test_cli.cpp b/test/test_cli.cpp index 22cae5c..3910044 100644 --- a/test/test_cli.cpp +++ b/test/test_cli.cpp @@ -91,6 +91,21 @@ void UserInput(Cli& cli, stringstream& oss, const string& input) BOOST_AUTO_TEST_SUITE(CliSuite) +BOOST_AUTO_TEST_CASE(FileSessionFinalLine) +{ + for (const auto& input : {string("add 2 3"), string("add 2 3\n")}) + { + auto rootMenu = make_unique