Skip to content

Commit 7da9be9

Browse files
committed
test for permission copying
1 parent e6b34e2 commit 7da9be9

File tree

1 file changed

+19
-6
lines changed

1 file changed

+19
-6
lines changed

test/filesystem_test.cpp

+19-6
Original file line numberDiff line numberDiff line change
@@ -99,15 +99,15 @@ using fstream = ghc::filesystem::fstream;
9999
//- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
100100

101101
template <typename TP>
102-
std::time_t to_time_t(TP tp)
102+
static std::time_t to_time_t(TP tp)
103103
{
104104
using namespace std::chrono;
105105
auto sctp = time_point_cast<system_clock::duration>(tp - TP::clock::now() + system_clock::now());
106106
return system_clock::to_time_t(sctp);
107107
}
108108

109109
template <typename TP>
110-
TP from_time_t(std::time_t t)
110+
static TP from_time_t(std::time_t t)
111111
{
112112
using namespace std::chrono;
113113
auto sctp = system_clock::from_time_t(t);
@@ -214,7 +214,7 @@ static void generateFile(const fs::path& pathname, int withSize = -1)
214214
}
215215

216216
#ifdef GHC_OS_WINDOWS
217-
inline bool isWow64Proc()
217+
static bool isWow64Proc()
218218
{
219219
typedef BOOL(WINAPI * IsWow64Process_t)(HANDLE, PBOOL);
220220
BOOL bIsWow64 = FALSE;
@@ -303,13 +303,13 @@ class TestAllocator
303303
};
304304

305305
template <class T, class U>
306-
bool operator==(TestAllocator<T> const&, TestAllocator<U> const&) noexcept
306+
static bool operator==(TestAllocator<T> const&, TestAllocator<U> const&) noexcept
307307
{
308308
return true;
309309
}
310310

311311
template <class T, class U>
312-
bool operator!=(TestAllocator<T> const& x, TestAllocator<U> const& y) noexcept
312+
static bool operator!=(TestAllocator<T> const& x, TestAllocator<U> const& y) noexcept
313313
{
314314
return !(x == y);
315315
}
@@ -1208,7 +1208,7 @@ TEST_CASE("fs.class.filesystem_error - class filesystem_error", "[filesystem][fi
12081208
CHECK(fse.path2() == "some/other");
12091209
}
12101210

1211-
constexpr fs::perms constExprOwnerAll()
1211+
static constexpr fs::perms constExprOwnerAll()
12121212
{
12131213
return fs::perms::owner_read | fs::perms::owner_write | fs::perms::owner_exec;
12141214
}
@@ -1787,6 +1787,19 @@ TEST_CASE("fs.op.copy_file - copy_file", "[filesystem][operations][fs.op.copy_fi
17871787
CHECK_NOTHROW(fs::copy_file("foobar", "foobar2", ec));
17881788
CHECK(ec);
17891789
CHECK(!fs::exists("foobar"));
1790+
fs::path file1("temp1.txt");
1791+
fs::path file2("temp2.txt");
1792+
generateFile(file1, 200);
1793+
generateFile(file2, 200);
1794+
auto allWrite = fs::perms::owner_write | fs::perms::group_write | fs::perms::others_write;
1795+
CHECK_NOTHROW(fs::permissions(file1, allWrite, fs::perm_options::remove));
1796+
CHECK((fs::status(file1).permissions() & fs::perms::owner_write) != fs::perms::owner_write);
1797+
CHECK_NOTHROW(fs::permissions(file2, allWrite, fs::perm_options::add));
1798+
CHECK((fs::status(file2).permissions() & fs::perms::owner_write) == fs::perms::owner_write);
1799+
fs::copy_file(file1, file2, fs::copy_options::overwrite_existing);
1800+
CHECK((fs::status(file2).permissions() & fs::perms::owner_write) != fs::perms::owner_write);
1801+
CHECK_NOTHROW(fs::permissions(file1, allWrite, fs::perm_options::add));
1802+
CHECK_NOTHROW(fs::permissions(file2, allWrite, fs::perm_options::add));
17901803
}
17911804

17921805
TEST_CASE("fs.op.copy_symlink - copy_symlink", "[filesystem][operations][fs.op.copy_symlink]")

0 commit comments

Comments
 (0)