Added copyright and license
[libcds.git] / tests / test-hdr / list / hdr_intrusive_lazy_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 "list/hdr_intrusive_lazy.h"
32 #include <cds/intrusive/lazy_list_hp.h>
33
34 namespace ordlist {
35     void IntrusiveLazyListHeaderTest::HP_base_cmp()
36     {
37         typedef base_int_item< cds::gc::HP > item;
38         struct traits : public ci::lazy_list::traits
39         {
40             typedef ci::lazy_list::base_hook< co::gc<cds::gc::HP> > hook;
41             typedef cmp<item> compare;
42             typedef faked_disposer disposer;
43         };
44         typedef ci::LazyList< cds::gc::HP, item, traits > list;
45         test_int<list>();
46     }
47     void IntrusiveLazyListHeaderTest::HP_base_less()
48     {
49         typedef base_int_item< cds::gc::HP > item;
50         typedef ci::LazyList< cds::gc::HP
51             ,item
52             ,ci::lazy_list::make_traits<
53                 ci::opt::hook< ci::lazy_list::base_hook< co::gc<cds::gc::HP> > >
54                 ,co::less< less<item> >
55                 ,ci::opt::disposer< faked_disposer >
56             >::type
57         >    list;
58         test_int<list>();
59     }
60     void IntrusiveLazyListHeaderTest::HP_base_cmpmix()
61     {
62         typedef base_int_item< cds::gc::HP > item;
63         typedef ci::LazyList< cds::gc::HP
64             ,item
65             ,ci::lazy_list::make_traits<
66                 ci::opt::hook< ci::lazy_list::base_hook< co::gc<cds::gc::HP> > >
67                 ,co::less< less<item> >
68                 ,co::compare< cmp<item> >
69                 ,ci::opt::disposer< faked_disposer >
70             >::type
71         >    list;
72         test_int<list>();
73     }
74     void IntrusiveLazyListHeaderTest::HP_base_ic()
75     {
76         typedef base_int_item< cds::gc::HP > item;
77         typedef ci::LazyList< cds::gc::HP
78             ,item
79             ,ci::lazy_list::make_traits<
80                 ci::opt::hook< ci::lazy_list::base_hook< co::gc<cds::gc::HP> > >
81                 ,co::less< less<item> >
82                 ,co::compare< cmp<item> >
83                 ,ci::opt::disposer< faked_disposer >
84                 ,co::item_counter< cds::atomicity::item_counter >
85             >::type
86         >    list;
87         test_int<list>();
88     }
89     void IntrusiveLazyListHeaderTest::HP_member_cmp()
90     {
91         typedef member_int_item< cds::gc::HP > item;
92         typedef ci::LazyList< cds::gc::HP
93             ,item
94             ,ci::lazy_list::make_traits<
95                 ci::opt::hook< ci::lazy_list::member_hook<
96                     offsetof( item, hMember ),
97                     co::gc<cds::gc::HP>
98                 > >
99                 ,co::compare< cmp<item> >
100                 ,ci::opt::disposer< faked_disposer >
101             >::type
102         >    list;
103         test_int<list>();
104     }
105     void IntrusiveLazyListHeaderTest::HP_member_less()
106     {
107         typedef member_int_item< cds::gc::HP > item;
108         struct traits : public ci::lazy_list::traits
109         {
110             typedef ci::lazy_list::member_hook< offsetof( item, hMember ), co::gc<cds::gc::HP>> hook;
111             typedef IntrusiveLazyListHeaderTest::less<item> less;
112             typedef faked_disposer disposer;
113         };
114         typedef ci::LazyList< cds::gc::HP, item, traits > list;
115         test_int<list>();
116     }
117     void IntrusiveLazyListHeaderTest::HP_member_cmpmix()
118     {
119         typedef member_int_item< cds::gc::HP > item;
120         typedef ci::LazyList< cds::gc::HP
121             ,item
122             ,ci::lazy_list::make_traits<
123                 ci::opt::hook< ci::lazy_list::member_hook<
124                     offsetof( item, hMember ),
125                     co::gc<cds::gc::HP>
126                 > >
127                 ,co::less< less<item> >
128                 ,co::compare< cmp<item> >
129                 ,ci::opt::disposer< faked_disposer >
130             >::type
131         >    list;
132         test_int<list>();
133     }
134     void IntrusiveLazyListHeaderTest::HP_member_ic()
135     {
136         typedef member_int_item< cds::gc::HP > item;
137         typedef ci::LazyList< cds::gc::HP
138             ,item
139             ,ci::lazy_list::make_traits<
140                 ci::opt::hook< ci::lazy_list::member_hook<
141                     offsetof( item, hMember ),
142                     co::gc<cds::gc::HP>
143                 > >
144                 ,co::compare< cmp<item> >
145                 ,ci::opt::disposer< faked_disposer >
146                 ,co::item_counter< cds::atomicity::item_counter >
147             >::type
148         >    list;
149         test_int<list>();
150     }
151 }   // namespace ordlist
152
153 CPPUNIT_TEST_SUITE_REGISTRATION(ordlist::IntrusiveLazyListHeaderTest);