xref: /llvm-project/libcxx/test/std/numerics/rand/rand.eng/rand.eng.sub/discard.pass.cpp (revision 7fc6a55688c816f5fc1a5481ae7af25be7500356)
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 #include "test_macros.h"
20 
21 void
test1()22 test1()
23 {
24     std::ranlux24_base e1;
25     std::ranlux24_base e2 = e1;
26     assert(e1 == e2);
27     e1.discard(3);
28     assert(e1 != e2);
29     (void)e2();
30     (void)e2();
31     (void)e2();
32     assert(e1 == e2);
33 }
34 
35 void
test2()36 test2()
37 {
38     std::ranlux48_base e1;
39     std::ranlux48_base e2 = e1;
40     assert(e1 == e2);
41     e1.discard(3);
42     assert(e1 != e2);
43     (void)e2();
44     (void)e2();
45     (void)e2();
46     assert(e1 == e2);
47 }
48 
main(int,char **)49 int main(int, char**)
50 {
51     test1();
52     test2();
53 
54   return 0;
55 }
56