* config/sparc/sparc.c (sparc_option_override): Set MASK_FSMULD flag
[official-gcc.git] / libstdc++-v3 / testsuite / util / testsuite_containergen.h
bloba87025be56611495254f7300fefc50da552a3e8e
1 // Copyright (C) 2013-2017 Free Software Foundation, Inc.
2 //
3 // This file is part of the GNU ISO C++ Library. This library is free
4 // software; you can redistribute it and/or modify it under the terms
5 // of the GNU General Public License as published by the Free Software
6 // Foundation; either version 3, or (at your option) any later
7 // version.
9 // This library is distributed in the hope that it will be useful, but
10 // WITHOUT ANY WARRANTY; without even the implied warranty of
11 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 // General Public License for more details.
14 // You should have received a copy of the GNU General Public License along
15 // with this library; see the file COPYING3. If not see
16 // <http://www.gnu.org/licenses/>.
18 #ifndef _GLIBCXX_TESTSUITE_CONTAINER_GEN_H
19 #define _GLIBCXX_TESTSUITE_CONTAINER_GEN_H
21 #include <testsuite_container_traits.h>
22 #include <random>
24 namespace __gnu_test
26 template<typename ContainerType, typename Tester, typename RandomGen>
27 void
28 test_single_container(Tester test, RandomGen& rg, int length, int domain)
30 std::vector<int> values;
31 auto dist = std::uniform_int_distribution<>(0, domain - 1);
33 for(int i = 0; i < length; ++i)
34 values.push_back(dist(rg));
36 ContainerType con(values.data(), values.data() + length);
37 test(con, rg);
40 template<typename ContainerType, typename Tester, typename RandomGen>
41 void
42 test_special_containers(Tester test, RandomGen& rg, int length)
44 std::vector<int> values(length);
45 ContainerType con(values.data(), values.data() + length);
47 for(int i = 0; i < length; ++i)
48 values[i] = 0;
49 test(con, rg);
51 for(int i = 0; i < length; ++i)
52 values[i] = i;
53 test(con, rg);
55 for(int i = 0; i < length; ++i)
56 values[i] = -i;
57 test(con, rg);
60 template<typename ContainerType, typename Tester>
61 void
62 test_containers(Tester test)
64 std::mt19937_64 random_gen;
66 #ifdef SIMULATOR_TEST
67 int loops = 10;
68 #else
69 int loops = 1000;
70 #endif
72 for(int i = 0; i < loops; ++i)
73 test_special_containers<ContainerType>(test, random_gen, i);
75 for(int i = 1; i < 100; ++i)
76 for(int j = 0; j < loops; ++j)
77 test_single_container<ContainerType>(test, random_gen, i, i);
79 for(int i = 0; i < loops; ++i)
81 test_single_container<ContainerType>(test, random_gen, 10, 10);
82 test_single_container<ContainerType>(test, random_gen, 100, 10);
83 test_single_container<ContainerType>(test, random_gen, 1000, 10);
84 test_single_container<ContainerType>(test, random_gen, 10, 1000);
87 #ifndef SIMULATOR_TEST
88 for(int i = 0; i < 1000; ++i)
90 test_single_container<ContainerType>(test, random_gen, 10000, 10);
91 test_single_container<ContainerType>(test, random_gen, 10000, 10000);
93 #endif
95 } // namespace __gnu_test
97 #endif