xref: /llvm-project/libcxx/test/std/numerics/rand/rand.eng/rand.eng.sub/discard.pass.cpp (revision 2df59c50688c122bbcae7467d3eaf862c3ea3088)
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 UIntType, size_t w, size_t s, size_t r>
12 // class subtract_with_carry_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_base e1;
23     std::ranlux24_base 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_base e1;
37     std::ranlux48_base 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(int, char**)
48 {
49     test1();
50     test2();
51 
52   return 0;
53 }
54