[RISCV] Fix mgather -> riscv.masked.strided.load combine not extending indices (...
[llvm-project.git] / libcxx / test / std / numerics / rand / rand.adapt / rand.adapt.shuf / eval.pass.cpp
blob4eecfea81b76e826fd051a6105a9369a8c150c7e
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 //===----------------------------------------------------------------------===//
9 // <random>
11 // template<class Engine, size_t k>
12 // class shuffle_order_engine
14 // result_type operator()();
16 #include <random>
17 #include <cassert>
19 #include "test_macros.h"
21 template <class UIntType, UIntType Min, UIntType Max>
22 class rand1
24 public:
25 // types
26 typedef UIntType result_type;
28 private:
29 result_type x_;
31 static_assert(Min < Max, "rand1 invalid parameters");
32 public:
34 #if TEST_STD_VER < 11 && defined(_LIBCPP_VERSION)
35 // Workaround for lack of constexpr in C++03
36 static const result_type _Min = Min;
37 static const result_type _Max = Max;
38 #endif
40 static TEST_CONSTEXPR result_type min() {return Min;}
41 static TEST_CONSTEXPR result_type max() {return Max;}
43 explicit rand1(result_type sd = Min) : x_(sd)
45 if (x_ > Max)
46 x_ = Max;
49 result_type operator()()
51 result_type r = x_;
52 if (x_ < Max)
53 ++x_;
54 else
55 x_ = Min;
56 return r;
60 void
61 test1()
63 typedef std::knuth_b E;
65 E e;
66 assert(e() == 152607844u);
69 void
70 test2()
72 typedef rand1<unsigned long long, 0, 0xFFFFFFFFFFFFFFFFull> E0;
73 typedef std::shuffle_order_engine<E0, 101> E;
74 E e;
75 e.discard(400);
76 assert(e() == 501);
79 void
80 test3()
82 typedef rand1<unsigned long long, 0, 0xFFFFFFFFFFFFFFFFull> E0;
83 typedef std::shuffle_order_engine<E0, 100> E;
84 E e;
85 e.discard(400);
86 assert(e() == 500);
89 int main(int, char**)
91 test1();
92 test2();
93 test3();
95 return 0;