From 70bcf0f65849cff273f3d6cacb121e52ffdad5ee Mon Sep 17 00:00:00 2001 From: "A. Jiang" Date: Fri, 23 Jun 2023 23:33:08 +0800 Subject: [PATCH] Test coverage for LWG-2682 --- tests/std/tests/P0218R1_filesystem/test.cpp | 22 +++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/tests/std/tests/P0218R1_filesystem/test.cpp b/tests/std/tests/P0218R1_filesystem/test.cpp index 1f53756d97..9dccd93941 100644 --- a/tests/std/tests/P0218R1_filesystem/test.cpp +++ b/tests/std/tests/P0218R1_filesystem/test.cpp @@ -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(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(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)); @@ -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();