
From: Hicham Mouline
Because RemoveSimulation(....) takes arguments which are not available inside the SimulatonId object/destructor.
Hi Hicham,
In our test suites we deal with this problem by using an own special
implementation of the assert() function. In this assert, called
dynamicAssert() or runTimeAssert(), we call the real assert() only if
the application is not running under test application. If running under
test, we throw an special exception type instead, e.g. AssertionEx. This
exception can be caught by the UTF and tested by Test-Tools. The
exception instance can hold some information from the assert, like file
and line, which can be printed out by a special exception handler, that
must be registered for the UTF.
Some example code:
// runtimeAssert.h defines an own assertion macro for the user code
struct AssertionEx;
extern void runtimeAssert_( const char* exp, const char* file, unsigned
long nLineNo ) throw AssertionEx;
#define dynamicAssert ( exp ) \
(void)((exp) || (runtimeAssert_(#exp, __FILE__, __LINE__), 0 ) )
// runtimeassert.cpp with special assert() implementation
struct AssertionEx
{
const char* exp_;
const char* file_;
unsigned long lineNo_;
AssertionEx( const char* exp, const char* file, unsigned long line )
: exp_(exp), file_(file), lineNo_(line)
{}
};
static bool runningUnderTest = false;
void runUnderTest() // must be called once by your test application
main()
{
runningUnderTest = true;
}
extern "C" {
#include