| 1 | // Copyright 2021 Peter Dimov. |
| 2 | // Distributed under the Boost Software License, Version 1.0. |
| 3 | // http://www.boost.org/LICENSE_1_0.txt |
| 4 | |
| 5 | #include <boost/system/error_code.hpp> |
| 6 | #include <boost/system/system_category.hpp> |
| 7 | #include <boost/system/generic_category.hpp> |
| 8 | #include <boost/core/lightweight_test.hpp> |
| 9 | #include <cerrno> |
| 10 | #include <system_error> |
| 11 | |
| 12 | void f1( std::error_code ec, int value, std::error_category const& category ) |
| 13 | { |
| 14 | BOOST_TEST_EQ( ec.value(), value ); |
| 15 | BOOST_TEST_EQ( &ec.category(), &category ); |
| 16 | } |
| 17 | |
| 18 | void f2( std::error_code const& ec, int value, std::error_category const& category ) |
| 19 | { |
| 20 | BOOST_TEST_EQ( ec.value(), value ); |
| 21 | BOOST_TEST_EQ( &ec.category(), &category ); |
| 22 | } |
| 23 | |
| 24 | int main() |
| 25 | { |
| 26 | { |
| 27 | boost::system::error_code e1; |
| 28 | boost::system::error_code e2( e1 ); |
| 29 | |
| 30 | f1( ec: e1, value: e1.value(), category: e1.category() ); |
| 31 | #if !defined(BOOST_SYSTEM_CLANG_6) |
| 32 | f2( ec: e1, value: e1.value(), category: e1.category() ); |
| 33 | #endif |
| 34 | |
| 35 | BOOST_TEST_EQ( e1, e2 ); |
| 36 | } |
| 37 | |
| 38 | { |
| 39 | boost::system::error_code e1( 0, boost::system::system_category() ); |
| 40 | boost::system::error_code e2( e1 ); |
| 41 | |
| 42 | f1( ec: e1, value: e1.value(), category: e1.category() ); |
| 43 | #if !defined(BOOST_SYSTEM_CLANG_6) |
| 44 | f2( ec: e1, value: e1.value(), category: e1.category() ); |
| 45 | #endif |
| 46 | |
| 47 | BOOST_TEST_EQ( e1, e2 ); |
| 48 | } |
| 49 | |
| 50 | { |
| 51 | boost::system::error_code e1( 5, boost::system::system_category() ); |
| 52 | boost::system::error_code e2( e1 ); |
| 53 | |
| 54 | f1( ec: e1, value: e1.value(), category: e1.category() ); |
| 55 | #if !defined(BOOST_SYSTEM_CLANG_6) |
| 56 | f2( ec: e1, value: e1.value(), category: e1.category() ); |
| 57 | #endif |
| 58 | |
| 59 | BOOST_TEST_EQ( e1, e2 ); |
| 60 | } |
| 61 | |
| 62 | { |
| 63 | boost::system::error_code e1( 0, boost::system::generic_category() ); |
| 64 | boost::system::error_code e2( e1 ); |
| 65 | |
| 66 | f1( ec: e1, value: e1.value(), category: e1.category() ); |
| 67 | #if !defined(BOOST_SYSTEM_CLANG_6) |
| 68 | f2( ec: e1, value: e1.value(), category: e1.category() ); |
| 69 | #endif |
| 70 | |
| 71 | BOOST_TEST_EQ( e1, e2 ); |
| 72 | } |
| 73 | |
| 74 | { |
| 75 | boost::system::error_code e1( ENOENT, boost::system::generic_category() ); |
| 76 | boost::system::error_code e2( e1 ); |
| 77 | |
| 78 | f1( ec: e1, value: e1.value(), category: e1.category() ); |
| 79 | #if !defined(BOOST_SYSTEM_CLANG_6) |
| 80 | f2( ec: e1, value: e1.value(), category: e1.category() ); |
| 81 | #endif |
| 82 | |
| 83 | BOOST_TEST_EQ( e1, e2 ); |
| 84 | } |
| 85 | |
| 86 | return boost::report_errors(); |
| 87 | } |
| 88 | |