HP and DHP SMR totally refactored
[libcds.git] / test / unit / intrusive-set / intrusive_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_intrusive_set_nogc.h"
32
33 #include <cds/intrusive/skip_list_nogc.h>
34
35 namespace {
36     namespace ci = cds::intrusive;
37     typedef cds::gc::nogc gc_type;
38
39     class IntrusiveSkipListSet_NoGC : public cds_test::intrusive_set_nogc
40     {
41     protected:
42         typedef cds_test::intrusive_set_nogc base_class;
43
44     protected:
45         typedef typename base_class::base_int_item< ci::skip_list::node< gc_type>>   base_item_type;
46         typedef typename base_class::member_int_item< ci::skip_list::node< gc_type>> member_item_type;
47
48         //void SetUp()
49         //{}
50
51         //void TearDown()
52         //{}
53     };
54
55
56     TEST_F( IntrusiveSkipListSet_NoGC, base_cmp )
57     {
58         struct traits : public ci::skip_list::traits
59         {
60             typedef ci::skip_list::base_hook< ci::opt::gc< gc_type >> hook;
61             typedef mock_disposer disposer;
62             typedef cmp<base_item_type> compare;
63         };
64
65         typedef ci::SkipListSet< gc_type, base_item_type, traits > set_type;
66
67         set_type s;
68         test( s );
69     }
70
71     TEST_F( IntrusiveSkipListSet_NoGC, base_less )
72     {
73         struct traits : public ci::skip_list::traits
74         {
75             typedef ci::skip_list::base_hook< ci::opt::gc< gc_type >> hook;
76             typedef mock_disposer disposer;
77             typedef base_class::less<base_item_type> less;
78             typedef cds::atomicity::item_counter item_counter;
79         };
80
81         typedef ci::SkipListSet< gc_type, base_item_type, traits > set_type;
82
83         set_type s;
84         test( s );
85     }
86
87     TEST_F( IntrusiveSkipListSet_NoGC, base_cmpmix )
88     {
89         struct traits : public ci::skip_list::traits
90         {
91             typedef ci::skip_list::base_hook< ci::opt::gc< gc_type >> hook;
92             typedef mock_disposer disposer;
93             typedef cmp<base_item_type> compare;
94             typedef base_class::less<base_item_type> less;
95             typedef ci::skip_list::stat<> stat;
96         };
97
98         typedef ci::SkipListSet< gc_type, base_item_type, traits > set_type;
99
100         set_type s;
101         test( s );
102     }
103
104     TEST_F( IntrusiveSkipListSet_NoGC, base_xorshift )
105     {
106         struct traits : public ci::skip_list::traits
107         {
108             typedef ci::skip_list::base_hook< ci::opt::gc< gc_type >> hook;
109             typedef mock_disposer disposer;
110             typedef cmp<base_item_type> compare;
111             typedef ci::skip_list::xorshift random_level_generator;
112         };
113
114         typedef ci::SkipListSet< gc_type, base_item_type, traits > set_type;
115
116         set_type s;
117         test( s );
118     }
119
120
121     TEST_F( IntrusiveSkipListSet_NoGC, member_cmp )
122     {
123         struct traits : public ci::skip_list::traits
124         {
125             typedef ci::skip_list::member_hook< offsetof(member_item_type, hMember), ci::opt::gc< gc_type >> hook;
126             typedef mock_disposer disposer;
127             typedef cmp<member_item_type> compare;
128         };
129
130         typedef ci::SkipListSet< gc_type, member_item_type, traits > set_type;
131
132         set_type s;
133         test( s );
134     }
135
136     TEST_F( IntrusiveSkipListSet_NoGC, member_less )
137     {
138         struct traits : public ci::skip_list::traits
139         {
140             typedef ci::skip_list::member_hook< offsetof( member_item_type, hMember ), ci::opt::gc< gc_type >> hook;
141             typedef mock_disposer disposer;
142             typedef base_class::less<member_item_type> less;
143             typedef cds::atomicity::item_counter item_counter;
144             typedef ci::opt::v::sequential_consistent memory_model;
145         };
146
147         typedef ci::SkipListSet< gc_type, member_item_type, traits > set_type;
148
149         set_type s;
150         test( s );
151     }
152
153     TEST_F( IntrusiveSkipListSet_NoGC, member_cmpmix )
154     {
155         struct traits : public ci::skip_list::traits
156         {
157             typedef ci::skip_list::member_hook< offsetof( member_item_type, hMember ), ci::opt::gc< gc_type >> hook;
158             typedef mock_disposer disposer;
159             typedef cmp<member_item_type> compare;
160             typedef base_class::less<member_item_type> less;
161             typedef ci::skip_list::stat<> stat;
162         };
163
164         typedef ci::SkipListSet< gc_type, member_item_type, traits > set_type;
165
166         set_type s;
167         test( s );
168     }
169
170     TEST_F( IntrusiveSkipListSet_NoGC, member_xorshift )
171     {
172         struct traits : public ci::skip_list::traits
173         {
174             typedef ci::skip_list::member_hook< offsetof( member_item_type, hMember ), ci::opt::gc< gc_type >> hook;
175             typedef mock_disposer disposer;
176             typedef cmp<member_item_type> compare;
177             typedef ci::skip_list::xorshift random_level_generator;
178         };
179
180         typedef ci::SkipListSet< gc_type, member_item_type, traits > set_type;
181
182         set_type s;
183         test( s );
184     }
185
186 } // namespace