diff --git a/src/proc/mobject/mobject-ref.cpp b/src/proc/mobject/mobject-ref.cpp index 69b4362f8..e711b26a8 100644 --- a/src/proc/mobject/mobject-ref.cpp +++ b/src/proc/mobject/mobject-ref.cpp @@ -46,7 +46,8 @@ namespace mobject { /** */ - LUMIERA_ERROR_DEFINE (INVALID_PLACEMENTREF, "unresolvable placement reference, or of incompatible type"); + LUMIERA_ERROR_DEFINE (INVALID_PLACEMENTREF, "unresolvable placement reference, or of incompatible type"); + LUMIERA_ERROR_DEFINE (BOTTOM_PLACEMENTREF, "NIL placement-ID marker encountered."); diff --git a/src/proc/mobject/placement-ref.hpp b/src/proc/mobject/placement-ref.hpp index 649fad269..08a42d660 100644 --- a/src/proc/mobject/placement-ref.hpp +++ b/src/proc/mobject/placement-ref.hpp @@ -64,6 +64,8 @@ namespace mobject { LUMIERA_ERROR_DECLARE (INVALID_PLACEMENTREF); ///< unresolvable placement reference, or of incompatible type + LUMIERA_ERROR_DECLARE (BOTTOM_PLACEMENTREF); ///< NIL placement-ID marker encountered + /** * TODO type comment diff --git a/src/proc/mobject/session/placement-index.hpp b/src/proc/mobject/session/placement-index.hpp index 928b53ad3..d591d58e9 100644 --- a/src/proc/mobject/session/placement-index.hpp +++ b/src/proc/mobject/session/placement-index.hpp @@ -176,6 +176,9 @@ namespace session { inline void __check_knownID(PlacementIndex const& idx, PlacementMO::ID id) { + if (!id) + throw lumiera::error::Logic ("Encountered a NIL Placement-ID marker" + ,LUMIERA_ERROR_BOTTOM_PLACEMENTREF); if (!idx.contains (id)) throw lumiera::error::Invalid ("Accessing Placement not registered within the index" ,LUMIERA_ERROR_NOT_IN_SESSION); ///////////////////////TICKET #197 diff --git a/tests/components/proc/mobject/placement-ref-test.cpp b/tests/components/proc/mobject/placement-ref-test.cpp index 55129eb60..14272322e 100644 --- a/tests/components/proc/mobject/placement-ref-test.cpp +++ b/tests/components/proc/mobject/placement-ref-test.cpp @@ -22,13 +22,14 @@ #include "lib/test/run.hpp" -#include "lib/lumitime.hpp" +#include "lib/test/test-helper.hpp" #include "proc/mobject/placement.hpp" #include "proc/mobject/placement-ref.hpp" #include "proc/mobject/session/placement-index.hpp" #include "proc/mobject/session/session-service-mock-index.hpp" #include "proc/mobject/explicitplacement.hpp" #include "proc/mobject/test-dummy-mobject.hpp" +#include "lib/lumitime.hpp" #include "lib/util.hpp" #include @@ -150,15 +151,9 @@ namespace test { // actually, the assignment has invalidated ref1, because of the changed ID ASSERT (p1.getID() == p2.getID()); - try - { - *ref1; - NOTREACHED(); - } - catch (...) - { - ASSERT (lumiera_error () == LUMIERA_ERROR_INVALID_PLACEMENTREF); - } + + VERIFY_ERROR(INVALID_PLACEMENTREF, *ref1 ); + ASSERT (!index->contains(p1)); // index indeed detected the invalid ref ASSERT (3 == ref2.use_count()); // but ref2 is still valid @@ -166,15 +161,14 @@ namespace test { index->remove (ref2); ASSERT (!ref2); // checks invalidity without throwing ASSERT (!refX); - try - { - *ref2; - NOTREACHED(); - } - catch (...) - { - ASSERT (lumiera_error () == LUMIERA_ERROR_INVALID_PLACEMENTREF); - } + VERIFY_ERROR(INVALID_PLACEMENTREF, *ref2 ); + + // deliberately create an invalid PlacementRef + PlacementRef bottom; + ASSERT (!bottom); + VERIFY_ERROR(INVALID_PLACEMENTREF, *bottom ); + VERIFY_ERROR(INVALID_PLACEMENTREF, bottom->specialAPI() ); + VERIFY_ERROR(INVALID_PLACEMENTREF, bottom.resolve() ); //consistency check; then reset PlacementRef index to default ASSERT (0 == index->size()); diff --git a/tests/components/proc/mobject/session/placement-index-test.cpp b/tests/components/proc/mobject/session/placement-index-test.cpp index 63fd5ca32..0e8a42b1b 100644 --- a/tests/components/proc/mobject/session/placement-index-test.cpp +++ b/tests/components/proc/mobject/session/placement-index-test.cpp @@ -27,10 +27,10 @@ //#include "proc/mobject/session.hpp" //#include "proc/mobject/session/edl.hpp" #include "proc/mobject/session/placement-index.hpp" -#include "proc/mobject/session/testclip.hpp" +#include "proc/mobject/session/scope.hpp" #include "proc/mobject/placement.hpp" -//#include "proc/mobject/explicitplacement.hpp" #include "lib/util.hpp" +#include "proc/mobject/session/testclip.hpp" //#include //#include @@ -137,6 +137,27 @@ namespace test { } + void + checkInvalidRef (Idx index) + { + RefPlacement invalid; + PlacementMO::ID invalidID (invalid); + ASSERT (!bool(invalidID)); + ASSERT (!bool(invalid)); + + VERIFY_ERROR(BOTTOM_PLACEMENTREF, index.find(invalid) ); + VERIFY_ERROR(BOTTOM_PLACEMENTREF, index.find(invalidID) ); + VERIFY_ERROR(BOTTOM_PLACEMENTREF, index.getScope(invalidID) ); + + ASSERT (!index.contains(invalidID)); + + PMO testObj = TestClip::create(); + VERIFY_ERROR(INVALID_SCOPE, index.insert(testObj, invalidID) ); + + ASSERT (false == index.remove(invalidID)); + } + + void checkScopeHandling (Idx index) {