Fixed explicit ctor bugs in stress tests
[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-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_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, random_level_generator )
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::xorshift 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 } // namespace