c++ - Printf-Style Assertions using CPPUnit -
does cppunit have functionality allow me printf
-style assertions? example:
cppunit_assert("actual size: %d", p->getsize(), p->getsize() == 0);
i know not valid cppunit_assert - using example.
i found cppunit_assert_message(message,condition)
takes string , condition evaluate no luck getting value assert.
you should able this:
#define cppunit_assert_stream(msg, condition) \ { \ std::ostringstream oss; \ cppunit_assert_message(\ static_cast<std::ostringstream &>(oss << msg).str(), \ condition); \ } while (0) cppunit_assert_stream("actual size: " << p->getsize(), p->getsize() == 0);
the above macro can combined boost.format:
cppunit_assert_stream(boost::format("actual size: %d") % p->getsize(), p->getsize() == 0);
Comments
Post a Comment