Home | History | Annotate | Download | only in rand.eng.sub
      1 //===----------------------------------------------------------------------===//
      2 //
      3 //                     The LLVM Compiler Infrastructure
      4 //
      5 // This file is dual licensed under the MIT and the University of Illinois Open
      6 // Source Licenses. See LICENSE.TXT for details.
      7 //
      8 //===----------------------------------------------------------------------===//
      9 
     10 // <random>
     11 
     12 // template<class UIntType, size_t w, size_t s, size_t r>
     13 // class subtract_with_carry_engine
     14 // {
     15 // public:
     16 //     // types
     17 //     typedef UIntType result_type;
     18 //
     19 //     // engine characteristics
     20 //     static constexpr size_t word_size = w;
     21 //     static constexpr size_t short_lag = s;
     22 //     static constexpr size_t long_lag = r;
     23 //     static constexpr result_type min() { return 0; }
     24 //     static constexpr result_type max() { return m-1; }
     25 //     static constexpr result_type default_seed = 19780503u;
     26 
     27 #include <random>
     28 #include <type_traits>
     29 #include <cassert>
     30 
     31 #include "test_macros.h"
     32 
     33 template <class _Tp>
     34 void where(const _Tp &) {}
     35 
     36 void
     37 test1()
     38 {
     39     typedef std::ranlux24_base E;
     40     static_assert((E::word_size == 24), "");
     41     static_assert((E::short_lag == 10), "");
     42     static_assert((E::long_lag == 24), "");
     43 #if TEST_STD_VER >= 11
     44     static_assert((E::min() == 0), "");
     45     static_assert((E::max() == 0xFFFFFF), "");
     46 #else
     47     assert((E::min() == 0));
     48     assert((E::max() == 0xFFFFFF));
     49 #endif
     50     static_assert((E::default_seed == 19780503u), "");
     51     where(E::word_size);
     52     where(E::short_lag);
     53     where(E::long_lag);
     54     where(E::default_seed);
     55 }
     56 
     57 void
     58 test2()
     59 {
     60     typedef std::ranlux48_base E;
     61     static_assert((E::word_size == 48), "");
     62     static_assert((E::short_lag == 5), "");
     63     static_assert((E::long_lag == 12), "");
     64 #if TEST_STD_VER >= 11
     65     static_assert((E::min() == 0), "");
     66     static_assert((E::max() == 0xFFFFFFFFFFFFull), "");
     67 #else
     68     assert((E::min() == 0));
     69     assert((E::max() == 0xFFFFFFFFFFFFull));
     70 #endif
     71     static_assert((E::default_seed == 19780503u), "");
     72     where(E::word_size);
     73     where(E::short_lag);
     74     where(E::long_lag);
     75     where(E::default_seed);
     76 }
     77 
     78 int main()
     79 {
     80     test1();
     81     test2();
     82 }
     83