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

source code of libcxx/test/std/numerics/rand/rand.adapt/rand.adapt.ibits/ctor_sseq.pass.cpp