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

Function cpp_main

test/convenience_test.cpp:60–178  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

58// ------------------------------------------------------------------------------------//
59
60int cpp_main(int, char*[])
61{
62
63 // create_directories() tests --------------------------------------------------------//
64
65 BOOST_TEST(!fs::create_directories("/")); // should be harmless
66
67 path unique_dir = fs::unique_path(); // unique name in case tests running in parallel
68 path unique_yy = unique_dir / "yy";
69 path unique_yya = unique_dir / "yya";
70 path unique_yy_zz = unique_dir / "yy" / "zz";
71
72 fs::remove_all(unique_dir); // make sure slate is blank
73 BOOST_TEST(!fs::exists(unique_dir)); // reality check
74
75 BOOST_TEST(fs::create_directories(unique_dir));
76 BOOST_TEST(fs::exists(unique_dir));
77 BOOST_TEST(fs::is_directory(unique_dir));
78
79 BOOST_TEST(fs::create_directories(unique_yy_zz));
80 BOOST_TEST(fs::exists(unique_dir));
81 BOOST_TEST(fs::exists(unique_yy));
82 BOOST_TEST(fs::exists(unique_yy_zz));
83 BOOST_TEST(fs::is_directory(unique_dir));
84 BOOST_TEST(fs::is_directory(unique_yy));
85 BOOST_TEST(fs::is_directory(unique_yy_zz));
86
87 path is_a_file(unique_dir / "uu");
88 {
89 std::ofstream f(is_a_file.string().c_str());
90 BOOST_TEST(!!f);
91 }
92 BOOST_TEST(throws_fs_error(
93 boost::bind(fs::create_directories, is_a_file)));
94 BOOST_TEST(throws_fs_error(
95 boost::bind(fs::create_directories, is_a_file / "aa")));
96
97 // recursive_directory_iterator tests ----------------------------------------//
98
99 sys::error_code ec;
100 fs::recursive_directory_iterator it("/no-such-path", ec);
101 BOOST_TEST(ec);
102
103 BOOST_TEST(throws_fs_error(
104 boost::bind(create_recursive_iterator, "/no-such-path")));
105
106 fs::remove(unique_dir / "uu");
107
108#ifdef BOOST_FILESYSTEM_WINDOWS_API
109 // These tests depends on ordering of directory entries, and that's guaranteed
110 // on Windows but not necessarily on other operating systems
111 {
112 std::ofstream f(unique_yya.string().c_str());
113 BOOST_TEST(!!f);
114 }
115
116 for (it = fs::recursive_directory_iterator(unique_dir);
117 it != fs::recursive_directory_iterator(); ++it)

Callers

nothing calls this directly

Calls 15

stringMethod · 0.80
pathMethod · 0.80
depthMethod · 0.80
popMethod · 0.80
clearMethod · 0.80
throws_fs_errorFunction · 0.70
create_directoriesFunction · 0.50
unique_pathFunction · 0.50
remove_allFunction · 0.50
existsFunction · 0.50

Tested by

no test coverage detected