[unit_test_framework] checkpoints for BOOST_CHECK*?
Hallo, I need to write an unit test checking several various inputs. As there may be larger number of the inputs, I thought about a loop. The problem is how to know the input for which the test failed (if it failed). I wanted to write something like this: .... BOOST_AUTO_TEST_CASE(....) { // each tested_variant may be quite complicated structure for (tested_variants::iterator i) { BOOST_TEST_CHECKPOINT("variant:" << i); // not usable for what I need :-( BOOST_CHECK_EQUAL(i.expected, tested_method(i.data)); } } .... However, BOOST_TEST_CHECKPOINT() does not work in this situation (well, according to the documentation it works for exceptions only). Is there a way how to achieve what I am looking for? Thank you very much, Dan T.
rozelak@volny.cz wrote:
Is there a way how to achieve what I am looking for?
Use BOOST_TEST_MESSAGE and set log level to message
Gennadiy
Yes, I have read about this option and it works - thank you. I consider it as not perfect, but working solution. However, I want to ask, if the idea of checkpoints could be generalised and used during check failure printing as well (as has been suggested in the example in my first post). I don't know boost source in depth, but it seems that BOOST_TEST_CHECKPOINT just calls boost::unit_test::unit_test_log.set_checkpoint(...), which stores the checkpoint info in unit_test_log (which is supposed to be singleton). Would, therefore, be possible to print the checkpoint stored also when test failure is printed? May I be helpfull somehow to do this? Or is it against the idea of the checkpoints? Thank you very much, Dan
AMDG rozelak@volny.cz wrote:
rozelak@volny.cz wrote:
Is there a way how to achieve what I am looking for?
Use BOOST_TEST_MESSAGE and set log level to message
Yes, I have read about this option and it works - thank you. I consider it as not perfect, but working solution.
However, I want to ask, if the idea of checkpoints could be generalised and used during check failure printing as well (as has been suggested in the example in my first post). I don't know boost source in depth, but it seems that BOOST_TEST_CHECKPOINT just calls boost::unit_test::unit_test_log.set_checkpoint(...), which stores the checkpoint info in unit_test_log (which is supposed to be singleton). Would, therefore, be possible to print the checkpoint stored also when test failure is printed? May I be helpfull somehow to do this?
Or is it against the idea of the checkpoints?
I think the issue is that BOOST_CHECK and friends set a checkpoint. In Christ, Steven Watanabe
participants (3)
-
Gennadiy Rozental
-
rozelak@volny.cz
-
Steven Watanabe