Boost logo

Boost-Commit :

Subject: [Boost-commit] svn:boost r69489 - in trunk: boost/icl/concept libs/icl/doc libs/icl/test
From: afojgo_at_[hidden]
Date: 2011-03-02 16:18:28


Author: jofaber
Date: 2011-03-02 16:18:25 EST (Wed, 02 Mar 2011)
New Revision: 69489
URL: http://svn.boost.org/trac/boost/changeset/69489

Log:
More tests and some documentation fixes.
Text files modified:
   trunk/boost/icl/concept/interval_associator_base.hpp | 8 ++++
   trunk/libs/icl/doc/icl.qbk | 2
   trunk/libs/icl/test/fast_stat_interval_map_cases.hpp | 6 ++
   trunk/libs/icl/test/fastest_interval_map_cases.hpp | 8 ++++
   trunk/libs/icl/test/test_interval_map_cases.hpp | 9 ++++
   trunk/libs/icl/test/test_interval_map_shared.hpp | 80 ++++++++++++++++++++++++++++++++-------
   trunk/libs/icl/test/test_interval_set_shared.hpp | 26 +++++++++++++
   7 files changed, 122 insertions(+), 17 deletions(-)

Modified: trunk/boost/icl/concept/interval_associator_base.hpp
==============================================================================
--- trunk/boost/icl/concept/interval_associator_base.hpp (original)
+++ trunk/boost/icl/concept/interval_associator_base.hpp 2011-03-02 16:18:25 EST (Wed, 02 Mar 2011)
@@ -91,6 +91,14 @@
 // NOTE: find(object, key) won't compile if key is of continuous type that does
 // not implement in(de)crementation (e.g. std::string).
 
+template<class Type>
+typename enable_if< is_interval_container<Type>
+ , typename Type::const_iterator>::type
+find(const Type& object, const typename interval_type_of<Type>::type& inter_val)
+{
+ return object.find(inter_val);
+}
+
 //==============================================================================
 //= Morphisms
 //==============================================================================

Modified: trunk/libs/icl/doc/icl.qbk
==============================================================================
--- trunk/libs/icl/doc/icl.qbk (original)
+++ trunk/libs/icl/doc/icl.qbk 2011-03-02 16:18:25 EST (Wed, 02 Mar 2011)
@@ -26,7 +26,7 @@
 [def __Itv_tr__ [classref boost::icl::interval_traits Interval_traits]]
 
 [def __ro_itv__ [classref boost::icl::right_open_interval right_open_interval]]
-[def __lo_itv__ [classref boost::icl::right_open_interval left_open_interval]]
+[def __lo_itv__ [classref boost::icl::left_open_interval left_open_interval]]
 [def __op_itv__ [classref boost::icl::open_interval open_interval]]
 [def __cl_itv__ [classref boost::icl::closed_interval closed_interval]]
 

Modified: trunk/libs/icl/test/fast_stat_interval_map_cases.hpp
==============================================================================
--- trunk/libs/icl/test/fast_stat_interval_map_cases.hpp (original)
+++ trunk/libs/icl/test/fast_stat_interval_map_cases.hpp 2011-03-02 16:18:25 EST (Wed, 02 Mar 2011)
@@ -50,13 +50,17 @@
 
 BOOST_AUTO_TEST_CASE
 (fastest_icl_interval_map_find_4_bicremental_types)
-{ interval_map_find_4_bicremental_types<INTERVAL_MAP, bicremental_type_2, int>();}
+{ interval_map_find_4_bicremental_types<INTERVAL_MAP, discrete_type_1, int>();}
 
 BOOST_AUTO_TEST_CASE
 (fastest_icl_interval_map_find_4_numeric_continuous_types)
 { interval_map_find_4_numeric_continuous_types<INTERVAL_MAP, numeric_continuous_type_1, int>();}
 
 BOOST_AUTO_TEST_CASE
+(fastest_icl_interval_map_range_4_bicremental_types)
+{ interval_map_range_4_bicremental_types<INTERVAL_MAP, discrete_type_2, int>();}
+
+BOOST_AUTO_TEST_CASE
 (fastest_icl_interval_map_set_4_bicremental_types)
 { interval_map_set_4_bicremental_types<INTERVAL_MAP, discrete_type_3, int>();}
 

Modified: trunk/libs/icl/test/fastest_interval_map_cases.hpp
==============================================================================
--- trunk/libs/icl/test/fastest_interval_map_cases.hpp (original)
+++ trunk/libs/icl/test/fastest_interval_map_cases.hpp 2011-03-02 16:18:25 EST (Wed, 02 Mar 2011)
@@ -65,6 +65,14 @@
 { interval_map_find_4_bicremental_types<INTERVAL_MAP, bicremental_type_2, double>();}
 
 BOOST_AUTO_TEST_CASE
+(fastest_icl_interval_map_find_4_numeric_continuous_types)
+{ interval_map_find_4_numeric_continuous_types<INTERVAL_MAP, numeric_continuous_type_1, int>();}
+
+BOOST_AUTO_TEST_CASE
+(fastest_icl_interval_map_range_4_bicremental_types)
+{ interval_map_range_4_bicremental_types<INTERVAL_MAP, bicremental_type_2, double>();}
+
+BOOST_AUTO_TEST_CASE
 (fastest_icl_interval_map_set_4_bicremental_types)
 { interval_map_set_4_bicremental_types<INTERVAL_MAP, bicremental_type_3, int>();}
 

Modified: trunk/libs/icl/test/test_interval_map_cases.hpp
==============================================================================
--- trunk/libs/icl/test/test_interval_map_cases.hpp (original)
+++ trunk/libs/icl/test/test_interval_map_cases.hpp 2011-03-02 16:18:25 EST (Wed, 02 Mar 2011)
@@ -59,11 +59,20 @@
 BOOST_AUTO_TEST_CASE_TEMPLATE
 (test_icl_interval_map_flip_4_bicremental_types, T, bicremental_types)
 { interval_map_flip_4_bicremental_types<INTERVAL_MAP, T, int>();}
+
 BOOST_AUTO_TEST_CASE_TEMPLATE
 (test_icl_interval_map_find_4_bicremental_types, T, bicremental_types)
 { interval_map_find_4_bicremental_types<INTERVAL_MAP, T, int>();}
 
 BOOST_AUTO_TEST_CASE_TEMPLATE
+(test_icl_interval_map_find_4_numeric_continuous_types, T, numeric_continuous_types)
+{ interval_map_find_4_numeric_continuous_types<INTERVAL_MAP, T, int>();}
+
+BOOST_AUTO_TEST_CASE_TEMPLATE
+(test_icl_interval_map_range_4_bicremental_types, T, bicremental_types)
+{ interval_map_range_4_bicremental_types<INTERVAL_MAP, T, int>();}
+
+BOOST_AUTO_TEST_CASE_TEMPLATE
 (test_icl_interval_map_set_4_bicremental_types, T, bicremental_types)
 { interval_map_set_4_bicremental_types<INTERVAL_MAP, T, int>();}
 

Modified: trunk/libs/icl/test/test_interval_map_shared.hpp
==============================================================================
--- trunk/libs/icl/test/test_interval_map_shared.hpp (original)
+++ trunk/libs/icl/test/test_interval_map_shared.hpp 2011-03-02 16:18:25 EST (Wed, 02 Mar 2011)
@@ -219,8 +219,16 @@
         BOOST_CHECK_EQUAL( hull(_I4_4I_u2).lower(), v4 );
         BOOST_CHECK_EQUAL( hull(_I4_4I_u2).upper(), v4 );
     }
- BOOST_CHECK_EQUAL( icl::first(hull(_I4_4I_u2)), v4 );
- BOOST_CHECK_EQUAL( icl::last(hull(_I4_4I_u2)), v4 );
+
+ if(is_discrete<T>::value)
+ {
+ if(is_same<float, T>::value)
+ {
+ BOOST_CHECK( false );
+ }
+ //BOOST_CHECK_EQUAL( icl::first(hull(_I4_4I_u2)), v4 );
+ //BOOST_CHECK_EQUAL( icl::last(hull(_I4_4I_u2)), v4 );
+ }
 
     IntervalMapT _I4_4I_u2_copy(_I4_4I_u2);
     IntervalMapT _I4_4I_u2_assigned;
@@ -1157,20 +1165,20 @@
     BOOST_CHECK_EQUAL( map_a(MK_v(8)), MK_u(4) );
 
     //LAW map c; key k: k in dom(c) => contains(c, (k, find(c, k)->second))
- BOOST_CHECK( icl::contains(map_a, K_v(2, icl::find(map_a, 2)->second)) );
- BOOST_CHECK( icl::contains(map_a, K_v(11, map_a.find(11)->second)) );
+ BOOST_CHECK( icl::contains(map_a, K_v(2, icl::find(map_a, MK_v(2))->second)) );
+ BOOST_CHECK( icl::contains(map_a, K_v(11, map_a.find(MK_v(11))->second)) );
+
+ BOOST_CHECK( icl::contains(map_a, MK_v(2)) );
+ BOOST_CHECK( icl::contains(map_a, MK_v(10)) );
+ BOOST_CHECK( !icl::contains(map_a, MK_v(1)) );
+ BOOST_CHECK( !icl::contains(map_a, MK_v(3)) );
+ BOOST_CHECK( !icl::contains(map_a, MK_v(12)) );
 
- BOOST_CHECK( icl::contains(map_a, 2) );
- BOOST_CHECK( icl::contains(map_a, 10) );
- BOOST_CHECK( !icl::contains(map_a, 1) );
- BOOST_CHECK( !icl::contains(map_a, 3) );
- BOOST_CHECK( !icl::contains(map_a, 12) );
-
- BOOST_CHECK( icl::intersects(map_a, 2) );
- BOOST_CHECK( icl::intersects(map_a, 10) );
- BOOST_CHECK( !icl::intersects(map_a, 1) );
- BOOST_CHECK( !icl::intersects(map_a, 3) );
- BOOST_CHECK( !icl::intersects(map_a, 12) );
+ BOOST_CHECK( icl::intersects(map_a, MK_v(2)) );
+ BOOST_CHECK( icl::intersects(map_a, MK_v(10)) );
+ BOOST_CHECK( !icl::intersects(map_a, MK_v(1)) );
+ BOOST_CHECK( !icl::intersects(map_a, MK_v(3)) );
+ BOOST_CHECK( !icl::intersects(map_a, MK_v(12)) );
 }
 
 
@@ -1247,6 +1255,48 @@
 #endif
     class T, class U
>
+void interval_map_range_4_bicremental_types()
+{
+ typedef IntervalMap<T,U> IntervalMapT;
+ typedef typename IntervalMapT::interval_type IntervalT;
+ typedef typename IntervalMapT::const_iterator c_iterator;
+
+ typename IntervalMapT::interval_mapping_type val_pair1 = IDv(6,9,1);
+ std::pair<const IntervalT, U> val_pair2 = IDv(3,5,3);
+ mapping_pair<T,U> map_pair = K_v(4,3);
+
+ IntervalMapT map_a;
+ map_a.add(CDv(1,3,1)).add(IDv(8,9,1)).add(IIv(6,11,3));
+ // {(1 3) [6 8)[8 9)[9 11)
+ // 1 3 4 3
+ // [2 7) := itv
+
+ IntervalT itv = I_D(2, 7);
+ c_iterator lwb1 = icl::find(map_a, itv);
+ c_iterator lwb2 = map_a.lower_bound(itv);
+
+ BOOST_CHECK ( lwb1 == lwb2 );
+ BOOST_CHECK_EQUAL( lwb1->second, lwb2->second );
+ BOOST_CHECK_EQUAL( lwb1->second, MK_u(1) );
+
+ c_iterator upb1 = map_a.upper_bound(itv);
+ BOOST_CHECK_EQUAL( upb1->second, MK_u(4) );
+
+ std::pair<c_iterator,c_iterator> exterior = map_a.equal_range(itv);
+ BOOST_CHECK ( lwb1 == exterior.first );
+ BOOST_CHECK ( upb1 == exterior.second );
+}
+
+
+template
+<
+#if (defined(__GNUC__) && (__GNUC__ < 4)) //MEMO Can be simplified, if gcc-3.4 is obsolete
+ ICL_IntervalMap_TEMPLATE(T,U,Traits,partial_absorber) IntervalMap,
+#else
+ ICL_IntervalMap_TEMPLATE(_T,_U,Traits,partial_absorber) IntervalMap,
+#endif
+ class T, class U
+>
 void interval_map_set_4_bicremental_types()
 {
     typedef IntervalMap<T,U> IntervalMapT;

Modified: trunk/libs/icl/test/test_interval_set_shared.hpp
==============================================================================
--- trunk/libs/icl/test/test_interval_set_shared.hpp (original)
+++ trunk/libs/icl/test/test_interval_set_shared.hpp 2011-03-02 16:18:25 EST (Wed, 02 Mar 2011)
@@ -662,6 +662,7 @@
 {
     typedef IntervalSet<T> IntervalSetT;
     typedef typename IntervalSetT::interval_type IntervalT;
+ typedef typename IntervalSetT::const_iterator c_iterator;
 
     IntervalT itv = I_D(3,5);
 
@@ -675,6 +676,31 @@
     found = set_a.find(MK_v(5));
 
     BOOST_CHECK_EQUAL( found == set_a.end(), true );
+
+ c_iterator found1 = set_a.find(MK_v(6));
+ c_iterator found2 = icl::find(set_a, MK_v(6));
+
+ BOOST_CHECK ( found1 == found2 );
+ BOOST_CHECK_EQUAL( *found1, *found2 );
+ BOOST_CHECK_EQUAL( *found1, I_I(6,11) );
+
+ found1 = set_a.find(MK_v(5));
+
+ BOOST_CHECK_EQUAL( found1 == set_a.end(), true );
+
+ //LAW map c; key k: k in dom(c) => contains(c, *find(c, k))
+ BOOST_CHECK( icl::contains(set_a, *icl::find(set_a, MK_v(2))) );
+ BOOST_CHECK( icl::contains(set_a, *set_a.find(MK_v(11))) );
+
+ BOOST_CHECK( icl::contains(set_a, MK_v(2)) );
+ BOOST_CHECK( icl::contains(set_a, MK_v(10)) );
+ BOOST_CHECK( !icl::contains(set_a, MK_v(1)) );
+ BOOST_CHECK( !icl::contains(set_a, MK_v(3)) );
+
+ BOOST_CHECK( icl::intersects(set_a, MK_v(2)) );
+ BOOST_CHECK( icl::intersects(set_a, MK_v(10)) );
+ BOOST_CHECK( !icl::intersects(set_a, MK_v(1)) );
+ BOOST_CHECK( !icl::intersects(set_a, MK_v(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