mirror of
https://github.com/boostorg/system.git
synced 2025-12-25 16:28:05 +01:00
Compare commits
2 Commits
feature/is
...
feature/is
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
32bf67f748 | ||
|
|
5d15aa1267 |
@@ -403,7 +403,12 @@ public:
|
||||
{
|
||||
#if defined(BOOST_SYSTEM_HAS_SYSTEM_ERROR)
|
||||
|
||||
if( lhs.lc_flags_ == 1 && rhs.lc_flags_ == 1 )
|
||||
bool s1 = lhs.lc_flags_ == 1;
|
||||
bool s2 = rhs.lc_flags_ == 1;
|
||||
|
||||
if( s1 != s2 ) return false;
|
||||
|
||||
if( s1 && s2 )
|
||||
{
|
||||
std::error_code const& e1 = *reinterpret_cast<std::error_code const*>( lhs.d2_ );
|
||||
std::error_code const& e2 = *reinterpret_cast<std::error_code const*>( rhs.d2_ );
|
||||
@@ -421,7 +426,13 @@ public:
|
||||
{
|
||||
#if defined(BOOST_SYSTEM_HAS_SYSTEM_ERROR)
|
||||
|
||||
if( lhs.lc_flags_ == 1 && rhs.lc_flags_ == 1 )
|
||||
bool s1 = lhs.lc_flags_ == 1;
|
||||
bool s2 = rhs.lc_flags_ == 1;
|
||||
|
||||
if( s1 < s2 ) return true;
|
||||
if( s2 < s1 ) return false;
|
||||
|
||||
if( s1 && s2 )
|
||||
{
|
||||
std::error_code const& e1 = *reinterpret_cast<std::error_code const*>( lhs.d2_ );
|
||||
std::error_code const& e2 = *reinterpret_cast<std::error_code const*>( rhs.d2_ );
|
||||
|
||||
@@ -132,6 +132,8 @@ boost_test(TYPE run SOURCES std_interop_test15.cpp)
|
||||
|
||||
boost_test(TYPE run SOURCES win32_generic_test.cpp)
|
||||
|
||||
boost_test(TYPE run SOURCES ec_hash_value_test.cpp)
|
||||
|
||||
# result
|
||||
|
||||
set(BOOST_TEST_COMPILE_FEATURES cxx_std_11)
|
||||
|
||||
@@ -160,6 +160,8 @@ run std_interop_test15.cpp ;
|
||||
|
||||
run win32_generic_test.cpp ;
|
||||
|
||||
run ec_hash_value_test.cpp ;
|
||||
|
||||
# result
|
||||
|
||||
import ../../config/checks/config : requires ;
|
||||
|
||||
132
test/ec_hash_value_test.cpp
Normal file
132
test/ec_hash_value_test.cpp
Normal file
@@ -0,0 +1,132 @@
|
||||
// Copyright 2022 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/system/generic_category.hpp>
|
||||
#include <boost/system/system_category.hpp>
|
||||
#include <boost/core/lightweight_test.hpp>
|
||||
#include <cerrno>
|
||||
#if defined(BOOST_SYSTEM_HAS_SYSTEM_ERROR)
|
||||
#include <system_error>
|
||||
#endif
|
||||
|
||||
namespace sys = boost::system;
|
||||
|
||||
int main()
|
||||
{
|
||||
// normal against normal (equal, system)
|
||||
{
|
||||
sys::error_code e2( 0, sys::system_category() );
|
||||
sys::error_code e3( e2.value(), e2.category() );
|
||||
|
||||
BOOST_TEST( e2 != e3 || hash_value( e2 ) == hash_value( e3 ) );
|
||||
BOOST_TEST( e2 == e3 || hash_value( e2 ) != hash_value( e3 ) );
|
||||
}
|
||||
|
||||
// normal against normal (equal, generic)
|
||||
{
|
||||
sys::error_code e2( EINVAL, sys::generic_category() );
|
||||
sys::error_code e3( e2.value(), e2.category() );
|
||||
|
||||
BOOST_TEST( e2 != e3 || hash_value( e2 ) == hash_value( e3 ) );
|
||||
BOOST_TEST( e2 == e3 || hash_value( e2 ) != hash_value( e3 ) );
|
||||
}
|
||||
|
||||
// normal against normal (inequal, value, generic)
|
||||
{
|
||||
sys::error_code e2( 0, sys::generic_category() );
|
||||
sys::error_code e3( EINVAL, sys::generic_category() );
|
||||
|
||||
BOOST_TEST( e2 != e3 || hash_value( e2 ) == hash_value( e3 ) );
|
||||
BOOST_TEST( e2 == e3 || hash_value( e2 ) != hash_value( e3 ) );
|
||||
}
|
||||
|
||||
// normal against normal (inequal, value, system)
|
||||
{
|
||||
sys::error_code e2( 1, sys::system_category() );
|
||||
sys::error_code e3( 2, sys::system_category() );
|
||||
|
||||
BOOST_TEST( e2 != e3 || hash_value( e2 ) == hash_value( e3 ) );
|
||||
BOOST_TEST( e2 == e3 || hash_value( e2 ) != hash_value( e3 ) );
|
||||
}
|
||||
|
||||
// normal against normal (inequal, category)
|
||||
{
|
||||
sys::error_code e2( 0, sys::system_category() );
|
||||
sys::error_code e3( 0, sys::generic_category() );
|
||||
|
||||
BOOST_TEST( e2 != e3 || hash_value( e2 ) == hash_value( e3 ) );
|
||||
BOOST_TEST( e2 == e3 || hash_value( e2 ) != hash_value( e3 ) );
|
||||
}
|
||||
|
||||
// empty against normal
|
||||
{
|
||||
sys::error_code e2;
|
||||
sys::error_code e3( e2.value(), e2.category() );
|
||||
|
||||
BOOST_TEST( e2 != e3 || hash_value( e2 ) == hash_value( e3 ) );
|
||||
BOOST_TEST( e2 == e3 || hash_value( e2 ) != hash_value( e3 ) );
|
||||
}
|
||||
|
||||
#if defined(BOOST_SYSTEM_HAS_SYSTEM_ERROR)
|
||||
|
||||
// std:: wrapping against normal
|
||||
{
|
||||
std::error_code e1( EINVAL, std::generic_category() );
|
||||
|
||||
sys::error_code e2( e1 );
|
||||
sys::error_code e3( e2.value(), e2.category() );
|
||||
|
||||
BOOST_TEST( e2 != e3 || hash_value( e2 ) == hash_value( e3 ) );
|
||||
BOOST_TEST( e2 == e3 || hash_value( e2 ) != hash_value( e3 ) );
|
||||
}
|
||||
|
||||
// empty against wrapping std:: empty
|
||||
{
|
||||
std::error_code e1;
|
||||
|
||||
sys::error_code e2( e1 );
|
||||
sys::error_code e3;
|
||||
|
||||
BOOST_TEST( e2 != e3 || hash_value( e2 ) == hash_value( e3 ) );
|
||||
BOOST_TEST( e2 == e3 || hash_value( e2 ) != hash_value( e3 ) );
|
||||
}
|
||||
|
||||
// empty against roundtrip via std
|
||||
{
|
||||
sys::error_code e2;
|
||||
|
||||
std::error_code e1( e2 );
|
||||
sys::error_code e3( e1 );
|
||||
|
||||
BOOST_TEST( e2 != e3 || hash_value( e2 ) == hash_value( e3 ) );
|
||||
BOOST_TEST( e2 == e3 || hash_value( e2 ) != hash_value( e3 ) );
|
||||
}
|
||||
|
||||
// normal/generic against roundtrip via std
|
||||
{
|
||||
sys::error_code e2( EINVAL, boost::system::generic_category() );
|
||||
|
||||
std::error_code e1( e2 );
|
||||
sys::error_code e3( e1 );
|
||||
|
||||
BOOST_TEST( e2 != e3 || hash_value( e2 ) == hash_value( e3 ) );
|
||||
BOOST_TEST( e2 == e3 || hash_value( e2 ) != hash_value( e3 ) );
|
||||
}
|
||||
|
||||
// normal/system against roundtrip via std
|
||||
{
|
||||
sys::error_code e2( 0, boost::system::system_category() );
|
||||
|
||||
std::error_code e1( e2 );
|
||||
sys::error_code e3( e1 );
|
||||
|
||||
BOOST_TEST( e2 != e3 || hash_value( e2 ) == hash_value( e3 ) );
|
||||
BOOST_TEST( e2 == e3 || hash_value( e2 ) != hash_value( e3 ) );
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
return boost::report_errors();
|
||||
}
|
||||
Reference in New Issue
Block a user