Improve portability of random_device tests. Patch from STL@microsoft.com

git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@272746 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Eric Fiselier
2016-06-15 01:50:31 +00:00
parent c02ca7f4b0
commit 42e3e187f5
2 changed files with 6 additions and 2 deletions

View File

@@ -27,6 +27,8 @@
#include <unistd.h> #include <unistd.h>
#endif #endif
#include "test_macros.h"
bool is_valid_random_device(const std::string &token) { bool is_valid_random_device(const std::string &token) {
#if defined(_LIBCPP_USING_DEV_RANDOM) #if defined(_LIBCPP_USING_DEV_RANDOM)
@@ -44,7 +46,7 @@ void check_random_device_valid(const std::string &token) {
void check_random_device_invalid(const std::string &token) { void check_random_device_invalid(const std::string &token) {
try { try {
std::random_device r(token); std::random_device r(token);
assert(false); LIBCPP_ASSERT(false);
} catch (const std::system_error&) { } catch (const std::system_error&) {
} }
} }

View File

@@ -17,6 +17,8 @@
#include <random> #include <random>
#include <cassert> #include <cassert>
#include "test_macros.h"
int main() int main()
{ {
{ {
@@ -28,7 +30,7 @@ int main()
{ {
std::random_device r("/dev/null"); std::random_device r("/dev/null");
r(); r();
assert(false); LIBCPP_ASSERT(false);
} }
catch (const std::system_error&) catch (const std::system_error&)
{ {