| 1 | /*-----------------------------------------------------------------------------+ |
| 2 | Copyright (c) 2008-2009: Joachim Faulhaber |
| 3 | +------------------------------------------------------------------------------+ |
| 4 | Distributed under the Boost Software License, Version 1.0. |
| 5 | (See accompanying file LICENCE.txt or copy at |
| 6 | http://www.boost.org/LICENSE_1_0.txt) |
| 7 | +-----------------------------------------------------------------------------*/ |
| 8 | #define BOOST_TEST_MODULE icl::casual unit test |
| 9 | |
| 10 | #define BOOST_ICL_TEST_CHRONO |
| 11 | |
| 12 | #include <libs/icl/test/disable_test_warnings.hpp> |
| 13 | |
| 14 | #include <string> |
| 15 | #include <vector> |
| 16 | #include <boost/mpl/list.hpp> |
| 17 | #include "../unit_test_unwarned.hpp" |
| 18 | |
| 19 | |
| 20 | // interval instance types |
| 21 | #include "../test_type_lists.hpp" |
| 22 | #include "../test_value_maker.hpp" |
| 23 | |
| 24 | #include <boost/rational.hpp> |
| 25 | |
| 26 | #include <boost/type_traits/is_same.hpp> |
| 27 | |
| 28 | #include <boost/icl/gregorian.hpp> |
| 29 | #include <boost/icl/ptime.hpp> |
| 30 | |
| 31 | #include <boost/icl/interval_map.hpp> |
| 32 | #include <boost/icl/interval_set.hpp> |
| 33 | #include <boost/icl/interval.hpp> |
| 34 | |
| 35 | |
| 36 | |
| 37 | namespace my |
| 38 | { |
| 39 | |
| 40 | class Spy |
| 41 | { |
| 42 | public: |
| 43 | Spy():_val(0){ |
| 44 | std::cout << "Spy() " ; |
| 45 | } |
| 46 | Spy(int val):_val(val){} |
| 47 | int val()const { return _val; } |
| 48 | |
| 49 | Spy& operator += (const Spy& rhs){ |
| 50 | std::cout << "+= " ; |
| 51 | return *this; |
| 52 | } |
| 53 | Spy& operator -= (const Spy& rhs){ if(_val == rhs.val()) _val=0; return *this; } |
| 54 | Spy& operator &= (const Spy& rhs){ if(_val != rhs.val()) _val=0; return *this; } |
| 55 | |
| 56 | private: |
| 57 | int _val; |
| 58 | }; |
| 59 | |
| 60 | bool operator == (const Spy& lhs, const Spy& rhs){ return lhs.val() == rhs.val(); } |
| 61 | bool operator < (const Spy& lhs, const Spy& rhs){ return lhs.val() < rhs.val(); } |
| 62 | |
| 63 | template<class CharType, class CharTraits> |
| 64 | std::basic_ostream<CharType, CharTraits> &operator<< |
| 65 | (std::basic_ostream<CharType, CharTraits> &stream, Spy const& value) |
| 66 | { |
| 67 | return stream << value.val(); |
| 68 | } |
| 69 | |
| 70 | } // namespace my |
| 71 | |
| 72 | |
| 73 | |
| 74 | |
| 75 | using namespace std; |
| 76 | using namespace boost; |
| 77 | using namespace unit_test; |
| 78 | using namespace boost::icl; |
| 79 | |
| 80 | BOOST_AUTO_TEST_CASE(casual) |
| 81 | { |
| 82 | using namespace my; |
| 83 | |
| 84 | |
| 85 | typedef interval_map<int, Spy> SpyMapT; |
| 86 | SpyMapT imap; |
| 87 | |
| 88 | //imap += make_pair(interval<int>::right_open( 0, 8), Spy(1)); |
| 89 | |
| 90 | imap.add(prior_: imap.begin(), interval_value_pair: make_pair(x: interval<int>::right_open( low: 0, up: 8), y: Spy(1))); |
| 91 | |
| 92 | BOOST_CHECK_EQUAL(true, true); |
| 93 | } |
| 94 | |
| 95 | |
| 96 | |