2006-06-13

CPPUnit Addon

I had to dig CPPUnit a little to have a possibility to inspect values of MFC CString in case of test failure.

#include <cppunit/TestAssert.h>

CPPUNIT_NS_BEGIN
// specialization for the CString type
template<>
struct assertion_traits<CString>
{
static bool equal( const CString& x, const CString& y )
{
return x == y;
}

static std::string toString( const CString& x )
{
// adds quote around the string to see whitespace
OStringStream ost;
ost << "\""<<(LPCSTR)x<<"\"";
return ost.str();;
}
};
CPPUNIT_NS_END


When I'll have enough time I'll readjust CompilerOutputter a little to have nice green and red lines in the console :)

No comments:

Post a Comment