[libcxx-commits] [PATCH] D99982: [libcxx] [test] Add more tests for renaming directories in fs.op.rename
Martin Storsjö via Phabricator via libcxx-commits
libcxx-commits at lists.llvm.org
Tue Apr 6 11:33:56 PDT 2021
mstorsjo created this revision.
mstorsjo requested review of this revision.
Herald added a project: libc++.
Herald added a reviewer: libc++.
This was requested during the review of D98640 <https://reviews.llvm.org/D98640>.
Repository:
rG LLVM Github Monorepo
https://reviews.llvm.org/D99982
Files:
libcxx/test/std/input.output/filesystems/fs.op.funcs/fs.op.rename/rename.pass.cpp
Index: libcxx/test/std/input.output/filesystems/fs.op.funcs/fs.op.rename/rename.pass.cpp
===================================================================
--- libcxx/test/std/input.output/filesystems/fs.op.funcs/fs.op.rename/rename.pass.cpp
+++ libcxx/test/std/input.output/filesystems/fs.op.funcs/fs.op.rename/rename.pass.cpp
@@ -127,4 +127,31 @@
}
}
+TEST_CASE(basic_rename_dir_test)
+{
+ static_test_env env;
+ const std::error_code set_ec = std::make_error_code(std::errc::address_in_use);
+ const path new_dir = env.makePath("new_dir");
+ { // dir -> dir (with contents)
+ std::error_code ec = set_ec;
+ rename(env.Dir, new_dir, ec);
+ TEST_CHECK(!ec);
+ TEST_CHECK(!exists(env.Dir));
+ TEST_CHECK(is_directory(new_dir));
+ TEST_CHECK(exists(new_dir / "file1"));
+ }
+#ifdef _WIN32
+ // On Windows, renaming a directory over a file isn't an error (this
+ // case is skipped in test_error_reporting above).
+ { // dir -> file
+ std::error_code ec = set_ec;
+ rename(new_dir, env.NonEmptyFile, ec);
+ TEST_CHECK(!ec);
+ TEST_CHECK(!exists(new_dir));
+ TEST_CHECK(is_directory(env.NonEmptyFile));
+ TEST_CHECK(exists(env.NonEmptyFile / "file1"));
+ }
+#endif
+}
+
TEST_SUITE_END()
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D99982.335610.patch
Type: text/x-patch
Size: 1305 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/libcxx-commits/attachments/20210406/eaa9d5fe/attachment.bin>
More information about the libcxx-commits
mailing list