#47 running under a debugger on Windows CPPUNIT_ASSERT can Break

open
nobody
5
2014-12-01
2007-09-17
Les
No

When running in a debugger under windows it would be nice if CPPUNIT_ASSERT(false); would stop like a break point as opposed to just reporting it at the end of the run. From what I can see this can be accomplished via adding code similar to that below to Asserter.cpp in the method Asserter::Fail(). This will cause a message to be printed in the IDE that when using visual studio, among others will bring the user straight to the line that contains the failed assertion by double clicking on the line in the debugger.

void
Asserter::fail( const Message &message,
const SourceLine &sourceLine )
{
#ifdef _WIN32
if (::IsDebuggerPresent())
{
std::ostringstream oss;
oss << sourceLine.fileName() << "(" << sourceLine.lineNumber() << ") : " << message.shortDescription() << " " << message.details() << std::endl;
::OutputDebugString(oss.str().c_str());
::DebugBreak();
}
#endif // _WIN32
throw Exception( message, sourceLine ); 37 throw Exception( message, sourceLine );
}

just a thought.

Discussion


Log in to post a comment.

Get latest updates about Open Source Projects, Conferences and News.

Sign up for the SourceForge newsletter:

JavaScript is required for this form.





No, thanks