]> git.proxmox.com Git - ceph.git/blob - ceph/src/boost/libs/system/test/std_interop_test2.cpp
update ceph source to reef 18.1.2
[ceph.git] / ceph / src / boost / libs / system / test / std_interop_test2.cpp
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 <boost/config/pragma_message.hpp>
10 #include <cerrno>
11
12 #if !defined(BOOST_SYSTEM_HAS_SYSTEM_ERROR)
13
14 BOOST_PRAGMA_MESSAGE( "BOOST_SYSTEM_HAS_SYSTEM_ERROR not defined, test will be skipped" )
15 int main() {}
16
17 #else
18
19 #include <system_error>
20
21 void f1( std::error_code ec, int value, std::error_category const& category )
22 {
23 BOOST_TEST_EQ( ec.value(), value );
24 BOOST_TEST_EQ( &ec.category(), &category );
25 }
26
27 void f2( std::error_code const& ec, int value, std::error_category const& category )
28 {
29 BOOST_TEST_EQ( ec.value(), value );
30 BOOST_TEST_EQ( &ec.category(), &category );
31 }
32
33 int main()
34 {
35 {
36 boost::system::error_code e1;
37 boost::system::error_code e2( e1 );
38
39 f1( e1, e1.value(), e1.category() );
40 #if !defined(BOOST_SYSTEM_CLANG_6)
41 f2( e1, e1.value(), e1.category() );
42 #endif
43
44 BOOST_TEST_EQ( e1, e2 );
45 }
46
47 {
48 boost::system::error_code e1( 0, boost::system::system_category() );
49 boost::system::error_code e2( e1 );
50
51 f1( e1, e1.value(), e1.category() );
52 #if !defined(BOOST_SYSTEM_CLANG_6)
53 f2( e1, e1.value(), e1.category() );
54 #endif
55
56 BOOST_TEST_EQ( e1, e2 );
57 }
58
59 {
60 boost::system::error_code e1( 5, boost::system::system_category() );
61 boost::system::error_code e2( e1 );
62
63 f1( e1, e1.value(), e1.category() );
64 #if !defined(BOOST_SYSTEM_CLANG_6)
65 f2( e1, e1.value(), e1.category() );
66 #endif
67
68 BOOST_TEST_EQ( e1, e2 );
69 }
70
71 {
72 boost::system::error_code e1( 0, boost::system::generic_category() );
73 boost::system::error_code e2( e1 );
74
75 f1( e1, e1.value(), e1.category() );
76 #if !defined(BOOST_SYSTEM_CLANG_6)
77 f2( e1, e1.value(), e1.category() );
78 #endif
79
80 BOOST_TEST_EQ( e1, e2 );
81 }
82
83 {
84 boost::system::error_code e1( ENOENT, boost::system::generic_category() );
85 boost::system::error_code e2( e1 );
86
87 f1( e1, e1.value(), e1.category() );
88 #if !defined(BOOST_SYSTEM_CLANG_6)
89 f2( e1, e1.value(), e1.category() );
90 #endif
91
92 BOOST_TEST_EQ( e1, e2 );
93 }
94
95 return boost::report_errors();
96 }
97
98 #endif