mirror of
https://github.com/boostorg/system.git
synced 2025-07-30 04:27:14 +02:00
Add const char* constructors to system_error, rationalize test coverage
[SVN r46678]
This commit is contained in:
@ -689,7 +689,10 @@ application program interfaces.</p>
|
||||
{
|
||||
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,12 +709,25 @@ application program interfaces.</p>
|
||||
<p><i>Postcondition:</i> <code>code() == ec <br>
|
||||
&& std::strcmp( this->runtime_error::what(), "" ) == 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>
|
||||
&& std::strcmp( this->runtime_error::what(), what_arg ) == 0</code></p>
|
||||
</blockquote>
|
||||
<pre>system_error( error_code ec, const std::string & 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>
|
||||
&& std::strcmp( this->runtime_error::what(), what_arg.c_str() ) == 0</code></p>
|
||||
</blockquote>
|
||||
<pre>system_error( error_code::value_type ev, const error_category & 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>
|
||||
&& std::strcmp( this->runtime_error::what(), what_arg ) == 0</code></p>
|
||||
</blockquote>
|
||||
<pre>system_error( error_code::value_type ev, const error_category & ecat,
|
||||
const std::string & what_arg );</pre>
|
||||
<blockquote>
|
||||
@ -743,7 +759,7 @@ Distributed under the Boost Software License, Version 1.0. See
|
||||
<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>
|
||||
|
@ -24,13 +24,23 @@ namespace boost
|
||||
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() {}
|
||||
|
||||
|
@ -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 @@ namespace
|
||||
# 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" );
|
||||
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) );
|
||||
|
||||
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 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;
|
||||
}
|
||||
|
Reference in New Issue
Block a user