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