[RISCV] Fix mgather -> riscv.masked.strided.load combine not extending indices (...
[llvm-project.git] / libcxx / test / std / numerics / rand / rand.util / rand.util.seedseq / iterator.pass.cpp
blob1dd9a055f7ca3a2fe1c2de00499d2e48cd1f0e30
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 // class seed_seq;
13 // template<class InputIterator>
14 // seed_seq(InputIterator begin, InputIterator end);
16 #include <random>
17 #include <cassert>
19 #include "test_macros.h"
21 void test()
24 unsigned a[5] = {5, 4, 3, 2, 1};
25 std::seed_seq s(a, a+5);
26 assert(s.size() == 5);
28 unsigned b[5] = {0};
29 s.param(b);
30 assert(b[0] == 5);
31 assert(b[1] == 4);
32 assert(b[2] == 3);
33 assert(b[3] == 2);
34 assert(b[4] == 1);
37 // Test truncation to 32 bits
38 unsigned long long a[4] = {
39 0x1234000056780000uLL,
40 0x0000001234567800uLL,
41 0xFFFFFFFFFFFFFFFFuLL,
42 0x0000000180000000uLL,
44 std::seed_seq s(a, a+4);
45 assert(s.size() == 4);
47 unsigned b[4] = {0};
48 s.param(b);
49 assert(b[0] == 0x56780000u);
50 assert(b[1] == 0x34567800u);
51 assert(b[2] == 0xFFFFFFFFu);
52 assert(b[3] == 0x80000000u);
54 #if TEST_STD_VER >= 11
56 // Test uniform initialization syntax (LWG 3422)
57 unsigned a[3] = {1, 2, 3};
58 std::seed_seq s{a, a+3}; // uniform initialization
59 assert(s.size() == 3);
61 unsigned b[3] = {0};
62 s.param(b);
63 assert(b[0] == 1);
64 assert(b[1] == 2);
65 assert(b[2] == 3);
67 #endif // TEST_STD_VER >= 11
70 int main(int, char**)
72 test();
74 return 0;