xref: /llvm-project/libcxx/test/std/numerics/rand/rand.adapt/rand.adapt.disc/discard.pass.cpp (revision 57b08b0944046a6a57ee9b7b479181f548a5b9b4)
1 //===----------------------------------------------------------------------===//
2 //
3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4 // See https://llvm.org/LICENSE.txt for license information.
5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6 //
7 //===----------------------------------------------------------------------===//
8 
9 // <random>
10 
11 // template<class Engine, size_t p, size_t r>
12 // class discard_block_engine
13 
14 // void discard(unsigned long long z);
15 
16 #include <random>
17 #include <cassert>
18 
19 void
20 test1()
21 {
22     std::ranlux24 e1;
23     std::ranlux24 e2 = e1;
24     assert(e1 == e2);
25     e1.discard(3);
26     assert(e1 != e2);
27     (void)e2();
28     (void)e2();
29     (void)e2();
30     assert(e1 == e2);
31 }
32 
33 void
34 test2()
35 {
36     std::ranlux48 e1;
37     std::ranlux48 e2 = e1;
38     assert(e1 == e2);
39     e1.discard(3);
40     assert(e1 != e2);
41     (void)e2();
42     (void)e2();
43     (void)e2();
44     assert(e1 == e2);
45 }
46 
47 int main()
48 {
49     test1();
50     test2();
51 }
52