summaryrefslogtreecommitdiffstats
path: root/src/boost/libs/icl/test/test_icl_map.hpp
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-27 18:24:20 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-27 18:24:20 +0000
commit483eb2f56657e8e7f419ab1a4fab8dce9ade8609 (patch)
treee5d88d25d870d5dedacb6bbdbe2a966086a0a5cf /src/boost/libs/icl/test/test_icl_map.hpp
parentInitial commit. (diff)
downloadceph-upstream.tar.xz
ceph-upstream.zip
Adding upstream version 14.2.21.upstream/14.2.21upstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'src/boost/libs/icl/test/test_icl_map.hpp')
-rw-r--r--src/boost/libs/icl/test/test_icl_map.hpp186
1 files changed, 186 insertions, 0 deletions
diff --git a/src/boost/libs/icl/test/test_icl_map.hpp b/src/boost/libs/icl/test/test_icl_map.hpp
new file mode 100644
index 00000000..f16c1100
--- /dev/null
+++ b/src/boost/libs/icl/test/test_icl_map.hpp
@@ -0,0 +1,186 @@
+/*-----------------------------------------------------------------------------+
+Copyright (c) 2008-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)
++-----------------------------------------------------------------------------*/
+#ifndef LIBS_ICL_TEST_TEST_ICL_MAP_HPP_JOFA_090119
+#define LIBS_ICL_TEST_TEST_ICL_MAP_HPP_JOFA_090119
+
+#include "portability.hpp"
+
+template
+<
+ class T, class U, class Trt,
+#if (defined(__GNUC__) && (__GNUC__ < 4)) //MEMO Can be simplified, if gcc-3.4 is obsolete
+ ICL_IntervalMap_TEMPLATE(T,U,Traits,Trt) IntervalMap
+#else
+ ICL_IntervalMap_TEMPLATE(_T,_U,Traits,Trt) IntervalMap
+#endif
+>
+void icl_map_contains_4_bicremental_types()
+{
+ typedef IntervalMap<T,U,Trt> IntervalMapT;
+ typedef icl::map<T,U,Trt> MapT;
+ //CL typedef std::set<T> SetT;
+ typedef typename MapT::element_type map_element_type;
+
+ IntervalMapT itv_map_a;
+ itv_map_a.add(IDv(2,4,1)).add(IIv(6,7,3));
+
+ MapT map_a;
+ segmental::atomize(map_a, itv_map_a);
+
+ BOOST_CHECK_EQUAL( contains(map_a, MK_v(3)), true );
+ BOOST_CHECK_EQUAL( within(MK_v(3), map_a), true );
+
+ map_element_type key_value_pair(MK_v(6), MK_u(3));
+ BOOST_CHECK( contains(map_a, key_value_pair) );
+ BOOST_CHECK( within(key_value_pair, map_a) );
+
+}
+
+
+template
+<
+ class T, class U, class Trt,
+#if (defined(__GNUC__) && (__GNUC__ < 4)) //MEMO Can be simplified, if gcc-3.4 is obsolete
+ ICL_IntervalMap_TEMPLATE(T,U,Traits,Trt) IntervalMap
+#else
+ ICL_IntervalMap_TEMPLATE(_T,_U,Traits,Trt) IntervalMap
+#endif
+>
+void icl_map_find_4_bicremental_types()
+{
+ typedef IntervalMap<T,U,Trt> IntervalMapT;
+ typedef icl::map<T,U,Trt> MapT;
+
+ IntervalMapT itv_map_a;
+ itv_map_a.add(IDv(2,4,1)).add(IIv(6,7,3));
+
+ MapT map_a;
+ segmental::atomize(map_a, itv_map_a);
+
+ typename MapT::const_iterator found = map_a.find(MK_v(6));
+
+ BOOST_CHECK_EQUAL( found->second, MK_u(3) );
+ BOOST_CHECK_EQUAL( map_a(MK_v(6)), MK_u(3) );
+
+ found = map_a.find(MK_v(5));
+
+ BOOST_CHECK_EQUAL( found == map_a.end(), true );
+ BOOST_CHECK_EQUAL( map_a(MK_v(5)), MK_u(0) );
+}
+
+
+template
+<
+ class T, class U, class Trt,
+#if (defined(__GNUC__) && (__GNUC__ < 4)) //MEMO Can be simplified, if gcc-3.4 is obsolete
+ ICL_IntervalMap_TEMPLATE(T,U,Traits,Trt) IntervalMap
+#else
+ ICL_IntervalMap_TEMPLATE(_T,_U,Traits,Trt) IntervalMap
+#endif
+>
+void icl_map_inclusion_compare_4_bicremental_types()
+{
+ typedef IntervalMap<T,U,Trt> IntervalMapT;
+ typedef icl::map<T,U,Trt> MapT;
+ typedef std::set<T> SetT;
+
+ IntervalMapT itv_map_sub_a, itv_map_a, itv_map_super_a,
+ itv_map_b, itv_map_c;
+ itv_map_sub_a.add(IDv(2,4,1)).add(IIv(6,7,3));
+ itv_map_a = itv_map_sub_a;
+ itv_map_a.add(IIv(9,9,1));
+ itv_map_c = itv_map_sub_a;
+ itv_map_c.erase(MK_v(7)).add(IIv(11,11,2));
+ itv_map_b = itv_map_a;
+ itv_map_b.set(IIv(6,7,2));
+
+ MapT map_sub_a, map_a, map_a2, map_b, map_c;
+ segmental::atomize(map_a, itv_map_a);
+ segmental::atomize(map_b, itv_map_b);
+ segmental::atomize(map_c, itv_map_c);
+ segmental::atomize(map_sub_a, itv_map_sub_a);
+
+ map_a2 = map_a;
+ BOOST_CHECK_EQUAL( inclusion_compare(MapT(), MapT()), inclusion::equal );
+ BOOST_CHECK_EQUAL( inclusion_compare(map_a, map_a), inclusion::equal );
+ BOOST_CHECK_EQUAL( inclusion_compare(map_a, map_a2), inclusion::equal );
+
+ BOOST_CHECK_EQUAL( inclusion_compare(map_a, MapT()), inclusion::superset );
+ BOOST_CHECK_EQUAL( inclusion_compare(map_a, map_sub_a), inclusion::superset );
+ BOOST_CHECK_EQUAL( inclusion_compare(MapT(), map_a), inclusion::subset );
+ BOOST_CHECK_EQUAL( inclusion_compare(map_sub_a, map_a), inclusion::subset );
+
+ BOOST_CHECK_EQUAL( inclusion_compare(map_a, map_b), inclusion::unrelated );
+ BOOST_CHECK_EQUAL( inclusion_compare(map_a, map_c), inclusion::unrelated );
+
+ SetT set_sub_a, set_a, set_a2, set_b, set_c;
+ icl::domain(set_a, map_a);
+ icl::domain(set_a2, map_a2);
+ icl::domain(set_sub_a, map_sub_a);
+
+ BOOST_CHECK_EQUAL( inclusion_compare(MapT(), SetT()), inclusion::equal );
+ BOOST_CHECK_EQUAL( inclusion_compare(SetT(), MapT()), inclusion::equal );
+ BOOST_CHECK_EQUAL( inclusion_compare(SetT(), SetT()), inclusion::equal );
+
+ BOOST_CHECK_EQUAL( inclusion_compare(map_a, set_a), inclusion::equal );
+ BOOST_CHECK_EQUAL( inclusion_compare(set_a, map_a), inclusion::equal );
+ BOOST_CHECK_EQUAL( inclusion_compare(set_a, set_a2), inclusion::equal );
+
+ BOOST_CHECK_EQUAL( inclusion_compare(map_a, SetT()), inclusion::superset );
+ BOOST_CHECK_EQUAL( inclusion_compare(map_a, set_sub_a), inclusion::superset );
+
+ BOOST_CHECK_EQUAL( inclusion_compare(SetT(), map_a), inclusion::subset );
+ BOOST_CHECK_EQUAL( inclusion_compare(set_sub_a, map_a), inclusion::subset );
+
+ BOOST_CHECK_EQUAL( inclusion_compare(set_a, SetT()), inclusion::superset );
+ BOOST_CHECK_EQUAL( inclusion_compare(set_a, set_sub_a), inclusion::superset );
+
+ BOOST_CHECK_EQUAL( inclusion_compare(SetT(), set_a), inclusion::subset );
+ BOOST_CHECK_EQUAL( inclusion_compare(set_sub_a, set_a), inclusion::subset );
+
+ BOOST_CHECK_EQUAL( inclusion_compare(set_a, map_c), inclusion::unrelated );
+ BOOST_CHECK_EQUAL( inclusion_compare(map_c, set_a), inclusion::unrelated );
+
+}
+
+
+template
+<
+ class T, class U, class Trt,
+#if (defined(__GNUC__) && (__GNUC__ < 4)) //MEMO Can be simplified, if gcc-3.4 is obsolete
+ ICL_IntervalMap_TEMPLATE(T,U,Traits,Trt) IntervalMap
+#else
+ ICL_IntervalMap_TEMPLATE(_T,_U,Traits,Trt) IntervalMap
+#endif
+>
+void icl_map_move_4_discrete_types()
+{
+ typedef icl::map<T,U,Trt> MapT;
+ typedef typename MapT::element_type map_element_type;
+
+ map_element_type kv_6_3(MK_v(6), MK_u(3));
+
+ MapT map_b;
+ map_b.add(kv_6_3);
+ MapT mv_cons_1(boost::move(MapT().add(kv_6_3)));
+ MapT cp_cons_1(map_b);
+
+ BOOST_CHECK_EQUAL( mv_cons_1, cp_cons_1 );
+ BOOST_CHECK_EQUAL( map_b, cp_cons_1 );
+
+ MapT mv_ass_1, cp_ass_1;
+ mv_ass_1 = boost::move(MapT().add(kv_6_3));
+ cp_ass_1 = map_b;
+
+ BOOST_CHECK_EQUAL( mv_ass_1, cp_ass_1 );
+ BOOST_CHECK_EQUAL( map_b, cp_ass_1 );
+}
+
+
+#endif // LIBS_ICL_TEST_TEST_ICL_MAP_HPP_JOFA_090119
+