]>
Commit | Line | Data |
---|---|---|
7adcbafe | 1 | // Copyright (C) 2020-2022 Free Software Foundation, Inc. |
813ad9c4 PP |
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 | |
5 | // terms of the GNU General Public License as published by the | |
6 | // Free Software Foundation; either version 3, or (at your option) | |
7 | // any later version. | |
8 | ||
9 | // This library is distributed in the hope that it will be useful, | |
10 | // but WITHOUT ANY WARRANTY; without even the implied warranty of | |
11 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
12 | // GNU General Public License for more details. | |
13 | ||
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/>. | |
17 | ||
813ad9c4 PP |
18 | // { dg-do run { target c++17 } } |
19 | // { dg-require-cstdint "" } | |
20 | ||
21 | #include <algorithm> | |
22 | #include <random> | |
23 | #include <testsuite_hooks.h> | |
24 | #include <testsuite_iterators.h> | |
25 | ||
26 | std::mt19937 rng; | |
27 | ||
28 | using std::sample; | |
29 | using __gnu_test::test_container; | |
30 | using __gnu_test::output_iterator_wrapper; | |
31 | using __gnu_test::forward_iterator_wrapper; | |
32 | ||
33 | void | |
34 | test01() | |
35 | { | |
36 | const int in = 0; | |
37 | test_container<const int, forward_iterator_wrapper> pop(&in, &in); | |
38 | int out; | |
39 | test_container<int, output_iterator_wrapper> samp(&out, &out + 1); | |
40 | ||
41 | auto it = sample(pop.begin(), pop.end(), samp.begin(), 1, rng); | |
42 | VERIFY( it.ptr == &out ); | |
43 | } | |
44 | ||
45 | int | |
46 | main() | |
47 | { | |
48 | test01(); | |
49 | } |