blob: 6c4a7f434f127076847d698332fc9054aa293761 [file] [log] [blame]
Howard Hinnant3e519522010-05-11 19:42:16 +00001//===----------------------------------------------------------------------===//
2//
Howard Hinnant5b08a8a2010-05-11 21:36:01 +00003// The LLVM Compiler Infrastructure
Howard Hinnant3e519522010-05-11 19:42:16 +00004//
Howard Hinnant412dbeb2010-11-16 22:09:02 +00005// This file is dual licensed under the MIT and the University of Illinois Open
6// Source Licenses. See LICENSE.TXT for details.
Howard Hinnant3e519522010-05-11 19:42:16 +00007//
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();
16
17#include <random>
18#include <cassert>
19
20template <class T, T a, T c, T m>
21void
22test1()
23{
24 typedef std::linear_congruential_engine<T, a, c, m> LCE;
25 typedef typename LCE::result_type result_type;
26 LCE e1;
27 LCE e2;
28 e2.seed();
29 assert(e1 == e2);
30}
31
32template <class T>
33void
34test()
35{
36 test1<T, 0, 0, 0>();
37 test1<T, 0, 1, 2>();
38 test1<T, 1, 1, 2>();
39 const T M(~0);
40 test1<T, 0, 0, M>();
41 test1<T, 0, M-2, M>();
42 test1<T, 0, M-1, M>();
43 test1<T, M-2, 0, M>();
44 test1<T, M-2, M-2, M>();
45 test1<T, M-2, M-1, M>();
46 test1<T, M-1, 0, M>();
47 test1<T, M-1, M-2, M>();
48 test1<T, M-1, M-1, M>();
49}
50
51int main()
52{
53 test<unsigned short>();
54 test<unsigned int>();
55 test<unsigned long>();
56 test<unsigned long long>();
57}