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 n, size_t m, size_t r, 12 // UIntType a, size_t u, UIntType d, size_t s, 13 // UIntType b, size_t t, UIntType c, size_t l, UIntType f> 14 // class mersenne_twister_engine; 15 16 // template <class charT, class traits, 17 // class UIntType, size_t w, size_t n, size_t m, size_t r, 18 // UIntType a, size_t u, UIntType d, size_t s, 19 // UIntType b, size_t t, UIntType c, size_t l, UIntType f> 20 // basic_ostream<charT, traits>& 21 // operator<<(basic_ostream<charT, traits>& os, 22 // const mersenne_twister_engine<UIntType, w, n, m, r, a, u, d, s, b, t, c, l, f>& x); 23 // 24 // template <class charT, class traits, 25 // class UIntType, size_t w, size_t n, size_t m, size_t r, 26 // UIntType a, size_t u, UIntType d, size_t s, 27 // UIntType b, size_t t, UIntType c, size_t l, UIntType f> 28 // basic_ostream<charT, traits>& 29 // operator>>(basic_istream<charT, traits>& is, 30 // mersenne_twister_engine<UIntType, w, n, m, r, a, u, d, s, b, t, c, l, f>& x); 31 32 #include <random> 33 #include <sstream> 34 #include <cassert> 35 36 #include "test_macros.h" 37 38 void 39 test1() 40 { 41 typedef std::mt19937 E; 42 E e1; 43 e1.discard(100); 44 std::ostringstream os; 45 os << e1; 46 std::istringstream is(os.str()); 47 E e2; 48 is >> e2; 49 assert(e1 == e2); 50 } 51 52 void 53 test2() 54 { 55 typedef std::mt19937_64 E; 56 E e1; 57 e1.discard(100); 58 std::ostringstream os; 59 os << e1; 60 std::istringstream is(os.str()); 61 E e2; 62 is >> e2; 63 assert(e1 == e2); 64 } 65 66 int main(int, char**) 67 { 68 test1(); 69 test2(); 70 71 return 0; 72 } 73