Boost logo

Boost-Commit :

From: bdawes_at_[hidden]
Date: 2007-08-15 17:58:00


Author: bemandawes
Date: 2007-08-15 17:57:58 EDT (Wed, 15 Aug 2007)
New Revision: 38703
URL: http://svn.boost.org/trac/boost/changeset/38703

Log:
Much more complete; Chris test3 added. Windows, Cygwin, Linux enums added.
Text files modified:
   branches/c++0x/boost/boost/system/error_code.hpp | 240 +++++++++++++++++++++++++++++++++++++--
   branches/c++0x/boost/libs/system/src/error_code.cpp | 14 +
   branches/c++0x/boost/libs/system/test/error_code_test.cpp | 56 +++++++--
   branches/c++0x/boost/libs/system/test/error_code_user_test.cpp | 146 +++++++++++++++++++++++-
   4 files changed, 416 insertions(+), 40 deletions(-)

Modified: branches/c++0x/boost/boost/system/error_code.hpp
==============================================================================
--- branches/c++0x/boost/boost/system/error_code.hpp (original)
+++ branches/c++0x/boost/boost/system/error_code.hpp 2007-08-15 17:57:58 EDT (Wed, 15 Aug 2007)
@@ -19,9 +19,13 @@
 #include <string>
 #include <stdexcept>
 
-// TODO: undef these macros if no already defined
+// TODO: undef these macros if not already defined
 #include <boost/cerrno.hpp>
 
+# ifdef BOOST_WINDOWS_API
+# include <winerror.h>
+# endif
+
 #include <boost/config/abi_prefix.hpp> // must be the last #include
 
 namespace boost
@@ -30,14 +34,13 @@
   {
 
     class error_code;
- bool equivalent( const error_code & lhs, const error_code & rhs );
 
     namespace posix
     {
 
       enum posix_errno
       {
- no_error = 0,
+ success = 0,
         address_family_not_supported = EAFNOSUPPORT,
         address_in_use = EADDRINUSE,
         address_not_available = EADDRNOTAVAIL,
@@ -128,9 +131,9 @@
     {
     public:
       virtual ~error_category(){}
- virtual const std::string & name() const = 0;
- virtual error_code generic_error_code( int ev) const;
- virtual std::string message( int ev ) const = 0;
+ virtual const std::string & name() const; // see implementation note below
+ virtual std::string message( int ev ) const; // see implementation note below
+ virtual error_code portable_error_code( int ev) const;
 
       bool operator==(const error_category & rhs) const { return this == &rhs; }
       bool operator!=(const error_category & rhs) const { return !(*this == rhs); }
@@ -184,7 +187,7 @@
       // observers:
       int value() const { return m_val; }
       const error_category & category() const { return *m_cat; }
- error_code generic_error_code() const { return m_cat->generic_error_code(value()); }
+ error_code portable_error_code() const { return m_cat->portable_error_code(value()); }
       std::string message() const { return m_cat->message(value()); }
 
       typedef void (*unspecified_bool_type)();
@@ -212,11 +215,11 @@
                                      const error_code & rhs )
       {
         if ( lhs.m_cat == rhs.m_cat ) return lhs.m_val == rhs.m_val;
- return same( lhs, rhs.generic_error_code() )
- || same( lhs.generic_error_code(), rhs );
+ return same( lhs, rhs.portable_error_code() )
+ || same( lhs.portable_error_code(), rhs );
         // Rationale: As in the language proper, a single automatic conversion
         // is acceptable, but two automatic conversions are not. Thus
- // return same (lhs.generic_error_code(), rhs.generic_error_code()) is
+ // return same (lhs.portable_error_code(), rhs.portable_error_code()) is
         // not an acceptable implementation as it performs two conversions.
       }
 
@@ -260,13 +263,224 @@
             : 0);
     }
 
- // error_category::generic_error_code ----------------------------------//
- // implemented here now that error_code is a complete type
- inline error_code error_category::generic_error_code( int ev) const
+
+ // error_category implementation ---------------------------------------//
+
+ // error_code is a complete type at this point
+ inline error_code error_category::portable_error_code( int ev) const
     {
       return error_code( ev, *this );
     }
 
+ // error_category implementation note: VC++ 8.0 objects to name() and
+ // message() being pure virtual functions. Thus these implementations.
+ inline const std::string & error_category::name() const
+ {
+ static std::string s("error: should never be called");
+ return s;
+ }
+ inline std::string error_category::message( int ev ) const
+ {
+ static std::string s("error: should never be called");
+ return s;
+ }
+
+ // ----------------------------------------------------------------------//
+
+ // Operating system specific interfaces --------------------------------//
+
+
+ // The interface is divided into general and system-specific portions to
+ // meet these requirements:
+ //
+ // * Code calling an operating system API can create an error_code with
+ // a single category (system_category), even for POSIX-like operating
+ // systems that return some POSIX errno values and some native errno
+ // values. This code should not have to pay the cost of distinguishing
+ // between categories, since it is not yet know if that is needed.
+ //
+ // * Users wishing to write system-specific code should have enums for
+ // at least the common error cases.
+ //
+ // * System specific code should fail at compile time if moved to another
+ // operating system.
+
+#ifdef BOOST_POSIX_API
+
+ // POSIX-based systems -------------------------------------------------//
+
+ // To construct an error_code after a API error:
+ //
+ // error_code( errno, system_category )
+
+ // User code should use the portable "posix" enums for POSIX errors; this
+ // allows such code to be portable to non-POSIX systems. For the non-POSIX
+ // errno values that POSIX-based systems typically provide in addition to
+ // POSIX values, use the system specific enums below.
+
+# ifdef __CYGWIN__
+
+ namespace cygwin
+ {
+ enum cygwin_error
+ {
+ no_net = ENONET,
+ no_package = ENOPKG,
+ no_share = ENOSHARE,
+ };
+ } // namespace cygwin
+
+ inline error_code make_error_code(cygwin::cygwin_error e)
+ { return error_code( e, system_category ); }
+
+# elif defined(linux) || defined(__linux) || defined(__linux__)
+
+ namespace lnx // linux obvious name prempted by its use as predefined macro
+ {
+ enum linux_error
+ {
+ advertise_error = EADV,
+ bad_exchange = EBADE,
+ bad_file_number = EBADFD,
+ bad_font_format = EBFONT,
+ bad_request_code = EBADRQC,
+ bad_request_descriptor = EBADR,
+ bad_slot = EBADSLT,
+ channel_range = ECHRNG,
+ communication_error = ECOMM,
+ dot_dot_error = EDOTDOT,
+ exchange_full = EXFULL,
+ host_down = EHOSTDOWN,
+ is_named_file_type= EISNAM,
+ key_expired = EKEYEXPIRED,
+ key_rejected = EKEYREJECTED,
+ key_revoked = EKEYREVOKED,
+ level2_halt= EL2HLT,
+ level2_no_syncronized= EL2NSYNC,
+ level3_halt = EL3HLT,
+ level3_reset = EL3RST,
+ link_range = ELNRNG,
+ medium_type = EMEDIUMTYPE,
+ no_anode= ENOANO,
+ no_block_device = ENOTBLK,
+ no_csi = ENOCSI,
+ no_key = ENOKEY,
+ no_medium = ENOMEDIUM,
+ no_network = ENONET,
+ no_package = ENOPKG,
+ not_avail = ENAVAIL,
+ not_named_file_type= ENOTNAM,
+ not_recoverable = ENOTRECOVERABLE,
+ not_unique = ENOTUNIQ,
+ owner_dead = EOWNERDEAD,
+ protocol_no_supported = EPFNOSUPPORT,
+ remote_address_changed = EREMCHG,
+ remote_io_error = EREMOTEIO,
+ remote_object = EREMOTE,
+ restart_needed = ERESTART,
+ shared_library_access = ELIBACC,
+ shared_library_bad = ELIBBAD,
+ shared_library_execute = ELIBEXEC,
+ shared_library_max_ = ELIBMAX,
+ shared_library_section= ELIBSCN,
+ shutdown = ESHUTDOWN,
+ socket_type_not_supported = ESOCKTNOSUPPORT,
+ srmount_error = ESRMNT,
+ stream_pipe_error = ESTRPIPE,
+ too_many_references = ETOOMANYREFS,
+ too_many_users = EUSERS,
+ unattached = EUNATCH,
+ unclean = EUCLEAN,
+ };
+ } // namespace lnx
+
+ inline error_code make_error_code(lnx::linux_error e)
+ { return error_code( e, system_category ); }
+
+# endif
+
+ // TODO: Add more POSIX-based operating systems here
+
+
+#elif defined(BOOST_WINDOWS_API)
+
+ // Microsoft Windows ---------------------------------------------------//
+
+ // To construct an error_code after a API error:
+ //
+ // error_code( ::GetLastError(), system_category )
+
+ namespace windows
+ {
+ enum windows_error
+ {
+ success = 0,
+ // These names and values are based on Windows winerror.h
+ invalid_function = ERROR_INVALID_FUNCTION,
+ file_not_found = ERROR_FILE_NOT_FOUND,
+ path_not_found = ERROR_PATH_NOT_FOUND,
+ too_many_open_files = ERROR_TOO_MANY_OPEN_FILES,
+ access_denied = ERROR_ACCESS_DENIED,
+ invalid_handle = ERROR_INVALID_HANDLE,
+ arena_trashed = ERROR_ARENA_TRASHED,
+ not_enough_memory = ERROR_NOT_ENOUGH_MEMORY,
+ invalid_block = ERROR_INVALID_BLOCK,
+ bad_environment = ERROR_BAD_ENVIRONMENT,
+ bad_format = ERROR_BAD_FORMAT,
+ invalid_access = ERROR_INVALID_ACCESS,
+ outofmemory = ERROR_OUTOFMEMORY,
+ invalid_drive = ERROR_INVALID_DRIVE,
+ current_directory = ERROR_CURRENT_DIRECTORY,
+ not_same_device = ERROR_NOT_SAME_DEVICE,
+ no_more_files = ERROR_NO_MORE_FILES,
+ write_protect = ERROR_WRITE_PROTECT,
+ bad_unit = ERROR_BAD_UNIT,
+ not_ready = ERROR_NOT_READY,
+ bad_command = ERROR_BAD_COMMAND,
+ crc = ERROR_CRC,
+ bad_length = ERROR_BAD_LENGTH,
+ seek = ERROR_SEEK,
+ not_dos_disk = ERROR_NOT_DOS_DISK,
+ sector_not_found = ERROR_SECTOR_NOT_FOUND,
+ out_of_paper = ERROR_OUT_OF_PAPER,
+ write_fault = ERROR_WRITE_FAULT,
+ read_fault = ERROR_READ_FAULT,
+ gen_failure = ERROR_GEN_FAILURE,
+ sharing_violation = ERROR_SHARING_VIOLATION,
+ lock_violation = ERROR_LOCK_VIOLATION,
+ wrong_disk = ERROR_WRONG_DISK,
+ sharing_buffer_exceeded = ERROR_SHARING_BUFFER_EXCEEDED,
+ handle_eof = ERROR_HANDLE_EOF,
+ handle_disk_full= ERROR_HANDLE_DISK_FULL,
+ rem_not_list = ERROR_REM_NOT_LIST,
+ dup_name = ERROR_DUP_NAME,
+ bad_net_path = ERROR_BAD_NETPATH,
+ network_busy = ERROR_NETWORK_BUSY,
+ // ...
+ file_exists = ERROR_FILE_EXISTS,
+ cannot_make = ERROR_CANNOT_MAKE,
+ // ...
+ broken_pipe = ERROR_BROKEN_PIPE,
+ open_failed = ERROR_OPEN_FAILED,
+ buffer_overflow = ERROR_BUFFER_OVERFLOW,
+ disk_full= ERROR_DISK_FULL,
+ // ...
+ lock_failed = ERROR_LOCK_FAILED,
+ busy = ERROR_BUSY,
+ cancel_violation = ERROR_CANCEL_VIOLATION,
+ already_exists = ERROR_ALREADY_EXISTS
+ // ...
+
+ // TODO: add more Windows errors
+ };
+ } // namespace windows
+
+ inline error_code make_error_code(windows::windows_error e)
+ { return error_code( e, system_category ); }
+
+#else
+# error BOOST_POSIX_API or BOOST_WINDOWS_API must be defined
+#endif
 
   } // namespace system
 } // namespace boost

Modified: branches/c++0x/boost/libs/system/src/error_code.cpp
==============================================================================
--- branches/c++0x/boost/libs/system/src/error_code.cpp (original)
+++ branches/c++0x/boost/libs/system/src/error_code.cpp 2007-08-15 17:57:58 EDT (Wed, 15 Aug 2007)
@@ -64,7 +64,7 @@
     { EINVAL, invalid_argument },
 
     // rest are alphabetical for easy maintenance
- { 0, no_error },
+ { 0, success },
     { E2BIG, argument_list_too_long },
     { EADDRINUSE, address_in_use },
     { EADDRNOTAVAIL, address_not_available },
@@ -152,7 +152,7 @@
     { ERROR_PATH_NOT_FOUND, no_such_file_or_directory },
 
     // rest are alphabetical for easy maintenance
- { 0, no_error },
+ { 0, success },
     { ERROR_ACCESS_DENIED, permission_denied },
     { ERROR_ALREADY_EXISTS, file_exists },
     { ERROR_BAD_UNIT, no_such_device },
@@ -210,7 +210,7 @@
   public:
     const std::string & name() const;
     posix::posix_errno posix( int ev ) const;
- error_code generic_error_code( int ev ) const;
+ error_code portable_error_code( int ev ) const;
     std::string message( int ev ) const;
   };
 
@@ -309,14 +309,14 @@
     return boost::system::posix::no_posix_equivalent;
   }
 
- error_code system_error_category::generic_error_code( int ev ) const
+ error_code system_error_category::portable_error_code( int ev ) const
   {
     return error_code( posix(ev), posix_category );
   }
 
 # if !defined( BOOST_WINDOWS_API )
 
- std::string system_error_category::message( boost::int_least32_t ev ) const
+ std::string system_error_category::message( int ev ) const
   {
     return posix_category.message( ev );
   }
@@ -358,15 +358,19 @@
     return str;
   }
 # endif
+
 } // unnamed namespace
 
 namespace boost
 {
   namespace system
   {
+
     BOOST_SYSTEM_DECL const error_category & posix_category
       = posix_category_const;
+
     BOOST_SYSTEM_DECL const error_category & system_category
       = system_category_const;
+
   } // namespace system
 } // namespace boost

Modified: branches/c++0x/boost/libs/system/test/error_code_test.cpp
==============================================================================
--- branches/c++0x/boost/libs/system/test/error_code_test.cpp (original)
+++ branches/c++0x/boost/libs/system/test/error_code_test.cpp 2007-08-15 17:57:58 EDT (Wed, 15 Aug 2007)
@@ -22,7 +22,7 @@
 #include <boost/system/error_code.hpp>
 #include <iostream>
 #include <sstream>
-#include <cerrno>
+#include <boost/cerrno.hpp>
 
 // Although using directives are not the best programming practice, testing
 // with a boost::system using directive increases use scenario coverage.
@@ -30,7 +30,6 @@
 
 # if defined( BOOST_WINDOWS_API )
 # include "winerror.h"
-# include <boost/cerrno.hpp>
 # define BOOST_ACCESS_ERROR_MACRO ERROR_ACCESS_DENIED
 # elif defined( BOOST_POSIX_API )
 # define BOOST_ACCESS_ERROR_MACRO EACCES
@@ -57,25 +56,26 @@
 
 int test_main( int, char ** )
 {
+ std::cout << "General tests...\n";
   // unit tests:
   error_code ec;
   error_code gec;
   BOOST_CHECK( !ec );
   BOOST_CHECK( ec.value() == 0 );
- gec = ec.generic_error_code();
+ gec = ec.portable_error_code();
   BOOST_CHECK( gec.value() == 0 );
   BOOST_CHECK( gec.category() == posix_category );
- BOOST_CHECK( ec == posix::no_error );
+ BOOST_CHECK( ec == posix::success );
   BOOST_CHECK( ec.category() == posix_category );
   BOOST_CHECK( ec.category().name() == "POSIX" );
 
   error_code ec_0_system( 0, system_category );
   BOOST_CHECK( !ec_0_system );
   BOOST_CHECK( ec_0_system.value() == 0 );
- gec = ec_0_system.generic_error_code();
+ gec = ec_0_system.portable_error_code();
   BOOST_CHECK( gec.value() == 0 );
   BOOST_CHECK( gec.category() == posix_category );
- BOOST_CHECK( ec_0_system == posix::no_error );
+ BOOST_CHECK( ec_0_system == posix::success );
   BOOST_CHECK( ec_0_system.category() == system_category );
   BOOST_CHECK( ec_0_system.category().name() == "system" );
   check_ostream( ec_0_system, "system:0" );
@@ -93,7 +93,7 @@
   ec = error_code( BOOST_ACCESS_ERROR_MACRO, system_category );
   BOOST_CHECK( ec );
   BOOST_CHECK( ec.value() == BOOST_ACCESS_ERROR_MACRO );
- gec = ec.generic_error_code();
+ gec = ec.portable_error_code();
   BOOST_CHECK( gec.value() == static_cast<int>(posix::permission_denied) );
   BOOST_CHECK( gec.category() == posix_category );
   BOOST_CHECK( same( gec, error_code( posix::permission_denied, posix_category ) ) );
@@ -104,39 +104,67 @@
   BOOST_CHECK( ec.category().name() == "system" );
 
 #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_FILE_NOT_FOUND, system_category );
   BOOST_CHECK( ec.value() == ERROR_FILE_NOT_FOUND );
   BOOST_CHECK( ec == posix::no_such_file_or_directory );
- BOOST_CHECK( ec.generic_error_code().value() == posix::no_such_file_or_directory );
+ BOOST_CHECK( ec.portable_error_code().value() == posix::no_such_file_or_directory );
 
   // test the second entry in the decoder table:
   ec = error_code( ERROR_PATH_NOT_FOUND, system_category );
   BOOST_CHECK( ec.value() == ERROR_PATH_NOT_FOUND );
   BOOST_CHECK( ec == posix::no_such_file_or_directory );
- BOOST_CHECK( ec.generic_error_code().value() == posix::no_such_file_or_directory );
+ BOOST_CHECK( ec.portable_error_code().value() == posix::no_such_file_or_directory );
 
   // test the third 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.generic_error_code().value() == posix::permission_denied );
+ BOOST_CHECK( ec.portable_error_code().value() == posix::permission_denied );
 
   // test the last regular 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.generic_error_code().value() == posix::permission_denied );
+ BOOST_CHECK( ec.portable_error_code().value() == posix::permission_denied );
 
   // test not-in-table condition:
   ec = error_code( 1234567890, system_category );
   BOOST_CHECK( ec.value() == 1234567890 );
   BOOST_CHECK( ec == posix::no_posix_equivalent );
- BOOST_CHECK( ec.generic_error_code().value() == posix::no_posix_equivalent );
+ BOOST_CHECK( ec.portable_error_code().value() == posix::no_posix_equivalent );
+
+#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 );
+
+# ifdef __CYGWIN__
+
+ std::cout << "Cygwin tests...\n";
+ ec = cygwin::no_package;
+ BOOST_CHECK( ec == cygwin::no_package );
+ BOOST_CHECK( ec == error_code( ENOPKG, system_category ) );
+ BOOST_CHECK( ec == error_code( cygwin::no_package, system_category ) );
+ BOOST_CHECK( ec == posix::no_posix_equivalent );
+
+# elif defined(linux) || defined(__linux) || defined(__linux__)
+
+ std::cout << "Linux tests...\n";
+ ec = lnx::dot_dot_error;
+ BOOST_CHECK( ec == lnx::dot_dot_error );
+ BOOST_CHECK( ec == error_code( EDOTDOT, system_category ) );
+ BOOST_CHECK( ec == error_code( lnx::dot_dot_error, system_category ) );
+ BOOST_CHECK( ec == posix::no_posix_equivalent );
+
+# endif
 
-#else
- // TODO: write some POSIX tests
 #endif
   
   return 0;

Modified: branches/c++0x/boost/libs/system/test/error_code_user_test.cpp
==============================================================================
--- branches/c++0x/boost/libs/system/test/error_code_user_test.cpp (original)
+++ branches/c++0x/boost/libs/system/test/error_code_user_test.cpp 2007-08-15 17:57:58 EDT (Wed, 15 Aug 2007)
@@ -20,12 +20,6 @@
 #include <cstdio>
 #include <boost/test/minimal.hpp>
 
-// Although using directives are not the best programming practice, testing
-// with a boost::system using directive increases use scenario coverage.
-// There also appears to be a bug in Microsoft VC++ 8.0 that is worked
-// around by this using directive.
-using namespace boost::system;
-
 #ifdef BOOST_POSIX_API
 # include <sys/stat.h>
 #else
@@ -109,7 +103,7 @@
         return s;
       }
 
- boost::system::error_code generic_error_code( int ev ) const
+ boost::system::error_code portable_error_code( int ev ) const
       {
         return boost::system::error_code(
           ev == boo_boo
@@ -167,7 +161,7 @@
       return s;
     }
 
- boost::system::error_code generic_error_code( int ev ) const
+ boost::system::error_code portable_error_code( int ev ) const
     {
       return boost::system::error_code(
         ev == boo_boo.value()
@@ -196,6 +190,139 @@
 
 // ------------------------------------------------------------------------ //
 
+// Chris Kolhoff's Test3, modified to work with error_code.hpp
+
+// Test3
+// =====
+// Define error classes to check for success, permission_denied and
+// out_of_memory, but add additional mappings for a user-defined error category.
+//
+
+namespace stdx = boost::system;
+
+namespace test3 {
+
+ enum user_err
+ {
+ user_success = 0,
+ user_permission_denied,
+ user_out_of_memory
+ };
+
+ class user_error_category_imp : public boost::system::error_category
+ {
+ public:
+ const std::string & name() const
+ {
+ static std::string s( "test3" );
+ return s;
+ }
+
+ stdx::error_code portable_error_code( int ev ) const
+ {
+ switch (ev)
+ {
+ case user_success:
+ return stdx::error_code(stdx::posix::success, stdx::posix_category);
+ case user_permission_denied:
+ return stdx::error_code(stdx::posix::permission_denied, stdx::posix_category);
+ case user_out_of_memory:
+ return stdx::error_code(stdx::posix::not_enough_memory, stdx::posix_category);
+ default:
+ break;
+ }
+ return stdx::error_code(stdx::posix::no_posix_equivalent, stdx::posix_category);
+ }
+
+ };
+
+ const user_error_category_imp user_error_category_const;
+
+ const stdx::error_category & user_error_category
+ = user_error_category_const;
+
+ inline stdx::error_code make_error_code(user_err e)
+ {
+ return stdx::error_code(e, user_error_category);
+ }
+
+ // test code
+
+ void check_success(const stdx::error_code& ec, bool expect)
+ {
+ BOOST_CHECK( (ec == stdx::posix::success) == expect );
+ if (ec == stdx::posix::success)
+ std::cout << "yes... " << (expect ? "ok" : "fail") << '\n';
+ else
+ std::cout << "no... " << (expect ? "fail" : "ok") << '\n';
+ }
+
+ void check_permission_denied(const stdx::error_code& ec, bool expect)
+ {
+ BOOST_CHECK( (ec == stdx::posix::permission_denied) == expect );
+ if (ec == stdx::posix::permission_denied)
+ std::cout << "yes... " << (expect ? "ok" : "fail") << '\n';
+ else
+ std::cout << "no... " << (expect ? "fail" : "ok") << '\n';
+ }
+
+ void check_out_of_memory(const stdx::error_code& ec, bool expect)
+ {
+ BOOST_CHECK( (ec == stdx::posix::not_enough_memory) == expect );
+ if (ec == stdx::posix::not_enough_memory)
+ std::cout << "yes... " << (expect ? "ok" : "fail") << '\n';
+ else
+ std::cout << "no... " << (expect ? "fail" : "ok") << '\n';
+ }
+
+ void run()
+ {
+ printf("Test3\n");
+ printf("=====\n");
+ stdx::error_code ec;
+ check_success(ec, true);
+ check_success(stdx::posix::success, true);
+ check_success(stdx::posix::permission_denied, false);
+ check_success(stdx::posix::not_enough_memory, false);
+ check_success(user_success, true);
+ check_success(user_permission_denied, false);
+ check_success(user_out_of_memory, false);
+ check_permission_denied(ec, false);
+ check_permission_denied(stdx::posix::success, false);
+ check_permission_denied(stdx::posix::permission_denied, true);
+ check_permission_denied(stdx::posix::not_enough_memory, false);
+ check_permission_denied(user_success, false);
+ check_permission_denied(user_permission_denied, true);
+ check_permission_denied(user_out_of_memory, false);
+ check_out_of_memory(ec, false);
+ check_out_of_memory(stdx::posix::success, false);
+ check_out_of_memory(stdx::posix::permission_denied, false);
+ check_out_of_memory(stdx::posix::not_enough_memory, true);
+ check_out_of_memory(user_success, false);
+ check_out_of_memory(user_permission_denied, false);
+ check_out_of_memory(user_out_of_memory, true);
+
+# ifdef BOOST_WINDOWS_API
+ check_success(stdx::windows::success, true);
+ check_success(stdx::windows::access_denied, false);
+ check_success(stdx::windows::not_enough_memory, false);
+ check_permission_denied(stdx::windows::success, false);
+ check_permission_denied(stdx::windows::access_denied, true);
+ check_permission_denied(stdx::windows::not_enough_memory, false);
+ check_out_of_memory(stdx::windows::success, false);
+ check_out_of_memory(stdx::windows::access_denied, false);
+ check_out_of_memory(stdx::windows::not_enough_memory, true);
+# endif
+
+ printf("\n");
+ }
+
+} // namespace test3
+
+
+
+// ------------------------------------------------------------------------ //
+
 int test_main( int, char *[] )
 {
   boost::system::error_code ec;
@@ -250,6 +377,9 @@
     lib4::lib4_error_category );
   BOOST_CHECK( ec4 == boost::system::posix::no_posix_equivalent );
 
+ // Test 3
+
+ test3::run();
 
   return 0;
 }


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