File: test_conv_iterators.cpp

package info (click to toggle)
boost1.90 1.90.0-1
  • links: PTS, VCS
  • area: main
  • in suites:
  • size: 593,120 kB
  • sloc: cpp: 4,190,908; xml: 196,648; python: 34,618; ansic: 23,145; asm: 5,468; sh: 3,774; makefile: 1,161; perl: 1,020; sql: 728; ruby: 676; yacc: 478; java: 77; lisp: 24; csh: 6
file content (75 lines) | stat: -rw-r--r-- 2,668 bytes parent folder | download | duplicates (19)
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
/* Boost.MultiIndex test for interconvertibilty between const and
 * non-const iterators.
 *
 * Copyright 2003-2013 Joaquin M Lopez Munoz.
 * Distributed under the Boost Software License, Version 1.0.
 * (See accompanying file LICENSE_1_0.txt or copy at
 * http://www.boost.org/LICENSE_1_0.txt)
 *
 * See http://www.boost.org/libs/multi_index for library home page.
 */

#include "test_conv_iterators.hpp"

#include <boost/config.hpp> /* keep it first to prevent nasty warns in MSVC */
#include "pre_multi_index.hpp"
#include "employee.hpp"
#include <boost/detail/lightweight_test.hpp>

using namespace boost::multi_index;

void test_conv_iterators()
{
  employee_set es;
  es.insert(employee(2,"John",40,7889));

  {
    const employee_set& ces=es;
    employee_set::iterator        it=es.find(employee(2,"John",40,7889));
    employee_set::const_iterator it1=es.find(employee(2,"John",40,7889));
    employee_set::const_iterator it2=ces.find(employee(2,"John",40,7889));

    BOOST_TEST(it==it1&&it1==it2&&it2==it);
    BOOST_TEST(*it==*it1&&*it1==*it2&&*it2==*it);
  }
  {
    employee_set_by_name&        i1=get<1>(es);
    const employee_set_by_name& ci1=get<1>(es);
    employee_set_by_name::iterator        it=i1.find("John");
    employee_set_by_name::const_iterator it1=i1.find("John");
    employee_set_by_name::const_iterator it2=ci1.find("John");

    BOOST_TEST(it==it1&&it1==it2&&it2==it);
    BOOST_TEST(*it==*it1&&*it1==*it2&&*it2==*it);
  }
  {
    employee_set_by_name&        i1=get<1>(es);
    const employee_set_by_name& ci1=get<1>(es);
    employee_set_by_name::local_iterator        it=i1.begin(i1.bucket("John"));
    employee_set_by_name::const_local_iterator it1=i1.begin(i1.bucket("John"));
    employee_set_by_name::const_local_iterator it2=ci1.begin(ci1.bucket("John"));

    BOOST_TEST(it==it1&&it1==it2&&it2==it);
    BOOST_TEST(*it==*it1&&*it1==*it2&&*it2==*it);
  }
  {
    employee_set_as_inserted&        i3=get<3>(es);
    const employee_set_as_inserted& ci3=get<3>(es);
    employee_set_as_inserted::iterator        it=i3.begin();
    employee_set_as_inserted::const_iterator it1=i3.begin();
    employee_set_as_inserted::const_iterator it2=ci3.begin();

    BOOST_TEST(it==it1&&it1==it2&&it2==it);
    BOOST_TEST(*it==*it1&&*it1==*it2&&*it2==*it);
  }
  {
    employee_set_randomly&        i5=get<5>(es);
    const employee_set_randomly& ci5=get<5>(es);
    employee_set_randomly::iterator        it=i5.begin();
    employee_set_randomly::const_iterator it1=i5.begin();
    employee_set_randomly::const_iterator it2=ci5.begin();

    BOOST_TEST(it==it1&&it1==it2&&it2==it);
    BOOST_TEST(*it==*it1&&*it1==*it2&&*it2==*it);
  }
}