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