Howard Hinnant | 3e51952 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1 | //===----------------------------------------------------------------------===// |
| 2 | // |
Howard Hinnant | 5b08a8a | 2010-05-11 21:36:01 +0000 | [diff] [blame] | 3 | // The LLVM Compiler Infrastructure |
Howard Hinnant | 3e51952 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 4 | // |
| 5 | // This file is distributed under the University of Illinois Open Source |
| 6 | // License. See LICENSE.TXT for details. |
| 7 | // |
| 8 | //===----------------------------------------------------------------------===// |
| 9 | |
| 10 | // <random> |
| 11 | |
| 12 | // template<class Engine, size_t w, class UIntType> |
| 13 | // class independent_bits_engine |
| 14 | |
| 15 | // template <class charT, class traits, |
| 16 | // class Engine, size_t w, class UIntType> |
| 17 | // basic_ostream<charT, traits>& |
| 18 | // operator<<(basic_ostream<charT, traits>& os, |
| 19 | // const independent_bits_engine<Engine, w, UIntType>& x); |
| 20 | // |
| 21 | // template <class charT, class traits, |
| 22 | // class Engine, size_t w, class UIntType> |
| 23 | // basic_istream<charT, traits>& |
| 24 | // operator>>(basic_istream<charT, traits>& is, |
| 25 | // independent_bits_engine<Engine, w, UIntType>& x); |
| 26 | |
| 27 | #include <random> |
| 28 | #include <sstream> |
| 29 | #include <cassert> |
| 30 | |
| 31 | void |
| 32 | test1() |
| 33 | { |
| 34 | typedef std::independent_bits_engine<std::ranlux24, 32, unsigned> E; |
| 35 | E e1; |
| 36 | e1.discard(100); |
| 37 | std::ostringstream os; |
| 38 | os << e1; |
| 39 | std::istringstream is(os.str()); |
| 40 | E e2; |
| 41 | is >> e2; |
| 42 | assert(e1 == e2); |
| 43 | } |
| 44 | |
| 45 | void |
| 46 | test2() |
| 47 | { |
| 48 | typedef std::independent_bits_engine<std::ranlux48, 64, unsigned long long> E; |
| 49 | E e1; |
| 50 | e1.discard(100); |
| 51 | std::ostringstream os; |
| 52 | os << e1; |
| 53 | std::istringstream is(os.str()); |
| 54 | E e2; |
| 55 | is >> e2; |
| 56 | assert(e1 == e2); |
| 57 | } |
| 58 | |
| 59 | int main() |
| 60 | { |
| 61 | test1(); |
| 62 | test2(); |
| 63 | } |