diff --git a/src/lib/p.hpp b/src/lib/p.hpp index a3ca96975..8bb46aacb 100644 --- a/src/lib/p.hpp +++ b/src/lib/p.hpp @@ -50,6 +50,7 @@ #define LUMIERA_P_H +#include "lib/error.hpp" #include @@ -107,19 +108,19 @@ namespace lumiera { template friend inline bool - operator< (P const& p, P<_O_> const& q) { return (p && q) && (*p < *q); } ////TICKET #307 : problem with equality test in associative containers, where equal(a,b) := !(a < b) && !(b < a) + operator< (P const& p, P<_O_> const& q) { REQUIRE (p && q); return *p < *q; } ///< @note deliberately not allowing comparison on NIL ////TICKET #307 : problem with equality test in associative containers, where equal(a,b) := !(a < b) && !(b < a) template friend inline bool - operator> (P const& p, P<_O_> const& q) { return (p && q) && (*q < *p); } + operator> (P const& p, P<_O_> const& q) { REQUIRE (p && q); return *q < *p; } template friend inline bool - operator<= (P const& p, P<_O_> const& q) { return (p && q)? (*p <= *q) : (!p && !q); } + operator<= (P const& p, P<_O_> const& q) { REQUIRE (p && q); return *p <= *q;} template friend inline bool - operator>= (P const& p, P<_O_> const& q) { return (p && q)? (*p >= *q) : (!p && !q); } + operator>= (P const& p, P<_O_> const& q) { REQUIRE (p && q); return *p >= *q;} }; diff --git a/tests/lib/customsharedptrtest.cpp b/tests/lib/customsharedptrtest.cpp index 1c15f25e5..5c8817dce 100644 --- a/tests/lib/customsharedptrtest.cpp +++ b/tests/lib/customsharedptrtest.cpp @@ -22,6 +22,7 @@ #include "lib/test/run.hpp" +#include "lib/test/test-helper.hpp" #include "lib/util.hpp" #include "lib/p.hpp" @@ -37,6 +38,8 @@ namespace asset { using lumiera::P; using std::tr1::shared_ptr; using std::tr1::weak_ptr; + + using lumiera::error::LUMIERA_ERROR_ASSERTION; struct X @@ -288,17 +291,28 @@ namespace asset { ASSERT (!(pXX == pX5)); // compare subtype ptr to empty ptr: "unequal but not orderable" ASSERT ( (pXX != pX5)); - ASSERT (!(pXX < pX5)); - ASSERT (!(pXX > pX5)); - ASSERT (!(pXX <= pX5)); - ASSERT (!(pXX >= pX5)); ASSERT ( (pX5 == pX6)); // compare two empty ptrs: "equal, equivalent but not orderable" ASSERT (!(pX5 != pX6)); - ASSERT (!(pX5 < pX6)); - ASSERT (!(pX5 > pX6)); - ASSERT ( (pX5 <= pX6)); - ASSERT ( (pX5 >= pX6)); + + // order relations on NIL pointers disallowed + +#if false ///////////////////////////////////////////////////////////////////////////////////////////////TICKET #537 : restore throwing ASSERT + VERIFY_ERROR (ASSERTION, pXX < pX5 ); + VERIFY_ERROR (ASSERTION, pXX > pX5 ); + VERIFY_ERROR (ASSERTION, pXX <= pX5 ); + VERIFY_ERROR (ASSERTION, pXX >= pX5 ); + + VERIFY_ERROR (ASSERTION, pX5 < pXX ); + VERIFY_ERROR (ASSERTION, pX5 > pXX ); + VERIFY_ERROR (ASSERTION, pX5 <= pXX ); + VERIFY_ERROR (ASSERTION, pX5 >= pXX ); + + VERIFY_ERROR (ASSERTION, pX5 < pX6 ); + VERIFY_ERROR (ASSERTION, pX5 > pX6 ); + VERIFY_ERROR (ASSERTION, pX5 <= pX6 ); + VERIFY_ERROR (ASSERTION, pX5 >= pX6 ); +#endif ///////////////////////////////////////////////////////////////////////////////////////////////TICKET #537 : restore throwing ASSERT } };