diff options
author | Jonathan Wakely <jwakely@redhat.com> | 2021-07-20 12:35:37 +0100 |
---|---|---|
committer | Jonathan Wakely <jwakely@redhat.com> | 2021-07-20 12:54:30 +0100 |
commit | 0c4ae4ff46b1d7633f1e06f57d348b5817b8f640 (patch) | |
tree | efc4a9ff11d05f47b7a229130ab057b723994166 /libstdc++-v3/testsuite/27_io/filesystem | |
parent | 7cc2df084b7977653a9b59cbc34a9ad500ae619c (diff) |
libstdc++: Add more tests for filesystem::create_directory [PR101510]
Signed-off-by: Jonathan Wakely <jwakely@redhat.com>
libstdc++-v3/ChangeLog:
PR libstdc++/101510
* src/c++17/fs_ops.cc (create_dir): Adjust whitespace.
* testsuite/27_io/filesystem/operations/create_directory.cc:
Test creating directory with name of existing symlink to
directory.
* testsuite/experimental/filesystem/operations/create_directory.cc:
Likewise.
Diffstat (limited to 'libstdc++-v3/testsuite/27_io/filesystem')
-rw-r--r-- | libstdc++-v3/testsuite/27_io/filesystem/operations/create_directory.cc | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/libstdc++-v3/testsuite/27_io/filesystem/operations/create_directory.cc b/libstdc++-v3/testsuite/27_io/filesystem/operations/create_directory.cc index a0e50471275..256621481d7 100644 --- a/libstdc++-v3/testsuite/27_io/filesystem/operations/create_directory.cc +++ b/libstdc++-v3/testsuite/27_io/filesystem/operations/create_directory.cc @@ -54,6 +54,33 @@ test01() b = create_directory(p); VERIFY( !b ); + auto f = p/"file"; + std::ofstream{f} << "create file"; + b = create_directory(f, ec); + VERIFY( ec == std::errc::file_exists ); + VERIFY( !b ); + try + { + create_directory(f); + VERIFY( false ); + } + catch (const fs::filesystem_error& e) + { + VERIFY( e.code() == std::errc::file_exists ); + VERIFY( e.path1() == f ); + } + + // PR libstdc++/101510 create_directory on an existing symlink to a directory + fs::create_directory(p/"dir"); + auto link = p/"link"; + fs::create_directory_symlink("dir", link); + ec = bad_ec; + b = fs::create_directory(link, ec); + VERIFY( !b ); + VERIFY( !ec ); + b = fs::create_directory(link); + VERIFY( !b ); + remove_all(p, ec); } |