Boost logo

Boost-Commit :

Subject: [Boost-commit] svn:boost r50726 - in sandbox/itl: boost/itl libs/itl/test libs/itl/test/test_interval_map libs/itl/test/test_interval_map_mixed libs/itl/test/test_interval_set libs/itl/test/test_interval_set_mixed libs/itl/test/test_separate_interval_set libs/itl/test/test_split_interval_map libs/itl/test/test_split_interval_set
From: afojgo_at_[hidden]
Date: 2009-01-22 09:01:52


Author: jofaber
Date: 2009-01-22 09:01:50 EST (Thu, 22 Jan 2009)
New Revision: 50726
URL: http://svn.boost.org/trac/boost/changeset/50726

Log:
Added tests: Added overloading tests for infix .&. testing is_inter_combinable<T>.
Stable {msvc-9.0, partly congcc-4.3-a7}

Text files modified:
   sandbox/itl/boost/itl/interval_sets.hpp | 35 ++++++++++++++-------------
   sandbox/itl/boost/itl/operators.hpp | 4 +-
   sandbox/itl/libs/itl/test/test_interval_map/test_interval_map.cpp | 2 +
   sandbox/itl/libs/itl/test/test_interval_map/test_interval_map_shared.cpp | 4 +++
   sandbox/itl/libs/itl/test/test_interval_map_mixed/test_interval_map_mixed.cpp | 12 +++++++++
   sandbox/itl/libs/itl/test/test_interval_map_shared.hpp | 50 ++++++++++++++++++++++++++++++++++++++-
   sandbox/itl/libs/itl/test/test_interval_set/test_interval_set_shared.cpp | 4 +++
   sandbox/itl/libs/itl/test/test_interval_set_mixed/test_interval_set_mixed.cpp | 14 +++++++++++
   sandbox/itl/libs/itl/test/test_interval_set_shared.hpp | 22 ++++++++++++++++
   sandbox/itl/libs/itl/test/test_separate_interval_set/test_separate_interval_set_shared.cpp | 7 ++++
   sandbox/itl/libs/itl/test/test_split_interval_map/test_split_interval_map.cpp | 2 +
   sandbox/itl/libs/itl/test/test_split_interval_map/test_split_interval_map_shared.cpp | 4 +++
   sandbox/itl/libs/itl/test/test_split_interval_set/test_split_interval_set_shared.cpp | 5 ++++
   sandbox/itl/libs/itl/test/test_value_maker.hpp | 18 ++++++++++++++
   14 files changed, 160 insertions(+), 23 deletions(-)

Modified: sandbox/itl/boost/itl/interval_sets.hpp
==============================================================================
--- sandbox/itl/boost/itl/interval_sets.hpp (original)
+++ sandbox/itl/boost/itl/interval_sets.hpp 2009-01-22 09:01:50 EST (Thu, 22 Jan 2009)
@@ -10,6 +10,7 @@
 
 #include <boost/itl/interval_base_set.hpp>
 #include <boost/itl/interval_set_algo.hpp>
+#include <boost/itl/operators.hpp>
 
 namespace boost{namespace itl
 {
@@ -22,19 +23,18 @@
 //-----------------------------------------------------------------------------
 template
 <
- class SubType, class DomainT,
- ITL_COMPARE Compare, template<class,ITL_COMPARE>class Interval, ITL_ALLOC Alloc,
+ class ObjectT,
+ class DomainT, ITL_COMPARE Compare, template<class,ITL_COMPARE>class Interval, ITL_ALLOC Alloc,
     template<class, ITL_COMPARE, template<class,ITL_COMPARE>class, ITL_ALLOC>class IntervalSet
>
-interval_base_set<SubType,DomainT,Compare,Interval,Alloc>&
-operator +=
+ObjectT& operator +=
 (
- interval_base_set<SubType,DomainT,Compare,Interval,Alloc>& object,
- const IntervalSet <DomainT,Compare,Interval,Alloc>& operand
+ ObjectT& object,
+ const IntervalSet<DomainT,Compare,Interval,Alloc>& operand
 )
 {
- typedef IntervalSet<DomainT,Compare,Interval,Alloc> set_type;
- const_FORALL(typename set_type, elem_, operand)
+ typedef IntervalSet<DomainT,Compare,Interval,Alloc> operand_type;
+ const_FORALL(typename operand_type, elem_, operand)
         object.add(*elem_);
 
     return object;
@@ -42,21 +42,22 @@
 
 template
 <
- class SubType, class DomainT,
- ITL_COMPARE Compare, template<class,ITL_COMPARE>class Interval, ITL_ALLOC Alloc,
+ class DomainT, ITL_COMPARE Compare, template<class,ITL_COMPARE>class Interval, ITL_ALLOC Alloc,
     template<class, ITL_COMPARE, template<class,ITL_COMPARE>class, ITL_ALLOC>class IntervalSet
>
-interval_base_set<SubType,DomainT,Compare,Interval,Alloc>
-operator +
+IntervalSet<DomainT,Compare,Interval,Alloc>&
+operator +=
 (
- const interval_base_set<SubType,DomainT,Compare,Interval,Alloc>& object,
- const IntervalSet <DomainT,Compare,Interval,Alloc>& operand
+ IntervalSet<DomainT,Compare,Interval,Alloc>& object,
+ const IntervalSet<DomainT,Compare,Interval,Alloc>& operand
 )
 {
- typedef interval_base_set<SubType,DomainT,Compare,Interval,Alloc> ObjectT;
- return ObjectT(object) += operand;
+ typedef IntervalSet<DomainT,Compare,Interval,Alloc> operand_type;
+ const_FORALL(typename operand_type, elem_, operand)
+ object.add(*elem_);
+
+ return object;
 }
-//-----------------------------------------------------------------------------
 
 //--- interval_type -----------------------------------------------------------
 template

Modified: sandbox/itl/boost/itl/operators.hpp
==============================================================================
--- sandbox/itl/boost/itl/operators.hpp (original)
+++ sandbox/itl/boost/itl/operators.hpp 2009-01-22 09:01:50 EST (Thu, 22 Jan 2009)
@@ -75,12 +75,12 @@
 // Intersection
 //------------------------------------------------------------------------------
 template<class ObjectT, class OperandT>
-typename boost::enable_if<is_interval_set_companion<ObjectT, OperandT>, ObjectT>::type
+typename boost::enable_if<is_inter_combinable<ObjectT, OperandT>, ObjectT>::type
 operator & (const ObjectT& object, const OperandT& operand)
 { return ObjectT(object) &= operand; }
 
 template<class ObjectT, class OperandT>
-typename boost::enable_if<is_interval_set_companion<ObjectT, OperandT>, ObjectT>::type
+typename boost::enable_if<is_inter_combinable<ObjectT, OperandT>, ObjectT>::type
 operator & (const OperandT& operand, const ObjectT& object)
 { return ObjectT(object) &= operand; }
 

Modified: sandbox/itl/libs/itl/test/test_interval_map/test_interval_map.cpp
==============================================================================
--- sandbox/itl/libs/itl/test/test_interval_map/test_interval_map.cpp (original)
+++ sandbox/itl/libs/itl/test/test_interval_map/test_interval_map.cpp 2009-01-22 09:01:50 EST (Thu, 22 Jan 2009)
@@ -16,6 +16,8 @@
 #include "../test_value_maker.hpp"
 #include "../test_laws.hpp"
 
+#include <boost/itl/separate_interval_set.hpp>
+#include <boost/itl/split_interval_set.hpp>
 #include <boost/itl/interval_map.hpp>
 #include <boost/itl/split_interval_map.hpp>
 

Modified: sandbox/itl/libs/itl/test/test_interval_map/test_interval_map_shared.cpp
==============================================================================
--- sandbox/itl/libs/itl/test/test_interval_map/test_interval_map_shared.cpp (original)
+++ sandbox/itl/libs/itl/test/test_interval_map/test_interval_map_shared.cpp 2009-01-22 09:01:50 EST (Thu, 22 Jan 2009)
@@ -54,3 +54,7 @@
 (test_itl_interval_map_infix_plus_overload_4_bicremental_types, T, bicremental_types)
 { interval_map_infix_plus_overload_4_bicremental_types<interval_map, T, int>();}
 
+BOOST_AUTO_TEST_CASE_TEMPLATE
+(test_itl_interval_map_infix_et_overload_4_bicremental_types, T, bicremental_types)
+{ interval_map_infix_et_overload_4_bicremental_types<interval_map, T, int>();}
+

Modified: sandbox/itl/libs/itl/test/test_interval_map_mixed/test_interval_map_mixed.cpp
==============================================================================
--- sandbox/itl/libs/itl/test/test_interval_map_mixed/test_interval_map_mixed.cpp (original)
+++ sandbox/itl/libs/itl/test/test_interval_map_mixed/test_interval_map_mixed.cpp 2009-01-22 09:01:50 EST (Thu, 22 Jan 2009)
@@ -1215,3 +1215,15 @@
     BOOST_CHECK_EQUAL( split_A, split_B );
 }
 
+BOOST_AUTO_TEST_CASE_TEMPLATE(test_itl_interval_set_mixed_infix_plus_overload_4_bicremental_types, T, bicremental_types)
+{
+ typedef int U;
+ typedef interval_map<T,U> IntervalMapT;
+ interval_map<T,U> join_a;
+ split_interval_map<T,U> split_a;
+
+ join_a .add(CDv(1,3,1)).add(IDv(8,9,1)).add(IIv(6,11,3));
+ split_a.add(IDv(0,9,2)).add(IIv(3,6,1)).add(IDv(5,7,1));
+
+ BOOST_CHECK_EQUAL(split_a + join_a, join_a + split_a);
+}
\ No newline at end of file

Modified: sandbox/itl/libs/itl/test/test_interval_map_shared.hpp
==============================================================================
--- sandbox/itl/libs/itl/test/test_interval_map_shared.hpp (original)
+++ sandbox/itl/libs/itl/test/test_interval_map_shared.hpp 2009-01-22 09:01:50 EST (Thu, 22 Jan 2009)
@@ -8,8 +8,6 @@
 #ifndef __test_itl_interval_map_shared_h_JOFA_081005__
 #define __test_itl_interval_map_shared_h_JOFA_081005__
 
-#include <boost/type_traits/is_same.hpp>
-
 template <template<class T, class U,
                    class Traits = neutron_absorber,
                    ITL_COMPARE Compare = ITL_COMPARE_INSTANCE(std::less, U),
@@ -823,5 +821,53 @@
         BOOST_CHECK_EQUAL(map_b + map_pair, map_pair + map_b);
 }
 
+template <template<class T, class U,
+ class Traits = neutron_absorber,
+ ITL_COMPARE Compare = ITL_COMPARE_INSTANCE(std::less, U),
+ ITL_COMBINE Combine = ITL_COMBINE_INSTANCE(itl::inplace_plus, U),
+ ITL_SECTION Section = ITL_SECTION_INSTANCE(itl::inplace_star, U),
+ template<class,ITL_COMPARE>class Interval = interval,
+ ITL_ALLOC Alloc = std::allocator
+ >class IntervalMap,
+ class T, class U>
+void interval_map_infix_et_overload_4_bicremental_types()
+{
+ typedef IntervalMap<T,U> IntervalMapT;
+
+ typename IntervalMapT::interval_mapping_type val_pair1 = IDv(6,9,1);
+ std::pair<const interval<T>, U> val_pair2 = IDv(3,5,3);
+ mapping_pair<T,U> map_pair = K_v(4,3);
+
+ itl::interval<T> itv = C_D(4,11);
+
+ IntervalMapT map_a, map_b;
+ map_a.add(CDv(1,3,1)).add(IDv(8,9,1)).add(IIv(6,11,3));
+ map_b.add(IDv(0,9,2)).add(IIv(3,6,1)).add(IDv(5,7,1));
+
+ interval_set<T> join_set_a;
+ separate_interval_set<T> sep_set_a;
+ split_interval_set<T> split_set_a;
+ join_set_a .add(I_D(0,4)).add(I_I(4,6)).add(I_D(5,9));
+ sep_set_a .add(I_D(0,4)).add(I_I(4,6)).add(I_D(5,11));
+ split_set_a.add(I_I(0,0)).add(I_D(8,7)).add(I_I(6,11));
+
+ //Happy day overloading
+ BOOST_CHECK_EQUAL(map_a & map_b, map_b & map_a);
+
+ //This checks all cases of is_interval_map_derivative<T>
+ BOOST_CHECK_EQUAL(map_a & val_pair1, val_pair1 & map_a);
+ BOOST_CHECK_EQUAL(map_b & val_pair2, val_pair2 & map_b);
+ BOOST_CHECK_EQUAL(map_b & map_pair, map_pair & map_b);
+
+ //This checks all cases of is_interval_set_derivative<T>
+ BOOST_CHECK_EQUAL(map_a & itv, itv & map_a);
+ BOOST_CHECK_EQUAL(map_b & MK_v(8), MK_v(8) & map_b);
+
+ //This checks all cases of is_interval_set_companion<T>
+ BOOST_CHECK_EQUAL(map_a & split_set_a, split_set_a & map_a);
+ BOOST_CHECK_EQUAL(map_a & sep_set_a, sep_set_a & map_a);
+ BOOST_CHECK_EQUAL(map_a & join_set_a, join_set_a & map_a);
+}
+
 #endif // __test_itl_interval_map_shared_h_JOFA_080920__
 

Modified: sandbox/itl/libs/itl/test/test_interval_set/test_interval_set_shared.cpp
==============================================================================
--- sandbox/itl/libs/itl/test/test_interval_set/test_interval_set_shared.cpp (original)
+++ sandbox/itl/libs/itl/test/test_interval_set/test_interval_set_shared.cpp 2009-01-22 09:01:50 EST (Thu, 22 Jan 2009)
@@ -42,3 +42,7 @@
 (test_itl_interval_set_base_intersect_4_bicremental_types, T, bicremental_types)
 { interval_set_base_intersect_4_bicremental_types<interval_set, T>();}
 
+BOOST_AUTO_TEST_CASE_TEMPLATE
+(test_itl_interval_set_infix_plus_overload_4_bicremental_types, T, bicremental_types)
+{ interval_set_infix_plus_overload_4_bicremental_types<interval_set, T>();}
+

Modified: sandbox/itl/libs/itl/test/test_interval_set_mixed/test_interval_set_mixed.cpp
==============================================================================
--- sandbox/itl/libs/itl/test/test_interval_set_mixed/test_interval_set_mixed.cpp (original)
+++ sandbox/itl/libs/itl/test/test_interval_set_mixed/test_interval_set_mixed.cpp 2009-01-22 09:01:50 EST (Thu, 22 Jan 2009)
@@ -751,3 +751,17 @@
     BOOST_CHECK_EQUAL( is_disjoint(join_A, join_B), true );
 }
 
+BOOST_AUTO_TEST_CASE_TEMPLATE(test_itl_interval_set_mixed_infix_plus_overload_4_bicremental_types, T, bicremental_types)
+{
+ interval_set<T> join_a;
+ separate_interval_set<T> sep_a;
+ split_interval_set<T> split_a;
+
+ join_a.add(I_D(0,4)) .add(I_I(4,6)).add(I_D(5,9));
+ sep_a .add(I_D(0,4)) .add(I_I(4,6)).add(I_D(5,11));
+ split_a.add(I_I(0,0)).add(I_D(8,7)).add(I_I(6,11));
+
+ BOOST_CHECK_EQUAL(split_a + sep_a, sep_a + split_a );
+ BOOST_CHECK_EQUAL(split_a + join_a, join_a + split_a);
+ BOOST_CHECK_EQUAL(sep_a + join_a, join_a + sep_a );
+}
\ No newline at end of file

Modified: sandbox/itl/libs/itl/test/test_interval_set_shared.hpp
==============================================================================
--- sandbox/itl/libs/itl/test/test_interval_set_shared.hpp (original)
+++ sandbox/itl/libs/itl/test/test_interval_set_shared.hpp 2009-01-22 09:01:50 EST (Thu, 22 Jan 2009)
@@ -8,7 +8,6 @@
 #ifndef __test_itl_interval_set_shared_h_JOFA_080920__
 #define __test_itl_interval_set_shared_h_JOFA_080920__
 
-
 template <template< class T,
                     ITL_COMPARE Compare = ITL_COMPARE_INSTANCE(std::less, T),
                                         template<class,ITL_COMPARE>class Interval = interval,
@@ -509,5 +508,26 @@
 }
 
 
+template <template< class T,
+ ITL_COMPARE Compare = ITL_COMPARE_INSTANCE(std::less, T),
+ template<class,ITL_COMPARE>class Interval = interval,
+ ITL_ALLOC Alloc = std::allocator
+ >class IntervalSet,
+ class T>
+void interval_set_infix_plus_overload_4_bicremental_types()
+{
+ typedef IntervalSet<T> IntervalSetT;
+ itl::interval<T> itv = I_D(3,5);
+
+ IntervalSetT set_a, set_b;
+ set_a.add(C_D(1,3)).add(I_D(8,9)).add(I_I(6,11));
+ set_b.add(I_D(0,9)).add(I_I(3,6)).add(I_D(5,7));
+
+ BOOST_CHECK_EQUAL(set_a + set_b, set_b + set_a);
+ //This checks all cases of is_interval_set_derivative<T>
+ BOOST_CHECK_EQUAL(set_a + itv, itv + set_a);
+ BOOST_CHECK_EQUAL(set_b + MK_v(4), MK_v(4) + set_b);
+}
+
 #endif // __test_itl_interval_set_shared_h_JOFA_080920__
 

Modified: sandbox/itl/libs/itl/test/test_separate_interval_set/test_separate_interval_set_shared.cpp
==============================================================================
--- sandbox/itl/libs/itl/test/test_separate_interval_set/test_separate_interval_set_shared.cpp (original)
+++ sandbox/itl/libs/itl/test/test_separate_interval_set/test_separate_interval_set_shared.cpp 2009-01-22 09:01:50 EST (Thu, 22 Jan 2009)
@@ -40,4 +40,9 @@
 
 BOOST_AUTO_TEST_CASE_TEMPLATE
 (test_itl_interval_set_base_intersect_4_bicremental_types, T, bicremental_types)
-{ interval_set_base_intersect_4_bicremental_types<interval_set, T>();}
+{ interval_set_base_intersect_4_bicremental_types<separate_interval_set, T>();}
+
+BOOST_AUTO_TEST_CASE_TEMPLATE
+(test_itl_interval_set_infix_plus_overload_4_bicremental_types, T, bicremental_types)
+{ interval_set_infix_plus_overload_4_bicremental_types<separate_interval_set, T>();}
+

Modified: sandbox/itl/libs/itl/test/test_split_interval_map/test_split_interval_map.cpp
==============================================================================
--- sandbox/itl/libs/itl/test/test_split_interval_map/test_split_interval_map.cpp (original)
+++ sandbox/itl/libs/itl/test/test_split_interval_map/test_split_interval_map.cpp 2009-01-22 09:01:50 EST (Thu, 22 Jan 2009)
@@ -15,6 +15,8 @@
 #include "../test_type_lists.hpp"
 #include "../test_value_maker.hpp"
 
+#include <boost/itl/separate_interval_set.hpp>
+#include <boost/itl/split_interval_set.hpp>
 #include <boost/itl/split_interval_map.hpp>
 
 using namespace std;

Modified: sandbox/itl/libs/itl/test/test_split_interval_map/test_split_interval_map_shared.cpp
==============================================================================
--- sandbox/itl/libs/itl/test/test_split_interval_map/test_split_interval_map_shared.cpp (original)
+++ sandbox/itl/libs/itl/test/test_split_interval_map/test_split_interval_map_shared.cpp 2009-01-22 09:01:50 EST (Thu, 22 Jan 2009)
@@ -53,3 +53,7 @@
 BOOST_AUTO_TEST_CASE_TEMPLATE
 (test_itl_interval_map_infix_plus_overload_4_bicremental_types, T, bicremental_types)
 { interval_map_infix_plus_overload_4_bicremental_types<split_interval_map, T, int>();}
+
+BOOST_AUTO_TEST_CASE_TEMPLATE
+(test_itl_interval_map_infix_et_overload_4_bicremental_types, T, bicremental_types)
+{ interval_map_infix_et_overload_4_bicremental_types<split_interval_map, T, int>();}

Modified: sandbox/itl/libs/itl/test/test_split_interval_set/test_split_interval_set_shared.cpp
==============================================================================
--- sandbox/itl/libs/itl/test/test_split_interval_set/test_split_interval_set_shared.cpp (original)
+++ sandbox/itl/libs/itl/test/test_split_interval_set/test_split_interval_set_shared.cpp 2009-01-22 09:01:50 EST (Thu, 22 Jan 2009)
@@ -42,3 +42,8 @@
 (test_itl_interval_set_base_intersect_4_bicremental_types, T, bicremental_types)
 { interval_set_base_intersect_4_bicremental_types<split_interval_set, T>();}
 
+BOOST_AUTO_TEST_CASE_TEMPLATE
+(test_itl_interval_set_infix_plus_overload_4_bicremental_types, T, bicremental_types)
+{ interval_set_infix_plus_overload_4_bicremental_types<split_interval_set, T>();}
+
+

Modified: sandbox/itl/libs/itl/test/test_value_maker.hpp
==============================================================================
--- sandbox/itl/libs/itl/test/test_value_maker.hpp (original)
+++ sandbox/itl/libs/itl/test/test_value_maker.hpp 2009-01-22 09:01:50 EST (Thu, 22 Jan 2009)
@@ -101,12 +101,30 @@
         }
 };
 
+// Very short value denotation for intervals
+// Assumption typename T existes in scope
+//I_I : [a,b]
+#define I_I(low,up) itl::interval<T>::closed (make<T>(low), make<T>(up))
+//I_D : [a,b)
+#define I_D(low,up) itl::interval<T>::rightopen(make<T>(low), make<T>(up))
+//C_I : (a,b]
+#define C_I(low,up) itl::interval<T>::leftopen (make<T>(low), make<T>(up))
+//C_D : (a,b)
+#define C_D(low,up) itl::interval<T>::open (make<T>(low), make<T>(up))
+
+#define MK_v(key) make<T>(key)
+
+
+
+// Very short value denotation for interval value pairs
+// Assumption typename IntervalMapT existes in scope
 #define IIv(low,up,val) map_val<IntervalMapT>::val_pair(low,up,val, closed_bounded)
 #define IDv(low,up,val) map_val<IntervalMapT>::val_pair(low,up,val, right_open)
 #define CIv(low,up,val) map_val<IntervalMapT>::val_pair(low,up,val, left_open)
 #define CDv(low,up,val) map_val<IntervalMapT>::val_pair(low,up,val, open_bounded)
 #define K_v(key,val) map_val<IntervalMapT>::map_pair(key,val)
 
+
 }} // namespace boost itl
 
 #endif


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