| 353 | #endif |
| 354 | |
| 355 | void exception_tests() |
| 356 | { |
| 357 | cout << "exception_tests..." << endl; |
| 358 | bool exception_thrown; |
| 359 | |
| 360 | // catch runtime_error by value |
| 361 | |
| 362 | cout << " catch runtime_error by value" << endl; |
| 363 | exception_thrown = false; |
| 364 | try |
| 365 | { |
| 366 | fs::create_directory("no-such-dir/foo/bar"); |
| 367 | } |
| 368 | catch (std::runtime_error x) |
| 369 | { |
| 370 | exception_thrown = true; |
| 371 | cout << " x.what() returns \"" << x.what() << "\"" << endl; |
| 372 | } |
| 373 | BOOST_TEST(exception_thrown); |
| 374 | |
| 375 | // catch system_error by value |
| 376 | |
| 377 | cout << " catch system_error by value" << endl; |
| 378 | exception_thrown = false; |
| 379 | try |
| 380 | { |
| 381 | fs::create_directory("no-such-dir/foo/bar"); |
| 382 | } |
| 383 | catch (system_error x) |
| 384 | { |
| 385 | exception_thrown = true; |
| 386 | cout << " x.what() returns \"" << x.what() << "\"" << endl; |
| 387 | } |
| 388 | BOOST_TEST(exception_thrown); |
| 389 | |
| 390 | // catch filesystem_error by value |
| 391 | |
| 392 | cout << " catch filesystem_error by value" << endl; |
| 393 | exception_thrown = false; |
| 394 | try |
| 395 | { |
| 396 | fs::create_directory("no-such-dir/foo/bar"); |
| 397 | } |
| 398 | catch (fs::filesystem_error x) |
| 399 | { |
| 400 | exception_thrown = true; |
| 401 | cout << " x.what() returns \"" << x.what() << "\"" << endl; |
| 402 | } |
| 403 | BOOST_TEST(exception_thrown); |
| 404 | |
| 405 | // catch filesystem_error by const reference |
| 406 | |
| 407 | cout << " catch filesystem_error by const reference" << endl; |
| 408 | exception_thrown = false; |
| 409 | try |
| 410 | { |
| 411 | fs::create_directory("no-such-dir/foo/bar"); |
| 412 | } |
no test coverage detected