[EMAIL PROTECTED] wrote:
--- SNIP Example ---
MyObject* my1 = new MyObject(1, 2, 3);
BOOST_CHECK_EQUAL(my1->getA(), 1);
BOOST_CHECK_EQUAL(my1->getB(), 2);
BOOST_CHECK_EQUAL(my1->getC(), 3);
MyObject* my2 = new MyObject(4, 5, 6);
BOOST_CHECK_EQUAL(my2->getA(), 4);
BOOST_CHECK_EQUAL(my2->getB(), 5);
BOOST_CHECK_EQUAL(my2->getC(), 6);
--- SNIP ---
can be refactored into:
--- SNIP Example refactored ---
void checkMyObject(MyObject* my, int a, int b, int c)
{
BOOST_CHECK_EQUAL(my->getA(), a);
BOOST_CHECK_EQUAL(my->getB(), b);
BOOST_CHECK_EQUAL(my->getC(), c);
}
MyObject* my1 = new MyObject(1, 2, 3);
checkMyObject(my1, 1, 2, 3);
MyObject* my2 = new MyObject(4, 5, 6);
checkMyObject(my2, 4, 5, 6);
--- SNIP ---
The problem with the second version is that if the check for equality
fails, the only output is the line number within checkMyObject() that
failed. No hint about the calling line is present. Ideally all macros
should print out a stack trace (as done in e.g. Java), but from my limited
knowledge of C++ I guess that this is not (easily) possible, so
introducing a BOOST_CHECK_EQUAL_MESSAGE macro is the second best solution
I've a similiar problem with BOOST_CHECK family, but I think the solution
can be different: provide a means to convert failed test into assertion
failure. This way I can conveniently debug. Currently, I have to
replace BOOST_CHECK with assert manually, to find where the failure happened.
Gennadiy, what do you think?
- Volodya
_______________________________________________
Unsubscribe & other changes: http://lists.boost.org/mailman/listinfo.cgi/boost