|
Boost-Commit : |
Subject: [Boost-commit] svn:boost r57549 - sandbox/filesystem-v3/libs/filesystem/test
From: bdawes_at_[hidden]
Date: 2009-11-10 13:07:57
Author: bemandawes
Date: 2009-11-10 13:07:56 EST (Tue, 10 Nov 2009)
New Revision: 57549
URL: http://svn.boost.org/trac/boost/changeset/57549
Log:
Add status_error_reporting_tests()
Text files modified:
sandbox/filesystem-v3/libs/filesystem/test/operations_test.cpp | 68 ++++++++++++++++++++++++++++++++++++++++
1 files changed, 68 insertions(+), 0 deletions(-)
Modified: sandbox/filesystem-v3/libs/filesystem/test/operations_test.cpp
==============================================================================
--- sandbox/filesystem-v3/libs/filesystem/test/operations_test.cpp (original)
+++ sandbox/filesystem-v3/libs/filesystem/test/operations_test.cpp 2009-11-10 13:07:56 EST (Tue, 10 Nov 2009)
@@ -103,6 +103,9 @@
return false;
}
+ boost::system::error_category* poison_category_aux() { return 0; }
+ boost::system::error_category& poison_category() { return *poison_category_aux(); }
+
// compile-only two argument "do-the-right-thing" tests
// verifies that all overload combinations compile without error
void do_not_call()
@@ -749,12 +752,14 @@
{
std::cout << "status_of_nonexistent_tests..." << std::endl;
fs::path p ("nosuch");
+ BOOST_TEST(!fs::exists(p));
BOOST_TEST(!fs::is_regular_file(p));
BOOST_TEST(!fs::is_directory(p));
BOOST_TEST(!fs::is_symlink(p));
BOOST_TEST(!fs::is_other(p));
fs::file_status s = fs::status(p);
+ BOOST_TEST(!fs::exists(s));
BOOST_TEST_EQ(s.type(), fs::file_not_found);
BOOST_TEST(fs::status_known(s));
BOOST_TEST(!fs::is_regular_file(s));
@@ -763,6 +768,68 @@
BOOST_TEST(!fs::is_other(s));
}
+ // status_error_reporting_tests ----------------------------------------------------//
+
+ void status_error_reporting_tests()
+ {
+ std::cout << "status_error_reporting_tests..." << std::endl;
+
+ error_code ec;
+
+ // test status, ec, for existing file
+ ec.assign(-1,poison_category());
+ BOOST_TEST(ec.value() == -1);
+ BOOST_TEST(&ec.category() == &poison_category());
+ fs::file_status s = fs::status(".",ec);
+ BOOST_TEST(ec.value() == 0);
+ BOOST_TEST(ec.category() == system_category);
+ BOOST_TEST(fs::exists(s));
+ BOOST_TEST(fs::is_directory(s));
+
+ // test status, ec, for non-existing file
+ fs::path p ("nosuch");
+ ec.assign(-1,poison_category());
+ s = fs::status(p,ec);
+ BOOST_TEST(ec.value() != 0);
+ BOOST_TEST(ec.category() == system_category);
+
+ BOOST_TEST(!fs::exists(s));
+ BOOST_TEST_EQ(s.type(), fs::file_not_found);
+ BOOST_TEST(fs::status_known(s));
+ BOOST_TEST(!fs::is_regular_file(s));
+ BOOST_TEST(!fs::is_directory(s));
+ BOOST_TEST(!fs::is_symlink(s));
+ BOOST_TEST(!fs::is_other(s));
+
+ // test queries, ec, for existing file
+ ec.assign(-1,poison_category());
+ BOOST_TEST(fs::exists(".", ec));
+ BOOST_TEST(ec.value() == 0);
+ BOOST_TEST(ec.category() == system_category);
+ ec.assign(-1,poison_category());
+ BOOST_TEST(!fs::is_regular_file(".", ec));
+ BOOST_TEST(ec.value() == 0);
+ BOOST_TEST(ec.category() == system_category);
+ ec.assign(-1,poison_category());
+ BOOST_TEST(fs::is_directory(".", ec));
+ BOOST_TEST(ec.value() == 0);
+ BOOST_TEST(ec.category() == system_category);
+
+ // test queries, ec, for non-existing file
+ ec.assign(-1,poison_category());
+ BOOST_TEST(!fs::exists(p, ec));
+ BOOST_TEST(ec.value() != 0);
+ BOOST_TEST(ec.category() == system_category);
+ ec.assign(-1,poison_category());
+ BOOST_TEST(!fs::is_regular_file(p, ec));
+ BOOST_TEST(ec.value() != 0);
+ BOOST_TEST(ec.category() == system_category);
+ ec.assign(-1,poison_category());
+ BOOST_TEST(!fs::is_directory(p, ec));
+ BOOST_TEST(ec.value() != 0);
+ BOOST_TEST(ec.category() == system_category);
+ }
+
// _tests --------------------------------------------------------------------------//
void _tests()
@@ -935,6 +1002,7 @@
BOOST_TEST(fs::is_empty(d1));
status_of_nonexistent_tests();
+ status_error_reporting_tests();
directory_iterator_tests();
create_directories_tests(); // must run AFTER directory_iterator_tests
Boost-Commit list run by bdawes at acm.org, david.abrahams at rcn.com, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk