• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*-----------------------------------------------------------------------------+
2 Copyright (c) 2010-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 
9 /*-----------------------------------------------------------------------------+
10 Function templates to call functions in object oriented or namespace glabal
11 versions.
12 +-----------------------------------------------------------------------------*/
13 #ifndef BOOST_LIBS_ICL_TEST_INTERVAL_LAWS_HPP_JOFA_101011
14 #define BOOST_LIBS_ICL_TEST_INTERVAL_LAWS_HPP_JOFA_101011
15 
16 #include <boost/icl/detail/notate.hpp>
17 #include <boost/icl/detail/design_config.hpp>
18 #include <boost/icl/type_traits/interval_type_default.hpp>
19 #include <boost/icl/interval.hpp>
20 #include <boost/icl/type_traits/is_interval.hpp>
21 #include <boost/icl/concept/interval.hpp>
22 
23 namespace boost{ namespace icl
24 {
25 
26 template<class Type>
27 typename enable_if<is_interval<Type>, void>::type
check_border_containedness(const Type & itv)28 check_border_containedness(const Type& itv)
29 {
30     typedef typename interval_traits<Type>::domain_type domain_type;
31     domain_type lo = icl::lower(itv);
32     domain_type up = icl::upper(itv);
33 
34     //LAW: The empty set is contained in every set
35     BOOST_CHECK_EQUAL(icl::contains(itv, icl::identity_element<Type>::value()), true);
36     //LAW: Reflexivity: Every interval contains itself
37     BOOST_CHECK_EQUAL(icl::contains(itv, itv), true);
38 
39     if(icl::bounds(itv) == interval_bounds::closed())
40     {
41         BOOST_CHECK_EQUAL(icl::contains(itv, lo), true);
42         BOOST_CHECK_EQUAL(icl::contains(itv, up), true);
43         BOOST_CHECK_EQUAL(icl::contains(itv, icl::interval<domain_type>::    closed(lo,up)), true);
44         BOOST_CHECK_EQUAL(icl::contains(itv, icl::interval<domain_type>::right_open(lo,up)), true);
45         BOOST_CHECK_EQUAL(icl::contains(itv, icl::interval<domain_type>:: left_open(lo,up)), true);
46         BOOST_CHECK_EQUAL(icl::contains(itv, icl::interval<domain_type>::      open(lo,up)), true);
47     }
48     else if(icl::bounds(itv) == interval_bounds::right_open())
49     {
50         BOOST_CHECK_EQUAL(icl::contains(itv, lo), true);
51         BOOST_CHECK_EQUAL(icl::contains(itv, up), false);
52         BOOST_CHECK_EQUAL(icl::contains(itv, icl::interval<domain_type>::    closed(lo,up)), false);
53         BOOST_CHECK_EQUAL(icl::contains(itv, icl::interval<domain_type>::right_open(lo,up)), true);
54         BOOST_CHECK_EQUAL(icl::contains(itv, icl::interval<domain_type>:: left_open(lo,up)), false);
55         BOOST_CHECK_EQUAL(icl::contains(itv, icl::interval<domain_type>::      open(lo,up)), true);
56     }
57     else if(icl::bounds(itv) == interval_bounds::left_open())
58     {
59         BOOST_CHECK_EQUAL(icl::contains(itv, lo), false);
60         BOOST_CHECK_EQUAL(icl::contains(itv, up), true);
61         BOOST_CHECK_EQUAL(icl::contains(itv, icl::interval<domain_type>::    closed(lo,up)), false);
62         BOOST_CHECK_EQUAL(icl::contains(itv, icl::interval<domain_type>::right_open(lo,up)), false);
63         BOOST_CHECK_EQUAL(icl::contains(itv, icl::interval<domain_type>:: left_open(lo,up)), true);
64         BOOST_CHECK_EQUAL(icl::contains(itv, icl::interval<domain_type>::      open(lo,up)), true);
65     }
66     else if(icl::bounds(itv) == interval_bounds::open())
67     {
68         BOOST_CHECK_EQUAL(icl::contains(itv, lo), false);
69         BOOST_CHECK_EQUAL(icl::contains(itv, up), false);
70         BOOST_CHECK_EQUAL(icl::contains(itv, icl::interval<domain_type>::    closed(lo,up)), false);
71         BOOST_CHECK_EQUAL(icl::contains(itv, icl::interval<domain_type>::right_open(lo,up)), false);
72         BOOST_CHECK_EQUAL(icl::contains(itv, icl::interval<domain_type>:: left_open(lo,up)), false);
73         BOOST_CHECK_EQUAL(icl::contains(itv, icl::interval<domain_type>::      open(lo,up)), true);
74     }
75     else
76     {
77         bool interval_borders_are_open_v_left_open_v_right_open_v_closed = true;
78         BOOST_CHECK_EQUAL(interval_borders_are_open_v_left_open_v_right_open_v_closed, false);
79     }
80 }
81 
82 }} // namespace boost icl
83 
84 #endif // BOOST_ICL_TEST_INTERVAL_LAWS_HPP_JOFA_100908
85