xref: /llvm-project/libcxx/test/std/numerics/rand/rand.eng/rand.eng.lcong/io.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, UIntType a, UIntType c, UIntType m>
12 //   class linear_congruential_engine;
13 
14 // template <class charT, class traits,
15 //           class UIntType, UIntType a, UIntType c, UIntType m>
16 // basic_ostream<charT, traits>&
17 // operator<<(basic_ostream<charT, traits>& os,
18 //            const linear_congruential_engine<UIntType, a, c, m>& x);
19 //
20 // template <class charT, class traits,
21 //           class UIntType, UIntType a, UIntType c, UIntType m>
22 // basic_istream<charT, traits>&
23 // operator>>(basic_istream<charT, traits>& is,
24 //            linear_congruential_engine<UIntType, a, c, m>& x);
25 
26 #include <random>
27 #include <sstream>
28 #include <cassert>
29 
30 #include "test_macros.h"
31 
32 int main(int, char**)
33 {
34     {
35         typedef std::linear_congruential_engine<unsigned, 48271, 0, 2147483647> E;
36         E e1;
37         e1.discard(100);
38         std::ostringstream os;
39         os << e1;
40         std::istringstream is(os.str());
41         E e2;
42         is >> e2;
43         assert(e1 == e2);
44     }
45 
46   return 0;
47 }
48