test_icl_continuous_interval.hpp 4.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182
  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. #ifndef BOOST_ICL_TEST_ICL_INTERVAL_CONTINUOUS_HPP_JOFA_100930
  9. #define BOOST_ICL_TEST_ICL_INTERVAL_CONTINUOUS_HPP_JOFA_100930
  10. template <class T, class IntervalT>
  11. void interval_ctor_4_ordered_types()
  12. {
  13. BOOST_CHECK_EQUAL(icl::is_empty(IntervalT()), true);
  14. BOOST_CHECK_EQUAL(icl::cardinality(IntervalT()), icl::identity_element<typename icl::size_type_of<T>::type>::value());
  15. BOOST_CHECK_EQUAL(icl::size(IntervalT()), icl::identity_element<typename icl::size_type_of<T>::type>::value());
  16. BOOST_CHECK_EQUAL( IntervalT(), IntervalT() );
  17. BOOST_CHECK_EQUAL( IntervalT(), IntervalT(IntervalT().lower(), IntervalT().upper()) );
  18. BOOST_CHECK_EQUAL( IntervalT(), IntervalT(icl::lower(IntervalT()), icl::upper(IntervalT())) );
  19. }
  20. template <class T, ICL_COMPARE Compare>
  21. void distant_intervals_4_numeric_continuous_types()
  22. {
  23. typedef right_open_interval<T,Compare> L__D; // L__D for [..)
  24. typedef left_open_interval<T,Compare> C__I; // C__I for (..]
  25. typedef typename icl::interval<T,Compare>::type IntervalT;
  26. BOOST_CHECK( is_interval<L__D>::value );
  27. BOOST_CHECK( has_difference<typename interval_traits<L__D>::domain_type>::value );
  28. BOOST_CHECK( is_continuous<typename interval_traits<L__D>::domain_type>::value );
  29. BOOST_CHECK( (boost::is_same<typename interval_traits<L__D>::domain_type, T>::value) );
  30. //CL typedef typename difference_type_of<T>::type DiffT;
  31. test_inner_complement<T,Compare,L__D>(MK_I(L__D,0,4), MK_I(L__D,8,9));
  32. test_inner_complement<T,Compare,L__D>(MK_I(L__D,7,8), MK_I(L__D,2,3));
  33. test_inner_complement<T,Compare,L__D>(MK_I(L__D,2,4), MK_I(L__D,4,6));
  34. test_inner_complement<T,Compare,L__D>(MK_I(L__D,3,7), MK_I(L__D,5,8));
  35. test_inner_complement<T,Compare,L__D>(MK_I(L__D,7,9), MK_I(L__D,0,4));
  36. test_inner_complement<T,Compare,L__D>(MK_I(L__D,0,0), MK_I(L__D,0,0));
  37. test_inner_complement<T,Compare,L__D>(MK_I(L__D,1,0), MK_I(L__D,2,0));
  38. test_inner_complement<T,Compare,C__I>(MK_I(C__I,1,5), MK_I(C__I,4,9));
  39. test_inner_complement<T,Compare,C__I>(MK_I(C__I,4,6), MK_I(C__I,1,3));
  40. test_inner_complement<T,Compare,C__I>(MK_I(C__I,0,2), MK_I(C__I,4,6));
  41. test_inner_complement<T,Compare,C__I>(MK_I(C__I,0,2), MK_I(C__I,0,6));
  42. //--------------------------------------------------------------------------
  43. #ifndef BOOST_ICL_USE_STATIC_BOUNDED_INTERVALS
  44. test_inner_complement<T,Compare,IntervalT>(I_D(0,4), I_D(8,9));
  45. test_inner_complement<T,Compare,IntervalT>(I_D(7,8), I_D(2,3));
  46. test_inner_complement<T,Compare,IntervalT>(I_D(2,4), I_D(4,6));
  47. test_inner_complement<T,Compare,IntervalT>(I_D(3,7), I_D(5,8));
  48. test_inner_complement<T,Compare,IntervalT>(I_D(7,9), I_D(0,4));
  49. test_inner_complement<T,Compare,IntervalT>(I_D(0,0), I_D(0,0));
  50. test_inner_complement<T,Compare,IntervalT>(I_D(1,0), I_D(2,0));
  51. test_inner_complement<T,Compare,IntervalT>(C_I(1,5), C_I(4,9));
  52. test_inner_complement<T,Compare,IntervalT>(C_I(4,6), C_I(1,3));
  53. test_inner_complement<T,Compare,IntervalT>(C_I(0,2), C_I(4,6));
  54. test_inner_complement<T,Compare,IntervalT>(C_I(0,2), C_I(0,6));
  55. test_inner_complement<T,Compare,IntervalT>(I_I(7,9), I_I(0,5));
  56. test_inner_complement<T,Compare,IntervalT>(I_I(0,9), I_I(2,5));
  57. test_inner_complement<T,Compare,IntervalT>(C_D(6,9), C_D(1,4));
  58. test_inner_complement<T,Compare,IntervalT>(C_D(1,3), C_D(1,4));
  59. test_inner_complement<T,Compare,IntervalT>(C_D(1,3), C_D(6,8));
  60. test_inner_complement<T,Compare,IntervalT>(C_D(1,7), C_D(1,6));
  61. test_inner_complement<T,Compare,IntervalT>(C_D(1,1), C_D(1,1));
  62. test_inner_complement<T,Compare,IntervalT>(C_D(3,0), C_D(4,0));
  63. test_inner_complement<T,Compare,IntervalT>(C_D(0,2), C_D(4,6));
  64. test_inner_complement<T,Compare,IntervalT>(C_D(0,2), C_D(0,6));
  65. #endif //BOOST_ICL_USE_STATIC_BOUNDED_INTERVALS
  66. }
  67. #endif // BOOST_ICL_TEST_ICL_INTERVAL_CONTINUOUS_HPP_JOFA_100930