Learn how easy it is to sync an existing GitHub or Google Code repo to a SourceForge project! See Demo

Close

#62 CPPUNIT_ASSERT change to report line number of exception

1.12.0
open
nobody
assertion (3)
5
2009-07-03
2009-07-03
Duncan Fletcher
No

With the current implementation of CPPUNIT_ASSERT, if the expression throws an exception then the line number of the assertion is lost. Means you have to break out the debugger and step through to work out which unit test line is throwing the exception. CPPUNIT_ASSERT_NO_THROW doesn't quite cut it because although it'll catch the exception and report it nicely, it doesn't care whether the expression itself is true or false.
This patch changes CPPUNIT_ASSERT (in CPPUNIT_HAVE_CPP_SOURCE_ANNOTATION mode at least) to test the expression as normal, but also to catch any exceptions that are thrown and report those nicely too.

Discussion