Skip to content

Commit

Permalink
Test coverage for LWG-2682 filesystem::copy() won't create a symlin…
Browse files Browse the repository at this point in the history
…k to a directory (#3827)
  • Loading branch information
frederick-vs-ja authored Jul 14, 2023
1 parent cc6533a commit f155b41
Showing 1 changed file with 22 additions and 0 deletions.
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

0 comments on commit f155b41

Please sign in to comment.