1 /* Boost.MultiIndex test for interconvertibilty between const and
4 * Copyright 2003-2013 Joaquin M Lopez Munoz.
5 * Distributed under the Boost Software License, Version 1.0.
6 * (See accompanying file LICENSE_1_0.txt or copy at
7 * http://www.boost.org/LICENSE_1_0.txt)
9 * See http://www.boost.org/libs/multi_index for library home page.
12 #include "test_conv_iterators.hpp"
14 #include <boost/config.hpp> /* keep it first to prevent nasty warns in MSVC */
15 #include "pre_multi_index.hpp"
16 #include "employee.hpp"
17 #include <boost/detail/lightweight_test.hpp>
19 using namespace boost::multi_index;
21 void test_conv_iterators()
24 es.insert(employee(2,"John",40,7889));
27 const employee_set& ces=es;
28 employee_set::iterator it=es.find(employee(2,"John",40,7889));
29 employee_set::const_iterator it1=es.find(employee(2,"John",40,7889));
30 employee_set::const_iterator it2=ces.find(employee(2,"John",40,7889));
32 BOOST_TEST(it==it1&&it1==it2&&it2==it);
33 BOOST_TEST(*it==*it1&&*it1==*it2&&*it2==*it);
36 employee_set_by_name& i1=get<1>(es);
37 const employee_set_by_name& ci1=get<1>(es);
38 employee_set_by_name::iterator it=i1.find("John");
39 employee_set_by_name::const_iterator it1=i1.find("John");
40 employee_set_by_name::const_iterator it2=ci1.find("John");
42 BOOST_TEST(it==it1&&it1==it2&&it2==it);
43 BOOST_TEST(*it==*it1&&*it1==*it2&&*it2==*it);
46 employee_set_by_name& i1=get<1>(es);
47 const employee_set_by_name& ci1=get<1>(es);
48 employee_set_by_name::local_iterator it=i1.begin(i1.bucket("John"));
49 employee_set_by_name::const_local_iterator it1=i1.begin(i1.bucket("John"));
50 employee_set_by_name::const_local_iterator it2=ci1.begin(ci1.bucket("John"));
52 BOOST_TEST(it==it1&&it1==it2&&it2==it);
53 BOOST_TEST(*it==*it1&&*it1==*it2&&*it2==*it);
56 employee_set_as_inserted& i3=get<3>(es);
57 const employee_set_as_inserted& ci3=get<3>(es);
58 employee_set_as_inserted::iterator it=i3.begin();
59 employee_set_as_inserted::const_iterator it1=i3.begin();
60 employee_set_as_inserted::const_iterator it2=ci3.begin();
62 BOOST_TEST(it==it1&&it1==it2&&it2==it);
63 BOOST_TEST(*it==*it1&&*it1==*it2&&*it2==*it);
66 employee_set_randomly& i5=get<5>(es);
67 const employee_set_randomly& ci5=get<5>(es);
68 employee_set_randomly::iterator it=i5.begin();
69 employee_set_randomly::const_iterator it1=i5.begin();
70 employee_set_randomly::const_iterator it2=ci5.begin();
72 BOOST_TEST(it==it1&&it1==it2&&it2==it);
73 BOOST_TEST(*it==*it1&&*it1==*it2&&*it2==*it);