WIP: test support macro for exception check

This commit is contained in:
Fischlurch 2009-06-07 03:22:08 +02:00
parent 905c0319be
commit f1827ea753
5 changed files with 32 additions and 30 deletions

View file

@ -90,7 +90,7 @@ namespace test
} // namespace test
// make them global for convienience
// make them global for convenience
using ::test::Arg;
using ::test::Test;
using ::test::Launch;

View file

@ -69,7 +69,7 @@ namespace test{
/** for printing sizeof().
* prints the given size and name litterally, without any further magic */
* prints the given size and name literally, without any further magic */
string
showSizeof (size_t siz, Symbol name);
@ -98,4 +98,27 @@ namespace test{
}} // namespace lib::test
/* === test helper macros === */
/**
* Macro to verify a statement indeed raises an exception.
* If no exception is thrown, the #NOTREACHED macro will trigger
* an assertion failure. In case of an exception, the #lumiera_error
* state is checked, cleared and verified.
*/
#define VERIFY_ERROR(ERROR_ID, ERRONEOUS_STATEMENT) \
try \
{ \
ERRONEOUS_STATEMENT ; \
NOTREACHED; \
} \
catch (...) \
{ \
ASSERT (lumiera_error () == LUMIERA_ERROR_##ERROR_ID ); \
}
#endif

View file

@ -244,7 +244,7 @@ namespace util {
* and we probably will enforce this design rule in future. */
#define INSTANCEOF(CLASS, EXPR) (dynamic_cast<const CLASS*> (EXPR))
/** the inevitalbe MAX macro, sometimes still necessary in template code */
/** the inevitable MAX macro, sometimes still necessary in template code */
#ifndef MAX // this is present to make this definition play nice with GLib
#define MAX(A,B) ((A < B) ? (B) : (A))
#endif

View file

@ -201,24 +201,8 @@ namespace test {
ASSERT (2 == p1.use_count());
ASSERT (2 == p2.use_count());
try
{
rMO.getPlacement();
NOTREACHED;
}
catch (...)
{
ASSERT (lumiera_error () == error::LUMIERA_ERROR_INVALID_PLACEMENTREF);
}
try
{
rMO->getMedia();
NOTREACHED
}
catch (...)
{
ASSERT (lumiera_error () == LUMIERA_ERROR_INVALID_MOBJECTREF);
}
VERIFY_ERROR (INVALID_PLACEMENTREF, rMO.getPlacement() );
VERIFY_ERROR (INVALID_MOBJECTREF, rMO->getMedia() );
}
void

View file

@ -47,6 +47,7 @@ namespace test {
using session::Clip;
using lib::test::showSizeof;
using namespace mobject::test;
using error::LUMIERA_ERROR_ASSERTION;
/***************************************************************************************
@ -147,15 +148,9 @@ namespace test {
///////////////////////////////////////////////////////////////////////////////TODO: find a way to configure NoBug to throw in case of assertion
///////////////////////////////////////////////////////////////////////////////TODO: configure NoBug specifically for the testsuite
// try
// {
// hijacked->specialAPI();
// NOTREACHED;
// }
// catch (...)
// {
// ASSERT (lumiera_error () == error::LUMIERA_ERROR_ASSERTION);
// }
#ifdef false
VERIFY_ERROR (ASSERTION, hijacked->specialAPI() );
#endif
// runtime type diagnostics based on pointee RTTI
ASSERT ( pSub2.isCompatible<MObject>());