brintos

brintos / llvm-project-archived public Read only

0
0
Text · 2.1 KiB · a877eff Raw
84 lines · cpp
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-exception6//7//===----------------------------------------------------------------------===//8 9// <random>10 11// template<class UIntType, size_t w, size_t s, size_t r>12// class subtract_with_carry_engine13// {14// public:15//     // types16//     typedef UIntType result_type;17//18//     // engine characteristics19//     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 32template <class T>33void where(const T &) {}34 35void36test1()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 >= 1143    static_assert((E::min() == 0), "");44    static_assert((E::max() == 0xFFFFFF), "");45#else46    assert((E::min() == 0));47    assert((E::max() == 0xFFFFFF));48#endif49    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 56void57test2()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 >= 1164    static_assert((E::min() == 0), "");65    static_assert((E::max() == 0xFFFFFFFFFFFFull), "");66#else67    assert((E::min() == 0));68    assert((E::max() == 0xFFFFFFFFFFFFull));69#endif70    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 77int main(int, char**)78{79    test1();80    test2();81 82  return 0;83}84