[SkipList] Added random-lvel generators for max height 32/24/16
[libcds.git] / test / unit / set / skiplist_nogc.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-2017
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_set_nogc.h"
32
33 #include <cds/container/skip_list_set_nogc.h>
34
35 namespace {
36     namespace cc = cds::container;
37     typedef cds::gc::nogc gc_type;
38
39     class SkipListSet_NoGC : public cds_test::container_set_nogc
40     {
41     protected:
42         typedef cds_test::container_set_nogc base_class;
43
44         //void SetUp()
45         //{}
46
47         //void TearDown()
48         //{}
49     };
50
51     TEST_F( SkipListSet_NoGC, compare )
52     {
53         typedef cc::SkipListSet< gc_type, int_item,
54             typename cc::skip_list::make_traits<
55                 cds::opt::compare< cmp >
56             >::type
57         > set_type;
58
59         set_type s;
60         test( s );
61     }
62
63     TEST_F( SkipListSet_NoGC, less )
64     {
65         typedef cc::SkipListSet< gc_type, int_item,
66             typename cc::skip_list::make_traits<
67                 cds::opt::less< base_class::less >
68             >::type
69         > set_type;
70
71         set_type s;
72         test( s );
73     }
74
75     TEST_F( SkipListSet_NoGC, cmpmix )
76     {
77         typedef cc::SkipListSet< gc_type, int_item,
78             typename cc::skip_list::make_traits<
79                 cds::opt::less< base_class::less >
80                 ,cds::opt::compare< cmp >
81             >::type
82         > set_type;
83
84         set_type s;
85         test( s );
86     }
87
88     TEST_F( SkipListSet_NoGC, item_counting )
89     {
90         struct set_traits: public cc::skip_list::traits
91         {
92             typedef cmp compare;
93             typedef base_class::less less;
94             typedef cds::atomicity::item_counter item_counter;
95         };
96         typedef cc::SkipListSet< gc_type, int_item, set_traits >set_type;
97
98         set_type s;
99         test( s );
100     }
101
102     TEST_F( SkipListSet_NoGC, backoff )
103     {
104         struct set_traits: public cc::skip_list::traits
105         {
106             typedef cmp compare;
107             typedef base_class::less less;
108             typedef cds::atomicity::item_counter item_counter;
109             typedef cds::backoff::yield back_off;
110         };
111         typedef cc::SkipListSet< gc_type, int_item, set_traits >set_type;
112
113         set_type s;
114         test( s );
115     }
116
117     TEST_F( SkipListSet_NoGC, stat )
118     {
119         struct set_traits: public cc::skip_list::traits
120         {
121             typedef cmp compare;
122             typedef base_class::less less;
123             typedef cds::atomicity::item_counter item_counter;
124             typedef cds::backoff::yield back_off;
125             typedef cc::skip_list::stat<> stat;
126         };
127         typedef cc::SkipListSet< gc_type, int_item, set_traits >set_type;
128
129         set_type s;
130         test( s );
131     }
132
133     TEST_F( SkipListSet_NoGC, xorshift32 )
134     {
135         struct set_traits: public cc::skip_list::traits
136         {
137             typedef cmp compare;
138             typedef base_class::less less;
139             typedef cds::atomicity::item_counter item_counter;
140             typedef cc::skip_list::stat<> stat;
141             typedef cc::skip_list::xorshift32 random_level_generator;
142         };
143         typedef cc::SkipListSet< gc_type, int_item, set_traits >set_type;
144
145         set_type s;
146         test( s );
147     }
148
149     TEST_F( SkipListSet_NoGC, xorshift24 )
150     {
151         struct set_traits: public cc::skip_list::traits
152         {
153             typedef cmp compare;
154             typedef base_class::less less;
155             typedef cds::atomicity::item_counter item_counter;
156             typedef cc::skip_list::stat<> stat;
157             typedef cc::skip_list::xorshift24 random_level_generator;
158         };
159         typedef cc::SkipListSet< gc_type, int_item, set_traits >set_type;
160
161         set_type s;
162         test( s );
163     }
164
165     TEST_F( SkipListSet_NoGC, xorshift16 )
166     {
167         struct set_traits: public cc::skip_list::traits
168         {
169             typedef cmp compare;
170             typedef base_class::less less;
171             typedef cds::atomicity::item_counter item_counter;
172             typedef cc::skip_list::stat<> stat;
173             typedef cc::skip_list::xorshift16 random_level_generator;
174         };
175         typedef cc::SkipListSet< gc_type, int_item, set_traits >set_type;
176
177         set_type s;
178         test( s );
179     }
180
181     TEST_F( SkipListSet_NoGC, turbo32 )
182     {
183         struct set_traits: public cc::skip_list::traits
184         {
185             typedef cmp compare;
186             typedef base_class::less less;
187             typedef cds::atomicity::item_counter item_counter;
188             typedef cc::skip_list::stat<> stat;
189             typedef cc::skip_list::turbo32 random_level_generator;
190         };
191         typedef cc::SkipListSet< gc_type, int_item, set_traits >set_type;
192
193         set_type s;
194         test( s );
195     }
196
197     TEST_F( SkipListSet_NoGC, turbo24 )
198     {
199         struct set_traits: public cc::skip_list::traits
200         {
201             typedef cmp compare;
202             typedef base_class::less less;
203             typedef cds::atomicity::item_counter item_counter;
204             typedef cc::skip_list::stat<> stat;
205             typedef cc::skip_list::turbo24 random_level_generator;
206         };
207         typedef cc::SkipListSet< gc_type, int_item, set_traits >set_type;
208
209         set_type s;
210         test( s );
211     }
212
213     TEST_F( SkipListSet_NoGC, turbo16 )
214     {
215         struct set_traits: public cc::skip_list::traits
216         {
217             typedef cmp compare;
218             typedef base_class::less less;
219             typedef cds::atomicity::item_counter item_counter;
220             typedef cc::skip_list::stat<> stat;
221             typedef cc::skip_list::turbo16 random_level_generator;
222         };
223         typedef cc::SkipListSet< gc_type, int_item, set_traits >set_type;
224
225         set_type s;
226         test( s );
227     }
228
229 } // namespace