test_casual.cpp 2.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495
  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. #define BOOST_ICL_TEST_CHRONO
  10. #include <libs/icl/test/disable_test_warnings.hpp>
  11. #include <string>
  12. #include <vector>
  13. #include <boost/mpl/list.hpp>
  14. #include "../unit_test_unwarned.hpp"
  15. // interval instance types
  16. #include "../test_type_lists.hpp"
  17. #include "../test_value_maker.hpp"
  18. #include <boost/rational.hpp>
  19. #include <boost/type_traits/is_same.hpp>
  20. #include <boost/icl/gregorian.hpp>
  21. #include <boost/icl/ptime.hpp>
  22. #include <boost/icl/interval_map.hpp>
  23. #include <boost/icl/interval_set.hpp>
  24. #include <boost/icl/interval.hpp>
  25. namespace my
  26. {
  27. class Spy
  28. {
  29. public:
  30. Spy():_val(0){
  31. std::cout << "Spy() ";
  32. }
  33. Spy(int val):_val(val){}
  34. int val()const { return _val; }
  35. Spy& operator += (const Spy& rhs){
  36. std::cout << "+= ";
  37. return *this;
  38. }
  39. Spy& operator -= (const Spy& rhs){ if(_val == rhs.val()) _val=0; return *this; }
  40. Spy& operator &= (const Spy& rhs){ if(_val != rhs.val()) _val=0; return *this; }
  41. private:
  42. int _val;
  43. };
  44. bool operator == (const Spy& lhs, const Spy& rhs){ return lhs.val() == rhs.val(); }
  45. bool operator < (const Spy& lhs, const Spy& rhs){ return lhs.val() < rhs.val(); }
  46. template<class CharType, class CharTraits>
  47. std::basic_ostream<CharType, CharTraits> &operator<<
  48. (std::basic_ostream<CharType, CharTraits> &stream, Spy const& value)
  49. {
  50. return stream << value.val();
  51. }
  52. } // namespace my
  53. using namespace std;
  54. using namespace boost;
  55. using namespace unit_test;
  56. using namespace boost::icl;
  57. BOOST_AUTO_TEST_CASE(casual)
  58. {
  59. using namespace my;
  60. typedef interval_map<int, Spy> SpyMapT;
  61. SpyMapT imap;
  62. //imap += make_pair(interval<int>::right_open( 0, 8), Spy(1));
  63. imap.add(imap.begin(), make_pair(interval<int>::right_open( 0, 8), Spy(1)));
  64. BOOST_CHECK_EQUAL(true, true);
  65. }