|
Boost Users : |
Subject: [Boost-users] Boost.Test - how to print the value of a variable in case of error?
From: Attila Feher F (attila.f.feher_at_[hidden])
Date: 2010-06-24 01:19:08
Hi,
I am testing "stuff" in a loop, and the "failure message" from Boost.Test is not too useful, because it does not tell me the "loop variable" value. I have hit this "problem" several times already, not only in loops, but any times a variable is involved in a tested expression. And I was not able to figure out what to do. I've looked at the sources etc., but I am too stupid to see if there is a solution in there. I haven't seen anything in the documentation. :(
Imagine this:
BOOST_CHECK_EQUAL(cont.erase(key),1u);
If it fails, it tells me this:
basics.cpp(61): error in "test_case": check cont.erase(key) == 1u failed [0 != 1]
I cannot see the value of the 'key' variable, so it quite hard to know what that error is. In case of simple code, it may not be a problem to track down what key is, but when it is a loop of over 100000 iterations... :(
..._CHECKPOINT does not work, because it is only printed in case of an exception, but not other failures. :(
I was hoping to find something like:
BOOST_CHECK_EQUAL_WITH(cont.erase(key),1u, (key) );
which would say:
basics.cpp(61): error in "test_case": check cont.erase(key) == 1u failed [0 != 1] with key == 12
Is there a way I could do that? I have tried to ask in #BOOST on IRC, but it seems there are only bots there. :(
TIA,
Attila
Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net