s/requires/REQUIRES to fix the test on release build
[llvm-project.git] / libcxx / test / std / numerics / rand / rand.device / eval.pass.cpp
blob9c385b3b88ec724f75e4bab2fd1ad6a9c0ca750f
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 // UNSUPPORTED: no-random-device
11 // <random>
13 // class random_device;
15 // result_type operator()();
17 #include <random>
18 #include <cassert>
19 #include <string>
20 #include <system_error>
22 #include "test_macros.h"
24 int main(int, char**)
27 std::random_device r;
28 std::random_device::result_type e = r();
29 ((void)e); // Prevent unused warning
32 // When using the `/dev/urandom` implementation, make sure that we throw
33 // an exception when we hit EOF while reading the custom-provided file.
34 #if !defined(TEST_HAS_NO_EXCEPTIONS) && defined(_LIBCPP_USING_DEV_RANDOM)
36 std::random_device r("/dev/null");
37 try {
38 (void)r();
39 LIBCPP_ASSERT(false);
40 } catch (const std::system_error&) {
43 #endif
45 return 0;