Added copyright and license
[libcds.git] / tests / test-hdr / map / hdr_feldman_hashmap_hp.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 "map/hdr_feldman_hashmap.h"
32 #include <cds/container/feldman_hashmap_hp.h>
33 #include "unit/print_feldman_hashset_stat.h"
34
35 namespace map {
36     namespace {
37         typedef cds::gc::HP gc_type;
38     } // namespace
39
40     void FeldmanHashMapHdrTest::hp_nohash()
41     {
42         typedef cc::FeldmanHashMap< gc_type, size_t, Item > map_type;
43
44         test_hp<map_type>(4, 2);
45     }
46
47     void FeldmanHashMapHdrTest::hp_stdhash()
48     {
49         struct traits : public cc::feldman_hashmap::traits {
50             typedef std::hash<size_t> hash;
51         };
52         typedef cc::FeldmanHashMap< gc_type, size_t, Item, traits > map_type;
53
54         test_hp<map_type>(4, 2);
55     }
56
57     void FeldmanHashMapHdrTest::hp_hash128()
58     {
59         struct traits : public cc::feldman_hashmap::traits {
60             typedef hash128::make hash;
61             typedef hash128::less less;
62         };
63         typedef cc::FeldmanHashMap< gc_type, size_t, Item, traits > map_type;
64         test_hp<map_type>(4, 2);
65
66         typedef cc::FeldmanHashMap< gc_type, size_t, Item,
67             typename cc::feldman_hashmap::make_traits<
68                 co::hash< hash128::make >
69                 , co::less< hash128::less >
70             >::type
71         > map_type2;
72         test_hp<map_type2>(4, 2);
73     }
74
75     void FeldmanHashMapHdrTest::hp_nohash_stat()
76     {
77         struct traits : public cc::feldman_hashmap::traits {
78             typedef cc::feldman_hashmap::stat<> stat;
79         };
80         typedef cc::FeldmanHashMap< gc_type, size_t, Item, traits > map_type;
81         test_hp<map_type>(4, 2);
82
83         typedef cc::FeldmanHashMap< gc_type, size_t, Item,
84             typename cc::feldman_hashmap::make_traits<
85                 co::stat< cc::feldman_hashmap::stat<>>
86             >::type
87         > map_type2;
88         test_hp<map_type2>(4, 2);
89     }
90
91     void FeldmanHashMapHdrTest::hp_stdhash_stat()
92     {
93         struct traits : public cc::feldman_hashmap::traits {
94             typedef std::hash<size_t> hash;
95             typedef cc::feldman_hashmap::stat<> stat;
96         };
97         typedef cc::FeldmanHashMap< gc_type, size_t, Item, traits > map_type;
98         test_hp<map_type>(4, 2);
99
100         typedef cc::FeldmanHashMap< gc_type, size_t, Item,
101             typename cc::feldman_hashmap::make_traits<
102                 co::stat< cc::feldman_hashmap::stat<>>
103                 ,co::hash< std::hash<size_t>>
104             >::type
105         > map_type2;
106         test_hp<map_type2>(4, 2);
107     }
108
109     void FeldmanHashMapHdrTest::hp_hash128_stat()
110     {
111         struct traits : public cc::feldman_hashmap::traits {
112             typedef cc::feldman_hashmap::stat<> stat;
113             typedef hash128::make hash;
114             typedef hash128::cmp compare;
115         };
116         typedef cc::FeldmanHashMap< gc_type, size_t, Item, traits > map_type;
117         test_hp<map_type>(4, 2);
118
119         typedef cc::FeldmanHashMap< gc_type, size_t, Item,
120             typename cc::feldman_hashmap::make_traits<
121                 co::stat< cc::feldman_hashmap::stat<>>
122                 , co::hash< hash128::make >
123                 , co::compare< hash128::cmp >
124             >::type
125         > map_type2;
126         test_hp<map_type2>(4, 2);
127     }
128
129     void FeldmanHashMapHdrTest::hp_nohash_5_3()
130     {
131         typedef cc::FeldmanHashMap< gc_type, size_t, Item > map_type;
132
133         test_hp<map_type>(5, 3);
134     }
135
136
137     void FeldmanHashMapHdrTest::hp_stdhash_5_3()
138     {
139         struct traits : public cc::feldman_hashmap::traits {
140             typedef std::hash<size_t> hash;
141         };
142         typedef cc::FeldmanHashMap< gc_type, size_t, Item, traits > map_type;
143
144         test_hp<map_type>(5, 3);
145     }
146
147     void FeldmanHashMapHdrTest::hp_nohash_5_3_stat()
148     {
149         struct traits : public cc::feldman_hashmap::traits {
150             typedef cc::feldman_hashmap::stat<> stat;
151             typedef cds::backoff::empty back_off;
152         };
153         typedef cc::FeldmanHashMap< gc_type, size_t, Item, traits > map_type;
154         test_hp<map_type>(5, 3);
155
156         typedef cc::FeldmanHashMap< gc_type, size_t, Item,
157             typename cc::feldman_hashmap::make_traits<
158             co::stat< cc::feldman_hashmap::stat<>>
159             , co::back_off< cds::backoff::empty >
160             >::type
161         > map_type2;
162         test_hp<map_type2>(5, 3);
163     }
164
165     void FeldmanHashMapHdrTest::hp_stdhash_5_3_stat()
166     {
167         struct traits : public cc::feldman_hashmap::traits {
168             typedef cc::feldman_hashmap::stat<> stat;
169             typedef cds::backoff::empty back_off;
170             typedef std::hash<size_t> hash;
171         };
172         typedef cc::FeldmanHashMap< gc_type, size_t, Item, traits > map_type;
173         test_hp<map_type>(5, 3);
174
175         typedef cc::FeldmanHashMap< gc_type, size_t, Item,
176             typename cc::feldman_hashmap::make_traits<
177                 co::stat< cc::feldman_hashmap::stat<>>
178                 ,co::back_off< cds::backoff::empty >
179                 ,co::hash< std::hash<size_t>>
180             >::type
181         > map_type2;
182         test_hp<map_type2>(5, 3);
183     }
184
185     void FeldmanHashMapHdrTest::hp_hash128_4_3()
186     {
187         struct traits : public cc::feldman_hashmap::traits {
188             typedef hash128::make hash;
189             typedef hash128::less less;
190         };
191         typedef cc::FeldmanHashMap< gc_type, size_t, Item, traits > map_type;
192         test_hp<map_type>(4, 3);
193
194         typedef cc::FeldmanHashMap< gc_type, size_t, Item,
195             typename cc::feldman_hashmap::make_traits<
196                 co::hash< hash128::make >
197                 , co::less< hash128::less >
198             >::type
199         > map_type2;
200         test_hp<map_type2>(4, 3);
201     }
202
203     void FeldmanHashMapHdrTest::hp_hash128_4_3_stat()
204     {
205         struct traits : public cc::feldman_hashmap::traits {
206             typedef hash128::make hash;
207             typedef hash128::less less;
208             typedef cc::feldman_hashmap::stat<> stat;
209             typedef co::v::sequential_consistent memory_model;
210         };
211         typedef cc::FeldmanHashMap< gc_type, size_t, Item, traits > map_type;
212         test_hp<map_type>(4, 3);
213
214         typedef cc::FeldmanHashMap< gc_type, size_t, Item,
215             typename cc::feldman_hashmap::make_traits<
216                 co::hash< hash128::make >
217                 , co::less< hash128::less >
218                 , co::stat< cc::feldman_hashmap::stat<>>
219                 , co::memory_model< co::v::sequential_consistent >
220             >::type
221         > map_type2;
222         test_hp<map_type2>(4, 3);
223     }
224 } // namespace map
225
226 CPPUNIT_TEST_SUITE_REGISTRATION(map::FeldmanHashMapHdrTest);