I'd like to have an equivalent to CPPUNIT_ASSERT
, CPPUNIT_ASSERT_MESSAGE
or `CPPUNIT_FAIL' which I can call from some common C code.
Our code is a mix of C and C++. Some older apps and those with specific requirements are coded in C and most, especially newer, are coded in C++.
However, a lot of project-agnostic, common code, such as memory buffer pools, debug tracing, etc are coded in C.
When testing a C++ app in CppUnit, I'd to be able to sprinkle some ASSSERT()s which would cause any running CppUnit test to fail.
Maye something like:
if testing
if running in debugger (Eclipse) then asm("int3"); // stop the debugger, even if no breakpoint at this line
else
if running CppUnit test - fail the test and move on to next
else
trace to log file
Most of that can be run by wrapping a macro around a few #ifdef
s, but I am not sure how I would cause a CppUni test to fail from C code. Can it be done?