From 483eb2f56657e8e7f419ab1a4fab8dce9ade8609 Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Sat, 27 Apr 2024 20:24:20 +0200 Subject: Adding upstream version 14.2.21. Signed-off-by: Daniel Baumann --- src/boost/libs/icl/test/test_interval_laws.hpp | 84 ++++++++++++++++++++++++++ 1 file changed, 84 insertions(+) create mode 100644 src/boost/libs/icl/test/test_interval_laws.hpp (limited to 'src/boost/libs/icl/test/test_interval_laws.hpp') diff --git a/src/boost/libs/icl/test/test_interval_laws.hpp b/src/boost/libs/icl/test/test_interval_laws.hpp new file mode 100644 index 00000000..587588ef --- /dev/null +++ b/src/boost/libs/icl/test/test_interval_laws.hpp @@ -0,0 +1,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 +#include +#include +#include +#include +#include + +namespace boost{ namespace icl +{ + +template +typename enable_if, void>::type +check_border_containedness(const Type& itv) +{ + typedef typename interval_traits::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::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:: closed(lo,up)), true); + BOOST_CHECK_EQUAL(icl::contains(itv, icl::interval::right_open(lo,up)), true); + BOOST_CHECK_EQUAL(icl::contains(itv, icl::interval:: left_open(lo,up)), true); + BOOST_CHECK_EQUAL(icl::contains(itv, icl::interval:: 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:: closed(lo,up)), false); + BOOST_CHECK_EQUAL(icl::contains(itv, icl::interval::right_open(lo,up)), true); + BOOST_CHECK_EQUAL(icl::contains(itv, icl::interval:: left_open(lo,up)), false); + BOOST_CHECK_EQUAL(icl::contains(itv, icl::interval:: 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:: closed(lo,up)), false); + BOOST_CHECK_EQUAL(icl::contains(itv, icl::interval::right_open(lo,up)), false); + BOOST_CHECK_EQUAL(icl::contains(itv, icl::interval:: left_open(lo,up)), true); + BOOST_CHECK_EQUAL(icl::contains(itv, icl::interval:: 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:: closed(lo,up)), false); + BOOST_CHECK_EQUAL(icl::contains(itv, icl::interval::right_open(lo,up)), false); + BOOST_CHECK_EQUAL(icl::contains(itv, icl::interval:: left_open(lo,up)), false); + BOOST_CHECK_EQUAL(icl::contains(itv, icl::interval:: 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 -- cgit v1.2.3