Reputation: 21514
When running console programs from Visual Studio, the console shows, program runs and then console disappears without giving you a chance to see it.
In general, I add those lines before main
's return statement:
std::cout << "Press enter to exit " << std::endl;
std::string sGot;
getline(std::cin, sGot);
How can I do something similar when program is compiled with boost::unit_test
framework? As the main
is directly part of the boost
library, I can't modify it (I'd like to avoid recompiling boost
for that).
Upvotes: 0
Views: 320
Reputation: 3385
This is a Visual Studio preference:
Upvotes: 0
Reputation: 5336
You can add a test that is dedicated to this purpose and is always run last.
Edit (completed by jpo38):
BOOST_AUTO_TEST_SUITE( PauseWhenDone )
BOOST_AUTO_TEST_CASE( do_pause )
{
std::cout << "Press enter to exit " << std::endl;
std::string sGot;
getline(std::cin, sGot);
}
BOOST_AUTO_TEST_SUITE_END()
Upvotes: 2