Boost logo

Boost-Commit :

Subject: [Boost-commit] svn:boost r75397 - in trunk: boost/icl/concept libs/icl/test/fix_tickets_
From: afojgo_at_[hidden]
Date: 2011-11-07 19:20:33


Author: jofaber
Date: 2011-11-07 19:20:31 EST (Mon, 07 Nov 2011)
New Revision: 75397
URL: http://svn.boost.org/trac/boost/changeset/75397

Log:
Fixed ticket #6095 filed by Marvin Sielenkemper. https://svn.boost.org/trac/boost/ticket/6095. Completing is_empty for open intervals (numeric_limits<domain_type>::max(), x).
Text files modified:
   trunk/boost/icl/concept/interval.hpp | 6 ++++--
   trunk/libs/icl/test/fix_tickets_/fix_tickets.cpp | 35 +++++++++++++++++++++++++++++++++++
   2 files changed, 39 insertions(+), 2 deletions(-)

Modified: trunk/boost/icl/concept/interval.hpp
==============================================================================
--- trunk/boost/icl/concept/interval.hpp (original)
+++ trunk/boost/icl/concept/interval.hpp 2011-11-07 19:20:31 EST (Mon, 07 Nov 2011)
@@ -547,7 +547,8 @@
 typename boost::enable_if<is_static_open<Type>, bool>::type
 is_empty(const Type& object)
 {
- return domain_less_equal<Type>(upper(object), domain_next<Type>(lower(object)));
+ return domain_less_equal<Type>(upper(object), domain_next<Type>(lower(object)))
+ || !domain_less<Type>(lower(object), domain_next<Type>(lower(object)));
 }
 
 template<class Type>
@@ -557,7 +558,8 @@
     if(object.bounds() == interval_bounds::closed())
         return domain_less<Type>(upper(object), lower(object));
     else if(object.bounds() == interval_bounds::open())
- return domain_less_equal<Type>(upper(object), domain_next<Type>(lower(object)));
+ return domain_less_equal<Type>(upper(object), domain_next<Type>(lower(object)))
+ || !domain_less<Type>(lower(object), domain_next<Type>(lower(object)));
     else
         return domain_less_equal<Type>(upper(object), lower(object));
 }

Modified: trunk/libs/icl/test/fix_tickets_/fix_tickets.cpp
==============================================================================
--- trunk/libs/icl/test/fix_tickets_/fix_tickets.cpp (original)
+++ trunk/libs/icl/test/fix_tickets_/fix_tickets.cpp 2011-11-07 19:20:31 EST (Mon, 07 Nov 2011)
@@ -54,3 +54,38 @@
     BOOST_CHECK_EQUAL(q1, q1+q5);
 }
 
+//------------------------------------------------------------------------------
+// Ticket #6095 Marvin Sielenkemper
+//------------------------------------------------------------------------------
+BOOST_AUTO_TEST_CASE(ticket_6095_Marvin_Sielenkemper_isEmptyTest)
+{
+ typedef int Value;
+ typedef boost::icl::interval<Value> Interval;
+ typedef std::numeric_limits<Value> Limits;
+
+ Value const max(Limits::max());
+
+ Interval::interval_type piff = Interval::open(max, max);
+
+ BOOST_CHECK(!icl::is_empty(Interval::open(max - 2, max)));
+ BOOST_CHECK( icl::is_empty(Interval::open(max - 1, max)));
+ BOOST_CHECK( icl::is_empty(Interval::open(max, max)));
+}
+
+BOOST_AUTO_TEST_CASE(ticket_6095_Marvin_Sielenkemper_totalRangeTest)
+{
+ typedef int Value;
+ typedef boost::icl::interval<Value> Interval;
+ typedef std::numeric_limits<Value> Limits;
+ typedef boost::icl::interval_map<Value, int, boost::icl::total_enricher> Container;
+
+ Value const min(Limits::min());
+ Value const max(Limits::max());
+
+ boost::icl::interval_map<Value, int, boost::icl::total_enricher> intervals;
+
+ intervals += std::make_pair(Interval::closed(min, max), 0);
+ intervals += std::make_pair(Interval::right_open(0, 10), 3);
+
+ BOOST_CHECK_EQUAL(intervals.iterative_size(), 3);
+}


Boost-Commit list run by bdawes at acm.org, david.abrahams at rcn.com, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk