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