> void checkMyObject(MyObject* my, int context, int a, int b, int c) > { > BOOST_CHECK_EQUAL_MESSAGE(my->getA(), a, context); > BOOST_CHECK_EQUAL_MESSAGE(my->getB(), b, context); > BOOST_CHECK_EQUAL_MESSAGE(my->getC(), c, context); > } > > MyObject* my1 = new MyObject(1, 2, 3); > checkMyObject(my1, __LINE__, 1, 2, 3); > MyObject* my2 = new MyObject(4, 5, 6); > checkMyObject(my2, __LINE__, 4, 5, 6);
I believe that message provided by BOOST_CHECK_EQUAL is more valuable, cause it gives the mismatched values. When you run in this kind of the situation I would recommend: 1. Use macro instead of function #define CHECK_MY_OBJECT( obj, vA, vB, vC ) \ BOOST_CHECK_EQUAL(obj->getA(), v1); \ .... This way want loose line information. 2. use BOOST_MESSAGE tool void checkMyObject(MyObject* my, int context, int a, int b, int c, size_t source_line) { BOOST_MESSAGE( "Testing " << my->some_kind_of_object_identification() ); // or BOOST_MESSAGE( "Perform check on line: " << source_line ); BOOST_CHECK_EQUAL(my->getA(), a); BOOST_CHECK_EQUAL(my->getB(), b); BOOST_CHECK_EQUAL(my->getC(), c); } Regards, Gennadiy. P.S. Don't forget to set log level to "messages" would you decide to choose the second solution. _______________________________________________ Unsubscribe & other changes: http://lists.boost.org/mailman/listinfo.cgi/boost