Boost logo

Boost-Commit :

Subject: [Boost-commit] svn:boost r55489 - in branches/release: boost/system libs/system libs/system/src libs/system/test libs/system/test/msvc_system libs/system/test/system_msvc libs/system/test/system_msvc/error_code_test
From: bdawes_at_[hidden]
Date: 2009-08-09 13:34:58


Author: bemandawes
Date: 2009-08-09 13:34:58 EDT (Sun, 09 Aug 2009)
New Revision: 55489
URL: http://svn.boost.org/trac/boost/changeset/55489

Log:
Merge from trunk
Added:
   branches/release/libs/system/CMakeLists.txt
      - copied unchanged from r55488, /trunk/libs/system/CMakeLists.txt
   branches/release/libs/system/module.cmake
      - copied unchanged from r55488, /trunk/libs/system/module.cmake
   branches/release/libs/system/src/CMakeLists.txt
      - copied unchanged from r55488, /trunk/libs/system/src/CMakeLists.txt
   branches/release/libs/system/test/system_msvc/
      - copied from r55488, /trunk/libs/system/test/system_msvc/
   branches/release/libs/system/test/system_msvc/common.vsprops
      - copied unchanged from r55488, /trunk/libs/system/test/system_msvc/common.vsprops
   branches/release/libs/system/test/system_msvc/error_code_test/
      - copied from r55488, /trunk/libs/system/test/system_msvc/error_code_test/
   branches/release/libs/system/test/system_msvc/error_code_test/error_code_test.vcproj
      - copied unchanged from r55488, /trunk/libs/system/test/system_msvc/error_code_test/error_code_test.vcproj
   branches/release/libs/system/test/system_msvc/system_msvc.sln
      - copied unchanged from r55488, /trunk/libs/system/test/system_msvc/system_msvc.sln
Removed:
   branches/release/libs/system/test/msvc_system/
Properties modified:
   branches/release/boost/system/ (props changed)
   branches/release/libs/system/ (props changed)
Text files modified:
   branches/release/boost/system/error_code.hpp | 22 ++++
   branches/release/libs/system/src/error_code.cpp | 4
   branches/release/libs/system/test/Jamfile.v2 | 2
   branches/release/libs/system/test/error_code_test.cpp | 216 ++++++++++++++++++++--------------------
   4 files changed, 134 insertions(+), 110 deletions(-)

Modified: branches/release/boost/system/error_code.hpp
==============================================================================
--- branches/release/boost/system/error_code.hpp (original)
+++ branches/release/boost/system/error_code.hpp 2009-08-09 13:34:58 EDT (Sun, 09 Aug 2009)
@@ -384,8 +384,30 @@
     };
 
     // predefined error_code object used as "throw on error" tag
+# ifndef BOOST_SYSTEM_NO_DEPRECATED
     BOOST_SYSTEM_DECL extern error_code throws;
+# endif
+
+ // Moving from a "throws" object to a "throws" function without breaking
+ // existing code is a bit of a problem. The workaround is to place the
+ // "throws" function in namespace boost rather than namespace boost::system.
+
+ } // namespace system
+
+ namespace detail { inline system::error_code * throws() { return 0; } }
+ // Misuse of the error_code object is turned into a noisy failure by
+ // poisoning the reference. This particular implementation doesn't
+ // produce warnings or errors from popular compilers, is very efficient
+ // (as determined by inspecting generated code), and does not suffer
+ // from order of initialization problems. In practice, it also seems
+ // cause user function error handling implementation errors to be detected
+ // very early in the development cycle.
+
+ inline system::error_code & throws()
+ { return *detail::throws(); }
 
+ namespace system
+ {
     // non-member functions ------------------------------------------------//
 
     inline bool operator!=( const error_code & lhs,

Modified: branches/release/libs/system/src/error_code.cpp
==============================================================================
--- branches/release/libs/system/src/error_code.cpp (original)
+++ branches/release/libs/system/src/error_code.cpp 2009-08-09 13:34:58 EDT (Sun, 09 Aug 2009)
@@ -23,7 +23,7 @@
 #include <cassert>
 
 using namespace boost::system;
-using namespace boost::system::posix_error;
+using namespace boost::system::errc;
 
 #include <cstring> // for strerror/strerror_r
 
@@ -411,11 +411,13 @@
   namespace system
   {
 
+# ifndef BOOST_SYSTEM_NO_DEPRECATED
     BOOST_SYSTEM_DECL error_code throws; // "throw on error" special error_code;
                                          // note that it doesn't matter if this
                                          // isn't initialized before use since
                                          // the only use is to take its
                                          // address for comparison purposes
+# endif
 
     BOOST_SYSTEM_DECL const error_category & get_system_category()
     {

Modified: branches/release/libs/system/test/Jamfile.v2
==============================================================================
--- branches/release/libs/system/test/Jamfile.v2 (original)
+++ branches/release/libs/system/test/Jamfile.v2 2009-08-09 13:34:58 EDT (Sun, 09 Aug 2009)
@@ -40,4 +40,4 @@
          [ run header_only_test.cpp
            : : : <link>static
          ]
- ;
+ ;

Modified: branches/release/libs/system/test/error_code_test.cpp
==============================================================================
--- branches/release/libs/system/test/error_code_test.cpp (original)
+++ branches/release/libs/system/test/error_code_test.cpp 2009-08-09 13:34:58 EDT (Sun, 09 Aug 2009)
@@ -11,7 +11,7 @@
 
 #include <boost/config/warning_disable.hpp>
 
-#include <boost/test/minimal.hpp>
+#include <boost/detail/lightweight_test.hpp>
 #include <boost/system/error_code.hpp>
 #include <boost/system/cygwin_error.hpp>
 #include <boost/system/linux_error.hpp>
@@ -45,100 +45,100 @@
 
     ss << ec;
     ss >> s;
- BOOST_CHECK( s == expected );
+ BOOST_TEST( s == expected );
   }
 }
 
-// test_main ---------------------------------------------------------------//
+// main ------------------------------------------------------------------------------//
 
 // TODO: add hash_value tests
 
-int test_main( int, char ** )
+int main( int, char ** )
 {
 
   std::cout << "General tests...\n";
   // unit tests:
 
- BOOST_CHECK( posix_category == posix_category );
- BOOST_CHECK( system_category == system_category );
- BOOST_CHECK( posix_category != system_category );
- BOOST_CHECK( system_category != posix_category );
+ BOOST_TEST( posix_category == posix_category );
+ BOOST_TEST( system_category == system_category );
+ BOOST_TEST( posix_category != system_category );
+ BOOST_TEST( system_category != posix_category );
 
   if ( std::less<const error_category*>()( &posix_category, &system_category ) )
   {
- BOOST_CHECK( posix_category < system_category );
- BOOST_CHECK( !(system_category < posix_category) );
+ BOOST_TEST( posix_category < system_category );
+ BOOST_TEST( !(system_category < posix_category) );
   }
   else
   {
- BOOST_CHECK( system_category < posix_category );
- BOOST_CHECK( !(posix_category < system_category) );
+ BOOST_TEST( system_category < posix_category );
+ BOOST_TEST( !(posix_category < system_category) );
   }
 
 
   error_code ec;
   error_condition dec;
- BOOST_CHECK( !ec );
- BOOST_CHECK( ec.value() == 0 );
+ BOOST_TEST( !ec );
+ BOOST_TEST( ec.value() == 0 );
   dec = ec.default_error_condition();
- BOOST_CHECK( dec.value() == 0 );
- BOOST_CHECK( dec.category() == posix_category );
- BOOST_CHECK( ec == posix::success );
- BOOST_CHECK( ec.category() == system_category );
- BOOST_CHECK( std::strcmp( ec.category().name(), "system") == 0 );
- BOOST_CHECK( !(ec < error_code( 0, system_category )) );
- BOOST_CHECK( !(error_code( 0, system_category ) < ec) );
- BOOST_CHECK( ec < error_code( 1, system_category ) );
- BOOST_CHECK( !(error_code( 1, system_category ) < ec) );
+ BOOST_TEST( dec.value() == 0 );
+ BOOST_TEST( dec.category() == posix_category );
+ BOOST_TEST( ec == posix::success );
+ BOOST_TEST( ec.category() == system_category );
+ BOOST_TEST( std::strcmp( ec.category().name(), "system") == 0 );
+ BOOST_TEST( !(ec < error_code( 0, system_category )) );
+ BOOST_TEST( !(error_code( 0, system_category ) < ec) );
+ BOOST_TEST( ec < error_code( 1, system_category ) );
+ BOOST_TEST( !(error_code( 1, system_category ) < ec) );
 
   error_code ec_0_system( 0, system_category );
- BOOST_CHECK( !ec_0_system );
- BOOST_CHECK( ec_0_system.value() == 0 );
+ BOOST_TEST( !ec_0_system );
+ BOOST_TEST( ec_0_system.value() == 0 );
   dec = ec_0_system.default_error_condition();
- BOOST_CHECK( dec.value() == 0 );
- BOOST_CHECK( dec.category() == posix_category );
- BOOST_CHECK( ec_0_system == posix::success );
- BOOST_CHECK( ec_0_system.category() == system_category );
- BOOST_CHECK( std::strcmp( ec_0_system.category().name(), "system") == 0 );
+ BOOST_TEST( dec.value() == 0 );
+ BOOST_TEST( dec.category() == posix_category );
+ BOOST_TEST( ec_0_system == posix::success );
+ BOOST_TEST( ec_0_system.category() == system_category );
+ BOOST_TEST( std::strcmp( ec_0_system.category().name(), "system") == 0 );
   check_ostream( ec_0_system, "system:0" );
 
- BOOST_CHECK( ec_0_system == ec );
+ BOOST_TEST( ec_0_system == ec );
 
   error_code ec_1_system( 1, system_category );
- BOOST_CHECK( ec_1_system );
- BOOST_CHECK( ec_1_system.value() == 1 );
- BOOST_CHECK( ec_1_system.value() != 0 );
- BOOST_CHECK( ec != ec_1_system );
- BOOST_CHECK( ec_0_system != ec_1_system );
+ BOOST_TEST( ec_1_system );
+ BOOST_TEST( ec_1_system.value() == 1 );
+ BOOST_TEST( ec_1_system.value() != 0 );
+ BOOST_TEST( ec != ec_1_system );
+ BOOST_TEST( ec_0_system != ec_1_system );
   check_ostream( ec_1_system, "system:1" );
 
   ec = error_code( BOOST_ACCESS_ERROR_MACRO, system_category );
- BOOST_CHECK( ec );
- BOOST_CHECK( ec.value() == BOOST_ACCESS_ERROR_MACRO );
+ BOOST_TEST( ec );
+ BOOST_TEST( ec.value() == BOOST_ACCESS_ERROR_MACRO );
   dec = ec.default_error_condition();
- BOOST_CHECK( dec.value() == static_cast<int>(posix::permission_denied) );
- BOOST_CHECK( dec.category() == posix_category );
- BOOST_CHECK( dec == error_condition( posix::permission_denied, posix_category ) );
- BOOST_CHECK( dec == posix::permission_denied );
- BOOST_CHECK( posix::permission_denied == dec );
- BOOST_CHECK( ec == posix::permission_denied );
- BOOST_CHECK( ec.category() == system_category );
- BOOST_CHECK( std::strcmp( ec.category().name(), "system") == 0 );
+ BOOST_TEST( dec.value() == static_cast<int>(posix::permission_denied) );
+ BOOST_TEST( dec.category() == posix_category );
+ BOOST_TEST( dec == error_condition( posix::permission_denied, posix_category ) );
+ BOOST_TEST( dec == posix::permission_denied );
+ BOOST_TEST( posix::permission_denied == dec );
+ BOOST_TEST( ec == posix::permission_denied );
+ BOOST_TEST( ec.category() == system_category );
+ BOOST_TEST( std::strcmp( ec.category().name(), "system") == 0 );
 
   // test the explicit make_error_code conversion for posix
   ec = make_error_code( posix::bad_message );
- BOOST_CHECK( ec );
- BOOST_CHECK( ec == posix::bad_message );
- BOOST_CHECK( posix::bad_message == ec );
- BOOST_CHECK( ec != posix::permission_denied );
- BOOST_CHECK( posix::permission_denied != ec );
- BOOST_CHECK( ec.category() == posix_category );
+ BOOST_TEST( ec );
+ BOOST_TEST( ec == posix::bad_message );
+ BOOST_TEST( posix::bad_message == ec );
+ BOOST_TEST( ec != posix::permission_denied );
+ BOOST_TEST( posix::permission_denied != ec );
+ BOOST_TEST( ec.category() == posix_category );
 
   // test the deprecated predefined error_category synonyms
- BOOST_CHECK( &system_category == &native_ecat );
- BOOST_CHECK( &posix_category == &errno_ecat );
- BOOST_CHECK( system_category == native_ecat );
- BOOST_CHECK( posix_category == errno_ecat );
+ BOOST_TEST( &system_category == &native_ecat );
+ BOOST_TEST( &posix_category == &errno_ecat );
+ BOOST_TEST( system_category == native_ecat );
+ BOOST_TEST( posix_category == errno_ecat );
 
   // test error_code and error_condition message();
   // see Boost.Filesystem operations_test for code specific message() tests
@@ -146,120 +146,120 @@
   std::cout << "error_code message for -1 is \"" << ec.message() << "\"\n";
 #if defined(BOOST_WINDOWS_API)
   // Borland appends newline, so just check text
- BOOST_CHECK( ec.message().substr(0,13) == "Unknown error" );
+ BOOST_TEST( ec.message().substr(0,13) == "Unknown error" );
 #elif defined(linux) || defined(__linux) || defined(__linux__)
   // Linux appends value to message as unsigned, so it varies with # of bits
- BOOST_CHECK( ec.message().substr(0,13) == "Unknown error" );
+ BOOST_TEST( ec.message().substr(0,13) == "Unknown error" );
 #elif defined(__hpux)
- BOOST_CHECK( ec.message() == "" );
+ BOOST_TEST( ec.message() == "" );
 #elif defined(__osf__)
- BOOST_CHECK( ec.message() == "Error -1 occurred." );
+ BOOST_TEST( ec.message() == "Error -1 occurred." );
 #elif defined(__vms)
- BOOST_CHECK( ec.message() == "error -1" );
+ BOOST_TEST( ec.message() == "error -1" );
 #endif
 
   ec = error_code( BOOST_ACCESS_ERROR_MACRO, system_category );
- BOOST_CHECK( ec.message() != "" );
- BOOST_CHECK( ec.message().substr( 0, 13) != "Unknown error" );
+ BOOST_TEST( ec.message() != "" );
+ BOOST_TEST( ec.message().substr( 0, 13) != "Unknown error" );
 
   dec = error_condition( -1, posix_category );
   std::cout << "error_condition message for -1 is \"" << dec.message() << "\"\n";
 #if defined(BOOST_WINDOWS_API)
   // Borland appends newline, so just check text
- BOOST_CHECK( dec.message().substr(0,13) == "Unknown error" );
+ BOOST_TEST( dec.message().substr(0,13) == "Unknown error" );
 #elif defined(linux) || defined(__linux) || defined(__linux__)
   // Linux appends value to message as unsigned, so it varies with # of bits
- BOOST_CHECK( dec.message().substr(0,13) == "Unknown error" );
+ BOOST_TEST( dec.message().substr(0,13) == "Unknown error" );
 #elif defined(__hpux)
- BOOST_CHECK( dec.message() == "" );
+ BOOST_TEST( dec.message() == "" );
 #elif defined(__osf__)
- BOOST_CHECK( dec.message() == "Error -1 occurred." );
+ BOOST_TEST( dec.message() == "Error -1 occurred." );
 #elif defined(__vms)
- BOOST_CHECK( dec.message() == "error -1" );
+ BOOST_TEST( dec.message() == "error -1" );
 #endif
 
   dec = error_condition( BOOST_ACCESS_ERROR_MACRO, posix_category );
- BOOST_CHECK( dec.message() != "" );
- BOOST_CHECK( dec.message().substr( 0, 13) != "Unknown error" );
+ BOOST_TEST( dec.message() != "" );
+ BOOST_TEST( dec.message().substr( 0, 13) != "Unknown error" );
 
 #ifdef BOOST_WINDOWS_API
   std::cout << "Windows tests...\n";
   // these tests probe the Windows posix decoder
   // test the first entry in the decoder table:
   ec = error_code( ERROR_ACCESS_DENIED, system_category );
- BOOST_CHECK( ec.value() == ERROR_ACCESS_DENIED );
- BOOST_CHECK( ec == posix::permission_denied );
- BOOST_CHECK( ec.default_error_condition().value() == posix::permission_denied );
- BOOST_CHECK( ec.default_error_condition().category() == posix_category );
+ BOOST_TEST( ec.value() == ERROR_ACCESS_DENIED );
+ BOOST_TEST( ec == posix::permission_denied );
+ BOOST_TEST( ec.default_error_condition().value() == posix::permission_denied );
+ BOOST_TEST( ec.default_error_condition().category() == posix_category );
 
   // test the second entry in the decoder table:
   ec = error_code( ERROR_ALREADY_EXISTS, system_category );
- BOOST_CHECK( ec.value() == ERROR_ALREADY_EXISTS );
- BOOST_CHECK( ec == posix::file_exists );
- BOOST_CHECK( ec.default_error_condition().value() == posix::file_exists );
- BOOST_CHECK( ec.default_error_condition().category() == posix_category );
+ BOOST_TEST( ec.value() == ERROR_ALREADY_EXISTS );
+ BOOST_TEST( ec == posix::file_exists );
+ BOOST_TEST( ec.default_error_condition().value() == posix::file_exists );
+ BOOST_TEST( ec.default_error_condition().category() == posix_category );
 
   // test the third entry in the decoder table:
   ec = error_code( ERROR_BAD_UNIT, system_category );
- BOOST_CHECK( ec.value() == ERROR_BAD_UNIT );
- BOOST_CHECK( ec == posix::no_such_device );
- BOOST_CHECK( ec.default_error_condition().value() == posix::no_such_device );
- BOOST_CHECK( ec.default_error_condition().category() == posix_category );
+ BOOST_TEST( ec.value() == ERROR_BAD_UNIT );
+ BOOST_TEST( ec == posix::no_such_device );
+ BOOST_TEST( ec.default_error_condition().value() == posix::no_such_device );
+ BOOST_TEST( ec.default_error_condition().category() == posix_category );
 
   // test the last non-Winsock entry in the decoder table:
   ec = error_code( ERROR_WRITE_PROTECT, system_category );
- BOOST_CHECK( ec.value() == ERROR_WRITE_PROTECT );
- BOOST_CHECK( ec == posix::permission_denied );
- BOOST_CHECK( ec.default_error_condition().value() == posix::permission_denied );
- BOOST_CHECK( ec.default_error_condition().category() == posix_category );
+ BOOST_TEST( ec.value() == ERROR_WRITE_PROTECT );
+ BOOST_TEST( ec == posix::permission_denied );
+ BOOST_TEST( ec.default_error_condition().value() == posix::permission_denied );
+ BOOST_TEST( ec.default_error_condition().category() == posix_category );
 
   // test the last Winsock entry in the decoder table:
   ec = error_code( WSAEWOULDBLOCK, system_category );
- BOOST_CHECK( ec.value() == WSAEWOULDBLOCK );
- BOOST_CHECK( ec == posix::operation_would_block );
- BOOST_CHECK( ec.default_error_condition().value() == posix::operation_would_block );
- BOOST_CHECK( ec.default_error_condition().category() == posix_category );
+ BOOST_TEST( ec.value() == WSAEWOULDBLOCK );
+ BOOST_TEST( ec == posix::operation_would_block );
+ BOOST_TEST( ec.default_error_condition().value() == posix::operation_would_block );
+ BOOST_TEST( ec.default_error_condition().category() == posix_category );
 
   // test not-in-table condition:
   ec = error_code( 1234567890, system_category );
- BOOST_CHECK( ec.value() == 1234567890 );
- BOOST_CHECK( ec.default_error_condition().value() == 1234567890 );
- BOOST_CHECK( ec.default_error_condition().category() == system_category );
+ BOOST_TEST( ec.value() == 1234567890 );
+ BOOST_TEST( ec.default_error_condition().value() == 1234567890 );
+ BOOST_TEST( ec.default_error_condition().category() == system_category );
 
 #else // POSIX
 
   std::cout << "POSIX tests...\n";
   ec = error_code( EACCES, system_category );
- BOOST_CHECK( ec == error_code( posix::permission_denied, system_category ) );
- BOOST_CHECK( error_code( posix::permission_denied, system_category ) == ec );
- BOOST_CHECK( ec == posix::permission_denied );
- BOOST_CHECK( posix::permission_denied == ec );
- BOOST_CHECK( ec.default_error_condition().value() == posix::permission_denied );
- BOOST_CHECK( ec.default_error_condition().category() == posix_category );
+ BOOST_TEST( ec == error_code( posix::permission_denied, system_category ) );
+ BOOST_TEST( error_code( posix::permission_denied, system_category ) == ec );
+ BOOST_TEST( ec == posix::permission_denied );
+ BOOST_TEST( posix::permission_denied == ec );
+ BOOST_TEST( ec.default_error_condition().value() == posix::permission_denied );
+ BOOST_TEST( ec.default_error_condition().category() == posix_category );
 
 # ifdef __CYGWIN__
 
   std::cout << "Cygwin tests...\n";
   ec = cygwin_error::no_package;
- BOOST_CHECK( ec == cygwin_error::no_package );
- BOOST_CHECK( ec == error_code( ENOPKG, system_category ) );
- BOOST_CHECK( ec == error_code( cygwin_error::no_package, system_category ) );
- BOOST_CHECK( ec.default_error_condition().category() == system_category );
+ BOOST_TEST( ec == cygwin_error::no_package );
+ BOOST_TEST( ec == error_code( ENOPKG, system_category ) );
+ BOOST_TEST( ec == error_code( cygwin_error::no_package, system_category ) );
+ BOOST_TEST( ec.default_error_condition().category() == system_category );
 
 # elif defined(linux) || defined(__linux) || defined(__linux__)
 
   std::cout << "Linux tests...\n";
   ec = linux_error::dot_dot_error;
- BOOST_CHECK( ec == linux_error::dot_dot_error );
- BOOST_CHECK( ec == error_code( EDOTDOT, system_category ) );
- BOOST_CHECK( ec == error_code( linux_error::dot_dot_error, system_category ) );
- BOOST_CHECK( ec.default_error_condition().category() == system_category );
+ BOOST_TEST( ec == linux_error::dot_dot_error );
+ BOOST_TEST( ec == error_code( EDOTDOT, system_category ) );
+ BOOST_TEST( ec == error_code( linux_error::dot_dot_error, system_category ) );
+ BOOST_TEST( ec.default_error_condition().category() == system_category );
 
 # endif
 
 #endif
   
- return 0;
+ return ::boost::report_errors();
 }
 
 


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