mirror of
https://github.com/boostorg/system.git
synced 2025-10-18 02:15:24 +02:00
Rework error_code for better std interop
This commit is contained in:
63
test/std_interop_test3.cpp
Normal file
63
test/std_interop_test3.cpp
Normal file
@@ -0,0 +1,63 @@
|
||||
// Copyright 2021 Peter Dimov.
|
||||
// Distributed under the Boost Software License, Version 1.0.
|
||||
// http://www.boost.org/LICENSE_1_0.txt
|
||||
|
||||
#include <boost/system/error_code.hpp>
|
||||
#include <boost/core/lightweight_test.hpp>
|
||||
#include <boost/config/pragma_message.hpp>
|
||||
#include <cerrno>
|
||||
|
||||
#if !defined(BOOST_SYSTEM_HAS_SYSTEM_ERROR)
|
||||
|
||||
BOOST_PRAGMA_MESSAGE( "BOOST_SYSTEM_HAS_SYSTEM_ERROR not defined, test will be skipped" )
|
||||
int main() {}
|
||||
|
||||
#else
|
||||
|
||||
#include <system_error>
|
||||
|
||||
int main()
|
||||
{
|
||||
{
|
||||
std::error_code e1;
|
||||
boost::system::error_code e2 = e1;
|
||||
std::error_code e3 = e2;
|
||||
|
||||
BOOST_TEST_EQ( e1, e3 );
|
||||
}
|
||||
|
||||
{
|
||||
std::error_code e1( 5, std::system_category() );
|
||||
boost::system::error_code e2 = e1;
|
||||
std::error_code e3 = e2;
|
||||
|
||||
BOOST_TEST_EQ( e1, e3 );
|
||||
}
|
||||
|
||||
{
|
||||
std::error_code e1( 0, std::generic_category() );
|
||||
boost::system::error_code e2 = e1;
|
||||
std::error_code e3 = e2;
|
||||
|
||||
BOOST_TEST_EQ( e1, e3 );
|
||||
}
|
||||
|
||||
{
|
||||
std::error_code e1( ENOENT, std::generic_category() );
|
||||
boost::system::error_code e2 = e1;
|
||||
std::error_code e3 = e2;
|
||||
|
||||
BOOST_TEST_EQ( e1, e3 );
|
||||
}
|
||||
|
||||
{
|
||||
boost::system::error_code e2 = make_error_code( std::errc::no_such_file_or_directory );
|
||||
std::error_code e3 = e2;
|
||||
|
||||
BOOST_TEST_EQ( make_error_code( std::errc::no_such_file_or_directory ), e3 );
|
||||
}
|
||||
|
||||
return boost::report_errors();
|
||||
}
|
||||
|
||||
#endif
|
Reference in New Issue
Block a user