2 This file is a part of libcds - Concurrent Data Structures library
4 (C) Copyright Maxim Khizhinsky (libcds.dev@gmail.com) 2006-2017
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 #include "test_map_nogc.h"
33 #include <cds/container/skip_list_map_nogc.h>
36 namespace cc = cds::container;
37 typedef cds::gc::nogc gc_type;
39 class SkipListMap_NoGC : public cds_test::container_map_nogc
42 typedef cds_test::container_map_nogc base_class;
44 template <typename Map>
47 // Precondition: map is empty
48 // Postcondition: map is empty
50 base_class::test( m );
52 ASSERT_TRUE( m.empty());
53 ASSERT_CONTAINER_SIZE( m, 0 );
55 typedef typename Map::value_type map_pair;
56 size_t const kkSize = base_class::kSize;
59 for ( int i = static_cast<int>( kkSize ); i > 0; --i ) {
60 ASSERT_TRUE( m.insert( i ) != m.end());
62 map_pair * p = m.get_min();
63 ASSERT_TRUE( p != nullptr );
64 EXPECT_EQ( p->first.nKey, i );
67 ASSERT_TRUE( p != nullptr );
68 EXPECT_EQ( p->first.nKey, static_cast<int>( kkSize ));
72 ASSERT_TRUE( m.empty());
73 ASSERT_CONTAINER_SIZE( m, 0 );
76 for ( int i = 0; i < static_cast<int>( kkSize ); ++i ) {
77 ASSERT_TRUE( m.insert( i ) != m.end());
79 map_pair * p = m.get_max();
80 ASSERT_TRUE( p != nullptr );
81 EXPECT_EQ( p->first.nKey, i );
84 ASSERT_TRUE( p != nullptr );
85 EXPECT_EQ( p->first.nKey, 0 );
98 TEST_F( SkipListMap_NoGC, compare )
100 typedef cc::SkipListMap< gc_type, key_type, value_type,
101 typename cc::skip_list::make_traits<
102 cds::opt::compare< cmp >
110 TEST_F( SkipListMap_NoGC, less )
112 typedef cc::SkipListMap< gc_type, key_type, value_type,
113 typename cc::skip_list::make_traits<
114 cds::opt::less< base_class::less >
122 TEST_F( SkipListMap_NoGC, cmpmix )
124 typedef cc::SkipListMap< gc_type, key_type, value_type,
125 typename cc::skip_list::make_traits<
126 cds::opt::less< base_class::less >
127 ,cds::opt::compare< cmp >
135 TEST_F( SkipListMap_NoGC, item_counting )
137 struct map_traits: public cc::skip_list::traits
140 typedef base_class::less less;
141 typedef cds::atomicity::item_counter item_counter;
143 typedef cc::SkipListMap< gc_type, key_type, value_type, map_traits > map_type;
149 TEST_F( SkipListMap_NoGC, backoff )
151 struct map_traits: public cc::skip_list::traits
154 typedef base_class::less less;
155 typedef cds::atomicity::item_counter item_counter;
156 typedef cds::backoff::yield back_off;
158 typedef cc::SkipListMap< gc_type, key_type, value_type, map_traits > map_type;
164 TEST_F( SkipListMap_NoGC, stat )
166 struct map_traits: public cc::skip_list::traits
169 typedef base_class::less less;
170 typedef cds::atomicity::item_counter item_counter;
171 typedef cds::backoff::yield back_off;
172 typedef cc::skip_list::stat<> stat;
174 typedef cc::SkipListMap< gc_type, key_type, value_type, map_traits > map_type;
180 TEST_F( SkipListMap_NoGC, random_level_generator )
182 struct map_traits: public cc::skip_list::traits
185 typedef base_class::less less;
186 typedef cds::atomicity::item_counter item_counter;
187 typedef cc::skip_list::stat<> stat;
188 typedef cc::skip_list::xorshift random_level_generator;
190 typedef cc::SkipListMap< gc_type, key_type, value_type, map_traits > map_type;