4232 |
15 Sep 22 |
peter |
// $Id$ |
4232 |
15 Sep 22 |
peter |
2 |
|
4232 |
15 Sep 22 |
peter |
3 |
/* |
4232 |
15 Sep 22 |
peter |
Copyright (C) 2022 Peter Johansson |
4232 |
15 Sep 22 |
peter |
5 |
|
4232 |
15 Sep 22 |
peter |
This file is part of the yat library, http://dev.thep.lu.se/yat |
4232 |
15 Sep 22 |
peter |
7 |
|
4232 |
15 Sep 22 |
peter |
The yat library is free software; you can redistribute it and/or |
4232 |
15 Sep 22 |
peter |
modify it under the terms of the GNU General Public License as |
4232 |
15 Sep 22 |
peter |
published by the Free Software Foundation; either version 3 of the |
4232 |
15 Sep 22 |
peter |
License, or (at your option) any later version. |
4232 |
15 Sep 22 |
peter |
12 |
|
4232 |
15 Sep 22 |
peter |
The yat library is distributed in the hope that it will be useful, |
4232 |
15 Sep 22 |
peter |
but WITHOUT ANY WARRANTY; without even the implied warranty of |
4232 |
15 Sep 22 |
peter |
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
4232 |
15 Sep 22 |
peter |
General Public License for more details. |
4232 |
15 Sep 22 |
peter |
17 |
|
4232 |
15 Sep 22 |
peter |
You should have received a copy of the GNU General Public License |
4232 |
15 Sep 22 |
peter |
along with yat. If not, see <http://www.gnu.org/licenses/>. |
4232 |
15 Sep 22 |
peter |
20 |
*/ |
4232 |
15 Sep 22 |
peter |
21 |
|
4232 |
15 Sep 22 |
peter |
22 |
#include <config.h> |
4232 |
15 Sep 22 |
peter |
23 |
|
4232 |
15 Sep 22 |
peter |
24 |
#include "Suite.h" |
4232 |
15 Sep 22 |
peter |
25 |
|
4232 |
15 Sep 22 |
peter |
26 |
#include "yat/random/random.h" |
4232 |
15 Sep 22 |
peter |
27 |
|
4232 |
15 Sep 22 |
peter |
28 |
#include <algorithm> |
4232 |
15 Sep 22 |
peter |
29 |
#include <iterator> |
4232 |
15 Sep 22 |
peter |
30 |
#include <vector> |
4232 |
15 Sep 22 |
peter |
31 |
|
4232 |
15 Sep 22 |
peter |
32 |
using namespace theplu::yat; |
4232 |
15 Sep 22 |
peter |
33 |
|
4232 |
15 Sep 22 |
peter |
34 |
int main(int argc, char* argv[]) |
4232 |
15 Sep 22 |
peter |
35 |
{ |
4232 |
15 Sep 22 |
peter |
36 |
theplu::yat::test::Suite suite(argc, argv); |
4232 |
15 Sep 22 |
peter |
37 |
|
4232 |
15 Sep 22 |
peter |
38 |
std::vector<int> a = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9}; |
4232 |
15 Sep 22 |
peter |
39 |
bool ok = false; |
4232 |
15 Sep 22 |
peter |
40 |
std::vector<int> b(a); |
4232 |
15 Sep 22 |
peter |
41 |
random::random_shuffle(b.begin(), b.end()); |
4232 |
15 Sep 22 |
peter |
42 |
std::copy(b.begin(), b.end(), std::ostream_iterator<int>(suite.out(), " ")); |
4232 |
15 Sep 22 |
peter |
43 |
for (size_t n = 0; !ok && n<100; ++n) { |
4232 |
15 Sep 22 |
peter |
44 |
std::vector<int> c(a); |
4232 |
15 Sep 22 |
peter |
45 |
random::random_shuffle(c.begin(), c.end()); |
4232 |
15 Sep 22 |
peter |
46 |
if (c != b ) |
4232 |
15 Sep 22 |
peter |
47 |
ok = true; |
4232 |
15 Sep 22 |
peter |
48 |
} |
4232 |
15 Sep 22 |
peter |
49 |
suite.add(ok); |
4232 |
15 Sep 22 |
peter |
50 |
return suite.return_value(); |
4232 |
15 Sep 22 |
peter |
51 |
} |