• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 s, size_t r>
12 // class subtract_with_carry_engine
13 // {
14 // public:
15 //     // types
16 //     typedef UIntType result_type;
17 //
18 //     // engine characteristics
19 //     static constexpr size_t word_size = w;
20 //     static constexpr size_t short_lag = s;
21 //     static constexpr size_t long_lag = r;
22 //     static constexpr result_type min() { return 0; }
23 //     static constexpr result_type max() { return m-1; }
24 //     static constexpr result_type default_seed = 19780503u;
25 
26 #include <random>
27 #include <type_traits>
28 #include <cassert>
29 
30 #include "test_macros.h"
31 
32 template <class T>
where(const T &)33 void where(const T &) {}
34 
35 void
test1()36 test1()
37 {
38     typedef std::ranlux24_base E;
39     static_assert((E::word_size == 24), "");
40     static_assert((E::short_lag == 10), "");
41     static_assert((E::long_lag == 24), "");
42 #if TEST_STD_VER >= 11
43     static_assert((E::min() == 0), "");
44     static_assert((E::max() == 0xFFFFFF), "");
45 #else
46     assert((E::min() == 0));
47     assert((E::max() == 0xFFFFFF));
48 #endif
49     static_assert((E::default_seed == 19780503u), "");
50     where(E::word_size);
51     where(E::short_lag);
52     where(E::long_lag);
53     where(E::default_seed);
54 }
55 
56 void
test2()57 test2()
58 {
59     typedef std::ranlux48_base E;
60     static_assert((E::word_size == 48), "");
61     static_assert((E::short_lag == 5), "");
62     static_assert((E::long_lag == 12), "");
63 #if TEST_STD_VER >= 11
64     static_assert((E::min() == 0), "");
65     static_assert((E::max() == 0xFFFFFFFFFFFFull), "");
66 #else
67     assert((E::min() == 0));
68     assert((E::max() == 0xFFFFFFFFFFFFull));
69 #endif
70     static_assert((E::default_seed == 19780503u), "");
71     where(E::word_size);
72     where(E::short_lag);
73     where(E::long_lag);
74     where(E::default_seed);
75 }
76 
main(int,char **)77 int main(int, char**)
78 {
79     test1();
80     test2();
81 
82   return 0;
83 }
84