| 1 | /* Boost.MultiIndex test for serialization, part 2. |
| 2 | * |
| 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) |
| 7 | * |
| 8 | * See http://www.boost.org/libs/multi_index for library home page. |
| 9 | */ |
| 10 | |
| 11 | #include "test_serialization2.hpp" |
| 12 | #include "test_serialization_template.hpp" |
| 13 | |
| 14 | #include <boost/multi_index/ordered_index.hpp> |
| 15 | #include <boost/multi_index/sequenced_index.hpp> |
| 16 | #include <boost/multi_index/random_access_index.hpp> |
| 17 | #include <boost/multi_index/key_extractors.hpp> |
| 18 | #include "non_std_allocator.hpp" |
| 19 | #include "pair_of_ints.hpp" |
| 20 | |
| 21 | using namespace boost::multi_index; |
| 22 | |
| 23 | void test_serialization2() |
| 24 | { |
| 25 | { |
| 26 | typedef multi_index_container< |
| 27 | pair_of_ints, |
| 28 | indexed_by< |
| 29 | ordered_unique< |
| 30 | BOOST_MULTI_INDEX_MEMBER(pair_of_ints,int,first) |
| 31 | >, |
| 32 | ordered_non_unique< |
| 33 | BOOST_MULTI_INDEX_MEMBER(pair_of_ints,int,second) |
| 34 | >, |
| 35 | random_access<>, |
| 36 | sequenced<> |
| 37 | >, |
| 38 | non_std_allocator<pair_of_ints> |
| 39 | > multi_index_t; |
| 40 | |
| 41 | multi_index_t m; |
| 42 | test_serialization(m); |
| 43 | |
| 44 | m.insert(x: pair_of_ints(4,0)); |
| 45 | test_serialization(m); |
| 46 | |
| 47 | m.insert(x: pair_of_ints(3,1)); |
| 48 | m.insert(x: pair_of_ints(2,1)); |
| 49 | test_serialization(m); |
| 50 | |
| 51 | m.insert(x: pair_of_ints(1,1)); |
| 52 | test_serialization(m); |
| 53 | |
| 54 | m.insert(x: pair_of_ints(0,0)); |
| 55 | test_serialization(m); |
| 56 | |
| 57 | m.insert(x: pair_of_ints(5,1)); |
| 58 | m.insert(x: pair_of_ints(7,1)); |
| 59 | m.insert(x: pair_of_ints(6,1)); |
| 60 | test_serialization(m); |
| 61 | |
| 62 | m.insert(x: pair_of_ints(8,1)); |
| 63 | m.insert(x: pair_of_ints(9,1)); |
| 64 | m.insert(x: pair_of_ints(12,1)); |
| 65 | m.insert(x: pair_of_ints(11,1)); |
| 66 | m.insert(x: pair_of_ints(10,1)); |
| 67 | test_serialization(m); |
| 68 | |
| 69 | /* testcase for bug reported at |
| 70 | * http://lists.boost.org/boost-users/2006/05/19362.php |
| 71 | */ |
| 72 | |
| 73 | m.clear(); |
| 74 | m.insert(x: pair_of_ints(0,0)); |
| 75 | m.insert(x: pair_of_ints(1,0)); |
| 76 | m.insert(x: pair_of_ints(2,1)); |
| 77 | m.insert(x: pair_of_ints(4,2)); |
| 78 | m.insert(x: pair_of_ints(3,2)); |
| 79 | test_serialization(m); |
| 80 | } |
| 81 | } |
| 82 | |