1 // Copyright (C) 2013-2018 Free Software Foundation, Inc.
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
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>
26 template<typename ContainerType
, typename Tester
, typename RandomGen
>
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
);
40 template<typename ContainerType
, typename Tester
, typename RandomGen
>
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
)
51 for(int i
= 0; i
< length
; ++i
)
55 for(int i
= 0; i
< length
; ++i
)
60 template<typename ContainerType
, typename Tester
>
62 test_containers(Tester test
)
64 std::mt19937_64 random_gen
;
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);
95 } // namespace __gnu_test