summaryrefslogtreecommitdiffstats
path: root/libcxx/test/support/filesystem_test_helper.hpp
diff options
context:
space:
mode:
Diffstat (limited to 'libcxx/test/support/filesystem_test_helper.hpp')
-rw-r--r--libcxx/test/support/filesystem_test_helper.hpp28
1 files changed, 16 insertions, 12 deletions
diff --git a/libcxx/test/support/filesystem_test_helper.hpp b/libcxx/test/support/filesystem_test_helper.hpp
index e3f46a16af3..de06868c014 100644
--- a/libcxx/test/support/filesystem_test_helper.hpp
+++ b/libcxx/test/support/filesystem_test_helper.hpp
@@ -105,6 +105,20 @@ static const fs::path RecDirFollowSymlinksIterationList[] = {
#error LIBCXX_FILESYSTEM_DYNAMIC_TEST_HELPER must be defined
#endif
+namespace random_utils {
+inline char to_hex(int ch) {
+ return ch < 10 ? static_cast<char>('0' + ch)
+ : static_cast<char>('a' + (ch - 10));
+}
+
+inline char random_hex_char() {
+ static std::mt19937 rd{std::random_device{}()};
+ static std::uniform_int_distribution<int> mrand{0, 15};
+ return to_hex(mrand(rd));
+}
+
+} // namespace random_utils
+
struct scoped_test_env
{
scoped_test_env() : test_root(random_env_path())
@@ -179,21 +193,11 @@ struct scoped_test_env
fs::path const test_root;
private:
- static char to_hex(int ch) {
- return ch < 10 ? static_cast<char>('0' + ch)
- : static_cast<char>('a' + (ch - 10));
- }
-
- static char random_hex_char() {
- static std::mt19937 rd { std::random_device{}() };
- static std::uniform_int_distribution<int> mrand{0, 15};
- return to_hex( mrand(rd) );
- }
-
static std::string unique_path_suffix() {
std::string model = "test.%%%%%%";
for (auto & ch : model) {
- if (ch == '%') ch = random_hex_char();
+ if (ch == '%')
+ ch = random_utils::random_hex_char();
}
return model;
}
OpenPOWER on IntegriCloud