]> git.ipfire.org Git - thirdparty/gcc.git/blob - libstdc++-v3/testsuite/ext/pb_ds/regression/list_update_set_rand_debug.cc
Update copyright years.
[thirdparty/gcc.git] / libstdc++-v3 / testsuite / ext / pb_ds / regression / list_update_set_rand_debug.cc
1 // { dg-require-debug-mode "" }
2 // { dg-require-time "" }
3 // { dg-timeout-factor 2.0 }
4
5 // -*- C++ -*-
6
7 // Copyright (C) 2011-2021 Free Software Foundation, Inc.
8 //
9 // This file is part of the GNU ISO C++ Library. This library is free
10 // software; you can redistribute it and/or modify it under the terms
11 // of the GNU General Public License as published by the Free Software
12 // Foundation; either version 3, or (at your option) any later
13 // version.
14
15 // This library is distributed in the hope that it will be useful, but
16 // WITHOUT ANY WARRANTY; without even the implied warranty of
17 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
18 // General Public License for more details.
19
20 // You should have received a copy of the GNU General Public License
21 // along with this library; see the file COPYING3. If not see
22 // <http://www.gnu.org/licenses/>.
23
24 /**
25 * @file list_update_data_map_rand_debug.cc
26 * Contains a random-operation test for maps and sets, separated out.
27 */
28
29 #define PB_DS_REGRESSION
30 //#define PB_DS_REGRESSION_TRACE
31
32 #include <regression/rand/assoc/rand_regression_test.hpp>
33 #include <regression/common_type.hpp>
34 #include <ext/throw_allocator.h>
35 #include <ext/pb_ds/tag_and_trait.hpp>
36
37 // Debug version of the rand regression tests, based on list_update_data_map.
38
39 // 1
40 // Simplify things by unrolling the typelist of the different
41 // container types into individual statements.
42 //
43 // Unroll the typelist represented by list_update_types, from
44 // regression/common_type.hpp. This is just a compile-time list of
45 // list_update types, with different policies for the type of
46 // update (lu_move_to_front_policy, lu_counter_policy).
47
48 using namespace __gnu_pbds::test::detail;
49 using namespace __gnu_pbds;
50 typedef __gnu_pbds::test::basic_type basic_type;
51 typedef __gnu_cxx::throw_allocator_random<basic_type> allocator_type;
52 typedef std::equal_to<basic_type> equal_type;
53
54 typedef __gnu_pbds::test::lu_move_to_front_policy_t_ policy_type1;
55
56 typedef __gnu_pbds::test::lu_counter_policy_t_<allocator_type, 5u>
57 policy_type2;
58
59
60 typedef list_update<basic_type, null_type, equal_type, policy_type1,
61 allocator_type>
62 list_type1;
63
64 typedef list_update<basic_type, null_type, equal_type, policy_type2,
65 allocator_type>
66 list_type2;
67
68 // 2
69 // Specialize container_rand_regression_test for specific container
70 // type and test function.
71
72 #ifdef SPECIALIZE
73 // For testing one specific container type.
74 typedef list_type1 test_type;
75
76 void debug_break_here() { }
77
78 namespace __gnu_pbds {
79 namespace test {
80 namespace detail {
81
82 template<>
83 void
84 container_rand_regression_test<test_type>::operator()()
85 {
86 }
87
88 }
89 }
90 }
91 #endif
92
93 int
94 main()
95 {
96 // Set up the test object.
97 size_t sd = 1303948889;
98 rand_reg_test test(sd, 50, 10, .2, .6, .2, .001, .25, true);
99
100 // 1
101 // Determine the problem container, function that fails.
102 test(list_type1());
103 test(list_type2());
104
105 #ifdef SPECIALIZE
106 // 2
107 // With specified problem container set test_type typedef
108 // appropriately above. Then, specialize operator()(), also
109 // above. Finally, run this below.
110 using namespace std;
111 test_type obj;
112 test(obj);
113 #endif
114
115 return 0;
116 }