Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Test coverage for LWG-2682 filesystem::copy() won't create a symlink to a directory #3827

Merged
merged 1 commit into from
Jul 14, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 22 additions & 0 deletions tests/std/tests/P0218R1_filesystem/test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2248,6 +2248,26 @@ void test_copy_symlink() {
}
}

void test_copy_directory_as_symlink() {
const path dirpath{L"./test-lwg2682-dir"sv};
error_code ec;
create_directory(dirpath, ec);
EXPECT(good(ec));
try {
copy(dirpath, L"./symlink"sv, copy_options::create_symlinks);
EXPECT(false);
} catch (filesystem_error& e) {
EXPECT(e.code().value() == static_cast<int>(errc::is_a_directory));
}
{
error_code copy_ec;
copy(dirpath, L"./symlink"sv, copy_options::create_symlinks, copy_ec);
EXPECT(copy_ec.value() == static_cast<int>(errc::is_a_directory));
}
remove_all(dirpath, ec);
EXPECT(good(ec));
}

void equivalent_failure_test_case(const path& left, const path& right) {
EXPECT(throws_filesystem_error([&] { EXPECT(!equivalent(left, right)); }, "equivalent", left, right));

Expand Down Expand Up @@ -3997,6 +4017,8 @@ int wmain(int argc, wchar_t* argv[]) {

test_copy_symlink();

test_copy_directory_as_symlink(); // per LWG-2682

test_conversions();

test_file_size();
Expand Down