mirror of
https://github.com/boostorg/system.git
synced 2025-07-30 20:47:14 +02:00
Update system_error::what to use error_code::what
This commit is contained in:
@ -35,17 +35,7 @@ private:
|
|||||||
r += ": ";
|
r += ": ";
|
||||||
}
|
}
|
||||||
|
|
||||||
r += ec.message();
|
r += ec.what();
|
||||||
|
|
||||||
if( ec.has_location() )
|
|
||||||
{
|
|
||||||
r += " [";
|
|
||||||
r += ec.to_string();
|
|
||||||
r += " at ";
|
|
||||||
r += ec.location().to_string();
|
|
||||||
r += "]";
|
|
||||||
}
|
|
||||||
|
|
||||||
return r;
|
return r;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -108,6 +108,7 @@ boost_test(TYPE run SOURCES std_interop_test10.cpp)
|
|||||||
|
|
||||||
boost_test(TYPE run SOURCES ec_location_test2.cpp)
|
boost_test(TYPE run SOURCES ec_location_test2.cpp)
|
||||||
boost_test(TYPE run SOURCES ec_what_test.cpp)
|
boost_test(TYPE run SOURCES ec_what_test.cpp)
|
||||||
|
boost_test(TYPE run SOURCES system_error_test3.cpp)
|
||||||
|
|
||||||
# result
|
# result
|
||||||
|
|
||||||
|
@ -130,6 +130,7 @@ run std_interop_test10.cpp ;
|
|||||||
|
|
||||||
run ec_location_test2.cpp ;
|
run ec_location_test2.cpp ;
|
||||||
run ec_what_test.cpp ;
|
run ec_what_test.cpp ;
|
||||||
|
run system_error_test3.cpp ;
|
||||||
|
|
||||||
# result
|
# result
|
||||||
|
|
||||||
|
@ -37,7 +37,7 @@ int main()
|
|||||||
boost::system::system_error x( bc, "prefix" );
|
boost::system::system_error x( bc, "prefix" );
|
||||||
|
|
||||||
BOOST_TEST_EQ( x.code(), bc );
|
BOOST_TEST_EQ( x.code(), bc );
|
||||||
BOOST_TEST_EQ( std::string( x.what() ), "prefix: " + bc.message() );
|
BOOST_TEST_EQ( std::string( x.what() ), "prefix: " + bc.what() );
|
||||||
|
|
||||||
return boost::report_errors();
|
return boost::report_errors();
|
||||||
}
|
}
|
||||||
|
@ -81,27 +81,25 @@ int main( int, char *[] )
|
|||||||
system_error c6_0( 0, system_category(), "c6_0" );
|
system_error c6_0( 0, system_category(), "c6_0" );
|
||||||
system_error c6_1( 1, system_category(), "c6_1" );
|
system_error c6_1( 1, system_category(), "c6_1" );
|
||||||
|
|
||||||
TEST( c1_0, 0, "The operation completed successfully" );
|
TEST( c1_0, 0, "The operation completed successfully [system:0]" );
|
||||||
TEST( c1_1, 1, "Incorrect function" );
|
TEST( c1_1, 1, "Incorrect function [system:1]" );
|
||||||
TEST( c1_2u, 2, "The system cannot find the file specified" );
|
TEST( c1_2u, 2, "The system cannot find the file specified [system:2]" );
|
||||||
|
|
||||||
TEST( c2_0, 0, "c2_0: The operation completed successfully" );
|
TEST( c2_0, 0, "c2_0: The operation completed successfully [system:0]" );
|
||||||
TEST( c2_1, 1, "c2_1: Incorrect function" );
|
TEST( c2_1, 1, "c2_1: Incorrect function [system:1]" );
|
||||||
|
|
||||||
TEST( c3_0, 0, "c3_0: The operation completed successfully" );
|
TEST( c3_0, 0, "c3_0: The operation completed successfully [system:0]" );
|
||||||
TEST( c3_1, 1, "c3_1: Incorrect function" );
|
TEST( c3_1, 1, "c3_1: Incorrect function [system:1]" );
|
||||||
|
|
||||||
TEST( c4_0, 0, "The operation completed successfully" );
|
TEST( c4_0, 0, "The operation completed successfully [system:0]" );
|
||||||
TEST( c4_1, 1, "Incorrect function" );
|
TEST( c4_1, 1, "Incorrect function [system:1]" );
|
||||||
TEST( c4_2u, 2, "The system cannot find the file specified" );
|
TEST( c4_2u, 2, "The system cannot find the file specified [system:2]" );
|
||||||
|
|
||||||
TEST( c5_0, 0, "c5_0: The operation completed successfully" );
|
TEST( c5_0, 0, "c5_0: The operation completed successfully [system:0]" );
|
||||||
TEST( c5_1, 1, "c5_1: Incorrect function" );
|
TEST( c5_1, 1, "c5_1: Incorrect function [system:1]" );
|
||||||
|
|
||||||
TEST( c6_0, 0, "c6_0: The operation completed successfully" );
|
TEST( c6_0, 0, "c6_0: The operation completed successfully [system:0]" );
|
||||||
TEST( c6_1, 1, "c6_1: Incorrect function" );
|
TEST( c6_1, 1, "c6_1: Incorrect function [system:1]" );
|
||||||
|
|
||||||
return ::boost::report_errors();
|
return ::boost::report_errors();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
42
test/system_error_test3.cpp
Normal file
42
test/system_error_test3.cpp
Normal file
@ -0,0 +1,42 @@
|
|||||||
|
// 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 );
|
||||||
|
|
||||||
|
BOOST_TEST_EQ( std::string( x1.what() ), ec.what() );
|
||||||
|
}
|
||||||
|
|
||||||
|
{
|
||||||
|
BOOST_STATIC_CONSTEXPR boost::source_location loc = BOOST_CURRENT_LOCATION;
|
||||||
|
|
||||||
|
sys::error_code ec( 5, sys::system_category(), &loc );
|
||||||
|
sys::system_error x1( ec, "prefix" );
|
||||||
|
|
||||||
|
BOOST_TEST_EQ( std::string( x1.what() ), "prefix: " + ec.what() );
|
||||||
|
}
|
||||||
|
|
||||||
|
{
|
||||||
|
sys::system_error x1( 5, sys::generic_category() );
|
||||||
|
|
||||||
|
BOOST_TEST_EQ( std::string( x1.what() ), sys::error_code( 5, sys::generic_category() ).what() );
|
||||||
|
}
|
||||||
|
|
||||||
|
{
|
||||||
|
sys::system_error x1( 5, sys::system_category(), "prefix" );
|
||||||
|
|
||||||
|
BOOST_TEST_EQ( std::string( x1.what() ), "prefix: " + sys::error_code( 5, sys::system_category() ).what() );
|
||||||
|
}
|
||||||
|
|
||||||
|
return boost::report_errors();
|
||||||
|
}
|
Reference in New Issue
Block a user