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 //===----------------------------------------------------------------------===//
8 
9 // See bugs.llvm.org/PR20183
10 //
11 // XFAIL: with_system_cxx_lib=macosx10.11
12 // XFAIL: with_system_cxx_lib=macosx10.10
13 // XFAIL: with_system_cxx_lib=macosx10.9
14 
15 // UNSUPPORTED: libcpp-has-no-random-device
16 
17 // <random>
18 
19 // class random_device;
20 
21 // result_type operator()();
22 
23 #include <random>
24 #include <cassert>
25 #include <system_error>
26 
27 #include "test_macros.h"
28 
main(int,char **)29 int main(int, char**)
30 {
31     {
32         std::random_device r;
33         std::random_device::result_type e = r();
34         ((void)e); // Prevent unused warning
35     }
36 
37 #ifndef TEST_HAS_NO_EXCEPTIONS
38     try
39     {
40         std::random_device r("/dev/null");
41         (void)r();
42         LIBCPP_ASSERT(false);
43     }
44     catch (const std::system_error&)
45     {
46     }
47 #endif
48 
49   return 0;
50 }
51