mirror of
https://github.com/boostorg/system.git
synced 2025-12-25 16:28:05 +01:00
Compare commits
6 Commits
feature/er
...
feature/st
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
9151633c95 | ||
|
|
5e0db22075 | ||
|
|
60a20eeeb9 | ||
|
|
1c8128e4cb | ||
|
|
1879ba6d35 | ||
|
|
b1dec88674 |
@@ -102,18 +102,26 @@ inline char const * error_category::message( int ev, char * buffer, std::size_t
|
||||
|
||||
inline boost::system::error_category::operator std::error_category const & () const
|
||||
{
|
||||
if( id_ == boost::system::detail::generic_category_id )
|
||||
{
|
||||
#if defined(BOOST_GCC) && BOOST_GCC < 50000
|
||||
|
||||
static const boost::system::detail::std_category generic_instance( this, 0x1F4D3 );
|
||||
return generic_instance;
|
||||
|
||||
#else
|
||||
|
||||
return std::generic_category();
|
||||
|
||||
#endif
|
||||
}
|
||||
|
||||
if( id_ == boost::system::detail::system_category_id )
|
||||
{
|
||||
static const boost::system::detail::std_category system_instance( this, 0x1F4D7 );
|
||||
return system_instance;
|
||||
}
|
||||
|
||||
if( id_ == boost::system::detail::generic_category_id )
|
||||
{
|
||||
static const boost::system::detail::std_category generic_instance( this, 0x1F4D3 );
|
||||
return generic_instance;
|
||||
}
|
||||
|
||||
boost::system::detail::std_category* p = ps_.load( std::memory_order_acquire );
|
||||
|
||||
if( p != 0 )
|
||||
|
||||
@@ -6,8 +6,8 @@
|
||||
// Distributed under the Boost Software License, Version 1.0.
|
||||
// https://www.boost.org/LICENSE_1_0.txt
|
||||
|
||||
#include <boost/system/errc.hpp>
|
||||
#include <boost/system/detail/error_code.hpp>
|
||||
#include <boost/system/detail/error_category_impl.hpp>
|
||||
#include <boost/system/detail/snprintf.hpp>
|
||||
#include <string>
|
||||
#include <stdexcept>
|
||||
|
||||
@@ -103,6 +103,7 @@ boost_test(TYPE run SOURCES ec_location_test.cpp)
|
||||
|
||||
boost_test(TYPE run SOURCES error_condition_test3.cpp)
|
||||
boost_test(TYPE run SOURCES error_code_test2.cpp)
|
||||
boost_test(TYPE run SOURCES system_error_test2.cpp)
|
||||
|
||||
# result
|
||||
|
||||
|
||||
@@ -125,6 +125,7 @@ run ec_location_test.cpp ;
|
||||
|
||||
run error_condition_test3.cpp ;
|
||||
run error_code_test2.cpp ;
|
||||
run system_error_test2.cpp ;
|
||||
|
||||
# result
|
||||
|
||||
|
||||
@@ -44,7 +44,8 @@ static void test_generic_category()
|
||||
|
||||
int ev = ENOENT;
|
||||
|
||||
BOOST_TEST_EQ( bt.message( ev ), st.message( ev ) );
|
||||
// Under MSVC, it's "no such file or directory" instead of "No such file or directory"
|
||||
BOOST_TEST_EQ( bt.message( ev ).substr( 1 ), st.message( ev ).substr( 1 ) );
|
||||
|
||||
{
|
||||
boost::system::error_code bc( ev, bt );
|
||||
|
||||
@@ -30,7 +30,7 @@ int main()
|
||||
BOOST_TEST_EQ( e2, e1 );
|
||||
BOOST_TEST_NOT( e2 != e1 );
|
||||
|
||||
BOOST_TEST( e2 == en );
|
||||
BOOST_TEST_EQ( e2, en );
|
||||
BOOST_TEST_NOT( e2 != en );
|
||||
|
||||
boost::system::error_code e3( e2 );
|
||||
@@ -51,7 +51,7 @@ int main()
|
||||
BOOST_TEST_EQ( e2, e1 );
|
||||
BOOST_TEST_NOT( e2 != e1 );
|
||||
|
||||
BOOST_TEST( e2 == en );
|
||||
BOOST_TEST_EQ( e2, en );
|
||||
BOOST_TEST_NOT( e2 != en );
|
||||
|
||||
boost::system::error_code e3( e2 );
|
||||
@@ -72,7 +72,7 @@ int main()
|
||||
BOOST_TEST_EQ( e2, e1 );
|
||||
BOOST_TEST_NOT( e2 != e1 );
|
||||
|
||||
BOOST_TEST( e2 == en );
|
||||
BOOST_TEST_EQ( e2, en );
|
||||
BOOST_TEST_NOT( e2 != en );
|
||||
|
||||
boost::system::error_code e3( e2 );
|
||||
@@ -93,7 +93,7 @@ int main()
|
||||
BOOST_TEST_EQ( e2, e1 );
|
||||
BOOST_TEST_NOT( e2 != e1 );
|
||||
|
||||
BOOST_TEST( e2 == en );
|
||||
BOOST_TEST_EQ( e2, en );
|
||||
BOOST_TEST_NOT( e2 != en );
|
||||
|
||||
boost::system::error_code e3( e2 );
|
||||
@@ -114,7 +114,7 @@ int main()
|
||||
BOOST_TEST_EQ( e2, e1 );
|
||||
BOOST_TEST_NOT( e2 != e1 );
|
||||
|
||||
BOOST_TEST( e2 == en );
|
||||
BOOST_TEST_EQ( e2, en );
|
||||
BOOST_TEST_NOT( e2 != en );
|
||||
|
||||
boost::system::error_code e3( e2 );
|
||||
|
||||
41
test/system_error_test2.cpp
Normal file
41
test/system_error_test2.cpp
Normal file
@@ -0,0 +1,41 @@
|
||||
// Copyright 2021 Peter Dimov
|
||||
// Distributed under the Boost Software License, Version 1.0
|
||||
// https://www.boost.org/LICENSE_1_0.txt
|
||||
|
||||
#include <boost/system/system_error.hpp>
|
||||
#include <boost/core/lightweight_test.hpp>
|
||||
#include <cerrno>
|
||||
|
||||
namespace sys = boost::system;
|
||||
|
||||
int main()
|
||||
{
|
||||
{
|
||||
sys::error_code ec( 5, sys::generic_category() );
|
||||
sys::system_error x1( ec );
|
||||
(void)x1;
|
||||
}
|
||||
|
||||
{
|
||||
sys::error_code ec( 5, sys::system_category() );
|
||||
sys::system_error x1( ec );
|
||||
(void)x1;
|
||||
}
|
||||
|
||||
{
|
||||
sys::system_error x1( make_error_code( sys::errc::invalid_argument ) );
|
||||
(void)x1;
|
||||
}
|
||||
|
||||
{
|
||||
sys::system_error x1( 5, sys::generic_category() );
|
||||
(void)x1;
|
||||
}
|
||||
|
||||
{
|
||||
sys::system_error x1( 5, sys::system_category() );
|
||||
(void)x1;
|
||||
}
|
||||
|
||||
return boost::report_errors();
|
||||
}
|
||||
Reference in New Issue
Block a user