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

Function create_directory_tests

test/operations_test.cpp:1145–1212  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1143// create_directory_tests ----------------------------------------------------------//
1144
1145void create_directory_tests()
1146{
1147 cout << "create_directory_tests..." << endl;
1148
1149 error_code ec;
1150 BOOST_TEST(!fs::create_directory("", ec));
1151 BOOST_TEST(ec);
1152
1153#ifdef BOOST_FILESYSTEM_WINDOWS_API
1154 ec.clear();
1155 BOOST_TEST(!fs::create_directory(" ", ec)); // OK on Linux
1156 BOOST_TEST(ec);
1157#endif
1158
1159 ec.clear();
1160 BOOST_TEST(!fs::create_directory("/", ec));
1161 BOOST_TEST(!ec);
1162 BOOST_TEST(fs::is_directory("/")); // this is a post-condition
1163
1164 ec.clear();
1165 BOOST_TEST(!fs::create_directory(".", ec));
1166 BOOST_TEST(!ec);
1167
1168 ec.clear();
1169 BOOST_TEST(!fs::create_directory("..", ec));
1170 BOOST_TEST(!ec);
1171
1172 // create a directory, then check it for consistency
1173 // take extra care to report problems, since if this fails
1174 // many subsequent tests will fail
1175 try
1176 {
1177 fs::create_directory(dir);
1178 }
1179 catch (const fs::filesystem_error& x)
1180 {
1181 cout << x.what() << "\n\n"
1182 "***** Creating directory "
1183 << dir << " failed. *****\n"
1184 "***** This is a serious error that will prevent further tests *****\n"
1185 "***** from returning useful results. Further testing is aborted. *****\n\n";
1186 std::exit(1);
1187 }
1188 catch (...)
1189 {
1190 cout << "\n\n"
1191 "***** Creating directory "
1192 << dir << " failed. *****\n"
1193 "***** This is a serious error that will prevent further tests *****\n"
1194 "***** from returning useful results. Further testing is aborted. *****\n\n";
1195 std::exit(1);
1196 }
1197
1198 BOOST_TEST(fs::exists(dir));
1199 BOOST_TEST(fs::is_empty(dir));
1200 BOOST_TEST(fs::is_directory(dir));
1201 BOOST_TEST(!fs::is_regular_file(dir));
1202 BOOST_TEST(!fs::is_other(dir));

Callers 1

cpp_mainFunction · 0.85

Calls 10

clearMethod · 0.80
whatMethod · 0.80
create_directoryFunction · 0.50
is_directoryFunction · 0.50
existsFunction · 0.50
is_emptyFunction · 0.50
is_regular_fileFunction · 0.50
is_otherFunction · 0.50
is_symlinkFunction · 0.50
statusFunction · 0.50

Tested by

no test coverage detected