
Hi! I think it might be a great feature if Boost.Test would be able to print diagnostic information saved in boost::exception. Actually my code havily relies on boost::exception. If one of my tests fail, I usually get nothing saying "std::exception occured" error message. But if Boost.Test could just catch boost::exception and print the default diagnostig info it would be a great help. Best Regards, Ovanes

It is possible to get the diagnostic information out of what(). See
www.boost.org/doc/libs/release/libs/exception/doc/diagnostic_information_what.html.
On Mon, Mar 5, 2012 at 11:46 AM, Ovanes Markarian
Hi!
I think it might be a great feature if Boost.Test would be able to print diagnostic information saved in boost::exception. Actually my code havily relies on boost::exception. If one of my tests fail, I usually get nothing saying "std::exception occured" error message. But if Boost.Test could just catch boost::exception and print the default diagnostig info it would be a great help.
Best Regards, Ovanes
_______________________________________________ Boost-users mailing list Boost-users@lists.boost.org http://lists.boost.org/mailman/listinfo.cgi/boost-users

On Mon, Mar 5, 2012 at 11:39 PM, Emil Dotchevski
It is possible to get the diagnostic information out of what(). See
www.boost.org/doc/libs/release/libs/exception/doc/diagnostic_information_what.html .
Thanks a lot for the answer. This is not my use case. I don't want to catch the exception myself in the unit test. I would like Boost.Test to report the extended error.
With Kind Regards, Ovanes

On Tue, Mar 6, 2012 at 11:07 AM, Ovanes Markarian
On Mon, Mar 5, 2012 at 11:39 PM, Emil Dotchevski
wrote: It is possible to get the diagnostic information out of what(). See
www.boost.org/doc/libs/release/libs/exception/doc/diagnostic_information_what.html.
Thanks a lot for the answer. This is not my use case. I don't want to catch the exception myself in the unit test. I would like Boost.Test to report the extended error.
You indicated that your version of Boost.Test shows the what() message. My point was that you can implement (possibly in a base class of your exception class hierarchy) what() using diagnostic_information_what, and you'll see full diagnostic information in any context that displays the what() string. -- Emil Dotchevski Reverge Studios, Inc. http://www.revergestudios.com/reblog/index.php?n=ReCode

On Mon, Mar 5, 2012 at 11:56 PM, Gennadiy Rozental
Ovanes Markarian
writes: I think it might be a great feature if Boost.Test would be able to print diagnostic information saved in boost::exception.
Boost::exception support was added long time ago. if it is not in latest release try trunk version.
Thanks a lot, I will definitely do that! In the 1.42 that is currently in use in the project this feature is not there. Ovanes

I found it helpful to include this in my test cases: #include "boost/test/unit_test_monitor.hpp" #include "boost/exception/all.hpp" void translate(boost::exception const& e) { BOOST_FAIL(boost::diagnostic_information(e)); } struct Exception_fixture { Exception_fixture() { ::boost::unit_test::unit_test_monitor.register_exception_translatorboost::exception(&translate); } }; BOOST_GLOBAL_FIXTURE( Exception_fixture ); BOOST_AUTO_TEST_CASE( case01 ) { //test body } -- View this message in context: http://boost.2283326.n4.nabble.com/Boost-Test-Using-boost-exception-tp444740... Sent from the Boost - Users mailing list archive at Nabble.com.

On Tue, Mar 6, 2012 at 8:53 PM, svarneticist
I found it helpful to include this in my test cases:
#include "boost/test/unit_test_monitor.hpp" #include "boost/exception/all.hpp"
void translate(boost::exception const& e) { BOOST_FAIL(boost::diagnostic_information(e)); }
struct Exception_fixture { Exception_fixture() {
::boost::unit_test::unit_test_monitor.register_exception_translatorboost::exception(&translate); } };
BOOST_GLOBAL_FIXTURE( Exception_fixture );
BOOST_AUTO_TEST_CASE( case01 ) { //test body }
Wow! This is a really great tip! Thanks a lot!
participants (5)
-
Emil Dotchevski
-
Emil Dotchevski
-
Gennadiy Rozental
-
Ovanes Markarian
-
svarneticist