Fixed minor gcc warnings
[libcds.git] / test / unit / map / feldman_hashmap_dhp.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_feldman_hashmap_hp.h"
32
33 #include <cds/container/feldman_hashmap_dhp.h>
34
35 namespace {
36     namespace cc = cds::container;
37     typedef cds::gc::DHP gc_type;
38
39     class FeldmanHashMap_DHP : public cds_test::feldman_hashmap_hp
40     {
41     protected:
42         typedef cds_test::feldman_hashmap_hp base_class;
43
44         void SetUp()
45         {
46             typedef cc::FeldmanHashMap< gc_type, key_type, value_type > map_type;
47
48             // +1 - for guarded_ptr
49             cds::gc::dhp::GarbageCollector::Construct( 16, map_type::c_nHazardPtrCount );
50             cds::threading::Manager::attachThread();
51         }
52
53         void TearDown()
54         {
55             cds::threading::Manager::detachThread();
56             cds::gc::dhp::GarbageCollector::Destruct();
57         }
58     };
59
60     TEST_F( FeldmanHashMap_DHP, defaulted )
61     {
62         typedef cc::FeldmanHashMap< gc_type, key_type, value_type > map_type;
63
64         map_type m;
65         test( m );
66     }
67
68     TEST_F( FeldmanHashMap_DHP, compare )
69     {
70         typedef cc::FeldmanHashMap< gc_type, key_type, value_type,
71             typename cc::feldman_hashmap::make_traits<
72                 cds::opt::compare< cmp >
73             >::type
74         > map_type;
75
76         map_type m( 4, 5 );
77         test( m );
78     }
79
80     TEST_F( FeldmanHashMap_DHP, less )
81     {
82         typedef cc::FeldmanHashMap< gc_type, key_type, value_type,
83             typename cc::feldman_hashmap::make_traits<
84                 cds::opt::less< less >
85             >::type
86         > map_type;
87
88         map_type m( 3, 2 );
89         test( m );
90     }
91
92     TEST_F( FeldmanHashMap_DHP, cmpmix )
93     {
94         typedef cc::FeldmanHashMap< gc_type, key_type, value_type,
95             typename cc::feldman_hashmap::make_traits<
96                 cds::opt::less< less >
97                 ,cds::opt::compare< cmp >
98             >::type
99         > map_type;
100
101         map_type m( 4, 4 );
102         test( m );
103     }
104
105     TEST_F( FeldmanHashMap_DHP, backoff )
106     {
107         struct map_traits: public cc::feldman_hashmap::traits
108         {
109             typedef cmp compare;
110             typedef cds::atomicity::item_counter item_counter;
111             typedef cds::backoff::yield back_off;
112         };
113         typedef cc::FeldmanHashMap< gc_type, key_type, value_type, map_traits > map_type;
114
115         map_type m( 8, 2 );
116         test( m );
117     }
118
119     TEST_F( FeldmanHashMap_DHP, stat )
120     {
121         struct map_traits: public cc::feldman_hashmap::traits
122         {
123             typedef cds::backoff::yield back_off;
124             typedef cc::feldman_hashmap::stat<> stat;
125         };
126         typedef cc::FeldmanHashMap< gc_type, key_type, value_type, map_traits > map_type;
127
128         map_type m( 1, 1 );
129         test( m );
130     }
131
132 } // namespace