|
Boost-Commit : |
Subject: [Boost-commit] svn:boost r82291 - in branches/release/libs/icl/test: . ex_boost_party_ test_casual_
From: afojgo_at_[hidden]
Date: 2012-12-30 20:15:41
Author: jofaber
Date: 2012-12-30 20:15:40 EST (Sun, 30 Dec 2012)
New Revision: 82291
URL: http://svn.boost.org/trac/boost/changeset/82291
Log:
Merged changes (81303-82287): Fixed ticket #7231. Switched off move semantics for clang and gcc > 4.6 due to compile problems.
Added:
branches/release/libs/icl/test/ex_boost_party_/
- copied from r82287, /trunk/libs/icl/test/ex_boost_party_/
Properties modified:
branches/release/libs/icl/test/ (props changed)
Text files modified:
branches/release/libs/icl/test/Jamfile.v2 | 3
branches/release/libs/icl/test/test_casual_/test_casual.cpp | 179 +++++++++++++++++++++++++++++++++++++++
branches/release/libs/icl/test/test_interval_map_mixed.hpp | 10 +
branches/release/libs/icl/test/test_interval_map_shared.hpp | 4
branches/release/libs/icl/test/vc10_icl_fast_tests.sln | 6 +
5 files changed, 193 insertions(+), 9 deletions(-)
Modified: branches/release/libs/icl/test/Jamfile.v2
==============================================================================
--- branches/release/libs/icl/test/Jamfile.v2 (original)
+++ branches/release/libs/icl/test/Jamfile.v2 2012-12-30 20:15:40 EST (Sun, 30 Dec 2012)
@@ -78,6 +78,9 @@
[ run cmp_clang_ttp_passing_/cmp_clang_ttp_passing.cpp ]
[ run cmp_clang_ttp_passing2_/cmp_clang_ttp_passing2.cpp ]
+ # Examples ---------------------------------------------------------------
+ [ run ex_boost_party_/ex_boost_party.cpp ]
+
# Ad hoc -----------------------------------------------------------------
#[ run test_casual_/test_casual.cpp ]
Modified: branches/release/libs/icl/test/test_casual_/test_casual.cpp
==============================================================================
--- branches/release/libs/icl/test/test_casual_/test_casual.cpp (original)
+++ branches/release/libs/icl/test/test_casual_/test_casual.cpp 2012-12-30 20:15:40 EST (Sun, 30 Dec 2012)
@@ -32,7 +32,44 @@
#include <boost/icl/interval_set.hpp>
#include <boost/icl/interval.hpp>
-#include <boost/scoped_ptr.hpp>
+
+namespace my
+{
+
+class Tag
+{
+public:
+ Tag():_val(0){}
+ Tag(int val):_val(val){}
+ int val()const { return _val; }
+
+ Tag& operator += (const Tag& rhs){ return *this; }
+ Tag& operator -= (const Tag& rhs){ if(_val == rhs.val()) _val=0; return *this; }
+ Tag& operator &= (const Tag& rhs){ if(_val != rhs.val()) _val=0; return *this; }
+
+private:
+ int _val;
+};
+
+bool operator == (const Tag& lhs, const Tag& rhs){ return lhs.val() == rhs.val(); }
+bool operator < (const Tag& lhs, const Tag& rhs){ return lhs.val() < rhs.val(); }
+
+template<class CharType, class CharTraits>
+std::basic_ostream<CharType, CharTraits> &operator<<
+ (std::basic_ostream<CharType, CharTraits> &stream, Tag const& value)
+{
+ return stream << value.val();
+}
+
+} // namespace my
+
+namespace boost{ namespace icl{
+ template<> struct is_set<my::Tag>
+ {
+ typedef is_set type;
+ BOOST_STATIC_CONSTANT(bool, value = true);
+ };
+}} // namespace icl boost
using namespace std;
using namespace boost;
@@ -40,18 +77,152 @@
using namespace boost::icl;
-BOOST_AUTO_TEST_CASE(casual)
+BOOST_AUTO_TEST_CASE(CacheSegments)
{
+ using namespace my;
+
typedef int T;
typedef int U;
typedef interval_map<T,U, partial_absorber> IntervalMapT;
typedef interval_set<T> IntervalSetT;
typedef IntervalMapT::interval_type IntervalT;
- IntervalSetT is = IntervalSetT(I_I(1,1)) + IntervalSetT(I_I(3,3));
+ typedef interval_map<int, Tag> InsMapT;
+ InsMapT imap;
- cout << is << endl;
+ imap += make_pair(interval<int>::right_open( 0, 8), Tag(1));
+ imap += make_pair(interval<int>::right_open( 8,16), Tag(2));
+ imap += make_pair(interval<int>::right_open(16,18), Tag(1));
+ imap += make_pair(interval<int>::right_open(17,20), Tag(2));
+ cout << imap << endl;
+
+ //imap -= make_pair(interval<int>::right_open( 4,20), Tag(1)); //drop_if(1)
+ imap &= make_pair(interval<int>::right_open( 4,20), Tag(1)); //keep_if(1)
+ cout << imap << endl;
BOOST_CHECK_EQUAL(true, true);
}
+BOOST_AUTO_TEST_CASE(casual)
+{
+ typedef int T;
+ typedef int U;
+ typedef interval_map<T,U, partial_absorber> IntervalMapT;
+ typedef interval_set<T> IntervalSetT;
+ typedef IntervalMapT::interval_type IntervalT;
+
+
+ BOOST_CHECK_EQUAL(true, true);
+}
+
+
+#include <boost/chrono.hpp>
+
+typedef chrono::time_point<chrono::system_clock> time_point;
+typedef icl::interval_map<time_point, int> IntervalMap;
+typedef IntervalMap::interval_type Interval;
+
+template<class D, class C>
+void add_closed(icl::interval_map<D,std::set<C>>& im, D low, D up, C data)
+{
+ typedef typename icl::interval_map<D,std::set<C>> IntervalMap;
+ typedef typename IntervalMap::interval_type Interval;
+ std::set<C> single;
+ single.insert(std::move(data));
+ im += make_pair(Interval::closed(low, up), single);
+}
+
+void icl_and_chrono()
+{
+ typedef chrono::time_point<chrono::system_clock> time_point;
+ typedef icl::interval_map<time_point, std::set<int> > IntervalMap;
+
+ IntervalMap im;
+ auto now = chrono::system_clock::now();
+
+ add_closed(im, now, now + chrono::seconds(10), 42);
+ add_closed(im, now + chrono::seconds(5), now + chrono::seconds(15), 24);
+ cout << im << endl;
+}
+
+void icl_chrono_101()
+{
+ typedef chrono::time_point<chrono::system_clock> time_point;
+ typedef icl::interval_map<time_point, int> IntervalMap;
+ typedef IntervalMap::interval_type Interval;
+
+ IntervalMap im;
+ auto now = chrono::system_clock::now();
+ im += make_pair(Interval::closed(now, now + chrono::seconds(10)), 42);
+ icl::discrete_interval<time_point> itv2
+ = Interval::closed(now + chrono::seconds(5), now + chrono::seconds(15));
+ im += make_pair(itv2, 24);
+
+ cout << im << endl;
+}
+
+BOOST_AUTO_TEST_CASE(chrono_101)
+{
+ icl_and_chrono();
+}
+
+
+template <typename Domain, typename Codomain>
+class interval_map2
+{
+public:
+ void add_closed(Domain lower, Domain upper, Codomain data)
+ {
+ set_type set;
+ set.insert(std::move(data));
+ map_ += std::make_pair(interval_type::closed(lower, upper), set);
+ }
+
+private:
+ typedef std::set<Codomain> set_type;
+ typedef boost::icl::discrete_interval<Domain> interval_type;
+ typedef boost::icl::interval_map<Domain, set_type> map_type;
+
+ map_type map_;
+};
+
+BOOST_AUTO_TEST_CASE(chrono_102)
+{
+ typedef chrono::time_point<chrono::system_clock> time_point;
+ interval_map2<time_point, int> im;
+ auto now = chrono::system_clock::now();
+ im.add_closed(now, now + chrono::seconds(10), 42);
+
+}
+
+//--------------------------------------
+BOOST_AUTO_TEST_CASE(hudel)
+{
+ typedef int Time;
+ icl::interval_set<Time> _badMonths;
+ std::vector<int> badMonths;
+ badMonths.push_back(2);
+ badMonths.push_back(6);
+ badMonths.push_back(9);
+
+ for(int m : badMonths)
+ {
+ icl::interval<Time>::type month(m, m+2);
+ _badMonths.insert(month);
+ }
+
+ Time timepoint = 7;
+ if ( icl::contains(_badMonths, timepoint) )
+ std::cout << timepoint << " intersects bad months" << std::endl;
+ if ( icl::within(timepoint, _badMonths) )
+ std::cout << timepoint << " intersects bad months" << std::endl;
+ if ( icl::intersects(_badMonths, timepoint) )
+ std::cout << timepoint << " intersects bad months" << std::endl;
+ if ( _badMonths.find(timepoint) != _badMonths.end() )
+ std::cout << timepoint << " intersects bad months" << std::endl;
+ if ( !icl::is_empty(_badMonths & timepoint) )
+ std::cout << timepoint << " intersects bad months" << std::endl;
+ if ( !(_badMonths &= timepoint).empty() )
+ std::cout << timepoint << " intersects bad months" << std::endl;
+}
+
Modified: branches/release/libs/icl/test/test_interval_map_mixed.hpp
==============================================================================
--- branches/release/libs/icl/test/test_interval_map_mixed.hpp (original)
+++ branches/release/libs/icl/test/test_interval_map_mixed.hpp 2012-12-30 20:15:40 EST (Sun, 30 Dec 2012)
@@ -22,7 +22,9 @@
T v0 = boost::icl::identity_element<T>::value();
U u1 = unit_element<U>::value();
- SplitIntervalMapT split_map(make_pair(v0,u1));
+ SplitIntervalMapT split_map(mapping_pair<T,U>(v0,u1));
+ //JODO: clang err: ctor ambiguous. Should compile
+ //JODO CLANG SplitIntervalMapT split_map(make_pair(v0,u1));
IntervalMapT join_map(split_map);
BOOST_CHECK_EQUAL( hull(split_map).lower(), hull(join_map).lower() );
@@ -39,8 +41,10 @@
T v0 = boost::icl::identity_element<T>::value();
U u1 = unit_element<U>::value();
- SplitIntervalMapT split_empty, split_single(make_pair(v0,u1));
- IntervalMapT join_empty, join_single(make_pair(v0,u1));
+ SplitIntervalMapT split_empty, split_single(mapping_pair<T,U>(v0,u1));
+ IntervalMapT join_empty, join_single(mapping_pair<T,U>(v0,u1));
+ //JODO CLANG SplitIntervalMapT split_empty, split_single(make_pair(v0,u1));
+ //JODO CLANG IntervalMapT join_empty, join_single(make_pair(v0,u1));
// mixed ==-equality is a strange thing. Most times is does not
// make sense. It is better to allow only for same type == equality.
Modified: branches/release/libs/icl/test/test_interval_map_shared.hpp
==============================================================================
--- branches/release/libs/icl/test/test_interval_map_shared.hpp (original)
+++ branches/release/libs/icl/test/test_interval_map_shared.hpp 2012-12-30 20:15:40 EST (Sun, 30 Dec 2012)
@@ -1527,7 +1527,7 @@
>
void interval_map_move_4_discrete_types()
{
-# ifndef BOOST_NO_RVALUE_REFERENCES
+# ifndef BOOST_NO_CXX11_RVALUE_REFERENCES
typedef IntervalMap<T,U> IntervalMapT;
typedef typename IntervalMapT::interval_type IntervalT;
@@ -1543,7 +1543,7 @@
BOOST_CHECK( icl::is_element_equal(map_A, map_B) );
BOOST_CHECK_EQUAL( map_A, join(map_B) );
-# endif // BOOST_NO_RVALUE_REFERENCES
+# endif // BOOST_NO_CXX11_RVALUE_REFERENCES
}
Modified: branches/release/libs/icl/test/vc10_icl_fast_tests.sln
==============================================================================
--- branches/release/libs/icl/test/vc10_icl_fast_tests.sln (original)
+++ branches/release/libs/icl/test/vc10_icl_fast_tests.sln 2012-12-30 20:15:40 EST (Sun, 30 Dec 2012)
@@ -67,6 +67,8 @@
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "vc10_test_casual", "test_casual_\vc10_test_casual.vcxproj", "{EE61B7EF-EC45-4165-8B49-FD5B8D3A9FA0}"
EndProject
+Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "vc10_ex_boost_party", "ex_boost_party_\vc10_ex_boost_party.vcxproj", "{EE61B7EF-EC45-4165-EC01-FD5B8D5A9FA0}"
+EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Win32 = Debug|Win32
@@ -205,6 +207,10 @@
{EE61B7EF-EC45-4165-8B49-FD5B8D3A9FA0}.Debug|Win32.Build.0 = Debug|Win32
{EE61B7EF-EC45-4165-8B49-FD5B8D3A9FA0}.Release|Win32.ActiveCfg = Release|Win32
{EE61B7EF-EC45-4165-8B49-FD5B8D3A9FA0}.Release|Win32.Build.0 = Release|Win32
+ {EE61B7EF-EC45-4165-EC01-FD5B8D5A9FA0}.Debug|Win32.ActiveCfg = Debug|Win32
+ {EE61B7EF-EC45-4165-EC01-FD5B8D5A9FA0}.Debug|Win32.Build.0 = Debug|Win32
+ {EE61B7EF-EC45-4165-EC01-FD5B8D5A9FA0}.Release|Win32.ActiveCfg = Release|Win32
+ {EE61B7EF-EC45-4165-EC01-FD5B8D5A9FA0}.Release|Win32.Build.0 = Release|Win32
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
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