]>
Commit | Line | Data |
---|---|---|
83ffe9cd | 1 | // Copyright (C) 2020-2023 Free Software Foundation, Inc. |
6ae17a3b JW |
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 | ||
c06617a7 | 18 | // { dg-do run { target c++11 } } |
6ae17a3b JW |
19 | |
20 | #include <random> | |
c06617a7 | 21 | #include <testsuite_hooks.h> |
6ae17a3b | 22 | |
c06617a7 | 23 | void |
6ae17a3b JW |
24 | test01() |
25 | { | |
26 | std::linear_congruential_engine<unsigned, 0, 0, 0> l; | |
c06617a7 JW |
27 | auto r = l(); // this used to result in divide by zero |
28 | VERIFY( r == 0 ); | |
29 | l.seed(2); | |
30 | r = l(); | |
31 | VERIFY( r == 0 ); | |
32 | VERIFY( l() == 0 ); | |
33 | } | |
34 | ||
35 | void | |
36 | test02() | |
37 | { | |
38 | std::linear_congruential_engine<unsigned, 0, 0, 3> l; | |
39 | auto r = l(); // this used to result in a different divide by zero | |
40 | VERIFY( r == 0 ); | |
41 | l.seed(2); | |
42 | r = l(); | |
43 | VERIFY( r == 0 ); | |
44 | VERIFY( l() == 0 ); | |
45 | } | |
46 | ||
47 | void | |
48 | test03() | |
49 | { | |
50 | std::linear_congruential_engine<unsigned, 0, 2, 3> l; | |
51 | auto r = l(); | |
52 | VERIFY( r == 2 ); | |
53 | l.seed(4); | |
54 | r = l(); | |
55 | VERIFY( r == 2 ); | |
56 | VERIFY( l() == 2 ); | |
57 | } | |
58 | ||
59 | int main() | |
60 | { | |
61 | test01(); | |
62 | test02(); | |
63 | test03(); | |
6ae17a3b | 64 | } |