1
/* Boost.MultiIndex basic test.
3
* Copyright 2003-2008 Joaquin M Lopez Munoz.
4
* Distributed under the Boost Software License, Version 1.0.
5
* (See accompanying file LICENSE_1_0.txt or copy at
6
* http://www.boost.org/LICENSE_1_0.txt)
8
* See http://www.boost.org/libs/multi_index for library home page.
11
#include "test_basic.hpp"
13
#include <boost/config.hpp> /* keep it first to prevent nasty warns in MSVC */
16
#include "pre_multi_index.hpp"
17
#include "employee.hpp"
18
#include <boost/test/test_tools.hpp>
20
using namespace boost::multi_index;
22
struct less_by_employee_age
24
bool operator()(const employee& e1,const employee& e2)const
33
std::vector<employee> v;
35
#if defined(BOOST_NO_MEMBER_TEMPLATES)
36
employee_set_by_name& i1=get<by_name>(es);
38
employee_set_by_name& i1=es.get<by_name>();
41
const employee_set_by_age& i2=get<2>(es);
42
employee_set_as_inserted& i3=get<3>(es);
43
employee_set_by_ssn& i4=get<ssn>(es);
44
employee_set_randomly& i5=get<randomly>(es);
46
es.insert(employee(0,"Joe",31,1123));
47
es.insert(employee(5,"Anna",41,1123)); /* clash*/
48
i1.insert(employee(1,"Robert",27,5601));
49
es.insert(employee(2,"John",40,7889));
50
i3.push_back(employee(3,"Albert",20,9012));
51
i4.insert(employee(4,"John",57,1002));
52
i5.push_back(employee(0,"Andrew",60,2302)); /* clash */
54
v.push_back(employee(0,"Joe",31,1123));
55
v.push_back(employee(1,"Robert",27,5601));
56
v.push_back(employee(2,"John",40,7889));
57
v.push_back(employee(3,"Albert",20,9012));
58
v.push_back(employee(4,"John",57,1002));
61
/* by insertion order */
63
BOOST_CHECK(std::equal(i3.begin(),i3.end(),v.begin()));
64
BOOST_CHECK(std::equal(i5.begin(),i5.end(),v.begin()));
70
std::sort(v.begin(),v.end());
71
BOOST_CHECK(std::equal(es.begin(),es.end(),v.begin()));
77
std::sort(v.begin(),v.end(),less_by_employee_age());
78
BOOST_CHECK(std::equal(i2.begin(),i2.end(),v.begin()));