eval.pass.cpp
2.12 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
//===----------------------------------------------------------------------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
// <random>
// template <class UIntType, UIntType a, UIntType c, UIntType m>
// class linear_congruential_engine;
// result_type operator()();
#include <random>
#include <cassert>
#include "test_macros.h"
template <class T>
void
randu()
{
typedef std::linear_congruential_engine<T, 65539, 0, 2147483648u> E;
E e(1);
assert(e() == 65539);
assert(e() == 393225);
assert(e() == 1769499);
assert(e() == 7077969);
assert(e() == 26542323);
assert(e() == 95552217);
assert(e() == 334432395);
assert(e() == 1146624417);
assert(e() == 1722371299);
assert(e() == 14608041);
assert(e() == 1766175739);
assert(e() == 1875647473);
}
template <class T>
void
minstd()
{
typedef std::linear_congruential_engine<T, 16807, 0, 2147483647> E;
E e(1);
assert(e() == 16807);
assert(e() == 282475249);
assert(e() == 1622650073);
assert(e() == 984943658);
assert(e() == 1144108930);
assert(e() == 470211272);
assert(e() == 101027544);
assert(e() == 1457850878);
assert(e() == 1458777923);
assert(e() == 2007237709);
assert(e() == 823564440);
assert(e() == 1115438165);
}
template <class T>
void
Haldir()
{
typedef std::linear_congruential_engine<T, 16807, 78125, 2147483647> E;
E e(207560540);
assert(e() == 956631177);
assert(e() == 2037688522);
assert(e() == 1509348670);
assert(e() == 1546336451);
assert(e() == 429714088);
assert(e() == 217250280);
}
int main(int, char**)
{
randu<unsigned int>();
randu<unsigned long>();
randu<unsigned long long>();
minstd<unsigned int>();
minstd<unsigned long>();
minstd<unsigned long long>();
Haldir<unsigned int>();
Haldir<unsigned long>();
Haldir<unsigned long long>();
return 0;
}