forked from OSchip/llvm-project
[libc++] [P1164] Add tests for create_directories. NFC.
That's a follow-up patch after D92769. Reviewed By: ldionne, #libc Differential Revision: https://reviews.llvm.org/D93026
This commit is contained in:
parent
c9213e1b29
commit
59c72a7012
|
@ -8,6 +8,9 @@
|
|||
|
||||
// UNSUPPORTED: c++03
|
||||
|
||||
// This test requires the dylib support introduced in D92769.
|
||||
// XFAIL: with_system_cxx_lib=macosx10.15
|
||||
|
||||
// <filesystem>
|
||||
|
||||
// bool create_directories(const path& p);
|
||||
|
@ -75,12 +78,12 @@ TEST_CASE(create_directory_symlinks) {
|
|||
std::error_code ec = GetTestEC();
|
||||
TEST_CHECK(create_directories(target, ec) == false);
|
||||
TEST_CHECK(ec);
|
||||
TEST_CHECK(ErrorIs(ec, std::errc::file_exists));
|
||||
TEST_CHECK(!exists(sym_dest_dead));
|
||||
TEST_CHECK(!exists(dead_sym));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
TEST_CASE(create_directory_through_symlinks) {
|
||||
scoped_test_env env;
|
||||
const path root = env.create_dir("dir");
|
||||
|
@ -97,4 +100,42 @@ TEST_CASE(create_directory_through_symlinks) {
|
|||
}
|
||||
}
|
||||
|
||||
TEST_CASE(dest_is_file)
|
||||
{
|
||||
scoped_test_env env;
|
||||
const path file = env.create_file("file", 42);
|
||||
std::error_code ec = GetTestEC();
|
||||
TEST_CHECK(fs::create_directories(file, ec) == false);
|
||||
TEST_CHECK(ec);
|
||||
TEST_CHECK(ErrorIs(ec, std::errc::file_exists));
|
||||
TEST_CHECK(is_regular_file(file));
|
||||
}
|
||||
|
||||
TEST_CASE(dest_part_is_file)
|
||||
{
|
||||
scoped_test_env env;
|
||||
const path file = env.create_file("file");
|
||||
const path dir = env.make_env_path("file/dir1");
|
||||
std::error_code ec = GetTestEC();
|
||||
TEST_CHECK(fs::create_directories(dir, ec) == false);
|
||||
TEST_CHECK(ec);
|
||||
TEST_CHECK(ErrorIs(ec, std::errc::not_a_directory));
|
||||
TEST_CHECK(is_regular_file(file));
|
||||
TEST_CHECK(!exists(dir));
|
||||
}
|
||||
|
||||
TEST_CASE(dest_final_part_is_file)
|
||||
{
|
||||
scoped_test_env env;
|
||||
env.create_dir("dir");
|
||||
const path file = env.create_file("dir/file");
|
||||
const path dir = env.make_env_path("dir/file/dir1");
|
||||
std::error_code ec = GetTestEC();
|
||||
TEST_CHECK(fs::create_directories(dir, ec) == false);
|
||||
TEST_CHECK(ec);
|
||||
TEST_CHECK(ErrorIs(ec, std::errc::not_a_directory));
|
||||
TEST_CHECK(is_regular_file(file));
|
||||
TEST_CHECK(!exists(dir));
|
||||
}
|
||||
|
||||
TEST_SUITE_END()
|
||||
|
|
Loading…
Reference in New Issue