]> git.proxmox.com Git - ceph.git/blob - ceph/src/boost/libs/interprocess/test/vector_test.cpp
add subtree-ish sources for 12.0.3
[ceph.git] / ceph / src / boost / libs / interprocess / test / vector_test.cpp
1 //////////////////////////////////////////////////////////////////////////////
2 //
3 // (C) Copyright Ion Gaztanaga 2004-2012. Distributed under the Boost
4 // Software License, Version 1.0. (See accompanying file
5 // LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
6 //
7 // See http://www.boost.org/libs/interprocess for documentation.
8 //
9 //////////////////////////////////////////////////////////////////////////////
10
11 #include <boost/interprocess/detail/config_begin.hpp>
12 #include <boost/interprocess/managed_shared_memory.hpp>
13 #include <boost/interprocess/containers/vector.hpp>
14 #include <boost/interprocess/allocators/allocator.hpp>
15 #include "allocator_v1.hpp"
16 #include "check_equal_containers.hpp"
17 #include "movable_int.hpp"
18 #include "expand_bwd_test_allocator.hpp"
19 #include "expand_bwd_test_template.hpp"
20 #include "dummy_test_allocator.hpp"
21 #include "vector_test.hpp"
22
23 using namespace boost::interprocess;
24
25 int test_expand_bwd()
26 {
27 //Now test all back insertion possibilities
28
29 //First raw ints
30 typedef test::expand_bwd_test_allocator<int>
31 int_allocator_type;
32 typedef vector<int, int_allocator_type>
33 int_vector;
34
35 if(!test::test_all_expand_bwd<int_vector>())
36 return 1;
37
38 //Now user defined wrapped int
39 typedef test::expand_bwd_test_allocator<test::int_holder>
40 int_holder_allocator_type;
41 typedef vector<test::int_holder, int_holder_allocator_type>
42 int_holder_vector;
43
44 if(!test::test_all_expand_bwd<int_holder_vector>())
45 return 1;
46
47 //Now user defined bigger wrapped int
48 typedef test::expand_bwd_test_allocator<test::triple_int_holder>
49 triple_int_holder_allocator_type;
50
51 typedef vector<test::triple_int_holder, triple_int_holder_allocator_type>
52 triple_int_holder_vector;
53
54 if(!test::test_all_expand_bwd<triple_int_holder_vector>())
55 return 1;
56
57 return 0;
58 }
59
60 int main()
61 {
62 typedef allocator<int, managed_shared_memory::segment_manager> ShmemAllocator;
63 typedef vector<int, ShmemAllocator> MyVector;
64
65 typedef test::allocator_v1<int, managed_shared_memory::segment_manager> ShmemV1Allocator;
66 typedef vector<int, ShmemV1Allocator> MyV1Vector;
67
68 typedef allocator<test::movable_int, managed_shared_memory::segment_manager> ShmemMoveAllocator;
69 typedef vector<test::movable_int, ShmemMoveAllocator> MyMoveVector;
70
71 typedef allocator<test::movable_and_copyable_int, managed_shared_memory::segment_manager> ShmemCopyMoveAllocator;
72 typedef vector<test::movable_and_copyable_int, ShmemCopyMoveAllocator> MyCopyMoveVector;
73
74 typedef allocator<test::copyable_int, managed_shared_memory::segment_manager> ShmemCopyAllocator;
75 typedef vector<test::copyable_int, ShmemCopyAllocator> MyCopyVector;
76
77 if(test::vector_test<managed_shared_memory, MyVector>())
78 return 1;
79
80 if(test::vector_test<managed_shared_memory, MyV1Vector>())
81 return 1;
82
83 if(test::vector_test<managed_shared_memory, MyMoveVector>())
84 return 1;
85
86 if(test::vector_test<managed_shared_memory, MyCopyMoveVector>())
87 return 1;
88
89 if(test::vector_test<managed_shared_memory, MyCopyVector>())
90 return 1;
91
92 if(test_expand_bwd())
93 return 1;
94
95 const test::EmplaceOptions Options = (test::EmplaceOptions)(test::EMPLACE_BACK | test::EMPLACE_BEFORE);
96 if(!boost::interprocess::test::test_emplace
97 < vector<test::EmplaceInt>, Options>())
98 return 1;
99
100 return 0;
101 }
102
103 #include <boost/interprocess/detail/config_end.hpp>