test_icl_discrete_interval.hpp 5.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798
  1. /*-----------------------------------------------------------------------------+
  2. Copyright (c) 2008-2010: 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. #ifndef BOOST_ICL_TEST_ICL_DISCRETE_INTERVAL_HPP_JOFA_100930
  9. #define BOOST_ICL_TEST_ICL_DISCRETE_INTERVAL_HPP_JOFA_100930
  10. template <class T, class IntervalT>
  11. void discrete_interval_traits()
  12. {
  13. BOOST_CHECK( is_interval<IntervalT>::value );
  14. BOOST_CHECK( is_discrete_interval<IntervalT>::value );
  15. BOOST_CHECK( is_discrete<typename IntervalT::domain_type>::value );
  16. BOOST_CHECK(!is_continuous<typename IntervalT::domain_type>::value);
  17. BOOST_CHECK( has_dynamic_bounds<IntervalT>::value );
  18. BOOST_CHECK(!has_static_bounds<IntervalT>::value );
  19. }
  20. template <class T, class IntervalT>
  21. void discrete_interval_ctor__dis_4_dyn_v_sta() // discrete && (dynamic or static)
  22. {
  23. BOOST_CHECK_EQUAL( IntervalT(MK_v(3)), IntervalT(MK_v(3)) );
  24. BOOST_CHECK_EQUAL( icl::contains(IntervalT(MK_v(1)), MK_v(1)), true );
  25. }
  26. template <class T, ICL_COMPARE Compare>
  27. void distant_intervals_4_discrete_types()
  28. {
  29. typedef right_open_interval<T,Compare> L__D; // L__D for [..)
  30. typedef left_open_interval<T,Compare> C__I; // C__I for (..]
  31. typedef closed_interval<T,Compare> L__I; // L__I for [..]
  32. typedef open_interval<T,Compare> C__D; // C__D for (..)
  33. typedef typename icl::interval<T,Compare>::type IntervalT;
  34. BOOST_CHECK( is_interval<L__D>::value );
  35. BOOST_CHECK( has_difference<typename interval_traits<L__D>::domain_type>::value );
  36. BOOST_CHECK( is_discrete<typename interval_traits<L__D>::domain_type>::value );
  37. BOOST_CHECK( (boost::is_same<typename interval_traits<L__D>::domain_type, T>::value) );
  38. test_inner_complement<T,Compare,L__D>(MK_I(L__D,0,4), MK_I(L__D,8,9));
  39. test_inner_complement<T,Compare,L__D>(MK_I(L__D,7,8), MK_I(L__D,2,3));
  40. test_inner_complement<T,Compare,L__D>(MK_I(L__D,2,4), MK_I(L__D,4,6));
  41. test_inner_complement<T,Compare,L__D>(MK_I(L__D,3,7), MK_I(L__D,5,8));
  42. test_inner_complement<T,Compare,L__D>(MK_I(L__D,7,9), MK_I(L__D,0,4));
  43. test_inner_complement<T,Compare,L__D>(MK_I(L__D,0,0), MK_I(L__D,0,0));
  44. test_inner_complement<T,Compare,L__D>(MK_I(L__D,1,0), MK_I(L__D,2,0));
  45. test_inner_complement<T,Compare,C__I>(MK_I(C__I,1,5), MK_I(C__I,4,9));
  46. test_inner_complement<T,Compare,C__I>(MK_I(C__I,4,6), MK_I(C__I,1,3));
  47. test_inner_complement<T,Compare,C__I>(MK_I(C__I,0,2), MK_I(C__I,4,6));
  48. test_inner_complement<T,Compare,C__I>(MK_I(C__I,0,2), MK_I(C__I,0,6));
  49. test_inner_complement<T,Compare,L__I>(MK_I(L__I,7,9), MK_I(L__I,0,5));
  50. test_inner_complement<T,Compare,L__I>(MK_I(L__I,0,9), MK_I(L__I,2,5));
  51. test_inner_complement<T,Compare,C__D>(MK_I(C__D,6,9), MK_I(C__D,1,4));
  52. test_inner_complement<T,Compare,C__D>(MK_I(C__D,1,3), MK_I(C__D,1,4));
  53. test_inner_complement<T,Compare,C__D>(MK_I(C__D,1,3), MK_I(C__D,6,8));
  54. test_inner_complement<T,Compare,C__D>(MK_I(C__D,1,7), MK_I(C__D,1,6));
  55. test_inner_complement<T,Compare,C__D>(MK_I(C__D,1,1), MK_I(C__D,1,1));
  56. test_inner_complement<T,Compare,C__D>(MK_I(C__D,3,0), MK_I(C__D,4,0));
  57. test_inner_complement<T,Compare,C__D>(MK_I(C__D,0,2), MK_I(C__D,4,6));
  58. test_inner_complement<T,Compare,C__D>(MK_I(C__D,0,2), MK_I(C__D,0,6));
  59. //--------------------------------------------------------------------------
  60. test_inner_complement<T,Compare,IntervalT>(I_D(0,4), I_D(8,9));
  61. test_inner_complement<T,Compare,IntervalT>(I_D(7,8), I_D(2,3));
  62. test_inner_complement<T,Compare,IntervalT>(I_D(2,4), I_D(4,6));
  63. test_inner_complement<T,Compare,IntervalT>(I_D(3,7), I_D(5,8));
  64. test_inner_complement<T,Compare,IntervalT>(I_D(7,9), I_D(0,4));
  65. test_inner_complement<T,Compare,IntervalT>(I_D(0,0), I_D(0,0));
  66. test_inner_complement<T,Compare,IntervalT>(I_D(1,0), I_D(2,0));
  67. test_inner_complement<T,Compare,IntervalT>(C_I(1,5), C_I(4,9));
  68. test_inner_complement<T,Compare,IntervalT>(C_I(4,6), C_I(1,3));
  69. test_inner_complement<T,Compare,IntervalT>(C_I(0,2), C_I(4,6));
  70. test_inner_complement<T,Compare,IntervalT>(C_I(0,2), C_I(0,6));
  71. test_inner_complement<T,Compare,IntervalT>(I_I(7,9), I_I(0,5));
  72. test_inner_complement<T,Compare,IntervalT>(I_I(0,9), I_I(2,5));
  73. test_inner_complement<T,Compare,IntervalT>(C_D(6,9), C_D(1,4));
  74. test_inner_complement<T,Compare,IntervalT>(C_D(1,3), C_D(1,4));
  75. test_inner_complement<T,Compare,IntervalT>(C_D(1,3), C_D(6,8));
  76. test_inner_complement<T,Compare,IntervalT>(C_D(1,7), C_D(1,6));
  77. test_inner_complement<T,Compare,IntervalT>(C_D(1,1), C_D(1,1));
  78. test_inner_complement<T,Compare,IntervalT>(C_D(3,0), C_D(4,0));
  79. test_inner_complement<T,Compare,IntervalT>(C_D(0,2), C_D(4,6));
  80. test_inner_complement<T,Compare,IntervalT>(C_D(0,2), C_D(0,6));
  81. }
  82. #endif // BOOST_ICL_TEST_ICL_DISCRETE_INTERVAL_HPP_JOFA_100930