]> git.ipfire.org Git - thirdparty/gcc.git/blob - libstdc++-v3/testsuite/ext/pb_ds/regression/priority_queue_rand_debug.cc
Update copyright years.
[thirdparty/gcc.git] / libstdc++-v3 / testsuite / ext / pb_ds / regression / priority_queue_rand_debug.cc
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 }
6
7 // -*- C++ -*-
8
9 // Copyright (C) 2011-2024 Free Software Foundation, Inc.
10 //
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.
16
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.
21
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/>.
25
26 /**
27 * @file priority_queue_rand_debug.cc
28 * Contains a random-operation test for priority queues.
29 */
30
31 #define PB_DS_REGRESSION
32 //#define PB_DS_REGRESSION_TRACE
33
34 #include <regression/rand/priority_queue/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>
38
39 #ifndef ITERATIONS
40 # define ITERATIONS 500
41 #endif
42
43 #ifndef KEYS
44 # define KEYS 1000
45 #endif
46
47 // Debug version of the rand regression tests, based on priority_queue_rand
48
49 // 1
50 // Simplify things by unrolling the typelist of the different
51 // container types into individual statements.
52 //
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 // priority_queue types, with different policies for the type of priority_queue
56 // (pairing_heap_tag, binomial_heap_tag, rc_binomial_heap_tag,
57 // binary_heap_tag, thin_heap_tag).
58
59 using namespace __gnu_pbds::test::detail;
60 using namespace __gnu_pbds;
61 typedef __gnu_pbds::test::basic_type basic_type;
62 typedef __gnu_cxx::throw_allocator_random<basic_type> allocator_type;
63
64 // pairing_heap_tag
65 typedef priority_queue<basic_type, std::less<basic_type>,
66 pairing_heap_tag, allocator_type>
67 priority_queue_type1;
68
69 // binomial_heap_tag
70 typedef priority_queue<basic_type, std::less<basic_type>,
71 binomial_heap_tag, allocator_type>
72 priority_queue_type2;
73
74 // rc_binomial_heap_tag
75 typedef priority_queue<basic_type, std::less<basic_type>,
76 rc_binomial_heap_tag, allocator_type>
77 priority_queue_type3;
78
79 // binary_heap_tag
80 typedef priority_queue<basic_type, std::less<basic_type>,
81 binary_heap_tag, allocator_type>
82 priority_queue_type4;
83
84 // thin_heap_tag
85 typedef priority_queue<basic_type, std::less<basic_type>,
86 thin_heap_tag, allocator_type>
87 priority_queue_type5;
88
89
90 // 2
91 // Specialize container_rand_regression_test for specific container
92 // type and test function.
93
94 #ifdef SPECIALIZE
95 // For testing one specific container type.
96 typedef priority_queue_type4 test_type;
97
98 void debug_break_here() { }
99
100 namespace __gnu_pbds {
101 namespace test {
102 namespace detail {
103
104 template<>
105 void
106 container_rand_regression_test<test_type>::operator()()
107 {
108
109 }
110
111 }
112 }
113 }
114 #endif
115
116 int
117 main()
118 {
119 // Set up the test object.
120 size_t sd = 1304368293;
121 rand_reg_test test(sd, ITERATIONS, KEYS, 0.2, .6, .1, .2, .001, 1, true);
122
123 // 1
124 // Determine the problem container, function that fails.
125 test(priority_queue_type1());
126 test(priority_queue_type2());
127 test(priority_queue_type3());
128 test(priority_queue_type4());
129 test(priority_queue_type5());
130
131 #ifdef SPECIALIZE
132 // 2
133 // With specified problem container set test_type typedef
134 // appropriately above. Then, specialize operator()(), also
135 // above. Finally, run this below.
136 using namespace std;
137 test_type obj;
138 test(obj);
139 #endif
140
141 return 0;
142 }