Add michael set test with unordered lazy list.
[libcds.git] / tests / test-hdr / set / hdr_michael_set_lazy_nogc.cpp
1 //$$CDS-header$$
2
3 #include "set/hdr_set.h"
4 #include <cds/container/lazy_list_nogc.h>
5 #include <cds/container/michael_set_nogc.h>
6
7 namespace set {
8
9     namespace {
10         struct set_traits: public cc::michael_set::traits
11         {
12             typedef HashSetHdrTest::hash_int            hash;
13             typedef HashSetHdrTest::simple_item_counter item_counter;
14         };
15
16         struct nogc_cmp_traits: public cc::lazy_list::traits
17         {
18             typedef HashSetHdrTest::cmp<HashSetHdrTest::item>   compare;
19         };
20
21         struct nogc_less_traits: public cc::lazy_list::traits
22         {
23             typedef HashSetHdrTest::less<HashSetHdrTest::item>   less;
24         };
25
26         struct nogc_equal_traits: public cc::lazy_list::traits
27         {
28             typedef HashSetHdrTest::equal<HashSetHdrTest::item>   equal_to;
29             static const bool sort = false;
30         };
31
32         struct nogc_cmpmix_traits: public cc::lazy_list::traits
33         {
34             typedef HashSetHdrTest::cmp<HashSetHdrTest::item>   compare;
35             typedef HashSetHdrTest::less<HashSetHdrTest::item>   less;
36         };
37     }
38
39     void HashSetHdrTest::Lazy_nogc_cmp()
40     {
41         typedef cc::LazyList< cds::gc::nogc, item, nogc_cmp_traits > list;
42
43         // traits-based version
44         typedef cc::MichaelHashSet< cds::gc::nogc, list, set_traits > set;
45         test_int_nogc< set >();
46
47         // option-based version
48         typedef cc::MichaelHashSet< cds::gc::nogc, list,
49             cc::michael_set::make_traits<
50                 cc::opt::hash< hash_int >
51                 ,cc::opt::item_counter< simple_item_counter >
52             >::type
53         > opt_set;
54         test_int_nogc< opt_set >();
55     }
56
57     void HashSetHdrTest::Lazy_nogc_less()
58     {
59         typedef cc::LazyList< cds::gc::nogc, item, nogc_less_traits > list;
60
61         // traits-based version
62         typedef cc::MichaelHashSet< cds::gc::nogc, list, set_traits > set;
63         test_int_nogc< set >();
64
65         // option-based version
66         typedef cc::MichaelHashSet< cds::gc::nogc, list,
67             cc::michael_set::make_traits<
68                 cc::opt::hash< hash_int >
69                 ,cc::opt::item_counter< simple_item_counter >
70             >::type
71         > opt_set;
72         test_int_nogc< opt_set >();
73     }
74
75     void HashSetHdrTest::Lazy_nogc_equal()
76     {
77         typedef cc::LazyList< cds::gc::nogc, item, nogc_equal_traits > list;
78
79         // traits-based version
80         typedef cc::MichaelHashSet< cds::gc::nogc, list, set_traits > set;
81         test_int_nogc_unordered< set >();
82
83         // option-based version
84         typedef cc::MichaelHashSet< cds::gc::nogc, list,
85             cc::michael_set::make_traits<
86                 cc::opt::hash< hash_int >
87                 ,cc::opt::item_counter< simple_item_counter >
88             >::type
89         > opt_set;
90         test_int_nogc_unordered< opt_set >();
91     }
92
93     void HashSetHdrTest::Lazy_nogc_cmpmix()
94     {
95         typedef cc::LazyList< cds::gc::nogc, item, nogc_cmpmix_traits > list;
96
97         // traits-based version
98         typedef cc::MichaelHashSet< cds::gc::nogc, list, set_traits > set;
99         test_int_nogc< set >();
100
101         // option-based version
102         typedef cc::MichaelHashSet< cds::gc::nogc, list,
103             cc::michael_set::make_traits<
104                 cc::opt::hash< hash_int >
105                 ,cc::opt::item_counter< simple_item_counter >
106             >::type
107         > opt_set;
108         test_int_nogc< opt_set >();
109     }
110
111
112 } // namespace set