]>
Commit | Line | Data |
---|---|---|
52066eae | 1 | // { dg-do run { target c++11 } } |
247d8075 PC |
2 | // { dg-require-cstdint "" } |
3 | ||
4 | // 2010-03-19 Paolo Carlini <paolo.carlini@oracle.com> | |
5 | ||
818ab71a | 6 | // Copyright (C) 2010-2016 Free Software Foundation, Inc. |
247d8075 PC |
7 | // |
8 | // This file is part of the GNU ISO C++ Library. This library is free | |
9 | // software; you can redistribute it and/or modify it under the | |
10 | // terms of the GNU General Public License as published by the | |
11 | // Free Software Foundation; either version 3, or (at your option) | |
12 | // any later version. | |
13 | ||
14 | // This library is distributed in the hope that it will be useful, | |
15 | // but WITHOUT ANY WARRANTY; without even the implied warranty of | |
16 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
17 | // GNU General Public License for more details. | |
18 | ||
19 | // You should have received a copy of the GNU General Public License along | |
20 | // with this library; see the file COPYING3. If not see | |
21 | // <http://www.gnu.org/licenses/>. | |
22 | ||
23 | #include <algorithm> | |
24 | #include <random> | |
25 | #include <vector> | |
26 | #include <testsuite_hooks.h> | |
27 | ||
28 | void test01() | |
29 | { | |
30 | bool test __attribute__((unused)) = true; | |
31 | ||
32 | for (unsigned size = 0; size < 50; ++size) | |
33 | { | |
34 | std::vector<int> vref(size); | |
35 | std::iota(vref.begin(), vref.end(), 0); | |
36 | std::vector<int> v1(vref), v2(vref); | |
37 | ||
38 | std::ranlux48_base g1(size), g2(size + 1); | |
39 | std::shuffle(v1.begin(), v1.end(), g1); | |
40 | std::shuffle(v2.begin(), v2.end(), g2); | |
41 | ||
42 | if (size >= 10) | |
43 | { | |
44 | VERIFY( !std::equal(v1.begin(), v1.end(), vref.begin()) ); | |
45 | VERIFY( !std::equal(v2.begin(), v2.end(), vref.begin()) ); | |
46 | VERIFY( !std::equal(v1.begin(), v1.end(), v2.begin()) ); | |
47 | } | |
48 | ||
49 | for (unsigned ind = 0; ind < size; ++ind) | |
50 | { | |
51 | auto it1 = std::find(v1.begin(), v1.end(), vref[ind]); | |
52 | auto it2 = std::find(v2.begin(), v2.end(), vref[ind]); | |
53 | VERIFY( it1 != v1.end() ); | |
54 | VERIFY( it2 != v2.end() ); | |
55 | v1.erase(it1); | |
56 | v2.erase(it2); | |
57 | } | |
58 | VERIFY( v1.empty() ); | |
59 | VERIFY( v2.empty() ); | |
60 | } | |
61 | } | |
62 | ||
63 | int main() | |
64 | { | |
65 | test01(); | |
66 | return 0; | |
67 | } |