MCPcopy Create free account
hub / github.com/boostorg/filesystem / creation_time_tests

Function creation_time_tests

test/operations_test.cpp:2260–2305  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

2258// creation_time_tests -------------------------------------------------------------//
2259
2260void creation_time_tests(const fs::path& dirx)
2261{
2262 cout << "creation_time_tests..." << endl;
2263
2264 fs::path f1x = dirx / "creation_time_file";
2265
2266 std::time_t start = std::time(nullptr);
2267
2268 // These pauses are inserted because the test spuriously fails on Windows, presumably because of
2269 // different converting FILETIME to seconds in time() and Boost.Filesystem or some sort of quirk
2270 // in the Windows implementation of filesystem API.
2271#if defined(BOOST_FILESYSTEM_POSIX_API)
2272 sleep(1);
2273#else
2274 Sleep(1000);
2275#endif
2276 create_file(f1x, "creation_time_file");
2277 BOOST_TEST(fs::is_regular_file(f1x));
2278 try
2279 {
2280 std::time_t ft = fs::creation_time(f1x);
2281#if defined(BOOST_FILESYSTEM_POSIX_API)
2282 sleep(1);
2283#else
2284 Sleep(1000);
2285#endif
2286 std::time_t finish = std::time(nullptr);
2287 cout << " start time: " << start << ", file creation time: " << ft << ", finish time: " << finish << endl;
2288
2289 BOOST_TEST(ft >= start && ft <= finish);
2290 }
2291 catch (fs::filesystem_error& e)
2292 {
2293 if (e.code() == make_error_condition(boost::system::errc::function_not_supported))
2294 {
2295 cout << "creation_time is not supported by the current system" << endl;
2296 }
2297 else
2298 {
2299 cout << "creation_time failed: " << e.what() << endl;
2300 BOOST_TEST(false);
2301 }
2302 }
2303
2304 fs::remove(f1x);
2305}
2306
2307// symlink_file_size_tests ---------------------------------------------------------//
2308

Callers 1

cpp_mainFunction · 0.85

Calls 5

creation_timeFunction · 0.85
whatMethod · 0.80
create_fileFunction · 0.70
is_regular_fileFunction · 0.50
removeFunction · 0.50

Tested by

no test coverage detected