Fixed minor gcc warnings
[libcds.git] / test / unit / tree / ellen_bintree_map_dhp.cpp
1 /*
2     This file is a part of libcds - Concurrent Data Structures library
3
4     (C) Copyright Maxim Khizhinsky (libcds.dev@gmail.com) 2006-2016
5
6     Source code repo: http://github.com/khizmax/libcds/
7     Download: http://sourceforge.net/projects/libcds/files/
8     
9     Redistribution and use in source and binary forms, with or without
10     modification, are permitted provided that the following conditions are met:
11
12     * Redistributions of source code must retain the above copyright notice, this
13       list of conditions and the following disclaimer.
14
15     * Redistributions in binary form must reproduce the above copyright notice,
16       this list of conditions and the following disclaimer in the documentation
17       and/or other materials provided with the distribution.
18
19     THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
20     AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
21     IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
22     DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
23     FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
24     DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
25     SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
26     CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
27     OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
28     OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.     
29 */
30
31 #include "test_tree_map_hp.h"
32
33 #include <cds/container/ellen_bintree_map_dhp.h>
34 #include "test_ellen_bintree_update_desc_pool.h"
35
36 namespace {
37     namespace cc = cds::container;
38     typedef cds::gc::DHP gc_type;
39
40     class EllenBinTreeMap_DHP : public cds_test::container_tree_map_hp
41     {
42     protected:
43         typedef cds_test::container_tree_map_hp base_class;
44
45         void SetUp()
46         {
47             typedef cc::EllenBinTreeMap< gc_type, key_type, value_type > map_type;
48
49             cds::gc::dhp::GarbageCollector::Construct( 16, map_type::c_nHazardPtrCount );
50             cds::threading::Manager::attachThread();
51         }
52
53         void TearDown()
54         {
55             cds::threading::Manager::detachThread();
56             cds::gc::dhp::GarbageCollector::Destruct();
57         }
58     };
59
60
61     TEST_F( EllenBinTreeMap_DHP, compare )
62     {
63         typedef cc::EllenBinTreeMap< gc_type, key_type, value_type,
64             typename cc::ellen_bintree::make_map_traits<
65                 cds::opt::compare< cmp >
66             >::type
67         > map_type;
68
69         map_type m;
70         test( m );
71     }
72
73     TEST_F( EllenBinTreeMap_DHP, less )
74     {
75         typedef cc::EllenBinTreeMap< gc_type, key_type, value_type,
76             typename cc::ellen_bintree::make_map_traits<
77                 cds::opt::less< base_class::less >
78             >::type
79         > map_type;
80
81         map_type m;
82         test( m );
83     }
84
85     TEST_F( EllenBinTreeMap_DHP, cmpmix )
86     {
87         typedef cc::EllenBinTreeMap< gc_type, key_type, value_type,
88             typename cc::ellen_bintree::make_map_traits<
89                 cds::opt::less< base_class::less >
90                 ,cds::opt::compare< cmp >
91             >::type
92         > map_type;
93
94         map_type m;
95         test( m );
96     }
97
98     TEST_F( EllenBinTreeMap_DHP, update_desc_pool )
99     {
100         struct map_traits: public cc::ellen_bintree::traits
101         {
102             typedef cmp compare;
103             typedef cds::memory::pool_allocator<cds_test::update_desc, cds_test::pool_accessor> update_desc_allocator;
104         };
105         typedef cc::EllenBinTreeMap< gc_type, key_type, value_type, map_traits > map_type;
106
107         map_type m;
108         test( m );
109     }
110
111     TEST_F( EllenBinTreeMap_DHP, update_desc_lazy_pool )
112     {
113         struct map_traits: public cc::ellen_bintree::traits
114         {
115             typedef cmp compare;
116             typedef cds::memory::pool_allocator< cds_test::update_desc, cds_test::lazy_pool_accessor> update_desc_allocator;
117         };
118         typedef cc::EllenBinTreeMap< gc_type, key_type, value_type, map_traits > map_type;
119
120         map_type m;
121         test( m );
122     }
123
124     TEST_F( EllenBinTreeMap_DHP, item_counting )
125     {
126         struct map_traits: public cc::ellen_bintree::traits
127         {
128             typedef cmp compare;
129             typedef base_class::less less;
130             typedef cds::atomicity::item_counter item_counter;
131             typedef cds::memory::pool_allocator<cds_test::update_desc, cds_test::pool_accessor> update_desc_allocator;
132         };
133         typedef cc::EllenBinTreeMap< gc_type, key_type, value_type, map_traits > map_type;
134
135         map_type m;
136         test( m );
137     }
138
139     TEST_F( EllenBinTreeMap_DHP, backoff )
140     {
141         struct map_traits: public cc::ellen_bintree::traits
142         {
143             typedef cmp compare;
144             typedef base_class::less less;
145             typedef cds::atomicity::item_counter item_counter;
146             typedef cds::backoff::yield back_off;
147             typedef cds::memory::pool_allocator<cds_test::update_desc, cds_test::lazy_pool_accessor> update_desc_allocator;
148         };
149         typedef cc::EllenBinTreeMap< gc_type, key_type, value_type, map_traits > map_type;
150
151         map_type m;
152         test( m );
153     }
154
155     TEST_F( EllenBinTreeMap_DHP, stat )
156     {
157         struct map_traits: public cc::ellen_bintree::traits
158         {
159             typedef base_class::less less;
160             typedef cds::atomicity::item_counter item_counter;
161             typedef cds::backoff::yield back_off;
162             typedef cc::ellen_bintree::stat<> stat;
163             typedef cds::memory::pool_allocator<cds_test::update_desc, cds_test::pool_accessor> update_desc_allocator;
164         };
165         typedef cc::EllenBinTreeMap< gc_type, key_type, value_type, map_traits > map_type;
166
167         map_type m;
168         test( m );
169     }
170
171     TEST_F( EllenBinTreeMap_DHP, copy_policy )
172     {
173         struct map_traits: public cc::ellen_bintree::traits
174         {
175             typedef base_class::less less;
176             typedef cds::atomicity::item_counter item_counter;
177             typedef cds::memory::pool_allocator<cds_test::update_desc, cds_test::pool_accessor> update_desc_allocator;
178             typedef copy_key copy_policy;
179         };
180         typedef cc::EllenBinTreeMap< gc_type, key_type, value_type, map_traits > map_type;
181
182         map_type m;
183         test( m );
184     }
185
186     TEST_F( EllenBinTreeMap_DHP, seq_cst )
187     {
188         struct map_traits: public cc::ellen_bintree::traits
189         {
190             typedef cmp compare;
191             typedef cds::atomicity::item_counter item_counter;
192             typedef cds::backoff::yield back_off;
193             typedef cds::memory::pool_allocator<cds_test::update_desc, cds_test::lazy_pool_accessor> update_desc_allocator;
194             typedef cds::opt::v::sequential_consistent memory_model;
195         };
196         typedef cc::EllenBinTreeMap< gc_type, key_type, value_type, map_traits > map_type;
197
198         map_type m;
199         test( m );
200     }
201
202 } // namespace