MultiLevelHashSet test, bugfixing
[libcds.git] / tests / test-hdr / set / hdr_intrusive_multilevel_hashset_hp.cpp
1 //$$CDS-header$$
2
3 #include "set/hdr_intrusive_multilevel_hashset.h"
4 #include <cds/intrusive/multilevel_hashset_hp.h>
5 #include "unit/print_multilevel_hashset_stat.h"
6
7 namespace set {
8     namespace {
9         typedef cds::gc::HP gc_type;
10     } // namespace
11
12     void IntrusiveMultiLevelHashSetHdrTest::hp_nohash()
13     {
14         typedef size_t key_type;
15
16         struct traits : public ci::multilevel_hashset::traits
17         {
18             typedef get_key<key_type> hash_accessor;
19             typedef item_disposer disposer;
20         };
21         typedef ci::MultiLevelHashSet< gc_type, Item<key_type>, traits > set_type;
22         static_assert(std::is_same< typename set_type::hash_type, size_t>::value, "set::hash_type != size_t!!!");
23         test_hp<set_type, nohash<key_type>>(4, 2);
24
25         typedef ci::MultiLevelHashSet<
26             gc_type,
27             Item<key_type>,
28             typename ci::multilevel_hashset::make_traits<
29                 ci::multilevel_hashset::hash_accessor< get_key<key_type>>
30                 , ci::opt::disposer< item_disposer >
31             >::type
32         > set_type2;
33         test_hp<set_type2, nohash<key_type>>(4, 2);
34     }
35
36     void IntrusiveMultiLevelHashSetHdrTest::hp_stdhash()
37     {
38         typedef size_t hash_type;
39
40         struct traits: public ci::multilevel_hashset::traits
41         {
42             typedef get_hash<hash_type> hash_accessor;
43             typedef item_disposer disposer;
44         };
45         typedef ci::MultiLevelHashSet< gc_type, Item<hash_type>, traits > set_type;
46         static_assert(std::is_same< typename set_type::hash_type, size_t>::value, "set::hash_type != size_t!!!" );
47         test_hp<set_type, std::hash<hash_type>>(4, 2);
48
49         typedef ci::MultiLevelHashSet<
50             gc_type,
51             Item<hash_type>,
52             typename ci::multilevel_hashset::make_traits<
53                 ci::multilevel_hashset::hash_accessor< get_hash<hash_type>>
54                 , ci::opt::disposer< item_disposer >
55             >::type
56         > set_type2;
57         test_hp<set_type2, std::hash<hash_type>>(4, 2);
58     }
59
60     void IntrusiveMultiLevelHashSetHdrTest::hp_hash128()
61     {
62         typedef hash128 hash_type;
63
64         struct traits: public ci::multilevel_hashset::traits
65         {
66             typedef get_hash<hash_type> hash_accessor;
67             typedef item_disposer disposer;
68             typedef hash128::less less;
69         };
70         typedef ci::MultiLevelHashSet< gc_type, Item<hash_type>, traits > set_type;
71         static_assert(std::is_same< typename set_type::hash_type, hash_type>::value, "set::hash_type != hash128!!!" );
72         test_hp<set_type, hash128::make>(4, 2);
73
74         typedef ci::MultiLevelHashSet<
75             gc_type,
76             Item<hash_type>,
77             typename ci::multilevel_hashset::make_traits<
78                 ci::multilevel_hashset::hash_accessor< get_hash<hash_type>>
79                 , ci::opt::disposer< item_disposer >
80                 , ci::opt::less< hash_type::less >
81             >::type
82         > set_type2;
83         test_hp<set_type2, hash128::make>(4, 2);
84     }
85
86     void IntrusiveMultiLevelHashSetHdrTest::hp_nohash_stat()
87     {
88         typedef size_t key_type;
89
90         struct traits : public ci::multilevel_hashset::traits
91         {
92             typedef get_key<key_type> hash_accessor;
93             typedef item_disposer disposer;
94             typedef ci::multilevel_hashset::stat<> stat;
95         };
96         typedef ci::MultiLevelHashSet< gc_type, Item<key_type>, traits > set_type;
97         static_assert(std::is_same< typename set_type::hash_type, size_t>::value, "set::hash_type != size_t!!!");
98         test_hp<set_type, nohash<key_type>>(4, 2);
99
100         typedef ci::MultiLevelHashSet<
101             gc_type,
102             Item<key_type>,
103             typename ci::multilevel_hashset::make_traits<
104             ci::multilevel_hashset::hash_accessor< get_key<key_type>>
105             , ci::opt::disposer< item_disposer >
106             , co::stat< ci::multilevel_hashset::stat<>>
107             >::type
108         > set_type2;
109         test_hp<set_type2, nohash<key_type>>(4, 2);
110     }
111
112     void IntrusiveMultiLevelHashSetHdrTest::hp_stdhash_stat()
113     {
114         typedef size_t hash_type;
115
116         struct traits: public ci::multilevel_hashset::traits
117         {
118             typedef get_hash<hash_type> hash_accessor;
119             typedef item_disposer disposer;
120             typedef ci::multilevel_hashset::stat<> stat;
121         };
122         typedef ci::MultiLevelHashSet< gc_type, Item<hash_type>, traits > set_type;
123         static_assert(std::is_same< typename set_type::hash_type, size_t>::value, "set::hash_type != size_t!!!" );
124         test_hp<set_type, std::hash<hash_type>>(4, 2);
125
126         typedef ci::MultiLevelHashSet<
127             gc_type,
128             Item<hash_type>,
129             typename ci::multilevel_hashset::make_traits<
130                 ci::multilevel_hashset::hash_accessor< get_hash<hash_type>>
131                 , ci::opt::disposer< item_disposer >
132                 ,co::stat< ci::multilevel_hashset::stat<>>
133             >::type
134         > set_type2;
135         test_hp<set_type2, std::hash<hash_type>>(4, 2);
136     }
137
138     void IntrusiveMultiLevelHashSetHdrTest::hp_hash128_stat()
139     {
140         typedef hash128 hash_type;
141
142         struct traits: public ci::multilevel_hashset::traits
143         {
144             typedef get_hash<hash_type> hash_accessor;
145             typedef item_disposer disposer;
146             typedef hash128::cmp  compare;
147             typedef ci::multilevel_hashset::stat<> stat;
148         };
149         typedef ci::MultiLevelHashSet< gc_type, Item<hash_type>, traits > set_type;
150         static_assert(std::is_same< typename set_type::hash_type, hash_type>::value, "set::hash_type != hash_type!!!" );
151         test_hp<set_type, hash_type::make>(4, 2);
152
153         typedef ci::MultiLevelHashSet<
154             gc_type,
155             Item<hash_type>,
156             typename ci::multilevel_hashset::make_traits<
157                 ci::multilevel_hashset::hash_accessor< get_hash<hash_type>>
158                 , ci::opt::disposer< item_disposer >
159                 ,co::stat< ci::multilevel_hashset::stat<>>
160                 ,co::compare< hash128::cmp >
161             >::type
162         > set_type2;
163         test_hp<set_type2, hash_type::make>(4, 2);
164     }
165
166     void IntrusiveMultiLevelHashSetHdrTest::hp_nohash_5_3()
167     {
168         typedef size_t key_type;
169
170         struct traits : public ci::multilevel_hashset::traits
171         {
172             typedef get_key<key_type> hash_accessor;
173             typedef item_disposer disposer;
174         };
175         typedef ci::MultiLevelHashSet< gc_type, Item<key_type>, traits > set_type;
176         static_assert(std::is_same< typename set_type::hash_type, size_t>::value, "set::hash_type != size_t!!!");
177         test_hp<set_type, nohash<key_type>>(5, 3);
178
179         typedef ci::MultiLevelHashSet<
180             gc_type,
181             Item<key_type>,
182             typename ci::multilevel_hashset::make_traits<
183             ci::multilevel_hashset::hash_accessor< get_key<key_type>>
184             , ci::opt::disposer< item_disposer >
185             >::type
186         > set_type2;
187         test_hp<set_type2, nohash<key_type>>(5, 3);
188     }
189
190     void IntrusiveMultiLevelHashSetHdrTest::hp_stdhash_5_3()
191     {
192         typedef size_t hash_type;
193
194         struct traits: public ci::multilevel_hashset::traits
195         {
196             typedef get_hash<hash_type> hash_accessor;
197             typedef item_disposer disposer;
198         };
199         typedef ci::MultiLevelHashSet< gc_type, Item<hash_type>, traits > set_type;
200         static_assert(std::is_same< typename set_type::hash_type, size_t>::value, "set::hash_type != size_t!!!" );
201         test_hp<set_type, std::hash<hash_type>>(5, 3);
202
203         typedef ci::MultiLevelHashSet<
204             gc_type,
205             Item<hash_type>,
206             typename ci::multilevel_hashset::make_traits<
207                 ci::multilevel_hashset::hash_accessor< get_hash<hash_type>>
208                 , ci::opt::disposer< item_disposer >
209             >::type
210         > set_type2;
211         test_hp<set_type2, std::hash<hash_type>>(5, 3);
212     }
213
214     void IntrusiveMultiLevelHashSetHdrTest::hp_hash128_4_3()
215     {
216         typedef hash128 hash_type;
217
218         struct traits: public ci::multilevel_hashset::traits
219         {
220             typedef get_hash<hash_type> hash_accessor;
221             typedef item_disposer disposer;
222             typedef co::v::sequential_consistent memory_model;
223         };
224         typedef ci::MultiLevelHashSet< gc_type, Item<hash_type>, traits > set_type;
225         static_assert(std::is_same< typename set_type::hash_type, hash_type>::value, "set::hash_type != hash_type!!!" );
226         test_hp<set_type, hash128::make >(4, 3);
227
228         typedef ci::MultiLevelHashSet<
229             gc_type,
230             Item<hash_type>,
231             typename ci::multilevel_hashset::make_traits<
232                 ci::multilevel_hashset::hash_accessor< get_hash<hash_type>>
233                 , ci::opt::disposer< item_disposer >
234                 ,co::memory_model< co::v::sequential_consistent >
235             >::type
236         > set_type2;
237         test_hp<set_type2, hash128::make >(4, 3);
238     }
239
240     void IntrusiveMultiLevelHashSetHdrTest::hp_nohash_5_3_stat()
241     {
242         typedef size_t key_type;
243
244         struct traits: public ci::multilevel_hashset::traits
245         {
246             typedef get_key<key_type> hash_accessor;
247             typedef item_disposer disposer;
248             typedef ci::multilevel_hashset::stat<> stat;
249         };
250         typedef ci::MultiLevelHashSet< gc_type, Item<key_type>, traits > set_type;
251         static_assert(std::is_same< typename set_type::hash_type, size_t>::value, "set::hash_type != size_t!!!" );
252         test_hp<set_type, nohash<key_type>>(5, 3);
253
254         typedef ci::MultiLevelHashSet<
255             gc_type,
256             Item<key_type>,
257             typename ci::multilevel_hashset::make_traits<
258                 ci::multilevel_hashset::hash_accessor< get_key<key_type>>
259                 , ci::opt::disposer< item_disposer >
260                 ,co::stat< ci::multilevel_hashset::stat<>>
261             >::type
262         > set_type2;
263         test_hp<set_type2, nohash<key_type>>(5, 3);
264     }
265
266     void IntrusiveMultiLevelHashSetHdrTest::hp_stdhash_5_3_stat()
267     {
268         typedef size_t hash_type;
269
270         struct traits: public ci::multilevel_hashset::traits
271         {
272             typedef get_hash<hash_type> hash_accessor;
273             typedef item_disposer disposer;
274             typedef ci::multilevel_hashset::stat<> stat;
275         };
276         typedef ci::MultiLevelHashSet< gc_type, Item<hash_type>, traits > set_type;
277         static_assert(std::is_same< typename set_type::hash_type, size_t>::value, "set::hash_type != size_t!!!" );
278         test_hp<set_type, std::hash<hash_type>>(5, 3);
279
280         typedef ci::MultiLevelHashSet<
281             gc_type,
282             Item<hash_type>,
283             typename ci::multilevel_hashset::make_traits<
284                 ci::multilevel_hashset::hash_accessor< get_hash<hash_type>>
285                 , ci::opt::disposer< item_disposer >
286                 ,co::stat< ci::multilevel_hashset::stat<>>
287             >::type
288         > set_type2;
289         test_hp<set_type2, std::hash<hash_type>>(5, 3);
290     }
291
292     void IntrusiveMultiLevelHashSetHdrTest::hp_hash128_4_3_stat()
293     {
294         typedef hash128 hash_type;
295
296         struct traits: public ci::multilevel_hashset::traits
297         {
298             typedef get_hash<hash_type> hash_accessor;
299             typedef item_disposer disposer;
300             typedef ci::multilevel_hashset::stat<> stat;
301             typedef hash128::less less;
302             typedef hash128::cmp compare;
303         };
304         typedef ci::MultiLevelHashSet< gc_type, Item<hash_type>, traits > set_type;
305         static_assert(std::is_same< typename set_type::hash_type, hash_type>::value, "set::hash_type != hash_type!!!" );
306         test_hp<set_type, hash_type::make>(4, 3);
307
308         typedef ci::MultiLevelHashSet<
309             gc_type,
310             Item<hash_type>,
311             typename ci::multilevel_hashset::make_traits<
312                 ci::multilevel_hashset::hash_accessor< get_hash<hash_type>>
313                 , ci::opt::disposer< item_disposer >
314                 , co::stat< ci::multilevel_hashset::stat<>>
315                 , co::less< hash_type::less >
316                 , co::compare< hash128::cmp >
317             >::type
318         > set_type2;
319         test_hp<set_type2, hash_type::make>(4, 3);
320     }
321
322 } // namespace set
323
324 CPPUNIT_TEST_SUITE_REGISTRATION(set::IntrusiveMultiLevelHashSetHdrTest);