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/managed_shared_memory.hpp> |
12 | #include <boost/interprocess/containers/vector.hpp> |
13 | #include <boost/interprocess/allocators/allocator.hpp> |
14 | #include "allocator_v1.hpp" |
15 | #include "check_equal_containers.hpp" |
16 | #include "movable_int.hpp" |
17 | #include "expand_bwd_test_allocator.hpp" |
18 | #include "expand_bwd_test_template.hpp" |
19 | #include "dummy_test_allocator.hpp" |
20 | #include "vector_test.hpp" |
21 | |
22 | using namespace boost::interprocess; |
23 | |
24 | int test_expand_bwd() |
25 | { |
26 | //Now test all back insertion possibilities |
27 | |
28 | //First raw ints |
29 | typedef test::expand_bwd_test_allocator<int> |
30 | int_allocator_type; |
31 | typedef vector<int, int_allocator_type> |
32 | int_vector; |
33 | |
34 | if(!test::test_all_expand_bwd<int_vector>()) |
35 | return 1; |
36 | |
37 | //Now user defined wrapped int |
38 | typedef test::expand_bwd_test_allocator<test::int_holder> |
39 | int_holder_allocator_type; |
40 | typedef vector<test::int_holder, int_holder_allocator_type> |
41 | int_holder_vector; |
42 | |
43 | if(!test::test_all_expand_bwd<int_holder_vector>()) |
44 | return 1; |
45 | |
46 | //Now user defined bigger wrapped int |
47 | typedef test::expand_bwd_test_allocator<test::triple_int_holder> |
48 | triple_int_holder_allocator_type; |
49 | |
50 | typedef vector<test::triple_int_holder, triple_int_holder_allocator_type> |
51 | triple_int_holder_vector; |
52 | |
53 | if(!test::test_all_expand_bwd<triple_int_holder_vector>()) |
54 | return 1; |
55 | |
56 | return 0; |
57 | } |
58 | |
59 | int main() |
60 | { |
61 | typedef allocator<int, managed_shared_memory::segment_manager> ShmemAllocator; |
62 | typedef vector<int, ShmemAllocator> MyVector; |
63 | |
64 | typedef test::allocator_v1<int, managed_shared_memory::segment_manager> ShmemV1Allocator; |
65 | typedef vector<int, ShmemV1Allocator> MyV1Vector; |
66 | |
67 | typedef allocator<test::movable_int, managed_shared_memory::segment_manager> ShmemMoveAllocator; |
68 | typedef vector<test::movable_int, ShmemMoveAllocator> MyMoveVector; |
69 | |
70 | typedef allocator<test::movable_and_copyable_int, managed_shared_memory::segment_manager> ShmemCopyMoveAllocator; |
71 | typedef vector<test::movable_and_copyable_int, ShmemCopyMoveAllocator> MyCopyMoveVector; |
72 | |
73 | typedef allocator<test::copyable_int, managed_shared_memory::segment_manager> ShmemCopyAllocator; |
74 | typedef vector<test::copyable_int, ShmemCopyAllocator> MyCopyVector; |
75 | |
76 | if(test::vector_test<managed_shared_memory, MyVector>()) |
77 | return 1; |
78 | |
79 | if(test::vector_test<managed_shared_memory, MyV1Vector>()) |
80 | return 1; |
81 | |
82 | if(test::vector_test<managed_shared_memory, MyMoveVector>()) |
83 | return 1; |
84 | |
85 | if(test::vector_test<managed_shared_memory, MyCopyMoveVector>()) |
86 | return 1; |
87 | |
88 | if(test::vector_test<managed_shared_memory, MyCopyVector>()) |
89 | return 1; |
90 | |
91 | if(test_expand_bwd()) |
92 | return 1; |
93 | |
94 | const test::EmplaceOptions Options = (test::EmplaceOptions)(test::EMPLACE_BACK | test::EMPLACE_BEFORE); |
95 | if(!boost::interprocess::test::test_emplace |
96 | < vector<test::EmplaceInt>, Options>()) |
97 | return 1; |
98 | |
99 | return 0; |
100 | } |
101 | |