2 This file is a part of libcds - Concurrent Data Structures library
4 (C) Copyright Maxim Khizhinsky (libcds.dev@gmail.com) 2006-2016
6 Source code repo: http://github.com/khizmax/libcds/
7 Download: http://sourceforge.net/projects/libcds/files/
9 Redistribution and use in source and binary forms, with or without
10 modification, are permitted provided that the following conditions are met:
12 * Redistributions of source code must retain the above copyright notice, this
13 list of conditions and the following disclaimer.
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.
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.
31 #ifndef CDSUNIT_LIST_TEST_LAZY_LIST_RCU_H
32 #define CDSUNIT_LIST_TEST_LAZY_LIST_RCU_H
34 #include "test_list_rcu.h"
35 #include <cds/container/lazy_list_rcu.h>
37 namespace cc = cds::container;
40 class LazyList : public cds_test::list_rcu
42 typedef cds_test::list_rcu base_class;
44 typedef cds::urcu::gc<RCU> rcu_type;
50 cds::threading::Manager::attachThread();
55 cds::threading::Manager::detachThread();
60 TYPED_TEST_CASE_P( LazyList );
62 TYPED_TEST_P( LazyList, less_ordered )
64 typedef cc::LazyList< typename TestFixture::rcu_type, typename TestFixture::item,
65 typename cc::lazy_list::make_traits<
66 cds::opt::less< typename TestFixture::template lt< typename TestFixture::item>>
71 this->test_common( l );
72 this->test_ordered_iterator( l );
76 TYPED_TEST_P( LazyList, compare_ordered )
78 typedef cc::LazyList< typename TestFixture::rcu_type, typename TestFixture::item,
79 typename cc::lazy_list::make_traits<
80 cds::opt::compare< typename TestFixture::template cmp< typename TestFixture::item>>
85 this->test_common( l );
86 this->test_ordered_iterator( l );
90 TYPED_TEST_P( LazyList, mix_ordered )
92 typedef cc::LazyList< typename TestFixture::rcu_type, typename TestFixture::item,
93 typename cc::lazy_list::make_traits<
94 cds::opt::less< typename TestFixture::template lt< typename TestFixture::item>>
95 ,cds::opt::compare< typename TestFixture::template cmp< typename TestFixture::item>>
100 this->test_common( l );
101 this->test_ordered_iterator( l );
105 TYPED_TEST_P( LazyList, item_counting )
107 struct traits : public cc::lazy_list::traits
109 typedef typename TestFixture::template lt< typename TestFixture::item> less;
110 typedef cds::atomicity::item_counter item_counter;
112 typedef cc::LazyList<typename TestFixture::rcu_type, typename TestFixture::item, traits > list_type;
115 this->test_common( l );
116 this->test_ordered_iterator( l );
120 TYPED_TEST_P( LazyList, backoff )
122 struct traits : public cc::lazy_list::traits
124 typedef typename TestFixture::template lt< typename TestFixture::item> less;
125 typedef cds::atomicity::item_counter item_counter;
126 typedef cds::backoff::empty back_off;
128 typedef cc::LazyList<typename TestFixture::rcu_type, typename TestFixture::item, traits > list_type;
131 this->test_common( l );
132 this->test_ordered_iterator( l );
136 TYPED_TEST_P( LazyList, seq_cst )
138 struct traits : public cc::lazy_list::traits
140 typedef typename TestFixture::template lt< typename TestFixture::item> less;
141 typedef cds::atomicity::item_counter item_counter;
142 typedef cds::opt::v::sequential_consistent memory_model;
144 typedef cc::LazyList<typename TestFixture::rcu_type, typename TestFixture::item, traits > list_type;
147 this->test_common( l );
148 this->test_ordered_iterator( l );
152 TYPED_TEST_P( LazyList, stat )
154 struct traits: public cc::lazy_list::traits
156 typedef typename TestFixture::template lt< typename TestFixture::item> less;
157 typedef cds::atomicity::item_counter item_counter;
158 typedef cds::container::lazy_list::stat<> stat;
160 typedef cc::LazyList<typename TestFixture::rcu_type, typename TestFixture::item, traits > list_type;
163 this->test_common( l );
164 this->test_ordered_iterator( l );
168 TYPED_TEST_P( LazyList, wrapped_stat )
170 struct traits: public cc::lazy_list::traits
172 typedef typename TestFixture::template lt< typename TestFixture::item> less;
173 typedef cds::atomicity::item_counter item_counter;
174 typedef cds::container::lazy_list::wrapped_stat<> stat;
176 typedef cc::LazyList<typename TestFixture::rcu_type, typename TestFixture::item, traits > list_type;
178 cds::container::lazy_list::stat<> st;
180 this->test_common( l );
181 this->test_ordered_iterator( l );
185 TYPED_TEST_P( LazyList, mutex )
187 struct traits : public cc::lazy_list::traits
189 typedef typename TestFixture::template lt< typename TestFixture::item> less;
190 typedef cds::atomicity::item_counter item_counter;
191 typedef std::mutex lock_type;
193 typedef cc::LazyList<typename TestFixture::rcu_type, typename TestFixture::item, traits > list_type;
196 this->test_common( l );
197 this->test_ordered_iterator( l );
201 // GCC 5: All test names should be written on single line, otherwise a runtime error will be encountered like as
202 // "No test named <test_name> can be found in this test case"
203 REGISTER_TYPED_TEST_CASE_P( LazyList,
204 less_ordered, compare_ordered, mix_ordered, item_counting, backoff, seq_cst, mutex, stat, wrapped_stat
207 #endif // CDSUNIT_LIST_TEST_LAZY_LIST_RCU_H