Is the use of BOOST_CHECK_EQUAL not permitted in init_unit_test_suite(int argc, char* argv[])? The following code throws an exception and reports the error "Boost.Test internal framework error: unknown reason" boost::unit_test::test_suite* init_unit_test_suite(int argc, char* argv[]) { BOOST_CHECK_EQUAL(foo(argc, argv), 0); boost::unit_test::test_suite* test = BOOST_TEST_SUITE("My test"); test -> add(BOOST_TEST_CASE(&test1)); test -> add(BOOST_TEST_CASE(&test2)); return test; } when the following works without any problems: boost::unit_test::test_suite* init_unit_test_suite(int argc, char* argv[]) { int result = foo(argc, argv); assert(result == 0); boost::unit_test::test_suite* test = BOOST_TEST_SUITE("My test"); test -> add(BOOST_TEST_CASE(&test1)); test -> add(BOOST_TEST_CASE(&test2)); return test; } I have no problem with using the latter code, but I am surprised that I get an exception in the former code and that it is caught by "..." and not by the library. If BOOST_CHECK_EQUAL (and BOOST_CHECK, BOOST_CHECK_CLOSE, etc) is not allowed in init_unit_test_suite(), is this fact documented? Should it generate an exception that can be caught by the library and reported with a useful message? Thanks, Paul
Is the use of BOOST_CHECK_EQUAL not permitted in init_unit_test_suite(int argc, char* argv[])?
No. It's not. You could use Test tools only within test case. Until init_unit_test_suite is not done test tree is not considered initialized and no testing could be done.
The following code throws an exception and reports the error "Boost.Test internal framework error: unknown reason"
Yeah. I guess it should produce more clear message. Will fix. Gennadiy
Gennadiy Rozental wrote:
Is the use of BOOST_CHECK_EQUAL not permitted in init_unit_test_suite(int argc, char* argv[])?
No. It's not. You could use Test tools only within test case. Until init_unit_test_suite is not done test tree is not considered initialized and no testing could be done.
That's what I thought - that something has not be initialised. Thanks for the clarification.
The following code throws an exception and reports the error "Boost.Test internal framework error: unknown reason"
Yeah. I guess it should produce more clear message. Will fix.
That will be helpful. Thanks. Paul
participants (2)
-
Gennadiy Rozental
-
Paul Giaccone