]>
git.ipfire.org Git - thirdparty/gcc.git/blob - libstdc++-v3/testsuite/25_algorithms/shuffle/1.cc
1 // { dg-options "-std=gnu++0x" }
2 // { dg-require-cstdint "" }
4 // 2010-03-19 Paolo Carlini <paolo.carlini@oracle.com>
6 // Copyright (C) 2010-2013 Free Software Foundation, Inc.
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)
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.
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/>.
26 #include <testsuite_hooks.h>
30 bool test
__attribute__((unused
)) = true;
32 for (unsigned size
= 0; size
< 50; ++size
)
34 std::vector
<int> vref(size
);
35 std::iota(vref
.begin(), vref
.end(), 0);
36 std::vector
<int> v1(vref
), v2(vref
);
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
);
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()) );
49 for (unsigned ind
= 0; ind
< size
; ++ind
)
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() );