Fix filesystem::last_write_time failure with 32-bit time_t

* testsuite/27_io/filesystem/operations/last_write_time.cc: Fix
	test failures on targets with 32-bit time_t.

From-SVN: r267811
This commit is contained in:
Jonathan Wakely 2019-01-10 15:39:28 +00:00 committed by Jonathan Wakely
parent 45a8d80fec
commit 174f1d2642
2 changed files with 18 additions and 1 deletions

View File

@ -1,5 +1,8 @@
2019-01-10 Jonathan Wakely <jwakely@redhat.com>
* testsuite/27_io/filesystem/operations/last_write_time.cc: Fix
test failures on targets with 32-bit time_t.
* include/bits/erase_if.h: Define __cpp_lib_erase_if.
* include/std/deque: Likewise.
* include/std/forward_list: Likewise.

View File

@ -22,6 +22,7 @@
// 15.25 Permissions [fs.op.last_write_time]
#include <filesystem>
#include <limits>
#include <testsuite_fs.h>
#include <testsuite_hooks.h>
@ -141,14 +142,27 @@ test02()
VERIFY( !ec );
VERIFY( approx_equal(last_write_time(f.path), time) );
if (std::numeric_limits<std::time_t>::max()
< std::numeric_limits<std::int64_t>::max())
return; // file clock's epoch is out of range for 32-bit time_t
ec = bad_ec;
// The file clock's epoch:
time = time_type();
last_write_time(f.path, time, ec);
VERIFY( !ec );
VERIFY( approx_equal(last_write_time(f.path), time) );
ec = bad_ec;
time -= std::chrono::milliseconds(1000 * 60 * 10 + 15);
// A time after the epoch
time += std::chrono::milliseconds(1000 * 60 * 10 + 15);
last_write_time(f.path, time, ec);
VERIFY( !ec );
VERIFY( approx_equal(last_write_time(f.path), time) );
ec = bad_ec;
// A time before than the epoch
time -= std::chrono::milliseconds(1000 * 60 * 20 + 15);
last_write_time(f.path, time, ec);
VERIFY( !ec );
VERIFY( approx_equal(last_write_time(f.path), time) );