Reverting merge from trunk
[official-gcc.git] / libstdc++-v3 / testsuite / ext / pb_ds / regression / hash_map_rand_debug.cc
blob929fdcd001826f48d36d15dabec27a75d4c13943
1 // { dg-require-debug-mode "" }
2 // { dg-require-time "" }
3 // This can take long on simulators, timing out the test.
4 // { dg-options "-DITERATIONS=5" { target simulator } }
5 // { dg-timeout-factor 2.0 }
7 // -*- C++ -*-
9 // Copyright (C) 2011-2013 Free Software Foundation, Inc.
11 // This file is part of the GNU ISO C++ Library. This library is free
12 // software; you can redistribute it and/or modify it under the terms
13 // of the GNU General Public License as published by the Free Software
14 // Foundation; either version 3, or (at your option) any later
15 // version.
17 // This library is distributed in the hope that it will be useful, but
18 // WITHOUT ANY WARRANTY; without even the implied warranty of
19 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
20 // General Public License for more details.
22 // You should have received a copy of the GNU General Public License
23 // along with this library; see the file COPYING3. If not see
24 // <http://www.gnu.org/licenses/>.
26 /**
27 * @file hash_data_map_rand.cc
28 * Contains a random-operation test for maps and sets, separated out.
31 #define PB_DS_REGRESSION
32 //#define PB_DS_REGRESSION_TRACE
34 #include <regression/rand/assoc/rand_regression_test.hpp>
35 #include <regression/common_type.hpp>
36 #include <ext/throw_allocator.h>
37 #include <ext/pb_ds/tag_and_trait.hpp>
39 #ifndef ITERATIONS
40 # define ITERATIONS 100
41 #endif
43 #ifndef KEYS
44 # define KEYS 200
45 #endif
47 // Debug version of the rand regression tests, based on hash_data_map_rand
49 // 1
50 // Simplify things by unrolling the typelist of the different
51 // container types into individual statements.
53 // Unroll the typelist represented by priority_queue_types, from
54 // regression/common_type.hpp. This is just a compile-time list of 5
55 // hash tables, with different policies for the type of table
56 // (gp_hash, cc_hash), for the resize policies and probe functions.
57 using namespace __gnu_pbds::test::detail;
58 using namespace __gnu_pbds;
59 typedef __gnu_pbds::test::basic_type basic_type;
60 typedef __gnu_cxx::throw_allocator_random<basic_type> allocator_type;
61 typedef std::equal_to<basic_type> equal_type;
64 typedef __gnu_pbds::test::direct_mod_range_hashing_t_<allocator_type>
65 cprobe_type1;
67 typedef __gnu_pbds::test::direct_mask_range_hashing_t_<allocator_type>
68 cprobe_type2;
71 typedef __gnu_pbds::test::quadratic_probe_fn_t_<basic_type, allocator_type>
72 probe_type1;
74 typedef __gnu_pbds::test::linear_probe_fn_t_<basic_type, allocator_type>
75 probe_type2;
78 typedef __gnu_pbds::test::hash_load_check_resize_trigger_t_<allocator_type,
79 1, 8, 1, 2, false>
80 trigger_type1;
82 typedef __gnu_pbds::test::hash_load_check_resize_trigger_t_<allocator_type,
83 1, 8, 1, 2, true>
84 trigger_type2;
86 typedef __gnu_pbds::test::hash_load_check_resize_trigger_t_<allocator_type,
87 1, 8, 1, 1, false>
88 trigger_type3;
90 typedef __gnu_pbds::test::cc_hash_max_collision_check_resize_trigger_t_<allocator_type, 1, 2, false>
91 trigger_type4;
93 typedef __gnu_pbds::test::cc_hash_max_collision_check_resize_trigger_t_<allocator_type, 1, 2, true>
94 trigger_type5;
97 typedef hash_standard_resize_policy<__gnu_pbds::test::hash_prime_size_policy_t_, trigger_type1, false, unsigned long> resize_type1;
99 typedef hash_standard_resize_policy<__gnu_pbds::test::hash_exponential_size_policy_t_<allocator_type>, trigger_type2, true, unsigned long>
100 resize_type2;
102 typedef hash_standard_resize_policy<__gnu_pbds::test::hash_exponential_size_policy_t_<allocator_type>, trigger_type5, false, unsigned long>
103 resize_type3;
107 // gp_hash 1
108 typedef gp_hash_table<basic_type, basic_type, __gnu_pbds::test::hash,
109 equal_type, cprobe_type1, probe_type1, resize_type1,
110 false, allocator_type>
111 gp_hash_type1;
113 // gp_hash 2
114 typedef gp_hash_table<basic_type, basic_type, __gnu_pbds::test::hash,
115 equal_type, cprobe_type2, probe_type2, resize_type2,
116 true, allocator_type>
117 gp_hash_type2;
120 // cc_hash 1
121 typedef cc_hash_table<basic_type, basic_type, __gnu_pbds::test::hash,
122 equal_type, cprobe_type2, resize_type3,
123 false, allocator_type>
124 cc_hash_type1;
126 // cc_hash 2
127 typedef cc_hash_table<basic_type, basic_type, __gnu_pbds::test::hash,
128 equal_type, cprobe_type2, resize_type2,
129 false, allocator_type>
130 cc_hash_type2;
132 // cc_hash 3
133 typedef cc_hash_table<basic_type, basic_type, __gnu_pbds::test::hash,
134 equal_type, cprobe_type1, resize_type1,
135 true, allocator_type>
136 cc_hash_type3;
138 // 2
139 // Specialize container_rand_regression_test for specific container
140 // type and test function.
142 #ifdef SPECIALIZE
143 // For testing one specific container type.
144 typedef cc_hash_type1 test_type;
146 void debug_break_here() { }
148 namespace __gnu_pbds {
149 namespace test {
150 namespace detail {
152 template<>
153 void
154 container_rand_regression_test<test_type>::operator()()
160 #endif
163 main()
165 // Set up the test object.
166 size_t sd = 1303948889;
167 rand_reg_test test(sd, ITERATIONS, KEYS, 0.2, .6, .2, .001, .25, true);
169 // 1
170 // Determine the problem container, function that fails.
171 test(gp_hash_type1());
172 test(gp_hash_type2());
174 test(cc_hash_type1());
175 test(cc_hash_type2());
176 test(cc_hash_type3());
178 #ifdef SPECIALIZE
179 // 2
180 // With specified problem container set test_type typedef
181 // appropriately above. Then, specialize operator()(), also
182 // above. Finally, run this below.
183 using namespace std;
184 test_type obj;
185 test(obj);
186 #endif
188 return 0;