xref: /llvm-project/libcxx/test/std/numerics/rand/rand.adapt/rand.adapt.disc/ctor_sseq.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 Engine, size_t p, size_t r>
12 // class discard_block_engine
13 
14 // template<class Sseq> explicit discard_block_engine(Sseq& q);
15 
16 #include <random>
17 #include <sstream>
18 #include <cassert>
19 
20 #include "test_macros.h"
21 
22 void
23 test1()
24 {
25     const char* a = "13604817 711567 9760686 13278398 3323440 175548 5553651 "
26     "3028863 10748297 2216688 275779 14778841 14438394 9483441 4229545 "
27     "14657301 12636508 15978210 1653340 1718567 9272421 14302862 7940348 "
28     "889045 0 0";
29     unsigned as[] = {3, 5, 7};
30     std::seed_seq sseq(as, as+3);
31     std::ranlux24 e1(sseq);
32     std::ostringstream os;
33     os << e1;
34     assert(os.str() == a);
35 }
36 
37 void
38 test2()
39 {
40     const char* a = "241408498702289 172342669275054 191026374555184 "
41     "61020585639411 231929771458953 142769679250755 198672786411514 "
42     "183712717244841 227473912549724 62843577252444 68782400568421 "
43     "159248704678140 0 0";
44     unsigned as[] = {3, 5, 7};
45     std::seed_seq sseq(as, as+3);
46     std::ranlux48 e1(sseq);
47     std::ostringstream os;
48     os << e1;
49     assert(os.str() == a);
50 }
51 
52 int main(int, char**)
53 {
54     test1();
55     test2();
56 
57   return 0;
58 }
59