diff --git a/src/lib/test/run.hpp b/src/lib/test/run.hpp index 0b3e896b3..930e3592f 100644 --- a/src/lib/test/run.hpp +++ b/src/lib/test/run.hpp @@ -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; diff --git a/src/lib/test/test-helper.hpp b/src/lib/test/test-helper.hpp index 23c252148..91b13da96 100644 --- a/src/lib/test/test-helper.hpp +++ b/src/lib/test/test-helper.hpp @@ -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 diff --git a/src/lib/util.hpp b/src/lib/util.hpp index 1fba41ca1..a835fc443 100644 --- a/src/lib/util.hpp +++ b/src/lib/util.hpp @@ -244,7 +244,7 @@ namespace util { * and we probably will enforce this design rule in future. */ #define INSTANCEOF(CLASS, EXPR) (dynamic_cast (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 diff --git a/tests/components/proc/mobject/mobject-ref-test.cpp b/tests/components/proc/mobject/mobject-ref-test.cpp index ac0617818..cafae095f 100644 --- a/tests/components/proc/mobject/mobject-ref-test.cpp +++ b/tests/components/proc/mobject/mobject-ref-test.cpp @@ -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 diff --git a/tests/components/proc/mobject/placement-hierarchy-test.cpp b/tests/components/proc/mobject/placement-hierarchy-test.cpp index 6ca72b590..3da03055e 100644 --- a/tests/components/proc/mobject/placement-hierarchy-test.cpp +++ b/tests/components/proc/mobject/placement-hierarchy-test.cpp @@ -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());