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 UIntType, UIntType a, UIntType c, UIntType m> |
| 13 | // class linear_congruential_engine; |
| 14 | |
| 15 | // linear_congruential_engine& operator=(const linear_congruential_engine&); |
| 16 | |
| 17 | #include <random> |
| 18 | #include <cassert> |
| 19 | |
| 20 | template <class T, T a, T c, T m> |
| 21 | void |
| 22 | test1() |
| 23 | { |
| 24 | typedef std::linear_congruential_engine<T, a, c, m> E; |
| 25 | E e1; |
| 26 | E e2; |
| 27 | assert(e1 == e2); |
| 28 | e1(); |
| 29 | e2 = e1; |
| 30 | assert(e1 == e2); |
| 31 | } |
| 32 | |
| 33 | template <class T> |
| 34 | void |
| 35 | test() |
| 36 | { |
| 37 | test1<T, 0, 0, 0>(); |
| 38 | test1<T, 0, 1, 2>(); |
| 39 | test1<T, 1, 1, 2>(); |
| 40 | const T M(~0); |
| 41 | test1<T, 0, 0, M>(); |
| 42 | test1<T, 0, M-2, M>(); |
| 43 | test1<T, 0, M-1, M>(); |
| 44 | test1<T, M-2, 0, M>(); |
| 45 | test1<T, M-2, M-2, M>(); |
| 46 | test1<T, M-2, M-1, M>(); |
| 47 | test1<T, M-1, 0, M>(); |
| 48 | test1<T, M-1, M-2, M>(); |
| 49 | test1<T, M-1, M-1, M>(); |
| 50 | } |
| 51 | |
| 52 | int main() |
| 53 | { |
| 54 | test<unsigned short>(); |
| 55 | test<unsigned int>(); |
| 56 | test<unsigned long>(); |
| 57 | test<unsigned long long>(); |
| 58 | } |