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

Function remove_all_tests

test/operations_test.cpp:1522–1579  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1520// remove_all_tests ----------------------------------------------------------------//
1521
1522void remove_all_tests(const fs::path& dirx)
1523{
1524 cout << "remove_all_tests..." << endl;
1525
1526 // remove_all() file
1527 {
1528 fs::path f1x = dirx / "shortlife";
1529 BOOST_TEST(!fs::exists(f1x));
1530 create_file(f1x, "");
1531 BOOST_TEST(fs::exists(f1x));
1532 BOOST_TEST(!fs::is_directory(f1x));
1533 BOOST_TEST_EQ(fs::remove_all(f1x), 1u);
1534 BOOST_TEST(!fs::exists(f1x));
1535 BOOST_TEST_EQ(fs::remove_all("no-such-file"), 0u);
1536 BOOST_TEST_EQ(fs::remove_all("no-such-directory/no-such-file"), 0u);
1537 }
1538
1539 // remove_all() directory tree
1540 {
1541 unsigned int created_count = 0u;
1542 fs::path d1x = dirx / "shortlife_dir";
1543 BOOST_TEST(!fs::exists(d1x));
1544 fs::create_directory(d1x);
1545 ++created_count;
1546 BOOST_TEST(fs::exists(d1x));
1547 BOOST_TEST(fs::is_directory(d1x));
1548
1549 fs::path d2x = d1x / "nested_dir";
1550 BOOST_TEST(!fs::exists(d2x));
1551 fs::create_directory(d2x);
1552 ++created_count;
1553 BOOST_TEST(fs::exists(d2x));
1554 BOOST_TEST(fs::is_directory(d2x));
1555
1556 fs::path f1x = d1x / "shortlife";
1557 BOOST_TEST(!fs::exists(f1x));
1558 create_file(f1x, "");
1559 ++created_count;
1560 BOOST_TEST(fs::exists(f1x));
1561 BOOST_TEST(!fs::is_directory(f1x));
1562
1563#if defined(BOOST_FILESYSTEM_WINDOWS_API)
1564 // read-only file
1565 fs::path f2x = d1x / "shortlife_ro";
1566 BOOST_TEST(!fs::exists(f2x));
1567 create_file(f2x, "");
1568 ++created_count;
1569 BOOST_TEST(fs::exists(f2x));
1570 BOOST_TEST(!fs::is_directory(f2x));
1571 set_read_only(f2x);
1572#endif // defined(BOOST_FILESYSTEM_WINDOWS_API)
1573
1574 boost::uintmax_t removed_count = fs::remove_all(d1x);
1575 BOOST_TEST_EQ(removed_count, created_count);
1576
1577 BOOST_TEST(!fs::exists(d1x));
1578 }
1579}

Callers 1

cpp_mainFunction · 0.85

Calls 6

set_read_onlyFunction · 0.85
create_fileFunction · 0.70
existsFunction · 0.50
is_directoryFunction · 0.50
remove_allFunction · 0.50
create_directoryFunction · 0.50

Tested by

no test coverage detected