Boost logo

Boost-Commit :

From: bdawes_at_[hidden]
Date: 2008-06-25 10:17:00


Author: bemandawes
Date: 2008-06-25 10:16:59 EDT (Wed, 25 Jun 2008)
New Revision: 46678
URL: http://svn.boost.org/trac/boost/changeset/46678

Log:
Add const char* constructors to system_error, rationalize test coverage
Text files modified:
   trunk/boost/system/system_error.hpp | 14 ++++++++-
   trunk/libs/system/doc/reference.html | 18 +++++++++++
   trunk/libs/system/test/system_error_test.cpp | 59 ++++++++++++++++++++++++++++-----------
   3 files changed, 71 insertions(+), 20 deletions(-)

Modified: trunk/boost/system/system_error.hpp
==============================================================================
--- trunk/boost/system/system_error.hpp (original)
+++ trunk/boost/system/system_error.hpp 2008-06-25 10:16:59 EDT (Wed, 25 Jun 2008)
@@ -24,13 +24,23 @@
     public:
       system_error( error_code ec )
           : std::runtime_error(""), m_error_code(ec) {}
+
       system_error( error_code ec, const std::string & what_arg )
           : std::runtime_error(what_arg), m_error_code(ec) {}
+
+ system_error( error_code ec, const char* what_arg )
+ : std::runtime_error(what_arg), m_error_code(ec) {}
+
+ system_error( int ev, const error_category & ecat )
+ : std::runtime_error(""), m_error_code(ev,ecat) {}
+
       system_error( int ev, const error_category & ecat,
         const std::string & what_arg )
           : std::runtime_error(what_arg), m_error_code(ev,ecat) {}
- system_error( int ev, const error_category & ecat )
- : std::runtime_error(""), m_error_code(ev,ecat) {}
+
+ system_error( int ev, const error_category & ecat,
+ const char * what_arg )
+ : std::runtime_error(what_arg), m_error_code(ev,ecat) {}
 
       virtual ~system_error() throw() {}
 

Modified: trunk/libs/system/doc/reference.html
==============================================================================
--- trunk/libs/system/doc/reference.html (original)
+++ trunk/libs/system/doc/reference.html 2008-06-25 10:16:59 EDT (Wed, 25 Jun 2008)
@@ -689,8 +689,11 @@
     {
     public:
       system_error( error_code ec );
+ system_error( error_code ec, const char * what_arg );
       system_error( error_code ec, const std::string & what_arg );
       system_error( error_code::value_type ev, const error_category & ecat,
+ const char * what_arg );
+ system_error( error_code::value_type ev, const error_category & ecat,
                     const std::string & what_arg );
       system_error( error_code::value_type ev, const error_category & ecat);
 
@@ -706,6 +709,12 @@
   <p><i>Postcondition:</i> <code>code() == ec <br>
 &nbsp; &amp;&amp; std::strcmp( this-&gt;runtime_error::what(), &quot;&quot; ) == 0</code></p>
 </blockquote>
+<pre>system_error( error_code ec, const char * what_arg );</pre>
+<blockquote>
+ <p><i>Effects:</i> Constructs an object of class <code>system_error</code>.</p>
+ <p><i>Postcondition:</i> <code>code() == ec <br>
+&nbsp; &amp;&amp; std::strcmp( this-&gt;runtime_error::what(), what_arg ) == 0</code></p>
+</blockquote>
 <pre>system_error( error_code ec, const std::string &amp; what_arg );</pre>
 <blockquote>
   <p><i>Effects:</i> Constructs an object of class <code>system_error</code>.</p>
@@ -713,6 +722,13 @@
 &nbsp; &amp;&amp; std::strcmp( this-&gt;runtime_error::what(), what_arg.c_str() ) == 0</code></p>
 </blockquote>
 <pre>system_error( error_code::value_type ev, const error_category &amp; ecat,
+ const char * what_arg );</pre>
+<blockquote>
+ <p><i>Effects:</i> Constructs an object of class <code>system_error</code>.</p>
+ <p><i>Postcondition:</i> <code>code() == error_code( ev, ecat )<br>
+&nbsp; &amp;&amp; std::strcmp( this-&gt;runtime_error::what(), what_arg ) == 0</code></p>
+</blockquote>
+<pre>system_error( error_code::value_type ev, const error_category &amp; ecat,
              const std::string &amp; what_arg );</pre>
 <blockquote>
   <p><i>Effects:</i> Constructs an object of class <code>system_error</code>.</p>
@@ -743,7 +759,7 @@
 <a href="http://www.boost.org/LICENSE_1_0.txt">www.boost.org/LICENSE_1_0.txt</a></p>
 
 <p>Revised
-<!--webbot bot="Timestamp" S-Type="EDITED" S-Format="%B %d, %Y" startspan -->June 24, 2008<!--webbot bot="Timestamp" endspan i-checksum="14232" --> </font>
+<!--webbot bot="Timestamp" S-Type="EDITED" S-Format="%B %d, %Y" startspan -->June 25, 2008<!--webbot bot="Timestamp" endspan i-checksum="14296" --> </font>
 </p>
 
 </body>

Modified: trunk/libs/system/test/system_error_test.cpp
==============================================================================
--- trunk/libs/system/test/system_error_test.cpp (original)
+++ trunk/libs/system/test/system_error_test.cpp 2008-06-25 10:16:59 EDT (Wed, 25 Jun 2008)
@@ -14,6 +14,7 @@
 #include <boost/test/minimal.hpp>
 #include <boost/system/system_error.hpp>
 #include <iostream>
+#include <string>
 
 #ifdef BOOST_WINDOWS_API
 #include <windows.h>
@@ -22,6 +23,7 @@
 using boost::system::system_error;
 using boost::system::error_code;
 using boost::system::system_category;
+using std::string;
 
 #define TEST(x,v,w) test(#x,x,v,w)
 
@@ -51,29 +53,52 @@
 # endif
   }
 
- const boost::uint_least32_t uvalue = 1u;
+ const boost::uint_least32_t uvalue = 2u;
 }
 
 int test_main( int, char *[] )
 {
- // all combinations of constructors:
+ // all constructors, in the same order as they appear in the header:
 
- system_error se_0_m( error_code(0, system_category), "se_0_m" );
- system_error se_1_m( 1, system_category, "se_1_m" );
- system_error se_0_nm( error_code(0, system_category), "" );
- system_error se_1_nm( 1, system_category, "" );
- system_error se_0_nmx( error_code(0, system_category), "" );
- system_error se_1_nmx( 1, system_category, "" );
- system_error se_1u_m( uvalue, system_category, "se_1u_m" );
-
- TEST( se_0_m, 0, "se_0_m" );
- TEST( se_1_m, 1, "se_1_m: Incorrect function" );
- TEST( se_0_nm, 0, "" );
- TEST( se_1_nm, 1, "Incorrect function" );
- TEST( se_0_nmx, 0, "" );
- TEST( se_1_nmx, 1, "Incorrect function" );
- TEST( se_1u_m, 1, "se_1u_m: Incorrect function" );
+ system_error c1_0( error_code(0, system_category) );
+ system_error c1_1( error_code(1, system_category) );
+ system_error c1_2u( error_code(uvalue, system_category) );
 
+ system_error c2_0( error_code(0, system_category), string("c2_0") );
+ system_error c2_1( error_code(1, system_category), string("c2_1") );
+
+ system_error c3_0( error_code(0, system_category), "c3_0" );
+ system_error c3_1( error_code(1, system_category), "c3_1" );
+
+ system_error c4_0( 0, system_category );
+ system_error c4_1( 1, system_category );
+ system_error c4_2u( uvalue, system_category );
+
+ system_error c5_0( 0, system_category, string("c5_0") );
+ system_error c5_1( 1, system_category, string("c5_1") );
+
+ system_error c6_0( 0, system_category, "c6_0" );
+ system_error c6_1( 1, system_category, "c6_1" );
+
+ TEST( c1_0, 0, "" );
+ TEST( c1_1, 1, "Incorrect function" );
+ TEST( c1_2u, 2, "The system cannot find the file specified" );
+
+ TEST( c2_0, 0, "c2_0" );
+ TEST( c2_1, 1, "c2_1: Incorrect function" );
+
+ TEST( c3_0, 0, "c3_0" );
+ TEST( c3_1, 1, "c3_1: Incorrect function" );
+
+ TEST( c4_0, 0, "" );
+ TEST( c4_1, 1, "Incorrect function" );
+ TEST( c4_2u, 2, "The system cannot find the file specified" );
+
+ TEST( c5_0, 0, "c5_0" );
+ TEST( c5_1, 1, "c5_1: Incorrect function" );
+
+ TEST( c6_0, 0, "c6_0" );
+ TEST( c6_1, 1, "c6_1: Incorrect function" );
 
   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